@fangorn-network/westmarch 2026.10.2-0.0-dev → 2026.10.2-2.0-dev

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 (584) hide show
  1. package/docs/app-to-agent.md +25 -41
  2. package/package.json +6 -5
  3. package/site/dist/assets/AccountNotFoundScreen-C4njXc69-DyVH4CEz.js +1 -0
  4. package/site/dist/assets/AddFundsSelectionScreen-RAoCn7ej-Dz1--SS9.js +31 -0
  5. package/site/dist/assets/Address-H8kD1d9O-BdFZmRwI.js +17 -0
  6. package/site/dist/assets/AffirmativeConsentScreen-BG0MJxku-CxaCAisL.js +6 -0
  7. package/site/dist/assets/AllowlistRejectionScreen-Cae6e1Od-JGk7vndN.js +1 -0
  8. package/site/dist/assets/ApiController-CTLbMCcH.js +5 -0
  9. package/site/dist/assets/ArrowsRightLeftIcon-B8g9adpz.js +1 -0
  10. package/site/dist/assets/AuthenticateWithWalletScreen-CU6hIcFT-CXD9_OP8.js +1 -0
  11. package/site/dist/assets/AwaitingEvmToSolBridgingScreen-D0e_sZMS-BtJCglvU.js +1 -0
  12. package/site/dist/assets/AwaitingExternalEthereumTransferScreen-ur5HL4R7-BgC2TsqH.js +1 -0
  13. package/site/dist/assets/AwaitingPasswordlessCodeScreen-DRHz76mM-B9OzLeEO.js +103 -0
  14. package/site/dist/assets/AwaitingSolToEvmBridgingScreen-CdLRrGD2-C7r5snUL.js +1 -0
  15. package/site/dist/assets/BridgeNetworkSelectionView-CFGjB2nO-BTV0NRio.js +68 -0
  16. package/site/dist/assets/CaptchaScreen-DbpvkIGx-7rSZIuM-.js +1 -0
  17. package/site/dist/assets/CheckCircleIcon-B1l17ioc.js +1 -0
  18. package/site/dist/assets/CheckCircleIcon-BGSI8nKf.js +1 -0
  19. package/site/dist/assets/Checkbox-D1EDeo41-BUfq0w99.js +52 -0
  20. package/site/dist/assets/ChevronDownIcon-B6uJvPHu.js +1 -0
  21. package/site/dist/assets/Chip-CZKIKt9K-r9Nk__0-.js +26 -0
  22. package/site/dist/assets/CoinbaseOnrampStatusScreen-BbyCJDXL-DWWNHxmR.js +16 -0
  23. package/site/dist/assets/ConnectEmailForm-B-VRE0MN-CRQwS0Xu.js +3 -0
  24. package/site/dist/assets/ConnectLedgerScreen-DWHABGot-CZcCt31O.js +10 -0
  25. package/site/dist/assets/ConnectOnlyLandingScreen-CZYx9Bmp-C5IOf-SQ.js +1 -0
  26. package/site/dist/assets/ConnectOnlyStatusScreen-DCRzjxHx-cwg74F3A.js +1 -0
  27. package/site/dist/assets/ConnectOrCreateScreen-CUUYUO07-D28oeK6b.js +1 -0
  28. package/site/dist/assets/ConnectPhoneForm-Dek5xn4C-EEdkKeTp.js +95 -0
  29. package/site/dist/assets/ConnectWalletView-DqI-PTvX-C2mEzukj.js +74 -0
  30. package/site/dist/assets/ConnectionStatusScreen-fUfROm9m-CH_7r8iV.js +7 -0
  31. package/site/dist/assets/ConnectionStatusScreen-fUfROm9m-Z33kis0B.js +1 -0
  32. package/site/dist/assets/ConnectorUtil-DH4NePk5.js +21 -0
  33. package/site/dist/assets/ConstantsUtil-DmLsRHAl.js +198 -0
  34. package/site/dist/assets/CopyToClipboard-i_OQSBJr-_G88JCVR.js +39 -0
  35. package/site/dist/assets/CopyableText-CQapvaMr-CGGfc_zM.js +28 -0
  36. package/site/dist/assets/CrossAppAuthScreen-CLw7ymZq-C9Okoc0V.js +1 -0
  37. package/site/dist/assets/CustomLandingScreenView-Cm_MBSyX-D2l6hdSl.js +22 -0
  38. package/site/dist/assets/DelegatedActionsConsentScreen-DYF2U4y5-Dda3KKqS.js +1 -0
  39. package/site/dist/assets/DelegatedActionsRevokeScreen-bPp6Uwyh-DG8kJPt1.js +1 -0
  40. package/site/dist/assets/DepositAddressAddressStepView-4vdkb55L-CcOUfn6f.js +187 -0
  41. package/site/dist/assets/DepositAddressScreen-DBLRs7aI-DeituDNh.js +8 -0
  42. package/site/dist/assets/DepositAddressV3Screen-CDqIEMQw-FDg6K14-.js +1 -0
  43. package/site/dist/assets/{EmailInputForm-Cqo1mda8-CZD4r5LM.js → EmailInputForm-Cqo1mda8-BmbxvPHC.js} +11 -11
  44. package/site/dist/assets/EmbeddedWalletConnectingScreen-D4T7DUzs-B05CQ9rx.js +1 -0
  45. package/site/dist/assets/EmbeddedWalletCreatedScreen-D7WhW5ve-Cxd1b9XH.js +1 -0
  46. package/site/dist/assets/EmbeddedWalletKeyExportScreen-CqV4NYQ3-CrJy0ViX.js +23 -0
  47. package/site/dist/assets/EmbeddedWalletOnAccountCreateScreen-BoKb3Q2S-Bakaa3zu.js +1 -0
  48. package/site/dist/assets/EmbeddedWalletPasswordUpdateScreen-D3rMlqS7-j78vKrcj.js +1 -0
  49. package/site/dist/assets/EmbeddedWalletPasswordUpdateSplashScreen-BPFkWJeE-D3dr7W9_.js +1 -0
  50. package/site/dist/assets/EnrollTotp-Dibew4dp-BXbYV8nI.js +66 -0
  51. package/site/dist/assets/EnvelopeIcon-DjPofnRI.js +1 -0
  52. package/site/dist/assets/ErrorBanner-BcpGRt0h-BhH6_V-9.js +21 -0
  53. package/site/dist/assets/{ErrorMessage-D8VaAP5m-oSruKN8L.js → ErrorMessage-D8VaAP5m-Bs7uX2a9.js} +2 -2
  54. package/site/dist/assets/ErrorScreen-DipdTWzE-BgPRgnOb.js +4 -0
  55. package/site/dist/assets/ErrorScreen-DipdTWzE-CvxXC6pz.js +1 -0
  56. package/site/dist/assets/ExclamationCircleIcon-BE-WGrut.js +1 -0
  57. package/site/dist/assets/ExclamationTriangleIcon-Ca1Xlc_f.js +1 -0
  58. package/site/dist/assets/FarcasterConnectStatusScreen-51tjUxqq-De2JvZdV.js +75 -0
  59. package/site/dist/assets/FarcasterSignerStatusScreen-6x-Uh95G-bLp3hXoO.js +28 -0
  60. package/site/dist/assets/FiatOnrampScreen-BAhYeiTI-Jr6D6JiZ.js +491 -0
  61. package/site/dist/assets/FingerPrintIcon-DOCbS93y.js +1 -0
  62. package/site/dist/assets/FundSolWalletWithExternalSolanaWallet-WtLwYaOl-A_G5kfa1.js +1 -0
  63. package/site/dist/assets/FundWalletMethodHeader-BWNkokCT-LPv35wkD.js +1 -0
  64. package/site/dist/assets/FundWithBankDepositScreen-DajkHxBD-0hfGrfvf.js +58 -0
  65. package/site/dist/assets/FundingEditAmountScreen-CpvpiO4M-Dz0s_NWR.js +1 -0
  66. package/site/dist/assets/FundingMethodSelectionScreen-Db7vhRlE-ZGm-3-Io.js +1 -0
  67. package/site/dist/assets/GlobeAltIcon-BBRl2MMn.js +1 -0
  68. package/site/dist/assets/GooglePay-B53WnudL-BGiVpB8y.js +1 -0
  69. package/site/dist/assets/HCaptchaWrapper-CUi9LJsp-CHdfIeD_.js +4 -0
  70. package/site/dist/assets/InAppBrowserLoginNotPossible-BMR9br1T-Cgoiow3m.js +1 -0
  71. package/site/dist/assets/InfoBanner-Cb3p1z12-_YqQmRiu.js +22 -0
  72. package/site/dist/assets/InjectedWalletIcon-DLcYOGDj-tuIrKQHH.js +1 -0
  73. package/site/dist/assets/InstallWalletScreen-DTA8dwLv-BMU_wa61.js +1 -0
  74. package/site/dist/assets/{JsonTree-BHzNC-ic-pAEq1bl9.js → JsonTree-BHzNC-ic-DcVr0YF0.js} +3 -3
  75. package/site/dist/assets/{LabelXs-oqZNqbm_-D09YjVR4.js → LabelXs-oqZNqbm_-CNprGVQM.js} +2 -2
  76. package/site/dist/assets/LandingScreen-CGWUoSUG-fH6rsQen.js +1 -0
  77. package/site/dist/assets/{Layouts-BMRfo5hw-D2u1-w8g.js → Layouts-BMRfo5hw-e-sepi6F.js} +16 -16
  78. package/site/dist/assets/Link-BdDilT2T-BdwlRJch.js +40 -0
  79. package/site/dist/assets/LinkConflictScreen-C3ZEPsgl-BXKN2Qm5.js +77 -0
  80. package/site/dist/assets/LinkEmailScreen-dKo9frwc-Cyn7Q8p1.js +1 -0
  81. package/site/dist/assets/LinkPasskeyScreen-zbrl_AI_-CWiqnwLM.js +117 -0
  82. package/site/dist/assets/LinkPasskeyScreen-zbrl_AI_-YmDevJzf.js +1 -0
  83. package/site/dist/assets/LinkPhoneScreen-oIUpfj0w-h7shW-Ay.js +1 -0
  84. package/site/dist/assets/Loader-UAZqxsnw-DJEVblm1.js +62 -0
  85. package/site/dist/assets/{LoadingSkeleton-BMsgO5PV-BRMh4Fv4.js → LoadingSkeleton-BMsgO5PV-D2atjsP5.js} +6 -6
  86. package/site/dist/assets/LockClosedIcon-9EFzWK1C.js +1 -0
  87. package/site/dist/assets/LoginFailedScreen-CN0dJV6U-By3Si77a.js +1 -0
  88. package/site/dist/assets/ManualTransferScreen-CHqcuqbs-BAHPY8rs.js +1 -0
  89. package/site/dist/assets/MfaAuthEnrollmentFlowScreen-Dj7gPTRC-CLjffFG1.js +1 -0
  90. package/site/dist/assets/MfaAuthVerifyFlowScreen-DbFpyWMy-BmQg1Y61.js +1 -0
  91. package/site/dist/assets/MfaEnrollmentFlowScreen-DhLnGgnr-DmBtTtlw.js +1 -0
  92. package/site/dist/assets/MfaVerifyFlowScreen-C_XPjMRP-4a683Bmf.js +1 -0
  93. package/site/dist/assets/ModalFooter-BCuEK_nz-C_71qsaz.js +403 -0
  94. package/site/dist/assets/MoonpayStatusScreen-CzTUtokc-DEHHcEf8.js +16 -0
  95. package/site/dist/assets/OAuthStatusScreen-ufbOa-da-BjAb_WsY.js +1 -0
  96. package/site/dist/assets/OpenLink-CUpJ1mOr-BLWFsPOW.js +39 -0
  97. package/site/dist/assets/PasskeySelectSignupOrLogin-xh2ScC_l-2PJTJxX-.js +1 -0
  98. package/site/dist/assets/PasskeyStatusScreen-Bla8MaOk-DCEg761l.js +6 -0
  99. package/site/dist/assets/PasswordRecoveryScreen-awGXZkQk-8nVjNc8k.js +20 -0
  100. package/site/dist/assets/{PhArrowCircleDown-BtlNV0TZ.js → PhArrowCircleDown-D97G-BOA.js} +5 -5
  101. package/site/dist/assets/PhArrowClockwise-DVgyFuez.js +14 -0
  102. package/site/dist/assets/PhArrowDown-87b1BizM.js +14 -0
  103. package/site/dist/assets/PhArrowLeft-Da0MfnbK.js +14 -0
  104. package/site/dist/assets/PhArrowRight-AdrIL4DW.js +14 -0
  105. package/site/dist/assets/{PhArrowSquareOut-DnQ7n_B4.js → PhArrowSquareOut-Bk2CMG3I.js} +5 -5
  106. package/site/dist/assets/PhArrowUp-4sgyKPGx.js +14 -0
  107. package/site/dist/assets/PhArrowUpRight-BNghD2zq.js +14 -0
  108. package/site/dist/assets/{PhArrowsClockwise-Brtx2Re-.js → PhArrowsClockwise-BXRn1GEl.js} +5 -5
  109. package/site/dist/assets/{PhArrowsDownUp-PZosTqZG.js → PhArrowsDownUp-DM09Jo_3.js} +5 -5
  110. package/site/dist/assets/PhArrowsLeftRight-MuKBLUoF.js +14 -0
  111. package/site/dist/assets/{PhBank-hhPAIPVb.js → PhBank-fHbgCqqZ.js} +5 -5
  112. package/site/dist/assets/PhBrowser-2-9m-AkM.js +14 -0
  113. package/site/dist/assets/PhCaretDown-BDNabFuL.js +14 -0
  114. package/site/dist/assets/PhCaretLeft-CI460R-A.js +14 -0
  115. package/site/dist/assets/PhCaretRight-D7ZS3Ls8.js +14 -0
  116. package/site/dist/assets/PhCaretUp-C-iIfyvO.js +14 -0
  117. package/site/dist/assets/PhCheck-DxQXn57r.js +14 -0
  118. package/site/dist/assets/{PhCircleHalf-Bk9C4DvT.js → PhCircleHalf-MJZeRBGF.js} +5 -5
  119. package/site/dist/assets/PhClock-x3MS3Mwi.js +14 -0
  120. package/site/dist/assets/{PhCompass-Df1ugFO-.js → PhCompass-hYn3HhGN.js} +5 -5
  121. package/site/dist/assets/PhCopy-CWNYcABI.js +14 -0
  122. package/site/dist/assets/{PhCreditCard-CZpdid2n.js → PhCreditCard-Fy4pzwtt.js} +5 -5
  123. package/site/dist/assets/{PhCurrencyDollar-B6IKKjue.js → PhCurrencyDollar-BgiaenCi.js} +5 -5
  124. package/site/dist/assets/{PhDesktop-BuCDXYJj.js → PhDesktop-CxrzCSv5.js} +5 -5
  125. package/site/dist/assets/PhDeviceMobile-CsyA5Goi.js +14 -0
  126. package/site/dist/assets/PhDotsThree-D-k1BiYg.js +14 -0
  127. package/site/dist/assets/PhEnvelope-D8kzeNox.js +14 -0
  128. package/site/dist/assets/PhFunnelSimple-CfQs5DAW.js +14 -0
  129. package/site/dist/assets/{PhGlobe-q1mqj65V.js → PhGlobe-DvmSc9_A.js} +5 -5
  130. package/site/dist/assets/{PhIdentificationCard-BeLXJpfZ.js → PhIdentificationCard-CfkZm-5K.js} +5 -5
  131. package/site/dist/assets/{PhImage-BYrKfN9k.js → PhImage-Cf0J2ZfJ.js} +5 -5
  132. package/site/dist/assets/{PhInfo-X33f06Ej.js → PhInfo-Bwi51-2X.js} +5 -5
  133. package/site/dist/assets/{PhLightbulb-DMZJsowR.js → PhLightbulb-C4FZV7Es.js} +5 -5
  134. package/site/dist/assets/PhMagnifyingGlass-C9u8jSCJ.js +14 -0
  135. package/site/dist/assets/{PhPaperPlaneRight-Dvo-nXr9.js → PhPaperPlaneRight-zxQVvPLX.js} +5 -5
  136. package/site/dist/assets/PhPlus-C4UoW-2n.js +14 -0
  137. package/site/dist/assets/{PhPower-D8-AcNM6.js → PhPower-CFyWDmgD.js} +5 -5
  138. package/site/dist/assets/{PhPuzzlePiece-C-7mYqGO.js → PhPuzzlePiece-BjoNVfST.js} +5 -5
  139. package/site/dist/assets/{PhQrCode-uIXlI5ER.js → PhQrCode-CP3tFauY.js} +5 -5
  140. package/site/dist/assets/{PhQuestion-rUoqC2sC.js → PhQuestion-wOWJBd3G.js} +5 -5
  141. package/site/dist/assets/{PhQuestionMark-W55Txvvb.js → PhQuestionMark-CV0k9C0Y.js} +5 -5
  142. package/site/dist/assets/{PhSealCheck-BeVLq9PH.js → PhSealCheck-vIKzREuN.js} +5 -5
  143. package/site/dist/assets/{PhSignOut-Cq2PivQ6.js → PhSignOut-CxELV-i0.js} +5 -5
  144. package/site/dist/assets/{PhSpinner-CZMtAFdX.js → PhSpinner-CGDmbzUd.js} +5 -5
  145. package/site/dist/assets/{PhTrash-BamrmMsN.js → PhTrash-C9PD0SAt.js} +5 -5
  146. package/site/dist/assets/{PhUser-A2fxqIV0.js → PhUser-0sWNXQeZ.js} +5 -5
  147. package/site/dist/assets/{PhVault-B8m1usHw.js → PhVault-6JTskUcC.js} +5 -5
  148. package/site/dist/assets/{PhWarning-CpkID9oi.js → PhWarning-CoKs3gz6.js} +5 -5
  149. package/site/dist/assets/PhWarningCircle-BXHw1fCt.js +14 -0
  150. package/site/dist/assets/PhX-DX0SFIqC.js +14 -0
  151. package/site/dist/assets/PhoneIcon-CZ47md80.js +1 -0
  152. package/site/dist/assets/PinInput-DbZ0b1i1-BrTXu3Km.js +247 -0
  153. package/site/dist/assets/PrivyPluginContext-DA-yS5vO-CY60yubk.js +1 -0
  154. package/site/dist/assets/QrCode-DbnZwlkH-CcMrWV5D.js +22 -0
  155. package/site/dist/assets/RecoveryOAuthStatusScreen-CsgtTI2x-DgeDnHOK.js +1 -0
  156. package/site/dist/assets/RecoveryPasswordCreateScreen-Be-qJ-LU-CvJJwLhK.js +1 -0
  157. package/site/dist/assets/RecoverySelectionScreen-D1iGtpmi-CADtGtSV.js +7 -0
  158. package/site/dist/assets/SIWXUtil-Cpiv91-M.js +1 -0
  159. package/site/dist/assets/{Screen-D30meWsY-DDum2qlY.js → Screen-D30meWsY-vEusJ7KX.js} +22 -22
  160. package/site/dist/assets/{ScreenHeader-CHmc4-Lu-BqrAEXbV.js → ScreenHeader-CHmc4-Lu-BvGTLg53.js} +4 -4
  161. package/site/dist/assets/ScreenLayout-OwaQQcxH-cfOTmyl0.js +1 -0
  162. package/site/dist/assets/{SelectSourceAsset-CWFog6gm-8iXuqbAs.js → SelectSourceAsset-CWFog6gm-DxYklZYs.js} +18 -18
  163. package/site/dist/assets/SetAutomaticRecoveryScreen-BO_OEqAZ-oeqeo05x.js +14 -0
  164. package/site/dist/assets/SetWalletPasswordForm-DwCTVtAh-BxFee9UA.js +11 -0
  165. package/site/dist/assets/ShieldCheckIcon-eFjsosCA.js +1 -0
  166. package/site/dist/assets/SignRequestScreen-BHKv32KR-z8ixfIma.js +26 -0
  167. package/site/dist/assets/SolanaWalletConnector-C7Lqk-Wz-Bc_lvdiF.js +1 -0
  168. package/site/dist/assets/{StackedContainer-B2vaEl56-C-ojzCoQ.js → StackedContainer-B2vaEl56-Do5dXB8-.js} +2 -2
  169. package/site/dist/assets/StandardSignAndSendTransactionScreen-CfhIXVtd-DudetZAc.js +20 -0
  170. package/site/dist/assets/{Subtitle-CV-2yKE4-o-1FQLlX.js → Subtitle-CV-2yKE4-DV0o1av3.js} +2 -2
  171. package/site/dist/assets/TelegramAuthScreen-UL9zLfO8-Bo3sONvf.js +1 -0
  172. package/site/dist/assets/{Title-BnzYV3Is-RX1f0RV-.js → Title-BnzYV3Is-C3qOPnO_.js} +2 -2
  173. package/site/dist/assets/TodoList-DnyULl18-BvxvubbF.js +36 -0
  174. package/site/dist/assets/TransactionDetails-e9nesl30-WWflkOIi.js +109 -0
  175. package/site/dist/assets/TransactionErrorView-BDBNqA_f-CotYKcgf.js +178 -0
  176. package/site/dist/assets/TransferFromWalletScreen-Qvn1Yuno-sVFlWqa8.js +31 -0
  177. package/site/dist/assets/TransferOrBridgeLoadingScreen-Dl1I_iIz-CV2-mY19.js +6 -0
  178. package/site/dist/assets/TurnstileWrapper-B7sNddys-oPbuMTQt.js +1 -0
  179. package/site/dist/assets/UpdateEmailScreen-DVOhPV0H-D_mjSpAy.js +1 -0
  180. package/site/dist/assets/UpdatePhoneScreen-CXRswTNZ-6RLG0ahv.js +1 -0
  181. package/site/dist/assets/UserLimitReachedScreen-5we2DHn8-CaVN0bti.js +1 -0
  182. package/site/dist/assets/{Value-DTgR824E-DZpvBCWi.js → Value-DTgR824E-Bp6WGZZm.js} +7 -7
  183. package/site/dist/assets/WalletCards-DH1rqayz-D3cOTb9x.js +1 -0
  184. package/site/dist/assets/WalletIcon-DOIZhb2l.js +1 -0
  185. package/site/dist/assets/WalletInfoCard-sq_2wgFg-bOqfl5MA.js +29 -0
  186. package/site/dist/assets/WalletInterstitialScreen-Sh7LfsAh-DWaVkMCA.js +1 -0
  187. package/site/dist/assets/WalletLink-DK5LB5Ha-DjUZvqs-.js +20 -0
  188. package/site/dist/assets/WalletOverflowButton-bfCnp-9T-B6P7DQXA.js +1 -0
  189. package/site/dist/assets/WarningBanner-ZZqCEtZK-Bc2YKZb7.js +21 -0
  190. package/site/dist/assets/__vite-browser-external-NciY4Vu1.js +1 -0
  191. package/site/dist/assets/_esm-BZP3cXTv.js +1 -0
  192. package/site/dist/assets/_esm-ZmzBJpEs.js +6 -0
  193. package/site/dist/assets/accounts-D4AXF17G.js +1 -0
  194. package/site/dist/assets/accounts-IkdFx9nq.js +1 -0
  195. package/site/dist/assets/analytics-mkkvFRju-BRBcadka.js +1 -0
  196. package/site/dist/assets/baseSepolia-Bn1j1Ysw.js +1 -0
  197. package/site/dist/assets/basic-Cz1YiCSk.js +1575 -0
  198. package/site/dist/assets/capitalizeFirstLetter-DmLYqXsO-DtOXx-2n.js +1 -0
  199. package/site/dist/assets/ccip-B1J3oTZx.js +7 -0
  200. package/site/dist/assets/ccip-Bd7261zy.js +1 -0
  201. package/site/dist/assets/ccip-D6EHKpjI.js +1 -0
  202. package/site/dist/assets/chain-scefkYIH.js +5 -0
  203. package/site/dist/assets/check-DHnllI8N.js +1 -0
  204. package/site/dist/assets/chevron-down-1y-r4bGO.js +1 -0
  205. package/site/dist/assets/circle-alert-OwxamXUX.js +1 -0
  206. package/site/dist/assets/circle-check-big-3sZGVC10.js +1 -0
  207. package/site/dist/assets/circle-x-DQjNUV9J.js +1 -0
  208. package/site/dist/assets/client-B-BpRtwY.js +1 -0
  209. package/site/dist/assets/client-BfIR1FvH.js +9 -0
  210. package/site/dist/assets/coinbase-DCPC2L_R-YEuIn3jh.js +3 -0
  211. package/site/dist/assets/copy-DMOX_yn7.js +1 -0
  212. package/site/dist/assets/core-GIEmxmAa.js +12 -0
  213. package/site/dist/assets/createLucideIcon-BsERoFTA.js +1 -0
  214. package/site/dist/assets/defineChain-B-SQDLTG.js +1 -0
  215. package/site/dist/assets/dijkstra-CY95afk4.js +1 -0
  216. package/site/dist/assets/dist-CoS6E-3x.js +1 -0
  217. package/site/dist/assets/dist-Cp6IXeJd.js +1 -0
  218. package/site/dist/assets/dist-CrNxmdZj.js +1 -0
  219. package/site/dist/assets/dist-DYGtf4F0.js +16 -0
  220. package/site/dist/assets/embed.worker-Cnl4VGr3.js +1 -0
  221. package/site/dist/assets/errors-BQ3N-RVt-CZPAWCgC.js +1 -0
  222. package/site/dist/assets/esm-C3DslVJx.js +1 -0
  223. package/site/dist/assets/esm-Ci1ogKuK.js +1 -0
  224. package/site/dist/assets/esm-Co94ENUV.js +37 -0
  225. package/site/dist/assets/esm-bb8SANZh.js +1 -0
  226. package/site/dist/assets/esm-n2lWo7kz.js +1 -0
  227. package/site/dist/assets/ethers-zTjbodk5-Cs648CnD.js +1 -0
  228. package/site/dist/assets/eventemitter3-Dzc_0Uq2.js +1 -0
  229. package/site/dist/assets/external-link-BBPG3rG7.js +1 -0
  230. package/site/dist/assets/farcaster-DPlSjvF5-CzBCmgyL.js +1 -0
  231. package/site/dist/assets/features-CuiHbgEJ.js +2 -0
  232. package/site/dist/assets/fingerprint-pattern-CjLtyIxB.js +1 -0
  233. package/site/dist/assets/floating-ui.react-DmaCfayr.js +1 -0
  234. package/site/dist/assets/floating-ui.react-dom-CaoMF8mP.js +1 -0
  235. package/site/dist/assets/formatErc20TokenAmount-BuPk9xcy-BVqOKQif.js +1 -0
  236. package/site/dist/assets/formatter-CVbp4SlJ.js +1 -0
  237. package/site/dist/assets/get-entropy-details-for-user-dHRH5Gpi-BNiOFXbK.js +1 -0
  238. package/site/dist/assets/getChainName-DjpPdUSc-DUyKDrnp.js +1 -0
  239. package/site/dist/assets/getErc20Balance-jXNpFf0N-q4bV8kQq.js +1 -0
  240. package/site/dist/assets/getErc20TokenInfo-BNTrzLMP-DcnTFrXN.js +1 -0
  241. package/site/dist/assets/getFormattedUsdFromLamports-De3U9GlO-Gx4_wxON.js +1 -0
  242. package/site/dist/assets/getUsdcMintAddress-BVgm9GRo-r2UnDeEy.js +1 -0
  243. package/site/dist/assets/guards-BIW-GiMJ-D3tWTQAR.js +1 -0
  244. package/site/dist/assets/hooks.module-BYZGfwDl.js +1 -0
  245. package/site/dist/assets/hourglass-D_GfQdJr.js +1 -0
  246. package/site/dist/assets/id-UqEwL2BI-CTlvRMA5.js +1 -0
  247. package/site/dist/assets/index-BdEw5wyl-kLbhqLbv.js +1 -0
  248. package/site/dist/assets/index-C2h3EneX.js +8 -0
  249. package/site/dist/assets/{index-CWARkn2w-D6ikWJWj.js → index-CWARkn2w-DxuckIFn.js} +7 -7
  250. package/site/dist/assets/index-DvMddJcd-CNBb4VUn.js +12 -0
  251. package/site/dist/assets/index-YiCw0Y_x-Czl0tWfF.js +436 -0
  252. package/site/dist/assets/index.browser-B-i-Lj3J.js +1 -0
  253. package/site/dist/assets/index.browser-BMmUcykv.js +1 -0
  254. package/site/dist/assets/index.es-Crd0TyUS.js +2 -0
  255. package/site/dist/assets/index.es-DQbup1WG.js +3 -0
  256. package/site/dist/assets/isPaymentRequestAvailable-Bq1cemEn-Cjf3l05I.js +1 -0
  257. package/site/dist/assets/jsx-runtime-CndCZlyt.js +1 -0
  258. package/site/dist/assets/landmark-BZPqMFEf.js +1 -0
  259. package/site/dist/assets/lib-DGtzi2DK.js +1 -0
  260. package/site/dist/assets/localBatchGatewayRequest-B71J8sQ9.js +29 -0
  261. package/site/dist/assets/lock-DyN_c-ud.js +1 -0
  262. package/site/dist/assets/logger-CsXm3oIv-B0UYpNFI.js +1 -0
  263. package/site/dist/assets/mail-V_mcPb64.js +1 -0
  264. package/site/dist/assets/modal-context-CwmSeFcv-DPWNJrfK.js +1 -0
  265. package/site/dist/assets/native-BKj27wfc.js +1 -0
  266. package/site/dist/assets/ofetch.CWycOUEr-Duby3iHT.js +1 -0
  267. package/site/dist/assets/parseAbi-Csg-8t59.js +2 -0
  268. package/site/dist/assets/parseAbiParameters-BWbIMYe4.js +1 -0
  269. package/site/dist/assets/parseEther-CHS0GNkM.js +1 -0
  270. package/site/dist/assets/pkce-DXF0yKjP-7_VY-d83.js +1 -0
  271. package/site/dist/assets/preload-helper-CRzLMJPS.js +1 -0
  272. package/site/dist/assets/privy-context-81KmsBw2-DiR6-Yq8.js +2 -0
  273. package/site/dist/assets/property-DuZ9DLP4.js +3 -0
  274. package/site/dist/assets/react-BfYA1q0G.js +1 -0
  275. package/site/dist/assets/react-CK2HRI1t.js +1 -0
  276. package/site/dist/assets/react-DxGeY8B8.js +1 -0
  277. package/site/dist/assets/react-auth-sHnipzbS.js +1 -0
  278. package/site/dist/assets/react-dom-BI2Koe4o.js +1 -0
  279. package/site/dist/assets/reservoir-x-nGuZkT-BguVFH3D.js +1 -0
  280. package/site/dist/assets/roles-BDPDWrwo.js +1 -0
  281. package/site/dist/assets/roles-DKPW79Ca.js +1 -0
  282. package/site/dist/assets/rolldown-runtime-Bjp52BOI.js +1 -0
  283. package/site/dist/assets/safe-url-D7SRPu33-CkMedGro.js +1 -0
  284. package/site/dist/assets/secp256k1-BeYL8aZl.js +1 -0
  285. package/site/dist/assets/secp256k1-Bh4MSkhz.js +1 -0
  286. package/site/dist/assets/secp256k1-Ci4cqHl0.js +1 -0
  287. package/site/dist/assets/secp256k1-DsxXqbXv.js +1 -0
  288. package/site/dist/assets/secp256k1-N9RUmafO.js +1 -0
  289. package/site/dist/assets/serializeAuthorizationList-DGMik9Wx.js +1 -0
  290. package/site/dist/assets/serializeSignature-CWKpxoab.js +2 -0
  291. package/site/dist/assets/sha2-C6s7zZmb.js +1 -0
  292. package/site/dist/assets/{shared-DRZUmnL5-MWD-C-pp.js → shared-DRZUmnL5-BewE5wK8.js} +33 -33
  293. package/site/dist/assets/{shared-FM0rljBt-c4eSjzGj.js → shared-FM0rljBt-CxLACri_.js} +6 -6
  294. package/site/dist/assets/shouldProceedtoEmbeddedWalletCreationFlow-B3vyavrh-BkAKsRNi.js +1 -0
  295. package/site/dist/assets/simulateTransaction-CfuOrae4-PjA_tGjX.js +1 -0
  296. package/site/dist/assets/smartphone-3p8nFSTE.js +1 -0
  297. package/site/dist/assets/src-BBjkfi-Q.js +1 -0
  298. package/site/dist/assets/storage-Ufl800Ne-1qCR2JMO.js +8 -0
  299. package/site/dist/assets/stringify-DqUj9VzO.js +20 -0
  300. package/site/dist/assets/stripe.esm-DEi2D291.js +2 -0
  301. package/site/dist/assets/styles-BsotlekN-Aq27nZGc.js +9 -0
  302. package/site/dist/assets/{styles-Cm9H63WO-Cv1TbqYi.js → styles-Cm9H63WO-p_ic_dxE.js} +17 -17
  303. package/site/dist/assets/{styles-DVyDvTdj-CI4xZNHp.js → styles-DVyDvTdj-CjsWqAld.js} +8 -8
  304. package/site/dist/assets/{styles-hslXy6xG-DeVcFoDD.js → styles-hslXy6xG-D5QHIrJU.js} +23 -23
  305. package/site/dist/assets/telegram-B-JqnkqZ-Dqkm4rDn.js +1 -0
  306. package/site/dist/assets/to-ui-error-DWe-qwS3-Bi1HUQI9.js +4 -0
  307. package/site/dist/assets/toViemAccount-B5iDGq1b-CdFZwv07.js +2 -0
  308. package/site/dist/assets/transaction-BNTP-bFm-M5tJx8vY.js +1 -0
  309. package/site/dist/assets/transfer-6YztDh-t-BVQkTvG-.js +1 -0
  310. package/site/dist/assets/transformers.web-BTyOEJ0C.js +40 -0
  311. package/site/dist/assets/transformers.web-CUZUFjAK.js +49 -0
  312. package/site/dist/assets/triangle-alert-BG3Qw-Hq.js +1 -0
  313. package/site/dist/assets/twitch-5IOe4sIQ-CaXHFlAu.js +1 -0
  314. package/site/dist/assets/types-4CuOD23i.js +1 -0
  315. package/site/dist/assets/use-headless-crypto-deposit-Yn-QRLB3-CQqeyhGY.js +1 -0
  316. package/site/dist/assets/use-unlink-wallet-BKK4_5Ur-C0xQN_Lp.js +1 -0
  317. package/site/dist/assets/useActiveWallet-B-yZYGc6-BkK6rFBm.js +123 -0
  318. package/site/dist/assets/useGetSolPrice-x7gfUIHJ-CLVXqv6I.js +1 -0
  319. package/site/dist/assets/useGetTokenPrice-CaoUkb79-DAXXs3rs.js +1 -0
  320. package/site/dist/assets/useI18n-C-5n_noF-CGpkgIVy.js +1 -0
  321. package/site/dist/assets/useWalletBalance-CZnP5f_f-Cfd64m4n.js +1 -0
  322. package/site/dist/assets/useWallets-X1ndvJ_U-CAYqg7Za.js +1 -0
  323. package/site/dist/assets/utils-BkR7EQjg.js +1 -0
  324. package/site/dist/assets/utils-DJhBNOZA.js +1 -0
  325. package/site/dist/assets/utils-DdckVfQr.js +1 -0
  326. package/site/dist/assets/w3m-modal-B4H_uiPH.js +1174 -0
  327. package/site/dist/assets/wallet-BNI12IYk.js +1 -0
  328. package/site/dist/assets/wallet-CITSaPlB.js +2 -0
  329. package/site/dist/assets/wallet-connect-BvJtUsDt-CVlSNIXP.js +1 -0
  330. package/site/dist/assets/walletconnect-registry-xxG8XLCb-BpzpBq5s.js +1 -0
  331. package/site/dist/assets/walletconnect-v2-3frQFwbg-CzZ6oybX.js +12 -0
  332. package/site/dist/assets/{index-CztIxJB6.js → wui-ux-by-reown-XyHdtV1O.js} +296 -296
  333. package/site/dist/assets/x-gjDrY2rk.js +1 -0
  334. package/site/dist/index.html +5 -117
  335. package/site/worker.js +20 -32
  336. package/src/agent/mcp.js +46 -14
  337. package/src/agent/view-tools.js +3 -11
  338. package/src/agent/x402.js +3 -42
  339. package/src/discover/apps.js +37 -2
  340. package/src/discover/explore.js +19 -13
  341. package/src/publish/init.js +74 -0
  342. package/src/publish/ship.js +90 -79
  343. package/src/publish/view-cli.js +6 -3
  344. package/src/publish/view.js +27 -43
  345. package/template/README.md +49 -0
  346. package/template/app.json +27 -0
  347. package/template/eval/goals.md +7 -0
  348. package/template/eval/golden.jsonl +0 -0
  349. package/template/gitignore +3 -0
  350. package/template/package.json +13 -0
  351. package/template/wrangler.json +12 -0
  352. package/site/dist/assets/AccountNotFoundScreen-C4njXc69-RUyAWRzV.js +0 -1
  353. package/site/dist/assets/AddFundsSelectionScreen-RAoCn7ej-ZV-LlYBe.js +0 -31
  354. package/site/dist/assets/Address-H8kD1d9O-CGQnt7Pu.js +0 -17
  355. package/site/dist/assets/AffirmativeConsentScreen-BG0MJxku-CKn2JLwq.js +0 -6
  356. package/site/dist/assets/AllowlistRejectionScreen-Cae6e1Od-9oIP9fma.js +0 -1
  357. package/site/dist/assets/ArrowsRightLeftIcon-BEhBD_6N.js +0 -1
  358. package/site/dist/assets/AuthenticateWithWalletScreen-CU6hIcFT-D1wLlSJs.js +0 -1
  359. package/site/dist/assets/AwaitingEvmToSolBridgingScreen-D0e_sZMS-CSBbHTyz.js +0 -1
  360. package/site/dist/assets/AwaitingExternalEthereumTransferScreen-ur5HL4R7-BsRq-xBt.js +0 -1
  361. package/site/dist/assets/AwaitingPasswordlessCodeScreen-DRHz76mM-BPdhsKvN.js +0 -103
  362. package/site/dist/assets/AwaitingSolToEvmBridgingScreen-CdLRrGD2-CEGNdrkr.js +0 -1
  363. package/site/dist/assets/BridgeNetworkSelectionView-CFGjB2nO-Da9P7eSx.js +0 -68
  364. package/site/dist/assets/CaptchaScreen-DbpvkIGx-BecgMnD_.js +0 -1
  365. package/site/dist/assets/CheckCircleIcon-DBiWFjO6.js +0 -1
  366. package/site/dist/assets/CheckCircleIcon-DzG2ROJZ.js +0 -1
  367. package/site/dist/assets/Checkbox-D1EDeo41-DMHcj9o_.js +0 -52
  368. package/site/dist/assets/ChevronDownIcon-2Os56gUt.js +0 -1
  369. package/site/dist/assets/Chip-CZKIKt9K-BWzs9fj5.js +0 -26
  370. package/site/dist/assets/CoinbaseOnrampStatusScreen-BbyCJDXL-CFvcSiDs.js +0 -16
  371. package/site/dist/assets/ConnectEmailForm-B-VRE0MN-BozkCg8q.js +0 -3
  372. package/site/dist/assets/ConnectLedgerScreen-DWHABGot-DaCnbBzh.js +0 -10
  373. package/site/dist/assets/ConnectOnlyLandingScreen-CZYx9Bmp-DUkCLkxD.js +0 -1
  374. package/site/dist/assets/ConnectOnlyStatusScreen-DCRzjxHx-Dv_5nMkZ.js +0 -1
  375. package/site/dist/assets/ConnectOrCreateScreen-CUUYUO07-DSGEeB3Y.js +0 -1
  376. package/site/dist/assets/ConnectPhoneForm-Dek5xn4C-C-s4s_Lq.js +0 -95
  377. package/site/dist/assets/ConnectWalletView-DqI-PTvX-BKX7fdYr.js +0 -74
  378. package/site/dist/assets/ConnectionStatusScreen-fUfROm9m-DSoAuMFZ.js +0 -7
  379. package/site/dist/assets/CopyToClipboard-i_OQSBJr-CZTXyfV0.js +0 -39
  380. package/site/dist/assets/CopyableText-CQapvaMr-DHO818I0.js +0 -28
  381. package/site/dist/assets/CrossAppAuthScreen-CLw7ymZq-DW4nRGfz.js +0 -1
  382. package/site/dist/assets/CustomLandingScreenView-Cm_MBSyX-DH8Nnb4Y.js +0 -22
  383. package/site/dist/assets/DelegatedActionsConsentScreen-DYF2U4y5-gfUS_uV5.js +0 -1
  384. package/site/dist/assets/DelegatedActionsRevokeScreen-bPp6Uwyh-DZj9HTHc.js +0 -1
  385. package/site/dist/assets/DepositAddressAddressStepView-4vdkb55L-eHYsDK9W.js +0 -187
  386. package/site/dist/assets/DepositAddressScreen-DBLRs7aI-DK_XVgVk.js +0 -8
  387. package/site/dist/assets/DepositAddressV3Screen-CDqIEMQw-6gRZzhLe.js +0 -1
  388. package/site/dist/assets/EmbeddedWalletConnectingScreen-D4T7DUzs-BZu2ae0k.js +0 -1
  389. package/site/dist/assets/EmbeddedWalletCreatedScreen-D7WhW5ve-86pviemJ.js +0 -1
  390. package/site/dist/assets/EmbeddedWalletKeyExportScreen-CqV4NYQ3-vDcvT53Y.js +0 -23
  391. package/site/dist/assets/EmbeddedWalletOnAccountCreateScreen-BoKb3Q2S-rNJAtSJc.js +0 -1
  392. package/site/dist/assets/EmbeddedWalletPasswordUpdateScreen-D3rMlqS7-I8Q95280.js +0 -1
  393. package/site/dist/assets/EmbeddedWalletPasswordUpdateSplashScreen-BPFkWJeE-Coi7OxoI.js +0 -1
  394. package/site/dist/assets/EnrollTotp-Dibew4dp-DC7FrDgo.js +0 -66
  395. package/site/dist/assets/EnvelopeIcon-DY6ERnW7.js +0 -1
  396. package/site/dist/assets/ErrorBanner-BcpGRt0h-BvESwN99.js +0 -21
  397. package/site/dist/assets/ErrorScreen-DipdTWzE-DnKGxH1Z.js +0 -4
  398. package/site/dist/assets/ExclamationCircleIcon-BZhlqH0r.js +0 -1
  399. package/site/dist/assets/ExclamationTriangleIcon-CkAOJIYV.js +0 -1
  400. package/site/dist/assets/FarcasterConnectStatusScreen-51tjUxqq-4pi7jooW.js +0 -75
  401. package/site/dist/assets/FarcasterSignerStatusScreen-6x-Uh95G-z2XCMaLL.js +0 -28
  402. package/site/dist/assets/FiatOnrampScreen-BAhYeiTI-CBVA9v1-.js +0 -491
  403. package/site/dist/assets/FingerPrintIcon-ra2dqmJO.js +0 -1
  404. package/site/dist/assets/FundSolWalletWithExternalSolanaWallet-WtLwYaOl-DwAwc6Ny.js +0 -1
  405. package/site/dist/assets/FundWalletMethodHeader-BWNkokCT-CZszQsZf.js +0 -1
  406. package/site/dist/assets/FundWithBankDepositScreen-DajkHxBD-DfX6nvFQ.js +0 -58
  407. package/site/dist/assets/FundingEditAmountScreen-CpvpiO4M-CDS_sk_t.js +0 -1
  408. package/site/dist/assets/FundingMethodSelectionScreen-Db7vhRlE-CPfNQemT.js +0 -1
  409. package/site/dist/assets/GlobeAltIcon-SEUEIe_E.js +0 -1
  410. package/site/dist/assets/GooglePay-B53WnudL-aap7zwag.js +0 -1
  411. package/site/dist/assets/HCaptchaWrapper-CUi9LJsp-DgSjCjQI.js +0 -4
  412. package/site/dist/assets/InAppBrowserLoginNotPossible-BMR9br1T-DO4wICml.js +0 -1
  413. package/site/dist/assets/InfoBanner-Cb3p1z12-CDWt2ADo.js +0 -22
  414. package/site/dist/assets/InjectedWalletIcon-DLcYOGDj-Ba19XoBr.js +0 -1
  415. package/site/dist/assets/InstallWalletScreen-DTA8dwLv-DGpewEch.js +0 -1
  416. package/site/dist/assets/LandingScreen-CGWUoSUG-CUOCWUXd.js +0 -1
  417. package/site/dist/assets/Link-BdDilT2T-BYiP1zvW.js +0 -40
  418. package/site/dist/assets/LinkConflictScreen-C3ZEPsgl-Tb6cAepT.js +0 -77
  419. package/site/dist/assets/LinkEmailScreen-dKo9frwc-pq0NF2JO.js +0 -1
  420. package/site/dist/assets/LinkPasskeyScreen-zbrl_AI_-D9MOmDqg.js +0 -117
  421. package/site/dist/assets/LinkPhoneScreen-oIUpfj0w-B80UJqAZ.js +0 -1
  422. package/site/dist/assets/LockClosedIcon-BqkoEL9J.js +0 -1
  423. package/site/dist/assets/LoginFailedScreen-CN0dJV6U-DlnOM-Kh.js +0 -1
  424. package/site/dist/assets/ManualTransferScreen-CHqcuqbs-DSShupq9.js +0 -1
  425. package/site/dist/assets/MfaAuthEnrollmentFlowScreen-Dj7gPTRC-DUPV_SLA.js +0 -1
  426. package/site/dist/assets/MfaAuthVerifyFlowScreen-DbFpyWMy-D96GpzXX.js +0 -1
  427. package/site/dist/assets/MfaEnrollmentFlowScreen-DhLnGgnr-CYQDa4ND.js +0 -1
  428. package/site/dist/assets/MfaVerifyFlowScreen-C_XPjMRP-CJtSAXGN.js +0 -1
  429. package/site/dist/assets/ModalFooter-BCuEK_nz-D2I8KWtk.js +0 -403
  430. package/site/dist/assets/MoonpayStatusScreen-CzTUtokc-Bx5aHy-z.js +0 -16
  431. package/site/dist/assets/OAuthStatusScreen-ufbOa-da-CS6988X2.js +0 -1
  432. package/site/dist/assets/OpenLink-CUpJ1mOr-EZWVSX2r.js +0 -39
  433. package/site/dist/assets/PasskeySelectSignupOrLogin-xh2ScC_l-BY4eK5Jh.js +0 -1
  434. package/site/dist/assets/PasskeyStatusScreen-Bla8MaOk-LXys76u9.js +0 -6
  435. package/site/dist/assets/PasswordRecoveryScreen-awGXZkQk-RczvLvmo.js +0 -20
  436. package/site/dist/assets/PhArrowClockwise-mOiWYLMV.js +0 -14
  437. package/site/dist/assets/PhArrowDown-CkoOD89h.js +0 -14
  438. package/site/dist/assets/PhArrowLeft-C0jlxVhM.js +0 -14
  439. package/site/dist/assets/PhArrowRight-BI-V03Xf.js +0 -14
  440. package/site/dist/assets/PhArrowUp-izKvURUW.js +0 -14
  441. package/site/dist/assets/PhArrowUpRight-Bn-JhHsY.js +0 -14
  442. package/site/dist/assets/PhArrowsLeftRight-CYsRQ2qh.js +0 -14
  443. package/site/dist/assets/PhBrowser-BjzAmrHO.js +0 -14
  444. package/site/dist/assets/PhCaretDown-ddSjwcwm.js +0 -14
  445. package/site/dist/assets/PhCaretLeft-B7YLoNEF.js +0 -14
  446. package/site/dist/assets/PhCaretRight-BY8D5MIg.js +0 -14
  447. package/site/dist/assets/PhCaretUp-BG10nSut.js +0 -14
  448. package/site/dist/assets/PhCheck-DrKd7pBC.js +0 -14
  449. package/site/dist/assets/PhClock-Sj17weCB.js +0 -14
  450. package/site/dist/assets/PhCopy-rgttky8E.js +0 -14
  451. package/site/dist/assets/PhDeviceMobile-CnybhXY-.js +0 -14
  452. package/site/dist/assets/PhDotsThree-CSAEcba1.js +0 -14
  453. package/site/dist/assets/PhEnvelope-SmaNeXoQ.js +0 -14
  454. package/site/dist/assets/PhFunnelSimple-DKx35ITq.js +0 -14
  455. package/site/dist/assets/PhMagnifyingGlass-B6D0sWFL.js +0 -14
  456. package/site/dist/assets/PhPlus-CBvZvLax.js +0 -14
  457. package/site/dist/assets/PhWarningCircle-Cm58gXb9.js +0 -14
  458. package/site/dist/assets/PhX-C3b4cCEy.js +0 -14
  459. package/site/dist/assets/PhoneIcon-CzbssTb8.js +0 -1
  460. package/site/dist/assets/PinInput-DbZ0b1i1-1DtLWL81.js +0 -247
  461. package/site/dist/assets/QrCode-DbnZwlkH-ChwcUk_h.js +0 -22
  462. package/site/dist/assets/RecoveryOAuthStatusScreen-CsgtTI2x-C79jd345.js +0 -1
  463. package/site/dist/assets/RecoveryPasswordCreateScreen-Be-qJ-LU-C9c0x-yq.js +0 -1
  464. package/site/dist/assets/RecoverySelectionScreen-D1iGtpmi-PNqHb6CI.js +0 -7
  465. package/site/dist/assets/ScreenLayout-OwaQQcxH-B4Z8FjFp.js +0 -1
  466. package/site/dist/assets/SetAutomaticRecoveryScreen-BO_OEqAZ-CUpQZ9wq.js +0 -14
  467. package/site/dist/assets/SetWalletPasswordForm-DwCTVtAh-ZzvPLj2s.js +0 -15
  468. package/site/dist/assets/ShieldCheckIcon-Bjwe_-PV.js +0 -1
  469. package/site/dist/assets/SignRequestScreen-BHKv32KR-0qGeNipB.js +0 -26
  470. package/site/dist/assets/StandardSignAndSendTransactionScreen-CfhIXVtd-C3lgJb68.js +0 -20
  471. package/site/dist/assets/TelegramAuthScreen-UL9zLfO8-l35_C2DG.js +0 -1
  472. package/site/dist/assets/TodoList-DnyULl18-JxWWU9KA.js +0 -36
  473. package/site/dist/assets/TransactionDetails-e9nesl30-C91nJPM9.js +0 -109
  474. package/site/dist/assets/TransactionErrorView-BDBNqA_f-Cpm-4xzm.js +0 -178
  475. package/site/dist/assets/TransferFromWalletScreen-Qvn1Yuno-BWCH7-Si.js +0 -31
  476. package/site/dist/assets/TransferOrBridgeLoadingScreen-Dl1I_iIz-BWMeJabk.js +0 -6
  477. package/site/dist/assets/TurnstileWrapper-B7sNddys-Dgr80Gih.js +0 -1
  478. package/site/dist/assets/UpdateEmailScreen-DVOhPV0H-Clk4zk-8.js +0 -1
  479. package/site/dist/assets/UpdatePhoneScreen-CXRswTNZ-BgRsoR3B.js +0 -1
  480. package/site/dist/assets/UserLimitReachedScreen-5we2DHn8-D-SU-vAz.js +0 -1
  481. package/site/dist/assets/WalletCards-DH1rqayz-UuZ4i_Ze.js +0 -1
  482. package/site/dist/assets/WalletIcon-B1i03Vqc.js +0 -1
  483. package/site/dist/assets/WalletInfoCard-sq_2wgFg-TXTxmb8L.js +0 -29
  484. package/site/dist/assets/WalletInterstitialScreen-Sh7LfsAh-CbrFb0ON.js +0 -1
  485. package/site/dist/assets/WalletLink-DK5LB5Ha-BYQZV7UV.js +0 -20
  486. package/site/dist/assets/WalletOverflowButton-bfCnp-9T-CNgSPnTS.js +0 -1
  487. package/site/dist/assets/WarningBanner-ZZqCEtZK-DNZUUOph.js +0 -21
  488. package/site/dist/assets/__vite-browser-external-BIHI7g3E.js +0 -1
  489. package/site/dist/assets/analytics-mkkvFRju-DOXuftJB.js +0 -1
  490. package/site/dist/assets/basic-C9wn6QoQ.js +0 -1575
  491. package/site/dist/assets/bytes-CjWw8TJh.js +0 -1
  492. package/site/dist/assets/capitalizeFirstLetter-DmLYqXsO-tV1Idewc.js +0 -1
  493. package/site/dist/assets/ccip-BhHEqVIW.js +0 -1
  494. package/site/dist/assets/check-C_DTyjLS.js +0 -1
  495. package/site/dist/assets/chevron-down-iklXXH-z.js +0 -1
  496. package/site/dist/assets/circle-alert-KEOUF48T.js +0 -1
  497. package/site/dist/assets/circle-check-big-BJ_ADwB4.js +0 -1
  498. package/site/dist/assets/circle-x-BSfWmhYk.js +0 -1
  499. package/site/dist/assets/client-BnDcP42J.js +0 -9
  500. package/site/dist/assets/client-DH86IrJA.js +0 -125
  501. package/site/dist/assets/coinbase-DCPC2L_R-2ivYfoMv.js +0 -3
  502. package/site/dist/assets/copy-sK00DOfH.js +0 -1
  503. package/site/dist/assets/core-CRE213RM.js +0 -211
  504. package/site/dist/assets/createLucideIcon-D9OK_uxG.js +0 -1
  505. package/site/dist/assets/custom-V1wex-Di.js +0 -1
  506. package/site/dist/assets/dijkstra-COg3n3zL.js +0 -1
  507. package/site/dist/assets/embed.worker-BRIYO7m8.js +0 -1
  508. package/site/dist/assets/encodePacked-DyXYq3Cc.js +0 -1
  509. package/site/dist/assets/ethers-zTjbodk5-DSYOi6tU.js +0 -1
  510. package/site/dist/assets/external-link-Cdp8NBio.js +0 -1
  511. package/site/dist/assets/fallback-DiFue5Zm.js +0 -1
  512. package/site/dist/assets/farcaster-DPlSjvF5-DP2DLoHZ.js +0 -1
  513. package/site/dist/assets/features-B6BTj_BL.js +0 -5
  514. package/site/dist/assets/fingerprint-pattern-gFJTz5e4.js +0 -1
  515. package/site/dist/assets/floating-ui.react-D9ndYqYK.js +0 -1
  516. package/site/dist/assets/floating-ui.react-dom-CNbOgOFt.js +0 -1
  517. package/site/dist/assets/formatErc20TokenAmount-BuPk9xcy-CkAr4Oc0.js +0 -1
  518. package/site/dist/assets/getChainName-DjpPdUSc-c2urPd0g.js +0 -1
  519. package/site/dist/assets/getErc20Balance-jXNpFf0N-mFQ9Iqk-.js +0 -1
  520. package/site/dist/assets/getErc20TokenInfo-BNTrzLMP-Dx5he_uG.js +0 -1
  521. package/site/dist/assets/getFormattedUsdFromLamports-De3U9GlO-C446pzMl.js +0 -1
  522. package/site/dist/assets/getTransactionCount-80UHlwAV.js +0 -1
  523. package/site/dist/assets/getUsdcMintAddress-BVgm9GRo-FDalV59C.js +0 -1
  524. package/site/dist/assets/hashTypedData-Beq57Ogb.js +0 -22
  525. package/site/dist/assets/hooks.module-ClpaQ1Tg.js +0 -1
  526. package/site/dist/assets/hourglass-CB7z_I9H.js +0 -1
  527. package/site/dist/assets/http-BocEfKYb.js +0 -19
  528. package/site/dist/assets/index-0knDOgU9.js +0 -1
  529. package/site/dist/assets/index-9jNeS_nC.js +0 -1
  530. package/site/dist/assets/index-B--T-Fmt.js +0 -16
  531. package/site/dist/assets/index-BDkarAkX.js +0 -2
  532. package/site/dist/assets/index-BMfMy017.js +0 -679
  533. package/site/dist/assets/index-BOd8jv8-.js +0 -1
  534. package/site/dist/assets/index-BdEw5wyl-2VGMzHIs.js +0 -1
  535. package/site/dist/assets/index-C8ThRelw.js +0 -9
  536. package/site/dist/assets/index-D4LdLFDC.js +0 -1
  537. package/site/dist/assets/index-D6T-s6sR.js +0 -1
  538. package/site/dist/assets/index-D7396TWe.js +0 -1
  539. package/site/dist/assets/index-DdxtHe81.js +0 -2
  540. package/site/dist/assets/index-DvMddJcd-D7AEQrzj.js +0 -12
  541. package/site/dist/assets/index-nibyPLVP.js +0 -1
  542. package/site/dist/assets/index.browser-B6Bt5URJ.js +0 -1
  543. package/site/dist/assets/isPaymentRequestAvailable-Bq1cemEn-D7xtzRqA.js +0 -1
  544. package/site/dist/assets/landmark-CMLKifhk.js +0 -1
  545. package/site/dist/assets/lock-BkyjNE8h.js +0 -1
  546. package/site/dist/assets/mail-B6-Tq9Ld.js +0 -1
  547. package/site/dist/assets/native-CJ5et6AR.js +0 -1
  548. package/site/dist/assets/nonceManager-zkW7cM66.js +0 -1
  549. package/site/dist/assets/parseEther-C7aOvuze.js +0 -1
  550. package/site/dist/assets/parseSignature-BIjcuWdB.js +0 -1
  551. package/site/dist/assets/preload-helper-PPVm8Dsz.js +0 -1
  552. package/site/dist/assets/privateKeyToAccount-CRvvpHWf.js +0 -1
  553. package/site/dist/assets/property-CnFDNXw5.js +0 -3
  554. package/site/dist/assets/react-auth_false-DedQs79w.js +0 -1
  555. package/site/dist/assets/reservoir-x-nGuZkT-DFxAFt2v.js +0 -1
  556. package/site/dist/assets/roles-DV_6FRBZ.js +0 -1
  557. package/site/dist/assets/safe-url-D7SRPu33-A8zMgOTd.js +0 -1
  558. package/site/dist/assets/serializeErc6492Signature-CeJeL3h6.js +0 -1
  559. package/site/dist/assets/serializeTransaction-L-_Ej-jW.js +0 -8
  560. package/site/dist/assets/shouldProceedtoEmbeddedWalletCreationFlow-B3vyavrh-CF2QteTJ.js +0 -1
  561. package/site/dist/assets/simulateTransaction-CfuOrae4-BHUMPf6Q.js +0 -1
  562. package/site/dist/assets/smartphone-DAN5rY0T.js +0 -1
  563. package/site/dist/assets/stripe.esm-Dv8C3q95.js +0 -2
  564. package/site/dist/assets/styles-BsotlekN-Cjuu2SDV.js +0 -9
  565. package/site/dist/assets/telegram-B-JqnkqZ-DTjJLkIF.js +0 -1
  566. package/site/dist/assets/to-ui-error-DWe-qwS3-Dx3yzcV0.js +0 -4
  567. package/site/dist/assets/toAccount-Bq6rbpbI.js +0 -1
  568. package/site/dist/assets/transaction-BNTP-bFm-CrebgH-D.js +0 -1
  569. package/site/dist/assets/transactionReceipt-BwJl-gjg.js +0 -1
  570. package/site/dist/assets/transfer-6YztDh-t-DU6hH7CZ.js +0 -1
  571. package/site/dist/assets/transformers.web-BEKVh7pD.js +0 -40
  572. package/site/dist/assets/transformers.web-aWa49tv1.js +0 -40
  573. package/site/dist/assets/triangle-alert-ndoiBs4y.js +0 -1
  574. package/site/dist/assets/twitch-5IOe4sIQ-BXviIywg.js +0 -1
  575. package/site/dist/assets/useGetSolPrice-x7gfUIHJ-C7axYJ--.js +0 -1
  576. package/site/dist/assets/useGetTokenPrice-CaoUkb79-CR4CrguU.js +0 -1
  577. package/site/dist/assets/useI18n-C-5n_noF-C_t8QqBJ.js +0 -1
  578. package/site/dist/assets/useWalletBalance-CZnP5f_f-BnSHLVI_.js +0 -1
  579. package/site/dist/assets/w3m-modal-Bz5KWTQ-.js +0 -1174
  580. package/site/dist/assets/wallet-DTM31trz.js +0 -2
  581. package/site/dist/assets/wallet-UESEqPei.js +0 -1
  582. package/site/dist/assets/wallet-connect-BvJtUsDt-CnvUnFbz.js +0 -1
  583. package/site/dist/assets/walletconnect-v2-3frQFwbg-CzQk99gS.js +0 -15
  584. package/site/dist/assets/x-B2_XdOVQ.js +0 -1
@@ -1,15 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./core-CRE213RM.js","./preload-helper-PPVm8Dsz.js","./index-9jNeS_nC.js","./index-BMfMy017.js","./index-BOd8jv8-.js","./serializeTransaction-L-_Ej-jW.js","./http-BocEfKYb.js","./hashTypedData-Beq57Ogb.js","./getTransactionCount-80UHlwAV.js","./transactionReceipt-BwJl-gjg.js","./toAccount-Bq6rbpbI.js","./parseSignature-BIjcuWdB.js","./index-D6T-s6sR.js","./fallback-DiFue5Zm.js"])))=>i.map(i=>d[i]);
2
- import{_ as Jg}from"./preload-helper-PPVm8Dsz.js";import{g as Wa,a as vf,c as jt}from"./index-9jNeS_nC.js";import{eN as Xg,eO as xn,eI as Qg,aW as De,eP as Ls,eQ as ey,eR as ty,aX as Ms,eK as ry,eS as iy,ak as qc,eT as ny,eU as sy,eV as oy,eW as ay,eX as zc,eL as cy,eY as uy,eZ as ly}from"./index-BMfMy017.js";import{c as hy,a as fy,k as dy,d as py,s as gy,g as Vc}from"./index-nibyPLVP.js";import{d as yy}from"./wallet-connect-BvJtUsDt-CnvUnFbz.js";var _n={exports:{}},Hc;function wy(){if(Hc)return _n.exports;Hc=1;var t=typeof Reflect=="object"?Reflect:null,e=t&&typeof t.apply=="function"?t.apply:function(E,I,$){return Function.prototype.apply.call(E,I,$)},r;t&&typeof t.ownKeys=="function"?r=t.ownKeys:Object.getOwnPropertySymbols?r=function(E){return Object.getOwnPropertyNames(E).concat(Object.getOwnPropertySymbols(E))}:r=function(E){return Object.getOwnPropertyNames(E)};function i(b){console&&console.warn&&console.warn(b)}var n=Number.isNaN||function(E){return E!==E};function s(){s.init.call(this)}_n.exports=s,_n.exports.once=x,s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var o=10;function a(b){if(typeof b!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof b)}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return o},set:function(b){if(typeof b!="number"||b<0||n(b))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+b+".");o=b}}),s.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},s.prototype.setMaxListeners=function(E){if(typeof E!="number"||E<0||n(E))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+E+".");return this._maxListeners=E,this};function c(b){return b._maxListeners===void 0?s.defaultMaxListeners:b._maxListeners}s.prototype.getMaxListeners=function(){return c(this)},s.prototype.emit=function(E){for(var I=[],$=1;$<arguments.length;$++)I.push(arguments[$]);var B=E==="error",C=this._events;if(C!==void 0)B=B&&C.error===void 0;else if(!B)return!1;if(B){var k;if(I.length>0&&(k=I[0]),k instanceof Error)throw k;var F=new Error("Unhandled error."+(k?" ("+k.message+")":""));throw F.context=k,F}var R=C[E];if(R===void 0)return!1;if(typeof R=="function")e(R,this,I);else for(var P=R.length,T=p(R,P),$=0;$<P;++$)e(T[$],this,I);return!0};function u(b,E,I,$){var B,C,k;if(a(I),C=b._events,C===void 0?(C=b._events=Object.create(null),b._eventsCount=0):(C.newListener!==void 0&&(b.emit("newListener",E,I.listener?I.listener:I),C=b._events),k=C[E]),k===void 0)k=C[E]=I,++b._eventsCount;else if(typeof k=="function"?k=C[E]=$?[I,k]:[k,I]:$?k.unshift(I):k.push(I),B=c(b),B>0&&k.length>B&&!k.warned){k.warned=!0;var F=new Error("Possible EventEmitter memory leak detected. "+k.length+" "+String(E)+" listeners added. Use emitter.setMaxListeners() to increase limit");F.name="MaxListenersExceededWarning",F.emitter=b,F.type=E,F.count=k.length,i(F)}return b}s.prototype.addListener=function(E,I){return u(this,E,I,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(E,I){return u(this,E,I,!0)};function l(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function h(b,E,I){var $={fired:!1,wrapFn:void 0,target:b,type:E,listener:I},B=l.bind($);return B.listener=I,$.wrapFn=B,B}s.prototype.once=function(E,I){return a(I),this.on(E,h(this,E,I)),this},s.prototype.prependOnceListener=function(E,I){return a(I),this.prependListener(E,h(this,E,I)),this},s.prototype.removeListener=function(E,I){var $,B,C,k,F;if(a(I),B=this._events,B===void 0)return this;if($=B[E],$===void 0)return this;if($===I||$.listener===I)--this._eventsCount===0?this._events=Object.create(null):(delete B[E],B.removeListener&&this.emit("removeListener",E,$.listener||I));else if(typeof $!="function"){for(C=-1,k=$.length-1;k>=0;k--)if($[k]===I||$[k].listener===I){F=$[k].listener,C=k;break}if(C<0)return this;C===0?$.shift():y($,C),$.length===1&&(B[E]=$[0]),B.removeListener!==void 0&&this.emit("removeListener",E,F||I)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(E){var I,$,B;if($=this._events,$===void 0)return this;if($.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):$[E]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete $[E]),this;if(arguments.length===0){var C=Object.keys($),k;for(B=0;B<C.length;++B)k=C[B],k!=="removeListener"&&this.removeAllListeners(k);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(I=$[E],typeof I=="function")this.removeListener(E,I);else if(I!==void 0)for(B=I.length-1;B>=0;B--)this.removeListener(E,I[B]);return this};function f(b,E,I){var $=b._events;if($===void 0)return[];var B=$[E];return B===void 0?[]:typeof B=="function"?I?[B.listener||B]:[B]:I?m(B):p(B,B.length)}s.prototype.listeners=function(E){return f(this,E,!0)},s.prototype.rawListeners=function(E){return f(this,E,!1)},s.listenerCount=function(b,E){return typeof b.listenerCount=="function"?b.listenerCount(E):g.call(b,E)},s.prototype.listenerCount=g;function g(b){var E=this._events;if(E!==void 0){var I=E[b];if(typeof I=="function")return 1;if(I!==void 0)return I.length}return 0}s.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]};function p(b,E){for(var I=new Array(E),$=0;$<E;++$)I[$]=b[$];return I}function y(b,E){for(;E+1<b.length;E++)b[E]=b[E+1];b.pop()}function m(b){for(var E=new Array(b.length),I=0;I<E.length;++I)E[I]=b[I].listener||b[I];return E}function x(b,E){return new Promise(function(I,$){function B(k){b.removeListener(E,C),$(k)}function C(){typeof b.removeListener=="function"&&b.removeListener("error",B),I([].slice.call(arguments))}v(b,E,C,{once:!0}),E!=="error"&&S(b,B,{once:!0})})}function S(b,E,I){typeof b.on=="function"&&v(b,"error",E,I)}function v(b,E,I,$){if(typeof b.on=="function")$.once?b.once(E,I):b.on(E,I);else if(typeof b.addEventListener=="function")b.addEventListener(E,function B(C){$.once&&b.removeEventListener(E,B),I(C)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof b)}return _n.exports}var ct=wy();const Ga=Wa(ct);var Kc=function(t,e,r){if(r||arguments.length===2)for(var i=0,n=e.length,s;i<n;i++)(s||!(i in e))&&(s||(s=Array.prototype.slice.call(e,0,i)),s[i]=e[i]);return t.concat(s||Array.prototype.slice.call(e))},by=(function(){function t(e,r,i){this.name=e,this.version=r,this.os=i,this.type="browser"}return t})(),my=(function(){function t(e){this.version=e,this.type="node",this.name="node",this.os=process.platform}return t})(),vy=(function(){function t(e,r,i,n){this.name=e,this.version=r,this.os=i,this.bot=n,this.type="bot-device"}return t})(),Ey=(function(){function t(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return t})(),Dy=(function(){function t(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return t})(),xy=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,_y=/(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,Wc=3,Iy=[["aol",/AOLShield\/([0-9\._]+)/],["edge",/Edge\/([0-9\._]+)/],["edge-ios",/EdgiOS\/([0-9\._]+)/],["yandexbrowser",/YaBrowser\/([0-9\._]+)/],["kakaotalk",/KAKAOTALK\s([0-9\.]+)/],["samsung",/SamsungBrowser\/([0-9\.]+)/],["silk",/\bSilk\/([0-9._-]+)\b/],["miui",/MiuiBrowser\/([0-9\.]+)$/],["beaker",/BeakerBrowser\/([0-9\.]+)/],["edge-chromium",/EdgA?\/([0-9\.]+)/],["chromium-webview",/(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["chrome",/(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["phantomjs",/PhantomJS\/([0-9\.]+)(:?\s|$)/],["crios",/CriOS\/([0-9\.]+)(:?\s|$)/],["firefox",/Firefox\/([0-9\.]+)(?:\s|$)/],["fxios",/FxiOS\/([0-9\.]+)/],["opera-mini",/Opera Mini.*Version\/([0-9\.]+)/],["opera",/Opera\/([0-9\.]+)(?:\s|$)/],["opera",/OPR\/([0-9\.]+)(:?\s|$)/],["pie",/^Microsoft Pocket Internet Explorer\/(\d+\.\d+)$/],["pie",/^Mozilla\/\d\.\d+\s\(compatible;\s(?:MSP?IE|MSInternet Explorer) (\d+\.\d+);.*Windows CE.*\)$/],["netfront",/^Mozilla\/\d\.\d+.*NetFront\/(\d.\d)/],["ie",/Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/],["ie",/MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],["ie",/MSIE\s(7\.0)/],["bb10",/BB10;\sTouch.*Version\/([0-9\.]+)/],["android",/Android\s([0-9\.]+)/],["ios",/Version\/([0-9\._]+).*Mobile.*Safari.*/],["safari",/Version\/([0-9\._]+).*Safari/],["facebook",/FB[AS]V\/([0-9\.]+)/],["instagram",/Instagram\s([0-9\.]+)/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Mobile/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Gecko\)$/],["curl",/^curl\/([0-9\.]+)$/],["searchbot",xy]],Gc=[["iOS",/iP(hone|od|ad)/],["Android OS",/Android/],["BlackBerry OS",/BlackBerry|BB10/],["Windows Mobile",/IEMobile/],["Amazon OS",/Kindle/],["Windows 3.11",/Win16/],["Windows 95",/(Windows 95)|(Win95)|(Windows_95)/],["Windows 98",/(Windows 98)|(Win98)/],["Windows 2000",/(Windows NT 5.0)|(Windows 2000)/],["Windows XP",/(Windows NT 5.1)|(Windows XP)/],["Windows Server 2003",/(Windows NT 5.2)/],["Windows Vista",/(Windows NT 6.0)/],["Windows 7",/(Windows NT 6.1)/],["Windows 8",/(Windows NT 6.2)/],["Windows 8.1",/(Windows NT 6.3)/],["Windows 10",/(Windows NT 10.0)/],["Windows ME",/Windows ME/],["Windows CE",/Windows CE|WinCE|Microsoft Pocket Internet Explorer/],["Open BSD",/OpenBSD/],["Sun OS",/SunOS/],["Chrome OS",/CrOS/],["Linux",/(Linux)|(X11)/],["Mac OS",/(Mac_PowerPC)|(Macintosh)/],["QNX",/QNX/],["BeOS",/BeOS/],["OS/2",/OS\/2/]];function Sy(t){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new Dy:typeof navigator<"u"?Ay(navigator.userAgent):Cy()}function Oy(t){return t!==""&&Iy.reduce(function(e,r){var i=r[0],n=r[1];if(e)return e;var s=n.exec(t);return!!s&&[i,s]},!1)}function Ay(t){var e=Oy(t);if(!e)return null;var r=e[0],i=e[1];if(r==="searchbot")return new Ey;var n=i[1]&&i[1].split(".").join("_").split("_").slice(0,3);n?n.length<Wc&&(n=Kc(Kc([],n,!0),Py(Wc-n.length),!0)):n=[];var s=n.join("."),o=$y(t),a=_y.exec(t);return a&&a[1]?new vy(r,s,o,a[1]):new by(r,s,o)}function $y(t){for(var e=0,r=Gc.length;e<r;e++){var i=Gc[e],n=i[0],s=i[1],o=s.exec(t);if(o)return n}return null}function Cy(){var t=typeof process<"u"&&process.version;return t?new my(process.version.slice(1)):null}function Py(t){for(var e=[],r=0;r<t;r++)e.push("0");return e}var qs={};var Go=function(t,e){return Go=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var n in i)i.hasOwnProperty(n)&&(r[n]=i[n])},Go(t,e)};function By(t,e){Go(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var Yo=function(){return Yo=Object.assign||function(e){for(var r,i=1,n=arguments.length;i<n;i++){r=arguments[i];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},Yo.apply(this,arguments)};function Ty(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(t);n<i.length;n++)e.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(t,i[n])&&(r[i[n]]=t[i[n]]);return r}function Ry(t,e,r,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(n<3?o(s):n>3?o(e,r,s):o(e,r))||s);return n>3&&s&&Object.defineProperty(e,r,s),s}function Uy(t,e){return function(r,i){e(r,i,t)}}function Ny(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function jy(t,e,r,i){function n(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function a(l){try{u(i.next(l))}catch(h){o(h)}}function c(l){try{u(i.throw(l))}catch(h){o(h)}}function u(l){l.done?s(l.value):n(l.value).then(a,c)}u((i=i.apply(t,e||[])).next())})}function ky(t,e){var r={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,n,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(u){return function(l){return c([u,l])}}function c(u){if(i)throw new TypeError("Generator is already executing.");for(;r;)try{if(i=1,n&&(s=u[0]&2?n.return:u[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,u[1])).done)return s;switch(n=0,s&&(u=[u[0]&2,s.value]),u[0]){case 0:case 1:s=u;break;case 4:return r.label++,{value:u[1],done:!1};case 5:r.label++,n=u[1],u=[0];continue;case 7:u=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(u[0]===6||u[0]===2)){r=0;continue}if(u[0]===3&&(!s||u[1]>s[0]&&u[1]<s[3])){r.label=u[1];break}if(u[0]===6&&r.label<s[1]){r.label=s[1],s=u;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(u);break}s[2]&&r.ops.pop(),r.trys.pop();continue}u=e.call(t,r)}catch(l){u=[6,l],n=0}finally{i=s=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}function Fy(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}function Ly(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function Zo(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],i=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Ef(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var i=r.call(t),n,s=[],o;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(a){o={error:a}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s}function My(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Ef(arguments[e]));return t}function qy(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var i=Array(t),n=0,e=0;e<r;e++)for(var s=arguments[e],o=0,a=s.length;o<a;o++,n++)i[n]=s[o];return i}function tn(t){return this instanceof tn?(this.v=t,this):new tn(t)}function zy(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=r.apply(t,e||[]),n,s=[];return n={},o("next"),o("throw"),o("return"),n[Symbol.asyncIterator]=function(){return this},n;function o(f){i[f]&&(n[f]=function(g){return new Promise(function(p,y){s.push([f,g,p,y])>1||a(f,g)})})}function a(f,g){try{c(i[f](g))}catch(p){h(s[0][3],p)}}function c(f){f.value instanceof tn?Promise.resolve(f.value.v).then(u,l):h(s[0][2],f)}function u(f){a("next",f)}function l(f){a("throw",f)}function h(f,g){f(g),s.shift(),s.length&&a(s[0][0],s[0][1])}}function Vy(t){var e,r;return e={},i("next"),i("throw",function(n){throw n}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(n,s){e[n]=t[n]?function(o){return(r=!r)?{value:tn(t[n](o)),done:n==="return"}:s?s(o):o}:s}}function Hy(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],r;return e?e.call(t):(t=typeof Zo=="function"?Zo(t):t[Symbol.iterator](),r={},i("next"),i("throw"),i("return"),r[Symbol.asyncIterator]=function(){return this},r);function i(s){r[s]=t[s]&&function(o){return new Promise(function(a,c){o=t[s](o),n(a,c,o.done,o.value)})}}function n(s,o,a,c){Promise.resolve(c).then(function(u){s({value:u,done:a})},o)}}function Ky(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function Wy(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e}function Gy(t){return t&&t.__esModule?t:{default:t}}function Yy(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function Zy(t,e,r){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,r),r}const Jy=Object.freeze(Object.defineProperty({__proto__:null,get __assign(){return Yo},__asyncDelegator:Vy,__asyncGenerator:zy,__asyncValues:Hy,__await:tn,__awaiter:jy,__classPrivateFieldGet:Yy,__classPrivateFieldSet:Zy,__createBinding:Fy,__decorate:Ry,__exportStar:Ly,__extends:By,__generator:ky,__importDefault:Gy,__importStar:Wy,__makeTemplateObject:Ky,__metadata:Ny,__param:Uy,__read:Ef,__rest:Ty,__spread:My,__spreadArrays:qy,__values:Zo},Symbol.toStringTag,{value:"Module"})),ys=vf(Jy);var zs={},$i={},Yc;function Xy(){if(Yc)return $i;Yc=1,Object.defineProperty($i,"__esModule",{value:!0}),$i.delay=void 0;function t(e){return new Promise(r=>{setTimeout(()=>{r(!0)},e)})}return $i.delay=t,$i}var Br={},Vs={},Tr={},Zc;function Qy(){return Zc||(Zc=1,Object.defineProperty(Tr,"__esModule",{value:!0}),Tr.ONE_THOUSAND=Tr.ONE_HUNDRED=void 0,Tr.ONE_HUNDRED=100,Tr.ONE_THOUSAND=1e3),Tr}var Hs={},Jc;function e0(){return Jc||(Jc=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.ONE_YEAR=t.FOUR_WEEKS=t.THREE_WEEKS=t.TWO_WEEKS=t.ONE_WEEK=t.THIRTY_DAYS=t.SEVEN_DAYS=t.FIVE_DAYS=t.THREE_DAYS=t.ONE_DAY=t.TWENTY_FOUR_HOURS=t.TWELVE_HOURS=t.SIX_HOURS=t.THREE_HOURS=t.ONE_HOUR=t.SIXTY_MINUTES=t.THIRTY_MINUTES=t.TEN_MINUTES=t.FIVE_MINUTES=t.ONE_MINUTE=t.SIXTY_SECONDS=t.THIRTY_SECONDS=t.TEN_SECONDS=t.FIVE_SECONDS=t.ONE_SECOND=void 0,t.ONE_SECOND=1,t.FIVE_SECONDS=5,t.TEN_SECONDS=10,t.THIRTY_SECONDS=30,t.SIXTY_SECONDS=60,t.ONE_MINUTE=t.SIXTY_SECONDS,t.FIVE_MINUTES=t.ONE_MINUTE*5,t.TEN_MINUTES=t.ONE_MINUTE*10,t.THIRTY_MINUTES=t.ONE_MINUTE*30,t.SIXTY_MINUTES=t.ONE_MINUTE*60,t.ONE_HOUR=t.SIXTY_MINUTES,t.THREE_HOURS=t.ONE_HOUR*3,t.SIX_HOURS=t.ONE_HOUR*6,t.TWELVE_HOURS=t.ONE_HOUR*12,t.TWENTY_FOUR_HOURS=t.ONE_HOUR*24,t.ONE_DAY=t.TWENTY_FOUR_HOURS,t.THREE_DAYS=t.ONE_DAY*3,t.FIVE_DAYS=t.ONE_DAY*5,t.SEVEN_DAYS=t.ONE_DAY*7,t.THIRTY_DAYS=t.ONE_DAY*30,t.ONE_WEEK=t.SEVEN_DAYS,t.TWO_WEEKS=t.ONE_WEEK*2,t.THREE_WEEKS=t.ONE_WEEK*3,t.FOUR_WEEKS=t.ONE_WEEK*4,t.ONE_YEAR=t.ONE_DAY*365})(Hs)),Hs}var Xc;function Df(){return Xc||(Xc=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=ys;e.__exportStar(Qy(),t),e.__exportStar(e0(),t)})(Vs)),Vs}var Qc;function t0(){if(Qc)return Br;Qc=1,Object.defineProperty(Br,"__esModule",{value:!0}),Br.fromMiliseconds=Br.toMiliseconds=void 0;const t=Df();function e(i){return i*t.ONE_THOUSAND}Br.toMiliseconds=e;function r(i){return Math.floor(i/t.ONE_THOUSAND)}return Br.fromMiliseconds=r,Br}var eu;function r0(){return eu||(eu=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=ys;e.__exportStar(Xy(),t),e.__exportStar(t0(),t)})(zs)),zs}var ii={},tu;function i0(){if(tu)return ii;tu=1,Object.defineProperty(ii,"__esModule",{value:!0}),ii.Watch=void 0;class t{constructor(){this.timestamps=new Map}start(r){if(this.timestamps.has(r))throw new Error(`Watch already started for label: ${r}`);this.timestamps.set(r,{started:Date.now()})}stop(r){const i=this.get(r);if(typeof i.elapsed<"u")throw new Error(`Watch already stopped for label: ${r}`);const n=Date.now()-i.started;this.timestamps.set(r,{started:i.started,elapsed:n})}get(r){const i=this.timestamps.get(r);if(typeof i>"u")throw new Error(`No timestamp found for label: ${r}`);return i}elapsed(r){const i=this.get(r);return i.elapsed||Date.now()-i.started}}return ii.Watch=t,ii.default=t,ii}var Ks={},Ci={},ru;function n0(){if(ru)return Ci;ru=1,Object.defineProperty(Ci,"__esModule",{value:!0}),Ci.IWatch=void 0;class t{}return Ci.IWatch=t,Ci}var iu;function s0(){return iu||(iu=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),ys.__exportStar(n0(),t)})(Ks)),Ks}var nu;function o0(){return nu||(nu=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=ys;e.__exportStar(r0(),t),e.__exportStar(i0(),t),e.__exportStar(s0(),t),e.__exportStar(Df(),t)})(qs)),qs}var V=o0(),se={},su;function xf(){if(su)return se;su=1,Object.defineProperty(se,"__esModule",{value:!0}),se.getLocalStorage=se.getLocalStorageOrThrow=se.getCrypto=se.getCryptoOrThrow=se.getLocation=se.getLocationOrThrow=se.getNavigator=se.getNavigatorOrThrow=se.getDocument=se.getDocumentOrThrow=se.getFromWindowOrThrow=se.getFromWindow=void 0;function t(f){let g;return typeof window<"u"&&typeof window[f]<"u"&&(g=window[f]),g}se.getFromWindow=t;function e(f){const g=t(f);if(!g)throw new Error(`${f} is not defined in Window`);return g}se.getFromWindowOrThrow=e;function r(){return e("document")}se.getDocumentOrThrow=r;function i(){return t("document")}se.getDocument=i;function n(){return e("navigator")}se.getNavigatorOrThrow=n;function s(){return t("navigator")}se.getNavigator=s;function o(){return e("location")}se.getLocationOrThrow=o;function a(){return t("location")}se.getLocation=a;function c(){return e("crypto")}se.getCryptoOrThrow=c;function u(){return t("crypto")}se.getCrypto=u;function l(){return e("localStorage")}se.getLocalStorageOrThrow=l;function h(){return t("localStorage")}return se.getLocalStorage=h,se}var sr=xf(),Pi={},ou;function a0(){if(ou)return Pi;ou=1,Object.defineProperty(Pi,"__esModule",{value:!0}),Pi.getWindowMetadata=void 0;const t=xf();function e(){let r,i;try{r=t.getDocumentOrThrow(),i=t.getLocationOrThrow()}catch{return null}function n(){const g=r.getElementsByTagName("link"),p=[];for(let y=0;y<g.length;y++){const m=g[y],x=m.getAttribute("rel");if(x&&x.toLowerCase().indexOf("icon")>-1){const S=m.getAttribute("href");if(S)if(S.toLowerCase().indexOf("https:")===-1&&S.toLowerCase().indexOf("http:")===-1&&S.indexOf("//")!==0){let v=i.protocol+"//"+i.host;if(S.indexOf("/")===0)v+=S;else{const b=i.pathname.split("/");b.pop();const E=b.join("/");v+=E+"/"+S}p.push(v)}else if(S.indexOf("//")===0){const v=i.protocol+S;p.push(v)}else p.push(S)}}return p}function s(...g){const p=r.getElementsByTagName("meta");for(let y=0;y<p.length;y++){const m=p[y],x=["itemprop","property","name"].map(S=>m.getAttribute(S)).filter(S=>S?g.includes(S):!1);if(x.length&&x){const S=m.getAttribute("content");if(S)return S}}return""}function o(){let g=s("name","og:site_name","og:title","twitter:title");return g||(g=r.title),g}function a(){return s("description","og:description","twitter:description","keywords")}const c=o(),u=a(),l=i.origin,h=n();return{description:u,url:l,icons:h,name:c}}return Pi.getWindowMetadata=e,Pi}var c0=a0();const u0="0.1.1";function l0(){return u0}class he extends Error{constructor(e,r={}){const i=(()=>{if(r.cause instanceof he){if(r.cause.details)return r.cause.details;if(r.cause.shortMessage)return r.cause.shortMessage}return r.cause&&"details"in r.cause&&typeof r.cause.details=="string"?r.cause.details:r.cause?.message?r.cause.message:r.details})(),n=r.cause instanceof he&&r.cause.docsPath||r.docsPath,o=`https://oxlib.sh${n??""}`,a=[e||"An error occurred.",...r.metaMessages?["",...r.metaMessages]:[],...i||n?["",i?`Details: ${i}`:void 0,n?`See: ${o}`:void 0]:[]].filter(c=>typeof c=="string").join(`
3
- `);super(a,r.cause?{cause:r.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:`ox@${l0()}`}),this.cause=r.cause,this.details=i,this.docs=o,this.docsPath=n,this.shortMessage=e}walk(e){return _f(this,e)}}function _f(t,e){return e?.(t)?t:t&&typeof t=="object"&&"cause"in t&&t.cause?_f(t.cause,e):e?null:t}const ni=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function h0(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function rn(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function Gr(t,...e){if(!h0(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function f0(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");rn(t.outputLen),rn(t.blockLen)}function Di(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function If(t,e){Gr(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function d0(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function xi(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function Ws(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function $t(t,e){return t<<32-e|t>>>e}const p0=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function g0(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function y0(t){for(let e=0;e<t.length;e++)t[e]=g0(t[e]);return t}const au=p0?t=>t:y0;function w0(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function ws(t){return typeof t=="string"&&(t=w0(t)),Gr(t),t}function b0(...t){let e=0;for(let i=0;i<t.length;i++){const n=t[i];Gr(n),e+=n.length}const r=new Uint8Array(e);for(let i=0,n=0;i<t.length;i++){const s=t[i];r.set(s,n),n+=s.length}return r}class Ya{}function Sf(t){const e=i=>t().update(ws(i)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function m0(t=32){if(ni&&typeof ni.getRandomValues=="function")return ni.getRandomValues(new Uint8Array(t));if(ni&&typeof ni.randomBytes=="function")return Uint8Array.from(ni.randomBytes(t));throw new Error("crypto.getRandomValues must be defined")}function v0(t,e,r,i){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,i);const n=BigInt(32),s=BigInt(4294967295),o=Number(r>>n&s),a=Number(r&s),c=i?4:0,u=i?0:4;t.setUint32(e+c,o,i),t.setUint32(e+u,a,i)}function E0(t,e,r){return t&e^~t&r}function D0(t,e,r){return t&e^t&r^e&r}class x0 extends Ya{constructor(e,r,i,n){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=r,this.padOffset=i,this.isLE=n,this.buffer=new Uint8Array(e),this.view=Ws(this.buffer)}update(e){Di(this),e=ws(e),Gr(e);const{view:r,buffer:i,blockLen:n}=this,s=e.length;for(let o=0;o<s;){const a=Math.min(n-this.pos,s-o);if(a===n){const c=Ws(e);for(;n<=s-o;o+=n)this.process(c,o);continue}i.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===n&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Di(this),If(e,this),this.finished=!0;const{buffer:r,view:i,blockLen:n,isLE:s}=this;let{pos:o}=this;r[o++]=128,xi(this.buffer.subarray(o)),this.padOffset>n-o&&(this.process(i,0),o=0);for(let h=o;h<n;h++)r[h]=0;v0(i,n-8,BigInt(this.length*8),s),this.process(i,0);const a=Ws(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=c/4,l=this.get();if(u>l.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<u;h++)a.setUint32(4*h,l[h],s)}digest(){const{buffer:e,outputLen:r}=this;this.digestInto(e);const i=e.slice(0,r);return this.destroy(),i}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:r,buffer:i,length:n,finished:s,destroyed:o,pos:a}=this;return e.destroyed=o,e.finished=s,e.length=n,e.pos=a,n%r&&e.buffer.set(i),e}clone(){return this._cloneInto()}}const cr=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),In=BigInt(2**32-1),cu=BigInt(32);function _0(t,e=!1){return e?{h:Number(t&In),l:Number(t>>cu&In)}:{h:Number(t>>cu&In)|0,l:Number(t&In)|0}}function I0(t,e=!1){const r=t.length;let i=new Uint32Array(r),n=new Uint32Array(r);for(let s=0;s<r;s++){const{h:o,l:a}=_0(t[s],e);[i[s],n[s]]=[o,a]}return[i,n]}const S0=(t,e,r)=>t<<r|e>>>32-r,O0=(t,e,r)=>e<<r|t>>>32-r,A0=(t,e,r)=>e<<r-32|t>>>64-r,$0=(t,e,r)=>t<<r-32|e>>>64-r,C0=BigInt(0),Bi=BigInt(1),P0=BigInt(2),B0=BigInt(7),T0=BigInt(256),R0=BigInt(113),Of=[],Af=[],$f=[];for(let t=0,e=Bi,r=1,i=0;t<24;t++){[r,i]=[i,(2*r+3*i)%5],Of.push(2*(5*i+r)),Af.push((t+1)*(t+2)/2%64);let n=C0;for(let s=0;s<7;s++)e=(e<<Bi^(e>>B0)*R0)%T0,e&P0&&(n^=Bi<<(Bi<<BigInt(s))-Bi);$f.push(n)}const Cf=I0($f,!0),U0=Cf[0],N0=Cf[1],uu=(t,e,r)=>r>32?A0(t,e,r):S0(t,e,r),lu=(t,e,r)=>r>32?$0(t,e,r):O0(t,e,r);function j0(t,e=24){const r=new Uint32Array(10);for(let i=24-e;i<24;i++){for(let o=0;o<10;o++)r[o]=t[o]^t[o+10]^t[o+20]^t[o+30]^t[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,u=r[c],l=r[c+1],h=uu(u,l,1)^r[a],f=lu(u,l,1)^r[a+1];for(let g=0;g<50;g+=10)t[o+g]^=h,t[o+g+1]^=f}let n=t[2],s=t[3];for(let o=0;o<24;o++){const a=Af[o],c=uu(n,s,a),u=lu(n,s,a),l=Of[o];n=t[l],s=t[l+1],t[l]=c,t[l+1]=u}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)r[a]=t[o+a];for(let a=0;a<10;a++)t[o+a]^=~r[(a+2)%10]&r[(a+4)%10]}t[0]^=U0[i],t[1]^=N0[i]}xi(r)}class Za extends Ya{constructor(e,r,i,n=!1,s=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=e,this.suffix=r,this.outputLen=i,this.enableXOF=n,this.rounds=s,rn(i),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=d0(this.state)}clone(){return this._cloneInto()}keccak(){au(this.state32),j0(this.state32,this.rounds),au(this.state32),this.posOut=0,this.pos=0}update(e){Di(this),e=ws(e),Gr(e);const{blockLen:r,state:i}=this,n=e.length;for(let s=0;s<n;){const o=Math.min(r-this.pos,n-s);for(let a=0;a<o;a++)i[this.pos++]^=e[s++];this.pos===r&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:r,pos:i,blockLen:n}=this;e[i]^=r,(r&128)!==0&&i===n-1&&this.keccak(),e[n-1]^=128,this.keccak()}writeInto(e){Di(this,!1),Gr(e),this.finish();const r=this.state,{blockLen:i}=this;for(let n=0,s=e.length;n<s;){this.posOut>=i&&this.keccak();const o=Math.min(i-this.posOut,s-n);e.set(r.subarray(this.posOut,this.posOut+o),n),this.posOut+=o,n+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return rn(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(If(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,xi(this.state)}_cloneInto(e){const{blockLen:r,suffix:i,outputLen:n,rounds:s,enableXOF:o}=this;return e||(e=new Za(r,i,n,o,s)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=s,e.suffix=i,e.outputLen=n,e.enableXOF=o,e.destroyed=this.destroyed,e}}const k0=(t,e,r)=>Sf(()=>new Za(e,t,r)),F0=k0(1,136,256/8),L0=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]),ur=new Uint32Array(64);class M0 extends x0{constructor(e=32){super(64,e,8,!1),this.A=cr[0]|0,this.B=cr[1]|0,this.C=cr[2]|0,this.D=cr[3]|0,this.E=cr[4]|0,this.F=cr[5]|0,this.G=cr[6]|0,this.H=cr[7]|0}get(){const{A:e,B:r,C:i,D:n,E:s,F:o,G:a,H:c}=this;return[e,r,i,n,s,o,a,c]}set(e,r,i,n,s,o,a,c){this.A=e|0,this.B=r|0,this.C=i|0,this.D=n|0,this.E=s|0,this.F=o|0,this.G=a|0,this.H=c|0}process(e,r){for(let h=0;h<16;h++,r+=4)ur[h]=e.getUint32(r,!1);for(let h=16;h<64;h++){const f=ur[h-15],g=ur[h-2],p=$t(f,7)^$t(f,18)^f>>>3,y=$t(g,17)^$t(g,19)^g>>>10;ur[h]=y+ur[h-7]+p+ur[h-16]|0}let{A:i,B:n,C:s,D:o,E:a,F:c,G:u,H:l}=this;for(let h=0;h<64;h++){const f=$t(a,6)^$t(a,11)^$t(a,25),g=l+f+E0(a,c,u)+L0[h]+ur[h]|0,y=($t(i,2)^$t(i,13)^$t(i,22))+D0(i,n,s)|0;l=u,u=c,c=a,a=o+g|0,o=s,s=n,n=i,i=g+y|0}i=i+this.A|0,n=n+this.B|0,s=s+this.C|0,o=o+this.D|0,a=a+this.E|0,c=c+this.F|0,u=u+this.G|0,l=l+this.H|0,this.set(i,n,s,o,a,c,u,l)}roundClean(){xi(ur)}destroy(){this.set(0,0,0,0,0,0,0,0),xi(this.buffer)}}const q0=Sf(()=>new M0);const Ja=BigInt(0),Jo=BigInt(1);function hn(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Xa(t){if(!hn(t))throw new Error("Uint8Array expected")}function nn(t,e){if(typeof e!="boolean")throw new Error(t+" boolean expected, got "+e)}function Sn(t){const e=t.toString(16);return e.length&1?"0"+e:e}function Pf(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?Ja:BigInt("0x"+t)}const Bf=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",z0=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function sn(t){if(Xa(t),Bf)return t.toHex();let e="";for(let r=0;r<t.length;r++)e+=z0[t[r]];return e}const zt={_0:48,_9:57,A:65,F:70,a:97,f:102};function hu(t){if(t>=zt._0&&t<=zt._9)return t-zt._0;if(t>=zt.A&&t<=zt.F)return t-(zt.A-10);if(t>=zt.a&&t<=zt.f)return t-(zt.a-10)}function Qn(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);if(Bf)return Uint8Array.fromHex(t);const e=t.length,r=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const i=new Uint8Array(r);for(let n=0,s=0;n<r;n++,s+=2){const o=hu(t.charCodeAt(s)),a=hu(t.charCodeAt(s+1));if(o===void 0||a===void 0){const c=t[s]+t[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}i[n]=o*16+a}return i}function Wr(t){return Pf(sn(t))}function Tf(t){return Xa(t),Pf(sn(Uint8Array.from(t).reverse()))}function fn(t,e){return Qn(t.toString(16).padStart(e*2,"0"))}function Rf(t,e){return fn(t,e).reverse()}function gt(t,e,r){let i;if(typeof e=="string")try{i=Qn(e)}catch(s){throw new Error(t+" must be hex string or Uint8Array, cause: "+s)}else if(hn(e))i=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");const n=i.length;if(typeof r=="number"&&n!==r)throw new Error(t+" of length "+r+" expected, got "+n);return i}function es(...t){let e=0;for(let i=0;i<t.length;i++){const n=t[i];Xa(n),e+=n.length}const r=new Uint8Array(e);for(let i=0,n=0;i<t.length;i++){const s=t[i];r.set(s,n),n+=s.length}return r}const Gs=t=>typeof t=="bigint"&&Ja<=t;function Qa(t,e,r){return Gs(t)&&Gs(e)&&Gs(r)&&e<=t&&t<r}function wi(t,e,r,i){if(!Qa(e,r,i))throw new Error("expected valid "+t+": "+r+" <= n < "+i+", got "+e)}function V0(t){let e;for(e=0;t>Ja;t>>=Jo,e+=1);return e}const bs=t=>(Jo<<BigInt(t))-Jo,Ys=t=>new Uint8Array(t),fu=t=>Uint8Array.from(t);function H0(t,e,r){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof r!="function")throw new Error("hmacFn must be a function");let i=Ys(t),n=Ys(t),s=0;const o=()=>{i.fill(1),n.fill(0),s=0},a=(...h)=>r(n,i,...h),c=(h=Ys(0))=>{n=a(fu([0]),h),i=a(),h.length!==0&&(n=a(fu([1]),h),i=a())},u=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let h=0;const f=[];for(;h<e;){i=a();const g=i.slice();f.push(g),h+=i.length}return es(...f)};return(h,f)=>{o(),c(h);let g;for(;!(g=f(u()));)c();return o(),g}}const K0={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||hn(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function ms(t,e,r={}){const i=(n,s,o)=>{const a=K0[s];if(typeof a!="function")throw new Error("invalid validator function");const c=t[n];if(!(o&&c===void 0)&&!a(c,t))throw new Error("param "+String(n)+" is invalid. Expected "+s+", got "+c)};for(const[n,s]of Object.entries(e))i(n,s,!1);for(const[n,s]of Object.entries(r))i(n,s,!0);return t}function du(t){const e=new WeakMap;return(r,...i)=>{const n=e.get(r);if(n!==void 0)return n;const s=t(r,...i);return e.set(r,s),s}}function W0(t,e){if(wu(t)>e)throw new pw({givenSize:wu(t),maxSize:e})}const Vt={zero:48,nine:57,A:65,F:70,a:97,f:102};function pu(t){if(t>=Vt.zero&&t<=Vt.nine)return t-Vt.zero;if(t>=Vt.A&&t<=Vt.F)return t-(Vt.A-10);if(t>=Vt.a&&t<=Vt.f)return t-(Vt.a-10)}function G0(t,e={}){const{dir:r,size:i=32}=e;if(i===0)return t;if(t.length>i)throw new gw({size:t.length,targetSize:i,type:"Bytes"});const n=new Uint8Array(i);for(let s=0;s<i;s++){const o=r==="right";n[o?s:i-s-1]=t[o?s:t.length-s-1]}return n}function Uf(t,e){if(Sr(t)>e)throw new nw({givenSize:Sr(t),maxSize:e})}function Y0(t,e){if(typeof e=="number"&&e>0&&e>Sr(t)-1)throw new kf({offset:e,position:"start",size:Sr(t)})}function Z0(t,e,r){if(typeof e=="number"&&typeof r=="number"&&Sr(t)!==r-e)throw new kf({offset:r,position:"end",size:Sr(t)})}function Nf(t,e={}){const{dir:r,size:i=32}=e;if(i===0)return t;const n=t.replace("0x","");if(n.length>i*2)throw new sw({size:Math.ceil(n.length/2),targetSize:i,type:"Hex"});return`0x${n[r==="right"?"padEnd":"padStart"](i*2,"0")}`}const J0="#__bigint";function ec(t,e,r){return JSON.stringify(t,(i,n)=>typeof n=="bigint"?n.toString()+J0:n,r)}const X0=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Q0(t,e={}){const{strict:r=!1}=e;if(!t)throw new gu(t);if(typeof t!="string")throw new gu(t);if(r&&!/^0x[0-9a-fA-F]*$/.test(t))throw new yu(t);if(!t.startsWith("0x"))throw new yu(t)}function ew(...t){return`0x${t.reduce((e,r)=>e+r.replace("0x",""),"")}`}function tc(t){return t instanceof Uint8Array?ts(t):Array.isArray(t)?ts(new Uint8Array(t)):t}function ts(t,e={}){let r="";for(let n=0;n<t.length;n++)r+=X0[t[n]];const i=`0x${r}`;return typeof e.size=="number"?(Uf(i,e.size),jf(i,e.size)):i}function Zs(t,e={}){const{signed:r,size:i}=e,n=BigInt(t);let s;i?r?s=(1n<<BigInt(i)*8n-1n)-1n:s=2n**(BigInt(i)*8n)-1n:typeof t=="number"&&(s=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof s=="bigint"&&r?-s-1n:0;if(s&&n>s||n<o){const u=typeof t=="bigint"?"n":"";throw new iw({max:s?`${s}${u}`:void 0,min:`${o}${u}`,signed:r,size:i,value:`${t}${u}`})}const c=`0x${(r&&n<0?(1n<<BigInt(i*8))+BigInt(n):n).toString(16)}`;return i?tw(c,i):c}function tw(t,e){return Nf(t,{dir:"left",size:e})}function jf(t,e){return Nf(t,{dir:"right",size:e})}function Xt(t,e,r,i={}){const{strict:n}=i;Y0(t,e);const s=`0x${t.replace("0x","").slice((e??0)*2,(r??t.length)*2)}`;return n&&Z0(s,e,r),s}function Sr(t){return Math.ceil((t.length-2)/2)}function rw(t,e={}){const{strict:r=!1}=e;try{return Q0(t,{strict:r}),!0}catch{return!1}}class iw extends he{constructor({max:e,min:r,signed:i,size:n,value:s}){super(`Number \`${s}\` is not in safe${n?` ${n*8}-bit`:""}${i?" signed":" unsigned"} integer range ${e?`(\`${r}\` to \`${e}\`)`:`(above \`${r}\`)`}`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.IntegerOutOfRangeError"})}}class gu extends he{constructor(e){super(`Value \`${typeof e=="object"?ec(e):e}\` of type \`${typeof e}\` is an invalid hex type.`,{metaMessages:['Hex types must be represented as `"0x${string}"`.']}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.InvalidHexTypeError"})}}class yu extends he{constructor(e){super(`Value \`${e}\` is an invalid hex value.`,{metaMessages:['Hex values must start with `"0x"` and contain only hexadecimal characters (0-9, a-f, A-F).']}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.InvalidHexValueError"})}}let nw=class extends he{constructor({givenSize:e,maxSize:r}){super(`Size cannot exceed \`${r}\` bytes. Given size: \`${e}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeOverflowError"})}};class kf extends he{constructor({offset:e,position:r,size:i}){super(`Slice ${r==="start"?"starting":"ending"} at offset \`${e}\` is out-of-bounds (size: \`${i}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SliceOffsetOutOfBoundsError"})}}let sw=class extends he{constructor({size:e,targetSize:r,type:i}){super(`${i.charAt(0).toUpperCase()}${i.slice(1).toLowerCase()} size (\`${e}\`) exceeds padding size (\`${r}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeExceedsPaddingSizeError"})}};const ow=new TextEncoder;function aw(t){if(!(t instanceof Uint8Array)){if(!t)throw new On(t);if(typeof t!="object")throw new On(t);if(!("BYTES_PER_ELEMENT"in t))throw new On(t);if(t.BYTES_PER_ELEMENT!==1||t.constructor.name!=="Uint8Array")throw new On(t)}}function cw(t){return t instanceof Uint8Array?t:typeof t=="string"?lw(t):uw(t)}function uw(t){return t instanceof Uint8Array?t:new Uint8Array(t)}function lw(t,e={}){const{size:r}=e;let i=t;r&&(Uf(t,r),i=jf(t,r));let n=i.slice(2);n.length%2&&(n=`0${n}`);const s=n.length/2,o=new Uint8Array(s);for(let a=0,c=0;a<s;a++){const u=pu(n.charCodeAt(c++)),l=pu(n.charCodeAt(c++));if(u===void 0||l===void 0)throw new he(`Invalid byte sequence ("${n[c-2]}${n[c-1]}" in "${n}").`);o[a]=u*16+l}return o}function hw(t,e={}){const{size:r}=e,i=ow.encode(t);return typeof r=="number"?(W0(i,r),fw(i,r)):i}function fw(t,e){return G0(t,{dir:"right",size:e})}function wu(t){return t.length}function dw(t){try{return aw(t),!0}catch{return!1}}class On extends he{constructor(e){super(`Value \`${typeof e=="object"?ec(e):e}\` of type \`${typeof e}\` is an invalid Bytes value.`,{metaMessages:["Bytes values must be of type `Bytes`."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.InvalidBytesTypeError"})}}class pw extends he{constructor({givenSize:e,maxSize:r}){super(`Size cannot exceed \`${r}\` bytes. Given size: \`${e}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeOverflowError"})}}class gw extends he{constructor({size:e,targetSize:r,type:i}){super(`${i.charAt(0).toUpperCase()}${i.slice(1).toLowerCase()} size (\`${e}\`) exceeds padding size (\`${r}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeExceedsPaddingSizeError"})}}function Ff(t,e={}){const{as:r=typeof t=="string"?"Hex":"Bytes"}=e,i=F0(cw(t));return r==="Bytes"?i:ts(i)}class yw extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const r=super.get(e);return super.has(e)&&r!==void 0&&(this.delete(e),super.set(e,r)),r}set(e,r){if(super.set(e,r),this.maxSize&&this.size>this.maxSize){const i=this.keys().next().value;i&&this.delete(i)}return this}}const ww={checksum:new yw(8192)},Js=ww.checksum;function Lf(t,e={}){const{compressed:r}=e,{prefix:i,x:n,y:s}=t;if(r===!1||typeof n=="bigint"&&typeof s=="bigint"){if(i!==4)throw new bu({prefix:i,cause:new xw});return}if(r===!0||typeof n=="bigint"&&typeof s>"u"){if(i!==3&&i!==2)throw new bu({prefix:i,cause:new Dw});return}throw new Ew({publicKey:t})}function bw(t){const e=(()=>{if(rw(t))return Mf(t);if(dw(t))return mw(t);const{prefix:r,x:i,y:n}=t;return typeof i=="bigint"&&typeof n=="bigint"?{prefix:r??4,x:i,y:n}:{prefix:r,x:i}})();return Lf(e),e}function mw(t){return Mf(ts(t))}function Mf(t){if(t.length!==132&&t.length!==130&&t.length!==68)throw new _w({publicKey:t});if(t.length===130){const i=BigInt(Xt(t,0,32)),n=BigInt(Xt(t,32,64));return{prefix:4,x:i,y:n}}if(t.length===132){const i=Number(Xt(t,0,1)),n=BigInt(Xt(t,1,33)),s=BigInt(Xt(t,33,65));return{prefix:i,x:n,y:s}}const e=Number(Xt(t,0,1)),r=BigInt(Xt(t,1,33));return{prefix:e,x:r}}function vw(t,e={}){Lf(t);const{prefix:r,x:i,y:n}=t,{includePrefix:s=!0}=e;return ew(s?Zs(r,{size:1}):"0x",Zs(i,{size:32}),typeof n=="bigint"?Zs(n,{size:32}):"0x")}class Ew extends he{constructor({publicKey:e}){super(`Value \`${ec(e)}\` is not a valid public key.`,{metaMessages:["Public key must contain:","- an `x` and `prefix` value (compressed)","- an `x`, `y`, and `prefix` value (uncompressed)"]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidError"})}}class bu extends he{constructor({prefix:e,cause:r}){super(`Prefix "${e}" is invalid.`,{cause:r}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidPrefixError"})}}class Dw extends he{constructor(){super("Prefix must be 2 or 3 for compressed public keys."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidCompressedPrefixError"})}}class xw extends he{constructor(){super("Prefix must be 4 for uncompressed public keys."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidUncompressedPrefixError"})}}let _w=class extends he{constructor({publicKey:e}){super(`Value \`${e}\` is an invalid public key size.`,{metaMessages:["Expected: 33 bytes (compressed + prefix), 64 bytes (uncompressed) or 65 bytes (uncompressed + prefix).",`Received ${Sr(tc(e))} bytes.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidSerializedSizeError"})}};const Iw=/^0x[a-fA-F0-9]{40}$/;function qf(t,e={}){const{strict:r=!0}=e;if(!Iw.test(t))throw new mu({address:t,cause:new Aw});if(r){if(t.toLowerCase()===t)return;if(zf(t)!==t)throw new mu({address:t,cause:new $w})}}function zf(t){if(Js.has(t))return Js.get(t);qf(t,{strict:!1});const e=t.substring(2).toLowerCase(),r=Ff(hw(e),{as:"Bytes"}),i=e.split("");for(let s=0;s<40;s+=2)r[s>>1]>>4>=8&&i[s]&&(i[s]=i[s].toUpperCase()),(r[s>>1]&15)>=8&&i[s+1]&&(i[s+1]=i[s+1].toUpperCase());const n=`0x${i.join("")}`;return Js.set(t,n),n}function Sw(t,e={}){const{checksum:r=!1}=e;return qf(t),r?zf(t):t}function Ow(t,e={}){const r=Ff(`0x${vw(t).slice(4)}`).substring(26);return Sw(`0x${r}`,e)}class mu extends he{constructor({address:e,cause:r}){super(`Address "${e}" is invalid.`,{cause:r}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidAddressError"})}}class Aw extends he{constructor(){super("Address is not a 20 byte (40 hexadecimal character) value."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidInputError"})}}class $w extends he{constructor(){super("Address does not match its checksum counterpart."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidChecksumError"})}}class Vf extends Ya{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,f0(e);const i=ws(r);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const n=this.blockLen,s=new Uint8Array(n);s.set(i.length>n?e.create().update(i).digest():i);for(let o=0;o<s.length;o++)s[o]^=54;this.iHash.update(s),this.oHash=e.create();for(let o=0;o<s.length;o++)s[o]^=106;this.oHash.update(s),xi(s)}update(e){return Di(this),this.iHash.update(e),this}digestInto(e){Di(this),Gr(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:r,iHash:i,finished:n,destroyed:s,blockLen:o,outputLen:a}=this;return e=e,e.finished=n,e.destroyed=s,e.blockLen=o,e.outputLen=a,e.oHash=r._cloneInto(e.oHash),e.iHash=i._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Hf=(t,e,r)=>new Vf(t,e).update(r).digest();Hf.create=(t,e)=>new Vf(t,e);const Je=BigInt(0),Me=BigInt(1),qr=BigInt(2),Cw=BigInt(3),Kf=BigInt(4),Wf=BigInt(5),Gf=BigInt(8);function Ge(t,e){const r=t%e;return r>=Je?r:e+r}function lt(t,e,r){let i=t;for(;e-- >Je;)i*=i,i%=r;return i}function Xo(t,e){if(t===Je)throw new Error("invert: expected non-zero number");if(e<=Je)throw new Error("invert: expected positive modulus, got "+e);let r=Ge(t,e),i=e,n=Je,s=Me;for(;r!==Je;){const a=i/r,c=i%r,u=n-s*a;i=r,r=c,n=s,s=u}if(i!==Me)throw new Error("invert: does not exist");return Ge(n,e)}function Yf(t,e){const r=(t.ORDER+Me)/Kf,i=t.pow(e,r);if(!t.eql(t.sqr(i),e))throw new Error("Cannot find square root");return i}function Pw(t,e){const r=(t.ORDER-Wf)/Gf,i=t.mul(e,qr),n=t.pow(i,r),s=t.mul(e,n),o=t.mul(t.mul(s,qr),n),a=t.mul(s,t.sub(o,t.ONE));if(!t.eql(t.sqr(a),e))throw new Error("Cannot find square root");return a}function Bw(t){if(t<BigInt(3))throw new Error("sqrt is not defined for small field");let e=t-Me,r=0;for(;e%qr===Je;)e/=qr,r++;let i=qr;const n=rc(t);for(;vu(n,i)===1;)if(i++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return Yf;let s=n.pow(i,e);const o=(e+Me)/qr;return function(c,u){if(c.is0(u))return u;if(vu(c,u)!==1)throw new Error("Cannot find square root");let l=r,h=c.mul(c.ONE,s),f=c.pow(u,e),g=c.pow(u,o);for(;!c.eql(f,c.ONE);){if(c.is0(f))return c.ZERO;let p=1,y=c.sqr(f);for(;!c.eql(y,c.ONE);)if(p++,y=c.sqr(y),p===l)throw new Error("Cannot find square root");const m=Me<<BigInt(l-p-1),x=c.pow(h,m);l=p,h=c.sqr(x),f=c.mul(f,h),g=c.mul(g,x)}return g}}function Tw(t){return t%Kf===Cw?Yf:t%Gf===Wf?Pw:Bw(t)}const Rw=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Uw(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=Rw.reduce((i,n)=>(i[n]="function",i),e);return ms(t,r)}function Nw(t,e,r){if(r<Je)throw new Error("invalid exponent, negatives unsupported");if(r===Je)return t.ONE;if(r===Me)return e;let i=t.ONE,n=e;for(;r>Je;)r&Me&&(i=t.mul(i,n)),n=t.sqr(n),r>>=Me;return i}function Zf(t,e,r=!1){const i=new Array(e.length).fill(r?t.ZERO:void 0),n=e.reduce((o,a,c)=>t.is0(a)?o:(i[c]=o,t.mul(o,a)),t.ONE),s=t.inv(n);return e.reduceRight((o,a,c)=>t.is0(a)?o:(i[c]=t.mul(o,i[c]),t.mul(o,a)),s),i}function vu(t,e){const r=(t.ORDER-Me)/qr,i=t.pow(e,r),n=t.eql(i,t.ONE),s=t.eql(i,t.ZERO),o=t.eql(i,t.neg(t.ONE));if(!n&&!s&&!o)throw new Error("invalid Legendre symbol result");return n?1:s?0:-1}function Jf(t,e){e!==void 0&&rn(e);const r=e!==void 0?e:t.toString(2).length,i=Math.ceil(r/8);return{nBitLength:r,nByteLength:i}}function rc(t,e,r=!1,i={}){if(t<=Je)throw new Error("invalid field: expected ORDER > 0, got "+t);const{nBitLength:n,nByteLength:s}=Jf(t,e);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let o;const a=Object.freeze({ORDER:t,isLE:r,BITS:n,BYTES:s,MASK:bs(n),ZERO:Je,ONE:Me,create:c=>Ge(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return Je<=c&&c<t},is0:c=>c===Je,isOdd:c=>(c&Me)===Me,neg:c=>Ge(-c,t),eql:(c,u)=>c===u,sqr:c=>Ge(c*c,t),add:(c,u)=>Ge(c+u,t),sub:(c,u)=>Ge(c-u,t),mul:(c,u)=>Ge(c*u,t),pow:(c,u)=>Nw(a,c,u),div:(c,u)=>Ge(c*Xo(u,t),t),sqrN:c=>c*c,addN:(c,u)=>c+u,subN:(c,u)=>c-u,mulN:(c,u)=>c*u,inv:c=>Xo(c,t),sqrt:i.sqrt||(c=>(o||(o=Tw(t)),o(a,c))),toBytes:c=>r?Rf(c,s):fn(c,s),fromBytes:c=>{if(c.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+c.length);return r?Tf(c):Wr(c)},invertBatch:c=>Zf(a,c),cmov:(c,u,l)=>l?u:c});return Object.freeze(a)}function Xf(t){if(typeof t!="bigint")throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function Qf(t){const e=Xf(t);return e+Math.ceil(e/2)}function jw(t,e,r=!1){const i=t.length,n=Xf(e),s=Qf(e);if(i<16||i<s||i>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+i);const o=r?Tf(t):Wr(t),a=Ge(o,e-Me)+Me;return r?Rf(a,n):fn(a,n)}const Eu=BigInt(0),Qo=BigInt(1);function Xs(t,e){const r=e.negate();return t?r:e}function ed(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function Qs(t,e){ed(t,e);const r=Math.ceil(e/t)+1,i=2**(t-1),n=2**t,s=bs(t),o=BigInt(t);return{windows:r,windowSize:i,mask:s,maxNumber:n,shiftBy:o}}function Du(t,e,r){const{windowSize:i,mask:n,maxNumber:s,shiftBy:o}=r;let a=Number(t&n),c=t>>o;a>i&&(a-=s,c+=Qo);const u=e*i,l=u+Math.abs(a)-1,h=a===0,f=a<0,g=e%2!==0;return{nextN:c,offset:l,isZero:h,isNeg:f,isNegF:g,offsetF:u}}function kw(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((r,i)=>{if(!(r instanceof e))throw new Error("invalid point at index "+i)})}function Fw(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((r,i)=>{if(!e.isValid(r))throw new Error("invalid scalar at index "+i)})}const eo=new WeakMap,td=new WeakMap;function to(t){return td.get(t)||1}function Lw(t,e){return{constTimeNegate:Xs,hasPrecomputes(r){return to(r)!==1},unsafeLadder(r,i,n=t.ZERO){let s=r;for(;i>Eu;)i&Qo&&(n=n.add(s)),s=s.double(),i>>=Qo;return n},precomputeWindow(r,i){const{windows:n,windowSize:s}=Qs(i,e),o=[];let a=r,c=a;for(let u=0;u<n;u++){c=a,o.push(c);for(let l=1;l<s;l++)c=c.add(a),o.push(c);a=c.double()}return o},wNAF(r,i,n){let s=t.ZERO,o=t.BASE;const a=Qs(r,e);for(let c=0;c<a.windows;c++){const{nextN:u,offset:l,isZero:h,isNeg:f,isNegF:g,offsetF:p}=Du(n,c,a);n=u,h?o=o.add(Xs(g,i[p])):s=s.add(Xs(f,i[l]))}return{p:s,f:o}},wNAFUnsafe(r,i,n,s=t.ZERO){const o=Qs(r,e);for(let a=0;a<o.windows&&n!==Eu;a++){const{nextN:c,offset:u,isZero:l,isNeg:h}=Du(n,a,o);if(n=c,!l){const f=i[u];s=s.add(h?f.negate():f)}}return s},getPrecomputes(r,i,n){let s=eo.get(i);return s||(s=this.precomputeWindow(i,r),r!==1&&eo.set(i,n(s))),s},wNAFCached(r,i,n){const s=to(r);return this.wNAF(s,this.getPrecomputes(s,r,n),i)},wNAFCachedUnsafe(r,i,n,s){const o=to(r);return o===1?this.unsafeLadder(r,i,s):this.wNAFUnsafe(o,this.getPrecomputes(o,r,n),i,s)},setWindowSize(r,i){ed(i,e),td.set(r,i),eo.delete(r)}}}function Mw(t,e,r,i){kw(r,t),Fw(i,e);const n=r.length,s=i.length;if(n!==s)throw new Error("arrays of points and scalars must have equal length");const o=t.ZERO,a=V0(BigInt(n));let c=1;a>12?c=a-3:a>4?c=a-2:a>0&&(c=2);const u=bs(c),l=new Array(Number(u)+1).fill(o),h=Math.floor((e.BITS-1)/c)*c;let f=o;for(let g=h;g>=0;g-=c){l.fill(o);for(let y=0;y<s;y++){const m=i[y],x=Number(m>>BigInt(g)&u);l[x]=l[x].add(r[y])}let p=o;for(let y=l.length-1,m=o;y>0;y--)m=m.add(l[y]),p=p.add(m);if(f=f.add(p),g!==0)for(let y=0;y<c;y++)f=f.double()}return f}function rd(t){return Uw(t.Fp),ms(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Jf(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}function xu(t){t.lowS!==void 0&&nn("lowS",t.lowS),t.prehash!==void 0&&nn("prehash",t.prehash)}function qw(t){const e=rd(t);ms(e,{a:"field",b:"field"},{allowInfinityPoint:"boolean",allowedPrivateKeyLengths:"array",clearCofactor:"function",fromBytes:"function",isTorsionFree:"function",toBytes:"function",wrapPrivateKey:"boolean"});const{endo:r,Fp:i,a:n}=e;if(r){if(!i.eql(n,i.ZERO))throw new Error("invalid endo: CURVE.a must be 0");if(typeof r!="object"||typeof r.beta!="bigint"||typeof r.splitScalar!="function")throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function')}return Object.freeze({...e})}class zw extends Error{constructor(e=""){super(e)}}const Qt={Err:zw,_tlv:{encode:(t,e)=>{const{Err:r}=Qt;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length&1)throw new r("tlv.encode: unpadded data");const i=e.length/2,n=Sn(i);if(n.length/2&128)throw new r("tlv.encode: long form length too big");const s=i>127?Sn(n.length/2|128):"";return Sn(t)+s+n+e},decode(t,e){const{Err:r}=Qt;let i=0;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length<2||e[i++]!==t)throw new r("tlv.decode: wrong tlv");const n=e[i++],s=!!(n&128);let o=0;if(!s)o=n;else{const c=n&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");const u=e.subarray(i,i+c);if(u.length!==c)throw new r("tlv.decode: length bytes not complete");if(u[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(const l of u)o=o<<8|l;if(i+=c,o<128)throw new r("tlv.decode(long): not minimal encoding")}const a=e.subarray(i,i+o);if(a.length!==o)throw new r("tlv.decode: wrong value length");return{v:a,l:e.subarray(i+o)}}},_int:{encode(t){const{Err:e}=Qt;if(t<tr)throw new e("integer: negative integers are not allowed");let r=Sn(t);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return r},decode(t){const{Err:e}=Qt;if(t[0]&128)throw new e("invalid signature integer: negative");if(t[0]===0&&!(t[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return Wr(t)}},toSig(t){const{Err:e,_int:r,_tlv:i}=Qt,n=gt("signature",t),{v:s,l:o}=i.decode(48,n);if(o.length)throw new e("invalid signature: left bytes after parsing");const{v:a,l:c}=i.decode(2,s),{v:u,l}=i.decode(2,c);if(l.length)throw new e("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(u)}},hexFromSig(t){const{_tlv:e,_int:r}=Qt,i=e.encode(2,r.encode(t.r)),n=e.encode(2,r.encode(t.s)),s=i+n;return e.encode(48,s)}};function ro(t,e){return sn(fn(t,e))}const tr=BigInt(0),Se=BigInt(1);BigInt(2);const io=BigInt(3),Vw=BigInt(4);function Hw(t){const e=qw(t),{Fp:r}=e,i=rc(e.n,e.nBitLength),n=e.toBytes||((v,b,E)=>{const I=b.toAffine();return es(Uint8Array.from([4]),r.toBytes(I.x),r.toBytes(I.y))}),s=e.fromBytes||(v=>{const b=v.subarray(1),E=r.fromBytes(b.subarray(0,r.BYTES)),I=r.fromBytes(b.subarray(r.BYTES,2*r.BYTES));return{x:E,y:I}});function o(v){const{a:b,b:E}=e,I=r.sqr(v),$=r.mul(I,v);return r.add(r.add($,r.mul(v,b)),E)}function a(v,b){const E=r.sqr(b),I=o(v);return r.eql(E,I)}if(!a(e.Gx,e.Gy))throw new Error("bad curve params: generator point");const c=r.mul(r.pow(e.a,io),Vw),u=r.mul(r.sqr(e.b),BigInt(27));if(r.is0(r.add(c,u)))throw new Error("bad curve params: a or b");function l(v){return Qa(v,Se,e.n)}function h(v){const{allowedPrivateKeyLengths:b,nByteLength:E,wrapPrivateKey:I,n:$}=e;if(b&&typeof v!="bigint"){if(hn(v)&&(v=sn(v)),typeof v!="string"||!b.includes(v.length))throw new Error("invalid private key");v=v.padStart(E*2,"0")}let B;try{B=typeof v=="bigint"?v:Wr(gt("private key",v,E))}catch{throw new Error("invalid private key, expected hex or "+E+" bytes, got "+typeof v)}return I&&(B=Ge(B,$)),wi("private key",B,Se,$),B}function f(v){if(!(v instanceof y))throw new Error("ProjectivePoint expected")}const g=du((v,b)=>{const{px:E,py:I,pz:$}=v;if(r.eql($,r.ONE))return{x:E,y:I};const B=v.is0();b==null&&(b=B?r.ONE:r.inv($));const C=r.mul(E,b),k=r.mul(I,b),F=r.mul($,b);if(B)return{x:r.ZERO,y:r.ZERO};if(!r.eql(F,r.ONE))throw new Error("invZ was invalid");return{x:C,y:k}}),p=du(v=>{if(v.is0()){if(e.allowInfinityPoint&&!r.is0(v.py))return;throw new Error("bad point: ZERO")}const{x:b,y:E}=v.toAffine();if(!r.isValid(b)||!r.isValid(E))throw new Error("bad point: x or y not FE");if(!a(b,E))throw new Error("bad point: equation left != right");if(!v.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class y{constructor(b,E,I){if(b==null||!r.isValid(b))throw new Error("x required");if(E==null||!r.isValid(E)||r.is0(E))throw new Error("y required");if(I==null||!r.isValid(I))throw new Error("z required");this.px=b,this.py=E,this.pz=I,Object.freeze(this)}static fromAffine(b){const{x:E,y:I}=b||{};if(!b||!r.isValid(E)||!r.isValid(I))throw new Error("invalid affine point");if(b instanceof y)throw new Error("projective point not allowed");const $=B=>r.eql(B,r.ZERO);return $(E)&&$(I)?y.ZERO:new y(E,I,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(b){const E=Zf(r,b.map(I=>I.pz));return b.map((I,$)=>I.toAffine(E[$])).map(y.fromAffine)}static fromHex(b){const E=y.fromAffine(s(gt("pointHex",b)));return E.assertValidity(),E}static fromPrivateKey(b){return y.BASE.multiply(h(b))}static msm(b,E){return Mw(y,i,b,E)}_setWindowSize(b){S.setWindowSize(this,b)}assertValidity(){p(this)}hasEvenY(){const{y:b}=this.toAffine();if(r.isOdd)return!r.isOdd(b);throw new Error("Field doesn't support isOdd")}equals(b){f(b);const{px:E,py:I,pz:$}=this,{px:B,py:C,pz:k}=b,F=r.eql(r.mul(E,k),r.mul(B,$)),R=r.eql(r.mul(I,k),r.mul(C,$));return F&&R}negate(){return new y(this.px,r.neg(this.py),this.pz)}double(){const{a:b,b:E}=e,I=r.mul(E,io),{px:$,py:B,pz:C}=this;let k=r.ZERO,F=r.ZERO,R=r.ZERO,P=r.mul($,$),T=r.mul(B,B),d=r.mul(C,C),w=r.mul($,B);return w=r.add(w,w),R=r.mul($,C),R=r.add(R,R),k=r.mul(b,R),F=r.mul(I,d),F=r.add(k,F),k=r.sub(T,F),F=r.add(T,F),F=r.mul(k,F),k=r.mul(w,k),R=r.mul(I,R),d=r.mul(b,d),w=r.sub(P,d),w=r.mul(b,w),w=r.add(w,R),R=r.add(P,P),P=r.add(R,P),P=r.add(P,d),P=r.mul(P,w),F=r.add(F,P),d=r.mul(B,C),d=r.add(d,d),P=r.mul(d,w),k=r.sub(k,P),R=r.mul(d,T),R=r.add(R,R),R=r.add(R,R),new y(k,F,R)}add(b){f(b);const{px:E,py:I,pz:$}=this,{px:B,py:C,pz:k}=b;let F=r.ZERO,R=r.ZERO,P=r.ZERO;const T=e.a,d=r.mul(e.b,io);let w=r.mul(E,B),D=r.mul(I,C),O=r.mul($,k),_=r.add(E,I),A=r.add(B,C);_=r.mul(_,A),A=r.add(w,D),_=r.sub(_,A),A=r.add(E,$);let N=r.add(B,k);return A=r.mul(A,N),N=r.add(w,O),A=r.sub(A,N),N=r.add(I,$),F=r.add(C,k),N=r.mul(N,F),F=r.add(D,O),N=r.sub(N,F),P=r.mul(T,A),F=r.mul(d,O),P=r.add(F,P),F=r.sub(D,P),P=r.add(D,P),R=r.mul(F,P),D=r.add(w,w),D=r.add(D,w),O=r.mul(T,O),A=r.mul(d,A),D=r.add(D,O),O=r.sub(w,O),O=r.mul(T,O),A=r.add(A,O),w=r.mul(D,A),R=r.add(R,w),w=r.mul(N,A),F=r.mul(_,F),F=r.sub(F,w),w=r.mul(_,D),P=r.mul(N,P),P=r.add(P,w),new y(F,R,P)}subtract(b){return this.add(b.negate())}is0(){return this.equals(y.ZERO)}wNAF(b){return S.wNAFCached(this,b,y.normalizeZ)}multiplyUnsafe(b){const{endo:E,n:I}=e;wi("scalar",b,tr,I);const $=y.ZERO;if(b===tr)return $;if(this.is0()||b===Se)return this;if(!E||S.hasPrecomputes(this))return S.wNAFCachedUnsafe(this,b,y.normalizeZ);let{k1neg:B,k1:C,k2neg:k,k2:F}=E.splitScalar(b),R=$,P=$,T=this;for(;C>tr||F>tr;)C&Se&&(R=R.add(T)),F&Se&&(P=P.add(T)),T=T.double(),C>>=Se,F>>=Se;return B&&(R=R.negate()),k&&(P=P.negate()),P=new y(r.mul(P.px,E.beta),P.py,P.pz),R.add(P)}multiply(b){const{endo:E,n:I}=e;wi("scalar",b,Se,I);let $,B;if(E){const{k1neg:C,k1:k,k2neg:F,k2:R}=E.splitScalar(b);let{p:P,f:T}=this.wNAF(k),{p:d,f:w}=this.wNAF(R);P=S.constTimeNegate(C,P),d=S.constTimeNegate(F,d),d=new y(r.mul(d.px,E.beta),d.py,d.pz),$=P.add(d),B=T.add(w)}else{const{p:C,f:k}=this.wNAF(b);$=C,B=k}return y.normalizeZ([$,B])[0]}multiplyAndAddUnsafe(b,E,I){const $=y.BASE,B=(k,F)=>F===tr||F===Se||!k.equals($)?k.multiplyUnsafe(F):k.multiply(F),C=B(this,E).add(B(b,I));return C.is0()?void 0:C}toAffine(b){return g(this,b)}isTorsionFree(){const{h:b,isTorsionFree:E}=e;if(b===Se)return!0;if(E)return E(y,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:b,clearCofactor:E}=e;return b===Se?this:E?E(y,this):this.multiplyUnsafe(e.h)}toRawBytes(b=!0){return nn("isCompressed",b),this.assertValidity(),n(y,this,b)}toHex(b=!0){return nn("isCompressed",b),sn(this.toRawBytes(b))}}y.BASE=new y(e.Gx,e.Gy,r.ONE),y.ZERO=new y(r.ZERO,r.ONE,r.ZERO);const{endo:m,nBitLength:x}=e,S=Lw(y,m?Math.ceil(x/2):x);return{CURVE:e,ProjectivePoint:y,normPrivateKeyToScalar:h,weierstrassEquation:o,isWithinCurveOrder:l}}function Kw(t){const e=rd(t);return ms(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function Ww(t){const e=Kw(t),{Fp:r,n:i,nByteLength:n,nBitLength:s}=e,o=r.BYTES+1,a=2*r.BYTES+1;function c(d){return Ge(d,i)}function u(d){return Xo(d,i)}const{ProjectivePoint:l,normPrivateKeyToScalar:h,weierstrassEquation:f,isWithinCurveOrder:g}=Hw({...e,toBytes(d,w,D){const O=w.toAffine(),_=r.toBytes(O.x),A=es;return nn("isCompressed",D),D?A(Uint8Array.from([w.hasEvenY()?2:3]),_):A(Uint8Array.from([4]),_,r.toBytes(O.y))},fromBytes(d){const w=d.length,D=d[0],O=d.subarray(1);if(w===o&&(D===2||D===3)){const _=Wr(O);if(!Qa(_,Se,r.ORDER))throw new Error("Point is not on curve");const A=f(_);let N;try{N=r.sqrt(A)}catch(U){const L=U instanceof Error?": "+U.message:"";throw new Error("Point is not on curve"+L)}const j=(N&Se)===Se;return(D&1)===1!==j&&(N=r.neg(N)),{x:_,y:N}}else if(w===a&&D===4){const _=r.fromBytes(O.subarray(0,r.BYTES)),A=r.fromBytes(O.subarray(r.BYTES,2*r.BYTES));return{x:_,y:A}}else{const _=o,A=a;throw new Error("invalid Point, expected length of "+_+", or uncompressed "+A+", got "+w)}}});function p(d){const w=i>>Se;return d>w}function y(d){return p(d)?c(-d):d}const m=(d,w,D)=>Wr(d.slice(w,D));class x{constructor(w,D,O){wi("r",w,Se,i),wi("s",D,Se,i),this.r=w,this.s=D,O!=null&&(this.recovery=O),Object.freeze(this)}static fromCompact(w){const D=n;return w=gt("compactSignature",w,D*2),new x(m(w,0,D),m(w,D,2*D))}static fromDER(w){const{r:D,s:O}=Qt.toSig(gt("DER",w));return new x(D,O)}assertValidity(){}addRecoveryBit(w){return new x(this.r,this.s,w)}recoverPublicKey(w){const{r:D,s:O,recovery:_}=this,A=$(gt("msgHash",w));if(_==null||![0,1,2,3].includes(_))throw new Error("recovery id invalid");const N=_===2||_===3?D+e.n:D;if(N>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");const j=(_&1)===0?"02":"03",q=l.fromHex(j+ro(N,r.BYTES)),U=u(N),L=c(-A*U),K=c(O*U),G=l.BASE.multiplyAndAddUnsafe(q,L,K);if(!G)throw new Error("point at infinify");return G.assertValidity(),G}hasHighS(){return p(this.s)}normalizeS(){return this.hasHighS()?new x(this.r,c(-this.s),this.recovery):this}toDERRawBytes(){return Qn(this.toDERHex())}toDERHex(){return Qt.hexFromSig(this)}toCompactRawBytes(){return Qn(this.toCompactHex())}toCompactHex(){const w=n;return ro(this.r,w)+ro(this.s,w)}}const S={isValidPrivateKey(d){try{return h(d),!0}catch{return!1}},normPrivateKeyToScalar:h,randomPrivateKey:()=>{const d=Qf(e.n);return jw(e.randomBytes(d),e.n)},precompute(d=8,w=l.BASE){return w._setWindowSize(d),w.multiply(BigInt(3)),w}};function v(d,w=!0){return l.fromPrivateKey(d).toRawBytes(w)}function b(d){if(typeof d=="bigint")return!1;if(d instanceof l)return!0;const D=gt("key",d).length,O=r.BYTES,_=O+1,A=2*O+1;if(!(e.allowedPrivateKeyLengths||n===_))return D===_||D===A}function E(d,w,D=!0){if(b(d)===!0)throw new Error("first arg must be private key");if(b(w)===!1)throw new Error("second arg must be public key");return l.fromHex(w).multiply(h(d)).toRawBytes(D)}const I=e.bits2int||function(d){if(d.length>8192)throw new Error("input is too large");const w=Wr(d),D=d.length*8-s;return D>0?w>>BigInt(D):w},$=e.bits2int_modN||function(d){return c(I(d))},B=bs(s);function C(d){return wi("num < 2^"+s,d,tr,B),fn(d,n)}function k(d,w,D=F){if(["recovered","canonical"].some(W=>W in D))throw new Error("sign() legacy options not supported");const{hash:O,randomBytes:_}=e;let{lowS:A,prehash:N,extraEntropy:j}=D;A==null&&(A=!0),d=gt("msgHash",d),xu(D),N&&(d=gt("prehashed msgHash",O(d)));const q=$(d),U=h(w),L=[C(U),C(q)];if(j!=null&&j!==!1){const W=j===!0?_(r.BYTES):j;L.push(gt("extraEntropy",W))}const K=es(...L),G=q;function Z(W){const Y=I(W);if(!g(Y))return;const ee=u(Y),ce=l.BASE.multiply(Y).toAffine(),fe=c(ce.x);if(fe===tr)return;const ge=c(ee*c(G+fe*U));if(ge===tr)return;let et=(ce.x===fe?0:2)|Number(ce.y&Se),Cr=ge;return A&&p(ge)&&(Cr=y(ge),et^=1),new x(fe,Cr,et)}return{seed:K,k2sig:Z}}const F={lowS:e.lowS,prehash:!1},R={lowS:e.lowS,prehash:!1};function P(d,w,D=F){const{seed:O,k2sig:_}=k(d,w,D),A=e;return H0(A.hash.outputLen,A.nByteLength,A.hmac)(O,_)}l.BASE._setWindowSize(8);function T(d,w,D,O=R){const _=d;w=gt("msgHash",w),D=gt("publicKey",D);const{lowS:A,prehash:N,format:j}=O;if(xu(O),"strict"in O)throw new Error("options.strict was renamed to lowS");if(j!==void 0&&j!=="compact"&&j!=="der")throw new Error("format must be compact or der");const q=typeof _=="string"||hn(_),U=!q&&!j&&typeof _=="object"&&_!==null&&typeof _.r=="bigint"&&typeof _.s=="bigint";if(!q&&!U)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let L,K;try{if(U&&(L=new x(_.r,_.s)),q){try{j!=="compact"&&(L=x.fromDER(_))}catch(et){if(!(et instanceof Qt.Err))throw et}!L&&j!=="der"&&(L=x.fromCompact(_))}K=l.fromHex(D)}catch{return!1}if(!L||A&&L.hasHighS())return!1;N&&(w=e.hash(w));const{r:G,s:Z}=L,W=$(w),Y=u(Z),ee=c(W*Y),ce=c(G*Y),fe=l.BASE.multiplyAndAddUnsafe(K,ee,ce)?.toAffine();return fe?c(fe.x)===G:!1}return{CURVE:e,getPublicKey:v,getSharedSecret:E,sign:P,verify:T,ProjectivePoint:l,Signature:x,utils:S}}function Gw(t){return{hash:t,hmac:(e,...r)=>Hf(t,e,b0(...r)),randomBytes:m0}}function Yw(t,e){const r=i=>Ww({...t,...Gw(i)});return{...r(e),create:r}}const id=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),_u=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Zw=BigInt(0),Jw=BigInt(1),ea=BigInt(2),Iu=(t,e)=>(t+e/ea)/e;function Xw(t){const e=id,r=BigInt(3),i=BigInt(6),n=BigInt(11),s=BigInt(22),o=BigInt(23),a=BigInt(44),c=BigInt(88),u=t*t*t%e,l=u*u*t%e,h=lt(l,r,e)*l%e,f=lt(h,r,e)*l%e,g=lt(f,ea,e)*u%e,p=lt(g,n,e)*g%e,y=lt(p,s,e)*p%e,m=lt(y,a,e)*y%e,x=lt(m,c,e)*m%e,S=lt(x,a,e)*y%e,v=lt(S,r,e)*l%e,b=lt(v,o,e)*p%e,E=lt(b,i,e)*u%e,I=lt(E,ea,e);if(!ta.eql(ta.sqr(I),t))throw new Error("Cannot find square root");return I}const ta=rc(id,void 0,void 0,{sqrt:Xw}),Qw=Yw({a:Zw,b:BigInt(7),Fp:ta,n:_u,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=_u,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),i=-Jw*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),n=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=r,o=BigInt("0x100000000000000000000000000000000"),a=Iu(s*t,e),c=Iu(-i*t,e);let u=Ge(t-a*r-c*n,e),l=Ge(-a*i-c*s,e);const h=u>o,f=l>o;if(h&&(u=e-u),f&&(l=e-l),u>o||l>o)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:h,k1:u,k2neg:f,k2:l}}}},q0);function eb(t){if(t.length!==130&&t.length!==132)throw new rb({signature:t});const e=BigInt(Xt(t,0,32)),r=BigInt(Xt(t,32,64)),i=(()=>{const n=+`0x${t.slice(130)}`;if(!Number.isNaN(n))try{return tb(n)}catch{throw new ib({value:n})}})();return typeof i>"u"?{r:e,s:r}:{r:e,s:r,yParity:i}}function tb(t){if(t===0||t===27)return 0;if(t===1||t===28)return 1;if(t>=35)return t%2===0?1:0;throw new nb({value:t})}class rb extends he{constructor({signature:e}){super(`Value \`${e}\` is an invalid signature size.`,{metaMessages:["Expected: 64 bytes or 65 bytes.",`Received ${Sr(tc(e))} bytes.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidSerializedSizeError"})}}class ib extends he{constructor({value:e}){super(`Value \`${e}\` is an invalid y-parity value. Y-parity must be 0 or 1.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidYParityError"})}}class nb extends he{constructor({value:e}){super(`Value \`${e}\` is an invalid v value. v must be 27, 28 or >=35.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidVError"})}}function sb(t){return Ow(ob(t))}function ob(t){const{payload:e,signature:r}=t,{r:i,s:n,yParity:s}=r,a=new Qw.Signature(BigInt(i),BigInt(n)).addRecoveryBit(s).recoverPublicKey(tc(e).substring(2));return bw(a)}function ab(t){if(t.length>=255)throw new TypeError("Alphabet too long");const e=new Uint8Array(256);for(let u=0;u<e.length;u++)e[u]=255;for(let u=0;u<t.length;u++){const l=t.charAt(u),h=l.charCodeAt(0);if(e[h]!==255)throw new TypeError(l+" is ambiguous");e[h]=u}const r=t.length,i=t.charAt(0),n=Math.log(r)/Math.log(256),s=Math.log(256)/Math.log(r);function o(u){if(u instanceof Uint8Array||(ArrayBuffer.isView(u)?u=new Uint8Array(u.buffer,u.byteOffset,u.byteLength):Array.isArray(u)&&(u=Uint8Array.from(u))),!(u instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(u.length===0)return"";let l=0,h=0,f=0;const g=u.length;for(;f!==g&&u[f]===0;)f++,l++;const p=(g-f)*s+1>>>0,y=new Uint8Array(p);for(;f!==g;){let S=u[f],v=0;for(let b=p-1;(S!==0||v<h)&&b!==-1;b--,v++)S+=256*y[b]>>>0,y[b]=S%r>>>0,S=S/r>>>0;if(S!==0)throw new Error("Non-zero carry");h=v,f++}let m=p-h;for(;m!==p&&y[m]===0;)m++;let x=i.repeat(l);for(;m<p;++m)x+=t.charAt(y[m]);return x}function a(u){if(typeof u!="string")throw new TypeError("Expected String");if(u.length===0)return new Uint8Array;let l=0,h=0,f=0;for(;u[l]===i;)h++,l++;const g=(u.length-l)*n+1>>>0,p=new Uint8Array(g);for(;l<u.length;){const S=u.charCodeAt(l);if(S>255)return;let v=e[S];if(v===255)return;let b=0;for(let E=g-1;(v!==0||b<f)&&E!==-1;E--,b++)v+=r*p[E]>>>0,p[E]=v%256>>>0,v=v/256>>>0;if(v!==0)throw new Error("Non-zero carry");f=b,l++}let y=g-f;for(;y!==g&&p[y]===0;)y++;const m=new Uint8Array(h+(g-y));let x=h;for(;y!==g;)m[x++]=p[y++];return m}function c(u){const l=a(u);if(l)return l;throw new Error("Non-base"+r+" character")}return{encode:o,decodeUnsafe:a,decode:c}}var cb="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";const dn=ab(cb);function ub(t){const e=t.length;let r=0,i=0;for(;i<e;){let n=t.charCodeAt(i++);if((n&4294967168)===0){r++;continue}else if((n&4294965248)===0)r+=2;else{if(n>=55296&&n<=56319&&i<e){const s=t.charCodeAt(i);(s&64512)===56320&&(++i,n=((n&1023)<<10)+(s&1023)+65536)}(n&4294901760)===0?r+=3:r+=4}}return r}function lb(t,e,r){const i=t.length;let n=r,s=0;for(;s<i;){let o=t.charCodeAt(s++);if((o&4294967168)===0){e[n++]=o;continue}else if((o&4294965248)===0)e[n++]=o>>6&31|192;else{if(o>=55296&&o<=56319&&s<i){const a=t.charCodeAt(s);(a&64512)===56320&&(++s,o=((o&1023)<<10)+(a&1023)+65536)}(o&4294901760)===0?(e[n++]=o>>12&15|224,e[n++]=o>>6&63|128):(e[n++]=o>>18&7|240,e[n++]=o>>12&63|128,e[n++]=o>>6&63|128)}e[n++]=o&63|128}}const hb=new TextEncoder,fb=50;function db(t,e,r){hb.encodeInto(t,e.subarray(r))}function pb(t,e,r){t.length>fb?db(t,e,r):lb(t,e,r)}const gb=4096;function nd(t,e,r){let i=e;const n=i+r,s=[];let o="";for(;i<n;){const a=t[i++];if((a&128)===0)s.push(a);else if((a&224)===192){const c=t[i++]&63;s.push((a&31)<<6|c)}else if((a&240)===224){const c=t[i++]&63,u=t[i++]&63;s.push((a&31)<<12|c<<6|u)}else if((a&248)===240){const c=t[i++]&63,u=t[i++]&63,l=t[i++]&63;let h=(a&7)<<18|c<<12|u<<6|l;h>65535&&(h-=65536,s.push(h>>>10&1023|55296),h=56320|h&1023),s.push(h)}else s.push(a);s.length>=gb&&(o+=String.fromCharCode(...s),s.length=0)}return s.length>0&&(o+=String.fromCharCode(...s)),o}const yb=new TextDecoder,wb=200;function bb(t,e,r){const i=t.subarray(e,e+r);return yb.decode(i)}function mb(t,e,r){return r>wb?bb(t,e,r):nd(t,e,r)}class An{constructor(e,r){this.type=e,this.data=r}}class nt extends Error{constructor(e){super(e);const r=Object.create(nt.prototype);Object.setPrototypeOf(this,r),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:nt.name})}}const Ti=4294967295;function vb(t,e,r){const i=r/4294967296,n=r;t.setUint32(e,i),t.setUint32(e+4,n)}function sd(t,e,r){const i=Math.floor(r/4294967296),n=r;t.setUint32(e,i),t.setUint32(e+4,n)}function od(t,e){const r=t.getInt32(e),i=t.getUint32(e+4);return r*4294967296+i}function Eb(t,e){const r=t.getUint32(e),i=t.getUint32(e+4);return r*4294967296+i}const Db=-1,xb=4294967296-1,_b=17179869184-1;function Ib({sec:t,nsec:e}){if(t>=0&&e>=0&&t<=_b)if(e===0&&t<=xb){const r=new Uint8Array(4);return new DataView(r.buffer).setUint32(0,t),r}else{const r=t/4294967296,i=t&4294967295,n=new Uint8Array(8),s=new DataView(n.buffer);return s.setUint32(0,e<<2|r&3),s.setUint32(4,i),n}else{const r=new Uint8Array(12),i=new DataView(r.buffer);return i.setUint32(0,e),sd(i,4,t),r}}function Sb(t){const e=t.getTime(),r=Math.floor(e/1e3),i=(e-r*1e3)*1e6,n=Math.floor(i/1e9);return{sec:r+n,nsec:i-n*1e9}}function Ob(t){if(t instanceof Date){const e=Sb(t);return Ib(e)}else return null}function Ab(t){const e=new DataView(t.buffer,t.byteOffset,t.byteLength);switch(t.byteLength){case 4:return{sec:e.getUint32(0),nsec:0};case 8:{const r=e.getUint32(0),i=e.getUint32(4),n=(r&3)*4294967296+i,s=r>>>2;return{sec:n,nsec:s}}case 12:{const r=od(e,4),i=e.getUint32(0);return{sec:r,nsec:i}}default:throw new nt(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${t.length}`)}}function $b(t){const e=Ab(t);return new Date(e.sec*1e3+e.nsec/1e6)}const Cb={type:Db,encode:Ob,decode:$b};class rs{constructor(){this.builtInEncoders=[],this.builtInDecoders=[],this.encoders=[],this.decoders=[],this.register(Cb)}register({type:e,encode:r,decode:i}){if(e>=0)this.encoders[e]=r,this.decoders[e]=i;else{const n=-1-e;this.builtInEncoders[n]=r,this.builtInDecoders[n]=i}}tryToEncode(e,r){for(let i=0;i<this.builtInEncoders.length;i++){const n=this.builtInEncoders[i];if(n!=null){const s=n(e,r);if(s!=null){const o=-1-i;return new An(o,s)}}}for(let i=0;i<this.encoders.length;i++){const n=this.encoders[i];if(n!=null){const s=n(e,r);if(s!=null){const o=i;return new An(o,s)}}}return e instanceof An?e:null}decode(e,r,i){const n=r<0?this.builtInDecoders[-1-r]:this.decoders[r];return n?n(e,r,i):new An(r,e)}}rs.defaultCodec=new rs;function Pb(t){return t instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer}function ra(t){return t instanceof Uint8Array?t:ArrayBuffer.isView(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Pb(t)?new Uint8Array(t):Uint8Array.from(t)}const Bb=100,Tb=2048;let Rb=class ad{constructor(e){this.entered=!1,this.extensionCodec=e?.extensionCodec??rs.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.maxDepth=e?.maxDepth??Bb,this.initialBufferSize=e?.initialBufferSize??Tb,this.sortKeys=e?.sortKeys??!1,this.forceFloat32=e?.forceFloat32??!1,this.ignoreUndefined=e?.ignoreUndefined??!1,this.forceIntegerToFloat=e?.forceIntegerToFloat??!1,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}clone(){return new ad({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,maxDepth:this.maxDepth,initialBufferSize:this.initialBufferSize,sortKeys:this.sortKeys,forceFloat32:this.forceFloat32,ignoreUndefined:this.ignoreUndefined,forceIntegerToFloat:this.forceIntegerToFloat})}reinitializeState(){this.pos=0}encodeSharedRef(e){if(this.entered)return this.clone().encodeSharedRef(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.subarray(0,this.pos)}finally{this.entered=!1}}encode(e){if(this.entered)return this.clone().encode(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.slice(0,this.pos)}finally{this.entered=!1}}doEncode(e,r){if(r>this.maxDepth)throw new Error(`Too deep objects in depth ${r}`);e==null?this.encodeNil():typeof e=="boolean"?this.encodeBoolean(e):typeof e=="number"?this.forceIntegerToFloat?this.encodeNumberAsFloat(e):this.encodeNumber(e):typeof e=="string"?this.encodeString(e):this.useBigInt64&&typeof e=="bigint"?this.encodeBigInt64(e):this.encodeObject(e,r)}ensureBufferSizeToWrite(e){const r=this.pos+e;this.view.byteLength<r&&this.resizeBuffer(r*2)}resizeBuffer(e){const r=new ArrayBuffer(e),i=new Uint8Array(r),n=new DataView(r);i.set(this.bytes),this.view=n,this.bytes=i}encodeNil(){this.writeU8(192)}encodeBoolean(e){e===!1?this.writeU8(194):this.writeU8(195)}encodeNumber(e){!this.forceIntegerToFloat&&Number.isSafeInteger(e)?e>=0?e<128?this.writeU8(e):e<256?(this.writeU8(204),this.writeU8(e)):e<65536?(this.writeU8(205),this.writeU16(e)):e<4294967296?(this.writeU8(206),this.writeU32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(207),this.writeU64(e)):e>=-32?this.writeU8(224|e+32):e>=-128?(this.writeU8(208),this.writeI8(e)):e>=-32768?(this.writeU8(209),this.writeI16(e)):e>=-2147483648?(this.writeU8(210),this.writeI32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(211),this.writeI64(e)):this.encodeNumberAsFloat(e)}encodeNumberAsFloat(e){this.forceFloat32?(this.writeU8(202),this.writeF32(e)):(this.writeU8(203),this.writeF64(e))}encodeBigInt64(e){e>=BigInt(0)?(this.writeU8(207),this.writeBigUint64(e)):(this.writeU8(211),this.writeBigInt64(e))}writeStringHeader(e){if(e<32)this.writeU8(160+e);else if(e<256)this.writeU8(217),this.writeU8(e);else if(e<65536)this.writeU8(218),this.writeU16(e);else if(e<4294967296)this.writeU8(219),this.writeU32(e);else throw new Error(`Too long string: ${e} bytes in UTF-8`)}encodeString(e){const i=ub(e);this.ensureBufferSizeToWrite(5+i),this.writeStringHeader(i),pb(e,this.bytes,this.pos),this.pos+=i}encodeObject(e,r){const i=this.extensionCodec.tryToEncode(e,this.context);if(i!=null)this.encodeExtension(i);else if(Array.isArray(e))this.encodeArray(e,r);else if(ArrayBuffer.isView(e))this.encodeBinary(e);else if(typeof e=="object")this.encodeMap(e,r);else throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(e)}`)}encodeBinary(e){const r=e.byteLength;if(r<256)this.writeU8(196),this.writeU8(r);else if(r<65536)this.writeU8(197),this.writeU16(r);else if(r<4294967296)this.writeU8(198),this.writeU32(r);else throw new Error(`Too large binary: ${r}`);const i=ra(e);this.writeU8a(i)}encodeArray(e,r){const i=e.length;if(i<16)this.writeU8(144+i);else if(i<65536)this.writeU8(220),this.writeU16(i);else if(i<4294967296)this.writeU8(221),this.writeU32(i);else throw new Error(`Too large array: ${i}`);for(const n of e)this.doEncode(n,r+1)}countWithoutUndefined(e,r){let i=0;for(const n of r)e[n]!==void 0&&i++;return i}encodeMap(e,r){const i=Object.keys(e);this.sortKeys&&i.sort();const n=this.ignoreUndefined?this.countWithoutUndefined(e,i):i.length;if(n<16)this.writeU8(128+n);else if(n<65536)this.writeU8(222),this.writeU16(n);else if(n<4294967296)this.writeU8(223),this.writeU32(n);else throw new Error(`Too large map object: ${n}`);for(const s of i){const o=e[s];this.ignoreUndefined&&o===void 0||(this.encodeString(s),this.doEncode(o,r+1))}}encodeExtension(e){if(typeof e.data=="function"){const i=e.data(this.pos+6),n=i.length;if(n>=4294967296)throw new Error(`Too large extension object: ${n}`);this.writeU8(201),this.writeU32(n),this.writeI8(e.type),this.writeU8a(i);return}const r=e.data.length;if(r===1)this.writeU8(212);else if(r===2)this.writeU8(213);else if(r===4)this.writeU8(214);else if(r===8)this.writeU8(215);else if(r===16)this.writeU8(216);else if(r<256)this.writeU8(199),this.writeU8(r);else if(r<65536)this.writeU8(200),this.writeU16(r);else if(r<4294967296)this.writeU8(201),this.writeU32(r);else throw new Error(`Too large extension object: ${r}`);this.writeI8(e.type),this.writeU8a(e.data)}writeU8(e){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,e),this.pos++}writeU8a(e){const r=e.length;this.ensureBufferSizeToWrite(r),this.bytes.set(e,this.pos),this.pos+=r}writeI8(e){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,e),this.pos++}writeU16(e){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,e),this.pos+=2}writeI16(e){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,e),this.pos+=2}writeU32(e){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,e),this.pos+=4}writeI32(e){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,e),this.pos+=4}writeF32(e){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,e),this.pos+=4}writeF64(e){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,e),this.pos+=8}writeU64(e){this.ensureBufferSizeToWrite(8),vb(this.view,this.pos,e),this.pos+=8}writeI64(e){this.ensureBufferSizeToWrite(8),sd(this.view,this.pos,e),this.pos+=8}writeBigUint64(e){this.ensureBufferSizeToWrite(8),this.view.setBigUint64(this.pos,e),this.pos+=8}writeBigInt64(e){this.ensureBufferSizeToWrite(8),this.view.setBigInt64(this.pos,e),this.pos+=8}};function Ub(t,e){return new Rb(e).encodeSharedRef(t)}function no(t){return`${t<0?"-":""}0x${Math.abs(t).toString(16).padStart(2,"0")}`}const Nb=16,jb=16;class kb{constructor(e=Nb,r=jb){this.hit=0,this.miss=0,this.maxKeyLength=e,this.maxLengthPerKey=r,this.caches=[];for(let i=0;i<this.maxKeyLength;i++)this.caches.push([])}canBeCached(e){return e>0&&e<=this.maxKeyLength}find(e,r,i){const n=this.caches[i-1];e:for(const s of n){const o=s.bytes;for(let a=0;a<i;a++)if(o[a]!==e[r+a])continue e;return s.str}return null}store(e,r){const i=this.caches[e.length-1],n={bytes:e,str:r};i.length>=this.maxLengthPerKey?i[Math.random()*i.length|0]=n:i.push(n)}decode(e,r,i){const n=this.find(e,r,i);if(n!=null)return this.hit++,n;this.miss++;const s=nd(e,r,i),o=Uint8Array.prototype.slice.call(e,r,r+i);return this.store(o,s),s}}const ia="array",Yi="map_key",cd="map_value",Fb=t=>{if(typeof t=="string"||typeof t=="number")return t;throw new nt("The type of key must be string or number but "+typeof t)};class Lb{constructor(){this.stack=[],this.stackHeadPosition=-1}get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(e){const r=this.getUninitializedStateFromPool();r.type=ia,r.position=0,r.size=e,r.array=new Array(e)}pushMapState(e){const r=this.getUninitializedStateFromPool();r.type=Yi,r.readCount=0,r.size=e,r.map={}}getUninitializedStateFromPool(){if(this.stackHeadPosition++,this.stackHeadPosition===this.stack.length){const e={type:void 0,size:0,array:void 0,position:0,readCount:0,map:void 0,key:null};this.stack.push(e)}return this.stack[this.stackHeadPosition]}release(e){if(this.stack[this.stackHeadPosition]!==e)throw new Error("Invalid stack state. Released state is not on top of the stack.");if(e.type===ia){const i=e;i.size=0,i.array=void 0,i.position=0,i.type=void 0}if(e.type===Yi||e.type===cd){const i=e;i.size=0,i.map=void 0,i.readCount=0,i.type=void 0}this.stackHeadPosition--}reset(){this.stack.length=0,this.stackHeadPosition=-1}}const Ri=-1,ic=new DataView(new ArrayBuffer(0)),Mb=new Uint8Array(ic.buffer);try{ic.getInt8(0)}catch(t){if(!(t instanceof RangeError))throw new Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access")}const Su=new RangeError("Insufficient data"),qb=new kb;let zb=class ud{constructor(e){this.totalPos=0,this.pos=0,this.view=ic,this.bytes=Mb,this.headByte=Ri,this.stack=new Lb,this.entered=!1,this.extensionCodec=e?.extensionCodec??rs.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.rawStrings=e?.rawStrings??!1,this.maxStrLength=e?.maxStrLength??Ti,this.maxBinLength=e?.maxBinLength??Ti,this.maxArrayLength=e?.maxArrayLength??Ti,this.maxMapLength=e?.maxMapLength??Ti,this.maxExtLength=e?.maxExtLength??Ti,this.keyDecoder=e?.keyDecoder!==void 0?e.keyDecoder:qb,this.mapKeyConverter=e?.mapKeyConverter??Fb}clone(){return new ud({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,rawStrings:this.rawStrings,maxStrLength:this.maxStrLength,maxBinLength:this.maxBinLength,maxArrayLength:this.maxArrayLength,maxMapLength:this.maxMapLength,maxExtLength:this.maxExtLength,keyDecoder:this.keyDecoder})}reinitializeState(){this.totalPos=0,this.headByte=Ri,this.stack.reset()}setBuffer(e){const r=ra(e);this.bytes=r,this.view=new DataView(r.buffer,r.byteOffset,r.byteLength),this.pos=0}appendBuffer(e){if(this.headByte===Ri&&!this.hasRemaining(1))this.setBuffer(e);else{const r=this.bytes.subarray(this.pos),i=ra(e),n=new Uint8Array(r.length+i.length);n.set(r),n.set(i,r.length),this.setBuffer(n)}}hasRemaining(e){return this.view.byteLength-this.pos>=e}createExtraByteError(e){const{view:r,pos:i}=this;return new RangeError(`Extra ${r.byteLength-i} of ${r.byteLength} byte(s) found at buffer[${e}]`)}decode(e){if(this.entered)return this.clone().decode(e);try{this.entered=!0,this.reinitializeState(),this.setBuffer(e);const r=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return r}finally{this.entered=!1}}*decodeMulti(e){if(this.entered){yield*this.clone().decodeMulti(e);return}try{for(this.entered=!0,this.reinitializeState(),this.setBuffer(e);this.hasRemaining(1);)yield this.doDecodeSync()}finally{this.entered=!1}}async decodeAsync(e){if(this.entered)return this.clone().decodeAsync(e);try{this.entered=!0;let r=!1,i;for await(const a of e){if(r)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(a);try{i=this.doDecodeSync(),r=!0}catch(c){if(!(c instanceof RangeError))throw c}this.totalPos+=this.pos}if(r){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return i}const{headByte:n,pos:s,totalPos:o}=this;throw new RangeError(`Insufficient data in parsing ${no(n)} at ${o} (${s} in the current buffer)`)}finally{this.entered=!1}}decodeArrayStream(e){return this.decodeMultiAsync(e,!0)}decodeStream(e){return this.decodeMultiAsync(e,!1)}async*decodeMultiAsync(e,r){if(this.entered){yield*this.clone().decodeMultiAsync(e,r);return}try{this.entered=!0;let i=r,n=-1;for await(const s of e){if(r&&n===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(s),i&&(n=this.readArraySize(),i=!1,this.complete());try{for(;yield this.doDecodeSync(),--n!==0;);}catch(o){if(!(o instanceof RangeError))throw o}this.totalPos+=this.pos}}finally{this.entered=!1}}doDecodeSync(){e:for(;;){const e=this.readHeadByte();let r;if(e>=224)r=e-256;else if(e<192)if(e<128)r=e;else if(e<144){const n=e-128;if(n!==0){this.pushMapState(n),this.complete();continue e}else r={}}else if(e<160){const n=e-144;if(n!==0){this.pushArrayState(n),this.complete();continue e}else r=[]}else{const n=e-160;r=this.decodeString(n,0)}else if(e===192)r=null;else if(e===194)r=!1;else if(e===195)r=!0;else if(e===202)r=this.readF32();else if(e===203)r=this.readF64();else if(e===204)r=this.readU8();else if(e===205)r=this.readU16();else if(e===206)r=this.readU32();else if(e===207)this.useBigInt64?r=this.readU64AsBigInt():r=this.readU64();else if(e===208)r=this.readI8();else if(e===209)r=this.readI16();else if(e===210)r=this.readI32();else if(e===211)this.useBigInt64?r=this.readI64AsBigInt():r=this.readI64();else if(e===217){const n=this.lookU8();r=this.decodeString(n,1)}else if(e===218){const n=this.lookU16();r=this.decodeString(n,2)}else if(e===219){const n=this.lookU32();r=this.decodeString(n,4)}else if(e===220){const n=this.readU16();if(n!==0){this.pushArrayState(n),this.complete();continue e}else r=[]}else if(e===221){const n=this.readU32();if(n!==0){this.pushArrayState(n),this.complete();continue e}else r=[]}else if(e===222){const n=this.readU16();if(n!==0){this.pushMapState(n),this.complete();continue e}else r={}}else if(e===223){const n=this.readU32();if(n!==0){this.pushMapState(n),this.complete();continue e}else r={}}else if(e===196){const n=this.lookU8();r=this.decodeBinary(n,1)}else if(e===197){const n=this.lookU16();r=this.decodeBinary(n,2)}else if(e===198){const n=this.lookU32();r=this.decodeBinary(n,4)}else if(e===212)r=this.decodeExtension(1,0);else if(e===213)r=this.decodeExtension(2,0);else if(e===214)r=this.decodeExtension(4,0);else if(e===215)r=this.decodeExtension(8,0);else if(e===216)r=this.decodeExtension(16,0);else if(e===199){const n=this.lookU8();r=this.decodeExtension(n,1)}else if(e===200){const n=this.lookU16();r=this.decodeExtension(n,2)}else if(e===201){const n=this.lookU32();r=this.decodeExtension(n,4)}else throw new nt(`Unrecognized type byte: ${no(e)}`);this.complete();const i=this.stack;for(;i.length>0;){const n=i.top();if(n.type===ia)if(n.array[n.position]=r,n.position++,n.position===n.size)r=n.array,i.release(n);else continue e;else if(n.type===Yi){if(r==="__proto__")throw new nt("The key __proto__ is not allowed");n.key=this.mapKeyConverter(r),n.type=cd;continue e}else if(n.map[n.key]=r,n.readCount++,n.readCount===n.size)r=n.map,i.release(n);else{n.key=null,n.type=Yi;continue e}}return r}}readHeadByte(){return this.headByte===Ri&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=Ri}readArraySize(){const e=this.readHeadByte();switch(e){case 220:return this.readU16();case 221:return this.readU32();default:{if(e<160)return e-144;throw new nt(`Unrecognized array type byte: ${no(e)}`)}}}pushMapState(e){if(e>this.maxMapLength)throw new nt(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(e)}pushArrayState(e){if(e>this.maxArrayLength)throw new nt(`Max length exceeded: array length (${e}) > maxArrayLength (${this.maxArrayLength})`);this.stack.pushArrayState(e)}decodeString(e,r){return!this.rawStrings||this.stateIsMapKey()?this.decodeUtf8String(e,r):this.decodeBinary(e,r)}decodeUtf8String(e,r){if(e>this.maxStrLength)throw new nt(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+r+e)throw Su;const i=this.pos+r;let n;return this.stateIsMapKey()&&this.keyDecoder?.canBeCached(e)?n=this.keyDecoder.decode(this.bytes,i,e):n=mb(this.bytes,i,e),this.pos+=r+e,n}stateIsMapKey(){return this.stack.length>0?this.stack.top().type===Yi:!1}decodeBinary(e,r){if(e>this.maxBinLength)throw new nt(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(e+r))throw Su;const i=this.pos+r,n=this.bytes.subarray(i,i+e);return this.pos+=r+e,n}decodeExtension(e,r){if(e>this.maxExtLength)throw new nt(`Max length exceeded: ext length (${e}) > maxExtLength (${this.maxExtLength})`);const i=this.view.getInt8(this.pos+r),n=this.decodeBinary(e,r+1);return this.extensionCodec.decode(n,i,this.context)}lookU8(){return this.view.getUint8(this.pos)}lookU16(){return this.view.getUint16(this.pos)}lookU32(){return this.view.getUint32(this.pos)}readU8(){const e=this.view.getUint8(this.pos);return this.pos++,e}readI8(){const e=this.view.getInt8(this.pos);return this.pos++,e}readU16(){const e=this.view.getUint16(this.pos);return this.pos+=2,e}readI16(){const e=this.view.getInt16(this.pos);return this.pos+=2,e}readU32(){const e=this.view.getUint32(this.pos);return this.pos+=4,e}readI32(){const e=this.view.getInt32(this.pos);return this.pos+=4,e}readU64(){const e=Eb(this.view,this.pos);return this.pos+=8,e}readI64(){const e=od(this.view,this.pos);return this.pos+=8,e}readU64AsBigInt(){const e=this.view.getBigUint64(this.pos);return this.pos+=8,e}readI64AsBigInt(){const e=this.view.getBigInt64(this.pos);return this.pos+=8,e}readF32(){const e=this.view.getFloat32(this.pos);return this.pos+=4,e}readF64(){const e=this.view.getFloat64(this.pos);return this.pos+=8,e}};function Vb(t,e){return new zb(e).decode(t)}const Hb=t=>JSON.stringify(t,(e,r)=>typeof r=="bigint"?r.toString()+"n":r),Kb=t=>{const e=/([\[:])?(\d{17,}|(?:[9](?:[1-9]07199254740991|0[1-9]7199254740991|00[8-9]199254740991|007[2-9]99254740991|007199[3-9]54740991|0071992[6-9]4740991|00719925[5-9]740991|007199254[8-9]40991|0071992547[5-9]0991|00719925474[1-9]991|00719925474099[2-9])))([,\}\]])/g,r=t.replace(e,'$1"$2n"$3');return JSON.parse(r,(i,n)=>typeof n=="string"&&n.match(/^\d+n$/)?BigInt(n.substring(0,n.length-1)):n)};function Yr(t){if(typeof t!="string")throw new Error(`Cannot safe json parse value of type ${typeof t}`);try{return Kb(t)}catch{return t}}function or(t){return typeof t=="string"?t:Hb(t)||""}function Wb(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function ld(t,...e){if(!Wb(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function Ou(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Gb(t,e){ld(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}const si=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;const so=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);function Yb(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function hd(t){return typeof t=="string"&&(t=Yb(t)),ld(t),t}let Zb=class{clone(){return this._cloneInto()}};function Jb(t){const e=i=>t().update(hd(i)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function fd(t=32){if(si&&typeof si.getRandomValues=="function")return si.getRandomValues(new Uint8Array(t));if(si&&typeof si.randomBytes=="function")return si.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}function Xb(t,e,r,i){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,i);const n=BigInt(32),s=BigInt(4294967295),o=Number(r>>n&s),a=Number(r&s),c=i?4:0,u=i?0:4;t.setUint32(e+c,o,i),t.setUint32(e+u,a,i)}let Qb=class extends Zb{constructor(e,r,i,n){super(),this.blockLen=e,this.outputLen=r,this.padOffset=i,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=so(this.buffer)}update(e){Ou(this);const{view:r,buffer:i,blockLen:n}=this;e=hd(e);const s=e.length;for(let o=0;o<s;){const a=Math.min(n-this.pos,s-o);if(a===n){const c=so(e);for(;n<=s-o;o+=n)this.process(c,o);continue}i.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===n&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Ou(this),Gb(e,this),this.finished=!0;const{buffer:r,view:i,blockLen:n,isLE:s}=this;let{pos:o}=this;r[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>n-o&&(this.process(i,0),o=0);for(let h=o;h<n;h++)r[h]=0;Xb(i,n-8,BigInt(this.length*8),s),this.process(i,0);const a=so(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=c/4,l=this.get();if(u>l.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<u;h++)a.setUint32(4*h,l[h],s)}digest(){const{buffer:e,outputLen:r}=this;this.digestInto(e);const i=e.slice(0,r);return this.destroy(),i}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:r,buffer:i,length:n,finished:s,destroyed:o,pos:a}=this;return e.length=n,e.pos=a,e.finished=s,e.destroyed=o,n%r&&e.buffer.set(i),e}};const $n=BigInt(2**32-1),na=BigInt(32);function dd(t,e=!1){return e?{h:Number(t&$n),l:Number(t>>na&$n)}:{h:Number(t>>na&$n)|0,l:Number(t&$n)|0}}function em(t,e=!1){let r=new Uint32Array(t.length),i=new Uint32Array(t.length);for(let n=0;n<t.length;n++){const{h:s,l:o}=dd(t[n],e);[r[n],i[n]]=[s,o]}return[r,i]}const tm=(t,e)=>BigInt(t>>>0)<<na|BigInt(e>>>0),rm=(t,e,r)=>t>>>r,im=(t,e,r)=>t<<32-r|e>>>r,nm=(t,e,r)=>t>>>r|e<<32-r,sm=(t,e,r)=>t<<32-r|e>>>r,om=(t,e,r)=>t<<64-r|e>>>r-32,am=(t,e,r)=>t>>>r-32|e<<64-r,cm=(t,e)=>e,um=(t,e)=>t,lm=(t,e,r)=>t<<r|e>>>32-r,hm=(t,e,r)=>e<<r|t>>>32-r,fm=(t,e,r)=>e<<r-32|t>>>64-r,dm=(t,e,r)=>t<<r-32|e>>>64-r;function pm(t,e,r,i){const n=(e>>>0)+(i>>>0);return{h:t+r+(n/2**32|0)|0,l:n|0}}const gm=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),ym=(t,e,r,i)=>e+r+i+(t/2**32|0)|0,wm=(t,e,r,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(i>>>0),bm=(t,e,r,i,n)=>e+r+i+n+(t/2**32|0)|0,mm=(t,e,r,i,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(i>>>0)+(n>>>0),vm=(t,e,r,i,n,s)=>e+r+i+n+s+(t/2**32|0)|0,J={fromBig:dd,split:em,toBig:tm,shrSH:rm,shrSL:im,rotrSH:nm,rotrSL:sm,rotrBH:om,rotrBL:am,rotr32H:cm,rotr32L:um,rotlSH:lm,rotlSL:hm,rotlBH:fm,rotlBL:dm,add:pm,add3L:gm,add3H:ym,add4L:wm,add4H:bm,add5H:vm,add5L:mm},[Em,Dm]=J.split(["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"].map(t=>BigInt(t))),lr=new Uint32Array(80),hr=new Uint32Array(80);let xm=class extends Qb{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:e,Al:r,Bh:i,Bl:n,Ch:s,Cl:o,Dh:a,Dl:c,Eh:u,El:l,Fh:h,Fl:f,Gh:g,Gl:p,Hh:y,Hl:m}=this;return[e,r,i,n,s,o,a,c,u,l,h,f,g,p,y,m]}set(e,r,i,n,s,o,a,c,u,l,h,f,g,p,y,m){this.Ah=e|0,this.Al=r|0,this.Bh=i|0,this.Bl=n|0,this.Ch=s|0,this.Cl=o|0,this.Dh=a|0,this.Dl=c|0,this.Eh=u|0,this.El=l|0,this.Fh=h|0,this.Fl=f|0,this.Gh=g|0,this.Gl=p|0,this.Hh=y|0,this.Hl=m|0}process(e,r){for(let v=0;v<16;v++,r+=4)lr[v]=e.getUint32(r),hr[v]=e.getUint32(r+=4);for(let v=16;v<80;v++){const b=lr[v-15]|0,E=hr[v-15]|0,I=J.rotrSH(b,E,1)^J.rotrSH(b,E,8)^J.shrSH(b,E,7),$=J.rotrSL(b,E,1)^J.rotrSL(b,E,8)^J.shrSL(b,E,7),B=lr[v-2]|0,C=hr[v-2]|0,k=J.rotrSH(B,C,19)^J.rotrBH(B,C,61)^J.shrSH(B,C,6),F=J.rotrSL(B,C,19)^J.rotrBL(B,C,61)^J.shrSL(B,C,6),R=J.add4L($,F,hr[v-7],hr[v-16]),P=J.add4H(R,I,k,lr[v-7],lr[v-16]);lr[v]=P|0,hr[v]=R|0}let{Ah:i,Al:n,Bh:s,Bl:o,Ch:a,Cl:c,Dh:u,Dl:l,Eh:h,El:f,Fh:g,Fl:p,Gh:y,Gl:m,Hh:x,Hl:S}=this;for(let v=0;v<80;v++){const b=J.rotrSH(h,f,14)^J.rotrSH(h,f,18)^J.rotrBH(h,f,41),E=J.rotrSL(h,f,14)^J.rotrSL(h,f,18)^J.rotrBL(h,f,41),I=h&g^~h&y,$=f&p^~f&m,B=J.add5L(S,E,$,Dm[v],hr[v]),C=J.add5H(B,x,b,I,Em[v],lr[v]),k=B|0,F=J.rotrSH(i,n,28)^J.rotrBH(i,n,34)^J.rotrBH(i,n,39),R=J.rotrSL(i,n,28)^J.rotrBL(i,n,34)^J.rotrBL(i,n,39),P=i&s^i&a^s&a,T=n&o^n&c^o&c;x=y|0,S=m|0,y=g|0,m=p|0,g=h|0,p=f|0,{h,l:f}=J.add(u|0,l|0,C|0,k|0),u=a|0,l=c|0,a=s|0,c=o|0,s=i|0,o=n|0;const d=J.add3L(k,R,T);i=J.add3H(d,C,F,P),n=d|0}({h:i,l:n}=J.add(this.Ah|0,this.Al|0,i|0,n|0)),{h:s,l:o}=J.add(this.Bh|0,this.Bl|0,s|0,o|0),{h:a,l:c}=J.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:u,l}=J.add(this.Dh|0,this.Dl|0,u|0,l|0),{h,l:f}=J.add(this.Eh|0,this.El|0,h|0,f|0),{h:g,l:p}=J.add(this.Fh|0,this.Fl|0,g|0,p|0),{h:y,l:m}=J.add(this.Gh|0,this.Gl|0,y|0,m|0),{h:x,l:S}=J.add(this.Hh|0,this.Hl|0,x|0,S|0),this.set(i,n,s,o,a,c,u,l,h,f,g,p,y,m,x,S)}roundClean(){lr.fill(0),hr.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};const _m=Jb(()=>new xm);const nc=BigInt(0),pd=BigInt(1),Im=BigInt(2);function sc(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function oc(t){if(!sc(t))throw new Error("Uint8Array expected")}function oo(t,e){if(typeof e!="boolean")throw new Error(t+" boolean expected, got "+e)}const Sm=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function ac(t){oc(t);let e="";for(let r=0;r<t.length;r++)e+=Sm[t[r]];return e}function gd(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?nc:BigInt("0x"+t)}const Ht={_0:48,_9:57,A:65,F:70,a:97,f:102};function Au(t){if(t>=Ht._0&&t<=Ht._9)return t-Ht._0;if(t>=Ht.A&&t<=Ht.F)return t-(Ht.A-10);if(t>=Ht.a&&t<=Ht.f)return t-(Ht.a-10)}function yd(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);const e=t.length,r=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const i=new Uint8Array(r);for(let n=0,s=0;n<r;n++,s+=2){const o=Au(t.charCodeAt(s)),a=Au(t.charCodeAt(s+1));if(o===void 0||a===void 0){const c=t[s]+t[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}i[n]=o*16+a}return i}function Om(t){return gd(ac(t))}function Kn(t){return oc(t),gd(ac(Uint8Array.from(t).reverse()))}function wd(t,e){return yd(t.toString(16).padStart(e*2,"0"))}function sa(t,e){return wd(t,e).reverse()}function Kt(t,e,r){let i;if(typeof e=="string")try{i=yd(e)}catch(s){throw new Error(t+" must be hex string or Uint8Array, cause: "+s)}else if(sc(e))i=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");const n=i.length;if(typeof r=="number"&&n!==r)throw new Error(t+" of length "+r+" expected, got "+n);return i}function $u(...t){let e=0;for(let i=0;i<t.length;i++){const n=t[i];oc(n),e+=n.length}const r=new Uint8Array(e);for(let i=0,n=0;i<t.length;i++){const s=t[i];r.set(s,n),n+=s.length}return r}const ao=t=>typeof t=="bigint"&&nc<=t;function Am(t,e,r){return ao(t)&&ao(e)&&ao(r)&&e<=t&&t<r}function Ui(t,e,r,i){if(!Am(e,r,i))throw new Error("expected valid "+t+": "+r+" <= n < "+i+", got "+e)}function $m(t){let e;for(e=0;t>nc;t>>=pd,e+=1);return e}const Cm=t=>(Im<<BigInt(t-1))-pd,Pm={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||sc(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function cc(t,e,r={}){const i=(n,s,o)=>{const a=Pm[s];if(typeof a!="function")throw new Error("invalid validator function");const c=t[n];if(!(o&&c===void 0)&&!a(c,t))throw new Error("param "+String(n)+" is invalid. Expected "+s+", got "+c)};for(const[n,s]of Object.entries(e))i(n,s,!1);for(const[n,s]of Object.entries(r))i(n,s,!0);return t}function Cu(t){const e=new WeakMap;return(r,...i)=>{const n=e.get(r);if(n!==void 0)return n;const s=t(r,...i);return e.set(r,s),s}}const Oe=BigInt(0),pe=BigInt(1),Fr=BigInt(2),Bm=BigInt(3),oa=BigInt(4),Pu=BigInt(5),Bu=BigInt(8);function ve(t,e){const r=t%e;return r>=Oe?r:e+r}function Tm(t,e,r){if(e<Oe)throw new Error("invalid exponent, negatives unsupported");if(r<=Oe)throw new Error("invalid modulus");if(r===pe)return Oe;let i=pe;for(;e>Oe;)e&pe&&(i=i*t%r),t=t*t%r,e>>=pe;return i}function Ct(t,e,r){let i=t;for(;e-- >Oe;)i*=i,i%=r;return i}function Tu(t,e){if(t===Oe)throw new Error("invert: expected non-zero number");if(e<=Oe)throw new Error("invert: expected positive modulus, got "+e);let r=ve(t,e),i=e,n=Oe,s=pe;for(;r!==Oe;){const o=i/r,a=i%r,c=n-s*o;i=r,r=a,n=s,s=c}if(i!==pe)throw new Error("invert: does not exist");return ve(n,e)}function Rm(t){const e=(t-pe)/Fr;let r,i,n;for(r=t-pe,i=0;r%Fr===Oe;r/=Fr,i++);for(n=Fr;n<t&&Tm(n,e,t)!==t-pe;n++)if(n>1e3)throw new Error("Cannot find square root: likely non-prime P");if(i===1){const o=(t+pe)/oa;return function(a,c){const u=a.pow(c,o);if(!a.eql(a.sqr(u),c))throw new Error("Cannot find square root");return u}}const s=(r+pe)/Fr;return function(o,a){if(o.pow(a,e)===o.neg(o.ONE))throw new Error("Cannot find square root");let c=i,u=o.pow(o.mul(o.ONE,n),r),l=o.pow(a,s),h=o.pow(a,r);for(;!o.eql(h,o.ONE);){if(o.eql(h,o.ZERO))return o.ZERO;let f=1;for(let p=o.sqr(h);f<c&&!o.eql(p,o.ONE);f++)p=o.sqr(p);const g=o.pow(u,pe<<BigInt(c-f-1));u=o.sqr(g),l=o.mul(l,g),h=o.mul(h,u),c=f}return l}}function Um(t){if(t%oa===Bm){const e=(t+pe)/oa;return function(r,i){const n=r.pow(i,e);if(!r.eql(r.sqr(n),i))throw new Error("Cannot find square root");return n}}if(t%Bu===Pu){const e=(t-Pu)/Bu;return function(r,i){const n=r.mul(i,Fr),s=r.pow(n,e),o=r.mul(i,s),a=r.mul(r.mul(o,Fr),s),c=r.mul(o,r.sub(a,r.ONE));if(!r.eql(r.sqr(c),i))throw new Error("Cannot find square root");return c}}return Rm(t)}const Nm=(t,e)=>(ve(t,e)&pe)===pe,jm=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function km(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=jm.reduce((i,n)=>(i[n]="function",i),e);return cc(t,r)}function Fm(t,e,r){if(r<Oe)throw new Error("invalid exponent, negatives unsupported");if(r===Oe)return t.ONE;if(r===pe)return e;let i=t.ONE,n=e;for(;r>Oe;)r&pe&&(i=t.mul(i,n)),n=t.sqr(n),r>>=pe;return i}function Lm(t,e){const r=new Array(e.length),i=e.reduce((s,o,a)=>t.is0(o)?s:(r[a]=s,t.mul(s,o)),t.ONE),n=t.inv(i);return e.reduceRight((s,o,a)=>t.is0(o)?s:(r[a]=t.mul(s,r[a]),t.mul(s,o)),n),r}function bd(t,e){const r=e!==void 0?e:t.toString(2).length,i=Math.ceil(r/8);return{nBitLength:r,nByteLength:i}}function md(t,e,r=!1,i={}){if(t<=Oe)throw new Error("invalid field: expected ORDER > 0, got "+t);const{nBitLength:n,nByteLength:s}=bd(t,e);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let o;const a=Object.freeze({ORDER:t,isLE:r,BITS:n,BYTES:s,MASK:Cm(n),ZERO:Oe,ONE:pe,create:c=>ve(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return Oe<=c&&c<t},is0:c=>c===Oe,isOdd:c=>(c&pe)===pe,neg:c=>ve(-c,t),eql:(c,u)=>c===u,sqr:c=>ve(c*c,t),add:(c,u)=>ve(c+u,t),sub:(c,u)=>ve(c-u,t),mul:(c,u)=>ve(c*u,t),pow:(c,u)=>Fm(a,c,u),div:(c,u)=>ve(c*Tu(u,t),t),sqrN:c=>c*c,addN:(c,u)=>c+u,subN:(c,u)=>c-u,mulN:(c,u)=>c*u,inv:c=>Tu(c,t),sqrt:i.sqrt||(c=>(o||(o=Um(t)),o(a,c))),invertBatch:c=>Lm(a,c),cmov:(c,u,l)=>l?u:c,toBytes:c=>r?sa(c,s):wd(c,s),fromBytes:c=>{if(c.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+c.length);return r?Kn(c):Om(c)}});return Object.freeze(a)}const Ru=BigInt(0),Cn=BigInt(1);function co(t,e){const r=e.negate();return t?r:e}function vd(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function uo(t,e){vd(t,e);const r=Math.ceil(e/t)+1,i=2**(t-1);return{windows:r,windowSize:i}}function Mm(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((r,i)=>{if(!(r instanceof e))throw new Error("invalid point at index "+i)})}function qm(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((r,i)=>{if(!e.isValid(r))throw new Error("invalid scalar at index "+i)})}const lo=new WeakMap,Ed=new WeakMap;function ho(t){return Ed.get(t)||1}function zm(t,e){return{constTimeNegate:co,hasPrecomputes(r){return ho(r)!==1},unsafeLadder(r,i,n=t.ZERO){let s=r;for(;i>Ru;)i&Cn&&(n=n.add(s)),s=s.double(),i>>=Cn;return n},precomputeWindow(r,i){const{windows:n,windowSize:s}=uo(i,e),o=[];let a=r,c=a;for(let u=0;u<n;u++){c=a,o.push(c);for(let l=1;l<s;l++)c=c.add(a),o.push(c);a=c.double()}return o},wNAF(r,i,n){const{windows:s,windowSize:o}=uo(r,e);let a=t.ZERO,c=t.BASE;const u=BigInt(2**r-1),l=2**r,h=BigInt(r);for(let f=0;f<s;f++){const g=f*o;let p=Number(n&u);n>>=h,p>o&&(p-=l,n+=Cn);const y=g,m=g+Math.abs(p)-1,x=f%2!==0,S=p<0;p===0?c=c.add(co(x,i[y])):a=a.add(co(S,i[m]))}return{p:a,f:c}},wNAFUnsafe(r,i,n,s=t.ZERO){const{windows:o,windowSize:a}=uo(r,e),c=BigInt(2**r-1),u=2**r,l=BigInt(r);for(let h=0;h<o;h++){const f=h*a;if(n===Ru)break;let g=Number(n&c);if(n>>=l,g>a&&(g-=u,n+=Cn),g===0)continue;let p=i[f+Math.abs(g)-1];g<0&&(p=p.negate()),s=s.add(p)}return s},getPrecomputes(r,i,n){let s=lo.get(i);return s||(s=this.precomputeWindow(i,r),r!==1&&lo.set(i,n(s))),s},wNAFCached(r,i,n){const s=ho(r);return this.wNAF(s,this.getPrecomputes(s,r,n),i)},wNAFCachedUnsafe(r,i,n,s){const o=ho(r);return o===1?this.unsafeLadder(r,i,s):this.wNAFUnsafe(o,this.getPrecomputes(o,r,n),i,s)},setWindowSize(r,i){vd(i,e),Ed.set(r,i),lo.delete(r)}}}function Vm(t,e,r,i){if(Mm(r,t),qm(i,e),r.length!==i.length)throw new Error("arrays of points and scalars must have equal length");const n=t.ZERO,s=$m(BigInt(r.length)),o=s>12?s-3:s>4?s-2:s?2:1,a=(1<<o)-1,c=new Array(a+1).fill(n),u=Math.floor((e.BITS-1)/o)*o;let l=n;for(let h=u;h>=0;h-=o){c.fill(n);for(let g=0;g<i.length;g++){const p=i[g],y=Number(p>>BigInt(h)&BigInt(a));c[y]=c[y].add(r[g])}let f=n;for(let g=c.length-1,p=n;g>0;g--)p=p.add(c[g]),f=f.add(p);if(l=l.add(f),h!==0)for(let g=0;g<o;g++)l=l.double()}return l}function Hm(t){return km(t.Fp),cc(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...bd(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}const Et=BigInt(0),Ve=BigInt(1),Pn=BigInt(2),Km=BigInt(8),Wm={zip215:!0};function Gm(t){const e=Hm(t);return cc(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function Ym(t){const e=Gm(t),{Fp:r,n:i,prehash:n,hash:s,randomBytes:o,nByteLength:a,h:c}=e,u=Pn<<BigInt(a*8)-Ve,l=r.create,h=md(e.n,e.nBitLength),f=e.uvRatio||((d,w)=>{try{return{isValid:!0,value:r.sqrt(d*r.inv(w))}}catch{return{isValid:!1,value:Et}}}),g=e.adjustScalarBytes||(d=>d),p=e.domain||((d,w,D)=>{if(oo("phflag",D),w.length||D)throw new Error("Contexts/pre-hash are not supported");return d});function y(d,w){Ui("coordinate "+d,w,Et,u)}function m(d){if(!(d instanceof v))throw new Error("ExtendedPoint expected")}const x=Cu((d,w)=>{const{ex:D,ey:O,ez:_}=d,A=d.is0();w==null&&(w=A?Km:r.inv(_));const N=l(D*w),j=l(O*w),q=l(_*w);if(A)return{x:Et,y:Ve};if(q!==Ve)throw new Error("invZ was invalid");return{x:N,y:j}}),S=Cu(d=>{const{a:w,d:D}=e;if(d.is0())throw new Error("bad point: ZERO");const{ex:O,ey:_,ez:A,et:N}=d,j=l(O*O),q=l(_*_),U=l(A*A),L=l(U*U),K=l(j*w),G=l(U*l(K+q)),Z=l(L+l(D*l(j*q)));if(G!==Z)throw new Error("bad point: equation left != right (1)");const W=l(O*_),Y=l(A*N);if(W!==Y)throw new Error("bad point: equation left != right (2)");return!0});class v{constructor(w,D,O,_){this.ex=w,this.ey=D,this.ez=O,this.et=_,y("x",w),y("y",D),y("z",O),y("t",_),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(w){if(w instanceof v)throw new Error("extended point not allowed");const{x:D,y:O}=w||{};return y("x",D),y("y",O),new v(D,O,Ve,l(D*O))}static normalizeZ(w){const D=r.invertBatch(w.map(O=>O.ez));return w.map((O,_)=>O.toAffine(D[_])).map(v.fromAffine)}static msm(w,D){return Vm(v,h,w,D)}_setWindowSize(w){I.setWindowSize(this,w)}assertValidity(){S(this)}equals(w){m(w);const{ex:D,ey:O,ez:_}=this,{ex:A,ey:N,ez:j}=w,q=l(D*j),U=l(A*_),L=l(O*j),K=l(N*_);return q===U&&L===K}is0(){return this.equals(v.ZERO)}negate(){return new v(l(-this.ex),this.ey,this.ez,l(-this.et))}double(){const{a:w}=e,{ex:D,ey:O,ez:_}=this,A=l(D*D),N=l(O*O),j=l(Pn*l(_*_)),q=l(w*A),U=D+O,L=l(l(U*U)-A-N),K=q+N,G=K-j,Z=q-N,W=l(L*G),Y=l(K*Z),ee=l(L*Z),ce=l(G*K);return new v(W,Y,ce,ee)}add(w){m(w);const{a:D,d:O}=e,{ex:_,ey:A,ez:N,et:j}=this,{ex:q,ey:U,ez:L,et:K}=w;if(D===BigInt(-1)){const Uc=l((A-_)*(U+q)),Nc=l((A+_)*(U-q)),Fs=l(Nc-Uc);if(Fs===Et)return this.double();const jc=l(N*Pn*K),kc=l(j*Pn*L),Fc=kc+jc,Lc=Nc+Uc,Mc=kc-jc,Wg=l(Fc*Fs),Gg=l(Lc*Mc),Yg=l(Fc*Mc),Zg=l(Fs*Lc);return new v(Wg,Gg,Zg,Yg)}const G=l(_*q),Z=l(A*U),W=l(j*O*K),Y=l(N*L),ee=l((_+A)*(q+U)-G-Z),ce=Y-W,fe=Y+W,ge=l(Z-D*G),et=l(ee*ce),Cr=l(fe*ge),Pr=l(ee*ge),ri=l(ce*fe);return new v(et,Cr,ri,Pr)}subtract(w){return this.add(w.negate())}wNAF(w){return I.wNAFCached(this,w,v.normalizeZ)}multiply(w){const D=w;Ui("scalar",D,Ve,i);const{p:O,f:_}=this.wNAF(D);return v.normalizeZ([O,_])[0]}multiplyUnsafe(w,D=v.ZERO){const O=w;return Ui("scalar",O,Et,i),O===Et?E:this.is0()||O===Ve?this:I.wNAFCachedUnsafe(this,O,v.normalizeZ,D)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return I.unsafeLadder(this,i).is0()}toAffine(w){return x(this,w)}clearCofactor(){const{h:w}=e;return w===Ve?this:this.multiplyUnsafe(w)}static fromHex(w,D=!1){const{d:O,a:_}=e,A=r.BYTES;w=Kt("pointHex",w,A),oo("zip215",D);const N=w.slice(),j=w[A-1];N[A-1]=j&-129;const q=Kn(N),U=D?u:r.ORDER;Ui("pointHex.y",q,Et,U);const L=l(q*q),K=l(L-Ve),G=l(O*L-_);let{isValid:Z,value:W}=f(K,G);if(!Z)throw new Error("Point.fromHex: invalid y coordinate");const Y=(W&Ve)===Ve,ee=(j&128)!==0;if(!D&&W===Et&&ee)throw new Error("Point.fromHex: x=0 and x_0=1");return ee!==Y&&(W=l(-W)),v.fromAffine({x:W,y:q})}static fromPrivateKey(w){return C(w).point}toRawBytes(){const{x:w,y:D}=this.toAffine(),O=sa(D,r.BYTES);return O[O.length-1]|=w&Ve?128:0,O}toHex(){return ac(this.toRawBytes())}}v.BASE=new v(e.Gx,e.Gy,Ve,l(e.Gx*e.Gy)),v.ZERO=new v(Et,Ve,Ve,Et);const{BASE:b,ZERO:E}=v,I=zm(v,a*8);function $(d){return ve(d,i)}function B(d){return $(Kn(d))}function C(d){const w=r.BYTES;d=Kt("private key",d,w);const D=Kt("hashed private key",s(d),2*w),O=g(D.slice(0,w)),_=D.slice(w,2*w),A=B(O),N=b.multiply(A),j=N.toRawBytes();return{head:O,prefix:_,scalar:A,point:N,pointBytes:j}}function k(d){return C(d).pointBytes}function F(d=new Uint8Array,...w){const D=$u(...w);return B(s(p(D,Kt("context",d),!!n)))}function R(d,w,D={}){d=Kt("message",d),n&&(d=n(d));const{prefix:O,scalar:_,pointBytes:A}=C(w),N=F(D.context,O,d),j=b.multiply(N).toRawBytes(),q=F(D.context,j,A,d),U=$(N+q*_);Ui("signature.s",U,Et,i);const L=$u(j,sa(U,r.BYTES));return Kt("result",L,r.BYTES*2)}const P=Wm;function T(d,w,D,O=P){const{context:_,zip215:A}=O,N=r.BYTES;d=Kt("signature",d,2*N),w=Kt("message",w),D=Kt("publicKey",D,N),A!==void 0&&oo("zip215",A),n&&(w=n(w));const j=Kn(d.slice(N,2*N));let q,U,L;try{q=v.fromHex(D,A),U=v.fromHex(d.slice(0,N),A),L=b.multiplyUnsafe(j)}catch{return!1}if(!A&&q.isSmallOrder())return!1;const K=F(_,U.toRawBytes(),q.toRawBytes(),w);return U.add(q.multiplyUnsafe(K)).subtract(L).clearCofactor().equals(v.ZERO)}return b._setWindowSize(8),{CURVE:e,getPublicKey:k,sign:R,verify:T,ExtendedPoint:v,utils:{getExtendedPublicKey:C,randomPrivateKey:()=>o(r.BYTES),precompute(d=8,w=v.BASE){return w._setWindowSize(d),w.multiply(BigInt(3)),w}}}}BigInt(0),BigInt(1);const uc=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Uu=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const Zm=BigInt(1),Nu=BigInt(2);BigInt(3);const Jm=BigInt(5),Xm=BigInt(8);function Qm(t){const e=BigInt(10),r=BigInt(20),i=BigInt(40),n=BigInt(80),s=uc,o=t*t%s*t%s,a=Ct(o,Nu,s)*o%s,c=Ct(a,Zm,s)*t%s,u=Ct(c,Jm,s)*c%s,l=Ct(u,e,s)*u%s,h=Ct(l,r,s)*l%s,f=Ct(h,i,s)*h%s,g=Ct(f,n,s)*f%s,p=Ct(g,n,s)*f%s,y=Ct(p,e,s)*u%s;return{pow_p_5_8:Ct(y,Nu,s)*t%s,b2:o}}function e1(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function t1(t,e){const r=uc,i=ve(e*e*e,r),n=ve(i*i*e,r),s=Qm(t*n).pow_p_5_8;let o=ve(t*i*s,r);const a=ve(e*o*o,r),c=o,u=ve(o*Uu,r),l=a===t,h=a===ve(-t,r),f=a===ve(-t*Uu,r);return l&&(o=c),(h||f)&&(o=u),Nm(o,r)&&(o=ve(-o,r)),{isValid:l||h,value:o}}const r1=md(uc,void 0,!0),i1={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:r1,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Xm,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:_m,randomBytes:fd,adjustScalarBytes:e1,uvRatio:t1},Dd=Ym(i1),n1="EdDSA",s1="JWT",is=".",vs="base64url",xd="utf8",_d="utf8",o1=":",a1="did",c1="key",ju="base58btc",u1="z",l1="K36",h1=32;function lc(t){return globalThis.Buffer!=null?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t}function Id(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?lc(globalThis.Buffer.allocUnsafe(t)):new Uint8Array(t)}function Sd(t,e){e||(e=t.reduce((n,s)=>n+s.length,0));const r=Id(e);let i=0;for(const n of t)r.set(n,i),i+=n.length;return lc(r)}function f1(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),i=0;i<r.length;i++)r[i]=255;for(var n=0;n<t.length;n++){var s=t.charAt(n),o=s.charCodeAt(0);if(r[o]!==255)throw new TypeError(s+" is ambiguous");r[o]=n}var a=t.length,c=t.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function h(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var y=0,m=0,x=0,S=p.length;x!==S&&p[x]===0;)x++,y++;for(var v=(S-x)*l+1>>>0,b=new Uint8Array(v);x!==S;){for(var E=p[x],I=0,$=v-1;(E!==0||I<m)&&$!==-1;$--,I++)E+=256*b[$]>>>0,b[$]=E%a>>>0,E=E/a>>>0;if(E!==0)throw new Error("Non-zero carry");m=I,x++}for(var B=v-m;B!==v&&b[B]===0;)B++;for(var C=c.repeat(y);B<v;++B)C+=t.charAt(b[B]);return C}function f(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var y=0;if(p[y]!==" "){for(var m=0,x=0;p[y]===c;)m++,y++;for(var S=(p.length-y)*u+1>>>0,v=new Uint8Array(S);p[y];){var b=r[p.charCodeAt(y)];if(b===255)return;for(var E=0,I=S-1;(b!==0||E<x)&&I!==-1;I--,E++)b+=a*v[I]>>>0,v[I]=b%256>>>0,b=b/256>>>0;if(b!==0)throw new Error("Non-zero carry");x=E,y++}if(p[y]!==" "){for(var $=S-x;$!==S&&v[$]===0;)$++;for(var B=new Uint8Array(m+(S-$)),C=m;$!==S;)B[C++]=v[$++];return B}}}function g(p){var y=f(p);if(y)return y;throw new Error(`Non-${e} character`)}return{encode:h,decodeUnsafe:f,decode:g}}var d1=f1,p1=d1;const Od=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")},g1=t=>new TextEncoder().encode(t),y1=t=>new TextDecoder().decode(t);let w1=class{constructor(e,r,i){this.name=e,this.prefix=r,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},b1=class{constructor(e,r,i){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Ad(this,e)}},m1=class{constructor(e){this.decoders=e}or(e){return Ad(this,e)}decode(e){const r=e[0],i=this.decoders[r];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};const Ad=(t,e)=>new m1({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});let v1=class{constructor(e,r,i,n){this.name=e,this.prefix=r,this.baseEncode=i,this.baseDecode=n,this.encoder=new w1(e,r,i),this.decoder=new b1(e,r,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};const Es=({name:t,prefix:e,encode:r,decode:i})=>new v1(t,e,r,i),pn=({prefix:t,name:e,alphabet:r})=>{const{encode:i,decode:n}=p1(r,e);return Es({prefix:t,name:e,encode:i,decode:s=>Od(n(s))})},E1=(t,e,r,i)=>{const n={};for(let l=0;l<e.length;++l)n[e[l]]=l;let s=t.length;for(;t[s-1]==="=";)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,u=0;for(let l=0;l<s;++l){const h=n[t[l]];if(h===void 0)throw new SyntaxError(`Non-${i} character`);c=c<<r|h,a+=r,a>=8&&(a-=8,o[u++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},D1=(t,e,r)=>{const i=e[e.length-1]==="=",n=(1<<r)-1;let s="",o=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],o+=8;o>r;)o-=r,s+=e[n&a>>o];if(o&&(s+=e[n&a<<r-o]),i)for(;s.length*r&7;)s+="=";return s},Pe=({name:t,prefix:e,bitsPerChar:r,alphabet:i})=>Es({prefix:e,name:t,encode(n){return D1(n,i,r)},decode(n){return E1(n,i,r,t)}}),x1=Es({prefix:"\0",name:"identity",encode:t=>y1(t),decode:t=>g1(t)});var _1=Object.freeze({__proto__:null,identity:x1});const I1=Pe({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var S1=Object.freeze({__proto__:null,base2:I1});const O1=Pe({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var A1=Object.freeze({__proto__:null,base8:O1});const $1=pn({prefix:"9",name:"base10",alphabet:"0123456789"});var C1=Object.freeze({__proto__:null,base10:$1});const P1=Pe({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),B1=Pe({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var T1=Object.freeze({__proto__:null,base16:P1,base16upper:B1});const R1=Pe({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),U1=Pe({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),N1=Pe({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),j1=Pe({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),k1=Pe({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),F1=Pe({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),L1=Pe({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),M1=Pe({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),q1=Pe({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var z1=Object.freeze({__proto__:null,base32:R1,base32upper:U1,base32pad:N1,base32padupper:j1,base32hex:k1,base32hexupper:F1,base32hexpad:L1,base32hexpadupper:M1,base32z:q1});const V1=pn({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),H1=pn({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var K1=Object.freeze({__proto__:null,base36:V1,base36upper:H1});const W1=pn({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),G1=pn({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Y1=Object.freeze({__proto__:null,base58btc:W1,base58flickr:G1});const Z1=Pe({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),J1=Pe({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),X1=Pe({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Q1=Pe({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var ev=Object.freeze({__proto__:null,base64:Z1,base64pad:J1,base64url:X1,base64urlpad:Q1});const $d=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),tv=$d.reduce((t,e,r)=>(t[r]=e,t),[]),rv=$d.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function iv(t){return t.reduce((e,r)=>(e+=tv[r],e),"")}function nv(t){const e=[];for(const r of t){const i=rv[r.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(i)}return new Uint8Array(e)}const sv=Es({prefix:"🚀",name:"base256emoji",encode:iv,decode:nv});var ov=Object.freeze({__proto__:null,base256emoji:sv}),av=Cd,ku=128,cv=-128,uv=Math.pow(2,31);function Cd(t,e,r){e=e||[],r=r||0;for(var i=r;t>=uv;)e[r++]=t&255|ku,t/=128;for(;t&cv;)e[r++]=t&255|ku,t>>>=7;return e[r]=t|0,Cd.bytes=r-i+1,e}var lv=aa,hv=128,Fu=127;function aa(t,i){var r=0,i=i||0,n=0,s=i,o,a=t.length;do{if(s>=a)throw aa.bytes=0,new RangeError("Could not decode varint");o=t[s++],r+=n<28?(o&Fu)<<n:(o&Fu)*Math.pow(2,n),n+=7}while(o>=hv);return aa.bytes=s-i,r}var fv=Math.pow(2,7),dv=Math.pow(2,14),pv=Math.pow(2,21),gv=Math.pow(2,28),yv=Math.pow(2,35),wv=Math.pow(2,42),bv=Math.pow(2,49),mv=Math.pow(2,56),vv=Math.pow(2,63),Ev=function(t){return t<fv?1:t<dv?2:t<pv?3:t<gv?4:t<yv?5:t<wv?6:t<bv?7:t<mv?8:t<vv?9:10},Dv={encode:av,decode:lv,encodingLength:Ev},Pd=Dv;const Lu=(t,e,r=0)=>(Pd.encode(t,e,r),e),Mu=t=>Pd.encodingLength(t),ca=(t,e)=>{const r=e.byteLength,i=Mu(t),n=i+Mu(r),s=new Uint8Array(n+r);return Lu(t,s,0),Lu(r,s,i),s.set(e,n),new xv(t,r,e,s)};let xv=class{constructor(e,r,i,n){this.code=e,this.size=r,this.digest=i,this.bytes=n}};const Bd=({name:t,code:e,encode:r})=>new _v(t,e,r);let _v=class{constructor(e,r,i){this.name=e,this.code=r,this.encode=i}digest(e){if(e instanceof Uint8Array){const r=this.encode(e);return r instanceof Uint8Array?ca(this.code,r):r.then(i=>ca(this.code,i))}else throw Error("Unknown type, must be binary type")}};const Td=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),Iv=Bd({name:"sha2-256",code:18,encode:Td("SHA-256")}),Sv=Bd({name:"sha2-512",code:19,encode:Td("SHA-512")});var Ov=Object.freeze({__proto__:null,sha256:Iv,sha512:Sv});const Rd=0,Av="identity",Ud=Od,$v=t=>ca(Rd,Ud(t)),Cv={code:Rd,name:Av,encode:Ud,digest:$v};var Pv=Object.freeze({__proto__:null,identity:Cv});new TextEncoder,new TextDecoder;const qu={..._1,...S1,...A1,...C1,...T1,...z1,...K1,...Y1,...ev,...ov};({...Ov,...Pv});function Nd(t,e,r,i){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:i}}}const zu=Nd("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),fo=Nd("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);const e=Id(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),jd={utf8:zu,"utf-8":zu,hex:qu.base16,latin1:fo,ascii:fo,binary:fo,...qu};function Ds(t,e="utf8"){const r=jd[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):r.encoder.encode(t).substring(1)}function Si(t,e="utf8"){const r=jd[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?lc(globalThis.Buffer.from(t,"utf-8")):r.decoder.decode(`${r.prefix}${t}`)}function Vu(t){return Yr(Ds(Si(t,vs),xd))}function ns(t){return Ds(Si(or(t),xd),vs)}function kd(t){const e=Si(l1,ju),r=u1+Ds(Sd([e,t]),ju);return[a1,c1,r].join(o1)}function Bv(t){return Ds(t,vs)}function Tv(t){return Si(t,vs)}function Rv(t){return Si([ns(t.header),ns(t.payload)].join(is),_d)}function Uv(t){return[ns(t.header),ns(t.payload),Bv(t.signature)].join(is)}function ua(t){const e=t.split(is),r=Vu(e[0]),i=Vu(e[1]),n=Tv(e[2]),s=Si(e.slice(0,2).join(is),_d);return{header:r,payload:i,signature:n,data:s}}function Hu(t=fd(h1)){const e=Dd.getPublicKey(t);return{secretKey:Sd([t,e]),publicKey:e}}async function Nv(t,e,r,i,n=V.fromMiliseconds(Date.now())){const s={alg:n1,typ:s1},o=kd(i.publicKey),a=n+r,c={iss:o,sub:t,aud:e,iat:n,exp:a},u=Rv({header:s,payload:c}),l=Dd.sign(u,i.secretKey.slice(0,32));return Uv({header:s,payload:c,signature:l})}function hc(t){return globalThis.Buffer!=null?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t}function Fd(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?hc(globalThis.Buffer.allocUnsafe(t)):new Uint8Array(t)}function Zi(t,e){e||(e=t.reduce((n,s)=>n+s.length,0));const r=Fd(e);let i=0;for(const n of t)r.set(n,i),i+=n.length;return hc(r)}function jv(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),i=0;i<r.length;i++)r[i]=255;for(var n=0;n<t.length;n++){var s=t.charAt(n),o=s.charCodeAt(0);if(r[o]!==255)throw new TypeError(s+" is ambiguous");r[o]=n}var a=t.length,c=t.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function h(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var y=0,m=0,x=0,S=p.length;x!==S&&p[x]===0;)x++,y++;for(var v=(S-x)*l+1>>>0,b=new Uint8Array(v);x!==S;){for(var E=p[x],I=0,$=v-1;(E!==0||I<m)&&$!==-1;$--,I++)E+=256*b[$]>>>0,b[$]=E%a>>>0,E=E/a>>>0;if(E!==0)throw new Error("Non-zero carry");m=I,x++}for(var B=v-m;B!==v&&b[B]===0;)B++;for(var C=c.repeat(y);B<v;++B)C+=t.charAt(b[B]);return C}function f(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var y=0;if(p[y]!==" "){for(var m=0,x=0;p[y]===c;)m++,y++;for(var S=(p.length-y)*u+1>>>0,v=new Uint8Array(S);p[y];){var b=r[p.charCodeAt(y)];if(b===255)return;for(var E=0,I=S-1;(b!==0||E<x)&&I!==-1;I--,E++)b+=a*v[I]>>>0,v[I]=b%256>>>0,b=b/256>>>0;if(b!==0)throw new Error("Non-zero carry");x=E,y++}if(p[y]!==" "){for(var $=S-x;$!==S&&v[$]===0;)$++;for(var B=new Uint8Array(m+(S-$)),C=m;$!==S;)B[C++]=v[$++];return B}}}function g(p){var y=f(p);if(y)return y;throw new Error(`Non-${e} character`)}return{encode:h,decodeUnsafe:f,decode:g}}var kv=jv,Fv=kv;const Lv=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")},Mv=t=>new TextEncoder().encode(t),qv=t=>new TextDecoder().decode(t);let zv=class{constructor(e,r,i){this.name=e,this.prefix=r,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Vv=class{constructor(e,r,i){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Ld(this,e)}},Hv=class{constructor(e){this.decoders=e}or(e){return Ld(this,e)}decode(e){const r=e[0],i=this.decoders[r];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};const Ld=(t,e)=>new Hv({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});let Kv=class{constructor(e,r,i,n){this.name=e,this.prefix=r,this.baseEncode=i,this.baseDecode=n,this.encoder=new zv(e,r,i),this.decoder=new Vv(e,r,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};const xs=({name:t,prefix:e,encode:r,decode:i})=>new Kv(t,e,r,i),gn=({prefix:t,name:e,alphabet:r})=>{const{encode:i,decode:n}=Fv(r,e);return xs({prefix:t,name:e,encode:i,decode:s=>Lv(n(s))})},Wv=(t,e,r,i)=>{const n={};for(let l=0;l<e.length;++l)n[e[l]]=l;let s=t.length;for(;t[s-1]==="=";)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,u=0;for(let l=0;l<s;++l){const h=n[t[l]];if(h===void 0)throw new SyntaxError(`Non-${i} character`);c=c<<r|h,a+=r,a>=8&&(a-=8,o[u++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},Gv=(t,e,r)=>{const i=e[e.length-1]==="=",n=(1<<r)-1;let s="",o=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],o+=8;o>r;)o-=r,s+=e[n&a>>o];if(o&&(s+=e[n&a<<r-o]),i)for(;s.length*r&7;)s+="=";return s},Be=({name:t,prefix:e,bitsPerChar:r,alphabet:i})=>xs({prefix:e,name:t,encode(n){return Gv(n,i,r)},decode(n){return Wv(n,i,r,t)}}),Yv=xs({prefix:"\0",name:"identity",encode:t=>qv(t),decode:t=>Mv(t)}),Zv=Object.freeze(Object.defineProperty({__proto__:null,identity:Yv},Symbol.toStringTag,{value:"Module"})),Jv=Be({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),Xv=Object.freeze(Object.defineProperty({__proto__:null,base2:Jv},Symbol.toStringTag,{value:"Module"})),Qv=Be({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),e2=Object.freeze(Object.defineProperty({__proto__:null,base8:Qv},Symbol.toStringTag,{value:"Module"})),t2=gn({prefix:"9",name:"base10",alphabet:"0123456789"}),r2=Object.freeze(Object.defineProperty({__proto__:null,base10:t2},Symbol.toStringTag,{value:"Module"})),i2=Be({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),n2=Be({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),s2=Object.freeze(Object.defineProperty({__proto__:null,base16:i2,base16upper:n2},Symbol.toStringTag,{value:"Module"})),o2=Be({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),a2=Be({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),c2=Be({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),u2=Be({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),l2=Be({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),h2=Be({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),f2=Be({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),d2=Be({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),p2=Be({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),g2=Object.freeze(Object.defineProperty({__proto__:null,base32:o2,base32hex:l2,base32hexpad:f2,base32hexpadupper:d2,base32hexupper:h2,base32pad:c2,base32padupper:u2,base32upper:a2,base32z:p2},Symbol.toStringTag,{value:"Module"})),y2=gn({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),w2=gn({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),b2=Object.freeze(Object.defineProperty({__proto__:null,base36:y2,base36upper:w2},Symbol.toStringTag,{value:"Module"})),m2=gn({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),v2=gn({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),E2=Object.freeze(Object.defineProperty({__proto__:null,base58btc:m2,base58flickr:v2},Symbol.toStringTag,{value:"Module"})),D2=Be({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),x2=Be({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),_2=Be({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),I2=Be({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),S2=Object.freeze(Object.defineProperty({__proto__:null,base64:D2,base64pad:x2,base64url:_2,base64urlpad:I2},Symbol.toStringTag,{value:"Module"})),Md=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),O2=Md.reduce((t,e,r)=>(t[r]=e,t),[]),A2=Md.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function $2(t){return t.reduce((e,r)=>(e+=O2[r],e),"")}function C2(t){const e=[];for(const r of t){const i=A2[r.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(i)}return new Uint8Array(e)}const P2=xs({prefix:"🚀",name:"base256emoji",encode:$2,decode:C2}),B2=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:P2},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const Ku={...Zv,...Xv,...e2,...r2,...s2,...g2,...b2,...E2,...S2,...B2};function qd(t,e,r,i){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:i}}}const Wu=qd("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),po=qd("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);const e=Fd(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),zd={utf8:Wu,"utf-8":Wu,hex:Ku.base16,latin1:po,ascii:po,binary:po,...Ku};function bt(t,e="utf8"){const r=zd[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?hc(globalThis.Buffer.from(t,"utf-8")):r.decoder.decode(`${r.prefix}${t}`)}function at(t,e="utf8"){const r=zd[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):r.encoder.encode(t).substring(1)}const T2={waku:{publish:"waku_publish",batchPublish:"waku_batchPublish",subscribe:"waku_subscribe",batchSubscribe:"waku_batchSubscribe",subscription:"waku_subscription",unsubscribe:"waku_unsubscribe",batchUnsubscribe:"waku_batchUnsubscribe",batchFetchMessages:"waku_batchFetchMessages"},irn:{publish:"irn_publish",batchPublish:"irn_batchPublish",subscribe:"irn_subscribe",batchSubscribe:"irn_batchSubscribe",subscription:"irn_subscription",unsubscribe:"irn_unsubscribe",batchUnsubscribe:"irn_batchUnsubscribe",batchFetchMessages:"irn_batchFetchMessages"},iridium:{publish:"iridium_publish",batchPublish:"iridium_batchPublish",subscribe:"iridium_subscribe",batchSubscribe:"iridium_batchSubscribe",subscription:"iridium_subscription",unsubscribe:"iridium_unsubscribe",batchUnsubscribe:"iridium_batchUnsubscribe",batchFetchMessages:"iridium_batchFetchMessages"}};var go,Gu;function Vd(){if(Gu)return go;Gu=1;const t="Input must be an string, Buffer or Uint8Array";function e(o){let a;if(o instanceof Uint8Array)a=o;else if(typeof o=="string")a=new TextEncoder().encode(o);else throw new Error(t);return a}function r(o){return Array.prototype.map.call(o,function(a){return(a<16?"0":"")+a.toString(16)}).join("")}function i(o){return(4294967296+o).toString(16).substring(1)}function n(o,a,c){let u=`
4
- `+o+" = ";for(let l=0;l<a.length;l+=2){if(c===32)u+=i(a[l]).toUpperCase(),u+=" ",u+=i(a[l+1]).toUpperCase();else if(c===64)u+=i(a[l+1]).toUpperCase(),u+=i(a[l]).toUpperCase();else throw new Error("Invalid size "+c);l%6===4?u+=`
5
- `+new Array(o.length+4).join(" "):l<a.length-2&&(u+=" ")}console.log(u)}function s(o,a,c){let u=new Date().getTime();const l=new Uint8Array(a);for(let f=0;f<a;f++)l[f]=f%256;const h=new Date().getTime();console.log("Generated random input in "+(h-u)+"ms"),u=h;for(let f=0;f<c;f++){const g=o(l),p=new Date().getTime(),y=p-u;u=p,console.log("Hashed in "+y+"ms: "+g.substring(0,20)+"..."),console.log(Math.round(a/(1<<20)/(y/1e3)*100)/100+" MB PER SECOND")}}return go={normalizeInput:e,toHex:r,debugPrint:n,testSpeed:s},go}var yo,Yu;function R2(){if(Yu)return yo;Yu=1;const t=Vd();function e(x,S,v){const b=x[S]+x[v];let E=x[S+1]+x[v+1];b>=4294967296&&E++,x[S]=b,x[S+1]=E}function r(x,S,v,b){let E=x[S]+v;v<0&&(E+=4294967296);let I=x[S+1]+b;E>=4294967296&&I++,x[S]=E,x[S+1]=I}function i(x,S){return x[S]^x[S+1]<<8^x[S+2]<<16^x[S+3]<<24}function n(x,S,v,b,E,I){const $=u[E],B=u[E+1],C=u[I],k=u[I+1];e(c,x,S),r(c,x,$,B);let F=c[b]^c[x],R=c[b+1]^c[x+1];c[b]=R,c[b+1]=F,e(c,v,b),F=c[S]^c[v],R=c[S+1]^c[v+1],c[S]=F>>>24^R<<8,c[S+1]=R>>>24^F<<8,e(c,x,S),r(c,x,C,k),F=c[b]^c[x],R=c[b+1]^c[x+1],c[b]=F>>>16^R<<16,c[b+1]=R>>>16^F<<16,e(c,v,b),F=c[S]^c[v],R=c[S+1]^c[v+1],c[S]=R>>>31^F<<1,c[S+1]=F>>>31^R<<1}const s=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),o=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3],a=new Uint8Array(o.map(function(x){return x*2})),c=new Uint32Array(32),u=new Uint32Array(32);function l(x,S){let v=0;for(v=0;v<16;v++)c[v]=x.h[v],c[v+16]=s[v];for(c[24]=c[24]^x.t,c[25]=c[25]^x.t/4294967296,S&&(c[28]=~c[28],c[29]=~c[29]),v=0;v<32;v++)u[v]=i(x.b,4*v);for(v=0;v<12;v++)n(0,8,16,24,a[v*16+0],a[v*16+1]),n(2,10,18,26,a[v*16+2],a[v*16+3]),n(4,12,20,28,a[v*16+4],a[v*16+5]),n(6,14,22,30,a[v*16+6],a[v*16+7]),n(0,10,20,30,a[v*16+8],a[v*16+9]),n(2,12,22,24,a[v*16+10],a[v*16+11]),n(4,14,16,26,a[v*16+12],a[v*16+13]),n(6,8,18,28,a[v*16+14],a[v*16+15]);for(v=0;v<16;v++)x.h[v]=x.h[v]^c[v]^c[v+16]}const h=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);function f(x,S,v,b){if(x===0||x>64)throw new Error("Illegal output length, expected 0 < length <= 64");if(S&&S.length>64)throw new Error("Illegal key, expected Uint8Array with 0 < length <= 64");if(v&&v.length!==16)throw new Error("Illegal salt, expected Uint8Array with length is 16");if(b&&b.length!==16)throw new Error("Illegal personal, expected Uint8Array with length is 16");const E={b:new Uint8Array(128),h:new Uint32Array(16),t:0,c:0,outlen:x};h.fill(0),h[0]=x,S&&(h[1]=S.length),h[2]=1,h[3]=1,v&&h.set(v,32),b&&h.set(b,48);for(let I=0;I<16;I++)E.h[I]=s[I]^i(h,I*4);return S&&(g(E,S),E.c=128),E}function g(x,S){for(let v=0;v<S.length;v++)x.c===128&&(x.t+=x.c,l(x,!1),x.c=0),x.b[x.c++]=S[v]}function p(x){for(x.t+=x.c;x.c<128;)x.b[x.c++]=0;l(x,!0);const S=new Uint8Array(x.outlen);for(let v=0;v<x.outlen;v++)S[v]=x.h[v>>2]>>8*(v&3);return S}function y(x,S,v,b,E){v=v||64,x=t.normalizeInput(x),b&&(b=t.normalizeInput(b)),E&&(E=t.normalizeInput(E));const I=f(v,S,b,E);return g(I,x),p(I)}function m(x,S,v,b,E){const I=y(x,S,v,b,E);return t.toHex(I)}return yo={blake2b:y,blake2bHex:m,blake2bInit:f,blake2bUpdate:g,blake2bFinal:p},yo}var wo,Zu;function U2(){if(Zu)return wo;Zu=1;const t=Vd();function e(p,y){return p[y]^p[y+1]<<8^p[y+2]<<16^p[y+3]<<24}function r(p,y,m,x,S,v){o[p]=o[p]+o[y]+S,o[x]=i(o[x]^o[p],16),o[m]=o[m]+o[x],o[y]=i(o[y]^o[m],12),o[p]=o[p]+o[y]+v,o[x]=i(o[x]^o[p],8),o[m]=o[m]+o[x],o[y]=i(o[y]^o[m],7)}function i(p,y){return p>>>y^p<<32-y}const n=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),s=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0]),o=new Uint32Array(16),a=new Uint32Array(16);function c(p,y){let m=0;for(m=0;m<8;m++)o[m]=p.h[m],o[m+8]=n[m];for(o[12]^=p.t,o[13]^=p.t/4294967296,y&&(o[14]=~o[14]),m=0;m<16;m++)a[m]=e(p.b,4*m);for(m=0;m<10;m++)r(0,4,8,12,a[s[m*16+0]],a[s[m*16+1]]),r(1,5,9,13,a[s[m*16+2]],a[s[m*16+3]]),r(2,6,10,14,a[s[m*16+4]],a[s[m*16+5]]),r(3,7,11,15,a[s[m*16+6]],a[s[m*16+7]]),r(0,5,10,15,a[s[m*16+8]],a[s[m*16+9]]),r(1,6,11,12,a[s[m*16+10]],a[s[m*16+11]]),r(2,7,8,13,a[s[m*16+12]],a[s[m*16+13]]),r(3,4,9,14,a[s[m*16+14]],a[s[m*16+15]]);for(m=0;m<8;m++)p.h[m]^=o[m]^o[m+8]}function u(p,y){if(!(p>0&&p<=32))throw new Error("Incorrect output length, should be in [1, 32]");const m=y?y.length:0;if(y&&!(m>0&&m<=32))throw new Error("Incorrect key length, should be in [1, 32]");const x={h:new Uint32Array(n),b:new Uint8Array(64),c:0,t:0,outlen:p};return x.h[0]^=16842752^m<<8^p,m>0&&(l(x,y),x.c=64),x}function l(p,y){for(let m=0;m<y.length;m++)p.c===64&&(p.t+=p.c,c(p,!1),p.c=0),p.b[p.c++]=y[m]}function h(p){for(p.t+=p.c;p.c<64;)p.b[p.c++]=0;c(p,!0);const y=new Uint8Array(p.outlen);for(let m=0;m<p.outlen;m++)y[m]=p.h[m>>2]>>8*(m&3)&255;return y}function f(p,y,m){m=m||32,p=t.normalizeInput(p);const x=u(m,y);return l(x,p),h(x)}function g(p,y,m){const x=f(p,y,m);return t.toHex(x)}return wo={blake2s:f,blake2sHex:g,blake2sInit:u,blake2sUpdate:l,blake2sFinal:h},wo}var bo,Ju;function N2(){if(Ju)return bo;Ju=1;const t=R2(),e=U2();return bo={blake2b:t.blake2b,blake2bHex:t.blake2bHex,blake2bInit:t.blake2bInit,blake2bUpdate:t.blake2bUpdate,blake2bFinal:t.blake2bFinal,blake2s:e.blake2s,blake2sHex:e.blake2sHex,blake2sInit:e.blake2sInit,blake2sUpdate:e.blake2sUpdate,blake2sFinal:e.blake2sFinal},bo}var j2=N2(),Ni={exports:{}},mo,Xu;function k2(){if(Xu)return mo;Xu=1;function t(r){try{return JSON.stringify(r)}catch{return'"[Circular]"'}}mo=e;function e(r,i,n){var s=n&&n.stringify||t,o=1;if(typeof r=="object"&&r!==null){var a=i.length+o;if(a===1)return r;var c=new Array(a);c[0]=s(r);for(var u=1;u<a;u++)c[u]=s(i[u]);return c.join(" ")}if(typeof r!="string")return r;var l=i.length;if(l===0)return r;for(var h="",f=1-o,g=-1,p=r&&r.length||0,y=0;y<p;){if(r.charCodeAt(y)===37&&y+1<p){switch(g=g>-1?g:0,r.charCodeAt(y+1)){case 100:case 102:if(f>=l||i[f]==null)break;g<y&&(h+=r.slice(g,y)),h+=Number(i[f]),g=y+2,y++;break;case 105:if(f>=l||i[f]==null)break;g<y&&(h+=r.slice(g,y)),h+=Math.floor(Number(i[f])),g=y+2,y++;break;case 79:case 111:case 106:if(f>=l||i[f]===void 0)break;g<y&&(h+=r.slice(g,y));var m=typeof i[f];if(m==="string"){h+="'"+i[f]+"'",g=y+2,y++;break}if(m==="function"){h+=i[f].name||"<anonymous>",g=y+2,y++;break}h+=s(i[f]),g=y+2,y++;break;case 115:if(f>=l)break;g<y&&(h+=r.slice(g,y)),h+=String(i[f]),g=y+2,y++;break;case 37:g<y&&(h+=r.slice(g,y)),h+="%",g=y+2,y++,f--;break}++f}++y}return g===-1?r:(g<p&&(h+=r.slice(g)),h)}return mo}var Qu;function F2(){if(Qu)return Ni.exports;Qu=1;const t=k2();Ni.exports=l;const e=T().console||{},r={mapHttpRequest:$,mapHttpResponse:$,wrapRequestSerializer:B,wrapResponseSerializer:B,wrapErrorSerializer:B,req:$,res:$,err:E,errWithCause:E};function i(d,w){return d==="silent"?1/0:w.levels.values[d]}const n=Symbol("pino.logFuncs"),s=Symbol("pino.hierarchy"),o={error:"log",fatal:"error",warn:"error",info:"log",debug:"log",trace:"log"};function a(d,w){const D={logger:w,parent:d[s]};w[s]=D}function c(d,w,D){const O={};w.forEach(_=>{O[_]=D[_]?D[_]:e[_]||e[o[_]||"log"]||C}),d[n]=O}function u(d,w){return Array.isArray(d)?d.filter(function(O){return O!=="!stdSerializers.err"}):d===!0?Object.keys(w):!1}function l(d){d=d||{},d.browser=d.browser||{};const w=d.browser.transmit;if(w&&typeof w.send!="function")throw Error("pino: transmit option must have a send function");const D=d.browser.write||e;d.browser.write&&(d.browser.asObject=!0);const O=d.serializers||{},_=u(d.browser.serialize,O);let A=d.browser.serialize;Array.isArray(d.browser.serialize)&&d.browser.serialize.indexOf("!stdSerializers.err")>-1&&(A=!1);const N=Object.keys(d.customLevels||{}),j=["error","fatal","warn","info","debug","trace"].concat(N);typeof D=="function"&&j.forEach(function(Y){D[Y]=D}),(d.enabled===!1||d.browser.disabled)&&(d.level="silent");const q=d.level||"info",U=Object.create(D);U.log||(U.log=C),c(U,j,D),a({},U),Object.defineProperty(U,"levelVal",{get:K}),Object.defineProperty(U,"level",{get:G,set:Z});const L={transmit:w,serialize:_,asObject:d.browser.asObject,asObjectBindingsOnly:d.browser.asObjectBindingsOnly,formatters:d.browser.formatters,levels:j,timestamp:I(d),messageKey:d.messageKey||"msg",onChild:d.onChild||C};U.levels=h(d),U.level=q,U.isLevelEnabled=function(Y){return this.levels.values[Y]?this.levels.values[Y]>=this.levels.values[this.level]:!1},U.setMaxListeners=U.getMaxListeners=U.emit=U.addListener=U.on=U.prependListener=U.once=U.prependOnceListener=U.removeListener=U.removeAllListeners=U.listeners=U.listenerCount=U.eventNames=U.write=U.flush=C,U.serializers=O,U._serialize=_,U._stdErrSerialize=A,U.child=function(...Y){return W.call(this,L,...Y)},w&&(U._logEvent=b());function K(){return i(this.level,this)}function G(){return this._level}function Z(Y){if(Y!=="silent"&&!this.levels.values[Y])throw Error("unknown level "+Y);this._level=Y,p(this,L,U,"error"),p(this,L,U,"fatal"),p(this,L,U,"warn"),p(this,L,U,"info"),p(this,L,U,"debug"),p(this,L,U,"trace"),N.forEach(ee=>{p(this,L,U,ee)})}function W(Y,ee,ce){if(!ee)throw new Error("missing bindings for child Pino");ce=ce||{},_&&ee.serializers&&(ce.serializers=ee.serializers);const fe=ce.serializers;if(_&&fe){var ge=Object.assign({},O,fe),et=d.browser.serialize===!0?Object.keys(ge):_;delete ee.serializers,S([ee],et,ge,this._stdErrSerialize)}function Cr(ri){this._childLevel=(ri._childLevel|0)+1,this.bindings=ee,ge&&(this.serializers=ge,this._serialize=et),w&&(this._logEvent=b([].concat(ri._logEvent.bindings,ee)))}Cr.prototype=this;const Pr=new Cr(this);return a(this,Pr),Pr.child=function(...ri){return W.call(this,Y,...ri)},Pr.level=ce.level||this.level,Y.onChild(Pr),Pr}return U}function h(d){const w=d.customLevels||{},D=Object.assign({},l.levels.values,w),O=Object.assign({},l.levels.labels,f(w));return{values:D,labels:O}}function f(d){const w={};return Object.keys(d).forEach(function(D){w[d[D]]=D}),w}l.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}},l.stdSerializers=r,l.stdTimeFunctions=Object.assign({},{nullTime:k,epochTime:F,unixTime:R,isoTime:P});function g(d){const w=[];d.bindings&&w.push(d.bindings);let D=d[s];for(;D.parent;)D=D.parent,D.logger.bindings&&w.push(D.logger.bindings);return w.reverse()}function p(d,w,D,O){if(Object.defineProperty(d,O,{value:i(d.level,D)>i(O,D)?C:D[n][O],writable:!0,enumerable:!0,configurable:!0}),d[O]===C){if(!w.transmit)return;const A=w.transmit.level||d.level,N=i(A,D);if(i(O,D)<N)return}d[O]=m(d,w,D,O);const _=g(d);_.length!==0&&(d[O]=y(_,d[O]))}function y(d,w){return function(){return w.apply(this,[...d,...arguments])}}function m(d,w,D,O){return(function(_){return function(){const N=w.timestamp(),j=new Array(arguments.length),q=Object.getPrototypeOf&&Object.getPrototypeOf(this)===e?e:this;for(var U=0;U<j.length;U++)j[U]=arguments[U];var L=!1;if(w.serialize&&(S(j,this._serialize,this.serializers,this._stdErrSerialize),L=!0),w.asObject||w.formatters?_.call(q,...x(this,O,j,N,w)):_.apply(q,j),w.transmit){const K=w.transmit.level||d._level,G=i(K,D),Z=i(O,D);if(Z<G)return;v(this,{ts:N,methodLevel:O,methodValue:Z,transmitValue:D.levels.values[w.transmit.level||d._level],send:w.transmit.send,val:i(d._level,D)},j,L)}}})(d[n][O])}function x(d,w,D,O,_){const{level:A,log:N=K=>K}=_.formatters||{},j=D.slice();let q=j[0];const U={};let L=(d._childLevel|0)+1;if(L<1&&(L=1),O&&(U.time=O),A){const K=A(w,d.levels.values[w]);Object.assign(U,K)}else U.level=d.levels.values[w];if(_.asObjectBindingsOnly){if(q!==null&&typeof q=="object")for(;L--&&typeof j[0]=="object";)Object.assign(U,j.shift());return[N(U),...j]}else{if(q!==null&&typeof q=="object"){for(;L--&&typeof j[0]=="object";)Object.assign(U,j.shift());q=j.length?t(j.shift(),j):void 0}else typeof q=="string"&&(q=t(j.shift(),j));return q!==void 0&&(U[_.messageKey]=q),[N(U)]}}function S(d,w,D,O){for(const _ in d)if(O&&d[_]instanceof Error)d[_]=l.stdSerializers.err(d[_]);else if(typeof d[_]=="object"&&!Array.isArray(d[_])&&w)for(const A in d[_])w.indexOf(A)>-1&&A in D&&(d[_][A]=D[A](d[_][A]))}function v(d,w,D,O=!1){const _=w.send,A=w.ts,N=w.methodLevel,j=w.methodValue,q=w.val,U=d._logEvent.bindings;O||S(D,d._serialize||Object.keys(d.serializers),d.serializers,d._stdErrSerialize===void 0?!0:d._stdErrSerialize),d._logEvent.ts=A,d._logEvent.messages=D.filter(function(L){return U.indexOf(L)===-1}),d._logEvent.level.label=N,d._logEvent.level.value=j,_(N,d._logEvent,q),d._logEvent=b(U)}function b(d){return{ts:0,messages:[],bindings:d||[],level:{label:"",value:0}}}function E(d){const w={type:d.constructor.name,msg:d.message,stack:d.stack};for(const D in d)w[D]===void 0&&(w[D]=d[D]);return w}function I(d){return typeof d.timestamp=="function"?d.timestamp:d.timestamp===!1?k:F}function $(){return{}}function B(d){return d}function C(){}function k(){return!1}function F(){return Date.now()}function R(){return Math.round(Date.now()/1e3)}function P(){return new Date(Date.now()).toISOString()}function T(){function d(w){return typeof w<"u"&&w}try{return typeof globalThis<"u"||Object.defineProperty(Object.prototype,"globalThis",{get:function(){return delete Object.prototype.globalThis,this.globalThis=this},configurable:!0}),globalThis}catch{return d(self)||d(window)||d(this)||{}}}return Ni.exports.default=l,Ni.exports.pino=l,Ni.exports}var fi=F2();const Hd=Wa(fi),L2={level:"info"},_s="custom_context",fc=1e3*1024;var M2=Object.defineProperty,q2=(t,e,r)=>e in t?M2(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Er=(t,e,r)=>q2(t,typeof e!="symbol"?e+"":e,r);let z2=class{constructor(e){Er(this,"nodeValue"),Er(this,"sizeInBytes"),Er(this,"next"),this.nodeValue=e,this.sizeInBytes=new TextEncoder().encode(this.nodeValue).length,this.next=null}get value(){return this.nodeValue}get size(){return this.sizeInBytes}},el=class{constructor(e){Er(this,"lengthInNodes"),Er(this,"sizeInBytes"),Er(this,"head"),Er(this,"tail"),Er(this,"maxSizeInBytes"),this.head=null,this.tail=null,this.lengthInNodes=0,this.maxSizeInBytes=e,this.sizeInBytes=0}append(e){const r=new z2(e);if(r.size>this.maxSizeInBytes)throw new Error(`[LinkedList] Value too big to insert into list: ${e} with size ${r.size}`);for(;this.size+r.size>this.maxSizeInBytes;)this.shift();this.head?(this.tail&&(this.tail.next=r),this.tail=r):(this.head=r,this.tail=r),this.lengthInNodes++,this.sizeInBytes+=r.size}shift(){if(!this.head)return;const e=this.head;this.head=this.head.next,this.head||(this.tail=null),this.lengthInNodes--,this.sizeInBytes-=e.size}toArray(){const e=[];let r=this.head;for(;r!==null;)e.push(r.value),r=r.next;return e}get length(){return this.lengthInNodes}get size(){return this.sizeInBytes}toOrderedArray(){return Array.from(this)}[Symbol.iterator](){let e=this.head;return{next:()=>{if(!e)return{done:!0,value:null};const r=e.value;return e=e.next,{done:!1,value:r}}}}};var V2=Object.defineProperty,H2=(t,e,r)=>e in t?V2(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Bn=(t,e,r)=>H2(t,typeof e!="symbol"?e+"":e,r);let Kd=class{constructor(e,r=fc){Bn(this,"logs"),Bn(this,"level"),Bn(this,"levelValue"),Bn(this,"MAX_LOG_SIZE_IN_BYTES"),this.level=e??"error",this.levelValue=fi.levels.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=r,this.logs=new el(this.MAX_LOG_SIZE_IN_BYTES)}forwardToConsole(e,r){r===fi.levels.values.error?console.error(e):r===fi.levels.values.warn?console.warn(e):r===fi.levels.values.debug?console.debug(e):r===fi.levels.values.trace?console.trace(e):console.log(e)}appendToLogs(e){this.logs.append(or({timestamp:new Date().toISOString(),log:e}));const r=typeof e=="string"?JSON.parse(e).level:e.level;r>=this.levelValue&&this.forwardToConsole(e,r)}getLogs(){return this.logs}clearLogs(){this.logs=new el(this.MAX_LOG_SIZE_IN_BYTES)}getLogArray(){return Array.from(this.logs)}logsToBlob(e){const r=this.getLogArray();return r.push(or({extraMetadata:e})),new Blob(r,{type:"application/json"})}};var K2=Object.defineProperty,W2=(t,e,r)=>e in t?K2(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,G2=(t,e,r)=>W2(t,e+"",r);let Y2=class{constructor(e,r=fc){G2(this,"baseChunkLogger"),this.baseChunkLogger=new Kd(e,r)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}downloadLogsBlobInBrowser(e){const r=URL.createObjectURL(this.logsToBlob(e)),i=document.createElement("a");i.href=r,i.download=`walletconnect-logs-${new Date().toISOString()}.txt`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r)}};var Z2=Object.defineProperty,J2=(t,e,r)=>e in t?Z2(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,X2=(t,e,r)=>J2(t,e+"",r);let Q2=class{constructor(e,r=fc){X2(this,"baseChunkLogger"),this.baseChunkLogger=new Kd(e,r)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}};var eE=Object.defineProperty,tE=Object.defineProperties,rE=Object.getOwnPropertyDescriptors,tl=Object.getOwnPropertySymbols,iE=Object.prototype.hasOwnProperty,nE=Object.prototype.propertyIsEnumerable,rl=(t,e,r)=>e in t?eE(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ss=(t,e)=>{for(var r in e||(e={}))iE.call(e,r)&&rl(t,r,e[r]);if(tl)for(var r of tl(e))nE.call(e,r)&&rl(t,r,e[r]);return t},os=(t,e)=>tE(t,rE(e));function sE(t){return os(ss({},t),{level:t?.level||L2.level})}function oE(t,e,r=_s){return t[r]=e,t}function Qe(t,e=_s){return t[e]||""}function aE(t,e,r=_s){const i=Qe(t,r);return i.trim()?`${i}/${e}`:e}function ut(t,e,r=_s){const i=aE(t,e,r),n=t.child({context:i});return oE(n,i,r)}function cE(t){var e,r;const i=new Y2((e=t.opts)==null?void 0:e.level,t.maxSizeInBytes);return{logger:Hd(os(ss({},t.opts),{level:"trace",browser:os(ss({},(r=t.opts)==null?void 0:r.browser),{write:n=>i.write(n)})})),chunkLoggerController:i}}function uE(t){var e;const r=new Q2((e=t.opts)==null?void 0:e.level,t.maxSizeInBytes);return{logger:Hd(os(ss({},t.opts),{level:"trace"}),r),chunkLoggerController:r}}function Wd(t){return typeof t.loggerOverride<"u"&&typeof t.loggerOverride!="string"?{logger:t.loggerOverride,chunkLoggerController:null}:typeof window<"u"?cE(t):uE(t)}var lE={};const hE=":";function ir(t){const[e,r]=t.split(hE);return{namespace:e,reference:r}}function il(t,e=[]){const r=[];return Object.keys(t).forEach(i=>{if(e.length&&!e.includes(i))return;const n=t[i];r.push(...n.accounts)}),r}function Gd(t,e){return t.includes(":")?[t]:e.chains||[]}var fE=Object.defineProperty,dE=Object.defineProperties,pE=Object.getOwnPropertyDescriptors,nl=Object.getOwnPropertySymbols,gE=Object.prototype.hasOwnProperty,yE=Object.prototype.propertyIsEnumerable,la=(t,e,r)=>e in t?fE(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,sl=(t,e)=>{for(var r in e||(e={}))gE.call(e,r)&&la(t,r,e[r]);if(nl)for(var r of nl(e))yE.call(e,r)&&la(t,r,e[r]);return t},wE=(t,e)=>dE(t,pE(e)),ol=(t,e,r)=>la(t,typeof e!="symbol"?e+"":e,r);const bE="ReactNative",ot={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},mE="js";function as(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function Ar(){return!sr.getDocument()&&!!sr.getNavigator()&&navigator.product===bE}function vE(){return Ar()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="android"}function EE(){return Ar()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="ios"}function Oi(){return!as()&&!!sr.getNavigator()&&!!sr.getDocument()}function yn(){return Ar()?ot.reactNative:as()?ot.node:Oi()?ot.browser:ot.unknown}function al(){var t;try{return Ar()&&typeof global<"u"&&typeof(global==null?void 0:global.Application)<"u"?(t=global.Application)==null?void 0:t.applicationId:void 0}catch{return}}function DE(t,e){const r=new URLSearchParams(t);return Object.entries(e).sort(([i],[n])=>i.localeCompare(n)).forEach(([i,n])=>{n!=null&&r.set(i,String(n))}),r.toString()}function xE(t){var e,r;const i=Yd();try{return t!=null&&t.url&&i.url&&new URL(t.url).host!==new URL(i.url).host&&(console.warn(`The configured WalletConnect 'metadata.url':${t.url} differs from the actual page url:${i.url}. This is probably unintended and can lead to issues.`),t.url=i.url),(e=t?.icons)!=null&&e.length&&t.icons.length>0&&(t.icons=t.icons.filter(n=>n!=="")),wE(sl(sl({},i),t),{url:t?.url||i.url,name:t?.name||i.name,description:t?.description||i.description,icons:(r=t?.icons)!=null&&r.length&&t.icons.length>0?t.icons:i.icons})}catch(n){return console.warn("Error populating app metadata",n),t||i}}function Yd(){return c0.getWindowMetadata()||{name:"",description:"",url:"",icons:[""]}}function _E(){if(yn()===ot.reactNative&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"){const{OS:r,Version:i}=global.Platform;return[r,i].join("-")}const t=Sy();if(t===null)return"unknown";const e=t.os?t.os.replace(" ","").toLowerCase():"unknown";return t.type==="browser"?[e,t.name,t.version].join("-"):[e,t.version].join("-")}function IE(){var t;const e=yn();return e===ot.browser?[e,((t=sr.getLocation())==null?void 0:t.host)||"unknown"].join(":"):e}function Zd(t,e,r){const i=_E(),n=IE();return[[t,e].join("-"),[mE,r].join("-"),i,n].join("/")}function SE({protocol:t,version:e,relayUrl:r,sdkVersion:i,auth:n,projectId:s,useOnCloseEvent:o,bundleId:a,packageName:c}){const u=r.split("?"),l=Zd(t,e,i),h={auth:n,ua:l,projectId:s,useOnCloseEvent:o,packageName:c||void 0,bundleId:a||void 0},f=DE(u[1]||"",h);return u[0]+"?"+f}function zr(t,e){return t.filter(r=>e.includes(r)).length===t.length}function ha(t){return Object.fromEntries(t.entries())}function fa(t){return new Map(Object.entries(t))}function jr(t=V.FIVE_MINUTES,e){const r=V.toMiliseconds(t||V.FIVE_MINUTES);let i,n,s,o;return{resolve:a=>{s&&i&&(clearTimeout(s),i(a),o=Promise.resolve(a))},reject:a=>{s&&n&&(clearTimeout(s),n(a))},done:()=>new Promise((a,c)=>{if(o)return a(o);s=setTimeout(()=>{const u=new Error(e);o=Promise.reject(u),c(u)},r),i=a,n=c})}}function Ft(t,e,r){return new Promise(async(i,n)=>{const s=setTimeout(()=>n(new Error(r)),e);try{const o=await t;i(o)}catch(o){n(o)}clearTimeout(s)})}function Jd(t,e){if(typeof e=="string"&&e.startsWith(`${t}:`))return e;if(t.toLowerCase()==="topic"){if(typeof e!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}else if(t.toLowerCase()==="id"){if(typeof e!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${e}`}throw new Error(`Unknown expirer target type: ${t}`)}function OE(t){return Jd("topic",t)}function AE(t){return Jd("id",t)}function Xd(t){const[e,r]=t.split(":"),i={id:void 0,topic:void 0};if(e==="topic"&&typeof r=="string")i.topic=r;else if(e==="id"&&Number.isInteger(Number(r)))i.id=Number(r);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${r}`);return i}function we(t,e){return V.fromMiliseconds(Date.now()+V.toMiliseconds(t))}function kt(t){return Date.now()>=V.toMiliseconds(t)}function ie(t,e){return`${t}${e?`:${e}`:""}`}function Lt(t=[],e=[]){return[...new Set([...t,...e])]}async function $E({id:t,topic:e,wcDeepLink:r}){var i;try{if(!r)return;const n=typeof r=="string"?JSON.parse(r):r,s=n?.href;if(typeof s!="string")return;const o=CE(s,t,e),a=yn();if(a===ot.browser){if(!((i=sr.getDocument())!=null&&i.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}PE(o)}else a===ot.reactNative&&typeof(global==null?void 0:global.Linking)<"u"&&await global.Linking.openURL(o)}catch(n){console.error(n)}}function CE(t,e,r){const i=`requestId=${e}&sessionTopic=${r}`;t.endsWith("/")&&(t=t.slice(0,-1));let n=`${t}`;if(t.startsWith("https://t.me")){const s=t.includes("?")?"&startapp=":"?startapp=";n=`${n}${s}${UE(i,!0)}`}else n=`${n}/wc?${i}`;return n}function PE(t){let e="_self";RE()?e="_top":(TE()||t.startsWith("https://")||t.startsWith("http://"))&&(e="_blank"),window.open(t,e,"noreferrer noopener")}async function BE(t,e){let r="";try{if(Oi()&&(r=localStorage.getItem(e),r))return r;r=await t.getItem(e)}catch(i){console.error(i)}return r}function cl(t,e){if(!t.includes(e))return null;const r=t.split(/([&,?,=])/),i=r.indexOf(e);return r[i+2]}function ul(){return typeof crypto<"u"&&crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,t=>{const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})}function dc(){return typeof process<"u"&&lE.IS_VITEST==="true"}function TE(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function RE(){try{return window.self!==window.top}catch{return!1}}function UE(t,e=!1){const r=Buffer.from(t).toString("base64");return e?r.replace(/[=]/g,""):r}function Qd(t){return Buffer.from(t,"base64").toString("utf-8")}function NE(t){return new Promise(e=>setTimeout(e,t))}let jE=class{constructor({limit:e}){ol(this,"limit"),ol(this,"set"),this.limit=e,this.set=new Set}add(e){if(!this.set.has(e)){if(this.set.size>=this.limit){const r=this.set.values().next().value;r&&this.set.delete(r)}this.set.add(e)}}has(e){return this.set.has(e)}};const Tn=BigInt(2**32-1),ll=BigInt(32);function ep(t,e=!1){return e?{h:Number(t&Tn),l:Number(t>>ll&Tn)}:{h:Number(t>>ll&Tn)|0,l:Number(t&Tn)|0}}function tp(t,e=!1){const r=t.length;let i=new Uint32Array(r),n=new Uint32Array(r);for(let s=0;s<r;s++){const{h:o,l:a}=ep(t[s],e);[i[s],n[s]]=[o,a]}return[i,n]}const hl=(t,e,r)=>t>>>r,fl=(t,e,r)=>t<<32-r|e>>>r,br=(t,e,r)=>t>>>r|e<<32-r,mr=(t,e,r)=>t<<32-r|e>>>r,Ki=(t,e,r)=>t<<64-r|e>>>r-32,Wi=(t,e,r)=>t>>>r-32|e<<64-r,kE=(t,e)=>e,FE=(t,e)=>t,LE=(t,e,r)=>t<<r|e>>>32-r,ME=(t,e,r)=>e<<r|t>>>32-r,qE=(t,e,r)=>e<<r-32|t>>>64-r,zE=(t,e,r)=>t<<r-32|e>>>64-r;function It(t,e,r,i){const n=(e>>>0)+(i>>>0);return{h:t+r+(n/2**32|0)|0,l:n|0}}const pc=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),gc=(t,e,r,i)=>e+r+i+(t/2**32|0)|0,VE=(t,e,r,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(i>>>0),HE=(t,e,r,i,n)=>e+r+i+n+(t/2**32|0)|0,KE=(t,e,r,i,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(i>>>0)+(n>>>0),WE=(t,e,r,i,n,s)=>e+r+i+n+s+(t/2**32|0)|0,oi=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function Is(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function ar(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function At(t,...e){if(!Is(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function Ss(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");ar(t.outputLen),ar(t.blockLen)}function Or(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function yc(t,e){At(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function on(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function vt(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function vo(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Pt(t,e){return t<<32-e|t>>>e}const rp=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function ip(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}const Zt=rp?t=>t:t=>ip(t);function GE(t){for(let e=0;e<t.length;e++)t[e]=ip(t[e]);return t}const vr=rp?t=>t:GE,np=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",YE=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function bi(t){if(At(t),np)return t.toHex();let e="";for(let r=0;r<t.length;r++)e+=YE[t[r]];return e}const Wt={_0:48,_9:57,A:65,F:70,a:97,f:102};function dl(t){if(t>=Wt._0&&t<=Wt._9)return t-Wt._0;if(t>=Wt.A&&t<=Wt.F)return t-(Wt.A-10);if(t>=Wt.a&&t<=Wt.f)return t-(Wt.a-10)}function cs(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);if(np)return Uint8Array.fromHex(t);const e=t.length,r=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const i=new Uint8Array(r);for(let n=0,s=0;n<r;n++,s+=2){const o=dl(t.charCodeAt(s)),a=dl(t.charCodeAt(s+1));if(o===void 0||a===void 0){const c=t[s]+t[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}i[n]=o*16+a}return i}function sp(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function Ot(t){return typeof t=="string"&&(t=sp(t)),At(t),t}function Dr(...t){let e=0;for(let i=0;i<t.length;i++){const n=t[i];At(n),e+=n.length}const r=new Uint8Array(e);for(let i=0,n=0;i<t.length;i++){const s=t[i];r.set(s,n),n+=s.length}return r}class Os{}function wn(t){const e=i=>t().update(Ot(i)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function ZE(t){const e=(i,n)=>t(n).update(Ot(i)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=i=>t(i),e}function Xr(t=32){if(oi&&typeof oi.getRandomValues=="function")return oi.getRandomValues(new Uint8Array(t));if(oi&&typeof oi.randomBytes=="function")return Uint8Array.from(oi.randomBytes(t));throw new Error("crypto.getRandomValues must be defined")}const JE=BigInt(0),ji=BigInt(1),XE=BigInt(2),QE=BigInt(7),e3=BigInt(256),t3=BigInt(113),op=[],ap=[],cp=[];for(let t=0,e=ji,r=1,i=0;t<24;t++){[r,i]=[i,(2*r+3*i)%5],op.push(2*(5*i+r)),ap.push((t+1)*(t+2)/2%64);let n=JE;for(let s=0;s<7;s++)e=(e<<ji^(e>>QE)*t3)%e3,e&XE&&(n^=ji<<(ji<<BigInt(s))-ji);cp.push(n)}const up=tp(cp,!0),r3=up[0],i3=up[1],pl=(t,e,r)=>r>32?qE(t,e,r):LE(t,e,r),gl=(t,e,r)=>r>32?zE(t,e,r):ME(t,e,r);function n3(t,e=24){const r=new Uint32Array(10);for(let i=24-e;i<24;i++){for(let o=0;o<10;o++)r[o]=t[o]^t[o+10]^t[o+20]^t[o+30]^t[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,u=r[c],l=r[c+1],h=pl(u,l,1)^r[a],f=gl(u,l,1)^r[a+1];for(let g=0;g<50;g+=10)t[o+g]^=h,t[o+g+1]^=f}let n=t[2],s=t[3];for(let o=0;o<24;o++){const a=ap[o],c=pl(n,s,a),u=gl(n,s,a),l=op[o];n=t[l],s=t[l+1],t[l]=c,t[l+1]=u}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)r[a]=t[o+a];for(let a=0;a<10;a++)t[o+a]^=~r[(a+2)%10]&r[(a+4)%10]}t[0]^=r3[i],t[1]^=i3[i]}vt(r)}let s3=class lp extends Os{constructor(e,r,i,n=!1,s=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=e,this.suffix=r,this.outputLen=i,this.enableXOF=n,this.rounds=s,ar(i),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=on(this.state)}clone(){return this._cloneInto()}keccak(){vr(this.state32),n3(this.state32,this.rounds),vr(this.state32),this.posOut=0,this.pos=0}update(e){Or(this),e=Ot(e),At(e);const{blockLen:r,state:i}=this,n=e.length;for(let s=0;s<n;){const o=Math.min(r-this.pos,n-s);for(let a=0;a<o;a++)i[this.pos++]^=e[s++];this.pos===r&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:r,pos:i,blockLen:n}=this;e[i]^=r,(r&128)!==0&&i===n-1&&this.keccak(),e[n-1]^=128,this.keccak()}writeInto(e){Or(this,!1),At(e),this.finish();const r=this.state,{blockLen:i}=this;for(let n=0,s=e.length;n<s;){this.posOut>=i&&this.keccak();const o=Math.min(i-this.posOut,s-n);e.set(r.subarray(this.posOut,this.posOut+o),n),this.posOut+=o,n+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return ar(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(yc(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,vt(this.state)}_cloneInto(e){const{blockLen:r,suffix:i,outputLen:n,rounds:s,enableXOF:o}=this;return e||(e=new lp(r,i,n,o,s)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=s,e.suffix=i,e.outputLen=n,e.enableXOF=o,e.destroyed=this.destroyed,e}};const o3=(t,e,r)=>wn(()=>new s3(e,t,r)),a3=o3(1,136,256/8);function c3(t,e,r,i){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,i);const n=BigInt(32),s=BigInt(4294967295),o=Number(r>>n&s),a=Number(r&s),c=i?4:0,u=i?0:4;t.setUint32(e+c,o,i),t.setUint32(e+u,a,i)}function u3(t,e,r){return t&e^~t&r}function l3(t,e,r){return t&e^t&r^e&r}let hp=class extends Os{constructor(e,r,i,n){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=r,this.padOffset=i,this.isLE=n,this.buffer=new Uint8Array(e),this.view=vo(this.buffer)}update(e){Or(this),e=Ot(e),At(e);const{view:r,buffer:i,blockLen:n}=this,s=e.length;for(let o=0;o<s;){const a=Math.min(n-this.pos,s-o);if(a===n){const c=vo(e);for(;n<=s-o;o+=n)this.process(c,o);continue}i.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===n&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Or(this),yc(e,this),this.finished=!0;const{buffer:r,view:i,blockLen:n,isLE:s}=this;let{pos:o}=this;r[o++]=128,vt(this.buffer.subarray(o)),this.padOffset>n-o&&(this.process(i,0),o=0);for(let h=o;h<n;h++)r[h]=0;c3(i,n-8,BigInt(this.length*8),s),this.process(i,0);const a=vo(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=c/4,l=this.get();if(u>l.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<u;h++)a.setUint32(4*h,l[h],s)}digest(){const{buffer:e,outputLen:r}=this;this.digestInto(e);const i=e.slice(0,r);return this.destroy(),i}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:r,buffer:i,length:n,finished:s,destroyed:o,pos:a}=this;return e.destroyed=o,e.finished=s,e.length=n,e.pos=a,n%r&&e.buffer.set(i),e}clone(){return this._cloneInto()}};const fr=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ue=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),Ne=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),h3=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]),dr=new Uint32Array(64);class f3 extends hp{constructor(e=32){super(64,e,8,!1),this.A=fr[0]|0,this.B=fr[1]|0,this.C=fr[2]|0,this.D=fr[3]|0,this.E=fr[4]|0,this.F=fr[5]|0,this.G=fr[6]|0,this.H=fr[7]|0}get(){const{A:e,B:r,C:i,D:n,E:s,F:o,G:a,H:c}=this;return[e,r,i,n,s,o,a,c]}set(e,r,i,n,s,o,a,c){this.A=e|0,this.B=r|0,this.C=i|0,this.D=n|0,this.E=s|0,this.F=o|0,this.G=a|0,this.H=c|0}process(e,r){for(let h=0;h<16;h++,r+=4)dr[h]=e.getUint32(r,!1);for(let h=16;h<64;h++){const f=dr[h-15],g=dr[h-2],p=Pt(f,7)^Pt(f,18)^f>>>3,y=Pt(g,17)^Pt(g,19)^g>>>10;dr[h]=y+dr[h-7]+p+dr[h-16]|0}let{A:i,B:n,C:s,D:o,E:a,F:c,G:u,H:l}=this;for(let h=0;h<64;h++){const f=Pt(a,6)^Pt(a,11)^Pt(a,25),g=l+f+u3(a,c,u)+h3[h]+dr[h]|0,p=(Pt(i,2)^Pt(i,13)^Pt(i,22))+l3(i,n,s)|0;l=u,u=c,c=a,a=o+g|0,o=s,s=n,n=i,i=g+p|0}i=i+this.A|0,n=n+this.B|0,s=s+this.C|0,o=o+this.D|0,a=a+this.E|0,c=c+this.F|0,u=u+this.G|0,l=l+this.H|0,this.set(i,n,s,o,a,c,u,l)}roundClean(){vt(dr)}destroy(){this.set(0,0,0,0,0,0,0,0),vt(this.buffer)}}const fp=tp(["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"].map(t=>BigInt(t))),d3=fp[0],p3=fp[1],pr=new Uint32Array(80),gr=new Uint32Array(80);let wc=class extends hp{constructor(e=64){super(128,e,16,!1),this.Ah=Ne[0]|0,this.Al=Ne[1]|0,this.Bh=Ne[2]|0,this.Bl=Ne[3]|0,this.Ch=Ne[4]|0,this.Cl=Ne[5]|0,this.Dh=Ne[6]|0,this.Dl=Ne[7]|0,this.Eh=Ne[8]|0,this.El=Ne[9]|0,this.Fh=Ne[10]|0,this.Fl=Ne[11]|0,this.Gh=Ne[12]|0,this.Gl=Ne[13]|0,this.Hh=Ne[14]|0,this.Hl=Ne[15]|0}get(){const{Ah:e,Al:r,Bh:i,Bl:n,Ch:s,Cl:o,Dh:a,Dl:c,Eh:u,El:l,Fh:h,Fl:f,Gh:g,Gl:p,Hh:y,Hl:m}=this;return[e,r,i,n,s,o,a,c,u,l,h,f,g,p,y,m]}set(e,r,i,n,s,o,a,c,u,l,h,f,g,p,y,m){this.Ah=e|0,this.Al=r|0,this.Bh=i|0,this.Bl=n|0,this.Ch=s|0,this.Cl=o|0,this.Dh=a|0,this.Dl=c|0,this.Eh=u|0,this.El=l|0,this.Fh=h|0,this.Fl=f|0,this.Gh=g|0,this.Gl=p|0,this.Hh=y|0,this.Hl=m|0}process(e,r){for(let v=0;v<16;v++,r+=4)pr[v]=e.getUint32(r),gr[v]=e.getUint32(r+=4);for(let v=16;v<80;v++){const b=pr[v-15]|0,E=gr[v-15]|0,I=br(b,E,1)^br(b,E,8)^hl(b,E,7),$=mr(b,E,1)^mr(b,E,8)^fl(b,E,7),B=pr[v-2]|0,C=gr[v-2]|0,k=br(B,C,19)^Ki(B,C,61)^hl(B,C,6),F=mr(B,C,19)^Wi(B,C,61)^fl(B,C,6),R=VE($,F,gr[v-7],gr[v-16]),P=HE(R,I,k,pr[v-7],pr[v-16]);pr[v]=P|0,gr[v]=R|0}let{Ah:i,Al:n,Bh:s,Bl:o,Ch:a,Cl:c,Dh:u,Dl:l,Eh:h,El:f,Fh:g,Fl:p,Gh:y,Gl:m,Hh:x,Hl:S}=this;for(let v=0;v<80;v++){const b=br(h,f,14)^br(h,f,18)^Ki(h,f,41),E=mr(h,f,14)^mr(h,f,18)^Wi(h,f,41),I=h&g^~h&y,$=f&p^~f&m,B=KE(S,E,$,p3[v],gr[v]),C=WE(B,x,b,I,d3[v],pr[v]),k=B|0,F=br(i,n,28)^Ki(i,n,34)^Ki(i,n,39),R=mr(i,n,28)^Wi(i,n,34)^Wi(i,n,39),P=i&s^i&a^s&a,T=n&o^n&c^o&c;x=y|0,S=m|0,y=g|0,m=p|0,g=h|0,p=f|0,{h,l:f}=It(u|0,l|0,C|0,k|0),u=a|0,l=c|0,a=s|0,c=o|0,s=i|0,o=n|0;const d=pc(k,R,T);i=gc(d,C,F,P),n=d|0}({h:i,l:n}=It(this.Ah|0,this.Al|0,i|0,n|0)),{h:s,l:o}=It(this.Bh|0,this.Bl|0,s|0,o|0),{h:a,l:c}=It(this.Ch|0,this.Cl|0,a|0,c|0),{h:u,l}=It(this.Dh|0,this.Dl|0,u|0,l|0),{h,l:f}=It(this.Eh|0,this.El|0,h|0,f|0),{h:g,l:p}=It(this.Fh|0,this.Fl|0,g|0,p|0),{h:y,l:m}=It(this.Gh|0,this.Gl|0,y|0,m|0),{h:x,l:S}=It(this.Hh|0,this.Hl|0,x|0,S|0),this.set(i,n,s,o,a,c,u,l,h,f,g,p,y,m,x,S)}roundClean(){vt(pr,gr)}destroy(){vt(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};class g3 extends wc{constructor(){super(48),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}}const je=Uint32Array.from([573645204,4230739756,2673172387,3360449730,596883563,1867755857,2520282905,1497426621,2519219938,2827943907,3193839141,1401305490,721525244,746961066,246885852,2177182882]);class y3 extends wc{constructor(){super(32),this.Ah=je[0]|0,this.Al=je[1]|0,this.Bh=je[2]|0,this.Bl=je[3]|0,this.Ch=je[4]|0,this.Cl=je[5]|0,this.Dh=je[6]|0,this.Dl=je[7]|0,this.Eh=je[8]|0,this.El=je[9]|0,this.Fh=je[10]|0,this.Fl=je[11]|0,this.Gh=je[12]|0,this.Gl=je[13]|0,this.Hh=je[14]|0,this.Hl=je[15]|0}}const As=wn(()=>new f3),w3=wn(()=>new wc),b3=wn(()=>new g3),m3=wn(()=>new y3),v3=Uint8Array.from([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9]),me=Uint32Array.from([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),H=new Uint32Array(32);function yr(t,e,r,i,n,s){const o=n[s],a=n[s+1];let c=H[2*t],u=H[2*t+1],l=H[2*e],h=H[2*e+1],f=H[2*r],g=H[2*r+1],p=H[2*i],y=H[2*i+1],m=pc(c,l,o);u=gc(m,u,h,a),c=m|0,{Dh:y,Dl:p}={Dh:y^u,Dl:p^c},{Dh:y,Dl:p}={Dh:kE(y,p),Dl:FE(y)},{h:g,l:f}=It(g,f,y,p),{Bh:h,Bl:l}={Bh:h^g,Bl:l^f},{Bh:h,Bl:l}={Bh:br(h,l,24),Bl:mr(h,l,24)},H[2*t]=c,H[2*t+1]=u,H[2*e]=l,H[2*e+1]=h,H[2*r]=f,H[2*r+1]=g,H[2*i]=p,H[2*i+1]=y}function wr(t,e,r,i,n,s){const o=n[s],a=n[s+1];let c=H[2*t],u=H[2*t+1],l=H[2*e],h=H[2*e+1],f=H[2*r],g=H[2*r+1],p=H[2*i],y=H[2*i+1],m=pc(c,l,o);u=gc(m,u,h,a),c=m|0,{Dh:y,Dl:p}={Dh:y^u,Dl:p^c},{Dh:y,Dl:p}={Dh:br(y,p,16),Dl:mr(y,p,16)},{h:g,l:f}=It(g,f,y,p),{Bh:h,Bl:l}={Bh:h^g,Bl:l^f},{Bh:h,Bl:l}={Bh:Ki(h,l,63),Bl:Wi(h,l,63)},H[2*t]=c,H[2*t+1]=u,H[2*e]=l,H[2*e+1]=h,H[2*r]=f,H[2*r+1]=g,H[2*i]=p,H[2*i+1]=y}function E3(t,e={},r,i,n){if(ar(r),t<0||t>r)throw new Error("outputLen bigger than keyLen");const{key:s,salt:o,personalization:a}=e;if(s!==void 0&&(s.length<1||s.length>r))throw new Error("key length must be undefined or 1.."+r);if(o!==void 0&&o.length!==i)throw new Error("salt must be undefined or "+i);if(a!==void 0&&a.length!==n)throw new Error("personalization must be undefined or "+n)}class D3 extends Os{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,this.length=0,this.pos=0,ar(e),ar(r),this.blockLen=e,this.outputLen=r,this.buffer=new Uint8Array(e),this.buffer32=on(this.buffer)}update(e){Or(this),e=Ot(e),At(e);const{blockLen:r,buffer:i,buffer32:n}=this,s=e.length,o=e.byteOffset,a=e.buffer;for(let c=0;c<s;){this.pos===r&&(vr(n),this.compress(n,0,!1),vr(n),this.pos=0);const u=Math.min(r-this.pos,s-c),l=o+c;if(u===r&&!(l%4)&&c+u<s){const h=new Uint32Array(a,l,Math.floor((s-c)/4));vr(h);for(let f=0;c+r<s;f+=n.length,c+=r)this.length+=r,this.compress(h,f,!1);vr(h);continue}i.set(e.subarray(c,c+u),this.pos),this.pos+=u,this.length+=u,c+=u}return this}digestInto(e){Or(this),yc(e,this);const{pos:r,buffer32:i}=this;this.finished=!0,vt(this.buffer.subarray(r)),vr(i),this.compress(i,0,!0),vr(i);const n=on(e);this.get().forEach((s,o)=>n[o]=Zt(s))}digest(){const{buffer:e,outputLen:r}=this;this.digestInto(e);const i=e.slice(0,r);return this.destroy(),i}_cloneInto(e){const{buffer:r,length:i,finished:n,destroyed:s,outputLen:o,pos:a}=this;return e||(e=new this.constructor({dkLen:o})),e.set(...this.get()),e.buffer.set(r),e.destroyed=s,e.finished=n,e.length=i,e.pos=a,e.outputLen=o,e}clone(){return this._cloneInto()}}class x3 extends D3{constructor(e={}){const r=e.dkLen===void 0?64:e.dkLen;super(128,r),this.v0l=me[0]|0,this.v0h=me[1]|0,this.v1l=me[2]|0,this.v1h=me[3]|0,this.v2l=me[4]|0,this.v2h=me[5]|0,this.v3l=me[6]|0,this.v3h=me[7]|0,this.v4l=me[8]|0,this.v4h=me[9]|0,this.v5l=me[10]|0,this.v5h=me[11]|0,this.v6l=me[12]|0,this.v6h=me[13]|0,this.v7l=me[14]|0,this.v7h=me[15]|0,E3(r,e,64,16,16);let{key:i,personalization:n,salt:s}=e,o=0;if(i!==void 0&&(i=Ot(i),o=i.length),this.v0l^=this.outputLen|o<<8|65536|1<<24,s!==void 0){s=Ot(s);const a=on(s);this.v4l^=Zt(a[0]),this.v4h^=Zt(a[1]),this.v5l^=Zt(a[2]),this.v5h^=Zt(a[3])}if(n!==void 0){n=Ot(n);const a=on(n);this.v6l^=Zt(a[0]),this.v6h^=Zt(a[1]),this.v7l^=Zt(a[2]),this.v7h^=Zt(a[3])}if(i!==void 0){const a=new Uint8Array(this.blockLen);a.set(i),this.update(a)}}get(){let{v0l:e,v0h:r,v1l:i,v1h:n,v2l:s,v2h:o,v3l:a,v3h:c,v4l:u,v4h:l,v5l:h,v5h:f,v6l:g,v6h:p,v7l:y,v7h:m}=this;return[e,r,i,n,s,o,a,c,u,l,h,f,g,p,y,m]}set(e,r,i,n,s,o,a,c,u,l,h,f,g,p,y,m){this.v0l=e|0,this.v0h=r|0,this.v1l=i|0,this.v1h=n|0,this.v2l=s|0,this.v2h=o|0,this.v3l=a|0,this.v3h=c|0,this.v4l=u|0,this.v4h=l|0,this.v5l=h|0,this.v5h=f|0,this.v6l=g|0,this.v6h=p|0,this.v7l=y|0,this.v7h=m|0}compress(e,r,i){this.get().forEach((c,u)=>H[u]=c),H.set(me,16);let{h:n,l:s}=ep(BigInt(this.length));H[24]=me[8]^s,H[25]=me[9]^n,i&&(H[28]=~H[28],H[29]=~H[29]);let o=0;const a=v3;for(let c=0;c<12;c++)yr(0,4,8,12,e,r+2*a[o++]),wr(0,4,8,12,e,r+2*a[o++]),yr(1,5,9,13,e,r+2*a[o++]),wr(1,5,9,13,e,r+2*a[o++]),yr(2,6,10,14,e,r+2*a[o++]),wr(2,6,10,14,e,r+2*a[o++]),yr(3,7,11,15,e,r+2*a[o++]),wr(3,7,11,15,e,r+2*a[o++]),yr(0,5,10,15,e,r+2*a[o++]),wr(0,5,10,15,e,r+2*a[o++]),yr(1,6,11,12,e,r+2*a[o++]),wr(1,6,11,12,e,r+2*a[o++]),yr(2,7,8,13,e,r+2*a[o++]),wr(2,7,8,13,e,r+2*a[o++]),yr(3,4,9,14,e,r+2*a[o++]),wr(3,4,9,14,e,r+2*a[o++]);this.v0l^=H[0]^H[16],this.v0h^=H[1]^H[17],this.v1l^=H[2]^H[18],this.v1h^=H[3]^H[19],this.v2l^=H[4]^H[20],this.v2h^=H[5]^H[21],this.v3l^=H[6]^H[22],this.v3h^=H[7]^H[23],this.v4l^=H[8]^H[24],this.v4h^=H[9]^H[25],this.v5l^=H[10]^H[26],this.v5h^=H[11]^H[27],this.v6l^=H[12]^H[28],this.v6h^=H[13]^H[29],this.v7l^=H[14]^H[30],this.v7h^=H[15]^H[31],vt(H)}destroy(){this.destroyed=!0,vt(this.buffer32),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const _3=ZE(t=>new x3(t)),I3="https://rpc.walletconnect.org/v1";function dp(t){const e=`Ethereum Signed Message:
6
- ${t.length}`,r=new TextEncoder().encode(e+t);return"0x"+Buffer.from(a3(r)).toString("hex")}async function S3(t,e,r,i,n,s){switch(r.t){case"eip191":return await O3(t,e,r.s);case"eip1271":return await A3(t,e,r.s,i,n,s);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${r.t}`)}}function O3(t,e,r){const i=eb(r);return sb({payload:dp(e),signature:i}).toLowerCase()===t.toLowerCase()}async function A3(t,e,r,i,n,s){const o=ir(i);if(!o.namespace||!o.reference)throw new Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${i}`);try{const a="0x1626ba7e",c="0000000000000000000000000000000000000000000000000000000000000040",u=r.substring(2),l=(u.length/2).toString(16).padStart(64,"0"),h=(e.startsWith("0x")?e:dp(e)).substring(2),f=a+h+c+l+u,g=await fetch(`${s||I3}/?chainId=${i}&projectId=${n}`,{headers:{"Content-Type":"application/json"},method:"POST",body:JSON.stringify({id:$3(),jsonrpc:"2.0",method:"eth_call",params:[{to:t,data:f},"latest"]})}),{result:p}=await g.json();return p?p.slice(0,a.length).toLowerCase()===a.toLowerCase():!1}catch(a){return console.error("isValidEip1271Signature: ",a),!1}}function $3(){return Date.now()+Math.floor(Math.random()*1e3)}function C3(t){const e=atob(t),r=new Uint8Array(e.length);for(let o=0;o<e.length;o++)r[o]=e.charCodeAt(o);const i=r[0];if(i===0)throw new Error("No signatures found");const n=1+i*64;if(r.length<n)throw new Error("Transaction data too short for claimed signature count");if(r.length<100)throw new Error("Transaction too short");const s=Buffer.from(t,"base64").slice(1,65);return dn.encode(s)}function P3(t){const e=new Uint8Array(Buffer.from(t,"base64")),r=Array.from("TransactionData::").map(s=>s.charCodeAt(0)),i=new Uint8Array(r.length+e.length);i.set(r),i.set(e,r.length);const n=_3(i,{dkLen:32});return dn.encode(n)}function yl(t){const e=new Uint8Array(As(B3(t)));return dn.encode(e)}function B3(t){if(t instanceof Uint8Array)return t;if(Array.isArray(t))return new Uint8Array(t);if(typeof t=="object"&&t!=null&&t.data)return new Uint8Array(Object.values(t.data));if(typeof t=="object"&&t)return new Uint8Array(Object.values(t));throw new Error("getNearUint8ArrayFromBytes: Unexpected result type from bytes array")}function wl(t){const e=Buffer.from(t,"base64"),r=Vb(e).txn;if(!r)throw new Error("Invalid signed transaction: missing 'txn' field");const i=Ub(r),n=Buffer.from("TX"),s=Buffer.concat([n,Buffer.from(i)]),o=m3(s);return Xg.encode(o).replace(/=+$/,"")}function Eo(t){const e=[];let r=BigInt(t);for(;r>=BigInt(128);)e.push(Number(r&BigInt(127)|BigInt(128))),r>>=BigInt(7);return e.push(Number(r)),Buffer.from(e)}function T3(t){const e=Buffer.from(t.signed.bodyBytes,"base64"),r=Buffer.from(t.signed.authInfoBytes,"base64"),i=Buffer.from(t.signature.signature,"base64"),n=[];n.push(Buffer.from([10])),n.push(Eo(e.length)),n.push(e),n.push(Buffer.from([18])),n.push(Eo(r.length)),n.push(r),n.push(Buffer.from([26])),n.push(Eo(i.length)),n.push(i);const s=Buffer.concat(n),o=As(s);return Buffer.from(o).toString("hex").toUpperCase()}function R3(t){var e,r;const i=[];try{if(typeof t=="string")return i.push(t),i;if(typeof t!="object")return i;t!=null&&t.id&&i.push(t.id);const n=(r=(e=t?.capabilities)==null?void 0:e.caip345)==null?void 0:r.transactionHashes;n&&i.push(...n)}catch(n){console.warn("getWalletSendCallsHashes failed: ",n)}return i}var U3=Object.defineProperty,N3=Object.defineProperties,j3=Object.getOwnPropertyDescriptors,bl=Object.getOwnPropertySymbols,k3=Object.prototype.hasOwnProperty,F3=Object.prototype.propertyIsEnumerable,ml=(t,e,r)=>e in t?U3(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,L3=(t,e)=>{for(var r in e||(e={}))k3.call(e,r)&&ml(t,r,e[r]);if(bl)for(var r of bl(e))F3.call(e,r)&&ml(t,r,e[r]);return t},M3=(t,e)=>N3(t,j3(e));const q3="did:pkh:",bc=t=>t?.split(":"),z3=t=>{const e=t&&bc(t);if(e)return t.includes(q3)?e[3]:e[1]},da=t=>{const e=t&&bc(t);if(e)return e[2]+":"+e[3]},us=t=>{const e=t&&bc(t);if(e)return e.pop()};async function vl(t){const{cacao:e,projectId:r}=t,{s:i,p:n}=e,s=pp(n,n.iss),o=us(n.iss);return await S3(o,s,i,da(n.iss),r)}const pp=(t,e)=>{const r=`${t.domain} wants you to sign in with your Ethereum account:`,i=us(e);if(!t.aud&&!t.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let n=t.statement||void 0;const s=`URI: ${t.aud||t.uri}`,o=`Version: ${t.version}`,a=`Chain ID: ${z3(e)}`,c=`Nonce: ${t.nonce}`,u=`Issued At: ${t.iat}`,l=t.exp?`Expiration Time: ${t.exp}`:void 0,h=t.nbf?`Not Before: ${t.nbf}`:void 0,f=t.requestId?`Request ID: ${t.requestId}`:void 0,g=t.resources?`Resources:${t.resources.map(y=>`
7
- - ${y}`).join("")}`:void 0,p=Wn(t.resources);if(p){const y=an(p);n=X3(n,y)}return[r,i,"",n,"",s,o,a,c,u,l,h,f,g].filter(y=>y!=null).join(`
8
- `)};function V3(t){return Buffer.from(JSON.stringify(t)).toString("base64")}function H3(t){return JSON.parse(Buffer.from(t,"base64").toString("utf-8"))}function Zr(t){if(!t)throw new Error("No recap provided, value is undefined");if(!t.att)throw new Error("No `att` property found");const e=Object.keys(t.att);if(!(e!=null&&e.length))throw new Error("No resources found in `att` property");e.forEach(r=>{const i=t.att[r];if(Array.isArray(i))throw new Error(`Resource must be an object: ${r}`);if(typeof i!="object")throw new Error(`Resource must be an object: ${r}`);if(!Object.keys(i).length)throw new Error(`Resource object is empty: ${r}`);Object.keys(i).forEach(n=>{const s=i[n];if(!Array.isArray(s))throw new Error(`Ability limits ${n} must be an array of objects, found: ${s}`);if(!s.length)throw new Error(`Value of ${n} is empty array, must be an array with objects`);s.forEach(o=>{if(typeof o!="object")throw new Error(`Ability limits (${n}) must be an array of objects, found: ${o}`)})})})}function K3(t,e,r,i={}){return r?.sort((n,s)=>n.localeCompare(s)),{att:{[t]:W3(e,r,i)}}}function W3(t,e,r={}){e=e?.sort((n,s)=>n.localeCompare(s));const i=e.map(n=>({[`${t}/${n}`]:[r]}));return Object.assign({},...i)}function gp(t){return Zr(t),`urn:recap:${V3(t).replace(/=/g,"")}`}function an(t){const e=H3(t.replace("urn:recap:",""));return Zr(e),e}function G3(t,e,r){const i=K3(t,e,r);return gp(i)}function Y3(t){return t&&t.includes("urn:recap:")}function Z3(t,e){const r=an(t),i=an(e),n=J3(r,i);return gp(n)}function J3(t,e){Zr(t),Zr(e);const r=Object.keys(t.att).concat(Object.keys(e.att)).sort((n,s)=>n.localeCompare(s)),i={att:{}};return r.forEach(n=>{var s,o;Object.keys(((s=t.att)==null?void 0:s[n])||{}).concat(Object.keys(((o=e.att)==null?void 0:o[n])||{})).sort((a,c)=>a.localeCompare(c)).forEach(a=>{var c,u;i.att[n]=M3(L3({},i.att[n]),{[a]:((c=t.att[n])==null?void 0:c[a])||((u=e.att[n])==null?void 0:u[a])})})}),i}function X3(t="",e){Zr(e);const r="I further authorize the stated URI to perform the following actions on my behalf: ";if(t.includes(r))return t;const i=[];let n=0;Object.keys(e.att).forEach(a=>{const c=Object.keys(e.att[a]).map(h=>({ability:h.split("/")[0],action:h.split("/")[1]}));c.sort((h,f)=>h.action.localeCompare(f.action));const u={};c.forEach(h=>{u[h.ability]||(u[h.ability]=[]),u[h.ability].push(h.action)});const l=Object.keys(u).map(h=>(n++,`(${n}) '${h}': '${u[h].join("', '")}' for '${a}'.`));i.push(l.join(", ").replace(".,","."))});const s=i.join(" "),o=`${r}${s}`;return`${t?t+" ":""}${o}`}function El(t){var e;const r=an(t);Zr(r);const i=(e=r.att)==null?void 0:e.eip155;return i?Object.keys(i).map(n=>n.split("/")[1]):[]}function Dl(t){const e=an(t);Zr(e);const r=[];return Object.values(e.att).forEach(i=>{Object.values(i).forEach(n=>{var s;(s=n?.[0])!=null&&s.chains&&r.push(n[0].chains)})}),[...new Set(r.flat())]}function Wn(t){if(!t)return;const e=t?.[t.length-1];return Y3(e)?e:void 0}function yp(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function pa(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}function Do(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function Ye(t,...e){if(!yp(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function xl(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Q3(t,e){Ye(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function Ir(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function _i(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function eD(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}const tD=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function rD(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function ga(t){if(typeof t=="string")t=rD(t);else if(yp(t))t=ya(t);else throw new Error("Uint8Array expected, got "+typeof t);return t}function iD(t,e){if(e==null||typeof e!="object")throw new Error("options must be defined");return Object.assign(t,e)}function nD(t,e){if(t.length!==e.length)return!1;let r=0;for(let i=0;i<t.length;i++)r|=t[i]^e[i];return r===0}const sD=(t,e)=>{function r(i,...n){if(Ye(i),!tD)throw new Error("Non little-endian hardware is not yet supported");if(t.nonceLength!==void 0){const u=n[0];if(!u)throw new Error("nonce / iv required");t.varSizeNonce?Ye(u):Ye(u,t.nonceLength)}const s=t.tagLength;s&&n[1]!==void 0&&Ye(n[1]);const o=e(i,...n),a=(u,l)=>{if(l!==void 0){if(u!==2)throw new Error("cipher output not supported");Ye(l)}};let c=!1;return{encrypt(u,l){if(c)throw new Error("cannot encrypt() twice with same key + nonce");return c=!0,Ye(u),a(o.encrypt.length,l),o.encrypt(u,l)},decrypt(u,l){if(Ye(u),s&&u.length<s)throw new Error("invalid ciphertext length: smaller than tagLength="+s);return a(o.decrypt.length,l),o.decrypt(u,l)}}}return Object.assign(r,t),r};function _l(t,e,r=!0){if(e===void 0)return new Uint8Array(t);if(e.length!==t)throw new Error("invalid output length, expected "+t+", got: "+e.length);if(r&&!aD(e))throw new Error("invalid output, must be aligned");return e}function Il(t,e,r,i){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,i);const n=BigInt(32),s=BigInt(4294967295),o=Number(r>>n&s),a=Number(r&s);t.setUint32(e+4,o,i),t.setUint32(e+0,a,i)}function oD(t,e,r){pa(r);const i=new Uint8Array(16),n=eD(i);return Il(n,0,BigInt(e),r),Il(n,8,BigInt(t),r),i}function aD(t){return t.byteOffset%4===0}function ya(t){return Uint8Array.from(t)}const wp=t=>Uint8Array.from(t.split("").map(e=>e.charCodeAt(0))),cD=wp("expand 16-byte k"),uD=wp("expand 32-byte k"),lD=Ir(cD),hD=Ir(uD);function te(t,e){return t<<e|t>>>32-e}function wa(t){return t.byteOffset%4===0}const Rn=64,fD=16,bp=2**32-1,Sl=new Uint32Array;function dD(t,e,r,i,n,s,o,a){const c=n.length,u=new Uint8Array(Rn),l=Ir(u),h=wa(n)&&wa(s),f=h?Ir(n):Sl,g=h?Ir(s):Sl;for(let p=0;p<c;o++){if(t(e,r,i,l,o,a),o>=bp)throw new Error("arx: counter overflow");const y=Math.min(Rn,c-p);if(h&&y===Rn){const m=p/4;if(p%4!==0)throw new Error("arx: invalid block position");for(let x=0,S;x<fD;x++)S=m+x,g[S]=f[S]^l[x];p+=Rn;continue}for(let m=0,x;m<y;m++)x=p+m,s[x]=n[x]^u[m];p+=y}}function pD(t,e){const{allowShortKeys:r,extendNonceFn:i,counterLength:n,counterRight:s,rounds:o}=iD({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},e);if(typeof t!="function")throw new Error("core must be a function");return Do(n),Do(o),pa(s),pa(r),(a,c,u,l,h=0)=>{Ye(a),Ye(c),Ye(u);const f=u.length;if(l===void 0&&(l=new Uint8Array(f)),Ye(l),Do(h),h<0||h>=bp)throw new Error("arx: counter overflow");if(l.length<f)throw new Error(`arx: output (${l.length}) is shorter than data (${f})`);const g=[];let p=a.length,y,m;if(p===32)g.push(y=ya(a)),m=hD;else if(p===16&&r)y=new Uint8Array(32),y.set(a),y.set(a,16),m=lD,g.push(y);else throw new Error(`arx: invalid 32-byte key, got length=${p}`);wa(c)||g.push(c=ya(c));const x=Ir(y);if(i){if(c.length!==24)throw new Error("arx: extended nonce must be 24 bytes");i(m,x,Ir(c.subarray(0,16)),x),c=c.subarray(16)}const S=16-n;if(S!==c.length)throw new Error(`arx: nonce must be ${S} or 16 bytes`);if(S!==12){const b=new Uint8Array(12);b.set(c,s?0:12-c.length),c=b,g.push(c)}const v=Ir(c);return dD(t,m,x,v,u,l,h,o),_i(...g),l}}const Ae=(t,e)=>t[e++]&255|(t[e++]&255)<<8;class gD{constructor(e){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,e=ga(e),Ye(e,32);const r=Ae(e,0),i=Ae(e,2),n=Ae(e,4),s=Ae(e,6),o=Ae(e,8),a=Ae(e,10),c=Ae(e,12),u=Ae(e,14);this.r[0]=r&8191,this.r[1]=(r>>>13|i<<3)&8191,this.r[2]=(i>>>10|n<<6)&7939,this.r[3]=(n>>>7|s<<9)&8191,this.r[4]=(s>>>4|o<<12)&255,this.r[5]=o>>>1&8190,this.r[6]=(o>>>14|a<<2)&8191,this.r[7]=(a>>>11|c<<5)&8065,this.r[8]=(c>>>8|u<<8)&8191,this.r[9]=u>>>5&127;for(let l=0;l<8;l++)this.pad[l]=Ae(e,16+2*l)}process(e,r,i=!1){const n=i?0:2048,{h:s,r:o}=this,a=o[0],c=o[1],u=o[2],l=o[3],h=o[4],f=o[5],g=o[6],p=o[7],y=o[8],m=o[9],x=Ae(e,r+0),S=Ae(e,r+2),v=Ae(e,r+4),b=Ae(e,r+6),E=Ae(e,r+8),I=Ae(e,r+10),$=Ae(e,r+12),B=Ae(e,r+14);let C=s[0]+(x&8191),k=s[1]+((x>>>13|S<<3)&8191),F=s[2]+((S>>>10|v<<6)&8191),R=s[3]+((v>>>7|b<<9)&8191),P=s[4]+((b>>>4|E<<12)&8191),T=s[5]+(E>>>1&8191),d=s[6]+((E>>>14|I<<2)&8191),w=s[7]+((I>>>11|$<<5)&8191),D=s[8]+(($>>>8|B<<8)&8191),O=s[9]+(B>>>5|n),_=0,A=_+C*a+k*(5*m)+F*(5*y)+R*(5*p)+P*(5*g);_=A>>>13,A&=8191,A+=T*(5*f)+d*(5*h)+w*(5*l)+D*(5*u)+O*(5*c),_+=A>>>13,A&=8191;let N=_+C*c+k*a+F*(5*m)+R*(5*y)+P*(5*p);_=N>>>13,N&=8191,N+=T*(5*g)+d*(5*f)+w*(5*h)+D*(5*l)+O*(5*u),_+=N>>>13,N&=8191;let j=_+C*u+k*c+F*a+R*(5*m)+P*(5*y);_=j>>>13,j&=8191,j+=T*(5*p)+d*(5*g)+w*(5*f)+D*(5*h)+O*(5*l),_+=j>>>13,j&=8191;let q=_+C*l+k*u+F*c+R*a+P*(5*m);_=q>>>13,q&=8191,q+=T*(5*y)+d*(5*p)+w*(5*g)+D*(5*f)+O*(5*h),_+=q>>>13,q&=8191;let U=_+C*h+k*l+F*u+R*c+P*a;_=U>>>13,U&=8191,U+=T*(5*m)+d*(5*y)+w*(5*p)+D*(5*g)+O*(5*f),_+=U>>>13,U&=8191;let L=_+C*f+k*h+F*l+R*u+P*c;_=L>>>13,L&=8191,L+=T*a+d*(5*m)+w*(5*y)+D*(5*p)+O*(5*g),_+=L>>>13,L&=8191;let K=_+C*g+k*f+F*h+R*l+P*u;_=K>>>13,K&=8191,K+=T*c+d*a+w*(5*m)+D*(5*y)+O*(5*p),_+=K>>>13,K&=8191;let G=_+C*p+k*g+F*f+R*h+P*l;_=G>>>13,G&=8191,G+=T*u+d*c+w*a+D*(5*m)+O*(5*y),_+=G>>>13,G&=8191;let Z=_+C*y+k*p+F*g+R*f+P*h;_=Z>>>13,Z&=8191,Z+=T*l+d*u+w*c+D*a+O*(5*m),_+=Z>>>13,Z&=8191;let W=_+C*m+k*y+F*p+R*g+P*f;_=W>>>13,W&=8191,W+=T*h+d*l+w*u+D*c+O*a,_+=W>>>13,W&=8191,_=(_<<2)+_|0,_=_+A|0,A=_&8191,_=_>>>13,N+=_,s[0]=A,s[1]=N,s[2]=j,s[3]=q,s[4]=U,s[5]=L,s[6]=K,s[7]=G,s[8]=Z,s[9]=W}finalize(){const{h:e,pad:r}=this,i=new Uint16Array(10);let n=e[1]>>>13;e[1]&=8191;for(let a=2;a<10;a++)e[a]+=n,n=e[a]>>>13,e[a]&=8191;e[0]+=n*5,n=e[0]>>>13,e[0]&=8191,e[1]+=n,n=e[1]>>>13,e[1]&=8191,e[2]+=n,i[0]=e[0]+5,n=i[0]>>>13,i[0]&=8191;for(let a=1;a<10;a++)i[a]=e[a]+n,n=i[a]>>>13,i[a]&=8191;i[9]-=8192;let s=(n^1)-1;for(let a=0;a<10;a++)i[a]&=s;s=~s;for(let a=0;a<10;a++)e[a]=e[a]&s|i[a];e[0]=(e[0]|e[1]<<13)&65535,e[1]=(e[1]>>>3|e[2]<<10)&65535,e[2]=(e[2]>>>6|e[3]<<7)&65535,e[3]=(e[3]>>>9|e[4]<<4)&65535,e[4]=(e[4]>>>12|e[5]<<1|e[6]<<14)&65535,e[5]=(e[6]>>>2|e[7]<<11)&65535,e[6]=(e[7]>>>5|e[8]<<8)&65535,e[7]=(e[8]>>>8|e[9]<<5)&65535;let o=e[0]+r[0];e[0]=o&65535;for(let a=1;a<8;a++)o=(e[a]+r[a]|0)+(o>>>16)|0,e[a]=o&65535;_i(i)}update(e){xl(this),e=ga(e),Ye(e);const{buffer:r,blockLen:i}=this,n=e.length;for(let s=0;s<n;){const o=Math.min(i-this.pos,n-s);if(o===i){for(;i<=n-s;s+=i)this.process(e,s);continue}r.set(e.subarray(s,s+o),this.pos),this.pos+=o,s+=o,this.pos===i&&(this.process(r,0,!1),this.pos=0)}return this}destroy(){_i(this.h,this.r,this.buffer,this.pad)}digestInto(e){xl(this),Q3(e,this),this.finished=!0;const{buffer:r,h:i}=this;let{pos:n}=this;if(n){for(r[n++]=1;n<16;n++)r[n]=0;this.process(r,0,!0)}this.finalize();let s=0;for(let o=0;o<8;o++)e[s++]=i[o]>>>0,e[s++]=i[o]>>>8;return e}digest(){const{buffer:e,outputLen:r}=this;this.digestInto(e);const i=e.slice(0,r);return this.destroy(),i}}function yD(t){const e=(i,n)=>t(n).update(ga(i)).digest(),r=t(new Uint8Array(32));return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=i=>t(i),e}const wD=yD(t=>new gD(t));function bD(t,e,r,i,n,s=20){let o=t[0],a=t[1],c=t[2],u=t[3],l=e[0],h=e[1],f=e[2],g=e[3],p=e[4],y=e[5],m=e[6],x=e[7],S=n,v=r[0],b=r[1],E=r[2],I=o,$=a,B=c,C=u,k=l,F=h,R=f,P=g,T=p,d=y,w=m,D=x,O=S,_=v,A=b,N=E;for(let q=0;q<s;q+=2)I=I+k|0,O=te(O^I,16),T=T+O|0,k=te(k^T,12),I=I+k|0,O=te(O^I,8),T=T+O|0,k=te(k^T,7),$=$+F|0,_=te(_^$,16),d=d+_|0,F=te(F^d,12),$=$+F|0,_=te(_^$,8),d=d+_|0,F=te(F^d,7),B=B+R|0,A=te(A^B,16),w=w+A|0,R=te(R^w,12),B=B+R|0,A=te(A^B,8),w=w+A|0,R=te(R^w,7),C=C+P|0,N=te(N^C,16),D=D+N|0,P=te(P^D,12),C=C+P|0,N=te(N^C,8),D=D+N|0,P=te(P^D,7),I=I+F|0,N=te(N^I,16),w=w+N|0,F=te(F^w,12),I=I+F|0,N=te(N^I,8),w=w+N|0,F=te(F^w,7),$=$+R|0,O=te(O^$,16),D=D+O|0,R=te(R^D,12),$=$+R|0,O=te(O^$,8),D=D+O|0,R=te(R^D,7),B=B+P|0,_=te(_^B,16),T=T+_|0,P=te(P^T,12),B=B+P|0,_=te(_^B,8),T=T+_|0,P=te(P^T,7),C=C+k|0,A=te(A^C,16),d=d+A|0,k=te(k^d,12),C=C+k|0,A=te(A^C,8),d=d+A|0,k=te(k^d,7);let j=0;i[j++]=o+I|0,i[j++]=a+$|0,i[j++]=c+B|0,i[j++]=u+C|0,i[j++]=l+k|0,i[j++]=h+F|0,i[j++]=f+R|0,i[j++]=g+P|0,i[j++]=p+T|0,i[j++]=y+d|0,i[j++]=m+w|0,i[j++]=x+D|0,i[j++]=S+O|0,i[j++]=v+_|0,i[j++]=b+A|0,i[j++]=E+N|0}const mD=pD(bD,{counterRight:!1,counterLength:4,allowShortKeys:!1}),vD=new Uint8Array(16),Ol=(t,e)=>{t.update(e);const r=e.length%16;r&&t.update(vD.subarray(r))},ED=new Uint8Array(32);function Al(t,e,r,i,n){const s=t(e,r,ED),o=wD.create(s);n&&Ol(o,n),Ol(o,i);const a=oD(i.length,n?n.length:0,!0);o.update(a);const c=o.digest();return _i(s,a),c}const DD=t=>(e,r,i)=>({encrypt(n,s){const o=n.length;s=_l(o+16,s,!1),s.set(n);const a=s.subarray(0,-16);t(e,r,a,a,1);const c=Al(t,e,r,a,i);return s.set(c,o),_i(c),s},decrypt(n,s){s=_l(n.length-16,s,!1);const o=n.subarray(0,-16),a=n.subarray(-16),c=Al(t,e,r,o,i);if(!nD(a,c))throw new Error("invalid tag");return s.set(n.subarray(0,-16)),t(e,r,s,s,1),_i(c),s}}),mp=sD({blockSize:64,nonceLength:12,tagLength:16},DD(mD));let vp=class extends Os{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,Ss(e);const i=Ot(r);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const n=this.blockLen,s=new Uint8Array(n);s.set(i.length>n?e.create().update(i).digest():i);for(let o=0;o<s.length;o++)s[o]^=54;this.iHash.update(s),this.oHash=e.create();for(let o=0;o<s.length;o++)s[o]^=106;this.oHash.update(s),vt(s)}update(e){return Or(this),this.iHash.update(e),this}digestInto(e){Or(this),At(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:r,iHash:i,finished:n,destroyed:s,blockLen:o,outputLen:a}=this;return e=e,e.finished=n,e.destroyed=s,e.blockLen=o,e.outputLen=a,e.oHash=r._cloneInto(e.oHash),e.iHash=i._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};const $s=(t,e,r)=>new vp(t,e).update(r).digest();$s.create=(t,e)=>new vp(t,e);function xD(t,e,r){return Ss(t),r===void 0&&(r=new Uint8Array(t.outputLen)),$s(t,Ot(r),Ot(e))}const xo=Uint8Array.from([0]),$l=Uint8Array.of();function _D(t,e,r,i=32){Ss(t),ar(i);const n=t.outputLen;if(i>255*n)throw new Error("Length should be <= 255*HashLen");const s=Math.ceil(i/n);r===void 0&&(r=$l);const o=new Uint8Array(s*n),a=$s.create(t,e),c=a._cloneInto(),u=new Uint8Array(a.outputLen);for(let l=0;l<s;l++)xo[0]=l+1,c.update(l===0?$l:u).update(r).update(xo).digestInto(u),o.set(u,n*l),a._cloneInto(c);return a.destroy(),c.destroy(),vt(u,xo),o.slice(0,i)}const ID=(t,e,r,i,n)=>_D(t,xD(t,e,r),i,n),Cs=As,mc=BigInt(0),ba=BigInt(1);function ls(t,e=""){if(typeof t!="boolean"){const r=e&&`"${e}"`;throw new Error(r+"expected boolean, got type="+typeof t)}return t}function Vr(t,e,r=""){const i=Is(t),n=t?.length,s=e!==void 0;if(!i||s&&n!==e){const o=r&&`"${r}" `,a=s?` of length ${e}`:"",c=i?`length=${n}`:`type=${typeof t}`;throw new Error(o+"expected Uint8Array"+a+", got "+c)}return t}function Un(t){const e=t.toString(16);return e.length&1?"0"+e:e}function Ep(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?mc:BigInt("0x"+t)}function Ps(t){return Ep(bi(t))}function hs(t){return At(t),Ep(bi(Uint8Array.from(t).reverse()))}function vc(t,e){return cs(t.toString(16).padStart(e*2,"0"))}function Ec(t,e){return vc(t,e).reverse()}function Le(t,e,r){let i;if(typeof e=="string")try{i=cs(e)}catch(s){throw new Error(t+" must be hex string or Uint8Array, cause: "+s)}else if(Is(e))i=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");const n=i.length;if(typeof r=="number"&&n!==r)throw new Error(t+" of length "+r+" expected, got "+n);return i}const _o=t=>typeof t=="bigint"&&mc<=t;function SD(t,e,r){return _o(t)&&_o(e)&&_o(r)&&e<=t&&t<r}function ma(t,e,r,i){if(!SD(e,r,i))throw new Error("expected valid "+t+": "+r+" <= n < "+i+", got "+e)}function Dp(t){let e;for(e=0;t>mc;t>>=ba,e+=1);return e}const bn=t=>(ba<<BigInt(t))-ba;function OD(t,e,r){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof r!="function")throw new Error("hmacFn must be a function");const i=f=>new Uint8Array(f),n=f=>Uint8Array.of(f);let s=i(t),o=i(t),a=0;const c=()=>{s.fill(1),o.fill(0),a=0},u=(...f)=>r(o,s,...f),l=(f=i(0))=>{o=u(n(0),f),s=u(),f.length!==0&&(o=u(n(1),f),s=u())},h=()=>{if(a++>=1e3)throw new Error("drbg: tried 1000 values");let f=0;const g=[];for(;f<e;){s=u();const p=s.slice();g.push(p),f+=s.length}return Dr(...g)};return(f,g)=>{c(),l(f);let p;for(;!(p=g(h()));)l();return c(),p}}function Bs(t,e,r={}){if(!t||typeof t!="object")throw new Error("expected valid options object");function i(n,s,o){const a=t[n];if(o&&a===void 0)return;const c=typeof a;if(c!==s||a===null)throw new Error(`param "${n}" is invalid: expected ${s}, got ${c}`)}Object.entries(e).forEach(([n,s])=>i(n,s,!1)),Object.entries(r).forEach(([n,s])=>i(n,s,!0))}function Cl(t){const e=new WeakMap;return(r,...i)=>{const n=e.get(r);if(n!==void 0)return n;const s=t(r,...i);return e.set(r,s),s}}const Xe=BigInt(0),qe=BigInt(1),Hr=BigInt(2),xp=BigInt(3),_p=BigInt(4),Ip=BigInt(5),AD=BigInt(7),Sp=BigInt(8),$D=BigInt(9),Op=BigInt(16);function st(t,e){const r=t%e;return r>=Xe?r:e+r}function _t(t,e,r){let i=t;for(;e-- >Xe;)i*=i,i%=r;return i}function Pl(t,e){if(t===Xe)throw new Error("invert: expected non-zero number");if(e<=Xe)throw new Error("invert: expected positive modulus, got "+e);let r=st(t,e),i=e,n=Xe,s=qe;for(;r!==Xe;){const o=i/r,a=i%r,c=n-s*o;i=r,r=a,n=s,s=c}if(i!==qe)throw new Error("invert: does not exist");return st(n,e)}function Dc(t,e,r){if(!t.eql(t.sqr(e),r))throw new Error("Cannot find square root")}function Ap(t,e){const r=(t.ORDER+qe)/_p,i=t.pow(e,r);return Dc(t,i,e),i}function CD(t,e){const r=(t.ORDER-Ip)/Sp,i=t.mul(e,Hr),n=t.pow(i,r),s=t.mul(e,n),o=t.mul(t.mul(s,Hr),n),a=t.mul(s,t.sub(o,t.ONE));return Dc(t,a,e),a}function PD(t){const e=$r(t),r=$p(t),i=r(e,e.neg(e.ONE)),n=r(e,i),s=r(e,e.neg(i)),o=(t+AD)/Op;return(a,c)=>{let u=a.pow(c,o),l=a.mul(u,i);const h=a.mul(u,n),f=a.mul(u,s),g=a.eql(a.sqr(l),c),p=a.eql(a.sqr(h),c);u=a.cmov(u,l,g),l=a.cmov(f,h,p);const y=a.eql(a.sqr(l),c),m=a.cmov(u,l,y);return Dc(a,m,c),m}}function $p(t){if(t<xp)throw new Error("sqrt is not defined for small field");let e=t-qe,r=0;for(;e%Hr===Xe;)e/=Hr,r++;let i=Hr;const n=$r(t);for(;Bl(n,i)===1;)if(i++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return Ap;let s=n.pow(i,e);const o=(e+qe)/Hr;return function(a,c){if(a.is0(c))return c;if(Bl(a,c)!==1)throw new Error("Cannot find square root");let u=r,l=a.mul(a.ONE,s),h=a.pow(c,e),f=a.pow(c,o);for(;!a.eql(h,a.ONE);){if(a.is0(h))return a.ZERO;let g=1,p=a.sqr(h);for(;!a.eql(p,a.ONE);)if(g++,p=a.sqr(p),g===u)throw new Error("Cannot find square root");const y=qe<<BigInt(u-g-1),m=a.pow(l,y);u=g,l=a.sqr(m),h=a.mul(h,l),f=a.mul(f,m)}return f}}function BD(t){return t%_p===xp?Ap:t%Sp===Ip?CD:t%Op===$D?PD(t):$p(t)}const TD=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function RD(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},r=TD.reduce((i,n)=>(i[n]="function",i),e);return Bs(t,r),t}function UD(t,e,r){if(r<Xe)throw new Error("invalid exponent, negatives unsupported");if(r===Xe)return t.ONE;if(r===qe)return e;let i=t.ONE,n=e;for(;r>Xe;)r&qe&&(i=t.mul(i,n)),n=t.sqr(n),r>>=qe;return i}function Cp(t,e,r=!1){const i=new Array(e.length).fill(r?t.ZERO:void 0),n=e.reduce((o,a,c)=>t.is0(a)?o:(i[c]=o,t.mul(o,a)),t.ONE),s=t.inv(n);return e.reduceRight((o,a,c)=>t.is0(a)?o:(i[c]=t.mul(o,i[c]),t.mul(o,a)),s),i}function Bl(t,e){const r=(t.ORDER-qe)/Hr,i=t.pow(e,r),n=t.eql(i,t.ONE),s=t.eql(i,t.ZERO),o=t.eql(i,t.neg(t.ONE));if(!n&&!s&&!o)throw new Error("invalid Legendre symbol result");return n?1:s?0:-1}function Pp(t,e){e!==void 0&&ar(e);const r=e!==void 0?e:t.toString(2).length,i=Math.ceil(r/8);return{nBitLength:r,nByteLength:i}}function $r(t,e,r=!1,i={}){if(t<=Xe)throw new Error("invalid field: expected ORDER > 0, got "+t);let n,s,o=!1,a;if(typeof e=="object"&&e!=null){if(i.sqrt||r)throw new Error("cannot specify opts in two arguments");const f=e;f.BITS&&(n=f.BITS),f.sqrt&&(s=f.sqrt),typeof f.isLE=="boolean"&&(r=f.isLE),typeof f.modFromBytes=="boolean"&&(o=f.modFromBytes),a=f.allowedLengths}else typeof e=="number"&&(n=e),i.sqrt&&(s=i.sqrt);const{nBitLength:c,nByteLength:u}=Pp(t,n);if(u>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let l;const h=Object.freeze({ORDER:t,isLE:r,BITS:c,BYTES:u,MASK:bn(c),ZERO:Xe,ONE:qe,allowedLengths:a,create:f=>st(f,t),isValid:f=>{if(typeof f!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof f);return Xe<=f&&f<t},is0:f=>f===Xe,isValidNot0:f=>!h.is0(f)&&h.isValid(f),isOdd:f=>(f&qe)===qe,neg:f=>st(-f,t),eql:(f,g)=>f===g,sqr:f=>st(f*f,t),add:(f,g)=>st(f+g,t),sub:(f,g)=>st(f-g,t),mul:(f,g)=>st(f*g,t),pow:(f,g)=>UD(h,f,g),div:(f,g)=>st(f*Pl(g,t),t),sqrN:f=>f*f,addN:(f,g)=>f+g,subN:(f,g)=>f-g,mulN:(f,g)=>f*g,inv:f=>Pl(f,t),sqrt:s||(f=>(l||(l=BD(t)),l(h,f))),toBytes:f=>r?Ec(f,u):vc(f,u),fromBytes:(f,g=!0)=>{if(a){if(!a.includes(f.length)||f.length>u)throw new Error("Field.fromBytes: expected "+a+" bytes, got "+f.length);const y=new Uint8Array(u);y.set(f,r?0:y.length-f.length),f=y}if(f.length!==u)throw new Error("Field.fromBytes: expected "+u+" bytes, got "+f.length);let p=r?hs(f):Ps(f);if(o&&(p=st(p,t)),!g&&!h.isValid(p))throw new Error("invalid field element: outside of range 0..ORDER");return p},invertBatch:f=>Cp(h,f),cmov:(f,g,p)=>p?g:f});return Object.freeze(h)}function Bp(t){if(typeof t!="bigint")throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function Tp(t){const e=Bp(t);return e+Math.ceil(e/2)}function ND(t,e,r=!1){const i=t.length,n=Bp(e),s=Tp(e);if(i<16||i<s||i>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+i);const o=r?hs(t):Ps(t),a=st(o,e-qe)+qe;return r?Ec(a,n):vc(a,n)}const Ii=BigInt(0),Kr=BigInt(1);function fs(t,e){const r=e.negate();return t?r:e}function Io(t,e){const r=Cp(t.Fp,e.map(i=>i.Z));return e.map((i,n)=>t.fromAffine(i.toAffine(r[n])))}function Rp(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function So(t,e){Rp(t,e);const r=Math.ceil(e/t)+1,i=2**(t-1),n=2**t,s=bn(t),o=BigInt(t);return{windows:r,windowSize:i,mask:s,maxNumber:n,shiftBy:o}}function Tl(t,e,r){const{windowSize:i,mask:n,maxNumber:s,shiftBy:o}=r;let a=Number(t&n),c=t>>o;a>i&&(a-=s,c+=Kr);const u=e*i,l=u+Math.abs(a)-1,h=a===0,f=a<0,g=e%2!==0;return{nextN:c,offset:l,isZero:h,isNeg:f,isNegF:g,offsetF:u}}function jD(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((r,i)=>{if(!(r instanceof e))throw new Error("invalid point at index "+i)})}function kD(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((r,i)=>{if(!e.isValid(r))throw new Error("invalid scalar at index "+i)})}const Oo=new WeakMap,Up=new WeakMap;function Ao(t){return Up.get(t)||1}function Rl(t){if(t!==Ii)throw new Error("invalid wNAF")}class FD{constructor(e,r){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=r}_unsafeLadder(e,r,i=this.ZERO){let n=e;for(;r>Ii;)r&Kr&&(i=i.add(n)),n=n.double(),r>>=Kr;return i}precomputeWindow(e,r){const{windows:i,windowSize:n}=So(r,this.bits),s=[];let o=e,a=o;for(let c=0;c<i;c++){a=o,s.push(a);for(let u=1;u<n;u++)a=a.add(o),s.push(a);o=a.double()}return s}wNAF(e,r,i){if(!this.Fn.isValid(i))throw new Error("invalid scalar");let n=this.ZERO,s=this.BASE;const o=So(e,this.bits);for(let a=0;a<o.windows;a++){const{nextN:c,offset:u,isZero:l,isNeg:h,isNegF:f,offsetF:g}=Tl(i,a,o);i=c,l?s=s.add(fs(f,r[g])):n=n.add(fs(h,r[u]))}return Rl(i),{p:n,f:s}}wNAFUnsafe(e,r,i,n=this.ZERO){const s=So(e,this.bits);for(let o=0;o<s.windows&&i!==Ii;o++){const{nextN:a,offset:c,isZero:u,isNeg:l}=Tl(i,o,s);if(i=a,!u){const h=r[c];n=n.add(l?h.negate():h)}}return Rl(i),n}getPrecomputes(e,r,i){let n=Oo.get(r);return n||(n=this.precomputeWindow(r,e),e!==1&&(typeof i=="function"&&(n=i(n)),Oo.set(r,n))),n}cached(e,r,i){const n=Ao(e);return this.wNAF(n,this.getPrecomputes(n,e,i),r)}unsafe(e,r,i,n){const s=Ao(e);return s===1?this._unsafeLadder(e,r,n):this.wNAFUnsafe(s,this.getPrecomputes(s,e,i),r,n)}createCache(e,r){Rp(r,this.bits),Up.set(e,r),Oo.delete(e)}hasCache(e){return Ao(e)!==1}}function LD(t,e,r,i){let n=e,s=t.ZERO,o=t.ZERO;for(;r>Ii||i>Ii;)r&Kr&&(s=s.add(n)),i&Kr&&(o=o.add(n)),n=n.double(),r>>=Kr,i>>=Kr;return{p1:s,p2:o}}function MD(t,e,r,i){jD(r,t),kD(i,e);const n=r.length,s=i.length;if(n!==s)throw new Error("arrays of points and scalars must have equal length");const o=t.ZERO,a=Dp(BigInt(n));let c=1;a>12?c=a-3:a>4?c=a-2:a>0&&(c=2);const u=bn(c),l=new Array(Number(u)+1).fill(o),h=Math.floor((e.BITS-1)/c)*c;let f=o;for(let g=h;g>=0;g-=c){l.fill(o);for(let y=0;y<s;y++){const m=i[y],x=Number(m>>BigInt(g)&u);l[x]=l[x].add(r[y])}let p=o;for(let y=l.length-1,m=o;y>0;y--)m=m.add(l[y]),p=p.add(m);if(f=f.add(p),g!==0)for(let y=0;y<c;y++)f=f.double()}return f}function Ul(t,e,r){if(e){if(e.ORDER!==t)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return RD(e),e}else return $r(t,{isLE:r})}function qD(t,e,r={},i){if(i===void 0&&(i=t==="edwards"),!e||typeof e!="object")throw new Error(`expected valid ${t} CURVE object`);for(const a of["p","n","h"]){const c=e[a];if(!(typeof c=="bigint"&&c>Ii))throw new Error(`CURVE.${a} must be positive bigint`)}const n=Ul(e.p,r.Fp,i),s=Ul(e.n,r.Fn,i),o=["Gx","Gy","a","b"];for(const a of o)if(!n.isValid(e[a]))throw new Error(`CURVE.${a} must be valid field element of CURVE.Fp`);return e=Object.freeze(Object.assign({},e)),{CURVE:e,Fp:n,Fn:s}}BigInt(0),BigInt(1),BigInt(2),BigInt(8),sp("HashToScalar-");const ki=BigInt(0),ai=BigInt(1),Nn=BigInt(2);function zD(t){return Bs(t,{adjustScalarBytes:"function",powPminus2:"function"}),Object.freeze({...t})}function VD(t){const e=zD(t),{P:r,type:i,adjustScalarBytes:n,powPminus2:s,randomBytes:o}=e,a=i==="x25519";if(!a&&i!=="x448")throw new Error("invalid type");const c=o||Xr,u=a?255:448,l=a?32:56,h=BigInt(a?9:5),f=BigInt(a?121665:39081),g=a?Nn**BigInt(254):Nn**BigInt(447),p=a?BigInt(8)*Nn**BigInt(251)-ai:BigInt(4)*Nn**BigInt(445)-ai,y=g+p+ai,m=R=>st(R,r),x=S(h);function S(R){return Ec(m(R),l)}function v(R){const P=Le("u coordinate",R,l);return a&&(P[31]&=127),m(hs(P))}function b(R){return hs(n(Le("scalar",R,l)))}function E(R,P){const T=B(v(P),b(R));if(T===ki)throw new Error("invalid private or public key received");return S(T)}function I(R){return E(R,x)}function $(R,P,T){const d=m(R*(P-T));return P=m(P-d),T=m(T+d),{x_2:P,x_3:T}}function B(R,P){ma("u",R,ki,r),ma("scalar",P,g,y);const T=P,d=R;let w=ai,D=ki,O=R,_=ai,A=ki;for(let j=BigInt(u-1);j>=ki;j--){const q=T>>j&ai;A^=q,{x_2:w,x_3:O}=$(A,w,O),{x_2:D,x_3:_}=$(A,D,_),A=q;const U=w+D,L=m(U*U),K=w-D,G=m(K*K),Z=L-G,W=O+_,Y=O-_,ee=m(Y*U),ce=m(W*K),fe=ee+ce,ge=ee-ce;O=m(fe*fe),_=m(d*m(ge*ge)),w=m(L*G),D=m(Z*(L+m(f*Z)))}({x_2:w,x_3:O}=$(A,w,O)),{x_2:D,x_3:_}=$(A,D,_);const N=s(D);return m(w*N)}const C={secretKey:l,publicKey:l,seed:l},k=(R=c(l))=>(At(R,C.seed),R);function F(R){const P=k(R);return{secretKey:P,publicKey:I(P)}}return{keygen:F,getSharedSecret:(R,P)=>E(R,P),getPublicKey:R=>I(R),scalarMult:E,scalarMultBase:I,utils:{randomSecretKey:k,randomPrivateKey:k},GuBytes:x.slice(),lengths:C}}const HD=BigInt(1),Nl=BigInt(2),KD=BigInt(3),WD=BigInt(5);BigInt(8);const Np=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),GD={p:Np,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function YD(t){const e=BigInt(10),r=BigInt(20),i=BigInt(40),n=BigInt(80),s=Np,o=t*t%s*t%s,a=_t(o,Nl,s)*o%s,c=_t(a,HD,s)*t%s,u=_t(c,WD,s)*c%s,l=_t(u,e,s)*u%s,h=_t(l,r,s)*l%s,f=_t(h,i,s)*h%s,g=_t(f,n,s)*f%s,p=_t(g,n,s)*f%s,y=_t(p,e,s)*u%s;return{pow_p_5_8:_t(y,Nl,s)*t%s,b2:o}}function ZD(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}const JD=$r(GD.p,{isLE:!0}),va=(()=>{const t=JD.ORDER;return VD({P:t,type:"x25519",powPminus2:e=>{const{pow_p_5_8:r,b2:i}=YD(e);return st(_t(r,KD,t)*i,t)},adjustScalarBytes:ZD})})(),jl=(t,e)=>(t+(t>=0?e:-e)/jp)/e;function XD(t,e,r){const[[i,n],[s,o]]=e,a=jl(o*t,r),c=jl(-n*t,r);let u=t-a*i-c*s,l=-a*n-c*o;const h=u<rr,f=l<rr;h&&(u=-u),f&&(l=-l);const g=bn(Math.ceil(Dp(r)/2))+mi;if(u<rr||u>=g||l<rr||l>=g)throw new Error("splitScalar (endomorphism): failed, k="+t);return{k1neg:h,k1:u,k2neg:f,k2:l}}function Ea(t){if(!["compact","recovered","der"].includes(t))throw new Error('Signature format must be "compact", "recovered", or "der"');return t}function $o(t,e){const r={};for(let i of Object.keys(e))r[i]=t[i]===void 0?e[i]:t[i];return ls(r.lowS,"lowS"),ls(r.prehash,"prehash"),r.format!==void 0&&Ea(r.format),r}class QD extends Error{constructor(e=""){super(e)}}const er={Err:QD,_tlv:{encode:(t,e)=>{const{Err:r}=er;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length&1)throw new r("tlv.encode: unpadded data");const i=e.length/2,n=Un(i);if(n.length/2&128)throw new r("tlv.encode: long form length too big");const s=i>127?Un(n.length/2|128):"";return Un(t)+s+n+e},decode(t,e){const{Err:r}=er;let i=0;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length<2||e[i++]!==t)throw new r("tlv.decode: wrong tlv");const n=e[i++],s=!!(n&128);let o=0;if(!s)o=n;else{const c=n&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");const u=e.subarray(i,i+c);if(u.length!==c)throw new r("tlv.decode: length bytes not complete");if(u[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(const l of u)o=o<<8|l;if(i+=c,o<128)throw new r("tlv.decode(long): not minimal encoding")}const a=e.subarray(i,i+o);if(a.length!==o)throw new r("tlv.decode: wrong value length");return{v:a,l:e.subarray(i+o)}}},_int:{encode(t){const{Err:e}=er;if(t<rr)throw new e("integer: negative integers are not allowed");let r=Un(t);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return r},decode(t){const{Err:e}=er;if(t[0]&128)throw new e("invalid signature integer: negative");if(t[0]===0&&!(t[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return Ps(t)}},toSig(t){const{Err:e,_int:r,_tlv:i}=er,n=Le("signature",t),{v:s,l:o}=i.decode(48,n);if(o.length)throw new e("invalid signature: left bytes after parsing");const{v:a,l:c}=i.decode(2,s),{v:u,l}=i.decode(2,c);if(l.length)throw new e("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(u)}},hexFromSig(t){const{_tlv:e,_int:r}=er,i=e.encode(2,r.encode(t.r)),n=e.encode(2,r.encode(t.s)),s=i+n;return e.encode(48,s)}},rr=BigInt(0),mi=BigInt(1),jp=BigInt(2),jn=BigInt(3),ex=BigInt(4);function di(t,e){const{BYTES:r}=t;let i;if(typeof e=="bigint")i=e;else{let n=Le("private key",e);try{i=t.fromBytes(n)}catch{throw new Error(`invalid private key: expected ui8a of size ${r}, got ${typeof e}`)}}if(!t.isValidNot0(i))throw new Error("invalid private key: out of range [1..N-1]");return i}function tx(t,e={}){const r=qD("weierstrass",t,e),{Fp:i,Fn:n}=r;let s=r.CURVE;const{h:o,n:a}=s;Bs(e,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});const{endo:c}=e;if(c&&(!i.is0(s.a)||typeof c.beta!="bigint"||!Array.isArray(c.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');const u=Fp(i,n);function l(){if(!i.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function h(R,P,T){const{x:d,y:w}=P.toAffine(),D=i.toBytes(d);if(ls(T,"isCompressed"),T){l();const O=!i.isOdd(w);return Dr(kp(O),D)}else return Dr(Uint8Array.of(4),D,i.toBytes(w))}function f(R){Vr(R,void 0,"Point");const{publicKey:P,publicKeyUncompressed:T}=u,d=R.length,w=R[0],D=R.subarray(1);if(d===P&&(w===2||w===3)){const O=i.fromBytes(D);if(!i.isValid(O))throw new Error("bad point: is not on curve, wrong x");const _=y(O);let A;try{A=i.sqrt(_)}catch(j){const q=j instanceof Error?": "+j.message:"";throw new Error("bad point: is not on curve, sqrt error"+q)}l();const N=i.isOdd(A);return(w&1)===1!==N&&(A=i.neg(A)),{x:O,y:A}}else if(d===T&&w===4){const O=i.BYTES,_=i.fromBytes(D.subarray(0,O)),A=i.fromBytes(D.subarray(O,O*2));if(!m(_,A))throw new Error("bad point: is not on curve");return{x:_,y:A}}else throw new Error(`bad point: got length ${d}, expected compressed=${P} or uncompressed=${T}`)}const g=e.toBytes||h,p=e.fromBytes||f;function y(R){const P=i.sqr(R),T=i.mul(P,R);return i.add(i.add(T,i.mul(R,s.a)),s.b)}function m(R,P){const T=i.sqr(P),d=y(R);return i.eql(T,d)}if(!m(s.Gx,s.Gy))throw new Error("bad curve params: generator point");const x=i.mul(i.pow(s.a,jn),ex),S=i.mul(i.sqr(s.b),BigInt(27));if(i.is0(i.add(x,S)))throw new Error("bad curve params: a or b");function v(R,P,T=!1){if(!i.isValid(P)||T&&i.is0(P))throw new Error(`bad point coordinate ${R}`);return P}function b(R){if(!(R instanceof C))throw new Error("ProjectivePoint expected")}function E(R){if(!c||!c.basises)throw new Error("no endo");return XD(R,c.basises,n.ORDER)}const I=Cl((R,P)=>{const{X:T,Y:d,Z:w}=R;if(i.eql(w,i.ONE))return{x:T,y:d};const D=R.is0();P==null&&(P=D?i.ONE:i.inv(w));const O=i.mul(T,P),_=i.mul(d,P),A=i.mul(w,P);if(D)return{x:i.ZERO,y:i.ZERO};if(!i.eql(A,i.ONE))throw new Error("invZ was invalid");return{x:O,y:_}}),$=Cl(R=>{if(R.is0()){if(e.allowInfinityPoint&&!i.is0(R.Y))return;throw new Error("bad point: ZERO")}const{x:P,y:T}=R.toAffine();if(!i.isValid(P)||!i.isValid(T))throw new Error("bad point: x or y not field elements");if(!m(P,T))throw new Error("bad point: equation left != right");if(!R.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function B(R,P,T,d,w){return T=new C(i.mul(T.X,R),T.Y,T.Z),P=fs(d,P),T=fs(w,T),P.add(T)}class C{constructor(P,T,d){this.X=v("x",P),this.Y=v("y",T,!0),this.Z=v("z",d),Object.freeze(this)}static CURVE(){return s}static fromAffine(P){const{x:T,y:d}=P||{};if(!P||!i.isValid(T)||!i.isValid(d))throw new Error("invalid affine point");if(P instanceof C)throw new Error("projective point not allowed");return i.is0(T)&&i.is0(d)?C.ZERO:new C(T,d,i.ONE)}static fromBytes(P){const T=C.fromAffine(p(Vr(P,void 0,"point")));return T.assertValidity(),T}static fromHex(P){return C.fromBytes(Le("pointHex",P))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(P=8,T=!0){return F.createCache(this,P),T||this.multiply(jn),this}assertValidity(){$(this)}hasEvenY(){const{y:P}=this.toAffine();if(!i.isOdd)throw new Error("Field doesn't support isOdd");return!i.isOdd(P)}equals(P){b(P);const{X:T,Y:d,Z:w}=this,{X:D,Y:O,Z:_}=P,A=i.eql(i.mul(T,_),i.mul(D,w)),N=i.eql(i.mul(d,_),i.mul(O,w));return A&&N}negate(){return new C(this.X,i.neg(this.Y),this.Z)}double(){const{a:P,b:T}=s,d=i.mul(T,jn),{X:w,Y:D,Z:O}=this;let _=i.ZERO,A=i.ZERO,N=i.ZERO,j=i.mul(w,w),q=i.mul(D,D),U=i.mul(O,O),L=i.mul(w,D);return L=i.add(L,L),N=i.mul(w,O),N=i.add(N,N),_=i.mul(P,N),A=i.mul(d,U),A=i.add(_,A),_=i.sub(q,A),A=i.add(q,A),A=i.mul(_,A),_=i.mul(L,_),N=i.mul(d,N),U=i.mul(P,U),L=i.sub(j,U),L=i.mul(P,L),L=i.add(L,N),N=i.add(j,j),j=i.add(N,j),j=i.add(j,U),j=i.mul(j,L),A=i.add(A,j),U=i.mul(D,O),U=i.add(U,U),j=i.mul(U,L),_=i.sub(_,j),N=i.mul(U,q),N=i.add(N,N),N=i.add(N,N),new C(_,A,N)}add(P){b(P);const{X:T,Y:d,Z:w}=this,{X:D,Y:O,Z:_}=P;let A=i.ZERO,N=i.ZERO,j=i.ZERO;const q=s.a,U=i.mul(s.b,jn);let L=i.mul(T,D),K=i.mul(d,O),G=i.mul(w,_),Z=i.add(T,d),W=i.add(D,O);Z=i.mul(Z,W),W=i.add(L,K),Z=i.sub(Z,W),W=i.add(T,w);let Y=i.add(D,_);return W=i.mul(W,Y),Y=i.add(L,G),W=i.sub(W,Y),Y=i.add(d,w),A=i.add(O,_),Y=i.mul(Y,A),A=i.add(K,G),Y=i.sub(Y,A),j=i.mul(q,W),A=i.mul(U,G),j=i.add(A,j),A=i.sub(K,j),j=i.add(K,j),N=i.mul(A,j),K=i.add(L,L),K=i.add(K,L),G=i.mul(q,G),W=i.mul(U,W),K=i.add(K,G),G=i.sub(L,G),G=i.mul(q,G),W=i.add(W,G),L=i.mul(K,W),N=i.add(N,L),L=i.mul(Y,W),A=i.mul(Z,A),A=i.sub(A,L),L=i.mul(Z,K),j=i.mul(Y,j),j=i.add(j,L),new C(A,N,j)}subtract(P){return this.add(P.negate())}is0(){return this.equals(C.ZERO)}multiply(P){const{endo:T}=e;if(!n.isValidNot0(P))throw new Error("invalid scalar: out of range");let d,w;const D=O=>F.cached(this,O,_=>Io(C,_));if(T){const{k1neg:O,k1:_,k2neg:A,k2:N}=E(P),{p:j,f:q}=D(_),{p:U,f:L}=D(N);w=q.add(L),d=B(T.beta,j,U,O,A)}else{const{p:O,f:_}=D(P);d=O,w=_}return Io(C,[d,w])[0]}multiplyUnsafe(P){const{endo:T}=e,d=this;if(!n.isValid(P))throw new Error("invalid scalar: out of range");if(P===rr||d.is0())return C.ZERO;if(P===mi)return d;if(F.hasCache(this))return this.multiply(P);if(T){const{k1neg:w,k1:D,k2neg:O,k2:_}=E(P),{p1:A,p2:N}=LD(C,d,D,_);return B(T.beta,A,N,w,O)}else return F.unsafe(d,P)}multiplyAndAddUnsafe(P,T,d){const w=this.multiplyUnsafe(T).add(P.multiplyUnsafe(d));return w.is0()?void 0:w}toAffine(P){return I(this,P)}isTorsionFree(){const{isTorsionFree:P}=e;return o===mi?!0:P?P(C,this):F.unsafe(this,a).is0()}clearCofactor(){const{clearCofactor:P}=e;return o===mi?this:P?P(C,this):this.multiplyUnsafe(o)}isSmallOrder(){return this.multiplyUnsafe(o).is0()}toBytes(P=!0){return ls(P,"isCompressed"),this.assertValidity(),g(C,this,P)}toHex(P=!0){return bi(this.toBytes(P))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(P=!0){return this.toBytes(P)}_setWindowSize(P){this.precompute(P)}static normalizeZ(P){return Io(C,P)}static msm(P,T){return MD(C,n,P,T)}static fromPrivateKey(P){return C.BASE.multiply(di(n,P))}}C.BASE=new C(s.Gx,s.Gy,i.ONE),C.ZERO=new C(i.ZERO,i.ONE,i.ZERO),C.Fp=i,C.Fn=n;const k=n.BITS,F=new FD(C,e.endo?Math.ceil(k/2):k);return C.BASE.precompute(8),C}function kp(t){return Uint8Array.of(t?2:3)}function Fp(t,e){return{secretKey:e.BYTES,publicKey:1+t.BYTES,publicKeyUncompressed:1+2*t.BYTES,publicKeyHasPrefix:!0,signature:2*e.BYTES}}function rx(t,e={}){const{Fn:r}=t,i=e.randomBytes||Xr,n=Object.assign(Fp(t.Fp,r),{seed:Tp(r.ORDER)});function s(f){try{return!!di(r,f)}catch{return!1}}function o(f,g){const{publicKey:p,publicKeyUncompressed:y}=n;try{const m=f.length;return g===!0&&m!==p||g===!1&&m!==y?!1:!!t.fromBytes(f)}catch{return!1}}function a(f=i(n.seed)){return ND(Vr(f,n.seed,"seed"),r.ORDER)}function c(f,g=!0){return t.BASE.multiply(di(r,f)).toBytes(g)}function u(f){const g=a(f);return{secretKey:g,publicKey:c(g)}}function l(f){if(typeof f=="bigint")return!1;if(f instanceof t)return!0;const{secretKey:g,publicKey:p,publicKeyUncompressed:y}=n;if(r.allowedLengths||g===p)return;const m=Le("key",f).length;return m===p||m===y}function h(f,g,p=!0){if(l(f)===!0)throw new Error("first arg must be private key");if(l(g)===!1)throw new Error("second arg must be public key");const y=di(r,f);return t.fromHex(g).multiply(y).toBytes(p)}return Object.freeze({getPublicKey:c,getSharedSecret:h,keygen:u,Point:t,utils:{isValidSecretKey:s,isValidPublicKey:o,randomSecretKey:a,isValidPrivateKey:s,randomPrivateKey:a,normPrivateKeyToScalar:f=>di(r,f),precompute(f=8,g=t.BASE){return g.precompute(f,!1)}},lengths:n})}function ix(t,e,r={}){Ss(e),Bs(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const i=r.randomBytes||Xr,n=r.hmac||((T,...d)=>$s(e,T,Dr(...d))),{Fp:s,Fn:o}=t,{ORDER:a,BITS:c}=o,{keygen:u,getPublicKey:l,getSharedSecret:h,utils:f,lengths:g}=rx(t,r),p={prehash:!1,lowS:typeof r.lowS=="boolean"?r.lowS:!1,format:void 0,extraEntropy:!1},y="compact";function m(T){const d=a>>mi;return T>d}function x(T,d){if(!o.isValidNot0(d))throw new Error(`invalid signature ${T}: out of range 1..Point.Fn.ORDER`);return d}function S(T,d){Ea(d);const w=g.signature,D=d==="compact"?w:d==="recovered"?w+1:void 0;return Vr(T,D,`${d} signature`)}class v{constructor(d,w,D){this.r=x("r",d),this.s=x("s",w),D!=null&&(this.recovery=D),Object.freeze(this)}static fromBytes(d,w=y){S(d,w);let D;if(w==="der"){const{r:N,s:j}=er.toSig(Vr(d));return new v(N,j)}w==="recovered"&&(D=d[0],w="compact",d=d.subarray(1));const O=o.BYTES,_=d.subarray(0,O),A=d.subarray(O,O*2);return new v(o.fromBytes(_),o.fromBytes(A),D)}static fromHex(d,w){return this.fromBytes(cs(d),w)}addRecoveryBit(d){return new v(this.r,this.s,d)}recoverPublicKey(d){const w=s.ORDER,{r:D,s:O,recovery:_}=this;if(_==null||![0,1,2,3].includes(_))throw new Error("recovery id invalid");if(a*jp<w&&_>1)throw new Error("recovery id is ambiguous for h>1 curve");const A=_===2||_===3?D+a:D;if(!s.isValid(A))throw new Error("recovery id 2 or 3 invalid");const N=s.toBytes(A),j=t.fromBytes(Dr(kp((_&1)===0),N)),q=o.inv(A),U=E(Le("msgHash",d)),L=o.create(-U*q),K=o.create(O*q),G=t.BASE.multiplyUnsafe(L).add(j.multiplyUnsafe(K));if(G.is0())throw new Error("point at infinify");return G.assertValidity(),G}hasHighS(){return m(this.s)}toBytes(d=y){if(Ea(d),d==="der")return cs(er.hexFromSig(this));const w=o.toBytes(this.r),D=o.toBytes(this.s);if(d==="recovered"){if(this.recovery==null)throw new Error("recovery bit must be present");return Dr(Uint8Array.of(this.recovery),w,D)}return Dr(w,D)}toHex(d){return bi(this.toBytes(d))}assertValidity(){}static fromCompact(d){return v.fromBytes(Le("sig",d),"compact")}static fromDER(d){return v.fromBytes(Le("sig",d),"der")}normalizeS(){return this.hasHighS()?new v(this.r,o.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return bi(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return bi(this.toBytes("compact"))}}const b=r.bits2int||function(T){if(T.length>8192)throw new Error("input is too large");const d=Ps(T),w=T.length*8-c;return w>0?d>>BigInt(w):d},E=r.bits2int_modN||function(T){return o.create(b(T))},I=bn(c);function $(T){return ma("num < 2^"+c,T,rr,I),o.toBytes(T)}function B(T,d){return Vr(T,void 0,"message"),d?Vr(e(T),void 0,"prehashed message"):T}function C(T,d,w){if(["recovered","canonical"].some(K=>K in w))throw new Error("sign() legacy options not supported");const{lowS:D,prehash:O,extraEntropy:_}=$o(w,p);T=B(T,O);const A=E(T),N=di(o,d),j=[$(N),$(A)];if(_!=null&&_!==!1){const K=_===!0?i(g.secretKey):_;j.push(Le("extraEntropy",K))}const q=Dr(...j),U=A;function L(K){const G=b(K);if(!o.isValidNot0(G))return;const Z=o.inv(G),W=t.BASE.multiply(G).toAffine(),Y=o.create(W.x);if(Y===rr)return;const ee=o.create(Z*o.create(U+Y*N));if(ee===rr)return;let ce=(W.x===Y?0:2)|Number(W.y&mi),fe=ee;return D&&m(ee)&&(fe=o.neg(ee),ce^=1),new v(Y,fe,ce)}return{seed:q,k2sig:L}}function k(T,d,w={}){T=Le("message",T);const{seed:D,k2sig:O}=C(T,d,w);return OD(e.outputLen,o.BYTES,n)(D,O)}function F(T){let d;const w=typeof T=="string"||Is(T),D=!w&&T!==null&&typeof T=="object"&&typeof T.r=="bigint"&&typeof T.s=="bigint";if(!w&&!D)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(D)d=new v(T.r,T.s);else if(w){try{d=v.fromBytes(Le("sig",T),"der")}catch(O){if(!(O instanceof er.Err))throw O}if(!d)try{d=v.fromBytes(Le("sig",T),"compact")}catch{return!1}}return d||!1}function R(T,d,w,D={}){const{lowS:O,prehash:_,format:A}=$o(D,p);if(w=Le("publicKey",w),d=B(Le("message",d),_),"strict"in D)throw new Error("options.strict was renamed to lowS");const N=A===void 0?F(T):v.fromBytes(Le("sig",T),A);if(N===!1)return!1;try{const j=t.fromBytes(w);if(O&&N.hasHighS())return!1;const{r:q,s:U}=N,L=E(d),K=o.inv(U),G=o.create(L*K),Z=o.create(q*K),W=t.BASE.multiplyUnsafe(G).add(j.multiplyUnsafe(Z));return W.is0()?!1:o.create(W.x)===q}catch{return!1}}function P(T,d,w={}){const{prehash:D}=$o(w,p);return d=B(d,D),v.fromBytes(T,"recovered").recoverPublicKey(d).toBytes()}return Object.freeze({keygen:u,getPublicKey:l,getSharedSecret:h,utils:f,lengths:g,Point:t,sign:k,verify:R,recoverPublicKey:P,Signature:v,hash:e})}function nx(t){const e={a:t.a,b:t.b,p:t.Fp.ORDER,n:t.n,h:t.h,Gx:t.Gx,Gy:t.Gy},r=t.Fp;let i=t.allowedPrivateKeyLengths?Array.from(new Set(t.allowedPrivateKeyLengths.map(o=>Math.ceil(o/2)))):void 0;const n=$r(e.n,{BITS:t.nBitLength,allowedLengths:i,modFromBytes:t.wrapPrivateKey}),s={Fp:r,Fn:n,allowInfinityPoint:t.allowInfinityPoint,endo:t.endo,isTorsionFree:t.isTorsionFree,clearCofactor:t.clearCofactor,fromBytes:t.fromBytes,toBytes:t.toBytes};return{CURVE:e,curveOpts:s}}function sx(t){const{CURVE:e,curveOpts:r}=nx(t),i={hmac:t.hmac,randomBytes:t.randomBytes,lowS:t.lowS,bits2int:t.bits2int,bits2int_modN:t.bits2int_modN};return{CURVE:e,curveOpts:r,hash:t.hash,ecdsaOpts:i}}function ox(t,e){const r=e.Point;return Object.assign({},e,{ProjectivePoint:r,CURVE:Object.assign({},t,Pp(r.Fn.ORDER,r.Fn.BITS))})}function ax(t){const{CURVE:e,curveOpts:r,hash:i,ecdsaOpts:n}=sx(t),s=tx(e,r),o=ix(s,i,n);return ox(t,o)}function Da(t,e){const r=i=>ax({...t,hash:i});return{...r(e),create:r}}const Lp={p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")},Mp={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff"),n:BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),h:BigInt(1),a:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000fffffffc"),b:BigInt("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef"),Gx:BigInt("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),Gy:BigInt("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f")},qp={p:BigInt("0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),n:BigInt("0x01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409"),h:BigInt(1),a:BigInt("0x1fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc"),b:BigInt("0x0051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00"),Gx:BigInt("0x00c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66"),Gy:BigInt("0x011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650")},cx=$r(Lp.p),ux=$r(Mp.p),lx=$r(qp.p),hx=Da({...Lp,Fp:cx,lowS:!1},As);Da({...Mp,Fp:ux,lowS:!1},b3),Da({...qp,Fp:lx,lowS:!1,allowedPrivateKeyLengths:[130,131,132]},w3);const fx=hx,zp="base10",ze="base16",Ze="base64pad",xr="base64url",mn="utf8",Vp=0,nr=1,vn=2,dx=0,kl=1,Ji=12,xc=32;function px(){const t=va.utils.randomPrivateKey(),e=va.getPublicKey(t);return{privateKey:at(t,ze),publicKey:at(e,ze)}}function xa(){const t=Xr(xc);return at(t,ze)}function gx(t,e){const r=va.getSharedSecret(bt(t,ze),bt(e,ze)),i=ID(Cs,r,void 0,void 0,xc);return at(i,ze)}function Gn(t){const e=Cs(bt(t,ze));return at(e,ze)}function yt(t){const e=Cs(bt(t,mn));return at(e,ze)}function Hp(t){return bt(`${t}`,zp)}function Jr(t){return Number(at(t,zp))}function Kp(t){return t.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Wp(t){const e=t.replace(/-/g,"+").replace(/_/g,"/"),r=(4-e.length%4)%4;return e+"=".repeat(r)}function yx(t){const e=Hp(typeof t.type<"u"?t.type:Vp);if(Jr(e)===nr&&typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const r=typeof t.senderPublicKey<"u"?bt(t.senderPublicKey,ze):void 0,i=typeof t.iv<"u"?bt(t.iv,ze):Xr(Ji),n=bt(t.symKey,ze),s=mp(n,i).encrypt(bt(t.message,mn)),o=Gp({type:e,sealed:s,iv:i,senderPublicKey:r});return t.encoding===xr?Kp(o):o}function wx(t){const e=bt(t.symKey,ze),{sealed:r,iv:i}=cn({encoded:t.encoded,encoding:t.encoding}),n=mp(e,i).decrypt(r);if(n===null)throw new Error("Failed to decrypt");return at(n,mn)}function bx(t,e){const r=Hp(vn),i=Xr(Ji),n=bt(t,mn),s=Gp({type:r,sealed:n,iv:i});return e===xr?Kp(s):s}function mx(t,e){const{sealed:r}=cn({encoded:t,encoding:e});return at(r,mn)}function Gp(t){if(Jr(t.type)===vn)return at(Zi([t.type,t.sealed]),Ze);if(Jr(t.type)===nr){if(typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return at(Zi([t.type,t.senderPublicKey,t.iv,t.sealed]),Ze)}return at(Zi([t.type,t.iv,t.sealed]),Ze)}function cn(t){const e=(t.encoding||Ze)===xr?Wp(t.encoded):t.encoded,r=bt(e,Ze),i=r.slice(dx,kl),n=kl;if(Jr(i)===nr){const c=n+xc,u=c+Ji,l=r.slice(n,c),h=r.slice(c,u),f=r.slice(u);return{type:i,sealed:f,iv:h,senderPublicKey:l}}if(Jr(i)===vn){const c=r.slice(n),u=Xr(Ji);return{type:i,sealed:c,iv:u}}const s=n+Ji,o=r.slice(n,s),a=r.slice(s);return{type:i,sealed:a,iv:o}}function vx(t,e){const r=cn({encoded:t,encoding:e?.encoding});return Yp({type:Jr(r.type),senderPublicKey:typeof r.senderPublicKey<"u"?at(r.senderPublicKey,ze):void 0,receiverPublicKey:e?.receiverPublicKey})}function Yp(t){const e=t?.type||Vp;if(e===nr){if(typeof t?.senderPublicKey>"u")throw new Error("missing sender public key");if(typeof t?.receiverPublicKey>"u")throw new Error("missing receiver public key")}return{type:e,senderPublicKey:t?.senderPublicKey,receiverPublicKey:t?.receiverPublicKey}}function Fl(t){return t.type===nr&&typeof t.senderPublicKey=="string"&&typeof t.receiverPublicKey=="string"}function Ll(t){return t.type===vn}function Ex(t){const e=Buffer.from(t.x,"base64"),r=Buffer.from(t.y,"base64");return Zi([new Uint8Array([4]),e,r])}function Dx(t,e){const[r,i,n]=t.split("."),s=Buffer.from(Wp(n),"base64");if(s.length!==64)throw new Error("Invalid signature length");const o=s.slice(0,32),a=s.slice(32,64),c=`${r}.${i}`,u=Cs(c),l=Ex(e);if(!fx.verify(Zi([o,a]),u,l))throw new Error("Invalid signature");return ua(t).payload}const xx="irn";function ds(t){return t?.relay||{protocol:xx}}function pi(t){const e=T2[t];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${t}`);return e}var _x=Object.defineProperty,Ix=Object.defineProperties,Sx=Object.getOwnPropertyDescriptors,Ml=Object.getOwnPropertySymbols,Ox=Object.prototype.hasOwnProperty,Ax=Object.prototype.propertyIsEnumerable,ql=(t,e,r)=>e in t?_x(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Co=(t,e)=>{for(var r in e||(e={}))Ox.call(e,r)&&ql(t,r,e[r]);if(Ml)for(var r of Ml(e))Ax.call(e,r)&&ql(t,r,e[r]);return t},$x=(t,e)=>Ix(t,Sx(e));function Cx(t,e="-"){const r={},i="relay"+e;return Object.keys(t).forEach(n=>{if(n.startsWith(i)){const s=n.replace(i,""),o=t[n];r[s]=o}}),r}function zl(t){if(!t.includes("wc:")){const u=Qd(t);u!=null&&u.includes("wc:")&&(t=u)}t=t.includes("wc://")?t.replace("wc://",""):t,t=t.includes("wc:")?t.replace("wc:",""):t;const e=t.indexOf(":"),r=t.indexOf("?")!==-1?t.indexOf("?"):void 0,i=t.substring(0,e),n=t.substring(e+1,r).split("@"),s=typeof r<"u"?t.substring(r):"",o=new URLSearchParams(s),a=Object.fromEntries(o.entries()),c=typeof a.methods=="string"?a.methods.split(","):void 0;return{protocol:i,topic:Px(n[0]),version:parseInt(n[1],10),symKey:a.symKey,relay:Cx(a),methods:c,expiryTimestamp:a.expiryTimestamp?parseInt(a.expiryTimestamp,10):void 0}}function Px(t){return t.startsWith("//")?t.substring(2):t}function Bx(t,e="-"){const r="relay",i={};return Object.keys(t).forEach(n=>{const s=n,o=r+e+s;t[s]&&(i[o]=t[s])}),i}function Vl(t){const e=new URLSearchParams,r=Co(Co($x(Co({},Bx(t.relay)),{symKey:t.symKey}),t.expiryTimestamp&&{expiryTimestamp:t.expiryTimestamp.toString()}),t.methods&&{methods:t.methods.join(",")});return Object.entries(r).sort(([i],[n])=>i.localeCompare(n)).forEach(([i,n])=>{n!==void 0&&e.append(i,String(n))}),`${t.protocol}:${t.topic}@${t.version}?${e}`}function kn(t,e,r){return`${t}?wc_ev=${r}&topic=${e}`}var Tx=Object.defineProperty,Rx=Object.defineProperties,Ux=Object.getOwnPropertyDescriptors,Hl=Object.getOwnPropertySymbols,Nx=Object.prototype.hasOwnProperty,jx=Object.prototype.propertyIsEnumerable,Kl=(t,e,r)=>e in t?Tx(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,kx=(t,e)=>{for(var r in e||(e={}))Nx.call(e,r)&&Kl(t,r,e[r]);if(Hl)for(var r of Hl(e))jx.call(e,r)&&Kl(t,r,e[r]);return t},Fx=(t,e)=>Rx(t,Ux(e));function Ai(t){const e=[];return t.forEach(r=>{const[i,n]=r.split(":");e.push(`${i}:${n}`)}),e}function Lx(t){const e=[];return Object.values(t).forEach(r=>{e.push(...Ai(r.accounts))}),e}function Mx(t,e){const r=[];return Object.values(t).forEach(i=>{Ai(i.accounts).includes(e)&&r.push(...i.methods)}),r}function qx(t,e){const r=[];return Object.values(t).forEach(i=>{Ai(i.accounts).includes(e)&&r.push(...i.events)}),r}function Ts(t){return t.includes(":")}function gi(t){return Ts(t)?t.split(":")[0]:t}function Wl(t){var e,r,i;const n={};if(!Mt(t))return n;for(const[s,o]of Object.entries(t)){const a=Ts(s)?[s]:o.chains,c=o.methods||[],u=o.events||[],l=gi(s);n[l]=Fx(kx({},n[l]),{chains:Lt(a,(e=n[l])==null?void 0:e.chains),methods:Lt(c,(r=n[l])==null?void 0:r.methods),events:Lt(u,(i=n[l])==null?void 0:i.events)})}return n}function zx(t){const e={};return t?.forEach(r=>{var i;const[n,s]=r.split(":");e[n]||(e[n]={accounts:[],chains:[],events:[],methods:[]}),e[n].accounts.push(r),(i=e[n].chains)==null||i.push(`${n}:${s}`)}),e}function Gl(t,e){e=e.map(i=>i.replace("did:pkh:",""));const r=zx(e);for(const[i,n]of Object.entries(r))n.methods?n.methods=Lt(n.methods,t):n.methods=t,n.events=["chainChanged","accountsChanged"];return r}function Vx(t,e){var r,i,n,s,o,a;const c=Wl(t),u=Wl(e),l={},h=Object.keys(c).concat(Object.keys(u));for(const f of h)l[f]={chains:Lt((r=c[f])==null?void 0:r.chains,(i=u[f])==null?void 0:i.chains),methods:Lt((n=c[f])==null?void 0:n.methods,(s=u[f])==null?void 0:s.methods),events:Lt((o=c[f])==null?void 0:o.events,(a=u[f])==null?void 0:a.events)};return l}const Hx={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}},Kx={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};function z(t,e){const{message:r,code:i}=Kx[t];return{message:e?`${r} ${e}`:r,code:i}}function le(t,e){const{message:r,code:i}=Hx[t];return{message:e?`${r} ${e}`:r,code:i}}function mt(t,e){return!!Array.isArray(t)}function Mt(t){return Object.getPrototypeOf(t)===Object.prototype&&Object.keys(t).length}function Ee(t){return typeof t>"u"}function be(t,e){return e&&Ee(t)?!0:typeof t=="string"&&!!t.trim().length}function _c(t,e){return e&&Ee(t)?!0:typeof t=="number"&&!isNaN(t)}function Wx(t,e){const{requiredNamespaces:r}=e,i=Object.keys(t.namespaces),n=Object.keys(r);let s=!0;return zr(n,i)?(i.forEach(o=>{const{accounts:a,methods:c,events:u}=t.namespaces[o],l=Ai(a),h=r[o];(!zr(Gd(o,h),l)||!zr(h.methods,c)||!zr(h.events,u))&&(s=!1)}),s):!1}function ps(t){return be(t,!1)&&t.includes(":")?t.split(":").length===2:!1}function Gx(t){if(be(t,!1)&&t.includes(":")){const e=t.split(":");if(e.length===3){const r=e[0]+":"+e[1];return!!e[2]&&ps(r)}}return!1}function Yx(t){function e(r){try{return typeof new URL(r)<"u"}catch{return!1}}try{if(be(t,!1)){if(e(t))return!0;const r=Qd(t);return e(r)}}catch{}return!1}function Zx(t){var e;return(e=t?.proposer)==null?void 0:e.publicKey}function Jx(t){return t?.topic}function Xx(t,e){let r=null;return be(t?.publicKey,!1)||(r=z("MISSING_OR_INVALID",`${e} controller public key should be a string`)),r}function Yl(t){let e=!0;return mt(t)?t.length&&(e=t.every(r=>be(r,!1))):e=!1,e}function Qx(t,e,r){let i=null;return mt(e)&&e.length?e.forEach(n=>{i||ps(n)||(i=le("UNSUPPORTED_CHAINS",`${r}, chain ${n} should be a string and conform to "namespace:chainId" format`))}):ps(t)||(i=le("UNSUPPORTED_CHAINS",`${r}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }`)),i}function e8(t,e,r){let i=null;return Object.entries(t).forEach(([n,s])=>{if(i)return;const o=Qx(n,Gd(n,s),`${e} ${r}`);o&&(i=o)}),i}function t8(t,e){let r=null;return mt(t)?t.forEach(i=>{r||Gx(i)||(r=le("UNSUPPORTED_ACCOUNTS",`${e}, account ${i} should be a string and conform to "namespace:chainId:address" format`))}):r=le("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),r}function r8(t,e){let r=null;return Object.values(t).forEach(i=>{if(r)return;const n=t8(i?.accounts,`${e} namespace`);n&&(r=n)}),r}function i8(t,e){let r=null;return Yl(t?.methods)?Yl(t?.events)||(r=le("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):r=le("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),r}function Zp(t,e){let r=null;return Object.values(t).forEach(i=>{if(r)return;const n=i8(i,`${e}, namespace`);n&&(r=n)}),r}function n8(t,e,r){let i=null;if(t&&Mt(t)){const n=Zp(t,e);n&&(i=n);const s=e8(t,e,r);s&&(i=s)}else i=z("MISSING_OR_INVALID",`${e}, ${r} should be an object with data`);return i}function Po(t,e){let r=null;if(t&&Mt(t)){const i=Zp(t,e);i&&(r=i);const n=r8(t,e);n&&(r=n)}else r=z("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return r}function Jp(t){return be(t.protocol,!0)}function s8(t,e){let r=!1;return t?t&&mt(t)&&t.length&&t.forEach(i=>{r=Jp(i)}):r=!0,r}function o8(t){return typeof t=="number"}function We(t){return typeof t<"u"&&typeof t!==null}function a8(t){return!(!t||typeof t!="object"||!t.code||!_c(t.code,!1)||!t.message||!be(t.message,!1))}function c8(t){return!(Ee(t)||!be(t.method,!1))}function u8(t){return!(Ee(t)||Ee(t.result)&&Ee(t.error)||!_c(t.id,!1)||!be(t.jsonrpc,!1))}function l8(t){return!(Ee(t)||!be(t.name,!1))}function Zl(t,e){return!(!ps(e)||!Lx(t).includes(e))}function h8(t,e,r){return be(r,!1)?Mx(t,e).includes(r):!1}function f8(t,e,r){return be(r,!1)?qx(t,e).includes(r):!1}function Jl(t,e,r){let i=null;const n=d8(t),s=p8(e),o=Object.keys(n),a=Object.keys(s),c=Xl(Object.keys(t)),u=Xl(Object.keys(e)),l=c.filter(h=>!u.includes(h));return l.length&&(i=z("NON_CONFORMING_NAMESPACES",`${r} namespaces keys don't satisfy requiredNamespaces.
9
- Required: ${l.toString()}
10
- Received: ${Object.keys(e).toString()}`)),zr(o,a)||(i=z("NON_CONFORMING_NAMESPACES",`${r} namespaces chains don't satisfy required namespaces.
11
- Required: ${o.toString()}
12
- Approved: ${a.toString()}`)),Object.keys(e).forEach(h=>{if(!h.includes(":")||i)return;const f=Ai(e[h].accounts);f.includes(h)||(i=z("NON_CONFORMING_NAMESPACES",`${r} namespaces accounts don't satisfy namespace accounts for ${h}
13
- Required: ${h}
14
- Approved: ${f.toString()}`))}),o.forEach(h=>{i||(zr(n[h].methods,s[h].methods)?zr(n[h].events,s[h].events)||(i=z("NON_CONFORMING_NAMESPACES",`${r} namespaces events don't satisfy namespace events for ${h}`)):i=z("NON_CONFORMING_NAMESPACES",`${r} namespaces methods don't satisfy namespace methods for ${h}`))}),i}function d8(t){const e={};return Object.keys(t).forEach(r=>{var i;r.includes(":")?e[r]=t[r]:(i=t[r].chains)==null||i.forEach(n=>{e[n]={methods:t[r].methods,events:t[r].events}})}),e}function Xl(t){return[...new Set(t.map(e=>e.includes(":")?e.split(":")[0]:e))]}function p8(t){const e={};return Object.keys(t).forEach(r=>{r.includes(":")?e[r]=t[r]:Ai(t[r].accounts)?.forEach(n=>{e[n]={accounts:t[r].accounts.filter(s=>s.includes(`${n}:`)),methods:t[r].methods,events:t[r].events}})}),e}function g8(t,e){return _c(t,!1)&&t<=e.max&&t>=e.min}function Ql(){const t=yn();return new Promise(e=>{switch(t){case ot.browser:e(y8());break;case ot.reactNative:e(w8());break;case ot.node:e(b8());break;default:e(!0)}})}function y8(){return Oi()&&navigator?.onLine}async function w8(){return Ar()&&typeof global<"u"&&global!=null&&global.NetInfo?(await(global==null?void 0:global.NetInfo.fetch()))?.isConnected:!0}function b8(){return!0}function m8(t){switch(yn()){case ot.browser:v8(t);break;case ot.reactNative:E8(t);break}}function v8(t){!Ar()&&Oi()&&(window.addEventListener("online",()=>t(!0)),window.addEventListener("offline",()=>t(!1)))}function E8(t){Ar()&&typeof global<"u"&&global!=null&&global.NetInfo&&global?.NetInfo.addEventListener(e=>t(e?.isConnected))}function D8(){var t;return Oi()&&sr.getDocument()?((t=sr.getDocument())==null?void 0:t.visibilityState)==="visible":!0}const Bo={};class Fi{static get(e){return Bo[e]}static set(e,r){Bo[e]=r}static delete(e){delete Bo[e]}}function x8(t){const e=dn.decode(t);if(e.length<33)throw new Error("Too short to contain a public key");return e.slice(1,33)}function _8({publicKey:t,signature:e,payload:r}){var i;const n=_a(r.method),s=128|parseInt(((i=r.version)==null?void 0:i.toString())||"4"),o=O8(r.address),a=r.era==="00"?new Uint8Array([0]):_a(r.era);if(a.length!==1&&a.length!==2)throw new Error("Invalid era length");const c=parseInt(r.nonce,16),u=new Uint8Array([c&255,c>>8&255]),l=BigInt(`0x${S8(r.tip)}`),h=$8(l),f=new Uint8Array([0,...t,o,...e,...a,...u,...h,...n]),g=A8(f.length+1);return new Uint8Array([...g,s,...f])}function I8(t){const e=_a(t),r=j2.blake2b(e,void 0,32);return"0x"+Buffer.from(r).toString("hex")}function _a(t){return new Uint8Array(t.replace(/^0x/,"").match(/.{1,2}/g).map(e=>parseInt(e,16)))}function S8(t){return t.startsWith("0x")?t.slice(2):t}function O8(t){const e=dn.decode(t)[0];return e===42?0:e===60?2:1}function A8(t){if(t<64)return new Uint8Array([t<<2]);if(t<16384){const e=t<<2|1;return new Uint8Array([e&255,e>>8&255])}else if(t<1<<30){const e=t<<2|2;return new Uint8Array([e&255,e>>8&255,e>>16&255,e>>24&255])}else throw new Error("Compact encoding > 2^30 not supported")}function $8(t){if(t<BigInt(1)<<BigInt(6))return new Uint8Array([Number(t<<BigInt(2))]);if(t<BigInt(1)<<BigInt(14)){const e=t<<BigInt(2)|BigInt(1);return new Uint8Array([Number(e&BigInt(255)),Number(e>>BigInt(8)&BigInt(255))])}else if(t<BigInt(1)<<BigInt(30)){const e=t<<BigInt(2)|BigInt(2);return new Uint8Array([Number(e&BigInt(255)),Number(e>>BigInt(8)&BigInt(255)),Number(e>>BigInt(16)&BigInt(255)),Number(e>>BigInt(24)&BigInt(255))])}else throw new Error("BigInt compact encoding not supported > 2^30")}function C8(t){const e=Uint8Array.from(Buffer.from(t.signature,"hex")),r=x8(t.transaction.address),i=_8({publicKey:r,signature:e,payload:t.transaction}),n=Buffer.from(i).toString("hex");return I8(n)}function Ic({logger:t,name:e}){const r=typeof t=="string"?Wd({opts:{level:t,name:e}}).logger:t;return r.level=typeof t=="string"?t:t.level,r}class Qr{}let P8=class extends Qr{constructor(e){super()}};const eh=V.FIVE_SECONDS,ei={pulse:"heartbeat_pulse"};let B8=class Xp extends P8{constructor(e){super(e),this.events=new ct.EventEmitter,this.interval=eh,this.interval=e?.interval||eh}static async init(e){const r=new Xp(e);return await r.init(),r}async init(){await this.initialize()}stop(){clearInterval(this.intervalRef)}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async initialize(){this.intervalRef=setInterval(()=>this.pulse(),V.toMiliseconds(this.interval))}pulse(){this.events.emit(ei.pulse)}};function T8(t){return!t||typeof t.then!="function"?Promise.resolve(t):t}function Ie(t,...e){try{return T8(t(...e))}catch(r){return Promise.reject(r)}}function R8(t){const e=typeof t;return t===null||e!=="object"&&e!=="function"}function U8(t){const e=Object.getPrototypeOf(t);return!e||e.isPrototypeOf(Object)}function Yn(t){if(R8(t))return String(t);if(U8(t)||Array.isArray(t))return JSON.stringify(t);if(typeof t.toJSON=="function")return Yn(t.toJSON());throw new Error("[unstorage] Cannot stringify value!")}const Ia="base64:";function N8(t){return typeof t=="string"?t:Ia+F8(t)}function j8(t){return typeof t!="string"||!t.startsWith(Ia)?t:k8(t.slice(Ia.length))}function k8(t){return globalThis.Buffer?Buffer.from(t,"base64"):Uint8Array.from(globalThis.atob(t),e=>e.codePointAt(0))}function F8(t){return globalThis.Buffer?Buffer.from(t).toString("base64"):globalThis.btoa(String.fromCodePoint(...t))}function Ke(t){return t&&t.split("?")[0]?.replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,"")||""}function L8(...t){return Ke(t.join(":"))}function Fn(t){return t=Ke(t),t?t+":":""}function M8(t,e){if(e===void 0)return!0;let r=0,i=t.indexOf(":");for(;i>-1;)r++,i=t.indexOf(":",i+1);return r<=e}function q8(t,e){return e?t.startsWith(e)&&t[t.length-1]!=="$":t[t.length-1]!=="$"}const z8="memory",V8=()=>{const t=new Map;return{name:z8,getInstance:()=>t,hasItem(e){return t.has(e)},getItem(e){return t.get(e)??null},getItemRaw(e){return t.get(e)??null},setItem(e,r){t.set(e,r)},setItemRaw(e,r){t.set(e,r)},removeItem(e){t.delete(e)},getKeys(){return[...t.keys()]},clear(){t.clear()},dispose(){t.clear()}}};function H8(t={}){const e={mounts:{"":t.driver||V8()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},r=u=>{for(const l of e.mountpoints)if(u.startsWith(l))return{base:l,relativeKey:u.slice(l.length),driver:e.mounts[l]};return{base:"",relativeKey:u,driver:e.mounts[""]}},i=(u,l)=>e.mountpoints.filter(h=>h.startsWith(u)||l&&u.startsWith(h)).map(h=>({relativeBase:u.length>h.length?u.slice(h.length):void 0,mountpoint:h,driver:e.mounts[h]})),n=(u,l)=>{if(e.watching){l=Ke(l);for(const h of e.watchListeners)h(u,l)}},s=async()=>{if(!e.watching){e.watching=!0;for(const u in e.mounts)e.unwatch[u]=await th(e.mounts[u],n,u)}},o=async()=>{if(e.watching){for(const u in e.unwatch)await e.unwatch[u]();e.unwatch={},e.watching=!1}},a=(u,l,h)=>{const f=new Map,g=p=>{let y=f.get(p.base);return y||(y={driver:p.driver,base:p.base,items:[]},f.set(p.base,y)),y};for(const p of u){const y=typeof p=="string",m=Ke(y?p:p.key),x=y?void 0:p.value,S=y||!p.options?l:{...l,...p.options},v=r(m);g(v).items.push({key:m,value:x,relativeKey:v.relativeKey,options:S})}return Promise.all([...f.values()].map(p=>h(p))).then(p=>p.flat())},c={hasItem(u,l={}){u=Ke(u);const{relativeKey:h,driver:f}=r(u);return Ie(f.hasItem,h,l)},getItem(u,l={}){u=Ke(u);const{relativeKey:h,driver:f}=r(u);return Ie(f.getItem,h,l).then(g=>xn(g))},getItems(u,l={}){return a(u,l,h=>h.driver.getItems?Ie(h.driver.getItems,h.items.map(f=>({key:f.relativeKey,options:f.options})),l).then(f=>f.map(g=>({key:L8(h.base,g.key),value:xn(g.value)}))):Promise.all(h.items.map(f=>Ie(h.driver.getItem,f.relativeKey,f.options).then(g=>({key:f.key,value:xn(g)})))))},getItemRaw(u,l={}){u=Ke(u);const{relativeKey:h,driver:f}=r(u);return f.getItemRaw?Ie(f.getItemRaw,h,l):Ie(f.getItem,h,l).then(g=>j8(g))},async setItem(u,l,h={}){if(l===void 0)return c.removeItem(u);u=Ke(u);const{relativeKey:f,driver:g}=r(u);g.setItem&&(await Ie(g.setItem,f,Yn(l),h),g.watch||n("update",u))},async setItems(u,l){await a(u,l,async h=>{if(h.driver.setItems)return Ie(h.driver.setItems,h.items.map(f=>({key:f.relativeKey,value:Yn(f.value),options:f.options})),l);h.driver.setItem&&await Promise.all(h.items.map(f=>Ie(h.driver.setItem,f.relativeKey,Yn(f.value),f.options)))})},async setItemRaw(u,l,h={}){if(l===void 0)return c.removeItem(u,h);u=Ke(u);const{relativeKey:f,driver:g}=r(u);if(g.setItemRaw)await Ie(g.setItemRaw,f,l,h);else if(g.setItem)await Ie(g.setItem,f,N8(l),h);else return;g.watch||n("update",u)},async removeItem(u,l={}){typeof l=="boolean"&&(l={removeMeta:l}),u=Ke(u);const{relativeKey:h,driver:f}=r(u);f.removeItem&&(await Ie(f.removeItem,h,l),(l.removeMeta||l.removeMata)&&await Ie(f.removeItem,h+"$",l),f.watch||n("remove",u))},async getMeta(u,l={}){typeof l=="boolean"&&(l={nativeOnly:l}),u=Ke(u);const{relativeKey:h,driver:f}=r(u),g=Object.create(null);if(f.getMeta&&Object.assign(g,await Ie(f.getMeta,h,l)),!l.nativeOnly){const p=await Ie(f.getItem,h+"$",l).then(y=>xn(y));p&&typeof p=="object"&&(typeof p.atime=="string"&&(p.atime=new Date(p.atime)),typeof p.mtime=="string"&&(p.mtime=new Date(p.mtime)),Object.assign(g,p))}return g},setMeta(u,l,h={}){return this.setItem(u+"$",l,h)},removeMeta(u,l={}){return this.removeItem(u+"$",l)},async getKeys(u,l={}){u=Fn(u);const h=i(u,!0);let f=[];const g=[];let p=!0;for(const m of h){m.driver.flags?.maxDepth||(p=!1);const x=await Ie(m.driver.getKeys,m.relativeBase,l);for(const S of x){const v=m.mountpoint+Ke(S);f.some(b=>v.startsWith(b))||g.push(v)}f=[m.mountpoint,...f.filter(S=>!S.startsWith(m.mountpoint))]}const y=l.maxDepth!==void 0&&!p;return g.filter(m=>(!y||M8(m,l.maxDepth))&&q8(m,u))},async clear(u,l={}){u=Fn(u),await Promise.all(i(u,!1).map(async h=>{if(h.driver.clear)return Ie(h.driver.clear,h.relativeBase,l);if(h.driver.removeItem){const f=await h.driver.getKeys(h.relativeBase||"",l);return Promise.all(f.map(g=>h.driver.removeItem(g,l)))}}))},async dispose(){await Promise.all(Object.values(e.mounts).map(u=>rh(u)))},async watch(u){return await s(),e.watchListeners.push(u),async()=>{e.watchListeners=e.watchListeners.filter(l=>l!==u),e.watchListeners.length===0&&await o()}},async unwatch(){e.watchListeners=[],await o()},mount(u,l){if(u=Fn(u),u&&e.mounts[u])throw new Error(`already mounted at ${u}`);return u&&(e.mountpoints.push(u),e.mountpoints.sort((h,f)=>f.length-h.length)),e.mounts[u]=l,e.watching&&Promise.resolve(th(l,n,u)).then(h=>{e.unwatch[u]=h}).catch(console.error),c},async unmount(u,l=!0){u=Fn(u),!(!u||!e.mounts[u])&&(e.watching&&u in e.unwatch&&(e.unwatch[u]?.(),delete e.unwatch[u]),l&&await rh(e.mounts[u]),e.mountpoints=e.mountpoints.filter(h=>h!==u),delete e.mounts[u])},getMount(u=""){u=Ke(u)+":";const l=r(u);return{driver:l.driver,base:l.base}},getMounts(u="",l={}){return u=Ke(u),i(u,l.parents).map(f=>({driver:f.driver,base:f.mountpoint}))},keys:(u,l={})=>c.getKeys(u,l),get:(u,l={})=>c.getItem(u,l),set:(u,l,h={})=>c.setItem(u,l,h),has:(u,l={})=>c.hasItem(u,l),del:(u,l={})=>c.removeItem(u,l),remove:(u,l={})=>c.removeItem(u,l)};return c}function th(t,e,r){return t.watch?t.watch((i,n)=>e(i,r+n)):()=>{}}async function rh(t){typeof t.dispose=="function"&&await Ie(t.dispose)}const K8="idb-keyval";var W8=(t={})=>{const e=t.base&&t.base.length>0?`${t.base}:`:"",r=n=>e+n;let i;return t.dbName&&t.storeName&&(i=hy(t.dbName,t.storeName)),{name:K8,options:t,async hasItem(n){return!(typeof await Vc(r(n),i)>"u")},async getItem(n){return await Vc(r(n),i)??null},setItem(n,s){return gy(r(n),s,i)},removeItem(n){return py(r(n),i)},getKeys(){return dy(i)},clear(){return fy(i)}}};const G8="WALLET_CONNECT_V2_INDEXED_DB",Y8="keyvaluestorage";let Z8=class{constructor(){this.indexedDb=H8({driver:W8({dbName:G8,storeName:Y8})})}async getKeys(){return this.indexedDb.getKeys()}async getEntries(){return(await this.indexedDb.getItems(await this.indexedDb.getKeys())).map(e=>[e.key,e.value])}async getItem(e){const r=await this.indexedDb.getItem(e);if(r!==null)return r}async setItem(e,r){await this.indexedDb.setItem(e,or(r))}async removeItem(e){await this.indexedDb.removeItem(e)}};var To=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Zn={exports:{}};(function(){let t;function e(){}t=e,t.prototype.getItem=function(r){return this.hasOwnProperty(r)?String(this[r]):null},t.prototype.setItem=function(r,i){this[r]=String(i)},t.prototype.removeItem=function(r){delete this[r]},t.prototype.clear=function(){const r=this;Object.keys(r).forEach(function(i){r[i]=void 0,delete r[i]})},t.prototype.key=function(r){return r=r||0,Object.keys(this)[r]},t.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof To<"u"&&To.localStorage?Zn.exports=To.localStorage:typeof window<"u"&&window.localStorage?Zn.exports=window.localStorage:Zn.exports=new e})();function J8(t){var e;return[t[0],Yr((e=t[1])!=null?e:"")]}let X8=class{constructor(){this.localStorage=Zn.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(J8)}async getItem(e){const r=this.localStorage.getItem(e);if(r!==null)return Yr(r)}async setItem(e,r){this.localStorage.setItem(e,or(r))}async removeItem(e){this.localStorage.removeItem(e)}};const Q8="wc_storage_version",ih=1,e_=async(t,e,r)=>{const i=Q8,n=await e.getItem(i);if(n&&n>=ih){r(e);return}const s=await t.getKeys();if(!s.length){r(e);return}const o=[];for(;s.length;){const a=s.shift();if(!a)continue;const c=a.toLowerCase();if(c.includes("wc@")||c.includes("walletconnect")||c.includes("wc_")||c.includes("wallet_connect")){const u=await t.getItem(a);await e.setItem(a,u),o.push(a)}}await e.setItem(i,ih),r(e),t_(t,o)},t_=async(t,e)=>{e.length&&e.forEach(async r=>{await t.removeItem(r)})};let r_=class{constructor(){this.initialized=!1,this.setInitialized=r=>{this.storage=r,this.initialized=!0};const e=new X8;this.storage=e;try{const r=new Z8;e_(e,r,this.setInitialized)}catch{this.initialized=!0}}async getKeys(){return await this.initialize(),this.storage.getKeys()}async getEntries(){return await this.initialize(),this.storage.getEntries()}async getItem(e){return await this.initialize(),this.storage.getItem(e)}async setItem(e,r){return await this.initialize(),this.storage.setItem(e,r)}async removeItem(e){return await this.initialize(),this.storage.removeItem(e)}async initialize(){this.initialized||await new Promise(e=>{const r=setInterval(()=>{this.initialized&&(clearInterval(r),e())},20)})}};var i_=Object.defineProperty,n_=(t,e,r)=>e in t?i_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,nh=(t,e,r)=>n_(t,typeof e!="symbol"?e+"":e,r);let s_=class extends Qr{constructor(e){super(),this.opts=e,nh(this,"protocol","wc"),nh(this,"version",2)}};var o_=Object.defineProperty,a_=(t,e,r)=>e in t?o_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,c_=(t,e,r)=>a_(t,e+"",r);let u_=class extends Qr{constructor(e,r){super(),this.core=e,this.logger=r,c_(this,"records",new Map)}},l_=class{constructor(e,r){this.logger=e,this.core=r}},h_=class extends Qr{constructor(e,r){super(),this.relayer=e,this.logger=r}},f_=class extends Qr{constructor(e){super()}},d_=class{constructor(e,r,i,n){this.core=e,this.logger=r,this.name=i}},p_=class extends Qr{constructor(e,r){super(),this.relayer=e,this.logger=r}},g_=class extends Qr{constructor(e,r){super(),this.core=e,this.logger=r}},y_=class{constructor(e,r,i){this.core=e,this.logger=r,this.store=i}},w_=class{constructor(e,r){this.projectId=e,this.logger=r}},b_=class{constructor(e,r,i){this.core=e,this.logger=r,this.telemetryEnabled=i}};var m_=Object.defineProperty,v_=(t,e,r)=>e in t?m_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,sh=(t,e,r)=>v_(t,typeof e!="symbol"?e+"":e,r);let E_=class{constructor(e){this.opts=e,sh(this,"protocol","wc"),sh(this,"version",2)}},D_=class{constructor(e){this.client=e}};function x_(t){return globalThis.Buffer!=null?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t}function __(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?x_(globalThis.Buffer.allocUnsafe(t)):new Uint8Array(t)}function I_(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),i=0;i<r.length;i++)r[i]=255;for(var n=0;n<t.length;n++){var s=t.charAt(n),o=s.charCodeAt(0);if(r[o]!==255)throw new TypeError(s+" is ambiguous");r[o]=n}var a=t.length,c=t.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function h(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var y=0,m=0,x=0,S=p.length;x!==S&&p[x]===0;)x++,y++;for(var v=(S-x)*l+1>>>0,b=new Uint8Array(v);x!==S;){for(var E=p[x],I=0,$=v-1;(E!==0||I<m)&&$!==-1;$--,I++)E+=256*b[$]>>>0,b[$]=E%a>>>0,E=E/a>>>0;if(E!==0)throw new Error("Non-zero carry");m=I,x++}for(var B=v-m;B!==v&&b[B]===0;)B++;for(var C=c.repeat(y);B<v;++B)C+=t.charAt(b[B]);return C}function f(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var y=0;if(p[y]!==" "){for(var m=0,x=0;p[y]===c;)m++,y++;for(var S=(p.length-y)*u+1>>>0,v=new Uint8Array(S);p[y];){var b=r[p.charCodeAt(y)];if(b===255)return;for(var E=0,I=S-1;(b!==0||E<x)&&I!==-1;I--,E++)b+=a*v[I]>>>0,v[I]=b%256>>>0,b=b/256>>>0;if(b!==0)throw new Error("Non-zero carry");x=E,y++}if(p[y]!==" "){for(var $=S-x;$!==S&&v[$]===0;)$++;for(var B=new Uint8Array(m+(S-$)),C=m;$!==S;)B[C++]=v[$++];return B}}}function g(p){var y=f(p);if(y)return y;throw new Error(`Non-${e} character`)}return{encode:h,decodeUnsafe:f,decode:g}}var S_=I_,O_=S_;const A_=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")},$_=t=>new TextEncoder().encode(t),C_=t=>new TextDecoder().decode(t);class P_{constructor(e,r,i){this.name=e,this.prefix=r,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class B_{constructor(e,r,i){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Qp(this,e)}}class T_{constructor(e){this.decoders=e}or(e){return Qp(this,e)}decode(e){const r=e[0],i=this.decoders[r];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const Qp=(t,e)=>new T_({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class R_{constructor(e,r,i,n){this.name=e,this.prefix=r,this.baseEncode=i,this.baseDecode=n,this.encoder=new P_(e,r,i),this.decoder=new B_(e,r,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Rs=({name:t,prefix:e,encode:r,decode:i})=>new R_(t,e,r,i),En=({prefix:t,name:e,alphabet:r})=>{const{encode:i,decode:n}=O_(r,e);return Rs({prefix:t,name:e,encode:i,decode:s=>A_(n(s))})},U_=(t,e,r,i)=>{const n={};for(let l=0;l<e.length;++l)n[e[l]]=l;let s=t.length;for(;t[s-1]==="=";)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,u=0;for(let l=0;l<s;++l){const h=n[t[l]];if(h===void 0)throw new SyntaxError(`Non-${i} character`);c=c<<r|h,a+=r,a>=8&&(a-=8,o[u++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},N_=(t,e,r)=>{const i=e[e.length-1]==="=",n=(1<<r)-1;let s="",o=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],o+=8;o>r;)o-=r,s+=e[n&a>>o];if(o&&(s+=e[n&a<<r-o]),i)for(;s.length*r&7;)s+="=";return s},Te=({name:t,prefix:e,bitsPerChar:r,alphabet:i})=>Rs({prefix:e,name:t,encode(n){return N_(n,i,r)},decode(n){return U_(n,i,r,t)}}),j_=Rs({prefix:"\0",name:"identity",encode:t=>C_(t),decode:t=>$_(t)}),k_=Object.freeze(Object.defineProperty({__proto__:null,identity:j_},Symbol.toStringTag,{value:"Module"})),F_=Te({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),L_=Object.freeze(Object.defineProperty({__proto__:null,base2:F_},Symbol.toStringTag,{value:"Module"})),M_=Te({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),q_=Object.freeze(Object.defineProperty({__proto__:null,base8:M_},Symbol.toStringTag,{value:"Module"})),z_=En({prefix:"9",name:"base10",alphabet:"0123456789"}),V_=Object.freeze(Object.defineProperty({__proto__:null,base10:z_},Symbol.toStringTag,{value:"Module"})),H_=Te({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),K_=Te({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),W_=Object.freeze(Object.defineProperty({__proto__:null,base16:H_,base16upper:K_},Symbol.toStringTag,{value:"Module"})),G_=Te({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Y_=Te({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Z_=Te({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),J_=Te({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),X_=Te({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Q_=Te({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),eI=Te({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),tI=Te({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),rI=Te({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),iI=Object.freeze(Object.defineProperty({__proto__:null,base32:G_,base32hex:X_,base32hexpad:eI,base32hexpadupper:tI,base32hexupper:Q_,base32pad:Z_,base32padupper:J_,base32upper:Y_,base32z:rI},Symbol.toStringTag,{value:"Module"})),nI=En({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),sI=En({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),oI=Object.freeze(Object.defineProperty({__proto__:null,base36:nI,base36upper:sI},Symbol.toStringTag,{value:"Module"})),aI=En({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),cI=En({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),uI=Object.freeze(Object.defineProperty({__proto__:null,base58btc:aI,base58flickr:cI},Symbol.toStringTag,{value:"Module"})),lI=Te({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),hI=Te({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),fI=Te({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),dI=Te({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),pI=Object.freeze(Object.defineProperty({__proto__:null,base64:lI,base64pad:hI,base64url:fI,base64urlpad:dI},Symbol.toStringTag,{value:"Module"})),eg=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),gI=eg.reduce((t,e,r)=>(t[r]=e,t),[]),yI=eg.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function wI(t){return t.reduce((e,r)=>(e+=gI[r],e),"")}function bI(t){const e=[];for(const r of t){const i=yI[r.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(i)}return new Uint8Array(e)}const mI=Rs({prefix:"🚀",name:"base256emoji",encode:wI,decode:bI}),vI=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:mI},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const oh={...k_,...L_,...q_,...V_,...W_,...iI,...oI,...uI,...pI,...vI};function tg(t,e,r,i){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:i}}}const ah=tg("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Ro=tg("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);const e=__(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),EI={utf8:ah,"utf-8":ah,hex:oh.base16,latin1:Ro,ascii:Ro,binary:Ro,...oh};function DI(t,e="utf8"){const r=EI[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):r.encoder.encode(t).substring(1)}const xI="PARSE_ERROR",_I="INVALID_REQUEST",II="METHOD_NOT_FOUND",SI="INVALID_PARAMS",rg="INTERNAL_ERROR",Sc="SERVER_ERROR",OI=[-32700,-32600,-32601,-32602,-32603],Xi={[xI]:{code:-32700,message:"Parse error"},[_I]:{code:-32600,message:"Invalid Request"},[II]:{code:-32601,message:"Method not found"},[SI]:{code:-32602,message:"Invalid params"},[rg]:{code:-32603,message:"Internal error"},[Sc]:{code:-32e3,message:"Server error"}},ig=Sc;function AI(t){return OI.includes(t)}function ch(t){return Object.keys(Xi).includes(t)?Xi[t]:Xi[ig]}function $I(t){const e=Object.values(Xi).find(r=>r.code===t);return e||Xi[ig]}function ng(t,e,r){return t.message.includes("getaddrinfo ENOTFOUND")||t.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${r} RPC url at ${e}`):t}var Uo={};var Sa=function(t,e){return Sa=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var n in i)i.hasOwnProperty(n)&&(r[n]=i[n])},Sa(t,e)};function CI(t,e){Sa(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var Oa=function(){return Oa=Object.assign||function(e){for(var r,i=1,n=arguments.length;i<n;i++){r=arguments[i];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},Oa.apply(this,arguments)};function PI(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(t);n<i.length;n++)e.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(t,i[n])&&(r[i[n]]=t[i[n]]);return r}function BI(t,e,r,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(n<3?o(s):n>3?o(e,r,s):o(e,r))||s);return n>3&&s&&Object.defineProperty(e,r,s),s}function TI(t,e){return function(r,i){e(r,i,t)}}function RI(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function UI(t,e,r,i){function n(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function a(l){try{u(i.next(l))}catch(h){o(h)}}function c(l){try{u(i.throw(l))}catch(h){o(h)}}function u(l){l.done?s(l.value):n(l.value).then(a,c)}u((i=i.apply(t,e||[])).next())})}function NI(t,e){var r={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,n,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(u){return function(l){return c([u,l])}}function c(u){if(i)throw new TypeError("Generator is already executing.");for(;r;)try{if(i=1,n&&(s=u[0]&2?n.return:u[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,u[1])).done)return s;switch(n=0,s&&(u=[u[0]&2,s.value]),u[0]){case 0:case 1:s=u;break;case 4:return r.label++,{value:u[1],done:!1};case 5:r.label++,n=u[1],u=[0];continue;case 7:u=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(u[0]===6||u[0]===2)){r=0;continue}if(u[0]===3&&(!s||u[1]>s[0]&&u[1]<s[3])){r.label=u[1];break}if(u[0]===6&&r.label<s[1]){r.label=s[1],s=u;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(u);break}s[2]&&r.ops.pop(),r.trys.pop();continue}u=e.call(t,r)}catch(l){u=[6,l],n=0}finally{i=s=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}function jI(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}function kI(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function Aa(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],i=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function sg(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var i=r.call(t),n,s=[],o;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(a){o={error:a}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s}function FI(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(sg(arguments[e]));return t}function LI(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var i=Array(t),n=0,e=0;e<r;e++)for(var s=arguments[e],o=0,a=s.length;o<a;o++,n++)i[n]=s[o];return i}function un(t){return this instanceof un?(this.v=t,this):new un(t)}function MI(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=r.apply(t,e||[]),n,s=[];return n={},o("next"),o("throw"),o("return"),n[Symbol.asyncIterator]=function(){return this},n;function o(f){i[f]&&(n[f]=function(g){return new Promise(function(p,y){s.push([f,g,p,y])>1||a(f,g)})})}function a(f,g){try{c(i[f](g))}catch(p){h(s[0][3],p)}}function c(f){f.value instanceof un?Promise.resolve(f.value.v).then(u,l):h(s[0][2],f)}function u(f){a("next",f)}function l(f){a("throw",f)}function h(f,g){f(g),s.shift(),s.length&&a(s[0][0],s[0][1])}}function qI(t){var e,r;return e={},i("next"),i("throw",function(n){throw n}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(n,s){e[n]=t[n]?function(o){return(r=!r)?{value:un(t[n](o)),done:n==="return"}:s?s(o):o}:s}}function zI(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],r;return e?e.call(t):(t=typeof Aa=="function"?Aa(t):t[Symbol.iterator](),r={},i("next"),i("throw"),i("return"),r[Symbol.asyncIterator]=function(){return this},r);function i(s){r[s]=t[s]&&function(o){return new Promise(function(a,c){o=t[s](o),n(a,c,o.done,o.value)})}}function n(s,o,a,c){Promise.resolve(c).then(function(u){s({value:u,done:a})},o)}}function VI(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function HI(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e}function KI(t){return t&&t.__esModule?t:{default:t}}function WI(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function GI(t,e,r){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,r),r}const YI=Object.freeze(Object.defineProperty({__proto__:null,get __assign(){return Oa},__asyncDelegator:qI,__asyncGenerator:MI,__asyncValues:zI,__await:un,__awaiter:UI,__classPrivateFieldGet:WI,__classPrivateFieldSet:GI,__createBinding:jI,__decorate:BI,__exportStar:kI,__extends:CI,__generator:NI,__importDefault:KI,__importStar:HI,__makeTemplateObject:VI,__metadata:RI,__param:TI,__read:sg,__rest:PI,__spread:FI,__spreadArrays:LI,__values:Aa},Symbol.toStringTag,{value:"Module"})),ZI=vf(YI);var Gt={},uh;function JI(){if(uh)return Gt;uh=1,Object.defineProperty(Gt,"__esModule",{value:!0}),Gt.isBrowserCryptoAvailable=Gt.getSubtleCrypto=Gt.getBrowerCrypto=void 0;function t(){return(jt===null||jt===void 0?void 0:jt.crypto)||(jt===null||jt===void 0?void 0:jt.msCrypto)||{}}Gt.getBrowerCrypto=t;function e(){const i=t();return i.subtle||i.webkitSubtle}Gt.getSubtleCrypto=e;function r(){return!!t()&&!!e()}return Gt.isBrowserCryptoAvailable=r,Gt}var Yt={},lh;function XI(){if(lh)return Yt;lh=1,Object.defineProperty(Yt,"__esModule",{value:!0}),Yt.isBrowser=Yt.isNode=Yt.isReactNative=void 0;function t(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}Yt.isReactNative=t;function e(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}Yt.isNode=e;function r(){return!t()&&!e()}return Yt.isBrowser=r,Yt}var hh;function QI(){return hh||(hh=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=ZI;e.__exportStar(JI(),t),e.__exportStar(XI(),t)})(Uo)),Uo}var eS=QI();function Ut(t=3){const e=Date.now()*Math.pow(10,t),r=Math.floor(Math.random()*Math.pow(10,t));return e+r}function _r(t=6){return BigInt(Ut(t))}function St(t,e,r){return{id:r||Ut(),jsonrpc:"2.0",method:t,params:e}}function ln(t,e){return{id:t,jsonrpc:"2.0",result:e}}function Us(t,e,r){return{id:t,jsonrpc:"2.0",error:tS(e)}}function tS(t,e){return typeof t>"u"?ch(rg):(typeof t=="string"&&(t=Object.assign(Object.assign({},ch(Sc)),{message:t})),AI(t.code)&&(t=$I(t.code)),t)}class rS{}class iS extends rS{constructor(){super()}}class nS extends iS{constructor(e){super()}}const sS="^https?:",oS="^wss?:";function aS(t){const e=t.match(new RegExp(/^\w+:/,"gi"));if(!(!e||!e.length))return e[0]}function og(t,e){const r=aS(t);return typeof r>"u"?!1:new RegExp(e).test(r)}function fh(t){return og(t,sS)}function dh(t){return og(t,oS)}function cS(t){return new RegExp("wss?://localhost(:d{2,5})?").test(t)}function ag(t){return typeof t=="object"&&"id"in t&&"jsonrpc"in t&&t.jsonrpc==="2.0"}function Oc(t){return ag(t)&&"method"in t}function Ns(t){return ag(t)&&(Nt(t)||wt(t))}function Nt(t){return"result"in t}function wt(t){return"error"in t}let Ac=class extends nS{constructor(e){super(e),this.events=new ct.EventEmitter,this.hasRegisteredEventListeners=!1,this.connection=this.setConnection(e),this.connection.connected&&this.registerEventListeners()}async connect(e=this.connection){await this.open(e)}async disconnect(){await this.close()}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async request(e,r){return this.requestStrict(St(e.method,e.params||[],e.id||_r().toString()),r)}async requestStrict(e,r){return new Promise(async(i,n)=>{if(!this.connection.connected)try{await this.open()}catch(s){n(s)}this.events.on(`${e.id}`,s=>{wt(s)?n(s.error):i(s.result)});try{await this.connection.send(e,r)}catch(s){n(s)}})}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),Ns(e)?this.events.emit(`${e.id}`,e):this.events.emit("message",{type:e.method,data:e.params})}onClose(e){e&&e.code===3e3&&this.events.emit("error",new Error(`WebSocket connection closed abnormally with code: ${e.code} ${e.reason?`(${e.reason})`:""}`)),this.events.emit("disconnect")}async open(e=this.connection){this.connection===e&&this.connection.connected||(this.connection.connected&&this.close(),typeof e=="string"&&(await this.connection.open(e),e=this.connection),this.connection=this.setConnection(e),await this.connection.open(),this.registerEventListeners(),this.events.emit("connect"))}async close(){await this.connection.close()}registerEventListeners(){this.hasRegisteredEventListeners||(this.connection.on("payload",e=>this.onPayload(e)),this.connection.on("close",e=>this.onClose(e)),this.connection.on("error",e=>this.events.emit("error",e)),this.connection.on("register_error",e=>this.onClose()),this.hasRegisteredEventListeners=!0)}};const uS=()=>typeof WebSocket<"u"?WebSocket:typeof global<"u"&&typeof global.WebSocket<"u"?global.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:typeof self<"u"&&typeof self.WebSocket<"u"?self.WebSocket:require("ws"),lS=()=>typeof WebSocket<"u"||typeof global<"u"&&typeof global.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",ph=t=>t.split("?")[0],gh=10,hS=uS();let fS=class{constructor(e){if(this.url=e,this.events=new ct.EventEmitter,this.registering=!1,!dh(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);this.url=e}get connected(){return typeof this.socket<"u"}get connecting(){return this.registering}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async open(e=this.url){await this.register(e)}async close(){return new Promise((e,r)=>{if(typeof this.socket>"u"){r(new Error("Connection already closed"));return}this.socket.onclose=i=>{this.onClose(i),e()},this.socket.close()})}async send(e){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(or(e))}catch(r){this.onError(e.id,r)}}register(e=this.url){if(!dh(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);if(this.registering){const r=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=r||this.events.listenerCount("open")>=r)&&this.events.setMaxListeners(r+1),new Promise((i,n)=>{this.events.once("register_error",s=>{this.resetMaxListeners(),n(s)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return n(new Error("WebSocket connection is missing or invalid"));i(this.socket)})})}return this.url=e,this.registering=!0,new Promise((r,i)=>{const n=eS.isReactNative()?void 0:{rejectUnauthorized:!cS(e)},s=new hS(e,[],n);lS()?s.onerror=o=>{const a=o;i(this.emitError(a.error))}:s.on("error",o=>{i(this.emitError(o))}),s.onopen=()=>{this.onOpen(s),r(s)}})}onOpen(e){e.onmessage=r=>this.onPayload(r),e.onclose=r=>this.onClose(r),this.socket=e,this.registering=!1,this.events.emit("open")}onClose(e){this.socket=void 0,this.registering=!1,this.events.emit("close",e)}onPayload(e){if(typeof e.data>"u")return;const r=typeof e.data=="string"?Yr(e.data):e.data;this.events.emit("payload",r)}onError(e,r){const i=this.parseError(r),n=i.message||i.toString(),s=Us(e,n);this.events.emit("payload",s)}parseError(e,r=this.url){return ng(e,ph(r),"WS")}resetMaxListeners(){this.events.getMaxListeners()>gh&&this.events.setMaxListeners(gh)}emitError(e){const r=this.parseError(new Error(e?.message||`WebSocket connection failed for host: ${ph(this.url)}`));return this.events.emit("register_error",r),r}};var dS={};const cg="wc",ug=2,$a="core",qt=`${cg}@2:${$a}:`,pS={logger:"error"},gS={database:":memory:"},yS="crypto",yh="client_ed25519_seed",wS=V.ONE_DAY,bS="keychain",mS="0.3",vS="messages",ES="0.3",DS=V.SIX_HOURS,xS="publisher",lg="irn",_S="error",hg="wss://relay.walletconnect.org",IS="relayer",de={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",transport_closed:"relayer_transport_closed",publish:"relayer_publish"},SS="_subscription",ht={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},OS=.1,Ca="2.22.4",ue={link_mode:"link_mode",relay:"relay"},Jn={inbound:"inbound",outbound:"outbound"},AS="0.3",$S="WALLETCONNECT_CLIENT_ID",wh="WALLETCONNECT_LINK_MODE_APPS",it={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},CS="subscription",PS="0.3",BS="pairing",TS="0.3",Li={wc_pairingDelete:{req:{ttl:V.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:V.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:V.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:V.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:V.ONE_DAY,prompt:!1,tag:0},res:{ttl:V.ONE_DAY,prompt:!1,tag:0}}},Lr={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},Dt={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},RS="history",US="0.3",NS="expirer",pt={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},jS="0.3",kS="verify-api",FS="https://verify.walletconnect.com",fg="https://verify.walletconnect.org",Qi=fg,LS=`${Qi}/v3`,MS=[FS,fg],qS="echo",zS="https://echo.walletconnect.com",Rt={pairing_started:"pairing_started",pairing_uri_validation_success:"pairing_uri_validation_success",pairing_uri_not_expired:"pairing_uri_not_expired",store_new_pairing:"store_new_pairing",subscribing_pairing_topic:"subscribing_pairing_topic",subscribe_pairing_topic_success:"subscribe_pairing_topic_success",existing_pairing:"existing_pairing",pairing_not_expired:"pairing_not_expired",emit_inactive_pairing:"emit_inactive_pairing",emit_session_proposal:"emit_session_proposal",subscribing_to_pairing_topic:"subscribing_to_pairing_topic"},Jt={no_wss_connection:"no_wss_connection",no_internet_connection:"no_internet_connection",malformed_pairing_uri:"malformed_pairing_uri",active_pairing_already_exists:"active_pairing_already_exists",subscribe_pairing_topic_failure:"subscribe_pairing_topic_failure",pairing_expired:"pairing_expired",proposal_expired:"proposal_expired",proposal_listener_not_found:"proposal_listener_not_found"},xt={session_approve_started:"session_approve_started",proposal_not_expired:"proposal_not_expired",session_namespaces_validation_success:"session_namespaces_validation_success",create_session_topic:"create_session_topic",subscribing_session_topic:"subscribing_session_topic",subscribe_session_topic_success:"subscribe_session_topic_success",publishing_session_approve:"publishing_session_approve",session_approve_publish_success:"session_approve_publish_success",store_session:"store_session",publishing_session_settle:"publishing_session_settle",session_settle_publish_success:"session_settle_publish_success",session_request_response_started:"session_request_response_started",session_request_response_validation_success:"session_request_response_validation_success",session_request_response_publish_started:"session_request_response_publish_started"},Rr={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",proposal_expired:"proposal_expired",subscribe_session_topic_failure:"subscribe_session_topic_failure",session_approve_publish_failure:"session_approve_publish_failure",session_settle_publish_failure:"session_settle_publish_failure",session_approve_namespace_validation_failure:"session_approve_namespace_validation_failure",proposal_not_found:"proposal_not_found",session_request_response_validation_failure:"session_request_response_validation_failure",session_request_response_publish_failure:"session_request_response_publish_failure"},Ur={authenticated_session_approve_started:"authenticated_session_approve_started",create_authenticated_session_topic:"create_authenticated_session_topic",cacaos_verified:"cacaos_verified",store_authenticated_session:"store_authenticated_session",subscribing_authenticated_session_topic:"subscribing_authenticated_session_topic",subscribe_authenticated_session_topic_success:"subscribe_authenticated_session_topic_success",publishing_authenticated_session_approve:"publishing_authenticated_session_approve"},Mi={no_internet_connection:"no_internet_connection",invalid_cacao:"invalid_cacao",subscribe_authenticated_session_topic_failure:"subscribe_authenticated_session_topic_failure",authenticated_session_approve_publish_failure:"authenticated_session_approve_publish_failure",authenticated_session_pending_request_not_found:"authenticated_session_pending_request_not_found"},VS=.1,HS="event-client",KS=86400,WS="https://pulse.walletconnect.org/batch";function GS(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),i=0;i<r.length;i++)r[i]=255;for(var n=0;n<t.length;n++){var s=t.charAt(n),o=s.charCodeAt(0);if(r[o]!==255)throw new TypeError(s+" is ambiguous");r[o]=n}var a=t.length,c=t.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function h(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var y=0,m=0,x=0,S=p.length;x!==S&&p[x]===0;)x++,y++;for(var v=(S-x)*l+1>>>0,b=new Uint8Array(v);x!==S;){for(var E=p[x],I=0,$=v-1;(E!==0||I<m)&&$!==-1;$--,I++)E+=256*b[$]>>>0,b[$]=E%a>>>0,E=E/a>>>0;if(E!==0)throw new Error("Non-zero carry");m=I,x++}for(var B=v-m;B!==v&&b[B]===0;)B++;for(var C=c.repeat(y);B<v;++B)C+=t.charAt(b[B]);return C}function f(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var y=0;if(p[y]!==" "){for(var m=0,x=0;p[y]===c;)m++,y++;for(var S=(p.length-y)*u+1>>>0,v=new Uint8Array(S);p[y];){var b=r[p.charCodeAt(y)];if(b===255)return;for(var E=0,I=S-1;(b!==0||E<x)&&I!==-1;I--,E++)b+=a*v[I]>>>0,v[I]=b%256>>>0,b=b/256>>>0;if(b!==0)throw new Error("Non-zero carry");x=E,y++}if(p[y]!==" "){for(var $=S-x;$!==S&&v[$]===0;)$++;for(var B=new Uint8Array(m+(S-$)),C=m;$!==S;)B[C++]=v[$++];return B}}}function g(p){var y=f(p);if(y)return y;throw new Error(`Non-${e} character`)}return{encode:h,decodeUnsafe:f,decode:g}}var YS=GS,ZS=YS;const dg=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")},JS=t=>new TextEncoder().encode(t),XS=t=>new TextDecoder().decode(t);class QS{constructor(e,r,i){this.name=e,this.prefix=r,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class eO{constructor(e,r,i){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return pg(this,e)}}class tO{constructor(e){this.decoders=e}or(e){return pg(this,e)}decode(e){const r=e[0],i=this.decoders[r];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const pg=(t,e)=>new tO({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class rO{constructor(e,r,i,n){this.name=e,this.prefix=r,this.baseEncode=i,this.baseDecode=n,this.encoder=new QS(e,r,i),this.decoder=new eO(e,r,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const js=({name:t,prefix:e,encode:r,decode:i})=>new rO(t,e,r,i),Dn=({prefix:t,name:e,alphabet:r})=>{const{encode:i,decode:n}=ZS(r,e);return js({prefix:t,name:e,encode:i,decode:s=>dg(n(s))})},iO=(t,e,r,i)=>{const n={};for(let l=0;l<e.length;++l)n[e[l]]=l;let s=t.length;for(;t[s-1]==="=";)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,u=0;for(let l=0;l<s;++l){const h=n[t[l]];if(h===void 0)throw new SyntaxError(`Non-${i} character`);c=c<<r|h,a+=r,a>=8&&(a-=8,o[u++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},nO=(t,e,r)=>{const i=e[e.length-1]==="=",n=(1<<r)-1;let s="",o=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],o+=8;o>r;)o-=r,s+=e[n&a>>o];if(o&&(s+=e[n&a<<r-o]),i)for(;s.length*r&7;)s+="=";return s},Re=({name:t,prefix:e,bitsPerChar:r,alphabet:i})=>js({prefix:e,name:t,encode(n){return nO(n,i,r)},decode(n){return iO(n,i,r,t)}}),sO=js({prefix:"\0",name:"identity",encode:t=>XS(t),decode:t=>JS(t)});var oO=Object.freeze({__proto__:null,identity:sO});const aO=Re({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var cO=Object.freeze({__proto__:null,base2:aO});const uO=Re({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var lO=Object.freeze({__proto__:null,base8:uO});const hO=Dn({prefix:"9",name:"base10",alphabet:"0123456789"});var fO=Object.freeze({__proto__:null,base10:hO});const dO=Re({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),pO=Re({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var gO=Object.freeze({__proto__:null,base16:dO,base16upper:pO});const yO=Re({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),wO=Re({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),bO=Re({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),mO=Re({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),vO=Re({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),EO=Re({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),DO=Re({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),xO=Re({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),_O=Re({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var IO=Object.freeze({__proto__:null,base32:yO,base32upper:wO,base32pad:bO,base32padupper:mO,base32hex:vO,base32hexupper:EO,base32hexpad:DO,base32hexpadupper:xO,base32z:_O});const SO=Dn({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),OO=Dn({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var AO=Object.freeze({__proto__:null,base36:SO,base36upper:OO});const $O=Dn({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),CO=Dn({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var PO=Object.freeze({__proto__:null,base58btc:$O,base58flickr:CO});const BO=Re({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),TO=Re({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),RO=Re({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),UO=Re({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var NO=Object.freeze({__proto__:null,base64:BO,base64pad:TO,base64url:RO,base64urlpad:UO});const gg=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),jO=gg.reduce((t,e,r)=>(t[r]=e,t),[]),kO=gg.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function FO(t){return t.reduce((e,r)=>(e+=jO[r],e),"")}function LO(t){const e=[];for(const r of t){const i=kO[r.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(i)}return new Uint8Array(e)}const MO=js({prefix:"🚀",name:"base256emoji",encode:FO,decode:LO});var qO=Object.freeze({__proto__:null,base256emoji:MO}),zO=yg,bh=128,VO=-128,HO=Math.pow(2,31);function yg(t,e,r){e=e||[],r=r||0;for(var i=r;t>=HO;)e[r++]=t&255|bh,t/=128;for(;t&VO;)e[r++]=t&255|bh,t>>>=7;return e[r]=t|0,yg.bytes=r-i+1,e}var KO=Pa,WO=128,mh=127;function Pa(t,i){var r=0,i=i||0,n=0,s=i,o,a=t.length;do{if(s>=a)throw Pa.bytes=0,new RangeError("Could not decode varint");o=t[s++],r+=n<28?(o&mh)<<n:(o&mh)*Math.pow(2,n),n+=7}while(o>=WO);return Pa.bytes=s-i,r}var GO=Math.pow(2,7),YO=Math.pow(2,14),ZO=Math.pow(2,21),JO=Math.pow(2,28),XO=Math.pow(2,35),QO=Math.pow(2,42),eA=Math.pow(2,49),tA=Math.pow(2,56),rA=Math.pow(2,63),iA=function(t){return t<GO?1:t<YO?2:t<ZO?3:t<JO?4:t<XO?5:t<QO?6:t<eA?7:t<tA?8:t<rA?9:10},nA={encode:zO,decode:KO,encodingLength:iA},wg=nA;const vh=(t,e,r=0)=>(wg.encode(t,e,r),e),Eh=t=>wg.encodingLength(t),Ba=(t,e)=>{const r=e.byteLength,i=Eh(t),n=i+Eh(r),s=new Uint8Array(n+r);return vh(t,s,0),vh(r,s,i),s.set(e,n),new sA(t,r,e,s)};class sA{constructor(e,r,i,n){this.code=e,this.size=r,this.digest=i,this.bytes=n}}const bg=({name:t,code:e,encode:r})=>new oA(t,e,r);class oA{constructor(e,r,i){this.name=e,this.code=r,this.encode=i}digest(e){if(e instanceof Uint8Array){const r=this.encode(e);return r instanceof Uint8Array?Ba(this.code,r):r.then(i=>Ba(this.code,i))}else throw Error("Unknown type, must be binary type")}}const mg=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),aA=bg({name:"sha2-256",code:18,encode:mg("SHA-256")}),cA=bg({name:"sha2-512",code:19,encode:mg("SHA-512")});var uA=Object.freeze({__proto__:null,sha256:aA,sha512:cA});const vg=0,lA="identity",Eg=dg,hA=t=>Ba(vg,Eg(t)),fA={code:vg,name:lA,encode:Eg,digest:hA};var dA=Object.freeze({__proto__:null,identity:fA});new TextEncoder,new TextDecoder;const Dh={...oO,...cO,...lO,...fO,...gO,...IO,...AO,...PO,...NO,...qO};({...uA,...dA});function Dg(t){return globalThis.Buffer!=null?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t}function pA(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?Dg(globalThis.Buffer.allocUnsafe(t)):new Uint8Array(t)}function xg(t,e,r,i){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:i}}}const xh=xg("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),No=xg("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);const e=pA(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),gA={utf8:xh,"utf-8":xh,hex:Dh.base16,latin1:No,ascii:No,binary:No,...Dh};function yA(t,e="utf8"){const r=gA[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?Dg(globalThis.Buffer.from(t,"utf-8")):r.decoder.decode(`${r.prefix}${t}`)}var wA=Object.defineProperty,bA=(t,e,r)=>e in t?wA(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Bt=(t,e,r)=>bA(t,typeof e!="symbol"?e+"":e,r);class mA{constructor(e,r){this.core=e,this.logger=r,Bt(this,"keychain",new Map),Bt(this,"name",bS),Bt(this,"version",mS),Bt(this,"initialized",!1),Bt(this,"storagePrefix",qt),Bt(this,"init",async()=>{if(!this.initialized){const i=await this.getKeyChain();typeof i<"u"&&(this.keychain=i),this.initialized=!0}}),Bt(this,"has",i=>(this.isInitialized(),this.keychain.has(i))),Bt(this,"set",async(i,n)=>{this.isInitialized(),this.keychain.set(i,n),await this.persist()}),Bt(this,"get",i=>{this.isInitialized();const n=this.keychain.get(i);if(typeof n>"u"){const{message:s}=z("NO_MATCHING_KEY",`${this.name}: ${i}`);throw new Error(s)}return n}),Bt(this,"del",async i=>{this.isInitialized(),this.keychain.delete(i),await this.persist()}),this.core=e,this.logger=ut(r,this.name)}get context(){return Qe(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,ha(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?fa(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=z("NOT_INITIALIZED",this.name);throw new Error(e)}}}var vA=Object.defineProperty,EA=(t,e,r)=>e in t?vA(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,xe=(t,e,r)=>EA(t,typeof e!="symbol"?e+"":e,r);class DA{constructor(e,r,i){this.core=e,this.logger=r,xe(this,"name",yS),xe(this,"keychain"),xe(this,"randomSessionIdentifier",xa()),xe(this,"initialized",!1),xe(this,"clientId"),xe(this,"init",async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)}),xe(this,"hasKeys",n=>(this.isInitialized(),this.keychain.has(n))),xe(this,"getClientId",async()=>{if(this.isInitialized(),this.clientId)return this.clientId;const n=await this.getClientSeed(),s=Hu(n),o=kd(s.publicKey);return this.clientId=o,o}),xe(this,"generateKeyPair",()=>{this.isInitialized();const n=px();return this.setPrivateKey(n.publicKey,n.privateKey)}),xe(this,"signJWT",async n=>{this.isInitialized();const s=await this.getClientSeed(),o=Hu(s),a=this.randomSessionIdentifier;return await Nv(a,n,wS,o)}),xe(this,"generateSharedKey",(n,s,o)=>{this.isInitialized();const a=this.getPrivateKey(n),c=gx(a,s);return this.setSymKey(c,o)}),xe(this,"setSymKey",async(n,s)=>{this.isInitialized();const o=s||Gn(n);return await this.keychain.set(o,n),o}),xe(this,"deleteKeyPair",async n=>{this.isInitialized(),await this.keychain.del(n)}),xe(this,"deleteSymKey",async n=>{this.isInitialized(),await this.keychain.del(n)}),xe(this,"encode",async(n,s,o)=>{this.isInitialized();const a=Yp(o),c=or(s);if(Ll(a))return bx(c,o?.encoding);if(Fl(a)){const f=a.senderPublicKey,g=a.receiverPublicKey;n=await this.generateSharedKey(f,g)}const u=this.getSymKey(n),{type:l,senderPublicKey:h}=a;return yx({type:l,symKey:u,message:c,senderPublicKey:h,encoding:o?.encoding})}),xe(this,"decode",async(n,s,o)=>{this.isInitialized();const a=vx(s,o);if(Ll(a)){const c=mx(s,o?.encoding);return Yr(c)}if(Fl(a)){const c=a.receiverPublicKey,u=a.senderPublicKey;n=await this.generateSharedKey(c,u)}try{const c=this.getSymKey(n),u=wx({symKey:c,encoded:s,encoding:o?.encoding});return Yr(u)}catch(c){this.logger.error(`Failed to decode message from topic: '${n}', clientId: '${await this.getClientId()}'`),this.logger.error(c)}}),xe(this,"getPayloadType",(n,s=Ze)=>{const o=cn({encoded:n,encoding:s});return Jr(o.type)}),xe(this,"getPayloadSenderPublicKey",(n,s=Ze)=>{const o=cn({encoded:n,encoding:s});return o.senderPublicKey?DI(o.senderPublicKey,ze):void 0}),this.core=e,this.logger=ut(r,this.name),this.keychain=i||new mA(this.core,this.logger)}get context(){return Qe(this.logger)}async setPrivateKey(e,r){return await this.keychain.set(e,r),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(yh)}catch{e=xa(),await this.keychain.set(yh,e)}return yA(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=z("NOT_INITIALIZED",this.name);throw new Error(e)}}}var xA=Object.defineProperty,_A=Object.defineProperties,IA=Object.getOwnPropertyDescriptors,_h=Object.getOwnPropertySymbols,SA=Object.prototype.hasOwnProperty,OA=Object.prototype.propertyIsEnumerable,Ta=(t,e,r)=>e in t?xA(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,AA=(t,e)=>{for(var r in e||(e={}))SA.call(e,r)&&Ta(t,r,e[r]);if(_h)for(var r of _h(e))OA.call(e,r)&&Ta(t,r,e[r]);return t},$A=(t,e)=>_A(t,IA(e)),tt=(t,e,r)=>Ta(t,typeof e!="symbol"?e+"":e,r);class CA extends l_{constructor(e,r){super(e,r),this.logger=e,this.core=r,tt(this,"messages",new Map),tt(this,"messagesWithoutClientAck",new Map),tt(this,"name",vS),tt(this,"version",ES),tt(this,"initialized",!1),tt(this,"storagePrefix",qt),tt(this,"init",async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const i=await this.getRelayerMessages();typeof i<"u"&&(this.messages=i);const n=await this.getRelayerMessagesWithoutClientAck();typeof n<"u"&&(this.messagesWithoutClientAck=n),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(i){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(i)}finally{this.initialized=!0}}}),tt(this,"set",async(i,n,s)=>{this.isInitialized();const o=yt(n);let a=this.messages.get(i);if(typeof a>"u"&&(a={}),typeof a[o]<"u")return o;if(a[o]=n,this.messages.set(i,a),s===Jn.inbound){const c=this.messagesWithoutClientAck.get(i)||{};this.messagesWithoutClientAck.set(i,$A(AA({},c),{[o]:n}))}return await this.persist(),o}),tt(this,"get",i=>{this.isInitialized();let n=this.messages.get(i);return typeof n>"u"&&(n={}),n}),tt(this,"getWithoutAck",i=>{this.isInitialized();const n={};for(const s of i){const o=this.messagesWithoutClientAck.get(s)||{};n[s]=Object.values(o)}return n}),tt(this,"has",(i,n)=>{this.isInitialized();const s=this.get(i),o=yt(n);return typeof s[o]<"u"}),tt(this,"ack",async(i,n)=>{this.isInitialized();const s=this.messagesWithoutClientAck.get(i);if(typeof s>"u")return;const o=yt(n);delete s[o],Object.keys(s).length===0?this.messagesWithoutClientAck.delete(i):this.messagesWithoutClientAck.set(i,s),await this.persist()}),tt(this,"del",async i=>{this.isInitialized(),this.messages.delete(i),this.messagesWithoutClientAck.delete(i),await this.persist()}),this.logger=ut(e,this.name),this.core=r}get context(){return Qe(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get storageKeyWithoutClientAck(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name+"_withoutClientAck"}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,ha(e))}async setRelayerMessagesWithoutClientAck(e){await this.core.storage.setItem(this.storageKeyWithoutClientAck,ha(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?fa(e):void 0}async getRelayerMessagesWithoutClientAck(){const e=await this.core.storage.getItem(this.storageKeyWithoutClientAck);return typeof e<"u"?fa(e):void 0}async persist(){await this.setRelayerMessages(this.messages),await this.setRelayerMessagesWithoutClientAck(this.messagesWithoutClientAck)}isInitialized(){if(!this.initialized){const{message:e}=z("NOT_INITIALIZED",this.name);throw new Error(e)}}}var PA=Object.defineProperty,BA=Object.defineProperties,TA=Object.getOwnPropertyDescriptors,Ih=Object.getOwnPropertySymbols,RA=Object.prototype.hasOwnProperty,UA=Object.prototype.propertyIsEnumerable,Ra=(t,e,r)=>e in t?PA(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ci=(t,e)=>{for(var r in e||(e={}))RA.call(e,r)&&Ra(t,r,e[r]);if(Ih)for(var r of Ih(e))UA.call(e,r)&&Ra(t,r,e[r]);return t},Sh=(t,e)=>BA(t,TA(e)),ft=(t,e,r)=>Ra(t,typeof e!="symbol"?e+"":e,r);class NA extends h_{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,ft(this,"events",new ct.EventEmitter),ft(this,"name",xS),ft(this,"queue",new Map),ft(this,"publishTimeout",V.toMiliseconds(V.ONE_MINUTE)),ft(this,"initialPublishTimeout",V.toMiliseconds(V.ONE_SECOND*15)),ft(this,"needsTransportRestart",!1),ft(this,"publish",async(i,n,s)=>{var o,a,c,u,l;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:i,message:n,opts:s}});const h=s?.ttl||DS,f=s?.prompt||!1,g=s?.tag||0,p=s?.id||_r().toString(),y=pi(ds().protocol),m={id:p,method:s?.publishMethod||y.publish,params:ci({topic:i,message:n,ttl:h,prompt:f,tag:g,attestation:s?.attestation},s?.tvf)},x=`Failed to publish payload, please try again. id:${p} tag:${g}`;try{Ee((o=m.params)==null?void 0:o.prompt)&&((a=m.params)==null||delete a.prompt),Ee((c=m.params)==null?void 0:c.tag)&&((u=m.params)==null||delete u.tag);const S=new Promise(async v=>{const b=({id:I})=>{var $;(($=m.id)==null?void 0:$.toString())===I.toString()&&(this.removeRequestFromQueue(I),this.relayer.events.removeListener(de.publish,b),v())};this.relayer.events.on(de.publish,b);const E=Ft(new Promise((I,$)=>{this.rpcPublish(m,s).then(I).catch(B=>{this.logger.warn(B,B?.message),$(B)})}),this.initialPublishTimeout,`Failed initial publish, retrying.... id:${p} tag:${g}`);try{await E,this.events.removeListener(de.publish,b)}catch(I){this.queue.set(p,{request:m,opts:s,attempt:1}),this.logger.warn(I,I?.message)}});this.logger.trace({type:"method",method:"publish",params:{id:p,topic:i,message:n,opts:s}}),await Ft(S,this.publishTimeout,x)}catch(S){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(S),(l=s?.internal)!=null&&l.throwOnFailedPublish)throw S}finally{this.queue.delete(p)}}),ft(this,"publishCustom",async i=>{var n,s,o,a,c;this.logger.debug("Publishing custom payload"),this.logger.trace({type:"method",method:"publishCustom",params:i});const{payload:u,opts:l={}}=i,{attestation:h,tvf:f,publishMethod:g,prompt:p,tag:y,ttl:m=V.FIVE_MINUTES}=l,x=l.id||_r().toString(),S=pi(ds().protocol),v=g||S.publish,b={id:x,method:v,params:ci(Sh(ci({},u),{ttl:m,prompt:p,tag:y,attestation:h}),f)},E=`Failed to publish custom payload, please try again. id:${x} tag:${y}`;try{Ee((n=b.params)==null?void 0:n.prompt)&&((s=b.params)==null||delete s.prompt),Ee((o=b.params)==null?void 0:o.tag)&&((a=b.params)==null||delete a.tag);const I=new Promise(async $=>{const B=({id:k})=>{var F;((F=b.id)==null?void 0:F.toString())===k.toString()&&(this.removeRequestFromQueue(k),this.relayer.events.removeListener(de.publish,B),$())};this.relayer.events.on(de.publish,B);const C=Ft(new Promise((k,F)=>{this.rpcPublish(b,l).then(k).catch(R=>{this.logger.warn(R,R?.message),F(R)})}),this.initialPublishTimeout,`Failed initial custom payload publish, retrying.... method:${v} id:${x} tag:${y}`);try{await C,this.events.removeListener(de.publish,B)}catch(k){this.queue.set(x,{request:b,opts:l,attempt:1}),this.logger.warn(k,k?.message)}});this.logger.trace({type:"method",method:"publish",params:{id:x,payload:u,opts:l}}),await Ft(I,this.publishTimeout,E)}catch(I){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(I),(c=l?.internal)!=null&&c.throwOnFailedPublish)throw I}finally{this.queue.delete(x)}}),ft(this,"on",(i,n)=>{this.events.on(i,n)}),ft(this,"once",(i,n)=>{this.events.once(i,n)}),ft(this,"off",(i,n)=>{this.events.off(i,n)}),ft(this,"removeListener",(i,n)=>{this.events.removeListener(i,n)}),this.relayer=e,this.logger=ut(r,this.name),this.registerEventListeners()}get context(){return Qe(this.logger)}async rpcPublish(e,r){this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:e});const i=await this.relayer.request(e);return this.relayer.events.emit(de.publish,ci(ci({},e),r)),this.logger.debug("Successfully Published Payload"),i}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async(e,r)=>{var i;const n=e.attempt+1;this.queue.set(r,Sh(ci({},e),{attempt:n})),this.logger.warn({},`Publisher: queue->publishing: ${e.request.id}, tag: ${(i=e.request.params)==null?void 0:i.tag}, attempt: ${n}`),await this.rpcPublish(e.request,e.opts),this.logger.warn({},`Publisher: queue->published: ${e.request.id}`)})}registerEventListeners(){this.relayer.core.heartbeat.on(ei.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(de.connection_stalled);return}this.checkQueue()}),this.relayer.on(de.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}}var jA=Object.defineProperty,kA=(t,e,r)=>e in t?jA(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ui=(t,e,r)=>kA(t,typeof e!="symbol"?e+"":e,r);class FA{constructor(){ui(this,"map",new Map),ui(this,"set",(e,r)=>{const i=this.get(e);this.exists(e,r)||this.map.set(e,[...i,r])}),ui(this,"get",e=>this.map.get(e)||[]),ui(this,"exists",(e,r)=>this.get(e).includes(r)),ui(this,"delete",(e,r)=>{if(typeof r>"u"){this.map.delete(e);return}if(!this.map.has(e))return;const i=this.get(e);if(!this.exists(e,r))return;const n=i.filter(s=>s!==r);if(!n.length){this.map.delete(e);return}this.map.set(e,n)}),ui(this,"clear",()=>{this.map.clear()})}get topics(){return Array.from(this.map.keys())}}var LA=Object.defineProperty,MA=Object.defineProperties,qA=Object.getOwnPropertyDescriptors,Oh=Object.getOwnPropertySymbols,zA=Object.prototype.hasOwnProperty,VA=Object.prototype.propertyIsEnumerable,Ua=(t,e,r)=>e in t?LA(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,qi=(t,e)=>{for(var r in e||(e={}))zA.call(e,r)&&Ua(t,r,e[r]);if(Oh)for(var r of Oh(e))VA.call(e,r)&&Ua(t,r,e[r]);return t},jo=(t,e)=>MA(t,qA(e)),oe=(t,e,r)=>Ua(t,typeof e!="symbol"?e+"":e,r);class HA extends p_{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,oe(this,"subscriptions",new Map),oe(this,"topicMap",new FA),oe(this,"events",new ct.EventEmitter),oe(this,"name",CS),oe(this,"version",PS),oe(this,"pending",new Map),oe(this,"cached",[]),oe(this,"initialized",!1),oe(this,"storagePrefix",qt),oe(this,"subscribeTimeout",V.toMiliseconds(V.ONE_MINUTE)),oe(this,"initialSubscribeTimeout",V.toMiliseconds(V.ONE_SECOND*15)),oe(this,"clientId"),oe(this,"batchSubscribeTopicsLimit",500),oe(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),await this.restore()),this.initialized=!0}),oe(this,"subscribe",async(i,n)=>{var s;this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:n}});try{const o=ds(n),a={topic:i,relay:o,transportType:n?.transportType};(s=n?.internal)!=null&&s.skipSubscribe||this.pending.set(i,a);const c=await this.rpcSubscribe(i,o,n);return typeof c=="string"&&(this.onSubscribe(c,a),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:n}})),c}catch(o){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(o),o}}),oe(this,"unsubscribe",async(i,n)=>{this.isInitialized(),typeof n?.id<"u"?await this.unsubscribeById(i,n.id,n):await this.unsubscribeByTopic(i,n)}),oe(this,"isSubscribed",i=>new Promise(n=>{n(this.topicMap.topics.includes(i))})),oe(this,"isKnownTopic",i=>new Promise(n=>{n(this.topicMap.topics.includes(i)||this.pending.has(i)||this.cached.some(s=>s.topic===i))})),oe(this,"on",(i,n)=>{this.events.on(i,n)}),oe(this,"once",(i,n)=>{this.events.once(i,n)}),oe(this,"off",(i,n)=>{this.events.off(i,n)}),oe(this,"removeListener",(i,n)=>{this.events.removeListener(i,n)}),oe(this,"start",async()=>{await this.onConnect()}),oe(this,"stop",async()=>{await this.onDisconnect()}),oe(this,"restart",async()=>{await this.restore(),await this.onRestart()}),oe(this,"checkPending",async()=>{if(this.pending.size===0&&(!this.initialized||!this.relayer.connected))return;const i=[];this.pending.forEach(n=>{i.push(n)}),await this.batchSubscribe(i)}),oe(this,"registerEventListeners",()=>{this.relayer.core.heartbeat.on(ei.pulse,async()=>{await this.checkPending()}),this.events.on(it.created,async i=>{const n=it.created;this.logger.info(`Emitting ${n}`),this.logger.debug({type:"event",event:n,data:i}),await this.persist()}),this.events.on(it.deleted,async i=>{const n=it.deleted;this.logger.info(`Emitting ${n}`),this.logger.debug({type:"event",event:n,data:i}),await this.persist()})}),this.relayer=e,this.logger=ut(r,this.name),this.clientId=""}get context(){return Qe(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}get hasAnyTopics(){return this.topicMap.topics.length>0||this.pending.size>0||this.cached.length>0||this.subscriptions.size>0}hasSubscription(e,r){let i=!1;try{i=this.getSubscription(e).topic===r}catch{}return i}reset(){this.cached=[],this.initialized=!0}onDisable(){this.values.length>0&&(this.cached=this.values),this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,r){const i=this.topicMap.get(e);await Promise.all(i.map(async n=>await this.unsubscribeById(e,n,r)))}async unsubscribeById(e,r,i){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:r,opts:i}});try{const n=ds(i);await this.restartToComplete({topic:e,id:r,relay:n}),await this.rpcUnsubscribe(e,r,n);const s=le("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,r,s),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:r,opts:i}})}catch(n){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(n),n}}async rpcSubscribe(e,r,i){var n,s;const o=await this.getSubscriptionId(e);if((n=i?.internal)!=null&&n.skipSubscribe)return o;(!i||i?.transportType===ue.relay)&&await this.restartToComplete({topic:e,id:e,relay:r});const a={method:pi(r.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:a});const c=(s=i?.internal)==null?void 0:s.throwOnFailedPublish;try{if(i?.transportType===ue.link_mode)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(a).catch(h=>this.logger.warn(h))},V.toMiliseconds(V.ONE_SECOND)),o;const u=new Promise(async h=>{const f=g=>{g.topic===e&&(this.events.removeListener(it.created,f),h(g.id))};this.events.on(it.created,f);try{const g=await Ft(new Promise((p,y)=>{this.relayer.request(a).catch(m=>{this.logger.warn(m,m?.message),y(m)}).then(p)}),this.initialSubscribeTimeout,`Subscribing to ${e} failed, please try again`);this.events.removeListener(it.created,f),h(g)}catch{}}),l=await Ft(u,this.subscribeTimeout,`Subscribing to ${e} failed, please try again`);if(!l&&c)throw new Error(`Subscribing to ${e} failed, please try again`);return l?o:null}catch(u){if(this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(de.connection_stalled),c)throw u}return null}async rpcBatchSubscribe(e){if(!e.length)return;const r=e[0].relay,i={method:pi(r.protocol).batchSubscribe,params:{topics:e.map(n=>n.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});try{await await Ft(new Promise(n=>{this.relayer.request(i).catch(s=>this.logger.warn(s)).then(n)}),this.subscribeTimeout,"rpcBatchSubscribe failed, please try again")}catch{this.relayer.events.emit(de.connection_stalled)}}async rpcBatchFetchMessages(e){if(!e.length)return;const r=e[0].relay,i={method:pi(r.protocol).batchFetchMessages,params:{topics:e.map(s=>s.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});let n;try{n=await await Ft(new Promise((s,o)=>{this.relayer.request(i).catch(a=>{this.logger.warn(a),o(a)}).then(s)}),this.subscribeTimeout,"rpcBatchFetchMessages failed, please try again")}catch{this.relayer.events.emit(de.connection_stalled)}return n}rpcUnsubscribe(e,r,i){const n={method:pi(i.protocol).unsubscribe,params:{topic:e,id:r}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n}),this.relayer.request(n)}onSubscribe(e,r){this.setSubscription(e,jo(qi({},r),{id:e})),this.pending.delete(r.topic)}onBatchSubscribe(e){e.length&&e.forEach(r=>{this.setSubscription(r.id,qi({},r)),this.pending.delete(r.topic)})}async onUnsubscribe(e,r,i){this.events.removeAllListeners(r),this.hasSubscription(r,e)&&this.deleteSubscription(r,i),await this.relayer.messages.del(e)}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,r){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:r}),this.addSubscription(e,r)}addSubscription(e,r){this.subscriptions.set(e,qi({},r)),this.topicMap.set(r.topic,e),this.events.emit(it.created,r)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});const r=this.subscriptions.get(e);if(!r){const{message:i}=z("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return r}deleteSubscription(e,r){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:r});const i=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(i.topic,e),this.events.emit(it.deleted,jo(qi({},i),{reason:r}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(it.sync)}async onRestart(){if(this.cached.length){const e=[...this.cached],r=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let i=0;i<r;i++){const n=e.splice(0,this.batchSubscribeTopicsLimit);await this.batchSubscribe(n)}}this.events.emit(it.resubscribed)}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size&&!e.every(r=>{var i;return r.topic===((i=this.subscriptions.get(r.id))==null?void 0:i.topic)})){const{message:r}=z("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(e){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(e)}}async batchSubscribe(e){e.length&&(await this.rpcBatchSubscribe(e),this.onBatchSubscribe(await Promise.all(e.map(async r=>jo(qi({},r),{id:await this.getSubscriptionId(r.topic)})))))}async batchFetchMessages(e){if(!e.length)return;this.logger.trace(`Fetching batch messages for ${e.length} subscriptions`);const r=await this.rpcBatchFetchMessages(e);r&&r.messages&&(await NE(V.toMiliseconds(V.ONE_SECOND)),await this.relayer.handleBatchMessageEvents(r.messages))}async onConnect(){await this.restart(),this.reset()}onDisconnect(){this.onDisable()}isInitialized(){if(!this.initialized){const{message:e}=z("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(e){!this.relayer.connected&&!this.relayer.connecting&&(this.cached.push(e),await this.relayer.transportOpen())}async getClientId(){return this.clientId||(this.clientId=await this.relayer.core.crypto.getClientId()),this.clientId}async getSubscriptionId(e){return yt(e+await this.getClientId())}}var KA=Object.defineProperty,Ah=Object.getOwnPropertySymbols,WA=Object.prototype.hasOwnProperty,GA=Object.prototype.propertyIsEnumerable,Na=(t,e,r)=>e in t?KA(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,$h=(t,e)=>{for(var r in e||(e={}))WA.call(e,r)&&Na(t,r,e[r]);if(Ah)for(var r of Ah(e))GA.call(e,r)&&Na(t,r,e[r]);return t},re=(t,e,r)=>Na(t,typeof e!="symbol"?e+"":e,r);class YA extends f_{constructor(e){var r;super(e),re(this,"protocol","wc"),re(this,"version",2),re(this,"core"),re(this,"logger"),re(this,"events",new ct.EventEmitter),re(this,"provider"),re(this,"messages"),re(this,"subscriber"),re(this,"publisher"),re(this,"name",IS),re(this,"transportExplicitlyClosed",!1),re(this,"initialized",!1),re(this,"connectionAttemptInProgress",!1),re(this,"relayUrl"),re(this,"projectId"),re(this,"packageName"),re(this,"bundleId"),re(this,"hasExperiencedNetworkDisruption",!1),re(this,"pingTimeout"),re(this,"heartBeatTimeout",V.toMiliseconds(V.THIRTY_SECONDS+V.FIVE_SECONDS)),re(this,"reconnectTimeout"),re(this,"connectPromise"),re(this,"reconnectInProgress",!1),re(this,"requestsInFlight",[]),re(this,"connectTimeout",V.toMiliseconds(V.ONE_SECOND*15)),re(this,"request",async i=>{var n,s;this.logger.debug("Publishing Request Payload");const o=i.id||_r().toString();await this.toEstablishConnection();try{this.logger.trace({id:o,method:i.method,topic:(n=i.params)==null?void 0:n.topic},"relayer.request - publishing...");const a=`${o}:${((s=i.params)==null?void 0:s.tag)||""}`;this.requestsInFlight.push(a);const c=await this.provider.request(i);return this.requestsInFlight=this.requestsInFlight.filter(u=>u!==a),c}catch(a){throw this.logger.debug(`Failed to Publish Request: ${o}`),a}}),re(this,"resetPingTimeout",()=>{as()&&(clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var i,n,s,o;try{this.logger.debug({},"pingTimeout: Connection stalled, terminating..."),(o=(s=(n=(i=this.provider)==null?void 0:i.connection)==null?void 0:n.socket)==null?void 0:s.terminate)==null||o.call(s)}catch(a){this.logger.warn(a,a?.message)}},this.heartBeatTimeout))}),re(this,"onPayloadHandler",i=>{this.onProviderPayload(i),this.resetPingTimeout()}),re(this,"onConnectHandler",()=>{this.logger.warn({},"Relayer connected 🛜"),this.startPingTimeout(),this.events.emit(de.connect)}),re(this,"onDisconnectHandler",()=>{this.logger.warn({},"Relayer disconnected 🛑"),this.requestsInFlight=[],this.onProviderDisconnect()}),re(this,"onProviderErrorHandler",i=>{this.logger.fatal(`Fatal socket error: ${i.message}`),this.events.emit(de.error,i),this.logger.fatal("Fatal socket error received, closing transport"),this.transportClose()}),re(this,"registerProviderListeners",()=>{this.provider.on(ht.payload,this.onPayloadHandler),this.provider.on(ht.connect,this.onConnectHandler),this.provider.on(ht.disconnect,this.onDisconnectHandler),this.provider.on(ht.error,this.onProviderErrorHandler)}),this.core=e.core,this.logger=Ic({logger:(r=e.logger)!=null?r:_S,name:this.name}),this.messages=new CA(this.logger,e.core),this.subscriber=new HA(this,this.logger),this.publisher=new NA(this,this.logger),this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||hg,vE()?this.packageName=al():EE()&&(this.bundleId=al()),this.provider={}}async init(){this.logger.trace("Initialized"),this.registerEventListeners(),await Promise.all([this.messages.init(),this.subscriber.init()]),this.initialized=!0,this.transportOpen().catch(e=>this.logger.warn(e,e?.message))}get context(){return Qe(this.logger)}get connected(){var e,r,i;return((i=(r=(e=this.provider)==null?void 0:e.connection)==null?void 0:r.socket)==null?void 0:i.readyState)===1||!1}get connecting(){var e,r,i;return((i=(r=(e=this.provider)==null?void 0:e.connection)==null?void 0:r.socket)==null?void 0:i.readyState)===0||this.connectPromise!==void 0||!1}async publish(e,r,i){this.isInitialized(),await this.publisher.publish(e,r,i),await this.recordMessageEvent({topic:e,message:r,publishedAt:Date.now(),transportType:ue.relay},Jn.outbound)}async publishCustom(e){this.isInitialized(),await this.publisher.publishCustom(e)}async subscribe(e,r){var i,n,s;this.isInitialized(),(!(r!=null&&r.transportType)||r?.transportType==="relay")&&await this.toEstablishConnection();const o=typeof((i=r?.internal)==null?void 0:i.throwOnFailedPublish)>"u"?!0:(n=r?.internal)==null?void 0:n.throwOnFailedPublish;let a=((s=this.subscriber.topicMap.get(e))==null?void 0:s[0])||"",c;const u=l=>{l.topic===e&&(this.subscriber.off(it.created,u),c())};return await Promise.all([new Promise(l=>{c=l,this.subscriber.on(it.created,u)}),new Promise(async(l,h)=>{a=await this.subscriber.subscribe(e,$h({internal:{throwOnFailedPublish:o}},r)).catch(f=>{o&&h(f)})||a,l()})]),a}async unsubscribe(e,r){this.isInitialized(),await this.subscriber.unsubscribe(e,r)}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async transportDisconnect(){this.provider.disconnect&&(this.hasExperiencedNetworkDisruption||this.connected)?await Ft(this.provider.disconnect(),2e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.onProviderDisconnect()}async transportClose(){this.transportExplicitlyClosed=!0,await this.transportDisconnect()}async transportOpen(e){if(!this.subscriber.hasAnyTopics){this.logger.info("Starting WS connection skipped because the client has no topics to work with.");return}if(this.connectPromise?(this.logger.debug({},"Waiting for existing connection attempt to resolve..."),await this.connectPromise,this.logger.debug({},"Existing connection attempt resolved")):(this.connectPromise=new Promise(async(r,i)=>{await this.connect(e).then(r).catch(i).finally(()=>{this.connectPromise=void 0})}),await this.connectPromise),!this.connected)throw new Error(`Couldn't establish socket connection to the relay server: ${this.relayUrl}`)}async restartTransport(e){this.logger.debug({},"Restarting transport..."),!this.connectionAttemptInProgress&&(this.relayUrl=e||this.relayUrl,await this.confirmOnlineStateOrThrow(),await this.transportClose(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await Ql())throw new Error("No internet connection detected. Please restart your network and try again.")}async handleBatchMessageEvents(e){if(e?.length===0){this.logger.trace("Batch message events is empty. Ignoring...");return}const r=e.sort((i,n)=>i.publishedAt-n.publishedAt);this.logger.debug(`Batch of ${r.length} message events sorted`);for(const i of r)try{await this.onMessageEvent(i)}catch(n){this.logger.warn(n,"Error while processing batch message event: "+n?.message)}this.logger.trace(`Batch of ${r.length} message events processed`)}async onLinkMessageEvent(e,r){const{topic:i}=e;if(!r.sessionExists){const n=we(V.FIVE_MINUTES),s={topic:i,expiry:n,relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(i,s)}this.events.emit(de.message,e),await this.recordMessageEvent(e,Jn.inbound)}async connect(e){await this.confirmOnlineStateOrThrow(),e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportDisconnect()),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;let r=1;for(;r<6;){try{if(this.transportExplicitlyClosed)break;this.logger.debug({},`Connecting to ${this.relayUrl}, attempt: ${r}...`),await this.createProvider(),await new Promise(async(i,n)=>{const s=()=>{n(new Error("Connection interrupted while trying to connect"))};this.provider.once(ht.disconnect,s),await Ft(new Promise((o,a)=>{this.provider.connect().then(o).catch(a)}),this.connectTimeout,`Socket stalled when trying to connect to ${this.relayUrl}`).catch(o=>{n(o)}).finally(()=>{this.provider.off(ht.disconnect,s),clearTimeout(this.reconnectTimeout)}),await new Promise(async(o,a)=>{const c=()=>{n(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(ht.disconnect,c),await this.subscriber.start().then(o).catch(a).finally(()=>{this.provider.off(ht.disconnect,c)})}),this.hasExperiencedNetworkDisruption=!1,i()})}catch(i){await this.subscriber.stop();const n=i;this.logger.warn({},n.message),this.hasExperiencedNetworkDisruption=!0}finally{this.connectionAttemptInProgress=!1}if(this.connected){this.logger.debug({},`Connected to ${this.relayUrl} successfully on attempt: ${r}`);break}await new Promise(i=>setTimeout(i,V.toMiliseconds(r*1))),r++}}startPingTimeout(){var e,r,i,n,s;if(as())try{(r=(e=this.provider)==null?void 0:e.connection)!=null&&r.socket&&((s=(n=(i=this.provider)==null?void 0:i.connection)==null?void 0:n.socket)==null||s.on("ping",()=>{this.resetPingTimeout()})),this.resetPingTimeout()}catch(o){this.logger.warn(o,o?.message)}}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();const e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new Ac(new fS(SE({sdkVersion:Ca,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0,bundleId:this.bundleId,packageName:this.packageName}))),this.registerProviderListeners()}async recordMessageEvent(e,r){const{topic:i,message:n}=e;await this.messages.set(i,n,r)}async shouldIgnoreMessageEvent(e){const{topic:r,message:i}=e;if(!i||i.length===0)return this.logger.warn(`Ignoring invalid/empty message: ${i}`),!0;if(!await this.subscriber.isKnownTopic(r))return this.logger.warn(`Ignoring message for unknown topic ${r}`),!0;const n=this.messages.has(r,i);return n&&this.logger.warn(`Ignoring duplicate message: ${i}`),n}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),Oc(e)){if(!e.method.endsWith(SS))return;const r=e.params,{topic:i,message:n,publishedAt:s,attestation:o}=r.data,a={topic:i,message:n,publishedAt:s,transportType:ue.relay,attestation:o};this.logger.debug("Emitting Relayer Payload"),this.logger.trace($h({type:"event",event:r.id},a)),this.events.emit(r.id,a),await this.acknowledgePayload(e),await this.onMessageEvent(a)}else Ns(e)&&this.events.emit(de.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(await this.recordMessageEvent(e,Jn.inbound),this.events.emit(de.message,e))}async acknowledgePayload(e){const r=ln(e.id,!0);await this.provider.connection.send(r)}unregisterProviderListeners(){this.provider.off(ht.payload,this.onPayloadHandler),this.provider.off(ht.connect,this.onConnectHandler),this.provider.off(ht.disconnect,this.onDisconnectHandler),this.provider.off(ht.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await Ql();m8(async r=>{e!==r&&(e=r,r?await this.transportOpen().catch(i=>this.logger.error(i,i?.message)):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))}),this.core.heartbeat.on(ei.pulse,async()=>{if(!this.transportExplicitlyClosed&&!this.connected&&D8())try{await this.confirmOnlineStateOrThrow(),await this.transportOpen()}catch(r){this.logger.warn(r,r?.message)}})}async onProviderDisconnect(){clearTimeout(this.pingTimeout),this.events.emit(de.disconnect),this.connectionAttemptInProgress=!1,!this.reconnectInProgress&&(this.reconnectInProgress=!0,await this.subscriber.stop(),this.subscriber.hasAnyTopics&&(this.transportExplicitlyClosed||(this.reconnectTimeout=setTimeout(async()=>{await this.transportOpen().catch(e=>this.logger.error(e,e?.message)),this.reconnectTimeout=void 0,this.reconnectInProgress=!1},V.toMiliseconds(OS)))))}isInitialized(){if(!this.initialized){const{message:e}=z("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){if(await this.confirmOnlineStateOrThrow(),!this.connected){if(this.connectPromise){await this.connectPromise;return}await this.connect()}}}function ZA(t,e){return t===e||Number.isNaN(t)&&Number.isNaN(e)}function Ch(t){return Object.getOwnPropertySymbols(t).filter(e=>Object.prototype.propertyIsEnumerable.call(t,e))}function Ph(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const JA="[object RegExp]",XA="[object String]",QA="[object Number]",e$="[object Boolean]",Bh="[object Arguments]",t$="[object Symbol]",r$="[object Date]",i$="[object Map]",n$="[object Set]",s$="[object Array]",o$="[object Function]",a$="[object ArrayBuffer]",ko="[object Object]",c$="[object Error]",u$="[object DataView]",l$="[object Uint8Array]",h$="[object Uint8ClampedArray]",f$="[object Uint16Array]",d$="[object Uint32Array]",p$="[object BigUint64Array]",g$="[object Int8Array]",y$="[object Int16Array]",w$="[object Int32Array]",b$="[object BigInt64Array]",m$="[object Float32Array]",v$="[object Float64Array]";function E$(){}function Th(t){if(!t||typeof t!="object")return!1;const e=Object.getPrototypeOf(t);return e===null||e===Object.prototype||Object.getPrototypeOf(e)===null?Object.prototype.toString.call(t)==="[object Object]":!1}function D$(t,e,r){return Gi(t,e,void 0,void 0,void 0,void 0,r)}function Gi(t,e,r,i,n,s,o){const a=o(t,e,r,i,n,s);if(a!==void 0)return a;if(typeof t==typeof e)switch(typeof t){case"bigint":case"string":case"boolean":case"symbol":case"undefined":return t===e;case"number":return t===e||Object.is(t,e);case"function":return t===e;case"object":return en(t,e,s,o)}return en(t,e,s,o)}function en(t,e,r,i){if(Object.is(t,e))return!0;let n=Ph(t),s=Ph(e);if(n===Bh&&(n=ko),s===Bh&&(s=ko),n!==s)return!1;switch(n){case XA:return t.toString()===e.toString();case QA:{const c=t.valueOf(),u=e.valueOf();return ZA(c,u)}case e$:case r$:case t$:return Object.is(t.valueOf(),e.valueOf());case JA:return t.source===e.source&&t.flags===e.flags;case o$:return t===e}r=r??new Map;const o=r.get(t),a=r.get(e);if(o!=null&&a!=null)return o===e;r.set(t,e),r.set(e,t);try{switch(n){case i$:{if(t.size!==e.size)return!1;for(const[c,u]of t.entries())if(!e.has(c)||!Gi(u,e.get(c),c,t,e,r,i))return!1;return!0}case n$:{if(t.size!==e.size)return!1;const c=Array.from(t.values()),u=Array.from(e.values());for(let l=0;l<c.length;l++){const h=c[l],f=u.findIndex(g=>Gi(h,g,void 0,t,e,r,i));if(f===-1)return!1;u.splice(f,1)}return!0}case s$:case l$:case h$:case f$:case d$:case p$:case g$:case y$:case w$:case b$:case m$:case v$:{if(typeof Buffer<"u"&&Buffer.isBuffer(t)!==Buffer.isBuffer(e)||t.length!==e.length)return!1;for(let c=0;c<t.length;c++)if(!Gi(t[c],e[c],c,t,e,r,i))return!1;return!0}case a$:return t.byteLength!==e.byteLength?!1:en(new Uint8Array(t),new Uint8Array(e),r,i);case u$:return t.byteLength!==e.byteLength||t.byteOffset!==e.byteOffset?!1:en(new Uint8Array(t),new Uint8Array(e),r,i);case c$:return t.name===e.name&&t.message===e.message;case ko:{if(!(en(t.constructor,e.constructor,r,i)||Th(t)&&Th(e)))return!1;const c=[...Object.keys(t),...Ch(t)],u=[...Object.keys(e),...Ch(e)];if(c.length!==u.length)return!1;for(let l=0;l<c.length;l++){const h=c[l],f=t[h];if(!Object.hasOwn(e,h))return!1;const g=e[h];if(!Gi(f,g,h,t,e,r,i))return!1}return!0}default:return!1}}finally{r.delete(t),r.delete(e)}}function x$(t,e){return D$(t,e,E$)}var _$=Object.defineProperty,Rh=Object.getOwnPropertySymbols,I$=Object.prototype.hasOwnProperty,S$=Object.prototype.propertyIsEnumerable,ja=(t,e,r)=>e in t?_$(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Uh=(t,e)=>{for(var r in e||(e={}))I$.call(e,r)&&ja(t,r,e[r]);if(Rh)for(var r of Rh(e))S$.call(e,r)&&ja(t,r,e[r]);return t},He=(t,e,r)=>ja(t,typeof e!="symbol"?e+"":e,r);class ti extends d_{constructor(e,r,i,n=qt,s=void 0){super(e,r,i,n),this.core=e,this.logger=r,this.name=i,He(this,"map",new Map),He(this,"version",AS),He(this,"cached",[]),He(this,"initialized",!1),He(this,"getKey"),He(this,"storagePrefix",qt),He(this,"recentlyDeleted",[]),He(this,"recentlyDeletedLimit",200),He(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(o=>{this.getKey&&o!==null&&!Ee(o)?this.map.set(this.getKey(o),o):Zx(o)?this.map.set(o.id,o):Jx(o)&&this.map.set(o.topic,o)}),this.cached=[],this.initialized=!0)}),He(this,"set",async(o,a)=>{this.isInitialized(),this.map.has(o)?await this.update(o,a):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:o,value:a}),this.map.set(o,a),await this.persist())}),He(this,"get",o=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:o}),this.getData(o))),He(this,"getAll",o=>(this.isInitialized(),o?this.values.filter(a=>Object.keys(o).every(c=>x$(a[c],o[c]))):this.values)),He(this,"update",async(o,a)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:o,update:a});const c=Uh(Uh({},this.getData(o)),a);this.map.set(o,c),await this.persist()}),He(this,"delete",async(o,a)=>{this.isInitialized(),this.map.has(o)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:o,reason:a}),this.map.delete(o),this.addToRecentlyDeleted(o),await this.persist())}),this.logger=ut(r,this.name),this.storagePrefix=n,this.getKey=s}get context(){return Qe(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}addToRecentlyDeleted(e){this.recentlyDeleted.push(e),this.recentlyDeleted.length>=this.recentlyDeletedLimit&&this.recentlyDeleted.splice(0,this.recentlyDeletedLimit/2)}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){const r=this.map.get(e);if(!r){if(this.recentlyDeleted.includes(e)){const{message:n}=z("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(n),new Error(n)}const{message:i}=z("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(i),new Error(i)}return r}async persist(){await this.setDataStore(this.values)}async restore(){try{const e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){const{message:r}=z("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(e){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(e)}}isInitialized(){if(!this.initialized){const{message:e}=z("NOT_INITIALIZED",this.name);throw new Error(e)}}}var O$=Object.defineProperty,A$=(t,e,r)=>e in t?O$(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,X=(t,e,r)=>A$(t,typeof e!="symbol"?e+"":e,r);class $${constructor(e,r){this.core=e,this.logger=r,X(this,"name",BS),X(this,"version",TS),X(this,"events",new Ga),X(this,"pairings"),X(this,"initialized",!1),X(this,"storagePrefix",qt),X(this,"ignoredPayloadTypes",[nr]),X(this,"registeredMethods",[]),X(this,"init",async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))}),X(this,"register",({methods:i})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...i])]}),X(this,"create",async i=>{this.isInitialized();const n=xa(),s=await this.core.crypto.setSymKey(n),o=we(V.FIVE_MINUTES),a={protocol:lg},c={topic:s,expiry:o,relay:a,active:!1,methods:i?.methods},u=Vl({protocol:this.core.protocol,version:this.core.version,topic:s,symKey:n,relay:a,expiryTimestamp:o,methods:i?.methods});return this.events.emit(Lr.create,c),this.core.expirer.set(s,o),await this.pairings.set(s,c),await this.core.relayer.subscribe(s,{transportType:i?.transportType,internal:i?.internal}),{topic:s,uri:u}}),X(this,"pair",async i=>{this.isInitialized();const n=this.core.eventClient.createEvent({properties:{topic:i?.uri,trace:[Rt.pairing_started]}});this.isValidPair(i,n);const{topic:s,symKey:o,relay:a,expiryTimestamp:c,methods:u}=zl(i.uri);n.props.properties.topic=s,n.addTrace(Rt.pairing_uri_validation_success),n.addTrace(Rt.pairing_uri_not_expired);let l;if(this.pairings.keys.includes(s)){if(l=this.pairings.get(s),n.addTrace(Rt.existing_pairing),l.active)throw n.setError(Jt.active_pairing_already_exists),new Error(`Pairing already exists: ${s}. Please try again with a new connection URI.`);n.addTrace(Rt.pairing_not_expired)}const h=c||we(V.FIVE_MINUTES),f={topic:s,relay:a,expiry:h,active:!1,methods:u};this.core.expirer.set(s,h),await this.pairings.set(s,f),n.addTrace(Rt.store_new_pairing),i.activatePairing&&await this.activate({topic:s}),this.events.emit(Lr.create,f),n.addTrace(Rt.emit_inactive_pairing),this.core.crypto.keychain.has(s)||await this.core.crypto.setSymKey(o,s),n.addTrace(Rt.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{n.setError(Jt.no_internet_connection)}try{await this.core.relayer.subscribe(s,{relay:a})}catch(g){throw n.setError(Jt.subscribe_pairing_topic_failure),g}return n.addTrace(Rt.subscribe_pairing_topic_success),f}),X(this,"activate",async({topic:i})=>{this.isInitialized();const n=we(V.FIVE_MINUTES);this.core.expirer.set(i,n),await this.pairings.update(i,{active:!0,expiry:n})}),X(this,"ping",async i=>{this.isInitialized(),await this.isValidPing(i),this.logger.warn("ping() is deprecated and will be removed in the next major release.");const{topic:n}=i;if(this.pairings.keys.includes(n)){const s=await this.sendRequest(n,"wc_pairingPing",{}),{done:o,resolve:a,reject:c}=jr();this.events.once(ie("pairing_ping",s),({error:u})=>{u?c(u):a()}),await o()}}),X(this,"updateExpiry",async({topic:i,expiry:n})=>{this.isInitialized(),await this.pairings.update(i,{expiry:n})}),X(this,"updateMetadata",async({topic:i,metadata:n})=>{this.isInitialized(),await this.pairings.update(i,{peerMetadata:n})}),X(this,"getPairings",()=>(this.isInitialized(),this.pairings.values)),X(this,"disconnect",async i=>{this.isInitialized(),await this.isValidDisconnect(i);const{topic:n}=i;this.pairings.keys.includes(n)&&(await this.sendRequest(n,"wc_pairingDelete",le("USER_DISCONNECTED")),await this.deletePairing(n))}),X(this,"formatUriFromPairing",i=>{this.isInitialized();const{topic:n,relay:s,expiry:o,methods:a}=i,c=this.core.crypto.keychain.get(n);return Vl({protocol:this.core.protocol,version:this.core.version,topic:n,symKey:c,relay:s,expiryTimestamp:o,methods:a})}),X(this,"sendRequest",async(i,n,s)=>{const o=St(n,s),a=await this.core.crypto.encode(i,o),c=Li[n].req;return this.core.history.set(i,o),this.core.relayer.publish(i,a,c),o.id}),X(this,"sendResult",async(i,n,s)=>{const o=ln(i,s),a=await this.core.crypto.encode(n,o),c=(await this.core.history.get(n,i)).request.method,u=Li[c].res;await this.core.relayer.publish(n,a,u),await this.core.history.resolve(o)}),X(this,"sendError",async(i,n,s)=>{const o=Us(i,s),a=await this.core.crypto.encode(n,o),c=(await this.core.history.get(n,i)).request.method,u=Li[c]?Li[c].res:Li.unregistered_method.res;await this.core.relayer.publish(n,a,u),await this.core.history.resolve(o)}),X(this,"deletePairing",async(i,n)=>{await this.core.relayer.unsubscribe(i),await Promise.all([this.pairings.delete(i,le("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(i),n?Promise.resolve():this.core.expirer.del(i)])}),X(this,"cleanup",async()=>{const i=this.pairings.getAll().filter(n=>kt(n.expiry));await Promise.all(i.map(n=>this.deletePairing(n.topic)))}),X(this,"onRelayEventRequest",async i=>{const{topic:n,payload:s}=i;switch(s.method){case"wc_pairingPing":return await this.onPairingPingRequest(n,s);case"wc_pairingDelete":return await this.onPairingDeleteRequest(n,s);default:return await this.onUnknownRpcMethodRequest(n,s)}}),X(this,"onRelayEventResponse",async i=>{const{topic:n,payload:s}=i,o=(await this.core.history.get(n,s.id)).request.method;return o==="wc_pairingPing"?this.onPairingPingResponse(n,s):this.onUnknownRpcMethodResponse(o)}),X(this,"onPairingPingRequest",async(i,n)=>{const{id:s}=n;try{this.isValidPing({topic:i}),await this.sendResult(s,i,!0),this.events.emit(Lr.ping,{id:s,topic:i})}catch(o){await this.sendError(s,i,o),this.logger.error(o)}}),X(this,"onPairingPingResponse",(i,n)=>{const{id:s}=n;setTimeout(()=>{Nt(n)?this.events.emit(ie("pairing_ping",s),{}):wt(n)&&this.events.emit(ie("pairing_ping",s),{error:n.error})},500)}),X(this,"onPairingDeleteRequest",async(i,n)=>{const{id:s}=n;try{this.isValidDisconnect({topic:i}),await this.deletePairing(i),this.events.emit(Lr.delete,{id:s,topic:i})}catch(o){await this.sendError(s,i,o),this.logger.error(o)}}),X(this,"onUnknownRpcMethodRequest",async(i,n)=>{const{id:s,method:o}=n;try{if(this.registeredMethods.includes(o))return;const a=le("WC_METHOD_UNSUPPORTED",o);await this.sendError(s,i,a),this.logger.error(a)}catch(a){await this.sendError(s,i,a),this.logger.error(a)}}),X(this,"onUnknownRpcMethodResponse",i=>{this.registeredMethods.includes(i)||this.logger.error(le("WC_METHOD_UNSUPPORTED",i))}),X(this,"isValidPair",(i,n)=>{var s;if(!We(i)){const{message:a}=z("MISSING_OR_INVALID",`pair() params: ${i}`);throw n.setError(Jt.malformed_pairing_uri),new Error(a)}if(!Yx(i.uri)){const{message:a}=z("MISSING_OR_INVALID",`pair() uri: ${i.uri}`);throw n.setError(Jt.malformed_pairing_uri),new Error(a)}const o=zl(i?.uri);if(!((s=o?.relay)!=null&&s.protocol)){const{message:a}=z("MISSING_OR_INVALID","pair() uri#relay-protocol");throw n.setError(Jt.malformed_pairing_uri),new Error(a)}if(!(o!=null&&o.symKey)){const{message:a}=z("MISSING_OR_INVALID","pair() uri#symKey");throw n.setError(Jt.malformed_pairing_uri),new Error(a)}if(o!=null&&o.expiryTimestamp&&V.toMiliseconds(o?.expiryTimestamp)<Date.now()){n.setError(Jt.pairing_expired);const{message:a}=z("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw new Error(a)}}),X(this,"isValidPing",async i=>{if(!We(i)){const{message:s}=z("MISSING_OR_INVALID",`ping() params: ${i}`);throw new Error(s)}const{topic:n}=i;await this.isValidPairingTopic(n)}),X(this,"isValidDisconnect",async i=>{if(!We(i)){const{message:s}=z("MISSING_OR_INVALID",`disconnect() params: ${i}`);throw new Error(s)}const{topic:n}=i;await this.isValidPairingTopic(n)}),X(this,"isValidPairingTopic",async i=>{if(!be(i,!1)){const{message:n}=z("MISSING_OR_INVALID",`pairing topic should be a string: ${i}`);throw new Error(n)}if(!this.pairings.keys.includes(i)){const{message:n}=z("NO_MATCHING_KEY",`pairing topic doesn't exist: ${i}`);throw new Error(n)}if(kt(this.pairings.get(i).expiry)){await this.deletePairing(i);const{message:n}=z("EXPIRED",`pairing topic: ${i}`);throw new Error(n)}}),this.core=e,this.logger=ut(r,this.name),this.pairings=new ti(this.core,this.logger,this.name,this.storagePrefix)}get context(){return Qe(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=z("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(de.message,async e=>{const{topic:r,message:i,transportType:n}=e;if(this.pairings.keys.includes(r)&&n!==ue.link_mode&&!this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i)))try{const s=await this.core.crypto.decode(r,i);Oc(s)?(this.core.history.set(r,s),await this.onRelayEventRequest({topic:r,payload:s})):Ns(s)&&(await this.core.history.resolve(s),await this.onRelayEventResponse({topic:r,payload:s}),this.core.history.delete(r,s.id)),await this.core.relayer.messages.ack(r,i)}catch(s){this.logger.error(s)}})}registerExpirerEvents(){this.core.expirer.on(pt.expired,async e=>{const{topic:r}=Xd(e.target);r&&this.pairings.keys.includes(r)&&(await this.deletePairing(r,!0),this.events.emit(Lr.expire,{topic:r}))})}}var C$=Object.defineProperty,P$=(t,e,r)=>e in t?C$(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,$e=(t,e,r)=>P$(t,typeof e!="symbol"?e+"":e,r);class B$ extends u_{constructor(e,r){super(e,r),this.core=e,this.logger=r,$e(this,"records",new Map),$e(this,"events",new ct.EventEmitter),$e(this,"name",RS),$e(this,"version",US),$e(this,"cached",[]),$e(this,"initialized",!1),$e(this,"storagePrefix",qt),$e(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.records.set(i.id,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0)}),$e(this,"set",(i,n,s)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:i,request:n,chainId:s}),this.records.has(n.id))return;const o={id:n.id,topic:i,request:{method:n.method,params:n.params||null},chainId:s,expiry:we(V.THIRTY_DAYS)};this.records.set(o.id,o),this.persist(),this.events.emit(Dt.created,o)}),$e(this,"resolve",async i=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:i}),!this.records.has(i.id))return;const n=await this.getRecord(i.id);typeof n.response>"u"&&(n.response=wt(i)?{error:i.error}:{result:i.result},this.records.set(n.id,n),this.persist(),this.events.emit(Dt.updated,n))}),$e(this,"get",async(i,n)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:i,id:n}),await this.getRecord(n))),$e(this,"delete",(i,n)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:n}),this.values.forEach(s=>{if(s.topic===i){if(typeof n<"u"&&s.id!==n)return;this.records.delete(s.id),this.events.emit(Dt.deleted,s)}}),this.persist()}),$e(this,"exists",async(i,n)=>(this.isInitialized(),this.records.has(n)?(await this.getRecord(n)).topic===i:!1)),$e(this,"on",(i,n)=>{this.events.on(i,n)}),$e(this,"once",(i,n)=>{this.events.once(i,n)}),$e(this,"off",(i,n)=>{this.events.off(i,n)}),$e(this,"removeListener",(i,n)=>{this.events.removeListener(i,n)}),this.logger=ut(r,this.name)}get context(){return Qe(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){const e=[];return this.values.forEach(r=>{if(typeof r.response<"u")return;const i={topic:r.topic,request:St(r.request.method,r.request.params,r.id),chainId:r.chainId};return e.push(i)}),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();const r=this.records.get(e);if(!r){const{message:i}=z("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return r}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(Dt.sync)}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:r}=z("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}}registerEventListeners(){this.events.on(Dt.created,e=>{const r=Dt.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.events.on(Dt.updated,e=>{const r=Dt.updated;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.events.on(Dt.deleted,e=>{const r=Dt.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.core.heartbeat.on(ei.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(r=>{V.toMiliseconds(r.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${r.id}`),this.records.delete(r.id),this.events.emit(Dt.deleted,r,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){const{message:e}=z("NOT_INITIALIZED",this.name);throw new Error(e)}}}var T$=Object.defineProperty,R$=(t,e,r)=>e in t?T$(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ke=(t,e,r)=>R$(t,typeof e!="symbol"?e+"":e,r);class U$ extends g_{constructor(e,r){super(e,r),this.core=e,this.logger=r,ke(this,"expirations",new Map),ke(this,"events",new ct.EventEmitter),ke(this,"name",NS),ke(this,"version",jS),ke(this,"cached",[]),ke(this,"initialized",!1),ke(this,"storagePrefix",qt),ke(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.expirations.set(i.target,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0)}),ke(this,"has",i=>{try{const n=this.formatTarget(i);return typeof this.getExpiration(n)<"u"}catch{return!1}}),ke(this,"set",(i,n)=>{this.isInitialized();const s=this.formatTarget(i),o={target:s,expiry:n};this.expirations.set(s,o),this.checkExpiry(s,o),this.events.emit(pt.created,{target:s,expiration:o})}),ke(this,"get",i=>{this.isInitialized();const n=this.formatTarget(i);return this.getExpiration(n)}),ke(this,"del",i=>{if(this.isInitialized(),this.has(i)){const n=this.formatTarget(i),s=this.getExpiration(n);this.expirations.delete(n),this.events.emit(pt.deleted,{target:n,expiration:s})}}),ke(this,"on",(i,n)=>{this.events.on(i,n)}),ke(this,"once",(i,n)=>{this.events.once(i,n)}),ke(this,"off",(i,n)=>{this.events.off(i,n)}),ke(this,"removeListener",(i,n)=>{this.events.removeListener(i,n)}),this.logger=ut(r,this.name)}get context(){return Qe(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if(typeof e=="string")return OE(e);if(typeof e=="number")return AE(e);const{message:r}=z("UNKNOWN_TYPE",`Target type: ${typeof e}`);throw new Error(r)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(pt.sync)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:r}=z("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e)}}getExpiration(e){const r=this.expirations.get(e);if(!r){const{message:i}=z("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(i),new Error(i)}return r}checkExpiry(e,r){const{expiry:i}=r;V.toMiliseconds(i)-Date.now()<=0&&this.expire(e,r)}expire(e,r){this.expirations.delete(e),this.events.emit(pt.expired,{target:e,expiration:r})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,r)=>this.checkExpiry(r,e))}registerEventListeners(){this.core.heartbeat.on(ei.pulse,()=>this.checkExpirations()),this.events.on(pt.created,e=>{const r=pt.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(pt.expired,e=>{const r=pt.expired;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(pt.deleted,e=>{const r=pt.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=z("NOT_INITIALIZED",this.name);throw new Error(e)}}}var N$=Object.defineProperty,j$=(t,e,r)=>e in t?N$(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ye=(t,e,r)=>j$(t,typeof e!="symbol"?e+"":e,r);class k$ extends y_{constructor(e,r,i){super(e,r,i),this.core=e,this.logger=r,this.store=i,ye(this,"name",kS),ye(this,"abortController"),ye(this,"isDevEnv"),ye(this,"verifyUrlV3",LS),ye(this,"storagePrefix",qt),ye(this,"version",ug),ye(this,"publicKey"),ye(this,"fetchPromise"),ye(this,"init",async()=>{var n;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&V.toMiliseconds((n=this.publicKey)==null?void 0:n.expiresAt)<Date.now()&&(this.logger.debug("verify v2 public key expired"),await this.removePublicKey()))}),ye(this,"register",async n=>{if(!Oi()||this.isDevEnv)return;const s=window.location.origin,{id:o,decryptedId:a}=n,c=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${s}&id=${o}&decryptedId=${a}`;try{const u=sr.getDocument(),l=this.startAbortTimer(V.ONE_SECOND*5),h=await new Promise((f,g)=>{const p=()=>{window.removeEventListener("message",m),u.body.removeChild(y),g("attestation aborted")};this.abortController.signal.addEventListener("abort",p);const y=u.createElement("iframe");y.src=c,y.style.display="none",y.addEventListener("error",p,{signal:this.abortController.signal});const m=x=>{if(x.data&&typeof x.data=="string")try{const S=JSON.parse(x.data);if(S.type==="verify_attestation"){if(ua(S.attestation).payload.id!==o)return;clearInterval(l),u.body.removeChild(y),this.abortController.signal.removeEventListener("abort",p),window.removeEventListener("message",m),f(S.attestation===null?"":S.attestation)}}catch(S){this.logger.warn(S)}};u.body.appendChild(y),window.addEventListener("message",m,{signal:this.abortController.signal})});return this.logger.debug(h,"jwt attestation"),h}catch(u){this.logger.warn(u)}return""}),ye(this,"resolve",async n=>{if(this.isDevEnv)return"";const{attestationId:s,hash:o,encryptedId:a}=n;if(s===""){this.logger.debug("resolve: attestationId is empty, skipping");return}if(s){if(ua(s).payload.id!==a)return;const u=await this.isValidJwtAttestation(s);if(u){if(!u.isVerified){this.logger.warn("resolve: jwt attestation: origin url not verified");return}return u}}if(!o)return;const c=this.getVerifyUrl(n?.verifyUrl);return this.fetchAttestation(o,c)}),ye(this,"fetchAttestation",async(n,s)=>{this.logger.debug(`resolving attestation: ${n} from url: ${s}`);const o=this.startAbortTimer(V.ONE_SECOND*5),a=await fetch(`${s}/attestation/${n}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(o),a.status===200?await a.json():void 0}),ye(this,"getVerifyUrl",n=>{let s=n||Qi;return MS.includes(s)||(this.logger.info(`verify url: ${s}, not included in trusted list, assigning default: ${Qi}`),s=Qi),s}),ye(this,"fetchPublicKey",async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);const n=this.startAbortTimer(V.FIVE_SECONDS),s=await fetch(`${this.verifyUrlV3}/public-key`,{signal:this.abortController.signal});return clearTimeout(n),await s.json()}catch(n){this.logger.warn(n)}}),ye(this,"persistPublicKey",async n=>{this.logger.debug(n,"persisting public key to local storage"),await this.store.setItem(this.storeKey,n),this.publicKey=n}),ye(this,"removePublicKey",async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0}),ye(this,"isValidJwtAttestation",async n=>{const s=await this.getPublicKey();try{if(s)return this.validateAttestation(n,s)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation")}const o=await this.fetchAndPersistPublicKey();try{if(o)return this.validateAttestation(n,o)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation")}}),ye(this,"getPublicKey",async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey()),ye(this,"fetchAndPersistPublicKey",async()=>{if(this.fetchPromise)return await this.fetchPromise,this.publicKey;this.fetchPromise=new Promise(async s=>{const o=await this.fetchPublicKey();o&&(await this.persistPublicKey(o),s(o))});const n=await this.fetchPromise;return this.fetchPromise=void 0,n}),ye(this,"validateAttestation",(n,s)=>{const o=Dx(n,s.publicKey),a={hasExpired:V.toMiliseconds(o.exp)<Date.now(),payload:o};if(a.hasExpired)throw this.logger.warn("resolve: jwt attestation expired"),new Error("JWT attestation expired");return{origin:a.payload.origin,isScam:a.payload.isScam,isVerified:a.payload.isVerified}}),this.logger=ut(r,this.name),this.abortController=new AbortController,this.isDevEnv=dc(),this.init()}get storeKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//verify:public:key"}get context(){return Qe(this.logger)}startAbortTimer(e){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),V.toMiliseconds(e))}}var F$=Object.defineProperty,L$=(t,e,r)=>e in t?F$(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Nh=(t,e,r)=>L$(t,typeof e!="symbol"?e+"":e,r);class M$ extends w_{constructor(e,r){super(e,r),this.projectId=e,this.logger=r,Nh(this,"context",qS),Nh(this,"registerDeviceToken",async i=>{const{clientId:n,token:s,notificationType:o,enableEncrypted:a=!1}=i,c=`${zS}/${this.projectId}/clients`;await fetch(c,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:n,type:o,token:s,always_raw:a})})}),this.logger=ut(r,this.context)}}var q$=Object.defineProperty,jh=Object.getOwnPropertySymbols,z$=Object.prototype.hasOwnProperty,V$=Object.prototype.propertyIsEnumerable,ka=(t,e,r)=>e in t?q$(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,zi=(t,e)=>{for(var r in e||(e={}))z$.call(e,r)&&ka(t,r,e[r]);if(jh)for(var r of jh(e))V$.call(e,r)&&ka(t,r,e[r]);return t},_e=(t,e,r)=>ka(t,typeof e!="symbol"?e+"":e,r);class H$ extends b_{constructor(e,r,i=!0){super(e,r,i),this.core=e,this.logger=r,_e(this,"context",HS),_e(this,"storagePrefix",qt),_e(this,"storageVersion",VS),_e(this,"events",new Map),_e(this,"shouldPersist",!1),_e(this,"init",async()=>{if(!dc())try{const n={eventId:ul(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:Zd(this.core.relayer.protocol,this.core.relayer.version,Ca)}}};await this.sendEvent([n])}catch(n){this.logger.warn(n)}}),_e(this,"createEvent",n=>{const{event:s="ERROR",type:o="",properties:{topic:a,trace:c}}=n,u=ul(),l=this.core.projectId||"",h=Date.now(),f=zi({eventId:u,timestamp:h,props:{event:s,type:o,properties:{topic:a,trace:c}},bundleId:l,domain:this.getAppDomain()},this.setMethods(u));return this.telemetryEnabled&&(this.events.set(u,f),this.shouldPersist=!0),f}),_e(this,"getEvent",n=>{const{eventId:s,topic:o}=n;if(s)return this.events.get(s);const a=Array.from(this.events.values()).find(c=>c.props.properties.topic===o);if(a)return zi(zi({},a),this.setMethods(a.eventId))}),_e(this,"deleteEvent",n=>{const{eventId:s}=n;this.events.delete(s),this.shouldPersist=!0}),_e(this,"setEventListeners",()=>{this.core.heartbeat.on(ei.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(n=>{V.fromMiliseconds(Date.now())-V.fromMiliseconds(n.timestamp)>KS&&(this.events.delete(n.eventId),this.shouldPersist=!0)})})}),_e(this,"setMethods",n=>({addTrace:s=>this.addTrace(n,s),setError:s=>this.setError(n,s)})),_e(this,"addTrace",(n,s)=>{const o=this.events.get(n);o&&(o.props.properties.trace.push(s),this.events.set(n,o),this.shouldPersist=!0)}),_e(this,"setError",(n,s)=>{const o=this.events.get(n);o&&(o.props.type=s,o.timestamp=Date.now(),this.events.set(n,o),this.shouldPersist=!0)}),_e(this,"persist",async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1}),_e(this,"restore",async()=>{try{const n=await this.core.storage.getItem(this.storageKey)||[];if(!n.length)return;n.forEach(s=>{this.events.set(s.eventId,zi(zi({},s),this.setMethods(s.eventId)))})}catch(n){this.logger.warn(n)}}),_e(this,"submit",async()=>{if(!this.telemetryEnabled||this.events.size===0)return;const n=[];for(const[s,o]of this.events)o.props.type&&n.push(o);if(n.length!==0)try{if((await this.sendEvent(n)).ok)for(const s of n)this.events.delete(s.eventId),this.shouldPersist=!0}catch(s){this.logger.warn(s)}}),_e(this,"sendEvent",async n=>{const s=this.getAppDomain()?"":"&sp=desktop";return await fetch(`${WS}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${Ca}${s}`,{method:"POST",body:JSON.stringify(n)})}),_e(this,"getAppDomain",()=>Yd().url),this.logger=ut(r,this.context),this.telemetryEnabled=i,i?this.restore().then(async()=>{await this.submit(),this.setEventListeners()}):this.persist()}get storageKey(){return this.storagePrefix+this.storageVersion+this.core.customStoragePrefix+"//"+this.context}}var K$=Object.defineProperty,kh=Object.getOwnPropertySymbols,W$=Object.prototype.hasOwnProperty,G$=Object.prototype.propertyIsEnumerable,Fa=(t,e,r)=>e in t?K$(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Fh=(t,e)=>{for(var r in e||(e={}))W$.call(e,r)&&Fa(t,r,e[r]);if(kh)for(var r of kh(e))G$.call(e,r)&&Fa(t,r,e[r]);return t},ae=(t,e,r)=>Fa(t,typeof e!="symbol"?e+"":e,r);let Y$=class _g extends s_{constructor(e){var r;super(e),ae(this,"protocol",cg),ae(this,"version",ug),ae(this,"name",$a),ae(this,"relayUrl"),ae(this,"projectId"),ae(this,"customStoragePrefix"),ae(this,"events",new ct.EventEmitter),ae(this,"logger"),ae(this,"heartbeat"),ae(this,"relayer"),ae(this,"crypto"),ae(this,"storage"),ae(this,"history"),ae(this,"expirer"),ae(this,"pairing"),ae(this,"verify"),ae(this,"echoClient"),ae(this,"linkModeSupportedApps"),ae(this,"eventClient"),ae(this,"initialized",!1),ae(this,"logChunkController"),ae(this,"on",(a,c)=>this.events.on(a,c)),ae(this,"once",(a,c)=>this.events.once(a,c)),ae(this,"off",(a,c)=>this.events.off(a,c)),ae(this,"removeListener",(a,c)=>this.events.removeListener(a,c)),ae(this,"dispatchEnvelope",({topic:a,message:c,sessionExists:u})=>{if(!a||!c)return;const l={topic:a,message:c,publishedAt:Date.now(),transportType:ue.link_mode};this.relayer.onLinkMessageEvent(l,{sessionExists:u})});const i=this.getGlobalCore(e?.customStoragePrefix);if(i)try{return this.customStoragePrefix=i.customStoragePrefix,this.logger=i.logger,this.heartbeat=i.heartbeat,this.crypto=i.crypto,this.history=i.history,this.expirer=i.expirer,this.storage=i.storage,this.relayer=i.relayer,this.pairing=i.pairing,this.verify=i.verify,this.echoClient=i.echoClient,this.linkModeSupportedApps=i.linkModeSupportedApps,this.eventClient=i.eventClient,this.initialized=i.initialized,this.logChunkController=i.logChunkController,i}catch(a){console.warn("Failed to copy global core",a)}this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||hg,this.customStoragePrefix=e!=null&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";const n=sE({level:typeof e?.logger=="string"&&e.logger?e.logger:pS.logger,name:$a}),{logger:s,chunkLoggerController:o}=Wd({opts:n,maxSizeInBytes:e?.maxLogBlobSizeInBytes,loggerOverride:e?.logger});this.logChunkController=o,(r=this.logChunkController)!=null&&r.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var a,c;(a=this.logChunkController)!=null&&a.downloadLogsBlobInBrowser&&((c=this.logChunkController)==null||c.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=ut(s,this.name),this.heartbeat=new B8,this.crypto=new DA(this,this.logger,e?.keychain),this.history=new B$(this,this.logger),this.expirer=new U$(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new r_(Fh(Fh({},gS),e?.storageOptions)),this.relayer=new YA({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new $$(this,this.logger),this.verify=new k$(this,this.logger,this.storage),this.echoClient=new M$(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new H$(this,this.logger,e?.telemetryEnabled),this.setGlobalCore(this)}static async init(e){const r=new _g(e);await r.initialize();const i=await r.crypto.getClientId();return await r.storage.setItem($S,i),r}get context(){return Qe(this.logger)}async start(){this.initialized||await this.initialize()}async getLogsBlob(){var e;return(e=this.logChunkController)==null?void 0:e.logsToBlob({clientId:await this.crypto.getClientId()})}async addLinkModeSupportedApp(e){this.linkModeSupportedApps.includes(e)||(this.linkModeSupportedApps.push(e),await this.storage.setItem(wh,this.linkModeSupportedApps))}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.linkModeSupportedApps=await this.storage.getItem(wh)||[],this.initialized=!0,this.logger.info("Core Initialization Success")}catch(e){throw this.logger.warn(e,`Core Initialization Failure at epoch ${Date.now()}`),this.logger.error(e.message),e}}getGlobalCore(e=""){try{if(this.isGlobalCoreDisabled())return;const r=`_walletConnectCore_${e}`,i=`${r}_count`;return globalThis[i]=(globalThis[i]||0)+1,globalThis[i]>1&&console.warn(`WalletConnect Core is already initialized. This is probably a mistake and can lead to unexpected behavior. Init() was called ${globalThis[i]} times.`),globalThis[r]}catch(r){console.warn("Failed to get global WalletConnect core",r);return}}setGlobalCore(e){var r;try{if(this.isGlobalCoreDisabled())return;const i=`_walletConnectCore_${((r=e.opts)==null?void 0:r.customStoragePrefix)||""}`;globalThis[i]=e}catch(i){console.warn("Failed to set global WalletConnect core",i)}}isGlobalCoreDisabled(){try{return typeof process<"u"&&dS.DISABLE_GLOBAL_CORE==="true"}catch{return!0}}};const Z$=Y$,Ig="wc",Sg=2,Og="client",$c=`${Ig}@${Sg}:${Og}:`,Fo={name:Og,logger:"error"},Lh="WALLETCONNECT_DEEPLINK_CHOICE",J$="proposal",Mh="Proposal expired",X$="session",li=V.SEVEN_DAYS,Q$="engine",Ce={wc_sessionPropose:{req:{ttl:V.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:V.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:V.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:V.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:V.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:V.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:V.ONE_DAY,prompt:!1,tag:1104},res:{ttl:V.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:V.ONE_DAY,prompt:!1,tag:1106},res:{ttl:V.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:V.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:V.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:V.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:V.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:V.ONE_DAY,prompt:!1,tag:1112},res:{ttl:V.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:V.ONE_DAY,prompt:!1,tag:1114},res:{ttl:V.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:V.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:V.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:V.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:V.FIVE_MINUTES,prompt:!1,tag:1119}}},Lo={min:V.FIVE_MINUTES,max:V.SEVEN_DAYS},Tt={idle:"IDLE",active:"ACTIVE"},e6={eth_sendTransaction:{key:""},eth_sendRawTransaction:{key:""},wallet_sendCalls:{key:""},solana_signTransaction:{key:"signature"},solana_signAllTransactions:{key:"transactions"},solana_signAndSendTransaction:{key:"signature"},sui_signAndExecuteTransaction:{key:"digest"},sui_signTransaction:{key:""},hedera_signAndExecuteTransaction:{key:"transactionId"},hedera_executeTransaction:{key:"transactionId"},near_signTransaction:{key:""},near_signTransactions:{key:""},tron_signTransaction:{key:"txID"},xrpl_signTransaction:{key:""},xrpl_signTransactionFor:{key:""},algo_signTxn:{key:""},sendTransfer:{key:"txid"},stacks_stxTransfer:{key:"txId"},polkadot_signTransaction:{key:""},cosmos_signDirect:{key:""}},t6="request",r6=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],i6="wc",n6="auth",s6="authKeys",o6="pairingTopics",a6="requests",ks=`${i6}@${1.5}:${n6}:`,Xn=`${ks}:PUB_KEY`;var c6=Object.defineProperty,u6=Object.defineProperties,l6=Object.getOwnPropertyDescriptors,qh=Object.getOwnPropertySymbols,h6=Object.prototype.hasOwnProperty,f6=Object.prototype.propertyIsEnumerable,La=(t,e,r)=>e in t?c6(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ne=(t,e)=>{for(var r in e||(e={}))h6.call(e,r)&&La(t,r,e[r]);if(qh)for(var r of qh(e))f6.call(e,r)&&La(t,r,e[r]);return t},Fe=(t,e)=>u6(t,l6(e)),M=(t,e,r)=>La(t,typeof e!="symbol"?e+"":e,r);class d6 extends D_{constructor(e){super(e),M(this,"name",Q$),M(this,"events",new Ga),M(this,"initialized",!1),M(this,"requestQueue",{state:Tt.idle,queue:[]}),M(this,"sessionRequestQueue",{state:Tt.idle,queue:[]}),M(this,"emittedSessionRequests",new jE({limit:500})),M(this,"requestQueueDelay",V.ONE_SECOND),M(this,"expectedPairingMethodMap",new Map),M(this,"recentlyDeletedMap",new Map),M(this,"recentlyDeletedLimit",200),M(this,"relayMessageCache",[]),M(this,"pendingSessions",new Map),M(this,"init",async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),await this.registerLinkModeListeners(),this.client.core.pairing.register({methods:Object.keys(Ce)}),this.initialized=!0,setTimeout(async()=>{await this.processPendingMessageEvents(),this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},V.toMiliseconds(this.requestQueueDelay)))}),M(this,"connect",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();const i=Fe(ne({},r),{requiredNamespaces:r.requiredNamespaces||{},optionalNamespaces:r.optionalNamespaces||{}});await this.isValidConnect(i),i.optionalNamespaces=Vx(i.requiredNamespaces,i.optionalNamespaces),i.requiredNamespaces={};const{pairingTopic:n,requiredNamespaces:s,optionalNamespaces:o,sessionProperties:a,scopedProperties:c,relays:u}=i;let l=n,h,f=!1;try{if(l){const I=this.client.core.pairing.pairings.get(l);this.client.logger.warn("connect() with existing pairing topic is deprecated and will be removed in the next major release."),f=I.active}}catch(I){throw this.client.logger.error(`connect() -> pairing.get(${l}) failed`),I}if(!l||!f){const{topic:I,uri:$}=await this.client.core.pairing.create({internal:{skipSubscribe:!0}});l=I,h=$}if(!l){const{message:I}=z("NO_MATCHING_KEY",`connect() pairing topic: ${l}`);throw new Error(I)}const g=await this.client.core.crypto.generateKeyPair(),p=Ce.wc_sessionPropose.req.ttl||V.FIVE_MINUTES,y=we(p),m=Fe(ne(ne({requiredNamespaces:s,optionalNamespaces:o,relays:u??[{protocol:lg}],proposer:{publicKey:g,metadata:this.client.metadata},expiryTimestamp:y,pairingTopic:l},a&&{sessionProperties:a}),c&&{scopedProperties:c}),{id:Ut()}),x=ie("session_connect",m.id),{reject:S,resolve:v,done:b}=jr(p,Mh),E=({id:I})=>{I===m.id&&(this.client.events.off("proposal_expire",E),this.pendingSessions.delete(m.id),this.events.emit(x,{error:{message:Mh,code:0}}))};return this.client.events.on("proposal_expire",E),this.events.once(x,({error:I,session:$})=>{this.client.events.off("proposal_expire",E),I?S(I):$&&v($)}),await this.sendProposeSession({proposal:m,publishOpts:{internal:{throwOnFailedPublish:!0},tvf:{correlationId:m.id}}}),await this.setProposal(m.id,m),{uri:h,approval:b}}),M(this,"pair",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{return await this.client.core.pairing.pair(r)}catch(i){throw this.client.logger.error("pair() failed"),i}}),M(this,"approve",async r=>{var i,n,s;const o=this.client.core.eventClient.createEvent({properties:{topic:(i=r?.id)==null?void 0:i.toString(),trace:[xt.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(C){throw o.setError(Rr.no_internet_connection),C}try{await this.isValidProposalId(r?.id)}catch(C){throw this.client.logger.error(`approve() -> proposal.get(${r?.id}) failed`),o.setError(Rr.proposal_not_found),C}try{await this.isValidApprove(r)}catch(C){throw this.client.logger.error("approve() -> isValidApprove() failed"),o.setError(Rr.session_approve_namespace_validation_failure),C}const{id:a,relayProtocol:c,namespaces:u,sessionProperties:l,scopedProperties:h,sessionConfig:f}=r,g=this.client.proposal.get(a);this.client.core.eventClient.deleteEvent({eventId:o.eventId});const{pairingTopic:p,proposer:y,requiredNamespaces:m,optionalNamespaces:x}=g;let S=(n=this.client.core.eventClient)==null?void 0:n.getEvent({topic:p});S||(S=(s=this.client.core.eventClient)==null?void 0:s.createEvent({type:xt.session_approve_started,properties:{topic:p,trace:[xt.session_approve_started,xt.session_namespaces_validation_success]}}));const v=await this.client.core.crypto.generateKeyPair(),b=y.publicKey,E=await this.client.core.crypto.generateSharedKey(v,b),I=ne(ne(ne({relay:{protocol:c??"irn"},namespaces:u,controller:{publicKey:v,metadata:this.client.metadata},expiry:we(li)},l&&{sessionProperties:l}),h&&{scopedProperties:h}),f&&{sessionConfig:f}),$=ue.relay;S.addTrace(xt.subscribing_session_topic);try{await this.client.core.relayer.subscribe(E,{transportType:$,internal:{skipSubscribe:!0}})}catch(C){throw S.setError(Rr.subscribe_session_topic_failure),C}S.addTrace(xt.subscribe_session_topic_success);const B=Fe(ne({},I),{topic:E,requiredNamespaces:m,optionalNamespaces:x,pairingTopic:p,acknowledged:!1,self:I.controller,peer:{publicKey:y.publicKey,metadata:y.metadata},controller:v,transportType:ue.relay});await this.client.session.set(E,B),S.addTrace(xt.store_session);try{await this.sendApproveSession({sessionTopic:E,proposal:g,pairingProposalResponse:{relay:{protocol:c??"irn"},responderPublicKey:v},sessionSettleRequest:I,publishOpts:{internal:{throwOnFailedPublish:!0},tvf:{correlationId:a}}}),S.addTrace(xt.session_approve_publish_success)}catch(C){throw this.client.logger.error(C),this.client.session.delete(E,le("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(E),C}return this.client.core.eventClient.deleteEvent({eventId:S.eventId}),await this.client.core.pairing.updateMetadata({topic:p,metadata:y.metadata}),await this.deleteProposal(a),await this.client.core.pairing.activate({topic:p}),await this.setExpiry(E,we(li)),{topic:E,acknowledged:()=>Promise.resolve(this.client.session.get(E))}}),M(this,"reject",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidReject(r)}catch(o){throw this.client.logger.error("reject() -> isValidReject() failed"),o}const{id:i,reason:n}=r;let s;try{s=this.client.proposal.get(i).pairingTopic}catch(o){throw this.client.logger.error(`reject() -> proposal.get(${i}) failed`),o}s&&await this.sendError({id:i,topic:s,error:n,rpcOpts:Ce.wc_sessionPropose.reject}),await this.deleteProposal(i)}),M(this,"update",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(r)}catch(h){throw this.client.logger.error("update() -> isValidUpdate() failed"),h}const{topic:i,namespaces:n}=r,{done:s,resolve:o,reject:a}=jr(),c=Ut(),u=_r().toString(),l=this.client.session.get(i).namespaces;return this.events.once(ie("session_update",c),({error:h})=>{h?a(h):o()}),await this.client.session.update(i,{namespaces:n}),await this.sendRequest({topic:i,method:"wc_sessionUpdate",params:{namespaces:n},throwOnFailedPublish:!0,clientRpcId:c,relayRpcId:u}).catch(h=>{this.client.logger.error(h),this.client.session.update(i,{namespaces:l}),a(h)}),{acknowledged:s}}),M(this,"extend",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(r)}catch(c){throw this.client.logger.error("extend() -> isValidExtend() failed"),c}const{topic:i}=r,n=Ut(),{done:s,resolve:o,reject:a}=jr();return this.events.once(ie("session_extend",n),({error:c})=>{c?a(c):o()}),await this.setExpiry(i,we(li)),this.sendRequest({topic:i,method:"wc_sessionExtend",params:{},clientRpcId:n,throwOnFailedPublish:!0}).catch(c=>{a(c)}),{acknowledged:s}}),M(this,"request",async r=>{this.isInitialized();try{await this.isValidRequest(r)}catch(m){throw this.client.logger.error("request() -> isValidRequest() failed"),m}const{chainId:i,request:n,topic:s,expiry:o=Ce.wc_sessionRequest.req.ttl}=r,a=this.client.session.get(s);a?.transportType===ue.relay&&await this.confirmOnlineStateOrThrow();const c=Ut(),u=_r().toString(),{done:l,resolve:h,reject:f}=jr(o,"Request expired. Please try again.");this.events.once(ie("session_request",c),({error:m,result:x})=>{m?f(m):h(x)});const g="wc_sessionRequest",p=this.getAppLinkIfEnabled(a.peer.metadata,a.transportType);if(p)return await this.sendRequest({clientRpcId:c,relayRpcId:u,topic:s,method:g,params:{request:Fe(ne({},n),{expiryTimestamp:we(o)}),chainId:i},expiry:o,throwOnFailedPublish:!0,appLink:p}).catch(m=>f(m)),this.client.events.emit("session_request_sent",{topic:s,request:n,chainId:i,id:c}),await l();const y={request:Fe(ne({},n),{expiryTimestamp:we(o)}),chainId:i};return await Promise.all([new Promise(async m=>{await this.sendRequest({clientRpcId:c,relayRpcId:u,topic:s,method:g,params:y,expiry:o,throwOnFailedPublish:!0,tvf:this.getTVFParams(c,y)}).catch(x=>f(x)),this.client.events.emit("session_request_sent",{topic:s,request:n,chainId:i,id:c}),m()}),new Promise(async m=>{var x;if(!((x=a.sessionConfig)!=null&&x.disableDeepLink)){const S=await BE(this.client.core.storage,Lh);await $E({id:c,topic:s,wcDeepLink:S})}m()}),l()]).then(m=>m[2])}),M(this,"respond",async r=>{var i,n;this.isInitialized();const s=this.client.core.eventClient.createEvent({properties:{topic:r?.topic||((n=(i=r?.response)==null?void 0:i.id)==null?void 0:n.toString()),trace:[xt.session_request_response_started]}});try{await this.isValidRespond(r)}catch(h){throw s.addTrace(h?.message),s.setError(Rr.session_request_response_validation_failure),h}s.addTrace(xt.session_request_response_validation_success);const{topic:o,response:a}=r,{id:c}=a,u=this.client.session.get(o);u.transportType===ue.relay&&await this.confirmOnlineStateOrThrow();const l=this.getAppLinkIfEnabled(u.peer.metadata,u.transportType);try{s.addTrace(xt.session_request_response_publish_started),Nt(a)?await this.sendResult({id:c,topic:o,result:a.result,throwOnFailedPublish:!0,appLink:l}):wt(a)&&await this.sendError({id:c,topic:o,error:a.error,appLink:l}),this.cleanupAfterResponse(r)}catch(h){throw s.addTrace(h?.message),s.setError(Rr.session_request_response_publish_failure),h}}),M(this,"ping",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(r)}catch(n){throw this.client.logger.error("ping() -> isValidPing() failed"),n}const{topic:i}=r;if(this.client.session.keys.includes(i)){const n=Ut(),s=_r().toString(),{done:o,resolve:a,reject:c}=jr();this.events.once(ie("session_ping",n),({error:u})=>{u?c(u):a()}),await Promise.all([this.sendRequest({topic:i,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:n,relayRpcId:s}),o()])}else this.client.core.pairing.pairings.keys.includes(i)&&(this.client.logger.warn("ping() on pairing topic is deprecated and will be removed in the next major release."),await this.client.core.pairing.ping({topic:i}))}),M(this,"emit",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(r);const{topic:i,event:n,chainId:s}=r,o=_r().toString(),a=Ut();await this.sendRequest({topic:i,method:"wc_sessionEvent",params:{event:n,chainId:s},throwOnFailedPublish:!0,relayRpcId:o,clientRpcId:a})}),M(this,"disconnect",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidDisconnect(r);const{topic:i}=r;if(this.client.session.keys.includes(i))await this.sendRequest({topic:i,method:"wc_sessionDelete",params:le("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:i,emitEvent:!1});else if(this.client.core.pairing.pairings.keys.includes(i))await this.client.core.pairing.disconnect({topic:i});else{const{message:n}=z("MISMATCHED_TOPIC",`Session or pairing topic not found: ${i}`);throw new Error(n)}}),M(this,"find",r=>(this.isInitialized(),this.client.session.getAll().filter(i=>Wx(i,r)))),M(this,"getPendingSessionRequests",()=>this.client.pendingRequest.getAll()),M(this,"authenticate",async(r,i)=>{var n;this.isInitialized(),this.isValidAuthenticate(r);const s=i&&this.client.core.linkModeSupportedApps.includes(i)&&((n=this.client.metadata.redirect)==null?void 0:n.linkMode),o=s?ue.link_mode:ue.relay;o===ue.relay&&await this.confirmOnlineStateOrThrow();const{chains:a,statement:c="",uri:u,domain:l,nonce:h,type:f,exp:g,nbf:p,methods:y=[],expiry:m}=r,x=[...r.resources||[]],{topic:S,uri:v}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:o});this.client.logger.info({message:"Generated new pairing",pairing:{topic:S,uri:v}});const b=await this.client.core.crypto.generateKeyPair(),E=Gn(b);if(await Promise.all([this.client.auth.authKeys.set(Xn,{responseTopic:E,publicKey:b}),this.client.auth.pairingTopics.set(E,{topic:E,pairingTopic:S})]),await this.client.core.relayer.subscribe(E,{transportType:o}),this.client.logger.info(`sending request to new pairing topic: ${S}`),y.length>0){const{namespace:_}=ir(a[0]);let A=G3(_,"request",y);Wn(x)&&(A=Z3(A,x.pop())),x.push(A)}const I=m&&m>Ce.wc_sessionAuthenticate.req.ttl?m:Ce.wc_sessionAuthenticate.req.ttl,$={authPayload:{type:f??"caip122",chains:a,statement:c,aud:u,domain:l,version:"1",nonce:h,iat:new Date().toISOString(),exp:g,nbf:p,resources:x},requester:{publicKey:b,metadata:this.client.metadata},expiryTimestamp:we(I)},B={eip155:{chains:a,methods:[...new Set(["personal_sign",...y])],events:["chainChanged","accountsChanged"]}},C={requiredNamespaces:{},optionalNamespaces:B,relays:[{protocol:"irn"}],pairingTopic:S,proposer:{publicKey:b,metadata:this.client.metadata},expiryTimestamp:we(Ce.wc_sessionPropose.req.ttl),id:Ut()},{done:k,resolve:F,reject:R}=jr(I,"Request expired"),P=Ut(),T=ie("session_connect",C.id),d=ie("session_request",P),w=async({error:_,session:A})=>{this.events.off(d,D),_?R(_):A&&F({session:A})},D=async _=>{var A,N,j;if(await this.deletePendingAuthRequest(P,{message:"fulfilled",code:0}),_.error){const W=le("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return _.error.code===W.code?void 0:(this.events.off(T,w),R(_.error.message))}await this.deleteProposal(C.id),this.events.off(T,w);const{cacaos:q,responder:U}=_.result,L=[],K=[];for(const W of q){await vl({cacao:W,projectId:this.client.core.projectId})||(this.client.logger.error(W,"Signature verification failed"),R(le("SESSION_SETTLEMENT_FAILED","Signature verification failed")));const{p:Y}=W,ee=Wn(Y.resources),ce=[da(Y.iss)],fe=us(Y.iss);if(ee){const ge=El(ee),et=Dl(ee);L.push(...ge),ce.push(...et)}for(const ge of ce)K.push(`${ge}:${fe}`)}const G=await this.client.core.crypto.generateSharedKey(b,U.publicKey);let Z;L.length>0&&(Z={topic:G,acknowledged:!0,self:{publicKey:b,metadata:this.client.metadata},peer:U,controller:U.publicKey,expiry:we(li),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:S,namespaces:Gl([...new Set(L)],[...new Set(K)]),transportType:o},await this.client.core.relayer.subscribe(G,{transportType:o}),await this.client.session.set(G,Z),S&&await this.client.core.pairing.updateMetadata({topic:S,metadata:U.metadata}),Z=this.client.session.get(G)),(A=this.client.metadata.redirect)!=null&&A.linkMode&&(N=U.metadata.redirect)!=null&&N.linkMode&&(j=U.metadata.redirect)!=null&&j.universal&&i&&(this.client.core.addLinkModeSupportedApp(U.metadata.redirect.universal),this.client.session.update(G,{transportType:ue.link_mode})),F({auths:q,session:Z})};this.events.once(T,w),this.events.once(d,D);let O;try{if(s){const _=St("wc_sessionAuthenticate",$,P);this.client.core.history.set(S,_);const A=await this.client.core.crypto.encode("",_,{type:vn,encoding:xr});O=kn(i,S,A)}else await Promise.all([this.sendRequest({topic:S,method:"wc_sessionAuthenticate",params:$,expiry:r.expiry,throwOnFailedPublish:!0,clientRpcId:P}),this.sendRequest({topic:S,method:"wc_sessionPropose",params:C,expiry:Ce.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:C.id})])}catch(_){throw this.events.off(T,w),this.events.off(d,D),_}return await this.setProposal(C.id,C),await this.setAuthRequest(P,{request:Fe(ne({},$),{verifyContext:{}}),pairingTopic:S,transportType:o}),{uri:O??v,response:k}}),M(this,"approveSessionAuthenticate",async r=>{const{id:i,auths:n}=r,s=this.client.core.eventClient.createEvent({properties:{topic:i.toString(),trace:[Ur.authenticated_session_approve_started]}});try{this.isInitialized()}catch(m){throw s.setError(Mi.no_internet_connection),m}const o=this.getPendingAuthRequest(i);if(!o)throw s.setError(Mi.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${i}`);const a=o.transportType||ue.relay;a===ue.relay&&await this.confirmOnlineStateOrThrow();const c=o.requester.publicKey,u=await this.client.core.crypto.generateKeyPair(),l=Gn(c),h={type:nr,receiverPublicKey:c,senderPublicKey:u},f=[],g=[];for(const m of n){if(!await vl({cacao:m,projectId:this.client.core.projectId})){s.setError(Mi.invalid_cacao);const E=le("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:i,topic:l,error:E,encodeOpts:h}),new Error(E.message)}s.addTrace(Ur.cacaos_verified);const{p:x}=m,S=Wn(x.resources),v=[da(x.iss)],b=us(x.iss);if(S){const E=El(S),I=Dl(S);f.push(...E),v.push(...I)}for(const E of v)g.push(`${E}:${b}`)}const p=await this.client.core.crypto.generateSharedKey(u,c);s.addTrace(Ur.create_authenticated_session_topic);let y;if(f?.length>0){y={topic:p,acknowledged:!0,self:{publicKey:u,metadata:this.client.metadata},peer:{publicKey:c,metadata:o.requester.metadata},controller:c,expiry:we(li),authentication:n,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:o.pairingTopic,namespaces:Gl([...new Set(f)],[...new Set(g)]),transportType:a},s.addTrace(Ur.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(p,{transportType:a})}catch(m){throw s.setError(Mi.subscribe_authenticated_session_topic_failure),m}s.addTrace(Ur.subscribe_authenticated_session_topic_success),await this.client.session.set(p,y),s.addTrace(Ur.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:o.pairingTopic,metadata:o.requester.metadata})}s.addTrace(Ur.publishing_authenticated_session_approve);try{await this.sendResult({topic:l,id:i,result:{cacaos:n,responder:{publicKey:u,metadata:this.client.metadata}},encodeOpts:h,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(o.requester.metadata,a)})}catch(m){throw s.setError(Mi.authenticated_session_approve_publish_failure),m}return await this.client.auth.requests.delete(i,{message:"fulfilled",code:0}),await this.client.core.pairing.activate({topic:o.pairingTopic}),this.client.core.eventClient.deleteEvent({eventId:s.eventId}),{session:y}}),M(this,"rejectSessionAuthenticate",async r=>{this.isInitialized();const{id:i,reason:n}=r,s=this.getPendingAuthRequest(i);if(!s)throw new Error(`Could not find pending auth request with id ${i}`);s.transportType===ue.relay&&await this.confirmOnlineStateOrThrow();const o=s.requester.publicKey,a=await this.client.core.crypto.generateKeyPair(),c=Gn(o),u={type:nr,receiverPublicKey:o,senderPublicKey:a};await this.sendError({id:i,topic:c,error:n,encodeOpts:u,rpcOpts:Ce.wc_sessionAuthenticate.reject,appLink:this.getAppLinkIfEnabled(s.requester.metadata,s.transportType)}),await this.client.auth.requests.delete(i,{message:"rejected",code:0}),await this.deleteProposal(i)}),M(this,"formatAuthMessage",r=>{this.isInitialized();const{request:i,iss:n}=r;return pp(i,n)}),M(this,"processRelayMessageCache",()=>{setTimeout(async()=>{if(this.relayMessageCache.length!==0)for(;this.relayMessageCache.length>0;)try{const r=this.relayMessageCache.shift();r&&await this.onRelayMessage(r)}catch(r){this.client.logger.error(r)}},50)}),M(this,"cleanupDuplicatePairings",async r=>{if(r.pairingTopic)try{const i=this.client.core.pairing.pairings.get(r.pairingTopic),n=this.client.core.pairing.pairings.getAll().filter(s=>{var o,a;return((o=s.peerMetadata)==null?void 0:o.url)&&((a=s.peerMetadata)==null?void 0:a.url)===r.peer.metadata.url&&s.topic&&s.topic!==i.topic});if(n.length===0)return;this.client.logger.info(`Cleaning up ${n.length} duplicate pairing(s)`),await Promise.all(n.map(s=>this.client.core.pairing.disconnect({topic:s.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(i){this.client.logger.error(i)}}),M(this,"deleteSession",async r=>{var i;const{topic:n,expirerHasDeleted:s=!1,emitEvent:o=!0,id:a=0}=r,{self:c}=this.client.session.get(n);await this.client.core.relayer.unsubscribe(n),await this.client.session.delete(n,le("USER_DISCONNECTED")),this.addToRecentlyDeleted(n,"session"),this.client.core.crypto.keychain.has(c.publicKey)&&await this.client.core.crypto.deleteKeyPair(c.publicKey),this.client.core.crypto.keychain.has(n)&&await this.client.core.crypto.deleteSymKey(n),s||this.client.core.expirer.del(n),this.client.core.storage.removeItem(Lh).catch(u=>this.client.logger.warn(u)),this.getPendingSessionRequests().forEach(u=>{u.topic===n&&this.deletePendingSessionRequest(u.id,le("USER_DISCONNECTED"))}),n===((i=this.sessionRequestQueue.queue[0])==null?void 0:i.topic)&&(this.sessionRequestQueue.state=Tt.idle),o&&this.client.events.emit("session_delete",{id:a,topic:n})}),M(this,"deleteProposal",async(r,i)=>{if(i)try{const n=this.client.proposal.get(r);this.client.core.eventClient.getEvent({topic:n.pairingTopic})?.setError(Rr.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(r,le("USER_DISCONNECTED")),i?Promise.resolve():this.client.core.expirer.del(r)]),this.addToRecentlyDeleted(r,"proposal")}),M(this,"deletePendingSessionRequest",async(r,i,n=!1)=>{await Promise.all([this.client.pendingRequest.delete(r,i),n?Promise.resolve():this.client.core.expirer.del(r)]),this.addToRecentlyDeleted(r,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(s=>s.id!==r),n&&(this.sessionRequestQueue.state=Tt.idle,this.client.events.emit("session_request_expire",{id:r}))}),M(this,"deletePendingAuthRequest",async(r,i,n=!1)=>{await Promise.all([this.client.auth.requests.delete(r,i),n?Promise.resolve():this.client.core.expirer.del(r)])}),M(this,"setExpiry",async(r,i)=>{this.client.session.keys.includes(r)&&(this.client.core.expirer.set(r,i),await this.client.session.update(r,{expiry:i}))}),M(this,"setProposal",async(r,i)=>{this.client.core.expirer.set(r,we(Ce.wc_sessionPropose.req.ttl)),await this.client.proposal.set(r,i)}),M(this,"setAuthRequest",async(r,i)=>{const{request:n,pairingTopic:s,transportType:o=ue.relay}=i;this.client.core.expirer.set(r,n.expiryTimestamp),await this.client.auth.requests.set(r,{authPayload:n.authPayload,requester:n.requester,expiryTimestamp:n.expiryTimestamp,id:r,pairingTopic:s,verifyContext:n.verifyContext,transportType:o})}),M(this,"setPendingSessionRequest",async r=>{const{id:i,topic:n,params:s,verifyContext:o}=r,a=s.request.expiryTimestamp||we(Ce.wc_sessionRequest.req.ttl);this.client.core.expirer.set(i,a),await this.client.pendingRequest.set(i,{id:i,topic:n,params:s,verifyContext:o})}),M(this,"sendRequest",async r=>{const{topic:i,method:n,params:s,expiry:o,relayRpcId:a,clientRpcId:c,throwOnFailedPublish:u,appLink:l,tvf:h,publishOpts:f={}}=r,g=St(n,s,c);let p;const y=!!l;try{const S=y?xr:Ze;p=await this.client.core.crypto.encode(i,g,{encoding:S})}catch(S){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${i} failed`),S}let m;if(r6.includes(n)){const S=yt(JSON.stringify(g)),v=yt(p);m=await this.client.core.verify.register({id:v,decryptedId:S})}const x=ne(ne({},Ce[n].req),f);if(x.attestation=m,o&&(x.ttl=o),a&&(x.id=a),this.client.core.history.set(i,g),y){const S=kn(l,i,p);await global.Linking.openURL(S,this.client.name)}else x.tvf=Fe(ne({},h),{correlationId:g.id}),u?(x.internal=Fe(ne({},x.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(i,p,x)):this.client.core.relayer.publish(i,p,x).catch(S=>this.client.logger.error(S));return g.id}),M(this,"sendProposeSession",async r=>{const{proposal:i,publishOpts:n}=r,s=St("wc_sessionPropose",i,i.id);this.client.core.history.set(i.pairingTopic,s);const o=await this.client.core.crypto.encode(i.pairingTopic,s,{encoding:Ze}),a=yt(JSON.stringify(s)),c=yt(o),u=await this.client.core.verify.register({id:c,decryptedId:a});await this.client.core.relayer.publishCustom({payload:{pairingTopic:i.pairingTopic,sessionProposal:o},opts:Fe(ne({},n),{publishMethod:"wc_proposeSession",attestation:u})})}),M(this,"sendApproveSession",async r=>{const{sessionTopic:i,pairingProposalResponse:n,proposal:s,sessionSettleRequest:o,publishOpts:a}=r,c=ln(s.id,n),u=await this.client.core.crypto.encode(s.pairingTopic,c,{encoding:Ze}),l=St("wc_sessionSettle",o,a?.id),h=await this.client.core.crypto.encode(i,l,{encoding:Ze});this.client.core.history.set(i,l),await this.client.core.relayer.publishCustom({payload:{sessionTopic:i,pairingTopic:s.pairingTopic,sessionProposalResponse:u,sessionSettlementRequest:h},opts:Fe(ne({},a),{publishMethod:"wc_approveSession"})})}),M(this,"sendResult",async r=>{const{id:i,topic:n,result:s,throwOnFailedPublish:o,encodeOpts:a,appLink:c}=r,u=ln(i,s);let l;const h=c&&typeof(global==null?void 0:global.Linking)<"u";try{const p=h?xr:Ze;l=await this.client.core.crypto.encode(n,u,Fe(ne({},a||{}),{encoding:p}))}catch(p){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${n} failed`),p}let f,g;try{f=await this.client.core.history.get(n,i);const p=f.request;try{g=this.getTVFParams(i,p.params,s)}catch(y){this.client.logger.warn(`sendResult() -> getTVFParams() failed: ${y?.message}`)}}catch(p){throw this.client.logger.error(`sendResult() -> history.get(${n}, ${i}) failed`),p}if(h){const p=kn(c,n,l);await global.Linking.openURL(p,this.client.name)}else{const p=f.request.method,y=Ce[p].res;y.tvf=Fe(ne({},g),{correlationId:i}),o?(y.internal=Fe(ne({},y.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(n,l,y)):this.client.core.relayer.publish(n,l,y).catch(m=>this.client.logger.error(m))}await this.client.core.history.resolve(u)}),M(this,"sendError",async r=>{const{id:i,topic:n,error:s,encodeOpts:o,rpcOpts:a,appLink:c}=r,u=Us(i,s);let l;const h=c&&typeof(global==null?void 0:global.Linking)<"u";try{const g=h?xr:Ze;l=await this.client.core.crypto.encode(n,u,Fe(ne({},o||{}),{encoding:g}))}catch(g){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${n} failed`),g}let f;try{f=await this.client.core.history.get(n,i)}catch(g){throw this.client.logger.error(`sendError() -> history.get(${n}, ${i}) failed`),g}if(h){const g=kn(c,n,l);await global.Linking.openURL(g,this.client.name)}else{const g=f.request.method,p=a||Ce[g].res;this.client.core.relayer.publish(n,l,p)}await this.client.core.history.resolve(u)}),M(this,"cleanup",async()=>{const r=[],i=[];this.client.session.getAll().forEach(n=>{let s=!1;kt(n.expiry)&&(s=!0),this.client.core.crypto.keychain.has(n.topic)||(s=!0),s&&r.push(n.topic)}),this.client.proposal.getAll().forEach(n=>{kt(n.expiryTimestamp)&&i.push(n.id)}),await Promise.all([...r.map(n=>this.deleteSession({topic:n})),...i.map(n=>this.deleteProposal(n))])}),M(this,"onProviderMessageEvent",async r=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(r):await this.onRelayMessage(r)}),M(this,"onRelayEventRequest",async r=>{this.requestQueue.queue.push(r),await this.processRequestsQueue()}),M(this,"processRequestsQueue",async()=>{if(this.requestQueue.state===Tt.active){this.client.logger.info("Request queue already active, skipping...");return}for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=Tt.active;const r=this.requestQueue.queue.shift();if(r)try{await this.processRequest(r)}catch(i){this.client.logger.warn(i)}}this.requestQueue.state=Tt.idle}),M(this,"processRequest",async r=>{const{topic:i,payload:n,attestation:s,transportType:o,encryptedId:a}=r,c=n.method;if(!this.shouldIgnorePairingRequest({topic:i,requestMethod:c}))switch(c){case"wc_sessionPropose":return await this.onSessionProposeRequest({topic:i,payload:n,attestation:s,encryptedId:a});case"wc_sessionSettle":return await this.onSessionSettleRequest(i,n);case"wc_sessionUpdate":return await this.onSessionUpdateRequest(i,n);case"wc_sessionExtend":return await this.onSessionExtendRequest(i,n);case"wc_sessionPing":return await this.onSessionPingRequest(i,n);case"wc_sessionDelete":return await this.onSessionDeleteRequest(i,n);case"wc_sessionRequest":return await this.onSessionRequest({topic:i,payload:n,attestation:s,encryptedId:a,transportType:o});case"wc_sessionEvent":return await this.onSessionEventRequest(i,n);case"wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:i,payload:n,attestation:s,encryptedId:a,transportType:o});default:return this.client.logger.info(`Unsupported request method ${c}`)}}),M(this,"onRelayEventResponse",async r=>{const{topic:i,payload:n,transportType:s}=r,o=(await this.client.core.history.get(i,n.id)).request.method;switch(o){case"wc_sessionPropose":return this.onSessionProposeResponse(i,n,s);case"wc_sessionSettle":return this.onSessionSettleResponse(i,n);case"wc_sessionUpdate":return this.onSessionUpdateResponse(i,n);case"wc_sessionExtend":return this.onSessionExtendResponse(i,n);case"wc_sessionPing":return this.onSessionPingResponse(i,n);case"wc_sessionRequest":return this.onSessionRequestResponse(i,n);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(i,n);default:return this.client.logger.info(`Unsupported response method ${o}`)}}),M(this,"onRelayEventUnknownPayload",r=>{const{topic:i}=r,{message:n}=z("MISSING_OR_INVALID",`Decoded payload on topic ${i} is not identifiable as a JSON-RPC request or a response.`);throw new Error(n)}),M(this,"shouldIgnorePairingRequest",r=>{const{topic:i,requestMethod:n}=r,s=this.expectedPairingMethodMap.get(i);return!s||s.includes(n)?!1:!!(s.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0)}),M(this,"onSessionProposeRequest",async r=>{const{topic:i,payload:n,attestation:s,encryptedId:o}=r,{params:a,id:c}=n;try{const u=this.client.core.eventClient.getEvent({topic:i});this.client.events.listenerCount("session_proposal")===0&&(console.warn("No listener for session_proposal event"),u?.setError(Jt.proposal_listener_not_found)),this.isValidConnect(ne({},n.params));const l=a.expiryTimestamp||we(Ce.wc_sessionPropose.req.ttl),h=ne({id:c,pairingTopic:i,expiryTimestamp:l,attestation:s,encryptedId:o},a);await this.setProposal(c,h);const f=await this.getVerifyContext({attestationId:s,hash:yt(JSON.stringify(n)),encryptedId:o,metadata:h.proposer.metadata});u?.addTrace(Rt.emit_session_proposal),this.client.events.emit("session_proposal",{id:c,params:h,verifyContext:f})}catch(u){await this.sendError({id:c,topic:i,error:u,rpcOpts:Ce.wc_sessionPropose.autoReject}),this.client.logger.error(u)}}),M(this,"onSessionProposeResponse",async(r,i,n)=>{const{id:s}=i;if(Nt(i)){const{result:o}=i;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:o});const a=this.client.proposal.get(s);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:a});const c=a.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:c});const u=o.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:u});const l=await this.client.core.crypto.generateSharedKey(c,u);this.pendingSessions.set(s,{sessionTopic:l,pairingTopic:r,proposalId:s,publicKey:c});const h=await this.client.core.relayer.subscribe(l,{transportType:n});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:h}),await this.client.core.pairing.activate({topic:r})}else if(wt(i)){await this.deleteProposal(s);const o=ie("session_connect",s);if(this.events.listenerCount(o)===0)throw new Error(`emitting ${o} without any listeners, 954`);this.events.emit(o,{error:i.error})}}),M(this,"onSessionSettleRequest",async(r,i)=>{const{id:n,params:s}=i;try{this.isValidSessionSettleRequest(s);const{relay:o,controller:a,expiry:c,namespaces:u,sessionProperties:l,scopedProperties:h,sessionConfig:f}=i.params,g=[...this.pendingSessions.values()].find(m=>m.sessionTopic===r);if(!g)return this.client.logger.error(`Pending session not found for topic ${r}`);const p=this.client.proposal.get(g.proposalId),y=Fe(ne(ne(ne({topic:r,relay:o,expiry:c,namespaces:u,acknowledged:!0,pairingTopic:g.pairingTopic,requiredNamespaces:p.requiredNamespaces,optionalNamespaces:p.optionalNamespaces,controller:a.publicKey,self:{publicKey:g.publicKey,metadata:this.client.metadata},peer:{publicKey:a.publicKey,metadata:a.metadata}},l&&{sessionProperties:l}),h&&{scopedProperties:h}),f&&{sessionConfig:f}),{transportType:ue.relay});await this.client.session.set(y.topic,y),await this.setExpiry(y.topic,y.expiry),await this.client.core.pairing.updateMetadata({topic:g.pairingTopic,metadata:y.peer.metadata}),this.client.events.emit("session_connect",{session:y}),this.events.emit(ie("session_connect",g.proposalId),{session:y}),this.pendingSessions.delete(g.proposalId),this.deleteProposal(g.proposalId,!1),this.cleanupDuplicatePairings(y),await this.sendResult({id:i.id,topic:r,result:!0})}catch(o){await this.sendError({id:n,topic:r,error:o}),this.client.logger.error(o)}}),M(this,"onSessionSettleResponse",async(r,i)=>{const{id:n}=i;Nt(i)?(await this.client.session.update(r,{acknowledged:!0}),this.events.emit(ie("session_approve",n),{})):wt(i)&&(await this.client.session.delete(r,le("USER_DISCONNECTED")),this.events.emit(ie("session_approve",n),{error:i.error}))}),M(this,"onSessionUpdateRequest",async(r,i)=>{const{params:n,id:s}=i;try{const o=`${r}_session_update`,a=Fi.get(o);if(a&&this.isRequestOutOfSync(a,s)){this.client.logger.warn(`Discarding out of sync request - ${s}`),this.sendError({id:s,topic:r,error:le("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(ne({topic:r},n));try{Fi.set(o,s),await this.client.session.update(r,{namespaces:n.namespaces}),await this.sendResult({id:s,topic:r,result:!0})}catch(c){throw Fi.delete(o),c}this.client.events.emit("session_update",{id:s,topic:r,params:n})}catch(o){await this.sendError({id:s,topic:r,error:o}),this.client.logger.error(o)}}),M(this,"isRequestOutOfSync",(r,i)=>i.toString().slice(0,-3)<r.toString().slice(0,-3)),M(this,"onSessionUpdateResponse",(r,i)=>{const{id:n}=i,s=ie("session_update",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);Nt(i)?this.events.emit(ie("session_update",n),{}):wt(i)&&this.events.emit(ie("session_update",n),{error:i.error})}),M(this,"onSessionExtendRequest",async(r,i)=>{const{id:n}=i;try{this.isValidExtend({topic:r}),await this.setExpiry(r,we(li)),await this.sendResult({id:n,topic:r,result:!0}),this.client.events.emit("session_extend",{id:n,topic:r})}catch(s){await this.sendError({id:n,topic:r,error:s}),this.client.logger.error(s)}}),M(this,"onSessionExtendResponse",(r,i)=>{const{id:n}=i,s=ie("session_extend",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);Nt(i)?this.events.emit(ie("session_extend",n),{}):wt(i)&&this.events.emit(ie("session_extend",n),{error:i.error})}),M(this,"onSessionPingRequest",async(r,i)=>{const{id:n}=i;try{this.isValidPing({topic:r}),await this.sendResult({id:n,topic:r,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:n,topic:r})}catch(s){await this.sendError({id:n,topic:r,error:s}),this.client.logger.error(s)}}),M(this,"onSessionPingResponse",(r,i)=>{const{id:n}=i,s=ie("session_ping",n);setTimeout(()=>{if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners 2176`);Nt(i)?this.events.emit(ie("session_ping",n),{}):wt(i)&&this.events.emit(ie("session_ping",n),{error:i.error})},500)}),M(this,"onSessionDeleteRequest",async(r,i)=>{const{id:n}=i;try{this.isValidDisconnect({topic:r,reason:i.params}),await Promise.all([new Promise(s=>{this.client.core.relayer.once(de.publish,async()=>{s(await this.deleteSession({topic:r,id:n}))})}),this.sendResult({id:n,topic:r,result:!0}),this.cleanupPendingSentRequestsForTopic({topic:r,error:le("USER_DISCONNECTED")})]).catch(s=>this.client.logger.error(s))}catch(s){this.client.logger.error(s)}}),M(this,"onSessionRequest",async r=>{var i,n,s;const{topic:o,payload:a,attestation:c,encryptedId:u,transportType:l}=r,{id:h,params:f}=a;try{await this.isValidRequest(ne({topic:o},f));const g=this.client.session.get(o),p=await this.getVerifyContext({attestationId:c,hash:yt(JSON.stringify(St("wc_sessionRequest",f,h))),encryptedId:u,metadata:g.peer.metadata,transportType:l}),y={id:h,topic:o,params:f,verifyContext:p};await this.setPendingSessionRequest(y),l===ue.link_mode&&(i=g.peer.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp((n=g.peer.metadata.redirect)==null?void 0:n.universal),(s=this.client.signConfig)!=null&&s.disableRequestQueue?this.emitSessionRequest(y):(this.addSessionRequestToSessionRequestQueue(y),this.processSessionRequestQueue())}catch(g){await this.sendError({id:h,topic:o,error:g}),this.client.logger.error(g)}}),M(this,"onSessionRequestResponse",(r,i)=>{const{id:n}=i,s=ie("session_request",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);Nt(i)?this.events.emit(ie("session_request",n),{result:i.result}):wt(i)&&this.events.emit(ie("session_request",n),{error:i.error})}),M(this,"onSessionEventRequest",async(r,i)=>{const{id:n,params:s}=i;try{const o=`${r}_session_event_${s.event.name}`,a=Fi.get(o);if(a&&this.isRequestOutOfSync(a,n)){this.client.logger.info(`Discarding out of sync request - ${n}`);return}this.isValidEmit(ne({topic:r},s)),this.client.events.emit("session_event",{id:n,topic:r,params:s}),Fi.set(o,n)}catch(o){await this.sendError({id:n,topic:r,error:o}),this.client.logger.error(o)}}),M(this,"onSessionAuthenticateResponse",(r,i)=>{const{id:n}=i;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:r,payload:i}),Nt(i)?this.events.emit(ie("session_request",n),{result:i.result}):wt(i)&&this.events.emit(ie("session_request",n),{error:i.error})}),M(this,"onSessionAuthenticateRequest",async r=>{var i;const{topic:n,payload:s,attestation:o,encryptedId:a,transportType:c}=r;try{const{requester:u,authPayload:l,expiryTimestamp:h}=s.params,f=await this.getVerifyContext({attestationId:o,hash:yt(JSON.stringify(s)),encryptedId:a,metadata:u.metadata,transportType:c}),g={requester:u,pairingTopic:n,id:s.id,authPayload:l,verifyContext:f,expiryTimestamp:h};await this.setAuthRequest(s.id,{request:g,pairingTopic:n,transportType:c}),c===ue.link_mode&&(i=u.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp(u.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:n,params:s.params,id:s.id,verifyContext:f})}catch(u){this.client.logger.error(u);const l=s.params.requester.publicKey,h=await this.client.core.crypto.generateKeyPair(),f=this.getAppLinkIfEnabled(s.params.requester.metadata,c),g={type:nr,receiverPublicKey:l,senderPublicKey:h};await this.sendError({id:s.id,topic:n,error:u,encodeOpts:g,rpcOpts:Ce.wc_sessionAuthenticate.autoReject,appLink:f})}}),M(this,"addSessionRequestToSessionRequestQueue",r=>{this.sessionRequestQueue.queue.push(r)}),M(this,"cleanupAfterResponse",r=>{this.deletePendingSessionRequest(r.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=Tt.idle,this.processSessionRequestQueue()},V.toMiliseconds(this.requestQueueDelay))}),M(this,"cleanupPendingSentRequestsForTopic",({topic:r,error:i})=>{const n=this.client.core.history.pending;n.length>0&&n.filter(s=>s.topic===r&&s.request.method==="wc_sessionRequest").forEach(s=>{const o=s.request.id,a=ie("session_request",o);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);this.events.emit(ie("session_request",s.request.id),{error:i})})}),M(this,"processSessionRequestQueue",()=>{if(this.sessionRequestQueue.state===Tt.active){this.client.logger.info("session request queue is already active.");return}const r=this.sessionRequestQueue.queue[0];if(!r){this.client.logger.info("session request queue is empty.");return}try{this.emitSessionRequest(r)}catch(i){this.client.logger.error(i)}}),M(this,"emitSessionRequest",r=>{if(this.emittedSessionRequests.has(r.id)){this.client.logger.warn({id:r.id},`Skipping emitting \`session_request\` event for duplicate request. id: ${r.id}`);return}this.sessionRequestQueue.state=Tt.active,this.emittedSessionRequests.add(r.id),this.client.events.emit("session_request",r)}),M(this,"onPairingCreated",r=>{if(r.methods&&this.expectedPairingMethodMap.set(r.topic,r.methods),r.active)return;const i=this.client.proposal.getAll().find(n=>n.pairingTopic===r.topic);i&&this.onSessionProposeRequest({topic:r.topic,payload:St("wc_sessionPropose",Fe(ne({},i),{requiredNamespaces:i.requiredNamespaces,optionalNamespaces:i.optionalNamespaces,relays:i.relays,proposer:i.proposer,sessionProperties:i.sessionProperties,scopedProperties:i.scopedProperties}),i.id),attestation:i.attestation,encryptedId:i.encryptedId})}),M(this,"isValidConnect",async r=>{if(!We(r)){const{message:u}=z("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(r)}`);throw new Error(u)}const{pairingTopic:i,requiredNamespaces:n,optionalNamespaces:s,sessionProperties:o,scopedProperties:a,relays:c}=r;if(Ee(i)||await this.isValidPairingTopic(i),!s8(c)){const{message:u}=z("MISSING_OR_INVALID",`connect() relays: ${c}`);throw new Error(u)}if(n&&!Ee(n)&&Mt(n)!==0){const u="requiredNamespaces are deprecated and are automatically assigned to optionalNamespaces";["fatal","error","silent"].includes(this.client.logger.level)?console.warn(u):this.client.logger.warn(u),this.validateNamespaces(n,"requiredNamespaces")}if(s&&!Ee(s)&&Mt(s)!==0&&this.validateNamespaces(s,"optionalNamespaces"),o&&!Ee(o)&&this.validateSessionProps(o,"sessionProperties"),a&&!Ee(a)){this.validateSessionProps(a,"scopedProperties");const u=Object.keys(n||{}).concat(Object.keys(s||{}));if(!Object.keys(a).every(l=>u.includes(l.split(":")[0])))throw new Error(`Scoped properties must be a subset of required/optional namespaces, received: ${JSON.stringify(a)}, required/optional namespaces: ${JSON.stringify(u)}`)}}),M(this,"validateNamespaces",(r,i)=>{const n=n8(r,"connect()",i);if(n)throw new Error(n.message)}),M(this,"isValidApprove",async r=>{if(!We(r))throw new Error(z("MISSING_OR_INVALID",`approve() params: ${r}`).message);const{id:i,namespaces:n,relayProtocol:s,sessionProperties:o,scopedProperties:a}=r;this.checkRecentlyDeleted(i),await this.isValidProposalId(i);const c=this.client.proposal.get(i),u=Po(n,"approve()");if(u)throw new Error(u.message);const l=Jl(c.requiredNamespaces,n,"approve()");if(l)throw new Error(l.message);if(!be(s,!0)){const{message:h}=z("MISSING_OR_INVALID",`approve() relayProtocol: ${s}`);throw new Error(h)}if(o&&!Ee(o)&&this.validateSessionProps(o,"sessionProperties"),a&&!Ee(a)){this.validateSessionProps(a,"scopedProperties");const h=new Set(Object.keys(n));if(!Object.keys(a).every(f=>h.has(f.split(":")[0])))throw new Error(`Scoped properties must be a subset of approved namespaces, received: ${JSON.stringify(a)}, approved namespaces: ${Array.from(h).join(", ")}`)}}),M(this,"isValidReject",async r=>{if(!We(r)){const{message:s}=z("MISSING_OR_INVALID",`reject() params: ${r}`);throw new Error(s)}const{id:i,reason:n}=r;if(this.checkRecentlyDeleted(i),await this.isValidProposalId(i),!a8(n)){const{message:s}=z("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(n)}`);throw new Error(s)}}),M(this,"isValidSessionSettleRequest",r=>{if(!We(r)){const{message:u}=z("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${r}`);throw new Error(u)}const{relay:i,controller:n,namespaces:s,expiry:o}=r;if(!Jp(i)){const{message:u}=z("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(u)}const a=Xx(n,"onSessionSettleRequest()");if(a)throw new Error(a.message);const c=Po(s,"onSessionSettleRequest()");if(c)throw new Error(c.message);if(kt(o)){const{message:u}=z("EXPIRED","onSessionSettleRequest()");throw new Error(u)}}),M(this,"isValidUpdate",async r=>{if(!We(r)){const{message:c}=z("MISSING_OR_INVALID",`update() params: ${r}`);throw new Error(c)}const{topic:i,namespaces:n}=r;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);const s=this.client.session.get(i),o=Po(n,"update()");if(o)throw new Error(o.message);const a=Jl(s.requiredNamespaces,n,"update()");if(a)throw new Error(a.message)}),M(this,"isValidExtend",async r=>{if(!We(r)){const{message:n}=z("MISSING_OR_INVALID",`extend() params: ${r}`);throw new Error(n)}const{topic:i}=r;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i)}),M(this,"isValidRequest",async r=>{if(!We(r)){const{message:c}=z("MISSING_OR_INVALID",`request() params: ${r}`);throw new Error(c)}const{topic:i,request:n,chainId:s,expiry:o}=r;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);const{namespaces:a}=this.client.session.get(i);if(!Zl(a,s)){const{message:c}=z("MISSING_OR_INVALID",`request() chainId: ${s}`);throw new Error(c)}if(!c8(n)){const{message:c}=z("MISSING_OR_INVALID",`request() ${JSON.stringify(n)}`);throw new Error(c)}if(!h8(a,s,n.method)){const{message:c}=z("MISSING_OR_INVALID",`request() method: ${n.method}`);throw new Error(c)}if(o&&!g8(o,Lo)){const{message:c}=z("MISSING_OR_INVALID",`request() expiry: ${o}. Expiry must be a number (in seconds) between ${Lo.min} and ${Lo.max}`);throw new Error(c)}}),M(this,"isValidRespond",async r=>{var i;if(!We(r)){const{message:a}=z("MISSING_OR_INVALID",`respond() params: ${r}`);throw new Error(a)}const{topic:n,response:s}=r;try{await this.isValidSessionTopic(n)}catch(a){throw(i=r?.response)!=null&&i.id&&this.cleanupAfterResponse(r),a}if(!u8(s)){const{message:a}=z("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(s)}`);throw new Error(a)}const o=this.client.pendingRequest.get(s.id);if(o.topic!==n){const{message:a}=z("MISMATCHED_TOPIC",`Request response topic mismatch. reqId: ${s.id}, expected topic: ${o.topic}, received topic: ${n}`);throw new Error(a)}}),M(this,"isValidPing",async r=>{if(!We(r)){const{message:n}=z("MISSING_OR_INVALID",`ping() params: ${r}`);throw new Error(n)}const{topic:i}=r;await this.isValidSessionOrPairingTopic(i)}),M(this,"isValidEmit",async r=>{if(!We(r)){const{message:a}=z("MISSING_OR_INVALID",`emit() params: ${r}`);throw new Error(a)}const{topic:i,event:n,chainId:s}=r;await this.isValidSessionTopic(i);const{namespaces:o}=this.client.session.get(i);if(!Zl(o,s)){const{message:a}=z("MISSING_OR_INVALID",`emit() chainId: ${s}`);throw new Error(a)}if(!l8(n)){const{message:a}=z("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(a)}if(!f8(o,s,n.name)){const{message:a}=z("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(a)}}),M(this,"isValidDisconnect",async r=>{if(!We(r)){const{message:n}=z("MISSING_OR_INVALID",`disconnect() params: ${r}`);throw new Error(n)}const{topic:i}=r;await this.isValidSessionOrPairingTopic(i)}),M(this,"isValidAuthenticate",r=>{const{chains:i,uri:n,domain:s,nonce:o}=r;if(!Array.isArray(i)||i.length===0)throw new Error("chains is required and must be a non-empty array");if(!be(n,!1))throw new Error("uri is required parameter");if(!be(s,!1))throw new Error("domain is required parameter");if(!be(o,!1))throw new Error("nonce is required parameter");if([...new Set(i.map(c=>ir(c).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");const{namespace:a}=ir(i[0]);if(a!=="eip155")throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")}),M(this,"getVerifyContext",async r=>{const{attestationId:i,hash:n,encryptedId:s,metadata:o,transportType:a}=r,c={verified:{verifyUrl:o.verifyUrl||Qi,validation:"UNKNOWN",origin:o.url||""}};try{if(a===ue.link_mode){const l=this.getAppLinkIfEnabled(o,a);return c.verified.validation=l&&new URL(l).origin===new URL(o.url).origin?"VALID":"INVALID",c}const u=await this.client.core.verify.resolve({attestationId:i,hash:n,encryptedId:s,verifyUrl:o.verifyUrl});u&&(c.verified.origin=u.origin,c.verified.isScam=u.isScam,c.verified.validation=u.origin===new URL(o.url).origin?"VALID":"INVALID")}catch(u){this.client.logger.warn(u)}return this.client.logger.debug(`Verify context: ${JSON.stringify(c)}`),c}),M(this,"validateSessionProps",(r,i)=>{Object.values(r).forEach((n,s)=>{if(n==null){const{message:o}=z("MISSING_OR_INVALID",`${i} must contain an existing value for each key. Received: ${n} for key ${Object.keys(r)[s]}`);throw new Error(o)}})}),M(this,"getPendingAuthRequest",r=>{const i=this.client.auth.requests.get(r);return typeof i=="object"?i:void 0}),M(this,"addToRecentlyDeleted",(r,i)=>{if(this.recentlyDeletedMap.set(r,i),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let n=0;const s=this.recentlyDeletedLimit/2;for(const o of this.recentlyDeletedMap.keys()){if(n++>=s)break;this.recentlyDeletedMap.delete(o)}}}),M(this,"checkRecentlyDeleted",r=>{const i=this.recentlyDeletedMap.get(r);if(i){const{message:n}=z("MISSING_OR_INVALID",`Record was recently deleted - ${i}: ${r}`);throw new Error(n)}}),M(this,"isLinkModeEnabled",(r,i)=>{var n,s,o,a,c,u,l,h,f;return!r||i!==ue.link_mode?!1:((s=(n=this.client.metadata)==null?void 0:n.redirect)==null?void 0:s.linkMode)===!0&&((a=(o=this.client.metadata)==null?void 0:o.redirect)==null?void 0:a.universal)!==void 0&&((u=(c=this.client.metadata)==null?void 0:c.redirect)==null?void 0:u.universal)!==""&&((l=r?.redirect)==null?void 0:l.universal)!==void 0&&((h=r?.redirect)==null?void 0:h.universal)!==""&&((f=r?.redirect)==null?void 0:f.linkMode)===!0&&this.client.core.linkModeSupportedApps.includes(r.redirect.universal)&&typeof(global==null?void 0:global.Linking)<"u"}),M(this,"getAppLinkIfEnabled",(r,i)=>{var n;return this.isLinkModeEnabled(r,i)?(n=r?.redirect)==null?void 0:n.universal:void 0}),M(this,"handleLinkModeMessage",({url:r})=>{if(!r||!r.includes("wc_ev")||!r.includes("topic"))return;const i=cl(r,"topic")||"",n=decodeURIComponent(cl(r,"wc_ev")||""),s=this.client.session.keys.includes(i);s&&this.client.session.update(i,{transportType:ue.link_mode}),this.client.core.dispatchEnvelope({topic:i,message:n,sessionExists:s})}),M(this,"registerLinkModeListeners",async()=>{var r;if(dc()||Ar()&&(r=this.client.metadata.redirect)!=null&&r.linkMode){const i=global==null?void 0:global.Linking;if(typeof i<"u"){i.addEventListener("url",this.handleLinkModeMessage,this.client.name);const n=await i.getInitialURL();n&&setTimeout(()=>{this.handleLinkModeMessage({url:n})},50)}}}),M(this,"getTVFParams",(r,i,n)=>{var s,o,a;if(!((s=i.request)!=null&&s.method))return{};const c={correlationId:r,rpcMethods:[i.request.method],chainId:i.chainId};try{const u=this.extractTxHashesFromResult(i.request,n);c.txHashes=u,c.contractAddresses=this.isValidContractData(i.request.params)?[(a=(o=i.request.params)==null?void 0:o[0])==null?void 0:a.to]:[]}catch(u){this.client.logger.warn(u,"Error getting TVF params")}return c}),M(this,"isValidContractData",r=>{var i;if(!r)return!1;try{const n=r?.data||((i=r?.[0])==null?void 0:i.data);if(!n.startsWith("0x"))return!1;const s=n.slice(2);return/^[0-9a-fA-F]*$/.test(s)?s.length%2===0:!1}catch{}return!1}),M(this,"extractTxHashesFromResult",(r,i)=>{var n;try{if(!i)return[];const s=r.method,o=e6[s];if(s==="sui_signTransaction")return[P3(i.transactionBytes)];if(s==="near_signTransaction")return[yl(i)];if(s==="near_signTransactions")return i.map(c=>yl(c));if(s==="xrpl_signTransactionFor"||s==="xrpl_signTransaction")return[(n=i.tx_json)==null?void 0:n.hash];if(s==="polkadot_signTransaction")return[C8({transaction:r.params.transactionPayload,signature:i.signature})];if(s==="algo_signTxn")return mt(i)?i.map(c=>wl(c)):[wl(i)];if(s==="cosmos_signDirect")return[T3(i)];if(s==="wallet_sendCalls")return R3(i);if(typeof i=="string")return[i];const a=i[o.key];if(mt(a))return s==="solana_signAllTransactions"?a.map(c=>C3(c)):a;if(typeof a=="string")return[a]}catch(s){this.client.logger.warn(s,"Error extracting tx hashes from result")}return[]})}async processPendingMessageEvents(){try{const e=this.client.session.keys,r=this.client.core.relayer.messages.getWithoutAck(e);for(const[i,n]of Object.entries(r))for(const s of n)try{await this.onProviderMessageEvent({topic:i,message:s,publishedAt:Date.now()})}catch{this.client.logger.warn(`Error processing pending message event for topic: ${i}, message: ${s}`)}}catch(e){this.client.logger.warn(e,"processPendingMessageEvents failed")}}isInitialized(){if(!this.initialized){const{message:e}=z("NOT_INITIALIZED",this.name);throw new Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(de.message,e=>{this.onProviderMessageEvent(e)})}async onRelayMessage(e){const{topic:r,message:i,attestation:n,transportType:s}=e,{publicKey:o}=this.client.auth.authKeys.keys.includes(Xn)?this.client.auth.authKeys.get(Xn):{publicKey:void 0};try{const a=await this.client.core.crypto.decode(r,i,{receiverPublicKey:o,encoding:s===ue.link_mode?xr:Ze});Oc(a)?(this.client.core.history.set(r,a),await this.onRelayEventRequest({topic:r,payload:a,attestation:n,transportType:s,encryptedId:yt(i)})):Ns(a)?(await this.client.core.history.resolve(a),await this.onRelayEventResponse({topic:r,payload:a,transportType:s}),this.client.core.history.delete(r,a.id)):await this.onRelayEventUnknownPayload({topic:r,payload:a,transportType:s}),await this.client.core.relayer.messages.ack(r,i)}catch(a){this.client.logger.error(a)}}registerExpirerEvents(){this.client.core.expirer.on(pt.expired,async e=>{const{topic:r,id:i}=Xd(e.target);if(i&&this.client.pendingRequest.keys.includes(i))return await this.deletePendingSessionRequest(i,z("EXPIRED"),!0);if(i&&this.client.auth.requests.keys.includes(i))return await this.deletePendingAuthRequest(i,z("EXPIRED"),!0);r?this.client.session.keys.includes(r)&&(await this.deleteSession({topic:r,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:r})):i&&(await this.deleteProposal(i,!0),this.client.events.emit("proposal_expire",{id:i}))})}registerPairingEvents(){this.client.core.pairing.events.on(Lr.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(Lr.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!be(e,!1)){const{message:r}=z("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(r)}if(!this.client.core.pairing.pairings.keys.includes(e)){const{message:r}=z("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(r)}if(kt(this.client.core.pairing.pairings.get(e).expiry)){const{message:r}=z("EXPIRED",`pairing topic: ${e}`);throw new Error(r)}}async isValidSessionTopic(e){if(!be(e,!1)){const{message:r}=z("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(r)}if(this.checkRecentlyDeleted(e),!this.client.session.keys.includes(e)){const{message:r}=z("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(r)}if(kt(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});const{message:r}=z("EXPIRED",`session topic: ${e}`);throw new Error(r)}if(!this.client.core.crypto.keychain.has(e)){const{message:r}=z("MISSING_OR_INVALID",`session topic does not exist in keychain: ${e}`);throw await this.deleteSession({topic:e}),new Error(r)}}async isValidSessionOrPairingTopic(e){if(this.checkRecentlyDeleted(e),this.client.session.keys.includes(e))await this.isValidSessionTopic(e);else if(this.client.core.pairing.pairings.keys.includes(e))this.isValidPairingTopic(e);else if(be(e,!1)){const{message:r}=z("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(r)}else{const{message:r}=z("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(r)}}async isValidProposalId(e){if(!o8(e)){const{message:r}=z("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(r)}if(!this.client.proposal.keys.includes(e)){const{message:r}=z("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(r)}if(kt(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);const{message:r}=z("EXPIRED",`proposal id: ${e}`);throw new Error(r)}}}class p6 extends ti{constructor(e,r){super(e,r,J$,$c),this.core=e,this.logger=r}}let g6=class extends ti{constructor(e,r){super(e,r,X$,$c),this.core=e,this.logger=r}};class y6 extends ti{constructor(e,r){super(e,r,t6,$c,i=>i.id),this.core=e,this.logger=r}}class w6 extends ti{constructor(e,r){super(e,r,s6,ks,()=>Xn),this.core=e,this.logger=r}}class b6 extends ti{constructor(e,r){super(e,r,o6,ks),this.core=e,this.logger=r}}class m6 extends ti{constructor(e,r){super(e,r,a6,ks,i=>i.id),this.core=e,this.logger=r}}var v6=Object.defineProperty,E6=(t,e,r)=>e in t?v6(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Mo=(t,e,r)=>E6(t,typeof e!="symbol"?e+"":e,r);class D6{constructor(e,r){this.core=e,this.logger=r,Mo(this,"authKeys"),Mo(this,"pairingTopics"),Mo(this,"requests"),this.authKeys=new w6(this.core,this.logger),this.pairingTopics=new b6(this.core,this.logger),this.requests=new m6(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}}var x6=Object.defineProperty,_6=(t,e,r)=>e in t?x6(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Q=(t,e,r)=>_6(t,typeof e!="symbol"?e+"":e,r);let I6=class Ag extends E_{constructor(e){super(e),Q(this,"protocol",Ig),Q(this,"version",Sg),Q(this,"name",Fo.name),Q(this,"metadata"),Q(this,"core"),Q(this,"logger"),Q(this,"events",new ct.EventEmitter),Q(this,"engine"),Q(this,"session"),Q(this,"proposal"),Q(this,"pendingRequest"),Q(this,"auth"),Q(this,"signConfig"),Q(this,"on",(i,n)=>this.events.on(i,n)),Q(this,"once",(i,n)=>this.events.once(i,n)),Q(this,"off",(i,n)=>this.events.off(i,n)),Q(this,"removeListener",(i,n)=>this.events.removeListener(i,n)),Q(this,"removeAllListeners",i=>this.events.removeAllListeners(i)),Q(this,"connect",async i=>{try{return await this.engine.connect(i)}catch(n){throw this.logger.error(n.message),n}}),Q(this,"pair",async i=>{try{return await this.engine.pair(i)}catch(n){throw this.logger.error(n.message),n}}),Q(this,"approve",async i=>{try{return await this.engine.approve(i)}catch(n){throw this.logger.error(n.message),n}}),Q(this,"reject",async i=>{try{return await this.engine.reject(i)}catch(n){throw this.logger.error(n.message),n}}),Q(this,"update",async i=>{try{return await this.engine.update(i)}catch(n){throw this.logger.error(n.message),n}}),Q(this,"extend",async i=>{try{return await this.engine.extend(i)}catch(n){throw this.logger.error(n.message),n}}),Q(this,"request",async i=>{try{return await this.engine.request(i)}catch(n){throw this.logger.error(n.message),n}}),Q(this,"respond",async i=>{try{return await this.engine.respond(i)}catch(n){throw this.logger.error(n.message),n}}),Q(this,"ping",async i=>{try{return await this.engine.ping(i)}catch(n){throw this.logger.error(n.message),n}}),Q(this,"emit",async i=>{try{return await this.engine.emit(i)}catch(n){throw this.logger.error(n.message),n}}),Q(this,"disconnect",async i=>{try{return await this.engine.disconnect(i)}catch(n){throw this.logger.error(n.message),n}}),Q(this,"find",i=>{try{return this.engine.find(i)}catch(n){throw this.logger.error(n.message),n}}),Q(this,"getPendingSessionRequests",()=>{try{return this.engine.getPendingSessionRequests()}catch(i){throw this.logger.error(i.message),i}}),Q(this,"authenticate",async(i,n)=>{try{return await this.engine.authenticate(i,n)}catch(s){throw this.logger.error(s.message),s}}),Q(this,"formatAuthMessage",i=>{try{return this.engine.formatAuthMessage(i)}catch(n){throw this.logger.error(n.message),n}}),Q(this,"approveSessionAuthenticate",async i=>{try{return await this.engine.approveSessionAuthenticate(i)}catch(n){throw this.logger.error(n.message),n}}),Q(this,"rejectSessionAuthenticate",async i=>{try{return await this.engine.rejectSessionAuthenticate(i)}catch(n){throw this.logger.error(n.message),n}}),this.name=e?.name||Fo.name,this.metadata=xE(e?.metadata),this.signConfig=e?.signConfig;const r=Ic({logger:e?.logger||Fo.logger,name:this.name});this.logger=r,this.core=e?.core||new Z$(e),this.session=new g6(this.core,this.logger),this.proposal=new p6(this.core,this.logger),this.pendingRequest=new y6(this.core,this.logger),this.engine=new d6(this),this.auth=new D6(this.core,this.logger)}static async init(e){const r=new Ag(e);return await r.initialize(),r}get context(){return Qe(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.auth.init(),await this.engine.init(),this.logger.info("SignClient Initialization Success")}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}};const S6=I6;var Ln={exports:{}},zh;function O6(){return zh||(zh=1,(function(t,e){var r=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof jt<"u"&&jt,i=(function(){function s(){this.fetch=!1,this.DOMException=r.DOMException}return s.prototype=r,new s})();(function(s){(function(o){var a=typeof s<"u"&&s||typeof self<"u"&&self||typeof jt<"u"&&jt||{},c={searchParams:"URLSearchParams"in a,iterable:"Symbol"in a&&"iterator"in Symbol,blob:"FileReader"in a&&"Blob"in a&&(function(){try{return new Blob,!0}catch{return!1}})(),formData:"FormData"in a,arrayBuffer:"ArrayBuffer"in a};function u(d){return d&&DataView.prototype.isPrototypeOf(d)}if(c.arrayBuffer)var l=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],h=ArrayBuffer.isView||function(d){return d&&l.indexOf(Object.prototype.toString.call(d))>-1};function f(d){if(typeof d!="string"&&(d=String(d)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(d)||d==="")throw new TypeError('Invalid character in header field name: "'+d+'"');return d.toLowerCase()}function g(d){return typeof d!="string"&&(d=String(d)),d}function p(d){var w={next:function(){var D=d.shift();return{done:D===void 0,value:D}}};return c.iterable&&(w[Symbol.iterator]=function(){return w}),w}function y(d){this.map={},d instanceof y?d.forEach(function(w,D){this.append(D,w)},this):Array.isArray(d)?d.forEach(function(w){if(w.length!=2)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+w.length);this.append(w[0],w[1])},this):d&&Object.getOwnPropertyNames(d).forEach(function(w){this.append(w,d[w])},this)}y.prototype.append=function(d,w){d=f(d),w=g(w);var D=this.map[d];this.map[d]=D?D+", "+w:w},y.prototype.delete=function(d){delete this.map[f(d)]},y.prototype.get=function(d){return d=f(d),this.has(d)?this.map[d]:null},y.prototype.has=function(d){return this.map.hasOwnProperty(f(d))},y.prototype.set=function(d,w){this.map[f(d)]=g(w)},y.prototype.forEach=function(d,w){for(var D in this.map)this.map.hasOwnProperty(D)&&d.call(w,this.map[D],D,this)},y.prototype.keys=function(){var d=[];return this.forEach(function(w,D){d.push(D)}),p(d)},y.prototype.values=function(){var d=[];return this.forEach(function(w){d.push(w)}),p(d)},y.prototype.entries=function(){var d=[];return this.forEach(function(w,D){d.push([D,w])}),p(d)},c.iterable&&(y.prototype[Symbol.iterator]=y.prototype.entries);function m(d){if(!d._noBody){if(d.bodyUsed)return Promise.reject(new TypeError("Already read"));d.bodyUsed=!0}}function x(d){return new Promise(function(w,D){d.onload=function(){w(d.result)},d.onerror=function(){D(d.error)}})}function S(d){var w=new FileReader,D=x(w);return w.readAsArrayBuffer(d),D}function v(d){var w=new FileReader,D=x(w),O=/charset=([A-Za-z0-9_-]+)/.exec(d.type),_=O?O[1]:"utf-8";return w.readAsText(d,_),D}function b(d){for(var w=new Uint8Array(d),D=new Array(w.length),O=0;O<w.length;O++)D[O]=String.fromCharCode(w[O]);return D.join("")}function E(d){if(d.slice)return d.slice(0);var w=new Uint8Array(d.byteLength);return w.set(new Uint8Array(d)),w.buffer}function I(){return this.bodyUsed=!1,this._initBody=function(d){this.bodyUsed=this.bodyUsed,this._bodyInit=d,d?typeof d=="string"?this._bodyText=d:c.blob&&Blob.prototype.isPrototypeOf(d)?this._bodyBlob=d:c.formData&&FormData.prototype.isPrototypeOf(d)?this._bodyFormData=d:c.searchParams&&URLSearchParams.prototype.isPrototypeOf(d)?this._bodyText=d.toString():c.arrayBuffer&&c.blob&&u(d)?(this._bodyArrayBuffer=E(d.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):c.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(d)||h(d))?this._bodyArrayBuffer=E(d):this._bodyText=d=Object.prototype.toString.call(d):(this._noBody=!0,this._bodyText=""),this.headers.get("content-type")||(typeof d=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):c.searchParams&&URLSearchParams.prototype.isPrototypeOf(d)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},c.blob&&(this.blob=function(){var d=m(this);if(d)return d;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))}),this.arrayBuffer=function(){if(this._bodyArrayBuffer){var d=m(this);return d||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}else{if(c.blob)return this.blob().then(S);throw new Error("could not read as ArrayBuffer")}},this.text=function(){var d=m(this);if(d)return d;if(this._bodyBlob)return v(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(b(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},c.formData&&(this.formData=function(){return this.text().then(k)}),this.json=function(){return this.text().then(JSON.parse)},this}var $=["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"];function B(d){var w=d.toUpperCase();return $.indexOf(w)>-1?w:d}function C(d,w){if(!(this instanceof C))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');w=w||{};var D=w.body;if(d instanceof C){if(d.bodyUsed)throw new TypeError("Already read");this.url=d.url,this.credentials=d.credentials,w.headers||(this.headers=new y(d.headers)),this.method=d.method,this.mode=d.mode,this.signal=d.signal,!D&&d._bodyInit!=null&&(D=d._bodyInit,d.bodyUsed=!0)}else this.url=String(d);if(this.credentials=w.credentials||this.credentials||"same-origin",(w.headers||!this.headers)&&(this.headers=new y(w.headers)),this.method=B(w.method||this.method||"GET"),this.mode=w.mode||this.mode||null,this.signal=w.signal||this.signal||(function(){if("AbortController"in a){var A=new AbortController;return A.signal}})(),this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&D)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(D),(this.method==="GET"||this.method==="HEAD")&&(w.cache==="no-store"||w.cache==="no-cache")){var O=/([?&])_=[^&]*/;if(O.test(this.url))this.url=this.url.replace(O,"$1_="+new Date().getTime());else{var _=/\?/;this.url+=(_.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}C.prototype.clone=function(){return new C(this,{body:this._bodyInit})};function k(d){var w=new FormData;return d.trim().split("&").forEach(function(D){if(D){var O=D.split("="),_=O.shift().replace(/\+/g," "),A=O.join("=").replace(/\+/g," ");w.append(decodeURIComponent(_),decodeURIComponent(A))}}),w}function F(d){var w=new y,D=d.replace(/\r?\n[\t ]+/g," ");return D.split("\r").map(function(O){return O.indexOf(`
15
- `)===0?O.substr(1,O.length):O}).forEach(function(O){var _=O.split(":"),A=_.shift().trim();if(A){var N=_.join(":").trim();try{w.append(A,N)}catch(j){console.warn("Response "+j.message)}}}),w}I.call(C.prototype);function R(d,w){if(!(this instanceof R))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(w||(w={}),this.type="default",this.status=w.status===void 0?200:w.status,this.status<200||this.status>599)throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=w.statusText===void 0?"":""+w.statusText,this.headers=new y(w.headers),this.url=w.url||"",this._initBody(d)}I.call(R.prototype),R.prototype.clone=function(){return new R(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new y(this.headers),url:this.url})},R.error=function(){var d=new R(null,{status:200,statusText:""});return d.ok=!1,d.status=0,d.type="error",d};var P=[301,302,303,307,308];R.redirect=function(d,w){if(P.indexOf(w)===-1)throw new RangeError("Invalid status code");return new R(null,{status:w,headers:{location:d}})},o.DOMException=a.DOMException;try{new o.DOMException}catch{o.DOMException=function(w,D){this.message=w,this.name=D;var O=Error(w);this.stack=O.stack},o.DOMException.prototype=Object.create(Error.prototype),o.DOMException.prototype.constructor=o.DOMException}function T(d,w){return new Promise(function(D,O){var _=new C(d,w);if(_.signal&&_.signal.aborted)return O(new o.DOMException("Aborted","AbortError"));var A=new XMLHttpRequest;function N(){A.abort()}A.onload=function(){var U={statusText:A.statusText,headers:F(A.getAllResponseHeaders()||"")};_.url.indexOf("file://")===0&&(A.status<200||A.status>599)?U.status=200:U.status=A.status,U.url="responseURL"in A?A.responseURL:U.headers.get("X-Request-URL");var L="response"in A?A.response:A.responseText;setTimeout(function(){D(new R(L,U))},0)},A.onerror=function(){setTimeout(function(){O(new TypeError("Network request failed"))},0)},A.ontimeout=function(){setTimeout(function(){O(new TypeError("Network request timed out"))},0)},A.onabort=function(){setTimeout(function(){O(new o.DOMException("Aborted","AbortError"))},0)};function j(U){try{return U===""&&a.location.href?a.location.href:U}catch{return U}}if(A.open(_.method,j(_.url),!0),_.credentials==="include"?A.withCredentials=!0:_.credentials==="omit"&&(A.withCredentials=!1),"responseType"in A&&(c.blob?A.responseType="blob":c.arrayBuffer&&(A.responseType="arraybuffer")),w&&typeof w.headers=="object"&&!(w.headers instanceof y||a.Headers&&w.headers instanceof a.Headers)){var q=[];Object.getOwnPropertyNames(w.headers).forEach(function(U){q.push(f(U)),A.setRequestHeader(U,g(w.headers[U]))}),_.headers.forEach(function(U,L){q.indexOf(L)===-1&&A.setRequestHeader(L,U)})}else _.headers.forEach(function(U,L){A.setRequestHeader(L,U)});_.signal&&(_.signal.addEventListener("abort",N),A.onreadystatechange=function(){A.readyState===4&&_.signal.removeEventListener("abort",N)}),A.send(typeof _._bodyInit>"u"?null:_._bodyInit)})}return T.polyfill=!0,a.fetch||(a.fetch=T,a.Headers=y,a.Request=C,a.Response=R),o.Headers=y,o.Request=C,o.Response=R,o.fetch=T,Object.defineProperty(o,"__esModule",{value:!0}),o})({})})(i),i.fetch.ponyfill=!0,delete i.fetch.polyfill;var n=r.fetch?r:i;e=n.fetch,e.default=n.fetch,e.fetch=n.fetch,e.Headers=n.Headers,e.Request=n.Request,e.Response=n.Response,t.exports=e})(Ln,Ln.exports)),Ln.exports}var A6=O6();const Vh=Wa(A6);var $6=Object.defineProperty,C6=Object.defineProperties,P6=Object.getOwnPropertyDescriptors,Hh=Object.getOwnPropertySymbols,B6=Object.prototype.hasOwnProperty,T6=Object.prototype.propertyIsEnumerable,Kh=(t,e,r)=>e in t?$6(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Wh=(t,e)=>{for(var r in e||(e={}))B6.call(e,r)&&Kh(t,r,e[r]);if(Hh)for(var r of Hh(e))T6.call(e,r)&&Kh(t,r,e[r]);return t},Gh=(t,e)=>C6(t,P6(e));const R6={Accept:"application/json","Content-Type":"application/json"},U6="POST",Yh={headers:R6,method:U6},Zh=10;let $g=class{constructor(e,r=!1){if(this.url=e,this.disableProviderPing=r,this.events=new ct.EventEmitter,this.isAvailable=!1,this.registering=!1,!fh(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);this.url=e,this.disableProviderPing=r}get connected(){return this.isAvailable}get connecting(){return this.registering}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async open(e=this.url){await this.register(e)}async close(){if(!this.isAvailable)throw new Error("Connection already closed");this.onClose()}async send(e){this.isAvailable||await this.register();try{const r=or(e),i=await(await Vh(this.url,Gh(Wh({},Yh),{body:r}))).json();this.onPayload({data:i})}catch(r){this.onError(e.id,r)}}async register(e=this.url){if(!fh(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);if(this.registering){const r=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=r||this.events.listenerCount("open")>=r)&&this.events.setMaxListeners(r+1),new Promise((i,n)=>{this.events.once("register_error",s=>{this.resetMaxListeners(),n(s)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.isAvailable>"u")return n(new Error("HTTP connection is missing or invalid"));i()})})}this.url=e,this.registering=!0;try{if(!this.disableProviderPing){const r=or({id:1,jsonrpc:"2.0",method:"test",params:[]});await Vh(e,Gh(Wh({},Yh),{body:r}))}this.onOpen()}catch(r){const i=this.parseError(r);throw this.events.emit("register_error",i),this.onClose(),i}}onOpen(){this.isAvailable=!0,this.registering=!1,this.events.emit("open")}onClose(){this.isAvailable=!1,this.registering=!1,this.events.emit("close")}onPayload(e){if(typeof e.data>"u")return;const r=typeof e.data=="string"?Yr(e.data):e.data;this.events.emit("payload",r)}onError(e,r){const i=this.parseError(r),n=i.message||i.toString(),s=Us(e,n);this.events.emit("payload",s)}parseError(e,r=this.url){return ng(e,r,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>Zh&&this.events.setMaxListeners(Zh)}};function Cc(t){return t==null||typeof t!="object"&&typeof t!="function"}function Cg(t){return Object.getOwnPropertySymbols(t).filter(e=>Object.prototype.propertyIsEnumerable.call(t,e))}function Pg(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const N6="[object RegExp]",Bg="[object String]",Tg="[object Number]",Rg="[object Boolean]",Ug="[object Arguments]",j6="[object Symbol]",k6="[object Date]",F6="[object Map]",L6="[object Set]",M6="[object Array]",q6="[object ArrayBuffer]",z6="[object Object]",V6="[object DataView]",H6="[object Uint8Array]",K6="[object Uint8ClampedArray]",W6="[object Uint16Array]",G6="[object Uint32Array]",Y6="[object Int8Array]",Z6="[object Int16Array]",J6="[object Int32Array]",X6="[object Float32Array]",Q6="[object Float64Array]";function Pc(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function eC(t,e){return yi(t,void 0,t,new Map,e)}function yi(t,e,r,i=new Map,n=void 0){const s=n?.(t,e,r,i);if(s!=null)return s;if(Cc(t))return t;if(i.has(t))return i.get(t);if(Array.isArray(t)){const o=new Array(t.length);i.set(t,o);for(let a=0;a<t.length;a++)o[a]=yi(t[a],a,r,i,n);return Object.hasOwn(t,"index")&&(o.index=t.index),Object.hasOwn(t,"input")&&(o.input=t.input),o}if(t instanceof Date)return new Date(t.getTime());if(t instanceof RegExp){const o=new RegExp(t.source,t.flags);return o.lastIndex=t.lastIndex,o}if(t instanceof Map){const o=new Map;i.set(t,o);for(const[a,c]of t)o.set(a,yi(c,a,r,i,n));return o}if(t instanceof Set){const o=new Set;i.set(t,o);for(const a of t)o.add(yi(a,void 0,r,i,n));return o}if(typeof Buffer<"u"&&Buffer.isBuffer(t))return t.subarray();if(Pc(t)){const o=new(Object.getPrototypeOf(t)).constructor(t.length);i.set(t,o);for(let a=0;a<t.length;a++)o[a]=yi(t[a],a,r,i,n);return o}if(t instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer)return t.slice(0);if(t instanceof DataView){const o=new DataView(t.buffer.slice(0),t.byteOffset,t.byteLength);return i.set(t,o),Mr(o,t,r,i,n),o}if(typeof File<"u"&&t instanceof File){const o=new File([t],t.name,{type:t.type});return i.set(t,o),Mr(o,t,r,i,n),o}if(t instanceof Blob){const o=new Blob([t],{type:t.type});return i.set(t,o),Mr(o,t,r,i,n),o}if(t instanceof Error){const o=new t.constructor;return i.set(t,o),o.message=t.message,o.name=t.name,o.stack=t.stack,o.cause=t.cause,Mr(o,t,r,i,n),o}if(typeof t=="object"&&tC(t)){const o=Object.create(Object.getPrototypeOf(t));return i.set(t,o),Mr(o,t,r,i,n),o}return t}function Mr(t,e,r=t,i,n){const s=[...Object.keys(e),...Cg(e)];for(let o=0;o<s.length;o++){const a=s[o],c=Object.getOwnPropertyDescriptor(t,a);(c==null||c.writable)&&(t[a]=yi(e[a],a,r,i,n))}}function tC(t){switch(Pg(t)){case Ug:case M6:case q6:case V6:case Rg:case k6:case X6:case Q6:case Y6:case Z6:case J6:case F6:case Tg:case z6:case N6:case L6:case Bg:case j6:case H6:case K6:case W6:case G6:return!0;default:return!1}}function rC(t,e){return eC(t,(r,i,n,s)=>{if(typeof t=="object")switch(Object.prototype.toString.call(t)){case Tg:case Bg:case Rg:{const o=new t.constructor(t?.valueOf());return Mr(o,t),o}case Ug:{const o={};return Mr(o,t),o.length=t.length,o[Symbol.iterator]=t[Symbol.iterator],o}default:return}})}function Jh(t){return rC(t)}function Xh(t){return t!==null&&typeof t=="object"&&Pg(t)==="[object Arguments]"}function Qh(t){return typeof t=="object"&&t!==null}function iC(){}function nC(t){return Pc(t)}function sC(t){if(typeof t!="object"||t==null)return!1;if(Object.getPrototypeOf(t)===null)return!0;if(Object.prototype.toString.call(t)!=="[object Object]"){const r=t[Symbol.toStringTag];return r==null||!Object.getOwnPropertyDescriptor(t,Symbol.toStringTag)?.writable?!1:t.toString()===`[object ${r}]`}let e=t;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}function oC(t){if(Cc(t))return t;if(Array.isArray(t)||Pc(t)||t instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer)return t.slice(0);const e=Object.getPrototypeOf(t),r=e.constructor;if(t instanceof Date||t instanceof Map||t instanceof Set)return new r(t);if(t instanceof RegExp){const i=new r(t);return i.lastIndex=t.lastIndex,i}if(t instanceof DataView)return new r(t.buffer.slice(0));if(t instanceof Error){const i=new r(t.message);return i.stack=t.stack,i.name=t.name,i.cause=t.cause,i}if(typeof File<"u"&&t instanceof File)return new r([t],t.name,{type:t.type,lastModified:t.lastModified});if(typeof t=="object"){const i=Object.create(e);return Object.assign(i,t)}return t}function aC(t,...e){const r=e.slice(0,-1),i=e[e.length-1];let n=t;for(let s=0;s<r.length;s++){const o=r[s];n=Ma(n,o,i,new Map)}return n}function Ma(t,e,r,i){if(Cc(t)&&(t=Object(t)),e==null||typeof e!="object")return t;if(i.has(e))return oC(i.get(e));if(i.set(e,t),Array.isArray(e)){e=e.slice();for(let s=0;s<e.length;s++)e[s]=e[s]??void 0}const n=[...Object.keys(e),...Cg(e)];for(let s=0;s<n.length;s++){const o=n[s];let a=e[o],c=t[o];if(Xh(a)&&(a={...a}),Xh(c)&&(c={...c}),typeof Buffer<"u"&&Buffer.isBuffer(a)&&(a=Jh(a)),Array.isArray(a))if(typeof c=="object"&&c!=null){const l=[],h=Reflect.ownKeys(c);for(let f=0;f<h.length;f++){const g=h[f];l[g]=c[g]}c=l}else c=[];const u=r(c,a,o,t,e,i);u!=null?t[o]=u:Array.isArray(a)||Qh(c)&&Qh(a)?t[o]=Ma(c,a,r,i):c==null&&sC(a)?t[o]=Ma({},a,r,i):c==null&&nC(a)?t[o]=Jh(a):(c===void 0||a!==void 0)&&(t[o]=a)}return t}function cC(t,...e){return aC(t,...e,iC)}const ef="error",uC="wss://relay.walletconnect.org",lC="wc",Ng="universal_provider",Mn=`${lC}@2:${Ng}:`,jg="https://rpc.walletconnect.org/v1/",kg="generic",hC=`${jg}bundler`,vi="call_status",fC=86400,Bc={DEFAULT_CHAIN_CHANGED:"default_chain_changed"};var dC=Object.defineProperty,pC=Object.defineProperties,gC=Object.getOwnPropertyDescriptors,tf=Object.getOwnPropertySymbols,yC=Object.prototype.hasOwnProperty,wC=Object.prototype.propertyIsEnumerable,rf=(t,e,r)=>e in t?dC(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,qn=(t,e)=>{for(var r in e||(e={}))yC.call(e,r)&&rf(t,r,e[r]);if(tf)for(var r of tf(e))wC.call(e,r)&&rf(t,r,e[r]);return t},bC=(t,e)=>pC(t,gC(e));function Fg(t,e,r){var i;const n=ir(t);return((i=e.rpcMap)==null?void 0:i[n.reference])||`${jg}?chainId=${n.namespace}:${n.reference}&projectId=${r}`}function mC(t){return t.includes(":")?t.split(":")[1]:t}function Lg(t){return t.map(e=>`${e.split(":")[0]}:${e.split(":")[1]}`)}function vC(t,e){const r=Object.keys(e.namespaces).filter(n=>n.includes(t));if(!r.length)return[];const i=[];return r.forEach(n=>{const s=e.namespaces[n].accounts;i.push(...s)}),i}function nf(t){return Object.fromEntries(Object.entries(t).filter(([e,r])=>{var i,n;return((i=r?.chains)==null?void 0:i.length)&&((n=r?.chains)==null?void 0:n.length)>0}))}function zn(t={},e={}){const r=nf(sf(t)),i=nf(sf(e));return cC(r,i)}function sf(t){var e,r,i,n,s;const o={};if(!Mt(t))return o;for(const[a,c]of Object.entries(t)){const u=Ts(a)?[a]:c.chains,l=c.methods||[],h=c.events||[],f=c.rpcMap||{},g=gi(a);o[g]=bC(qn(qn({},o[g]),c),{chains:Lt(u,(e=o[g])==null?void 0:e.chains),methods:Lt(l,(r=o[g])==null?void 0:r.methods),events:Lt(h,(i=o[g])==null?void 0:i.events)}),(Mt(f)||Mt(((n=o[g])==null?void 0:n.rpcMap)||{}))&&(o[g].rpcMap=qn(qn({},f),(s=o[g])==null?void 0:s.rpcMap))}return o}function of(t){return t.includes(":")?t.split(":")[2]:t}function af(t){const e={};for(const[r,i]of Object.entries(t)){const n=i.methods||[],s=i.events||[],o=i.accounts||[],a=Ts(r)?[r]:i.chains?i.chains:Lg(i.accounts);e[r]={chains:a,methods:n,events:s,accounts:o}}return e}function qo(t){return typeof t=="number"?t:t.includes("0x")?parseInt(t,16):(t=t.includes(":")?t.split(":")[1]:t,isNaN(Number(t))?t:Number(t))}function EC(t){try{const e=JSON.parse(t);return typeof e=="object"&&e!==null&&!Array.isArray(e)}catch{return!1}}const Mg={},Ei=t=>Mg[t],zo=(t,e)=>{Mg[t]=e};var DC=Object.defineProperty,cf=Object.getOwnPropertySymbols,xC=Object.prototype.hasOwnProperty,_C=Object.prototype.propertyIsEnumerable,uf=(t,e,r)=>e in t?DC(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,lf=(t,e)=>{for(var r in e||(e={}))xC.call(e,r)&&uf(t,r,e[r]);if(cf)for(var r of cf(e))_C.call(e,r)&&uf(t,r,e[r]);return t};const hf="eip155",IC=["atomic","flow-control","paymasterService","sessionKeys","auxiliaryFunds"],SC=t=>t&&t.startsWith("0x")?BigInt(t).toString(10):t,Vo=t=>t&&t.startsWith("0x")?t:`0x${BigInt(t).toString(16)}`,ff=t=>Object.keys(t).filter(e=>IC.includes(e)).reduce((e,r)=>(e[r]=OC(t[r]),e),{}),OC=t=>typeof t=="string"&&EC(t)?JSON.parse(t):t,AC=(t,e,r)=>{const{sessionProperties:i={},scopedProperties:n={}}=t,s={};if(!Mt(n)&&!Mt(i))return;const o=ff(i);for(const a of r){const c=SC(a);if(!c)continue;s[Vo(c)]=o;const u=n?.[`${hf}:${c}`];if(u){const l=u?.[`${hf}:${c}:${e}`];s[Vo(c)]=lf(lf({},s[Vo(c)]),ff(l||u))}}for(const[a,c]of Object.entries(s))Object.keys(c).length===0&&delete s[a];return Object.keys(s).length>0?s:void 0};var $C=Object.defineProperty,CC=(t,e,r)=>e in t?$C(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,PC=(t,e,r)=>CC(t,e+"",r);let Ho,BC=class qg{constructor(e){PC(this,"storage"),this.storage=e}async getItem(e){return await this.storage.getItem(e)}async setItem(e,r){return await this.storage.setItem(e,r)}async removeItem(e){return await this.storage.removeItem(e)}static getStorage(e){return Ho||(Ho=new qg(e)),Ho}};var TC=Object.defineProperty,RC=Object.defineProperties,UC=Object.getOwnPropertyDescriptors,df=Object.getOwnPropertySymbols,NC=Object.prototype.hasOwnProperty,jC=Object.prototype.propertyIsEnumerable,pf=(t,e,r)=>e in t?TC(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,kC=(t,e)=>{for(var r in e||(e={}))NC.call(e,r)&&pf(t,r,e[r]);if(df)for(var r of df(e))jC.call(e,r)&&pf(t,r,e[r]);return t},FC=(t,e)=>RC(t,UC(e));async function LC(t,e){const r=ir(t.result.capabilities.caip345.caip2),i=t.result.capabilities.caip345.transactionHashes,n=await Promise.allSettled(i.map(h=>MC(r.reference,h,e))),s=n.filter(h=>h.status==="fulfilled").map(h=>h.value).filter(h=>h);n.filter(h=>h.status==="rejected").forEach(h=>console.warn("Failed to fetch transaction receipt:",h.reason));const o=!s.length||s.some(h=>!h),a=s.every(h=>h?.status==="0x1"),c=s.every(h=>h?.status==="0x0"),u=s.some(h=>h?.status==="0x0");let l;return o?l=100:a?l=200:c?l=500:u&&(l=600),{id:t.result.id,version:t.request.version,atomic:t.request.atomicRequired,chainId:t.request.chainId,capabilities:t.result.capabilities,receipts:s,status:l}}async function MC(t,e,r){return await r(parseInt(t)).request(St("eth_getTransactionReceipt",[e]))}async function qC({sendCalls:t,storage:e}){const r=await e.getItem(vi);await e.setItem(vi,FC(kC({},r),{[t.result.id]:{request:t.request,result:t.result,expiry:we(fC)}}))}async function zC({resultId:t,storage:e}){const r=await e.getItem(vi);if(r){delete r[t],await e.setItem(vi,r);for(const i in r)kt(r[i].expiry)&&delete r[i];await e.setItem(vi,r)}}async function VC({resultId:t,storage:e}){const r=await e.getItem(vi),i=r?.[t];if(i&&!kt(i.expiry))return i;await zC({resultId:t,storage:e})}var HC=Object.defineProperty,KC=Object.defineProperties,WC=Object.getOwnPropertyDescriptors,gf=Object.getOwnPropertySymbols,GC=Object.prototype.hasOwnProperty,YC=Object.prototype.propertyIsEnumerable,qa=(t,e,r)=>e in t?HC(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ko=(t,e)=>{for(var r in e||(e={}))GC.call(e,r)&&qa(t,r,e[r]);if(gf)for(var r of gf(e))YC.call(e,r)&&qa(t,r,e[r]);return t},Wo=(t,e)=>KC(t,WC(e)),Nr=(t,e,r)=>qa(t,typeof e!="symbol"?e+"":e,r);class ZC{constructor(e){Nr(this,"name","eip155"),Nr(this,"client"),Nr(this,"chainId"),Nr(this,"namespace"),Nr(this,"httpProviders"),Nr(this,"events"),Nr(this,"storage"),this.namespace=e.namespace,this.events=Ei("events"),this.client=Ei("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain()),this.storage=BC.getStorage(this.client.core.storage)}async request(e){switch(e.request.method){case"eth_requestAccounts":return this.getAccounts();case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(e);case"eth_chainId":return parseInt(this.getDefaultChain());case"wallet_getCapabilities":return await this.getCapabilities(e);case"wallet_getCallsStatus":return await this.getCallStatus(e);case"wallet_sendCalls":return await this.sendCalls(e)}return this.namespace.methods.includes(e.request.method)?await this.client.request(e):this.getHttpProvider().request(e.request)}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(parseInt(e),r);const i=this.chainId;this.chainId=parseInt(e),this.events.emit(Bc.DEFAULT_CHAIN_CHANGED,{currentCaipChainId:`${this.name}:${e}`,previousCaipChainId:`${this.name}:${i}`})}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}createHttpProvider(e,r){const i=r||Fg(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new Ac(new $g(i,Ei("disableProviderPing")))}setHttpProvider(e,r){const i=this.createHttpProvider(e,r);i&&(this.httpProviders[e]=i)}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var i;const n=parseInt(mC(r));e[n]=this.createHttpProvider(n,(i=this.namespace.rpcMap)==null?void 0:i[r])}),e}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}getHttpProvider(e){const r=e||this.chainId;return this.httpProviders[r]||(this.httpProviders=Wo(Ko({},this.httpProviders),{[r]:this.createHttpProvider(r)}),this.httpProviders[r])}async handleSwitchChain(e){var r,i;let n=e.request.params?(r=e.request.params[0])==null?void 0:r.chainId:"0x0";n=n.startsWith("0x")?n:`0x${n}`;const s=parseInt(n,16);if(this.isChainApproved(s))this.setDefaultChain(`${s}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:e.topic,request:{method:e.request.method,params:[{chainId:n}]},chainId:(i=this.namespace.chains)==null?void 0:i[0]}),this.setDefaultChain(`${s}`);else throw new Error(`Failed to switch to chain 'eip155:${s}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved(e){return this.namespace.chains.includes(`${this.name}:${e}`)}async getCapabilities(e){var r,i,n,s,o;const a=(i=(r=e.request)==null?void 0:r.params)==null?void 0:i[0],c=((s=(n=e.request)==null?void 0:n.params)==null?void 0:s[1])||[];if(!a)throw new Error("Missing address parameter in `wallet_getCapabilities` request");const u=this.client.session.get(e.topic),l=((o=u?.sessionProperties)==null?void 0:o.capabilities)||{},h=`${a}${c.join(",")}`,f=l?.[h];if(f)return f;let g;try{g=AC(u,a,c)}catch(y){console.warn("Failed to extract capabilities from session",y)}if(g)return g;const p=await this.client.request(e);try{await this.client.session.update(e.topic,{sessionProperties:Wo(Ko({},u.sessionProperties||{}),{capabilities:Wo(Ko({},l||{}),{[h]:p})})})}catch(y){console.warn("Failed to update session with capabilities",y)}return p}async getCallStatus(e){var r,i,n;const s=this.client.session.get(e.topic),o=(r=s.sessionProperties)==null?void 0:r.bundler_name;if(o){const u=this.getBundlerUrl(e.chainId,o);try{return await this.getUserOperationReceipt(u,e)}catch(l){console.warn("Failed to fetch call status from bundler",l,u)}}const a=(i=s.sessionProperties)==null?void 0:i.bundler_url;if(a)try{return await this.getUserOperationReceipt(a,e)}catch(u){console.warn("Failed to fetch call status from custom bundler",u,a)}const c=await VC({resultId:(n=e.request.params)==null?void 0:n[0],storage:this.storage});if(c)try{return await LC(c,this.getHttpProvider.bind(this))}catch(u){console.warn("Failed to fetch call status from stored send calls",u,c)}if(this.namespace.methods.includes(e.request.method))return await this.client.request(e);throw new Error("Fetching call status not approved by the wallet.")}async getUserOperationReceipt(e,r){var i;const n=new URL(e),s=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(St("eth_getUserOperationReceipt",[(i=r.request.params)==null?void 0:i[0]]))});if(!s.ok)throw new Error(`Failed to fetch user operation receipt - ${s.status}`);return await s.json()}getBundlerUrl(e,r){return`${hC}?projectId=${this.client.core.projectId}&chainId=${e}&bundler=${r}`}async sendCalls(e){var r,i,n;const s=await this.client.request(e),o=(r=e.request.params)==null?void 0:r[0],a=s?.id,c=s?.capabilities||{},u=(i=c?.caip345)==null?void 0:i.caip2,l=(n=c?.caip345)==null?void 0:n.transactionHashes;return!a||!u||!(l!=null&&l.length)||await qC({sendCalls:{request:o,result:s},storage:this.storage}),s}}var JC=Object.defineProperty,XC=(t,e,r)=>e in t?JC(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,hi=(t,e,r)=>XC(t,typeof e!="symbol"?e+"":e,r);class QC{constructor(e){hi(this,"name",kg),hi(this,"client"),hi(this,"httpProviders"),hi(this,"events"),hi(this,"namespace"),hi(this,"chainId"),this.namespace=e.namespace,this.events=Ei("events"),this.client=Ei("client"),this.chainId=this.getDefaultChain(),this.name=this.getNamespaceName(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace.chains=[...new Set((this.namespace.chains||[]).concat(e.chains||[]))],this.namespace.accounts=[...new Set((this.namespace.accounts||[]).concat(e.accounts||[]))],this.namespace.methods=[...new Set((this.namespace.methods||[]).concat(e.methods||[]))],this.namespace.events=[...new Set((this.namespace.events||[]).concat(e.events||[]))],this.httpProviders=this.createHttpProviders()}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider(e.chainId).request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r);const i=this.chainId;this.chainId=e,this.events.emit(Bc.DEFAULT_CHAIN_CHANGED,{currentCaipChainId:`${this.name}:${e}`,previousCaipChainId:`${this.name}:${i}`})}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getNamespaceName(){const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return ir(e).namespace}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){var e,r;const i={};return(r=(e=this.namespace)==null?void 0:e.accounts)==null||r.forEach(n=>{var s,o;const a=ir(n),c=(o=(s=this.namespace)==null?void 0:s.rpcMap)==null?void 0:o[`${a.namespace}:${a.reference}`];i[a.reference]=this.createHttpProvider(n,c)}),i}getHttpProvider(e){const r=ir(e).reference,i=this.httpProviders[r];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return i}setHttpProvider(e,r){const i=this.createHttpProvider(e,r);i&&(this.httpProviders[e]=i)}createHttpProvider(e,r){const i=r||Fg(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new Ac(new $g(i,Ei("disableProviderPing")))}}var e4=Object.defineProperty,t4=Object.defineProperties,r4=Object.getOwnPropertyDescriptors,yf=Object.getOwnPropertySymbols,i4=Object.prototype.hasOwnProperty,n4=Object.prototype.propertyIsEnumerable,za=(t,e,r)=>e in t?e4(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Vi=(t,e)=>{for(var r in e||(e={}))i4.call(e,r)&&za(t,r,e[r]);if(yf)for(var r of yf(e))n4.call(e,r)&&za(t,r,e[r]);return t},Vn=(t,e)=>t4(t,r4(e)),dt=(t,e,r)=>za(t,typeof e!="symbol"?e+"":e,r);class Tc{constructor(e){dt(this,"client"),dt(this,"namespaces"),dt(this,"optionalNamespaces"),dt(this,"sessionProperties"),dt(this,"scopedProperties"),dt(this,"events",new Ga),dt(this,"rpcProviders",{}),dt(this,"session"),dt(this,"providerOpts"),dt(this,"logger"),dt(this,"uri"),dt(this,"disableProviderPing",!1);var r,i;this.providerOpts=e,this.logger=Ic({logger:(r=e.logger)!=null?r:ef,name:(i=this.providerOpts.name)!=null?i:Ng}),this.disableProviderPing=e?.disableProviderPing||!1}static async init(e){const r=new Tc(e);return await r.initialize(),r}async request(e,r,i){const[n,s]=this.validateChain(r);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(n).request({request:Vi({},e),chainId:`${n}:${s}`,topic:this.session.topic,expiry:i})}sendAsync(e,r,i,n){const s=new Date().getTime();this.request(e,i,n).then(o=>r(null,ln(s,o))).catch(o=>r(o,void 0))}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties,scopedProperties:this.scopedProperties}),await this.requestAccounts()}async disconnect(){var e;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:(e=this.session)==null?void 0:e.topic,reason:le("USER_DISCONNECTED")}),await this.cleanup()}async connect(e){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(e),this.cleanupPendingPairings(),!e.skipPairing)return await this.pair(e.pairingTopic)}async authenticate(e,r){if(!this.client)throw new Error("Sign Client not initialized");this.setNamespaces(e),await this.cleanupPendingPairings();const{uri:i,response:n}=await this.client.authenticate(e,r);i&&(this.uri=i,this.events.emit("display_uri",i));const s=await n();if(this.session=s.session,this.session){const o=af(this.session.namespaces);this.namespaces=zn(this.namespaces,o),await this.persist("namespaces",this.namespaces),this.onConnect()}return s}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}removeListener(e,r){this.events.removeListener(e,r)}off(e,r){this.events.off(e,r)}get isWalletConnect(){return!0}async pair(e){const{uri:r,approval:i}=await this.client.connect({pairingTopic:e,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties,scopedProperties:this.scopedProperties});r&&(this.uri=r,this.events.emit("display_uri",r));const n=await i();this.session=n;const s=af(n.namespaces);return this.namespaces=zn(this.namespaces,s),await this.persist("namespaces",this.namespaces),await this.persist("optionalNamespaces",this.optionalNamespaces),this.onConnect(),this.session}setDefaultChain(e,r){try{if(!this.session)return;const[i,n]=this.validateChain(e);this.getProvider(i).setDefaultChain(n,r)}catch(i){if(!/Please call connect/.test(i.message))throw i}}async cleanupPendingPairings(e={}){try{this.logger.info("Cleaning up inactive pairings...");const r=this.client.pairing.getAll();if(!mt(r))return;for(const i of r)e.deletePairings?this.client.core.expirer.set(i.topic,0):await this.client.core.relayer.subscriber.unsubscribe(i.topic);this.logger.info(`Inactive pairings cleared: ${r.length}`)}catch(r){this.logger.warn(r,"Failed to cleanup pending pairings")}}abortPairingAttempt(){this.logger.warn("abortPairingAttempt is deprecated. This is now a no-op.")}async checkStorage(){this.namespaces=await this.getFromStore("namespaces")||{},this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.session&&this.createProviders()}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){var e,r;if(this.client=this.providerOpts.client||await S6.init({core:this.providerOpts.core,logger:this.providerOpts.logger||ef,relayUrl:this.providerOpts.relayUrl||uC,projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name,customStoragePrefix:this.providerOpts.customStoragePrefix,telemetryEnabled:this.providerOpts.telemetryEnabled}),this.providerOpts.session)try{this.session=this.client.session.get(this.providerOpts.session.topic)}catch(i){throw this.logger.error(i,"Failed to get session"),new Error(`The provided session: ${(r=(e=this.providerOpts)==null?void 0:e.session)==null?void 0:r.topic} doesn't exist in the Sign client`)}else{const i=this.client.session.getAll();this.session=i[0]}this.logger.trace("SignClient Initialized")}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const e=[...new Set(Object.keys(this.session.namespaces).map(r=>gi(r)))];zo("client",this.client),zo("events",this.events),zo("disableProviderPing",this.disableProviderPing),e.forEach(r=>{if(!this.session)return;const i=vC(r,this.session);if(i?.length===0)return;const n=Lg(i),s=zn(this.namespaces,this.optionalNamespaces),o=Vn(Vi({},s[r]),{accounts:i,chains:n});r==="eip155"?this.rpcProviders[r]=new ZC({namespace:o}):this.rpcProviders[r]=new QC({namespace:o})})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",e=>{var r;const{topic:i}=e;i===((r=this.session)==null?void 0:r.topic)&&this.events.emit("session_ping",e)}),this.client.on("session_event",e=>{var r;const{params:i,topic:n}=e;if(n!==((r=this.session)==null?void 0:r.topic))return;const{event:s}=i;if(s.name==="accountsChanged"){const o=s.data;o&&mt(o)&&this.events.emit("accountsChanged",o.map(of))}else if(s.name==="chainChanged"){const o=i.chainId,a=i.event.data,c=gi(o),u=qo(o)!==qo(a)?`${c}:${qo(a)}`:o;this.onChainChanged({currentCaipChainId:u})}else this.events.emit(s.name,s.data);this.events.emit("session_event",e)}),this.client.on("session_update",({topic:e,params:r})=>{var i,n;if(e!==((i=this.session)==null?void 0:i.topic))return;const{namespaces:s}=r,o=(n=this.client)==null?void 0:n.session.get(e);this.session=Vn(Vi({},o),{namespaces:s}),this.onSessionUpdate(),this.events.emit("session_update",{topic:e,params:r})}),this.client.on("session_delete",async e=>{var r;e.topic===((r=this.session)==null?void 0:r.topic)&&(await this.cleanup(),this.events.emit("session_delete",e),this.events.emit("disconnect",Vn(Vi({},le("USER_DISCONNECTED")),{data:e.topic})))}),this.on(Bc.DEFAULT_CHAIN_CHANGED,e=>{this.onChainChanged(Vn(Vi({},e),{internal:!0}))})}getProvider(e){return this.rpcProviders[e]||this.rpcProviders[kg]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(e=>{var r;this.getProvider(e).updateNamespace((r=this.session)==null?void 0:r.namespaces[e])})}setNamespaces(e){const{namespaces:r={},optionalNamespaces:i={},sessionProperties:n,scopedProperties:s}=e;this.optionalNamespaces=zn(r,i),this.sessionProperties=n,this.scopedProperties=s}validateChain(e){const[r,i]=e?.split(":")||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[r,i];if(r&&!Object.keys(this.namespaces||{}).map(o=>gi(o)).includes(r))throw new Error(`Namespace '${r}' is not configured. Please call connect() first with namespace config.`);if(r&&i)return[r,i];const n=gi(Object.keys(this.namespaces)[0]),s=this.rpcProviders[n].getDefaultChain();return[n,s]}async requestAccounts(){const[e]=this.validateChain();return await this.getProvider(e).requestAccounts()}async onChainChanged({currentCaipChainId:e,previousCaipChainId:r,internal:i=!1}){if(!this.namespaces)return;const[n,s]=this.validateChain(e);s&&(this.updateNamespaceChain(n,s),i?(this.events.emit("chainChanged",s),this.emitAccountsChangedOnChainChange({namespace:n,currentCaipChainId:e,previousCaipChainId:r})):this.getProvider(n).setDefaultChain(s),await this.persist("namespaces",this.namespaces))}emitAccountsChangedOnChainChange({namespace:e,currentCaipChainId:r,previousCaipChainId:i}){var n,s;try{if(i===r)return;const o=(s=(n=this.session)==null?void 0:n.namespaces[e])==null?void 0:s.accounts;if(!o)return;const a=o.filter(c=>c.includes(`${r}:`)).map(of);if(!mt(a))return;this.events.emit("accountsChanged",a)}catch(o){this.logger.warn(o,"Failed to emit accountsChanged on chain change")}}updateNamespaceChain(e,r){if(!this.namespaces)return;const i=this.namespaces[e]?e:`${e}:${r}`,n={chains:[],methods:[],events:[],defaultChain:r};this.namespaces[i]?this.namespaces[i]&&(this.namespaces[i].defaultChain=r):this.namespaces[i]=n}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,await this.deleteFromStore("namespaces"),await this.deleteFromStore("optionalNamespaces"),await this.deleteFromStore("sessionProperties"),this.session=void 0,this.cleanupPendingPairings({deletePairings:!0}),await this.cleanupStorage()}async persist(e,r){var i;const n=((i=this.session)==null?void 0:i.topic)||"";await this.client.core.storage.setItem(`${Mn}/${e}${n}`,r)}async getFromStore(e){var r;const i=((r=this.session)==null?void 0:r.topic)||"";return await this.client.core.storage.getItem(`${Mn}/${e}${i}`)}async deleteFromStore(e){var r;const i=((r=this.session)==null?void 0:r.topic)||"";await this.client.core.storage.removeItem(`${Mn}/${e}${i}`)}async cleanupStorage(){var e;try{if(((e=this.client)==null?void 0:e.session.length)>0)return;const r=await this.client.core.storage.getKeys();for(const i of r)i.startsWith(Mn)&&await this.client.core.storage.removeItem(i)}catch(r){this.logger.warn(r,"Failed to cleanup storage")}}}const s4=Tc,o4="wc",a4="ethereum_provider",c4=`${o4}@2:${a4}:`,u4="https://rpc.walletconnect.org/v1/",Va=["eth_sendTransaction","personal_sign"],zg=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode","wallet_sendCalls","wallet_getCapabilities","wallet_getCallsStatus","wallet_showCallsStatus"],Ha=["chainChanged","accountsChanged"],Vg=["chainChanged","accountsChanged","message","disconnect","connect"],l4=async()=>{const{createAppKit:t}=await Jg(()=>import("./core-CRE213RM.js").then(e=>e.a0),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13]),import.meta.url);return t};var h4=Object.defineProperty,f4=Object.defineProperties,d4=Object.getOwnPropertyDescriptors,wf=Object.getOwnPropertySymbols,p4=Object.prototype.hasOwnProperty,g4=Object.prototype.propertyIsEnumerable,Ka=(t,e,r)=>e in t?h4(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,kr=(t,e)=>{for(var r in e||(e={}))p4.call(e,r)&&Ka(t,r,e[r]);if(wf)for(var r of wf(e))g4.call(e,r)&&Ka(t,r,e[r]);return t},Hi=(t,e)=>f4(t,d4(e)),rt=(t,e,r)=>Ka(t,typeof e!="symbol"?e+"":e,r);function gs(t){return Number(t[0].split(":")[1])}function Hn(t){return`0x${t.toString(16)}`}function y4(t){const{chains:e,optionalChains:r,methods:i,optionalMethods:n,events:s,optionalEvents:o,rpcMap:a}=t;if(!mt(e))throw new Error("Invalid chains");const c={chains:e,methods:i||Va,events:s||Ha,rpcMap:kr({},e.length?{[gs(e)]:a[gs(e)]}:{})},u=s?.filter(g=>!Ha.includes(g)),l=i?.filter(g=>!Va.includes(g));if(!r&&!o&&!n&&!(u!=null&&u.length)&&!(l!=null&&l.length))return{required:e.length?c:void 0};const h=u?.length&&l?.length||!r,f={chains:[...new Set(h?c.chains.concat(r||[]):r)],methods:[...new Set(c.methods.concat(n!=null&&n.length?n:zg))],events:[...new Set(c.events.concat(o!=null&&o.length?o:Vg))],rpcMap:a};return{required:e.length?c:void 0,optional:r.length?f:void 0}}class Rc{constructor(){rt(this,"events",new ct.EventEmitter),rt(this,"namespace","eip155"),rt(this,"accounts",[]),rt(this,"signer"),rt(this,"chainId",1),rt(this,"modal"),rt(this,"rpc"),rt(this,"STORAGE_KEY",c4),rt(this,"on",(e,r)=>(this.events.on(e,r),this)),rt(this,"once",(e,r)=>(this.events.once(e,r),this)),rt(this,"removeListener",(e,r)=>(this.events.removeListener(e,r),this)),rt(this,"off",(e,r)=>(this.events.off(e,r),this)),rt(this,"parseAccount",e=>this.isCompatibleChainId(e)?this.parseAccountId(e).address:e),this.signer={},this.rpc={}}static async init(e){const r=new Rc;return await r.initialize(e),r}async request(e,r){return await this.signer.request(e,this.formatChainId(this.chainId),r)}sendAsync(e,r,i){this.signer.sendAsync(e,r,this.formatChainId(this.chainId),i)}get connected(){return this.signer.client?this.signer.client.core.relayer.connected:!1}get connecting(){return this.signer.client?this.signer.client.core.relayer.connecting:!1}async enable(){return this.session||await this.connect(),await this.request({method:"eth_requestAccounts"})}async connect(e){var r;if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts(e);const{required:i,optional:n}=y4(this.rpc);try{const s=await new Promise(async(a,c)=>{var u,l;this.rpc.showQrModal&&((u=this.modal)==null||u.open(),(l=this.modal)==null||l.subscribeState(f=>{!f.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),c(new Error("Connection request reset. Please try again.")))}));const h=e!=null&&e.scopedProperties?{[this.namespace]:e.scopedProperties}:void 0;await this.signer.connect(Hi(kr({namespaces:kr({},i&&{[this.namespace]:i})},n&&{optionalNamespaces:{[this.namespace]:n}}),{pairingTopic:e?.pairingTopic,scopedProperties:h})).then(f=>{a(f)}).catch(f=>{var g;(g=this.modal)==null||g.showErrorMessage("Unable to connect"),c(new Error(f.message))})});if(!s)return;const o=il(s.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:o),this.setAccounts(o),this.events.emit("connect",{chainId:Hn(this.chainId)})}catch(s){throw this.signer.logger.error(s),s}finally{(r=this.modal)==null||r.close()}}async authenticate(e,r){var i;if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts({chains:e?.chains});try{const n=await new Promise(async(o,a)=>{var c,u;this.rpc.showQrModal&&((c=this.modal)==null||c.open(),(u=this.modal)==null||u.subscribeState(l=>{!l.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),a(new Error("Connection request reset. Please try again.")))})),await this.signer.authenticate(Hi(kr({},e),{chains:this.rpc.chains}),r).then(l=>{o(l)}).catch(l=>{var h;(h=this.modal)==null||h.showErrorMessage("Unable to connect"),a(new Error(l.message))})}),s=n.session;if(s){const o=il(s.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:o),this.setAccounts(o),this.events.emit("connect",{chainId:Hn(this.chainId)})}return n}catch(n){throw this.signer.logger.error(n),n}finally{(i=this.modal)==null||i.close()}}async disconnect(){this.session&&await this.signer.disconnect(),this.reset()}get isWalletConnect(){return!0}get session(){return this.signer.session}registerEventListeners(){this.signer.on("session_event",e=>{const{params:r}=e,{event:i}=r;i.name==="accountsChanged"?(this.accounts=this.parseAccounts(i.data),this.events.emit("accountsChanged",this.accounts)):i.name==="chainChanged"?this.setChainId(this.formatChainId(i.data)):this.events.emit(i.name,i.data),this.events.emit("session_event",e)}),this.signer.on("accountsChanged",e=>{this.accounts=this.parseAccounts(e),this.events.emit("accountsChanged",this.accounts)}),this.signer.on("chainChanged",e=>{const r=parseInt(e);this.chainId=r,this.events.emit("chainChanged",Hn(this.chainId)),this.persist()}),this.signer.on("session_update",e=>{this.events.emit("session_update",e)}),this.signer.on("session_delete",e=>{this.reset(),this.events.emit("session_delete",e),this.events.emit("disconnect",Hi(kr({},le("USER_DISCONNECTED")),{data:e.topic,name:"USER_DISCONNECTED"}))}),this.signer.on("display_uri",e=>{this.events.emit("display_uri",e)})}switchEthereumChain(e){this.request({method:"wallet_switchEthereumChain",params:[{chainId:e.toString(16)}]})}isCompatibleChainId(e){return typeof e=="string"?e.startsWith(`${this.namespace}:`):!1}formatChainId(e){return`${this.namespace}:${e}`}parseChainId(e){return Number(e.split(":")[1])}setChainIds(e){const r=e.filter(i=>this.isCompatibleChainId(i)).map(i=>this.parseChainId(i));r.length&&(this.chainId=r[0],this.events.emit("chainChanged",Hn(this.chainId)),this.persist())}setChainId(e){if(this.isCompatibleChainId(e)){const r=this.parseChainId(e);this.chainId=r,this.switchEthereumChain(r)}}parseAccountId(e){const[r,i,n]=e.split(":");return{chainId:`${r}:${i}`,address:n}}setAccounts(e){this.accounts=e.filter(r=>this.parseChainId(this.parseAccountId(r).chainId)===this.chainId).map(r=>this.parseAccountId(r).address),this.events.emit("accountsChanged",this.accounts)}getRpcConfig(e){var r,i;const n=(r=e?.chains)!=null?r:[],s=(i=e?.optionalChains)!=null?i:[],o=n.concat(s);if(!o.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const a=n.length?e?.methods||Va:[],c=n.length?e?.events||Ha:[],u=e?.optionalMethods||[],l=e?.optionalEvents||[],h=e?.rpcMap||this.buildRpcMap(o,e.projectId),f=e?.qrModalOptions||void 0;return{chains:n?.map(g=>this.formatChainId(g)),optionalChains:s.map(g=>this.formatChainId(g)),methods:a,events:c,optionalMethods:u,optionalEvents:l,rpcMap:h,showQrModal:!!(e!=null&&e.showQrModal),qrModalOptions:f,projectId:e.projectId,metadata:e.metadata}}buildRpcMap(e,r){const i={};return e.forEach(n=>{i[n]=this.getRpcUrl(n,r)}),i}async initialize(e){var r;if(this.rpc=this.getRpcConfig(e),this.chainId=this.rpc.chains.length?gs(this.rpc.chains):gs(this.rpc.optionalChains),this.signer=await s4.init({projectId:this.rpc.projectId,metadata:this.rpc.metadata,disableProviderPing:e.disableProviderPing,relayUrl:e.relayUrl,storage:e.storage,storageOptions:e.storageOptions,customStoragePrefix:e.customStoragePrefix,telemetryEnabled:e.telemetryEnabled,logger:e.logger}),this.registerEventListeners(),await this.loadPersistedSession(),this.rpc.showQrModal){let i;try{const n=await l4(),{convertWCMToAppKitOptions:s}=await Promise.resolve().then(function(){return O4}),o=s(Hi(kr({},this.rpc.qrModalOptions),{chains:[...new Set([...this.rpc.chains,...this.rpc.optionalChains])],metadata:this.rpc.metadata,projectId:this.rpc.projectId}));if(!o.networks.length)throw new Error("No networks found for WalletConnect·");i=n(Hi(kr({},o),{universalProvider:this.signer,manualWCControl:!0,enableMobileFullScreen:((r=this.rpc.qrModalOptions)==null?void 0:r.enableMobileFullScreen)===!0}))}catch(n){throw console.warn(n),new Error("To use QR modal, please install @reown/appkit package")}if(i)try{this.modal=i}catch(n){throw this.signer.logger.error(n),new Error("Could not generate WalletConnectModal Instance")}}}loadConnectOpts(e){if(!e)return;const{chains:r,optionalChains:i,rpcMap:n}=e;r&&mt(r)&&(this.rpc.chains=r.map(s=>this.formatChainId(s)),r.forEach(s=>{this.rpc.rpcMap[s]=n?.[s]||this.getRpcUrl(s)})),i&&mt(i)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=i?.map(s=>this.formatChainId(s)),i.forEach(s=>{this.rpc.rpcMap[s]=n?.[s]||this.getRpcUrl(s)}))}getRpcUrl(e,r){var i;return((i=this.rpc.rpcMap)==null?void 0:i[e])||`${u4}?chainId=eip155:${e}&projectId=${r||this.rpc.projectId}`}async loadPersistedSession(){if(this.session)try{const e=await this.signer.client.core.storage.getItem(`${this.STORAGE_KEY}/chainId`),r=this.session.namespaces[`${this.namespace}:${e}`]?this.session.namespaces[`${this.namespace}:${e}`]:this.session.namespaces[this.namespace];this.setChainIds(e?[this.formatChainId(e)]:r?.accounts),this.setAccounts(r?.accounts)}catch(e){this.signer.logger.error("Failed to load persisted session, clearing state..."),this.signer.logger.error(e),await this.disconnect().catch(r=>this.signer.logger.warn(r))}}reset(){this.chainId=1,this.accounts=[]}persist(){this.session&&this.signer.client.core.storage.setItem(`${this.STORAGE_KEY}/chainId`,this.chainId)}parseAccounts(e){return typeof e=="string"||e instanceof String?[this.parseAccount(e)]:e.map(r=>this.parseAccount(r))}}const w4=Rc;var b4=Object.defineProperty,m4=Object.defineProperties,v4=Object.getOwnPropertyDescriptors,bf=Object.getOwnPropertySymbols,E4=Object.prototype.hasOwnProperty,D4=Object.prototype.propertyIsEnumerable,mf=(t,e,r)=>e in t?b4(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Hg=(t,e)=>{for(var r in e||(e={}))E4.call(e,r)&&mf(t,r,e[r]);if(bf)for(var r of bf(e))D4.call(e,r)&&mf(t,r,e[r]);return t},x4=(t,e)=>m4(t,v4(e));function _4(t){if(t)return{"--w3m-font-family":t["--wcm-font-family"],"--w3m-accent":t["--wcm-accent-color"],"--w3m-color-mix":t["--wcm-background-color"],"--w3m-z-index":t["--wcm-z-index"]?Number(t["--wcm-z-index"]):void 0,"--w3m-qr-color":t["--wcm-accent-color"],"--w3m-font-size-master":t["--wcm-text-medium-regular-size"],"--w3m-border-radius-master":t["--wcm-container-border-radius"],"--w3m-color-mix-strength":0}}const I4=t=>{const[e,r]=t.split(":");return Kg({id:r,caipNetworkId:t,chainNamespace:e,name:"",nativeCurrency:{name:"",symbol:"",decimals:8},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}}})};function S4(t){var e,r,i,n,s,o,a;const c=(e=t.chains)==null?void 0:e.map(I4).filter(Boolean);if(c.length===0)throw new Error("At least one chain must be specified");const u=c.find(h=>{var f;return h.id===((f=t.defaultChain)==null?void 0:f.id)}),l={projectId:t.projectId,networks:c,themeMode:t.themeMode,themeVariables:_4(t.themeVariables),chainImages:t.chainImages,connectorImages:t.walletImages,defaultNetwork:u,metadata:x4(Hg({},t.metadata),{name:((r=t.metadata)==null?void 0:r.name)||"WalletConnect",description:((i=t.metadata)==null?void 0:i.description)||"Connect to WalletConnect-compatible wallets",url:((n=t.metadata)==null?void 0:n.url)||"https://walletconnect.org",icons:((s=t.metadata)==null?void 0:s.icons)||["https://walletconnect.org/walletconnect-logo.png"]}),showWallets:!0,featuredWalletIds:t.explorerRecommendedWalletIds==="NONE"?[]:Array.isArray(t.explorerRecommendedWalletIds)?t.explorerRecommendedWalletIds:[],excludeWalletIds:t.explorerExcludedWalletIds==="ALL"?[]:Array.isArray(t.explorerExcludedWalletIds)?t.explorerExcludedWalletIds:[],enableEIP6963:!1,enableInjected:!1,enableCoinbase:!0,enableWalletConnect:!0,features:{email:!1,socials:!1}};if((o=t.mobileWallets)!=null&&o.length||(a=t.desktopWallets)!=null&&a.length){const h=[...(t.mobileWallets||[]).map(p=>({id:p.id,name:p.name,links:p.links})),...(t.desktopWallets||[]).map(p=>({id:p.id,name:p.name,links:{native:p.links.native,universal:p.links.universal}}))],f=[...l.featuredWalletIds||[],...l.excludeWalletIds||[]],g=h.filter(p=>!f.includes(p.id));g.length&&(l.customWallets=g)}return l}function Kg(t){return Hg({formatters:void 0,fees:void 0,serializers:void 0},t)}var O4=Object.freeze({__proto__:null,convertWCMToAppKitOptions:S4,defineChain:Kg});class A4 extends Qg{async initialize(){De.debug("Initializing WalletConnect V2 connector",{wallet:this.walletClientType});let e=await this.createProvider();if(this.provider=e,this.proxyProvider.setWalletProvider(e),this.subscribeListeners(),e.session){let r=this.walletProvider?.session?.peer.metadata;De.debug("Restoring existing WalletConnect session",{peerName:r?.name,accountsCount:this.walletProvider?.accounts?.length}),this.walletProvider?.session?.peer.metadata.url&&(this.walletEntry=Ls(this.walletProvider?.session?.peer.metadata.url),this.walletClientType=this.walletEntry?.slug||"unknown"),this.connected=!0,await this.syncAccounts()}this.initialized=!0,this.emit("initialized")}async connect(e){De.connectionStart(this.walletClientType,"wallet_connect_v2",{showPrompt:e.showPrompt}),e.showPrompt&&await this.promptConnection();let r=await this.getConnectedWallet();return r&&De.connectionSuccess(this.walletClientType),r}async isConnected(){return!!this.walletProvider?.connected}get walletBranding(){let e=this.walletProvider?.session?.peer.metadata.icons?.[0];return{name:ey(this.walletProvider?.session?.peer.metadata.name||"")||"WalletConnect",icon:typeof e=="string"?e:yy,id:this.walletProvider?.session?.peer.metadata.name.toLowerCase()||"wallet_connect_v2"}}async resetConnection(e){let r=this.walletClientType;De.debug("Resetting WalletConnect connection for new wallet",{previousWallet:r,newWallet:e}),this.walletProvider&&this.walletProvider.connected&&(await this.walletProvider.disconnect(),this.walletProvider.signer.session=void 0,this.walletClientType=e,this.redirectUri=void 0,this.fallbackUniversalRedirectUri=void 0,ty(),this.onDisconnect())}async promptConnection(){if(this.provider)return De.debug("Prompting WalletConnect connection",{wallet:this.walletClientType}),new Promise(((e,r)=>{(async()=>{De.debug("Enabling WalletConnect provider",{wallet:this.walletClientType,timeoutMs:this.proxyProvider.rpcTimeoutDuration});let i="",n=await Promise.race([this.walletProvider?.enable(),this.proxyProvider.walletTimeout().then((()=>{}))]);if(n?.length&&(i=n[0],De.debug("WalletConnect accounts received",{address:i,accountsCount:n.length})),!i||i==="")throw new Ms("Unable to retrieve address");this.walletProvider?.session?.peer.metadata.url&&(this.walletEntry=Ls(this.walletProvider?.session?.peer.metadata.url),this.walletClientType=this.walletEntry?.slug||"unknown",De.debug("Identified wallet from session",{wallet:this.walletClientType}),this.proxyProvider.rpcTimeoutDuration=ly(this.rpcConfig,this.walletClientType)),this.connected=!0,await this.syncAccounts(n),e()})().catch((i=>{De.connectionFailed(this.walletClientType,i,{method:"wallet_connect_v2"}),r(i?ry(i):new Ms("Unknown error during connection"))}))}));De.warn("WalletConnect provider not initialized")}disconnect(){this.walletProvider?.disconnect().then((()=>this.onDisconnect())).catch((()=>console.warn("Unable to disconnect WalletConnect provider")))}get walletProvider(){return this.proxyProvider.walletProvider}setWalletProvider(e){this.proxyProvider.setWalletProvider(e)}async createProvider(){De.debug("Creating WalletConnect EthereumProvider",{chainsCount:this.chains.length,defaultChainId:this.defaultChain.id});let e={};for(let s of this.chains){let o=iy(s.id,this.chains,this.rpcConfig,this.privyAppId);o&&(e[s.id]=o)}let r=this.shouldEnforceDefaultChainOnConnect?[this.defaultChain.id]:[],i=this.chains.map((s=>s.id));De.debug("Initializing WalletConnect EthereumProvider",{requiredChains:r.join(", ")||"none",optionalChainsCount:i.length});let n=await w4.init({projectId:this.walletConnectCloudProjectId,chains:r,optionalChains:i,optionalEvents:Vg,optionalMethods:zg,rpcMap:e,showQrModal:!1,metadata:{description:this.privyAppName,name:this.privyAppName,url:window.location.origin,icons:[]}});return n.on("display_uri",(s=>{if(De.debug("WalletConnect URI generated",{wallet:this.walletClientType,isMobile:qc.isMobile,hasWalletEntry:!!this.walletEntry}),De.debug("Aborting WalletConnect pairing attempt"),n.signer.abortPairingAttempt(),ny(),!this.showPrivyQrModal)throw new Ms("WalletConnect modal not available - Privy handles wallet connections through its own UI");if(qc.isMobile&&this.walletEntry){let{redirect:o,href:a}=sy(s,this.walletEntry),c=o.startsWith("http");De.debug("Opening mobile wallet via deep link",{wallet:this.walletEntry.name,redirectType:c?"universal":"native"}),oy(o,"_self"),ay({href:a,name:this.walletEntry.metadata?.shortName||this.walletEntry.name});let u=zc(s,this.walletEntry);return this.redirectUri=o,this.fallbackUniversalRedirectUri=u?.redirect,this.showPrivyQrModal({native:o,universal:o})}if(De.debug("Displaying WalletConnect QR code",{wallet:this.walletEntry?.name||"generic"}),this.redirectUri=void 0,this.walletEntry){let o=zc(s,this.walletEntry);this.fallbackUniversalRedirectUri=o?.redirect}this.showPrivyQrModal({native:s,universal:void 0})})),n.on("connect",(()=>{let s=n.session?.peer.metadata;De.debug("WalletConnect session established",{peerName:s?.name,peerIcon:s?.icons?.[0]?"present":"none"}),n.session?.peer.metadata.url&&(this.walletEntry=Ls(n.session?.peer.metadata.url),this.walletClientType=this.walletEntry?.slug||"unknown")})),n}async enableProvider(){return this.walletProvider?.connected?Promise.resolve(this.walletProvider.accounts):await this.walletProvider?.enable()}setWalletEntry(e,r){this.walletEntry=e,this.showPrivyQrModal=r}constructor({walletConnectCloudProjectId:e,rpcConfig:r,chains:i,defaultChain:n,shouldEnforceDefaultChainOnConnect:s,privyAppId:o,privyAppName:a,walletClientType:c}){super(c||"unknown",i,n,r),this.connectorType="wallet_connect_v2",this.privyAppId=o,this.privyAppName=a,this.walletConnectCloudProjectId=e,this.rpcConfig=r,this.shouldEnforceDefaultChainOnConnect=s,this.proxyProvider=new cy(void 0,this.rpcTimeoutDuration),c&&(this.walletEntry=uy(c),this.walletClientType=c)}}const SP=Object.freeze(Object.defineProperty({__proto__:null,WalletConnectV2WalletConnector:A4},Symbol.toStringTag,{value:"Module"}));export{Nt as A,wt as B,T2 as C,Ut as D,$g as E,SP as F,Qr as I,Hu as P,kd as Q,V as a,sr as b,c0 as c,Sy as d,ua as e,dn as f,Vb as g,Ub as h,j2 as i,ct as j,B8 as k,r_ as l,St as m,ei as n,Ac as o,fS as p,Oc as q,k2 as r,or as s,Ns as t,ln as u,Nv as v,Yr as w,Ga as x,_r as y,Us as z};