@acedatacloud/nexior 3.358.0 → 3.360.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (426) hide show
  1. package/dist/assets/{ApiCodeButton-CiNqmFYp.js → ApiCodeButton-Dh0e3VYw.js} +1 -1
  2. package/dist/assets/{ApiCodeDialog-z5vXc7Xi.js → ApiCodeDialog-DpBy84t3.js} +2 -2
  3. package/dist/assets/{Artifacts-BgCwr5i5.js → Artifacts-BmyA60t9.js} +1 -1
  4. package/dist/assets/{AskUserQuestionCard-c9PYBcSn.js → AskUserQuestionCard-B5MKrPzt.js} +1 -1
  5. package/dist/assets/{AudioPreview-uUWI_oVU.js → AudioPreview-BGWgOrNN.js} +1 -1
  6. package/dist/assets/{Auth-D7rXWt2c.js → Auth-xS-EuHJA.js} +1 -1
  7. package/dist/assets/{Bare-QIH-zKDl.js → Bare-D71gSqKE.js} +1 -1
  8. package/dist/assets/{BotPlaceholder-CDv27X3P.js → BotPlaceholder-D55egP4z.js} +1 -1
  9. package/dist/assets/{BottomFooter-CgjUhGFP.js → BottomFooter-DA9b04xf.js} +1 -1
  10. package/dist/assets/{BrowseConnectors-1biG2Qgb.js → BrowseConnectors-D8Db2Sau.js} +1 -1
  11. package/dist/assets/BrowserPairingDialog-FTM3lWFY.css +1 -0
  12. package/dist/assets/BrowserPairingDialog-XYsGv__q.js +1 -0
  13. package/dist/assets/{Callback-CgQSpuL1.js → Callback-hNDdYeqS.js} +1 -1
  14. package/dist/assets/{CodeSnippet-CBWP_eZL.js → CodeSnippet-Ty_4_CTP.js} +1 -1
  15. package/dist/assets/{Console-XKqCKdZn.js → Console-DjOjxwZQ.js} +1 -1
  16. package/dist/assets/{Consumption-Byk7yTVz.js → Consumption-DBu0ktO9.js} +1 -1
  17. package/dist/assets/Conversation-CRqJWOb-.js +1 -0
  18. package/dist/assets/{Conversation-D8Wm_Zri.js → Conversation-DsJRUcLN.js} +1 -1
  19. package/dist/assets/{Conversation-CA6VWzAh.css → Conversation-lrKxdgf9.css} +1 -1
  20. package/dist/assets/CopyToClipboard-CBPEp-6G.css +1 -0
  21. package/dist/assets/CopyToClipboard-CGwG-ynF.js +1 -0
  22. package/dist/assets/Detail-CN4qBrqa.js +2 -0
  23. package/dist/assets/Extra-Bk8BGvR7.js +1 -0
  24. package/dist/assets/{FilePreview-B2BrZCN4.js → FilePreview-CNpEeq4z.js} +1 -1
  25. package/dist/assets/{Hailuo-C2sgwciH.js → Hailuo-Bu85S4kU.js} +1 -1
  26. package/dist/assets/{History-DwzwIr-b.js → History-CV0kfdmB.js} +1 -1
  27. package/dist/assets/{ImagePreview-ESZQ89R1.js → ImagePreview-COEccbcx.js} +1 -1
  28. package/dist/assets/{ImageWrapper-ByG7FJxY.js → ImageWrapper-wYnQ-6uQ.js} +1 -1
  29. package/dist/assets/{Index-Tx5AB9O4.css → Index-B-iCrV5d.css} +1 -1
  30. package/dist/assets/Index-BBuwMXxr.js +1 -0
  31. package/dist/assets/{Index-CirWkDBR.js → Index-BDp2zTIt2.js} +1 -1
  32. package/dist/assets/{Index-CQX-mX8l.js → Index-BKwWNdkD.js} +1 -1
  33. package/dist/assets/Index-BS-CVfGF.js +1 -0
  34. package/dist/assets/Index-BTWcJusZ.js +1 -0
  35. package/dist/assets/{Index-alCHtqWd.js → Index-BU5zipXg.js} +1 -1
  36. package/dist/assets/{Index-YcZrDvKK.js → Index-BUf9FFq2.js} +1 -1
  37. package/dist/assets/{Index-D2m8ATNJ.js → Index-BVLVBIEM.js} +2 -2
  38. package/dist/assets/Index-BZD5EOlO.js +1 -0
  39. package/dist/assets/Index-B_dscbOL.js +1 -0
  40. package/dist/assets/{Index-7zEoaAQu.css → Index-BbxAE6Dv.css} +1 -1
  41. package/dist/assets/Index-BsxaSTgq.js +1 -0
  42. package/dist/assets/{Index-BSvC21Tn.js → Index-BvaN5lwK.js} +1 -1
  43. package/dist/assets/Index-Bxb-zaau.js +1 -0
  44. package/dist/assets/Index-C6ZohPAI.js +1 -0
  45. package/dist/assets/Index-C7MiXUYB.js +1 -0
  46. package/dist/assets/{Index-Dh6I-L3l.js → Index-C9Ku9BKB.js} +1 -1
  47. package/dist/assets/{Index-D8yq23DF.js → Index-CE39V6gV.js} +1 -1
  48. package/dist/assets/Index-CTP6z3HC.js +1 -0
  49. package/dist/assets/Index-CY0jqHV_.js +1 -0
  50. package/dist/assets/Index-Cd8MO61v.js +1 -0
  51. package/dist/assets/Index-CkbP3e0s.js +1 -0
  52. package/dist/assets/{Index-C8I0_0Jk.css → Index-CsbX_HB_.css} +1 -1
  53. package/dist/assets/{Index-DSE4_905.js → Index-Ctaf6i3t.js} +1 -1
  54. package/dist/assets/{Index-CRHRqEjI.js → Index-Cwmg7dN4.js} +1 -1
  55. package/dist/assets/{Index-B-nXto0t.css → Index-D14ip-eO.css} +1 -1
  56. package/dist/assets/Index-D3OWaY9K.js +1 -0
  57. package/dist/assets/{Index-C7p8OXFc.css → Index-DMFbiTzd.css} +1 -1
  58. package/dist/assets/{Index-Cb9NGvy_.css → Index-DMm2-tI2.css} +1 -1
  59. package/dist/assets/Index-DVNFZg1_.js +1 -0
  60. package/dist/assets/Index-DgvHJ1Q0.js +1 -0
  61. package/dist/assets/Index-Dpb-f_TW.js +1 -0
  62. package/dist/assets/Index-DyZjYpkO.js +1 -0
  63. package/dist/assets/Index-IQYM4Npt.js +1 -0
  64. package/dist/assets/{Index-CiwW7_xF.js → Index-e9yQNtrh.js} +1 -1
  65. package/dist/assets/Index-eQOWN-kj.js +1 -0
  66. package/dist/assets/{Index-CFip9nIj.css → Index-fWSMR3_L.css} +1 -1
  67. package/dist/assets/Index-i6l_Ug1h.js +1 -0
  68. package/dist/assets/{Index-D53QUcJW.css → Index-kkW-6KV5.css} +1 -1
  69. package/dist/assets/Index-nHdc4bFS.js +1 -0
  70. package/dist/assets/Index-oeqRy6sE.js +1 -0
  71. package/dist/assets/{Index-CIZ0JZtW.css → Index-q3hfYQ5i.css} +1 -1
  72. package/dist/assets/{Index-CIe21BJa.css → Index-sP0w7E5Y.css} +1 -1
  73. package/dist/assets/{Index-D8Zqoj4n.js → Index-vwDzZvRr.js} +1 -1
  74. package/dist/assets/{Invitees-DV3QywcL.js → Invitees-DK_TIIfN.js} +1 -1
  75. package/dist/assets/List-BJC4kROk.css +1 -0
  76. package/dist/assets/List-CBWKgk0a.js +1 -0
  77. package/dist/assets/List-CRr6bWE9.js +1 -0
  78. package/dist/assets/List-DZk_5yHu.css +1 -0
  79. package/dist/assets/List-f729hgqX.js +1 -0
  80. package/dist/assets/{LocalTools-B5ToSxwe.js → LocalTools-BMvTGYcX.js} +1 -1
  81. package/dist/assets/{LocalTools-BhSf8_Y4.js → LocalTools-CKgauRfj.js} +2 -2
  82. package/dist/assets/Logo-fKY-0-aK.css +1 -0
  83. package/dist/assets/Logo-nwdT-9cQ.js +1 -0
  84. package/dist/assets/Main-BK7rF6os.js +1 -0
  85. package/dist/assets/Main-CUxrmxme.css +1 -0
  86. package/dist/assets/{Message-Dr93wREd.css → Message-D6tWmQRB.css} +1 -1
  87. package/dist/assets/Message-tz2f1Hh7.js +3 -0
  88. package/dist/assets/Model-BSgvWknV.js +1 -0
  89. package/dist/assets/Navigator-ByxI29p7.js +8 -0
  90. package/dist/assets/Navigator-DJAPAK_Y.css +1 -0
  91. package/dist/assets/{NotFound-BopsMgLM.js → NotFound-p5BzZGCL.js} +1 -1
  92. package/dist/assets/{PageHeader-Cd9mBW43.js → PageHeader-DwqWzeFN.js} +1 -1
  93. package/dist/assets/Pay-Cbj76O0D.js +1 -0
  94. package/dist/assets/{Player-DQNg6dOq.js → Player-BVXbVXzD.js} +1 -1
  95. package/dist/assets/{Poivelle-0k_mctcv.js → Poivelle-DBNnTjly.js} +1 -1
  96. package/dist/assets/{RealtimeCall-BgkQdni0.js → RealtimeCall-B03pDx80.js} +1 -1
  97. package/dist/assets/{ReportButton-CuTsbpH1.js → ReportButton-DTNrYuaU.js} +1 -1
  98. package/dist/assets/{ReportDialog-dN-kkVrJ.js → ReportDialog-BycYyA98.js} +1 -1
  99. package/dist/assets/ScenarioPaymentMode-D5rkIuHw.js +1 -0
  100. package/dist/assets/ScheduledTasks-Bw4xzuMD.css +1 -0
  101. package/dist/assets/ScheduledTasks-De_sRGrg.js +2 -0
  102. package/dist/assets/{SolanaWalletPickerDialog-CS7bSwXe.js → SolanaWalletPickerDialog-DJXeSkon.js} +1 -1
  103. package/dist/assets/{Status-BDIpm7RB.css → Status-Dqmgq95G.css} +1 -1
  104. package/dist/assets/Status-qFA8vAiM.js +1 -0
  105. package/dist/assets/{Subscribe-zhWEFj1j.js → Subscribe-8H7BrvN6.js} +1 -1
  106. package/dist/assets/{TabSwitcher-C4UtlgZ0.js → TabSwitcher-AuKNH5HD.js} +1 -1
  107. package/dist/assets/Tts-B-_FnarM.js +1 -0
  108. package/dist/assets/{VideoPlayer-B9ZoxGwN.js → VideoPlayer-Dlr4zmTe.js} +1 -1
  109. package/dist/assets/{VideoPreview-D0f8om32.js → VideoPreview-CYw6jPbC.js} +1 -1
  110. package/dist/assets/arrow-down-oGu5Mf6h.js +1 -0
  111. package/dist/assets/{arrow-down-wide-narrow-D9hT9P8T.js → arrow-down-wide-narrow-N9PI6aG3.js} +1 -1
  112. package/dist/assets/arrow-left-ChILYj5b.js +1 -0
  113. package/dist/assets/arrow-right-CBi9bCfZ.js +1 -0
  114. package/dist/assets/arrow-up-FlLGQPvk.js +1 -0
  115. package/dist/assets/{authorizeFlow-DjzUZZcO.js → authorizeFlow-BAdD2PFZ.js} +1 -1
  116. package/dist/assets/{avatar-DIY5kVwM.js → avatar-C_mk-bnf.js} +1 -1
  117. package/dist/assets/{basic-C9st9xfO.js → basic-BiSlMG94.js} +1 -1
  118. package/dist/assets/{book-open-89ot7rat.js → book-open-BCLZH-En.js} +1 -1
  119. package/dist/assets/{box-C1K_05R1.js → box-hvoqdbSL.js} +1 -1
  120. package/dist/assets/{boxes-CVfQGj6z.js → boxes-C3OmL03p.js} +1 -1
  121. package/dist/assets/{brain-DFSeKAZC.js → brain-BanKJA0f.js} +1 -1
  122. package/dist/assets/{chart-no-axes-combined-k3QiYa3s.js → chart-no-axes-combined-BO2W5bO8.js} +1 -1
  123. package/dist/assets/{chat-CPepUbBA.js → chat-CLjz6JEm.js} +1 -1
  124. package/dist/assets/{chat-CPyDS1s8.js → chat-CXkcYUKq.js} +1 -1
  125. package/dist/assets/{chat-BY9DKfAi.js → chat-CcSpUgkY.js} +1 -1
  126. package/dist/assets/{chat-yJqk9kt9.js → chat-CgPWqT6E.js} +1 -1
  127. package/dist/assets/{chat-duM8vKdA.js → chat-D91Hmjlb.js} +1 -1
  128. package/dist/assets/{chat-DPYlE44u.js → chat-DEkZV9iK.js} +1 -1
  129. package/dist/assets/{chat-CA0MD_st.js → chat-DIpceuMx.js} +1 -1
  130. package/dist/assets/{chat-C1uZputZ.js → chat-DPB9kvDA.js} +1 -1
  131. package/dist/assets/{chat-tfvZdHmk.js → chat-DjqHq4_f.js} +1 -1
  132. package/dist/assets/{chat-DsACa9Pk.js → chat-DrKLvU2W.js} +1 -1
  133. package/dist/assets/{chat-CFPaNnVM.js → chat-Dtw60MWq.js} +1 -1
  134. package/dist/assets/{chat-BbW_31UJ.js → chat-ElsfXAuZ.js} +1 -1
  135. package/dist/assets/{chat-CwJDPmon.js → chat-NA5rrX_r.js} +1 -1
  136. package/dist/assets/{chat-C-7WVcbW.js → chat-WG_nIFDy.js} +1 -1
  137. package/dist/assets/{chat-CmjlhXy_.js → chat-geiX4yJF.js} +1 -1
  138. package/dist/assets/{chat-D0orhGlF.js → chat-hwzsraaF.js} +1 -1
  139. package/dist/assets/{chat-DpRbp8uT.js → chat-lMTbLC_k.js} +1 -1
  140. package/dist/assets/{chat-CK9a-_Ni.js → chat-s_gscg0W.js} +1 -1
  141. package/dist/assets/{chat-DCsVMCF2.js → chat-vuR7a0wY.js} +1 -1
  142. package/dist/assets/check-Dp9-eY7h.js +1 -0
  143. package/dist/assets/chevron-down-DXkdjvB0.js +1 -0
  144. package/dist/assets/chevron-right-kh4R7_XG.js +1 -0
  145. package/dist/assets/circle-check-BTdTav-h.js +1 -0
  146. package/dist/assets/{circle-question-mark-C5ETt-Gy.js → circle-question-mark-kiKFln6-.js} +1 -1
  147. package/dist/assets/{clipboard-list-BaOyMkLK.js → clipboard-list-CYUmuvxu.js} +1 -1
  148. package/dist/assets/clock-CTJFRyio.js +1 -0
  149. package/dist/assets/code-COF542pV.js +1 -0
  150. package/dist/assets/codingBridge-CAgfVMcb.js +2 -0
  151. package/dist/assets/{codingBridgeNotify-Djdt8v1B.js → codingBridgeNotify-BGiAuoCE.js} +2 -2
  152. package/dist/assets/{coins-o7-8OSvE.js → coins-BGKsSQIe.js} +1 -1
  153. package/dist/assets/{collapse-B7B33h1p.js → collapse-BynYX4nc.js} +1 -1
  154. package/dist/assets/constants-fPCXwWF5.js +1 -0
  155. package/dist/assets/{copy-CS92scYJ.js → copy-BblyTnYh.js} +1 -1
  156. package/dist/assets/{createTaskActions-DLdbSeB0.js → createTaskActions-yQCYafsg.js} +1 -1
  157. package/dist/assets/{digitalhuman-CRLcje7j.js → digitalhuman-B3cY4kr8.js} +1 -1
  158. package/dist/assets/{dollar-sign-Dp4uO1oi.js → dollar-sign-BqDT_Rax.js} +1 -1
  159. package/dist/assets/{download-BdbUJy-0.js → download-DXGBv4fw.js} +1 -1
  160. package/dist/assets/{drawer-BWJ3_fqW.js → drawer-DeX9ylXe.js} +1 -1
  161. package/dist/assets/{dropdown-gJTX6f0h.js → dropdown-BK1MA18J.js} +1 -1
  162. package/dist/assets/{dropdown--LXlsWOR.js → dropdown-odlCBrK8.js} +1 -1
  163. package/dist/assets/{ellipsis-CGG2t4rN.js → ellipsis-BfbDX1Im.js} +1 -1
  164. package/dist/assets/{esm-BdQ3IlZD.js → esm-1RRQVG3T.js} +1 -1
  165. package/dist/assets/{esm-BbAKv0FA.js → esm-B-mMn9Pd.js} +1 -1
  166. package/dist/assets/esm-BJF22HMX.js +1 -0
  167. package/dist/assets/esm-BSKlzMOp.js +2 -0
  168. package/dist/assets/{esm-DJYfkLDv.js → esm-Bg4ngxSQ.js} +3 -3
  169. package/dist/assets/{esm-xK2aBMtJ.js → esm-CLs8Pj3d.js} +2 -2
  170. package/dist/assets/{esm-ClxEw27d.js → esm-DdiN3DgH.js} +1 -1
  171. package/dist/assets/{external-link-B_1us9v2.js → external-link-COz3zr-1.js} +1 -1
  172. package/dist/assets/{eye-B7qn04JQ.js → eye-DLHCgXYF.js} +1 -1
  173. package/dist/assets/{file-BexmqRy7.js → file-CBL-Xmkx.js} +1 -1
  174. package/dist/assets/{file-output-BJhPINIu.js → file-output-DzpZPLl7.js} +1 -1
  175. package/dist/assets/{file-text-CJaP1sSt.js → file-text-B9QIn9gw.js} +1 -1
  176. package/dist/assets/{fish-BJ8_esph.js → fish-BsxH3ehp.js} +1 -1
  177. package/dist/assets/{flux-St5avyWB.js → flux-JR4IGKM9.js} +1 -1
  178. package/dist/assets/{folder-CVwMb5LW.js → folder-CmPAcd83.js} +1 -1
  179. package/dist/assets/gauge--DE_s4Eh.js +1 -0
  180. package/dist/assets/{globe-BUY6KxOP.js → globe-BBZQHNRh.js} +1 -1
  181. package/dist/assets/{grokvideo-BzBXIfSN.js → grokvideo-CjPZ_CCZ.js} +1 -1
  182. package/dist/assets/{hailuo-Ehj7U293.js → hailuo-DXHT8umU.js} +1 -1
  183. package/dist/assets/{headphones-DP3Pmamv.js → headphones-CyLzwLZl.js} +1 -1
  184. package/dist/assets/{history-Drg92s0e.js → history-Bc2D9Hc5.js} +1 -1
  185. package/dist/assets/{house-B1TwBkue.js → house-Dc9tgUCb.js} +1 -1
  186. package/dist/assets/{i18n-thhk7vzg.js → i18n-D4nr5BAx.js} +1 -1
  187. package/dist/assets/{image-DLh3kiN0.js → image-BA6QTiGp.js} +1 -1
  188. package/dist/assets/imageRequests-BjSBSzeM.js +1 -0
  189. package/dist/assets/{index-DW-VIENs.css → index-BIRoiZhq.css} +1 -1
  190. package/dist/assets/index-BcBWKKi1.js +570 -0
  191. package/dist/assets/{index.browser.esm-D1e4_8C8.js → index.browser.esm-BGQvgXoe.js} +1 -1
  192. package/dist/assets/{index.es-lCrLu01L.js → index.es-CUm3UI6r.js} +1 -1
  193. package/dist/assets/{info-JrDUNc3f.js → info-BNXVGCAa.js} +1 -1
  194. package/dist/assets/{input-number-C61XfqeG.js → input-number-CulKOOnA.js} +1 -1
  195. package/dist/assets/{key-round-DXFWRMd5.js → key-round-DYDNb3RR.js} +1 -1
  196. package/dist/assets/{kling-DoGXHJTZ.js → kling-Da6f0L-N.js} +1 -1
  197. package/dist/assets/{languages-Cgvplr1A.js → languages-B7T1r5t8.js} +1 -1
  198. package/dist/assets/{laptop-I-UIq9Vj.js → laptop-DitBasOD.js} +1 -1
  199. package/dist/assets/{lightbulb-DQPhT5Fv.js → lightbulb-C2JdRcH3.js} +1 -1
  200. package/dist/assets/{link-DqeldxUU.js → link-DgrmI785.js} +1 -1
  201. package/dist/assets/loader-circle-CwxkgZr9.js +1 -0
  202. package/dist/assets/{lock-Cyg1wnc-.js → lock-CZtQQ55R.js} +1 -1
  203. package/dist/assets/{luma-gSaEzmni.js → luma-c1z5u3Tt.js} +1 -1
  204. package/dist/assets/maestro-C0-TTUwh.js +1 -0
  205. package/dist/assets/maestroLanguages-aThsRCEV.js +1 -0
  206. package/dist/assets/{mail-qBSkwZDU.js → mail-Pp_9c5Tk.js} +1 -1
  207. package/dist/assets/{message-circle-BQZnKfis.js → message-circle-SfeT_L3K.js} +1 -1
  208. package/dist/assets/{mic-DcJCGd7v.js → mic-Cn9RB1yv.js} +1 -1
  209. package/dist/assets/midjourney-CNt_laVt.js +1 -0
  210. package/dist/assets/minimax-zuh2D9dA.js +1 -0
  211. package/dist/assets/{mobileLocalExec-ChALdNhl.js → mobileLocalExec-C6uwUBCb.js} +2 -2
  212. package/dist/assets/{models-D6J60Ang.js → models-C7ANi-Un.js} +1 -1
  213. package/dist/assets/{monitor-C6EmGPtA.js → monitor-CdtULFyZ.js} +1 -1
  214. package/dist/assets/{mouse-pointer-2-BJ6u3j3g.js → mouse-pointer-2-DjsSLxjN.js} +1 -1
  215. package/dist/assets/music-2-CYeSEWCC.js +1 -0
  216. package/dist/assets/{nanobanana-DHdmNSY7.js → nanobanana-CmXIeR9Z.js} +1 -1
  217. package/dist/assets/{omni-DNB82gzr.js → omni-Clsq5ES8.js} +1 -1
  218. package/dist/assets/{openaiimage-67EecuUS.js → openaiimage-Btwxs_mV.js} +1 -1
  219. package/dist/assets/{pagination-D8oUwQ9k.js → pagination-BjoEfHiN.js} +1 -1
  220. package/dist/assets/{pagination-D0KEjXO1.js → pagination-CIX0MX3t.js} +1 -1
  221. package/dist/assets/{pagination-Bh_-G5Ma.js → pagination-Lro_X_rE.js} +1 -1
  222. package/dist/assets/{palette-BP1_UTBm.js → palette-CYvVBbIc.js} +1 -1
  223. package/dist/assets/{paperclip-bLPkbpvE.js → paperclip-CGTRhARZ.js} +1 -1
  224. package/dist/assets/{pause-DThYSFfn.js → pause-BMalNKCY.js} +1 -1
  225. package/dist/assets/{pencil-U1H8ouvD.js → pencil-a0ovNlh4.js} +1 -1
  226. package/dist/assets/{sora-BkHyNKjN.js → pika-BxM6ykVj.js} +1 -1
  227. package/dist/assets/pixverse-CPpfOOZO.js +1 -0
  228. package/dist/assets/play-CaHLVQC6.js +1 -0
  229. package/dist/assets/{plug-qlX-ubkq.js → plug-BNnFblsy.js} +1 -1
  230. package/dist/assets/plus-C9kUVwFa.js +1 -0
  231. package/dist/assets/{poivelle-BpE_pkIX.js → poivelle-BWX2hhDF.js} +1 -1
  232. package/dist/assets/{popover-Bf9u8EI7.js → popover-CCabhxbU.js} +1 -1
  233. package/dist/assets/producer-sye1Huyx.js +1 -0
  234. package/dist/assets/{qrart-qKp7QNwE.js → qrart-BL9fqeRZ.js} +1 -1
  235. package/dist/assets/realtime-DFxU7-1a.js +1 -0
  236. package/dist/assets/{refresh-cw-DKpjew0c.js → refresh-cw-CEDoG8Dx.js} +1 -1
  237. package/dist/assets/rotate-ccw-Bnq60__y.js +1 -0
  238. package/dist/assets/rotate-cw-D0rJoUHk.js +1 -0
  239. package/dist/assets/{row-CSMwp8He.js → row-DwvEQ4Kv.js} +1 -1
  240. package/dist/assets/{scenarioPayment-BQxaybOL.js → scenarioPayment-DsDn3g93.js} +1 -1
  241. package/dist/assets/search-DHxVw0ij.js +1 -0
  242. package/dist/assets/{seedance-CgiMOVoI.js → seedance-s45LWDKW.js} +1 -1
  243. package/dist/assets/{seedream-CCN_-T37.js → seedream-Dze5uUQ1.js} +1 -1
  244. package/dist/assets/{select-BPmmsYsL.js → select-CeX_bNg0.js} +1 -1
  245. package/dist/assets/serp-CzL67O53.js +1 -0
  246. package/dist/assets/{shield-DYsoSjvj.js → shield-B3Il942k.js} +1 -1
  247. package/dist/assets/{shuffle-C2cXZMq5.js → shuffle-Ceuvb3Pq.js} +1 -1
  248. package/dist/assets/site-B9bNGPDp.js +1 -0
  249. package/dist/assets/{site-KpCMucOQ.js → site-BBY-KjEs.js} +1 -1
  250. package/dist/assets/site-BFzbqR6B.js +1 -0
  251. package/dist/assets/site-BUAevgYO.js +1 -0
  252. package/dist/assets/site-BU_tgBOc.js +1 -0
  253. package/dist/assets/site-Bt-5LCIk.js +1 -0
  254. package/dist/assets/site-C1s3m4wS.js +1 -0
  255. package/dist/assets/site-C8Q7Vs05.js +1 -0
  256. package/dist/assets/site-CGDFhgEE.js +1 -0
  257. package/dist/assets/site-CXE47oRI.js +1 -0
  258. package/dist/assets/site-CgY1dD-J.js +1 -0
  259. package/dist/assets/site-CjYXcRar.js +1 -0
  260. package/dist/assets/site-CqAZVRQ5.js +1 -0
  261. package/dist/assets/site-CsGR8gMq.js +1 -0
  262. package/dist/assets/site-DsmH5PLg.js +1 -0
  263. package/dist/assets/site-DzMlHY0-.js +1 -0
  264. package/dist/assets/site-Vo2MP55Y.js +1 -0
  265. package/dist/assets/site-zGUINcZY.js +1 -0
  266. package/dist/assets/{slider-BkpC12ud.js → slider-EsCfJqwi.js} +1 -1
  267. package/dist/assets/{solana-BXAF_MAk.js → solana-BrezZweG.js} +2 -2
  268. package/dist/assets/{solana-wallets-DX1uEpyK.js → solana-wallets-D3rOnkt9.js} +2 -2
  269. package/dist/assets/{solana-wallets-vue-BnsXwDtg.js → solana-wallets-vue-CLd3Bp3c.js} +1 -1
  270. package/dist/assets/{wan-DKcIIxSa.js → sora-90o8cs5a.js} +1 -1
  271. package/dist/assets/{sparkles-BwWvghRX.js → sparkles-CLFz4tXS.js} +1 -1
  272. package/dist/assets/square-Bk41T292.js +1 -0
  273. package/dist/assets/{store-p6xQ2bAP.js → store-BhIfsufA.js} +1 -1
  274. package/dist/assets/suno-C3w1uyOT.js +1 -0
  275. package/dist/assets/{switch-B42bu5O7.js → switch-CNbPld6w.js} +1 -1
  276. package/dist/assets/{table-BD6Hv1lx.js → table-DvZrfif5.js} +1 -1
  277. package/dist/assets/{tabs-MtKgGPfn.js → tabs-4TPiegps.js} +1 -1
  278. package/dist/assets/{tag-q7oTj4uz.js → tag-Ba8zFUBB.js} +1 -1
  279. package/dist/assets/terminal-C8RjohOp.js +1 -0
  280. package/dist/assets/{time-picker-BcOKI3mu.js → time-picker-BYmX0sAP.js} +1 -1
  281. package/dist/assets/{tooltip-DKF_sGto.js → tooltip-FKvalKCm.js} +1 -1
  282. package/dist/assets/{trash-2-Cf1lYl_N.js → trash-2-CCnFGmoK.js} +1 -1
  283. package/dist/assets/{triangle-alert-_LVPy92s.js → triangle-alert-CmopbNHi.js} +1 -1
  284. package/dist/assets/{upload-C1h3h1KN.js → upload-B_e6GXND.js} +1 -1
  285. package/dist/assets/{upload-CTvrSmVZ.js → upload-D9uL4dkQ.js} +1 -1
  286. package/dist/assets/{usage-Dppnw4Fs.js → usage-04z9NZRc.js} +1 -1
  287. package/dist/assets/{usage-BwijwtIt.js → usage-73yEs7Mu.js} +1 -1
  288. package/dist/assets/{usage-BhJBxTFm.js → usage-AXtTdmov.js} +1 -1
  289. package/dist/assets/{usage-BT3Vpw6D.js → usage-BCx4gHkz.js} +1 -1
  290. package/dist/assets/{usage-P0GwdDpe.js → usage-BbLzE6-S.js} +1 -1
  291. package/dist/assets/{usage-CpAzsFQJ.js → usage-BrU23hEz.js} +1 -1
  292. package/dist/assets/usage-BtE70Zyx.js +1 -0
  293. package/dist/assets/{usage-0JZzyYFH.js → usage-CQF8OlL9.js} +1 -1
  294. package/dist/assets/{usage-DT-44dxH.js → usage-D2P27yNE.js} +1 -1
  295. package/dist/assets/{usage-L3l5Eufa.js → usage-DPrYoBCw.js} +1 -1
  296. package/dist/assets/{usage-CnsPzezH.js → usage-DcCek_bo.js} +1 -1
  297. package/dist/assets/{usage-BzIokmAu.js → usage-DdyGDvEE.js} +1 -1
  298. package/dist/assets/usage-Dja9rFWB.js +1 -0
  299. package/dist/assets/{usage--Zn0QeyQ.js → usage-Dp2RJpVP.js} +1 -1
  300. package/dist/assets/{usage-DdlX40M5.js → usage-DzHuO39g.js} +1 -1
  301. package/dist/assets/{usage-C1FkKtgn.js → usage-IPVqlr7d.js} +1 -1
  302. package/dist/assets/{usage-XjEHiZAl.js → usage-ROzxvUW5.js} +1 -1
  303. package/dist/assets/{usage-CAL51pBB.js → usage-h3vAtDis.js} +1 -1
  304. package/dist/assets/user-mH5pTyTU.js +1 -0
  305. package/dist/assets/{veo-sG-RXLUg.js → veo-DYzzaGw8.js} +1 -1
  306. package/dist/assets/{video-BaKcHmj6.js → video-CtGoK_4t.js} +1 -1
  307. package/dist/assets/{volume-2-CY9fv2mC.js → volume-2-DBsnfXmG.js} +1 -1
  308. package/dist/assets/{wallet-3BCb_2vC.js → wallet-BayS1PIM.js} +1 -1
  309. package/dist/assets/{pika-CWpxgVbz.js → wan-DsOYUFTC.js} +1 -1
  310. package/dist/assets/{wand-sparkles-DNHHWq-f.js → wand-sparkles-DoGA5MuS.js} +1 -1
  311. package/dist/assets/{web-CFOndwVN.js → web-BAIyltVw.js} +1 -1
  312. package/dist/assets/{web-CFTtGOqY.js → web-BkMQZT4M.js} +1 -1
  313. package/dist/assets/{web-oUobTiGG.js → web-CGfTDr08.js} +1 -1
  314. package/dist/assets/web-Cw7-ECXo.js +1 -0
  315. package/dist/assets/{web-BLn3-jMx.js → web-DotMPgJb.js} +1 -1
  316. package/dist/assets/webextrator-BBdpOFYt.js +1 -0
  317. package/dist/assets/x402-CPM8RH8s.js +1 -0
  318. package/dist/assets/{zap-BQE62bDm.js → zap-CZ02c990.js} +1 -1
  319. package/dist/index.html +5 -5
  320. package/package.json +2 -2
  321. package/dist/assets/BrowserPairingDialog-BIBE8_J9.js +0 -1
  322. package/dist/assets/BrowserPairingDialog-DJiPCPev.css +0 -1
  323. package/dist/assets/Conversation-dprhbIvD.js +0 -1
  324. package/dist/assets/CopyToClipboard-BMiCg7d2.js +0 -1
  325. package/dist/assets/CopyToClipboard-CAM7F2fv.css +0 -1
  326. package/dist/assets/Detail-BxuN8k_9.js +0 -2
  327. package/dist/assets/Extra-xrdEsbzz.js +0 -1
  328. package/dist/assets/Index-B3f-1Ux6.js +0 -1
  329. package/dist/assets/Index-B8RYaLCH.js +0 -1
  330. package/dist/assets/Index-BMpUhZ9q.js +0 -1
  331. package/dist/assets/Index-B_Iz0WQh.js +0 -1
  332. package/dist/assets/Index-Bpb4LsMP.js +0 -1
  333. package/dist/assets/Index-C6oXyNiR.js +0 -1
  334. package/dist/assets/Index-CP8kmAF9.js +0 -1
  335. package/dist/assets/Index-CZTEOg82.js +0 -1
  336. package/dist/assets/Index-C_69L5xX.js +0 -1
  337. package/dist/assets/Index-Cj5n4RJn2.js +0 -1
  338. package/dist/assets/Index-CmbZFmpj.js +0 -1
  339. package/dist/assets/Index-CvB6FNVL.js +0 -1
  340. package/dist/assets/Index-D3VSffBn.js +0 -1
  341. package/dist/assets/Index-DG5VlJU5.js +0 -1
  342. package/dist/assets/Index-DK143DDK.js +0 -1
  343. package/dist/assets/Index-DOXpcGvC.js +0 -1
  344. package/dist/assets/Index-DfULgGDk.js +0 -1
  345. package/dist/assets/Index-DpsQqW9b.js +0 -1
  346. package/dist/assets/Index-DrFIjAC4.js +0 -1
  347. package/dist/assets/Index-DtxAmXcP.js +0 -1
  348. package/dist/assets/Index-DzfWc7R3.js +0 -1
  349. package/dist/assets/Index-iHUpduNy.js +0 -1
  350. package/dist/assets/Index-vI1pmCgu.js +0 -1
  351. package/dist/assets/List-BARsKpTh.js +0 -1
  352. package/dist/assets/List-BW8OTe4G.js +0 -1
  353. package/dist/assets/List-DEqv2XDz.css +0 -1
  354. package/dist/assets/List-DPzL-ykG.css +0 -1
  355. package/dist/assets/List-DuRVdIUe.js +0 -1
  356. package/dist/assets/Logo-BCsapzVO.js +0 -1
  357. package/dist/assets/Logo-WBk_MhiY.css +0 -1
  358. package/dist/assets/Main-Cy6-Ifg-.js +0 -1
  359. package/dist/assets/Main-DWK8rjPk.css +0 -1
  360. package/dist/assets/Message-DlnFjCzr.js +0 -3
  361. package/dist/assets/Model-Dt3P_UQQ.js +0 -1
  362. package/dist/assets/Navigator-DcUhkdaf.css +0 -1
  363. package/dist/assets/Navigator-E7FCgVs1.js +0 -8
  364. package/dist/assets/Pay-0x3gmRoq.js +0 -1
  365. package/dist/assets/ScheduledTasks-CvrES_A8.css +0 -1
  366. package/dist/assets/ScheduledTasks-D-qGHm0o.js +0 -2
  367. package/dist/assets/Status-AZzfal7k.js +0 -1
  368. package/dist/assets/Tts-CqGAcIoB.js +0 -1
  369. package/dist/assets/arrow-down-CnzBxJOK.js +0 -1
  370. package/dist/assets/arrow-left-igb8AMz_.js +0 -1
  371. package/dist/assets/arrow-right-CGXNgdDZ.js +0 -1
  372. package/dist/assets/arrow-up-Drhcfl9s.js +0 -1
  373. package/dist/assets/check-sZ3LdzYe.js +0 -1
  374. package/dist/assets/chevron-down-B9A1h-il.js +0 -1
  375. package/dist/assets/chevron-right-CSsOai_n.js +0 -1
  376. package/dist/assets/circle-check-Cm0vi3QJ.js +0 -1
  377. package/dist/assets/clock-BRjX06BR.js +0 -1
  378. package/dist/assets/code-4fXy3EJM.js +0 -1
  379. package/dist/assets/codingBridge-ZH5aQjeX.js +0 -2
  380. package/dist/assets/constants-CX4j41GC.js +0 -1
  381. package/dist/assets/esm-COArLl5w.js +0 -2
  382. package/dist/assets/esm-D0SEwzQg.js +0 -1
  383. package/dist/assets/gauge-DZ-l2vCx.js +0 -1
  384. package/dist/assets/imageRequests-BMlSTRGz.js +0 -1
  385. package/dist/assets/index-DKnFv8oI.js +0 -570
  386. package/dist/assets/loader-circle-BOu6l4ZA.js +0 -1
  387. package/dist/assets/maestro-DpyfDSpq.js +0 -1
  388. package/dist/assets/maestro-EccNg3GS.js +0 -1
  389. package/dist/assets/midjourney-CT0W-uYP.js +0 -1
  390. package/dist/assets/minimax-Pf3RXf5W.js +0 -1
  391. package/dist/assets/music-2-CuTbesAz.js +0 -1
  392. package/dist/assets/pixverse-DzV6JmiT.js +0 -1
  393. package/dist/assets/play-DUVZyA7n.js +0 -1
  394. package/dist/assets/plus-Coq-6ZBW.js +0 -1
  395. package/dist/assets/producer-B0atTy_p.js +0 -1
  396. package/dist/assets/realtime-C9h-cRy7.js +0 -1
  397. package/dist/assets/rotate-ccw-mdSBnuP9.js +0 -1
  398. package/dist/assets/rotate-cw-C-F1OyBK.js +0 -1
  399. package/dist/assets/search-C73sRSFS.js +0 -1
  400. package/dist/assets/serp-75AFhZeM.js +0 -1
  401. package/dist/assets/site-AhbD1cAy.js +0 -1
  402. package/dist/assets/site-ApsDzXmT.js +0 -1
  403. package/dist/assets/site-B5aK2u48.js +0 -1
  404. package/dist/assets/site-BSs5bzZR.js +0 -1
  405. package/dist/assets/site-Bp09pxfx.js +0 -1
  406. package/dist/assets/site-CAj6esyl.js +0 -1
  407. package/dist/assets/site-CFOpzeB9.js +0 -1
  408. package/dist/assets/site-CgKjNFLm.js +0 -1
  409. package/dist/assets/site-CpvOXr5j.js +0 -1
  410. package/dist/assets/site-Cz55lBe5.js +0 -1
  411. package/dist/assets/site-D0_3FJ19.js +0 -1
  412. package/dist/assets/site-DSnZF7EC.js +0 -1
  413. package/dist/assets/site-DUtm0lCL.js +0 -1
  414. package/dist/assets/site-Dyw5SF13.js +0 -1
  415. package/dist/assets/site-HEpGPpP9.js +0 -1
  416. package/dist/assets/site-awqEUONZ.js +0 -1
  417. package/dist/assets/site-wXX_sllY.js +0 -1
  418. package/dist/assets/square-B1xtLDOg.js +0 -1
  419. package/dist/assets/suno-CFFLk4vG.js +0 -1
  420. package/dist/assets/terminal-bgNmS1ov.js +0 -1
  421. package/dist/assets/usage-CMQfpqxQ.js +0 -1
  422. package/dist/assets/usage-UhwLGkJP.js +0 -1
  423. package/dist/assets/user-F688Rsm5.js +0 -1
  424. package/dist/assets/web-DK27GiIu.js +0 -1
  425. package/dist/assets/webextrator-C8hHzuf5.js +0 -1
  426. /package/dist/assets/{imageRequests-DGx3ElFQ.css → ScenarioPaymentMode-DGx3ElFQ.css} +0 -0
@@ -1,2 +1,2 @@
1
- import{a as e,n as t,o as n,r,t as i}from"./rolldown-runtime--c01j_DQ.js";import{Ir as a}from"./index-DKnFv8oI.js";import{n as o}from"./eventemitter3-CwKRT-4Q.js";import{t as s}from"./buffer-CnhyIITQ.js";var c=BigInt(2**32-1),l=BigInt(32);function u(e,t=!1){return t?{h:Number(e&c),l:Number(e>>l&c)}:{h:Number(e>>l&c)|0,l:Number(e&c)|0}}function d(e,t=!1){let n=e.length,r=new Uint32Array(n),i=new Uint32Array(n);for(let a=0;a<n;a++){let{h:n,l:o}=u(e[a],t);[r[a],i[a]]=[n,o]}return[r,i]}var f=(e,t,n)=>e>>>n,p=(e,t,n)=>e<<32-n|t>>>n,m=(e,t,n)=>e>>>n|t<<32-n,h=(e,t,n)=>e<<32-n|t>>>n,g=(e,t,n)=>e<<64-n|t>>>n-32,_=(e,t,n)=>e>>>n-32|t<<64-n,v=(e,t,n)=>e<<n|t>>>32-n,y=(e,t,n)=>t<<n|e>>>32-n,b=(e,t,n)=>t<<n-32|e>>>64-n,x=(e,t,n)=>e<<n-32|t>>>64-n;function S(e,t,n,r){let i=(t>>>0)+(r>>>0);return{h:e+n+(i/2**32|0)|0,l:i|0}}var C=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),w=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,T=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),E=(e,t,n,r,i)=>t+n+r+i+(e/2**32|0)|0,D=(e,t,n,r,i)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(i>>>0),O=(e,t,n,r,i,a)=>t+n+r+i+a+(e/2**32|0)|0,k=typeof globalThis==`object`&&`crypto`in globalThis?globalThis.crypto:void 0;function A(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`}function ee(e){if(!Number.isSafeInteger(e)||e<0)throw Error(`positive integer expected, got `+e)}function j(e,...t){if(!A(e))throw Error(`Uint8Array expected`);if(t.length>0&&!t.includes(e.length))throw Error(`Uint8Array expected of length `+t+`, got length=`+e.length)}function M(e){if(typeof e!=`function`||typeof e.create!=`function`)throw Error(`Hash should be wrapped by utils.createHasher`);ee(e.outputLen),ee(e.blockLen)}function te(e,t=!0){if(e.destroyed)throw Error(`Hash instance has been destroyed`);if(t&&e.finished)throw Error(`Hash#digest() has already been called`)}function ne(e,t){j(e);let n=t.outputLen;if(e.length<n)throw Error(`digestInto() expects output buffer of length at least `+n)}function re(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function ie(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function ae(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function N(e,t){return e<<32-t|e>>>t}var oe=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function se(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function ce(e){for(let t=0;t<e.length;t++)e[t]=se(e[t]);return e}var le=oe?e=>e:ce,ue=typeof Uint8Array.from([]).toHex==`function`&&typeof Uint8Array.fromHex==`function`,de=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function fe(e){if(j(e),ue)return e.toHex();let t=``;for(let n=0;n<e.length;n++)t+=de[e[n]];return t}var P={_0:48,_9:57,A:65,F:70,a:97,f:102};function pe(e){if(e>=P._0&&e<=P._9)return e-P._0;if(e>=P.A&&e<=P.F)return e-(P.A-10);if(e>=P.a&&e<=P.f)return e-(P.a-10)}function me(e){if(typeof e!=`string`)throw Error(`hex string expected, got `+typeof e);if(ue)return Uint8Array.fromHex(e);let t=e.length,n=t/2;if(t%2)throw Error(`hex string expected, got unpadded hex of length `+t);let r=new Uint8Array(n);for(let t=0,i=0;t<n;t++,i+=2){let n=pe(e.charCodeAt(i)),a=pe(e.charCodeAt(i+1));if(n===void 0||a===void 0){let t=e[i]+e[i+1];throw Error(`hex string expected, got non-hex character "`+t+`" at index `+i)}r[t]=n*16+a}return r}function he(e){if(typeof e!=`string`)throw Error(`string expected`);return new Uint8Array(new TextEncoder().encode(e))}function ge(e){return typeof e==`string`&&(e=he(e)),j(e),e}function _e(...e){let t=0;for(let n=0;n<e.length;n++){let r=e[n];j(r),t+=r.length}let n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){let i=e[t];n.set(i,r),r+=i.length}return n}var ve=class{};function ye(e){let t=t=>e().update(ge(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function be(e=32){if(k&&typeof k.getRandomValues==`function`)return k.getRandomValues(new Uint8Array(e));if(k&&typeof k.randomBytes==`function`)return Uint8Array.from(k.randomBytes(e));throw Error(`crypto.getRandomValues must be defined`)}var xe=BigInt(0),Se=BigInt(1),Ce=BigInt(2),we=BigInt(7),Te=BigInt(256),Ee=BigInt(113),De=[],Oe=[],ke=[];for(let e=0,t=Se,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],De.push(2*(5*r+n)),Oe.push((e+1)*(e+2)/2%64);let i=xe;for(let e=0;e<7;e++)t=(t<<Se^(t>>we)*Ee)%Te,t&Ce&&(i^=Se<<(Se<<BigInt(e))-Se);ke.push(i)}var Ae=d(ke,!0),je=Ae[0],Me=Ae[1],Ne=(e,t,n)=>n>32?b(e,t,n):v(e,t,n),Pe=(e,t,n)=>n>32?x(e,t,n):y(e,t,n);function Fe(e,t=24){let n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let t=0;t<10;t++)n[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){let r=(t+8)%10,i=(t+2)%10,a=n[i],o=n[i+1],s=Ne(a,o,1)^n[r],c=Pe(a,o,1)^n[r+1];for(let n=0;n<50;n+=10)e[t+n]^=s,e[t+n+1]^=c}let t=e[2],i=e[3];for(let n=0;n<24;n++){let r=Oe[n],a=Ne(t,i,r),o=Pe(t,i,r),s=De[n];t=e[s],i=e[s+1],e[s]=a,e[s+1]=o}for(let t=0;t<50;t+=10){for(let r=0;r<10;r++)n[r]=e[t+r];for(let r=0;r<10;r++)e[t+r]^=~n[(r+2)%10]&n[(r+4)%10]}e[0]^=je[r],e[1]^=Me[r]}ie(n)}var Ie=class e extends ve{constructor(e,t,n,r=!1,i=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=r,this.rounds=i,ee(n),!(0<e&&e<200))throw Error(`only keccak-f1600 function is supported`);this.state=new Uint8Array(200),this.state32=re(this.state)}clone(){return this._cloneInto()}keccak(){le(this.state32),Fe(this.state32,this.rounds),le(this.state32),this.posOut=0,this.pos=0}update(e){te(this),e=ge(e),j(e);let{blockLen:t,state:n}=this,r=e.length;for(let i=0;i<r;){let a=Math.min(t-this.pos,r-i);for(let t=0;t<a;t++)n[this.pos++]^=e[i++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:t,pos:n,blockLen:r}=this;e[n]^=t,t&128&&n===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){te(this,!1),j(e),this.finish();let t=this.state,{blockLen:n}=this;for(let r=0,i=e.length;r<i;){this.posOut>=n&&this.keccak();let a=Math.min(n-this.posOut,i-r);e.set(t.subarray(this.posOut,this.posOut+a),r),this.posOut+=a,r+=a}return e}xofInto(e){if(!this.enableXOF)throw Error(`XOF is not possible for this instance`);return this.writeInto(e)}xof(e){return ee(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(ne(e,this),this.finished)throw Error(`digest() was already called`);return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,ie(this.state)}_cloneInto(t){let{blockLen:n,suffix:r,outputLen:i,rounds:a,enableXOF:o}=this;return t||=new e(n,r,i,o,a),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=a,t.suffix=r,t.outputLen=i,t.enableXOF=o,t.destroyed=this.destroyed,t}},Le=((e,t,n)=>ye(()=>new Ie(t,e,n)))(1,136,256/8);function Re(e,t,n,r){if(typeof e.setBigUint64==`function`)return e.setBigUint64(t,n,r);let i=BigInt(32),a=BigInt(4294967295),o=Number(n>>i&a),s=Number(n&a),c=r?4:0,l=r?0:4;e.setUint32(t+c,o,r),e.setUint32(t+l,s,r)}function ze(e,t,n){return e&t^~e&n}function Be(e,t,n){return e&t^e&n^t&n}var Ve=class extends ve{constructor(e,t,n,r){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=ae(this.buffer)}update(e){te(this),e=ge(e),j(e);let{view:t,buffer:n,blockLen:r}=this,i=e.length;for(let a=0;a<i;){let o=Math.min(r-this.pos,i-a);if(o===r){let t=ae(e);for(;r<=i-a;a+=r)this.process(t,a);continue}n.set(e.subarray(a,a+o),this.pos),this.pos+=o,a+=o,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){te(this),ne(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:r,isLE:i}=this,{pos:a}=this;t[a++]=128,ie(this.buffer.subarray(a)),this.padOffset>r-a&&(this.process(n,0),a=0);for(let e=a;e<r;e++)t[e]=0;Re(n,r-8,BigInt(this.length*8),i),this.process(n,0);let o=ae(e),s=this.outputLen;if(s%4)throw Error(`_sha2: outputLen should be aligned to 32bit`);let c=s/4,l=this.get();if(c>l.length)throw Error(`_sha2: outputLen bigger than state`);for(let e=0;e<c;e++)o.setUint32(4*e,l[e],i)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||=new this.constructor,e.set(...this.get());let{blockLen:t,buffer:n,length:r,finished:i,destroyed:a,pos:o}=this;return e.destroyed=a,e.finished=i,e.length=r,e.pos=o,r%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}},He=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ue=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),We=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Ge=new Uint32Array(64),Ke=class extends Ve{constructor(e=32){super(64,e,8,!1),this.A=He[0]|0,this.B=He[1]|0,this.C=He[2]|0,this.D=He[3]|0,this.E=He[4]|0,this.F=He[5]|0,this.G=He[6]|0,this.H=He[7]|0}get(){let{A:e,B:t,C:n,D:r,E:i,F:a,G:o,H:s}=this;return[e,t,n,r,i,a,o,s]}set(e,t,n,r,i,a,o,s){this.A=e|0,this.B=t|0,this.C=n|0,this.D=r|0,this.E=i|0,this.F=a|0,this.G=o|0,this.H=s|0}process(e,t){for(let n=0;n<16;n++,t+=4)Ge[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){let t=Ge[e-15],n=Ge[e-2],r=N(t,7)^N(t,18)^t>>>3;Ge[e]=(N(n,17)^N(n,19)^n>>>10)+Ge[e-7]+r+Ge[e-16]|0}let{A:n,B:r,C:i,D:a,E:o,F:s,G:c,H:l}=this;for(let e=0;e<64;e++){let t=N(o,6)^N(o,11)^N(o,25),u=l+t+ze(o,s,c)+We[e]+Ge[e]|0,d=(N(n,2)^N(n,13)^N(n,22))+Be(n,r,i)|0;l=c,c=s,s=o,o=a+u|0,a=i,i=r,r=n,n=u+d|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,a=a+this.D|0,o=o+this.E|0,s=s+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,i,a,o,s,c,l)}roundClean(){ie(Ge)}destroy(){this.set(0,0,0,0,0,0,0,0),ie(this.buffer)}},qe=d(`0x428a2f98d728ae22.0x7137449123ef65cd.0xb5c0fbcfec4d3b2f.0xe9b5dba58189dbbc.0x3956c25bf348b538.0x59f111f1b605d019.0x923f82a4af194f9b.0xab1c5ed5da6d8118.0xd807aa98a3030242.0x12835b0145706fbe.0x243185be4ee4b28c.0x550c7dc3d5ffb4e2.0x72be5d74f27b896f.0x80deb1fe3b1696b1.0x9bdc06a725c71235.0xc19bf174cf692694.0xe49b69c19ef14ad2.0xefbe4786384f25e3.0x0fc19dc68b8cd5b5.0x240ca1cc77ac9c65.0x2de92c6f592b0275.0x4a7484aa6ea6e483.0x5cb0a9dcbd41fbd4.0x76f988da831153b5.0x983e5152ee66dfab.0xa831c66d2db43210.0xb00327c898fb213f.0xbf597fc7beef0ee4.0xc6e00bf33da88fc2.0xd5a79147930aa725.0x06ca6351e003826f.0x142929670a0e6e70.0x27b70a8546d22ffc.0x2e1b21385c26c926.0x4d2c6dfc5ac42aed.0x53380d139d95b3df.0x650a73548baf63de.0x766a0abb3c77b2a8.0x81c2c92e47edaee6.0x92722c851482353b.0xa2bfe8a14cf10364.0xa81a664bbc423001.0xc24b8b70d0f89791.0xc76c51a30654be30.0xd192e819d6ef5218.0xd69906245565a910.0xf40e35855771202a.0x106aa07032bbd1b8.0x19a4c116b8d2d0c8.0x1e376c085141ab53.0x2748774cdf8eeb99.0x34b0bcb5e19b48a8.0x391c0cb3c5c95a63.0x4ed8aa4ae3418acb.0x5b9cca4f7763e373.0x682e6ff3d6b2b8a3.0x748f82ee5defb2fc.0x78a5636f43172f60.0x84c87814a1f0ab72.0x8cc702081a6439ec.0x90befffa23631e28.0xa4506cebde82bde9.0xbef9a3f7b2c67915.0xc67178f2e372532b.0xca273eceea26619c.0xd186b8c721c0c207.0xeada7dd6cde0eb1e.0xf57d4f7fee6ed178.0x06f067aa72176fba.0x0a637dc5a2c898a6.0x113f9804bef90dae.0x1b710b35131c471b.0x28db77f523047d84.0x32caab7b40c72493.0x3c9ebe0a15c9bebc.0x431d67c49c100d4c.0x4cc5d4becb3e42b6.0x597f299cfc657e2a.0x5fcb6fab3ad6faec.0x6c44198c4a475817`.split(`.`).map(e=>BigInt(e))),Je=qe[0],Ye=qe[1],Xe=new Uint32Array(80),Ze=new Uint32Array(80),Qe=class extends Ve{constructor(e=64){super(128,e,16,!1),this.Ah=Ue[0]|0,this.Al=Ue[1]|0,this.Bh=Ue[2]|0,this.Bl=Ue[3]|0,this.Ch=Ue[4]|0,this.Cl=Ue[5]|0,this.Dh=Ue[6]|0,this.Dl=Ue[7]|0,this.Eh=Ue[8]|0,this.El=Ue[9]|0,this.Fh=Ue[10]|0,this.Fl=Ue[11]|0,this.Gh=Ue[12]|0,this.Gl=Ue[13]|0,this.Hh=Ue[14]|0,this.Hl=Ue[15]|0}get(){let{Ah:e,Al:t,Bh:n,Bl:r,Ch:i,Cl:a,Dh:o,Dl:s,Eh:c,El:l,Fh:u,Fl:d,Gh:f,Gl:p,Hh:m,Hl:h}=this;return[e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h]}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=r|0,this.Ch=i|0,this.Cl=a|0,this.Dh=o|0,this.Dl=s|0,this.Eh=c|0,this.El=l|0,this.Fh=u|0,this.Fl=d|0,this.Gh=f|0,this.Gl=p|0,this.Hh=m|0,this.Hl=h|0}process(e,t){for(let n=0;n<16;n++,t+=4)Xe[n]=e.getUint32(t),Ze[n]=e.getUint32(t+=4);for(let e=16;e<80;e++){let t=Xe[e-15]|0,n=Ze[e-15]|0,r=m(t,n,1)^m(t,n,8)^f(t,n,7),i=h(t,n,1)^h(t,n,8)^p(t,n,7),a=Xe[e-2]|0,o=Ze[e-2]|0,s=m(a,o,19)^g(a,o,61)^f(a,o,6),c=T(i,h(a,o,19)^_(a,o,61)^p(a,o,6),Ze[e-7],Ze[e-16]);Xe[e]=E(c,r,s,Xe[e-7],Xe[e-16])|0,Ze[e]=c|0}let{Ah:n,Al:r,Bh:i,Bl:a,Ch:o,Cl:s,Dh:c,Dl:l,Eh:u,El:d,Fh:v,Fl:y,Gh:b,Gl:x,Hh:k,Hl:A}=this;for(let e=0;e<80;e++){let t=m(u,d,14)^m(u,d,18)^g(u,d,41),f=h(u,d,14)^h(u,d,18)^_(u,d,41),p=u&v^~u&b,T=d&y^~d&x,E=D(A,f,T,Ye[e],Ze[e]),ee=O(E,k,t,p,Je[e],Xe[e]),j=E|0,M=m(n,r,28)^g(n,r,34)^g(n,r,39),te=h(n,r,28)^_(n,r,34)^_(n,r,39),ne=n&i^n&o^i&o,re=r&a^r&s^a&s;k=b|0,A=x|0,b=v|0,x=y|0,v=u|0,y=d|0,{h:u,l:d}=S(c|0,l|0,ee|0,j|0),c=o|0,l=s|0,o=i|0,s=a|0,i=n|0,a=r|0;let ie=C(j,te,re);n=w(ie,ee,M,ne),r=ie|0}({h:n,l:r}=S(this.Ah|0,this.Al|0,n|0,r|0)),{h:i,l:a}=S(this.Bh|0,this.Bl|0,i|0,a|0),{h:o,l:s}=S(this.Ch|0,this.Cl|0,o|0,s|0),{h:c,l}=S(this.Dh|0,this.Dl|0,c|0,l|0),{h:u,l:d}=S(this.Eh|0,this.El|0,u|0,d|0),{h:v,l:y}=S(this.Fh|0,this.Fl|0,v|0,y|0),{h:b,l:x}=S(this.Gh|0,this.Gl|0,b|0,x|0),{h:k,l:A}=S(this.Hh|0,this.Hl|0,k|0,A|0),this.set(n,r,i,a,o,s,c,l,u,d,v,y,b,x,k,A)}roundClean(){ie(Xe,Ze)}destroy(){ie(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},$e=ye(()=>new Ke),et=ye(()=>new Qe),tt=$e,nt=class extends ve{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,M(e);let n=ge(t);if(this.iHash=e.create(),typeof this.iHash.update!=`function`)throw Error(`Expected instance of class which extends utils.Hash`);this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let r=this.blockLen,i=new Uint8Array(r);i.set(n.length>r?e.create().update(n).digest():n);for(let e=0;e<i.length;e++)i[e]^=54;this.iHash.update(i),this.oHash=e.create();for(let e=0;e<i.length;e++)i[e]^=106;this.oHash.update(i),ie(i)}update(e){return te(this),this.iHash.update(e),this}digestInto(e){te(this),j(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:t,iHash:n,finished:r,destroyed:i,blockLen:a,outputLen:o}=this;return e=e,e.finished=r,e.destroyed=i,e.blockLen=a,e.outputLen=o,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},rt=(e,t,n)=>new nt(e,t).update(n).digest();rt.create=(e,t)=>new nt(e,t);var F=s(),it=BigInt(0),at=BigInt(1);function ot(e,t=``){if(typeof e!=`boolean`){let n=t&&`"${t}"`;throw Error(n+`expected boolean, got type=`+typeof e)}return e}function st(e,t,n=``){let r=A(e),i=e?.length,a=t!==void 0;if(!r||a&&i!==t){let o=n&&`"${n}" `,s=a?` of length ${t}`:``,c=r?`length=${i}`:`type=${typeof e}`;throw Error(o+`expected Uint8Array`+s+`, got `+c)}return e}function ct(e){let t=e.toString(16);return t.length&1?`0`+t:t}function lt(e){if(typeof e!=`string`)throw Error(`hex string expected, got `+typeof e);return e===``?it:BigInt(`0x`+e)}function ut(e){return lt(fe(e))}function dt(e){return j(e),lt(fe(Uint8Array.from(e).reverse()))}function ft(e,t){return me(e.toString(16).padStart(t*2,`0`))}function pt(e,t){return ft(e,t).reverse()}function mt(e,t,n){let r;if(typeof t==`string`)try{r=me(t)}catch(t){throw Error(e+` must be hex string or Uint8Array, cause: `+t)}else if(A(t))r=Uint8Array.from(t);else throw Error(e+` must be hex string or Uint8Array`);let i=r.length;if(typeof n==`number`&&i!==n)throw Error(e+` of length `+n+` expected, got `+i);return r}function ht(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return n===0}function gt(e){return Uint8Array.from(e)}var _t=e=>typeof e==`bigint`&&it<=e;function vt(e,t,n){return _t(e)&&_t(t)&&_t(n)&&t<=e&&e<n}function yt(e,t,n,r){if(!vt(t,n,r))throw Error(`expected valid `+e+`: `+n+` <= n < `+r+`, got `+t)}function bt(e){let t;for(t=0;e>it;e>>=at,t+=1);return t}var xt=e=>(at<<BigInt(e))-at;function St(e,t,n){if(typeof e!=`number`||e<2)throw Error(`hashLen must be a number`);if(typeof t!=`number`||t<2)throw Error(`qByteLen must be a number`);if(typeof n!=`function`)throw Error(`hmacFn must be a function`);let r=e=>new Uint8Array(e),i=e=>Uint8Array.of(e),a=r(e),o=r(e),s=0,c=()=>{a.fill(1),o.fill(0),s=0},l=(...e)=>n(o,a,...e),u=(e=r(0))=>{o=l(i(0),e),a=l(),e.length!==0&&(o=l(i(1),e),a=l())},d=()=>{if(s++>=1e3)throw Error(`drbg: tried 1000 values`);let e=0,n=[];for(;e<t;){a=l();let t=a.slice();n.push(t),e+=a.length}return _e(...n)};return(e,t)=>{c(),u(e);let n;for(;!(n=t(d()));)u();return c(),n}}function Ct(e,t,n={}){if(!e||typeof e!=`object`)throw Error(`expected valid options object`);function r(t,n,r){let i=e[t];if(r&&i===void 0)return;let a=typeof i;if(a!==n||i===null)throw Error(`param "${t}" is invalid: expected ${n}, got ${a}`)}Object.entries(t).forEach(([e,t])=>r(e,t,!1)),Object.entries(n).forEach(([e,t])=>r(e,t,!0))}var wt=()=>{throw Error(`not implemented`)};function Tt(e){let t=new WeakMap;return(n,...r)=>{let i=t.get(n);if(i!==void 0)return i;let a=e(n,...r);return t.set(n,a),a}}var Et=BigInt(0),Dt=BigInt(1),Ot=BigInt(2),kt=BigInt(3),At=BigInt(4),jt=BigInt(5),Mt=BigInt(7),Nt=BigInt(8),Pt=BigInt(9),Ft=BigInt(16);function It(e,t){let n=e%t;return n>=Et?n:t+n}function Lt(e,t,n){let r=e;for(;t-- >Et;)r*=r,r%=n;return r}function Rt(e,t){if(e===Et)throw Error(`invert: expected non-zero number`);if(t<=Et)throw Error(`invert: expected positive modulus, got `+t);let n=It(e,t),r=t,i=Et,a=Dt,o=Dt,s=Et;for(;n!==Et;){let e=r/n,t=r%n,c=i-o*e,l=a-s*e;r=n,n=t,i=o,a=s,o=c,s=l}if(r!==Dt)throw Error(`invert: does not exist`);return It(i,t)}function zt(e,t,n){if(!e.eql(e.sqr(t),n))throw Error(`Cannot find square root`)}function Bt(e,t){let n=(e.ORDER+Dt)/At,r=e.pow(t,n);return zt(e,r,t),r}function Vt(e,t){let n=(e.ORDER-jt)/Nt,r=e.mul(t,Ot),i=e.pow(r,n),a=e.mul(t,i),o=e.mul(e.mul(a,Ot),i),s=e.mul(a,e.sub(o,e.ONE));return zt(e,s,t),s}function Ht(e){let t=Qt(e),n=Ut(e),r=n(t,t.neg(t.ONE)),i=n(t,r),a=n(t,t.neg(r)),o=(e+Mt)/Ft;return(e,t)=>{let n=e.pow(t,o),s=e.mul(n,r),c=e.mul(n,i),l=e.mul(n,a),u=e.eql(e.sqr(s),t),d=e.eql(e.sqr(c),t);n=e.cmov(n,s,u),s=e.cmov(l,c,d);let f=e.eql(e.sqr(s),t),p=e.cmov(n,s,f);return zt(e,p,t),p}}function Ut(e){if(e<kt)throw Error(`sqrt is not defined for small field`);let t=e-Dt,n=0;for(;t%Ot===Et;)t/=Ot,n++;let r=Ot,i=Qt(e);for(;Xt(i,r)===1;)if(r++>1e3)throw Error(`Cannot find square root: probably non-prime P`);if(n===1)return Bt;let a=i.pow(r,t),o=(t+Dt)/Ot;return function(e,r){if(e.is0(r))return r;if(Xt(e,r)!==1)throw Error(`Cannot find square root`);let i=n,s=e.mul(e.ONE,a),c=e.pow(r,t),l=e.pow(r,o);for(;!e.eql(c,e.ONE);){if(e.is0(c))return e.ZERO;let t=1,n=e.sqr(c);for(;!e.eql(n,e.ONE);)if(t++,n=e.sqr(n),t===i)throw Error(`Cannot find square root`);let r=Dt<<BigInt(i-t-1),a=e.pow(s,r);i=t,s=e.sqr(a),c=e.mul(c,s),l=e.mul(l,a)}return l}}function Wt(e){return e%At===kt?Bt:e%Nt===jt?Vt:e%Ft===Pt?Ht(e):Ut(e)}var Gt=(e,t)=>(It(e,t)&Dt)===Dt,Kt=[`create`,`isValid`,`is0`,`neg`,`inv`,`sqrt`,`sqr`,`eql`,`add`,`sub`,`mul`,`pow`,`div`,`addN`,`subN`,`mulN`,`sqrN`];function qt(e){return Ct(e,Kt.reduce((e,t)=>(e[t]=`function`,e),{ORDER:`bigint`,MASK:`bigint`,BYTES:`number`,BITS:`number`})),e}function Jt(e,t,n){if(n<Et)throw Error(`invalid exponent, negatives unsupported`);if(n===Et)return e.ONE;if(n===Dt)return t;let r=e.ONE,i=t;for(;n>Et;)n&Dt&&(r=e.mul(r,i)),i=e.sqr(i),n>>=Dt;return r}function Yt(e,t,n=!1){let r=Array(t.length).fill(n?e.ZERO:void 0),i=t.reduce((t,n,i)=>e.is0(n)?t:(r[i]=t,e.mul(t,n)),e.ONE),a=e.inv(i);return t.reduceRight((t,n,i)=>e.is0(n)?t:(r[i]=e.mul(t,r[i]),e.mul(t,n)),a),r}function Xt(e,t){let n=(e.ORDER-Dt)/Ot,r=e.pow(t,n),i=e.eql(r,e.ONE),a=e.eql(r,e.ZERO),o=e.eql(r,e.neg(e.ONE));if(!i&&!a&&!o)throw Error(`invalid Legendre symbol result`);return i?1:a?0:-1}function Zt(e,t){t!==void 0&&ee(t);let n=t===void 0?e.toString(2).length:t;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function Qt(e,t,n=!1,r={}){if(e<=Et)throw Error(`invalid field: expected ORDER > 0, got `+e);let i,a,o=!1,s;if(typeof t==`object`&&t){if(r.sqrt||n)throw Error(`cannot specify opts in two arguments`);let e=t;e.BITS&&(i=e.BITS),e.sqrt&&(a=e.sqrt),typeof e.isLE==`boolean`&&(n=e.isLE),typeof e.modFromBytes==`boolean`&&(o=e.modFromBytes),s=e.allowedLengths}else typeof t==`number`&&(i=t),r.sqrt&&(a=r.sqrt);let{nBitLength:c,nByteLength:l}=Zt(e,i);if(l>2048)throw Error(`invalid field: expected ORDER of <= 2048 bytes`);let u,d=Object.freeze({ORDER:e,isLE:n,BITS:c,BYTES:l,MASK:xt(c),ZERO:Et,ONE:Dt,allowedLengths:s,create:t=>It(t,e),isValid:t=>{if(typeof t!=`bigint`)throw Error(`invalid field element: expected bigint, got `+typeof t);return Et<=t&&t<e},is0:e=>e===Et,isValidNot0:e=>!d.is0(e)&&d.isValid(e),isOdd:e=>(e&Dt)===Dt,neg:t=>It(-t,e),eql:(e,t)=>e===t,sqr:t=>It(t*t,e),add:(t,n)=>It(t+n,e),sub:(t,n)=>It(t-n,e),mul:(t,n)=>It(t*n,e),pow:(e,t)=>Jt(d,e,t),div:(t,n)=>It(t*Rt(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>Rt(t,e),sqrt:a||(t=>(u||=Wt(e),u(d,t))),toBytes:e=>n?pt(e,l):ft(e,l),fromBytes:(t,r=!0)=>{if(s){if(!s.includes(t.length)||t.length>l)throw Error(`Field.fromBytes: expected `+s+` bytes, got `+t.length);let e=new Uint8Array(l);e.set(t,n?0:e.length-t.length),t=e}if(t.length!==l)throw Error(`Field.fromBytes: expected `+l+` bytes, got `+t.length);let i=n?dt(t):ut(t);if(o&&(i=It(i,e)),!r&&!d.isValid(i))throw Error(`invalid field element: outside of range 0..ORDER`);return i},invertBatch:e=>Yt(d,e),cmov:(e,t,n)=>n?t:e});return Object.freeze(d)}function $t(e){if(typeof e!=`bigint`)throw Error(`field order must be bigint`);let t=e.toString(2).length;return Math.ceil(t/8)}function en(e){let t=$t(e);return t+Math.ceil(t/2)}function tn(e,t,n=!1){let r=e.length,i=$t(t),a=en(t);if(r<16||r<a||r>1024)throw Error(`expected `+a+`-1024 bytes of input, got `+r);let o=It(n?dt(e):ut(e),t-Dt)+Dt;return n?pt(o,i):ft(o,i)}var nn=BigInt(0),rn=BigInt(1);function an(e,t){let n=t.negate();return e?n:t}function on(e,t){let n=Yt(e.Fp,t.map(e=>e.Z));return t.map((t,r)=>e.fromAffine(t.toAffine(n[r])))}function sn(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw Error(`invalid window size, expected [1..`+t+`], got W=`+e)}function cn(e,t){sn(e,t);let n=Math.ceil(t/e)+1,r=2**(e-1),i=2**e;return{windows:n,windowSize:r,mask:xt(e),maxNumber:i,shiftBy:BigInt(e)}}function ln(e,t,n){let{windowSize:r,mask:i,maxNumber:a,shiftBy:o}=n,s=Number(e&i),c=e>>o;s>r&&(s-=a,c+=rn);let l=t*r,u=l+Math.abs(s)-1,d=s===0,f=s<0,p=t%2!=0;return{nextN:c,offset:u,isZero:d,isNeg:f,isNegF:p,offsetF:l}}function un(e,t){if(!Array.isArray(e))throw Error(`array expected`);e.forEach((e,n)=>{if(!(e instanceof t))throw Error(`invalid point at index `+n)})}function dn(e,t){if(!Array.isArray(e))throw Error(`array of scalars expected`);e.forEach((e,n)=>{if(!t.isValid(e))throw Error(`invalid scalar at index `+n)})}var fn=new WeakMap,pn=new WeakMap;function mn(e){return pn.get(e)||1}function hn(e){if(e!==nn)throw Error(`invalid wNAF`)}var gn=class{constructor(e,t){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=t}_unsafeLadder(e,t,n=this.ZERO){let r=e;for(;t>nn;)t&rn&&(n=n.add(r)),r=r.double(),t>>=rn;return n}precomputeWindow(e,t){let{windows:n,windowSize:r}=cn(t,this.bits),i=[],a=e,o=a;for(let e=0;e<n;e++){o=a,i.push(o);for(let e=1;e<r;e++)o=o.add(a),i.push(o);a=o.double()}return i}wNAF(e,t,n){if(!this.Fn.isValid(n))throw Error(`invalid scalar`);let r=this.ZERO,i=this.BASE,a=cn(e,this.bits);for(let e=0;e<a.windows;e++){let{nextN:o,offset:s,isZero:c,isNeg:l,isNegF:u,offsetF:d}=ln(n,e,a);n=o,c?i=i.add(an(u,t[d])):r=r.add(an(l,t[s]))}return hn(n),{p:r,f:i}}wNAFUnsafe(e,t,n,r=this.ZERO){let i=cn(e,this.bits);for(let e=0;e<i.windows&&n!==nn;e++){let{nextN:a,offset:o,isZero:s,isNeg:c}=ln(n,e,i);if(n=a,!s){let e=t[o];r=r.add(c?e.negate():e)}}return hn(n),r}getPrecomputes(e,t,n){let r=fn.get(t);return r||(r=this.precomputeWindow(t,e),e!==1&&(typeof n==`function`&&(r=n(r)),fn.set(t,r))),r}cached(e,t,n){let r=mn(e);return this.wNAF(r,this.getPrecomputes(r,e,n),t)}unsafe(e,t,n,r){let i=mn(e);return i===1?this._unsafeLadder(e,t,r):this.wNAFUnsafe(i,this.getPrecomputes(i,e,n),t,r)}createCache(e,t){sn(t,this.bits),pn.set(e,t),fn.delete(e)}hasCache(e){return mn(e)!==1}};function _n(e,t,n,r){let i=t,a=e.ZERO,o=e.ZERO;for(;n>nn||r>nn;)n&rn&&(a=a.add(i)),r&rn&&(o=o.add(i)),i=i.double(),n>>=rn,r>>=rn;return{p1:a,p2:o}}function vn(e,t,n,r){un(n,e),dn(r,t);let i=n.length,a=r.length;if(i!==a)throw Error(`arrays of points and scalars must have equal length`);let o=e.ZERO,s=bt(BigInt(i)),c=1;s>12?c=s-3:s>4?c=s-2:s>0&&(c=2);let l=xt(c),u=Array(Number(l)+1).fill(o),d=Math.floor((t.BITS-1)/c)*c,f=o;for(let e=d;e>=0;e-=c){u.fill(o);for(let t=0;t<a;t++){let i=r[t],a=Number(i>>BigInt(e)&l);u[a]=u[a].add(n[t])}let t=o;for(let e=u.length-1,n=o;e>0;e--)n=n.add(u[e]),t=t.add(n);if(f=f.add(t),e!==0)for(let e=0;e<c;e++)f=f.double()}return f}function yn(e,t,n){if(t){if(t.ORDER!==e)throw Error(`Field.ORDER must match order: Fp == p, Fn == n`);return qt(t),t}else return Qt(e,{isLE:n})}function bn(e,t,n={},r){if(r===void 0&&(r=e===`edwards`),!t||typeof t!=`object`)throw Error(`expected valid ${e} CURVE object`);for(let e of[`p`,`n`,`h`]){let n=t[e];if(!(typeof n==`bigint`&&n>nn))throw Error(`CURVE.${e} must be positive bigint`)}let i=yn(t.p,n.Fp,r),a=yn(t.n,n.Fn,r),o=[`Gx`,`Gy`,`a`,e===`weierstrass`?`b`:`d`];for(let e of o)if(!i.isValid(t[e]))throw Error(`CURVE.${e} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:i,Fn:a}}var xn=BigInt(0),Sn=BigInt(1),Cn=BigInt(2),wn=BigInt(8);function Tn(e,t,n,r){let i=e.sqr(n),a=e.sqr(r),o=e.add(e.mul(t.a,i),a),s=e.add(e.ONE,e.mul(t.d,e.mul(i,a)));return e.eql(o,s)}function En(e,t={}){let n=bn(`edwards`,e,t,t.FpFnLE),{Fp:r,Fn:i}=n,a=n.CURVE,{h:o}=a;Ct(t,{},{uvRatio:`function`});let s=Cn<<BigInt(i.BYTES*8)-Sn,c=e=>r.create(e),l=t.uvRatio||((e,t)=>{try{return{isValid:!0,value:r.sqrt(r.div(e,t))}}catch{return{isValid:!1,value:xn}}});if(!Tn(r,a,a.Gx,a.Gy))throw Error(`bad curve params: generator point`);function u(e,t,n=!1){let r=n?Sn:xn;return yt(`coordinate `+e,t,r,s),t}function d(e){if(!(e instanceof m))throw Error(`ExtendedPoint expected`)}let f=Tt((e,t)=>{let{X:n,Y:i,Z:a}=e,o=e.is0();t??=o?wn:r.inv(a);let s=c(n*t),l=c(i*t),u=r.mul(a,t);if(o)return{x:xn,y:Sn};if(u!==Sn)throw Error(`invZ was invalid`);return{x:s,y:l}}),p=Tt(e=>{let{a:t,d:n}=a;if(e.is0())throw Error(`bad point: ZERO`);let{X:r,Y:i,Z:o,T:s}=e,l=c(r*r),u=c(i*i),d=c(o*o),f=c(d*d);if(c(d*c(c(l*t)+u))!==c(f+c(n*c(l*u))))throw Error(`bad point: equation left != right (1)`);if(c(r*i)!==c(o*s))throw Error(`bad point: equation left != right (2)`);return!0});class m{constructor(e,t,n,r){this.X=u(`x`,e),this.Y=u(`y`,t),this.Z=u(`z`,n,!0),this.T=u(`t`,r),Object.freeze(this)}static CURVE(){return a}static fromAffine(e){if(e instanceof m)throw Error(`extended point not allowed`);let{x:t,y:n}=e||{};return u(`x`,t),u(`y`,n),new m(t,n,Sn,c(t*n))}static fromBytes(e,t=!1){let n=r.BYTES,{a:i,d:o}=a;e=gt(st(e,n,`point`)),ot(t,`zip215`);let u=gt(e),d=e[n-1];u[n-1]=d&-129;let f=dt(u);yt(`point.y`,f,xn,t?s:r.ORDER);let p=c(f*f),{isValid:h,value:g}=l(c(p-Sn),c(o*p-i));if(!h)throw Error(`bad point: invalid y coordinate`);let _=(g&Sn)===Sn,v=(d&128)!=0;if(!t&&g===xn&&v)throw Error(`bad point: x=0 and x_0=1`);return v!==_&&(g=c(-g)),m.fromAffine({x:g,y:f})}static fromHex(e,t=!1){return m.fromBytes(mt(`point`,e),t)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(e=8,t=!0){return h.createCache(this,e),t||this.multiply(Cn),this}assertValidity(){p(this)}equals(e){d(e);let{X:t,Y:n,Z:r}=this,{X:i,Y:a,Z:o}=e,s=c(t*o),l=c(i*r),u=c(n*o),f=c(a*r);return s===l&&u===f}is0(){return this.equals(m.ZERO)}negate(){return new m(c(-this.X),this.Y,this.Z,c(-this.T))}double(){let{a:e}=a,{X:t,Y:n,Z:r}=this,i=c(t*t),o=c(n*n),s=c(Cn*c(r*r)),l=c(e*i),u=t+n,d=c(c(u*u)-i-o),f=l+o,p=f-s,h=l-o,g=c(d*p),_=c(f*h),v=c(d*h);return new m(g,_,c(p*f),v)}add(e){d(e);let{a:t,d:n}=a,{X:r,Y:i,Z:o,T:s}=this,{X:l,Y:u,Z:f,T:p}=e,h=c(r*l),g=c(i*u),_=c(s*n*p),v=c(o*f),y=c((r+i)*(l+u)-h-g),b=v-_,x=v+_,S=c(g-t*h),C=c(y*b),w=c(x*S),T=c(y*S);return new m(C,w,c(b*x),T)}subtract(e){return this.add(e.negate())}multiply(e){if(!i.isValidNot0(e))throw Error(`invalid scalar: expected 1 <= sc < curve.n`);let{p:t,f:n}=h.cached(this,e,e=>on(m,e));return on(m,[t,n])[0]}multiplyUnsafe(e,t=m.ZERO){if(!i.isValid(e))throw Error(`invalid scalar: expected 0 <= sc < curve.n`);return e===xn?m.ZERO:this.is0()||e===Sn?this:h.unsafe(this,e,e=>on(m,e),t)}isSmallOrder(){return this.multiplyUnsafe(o).is0()}isTorsionFree(){return h.unsafe(this,a.n).is0()}toAffine(e){return f(this,e)}clearCofactor(){return o===Sn?this:this.multiplyUnsafe(o)}toBytes(){let{x:e,y:t}=this.toAffine(),n=r.toBytes(t);return n[n.length-1]|=e&Sn?128:0,n}toHex(){return fe(this.toBytes())}toString(){return`<Point ${this.is0()?`ZERO`:this.toHex()}>`}get ex(){return this.X}get ey(){return this.Y}get ez(){return this.Z}get et(){return this.T}static normalizeZ(e){return on(m,e)}static msm(e,t){return vn(m,i,e,t)}_setWindowSize(e){this.precompute(e)}toRawBytes(){return this.toBytes()}}m.BASE=new m(a.Gx,a.Gy,Sn,c(a.Gx*a.Gy)),m.ZERO=new m(xn,Sn,Sn,xn),m.Fp=r,m.Fn=i;let h=new gn(m,i.BITS);return m.BASE.precompute(8),m}var Dn=class{constructor(e){this.ep=e}static fromBytes(e){wt()}static fromHex(e){wt()}get x(){return this.toAffine().x}get y(){return this.toAffine().y}clearCofactor(){return this}assertValidity(){this.ep.assertValidity()}toAffine(e){return this.ep.toAffine(e)}toHex(){return fe(this.toBytes())}toString(){return this.toHex()}isTorsionFree(){return!0}isSmallOrder(){return!1}add(e){return this.assertSame(e),this.init(this.ep.add(e.ep))}subtract(e){return this.assertSame(e),this.init(this.ep.subtract(e.ep))}multiply(e){return this.init(this.ep.multiply(e))}multiplyUnsafe(e){return this.init(this.ep.multiplyUnsafe(e))}double(){return this.init(this.ep.double())}negate(){return this.init(this.ep.negate())}precompute(e,t){return this.init(this.ep.precompute(e,t))}toRawBytes(){return this.toBytes()}};function On(e,t,n={}){if(typeof t!=`function`)throw Error(`"hash" function param is required`);Ct(n,{},{adjustScalarBytes:`function`,randomBytes:`function`,domain:`function`,prehash:`function`,mapToCurve:`function`});let{prehash:r}=n,{BASE:i,Fp:a,Fn:o}=e,s=n.randomBytes||be,c=n.adjustScalarBytes||(e=>e),l=n.domain||((e,t,n)=>{if(ot(n,`phflag`),t.length||n)throw Error(`Contexts/pre-hash are not supported`);return e});function u(e){return o.create(dt(e))}function d(e){let n=y.secretKey;e=mt(`private key`,e,n);let r=mt(`hashed private key`,t(e),2*n),i=c(r.slice(0,n));return{head:i,prefix:r.slice(n,2*n),scalar:u(i)}}function f(e){let{head:t,prefix:n,scalar:r}=d(e),a=i.multiply(r);return{head:t,prefix:n,scalar:r,point:a,pointBytes:a.toBytes()}}function p(e){return f(e).pointBytes}function m(e=Uint8Array.of(),...n){return u(t(l(_e(...n),mt(`context`,e),!!r)))}function h(e,t,n={}){e=mt(`message`,e),r&&(e=r(e));let{prefix:a,scalar:s,pointBytes:c}=f(t),l=m(n.context,a,e),u=i.multiply(l).toBytes(),d=m(n.context,u,c,e),p=o.create(l+d*s);if(!o.isValid(p))throw Error(`sign failed: invalid s`);return st(_e(u,o.toBytes(p)),y.signature,`result`)}let g={zip215:!0};function _(t,n,a,o=g){let{context:s,zip215:c}=o,l=y.signature;t=mt(`signature`,t,l),n=mt(`message`,n),a=mt(`publicKey`,a,y.publicKey),c!==void 0&&ot(c,`zip215`),r&&(n=r(n));let u=l/2,d=t.subarray(0,u),f=dt(t.subarray(u,l)),p,h,_;try{p=e.fromBytes(a,c),h=e.fromBytes(d,c),_=i.multiplyUnsafe(f)}catch{return!1}if(!c&&p.isSmallOrder())return!1;let v=m(s,h.toBytes(),p.toBytes(),n);return h.add(p.multiplyUnsafe(v)).subtract(_).clearCofactor().is0()}let v=a.BYTES,y={secretKey:v,publicKey:v,signature:2*v,seed:v};function b(e=s(y.seed)){return st(e,y.seed,`seed`)}function x(e){let t=w.randomSecretKey(e);return{secretKey:t,publicKey:p(t)}}function S(e){return A(e)&&e.length===o.BYTES}function C(t,n){try{return!!e.fromBytes(t,n)}catch{return!1}}let w={getExtendedPublicKey:f,randomSecretKey:b,isValidSecretKey:S,isValidPublicKey:C,toMontgomery(t){let{y:n}=e.fromBytes(t),r=y.publicKey,i=r===32;if(!i&&r!==57)throw Error(`only defined for 25519 and 448`);let o=i?a.div(Sn+n,Sn-n):a.div(n-Sn,n+Sn);return a.toBytes(o)},toMontgomerySecret(e){let n=y.secretKey;return st(e,n),c(t(e.subarray(0,n))).subarray(0,n)},randomPrivateKey:b,precompute(t=8,n=e.BASE){return n.precompute(t,!1)}};return Object.freeze({keygen:x,getPublicKey:p,sign:h,verify:_,utils:w,Point:e,lengths:y})}function kn(e){let t={a:e.a,d:e.d,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},n={Fp:e.Fp,Fn:Qt(t.n,e.nBitLength,!0),uvRatio:e.uvRatio},r={randomBytes:e.randomBytes,adjustScalarBytes:e.adjustScalarBytes,domain:e.domain,prehash:e.prehash,mapToCurve:e.mapToCurve};return{CURVE:t,curveOpts:n,hash:e.hash,eddsaOpts:r}}function An(e,t){let n=t.Point;return Object.assign({},t,{ExtendedPoint:n,CURVE:e,nBitLength:n.Fn.BITS,nByteLength:n.Fn.BYTES})}function jn(e){let{CURVE:t,curveOpts:n,hash:r,eddsaOpts:i}=kn(e);return An(e,On(En(t,n),r,i))}var Mn=BigInt(0),Nn=BigInt(1),Pn=BigInt(2),Fn=BigInt(5),In=BigInt(8),Ln=BigInt(`0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed`),Rn={p:Ln,n:BigInt(`0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed`),h:In,a:BigInt(`0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec`),d:BigInt(`0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3`),Gx:BigInt(`0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a`),Gy:BigInt(`0x6666666666666666666666666666666666666666666666666666666666666658`)};function zn(e){let t=BigInt(10),n=BigInt(20),r=BigInt(40),i=BigInt(80),a=Ln,o=e*e%a*e%a,s=Lt(Lt(o,Pn,a)*o%a,Nn,a)*e%a,c=Lt(s,Fn,a)*s%a,l=Lt(c,t,a)*c%a,u=Lt(l,n,a)*l%a,d=Lt(u,r,a)*u%a;return{pow_p_5_8:Lt(Lt(Lt(Lt(d,i,a)*d%a,i,a)*d%a,t,a)*c%a,Pn,a)*e%a,b2:o}}function Bn(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var Vn=BigInt(`19681161376707505956807079304988542015446066515923890162744021073123829784752`);function Hn(e,t){let n=Ln,r=It(t*t*t,n),i=zn(e*It(r*r*t,n)).pow_p_5_8,a=It(e*r*i,n),o=It(t*a*a,n),s=a,c=It(a*Vn,n),l=o===e,u=o===It(-e,n),d=o===It(-e*Vn,n);return l&&(a=s),(u||d)&&(a=c),Gt(a,n)&&(a=It(-a,n)),{isValid:l||u,value:a}}var Un=Qt(Rn.p,{isLE:!0}),Wn=Qt(Rn.n,{isLE:!0}),Gn=jn({...Rn,Fp:Un,hash:et,adjustScalarBytes:Bn,uvRatio:Hn}),Kn=Vn,qn=BigInt(`25063068953384623474111414158702152701244531502492656460079210482610430750235`),Jn=BigInt(`54469307008909316920995813868745141605393597292927456921205312896311721017578`),Yn=BigInt(`1159843021668779879193775521855586647937357759715417654439879720876111806838`),Xn=BigInt(`40440834346308536858101042469323190826248399146238708352240133220865137265952`),Zn=e=>Hn(Nn,e),Qn=BigInt(`0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff`),$n=e=>Gn.Point.Fp.create(dt(e)&Qn);function er(e){let{d:t}=Rn,n=Ln,r=e=>Un.create(e),i=r(Kn*e*e),a=r((i+Nn)*Yn),o=BigInt(-1),s=r((o-t*i)*r(i+t)),{isValid:c,value:l}=Hn(a,s),u=r(l*e);Gt(u,n)||(u=r(-u)),c||(l=u),c||(o=i);let d=r(o*(i-Nn)*Xn-s),f=l*l,p=r((l+l)*s),m=r(d*qn),h=r(Nn-f),g=r(Nn+f);return new Gn.Point(r(p*g),r(h*m),r(m*g),r(p*h))}function tr(e){j(e,64);let t=er($n(e.subarray(0,32))),n=er($n(e.subarray(32,64)));return new nr(t.add(n))}var nr=class e extends Dn{constructor(e){super(e)}static fromAffine(t){return new e(Gn.Point.fromAffine(t))}assertSame(t){if(!(t instanceof e))throw Error(`RistrettoPoint expected`)}init(t){return new e(t)}static hashToCurve(e){return tr(mt(`ristrettoHash`,e,64))}static fromBytes(t){j(t,32);let{a:n,d:r}=Rn,i=Ln,a=e=>Un.create(e),o=$n(t);if(!ht(Un.toBytes(o),t)||Gt(o,i))throw Error(`invalid ristretto255 encoding 1`);let s=a(o*o),c=a(Nn+n*s),l=a(Nn-n*s),u=a(c*c),d=a(l*l),f=a(n*r*u-d),{isValid:p,value:m}=Zn(a(f*d)),h=a(m*l),g=a(m*h*f),_=a((o+o)*h);Gt(_,i)&&(_=a(-_));let v=a(c*g),y=a(_*v);if(!p||Gt(y,i)||v===Mn)throw Error(`invalid ristretto255 encoding 2`);return new e(new Gn.Point(_,v,Nn,y))}static fromHex(t){return e.fromBytes(mt(`ristrettoHex`,t,32))}static msm(t,n){return vn(e,Gn.Point.Fn,t,n)}toBytes(){let{X:e,Y:t,Z:n,T:r}=this.ep,i=Ln,a=e=>Un.create(e),o=a(a(n+t)*a(n-t)),s=a(e*t),{value:c}=Zn(a(o*a(s*s))),l=a(c*o),u=a(c*s),d=a(l*u*r),f;if(Gt(r*d,i)){let n=a(t*Kn),r=a(e*Kn);e=n,t=r,f=a(l*Jn)}else f=u;Gt(e*d,i)&&(t=a(-t));let p=a((n-t)*f);return Gt(p,i)&&(p=a(-p)),Un.toBytes(p)}equals(e){this.assertSame(e);let{X:t,Y:n}=this.ep,{X:r,Y:i}=e.ep,a=e=>Un.create(e),o=a(t*i)===a(n*r),s=a(n*i)===a(t*r);return o||s}is0(){return this.equals(e.ZERO)}};nr.BASE=new nr(Gn.Point.BASE),nr.ZERO=new nr(Gn.Point.ZERO),nr.Fp=Un,nr.Fn=Wn;var rr=i(((e,t)=>{(function(e,t){function n(e,t){if(!e)throw Error(t||`Assertion failed`)}function r(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}function i(e,t,n){if(i.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,e!==null&&((t===`le`||t===`be`)&&(n=t,t=10),this._init(e||0,t||10,n||`be`))}typeof e==`object`?e.exports=i:t.BN=i,i.BN=i,i.wordSize=26;var o;try{o=typeof window<`u`&&window.Buffer!==void 0?window.Buffer:a().Buffer}catch{}i.isBN=function(e){return e instanceof i?!0:typeof e==`object`&&!!e&&e.constructor.wordSize===i.wordSize&&Array.isArray(e.words)},i.max=function(e,t){return e.cmp(t)>0?e:t},i.min=function(e,t){return e.cmp(t)<0?e:t},i.prototype._init=function(e,t,r){if(typeof e==`number`)return this._initNumber(e,t,r);if(typeof e==`object`)return this._initArray(e,t,r);t===`hex`&&(t=16),n(t===(t|0)&&t>=2&&t<=36),e=e.toString().replace(/\s+/g,``);var i=0;e[0]===`-`&&(i++,this.negative=1),i<e.length&&(t===16?this._parseHex(e,i,r):(this._parseBase(e,t,i),r===`le`&&this._initArray(this.toArray(),t,r)))},i.prototype._initNumber=function(e,t,r){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[e&67108863],this.length=1):e<4503599627370496?(this.words=[e&67108863,e/67108864&67108863],this.length=2):(n(e<9007199254740992),this.words=[e&67108863,e/67108864&67108863,1],this.length=3),r===`le`&&this._initArray(this.toArray(),t,r)},i.prototype._initArray=function(e,t,r){if(n(typeof e.length==`number`),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var a,o,s=0;if(r===`be`)for(i=e.length-1,a=0;i>=0;i-=3)o=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[a]|=o<<s&67108863,this.words[a+1]=o>>>26-s&67108863,s+=24,s>=26&&(s-=26,a++);else if(r===`le`)for(i=0,a=0;i<e.length;i+=3)o=e[i]|e[i+1]<<8|e[i+2]<<16,this.words[a]|=o<<s&67108863,this.words[a+1]=o>>>26-s&67108863,s+=24,s>=26&&(s-=26,a++);return this._strip()};function s(e,t){var r=e.charCodeAt(t);if(r>=48&&r<=57)return r-48;if(r>=65&&r<=70)return r-55;if(r>=97&&r<=102)return r-87;n(!1,`Invalid character in `+e)}function c(e,t,n){var r=s(e,n);return n-1>=t&&(r|=s(e,n-1)<<4),r}i.prototype._parseHex=function(e,t,n){this.length=Math.ceil((e.length-t)/6),this.words=Array(this.length);for(var r=0;r<this.length;r++)this.words[r]=0;var i=0,a=0,o;if(n===`be`)for(r=e.length-1;r>=t;r-=2)o=c(e,t,r)<<i,this.words[a]|=o&67108863,i>=18?(i-=18,a+=1,this.words[a]|=o>>>26):i+=8;else for(r=(e.length-t)%2==0?t+1:t;r<e.length;r+=2)o=c(e,t,r)<<i,this.words[a]|=o&67108863,i>=18?(i-=18,a+=1,this.words[a]|=o>>>26):i+=8;this._strip()};function l(e,t,r,i){for(var a=0,o=0,s=Math.min(e.length,r),c=t;c<s;c++){var l=e.charCodeAt(c)-48;a*=i,o=l>=49?l-49+10:l>=17?l-17+10:l,n(l>=0&&o<i,`Invalid character`),a+=o}return a}i.prototype._parseBase=function(e,t,n){this.words=[0],this.length=1;for(var r=0,i=1;i<=67108863;i*=t)r++;r--,i=i/t|0;for(var a=e.length-n,o=a%r,s=Math.min(a,a-o)+n,c=0,u=n;u<s;u+=r)c=l(e,u,u+r,t),this.imuln(i),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c);if(o!==0){var d=1;for(c=l(e,u,e.length,t),u=0;u<o;u++)d*=t;this.imuln(d),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c)}this._strip()},i.prototype.copy=function(e){e.words=Array(this.length);for(var t=0;t<this.length;t++)e.words[t]=this.words[t];e.length=this.length,e.negative=this.negative,e.red=this.red};function u(e,t){e.words=t.words,e.length=t.length,e.negative=t.negative,e.red=t.red}if(i.prototype._move=function(e){u(e,this)},i.prototype.clone=function(){var e=new i(null);return this.copy(e),e},i.prototype._expand=function(e){for(;this.length<e;)this.words[this.length++]=0;return this},i.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},i.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<`u`&&typeof Symbol.for==`function`)try{i.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=d}catch{i.prototype.inspect=d}else i.prototype.inspect=d;function d(){return(this.red?`<BN-R: `:`<BN: `)+this.toString(16)+`>`}var f=`.0.00.000.0000.00000.000000.0000000.00000000.000000000.0000000000.00000000000.000000000000.0000000000000.00000000000000.000000000000000.0000000000000000.00000000000000000.000000000000000000.0000000000000000000.00000000000000000000.000000000000000000000.0000000000000000000000.00000000000000000000000.000000000000000000000000.0000000000000000000000000`.split(`.`),p=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],m=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];i.prototype.toString=function(e,t){e||=10,t=t|0||1;var r;if(e===16||e===`hex`){r=``;for(var i=0,a=0,o=0;o<this.length;o++){var s=this.words[o],c=((s<<i|a)&16777215).toString(16);a=s>>>24-i&16777215,i+=2,i>=26&&(i-=26,o--),r=a!==0||o!==this.length-1?f[6-c.length]+c+r:c+r}for(a!==0&&(r=a.toString(16)+r);r.length%t!==0;)r=`0`+r;return this.negative!==0&&(r=`-`+r),r}if(e===(e|0)&&e>=2&&e<=36){var l=p[e],u=m[e];r=``;var d=this.clone();for(d.negative=0;!d.isZero();){var h=d.modrn(u).toString(e);d=d.idivn(u),r=d.isZero()?h+r:f[l-h.length]+h+r}for(this.isZero()&&(r=`0`+r);r.length%t!==0;)r=`0`+r;return this.negative!==0&&(r=`-`+r),r}n(!1,`Base should be between 2 and 36`)},i.prototype.toNumber=function(){var e=this.words[0];return this.length===2?e+=this.words[1]*67108864:this.length===3&&this.words[2]===1?e+=4503599627370496+this.words[1]*67108864:this.length>2&&n(!1,`Number can only safely store up to 53 bits`),this.negative===0?e:-e},i.prototype.toJSON=function(){return this.toString(16,2)},o&&(i.prototype.toBuffer=function(e,t){return this.toArrayLike(o,e,t)}),i.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)};var h=function(e,t){return e.allocUnsafe?e.allocUnsafe(t):new e(t)};i.prototype.toArrayLike=function(e,t,r){this._strip();var i=this.byteLength(),a=r||Math.max(1,i);n(i<=a,`byte array longer than desired length`),n(a>0,`Requested array length <= 0`);var o=h(e,a),s=t===`le`?`LE`:`BE`;return this[`_toArrayLike`+s](o,i),o},i.prototype._toArrayLikeLE=function(e,t){for(var n=0,r=0,i=0,a=0;i<this.length;i++){var o=this.words[i]<<a|r;e[n++]=o&255,n<e.length&&(e[n++]=o>>8&255),n<e.length&&(e[n++]=o>>16&255),a===6?(n<e.length&&(e[n++]=o>>24&255),r=0,a=0):(r=o>>>24,a+=2)}if(n<e.length)for(e[n++]=r;n<e.length;)e[n++]=0},i.prototype._toArrayLikeBE=function(e,t){for(var n=e.length-1,r=0,i=0,a=0;i<this.length;i++){var o=this.words[i]<<a|r;e[n--]=o&255,n>=0&&(e[n--]=o>>8&255),n>=0&&(e[n--]=o>>16&255),a===6?(n>=0&&(e[n--]=o>>24&255),r=0,a=0):(r=o>>>24,a+=2)}if(n>=0)for(e[n--]=r;n>=0;)e[n--]=0},Math.clz32?i.prototype._countBits=function(e){return 32-Math.clz32(e)}:i.prototype._countBits=function(e){var t=e,n=0;return t>=4096&&(n+=13,t>>>=13),t>=64&&(n+=7,t>>>=7),t>=8&&(n+=4,t>>>=4),t>=2&&(n+=2,t>>>=2),n+t},i.prototype._zeroBits=function(e){if(e===0)return 26;var t=e,n=0;return t&8191||(n+=13,t>>>=13),t&127||(n+=7,t>>>=7),t&15||(n+=4,t>>>=4),t&3||(n+=2,t>>>=2),t&1||n++,n},i.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return(this.length-1)*26+t};function g(e){for(var t=Array(e.bitLength()),n=0;n<t.length;n++){var r=n/26|0,i=n%26;t[n]=e.words[r]>>>i&1}return t}i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;t<this.length;t++){var n=this._zeroBits(this.words[t]);if(e+=n,n!==26)break}return e},i.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},i.prototype.toTwos=function(e){return this.negative===0?this.clone():this.abs().inotn(e).iaddn(1)},i.prototype.fromTwos=function(e){return this.testn(e-1)?this.notn(e).iaddn(1).ineg():this.clone()},i.prototype.isNeg=function(){return this.negative!==0},i.prototype.neg=function(){return this.clone().ineg()},i.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},i.prototype.iuor=function(e){for(;this.length<e.length;)this.words[this.length++]=0;for(var t=0;t<e.length;t++)this.words[t]=this.words[t]|e.words[t];return this._strip()},i.prototype.ior=function(e){return n((this.negative|e.negative)===0),this.iuor(e)},i.prototype.or=function(e){return this.length>e.length?this.clone().ior(e):e.clone().ior(this)},i.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},i.prototype.iuand=function(e){for(var t=this.length>e.length?e:this,n=0;n<t.length;n++)this.words[n]=this.words[n]&e.words[n];return this.length=t.length,this._strip()},i.prototype.iand=function(e){return n((this.negative|e.negative)===0),this.iuand(e)},i.prototype.and=function(e){return this.length>e.length?this.clone().iand(e):e.clone().iand(this)},i.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},i.prototype.iuxor=function(e){var t,n;this.length>e.length?(t=this,n=e):(t=e,n=this);for(var r=0;r<n.length;r++)this.words[r]=t.words[r]^n.words[r];if(this!==t)for(;r<t.length;r++)this.words[r]=t.words[r];return this.length=t.length,this._strip()},i.prototype.ixor=function(e){return n((this.negative|e.negative)===0),this.iuxor(e)},i.prototype.xor=function(e){return this.length>e.length?this.clone().ixor(e):e.clone().ixor(this)},i.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},i.prototype.inotn=function(e){n(typeof e==`number`&&e>=0);var t=Math.ceil(e/26)|0,r=e%26;this._expand(t),r>0&&t--;for(var i=0;i<t;i++)this.words[i]=~this.words[i]&67108863;return r>0&&(this.words[i]=~this.words[i]&67108863>>26-r),this._strip()},i.prototype.notn=function(e){return this.clone().inotn(e)},i.prototype.setn=function(e,t){n(typeof e==`number`&&e>=0);var r=e/26|0,i=e%26;return this._expand(r+1),t?this.words[r]=this.words[r]|1<<i:this.words[r]=this.words[r]&~(1<<i),this._strip()},i.prototype.iadd=function(e){var t;if(this.negative!==0&&e.negative===0)return this.negative=0,t=this.isub(e),this.negative^=1,this._normSign();if(this.negative===0&&e.negative!==0)return e.negative=0,t=this.isub(e),e.negative=1,t._normSign();var n,r;this.length>e.length?(n=this,r=e):(n=e,r=this);for(var i=0,a=0;a<r.length;a++)t=(n.words[a]|0)+(r.words[a]|0)+i,this.words[a]=t&67108863,i=t>>>26;for(;i!==0&&a<n.length;a++)t=(n.words[a]|0)+i,this.words[a]=t&67108863,i=t>>>26;if(this.length=n.length,i!==0)this.words[this.length]=i,this.length++;else if(n!==this)for(;a<n.length;a++)this.words[a]=n.words[a];return this},i.prototype.add=function(e){var t;return e.negative!==0&&this.negative===0?(e.negative=0,t=this.sub(e),e.negative^=1,t):e.negative===0&&this.negative!==0?(this.negative=0,t=e.sub(this),this.negative=1,t):this.length>e.length?this.clone().iadd(e):e.clone().iadd(this)},i.prototype.isub=function(e){if(e.negative!==0){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var n=this.cmp(e);if(n===0)return this.negative=0,this.length=1,this.words[0]=0,this;var r,i;n>0?(r=this,i=e):(r=e,i=this);for(var a=0,o=0;o<i.length;o++)t=(r.words[o]|0)-(i.words[o]|0)+a,a=t>>26,this.words[o]=t&67108863;for(;a!==0&&o<r.length;o++)t=(r.words[o]|0)+a,a=t>>26,this.words[o]=t&67108863;if(a===0&&o<r.length&&r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this.length=Math.max(this.length,o),r!==this&&(this.negative=1),this._strip()},i.prototype.sub=function(e){return this.clone().isub(e)};function _(e,t,n){n.negative=t.negative^e.negative;var r=e.length+t.length|0;n.length=r,r=r-1|0;var i=e.words[0]|0,a=t.words[0]|0,o=i*a,s=o&67108863,c=o/67108864|0;n.words[0]=s;for(var l=1;l<r;l++){for(var u=c>>>26,d=c&67108863,f=Math.min(l,t.length-1),p=Math.max(0,l-e.length+1);p<=f;p++){var m=l-p|0;i=e.words[m]|0,a=t.words[p]|0,o=i*a+d,u+=o/67108864|0,d=o&67108863}n.words[l]=d|0,c=u|0}return c===0?n.length--:n.words[l]=c|0,n._strip()}var v=function(e,t,n){var r=e.words,i=t.words,a=n.words,o=0,s,c,l,u=r[0]|0,d=u&8191,f=u>>>13,p=r[1]|0,m=p&8191,h=p>>>13,g=r[2]|0,_=g&8191,v=g>>>13,y=r[3]|0,b=y&8191,x=y>>>13,S=r[4]|0,C=S&8191,w=S>>>13,T=r[5]|0,E=T&8191,D=T>>>13,O=r[6]|0,k=O&8191,A=O>>>13,ee=r[7]|0,j=ee&8191,M=ee>>>13,te=r[8]|0,ne=te&8191,re=te>>>13,ie=r[9]|0,ae=ie&8191,N=ie>>>13,oe=i[0]|0,se=oe&8191,ce=oe>>>13,le=i[1]|0,ue=le&8191,de=le>>>13,fe=i[2]|0,P=fe&8191,pe=fe>>>13,me=i[3]|0,he=me&8191,ge=me>>>13,_e=i[4]|0,ve=_e&8191,ye=_e>>>13,be=i[5]|0,xe=be&8191,Se=be>>>13,Ce=i[6]|0,we=Ce&8191,Te=Ce>>>13,Ee=i[7]|0,De=Ee&8191,Oe=Ee>>>13,ke=i[8]|0,Ae=ke&8191,je=ke>>>13,Me=i[9]|0,Ne=Me&8191,Pe=Me>>>13;n.negative=e.negative^t.negative,n.length=19,s=Math.imul(d,se),c=Math.imul(d,ce),c=c+Math.imul(f,se)|0,l=Math.imul(f,ce);var Fe=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Fe>>>26)|0,Fe&=67108863,s=Math.imul(m,se),c=Math.imul(m,ce),c=c+Math.imul(h,se)|0,l=Math.imul(h,ce),s=s+Math.imul(d,ue)|0,c=c+Math.imul(d,de)|0,c=c+Math.imul(f,ue)|0,l=l+Math.imul(f,de)|0;var Ie=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,s=Math.imul(_,se),c=Math.imul(_,ce),c=c+Math.imul(v,se)|0,l=Math.imul(v,ce),s=s+Math.imul(m,ue)|0,c=c+Math.imul(m,de)|0,c=c+Math.imul(h,ue)|0,l=l+Math.imul(h,de)|0,s=s+Math.imul(d,P)|0,c=c+Math.imul(d,pe)|0,c=c+Math.imul(f,P)|0,l=l+Math.imul(f,pe)|0;var Le=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Le>>>26)|0,Le&=67108863,s=Math.imul(b,se),c=Math.imul(b,ce),c=c+Math.imul(x,se)|0,l=Math.imul(x,ce),s=s+Math.imul(_,ue)|0,c=c+Math.imul(_,de)|0,c=c+Math.imul(v,ue)|0,l=l+Math.imul(v,de)|0,s=s+Math.imul(m,P)|0,c=c+Math.imul(m,pe)|0,c=c+Math.imul(h,P)|0,l=l+Math.imul(h,pe)|0,s=s+Math.imul(d,he)|0,c=c+Math.imul(d,ge)|0,c=c+Math.imul(f,he)|0,l=l+Math.imul(f,ge)|0;var Re=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Re>>>26)|0,Re&=67108863,s=Math.imul(C,se),c=Math.imul(C,ce),c=c+Math.imul(w,se)|0,l=Math.imul(w,ce),s=s+Math.imul(b,ue)|0,c=c+Math.imul(b,de)|0,c=c+Math.imul(x,ue)|0,l=l+Math.imul(x,de)|0,s=s+Math.imul(_,P)|0,c=c+Math.imul(_,pe)|0,c=c+Math.imul(v,P)|0,l=l+Math.imul(v,pe)|0,s=s+Math.imul(m,he)|0,c=c+Math.imul(m,ge)|0,c=c+Math.imul(h,he)|0,l=l+Math.imul(h,ge)|0,s=s+Math.imul(d,ve)|0,c=c+Math.imul(d,ye)|0,c=c+Math.imul(f,ve)|0,l=l+Math.imul(f,ye)|0;var ze=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(ze>>>26)|0,ze&=67108863,s=Math.imul(E,se),c=Math.imul(E,ce),c=c+Math.imul(D,se)|0,l=Math.imul(D,ce),s=s+Math.imul(C,ue)|0,c=c+Math.imul(C,de)|0,c=c+Math.imul(w,ue)|0,l=l+Math.imul(w,de)|0,s=s+Math.imul(b,P)|0,c=c+Math.imul(b,pe)|0,c=c+Math.imul(x,P)|0,l=l+Math.imul(x,pe)|0,s=s+Math.imul(_,he)|0,c=c+Math.imul(_,ge)|0,c=c+Math.imul(v,he)|0,l=l+Math.imul(v,ge)|0,s=s+Math.imul(m,ve)|0,c=c+Math.imul(m,ye)|0,c=c+Math.imul(h,ve)|0,l=l+Math.imul(h,ye)|0,s=s+Math.imul(d,xe)|0,c=c+Math.imul(d,Se)|0,c=c+Math.imul(f,xe)|0,l=l+Math.imul(f,Se)|0;var Be=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Be>>>26)|0,Be&=67108863,s=Math.imul(k,se),c=Math.imul(k,ce),c=c+Math.imul(A,se)|0,l=Math.imul(A,ce),s=s+Math.imul(E,ue)|0,c=c+Math.imul(E,de)|0,c=c+Math.imul(D,ue)|0,l=l+Math.imul(D,de)|0,s=s+Math.imul(C,P)|0,c=c+Math.imul(C,pe)|0,c=c+Math.imul(w,P)|0,l=l+Math.imul(w,pe)|0,s=s+Math.imul(b,he)|0,c=c+Math.imul(b,ge)|0,c=c+Math.imul(x,he)|0,l=l+Math.imul(x,ge)|0,s=s+Math.imul(_,ve)|0,c=c+Math.imul(_,ye)|0,c=c+Math.imul(v,ve)|0,l=l+Math.imul(v,ye)|0,s=s+Math.imul(m,xe)|0,c=c+Math.imul(m,Se)|0,c=c+Math.imul(h,xe)|0,l=l+Math.imul(h,Se)|0,s=s+Math.imul(d,we)|0,c=c+Math.imul(d,Te)|0,c=c+Math.imul(f,we)|0,l=l+Math.imul(f,Te)|0;var Ve=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Ve>>>26)|0,Ve&=67108863,s=Math.imul(j,se),c=Math.imul(j,ce),c=c+Math.imul(M,se)|0,l=Math.imul(M,ce),s=s+Math.imul(k,ue)|0,c=c+Math.imul(k,de)|0,c=c+Math.imul(A,ue)|0,l=l+Math.imul(A,de)|0,s=s+Math.imul(E,P)|0,c=c+Math.imul(E,pe)|0,c=c+Math.imul(D,P)|0,l=l+Math.imul(D,pe)|0,s=s+Math.imul(C,he)|0,c=c+Math.imul(C,ge)|0,c=c+Math.imul(w,he)|0,l=l+Math.imul(w,ge)|0,s=s+Math.imul(b,ve)|0,c=c+Math.imul(b,ye)|0,c=c+Math.imul(x,ve)|0,l=l+Math.imul(x,ye)|0,s=s+Math.imul(_,xe)|0,c=c+Math.imul(_,Se)|0,c=c+Math.imul(v,xe)|0,l=l+Math.imul(v,Se)|0,s=s+Math.imul(m,we)|0,c=c+Math.imul(m,Te)|0,c=c+Math.imul(h,we)|0,l=l+Math.imul(h,Te)|0,s=s+Math.imul(d,De)|0,c=c+Math.imul(d,Oe)|0,c=c+Math.imul(f,De)|0,l=l+Math.imul(f,Oe)|0;var He=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(He>>>26)|0,He&=67108863,s=Math.imul(ne,se),c=Math.imul(ne,ce),c=c+Math.imul(re,se)|0,l=Math.imul(re,ce),s=s+Math.imul(j,ue)|0,c=c+Math.imul(j,de)|0,c=c+Math.imul(M,ue)|0,l=l+Math.imul(M,de)|0,s=s+Math.imul(k,P)|0,c=c+Math.imul(k,pe)|0,c=c+Math.imul(A,P)|0,l=l+Math.imul(A,pe)|0,s=s+Math.imul(E,he)|0,c=c+Math.imul(E,ge)|0,c=c+Math.imul(D,he)|0,l=l+Math.imul(D,ge)|0,s=s+Math.imul(C,ve)|0,c=c+Math.imul(C,ye)|0,c=c+Math.imul(w,ve)|0,l=l+Math.imul(w,ye)|0,s=s+Math.imul(b,xe)|0,c=c+Math.imul(b,Se)|0,c=c+Math.imul(x,xe)|0,l=l+Math.imul(x,Se)|0,s=s+Math.imul(_,we)|0,c=c+Math.imul(_,Te)|0,c=c+Math.imul(v,we)|0,l=l+Math.imul(v,Te)|0,s=s+Math.imul(m,De)|0,c=c+Math.imul(m,Oe)|0,c=c+Math.imul(h,De)|0,l=l+Math.imul(h,Oe)|0,s=s+Math.imul(d,Ae)|0,c=c+Math.imul(d,je)|0,c=c+Math.imul(f,Ae)|0,l=l+Math.imul(f,je)|0;var Ue=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Ue>>>26)|0,Ue&=67108863,s=Math.imul(ae,se),c=Math.imul(ae,ce),c=c+Math.imul(N,se)|0,l=Math.imul(N,ce),s=s+Math.imul(ne,ue)|0,c=c+Math.imul(ne,de)|0,c=c+Math.imul(re,ue)|0,l=l+Math.imul(re,de)|0,s=s+Math.imul(j,P)|0,c=c+Math.imul(j,pe)|0,c=c+Math.imul(M,P)|0,l=l+Math.imul(M,pe)|0,s=s+Math.imul(k,he)|0,c=c+Math.imul(k,ge)|0,c=c+Math.imul(A,he)|0,l=l+Math.imul(A,ge)|0,s=s+Math.imul(E,ve)|0,c=c+Math.imul(E,ye)|0,c=c+Math.imul(D,ve)|0,l=l+Math.imul(D,ye)|0,s=s+Math.imul(C,xe)|0,c=c+Math.imul(C,Se)|0,c=c+Math.imul(w,xe)|0,l=l+Math.imul(w,Se)|0,s=s+Math.imul(b,we)|0,c=c+Math.imul(b,Te)|0,c=c+Math.imul(x,we)|0,l=l+Math.imul(x,Te)|0,s=s+Math.imul(_,De)|0,c=c+Math.imul(_,Oe)|0,c=c+Math.imul(v,De)|0,l=l+Math.imul(v,Oe)|0,s=s+Math.imul(m,Ae)|0,c=c+Math.imul(m,je)|0,c=c+Math.imul(h,Ae)|0,l=l+Math.imul(h,je)|0,s=s+Math.imul(d,Ne)|0,c=c+Math.imul(d,Pe)|0,c=c+Math.imul(f,Ne)|0,l=l+Math.imul(f,Pe)|0;var We=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(We>>>26)|0,We&=67108863,s=Math.imul(ae,ue),c=Math.imul(ae,de),c=c+Math.imul(N,ue)|0,l=Math.imul(N,de),s=s+Math.imul(ne,P)|0,c=c+Math.imul(ne,pe)|0,c=c+Math.imul(re,P)|0,l=l+Math.imul(re,pe)|0,s=s+Math.imul(j,he)|0,c=c+Math.imul(j,ge)|0,c=c+Math.imul(M,he)|0,l=l+Math.imul(M,ge)|0,s=s+Math.imul(k,ve)|0,c=c+Math.imul(k,ye)|0,c=c+Math.imul(A,ve)|0,l=l+Math.imul(A,ye)|0,s=s+Math.imul(E,xe)|0,c=c+Math.imul(E,Se)|0,c=c+Math.imul(D,xe)|0,l=l+Math.imul(D,Se)|0,s=s+Math.imul(C,we)|0,c=c+Math.imul(C,Te)|0,c=c+Math.imul(w,we)|0,l=l+Math.imul(w,Te)|0,s=s+Math.imul(b,De)|0,c=c+Math.imul(b,Oe)|0,c=c+Math.imul(x,De)|0,l=l+Math.imul(x,Oe)|0,s=s+Math.imul(_,Ae)|0,c=c+Math.imul(_,je)|0,c=c+Math.imul(v,Ae)|0,l=l+Math.imul(v,je)|0,s=s+Math.imul(m,Ne)|0,c=c+Math.imul(m,Pe)|0,c=c+Math.imul(h,Ne)|0,l=l+Math.imul(h,Pe)|0;var Ge=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Ge>>>26)|0,Ge&=67108863,s=Math.imul(ae,P),c=Math.imul(ae,pe),c=c+Math.imul(N,P)|0,l=Math.imul(N,pe),s=s+Math.imul(ne,he)|0,c=c+Math.imul(ne,ge)|0,c=c+Math.imul(re,he)|0,l=l+Math.imul(re,ge)|0,s=s+Math.imul(j,ve)|0,c=c+Math.imul(j,ye)|0,c=c+Math.imul(M,ve)|0,l=l+Math.imul(M,ye)|0,s=s+Math.imul(k,xe)|0,c=c+Math.imul(k,Se)|0,c=c+Math.imul(A,xe)|0,l=l+Math.imul(A,Se)|0,s=s+Math.imul(E,we)|0,c=c+Math.imul(E,Te)|0,c=c+Math.imul(D,we)|0,l=l+Math.imul(D,Te)|0,s=s+Math.imul(C,De)|0,c=c+Math.imul(C,Oe)|0,c=c+Math.imul(w,De)|0,l=l+Math.imul(w,Oe)|0,s=s+Math.imul(b,Ae)|0,c=c+Math.imul(b,je)|0,c=c+Math.imul(x,Ae)|0,l=l+Math.imul(x,je)|0,s=s+Math.imul(_,Ne)|0,c=c+Math.imul(_,Pe)|0,c=c+Math.imul(v,Ne)|0,l=l+Math.imul(v,Pe)|0;var Ke=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Ke>>>26)|0,Ke&=67108863,s=Math.imul(ae,he),c=Math.imul(ae,ge),c=c+Math.imul(N,he)|0,l=Math.imul(N,ge),s=s+Math.imul(ne,ve)|0,c=c+Math.imul(ne,ye)|0,c=c+Math.imul(re,ve)|0,l=l+Math.imul(re,ye)|0,s=s+Math.imul(j,xe)|0,c=c+Math.imul(j,Se)|0,c=c+Math.imul(M,xe)|0,l=l+Math.imul(M,Se)|0,s=s+Math.imul(k,we)|0,c=c+Math.imul(k,Te)|0,c=c+Math.imul(A,we)|0,l=l+Math.imul(A,Te)|0,s=s+Math.imul(E,De)|0,c=c+Math.imul(E,Oe)|0,c=c+Math.imul(D,De)|0,l=l+Math.imul(D,Oe)|0,s=s+Math.imul(C,Ae)|0,c=c+Math.imul(C,je)|0,c=c+Math.imul(w,Ae)|0,l=l+Math.imul(w,je)|0,s=s+Math.imul(b,Ne)|0,c=c+Math.imul(b,Pe)|0,c=c+Math.imul(x,Ne)|0,l=l+Math.imul(x,Pe)|0;var qe=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(qe>>>26)|0,qe&=67108863,s=Math.imul(ae,ve),c=Math.imul(ae,ye),c=c+Math.imul(N,ve)|0,l=Math.imul(N,ye),s=s+Math.imul(ne,xe)|0,c=c+Math.imul(ne,Se)|0,c=c+Math.imul(re,xe)|0,l=l+Math.imul(re,Se)|0,s=s+Math.imul(j,we)|0,c=c+Math.imul(j,Te)|0,c=c+Math.imul(M,we)|0,l=l+Math.imul(M,Te)|0,s=s+Math.imul(k,De)|0,c=c+Math.imul(k,Oe)|0,c=c+Math.imul(A,De)|0,l=l+Math.imul(A,Oe)|0,s=s+Math.imul(E,Ae)|0,c=c+Math.imul(E,je)|0,c=c+Math.imul(D,Ae)|0,l=l+Math.imul(D,je)|0,s=s+Math.imul(C,Ne)|0,c=c+Math.imul(C,Pe)|0,c=c+Math.imul(w,Ne)|0,l=l+Math.imul(w,Pe)|0;var Je=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Je>>>26)|0,Je&=67108863,s=Math.imul(ae,xe),c=Math.imul(ae,Se),c=c+Math.imul(N,xe)|0,l=Math.imul(N,Se),s=s+Math.imul(ne,we)|0,c=c+Math.imul(ne,Te)|0,c=c+Math.imul(re,we)|0,l=l+Math.imul(re,Te)|0,s=s+Math.imul(j,De)|0,c=c+Math.imul(j,Oe)|0,c=c+Math.imul(M,De)|0,l=l+Math.imul(M,Oe)|0,s=s+Math.imul(k,Ae)|0,c=c+Math.imul(k,je)|0,c=c+Math.imul(A,Ae)|0,l=l+Math.imul(A,je)|0,s=s+Math.imul(E,Ne)|0,c=c+Math.imul(E,Pe)|0,c=c+Math.imul(D,Ne)|0,l=l+Math.imul(D,Pe)|0;var Ye=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Ye>>>26)|0,Ye&=67108863,s=Math.imul(ae,we),c=Math.imul(ae,Te),c=c+Math.imul(N,we)|0,l=Math.imul(N,Te),s=s+Math.imul(ne,De)|0,c=c+Math.imul(ne,Oe)|0,c=c+Math.imul(re,De)|0,l=l+Math.imul(re,Oe)|0,s=s+Math.imul(j,Ae)|0,c=c+Math.imul(j,je)|0,c=c+Math.imul(M,Ae)|0,l=l+Math.imul(M,je)|0,s=s+Math.imul(k,Ne)|0,c=c+Math.imul(k,Pe)|0,c=c+Math.imul(A,Ne)|0,l=l+Math.imul(A,Pe)|0;var Xe=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Xe>>>26)|0,Xe&=67108863,s=Math.imul(ae,De),c=Math.imul(ae,Oe),c=c+Math.imul(N,De)|0,l=Math.imul(N,Oe),s=s+Math.imul(ne,Ae)|0,c=c+Math.imul(ne,je)|0,c=c+Math.imul(re,Ae)|0,l=l+Math.imul(re,je)|0,s=s+Math.imul(j,Ne)|0,c=c+Math.imul(j,Pe)|0,c=c+Math.imul(M,Ne)|0,l=l+Math.imul(M,Pe)|0;var Ze=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Ze>>>26)|0,Ze&=67108863,s=Math.imul(ae,Ae),c=Math.imul(ae,je),c=c+Math.imul(N,Ae)|0,l=Math.imul(N,je),s=s+Math.imul(ne,Ne)|0,c=c+Math.imul(ne,Pe)|0,c=c+Math.imul(re,Ne)|0,l=l+Math.imul(re,Pe)|0;var Qe=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Qe>>>26)|0,Qe&=67108863,s=Math.imul(ae,Ne),c=Math.imul(ae,Pe),c=c+Math.imul(N,Ne)|0,l=Math.imul(N,Pe);var $e=(o+s|0)+((c&8191)<<13)|0;return o=(l+(c>>>13)|0)+($e>>>26)|0,$e&=67108863,a[0]=Fe,a[1]=Ie,a[2]=Le,a[3]=Re,a[4]=ze,a[5]=Be,a[6]=Ve,a[7]=He,a[8]=Ue,a[9]=We,a[10]=Ge,a[11]=Ke,a[12]=qe,a[13]=Je,a[14]=Ye,a[15]=Xe,a[16]=Ze,a[17]=Qe,a[18]=$e,o!==0&&(a[19]=o,n.length++),n};Math.imul||(v=_);function y(e,t,n){n.negative=t.negative^e.negative,n.length=e.length+t.length;for(var r=0,i=0,a=0;a<n.length-1;a++){var o=i;i=0;for(var s=r&67108863,c=Math.min(a,t.length-1),l=Math.max(0,a-e.length+1);l<=c;l++){var u=a-l,d=(e.words[u]|0)*(t.words[l]|0),f=d&67108863;o=o+(d/67108864|0)|0,f=f+s|0,s=f&67108863,o=o+(f>>>26)|0,i+=o>>>26,o&=67108863}n.words[a]=s,r=o,o=i}return r===0?n.length--:n.words[a]=r,n._strip()}function b(e,t,n){return y(e,t,n)}i.prototype.mulTo=function(e,t){var n,r=this.length+e.length;return n=this.length===10&&e.length===10?v(this,e,t):r<63?_(this,e,t):r<1024?y(this,e,t):b(this,e,t),n};function x(e,t){this.x=e,this.y=t}x.prototype.makeRBT=function(e){for(var t=Array(e),n=i.prototype._countBits(e)-1,r=0;r<e;r++)t[r]=this.revBin(r,n,e);return t},x.prototype.revBin=function(e,t,n){if(e===0||e===n-1)return e;for(var r=0,i=0;i<t;i++)r|=(e&1)<<t-i-1,e>>=1;return r},x.prototype.permute=function(e,t,n,r,i,a){for(var o=0;o<a;o++)r[o]=t[e[o]],i[o]=n[e[o]]},x.prototype.transform=function(e,t,n,r,i,a){this.permute(a,e,t,n,r,i);for(var o=1;o<i;o<<=1)for(var s=o<<1,c=Math.cos(2*Math.PI/s),l=Math.sin(2*Math.PI/s),u=0;u<i;u+=s)for(var d=c,f=l,p=0;p<o;p++){var m=n[u+p],h=r[u+p],g=n[u+p+o],_=r[u+p+o],v=d*g-f*_;_=d*_+f*g,g=v,n[u+p]=m+g,r[u+p]=h+_,n[u+p+o]=m-g,r[u+p+o]=h-_,p!==s&&(v=c*d-l*f,f=c*f+l*d,d=v)}},x.prototype.guessLen13b=function(e,t){var n=Math.max(t,e)|1,r=n&1,i=0;for(n=n/2|0;n;n>>>=1)i++;return 1<<i+1+r},x.prototype.conjugate=function(e,t,n){if(!(n<=1))for(var r=0;r<n/2;r++){var i=e[r];e[r]=e[n-r-1],e[n-r-1]=i,i=t[r],t[r]=-t[n-r-1],t[n-r-1]=-i}},x.prototype.normalize13b=function(e,t){for(var n=0,r=0;r<t/2;r++){var i=Math.round(e[2*r+1]/t)*8192+Math.round(e[2*r]/t)+n;e[r]=i&67108863,n=i<67108864?0:i/67108864|0}return e},x.prototype.convert13b=function(e,t,r,i){for(var a=0,o=0;o<t;o++)a+=e[o]|0,r[2*o]=a&8191,a>>>=13,r[2*o+1]=a&8191,a>>>=13;for(o=2*t;o<i;++o)r[o]=0;n(a===0),n((a&-8192)==0)},x.prototype.stub=function(e){for(var t=Array(e),n=0;n<e;n++)t[n]=0;return t},x.prototype.mulp=function(e,t,n){var r=2*this.guessLen13b(e.length,t.length),i=this.makeRBT(r),a=this.stub(r),o=Array(r),s=Array(r),c=Array(r),l=Array(r),u=Array(r),d=Array(r),f=n.words;f.length=r,this.convert13b(e.words,e.length,o,r),this.convert13b(t.words,t.length,l,r),this.transform(o,a,s,c,r,i),this.transform(l,a,u,d,r,i);for(var p=0;p<r;p++){var m=s[p]*u[p]-c[p]*d[p];c[p]=s[p]*d[p]+c[p]*u[p],s[p]=m}return this.conjugate(s,c,r),this.transform(s,c,f,a,r,i),this.conjugate(f,a,r),this.normalize13b(f,r),n.negative=e.negative^t.negative,n.length=e.length+t.length,n._strip()},i.prototype.mul=function(e){var t=new i(null);return t.words=Array(this.length+e.length),this.mulTo(e,t)},i.prototype.mulf=function(e){var t=new i(null);return t.words=Array(this.length+e.length),b(this,e,t)},i.prototype.imul=function(e){return this.clone().mulTo(e,this)},i.prototype.imuln=function(e){var t=e<0;t&&(e=-e),n(typeof e==`number`),n(e<67108864);for(var r=0,i=0;i<this.length;i++){var a=(this.words[i]|0)*e,o=(a&67108863)+(r&67108863);r>>=26,r+=a/67108864|0,r+=o>>>26,this.words[i]=o&67108863}return r!==0&&(this.words[i]=r,this.length++),this.length=e===0?1:this.length,t?this.ineg():this},i.prototype.muln=function(e){return this.clone().imuln(e)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(e){var t=g(e);if(t.length===0)return new i(1);for(var n=this,r=0;r<t.length&&t[r]===0;r++,n=n.sqr());if(++r<t.length)for(var a=n.sqr();r<t.length;r++,a=a.sqr())t[r]!==0&&(n=n.mul(a));return n},i.prototype.iushln=function(e){n(typeof e==`number`&&e>=0);var t=e%26,r=(e-t)/26,i=67108863>>>26-t<<26-t,a;if(t!==0){var o=0;for(a=0;a<this.length;a++){var s=this.words[a]&i,c=(this.words[a]|0)-s<<t;this.words[a]=c|o,o=s>>>26-t}o&&(this.words[a]=o,this.length++)}if(r!==0){for(a=this.length-1;a>=0;a--)this.words[a+r]=this.words[a];for(a=0;a<r;a++)this.words[a]=0;this.length+=r}return this._strip()},i.prototype.ishln=function(e){return n(this.negative===0),this.iushln(e)},i.prototype.iushrn=function(e,t,r){n(typeof e==`number`&&e>=0);var i=t?(t-t%26)/26:0,a=e%26,o=Math.min((e-a)/26,this.length),s=67108863^67108863>>>a<<a,c=r;if(i-=o,i=Math.max(0,i),c){for(var l=0;l<o;l++)c.words[l]=this.words[l];c.length=o}if(o!==0)if(this.length>o)for(this.length-=o,l=0;l<this.length;l++)this.words[l]=this.words[l+o];else this.words[0]=0,this.length=1;var u=0;for(l=this.length-1;l>=0&&(u!==0||l>=i);l--){var d=this.words[l]|0;this.words[l]=u<<26-a|d>>>a,u=d&s}return c&&u!==0&&(c.words[c.length++]=u),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},i.prototype.ishrn=function(e,t,r){return n(this.negative===0),this.iushrn(e,t,r)},i.prototype.shln=function(e){return this.clone().ishln(e)},i.prototype.ushln=function(e){return this.clone().iushln(e)},i.prototype.shrn=function(e){return this.clone().ishrn(e)},i.prototype.ushrn=function(e){return this.clone().iushrn(e)},i.prototype.testn=function(e){n(typeof e==`number`&&e>=0);var t=e%26,r=(e-t)/26,i=1<<t;return this.length<=r?!1:!!(this.words[r]&i)},i.prototype.imaskn=function(e){n(typeof e==`number`&&e>=0);var t=e%26,r=(e-t)/26;if(n(this.negative===0,`imaskn works only with positive numbers`),this.length<=r)return this;if(t!==0&&r++,this.length=Math.min(r,this.length),t!==0){var i=67108863^67108863>>>t<<t;this.words[this.length-1]&=i}return this.length===0&&(this.words[0]=0,this.length=1),this._strip()},i.prototype.maskn=function(e){return this.clone().imaskn(e)},i.prototype.iaddn=function(e){return n(typeof e==`number`),n(e<67108864),e<0?this.isubn(-e):this.negative===0?this._iaddn(e):this.length===1&&(this.words[0]|0)<=e?(this.words[0]=e-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(e),this.negative=1,this)},i.prototype._iaddn=function(e){this.words[0]+=e;for(var t=0;t<this.length&&this.words[t]>=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},i.prototype.isubn=function(e){if(n(typeof e==`number`),n(e<67108864),e<0)return this.iaddn(-e);if(this.negative!==0)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t<this.length&&this.words[t]<0;t++)this.words[t]+=67108864,--this.words[t+1];return this._strip()},i.prototype.addn=function(e){return this.clone().iaddn(e)},i.prototype.subn=function(e){return this.clone().isubn(e)},i.prototype.iabs=function(){return this.negative=0,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(e,t,r){var i=e.length+r,a;this._expand(i);var o,s=0;for(a=0;a<e.length;a++){o=(this.words[a+r]|0)+s;var c=(e.words[a]|0)*t;o-=c&67108863,s=(o>>26)-(c/67108864|0),this.words[a+r]=o&67108863}for(;a<this.length-r;a++)o=(this.words[a+r]|0)+s,s=o>>26,this.words[a+r]=o&67108863;if(s===0)return this._strip();for(n(s===-1),s=0,a=0;a<this.length;a++)o=-(this.words[a]|0)+s,s=o>>26,this.words[a]=o&67108863;return this.negative=1,this._strip()},i.prototype._wordDiv=function(e,t){var n=this.length-e.length,r=this.clone(),a=e,o=a.words[a.length-1]|0;n=26-this._countBits(o),n!==0&&(a=a.ushln(n),r.iushln(n),o=a.words[a.length-1]|0);var s=r.length-a.length,c;if(t!==`mod`){c=new i(null),c.length=s+1,c.words=Array(c.length);for(var l=0;l<c.length;l++)c.words[l]=0}var u=r.clone()._ishlnsubmul(a,1,s);u.negative===0&&(r=u,c&&(c.words[s]=1));for(var d=s-1;d>=0;d--){var f=(r.words[a.length+d]|0)*67108864+(r.words[a.length+d-1]|0);for(f=Math.min(f/o|0,67108863),r._ishlnsubmul(a,f,d);r.negative!==0;)f--,r.negative=0,r._ishlnsubmul(a,1,d),r.isZero()||(r.negative^=1);c&&(c.words[d]=f)}return c&&c._strip(),r._strip(),t!==`div`&&n!==0&&r.iushrn(n),{div:c||null,mod:r}},i.prototype.divmod=function(e,t,r){if(n(!e.isZero()),this.isZero())return{div:new i(0),mod:new i(0)};var a,o,s;return this.negative!==0&&e.negative===0?(s=this.neg().divmod(e,t),t!==`mod`&&(a=s.div.neg()),t!==`div`&&(o=s.mod.neg(),r&&o.negative!==0&&o.iadd(e)),{div:a,mod:o}):this.negative===0&&e.negative!==0?(s=this.divmod(e.neg(),t),t!==`mod`&&(a=s.div.neg()),{div:a,mod:s.mod}):(this.negative&e.negative)===0?e.length>this.length||this.cmp(e)<0?{div:new i(0),mod:this}:e.length===1?t===`div`?{div:this.divn(e.words[0]),mod:null}:t===`mod`?{div:null,mod:new i(this.modrn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new i(this.modrn(e.words[0]))}:this._wordDiv(e,t):(s=this.neg().divmod(e.neg(),t),t!==`div`&&(o=s.mod.neg(),r&&o.negative!==0&&o.isub(e)),{div:s.div,mod:o})},i.prototype.div=function(e){return this.divmod(e,`div`,!1).div},i.prototype.mod=function(e){return this.divmod(e,`mod`,!1).mod},i.prototype.umod=function(e){return this.divmod(e,`mod`,!0).mod},i.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var n=t.div.negative===0?t.mod:t.mod.isub(e),r=e.ushrn(1),i=e.andln(1),a=n.cmp(r);return a<0||i===1&&a===0?t.div:t.div.negative===0?t.div.iaddn(1):t.div.isubn(1)},i.prototype.modrn=function(e){var t=e<0;t&&(e=-e),n(e<=67108863);for(var r=(1<<26)%e,i=0,a=this.length-1;a>=0;a--)i=(r*i+(this.words[a]|0))%e;return t?-i:i},i.prototype.modn=function(e){return this.modrn(e)},i.prototype.idivn=function(e){var t=e<0;t&&(e=-e),n(e<=67108863);for(var r=0,i=this.length-1;i>=0;i--){var a=(this.words[i]|0)+r*67108864;this.words[i]=a/e|0,r=a%e}return this._strip(),t?this.ineg():this},i.prototype.divn=function(e){return this.clone().idivn(e)},i.prototype.egcd=function(e){n(e.negative===0),n(!e.isZero());var t=this,r=e.clone();t=t.negative===0?t.clone():t.umod(e);for(var a=new i(1),o=new i(0),s=new i(0),c=new i(1),l=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++l;for(var u=r.clone(),d=t.clone();!t.isZero();){for(var f=0,p=1;(t.words[0]&p)===0&&f<26;++f,p<<=1);if(f>0)for(t.iushrn(f);f-- >0;)(a.isOdd()||o.isOdd())&&(a.iadd(u),o.isub(d)),a.iushrn(1),o.iushrn(1);for(var m=0,h=1;(r.words[0]&h)===0&&m<26;++m,h<<=1);if(m>0)for(r.iushrn(m);m-- >0;)(s.isOdd()||c.isOdd())&&(s.iadd(u),c.isub(d)),s.iushrn(1),c.iushrn(1);t.cmp(r)>=0?(t.isub(r),a.isub(s),o.isub(c)):(r.isub(t),s.isub(a),c.isub(o))}return{a:s,b:c,gcd:r.iushln(l)}},i.prototype._invmp=function(e){n(e.negative===0),n(!e.isZero());var t=this,r=e.clone();t=t.negative===0?t.clone():t.umod(e);for(var a=new i(1),o=new i(0),s=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var c=0,l=1;(t.words[0]&l)===0&&c<26;++c,l<<=1);if(c>0)for(t.iushrn(c);c-- >0;)a.isOdd()&&a.iadd(s),a.iushrn(1);for(var u=0,d=1;(r.words[0]&d)===0&&u<26;++u,d<<=1);if(u>0)for(r.iushrn(u);u-- >0;)o.isOdd()&&o.iadd(s),o.iushrn(1);t.cmp(r)>=0?(t.isub(r),a.isub(o)):(r.isub(t),o.isub(a))}var f=t.cmpn(1)===0?a:o;return f.cmpn(0)<0&&f.iadd(e),f},i.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),n=e.clone();t.negative=0,n.negative=0;for(var r=0;t.isEven()&&n.isEven();r++)t.iushrn(1),n.iushrn(1);do{for(;t.isEven();)t.iushrn(1);for(;n.isEven();)n.iushrn(1);var i=t.cmp(n);if(i<0){var a=t;t=n,n=a}else if(i===0||n.cmpn(1)===0)break;t.isub(n)}while(!0);return n.iushln(r)},i.prototype.invm=function(e){return this.egcd(e).a.umod(e)},i.prototype.isEven=function(){return(this.words[0]&1)==0},i.prototype.isOdd=function(){return(this.words[0]&1)==1},i.prototype.andln=function(e){return this.words[0]&e},i.prototype.bincn=function(e){n(typeof e==`number`);var t=e%26,r=(e-t)/26,i=1<<t;if(this.length<=r)return this._expand(r+1),this.words[r]|=i,this;for(var a=i,o=r;a!==0&&o<this.length;o++){var s=this.words[o]|0;s+=a,a=s>>>26,s&=67108863,this.words[o]=s}return a!==0&&(this.words[o]=a,this.length++),this},i.prototype.isZero=function(){return this.length===1&&this.words[0]===0},i.prototype.cmpn=function(e){var t=e<0;if(this.negative!==0&&!t)return-1;if(this.negative===0&&t)return 1;this._strip();var r;if(this.length>1)r=1;else{t&&(e=-e),n(e<=67108863,`Number is too big`);var i=this.words[0]|0;r=i===e?0:i<e?-1:1}return this.negative===0?r:-r|0},i.prototype.cmp=function(e){if(this.negative!==0&&e.negative===0)return-1;if(this.negative===0&&e.negative!==0)return 1;var t=this.ucmp(e);return this.negative===0?t:-t|0},i.prototype.ucmp=function(e){if(this.length>e.length)return 1;if(this.length<e.length)return-1;for(var t=0,n=this.length-1;n>=0;n--){var r=this.words[n]|0,i=e.words[n]|0;if(r!==i){r<i?t=-1:r>i&&(t=1);break}}return t},i.prototype.gtn=function(e){return this.cmpn(e)===1},i.prototype.gt=function(e){return this.cmp(e)===1},i.prototype.gten=function(e){return this.cmpn(e)>=0},i.prototype.gte=function(e){return this.cmp(e)>=0},i.prototype.ltn=function(e){return this.cmpn(e)===-1},i.prototype.lt=function(e){return this.cmp(e)===-1},i.prototype.lten=function(e){return this.cmpn(e)<=0},i.prototype.lte=function(e){return this.cmp(e)<=0},i.prototype.eqn=function(e){return this.cmpn(e)===0},i.prototype.eq=function(e){return this.cmp(e)===0},i.red=function(e){return new O(e)},i.prototype.toRed=function(e){return n(!this.red,`Already a number in reduction context`),n(this.negative===0,`red works only with positives`),e.convertTo(this)._forceRed(e)},i.prototype.fromRed=function(){return n(this.red,`fromRed works only with numbers in reduction context`),this.red.convertFrom(this)},i.prototype._forceRed=function(e){return this.red=e,this},i.prototype.forceRed=function(e){return n(!this.red,`Already a number in reduction context`),this._forceRed(e)},i.prototype.redAdd=function(e){return n(this.red,`redAdd works only with red numbers`),this.red.add(this,e)},i.prototype.redIAdd=function(e){return n(this.red,`redIAdd works only with red numbers`),this.red.iadd(this,e)},i.prototype.redSub=function(e){return n(this.red,`redSub works only with red numbers`),this.red.sub(this,e)},i.prototype.redISub=function(e){return n(this.red,`redISub works only with red numbers`),this.red.isub(this,e)},i.prototype.redShl=function(e){return n(this.red,`redShl works only with red numbers`),this.red.shl(this,e)},i.prototype.redMul=function(e){return n(this.red,`redMul works only with red numbers`),this.red._verify2(this,e),this.red.mul(this,e)},i.prototype.redIMul=function(e){return n(this.red,`redMul works only with red numbers`),this.red._verify2(this,e),this.red.imul(this,e)},i.prototype.redSqr=function(){return n(this.red,`redSqr works only with red numbers`),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return n(this.red,`redISqr works only with red numbers`),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return n(this.red,`redSqrt works only with red numbers`),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return n(this.red,`redInvm works only with red numbers`),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return n(this.red,`redNeg works only with red numbers`),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(e){return n(this.red&&!e.red,`redPow(normalNum)`),this.red._verify1(this),this.red.pow(this,e)};var S={k256:null,p224:null,p192:null,p25519:null};function C(e,t){this.name=e,this.p=new i(t,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}C.prototype._tmp=function(){var e=new i(null);return e.words=Array(Math.ceil(this.n/13)),e},C.prototype.ireduce=function(e){var t=e,n;do this.split(t,this.tmp),t=this.imulK(t),t=t.iadd(this.tmp),n=t.bitLength();while(n>this.n);var r=n<this.n?-1:t.ucmp(this.p);return r===0?(t.words[0]=0,t.length=1):r>0?t.isub(this.p):t.strip===void 0?t._strip():t.strip(),t},C.prototype.split=function(e,t){e.iushrn(this.n,0,t)},C.prototype.imulK=function(e){return e.imul(this.k)};function w(){C.call(this,`k256`,`ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f`)}r(w,C),w.prototype.split=function(e,t){for(var n=4194303,r=Math.min(e.length,9),i=0;i<r;i++)t.words[i]=e.words[i];if(t.length=r,e.length<=9){e.words[0]=0,e.length=1;return}var a=e.words[9];for(t.words[t.length++]=a&n,i=10;i<e.length;i++){var o=e.words[i]|0;e.words[i-10]=(o&n)<<4|a>>>22,a=o}a>>>=22,e.words[i-10]=a,a===0&&e.length>10?e.length-=10:e.length-=9},w.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,n=0;n<e.length;n++){var r=e.words[n]|0;t+=r*977,e.words[n]=t&67108863,t=r*64+(t/67108864|0)}return e.words[e.length-1]===0&&(e.length--,e.words[e.length-1]===0&&e.length--),e};function T(){C.call(this,`p224`,`ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001`)}r(T,C);function E(){C.call(this,`p192`,`ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff`)}r(E,C);function D(){C.call(this,`25519`,`7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed`)}r(D,C),D.prototype.imulK=function(e){for(var t=0,n=0;n<e.length;n++){var r=(e.words[n]|0)*19+t,i=r&67108863;r>>>=26,e.words[n]=i,t=r}return t!==0&&(e.words[e.length++]=t),e},i._prime=function(e){if(S[e])return S[e];var t;if(e===`k256`)t=new w;else if(e===`p224`)t=new T;else if(e===`p192`)t=new E;else if(e===`p25519`)t=new D;else throw Error(`Unknown prime `+e);return S[e]=t,t};function O(e){if(typeof e==`string`){var t=i._prime(e);this.m=t.p,this.prime=t}else n(e.gtn(1),`modulus must be greater than 1`),this.m=e,this.prime=null}O.prototype._verify1=function(e){n(e.negative===0,`red works only with positives`),n(e.red,`red works only with red numbers`)},O.prototype._verify2=function(e,t){n((e.negative|t.negative)===0,`red works only with positives`),n(e.red&&e.red===t.red,`red works only with red numbers`)},O.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):(u(e,e.umod(this.m)._forceRed(this)),e)},O.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},O.prototype.add=function(e,t){this._verify2(e,t);var n=e.add(t);return n.cmp(this.m)>=0&&n.isub(this.m),n._forceRed(this)},O.prototype.iadd=function(e,t){this._verify2(e,t);var n=e.iadd(t);return n.cmp(this.m)>=0&&n.isub(this.m),n},O.prototype.sub=function(e,t){this._verify2(e,t);var n=e.sub(t);return n.cmpn(0)<0&&n.iadd(this.m),n._forceRed(this)},O.prototype.isub=function(e,t){this._verify2(e,t);var n=e.isub(t);return n.cmpn(0)<0&&n.iadd(this.m),n},O.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},O.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},O.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},O.prototype.isqr=function(e){return this.imul(e,e.clone())},O.prototype.sqr=function(e){return this.mul(e,e)},O.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(n(t%2==1),t===3){var r=this.m.add(new i(1)).iushrn(2);return this.pow(e,r)}for(var a=this.m.subn(1),o=0;!a.isZero()&&a.andln(1)===0;)o++,a.iushrn(1);n(!a.isZero());var s=new i(1).toRed(this),c=s.redNeg(),l=this.m.subn(1).iushrn(1),u=this.m.bitLength();for(u=new i(2*u*u).toRed(this);this.pow(u,l).cmp(c)!==0;)u.redIAdd(c);for(var d=this.pow(u,a),f=this.pow(e,a.addn(1).iushrn(1)),p=this.pow(e,a),m=o;p.cmp(s)!==0;){for(var h=p,g=0;h.cmp(s)!==0;g++)h=h.redSqr();n(g<m);var _=this.pow(d,new i(1).iushln(m-g-1));f=f.redMul(_),d=_.redSqr(),p=p.redMul(d),m=g}return f},O.prototype.invm=function(e){var t=e._invmp(this.m);return t.negative===0?this.imod(t):(t.negative=0,this.imod(t).redNeg())},O.prototype.pow=function(e,t){if(t.isZero())return new i(1).toRed(this);if(t.cmpn(1)===0)return e.clone();var n=4,r=Array(1<<n);r[0]=new i(1).toRed(this),r[1]=e;for(var a=2;a<r.length;a++)r[a]=this.mul(r[a-1],e);var o=r[0],s=0,c=0,l=t.bitLength()%26;for(l===0&&(l=26),a=t.length-1;a>=0;a--){for(var u=t.words[a],d=l-1;d>=0;d--){var f=u>>d&1;if(o!==r[0]&&(o=this.sqr(o)),f===0&&s===0){c=0;continue}s<<=1,s|=f,c++,!(c!==n&&(a!==0||d!==0))&&(o=this.mul(o,r[s]),c=0,s=0)}l=26}return o},O.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},O.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},i.mont=function(e){return new k(e)};function k(e){O.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new i(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}r(k,O),k.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},k.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},k.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var n=e.imul(t),r=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=n.isub(r).iushrn(this.shift),a=i;return i.cmp(this.m)>=0?a=i.isub(this.m):i.cmpn(0)<0&&(a=i.iadd(this.m)),a._forceRed(this)},k.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new i(0)._forceRed(this);var n=e.mul(t),r=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),a=n.isub(r).iushrn(this.shift),o=a;return a.cmp(this.m)>=0?o=a.isub(this.m):a.cmpn(0)<0&&(o=a.iadd(this.m)),o._forceRed(this)},k.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}})(t===void 0||t,e)})),ir=i(((e,t)=>{var n=s(),r=n.Buffer;function i(e,t){for(var n in e)t[n]=e[n]}r.from&&r.alloc&&r.allocUnsafe&&r.allocUnsafeSlow?t.exports=n:(i(n,e),e.Buffer=a);function a(e,t,n){return r(e,t,n)}a.prototype=Object.create(r.prototype),i(r,a),a.from=function(e,t,n){if(typeof e==`number`)throw TypeError(`Argument must not be a number`);return r(e,t,n)},a.alloc=function(e,t,n){if(typeof e!=`number`)throw TypeError(`Argument must be a number`);var i=r(e);return t===void 0?i.fill(0):typeof n==`string`?i.fill(t,n):i.fill(t),i},a.allocUnsafe=function(e){if(typeof e!=`number`)throw TypeError(`Argument must be a number`);return r(e)},a.allocUnsafeSlow=function(e){if(typeof e!=`number`)throw TypeError(`Argument must be a number`);return n.SlowBuffer(e)}})),ar=i(((e,t)=>{var n=ir().Buffer;function r(e){if(e.length>=255)throw TypeError(`Alphabet too long`);for(var t=new Uint8Array(256),r=0;r<t.length;r++)t[r]=255;for(var i=0;i<e.length;i++){var a=e.charAt(i),o=a.charCodeAt(0);if(t[o]!==255)throw TypeError(a+` is ambiguous`);t[o]=i}var s=e.length,c=e.charAt(0),l=Math.log(s)/Math.log(256),u=Math.log(256)/Math.log(s);function d(t){if((Array.isArray(t)||t instanceof Uint8Array)&&(t=n.from(t)),!n.isBuffer(t))throw TypeError(`Expected Buffer`);if(t.length===0)return``;for(var r=0,i=0,a=0,o=t.length;a!==o&&t[a]===0;)a++,r++;for(var l=(o-a)*u+1>>>0,d=new Uint8Array(l);a!==o;){for(var f=t[a],p=0,m=l-1;(f!==0||p<i)&&m!==-1;m--,p++)f+=256*d[m]>>>0,d[m]=f%s>>>0,f=f/s>>>0;if(f!==0)throw Error(`Non-zero carry`);i=p,a++}for(var h=l-i;h!==l&&d[h]===0;)h++;for(var g=c.repeat(r);h<l;++h)g+=e.charAt(d[h]);return g}function f(e){if(typeof e!=`string`)throw TypeError(`Expected String`);if(e.length===0)return n.alloc(0);for(var r=0,i=0,a=0;e[r]===c;)i++,r++;for(var o=(e.length-r)*l+1>>>0,u=new Uint8Array(o);r<e.length;){var d=e.charCodeAt(r);if(d>255)return;var f=t[d];if(f===255)return;for(var p=0,m=o-1;(f!==0||p<a)&&m!==-1;m--,p++)f+=s*u[m]>>>0,u[m]=f%256>>>0,f=f/256>>>0;if(f!==0)throw Error(`Non-zero carry`);a=p,r++}for(var h=o-a;h!==o&&u[h]===0;)h++;var g=n.allocUnsafe(i+(o-h));g.fill(0,0,i);for(var _=i;h!==o;)g[_++]=u[h++];return g}function p(e){var t=f(e);if(t)return t;throw Error(`Non-base`+s+` character`)}return{encode:d,decodeUnsafe:f,decode:p}}t.exports=r})),or=i(((e,t)=>{t.exports=ar()(`123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz`)})),sr=i(((e,t)=>{var n=ir().Buffer;function r(e){if(e.length>=255)throw TypeError(`Alphabet too long`);for(var t=new Uint8Array(256),r=0;r<t.length;r++)t[r]=255;for(var i=0;i<e.length;i++){var a=e.charAt(i),o=a.charCodeAt(0);if(t[o]!==255)throw TypeError(a+` is ambiguous`);t[o]=i}var s=e.length,c=e.charAt(0),l=Math.log(s)/Math.log(256),u=Math.log(256)/Math.log(s);function d(t){if((Array.isArray(t)||t instanceof Uint8Array)&&(t=n.from(t)),!n.isBuffer(t))throw TypeError(`Expected Buffer`);if(t.length===0)return``;for(var r=0,i=0,a=0,o=t.length;a!==o&&t[a]===0;)a++,r++;for(var l=(o-a)*u+1>>>0,d=new Uint8Array(l);a!==o;){for(var f=t[a],p=0,m=l-1;(f!==0||p<i)&&m!==-1;m--,p++)f+=256*d[m]>>>0,d[m]=f%s>>>0,f=f/s>>>0;if(f!==0)throw Error(`Non-zero carry`);i=p,a++}for(var h=l-i;h!==l&&d[h]===0;)h++;for(var g=c.repeat(r);h<l;++h)g+=e.charAt(d[h]);return g}function f(e){if(typeof e!=`string`)throw TypeError(`Expected String`);if(e.length===0)return n.alloc(0);for(var r=0,i=0,a=0;e[r]===c;)i++,r++;for(var o=(e.length-r)*l+1>>>0,u=new Uint8Array(o);r<e.length;){var d=e.charCodeAt(r);if(d>255)return;var f=t[d];if(f===255)return;for(var p=0,m=o-1;(f!==0||p<a)&&m!==-1;m--,p++)f+=s*u[m]>>>0,u[m]=f%256>>>0,f=f/256>>>0;if(f!==0)throw Error(`Non-zero carry`);a=p,r++}for(var h=o-a;h!==o&&u[h]===0;)h++;var g=n.allocUnsafe(i+(o-h));g.fill(0,0,i);for(var _=i;h!==o;)g[_++]=u[h++];return g}function p(e){var t=f(e);if(t)return t;throw Error(`Non-base`+s+` character`)}return{encode:d,decodeUnsafe:f,decode:p}}t.exports=r})),cr=i(((e,t)=>{t.exports=sr()(`123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz`)})),lr=r({TextDecoder:()=>vr,TextEncoder:()=>yr});function ur(e,t,n){return t<=e&&e<=n}function dr(e){if(e===void 0)return{};if(e===Object(e))return e;throw TypeError(`Could not convert argument to dictionary`)}function fr(e){for(var t=String(e),n=t.length,r=0,i=[];r<n;){var a=t.charCodeAt(r);if(a<55296||a>57343)i.push(a);else if(56320<=a&&a<=57343)i.push(65533);else if(55296<=a&&a<=56319)if(r===n-1)i.push(65533);else{var o=e.charCodeAt(r+1);if(56320<=o&&o<=57343){var s=a&1023,c=o&1023;i.push(65536+(s<<10)+c),r+=1}else i.push(65533)}r+=1}return i}function pr(e){for(var t=``,n=0;n<e.length;++n){var r=e[n];r<=65535?t+=String.fromCharCode(r):(r-=65536,t+=String.fromCharCode((r>>10)+55296,(r&1023)+56320))}return t}function mr(e){this.tokens=[].slice.call(e)}function hr(e,t){if(e)throw TypeError(`Decoder error`);return t||65533}function gr(){}function _r(){}function vr(e,t){if(!(this instanceof vr))return new vr(e,t);if(e=e===void 0?wr:String(e).toLowerCase(),e!==wr)throw Error(`Encoding not supported. Only utf-8 is supported`);t=dr(t),this._streaming=!1,this._BOMseen=!1,this._decoder=null,this._fatal=!!t.fatal,this._ignoreBOM=!!t.ignoreBOM,Object.defineProperty(this,"encoding",{value:`utf-8`}),Object.defineProperty(this,"fatal",{value:this._fatal}),Object.defineProperty(this,"ignoreBOM",{value:this._ignoreBOM})}function yr(e,t){if(!(this instanceof yr))return new yr(e,t);if(e=e===void 0?wr:String(e).toLowerCase(),e!==wr)throw Error(`Encoding not supported. Only utf-8 is supported`);t=dr(t),this._streaming=!1,this._encoder=null,this._options={fatal:!!t.fatal},Object.defineProperty(this,"encoding",{value:`utf-8`})}function br(e){var t=e.fatal,n=0,r=0,i=0,a=128,o=191;this.handler=function(e,s){if(s===Sr&&i!==0)return i=0,hr(t);if(s===Sr)return Cr;if(i===0){if(ur(s,0,127))return s;if(ur(s,194,223))i=1,n=s-192;else if(ur(s,224,239))s===224&&(a=160),s===237&&(o=159),i=2,n=s-224;else if(ur(s,240,244))s===240&&(a=144),s===244&&(o=143),i=3,n=s-240;else return hr(t);return n<<=6*i,null}if(!ur(s,a,o))return n=i=r=0,a=128,o=191,e.prepend(s),hr(t);if(a=128,o=191,r+=1,n+=s-128<<6*(i-r),r!==i)return null;var c=n;return n=i=r=0,c}}function xr(e){e.fatal,this.handler=function(e,t){if(t===Sr)return Cr;if(ur(t,0,127))return t;var n,r;ur(t,128,2047)?(n=1,r=192):ur(t,2048,65535)?(n=2,r=224):ur(t,65536,1114111)&&(n=3,r=240);for(var i=[(t>>6*n)+r];n>0;){var a=t>>6*(n-1);i.push(128|a&63),--n}return i}}var Sr,Cr,wr,Tr=t((()=>{Sr=-1,mr.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():Sr},prepend:function(e){if(Array.isArray(e))for(var t=e;t.length;)this.tokens.unshift(t.pop());else this.tokens.unshift(e)},push:function(e){if(Array.isArray(e))for(var t=e;t.length;)this.tokens.push(t.shift());else this.tokens.push(e)}},Cr=-1,gr.prototype={handler:function(e,t){}},_r.prototype={handler:function(e,t){}},wr=`utf-8`,vr.prototype={decode:function(e,t){var n=typeof e==`object`&&e instanceof ArrayBuffer?new Uint8Array(e):typeof e==`object`&&`buffer`in e&&e.buffer instanceof ArrayBuffer?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array;t=dr(t),this._streaming||(this._decoder=new br({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!t.stream;for(var r=new mr(n),i=[],a;!r.endOfStream()&&(a=this._decoder.handler(r,r.read()),a!==Cr);)a!==null&&(Array.isArray(a)?i.push.apply(i,a):i.push(a));if(!this._streaming){do{if(a=this._decoder.handler(r,r.read()),a===Cr)break;if(a===null)continue;Array.isArray(a)?i.push.apply(i,a):i.push(a)}while(!r.endOfStream());this._decoder=null}return i.length&&[`utf-8`].indexOf(this.encoding)!==-1&&!this._ignoreBOM&&!this._BOMseen&&(i[0]===65279?(this._BOMseen=!0,i.shift()):this._BOMseen=!0),pr(i)}},yr.prototype={encode:function(e,t){e=e?String(e):``,t=dr(t),this._streaming||(this._encoder=new xr(this._options)),this._streaming=!!t.stream;for(var n=[],r=new mr(fr(e)),i;!r.endOfStream()&&(i=this._encoder.handler(r,r.read()),i!==Cr);)Array.isArray(i)?n.push.apply(n,i):n.push(i);if(!this._streaming){for(;i=this._encoder.handler(r,r.read()),i!==Cr;)Array.isArray(i)?n.push.apply(n,i):n.push(i);this._encoder=null}return new Uint8Array(n)}}})),Er=i((t=>{var n=t&&t.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),r=t&&t.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),i=t&&t.__decorate||function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},a=t&&t.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var i in e)i!==`default`&&Object.hasOwnProperty.call(e,i)&&n(t,e,i);return r(t,e),t},o=t&&t.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.deserializeUnchecked=t.deserialize=t.serialize=t.BinaryReader=t.BinaryWriter=t.BorshError=t.baseDecode=t.baseEncode=void 0;var s=o(rr()),c=o(cr()),l=a((Tr(),e(lr))),u=new(typeof TextDecoder==`function`?TextDecoder:l.TextDecoder)(`utf-8`,{fatal:!0});function d(e){return typeof e==`string`&&(e=Buffer.from(e,`utf8`)),c.default.encode(Buffer.from(e))}t.baseEncode=d;function f(e){return Buffer.from(c.default.decode(e))}t.baseDecode=f;var p=1024,m=class extends Error{constructor(e){super(e),this.fieldPath=[],this.originalMessage=e}addToFieldPath(e){this.fieldPath.splice(0,0,e),this.message=this.originalMessage+`: `+this.fieldPath.join(`.`)}};t.BorshError=m;var h=class{constructor(){this.buf=Buffer.alloc(p),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Buffer.concat([this.buf,Buffer.alloc(p)]))}writeU8(e){this.maybeResize(),this.buf.writeUInt8(e,this.length),this.length+=1}writeU16(e){this.maybeResize(),this.buf.writeUInt16LE(e,this.length),this.length+=2}writeU32(e){this.maybeResize(),this.buf.writeUInt32LE(e,this.length),this.length+=4}writeU64(e){this.maybeResize(),this.writeBuffer(Buffer.from(new s.default(e).toArray(`le`,8)))}writeU128(e){this.maybeResize(),this.writeBuffer(Buffer.from(new s.default(e).toArray(`le`,16)))}writeU256(e){this.maybeResize(),this.writeBuffer(Buffer.from(new s.default(e).toArray(`le`,32)))}writeU512(e){this.maybeResize(),this.writeBuffer(Buffer.from(new s.default(e).toArray(`le`,64)))}writeBuffer(e){this.buf=Buffer.concat([Buffer.from(this.buf.subarray(0,this.length)),e,Buffer.alloc(p)]),this.length+=e.length}writeString(e){this.maybeResize();let t=Buffer.from(e,`utf8`);this.writeU32(t.length),this.writeBuffer(t)}writeFixedArray(e){this.writeBuffer(Buffer.from(e))}writeArray(e,t){this.maybeResize(),this.writeU32(e.length);for(let n of e)this.maybeResize(),t(n)}toArray(){return this.buf.subarray(0,this.length)}};t.BinaryWriter=h;function g(e,t,n){let r=n.value;n.value=function(...e){try{return r.apply(this,e)}catch(e){if(e instanceof RangeError){let t=e.code;if([`ERR_BUFFER_OUT_OF_BOUNDS`,`ERR_OUT_OF_RANGE`].indexOf(t)>=0)throw new m(`Reached the end of buffer when deserializing`)}throw e}}}var _=class{constructor(e){this.buf=e,this.offset=0}readU8(){let e=this.buf.readUInt8(this.offset);return this.offset+=1,e}readU16(){let e=this.buf.readUInt16LE(this.offset);return this.offset+=2,e}readU32(){let e=this.buf.readUInt32LE(this.offset);return this.offset+=4,e}readU64(){let e=this.readBuffer(8);return new s.default(e,`le`)}readU128(){let e=this.readBuffer(16);return new s.default(e,`le`)}readU256(){let e=this.readBuffer(32);return new s.default(e,`le`)}readU512(){let e=this.readBuffer(64);return new s.default(e,`le`)}readBuffer(e){if(this.offset+e>this.buf.length)throw new m(`Expected buffer length ${e} isn't within bounds`);let t=this.buf.slice(this.offset,this.offset+e);return this.offset+=e,t}readString(){let e=this.readU32(),t=this.readBuffer(e);try{return u.decode(t)}catch(e){throw new m(`Error decoding UTF-8 string: ${e}`)}}readFixedArray(e){return new Uint8Array(this.readBuffer(e))}readArray(e){let t=this.readU32(),n=[];for(let r=0;r<t;++r)n.push(e());return n}};i([g],_.prototype,`readU8`,null),i([g],_.prototype,`readU16`,null),i([g],_.prototype,`readU32`,null),i([g],_.prototype,`readU64`,null),i([g],_.prototype,`readU128`,null),i([g],_.prototype,`readU256`,null),i([g],_.prototype,`readU512`,null),i([g],_.prototype,`readString`,null),i([g],_.prototype,`readFixedArray`,null),i([g],_.prototype,`readArray`,null),t.BinaryReader=_;function v(e){return e.charAt(0).toUpperCase()+e.slice(1)}function y(e,t,n,r,i){try{if(typeof r==`string`)i[`write${v(r)}`](n);else if(r instanceof Array)if(typeof r[0]==`number`){if(n.length!==r[0])throw new m(`Expecting byte array of length ${r[0]}, but got ${n.length} bytes`);i.writeFixedArray(n)}else if(r.length===2&&typeof r[1]==`number`){if(n.length!==r[1])throw new m(`Expecting byte array of length ${r[1]}, but got ${n.length} bytes`);for(let t=0;t<r[1];t++)y(e,null,n[t],r[0],i)}else i.writeArray(n,n=>{y(e,t,n,r[0],i)});else if(r.kind!==void 0)switch(r.kind){case`option`:n==null?i.writeU8(0):(i.writeU8(1),y(e,t,n,r.type,i));break;case`map`:i.writeU32(n.size),n.forEach((n,a)=>{y(e,t,a,r.key,i),y(e,t,n,r.value,i)});break;default:throw new m(`FieldType ${r} unrecognized`)}else b(e,n,i)}catch(e){throw e instanceof m&&e.addToFieldPath(t),e}}function b(e,t,n){if(typeof t.borshSerialize==`function`){t.borshSerialize(n);return}let r=e.get(t.constructor);if(!r)throw new m(`Class ${t.constructor.name} is missing in schema`);if(r.kind===`struct`)r.fields.map(([r,i])=>{y(e,r,t[r],i,n)});else if(r.kind===`enum`){let i=t[r.field];for(let a=0;a<r.values.length;++a){let[o,s]=r.values[a];if(o===i){n.writeU8(a),y(e,o,t[o],s,n);break}}}else throw new m(`Unexpected schema kind: ${r.kind} for ${t.constructor.name}`)}function x(e,t,n=h){let r=new n;return b(e,t,r),r.toArray()}t.serialize=x;function S(e,t,n,r){try{if(typeof n==`string`)return r[`read${v(n)}`]();if(n instanceof Array){if(typeof n[0]==`number`)return r.readFixedArray(n[0]);if(typeof n[1]==`number`){let t=[];for(let i=0;i<n[1];i++)t.push(S(e,null,n[0],r));return t}else return r.readArray(()=>S(e,t,n[0],r))}if(n.kind===`option`)return r.readU8()?S(e,t,n.type,r):void 0;if(n.kind===`map`){let i=new Map,a=r.readU32();for(let o=0;o<a;o++){let a=S(e,t,n.key,r),o=S(e,t,n.value,r);i.set(a,o)}return i}return C(e,n,r)}catch(e){throw e instanceof m&&e.addToFieldPath(t),e}}function C(e,t,n){if(typeof t.borshDeserialize==`function`)return t.borshDeserialize(n);let r=e.get(t);if(!r)throw new m(`Class ${t.name} is missing in schema`);if(r.kind===`struct`){let r={};for(let[i,a]of e.get(t).fields)r[i]=S(e,i,a,n);return new t(r)}if(r.kind===`enum`){let i=n.readU8();if(i>=r.values.length)throw new m(`Enum index: ${i} is out of range`);let[a,o]=r.values[i],s=S(e,a,o,n);return new t({[a]:s})}throw new m(`Unexpected schema kind: ${r.kind} for ${t.constructor.name}`)}function w(e,t,n,r=_){let i=new r(n),a=C(e,t,i);if(i.offset<n.length)throw new m(`Unexpected ${n.length-i.offset} bytes after deserialized data`);return a}t.deserialize=w;function T(e,t,n,r=_){return C(e,t,new r(n))}t.deserializeUnchecked=T})),Dr=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.s16=e.s8=e.nu64be=e.u48be=e.u40be=e.u32be=e.u24be=e.u16be=e.nu64=e.u48=e.u40=e.u32=e.u24=e.u16=e.u8=e.offset=e.greedy=e.Constant=e.UTF8=e.CString=e.Blob=e.Boolean=e.BitField=e.BitStructure=e.VariantLayout=e.Union=e.UnionLayoutDiscriminator=e.UnionDiscriminator=e.Structure=e.Sequence=e.DoubleBE=e.Double=e.FloatBE=e.Float=e.NearInt64BE=e.NearInt64=e.NearUInt64BE=e.NearUInt64=e.IntBE=e.Int=e.UIntBE=e.UInt=e.OffsetLayout=e.GreedyCount=e.ExternalLayout=e.bindConstructorLayout=e.nameWithProperty=e.Layout=e.uint8ArrayToBuffer=e.checkUint8Array=void 0,e.constant=e.utf8=e.cstr=e.blob=e.unionLayoutDiscriminator=e.union=e.seq=e.bits=e.struct=e.f64be=e.f64=e.f32be=e.f32=e.ns64be=e.s48be=e.s40be=e.s32be=e.s24be=e.s16be=e.ns64=e.s48=e.s40=e.s32=e.s24=void 0;var t=s();function n(e){if(!(e instanceof Uint8Array))throw TypeError(`b must be a Uint8Array`)}e.checkUint8Array=n;function r(e){return n(e),t.Buffer.from(e.buffer,e.byteOffset,e.length)}e.uint8ArrayToBuffer=r;var i=class{constructor(e,t){if(!Number.isInteger(e))throw TypeError(`span must be an integer`);this.span=e,this.property=t}makeDestinationObject(){return{}}getSpan(e,t){if(0>this.span)throw RangeError(`indeterminate span`);return this.span}replicate(e){let t=Object.create(this.constructor.prototype);return Object.assign(t,this),t.property=e,t}fromArray(e){}};e.Layout=i;function a(e,t){return t.property?e+`[`+t.property+`]`:e}e.nameWithProperty=a;function o(e,t){if(typeof e!=`function`)throw TypeError(`Class must be constructor`);if(Object.prototype.hasOwnProperty.call(e,`layout_`))throw Error(`Class is already bound to a layout`);if(!(t&&t instanceof i))throw TypeError(`layout must be a Layout`);if(Object.prototype.hasOwnProperty.call(t,`boundConstructor_`))throw Error(`layout is already bound to a constructor`);e.layout_=t,t.boundConstructor_=e,t.makeDestinationObject=(()=>new e),Object.defineProperty(e.prototype,"encode",{value(e,n){return t.encode(this,e,n)},writable:!0}),Object.defineProperty(e,"decode",{value(e,n){return t.decode(e,n)},writable:!0})}e.bindConstructorLayout=o;var c=class extends i{isCount(){throw Error(`ExternalLayout is abstract`)}};e.ExternalLayout=c;var l=class extends c{constructor(e=1,t){if(!Number.isInteger(e)||0>=e)throw TypeError(`elementSpan must be a (positive) integer`);super(-1,t),this.elementSpan=e}isCount(){return!0}decode(e,t=0){n(e);let r=e.length-t;return Math.floor(r/this.elementSpan)}encode(e,t,n){return 0}};e.GreedyCount=l;var u=class extends c{constructor(e,t=0,n){if(!(e instanceof i))throw TypeError(`layout must be a Layout`);if(!Number.isInteger(t))throw TypeError(`offset must be integer or undefined`);super(e.span,n||e.property),this.layout=e,this.offset=t}isCount(){return this.layout instanceof d||this.layout instanceof f}decode(e,t=0){return this.layout.decode(e,t+this.offset)}encode(e,t,n=0){return this.layout.encode(e,t,n+this.offset)}};e.OffsetLayout=u;var d=class extends i{constructor(e,t){if(super(e,t),6<this.span)throw RangeError(`span must not exceed 6 bytes`)}decode(e,t=0){return r(e).readUIntLE(t,this.span)}encode(e,t,n=0){return r(t).writeUIntLE(e,n,this.span),this.span}};e.UInt=d;var f=class extends i{constructor(e,t){if(super(e,t),6<this.span)throw RangeError(`span must not exceed 6 bytes`)}decode(e,t=0){return r(e).readUIntBE(t,this.span)}encode(e,t,n=0){return r(t).writeUIntBE(e,n,this.span),this.span}};e.UIntBE=f;var p=class extends i{constructor(e,t){if(super(e,t),6<this.span)throw RangeError(`span must not exceed 6 bytes`)}decode(e,t=0){return r(e).readIntLE(t,this.span)}encode(e,t,n=0){return r(t).writeIntLE(e,n,this.span),this.span}};e.Int=p;var m=class extends i{constructor(e,t){if(super(e,t),6<this.span)throw RangeError(`span must not exceed 6 bytes`)}decode(e,t=0){return r(e).readIntBE(t,this.span)}encode(e,t,n=0){return r(t).writeIntBE(e,n,this.span),this.span}};e.IntBE=m;var h=2**32;function g(e){let t=Math.floor(e/h);return{hi32:t,lo32:e-t*h}}function _(e,t){return e*h+t}var v=class extends i{constructor(e){super(8,e)}decode(e,t=0){let n=r(e),i=n.readUInt32LE(t);return _(n.readUInt32LE(t+4),i)}encode(e,t,n=0){let i=g(e),a=r(t);return a.writeUInt32LE(i.lo32,n),a.writeUInt32LE(i.hi32,n+4),8}};e.NearUInt64=v;var y=class extends i{constructor(e){super(8,e)}decode(e,t=0){let n=r(e);return _(n.readUInt32BE(t),n.readUInt32BE(t+4))}encode(e,t,n=0){let i=g(e),a=r(t);return a.writeUInt32BE(i.hi32,n),a.writeUInt32BE(i.lo32,n+4),8}};e.NearUInt64BE=y;var b=class extends i{constructor(e){super(8,e)}decode(e,t=0){let n=r(e),i=n.readUInt32LE(t);return _(n.readInt32LE(t+4),i)}encode(e,t,n=0){let i=g(e),a=r(t);return a.writeUInt32LE(i.lo32,n),a.writeInt32LE(i.hi32,n+4),8}};e.NearInt64=b;var x=class extends i{constructor(e){super(8,e)}decode(e,t=0){let n=r(e);return _(n.readInt32BE(t),n.readUInt32BE(t+4))}encode(e,t,n=0){let i=g(e),a=r(t);return a.writeInt32BE(i.hi32,n),a.writeUInt32BE(i.lo32,n+4),8}};e.NearInt64BE=x;var S=class extends i{constructor(e){super(4,e)}decode(e,t=0){return r(e).readFloatLE(t)}encode(e,t,n=0){return r(t).writeFloatLE(e,n),4}};e.Float=S;var C=class extends i{constructor(e){super(4,e)}decode(e,t=0){return r(e).readFloatBE(t)}encode(e,t,n=0){return r(t).writeFloatBE(e,n),4}};e.FloatBE=C;var w=class extends i{constructor(e){super(8,e)}decode(e,t=0){return r(e).readDoubleLE(t)}encode(e,t,n=0){return r(t).writeDoubleLE(e,n),8}};e.Double=w;var T=class extends i{constructor(e){super(8,e)}decode(e,t=0){return r(e).readDoubleBE(t)}encode(e,t,n=0){return r(t).writeDoubleBE(e,n),8}};e.DoubleBE=T;var E=class extends i{constructor(e,t,n){if(!(e instanceof i))throw TypeError(`elementLayout must be a Layout`);if(!(t instanceof c&&t.isCount()||Number.isInteger(t)&&0<=t))throw TypeError(`count must be non-negative integer or an unsigned integer ExternalLayout`);let r=-1;!(t instanceof c)&&0<e.span&&(r=t*e.span),super(r,n),this.elementLayout=e,this.count=t}getSpan(e,t=0){if(0<=this.span)return this.span;let n=0,r=this.count;if(r instanceof c&&(r=r.decode(e,t)),0<this.elementLayout.span)n=r*this.elementLayout.span;else{let i=0;for(;i<r;)n+=this.elementLayout.getSpan(e,t+n),++i}return n}decode(e,t=0){let n=[],r=0,i=this.count;for(i instanceof c&&(i=i.decode(e,t));r<i;)n.push(this.elementLayout.decode(e,t)),t+=this.elementLayout.getSpan(e,t),r+=1;return n}encode(e,t,n=0){let r=this.elementLayout,i=e.reduce((e,i)=>e+r.encode(i,t,n+e),0);return this.count instanceof c&&this.count.encode(e.length,t,n),i}};e.Sequence=E;var D=class extends i{constructor(e,t,n){if(!(Array.isArray(e)&&e.reduce((e,t)=>e&&t instanceof i,!0)))throw TypeError(`fields must be array of Layout instances`);typeof t==`boolean`&&n===void 0&&(n=t,t=void 0);for(let t of e)if(0>t.span&&t.property===void 0)throw Error(`fields cannot contain unnamed variable-length layout`);let r=-1;try{r=e.reduce((e,t)=>e+t.getSpan(),0)}catch{}super(r,t),this.fields=e,this.decodePrefixes=!!n}getSpan(e,t=0){if(0<=this.span)return this.span;let n=0;try{n=this.fields.reduce((n,r)=>{let i=r.getSpan(e,t);return t+=i,n+i},0)}catch{throw RangeError(`indeterminate span`)}return n}decode(e,t=0){n(e);let r=this.makeDestinationObject();for(let n of this.fields)if(n.property!==void 0&&(r[n.property]=n.decode(e,t)),t+=n.getSpan(e,t),this.decodePrefixes&&e.length===t)break;return r}encode(e,t,n=0){let r=n,i=0,a=0;for(let r of this.fields){let o=r.span;if(a=0<o?o:0,r.property!==void 0){let i=e[r.property];i!==void 0&&(a=r.encode(i,t,n),0>o&&(o=r.getSpan(t,n)))}i=n,n+=o}return i+a-r}fromArray(e){let t=this.makeDestinationObject();for(let n of this.fields)n.property!==void 0&&0<e.length&&(t[n.property]=e.shift());return t}layoutFor(e){if(typeof e!=`string`)throw TypeError(`property must be string`);for(let t of this.fields)if(t.property===e)return t}offsetOf(e){if(typeof e!=`string`)throw TypeError(`property must be string`);let t=0;for(let n of this.fields){if(n.property===e)return t;0>n.span?t=-1:0<=t&&(t+=n.span)}}};e.Structure=D;var O=class{constructor(e){this.property=e}decode(e,t){throw Error(`UnionDiscriminator is abstract`)}encode(e,t,n){throw Error(`UnionDiscriminator is abstract`)}};e.UnionDiscriminator=O;var k=class extends O{constructor(e,t){if(!(e instanceof c&&e.isCount()))throw TypeError(`layout must be an unsigned integer ExternalLayout`);super(t||e.property||`variant`),this.layout=e}decode(e,t){return this.layout.decode(e,t)}encode(e,t,n){return this.layout.encode(e,t,n)}};e.UnionLayoutDiscriminator=k;var A=class extends i{constructor(e,t,n){let r;if(e instanceof d||e instanceof f)r=new k(new u(e));else if(e instanceof c&&e.isCount())r=new k(e);else if(e instanceof O)r=e;else throw TypeError(`discr must be a UnionDiscriminator or an unsigned integer layout`);if(t===void 0&&(t=null),!(t===null||t instanceof i))throw TypeError(`defaultLayout must be null or a Layout`);if(t!==null){if(0>t.span)throw Error(`defaultLayout must have constant span`);t.property===void 0&&(t=t.replicate(`content`))}let a=-1;t&&(a=t.span,0<=a&&(e instanceof d||e instanceof f)&&(a+=r.layout.span)),super(a,n),this.discriminator=r,this.usesPrefixDiscriminator=e instanceof d||e instanceof f,this.defaultLayout=t,this.registry={};let o=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(e){return o(e)},this.configGetSourceVariant=function(e){o=e.bind(this)}}getSpan(e,t=0){if(0<=this.span)return this.span;let n=this.getVariant(e,t);if(!n)throw Error(`unable to determine span for unrecognized variant`);return n.getSpan(e,t)}defaultGetSourceVariant(e){if(Object.prototype.hasOwnProperty.call(e,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(e,this.defaultLayout.property))return;let t=this.registry[e[this.discriminator.property]];if(t&&(!t.layout||t.property&&Object.prototype.hasOwnProperty.call(e,t.property)))return t}else for(let t in this.registry){let n=this.registry[t];if(n.property&&Object.prototype.hasOwnProperty.call(e,n.property))return n}throw Error(`unable to infer src variant`)}decode(e,t=0){let n,r=this.discriminator,i=r.decode(e,t),a=this.registry[i];if(a===void 0){let a=this.defaultLayout,o=0;this.usesPrefixDiscriminator&&(o=r.layout.span),n=this.makeDestinationObject(),n[r.property]=i,n[a.property]=a.decode(e,t+o)}else n=a.decode(e,t);return n}encode(e,t,n=0){let r=this.getSourceVariant(e);if(r===void 0){let r=this.discriminator,i=this.defaultLayout,a=0;return this.usesPrefixDiscriminator&&(a=r.layout.span),r.encode(e[r.property],t,n),a+i.encode(e[i.property],t,n+a)}return r.encode(e,t,n)}addVariant(e,t,n){let r=new ee(this,e,t,n);return this.registry[e]=r,r}getVariant(e,t=0){let n;return n=e instanceof Uint8Array?this.discriminator.decode(e,t):e,this.registry[n]}};e.Union=A;var ee=class extends i{constructor(e,t,n,r){if(!(e instanceof A))throw TypeError(`union must be a Union`);if(!Number.isInteger(t)||0>t)throw TypeError(`variant must be a (non-negative) integer`);if(typeof n==`string`&&r===void 0&&(r=n,n=null),n){if(!(n instanceof i))throw TypeError(`layout must be a Layout`);if(e.defaultLayout!==null&&0<=n.span&&n.span>e.defaultLayout.span)throw Error(`variant span exceeds span of containing union`);if(typeof r!=`string`)throw TypeError(`variant must have a String property`)}let a=e.span;0>e.span&&(a=n?n.span:0,0<=a&&e.usesPrefixDiscriminator&&(a+=e.discriminator.layout.span)),super(a,r),this.union=e,this.variant=t,this.layout=n||null}getSpan(e,t=0){if(0<=this.span)return this.span;let n=0;this.union.usesPrefixDiscriminator&&(n=this.union.discriminator.layout.span);let r=0;return this.layout&&(r=this.layout.getSpan(e,t+n)),n+r}decode(e,t=0){let n=this.makeDestinationObject();if(this!==this.union.getVariant(e,t))throw Error(`variant mismatch`);let r=0;return this.union.usesPrefixDiscriminator&&(r=this.union.discriminator.layout.span),this.layout?n[this.property]=this.layout.decode(e,t+r):this.property?n[this.property]=!0:this.union.usesPrefixDiscriminator&&(n[this.union.discriminator.property]=this.variant),n}encode(e,t,n=0){let r=0;if(this.union.usesPrefixDiscriminator&&(r=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(e,this.property))throw TypeError(`variant lacks property `+this.property);this.union.discriminator.encode(this.variant,t,n);let i=r;if(this.layout&&(this.layout.encode(e[this.property],t,n+r),i+=this.layout.getSpan(t,n+r),0<=this.union.span&&i>this.union.span))throw Error(`encoded variant overruns containing union`);return i}fromArray(e){if(this.layout)return this.layout.fromArray(e)}};e.VariantLayout=ee;function j(e){return 0>e&&(e+=4294967296),e}var M=class extends i{constructor(e,t,n){if(!(e instanceof d||e instanceof f))throw TypeError(`word must be a UInt or UIntBE layout`);if(typeof t==`string`&&n===void 0&&(n=t,t=!1),4<e.span)throw RangeError(`word cannot exceed 32 bits`);super(e.span,n),this.word=e,this.msb=!!t,this.fields=[];let r=0;this._packedSetValue=function(e){return r=j(e),this},this._packedGetValue=function(){return r}}decode(e,t=0){let n=this.makeDestinationObject(),r=this.word.decode(e,t);this._packedSetValue(r);for(let t of this.fields)t.property!==void 0&&(n[t.property]=t.decode(e));return n}encode(e,t,n=0){let r=this.word.decode(t,n);this._packedSetValue(r);for(let t of this.fields)if(t.property!==void 0){let n=e[t.property];n!==void 0&&t.encode(n)}return this.word.encode(this._packedGetValue(),t,n)}addField(e,t){let n=new te(this,e,t);return this.fields.push(n),n}addBoolean(e){let t=new ne(this,e);return this.fields.push(t),t}fieldFor(e){if(typeof e!=`string`)throw TypeError(`property must be string`);for(let t of this.fields)if(t.property===e)return t}};e.BitStructure=M;var te=class{constructor(e,t,n){if(!(e instanceof M))throw TypeError(`container must be a BitStructure`);if(!Number.isInteger(t)||0>=t)throw TypeError(`bits must be positive integer`);let r=8*e.span,i=e.fields.reduce((e,t)=>e+t.bits,0);if(t+i>r)throw Error(`bits too long for span remainder (`+(r-i)+` of `+r+` remain)`);this.container=e,this.bits=t,this.valueMask=(1<<t)-1,t===32&&(this.valueMask=4294967295),this.start=i,this.container.msb&&(this.start=r-i-t),this.wordMask=j(this.valueMask<<this.start),this.property=n}decode(e,t){return j(this.container._packedGetValue()&this.wordMask)>>>this.start}encode(e){if(typeof e!=`number`||!Number.isInteger(e)||e!==j(e&this.valueMask))throw TypeError(a(`BitField.encode`,this)+` value must be integer not exceeding `+this.valueMask);let t=this.container._packedGetValue(),n=j(e<<this.start);this.container._packedSetValue(j(t&~this.wordMask)|n)}};e.BitField=te;var ne=class extends te{constructor(e,t){super(e,1,t)}decode(e,t){return!!super.decode(e,t)}encode(e){typeof e==`boolean`&&(e=+e),super.encode(e)}};e.Boolean=ne;var re=class extends i{constructor(e,t){if(!(e instanceof c&&e.isCount()||Number.isInteger(e)&&0<=e))throw TypeError(`length must be positive integer or an unsigned integer ExternalLayout`);let n=-1;e instanceof c||(n=e),super(n,t),this.length=e}getSpan(e,t){let n=this.span;return 0>n&&(n=this.length.decode(e,t)),n}decode(e,t=0){let n=this.span;return 0>n&&(n=this.length.decode(e,t)),r(e).slice(t,t+n)}encode(e,t,n){let i=this.length;if(this.length instanceof c&&(i=e.length),!(e instanceof Uint8Array&&i===e.length))throw TypeError(a(`Blob.encode`,this)+` requires (length `+i+`) Uint8Array as src`);if(n+i>t.length)throw RangeError(`encoding overruns Uint8Array`);let o=r(e);return r(t).write(o.toString(`hex`),n,i,`hex`),this.length instanceof c&&this.length.encode(i,t,n),i}};e.Blob=re;var ie=class extends i{constructor(e){super(-1,e)}getSpan(e,t=0){n(e);let r=t;for(;r<e.length&&e[r]!==0;)r+=1;return 1+r-t}decode(e,t=0){let n=this.getSpan(e,t);return r(e).slice(t,t+n-1).toString(`utf-8`)}encode(e,n,i=0){typeof e!=`string`&&(e=String(e));let a=t.Buffer.from(e,`utf8`),o=a.length;if(i+o>n.length)throw RangeError(`encoding overruns Buffer`);let s=r(n);return a.copy(s,i),s[i+o]=0,o+1}};e.CString=ie;var ae=class extends i{constructor(e,t){if(typeof e==`string`&&t===void 0&&(t=e,e=void 0),e===void 0)e=-1;else if(!Number.isInteger(e))throw TypeError(`maxSpan must be an integer`);super(-1,t),this.maxSpan=e}getSpan(e,t=0){return n(e),e.length-t}decode(e,t=0){let n=this.getSpan(e,t);if(0<=this.maxSpan&&this.maxSpan<n)throw RangeError(`text length exceeds maxSpan`);return r(e).slice(t,t+n).toString(`utf-8`)}encode(e,n,i=0){typeof e!=`string`&&(e=String(e));let a=t.Buffer.from(e,`utf8`),o=a.length;if(0<=this.maxSpan&&this.maxSpan<o)throw RangeError(`text length exceeds maxSpan`);if(i+o>n.length)throw RangeError(`encoding overruns Buffer`);return a.copy(r(n),i),o}};e.UTF8=ae;var N=class extends i{constructor(e,t){super(0,t),this.value=e}decode(e,t){return this.value}encode(e,t,n){return 0}};e.Constant=N,e.greedy=((e,t)=>new l(e,t)),e.offset=((e,t,n)=>new u(e,t,n)),e.u8=(e=>new d(1,e)),e.u16=(e=>new d(2,e)),e.u24=(e=>new d(3,e)),e.u32=(e=>new d(4,e)),e.u40=(e=>new d(5,e)),e.u48=(e=>new d(6,e)),e.nu64=(e=>new v(e)),e.u16be=(e=>new f(2,e)),e.u24be=(e=>new f(3,e)),e.u32be=(e=>new f(4,e)),e.u40be=(e=>new f(5,e)),e.u48be=(e=>new f(6,e)),e.nu64be=(e=>new y(e)),e.s8=(e=>new p(1,e)),e.s16=(e=>new p(2,e)),e.s24=(e=>new p(3,e)),e.s32=(e=>new p(4,e)),e.s40=(e=>new p(5,e)),e.s48=(e=>new p(6,e)),e.ns64=(e=>new b(e)),e.s16be=(e=>new m(2,e)),e.s24be=(e=>new m(3,e)),e.s32be=(e=>new m(4,e)),e.s40be=(e=>new m(5,e)),e.s48be=(e=>new m(6,e)),e.ns64be=(e=>new x(e)),e.f32=(e=>new S(e)),e.f32be=(e=>new C(e)),e.f64=(e=>new w(e)),e.f64be=(e=>new T(e)),e.struct=((e,t,n)=>new D(e,t,n)),e.bits=((e,t,n)=>new M(e,t,n)),e.seq=((e,t,n)=>new E(e,t,n)),e.union=((e,t,n)=>new A(e,t,n)),e.unionLayoutDiscriminator=((e,t)=>new k(e,t)),e.blob=((e,t)=>new re(e,t)),e.cstr=(e=>new ie(e)),e.utf8=((e,t)=>new ae(e,t)),e.constant=((e,t)=>new N(e,t))})),Or=n(rr()),kr=n(or()),Ar=Er(),I=n(Dr()),jr=8078e3,Mr=8078001,Nr=8078004,Pr=8078005,Fr=8078006,Ir=8078011;function Lr(e){return Array.isArray(e)?`%5B`+e.map(Lr).join(`%2C%20`)+`%5D`:typeof e==`bigint`?`${e}n`:encodeURIComponent(String(e!=null&&Object.getPrototypeOf(e)===null?{...e}:e))}function Rr([e,t]){return`${e}=${Lr(t)}`}function zr(e){let t=Object.entries(e).map(Rr).join(`&`);return btoa(t)}function Br(e,t={}){{let n=`Solana error #${e}; Decode this error by running \`npx @solana/errors decode -- ${e}`;return Object.keys(t).length&&(n+=` '${zr(t)}'`),`${n}\``}}var Vr=class extends Error{cause=this.cause;context;constructor(...[e,t]){let n,r;if(t){let{cause:e,...i}=t;e&&(r={cause:e}),Object.keys(i).length>0&&(n=i)}let i=Br(e,n);super(i,r),this.context={__code:e,...n},this.name=`SolanaError`}};function Hr(e,t){return`fixedSize`in t?t.fixedSize:t.getSizeFromValue(e)}function Ur(e){return Object.freeze({...e,encode:t=>{let n=new Uint8Array(Hr(t,e));return e.write(t,n,0),n}})}function Wr(e){return Object.freeze({...e,decode:(t,n=0)=>e.read(t,n)[0]})}function Gr(e){return`fixedSize`in e&&typeof e.fixedSize==`number`}function Kr(e,t){if(Gr(e)!==Gr(t))throw new Vr(Nr);if(Gr(e)&&Gr(t)&&e.fixedSize!==t.fixedSize)throw new Vr(Pr,{decoderFixedSize:t.fixedSize,encoderFixedSize:e.fixedSize});if(!Gr(e)&&!Gr(t)&&e.maxSize!==t.maxSize)throw new Vr(Fr,{decoderMaxSize:t.maxSize,encoderMaxSize:e.maxSize});return{...t,...e,decode:t.decode,encode:e.encode,read:t.read,write:e.write}}function qr(e,t,n=0){if(t.length-n<=0)throw new Vr(jr,{codecDescription:e})}function Jr(e,t,n,r=0){let i=n.length-r;if(i<t)throw new Vr(Mr,{bytesLength:i,codecDescription:e,expected:t})}function Yr(e,t,n,r){if(r<t||r>n)throw new Vr(Ir,{codecDescription:e,max:n,min:t,value:r})}function Xr(e){return e?.endian!==1}function Zr(e){return Ur({fixedSize:e.size,write(t,n,r){e.range&&Yr(e.name,e.range[0],e.range[1],t);let i=new ArrayBuffer(e.size);return e.set(new DataView(i),t,Xr(e.config)),n.set(new Uint8Array(i),r),r+e.size}})}function Qr(e){return Wr({fixedSize:e.size,read(t,n=0){qr(e.name,t,n),Jr(e.name,e.size,t,n);let r=new DataView($r(t,n,e.size));return[e.get(r,Xr(e.config)),n+e.size]}})}function $r(e,t,n){let r=e.byteOffset+(t??0),i=n??e.byteLength;return e.buffer.slice(r,r+i)}var ei=(e={})=>Zr({config:e,name:`u64`,range:[0n,BigInt(`0xffffffffffffffff`)],set:(e,t,n)=>e.setBigUint64(0,BigInt(t),n),size:8}),ti=(e={})=>Qr({config:e,get:(e,t)=>e.getBigUint64(0,t),name:`u64`,size:8}),ni=(e={})=>Kr(ei(e),ti(e)),ri=class extends TypeError{constructor(e,t){let n,{message:r,explanation:i,...a}=e,{path:o}=e,s=o.length===0?r:`At path: ${o.join(`.`)} -- ${r}`;super(i??s),i!=null&&(this.cause=s),Object.assign(this,a),this.name=this.constructor.name,this.failures=()=>n??=[e,...t()]}};function ii(e){return ai(e)&&typeof e[Symbol.iterator]==`function`}function ai(e){return typeof e==`object`&&!!e}function oi(e){return ai(e)&&!Array.isArray(e)}function si(e){return typeof e==`symbol`?e.toString():typeof e==`string`?JSON.stringify(e):`${e}`}function ci(e){let{done:t,value:n}=e.next();return t?void 0:n}function li(e,t,n,r){if(e===!0)return;e===!1?e={}:typeof e==`string`&&(e={message:e});let{path:i,branch:a}=t,{type:o}=n,{refinement:s,message:c=`Expected a value of type \`${o}\`${s?` with refinement \`${s}\``:``}, but received: \`${si(r)}\``}=e;return{value:r,type:o,refinement:s,key:i[i.length-1],path:i,branch:a,...e,message:c}}function*ui(e,t,n,r){ii(e)||(e=[e]);for(let i of e){let e=li(i,t,n,r);e&&(yield e)}}function*di(e,t,n={}){let{path:r=[],branch:i=[e],coerce:a=!1,mask:o=!1}=n,s={path:r,branch:i,mask:o};a&&(e=t.coercer(e,s));let c=`valid`;for(let r of t.validator(e,s))r.explanation=n.message,c=`not_valid`,yield[r,void 0];for(let[l,u,d]of t.entries(e,s)){let t=di(u,d,{path:l===void 0?r:[...r,l],branch:l===void 0?i:[...i,u],coerce:a,mask:o,message:n.message});for(let n of t)n[0]?(c=n[0].refinement==null?`not_valid`:`not_refined`,yield[n[0],void 0]):a&&(u=n[1],l===void 0?e=u:e instanceof Map?e.set(l,u):e instanceof Set?e.add(u):ai(e)&&(u!==void 0||l in e)&&(e[l]=u))}if(c!==`not_valid`)for(let r of t.refiner(e,s))r.explanation=n.message,c=`not_refined`,yield[r,void 0];c===`valid`&&(yield[void 0,e])}var fi=class{constructor(e){let{type:t,schema:n,validator:r,refiner:i,coercer:a=e=>e,entries:o=function*(){}}=e;this.type=t,this.schema=n,this.entries=o,this.coercer=a,r?this.validator=(e,t)=>ui(r(e,t),t,this,e):this.validator=()=>[],i?this.refiner=(e,t)=>ui(i(e,t),t,this,e):this.refiner=()=>[]}assert(e,t){return pi(e,this,t)}create(e,t){return L(e,this,t)}is(e){return hi(e,this)}mask(e,t){return mi(e,this,t)}validate(e,t={}){return gi(e,this,t)}};function pi(e,t,n){let r=gi(e,t,{message:n});if(r[0])throw r[0]}function L(e,t,n){let r=gi(e,t,{coerce:!0,message:n});if(r[0])throw r[0];return r[1]}function mi(e,t,n){let r=gi(e,t,{coerce:!0,mask:!0,message:n});if(r[0])throw r[0];return r[1]}function hi(e,t){return!gi(e,t)[0]}function gi(e,t,n={}){let r=di(e,t,n),i=ci(r);return i[0]?[new ri(i[0],function*(){for(let e of r)e[0]&&(yield e[0])}),void 0]:[void 0,i[1]]}function _i(e,t){return new fi({type:e,schema:null,validator:t})}function vi(){return _i(`any`,()=>!0)}function R(e){return new fi({type:`array`,schema:e,*entries(t){if(e&&Array.isArray(t))for(let[n,r]of t.entries())yield[n,r,e]},coercer(e){return Array.isArray(e)?e.slice():e},validator(e){return Array.isArray(e)||`Expected an array value, but received: ${si(e)}`}})}function yi(){return _i(`boolean`,e=>typeof e==`boolean`)}function bi(e){return _i(`instance`,t=>t instanceof e||`Expected a \`${e.name}\` instance, but received: ${si(t)}`)}function xi(e){let t=si(e),n=typeof e;return new fi({type:`literal`,schema:n===`string`||n===`number`||n===`boolean`?e:null,validator(n){return n===e||`Expected the literal \`${t}\`, but received: ${si(n)}`}})}function Si(){return _i(`never`,()=>!1)}function z(e){return new fi({...e,validator:(t,n)=>t===null||e.validator(t,n),refiner:(t,n)=>t===null||e.refiner(t,n)})}function B(){return _i(`number`,e=>typeof e==`number`&&!isNaN(e)||`Expected a number, but received: ${si(e)}`)}function V(e){return new fi({...e,validator:(t,n)=>t===void 0||e.validator(t,n),refiner:(t,n)=>t===void 0||e.refiner(t,n)})}function Ci(e,t){return new fi({type:`record`,schema:null,*entries(n){if(ai(n))for(let r in n){let i=n[r];yield[r,r,e],yield[r,i,t]}},validator(e){return oi(e)||`Expected an object, but received: ${si(e)}`},coercer(e){return oi(e)?{...e}:e}})}function H(){return _i(`string`,e=>typeof e==`string`||`Expected a string, but received: ${si(e)}`)}function wi(e){let t=Si();return new fi({type:`tuple`,schema:null,*entries(n){if(Array.isArray(n)){let r=Math.max(e.length,n.length);for(let i=0;i<r;i++)yield[i,n[i],e[i]||t]}},validator(e){return Array.isArray(e)||`Expected an array, but received: ${si(e)}`},coercer(e){return Array.isArray(e)?e.slice():e}})}function U(e){let t=Object.keys(e);return new fi({type:`type`,schema:e,*entries(n){if(ai(n))for(let r of t)yield[r,n[r],e[r]]},validator(e){return oi(e)||`Expected an object, but received: ${si(e)}`},coercer(e){return oi(e)?{...e}:e}})}function Ti(e){let t=e.map(e=>e.type).join(` | `);return new fi({type:`union`,schema:null,coercer(t,n){for(let r of e){let[e,i]=r.validate(t,{coerce:!0,mask:n.mask});if(!e)return i}return t},validator(n,r){let i=[];for(let t of e){let[...e]=di(n,t,r),[a]=e;if(a[0])for(let[t]of e)t&&i.push(t);else return[]}return[`Expected the value to satisfy a union of \`${t}\`, but received: ${si(n)}`,...i]}})}function Ei(){return _i(`unknown`,()=>!0)}function Di(e,t,n){return new fi({...e,coercer:(r,i)=>hi(r,t)?e.coercer(n(r,i),i):e.coercer(r,i)})}function Oi(){if(!ki&&(ki=typeof crypto<`u`&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<`u`&&typeof msCrypto.getRandomValues==`function`&&msCrypto.getRandomValues.bind(msCrypto),!ki))throw Error(`crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported`);return ki(Ai)}var ki,Ai,ji=t((()=>{Ai=new Uint8Array(16)})),Mi,Ni=t((()=>{Mi=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i}));function Pi(e){return typeof e==`string`&&Mi.test(e)}var Fi=t((()=>{Ni()}));function Ii(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=(Li[e[t+0]]+Li[e[t+1]]+Li[e[t+2]]+Li[e[t+3]]+`-`+Li[e[t+4]]+Li[e[t+5]]+`-`+Li[e[t+6]]+Li[e[t+7]]+`-`+Li[e[t+8]]+Li[e[t+9]]+`-`+Li[e[t+10]]+Li[e[t+11]]+Li[e[t+12]]+Li[e[t+13]]+Li[e[t+14]]+Li[e[t+15]]).toLowerCase();if(!Pi(n))throw TypeError(`Stringified UUID is invalid`);return n}var Li,Ri,zi=t((()=>{for(Fi(),Li=[],Ri=0;Ri<256;++Ri)Li.push((Ri+256).toString(16).substr(1))}));function Bi(e,t,n){var r=t&&n||0,i=t||Array(16);e||={};var a=e.node||Vi,o=e.clockseq===void 0?Hi:e.clockseq;if(a==null||o==null){var s=e.random||(e.rng||Oi)();a??=Vi=[s[0]|1,s[1],s[2],s[3],s[4],s[5]],o??=Hi=(s[6]<<8|s[7])&16383}var c=e.msecs===void 0?Date.now():e.msecs,l=e.nsecs===void 0?Wi+1:e.nsecs,u=c-Ui+(l-Wi)/1e4;if(u<0&&e.clockseq===void 0&&(o=o+1&16383),(u<0||c>Ui)&&e.nsecs===void 0&&(l=0),l>=1e4)throw Error(`uuid.v1(): Can't create more than 10M uuids/sec`);Ui=c,Wi=l,Hi=o,c+=0xb1d069b5400;var d=((c&268435455)*1e4+l)%4294967296;i[r++]=d>>>24&255,i[r++]=d>>>16&255,i[r++]=d>>>8&255,i[r++]=d&255;var f=c/4294967296*1e4&268435455;i[r++]=f>>>8&255,i[r++]=f&255,i[r++]=f>>>24&15|16,i[r++]=f>>>16&255,i[r++]=o>>>8|128,i[r++]=o&255;for(var p=0;p<6;++p)i[r+p]=a[p];return t||Ii(i)}var Vi,Hi,Ui,Wi,Gi=t((()=>{ji(),zi(),Ui=0,Wi=0}));function Ki(e){if(!Pi(e))throw TypeError(`Invalid UUID`);var t,n=new Uint8Array(16);return n[0]=(t=parseInt(e.slice(0,8),16))>>>24,n[1]=t>>>16&255,n[2]=t>>>8&255,n[3]=t&255,n[4]=(t=parseInt(e.slice(9,13),16))>>>8,n[5]=t&255,n[6]=(t=parseInt(e.slice(14,18),16))>>>8,n[7]=t&255,n[8]=(t=parseInt(e.slice(19,23),16))>>>8,n[9]=t&255,n[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,n[11]=t/4294967296&255,n[12]=t>>>24&255,n[13]=t>>>16&255,n[14]=t>>>8&255,n[15]=t&255,n}var qi=t((()=>{Fi()}));function Ji(e){e=unescape(encodeURIComponent(e));for(var t=[],n=0;n<e.length;++n)t.push(e.charCodeAt(n));return t}function Yi(e,t,n){function r(e,r,i,a){if(typeof e==`string`&&(e=Ji(e)),typeof r==`string`&&(r=Ki(r)),r.length!==16)throw TypeError(`Namespace must be array-like (16 iterable integer values, 0-255)`);var o=new Uint8Array(16+e.length);if(o.set(r),o.set(e,r.length),o=n(o),o[6]=o[6]&15|t,o[8]=o[8]&63|128,i){a||=0;for(var s=0;s<16;++s)i[a+s]=o[s];return i}return Ii(o)}try{r.name=e}catch{}return r.DNS=Xi,r.URL=Zi,r}var Xi,Zi,Qi=t((()=>{zi(),qi(),Xi=`6ba7b810-9dad-11d1-80b4-00c04fd430c8`,Zi=`6ba7b811-9dad-11d1-80b4-00c04fd430c8`}));function $i(e){if(typeof e==`string`){var t=unescape(encodeURIComponent(e));e=new Uint8Array(t.length);for(var n=0;n<t.length;++n)e[n]=t.charCodeAt(n)}return ea(na(ra(e),e.length*8))}function ea(e){for(var t=[],n=e.length*32,r=`0123456789abcdef`,i=0;i<n;i+=8){var a=e[i>>5]>>>i%32&255,o=parseInt(r.charAt(a>>>4&15)+r.charAt(a&15),16);t.push(o)}return t}function ta(e){return(e+64>>>9<<4)+14+1}function na(e,t){e[t>>5]|=128<<t%32,e[ta(t)-1]=t;for(var n=1732584193,r=-271733879,i=-1732584194,a=271733878,o=0;o<e.length;o+=16){var s=n,c=r,l=i,u=a;n=sa(n,r,i,a,e[o],7,-680876936),a=sa(a,n,r,i,e[o+1],12,-389564586),i=sa(i,a,n,r,e[o+2],17,606105819),r=sa(r,i,a,n,e[o+3],22,-1044525330),n=sa(n,r,i,a,e[o+4],7,-176418897),a=sa(a,n,r,i,e[o+5],12,1200080426),i=sa(i,a,n,r,e[o+6],17,-1473231341),r=sa(r,i,a,n,e[o+7],22,-45705983),n=sa(n,r,i,a,e[o+8],7,1770035416),a=sa(a,n,r,i,e[o+9],12,-1958414417),i=sa(i,a,n,r,e[o+10],17,-42063),r=sa(r,i,a,n,e[o+11],22,-1990404162),n=sa(n,r,i,a,e[o+12],7,1804603682),a=sa(a,n,r,i,e[o+13],12,-40341101),i=sa(i,a,n,r,e[o+14],17,-1502002290),r=sa(r,i,a,n,e[o+15],22,1236535329),n=ca(n,r,i,a,e[o+1],5,-165796510),a=ca(a,n,r,i,e[o+6],9,-1069501632),i=ca(i,a,n,r,e[o+11],14,643717713),r=ca(r,i,a,n,e[o],20,-373897302),n=ca(n,r,i,a,e[o+5],5,-701558691),a=ca(a,n,r,i,e[o+10],9,38016083),i=ca(i,a,n,r,e[o+15],14,-660478335),r=ca(r,i,a,n,e[o+4],20,-405537848),n=ca(n,r,i,a,e[o+9],5,568446438),a=ca(a,n,r,i,e[o+14],9,-1019803690),i=ca(i,a,n,r,e[o+3],14,-187363961),r=ca(r,i,a,n,e[o+8],20,1163531501),n=ca(n,r,i,a,e[o+13],5,-1444681467),a=ca(a,n,r,i,e[o+2],9,-51403784),i=ca(i,a,n,r,e[o+7],14,1735328473),r=ca(r,i,a,n,e[o+12],20,-1926607734),n=la(n,r,i,a,e[o+5],4,-378558),a=la(a,n,r,i,e[o+8],11,-2022574463),i=la(i,a,n,r,e[o+11],16,1839030562),r=la(r,i,a,n,e[o+14],23,-35309556),n=la(n,r,i,a,e[o+1],4,-1530992060),a=la(a,n,r,i,e[o+4],11,1272893353),i=la(i,a,n,r,e[o+7],16,-155497632),r=la(r,i,a,n,e[o+10],23,-1094730640),n=la(n,r,i,a,e[o+13],4,681279174),a=la(a,n,r,i,e[o],11,-358537222),i=la(i,a,n,r,e[o+3],16,-722521979),r=la(r,i,a,n,e[o+6],23,76029189),n=la(n,r,i,a,e[o+9],4,-640364487),a=la(a,n,r,i,e[o+12],11,-421815835),i=la(i,a,n,r,e[o+15],16,530742520),r=la(r,i,a,n,e[o+2],23,-995338651),n=ua(n,r,i,a,e[o],6,-198630844),a=ua(a,n,r,i,e[o+7],10,1126891415),i=ua(i,a,n,r,e[o+14],15,-1416354905),r=ua(r,i,a,n,e[o+5],21,-57434055),n=ua(n,r,i,a,e[o+12],6,1700485571),a=ua(a,n,r,i,e[o+3],10,-1894986606),i=ua(i,a,n,r,e[o+10],15,-1051523),r=ua(r,i,a,n,e[o+1],21,-2054922799),n=ua(n,r,i,a,e[o+8],6,1873313359),a=ua(a,n,r,i,e[o+15],10,-30611744),i=ua(i,a,n,r,e[o+6],15,-1560198380),r=ua(r,i,a,n,e[o+13],21,1309151649),n=ua(n,r,i,a,e[o+4],6,-145523070),a=ua(a,n,r,i,e[o+11],10,-1120210379),i=ua(i,a,n,r,e[o+2],15,718787259),r=ua(r,i,a,n,e[o+9],21,-343485551),n=ia(n,s),r=ia(r,c),i=ia(i,l),a=ia(a,u)}return[n,r,i,a]}function ra(e){if(e.length===0)return[];for(var t=e.length*8,n=new Uint32Array(ta(t)),r=0;r<t;r+=8)n[r>>5]|=(e[r/8]&255)<<r%32;return n}function ia(e,t){var n=(e&65535)+(t&65535);return(e>>16)+(t>>16)+(n>>16)<<16|n&65535}function aa(e,t){return e<<t|e>>>32-t}function oa(e,t,n,r,i,a){return ia(aa(ia(ia(t,e),ia(r,a)),i),n)}function sa(e,t,n,r,i,a,o){return oa(t&n|~t&r,e,t,i,a,o)}function ca(e,t,n,r,i,a,o){return oa(t&r|n&~r,e,t,i,a,o)}function la(e,t,n,r,i,a,o){return oa(t^n^r,e,t,i,a,o)}function ua(e,t,n,r,i,a,o){return oa(n^(t|~r),e,t,i,a,o)}var da=t((()=>{})),fa,pa=t((()=>{Qi(),da(),fa=Yi(`v3`,48,$i)}));function ma(e,t,n){e||={};var r=e.random||(e.rng||Oi)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){n||=0;for(var i=0;i<16;++i)t[n+i]=r[i];return t}return Ii(r)}var ha=t((()=>{ji(),zi()}));function ga(e,t,n,r){switch(e){case 0:return t&n^~t&r;case 1:return t^n^r;case 2:return t&n^t&r^n&r;case 3:return t^n^r}}function _a(e,t){return e<<t|e>>>32-t}function va(e){var t=[1518500249,1859775393,2400959708,3395469782],n=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof e==`string`){var r=unescape(encodeURIComponent(e));e=[];for(var i=0;i<r.length;++i)e.push(r.charCodeAt(i))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);for(var a=e.length/4+2,o=Math.ceil(a/16),s=Array(o),c=0;c<o;++c){for(var l=new Uint32Array(16),u=0;u<16;++u)l[u]=e[c*64+u*4]<<24|e[c*64+u*4+1]<<16|e[c*64+u*4+2]<<8|e[c*64+u*4+3];s[c]=l}s[o-1][14]=(e.length-1)*8/2**32,s[o-1][14]=Math.floor(s[o-1][14]),s[o-1][15]=(e.length-1)*8&4294967295;for(var d=0;d<o;++d){for(var f=new Uint32Array(80),p=0;p<16;++p)f[p]=s[d][p];for(var m=16;m<80;++m)f[m]=_a(f[m-3]^f[m-8]^f[m-14]^f[m-16],1);for(var h=n[0],g=n[1],_=n[2],v=n[3],y=n[4],b=0;b<80;++b){var x=Math.floor(b/20),S=_a(h,5)+ga(x,g,_,v)+y+t[x]+f[b]>>>0;y=v,v=_,_=_a(g,30)>>>0,g=h,h=S}n[0]=n[0]+h>>>0,n[1]=n[1]+g>>>0,n[2]=n[2]+_>>>0,n[3]=n[3]+v>>>0,n[4]=n[4]+y>>>0}return[n[0]>>24&255,n[0]>>16&255,n[0]>>8&255,n[0]&255,n[1]>>24&255,n[1]>>16&255,n[1]>>8&255,n[1]&255,n[2]>>24&255,n[2]>>16&255,n[2]>>8&255,n[2]&255,n[3]>>24&255,n[3]>>16&255,n[3]>>8&255,n[3]&255,n[4]>>24&255,n[4]>>16&255,n[4]>>8&255,n[4]&255]}var ya=t((()=>{})),ba,xa=t((()=>{Qi(),ya(),ba=Yi(`v5`,80,va)})),Sa,Ca=t((()=>{Sa=`00000000-0000-0000-0000-000000000000`}));function wa(e){if(!Pi(e))throw TypeError(`Invalid UUID`);return parseInt(e.substr(14,1),16)}var Ta=t((()=>{Fi()})),Ea=r({NIL:()=>Sa,parse:()=>Ki,stringify:()=>Ii,v1:()=>Bi,v3:()=>fa,v4:()=>ma,v5:()=>ba,validate:()=>Pi,version:()=>wa}),Da=t((()=>{Gi(),pa(),ha(),xa(),Ca(),Ta(),Fi(),zi(),qi()})),Oa=i(((t,n)=>{var r=(Da(),e(Ea)).v4;n.exports=function(e,t,n,i){if(typeof e!=`string`)throw TypeError(e+` must be a string`);i||={};let a=typeof i.version==`number`?i.version:2;if(a!==1&&a!==2)throw TypeError(a+` must be 1 or 2`);let o={method:e};if(a===2&&(o.jsonrpc=`2.0`),t){if(typeof t!=`object`&&!Array.isArray(t))throw TypeError(t+` must be an object, array or omitted`);o.params=t}return n===void 0?o.id=(typeof i.generator==`function`?i.generator:function(){return r()})(o,i):a===2&&n===null?i.notificationIdNull&&(o.id=null):o.id=n,o}})),ka=n(i(((t,n)=>{var r=(Da(),e(Ea)).v4,i=Oa(),a=function(e,t){if(!(this instanceof a))return new a(e,t);t||={},this.options={reviver:t.reviver===void 0?null:t.reviver,replacer:t.replacer===void 0?null:t.replacer,generator:t.generator===void 0?function(){return r()}:t.generator,version:t.version===void 0?2:t.version,notificationIdNull:typeof t.notificationIdNull==`boolean`?t.notificationIdNull:!1},this.callServer=e};n.exports=a,a.prototype.request=function(e,t,n,r){let a=this,o=null,s=Array.isArray(e)&&typeof t==`function`;if(this.options.version===1&&s)throw TypeError(`JSON-RPC 1.0 does not support batching`);if(s||!s&&e&&typeof e==`object`&&typeof t==`function`)r=t,o=e;else{typeof n==`function`&&(r=n,n=void 0);let a=typeof r==`function`;try{o=i(e,t,n,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(e){if(a){r(e);return}throw e}if(!a)return o}let c;try{c=JSON.stringify(o,this.options.replacer)}catch(e){r(e);return}return this.callServer(c,function(e,t){a._parseResponse(e,t,r)}),o},a.prototype._parseResponse=function(e,t,n){if(e){n(e);return}if(!t){n();return}let r;try{r=JSON.parse(t,this.options.reviver)}catch(e){n(e);return}if(n.length===3)if(Array.isArray(r)){let e=function(e){return e.error!==void 0};n(null,r.filter(e),r.filter(function(t){return!e(t)}));return}else{n(null,r.error,r.result);return}n(null,r)}}))()),Aa=class extends o.default{socket;constructor(e,t){super(),this.socket=new window.WebSocket(e,t.protocols),this.socket.onopen=()=>this.emit(`open`),this.socket.onmessage=e=>this.emit(`message`,e.data),this.socket.onerror=e=>this.emit(`error`,e),this.socket.onclose=e=>{this.emit(`close`,e.code,e.reason)}}send(e,t,n){let r=n||t;try{this.socket.send(e),r()}catch(e){r(e)}}close(e,t){this.socket.close(e,t)}addEventListener(e,t,n){this.socket.addEventListener(e,t,n)}};function ja(e,t){return new Aa(e,t)}var Ma=class{encode(e){return JSON.stringify(e)}decode(e){return JSON.parse(e)}},Na=class extends o.default{address;rpc_id;queue;options;autoconnect;ready;reconnect;reconnect_timer_id;reconnect_interval;max_reconnects;rest_options;current_reconnects;generate_request_id;socket;webSocketFactory;dataPack;constructor(e,t=`ws://localhost:8080`,{autoconnect:n=!0,reconnect:r=!0,reconnect_interval:i=1e3,max_reconnects:a=5,...o}={},s,c){super(),this.webSocketFactory=e,this.queue={},this.rpc_id=0,this.address=t,this.autoconnect=n,this.ready=!1,this.reconnect=r,this.reconnect_timer_id=void 0,this.reconnect_interval=i,this.max_reconnects=a,this.rest_options=o,this.current_reconnects=0,this.generate_request_id=s||(()=>typeof this.rpc_id==`number`?++this.rpc_id:Number(this.rpc_id)+1),c?this.dataPack=c:this.dataPack=new Ma,this.autoconnect&&this._connect(this.address,{autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects,...this.rest_options})}connect(){this.socket||this._connect(this.address,{autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects,...this.rest_options})}call(e,t,n,r){return!r&&typeof n==`object`&&(r=n,n=null),new Promise((i,a)=>{if(!this.ready)return a(Error(`socket not ready`));let o=this.generate_request_id(e,t),s={jsonrpc:`2.0`,method:e,params:t||void 0,id:o};this.socket.send(this.dataPack.encode(s),r,e=>{if(e)return a(e);this.queue[o]={promise:[i,a]},n&&(this.queue[o].timeout=setTimeout(()=>{delete this.queue[o],a(Error(`reply timeout`))},n))})})}async login(e){let t=await this.call(`rpc.login`,e);if(!t)throw Error(`authentication failed`);return t}async listMethods(){return await this.call(`__listMethods`)}notify(e,t){return new Promise((n,r)=>{if(!this.ready)return r(Error(`socket not ready`));let i={jsonrpc:`2.0`,method:e,params:t};this.socket.send(this.dataPack.encode(i),e=>{if(e)return r(e);n()})})}async subscribe(e){typeof e==`string`&&(e=[e]);let t=await this.call(`rpc.on`,e);if(typeof e==`string`&&t[e]!==`ok`)throw Error(`Failed subscribing to an event '`+e+`' with: `+t[e]);return t}async unsubscribe(e){typeof e==`string`&&(e=[e]);let t=await this.call(`rpc.off`,e);if(typeof e==`string`&&t[e]!==`ok`)throw Error(`Failed unsubscribing from an event with: `+t);return t}close(e,t){this.socket&&this.socket.close(e||1e3,t)}setAutoReconnect(e){this.reconnect=e}setReconnectInterval(e){this.reconnect_interval=e}setMaxReconnects(e){this.max_reconnects=e}getCurrentReconnects(){return this.current_reconnects}getMaxReconnects(){return this.max_reconnects}isReconnecting(){return this.reconnect_timer_id!==void 0}willReconnect(){return this.reconnect&&(this.max_reconnects===0||this.current_reconnects<this.max_reconnects)}_connect(e,t){clearTimeout(this.reconnect_timer_id),this.socket=this.webSocketFactory(e,t),this.socket.addEventListener(`open`,()=>{this.ready=!0,this.emit(`open`),this.current_reconnects=0}),this.socket.addEventListener(`message`,({data:e})=>{e instanceof ArrayBuffer&&(e=F.Buffer.from(e).toString());try{e=this.dataPack.decode(e)}catch{return}if(e.notification&&this.listeners(e.notification).length){if(!Object.keys(e.params).length)return this.emit(e.notification);let t=[e.notification];if(e.params.constructor===Object)t.push(e.params);else for(let n=0;n<e.params.length;n++)t.push(e.params[n]);return Promise.resolve().then(()=>{this.emit.apply(this,t)})}if(!this.queue[e.id])return e.method?Promise.resolve().then(()=>{this.emit(e.method,e?.params)}):void 0;`error`in e==`result`in e&&this.queue[e.id].promise[1](Error(`Server response malformed. Response must include either "result" or "error", but not both.`)),this.queue[e.id].timeout&&clearTimeout(this.queue[e.id].timeout),e.error?this.queue[e.id].promise[1](e.error):this.queue[e.id].promise[0](e.result),delete this.queue[e.id]}),this.socket.addEventListener(`error`,e=>this.emit(`error`,e)),this.socket.addEventListener(`close`,({code:n,reason:r})=>{this.ready&&setTimeout(()=>this.emit(`close`,n,r),0),this.ready=!1,this.socket=void 0,n!==1e3&&(this.current_reconnects++,this.reconnect&&(this.max_reconnects>this.current_reconnects||this.max_reconnects===0)?this.reconnect_timer_id=setTimeout(()=>this._connect(e,t),this.reconnect_interval):this.reconnect&&this.max_reconnects>0&&this.current_reconnects>=this.max_reconnects&&setTimeout(()=>this.emit(`max_reconnects_reached`,n,r),1))})}},Pa=(e,t)=>(e+(e>=0?t:-t)/Va)/t;function Fa(e,t,n){let[[r,i],[a,o]]=t,s=Pa(o*e,n),c=Pa(-i*e,n),l=e-s*r-c*a,u=-s*i-c*o,d=l<za,f=u<za;d&&(l=-l),f&&(u=-u);let p=xt(Math.ceil(bt(n)/2))+Ba;if(l<za||l>=p||u<za||u>=p)throw Error(`splitScalar (endomorphism): failed, k=`+e);return{k1neg:d,k1:l,k2neg:f,k2:u}}function Ia(e){if(![`compact`,`recovered`,`der`].includes(e))throw Error(`Signature format must be "compact", "recovered", or "der"`);return e}function La(e,t){let n={};for(let r of Object.keys(t))n[r]=e[r]===void 0?t[r]:e[r];return ot(n.lowS,`lowS`),ot(n.prehash,`prehash`),n.format!==void 0&&Ia(n.format),n}var Ra={Err:class extends Error{constructor(e=``){super(e)}},_tlv:{encode:(e,t)=>{let{Err:n}=Ra;if(e<0||e>256)throw new n(`tlv.encode: wrong tag`);if(t.length&1)throw new n(`tlv.encode: unpadded data`);let r=t.length/2,i=ct(r);if(i.length/2&128)throw new n(`tlv.encode: long form length too big`);let a=r>127?ct(i.length/2|128):``;return ct(e)+a+i+t},decode(e,t){let{Err:n}=Ra,r=0;if(e<0||e>256)throw new n(`tlv.encode: wrong tag`);if(t.length<2||t[r++]!==e)throw new n(`tlv.decode: wrong tlv`);let i=t[r++],a=!!(i&128),o=0;if(!a)o=i;else{let e=i&127;if(!e)throw new n(`tlv.decode(long): indefinite length not supported`);if(e>4)throw new n(`tlv.decode(long): byte length is too big`);let a=t.subarray(r,r+e);if(a.length!==e)throw new n(`tlv.decode: length bytes not complete`);if(a[0]===0)throw new n(`tlv.decode(long): zero leftmost byte`);for(let e of a)o=o<<8|e;if(r+=e,o<128)throw new n(`tlv.decode(long): not minimal encoding`)}let s=t.subarray(r,r+o);if(s.length!==o)throw new n(`tlv.decode: wrong value length`);return{v:s,l:t.subarray(r+o)}}},_int:{encode(e){let{Err:t}=Ra;if(e<za)throw new t(`integer: negative integers are not allowed`);let n=ct(e);if(Number.parseInt(n[0],16)&8&&(n=`00`+n),n.length&1)throw new t(`unexpected DER parsing assertion: unpadded hex`);return n},decode(e){let{Err:t}=Ra;if(e[0]&128)throw new t(`invalid signature integer: negative`);if(e[0]===0&&!(e[1]&128))throw new t(`invalid signature integer: unnecessary leading zero`);return ut(e)}},toSig(e){let{Err:t,_int:n,_tlv:r}=Ra,i=mt(`signature`,e),{v:a,l:o}=r.decode(48,i);if(o.length)throw new t(`invalid signature: left bytes after parsing`);let{v:s,l:c}=r.decode(2,a),{v:l,l:u}=r.decode(2,c);if(u.length)throw new t(`invalid signature: left bytes after parsing`);return{r:n.decode(s),s:n.decode(l)}},hexFromSig(e){let{_tlv:t,_int:n}=Ra,r=t.encode(2,n.encode(e.r))+t.encode(2,n.encode(e.s));return t.encode(48,r)}},za=BigInt(0),Ba=BigInt(1),Va=BigInt(2),Ha=BigInt(3),Ua=BigInt(4);function Wa(e,t){let{BYTES:n}=e,r;if(typeof t==`bigint`)r=t;else{let i=mt(`private key`,t);try{r=e.fromBytes(i)}catch{throw Error(`invalid private key: expected ui8a of size ${n}, got ${typeof t}`)}}if(!e.isValidNot0(r))throw Error(`invalid private key: out of range [1..N-1]`);return r}function Ga(e,t={}){let n=bn(`weierstrass`,e,t),{Fp:r,Fn:i}=n,a=n.CURVE,{h:o,n:s}=a;Ct(t,{},{allowInfinityPoint:`boolean`,clearCofactor:`function`,isTorsionFree:`function`,fromBytes:`function`,toBytes:`function`,endo:`object`,wrapPrivateKey:`boolean`});let{endo:c}=t;if(c&&(!r.is0(a.a)||typeof c.beta!=`bigint`||!Array.isArray(c.basises)))throw Error(`invalid endo: expected "beta": bigint and "basises": array`);let l=qa(r,i);function u(){if(!r.isOdd)throw Error(`compression is not supported: Field does not have .isOdd()`)}function d(e,t,n){let{x:i,y:a}=t.toAffine(),o=r.toBytes(i);return ot(n,`isCompressed`),n?(u(),_e(Ka(!r.isOdd(a)),o)):_e(Uint8Array.of(4),o,r.toBytes(a))}function f(e){st(e,void 0,`Point`);let{publicKey:t,publicKeyUncompressed:n}=l,i=e.length,a=e[0],o=e.subarray(1);if(i===t&&(a===2||a===3)){let e=r.fromBytes(o);if(!r.isValid(e))throw Error(`bad point: is not on curve, wrong x`);let t=h(e),n;try{n=r.sqrt(t)}catch(e){let t=e instanceof Error?`: `+e.message:``;throw Error(`bad point: is not on curve, sqrt error`+t)}u();let i=r.isOdd(n);return(a&1)==1!==i&&(n=r.neg(n)),{x:e,y:n}}else if(i===n&&a===4){let e=r.BYTES,t=r.fromBytes(o.subarray(0,e)),n=r.fromBytes(o.subarray(e,e*2));if(!g(t,n))throw Error(`bad point: is not on curve`);return{x:t,y:n}}else throw Error(`bad point: got length ${i}, expected compressed=${t} or uncompressed=${n}`)}let p=t.toBytes||d,m=t.fromBytes||f;function h(e){let t=r.sqr(e),n=r.mul(t,e);return r.add(r.add(n,r.mul(e,a.a)),a.b)}function g(e,t){let n=r.sqr(t),i=h(e);return r.eql(n,i)}if(!g(a.Gx,a.Gy))throw Error(`bad curve params: generator point`);let _=r.mul(r.pow(a.a,Ha),Ua),v=r.mul(r.sqr(a.b),BigInt(27));if(r.is0(r.add(_,v)))throw Error(`bad curve params: a or b`);function y(e,t,n=!1){if(!r.isValid(t)||n&&r.is0(t))throw Error(`bad point coordinate ${e}`);return t}function b(e){if(!(e instanceof T))throw Error(`ProjectivePoint expected`)}function x(e){if(!c||!c.basises)throw Error(`no endo`);return Fa(e,c.basises,i.ORDER)}let S=Tt((e,t)=>{let{X:n,Y:i,Z:a}=e;if(r.eql(a,r.ONE))return{x:n,y:i};let o=e.is0();t??=o?r.ONE:r.inv(a);let s=r.mul(n,t),c=r.mul(i,t),l=r.mul(a,t);if(o)return{x:r.ZERO,y:r.ZERO};if(!r.eql(l,r.ONE))throw Error(`invZ was invalid`);return{x:s,y:c}}),C=Tt(e=>{if(e.is0()){if(t.allowInfinityPoint&&!r.is0(e.Y))return;throw Error(`bad point: ZERO`)}let{x:n,y:i}=e.toAffine();if(!r.isValid(n)||!r.isValid(i))throw Error(`bad point: x or y not field elements`);if(!g(n,i))throw Error(`bad point: equation left != right`);if(!e.isTorsionFree())throw Error(`bad point: not in prime-order subgroup`);return!0});function w(e,t,n,i,a){return n=new T(r.mul(n.X,e),n.Y,n.Z),t=an(i,t),n=an(a,n),t.add(n)}class T{constructor(e,t,n){this.X=y(`x`,e),this.Y=y(`y`,t,!0),this.Z=y(`z`,n),Object.freeze(this)}static CURVE(){return a}static fromAffine(e){let{x:t,y:n}=e||{};if(!e||!r.isValid(t)||!r.isValid(n))throw Error(`invalid affine point`);if(e instanceof T)throw Error(`projective point not allowed`);return r.is0(t)&&r.is0(n)?T.ZERO:new T(t,n,r.ONE)}static fromBytes(e){let t=T.fromAffine(m(st(e,void 0,`point`)));return t.assertValidity(),t}static fromHex(e){return T.fromBytes(mt(`pointHex`,e))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(e=8,t=!0){return D.createCache(this,e),t||this.multiply(Ha),this}assertValidity(){C(this)}hasEvenY(){let{y:e}=this.toAffine();if(!r.isOdd)throw Error(`Field doesn't support isOdd`);return!r.isOdd(e)}equals(e){b(e);let{X:t,Y:n,Z:i}=this,{X:a,Y:o,Z:s}=e,c=r.eql(r.mul(t,s),r.mul(a,i)),l=r.eql(r.mul(n,s),r.mul(o,i));return c&&l}negate(){return new T(this.X,r.neg(this.Y),this.Z)}double(){let{a:e,b:t}=a,n=r.mul(t,Ha),{X:i,Y:o,Z:s}=this,c=r.ZERO,l=r.ZERO,u=r.ZERO,d=r.mul(i,i),f=r.mul(o,o),p=r.mul(s,s),m=r.mul(i,o);return m=r.add(m,m),u=r.mul(i,s),u=r.add(u,u),c=r.mul(e,u),l=r.mul(n,p),l=r.add(c,l),c=r.sub(f,l),l=r.add(f,l),l=r.mul(c,l),c=r.mul(m,c),u=r.mul(n,u),p=r.mul(e,p),m=r.sub(d,p),m=r.mul(e,m),m=r.add(m,u),u=r.add(d,d),d=r.add(u,d),d=r.add(d,p),d=r.mul(d,m),l=r.add(l,d),p=r.mul(o,s),p=r.add(p,p),d=r.mul(p,m),c=r.sub(c,d),u=r.mul(p,f),u=r.add(u,u),u=r.add(u,u),new T(c,l,u)}add(e){b(e);let{X:t,Y:n,Z:i}=this,{X:o,Y:s,Z:c}=e,l=r.ZERO,u=r.ZERO,d=r.ZERO,f=a.a,p=r.mul(a.b,Ha),m=r.mul(t,o),h=r.mul(n,s),g=r.mul(i,c),_=r.add(t,n),v=r.add(o,s);_=r.mul(_,v),v=r.add(m,h),_=r.sub(_,v),v=r.add(t,i);let y=r.add(o,c);return v=r.mul(v,y),y=r.add(m,g),v=r.sub(v,y),y=r.add(n,i),l=r.add(s,c),y=r.mul(y,l),l=r.add(h,g),y=r.sub(y,l),d=r.mul(f,v),l=r.mul(p,g),d=r.add(l,d),l=r.sub(h,d),d=r.add(h,d),u=r.mul(l,d),h=r.add(m,m),h=r.add(h,m),g=r.mul(f,g),v=r.mul(p,v),h=r.add(h,g),g=r.sub(m,g),g=r.mul(f,g),v=r.add(v,g),m=r.mul(h,v),u=r.add(u,m),m=r.mul(y,v),l=r.mul(_,l),l=r.sub(l,m),m=r.mul(_,h),d=r.mul(y,d),d=r.add(d,m),new T(l,u,d)}subtract(e){return this.add(e.negate())}is0(){return this.equals(T.ZERO)}multiply(e){let{endo:n}=t;if(!i.isValidNot0(e))throw Error(`invalid scalar: out of range`);let r,a,o=e=>D.cached(this,e,e=>on(T,e));if(n){let{k1neg:t,k1:i,k2neg:s,k2:c}=x(e),{p:l,f:u}=o(i),{p:d,f}=o(c);a=u.add(f),r=w(n.beta,l,d,t,s)}else{let{p:t,f:n}=o(e);r=t,a=n}return on(T,[r,a])[0]}multiplyUnsafe(e){let{endo:n}=t,r=this;if(!i.isValid(e))throw Error(`invalid scalar: out of range`);if(e===za||r.is0())return T.ZERO;if(e===Ba)return r;if(D.hasCache(this))return this.multiply(e);if(n){let{k1neg:t,k1:i,k2neg:a,k2:o}=x(e),{p1:s,p2:c}=_n(T,r,i,o);return w(n.beta,s,c,t,a)}else return D.unsafe(r,e)}multiplyAndAddUnsafe(e,t,n){let r=this.multiplyUnsafe(t).add(e.multiplyUnsafe(n));return r.is0()?void 0:r}toAffine(e){return S(this,e)}isTorsionFree(){let{isTorsionFree:e}=t;return o===Ba?!0:e?e(T,this):D.unsafe(this,s).is0()}clearCofactor(){let{clearCofactor:e}=t;return o===Ba?this:e?e(T,this):this.multiplyUnsafe(o)}isSmallOrder(){return this.multiplyUnsafe(o).is0()}toBytes(e=!0){return ot(e,`isCompressed`),this.assertValidity(),p(T,this,e)}toHex(e=!0){return fe(this.toBytes(e))}toString(){return`<Point ${this.is0()?`ZERO`:this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(e=!0){return this.toBytes(e)}_setWindowSize(e){this.precompute(e)}static normalizeZ(e){return on(T,e)}static msm(e,t){return vn(T,i,e,t)}static fromPrivateKey(e){return T.BASE.multiply(Wa(i,e))}}T.BASE=new T(a.Gx,a.Gy,r.ONE),T.ZERO=new T(r.ZERO,r.ONE,r.ZERO),T.Fp=r,T.Fn=i;let E=i.BITS,D=new gn(T,t.endo?Math.ceil(E/2):E);return T.BASE.precompute(8),T}function Ka(e){return Uint8Array.of(e?2:3)}function qa(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function Ja(e,t={}){let{Fn:n}=e,r=t.randomBytes||be,i=Object.assign(qa(e.Fp,n),{seed:en(n.ORDER)});function a(e){try{return!!Wa(n,e)}catch{return!1}}function o(t,n){let{publicKey:r,publicKeyUncompressed:a}=i;try{let i=t.length;return n===!0&&i!==r||n===!1&&i!==a?!1:!!e.fromBytes(t)}catch{return!1}}function s(e=r(i.seed)){return tn(st(e,i.seed,`seed`),n.ORDER)}function c(t,r=!0){return e.BASE.multiply(Wa(n,t)).toBytes(r)}function l(e){let t=s(e);return{secretKey:t,publicKey:c(t)}}function u(t){if(typeof t==`bigint`)return!1;if(t instanceof e)return!0;let{secretKey:r,publicKey:a,publicKeyUncompressed:o}=i;if(n.allowedLengths||r===a)return;let s=mt(`key`,t).length;return s===a||s===o}function d(t,r,i=!0){if(u(t)===!0)throw Error(`first arg must be private key`);if(u(r)===!1)throw Error(`second arg must be public key`);let a=Wa(n,t);return e.fromHex(r).multiply(a).toBytes(i)}return Object.freeze({getPublicKey:c,getSharedSecret:d,keygen:l,Point:e,utils:{isValidSecretKey:a,isValidPublicKey:o,randomSecretKey:s,isValidPrivateKey:a,randomPrivateKey:s,normPrivateKeyToScalar:e=>Wa(n,e),precompute(t=8,n=e.BASE){return n.precompute(t,!1)}},lengths:i})}function Ya(e,t,n={}){M(t),Ct(n,{},{hmac:`function`,lowS:`boolean`,randomBytes:`function`,bits2int:`function`,bits2int_modN:`function`});let r=n.randomBytes||be,i=n.hmac||((e,...n)=>rt(t,e,_e(...n))),{Fp:a,Fn:o}=e,{ORDER:s,BITS:c}=o,{keygen:l,getPublicKey:u,getSharedSecret:d,utils:f,lengths:p}=Ja(e,n),m={prehash:!1,lowS:typeof n.lowS==`boolean`?n.lowS:!1,format:void 0,extraEntropy:!1},h=`compact`;function g(e){return e>s>>Ba}function _(e,t){if(!o.isValidNot0(t))throw Error(`invalid signature ${e}: out of range 1..Point.Fn.ORDER`);return t}function v(e,t){Ia(t);let n=p.signature;return st(e,t===`compact`?n:t===`recovered`?n+1:void 0,`${t} signature`)}class y{constructor(e,t,n){this.r=_(`r`,e),this.s=_(`s`,t),n!=null&&(this.recovery=n),Object.freeze(this)}static fromBytes(e,t=h){v(e,t);let n;if(t===`der`){let{r:t,s:n}=Ra.toSig(st(e));return new y(t,n)}t===`recovered`&&(n=e[0],t=`compact`,e=e.subarray(1));let r=o.BYTES,i=e.subarray(0,r),a=e.subarray(r,r*2);return new y(o.fromBytes(i),o.fromBytes(a),n)}static fromHex(e,t){return this.fromBytes(me(e),t)}addRecoveryBit(e){return new y(this.r,this.s,e)}recoverPublicKey(t){let n=a.ORDER,{r,s:i,recovery:c}=this;if(c==null||![0,1,2,3].includes(c))throw Error(`recovery id invalid`);if(s*Va<n&&c>1)throw Error(`recovery id is ambiguous for h>1 curve`);let l=c===2||c===3?r+s:r;if(!a.isValid(l))throw Error(`recovery id 2 or 3 invalid`);let u=a.toBytes(l),d=e.fromBytes(_e(Ka((c&1)==0),u)),f=o.inv(l),p=x(mt(`msgHash`,t)),m=o.create(-p*f),h=o.create(i*f),g=e.BASE.multiplyUnsafe(m).add(d.multiplyUnsafe(h));if(g.is0())throw Error(`point at infinify`);return g.assertValidity(),g}hasHighS(){return g(this.s)}toBytes(e=h){if(Ia(e),e===`der`)return me(Ra.hexFromSig(this));let t=o.toBytes(this.r),n=o.toBytes(this.s);if(e===`recovered`){if(this.recovery==null)throw Error(`recovery bit must be present`);return _e(Uint8Array.of(this.recovery),t,n)}return _e(t,n)}toHex(e){return fe(this.toBytes(e))}assertValidity(){}static fromCompact(e){return y.fromBytes(mt(`sig`,e),`compact`)}static fromDER(e){return y.fromBytes(mt(`sig`,e),`der`)}normalizeS(){return this.hasHighS()?new y(this.r,o.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes(`der`)}toDERHex(){return fe(this.toBytes(`der`))}toCompactRawBytes(){return this.toBytes(`compact`)}toCompactHex(){return fe(this.toBytes(`compact`))}}let b=n.bits2int||function(e){if(e.length>8192)throw Error(`input is too large`);let t=ut(e),n=e.length*8-c;return n>0?t>>BigInt(n):t},x=n.bits2int_modN||function(e){return o.create(b(e))},S=xt(c);function C(e){return yt(`num < 2^`+c,e,za,S),o.toBytes(e)}function w(e,n){return st(e,void 0,`message`),n?st(t(e),void 0,`prehashed message`):e}function T(t,n,i){if([`recovered`,`canonical`].some(e=>e in i))throw Error(`sign() legacy options not supported`);let{lowS:a,prehash:s,extraEntropy:c}=La(i,m);t=w(t,s);let l=x(t),u=Wa(o,n),d=[C(u),C(l)];if(c!=null&&c!==!1){let e=c===!0?r(p.secretKey):c;d.push(mt(`extraEntropy`,e))}let f=_e(...d),h=l;function _(t){let n=b(t);if(!o.isValidNot0(n))return;let r=o.inv(n),i=e.BASE.multiply(n).toAffine(),s=o.create(i.x);if(s===za)return;let c=o.create(r*o.create(h+s*u));if(c===za)return;let l=(i.x===s?0:2)|Number(i.y&Ba),d=c;return a&&g(c)&&(d=o.neg(c),l^=1),new y(s,d,l)}return{seed:f,k2sig:_}}function E(e,n,r={}){e=mt(`message`,e);let{seed:a,k2sig:s}=T(e,n,r);return St(t.outputLen,o.BYTES,i)(a,s)}function D(e){let t,n=typeof e==`string`||A(e),r=!n&&typeof e==`object`&&!!e&&typeof e.r==`bigint`&&typeof e.s==`bigint`;if(!n&&!r)throw Error(`invalid signature, expected Uint8Array, hex string or Signature instance`);if(r)t=new y(e.r,e.s);else if(n){try{t=y.fromBytes(mt(`sig`,e),`der`)}catch(e){if(!(e instanceof Ra.Err))throw e}if(!t)try{t=y.fromBytes(mt(`sig`,e),`compact`)}catch{return!1}}return t||!1}function O(t,n,r,i={}){let{lowS:a,prehash:s,format:c}=La(i,m);if(r=mt(`publicKey`,r),n=w(mt(`message`,n),s),`strict`in i)throw Error(`options.strict was renamed to lowS`);let l=c===void 0?D(t):y.fromBytes(mt(`sig`,t),c);if(l===!1)return!1;try{let t=e.fromBytes(r);if(a&&l.hasHighS())return!1;let{r:i,s}=l,c=x(n),u=o.inv(s),d=o.create(c*u),f=o.create(i*u),p=e.BASE.multiplyUnsafe(d).add(t.multiplyUnsafe(f));return p.is0()?!1:o.create(p.x)===i}catch{return!1}}function k(e,t,n={}){let{prehash:r}=La(n,m);return t=w(t,r),y.fromBytes(e,`recovered`).recoverPublicKey(t).toBytes()}return Object.freeze({keygen:l,getPublicKey:u,getSharedSecret:d,utils:f,lengths:p,Point:e,sign:E,verify:O,recoverPublicKey:k,Signature:y,hash:t})}function Xa(e){let t={a:e.a,b:e.b,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},n=e.Fp,r=e.allowedPrivateKeyLengths?Array.from(new Set(e.allowedPrivateKeyLengths.map(e=>Math.ceil(e/2)))):void 0;return{CURVE:t,curveOpts:{Fp:n,Fn:Qt(t.n,{BITS:e.nBitLength,allowedLengths:r,modFromBytes:e.wrapPrivateKey}),allowInfinityPoint:e.allowInfinityPoint,endo:e.endo,isTorsionFree:e.isTorsionFree,clearCofactor:e.clearCofactor,fromBytes:e.fromBytes,toBytes:e.toBytes}}}function Za(e){let{CURVE:t,curveOpts:n}=Xa(e),r={hmac:e.hmac,randomBytes:e.randomBytes,lowS:e.lowS,bits2int:e.bits2int,bits2int_modN:e.bits2int_modN};return{CURVE:t,curveOpts:n,hash:e.hash,ecdsaOpts:r}}function Qa(e,t){let n=t.Point;return Object.assign({},t,{ProjectivePoint:n,CURVE:Object.assign({},e,Zt(n.Fn.ORDER,n.Fn.BITS))})}function $a(e){let{CURVE:t,curveOpts:n,hash:r,ecdsaOpts:i}=Za(e);return Qa(e,Ya(Ga(t,n),r,i))}function eo(e,t){let n=t=>$a({...e,hash:t});return{...n(t),create:n}}var to={p:BigInt(`0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f`),n:BigInt(`0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141`),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt(`0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798`),Gy:BigInt(`0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8`)},no={beta:BigInt(`0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee`),basises:[[BigInt(`0x3086d221a7d46bcde86c90e49284eb15`),-BigInt(`0xe4437ed6010e88286f547fa90abfe4c3`)],[BigInt(`0x114ca50f7a8e2f3f657c1108d9d44cfd8`),BigInt(`0x3086d221a7d46bcde86c90e49284eb15`)]]},ro=BigInt(2);function io(e){let t=to.p,n=BigInt(3),r=BigInt(6),i=BigInt(11),a=BigInt(22),o=BigInt(23),s=BigInt(44),c=BigInt(88),l=e*e*e%t,u=l*l*e%t,d=Lt(Lt(Lt(u,n,t)*u%t,n,t)*u%t,ro,t)*l%t,f=Lt(d,i,t)*d%t,p=Lt(f,a,t)*f%t,m=Lt(p,s,t)*p%t,h=Lt(Lt(Lt(Lt(Lt(Lt(m,c,t)*m%t,s,t)*p%t,n,t)*u%t,o,t)*f%t,r,t)*l%t,ro,t);if(!ao.eql(ao.sqr(h),e))throw Error(`Cannot find square root`);return h}var ao=Qt(to.p,{sqrt:io}),oo=eo({...to,Fp:ao,lowS:!0,endo:no},$e),so=r({Account:()=>xo,AddressLookupTableAccount:()=>Ps,AddressLookupTableInstruction:()=>Ml,AddressLookupTableProgram:()=>Nl,Authorized:()=>Zl,BLOCKHASH_CACHE_TIMEOUT_MS:()=>Vs,BPF_LOADER_DEPRECATED_PROGRAM_ID:()=>So,BPF_LOADER_PROGRAM_ID:()=>ys,BpfLoader:()=>bs,COMPUTE_BUDGET_INSTRUCTION_LAYOUTS:()=>Fl,ComputeBudgetInstruction:()=>Pl,ComputeBudgetProgram:()=>Il,Connection:()=>kl,Ed25519Program:()=>Vl,Enum:()=>go,EpochSchedule:()=>ks,FeeCalculatorLayout:()=>ls,Keypair:()=>Al,LAMPORTS_PER_SOL:()=>bu,LOOKUP_TABLE_INSTRUCTION_LAYOUTS:()=>jl,Loader:()=>vs,Lockup:()=>Ql,MAX_SEED_LENGTH:()=>32,Message:()=>Ho,MessageAccountKeys:()=>Oo,MessageV0:()=>Uo,NONCE_ACCOUNT_LENGTH:()=>ds,NonceAccount:()=>fs,PACKET_DATA_SIZE:()=>Co,PUBLIC_KEY_LENGTH:()=>32,PublicKey:()=>G,SIGNATURE_LENGTH_IN_BYTES:()=>64,SOLANA_SCHEMA:()=>_o,STAKE_CONFIG_ID:()=>Xl,STAKE_INSTRUCTION_LAYOUTS:()=>eu,SYSTEM_INSTRUCTION_LAYOUTS:()=>hs,SYSVAR_CLOCK_PUBKEY:()=>Xo,SYSVAR_EPOCH_SCHEDULE_PUBKEY:()=>Zo,SYSVAR_INSTRUCTIONS_PUBKEY:()=>Qo,SYSVAR_RECENT_BLOCKHASHES_PUBKEY:()=>$o,SYSVAR_RENT_PUBKEY:()=>es,SYSVAR_REWARDS_PUBKEY:()=>ts,SYSVAR_SLOT_HASHES_PUBKEY:()=>ns,SYSVAR_SLOT_HISTORY_PUBKEY:()=>rs,SYSVAR_STAKE_HISTORY_PUBKEY:()=>is,Secp256k1Program:()=>Jl,SendTransactionError:()=>as,SolanaJSONRPCError:()=>X,SolanaJSONRPCErrorCode:()=>os,StakeAuthorizationLayout:()=>tu,StakeInstruction:()=>$l,StakeProgram:()=>nu,Struct:()=>ho,SystemInstruction:()=>ms,SystemProgram:()=>gs,Transaction:()=>Y,TransactionExpiredBlockheightExceededError:()=>To,TransactionExpiredNonceInvalidError:()=>Do,TransactionExpiredTimeoutError:()=>Eo,TransactionInstruction:()=>J,TransactionMessage:()=>qo,TransactionStatus:()=>Go,VALIDATOR_INFO_KEY:()=>cu,VERSION_PREFIX_MASK:()=>127,VOTE_PROGRAM_ID:()=>du,ValidatorInfo:()=>uu,VersionedMessage:()=>Wo,VersionedTransaction:()=>Jo,VoteAccount:()=>pu,VoteAuthorizationLayout:()=>ou,VoteInit:()=>ru,VoteInstruction:()=>iu,VoteProgram:()=>su,clusterApiUrl:()=>vu,sendAndConfirmRawTransaction:()=>yu,sendAndConfirmTransaction:()=>ss}),co=Gn.utils.randomPrivateKey,lo=()=>{let e=Gn.utils.randomPrivateKey(),t=uo(e),n=new Uint8Array(64);return n.set(e),n.set(t,32),{publicKey:t,secretKey:n}},uo=Gn.getPublicKey;function fo(e){try{return Gn.ExtendedPoint.fromHex(e),!0}catch{return!1}}var po=(e,t)=>Gn.sign(e,t.slice(0,32)),mo=Gn.verify,W=e=>F.Buffer.isBuffer(e)?e:e instanceof Uint8Array?F.Buffer.from(e.buffer,e.byteOffset,e.byteLength):F.Buffer.from(e),ho=class{constructor(e){Object.assign(this,e)}encode(){return F.Buffer.from((0,Ar.serialize)(_o,this))}static decode(e){return(0,Ar.deserialize)(_o,this,e)}static decodeUnchecked(e){return(0,Ar.deserializeUnchecked)(_o,this,e)}},go=class extends ho{constructor(e){if(super(e),this.enum=``,Object.keys(e).length!==1)throw Error(`Enum can only take single value`);Object.keys(e).map(e=>{this.enum=e})}},_o=new Map,vo;function yo(e){return e._bn!==void 0}var bo=1,G=class e extends ho{constructor(e){if(super({}),this._bn=void 0,yo(e))this._bn=e._bn;else{if(typeof e==`string`){let t=kr.default.decode(e);if(t.length!=32)throw Error(`Invalid public key input`);this._bn=new Or.default(t)}else this._bn=new Or.default(e);if(this._bn.byteLength()>32)throw Error(`Invalid public key input`)}}static unique(){let t=new e(bo);return bo+=1,new e(t.toBuffer())}equals(e){return this._bn.eq(e._bn)}toBase58(){return kr.default.encode(this.toBytes())}toJSON(){return this.toBase58()}toBytes(){let e=this.toBuffer();return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}toBuffer(){let e=this._bn.toArrayLike(F.Buffer);if(e.length===32)return e;let t=F.Buffer.alloc(32);return e.copy(t,32-e.length),t}get[Symbol.toStringTag](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(t,n,r){return new e(tt(F.Buffer.concat([t.toBuffer(),F.Buffer.from(n),r.toBuffer()])))}static createProgramAddressSync(t,n){let r=F.Buffer.alloc(0);t.forEach(function(e){if(e.length>32)throw TypeError(`Max seed length exceeded`);r=F.Buffer.concat([r,W(e)])}),r=F.Buffer.concat([r,n.toBuffer(),F.Buffer.from(`ProgramDerivedAddress`)]);let i=tt(r);if(fo(i))throw Error(`Invalid seeds, address must fall off the curve`);return new e(i)}static async createProgramAddress(e,t){return this.createProgramAddressSync(e,t)}static findProgramAddressSync(e,t){let n=255,r;for(;n!=0;){try{let i=e.concat(F.Buffer.from([n]));r=this.createProgramAddressSync(i,t)}catch(e){if(e instanceof TypeError)throw e;n--;continue}return[r,n]}throw Error(`Unable to find a viable program address nonce`)}static async findProgramAddress(e,t){return this.findProgramAddressSync(e,t)}static isOnCurve(t){return fo(new e(t).toBytes())}};vo=G,G.default=new vo(`11111111111111111111111111111111`),_o.set(G,{kind:`struct`,fields:[[`_bn`,`u256`]]});var xo=class{constructor(e){if(this._publicKey=void 0,this._secretKey=void 0,e){let t=W(e);if(e.length!==64)throw Error(`bad secret key size`);this._publicKey=t.slice(32,64),this._secretKey=t.slice(0,32)}else this._secretKey=W(co()),this._publicKey=W(uo(this._secretKey))}get publicKey(){return new G(this._publicKey)}get secretKey(){return F.Buffer.concat([this._secretKey,this._publicKey],64)}},So=new G(`BPFLoader1111111111111111111111111111111111`),Co=1232,wo=64,To=class extends Error{constructor(e){super(`Signature ${e} has expired: block height exceeded.`),this.signature=void 0,this.signature=e}};Object.defineProperty(To.prototype,"name",{value:`TransactionExpiredBlockheightExceededError`});var Eo=class extends Error{constructor(e,t){super(`Transaction was not confirmed in ${t.toFixed(2)} seconds. It is unknown if it succeeded or failed. Check signature ${e} using the Solana Explorer or CLI tools.`),this.signature=void 0,this.signature=e}};Object.defineProperty(Eo.prototype,"name",{value:`TransactionExpiredTimeoutError`});var Do=class extends Error{constructor(e){super(`Signature ${e} has expired: the nonce is no longer valid.`),this.signature=void 0,this.signature=e}};Object.defineProperty(Do.prototype,"name",{value:`TransactionExpiredNonceInvalidError`});var Oo=class{constructor(e,t){this.staticAccountKeys=void 0,this.accountKeysFromLookups=void 0,this.staticAccountKeys=e,this.accountKeysFromLookups=t}keySegments(){let e=[this.staticAccountKeys];return this.accountKeysFromLookups&&(e.push(this.accountKeysFromLookups.writable),e.push(this.accountKeysFromLookups.readonly)),e}get(e){for(let t of this.keySegments())if(e<t.length)return t[e];else e-=t.length}get length(){return this.keySegments().flat().length}compileInstructions(e){if(this.length>256)throw Error(`Account index overflow encountered during compilation`);let t=new Map;this.keySegments().flat().forEach((e,n)=>{t.set(e.toBase58(),n)});let n=e=>{let n=t.get(e.toBase58());if(n===void 0)throw Error(`Encountered an unknown instruction account key during compilation`);return n};return e.map(e=>({programIdIndex:n(e.programId),accountKeyIndexes:e.keys.map(e=>n(e.pubkey)),data:e.data}))}},K=(e=`publicKey`)=>I.blob(32,e),ko=(e=`signature`)=>I.blob(64,e),Ao=(e=`string`)=>{let t=I.struct([I.u32(`length`),I.u32(`lengthPadding`),I.blob(I.offset(I.u32(),-8),`chars`)],e),n=t.decode.bind(t),r=t.encode.bind(t),i=t;return i.decode=(e,t)=>n(e,t).chars.toString(),i.encode=(e,t,n)=>r({chars:F.Buffer.from(e,`utf8`)},t,n),i.alloc=e=>I.u32().span+I.u32().span+F.Buffer.from(e,`utf8`).length,i},jo=(e=`authorized`)=>I.struct([K(`staker`),K(`withdrawer`)],e),Mo=(e=`lockup`)=>I.struct([I.ns64(`unixTimestamp`),I.ns64(`epoch`),K(`custodian`)],e),No=(e=`voteInit`)=>I.struct([K(`nodePubkey`),K(`authorizedVoter`),K(`authorizedWithdrawer`),I.u8(`commission`)],e),Po=(e=`voteAuthorizeWithSeedArgs`)=>I.struct([I.u32(`voteAuthorizationType`),K(`currentAuthorityDerivedKeyOwnerPubkey`),Ao(`currentAuthorityDerivedKeySeed`),K(`newAuthorized`)],e);function Fo(e,t){let n=e=>{if(e.span>=0)return e.span;if(typeof e.alloc==`function`)return e.alloc(t[e.property]);if(`count`in e&&`elementLayout`in e){let r=t[e.property];if(Array.isArray(r))return r.length*n(e.elementLayout)}else if(`fields`in e)return Fo({layout:e},t[e.property]);return 0},r=0;return e.layout.fields.forEach(e=>{r+=n(e)}),r}function Io(e){let t=0,n=0;for(;;){let r=e.shift();if(t|=(r&127)<<n*7,n+=1,!(r&128))break}return t}function Lo(e,t){let n=t;for(;;){let t=n&127;if(n>>=7,n==0){e.push(t);break}else t|=128,e.push(t)}}function q(e,t){if(!e)throw Error(t||`Assertion failed`)}var Ro=class e{constructor(e,t){this.payer=void 0,this.keyMetaMap=void 0,this.payer=e,this.keyMetaMap=t}static compile(t,n){let r=new Map,i=e=>{let t=e.toBase58(),n=r.get(t);return n===void 0&&(n={isSigner:!1,isWritable:!1,isInvoked:!1},r.set(t,n)),n},a=i(n);a.isSigner=!0,a.isWritable=!0;for(let e of t){i(e.programId).isInvoked=!0;for(let t of e.keys){let e=i(t.pubkey);e.isSigner||=t.isSigner,e.isWritable||=t.isWritable}}return new e(n,r)}getMessageComponents(){let e=[...this.keyMetaMap.entries()];q(e.length<=256,`Max static account keys length exceeded`);let t=e.filter(([,e])=>e.isSigner&&e.isWritable),n=e.filter(([,e])=>e.isSigner&&!e.isWritable),r=e.filter(([,e])=>!e.isSigner&&e.isWritable),i=e.filter(([,e])=>!e.isSigner&&!e.isWritable),a={numRequiredSignatures:t.length+n.length,numReadonlySignedAccounts:n.length,numReadonlyUnsignedAccounts:i.length};{q(t.length>0,`Expected at least one writable signer key`);let[e]=t[0];q(e===this.payer.toBase58(),`Expected first writable signer key to be the fee payer`)}return[a,[...t.map(([e])=>new G(e)),...n.map(([e])=>new G(e)),...r.map(([e])=>new G(e)),...i.map(([e])=>new G(e))]]}extractTableLookup(e){let[t,n]=this.drainKeysFoundInLookupTable(e.state.addresses,e=>!e.isSigner&&!e.isInvoked&&e.isWritable),[r,i]=this.drainKeysFoundInLookupTable(e.state.addresses,e=>!e.isSigner&&!e.isInvoked&&!e.isWritable);if(!(t.length===0&&r.length===0))return[{accountKey:e.key,writableIndexes:t,readonlyIndexes:r},{writable:n,readonly:i}]}drainKeysFoundInLookupTable(e,t){let n=[],r=[];for(let[i,a]of this.keyMetaMap.entries())if(t(a)){let t=new G(i),a=e.findIndex(e=>e.equals(t));a>=0&&(q(a<256,`Max lookup table index exceeded`),n.push(a),r.push(t),this.keyMetaMap.delete(i))}return[n,r]}},zo=`Reached end of buffer unexpectedly`;function Bo(e){if(e.length===0)throw Error(zo);return e.shift()}function Vo(e,...t){let[n]=t;if(t.length===2?n+(t[1]??0)>e.length:n>=e.length)throw Error(zo);return e.splice(...t)}var Ho=class e{constructor(e){this.header=void 0,this.accountKeys=void 0,this.recentBlockhash=void 0,this.instructions=void 0,this.indexToProgramIds=new Map,this.header=e.header,this.accountKeys=e.accountKeys.map(e=>new G(e)),this.recentBlockhash=e.recentBlockhash,this.instructions=e.instructions,this.instructions.forEach(e=>this.indexToProgramIds.set(e.programIdIndex,this.accountKeys[e.programIdIndex]))}get version(){return`legacy`}get staticAccountKeys(){return this.accountKeys}get compiledInstructions(){return this.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:kr.default.decode(e.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new Oo(this.staticAccountKeys)}static compile(t){let[n,r]=Ro.compile(t.instructions,t.payerKey).getMessageComponents(),i=new Oo(r).compileInstructions(t.instructions).map(e=>({programIdIndex:e.programIdIndex,accounts:e.accountKeyIndexes,data:kr.default.encode(e.data)}));return new e({header:n,accountKeys:r,recentBlockhash:t.recentBlockhash,instructions:i})}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){let t=this.header.numRequiredSignatures;return e>=this.header.numRequiredSignatures?e-t<this.accountKeys.length-t-this.header.numReadonlyUnsignedAccounts:e<t-this.header.numReadonlySignedAccounts}isProgramId(e){return this.indexToProgramIds.has(e)}programIds(){return[...this.indexToProgramIds.values()]}nonProgramIds(){return this.accountKeys.filter((e,t)=>!this.isProgramId(t))}serialize(){let e=this.accountKeys.length,t=[];Lo(t,e);let n=this.instructions.map(e=>{let{accounts:t,programIdIndex:n}=e,r=Array.from(kr.default.decode(e.data)),i=[];Lo(i,t.length);let a=[];return Lo(a,r.length),{programIdIndex:n,keyIndicesCount:F.Buffer.from(i),keyIndices:t,dataLength:F.Buffer.from(a),data:r}}),r=[];Lo(r,n.length);let i=F.Buffer.alloc(Co);F.Buffer.from(r).copy(i);let a=r.length;n.forEach(e=>{let t=I.struct([I.u8(`programIdIndex`),I.blob(e.keyIndicesCount.length,`keyIndicesCount`),I.seq(I.u8(`keyIndex`),e.keyIndices.length,`keyIndices`),I.blob(e.dataLength.length,`dataLength`),I.seq(I.u8(`userdatum`),e.data.length,`data`)]).encode(e,i,a);a+=t}),i=i.slice(0,a);let o=I.struct([I.blob(1,`numRequiredSignatures`),I.blob(1,`numReadonlySignedAccounts`),I.blob(1,`numReadonlyUnsignedAccounts`),I.blob(t.length,`keyCount`),I.seq(K(`key`),e,`keys`),K(`recentBlockhash`)]),s={numRequiredSignatures:F.Buffer.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:F.Buffer.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:F.Buffer.from([this.header.numReadonlyUnsignedAccounts]),keyCount:F.Buffer.from(t),keys:this.accountKeys.map(e=>W(e.toBytes())),recentBlockhash:kr.default.decode(this.recentBlockhash)},c=F.Buffer.alloc(2048),l=o.encode(s,c);return i.copy(c,l),c.slice(0,l+i.length)}static from(t){let n=[...t],r=Bo(n);if(r!==(r&127))throw Error(`Versioned messages must be deserialized with VersionedMessage.deserialize()`);let i=Bo(n),a=Bo(n),o=Io(n),s=[];for(let e=0;e<o;e++){let e=Vo(n,0,32);s.push(new G(F.Buffer.from(e)))}let c=Vo(n,0,32),l=Io(n),u=[];for(let e=0;e<l;e++){let e=Bo(n),t=Vo(n,0,Io(n)),r=Vo(n,0,Io(n)),i=kr.default.encode(F.Buffer.from(r));u.push({programIdIndex:e,accounts:t,data:i})}return new e({header:{numRequiredSignatures:r,numReadonlySignedAccounts:i,numReadonlyUnsignedAccounts:a},recentBlockhash:kr.default.encode(F.Buffer.from(c)),accountKeys:s,instructions:u})}},Uo=class e{constructor(e){this.header=void 0,this.staticAccountKeys=void 0,this.recentBlockhash=void 0,this.compiledInstructions=void 0,this.addressTableLookups=void 0,this.header=e.header,this.staticAccountKeys=e.staticAccountKeys,this.recentBlockhash=e.recentBlockhash,this.compiledInstructions=e.compiledInstructions,this.addressTableLookups=e.addressTableLookups}get version(){return 0}get numAccountKeysFromLookups(){let e=0;for(let t of this.addressTableLookups)e+=t.readonlyIndexes.length+t.writableIndexes.length;return e}getAccountKeys(e){let t;if(e&&`accountKeysFromLookups`in e&&e.accountKeysFromLookups){if(this.numAccountKeysFromLookups!=e.accountKeysFromLookups.writable.length+e.accountKeysFromLookups.readonly.length)throw Error(`Failed to get account keys because of a mismatch in the number of account keys from lookups`);t=e.accountKeysFromLookups}else if(e&&`addressLookupTableAccounts`in e&&e.addressLookupTableAccounts)t=this.resolveAddressTableLookups(e.addressLookupTableAccounts);else if(this.addressTableLookups.length>0)throw Error(`Failed to get account keys because address table lookups were not resolved`);return new Oo(this.staticAccountKeys,t)}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){let t=this.header.numRequiredSignatures,n=this.staticAccountKeys.length;return e>=n?e-n<this.addressTableLookups.reduce((e,t)=>e+t.writableIndexes.length,0):e>=this.header.numRequiredSignatures?e-t<n-t-this.header.numReadonlyUnsignedAccounts:e<t-this.header.numReadonlySignedAccounts}resolveAddressTableLookups(e){let t={writable:[],readonly:[]};for(let n of this.addressTableLookups){let r=e.find(e=>e.key.equals(n.accountKey));if(!r)throw Error(`Failed to find address lookup table account for table key ${n.accountKey.toBase58()}`);for(let e of n.writableIndexes)if(e<r.state.addresses.length)t.writable.push(r.state.addresses[e]);else throw Error(`Failed to find address for index ${e} in address lookup table ${n.accountKey.toBase58()}`);for(let e of n.readonlyIndexes)if(e<r.state.addresses.length)t.readonly.push(r.state.addresses[e]);else throw Error(`Failed to find address for index ${e} in address lookup table ${n.accountKey.toBase58()}`)}return t}static compile(t){let n=Ro.compile(t.instructions,t.payerKey),r=[],i={writable:[],readonly:[]},a=t.addressLookupTableAccounts||[];for(let e of a){let t=n.extractTableLookup(e);if(t!==void 0){let[e,{writable:n,readonly:a}]=t;r.push(e),i.writable.push(...n),i.readonly.push(...a)}}let[o,s]=n.getMessageComponents(),c=new Oo(s,i).compileInstructions(t.instructions);return new e({header:o,staticAccountKeys:s,recentBlockhash:t.recentBlockhash,compiledInstructions:c,addressTableLookups:r})}serialize(){let e=[];Lo(e,this.staticAccountKeys.length);let t=this.serializeInstructions(),n=[];Lo(n,this.compiledInstructions.length);let r=this.serializeAddressTableLookups(),i=[];Lo(i,this.addressTableLookups.length);let a=I.struct([I.u8(`prefix`),I.struct([I.u8(`numRequiredSignatures`),I.u8(`numReadonlySignedAccounts`),I.u8(`numReadonlyUnsignedAccounts`)],`header`),I.blob(e.length,`staticAccountKeysLength`),I.seq(K(),this.staticAccountKeys.length,`staticAccountKeys`),K(`recentBlockhash`),I.blob(n.length,`instructionsLength`),I.blob(t.length,`serializedInstructions`),I.blob(i.length,`addressTableLookupsLength`),I.blob(r.length,`serializedAddressTableLookups`)]),o=new Uint8Array(Co),s=a.encode({prefix:128,header:this.header,staticAccountKeysLength:new Uint8Array(e),staticAccountKeys:this.staticAccountKeys.map(e=>e.toBytes()),recentBlockhash:kr.default.decode(this.recentBlockhash),instructionsLength:new Uint8Array(n),serializedInstructions:t,addressTableLookupsLength:new Uint8Array(i),serializedAddressTableLookups:r},o);return o.slice(0,s)}serializeInstructions(){let e=0,t=new Uint8Array(Co);for(let n of this.compiledInstructions){let r=[];Lo(r,n.accountKeyIndexes.length);let i=[];Lo(i,n.data.length);let a=I.struct([I.u8(`programIdIndex`),I.blob(r.length,`encodedAccountKeyIndexesLength`),I.seq(I.u8(),n.accountKeyIndexes.length,`accountKeyIndexes`),I.blob(i.length,`encodedDataLength`),I.blob(n.data.length,`data`)]);e+=a.encode({programIdIndex:n.programIdIndex,encodedAccountKeyIndexesLength:new Uint8Array(r),accountKeyIndexes:n.accountKeyIndexes,encodedDataLength:new Uint8Array(i),data:n.data},t,e)}return t.slice(0,e)}serializeAddressTableLookups(){let e=0,t=new Uint8Array(Co);for(let n of this.addressTableLookups){let r=[];Lo(r,n.writableIndexes.length);let i=[];Lo(i,n.readonlyIndexes.length);let a=I.struct([K(`accountKey`),I.blob(r.length,`encodedWritableIndexesLength`),I.seq(I.u8(),n.writableIndexes.length,`writableIndexes`),I.blob(i.length,`encodedReadonlyIndexesLength`),I.seq(I.u8(),n.readonlyIndexes.length,`readonlyIndexes`)]);e+=a.encode({accountKey:n.accountKey.toBytes(),encodedWritableIndexesLength:new Uint8Array(r),writableIndexes:n.writableIndexes,encodedReadonlyIndexesLength:new Uint8Array(i),readonlyIndexes:n.readonlyIndexes},t,e)}return t.slice(0,e)}static deserialize(t){let n=[...t],r=Bo(n),i=r&127;q(r!==i,`Expected versioned message but received legacy message`);let a=i;q(a===0,`Expected versioned message with version 0 but found version ${a}`);let o={numRequiredSignatures:Bo(n),numReadonlySignedAccounts:Bo(n),numReadonlyUnsignedAccounts:Bo(n)},s=[],c=Io(n);for(let e=0;e<c;e++)s.push(new G(Vo(n,0,32)));let l=kr.default.encode(Vo(n,0,32)),u=Io(n),d=[];for(let e=0;e<u;e++){let e=Bo(n),t=Vo(n,0,Io(n)),r=Io(n),i=new Uint8Array(Vo(n,0,r));d.push({programIdIndex:e,accountKeyIndexes:t,data:i})}let f=Io(n),p=[];for(let e=0;e<f;e++){let e=new G(Vo(n,0,32)),t=Vo(n,0,Io(n)),r=Vo(n,0,Io(n));p.push({accountKey:e,writableIndexes:t,readonlyIndexes:r})}return new e({header:o,staticAccountKeys:s,recentBlockhash:l,compiledInstructions:d,addressTableLookups:p})}},Wo={deserializeMessageVersion(e){let t=e[0],n=t&127;return n===t?`legacy`:n},deserialize:e=>{let t=Wo.deserializeMessageVersion(e);if(t===`legacy`)return Ho.from(e);if(t===0)return Uo.deserialize(e);throw Error(`Transaction message version ${t} deserialization is not supported`)}},Go=function(e){return e[e.BLOCKHEIGHT_EXCEEDED=0]=`BLOCKHEIGHT_EXCEEDED`,e[e.PROCESSED=1]=`PROCESSED`,e[e.TIMED_OUT=2]=`TIMED_OUT`,e[e.NONCE_INVALID=3]=`NONCE_INVALID`,e}({}),Ko=F.Buffer.alloc(64).fill(0),J=class{constructor(e){this.keys=void 0,this.programId=void 0,this.data=F.Buffer.alloc(0),this.programId=e.programId,this.keys=e.keys,e.data&&(this.data=e.data)}toJSON(){return{keys:this.keys.map(({pubkey:e,isSigner:t,isWritable:n})=>({pubkey:e.toJSON(),isSigner:t,isWritable:n})),programId:this.programId.toJSON(),data:[...this.data]}}},Y=class e{get signature(){return this.signatures.length>0?this.signatures[0].signature:null}constructor(e){if(this.signatures=[],this.feePayer=void 0,this.instructions=[],this.recentBlockhash=void 0,this.lastValidBlockHeight=void 0,this.nonceInfo=void 0,this.minNonceContextSlot=void 0,this._message=void 0,this._json=void 0,e)if(e.feePayer&&(this.feePayer=e.feePayer),e.signatures&&(this.signatures=e.signatures),Object.prototype.hasOwnProperty.call(e,`nonceInfo`)){let{minContextSlot:t,nonceInfo:n}=e;this.minNonceContextSlot=t,this.nonceInfo=n}else if(Object.prototype.hasOwnProperty.call(e,`lastValidBlockHeight`)){let{blockhash:t,lastValidBlockHeight:n}=e;this.recentBlockhash=t,this.lastValidBlockHeight=n}else{let{recentBlockhash:t,nonceInfo:n}=e;n&&(this.nonceInfo=n),this.recentBlockhash=t}}toJSON(){return{recentBlockhash:this.recentBlockhash||null,feePayer:this.feePayer?this.feePayer.toJSON():null,nonceInfo:this.nonceInfo?{nonce:this.nonceInfo.nonce,nonceInstruction:this.nonceInfo.nonceInstruction.toJSON()}:null,instructions:this.instructions.map(e=>e.toJSON()),signers:this.signatures.map(({publicKey:e})=>e.toJSON())}}add(...e){if(e.length===0)throw Error(`No instructions`);return e.forEach(e=>{`instructions`in e?this.instructions=this.instructions.concat(e.instructions):`data`in e&&`programId`in e&&`keys`in e?this.instructions.push(e):this.instructions.push(new J(e))}),this}compileMessage(){if(this._message&&JSON.stringify(this.toJSON())===JSON.stringify(this._json))return this._message;let e,t;if(this.nonceInfo?(e=this.nonceInfo.nonce,t=this.instructions[0]==this.nonceInfo.nonceInstruction?this.instructions:[this.nonceInfo.nonceInstruction,...this.instructions]):(e=this.recentBlockhash,t=this.instructions),!e)throw Error(`Transaction recentBlockhash required`);t.length<1&&console.warn(`No instructions provided`);let n;if(this.feePayer)n=this.feePayer;else if(this.signatures.length>0&&this.signatures[0].publicKey)n=this.signatures[0].publicKey;else throw Error(`Transaction fee payer required`);for(let e=0;e<t.length;e++)if(t[e].programId===void 0)throw Error(`Transaction instruction index ${e} has undefined program id`);let r=[],i=[];t.forEach(e=>{e.keys.forEach(e=>{i.push({...e})});let t=e.programId.toString();r.includes(t)||r.push(t)}),r.forEach(e=>{i.push({pubkey:new G(e),isSigner:!1,isWritable:!1})});let a=[];i.forEach(e=>{let t=e.pubkey.toString(),n=a.findIndex(e=>e.pubkey.toString()===t);n>-1?(a[n].isWritable=a[n].isWritable||e.isWritable,a[n].isSigner=a[n].isSigner||e.isSigner):a.push(e)}),a.sort(function(e,t){return e.isSigner===t.isSigner?e.isWritable===t.isWritable?e.pubkey.toBase58().localeCompare(t.pubkey.toBase58(),`en`,{localeMatcher:`best fit`,usage:`sort`,sensitivity:`variant`,ignorePunctuation:!1,numeric:!1,caseFirst:`lower`}):e.isWritable?-1:1:e.isSigner?-1:1});let o=a.findIndex(e=>e.pubkey.equals(n));if(o>-1){let[e]=a.splice(o,1);e.isSigner=!0,e.isWritable=!0,a.unshift(e)}else a.unshift({pubkey:n,isSigner:!0,isWritable:!0});for(let e of this.signatures){let t=a.findIndex(t=>t.pubkey.equals(e.publicKey));if(t>-1)a[t].isSigner||(a[t].isSigner=!0,console.warn(`Transaction references a signature that is unnecessary, only the fee payer and instruction signer accounts should sign a transaction. This behavior is deprecated and will throw an error in the next major version release.`));else throw Error(`unknown signer: ${e.publicKey.toString()}`)}let s=0,c=0,l=0,u=[],d=[];a.forEach(({pubkey:e,isSigner:t,isWritable:n})=>{t?(u.push(e.toString()),s+=1,n||(c+=1)):(d.push(e.toString()),n||(l+=1))});let f=u.concat(d),p=t.map(e=>{let{data:t,programId:n}=e;return{programIdIndex:f.indexOf(n.toString()),accounts:e.keys.map(e=>f.indexOf(e.pubkey.toString())),data:kr.default.encode(t)}});return p.forEach(e=>{q(e.programIdIndex>=0),e.accounts.forEach(e=>q(e>=0))}),new Ho({header:{numRequiredSignatures:s,numReadonlySignedAccounts:c,numReadonlyUnsignedAccounts:l},accountKeys:f,recentBlockhash:e,instructions:p})}_compile(){let e=this.compileMessage(),t=e.accountKeys.slice(0,e.header.numRequiredSignatures);return this.signatures.length===t.length&&this.signatures.every((e,n)=>t[n].equals(e.publicKey))||(this.signatures=t.map(e=>({signature:null,publicKey:e}))),e}serializeMessage(){return this._compile().serialize()}async getEstimatedFee(e){return(await e.getFeeForMessage(this.compileMessage())).value}setSigners(...e){if(e.length===0)throw Error(`No signers`);let t=new Set;this.signatures=e.filter(e=>{let n=e.toString();return t.has(n)?!1:(t.add(n),!0)}).map(e=>({signature:null,publicKey:e}))}sign(...e){if(e.length===0)throw Error(`No signers`);let t=new Set,n=[];for(let r of e){let e=r.publicKey.toString();t.has(e)||(t.add(e),n.push(r))}this.signatures=n.map(e=>({signature:null,publicKey:e.publicKey}));let r=this._compile();this._partialSign(r,...n)}partialSign(...e){if(e.length===0)throw Error(`No signers`);let t=new Set,n=[];for(let r of e){let e=r.publicKey.toString();t.has(e)||(t.add(e),n.push(r))}let r=this._compile();this._partialSign(r,...n)}_partialSign(e,...t){let n=e.serialize();t.forEach(e=>{let t=po(n,e.secretKey);this._addSignature(e.publicKey,W(t))})}addSignature(e,t){this._compile(),this._addSignature(e,t)}_addSignature(e,t){q(t.length===64);let n=this.signatures.findIndex(t=>e.equals(t.publicKey));if(n<0)throw Error(`unknown signer: ${e.toString()}`);this.signatures[n].signature=F.Buffer.from(t)}verifySignatures(e=!0){return!this._getMessageSignednessErrors(this.serializeMessage(),e)}_getMessageSignednessErrors(e,t){let n={};for(let{signature:r,publicKey:i}of this.signatures)r===null?t&&(n.missing||=[]).push(i):mo(r,e,i.toBytes())||(n.invalid||=[]).push(i);return n.invalid||n.missing?n:void 0}serialize(e){let{requireAllSignatures:t,verifySignatures:n}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},e),r=this.serializeMessage();if(n){let e=this._getMessageSignednessErrors(r,t);if(e){let t=`Signature verification failed.`;throw e.invalid&&(t+=`\nInvalid signature for public key${e.invalid.length===1?``:`(s)`} [\`${e.invalid.map(e=>e.toBase58()).join("`, `")}\`].`),e.missing&&(t+=`\nMissing signature for public key${e.missing.length===1?``:`(s)`} [\`${e.missing.map(e=>e.toBase58()).join("`, `")}\`].`),Error(t)}}return this._serialize(r)}_serialize(e){let{signatures:t}=this,n=[];Lo(n,t.length);let r=n.length+t.length*64+e.length,i=F.Buffer.alloc(r);return q(t.length<256),F.Buffer.from(n).copy(i,0),t.forEach(({signature:e},t)=>{e!==null&&(q(e.length===64,`signature has invalid length`),F.Buffer.from(e).copy(i,n.length+t*64))}),e.copy(i,n.length+t.length*64),q(i.length<=Co,`Transaction too large: ${i.length} > ${Co}`),i}get keys(){return q(this.instructions.length===1),this.instructions[0].keys.map(e=>e.pubkey)}get programId(){return q(this.instructions.length===1),this.instructions[0].programId}get data(){return q(this.instructions.length===1),this.instructions[0].data}static from(t){let n=[...t],r=Io(n),i=[];for(let e=0;e<r;e++){let e=Vo(n,0,64);i.push(kr.default.encode(F.Buffer.from(e)))}return e.populate(Ho.from(n),i)}static populate(t,n=[]){let r=new e;return r.recentBlockhash=t.recentBlockhash,t.header.numRequiredSignatures>0&&(r.feePayer=t.accountKeys[0]),n.forEach((e,n)=>{let i={signature:e==kr.default.encode(Ko)?null:kr.default.decode(e),publicKey:t.accountKeys[n]};r.signatures.push(i)}),t.instructions.forEach(e=>{let n=e.accounts.map(e=>{let n=t.accountKeys[e];return{pubkey:n,isSigner:r.signatures.some(e=>e.publicKey.toString()===n.toString())||t.isAccountSigner(e),isWritable:t.isAccountWritable(e)}});r.instructions.push(new J({keys:n,programId:t.accountKeys[e.programIdIndex],data:kr.default.decode(e.data)}))}),r._message=t,r._json=r.toJSON(),r}},qo=class e{constructor(e){this.payerKey=void 0,this.instructions=void 0,this.recentBlockhash=void 0,this.payerKey=e.payerKey,this.instructions=e.instructions,this.recentBlockhash=e.recentBlockhash}static decompile(t,n){let{header:r,compiledInstructions:i,recentBlockhash:a}=t,{numRequiredSignatures:o,numReadonlySignedAccounts:s,numReadonlyUnsignedAccounts:c}=r,l=o-s;q(l>0,`Message header is invalid`);let u=t.staticAccountKeys.length-o-c;q(u>=0,`Message header is invalid`);let d=t.getAccountKeys(n),f=d.get(0);if(f===void 0)throw Error(`Failed to decompile message because no account keys were found`);let p=[];for(let e of i){let t=[];for(let n of e.accountKeyIndexes){let e=d.get(n);if(e===void 0)throw Error(`Failed to find key for account key index ${n}`);let i=n<o,a;a=i?n<l:n<d.staticAccountKeys.length?n-o<u:n-d.staticAccountKeys.length<d.accountKeysFromLookups.writable.length,t.push({pubkey:e,isSigner:n<r.numRequiredSignatures,isWritable:a})}let n=d.get(e.programIdIndex);if(n===void 0)throw Error(`Failed to find program id for program id index ${e.programIdIndex}`);p.push(new J({programId:n,data:W(e.data),keys:t}))}return new e({payerKey:f,instructions:p,recentBlockhash:a})}compileToLegacyMessage(){return Ho.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions})}compileToV0Message(e){return Uo.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions,addressLookupTableAccounts:e})}},Jo=class e{get version(){return this.message.version}constructor(e,t){if(this.signatures=void 0,this.message=void 0,t!==void 0)q(t.length===e.header.numRequiredSignatures,`Expected signatures length to be equal to the number of required signatures`),this.signatures=t;else{let t=[];for(let n=0;n<e.header.numRequiredSignatures;n++)t.push(new Uint8Array(64));this.signatures=t}this.message=e}serialize(){let e=this.message.serialize(),t=[];Lo(t,this.signatures.length);let n=I.struct([I.blob(t.length,`encodedSignaturesLength`),I.seq(ko(),this.signatures.length,`signatures`),I.blob(e.length,`serializedMessage`)]),r=new Uint8Array(2048),i=n.encode({encodedSignaturesLength:new Uint8Array(t),signatures:this.signatures,serializedMessage:e},r);return r.slice(0,i)}static deserialize(t){let n=[...t],r=[],i=Io(n);for(let e=0;e<i;e++)r.push(new Uint8Array(Vo(n,0,64)));return new e(Wo.deserialize(new Uint8Array(n)),r)}sign(e){let t=this.message.serialize(),n=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures);for(let r of e){let e=n.findIndex(e=>e.equals(r.publicKey));q(e>=0,`Cannot sign with non signer key ${r.publicKey.toBase58()}`),this.signatures[e]=po(t,r.secretKey)}}addSignature(e,t){q(t.byteLength===64,`Signature must be 64 bytes long`);let n=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures).findIndex(t=>t.equals(e));q(n>=0,`Can not add signature; \`${e.toBase58()}\` is not required to sign this transaction`),this.signatures[n]=t}},Yo=1e3/(160/64),Xo=new G(`SysvarC1ock11111111111111111111111111111111`),Zo=new G(`SysvarEpochSchedu1e111111111111111111111111`),Qo=new G(`Sysvar1nstructions1111111111111111111111111`),$o=new G(`SysvarRecentB1ockHashes11111111111111111111`),es=new G(`SysvarRent111111111111111111111111111111111`),ts=new G(`SysvarRewards111111111111111111111111111111`),ns=new G(`SysvarS1otHashes111111111111111111111111111`),rs=new G(`SysvarS1otHistory11111111111111111111111111`),is=new G(`SysvarStakeHistory1111111111111111111111111`),as=class extends Error{constructor({action:e,signature:t,transactionMessage:n,logs:r}){let i=r?`Logs: \n${JSON.stringify(r.slice(-10),null,2)}. `:``,a="\nCatch the `SendTransactionError` and call `getLogs()` on it for full details.",o;switch(e){case`send`:o=`Transaction ${t} resulted in an error. \n${n}. `+i+a;break;case`simulate`:o=`Simulation failed. \nMessage: ${n}. \n`+i+a;break;default:o=`Unknown action '${(e=>e)(e)}'`}super(o),this.signature=void 0,this.transactionMessage=void 0,this.transactionLogs=void 0,this.signature=t,this.transactionMessage=n,this.transactionLogs=r||void 0}get transactionError(){return{message:this.transactionMessage,logs:Array.isArray(this.transactionLogs)?this.transactionLogs:void 0}}get logs(){let e=this.transactionLogs;if(!(typeof e==`object`&&e&&`then`in e))return e}async getLogs(e){return Array.isArray(this.transactionLogs)||(this.transactionLogs=new Promise((t,n)=>{e.getTransaction(this.signature).then(e=>{if(e&&e.meta&&e.meta.logMessages){let n=e.meta.logMessages;this.transactionLogs=n,t(n)}else n(Error(`Log messages not found`))}).catch(n)})),await this.transactionLogs}},os={JSON_RPC_SERVER_ERROR_BLOCK_CLEANED_UP:-32001,JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE:-32002,JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE:-32003,JSON_RPC_SERVER_ERROR_BLOCK_NOT_AVAILABLE:-32004,JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY:-32005,JSON_RPC_SERVER_ERROR_TRANSACTION_PRECOMPILE_VERIFICATION_FAILURE:-32006,JSON_RPC_SERVER_ERROR_SLOT_SKIPPED:-32007,JSON_RPC_SERVER_ERROR_NO_SNAPSHOT:-32008,JSON_RPC_SERVER_ERROR_LONG_TERM_STORAGE_SLOT_SKIPPED:-32009,JSON_RPC_SERVER_ERROR_KEY_EXCLUDED_FROM_SECONDARY_INDEX:-32010,JSON_RPC_SERVER_ERROR_TRANSACTION_HISTORY_NOT_AVAILABLE:-32011,JSON_RPC_SCAN_ERROR:-32012,JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_LEN_MISMATCH:-32013,JSON_RPC_SERVER_ERROR_BLOCK_STATUS_NOT_AVAILABLE_YET:-32014,JSON_RPC_SERVER_ERROR_UNSUPPORTED_TRANSACTION_VERSION:-32015,JSON_RPC_SERVER_ERROR_MIN_CONTEXT_SLOT_NOT_REACHED:-32016},X=class extends Error{constructor({code:e,message:t,data:n},r){super(r==null?t:`${r}: ${t}`),this.code=void 0,this.data=void 0,this.code=e,this.data=n,this.name=`SolanaJSONRPCError`}};async function ss(e,t,n,r){let i=r&&{skipPreflight:r.skipPreflight,preflightCommitment:r.preflightCommitment||r.commitment,maxRetries:r.maxRetries,minContextSlot:r.minContextSlot},a=await e.sendTransaction(t,n,i),o;if(t.recentBlockhash!=null&&t.lastValidBlockHeight!=null)o=(await e.confirmTransaction({abortSignal:r?.abortSignal,signature:a,blockhash:t.recentBlockhash,lastValidBlockHeight:t.lastValidBlockHeight},r&&r.commitment)).value;else if(t.minNonceContextSlot!=null&&t.nonceInfo!=null){let{nonceInstruction:n}=t.nonceInfo,i=n.keys[0].pubkey;o=(await e.confirmTransaction({abortSignal:r?.abortSignal,minContextSlot:t.minNonceContextSlot,nonceAccountPubkey:i,nonceValue:t.nonceInfo.nonce,signature:a},r&&r.commitment)).value}else r?.abortSignal!=null&&console.warn("sendAndConfirmTransaction(): A transaction with a deprecated confirmation strategy was supplied along with an `abortSignal`. Only transactions having `lastValidBlockHeight` or a combination of `nonceInfo` and `minNonceContextSlot` are abortable."),o=(await e.confirmTransaction(a,r&&r.commitment)).value;if(o.err)throw a==null?Error(`Transaction ${a} failed (${JSON.stringify(o)})`):new as({action:`send`,signature:a,transactionMessage:`Status: (${JSON.stringify(o)})`});return a}function cs(e){return new Promise(t=>setTimeout(t,e))}function Z(e,t){let n=e.layout.span>=0?e.layout.span:Fo(e,t),r=F.Buffer.alloc(n),i=Object.assign({instruction:e.index},t);return e.layout.encode(i,r),r}function Q(e,t){let n;try{n=e.layout.decode(t)}catch(e){throw Error(`invalid instruction; `+e)}if(n.instruction!==e.index)throw Error(`invalid instruction; instruction index mismatch ${n.instruction} != ${e.index}`);return n}var ls=I.nu64(`lamportsPerSignature`),us=I.struct([I.u32(`version`),I.u32(`state`),K(`authorizedPubkey`),K(`nonce`),I.struct([ls],`feeCalculator`)]),ds=us.span,fs=class e{constructor(e){this.authorizedPubkey=void 0,this.nonce=void 0,this.feeCalculator=void 0,this.authorizedPubkey=e.authorizedPubkey,this.nonce=e.nonce,this.feeCalculator=e.feeCalculator}static fromAccountData(t){let n=us.decode(W(t),0);return new e({authorizedPubkey:new G(n.authorizedPubkey),nonce:new G(n.nonce).toString(),feeCalculator:n.feeCalculator})}};function ps(e){let t=(0,I.blob)(8,e),n=t.decode.bind(t),r=t.encode.bind(t),i=t,a=ni();return i.decode=(e,t)=>{let r=n(e,t);return a.decode(r)},i.encode=(e,t,n)=>r(a.encode(e),t,n),i}var ms=class{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);let t=I.u32(`instruction`).decode(e.data),n;for(let[e,r]of Object.entries(hs))if(r.index==t){n=e;break}if(!n)throw Error(`Instruction type incorrect; not a SystemInstruction`);return n}static decodeCreateAccount(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);let{lamports:t,space:n,programId:r}=Q(hs.Create,e.data);return{fromPubkey:e.keys[0].pubkey,newAccountPubkey:e.keys[1].pubkey,lamports:t,space:n,programId:new G(r)}}static decodeTransfer(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);let{lamports:t}=Q(hs.Transfer,e.data);return{fromPubkey:e.keys[0].pubkey,toPubkey:e.keys[1].pubkey,lamports:t}}static decodeTransferWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);let{lamports:t,seed:n,programId:r}=Q(hs.TransferWithSeed,e.data);return{fromPubkey:e.keys[0].pubkey,basePubkey:e.keys[1].pubkey,toPubkey:e.keys[2].pubkey,lamports:t,seed:n,programId:new G(r)}}static decodeAllocate(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);let{space:t}=Q(hs.Allocate,e.data);return{accountPubkey:e.keys[0].pubkey,space:t}}static decodeAllocateWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);let{base:t,seed:n,space:r,programId:i}=Q(hs.AllocateWithSeed,e.data);return{accountPubkey:e.keys[0].pubkey,basePubkey:new G(t),seed:n,space:r,programId:new G(i)}}static decodeAssign(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);let{programId:t}=Q(hs.Assign,e.data);return{accountPubkey:e.keys[0].pubkey,programId:new G(t)}}static decodeAssignWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);let{base:t,seed:n,programId:r}=Q(hs.AssignWithSeed,e.data);return{accountPubkey:e.keys[0].pubkey,basePubkey:new G(t),seed:n,programId:new G(r)}}static decodeCreateWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);let{base:t,seed:n,lamports:r,space:i,programId:a}=Q(hs.CreateWithSeed,e.data);return{fromPubkey:e.keys[0].pubkey,newAccountPubkey:e.keys[1].pubkey,basePubkey:new G(t),seed:n,lamports:r,space:i,programId:new G(a)}}static decodeNonceInitialize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);let{authorized:t}=Q(hs.InitializeNonceAccount,e.data);return{noncePubkey:e.keys[0].pubkey,authorizedPubkey:new G(t)}}static decodeNonceAdvance(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3),Q(hs.AdvanceNonceAccount,e.data),{noncePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey}}static decodeNonceWithdraw(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,5);let{lamports:t}=Q(hs.WithdrawNonceAccount,e.data);return{noncePubkey:e.keys[0].pubkey,toPubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[4].pubkey,lamports:t}}static decodeNonceAuthorize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);let{authorized:t}=Q(hs.AuthorizeNonceAccount,e.data);return{noncePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[1].pubkey,newAuthorizedPubkey:new G(t)}}static checkProgramId(e){if(!e.equals(gs.programId))throw Error(`invalid instruction; programId is not SystemProgram`)}static checkKeyLength(e,t){if(e.length<t)throw Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}},hs=Object.freeze({Create:{index:0,layout:I.struct([I.u32(`instruction`),I.ns64(`lamports`),I.ns64(`space`),K(`programId`)])},Assign:{index:1,layout:I.struct([I.u32(`instruction`),K(`programId`)])},Transfer:{index:2,layout:I.struct([I.u32(`instruction`),ps(`lamports`)])},CreateWithSeed:{index:3,layout:I.struct([I.u32(`instruction`),K(`base`),Ao(`seed`),I.ns64(`lamports`),I.ns64(`space`),K(`programId`)])},AdvanceNonceAccount:{index:4,layout:I.struct([I.u32(`instruction`)])},WithdrawNonceAccount:{index:5,layout:I.struct([I.u32(`instruction`),I.ns64(`lamports`)])},InitializeNonceAccount:{index:6,layout:I.struct([I.u32(`instruction`),K(`authorized`)])},AuthorizeNonceAccount:{index:7,layout:I.struct([I.u32(`instruction`),K(`authorized`)])},Allocate:{index:8,layout:I.struct([I.u32(`instruction`),I.ns64(`space`)])},AllocateWithSeed:{index:9,layout:I.struct([I.u32(`instruction`),K(`base`),Ao(`seed`),I.ns64(`space`),K(`programId`)])},AssignWithSeed:{index:10,layout:I.struct([I.u32(`instruction`),K(`base`),Ao(`seed`),K(`programId`)])},TransferWithSeed:{index:11,layout:I.struct([I.u32(`instruction`),ps(`lamports`),Ao(`seed`),K(`programId`)])},UpgradeNonceAccount:{index:12,layout:I.struct([I.u32(`instruction`)])}}),gs=class e{constructor(){}static createAccount(e){let t=hs.Create,n=Z(t,{lamports:e.lamports,space:e.space,programId:W(e.programId.toBuffer())});return new J({keys:[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.newAccountPubkey,isSigner:!0,isWritable:!0}],programId:this.programId,data:n})}static transfer(e){let t,n;if(`basePubkey`in e){let r=hs.TransferWithSeed;t=Z(r,{lamports:BigInt(e.lamports),seed:e.seed,programId:W(e.programId.toBuffer())}),n=[{pubkey:e.fromPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0}]}else{let r=hs.Transfer;t=Z(r,{lamports:BigInt(e.lamports)}),n=[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0}]}return new J({keys:n,programId:this.programId,data:t})}static assign(e){let t,n;if(`basePubkey`in e){let r=hs.AssignWithSeed;t=Z(r,{base:W(e.basePubkey.toBuffer()),seed:e.seed,programId:W(e.programId.toBuffer())}),n=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]}else{let r=hs.Assign;t=Z(r,{programId:W(e.programId.toBuffer())}),n=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]}return new J({keys:n,programId:this.programId,data:t})}static createAccountWithSeed(e){let t=hs.CreateWithSeed,n=Z(t,{base:W(e.basePubkey.toBuffer()),seed:e.seed,lamports:e.lamports,space:e.space,programId:W(e.programId.toBuffer())}),r=[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.newAccountPubkey,isSigner:!1,isWritable:!0}];return e.basePubkey.equals(e.fromPubkey)||r.push({pubkey:e.basePubkey,isSigner:!0,isWritable:!1}),new J({keys:r,programId:this.programId,data:n})}static createNonceAccount(t){let n=new Y;`basePubkey`in t&&`seed`in t?n.add(e.createAccountWithSeed({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,basePubkey:t.basePubkey,seed:t.seed,lamports:t.lamports,space:ds,programId:this.programId})):n.add(e.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,lamports:t.lamports,space:ds,programId:this.programId}));let r={noncePubkey:t.noncePubkey,authorizedPubkey:t.authorizedPubkey};return n.add(this.nonceInitialize(r)),n}static nonceInitialize(e){let t=hs.InitializeNonceAccount,n=Z(t,{authorized:W(e.authorizedPubkey.toBuffer())});return new J({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:$o,isSigner:!1,isWritable:!1},{pubkey:es,isSigner:!1,isWritable:!1}],programId:this.programId,data:n})}static nonceAdvance(e){let t=hs.AdvanceNonceAccount,n=Z(t);return new J({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:$o,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static nonceWithdraw(e){let t=hs.WithdrawNonceAccount,n=Z(t,{lamports:e.lamports});return new J({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0},{pubkey:$o,isSigner:!1,isWritable:!1},{pubkey:es,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static nonceAuthorize(e){let t=hs.AuthorizeNonceAccount,n=Z(t,{authorized:W(e.newAuthorizedPubkey.toBuffer())});return new J({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static allocate(e){let t,n;if(`basePubkey`in e){let r=hs.AllocateWithSeed;t=Z(r,{base:W(e.basePubkey.toBuffer()),seed:e.seed,space:e.space,programId:W(e.programId.toBuffer())}),n=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]}else{let r=hs.Allocate;t=Z(r,{space:e.space}),n=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]}return new J({keys:n,programId:this.programId,data:t})}};gs.programId=new G(`11111111111111111111111111111111`);var _s=Co-300,vs=class e{constructor(){}static getMinNumSignatures(t){return 2*(Math.ceil(t/e.chunkSize)+1+1)}static async load(t,n,r,i,a){{let e=await t.getMinimumBalanceForRentExemption(a.length),o=await t.getAccountInfo(r.publicKey,`confirmed`),s=null;if(o!==null){if(o.executable)return console.error(`Program load failed, account is already executable`),!1;o.data.length!==a.length&&(s||=new Y,s.add(gs.allocate({accountPubkey:r.publicKey,space:a.length}))),o.owner.equals(i)||(s||=new Y,s.add(gs.assign({accountPubkey:r.publicKey,programId:i}))),o.lamports<e&&(s||=new Y,s.add(gs.transfer({fromPubkey:n.publicKey,toPubkey:r.publicKey,lamports:e-o.lamports})))}else s=new Y().add(gs.createAccount({fromPubkey:n.publicKey,newAccountPubkey:r.publicKey,lamports:e>0?e:1,space:a.length,programId:i}));s!==null&&await ss(t,s,[n,r],{commitment:`confirmed`})}let o=I.struct([I.u32(`instruction`),I.u32(`offset`),I.u32(`bytesLength`),I.u32(`bytesLengthPadding`),I.seq(I.u8(`byte`),I.offset(I.u32(),-8),`bytes`)]),s=e.chunkSize,c=0,l=a,u=[];for(;l.length>0;){let e=l.slice(0,s),a=F.Buffer.alloc(s+16);o.encode({instruction:0,offset:c,bytes:e,bytesLength:0,bytesLengthPadding:0},a);let d=new Y().add({keys:[{pubkey:r.publicKey,isSigner:!0,isWritable:!0}],programId:i,data:a});u.push(ss(t,d,[n,r],{commitment:`confirmed`})),t._rpcEndpoint.includes(`solana.com`)&&await cs(1e3/4),c+=s,l=l.slice(s)}await Promise.all(u);{let e=I.struct([I.u32(`instruction`)]),a=F.Buffer.alloc(e.span);e.encode({instruction:1},a);let o=new Y().add({keys:[{pubkey:r.publicKey,isSigner:!0,isWritable:!0},{pubkey:es,isSigner:!1,isWritable:!1}],programId:i,data:a}),s=`processed`,c=await t.sendTransaction(o,[n,r],{preflightCommitment:s}),{context:l,value:u}=await t.confirmTransaction({signature:c,lastValidBlockHeight:o.lastValidBlockHeight,blockhash:o.recentBlockhash},s);if(u.err)throw Error(`Transaction ${c} failed (${JSON.stringify(u)})`);for(;;){try{if(await t.getSlot({commitment:s})>l.slot)break}catch{}await new Promise(e=>setTimeout(e,Math.round(Yo/2)))}}return!0}};vs.chunkSize=_s;var ys=new G(`BPFLoader2111111111111111111111111111111111`),bs=class{static getMinNumSignatures(e){return vs.getMinNumSignatures(e)}static load(e,t,n,r,i){return vs.load(e,t,n,i,r)}};function xs(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}var Ss,Cs;function ws(){if(Cs)return Ss;Cs=1;var e=Object.prototype.toString,t=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};function n(r,i){var a,o,s,c,l,u,d;if(r===!0)return`true`;if(r===!1)return`false`;switch(typeof r){case`object`:if(r===null)return null;if(r.toJSON&&typeof r.toJSON==`function`)return n(r.toJSON(),i);if(d=e.call(r),d===`[object Array]`){for(s=`[`,o=r.length-1,a=0;a<o;a++)s+=n(r[a],!0)+`,`;return o>-1&&(s+=n(r[a],!0)),s+`]`}else if(d===`[object Object]`){for(c=t(r).sort(),o=c.length,s=``,a=0;a<o;)l=c[a],u=n(r[l],!1),u!==void 0&&(s&&(s+=`,`),s+=JSON.stringify(l)+`:`+u),a++;return`{`+s+`}`}else return JSON.stringify(r);case`function`:case`undefined`:return i?null:void 0;case`string`:return JSON.stringify(r);default:return isFinite(r)?r:null}}return Ss=function(e){var t=n(e,!1);if(t!==void 0)return``+t},Ss}var Ts=xs(ws()),Es=32;function Ds(e){let t=0;for(;e>1;)e/=2,t++;return t}function Os(e){return e===0?1:(e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,e|=e>>32,e+1)}var ks=class{constructor(e,t,n,r,i){this.slotsPerEpoch=void 0,this.leaderScheduleSlotOffset=void 0,this.warmup=void 0,this.firstNormalEpoch=void 0,this.firstNormalSlot=void 0,this.slotsPerEpoch=e,this.leaderScheduleSlotOffset=t,this.warmup=n,this.firstNormalEpoch=r,this.firstNormalSlot=i}getEpoch(e){return this.getEpochAndSlotIndex(e)[0]}getEpochAndSlotIndex(e){if(e<this.firstNormalSlot){let t=Ds(Os(e+Es+1))-Ds(Es)-1;return[t,e-(this.getSlotsInEpoch(t)-Es)]}else{let t=e-this.firstNormalSlot,n=Math.floor(t/this.slotsPerEpoch);return[this.firstNormalEpoch+n,t%this.slotsPerEpoch]}}getFirstSlotInEpoch(e){return e<=this.firstNormalEpoch?(2**e-1)*Es:(e-this.firstNormalEpoch)*this.slotsPerEpoch+this.firstNormalSlot}getLastSlotInEpoch(e){return this.getFirstSlotInEpoch(e)+this.getSlotsInEpoch(e)-1}getSlotsInEpoch(e){return e<this.firstNormalEpoch?2**(e+Ds(Es)):this.slotsPerEpoch}},As=globalThis.fetch,js=class extends Na{constructor(e,t,n){super(e=>{let n=ja(e,{autoconnect:!0,max_reconnects:5,reconnect:!0,reconnect_interval:1e3,...t});return`socket`in n?this.underlyingSocket=n.socket:this.underlyingSocket=n,n},e,t,n),this.underlyingSocket=void 0}call(...e){let t=this.underlyingSocket?.readyState;return t===1?super.call(...e):Promise.reject(Error("Tried to call a JSON-RPC method `"+e[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+t+`)`))}notify(...e){let t=this.underlyingSocket?.readyState;return t===1?super.notify(...e):Promise.reject(Error("Tried to send a JSON-RPC notification `"+e[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+t+`)`))}};function Ms(e,t){let n;try{n=e.layout.decode(t)}catch(e){throw Error(`invalid instruction; `+e)}if(n.typeIndex!==e.index)throw Error(`invalid account data; account type mismatch ${n.typeIndex} != ${e.index}`);return n}var Ns=56,Ps=class{constructor(e){this.key=void 0,this.state=void 0,this.key=e.key,this.state=e.state}isActive(){let e=BigInt(`0xffffffffffffffff`);return this.state.deactivationSlot===e}static deserialize(e){let t=Ms(Fs,e),n=e.length-Ns;q(n>=0,`lookup table is invalid`),q(n%32==0,`lookup table is invalid`);let r=n/32,{addresses:i}=I.struct([I.seq(K(),r,`addresses`)]).decode(e.slice(Ns));return{deactivationSlot:t.deactivationSlot,lastExtendedSlot:t.lastExtendedSlot,lastExtendedSlotStartIndex:t.lastExtendedStartIndex,authority:t.authority.length===0?void 0:new G(t.authority[0]),addresses:i.map(e=>new G(e))}}},Fs={index:1,layout:I.struct([I.u32(`typeIndex`),ps(`deactivationSlot`),I.nu64(`lastExtendedSlot`),I.u8(`lastExtendedStartIndex`),I.u8(),I.seq(K(),I.offset(I.u8(),-1),`authority`)])},Is=/^[^:]+:\/\/([^:[]+|\[[^\]]+\])(:\d+)?(.*)/i;function Ls(e){let t=e.match(Is);if(t==null)throw TypeError(`Failed to validate endpoint URL \`${e}\``);let[n,r,i,a]=t,o=e.startsWith(`https:`)?`wss:`:`ws:`,s=i==null?null:parseInt(i.slice(1),10);return`${o}//${r}${s==null?``:`:${s+1}`}${a}`}var Rs=Di(bi(G),H(),e=>new G(e)),zs=wi([H(),xi(`base64`)]),Bs=Di(bi(F.Buffer),zs,e=>F.Buffer.from(e[0],`base64`)),Vs=30*1e3;function Hs(e){if(/^https?:/.test(e)===!1)throw TypeError("Endpoint URL must start with `http:` or `https:`.");return e}function Us(e){let t,n;if(typeof e==`string`)t=e;else if(e){let{commitment:r,...i}=e;t=r,n=i}return{commitment:t,config:n}}function Ws(e){return e.map(e=>`memcmp`in e?{...e,memcmp:{...e.memcmp,encoding:e.memcmp.encoding??`base58`}}:e)}function Gs(e){return Ti([U({jsonrpc:xi(`2.0`),id:H(),result:e}),U({jsonrpc:xi(`2.0`),id:H(),error:U({code:Ei(),message:H(),data:V(vi())})})])}var Ks=Gs(Ei());function $(e){return Di(Gs(e),Ks,t=>`error`in t?t:{...t,result:L(t.result,e)})}function qs(e){return $(U({context:U({slot:B()}),value:e}))}function Js(e){return U({context:U({slot:B()}),value:e})}function Ys(e,t){return e===0?new Uo({header:t.header,staticAccountKeys:t.accountKeys.map(e=>new G(e)),recentBlockhash:t.recentBlockhash,compiledInstructions:t.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:kr.default.decode(e.data)})),addressTableLookups:t.addressTableLookups}):new Ho(t)}var Xs=U({foundation:B(),foundationTerm:B(),initial:B(),taper:B(),terminal:B()}),Zs=$(R(z(U({epoch:B(),effectiveSlot:B(),amount:B(),postBalance:B(),commission:V(z(B()))})))),Qs=R(U({slot:B(),prioritizationFee:B()})),$s=U({total:B(),validator:B(),foundation:B(),epoch:B()}),ec=U({epoch:B(),slotIndex:B(),slotsInEpoch:B(),absoluteSlot:B(),blockHeight:V(B()),transactionCount:V(B())}),tc=U({slotsPerEpoch:B(),leaderScheduleSlotOffset:B(),warmup:yi(),firstNormalEpoch:B(),firstNormalSlot:B()}),nc=Ci(H(),R(B())),rc=z(Ti([U({}),H()])),ic=U({err:rc}),ac=xi(`receivedSignature`),oc=U({"solana-core":H(),"feature-set":V(B())}),sc=U({program:H(),programId:Rs,parsed:Ei()}),cc=U({programId:Rs,accounts:R(Rs),data:H()}),lc=qs(U({err:z(Ti([U({}),H()])),logs:z(R(H())),accounts:V(z(R(z(U({executable:yi(),owner:H(),lamports:B(),data:R(H()),rentEpoch:V(B())}))))),unitsConsumed:V(B()),returnData:V(z(U({programId:H(),data:wi([H(),xi(`base64`)])}))),innerInstructions:V(z(R(U({index:B(),instructions:R(Ti([sc,cc]))}))))})),uc=qs(U({byIdentity:Ci(H(),R(B())),range:U({firstSlot:B(),lastSlot:B()})}));function dc(e,t,n,r,i,a){let o=n||As;a!=null&&console.warn("You have supplied an `httpAgent` when creating a `Connection` in a browser environment.It has been ignored; `httpAgent` is only used in Node environments.");let s;return r&&(s=async(e,t)=>await o(...await new Promise((n,i)=>{try{r(e,t,(e,t)=>n([e,t]))}catch(e){i(e)}}))),new ka.default(async(n,r)=>{let a={method:`POST`,body:n,agent:void 0,headers:Object.assign({"Content-Type":`application/json`},t||{},Ol)};try{let t=5,n,c=500;for(;n=s?await s(e,a):await o(e,a),!(n.status!==429||i===!0||(--t,t===0));)console.error(`Server responded with ${n.status} ${n.statusText}. Retrying after ${c}ms delay...`),await cs(c),c*=2;let l=await n.text();n.ok?r(null,l):r(Error(`${n.status} ${n.statusText}: ${l}`))}catch(e){e instanceof Error&&r(e)}},{})}function fc(e){return(t,n)=>new Promise((r,i)=>{e.request(t,n,(e,t)=>{if(e){i(e);return}r(t)})})}function pc(e){return t=>new Promise((n,r)=>{t.length===0&&n([]);let i=t.map(t=>e.request(t.methodName,t.args));e.request(i,(e,t)=>{if(e){r(e);return}n(t)})})}var mc=$(Xs),hc=$($s),gc=$(Qs),_c=$(ec),vc=$(tc),yc=$(nc),bc=$(B()),xc=qs(U({total:B(),circulating:B(),nonCirculating:B(),nonCirculatingAccounts:R(Rs)})),Sc=U({amount:H(),uiAmount:z(B()),decimals:B(),uiAmountString:V(H())}),Cc=qs(R(U({address:Rs,amount:H(),uiAmount:z(B()),decimals:B(),uiAmountString:V(H())}))),wc=qs(R(U({pubkey:Rs,account:U({executable:yi(),owner:Rs,lamports:B(),data:Bs,rentEpoch:B()})}))),Tc=U({program:H(),parsed:Ei(),space:B()}),Ec=qs(R(U({pubkey:Rs,account:U({executable:yi(),owner:Rs,lamports:B(),data:Tc,rentEpoch:B()})}))),Dc=qs(R(U({lamports:B(),address:Rs}))),Oc=U({executable:yi(),owner:Rs,lamports:B(),data:Bs,rentEpoch:B()}),kc=U({pubkey:Rs,account:Oc}),Ac=Di(Ti([bi(F.Buffer),Tc]),Ti([zs,Tc]),e=>Array.isArray(e)?L(e,Bs):e),jc=U({executable:yi(),owner:Rs,lamports:B(),data:Ac,rentEpoch:B()}),Mc=U({pubkey:Rs,account:jc}),Nc=U({state:Ti([xi(`active`),xi(`inactive`),xi(`activating`),xi(`deactivating`)]),active:B(),inactive:B()}),Pc=$(R(U({signature:H(),slot:B(),err:rc,memo:z(H()),blockTime:V(z(B()))}))),Fc=$(R(U({signature:H(),slot:B(),err:rc,memo:z(H()),blockTime:V(z(B()))}))),Ic=U({subscription:B(),result:Js(Oc)}),Lc=U({pubkey:Rs,account:Oc}),Rc=U({subscription:B(),result:Js(Lc)}),zc=U({parent:B(),slot:B(),root:B()}),Bc=U({subscription:B(),result:zc}),Vc=Ti([U({type:Ti([xi(`firstShredReceived`),xi(`completed`),xi(`optimisticConfirmation`),xi(`root`)]),slot:B(),timestamp:B()}),U({type:xi(`createdBank`),parent:B(),slot:B(),timestamp:B()}),U({type:xi(`frozen`),slot:B(),timestamp:B(),stats:U({numTransactionEntries:B(),numSuccessfulTransactions:B(),numFailedTransactions:B(),maxTransactionsPerEntry:B()})}),U({type:xi(`dead`),slot:B(),timestamp:B(),err:H()})]),Hc=U({subscription:B(),result:Vc}),Uc=U({subscription:B(),result:Js(Ti([ic,ac]))}),Wc=U({subscription:B(),result:B()}),Gc=U({pubkey:H(),gossip:z(H()),tpu:z(H()),rpc:z(H()),version:z(H())}),Kc=U({votePubkey:H(),nodePubkey:H(),activatedStake:B(),epochVoteAccount:yi(),epochCredits:R(wi([B(),B(),B()])),commission:B(),lastVote:B(),rootSlot:z(B())}),qc=$(U({current:R(Kc),delinquent:R(Kc)})),Jc=Ti([xi(`processed`),xi(`confirmed`),xi(`finalized`)]),Yc=qs(R(z(U({slot:B(),confirmations:z(B()),err:rc,confirmationStatus:V(Jc)})))),Xc=$(B()),Zc=U({accountKey:Rs,writableIndexes:R(B()),readonlyIndexes:R(B())}),Qc=U({signatures:R(H()),message:U({accountKeys:R(H()),header:U({numRequiredSignatures:B(),numReadonlySignedAccounts:B(),numReadonlyUnsignedAccounts:B()}),instructions:R(U({accounts:R(B()),data:H(),programIdIndex:B()})),recentBlockhash:H(),addressTableLookups:V(R(Zc))})}),$c=U({pubkey:Rs,signer:yi(),writable:yi(),source:V(Ti([xi(`transaction`),xi(`lookupTable`)]))}),el=U({accountKeys:R($c),signatures:R(H())}),tl=U({parsed:Ei(),program:H(),programId:Rs}),nl=U({accounts:R(Rs),data:H(),programId:Rs}),rl=Di(Ti([nl,tl]),Ti([U({parsed:Ei(),program:H(),programId:H()}),U({accounts:R(H()),data:H(),programId:H()})]),e=>`accounts`in e?L(e,nl):L(e,tl)),il=U({signatures:R(H()),message:U({accountKeys:R($c),instructions:R(rl),recentBlockhash:H(),addressTableLookups:V(z(R(Zc)))})}),al=U({accountIndex:B(),mint:H(),owner:V(H()),programId:V(H()),uiTokenAmount:Sc}),ol=U({writable:R(Rs),readonly:R(Rs)}),sl=U({err:rc,fee:B(),innerInstructions:V(z(R(U({index:B(),instructions:R(U({accounts:R(B()),data:H(),programIdIndex:B()}))})))),preBalances:R(B()),postBalances:R(B()),logMessages:V(z(R(H()))),preTokenBalances:V(z(R(al))),postTokenBalances:V(z(R(al))),loadedAddresses:V(ol),computeUnitsConsumed:V(B()),costUnits:V(B())}),cl=U({err:rc,fee:B(),innerInstructions:V(z(R(U({index:B(),instructions:R(rl)})))),preBalances:R(B()),postBalances:R(B()),logMessages:V(z(R(H()))),preTokenBalances:V(z(R(al))),postTokenBalances:V(z(R(al))),loadedAddresses:V(ol),computeUnitsConsumed:V(B()),costUnits:V(B())}),ll=Ti([xi(0),xi(`legacy`)]),ul=U({pubkey:H(),lamports:B(),postBalance:z(B()),rewardType:z(H()),commission:V(z(B()))}),dl=$(z(U({blockhash:H(),previousBlockhash:H(),parentSlot:B(),transactions:R(U({transaction:Qc,meta:z(sl),version:V(ll)})),rewards:V(R(ul)),blockTime:z(B()),blockHeight:z(B())}))),fl=$(z(U({blockhash:H(),previousBlockhash:H(),parentSlot:B(),rewards:V(R(ul)),blockTime:z(B()),blockHeight:z(B())}))),pl=$(z(U({blockhash:H(),previousBlockhash:H(),parentSlot:B(),transactions:R(U({transaction:el,meta:z(sl),version:V(ll)})),rewards:V(R(ul)),blockTime:z(B()),blockHeight:z(B())}))),ml=$(z(U({blockhash:H(),previousBlockhash:H(),parentSlot:B(),transactions:R(U({transaction:il,meta:z(cl),version:V(ll)})),rewards:V(R(ul)),blockTime:z(B()),blockHeight:z(B())}))),hl=$(z(U({blockhash:H(),previousBlockhash:H(),parentSlot:B(),transactions:R(U({transaction:el,meta:z(cl),version:V(ll)})),rewards:V(R(ul)),blockTime:z(B()),blockHeight:z(B())}))),gl=$(z(U({blockhash:H(),previousBlockhash:H(),parentSlot:B(),rewards:V(R(ul)),blockTime:z(B()),blockHeight:z(B())}))),_l=$(z(U({blockhash:H(),previousBlockhash:H(),parentSlot:B(),transactions:R(U({transaction:Qc,meta:z(sl)})),rewards:V(R(ul)),blockTime:z(B())}))),vl=$(z(U({blockhash:H(),previousBlockhash:H(),parentSlot:B(),signatures:R(H()),blockTime:z(B())}))),yl=$(z(U({slot:B(),meta:z(sl),blockTime:V(z(B())),transaction:Qc,version:V(ll)}))),bl=$(z(U({slot:B(),transaction:il,meta:z(cl),blockTime:V(z(B())),version:V(ll)}))),xl=qs(U({blockhash:H(),lastValidBlockHeight:B()})),Sl=qs(yi()),Cl=$(R(U({slot:B(),numTransactions:B(),numSlots:B(),samplePeriodSecs:B()}))),wl=qs(z(U({feeCalculator:U({lamportsPerSignature:B()})}))),Tl=$(H()),El=$(H()),Dl=U({result:Js(U({err:rc,logs:R(H()),signature:H()})),subscription:B()}),Ol={"solana-client":`js/1.0.0-maintenance`},kl=class{constructor(e,t){this._commitment=void 0,this._confirmTransactionInitialTimeout=void 0,this._rpcEndpoint=void 0,this._rpcWsEndpoint=void 0,this._rpcClient=void 0,this._rpcRequest=void 0,this._rpcBatchRequest=void 0,this._rpcWebSocket=void 0,this._rpcWebSocketConnected=!1,this._rpcWebSocketHeartbeat=null,this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketGeneration=0,this._disableBlockhashCaching=!1,this._pollingBlockhash=!1,this._blockhashInfo={latestBlockhash:null,lastFetch:0,transactionSignatures:[],simulatedSignatures:[]},this._nextClientSubscriptionId=0,this._subscriptionDisposeFunctionsByClientSubscriptionId={},this._subscriptionHashByClientSubscriptionId={},this._subscriptionStateChangeCallbacksByHash={},this._subscriptionCallbacksByServerSubscriptionId={},this._subscriptionsByHash={},this._subscriptionsAutoDisposedByRpc=new Set,this.getBlockHeight=(()=>{let e={};return async t=>{let{commitment:n,config:r}=Us(t),i=this._buildArgs([],n,void 0,r),a=Ts(i);return e[a]=e[a]??(async()=>{try{let e=L(await this._rpcRequest(`getBlockHeight`,i),$(B()));if(`error`in e)throw new X(e.error,`failed to get block height information`);return e.result}finally{delete e[a]}})(),await e[a]}})();let n,r,i,a,o,s;t&&typeof t==`string`?this._commitment=t:t&&(this._commitment=t.commitment,this._confirmTransactionInitialTimeout=t.confirmTransactionInitialTimeout,n=t.wsEndpoint,r=t.httpHeaders,i=t.fetch,a=t.fetchMiddleware,o=t.disableRetryOnRateLimit,s=t.httpAgent),this._rpcEndpoint=Hs(e),this._rpcWsEndpoint=n||Ls(e),this._rpcClient=dc(e,r,i,a,o,s),this._rpcRequest=fc(this._rpcClient),this._rpcBatchRequest=pc(this._rpcClient),this._rpcWebSocket=new js(this._rpcWsEndpoint,{autoconnect:!1,max_reconnects:1/0}),this._rpcWebSocket.on(`open`,this._wsOnOpen.bind(this)),this._rpcWebSocket.on(`error`,this._wsOnError.bind(this)),this._rpcWebSocket.on(`close`,this._wsOnClose.bind(this)),this._rpcWebSocket.on(`accountNotification`,this._wsOnAccountNotification.bind(this)),this._rpcWebSocket.on(`programNotification`,this._wsOnProgramAccountNotification.bind(this)),this._rpcWebSocket.on(`slotNotification`,this._wsOnSlotNotification.bind(this)),this._rpcWebSocket.on(`slotsUpdatesNotification`,this._wsOnSlotUpdatesNotification.bind(this)),this._rpcWebSocket.on(`signatureNotification`,this._wsOnSignatureNotification.bind(this)),this._rpcWebSocket.on(`rootNotification`,this._wsOnRootNotification.bind(this)),this._rpcWebSocket.on(`logsNotification`,this._wsOnLogsNotification.bind(this))}get commitment(){return this._commitment}get rpcEndpoint(){return this._rpcEndpoint}async getBalanceAndContext(e,t){let{commitment:n,config:r}=Us(t),i=this._buildArgs([e.toBase58()],n,void 0,r),a=L(await this._rpcRequest(`getBalance`,i),qs(B()));if(`error`in a)throw new X(a.error,`failed to get balance for ${e.toBase58()}`);return a.result}async getBalance(e,t){return await this.getBalanceAndContext(e,t).then(e=>e.value).catch(t=>{throw Error(`failed to get balance of account `+e.toBase58()+`: `+t)})}async getBlockTime(e){let t=L(await this._rpcRequest(`getBlockTime`,[e]),$(z(B())));if(`error`in t)throw new X(t.error,`failed to get block time for slot ${e}`);return t.result}async getMinimumLedgerSlot(){let e=L(await this._rpcRequest(`minimumLedgerSlot`,[]),$(B()));if(`error`in e)throw new X(e.error,`failed to get minimum ledger slot`);return e.result}async getFirstAvailableBlock(){let e=L(await this._rpcRequest(`getFirstAvailableBlock`,[]),bc);if(`error`in e)throw new X(e.error,`failed to get first available block`);return e.result}async getSupply(e){let t={};t=typeof e==`string`?{commitment:e}:e?{...e,commitment:e&&e.commitment||this.commitment}:{commitment:this.commitment};let n=L(await this._rpcRequest(`getSupply`,[t]),xc);if(`error`in n)throw new X(n.error,`failed to get supply`);return n.result}async getTokenSupply(e,t){let n=this._buildArgs([e.toBase58()],t),r=L(await this._rpcRequest(`getTokenSupply`,n),qs(Sc));if(`error`in r)throw new X(r.error,`failed to get token supply`);return r.result}async getTokenAccountBalance(e,t){let n=this._buildArgs([e.toBase58()],t),r=L(await this._rpcRequest(`getTokenAccountBalance`,n),qs(Sc));if(`error`in r)throw new X(r.error,`failed to get token account balance`);return r.result}async getTokenAccountsByOwner(e,t,n){let{commitment:r,config:i}=Us(n),a=[e.toBase58()];`mint`in t?a.push({mint:t.mint.toBase58()}):a.push({programId:t.programId.toBase58()});let o=this._buildArgs(a,r,`base64`,i),s=L(await this._rpcRequest(`getTokenAccountsByOwner`,o),wc);if(`error`in s)throw new X(s.error,`failed to get token accounts owned by account ${e.toBase58()}`);return s.result}async getParsedTokenAccountsByOwner(e,t,n){let r=[e.toBase58()];`mint`in t?r.push({mint:t.mint.toBase58()}):r.push({programId:t.programId.toBase58()});let i=this._buildArgs(r,n,`jsonParsed`),a=L(await this._rpcRequest(`getTokenAccountsByOwner`,i),Ec);if(`error`in a)throw new X(a.error,`failed to get token accounts owned by account ${e.toBase58()}`);return a.result}async getLargestAccounts(e){let t={...e,commitment:e&&e.commitment||this.commitment},n=t.filter||t.commitment?[t]:[],r=L(await this._rpcRequest(`getLargestAccounts`,n),Dc);if(`error`in r)throw new X(r.error,`failed to get largest accounts`);return r.result}async getTokenLargestAccounts(e,t){let n=this._buildArgs([e.toBase58()],t),r=L(await this._rpcRequest(`getTokenLargestAccounts`,n),Cc);if(`error`in r)throw new X(r.error,`failed to get token largest accounts`);return r.result}async getAccountInfoAndContext(e,t){let{commitment:n,config:r}=Us(t),i=this._buildArgs([e.toBase58()],n,`base64`,r),a=L(await this._rpcRequest(`getAccountInfo`,i),qs(z(Oc)));if(`error`in a)throw new X(a.error,`failed to get info about account ${e.toBase58()}`);return a.result}async getParsedAccountInfo(e,t){let{commitment:n,config:r}=Us(t),i=this._buildArgs([e.toBase58()],n,`jsonParsed`,r),a=L(await this._rpcRequest(`getAccountInfo`,i),qs(z(jc)));if(`error`in a)throw new X(a.error,`failed to get info about account ${e.toBase58()}`);return a.result}async getAccountInfo(e,t){try{return(await this.getAccountInfoAndContext(e,t)).value}catch(t){throw Error(`failed to get info about account `+e.toBase58()+`: `+t)}}async getMultipleParsedAccounts(e,t){let{commitment:n,config:r}=Us(t),i=e.map(e=>e.toBase58()),a=this._buildArgs([i],n,`jsonParsed`,r),o=L(await this._rpcRequest(`getMultipleAccounts`,a),qs(R(z(jc))));if(`error`in o)throw new X(o.error,`failed to get info for accounts ${i}`);return o.result}async getMultipleAccountsInfoAndContext(e,t){let{commitment:n,config:r}=Us(t),i=e.map(e=>e.toBase58()),a=this._buildArgs([i],n,`base64`,r),o=L(await this._rpcRequest(`getMultipleAccounts`,a),qs(R(z(Oc))));if(`error`in o)throw new X(o.error,`failed to get info for accounts ${i}`);return o.result}async getMultipleAccountsInfo(e,t){return(await this.getMultipleAccountsInfoAndContext(e,t)).value}async getStakeActivation(e,t,n){let{commitment:r,config:i}=Us(t),a=this._buildArgs([e.toBase58()],r,void 0,{...i,epoch:n??i?.epoch}),o=L(await this._rpcRequest(`getStakeActivation`,a),$(Nc));if(`error`in o)throw new X(o.error,`failed to get Stake Activation ${e.toBase58()}`);return o.result}async getProgramAccounts(e,t){let{commitment:n,config:r}=Us(t),{encoding:i,...a}=r||{},o=this._buildArgs([e.toBase58()],n,i||`base64`,{...a,...a.filters?{filters:Ws(a.filters)}:null}),s=await this._rpcRequest(`getProgramAccounts`,o),c=R(kc),l=a.withContext===!0?L(s,qs(c)):L(s,$(c));if(`error`in l)throw new X(l.error,`failed to get accounts owned by program ${e.toBase58()}`);return l.result}async getParsedProgramAccounts(e,t){let{commitment:n,config:r}=Us(t),i=this._buildArgs([e.toBase58()],n,`jsonParsed`,r),a=L(await this._rpcRequest(`getProgramAccounts`,i),$(R(Mc)));if(`error`in a)throw new X(a.error,`failed to get accounts owned by program ${e.toBase58()}`);return a.result}async confirmTransaction(e,t){let n;if(typeof e==`string`)n=e;else{let t=e;if(t.abortSignal?.aborted)return Promise.reject(t.abortSignal.reason);n=t.signature}let r;try{r=kr.default.decode(n)}catch{throw Error(`signature must be base58 encoded: `+n)}return q(r.length===64,`signature has invalid length`),typeof e==`string`?await this.confirmTransactionUsingLegacyTimeoutStrategy({commitment:t||this.commitment,signature:n}):`lastValidBlockHeight`in e?await this.confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:t||this.commitment,strategy:e}):await this.confirmTransactionUsingDurableNonceStrategy({commitment:t||this.commitment,strategy:e})}getCancellationPromise(e){return new Promise((t,n)=>{e!=null&&(e.aborted?n(e.reason):e.addEventListener(`abort`,()=>{n(e.reason)}))})}getTransactionConfirmationPromise({commitment:e,signature:t}){let n,r,i=!1;return{abortConfirmation:()=>{r&&=(r(),void 0),n!=null&&(this.removeSignatureListener(n),n=void 0)},confirmationPromise:new Promise((a,o)=>{try{n=this.onSignature(t,(e,t)=>{n=void 0;let r={context:t,value:e};a({__type:Go.PROCESSED,response:r})},e);let s=new Promise(e=>{n==null?e():r=this._onSubscriptionStateChange(n,t=>{t===`subscribed`&&e()})});(async()=>{if(await s,i)return;let n=await this.getSignatureStatus(t);if(i||n==null)return;let{context:r,value:c}=n;if(c!=null)if(c?.err)o(c.err);else{switch(e){case`confirmed`:case`single`:case`singleGossip`:if(c.confirmationStatus===`processed`)return;break;case`finalized`:case`max`:case`root`:if(c.confirmationStatus===`processed`||c.confirmationStatus===`confirmed`)return;break;case`processed`:case`recent`:}i=!0,a({__type:Go.PROCESSED,response:{context:r,value:c}})}})()}catch(e){o(e)}})}}async confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:e,strategy:{abortSignal:t,lastValidBlockHeight:n,signature:r}}){let i=!1,a=new Promise(t=>{let r=async()=>{try{return await this.getBlockHeight(e)}catch{return-1}};(async()=>{let e=await r();if(!i){for(;e<=n;)if(await cs(1e3),i||(e=await r(),i))return;t({__type:Go.BLOCKHEIGHT_EXCEEDED})}})()}),{abortConfirmation:o,confirmationPromise:s}=this.getTransactionConfirmationPromise({commitment:e,signature:r}),c=this.getCancellationPromise(t),l;try{let e=await Promise.race([c,s,a]);if(e.__type===Go.PROCESSED)l=e.response;else throw new To(r)}finally{i=!0,o()}return l}async confirmTransactionUsingDurableNonceStrategy({commitment:e,strategy:{abortSignal:t,minContextSlot:n,nonceAccountPubkey:r,nonceValue:i,signature:a}}){let o=!1,s=new Promise(t=>{let a=i,s=null,c=async()=>{try{let{context:t,value:i}=await this.getNonceAndContext(r,{commitment:e,minContextSlot:n});return s=t.slot,i?.nonce}catch{return a}};(async()=>{if(a=await c(),!o)for(;;){if(i!==a){t({__type:Go.NONCE_INVALID,slotInWhichNonceDidAdvance:s});return}if(await cs(2e3),o||(a=await c(),o))return}})()}),{abortConfirmation:c,confirmationPromise:l}=this.getTransactionConfirmationPromise({commitment:e,signature:a}),u=this.getCancellationPromise(t),d;try{let t=await Promise.race([u,l,s]);if(t.__type===Go.PROCESSED)d=t.response;else{let r;for(;;){let e=await this.getSignatureStatus(a);if(e==null)break;if(e.context.slot<(t.slotInWhichNonceDidAdvance??n)){await cs(400);continue}r=e;break}if(r?.value){let t=e||`finalized`,{confirmationStatus:n}=r.value;switch(t){case`processed`:case`recent`:if(n!==`processed`&&n!==`confirmed`&&n!==`finalized`)throw new Do(a);break;case`confirmed`:case`single`:case`singleGossip`:if(n!==`confirmed`&&n!==`finalized`)throw new Do(a);break;case`finalized`:case`max`:case`root`:if(n!==`finalized`)throw new Do(a);break;default:(e=>{})(t)}d={context:r.context,value:{err:r.value.err}}}else throw new Do(a)}}finally{o=!0,c()}return d}async confirmTransactionUsingLegacyTimeoutStrategy({commitment:e,signature:t}){let n,r=new Promise(t=>{let r=this._confirmTransactionInitialTimeout||60*1e3;switch(e){case`processed`:case`recent`:case`single`:case`confirmed`:case`singleGossip`:r=this._confirmTransactionInitialTimeout||30*1e3;break}n=setTimeout(()=>t({__type:Go.TIMED_OUT,timeoutMs:r}),r)}),{abortConfirmation:i,confirmationPromise:a}=this.getTransactionConfirmationPromise({commitment:e,signature:t}),o;try{let e=await Promise.race([a,r]);if(e.__type===Go.PROCESSED)o=e.response;else throw new Eo(t,e.timeoutMs/1e3)}finally{clearTimeout(n),i()}return o}async getClusterNodes(){let e=L(await this._rpcRequest(`getClusterNodes`,[]),$(R(Gc)));if(`error`in e)throw new X(e.error,`failed to get cluster nodes`);return e.result}async getVoteAccounts(e){let t=this._buildArgs([],e),n=L(await this._rpcRequest(`getVoteAccounts`,t),qc);if(`error`in n)throw new X(n.error,`failed to get vote accounts`);return n.result}async getSlot(e){let{commitment:t,config:n}=Us(e),r=this._buildArgs([],t,void 0,n),i=L(await this._rpcRequest(`getSlot`,r),$(B()));if(`error`in i)throw new X(i.error,`failed to get slot`);return i.result}async getSlotLeader(e){let{commitment:t,config:n}=Us(e),r=this._buildArgs([],t,void 0,n),i=L(await this._rpcRequest(`getSlotLeader`,r),$(H()));if(`error`in i)throw new X(i.error,`failed to get slot leader`);return i.result}async getSlotLeaders(e,t){let n=[e,t],r=L(await this._rpcRequest(`getSlotLeaders`,n),$(R(Rs)));if(`error`in r)throw new X(r.error,`failed to get slot leaders`);return r.result}async getSignatureStatus(e,t){let{context:n,value:r}=await this.getSignatureStatuses([e],t);return q(r.length===1),{context:n,value:r[0]}}async getSignatureStatuses(e,t){let n=[e];t&&n.push(t);let r=L(await this._rpcRequest(`getSignatureStatuses`,n),Yc);if(`error`in r)throw new X(r.error,`failed to get signature status`);return r.result}async getTransactionCount(e){let{commitment:t,config:n}=Us(e),r=this._buildArgs([],t,void 0,n),i=L(await this._rpcRequest(`getTransactionCount`,r),$(B()));if(`error`in i)throw new X(i.error,`failed to get transaction count`);return i.result}async getTotalSupply(e){return(await this.getSupply({commitment:e,excludeNonCirculatingAccountsList:!0})).value.total}async getInflationGovernor(e){let t=this._buildArgs([],e),n=L(await this._rpcRequest(`getInflationGovernor`,t),mc);if(`error`in n)throw new X(n.error,`failed to get inflation`);return n.result}async getInflationReward(e,t,n){let{commitment:r,config:i}=Us(n),a=this._buildArgs([e.map(e=>e.toBase58())],r,void 0,{...i,epoch:t??i?.epoch}),o=L(await this._rpcRequest(`getInflationReward`,a),Zs);if(`error`in o)throw new X(o.error,`failed to get inflation reward`);return o.result}async getInflationRate(){let e=L(await this._rpcRequest(`getInflationRate`,[]),hc);if(`error`in e)throw new X(e.error,`failed to get inflation rate`);return e.result}async getEpochInfo(e){let{commitment:t,config:n}=Us(e),r=this._buildArgs([],t,void 0,n),i=L(await this._rpcRequest(`getEpochInfo`,r),_c);if(`error`in i)throw new X(i.error,`failed to get epoch info`);return i.result}async getEpochSchedule(){let e=L(await this._rpcRequest(`getEpochSchedule`,[]),vc);if(`error`in e)throw new X(e.error,`failed to get epoch schedule`);let t=e.result;return new ks(t.slotsPerEpoch,t.leaderScheduleSlotOffset,t.warmup,t.firstNormalEpoch,t.firstNormalSlot)}async getLeaderSchedule(){let e=L(await this._rpcRequest(`getLeaderSchedule`,[]),yc);if(`error`in e)throw new X(e.error,`failed to get leader schedule`);return e.result}async getMinimumBalanceForRentExemption(e,t){let n=this._buildArgs([e],t),r=L(await this._rpcRequest(`getMinimumBalanceForRentExemption`,n),Xc);return`error`in r?(console.warn(`Unable to fetch minimum balance for rent exemption`),0):r.result}async getRecentBlockhashAndContext(e){let{context:t,value:{blockhash:n}}=await this.getLatestBlockhashAndContext(e);return{context:t,value:{blockhash:n,feeCalculator:{get lamportsPerSignature(){throw Error("The capability to fetch `lamportsPerSignature` using the `getRecentBlockhash` API is no longer offered by the network. Use the `getFeeForMessage` API to obtain the fee for a given message.")},toJSON(){return{}}}}}}async getRecentPerformanceSamples(e){let t=L(await this._rpcRequest(`getRecentPerformanceSamples`,e?[e]:[]),Cl);if(`error`in t)throw new X(t.error,`failed to get recent performance samples`);return t.result}async getFeeCalculatorForBlockhash(e,t){let n=this._buildArgs([e],t),r=L(await this._rpcRequest(`getFeeCalculatorForBlockhash`,n),wl);if(`error`in r)throw new X(r.error,`failed to get fee calculator`);let{context:i,value:a}=r.result;return{context:i,value:a===null?null:a.feeCalculator}}async getFeeForMessage(e,t){let n=W(e.serialize()).toString(`base64`),r=this._buildArgs([n],t),i=L(await this._rpcRequest(`getFeeForMessage`,r),qs(z(B())));if(`error`in i)throw new X(i.error,`failed to get fee for message`);if(i.result===null)throw Error(`invalid blockhash`);return i.result}async getRecentPrioritizationFees(e){let t=e?.lockedWritableAccounts?.map(e=>e.toBase58()),n=t?.length?[t]:[],r=L(await this._rpcRequest(`getRecentPrioritizationFees`,n),gc);if(`error`in r)throw new X(r.error,`failed to get recent prioritization fees`);return r.result}async getRecentBlockhash(e){try{return(await this.getRecentBlockhashAndContext(e)).value}catch(e){throw Error(`failed to get recent blockhash: `+e)}}async getLatestBlockhash(e){try{return(await this.getLatestBlockhashAndContext(e)).value}catch(e){throw Error(`failed to get recent blockhash: `+e)}}async getLatestBlockhashAndContext(e){let{commitment:t,config:n}=Us(e),r=this._buildArgs([],t,void 0,n),i=L(await this._rpcRequest(`getLatestBlockhash`,r),xl);if(`error`in i)throw new X(i.error,`failed to get latest blockhash`);return i.result}async isBlockhashValid(e,t){let{commitment:n,config:r}=Us(t),i=this._buildArgs([e],n,void 0,r),a=L(await this._rpcRequest(`isBlockhashValid`,i),Sl);if(`error`in a)throw new X(a.error,"failed to determine if the blockhash `"+e+"`is valid");return a.result}async getVersion(){let e=L(await this._rpcRequest(`getVersion`,[]),$(oc));if(`error`in e)throw new X(e.error,`failed to get version`);return e.result}async getGenesisHash(){let e=L(await this._rpcRequest(`getGenesisHash`,[]),$(H()));if(`error`in e)throw new X(e.error,`failed to get genesis hash`);return e.result}async getBlock(e,t){let{commitment:n,config:r}=Us(t),i=this._buildArgsAtLeastConfirmed([e],n,void 0,r),a=await this._rpcRequest(`getBlock`,i);try{switch(r?.transactionDetails){case`accounts`:{let e=L(a,pl);if(`error`in e)throw e.error;return e.result}case`none`:{let e=L(a,fl);if(`error`in e)throw e.error;return e.result}default:{let e=L(a,dl);if(`error`in e)throw e.error;let{result:t}=e;return t?{...t,transactions:t.transactions.map(({transaction:e,meta:t,version:n})=>({meta:t,transaction:{...e,message:Ys(n,e.message)},version:n}))}:null}}}catch(e){throw new X(e,`failed to get confirmed block`)}}async getParsedBlock(e,t){let{commitment:n,config:r}=Us(t),i=this._buildArgsAtLeastConfirmed([e],n,`jsonParsed`,r),a=await this._rpcRequest(`getBlock`,i);try{switch(r?.transactionDetails){case`accounts`:{let e=L(a,hl);if(`error`in e)throw e.error;return e.result}case`none`:{let e=L(a,gl);if(`error`in e)throw e.error;return e.result}default:{let e=L(a,ml);if(`error`in e)throw e.error;return e.result}}}catch(e){throw new X(e,`failed to get block`)}}async getBlockProduction(e){let t,n;if(typeof e==`string`)n=e;else if(e){let{commitment:r,...i}=e;n=r,t=i}let r=this._buildArgs([],n,`base64`,t),i=L(await this._rpcRequest(`getBlockProduction`,r),uc);if(`error`in i)throw new X(i.error,`failed to get block production information`);return i.result}async getTransaction(e,t){let{commitment:n,config:r}=Us(t),i=this._buildArgsAtLeastConfirmed([e],n,void 0,r),a=L(await this._rpcRequest(`getTransaction`,i),yl);if(`error`in a)throw new X(a.error,`failed to get transaction`);let o=a.result;return o&&{...o,transaction:{...o.transaction,message:Ys(o.version,o.transaction.message)}}}async getParsedTransaction(e,t){let{commitment:n,config:r}=Us(t),i=this._buildArgsAtLeastConfirmed([e],n,`jsonParsed`,r),a=L(await this._rpcRequest(`getTransaction`,i),bl);if(`error`in a)throw new X(a.error,`failed to get transaction`);return a.result}async getParsedTransactions(e,t){let{commitment:n,config:r}=Us(t),i=e.map(e=>({methodName:`getTransaction`,args:this._buildArgsAtLeastConfirmed([e],n,`jsonParsed`,r)}));return(await this._rpcBatchRequest(i)).map(e=>{let t=L(e,bl);if(`error`in t)throw new X(t.error,`failed to get transactions`);return t.result})}async getTransactions(e,t){let{commitment:n,config:r}=Us(t),i=e.map(e=>({methodName:`getTransaction`,args:this._buildArgsAtLeastConfirmed([e],n,void 0,r)}));return(await this._rpcBatchRequest(i)).map(e=>{let t=L(e,yl);if(`error`in t)throw new X(t.error,`failed to get transactions`);let n=t.result;return n&&{...n,transaction:{...n.transaction,message:Ys(n.version,n.transaction.message)}}})}async getConfirmedBlock(e,t){let n=this._buildArgsAtLeastConfirmed([e],t),r=L(await this._rpcRequest(`getBlock`,n),_l);if(`error`in r)throw new X(r.error,`failed to get confirmed block`);let i=r.result;if(!i)throw Error(`Confirmed block `+e+` not found`);let a={...i,transactions:i.transactions.map(({transaction:e,meta:t})=>{let n=new Ho(e.message);return{meta:t,transaction:{...e,message:n}}})};return{...a,transactions:a.transactions.map(({transaction:e,meta:t})=>({meta:t,transaction:Y.populate(e.message,e.signatures)}))}}async getBlocks(e,t,n){let r=this._buildArgsAtLeastConfirmed(t===void 0?[e]:[e,t],n),i=L(await this._rpcRequest(`getBlocks`,r),$(R(B())));if(`error`in i)throw new X(i.error,`failed to get blocks`);return i.result}async getBlockSignatures(e,t){let n=this._buildArgsAtLeastConfirmed([e],t,void 0,{transactionDetails:`signatures`,rewards:!1}),r=L(await this._rpcRequest(`getBlock`,n),vl);if(`error`in r)throw new X(r.error,`failed to get block`);let i=r.result;if(!i)throw Error(`Block `+e+` not found`);return i}async getConfirmedBlockSignatures(e,t){let n=this._buildArgsAtLeastConfirmed([e],t,void 0,{transactionDetails:`signatures`,rewards:!1}),r=L(await this._rpcRequest(`getBlock`,n),vl);if(`error`in r)throw new X(r.error,`failed to get confirmed block`);let i=r.result;if(!i)throw Error(`Confirmed block `+e+` not found`);return i}async getConfirmedTransaction(e,t){let n=this._buildArgsAtLeastConfirmed([e],t),r=L(await this._rpcRequest(`getTransaction`,n),yl);if(`error`in r)throw new X(r.error,`failed to get transaction`);let i=r.result;if(!i)return i;let a=new Ho(i.transaction.message),o=i.transaction.signatures;return{...i,transaction:Y.populate(a,o)}}async getParsedConfirmedTransaction(e,t){let n=this._buildArgsAtLeastConfirmed([e],t,`jsonParsed`),r=L(await this._rpcRequest(`getTransaction`,n),bl);if(`error`in r)throw new X(r.error,`failed to get confirmed transaction`);return r.result}async getParsedConfirmedTransactions(e,t){let n=e.map(e=>({methodName:`getTransaction`,args:this._buildArgsAtLeastConfirmed([e],t,`jsonParsed`)}));return(await this._rpcBatchRequest(n)).map(e=>{let t=L(e,bl);if(`error`in t)throw new X(t.error,`failed to get confirmed transactions`);return t.result})}async getConfirmedSignaturesForAddress(e,t,n){let r={},i=await this.getFirstAvailableBlock();for(;!(`until`in r)&&(t--,!(t<=0||t<i));)try{let e=await this.getConfirmedBlockSignatures(t,`finalized`);e.signatures.length>0&&(r.until=e.signatures[e.signatures.length-1].toString())}catch(e){if(e instanceof Error&&e.message.includes(`skipped`))continue;throw e}let a=await this.getSlot(`finalized`);for(;!(`before`in r)&&(n++,!(n>a));)try{let e=await this.getConfirmedBlockSignatures(n);e.signatures.length>0&&(r.before=e.signatures[e.signatures.length-1].toString())}catch(e){if(e instanceof Error&&e.message.includes(`skipped`))continue;throw e}return(await this.getConfirmedSignaturesForAddress2(e,r)).map(e=>e.signature)}async getConfirmedSignaturesForAddress2(e,t,n){let r=this._buildArgsAtLeastConfirmed([e.toBase58()],n,void 0,t),i=L(await this._rpcRequest(`getConfirmedSignaturesForAddress2`,r),Pc);if(`error`in i)throw new X(i.error,`failed to get confirmed signatures for address`);return i.result}async getSignaturesForAddress(e,t,n){let r=this._buildArgsAtLeastConfirmed([e.toBase58()],n,void 0,t),i=L(await this._rpcRequest(`getSignaturesForAddress`,r),Fc);if(`error`in i)throw new X(i.error,`failed to get signatures for address`);return i.result}async getAddressLookupTable(e,t){let{context:n,value:r}=await this.getAccountInfoAndContext(e,t),i=null;return r!==null&&(i=new Ps({key:e,state:Ps.deserialize(r.data)})),{context:n,value:i}}async getNonceAndContext(e,t){let{context:n,value:r}=await this.getAccountInfoAndContext(e,t),i=null;return r!==null&&(i=fs.fromAccountData(r.data)),{context:n,value:i}}async getNonce(e,t){return await this.getNonceAndContext(e,t).then(e=>e.value).catch(t=>{throw Error(`failed to get nonce for account `+e.toBase58()+`: `+t)})}async requestAirdrop(e,t){let n=L(await this._rpcRequest(`requestAirdrop`,[e.toBase58(),t]),Tl);if(`error`in n)throw new X(n.error,`airdrop to ${e.toBase58()} failed`);return n.result}async _blockhashWithExpiryBlockHeight(e){if(!e){for(;this._pollingBlockhash;)await cs(100);let e=Date.now()-this._blockhashInfo.lastFetch>=Vs;if(this._blockhashInfo.latestBlockhash!==null&&!e)return this._blockhashInfo.latestBlockhash}return await this._pollNewBlockhash()}async _pollNewBlockhash(){this._pollingBlockhash=!0;try{let e=Date.now(),t=this._blockhashInfo.latestBlockhash,n=t?t.blockhash:null;for(let e=0;e<50;e++){let e=await this.getLatestBlockhash(`finalized`);if(n!==e.blockhash)return this._blockhashInfo={latestBlockhash:e,lastFetch:Date.now(),transactionSignatures:[],simulatedSignatures:[]},e;await cs(Yo/2)}throw Error(`Unable to obtain a new blockhash after ${Date.now()-e}ms`)}finally{this._pollingBlockhash=!1}}async getStakeMinimumDelegation(e){let{commitment:t,config:n}=Us(e),r=this._buildArgs([],t,`base64`,n),i=L(await this._rpcRequest(`getStakeMinimumDelegation`,r),qs(B()));if(`error`in i)throw new X(i.error,`failed to get stake minimum delegation`);return i.result}async simulateTransaction(e,t,n){if(`message`in e){let r=e.serialize(),i=F.Buffer.from(r).toString(`base64`);if(Array.isArray(t)||n!==void 0)throw Error(`Invalid arguments`);let a=t||{};a.encoding=`base64`,`commitment`in a||(a.commitment=this.commitment),t&&typeof t==`object`&&`innerInstructions`in t&&(a.innerInstructions=t.innerInstructions);let o=[i,a],s=L(await this._rpcRequest(`simulateTransaction`,o),lc);if(`error`in s)throw Error(`failed to simulate transaction: `+s.error.message);return s.result}let r;if(e instanceof Y){let t=e;r=new Y,r.feePayer=t.feePayer,r.instructions=e.instructions,r.nonceInfo=t.nonceInfo,r.signatures=t.signatures}else r=Y.populate(e),r._message=r._json=void 0;if(t!==void 0&&!Array.isArray(t))throw Error(`Invalid arguments`);let i=t;if(r.nonceInfo&&i)r.sign(...i);else{let e=this._disableBlockhashCaching;for(;;){let t=await this._blockhashWithExpiryBlockHeight(e);if(r.lastValidBlockHeight=t.lastValidBlockHeight,r.recentBlockhash=t.blockhash,!i)break;if(r.sign(...i),!r.signature)throw Error(`!signature`);let n=r.signature.toString(`base64`);if(!this._blockhashInfo.simulatedSignatures.includes(n)&&!this._blockhashInfo.transactionSignatures.includes(n)){this._blockhashInfo.simulatedSignatures.push(n);break}else e=!0}}let a=r._compile(),o=a.serialize(),s=r._serialize(o).toString(`base64`),c={encoding:`base64`,commitment:this.commitment};n&&(c.accounts={encoding:`base64`,addresses:(Array.isArray(n)?n:a.nonProgramIds()).map(e=>e.toBase58())}),i&&(c.sigVerify=!0),t&&typeof t==`object`&&`innerInstructions`in t&&(c.innerInstructions=t.innerInstructions);let l=[s,c],u=L(await this._rpcRequest(`simulateTransaction`,l),lc);if(`error`in u){let e;if(`data`in u.error&&(e=u.error.data.logs,e&&Array.isArray(e))){let t=`
1
+ import{a as e,n as t,o as n,r,t as i}from"./rolldown-runtime--c01j_DQ.js";import{di as a}from"./index-BcBWKKi1.js";import{n as o}from"./eventemitter3-CwKRT-4Q.js";import{t as s}from"./buffer-CnhyIITQ.js";var c=BigInt(2**32-1),l=BigInt(32);function u(e,t=!1){return t?{h:Number(e&c),l:Number(e>>l&c)}:{h:Number(e>>l&c)|0,l:Number(e&c)|0}}function d(e,t=!1){let n=e.length,r=new Uint32Array(n),i=new Uint32Array(n);for(let a=0;a<n;a++){let{h:n,l:o}=u(e[a],t);[r[a],i[a]]=[n,o]}return[r,i]}var f=(e,t,n)=>e>>>n,p=(e,t,n)=>e<<32-n|t>>>n,m=(e,t,n)=>e>>>n|t<<32-n,h=(e,t,n)=>e<<32-n|t>>>n,g=(e,t,n)=>e<<64-n|t>>>n-32,_=(e,t,n)=>e>>>n-32|t<<64-n,v=(e,t,n)=>e<<n|t>>>32-n,y=(e,t,n)=>t<<n|e>>>32-n,b=(e,t,n)=>t<<n-32|e>>>64-n,x=(e,t,n)=>e<<n-32|t>>>64-n;function S(e,t,n,r){let i=(t>>>0)+(r>>>0);return{h:e+n+(i/2**32|0)|0,l:i|0}}var C=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),w=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,T=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),E=(e,t,n,r,i)=>t+n+r+i+(e/2**32|0)|0,D=(e,t,n,r,i)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(i>>>0),O=(e,t,n,r,i,a)=>t+n+r+i+a+(e/2**32|0)|0,k=typeof globalThis==`object`&&`crypto`in globalThis?globalThis.crypto:void 0;function A(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`}function ee(e){if(!Number.isSafeInteger(e)||e<0)throw Error(`positive integer expected, got `+e)}function j(e,...t){if(!A(e))throw Error(`Uint8Array expected`);if(t.length>0&&!t.includes(e.length))throw Error(`Uint8Array expected of length `+t+`, got length=`+e.length)}function M(e){if(typeof e!=`function`||typeof e.create!=`function`)throw Error(`Hash should be wrapped by utils.createHasher`);ee(e.outputLen),ee(e.blockLen)}function te(e,t=!0){if(e.destroyed)throw Error(`Hash instance has been destroyed`);if(t&&e.finished)throw Error(`Hash#digest() has already been called`)}function ne(e,t){j(e);let n=t.outputLen;if(e.length<n)throw Error(`digestInto() expects output buffer of length at least `+n)}function re(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function ie(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function ae(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function N(e,t){return e<<32-t|e>>>t}var oe=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function se(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function ce(e){for(let t=0;t<e.length;t++)e[t]=se(e[t]);return e}var le=oe?e=>e:ce,ue=typeof Uint8Array.from([]).toHex==`function`&&typeof Uint8Array.fromHex==`function`,de=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function fe(e){if(j(e),ue)return e.toHex();let t=``;for(let n=0;n<e.length;n++)t+=de[e[n]];return t}var P={_0:48,_9:57,A:65,F:70,a:97,f:102};function pe(e){if(e>=P._0&&e<=P._9)return e-P._0;if(e>=P.A&&e<=P.F)return e-(P.A-10);if(e>=P.a&&e<=P.f)return e-(P.a-10)}function me(e){if(typeof e!=`string`)throw Error(`hex string expected, got `+typeof e);if(ue)return Uint8Array.fromHex(e);let t=e.length,n=t/2;if(t%2)throw Error(`hex string expected, got unpadded hex of length `+t);let r=new Uint8Array(n);for(let t=0,i=0;t<n;t++,i+=2){let n=pe(e.charCodeAt(i)),a=pe(e.charCodeAt(i+1));if(n===void 0||a===void 0){let t=e[i]+e[i+1];throw Error(`hex string expected, got non-hex character "`+t+`" at index `+i)}r[t]=n*16+a}return r}function he(e){if(typeof e!=`string`)throw Error(`string expected`);return new Uint8Array(new TextEncoder().encode(e))}function ge(e){return typeof e==`string`&&(e=he(e)),j(e),e}function _e(...e){let t=0;for(let n=0;n<e.length;n++){let r=e[n];j(r),t+=r.length}let n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){let i=e[t];n.set(i,r),r+=i.length}return n}var ve=class{};function ye(e){let t=t=>e().update(ge(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function be(e=32){if(k&&typeof k.getRandomValues==`function`)return k.getRandomValues(new Uint8Array(e));if(k&&typeof k.randomBytes==`function`)return Uint8Array.from(k.randomBytes(e));throw Error(`crypto.getRandomValues must be defined`)}var xe=BigInt(0),Se=BigInt(1),Ce=BigInt(2),we=BigInt(7),Te=BigInt(256),Ee=BigInt(113),De=[],Oe=[],ke=[];for(let e=0,t=Se,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],De.push(2*(5*r+n)),Oe.push((e+1)*(e+2)/2%64);let i=xe;for(let e=0;e<7;e++)t=(t<<Se^(t>>we)*Ee)%Te,t&Ce&&(i^=Se<<(Se<<BigInt(e))-Se);ke.push(i)}var Ae=d(ke,!0),je=Ae[0],Me=Ae[1],Ne=(e,t,n)=>n>32?b(e,t,n):v(e,t,n),Pe=(e,t,n)=>n>32?x(e,t,n):y(e,t,n);function Fe(e,t=24){let n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let t=0;t<10;t++)n[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){let r=(t+8)%10,i=(t+2)%10,a=n[i],o=n[i+1],s=Ne(a,o,1)^n[r],c=Pe(a,o,1)^n[r+1];for(let n=0;n<50;n+=10)e[t+n]^=s,e[t+n+1]^=c}let t=e[2],i=e[3];for(let n=0;n<24;n++){let r=Oe[n],a=Ne(t,i,r),o=Pe(t,i,r),s=De[n];t=e[s],i=e[s+1],e[s]=a,e[s+1]=o}for(let t=0;t<50;t+=10){for(let r=0;r<10;r++)n[r]=e[t+r];for(let r=0;r<10;r++)e[t+r]^=~n[(r+2)%10]&n[(r+4)%10]}e[0]^=je[r],e[1]^=Me[r]}ie(n)}var Ie=class e extends ve{constructor(e,t,n,r=!1,i=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=r,this.rounds=i,ee(n),!(0<e&&e<200))throw Error(`only keccak-f1600 function is supported`);this.state=new Uint8Array(200),this.state32=re(this.state)}clone(){return this._cloneInto()}keccak(){le(this.state32),Fe(this.state32,this.rounds),le(this.state32),this.posOut=0,this.pos=0}update(e){te(this),e=ge(e),j(e);let{blockLen:t,state:n}=this,r=e.length;for(let i=0;i<r;){let a=Math.min(t-this.pos,r-i);for(let t=0;t<a;t++)n[this.pos++]^=e[i++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:t,pos:n,blockLen:r}=this;e[n]^=t,t&128&&n===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){te(this,!1),j(e),this.finish();let t=this.state,{blockLen:n}=this;for(let r=0,i=e.length;r<i;){this.posOut>=n&&this.keccak();let a=Math.min(n-this.posOut,i-r);e.set(t.subarray(this.posOut,this.posOut+a),r),this.posOut+=a,r+=a}return e}xofInto(e){if(!this.enableXOF)throw Error(`XOF is not possible for this instance`);return this.writeInto(e)}xof(e){return ee(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(ne(e,this),this.finished)throw Error(`digest() was already called`);return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,ie(this.state)}_cloneInto(t){let{blockLen:n,suffix:r,outputLen:i,rounds:a,enableXOF:o}=this;return t||=new e(n,r,i,o,a),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=a,t.suffix=r,t.outputLen=i,t.enableXOF=o,t.destroyed=this.destroyed,t}},Le=((e,t,n)=>ye(()=>new Ie(t,e,n)))(1,136,256/8);function Re(e,t,n,r){if(typeof e.setBigUint64==`function`)return e.setBigUint64(t,n,r);let i=BigInt(32),a=BigInt(4294967295),o=Number(n>>i&a),s=Number(n&a),c=r?4:0,l=r?0:4;e.setUint32(t+c,o,r),e.setUint32(t+l,s,r)}function ze(e,t,n){return e&t^~e&n}function Be(e,t,n){return e&t^e&n^t&n}var Ve=class extends ve{constructor(e,t,n,r){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=ae(this.buffer)}update(e){te(this),e=ge(e),j(e);let{view:t,buffer:n,blockLen:r}=this,i=e.length;for(let a=0;a<i;){let o=Math.min(r-this.pos,i-a);if(o===r){let t=ae(e);for(;r<=i-a;a+=r)this.process(t,a);continue}n.set(e.subarray(a,a+o),this.pos),this.pos+=o,a+=o,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){te(this),ne(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:r,isLE:i}=this,{pos:a}=this;t[a++]=128,ie(this.buffer.subarray(a)),this.padOffset>r-a&&(this.process(n,0),a=0);for(let e=a;e<r;e++)t[e]=0;Re(n,r-8,BigInt(this.length*8),i),this.process(n,0);let o=ae(e),s=this.outputLen;if(s%4)throw Error(`_sha2: outputLen should be aligned to 32bit`);let c=s/4,l=this.get();if(c>l.length)throw Error(`_sha2: outputLen bigger than state`);for(let e=0;e<c;e++)o.setUint32(4*e,l[e],i)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||=new this.constructor,e.set(...this.get());let{blockLen:t,buffer:n,length:r,finished:i,destroyed:a,pos:o}=this;return e.destroyed=a,e.finished=i,e.length=r,e.pos=o,r%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}},He=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ue=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),We=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Ge=new Uint32Array(64),Ke=class extends Ve{constructor(e=32){super(64,e,8,!1),this.A=He[0]|0,this.B=He[1]|0,this.C=He[2]|0,this.D=He[3]|0,this.E=He[4]|0,this.F=He[5]|0,this.G=He[6]|0,this.H=He[7]|0}get(){let{A:e,B:t,C:n,D:r,E:i,F:a,G:o,H:s}=this;return[e,t,n,r,i,a,o,s]}set(e,t,n,r,i,a,o,s){this.A=e|0,this.B=t|0,this.C=n|0,this.D=r|0,this.E=i|0,this.F=a|0,this.G=o|0,this.H=s|0}process(e,t){for(let n=0;n<16;n++,t+=4)Ge[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){let t=Ge[e-15],n=Ge[e-2],r=N(t,7)^N(t,18)^t>>>3;Ge[e]=(N(n,17)^N(n,19)^n>>>10)+Ge[e-7]+r+Ge[e-16]|0}let{A:n,B:r,C:i,D:a,E:o,F:s,G:c,H:l}=this;for(let e=0;e<64;e++){let t=N(o,6)^N(o,11)^N(o,25),u=l+t+ze(o,s,c)+We[e]+Ge[e]|0,d=(N(n,2)^N(n,13)^N(n,22))+Be(n,r,i)|0;l=c,c=s,s=o,o=a+u|0,a=i,i=r,r=n,n=u+d|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,a=a+this.D|0,o=o+this.E|0,s=s+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,i,a,o,s,c,l)}roundClean(){ie(Ge)}destroy(){this.set(0,0,0,0,0,0,0,0),ie(this.buffer)}},qe=d(`0x428a2f98d728ae22.0x7137449123ef65cd.0xb5c0fbcfec4d3b2f.0xe9b5dba58189dbbc.0x3956c25bf348b538.0x59f111f1b605d019.0x923f82a4af194f9b.0xab1c5ed5da6d8118.0xd807aa98a3030242.0x12835b0145706fbe.0x243185be4ee4b28c.0x550c7dc3d5ffb4e2.0x72be5d74f27b896f.0x80deb1fe3b1696b1.0x9bdc06a725c71235.0xc19bf174cf692694.0xe49b69c19ef14ad2.0xefbe4786384f25e3.0x0fc19dc68b8cd5b5.0x240ca1cc77ac9c65.0x2de92c6f592b0275.0x4a7484aa6ea6e483.0x5cb0a9dcbd41fbd4.0x76f988da831153b5.0x983e5152ee66dfab.0xa831c66d2db43210.0xb00327c898fb213f.0xbf597fc7beef0ee4.0xc6e00bf33da88fc2.0xd5a79147930aa725.0x06ca6351e003826f.0x142929670a0e6e70.0x27b70a8546d22ffc.0x2e1b21385c26c926.0x4d2c6dfc5ac42aed.0x53380d139d95b3df.0x650a73548baf63de.0x766a0abb3c77b2a8.0x81c2c92e47edaee6.0x92722c851482353b.0xa2bfe8a14cf10364.0xa81a664bbc423001.0xc24b8b70d0f89791.0xc76c51a30654be30.0xd192e819d6ef5218.0xd69906245565a910.0xf40e35855771202a.0x106aa07032bbd1b8.0x19a4c116b8d2d0c8.0x1e376c085141ab53.0x2748774cdf8eeb99.0x34b0bcb5e19b48a8.0x391c0cb3c5c95a63.0x4ed8aa4ae3418acb.0x5b9cca4f7763e373.0x682e6ff3d6b2b8a3.0x748f82ee5defb2fc.0x78a5636f43172f60.0x84c87814a1f0ab72.0x8cc702081a6439ec.0x90befffa23631e28.0xa4506cebde82bde9.0xbef9a3f7b2c67915.0xc67178f2e372532b.0xca273eceea26619c.0xd186b8c721c0c207.0xeada7dd6cde0eb1e.0xf57d4f7fee6ed178.0x06f067aa72176fba.0x0a637dc5a2c898a6.0x113f9804bef90dae.0x1b710b35131c471b.0x28db77f523047d84.0x32caab7b40c72493.0x3c9ebe0a15c9bebc.0x431d67c49c100d4c.0x4cc5d4becb3e42b6.0x597f299cfc657e2a.0x5fcb6fab3ad6faec.0x6c44198c4a475817`.split(`.`).map(e=>BigInt(e))),Je=qe[0],Ye=qe[1],Xe=new Uint32Array(80),Ze=new Uint32Array(80),Qe=class extends Ve{constructor(e=64){super(128,e,16,!1),this.Ah=Ue[0]|0,this.Al=Ue[1]|0,this.Bh=Ue[2]|0,this.Bl=Ue[3]|0,this.Ch=Ue[4]|0,this.Cl=Ue[5]|0,this.Dh=Ue[6]|0,this.Dl=Ue[7]|0,this.Eh=Ue[8]|0,this.El=Ue[9]|0,this.Fh=Ue[10]|0,this.Fl=Ue[11]|0,this.Gh=Ue[12]|0,this.Gl=Ue[13]|0,this.Hh=Ue[14]|0,this.Hl=Ue[15]|0}get(){let{Ah:e,Al:t,Bh:n,Bl:r,Ch:i,Cl:a,Dh:o,Dl:s,Eh:c,El:l,Fh:u,Fl:d,Gh:f,Gl:p,Hh:m,Hl:h}=this;return[e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h]}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=r|0,this.Ch=i|0,this.Cl=a|0,this.Dh=o|0,this.Dl=s|0,this.Eh=c|0,this.El=l|0,this.Fh=u|0,this.Fl=d|0,this.Gh=f|0,this.Gl=p|0,this.Hh=m|0,this.Hl=h|0}process(e,t){for(let n=0;n<16;n++,t+=4)Xe[n]=e.getUint32(t),Ze[n]=e.getUint32(t+=4);for(let e=16;e<80;e++){let t=Xe[e-15]|0,n=Ze[e-15]|0,r=m(t,n,1)^m(t,n,8)^f(t,n,7),i=h(t,n,1)^h(t,n,8)^p(t,n,7),a=Xe[e-2]|0,o=Ze[e-2]|0,s=m(a,o,19)^g(a,o,61)^f(a,o,6),c=T(i,h(a,o,19)^_(a,o,61)^p(a,o,6),Ze[e-7],Ze[e-16]);Xe[e]=E(c,r,s,Xe[e-7],Xe[e-16])|0,Ze[e]=c|0}let{Ah:n,Al:r,Bh:i,Bl:a,Ch:o,Cl:s,Dh:c,Dl:l,Eh:u,El:d,Fh:v,Fl:y,Gh:b,Gl:x,Hh:k,Hl:A}=this;for(let e=0;e<80;e++){let t=m(u,d,14)^m(u,d,18)^g(u,d,41),f=h(u,d,14)^h(u,d,18)^_(u,d,41),p=u&v^~u&b,T=d&y^~d&x,E=D(A,f,T,Ye[e],Ze[e]),ee=O(E,k,t,p,Je[e],Xe[e]),j=E|0,M=m(n,r,28)^g(n,r,34)^g(n,r,39),te=h(n,r,28)^_(n,r,34)^_(n,r,39),ne=n&i^n&o^i&o,re=r&a^r&s^a&s;k=b|0,A=x|0,b=v|0,x=y|0,v=u|0,y=d|0,{h:u,l:d}=S(c|0,l|0,ee|0,j|0),c=o|0,l=s|0,o=i|0,s=a|0,i=n|0,a=r|0;let ie=C(j,te,re);n=w(ie,ee,M,ne),r=ie|0}({h:n,l:r}=S(this.Ah|0,this.Al|0,n|0,r|0)),{h:i,l:a}=S(this.Bh|0,this.Bl|0,i|0,a|0),{h:o,l:s}=S(this.Ch|0,this.Cl|0,o|0,s|0),{h:c,l}=S(this.Dh|0,this.Dl|0,c|0,l|0),{h:u,l:d}=S(this.Eh|0,this.El|0,u|0,d|0),{h:v,l:y}=S(this.Fh|0,this.Fl|0,v|0,y|0),{h:b,l:x}=S(this.Gh|0,this.Gl|0,b|0,x|0),{h:k,l:A}=S(this.Hh|0,this.Hl|0,k|0,A|0),this.set(n,r,i,a,o,s,c,l,u,d,v,y,b,x,k,A)}roundClean(){ie(Xe,Ze)}destroy(){ie(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},$e=ye(()=>new Ke),et=ye(()=>new Qe),tt=$e,nt=class extends ve{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,M(e);let n=ge(t);if(this.iHash=e.create(),typeof this.iHash.update!=`function`)throw Error(`Expected instance of class which extends utils.Hash`);this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let r=this.blockLen,i=new Uint8Array(r);i.set(n.length>r?e.create().update(n).digest():n);for(let e=0;e<i.length;e++)i[e]^=54;this.iHash.update(i),this.oHash=e.create();for(let e=0;e<i.length;e++)i[e]^=106;this.oHash.update(i),ie(i)}update(e){return te(this),this.iHash.update(e),this}digestInto(e){te(this),j(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:t,iHash:n,finished:r,destroyed:i,blockLen:a,outputLen:o}=this;return e=e,e.finished=r,e.destroyed=i,e.blockLen=a,e.outputLen=o,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},rt=(e,t,n)=>new nt(e,t).update(n).digest();rt.create=(e,t)=>new nt(e,t);var F=s(),it=BigInt(0),at=BigInt(1);function ot(e,t=``){if(typeof e!=`boolean`){let n=t&&`"${t}"`;throw Error(n+`expected boolean, got type=`+typeof e)}return e}function st(e,t,n=``){let r=A(e),i=e?.length,a=t!==void 0;if(!r||a&&i!==t){let o=n&&`"${n}" `,s=a?` of length ${t}`:``,c=r?`length=${i}`:`type=${typeof e}`;throw Error(o+`expected Uint8Array`+s+`, got `+c)}return e}function ct(e){let t=e.toString(16);return t.length&1?`0`+t:t}function lt(e){if(typeof e!=`string`)throw Error(`hex string expected, got `+typeof e);return e===``?it:BigInt(`0x`+e)}function ut(e){return lt(fe(e))}function dt(e){return j(e),lt(fe(Uint8Array.from(e).reverse()))}function ft(e,t){return me(e.toString(16).padStart(t*2,`0`))}function pt(e,t){return ft(e,t).reverse()}function mt(e,t,n){let r;if(typeof t==`string`)try{r=me(t)}catch(t){throw Error(e+` must be hex string or Uint8Array, cause: `+t)}else if(A(t))r=Uint8Array.from(t);else throw Error(e+` must be hex string or Uint8Array`);let i=r.length;if(typeof n==`number`&&i!==n)throw Error(e+` of length `+n+` expected, got `+i);return r}function ht(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return n===0}function gt(e){return Uint8Array.from(e)}var _t=e=>typeof e==`bigint`&&it<=e;function vt(e,t,n){return _t(e)&&_t(t)&&_t(n)&&t<=e&&e<n}function yt(e,t,n,r){if(!vt(t,n,r))throw Error(`expected valid `+e+`: `+n+` <= n < `+r+`, got `+t)}function bt(e){let t;for(t=0;e>it;e>>=at,t+=1);return t}var xt=e=>(at<<BigInt(e))-at;function St(e,t,n){if(typeof e!=`number`||e<2)throw Error(`hashLen must be a number`);if(typeof t!=`number`||t<2)throw Error(`qByteLen must be a number`);if(typeof n!=`function`)throw Error(`hmacFn must be a function`);let r=e=>new Uint8Array(e),i=e=>Uint8Array.of(e),a=r(e),o=r(e),s=0,c=()=>{a.fill(1),o.fill(0),s=0},l=(...e)=>n(o,a,...e),u=(e=r(0))=>{o=l(i(0),e),a=l(),e.length!==0&&(o=l(i(1),e),a=l())},d=()=>{if(s++>=1e3)throw Error(`drbg: tried 1000 values`);let e=0,n=[];for(;e<t;){a=l();let t=a.slice();n.push(t),e+=a.length}return _e(...n)};return(e,t)=>{c(),u(e);let n;for(;!(n=t(d()));)u();return c(),n}}function Ct(e,t,n={}){if(!e||typeof e!=`object`)throw Error(`expected valid options object`);function r(t,n,r){let i=e[t];if(r&&i===void 0)return;let a=typeof i;if(a!==n||i===null)throw Error(`param "${t}" is invalid: expected ${n}, got ${a}`)}Object.entries(t).forEach(([e,t])=>r(e,t,!1)),Object.entries(n).forEach(([e,t])=>r(e,t,!0))}var wt=()=>{throw Error(`not implemented`)};function Tt(e){let t=new WeakMap;return(n,...r)=>{let i=t.get(n);if(i!==void 0)return i;let a=e(n,...r);return t.set(n,a),a}}var Et=BigInt(0),Dt=BigInt(1),Ot=BigInt(2),kt=BigInt(3),At=BigInt(4),jt=BigInt(5),Mt=BigInt(7),Nt=BigInt(8),Pt=BigInt(9),Ft=BigInt(16);function It(e,t){let n=e%t;return n>=Et?n:t+n}function Lt(e,t,n){let r=e;for(;t-- >Et;)r*=r,r%=n;return r}function Rt(e,t){if(e===Et)throw Error(`invert: expected non-zero number`);if(t<=Et)throw Error(`invert: expected positive modulus, got `+t);let n=It(e,t),r=t,i=Et,a=Dt,o=Dt,s=Et;for(;n!==Et;){let e=r/n,t=r%n,c=i-o*e,l=a-s*e;r=n,n=t,i=o,a=s,o=c,s=l}if(r!==Dt)throw Error(`invert: does not exist`);return It(i,t)}function zt(e,t,n){if(!e.eql(e.sqr(t),n))throw Error(`Cannot find square root`)}function Bt(e,t){let n=(e.ORDER+Dt)/At,r=e.pow(t,n);return zt(e,r,t),r}function Vt(e,t){let n=(e.ORDER-jt)/Nt,r=e.mul(t,Ot),i=e.pow(r,n),a=e.mul(t,i),o=e.mul(e.mul(a,Ot),i),s=e.mul(a,e.sub(o,e.ONE));return zt(e,s,t),s}function Ht(e){let t=Qt(e),n=Ut(e),r=n(t,t.neg(t.ONE)),i=n(t,r),a=n(t,t.neg(r)),o=(e+Mt)/Ft;return(e,t)=>{let n=e.pow(t,o),s=e.mul(n,r),c=e.mul(n,i),l=e.mul(n,a),u=e.eql(e.sqr(s),t),d=e.eql(e.sqr(c),t);n=e.cmov(n,s,u),s=e.cmov(l,c,d);let f=e.eql(e.sqr(s),t),p=e.cmov(n,s,f);return zt(e,p,t),p}}function Ut(e){if(e<kt)throw Error(`sqrt is not defined for small field`);let t=e-Dt,n=0;for(;t%Ot===Et;)t/=Ot,n++;let r=Ot,i=Qt(e);for(;Xt(i,r)===1;)if(r++>1e3)throw Error(`Cannot find square root: probably non-prime P`);if(n===1)return Bt;let a=i.pow(r,t),o=(t+Dt)/Ot;return function(e,r){if(e.is0(r))return r;if(Xt(e,r)!==1)throw Error(`Cannot find square root`);let i=n,s=e.mul(e.ONE,a),c=e.pow(r,t),l=e.pow(r,o);for(;!e.eql(c,e.ONE);){if(e.is0(c))return e.ZERO;let t=1,n=e.sqr(c);for(;!e.eql(n,e.ONE);)if(t++,n=e.sqr(n),t===i)throw Error(`Cannot find square root`);let r=Dt<<BigInt(i-t-1),a=e.pow(s,r);i=t,s=e.sqr(a),c=e.mul(c,s),l=e.mul(l,a)}return l}}function Wt(e){return e%At===kt?Bt:e%Nt===jt?Vt:e%Ft===Pt?Ht(e):Ut(e)}var Gt=(e,t)=>(It(e,t)&Dt)===Dt,Kt=[`create`,`isValid`,`is0`,`neg`,`inv`,`sqrt`,`sqr`,`eql`,`add`,`sub`,`mul`,`pow`,`div`,`addN`,`subN`,`mulN`,`sqrN`];function qt(e){return Ct(e,Kt.reduce((e,t)=>(e[t]=`function`,e),{ORDER:`bigint`,MASK:`bigint`,BYTES:`number`,BITS:`number`})),e}function Jt(e,t,n){if(n<Et)throw Error(`invalid exponent, negatives unsupported`);if(n===Et)return e.ONE;if(n===Dt)return t;let r=e.ONE,i=t;for(;n>Et;)n&Dt&&(r=e.mul(r,i)),i=e.sqr(i),n>>=Dt;return r}function Yt(e,t,n=!1){let r=Array(t.length).fill(n?e.ZERO:void 0),i=t.reduce((t,n,i)=>e.is0(n)?t:(r[i]=t,e.mul(t,n)),e.ONE),a=e.inv(i);return t.reduceRight((t,n,i)=>e.is0(n)?t:(r[i]=e.mul(t,r[i]),e.mul(t,n)),a),r}function Xt(e,t){let n=(e.ORDER-Dt)/Ot,r=e.pow(t,n),i=e.eql(r,e.ONE),a=e.eql(r,e.ZERO),o=e.eql(r,e.neg(e.ONE));if(!i&&!a&&!o)throw Error(`invalid Legendre symbol result`);return i?1:a?0:-1}function Zt(e,t){t!==void 0&&ee(t);let n=t===void 0?e.toString(2).length:t;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function Qt(e,t,n=!1,r={}){if(e<=Et)throw Error(`invalid field: expected ORDER > 0, got `+e);let i,a,o=!1,s;if(typeof t==`object`&&t){if(r.sqrt||n)throw Error(`cannot specify opts in two arguments`);let e=t;e.BITS&&(i=e.BITS),e.sqrt&&(a=e.sqrt),typeof e.isLE==`boolean`&&(n=e.isLE),typeof e.modFromBytes==`boolean`&&(o=e.modFromBytes),s=e.allowedLengths}else typeof t==`number`&&(i=t),r.sqrt&&(a=r.sqrt);let{nBitLength:c,nByteLength:l}=Zt(e,i);if(l>2048)throw Error(`invalid field: expected ORDER of <= 2048 bytes`);let u,d=Object.freeze({ORDER:e,isLE:n,BITS:c,BYTES:l,MASK:xt(c),ZERO:Et,ONE:Dt,allowedLengths:s,create:t=>It(t,e),isValid:t=>{if(typeof t!=`bigint`)throw Error(`invalid field element: expected bigint, got `+typeof t);return Et<=t&&t<e},is0:e=>e===Et,isValidNot0:e=>!d.is0(e)&&d.isValid(e),isOdd:e=>(e&Dt)===Dt,neg:t=>It(-t,e),eql:(e,t)=>e===t,sqr:t=>It(t*t,e),add:(t,n)=>It(t+n,e),sub:(t,n)=>It(t-n,e),mul:(t,n)=>It(t*n,e),pow:(e,t)=>Jt(d,e,t),div:(t,n)=>It(t*Rt(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>Rt(t,e),sqrt:a||(t=>(u||=Wt(e),u(d,t))),toBytes:e=>n?pt(e,l):ft(e,l),fromBytes:(t,r=!0)=>{if(s){if(!s.includes(t.length)||t.length>l)throw Error(`Field.fromBytes: expected `+s+` bytes, got `+t.length);let e=new Uint8Array(l);e.set(t,n?0:e.length-t.length),t=e}if(t.length!==l)throw Error(`Field.fromBytes: expected `+l+` bytes, got `+t.length);let i=n?dt(t):ut(t);if(o&&(i=It(i,e)),!r&&!d.isValid(i))throw Error(`invalid field element: outside of range 0..ORDER`);return i},invertBatch:e=>Yt(d,e),cmov:(e,t,n)=>n?t:e});return Object.freeze(d)}function $t(e){if(typeof e!=`bigint`)throw Error(`field order must be bigint`);let t=e.toString(2).length;return Math.ceil(t/8)}function en(e){let t=$t(e);return t+Math.ceil(t/2)}function tn(e,t,n=!1){let r=e.length,i=$t(t),a=en(t);if(r<16||r<a||r>1024)throw Error(`expected `+a+`-1024 bytes of input, got `+r);let o=It(n?dt(e):ut(e),t-Dt)+Dt;return n?pt(o,i):ft(o,i)}var nn=BigInt(0),rn=BigInt(1);function an(e,t){let n=t.negate();return e?n:t}function on(e,t){let n=Yt(e.Fp,t.map(e=>e.Z));return t.map((t,r)=>e.fromAffine(t.toAffine(n[r])))}function sn(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw Error(`invalid window size, expected [1..`+t+`], got W=`+e)}function cn(e,t){sn(e,t);let n=Math.ceil(t/e)+1,r=2**(e-1),i=2**e;return{windows:n,windowSize:r,mask:xt(e),maxNumber:i,shiftBy:BigInt(e)}}function ln(e,t,n){let{windowSize:r,mask:i,maxNumber:a,shiftBy:o}=n,s=Number(e&i),c=e>>o;s>r&&(s-=a,c+=rn);let l=t*r,u=l+Math.abs(s)-1,d=s===0,f=s<0,p=t%2!=0;return{nextN:c,offset:u,isZero:d,isNeg:f,isNegF:p,offsetF:l}}function un(e,t){if(!Array.isArray(e))throw Error(`array expected`);e.forEach((e,n)=>{if(!(e instanceof t))throw Error(`invalid point at index `+n)})}function dn(e,t){if(!Array.isArray(e))throw Error(`array of scalars expected`);e.forEach((e,n)=>{if(!t.isValid(e))throw Error(`invalid scalar at index `+n)})}var fn=new WeakMap,pn=new WeakMap;function mn(e){return pn.get(e)||1}function hn(e){if(e!==nn)throw Error(`invalid wNAF`)}var gn=class{constructor(e,t){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=t}_unsafeLadder(e,t,n=this.ZERO){let r=e;for(;t>nn;)t&rn&&(n=n.add(r)),r=r.double(),t>>=rn;return n}precomputeWindow(e,t){let{windows:n,windowSize:r}=cn(t,this.bits),i=[],a=e,o=a;for(let e=0;e<n;e++){o=a,i.push(o);for(let e=1;e<r;e++)o=o.add(a),i.push(o);a=o.double()}return i}wNAF(e,t,n){if(!this.Fn.isValid(n))throw Error(`invalid scalar`);let r=this.ZERO,i=this.BASE,a=cn(e,this.bits);for(let e=0;e<a.windows;e++){let{nextN:o,offset:s,isZero:c,isNeg:l,isNegF:u,offsetF:d}=ln(n,e,a);n=o,c?i=i.add(an(u,t[d])):r=r.add(an(l,t[s]))}return hn(n),{p:r,f:i}}wNAFUnsafe(e,t,n,r=this.ZERO){let i=cn(e,this.bits);for(let e=0;e<i.windows&&n!==nn;e++){let{nextN:a,offset:o,isZero:s,isNeg:c}=ln(n,e,i);if(n=a,!s){let e=t[o];r=r.add(c?e.negate():e)}}return hn(n),r}getPrecomputes(e,t,n){let r=fn.get(t);return r||(r=this.precomputeWindow(t,e),e!==1&&(typeof n==`function`&&(r=n(r)),fn.set(t,r))),r}cached(e,t,n){let r=mn(e);return this.wNAF(r,this.getPrecomputes(r,e,n),t)}unsafe(e,t,n,r){let i=mn(e);return i===1?this._unsafeLadder(e,t,r):this.wNAFUnsafe(i,this.getPrecomputes(i,e,n),t,r)}createCache(e,t){sn(t,this.bits),pn.set(e,t),fn.delete(e)}hasCache(e){return mn(e)!==1}};function _n(e,t,n,r){let i=t,a=e.ZERO,o=e.ZERO;for(;n>nn||r>nn;)n&rn&&(a=a.add(i)),r&rn&&(o=o.add(i)),i=i.double(),n>>=rn,r>>=rn;return{p1:a,p2:o}}function vn(e,t,n,r){un(n,e),dn(r,t);let i=n.length,a=r.length;if(i!==a)throw Error(`arrays of points and scalars must have equal length`);let o=e.ZERO,s=bt(BigInt(i)),c=1;s>12?c=s-3:s>4?c=s-2:s>0&&(c=2);let l=xt(c),u=Array(Number(l)+1).fill(o),d=Math.floor((t.BITS-1)/c)*c,f=o;for(let e=d;e>=0;e-=c){u.fill(o);for(let t=0;t<a;t++){let i=r[t],a=Number(i>>BigInt(e)&l);u[a]=u[a].add(n[t])}let t=o;for(let e=u.length-1,n=o;e>0;e--)n=n.add(u[e]),t=t.add(n);if(f=f.add(t),e!==0)for(let e=0;e<c;e++)f=f.double()}return f}function yn(e,t,n){if(t){if(t.ORDER!==e)throw Error(`Field.ORDER must match order: Fp == p, Fn == n`);return qt(t),t}else return Qt(e,{isLE:n})}function bn(e,t,n={},r){if(r===void 0&&(r=e===`edwards`),!t||typeof t!=`object`)throw Error(`expected valid ${e} CURVE object`);for(let e of[`p`,`n`,`h`]){let n=t[e];if(!(typeof n==`bigint`&&n>nn))throw Error(`CURVE.${e} must be positive bigint`)}let i=yn(t.p,n.Fp,r),a=yn(t.n,n.Fn,r),o=[`Gx`,`Gy`,`a`,e===`weierstrass`?`b`:`d`];for(let e of o)if(!i.isValid(t[e]))throw Error(`CURVE.${e} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:i,Fn:a}}var xn=BigInt(0),Sn=BigInt(1),Cn=BigInt(2),wn=BigInt(8);function Tn(e,t,n,r){let i=e.sqr(n),a=e.sqr(r),o=e.add(e.mul(t.a,i),a),s=e.add(e.ONE,e.mul(t.d,e.mul(i,a)));return e.eql(o,s)}function En(e,t={}){let n=bn(`edwards`,e,t,t.FpFnLE),{Fp:r,Fn:i}=n,a=n.CURVE,{h:o}=a;Ct(t,{},{uvRatio:`function`});let s=Cn<<BigInt(i.BYTES*8)-Sn,c=e=>r.create(e),l=t.uvRatio||((e,t)=>{try{return{isValid:!0,value:r.sqrt(r.div(e,t))}}catch{return{isValid:!1,value:xn}}});if(!Tn(r,a,a.Gx,a.Gy))throw Error(`bad curve params: generator point`);function u(e,t,n=!1){let r=n?Sn:xn;return yt(`coordinate `+e,t,r,s),t}function d(e){if(!(e instanceof m))throw Error(`ExtendedPoint expected`)}let f=Tt((e,t)=>{let{X:n,Y:i,Z:a}=e,o=e.is0();t??=o?wn:r.inv(a);let s=c(n*t),l=c(i*t),u=r.mul(a,t);if(o)return{x:xn,y:Sn};if(u!==Sn)throw Error(`invZ was invalid`);return{x:s,y:l}}),p=Tt(e=>{let{a:t,d:n}=a;if(e.is0())throw Error(`bad point: ZERO`);let{X:r,Y:i,Z:o,T:s}=e,l=c(r*r),u=c(i*i),d=c(o*o),f=c(d*d);if(c(d*c(c(l*t)+u))!==c(f+c(n*c(l*u))))throw Error(`bad point: equation left != right (1)`);if(c(r*i)!==c(o*s))throw Error(`bad point: equation left != right (2)`);return!0});class m{constructor(e,t,n,r){this.X=u(`x`,e),this.Y=u(`y`,t),this.Z=u(`z`,n,!0),this.T=u(`t`,r),Object.freeze(this)}static CURVE(){return a}static fromAffine(e){if(e instanceof m)throw Error(`extended point not allowed`);let{x:t,y:n}=e||{};return u(`x`,t),u(`y`,n),new m(t,n,Sn,c(t*n))}static fromBytes(e,t=!1){let n=r.BYTES,{a:i,d:o}=a;e=gt(st(e,n,`point`)),ot(t,`zip215`);let u=gt(e),d=e[n-1];u[n-1]=d&-129;let f=dt(u);yt(`point.y`,f,xn,t?s:r.ORDER);let p=c(f*f),{isValid:h,value:g}=l(c(p-Sn),c(o*p-i));if(!h)throw Error(`bad point: invalid y coordinate`);let _=(g&Sn)===Sn,v=(d&128)!=0;if(!t&&g===xn&&v)throw Error(`bad point: x=0 and x_0=1`);return v!==_&&(g=c(-g)),m.fromAffine({x:g,y:f})}static fromHex(e,t=!1){return m.fromBytes(mt(`point`,e),t)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(e=8,t=!0){return h.createCache(this,e),t||this.multiply(Cn),this}assertValidity(){p(this)}equals(e){d(e);let{X:t,Y:n,Z:r}=this,{X:i,Y:a,Z:o}=e,s=c(t*o),l=c(i*r),u=c(n*o),f=c(a*r);return s===l&&u===f}is0(){return this.equals(m.ZERO)}negate(){return new m(c(-this.X),this.Y,this.Z,c(-this.T))}double(){let{a:e}=a,{X:t,Y:n,Z:r}=this,i=c(t*t),o=c(n*n),s=c(Cn*c(r*r)),l=c(e*i),u=t+n,d=c(c(u*u)-i-o),f=l+o,p=f-s,h=l-o,g=c(d*p),_=c(f*h),v=c(d*h);return new m(g,_,c(p*f),v)}add(e){d(e);let{a:t,d:n}=a,{X:r,Y:i,Z:o,T:s}=this,{X:l,Y:u,Z:f,T:p}=e,h=c(r*l),g=c(i*u),_=c(s*n*p),v=c(o*f),y=c((r+i)*(l+u)-h-g),b=v-_,x=v+_,S=c(g-t*h),C=c(y*b),w=c(x*S),T=c(y*S);return new m(C,w,c(b*x),T)}subtract(e){return this.add(e.negate())}multiply(e){if(!i.isValidNot0(e))throw Error(`invalid scalar: expected 1 <= sc < curve.n`);let{p:t,f:n}=h.cached(this,e,e=>on(m,e));return on(m,[t,n])[0]}multiplyUnsafe(e,t=m.ZERO){if(!i.isValid(e))throw Error(`invalid scalar: expected 0 <= sc < curve.n`);return e===xn?m.ZERO:this.is0()||e===Sn?this:h.unsafe(this,e,e=>on(m,e),t)}isSmallOrder(){return this.multiplyUnsafe(o).is0()}isTorsionFree(){return h.unsafe(this,a.n).is0()}toAffine(e){return f(this,e)}clearCofactor(){return o===Sn?this:this.multiplyUnsafe(o)}toBytes(){let{x:e,y:t}=this.toAffine(),n=r.toBytes(t);return n[n.length-1]|=e&Sn?128:0,n}toHex(){return fe(this.toBytes())}toString(){return`<Point ${this.is0()?`ZERO`:this.toHex()}>`}get ex(){return this.X}get ey(){return this.Y}get ez(){return this.Z}get et(){return this.T}static normalizeZ(e){return on(m,e)}static msm(e,t){return vn(m,i,e,t)}_setWindowSize(e){this.precompute(e)}toRawBytes(){return this.toBytes()}}m.BASE=new m(a.Gx,a.Gy,Sn,c(a.Gx*a.Gy)),m.ZERO=new m(xn,Sn,Sn,xn),m.Fp=r,m.Fn=i;let h=new gn(m,i.BITS);return m.BASE.precompute(8),m}var Dn=class{constructor(e){this.ep=e}static fromBytes(e){wt()}static fromHex(e){wt()}get x(){return this.toAffine().x}get y(){return this.toAffine().y}clearCofactor(){return this}assertValidity(){this.ep.assertValidity()}toAffine(e){return this.ep.toAffine(e)}toHex(){return fe(this.toBytes())}toString(){return this.toHex()}isTorsionFree(){return!0}isSmallOrder(){return!1}add(e){return this.assertSame(e),this.init(this.ep.add(e.ep))}subtract(e){return this.assertSame(e),this.init(this.ep.subtract(e.ep))}multiply(e){return this.init(this.ep.multiply(e))}multiplyUnsafe(e){return this.init(this.ep.multiplyUnsafe(e))}double(){return this.init(this.ep.double())}negate(){return this.init(this.ep.negate())}precompute(e,t){return this.init(this.ep.precompute(e,t))}toRawBytes(){return this.toBytes()}};function On(e,t,n={}){if(typeof t!=`function`)throw Error(`"hash" function param is required`);Ct(n,{},{adjustScalarBytes:`function`,randomBytes:`function`,domain:`function`,prehash:`function`,mapToCurve:`function`});let{prehash:r}=n,{BASE:i,Fp:a,Fn:o}=e,s=n.randomBytes||be,c=n.adjustScalarBytes||(e=>e),l=n.domain||((e,t,n)=>{if(ot(n,`phflag`),t.length||n)throw Error(`Contexts/pre-hash are not supported`);return e});function u(e){return o.create(dt(e))}function d(e){let n=y.secretKey;e=mt(`private key`,e,n);let r=mt(`hashed private key`,t(e),2*n),i=c(r.slice(0,n));return{head:i,prefix:r.slice(n,2*n),scalar:u(i)}}function f(e){let{head:t,prefix:n,scalar:r}=d(e),a=i.multiply(r);return{head:t,prefix:n,scalar:r,point:a,pointBytes:a.toBytes()}}function p(e){return f(e).pointBytes}function m(e=Uint8Array.of(),...n){return u(t(l(_e(...n),mt(`context`,e),!!r)))}function h(e,t,n={}){e=mt(`message`,e),r&&(e=r(e));let{prefix:a,scalar:s,pointBytes:c}=f(t),l=m(n.context,a,e),u=i.multiply(l).toBytes(),d=m(n.context,u,c,e),p=o.create(l+d*s);if(!o.isValid(p))throw Error(`sign failed: invalid s`);return st(_e(u,o.toBytes(p)),y.signature,`result`)}let g={zip215:!0};function _(t,n,a,o=g){let{context:s,zip215:c}=o,l=y.signature;t=mt(`signature`,t,l),n=mt(`message`,n),a=mt(`publicKey`,a,y.publicKey),c!==void 0&&ot(c,`zip215`),r&&(n=r(n));let u=l/2,d=t.subarray(0,u),f=dt(t.subarray(u,l)),p,h,_;try{p=e.fromBytes(a,c),h=e.fromBytes(d,c),_=i.multiplyUnsafe(f)}catch{return!1}if(!c&&p.isSmallOrder())return!1;let v=m(s,h.toBytes(),p.toBytes(),n);return h.add(p.multiplyUnsafe(v)).subtract(_).clearCofactor().is0()}let v=a.BYTES,y={secretKey:v,publicKey:v,signature:2*v,seed:v};function b(e=s(y.seed)){return st(e,y.seed,`seed`)}function x(e){let t=w.randomSecretKey(e);return{secretKey:t,publicKey:p(t)}}function S(e){return A(e)&&e.length===o.BYTES}function C(t,n){try{return!!e.fromBytes(t,n)}catch{return!1}}let w={getExtendedPublicKey:f,randomSecretKey:b,isValidSecretKey:S,isValidPublicKey:C,toMontgomery(t){let{y:n}=e.fromBytes(t),r=y.publicKey,i=r===32;if(!i&&r!==57)throw Error(`only defined for 25519 and 448`);let o=i?a.div(Sn+n,Sn-n):a.div(n-Sn,n+Sn);return a.toBytes(o)},toMontgomerySecret(e){let n=y.secretKey;return st(e,n),c(t(e.subarray(0,n))).subarray(0,n)},randomPrivateKey:b,precompute(t=8,n=e.BASE){return n.precompute(t,!1)}};return Object.freeze({keygen:x,getPublicKey:p,sign:h,verify:_,utils:w,Point:e,lengths:y})}function kn(e){let t={a:e.a,d:e.d,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},n={Fp:e.Fp,Fn:Qt(t.n,e.nBitLength,!0),uvRatio:e.uvRatio},r={randomBytes:e.randomBytes,adjustScalarBytes:e.adjustScalarBytes,domain:e.domain,prehash:e.prehash,mapToCurve:e.mapToCurve};return{CURVE:t,curveOpts:n,hash:e.hash,eddsaOpts:r}}function An(e,t){let n=t.Point;return Object.assign({},t,{ExtendedPoint:n,CURVE:e,nBitLength:n.Fn.BITS,nByteLength:n.Fn.BYTES})}function jn(e){let{CURVE:t,curveOpts:n,hash:r,eddsaOpts:i}=kn(e);return An(e,On(En(t,n),r,i))}var Mn=BigInt(0),Nn=BigInt(1),Pn=BigInt(2),Fn=BigInt(5),In=BigInt(8),Ln=BigInt(`0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed`),Rn={p:Ln,n:BigInt(`0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed`),h:In,a:BigInt(`0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec`),d:BigInt(`0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3`),Gx:BigInt(`0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a`),Gy:BigInt(`0x6666666666666666666666666666666666666666666666666666666666666658`)};function zn(e){let t=BigInt(10),n=BigInt(20),r=BigInt(40),i=BigInt(80),a=Ln,o=e*e%a*e%a,s=Lt(Lt(o,Pn,a)*o%a,Nn,a)*e%a,c=Lt(s,Fn,a)*s%a,l=Lt(c,t,a)*c%a,u=Lt(l,n,a)*l%a,d=Lt(u,r,a)*u%a;return{pow_p_5_8:Lt(Lt(Lt(Lt(d,i,a)*d%a,i,a)*d%a,t,a)*c%a,Pn,a)*e%a,b2:o}}function Bn(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var Vn=BigInt(`19681161376707505956807079304988542015446066515923890162744021073123829784752`);function Hn(e,t){let n=Ln,r=It(t*t*t,n),i=zn(e*It(r*r*t,n)).pow_p_5_8,a=It(e*r*i,n),o=It(t*a*a,n),s=a,c=It(a*Vn,n),l=o===e,u=o===It(-e,n),d=o===It(-e*Vn,n);return l&&(a=s),(u||d)&&(a=c),Gt(a,n)&&(a=It(-a,n)),{isValid:l||u,value:a}}var Un=Qt(Rn.p,{isLE:!0}),Wn=Qt(Rn.n,{isLE:!0}),Gn=jn({...Rn,Fp:Un,hash:et,adjustScalarBytes:Bn,uvRatio:Hn}),Kn=Vn,qn=BigInt(`25063068953384623474111414158702152701244531502492656460079210482610430750235`),Jn=BigInt(`54469307008909316920995813868745141605393597292927456921205312896311721017578`),Yn=BigInt(`1159843021668779879193775521855586647937357759715417654439879720876111806838`),Xn=BigInt(`40440834346308536858101042469323190826248399146238708352240133220865137265952`),Zn=e=>Hn(Nn,e),Qn=BigInt(`0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff`),$n=e=>Gn.Point.Fp.create(dt(e)&Qn);function er(e){let{d:t}=Rn,n=Ln,r=e=>Un.create(e),i=r(Kn*e*e),a=r((i+Nn)*Yn),o=BigInt(-1),s=r((o-t*i)*r(i+t)),{isValid:c,value:l}=Hn(a,s),u=r(l*e);Gt(u,n)||(u=r(-u)),c||(l=u),c||(o=i);let d=r(o*(i-Nn)*Xn-s),f=l*l,p=r((l+l)*s),m=r(d*qn),h=r(Nn-f),g=r(Nn+f);return new Gn.Point(r(p*g),r(h*m),r(m*g),r(p*h))}function tr(e){j(e,64);let t=er($n(e.subarray(0,32))),n=er($n(e.subarray(32,64)));return new nr(t.add(n))}var nr=class e extends Dn{constructor(e){super(e)}static fromAffine(t){return new e(Gn.Point.fromAffine(t))}assertSame(t){if(!(t instanceof e))throw Error(`RistrettoPoint expected`)}init(t){return new e(t)}static hashToCurve(e){return tr(mt(`ristrettoHash`,e,64))}static fromBytes(t){j(t,32);let{a:n,d:r}=Rn,i=Ln,a=e=>Un.create(e),o=$n(t);if(!ht(Un.toBytes(o),t)||Gt(o,i))throw Error(`invalid ristretto255 encoding 1`);let s=a(o*o),c=a(Nn+n*s),l=a(Nn-n*s),u=a(c*c),d=a(l*l),f=a(n*r*u-d),{isValid:p,value:m}=Zn(a(f*d)),h=a(m*l),g=a(m*h*f),_=a((o+o)*h);Gt(_,i)&&(_=a(-_));let v=a(c*g),y=a(_*v);if(!p||Gt(y,i)||v===Mn)throw Error(`invalid ristretto255 encoding 2`);return new e(new Gn.Point(_,v,Nn,y))}static fromHex(t){return e.fromBytes(mt(`ristrettoHex`,t,32))}static msm(t,n){return vn(e,Gn.Point.Fn,t,n)}toBytes(){let{X:e,Y:t,Z:n,T:r}=this.ep,i=Ln,a=e=>Un.create(e),o=a(a(n+t)*a(n-t)),s=a(e*t),{value:c}=Zn(a(o*a(s*s))),l=a(c*o),u=a(c*s),d=a(l*u*r),f;if(Gt(r*d,i)){let n=a(t*Kn),r=a(e*Kn);e=n,t=r,f=a(l*Jn)}else f=u;Gt(e*d,i)&&(t=a(-t));let p=a((n-t)*f);return Gt(p,i)&&(p=a(-p)),Un.toBytes(p)}equals(e){this.assertSame(e);let{X:t,Y:n}=this.ep,{X:r,Y:i}=e.ep,a=e=>Un.create(e),o=a(t*i)===a(n*r),s=a(n*i)===a(t*r);return o||s}is0(){return this.equals(e.ZERO)}};nr.BASE=new nr(Gn.Point.BASE),nr.ZERO=new nr(Gn.Point.ZERO),nr.Fp=Un,nr.Fn=Wn;var rr=i(((e,t)=>{(function(e,t){function n(e,t){if(!e)throw Error(t||`Assertion failed`)}function r(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}function i(e,t,n){if(i.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,e!==null&&((t===`le`||t===`be`)&&(n=t,t=10),this._init(e||0,t||10,n||`be`))}typeof e==`object`?e.exports=i:t.BN=i,i.BN=i,i.wordSize=26;var o;try{o=typeof window<`u`&&window.Buffer!==void 0?window.Buffer:a().Buffer}catch{}i.isBN=function(e){return e instanceof i?!0:typeof e==`object`&&!!e&&e.constructor.wordSize===i.wordSize&&Array.isArray(e.words)},i.max=function(e,t){return e.cmp(t)>0?e:t},i.min=function(e,t){return e.cmp(t)<0?e:t},i.prototype._init=function(e,t,r){if(typeof e==`number`)return this._initNumber(e,t,r);if(typeof e==`object`)return this._initArray(e,t,r);t===`hex`&&(t=16),n(t===(t|0)&&t>=2&&t<=36),e=e.toString().replace(/\s+/g,``);var i=0;e[0]===`-`&&(i++,this.negative=1),i<e.length&&(t===16?this._parseHex(e,i,r):(this._parseBase(e,t,i),r===`le`&&this._initArray(this.toArray(),t,r)))},i.prototype._initNumber=function(e,t,r){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[e&67108863],this.length=1):e<4503599627370496?(this.words=[e&67108863,e/67108864&67108863],this.length=2):(n(e<9007199254740992),this.words=[e&67108863,e/67108864&67108863,1],this.length=3),r===`le`&&this._initArray(this.toArray(),t,r)},i.prototype._initArray=function(e,t,r){if(n(typeof e.length==`number`),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var a,o,s=0;if(r===`be`)for(i=e.length-1,a=0;i>=0;i-=3)o=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[a]|=o<<s&67108863,this.words[a+1]=o>>>26-s&67108863,s+=24,s>=26&&(s-=26,a++);else if(r===`le`)for(i=0,a=0;i<e.length;i+=3)o=e[i]|e[i+1]<<8|e[i+2]<<16,this.words[a]|=o<<s&67108863,this.words[a+1]=o>>>26-s&67108863,s+=24,s>=26&&(s-=26,a++);return this._strip()};function s(e,t){var r=e.charCodeAt(t);if(r>=48&&r<=57)return r-48;if(r>=65&&r<=70)return r-55;if(r>=97&&r<=102)return r-87;n(!1,`Invalid character in `+e)}function c(e,t,n){var r=s(e,n);return n-1>=t&&(r|=s(e,n-1)<<4),r}i.prototype._parseHex=function(e,t,n){this.length=Math.ceil((e.length-t)/6),this.words=Array(this.length);for(var r=0;r<this.length;r++)this.words[r]=0;var i=0,a=0,o;if(n===`be`)for(r=e.length-1;r>=t;r-=2)o=c(e,t,r)<<i,this.words[a]|=o&67108863,i>=18?(i-=18,a+=1,this.words[a]|=o>>>26):i+=8;else for(r=(e.length-t)%2==0?t+1:t;r<e.length;r+=2)o=c(e,t,r)<<i,this.words[a]|=o&67108863,i>=18?(i-=18,a+=1,this.words[a]|=o>>>26):i+=8;this._strip()};function l(e,t,r,i){for(var a=0,o=0,s=Math.min(e.length,r),c=t;c<s;c++){var l=e.charCodeAt(c)-48;a*=i,o=l>=49?l-49+10:l>=17?l-17+10:l,n(l>=0&&o<i,`Invalid character`),a+=o}return a}i.prototype._parseBase=function(e,t,n){this.words=[0],this.length=1;for(var r=0,i=1;i<=67108863;i*=t)r++;r--,i=i/t|0;for(var a=e.length-n,o=a%r,s=Math.min(a,a-o)+n,c=0,u=n;u<s;u+=r)c=l(e,u,u+r,t),this.imuln(i),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c);if(o!==0){var d=1;for(c=l(e,u,e.length,t),u=0;u<o;u++)d*=t;this.imuln(d),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c)}this._strip()},i.prototype.copy=function(e){e.words=Array(this.length);for(var t=0;t<this.length;t++)e.words[t]=this.words[t];e.length=this.length,e.negative=this.negative,e.red=this.red};function u(e,t){e.words=t.words,e.length=t.length,e.negative=t.negative,e.red=t.red}if(i.prototype._move=function(e){u(e,this)},i.prototype.clone=function(){var e=new i(null);return this.copy(e),e},i.prototype._expand=function(e){for(;this.length<e;)this.words[this.length++]=0;return this},i.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},i.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<`u`&&typeof Symbol.for==`function`)try{i.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=d}catch{i.prototype.inspect=d}else i.prototype.inspect=d;function d(){return(this.red?`<BN-R: `:`<BN: `)+this.toString(16)+`>`}var f=`.0.00.000.0000.00000.000000.0000000.00000000.000000000.0000000000.00000000000.000000000000.0000000000000.00000000000000.000000000000000.0000000000000000.00000000000000000.000000000000000000.0000000000000000000.00000000000000000000.000000000000000000000.0000000000000000000000.00000000000000000000000.000000000000000000000000.0000000000000000000000000`.split(`.`),p=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],m=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];i.prototype.toString=function(e,t){e||=10,t=t|0||1;var r;if(e===16||e===`hex`){r=``;for(var i=0,a=0,o=0;o<this.length;o++){var s=this.words[o],c=((s<<i|a)&16777215).toString(16);a=s>>>24-i&16777215,i+=2,i>=26&&(i-=26,o--),r=a!==0||o!==this.length-1?f[6-c.length]+c+r:c+r}for(a!==0&&(r=a.toString(16)+r);r.length%t!==0;)r=`0`+r;return this.negative!==0&&(r=`-`+r),r}if(e===(e|0)&&e>=2&&e<=36){var l=p[e],u=m[e];r=``;var d=this.clone();for(d.negative=0;!d.isZero();){var h=d.modrn(u).toString(e);d=d.idivn(u),r=d.isZero()?h+r:f[l-h.length]+h+r}for(this.isZero()&&(r=`0`+r);r.length%t!==0;)r=`0`+r;return this.negative!==0&&(r=`-`+r),r}n(!1,`Base should be between 2 and 36`)},i.prototype.toNumber=function(){var e=this.words[0];return this.length===2?e+=this.words[1]*67108864:this.length===3&&this.words[2]===1?e+=4503599627370496+this.words[1]*67108864:this.length>2&&n(!1,`Number can only safely store up to 53 bits`),this.negative===0?e:-e},i.prototype.toJSON=function(){return this.toString(16,2)},o&&(i.prototype.toBuffer=function(e,t){return this.toArrayLike(o,e,t)}),i.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)};var h=function(e,t){return e.allocUnsafe?e.allocUnsafe(t):new e(t)};i.prototype.toArrayLike=function(e,t,r){this._strip();var i=this.byteLength(),a=r||Math.max(1,i);n(i<=a,`byte array longer than desired length`),n(a>0,`Requested array length <= 0`);var o=h(e,a),s=t===`le`?`LE`:`BE`;return this[`_toArrayLike`+s](o,i),o},i.prototype._toArrayLikeLE=function(e,t){for(var n=0,r=0,i=0,a=0;i<this.length;i++){var o=this.words[i]<<a|r;e[n++]=o&255,n<e.length&&(e[n++]=o>>8&255),n<e.length&&(e[n++]=o>>16&255),a===6?(n<e.length&&(e[n++]=o>>24&255),r=0,a=0):(r=o>>>24,a+=2)}if(n<e.length)for(e[n++]=r;n<e.length;)e[n++]=0},i.prototype._toArrayLikeBE=function(e,t){for(var n=e.length-1,r=0,i=0,a=0;i<this.length;i++){var o=this.words[i]<<a|r;e[n--]=o&255,n>=0&&(e[n--]=o>>8&255),n>=0&&(e[n--]=o>>16&255),a===6?(n>=0&&(e[n--]=o>>24&255),r=0,a=0):(r=o>>>24,a+=2)}if(n>=0)for(e[n--]=r;n>=0;)e[n--]=0},Math.clz32?i.prototype._countBits=function(e){return 32-Math.clz32(e)}:i.prototype._countBits=function(e){var t=e,n=0;return t>=4096&&(n+=13,t>>>=13),t>=64&&(n+=7,t>>>=7),t>=8&&(n+=4,t>>>=4),t>=2&&(n+=2,t>>>=2),n+t},i.prototype._zeroBits=function(e){if(e===0)return 26;var t=e,n=0;return t&8191||(n+=13,t>>>=13),t&127||(n+=7,t>>>=7),t&15||(n+=4,t>>>=4),t&3||(n+=2,t>>>=2),t&1||n++,n},i.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return(this.length-1)*26+t};function g(e){for(var t=Array(e.bitLength()),n=0;n<t.length;n++){var r=n/26|0,i=n%26;t[n]=e.words[r]>>>i&1}return t}i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;t<this.length;t++){var n=this._zeroBits(this.words[t]);if(e+=n,n!==26)break}return e},i.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},i.prototype.toTwos=function(e){return this.negative===0?this.clone():this.abs().inotn(e).iaddn(1)},i.prototype.fromTwos=function(e){return this.testn(e-1)?this.notn(e).iaddn(1).ineg():this.clone()},i.prototype.isNeg=function(){return this.negative!==0},i.prototype.neg=function(){return this.clone().ineg()},i.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},i.prototype.iuor=function(e){for(;this.length<e.length;)this.words[this.length++]=0;for(var t=0;t<e.length;t++)this.words[t]=this.words[t]|e.words[t];return this._strip()},i.prototype.ior=function(e){return n((this.negative|e.negative)===0),this.iuor(e)},i.prototype.or=function(e){return this.length>e.length?this.clone().ior(e):e.clone().ior(this)},i.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},i.prototype.iuand=function(e){for(var t=this.length>e.length?e:this,n=0;n<t.length;n++)this.words[n]=this.words[n]&e.words[n];return this.length=t.length,this._strip()},i.prototype.iand=function(e){return n((this.negative|e.negative)===0),this.iuand(e)},i.prototype.and=function(e){return this.length>e.length?this.clone().iand(e):e.clone().iand(this)},i.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},i.prototype.iuxor=function(e){var t,n;this.length>e.length?(t=this,n=e):(t=e,n=this);for(var r=0;r<n.length;r++)this.words[r]=t.words[r]^n.words[r];if(this!==t)for(;r<t.length;r++)this.words[r]=t.words[r];return this.length=t.length,this._strip()},i.prototype.ixor=function(e){return n((this.negative|e.negative)===0),this.iuxor(e)},i.prototype.xor=function(e){return this.length>e.length?this.clone().ixor(e):e.clone().ixor(this)},i.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},i.prototype.inotn=function(e){n(typeof e==`number`&&e>=0);var t=Math.ceil(e/26)|0,r=e%26;this._expand(t),r>0&&t--;for(var i=0;i<t;i++)this.words[i]=~this.words[i]&67108863;return r>0&&(this.words[i]=~this.words[i]&67108863>>26-r),this._strip()},i.prototype.notn=function(e){return this.clone().inotn(e)},i.prototype.setn=function(e,t){n(typeof e==`number`&&e>=0);var r=e/26|0,i=e%26;return this._expand(r+1),t?this.words[r]=this.words[r]|1<<i:this.words[r]=this.words[r]&~(1<<i),this._strip()},i.prototype.iadd=function(e){var t;if(this.negative!==0&&e.negative===0)return this.negative=0,t=this.isub(e),this.negative^=1,this._normSign();if(this.negative===0&&e.negative!==0)return e.negative=0,t=this.isub(e),e.negative=1,t._normSign();var n,r;this.length>e.length?(n=this,r=e):(n=e,r=this);for(var i=0,a=0;a<r.length;a++)t=(n.words[a]|0)+(r.words[a]|0)+i,this.words[a]=t&67108863,i=t>>>26;for(;i!==0&&a<n.length;a++)t=(n.words[a]|0)+i,this.words[a]=t&67108863,i=t>>>26;if(this.length=n.length,i!==0)this.words[this.length]=i,this.length++;else if(n!==this)for(;a<n.length;a++)this.words[a]=n.words[a];return this},i.prototype.add=function(e){var t;return e.negative!==0&&this.negative===0?(e.negative=0,t=this.sub(e),e.negative^=1,t):e.negative===0&&this.negative!==0?(this.negative=0,t=e.sub(this),this.negative=1,t):this.length>e.length?this.clone().iadd(e):e.clone().iadd(this)},i.prototype.isub=function(e){if(e.negative!==0){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var n=this.cmp(e);if(n===0)return this.negative=0,this.length=1,this.words[0]=0,this;var r,i;n>0?(r=this,i=e):(r=e,i=this);for(var a=0,o=0;o<i.length;o++)t=(r.words[o]|0)-(i.words[o]|0)+a,a=t>>26,this.words[o]=t&67108863;for(;a!==0&&o<r.length;o++)t=(r.words[o]|0)+a,a=t>>26,this.words[o]=t&67108863;if(a===0&&o<r.length&&r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this.length=Math.max(this.length,o),r!==this&&(this.negative=1),this._strip()},i.prototype.sub=function(e){return this.clone().isub(e)};function _(e,t,n){n.negative=t.negative^e.negative;var r=e.length+t.length|0;n.length=r,r=r-1|0;var i=e.words[0]|0,a=t.words[0]|0,o=i*a,s=o&67108863,c=o/67108864|0;n.words[0]=s;for(var l=1;l<r;l++){for(var u=c>>>26,d=c&67108863,f=Math.min(l,t.length-1),p=Math.max(0,l-e.length+1);p<=f;p++){var m=l-p|0;i=e.words[m]|0,a=t.words[p]|0,o=i*a+d,u+=o/67108864|0,d=o&67108863}n.words[l]=d|0,c=u|0}return c===0?n.length--:n.words[l]=c|0,n._strip()}var v=function(e,t,n){var r=e.words,i=t.words,a=n.words,o=0,s,c,l,u=r[0]|0,d=u&8191,f=u>>>13,p=r[1]|0,m=p&8191,h=p>>>13,g=r[2]|0,_=g&8191,v=g>>>13,y=r[3]|0,b=y&8191,x=y>>>13,S=r[4]|0,C=S&8191,w=S>>>13,T=r[5]|0,E=T&8191,D=T>>>13,O=r[6]|0,k=O&8191,A=O>>>13,ee=r[7]|0,j=ee&8191,M=ee>>>13,te=r[8]|0,ne=te&8191,re=te>>>13,ie=r[9]|0,ae=ie&8191,N=ie>>>13,oe=i[0]|0,se=oe&8191,ce=oe>>>13,le=i[1]|0,ue=le&8191,de=le>>>13,fe=i[2]|0,P=fe&8191,pe=fe>>>13,me=i[3]|0,he=me&8191,ge=me>>>13,_e=i[4]|0,ve=_e&8191,ye=_e>>>13,be=i[5]|0,xe=be&8191,Se=be>>>13,Ce=i[6]|0,we=Ce&8191,Te=Ce>>>13,Ee=i[7]|0,De=Ee&8191,Oe=Ee>>>13,ke=i[8]|0,Ae=ke&8191,je=ke>>>13,Me=i[9]|0,Ne=Me&8191,Pe=Me>>>13;n.negative=e.negative^t.negative,n.length=19,s=Math.imul(d,se),c=Math.imul(d,ce),c=c+Math.imul(f,se)|0,l=Math.imul(f,ce);var Fe=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Fe>>>26)|0,Fe&=67108863,s=Math.imul(m,se),c=Math.imul(m,ce),c=c+Math.imul(h,se)|0,l=Math.imul(h,ce),s=s+Math.imul(d,ue)|0,c=c+Math.imul(d,de)|0,c=c+Math.imul(f,ue)|0,l=l+Math.imul(f,de)|0;var Ie=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,s=Math.imul(_,se),c=Math.imul(_,ce),c=c+Math.imul(v,se)|0,l=Math.imul(v,ce),s=s+Math.imul(m,ue)|0,c=c+Math.imul(m,de)|0,c=c+Math.imul(h,ue)|0,l=l+Math.imul(h,de)|0,s=s+Math.imul(d,P)|0,c=c+Math.imul(d,pe)|0,c=c+Math.imul(f,P)|0,l=l+Math.imul(f,pe)|0;var Le=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Le>>>26)|0,Le&=67108863,s=Math.imul(b,se),c=Math.imul(b,ce),c=c+Math.imul(x,se)|0,l=Math.imul(x,ce),s=s+Math.imul(_,ue)|0,c=c+Math.imul(_,de)|0,c=c+Math.imul(v,ue)|0,l=l+Math.imul(v,de)|0,s=s+Math.imul(m,P)|0,c=c+Math.imul(m,pe)|0,c=c+Math.imul(h,P)|0,l=l+Math.imul(h,pe)|0,s=s+Math.imul(d,he)|0,c=c+Math.imul(d,ge)|0,c=c+Math.imul(f,he)|0,l=l+Math.imul(f,ge)|0;var Re=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Re>>>26)|0,Re&=67108863,s=Math.imul(C,se),c=Math.imul(C,ce),c=c+Math.imul(w,se)|0,l=Math.imul(w,ce),s=s+Math.imul(b,ue)|0,c=c+Math.imul(b,de)|0,c=c+Math.imul(x,ue)|0,l=l+Math.imul(x,de)|0,s=s+Math.imul(_,P)|0,c=c+Math.imul(_,pe)|0,c=c+Math.imul(v,P)|0,l=l+Math.imul(v,pe)|0,s=s+Math.imul(m,he)|0,c=c+Math.imul(m,ge)|0,c=c+Math.imul(h,he)|0,l=l+Math.imul(h,ge)|0,s=s+Math.imul(d,ve)|0,c=c+Math.imul(d,ye)|0,c=c+Math.imul(f,ve)|0,l=l+Math.imul(f,ye)|0;var ze=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(ze>>>26)|0,ze&=67108863,s=Math.imul(E,se),c=Math.imul(E,ce),c=c+Math.imul(D,se)|0,l=Math.imul(D,ce),s=s+Math.imul(C,ue)|0,c=c+Math.imul(C,de)|0,c=c+Math.imul(w,ue)|0,l=l+Math.imul(w,de)|0,s=s+Math.imul(b,P)|0,c=c+Math.imul(b,pe)|0,c=c+Math.imul(x,P)|0,l=l+Math.imul(x,pe)|0,s=s+Math.imul(_,he)|0,c=c+Math.imul(_,ge)|0,c=c+Math.imul(v,he)|0,l=l+Math.imul(v,ge)|0,s=s+Math.imul(m,ve)|0,c=c+Math.imul(m,ye)|0,c=c+Math.imul(h,ve)|0,l=l+Math.imul(h,ye)|0,s=s+Math.imul(d,xe)|0,c=c+Math.imul(d,Se)|0,c=c+Math.imul(f,xe)|0,l=l+Math.imul(f,Se)|0;var Be=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Be>>>26)|0,Be&=67108863,s=Math.imul(k,se),c=Math.imul(k,ce),c=c+Math.imul(A,se)|0,l=Math.imul(A,ce),s=s+Math.imul(E,ue)|0,c=c+Math.imul(E,de)|0,c=c+Math.imul(D,ue)|0,l=l+Math.imul(D,de)|0,s=s+Math.imul(C,P)|0,c=c+Math.imul(C,pe)|0,c=c+Math.imul(w,P)|0,l=l+Math.imul(w,pe)|0,s=s+Math.imul(b,he)|0,c=c+Math.imul(b,ge)|0,c=c+Math.imul(x,he)|0,l=l+Math.imul(x,ge)|0,s=s+Math.imul(_,ve)|0,c=c+Math.imul(_,ye)|0,c=c+Math.imul(v,ve)|0,l=l+Math.imul(v,ye)|0,s=s+Math.imul(m,xe)|0,c=c+Math.imul(m,Se)|0,c=c+Math.imul(h,xe)|0,l=l+Math.imul(h,Se)|0,s=s+Math.imul(d,we)|0,c=c+Math.imul(d,Te)|0,c=c+Math.imul(f,we)|0,l=l+Math.imul(f,Te)|0;var Ve=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Ve>>>26)|0,Ve&=67108863,s=Math.imul(j,se),c=Math.imul(j,ce),c=c+Math.imul(M,se)|0,l=Math.imul(M,ce),s=s+Math.imul(k,ue)|0,c=c+Math.imul(k,de)|0,c=c+Math.imul(A,ue)|0,l=l+Math.imul(A,de)|0,s=s+Math.imul(E,P)|0,c=c+Math.imul(E,pe)|0,c=c+Math.imul(D,P)|0,l=l+Math.imul(D,pe)|0,s=s+Math.imul(C,he)|0,c=c+Math.imul(C,ge)|0,c=c+Math.imul(w,he)|0,l=l+Math.imul(w,ge)|0,s=s+Math.imul(b,ve)|0,c=c+Math.imul(b,ye)|0,c=c+Math.imul(x,ve)|0,l=l+Math.imul(x,ye)|0,s=s+Math.imul(_,xe)|0,c=c+Math.imul(_,Se)|0,c=c+Math.imul(v,xe)|0,l=l+Math.imul(v,Se)|0,s=s+Math.imul(m,we)|0,c=c+Math.imul(m,Te)|0,c=c+Math.imul(h,we)|0,l=l+Math.imul(h,Te)|0,s=s+Math.imul(d,De)|0,c=c+Math.imul(d,Oe)|0,c=c+Math.imul(f,De)|0,l=l+Math.imul(f,Oe)|0;var He=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(He>>>26)|0,He&=67108863,s=Math.imul(ne,se),c=Math.imul(ne,ce),c=c+Math.imul(re,se)|0,l=Math.imul(re,ce),s=s+Math.imul(j,ue)|0,c=c+Math.imul(j,de)|0,c=c+Math.imul(M,ue)|0,l=l+Math.imul(M,de)|0,s=s+Math.imul(k,P)|0,c=c+Math.imul(k,pe)|0,c=c+Math.imul(A,P)|0,l=l+Math.imul(A,pe)|0,s=s+Math.imul(E,he)|0,c=c+Math.imul(E,ge)|0,c=c+Math.imul(D,he)|0,l=l+Math.imul(D,ge)|0,s=s+Math.imul(C,ve)|0,c=c+Math.imul(C,ye)|0,c=c+Math.imul(w,ve)|0,l=l+Math.imul(w,ye)|0,s=s+Math.imul(b,xe)|0,c=c+Math.imul(b,Se)|0,c=c+Math.imul(x,xe)|0,l=l+Math.imul(x,Se)|0,s=s+Math.imul(_,we)|0,c=c+Math.imul(_,Te)|0,c=c+Math.imul(v,we)|0,l=l+Math.imul(v,Te)|0,s=s+Math.imul(m,De)|0,c=c+Math.imul(m,Oe)|0,c=c+Math.imul(h,De)|0,l=l+Math.imul(h,Oe)|0,s=s+Math.imul(d,Ae)|0,c=c+Math.imul(d,je)|0,c=c+Math.imul(f,Ae)|0,l=l+Math.imul(f,je)|0;var Ue=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Ue>>>26)|0,Ue&=67108863,s=Math.imul(ae,se),c=Math.imul(ae,ce),c=c+Math.imul(N,se)|0,l=Math.imul(N,ce),s=s+Math.imul(ne,ue)|0,c=c+Math.imul(ne,de)|0,c=c+Math.imul(re,ue)|0,l=l+Math.imul(re,de)|0,s=s+Math.imul(j,P)|0,c=c+Math.imul(j,pe)|0,c=c+Math.imul(M,P)|0,l=l+Math.imul(M,pe)|0,s=s+Math.imul(k,he)|0,c=c+Math.imul(k,ge)|0,c=c+Math.imul(A,he)|0,l=l+Math.imul(A,ge)|0,s=s+Math.imul(E,ve)|0,c=c+Math.imul(E,ye)|0,c=c+Math.imul(D,ve)|0,l=l+Math.imul(D,ye)|0,s=s+Math.imul(C,xe)|0,c=c+Math.imul(C,Se)|0,c=c+Math.imul(w,xe)|0,l=l+Math.imul(w,Se)|0,s=s+Math.imul(b,we)|0,c=c+Math.imul(b,Te)|0,c=c+Math.imul(x,we)|0,l=l+Math.imul(x,Te)|0,s=s+Math.imul(_,De)|0,c=c+Math.imul(_,Oe)|0,c=c+Math.imul(v,De)|0,l=l+Math.imul(v,Oe)|0,s=s+Math.imul(m,Ae)|0,c=c+Math.imul(m,je)|0,c=c+Math.imul(h,Ae)|0,l=l+Math.imul(h,je)|0,s=s+Math.imul(d,Ne)|0,c=c+Math.imul(d,Pe)|0,c=c+Math.imul(f,Ne)|0,l=l+Math.imul(f,Pe)|0;var We=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(We>>>26)|0,We&=67108863,s=Math.imul(ae,ue),c=Math.imul(ae,de),c=c+Math.imul(N,ue)|0,l=Math.imul(N,de),s=s+Math.imul(ne,P)|0,c=c+Math.imul(ne,pe)|0,c=c+Math.imul(re,P)|0,l=l+Math.imul(re,pe)|0,s=s+Math.imul(j,he)|0,c=c+Math.imul(j,ge)|0,c=c+Math.imul(M,he)|0,l=l+Math.imul(M,ge)|0,s=s+Math.imul(k,ve)|0,c=c+Math.imul(k,ye)|0,c=c+Math.imul(A,ve)|0,l=l+Math.imul(A,ye)|0,s=s+Math.imul(E,xe)|0,c=c+Math.imul(E,Se)|0,c=c+Math.imul(D,xe)|0,l=l+Math.imul(D,Se)|0,s=s+Math.imul(C,we)|0,c=c+Math.imul(C,Te)|0,c=c+Math.imul(w,we)|0,l=l+Math.imul(w,Te)|0,s=s+Math.imul(b,De)|0,c=c+Math.imul(b,Oe)|0,c=c+Math.imul(x,De)|0,l=l+Math.imul(x,Oe)|0,s=s+Math.imul(_,Ae)|0,c=c+Math.imul(_,je)|0,c=c+Math.imul(v,Ae)|0,l=l+Math.imul(v,je)|0,s=s+Math.imul(m,Ne)|0,c=c+Math.imul(m,Pe)|0,c=c+Math.imul(h,Ne)|0,l=l+Math.imul(h,Pe)|0;var Ge=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Ge>>>26)|0,Ge&=67108863,s=Math.imul(ae,P),c=Math.imul(ae,pe),c=c+Math.imul(N,P)|0,l=Math.imul(N,pe),s=s+Math.imul(ne,he)|0,c=c+Math.imul(ne,ge)|0,c=c+Math.imul(re,he)|0,l=l+Math.imul(re,ge)|0,s=s+Math.imul(j,ve)|0,c=c+Math.imul(j,ye)|0,c=c+Math.imul(M,ve)|0,l=l+Math.imul(M,ye)|0,s=s+Math.imul(k,xe)|0,c=c+Math.imul(k,Se)|0,c=c+Math.imul(A,xe)|0,l=l+Math.imul(A,Se)|0,s=s+Math.imul(E,we)|0,c=c+Math.imul(E,Te)|0,c=c+Math.imul(D,we)|0,l=l+Math.imul(D,Te)|0,s=s+Math.imul(C,De)|0,c=c+Math.imul(C,Oe)|0,c=c+Math.imul(w,De)|0,l=l+Math.imul(w,Oe)|0,s=s+Math.imul(b,Ae)|0,c=c+Math.imul(b,je)|0,c=c+Math.imul(x,Ae)|0,l=l+Math.imul(x,je)|0,s=s+Math.imul(_,Ne)|0,c=c+Math.imul(_,Pe)|0,c=c+Math.imul(v,Ne)|0,l=l+Math.imul(v,Pe)|0;var Ke=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Ke>>>26)|0,Ke&=67108863,s=Math.imul(ae,he),c=Math.imul(ae,ge),c=c+Math.imul(N,he)|0,l=Math.imul(N,ge),s=s+Math.imul(ne,ve)|0,c=c+Math.imul(ne,ye)|0,c=c+Math.imul(re,ve)|0,l=l+Math.imul(re,ye)|0,s=s+Math.imul(j,xe)|0,c=c+Math.imul(j,Se)|0,c=c+Math.imul(M,xe)|0,l=l+Math.imul(M,Se)|0,s=s+Math.imul(k,we)|0,c=c+Math.imul(k,Te)|0,c=c+Math.imul(A,we)|0,l=l+Math.imul(A,Te)|0,s=s+Math.imul(E,De)|0,c=c+Math.imul(E,Oe)|0,c=c+Math.imul(D,De)|0,l=l+Math.imul(D,Oe)|0,s=s+Math.imul(C,Ae)|0,c=c+Math.imul(C,je)|0,c=c+Math.imul(w,Ae)|0,l=l+Math.imul(w,je)|0,s=s+Math.imul(b,Ne)|0,c=c+Math.imul(b,Pe)|0,c=c+Math.imul(x,Ne)|0,l=l+Math.imul(x,Pe)|0;var qe=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(qe>>>26)|0,qe&=67108863,s=Math.imul(ae,ve),c=Math.imul(ae,ye),c=c+Math.imul(N,ve)|0,l=Math.imul(N,ye),s=s+Math.imul(ne,xe)|0,c=c+Math.imul(ne,Se)|0,c=c+Math.imul(re,xe)|0,l=l+Math.imul(re,Se)|0,s=s+Math.imul(j,we)|0,c=c+Math.imul(j,Te)|0,c=c+Math.imul(M,we)|0,l=l+Math.imul(M,Te)|0,s=s+Math.imul(k,De)|0,c=c+Math.imul(k,Oe)|0,c=c+Math.imul(A,De)|0,l=l+Math.imul(A,Oe)|0,s=s+Math.imul(E,Ae)|0,c=c+Math.imul(E,je)|0,c=c+Math.imul(D,Ae)|0,l=l+Math.imul(D,je)|0,s=s+Math.imul(C,Ne)|0,c=c+Math.imul(C,Pe)|0,c=c+Math.imul(w,Ne)|0,l=l+Math.imul(w,Pe)|0;var Je=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Je>>>26)|0,Je&=67108863,s=Math.imul(ae,xe),c=Math.imul(ae,Se),c=c+Math.imul(N,xe)|0,l=Math.imul(N,Se),s=s+Math.imul(ne,we)|0,c=c+Math.imul(ne,Te)|0,c=c+Math.imul(re,we)|0,l=l+Math.imul(re,Te)|0,s=s+Math.imul(j,De)|0,c=c+Math.imul(j,Oe)|0,c=c+Math.imul(M,De)|0,l=l+Math.imul(M,Oe)|0,s=s+Math.imul(k,Ae)|0,c=c+Math.imul(k,je)|0,c=c+Math.imul(A,Ae)|0,l=l+Math.imul(A,je)|0,s=s+Math.imul(E,Ne)|0,c=c+Math.imul(E,Pe)|0,c=c+Math.imul(D,Ne)|0,l=l+Math.imul(D,Pe)|0;var Ye=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Ye>>>26)|0,Ye&=67108863,s=Math.imul(ae,we),c=Math.imul(ae,Te),c=c+Math.imul(N,we)|0,l=Math.imul(N,Te),s=s+Math.imul(ne,De)|0,c=c+Math.imul(ne,Oe)|0,c=c+Math.imul(re,De)|0,l=l+Math.imul(re,Oe)|0,s=s+Math.imul(j,Ae)|0,c=c+Math.imul(j,je)|0,c=c+Math.imul(M,Ae)|0,l=l+Math.imul(M,je)|0,s=s+Math.imul(k,Ne)|0,c=c+Math.imul(k,Pe)|0,c=c+Math.imul(A,Ne)|0,l=l+Math.imul(A,Pe)|0;var Xe=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Xe>>>26)|0,Xe&=67108863,s=Math.imul(ae,De),c=Math.imul(ae,Oe),c=c+Math.imul(N,De)|0,l=Math.imul(N,Oe),s=s+Math.imul(ne,Ae)|0,c=c+Math.imul(ne,je)|0,c=c+Math.imul(re,Ae)|0,l=l+Math.imul(re,je)|0,s=s+Math.imul(j,Ne)|0,c=c+Math.imul(j,Pe)|0,c=c+Math.imul(M,Ne)|0,l=l+Math.imul(M,Pe)|0;var Ze=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Ze>>>26)|0,Ze&=67108863,s=Math.imul(ae,Ae),c=Math.imul(ae,je),c=c+Math.imul(N,Ae)|0,l=Math.imul(N,je),s=s+Math.imul(ne,Ne)|0,c=c+Math.imul(ne,Pe)|0,c=c+Math.imul(re,Ne)|0,l=l+Math.imul(re,Pe)|0;var Qe=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Qe>>>26)|0,Qe&=67108863,s=Math.imul(ae,Ne),c=Math.imul(ae,Pe),c=c+Math.imul(N,Ne)|0,l=Math.imul(N,Pe);var $e=(o+s|0)+((c&8191)<<13)|0;return o=(l+(c>>>13)|0)+($e>>>26)|0,$e&=67108863,a[0]=Fe,a[1]=Ie,a[2]=Le,a[3]=Re,a[4]=ze,a[5]=Be,a[6]=Ve,a[7]=He,a[8]=Ue,a[9]=We,a[10]=Ge,a[11]=Ke,a[12]=qe,a[13]=Je,a[14]=Ye,a[15]=Xe,a[16]=Ze,a[17]=Qe,a[18]=$e,o!==0&&(a[19]=o,n.length++),n};Math.imul||(v=_);function y(e,t,n){n.negative=t.negative^e.negative,n.length=e.length+t.length;for(var r=0,i=0,a=0;a<n.length-1;a++){var o=i;i=0;for(var s=r&67108863,c=Math.min(a,t.length-1),l=Math.max(0,a-e.length+1);l<=c;l++){var u=a-l,d=(e.words[u]|0)*(t.words[l]|0),f=d&67108863;o=o+(d/67108864|0)|0,f=f+s|0,s=f&67108863,o=o+(f>>>26)|0,i+=o>>>26,o&=67108863}n.words[a]=s,r=o,o=i}return r===0?n.length--:n.words[a]=r,n._strip()}function b(e,t,n){return y(e,t,n)}i.prototype.mulTo=function(e,t){var n,r=this.length+e.length;return n=this.length===10&&e.length===10?v(this,e,t):r<63?_(this,e,t):r<1024?y(this,e,t):b(this,e,t),n};function x(e,t){this.x=e,this.y=t}x.prototype.makeRBT=function(e){for(var t=Array(e),n=i.prototype._countBits(e)-1,r=0;r<e;r++)t[r]=this.revBin(r,n,e);return t},x.prototype.revBin=function(e,t,n){if(e===0||e===n-1)return e;for(var r=0,i=0;i<t;i++)r|=(e&1)<<t-i-1,e>>=1;return r},x.prototype.permute=function(e,t,n,r,i,a){for(var o=0;o<a;o++)r[o]=t[e[o]],i[o]=n[e[o]]},x.prototype.transform=function(e,t,n,r,i,a){this.permute(a,e,t,n,r,i);for(var o=1;o<i;o<<=1)for(var s=o<<1,c=Math.cos(2*Math.PI/s),l=Math.sin(2*Math.PI/s),u=0;u<i;u+=s)for(var d=c,f=l,p=0;p<o;p++){var m=n[u+p],h=r[u+p],g=n[u+p+o],_=r[u+p+o],v=d*g-f*_;_=d*_+f*g,g=v,n[u+p]=m+g,r[u+p]=h+_,n[u+p+o]=m-g,r[u+p+o]=h-_,p!==s&&(v=c*d-l*f,f=c*f+l*d,d=v)}},x.prototype.guessLen13b=function(e,t){var n=Math.max(t,e)|1,r=n&1,i=0;for(n=n/2|0;n;n>>>=1)i++;return 1<<i+1+r},x.prototype.conjugate=function(e,t,n){if(!(n<=1))for(var r=0;r<n/2;r++){var i=e[r];e[r]=e[n-r-1],e[n-r-1]=i,i=t[r],t[r]=-t[n-r-1],t[n-r-1]=-i}},x.prototype.normalize13b=function(e,t){for(var n=0,r=0;r<t/2;r++){var i=Math.round(e[2*r+1]/t)*8192+Math.round(e[2*r]/t)+n;e[r]=i&67108863,n=i<67108864?0:i/67108864|0}return e},x.prototype.convert13b=function(e,t,r,i){for(var a=0,o=0;o<t;o++)a+=e[o]|0,r[2*o]=a&8191,a>>>=13,r[2*o+1]=a&8191,a>>>=13;for(o=2*t;o<i;++o)r[o]=0;n(a===0),n((a&-8192)==0)},x.prototype.stub=function(e){for(var t=Array(e),n=0;n<e;n++)t[n]=0;return t},x.prototype.mulp=function(e,t,n){var r=2*this.guessLen13b(e.length,t.length),i=this.makeRBT(r),a=this.stub(r),o=Array(r),s=Array(r),c=Array(r),l=Array(r),u=Array(r),d=Array(r),f=n.words;f.length=r,this.convert13b(e.words,e.length,o,r),this.convert13b(t.words,t.length,l,r),this.transform(o,a,s,c,r,i),this.transform(l,a,u,d,r,i);for(var p=0;p<r;p++){var m=s[p]*u[p]-c[p]*d[p];c[p]=s[p]*d[p]+c[p]*u[p],s[p]=m}return this.conjugate(s,c,r),this.transform(s,c,f,a,r,i),this.conjugate(f,a,r),this.normalize13b(f,r),n.negative=e.negative^t.negative,n.length=e.length+t.length,n._strip()},i.prototype.mul=function(e){var t=new i(null);return t.words=Array(this.length+e.length),this.mulTo(e,t)},i.prototype.mulf=function(e){var t=new i(null);return t.words=Array(this.length+e.length),b(this,e,t)},i.prototype.imul=function(e){return this.clone().mulTo(e,this)},i.prototype.imuln=function(e){var t=e<0;t&&(e=-e),n(typeof e==`number`),n(e<67108864);for(var r=0,i=0;i<this.length;i++){var a=(this.words[i]|0)*e,o=(a&67108863)+(r&67108863);r>>=26,r+=a/67108864|0,r+=o>>>26,this.words[i]=o&67108863}return r!==0&&(this.words[i]=r,this.length++),this.length=e===0?1:this.length,t?this.ineg():this},i.prototype.muln=function(e){return this.clone().imuln(e)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(e){var t=g(e);if(t.length===0)return new i(1);for(var n=this,r=0;r<t.length&&t[r]===0;r++,n=n.sqr());if(++r<t.length)for(var a=n.sqr();r<t.length;r++,a=a.sqr())t[r]!==0&&(n=n.mul(a));return n},i.prototype.iushln=function(e){n(typeof e==`number`&&e>=0);var t=e%26,r=(e-t)/26,i=67108863>>>26-t<<26-t,a;if(t!==0){var o=0;for(a=0;a<this.length;a++){var s=this.words[a]&i,c=(this.words[a]|0)-s<<t;this.words[a]=c|o,o=s>>>26-t}o&&(this.words[a]=o,this.length++)}if(r!==0){for(a=this.length-1;a>=0;a--)this.words[a+r]=this.words[a];for(a=0;a<r;a++)this.words[a]=0;this.length+=r}return this._strip()},i.prototype.ishln=function(e){return n(this.negative===0),this.iushln(e)},i.prototype.iushrn=function(e,t,r){n(typeof e==`number`&&e>=0);var i=t?(t-t%26)/26:0,a=e%26,o=Math.min((e-a)/26,this.length),s=67108863^67108863>>>a<<a,c=r;if(i-=o,i=Math.max(0,i),c){for(var l=0;l<o;l++)c.words[l]=this.words[l];c.length=o}if(o!==0)if(this.length>o)for(this.length-=o,l=0;l<this.length;l++)this.words[l]=this.words[l+o];else this.words[0]=0,this.length=1;var u=0;for(l=this.length-1;l>=0&&(u!==0||l>=i);l--){var d=this.words[l]|0;this.words[l]=u<<26-a|d>>>a,u=d&s}return c&&u!==0&&(c.words[c.length++]=u),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},i.prototype.ishrn=function(e,t,r){return n(this.negative===0),this.iushrn(e,t,r)},i.prototype.shln=function(e){return this.clone().ishln(e)},i.prototype.ushln=function(e){return this.clone().iushln(e)},i.prototype.shrn=function(e){return this.clone().ishrn(e)},i.prototype.ushrn=function(e){return this.clone().iushrn(e)},i.prototype.testn=function(e){n(typeof e==`number`&&e>=0);var t=e%26,r=(e-t)/26,i=1<<t;return this.length<=r?!1:!!(this.words[r]&i)},i.prototype.imaskn=function(e){n(typeof e==`number`&&e>=0);var t=e%26,r=(e-t)/26;if(n(this.negative===0,`imaskn works only with positive numbers`),this.length<=r)return this;if(t!==0&&r++,this.length=Math.min(r,this.length),t!==0){var i=67108863^67108863>>>t<<t;this.words[this.length-1]&=i}return this.length===0&&(this.words[0]=0,this.length=1),this._strip()},i.prototype.maskn=function(e){return this.clone().imaskn(e)},i.prototype.iaddn=function(e){return n(typeof e==`number`),n(e<67108864),e<0?this.isubn(-e):this.negative===0?this._iaddn(e):this.length===1&&(this.words[0]|0)<=e?(this.words[0]=e-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(e),this.negative=1,this)},i.prototype._iaddn=function(e){this.words[0]+=e;for(var t=0;t<this.length&&this.words[t]>=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},i.prototype.isubn=function(e){if(n(typeof e==`number`),n(e<67108864),e<0)return this.iaddn(-e);if(this.negative!==0)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t<this.length&&this.words[t]<0;t++)this.words[t]+=67108864,--this.words[t+1];return this._strip()},i.prototype.addn=function(e){return this.clone().iaddn(e)},i.prototype.subn=function(e){return this.clone().isubn(e)},i.prototype.iabs=function(){return this.negative=0,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(e,t,r){var i=e.length+r,a;this._expand(i);var o,s=0;for(a=0;a<e.length;a++){o=(this.words[a+r]|0)+s;var c=(e.words[a]|0)*t;o-=c&67108863,s=(o>>26)-(c/67108864|0),this.words[a+r]=o&67108863}for(;a<this.length-r;a++)o=(this.words[a+r]|0)+s,s=o>>26,this.words[a+r]=o&67108863;if(s===0)return this._strip();for(n(s===-1),s=0,a=0;a<this.length;a++)o=-(this.words[a]|0)+s,s=o>>26,this.words[a]=o&67108863;return this.negative=1,this._strip()},i.prototype._wordDiv=function(e,t){var n=this.length-e.length,r=this.clone(),a=e,o=a.words[a.length-1]|0;n=26-this._countBits(o),n!==0&&(a=a.ushln(n),r.iushln(n),o=a.words[a.length-1]|0);var s=r.length-a.length,c;if(t!==`mod`){c=new i(null),c.length=s+1,c.words=Array(c.length);for(var l=0;l<c.length;l++)c.words[l]=0}var u=r.clone()._ishlnsubmul(a,1,s);u.negative===0&&(r=u,c&&(c.words[s]=1));for(var d=s-1;d>=0;d--){var f=(r.words[a.length+d]|0)*67108864+(r.words[a.length+d-1]|0);for(f=Math.min(f/o|0,67108863),r._ishlnsubmul(a,f,d);r.negative!==0;)f--,r.negative=0,r._ishlnsubmul(a,1,d),r.isZero()||(r.negative^=1);c&&(c.words[d]=f)}return c&&c._strip(),r._strip(),t!==`div`&&n!==0&&r.iushrn(n),{div:c||null,mod:r}},i.prototype.divmod=function(e,t,r){if(n(!e.isZero()),this.isZero())return{div:new i(0),mod:new i(0)};var a,o,s;return this.negative!==0&&e.negative===0?(s=this.neg().divmod(e,t),t!==`mod`&&(a=s.div.neg()),t!==`div`&&(o=s.mod.neg(),r&&o.negative!==0&&o.iadd(e)),{div:a,mod:o}):this.negative===0&&e.negative!==0?(s=this.divmod(e.neg(),t),t!==`mod`&&(a=s.div.neg()),{div:a,mod:s.mod}):(this.negative&e.negative)===0?e.length>this.length||this.cmp(e)<0?{div:new i(0),mod:this}:e.length===1?t===`div`?{div:this.divn(e.words[0]),mod:null}:t===`mod`?{div:null,mod:new i(this.modrn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new i(this.modrn(e.words[0]))}:this._wordDiv(e,t):(s=this.neg().divmod(e.neg(),t),t!==`div`&&(o=s.mod.neg(),r&&o.negative!==0&&o.isub(e)),{div:s.div,mod:o})},i.prototype.div=function(e){return this.divmod(e,`div`,!1).div},i.prototype.mod=function(e){return this.divmod(e,`mod`,!1).mod},i.prototype.umod=function(e){return this.divmod(e,`mod`,!0).mod},i.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var n=t.div.negative===0?t.mod:t.mod.isub(e),r=e.ushrn(1),i=e.andln(1),a=n.cmp(r);return a<0||i===1&&a===0?t.div:t.div.negative===0?t.div.iaddn(1):t.div.isubn(1)},i.prototype.modrn=function(e){var t=e<0;t&&(e=-e),n(e<=67108863);for(var r=(1<<26)%e,i=0,a=this.length-1;a>=0;a--)i=(r*i+(this.words[a]|0))%e;return t?-i:i},i.prototype.modn=function(e){return this.modrn(e)},i.prototype.idivn=function(e){var t=e<0;t&&(e=-e),n(e<=67108863);for(var r=0,i=this.length-1;i>=0;i--){var a=(this.words[i]|0)+r*67108864;this.words[i]=a/e|0,r=a%e}return this._strip(),t?this.ineg():this},i.prototype.divn=function(e){return this.clone().idivn(e)},i.prototype.egcd=function(e){n(e.negative===0),n(!e.isZero());var t=this,r=e.clone();t=t.negative===0?t.clone():t.umod(e);for(var a=new i(1),o=new i(0),s=new i(0),c=new i(1),l=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++l;for(var u=r.clone(),d=t.clone();!t.isZero();){for(var f=0,p=1;(t.words[0]&p)===0&&f<26;++f,p<<=1);if(f>0)for(t.iushrn(f);f-- >0;)(a.isOdd()||o.isOdd())&&(a.iadd(u),o.isub(d)),a.iushrn(1),o.iushrn(1);for(var m=0,h=1;(r.words[0]&h)===0&&m<26;++m,h<<=1);if(m>0)for(r.iushrn(m);m-- >0;)(s.isOdd()||c.isOdd())&&(s.iadd(u),c.isub(d)),s.iushrn(1),c.iushrn(1);t.cmp(r)>=0?(t.isub(r),a.isub(s),o.isub(c)):(r.isub(t),s.isub(a),c.isub(o))}return{a:s,b:c,gcd:r.iushln(l)}},i.prototype._invmp=function(e){n(e.negative===0),n(!e.isZero());var t=this,r=e.clone();t=t.negative===0?t.clone():t.umod(e);for(var a=new i(1),o=new i(0),s=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var c=0,l=1;(t.words[0]&l)===0&&c<26;++c,l<<=1);if(c>0)for(t.iushrn(c);c-- >0;)a.isOdd()&&a.iadd(s),a.iushrn(1);for(var u=0,d=1;(r.words[0]&d)===0&&u<26;++u,d<<=1);if(u>0)for(r.iushrn(u);u-- >0;)o.isOdd()&&o.iadd(s),o.iushrn(1);t.cmp(r)>=0?(t.isub(r),a.isub(o)):(r.isub(t),o.isub(a))}var f=t.cmpn(1)===0?a:o;return f.cmpn(0)<0&&f.iadd(e),f},i.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),n=e.clone();t.negative=0,n.negative=0;for(var r=0;t.isEven()&&n.isEven();r++)t.iushrn(1),n.iushrn(1);do{for(;t.isEven();)t.iushrn(1);for(;n.isEven();)n.iushrn(1);var i=t.cmp(n);if(i<0){var a=t;t=n,n=a}else if(i===0||n.cmpn(1)===0)break;t.isub(n)}while(!0);return n.iushln(r)},i.prototype.invm=function(e){return this.egcd(e).a.umod(e)},i.prototype.isEven=function(){return(this.words[0]&1)==0},i.prototype.isOdd=function(){return(this.words[0]&1)==1},i.prototype.andln=function(e){return this.words[0]&e},i.prototype.bincn=function(e){n(typeof e==`number`);var t=e%26,r=(e-t)/26,i=1<<t;if(this.length<=r)return this._expand(r+1),this.words[r]|=i,this;for(var a=i,o=r;a!==0&&o<this.length;o++){var s=this.words[o]|0;s+=a,a=s>>>26,s&=67108863,this.words[o]=s}return a!==0&&(this.words[o]=a,this.length++),this},i.prototype.isZero=function(){return this.length===1&&this.words[0]===0},i.prototype.cmpn=function(e){var t=e<0;if(this.negative!==0&&!t)return-1;if(this.negative===0&&t)return 1;this._strip();var r;if(this.length>1)r=1;else{t&&(e=-e),n(e<=67108863,`Number is too big`);var i=this.words[0]|0;r=i===e?0:i<e?-1:1}return this.negative===0?r:-r|0},i.prototype.cmp=function(e){if(this.negative!==0&&e.negative===0)return-1;if(this.negative===0&&e.negative!==0)return 1;var t=this.ucmp(e);return this.negative===0?t:-t|0},i.prototype.ucmp=function(e){if(this.length>e.length)return 1;if(this.length<e.length)return-1;for(var t=0,n=this.length-1;n>=0;n--){var r=this.words[n]|0,i=e.words[n]|0;if(r!==i){r<i?t=-1:r>i&&(t=1);break}}return t},i.prototype.gtn=function(e){return this.cmpn(e)===1},i.prototype.gt=function(e){return this.cmp(e)===1},i.prototype.gten=function(e){return this.cmpn(e)>=0},i.prototype.gte=function(e){return this.cmp(e)>=0},i.prototype.ltn=function(e){return this.cmpn(e)===-1},i.prototype.lt=function(e){return this.cmp(e)===-1},i.prototype.lten=function(e){return this.cmpn(e)<=0},i.prototype.lte=function(e){return this.cmp(e)<=0},i.prototype.eqn=function(e){return this.cmpn(e)===0},i.prototype.eq=function(e){return this.cmp(e)===0},i.red=function(e){return new O(e)},i.prototype.toRed=function(e){return n(!this.red,`Already a number in reduction context`),n(this.negative===0,`red works only with positives`),e.convertTo(this)._forceRed(e)},i.prototype.fromRed=function(){return n(this.red,`fromRed works only with numbers in reduction context`),this.red.convertFrom(this)},i.prototype._forceRed=function(e){return this.red=e,this},i.prototype.forceRed=function(e){return n(!this.red,`Already a number in reduction context`),this._forceRed(e)},i.prototype.redAdd=function(e){return n(this.red,`redAdd works only with red numbers`),this.red.add(this,e)},i.prototype.redIAdd=function(e){return n(this.red,`redIAdd works only with red numbers`),this.red.iadd(this,e)},i.prototype.redSub=function(e){return n(this.red,`redSub works only with red numbers`),this.red.sub(this,e)},i.prototype.redISub=function(e){return n(this.red,`redISub works only with red numbers`),this.red.isub(this,e)},i.prototype.redShl=function(e){return n(this.red,`redShl works only with red numbers`),this.red.shl(this,e)},i.prototype.redMul=function(e){return n(this.red,`redMul works only with red numbers`),this.red._verify2(this,e),this.red.mul(this,e)},i.prototype.redIMul=function(e){return n(this.red,`redMul works only with red numbers`),this.red._verify2(this,e),this.red.imul(this,e)},i.prototype.redSqr=function(){return n(this.red,`redSqr works only with red numbers`),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return n(this.red,`redISqr works only with red numbers`),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return n(this.red,`redSqrt works only with red numbers`),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return n(this.red,`redInvm works only with red numbers`),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return n(this.red,`redNeg works only with red numbers`),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(e){return n(this.red&&!e.red,`redPow(normalNum)`),this.red._verify1(this),this.red.pow(this,e)};var S={k256:null,p224:null,p192:null,p25519:null};function C(e,t){this.name=e,this.p=new i(t,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}C.prototype._tmp=function(){var e=new i(null);return e.words=Array(Math.ceil(this.n/13)),e},C.prototype.ireduce=function(e){var t=e,n;do this.split(t,this.tmp),t=this.imulK(t),t=t.iadd(this.tmp),n=t.bitLength();while(n>this.n);var r=n<this.n?-1:t.ucmp(this.p);return r===0?(t.words[0]=0,t.length=1):r>0?t.isub(this.p):t.strip===void 0?t._strip():t.strip(),t},C.prototype.split=function(e,t){e.iushrn(this.n,0,t)},C.prototype.imulK=function(e){return e.imul(this.k)};function w(){C.call(this,`k256`,`ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f`)}r(w,C),w.prototype.split=function(e,t){for(var n=4194303,r=Math.min(e.length,9),i=0;i<r;i++)t.words[i]=e.words[i];if(t.length=r,e.length<=9){e.words[0]=0,e.length=1;return}var a=e.words[9];for(t.words[t.length++]=a&n,i=10;i<e.length;i++){var o=e.words[i]|0;e.words[i-10]=(o&n)<<4|a>>>22,a=o}a>>>=22,e.words[i-10]=a,a===0&&e.length>10?e.length-=10:e.length-=9},w.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,n=0;n<e.length;n++){var r=e.words[n]|0;t+=r*977,e.words[n]=t&67108863,t=r*64+(t/67108864|0)}return e.words[e.length-1]===0&&(e.length--,e.words[e.length-1]===0&&e.length--),e};function T(){C.call(this,`p224`,`ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001`)}r(T,C);function E(){C.call(this,`p192`,`ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff`)}r(E,C);function D(){C.call(this,`25519`,`7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed`)}r(D,C),D.prototype.imulK=function(e){for(var t=0,n=0;n<e.length;n++){var r=(e.words[n]|0)*19+t,i=r&67108863;r>>>=26,e.words[n]=i,t=r}return t!==0&&(e.words[e.length++]=t),e},i._prime=function(e){if(S[e])return S[e];var t;if(e===`k256`)t=new w;else if(e===`p224`)t=new T;else if(e===`p192`)t=new E;else if(e===`p25519`)t=new D;else throw Error(`Unknown prime `+e);return S[e]=t,t};function O(e){if(typeof e==`string`){var t=i._prime(e);this.m=t.p,this.prime=t}else n(e.gtn(1),`modulus must be greater than 1`),this.m=e,this.prime=null}O.prototype._verify1=function(e){n(e.negative===0,`red works only with positives`),n(e.red,`red works only with red numbers`)},O.prototype._verify2=function(e,t){n((e.negative|t.negative)===0,`red works only with positives`),n(e.red&&e.red===t.red,`red works only with red numbers`)},O.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):(u(e,e.umod(this.m)._forceRed(this)),e)},O.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},O.prototype.add=function(e,t){this._verify2(e,t);var n=e.add(t);return n.cmp(this.m)>=0&&n.isub(this.m),n._forceRed(this)},O.prototype.iadd=function(e,t){this._verify2(e,t);var n=e.iadd(t);return n.cmp(this.m)>=0&&n.isub(this.m),n},O.prototype.sub=function(e,t){this._verify2(e,t);var n=e.sub(t);return n.cmpn(0)<0&&n.iadd(this.m),n._forceRed(this)},O.prototype.isub=function(e,t){this._verify2(e,t);var n=e.isub(t);return n.cmpn(0)<0&&n.iadd(this.m),n},O.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},O.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},O.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},O.prototype.isqr=function(e){return this.imul(e,e.clone())},O.prototype.sqr=function(e){return this.mul(e,e)},O.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(n(t%2==1),t===3){var r=this.m.add(new i(1)).iushrn(2);return this.pow(e,r)}for(var a=this.m.subn(1),o=0;!a.isZero()&&a.andln(1)===0;)o++,a.iushrn(1);n(!a.isZero());var s=new i(1).toRed(this),c=s.redNeg(),l=this.m.subn(1).iushrn(1),u=this.m.bitLength();for(u=new i(2*u*u).toRed(this);this.pow(u,l).cmp(c)!==0;)u.redIAdd(c);for(var d=this.pow(u,a),f=this.pow(e,a.addn(1).iushrn(1)),p=this.pow(e,a),m=o;p.cmp(s)!==0;){for(var h=p,g=0;h.cmp(s)!==0;g++)h=h.redSqr();n(g<m);var _=this.pow(d,new i(1).iushln(m-g-1));f=f.redMul(_),d=_.redSqr(),p=p.redMul(d),m=g}return f},O.prototype.invm=function(e){var t=e._invmp(this.m);return t.negative===0?this.imod(t):(t.negative=0,this.imod(t).redNeg())},O.prototype.pow=function(e,t){if(t.isZero())return new i(1).toRed(this);if(t.cmpn(1)===0)return e.clone();var n=4,r=Array(1<<n);r[0]=new i(1).toRed(this),r[1]=e;for(var a=2;a<r.length;a++)r[a]=this.mul(r[a-1],e);var o=r[0],s=0,c=0,l=t.bitLength()%26;for(l===0&&(l=26),a=t.length-1;a>=0;a--){for(var u=t.words[a],d=l-1;d>=0;d--){var f=u>>d&1;if(o!==r[0]&&(o=this.sqr(o)),f===0&&s===0){c=0;continue}s<<=1,s|=f,c++,!(c!==n&&(a!==0||d!==0))&&(o=this.mul(o,r[s]),c=0,s=0)}l=26}return o},O.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},O.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},i.mont=function(e){return new k(e)};function k(e){O.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new i(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}r(k,O),k.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},k.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},k.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var n=e.imul(t),r=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=n.isub(r).iushrn(this.shift),a=i;return i.cmp(this.m)>=0?a=i.isub(this.m):i.cmpn(0)<0&&(a=i.iadd(this.m)),a._forceRed(this)},k.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new i(0)._forceRed(this);var n=e.mul(t),r=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),a=n.isub(r).iushrn(this.shift),o=a;return a.cmp(this.m)>=0?o=a.isub(this.m):a.cmpn(0)<0&&(o=a.iadd(this.m)),o._forceRed(this)},k.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}})(t===void 0||t,e)})),ir=i(((e,t)=>{var n=s(),r=n.Buffer;function i(e,t){for(var n in e)t[n]=e[n]}r.from&&r.alloc&&r.allocUnsafe&&r.allocUnsafeSlow?t.exports=n:(i(n,e),e.Buffer=a);function a(e,t,n){return r(e,t,n)}a.prototype=Object.create(r.prototype),i(r,a),a.from=function(e,t,n){if(typeof e==`number`)throw TypeError(`Argument must not be a number`);return r(e,t,n)},a.alloc=function(e,t,n){if(typeof e!=`number`)throw TypeError(`Argument must be a number`);var i=r(e);return t===void 0?i.fill(0):typeof n==`string`?i.fill(t,n):i.fill(t),i},a.allocUnsafe=function(e){if(typeof e!=`number`)throw TypeError(`Argument must be a number`);return r(e)},a.allocUnsafeSlow=function(e){if(typeof e!=`number`)throw TypeError(`Argument must be a number`);return n.SlowBuffer(e)}})),ar=i(((e,t)=>{var n=ir().Buffer;function r(e){if(e.length>=255)throw TypeError(`Alphabet too long`);for(var t=new Uint8Array(256),r=0;r<t.length;r++)t[r]=255;for(var i=0;i<e.length;i++){var a=e.charAt(i),o=a.charCodeAt(0);if(t[o]!==255)throw TypeError(a+` is ambiguous`);t[o]=i}var s=e.length,c=e.charAt(0),l=Math.log(s)/Math.log(256),u=Math.log(256)/Math.log(s);function d(t){if((Array.isArray(t)||t instanceof Uint8Array)&&(t=n.from(t)),!n.isBuffer(t))throw TypeError(`Expected Buffer`);if(t.length===0)return``;for(var r=0,i=0,a=0,o=t.length;a!==o&&t[a]===0;)a++,r++;for(var l=(o-a)*u+1>>>0,d=new Uint8Array(l);a!==o;){for(var f=t[a],p=0,m=l-1;(f!==0||p<i)&&m!==-1;m--,p++)f+=256*d[m]>>>0,d[m]=f%s>>>0,f=f/s>>>0;if(f!==0)throw Error(`Non-zero carry`);i=p,a++}for(var h=l-i;h!==l&&d[h]===0;)h++;for(var g=c.repeat(r);h<l;++h)g+=e.charAt(d[h]);return g}function f(e){if(typeof e!=`string`)throw TypeError(`Expected String`);if(e.length===0)return n.alloc(0);for(var r=0,i=0,a=0;e[r]===c;)i++,r++;for(var o=(e.length-r)*l+1>>>0,u=new Uint8Array(o);r<e.length;){var d=e.charCodeAt(r);if(d>255)return;var f=t[d];if(f===255)return;for(var p=0,m=o-1;(f!==0||p<a)&&m!==-1;m--,p++)f+=s*u[m]>>>0,u[m]=f%256>>>0,f=f/256>>>0;if(f!==0)throw Error(`Non-zero carry`);a=p,r++}for(var h=o-a;h!==o&&u[h]===0;)h++;var g=n.allocUnsafe(i+(o-h));g.fill(0,0,i);for(var _=i;h!==o;)g[_++]=u[h++];return g}function p(e){var t=f(e);if(t)return t;throw Error(`Non-base`+s+` character`)}return{encode:d,decodeUnsafe:f,decode:p}}t.exports=r})),or=i(((e,t)=>{t.exports=ar()(`123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz`)})),sr=i(((e,t)=>{var n=ir().Buffer;function r(e){if(e.length>=255)throw TypeError(`Alphabet too long`);for(var t=new Uint8Array(256),r=0;r<t.length;r++)t[r]=255;for(var i=0;i<e.length;i++){var a=e.charAt(i),o=a.charCodeAt(0);if(t[o]!==255)throw TypeError(a+` is ambiguous`);t[o]=i}var s=e.length,c=e.charAt(0),l=Math.log(s)/Math.log(256),u=Math.log(256)/Math.log(s);function d(t){if((Array.isArray(t)||t instanceof Uint8Array)&&(t=n.from(t)),!n.isBuffer(t))throw TypeError(`Expected Buffer`);if(t.length===0)return``;for(var r=0,i=0,a=0,o=t.length;a!==o&&t[a]===0;)a++,r++;for(var l=(o-a)*u+1>>>0,d=new Uint8Array(l);a!==o;){for(var f=t[a],p=0,m=l-1;(f!==0||p<i)&&m!==-1;m--,p++)f+=256*d[m]>>>0,d[m]=f%s>>>0,f=f/s>>>0;if(f!==0)throw Error(`Non-zero carry`);i=p,a++}for(var h=l-i;h!==l&&d[h]===0;)h++;for(var g=c.repeat(r);h<l;++h)g+=e.charAt(d[h]);return g}function f(e){if(typeof e!=`string`)throw TypeError(`Expected String`);if(e.length===0)return n.alloc(0);for(var r=0,i=0,a=0;e[r]===c;)i++,r++;for(var o=(e.length-r)*l+1>>>0,u=new Uint8Array(o);r<e.length;){var d=e.charCodeAt(r);if(d>255)return;var f=t[d];if(f===255)return;for(var p=0,m=o-1;(f!==0||p<a)&&m!==-1;m--,p++)f+=s*u[m]>>>0,u[m]=f%256>>>0,f=f/256>>>0;if(f!==0)throw Error(`Non-zero carry`);a=p,r++}for(var h=o-a;h!==o&&u[h]===0;)h++;var g=n.allocUnsafe(i+(o-h));g.fill(0,0,i);for(var _=i;h!==o;)g[_++]=u[h++];return g}function p(e){var t=f(e);if(t)return t;throw Error(`Non-base`+s+` character`)}return{encode:d,decodeUnsafe:f,decode:p}}t.exports=r})),cr=i(((e,t)=>{t.exports=sr()(`123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz`)})),lr=r({TextDecoder:()=>vr,TextEncoder:()=>yr});function ur(e,t,n){return t<=e&&e<=n}function dr(e){if(e===void 0)return{};if(e===Object(e))return e;throw TypeError(`Could not convert argument to dictionary`)}function fr(e){for(var t=String(e),n=t.length,r=0,i=[];r<n;){var a=t.charCodeAt(r);if(a<55296||a>57343)i.push(a);else if(56320<=a&&a<=57343)i.push(65533);else if(55296<=a&&a<=56319)if(r===n-1)i.push(65533);else{var o=e.charCodeAt(r+1);if(56320<=o&&o<=57343){var s=a&1023,c=o&1023;i.push(65536+(s<<10)+c),r+=1}else i.push(65533)}r+=1}return i}function pr(e){for(var t=``,n=0;n<e.length;++n){var r=e[n];r<=65535?t+=String.fromCharCode(r):(r-=65536,t+=String.fromCharCode((r>>10)+55296,(r&1023)+56320))}return t}function mr(e){this.tokens=[].slice.call(e)}function hr(e,t){if(e)throw TypeError(`Decoder error`);return t||65533}function gr(){}function _r(){}function vr(e,t){if(!(this instanceof vr))return new vr(e,t);if(e=e===void 0?wr:String(e).toLowerCase(),e!==wr)throw Error(`Encoding not supported. Only utf-8 is supported`);t=dr(t),this._streaming=!1,this._BOMseen=!1,this._decoder=null,this._fatal=!!t.fatal,this._ignoreBOM=!!t.ignoreBOM,Object.defineProperty(this,"encoding",{value:`utf-8`}),Object.defineProperty(this,"fatal",{value:this._fatal}),Object.defineProperty(this,"ignoreBOM",{value:this._ignoreBOM})}function yr(e,t){if(!(this instanceof yr))return new yr(e,t);if(e=e===void 0?wr:String(e).toLowerCase(),e!==wr)throw Error(`Encoding not supported. Only utf-8 is supported`);t=dr(t),this._streaming=!1,this._encoder=null,this._options={fatal:!!t.fatal},Object.defineProperty(this,"encoding",{value:`utf-8`})}function br(e){var t=e.fatal,n=0,r=0,i=0,a=128,o=191;this.handler=function(e,s){if(s===Sr&&i!==0)return i=0,hr(t);if(s===Sr)return Cr;if(i===0){if(ur(s,0,127))return s;if(ur(s,194,223))i=1,n=s-192;else if(ur(s,224,239))s===224&&(a=160),s===237&&(o=159),i=2,n=s-224;else if(ur(s,240,244))s===240&&(a=144),s===244&&(o=143),i=3,n=s-240;else return hr(t);return n<<=6*i,null}if(!ur(s,a,o))return n=i=r=0,a=128,o=191,e.prepend(s),hr(t);if(a=128,o=191,r+=1,n+=s-128<<6*(i-r),r!==i)return null;var c=n;return n=i=r=0,c}}function xr(e){e.fatal,this.handler=function(e,t){if(t===Sr)return Cr;if(ur(t,0,127))return t;var n,r;ur(t,128,2047)?(n=1,r=192):ur(t,2048,65535)?(n=2,r=224):ur(t,65536,1114111)&&(n=3,r=240);for(var i=[(t>>6*n)+r];n>0;){var a=t>>6*(n-1);i.push(128|a&63),--n}return i}}var Sr,Cr,wr,Tr=t((()=>{Sr=-1,mr.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():Sr},prepend:function(e){if(Array.isArray(e))for(var t=e;t.length;)this.tokens.unshift(t.pop());else this.tokens.unshift(e)},push:function(e){if(Array.isArray(e))for(var t=e;t.length;)this.tokens.push(t.shift());else this.tokens.push(e)}},Cr=-1,gr.prototype={handler:function(e,t){}},_r.prototype={handler:function(e,t){}},wr=`utf-8`,vr.prototype={decode:function(e,t){var n=typeof e==`object`&&e instanceof ArrayBuffer?new Uint8Array(e):typeof e==`object`&&`buffer`in e&&e.buffer instanceof ArrayBuffer?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array;t=dr(t),this._streaming||(this._decoder=new br({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!t.stream;for(var r=new mr(n),i=[],a;!r.endOfStream()&&(a=this._decoder.handler(r,r.read()),a!==Cr);)a!==null&&(Array.isArray(a)?i.push.apply(i,a):i.push(a));if(!this._streaming){do{if(a=this._decoder.handler(r,r.read()),a===Cr)break;if(a===null)continue;Array.isArray(a)?i.push.apply(i,a):i.push(a)}while(!r.endOfStream());this._decoder=null}return i.length&&[`utf-8`].indexOf(this.encoding)!==-1&&!this._ignoreBOM&&!this._BOMseen&&(i[0]===65279?(this._BOMseen=!0,i.shift()):this._BOMseen=!0),pr(i)}},yr.prototype={encode:function(e,t){e=e?String(e):``,t=dr(t),this._streaming||(this._encoder=new xr(this._options)),this._streaming=!!t.stream;for(var n=[],r=new mr(fr(e)),i;!r.endOfStream()&&(i=this._encoder.handler(r,r.read()),i!==Cr);)Array.isArray(i)?n.push.apply(n,i):n.push(i);if(!this._streaming){for(;i=this._encoder.handler(r,r.read()),i!==Cr;)Array.isArray(i)?n.push.apply(n,i):n.push(i);this._encoder=null}return new Uint8Array(n)}}})),Er=i((t=>{var n=t&&t.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),r=t&&t.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),i=t&&t.__decorate||function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},a=t&&t.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var i in e)i!==`default`&&Object.hasOwnProperty.call(e,i)&&n(t,e,i);return r(t,e),t},o=t&&t.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.deserializeUnchecked=t.deserialize=t.serialize=t.BinaryReader=t.BinaryWriter=t.BorshError=t.baseDecode=t.baseEncode=void 0;var s=o(rr()),c=o(cr()),l=a((Tr(),e(lr))),u=new(typeof TextDecoder==`function`?TextDecoder:l.TextDecoder)(`utf-8`,{fatal:!0});function d(e){return typeof e==`string`&&(e=Buffer.from(e,`utf8`)),c.default.encode(Buffer.from(e))}t.baseEncode=d;function f(e){return Buffer.from(c.default.decode(e))}t.baseDecode=f;var p=1024,m=class extends Error{constructor(e){super(e),this.fieldPath=[],this.originalMessage=e}addToFieldPath(e){this.fieldPath.splice(0,0,e),this.message=this.originalMessage+`: `+this.fieldPath.join(`.`)}};t.BorshError=m;var h=class{constructor(){this.buf=Buffer.alloc(p),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Buffer.concat([this.buf,Buffer.alloc(p)]))}writeU8(e){this.maybeResize(),this.buf.writeUInt8(e,this.length),this.length+=1}writeU16(e){this.maybeResize(),this.buf.writeUInt16LE(e,this.length),this.length+=2}writeU32(e){this.maybeResize(),this.buf.writeUInt32LE(e,this.length),this.length+=4}writeU64(e){this.maybeResize(),this.writeBuffer(Buffer.from(new s.default(e).toArray(`le`,8)))}writeU128(e){this.maybeResize(),this.writeBuffer(Buffer.from(new s.default(e).toArray(`le`,16)))}writeU256(e){this.maybeResize(),this.writeBuffer(Buffer.from(new s.default(e).toArray(`le`,32)))}writeU512(e){this.maybeResize(),this.writeBuffer(Buffer.from(new s.default(e).toArray(`le`,64)))}writeBuffer(e){this.buf=Buffer.concat([Buffer.from(this.buf.subarray(0,this.length)),e,Buffer.alloc(p)]),this.length+=e.length}writeString(e){this.maybeResize();let t=Buffer.from(e,`utf8`);this.writeU32(t.length),this.writeBuffer(t)}writeFixedArray(e){this.writeBuffer(Buffer.from(e))}writeArray(e,t){this.maybeResize(),this.writeU32(e.length);for(let n of e)this.maybeResize(),t(n)}toArray(){return this.buf.subarray(0,this.length)}};t.BinaryWriter=h;function g(e,t,n){let r=n.value;n.value=function(...e){try{return r.apply(this,e)}catch(e){if(e instanceof RangeError){let t=e.code;if([`ERR_BUFFER_OUT_OF_BOUNDS`,`ERR_OUT_OF_RANGE`].indexOf(t)>=0)throw new m(`Reached the end of buffer when deserializing`)}throw e}}}var _=class{constructor(e){this.buf=e,this.offset=0}readU8(){let e=this.buf.readUInt8(this.offset);return this.offset+=1,e}readU16(){let e=this.buf.readUInt16LE(this.offset);return this.offset+=2,e}readU32(){let e=this.buf.readUInt32LE(this.offset);return this.offset+=4,e}readU64(){let e=this.readBuffer(8);return new s.default(e,`le`)}readU128(){let e=this.readBuffer(16);return new s.default(e,`le`)}readU256(){let e=this.readBuffer(32);return new s.default(e,`le`)}readU512(){let e=this.readBuffer(64);return new s.default(e,`le`)}readBuffer(e){if(this.offset+e>this.buf.length)throw new m(`Expected buffer length ${e} isn't within bounds`);let t=this.buf.slice(this.offset,this.offset+e);return this.offset+=e,t}readString(){let e=this.readU32(),t=this.readBuffer(e);try{return u.decode(t)}catch(e){throw new m(`Error decoding UTF-8 string: ${e}`)}}readFixedArray(e){return new Uint8Array(this.readBuffer(e))}readArray(e){let t=this.readU32(),n=[];for(let r=0;r<t;++r)n.push(e());return n}};i([g],_.prototype,`readU8`,null),i([g],_.prototype,`readU16`,null),i([g],_.prototype,`readU32`,null),i([g],_.prototype,`readU64`,null),i([g],_.prototype,`readU128`,null),i([g],_.prototype,`readU256`,null),i([g],_.prototype,`readU512`,null),i([g],_.prototype,`readString`,null),i([g],_.prototype,`readFixedArray`,null),i([g],_.prototype,`readArray`,null),t.BinaryReader=_;function v(e){return e.charAt(0).toUpperCase()+e.slice(1)}function y(e,t,n,r,i){try{if(typeof r==`string`)i[`write${v(r)}`](n);else if(r instanceof Array)if(typeof r[0]==`number`){if(n.length!==r[0])throw new m(`Expecting byte array of length ${r[0]}, but got ${n.length} bytes`);i.writeFixedArray(n)}else if(r.length===2&&typeof r[1]==`number`){if(n.length!==r[1])throw new m(`Expecting byte array of length ${r[1]}, but got ${n.length} bytes`);for(let t=0;t<r[1];t++)y(e,null,n[t],r[0],i)}else i.writeArray(n,n=>{y(e,t,n,r[0],i)});else if(r.kind!==void 0)switch(r.kind){case`option`:n==null?i.writeU8(0):(i.writeU8(1),y(e,t,n,r.type,i));break;case`map`:i.writeU32(n.size),n.forEach((n,a)=>{y(e,t,a,r.key,i),y(e,t,n,r.value,i)});break;default:throw new m(`FieldType ${r} unrecognized`)}else b(e,n,i)}catch(e){throw e instanceof m&&e.addToFieldPath(t),e}}function b(e,t,n){if(typeof t.borshSerialize==`function`){t.borshSerialize(n);return}let r=e.get(t.constructor);if(!r)throw new m(`Class ${t.constructor.name} is missing in schema`);if(r.kind===`struct`)r.fields.map(([r,i])=>{y(e,r,t[r],i,n)});else if(r.kind===`enum`){let i=t[r.field];for(let a=0;a<r.values.length;++a){let[o,s]=r.values[a];if(o===i){n.writeU8(a),y(e,o,t[o],s,n);break}}}else throw new m(`Unexpected schema kind: ${r.kind} for ${t.constructor.name}`)}function x(e,t,n=h){let r=new n;return b(e,t,r),r.toArray()}t.serialize=x;function S(e,t,n,r){try{if(typeof n==`string`)return r[`read${v(n)}`]();if(n instanceof Array){if(typeof n[0]==`number`)return r.readFixedArray(n[0]);if(typeof n[1]==`number`){let t=[];for(let i=0;i<n[1];i++)t.push(S(e,null,n[0],r));return t}else return r.readArray(()=>S(e,t,n[0],r))}if(n.kind===`option`)return r.readU8()?S(e,t,n.type,r):void 0;if(n.kind===`map`){let i=new Map,a=r.readU32();for(let o=0;o<a;o++){let a=S(e,t,n.key,r),o=S(e,t,n.value,r);i.set(a,o)}return i}return C(e,n,r)}catch(e){throw e instanceof m&&e.addToFieldPath(t),e}}function C(e,t,n){if(typeof t.borshDeserialize==`function`)return t.borshDeserialize(n);let r=e.get(t);if(!r)throw new m(`Class ${t.name} is missing in schema`);if(r.kind===`struct`){let r={};for(let[i,a]of e.get(t).fields)r[i]=S(e,i,a,n);return new t(r)}if(r.kind===`enum`){let i=n.readU8();if(i>=r.values.length)throw new m(`Enum index: ${i} is out of range`);let[a,o]=r.values[i],s=S(e,a,o,n);return new t({[a]:s})}throw new m(`Unexpected schema kind: ${r.kind} for ${t.constructor.name}`)}function w(e,t,n,r=_){let i=new r(n),a=C(e,t,i);if(i.offset<n.length)throw new m(`Unexpected ${n.length-i.offset} bytes after deserialized data`);return a}t.deserialize=w;function T(e,t,n,r=_){return C(e,t,new r(n))}t.deserializeUnchecked=T})),Dr=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.s16=e.s8=e.nu64be=e.u48be=e.u40be=e.u32be=e.u24be=e.u16be=e.nu64=e.u48=e.u40=e.u32=e.u24=e.u16=e.u8=e.offset=e.greedy=e.Constant=e.UTF8=e.CString=e.Blob=e.Boolean=e.BitField=e.BitStructure=e.VariantLayout=e.Union=e.UnionLayoutDiscriminator=e.UnionDiscriminator=e.Structure=e.Sequence=e.DoubleBE=e.Double=e.FloatBE=e.Float=e.NearInt64BE=e.NearInt64=e.NearUInt64BE=e.NearUInt64=e.IntBE=e.Int=e.UIntBE=e.UInt=e.OffsetLayout=e.GreedyCount=e.ExternalLayout=e.bindConstructorLayout=e.nameWithProperty=e.Layout=e.uint8ArrayToBuffer=e.checkUint8Array=void 0,e.constant=e.utf8=e.cstr=e.blob=e.unionLayoutDiscriminator=e.union=e.seq=e.bits=e.struct=e.f64be=e.f64=e.f32be=e.f32=e.ns64be=e.s48be=e.s40be=e.s32be=e.s24be=e.s16be=e.ns64=e.s48=e.s40=e.s32=e.s24=void 0;var t=s();function n(e){if(!(e instanceof Uint8Array))throw TypeError(`b must be a Uint8Array`)}e.checkUint8Array=n;function r(e){return n(e),t.Buffer.from(e.buffer,e.byteOffset,e.length)}e.uint8ArrayToBuffer=r;var i=class{constructor(e,t){if(!Number.isInteger(e))throw TypeError(`span must be an integer`);this.span=e,this.property=t}makeDestinationObject(){return{}}getSpan(e,t){if(0>this.span)throw RangeError(`indeterminate span`);return this.span}replicate(e){let t=Object.create(this.constructor.prototype);return Object.assign(t,this),t.property=e,t}fromArray(e){}};e.Layout=i;function a(e,t){return t.property?e+`[`+t.property+`]`:e}e.nameWithProperty=a;function o(e,t){if(typeof e!=`function`)throw TypeError(`Class must be constructor`);if(Object.prototype.hasOwnProperty.call(e,`layout_`))throw Error(`Class is already bound to a layout`);if(!(t&&t instanceof i))throw TypeError(`layout must be a Layout`);if(Object.prototype.hasOwnProperty.call(t,`boundConstructor_`))throw Error(`layout is already bound to a constructor`);e.layout_=t,t.boundConstructor_=e,t.makeDestinationObject=(()=>new e),Object.defineProperty(e.prototype,"encode",{value(e,n){return t.encode(this,e,n)},writable:!0}),Object.defineProperty(e,"decode",{value(e,n){return t.decode(e,n)},writable:!0})}e.bindConstructorLayout=o;var c=class extends i{isCount(){throw Error(`ExternalLayout is abstract`)}};e.ExternalLayout=c;var l=class extends c{constructor(e=1,t){if(!Number.isInteger(e)||0>=e)throw TypeError(`elementSpan must be a (positive) integer`);super(-1,t),this.elementSpan=e}isCount(){return!0}decode(e,t=0){n(e);let r=e.length-t;return Math.floor(r/this.elementSpan)}encode(e,t,n){return 0}};e.GreedyCount=l;var u=class extends c{constructor(e,t=0,n){if(!(e instanceof i))throw TypeError(`layout must be a Layout`);if(!Number.isInteger(t))throw TypeError(`offset must be integer or undefined`);super(e.span,n||e.property),this.layout=e,this.offset=t}isCount(){return this.layout instanceof d||this.layout instanceof f}decode(e,t=0){return this.layout.decode(e,t+this.offset)}encode(e,t,n=0){return this.layout.encode(e,t,n+this.offset)}};e.OffsetLayout=u;var d=class extends i{constructor(e,t){if(super(e,t),6<this.span)throw RangeError(`span must not exceed 6 bytes`)}decode(e,t=0){return r(e).readUIntLE(t,this.span)}encode(e,t,n=0){return r(t).writeUIntLE(e,n,this.span),this.span}};e.UInt=d;var f=class extends i{constructor(e,t){if(super(e,t),6<this.span)throw RangeError(`span must not exceed 6 bytes`)}decode(e,t=0){return r(e).readUIntBE(t,this.span)}encode(e,t,n=0){return r(t).writeUIntBE(e,n,this.span),this.span}};e.UIntBE=f;var p=class extends i{constructor(e,t){if(super(e,t),6<this.span)throw RangeError(`span must not exceed 6 bytes`)}decode(e,t=0){return r(e).readIntLE(t,this.span)}encode(e,t,n=0){return r(t).writeIntLE(e,n,this.span),this.span}};e.Int=p;var m=class extends i{constructor(e,t){if(super(e,t),6<this.span)throw RangeError(`span must not exceed 6 bytes`)}decode(e,t=0){return r(e).readIntBE(t,this.span)}encode(e,t,n=0){return r(t).writeIntBE(e,n,this.span),this.span}};e.IntBE=m;var h=2**32;function g(e){let t=Math.floor(e/h);return{hi32:t,lo32:e-t*h}}function _(e,t){return e*h+t}var v=class extends i{constructor(e){super(8,e)}decode(e,t=0){let n=r(e),i=n.readUInt32LE(t);return _(n.readUInt32LE(t+4),i)}encode(e,t,n=0){let i=g(e),a=r(t);return a.writeUInt32LE(i.lo32,n),a.writeUInt32LE(i.hi32,n+4),8}};e.NearUInt64=v;var y=class extends i{constructor(e){super(8,e)}decode(e,t=0){let n=r(e);return _(n.readUInt32BE(t),n.readUInt32BE(t+4))}encode(e,t,n=0){let i=g(e),a=r(t);return a.writeUInt32BE(i.hi32,n),a.writeUInt32BE(i.lo32,n+4),8}};e.NearUInt64BE=y;var b=class extends i{constructor(e){super(8,e)}decode(e,t=0){let n=r(e),i=n.readUInt32LE(t);return _(n.readInt32LE(t+4),i)}encode(e,t,n=0){let i=g(e),a=r(t);return a.writeUInt32LE(i.lo32,n),a.writeInt32LE(i.hi32,n+4),8}};e.NearInt64=b;var x=class extends i{constructor(e){super(8,e)}decode(e,t=0){let n=r(e);return _(n.readInt32BE(t),n.readUInt32BE(t+4))}encode(e,t,n=0){let i=g(e),a=r(t);return a.writeInt32BE(i.hi32,n),a.writeUInt32BE(i.lo32,n+4),8}};e.NearInt64BE=x;var S=class extends i{constructor(e){super(4,e)}decode(e,t=0){return r(e).readFloatLE(t)}encode(e,t,n=0){return r(t).writeFloatLE(e,n),4}};e.Float=S;var C=class extends i{constructor(e){super(4,e)}decode(e,t=0){return r(e).readFloatBE(t)}encode(e,t,n=0){return r(t).writeFloatBE(e,n),4}};e.FloatBE=C;var w=class extends i{constructor(e){super(8,e)}decode(e,t=0){return r(e).readDoubleLE(t)}encode(e,t,n=0){return r(t).writeDoubleLE(e,n),8}};e.Double=w;var T=class extends i{constructor(e){super(8,e)}decode(e,t=0){return r(e).readDoubleBE(t)}encode(e,t,n=0){return r(t).writeDoubleBE(e,n),8}};e.DoubleBE=T;var E=class extends i{constructor(e,t,n){if(!(e instanceof i))throw TypeError(`elementLayout must be a Layout`);if(!(t instanceof c&&t.isCount()||Number.isInteger(t)&&0<=t))throw TypeError(`count must be non-negative integer or an unsigned integer ExternalLayout`);let r=-1;!(t instanceof c)&&0<e.span&&(r=t*e.span),super(r,n),this.elementLayout=e,this.count=t}getSpan(e,t=0){if(0<=this.span)return this.span;let n=0,r=this.count;if(r instanceof c&&(r=r.decode(e,t)),0<this.elementLayout.span)n=r*this.elementLayout.span;else{let i=0;for(;i<r;)n+=this.elementLayout.getSpan(e,t+n),++i}return n}decode(e,t=0){let n=[],r=0,i=this.count;for(i instanceof c&&(i=i.decode(e,t));r<i;)n.push(this.elementLayout.decode(e,t)),t+=this.elementLayout.getSpan(e,t),r+=1;return n}encode(e,t,n=0){let r=this.elementLayout,i=e.reduce((e,i)=>e+r.encode(i,t,n+e),0);return this.count instanceof c&&this.count.encode(e.length,t,n),i}};e.Sequence=E;var D=class extends i{constructor(e,t,n){if(!(Array.isArray(e)&&e.reduce((e,t)=>e&&t instanceof i,!0)))throw TypeError(`fields must be array of Layout instances`);typeof t==`boolean`&&n===void 0&&(n=t,t=void 0);for(let t of e)if(0>t.span&&t.property===void 0)throw Error(`fields cannot contain unnamed variable-length layout`);let r=-1;try{r=e.reduce((e,t)=>e+t.getSpan(),0)}catch{}super(r,t),this.fields=e,this.decodePrefixes=!!n}getSpan(e,t=0){if(0<=this.span)return this.span;let n=0;try{n=this.fields.reduce((n,r)=>{let i=r.getSpan(e,t);return t+=i,n+i},0)}catch{throw RangeError(`indeterminate span`)}return n}decode(e,t=0){n(e);let r=this.makeDestinationObject();for(let n of this.fields)if(n.property!==void 0&&(r[n.property]=n.decode(e,t)),t+=n.getSpan(e,t),this.decodePrefixes&&e.length===t)break;return r}encode(e,t,n=0){let r=n,i=0,a=0;for(let r of this.fields){let o=r.span;if(a=0<o?o:0,r.property!==void 0){let i=e[r.property];i!==void 0&&(a=r.encode(i,t,n),0>o&&(o=r.getSpan(t,n)))}i=n,n+=o}return i+a-r}fromArray(e){let t=this.makeDestinationObject();for(let n of this.fields)n.property!==void 0&&0<e.length&&(t[n.property]=e.shift());return t}layoutFor(e){if(typeof e!=`string`)throw TypeError(`property must be string`);for(let t of this.fields)if(t.property===e)return t}offsetOf(e){if(typeof e!=`string`)throw TypeError(`property must be string`);let t=0;for(let n of this.fields){if(n.property===e)return t;0>n.span?t=-1:0<=t&&(t+=n.span)}}};e.Structure=D;var O=class{constructor(e){this.property=e}decode(e,t){throw Error(`UnionDiscriminator is abstract`)}encode(e,t,n){throw Error(`UnionDiscriminator is abstract`)}};e.UnionDiscriminator=O;var k=class extends O{constructor(e,t){if(!(e instanceof c&&e.isCount()))throw TypeError(`layout must be an unsigned integer ExternalLayout`);super(t||e.property||`variant`),this.layout=e}decode(e,t){return this.layout.decode(e,t)}encode(e,t,n){return this.layout.encode(e,t,n)}};e.UnionLayoutDiscriminator=k;var A=class extends i{constructor(e,t,n){let r;if(e instanceof d||e instanceof f)r=new k(new u(e));else if(e instanceof c&&e.isCount())r=new k(e);else if(e instanceof O)r=e;else throw TypeError(`discr must be a UnionDiscriminator or an unsigned integer layout`);if(t===void 0&&(t=null),!(t===null||t instanceof i))throw TypeError(`defaultLayout must be null or a Layout`);if(t!==null){if(0>t.span)throw Error(`defaultLayout must have constant span`);t.property===void 0&&(t=t.replicate(`content`))}let a=-1;t&&(a=t.span,0<=a&&(e instanceof d||e instanceof f)&&(a+=r.layout.span)),super(a,n),this.discriminator=r,this.usesPrefixDiscriminator=e instanceof d||e instanceof f,this.defaultLayout=t,this.registry={};let o=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(e){return o(e)},this.configGetSourceVariant=function(e){o=e.bind(this)}}getSpan(e,t=0){if(0<=this.span)return this.span;let n=this.getVariant(e,t);if(!n)throw Error(`unable to determine span for unrecognized variant`);return n.getSpan(e,t)}defaultGetSourceVariant(e){if(Object.prototype.hasOwnProperty.call(e,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(e,this.defaultLayout.property))return;let t=this.registry[e[this.discriminator.property]];if(t&&(!t.layout||t.property&&Object.prototype.hasOwnProperty.call(e,t.property)))return t}else for(let t in this.registry){let n=this.registry[t];if(n.property&&Object.prototype.hasOwnProperty.call(e,n.property))return n}throw Error(`unable to infer src variant`)}decode(e,t=0){let n,r=this.discriminator,i=r.decode(e,t),a=this.registry[i];if(a===void 0){let a=this.defaultLayout,o=0;this.usesPrefixDiscriminator&&(o=r.layout.span),n=this.makeDestinationObject(),n[r.property]=i,n[a.property]=a.decode(e,t+o)}else n=a.decode(e,t);return n}encode(e,t,n=0){let r=this.getSourceVariant(e);if(r===void 0){let r=this.discriminator,i=this.defaultLayout,a=0;return this.usesPrefixDiscriminator&&(a=r.layout.span),r.encode(e[r.property],t,n),a+i.encode(e[i.property],t,n+a)}return r.encode(e,t,n)}addVariant(e,t,n){let r=new ee(this,e,t,n);return this.registry[e]=r,r}getVariant(e,t=0){let n;return n=e instanceof Uint8Array?this.discriminator.decode(e,t):e,this.registry[n]}};e.Union=A;var ee=class extends i{constructor(e,t,n,r){if(!(e instanceof A))throw TypeError(`union must be a Union`);if(!Number.isInteger(t)||0>t)throw TypeError(`variant must be a (non-negative) integer`);if(typeof n==`string`&&r===void 0&&(r=n,n=null),n){if(!(n instanceof i))throw TypeError(`layout must be a Layout`);if(e.defaultLayout!==null&&0<=n.span&&n.span>e.defaultLayout.span)throw Error(`variant span exceeds span of containing union`);if(typeof r!=`string`)throw TypeError(`variant must have a String property`)}let a=e.span;0>e.span&&(a=n?n.span:0,0<=a&&e.usesPrefixDiscriminator&&(a+=e.discriminator.layout.span)),super(a,r),this.union=e,this.variant=t,this.layout=n||null}getSpan(e,t=0){if(0<=this.span)return this.span;let n=0;this.union.usesPrefixDiscriminator&&(n=this.union.discriminator.layout.span);let r=0;return this.layout&&(r=this.layout.getSpan(e,t+n)),n+r}decode(e,t=0){let n=this.makeDestinationObject();if(this!==this.union.getVariant(e,t))throw Error(`variant mismatch`);let r=0;return this.union.usesPrefixDiscriminator&&(r=this.union.discriminator.layout.span),this.layout?n[this.property]=this.layout.decode(e,t+r):this.property?n[this.property]=!0:this.union.usesPrefixDiscriminator&&(n[this.union.discriminator.property]=this.variant),n}encode(e,t,n=0){let r=0;if(this.union.usesPrefixDiscriminator&&(r=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(e,this.property))throw TypeError(`variant lacks property `+this.property);this.union.discriminator.encode(this.variant,t,n);let i=r;if(this.layout&&(this.layout.encode(e[this.property],t,n+r),i+=this.layout.getSpan(t,n+r),0<=this.union.span&&i>this.union.span))throw Error(`encoded variant overruns containing union`);return i}fromArray(e){if(this.layout)return this.layout.fromArray(e)}};e.VariantLayout=ee;function j(e){return 0>e&&(e+=4294967296),e}var M=class extends i{constructor(e,t,n){if(!(e instanceof d||e instanceof f))throw TypeError(`word must be a UInt or UIntBE layout`);if(typeof t==`string`&&n===void 0&&(n=t,t=!1),4<e.span)throw RangeError(`word cannot exceed 32 bits`);super(e.span,n),this.word=e,this.msb=!!t,this.fields=[];let r=0;this._packedSetValue=function(e){return r=j(e),this},this._packedGetValue=function(){return r}}decode(e,t=0){let n=this.makeDestinationObject(),r=this.word.decode(e,t);this._packedSetValue(r);for(let t of this.fields)t.property!==void 0&&(n[t.property]=t.decode(e));return n}encode(e,t,n=0){let r=this.word.decode(t,n);this._packedSetValue(r);for(let t of this.fields)if(t.property!==void 0){let n=e[t.property];n!==void 0&&t.encode(n)}return this.word.encode(this._packedGetValue(),t,n)}addField(e,t){let n=new te(this,e,t);return this.fields.push(n),n}addBoolean(e){let t=new ne(this,e);return this.fields.push(t),t}fieldFor(e){if(typeof e!=`string`)throw TypeError(`property must be string`);for(let t of this.fields)if(t.property===e)return t}};e.BitStructure=M;var te=class{constructor(e,t,n){if(!(e instanceof M))throw TypeError(`container must be a BitStructure`);if(!Number.isInteger(t)||0>=t)throw TypeError(`bits must be positive integer`);let r=8*e.span,i=e.fields.reduce((e,t)=>e+t.bits,0);if(t+i>r)throw Error(`bits too long for span remainder (`+(r-i)+` of `+r+` remain)`);this.container=e,this.bits=t,this.valueMask=(1<<t)-1,t===32&&(this.valueMask=4294967295),this.start=i,this.container.msb&&(this.start=r-i-t),this.wordMask=j(this.valueMask<<this.start),this.property=n}decode(e,t){return j(this.container._packedGetValue()&this.wordMask)>>>this.start}encode(e){if(typeof e!=`number`||!Number.isInteger(e)||e!==j(e&this.valueMask))throw TypeError(a(`BitField.encode`,this)+` value must be integer not exceeding `+this.valueMask);let t=this.container._packedGetValue(),n=j(e<<this.start);this.container._packedSetValue(j(t&~this.wordMask)|n)}};e.BitField=te;var ne=class extends te{constructor(e,t){super(e,1,t)}decode(e,t){return!!super.decode(e,t)}encode(e){typeof e==`boolean`&&(e=+e),super.encode(e)}};e.Boolean=ne;var re=class extends i{constructor(e,t){if(!(e instanceof c&&e.isCount()||Number.isInteger(e)&&0<=e))throw TypeError(`length must be positive integer or an unsigned integer ExternalLayout`);let n=-1;e instanceof c||(n=e),super(n,t),this.length=e}getSpan(e,t){let n=this.span;return 0>n&&(n=this.length.decode(e,t)),n}decode(e,t=0){let n=this.span;return 0>n&&(n=this.length.decode(e,t)),r(e).slice(t,t+n)}encode(e,t,n){let i=this.length;if(this.length instanceof c&&(i=e.length),!(e instanceof Uint8Array&&i===e.length))throw TypeError(a(`Blob.encode`,this)+` requires (length `+i+`) Uint8Array as src`);if(n+i>t.length)throw RangeError(`encoding overruns Uint8Array`);let o=r(e);return r(t).write(o.toString(`hex`),n,i,`hex`),this.length instanceof c&&this.length.encode(i,t,n),i}};e.Blob=re;var ie=class extends i{constructor(e){super(-1,e)}getSpan(e,t=0){n(e);let r=t;for(;r<e.length&&e[r]!==0;)r+=1;return 1+r-t}decode(e,t=0){let n=this.getSpan(e,t);return r(e).slice(t,t+n-1).toString(`utf-8`)}encode(e,n,i=0){typeof e!=`string`&&(e=String(e));let a=t.Buffer.from(e,`utf8`),o=a.length;if(i+o>n.length)throw RangeError(`encoding overruns Buffer`);let s=r(n);return a.copy(s,i),s[i+o]=0,o+1}};e.CString=ie;var ae=class extends i{constructor(e,t){if(typeof e==`string`&&t===void 0&&(t=e,e=void 0),e===void 0)e=-1;else if(!Number.isInteger(e))throw TypeError(`maxSpan must be an integer`);super(-1,t),this.maxSpan=e}getSpan(e,t=0){return n(e),e.length-t}decode(e,t=0){let n=this.getSpan(e,t);if(0<=this.maxSpan&&this.maxSpan<n)throw RangeError(`text length exceeds maxSpan`);return r(e).slice(t,t+n).toString(`utf-8`)}encode(e,n,i=0){typeof e!=`string`&&(e=String(e));let a=t.Buffer.from(e,`utf8`),o=a.length;if(0<=this.maxSpan&&this.maxSpan<o)throw RangeError(`text length exceeds maxSpan`);if(i+o>n.length)throw RangeError(`encoding overruns Buffer`);return a.copy(r(n),i),o}};e.UTF8=ae;var N=class extends i{constructor(e,t){super(0,t),this.value=e}decode(e,t){return this.value}encode(e,t,n){return 0}};e.Constant=N,e.greedy=((e,t)=>new l(e,t)),e.offset=((e,t,n)=>new u(e,t,n)),e.u8=(e=>new d(1,e)),e.u16=(e=>new d(2,e)),e.u24=(e=>new d(3,e)),e.u32=(e=>new d(4,e)),e.u40=(e=>new d(5,e)),e.u48=(e=>new d(6,e)),e.nu64=(e=>new v(e)),e.u16be=(e=>new f(2,e)),e.u24be=(e=>new f(3,e)),e.u32be=(e=>new f(4,e)),e.u40be=(e=>new f(5,e)),e.u48be=(e=>new f(6,e)),e.nu64be=(e=>new y(e)),e.s8=(e=>new p(1,e)),e.s16=(e=>new p(2,e)),e.s24=(e=>new p(3,e)),e.s32=(e=>new p(4,e)),e.s40=(e=>new p(5,e)),e.s48=(e=>new p(6,e)),e.ns64=(e=>new b(e)),e.s16be=(e=>new m(2,e)),e.s24be=(e=>new m(3,e)),e.s32be=(e=>new m(4,e)),e.s40be=(e=>new m(5,e)),e.s48be=(e=>new m(6,e)),e.ns64be=(e=>new x(e)),e.f32=(e=>new S(e)),e.f32be=(e=>new C(e)),e.f64=(e=>new w(e)),e.f64be=(e=>new T(e)),e.struct=((e,t,n)=>new D(e,t,n)),e.bits=((e,t,n)=>new M(e,t,n)),e.seq=((e,t,n)=>new E(e,t,n)),e.union=((e,t,n)=>new A(e,t,n)),e.unionLayoutDiscriminator=((e,t)=>new k(e,t)),e.blob=((e,t)=>new re(e,t)),e.cstr=(e=>new ie(e)),e.utf8=((e,t)=>new ae(e,t)),e.constant=((e,t)=>new N(e,t))})),Or=n(rr()),kr=n(or()),Ar=Er(),I=n(Dr()),jr=8078e3,Mr=8078001,Nr=8078004,Pr=8078005,Fr=8078006,Ir=8078011;function Lr(e){return Array.isArray(e)?`%5B`+e.map(Lr).join(`%2C%20`)+`%5D`:typeof e==`bigint`?`${e}n`:encodeURIComponent(String(e!=null&&Object.getPrototypeOf(e)===null?{...e}:e))}function Rr([e,t]){return`${e}=${Lr(t)}`}function zr(e){let t=Object.entries(e).map(Rr).join(`&`);return btoa(t)}function Br(e,t={}){{let n=`Solana error #${e}; Decode this error by running \`npx @solana/errors decode -- ${e}`;return Object.keys(t).length&&(n+=` '${zr(t)}'`),`${n}\``}}var Vr=class extends Error{cause=this.cause;context;constructor(...[e,t]){let n,r;if(t){let{cause:e,...i}=t;e&&(r={cause:e}),Object.keys(i).length>0&&(n=i)}let i=Br(e,n);super(i,r),this.context={__code:e,...n},this.name=`SolanaError`}};function Hr(e,t){return`fixedSize`in t?t.fixedSize:t.getSizeFromValue(e)}function Ur(e){return Object.freeze({...e,encode:t=>{let n=new Uint8Array(Hr(t,e));return e.write(t,n,0),n}})}function Wr(e){return Object.freeze({...e,decode:(t,n=0)=>e.read(t,n)[0]})}function Gr(e){return`fixedSize`in e&&typeof e.fixedSize==`number`}function Kr(e,t){if(Gr(e)!==Gr(t))throw new Vr(Nr);if(Gr(e)&&Gr(t)&&e.fixedSize!==t.fixedSize)throw new Vr(Pr,{decoderFixedSize:t.fixedSize,encoderFixedSize:e.fixedSize});if(!Gr(e)&&!Gr(t)&&e.maxSize!==t.maxSize)throw new Vr(Fr,{decoderMaxSize:t.maxSize,encoderMaxSize:e.maxSize});return{...t,...e,decode:t.decode,encode:e.encode,read:t.read,write:e.write}}function qr(e,t,n=0){if(t.length-n<=0)throw new Vr(jr,{codecDescription:e})}function Jr(e,t,n,r=0){let i=n.length-r;if(i<t)throw new Vr(Mr,{bytesLength:i,codecDescription:e,expected:t})}function Yr(e,t,n,r){if(r<t||r>n)throw new Vr(Ir,{codecDescription:e,max:n,min:t,value:r})}function Xr(e){return e?.endian!==1}function Zr(e){return Ur({fixedSize:e.size,write(t,n,r){e.range&&Yr(e.name,e.range[0],e.range[1],t);let i=new ArrayBuffer(e.size);return e.set(new DataView(i),t,Xr(e.config)),n.set(new Uint8Array(i),r),r+e.size}})}function Qr(e){return Wr({fixedSize:e.size,read(t,n=0){qr(e.name,t,n),Jr(e.name,e.size,t,n);let r=new DataView($r(t,n,e.size));return[e.get(r,Xr(e.config)),n+e.size]}})}function $r(e,t,n){let r=e.byteOffset+(t??0),i=n??e.byteLength;return e.buffer.slice(r,r+i)}var ei=(e={})=>Zr({config:e,name:`u64`,range:[0n,BigInt(`0xffffffffffffffff`)],set:(e,t,n)=>e.setBigUint64(0,BigInt(t),n),size:8}),ti=(e={})=>Qr({config:e,get:(e,t)=>e.getBigUint64(0,t),name:`u64`,size:8}),ni=(e={})=>Kr(ei(e),ti(e)),ri=class extends TypeError{constructor(e,t){let n,{message:r,explanation:i,...a}=e,{path:o}=e,s=o.length===0?r:`At path: ${o.join(`.`)} -- ${r}`;super(i??s),i!=null&&(this.cause=s),Object.assign(this,a),this.name=this.constructor.name,this.failures=()=>n??=[e,...t()]}};function ii(e){return ai(e)&&typeof e[Symbol.iterator]==`function`}function ai(e){return typeof e==`object`&&!!e}function oi(e){return ai(e)&&!Array.isArray(e)}function si(e){return typeof e==`symbol`?e.toString():typeof e==`string`?JSON.stringify(e):`${e}`}function ci(e){let{done:t,value:n}=e.next();return t?void 0:n}function li(e,t,n,r){if(e===!0)return;e===!1?e={}:typeof e==`string`&&(e={message:e});let{path:i,branch:a}=t,{type:o}=n,{refinement:s,message:c=`Expected a value of type \`${o}\`${s?` with refinement \`${s}\``:``}, but received: \`${si(r)}\``}=e;return{value:r,type:o,refinement:s,key:i[i.length-1],path:i,branch:a,...e,message:c}}function*ui(e,t,n,r){ii(e)||(e=[e]);for(let i of e){let e=li(i,t,n,r);e&&(yield e)}}function*di(e,t,n={}){let{path:r=[],branch:i=[e],coerce:a=!1,mask:o=!1}=n,s={path:r,branch:i,mask:o};a&&(e=t.coercer(e,s));let c=`valid`;for(let r of t.validator(e,s))r.explanation=n.message,c=`not_valid`,yield[r,void 0];for(let[l,u,d]of t.entries(e,s)){let t=di(u,d,{path:l===void 0?r:[...r,l],branch:l===void 0?i:[...i,u],coerce:a,mask:o,message:n.message});for(let n of t)n[0]?(c=n[0].refinement==null?`not_valid`:`not_refined`,yield[n[0],void 0]):a&&(u=n[1],l===void 0?e=u:e instanceof Map?e.set(l,u):e instanceof Set?e.add(u):ai(e)&&(u!==void 0||l in e)&&(e[l]=u))}if(c!==`not_valid`)for(let r of t.refiner(e,s))r.explanation=n.message,c=`not_refined`,yield[r,void 0];c===`valid`&&(yield[void 0,e])}var fi=class{constructor(e){let{type:t,schema:n,validator:r,refiner:i,coercer:a=e=>e,entries:o=function*(){}}=e;this.type=t,this.schema=n,this.entries=o,this.coercer=a,r?this.validator=(e,t)=>ui(r(e,t),t,this,e):this.validator=()=>[],i?this.refiner=(e,t)=>ui(i(e,t),t,this,e):this.refiner=()=>[]}assert(e,t){return pi(e,this,t)}create(e,t){return L(e,this,t)}is(e){return hi(e,this)}mask(e,t){return mi(e,this,t)}validate(e,t={}){return gi(e,this,t)}};function pi(e,t,n){let r=gi(e,t,{message:n});if(r[0])throw r[0]}function L(e,t,n){let r=gi(e,t,{coerce:!0,message:n});if(r[0])throw r[0];return r[1]}function mi(e,t,n){let r=gi(e,t,{coerce:!0,mask:!0,message:n});if(r[0])throw r[0];return r[1]}function hi(e,t){return!gi(e,t)[0]}function gi(e,t,n={}){let r=di(e,t,n),i=ci(r);return i[0]?[new ri(i[0],function*(){for(let e of r)e[0]&&(yield e[0])}),void 0]:[void 0,i[1]]}function _i(e,t){return new fi({type:e,schema:null,validator:t})}function vi(){return _i(`any`,()=>!0)}function R(e){return new fi({type:`array`,schema:e,*entries(t){if(e&&Array.isArray(t))for(let[n,r]of t.entries())yield[n,r,e]},coercer(e){return Array.isArray(e)?e.slice():e},validator(e){return Array.isArray(e)||`Expected an array value, but received: ${si(e)}`}})}function yi(){return _i(`boolean`,e=>typeof e==`boolean`)}function bi(e){return _i(`instance`,t=>t instanceof e||`Expected a \`${e.name}\` instance, but received: ${si(t)}`)}function xi(e){let t=si(e),n=typeof e;return new fi({type:`literal`,schema:n===`string`||n===`number`||n===`boolean`?e:null,validator(n){return n===e||`Expected the literal \`${t}\`, but received: ${si(n)}`}})}function Si(){return _i(`never`,()=>!1)}function z(e){return new fi({...e,validator:(t,n)=>t===null||e.validator(t,n),refiner:(t,n)=>t===null||e.refiner(t,n)})}function B(){return _i(`number`,e=>typeof e==`number`&&!isNaN(e)||`Expected a number, but received: ${si(e)}`)}function V(e){return new fi({...e,validator:(t,n)=>t===void 0||e.validator(t,n),refiner:(t,n)=>t===void 0||e.refiner(t,n)})}function Ci(e,t){return new fi({type:`record`,schema:null,*entries(n){if(ai(n))for(let r in n){let i=n[r];yield[r,r,e],yield[r,i,t]}},validator(e){return oi(e)||`Expected an object, but received: ${si(e)}`},coercer(e){return oi(e)?{...e}:e}})}function H(){return _i(`string`,e=>typeof e==`string`||`Expected a string, but received: ${si(e)}`)}function wi(e){let t=Si();return new fi({type:`tuple`,schema:null,*entries(n){if(Array.isArray(n)){let r=Math.max(e.length,n.length);for(let i=0;i<r;i++)yield[i,n[i],e[i]||t]}},validator(e){return Array.isArray(e)||`Expected an array, but received: ${si(e)}`},coercer(e){return Array.isArray(e)?e.slice():e}})}function U(e){let t=Object.keys(e);return new fi({type:`type`,schema:e,*entries(n){if(ai(n))for(let r of t)yield[r,n[r],e[r]]},validator(e){return oi(e)||`Expected an object, but received: ${si(e)}`},coercer(e){return oi(e)?{...e}:e}})}function Ti(e){let t=e.map(e=>e.type).join(` | `);return new fi({type:`union`,schema:null,coercer(t,n){for(let r of e){let[e,i]=r.validate(t,{coerce:!0,mask:n.mask});if(!e)return i}return t},validator(n,r){let i=[];for(let t of e){let[...e]=di(n,t,r),[a]=e;if(a[0])for(let[t]of e)t&&i.push(t);else return[]}return[`Expected the value to satisfy a union of \`${t}\`, but received: ${si(n)}`,...i]}})}function Ei(){return _i(`unknown`,()=>!0)}function Di(e,t,n){return new fi({...e,coercer:(r,i)=>hi(r,t)?e.coercer(n(r,i),i):e.coercer(r,i)})}function Oi(){if(!ki&&(ki=typeof crypto<`u`&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<`u`&&typeof msCrypto.getRandomValues==`function`&&msCrypto.getRandomValues.bind(msCrypto),!ki))throw Error(`crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported`);return ki(Ai)}var ki,Ai,ji=t((()=>{Ai=new Uint8Array(16)})),Mi,Ni=t((()=>{Mi=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i}));function Pi(e){return typeof e==`string`&&Mi.test(e)}var Fi=t((()=>{Ni()}));function Ii(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=(Li[e[t+0]]+Li[e[t+1]]+Li[e[t+2]]+Li[e[t+3]]+`-`+Li[e[t+4]]+Li[e[t+5]]+`-`+Li[e[t+6]]+Li[e[t+7]]+`-`+Li[e[t+8]]+Li[e[t+9]]+`-`+Li[e[t+10]]+Li[e[t+11]]+Li[e[t+12]]+Li[e[t+13]]+Li[e[t+14]]+Li[e[t+15]]).toLowerCase();if(!Pi(n))throw TypeError(`Stringified UUID is invalid`);return n}var Li,Ri,zi=t((()=>{for(Fi(),Li=[],Ri=0;Ri<256;++Ri)Li.push((Ri+256).toString(16).substr(1))}));function Bi(e,t,n){var r=t&&n||0,i=t||Array(16);e||={};var a=e.node||Vi,o=e.clockseq===void 0?Hi:e.clockseq;if(a==null||o==null){var s=e.random||(e.rng||Oi)();a??=Vi=[s[0]|1,s[1],s[2],s[3],s[4],s[5]],o??=Hi=(s[6]<<8|s[7])&16383}var c=e.msecs===void 0?Date.now():e.msecs,l=e.nsecs===void 0?Wi+1:e.nsecs,u=c-Ui+(l-Wi)/1e4;if(u<0&&e.clockseq===void 0&&(o=o+1&16383),(u<0||c>Ui)&&e.nsecs===void 0&&(l=0),l>=1e4)throw Error(`uuid.v1(): Can't create more than 10M uuids/sec`);Ui=c,Wi=l,Hi=o,c+=0xb1d069b5400;var d=((c&268435455)*1e4+l)%4294967296;i[r++]=d>>>24&255,i[r++]=d>>>16&255,i[r++]=d>>>8&255,i[r++]=d&255;var f=c/4294967296*1e4&268435455;i[r++]=f>>>8&255,i[r++]=f&255,i[r++]=f>>>24&15|16,i[r++]=f>>>16&255,i[r++]=o>>>8|128,i[r++]=o&255;for(var p=0;p<6;++p)i[r+p]=a[p];return t||Ii(i)}var Vi,Hi,Ui,Wi,Gi=t((()=>{ji(),zi(),Ui=0,Wi=0}));function Ki(e){if(!Pi(e))throw TypeError(`Invalid UUID`);var t,n=new Uint8Array(16);return n[0]=(t=parseInt(e.slice(0,8),16))>>>24,n[1]=t>>>16&255,n[2]=t>>>8&255,n[3]=t&255,n[4]=(t=parseInt(e.slice(9,13),16))>>>8,n[5]=t&255,n[6]=(t=parseInt(e.slice(14,18),16))>>>8,n[7]=t&255,n[8]=(t=parseInt(e.slice(19,23),16))>>>8,n[9]=t&255,n[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,n[11]=t/4294967296&255,n[12]=t>>>24&255,n[13]=t>>>16&255,n[14]=t>>>8&255,n[15]=t&255,n}var qi=t((()=>{Fi()}));function Ji(e){e=unescape(encodeURIComponent(e));for(var t=[],n=0;n<e.length;++n)t.push(e.charCodeAt(n));return t}function Yi(e,t,n){function r(e,r,i,a){if(typeof e==`string`&&(e=Ji(e)),typeof r==`string`&&(r=Ki(r)),r.length!==16)throw TypeError(`Namespace must be array-like (16 iterable integer values, 0-255)`);var o=new Uint8Array(16+e.length);if(o.set(r),o.set(e,r.length),o=n(o),o[6]=o[6]&15|t,o[8]=o[8]&63|128,i){a||=0;for(var s=0;s<16;++s)i[a+s]=o[s];return i}return Ii(o)}try{r.name=e}catch{}return r.DNS=Xi,r.URL=Zi,r}var Xi,Zi,Qi=t((()=>{zi(),qi(),Xi=`6ba7b810-9dad-11d1-80b4-00c04fd430c8`,Zi=`6ba7b811-9dad-11d1-80b4-00c04fd430c8`}));function $i(e){if(typeof e==`string`){var t=unescape(encodeURIComponent(e));e=new Uint8Array(t.length);for(var n=0;n<t.length;++n)e[n]=t.charCodeAt(n)}return ea(na(ra(e),e.length*8))}function ea(e){for(var t=[],n=e.length*32,r=`0123456789abcdef`,i=0;i<n;i+=8){var a=e[i>>5]>>>i%32&255,o=parseInt(r.charAt(a>>>4&15)+r.charAt(a&15),16);t.push(o)}return t}function ta(e){return(e+64>>>9<<4)+14+1}function na(e,t){e[t>>5]|=128<<t%32,e[ta(t)-1]=t;for(var n=1732584193,r=-271733879,i=-1732584194,a=271733878,o=0;o<e.length;o+=16){var s=n,c=r,l=i,u=a;n=sa(n,r,i,a,e[o],7,-680876936),a=sa(a,n,r,i,e[o+1],12,-389564586),i=sa(i,a,n,r,e[o+2],17,606105819),r=sa(r,i,a,n,e[o+3],22,-1044525330),n=sa(n,r,i,a,e[o+4],7,-176418897),a=sa(a,n,r,i,e[o+5],12,1200080426),i=sa(i,a,n,r,e[o+6],17,-1473231341),r=sa(r,i,a,n,e[o+7],22,-45705983),n=sa(n,r,i,a,e[o+8],7,1770035416),a=sa(a,n,r,i,e[o+9],12,-1958414417),i=sa(i,a,n,r,e[o+10],17,-42063),r=sa(r,i,a,n,e[o+11],22,-1990404162),n=sa(n,r,i,a,e[o+12],7,1804603682),a=sa(a,n,r,i,e[o+13],12,-40341101),i=sa(i,a,n,r,e[o+14],17,-1502002290),r=sa(r,i,a,n,e[o+15],22,1236535329),n=ca(n,r,i,a,e[o+1],5,-165796510),a=ca(a,n,r,i,e[o+6],9,-1069501632),i=ca(i,a,n,r,e[o+11],14,643717713),r=ca(r,i,a,n,e[o],20,-373897302),n=ca(n,r,i,a,e[o+5],5,-701558691),a=ca(a,n,r,i,e[o+10],9,38016083),i=ca(i,a,n,r,e[o+15],14,-660478335),r=ca(r,i,a,n,e[o+4],20,-405537848),n=ca(n,r,i,a,e[o+9],5,568446438),a=ca(a,n,r,i,e[o+14],9,-1019803690),i=ca(i,a,n,r,e[o+3],14,-187363961),r=ca(r,i,a,n,e[o+8],20,1163531501),n=ca(n,r,i,a,e[o+13],5,-1444681467),a=ca(a,n,r,i,e[o+2],9,-51403784),i=ca(i,a,n,r,e[o+7],14,1735328473),r=ca(r,i,a,n,e[o+12],20,-1926607734),n=la(n,r,i,a,e[o+5],4,-378558),a=la(a,n,r,i,e[o+8],11,-2022574463),i=la(i,a,n,r,e[o+11],16,1839030562),r=la(r,i,a,n,e[o+14],23,-35309556),n=la(n,r,i,a,e[o+1],4,-1530992060),a=la(a,n,r,i,e[o+4],11,1272893353),i=la(i,a,n,r,e[o+7],16,-155497632),r=la(r,i,a,n,e[o+10],23,-1094730640),n=la(n,r,i,a,e[o+13],4,681279174),a=la(a,n,r,i,e[o],11,-358537222),i=la(i,a,n,r,e[o+3],16,-722521979),r=la(r,i,a,n,e[o+6],23,76029189),n=la(n,r,i,a,e[o+9],4,-640364487),a=la(a,n,r,i,e[o+12],11,-421815835),i=la(i,a,n,r,e[o+15],16,530742520),r=la(r,i,a,n,e[o+2],23,-995338651),n=ua(n,r,i,a,e[o],6,-198630844),a=ua(a,n,r,i,e[o+7],10,1126891415),i=ua(i,a,n,r,e[o+14],15,-1416354905),r=ua(r,i,a,n,e[o+5],21,-57434055),n=ua(n,r,i,a,e[o+12],6,1700485571),a=ua(a,n,r,i,e[o+3],10,-1894986606),i=ua(i,a,n,r,e[o+10],15,-1051523),r=ua(r,i,a,n,e[o+1],21,-2054922799),n=ua(n,r,i,a,e[o+8],6,1873313359),a=ua(a,n,r,i,e[o+15],10,-30611744),i=ua(i,a,n,r,e[o+6],15,-1560198380),r=ua(r,i,a,n,e[o+13],21,1309151649),n=ua(n,r,i,a,e[o+4],6,-145523070),a=ua(a,n,r,i,e[o+11],10,-1120210379),i=ua(i,a,n,r,e[o+2],15,718787259),r=ua(r,i,a,n,e[o+9],21,-343485551),n=ia(n,s),r=ia(r,c),i=ia(i,l),a=ia(a,u)}return[n,r,i,a]}function ra(e){if(e.length===0)return[];for(var t=e.length*8,n=new Uint32Array(ta(t)),r=0;r<t;r+=8)n[r>>5]|=(e[r/8]&255)<<r%32;return n}function ia(e,t){var n=(e&65535)+(t&65535);return(e>>16)+(t>>16)+(n>>16)<<16|n&65535}function aa(e,t){return e<<t|e>>>32-t}function oa(e,t,n,r,i,a){return ia(aa(ia(ia(t,e),ia(r,a)),i),n)}function sa(e,t,n,r,i,a,o){return oa(t&n|~t&r,e,t,i,a,o)}function ca(e,t,n,r,i,a,o){return oa(t&r|n&~r,e,t,i,a,o)}function la(e,t,n,r,i,a,o){return oa(t^n^r,e,t,i,a,o)}function ua(e,t,n,r,i,a,o){return oa(n^(t|~r),e,t,i,a,o)}var da=t((()=>{})),fa,pa=t((()=>{Qi(),da(),fa=Yi(`v3`,48,$i)}));function ma(e,t,n){e||={};var r=e.random||(e.rng||Oi)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){n||=0;for(var i=0;i<16;++i)t[n+i]=r[i];return t}return Ii(r)}var ha=t((()=>{ji(),zi()}));function ga(e,t,n,r){switch(e){case 0:return t&n^~t&r;case 1:return t^n^r;case 2:return t&n^t&r^n&r;case 3:return t^n^r}}function _a(e,t){return e<<t|e>>>32-t}function va(e){var t=[1518500249,1859775393,2400959708,3395469782],n=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof e==`string`){var r=unescape(encodeURIComponent(e));e=[];for(var i=0;i<r.length;++i)e.push(r.charCodeAt(i))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);for(var a=e.length/4+2,o=Math.ceil(a/16),s=Array(o),c=0;c<o;++c){for(var l=new Uint32Array(16),u=0;u<16;++u)l[u]=e[c*64+u*4]<<24|e[c*64+u*4+1]<<16|e[c*64+u*4+2]<<8|e[c*64+u*4+3];s[c]=l}s[o-1][14]=(e.length-1)*8/2**32,s[o-1][14]=Math.floor(s[o-1][14]),s[o-1][15]=(e.length-1)*8&4294967295;for(var d=0;d<o;++d){for(var f=new Uint32Array(80),p=0;p<16;++p)f[p]=s[d][p];for(var m=16;m<80;++m)f[m]=_a(f[m-3]^f[m-8]^f[m-14]^f[m-16],1);for(var h=n[0],g=n[1],_=n[2],v=n[3],y=n[4],b=0;b<80;++b){var x=Math.floor(b/20),S=_a(h,5)+ga(x,g,_,v)+y+t[x]+f[b]>>>0;y=v,v=_,_=_a(g,30)>>>0,g=h,h=S}n[0]=n[0]+h>>>0,n[1]=n[1]+g>>>0,n[2]=n[2]+_>>>0,n[3]=n[3]+v>>>0,n[4]=n[4]+y>>>0}return[n[0]>>24&255,n[0]>>16&255,n[0]>>8&255,n[0]&255,n[1]>>24&255,n[1]>>16&255,n[1]>>8&255,n[1]&255,n[2]>>24&255,n[2]>>16&255,n[2]>>8&255,n[2]&255,n[3]>>24&255,n[3]>>16&255,n[3]>>8&255,n[3]&255,n[4]>>24&255,n[4]>>16&255,n[4]>>8&255,n[4]&255]}var ya=t((()=>{})),ba,xa=t((()=>{Qi(),ya(),ba=Yi(`v5`,80,va)})),Sa,Ca=t((()=>{Sa=`00000000-0000-0000-0000-000000000000`}));function wa(e){if(!Pi(e))throw TypeError(`Invalid UUID`);return parseInt(e.substr(14,1),16)}var Ta=t((()=>{Fi()})),Ea=r({NIL:()=>Sa,parse:()=>Ki,stringify:()=>Ii,v1:()=>Bi,v3:()=>fa,v4:()=>ma,v5:()=>ba,validate:()=>Pi,version:()=>wa}),Da=t((()=>{Gi(),pa(),ha(),xa(),Ca(),Ta(),Fi(),zi(),qi()})),Oa=i(((t,n)=>{var r=(Da(),e(Ea)).v4;n.exports=function(e,t,n,i){if(typeof e!=`string`)throw TypeError(e+` must be a string`);i||={};let a=typeof i.version==`number`?i.version:2;if(a!==1&&a!==2)throw TypeError(a+` must be 1 or 2`);let o={method:e};if(a===2&&(o.jsonrpc=`2.0`),t){if(typeof t!=`object`&&!Array.isArray(t))throw TypeError(t+` must be an object, array or omitted`);o.params=t}return n===void 0?o.id=(typeof i.generator==`function`?i.generator:function(){return r()})(o,i):a===2&&n===null?i.notificationIdNull&&(o.id=null):o.id=n,o}})),ka=n(i(((t,n)=>{var r=(Da(),e(Ea)).v4,i=Oa(),a=function(e,t){if(!(this instanceof a))return new a(e,t);t||={},this.options={reviver:t.reviver===void 0?null:t.reviver,replacer:t.replacer===void 0?null:t.replacer,generator:t.generator===void 0?function(){return r()}:t.generator,version:t.version===void 0?2:t.version,notificationIdNull:typeof t.notificationIdNull==`boolean`?t.notificationIdNull:!1},this.callServer=e};n.exports=a,a.prototype.request=function(e,t,n,r){let a=this,o=null,s=Array.isArray(e)&&typeof t==`function`;if(this.options.version===1&&s)throw TypeError(`JSON-RPC 1.0 does not support batching`);if(s||!s&&e&&typeof e==`object`&&typeof t==`function`)r=t,o=e;else{typeof n==`function`&&(r=n,n=void 0);let a=typeof r==`function`;try{o=i(e,t,n,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(e){if(a){r(e);return}throw e}if(!a)return o}let c;try{c=JSON.stringify(o,this.options.replacer)}catch(e){r(e);return}return this.callServer(c,function(e,t){a._parseResponse(e,t,r)}),o},a.prototype._parseResponse=function(e,t,n){if(e){n(e);return}if(!t){n();return}let r;try{r=JSON.parse(t,this.options.reviver)}catch(e){n(e);return}if(n.length===3)if(Array.isArray(r)){let e=function(e){return e.error!==void 0};n(null,r.filter(e),r.filter(function(t){return!e(t)}));return}else{n(null,r.error,r.result);return}n(null,r)}}))()),Aa=class extends o.default{socket;constructor(e,t){super(),this.socket=new window.WebSocket(e,t.protocols),this.socket.onopen=()=>this.emit(`open`),this.socket.onmessage=e=>this.emit(`message`,e.data),this.socket.onerror=e=>this.emit(`error`,e),this.socket.onclose=e=>{this.emit(`close`,e.code,e.reason)}}send(e,t,n){let r=n||t;try{this.socket.send(e),r()}catch(e){r(e)}}close(e,t){this.socket.close(e,t)}addEventListener(e,t,n){this.socket.addEventListener(e,t,n)}};function ja(e,t){return new Aa(e,t)}var Ma=class{encode(e){return JSON.stringify(e)}decode(e){return JSON.parse(e)}},Na=class extends o.default{address;rpc_id;queue;options;autoconnect;ready;reconnect;reconnect_timer_id;reconnect_interval;max_reconnects;rest_options;current_reconnects;generate_request_id;socket;webSocketFactory;dataPack;constructor(e,t=`ws://localhost:8080`,{autoconnect:n=!0,reconnect:r=!0,reconnect_interval:i=1e3,max_reconnects:a=5,...o}={},s,c){super(),this.webSocketFactory=e,this.queue={},this.rpc_id=0,this.address=t,this.autoconnect=n,this.ready=!1,this.reconnect=r,this.reconnect_timer_id=void 0,this.reconnect_interval=i,this.max_reconnects=a,this.rest_options=o,this.current_reconnects=0,this.generate_request_id=s||(()=>typeof this.rpc_id==`number`?++this.rpc_id:Number(this.rpc_id)+1),c?this.dataPack=c:this.dataPack=new Ma,this.autoconnect&&this._connect(this.address,{autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects,...this.rest_options})}connect(){this.socket||this._connect(this.address,{autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects,...this.rest_options})}call(e,t,n,r){return!r&&typeof n==`object`&&(r=n,n=null),new Promise((i,a)=>{if(!this.ready)return a(Error(`socket not ready`));let o=this.generate_request_id(e,t),s={jsonrpc:`2.0`,method:e,params:t||void 0,id:o};this.socket.send(this.dataPack.encode(s),r,e=>{if(e)return a(e);this.queue[o]={promise:[i,a]},n&&(this.queue[o].timeout=setTimeout(()=>{delete this.queue[o],a(Error(`reply timeout`))},n))})})}async login(e){let t=await this.call(`rpc.login`,e);if(!t)throw Error(`authentication failed`);return t}async listMethods(){return await this.call(`__listMethods`)}notify(e,t){return new Promise((n,r)=>{if(!this.ready)return r(Error(`socket not ready`));let i={jsonrpc:`2.0`,method:e,params:t};this.socket.send(this.dataPack.encode(i),e=>{if(e)return r(e);n()})})}async subscribe(e){typeof e==`string`&&(e=[e]);let t=await this.call(`rpc.on`,e);if(typeof e==`string`&&t[e]!==`ok`)throw Error(`Failed subscribing to an event '`+e+`' with: `+t[e]);return t}async unsubscribe(e){typeof e==`string`&&(e=[e]);let t=await this.call(`rpc.off`,e);if(typeof e==`string`&&t[e]!==`ok`)throw Error(`Failed unsubscribing from an event with: `+t);return t}close(e,t){this.socket&&this.socket.close(e||1e3,t)}setAutoReconnect(e){this.reconnect=e}setReconnectInterval(e){this.reconnect_interval=e}setMaxReconnects(e){this.max_reconnects=e}getCurrentReconnects(){return this.current_reconnects}getMaxReconnects(){return this.max_reconnects}isReconnecting(){return this.reconnect_timer_id!==void 0}willReconnect(){return this.reconnect&&(this.max_reconnects===0||this.current_reconnects<this.max_reconnects)}_connect(e,t){clearTimeout(this.reconnect_timer_id),this.socket=this.webSocketFactory(e,t),this.socket.addEventListener(`open`,()=>{this.ready=!0,this.emit(`open`),this.current_reconnects=0}),this.socket.addEventListener(`message`,({data:e})=>{e instanceof ArrayBuffer&&(e=F.Buffer.from(e).toString());try{e=this.dataPack.decode(e)}catch{return}if(e.notification&&this.listeners(e.notification).length){if(!Object.keys(e.params).length)return this.emit(e.notification);let t=[e.notification];if(e.params.constructor===Object)t.push(e.params);else for(let n=0;n<e.params.length;n++)t.push(e.params[n]);return Promise.resolve().then(()=>{this.emit.apply(this,t)})}if(!this.queue[e.id])return e.method?Promise.resolve().then(()=>{this.emit(e.method,e?.params)}):void 0;`error`in e==`result`in e&&this.queue[e.id].promise[1](Error(`Server response malformed. Response must include either "result" or "error", but not both.`)),this.queue[e.id].timeout&&clearTimeout(this.queue[e.id].timeout),e.error?this.queue[e.id].promise[1](e.error):this.queue[e.id].promise[0](e.result),delete this.queue[e.id]}),this.socket.addEventListener(`error`,e=>this.emit(`error`,e)),this.socket.addEventListener(`close`,({code:n,reason:r})=>{this.ready&&setTimeout(()=>this.emit(`close`,n,r),0),this.ready=!1,this.socket=void 0,n!==1e3&&(this.current_reconnects++,this.reconnect&&(this.max_reconnects>this.current_reconnects||this.max_reconnects===0)?this.reconnect_timer_id=setTimeout(()=>this._connect(e,t),this.reconnect_interval):this.reconnect&&this.max_reconnects>0&&this.current_reconnects>=this.max_reconnects&&setTimeout(()=>this.emit(`max_reconnects_reached`,n,r),1))})}},Pa=(e,t)=>(e+(e>=0?t:-t)/Va)/t;function Fa(e,t,n){let[[r,i],[a,o]]=t,s=Pa(o*e,n),c=Pa(-i*e,n),l=e-s*r-c*a,u=-s*i-c*o,d=l<za,f=u<za;d&&(l=-l),f&&(u=-u);let p=xt(Math.ceil(bt(n)/2))+Ba;if(l<za||l>=p||u<za||u>=p)throw Error(`splitScalar (endomorphism): failed, k=`+e);return{k1neg:d,k1:l,k2neg:f,k2:u}}function Ia(e){if(![`compact`,`recovered`,`der`].includes(e))throw Error(`Signature format must be "compact", "recovered", or "der"`);return e}function La(e,t){let n={};for(let r of Object.keys(t))n[r]=e[r]===void 0?t[r]:e[r];return ot(n.lowS,`lowS`),ot(n.prehash,`prehash`),n.format!==void 0&&Ia(n.format),n}var Ra={Err:class extends Error{constructor(e=``){super(e)}},_tlv:{encode:(e,t)=>{let{Err:n}=Ra;if(e<0||e>256)throw new n(`tlv.encode: wrong tag`);if(t.length&1)throw new n(`tlv.encode: unpadded data`);let r=t.length/2,i=ct(r);if(i.length/2&128)throw new n(`tlv.encode: long form length too big`);let a=r>127?ct(i.length/2|128):``;return ct(e)+a+i+t},decode(e,t){let{Err:n}=Ra,r=0;if(e<0||e>256)throw new n(`tlv.encode: wrong tag`);if(t.length<2||t[r++]!==e)throw new n(`tlv.decode: wrong tlv`);let i=t[r++],a=!!(i&128),o=0;if(!a)o=i;else{let e=i&127;if(!e)throw new n(`tlv.decode(long): indefinite length not supported`);if(e>4)throw new n(`tlv.decode(long): byte length is too big`);let a=t.subarray(r,r+e);if(a.length!==e)throw new n(`tlv.decode: length bytes not complete`);if(a[0]===0)throw new n(`tlv.decode(long): zero leftmost byte`);for(let e of a)o=o<<8|e;if(r+=e,o<128)throw new n(`tlv.decode(long): not minimal encoding`)}let s=t.subarray(r,r+o);if(s.length!==o)throw new n(`tlv.decode: wrong value length`);return{v:s,l:t.subarray(r+o)}}},_int:{encode(e){let{Err:t}=Ra;if(e<za)throw new t(`integer: negative integers are not allowed`);let n=ct(e);if(Number.parseInt(n[0],16)&8&&(n=`00`+n),n.length&1)throw new t(`unexpected DER parsing assertion: unpadded hex`);return n},decode(e){let{Err:t}=Ra;if(e[0]&128)throw new t(`invalid signature integer: negative`);if(e[0]===0&&!(e[1]&128))throw new t(`invalid signature integer: unnecessary leading zero`);return ut(e)}},toSig(e){let{Err:t,_int:n,_tlv:r}=Ra,i=mt(`signature`,e),{v:a,l:o}=r.decode(48,i);if(o.length)throw new t(`invalid signature: left bytes after parsing`);let{v:s,l:c}=r.decode(2,a),{v:l,l:u}=r.decode(2,c);if(u.length)throw new t(`invalid signature: left bytes after parsing`);return{r:n.decode(s),s:n.decode(l)}},hexFromSig(e){let{_tlv:t,_int:n}=Ra,r=t.encode(2,n.encode(e.r))+t.encode(2,n.encode(e.s));return t.encode(48,r)}},za=BigInt(0),Ba=BigInt(1),Va=BigInt(2),Ha=BigInt(3),Ua=BigInt(4);function Wa(e,t){let{BYTES:n}=e,r;if(typeof t==`bigint`)r=t;else{let i=mt(`private key`,t);try{r=e.fromBytes(i)}catch{throw Error(`invalid private key: expected ui8a of size ${n}, got ${typeof t}`)}}if(!e.isValidNot0(r))throw Error(`invalid private key: out of range [1..N-1]`);return r}function Ga(e,t={}){let n=bn(`weierstrass`,e,t),{Fp:r,Fn:i}=n,a=n.CURVE,{h:o,n:s}=a;Ct(t,{},{allowInfinityPoint:`boolean`,clearCofactor:`function`,isTorsionFree:`function`,fromBytes:`function`,toBytes:`function`,endo:`object`,wrapPrivateKey:`boolean`});let{endo:c}=t;if(c&&(!r.is0(a.a)||typeof c.beta!=`bigint`||!Array.isArray(c.basises)))throw Error(`invalid endo: expected "beta": bigint and "basises": array`);let l=qa(r,i);function u(){if(!r.isOdd)throw Error(`compression is not supported: Field does not have .isOdd()`)}function d(e,t,n){let{x:i,y:a}=t.toAffine(),o=r.toBytes(i);return ot(n,`isCompressed`),n?(u(),_e(Ka(!r.isOdd(a)),o)):_e(Uint8Array.of(4),o,r.toBytes(a))}function f(e){st(e,void 0,`Point`);let{publicKey:t,publicKeyUncompressed:n}=l,i=e.length,a=e[0],o=e.subarray(1);if(i===t&&(a===2||a===3)){let e=r.fromBytes(o);if(!r.isValid(e))throw Error(`bad point: is not on curve, wrong x`);let t=h(e),n;try{n=r.sqrt(t)}catch(e){let t=e instanceof Error?`: `+e.message:``;throw Error(`bad point: is not on curve, sqrt error`+t)}u();let i=r.isOdd(n);return(a&1)==1!==i&&(n=r.neg(n)),{x:e,y:n}}else if(i===n&&a===4){let e=r.BYTES,t=r.fromBytes(o.subarray(0,e)),n=r.fromBytes(o.subarray(e,e*2));if(!g(t,n))throw Error(`bad point: is not on curve`);return{x:t,y:n}}else throw Error(`bad point: got length ${i}, expected compressed=${t} or uncompressed=${n}`)}let p=t.toBytes||d,m=t.fromBytes||f;function h(e){let t=r.sqr(e),n=r.mul(t,e);return r.add(r.add(n,r.mul(e,a.a)),a.b)}function g(e,t){let n=r.sqr(t),i=h(e);return r.eql(n,i)}if(!g(a.Gx,a.Gy))throw Error(`bad curve params: generator point`);let _=r.mul(r.pow(a.a,Ha),Ua),v=r.mul(r.sqr(a.b),BigInt(27));if(r.is0(r.add(_,v)))throw Error(`bad curve params: a or b`);function y(e,t,n=!1){if(!r.isValid(t)||n&&r.is0(t))throw Error(`bad point coordinate ${e}`);return t}function b(e){if(!(e instanceof T))throw Error(`ProjectivePoint expected`)}function x(e){if(!c||!c.basises)throw Error(`no endo`);return Fa(e,c.basises,i.ORDER)}let S=Tt((e,t)=>{let{X:n,Y:i,Z:a}=e;if(r.eql(a,r.ONE))return{x:n,y:i};let o=e.is0();t??=o?r.ONE:r.inv(a);let s=r.mul(n,t),c=r.mul(i,t),l=r.mul(a,t);if(o)return{x:r.ZERO,y:r.ZERO};if(!r.eql(l,r.ONE))throw Error(`invZ was invalid`);return{x:s,y:c}}),C=Tt(e=>{if(e.is0()){if(t.allowInfinityPoint&&!r.is0(e.Y))return;throw Error(`bad point: ZERO`)}let{x:n,y:i}=e.toAffine();if(!r.isValid(n)||!r.isValid(i))throw Error(`bad point: x or y not field elements`);if(!g(n,i))throw Error(`bad point: equation left != right`);if(!e.isTorsionFree())throw Error(`bad point: not in prime-order subgroup`);return!0});function w(e,t,n,i,a){return n=new T(r.mul(n.X,e),n.Y,n.Z),t=an(i,t),n=an(a,n),t.add(n)}class T{constructor(e,t,n){this.X=y(`x`,e),this.Y=y(`y`,t,!0),this.Z=y(`z`,n),Object.freeze(this)}static CURVE(){return a}static fromAffine(e){let{x:t,y:n}=e||{};if(!e||!r.isValid(t)||!r.isValid(n))throw Error(`invalid affine point`);if(e instanceof T)throw Error(`projective point not allowed`);return r.is0(t)&&r.is0(n)?T.ZERO:new T(t,n,r.ONE)}static fromBytes(e){let t=T.fromAffine(m(st(e,void 0,`point`)));return t.assertValidity(),t}static fromHex(e){return T.fromBytes(mt(`pointHex`,e))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(e=8,t=!0){return D.createCache(this,e),t||this.multiply(Ha),this}assertValidity(){C(this)}hasEvenY(){let{y:e}=this.toAffine();if(!r.isOdd)throw Error(`Field doesn't support isOdd`);return!r.isOdd(e)}equals(e){b(e);let{X:t,Y:n,Z:i}=this,{X:a,Y:o,Z:s}=e,c=r.eql(r.mul(t,s),r.mul(a,i)),l=r.eql(r.mul(n,s),r.mul(o,i));return c&&l}negate(){return new T(this.X,r.neg(this.Y),this.Z)}double(){let{a:e,b:t}=a,n=r.mul(t,Ha),{X:i,Y:o,Z:s}=this,c=r.ZERO,l=r.ZERO,u=r.ZERO,d=r.mul(i,i),f=r.mul(o,o),p=r.mul(s,s),m=r.mul(i,o);return m=r.add(m,m),u=r.mul(i,s),u=r.add(u,u),c=r.mul(e,u),l=r.mul(n,p),l=r.add(c,l),c=r.sub(f,l),l=r.add(f,l),l=r.mul(c,l),c=r.mul(m,c),u=r.mul(n,u),p=r.mul(e,p),m=r.sub(d,p),m=r.mul(e,m),m=r.add(m,u),u=r.add(d,d),d=r.add(u,d),d=r.add(d,p),d=r.mul(d,m),l=r.add(l,d),p=r.mul(o,s),p=r.add(p,p),d=r.mul(p,m),c=r.sub(c,d),u=r.mul(p,f),u=r.add(u,u),u=r.add(u,u),new T(c,l,u)}add(e){b(e);let{X:t,Y:n,Z:i}=this,{X:o,Y:s,Z:c}=e,l=r.ZERO,u=r.ZERO,d=r.ZERO,f=a.a,p=r.mul(a.b,Ha),m=r.mul(t,o),h=r.mul(n,s),g=r.mul(i,c),_=r.add(t,n),v=r.add(o,s);_=r.mul(_,v),v=r.add(m,h),_=r.sub(_,v),v=r.add(t,i);let y=r.add(o,c);return v=r.mul(v,y),y=r.add(m,g),v=r.sub(v,y),y=r.add(n,i),l=r.add(s,c),y=r.mul(y,l),l=r.add(h,g),y=r.sub(y,l),d=r.mul(f,v),l=r.mul(p,g),d=r.add(l,d),l=r.sub(h,d),d=r.add(h,d),u=r.mul(l,d),h=r.add(m,m),h=r.add(h,m),g=r.mul(f,g),v=r.mul(p,v),h=r.add(h,g),g=r.sub(m,g),g=r.mul(f,g),v=r.add(v,g),m=r.mul(h,v),u=r.add(u,m),m=r.mul(y,v),l=r.mul(_,l),l=r.sub(l,m),m=r.mul(_,h),d=r.mul(y,d),d=r.add(d,m),new T(l,u,d)}subtract(e){return this.add(e.negate())}is0(){return this.equals(T.ZERO)}multiply(e){let{endo:n}=t;if(!i.isValidNot0(e))throw Error(`invalid scalar: out of range`);let r,a,o=e=>D.cached(this,e,e=>on(T,e));if(n){let{k1neg:t,k1:i,k2neg:s,k2:c}=x(e),{p:l,f:u}=o(i),{p:d,f}=o(c);a=u.add(f),r=w(n.beta,l,d,t,s)}else{let{p:t,f:n}=o(e);r=t,a=n}return on(T,[r,a])[0]}multiplyUnsafe(e){let{endo:n}=t,r=this;if(!i.isValid(e))throw Error(`invalid scalar: out of range`);if(e===za||r.is0())return T.ZERO;if(e===Ba)return r;if(D.hasCache(this))return this.multiply(e);if(n){let{k1neg:t,k1:i,k2neg:a,k2:o}=x(e),{p1:s,p2:c}=_n(T,r,i,o);return w(n.beta,s,c,t,a)}else return D.unsafe(r,e)}multiplyAndAddUnsafe(e,t,n){let r=this.multiplyUnsafe(t).add(e.multiplyUnsafe(n));return r.is0()?void 0:r}toAffine(e){return S(this,e)}isTorsionFree(){let{isTorsionFree:e}=t;return o===Ba?!0:e?e(T,this):D.unsafe(this,s).is0()}clearCofactor(){let{clearCofactor:e}=t;return o===Ba?this:e?e(T,this):this.multiplyUnsafe(o)}isSmallOrder(){return this.multiplyUnsafe(o).is0()}toBytes(e=!0){return ot(e,`isCompressed`),this.assertValidity(),p(T,this,e)}toHex(e=!0){return fe(this.toBytes(e))}toString(){return`<Point ${this.is0()?`ZERO`:this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(e=!0){return this.toBytes(e)}_setWindowSize(e){this.precompute(e)}static normalizeZ(e){return on(T,e)}static msm(e,t){return vn(T,i,e,t)}static fromPrivateKey(e){return T.BASE.multiply(Wa(i,e))}}T.BASE=new T(a.Gx,a.Gy,r.ONE),T.ZERO=new T(r.ZERO,r.ONE,r.ZERO),T.Fp=r,T.Fn=i;let E=i.BITS,D=new gn(T,t.endo?Math.ceil(E/2):E);return T.BASE.precompute(8),T}function Ka(e){return Uint8Array.of(e?2:3)}function qa(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function Ja(e,t={}){let{Fn:n}=e,r=t.randomBytes||be,i=Object.assign(qa(e.Fp,n),{seed:en(n.ORDER)});function a(e){try{return!!Wa(n,e)}catch{return!1}}function o(t,n){let{publicKey:r,publicKeyUncompressed:a}=i;try{let i=t.length;return n===!0&&i!==r||n===!1&&i!==a?!1:!!e.fromBytes(t)}catch{return!1}}function s(e=r(i.seed)){return tn(st(e,i.seed,`seed`),n.ORDER)}function c(t,r=!0){return e.BASE.multiply(Wa(n,t)).toBytes(r)}function l(e){let t=s(e);return{secretKey:t,publicKey:c(t)}}function u(t){if(typeof t==`bigint`)return!1;if(t instanceof e)return!0;let{secretKey:r,publicKey:a,publicKeyUncompressed:o}=i;if(n.allowedLengths||r===a)return;let s=mt(`key`,t).length;return s===a||s===o}function d(t,r,i=!0){if(u(t)===!0)throw Error(`first arg must be private key`);if(u(r)===!1)throw Error(`second arg must be public key`);let a=Wa(n,t);return e.fromHex(r).multiply(a).toBytes(i)}return Object.freeze({getPublicKey:c,getSharedSecret:d,keygen:l,Point:e,utils:{isValidSecretKey:a,isValidPublicKey:o,randomSecretKey:s,isValidPrivateKey:a,randomPrivateKey:s,normPrivateKeyToScalar:e=>Wa(n,e),precompute(t=8,n=e.BASE){return n.precompute(t,!1)}},lengths:i})}function Ya(e,t,n={}){M(t),Ct(n,{},{hmac:`function`,lowS:`boolean`,randomBytes:`function`,bits2int:`function`,bits2int_modN:`function`});let r=n.randomBytes||be,i=n.hmac||((e,...n)=>rt(t,e,_e(...n))),{Fp:a,Fn:o}=e,{ORDER:s,BITS:c}=o,{keygen:l,getPublicKey:u,getSharedSecret:d,utils:f,lengths:p}=Ja(e,n),m={prehash:!1,lowS:typeof n.lowS==`boolean`?n.lowS:!1,format:void 0,extraEntropy:!1},h=`compact`;function g(e){return e>s>>Ba}function _(e,t){if(!o.isValidNot0(t))throw Error(`invalid signature ${e}: out of range 1..Point.Fn.ORDER`);return t}function v(e,t){Ia(t);let n=p.signature;return st(e,t===`compact`?n:t===`recovered`?n+1:void 0,`${t} signature`)}class y{constructor(e,t,n){this.r=_(`r`,e),this.s=_(`s`,t),n!=null&&(this.recovery=n),Object.freeze(this)}static fromBytes(e,t=h){v(e,t);let n;if(t===`der`){let{r:t,s:n}=Ra.toSig(st(e));return new y(t,n)}t===`recovered`&&(n=e[0],t=`compact`,e=e.subarray(1));let r=o.BYTES,i=e.subarray(0,r),a=e.subarray(r,r*2);return new y(o.fromBytes(i),o.fromBytes(a),n)}static fromHex(e,t){return this.fromBytes(me(e),t)}addRecoveryBit(e){return new y(this.r,this.s,e)}recoverPublicKey(t){let n=a.ORDER,{r,s:i,recovery:c}=this;if(c==null||![0,1,2,3].includes(c))throw Error(`recovery id invalid`);if(s*Va<n&&c>1)throw Error(`recovery id is ambiguous for h>1 curve`);let l=c===2||c===3?r+s:r;if(!a.isValid(l))throw Error(`recovery id 2 or 3 invalid`);let u=a.toBytes(l),d=e.fromBytes(_e(Ka((c&1)==0),u)),f=o.inv(l),p=x(mt(`msgHash`,t)),m=o.create(-p*f),h=o.create(i*f),g=e.BASE.multiplyUnsafe(m).add(d.multiplyUnsafe(h));if(g.is0())throw Error(`point at infinify`);return g.assertValidity(),g}hasHighS(){return g(this.s)}toBytes(e=h){if(Ia(e),e===`der`)return me(Ra.hexFromSig(this));let t=o.toBytes(this.r),n=o.toBytes(this.s);if(e===`recovered`){if(this.recovery==null)throw Error(`recovery bit must be present`);return _e(Uint8Array.of(this.recovery),t,n)}return _e(t,n)}toHex(e){return fe(this.toBytes(e))}assertValidity(){}static fromCompact(e){return y.fromBytes(mt(`sig`,e),`compact`)}static fromDER(e){return y.fromBytes(mt(`sig`,e),`der`)}normalizeS(){return this.hasHighS()?new y(this.r,o.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes(`der`)}toDERHex(){return fe(this.toBytes(`der`))}toCompactRawBytes(){return this.toBytes(`compact`)}toCompactHex(){return fe(this.toBytes(`compact`))}}let b=n.bits2int||function(e){if(e.length>8192)throw Error(`input is too large`);let t=ut(e),n=e.length*8-c;return n>0?t>>BigInt(n):t},x=n.bits2int_modN||function(e){return o.create(b(e))},S=xt(c);function C(e){return yt(`num < 2^`+c,e,za,S),o.toBytes(e)}function w(e,n){return st(e,void 0,`message`),n?st(t(e),void 0,`prehashed message`):e}function T(t,n,i){if([`recovered`,`canonical`].some(e=>e in i))throw Error(`sign() legacy options not supported`);let{lowS:a,prehash:s,extraEntropy:c}=La(i,m);t=w(t,s);let l=x(t),u=Wa(o,n),d=[C(u),C(l)];if(c!=null&&c!==!1){let e=c===!0?r(p.secretKey):c;d.push(mt(`extraEntropy`,e))}let f=_e(...d),h=l;function _(t){let n=b(t);if(!o.isValidNot0(n))return;let r=o.inv(n),i=e.BASE.multiply(n).toAffine(),s=o.create(i.x);if(s===za)return;let c=o.create(r*o.create(h+s*u));if(c===za)return;let l=(i.x===s?0:2)|Number(i.y&Ba),d=c;return a&&g(c)&&(d=o.neg(c),l^=1),new y(s,d,l)}return{seed:f,k2sig:_}}function E(e,n,r={}){e=mt(`message`,e);let{seed:a,k2sig:s}=T(e,n,r);return St(t.outputLen,o.BYTES,i)(a,s)}function D(e){let t,n=typeof e==`string`||A(e),r=!n&&typeof e==`object`&&!!e&&typeof e.r==`bigint`&&typeof e.s==`bigint`;if(!n&&!r)throw Error(`invalid signature, expected Uint8Array, hex string or Signature instance`);if(r)t=new y(e.r,e.s);else if(n){try{t=y.fromBytes(mt(`sig`,e),`der`)}catch(e){if(!(e instanceof Ra.Err))throw e}if(!t)try{t=y.fromBytes(mt(`sig`,e),`compact`)}catch{return!1}}return t||!1}function O(t,n,r,i={}){let{lowS:a,prehash:s,format:c}=La(i,m);if(r=mt(`publicKey`,r),n=w(mt(`message`,n),s),`strict`in i)throw Error(`options.strict was renamed to lowS`);let l=c===void 0?D(t):y.fromBytes(mt(`sig`,t),c);if(l===!1)return!1;try{let t=e.fromBytes(r);if(a&&l.hasHighS())return!1;let{r:i,s}=l,c=x(n),u=o.inv(s),d=o.create(c*u),f=o.create(i*u),p=e.BASE.multiplyUnsafe(d).add(t.multiplyUnsafe(f));return p.is0()?!1:o.create(p.x)===i}catch{return!1}}function k(e,t,n={}){let{prehash:r}=La(n,m);return t=w(t,r),y.fromBytes(e,`recovered`).recoverPublicKey(t).toBytes()}return Object.freeze({keygen:l,getPublicKey:u,getSharedSecret:d,utils:f,lengths:p,Point:e,sign:E,verify:O,recoverPublicKey:k,Signature:y,hash:t})}function Xa(e){let t={a:e.a,b:e.b,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},n=e.Fp,r=e.allowedPrivateKeyLengths?Array.from(new Set(e.allowedPrivateKeyLengths.map(e=>Math.ceil(e/2)))):void 0;return{CURVE:t,curveOpts:{Fp:n,Fn:Qt(t.n,{BITS:e.nBitLength,allowedLengths:r,modFromBytes:e.wrapPrivateKey}),allowInfinityPoint:e.allowInfinityPoint,endo:e.endo,isTorsionFree:e.isTorsionFree,clearCofactor:e.clearCofactor,fromBytes:e.fromBytes,toBytes:e.toBytes}}}function Za(e){let{CURVE:t,curveOpts:n}=Xa(e),r={hmac:e.hmac,randomBytes:e.randomBytes,lowS:e.lowS,bits2int:e.bits2int,bits2int_modN:e.bits2int_modN};return{CURVE:t,curveOpts:n,hash:e.hash,ecdsaOpts:r}}function Qa(e,t){let n=t.Point;return Object.assign({},t,{ProjectivePoint:n,CURVE:Object.assign({},e,Zt(n.Fn.ORDER,n.Fn.BITS))})}function $a(e){let{CURVE:t,curveOpts:n,hash:r,ecdsaOpts:i}=Za(e);return Qa(e,Ya(Ga(t,n),r,i))}function eo(e,t){let n=t=>$a({...e,hash:t});return{...n(t),create:n}}var to={p:BigInt(`0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f`),n:BigInt(`0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141`),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt(`0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798`),Gy:BigInt(`0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8`)},no={beta:BigInt(`0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee`),basises:[[BigInt(`0x3086d221a7d46bcde86c90e49284eb15`),-BigInt(`0xe4437ed6010e88286f547fa90abfe4c3`)],[BigInt(`0x114ca50f7a8e2f3f657c1108d9d44cfd8`),BigInt(`0x3086d221a7d46bcde86c90e49284eb15`)]]},ro=BigInt(2);function io(e){let t=to.p,n=BigInt(3),r=BigInt(6),i=BigInt(11),a=BigInt(22),o=BigInt(23),s=BigInt(44),c=BigInt(88),l=e*e*e%t,u=l*l*e%t,d=Lt(Lt(Lt(u,n,t)*u%t,n,t)*u%t,ro,t)*l%t,f=Lt(d,i,t)*d%t,p=Lt(f,a,t)*f%t,m=Lt(p,s,t)*p%t,h=Lt(Lt(Lt(Lt(Lt(Lt(m,c,t)*m%t,s,t)*p%t,n,t)*u%t,o,t)*f%t,r,t)*l%t,ro,t);if(!ao.eql(ao.sqr(h),e))throw Error(`Cannot find square root`);return h}var ao=Qt(to.p,{sqrt:io}),oo=eo({...to,Fp:ao,lowS:!0,endo:no},$e),so=r({Account:()=>xo,AddressLookupTableAccount:()=>Ps,AddressLookupTableInstruction:()=>Ml,AddressLookupTableProgram:()=>Nl,Authorized:()=>Zl,BLOCKHASH_CACHE_TIMEOUT_MS:()=>Vs,BPF_LOADER_DEPRECATED_PROGRAM_ID:()=>So,BPF_LOADER_PROGRAM_ID:()=>ys,BpfLoader:()=>bs,COMPUTE_BUDGET_INSTRUCTION_LAYOUTS:()=>Fl,ComputeBudgetInstruction:()=>Pl,ComputeBudgetProgram:()=>Il,Connection:()=>kl,Ed25519Program:()=>Vl,Enum:()=>go,EpochSchedule:()=>ks,FeeCalculatorLayout:()=>ls,Keypair:()=>Al,LAMPORTS_PER_SOL:()=>bu,LOOKUP_TABLE_INSTRUCTION_LAYOUTS:()=>jl,Loader:()=>vs,Lockup:()=>Ql,MAX_SEED_LENGTH:()=>32,Message:()=>Ho,MessageAccountKeys:()=>Oo,MessageV0:()=>Uo,NONCE_ACCOUNT_LENGTH:()=>ds,NonceAccount:()=>fs,PACKET_DATA_SIZE:()=>Co,PUBLIC_KEY_LENGTH:()=>32,PublicKey:()=>G,SIGNATURE_LENGTH_IN_BYTES:()=>64,SOLANA_SCHEMA:()=>_o,STAKE_CONFIG_ID:()=>Xl,STAKE_INSTRUCTION_LAYOUTS:()=>eu,SYSTEM_INSTRUCTION_LAYOUTS:()=>hs,SYSVAR_CLOCK_PUBKEY:()=>Xo,SYSVAR_EPOCH_SCHEDULE_PUBKEY:()=>Zo,SYSVAR_INSTRUCTIONS_PUBKEY:()=>Qo,SYSVAR_RECENT_BLOCKHASHES_PUBKEY:()=>$o,SYSVAR_RENT_PUBKEY:()=>es,SYSVAR_REWARDS_PUBKEY:()=>ts,SYSVAR_SLOT_HASHES_PUBKEY:()=>ns,SYSVAR_SLOT_HISTORY_PUBKEY:()=>rs,SYSVAR_STAKE_HISTORY_PUBKEY:()=>is,Secp256k1Program:()=>Jl,SendTransactionError:()=>as,SolanaJSONRPCError:()=>X,SolanaJSONRPCErrorCode:()=>os,StakeAuthorizationLayout:()=>tu,StakeInstruction:()=>$l,StakeProgram:()=>nu,Struct:()=>ho,SystemInstruction:()=>ms,SystemProgram:()=>gs,Transaction:()=>Y,TransactionExpiredBlockheightExceededError:()=>To,TransactionExpiredNonceInvalidError:()=>Do,TransactionExpiredTimeoutError:()=>Eo,TransactionInstruction:()=>J,TransactionMessage:()=>qo,TransactionStatus:()=>Go,VALIDATOR_INFO_KEY:()=>cu,VERSION_PREFIX_MASK:()=>127,VOTE_PROGRAM_ID:()=>du,ValidatorInfo:()=>uu,VersionedMessage:()=>Wo,VersionedTransaction:()=>Jo,VoteAccount:()=>pu,VoteAuthorizationLayout:()=>ou,VoteInit:()=>ru,VoteInstruction:()=>iu,VoteProgram:()=>su,clusterApiUrl:()=>vu,sendAndConfirmRawTransaction:()=>yu,sendAndConfirmTransaction:()=>ss}),co=Gn.utils.randomPrivateKey,lo=()=>{let e=Gn.utils.randomPrivateKey(),t=uo(e),n=new Uint8Array(64);return n.set(e),n.set(t,32),{publicKey:t,secretKey:n}},uo=Gn.getPublicKey;function fo(e){try{return Gn.ExtendedPoint.fromHex(e),!0}catch{return!1}}var po=(e,t)=>Gn.sign(e,t.slice(0,32)),mo=Gn.verify,W=e=>F.Buffer.isBuffer(e)?e:e instanceof Uint8Array?F.Buffer.from(e.buffer,e.byteOffset,e.byteLength):F.Buffer.from(e),ho=class{constructor(e){Object.assign(this,e)}encode(){return F.Buffer.from((0,Ar.serialize)(_o,this))}static decode(e){return(0,Ar.deserialize)(_o,this,e)}static decodeUnchecked(e){return(0,Ar.deserializeUnchecked)(_o,this,e)}},go=class extends ho{constructor(e){if(super(e),this.enum=``,Object.keys(e).length!==1)throw Error(`Enum can only take single value`);Object.keys(e).map(e=>{this.enum=e})}},_o=new Map,vo;function yo(e){return e._bn!==void 0}var bo=1,G=class e extends ho{constructor(e){if(super({}),this._bn=void 0,yo(e))this._bn=e._bn;else{if(typeof e==`string`){let t=kr.default.decode(e);if(t.length!=32)throw Error(`Invalid public key input`);this._bn=new Or.default(t)}else this._bn=new Or.default(e);if(this._bn.byteLength()>32)throw Error(`Invalid public key input`)}}static unique(){let t=new e(bo);return bo+=1,new e(t.toBuffer())}equals(e){return this._bn.eq(e._bn)}toBase58(){return kr.default.encode(this.toBytes())}toJSON(){return this.toBase58()}toBytes(){let e=this.toBuffer();return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}toBuffer(){let e=this._bn.toArrayLike(F.Buffer);if(e.length===32)return e;let t=F.Buffer.alloc(32);return e.copy(t,32-e.length),t}get[Symbol.toStringTag](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(t,n,r){return new e(tt(F.Buffer.concat([t.toBuffer(),F.Buffer.from(n),r.toBuffer()])))}static createProgramAddressSync(t,n){let r=F.Buffer.alloc(0);t.forEach(function(e){if(e.length>32)throw TypeError(`Max seed length exceeded`);r=F.Buffer.concat([r,W(e)])}),r=F.Buffer.concat([r,n.toBuffer(),F.Buffer.from(`ProgramDerivedAddress`)]);let i=tt(r);if(fo(i))throw Error(`Invalid seeds, address must fall off the curve`);return new e(i)}static async createProgramAddress(e,t){return this.createProgramAddressSync(e,t)}static findProgramAddressSync(e,t){let n=255,r;for(;n!=0;){try{let i=e.concat(F.Buffer.from([n]));r=this.createProgramAddressSync(i,t)}catch(e){if(e instanceof TypeError)throw e;n--;continue}return[r,n]}throw Error(`Unable to find a viable program address nonce`)}static async findProgramAddress(e,t){return this.findProgramAddressSync(e,t)}static isOnCurve(t){return fo(new e(t).toBytes())}};vo=G,G.default=new vo(`11111111111111111111111111111111`),_o.set(G,{kind:`struct`,fields:[[`_bn`,`u256`]]});var xo=class{constructor(e){if(this._publicKey=void 0,this._secretKey=void 0,e){let t=W(e);if(e.length!==64)throw Error(`bad secret key size`);this._publicKey=t.slice(32,64),this._secretKey=t.slice(0,32)}else this._secretKey=W(co()),this._publicKey=W(uo(this._secretKey))}get publicKey(){return new G(this._publicKey)}get secretKey(){return F.Buffer.concat([this._secretKey,this._publicKey],64)}},So=new G(`BPFLoader1111111111111111111111111111111111`),Co=1232,wo=64,To=class extends Error{constructor(e){super(`Signature ${e} has expired: block height exceeded.`),this.signature=void 0,this.signature=e}};Object.defineProperty(To.prototype,"name",{value:`TransactionExpiredBlockheightExceededError`});var Eo=class extends Error{constructor(e,t){super(`Transaction was not confirmed in ${t.toFixed(2)} seconds. It is unknown if it succeeded or failed. Check signature ${e} using the Solana Explorer or CLI tools.`),this.signature=void 0,this.signature=e}};Object.defineProperty(Eo.prototype,"name",{value:`TransactionExpiredTimeoutError`});var Do=class extends Error{constructor(e){super(`Signature ${e} has expired: the nonce is no longer valid.`),this.signature=void 0,this.signature=e}};Object.defineProperty(Do.prototype,"name",{value:`TransactionExpiredNonceInvalidError`});var Oo=class{constructor(e,t){this.staticAccountKeys=void 0,this.accountKeysFromLookups=void 0,this.staticAccountKeys=e,this.accountKeysFromLookups=t}keySegments(){let e=[this.staticAccountKeys];return this.accountKeysFromLookups&&(e.push(this.accountKeysFromLookups.writable),e.push(this.accountKeysFromLookups.readonly)),e}get(e){for(let t of this.keySegments())if(e<t.length)return t[e];else e-=t.length}get length(){return this.keySegments().flat().length}compileInstructions(e){if(this.length>256)throw Error(`Account index overflow encountered during compilation`);let t=new Map;this.keySegments().flat().forEach((e,n)=>{t.set(e.toBase58(),n)});let n=e=>{let n=t.get(e.toBase58());if(n===void 0)throw Error(`Encountered an unknown instruction account key during compilation`);return n};return e.map(e=>({programIdIndex:n(e.programId),accountKeyIndexes:e.keys.map(e=>n(e.pubkey)),data:e.data}))}},K=(e=`publicKey`)=>I.blob(32,e),ko=(e=`signature`)=>I.blob(64,e),Ao=(e=`string`)=>{let t=I.struct([I.u32(`length`),I.u32(`lengthPadding`),I.blob(I.offset(I.u32(),-8),`chars`)],e),n=t.decode.bind(t),r=t.encode.bind(t),i=t;return i.decode=(e,t)=>n(e,t).chars.toString(),i.encode=(e,t,n)=>r({chars:F.Buffer.from(e,`utf8`)},t,n),i.alloc=e=>I.u32().span+I.u32().span+F.Buffer.from(e,`utf8`).length,i},jo=(e=`authorized`)=>I.struct([K(`staker`),K(`withdrawer`)],e),Mo=(e=`lockup`)=>I.struct([I.ns64(`unixTimestamp`),I.ns64(`epoch`),K(`custodian`)],e),No=(e=`voteInit`)=>I.struct([K(`nodePubkey`),K(`authorizedVoter`),K(`authorizedWithdrawer`),I.u8(`commission`)],e),Po=(e=`voteAuthorizeWithSeedArgs`)=>I.struct([I.u32(`voteAuthorizationType`),K(`currentAuthorityDerivedKeyOwnerPubkey`),Ao(`currentAuthorityDerivedKeySeed`),K(`newAuthorized`)],e);function Fo(e,t){let n=e=>{if(e.span>=0)return e.span;if(typeof e.alloc==`function`)return e.alloc(t[e.property]);if(`count`in e&&`elementLayout`in e){let r=t[e.property];if(Array.isArray(r))return r.length*n(e.elementLayout)}else if(`fields`in e)return Fo({layout:e},t[e.property]);return 0},r=0;return e.layout.fields.forEach(e=>{r+=n(e)}),r}function Io(e){let t=0,n=0;for(;;){let r=e.shift();if(t|=(r&127)<<n*7,n+=1,!(r&128))break}return t}function Lo(e,t){let n=t;for(;;){let t=n&127;if(n>>=7,n==0){e.push(t);break}else t|=128,e.push(t)}}function q(e,t){if(!e)throw Error(t||`Assertion failed`)}var Ro=class e{constructor(e,t){this.payer=void 0,this.keyMetaMap=void 0,this.payer=e,this.keyMetaMap=t}static compile(t,n){let r=new Map,i=e=>{let t=e.toBase58(),n=r.get(t);return n===void 0&&(n={isSigner:!1,isWritable:!1,isInvoked:!1},r.set(t,n)),n},a=i(n);a.isSigner=!0,a.isWritable=!0;for(let e of t){i(e.programId).isInvoked=!0;for(let t of e.keys){let e=i(t.pubkey);e.isSigner||=t.isSigner,e.isWritable||=t.isWritable}}return new e(n,r)}getMessageComponents(){let e=[...this.keyMetaMap.entries()];q(e.length<=256,`Max static account keys length exceeded`);let t=e.filter(([,e])=>e.isSigner&&e.isWritable),n=e.filter(([,e])=>e.isSigner&&!e.isWritable),r=e.filter(([,e])=>!e.isSigner&&e.isWritable),i=e.filter(([,e])=>!e.isSigner&&!e.isWritable),a={numRequiredSignatures:t.length+n.length,numReadonlySignedAccounts:n.length,numReadonlyUnsignedAccounts:i.length};{q(t.length>0,`Expected at least one writable signer key`);let[e]=t[0];q(e===this.payer.toBase58(),`Expected first writable signer key to be the fee payer`)}return[a,[...t.map(([e])=>new G(e)),...n.map(([e])=>new G(e)),...r.map(([e])=>new G(e)),...i.map(([e])=>new G(e))]]}extractTableLookup(e){let[t,n]=this.drainKeysFoundInLookupTable(e.state.addresses,e=>!e.isSigner&&!e.isInvoked&&e.isWritable),[r,i]=this.drainKeysFoundInLookupTable(e.state.addresses,e=>!e.isSigner&&!e.isInvoked&&!e.isWritable);if(!(t.length===0&&r.length===0))return[{accountKey:e.key,writableIndexes:t,readonlyIndexes:r},{writable:n,readonly:i}]}drainKeysFoundInLookupTable(e,t){let n=[],r=[];for(let[i,a]of this.keyMetaMap.entries())if(t(a)){let t=new G(i),a=e.findIndex(e=>e.equals(t));a>=0&&(q(a<256,`Max lookup table index exceeded`),n.push(a),r.push(t),this.keyMetaMap.delete(i))}return[n,r]}},zo=`Reached end of buffer unexpectedly`;function Bo(e){if(e.length===0)throw Error(zo);return e.shift()}function Vo(e,...t){let[n]=t;if(t.length===2?n+(t[1]??0)>e.length:n>=e.length)throw Error(zo);return e.splice(...t)}var Ho=class e{constructor(e){this.header=void 0,this.accountKeys=void 0,this.recentBlockhash=void 0,this.instructions=void 0,this.indexToProgramIds=new Map,this.header=e.header,this.accountKeys=e.accountKeys.map(e=>new G(e)),this.recentBlockhash=e.recentBlockhash,this.instructions=e.instructions,this.instructions.forEach(e=>this.indexToProgramIds.set(e.programIdIndex,this.accountKeys[e.programIdIndex]))}get version(){return`legacy`}get staticAccountKeys(){return this.accountKeys}get compiledInstructions(){return this.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:kr.default.decode(e.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new Oo(this.staticAccountKeys)}static compile(t){let[n,r]=Ro.compile(t.instructions,t.payerKey).getMessageComponents(),i=new Oo(r).compileInstructions(t.instructions).map(e=>({programIdIndex:e.programIdIndex,accounts:e.accountKeyIndexes,data:kr.default.encode(e.data)}));return new e({header:n,accountKeys:r,recentBlockhash:t.recentBlockhash,instructions:i})}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){let t=this.header.numRequiredSignatures;return e>=this.header.numRequiredSignatures?e-t<this.accountKeys.length-t-this.header.numReadonlyUnsignedAccounts:e<t-this.header.numReadonlySignedAccounts}isProgramId(e){return this.indexToProgramIds.has(e)}programIds(){return[...this.indexToProgramIds.values()]}nonProgramIds(){return this.accountKeys.filter((e,t)=>!this.isProgramId(t))}serialize(){let e=this.accountKeys.length,t=[];Lo(t,e);let n=this.instructions.map(e=>{let{accounts:t,programIdIndex:n}=e,r=Array.from(kr.default.decode(e.data)),i=[];Lo(i,t.length);let a=[];return Lo(a,r.length),{programIdIndex:n,keyIndicesCount:F.Buffer.from(i),keyIndices:t,dataLength:F.Buffer.from(a),data:r}}),r=[];Lo(r,n.length);let i=F.Buffer.alloc(Co);F.Buffer.from(r).copy(i);let a=r.length;n.forEach(e=>{let t=I.struct([I.u8(`programIdIndex`),I.blob(e.keyIndicesCount.length,`keyIndicesCount`),I.seq(I.u8(`keyIndex`),e.keyIndices.length,`keyIndices`),I.blob(e.dataLength.length,`dataLength`),I.seq(I.u8(`userdatum`),e.data.length,`data`)]).encode(e,i,a);a+=t}),i=i.slice(0,a);let o=I.struct([I.blob(1,`numRequiredSignatures`),I.blob(1,`numReadonlySignedAccounts`),I.blob(1,`numReadonlyUnsignedAccounts`),I.blob(t.length,`keyCount`),I.seq(K(`key`),e,`keys`),K(`recentBlockhash`)]),s={numRequiredSignatures:F.Buffer.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:F.Buffer.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:F.Buffer.from([this.header.numReadonlyUnsignedAccounts]),keyCount:F.Buffer.from(t),keys:this.accountKeys.map(e=>W(e.toBytes())),recentBlockhash:kr.default.decode(this.recentBlockhash)},c=F.Buffer.alloc(2048),l=o.encode(s,c);return i.copy(c,l),c.slice(0,l+i.length)}static from(t){let n=[...t],r=Bo(n);if(r!==(r&127))throw Error(`Versioned messages must be deserialized with VersionedMessage.deserialize()`);let i=Bo(n),a=Bo(n),o=Io(n),s=[];for(let e=0;e<o;e++){let e=Vo(n,0,32);s.push(new G(F.Buffer.from(e)))}let c=Vo(n,0,32),l=Io(n),u=[];for(let e=0;e<l;e++){let e=Bo(n),t=Vo(n,0,Io(n)),r=Vo(n,0,Io(n)),i=kr.default.encode(F.Buffer.from(r));u.push({programIdIndex:e,accounts:t,data:i})}return new e({header:{numRequiredSignatures:r,numReadonlySignedAccounts:i,numReadonlyUnsignedAccounts:a},recentBlockhash:kr.default.encode(F.Buffer.from(c)),accountKeys:s,instructions:u})}},Uo=class e{constructor(e){this.header=void 0,this.staticAccountKeys=void 0,this.recentBlockhash=void 0,this.compiledInstructions=void 0,this.addressTableLookups=void 0,this.header=e.header,this.staticAccountKeys=e.staticAccountKeys,this.recentBlockhash=e.recentBlockhash,this.compiledInstructions=e.compiledInstructions,this.addressTableLookups=e.addressTableLookups}get version(){return 0}get numAccountKeysFromLookups(){let e=0;for(let t of this.addressTableLookups)e+=t.readonlyIndexes.length+t.writableIndexes.length;return e}getAccountKeys(e){let t;if(e&&`accountKeysFromLookups`in e&&e.accountKeysFromLookups){if(this.numAccountKeysFromLookups!=e.accountKeysFromLookups.writable.length+e.accountKeysFromLookups.readonly.length)throw Error(`Failed to get account keys because of a mismatch in the number of account keys from lookups`);t=e.accountKeysFromLookups}else if(e&&`addressLookupTableAccounts`in e&&e.addressLookupTableAccounts)t=this.resolveAddressTableLookups(e.addressLookupTableAccounts);else if(this.addressTableLookups.length>0)throw Error(`Failed to get account keys because address table lookups were not resolved`);return new Oo(this.staticAccountKeys,t)}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){let t=this.header.numRequiredSignatures,n=this.staticAccountKeys.length;return e>=n?e-n<this.addressTableLookups.reduce((e,t)=>e+t.writableIndexes.length,0):e>=this.header.numRequiredSignatures?e-t<n-t-this.header.numReadonlyUnsignedAccounts:e<t-this.header.numReadonlySignedAccounts}resolveAddressTableLookups(e){let t={writable:[],readonly:[]};for(let n of this.addressTableLookups){let r=e.find(e=>e.key.equals(n.accountKey));if(!r)throw Error(`Failed to find address lookup table account for table key ${n.accountKey.toBase58()}`);for(let e of n.writableIndexes)if(e<r.state.addresses.length)t.writable.push(r.state.addresses[e]);else throw Error(`Failed to find address for index ${e} in address lookup table ${n.accountKey.toBase58()}`);for(let e of n.readonlyIndexes)if(e<r.state.addresses.length)t.readonly.push(r.state.addresses[e]);else throw Error(`Failed to find address for index ${e} in address lookup table ${n.accountKey.toBase58()}`)}return t}static compile(t){let n=Ro.compile(t.instructions,t.payerKey),r=[],i={writable:[],readonly:[]},a=t.addressLookupTableAccounts||[];for(let e of a){let t=n.extractTableLookup(e);if(t!==void 0){let[e,{writable:n,readonly:a}]=t;r.push(e),i.writable.push(...n),i.readonly.push(...a)}}let[o,s]=n.getMessageComponents(),c=new Oo(s,i).compileInstructions(t.instructions);return new e({header:o,staticAccountKeys:s,recentBlockhash:t.recentBlockhash,compiledInstructions:c,addressTableLookups:r})}serialize(){let e=[];Lo(e,this.staticAccountKeys.length);let t=this.serializeInstructions(),n=[];Lo(n,this.compiledInstructions.length);let r=this.serializeAddressTableLookups(),i=[];Lo(i,this.addressTableLookups.length);let a=I.struct([I.u8(`prefix`),I.struct([I.u8(`numRequiredSignatures`),I.u8(`numReadonlySignedAccounts`),I.u8(`numReadonlyUnsignedAccounts`)],`header`),I.blob(e.length,`staticAccountKeysLength`),I.seq(K(),this.staticAccountKeys.length,`staticAccountKeys`),K(`recentBlockhash`),I.blob(n.length,`instructionsLength`),I.blob(t.length,`serializedInstructions`),I.blob(i.length,`addressTableLookupsLength`),I.blob(r.length,`serializedAddressTableLookups`)]),o=new Uint8Array(Co),s=a.encode({prefix:128,header:this.header,staticAccountKeysLength:new Uint8Array(e),staticAccountKeys:this.staticAccountKeys.map(e=>e.toBytes()),recentBlockhash:kr.default.decode(this.recentBlockhash),instructionsLength:new Uint8Array(n),serializedInstructions:t,addressTableLookupsLength:new Uint8Array(i),serializedAddressTableLookups:r},o);return o.slice(0,s)}serializeInstructions(){let e=0,t=new Uint8Array(Co);for(let n of this.compiledInstructions){let r=[];Lo(r,n.accountKeyIndexes.length);let i=[];Lo(i,n.data.length);let a=I.struct([I.u8(`programIdIndex`),I.blob(r.length,`encodedAccountKeyIndexesLength`),I.seq(I.u8(),n.accountKeyIndexes.length,`accountKeyIndexes`),I.blob(i.length,`encodedDataLength`),I.blob(n.data.length,`data`)]);e+=a.encode({programIdIndex:n.programIdIndex,encodedAccountKeyIndexesLength:new Uint8Array(r),accountKeyIndexes:n.accountKeyIndexes,encodedDataLength:new Uint8Array(i),data:n.data},t,e)}return t.slice(0,e)}serializeAddressTableLookups(){let e=0,t=new Uint8Array(Co);for(let n of this.addressTableLookups){let r=[];Lo(r,n.writableIndexes.length);let i=[];Lo(i,n.readonlyIndexes.length);let a=I.struct([K(`accountKey`),I.blob(r.length,`encodedWritableIndexesLength`),I.seq(I.u8(),n.writableIndexes.length,`writableIndexes`),I.blob(i.length,`encodedReadonlyIndexesLength`),I.seq(I.u8(),n.readonlyIndexes.length,`readonlyIndexes`)]);e+=a.encode({accountKey:n.accountKey.toBytes(),encodedWritableIndexesLength:new Uint8Array(r),writableIndexes:n.writableIndexes,encodedReadonlyIndexesLength:new Uint8Array(i),readonlyIndexes:n.readonlyIndexes},t,e)}return t.slice(0,e)}static deserialize(t){let n=[...t],r=Bo(n),i=r&127;q(r!==i,`Expected versioned message but received legacy message`);let a=i;q(a===0,`Expected versioned message with version 0 but found version ${a}`);let o={numRequiredSignatures:Bo(n),numReadonlySignedAccounts:Bo(n),numReadonlyUnsignedAccounts:Bo(n)},s=[],c=Io(n);for(let e=0;e<c;e++)s.push(new G(Vo(n,0,32)));let l=kr.default.encode(Vo(n,0,32)),u=Io(n),d=[];for(let e=0;e<u;e++){let e=Bo(n),t=Vo(n,0,Io(n)),r=Io(n),i=new Uint8Array(Vo(n,0,r));d.push({programIdIndex:e,accountKeyIndexes:t,data:i})}let f=Io(n),p=[];for(let e=0;e<f;e++){let e=new G(Vo(n,0,32)),t=Vo(n,0,Io(n)),r=Vo(n,0,Io(n));p.push({accountKey:e,writableIndexes:t,readonlyIndexes:r})}return new e({header:o,staticAccountKeys:s,recentBlockhash:l,compiledInstructions:d,addressTableLookups:p})}},Wo={deserializeMessageVersion(e){let t=e[0],n=t&127;return n===t?`legacy`:n},deserialize:e=>{let t=Wo.deserializeMessageVersion(e);if(t===`legacy`)return Ho.from(e);if(t===0)return Uo.deserialize(e);throw Error(`Transaction message version ${t} deserialization is not supported`)}},Go=function(e){return e[e.BLOCKHEIGHT_EXCEEDED=0]=`BLOCKHEIGHT_EXCEEDED`,e[e.PROCESSED=1]=`PROCESSED`,e[e.TIMED_OUT=2]=`TIMED_OUT`,e[e.NONCE_INVALID=3]=`NONCE_INVALID`,e}({}),Ko=F.Buffer.alloc(64).fill(0),J=class{constructor(e){this.keys=void 0,this.programId=void 0,this.data=F.Buffer.alloc(0),this.programId=e.programId,this.keys=e.keys,e.data&&(this.data=e.data)}toJSON(){return{keys:this.keys.map(({pubkey:e,isSigner:t,isWritable:n})=>({pubkey:e.toJSON(),isSigner:t,isWritable:n})),programId:this.programId.toJSON(),data:[...this.data]}}},Y=class e{get signature(){return this.signatures.length>0?this.signatures[0].signature:null}constructor(e){if(this.signatures=[],this.feePayer=void 0,this.instructions=[],this.recentBlockhash=void 0,this.lastValidBlockHeight=void 0,this.nonceInfo=void 0,this.minNonceContextSlot=void 0,this._message=void 0,this._json=void 0,e)if(e.feePayer&&(this.feePayer=e.feePayer),e.signatures&&(this.signatures=e.signatures),Object.prototype.hasOwnProperty.call(e,`nonceInfo`)){let{minContextSlot:t,nonceInfo:n}=e;this.minNonceContextSlot=t,this.nonceInfo=n}else if(Object.prototype.hasOwnProperty.call(e,`lastValidBlockHeight`)){let{blockhash:t,lastValidBlockHeight:n}=e;this.recentBlockhash=t,this.lastValidBlockHeight=n}else{let{recentBlockhash:t,nonceInfo:n}=e;n&&(this.nonceInfo=n),this.recentBlockhash=t}}toJSON(){return{recentBlockhash:this.recentBlockhash||null,feePayer:this.feePayer?this.feePayer.toJSON():null,nonceInfo:this.nonceInfo?{nonce:this.nonceInfo.nonce,nonceInstruction:this.nonceInfo.nonceInstruction.toJSON()}:null,instructions:this.instructions.map(e=>e.toJSON()),signers:this.signatures.map(({publicKey:e})=>e.toJSON())}}add(...e){if(e.length===0)throw Error(`No instructions`);return e.forEach(e=>{`instructions`in e?this.instructions=this.instructions.concat(e.instructions):`data`in e&&`programId`in e&&`keys`in e?this.instructions.push(e):this.instructions.push(new J(e))}),this}compileMessage(){if(this._message&&JSON.stringify(this.toJSON())===JSON.stringify(this._json))return this._message;let e,t;if(this.nonceInfo?(e=this.nonceInfo.nonce,t=this.instructions[0]==this.nonceInfo.nonceInstruction?this.instructions:[this.nonceInfo.nonceInstruction,...this.instructions]):(e=this.recentBlockhash,t=this.instructions),!e)throw Error(`Transaction recentBlockhash required`);t.length<1&&console.warn(`No instructions provided`);let n;if(this.feePayer)n=this.feePayer;else if(this.signatures.length>0&&this.signatures[0].publicKey)n=this.signatures[0].publicKey;else throw Error(`Transaction fee payer required`);for(let e=0;e<t.length;e++)if(t[e].programId===void 0)throw Error(`Transaction instruction index ${e} has undefined program id`);let r=[],i=[];t.forEach(e=>{e.keys.forEach(e=>{i.push({...e})});let t=e.programId.toString();r.includes(t)||r.push(t)}),r.forEach(e=>{i.push({pubkey:new G(e),isSigner:!1,isWritable:!1})});let a=[];i.forEach(e=>{let t=e.pubkey.toString(),n=a.findIndex(e=>e.pubkey.toString()===t);n>-1?(a[n].isWritable=a[n].isWritable||e.isWritable,a[n].isSigner=a[n].isSigner||e.isSigner):a.push(e)}),a.sort(function(e,t){return e.isSigner===t.isSigner?e.isWritable===t.isWritable?e.pubkey.toBase58().localeCompare(t.pubkey.toBase58(),`en`,{localeMatcher:`best fit`,usage:`sort`,sensitivity:`variant`,ignorePunctuation:!1,numeric:!1,caseFirst:`lower`}):e.isWritable?-1:1:e.isSigner?-1:1});let o=a.findIndex(e=>e.pubkey.equals(n));if(o>-1){let[e]=a.splice(o,1);e.isSigner=!0,e.isWritable=!0,a.unshift(e)}else a.unshift({pubkey:n,isSigner:!0,isWritable:!0});for(let e of this.signatures){let t=a.findIndex(t=>t.pubkey.equals(e.publicKey));if(t>-1)a[t].isSigner||(a[t].isSigner=!0,console.warn(`Transaction references a signature that is unnecessary, only the fee payer and instruction signer accounts should sign a transaction. This behavior is deprecated and will throw an error in the next major version release.`));else throw Error(`unknown signer: ${e.publicKey.toString()}`)}let s=0,c=0,l=0,u=[],d=[];a.forEach(({pubkey:e,isSigner:t,isWritable:n})=>{t?(u.push(e.toString()),s+=1,n||(c+=1)):(d.push(e.toString()),n||(l+=1))});let f=u.concat(d),p=t.map(e=>{let{data:t,programId:n}=e;return{programIdIndex:f.indexOf(n.toString()),accounts:e.keys.map(e=>f.indexOf(e.pubkey.toString())),data:kr.default.encode(t)}});return p.forEach(e=>{q(e.programIdIndex>=0),e.accounts.forEach(e=>q(e>=0))}),new Ho({header:{numRequiredSignatures:s,numReadonlySignedAccounts:c,numReadonlyUnsignedAccounts:l},accountKeys:f,recentBlockhash:e,instructions:p})}_compile(){let e=this.compileMessage(),t=e.accountKeys.slice(0,e.header.numRequiredSignatures);return this.signatures.length===t.length&&this.signatures.every((e,n)=>t[n].equals(e.publicKey))||(this.signatures=t.map(e=>({signature:null,publicKey:e}))),e}serializeMessage(){return this._compile().serialize()}async getEstimatedFee(e){return(await e.getFeeForMessage(this.compileMessage())).value}setSigners(...e){if(e.length===0)throw Error(`No signers`);let t=new Set;this.signatures=e.filter(e=>{let n=e.toString();return t.has(n)?!1:(t.add(n),!0)}).map(e=>({signature:null,publicKey:e}))}sign(...e){if(e.length===0)throw Error(`No signers`);let t=new Set,n=[];for(let r of e){let e=r.publicKey.toString();t.has(e)||(t.add(e),n.push(r))}this.signatures=n.map(e=>({signature:null,publicKey:e.publicKey}));let r=this._compile();this._partialSign(r,...n)}partialSign(...e){if(e.length===0)throw Error(`No signers`);let t=new Set,n=[];for(let r of e){let e=r.publicKey.toString();t.has(e)||(t.add(e),n.push(r))}let r=this._compile();this._partialSign(r,...n)}_partialSign(e,...t){let n=e.serialize();t.forEach(e=>{let t=po(n,e.secretKey);this._addSignature(e.publicKey,W(t))})}addSignature(e,t){this._compile(),this._addSignature(e,t)}_addSignature(e,t){q(t.length===64);let n=this.signatures.findIndex(t=>e.equals(t.publicKey));if(n<0)throw Error(`unknown signer: ${e.toString()}`);this.signatures[n].signature=F.Buffer.from(t)}verifySignatures(e=!0){return!this._getMessageSignednessErrors(this.serializeMessage(),e)}_getMessageSignednessErrors(e,t){let n={};for(let{signature:r,publicKey:i}of this.signatures)r===null?t&&(n.missing||=[]).push(i):mo(r,e,i.toBytes())||(n.invalid||=[]).push(i);return n.invalid||n.missing?n:void 0}serialize(e){let{requireAllSignatures:t,verifySignatures:n}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},e),r=this.serializeMessage();if(n){let e=this._getMessageSignednessErrors(r,t);if(e){let t=`Signature verification failed.`;throw e.invalid&&(t+=`\nInvalid signature for public key${e.invalid.length===1?``:`(s)`} [\`${e.invalid.map(e=>e.toBase58()).join("`, `")}\`].`),e.missing&&(t+=`\nMissing signature for public key${e.missing.length===1?``:`(s)`} [\`${e.missing.map(e=>e.toBase58()).join("`, `")}\`].`),Error(t)}}return this._serialize(r)}_serialize(e){let{signatures:t}=this,n=[];Lo(n,t.length);let r=n.length+t.length*64+e.length,i=F.Buffer.alloc(r);return q(t.length<256),F.Buffer.from(n).copy(i,0),t.forEach(({signature:e},t)=>{e!==null&&(q(e.length===64,`signature has invalid length`),F.Buffer.from(e).copy(i,n.length+t*64))}),e.copy(i,n.length+t.length*64),q(i.length<=Co,`Transaction too large: ${i.length} > ${Co}`),i}get keys(){return q(this.instructions.length===1),this.instructions[0].keys.map(e=>e.pubkey)}get programId(){return q(this.instructions.length===1),this.instructions[0].programId}get data(){return q(this.instructions.length===1),this.instructions[0].data}static from(t){let n=[...t],r=Io(n),i=[];for(let e=0;e<r;e++){let e=Vo(n,0,64);i.push(kr.default.encode(F.Buffer.from(e)))}return e.populate(Ho.from(n),i)}static populate(t,n=[]){let r=new e;return r.recentBlockhash=t.recentBlockhash,t.header.numRequiredSignatures>0&&(r.feePayer=t.accountKeys[0]),n.forEach((e,n)=>{let i={signature:e==kr.default.encode(Ko)?null:kr.default.decode(e),publicKey:t.accountKeys[n]};r.signatures.push(i)}),t.instructions.forEach(e=>{let n=e.accounts.map(e=>{let n=t.accountKeys[e];return{pubkey:n,isSigner:r.signatures.some(e=>e.publicKey.toString()===n.toString())||t.isAccountSigner(e),isWritable:t.isAccountWritable(e)}});r.instructions.push(new J({keys:n,programId:t.accountKeys[e.programIdIndex],data:kr.default.decode(e.data)}))}),r._message=t,r._json=r.toJSON(),r}},qo=class e{constructor(e){this.payerKey=void 0,this.instructions=void 0,this.recentBlockhash=void 0,this.payerKey=e.payerKey,this.instructions=e.instructions,this.recentBlockhash=e.recentBlockhash}static decompile(t,n){let{header:r,compiledInstructions:i,recentBlockhash:a}=t,{numRequiredSignatures:o,numReadonlySignedAccounts:s,numReadonlyUnsignedAccounts:c}=r,l=o-s;q(l>0,`Message header is invalid`);let u=t.staticAccountKeys.length-o-c;q(u>=0,`Message header is invalid`);let d=t.getAccountKeys(n),f=d.get(0);if(f===void 0)throw Error(`Failed to decompile message because no account keys were found`);let p=[];for(let e of i){let t=[];for(let n of e.accountKeyIndexes){let e=d.get(n);if(e===void 0)throw Error(`Failed to find key for account key index ${n}`);let i=n<o,a;a=i?n<l:n<d.staticAccountKeys.length?n-o<u:n-d.staticAccountKeys.length<d.accountKeysFromLookups.writable.length,t.push({pubkey:e,isSigner:n<r.numRequiredSignatures,isWritable:a})}let n=d.get(e.programIdIndex);if(n===void 0)throw Error(`Failed to find program id for program id index ${e.programIdIndex}`);p.push(new J({programId:n,data:W(e.data),keys:t}))}return new e({payerKey:f,instructions:p,recentBlockhash:a})}compileToLegacyMessage(){return Ho.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions})}compileToV0Message(e){return Uo.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions,addressLookupTableAccounts:e})}},Jo=class e{get version(){return this.message.version}constructor(e,t){if(this.signatures=void 0,this.message=void 0,t!==void 0)q(t.length===e.header.numRequiredSignatures,`Expected signatures length to be equal to the number of required signatures`),this.signatures=t;else{let t=[];for(let n=0;n<e.header.numRequiredSignatures;n++)t.push(new Uint8Array(64));this.signatures=t}this.message=e}serialize(){let e=this.message.serialize(),t=[];Lo(t,this.signatures.length);let n=I.struct([I.blob(t.length,`encodedSignaturesLength`),I.seq(ko(),this.signatures.length,`signatures`),I.blob(e.length,`serializedMessage`)]),r=new Uint8Array(2048),i=n.encode({encodedSignaturesLength:new Uint8Array(t),signatures:this.signatures,serializedMessage:e},r);return r.slice(0,i)}static deserialize(t){let n=[...t],r=[],i=Io(n);for(let e=0;e<i;e++)r.push(new Uint8Array(Vo(n,0,64)));return new e(Wo.deserialize(new Uint8Array(n)),r)}sign(e){let t=this.message.serialize(),n=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures);for(let r of e){let e=n.findIndex(e=>e.equals(r.publicKey));q(e>=0,`Cannot sign with non signer key ${r.publicKey.toBase58()}`),this.signatures[e]=po(t,r.secretKey)}}addSignature(e,t){q(t.byteLength===64,`Signature must be 64 bytes long`);let n=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures).findIndex(t=>t.equals(e));q(n>=0,`Can not add signature; \`${e.toBase58()}\` is not required to sign this transaction`),this.signatures[n]=t}},Yo=1e3/(160/64),Xo=new G(`SysvarC1ock11111111111111111111111111111111`),Zo=new G(`SysvarEpochSchedu1e111111111111111111111111`),Qo=new G(`Sysvar1nstructions1111111111111111111111111`),$o=new G(`SysvarRecentB1ockHashes11111111111111111111`),es=new G(`SysvarRent111111111111111111111111111111111`),ts=new G(`SysvarRewards111111111111111111111111111111`),ns=new G(`SysvarS1otHashes111111111111111111111111111`),rs=new G(`SysvarS1otHistory11111111111111111111111111`),is=new G(`SysvarStakeHistory1111111111111111111111111`),as=class extends Error{constructor({action:e,signature:t,transactionMessage:n,logs:r}){let i=r?`Logs: \n${JSON.stringify(r.slice(-10),null,2)}. `:``,a="\nCatch the `SendTransactionError` and call `getLogs()` on it for full details.",o;switch(e){case`send`:o=`Transaction ${t} resulted in an error. \n${n}. `+i+a;break;case`simulate`:o=`Simulation failed. \nMessage: ${n}. \n`+i+a;break;default:o=`Unknown action '${(e=>e)(e)}'`}super(o),this.signature=void 0,this.transactionMessage=void 0,this.transactionLogs=void 0,this.signature=t,this.transactionMessage=n,this.transactionLogs=r||void 0}get transactionError(){return{message:this.transactionMessage,logs:Array.isArray(this.transactionLogs)?this.transactionLogs:void 0}}get logs(){let e=this.transactionLogs;if(!(typeof e==`object`&&e&&`then`in e))return e}async getLogs(e){return Array.isArray(this.transactionLogs)||(this.transactionLogs=new Promise((t,n)=>{e.getTransaction(this.signature).then(e=>{if(e&&e.meta&&e.meta.logMessages){let n=e.meta.logMessages;this.transactionLogs=n,t(n)}else n(Error(`Log messages not found`))}).catch(n)})),await this.transactionLogs}},os={JSON_RPC_SERVER_ERROR_BLOCK_CLEANED_UP:-32001,JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE:-32002,JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE:-32003,JSON_RPC_SERVER_ERROR_BLOCK_NOT_AVAILABLE:-32004,JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY:-32005,JSON_RPC_SERVER_ERROR_TRANSACTION_PRECOMPILE_VERIFICATION_FAILURE:-32006,JSON_RPC_SERVER_ERROR_SLOT_SKIPPED:-32007,JSON_RPC_SERVER_ERROR_NO_SNAPSHOT:-32008,JSON_RPC_SERVER_ERROR_LONG_TERM_STORAGE_SLOT_SKIPPED:-32009,JSON_RPC_SERVER_ERROR_KEY_EXCLUDED_FROM_SECONDARY_INDEX:-32010,JSON_RPC_SERVER_ERROR_TRANSACTION_HISTORY_NOT_AVAILABLE:-32011,JSON_RPC_SCAN_ERROR:-32012,JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_LEN_MISMATCH:-32013,JSON_RPC_SERVER_ERROR_BLOCK_STATUS_NOT_AVAILABLE_YET:-32014,JSON_RPC_SERVER_ERROR_UNSUPPORTED_TRANSACTION_VERSION:-32015,JSON_RPC_SERVER_ERROR_MIN_CONTEXT_SLOT_NOT_REACHED:-32016},X=class extends Error{constructor({code:e,message:t,data:n},r){super(r==null?t:`${r}: ${t}`),this.code=void 0,this.data=void 0,this.code=e,this.data=n,this.name=`SolanaJSONRPCError`}};async function ss(e,t,n,r){let i=r&&{skipPreflight:r.skipPreflight,preflightCommitment:r.preflightCommitment||r.commitment,maxRetries:r.maxRetries,minContextSlot:r.minContextSlot},a=await e.sendTransaction(t,n,i),o;if(t.recentBlockhash!=null&&t.lastValidBlockHeight!=null)o=(await e.confirmTransaction({abortSignal:r?.abortSignal,signature:a,blockhash:t.recentBlockhash,lastValidBlockHeight:t.lastValidBlockHeight},r&&r.commitment)).value;else if(t.minNonceContextSlot!=null&&t.nonceInfo!=null){let{nonceInstruction:n}=t.nonceInfo,i=n.keys[0].pubkey;o=(await e.confirmTransaction({abortSignal:r?.abortSignal,minContextSlot:t.minNonceContextSlot,nonceAccountPubkey:i,nonceValue:t.nonceInfo.nonce,signature:a},r&&r.commitment)).value}else r?.abortSignal!=null&&console.warn("sendAndConfirmTransaction(): A transaction with a deprecated confirmation strategy was supplied along with an `abortSignal`. Only transactions having `lastValidBlockHeight` or a combination of `nonceInfo` and `minNonceContextSlot` are abortable."),o=(await e.confirmTransaction(a,r&&r.commitment)).value;if(o.err)throw a==null?Error(`Transaction ${a} failed (${JSON.stringify(o)})`):new as({action:`send`,signature:a,transactionMessage:`Status: (${JSON.stringify(o)})`});return a}function cs(e){return new Promise(t=>setTimeout(t,e))}function Z(e,t){let n=e.layout.span>=0?e.layout.span:Fo(e,t),r=F.Buffer.alloc(n),i=Object.assign({instruction:e.index},t);return e.layout.encode(i,r),r}function Q(e,t){let n;try{n=e.layout.decode(t)}catch(e){throw Error(`invalid instruction; `+e)}if(n.instruction!==e.index)throw Error(`invalid instruction; instruction index mismatch ${n.instruction} != ${e.index}`);return n}var ls=I.nu64(`lamportsPerSignature`),us=I.struct([I.u32(`version`),I.u32(`state`),K(`authorizedPubkey`),K(`nonce`),I.struct([ls],`feeCalculator`)]),ds=us.span,fs=class e{constructor(e){this.authorizedPubkey=void 0,this.nonce=void 0,this.feeCalculator=void 0,this.authorizedPubkey=e.authorizedPubkey,this.nonce=e.nonce,this.feeCalculator=e.feeCalculator}static fromAccountData(t){let n=us.decode(W(t),0);return new e({authorizedPubkey:new G(n.authorizedPubkey),nonce:new G(n.nonce).toString(),feeCalculator:n.feeCalculator})}};function ps(e){let t=(0,I.blob)(8,e),n=t.decode.bind(t),r=t.encode.bind(t),i=t,a=ni();return i.decode=(e,t)=>{let r=n(e,t);return a.decode(r)},i.encode=(e,t,n)=>r(a.encode(e),t,n),i}var ms=class{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);let t=I.u32(`instruction`).decode(e.data),n;for(let[e,r]of Object.entries(hs))if(r.index==t){n=e;break}if(!n)throw Error(`Instruction type incorrect; not a SystemInstruction`);return n}static decodeCreateAccount(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);let{lamports:t,space:n,programId:r}=Q(hs.Create,e.data);return{fromPubkey:e.keys[0].pubkey,newAccountPubkey:e.keys[1].pubkey,lamports:t,space:n,programId:new G(r)}}static decodeTransfer(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);let{lamports:t}=Q(hs.Transfer,e.data);return{fromPubkey:e.keys[0].pubkey,toPubkey:e.keys[1].pubkey,lamports:t}}static decodeTransferWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);let{lamports:t,seed:n,programId:r}=Q(hs.TransferWithSeed,e.data);return{fromPubkey:e.keys[0].pubkey,basePubkey:e.keys[1].pubkey,toPubkey:e.keys[2].pubkey,lamports:t,seed:n,programId:new G(r)}}static decodeAllocate(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);let{space:t}=Q(hs.Allocate,e.data);return{accountPubkey:e.keys[0].pubkey,space:t}}static decodeAllocateWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);let{base:t,seed:n,space:r,programId:i}=Q(hs.AllocateWithSeed,e.data);return{accountPubkey:e.keys[0].pubkey,basePubkey:new G(t),seed:n,space:r,programId:new G(i)}}static decodeAssign(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);let{programId:t}=Q(hs.Assign,e.data);return{accountPubkey:e.keys[0].pubkey,programId:new G(t)}}static decodeAssignWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);let{base:t,seed:n,programId:r}=Q(hs.AssignWithSeed,e.data);return{accountPubkey:e.keys[0].pubkey,basePubkey:new G(t),seed:n,programId:new G(r)}}static decodeCreateWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);let{base:t,seed:n,lamports:r,space:i,programId:a}=Q(hs.CreateWithSeed,e.data);return{fromPubkey:e.keys[0].pubkey,newAccountPubkey:e.keys[1].pubkey,basePubkey:new G(t),seed:n,lamports:r,space:i,programId:new G(a)}}static decodeNonceInitialize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);let{authorized:t}=Q(hs.InitializeNonceAccount,e.data);return{noncePubkey:e.keys[0].pubkey,authorizedPubkey:new G(t)}}static decodeNonceAdvance(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3),Q(hs.AdvanceNonceAccount,e.data),{noncePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey}}static decodeNonceWithdraw(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,5);let{lamports:t}=Q(hs.WithdrawNonceAccount,e.data);return{noncePubkey:e.keys[0].pubkey,toPubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[4].pubkey,lamports:t}}static decodeNonceAuthorize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);let{authorized:t}=Q(hs.AuthorizeNonceAccount,e.data);return{noncePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[1].pubkey,newAuthorizedPubkey:new G(t)}}static checkProgramId(e){if(!e.equals(gs.programId))throw Error(`invalid instruction; programId is not SystemProgram`)}static checkKeyLength(e,t){if(e.length<t)throw Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}},hs=Object.freeze({Create:{index:0,layout:I.struct([I.u32(`instruction`),I.ns64(`lamports`),I.ns64(`space`),K(`programId`)])},Assign:{index:1,layout:I.struct([I.u32(`instruction`),K(`programId`)])},Transfer:{index:2,layout:I.struct([I.u32(`instruction`),ps(`lamports`)])},CreateWithSeed:{index:3,layout:I.struct([I.u32(`instruction`),K(`base`),Ao(`seed`),I.ns64(`lamports`),I.ns64(`space`),K(`programId`)])},AdvanceNonceAccount:{index:4,layout:I.struct([I.u32(`instruction`)])},WithdrawNonceAccount:{index:5,layout:I.struct([I.u32(`instruction`),I.ns64(`lamports`)])},InitializeNonceAccount:{index:6,layout:I.struct([I.u32(`instruction`),K(`authorized`)])},AuthorizeNonceAccount:{index:7,layout:I.struct([I.u32(`instruction`),K(`authorized`)])},Allocate:{index:8,layout:I.struct([I.u32(`instruction`),I.ns64(`space`)])},AllocateWithSeed:{index:9,layout:I.struct([I.u32(`instruction`),K(`base`),Ao(`seed`),I.ns64(`space`),K(`programId`)])},AssignWithSeed:{index:10,layout:I.struct([I.u32(`instruction`),K(`base`),Ao(`seed`),K(`programId`)])},TransferWithSeed:{index:11,layout:I.struct([I.u32(`instruction`),ps(`lamports`),Ao(`seed`),K(`programId`)])},UpgradeNonceAccount:{index:12,layout:I.struct([I.u32(`instruction`)])}}),gs=class e{constructor(){}static createAccount(e){let t=hs.Create,n=Z(t,{lamports:e.lamports,space:e.space,programId:W(e.programId.toBuffer())});return new J({keys:[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.newAccountPubkey,isSigner:!0,isWritable:!0}],programId:this.programId,data:n})}static transfer(e){let t,n;if(`basePubkey`in e){let r=hs.TransferWithSeed;t=Z(r,{lamports:BigInt(e.lamports),seed:e.seed,programId:W(e.programId.toBuffer())}),n=[{pubkey:e.fromPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0}]}else{let r=hs.Transfer;t=Z(r,{lamports:BigInt(e.lamports)}),n=[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0}]}return new J({keys:n,programId:this.programId,data:t})}static assign(e){let t,n;if(`basePubkey`in e){let r=hs.AssignWithSeed;t=Z(r,{base:W(e.basePubkey.toBuffer()),seed:e.seed,programId:W(e.programId.toBuffer())}),n=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]}else{let r=hs.Assign;t=Z(r,{programId:W(e.programId.toBuffer())}),n=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]}return new J({keys:n,programId:this.programId,data:t})}static createAccountWithSeed(e){let t=hs.CreateWithSeed,n=Z(t,{base:W(e.basePubkey.toBuffer()),seed:e.seed,lamports:e.lamports,space:e.space,programId:W(e.programId.toBuffer())}),r=[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.newAccountPubkey,isSigner:!1,isWritable:!0}];return e.basePubkey.equals(e.fromPubkey)||r.push({pubkey:e.basePubkey,isSigner:!0,isWritable:!1}),new J({keys:r,programId:this.programId,data:n})}static createNonceAccount(t){let n=new Y;`basePubkey`in t&&`seed`in t?n.add(e.createAccountWithSeed({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,basePubkey:t.basePubkey,seed:t.seed,lamports:t.lamports,space:ds,programId:this.programId})):n.add(e.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,lamports:t.lamports,space:ds,programId:this.programId}));let r={noncePubkey:t.noncePubkey,authorizedPubkey:t.authorizedPubkey};return n.add(this.nonceInitialize(r)),n}static nonceInitialize(e){let t=hs.InitializeNonceAccount,n=Z(t,{authorized:W(e.authorizedPubkey.toBuffer())});return new J({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:$o,isSigner:!1,isWritable:!1},{pubkey:es,isSigner:!1,isWritable:!1}],programId:this.programId,data:n})}static nonceAdvance(e){let t=hs.AdvanceNonceAccount,n=Z(t);return new J({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:$o,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static nonceWithdraw(e){let t=hs.WithdrawNonceAccount,n=Z(t,{lamports:e.lamports});return new J({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0},{pubkey:$o,isSigner:!1,isWritable:!1},{pubkey:es,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static nonceAuthorize(e){let t=hs.AuthorizeNonceAccount,n=Z(t,{authorized:W(e.newAuthorizedPubkey.toBuffer())});return new J({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static allocate(e){let t,n;if(`basePubkey`in e){let r=hs.AllocateWithSeed;t=Z(r,{base:W(e.basePubkey.toBuffer()),seed:e.seed,space:e.space,programId:W(e.programId.toBuffer())}),n=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]}else{let r=hs.Allocate;t=Z(r,{space:e.space}),n=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]}return new J({keys:n,programId:this.programId,data:t})}};gs.programId=new G(`11111111111111111111111111111111`);var _s=Co-300,vs=class e{constructor(){}static getMinNumSignatures(t){return 2*(Math.ceil(t/e.chunkSize)+1+1)}static async load(t,n,r,i,a){{let e=await t.getMinimumBalanceForRentExemption(a.length),o=await t.getAccountInfo(r.publicKey,`confirmed`),s=null;if(o!==null){if(o.executable)return console.error(`Program load failed, account is already executable`),!1;o.data.length!==a.length&&(s||=new Y,s.add(gs.allocate({accountPubkey:r.publicKey,space:a.length}))),o.owner.equals(i)||(s||=new Y,s.add(gs.assign({accountPubkey:r.publicKey,programId:i}))),o.lamports<e&&(s||=new Y,s.add(gs.transfer({fromPubkey:n.publicKey,toPubkey:r.publicKey,lamports:e-o.lamports})))}else s=new Y().add(gs.createAccount({fromPubkey:n.publicKey,newAccountPubkey:r.publicKey,lamports:e>0?e:1,space:a.length,programId:i}));s!==null&&await ss(t,s,[n,r],{commitment:`confirmed`})}let o=I.struct([I.u32(`instruction`),I.u32(`offset`),I.u32(`bytesLength`),I.u32(`bytesLengthPadding`),I.seq(I.u8(`byte`),I.offset(I.u32(),-8),`bytes`)]),s=e.chunkSize,c=0,l=a,u=[];for(;l.length>0;){let e=l.slice(0,s),a=F.Buffer.alloc(s+16);o.encode({instruction:0,offset:c,bytes:e,bytesLength:0,bytesLengthPadding:0},a);let d=new Y().add({keys:[{pubkey:r.publicKey,isSigner:!0,isWritable:!0}],programId:i,data:a});u.push(ss(t,d,[n,r],{commitment:`confirmed`})),t._rpcEndpoint.includes(`solana.com`)&&await cs(1e3/4),c+=s,l=l.slice(s)}await Promise.all(u);{let e=I.struct([I.u32(`instruction`)]),a=F.Buffer.alloc(e.span);e.encode({instruction:1},a);let o=new Y().add({keys:[{pubkey:r.publicKey,isSigner:!0,isWritable:!0},{pubkey:es,isSigner:!1,isWritable:!1}],programId:i,data:a}),s=`processed`,c=await t.sendTransaction(o,[n,r],{preflightCommitment:s}),{context:l,value:u}=await t.confirmTransaction({signature:c,lastValidBlockHeight:o.lastValidBlockHeight,blockhash:o.recentBlockhash},s);if(u.err)throw Error(`Transaction ${c} failed (${JSON.stringify(u)})`);for(;;){try{if(await t.getSlot({commitment:s})>l.slot)break}catch{}await new Promise(e=>setTimeout(e,Math.round(Yo/2)))}}return!0}};vs.chunkSize=_s;var ys=new G(`BPFLoader2111111111111111111111111111111111`),bs=class{static getMinNumSignatures(e){return vs.getMinNumSignatures(e)}static load(e,t,n,r,i){return vs.load(e,t,n,i,r)}};function xs(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}var Ss,Cs;function ws(){if(Cs)return Ss;Cs=1;var e=Object.prototype.toString,t=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};function n(r,i){var a,o,s,c,l,u,d;if(r===!0)return`true`;if(r===!1)return`false`;switch(typeof r){case`object`:if(r===null)return null;if(r.toJSON&&typeof r.toJSON==`function`)return n(r.toJSON(),i);if(d=e.call(r),d===`[object Array]`){for(s=`[`,o=r.length-1,a=0;a<o;a++)s+=n(r[a],!0)+`,`;return o>-1&&(s+=n(r[a],!0)),s+`]`}else if(d===`[object Object]`){for(c=t(r).sort(),o=c.length,s=``,a=0;a<o;)l=c[a],u=n(r[l],!1),u!==void 0&&(s&&(s+=`,`),s+=JSON.stringify(l)+`:`+u),a++;return`{`+s+`}`}else return JSON.stringify(r);case`function`:case`undefined`:return i?null:void 0;case`string`:return JSON.stringify(r);default:return isFinite(r)?r:null}}return Ss=function(e){var t=n(e,!1);if(t!==void 0)return``+t},Ss}var Ts=xs(ws()),Es=32;function Ds(e){let t=0;for(;e>1;)e/=2,t++;return t}function Os(e){return e===0?1:(e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,e|=e>>32,e+1)}var ks=class{constructor(e,t,n,r,i){this.slotsPerEpoch=void 0,this.leaderScheduleSlotOffset=void 0,this.warmup=void 0,this.firstNormalEpoch=void 0,this.firstNormalSlot=void 0,this.slotsPerEpoch=e,this.leaderScheduleSlotOffset=t,this.warmup=n,this.firstNormalEpoch=r,this.firstNormalSlot=i}getEpoch(e){return this.getEpochAndSlotIndex(e)[0]}getEpochAndSlotIndex(e){if(e<this.firstNormalSlot){let t=Ds(Os(e+Es+1))-Ds(Es)-1;return[t,e-(this.getSlotsInEpoch(t)-Es)]}else{let t=e-this.firstNormalSlot,n=Math.floor(t/this.slotsPerEpoch);return[this.firstNormalEpoch+n,t%this.slotsPerEpoch]}}getFirstSlotInEpoch(e){return e<=this.firstNormalEpoch?(2**e-1)*Es:(e-this.firstNormalEpoch)*this.slotsPerEpoch+this.firstNormalSlot}getLastSlotInEpoch(e){return this.getFirstSlotInEpoch(e)+this.getSlotsInEpoch(e)-1}getSlotsInEpoch(e){return e<this.firstNormalEpoch?2**(e+Ds(Es)):this.slotsPerEpoch}},As=globalThis.fetch,js=class extends Na{constructor(e,t,n){super(e=>{let n=ja(e,{autoconnect:!0,max_reconnects:5,reconnect:!0,reconnect_interval:1e3,...t});return`socket`in n?this.underlyingSocket=n.socket:this.underlyingSocket=n,n},e,t,n),this.underlyingSocket=void 0}call(...e){let t=this.underlyingSocket?.readyState;return t===1?super.call(...e):Promise.reject(Error("Tried to call a JSON-RPC method `"+e[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+t+`)`))}notify(...e){let t=this.underlyingSocket?.readyState;return t===1?super.notify(...e):Promise.reject(Error("Tried to send a JSON-RPC notification `"+e[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+t+`)`))}};function Ms(e,t){let n;try{n=e.layout.decode(t)}catch(e){throw Error(`invalid instruction; `+e)}if(n.typeIndex!==e.index)throw Error(`invalid account data; account type mismatch ${n.typeIndex} != ${e.index}`);return n}var Ns=56,Ps=class{constructor(e){this.key=void 0,this.state=void 0,this.key=e.key,this.state=e.state}isActive(){let e=BigInt(`0xffffffffffffffff`);return this.state.deactivationSlot===e}static deserialize(e){let t=Ms(Fs,e),n=e.length-Ns;q(n>=0,`lookup table is invalid`),q(n%32==0,`lookup table is invalid`);let r=n/32,{addresses:i}=I.struct([I.seq(K(),r,`addresses`)]).decode(e.slice(Ns));return{deactivationSlot:t.deactivationSlot,lastExtendedSlot:t.lastExtendedSlot,lastExtendedSlotStartIndex:t.lastExtendedStartIndex,authority:t.authority.length===0?void 0:new G(t.authority[0]),addresses:i.map(e=>new G(e))}}},Fs={index:1,layout:I.struct([I.u32(`typeIndex`),ps(`deactivationSlot`),I.nu64(`lastExtendedSlot`),I.u8(`lastExtendedStartIndex`),I.u8(),I.seq(K(),I.offset(I.u8(),-1),`authority`)])},Is=/^[^:]+:\/\/([^:[]+|\[[^\]]+\])(:\d+)?(.*)/i;function Ls(e){let t=e.match(Is);if(t==null)throw TypeError(`Failed to validate endpoint URL \`${e}\``);let[n,r,i,a]=t,o=e.startsWith(`https:`)?`wss:`:`ws:`,s=i==null?null:parseInt(i.slice(1),10);return`${o}//${r}${s==null?``:`:${s+1}`}${a}`}var Rs=Di(bi(G),H(),e=>new G(e)),zs=wi([H(),xi(`base64`)]),Bs=Di(bi(F.Buffer),zs,e=>F.Buffer.from(e[0],`base64`)),Vs=30*1e3;function Hs(e){if(/^https?:/.test(e)===!1)throw TypeError("Endpoint URL must start with `http:` or `https:`.");return e}function Us(e){let t,n;if(typeof e==`string`)t=e;else if(e){let{commitment:r,...i}=e;t=r,n=i}return{commitment:t,config:n}}function Ws(e){return e.map(e=>`memcmp`in e?{...e,memcmp:{...e.memcmp,encoding:e.memcmp.encoding??`base58`}}:e)}function Gs(e){return Ti([U({jsonrpc:xi(`2.0`),id:H(),result:e}),U({jsonrpc:xi(`2.0`),id:H(),error:U({code:Ei(),message:H(),data:V(vi())})})])}var Ks=Gs(Ei());function $(e){return Di(Gs(e),Ks,t=>`error`in t?t:{...t,result:L(t.result,e)})}function qs(e){return $(U({context:U({slot:B()}),value:e}))}function Js(e){return U({context:U({slot:B()}),value:e})}function Ys(e,t){return e===0?new Uo({header:t.header,staticAccountKeys:t.accountKeys.map(e=>new G(e)),recentBlockhash:t.recentBlockhash,compiledInstructions:t.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:kr.default.decode(e.data)})),addressTableLookups:t.addressTableLookups}):new Ho(t)}var Xs=U({foundation:B(),foundationTerm:B(),initial:B(),taper:B(),terminal:B()}),Zs=$(R(z(U({epoch:B(),effectiveSlot:B(),amount:B(),postBalance:B(),commission:V(z(B()))})))),Qs=R(U({slot:B(),prioritizationFee:B()})),$s=U({total:B(),validator:B(),foundation:B(),epoch:B()}),ec=U({epoch:B(),slotIndex:B(),slotsInEpoch:B(),absoluteSlot:B(),blockHeight:V(B()),transactionCount:V(B())}),tc=U({slotsPerEpoch:B(),leaderScheduleSlotOffset:B(),warmup:yi(),firstNormalEpoch:B(),firstNormalSlot:B()}),nc=Ci(H(),R(B())),rc=z(Ti([U({}),H()])),ic=U({err:rc}),ac=xi(`receivedSignature`),oc=U({"solana-core":H(),"feature-set":V(B())}),sc=U({program:H(),programId:Rs,parsed:Ei()}),cc=U({programId:Rs,accounts:R(Rs),data:H()}),lc=qs(U({err:z(Ti([U({}),H()])),logs:z(R(H())),accounts:V(z(R(z(U({executable:yi(),owner:H(),lamports:B(),data:R(H()),rentEpoch:V(B())}))))),unitsConsumed:V(B()),returnData:V(z(U({programId:H(),data:wi([H(),xi(`base64`)])}))),innerInstructions:V(z(R(U({index:B(),instructions:R(Ti([sc,cc]))}))))})),uc=qs(U({byIdentity:Ci(H(),R(B())),range:U({firstSlot:B(),lastSlot:B()})}));function dc(e,t,n,r,i,a){let o=n||As;a!=null&&console.warn("You have supplied an `httpAgent` when creating a `Connection` in a browser environment.It has been ignored; `httpAgent` is only used in Node environments.");let s;return r&&(s=async(e,t)=>await o(...await new Promise((n,i)=>{try{r(e,t,(e,t)=>n([e,t]))}catch(e){i(e)}}))),new ka.default(async(n,r)=>{let a={method:`POST`,body:n,agent:void 0,headers:Object.assign({"Content-Type":`application/json`},t||{},Ol)};try{let t=5,n,c=500;for(;n=s?await s(e,a):await o(e,a),!(n.status!==429||i===!0||(--t,t===0));)console.error(`Server responded with ${n.status} ${n.statusText}. Retrying after ${c}ms delay...`),await cs(c),c*=2;let l=await n.text();n.ok?r(null,l):r(Error(`${n.status} ${n.statusText}: ${l}`))}catch(e){e instanceof Error&&r(e)}},{})}function fc(e){return(t,n)=>new Promise((r,i)=>{e.request(t,n,(e,t)=>{if(e){i(e);return}r(t)})})}function pc(e){return t=>new Promise((n,r)=>{t.length===0&&n([]);let i=t.map(t=>e.request(t.methodName,t.args));e.request(i,(e,t)=>{if(e){r(e);return}n(t)})})}var mc=$(Xs),hc=$($s),gc=$(Qs),_c=$(ec),vc=$(tc),yc=$(nc),bc=$(B()),xc=qs(U({total:B(),circulating:B(),nonCirculating:B(),nonCirculatingAccounts:R(Rs)})),Sc=U({amount:H(),uiAmount:z(B()),decimals:B(),uiAmountString:V(H())}),Cc=qs(R(U({address:Rs,amount:H(),uiAmount:z(B()),decimals:B(),uiAmountString:V(H())}))),wc=qs(R(U({pubkey:Rs,account:U({executable:yi(),owner:Rs,lamports:B(),data:Bs,rentEpoch:B()})}))),Tc=U({program:H(),parsed:Ei(),space:B()}),Ec=qs(R(U({pubkey:Rs,account:U({executable:yi(),owner:Rs,lamports:B(),data:Tc,rentEpoch:B()})}))),Dc=qs(R(U({lamports:B(),address:Rs}))),Oc=U({executable:yi(),owner:Rs,lamports:B(),data:Bs,rentEpoch:B()}),kc=U({pubkey:Rs,account:Oc}),Ac=Di(Ti([bi(F.Buffer),Tc]),Ti([zs,Tc]),e=>Array.isArray(e)?L(e,Bs):e),jc=U({executable:yi(),owner:Rs,lamports:B(),data:Ac,rentEpoch:B()}),Mc=U({pubkey:Rs,account:jc}),Nc=U({state:Ti([xi(`active`),xi(`inactive`),xi(`activating`),xi(`deactivating`)]),active:B(),inactive:B()}),Pc=$(R(U({signature:H(),slot:B(),err:rc,memo:z(H()),blockTime:V(z(B()))}))),Fc=$(R(U({signature:H(),slot:B(),err:rc,memo:z(H()),blockTime:V(z(B()))}))),Ic=U({subscription:B(),result:Js(Oc)}),Lc=U({pubkey:Rs,account:Oc}),Rc=U({subscription:B(),result:Js(Lc)}),zc=U({parent:B(),slot:B(),root:B()}),Bc=U({subscription:B(),result:zc}),Vc=Ti([U({type:Ti([xi(`firstShredReceived`),xi(`completed`),xi(`optimisticConfirmation`),xi(`root`)]),slot:B(),timestamp:B()}),U({type:xi(`createdBank`),parent:B(),slot:B(),timestamp:B()}),U({type:xi(`frozen`),slot:B(),timestamp:B(),stats:U({numTransactionEntries:B(),numSuccessfulTransactions:B(),numFailedTransactions:B(),maxTransactionsPerEntry:B()})}),U({type:xi(`dead`),slot:B(),timestamp:B(),err:H()})]),Hc=U({subscription:B(),result:Vc}),Uc=U({subscription:B(),result:Js(Ti([ic,ac]))}),Wc=U({subscription:B(),result:B()}),Gc=U({pubkey:H(),gossip:z(H()),tpu:z(H()),rpc:z(H()),version:z(H())}),Kc=U({votePubkey:H(),nodePubkey:H(),activatedStake:B(),epochVoteAccount:yi(),epochCredits:R(wi([B(),B(),B()])),commission:B(),lastVote:B(),rootSlot:z(B())}),qc=$(U({current:R(Kc),delinquent:R(Kc)})),Jc=Ti([xi(`processed`),xi(`confirmed`),xi(`finalized`)]),Yc=qs(R(z(U({slot:B(),confirmations:z(B()),err:rc,confirmationStatus:V(Jc)})))),Xc=$(B()),Zc=U({accountKey:Rs,writableIndexes:R(B()),readonlyIndexes:R(B())}),Qc=U({signatures:R(H()),message:U({accountKeys:R(H()),header:U({numRequiredSignatures:B(),numReadonlySignedAccounts:B(),numReadonlyUnsignedAccounts:B()}),instructions:R(U({accounts:R(B()),data:H(),programIdIndex:B()})),recentBlockhash:H(),addressTableLookups:V(R(Zc))})}),$c=U({pubkey:Rs,signer:yi(),writable:yi(),source:V(Ti([xi(`transaction`),xi(`lookupTable`)]))}),el=U({accountKeys:R($c),signatures:R(H())}),tl=U({parsed:Ei(),program:H(),programId:Rs}),nl=U({accounts:R(Rs),data:H(),programId:Rs}),rl=Di(Ti([nl,tl]),Ti([U({parsed:Ei(),program:H(),programId:H()}),U({accounts:R(H()),data:H(),programId:H()})]),e=>`accounts`in e?L(e,nl):L(e,tl)),il=U({signatures:R(H()),message:U({accountKeys:R($c),instructions:R(rl),recentBlockhash:H(),addressTableLookups:V(z(R(Zc)))})}),al=U({accountIndex:B(),mint:H(),owner:V(H()),programId:V(H()),uiTokenAmount:Sc}),ol=U({writable:R(Rs),readonly:R(Rs)}),sl=U({err:rc,fee:B(),innerInstructions:V(z(R(U({index:B(),instructions:R(U({accounts:R(B()),data:H(),programIdIndex:B()}))})))),preBalances:R(B()),postBalances:R(B()),logMessages:V(z(R(H()))),preTokenBalances:V(z(R(al))),postTokenBalances:V(z(R(al))),loadedAddresses:V(ol),computeUnitsConsumed:V(B()),costUnits:V(B())}),cl=U({err:rc,fee:B(),innerInstructions:V(z(R(U({index:B(),instructions:R(rl)})))),preBalances:R(B()),postBalances:R(B()),logMessages:V(z(R(H()))),preTokenBalances:V(z(R(al))),postTokenBalances:V(z(R(al))),loadedAddresses:V(ol),computeUnitsConsumed:V(B()),costUnits:V(B())}),ll=Ti([xi(0),xi(`legacy`)]),ul=U({pubkey:H(),lamports:B(),postBalance:z(B()),rewardType:z(H()),commission:V(z(B()))}),dl=$(z(U({blockhash:H(),previousBlockhash:H(),parentSlot:B(),transactions:R(U({transaction:Qc,meta:z(sl),version:V(ll)})),rewards:V(R(ul)),blockTime:z(B()),blockHeight:z(B())}))),fl=$(z(U({blockhash:H(),previousBlockhash:H(),parentSlot:B(),rewards:V(R(ul)),blockTime:z(B()),blockHeight:z(B())}))),pl=$(z(U({blockhash:H(),previousBlockhash:H(),parentSlot:B(),transactions:R(U({transaction:el,meta:z(sl),version:V(ll)})),rewards:V(R(ul)),blockTime:z(B()),blockHeight:z(B())}))),ml=$(z(U({blockhash:H(),previousBlockhash:H(),parentSlot:B(),transactions:R(U({transaction:il,meta:z(cl),version:V(ll)})),rewards:V(R(ul)),blockTime:z(B()),blockHeight:z(B())}))),hl=$(z(U({blockhash:H(),previousBlockhash:H(),parentSlot:B(),transactions:R(U({transaction:el,meta:z(cl),version:V(ll)})),rewards:V(R(ul)),blockTime:z(B()),blockHeight:z(B())}))),gl=$(z(U({blockhash:H(),previousBlockhash:H(),parentSlot:B(),rewards:V(R(ul)),blockTime:z(B()),blockHeight:z(B())}))),_l=$(z(U({blockhash:H(),previousBlockhash:H(),parentSlot:B(),transactions:R(U({transaction:Qc,meta:z(sl)})),rewards:V(R(ul)),blockTime:z(B())}))),vl=$(z(U({blockhash:H(),previousBlockhash:H(),parentSlot:B(),signatures:R(H()),blockTime:z(B())}))),yl=$(z(U({slot:B(),meta:z(sl),blockTime:V(z(B())),transaction:Qc,version:V(ll)}))),bl=$(z(U({slot:B(),transaction:il,meta:z(cl),blockTime:V(z(B())),version:V(ll)}))),xl=qs(U({blockhash:H(),lastValidBlockHeight:B()})),Sl=qs(yi()),Cl=$(R(U({slot:B(),numTransactions:B(),numSlots:B(),samplePeriodSecs:B()}))),wl=qs(z(U({feeCalculator:U({lamportsPerSignature:B()})}))),Tl=$(H()),El=$(H()),Dl=U({result:Js(U({err:rc,logs:R(H()),signature:H()})),subscription:B()}),Ol={"solana-client":`js/1.0.0-maintenance`},kl=class{constructor(e,t){this._commitment=void 0,this._confirmTransactionInitialTimeout=void 0,this._rpcEndpoint=void 0,this._rpcWsEndpoint=void 0,this._rpcClient=void 0,this._rpcRequest=void 0,this._rpcBatchRequest=void 0,this._rpcWebSocket=void 0,this._rpcWebSocketConnected=!1,this._rpcWebSocketHeartbeat=null,this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketGeneration=0,this._disableBlockhashCaching=!1,this._pollingBlockhash=!1,this._blockhashInfo={latestBlockhash:null,lastFetch:0,transactionSignatures:[],simulatedSignatures:[]},this._nextClientSubscriptionId=0,this._subscriptionDisposeFunctionsByClientSubscriptionId={},this._subscriptionHashByClientSubscriptionId={},this._subscriptionStateChangeCallbacksByHash={},this._subscriptionCallbacksByServerSubscriptionId={},this._subscriptionsByHash={},this._subscriptionsAutoDisposedByRpc=new Set,this.getBlockHeight=(()=>{let e={};return async t=>{let{commitment:n,config:r}=Us(t),i=this._buildArgs([],n,void 0,r),a=Ts(i);return e[a]=e[a]??(async()=>{try{let e=L(await this._rpcRequest(`getBlockHeight`,i),$(B()));if(`error`in e)throw new X(e.error,`failed to get block height information`);return e.result}finally{delete e[a]}})(),await e[a]}})();let n,r,i,a,o,s;t&&typeof t==`string`?this._commitment=t:t&&(this._commitment=t.commitment,this._confirmTransactionInitialTimeout=t.confirmTransactionInitialTimeout,n=t.wsEndpoint,r=t.httpHeaders,i=t.fetch,a=t.fetchMiddleware,o=t.disableRetryOnRateLimit,s=t.httpAgent),this._rpcEndpoint=Hs(e),this._rpcWsEndpoint=n||Ls(e),this._rpcClient=dc(e,r,i,a,o,s),this._rpcRequest=fc(this._rpcClient),this._rpcBatchRequest=pc(this._rpcClient),this._rpcWebSocket=new js(this._rpcWsEndpoint,{autoconnect:!1,max_reconnects:1/0}),this._rpcWebSocket.on(`open`,this._wsOnOpen.bind(this)),this._rpcWebSocket.on(`error`,this._wsOnError.bind(this)),this._rpcWebSocket.on(`close`,this._wsOnClose.bind(this)),this._rpcWebSocket.on(`accountNotification`,this._wsOnAccountNotification.bind(this)),this._rpcWebSocket.on(`programNotification`,this._wsOnProgramAccountNotification.bind(this)),this._rpcWebSocket.on(`slotNotification`,this._wsOnSlotNotification.bind(this)),this._rpcWebSocket.on(`slotsUpdatesNotification`,this._wsOnSlotUpdatesNotification.bind(this)),this._rpcWebSocket.on(`signatureNotification`,this._wsOnSignatureNotification.bind(this)),this._rpcWebSocket.on(`rootNotification`,this._wsOnRootNotification.bind(this)),this._rpcWebSocket.on(`logsNotification`,this._wsOnLogsNotification.bind(this))}get commitment(){return this._commitment}get rpcEndpoint(){return this._rpcEndpoint}async getBalanceAndContext(e,t){let{commitment:n,config:r}=Us(t),i=this._buildArgs([e.toBase58()],n,void 0,r),a=L(await this._rpcRequest(`getBalance`,i),qs(B()));if(`error`in a)throw new X(a.error,`failed to get balance for ${e.toBase58()}`);return a.result}async getBalance(e,t){return await this.getBalanceAndContext(e,t).then(e=>e.value).catch(t=>{throw Error(`failed to get balance of account `+e.toBase58()+`: `+t)})}async getBlockTime(e){let t=L(await this._rpcRequest(`getBlockTime`,[e]),$(z(B())));if(`error`in t)throw new X(t.error,`failed to get block time for slot ${e}`);return t.result}async getMinimumLedgerSlot(){let e=L(await this._rpcRequest(`minimumLedgerSlot`,[]),$(B()));if(`error`in e)throw new X(e.error,`failed to get minimum ledger slot`);return e.result}async getFirstAvailableBlock(){let e=L(await this._rpcRequest(`getFirstAvailableBlock`,[]),bc);if(`error`in e)throw new X(e.error,`failed to get first available block`);return e.result}async getSupply(e){let t={};t=typeof e==`string`?{commitment:e}:e?{...e,commitment:e&&e.commitment||this.commitment}:{commitment:this.commitment};let n=L(await this._rpcRequest(`getSupply`,[t]),xc);if(`error`in n)throw new X(n.error,`failed to get supply`);return n.result}async getTokenSupply(e,t){let n=this._buildArgs([e.toBase58()],t),r=L(await this._rpcRequest(`getTokenSupply`,n),qs(Sc));if(`error`in r)throw new X(r.error,`failed to get token supply`);return r.result}async getTokenAccountBalance(e,t){let n=this._buildArgs([e.toBase58()],t),r=L(await this._rpcRequest(`getTokenAccountBalance`,n),qs(Sc));if(`error`in r)throw new X(r.error,`failed to get token account balance`);return r.result}async getTokenAccountsByOwner(e,t,n){let{commitment:r,config:i}=Us(n),a=[e.toBase58()];`mint`in t?a.push({mint:t.mint.toBase58()}):a.push({programId:t.programId.toBase58()});let o=this._buildArgs(a,r,`base64`,i),s=L(await this._rpcRequest(`getTokenAccountsByOwner`,o),wc);if(`error`in s)throw new X(s.error,`failed to get token accounts owned by account ${e.toBase58()}`);return s.result}async getParsedTokenAccountsByOwner(e,t,n){let r=[e.toBase58()];`mint`in t?r.push({mint:t.mint.toBase58()}):r.push({programId:t.programId.toBase58()});let i=this._buildArgs(r,n,`jsonParsed`),a=L(await this._rpcRequest(`getTokenAccountsByOwner`,i),Ec);if(`error`in a)throw new X(a.error,`failed to get token accounts owned by account ${e.toBase58()}`);return a.result}async getLargestAccounts(e){let t={...e,commitment:e&&e.commitment||this.commitment},n=t.filter||t.commitment?[t]:[],r=L(await this._rpcRequest(`getLargestAccounts`,n),Dc);if(`error`in r)throw new X(r.error,`failed to get largest accounts`);return r.result}async getTokenLargestAccounts(e,t){let n=this._buildArgs([e.toBase58()],t),r=L(await this._rpcRequest(`getTokenLargestAccounts`,n),Cc);if(`error`in r)throw new X(r.error,`failed to get token largest accounts`);return r.result}async getAccountInfoAndContext(e,t){let{commitment:n,config:r}=Us(t),i=this._buildArgs([e.toBase58()],n,`base64`,r),a=L(await this._rpcRequest(`getAccountInfo`,i),qs(z(Oc)));if(`error`in a)throw new X(a.error,`failed to get info about account ${e.toBase58()}`);return a.result}async getParsedAccountInfo(e,t){let{commitment:n,config:r}=Us(t),i=this._buildArgs([e.toBase58()],n,`jsonParsed`,r),a=L(await this._rpcRequest(`getAccountInfo`,i),qs(z(jc)));if(`error`in a)throw new X(a.error,`failed to get info about account ${e.toBase58()}`);return a.result}async getAccountInfo(e,t){try{return(await this.getAccountInfoAndContext(e,t)).value}catch(t){throw Error(`failed to get info about account `+e.toBase58()+`: `+t)}}async getMultipleParsedAccounts(e,t){let{commitment:n,config:r}=Us(t),i=e.map(e=>e.toBase58()),a=this._buildArgs([i],n,`jsonParsed`,r),o=L(await this._rpcRequest(`getMultipleAccounts`,a),qs(R(z(jc))));if(`error`in o)throw new X(o.error,`failed to get info for accounts ${i}`);return o.result}async getMultipleAccountsInfoAndContext(e,t){let{commitment:n,config:r}=Us(t),i=e.map(e=>e.toBase58()),a=this._buildArgs([i],n,`base64`,r),o=L(await this._rpcRequest(`getMultipleAccounts`,a),qs(R(z(Oc))));if(`error`in o)throw new X(o.error,`failed to get info for accounts ${i}`);return o.result}async getMultipleAccountsInfo(e,t){return(await this.getMultipleAccountsInfoAndContext(e,t)).value}async getStakeActivation(e,t,n){let{commitment:r,config:i}=Us(t),a=this._buildArgs([e.toBase58()],r,void 0,{...i,epoch:n??i?.epoch}),o=L(await this._rpcRequest(`getStakeActivation`,a),$(Nc));if(`error`in o)throw new X(o.error,`failed to get Stake Activation ${e.toBase58()}`);return o.result}async getProgramAccounts(e,t){let{commitment:n,config:r}=Us(t),{encoding:i,...a}=r||{},o=this._buildArgs([e.toBase58()],n,i||`base64`,{...a,...a.filters?{filters:Ws(a.filters)}:null}),s=await this._rpcRequest(`getProgramAccounts`,o),c=R(kc),l=a.withContext===!0?L(s,qs(c)):L(s,$(c));if(`error`in l)throw new X(l.error,`failed to get accounts owned by program ${e.toBase58()}`);return l.result}async getParsedProgramAccounts(e,t){let{commitment:n,config:r}=Us(t),i=this._buildArgs([e.toBase58()],n,`jsonParsed`,r),a=L(await this._rpcRequest(`getProgramAccounts`,i),$(R(Mc)));if(`error`in a)throw new X(a.error,`failed to get accounts owned by program ${e.toBase58()}`);return a.result}async confirmTransaction(e,t){let n;if(typeof e==`string`)n=e;else{let t=e;if(t.abortSignal?.aborted)return Promise.reject(t.abortSignal.reason);n=t.signature}let r;try{r=kr.default.decode(n)}catch{throw Error(`signature must be base58 encoded: `+n)}return q(r.length===64,`signature has invalid length`),typeof e==`string`?await this.confirmTransactionUsingLegacyTimeoutStrategy({commitment:t||this.commitment,signature:n}):`lastValidBlockHeight`in e?await this.confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:t||this.commitment,strategy:e}):await this.confirmTransactionUsingDurableNonceStrategy({commitment:t||this.commitment,strategy:e})}getCancellationPromise(e){return new Promise((t,n)=>{e!=null&&(e.aborted?n(e.reason):e.addEventListener(`abort`,()=>{n(e.reason)}))})}getTransactionConfirmationPromise({commitment:e,signature:t}){let n,r,i=!1;return{abortConfirmation:()=>{r&&=(r(),void 0),n!=null&&(this.removeSignatureListener(n),n=void 0)},confirmationPromise:new Promise((a,o)=>{try{n=this.onSignature(t,(e,t)=>{n=void 0;let r={context:t,value:e};a({__type:Go.PROCESSED,response:r})},e);let s=new Promise(e=>{n==null?e():r=this._onSubscriptionStateChange(n,t=>{t===`subscribed`&&e()})});(async()=>{if(await s,i)return;let n=await this.getSignatureStatus(t);if(i||n==null)return;let{context:r,value:c}=n;if(c!=null)if(c?.err)o(c.err);else{switch(e){case`confirmed`:case`single`:case`singleGossip`:if(c.confirmationStatus===`processed`)return;break;case`finalized`:case`max`:case`root`:if(c.confirmationStatus===`processed`||c.confirmationStatus===`confirmed`)return;break;case`processed`:case`recent`:}i=!0,a({__type:Go.PROCESSED,response:{context:r,value:c}})}})()}catch(e){o(e)}})}}async confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:e,strategy:{abortSignal:t,lastValidBlockHeight:n,signature:r}}){let i=!1,a=new Promise(t=>{let r=async()=>{try{return await this.getBlockHeight(e)}catch{return-1}};(async()=>{let e=await r();if(!i){for(;e<=n;)if(await cs(1e3),i||(e=await r(),i))return;t({__type:Go.BLOCKHEIGHT_EXCEEDED})}})()}),{abortConfirmation:o,confirmationPromise:s}=this.getTransactionConfirmationPromise({commitment:e,signature:r}),c=this.getCancellationPromise(t),l;try{let e=await Promise.race([c,s,a]);if(e.__type===Go.PROCESSED)l=e.response;else throw new To(r)}finally{i=!0,o()}return l}async confirmTransactionUsingDurableNonceStrategy({commitment:e,strategy:{abortSignal:t,minContextSlot:n,nonceAccountPubkey:r,nonceValue:i,signature:a}}){let o=!1,s=new Promise(t=>{let a=i,s=null,c=async()=>{try{let{context:t,value:i}=await this.getNonceAndContext(r,{commitment:e,minContextSlot:n});return s=t.slot,i?.nonce}catch{return a}};(async()=>{if(a=await c(),!o)for(;;){if(i!==a){t({__type:Go.NONCE_INVALID,slotInWhichNonceDidAdvance:s});return}if(await cs(2e3),o||(a=await c(),o))return}})()}),{abortConfirmation:c,confirmationPromise:l}=this.getTransactionConfirmationPromise({commitment:e,signature:a}),u=this.getCancellationPromise(t),d;try{let t=await Promise.race([u,l,s]);if(t.__type===Go.PROCESSED)d=t.response;else{let r;for(;;){let e=await this.getSignatureStatus(a);if(e==null)break;if(e.context.slot<(t.slotInWhichNonceDidAdvance??n)){await cs(400);continue}r=e;break}if(r?.value){let t=e||`finalized`,{confirmationStatus:n}=r.value;switch(t){case`processed`:case`recent`:if(n!==`processed`&&n!==`confirmed`&&n!==`finalized`)throw new Do(a);break;case`confirmed`:case`single`:case`singleGossip`:if(n!==`confirmed`&&n!==`finalized`)throw new Do(a);break;case`finalized`:case`max`:case`root`:if(n!==`finalized`)throw new Do(a);break;default:(e=>{})(t)}d={context:r.context,value:{err:r.value.err}}}else throw new Do(a)}}finally{o=!0,c()}return d}async confirmTransactionUsingLegacyTimeoutStrategy({commitment:e,signature:t}){let n,r=new Promise(t=>{let r=this._confirmTransactionInitialTimeout||60*1e3;switch(e){case`processed`:case`recent`:case`single`:case`confirmed`:case`singleGossip`:r=this._confirmTransactionInitialTimeout||30*1e3;break}n=setTimeout(()=>t({__type:Go.TIMED_OUT,timeoutMs:r}),r)}),{abortConfirmation:i,confirmationPromise:a}=this.getTransactionConfirmationPromise({commitment:e,signature:t}),o;try{let e=await Promise.race([a,r]);if(e.__type===Go.PROCESSED)o=e.response;else throw new Eo(t,e.timeoutMs/1e3)}finally{clearTimeout(n),i()}return o}async getClusterNodes(){let e=L(await this._rpcRequest(`getClusterNodes`,[]),$(R(Gc)));if(`error`in e)throw new X(e.error,`failed to get cluster nodes`);return e.result}async getVoteAccounts(e){let t=this._buildArgs([],e),n=L(await this._rpcRequest(`getVoteAccounts`,t),qc);if(`error`in n)throw new X(n.error,`failed to get vote accounts`);return n.result}async getSlot(e){let{commitment:t,config:n}=Us(e),r=this._buildArgs([],t,void 0,n),i=L(await this._rpcRequest(`getSlot`,r),$(B()));if(`error`in i)throw new X(i.error,`failed to get slot`);return i.result}async getSlotLeader(e){let{commitment:t,config:n}=Us(e),r=this._buildArgs([],t,void 0,n),i=L(await this._rpcRequest(`getSlotLeader`,r),$(H()));if(`error`in i)throw new X(i.error,`failed to get slot leader`);return i.result}async getSlotLeaders(e,t){let n=[e,t],r=L(await this._rpcRequest(`getSlotLeaders`,n),$(R(Rs)));if(`error`in r)throw new X(r.error,`failed to get slot leaders`);return r.result}async getSignatureStatus(e,t){let{context:n,value:r}=await this.getSignatureStatuses([e],t);return q(r.length===1),{context:n,value:r[0]}}async getSignatureStatuses(e,t){let n=[e];t&&n.push(t);let r=L(await this._rpcRequest(`getSignatureStatuses`,n),Yc);if(`error`in r)throw new X(r.error,`failed to get signature status`);return r.result}async getTransactionCount(e){let{commitment:t,config:n}=Us(e),r=this._buildArgs([],t,void 0,n),i=L(await this._rpcRequest(`getTransactionCount`,r),$(B()));if(`error`in i)throw new X(i.error,`failed to get transaction count`);return i.result}async getTotalSupply(e){return(await this.getSupply({commitment:e,excludeNonCirculatingAccountsList:!0})).value.total}async getInflationGovernor(e){let t=this._buildArgs([],e),n=L(await this._rpcRequest(`getInflationGovernor`,t),mc);if(`error`in n)throw new X(n.error,`failed to get inflation`);return n.result}async getInflationReward(e,t,n){let{commitment:r,config:i}=Us(n),a=this._buildArgs([e.map(e=>e.toBase58())],r,void 0,{...i,epoch:t??i?.epoch}),o=L(await this._rpcRequest(`getInflationReward`,a),Zs);if(`error`in o)throw new X(o.error,`failed to get inflation reward`);return o.result}async getInflationRate(){let e=L(await this._rpcRequest(`getInflationRate`,[]),hc);if(`error`in e)throw new X(e.error,`failed to get inflation rate`);return e.result}async getEpochInfo(e){let{commitment:t,config:n}=Us(e),r=this._buildArgs([],t,void 0,n),i=L(await this._rpcRequest(`getEpochInfo`,r),_c);if(`error`in i)throw new X(i.error,`failed to get epoch info`);return i.result}async getEpochSchedule(){let e=L(await this._rpcRequest(`getEpochSchedule`,[]),vc);if(`error`in e)throw new X(e.error,`failed to get epoch schedule`);let t=e.result;return new ks(t.slotsPerEpoch,t.leaderScheduleSlotOffset,t.warmup,t.firstNormalEpoch,t.firstNormalSlot)}async getLeaderSchedule(){let e=L(await this._rpcRequest(`getLeaderSchedule`,[]),yc);if(`error`in e)throw new X(e.error,`failed to get leader schedule`);return e.result}async getMinimumBalanceForRentExemption(e,t){let n=this._buildArgs([e],t),r=L(await this._rpcRequest(`getMinimumBalanceForRentExemption`,n),Xc);return`error`in r?(console.warn(`Unable to fetch minimum balance for rent exemption`),0):r.result}async getRecentBlockhashAndContext(e){let{context:t,value:{blockhash:n}}=await this.getLatestBlockhashAndContext(e);return{context:t,value:{blockhash:n,feeCalculator:{get lamportsPerSignature(){throw Error("The capability to fetch `lamportsPerSignature` using the `getRecentBlockhash` API is no longer offered by the network. Use the `getFeeForMessage` API to obtain the fee for a given message.")},toJSON(){return{}}}}}}async getRecentPerformanceSamples(e){let t=L(await this._rpcRequest(`getRecentPerformanceSamples`,e?[e]:[]),Cl);if(`error`in t)throw new X(t.error,`failed to get recent performance samples`);return t.result}async getFeeCalculatorForBlockhash(e,t){let n=this._buildArgs([e],t),r=L(await this._rpcRequest(`getFeeCalculatorForBlockhash`,n),wl);if(`error`in r)throw new X(r.error,`failed to get fee calculator`);let{context:i,value:a}=r.result;return{context:i,value:a===null?null:a.feeCalculator}}async getFeeForMessage(e,t){let n=W(e.serialize()).toString(`base64`),r=this._buildArgs([n],t),i=L(await this._rpcRequest(`getFeeForMessage`,r),qs(z(B())));if(`error`in i)throw new X(i.error,`failed to get fee for message`);if(i.result===null)throw Error(`invalid blockhash`);return i.result}async getRecentPrioritizationFees(e){let t=e?.lockedWritableAccounts?.map(e=>e.toBase58()),n=t?.length?[t]:[],r=L(await this._rpcRequest(`getRecentPrioritizationFees`,n),gc);if(`error`in r)throw new X(r.error,`failed to get recent prioritization fees`);return r.result}async getRecentBlockhash(e){try{return(await this.getRecentBlockhashAndContext(e)).value}catch(e){throw Error(`failed to get recent blockhash: `+e)}}async getLatestBlockhash(e){try{return(await this.getLatestBlockhashAndContext(e)).value}catch(e){throw Error(`failed to get recent blockhash: `+e)}}async getLatestBlockhashAndContext(e){let{commitment:t,config:n}=Us(e),r=this._buildArgs([],t,void 0,n),i=L(await this._rpcRequest(`getLatestBlockhash`,r),xl);if(`error`in i)throw new X(i.error,`failed to get latest blockhash`);return i.result}async isBlockhashValid(e,t){let{commitment:n,config:r}=Us(t),i=this._buildArgs([e],n,void 0,r),a=L(await this._rpcRequest(`isBlockhashValid`,i),Sl);if(`error`in a)throw new X(a.error,"failed to determine if the blockhash `"+e+"`is valid");return a.result}async getVersion(){let e=L(await this._rpcRequest(`getVersion`,[]),$(oc));if(`error`in e)throw new X(e.error,`failed to get version`);return e.result}async getGenesisHash(){let e=L(await this._rpcRequest(`getGenesisHash`,[]),$(H()));if(`error`in e)throw new X(e.error,`failed to get genesis hash`);return e.result}async getBlock(e,t){let{commitment:n,config:r}=Us(t),i=this._buildArgsAtLeastConfirmed([e],n,void 0,r),a=await this._rpcRequest(`getBlock`,i);try{switch(r?.transactionDetails){case`accounts`:{let e=L(a,pl);if(`error`in e)throw e.error;return e.result}case`none`:{let e=L(a,fl);if(`error`in e)throw e.error;return e.result}default:{let e=L(a,dl);if(`error`in e)throw e.error;let{result:t}=e;return t?{...t,transactions:t.transactions.map(({transaction:e,meta:t,version:n})=>({meta:t,transaction:{...e,message:Ys(n,e.message)},version:n}))}:null}}}catch(e){throw new X(e,`failed to get confirmed block`)}}async getParsedBlock(e,t){let{commitment:n,config:r}=Us(t),i=this._buildArgsAtLeastConfirmed([e],n,`jsonParsed`,r),a=await this._rpcRequest(`getBlock`,i);try{switch(r?.transactionDetails){case`accounts`:{let e=L(a,hl);if(`error`in e)throw e.error;return e.result}case`none`:{let e=L(a,gl);if(`error`in e)throw e.error;return e.result}default:{let e=L(a,ml);if(`error`in e)throw e.error;return e.result}}}catch(e){throw new X(e,`failed to get block`)}}async getBlockProduction(e){let t,n;if(typeof e==`string`)n=e;else if(e){let{commitment:r,...i}=e;n=r,t=i}let r=this._buildArgs([],n,`base64`,t),i=L(await this._rpcRequest(`getBlockProduction`,r),uc);if(`error`in i)throw new X(i.error,`failed to get block production information`);return i.result}async getTransaction(e,t){let{commitment:n,config:r}=Us(t),i=this._buildArgsAtLeastConfirmed([e],n,void 0,r),a=L(await this._rpcRequest(`getTransaction`,i),yl);if(`error`in a)throw new X(a.error,`failed to get transaction`);let o=a.result;return o&&{...o,transaction:{...o.transaction,message:Ys(o.version,o.transaction.message)}}}async getParsedTransaction(e,t){let{commitment:n,config:r}=Us(t),i=this._buildArgsAtLeastConfirmed([e],n,`jsonParsed`,r),a=L(await this._rpcRequest(`getTransaction`,i),bl);if(`error`in a)throw new X(a.error,`failed to get transaction`);return a.result}async getParsedTransactions(e,t){let{commitment:n,config:r}=Us(t),i=e.map(e=>({methodName:`getTransaction`,args:this._buildArgsAtLeastConfirmed([e],n,`jsonParsed`,r)}));return(await this._rpcBatchRequest(i)).map(e=>{let t=L(e,bl);if(`error`in t)throw new X(t.error,`failed to get transactions`);return t.result})}async getTransactions(e,t){let{commitment:n,config:r}=Us(t),i=e.map(e=>({methodName:`getTransaction`,args:this._buildArgsAtLeastConfirmed([e],n,void 0,r)}));return(await this._rpcBatchRequest(i)).map(e=>{let t=L(e,yl);if(`error`in t)throw new X(t.error,`failed to get transactions`);let n=t.result;return n&&{...n,transaction:{...n.transaction,message:Ys(n.version,n.transaction.message)}}})}async getConfirmedBlock(e,t){let n=this._buildArgsAtLeastConfirmed([e],t),r=L(await this._rpcRequest(`getBlock`,n),_l);if(`error`in r)throw new X(r.error,`failed to get confirmed block`);let i=r.result;if(!i)throw Error(`Confirmed block `+e+` not found`);let a={...i,transactions:i.transactions.map(({transaction:e,meta:t})=>{let n=new Ho(e.message);return{meta:t,transaction:{...e,message:n}}})};return{...a,transactions:a.transactions.map(({transaction:e,meta:t})=>({meta:t,transaction:Y.populate(e.message,e.signatures)}))}}async getBlocks(e,t,n){let r=this._buildArgsAtLeastConfirmed(t===void 0?[e]:[e,t],n),i=L(await this._rpcRequest(`getBlocks`,r),$(R(B())));if(`error`in i)throw new X(i.error,`failed to get blocks`);return i.result}async getBlockSignatures(e,t){let n=this._buildArgsAtLeastConfirmed([e],t,void 0,{transactionDetails:`signatures`,rewards:!1}),r=L(await this._rpcRequest(`getBlock`,n),vl);if(`error`in r)throw new X(r.error,`failed to get block`);let i=r.result;if(!i)throw Error(`Block `+e+` not found`);return i}async getConfirmedBlockSignatures(e,t){let n=this._buildArgsAtLeastConfirmed([e],t,void 0,{transactionDetails:`signatures`,rewards:!1}),r=L(await this._rpcRequest(`getBlock`,n),vl);if(`error`in r)throw new X(r.error,`failed to get confirmed block`);let i=r.result;if(!i)throw Error(`Confirmed block `+e+` not found`);return i}async getConfirmedTransaction(e,t){let n=this._buildArgsAtLeastConfirmed([e],t),r=L(await this._rpcRequest(`getTransaction`,n),yl);if(`error`in r)throw new X(r.error,`failed to get transaction`);let i=r.result;if(!i)return i;let a=new Ho(i.transaction.message),o=i.transaction.signatures;return{...i,transaction:Y.populate(a,o)}}async getParsedConfirmedTransaction(e,t){let n=this._buildArgsAtLeastConfirmed([e],t,`jsonParsed`),r=L(await this._rpcRequest(`getTransaction`,n),bl);if(`error`in r)throw new X(r.error,`failed to get confirmed transaction`);return r.result}async getParsedConfirmedTransactions(e,t){let n=e.map(e=>({methodName:`getTransaction`,args:this._buildArgsAtLeastConfirmed([e],t,`jsonParsed`)}));return(await this._rpcBatchRequest(n)).map(e=>{let t=L(e,bl);if(`error`in t)throw new X(t.error,`failed to get confirmed transactions`);return t.result})}async getConfirmedSignaturesForAddress(e,t,n){let r={},i=await this.getFirstAvailableBlock();for(;!(`until`in r)&&(t--,!(t<=0||t<i));)try{let e=await this.getConfirmedBlockSignatures(t,`finalized`);e.signatures.length>0&&(r.until=e.signatures[e.signatures.length-1].toString())}catch(e){if(e instanceof Error&&e.message.includes(`skipped`))continue;throw e}let a=await this.getSlot(`finalized`);for(;!(`before`in r)&&(n++,!(n>a));)try{let e=await this.getConfirmedBlockSignatures(n);e.signatures.length>0&&(r.before=e.signatures[e.signatures.length-1].toString())}catch(e){if(e instanceof Error&&e.message.includes(`skipped`))continue;throw e}return(await this.getConfirmedSignaturesForAddress2(e,r)).map(e=>e.signature)}async getConfirmedSignaturesForAddress2(e,t,n){let r=this._buildArgsAtLeastConfirmed([e.toBase58()],n,void 0,t),i=L(await this._rpcRequest(`getConfirmedSignaturesForAddress2`,r),Pc);if(`error`in i)throw new X(i.error,`failed to get confirmed signatures for address`);return i.result}async getSignaturesForAddress(e,t,n){let r=this._buildArgsAtLeastConfirmed([e.toBase58()],n,void 0,t),i=L(await this._rpcRequest(`getSignaturesForAddress`,r),Fc);if(`error`in i)throw new X(i.error,`failed to get signatures for address`);return i.result}async getAddressLookupTable(e,t){let{context:n,value:r}=await this.getAccountInfoAndContext(e,t),i=null;return r!==null&&(i=new Ps({key:e,state:Ps.deserialize(r.data)})),{context:n,value:i}}async getNonceAndContext(e,t){let{context:n,value:r}=await this.getAccountInfoAndContext(e,t),i=null;return r!==null&&(i=fs.fromAccountData(r.data)),{context:n,value:i}}async getNonce(e,t){return await this.getNonceAndContext(e,t).then(e=>e.value).catch(t=>{throw Error(`failed to get nonce for account `+e.toBase58()+`: `+t)})}async requestAirdrop(e,t){let n=L(await this._rpcRequest(`requestAirdrop`,[e.toBase58(),t]),Tl);if(`error`in n)throw new X(n.error,`airdrop to ${e.toBase58()} failed`);return n.result}async _blockhashWithExpiryBlockHeight(e){if(!e){for(;this._pollingBlockhash;)await cs(100);let e=Date.now()-this._blockhashInfo.lastFetch>=Vs;if(this._blockhashInfo.latestBlockhash!==null&&!e)return this._blockhashInfo.latestBlockhash}return await this._pollNewBlockhash()}async _pollNewBlockhash(){this._pollingBlockhash=!0;try{let e=Date.now(),t=this._blockhashInfo.latestBlockhash,n=t?t.blockhash:null;for(let e=0;e<50;e++){let e=await this.getLatestBlockhash(`finalized`);if(n!==e.blockhash)return this._blockhashInfo={latestBlockhash:e,lastFetch:Date.now(),transactionSignatures:[],simulatedSignatures:[]},e;await cs(Yo/2)}throw Error(`Unable to obtain a new blockhash after ${Date.now()-e}ms`)}finally{this._pollingBlockhash=!1}}async getStakeMinimumDelegation(e){let{commitment:t,config:n}=Us(e),r=this._buildArgs([],t,`base64`,n),i=L(await this._rpcRequest(`getStakeMinimumDelegation`,r),qs(B()));if(`error`in i)throw new X(i.error,`failed to get stake minimum delegation`);return i.result}async simulateTransaction(e,t,n){if(`message`in e){let r=e.serialize(),i=F.Buffer.from(r).toString(`base64`);if(Array.isArray(t)||n!==void 0)throw Error(`Invalid arguments`);let a=t||{};a.encoding=`base64`,`commitment`in a||(a.commitment=this.commitment),t&&typeof t==`object`&&`innerInstructions`in t&&(a.innerInstructions=t.innerInstructions);let o=[i,a],s=L(await this._rpcRequest(`simulateTransaction`,o),lc);if(`error`in s)throw Error(`failed to simulate transaction: `+s.error.message);return s.result}let r;if(e instanceof Y){let t=e;r=new Y,r.feePayer=t.feePayer,r.instructions=e.instructions,r.nonceInfo=t.nonceInfo,r.signatures=t.signatures}else r=Y.populate(e),r._message=r._json=void 0;if(t!==void 0&&!Array.isArray(t))throw Error(`Invalid arguments`);let i=t;if(r.nonceInfo&&i)r.sign(...i);else{let e=this._disableBlockhashCaching;for(;;){let t=await this._blockhashWithExpiryBlockHeight(e);if(r.lastValidBlockHeight=t.lastValidBlockHeight,r.recentBlockhash=t.blockhash,!i)break;if(r.sign(...i),!r.signature)throw Error(`!signature`);let n=r.signature.toString(`base64`);if(!this._blockhashInfo.simulatedSignatures.includes(n)&&!this._blockhashInfo.transactionSignatures.includes(n)){this._blockhashInfo.simulatedSignatures.push(n);break}else e=!0}}let a=r._compile(),o=a.serialize(),s=r._serialize(o).toString(`base64`),c={encoding:`base64`,commitment:this.commitment};n&&(c.accounts={encoding:`base64`,addresses:(Array.isArray(n)?n:a.nonProgramIds()).map(e=>e.toBase58())}),i&&(c.sigVerify=!0),t&&typeof t==`object`&&`innerInstructions`in t&&(c.innerInstructions=t.innerInstructions);let l=[s,c],u=L(await this._rpcRequest(`simulateTransaction`,l),lc);if(`error`in u){let e;if(`data`in u.error&&(e=u.error.data.logs,e&&Array.isArray(e))){let t=`
2
2
  `,n=t+e.join(t);console.error(u.error.message,n)}throw new as({action:`simulate`,signature:``,transactionMessage:u.error.message,logs:e})}return u.result}async sendTransaction(e,t,n){if(`version`in e){if(t&&Array.isArray(t))throw Error(`Invalid arguments`);let n=e.serialize();return await this.sendRawTransaction(n,t)}if(t===void 0||!Array.isArray(t))throw Error(`Invalid arguments`);let r=t;if(e.nonceInfo)e.sign(...r);else{let t=this._disableBlockhashCaching;for(;;){let n=await this._blockhashWithExpiryBlockHeight(t);if(e.lastValidBlockHeight=n.lastValidBlockHeight,e.recentBlockhash=n.blockhash,e.sign(...r),!e.signature)throw Error(`!signature`);let i=e.signature.toString(`base64`);if(this._blockhashInfo.transactionSignatures.includes(i))t=!0;else{this._blockhashInfo.transactionSignatures.push(i);break}}}let i=e.serialize();return await this.sendRawTransaction(i,n)}async sendRawTransaction(e,t){let n=W(e).toString(`base64`);return await this.sendEncodedTransaction(n,t)}async sendEncodedTransaction(e,t){let n={encoding:`base64`},r=t&&t.skipPreflight,i=r===!0?`processed`:t&&t.preflightCommitment||this.commitment;t&&t.maxRetries!=null&&(n.maxRetries=t.maxRetries),t&&t.minContextSlot!=null&&(n.minContextSlot=t.minContextSlot),r&&(n.skipPreflight=r),i&&(n.preflightCommitment=i);let a=[e,n],o=L(await this._rpcRequest(`sendTransaction`,a),El);if(`error`in o){let e;throw`data`in o.error&&(e=o.error.data.logs),new as({action:r?`send`:`simulate`,signature:``,transactionMessage:o.error.message,logs:e})}return o.result}_wsOnOpen(){this._rpcWebSocketConnected=!0,this._rpcWebSocketHeartbeat=setInterval(()=>{(async()=>{try{await this._rpcWebSocket.notify(`ping`)}catch{}})()},5e3),this._updateSubscriptions()}_wsOnError(e){this._rpcWebSocketConnected=!1,console.error(`ws error:`,e.message)}_wsOnClose(e){if(this._rpcWebSocketConnected=!1,this._rpcWebSocketGeneration=(this._rpcWebSocketGeneration+1)%(2**53-1),this._rpcWebSocketIdleTimeout&&=(clearTimeout(this._rpcWebSocketIdleTimeout),null),this._rpcWebSocketHeartbeat&&=(clearInterval(this._rpcWebSocketHeartbeat),null),e===1e3){this._updateSubscriptions();return}this._subscriptionCallbacksByServerSubscriptionId={},Object.entries(this._subscriptionsByHash).forEach(([e,t])=>{this._setSubscription(e,{...t,state:`pending`})})}_setSubscription(e,t){let n=this._subscriptionsByHash[e]?.state;if(this._subscriptionsByHash[e]=t,n!==t.state){let n=this._subscriptionStateChangeCallbacksByHash[e];n&&n.forEach(e=>{try{e(t.state)}catch{}})}}_onSubscriptionStateChange(e,t){let n=this._subscriptionHashByClientSubscriptionId[e];if(n==null)return()=>{};let r=this._subscriptionStateChangeCallbacksByHash[n]||=new Set;return r.add(t),()=>{r.delete(t),r.size===0&&delete this._subscriptionStateChangeCallbacksByHash[n]}}async _updateSubscriptions(){if(Object.keys(this._subscriptionsByHash).length===0){this._rpcWebSocketConnected&&(this._rpcWebSocketConnected=!1,this._rpcWebSocketIdleTimeout=setTimeout(()=>{this._rpcWebSocketIdleTimeout=null;try{this._rpcWebSocket.close()}catch(e){e instanceof Error&&console.log(`Error when closing socket connection: ${e.message}`)}},500));return}if(this._rpcWebSocketIdleTimeout!==null&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketConnected=!0),!this._rpcWebSocketConnected){this._rpcWebSocket.connect();return}let e=this._rpcWebSocketGeneration,t=()=>e===this._rpcWebSocketGeneration;await Promise.all(Object.keys(this._subscriptionsByHash).map(async e=>{let n=this._subscriptionsByHash[e];if(n!==void 0)switch(n.state){case`pending`:case`unsubscribed`:if(n.callbacks.size===0){delete this._subscriptionsByHash[e],n.state===`unsubscribed`&&delete this._subscriptionCallbacksByServerSubscriptionId[n.serverSubscriptionId],await this._updateSubscriptions();return}await(async()=>{let{args:r,method:i}=n;try{this._setSubscription(e,{...n,state:`subscribing`});let t=await this._rpcWebSocket.call(i,r);this._setSubscription(e,{...n,serverSubscriptionId:t,state:`subscribed`}),this._subscriptionCallbacksByServerSubscriptionId[t]=n.callbacks,await this._updateSubscriptions()}catch(a){if(console.error(`Received ${a instanceof Error?``:`JSON-RPC `}error calling \`${i}\``,{args:r,error:a}),!t())return;this._setSubscription(e,{...n,state:`pending`}),await this._updateSubscriptions()}})();break;case`subscribed`:n.callbacks.size===0&&await(async()=>{let{serverSubscriptionId:r,unsubscribeMethod:i}=n;if(this._subscriptionsAutoDisposedByRpc.has(r))this._subscriptionsAutoDisposedByRpc.delete(r);else{this._setSubscription(e,{...n,state:`unsubscribing`}),this._setSubscription(e,{...n,state:`unsubscribing`});try{await this._rpcWebSocket.call(i,[r])}catch(r){if(r instanceof Error&&console.error(`${i} error:`,r.message),!t())return;this._setSubscription(e,{...n,state:`subscribed`}),await this._updateSubscriptions();return}}this._setSubscription(e,{...n,state:`unsubscribed`}),await this._updateSubscriptions()})();break}}))}_handleServerNotification(e,t){let n=this._subscriptionCallbacksByServerSubscriptionId[e];n!==void 0&&n.forEach(e=>{try{e(...t)}catch(e){console.error(e)}})}_wsOnAccountNotification(e){let{result:t,subscription:n}=L(e,Ic);this._handleServerNotification(n,[t.value,t.context])}_makeSubscription(e,t){let n=this._nextClientSubscriptionId++,r=Ts([e.method,t]),i=this._subscriptionsByHash[r];return i===void 0?this._subscriptionsByHash[r]={...e,args:t,callbacks:new Set([e.callback]),state:`pending`}:i.callbacks.add(e.callback),this._subscriptionHashByClientSubscriptionId[n]=r,this._subscriptionDisposeFunctionsByClientSubscriptionId[n]=async()=>{delete this._subscriptionDisposeFunctionsByClientSubscriptionId[n],delete this._subscriptionHashByClientSubscriptionId[n];let t=this._subscriptionsByHash[r];q(t!==void 0,`Could not find a \`Subscription\` when tearing down client subscription #${n}`),t.callbacks.delete(e.callback),await this._updateSubscriptions()},this._updateSubscriptions(),n}onAccountChange(e,t,n){let{commitment:r,config:i}=Us(n),a=this._buildArgs([e.toBase58()],r||this._commitment||`finalized`,`base64`,i);return this._makeSubscription({callback:t,method:`accountSubscribe`,unsubscribeMethod:`accountUnsubscribe`},a)}async removeAccountChangeListener(e){await this._unsubscribeClientSubscription(e,`account change`)}_wsOnProgramAccountNotification(e){let{result:t,subscription:n}=L(e,Rc);this._handleServerNotification(n,[{accountId:t.value.pubkey,accountInfo:t.value.account},t.context])}onProgramAccountChange(e,t,n,r){let{commitment:i,config:a}=Us(n),o=this._buildArgs([e.toBase58()],i||this._commitment||`finalized`,`base64`,a||(r?{filters:Ws(r)}:void 0));return this._makeSubscription({callback:t,method:`programSubscribe`,unsubscribeMethod:`programUnsubscribe`},o)}async removeProgramAccountChangeListener(e){await this._unsubscribeClientSubscription(e,`program account change`)}onLogs(e,t,n){let r=this._buildArgs([typeof e==`object`?{mentions:[e.toString()]}:e],n||this._commitment||`finalized`);return this._makeSubscription({callback:t,method:`logsSubscribe`,unsubscribeMethod:`logsUnsubscribe`},r)}async removeOnLogsListener(e){await this._unsubscribeClientSubscription(e,`logs`)}_wsOnLogsNotification(e){let{result:t,subscription:n}=L(e,Dl);this._handleServerNotification(n,[t.value,t.context])}_wsOnSlotNotification(e){let{result:t,subscription:n}=L(e,Bc);this._handleServerNotification(n,[t])}onSlotChange(e){return this._makeSubscription({callback:e,method:`slotSubscribe`,unsubscribeMethod:`slotUnsubscribe`},[])}async removeSlotChangeListener(e){await this._unsubscribeClientSubscription(e,`slot change`)}_wsOnSlotUpdatesNotification(e){let{result:t,subscription:n}=L(e,Hc);this._handleServerNotification(n,[t])}onSlotUpdate(e){return this._makeSubscription({callback:e,method:`slotsUpdatesSubscribe`,unsubscribeMethod:`slotsUpdatesUnsubscribe`},[])}async removeSlotUpdateListener(e){await this._unsubscribeClientSubscription(e,`slot update`)}async _unsubscribeClientSubscription(e,t){let n=this._subscriptionDisposeFunctionsByClientSubscriptionId[e];n?await n():console.warn(`Ignored unsubscribe request because an active subscription with id \`${e}\` for '${t}' events could not be found.`)}_buildArgs(e,t,n,r){let i=t||this._commitment;if(i||n||r){let t={};n&&(t.encoding=n),i&&(t.commitment=i),r&&(t=Object.assign(t,r)),e.push(t)}return e}_buildArgsAtLeastConfirmed(e,t,n,r){let i=t||this._commitment;if(i&&![`confirmed`,`finalized`].includes(i))throw Error("Using Connection with default commitment: `"+this._commitment+"`, but method requires at least `confirmed`");return this._buildArgs(e,t,n,r)}_wsOnSignatureNotification(e){let{result:t,subscription:n}=L(e,Uc);t.value!==`receivedSignature`&&this._subscriptionsAutoDisposedByRpc.add(n),this._handleServerNotification(n,t.value===`receivedSignature`?[{type:`received`},t.context]:[{type:`status`,result:t.value},t.context])}onSignature(e,t,n){let r=this._buildArgs([e],n||this._commitment||`finalized`),i=this._makeSubscription({callback:(e,n)=>{if(e.type===`status`){t(e.result,n);try{this.removeSignatureListener(i)}catch{}}},method:`signatureSubscribe`,unsubscribeMethod:`signatureUnsubscribe`},r);return i}onSignatureWithOptions(e,t,n){let{commitment:r,...i}={...n,commitment:n&&n.commitment||this._commitment||`finalized`},a=this._buildArgs([e],r,void 0,i),o=this._makeSubscription({callback:(e,n)=>{t(e,n);try{this.removeSignatureListener(o)}catch{}},method:`signatureSubscribe`,unsubscribeMethod:`signatureUnsubscribe`},a);return o}async removeSignatureListener(e){await this._unsubscribeClientSubscription(e,`signature result`)}_wsOnRootNotification(e){let{result:t,subscription:n}=L(e,Wc);this._handleServerNotification(n,[t])}onRootChange(e){return this._makeSubscription({callback:e,method:`rootSubscribe`,unsubscribeMethod:`rootUnsubscribe`},[])}async removeRootChangeListener(e){await this._unsubscribeClientSubscription(e,`root change`)}},Al=class e{constructor(e){this._keypair=void 0,this._keypair=e??lo()}static generate(){return new e(lo())}static fromSecretKey(t,n){if(t.byteLength!==64)throw Error(`bad secret key size`);let r=t.slice(32,64);if(!n||!n.skipValidation){let e=uo(t.slice(0,32));for(let t=0;t<32;t++)if(r[t]!==e[t])throw Error(`provided secretKey is invalid`)}return new e({publicKey:r,secretKey:t})}static fromSeed(t){let n=uo(t),r=new Uint8Array(64);return r.set(t),r.set(n,32),new e({publicKey:n,secretKey:r})}get publicKey(){return new G(this._keypair.publicKey)}get secretKey(){return new Uint8Array(this._keypair.secretKey)}},jl=Object.freeze({CreateLookupTable:{index:0,layout:I.struct([I.u32(`instruction`),ps(`recentSlot`),I.u8(`bumpSeed`)])},FreezeLookupTable:{index:1,layout:I.struct([I.u32(`instruction`)])},ExtendLookupTable:{index:2,layout:I.struct([I.u32(`instruction`),ps(),I.seq(K(),I.offset(I.u32(),-8),`addresses`)])},DeactivateLookupTable:{index:3,layout:I.struct([I.u32(`instruction`)])},CloseLookupTable:{index:4,layout:I.struct([I.u32(`instruction`)])}}),Ml=class{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);let t=I.u32(`instruction`).decode(e.data),n;for(let[e,r]of Object.entries(jl))if(r.index==t){n=e;break}if(!n)throw Error(`Invalid Instruction. Should be a LookupTable Instruction`);return n}static decodeCreateLookupTable(e){this.checkProgramId(e.programId),this.checkKeysLength(e.keys,4);let{recentSlot:t}=Q(jl.CreateLookupTable,e.data);return{authority:e.keys[1].pubkey,payer:e.keys[2].pubkey,recentSlot:Number(t)}}static decodeExtendLookupTable(e){if(this.checkProgramId(e.programId),e.keys.length<2)throw Error(`invalid instruction; found ${e.keys.length} keys, expected at least 2`);let{addresses:t}=Q(jl.ExtendLookupTable,e.data);return{lookupTable:e.keys[0].pubkey,authority:e.keys[1].pubkey,payer:e.keys.length>2?e.keys[2].pubkey:void 0,addresses:t.map(e=>new G(e))}}static decodeCloseLookupTable(e){return this.checkProgramId(e.programId),this.checkKeysLength(e.keys,3),{lookupTable:e.keys[0].pubkey,authority:e.keys[1].pubkey,recipient:e.keys[2].pubkey}}static decodeFreezeLookupTable(e){return this.checkProgramId(e.programId),this.checkKeysLength(e.keys,2),{lookupTable:e.keys[0].pubkey,authority:e.keys[1].pubkey}}static decodeDeactivateLookupTable(e){return this.checkProgramId(e.programId),this.checkKeysLength(e.keys,2),{lookupTable:e.keys[0].pubkey,authority:e.keys[1].pubkey}}static checkProgramId(e){if(!e.equals(Nl.programId))throw Error(`invalid instruction; programId is not AddressLookupTable Program`)}static checkKeysLength(e,t){if(e.length<t)throw Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}},Nl=class{constructor(){}static createLookupTable(e){let[t,n]=G.findProgramAddressSync([e.authority.toBuffer(),ei().encode(e.recentSlot)],this.programId),r=jl.CreateLookupTable,i=Z(r,{recentSlot:BigInt(e.recentSlot),bumpSeed:n}),a=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1},{pubkey:e.payer,isSigner:!0,isWritable:!0},{pubkey:gs.programId,isSigner:!1,isWritable:!1}];return[new J({programId:this.programId,keys:a,data:i}),t]}static freezeLookupTable(e){let t=jl.FreezeLookupTable,n=Z(t),r=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return new J({programId:this.programId,keys:r,data:n})}static extendLookupTable(e){let t=jl.ExtendLookupTable,n=Z(t,{addresses:e.addresses.map(e=>e.toBytes())}),r=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return e.payer&&r.push({pubkey:e.payer,isSigner:!0,isWritable:!0},{pubkey:gs.programId,isSigner:!1,isWritable:!1}),new J({programId:this.programId,keys:r,data:n})}static deactivateLookupTable(e){let t=jl.DeactivateLookupTable,n=Z(t),r=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return new J({programId:this.programId,keys:r,data:n})}static closeLookupTable(e){let t=jl.CloseLookupTable,n=Z(t),r=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1},{pubkey:e.recipient,isSigner:!1,isWritable:!0}];return new J({programId:this.programId,keys:r,data:n})}};Nl.programId=new G(`AddressLookupTab1e1111111111111111111111111`);var Pl=class{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);let t=I.u8(`instruction`).decode(e.data),n;for(let[e,r]of Object.entries(Fl))if(r.index==t){n=e;break}if(!n)throw Error(`Instruction type incorrect; not a ComputeBudgetInstruction`);return n}static decodeRequestUnits(e){this.checkProgramId(e.programId);let{units:t,additionalFee:n}=Q(Fl.RequestUnits,e.data);return{units:t,additionalFee:n}}static decodeRequestHeapFrame(e){this.checkProgramId(e.programId);let{bytes:t}=Q(Fl.RequestHeapFrame,e.data);return{bytes:t}}static decodeSetComputeUnitLimit(e){this.checkProgramId(e.programId);let{units:t}=Q(Fl.SetComputeUnitLimit,e.data);return{units:t}}static decodeSetComputeUnitPrice(e){this.checkProgramId(e.programId);let{microLamports:t}=Q(Fl.SetComputeUnitPrice,e.data);return{microLamports:t}}static checkProgramId(e){if(!e.equals(Il.programId))throw Error(`invalid instruction; programId is not ComputeBudgetProgram`)}},Fl=Object.freeze({RequestUnits:{index:0,layout:I.struct([I.u8(`instruction`),I.u32(`units`),I.u32(`additionalFee`)])},RequestHeapFrame:{index:1,layout:I.struct([I.u8(`instruction`),I.u32(`bytes`)])},SetComputeUnitLimit:{index:2,layout:I.struct([I.u8(`instruction`),I.u32(`units`)])},SetComputeUnitPrice:{index:3,layout:I.struct([I.u8(`instruction`),ps(`microLamports`)])}}),Il=class{constructor(){}static requestUnits(e){let t=Fl.RequestUnits,n=Z(t,e);return new J({keys:[],programId:this.programId,data:n})}static requestHeapFrame(e){let t=Fl.RequestHeapFrame,n=Z(t,e);return new J({keys:[],programId:this.programId,data:n})}static setComputeUnitLimit(e){let t=Fl.SetComputeUnitLimit,n=Z(t,e);return new J({keys:[],programId:this.programId,data:n})}static setComputeUnitPrice(e){let t=Fl.SetComputeUnitPrice,n=Z(t,{microLamports:BigInt(e.microLamports)});return new J({keys:[],programId:this.programId,data:n})}};Il.programId=new G(`ComputeBudget111111111111111111111111111111`);var Ll=64,Rl=32,zl=64,Bl=I.struct([I.u8(`numSignatures`),I.u8(`padding`),I.u16(`signatureOffset`),I.u16(`signatureInstructionIndex`),I.u16(`publicKeyOffset`),I.u16(`publicKeyInstructionIndex`),I.u16(`messageDataOffset`),I.u16(`messageDataSize`),I.u16(`messageInstructionIndex`)]),Vl=class e{constructor(){}static createInstructionWithPublicKey(t){let{publicKey:n,message:r,signature:i,instructionIndex:a}=t;q(n.length===Rl,`Public Key must be ${Rl} bytes but received ${n.length} bytes`),q(i.length===zl,`Signature must be ${zl} bytes but received ${i.length} bytes`);let o=Bl.span,s=o+n.length,c=s+i.length,l=F.Buffer.alloc(c+r.length),u=a??65535;return Bl.encode({numSignatures:1,padding:0,signatureOffset:s,signatureInstructionIndex:u,publicKeyOffset:o,publicKeyInstructionIndex:u,messageDataOffset:c,messageDataSize:r.length,messageInstructionIndex:u},l),l.fill(n,o),l.fill(i,s),l.fill(r,c),new J({keys:[],programId:e.programId,data:l})}static createInstructionWithPrivateKey(e){let{privateKey:t,message:n,instructionIndex:r}=e;q(t.length===Ll,`Private key must be ${Ll} bytes but received ${t.length} bytes`);try{let e=Al.fromSecretKey(t),i=e.publicKey.toBytes(),a=po(n,e.secretKey);return this.createInstructionWithPublicKey({publicKey:i,message:n,signature:a,instructionIndex:r})}catch(e){throw Error(`Error creating instruction; ${e}`)}}};Vl.programId=new G(`Ed25519SigVerify111111111111111111111111111`);var Hl=(e,t)=>{let n=oo.sign(e,t);return[n.toCompactRawBytes(),n.recovery]};oo.utils.isValidPrivateKey;var Ul=oo.getPublicKey,Wl=32,Gl=20,Kl=64,ql=I.struct([I.u8(`numSignatures`),I.u16(`signatureOffset`),I.u8(`signatureInstructionIndex`),I.u16(`ethAddressOffset`),I.u8(`ethAddressInstructionIndex`),I.u16(`messageDataOffset`),I.u16(`messageDataSize`),I.u8(`messageInstructionIndex`),I.blob(20,`ethAddress`),I.blob(64,`signature`),I.u8(`recoveryId`)]),Jl=class e{constructor(){}static publicKeyToEthAddress(e){q(e.length===Kl,`Public key must be ${Kl} bytes but received ${e.length} bytes`);try{return F.Buffer.from(Le(W(e))).slice(-20)}catch(e){throw Error(`Error constructing Ethereum address: ${e}`)}}static createInstructionWithPublicKey(t){let{publicKey:n,message:r,signature:i,recoveryId:a,instructionIndex:o}=t;return e.createInstructionWithEthAddress({ethAddress:e.publicKeyToEthAddress(n),message:r,signature:i,recoveryId:a,instructionIndex:o})}static createInstructionWithEthAddress(t){let{ethAddress:n,message:r,signature:i,recoveryId:a,instructionIndex:o=0}=t,s;s=typeof n==`string`?n.startsWith(`0x`)?F.Buffer.from(n.substr(2),`hex`):F.Buffer.from(n,`hex`):n,q(s.length===Gl,`Address must be ${Gl} bytes but received ${s.length} bytes`);let c=12+s.length,l=c+i.length+1,u=F.Buffer.alloc(ql.span+r.length);return ql.encode({numSignatures:1,signatureOffset:c,signatureInstructionIndex:o,ethAddressOffset:12,ethAddressInstructionIndex:o,messageDataOffset:l,messageDataSize:r.length,messageInstructionIndex:o,signature:W(i),ethAddress:W(s),recoveryId:a},u),u.fill(W(r),ql.span),new J({keys:[],programId:e.programId,data:u})}static createInstructionWithPrivateKey(e){let{privateKey:t,message:n,instructionIndex:r}=e;q(t.length===Wl,`Private key must be ${Wl} bytes but received ${t.length} bytes`);try{let e=W(t),i=Ul(e,!1).slice(1),[a,o]=Hl(F.Buffer.from(Le(W(n))),e);return this.createInstructionWithPublicKey({publicKey:i,message:n,signature:a,recoveryId:o,instructionIndex:r})}catch(e){throw Error(`Error creating instruction; ${e}`)}}};Jl.programId=new G(`KeccakSecp256k11111111111111111111111111111`);var Yl,Xl=new G(`StakeConfig11111111111111111111111111111111`),Zl=class{constructor(e,t){this.staker=void 0,this.withdrawer=void 0,this.staker=e,this.withdrawer=t}},Ql=class{constructor(e,t,n){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=e,this.epoch=t,this.custodian=n}};Yl=Ql,Ql.default=new Yl(0,0,G.default);var $l=class{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);let t=I.u32(`instruction`).decode(e.data),n;for(let[e,r]of Object.entries(eu))if(r.index==t){n=e;break}if(!n)throw Error(`Instruction type incorrect; not a StakeInstruction`);return n}static decodeInitialize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);let{authorized:t,lockup:n}=Q(eu.Initialize,e.data);return{stakePubkey:e.keys[0].pubkey,authorized:new Zl(new G(t.staker),new G(t.withdrawer)),lockup:new Ql(n.unixTimestamp,n.epoch,new G(n.custodian))}}static decodeDelegate(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,6),Q(eu.Delegate,e.data),{stakePubkey:e.keys[0].pubkey,votePubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[5].pubkey}}static decodeAuthorize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);let{newAuthorized:t,stakeAuthorizationType:n}=Q(eu.Authorize,e.data),r={stakePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey,newAuthorizedPubkey:new G(t),stakeAuthorizationType:{index:n}};return e.keys.length>3&&(r.custodianPubkey=e.keys[3].pubkey),r}static decodeAuthorizeWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);let{newAuthorized:t,stakeAuthorizationType:n,authoritySeed:r,authorityOwner:i}=Q(eu.AuthorizeWithSeed,e.data),a={stakePubkey:e.keys[0].pubkey,authorityBase:e.keys[1].pubkey,authoritySeed:r,authorityOwner:new G(i),newAuthorizedPubkey:new G(t),stakeAuthorizationType:{index:n}};return e.keys.length>3&&(a.custodianPubkey=e.keys[3].pubkey),a}static decodeSplit(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);let{lamports:t}=Q(eu.Split,e.data);return{stakePubkey:e.keys[0].pubkey,splitStakePubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[2].pubkey,lamports:t}}static decodeMerge(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3),Q(eu.Merge,e.data),{stakePubkey:e.keys[0].pubkey,sourceStakePubKey:e.keys[1].pubkey,authorizedPubkey:e.keys[4].pubkey}}static decodeWithdraw(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,5);let{lamports:t}=Q(eu.Withdraw,e.data),n={stakePubkey:e.keys[0].pubkey,toPubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[4].pubkey,lamports:t};return e.keys.length>5&&(n.custodianPubkey=e.keys[5].pubkey),n}static decodeDeactivate(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3),Q(eu.Deactivate,e.data),{stakePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey}}static checkProgramId(e){if(!e.equals(nu.programId))throw Error(`invalid instruction; programId is not StakeProgram`)}static checkKeyLength(e,t){if(e.length<t)throw Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}},eu=Object.freeze({Initialize:{index:0,layout:I.struct([I.u32(`instruction`),jo(),Mo()])},Authorize:{index:1,layout:I.struct([I.u32(`instruction`),K(`newAuthorized`),I.u32(`stakeAuthorizationType`)])},Delegate:{index:2,layout:I.struct([I.u32(`instruction`)])},Split:{index:3,layout:I.struct([I.u32(`instruction`),I.ns64(`lamports`)])},Withdraw:{index:4,layout:I.struct([I.u32(`instruction`),I.ns64(`lamports`)])},Deactivate:{index:5,layout:I.struct([I.u32(`instruction`)])},Merge:{index:7,layout:I.struct([I.u32(`instruction`)])},AuthorizeWithSeed:{index:8,layout:I.struct([I.u32(`instruction`),K(`newAuthorized`),I.u32(`stakeAuthorizationType`),Ao(`authoritySeed`),K(`authorityOwner`)])}}),tu=Object.freeze({Staker:{index:0},Withdrawer:{index:1}}),nu=class{constructor(){}static initialize(e){let{stakePubkey:t,authorized:n,lockup:r}=e,i=r||Ql.default,a=eu.Initialize,o=Z(a,{authorized:{staker:W(n.staker.toBuffer()),withdrawer:W(n.withdrawer.toBuffer())},lockup:{unixTimestamp:i.unixTimestamp,epoch:i.epoch,custodian:W(i.custodian.toBuffer())}});return new J({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:es,isSigner:!1,isWritable:!1}],programId:this.programId,data:o})}static createAccountWithSeed(e){let t=new Y;t.add(gs.createAccountWithSeed({fromPubkey:e.fromPubkey,newAccountPubkey:e.stakePubkey,basePubkey:e.basePubkey,seed:e.seed,lamports:e.lamports,space:this.space,programId:this.programId}));let{stakePubkey:n,authorized:r,lockup:i}=e;return t.add(this.initialize({stakePubkey:n,authorized:r,lockup:i}))}static createAccount(e){let t=new Y;t.add(gs.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.stakePubkey,lamports:e.lamports,space:this.space,programId:this.programId}));let{stakePubkey:n,authorized:r,lockup:i}=e;return t.add(this.initialize({stakePubkey:n,authorized:r,lockup:i}))}static delegate(e){let{stakePubkey:t,authorizedPubkey:n,votePubkey:r}=e,i=eu.Delegate,a=Z(i);return new Y().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!1},{pubkey:Xo,isSigner:!1,isWritable:!1},{pubkey:is,isSigner:!1,isWritable:!1},{pubkey:Xl,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:a})}static authorize(e){let{stakePubkey:t,authorizedPubkey:n,newAuthorizedPubkey:r,stakeAuthorizationType:i,custodianPubkey:a}=e,o=eu.Authorize,s=Z(o,{newAuthorized:W(r.toBuffer()),stakeAuthorizationType:i.index}),c=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:Xo,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}];return a&&c.push({pubkey:a,isSigner:!0,isWritable:!1}),new Y().add({keys:c,programId:this.programId,data:s})}static authorizeWithSeed(e){let{stakePubkey:t,authorityBase:n,authoritySeed:r,authorityOwner:i,newAuthorizedPubkey:a,stakeAuthorizationType:o,custodianPubkey:s}=e,c=eu.AuthorizeWithSeed,l=Z(c,{newAuthorized:W(a.toBuffer()),stakeAuthorizationType:o.index,authoritySeed:r,authorityOwner:W(i.toBuffer())}),u=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1},{pubkey:Xo,isSigner:!1,isWritable:!1}];return s&&u.push({pubkey:s,isSigner:!0,isWritable:!1}),new Y().add({keys:u,programId:this.programId,data:l})}static splitInstruction(e){let{stakePubkey:t,authorizedPubkey:n,splitStakePubkey:r,lamports:i}=e,a=eu.Split,o=Z(a,{lamports:i});return new J({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:o})}static split(e,t){let n=new Y;return n.add(gs.createAccount({fromPubkey:e.authorizedPubkey,newAccountPubkey:e.splitStakePubkey,lamports:t,space:this.space,programId:this.programId})),n.add(this.splitInstruction(e))}static splitWithSeed(e,t){let{stakePubkey:n,authorizedPubkey:r,splitStakePubkey:i,basePubkey:a,seed:o,lamports:s}=e,c=new Y;return c.add(gs.allocate({accountPubkey:i,basePubkey:a,seed:o,space:this.space,programId:this.programId})),t&&t>0&&c.add(gs.transfer({fromPubkey:e.authorizedPubkey,toPubkey:i,lamports:t})),c.add(this.splitInstruction({stakePubkey:n,authorizedPubkey:r,splitStakePubkey:i,lamports:s}))}static merge(e){let{stakePubkey:t,sourceStakePubKey:n,authorizedPubkey:r}=e,i=eu.Merge,a=Z(i);return new Y().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!0},{pubkey:Xo,isSigner:!1,isWritable:!1},{pubkey:is,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:a})}static withdraw(e){let{stakePubkey:t,authorizedPubkey:n,toPubkey:r,lamports:i,custodianPubkey:a}=e,o=eu.Withdraw,s=Z(o,{lamports:i}),c=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:Xo,isSigner:!1,isWritable:!1},{pubkey:is,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return a&&c.push({pubkey:a,isSigner:!0,isWritable:!1}),new Y().add({keys:c,programId:this.programId,data:s})}static deactivate(e){let{stakePubkey:t,authorizedPubkey:n}=e,r=eu.Deactivate,i=Z(r);return new Y().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:Xo,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:i})}};nu.programId=new G(`Stake11111111111111111111111111111111111111`),nu.space=200;var ru=class{constructor(e,t,n,r){this.nodePubkey=void 0,this.authorizedVoter=void 0,this.authorizedWithdrawer=void 0,this.commission=void 0,this.nodePubkey=e,this.authorizedVoter=t,this.authorizedWithdrawer=n,this.commission=r}},iu=class{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);let t=I.u32(`instruction`).decode(e.data),n;for(let[e,r]of Object.entries(au))if(r.index==t){n=e;break}if(!n)throw Error(`Instruction type incorrect; not a VoteInstruction`);return n}static decodeInitializeAccount(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,4);let{voteInit:t}=Q(au.InitializeAccount,e.data);return{votePubkey:e.keys[0].pubkey,nodePubkey:e.keys[3].pubkey,voteInit:new ru(new G(t.nodePubkey),new G(t.authorizedVoter),new G(t.authorizedWithdrawer),t.commission)}}static decodeAuthorize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);let{newAuthorized:t,voteAuthorizationType:n}=Q(au.Authorize,e.data);return{votePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey,newAuthorizedPubkey:new G(t),voteAuthorizationType:{index:n}}}static decodeAuthorizeWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);let{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:t,currentAuthorityDerivedKeySeed:n,newAuthorized:r,voteAuthorizationType:i}}=Q(au.AuthorizeWithSeed,e.data);return{currentAuthorityDerivedKeyBasePubkey:e.keys[2].pubkey,currentAuthorityDerivedKeyOwnerPubkey:new G(t),currentAuthorityDerivedKeySeed:n,newAuthorizedPubkey:new G(r),voteAuthorizationType:{index:i},votePubkey:e.keys[0].pubkey}}static decodeWithdraw(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);let{lamports:t}=Q(au.Withdraw,e.data);return{votePubkey:e.keys[0].pubkey,authorizedWithdrawerPubkey:e.keys[2].pubkey,lamports:t,toPubkey:e.keys[1].pubkey}}static checkProgramId(e){if(!e.equals(su.programId))throw Error(`invalid instruction; programId is not VoteProgram`)}static checkKeyLength(e,t){if(e.length<t)throw Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}},au=Object.freeze({InitializeAccount:{index:0,layout:I.struct([I.u32(`instruction`),No()])},Authorize:{index:1,layout:I.struct([I.u32(`instruction`),K(`newAuthorized`),I.u32(`voteAuthorizationType`)])},Withdraw:{index:3,layout:I.struct([I.u32(`instruction`),I.ns64(`lamports`)])},UpdateValidatorIdentity:{index:4,layout:I.struct([I.u32(`instruction`)])},AuthorizeWithSeed:{index:10,layout:I.struct([I.u32(`instruction`),Po()])}}),ou=Object.freeze({Voter:{index:0},Withdrawer:{index:1}}),su=class e{constructor(){}static initializeAccount(e){let{votePubkey:t,nodePubkey:n,voteInit:r}=e,i=au.InitializeAccount,a=Z(i,{voteInit:{nodePubkey:W(r.nodePubkey.toBuffer()),authorizedVoter:W(r.authorizedVoter.toBuffer()),authorizedWithdrawer:W(r.authorizedWithdrawer.toBuffer()),commission:r.commission}});return new J({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:es,isSigner:!1,isWritable:!1},{pubkey:Xo,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:a})}static createAccount(e){let t=new Y;return t.add(gs.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.votePubkey,lamports:e.lamports,space:this.space,programId:this.programId})),t.add(this.initializeAccount({votePubkey:e.votePubkey,nodePubkey:e.voteInit.nodePubkey,voteInit:e.voteInit}))}static authorize(e){let{votePubkey:t,authorizedPubkey:n,newAuthorizedPubkey:r,voteAuthorizationType:i}=e,a=au.Authorize,o=Z(a,{newAuthorized:W(r.toBuffer()),voteAuthorizationType:i.index}),s=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:Xo,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return new Y().add({keys:s,programId:this.programId,data:o})}static authorizeWithSeed(e){let{currentAuthorityDerivedKeyBasePubkey:t,currentAuthorityDerivedKeyOwnerPubkey:n,currentAuthorityDerivedKeySeed:r,newAuthorizedPubkey:i,voteAuthorizationType:a,votePubkey:o}=e,s=au.AuthorizeWithSeed,c=Z(s,{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:W(n.toBuffer()),currentAuthorityDerivedKeySeed:r,newAuthorized:W(i.toBuffer()),voteAuthorizationType:a.index}}),l=[{pubkey:o,isSigner:!1,isWritable:!0},{pubkey:Xo,isSigner:!1,isWritable:!1},{pubkey:t,isSigner:!0,isWritable:!1}];return new Y().add({keys:l,programId:this.programId,data:c})}static withdraw(e){let{votePubkey:t,authorizedWithdrawerPubkey:n,lamports:r,toPubkey:i}=e,a=au.Withdraw,o=Z(a,{lamports:r}),s=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}];return new Y().add({keys:s,programId:this.programId,data:o})}static safeWithdraw(t,n,r){if(t.lamports>n-r)throw Error(`Withdraw will leave vote account with insufficient funds.`);return e.withdraw(t)}static updateValidatorIdentity(e){let{votePubkey:t,authorizedWithdrawerPubkey:n,nodePubkey:r}=e,i=au.UpdateValidatorIdentity,a=Z(i),o=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return new Y().add({keys:o,programId:this.programId,data:a})}};su.programId=new G(`Vote111111111111111111111111111111111111111`),su.space=3762;var cu=new G(`Va1idator1nfo111111111111111111111111111111`),lu=U({name:H(),website:V(H()),details:V(H()),iconUrl:V(H()),keybaseUsername:V(H())}),uu=class e{constructor(e,t){this.key=void 0,this.info=void 0,this.key=e,this.info=t}static fromConfigData(t){let n=[...t];if(Io(n)!==2)return null;let r=[];for(let e=0;e<2;e++){let e=new G(Vo(n,0,32)),t=Bo(n)===1;r.push({publicKey:e,isSigner:t})}if(r[0].publicKey.equals(cu)&&r[1].isSigner){let t=Ao().decode(F.Buffer.from(n)),i=JSON.parse(t);return pi(i,lu),new e(r[1].publicKey,i)}return null}},du=new G(`Vote111111111111111111111111111111111111111`),fu=I.struct([K(`nodePubkey`),K(`authorizedWithdrawer`),I.u8(`commission`),I.nu64(),I.seq(I.struct([I.nu64(`slot`),I.u32(`confirmationCount`)]),I.offset(I.u32(),-8),`votes`),I.u8(`rootSlotValid`),I.nu64(`rootSlot`),I.nu64(),I.seq(I.struct([I.nu64(`epoch`),K(`authorizedVoter`)]),I.offset(I.u32(),-8),`authorizedVoters`),I.struct([I.seq(I.struct([K(`authorizedPubkey`),I.nu64(`epochOfLastAuthorizedSwitch`),I.nu64(`targetEpoch`)]),32,`buf`),I.nu64(`idx`),I.u8(`isEmpty`)],`priorVoters`),I.nu64(),I.seq(I.struct([I.nu64(`epoch`),I.nu64(`credits`),I.nu64(`prevCredits`)]),I.offset(I.u32(),-8),`epochCredits`),I.struct([I.nu64(`slot`),I.nu64(`timestamp`)],`lastTimestamp`)]),pu=class e{constructor(e){this.nodePubkey=void 0,this.authorizedWithdrawer=void 0,this.commission=void 0,this.rootSlot=void 0,this.votes=void 0,this.authorizedVoters=void 0,this.priorVoters=void 0,this.epochCredits=void 0,this.lastTimestamp=void 0,this.nodePubkey=e.nodePubkey,this.authorizedWithdrawer=e.authorizedWithdrawer,this.commission=e.commission,this.rootSlot=e.rootSlot,this.votes=e.votes,this.authorizedVoters=e.authorizedVoters,this.priorVoters=e.priorVoters,this.epochCredits=e.epochCredits,this.lastTimestamp=e.lastTimestamp}static fromAccountData(t){let n=fu.decode(W(t),4),r=n.rootSlot;return n.rootSlotValid||(r=null),new e({nodePubkey:new G(n.nodePubkey),authorizedWithdrawer:new G(n.authorizedWithdrawer),commission:n.commission,votes:n.votes,rootSlot:r,authorizedVoters:n.authorizedVoters.map(mu),priorVoters:gu(n.priorVoters),epochCredits:n.epochCredits,lastTimestamp:n.lastTimestamp})}};function mu({authorizedVoter:e,epoch:t}){return{epoch:t,authorizedVoter:new G(e)}}function hu({authorizedPubkey:e,epochOfLastAuthorizedSwitch:t,targetEpoch:n}){return{authorizedPubkey:new G(e),epochOfLastAuthorizedSwitch:t,targetEpoch:n}}function gu({buf:e,idx:t,isEmpty:n}){return n?[]:[...e.slice(t+1).map(hu),...e.slice(0,t).map(hu)]}var _u={http:{devnet:`http://api.devnet.solana.com`,testnet:`http://api.testnet.solana.com`,"mainnet-beta":`http://api.mainnet-beta.solana.com/`},https:{devnet:`https://api.devnet.solana.com`,testnet:`https://api.testnet.solana.com`,"mainnet-beta":`https://api.mainnet-beta.solana.com/`}};function vu(e,t){let n=t===!1?`http`:`https`;if(!e)return _u[n].devnet;let r=_u[n][e];if(!r)throw Error(`Unknown ${n} cluster: ${e}`);return r}async function yu(e,t,n,r){let i,a;n&&Object.prototype.hasOwnProperty.call(n,`lastValidBlockHeight`)||n&&Object.prototype.hasOwnProperty.call(n,`nonceValue`)?(i=n,a=r):a=n;let o=a&&{skipPreflight:a.skipPreflight,preflightCommitment:a.preflightCommitment||a.commitment,minContextSlot:a.minContextSlot},s=await e.sendRawTransaction(t,o),c=a&&a.commitment,l=(await(i?e.confirmTransaction(i,c):e.confirmTransaction(s,c))).value;if(l.err)throw s==null?Error(`Raw transaction ${s} failed (${JSON.stringify(l)})`):new as({action:o?.skipPreflight?`send`:`simulate`,signature:s,transactionMessage:`Status: (${JSON.stringify(l)})`});return s}var bu=1e9;export{Jo as a,Wo as i,wo as n,so as o,Y as r,G as t};