@acedatacloud/nexior 3.141.0 → 3.143.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{Auth-3aYg4zQW.js → Auth-CtUQEVNK.js} +1 -1
- package/dist/assets/{BotPlaceholder-B__fEJN9.js → BotPlaceholder-BPfrGl17.js} +1 -1
- package/dist/assets/{Callback-6PAiu69Q.js → Callback-CUZz-_uL.js} +1 -1
- package/dist/assets/{Console-CAUNb_iW.js → Console-CZyUJwFi.js} +1 -1
- package/dist/assets/{Consumption-JQ-zRz0e.js → Consumption-ClgEQgDH.js} +1 -1
- package/dist/assets/{Conversation-CSktyKjd.js → Conversation-BJLfspBm.js} +2 -2
- package/dist/assets/{CopyToClipboard-DATp0YfS.js → CopyToClipboard-B-j3IeKI.js} +1 -1
- package/dist/assets/Detail-slLvnO9U.js +2 -0
- package/dist/assets/{EditArray-Dvry3sKT.js → EditArray-B_9d9BF5.js} +1 -1
- package/dist/assets/{Extra-rYvlQN0s.js → Extra-FPsB7z1H.js} +1 -1
- package/dist/assets/{FilePreview-CWUOBM4X.js → FilePreview-DnWckrxT.js} +1 -1
- package/dist/assets/{History-BG1XD4s2.js → History-B0ogAEX0.js} +1 -1
- package/dist/assets/{IconPark.vue_vue_type_script_setup_true_lang-Cq9hsIRa.js → IconPark.vue_vue_type_script_setup_true_lang-BZE7qVtA.js} +1 -1
- package/dist/assets/{ImagePreview-BHCy1reF.js → ImagePreview-Dj1qrKsG.js} +1 -1
- package/dist/assets/{ImageWrapper-BET8UBiH.js → ImageWrapper-CW4rFhRa.js} +1 -1
- package/dist/assets/{Index-DJj1bDnC.js → Index-5KHWi7Dq.js} +1 -1
- package/dist/assets/{Index-KDMSRqUt.js → Index-B353sbqU.js} +1 -1
- package/dist/assets/{Index-csT0_n4-.js → Index-BFxmvZkU.js} +1 -1
- package/dist/assets/{Index-DjwdmSNq.js → Index-BHxzob5z.js} +1 -1
- package/dist/assets/{Index-D-QR5grv.js → Index-BMybNjHW.js} +1 -1
- package/dist/assets/{Index-DTN8JQvP.js → Index-BRZNJRcF.js} +1 -1
- package/dist/assets/{Index-CPNDtX6f.js → Index-BXflygvQ.js} +1 -1
- package/dist/assets/{Index-CDJ-c5d5.js → Index-Bpx7haqT.js} +1 -1
- package/dist/assets/{Index-PLx3gYXI.js → Index-CG-k5P0E.js} +1 -1
- package/dist/assets/{Index-B3wjI3dc.js → Index-CKQ20PRK.js} +1 -1
- package/dist/assets/{Index-IVS-Ot_C.js → Index-CNGIO1-q.js} +1 -1
- package/dist/assets/{Index-DJMY-Fde.js → Index-CSkumcf5.js} +1 -1
- package/dist/assets/{Index-nBUl1zbe.js → Index-CXG8sBCz.js} +1 -1
- package/dist/assets/{Index-BH6iph5-.js → Index-CXn6Z5SI.js} +1 -1
- package/dist/assets/{Index-CQSyworq.js → Index-C_jBhDqQ.js} +1 -1
- package/dist/assets/{Index-Bwg6AmFb.js → Index-CbRlUGpE.js} +1 -1
- package/dist/assets/{Index-BPoj-7iI.js → Index-CiBO7-CL.js} +1 -1
- package/dist/assets/{Index-B-8w_1Dc.js → Index-DQWQvmzR.js} +1 -1
- package/dist/assets/{Index--zRxsLfK.js → Index-DZGZybb4.js} +1 -1
- package/dist/assets/{Index-DxFKmeL2.js → Index-DyeXiZOC.js} +1 -1
- package/dist/assets/{Index-dVV_jMO2.js → Index-Dykr7MYF.js} +1 -1
- package/dist/assets/{Index-DtTvPEj0.js → Index-_KEm4PEs.js} +1 -1
- package/dist/assets/{Index-2nqZow6M.js → Index-d-dEUMMS.js} +1 -1
- package/dist/assets/{Index-Be7EIFJ7.js → Index-pd-FlLOH.js} +1 -1
- package/dist/assets/{Invitees-Cz8kKzAH.js → Invitees-CKE3swBs.js} +1 -1
- package/dist/assets/{List-CTOBpRZS.js → List-Bs9Dt7II.js} +1 -1
- package/dist/assets/{List-C8IhrXJF.js → List-HEowMEan.js} +1 -1
- package/dist/assets/{List-DNY4me-w.js → List-LJIK4Wu3.js} +1 -1
- package/dist/assets/{Main-JAWcoEci.js → Main-BMztfwzI.js} +1 -1
- package/dist/assets/{Navigator-nCx0zctM.js → Navigator-CQgH5RDk.js} +1 -1
- package/dist/assets/{NoTasks-D-HX_WRO.js → NoTasks-CUTKaxqT.js} +1 -1
- package/dist/assets/{NotFound-Bii7ankq.js → NotFound-D19HSsaM.js} +1 -1
- package/dist/assets/{OAuthCallback-WqHbw0Ff.js → OAuthCallback-Bjehu6_9.js} +1 -1
- package/dist/assets/{Pagination-Cs7qzInO.js → Pagination-D7oYcJPo.js} +1 -1
- package/dist/assets/{Status-B70iKLV9.js → Status-Dott-sZ5.js} +1 -1
- package/dist/assets/{Subscribe-Crv7wtnJ.js → Subscribe-Cuiwkot5.js} +1 -1
- package/dist/assets/{VideoPlayer-BnHxpSfK.js → VideoPlayer-D9YyWMtB.js} +1 -1
- package/dist/assets/{_Uint8Array-DE6T0OjR.js → _Uint8Array-DfhsEbA6.js} +1 -1
- package/dist/assets/{_baseClone-BK9DuJ-Q.js → _baseClone-0JASqonl.js} +1 -1
- package/dist/assets/{_baseIteratee-C1Fk6TCS.js → _baseIteratee-D64njDFX.js} +1 -1
- package/dist/assets/{_initCloneObject-BMnqIZRv.js → _initCloneObject-CT9aktWN.js} +1 -1
- package/dist/assets/{add-C96O-0sc.js → add-DzyDrpy_.js} +1 -1
- package/dist/assets/{aegis.min-CyBmduI0.js → aegis.min-oaWR29zZ.js} +1 -1
- package/dist/assets/{all-wallets-BqxfUyU2.js → all-wallets-C61SK3TG.js} +1 -1
- package/dist/assets/{app-store-BaaSZuOQ.js → app-store--3y1_rqD.js} +1 -1
- package/dist/assets/{apple-Dq9h4i86.js → apple-DCMexxNe.js} +1 -1
- package/dist/assets/{arrow-bottom-DvooFXyP.js → arrow-bottom-BLWgwgR_.js} +1 -1
- package/dist/assets/{arrow-bottom-circle-DT7ibQKG.js → arrow-bottom-circle-CO8dfn1r.js} +1 -1
- package/dist/assets/{arrow-left-Ql_GXNwd.js → arrow-left-BtBEwMpk.js} +1 -1
- package/dist/assets/{arrow-right-NjtoRP1k.js → arrow-right-DE867PMf.js} +1 -1
- package/dist/assets/{arrow-top-BpIc9EFZ.js → arrow-top-D6ia32Do.js} +1 -1
- package/dist/assets/{avatar-Bmzu5k6d.js → avatar-DoH5qvQb.js} +1 -1
- package/dist/assets/{bank-DFvmq_Fu.js → bank-nHz1zcsF.js} +1 -1
- package/dist/assets/{basic-CzlXus7C.js → basic-BATfqZ4A.js} +1 -1
- package/dist/assets/{browser-z_vIayx4.js → browser-BHdX4mfm.js} +1 -1
- package/dist/assets/{byokCredential-D5RMTXW9.js → byokCredential-BO7-v5YN.js} +1 -1
- package/dist/assets/{card-XCiPqK23.js → card-BnzclBSU.js} +1 -1
- package/dist/assets/{castArray-CfNHhez0.js → castArray-Den3_6LQ.js} +1 -1
- package/dist/assets/{chat-CldaknVn.js → chat-DZJrcSit.js} +1 -1
- package/dist/assets/{checkmark-B-hzn7uF.js → checkmark-CQSvr6ZZ.js} +1 -1
- package/dist/assets/{checkmark-bold-ccpb4eEx.js → checkmark-bold-6RskSnLi.js} +1 -1
- package/dist/assets/{chevron-bottom-D2m37JY0.js → chevron-bottom-CPCo3DY0.js} +1 -1
- package/dist/assets/{chevron-left-CGNcwOaD.js → chevron-left-BirjUKvX.js} +1 -1
- package/dist/assets/{chevron-right-BzpjNswK.js → chevron-right-CdU0xk79.js} +1 -1
- package/dist/assets/{chevron-top-Bj8ZZxOF.js → chevron-top-D1oFtKMM.js} +1 -1
- package/dist/assets/{chrome-store-Fbb_tmkX.js → chrome-store-6CbzVUB-.js} +1 -1
- package/dist/assets/{clock-BLFi-fAc.js → clock-DzwUWAMI.js} +1 -1
- package/dist/assets/{close-BUJ8S_cy.js → close-CwhwrwkW.js} +1 -1
- package/dist/assets/{coinPlaceholder-CShYjn6F.js → coinPlaceholder-H7CxrcQG.js} +1 -1
- package/dist/assets/{compass-CPP2sVek.js → compass-zOb3c-um.js} +1 -1
- package/dist/assets/{copy-qpK4Mh88.js → copy-CVogK2-j.js} +1 -1
- package/dist/assets/cursor-DoG7MjKg.js +3 -0
- package/dist/assets/{cursor-transparent-BuQu4Xza.js → cursor-transparent-BUzXtRXv.js} +1 -1
- package/dist/assets/{debounce-BPDgOl3K.js → debounce-qySOHK2f.js} +1 -1
- package/dist/assets/{desktop-BEB2x90I.js → desktop-BpN-Z-Th.js} +1 -1
- package/dist/assets/{disconnect-BppzJERm.js → disconnect-DjVB9pUw.js} +1 -1
- package/dist/assets/{discord-D9ErfH7F.js → discord-DAa-xF6t.js} +1 -1
- package/dist/assets/{distribution-COd8JnOO.js → distribution-CFTKR_7N.js} +1 -1
- package/dist/assets/{dropdown-C9AJw4pd.js → dropdown-QJOjX_D8.js} +1 -1
- package/dist/assets/{etherscan-Da2AijVM.js → etherscan-pBkuDjyY.js} +1 -1
- package/dist/assets/{exclamation-triangle-B02QzVJX.js → exclamation-triangle-Cqg9_-TP.js} +1 -1
- package/dist/assets/{extension-DlyOSX2E.js → extension-BoRHvse0.js} +1 -1
- package/dist/assets/{external-link-knj_xNEx.js → external-link-Co8JaB3x.js} +1 -1
- package/dist/assets/{facebook-Dhm2ywvk.js → facebook-DgDQRfgR.js} +1 -1
- package/dist/assets/{farcaster-B0tDtTPm.js → farcaster-D69aKskv.js} +1 -1
- package/dist/assets/{filters-CfIH0b4F.js → filters-D2dMSL_o.js} +1 -1
- package/dist/assets/{flux-BbGm0JgL.js → flux-BwAC3S5-.js} +1 -1
- package/dist/assets/fp.esm-DxpQCkCY.js +8 -0
- package/dist/assets/{github-D_UZMczu.js → github-D7whLcWp.js} +1 -1
- package/dist/assets/{google-BUgcji2K.js → google-DmFMO6N5.js} +1 -1
- package/dist/assets/{hailuo-DS8314uv.js → hailuo-B8zs9Ovu.js} +1 -1
- package/dist/assets/{headshots-BFUDeV3q.js → headshots-DanVR0aX.js} +1 -1
- package/dist/assets/{help-circle-M_TjG9cz.js → help-circle-DxoMXqOF.js} +1 -1
- package/dist/assets/{id-7gbtBKLO.js → id-DKliwwSL.js} +1 -1
- package/dist/assets/{image-ChIF8buh.js → image-B_J5ddmn.js} +1 -1
- package/dist/assets/{index-DxpHBLTs.js → index-0ObN0Dig.js} +1 -1
- package/dist/assets/{index-BHU0zbZw.js → index-60y9JL--.js} +1 -1
- package/dist/assets/{index-CVHPJfCy.js → index-9HGDSJTR.js} +1 -1
- package/dist/assets/{index-wTiYiYRV.js → index-ApUzrZjA.js} +1 -1
- package/dist/assets/{index-DVGd6Xhg.js → index-B1kni6-B.js} +1 -1
- package/dist/assets/index-B1q4_wjP.js +3 -0
- package/dist/assets/{index-Cqc9uxp4.js → index-B2Oy_3FT.js} +1 -1
- package/dist/assets/{index-7hkwQR4o.js → index-BPR2ZBL3.js} +1 -1
- package/dist/assets/{index-DneHSZ5q.js → index-BTIqLd-9.js} +1 -1
- package/dist/assets/{index-BwX5s8fC.js → index-BVx89d8R.js} +1 -1
- package/dist/assets/{index-MfRQJOXO.js → index-BW2wbkhi.js} +1 -1
- package/dist/assets/{index-DXLhI3ID.js → index-BWyQEIEc.js} +1 -1
- package/dist/assets/{index-D1obFrQ6.js → index-BY3ZI2OY.js} +1 -1
- package/dist/assets/{index-DBxdQscu.js → index-BiFnm5Fz.js} +1 -1
- package/dist/assets/{index-BWLI2t9f.js → index-BjJZ22Y3.js} +1 -1
- package/dist/assets/{index-BDzYsDx8.js → index-BlzSfoGW.js} +1 -1
- package/dist/assets/{index-BrkqK7sl.js → index-Bo_JlvjV.js} +1 -1
- package/dist/assets/{index-M62vPQwv.js → index-BowVIJh5.js} +1 -1
- package/dist/assets/{index-DYAa0XF7.js → index-BqyUpApV.js} +1 -1
- package/dist/assets/{index-MxDhROWk.js → index-Bs5Q_18V.js} +3 -3
- package/dist/assets/{index-BK5DuvIJ.js → index-ByRmkGAV.js} +1 -1
- package/dist/assets/index-C-wF25mS.js +1 -0
- package/dist/assets/{index-Je6LWhXA.js → index-C7C4YZtO.js} +1 -1
- package/dist/assets/{index-C6E1J777.js → index-C9wQOJYW.js} +1 -1
- package/dist/assets/{index-BLK3b_Xp.js → index-CH1zG0ot.js} +1 -1
- package/dist/assets/{index-DQBy2VTo.js → index-CHxnPGsh.js} +1 -1
- package/dist/assets/{index-zDkOHKSg.js → index-CJo-6wRX.js} +1 -1
- package/dist/assets/index-CL9QQab3.js +904 -0
- package/dist/assets/{index-D9rmPKho.js → index-CTDK5ATG.js} +1 -1
- package/dist/assets/{index-Dl8-Goxg.js → index-CTjlNIkO.js} +1 -1
- package/dist/assets/{index-guHdpfEc.js → index-CXhhCjmF.js} +1 -1
- package/dist/assets/{index-Bn4rDC6S.js → index-C_B9_8m5.js} +1 -1
- package/dist/assets/{index-DCtjoVct.js → index-Cefy4vQg.js} +1 -1
- package/dist/assets/{index-CkyhGtoC.js → index-CkIeLqJ4.js} +1 -1
- package/dist/assets/{index-L26y6paB.js → index-CkrK0Qe5.js} +1 -1
- package/dist/assets/{index-DezIxVaW.js → index-Cl0U4sgn.js} +1 -1
- package/dist/assets/{index-i-5UiV7F.js → index-Cmh-m9tQ.js} +1 -1
- package/dist/assets/{index-PVHx9bSd.js → index-CpSvxFK6.js} +1 -1
- package/dist/assets/{index-CjrJCVi3.js → index-Cyf8EOi-.js} +13 -13
- package/dist/assets/{index-CoqvM4YB.js → index-D1bOBFvl.js} +1 -1
- package/dist/assets/{index-D40MqQyw.js → index-D6eGd2z6.js} +1 -1
- package/dist/assets/{index-CnRhLgvn.js → index-DMZjaLyD.js} +1 -1
- package/dist/assets/{index-CEEKnqKe.js → index-DR3AmhzB.js} +1 -1
- package/dist/assets/{index-hKpIA3KX.js → index-DV28EGIy.js} +1 -1
- package/dist/assets/{index-qpE79lxS.js → index-DcJdQSfw.js} +1 -1
- package/dist/assets/{index-CcDIRTSY.js → index-DdEU08KU.js} +1 -1
- package/dist/assets/{index-Bw4p7Hn6.js → index-De59Ka4m.js} +1 -1
- package/dist/assets/index-Dhu22YaW.js +1 -0
- package/dist/assets/{index-C5ILW1Ou.js → index-DoXdKcuT.js} +1 -1
- package/dist/assets/{index-NUDTQYA9.js → index-Dt3X1kZ4.js} +1 -1
- package/dist/assets/index-DuNzbqbv.js +2 -0
- package/dist/assets/{index-DYRY4x8a.js → index-DxKv9BIl.js} +1 -1
- package/dist/assets/{index--4e-9241.js → index-DxpQaVyM.js} +1 -1
- package/dist/assets/{index-BKLIEE62.js → index-DyXkWXGx.js} +1 -1
- package/dist/assets/{index-ClwdU7O1.js → index-Hg-ElA3u.js} +1 -1
- package/dist/assets/{index-DroKJlFz.js → index-IuzkX0PB.js} +1 -1
- package/dist/assets/{index-DYIElpgN.js → index-NUkv1M5_.js} +1 -1
- package/dist/assets/{index-C23AoQtX.js → index-Vod2n73X.js} +1 -1
- package/dist/assets/{index-eSHn18d5.js → index-XaPqTDhv.js} +1 -1
- package/dist/assets/{index-Ck7-3bp_.js → index-kGAGAJMD.js} +1 -1
- package/dist/assets/{index-CehygrDL.js → index-qn-HlcRf.js} +1 -1
- package/dist/assets/{index-BK8wZFB8.js → index-vIjQu9iy.js} +1 -1
- package/dist/assets/index.browser.esm-D-iED0Cc.js +8 -0
- package/dist/assets/{index.es-SZUFV4pc.js → index.es-TsWsNkRg.js} +1 -1
- package/dist/assets/{info-DZ4Oo8s_.js → info-CL_whZjn.js} +1 -1
- package/dist/assets/{info-circle-BQA7CrQA.js → info-circle-zTGxSNMv.js} +1 -1
- package/dist/assets/{isEqual-CsjxLFGH.js → isEqual-Dcf8wohg.js} +1 -1
- package/dist/assets/{isPlainObject-DuzUySLk.js → isPlainObject-DoEvj-JF.js} +1 -1
- package/dist/assets/{kling-xorFo7AD.js → kling-CHRtfU1h.js} +1 -1
- package/dist/assets/{lightbulb-De6yafhi.js → lightbulb-Bs5mJUnu.js} +1 -1
- package/dist/assets/{luma-7_ybMb_6.js → luma-DnaLw93c.js} +1 -1
- package/dist/assets/{mail-C8PkVLtO.js → mail-0QMW3eXE.js} +1 -1
- package/dist/assets/{midjourney-CY1LgUIp.js → midjourney-CS8ptNIO.js} +1 -1
- package/dist/assets/{mobile-UWJrrWLf.js → mobile-DuSCK1a5.js} +1 -1
- package/dist/assets/{more-Fzja37Wl.js → more-DG-UiUYg.js} +1 -1
- package/dist/assets/{nanobanana-CkFNR3ve.js → nanobanana-CxQYAZGf.js} +1 -1
- package/dist/assets/{network-placeholder-7BHKRsM8.js → network-placeholder-DVZvCh2s.js} +1 -1
- package/dist/assets/{nftPlaceholder-Bo1dT09a.js → nftPlaceholder-lPnm7SOn.js} +1 -1
- package/dist/assets/{off-B_KjApPd.js → off-C8urHZqx.js} +1 -1
- package/dist/assets/{openaiimage-DbeIKgYk.js → openaiimage-B-V3xEPL.js} +1 -1
- package/dist/assets/{order-CxdsB8ao.js → order-Bmp_yaG1.js} +1 -1
- package/dist/assets/{pagination-zLOBSvf0.js → pagination-Kf9WeXkv.js} +1 -1
- package/dist/assets/{pika-lzF_S5Tj.js → pika-BiKq2nSB.js} +1 -1
- package/dist/assets/{pixverse-Bok-8m_R.js → pixverse-C4gMbePC.js} +1 -1
- package/dist/assets/{play-store-BqPYWJm6.js → play-store-XGMJl_Pn.js} +1 -1
- package/dist/assets/{plus-bF5_EB61.js → plus-BqgdwTLw.js} +1 -1
- package/dist/assets/{price-Sv1Sj9H3.js → price-CnHV1sgg.js} +1 -1
- package/dist/assets/{producer-D677gy2i.js → producer-DBQx_C86.js} +1 -1
- package/dist/assets/{qr-code-as7_JVoX.js → qr-code-EM8QiYyD.js} +1 -1
- package/dist/assets/{qrart-vHHgK44j.js → qrart-Dw2YrUVF.js} +1 -1
- package/dist/assets/{recycle-horizontal-BHq_wKfu.js → recycle-horizontal-DNZ_fKjj.js} +1 -1
- package/dist/assets/{refresh-AqqZZpdz.js → refresh-C6pr3cc6.js} +1 -1
- package/dist/assets/{reown-logo-B5v7fkEL.js → reown-logo-BczI0j4a.js} +1 -1
- package/dist/assets/{search-BwZVcAFw.js → search-i-aR-LkD.js} +1 -1
- package/dist/assets/{secp256k1-BAXGIkp5.js → secp256k1-64NdIXXC.js} +1 -1
- package/dist/assets/{secp256k1-C43lEMBe.js → secp256k1-BH-Xrsbp.js} +1 -1
- package/dist/assets/{seedance-_MAoP_lJ.js → seedance-D-UOraSv.js} +1 -1
- package/dist/assets/{seedream-BdJOMHdm.js → seedream--P09hKyP.js} +1 -1
- package/dist/assets/{send-_iojLXQX.js → send-BKqbXKgW.js} +1 -1
- package/dist/assets/{service-D8pTLxfo.js → service-BSfAGiOY.js} +1 -1
- package/dist/assets/{signer-Bt6hppoz.js → signer-VxQoXw0x.js} +1 -1
- package/dist/assets/solana-wallets-OgrTm8Iq.js +2 -0
- package/dist/assets/{solana-wallets-vue-Dv4JQfB7.js → solana-wallets-vue-Ca9b6qlb.js} +7 -7
- package/dist/assets/{sora-DrifPRi3.js → sora-BC_C_K6y.js} +1 -1
- package/dist/assets/{suno-jobuFjWf.js → suno-DJNe_FQB.js} +1 -1
- package/dist/assets/{swapHorizontal-Bc0J_Zwv.js → swapHorizontal-67e30EgZ.js} +1 -1
- package/dist/assets/{swapHorizontalBold-c9aQvTNb.js → swapHorizontalBold-DeASCDI4.js} +1 -1
- package/dist/assets/{swapHorizontalMedium-DkBfc3CM.js → swapHorizontalMedium-xCn2o46w.js} +1 -1
- package/dist/assets/{swapHorizontalRoundedBold-wz3AQfWh.js → swapHorizontalRoundedBold-BbahDpkx.js} +1 -1
- package/dist/assets/{swapVertical-DbP_Dr5T.js → swapVertical-Cgc3RF8L.js} +1 -1
- package/dist/assets/{telegram-Dx1PgMDc.js → telegram-8VQcI4of.js} +1 -1
- package/dist/assets/{three-dots-B15JjTHU.js → three-dots-B2Z18kUd.js} +1 -1
- package/dist/assets/{twitch-DOlxfeDz.js → twitch-DjoQouxh.js} +1 -1
- package/dist/assets/{twitterIcon-QlLr_yXl.js → twitterIcon-hMeBY06b.js} +1 -1
- package/dist/assets/{typescript-BZnWy4Bd.js → typescript-C1XBDfAK.js} +1 -1
- package/dist/assets/{use-form-item-BqnxTqcj.js → use-form-item-RRBZ2FOX.js} +1 -1
- package/dist/assets/validator-DZr7xmmp.js +1 -0
- package/dist/assets/{vendor-dayjs-Cvgzdobq.js → vendor-dayjs-v0j1UNZp.js} +1 -1
- package/dist/assets/{vendor-highlight-Mh8RTITr.js → vendor-highlight-lEWW1Jxd.js} +1 -1
- package/dist/assets/{veo-BuLQ-o05.js → veo-CtD3A3j-.js} +1 -1
- package/dist/assets/{verify-filled-JwkGlMvo.js → verify-filled-CY_YWmoQ.js} +1 -1
- package/dist/assets/{verify-C23xui3e.js → verify-ghGtyftd.js} +1 -1
- package/dist/assets/{w3m-modal-Vm-J1GvD.js → w3m-modal-DejLuZa8.js} +1 -1
- package/dist/assets/{wallet-BFf-hX9n.js → wallet-BWHSp4R8.js} +1 -1
- package/dist/assets/{wallet-placeholder-BWNI_3Ro.js → wallet-placeholder-rUJuUg4d.js} +1 -1
- package/dist/assets/{walletconnect-DsKN4Ih8.js → walletconnect-JjlChPhX.js} +1 -1
- package/dist/assets/{wan-CopRmIT9.js → wan-CaJsMNtt.js} +1 -1
- package/dist/assets/{warning-circle-Ds_0qkqf.js → warning-circle-BJhp1Zgv.js} +1 -1
- package/dist/assets/{web-CG7tPkux.js → web-BKG_umNP.js} +1 -1
- package/dist/assets/{web-DXzOnFBt.js → web-CfaNoXz2.js} +1 -1
- package/dist/assets/{x-Dx-tDohG.js → x-CRob5JDu.js} +1 -1
- package/dist/index.html +2 -2
- package/package.json +5 -6
- package/dist/assets/Detail-BeZYBdTd.js +0 -2
- package/dist/assets/TransportWebHID-IYLeh2FJ.js +0 -1
- package/dist/assets/_commonjs-dynamic-modules-TDtrdbi3.js +0 -1
- package/dist/assets/bignumber-C3amavAD.js +0 -1
- package/dist/assets/cursor-CmjOudFl.js +0 -3
- package/dist/assets/draggabilly-C9AcGLUK.js +0 -1
- package/dist/assets/fp.esm-DHUg1SIa.js +0 -8
- package/dist/assets/index--ewSZOjg.js +0 -30
- package/dist/assets/index-B0M1bXln.js +0 -3
- package/dist/assets/index-B2wclSMp.js +0 -1
- package/dist/assets/index-CBbsBQha.js +0 -1
- package/dist/assets/index-CISYOTMH.js +0 -290
- package/dist/assets/index-CaaVrpc7.js +0 -151
- package/dist/assets/index-CxUeIbEw.js +0 -1
- package/dist/assets/index-D0w7Z8ty.js +0 -911
- package/dist/assets/index.browser.esm-BCQuHR2f.js +0 -8
- package/dist/assets/solana-wallets-ysFpa2tR.js +0 -2
- package/dist/assets/solanaEmbed.esm-DLm5-KIb.js +0 -10
- package/dist/assets/string_decoder-CF6EZ2r5.js +0 -1
- package/dist/assets/tslib.es6-ooV_ZcXm.js +0 -1
- package/dist/assets/validator-DxIrjUeh.js +0 -1
|
@@ -0,0 +1,904 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/secp256k1-BH-Xrsbp.js","assets/index.browser.esm-D-iED0Cc.js","assets/vendor-dayjs-v0j1UNZp.js","assets/index-Cyf8EOi-.js","assets/vendor-vue-NSDaktjZ.js","assets/vendor-axios-B8_nURbH.js","assets/vendor-vue-router-Kg6s1a65.js","assets/index-DZIBVLbD.css","assets/index-9HGDSJTR.js","assets/signer-VxQoXw0x.js","assets/types-Cvj5H4DH.js","assets/secp256k1-64NdIXXC.js","assets/basic-BATfqZ4A.js","assets/index-Bs5Q_18V.js","assets/w3m-modal-DejLuZa8.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{PublicKey as ZE,VersionedTransaction as e4,Transaction as t4}from"./index.browser.esm-D-iED0Cc.js";import{g as wh,j as Yv,c as Yr}from"./vendor-dayjs-v0j1UNZp.js";import{_ as Jl,eg as Jv}from"./index-Cyf8EOi-.js";import{e as r4,w as c0,b as i4,n as Yh,l as s4,u as n4,g as o4,k as Qu,r as Jh,q as a4}from"./signer-VxQoXw0x.js";import{W as c4}from"./types-Cvj5H4DH.js";var Ql;(function(t){t.Mainnet="solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",t.Devnet="solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",t.Deprecated_Mainnet="solana:4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ",t.Deprecated_Devnet="solana:8E9rvCKLFQia2Y35HXjjpWzj8weVo44K"})(Ql||(Ql={}));var $i;(function(t){t.signTransaction="solana_signTransaction",t.signMessage="solana_signMessage",t.signAndSendTransaction="solana_signAndSendTransaction",t.signAndSendAllTransactions="solana_signAndSendAllTransactions",t.signAllTransactions="solana_signAllTransactions"})($i||($i={}));const tr={Mainnet:"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",Devnet:"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",Deprecated_Mainnet:"solana:4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ",Deprecated_Devnet:"solana:8E9rvCKLFQia2Y35HXjjpWzj8weVo44K"};var Xu={exports:{}},u0;function u4(){if(u0)return Xu.exports;u0=1;var t=typeof Reflect=="object"?Reflect:null,e=t&&typeof t.apply=="function"?t.apply:function(T,x,M){return Function.prototype.apply.call(T,x,M)},r;t&&typeof t.ownKeys=="function"?r=t.ownKeys:Object.getOwnPropertySymbols?r=function(T){return Object.getOwnPropertyNames(T).concat(Object.getOwnPropertySymbols(T))}:r=function(T){return Object.getOwnPropertyNames(T)};function i(O){console&&console.warn&&console.warn(O)}var s=Number.isNaN||function(T){return T!==T};function n(){n.init.call(this)}Xu.exports=n,Xu.exports.once=S,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._eventsCount=0,n.prototype._maxListeners=void 0;var o=10;function a(O){if(typeof O!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof O)}Object.defineProperty(n,"defaultMaxListeners",{enumerable:!0,get:function(){return o},set:function(O){if(typeof O!="number"||O<0||s(O))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+O+".");o=O}}),n.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},n.prototype.setMaxListeners=function(T){if(typeof T!="number"||T<0||s(T))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+T+".");return this._maxListeners=T,this};function u(O){return O._maxListeners===void 0?n.defaultMaxListeners:O._maxListeners}n.prototype.getMaxListeners=function(){return u(this)},n.prototype.emit=function(T){for(var x=[],M=1;M<arguments.length;M++)x.push(arguments[M]);var U=T==="error",R=this._events;if(R!==void 0)U=U&&R.error===void 0;else if(!U)return!1;if(U){var L;if(x.length>0&&(L=x[0]),L instanceof Error)throw L;var $=new Error("Unhandled error."+(L?" ("+L.message+")":""));throw $.context=L,$}var d=R[T];if(d===void 0)return!1;if(typeof d=="function")e(d,this,x);else for(var b=d.length,_=g(d,b),M=0;M<b;++M)e(_[M],this,x);return!0};function c(O,T,x,M){var U,R,L;if(a(x),R=O._events,R===void 0?(R=O._events=Object.create(null),O._eventsCount=0):(R.newListener!==void 0&&(O.emit("newListener",T,x.listener?x.listener:x),R=O._events),L=R[T]),L===void 0)L=R[T]=x,++O._eventsCount;else if(typeof L=="function"?L=R[T]=M?[x,L]:[L,x]:M?L.unshift(x):L.push(x),U=u(O),U>0&&L.length>U&&!L.warned){L.warned=!0;var $=new Error("Possible EventEmitter memory leak detected. "+L.length+" "+String(T)+" listeners added. Use emitter.setMaxListeners() to increase limit");$.name="MaxListenersExceededWarning",$.emitter=O,$.type=T,$.count=L.length,i($)}return O}n.prototype.addListener=function(T,x){return c(this,T,x,!1)},n.prototype.on=n.prototype.addListener,n.prototype.prependListener=function(T,x){return c(this,T,x,!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(O,T,x){var M={fired:!1,wrapFn:void 0,target:O,type:T,listener:x},U=l.bind(M);return U.listener=x,M.wrapFn=U,U}n.prototype.once=function(T,x){return a(x),this.on(T,h(this,T,x)),this},n.prototype.prependOnceListener=function(T,x){return a(x),this.prependListener(T,h(this,T,x)),this},n.prototype.removeListener=function(T,x){var M,U,R,L,$;if(a(x),U=this._events,U===void 0)return this;if(M=U[T],M===void 0)return this;if(M===x||M.listener===x)--this._eventsCount===0?this._events=Object.create(null):(delete U[T],U.removeListener&&this.emit("removeListener",T,M.listener||x));else if(typeof M!="function"){for(R=-1,L=M.length-1;L>=0;L--)if(M[L]===x||M[L].listener===x){$=M[L].listener,R=L;break}if(R<0)return this;R===0?M.shift():y(M,R),M.length===1&&(U[T]=M[0]),U.removeListener!==void 0&&this.emit("removeListener",T,$||x)}return this},n.prototype.off=n.prototype.removeListener,n.prototype.removeAllListeners=function(T){var x,M,U;if(M=this._events,M===void 0)return this;if(M.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):M[T]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete M[T]),this;if(arguments.length===0){var R=Object.keys(M),L;for(U=0;U<R.length;++U)L=R[U],L!=="removeListener"&&this.removeAllListeners(L);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(x=M[T],typeof x=="function")this.removeListener(T,x);else if(x!==void 0)for(U=x.length-1;U>=0;U--)this.removeListener(T,x[U]);return this};function f(O,T,x){var M=O._events;if(M===void 0)return[];var U=M[T];return U===void 0?[]:typeof U=="function"?x?[U.listener||U]:[U]:x?C(U):g(U,U.length)}n.prototype.listeners=function(T){return f(this,T,!0)},n.prototype.rawListeners=function(T){return f(this,T,!1)},n.listenerCount=function(O,T){return typeof O.listenerCount=="function"?O.listenerCount(T):m.call(O,T)},n.prototype.listenerCount=m;function m(O){var T=this._events;if(T!==void 0){var x=T[O];if(typeof x=="function")return 1;if(x!==void 0)return x.length}return 0}n.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]};function g(O,T){for(var x=new Array(T),M=0;M<T;++M)x[M]=O[M];return x}function y(O,T){for(;T+1<O.length;T++)O[T]=O[T+1];O.pop()}function C(O){for(var T=new Array(O.length),x=0;x<T.length;++x)T[x]=O[x].listener||O[x];return T}function S(O,T){return new Promise(function(x,M){function U(L){O.removeListener(T,R),M(L)}function R(){typeof O.removeListener=="function"&&O.removeListener("error",U),x([].slice.call(arguments))}D(O,T,R,{once:!0}),T!=="error"&&A(O,U,{once:!0})})}function A(O,T,x){typeof O.on=="function"&&D(O,"error",T,x)}function D(O,T,x,M){if(typeof O.on=="function")M.once?O.once(T,x):O.on(T,x);else if(typeof O.addEventListener=="function")O.addEventListener(T,function U(R){M.once&&O.removeEventListener(T,U),x(R)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof O)}return Xu.exports}var sr=u4();const wa=wh(sr);var Qh={};var qf=function(t,e){return qf=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var s in i)i.hasOwnProperty(s)&&(r[s]=i[s])},qf(t,e)};function l4(t,e){qf(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var Bf=function(){return Bf=Object.assign||function(e){for(var r,i=1,s=arguments.length;i<s;i++){r=arguments[i];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},Bf.apply(this,arguments)};function h4(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 s=0,i=Object.getOwnPropertySymbols(t);s<i.length;s++)e.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(t,i[s])&&(r[i[s]]=t[i[s]]);return r}function d4(t,e,r,i){var s=arguments.length,n=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(n=(s<3?o(n):s>3?o(e,r,n):o(e,r))||n);return s>3&&n&&Object.defineProperty(e,r,n),n}function f4(t,e){return function(r,i){e(r,i,t)}}function p4(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function g4(t,e,r,i){function s(n){return n instanceof r?n:new r(function(o){o(n)})}return new(r||(r=Promise))(function(n,o){function a(l){try{c(i.next(l))}catch(h){o(h)}}function u(l){try{c(i.throw(l))}catch(h){o(h)}}function c(l){l.done?n(l.value):s(l.value).then(a,u)}c((i=i.apply(t,e||[])).next())})}function b4(t,e){var r={label:0,sent:function(){if(n[0]&1)throw n[1];return n[1]},trys:[],ops:[]},i,s,n,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(c){return function(l){return u([c,l])}}function u(c){if(i)throw new TypeError("Generator is already executing.");for(;r;)try{if(i=1,s&&(n=c[0]&2?s.return:c[0]?s.throw||((n=s.return)&&n.call(s),0):s.next)&&!(n=n.call(s,c[1])).done)return n;switch(s=0,n&&(c=[c[0]&2,n.value]),c[0]){case 0:case 1:n=c;break;case 4:return r.label++,{value:c[1],done:!1};case 5:r.label++,s=c[1],c=[0];continue;case 7:c=r.ops.pop(),r.trys.pop();continue;default:if(n=r.trys,!(n=n.length>0&&n[n.length-1])&&(c[0]===6||c[0]===2)){r=0;continue}if(c[0]===3&&(!n||c[1]>n[0]&&c[1]<n[3])){r.label=c[1];break}if(c[0]===6&&r.label<n[1]){r.label=n[1],n=c;break}if(n&&r.label<n[2]){r.label=n[2],r.ops.push(c);break}n[2]&&r.ops.pop(),r.trys.pop();continue}c=e.call(t,r)}catch(l){c=[6,l],s=0}finally{i=n=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}function m4(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}function y4(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function zf(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 Qv(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var i=r.call(t),s,n=[],o;try{for(;(e===void 0||e-- >0)&&!(s=i.next()).done;)n.push(s.value)}catch(a){o={error:a}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return n}function w4(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Qv(arguments[e]));return t}function v4(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var i=Array(t),s=0,e=0;e<r;e++)for(var n=arguments[e],o=0,a=n.length;o<a;o++,s++)i[s]=n[o];return i}function Lc(t){return this instanceof Lc?(this.v=t,this):new Lc(t)}function _4(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=r.apply(t,e||[]),s,n=[];return s={},o("next"),o("throw"),o("return"),s[Symbol.asyncIterator]=function(){return this},s;function o(f){i[f]&&(s[f]=function(m){return new Promise(function(g,y){n.push([f,m,g,y])>1||a(f,m)})})}function a(f,m){try{u(i[f](m))}catch(g){h(n[0][3],g)}}function u(f){f.value instanceof Lc?Promise.resolve(f.value.v).then(c,l):h(n[0][2],f)}function c(f){a("next",f)}function l(f){a("throw",f)}function h(f,m){f(m),n.shift(),n.length&&a(n[0][0],n[0][1])}}function E4(t){var e,r;return e={},i("next"),i("throw",function(s){throw s}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(s,n){e[s]=t[s]?function(o){return(r=!r)?{value:Lc(t[s](o)),done:s==="return"}:n?n(o):o}:n}}function I4(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 zf=="function"?zf(t):t[Symbol.iterator](),r={},i("next"),i("throw"),i("return"),r[Symbol.asyncIterator]=function(){return this},r);function i(n){r[n]=t[n]&&function(o){return new Promise(function(a,u){o=t[n](o),s(a,u,o.done,o.value)})}}function s(n,o,a,u){Promise.resolve(u).then(function(c){n({value:c,done:a})},o)}}function A4(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function S4(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 C4(t){return t&&t.__esModule?t:{default:t}}function $4(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function x4(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 P4=Object.freeze(Object.defineProperty({__proto__:null,get __assign(){return Bf},__asyncDelegator:E4,__asyncGenerator:_4,__asyncValues:I4,__await:Lc,__awaiter:g4,__classPrivateFieldGet:$4,__classPrivateFieldSet:x4,__createBinding:m4,__decorate:d4,__exportStar:y4,__extends:l4,__generator:b4,__importDefault:C4,__importStar:S4,__makeTemplateObject:A4,__metadata:p4,__param:f4,__read:Qv,__rest:h4,__spread:w4,__spreadArrays:v4,__values:zf},Symbol.toStringTag,{value:"Module"})),vh=Yv(P4);var Xh={},Ga={},l0;function N4(){if(l0)return Ga;l0=1,Object.defineProperty(Ga,"__esModule",{value:!0}),Ga.delay=void 0;function t(e){return new Promise(r=>{setTimeout(()=>{r(!0)},e)})}return Ga.delay=t,Ga}var bn={},Zh={},mn={},h0;function O4(){return h0||(h0=1,Object.defineProperty(mn,"__esModule",{value:!0}),mn.ONE_THOUSAND=mn.ONE_HUNDRED=void 0,mn.ONE_HUNDRED=100,mn.ONE_THOUSAND=1e3),mn}var ed={},d0;function T4(){return d0||(d0=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})(ed)),ed}var f0;function Xv(){return f0||(f0=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=vh;e.__exportStar(O4(),t),e.__exportStar(T4(),t)})(Zh)),Zh}var p0;function D4(){if(p0)return bn;p0=1,Object.defineProperty(bn,"__esModule",{value:!0}),bn.fromMiliseconds=bn.toMiliseconds=void 0;const t=Xv();function e(i){return i*t.ONE_THOUSAND}bn.toMiliseconds=e;function r(i){return Math.floor(i/t.ONE_THOUSAND)}return bn.fromMiliseconds=r,bn}var g0;function R4(){return g0||(g0=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=vh;e.__exportStar(N4(),t),e.__exportStar(D4(),t)})(Xh)),Xh}var oo={},b0;function M4(){if(b0)return oo;b0=1,Object.defineProperty(oo,"__esModule",{value:!0}),oo.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 s=Date.now()-i.started;this.timestamps.set(r,{started:i.started,elapsed:s})}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 oo.Watch=t,oo.default=t,oo}var td={},Ya={},m0;function k4(){if(m0)return Ya;m0=1,Object.defineProperty(Ya,"__esModule",{value:!0}),Ya.IWatch=void 0;class t{}return Ya.IWatch=t,Ya}var y0;function U4(){return y0||(y0=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),vh.__exportStar(k4(),t)})(td)),td}var w0;function L4(){return w0||(w0=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=vh;e.__exportStar(R4(),t),e.__exportStar(M4(),t),e.__exportStar(U4(),t),e.__exportStar(Xv(),t)})(Qh)),Qh}var B=L4();class pi{}let F4=class extends pi{constructor(e){super()}};const v0=B.FIVE_SECONDS,Hi={pulse:"heartbeat_pulse"};let Zv=class e1 extends F4{constructor(e){super(e),this.events=new sr.EventEmitter,this.interval=v0,this.interval=e?.interval||v0}static async init(e){const r=new e1(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(),B.toMiliseconds(this.interval))}pulse(){this.events.emit(Hi.pulse)}};const j4=/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,q4=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,B4=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function z4(t,e){if(t==="__proto__"||t==="constructor"&&e&&typeof e=="object"&&"prototype"in e){H4(t);return}return e}function H4(t){console.warn(`[destr] Dropping "${t}" key to prevent prototype pollution.`)}function Zu(t,e={}){if(typeof t!="string")return t;if(t[0]==='"'&&t[t.length-1]==='"'&&t.indexOf("\\")===-1)return t.slice(1,-1);const r=t.trim();if(r.length<=9)switch(r.toLowerCase()){case"true":return!0;case"false":return!1;case"undefined":return;case"null":return null;case"nan":return Number.NaN;case"infinity":return Number.POSITIVE_INFINITY;case"-infinity":return Number.NEGATIVE_INFINITY}if(!B4.test(t)){if(e.strict)throw new SyntaxError("[destr] Invalid JSON");return t}try{if(j4.test(t)||q4.test(t)){if(e.strict)throw new Error("[destr] Possible prototype pollution");return JSON.parse(t,z4)}return JSON.parse(t)}catch(i){if(e.strict)throw i;return t}}function V4(t){return!t||typeof t.then!="function"?Promise.resolve(t):t}function lr(t,...e){try{return V4(t(...e))}catch(r){return Promise.reject(r)}}function K4(t){const e=typeof t;return t===null||e!=="object"&&e!=="function"}function W4(t){const e=Object.getPrototypeOf(t);return!e||e.isPrototypeOf(Object)}function Dl(t){if(K4(t))return String(t);if(W4(t)||Array.isArray(t))return JSON.stringify(t);if(typeof t.toJSON=="function")return Dl(t.toJSON());throw new Error("[unstorage] Cannot stringify value!")}const Hf="base64:";function G4(t){return typeof t=="string"?t:Hf+Q4(t)}function Y4(t){return typeof t!="string"||!t.startsWith(Hf)?t:J4(t.slice(Hf.length))}function J4(t){return globalThis.Buffer?Buffer.from(t,"base64"):Uint8Array.from(globalThis.atob(t),e=>e.codePointAt(0))}function Q4(t){return globalThis.Buffer?Buffer.from(t).toString("base64"):globalThis.btoa(String.fromCodePoint(...t))}function Kr(t){return t&&t.split("?")[0]?.replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,"")||""}function X4(...t){return Kr(t.join(":"))}function el(t){return t=Kr(t),t?t+":":""}function Z4(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 e5(t,e){return e?t.startsWith(e)&&t[t.length-1]!=="$":t[t.length-1]!=="$"}const t5="memory",r5=()=>{const t=new Map;return{name:t5,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 i5(t={}){const e={mounts:{"":t.driver||r5()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},r=c=>{for(const l of e.mountpoints)if(c.startsWith(l))return{base:l,relativeKey:c.slice(l.length),driver:e.mounts[l]};return{base:"",relativeKey:c,driver:e.mounts[""]}},i=(c,l)=>e.mountpoints.filter(h=>h.startsWith(c)||l&&c.startsWith(h)).map(h=>({relativeBase:c.length>h.length?c.slice(h.length):void 0,mountpoint:h,driver:e.mounts[h]})),s=(c,l)=>{if(e.watching){l=Kr(l);for(const h of e.watchListeners)h(c,l)}},n=async()=>{if(!e.watching){e.watching=!0;for(const c in e.mounts)e.unwatch[c]=await _0(e.mounts[c],s,c)}},o=async()=>{if(e.watching){for(const c in e.unwatch)await e.unwatch[c]();e.unwatch={},e.watching=!1}},a=(c,l,h)=>{const f=new Map,m=g=>{let y=f.get(g.base);return y||(y={driver:g.driver,base:g.base,items:[]},f.set(g.base,y)),y};for(const g of c){const y=typeof g=="string",C=Kr(y?g:g.key),S=y?void 0:g.value,A=y||!g.options?l:{...l,...g.options},D=r(C);m(D).items.push({key:C,value:S,relativeKey:D.relativeKey,options:A})}return Promise.all([...f.values()].map(g=>h(g))).then(g=>g.flat())},u={hasItem(c,l={}){c=Kr(c);const{relativeKey:h,driver:f}=r(c);return lr(f.hasItem,h,l)},getItem(c,l={}){c=Kr(c);const{relativeKey:h,driver:f}=r(c);return lr(f.getItem,h,l).then(m=>Zu(m))},getItems(c,l={}){return a(c,l,h=>h.driver.getItems?lr(h.driver.getItems,h.items.map(f=>({key:f.relativeKey,options:f.options})),l).then(f=>f.map(m=>({key:X4(h.base,m.key),value:Zu(m.value)}))):Promise.all(h.items.map(f=>lr(h.driver.getItem,f.relativeKey,f.options).then(m=>({key:f.key,value:Zu(m)})))))},getItemRaw(c,l={}){c=Kr(c);const{relativeKey:h,driver:f}=r(c);return f.getItemRaw?lr(f.getItemRaw,h,l):lr(f.getItem,h,l).then(m=>Y4(m))},async setItem(c,l,h={}){if(l===void 0)return u.removeItem(c);c=Kr(c);const{relativeKey:f,driver:m}=r(c);m.setItem&&(await lr(m.setItem,f,Dl(l),h),m.watch||s("update",c))},async setItems(c,l){await a(c,l,async h=>{if(h.driver.setItems)return lr(h.driver.setItems,h.items.map(f=>({key:f.relativeKey,value:Dl(f.value),options:f.options})),l);h.driver.setItem&&await Promise.all(h.items.map(f=>lr(h.driver.setItem,f.relativeKey,Dl(f.value),f.options)))})},async setItemRaw(c,l,h={}){if(l===void 0)return u.removeItem(c,h);c=Kr(c);const{relativeKey:f,driver:m}=r(c);if(m.setItemRaw)await lr(m.setItemRaw,f,l,h);else if(m.setItem)await lr(m.setItem,f,G4(l),h);else return;m.watch||s("update",c)},async removeItem(c,l={}){typeof l=="boolean"&&(l={removeMeta:l}),c=Kr(c);const{relativeKey:h,driver:f}=r(c);f.removeItem&&(await lr(f.removeItem,h,l),(l.removeMeta||l.removeMata)&&await lr(f.removeItem,h+"$",l),f.watch||s("remove",c))},async getMeta(c,l={}){typeof l=="boolean"&&(l={nativeOnly:l}),c=Kr(c);const{relativeKey:h,driver:f}=r(c),m=Object.create(null);if(f.getMeta&&Object.assign(m,await lr(f.getMeta,h,l)),!l.nativeOnly){const g=await lr(f.getItem,h+"$",l).then(y=>Zu(y));g&&typeof g=="object"&&(typeof g.atime=="string"&&(g.atime=new Date(g.atime)),typeof g.mtime=="string"&&(g.mtime=new Date(g.mtime)),Object.assign(m,g))}return m},setMeta(c,l,h={}){return this.setItem(c+"$",l,h)},removeMeta(c,l={}){return this.removeItem(c+"$",l)},async getKeys(c,l={}){c=el(c);const h=i(c,!0);let f=[];const m=[];let g=!0;for(const C of h){C.driver.flags?.maxDepth||(g=!1);const S=await lr(C.driver.getKeys,C.relativeBase,l);for(const A of S){const D=C.mountpoint+Kr(A);f.some(O=>D.startsWith(O))||m.push(D)}f=[C.mountpoint,...f.filter(A=>!A.startsWith(C.mountpoint))]}const y=l.maxDepth!==void 0&&!g;return m.filter(C=>(!y||Z4(C,l.maxDepth))&&e5(C,c))},async clear(c,l={}){c=el(c),await Promise.all(i(c,!1).map(async h=>{if(h.driver.clear)return lr(h.driver.clear,h.relativeBase,l);if(h.driver.removeItem){const f=await h.driver.getKeys(h.relativeBase||"",l);return Promise.all(f.map(m=>h.driver.removeItem(m,l)))}}))},async dispose(){await Promise.all(Object.values(e.mounts).map(c=>E0(c)))},async watch(c){return await n(),e.watchListeners.push(c),async()=>{e.watchListeners=e.watchListeners.filter(l=>l!==c),e.watchListeners.length===0&&await o()}},async unwatch(){e.watchListeners=[],await o()},mount(c,l){if(c=el(c),c&&e.mounts[c])throw new Error(`already mounted at ${c}`);return c&&(e.mountpoints.push(c),e.mountpoints.sort((h,f)=>f.length-h.length)),e.mounts[c]=l,e.watching&&Promise.resolve(_0(l,s,c)).then(h=>{e.unwatch[c]=h}).catch(console.error),u},async unmount(c,l=!0){c=el(c),!(!c||!e.mounts[c])&&(e.watching&&c in e.unwatch&&(e.unwatch[c]?.(),delete e.unwatch[c]),l&&await E0(e.mounts[c]),e.mountpoints=e.mountpoints.filter(h=>h!==c),delete e.mounts[c])},getMount(c=""){c=Kr(c)+":";const l=r(c);return{driver:l.driver,base:l.base}},getMounts(c="",l={}){return c=Kr(c),i(c,l.parents).map(f=>({driver:f.driver,base:f.mountpoint}))},keys:(c,l={})=>u.getKeys(c,l),get:(c,l={})=>u.getItem(c,l),set:(c,l,h={})=>u.setItem(c,l,h),has:(c,l={})=>u.hasItem(c,l),del:(c,l={})=>u.removeItem(c,l),remove:(c,l={})=>u.removeItem(c,l)};return u}function _0(t,e,r){return t.watch?t.watch((i,s)=>e(i,r+s)):()=>{}}async function E0(t){typeof t.dispose=="function"&&await lr(t.dispose)}function Wn(t){return new Promise((e,r)=>{t.oncomplete=t.onsuccess=()=>e(t.result),t.onabort=t.onerror=()=>r(t.error)})}function t1(t,e){let r;const i=()=>{if(r)return r;const s=indexedDB.open(t);return s.onupgradeneeded=()=>s.result.createObjectStore(e),r=Wn(s),r.then(n=>{n.onclose=()=>r=void 0},()=>{}),r};return(s,n)=>i().then(o=>n(o.transaction(e,s).objectStore(e)))}let rd;function vu(){return rd||(rd=t1("keyval-store","keyval")),rd}function I0(t,e=vu()){return e("readonly",r=>Wn(r.get(t)))}function s5(t,e,r=vu()){return r("readwrite",i=>(i.put(e,t),Wn(i.transaction)))}function n5(t,e=vu()){return e("readwrite",r=>(r.delete(t),Wn(r.transaction)))}function o5(t=vu()){return t("readwrite",e=>(e.clear(),Wn(e.transaction)))}function a5(t,e){return t.openCursor().onsuccess=function(){this.result&&(e(this.result),this.result.continue())},Wn(t.transaction)}function c5(t=vu()){return t("readonly",e=>{if(e.getAllKeys)return Wn(e.getAllKeys());const r=[];return a5(e,i=>r.push(i.key)).then(()=>r)})}const u5=t=>JSON.stringify(t,(e,r)=>typeof r=="bigint"?r.toString()+"n":r),l5=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,s)=>typeof s=="string"&&s.match(/^\d+n$/)?BigInt(s.substring(0,s.length-1)):s)};function Os(t){if(typeof t!="string")throw new Error(`Cannot safe json parse value of type ${typeof t}`);try{return l5(t)}catch{return t}}function us(t){return typeof t=="string"?t:u5(t)||""}const h5="idb-keyval";var d5=(t={})=>{const e=t.base&&t.base.length>0?`${t.base}:`:"",r=s=>e+s;let i;return t.dbName&&t.storeName&&(i=t1(t.dbName,t.storeName)),{name:h5,options:t,async hasItem(s){return!(typeof await I0(r(s),i)>"u")},async getItem(s){return await I0(r(s),i)??null},setItem(s,n){return s5(r(s),n,i)},removeItem(s){return n5(r(s),i)},getKeys(){return c5(i)},clear(){return o5(i)}}};const f5="WALLET_CONNECT_V2_INDEXED_DB",p5="keyvaluestorage";let g5=class{constructor(){this.indexedDb=i5({driver:d5({dbName:f5,storeName:p5})})}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,us(r))}async removeItem(e){await this.indexedDb.removeItem(e)}};var id=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Rl={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 id<"u"&&id.localStorage?Rl.exports=id.localStorage:typeof window<"u"&&window.localStorage?Rl.exports=window.localStorage:Rl.exports=new e})();function b5(t){var e;return[t[0],Os((e=t[1])!=null?e:"")]}let m5=class{constructor(){this.localStorage=Rl.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(b5)}async getItem(e){const r=this.localStorage.getItem(e);if(r!==null)return Os(r)}async setItem(e,r){this.localStorage.setItem(e,us(r))}async removeItem(e){this.localStorage.removeItem(e)}};const y5="wc_storage_version",A0=1,w5=async(t,e,r)=>{const i=y5,s=await e.getItem(i);if(s&&s>=A0){r(e);return}const n=await t.getKeys();if(!n.length){r(e);return}const o=[];for(;n.length;){const a=n.shift();if(!a)continue;const u=a.toLowerCase();if(u.includes("wc@")||u.includes("walletconnect")||u.includes("wc_")||u.includes("wallet_connect")){const c=await t.getItem(a);await e.setItem(a,c),o.push(a)}}await e.setItem(i,A0),r(e),v5(t,o)},v5=async(t,e)=>{e.length&&e.forEach(async r=>{await t.removeItem(r)})};let r1=class{constructor(){this.initialized=!1,this.setInitialized=r=>{this.storage=r,this.initialized=!0};const e=new m5;this.storage=e;try{const r=new g5;w5(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 sd,S0;function _5(){if(S0)return sd;S0=1;function t(r){try{return JSON.stringify(r)}catch{return'"[Circular]"'}}sd=e;function e(r,i,s){var n=s&&s.stringify||t,o=1;if(typeof r=="object"&&r!==null){var a=i.length+o;if(a===1)return r;var u=new Array(a);u[0]=n(r);for(var c=1;c<a;c++)u[c]=n(i[c]);return u.join(" ")}if(typeof r!="string")return r;var l=i.length;if(l===0)return r;for(var h="",f=1-o,m=-1,g=r&&r.length||0,y=0;y<g;){if(r.charCodeAt(y)===37&&y+1<g){switch(m=m>-1?m:0,r.charCodeAt(y+1)){case 100:case 102:if(f>=l||i[f]==null)break;m<y&&(h+=r.slice(m,y)),h+=Number(i[f]),m=y+2,y++;break;case 105:if(f>=l||i[f]==null)break;m<y&&(h+=r.slice(m,y)),h+=Math.floor(Number(i[f])),m=y+2,y++;break;case 79:case 111:case 106:if(f>=l||i[f]===void 0)break;m<y&&(h+=r.slice(m,y));var C=typeof i[f];if(C==="string"){h+="'"+i[f]+"'",m=y+2,y++;break}if(C==="function"){h+=i[f].name||"<anonymous>",m=y+2,y++;break}h+=n(i[f]),m=y+2,y++;break;case 115:if(f>=l)break;m<y&&(h+=r.slice(m,y)),h+=String(i[f]),m=y+2,y++;break;case 37:m<y&&(h+=r.slice(m,y)),h+="%",m=y+2,y++,f--;break}++f}++y}return m===-1?r:(m<g&&(h+=r.slice(m)),h)}return sd}var nd,C0;function E5(){if(C0)return nd;C0=1;const t=_5();nd=s;const e=T().console||{},r={mapHttpRequest:g,mapHttpResponse:g,wrapRequestSerializer:y,wrapResponseSerializer:y,wrapErrorSerializer:y,req:g,res:g,err:f};function i(x,M){return Array.isArray(x)?x.filter(function(R){return R!=="!stdSerializers.err"}):x===!0?Object.keys(M):!1}function s(x){x=x||{},x.browser=x.browser||{};const M=x.browser.transmit;if(M&&typeof M.send!="function")throw Error("pino: transmit option must have a send function");const U=x.browser.write||e;x.browser.write&&(x.browser.asObject=!0);const R=x.serializers||{},L=i(x.browser.serialize,R);let $=x.browser.serialize;Array.isArray(x.browser.serialize)&&x.browser.serialize.indexOf("!stdSerializers.err")>-1&&($=!1);const d=["error","fatal","warn","info","debug","trace"];typeof U=="function"&&(U.error=U.fatal=U.warn=U.info=U.debug=U.trace=U),x.enabled===!1&&(x.level="silent");const b=x.level||"info",_=Object.create(U);_.log||(_.log=C),Object.defineProperty(_,"levelVal",{get:v}),Object.defineProperty(_,"level",{get:I,set:P});const w={transmit:M,serialize:L,asObject:x.browser.asObject,levels:d,timestamp:m(x)};_.levels=s.levels,_.level=b,_.setMaxListeners=_.getMaxListeners=_.emit=_.addListener=_.on=_.prependListener=_.once=_.prependOnceListener=_.removeListener=_.removeAllListeners=_.listeners=_.listenerCount=_.eventNames=_.write=_.flush=C,_.serializers=R,_._serialize=L,_._stdErrSerialize=$,_.child=E,M&&(_._logEvent=h());function v(){return this.level==="silent"?1/0:this.levels.values[this.level]}function I(){return this._level}function P(p){if(p!=="silent"&&!this.levels.values[p])throw Error("unknown level "+p);this._level=p,n(w,_,"error","log"),n(w,_,"fatal","error"),n(w,_,"warn","error"),n(w,_,"info","log"),n(w,_,"debug","log"),n(w,_,"trace","log")}function E(p,N){if(!p)throw new Error("missing bindings for child Pino");N=N||{},L&&p.serializers&&(N.serializers=p.serializers);const q=N.serializers;if(L&&q){var H=Object.assign({},R,q),z=x.browser.serialize===!0?Object.keys(H):L;delete p.serializers,u([p],z,H,this._stdErrSerialize)}function V(Y){this._childLevel=(Y._childLevel|0)+1,this.error=c(Y,p,"error"),this.fatal=c(Y,p,"fatal"),this.warn=c(Y,p,"warn"),this.info=c(Y,p,"info"),this.debug=c(Y,p,"debug"),this.trace=c(Y,p,"trace"),H&&(this.serializers=H,this._serialize=z),M&&(this._logEvent=h([].concat(Y._logEvent.bindings,p)))}return V.prototype=this,new V(this)}return _}s.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"}},s.stdSerializers=r,s.stdTimeFunctions=Object.assign({},{nullTime:S,epochTime:A,unixTime:D,isoTime:O});function n(x,M,U,R){const L=Object.getPrototypeOf(M);M[U]=M.levelVal>M.levels.values[U]?C:L[U]?L[U]:e[U]||e[R]||C,o(x,M,U)}function o(x,M,U){!x.transmit&&M[U]===C||(M[U]=(function(R){return function(){const $=x.timestamp(),d=new Array(arguments.length),b=Object.getPrototypeOf&&Object.getPrototypeOf(this)===e?e:this;for(var _=0;_<d.length;_++)d[_]=arguments[_];if(x.serialize&&!x.asObject&&u(d,this._serialize,this.serializers,this._stdErrSerialize),x.asObject?R.call(b,a(this,U,d,$)):R.apply(b,d),x.transmit){const w=x.transmit.level||M.level,v=s.levels.values[w],I=s.levels.values[U];if(I<v)return;l(this,{ts:$,methodLevel:U,methodValue:I,transmitValue:s.levels.values[x.transmit.level||M.level],send:x.transmit.send,val:M.levelVal},d)}}})(M[U]))}function a(x,M,U,R){x._serialize&&u(U,x._serialize,x.serializers,x._stdErrSerialize);const L=U.slice();let $=L[0];const d={};R&&(d.time=R),d.level=s.levels.values[M];let b=(x._childLevel|0)+1;if(b<1&&(b=1),$!==null&&typeof $=="object"){for(;b--&&typeof L[0]=="object";)Object.assign(d,L.shift());$=L.length?t(L.shift(),L):void 0}else typeof $=="string"&&($=t(L.shift(),L));return $!==void 0&&(d.msg=$),d}function u(x,M,U,R){for(const L in x)if(R&&x[L]instanceof Error)x[L]=s.stdSerializers.err(x[L]);else if(typeof x[L]=="object"&&!Array.isArray(x[L]))for(const $ in x[L])M&&M.indexOf($)>-1&&$ in U&&(x[L][$]=U[$](x[L][$]))}function c(x,M,U){return function(){const R=new Array(1+arguments.length);R[0]=M;for(var L=1;L<R.length;L++)R[L]=arguments[L-1];return x[U].apply(this,R)}}function l(x,M,U){const R=M.send,L=M.ts,$=M.methodLevel,d=M.methodValue,b=M.val,_=x._logEvent.bindings;u(U,x._serialize||Object.keys(x.serializers),x.serializers,x._stdErrSerialize===void 0?!0:x._stdErrSerialize),x._logEvent.ts=L,x._logEvent.messages=U.filter(function(w){return _.indexOf(w)===-1}),x._logEvent.level.label=$,x._logEvent.level.value=d,R($,x._logEvent,b),x._logEvent=h(_)}function h(x){return{ts:0,messages:[],bindings:x||[],level:{label:"",value:0}}}function f(x){const M={type:x.constructor.name,msg:x.message,stack:x.stack};for(const U in x)M[U]===void 0&&(M[U]=x[U]);return M}function m(x){return typeof x.timestamp=="function"?x.timestamp:x.timestamp===!1?S:A}function g(){return{}}function y(x){return x}function C(){}function S(){return!1}function A(){return Date.now()}function D(){return Math.round(Date.now()/1e3)}function O(){return new Date(Date.now()).toISOString()}function T(){function x(M){return typeof M<"u"&&M}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 x(self)||x(window)||x(this)||{}}}return nd}var Bo=E5();const cn=wh(Bo),I5={level:"info"},_u="custom_context",ig=1e3*1024;let A5=class{constructor(e){this.nodeValue=e,this.sizeInBytes=new TextEncoder().encode(this.nodeValue).length,this.next=null}get value(){return this.nodeValue}get size(){return this.sizeInBytes}},$0=class{constructor(e){this.head=null,this.tail=null,this.lengthInNodes=0,this.maxSizeInBytes=e,this.sizeInBytes=0}append(e){const r=new A5(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}}}}},i1=class{constructor(e,r=ig){this.level=e??"error",this.levelValue=Bo.levels.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=r,this.logs=new $0(this.MAX_LOG_SIZE_IN_BYTES)}forwardToConsole(e,r){r===Bo.levels.values.error?console.error(e):r===Bo.levels.values.warn?console.warn(e):r===Bo.levels.values.debug?console.debug(e):r===Bo.levels.values.trace?console.trace(e):console.log(e)}appendToLogs(e){this.logs.append(us({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 $0(this.MAX_LOG_SIZE_IN_BYTES)}getLogArray(){return Array.from(this.logs)}logsToBlob(e){const r=this.getLogArray();return r.push(us({extraMetadata:e})),new Blob(r,{type:"application/json"})}},S5=class{constructor(e,r=ig){this.baseChunkLogger=new i1(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)}},C5=class{constructor(e,r=ig){this.baseChunkLogger=new i1(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 $5=Object.defineProperty,x5=Object.defineProperties,P5=Object.getOwnPropertyDescriptors,x0=Object.getOwnPropertySymbols,N5=Object.prototype.hasOwnProperty,O5=Object.prototype.propertyIsEnumerable,P0=(t,e,r)=>e in t?$5(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Xl=(t,e)=>{for(var r in e||(e={}))N5.call(e,r)&&P0(t,r,e[r]);if(x0)for(var r of x0(e))O5.call(e,r)&&P0(t,r,e[r]);return t},Zl=(t,e)=>x5(t,P5(e));function Ts(t){return Zl(Xl({},t),{level:t?.level||I5.level})}function T5(t,e=_u){return t[e]||""}function D5(t,e,r=_u){return t[r]=e,t}function it(t,e=_u){let r="";return typeof t.bindings>"u"?r=T5(t,e):r=t.bindings().context||"",r}function R5(t,e,r=_u){const i=it(t,r);return i.trim()?`${i}/${e}`:e}function je(t,e,r=_u){const i=R5(t,e,r),s=t.child({context:i});return D5(s,i,r)}function M5(t){var e,r;const i=new S5((e=t.opts)==null?void 0:e.level,t.maxSizeInBytes);return{logger:cn(Zl(Xl({},t.opts),{level:"trace",browser:Zl(Xl({},(r=t.opts)==null?void 0:r.browser),{write:s=>i.write(s)})})),chunkLoggerController:i}}function k5(t){var e;const r=new C5((e=t.opts)==null?void 0:e.level,t.maxSizeInBytes);return{logger:cn(Zl(Xl({},t.opts),{level:"trace"}),r),chunkLoggerController:r}}function sg(t){return typeof t.loggerOverride<"u"&&typeof t.loggerOverride!="string"?{logger:t.loggerOverride,chunkLoggerController:null}:typeof window<"u"?M5(t):k5(t)}var U5=Object.defineProperty,L5=(t,e,r)=>e in t?U5(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,N0=(t,e,r)=>L5(t,typeof e!="symbol"?e+"":e,r);let F5=class extends pi{constructor(e){super(),this.opts=e,N0(this,"protocol","wc"),N0(this,"version",2)}};var j5=Object.defineProperty,q5=(t,e,r)=>e in t?j5(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,B5=(t,e,r)=>q5(t,e+"",r);let z5=class extends pi{constructor(e,r){super(),this.core=e,this.logger=r,B5(this,"records",new Map)}},H5=class{constructor(e,r){this.logger=e,this.core=r}},V5=class extends pi{constructor(e,r){super(),this.relayer=e,this.logger=r}},K5=class extends pi{constructor(e){super()}},W5=class{constructor(e,r,i,s){this.core=e,this.logger=r,this.name=i}},G5=class extends pi{constructor(e,r){super(),this.relayer=e,this.logger=r}},Y5=class extends pi{constructor(e,r){super(),this.core=e,this.logger=r}},J5=class{constructor(e,r,i){this.core=e,this.logger=r,this.store=i}},Q5=class{constructor(e,r){this.projectId=e,this.logger=r}},X5=class{constructor(e,r,i){this.core=e,this.logger=r,this.telemetryEnabled=i}};function Z5(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function s1(t,...e){if(!Z5(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 O0(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 e6(t,e){s1(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}const ao=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;const od=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);function t6(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function n1(t){return typeof t=="string"&&(t=t6(t)),s1(t),t}let r6=class{clone(){return this._cloneInto()}};function i6(t){const e=i=>t().update(n1(i)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function o1(t=32){if(ao&&typeof ao.getRandomValues=="function")return ao.getRandomValues(new Uint8Array(t));if(ao&&typeof ao.randomBytes=="function")return ao.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}function s6(t,e,r,i){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,i);const s=BigInt(32),n=BigInt(4294967295),o=Number(r>>s&n),a=Number(r&n),u=i?4:0,c=i?0:4;t.setUint32(e+u,o,i),t.setUint32(e+c,a,i)}let n6=class extends r6{constructor(e,r,i,s){super(),this.blockLen=e,this.outputLen=r,this.padOffset=i,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=od(this.buffer)}update(e){O0(this);const{view:r,buffer:i,blockLen:s}=this;e=n1(e);const n=e.length;for(let o=0;o<n;){const a=Math.min(s-this.pos,n-o);if(a===s){const u=od(e);for(;s<=n-o;o+=s)this.process(u,o);continue}i.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===s&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){O0(this),e6(e,this),this.finished=!0;const{buffer:r,view:i,blockLen:s,isLE:n}=this;let{pos:o}=this;r[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>s-o&&(this.process(i,0),o=0);for(let h=o;h<s;h++)r[h]=0;s6(i,s-8,BigInt(this.length*8),n),this.process(i,0);const a=od(e),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=u/4,l=this.get();if(c>l.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<c;h++)a.setUint32(4*h,l[h],n)}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:s,finished:n,destroyed:o,pos:a}=this;return e.length=s,e.pos=a,e.finished=n,e.destroyed=o,s%r&&e.buffer.set(i),e}};const tl=BigInt(2**32-1),Vf=BigInt(32);function a1(t,e=!1){return e?{h:Number(t&tl),l:Number(t>>Vf&tl)}:{h:Number(t>>Vf&tl)|0,l:Number(t&tl)|0}}function o6(t,e=!1){let r=new Uint32Array(t.length),i=new Uint32Array(t.length);for(let s=0;s<t.length;s++){const{h:n,l:o}=a1(t[s],e);[r[s],i[s]]=[n,o]}return[r,i]}const a6=(t,e)=>BigInt(t>>>0)<<Vf|BigInt(e>>>0),c6=(t,e,r)=>t>>>r,u6=(t,e,r)=>t<<32-r|e>>>r,l6=(t,e,r)=>t>>>r|e<<32-r,h6=(t,e,r)=>t<<32-r|e>>>r,d6=(t,e,r)=>t<<64-r|e>>>r-32,f6=(t,e,r)=>t>>>r-32|e<<64-r,p6=(t,e)=>e,g6=(t,e)=>t,b6=(t,e,r)=>t<<r|e>>>32-r,m6=(t,e,r)=>e<<r|t>>>32-r,y6=(t,e,r)=>e<<r-32|t>>>64-r,w6=(t,e,r)=>t<<r-32|e>>>64-r;function v6(t,e,r,i){const s=(e>>>0)+(i>>>0);return{h:t+r+(s/2**32|0)|0,l:s|0}}const _6=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),E6=(t,e,r,i)=>e+r+i+(t/2**32|0)|0,I6=(t,e,r,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(i>>>0),A6=(t,e,r,i,s)=>e+r+i+s+(t/2**32|0)|0,S6=(t,e,r,i,s)=>(t>>>0)+(e>>>0)+(r>>>0)+(i>>>0)+(s>>>0),C6=(t,e,r,i,s,n)=>e+r+i+s+n+(t/2**32|0)|0,de={fromBig:a1,split:o6,toBig:a6,shrSH:c6,shrSL:u6,rotrSH:l6,rotrSL:h6,rotrBH:d6,rotrBL:f6,rotr32H:p6,rotr32L:g6,rotlSH:b6,rotlSL:m6,rotlBH:y6,rotlBL:w6,add:v6,add3L:_6,add3H:E6,add4L:I6,add4H:A6,add5H:C6,add5L:S6},[$6,x6]=de.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))),Ls=new Uint32Array(80),Fs=new Uint32Array(80);let P6=class extends n6{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:s,Ch:n,Cl:o,Dh:a,Dl:u,Eh:c,El:l,Fh:h,Fl:f,Gh:m,Gl:g,Hh:y,Hl:C}=this;return[e,r,i,s,n,o,a,u,c,l,h,f,m,g,y,C]}set(e,r,i,s,n,o,a,u,c,l,h,f,m,g,y,C){this.Ah=e|0,this.Al=r|0,this.Bh=i|0,this.Bl=s|0,this.Ch=n|0,this.Cl=o|0,this.Dh=a|0,this.Dl=u|0,this.Eh=c|0,this.El=l|0,this.Fh=h|0,this.Fl=f|0,this.Gh=m|0,this.Gl=g|0,this.Hh=y|0,this.Hl=C|0}process(e,r){for(let D=0;D<16;D++,r+=4)Ls[D]=e.getUint32(r),Fs[D]=e.getUint32(r+=4);for(let D=16;D<80;D++){const O=Ls[D-15]|0,T=Fs[D-15]|0,x=de.rotrSH(O,T,1)^de.rotrSH(O,T,8)^de.shrSH(O,T,7),M=de.rotrSL(O,T,1)^de.rotrSL(O,T,8)^de.shrSL(O,T,7),U=Ls[D-2]|0,R=Fs[D-2]|0,L=de.rotrSH(U,R,19)^de.rotrBH(U,R,61)^de.shrSH(U,R,6),$=de.rotrSL(U,R,19)^de.rotrBL(U,R,61)^de.shrSL(U,R,6),d=de.add4L(M,$,Fs[D-7],Fs[D-16]),b=de.add4H(d,x,L,Ls[D-7],Ls[D-16]);Ls[D]=b|0,Fs[D]=d|0}let{Ah:i,Al:s,Bh:n,Bl:o,Ch:a,Cl:u,Dh:c,Dl:l,Eh:h,El:f,Fh:m,Fl:g,Gh:y,Gl:C,Hh:S,Hl:A}=this;for(let D=0;D<80;D++){const O=de.rotrSH(h,f,14)^de.rotrSH(h,f,18)^de.rotrBH(h,f,41),T=de.rotrSL(h,f,14)^de.rotrSL(h,f,18)^de.rotrBL(h,f,41),x=h&m^~h&y,M=f&g^~f&C,U=de.add5L(A,T,M,x6[D],Fs[D]),R=de.add5H(U,S,O,x,$6[D],Ls[D]),L=U|0,$=de.rotrSH(i,s,28)^de.rotrBH(i,s,34)^de.rotrBH(i,s,39),d=de.rotrSL(i,s,28)^de.rotrBL(i,s,34)^de.rotrBL(i,s,39),b=i&n^i&a^n&a,_=s&o^s&u^o&u;S=y|0,A=C|0,y=m|0,C=g|0,m=h|0,g=f|0,{h,l:f}=de.add(c|0,l|0,R|0,L|0),c=a|0,l=u|0,a=n|0,u=o|0,n=i|0,o=s|0;const w=de.add3L(L,d,_);i=de.add3H(w,R,$,b),s=w|0}({h:i,l:s}=de.add(this.Ah|0,this.Al|0,i|0,s|0)),{h:n,l:o}=de.add(this.Bh|0,this.Bl|0,n|0,o|0),{h:a,l:u}=de.add(this.Ch|0,this.Cl|0,a|0,u|0),{h:c,l}=de.add(this.Dh|0,this.Dl|0,c|0,l|0),{h,l:f}=de.add(this.Eh|0,this.El|0,h|0,f|0),{h:m,l:g}=de.add(this.Fh|0,this.Fl|0,m|0,g|0),{h:y,l:C}=de.add(this.Gh|0,this.Gl|0,y|0,C|0),{h:S,l:A}=de.add(this.Hh|0,this.Hl|0,S|0,A|0),this.set(i,s,n,o,a,u,c,l,h,f,m,g,y,C,S,A)}roundClean(){Ls.fill(0),Fs.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 N6=i6(()=>new P6);const ng=BigInt(0),c1=BigInt(1),O6=BigInt(2);function og(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function ag(t){if(!og(t))throw new Error("Uint8Array expected")}function ad(t,e){if(typeof e!="boolean")throw new Error(t+" boolean expected, got "+e)}const T6=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function cg(t){ag(t);let e="";for(let r=0;r<t.length;r++)e+=T6[t[r]];return e}function u1(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?ng:BigInt("0x"+t)}const gs={_0:48,_9:57,A:65,F:70,a:97,f:102};function T0(t){if(t>=gs._0&&t<=gs._9)return t-gs._0;if(t>=gs.A&&t<=gs.F)return t-(gs.A-10);if(t>=gs.a&&t<=gs.f)return t-(gs.a-10)}function l1(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 s=0,n=0;s<r;s++,n+=2){const o=T0(t.charCodeAt(n)),a=T0(t.charCodeAt(n+1));if(o===void 0||a===void 0){const u=t[n]+t[n+1];throw new Error('hex string expected, got non-hex character "'+u+'" at index '+n)}i[s]=o*16+a}return i}function D6(t){return u1(cg(t))}function Ml(t){return ag(t),u1(cg(Uint8Array.from(t).reverse()))}function h1(t,e){return l1(t.toString(16).padStart(e*2,"0"))}function Kf(t,e){return h1(t,e).reverse()}function bs(t,e,r){let i;if(typeof e=="string")try{i=l1(e)}catch(n){throw new Error(t+" must be hex string or Uint8Array, cause: "+n)}else if(og(e))i=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");const s=i.length;if(typeof r=="number"&&s!==r)throw new Error(t+" of length "+r+" expected, got "+s);return i}function D0(...t){let e=0;for(let i=0;i<t.length;i++){const s=t[i];ag(s),e+=s.length}const r=new Uint8Array(e);for(let i=0,s=0;i<t.length;i++){const n=t[i];r.set(n,s),s+=n.length}return r}const cd=t=>typeof t=="bigint"&&ng<=t;function R6(t,e,r){return cd(t)&&cd(e)&&cd(r)&&e<=t&&t<r}function Ja(t,e,r,i){if(!R6(e,r,i))throw new Error("expected valid "+t+": "+r+" <= n < "+i+", got "+e)}function M6(t){let e;for(e=0;t>ng;t>>=c1,e+=1);return e}const k6=t=>(O6<<BigInt(t-1))-c1,U6={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"||og(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 ug(t,e,r={}){const i=(s,n,o)=>{const a=U6[n];if(typeof a!="function")throw new Error("invalid validator function");const u=t[s];if(!(o&&u===void 0)&&!a(u,t))throw new Error("param "+String(s)+" is invalid. Expected "+n+", got "+u)};for(const[s,n]of Object.entries(e))i(s,n,!1);for(const[s,n]of Object.entries(r))i(s,n,!0);return t}function R0(t){const e=new WeakMap;return(r,...i)=>{const s=e.get(r);if(s!==void 0)return s;const n=t(r,...i);return e.set(r,n),n}}const gr=BigInt(0),Wt=BigInt(1),$n=BigInt(2),L6=BigInt(3),Wf=BigInt(4),M0=BigInt(5),k0=BigInt(8);function rr(t,e){const r=t%e;return r>=gr?r:e+r}function F6(t,e,r){if(e<gr)throw new Error("invalid exponent, negatives unsupported");if(r<=gr)throw new Error("invalid modulus");if(r===Wt)return gr;let i=Wt;for(;e>gr;)e&Wt&&(i=i*t%r),t=t*t%r,e>>=Wt;return i}function Yi(t,e,r){let i=t;for(;e-- >gr;)i*=i,i%=r;return i}function U0(t,e){if(t===gr)throw new Error("invert: expected non-zero number");if(e<=gr)throw new Error("invert: expected positive modulus, got "+e);let r=rr(t,e),i=e,s=gr,n=Wt;for(;r!==gr;){const o=i/r,a=i%r,u=s-n*o;i=r,r=a,s=n,n=u}if(i!==Wt)throw new Error("invert: does not exist");return rr(s,e)}function j6(t){const e=(t-Wt)/$n;let r,i,s;for(r=t-Wt,i=0;r%$n===gr;r/=$n,i++);for(s=$n;s<t&&F6(s,e,t)!==t-Wt;s++)if(s>1e3)throw new Error("Cannot find square root: likely non-prime P");if(i===1){const o=(t+Wt)/Wf;return function(a,u){const c=a.pow(u,o);if(!a.eql(a.sqr(c),u))throw new Error("Cannot find square root");return c}}const n=(r+Wt)/$n;return function(o,a){if(o.pow(a,e)===o.neg(o.ONE))throw new Error("Cannot find square root");let u=i,c=o.pow(o.mul(o.ONE,s),r),l=o.pow(a,n),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 g=o.sqr(h);f<u&&!o.eql(g,o.ONE);f++)g=o.sqr(g);const m=o.pow(c,Wt<<BigInt(u-f-1));c=o.sqr(m),l=o.mul(l,m),h=o.mul(h,c),u=f}return l}}function q6(t){if(t%Wf===L6){const e=(t+Wt)/Wf;return function(r,i){const s=r.pow(i,e);if(!r.eql(r.sqr(s),i))throw new Error("Cannot find square root");return s}}if(t%k0===M0){const e=(t-M0)/k0;return function(r,i){const s=r.mul(i,$n),n=r.pow(s,e),o=r.mul(i,n),a=r.mul(r.mul(o,$n),n),u=r.mul(o,r.sub(a,r.ONE));if(!r.eql(r.sqr(u),i))throw new Error("Cannot find square root");return u}}return j6(t)}const B6=(t,e)=>(rr(t,e)&Wt)===Wt,z6=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function H6(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=z6.reduce((i,s)=>(i[s]="function",i),e);return ug(t,r)}function V6(t,e,r){if(r<gr)throw new Error("invalid exponent, negatives unsupported");if(r===gr)return t.ONE;if(r===Wt)return e;let i=t.ONE,s=e;for(;r>gr;)r&Wt&&(i=t.mul(i,s)),s=t.sqr(s),r>>=Wt;return i}function K6(t,e){const r=new Array(e.length),i=e.reduce((n,o,a)=>t.is0(o)?n:(r[a]=n,t.mul(n,o)),t.ONE),s=t.inv(i);return e.reduceRight((n,o,a)=>t.is0(o)?n:(r[a]=t.mul(n,r[a]),t.mul(n,o)),s),r}function d1(t,e){const r=e!==void 0?e:t.toString(2).length,i=Math.ceil(r/8);return{nBitLength:r,nByteLength:i}}function f1(t,e,r=!1,i={}){if(t<=gr)throw new Error("invalid field: expected ORDER > 0, got "+t);const{nBitLength:s,nByteLength:n}=d1(t,e);if(n>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let o;const a=Object.freeze({ORDER:t,isLE:r,BITS:s,BYTES:n,MASK:k6(s),ZERO:gr,ONE:Wt,create:u=>rr(u,t),isValid:u=>{if(typeof u!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof u);return gr<=u&&u<t},is0:u=>u===gr,isOdd:u=>(u&Wt)===Wt,neg:u=>rr(-u,t),eql:(u,c)=>u===c,sqr:u=>rr(u*u,t),add:(u,c)=>rr(u+c,t),sub:(u,c)=>rr(u-c,t),mul:(u,c)=>rr(u*c,t),pow:(u,c)=>V6(a,u,c),div:(u,c)=>rr(u*U0(c,t),t),sqrN:u=>u*u,addN:(u,c)=>u+c,subN:(u,c)=>u-c,mulN:(u,c)=>u*c,inv:u=>U0(u,t),sqrt:i.sqrt||(u=>(o||(o=q6(t)),o(a,u))),invertBatch:u=>K6(a,u),cmov:(u,c,l)=>l?c:u,toBytes:u=>r?Kf(u,n):h1(u,n),fromBytes:u=>{if(u.length!==n)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+u.length);return r?Ml(u):D6(u)}});return Object.freeze(a)}const L0=BigInt(0),rl=BigInt(1);function ud(t,e){const r=e.negate();return t?r:e}function p1(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function ld(t,e){p1(t,e);const r=Math.ceil(e/t)+1,i=2**(t-1);return{windows:r,windowSize:i}}function W6(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 G6(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 hd=new WeakMap,g1=new WeakMap;function dd(t){return g1.get(t)||1}function Y6(t,e){return{constTimeNegate:ud,hasPrecomputes(r){return dd(r)!==1},unsafeLadder(r,i,s=t.ZERO){let n=r;for(;i>L0;)i&rl&&(s=s.add(n)),n=n.double(),i>>=rl;return s},precomputeWindow(r,i){const{windows:s,windowSize:n}=ld(i,e),o=[];let a=r,u=a;for(let c=0;c<s;c++){u=a,o.push(u);for(let l=1;l<n;l++)u=u.add(a),o.push(u);a=u.double()}return o},wNAF(r,i,s){const{windows:n,windowSize:o}=ld(r,e);let a=t.ZERO,u=t.BASE;const c=BigInt(2**r-1),l=2**r,h=BigInt(r);for(let f=0;f<n;f++){const m=f*o;let g=Number(s&c);s>>=h,g>o&&(g-=l,s+=rl);const y=m,C=m+Math.abs(g)-1,S=f%2!==0,A=g<0;g===0?u=u.add(ud(S,i[y])):a=a.add(ud(A,i[C]))}return{p:a,f:u}},wNAFUnsafe(r,i,s,n=t.ZERO){const{windows:o,windowSize:a}=ld(r,e),u=BigInt(2**r-1),c=2**r,l=BigInt(r);for(let h=0;h<o;h++){const f=h*a;if(s===L0)break;let m=Number(s&u);if(s>>=l,m>a&&(m-=c,s+=rl),m===0)continue;let g=i[f+Math.abs(m)-1];m<0&&(g=g.negate()),n=n.add(g)}return n},getPrecomputes(r,i,s){let n=hd.get(i);return n||(n=this.precomputeWindow(i,r),r!==1&&hd.set(i,s(n))),n},wNAFCached(r,i,s){const n=dd(r);return this.wNAF(n,this.getPrecomputes(n,r,s),i)},wNAFCachedUnsafe(r,i,s,n){const o=dd(r);return o===1?this.unsafeLadder(r,i,n):this.wNAFUnsafe(o,this.getPrecomputes(o,r,s),i,n)},setWindowSize(r,i){p1(i,e),g1.set(r,i),hd.delete(r)}}}function J6(t,e,r,i){if(W6(r,t),G6(i,e),r.length!==i.length)throw new Error("arrays of points and scalars must have equal length");const s=t.ZERO,n=M6(BigInt(r.length)),o=n>12?n-3:n>4?n-2:n?2:1,a=(1<<o)-1,u=new Array(a+1).fill(s),c=Math.floor((e.BITS-1)/o)*o;let l=s;for(let h=c;h>=0;h-=o){u.fill(s);for(let m=0;m<i.length;m++){const g=i[m],y=Number(g>>BigInt(h)&BigInt(a));u[y]=u[y].add(r[m])}let f=s;for(let m=u.length-1,g=s;m>0;m--)g=g.add(u[m]),f=f.add(g);if(l=l.add(f),h!==0)for(let m=0;m<o;m++)l=l.double()}return l}function Q6(t){return H6(t.Fp),ug(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...d1(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}const Di=BigInt(0),jr=BigInt(1),il=BigInt(2),X6=BigInt(8),Z6={zip215:!0};function eI(t){const e=Q6(t);return ug(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function tI(t){const e=eI(t),{Fp:r,n:i,prehash:s,hash:n,randomBytes:o,nByteLength:a,h:u}=e,c=il<<BigInt(a*8)-jr,l=r.create,h=f1(e.n,e.nBitLength),f=e.uvRatio||((w,v)=>{try{return{isValid:!0,value:r.sqrt(w*r.inv(v))}}catch{return{isValid:!1,value:Di}}}),m=e.adjustScalarBytes||(w=>w),g=e.domain||((w,v,I)=>{if(ad("phflag",I),v.length||I)throw new Error("Contexts/pre-hash are not supported");return w});function y(w,v){Ja("coordinate "+w,v,Di,c)}function C(w){if(!(w instanceof D))throw new Error("ExtendedPoint expected")}const S=R0((w,v)=>{const{ex:I,ey:P,ez:E}=w,p=w.is0();v==null&&(v=p?X6:r.inv(E));const N=l(I*v),q=l(P*v),H=l(E*v);if(p)return{x:Di,y:jr};if(H!==jr)throw new Error("invZ was invalid");return{x:N,y:q}}),A=R0(w=>{const{a:v,d:I}=e;if(w.is0())throw new Error("bad point: ZERO");const{ex:P,ey:E,ez:p,et:N}=w,q=l(P*P),H=l(E*E),z=l(p*p),V=l(z*z),Y=l(q*v),te=l(z*l(Y+H)),ie=l(V+l(I*l(q*H)));if(te!==ie)throw new Error("bad point: equation left != right (1)");const Z=l(P*E),ae=l(p*N);if(Z!==ae)throw new Error("bad point: equation left != right (2)");return!0});class D{constructor(v,I,P,E){this.ex=v,this.ey=I,this.ez=P,this.et=E,y("x",v),y("y",I),y("z",P),y("t",E),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(v){if(v instanceof D)throw new Error("extended point not allowed");const{x:I,y:P}=v||{};return y("x",I),y("y",P),new D(I,P,jr,l(I*P))}static normalizeZ(v){const I=r.invertBatch(v.map(P=>P.ez));return v.map((P,E)=>P.toAffine(I[E])).map(D.fromAffine)}static msm(v,I){return J6(D,h,v,I)}_setWindowSize(v){x.setWindowSize(this,v)}assertValidity(){A(this)}equals(v){C(v);const{ex:I,ey:P,ez:E}=this,{ex:p,ey:N,ez:q}=v,H=l(I*q),z=l(p*E),V=l(P*q),Y=l(N*E);return H===z&&V===Y}is0(){return this.equals(D.ZERO)}negate(){return new D(l(-this.ex),this.ey,this.ez,l(-this.et))}double(){const{a:v}=e,{ex:I,ey:P,ez:E}=this,p=l(I*I),N=l(P*P),q=l(il*l(E*E)),H=l(v*p),z=I+P,V=l(l(z*z)-p-N),Y=H+N,te=Y-q,ie=H-N,Z=l(V*te),ae=l(Y*ie),ht=l(V*ie),ge=l(te*Y);return new D(Z,ae,ge,ht)}add(v){C(v);const{a:I,d:P}=e,{ex:E,ey:p,ez:N,et:q}=this,{ex:H,ey:z,ez:V,et:Y}=v;if(I===BigInt(-1)){const Ke=l((p-E)*(z+H)),Vi=l((p+E)*(z-H)),qe=l(Vi-Ke);if(qe===Di)return this.double();const We=l(N*il*Y),Ki=l(q*il*V),De=Ki+We,Re=Vi+Ke,Wi=Ki-We,Me=l(De*qe),st=l(Re*Wi),dn=l(De*Wi),Se=l(qe*Re);return new D(Me,st,Se,dn)}const te=l(E*H),ie=l(p*z),Z=l(q*P*Y),ae=l(N*V),ht=l((E+p)*(H+z)-te-ie),ge=ae-Z,ye=ae+Z,Dt=l(ie-I*te),Ie=l(ht*ge),Te=l(ye*Dt),bi=l(ht*Dt),Ze=l(ge*ye);return new D(Ie,Te,Ze,bi)}subtract(v){return this.add(v.negate())}wNAF(v){return x.wNAFCached(this,v,D.normalizeZ)}multiply(v){const I=v;Ja("scalar",I,jr,i);const{p:P,f:E}=this.wNAF(I);return D.normalizeZ([P,E])[0]}multiplyUnsafe(v,I=D.ZERO){const P=v;return Ja("scalar",P,Di,i),P===Di?T:this.is0()||P===jr?this:x.wNAFCachedUnsafe(this,P,D.normalizeZ,I)}isSmallOrder(){return this.multiplyUnsafe(u).is0()}isTorsionFree(){return x.unsafeLadder(this,i).is0()}toAffine(v){return S(this,v)}clearCofactor(){const{h:v}=e;return v===jr?this:this.multiplyUnsafe(v)}static fromHex(v,I=!1){const{d:P,a:E}=e,p=r.BYTES;v=bs("pointHex",v,p),ad("zip215",I);const N=v.slice(),q=v[p-1];N[p-1]=q&-129;const H=Ml(N),z=I?c:r.ORDER;Ja("pointHex.y",H,Di,z);const V=l(H*H),Y=l(V-jr),te=l(P*V-E);let{isValid:ie,value:Z}=f(Y,te);if(!ie)throw new Error("Point.fromHex: invalid y coordinate");const ae=(Z&jr)===jr,ht=(q&128)!==0;if(!I&&Z===Di&&ht)throw new Error("Point.fromHex: x=0 and x_0=1");return ht!==ae&&(Z=l(-Z)),D.fromAffine({x:Z,y:H})}static fromPrivateKey(v){return R(v).point}toRawBytes(){const{x:v,y:I}=this.toAffine(),P=Kf(I,r.BYTES);return P[P.length-1]|=v&jr?128:0,P}toHex(){return cg(this.toRawBytes())}}D.BASE=new D(e.Gx,e.Gy,jr,l(e.Gx*e.Gy)),D.ZERO=new D(Di,jr,jr,Di);const{BASE:O,ZERO:T}=D,x=Y6(D,a*8);function M(w){return rr(w,i)}function U(w){return M(Ml(w))}function R(w){const v=r.BYTES;w=bs("private key",w,v);const I=bs("hashed private key",n(w),2*v),P=m(I.slice(0,v)),E=I.slice(v,2*v),p=U(P),N=O.multiply(p),q=N.toRawBytes();return{head:P,prefix:E,scalar:p,point:N,pointBytes:q}}function L(w){return R(w).pointBytes}function $(w=new Uint8Array,...v){const I=D0(...v);return U(n(g(I,bs("context",w),!!s)))}function d(w,v,I={}){w=bs("message",w),s&&(w=s(w));const{prefix:P,scalar:E,pointBytes:p}=R(v),N=$(I.context,P,w),q=O.multiply(N).toRawBytes(),H=$(I.context,q,p,w),z=M(N+H*E);Ja("signature.s",z,Di,i);const V=D0(q,Kf(z,r.BYTES));return bs("result",V,r.BYTES*2)}const b=Z6;function _(w,v,I,P=b){const{context:E,zip215:p}=P,N=r.BYTES;w=bs("signature",w,2*N),v=bs("message",v),I=bs("publicKey",I,N),p!==void 0&&ad("zip215",p),s&&(v=s(v));const q=Ml(w.slice(N,2*N));let H,z,V;try{H=D.fromHex(I,p),z=D.fromHex(w.slice(0,N),p),V=O.multiplyUnsafe(q)}catch{return!1}if(!p&&H.isSmallOrder())return!1;const Y=$(E,z.toRawBytes(),H.toRawBytes(),v);return z.add(H.multiplyUnsafe(Y)).subtract(V).clearCofactor().equals(D.ZERO)}return O._setWindowSize(8),{CURVE:e,getPublicKey:L,sign:d,verify:_,ExtendedPoint:D,utils:{getExtendedPublicKey:R,randomPrivateKey:()=>o(r.BYTES),precompute(w=8,v=D.BASE){return v._setWindowSize(w),v.multiply(BigInt(3)),v}}}}BigInt(0),BigInt(1);const lg=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),F0=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const rI=BigInt(1),j0=BigInt(2);BigInt(3);const iI=BigInt(5),sI=BigInt(8);function nI(t){const e=BigInt(10),r=BigInt(20),i=BigInt(40),s=BigInt(80),n=lg,o=t*t%n*t%n,a=Yi(o,j0,n)*o%n,u=Yi(a,rI,n)*t%n,c=Yi(u,iI,n)*u%n,l=Yi(c,e,n)*c%n,h=Yi(l,r,n)*l%n,f=Yi(h,i,n)*h%n,m=Yi(f,s,n)*f%n,g=Yi(m,s,n)*f%n,y=Yi(g,e,n)*c%n;return{pow_p_5_8:Yi(y,j0,n)*t%n,b2:o}}function oI(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function aI(t,e){const r=lg,i=rr(e*e*e,r),s=rr(i*i*e,r),n=nI(t*s).pow_p_5_8;let o=rr(t*i*n,r);const a=rr(e*o*o,r),u=o,c=rr(o*F0,r),l=a===t,h=a===rr(-t,r),f=a===rr(-t*F0,r);return l&&(o=u),(h||f)&&(o=c),B6(o,r)&&(o=rr(-o,r)),{isValid:l||h,value:o}}const cI=f1(lg,void 0,!0),uI={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:cI,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:sI,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:N6,randomBytes:o1,adjustScalarBytes:oI,uvRatio:aI},b1=tI(uI),lI="EdDSA",hI="JWT",eh=".",_h="base64url",m1="utf8",y1="utf8",dI=":",fI="did",pI="key",q0="base58btc",gI="z",bI="K36",mI=32;function hg(t){return globalThis.Buffer!=null?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t}function w1(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?hg(globalThis.Buffer.allocUnsafe(t)):new Uint8Array(t)}function v1(t,e){e||(e=t.reduce((s,n)=>s+n.length,0));const r=w1(e);let i=0;for(const s of t)r.set(s,i),i+=s.length;return hg(r)}function yI(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 s=0;s<t.length;s++){var n=t.charAt(s),o=n.charCodeAt(0);if(r[o]!==255)throw new TypeError(n+" is ambiguous");r[o]=s}var a=t.length,u=t.charAt(0),c=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function h(g){if(g instanceof Uint8Array||(ArrayBuffer.isView(g)?g=new Uint8Array(g.buffer,g.byteOffset,g.byteLength):Array.isArray(g)&&(g=Uint8Array.from(g))),!(g instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(g.length===0)return"";for(var y=0,C=0,S=0,A=g.length;S!==A&&g[S]===0;)S++,y++;for(var D=(A-S)*l+1>>>0,O=new Uint8Array(D);S!==A;){for(var T=g[S],x=0,M=D-1;(T!==0||x<C)&&M!==-1;M--,x++)T+=256*O[M]>>>0,O[M]=T%a>>>0,T=T/a>>>0;if(T!==0)throw new Error("Non-zero carry");C=x,S++}for(var U=D-C;U!==D&&O[U]===0;)U++;for(var R=u.repeat(y);U<D;++U)R+=t.charAt(O[U]);return R}function f(g){if(typeof g!="string")throw new TypeError("Expected String");if(g.length===0)return new Uint8Array;var y=0;if(g[y]!==" "){for(var C=0,S=0;g[y]===u;)C++,y++;for(var A=(g.length-y)*c+1>>>0,D=new Uint8Array(A);g[y];){var O=r[g.charCodeAt(y)];if(O===255)return;for(var T=0,x=A-1;(O!==0||T<S)&&x!==-1;x--,T++)O+=a*D[x]>>>0,D[x]=O%256>>>0,O=O/256>>>0;if(O!==0)throw new Error("Non-zero carry");S=T,y++}if(g[y]!==" "){for(var M=A-S;M!==A&&D[M]===0;)M++;for(var U=new Uint8Array(C+(A-M)),R=C;M!==A;)U[R++]=D[M++];return U}}}function m(g){var y=f(g);if(y)return y;throw new Error(`Non-${e} character`)}return{encode:h,decodeUnsafe:f,decode:m}}var wI=yI,vI=wI;const _1=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")},_I=t=>new TextEncoder().encode(t),EI=t=>new TextDecoder().decode(t);let II=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")}},AI=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 E1(this,e)}},SI=class{constructor(e){this.decoders=e}or(e){return E1(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 E1=(t,e)=>new SI({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});let CI=class{constructor(e,r,i,s){this.name=e,this.prefix=r,this.baseEncode=i,this.baseDecode=s,this.encoder=new II(e,r,i),this.decoder=new AI(e,r,s)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};const Eh=({name:t,prefix:e,encode:r,decode:i})=>new CI(t,e,r,i),Eu=({prefix:t,name:e,alphabet:r})=>{const{encode:i,decode:s}=vI(r,e);return Eh({prefix:t,name:e,encode:i,decode:n=>_1(s(n))})},$I=(t,e,r,i)=>{const s={};for(let l=0;l<e.length;++l)s[e[l]]=l;let n=t.length;for(;t[n-1]==="=";)--n;const o=new Uint8Array(n*r/8|0);let a=0,u=0,c=0;for(let l=0;l<n;++l){const h=s[t[l]];if(h===void 0)throw new SyntaxError(`Non-${i} character`);u=u<<r|h,a+=r,a>=8&&(a-=8,o[c++]=255&u>>a)}if(a>=r||255&u<<8-a)throw new SyntaxError("Unexpected end of data");return o},xI=(t,e,r)=>{const i=e[e.length-1]==="=",s=(1<<r)-1;let n="",o=0,a=0;for(let u=0;u<t.length;++u)for(a=a<<8|t[u],o+=8;o>r;)o-=r,n+=e[s&a>>o];if(o&&(n+=e[s&a<<r-o]),i)for(;n.length*r&7;)n+="=";return n},Sr=({name:t,prefix:e,bitsPerChar:r,alphabet:i})=>Eh({prefix:e,name:t,encode(s){return xI(s,i,r)},decode(s){return $I(s,i,r,t)}}),PI=Eh({prefix:"\0",name:"identity",encode:t=>EI(t),decode:t=>_I(t)});var NI=Object.freeze({__proto__:null,identity:PI});const OI=Sr({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var TI=Object.freeze({__proto__:null,base2:OI});const DI=Sr({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var RI=Object.freeze({__proto__:null,base8:DI});const MI=Eu({prefix:"9",name:"base10",alphabet:"0123456789"});var kI=Object.freeze({__proto__:null,base10:MI});const UI=Sr({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),LI=Sr({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var FI=Object.freeze({__proto__:null,base16:UI,base16upper:LI});const jI=Sr({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),qI=Sr({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),BI=Sr({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),zI=Sr({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),HI=Sr({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),VI=Sr({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),KI=Sr({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),WI=Sr({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),GI=Sr({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var YI=Object.freeze({__proto__:null,base32:jI,base32upper:qI,base32pad:BI,base32padupper:zI,base32hex:HI,base32hexupper:VI,base32hexpad:KI,base32hexpadupper:WI,base32z:GI});const JI=Eu({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),QI=Eu({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var XI=Object.freeze({__proto__:null,base36:JI,base36upper:QI});const ZI=Eu({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),e8=Eu({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var t8=Object.freeze({__proto__:null,base58btc:ZI,base58flickr:e8});const r8=Sr({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),i8=Sr({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),s8=Sr({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),n8=Sr({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var o8=Object.freeze({__proto__:null,base64:r8,base64pad:i8,base64url:s8,base64urlpad:n8});const I1=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),a8=I1.reduce((t,e,r)=>(t[r]=e,t),[]),c8=I1.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function u8(t){return t.reduce((e,r)=>(e+=a8[r],e),"")}function l8(t){const e=[];for(const r of t){const i=c8[r.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(i)}return new Uint8Array(e)}const h8=Eh({prefix:"🚀",name:"base256emoji",encode:u8,decode:l8});var d8=Object.freeze({__proto__:null,base256emoji:h8}),f8=A1,B0=128,p8=-128,g8=Math.pow(2,31);function A1(t,e,r){e=e||[],r=r||0;for(var i=r;t>=g8;)e[r++]=t&255|B0,t/=128;for(;t&p8;)e[r++]=t&255|B0,t>>>=7;return e[r]=t|0,A1.bytes=r-i+1,e}var b8=Gf,m8=128,z0=127;function Gf(t,i){var r=0,i=i||0,s=0,n=i,o,a=t.length;do{if(n>=a)throw Gf.bytes=0,new RangeError("Could not decode varint");o=t[n++],r+=s<28?(o&z0)<<s:(o&z0)*Math.pow(2,s),s+=7}while(o>=m8);return Gf.bytes=n-i,r}var y8=Math.pow(2,7),w8=Math.pow(2,14),v8=Math.pow(2,21),_8=Math.pow(2,28),E8=Math.pow(2,35),I8=Math.pow(2,42),A8=Math.pow(2,49),S8=Math.pow(2,56),C8=Math.pow(2,63),$8=function(t){return t<y8?1:t<w8?2:t<v8?3:t<_8?4:t<E8?5:t<I8?6:t<A8?7:t<S8?8:t<C8?9:10},x8={encode:f8,decode:b8,encodingLength:$8},S1=x8;const H0=(t,e,r=0)=>(S1.encode(t,e,r),e),V0=t=>S1.encodingLength(t),Yf=(t,e)=>{const r=e.byteLength,i=V0(t),s=i+V0(r),n=new Uint8Array(s+r);return H0(t,n,0),H0(r,n,i),n.set(e,s),new P8(t,r,e,n)};let P8=class{constructor(e,r,i,s){this.code=e,this.size=r,this.digest=i,this.bytes=s}};const C1=({name:t,code:e,encode:r})=>new N8(t,e,r);let N8=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?Yf(this.code,r):r.then(i=>Yf(this.code,i))}else throw Error("Unknown type, must be binary type")}};const $1=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),O8=C1({name:"sha2-256",code:18,encode:$1("SHA-256")}),T8=C1({name:"sha2-512",code:19,encode:$1("SHA-512")});var D8=Object.freeze({__proto__:null,sha256:O8,sha512:T8});const x1=0,R8="identity",P1=_1,M8=t=>Yf(x1,P1(t)),k8={code:x1,name:R8,encode:P1,digest:M8};var U8=Object.freeze({__proto__:null,identity:k8});new TextEncoder,new TextDecoder;const K0={...NI,...TI,...RI,...kI,...FI,...YI,...XI,...t8,...o8,...d8};({...D8,...U8});function N1(t,e,r,i){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:i}}}const W0=N1("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),fd=N1("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=w1(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),O1={utf8:W0,"utf-8":W0,hex:K0.base16,latin1:fd,ascii:fd,binary:fd,...K0};function Ih(t,e="utf8"){const r=O1[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 va(t,e="utf8"){const r=O1[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?hg(globalThis.Buffer.from(t,"utf-8")):r.decoder.decode(`${r.prefix}${t}`)}function G0(t){return Os(Ih(va(t,_h),m1))}function th(t){return Ih(va(us(t),m1),_h)}function dg(t){const e=va(bI,q0),r=gI+Ih(v1([e,t]),q0);return[fI,pI,r].join(dI)}function L8(t){return Ih(t,_h)}function F8(t){return va(t,_h)}function j8(t){return va([th(t.header),th(t.payload)].join(eh),y1)}function q8(t){return[th(t.header),th(t.payload),L8(t.signature)].join(eh)}function oa(t){const e=t.split(eh),r=G0(e[0]),i=G0(e[1]),s=F8(e[2]),n=va(e.slice(0,2).join(eh),y1);return{header:r,payload:i,signature:s,data:n}}function rh(t=o1(mI)){const e=b1.getPublicKey(t);return{secretKey:v1([t,e]),publicKey:e}}async function T1(t,e,r,i,s=B.fromMiliseconds(Date.now())){const n={alg:lI,typ:hI},o=dg(i.publicKey),a=s+r,u={iss:o,sub:t,aud:e,iat:s,exp:a},c=j8({header:n,payload:u}),l=b1.sign(c,i.secretKey.slice(0,32));return q8({header:n,payload:u,signature:l})}var Y0=function(t,e,r){if(r||arguments.length===2)for(var i=0,s=e.length,n;i<s;i++)(n||!(i in e))&&(n||(n=Array.prototype.slice.call(e,0,i)),n[i]=e[i]);return t.concat(n||Array.prototype.slice.call(e))},B8=(function(){function t(e,r,i){this.name=e,this.version=r,this.os=i,this.type="browser"}return t})(),z8=(function(){function t(e){this.version=e,this.type="node",this.name="node",this.os=process.platform}return t})(),H8=(function(){function t(e,r,i,s){this.name=e,this.version=r,this.os=i,this.bot=s,this.type="bot-device"}return t})(),V8=(function(){function t(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return t})(),K8=(function(){function t(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return t})(),W8=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,G8=/(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,J0=3,Y8=[["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",W8]],Q0=[["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 D1(t){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new K8:typeof navigator<"u"?Q8(navigator.userAgent):Z8()}function J8(t){return t!==""&&Y8.reduce(function(e,r){var i=r[0],s=r[1];if(e)return e;var n=s.exec(t);return!!n&&[i,n]},!1)}function Q8(t){var e=J8(t);if(!e)return null;var r=e[0],i=e[1];if(r==="searchbot")return new V8;var s=i[1]&&i[1].split(".").join("_").split("_").slice(0,3);s?s.length<J0&&(s=Y0(Y0([],s,!0),eA(J0-s.length),!0)):s=[];var n=s.join("."),o=X8(t),a=G8.exec(t);return a&&a[1]?new H8(r,n,o,a[1]):new B8(r,n,o)}function X8(t){for(var e=0,r=Q0.length;e<r;e++){var i=Q0[e],s=i[0],n=i[1],o=n.exec(t);if(o)return s}return null}function Z8(){var t=typeof process<"u"&&process.version;return t?new z8(process.version.slice(1)):null}function eA(t){for(var e=[],r=0;r<t;r++)e.push("0");return e}var et={},X0;function R1(){if(X0)return et;X0=1,Object.defineProperty(et,"__esModule",{value:!0}),et.getLocalStorage=et.getLocalStorageOrThrow=et.getCrypto=et.getCryptoOrThrow=et.getLocation=et.getLocationOrThrow=et.getNavigator=et.getNavigatorOrThrow=et.getDocument=et.getDocumentOrThrow=et.getFromWindowOrThrow=et.getFromWindow=void 0;function t(f){let m;return typeof window<"u"&&typeof window[f]<"u"&&(m=window[f]),m}et.getFromWindow=t;function e(f){const m=t(f);if(!m)throw new Error(`${f} is not defined in Window`);return m}et.getFromWindowOrThrow=e;function r(){return e("document")}et.getDocumentOrThrow=r;function i(){return t("document")}et.getDocument=i;function s(){return e("navigator")}et.getNavigatorOrThrow=s;function n(){return t("navigator")}et.getNavigator=n;function o(){return e("location")}et.getLocationOrThrow=o;function a(){return t("location")}et.getLocation=a;function u(){return e("crypto")}et.getCryptoOrThrow=u;function c(){return t("crypto")}et.getCrypto=c;function l(){return e("localStorage")}et.getLocalStorageOrThrow=l;function h(){return t("localStorage")}return et.getLocalStorage=h,et}var Qr=R1(),Qa={},Z0;function tA(){if(Z0)return Qa;Z0=1,Object.defineProperty(Qa,"__esModule",{value:!0}),Qa.getWindowMetadata=void 0;const t=R1();function e(){let r,i;try{r=t.getDocumentOrThrow(),i=t.getLocationOrThrow()}catch{return null}function s(){const m=r.getElementsByTagName("link"),g=[];for(let y=0;y<m.length;y++){const C=m[y],S=C.getAttribute("rel");if(S&&S.toLowerCase().indexOf("icon")>-1){const A=C.getAttribute("href");if(A)if(A.toLowerCase().indexOf("https:")===-1&&A.toLowerCase().indexOf("http:")===-1&&A.indexOf("//")!==0){let D=i.protocol+"//"+i.host;if(A.indexOf("/")===0)D+=A;else{const O=i.pathname.split("/");O.pop();const T=O.join("/");D+=T+"/"+A}g.push(D)}else if(A.indexOf("//")===0){const D=i.protocol+A;g.push(D)}else g.push(A)}}return g}function n(...m){const g=r.getElementsByTagName("meta");for(let y=0;y<g.length;y++){const C=g[y],S=["itemprop","property","name"].map(A=>C.getAttribute(A)).filter(A=>A?m.includes(A):!1);if(S.length&&S){const A=C.getAttribute("content");if(A)return A}}return""}function o(){let m=n("name","og:site_name","og:title","twitter:title");return m||(m=r.title),m}function a(){return n("description","og:description","twitter:description","keywords")}const u=o(),c=a(),l=i.origin,h=s();return{description:c,url:l,icons:h,name:u}}return Qa.getWindowMetadata=e,Qa}var M1=tA();function Fc(t,{strict:e=!0}={}){return!t||typeof t!="string"?!1:e?/^0x[0-9a-fA-F]*$/.test(t):t.startsWith("0x")}function eb(t){return Fc(t,{strict:!1})?Math.ceil((t.length-2)/2):t.length}const k1="2.23.2";let pd={getDocsUrl:({docsBaseUrl:t,docsPath:e="",docsSlug:r})=>e?`${t??"https://viem.sh"}${e}${r?`#${r}`:""}`:void 0,version:`viem@${k1}`},Ah=class Jf extends Error{constructor(e,r={}){const i=r.cause instanceof Jf?r.cause.details:r.cause?.message?r.cause.message:r.details,s=r.cause instanceof Jf&&r.cause.docsPath||r.docsPath,n=pd.getDocsUrl?.({...r,docsPath:s}),o=[e||"An error occurred.","",...r.metaMessages?[...r.metaMessages,""]:[],...n?[`Docs: ${n}`]:[],...i?[`Details: ${i}`]:[],...pd.version?[`Version: ${pd.version}`]:[]].join(`
|
|
3
|
+
`);super(o,r.cause?{cause:r.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=i,this.docsPath=s,this.metaMessages=r.metaMessages,this.name=r.name??this.name,this.shortMessage=e,this.version=k1}walk(e){return U1(this,e)}};function U1(t,e){return e?.(t)?t:t&&typeof t=="object"&&"cause"in t&&t.cause!==void 0?U1(t.cause,e):e?null:t}let L1=class extends Ah{constructor({size:e,targetSize:r,type:i}){super(`${i.charAt(0).toUpperCase()}${i.slice(1).toLowerCase()} size (${e}) exceeds padding size (${r}).`,{name:"SizeExceedsPaddingSizeError"})}};function _a(t,{dir:e,size:r=32}={}){return typeof t=="string"?rA(t,{dir:e,size:r}):iA(t,{dir:e,size:r})}function rA(t,{dir:e,size:r=32}={}){if(r===null)return t;const i=t.replace("0x","");if(i.length>r*2)throw new L1({size:Math.ceil(i.length/2),targetSize:r,type:"hex"});return`0x${i[e==="right"?"padEnd":"padStart"](r*2,"0")}`}function iA(t,{dir:e,size:r=32}={}){if(r===null)return t;if(t.length>r)throw new L1({size:t.length,targetSize:r,type:"bytes"});const i=new Uint8Array(r);for(let s=0;s<r;s++){const n=e==="right";i[n?s:r-s-1]=t[n?s:t.length-s-1]}return i}let sA=class extends Ah{constructor({max:e,min:r,signed:i,size:s,value:n}){super(`Number "${n}" is not in safe ${s?`${s*8}-bit ${i?"signed":"unsigned"} `:""}integer range ${e?`(${r} to ${e})`:`(above ${r})`}`,{name:"IntegerOutOfRangeError"})}},nA=class extends Ah{constructor({givenSize:e,maxSize:r}){super(`Size cannot exceed ${r} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}};function Ea(t,{size:e}){if(eb(t)>e)throw new nA({givenSize:eb(t),maxSize:e})}function Qf(t,e={}){const{signed:r}=e;e.size&&Ea(t,{size:e.size});const i=BigInt(t);if(!r)return i;const s=(t.length-2)/2,n=(1n<<BigInt(s)*8n-1n)-1n;return i<=n?i:i-BigInt(`0x${"f".padStart(s*2,"f")}`)-1n}function oA(t,e={}){return Number(Qf(t,e))}const aA=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Xf(t,e={}){return typeof t=="number"||typeof t=="bigint"?j1(t,e):typeof t=="string"?lA(t,e):typeof t=="boolean"?cA(t,e):F1(t,e)}function cA(t,e={}){const r=`0x${Number(t)}`;return typeof e.size=="number"?(Ea(r,{size:e.size}),_a(r,{size:e.size})):r}function F1(t,e={}){let r="";for(let s=0;s<t.length;s++)r+=aA[t[s]];const i=`0x${r}`;return typeof e.size=="number"?(Ea(i,{size:e.size}),_a(i,{dir:"right",size:e.size})):i}function j1(t,e={}){const{signed:r,size:i}=e,s=BigInt(t);let n;i?r?n=(1n<<BigInt(i)*8n-1n)-1n:n=2n**(BigInt(i)*8n)-1n:typeof t=="number"&&(n=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof n=="bigint"&&r?-n-1n:0;if(n&&s>n||s<o){const u=typeof t=="bigint"?"n":"";throw new sA({max:n?`${n}${u}`:void 0,min:`${o}${u}`,signed:r,size:i,value:`${t}${u}`})}const a=`0x${(r&&s<0?(1n<<BigInt(i*8))+BigInt(s):s).toString(16)}`;return i?_a(a,{size:i}):a}const uA=new TextEncoder;function lA(t,e={}){const r=uA.encode(t);return F1(r,e)}const hA=new TextEncoder;function dA(t,e={}){return typeof t=="number"||typeof t=="bigint"?pA(t,e):typeof t=="boolean"?fA(t,e):Fc(t)?q1(t,e):B1(t,e)}function fA(t,e={}){const r=new Uint8Array(1);return r[0]=Number(t),typeof e.size=="number"?(Ea(r,{size:e.size}),_a(r,{size:e.size})):r}const ms={zero:48,nine:57,A:65,F:70,a:97,f:102};function tb(t){if(t>=ms.zero&&t<=ms.nine)return t-ms.zero;if(t>=ms.A&&t<=ms.F)return t-(ms.A-10);if(t>=ms.a&&t<=ms.f)return t-(ms.a-10)}function q1(t,e={}){let r=t;e.size&&(Ea(r,{size:e.size}),r=_a(r,{dir:"right",size:e.size}));let i=r.slice(2);i.length%2&&(i=`0${i}`);const s=i.length/2,n=new Uint8Array(s);for(let o=0,a=0;o<s;o++){const u=tb(i.charCodeAt(a++)),c=tb(i.charCodeAt(a++));if(u===void 0||c===void 0)throw new Ah(`Invalid byte sequence ("${i[a-2]}${i[a-1]}" in "${i}").`);n[o]=u*16+c}return n}function pA(t,e){const r=j1(t,e);return q1(r)}function B1(t,e={}){const r=hA.encode(t);return typeof e.size=="number"?(Ea(r,{size:e.size}),_a(r,{dir:"right",size:e.size})):r}function ih(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function gA(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Sh(t,...e){if(!gA(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 QQ(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");ih(t.outputLen),ih(t.blockLen)}function rb(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 bA(t,e){Sh(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}const sl=BigInt(2**32-1),ib=BigInt(32);function mA(t,e=!1){return e?{h:Number(t&sl),l:Number(t>>ib&sl)}:{h:Number(t>>ib&sl)|0,l:Number(t&sl)|0}}function yA(t,e=!1){let r=new Uint32Array(t.length),i=new Uint32Array(t.length);for(let s=0;s<t.length;s++){const{h:n,l:o}=mA(t[s],e);[r[s],i[s]]=[n,o]}return[r,i]}const wA=(t,e,r)=>t<<r|e>>>32-r,vA=(t,e,r)=>e<<r|t>>>32-r,_A=(t,e,r)=>e<<r-32|t>>>64-r,EA=(t,e,r)=>t<<r-32|e>>>64-r,co=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function IA(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function XQ(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function ZQ(t,e){return t<<32-e|t>>>e}const sb=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function AA(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function nb(t){for(let e=0;e<t.length;e++)t[e]=AA(t[e])}function SA(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function z1(t){return typeof t=="string"&&(t=SA(t)),Sh(t),t}function eX(...t){let e=0;for(let i=0;i<t.length;i++){const s=t[i];Sh(s),e+=s.length}const r=new Uint8Array(e);for(let i=0,s=0;i<t.length;i++){const n=t[i];r.set(n,s),s+=n.length}return r}let CA=class{clone(){return this._cloneInto()}};function $A(t){const e=i=>t().update(z1(i)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function rX(t=32){if(co&&typeof co.getRandomValues=="function")return co.getRandomValues(new Uint8Array(t));if(co&&typeof co.randomBytes=="function")return co.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}const H1=[],V1=[],K1=[],xA=BigInt(0),Xa=BigInt(1),PA=BigInt(2),NA=BigInt(7),OA=BigInt(256),TA=BigInt(113);for(let t=0,e=Xa,r=1,i=0;t<24;t++){[r,i]=[i,(2*r+3*i)%5],H1.push(2*(5*i+r)),V1.push((t+1)*(t+2)/2%64);let s=xA;for(let n=0;n<7;n++)e=(e<<Xa^(e>>NA)*TA)%OA,e&PA&&(s^=Xa<<(Xa<<BigInt(n))-Xa);K1.push(s)}const[DA,RA]=yA(K1,!0),ob=(t,e,r)=>r>32?_A(t,e,r):wA(t,e,r),ab=(t,e,r)=>r>32?EA(t,e,r):vA(t,e,r);function MA(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,u=(o+2)%10,c=r[u],l=r[u+1],h=ob(c,l,1)^r[a],f=ab(c,l,1)^r[a+1];for(let m=0;m<50;m+=10)t[o+m]^=h,t[o+m+1]^=f}let s=t[2],n=t[3];for(let o=0;o<24;o++){const a=V1[o],u=ob(s,n,a),c=ab(s,n,a),l=H1[o];s=t[l],n=t[l+1],t[l]=u,t[l+1]=c}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]^=DA[i],t[1]^=RA[i]}r.fill(0)}let kA=class W1 extends CA{constructor(e,r,i,s=!1,n=24){if(super(),this.blockLen=e,this.suffix=r,this.outputLen=i,this.enableXOF=s,this.rounds=n,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,ih(i),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=IA(this.state)}keccak(){sb||nb(this.state32),MA(this.state32,this.rounds),sb||nb(this.state32),this.posOut=0,this.pos=0}update(e){rb(this);const{blockLen:r,state:i}=this;e=z1(e);const s=e.length;for(let n=0;n<s;){const o=Math.min(r-this.pos,s-n);for(let a=0;a<o;a++)i[this.pos++]^=e[n++];this.pos===r&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:r,pos:i,blockLen:s}=this;e[i]^=r,(r&128)!==0&&i===s-1&&this.keccak(),e[s-1]^=128,this.keccak()}writeInto(e){rb(this,!1),Sh(e),this.finish();const r=this.state,{blockLen:i}=this;for(let s=0,n=e.length;s<n;){this.posOut>=i&&this.keccak();const o=Math.min(i-this.posOut,n-s);e.set(r.subarray(this.posOut,this.posOut+o),s),this.posOut+=o,s+=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 ih(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(bA(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,this.state.fill(0)}_cloneInto(e){const{blockLen:r,suffix:i,outputLen:s,rounds:n,enableXOF:o}=this;return e||(e=new W1(r,i,s,o,n)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=n,e.suffix=i,e.outputLen=s,e.enableXOF=o,e.destroyed=this.destroyed,e}};const UA=(t,e,r)=>$A(()=>new kA(e,t,r)),LA=UA(1,136,256/8);function G1(t,e){const r=e||"hex",i=LA(Fc(t,{strict:!1})?dA(t):t);return r==="bytes"?i:Xf(i)}let FA=class 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 gd=new FA(8192);function jA(t,e){if(gd.has(`${t}.${e}`))return gd.get(`${t}.${e}`);const r=t.substring(2).toLowerCase(),i=G1(B1(r),"bytes"),s=r.split("");for(let o=0;o<40;o+=2)i[o>>1]>>4>=8&&s[o]&&(s[o]=s[o].toUpperCase()),(i[o>>1]&15)>=8&&s[o+1]&&(s[o+1]=s[o+1].toUpperCase());const n=`0x${s.join("")}`;return gd.set(`${t}.${e}`,n),n}function qA(t){const e=G1(`0x${t.substring(4)}`).substring(26);return jA(`0x${e}`)}async function BA({hash:t,signature:e}){const r=Fc(t)?t:Xf(t),{secp256k1:i}=await Jl(async()=>{const{secp256k1:o}=await import("./secp256k1-BH-Xrsbp.js");return{secp256k1:o}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10]));return`0x${(()=>{if(typeof e=="object"&&"r"in e&&"s"in e){const{r:c,s:l,v:h,yParity:f}=e,m=Number(f??h),g=cb(m);return new i.Signature(Qf(c),Qf(l)).addRecoveryBit(g)}const o=Fc(e)?e:Xf(e),a=oA(`0x${o.slice(130)}`),u=cb(a);return i.Signature.fromCompact(o.substring(2,130)).addRecoveryBit(u)})().recoverPublicKey(r.substring(2)).toHex(!1)}`}function cb(t){if(t===0||t===1)return t;if(t===27)return 0;if(t===28)return 1;throw new Error("Invalid yParityOrV value")}async function zA({hash:t,signature:e}){return qA(await BA({hash:t,signature:e}))}function Y1(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function ta(t,e){e||(e=t.reduce((s,n)=>s+n.length,0));const r=Y1(e);let i=0;for(const s of t)r.set(s,i),i+=s.length;return r}function HA(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 s=0;s<t.length;s++){var n=t.charAt(s),o=n.charCodeAt(0);if(r[o]!==255)throw new TypeError(n+" is ambiguous");r[o]=s}var a=t.length,u=t.charAt(0),c=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function h(g){if(g instanceof Uint8Array||(ArrayBuffer.isView(g)?g=new Uint8Array(g.buffer,g.byteOffset,g.byteLength):Array.isArray(g)&&(g=Uint8Array.from(g))),!(g instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(g.length===0)return"";for(var y=0,C=0,S=0,A=g.length;S!==A&&g[S]===0;)S++,y++;for(var D=(A-S)*l+1>>>0,O=new Uint8Array(D);S!==A;){for(var T=g[S],x=0,M=D-1;(T!==0||x<C)&&M!==-1;M--,x++)T+=256*O[M]>>>0,O[M]=T%a>>>0,T=T/a>>>0;if(T!==0)throw new Error("Non-zero carry");C=x,S++}for(var U=D-C;U!==D&&O[U]===0;)U++;for(var R=u.repeat(y);U<D;++U)R+=t.charAt(O[U]);return R}function f(g){if(typeof g!="string")throw new TypeError("Expected String");if(g.length===0)return new Uint8Array;var y=0;if(g[y]!==" "){for(var C=0,S=0;g[y]===u;)C++,y++;for(var A=(g.length-y)*c+1>>>0,D=new Uint8Array(A);g[y];){var O=r[g.charCodeAt(y)];if(O===255)return;for(var T=0,x=A-1;(O!==0||T<S)&&x!==-1;x--,T++)O+=a*D[x]>>>0,D[x]=O%256>>>0,O=O/256>>>0;if(O!==0)throw new Error("Non-zero carry");S=T,y++}if(g[y]!==" "){for(var M=A-S;M!==A&&D[M]===0;)M++;for(var U=new Uint8Array(C+(A-M)),R=C;M!==A;)U[R++]=D[M++];return U}}}function m(g){var y=f(g);if(y)return y;throw new Error(`Non-${e} character`)}return{encode:h,decodeUnsafe:f,decode:m}}var VA=HA,KA=VA;const WA=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")},GA=t=>new TextEncoder().encode(t),YA=t=>new TextDecoder().decode(t);class JA{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 QA{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 J1(this,e)}}class XA{constructor(e){this.decoders=e}or(e){return J1(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 J1=(t,e)=>new XA({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class ZA{constructor(e,r,i,s){this.name=e,this.prefix=r,this.baseEncode=i,this.baseDecode=s,this.encoder=new JA(e,r,i),this.decoder=new QA(e,r,s)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Ch=({name:t,prefix:e,encode:r,decode:i})=>new ZA(t,e,r,i),Iu=({prefix:t,name:e,alphabet:r})=>{const{encode:i,decode:s}=KA(r,e);return Ch({prefix:t,name:e,encode:i,decode:n=>WA(s(n))})},eS=(t,e,r,i)=>{const s={};for(let l=0;l<e.length;++l)s[e[l]]=l;let n=t.length;for(;t[n-1]==="=";)--n;const o=new Uint8Array(n*r/8|0);let a=0,u=0,c=0;for(let l=0;l<n;++l){const h=s[t[l]];if(h===void 0)throw new SyntaxError(`Non-${i} character`);u=u<<r|h,a+=r,a>=8&&(a-=8,o[c++]=255&u>>a)}if(a>=r||255&u<<8-a)throw new SyntaxError("Unexpected end of data");return o},tS=(t,e,r)=>{const i=e[e.length-1]==="=",s=(1<<r)-1;let n="",o=0,a=0;for(let u=0;u<t.length;++u)for(a=a<<8|t[u],o+=8;o>r;)o-=r,n+=e[s&a>>o];if(o&&(n+=e[s&a<<r-o]),i)for(;n.length*r&7;)n+="=";return n},Cr=({name:t,prefix:e,bitsPerChar:r,alphabet:i})=>Ch({prefix:e,name:t,encode(s){return tS(s,i,r)},decode(s){return eS(s,i,r,t)}}),rS=Ch({prefix:"\0",name:"identity",encode:t=>YA(t),decode:t=>GA(t)}),iS=Object.freeze(Object.defineProperty({__proto__:null,identity:rS},Symbol.toStringTag,{value:"Module"})),sS=Cr({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),nS=Object.freeze(Object.defineProperty({__proto__:null,base2:sS},Symbol.toStringTag,{value:"Module"})),oS=Cr({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),aS=Object.freeze(Object.defineProperty({__proto__:null,base8:oS},Symbol.toStringTag,{value:"Module"})),cS=Iu({prefix:"9",name:"base10",alphabet:"0123456789"}),uS=Object.freeze(Object.defineProperty({__proto__:null,base10:cS},Symbol.toStringTag,{value:"Module"})),lS=Cr({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),hS=Cr({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),dS=Object.freeze(Object.defineProperty({__proto__:null,base16:lS,base16upper:hS},Symbol.toStringTag,{value:"Module"})),fS=Cr({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),pS=Cr({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),gS=Cr({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),bS=Cr({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),mS=Cr({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),yS=Cr({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),wS=Cr({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),vS=Cr({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),_S=Cr({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),ES=Object.freeze(Object.defineProperty({__proto__:null,base32:fS,base32hex:mS,base32hexpad:wS,base32hexpadupper:vS,base32hexupper:yS,base32pad:gS,base32padupper:bS,base32upper:pS,base32z:_S},Symbol.toStringTag,{value:"Module"})),IS=Iu({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),AS=Iu({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),SS=Object.freeze(Object.defineProperty({__proto__:null,base36:IS,base36upper:AS},Symbol.toStringTag,{value:"Module"})),CS=Iu({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),$S=Iu({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),xS=Object.freeze(Object.defineProperty({__proto__:null,base58btc:CS,base58flickr:$S},Symbol.toStringTag,{value:"Module"})),PS=Cr({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),NS=Cr({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),OS=Cr({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),TS=Cr({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),DS=Object.freeze(Object.defineProperty({__proto__:null,base64:PS,base64pad:NS,base64url:OS,base64urlpad:TS},Symbol.toStringTag,{value:"Module"})),Q1=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),RS=Q1.reduce((t,e,r)=>(t[r]=e,t),[]),MS=Q1.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function kS(t){return t.reduce((e,r)=>(e+=RS[r],e),"")}function US(t){const e=[];for(const r of t){const i=MS[r.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(i)}return new Uint8Array(e)}const LS=Ch({prefix:"🚀",name:"base256emoji",encode:kS,decode:US}),FS=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:LS},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const ub={...iS,...nS,...aS,...uS,...dS,...ES,...SS,...xS,...DS,...FS};function X1(t,e,r,i){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:i}}}const lb=X1("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),bd=X1("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=Y1(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Z1={utf8:lb,"utf-8":lb,hex:ub.base16,latin1:bd,ascii:bd,binary:bd,...ub};function _t(t,e="utf8"){const r=Z1[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,"utf8"):r.decoder.decode(`${r.prefix}${t}`)}function Fe(t,e="utf8"){const r=Z1[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)}var md={};const jS="6.6.1",qS={version:jS};var yd={},kl={exports:{}},BS=kl.exports,hb;function Ds(){return hb||(hb=1,(function(t){(function(e,r){function i($,d){if(!$)throw new Error(d||"Assertion failed")}function s($,d){$.super_=d;var b=function(){};b.prototype=d.prototype,$.prototype=new b,$.prototype.constructor=$}function n($,d,b){if(n.isBN($))return $;this.negative=0,this.words=null,this.length=0,this.red=null,$!==null&&((d==="le"||d==="be")&&(b=d,d=10),this._init($||0,d||10,b||"be"))}typeof e=="object"?e.exports=n:r.BN=n,n.BN=n,n.wordSize=26;var o;try{typeof window<"u"&&typeof window.Buffer<"u"?o=window.Buffer:o=Jv.Buffer}catch{}n.isBN=function(d){return d instanceof n?!0:d!==null&&typeof d=="object"&&d.constructor.wordSize===n.wordSize&&Array.isArray(d.words)},n.max=function(d,b){return d.cmp(b)>0?d:b},n.min=function(d,b){return d.cmp(b)<0?d:b},n.prototype._init=function(d,b,_){if(typeof d=="number")return this._initNumber(d,b,_);if(typeof d=="object")return this._initArray(d,b,_);b==="hex"&&(b=16),i(b===(b|0)&&b>=2&&b<=36),d=d.toString().replace(/\s+/g,"");var w=0;d[0]==="-"&&(w++,this.negative=1),w<d.length&&(b===16?this._parseHex(d,w,_):(this._parseBase(d,b,w),_==="le"&&this._initArray(this.toArray(),b,_)))},n.prototype._initNumber=function(d,b,_){d<0&&(this.negative=1,d=-d),d<67108864?(this.words=[d&67108863],this.length=1):d<4503599627370496?(this.words=[d&67108863,d/67108864&67108863],this.length=2):(i(d<9007199254740992),this.words=[d&67108863,d/67108864&67108863,1],this.length=3),_==="le"&&this._initArray(this.toArray(),b,_)},n.prototype._initArray=function(d,b,_){if(i(typeof d.length=="number"),d.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(d.length/3),this.words=new Array(this.length);for(var w=0;w<this.length;w++)this.words[w]=0;var v,I,P=0;if(_==="be")for(w=d.length-1,v=0;w>=0;w-=3)I=d[w]|d[w-1]<<8|d[w-2]<<16,this.words[v]|=I<<P&67108863,this.words[v+1]=I>>>26-P&67108863,P+=24,P>=26&&(P-=26,v++);else if(_==="le")for(w=0,v=0;w<d.length;w+=3)I=d[w]|d[w+1]<<8|d[w+2]<<16,this.words[v]|=I<<P&67108863,this.words[v+1]=I>>>26-P&67108863,P+=24,P>=26&&(P-=26,v++);return this.strip()};function a($,d){var b=$.charCodeAt(d);return b>=65&&b<=70?b-55:b>=97&&b<=102?b-87:b-48&15}function u($,d,b){var _=a($,b);return b-1>=d&&(_|=a($,b-1)<<4),_}n.prototype._parseHex=function(d,b,_){this.length=Math.ceil((d.length-b)/6),this.words=new Array(this.length);for(var w=0;w<this.length;w++)this.words[w]=0;var v=0,I=0,P;if(_==="be")for(w=d.length-1;w>=b;w-=2)P=u(d,b,w)<<v,this.words[I]|=P&67108863,v>=18?(v-=18,I+=1,this.words[I]|=P>>>26):v+=8;else{var E=d.length-b;for(w=E%2===0?b+1:b;w<d.length;w+=2)P=u(d,b,w)<<v,this.words[I]|=P&67108863,v>=18?(v-=18,I+=1,this.words[I]|=P>>>26):v+=8}this.strip()};function c($,d,b,_){for(var w=0,v=Math.min($.length,b),I=d;I<v;I++){var P=$.charCodeAt(I)-48;w*=_,P>=49?w+=P-49+10:P>=17?w+=P-17+10:w+=P}return w}n.prototype._parseBase=function(d,b,_){this.words=[0],this.length=1;for(var w=0,v=1;v<=67108863;v*=b)w++;w--,v=v/b|0;for(var I=d.length-_,P=I%w,E=Math.min(I,I-P)+_,p=0,N=_;N<E;N+=w)p=c(d,N,N+w,b),this.imuln(v),this.words[0]+p<67108864?this.words[0]+=p:this._iaddn(p);if(P!==0){var q=1;for(p=c(d,N,d.length,b),N=0;N<P;N++)q*=b;this.imuln(q),this.words[0]+p<67108864?this.words[0]+=p:this._iaddn(p)}this.strip()},n.prototype.copy=function(d){d.words=new Array(this.length);for(var b=0;b<this.length;b++)d.words[b]=this.words[b];d.length=this.length,d.negative=this.negative,d.red=this.red},n.prototype.clone=function(){var d=new n(null);return this.copy(d),d},n.prototype._expand=function(d){for(;this.length<d;)this.words[this.length++]=0;return this},n.prototype.strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},n.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},n.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var l=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],h=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],f=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];n.prototype.toString=function(d,b){d=d||10,b=b|0||1;var _;if(d===16||d==="hex"){_="";for(var w=0,v=0,I=0;I<this.length;I++){var P=this.words[I],E=((P<<w|v)&16777215).toString(16);v=P>>>24-w&16777215,w+=2,w>=26&&(w-=26,I--),v!==0||I!==this.length-1?_=l[6-E.length]+E+_:_=E+_}for(v!==0&&(_=v.toString(16)+_);_.length%b!==0;)_="0"+_;return this.negative!==0&&(_="-"+_),_}if(d===(d|0)&&d>=2&&d<=36){var p=h[d],N=f[d];_="";var q=this.clone();for(q.negative=0;!q.isZero();){var H=q.modn(N).toString(d);q=q.idivn(N),q.isZero()?_=H+_:_=l[p-H.length]+H+_}for(this.isZero()&&(_="0"+_);_.length%b!==0;)_="0"+_;return this.negative!==0&&(_="-"+_),_}i(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var d=this.words[0];return this.length===2?d+=this.words[1]*67108864:this.length===3&&this.words[2]===1?d+=4503599627370496+this.words[1]*67108864:this.length>2&&i(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-d:d},n.prototype.toJSON=function(){return this.toString(16)},n.prototype.toBuffer=function(d,b){return i(typeof o<"u"),this.toArrayLike(o,d,b)},n.prototype.toArray=function(d,b){return this.toArrayLike(Array,d,b)},n.prototype.toArrayLike=function(d,b,_){var w=this.byteLength(),v=_||Math.max(1,w);i(w<=v,"byte array longer than desired length"),i(v>0,"Requested array length <= 0"),this.strip();var I=b==="le",P=new d(v),E,p,N=this.clone();if(I){for(p=0;!N.isZero();p++)E=N.andln(255),N.iushrn(8),P[p]=E;for(;p<v;p++)P[p]=0}else{for(p=0;p<v-w;p++)P[p]=0;for(p=0;!N.isZero();p++)E=N.andln(255),N.iushrn(8),P[v-p-1]=E}return P},Math.clz32?n.prototype._countBits=function(d){return 32-Math.clz32(d)}:n.prototype._countBits=function(d){var b=d,_=0;return b>=4096&&(_+=13,b>>>=13),b>=64&&(_+=7,b>>>=7),b>=8&&(_+=4,b>>>=4),b>=2&&(_+=2,b>>>=2),_+b},n.prototype._zeroBits=function(d){if(d===0)return 26;var b=d,_=0;return(b&8191)===0&&(_+=13,b>>>=13),(b&127)===0&&(_+=7,b>>>=7),(b&15)===0&&(_+=4,b>>>=4),(b&3)===0&&(_+=2,b>>>=2),(b&1)===0&&_++,_},n.prototype.bitLength=function(){var d=this.words[this.length-1],b=this._countBits(d);return(this.length-1)*26+b};function m($){for(var d=new Array($.bitLength()),b=0;b<d.length;b++){var _=b/26|0,w=b%26;d[b]=($.words[_]&1<<w)>>>w}return d}n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var d=0,b=0;b<this.length;b++){var _=this._zeroBits(this.words[b]);if(d+=_,_!==26)break}return d},n.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},n.prototype.toTwos=function(d){return this.negative!==0?this.abs().inotn(d).iaddn(1):this.clone()},n.prototype.fromTwos=function(d){return this.testn(d-1)?this.notn(d).iaddn(1).ineg():this.clone()},n.prototype.isNeg=function(){return this.negative!==0},n.prototype.neg=function(){return this.clone().ineg()},n.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},n.prototype.iuor=function(d){for(;this.length<d.length;)this.words[this.length++]=0;for(var b=0;b<d.length;b++)this.words[b]=this.words[b]|d.words[b];return this.strip()},n.prototype.ior=function(d){return i((this.negative|d.negative)===0),this.iuor(d)},n.prototype.or=function(d){return this.length>d.length?this.clone().ior(d):d.clone().ior(this)},n.prototype.uor=function(d){return this.length>d.length?this.clone().iuor(d):d.clone().iuor(this)},n.prototype.iuand=function(d){var b;this.length>d.length?b=d:b=this;for(var _=0;_<b.length;_++)this.words[_]=this.words[_]&d.words[_];return this.length=b.length,this.strip()},n.prototype.iand=function(d){return i((this.negative|d.negative)===0),this.iuand(d)},n.prototype.and=function(d){return this.length>d.length?this.clone().iand(d):d.clone().iand(this)},n.prototype.uand=function(d){return this.length>d.length?this.clone().iuand(d):d.clone().iuand(this)},n.prototype.iuxor=function(d){var b,_;this.length>d.length?(b=this,_=d):(b=d,_=this);for(var w=0;w<_.length;w++)this.words[w]=b.words[w]^_.words[w];if(this!==b)for(;w<b.length;w++)this.words[w]=b.words[w];return this.length=b.length,this.strip()},n.prototype.ixor=function(d){return i((this.negative|d.negative)===0),this.iuxor(d)},n.prototype.xor=function(d){return this.length>d.length?this.clone().ixor(d):d.clone().ixor(this)},n.prototype.uxor=function(d){return this.length>d.length?this.clone().iuxor(d):d.clone().iuxor(this)},n.prototype.inotn=function(d){i(typeof d=="number"&&d>=0);var b=Math.ceil(d/26)|0,_=d%26;this._expand(b),_>0&&b--;for(var w=0;w<b;w++)this.words[w]=~this.words[w]&67108863;return _>0&&(this.words[w]=~this.words[w]&67108863>>26-_),this.strip()},n.prototype.notn=function(d){return this.clone().inotn(d)},n.prototype.setn=function(d,b){i(typeof d=="number"&&d>=0);var _=d/26|0,w=d%26;return this._expand(_+1),b?this.words[_]=this.words[_]|1<<w:this.words[_]=this.words[_]&~(1<<w),this.strip()},n.prototype.iadd=function(d){var b;if(this.negative!==0&&d.negative===0)return this.negative=0,b=this.isub(d),this.negative^=1,this._normSign();if(this.negative===0&&d.negative!==0)return d.negative=0,b=this.isub(d),d.negative=1,b._normSign();var _,w;this.length>d.length?(_=this,w=d):(_=d,w=this);for(var v=0,I=0;I<w.length;I++)b=(_.words[I]|0)+(w.words[I]|0)+v,this.words[I]=b&67108863,v=b>>>26;for(;v!==0&&I<_.length;I++)b=(_.words[I]|0)+v,this.words[I]=b&67108863,v=b>>>26;if(this.length=_.length,v!==0)this.words[this.length]=v,this.length++;else if(_!==this)for(;I<_.length;I++)this.words[I]=_.words[I];return this},n.prototype.add=function(d){var b;return d.negative!==0&&this.negative===0?(d.negative=0,b=this.sub(d),d.negative^=1,b):d.negative===0&&this.negative!==0?(this.negative=0,b=d.sub(this),this.negative=1,b):this.length>d.length?this.clone().iadd(d):d.clone().iadd(this)},n.prototype.isub=function(d){if(d.negative!==0){d.negative=0;var b=this.iadd(d);return d.negative=1,b._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(d),this.negative=1,this._normSign();var _=this.cmp(d);if(_===0)return this.negative=0,this.length=1,this.words[0]=0,this;var w,v;_>0?(w=this,v=d):(w=d,v=this);for(var I=0,P=0;P<v.length;P++)b=(w.words[P]|0)-(v.words[P]|0)+I,I=b>>26,this.words[P]=b&67108863;for(;I!==0&&P<w.length;P++)b=(w.words[P]|0)+I,I=b>>26,this.words[P]=b&67108863;if(I===0&&P<w.length&&w!==this)for(;P<w.length;P++)this.words[P]=w.words[P];return this.length=Math.max(this.length,P),w!==this&&(this.negative=1),this.strip()},n.prototype.sub=function(d){return this.clone().isub(d)};function g($,d,b){b.negative=d.negative^$.negative;var _=$.length+d.length|0;b.length=_,_=_-1|0;var w=$.words[0]|0,v=d.words[0]|0,I=w*v,P=I&67108863,E=I/67108864|0;b.words[0]=P;for(var p=1;p<_;p++){for(var N=E>>>26,q=E&67108863,H=Math.min(p,d.length-1),z=Math.max(0,p-$.length+1);z<=H;z++){var V=p-z|0;w=$.words[V]|0,v=d.words[z]|0,I=w*v+q,N+=I/67108864|0,q=I&67108863}b.words[p]=q|0,E=N|0}return E!==0?b.words[p]=E|0:b.length--,b.strip()}var y=function(d,b,_){var w=d.words,v=b.words,I=_.words,P=0,E,p,N,q=w[0]|0,H=q&8191,z=q>>>13,V=w[1]|0,Y=V&8191,te=V>>>13,ie=w[2]|0,Z=ie&8191,ae=ie>>>13,ht=w[3]|0,ge=ht&8191,ye=ht>>>13,Dt=w[4]|0,Ie=Dt&8191,Te=Dt>>>13,bi=w[5]|0,Ze=bi&8191,Ke=bi>>>13,Vi=w[6]|0,qe=Vi&8191,We=Vi>>>13,Ki=w[7]|0,De=Ki&8191,Re=Ki>>>13,Wi=w[8]|0,Me=Wi&8191,st=Wi>>>13,dn=w[9]|0,Se=dn&8191,It=dn>>>13,Na=v[0]|0,Rt=Na&8191,At=Na>>>13,fn=v[1]|0,St=fn&8191,Ct=fn>>>13,qu=v[2]|0,Ge=qu&8191,$t=qu>>>13,Bu=v[3]|0,Mt=Bu&8191,bt=Bu>>>13,Rs=v[4]|0,mt=Rs&8191,yt=Rs>>>13,so=v[5]|0,nt=so&8191,kt=so>>>13,zu=v[6]|0,Ut=zu&8191,Lt=zu>>>13,Hu=v[7]|0,xt=Hu&8191,wt=Hu>>>13,Gi=v[8]|0,Ft=Gi&8191,jt=Gi>>>13,Vu=v[9]|0,qt=Vu&8191,Bt=Vu>>>13;_.negative=d.negative^b.negative,_.length=19,E=Math.imul(H,Rt),p=Math.imul(H,At),p=p+Math.imul(z,Rt)|0,N=Math.imul(z,At);var ei=(P+E|0)+((p&8191)<<13)|0;P=(N+(p>>>13)|0)+(ei>>>26)|0,ei&=67108863,E=Math.imul(Y,Rt),p=Math.imul(Y,At),p=p+Math.imul(te,Rt)|0,N=Math.imul(te,At),E=E+Math.imul(H,St)|0,p=p+Math.imul(H,Ct)|0,p=p+Math.imul(z,St)|0,N=N+Math.imul(z,Ct)|0;var Oa=(P+E|0)+((p&8191)<<13)|0;P=(N+(p>>>13)|0)+(Oa>>>26)|0,Oa&=67108863,E=Math.imul(Z,Rt),p=Math.imul(Z,At),p=p+Math.imul(ae,Rt)|0,N=Math.imul(ae,At),E=E+Math.imul(Y,St)|0,p=p+Math.imul(Y,Ct)|0,p=p+Math.imul(te,St)|0,N=N+Math.imul(te,Ct)|0,E=E+Math.imul(H,Ge)|0,p=p+Math.imul(H,$t)|0,p=p+Math.imul(z,Ge)|0,N=N+Math.imul(z,$t)|0;var Ta=(P+E|0)+((p&8191)<<13)|0;P=(N+(p>>>13)|0)+(Ta>>>26)|0,Ta&=67108863,E=Math.imul(ge,Rt),p=Math.imul(ge,At),p=p+Math.imul(ye,Rt)|0,N=Math.imul(ye,At),E=E+Math.imul(Z,St)|0,p=p+Math.imul(Z,Ct)|0,p=p+Math.imul(ae,St)|0,N=N+Math.imul(ae,Ct)|0,E=E+Math.imul(Y,Ge)|0,p=p+Math.imul(Y,$t)|0,p=p+Math.imul(te,Ge)|0,N=N+Math.imul(te,$t)|0,E=E+Math.imul(H,Mt)|0,p=p+Math.imul(H,bt)|0,p=p+Math.imul(z,Mt)|0,N=N+Math.imul(z,bt)|0;var Da=(P+E|0)+((p&8191)<<13)|0;P=(N+(p>>>13)|0)+(Da>>>26)|0,Da&=67108863,E=Math.imul(Ie,Rt),p=Math.imul(Ie,At),p=p+Math.imul(Te,Rt)|0,N=Math.imul(Te,At),E=E+Math.imul(ge,St)|0,p=p+Math.imul(ge,Ct)|0,p=p+Math.imul(ye,St)|0,N=N+Math.imul(ye,Ct)|0,E=E+Math.imul(Z,Ge)|0,p=p+Math.imul(Z,$t)|0,p=p+Math.imul(ae,Ge)|0,N=N+Math.imul(ae,$t)|0,E=E+Math.imul(Y,Mt)|0,p=p+Math.imul(Y,bt)|0,p=p+Math.imul(te,Mt)|0,N=N+Math.imul(te,bt)|0,E=E+Math.imul(H,mt)|0,p=p+Math.imul(H,yt)|0,p=p+Math.imul(z,mt)|0,N=N+Math.imul(z,yt)|0;var Ra=(P+E|0)+((p&8191)<<13)|0;P=(N+(p>>>13)|0)+(Ra>>>26)|0,Ra&=67108863,E=Math.imul(Ze,Rt),p=Math.imul(Ze,At),p=p+Math.imul(Ke,Rt)|0,N=Math.imul(Ke,At),E=E+Math.imul(Ie,St)|0,p=p+Math.imul(Ie,Ct)|0,p=p+Math.imul(Te,St)|0,N=N+Math.imul(Te,Ct)|0,E=E+Math.imul(ge,Ge)|0,p=p+Math.imul(ge,$t)|0,p=p+Math.imul(ye,Ge)|0,N=N+Math.imul(ye,$t)|0,E=E+Math.imul(Z,Mt)|0,p=p+Math.imul(Z,bt)|0,p=p+Math.imul(ae,Mt)|0,N=N+Math.imul(ae,bt)|0,E=E+Math.imul(Y,mt)|0,p=p+Math.imul(Y,yt)|0,p=p+Math.imul(te,mt)|0,N=N+Math.imul(te,yt)|0,E=E+Math.imul(H,nt)|0,p=p+Math.imul(H,kt)|0,p=p+Math.imul(z,nt)|0,N=N+Math.imul(z,kt)|0;var Ma=(P+E|0)+((p&8191)<<13)|0;P=(N+(p>>>13)|0)+(Ma>>>26)|0,Ma&=67108863,E=Math.imul(qe,Rt),p=Math.imul(qe,At),p=p+Math.imul(We,Rt)|0,N=Math.imul(We,At),E=E+Math.imul(Ze,St)|0,p=p+Math.imul(Ze,Ct)|0,p=p+Math.imul(Ke,St)|0,N=N+Math.imul(Ke,Ct)|0,E=E+Math.imul(Ie,Ge)|0,p=p+Math.imul(Ie,$t)|0,p=p+Math.imul(Te,Ge)|0,N=N+Math.imul(Te,$t)|0,E=E+Math.imul(ge,Mt)|0,p=p+Math.imul(ge,bt)|0,p=p+Math.imul(ye,Mt)|0,N=N+Math.imul(ye,bt)|0,E=E+Math.imul(Z,mt)|0,p=p+Math.imul(Z,yt)|0,p=p+Math.imul(ae,mt)|0,N=N+Math.imul(ae,yt)|0,E=E+Math.imul(Y,nt)|0,p=p+Math.imul(Y,kt)|0,p=p+Math.imul(te,nt)|0,N=N+Math.imul(te,kt)|0,E=E+Math.imul(H,Ut)|0,p=p+Math.imul(H,Lt)|0,p=p+Math.imul(z,Ut)|0,N=N+Math.imul(z,Lt)|0;var Oi=(P+E|0)+((p&8191)<<13)|0;P=(N+(p>>>13)|0)+(Oi>>>26)|0,Oi&=67108863,E=Math.imul(De,Rt),p=Math.imul(De,At),p=p+Math.imul(Re,Rt)|0,N=Math.imul(Re,At),E=E+Math.imul(qe,St)|0,p=p+Math.imul(qe,Ct)|0,p=p+Math.imul(We,St)|0,N=N+Math.imul(We,Ct)|0,E=E+Math.imul(Ze,Ge)|0,p=p+Math.imul(Ze,$t)|0,p=p+Math.imul(Ke,Ge)|0,N=N+Math.imul(Ke,$t)|0,E=E+Math.imul(Ie,Mt)|0,p=p+Math.imul(Ie,bt)|0,p=p+Math.imul(Te,Mt)|0,N=N+Math.imul(Te,bt)|0,E=E+Math.imul(ge,mt)|0,p=p+Math.imul(ge,yt)|0,p=p+Math.imul(ye,mt)|0,N=N+Math.imul(ye,yt)|0,E=E+Math.imul(Z,nt)|0,p=p+Math.imul(Z,kt)|0,p=p+Math.imul(ae,nt)|0,N=N+Math.imul(ae,kt)|0,E=E+Math.imul(Y,Ut)|0,p=p+Math.imul(Y,Lt)|0,p=p+Math.imul(te,Ut)|0,N=N+Math.imul(te,Lt)|0,E=E+Math.imul(H,xt)|0,p=p+Math.imul(H,wt)|0,p=p+Math.imul(z,xt)|0,N=N+Math.imul(z,wt)|0;var ka=(P+E|0)+((p&8191)<<13)|0;P=(N+(p>>>13)|0)+(ka>>>26)|0,ka&=67108863,E=Math.imul(Me,Rt),p=Math.imul(Me,At),p=p+Math.imul(st,Rt)|0,N=Math.imul(st,At),E=E+Math.imul(De,St)|0,p=p+Math.imul(De,Ct)|0,p=p+Math.imul(Re,St)|0,N=N+Math.imul(Re,Ct)|0,E=E+Math.imul(qe,Ge)|0,p=p+Math.imul(qe,$t)|0,p=p+Math.imul(We,Ge)|0,N=N+Math.imul(We,$t)|0,E=E+Math.imul(Ze,Mt)|0,p=p+Math.imul(Ze,bt)|0,p=p+Math.imul(Ke,Mt)|0,N=N+Math.imul(Ke,bt)|0,E=E+Math.imul(Ie,mt)|0,p=p+Math.imul(Ie,yt)|0,p=p+Math.imul(Te,mt)|0,N=N+Math.imul(Te,yt)|0,E=E+Math.imul(ge,nt)|0,p=p+Math.imul(ge,kt)|0,p=p+Math.imul(ye,nt)|0,N=N+Math.imul(ye,kt)|0,E=E+Math.imul(Z,Ut)|0,p=p+Math.imul(Z,Lt)|0,p=p+Math.imul(ae,Ut)|0,N=N+Math.imul(ae,Lt)|0,E=E+Math.imul(Y,xt)|0,p=p+Math.imul(Y,wt)|0,p=p+Math.imul(te,xt)|0,N=N+Math.imul(te,wt)|0,E=E+Math.imul(H,Ft)|0,p=p+Math.imul(H,jt)|0,p=p+Math.imul(z,Ft)|0,N=N+Math.imul(z,jt)|0;var Ua=(P+E|0)+((p&8191)<<13)|0;P=(N+(p>>>13)|0)+(Ua>>>26)|0,Ua&=67108863,E=Math.imul(Se,Rt),p=Math.imul(Se,At),p=p+Math.imul(It,Rt)|0,N=Math.imul(It,At),E=E+Math.imul(Me,St)|0,p=p+Math.imul(Me,Ct)|0,p=p+Math.imul(st,St)|0,N=N+Math.imul(st,Ct)|0,E=E+Math.imul(De,Ge)|0,p=p+Math.imul(De,$t)|0,p=p+Math.imul(Re,Ge)|0,N=N+Math.imul(Re,$t)|0,E=E+Math.imul(qe,Mt)|0,p=p+Math.imul(qe,bt)|0,p=p+Math.imul(We,Mt)|0,N=N+Math.imul(We,bt)|0,E=E+Math.imul(Ze,mt)|0,p=p+Math.imul(Ze,yt)|0,p=p+Math.imul(Ke,mt)|0,N=N+Math.imul(Ke,yt)|0,E=E+Math.imul(Ie,nt)|0,p=p+Math.imul(Ie,kt)|0,p=p+Math.imul(Te,nt)|0,N=N+Math.imul(Te,kt)|0,E=E+Math.imul(ge,Ut)|0,p=p+Math.imul(ge,Lt)|0,p=p+Math.imul(ye,Ut)|0,N=N+Math.imul(ye,Lt)|0,E=E+Math.imul(Z,xt)|0,p=p+Math.imul(Z,wt)|0,p=p+Math.imul(ae,xt)|0,N=N+Math.imul(ae,wt)|0,E=E+Math.imul(Y,Ft)|0,p=p+Math.imul(Y,jt)|0,p=p+Math.imul(te,Ft)|0,N=N+Math.imul(te,jt)|0,E=E+Math.imul(H,qt)|0,p=p+Math.imul(H,Bt)|0,p=p+Math.imul(z,qt)|0,N=N+Math.imul(z,Bt)|0;var La=(P+E|0)+((p&8191)<<13)|0;P=(N+(p>>>13)|0)+(La>>>26)|0,La&=67108863,E=Math.imul(Se,St),p=Math.imul(Se,Ct),p=p+Math.imul(It,St)|0,N=Math.imul(It,Ct),E=E+Math.imul(Me,Ge)|0,p=p+Math.imul(Me,$t)|0,p=p+Math.imul(st,Ge)|0,N=N+Math.imul(st,$t)|0,E=E+Math.imul(De,Mt)|0,p=p+Math.imul(De,bt)|0,p=p+Math.imul(Re,Mt)|0,N=N+Math.imul(Re,bt)|0,E=E+Math.imul(qe,mt)|0,p=p+Math.imul(qe,yt)|0,p=p+Math.imul(We,mt)|0,N=N+Math.imul(We,yt)|0,E=E+Math.imul(Ze,nt)|0,p=p+Math.imul(Ze,kt)|0,p=p+Math.imul(Ke,nt)|0,N=N+Math.imul(Ke,kt)|0,E=E+Math.imul(Ie,Ut)|0,p=p+Math.imul(Ie,Lt)|0,p=p+Math.imul(Te,Ut)|0,N=N+Math.imul(Te,Lt)|0,E=E+Math.imul(ge,xt)|0,p=p+Math.imul(ge,wt)|0,p=p+Math.imul(ye,xt)|0,N=N+Math.imul(ye,wt)|0,E=E+Math.imul(Z,Ft)|0,p=p+Math.imul(Z,jt)|0,p=p+Math.imul(ae,Ft)|0,N=N+Math.imul(ae,jt)|0,E=E+Math.imul(Y,qt)|0,p=p+Math.imul(Y,Bt)|0,p=p+Math.imul(te,qt)|0,N=N+Math.imul(te,Bt)|0;var Fa=(P+E|0)+((p&8191)<<13)|0;P=(N+(p>>>13)|0)+(Fa>>>26)|0,Fa&=67108863,E=Math.imul(Se,Ge),p=Math.imul(Se,$t),p=p+Math.imul(It,Ge)|0,N=Math.imul(It,$t),E=E+Math.imul(Me,Mt)|0,p=p+Math.imul(Me,bt)|0,p=p+Math.imul(st,Mt)|0,N=N+Math.imul(st,bt)|0,E=E+Math.imul(De,mt)|0,p=p+Math.imul(De,yt)|0,p=p+Math.imul(Re,mt)|0,N=N+Math.imul(Re,yt)|0,E=E+Math.imul(qe,nt)|0,p=p+Math.imul(qe,kt)|0,p=p+Math.imul(We,nt)|0,N=N+Math.imul(We,kt)|0,E=E+Math.imul(Ze,Ut)|0,p=p+Math.imul(Ze,Lt)|0,p=p+Math.imul(Ke,Ut)|0,N=N+Math.imul(Ke,Lt)|0,E=E+Math.imul(Ie,xt)|0,p=p+Math.imul(Ie,wt)|0,p=p+Math.imul(Te,xt)|0,N=N+Math.imul(Te,wt)|0,E=E+Math.imul(ge,Ft)|0,p=p+Math.imul(ge,jt)|0,p=p+Math.imul(ye,Ft)|0,N=N+Math.imul(ye,jt)|0,E=E+Math.imul(Z,qt)|0,p=p+Math.imul(Z,Bt)|0,p=p+Math.imul(ae,qt)|0,N=N+Math.imul(ae,Bt)|0;var ja=(P+E|0)+((p&8191)<<13)|0;P=(N+(p>>>13)|0)+(ja>>>26)|0,ja&=67108863,E=Math.imul(Se,Mt),p=Math.imul(Se,bt),p=p+Math.imul(It,Mt)|0,N=Math.imul(It,bt),E=E+Math.imul(Me,mt)|0,p=p+Math.imul(Me,yt)|0,p=p+Math.imul(st,mt)|0,N=N+Math.imul(st,yt)|0,E=E+Math.imul(De,nt)|0,p=p+Math.imul(De,kt)|0,p=p+Math.imul(Re,nt)|0,N=N+Math.imul(Re,kt)|0,E=E+Math.imul(qe,Ut)|0,p=p+Math.imul(qe,Lt)|0,p=p+Math.imul(We,Ut)|0,N=N+Math.imul(We,Lt)|0,E=E+Math.imul(Ze,xt)|0,p=p+Math.imul(Ze,wt)|0,p=p+Math.imul(Ke,xt)|0,N=N+Math.imul(Ke,wt)|0,E=E+Math.imul(Ie,Ft)|0,p=p+Math.imul(Ie,jt)|0,p=p+Math.imul(Te,Ft)|0,N=N+Math.imul(Te,jt)|0,E=E+Math.imul(ge,qt)|0,p=p+Math.imul(ge,Bt)|0,p=p+Math.imul(ye,qt)|0,N=N+Math.imul(ye,Bt)|0;var Ms=(P+E|0)+((p&8191)<<13)|0;P=(N+(p>>>13)|0)+(Ms>>>26)|0,Ms&=67108863,E=Math.imul(Se,mt),p=Math.imul(Se,yt),p=p+Math.imul(It,mt)|0,N=Math.imul(It,yt),E=E+Math.imul(Me,nt)|0,p=p+Math.imul(Me,kt)|0,p=p+Math.imul(st,nt)|0,N=N+Math.imul(st,kt)|0,E=E+Math.imul(De,Ut)|0,p=p+Math.imul(De,Lt)|0,p=p+Math.imul(Re,Ut)|0,N=N+Math.imul(Re,Lt)|0,E=E+Math.imul(qe,xt)|0,p=p+Math.imul(qe,wt)|0,p=p+Math.imul(We,xt)|0,N=N+Math.imul(We,wt)|0,E=E+Math.imul(Ze,Ft)|0,p=p+Math.imul(Ze,jt)|0,p=p+Math.imul(Ke,Ft)|0,N=N+Math.imul(Ke,jt)|0,E=E+Math.imul(Ie,qt)|0,p=p+Math.imul(Ie,Bt)|0,p=p+Math.imul(Te,qt)|0,N=N+Math.imul(Te,Bt)|0;var qa=(P+E|0)+((p&8191)<<13)|0;P=(N+(p>>>13)|0)+(qa>>>26)|0,qa&=67108863,E=Math.imul(Se,nt),p=Math.imul(Se,kt),p=p+Math.imul(It,nt)|0,N=Math.imul(It,kt),E=E+Math.imul(Me,Ut)|0,p=p+Math.imul(Me,Lt)|0,p=p+Math.imul(st,Ut)|0,N=N+Math.imul(st,Lt)|0,E=E+Math.imul(De,xt)|0,p=p+Math.imul(De,wt)|0,p=p+Math.imul(Re,xt)|0,N=N+Math.imul(Re,wt)|0,E=E+Math.imul(qe,Ft)|0,p=p+Math.imul(qe,jt)|0,p=p+Math.imul(We,Ft)|0,N=N+Math.imul(We,jt)|0,E=E+Math.imul(Ze,qt)|0,p=p+Math.imul(Ze,Bt)|0,p=p+Math.imul(Ke,qt)|0,N=N+Math.imul(Ke,Bt)|0;var Ba=(P+E|0)+((p&8191)<<13)|0;P=(N+(p>>>13)|0)+(Ba>>>26)|0,Ba&=67108863,E=Math.imul(Se,Ut),p=Math.imul(Se,Lt),p=p+Math.imul(It,Ut)|0,N=Math.imul(It,Lt),E=E+Math.imul(Me,xt)|0,p=p+Math.imul(Me,wt)|0,p=p+Math.imul(st,xt)|0,N=N+Math.imul(st,wt)|0,E=E+Math.imul(De,Ft)|0,p=p+Math.imul(De,jt)|0,p=p+Math.imul(Re,Ft)|0,N=N+Math.imul(Re,jt)|0,E=E+Math.imul(qe,qt)|0,p=p+Math.imul(qe,Bt)|0,p=p+Math.imul(We,qt)|0,N=N+Math.imul(We,Bt)|0;var mi=(P+E|0)+((p&8191)<<13)|0;P=(N+(p>>>13)|0)+(mi>>>26)|0,mi&=67108863,E=Math.imul(Se,xt),p=Math.imul(Se,wt),p=p+Math.imul(It,xt)|0,N=Math.imul(It,wt),E=E+Math.imul(Me,Ft)|0,p=p+Math.imul(Me,jt)|0,p=p+Math.imul(st,Ft)|0,N=N+Math.imul(st,jt)|0,E=E+Math.imul(De,qt)|0,p=p+Math.imul(De,Bt)|0,p=p+Math.imul(Re,qt)|0,N=N+Math.imul(Re,Bt)|0;var za=(P+E|0)+((p&8191)<<13)|0;P=(N+(p>>>13)|0)+(za>>>26)|0,za&=67108863,E=Math.imul(Se,Ft),p=Math.imul(Se,jt),p=p+Math.imul(It,Ft)|0,N=Math.imul(It,jt),E=E+Math.imul(Me,qt)|0,p=p+Math.imul(Me,Bt)|0,p=p+Math.imul(st,qt)|0,N=N+Math.imul(st,Bt)|0;var Ha=(P+E|0)+((p&8191)<<13)|0;P=(N+(p>>>13)|0)+(Ha>>>26)|0,Ha&=67108863,E=Math.imul(Se,qt),p=Math.imul(Se,Bt),p=p+Math.imul(It,qt)|0,N=Math.imul(It,Bt);var Va=(P+E|0)+((p&8191)<<13)|0;return P=(N+(p>>>13)|0)+(Va>>>26)|0,Va&=67108863,I[0]=ei,I[1]=Oa,I[2]=Ta,I[3]=Da,I[4]=Ra,I[5]=Ma,I[6]=Oi,I[7]=ka,I[8]=Ua,I[9]=La,I[10]=Fa,I[11]=ja,I[12]=Ms,I[13]=qa,I[14]=Ba,I[15]=mi,I[16]=za,I[17]=Ha,I[18]=Va,P!==0&&(I[19]=P,_.length++),_};Math.imul||(y=g);function C($,d,b){b.negative=d.negative^$.negative,b.length=$.length+d.length;for(var _=0,w=0,v=0;v<b.length-1;v++){var I=w;w=0;for(var P=_&67108863,E=Math.min(v,d.length-1),p=Math.max(0,v-$.length+1);p<=E;p++){var N=v-p,q=$.words[N]|0,H=d.words[p]|0,z=q*H,V=z&67108863;I=I+(z/67108864|0)|0,V=V+P|0,P=V&67108863,I=I+(V>>>26)|0,w+=I>>>26,I&=67108863}b.words[v]=P,_=I,I=w}return _!==0?b.words[v]=_:b.length--,b.strip()}function S($,d,b){var _=new A;return _.mulp($,d,b)}n.prototype.mulTo=function(d,b){var _,w=this.length+d.length;return this.length===10&&d.length===10?_=y(this,d,b):w<63?_=g(this,d,b):w<1024?_=C(this,d,b):_=S(this,d,b),_};function A($,d){this.x=$,this.y=d}A.prototype.makeRBT=function(d){for(var b=new Array(d),_=n.prototype._countBits(d)-1,w=0;w<d;w++)b[w]=this.revBin(w,_,d);return b},A.prototype.revBin=function(d,b,_){if(d===0||d===_-1)return d;for(var w=0,v=0;v<b;v++)w|=(d&1)<<b-v-1,d>>=1;return w},A.prototype.permute=function(d,b,_,w,v,I){for(var P=0;P<I;P++)w[P]=b[d[P]],v[P]=_[d[P]]},A.prototype.transform=function(d,b,_,w,v,I){this.permute(I,d,b,_,w,v);for(var P=1;P<v;P<<=1)for(var E=P<<1,p=Math.cos(2*Math.PI/E),N=Math.sin(2*Math.PI/E),q=0;q<v;q+=E)for(var H=p,z=N,V=0;V<P;V++){var Y=_[q+V],te=w[q+V],ie=_[q+V+P],Z=w[q+V+P],ae=H*ie-z*Z;Z=H*Z+z*ie,ie=ae,_[q+V]=Y+ie,w[q+V]=te+Z,_[q+V+P]=Y-ie,w[q+V+P]=te-Z,V!==E&&(ae=p*H-N*z,z=p*z+N*H,H=ae)}},A.prototype.guessLen13b=function(d,b){var _=Math.max(b,d)|1,w=_&1,v=0;for(_=_/2|0;_;_=_>>>1)v++;return 1<<v+1+w},A.prototype.conjugate=function(d,b,_){if(!(_<=1))for(var w=0;w<_/2;w++){var v=d[w];d[w]=d[_-w-1],d[_-w-1]=v,v=b[w],b[w]=-b[_-w-1],b[_-w-1]=-v}},A.prototype.normalize13b=function(d,b){for(var _=0,w=0;w<b/2;w++){var v=Math.round(d[2*w+1]/b)*8192+Math.round(d[2*w]/b)+_;d[w]=v&67108863,v<67108864?_=0:_=v/67108864|0}return d},A.prototype.convert13b=function(d,b,_,w){for(var v=0,I=0;I<b;I++)v=v+(d[I]|0),_[2*I]=v&8191,v=v>>>13,_[2*I+1]=v&8191,v=v>>>13;for(I=2*b;I<w;++I)_[I]=0;i(v===0),i((v&-8192)===0)},A.prototype.stub=function(d){for(var b=new Array(d),_=0;_<d;_++)b[_]=0;return b},A.prototype.mulp=function(d,b,_){var w=2*this.guessLen13b(d.length,b.length),v=this.makeRBT(w),I=this.stub(w),P=new Array(w),E=new Array(w),p=new Array(w),N=new Array(w),q=new Array(w),H=new Array(w),z=_.words;z.length=w,this.convert13b(d.words,d.length,P,w),this.convert13b(b.words,b.length,N,w),this.transform(P,I,E,p,w,v),this.transform(N,I,q,H,w,v);for(var V=0;V<w;V++){var Y=E[V]*q[V]-p[V]*H[V];p[V]=E[V]*H[V]+p[V]*q[V],E[V]=Y}return this.conjugate(E,p,w),this.transform(E,p,z,I,w,v),this.conjugate(z,I,w),this.normalize13b(z,w),_.negative=d.negative^b.negative,_.length=d.length+b.length,_.strip()},n.prototype.mul=function(d){var b=new n(null);return b.words=new Array(this.length+d.length),this.mulTo(d,b)},n.prototype.mulf=function(d){var b=new n(null);return b.words=new Array(this.length+d.length),S(this,d,b)},n.prototype.imul=function(d){return this.clone().mulTo(d,this)},n.prototype.imuln=function(d){i(typeof d=="number"),i(d<67108864);for(var b=0,_=0;_<this.length;_++){var w=(this.words[_]|0)*d,v=(w&67108863)+(b&67108863);b>>=26,b+=w/67108864|0,b+=v>>>26,this.words[_]=v&67108863}return b!==0&&(this.words[_]=b,this.length++),this.length=d===0?1:this.length,this},n.prototype.muln=function(d){return this.clone().imuln(d)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(d){var b=m(d);if(b.length===0)return new n(1);for(var _=this,w=0;w<b.length&&b[w]===0;w++,_=_.sqr());if(++w<b.length)for(var v=_.sqr();w<b.length;w++,v=v.sqr())b[w]!==0&&(_=_.mul(v));return _},n.prototype.iushln=function(d){i(typeof d=="number"&&d>=0);var b=d%26,_=(d-b)/26,w=67108863>>>26-b<<26-b,v;if(b!==0){var I=0;for(v=0;v<this.length;v++){var P=this.words[v]&w,E=(this.words[v]|0)-P<<b;this.words[v]=E|I,I=P>>>26-b}I&&(this.words[v]=I,this.length++)}if(_!==0){for(v=this.length-1;v>=0;v--)this.words[v+_]=this.words[v];for(v=0;v<_;v++)this.words[v]=0;this.length+=_}return this.strip()},n.prototype.ishln=function(d){return i(this.negative===0),this.iushln(d)},n.prototype.iushrn=function(d,b,_){i(typeof d=="number"&&d>=0);var w;b?w=(b-b%26)/26:w=0;var v=d%26,I=Math.min((d-v)/26,this.length),P=67108863^67108863>>>v<<v,E=_;if(w-=I,w=Math.max(0,w),E){for(var p=0;p<I;p++)E.words[p]=this.words[p];E.length=I}if(I!==0)if(this.length>I)for(this.length-=I,p=0;p<this.length;p++)this.words[p]=this.words[p+I];else this.words[0]=0,this.length=1;var N=0;for(p=this.length-1;p>=0&&(N!==0||p>=w);p--){var q=this.words[p]|0;this.words[p]=N<<26-v|q>>>v,N=q&P}return E&&N!==0&&(E.words[E.length++]=N),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},n.prototype.ishrn=function(d,b,_){return i(this.negative===0),this.iushrn(d,b,_)},n.prototype.shln=function(d){return this.clone().ishln(d)},n.prototype.ushln=function(d){return this.clone().iushln(d)},n.prototype.shrn=function(d){return this.clone().ishrn(d)},n.prototype.ushrn=function(d){return this.clone().iushrn(d)},n.prototype.testn=function(d){i(typeof d=="number"&&d>=0);var b=d%26,_=(d-b)/26,w=1<<b;if(this.length<=_)return!1;var v=this.words[_];return!!(v&w)},n.prototype.imaskn=function(d){i(typeof d=="number"&&d>=0);var b=d%26,_=(d-b)/26;if(i(this.negative===0,"imaskn works only with positive numbers"),this.length<=_)return this;if(b!==0&&_++,this.length=Math.min(_,this.length),b!==0){var w=67108863^67108863>>>b<<b;this.words[this.length-1]&=w}return this.length===0&&(this.words[0]=0,this.length=1),this.strip()},n.prototype.maskn=function(d){return this.clone().imaskn(d)},n.prototype.iaddn=function(d){return i(typeof d=="number"),i(d<67108864),d<0?this.isubn(-d):this.negative!==0?this.length===1&&(this.words[0]|0)<d?(this.words[0]=d-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(d),this.negative=1,this):this._iaddn(d)},n.prototype._iaddn=function(d){this.words[0]+=d;for(var b=0;b<this.length&&this.words[b]>=67108864;b++)this.words[b]-=67108864,b===this.length-1?this.words[b+1]=1:this.words[b+1]++;return this.length=Math.max(this.length,b+1),this},n.prototype.isubn=function(d){if(i(typeof d=="number"),i(d<67108864),d<0)return this.iaddn(-d);if(this.negative!==0)return this.negative=0,this.iaddn(d),this.negative=1,this;if(this.words[0]-=d,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var b=0;b<this.length&&this.words[b]<0;b++)this.words[b]+=67108864,this.words[b+1]-=1;return this.strip()},n.prototype.addn=function(d){return this.clone().iaddn(d)},n.prototype.subn=function(d){return this.clone().isubn(d)},n.prototype.iabs=function(){return this.negative=0,this},n.prototype.abs=function(){return this.clone().iabs()},n.prototype._ishlnsubmul=function(d,b,_){var w=d.length+_,v;this._expand(w);var I,P=0;for(v=0;v<d.length;v++){I=(this.words[v+_]|0)+P;var E=(d.words[v]|0)*b;I-=E&67108863,P=(I>>26)-(E/67108864|0),this.words[v+_]=I&67108863}for(;v<this.length-_;v++)I=(this.words[v+_]|0)+P,P=I>>26,this.words[v+_]=I&67108863;if(P===0)return this.strip();for(i(P===-1),P=0,v=0;v<this.length;v++)I=-(this.words[v]|0)+P,P=I>>26,this.words[v]=I&67108863;return this.negative=1,this.strip()},n.prototype._wordDiv=function(d,b){var _=this.length-d.length,w=this.clone(),v=d,I=v.words[v.length-1]|0,P=this._countBits(I);_=26-P,_!==0&&(v=v.ushln(_),w.iushln(_),I=v.words[v.length-1]|0);var E=w.length-v.length,p;if(b!=="mod"){p=new n(null),p.length=E+1,p.words=new Array(p.length);for(var N=0;N<p.length;N++)p.words[N]=0}var q=w.clone()._ishlnsubmul(v,1,E);q.negative===0&&(w=q,p&&(p.words[E]=1));for(var H=E-1;H>=0;H--){var z=(w.words[v.length+H]|0)*67108864+(w.words[v.length+H-1]|0);for(z=Math.min(z/I|0,67108863),w._ishlnsubmul(v,z,H);w.negative!==0;)z--,w.negative=0,w._ishlnsubmul(v,1,H),w.isZero()||(w.negative^=1);p&&(p.words[H]=z)}return p&&p.strip(),w.strip(),b!=="div"&&_!==0&&w.iushrn(_),{div:p||null,mod:w}},n.prototype.divmod=function(d,b,_){if(i(!d.isZero()),this.isZero())return{div:new n(0),mod:new n(0)};var w,v,I;return this.negative!==0&&d.negative===0?(I=this.neg().divmod(d,b),b!=="mod"&&(w=I.div.neg()),b!=="div"&&(v=I.mod.neg(),_&&v.negative!==0&&v.iadd(d)),{div:w,mod:v}):this.negative===0&&d.negative!==0?(I=this.divmod(d.neg(),b),b!=="mod"&&(w=I.div.neg()),{div:w,mod:I.mod}):(this.negative&d.negative)!==0?(I=this.neg().divmod(d.neg(),b),b!=="div"&&(v=I.mod.neg(),_&&v.negative!==0&&v.isub(d)),{div:I.div,mod:v}):d.length>this.length||this.cmp(d)<0?{div:new n(0),mod:this}:d.length===1?b==="div"?{div:this.divn(d.words[0]),mod:null}:b==="mod"?{div:null,mod:new n(this.modn(d.words[0]))}:{div:this.divn(d.words[0]),mod:new n(this.modn(d.words[0]))}:this._wordDiv(d,b)},n.prototype.div=function(d){return this.divmod(d,"div",!1).div},n.prototype.mod=function(d){return this.divmod(d,"mod",!1).mod},n.prototype.umod=function(d){return this.divmod(d,"mod",!0).mod},n.prototype.divRound=function(d){var b=this.divmod(d);if(b.mod.isZero())return b.div;var _=b.div.negative!==0?b.mod.isub(d):b.mod,w=d.ushrn(1),v=d.andln(1),I=_.cmp(w);return I<0||v===1&&I===0?b.div:b.div.negative!==0?b.div.isubn(1):b.div.iaddn(1)},n.prototype.modn=function(d){i(d<=67108863);for(var b=(1<<26)%d,_=0,w=this.length-1;w>=0;w--)_=(b*_+(this.words[w]|0))%d;return _},n.prototype.idivn=function(d){i(d<=67108863);for(var b=0,_=this.length-1;_>=0;_--){var w=(this.words[_]|0)+b*67108864;this.words[_]=w/d|0,b=w%d}return this.strip()},n.prototype.divn=function(d){return this.clone().idivn(d)},n.prototype.egcd=function(d){i(d.negative===0),i(!d.isZero());var b=this,_=d.clone();b.negative!==0?b=b.umod(d):b=b.clone();for(var w=new n(1),v=new n(0),I=new n(0),P=new n(1),E=0;b.isEven()&&_.isEven();)b.iushrn(1),_.iushrn(1),++E;for(var p=_.clone(),N=b.clone();!b.isZero();){for(var q=0,H=1;(b.words[0]&H)===0&&q<26;++q,H<<=1);if(q>0)for(b.iushrn(q);q-- >0;)(w.isOdd()||v.isOdd())&&(w.iadd(p),v.isub(N)),w.iushrn(1),v.iushrn(1);for(var z=0,V=1;(_.words[0]&V)===0&&z<26;++z,V<<=1);if(z>0)for(_.iushrn(z);z-- >0;)(I.isOdd()||P.isOdd())&&(I.iadd(p),P.isub(N)),I.iushrn(1),P.iushrn(1);b.cmp(_)>=0?(b.isub(_),w.isub(I),v.isub(P)):(_.isub(b),I.isub(w),P.isub(v))}return{a:I,b:P,gcd:_.iushln(E)}},n.prototype._invmp=function(d){i(d.negative===0),i(!d.isZero());var b=this,_=d.clone();b.negative!==0?b=b.umod(d):b=b.clone();for(var w=new n(1),v=new n(0),I=_.clone();b.cmpn(1)>0&&_.cmpn(1)>0;){for(var P=0,E=1;(b.words[0]&E)===0&&P<26;++P,E<<=1);if(P>0)for(b.iushrn(P);P-- >0;)w.isOdd()&&w.iadd(I),w.iushrn(1);for(var p=0,N=1;(_.words[0]&N)===0&&p<26;++p,N<<=1);if(p>0)for(_.iushrn(p);p-- >0;)v.isOdd()&&v.iadd(I),v.iushrn(1);b.cmp(_)>=0?(b.isub(_),w.isub(v)):(_.isub(b),v.isub(w))}var q;return b.cmpn(1)===0?q=w:q=v,q.cmpn(0)<0&&q.iadd(d),q},n.prototype.gcd=function(d){if(this.isZero())return d.abs();if(d.isZero())return this.abs();var b=this.clone(),_=d.clone();b.negative=0,_.negative=0;for(var w=0;b.isEven()&&_.isEven();w++)b.iushrn(1),_.iushrn(1);do{for(;b.isEven();)b.iushrn(1);for(;_.isEven();)_.iushrn(1);var v=b.cmp(_);if(v<0){var I=b;b=_,_=I}else if(v===0||_.cmpn(1)===0)break;b.isub(_)}while(!0);return _.iushln(w)},n.prototype.invm=function(d){return this.egcd(d).a.umod(d)},n.prototype.isEven=function(){return(this.words[0]&1)===0},n.prototype.isOdd=function(){return(this.words[0]&1)===1},n.prototype.andln=function(d){return this.words[0]&d},n.prototype.bincn=function(d){i(typeof d=="number");var b=d%26,_=(d-b)/26,w=1<<b;if(this.length<=_)return this._expand(_+1),this.words[_]|=w,this;for(var v=w,I=_;v!==0&&I<this.length;I++){var P=this.words[I]|0;P+=v,v=P>>>26,P&=67108863,this.words[I]=P}return v!==0&&(this.words[I]=v,this.length++),this},n.prototype.isZero=function(){return this.length===1&&this.words[0]===0},n.prototype.cmpn=function(d){var b=d<0;if(this.negative!==0&&!b)return-1;if(this.negative===0&&b)return 1;this.strip();var _;if(this.length>1)_=1;else{b&&(d=-d),i(d<=67108863,"Number is too big");var w=this.words[0]|0;_=w===d?0:w<d?-1:1}return this.negative!==0?-_|0:_},n.prototype.cmp=function(d){if(this.negative!==0&&d.negative===0)return-1;if(this.negative===0&&d.negative!==0)return 1;var b=this.ucmp(d);return this.negative!==0?-b|0:b},n.prototype.ucmp=function(d){if(this.length>d.length)return 1;if(this.length<d.length)return-1;for(var b=0,_=this.length-1;_>=0;_--){var w=this.words[_]|0,v=d.words[_]|0;if(w!==v){w<v?b=-1:w>v&&(b=1);break}}return b},n.prototype.gtn=function(d){return this.cmpn(d)===1},n.prototype.gt=function(d){return this.cmp(d)===1},n.prototype.gten=function(d){return this.cmpn(d)>=0},n.prototype.gte=function(d){return this.cmp(d)>=0},n.prototype.ltn=function(d){return this.cmpn(d)===-1},n.prototype.lt=function(d){return this.cmp(d)===-1},n.prototype.lten=function(d){return this.cmpn(d)<=0},n.prototype.lte=function(d){return this.cmp(d)<=0},n.prototype.eqn=function(d){return this.cmpn(d)===0},n.prototype.eq=function(d){return this.cmp(d)===0},n.red=function(d){return new R(d)},n.prototype.toRed=function(d){return i(!this.red,"Already a number in reduction context"),i(this.negative===0,"red works only with positives"),d.convertTo(this)._forceRed(d)},n.prototype.fromRed=function(){return i(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(d){return this.red=d,this},n.prototype.forceRed=function(d){return i(!this.red,"Already a number in reduction context"),this._forceRed(d)},n.prototype.redAdd=function(d){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,d)},n.prototype.redIAdd=function(d){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,d)},n.prototype.redSub=function(d){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,d)},n.prototype.redISub=function(d){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,d)},n.prototype.redShl=function(d){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,d)},n.prototype.redMul=function(d){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,d),this.red.mul(this,d)},n.prototype.redIMul=function(d){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,d),this.red.imul(this,d)},n.prototype.redSqr=function(){return i(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return i(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return i(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return i(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return i(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(d){return i(this.red&&!d.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,d)};var D={k256:null,p224:null,p192:null,p25519:null};function O($,d){this.name=$,this.p=new n(d,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}O.prototype._tmp=function(){var d=new n(null);return d.words=new Array(Math.ceil(this.n/13)),d},O.prototype.ireduce=function(d){var b=d,_;do this.split(b,this.tmp),b=this.imulK(b),b=b.iadd(this.tmp),_=b.bitLength();while(_>this.n);var w=_<this.n?-1:b.ucmp(this.p);return w===0?(b.words[0]=0,b.length=1):w>0?b.isub(this.p):b.strip!==void 0?b.strip():b._strip(),b},O.prototype.split=function(d,b){d.iushrn(this.n,0,b)},O.prototype.imulK=function(d){return d.imul(this.k)};function T(){O.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}s(T,O),T.prototype.split=function(d,b){for(var _=4194303,w=Math.min(d.length,9),v=0;v<w;v++)b.words[v]=d.words[v];if(b.length=w,d.length<=9){d.words[0]=0,d.length=1;return}var I=d.words[9];for(b.words[b.length++]=I&_,v=10;v<d.length;v++){var P=d.words[v]|0;d.words[v-10]=(P&_)<<4|I>>>22,I=P}I>>>=22,d.words[v-10]=I,I===0&&d.length>10?d.length-=10:d.length-=9},T.prototype.imulK=function(d){d.words[d.length]=0,d.words[d.length+1]=0,d.length+=2;for(var b=0,_=0;_<d.length;_++){var w=d.words[_]|0;b+=w*977,d.words[_]=b&67108863,b=w*64+(b/67108864|0)}return d.words[d.length-1]===0&&(d.length--,d.words[d.length-1]===0&&d.length--),d};function x(){O.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}s(x,O);function M(){O.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}s(M,O);function U(){O.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}s(U,O),U.prototype.imulK=function(d){for(var b=0,_=0;_<d.length;_++){var w=(d.words[_]|0)*19+b,v=w&67108863;w>>>=26,d.words[_]=v,b=w}return b!==0&&(d.words[d.length++]=b),d},n._prime=function(d){if(D[d])return D[d];var b;if(d==="k256")b=new T;else if(d==="p224")b=new x;else if(d==="p192")b=new M;else if(d==="p25519")b=new U;else throw new Error("Unknown prime "+d);return D[d]=b,b};function R($){if(typeof $=="string"){var d=n._prime($);this.m=d.p,this.prime=d}else i($.gtn(1),"modulus must be greater than 1"),this.m=$,this.prime=null}R.prototype._verify1=function(d){i(d.negative===0,"red works only with positives"),i(d.red,"red works only with red numbers")},R.prototype._verify2=function(d,b){i((d.negative|b.negative)===0,"red works only with positives"),i(d.red&&d.red===b.red,"red works only with red numbers")},R.prototype.imod=function(d){return this.prime?this.prime.ireduce(d)._forceRed(this):d.umod(this.m)._forceRed(this)},R.prototype.neg=function(d){return d.isZero()?d.clone():this.m.sub(d)._forceRed(this)},R.prototype.add=function(d,b){this._verify2(d,b);var _=d.add(b);return _.cmp(this.m)>=0&&_.isub(this.m),_._forceRed(this)},R.prototype.iadd=function(d,b){this._verify2(d,b);var _=d.iadd(b);return _.cmp(this.m)>=0&&_.isub(this.m),_},R.prototype.sub=function(d,b){this._verify2(d,b);var _=d.sub(b);return _.cmpn(0)<0&&_.iadd(this.m),_._forceRed(this)},R.prototype.isub=function(d,b){this._verify2(d,b);var _=d.isub(b);return _.cmpn(0)<0&&_.iadd(this.m),_},R.prototype.shl=function(d,b){return this._verify1(d),this.imod(d.ushln(b))},R.prototype.imul=function(d,b){return this._verify2(d,b),this.imod(d.imul(b))},R.prototype.mul=function(d,b){return this._verify2(d,b),this.imod(d.mul(b))},R.prototype.isqr=function(d){return this.imul(d,d.clone())},R.prototype.sqr=function(d){return this.mul(d,d)},R.prototype.sqrt=function(d){if(d.isZero())return d.clone();var b=this.m.andln(3);if(i(b%2===1),b===3){var _=this.m.add(new n(1)).iushrn(2);return this.pow(d,_)}for(var w=this.m.subn(1),v=0;!w.isZero()&&w.andln(1)===0;)v++,w.iushrn(1);i(!w.isZero());var I=new n(1).toRed(this),P=I.redNeg(),E=this.m.subn(1).iushrn(1),p=this.m.bitLength();for(p=new n(2*p*p).toRed(this);this.pow(p,E).cmp(P)!==0;)p.redIAdd(P);for(var N=this.pow(p,w),q=this.pow(d,w.addn(1).iushrn(1)),H=this.pow(d,w),z=v;H.cmp(I)!==0;){for(var V=H,Y=0;V.cmp(I)!==0;Y++)V=V.redSqr();i(Y<z);var te=this.pow(N,new n(1).iushln(z-Y-1));q=q.redMul(te),N=te.redSqr(),H=H.redMul(N),z=Y}return q},R.prototype.invm=function(d){var b=d._invmp(this.m);return b.negative!==0?(b.negative=0,this.imod(b).redNeg()):this.imod(b)},R.prototype.pow=function(d,b){if(b.isZero())return new n(1).toRed(this);if(b.cmpn(1)===0)return d.clone();var _=4,w=new Array(1<<_);w[0]=new n(1).toRed(this),w[1]=d;for(var v=2;v<w.length;v++)w[v]=this.mul(w[v-1],d);var I=w[0],P=0,E=0,p=b.bitLength()%26;for(p===0&&(p=26),v=b.length-1;v>=0;v--){for(var N=b.words[v],q=p-1;q>=0;q--){var H=N>>q&1;if(I!==w[0]&&(I=this.sqr(I)),H===0&&P===0){E=0;continue}P<<=1,P|=H,E++,!(E!==_&&(v!==0||q!==0))&&(I=this.mul(I,w[P]),E=0,P=0)}p=26}return I},R.prototype.convertTo=function(d){var b=d.umod(this.m);return b===d?b.clone():b},R.prototype.convertFrom=function(d){var b=d.clone();return b.red=null,b},n.mont=function(d){return new L(d)};function L($){R.call(this,$),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new n(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}s(L,R),L.prototype.convertTo=function(d){return this.imod(d.ushln(this.shift))},L.prototype.convertFrom=function(d){var b=this.imod(d.mul(this.rinv));return b.red=null,b},L.prototype.imul=function(d,b){if(d.isZero()||b.isZero())return d.words[0]=0,d.length=1,d;var _=d.imul(b),w=_.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),v=_.isub(w).iushrn(this.shift),I=v;return v.cmp(this.m)>=0?I=v.isub(this.m):v.cmpn(0)<0&&(I=v.iadd(this.m)),I._forceRed(this)},L.prototype.mul=function(d,b){if(d.isZero()||b.isZero())return new n(0)._forceRed(this);var _=d.mul(b),w=_.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),v=_.isub(w).iushrn(this.shift),I=v;return v.cmp(this.m)>=0?I=v.isub(this.m):v.cmpn(0)<0&&(I=v.iadd(this.m)),I._forceRed(this)},L.prototype.invm=function(d){var b=this.imod(d._invmp(this.m).mul(this.r2));return b._forceRed(this)}})(t,BS)})(kl)),kl.exports}var wd,db;function Gn(){if(db)return wd;db=1,wd=t;function t(e,r){if(!e)throw new Error(r||"Assertion failed")}return t.equal=function(r,i,s){if(r!=i)throw new Error(s||"Assertion failed: "+r+" != "+i)},wd}var vd={},fb;function e2(){return fb||(fb=1,(function(t){var e=t;function r(n,o){if(Array.isArray(n))return n.slice();if(!n)return[];var a=[];if(typeof n!="string"){for(var u=0;u<n.length;u++)a[u]=n[u]|0;return a}if(o==="hex"){n=n.replace(/[^a-z0-9]+/ig,""),n.length%2!==0&&(n="0"+n);for(var u=0;u<n.length;u+=2)a.push(parseInt(n[u]+n[u+1],16))}else for(var u=0;u<n.length;u++){var c=n.charCodeAt(u),l=c>>8,h=c&255;l?a.push(l,h):a.push(h)}return a}e.toArray=r;function i(n){return n.length===1?"0"+n:n}e.zero2=i;function s(n){for(var o="",a=0;a<n.length;a++)o+=i(n[a].toString(16));return o}e.toHex=s,e.encode=function(o,a){return a==="hex"?s(o):o}})(vd)),vd}var pb;function xi(){return pb||(pb=1,(function(t){var e=t,r=Ds(),i=Gn(),s=e2();e.assert=i,e.toArray=s.toArray,e.zero2=s.zero2,e.toHex=s.toHex,e.encode=s.encode;function n(l,h,f){var m=new Array(Math.max(l.bitLength(),f)+1),g;for(g=0;g<m.length;g+=1)m[g]=0;var y=1<<h+1,C=l.clone();for(g=0;g<m.length;g++){var S,A=C.andln(y-1);C.isOdd()?(A>(y>>1)-1?S=(y>>1)-A:S=A,C.isubn(S)):S=0,m[g]=S,C.iushrn(1)}return m}e.getNAF=n;function o(l,h){var f=[[],[]];l=l.clone(),h=h.clone();for(var m=0,g=0,y;l.cmpn(-m)>0||h.cmpn(-g)>0;){var C=l.andln(3)+m&3,S=h.andln(3)+g&3;C===3&&(C=-1),S===3&&(S=-1);var A;(C&1)===0?A=0:(y=l.andln(7)+m&7,(y===3||y===5)&&S===2?A=-C:A=C),f[0].push(A);var D;(S&1)===0?D=0:(y=h.andln(7)+g&7,(y===3||y===5)&&C===2?D=-S:D=S),f[1].push(D),2*m===A+1&&(m=1-m),2*g===D+1&&(g=1-g),l.iushrn(1),h.iushrn(1)}return f}e.getJSF=o;function a(l,h,f){var m="_"+h;l.prototype[h]=function(){return this[m]!==void 0?this[m]:this[m]=f.call(this)}}e.cachedProperty=a;function u(l){return typeof l=="string"?e.toArray(l,"hex"):l}e.parseBytes=u;function c(l){return new r(l,"hex","le")}e.intFromLE=c})(yd)),yd}var nl={exports:{}},gb;function t2(){if(gb)return nl.exports;gb=1;var t;nl.exports=function(s){return t||(t=new e(null)),t.generate(s)};function e(i){this.rand=i}if(nl.exports.Rand=e,e.prototype.generate=function(s){return this._rand(s)},e.prototype._rand=function(s){if(this.rand.getBytes)return this.rand.getBytes(s);for(var n=new Uint8Array(s),o=0;o<n.length;o++)n[o]=this.rand.getByte();return n},typeof self=="object")self.crypto&&self.crypto.getRandomValues?e.prototype._rand=function(s){var n=new Uint8Array(s);return self.crypto.getRandomValues(n),n}:self.msCrypto&&self.msCrypto.getRandomValues?e.prototype._rand=function(s){var n=new Uint8Array(s);return self.msCrypto.getRandomValues(n),n}:typeof window=="object"&&(e.prototype._rand=function(){throw new Error("Not implemented yet")});else try{var r=Jv;if(typeof r.randomBytes!="function")throw new Error("Not supported");e.prototype._rand=function(s){return r.randomBytes(s)}}catch{}return nl.exports}var _d={},Ed,bb;function $h(){if(bb)return Ed;bb=1;var t=Ds(),e=xi(),r=e.getNAF,i=e.getJSF,s=e.assert;function n(a,u){this.type=a,this.p=new t(u.p,16),this.red=u.prime?t.red(u.prime):t.mont(this.p),this.zero=new t(0).toRed(this.red),this.one=new t(1).toRed(this.red),this.two=new t(2).toRed(this.red),this.n=u.n&&new t(u.n,16),this.g=u.g&&this.pointFromJSON(u.g,u.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var c=this.n&&this.p.div(this.n);!c||c.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}Ed=n,n.prototype.point=function(){throw new Error("Not implemented")},n.prototype.validate=function(){throw new Error("Not implemented")},n.prototype._fixedNafMul=function(u,c){s(u.precomputed);var l=u._getDoubles(),h=r(c,1,this._bitLength),f=(1<<l.step+1)-(l.step%2===0?2:1);f/=3;var m=[],g,y;for(g=0;g<h.length;g+=l.step){y=0;for(var C=g+l.step-1;C>=g;C--)y=(y<<1)+h[C];m.push(y)}for(var S=this.jpoint(null,null,null),A=this.jpoint(null,null,null),D=f;D>0;D--){for(g=0;g<m.length;g++)y=m[g],y===D?A=A.mixedAdd(l.points[g]):y===-D&&(A=A.mixedAdd(l.points[g].neg()));S=S.add(A)}return S.toP()},n.prototype._wnafMul=function(u,c){var l=4,h=u._getNAFPoints(l);l=h.wnd;for(var f=h.points,m=r(c,l,this._bitLength),g=this.jpoint(null,null,null),y=m.length-1;y>=0;y--){for(var C=0;y>=0&&m[y]===0;y--)C++;if(y>=0&&C++,g=g.dblp(C),y<0)break;var S=m[y];s(S!==0),u.type==="affine"?S>0?g=g.mixedAdd(f[S-1>>1]):g=g.mixedAdd(f[-S-1>>1].neg()):S>0?g=g.add(f[S-1>>1]):g=g.add(f[-S-1>>1].neg())}return u.type==="affine"?g.toP():g},n.prototype._wnafMulAdd=function(u,c,l,h,f){var m=this._wnafT1,g=this._wnafT2,y=this._wnafT3,C=0,S,A,D;for(S=0;S<h;S++){D=c[S];var O=D._getNAFPoints(u);m[S]=O.wnd,g[S]=O.points}for(S=h-1;S>=1;S-=2){var T=S-1,x=S;if(m[T]!==1||m[x]!==1){y[T]=r(l[T],m[T],this._bitLength),y[x]=r(l[x],m[x],this._bitLength),C=Math.max(y[T].length,C),C=Math.max(y[x].length,C);continue}var M=[c[T],null,null,c[x]];c[T].y.cmp(c[x].y)===0?(M[1]=c[T].add(c[x]),M[2]=c[T].toJ().mixedAdd(c[x].neg())):c[T].y.cmp(c[x].y.redNeg())===0?(M[1]=c[T].toJ().mixedAdd(c[x]),M[2]=c[T].add(c[x].neg())):(M[1]=c[T].toJ().mixedAdd(c[x]),M[2]=c[T].toJ().mixedAdd(c[x].neg()));var U=[-3,-1,-5,-7,0,7,5,1,3],R=i(l[T],l[x]);for(C=Math.max(R[0].length,C),y[T]=new Array(C),y[x]=new Array(C),A=0;A<C;A++){var L=R[0][A]|0,$=R[1][A]|0;y[T][A]=U[(L+1)*3+($+1)],y[x][A]=0,g[T]=M}}var d=this.jpoint(null,null,null),b=this._wnafT4;for(S=C;S>=0;S--){for(var _=0;S>=0;){var w=!0;for(A=0;A<h;A++)b[A]=y[A][S]|0,b[A]!==0&&(w=!1);if(!w)break;_++,S--}if(S>=0&&_++,d=d.dblp(_),S<0)break;for(A=0;A<h;A++){var v=b[A];v!==0&&(v>0?D=g[A][v-1>>1]:v<0&&(D=g[A][-v-1>>1].neg()),D.type==="affine"?d=d.mixedAdd(D):d=d.add(D))}}for(S=0;S<h;S++)g[S]=null;return f?d:d.toP()};function o(a,u){this.curve=a,this.type=u,this.precomputed=null}return n.BasePoint=o,o.prototype.eq=function(){throw new Error("Not implemented")},o.prototype.validate=function(){return this.curve.validate(this)},n.prototype.decodePoint=function(u,c){u=e.toArray(u,c);var l=this.p.byteLength();if((u[0]===4||u[0]===6||u[0]===7)&&u.length-1===2*l){u[0]===6?s(u[u.length-1]%2===0):u[0]===7&&s(u[u.length-1]%2===1);var h=this.point(u.slice(1,1+l),u.slice(1+l,1+2*l));return h}else if((u[0]===2||u[0]===3)&&u.length-1===l)return this.pointFromX(u.slice(1,1+l),u[0]===3);throw new Error("Unknown point format")},o.prototype.encodeCompressed=function(u){return this.encode(u,!0)},o.prototype._encode=function(u){var c=this.curve.p.byteLength(),l=this.getX().toArray("be",c);return u?[this.getY().isEven()?2:3].concat(l):[4].concat(l,this.getY().toArray("be",c))},o.prototype.encode=function(u,c){return e.encode(this._encode(c),u)},o.prototype.precompute=function(u){if(this.precomputed)return this;var c={doubles:null,naf:null,beta:null};return c.naf=this._getNAFPoints(8),c.doubles=this._getDoubles(4,u),c.beta=this._getBeta(),this.precomputed=c,this},o.prototype._hasDoubles=function(u){if(!this.precomputed)return!1;var c=this.precomputed.doubles;return c?c.points.length>=Math.ceil((u.bitLength()+1)/c.step):!1},o.prototype._getDoubles=function(u,c){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var l=[this],h=this,f=0;f<c;f+=u){for(var m=0;m<u;m++)h=h.dbl();l.push(h)}return{step:u,points:l}},o.prototype._getNAFPoints=function(u){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var c=[this],l=(1<<u)-1,h=l===1?null:this.dbl(),f=1;f<l;f++)c[f]=c[f-1].add(h);return{wnd:u,points:c}},o.prototype._getBeta=function(){return null},o.prototype.dblp=function(u){for(var c=this,l=0;l<u;l++)c=c.dbl();return c},Ed}var ol={exports:{}},mb;function xh(){return mb||(mb=1,typeof Object.create=="function"?ol.exports=function(e,r){r&&(e.super_=r,e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:ol.exports=function(e,r){if(r){e.super_=r;var i=function(){};i.prototype=r.prototype,e.prototype=new i,e.prototype.constructor=e}}),ol.exports}var Id,yb;function zS(){if(yb)return Id;yb=1;var t=xi(),e=Ds(),r=xh(),i=$h(),s=t.assert;function n(u){i.call(this,"short",u),this.a=new e(u.a,16).toRed(this.red),this.b=new e(u.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=this.a.fromRed().cmpn(0)===0,this.threeA=this.a.fromRed().sub(this.p).cmpn(-3)===0,this.endo=this._getEndomorphism(u),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}r(n,i),Id=n,n.prototype._getEndomorphism=function(c){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var l,h;if(c.beta)l=new e(c.beta,16).toRed(this.red);else{var f=this._getEndoRoots(this.p);l=f[0].cmp(f[1])<0?f[0]:f[1],l=l.toRed(this.red)}if(c.lambda)h=new e(c.lambda,16);else{var m=this._getEndoRoots(this.n);this.g.mul(m[0]).x.cmp(this.g.x.redMul(l))===0?h=m[0]:(h=m[1],s(this.g.mul(h).x.cmp(this.g.x.redMul(l))===0))}var g;return c.basis?g=c.basis.map(function(y){return{a:new e(y.a,16),b:new e(y.b,16)}}):g=this._getEndoBasis(h),{beta:l,lambda:h,basis:g}}},n.prototype._getEndoRoots=function(c){var l=c===this.p?this.red:e.mont(c),h=new e(2).toRed(l).redInvm(),f=h.redNeg(),m=new e(3).toRed(l).redNeg().redSqrt().redMul(h),g=f.redAdd(m).fromRed(),y=f.redSub(m).fromRed();return[g,y]},n.prototype._getEndoBasis=function(c){for(var l=this.n.ushrn(Math.floor(this.n.bitLength()/2)),h=c,f=this.n.clone(),m=new e(1),g=new e(0),y=new e(0),C=new e(1),S,A,D,O,T,x,M,U=0,R,L;h.cmpn(0)!==0;){var $=f.div(h);R=f.sub($.mul(h)),L=y.sub($.mul(m));var d=C.sub($.mul(g));if(!D&&R.cmp(l)<0)S=M.neg(),A=m,D=R.neg(),O=L;else if(D&&++U===2)break;M=R,f=h,h=R,y=m,m=L,C=g,g=d}T=R.neg(),x=L;var b=D.sqr().add(O.sqr()),_=T.sqr().add(x.sqr());return _.cmp(b)>=0&&(T=S,x=A),D.negative&&(D=D.neg(),O=O.neg()),T.negative&&(T=T.neg(),x=x.neg()),[{a:D,b:O},{a:T,b:x}]},n.prototype._endoSplit=function(c){var l=this.endo.basis,h=l[0],f=l[1],m=f.b.mul(c).divRound(this.n),g=h.b.neg().mul(c).divRound(this.n),y=m.mul(h.a),C=g.mul(f.a),S=m.mul(h.b),A=g.mul(f.b),D=c.sub(y).sub(C),O=S.add(A).neg();return{k1:D,k2:O}},n.prototype.pointFromX=function(c,l){c=new e(c,16),c.red||(c=c.toRed(this.red));var h=c.redSqr().redMul(c).redIAdd(c.redMul(this.a)).redIAdd(this.b),f=h.redSqrt();if(f.redSqr().redSub(h).cmp(this.zero)!==0)throw new Error("invalid point");var m=f.fromRed().isOdd();return(l&&!m||!l&&m)&&(f=f.redNeg()),this.point(c,f)},n.prototype.validate=function(c){if(c.inf)return!0;var l=c.x,h=c.y,f=this.a.redMul(l),m=l.redSqr().redMul(l).redIAdd(f).redIAdd(this.b);return h.redSqr().redISub(m).cmpn(0)===0},n.prototype._endoWnafMulAdd=function(c,l,h){for(var f=this._endoWnafT1,m=this._endoWnafT2,g=0;g<c.length;g++){var y=this._endoSplit(l[g]),C=c[g],S=C._getBeta();y.k1.negative&&(y.k1.ineg(),C=C.neg(!0)),y.k2.negative&&(y.k2.ineg(),S=S.neg(!0)),f[g*2]=C,f[g*2+1]=S,m[g*2]=y.k1,m[g*2+1]=y.k2}for(var A=this._wnafMulAdd(1,f,m,g*2,h),D=0;D<g*2;D++)f[D]=null,m[D]=null;return A};function o(u,c,l,h){i.BasePoint.call(this,u,"affine"),c===null&&l===null?(this.x=null,this.y=null,this.inf=!0):(this.x=new e(c,16),this.y=new e(l,16),h&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}r(o,i.BasePoint),n.prototype.point=function(c,l,h){return new o(this,c,l,h)},n.prototype.pointFromJSON=function(c,l){return o.fromJSON(this,c,l)},o.prototype._getBeta=function(){if(this.curve.endo){var c=this.precomputed;if(c&&c.beta)return c.beta;var l=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(c){var h=this.curve,f=function(m){return h.point(m.x.redMul(h.endo.beta),m.y)};c.beta=l,l.precomputed={beta:null,naf:c.naf&&{wnd:c.naf.wnd,points:c.naf.points.map(f)},doubles:c.doubles&&{step:c.doubles.step,points:c.doubles.points.map(f)}}}return l}},o.prototype.toJSON=function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]},o.fromJSON=function(c,l,h){typeof l=="string"&&(l=JSON.parse(l));var f=c.point(l[0],l[1],h);if(!l[2])return f;function m(y){return c.point(y[0],y[1],h)}var g=l[2];return f.precomputed={beta:null,doubles:g.doubles&&{step:g.doubles.step,points:[f].concat(g.doubles.points.map(m))},naf:g.naf&&{wnd:g.naf.wnd,points:[f].concat(g.naf.points.map(m))}},f},o.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"},o.prototype.isInfinity=function(){return this.inf},o.prototype.add=function(c){if(this.inf)return c;if(c.inf)return this;if(this.eq(c))return this.dbl();if(this.neg().eq(c))return this.curve.point(null,null);if(this.x.cmp(c.x)===0)return this.curve.point(null,null);var l=this.y.redSub(c.y);l.cmpn(0)!==0&&(l=l.redMul(this.x.redSub(c.x).redInvm()));var h=l.redSqr().redISub(this.x).redISub(c.x),f=l.redMul(this.x.redSub(h)).redISub(this.y);return this.curve.point(h,f)},o.prototype.dbl=function(){if(this.inf)return this;var c=this.y.redAdd(this.y);if(c.cmpn(0)===0)return this.curve.point(null,null);var l=this.curve.a,h=this.x.redSqr(),f=c.redInvm(),m=h.redAdd(h).redIAdd(h).redIAdd(l).redMul(f),g=m.redSqr().redISub(this.x.redAdd(this.x)),y=m.redMul(this.x.redSub(g)).redISub(this.y);return this.curve.point(g,y)},o.prototype.getX=function(){return this.x.fromRed()},o.prototype.getY=function(){return this.y.fromRed()},o.prototype.mul=function(c){return c=new e(c,16),this.isInfinity()?this:this._hasDoubles(c)?this.curve._fixedNafMul(this,c):this.curve.endo?this.curve._endoWnafMulAdd([this],[c]):this.curve._wnafMul(this,c)},o.prototype.mulAdd=function(c,l,h){var f=[this,l],m=[c,h];return this.curve.endo?this.curve._endoWnafMulAdd(f,m):this.curve._wnafMulAdd(1,f,m,2)},o.prototype.jmulAdd=function(c,l,h){var f=[this,l],m=[c,h];return this.curve.endo?this.curve._endoWnafMulAdd(f,m,!0):this.curve._wnafMulAdd(1,f,m,2,!0)},o.prototype.eq=function(c){return this===c||this.inf===c.inf&&(this.inf||this.x.cmp(c.x)===0&&this.y.cmp(c.y)===0)},o.prototype.neg=function(c){if(this.inf)return this;var l=this.curve.point(this.x,this.y.redNeg());if(c&&this.precomputed){var h=this.precomputed,f=function(m){return m.neg()};l.precomputed={naf:h.naf&&{wnd:h.naf.wnd,points:h.naf.points.map(f)},doubles:h.doubles&&{step:h.doubles.step,points:h.doubles.points.map(f)}}}return l},o.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var c=this.curve.jpoint(this.x,this.y,this.curve.one);return c};function a(u,c,l,h){i.BasePoint.call(this,u,"jacobian"),c===null&&l===null&&h===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new e(0)):(this.x=new e(c,16),this.y=new e(l,16),this.z=new e(h,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}return r(a,i.BasePoint),n.prototype.jpoint=function(c,l,h){return new a(this,c,l,h)},a.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var c=this.z.redInvm(),l=c.redSqr(),h=this.x.redMul(l),f=this.y.redMul(l).redMul(c);return this.curve.point(h,f)},a.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},a.prototype.add=function(c){if(this.isInfinity())return c;if(c.isInfinity())return this;var l=c.z.redSqr(),h=this.z.redSqr(),f=this.x.redMul(l),m=c.x.redMul(h),g=this.y.redMul(l.redMul(c.z)),y=c.y.redMul(h.redMul(this.z)),C=f.redSub(m),S=g.redSub(y);if(C.cmpn(0)===0)return S.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var A=C.redSqr(),D=A.redMul(C),O=f.redMul(A),T=S.redSqr().redIAdd(D).redISub(O).redISub(O),x=S.redMul(O.redISub(T)).redISub(g.redMul(D)),M=this.z.redMul(c.z).redMul(C);return this.curve.jpoint(T,x,M)},a.prototype.mixedAdd=function(c){if(this.isInfinity())return c.toJ();if(c.isInfinity())return this;var l=this.z.redSqr(),h=this.x,f=c.x.redMul(l),m=this.y,g=c.y.redMul(l).redMul(this.z),y=h.redSub(f),C=m.redSub(g);if(y.cmpn(0)===0)return C.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var S=y.redSqr(),A=S.redMul(y),D=h.redMul(S),O=C.redSqr().redIAdd(A).redISub(D).redISub(D),T=C.redMul(D.redISub(O)).redISub(m.redMul(A)),x=this.z.redMul(y);return this.curve.jpoint(O,T,x)},a.prototype.dblp=function(c){if(c===0)return this;if(this.isInfinity())return this;if(!c)return this.dbl();var l;if(this.curve.zeroA||this.curve.threeA){var h=this;for(l=0;l<c;l++)h=h.dbl();return h}var f=this.curve.a,m=this.curve.tinv,g=this.x,y=this.y,C=this.z,S=C.redSqr().redSqr(),A=y.redAdd(y);for(l=0;l<c;l++){var D=g.redSqr(),O=A.redSqr(),T=O.redSqr(),x=D.redAdd(D).redIAdd(D).redIAdd(f.redMul(S)),M=g.redMul(O),U=x.redSqr().redISub(M.redAdd(M)),R=M.redISub(U),L=x.redMul(R);L=L.redIAdd(L).redISub(T);var $=A.redMul(C);l+1<c&&(S=S.redMul(T)),g=U,C=$,A=L}return this.curve.jpoint(g,A.redMul(m),C)},a.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},a.prototype._zeroDbl=function(){var c,l,h;if(this.zOne){var f=this.x.redSqr(),m=this.y.redSqr(),g=m.redSqr(),y=this.x.redAdd(m).redSqr().redISub(f).redISub(g);y=y.redIAdd(y);var C=f.redAdd(f).redIAdd(f),S=C.redSqr().redISub(y).redISub(y),A=g.redIAdd(g);A=A.redIAdd(A),A=A.redIAdd(A),c=S,l=C.redMul(y.redISub(S)).redISub(A),h=this.y.redAdd(this.y)}else{var D=this.x.redSqr(),O=this.y.redSqr(),T=O.redSqr(),x=this.x.redAdd(O).redSqr().redISub(D).redISub(T);x=x.redIAdd(x);var M=D.redAdd(D).redIAdd(D),U=M.redSqr(),R=T.redIAdd(T);R=R.redIAdd(R),R=R.redIAdd(R),c=U.redISub(x).redISub(x),l=M.redMul(x.redISub(c)).redISub(R),h=this.y.redMul(this.z),h=h.redIAdd(h)}return this.curve.jpoint(c,l,h)},a.prototype._threeDbl=function(){var c,l,h;if(this.zOne){var f=this.x.redSqr(),m=this.y.redSqr(),g=m.redSqr(),y=this.x.redAdd(m).redSqr().redISub(f).redISub(g);y=y.redIAdd(y);var C=f.redAdd(f).redIAdd(f).redIAdd(this.curve.a),S=C.redSqr().redISub(y).redISub(y);c=S;var A=g.redIAdd(g);A=A.redIAdd(A),A=A.redIAdd(A),l=C.redMul(y.redISub(S)).redISub(A),h=this.y.redAdd(this.y)}else{var D=this.z.redSqr(),O=this.y.redSqr(),T=this.x.redMul(O),x=this.x.redSub(D).redMul(this.x.redAdd(D));x=x.redAdd(x).redIAdd(x);var M=T.redIAdd(T);M=M.redIAdd(M);var U=M.redAdd(M);c=x.redSqr().redISub(U),h=this.y.redAdd(this.z).redSqr().redISub(O).redISub(D);var R=O.redSqr();R=R.redIAdd(R),R=R.redIAdd(R),R=R.redIAdd(R),l=x.redMul(M.redISub(c)).redISub(R)}return this.curve.jpoint(c,l,h)},a.prototype._dbl=function(){var c=this.curve.a,l=this.x,h=this.y,f=this.z,m=f.redSqr().redSqr(),g=l.redSqr(),y=h.redSqr(),C=g.redAdd(g).redIAdd(g).redIAdd(c.redMul(m)),S=l.redAdd(l);S=S.redIAdd(S);var A=S.redMul(y),D=C.redSqr().redISub(A.redAdd(A)),O=A.redISub(D),T=y.redSqr();T=T.redIAdd(T),T=T.redIAdd(T),T=T.redIAdd(T);var x=C.redMul(O).redISub(T),M=h.redAdd(h).redMul(f);return this.curve.jpoint(D,x,M)},a.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var c=this.x.redSqr(),l=this.y.redSqr(),h=this.z.redSqr(),f=l.redSqr(),m=c.redAdd(c).redIAdd(c),g=m.redSqr(),y=this.x.redAdd(l).redSqr().redISub(c).redISub(f);y=y.redIAdd(y),y=y.redAdd(y).redIAdd(y),y=y.redISub(g);var C=y.redSqr(),S=f.redIAdd(f);S=S.redIAdd(S),S=S.redIAdd(S),S=S.redIAdd(S);var A=m.redIAdd(y).redSqr().redISub(g).redISub(C).redISub(S),D=l.redMul(A);D=D.redIAdd(D),D=D.redIAdd(D);var O=this.x.redMul(C).redISub(D);O=O.redIAdd(O),O=O.redIAdd(O);var T=this.y.redMul(A.redMul(S.redISub(A)).redISub(y.redMul(C)));T=T.redIAdd(T),T=T.redIAdd(T),T=T.redIAdd(T);var x=this.z.redAdd(y).redSqr().redISub(h).redISub(C);return this.curve.jpoint(O,T,x)},a.prototype.mul=function(c,l){return c=new e(c,l),this.curve._wnafMul(this,c)},a.prototype.eq=function(c){if(c.type==="affine")return this.eq(c.toJ());if(this===c)return!0;var l=this.z.redSqr(),h=c.z.redSqr();if(this.x.redMul(h).redISub(c.x.redMul(l)).cmpn(0)!==0)return!1;var f=l.redMul(this.z),m=h.redMul(c.z);return this.y.redMul(m).redISub(c.y.redMul(f)).cmpn(0)===0},a.prototype.eqXToP=function(c){var l=this.z.redSqr(),h=c.toRed(this.curve.red).redMul(l);if(this.x.cmp(h)===0)return!0;for(var f=c.clone(),m=this.curve.redN.redMul(l);;){if(f.iadd(this.curve.n),f.cmp(this.curve.p)>=0)return!1;if(h.redIAdd(m),this.x.cmp(h)===0)return!0}},a.prototype.inspect=function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"},a.prototype.isInfinity=function(){return this.z.cmpn(0)===0},Id}var Ad,wb;function HS(){if(wb)return Ad;wb=1;var t=Ds(),e=xh(),r=$h(),i=xi();function s(o){r.call(this,"mont",o),this.a=new t(o.a,16).toRed(this.red),this.b=new t(o.b,16).toRed(this.red),this.i4=new t(4).toRed(this.red).redInvm(),this.two=new t(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}e(s,r),Ad=s,s.prototype.validate=function(a){var u=a.normalize().x,c=u.redSqr(),l=c.redMul(u).redAdd(c.redMul(this.a)).redAdd(u),h=l.redSqrt();return h.redSqr().cmp(l)===0};function n(o,a,u){r.BasePoint.call(this,o,"projective"),a===null&&u===null?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new t(a,16),this.z=new t(u,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}return e(n,r.BasePoint),s.prototype.decodePoint=function(a,u){return this.point(i.toArray(a,u),1)},s.prototype.point=function(a,u){return new n(this,a,u)},s.prototype.pointFromJSON=function(a){return n.fromJSON(this,a)},n.prototype.precompute=function(){},n.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},n.fromJSON=function(a,u){return new n(a,u[0],u[1]||a.one)},n.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"},n.prototype.isInfinity=function(){return this.z.cmpn(0)===0},n.prototype.dbl=function(){var a=this.x.redAdd(this.z),u=a.redSqr(),c=this.x.redSub(this.z),l=c.redSqr(),h=u.redSub(l),f=u.redMul(l),m=h.redMul(l.redAdd(this.curve.a24.redMul(h)));return this.curve.point(f,m)},n.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},n.prototype.diffAdd=function(a,u){var c=this.x.redAdd(this.z),l=this.x.redSub(this.z),h=a.x.redAdd(a.z),f=a.x.redSub(a.z),m=f.redMul(c),g=h.redMul(l),y=u.z.redMul(m.redAdd(g).redSqr()),C=u.x.redMul(m.redISub(g).redSqr());return this.curve.point(y,C)},n.prototype.mul=function(a){for(var u=a.clone(),c=this,l=this.curve.point(null,null),h=this,f=[];u.cmpn(0)!==0;u.iushrn(1))f.push(u.andln(1));for(var m=f.length-1;m>=0;m--)f[m]===0?(c=c.diffAdd(l,h),l=l.dbl()):(l=c.diffAdd(l,h),c=c.dbl());return l},n.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},n.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},n.prototype.eq=function(a){return this.getX().cmp(a.getX())===0},n.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},n.prototype.getX=function(){return this.normalize(),this.x.fromRed()},Ad}var Sd,vb;function VS(){if(vb)return Sd;vb=1;var t=xi(),e=Ds(),r=xh(),i=$h(),s=t.assert;function n(a){this.twisted=(a.a|0)!==1,this.mOneA=this.twisted&&(a.a|0)===-1,this.extended=this.mOneA,i.call(this,"edwards",a),this.a=new e(a.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new e(a.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new e(a.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),s(!this.twisted||this.c.fromRed().cmpn(1)===0),this.oneC=(a.c|0)===1}r(n,i),Sd=n,n.prototype._mulA=function(u){return this.mOneA?u.redNeg():this.a.redMul(u)},n.prototype._mulC=function(u){return this.oneC?u:this.c.redMul(u)},n.prototype.jpoint=function(u,c,l,h){return this.point(u,c,l,h)},n.prototype.pointFromX=function(u,c){u=new e(u,16),u.red||(u=u.toRed(this.red));var l=u.redSqr(),h=this.c2.redSub(this.a.redMul(l)),f=this.one.redSub(this.c2.redMul(this.d).redMul(l)),m=h.redMul(f.redInvm()),g=m.redSqrt();if(g.redSqr().redSub(m).cmp(this.zero)!==0)throw new Error("invalid point");var y=g.fromRed().isOdd();return(c&&!y||!c&&y)&&(g=g.redNeg()),this.point(u,g)},n.prototype.pointFromY=function(u,c){u=new e(u,16),u.red||(u=u.toRed(this.red));var l=u.redSqr(),h=l.redSub(this.c2),f=l.redMul(this.d).redMul(this.c2).redSub(this.a),m=h.redMul(f.redInvm());if(m.cmp(this.zero)===0){if(c)throw new Error("invalid point");return this.point(this.zero,u)}var g=m.redSqrt();if(g.redSqr().redSub(m).cmp(this.zero)!==0)throw new Error("invalid point");return g.fromRed().isOdd()!==c&&(g=g.redNeg()),this.point(g,u)},n.prototype.validate=function(u){if(u.isInfinity())return!0;u.normalize();var c=u.x.redSqr(),l=u.y.redSqr(),h=c.redMul(this.a).redAdd(l),f=this.c2.redMul(this.one.redAdd(this.d.redMul(c).redMul(l)));return h.cmp(f)===0};function o(a,u,c,l,h){i.BasePoint.call(this,a,"projective"),u===null&&c===null&&l===null?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new e(u,16),this.y=new e(c,16),this.z=l?new e(l,16):this.curve.one,this.t=h&&new e(h,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}return r(o,i.BasePoint),n.prototype.pointFromJSON=function(u){return o.fromJSON(this,u)},n.prototype.point=function(u,c,l,h){return new o(this,u,c,l,h)},o.fromJSON=function(u,c){return new o(u,c[0],c[1],c[2])},o.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"},o.prototype.isInfinity=function(){return this.x.cmpn(0)===0&&(this.y.cmp(this.z)===0||this.zOne&&this.y.cmp(this.curve.c)===0)},o.prototype._extDbl=function(){var u=this.x.redSqr(),c=this.y.redSqr(),l=this.z.redSqr();l=l.redIAdd(l);var h=this.curve._mulA(u),f=this.x.redAdd(this.y).redSqr().redISub(u).redISub(c),m=h.redAdd(c),g=m.redSub(l),y=h.redSub(c),C=f.redMul(g),S=m.redMul(y),A=f.redMul(y),D=g.redMul(m);return this.curve.point(C,S,D,A)},o.prototype._projDbl=function(){var u=this.x.redAdd(this.y).redSqr(),c=this.x.redSqr(),l=this.y.redSqr(),h,f,m,g,y,C;if(this.curve.twisted){g=this.curve._mulA(c);var S=g.redAdd(l);this.zOne?(h=u.redSub(c).redSub(l).redMul(S.redSub(this.curve.two)),f=S.redMul(g.redSub(l)),m=S.redSqr().redSub(S).redSub(S)):(y=this.z.redSqr(),C=S.redSub(y).redISub(y),h=u.redSub(c).redISub(l).redMul(C),f=S.redMul(g.redSub(l)),m=S.redMul(C))}else g=c.redAdd(l),y=this.curve._mulC(this.z).redSqr(),C=g.redSub(y).redSub(y),h=this.curve._mulC(u.redISub(g)).redMul(C),f=this.curve._mulC(g).redMul(c.redISub(l)),m=g.redMul(C);return this.curve.point(h,f,m)},o.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},o.prototype._extAdd=function(u){var c=this.y.redSub(this.x).redMul(u.y.redSub(u.x)),l=this.y.redAdd(this.x).redMul(u.y.redAdd(u.x)),h=this.t.redMul(this.curve.dd).redMul(u.t),f=this.z.redMul(u.z.redAdd(u.z)),m=l.redSub(c),g=f.redSub(h),y=f.redAdd(h),C=l.redAdd(c),S=m.redMul(g),A=y.redMul(C),D=m.redMul(C),O=g.redMul(y);return this.curve.point(S,A,O,D)},o.prototype._projAdd=function(u){var c=this.z.redMul(u.z),l=c.redSqr(),h=this.x.redMul(u.x),f=this.y.redMul(u.y),m=this.curve.d.redMul(h).redMul(f),g=l.redSub(m),y=l.redAdd(m),C=this.x.redAdd(this.y).redMul(u.x.redAdd(u.y)).redISub(h).redISub(f),S=c.redMul(g).redMul(C),A,D;return this.curve.twisted?(A=c.redMul(y).redMul(f.redSub(this.curve._mulA(h))),D=g.redMul(y)):(A=c.redMul(y).redMul(f.redSub(h)),D=this.curve._mulC(g).redMul(y)),this.curve.point(S,A,D)},o.prototype.add=function(u){return this.isInfinity()?u:u.isInfinity()?this:this.curve.extended?this._extAdd(u):this._projAdd(u)},o.prototype.mul=function(u){return this._hasDoubles(u)?this.curve._fixedNafMul(this,u):this.curve._wnafMul(this,u)},o.prototype.mulAdd=function(u,c,l){return this.curve._wnafMulAdd(1,[this,c],[u,l],2,!1)},o.prototype.jmulAdd=function(u,c,l){return this.curve._wnafMulAdd(1,[this,c],[u,l],2,!0)},o.prototype.normalize=function(){if(this.zOne)return this;var u=this.z.redInvm();return this.x=this.x.redMul(u),this.y=this.y.redMul(u),this.t&&(this.t=this.t.redMul(u)),this.z=this.curve.one,this.zOne=!0,this},o.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},o.prototype.getX=function(){return this.normalize(),this.x.fromRed()},o.prototype.getY=function(){return this.normalize(),this.y.fromRed()},o.prototype.eq=function(u){return this===u||this.getX().cmp(u.getX())===0&&this.getY().cmp(u.getY())===0},o.prototype.eqXToP=function(u){var c=u.toRed(this.curve.red).redMul(this.z);if(this.x.cmp(c)===0)return!0;for(var l=u.clone(),h=this.curve.redN.redMul(this.z);;){if(l.iadd(this.curve.n),l.cmp(this.curve.p)>=0)return!1;if(c.redIAdd(h),this.x.cmp(c)===0)return!0}},o.prototype.toP=o.prototype.normalize,o.prototype.mixedAdd=o.prototype.add,Sd}var _b;function r2(){return _b||(_b=1,(function(t){var e=t;e.base=$h(),e.short=zS(),e.mont=HS(),e.edwards=VS()})(_d)),_d}var Cd={},$d={},Ye={},Eb;function ds(){if(Eb)return Ye;Eb=1;var t=Gn(),e=xh();Ye.inherits=e;function r(d,b){return(d.charCodeAt(b)&64512)!==55296||b<0||b+1>=d.length?!1:(d.charCodeAt(b+1)&64512)===56320}function i(d,b){if(Array.isArray(d))return d.slice();if(!d)return[];var _=[];if(typeof d=="string")if(b){if(b==="hex")for(d=d.replace(/[^a-z0-9]+/ig,""),d.length%2!==0&&(d="0"+d),v=0;v<d.length;v+=2)_.push(parseInt(d[v]+d[v+1],16))}else for(var w=0,v=0;v<d.length;v++){var I=d.charCodeAt(v);I<128?_[w++]=I:I<2048?(_[w++]=I>>6|192,_[w++]=I&63|128):r(d,v)?(I=65536+((I&1023)<<10)+(d.charCodeAt(++v)&1023),_[w++]=I>>18|240,_[w++]=I>>12&63|128,_[w++]=I>>6&63|128,_[w++]=I&63|128):(_[w++]=I>>12|224,_[w++]=I>>6&63|128,_[w++]=I&63|128)}else for(v=0;v<d.length;v++)_[v]=d[v]|0;return _}Ye.toArray=i;function s(d){for(var b="",_=0;_<d.length;_++)b+=a(d[_].toString(16));return b}Ye.toHex=s;function n(d){var b=d>>>24|d>>>8&65280|d<<8&16711680|(d&255)<<24;return b>>>0}Ye.htonl=n;function o(d,b){for(var _="",w=0;w<d.length;w++){var v=d[w];b==="little"&&(v=n(v)),_+=u(v.toString(16))}return _}Ye.toHex32=o;function a(d){return d.length===1?"0"+d:d}Ye.zero2=a;function u(d){return d.length===7?"0"+d:d.length===6?"00"+d:d.length===5?"000"+d:d.length===4?"0000"+d:d.length===3?"00000"+d:d.length===2?"000000"+d:d.length===1?"0000000"+d:d}Ye.zero8=u;function c(d,b,_,w){var v=_-b;t(v%4===0);for(var I=new Array(v/4),P=0,E=b;P<I.length;P++,E+=4){var p;w==="big"?p=d[E]<<24|d[E+1]<<16|d[E+2]<<8|d[E+3]:p=d[E+3]<<24|d[E+2]<<16|d[E+1]<<8|d[E],I[P]=p>>>0}return I}Ye.join32=c;function l(d,b){for(var _=new Array(d.length*4),w=0,v=0;w<d.length;w++,v+=4){var I=d[w];b==="big"?(_[v]=I>>>24,_[v+1]=I>>>16&255,_[v+2]=I>>>8&255,_[v+3]=I&255):(_[v+3]=I>>>24,_[v+2]=I>>>16&255,_[v+1]=I>>>8&255,_[v]=I&255)}return _}Ye.split32=l;function h(d,b){return d>>>b|d<<32-b}Ye.rotr32=h;function f(d,b){return d<<b|d>>>32-b}Ye.rotl32=f;function m(d,b){return d+b>>>0}Ye.sum32=m;function g(d,b,_){return d+b+_>>>0}Ye.sum32_3=g;function y(d,b,_,w){return d+b+_+w>>>0}Ye.sum32_4=y;function C(d,b,_,w,v){return d+b+_+w+v>>>0}Ye.sum32_5=C;function S(d,b,_,w){var v=d[b],I=d[b+1],P=w+I>>>0,E=(P<w?1:0)+_+v;d[b]=E>>>0,d[b+1]=P}Ye.sum64=S;function A(d,b,_,w){var v=b+w>>>0,I=(v<b?1:0)+d+_;return I>>>0}Ye.sum64_hi=A;function D(d,b,_,w){var v=b+w;return v>>>0}Ye.sum64_lo=D;function O(d,b,_,w,v,I,P,E){var p=0,N=b;N=N+w>>>0,p+=N<b?1:0,N=N+I>>>0,p+=N<I?1:0,N=N+E>>>0,p+=N<E?1:0;var q=d+_+v+P+p;return q>>>0}Ye.sum64_4_hi=O;function T(d,b,_,w,v,I,P,E){var p=b+w+I+E;return p>>>0}Ye.sum64_4_lo=T;function x(d,b,_,w,v,I,P,E,p,N){var q=0,H=b;H=H+w>>>0,q+=H<b?1:0,H=H+I>>>0,q+=H<I?1:0,H=H+E>>>0,q+=H<E?1:0,H=H+N>>>0,q+=H<N?1:0;var z=d+_+v+P+p+q;return z>>>0}Ye.sum64_5_hi=x;function M(d,b,_,w,v,I,P,E,p,N){var q=b+w+I+E+N;return q>>>0}Ye.sum64_5_lo=M;function U(d,b,_){var w=b<<32-_|d>>>_;return w>>>0}Ye.rotr64_hi=U;function R(d,b,_){var w=d<<32-_|b>>>_;return w>>>0}Ye.rotr64_lo=R;function L(d,b,_){return d>>>_}Ye.shr64_hi=L;function $(d,b,_){var w=d<<32-_|b>>>_;return w>>>0}return Ye.shr64_lo=$,Ye}var xd={},Ib;function Au(){if(Ib)return xd;Ib=1;var t=ds(),e=Gn();function r(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}return xd.BlockHash=r,r.prototype.update=function(s,n){if(s=t.toArray(s,n),this.pending?this.pending=this.pending.concat(s):this.pending=s,this.pendingTotal+=s.length,this.pending.length>=this._delta8){s=this.pending;var o=s.length%this._delta8;this.pending=s.slice(s.length-o,s.length),this.pending.length===0&&(this.pending=null),s=t.join32(s,0,s.length-o,this.endian);for(var a=0;a<s.length;a+=this._delta32)this._update(s,a,a+this._delta32)}return this},r.prototype.digest=function(s){return this.update(this._pad()),e(this.pending===null),this._digest(s)},r.prototype._pad=function(){var s=this.pendingTotal,n=this._delta8,o=n-(s+this.padLength)%n,a=new Array(o+this.padLength);a[0]=128;for(var u=1;u<o;u++)a[u]=0;if(s<<=3,this.endian==="big"){for(var c=8;c<this.padLength;c++)a[u++]=0;a[u++]=0,a[u++]=0,a[u++]=0,a[u++]=0,a[u++]=s>>>24&255,a[u++]=s>>>16&255,a[u++]=s>>>8&255,a[u++]=s&255}else for(a[u++]=s&255,a[u++]=s>>>8&255,a[u++]=s>>>16&255,a[u++]=s>>>24&255,a[u++]=0,a[u++]=0,a[u++]=0,a[u++]=0,c=8;c<this.padLength;c++)a[u++]=0;return a},xd}var yn={},Ji={},Ab;function i2(){if(Ab)return Ji;Ab=1;var t=ds(),e=t.rotr32;function r(l,h,f,m){if(l===0)return i(h,f,m);if(l===1||l===3)return n(h,f,m);if(l===2)return s(h,f,m)}Ji.ft_1=r;function i(l,h,f){return l&h^~l&f}Ji.ch32=i;function s(l,h,f){return l&h^l&f^h&f}Ji.maj32=s;function n(l,h,f){return l^h^f}Ji.p32=n;function o(l){return e(l,2)^e(l,13)^e(l,22)}Ji.s0_256=o;function a(l){return e(l,6)^e(l,11)^e(l,25)}Ji.s1_256=a;function u(l){return e(l,7)^e(l,18)^l>>>3}Ji.g0_256=u;function c(l){return e(l,17)^e(l,19)^l>>>10}return Ji.g1_256=c,Ji}var Pd,Sb;function KS(){if(Sb)return Pd;Sb=1;var t=ds(),e=Au(),r=i2(),i=t.rotl32,s=t.sum32,n=t.sum32_5,o=r.ft_1,a=e.BlockHash,u=[1518500249,1859775393,2400959708,3395469782];function c(){if(!(this instanceof c))return new c;a.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}return t.inherits(c,a),Pd=c,c.blockSize=512,c.outSize=160,c.hmacStrength=80,c.padLength=64,c.prototype._update=function(h,f){for(var m=this.W,g=0;g<16;g++)m[g]=h[f+g];for(;g<m.length;g++)m[g]=i(m[g-3]^m[g-8]^m[g-14]^m[g-16],1);var y=this.h[0],C=this.h[1],S=this.h[2],A=this.h[3],D=this.h[4];for(g=0;g<m.length;g++){var O=~~(g/20),T=n(i(y,5),o(O,C,S,A),D,m[g],u[O]);D=A,A=S,S=i(C,30),C=y,y=T}this.h[0]=s(this.h[0],y),this.h[1]=s(this.h[1],C),this.h[2]=s(this.h[2],S),this.h[3]=s(this.h[3],A),this.h[4]=s(this.h[4],D)},c.prototype._digest=function(h){return h==="hex"?t.toHex32(this.h,"big"):t.split32(this.h,"big")},Pd}var Nd,Cb;function s2(){if(Cb)return Nd;Cb=1;var t=ds(),e=Au(),r=i2(),i=Gn(),s=t.sum32,n=t.sum32_4,o=t.sum32_5,a=r.ch32,u=r.maj32,c=r.s0_256,l=r.s1_256,h=r.g0_256,f=r.g1_256,m=e.BlockHash,g=[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];function y(){if(!(this instanceof y))return new y;m.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=g,this.W=new Array(64)}return t.inherits(y,m),Nd=y,y.blockSize=512,y.outSize=256,y.hmacStrength=192,y.padLength=64,y.prototype._update=function(S,A){for(var D=this.W,O=0;O<16;O++)D[O]=S[A+O];for(;O<D.length;O++)D[O]=n(f(D[O-2]),D[O-7],h(D[O-15]),D[O-16]);var T=this.h[0],x=this.h[1],M=this.h[2],U=this.h[3],R=this.h[4],L=this.h[5],$=this.h[6],d=this.h[7];for(i(this.k.length===D.length),O=0;O<D.length;O++){var b=o(d,l(R),a(R,L,$),this.k[O],D[O]),_=s(c(T),u(T,x,M));d=$,$=L,L=R,R=s(U,b),U=M,M=x,x=T,T=s(b,_)}this.h[0]=s(this.h[0],T),this.h[1]=s(this.h[1],x),this.h[2]=s(this.h[2],M),this.h[3]=s(this.h[3],U),this.h[4]=s(this.h[4],R),this.h[5]=s(this.h[5],L),this.h[6]=s(this.h[6],$),this.h[7]=s(this.h[7],d)},y.prototype._digest=function(S){return S==="hex"?t.toHex32(this.h,"big"):t.split32(this.h,"big")},Nd}var Od,$b;function WS(){if($b)return Od;$b=1;var t=ds(),e=s2();function r(){if(!(this instanceof r))return new r;e.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}return t.inherits(r,e),Od=r,r.blockSize=512,r.outSize=224,r.hmacStrength=192,r.padLength=64,r.prototype._digest=function(s){return s==="hex"?t.toHex32(this.h.slice(0,7),"big"):t.split32(this.h.slice(0,7),"big")},Od}var Td,xb;function n2(){if(xb)return Td;xb=1;var t=ds(),e=Au(),r=Gn(),i=t.rotr64_hi,s=t.rotr64_lo,n=t.shr64_hi,o=t.shr64_lo,a=t.sum64,u=t.sum64_hi,c=t.sum64_lo,l=t.sum64_4_hi,h=t.sum64_4_lo,f=t.sum64_5_hi,m=t.sum64_5_lo,g=e.BlockHash,y=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function C(){if(!(this instanceof C))return new C;g.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=y,this.W=new Array(160)}t.inherits(C,g),Td=C,C.blockSize=1024,C.outSize=512,C.hmacStrength=192,C.padLength=128,C.prototype._prepareBlock=function(_,w){for(var v=this.W,I=0;I<32;I++)v[I]=_[w+I];for(;I<v.length;I+=2){var P=$(v[I-4],v[I-3]),E=d(v[I-4],v[I-3]),p=v[I-14],N=v[I-13],q=R(v[I-30],v[I-29]),H=L(v[I-30],v[I-29]),z=v[I-32],V=v[I-31];v[I]=l(P,E,p,N,q,H,z,V),v[I+1]=h(P,E,p,N,q,H,z,V)}},C.prototype._update=function(_,w){this._prepareBlock(_,w);var v=this.W,I=this.h[0],P=this.h[1],E=this.h[2],p=this.h[3],N=this.h[4],q=this.h[5],H=this.h[6],z=this.h[7],V=this.h[8],Y=this.h[9],te=this.h[10],ie=this.h[11],Z=this.h[12],ae=this.h[13],ht=this.h[14],ge=this.h[15];r(this.k.length===v.length);for(var ye=0;ye<v.length;ye+=2){var Dt=ht,Ie=ge,Te=M(V,Y),bi=U(V,Y),Ze=S(V,Y,te,ie,Z),Ke=A(V,Y,te,ie,Z,ae),Vi=this.k[ye],qe=this.k[ye+1],We=v[ye],Ki=v[ye+1],De=f(Dt,Ie,Te,bi,Ze,Ke,Vi,qe,We,Ki),Re=m(Dt,Ie,Te,bi,Ze,Ke,Vi,qe,We,Ki);Dt=T(I,P),Ie=x(I,P),Te=D(I,P,E,p,N),bi=O(I,P,E,p,N,q);var Wi=u(Dt,Ie,Te,bi),Me=c(Dt,Ie,Te,bi);ht=Z,ge=ae,Z=te,ae=ie,te=V,ie=Y,V=u(H,z,De,Re),Y=c(z,z,De,Re),H=N,z=q,N=E,q=p,E=I,p=P,I=u(De,Re,Wi,Me),P=c(De,Re,Wi,Me)}a(this.h,0,I,P),a(this.h,2,E,p),a(this.h,4,N,q),a(this.h,6,H,z),a(this.h,8,V,Y),a(this.h,10,te,ie),a(this.h,12,Z,ae),a(this.h,14,ht,ge)},C.prototype._digest=function(_){return _==="hex"?t.toHex32(this.h,"big"):t.split32(this.h,"big")};function S(b,_,w,v,I){var P=b&w^~b&I;return P<0&&(P+=4294967296),P}function A(b,_,w,v,I,P){var E=_&v^~_&P;return E<0&&(E+=4294967296),E}function D(b,_,w,v,I){var P=b&w^b&I^w&I;return P<0&&(P+=4294967296),P}function O(b,_,w,v,I,P){var E=_&v^_&P^v&P;return E<0&&(E+=4294967296),E}function T(b,_){var w=i(b,_,28),v=i(_,b,2),I=i(_,b,7),P=w^v^I;return P<0&&(P+=4294967296),P}function x(b,_){var w=s(b,_,28),v=s(_,b,2),I=s(_,b,7),P=w^v^I;return P<0&&(P+=4294967296),P}function M(b,_){var w=i(b,_,14),v=i(b,_,18),I=i(_,b,9),P=w^v^I;return P<0&&(P+=4294967296),P}function U(b,_){var w=s(b,_,14),v=s(b,_,18),I=s(_,b,9),P=w^v^I;return P<0&&(P+=4294967296),P}function R(b,_){var w=i(b,_,1),v=i(b,_,8),I=n(b,_,7),P=w^v^I;return P<0&&(P+=4294967296),P}function L(b,_){var w=s(b,_,1),v=s(b,_,8),I=o(b,_,7),P=w^v^I;return P<0&&(P+=4294967296),P}function $(b,_){var w=i(b,_,19),v=i(_,b,29),I=n(b,_,6),P=w^v^I;return P<0&&(P+=4294967296),P}function d(b,_){var w=s(b,_,19),v=s(_,b,29),I=o(b,_,6),P=w^v^I;return P<0&&(P+=4294967296),P}return Td}var Dd,Pb;function GS(){if(Pb)return Dd;Pb=1;var t=ds(),e=n2();function r(){if(!(this instanceof r))return new r;e.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}return t.inherits(r,e),Dd=r,r.blockSize=1024,r.outSize=384,r.hmacStrength=192,r.padLength=128,r.prototype._digest=function(s){return s==="hex"?t.toHex32(this.h.slice(0,12),"big"):t.split32(this.h.slice(0,12),"big")},Dd}var Nb;function YS(){return Nb||(Nb=1,yn.sha1=KS(),yn.sha224=WS(),yn.sha256=s2(),yn.sha384=GS(),yn.sha512=n2()),yn}var Rd={},Ob;function JS(){if(Ob)return Rd;Ob=1;var t=ds(),e=Au(),r=t.rotl32,i=t.sum32,s=t.sum32_3,n=t.sum32_4,o=e.BlockHash;function a(){if(!(this instanceof a))return new a;o.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}t.inherits(a,o),Rd.ripemd160=a,a.blockSize=512,a.outSize=160,a.hmacStrength=192,a.padLength=64,a.prototype._update=function(C,S){for(var A=this.h[0],D=this.h[1],O=this.h[2],T=this.h[3],x=this.h[4],M=A,U=D,R=O,L=T,$=x,d=0;d<80;d++){var b=i(r(n(A,u(d,D,O,T),C[h[d]+S],c(d)),m[d]),x);A=x,x=T,T=r(O,10),O=D,D=b,b=i(r(n(M,u(79-d,U,R,L),C[f[d]+S],l(d)),g[d]),$),M=$,$=L,L=r(R,10),R=U,U=b}b=s(this.h[1],O,L),this.h[1]=s(this.h[2],T,$),this.h[2]=s(this.h[3],x,M),this.h[3]=s(this.h[4],A,U),this.h[4]=s(this.h[0],D,R),this.h[0]=b},a.prototype._digest=function(C){return C==="hex"?t.toHex32(this.h,"little"):t.split32(this.h,"little")};function u(y,C,S,A){return y<=15?C^S^A:y<=31?C&S|~C&A:y<=47?(C|~S)^A:y<=63?C&A|S&~A:C^(S|~A)}function c(y){return y<=15?0:y<=31?1518500249:y<=47?1859775393:y<=63?2400959708:2840853838}function l(y){return y<=15?1352829926:y<=31?1548603684:y<=47?1836072691:y<=63?2053994217:0}var h=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],f=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],m=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],g=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11];return Rd}var Md,Tb;function QS(){if(Tb)return Md;Tb=1;var t=ds(),e=Gn();function r(i,s,n){if(!(this instanceof r))return new r(i,s,n);this.Hash=i,this.blockSize=i.blockSize/8,this.outSize=i.outSize/8,this.inner=null,this.outer=null,this._init(t.toArray(s,n))}return Md=r,r.prototype._init=function(s){s.length>this.blockSize&&(s=new this.Hash().update(s).digest()),e(s.length<=this.blockSize);for(var n=s.length;n<this.blockSize;n++)s.push(0);for(n=0;n<s.length;n++)s[n]^=54;for(this.inner=new this.Hash().update(s),n=0;n<s.length;n++)s[n]^=106;this.outer=new this.Hash().update(s)},r.prototype.update=function(s,n){return this.inner.update(s,n),this},r.prototype.digest=function(s){return this.outer.update(this.inner.digest()),this.outer.digest(s)},Md}var Db;function fg(){return Db||(Db=1,(function(t){var e=t;e.utils=ds(),e.common=Au(),e.sha=YS(),e.ripemd=JS(),e.hmac=QS(),e.sha1=e.sha.sha1,e.sha256=e.sha.sha256,e.sha224=e.sha.sha224,e.sha384=e.sha.sha384,e.sha512=e.sha.sha512,e.ripemd160=e.ripemd.ripemd160})($d)),$d}var kd,Rb;function XS(){return Rb||(Rb=1,kd={doubles:{step:4,points:[["e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a","f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821"],["8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508","11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf"],["175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739","d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695"],["363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640","4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9"],["8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c","4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36"],["723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda","96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f"],["eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa","5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999"],["100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0","cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09"],["e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d","9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d"],["feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d","e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088"],["da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1","9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d"],["53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0","5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8"],["8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047","10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a"],["385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862","283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453"],["6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7","7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160"],["3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd","56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0"],["85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83","7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6"],["948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a","53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589"],["6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8","bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17"],["e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d","4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda"],["e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725","7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd"],["213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754","4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2"],["4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c","17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6"],["fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6","6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f"],["76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39","c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01"],["c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891","893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3"],["d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b","febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f"],["b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03","2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7"],["e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d","eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78"],["a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070","7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1"],["90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4","e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150"],["8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da","662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82"],["e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11","1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc"],["8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e","efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b"],["e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41","2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51"],["b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef","67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45"],["d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8","db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120"],["324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d","648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84"],["4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96","35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d"],["9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd","ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d"],["6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5","9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8"],["a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266","40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8"],["7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71","34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac"],["928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac","c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f"],["85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751","1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962"],["ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e","493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907"],["827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241","c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec"],["eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3","be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d"],["e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f","4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414"],["1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19","aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd"],["146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be","b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0"],["fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9","6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811"],["da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2","8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1"],["a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13","7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c"],["174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c","ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73"],["959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba","2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd"],["d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151","e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405"],["64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073","d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589"],["8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458","38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e"],["13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b","69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27"],["bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366","d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1"],["8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa","40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482"],["8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0","620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945"],["dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787","7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573"],["f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e","ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82"]]},naf:{wnd:7,points:[["f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9","388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672"],["2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4","d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6"],["5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc","6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da"],["acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe","cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37"],["774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb","d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b"],["f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8","ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81"],["d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e","581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58"],["defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34","4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77"],["2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c","85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a"],["352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5","321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c"],["2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f","2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67"],["9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714","73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402"],["daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729","a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55"],["c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db","2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482"],["6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4","e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82"],["1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5","b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396"],["605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479","2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49"],["62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d","80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf"],["80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f","1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a"],["7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb","d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7"],["d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9","eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933"],["49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963","758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a"],["77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74","958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6"],["f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530","e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37"],["463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b","5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e"],["f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247","cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6"],["caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1","cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476"],["2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120","4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40"],["7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435","91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61"],["754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18","673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683"],["e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8","59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5"],["186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb","3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b"],["df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f","55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417"],["5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143","efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868"],["290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba","e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a"],["af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45","f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6"],["766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a","744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996"],["59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e","c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e"],["f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8","e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d"],["7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c","30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2"],["948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519","e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e"],["7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab","100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437"],["3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca","ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311"],["d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf","8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4"],["1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610","68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575"],["733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4","f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d"],["15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c","d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d"],["a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940","edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629"],["e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980","a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06"],["311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3","66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374"],["34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf","9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee"],["f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63","4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1"],["d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448","fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b"],["32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf","5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661"],["7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5","8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6"],["ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6","8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e"],["16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5","5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d"],["eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99","f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc"],["78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51","f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4"],["494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5","42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c"],["a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5","204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b"],["c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997","4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913"],["841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881","73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154"],["5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5","39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865"],["36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66","d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc"],["336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726","ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224"],["8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede","6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e"],["1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94","60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6"],["85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31","3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511"],["29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51","b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b"],["a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252","ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2"],["4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5","cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c"],["d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b","6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3"],["ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4","322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d"],["af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f","6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700"],["e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889","2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4"],["591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246","b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196"],["11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984","998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4"],["3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a","b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257"],["cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030","bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13"],["c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197","6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096"],["c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593","c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38"],["a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef","21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f"],["347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38","60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448"],["da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a","49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a"],["c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111","5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4"],["4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502","7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437"],["3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea","be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7"],["cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26","8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d"],["b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986","39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a"],["d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e","62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54"],["48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4","25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77"],["dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda","ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517"],["6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859","cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10"],["e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f","f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125"],["eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c","6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e"],["13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942","fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1"],["ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a","1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2"],["b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80","5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423"],["ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d","438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8"],["8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1","cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758"],["52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63","c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375"],["e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352","6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d"],["7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193","ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec"],["5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00","9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0"],["32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58","ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c"],["e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7","d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4"],["8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8","c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f"],["4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e","67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649"],["3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d","cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826"],["674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b","299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5"],["d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f","f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87"],["30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6","462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b"],["be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297","62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc"],["93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a","7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c"],["b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c","ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f"],["d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52","4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a"],["d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb","bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46"],["463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065","bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f"],["7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917","603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03"],["74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9","cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08"],["30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3","553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8"],["9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57","712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373"],["176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66","ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3"],["75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8","9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8"],["809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721","9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1"],["1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180","4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9"]]}}),kd}var Mb;function pg(){return Mb||(Mb=1,(function(t){var e=t,r=fg(),i=r2(),s=xi(),n=s.assert;function o(c){c.type==="short"?this.curve=new i.short(c):c.type==="edwards"?this.curve=new i.edwards(c):this.curve=new i.mont(c),this.g=this.curve.g,this.n=this.curve.n,this.hash=c.hash,n(this.g.validate(),"Invalid curve"),n(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}e.PresetCurve=o;function a(c,l){Object.defineProperty(e,c,{configurable:!0,enumerable:!0,get:function(){var h=new o(l);return Object.defineProperty(e,c,{configurable:!0,enumerable:!0,value:h}),h}})}a("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:r.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),a("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:r.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),a("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:r.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),a("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:r.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),a("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:r.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),a("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:r.sha256,gRed:!1,g:["9"]}),a("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:r.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var u;try{u=XS()}catch{u=void 0}a("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:r.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",u]})})(Cd)),Cd}var Ud,kb;function ZS(){if(kb)return Ud;kb=1;var t=fg(),e=e2(),r=Gn();function i(s){if(!(this instanceof i))return new i(s);this.hash=s.hash,this.predResist=!!s.predResist,this.outLen=this.hash.outSize,this.minEntropy=s.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var n=e.toArray(s.entropy,s.entropyEnc||"hex"),o=e.toArray(s.nonce,s.nonceEnc||"hex"),a=e.toArray(s.pers,s.persEnc||"hex");r(n.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(n,o,a)}return Ud=i,i.prototype._init=function(n,o,a){var u=n.concat(o).concat(a);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var c=0;c<this.V.length;c++)this.K[c]=0,this.V[c]=1;this._update(u),this._reseed=1,this.reseedInterval=281474976710656},i.prototype._hmac=function(){return new t.hmac(this.hash,this.K)},i.prototype._update=function(n){var o=this._hmac().update(this.V).update([0]);n&&(o=o.update(n)),this.K=o.digest(),this.V=this._hmac().update(this.V).digest(),n&&(this.K=this._hmac().update(this.V).update([1]).update(n).digest(),this.V=this._hmac().update(this.V).digest())},i.prototype.reseed=function(n,o,a,u){typeof o!="string"&&(u=a,a=o,o=null),n=e.toArray(n,o),a=e.toArray(a,u),r(n.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(n.concat(a||[])),this._reseed=1},i.prototype.generate=function(n,o,a,u){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof o!="string"&&(u=a,a=o,o=null),a&&(a=e.toArray(a,u||"hex"),this._update(a));for(var c=[];c.length<n;)this.V=this._hmac().update(this.V).digest(),c=c.concat(this.V);var l=c.slice(0,n);return this._update(a),this._reseed++,e.encode(l,o)},Ud}var Ld,Ub;function eC(){if(Ub)return Ld;Ub=1;var t=Ds(),e=xi(),r=e.assert;function i(s,n){this.ec=s,this.priv=null,this.pub=null,n.priv&&this._importPrivate(n.priv,n.privEnc),n.pub&&this._importPublic(n.pub,n.pubEnc)}return Ld=i,i.fromPublic=function(n,o,a){return o instanceof i?o:new i(n,{pub:o,pubEnc:a})},i.fromPrivate=function(n,o,a){return o instanceof i?o:new i(n,{priv:o,privEnc:a})},i.prototype.validate=function(){var n=this.getPublic();return n.isInfinity()?{result:!1,reason:"Invalid public key"}:n.validate()?n.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},i.prototype.getPublic=function(n,o){return typeof n=="string"&&(o=n,n=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),o?this.pub.encode(o,n):this.pub},i.prototype.getPrivate=function(n){return n==="hex"?this.priv.toString(16,2):this.priv},i.prototype._importPrivate=function(n,o){this.priv=new t(n,o||16),this.priv=this.priv.umod(this.ec.curve.n)},i.prototype._importPublic=function(n,o){if(n.x||n.y){this.ec.curve.type==="mont"?r(n.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&r(n.x&&n.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point(n.x,n.y);return}this.pub=this.ec.curve.decodePoint(n,o)},i.prototype.derive=function(n){return n.validate()||r(n.validate(),"public point not validated"),n.mul(this.priv).getX()},i.prototype.sign=function(n,o,a){return this.ec.sign(n,this,o,a)},i.prototype.verify=function(n,o,a){return this.ec.verify(n,o,this,void 0,a)},i.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"},Ld}var Fd,Lb;function tC(){if(Lb)return Fd;Lb=1;var t=Ds(),e=xi(),r=e.assert;function i(u,c){if(u instanceof i)return u;this._importDER(u,c)||(r(u.r&&u.s,"Signature without r or s"),this.r=new t(u.r,16),this.s=new t(u.s,16),u.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=u.recoveryParam)}Fd=i;function s(){this.place=0}function n(u,c){var l=u[c.place++];if(!(l&128))return l;var h=l&15;if(h===0||h>4||u[c.place]===0)return!1;for(var f=0,m=0,g=c.place;m<h;m++,g++)f<<=8,f|=u[g],f>>>=0;return f<=127?!1:(c.place=g,f)}function o(u){for(var c=0,l=u.length-1;!u[c]&&!(u[c+1]&128)&&c<l;)c++;return c===0?u:u.slice(c)}i.prototype._importDER=function(c,l){c=e.toArray(c,l);var h=new s;if(c[h.place++]!==48)return!1;var f=n(c,h);if(f===!1||f+h.place!==c.length||c[h.place++]!==2)return!1;var m=n(c,h);if(m===!1||(c[h.place]&128)!==0)return!1;var g=c.slice(h.place,m+h.place);if(h.place+=m,c[h.place++]!==2)return!1;var y=n(c,h);if(y===!1||c.length!==y+h.place||(c[h.place]&128)!==0)return!1;var C=c.slice(h.place,y+h.place);if(g[0]===0)if(g[1]&128)g=g.slice(1);else return!1;if(C[0]===0)if(C[1]&128)C=C.slice(1);else return!1;return this.r=new t(g),this.s=new t(C),this.recoveryParam=null,!0};function a(u,c){if(c<128){u.push(c);return}var l=1+(Math.log(c)/Math.LN2>>>3);for(u.push(l|128);--l;)u.push(c>>>(l<<3)&255);u.push(c)}return i.prototype.toDER=function(c){var l=this.r.toArray(),h=this.s.toArray();for(l[0]&128&&(l=[0].concat(l)),h[0]&128&&(h=[0].concat(h)),l=o(l),h=o(h);!h[0]&&!(h[1]&128);)h=h.slice(1);var f=[2];a(f,l.length),f=f.concat(l),f.push(2),a(f,h.length);var m=f.concat(h),g=[48];return a(g,m.length),g=g.concat(m),e.encode(g,c)},Fd}var jd,Fb;function rC(){if(Fb)return jd;Fb=1;var t=Ds(),e=ZS(),r=xi(),i=pg(),s=t2(),n=r.assert,o=eC(),a=tC();function u(c){if(!(this instanceof u))return new u(c);typeof c=="string"&&(n(Object.prototype.hasOwnProperty.call(i,c),"Unknown curve "+c),c=i[c]),c instanceof i.PresetCurve&&(c={curve:c}),this.curve=c.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=c.curve.g,this.g.precompute(c.curve.n.bitLength()+1),this.hash=c.hash||c.curve.hash}return jd=u,u.prototype.keyPair=function(l){return new o(this,l)},u.prototype.keyFromPrivate=function(l,h){return o.fromPrivate(this,l,h)},u.prototype.keyFromPublic=function(l,h){return o.fromPublic(this,l,h)},u.prototype.genKeyPair=function(l){l||(l={});for(var h=new e({hash:this.hash,pers:l.pers,persEnc:l.persEnc||"utf8",entropy:l.entropy||s(this.hash.hmacStrength),entropyEnc:l.entropy&&l.entropyEnc||"utf8",nonce:this.n.toArray()}),f=this.n.byteLength(),m=this.n.sub(new t(2));;){var g=new t(h.generate(f));if(!(g.cmp(m)>0))return g.iaddn(1),this.keyFromPrivate(g)}},u.prototype._truncateToN=function(l,h,f){var m;if(t.isBN(l)||typeof l=="number")l=new t(l,16),m=l.byteLength();else if(typeof l=="object")m=l.length,l=new t(l,16);else{var g=l.toString();m=g.length+1>>>1,l=new t(g,16)}typeof f!="number"&&(f=m*8);var y=f-this.n.bitLength();return y>0&&(l=l.ushrn(y)),!h&&l.cmp(this.n)>=0?l.sub(this.n):l},u.prototype.sign=function(l,h,f,m){if(typeof f=="object"&&(m=f,f=null),m||(m={}),typeof l!="string"&&typeof l!="number"&&!t.isBN(l)){n(typeof l=="object"&&l&&typeof l.length=="number","Expected message to be an array-like, a hex string, or a BN instance"),n(l.length>>>0===l.length);for(var g=0;g<l.length;g++)n((l[g]&255)===l[g])}h=this.keyFromPrivate(h,f),l=this._truncateToN(l,!1,m.msgBitLength),n(!l.isNeg(),"Can not sign a negative message");var y=this.n.byteLength(),C=h.getPrivate().toArray("be",y),S=l.toArray("be",y);n(new t(S).eq(l),"Can not sign message");for(var A=new e({hash:this.hash,entropy:C,nonce:S,pers:m.pers,persEnc:m.persEnc||"utf8"}),D=this.n.sub(new t(1)),O=0;;O++){var T=m.k?m.k(O):new t(A.generate(this.n.byteLength()));if(T=this._truncateToN(T,!0),!(T.cmpn(1)<=0||T.cmp(D)>=0)){var x=this.g.mul(T);if(!x.isInfinity()){var M=x.getX(),U=M.umod(this.n);if(U.cmpn(0)!==0){var R=T.invm(this.n).mul(U.mul(h.getPrivate()).iadd(l));if(R=R.umod(this.n),R.cmpn(0)!==0){var L=(x.getY().isOdd()?1:0)|(M.cmp(U)!==0?2:0);return m.canonical&&R.cmp(this.nh)>0&&(R=this.n.sub(R),L^=1),new a({r:U,s:R,recoveryParam:L})}}}}}},u.prototype.verify=function(l,h,f,m,g){g||(g={}),l=this._truncateToN(l,!1,g.msgBitLength),f=this.keyFromPublic(f,m),h=new a(h,"hex");var y=h.r,C=h.s;if(y.cmpn(1)<0||y.cmp(this.n)>=0||C.cmpn(1)<0||C.cmp(this.n)>=0)return!1;var S=C.invm(this.n),A=S.mul(l).umod(this.n),D=S.mul(y).umod(this.n),O;return this.curve._maxwellTrick?(O=this.g.jmulAdd(A,f.getPublic(),D),O.isInfinity()?!1:O.eqXToP(y)):(O=this.g.mulAdd(A,f.getPublic(),D),O.isInfinity()?!1:O.getX().umod(this.n).cmp(y)===0)},u.prototype.recoverPubKey=function(c,l,h,f){n((3&h)===h,"The recovery param is more than two bits"),l=new a(l,f);var m=this.n,g=new t(c),y=l.r,C=l.s,S=h&1,A=h>>1;if(y.cmp(this.curve.p.umod(this.curve.n))>=0&&A)throw new Error("Unable to find sencond key candinate");A?y=this.curve.pointFromX(y.add(this.curve.n),S):y=this.curve.pointFromX(y,S);var D=l.r.invm(m),O=m.sub(g).mul(D).umod(m),T=C.mul(D).umod(m);return this.g.mulAdd(O,y,T)},u.prototype.getKeyRecoveryParam=function(c,l,h,f){if(l=new a(l,f),l.recoveryParam!==null)return l.recoveryParam;for(var m=0;m<4;m++){var g;try{g=this.recoverPubKey(c,l,m)}catch{continue}if(g.eq(h))return m}throw new Error("Unable to find valid recovery factor")},jd}var qd,jb;function iC(){if(jb)return qd;jb=1;var t=xi(),e=t.assert,r=t.parseBytes,i=t.cachedProperty;function s(n,o){this.eddsa=n,this._secret=r(o.secret),n.isPoint(o.pub)?this._pub=o.pub:this._pubBytes=r(o.pub)}return s.fromPublic=function(o,a){return a instanceof s?a:new s(o,{pub:a})},s.fromSecret=function(o,a){return a instanceof s?a:new s(o,{secret:a})},s.prototype.secret=function(){return this._secret},i(s,"pubBytes",function(){return this.eddsa.encodePoint(this.pub())}),i(s,"pub",function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())}),i(s,"privBytes",function(){var o=this.eddsa,a=this.hash(),u=o.encodingLength-1,c=a.slice(0,o.encodingLength);return c[0]&=248,c[u]&=127,c[u]|=64,c}),i(s,"priv",function(){return this.eddsa.decodeInt(this.privBytes())}),i(s,"hash",function(){return this.eddsa.hash().update(this.secret()).digest()}),i(s,"messagePrefix",function(){return this.hash().slice(this.eddsa.encodingLength)}),s.prototype.sign=function(o){return e(this._secret,"KeyPair can only verify"),this.eddsa.sign(o,this)},s.prototype.verify=function(o,a){return this.eddsa.verify(o,a,this)},s.prototype.getSecret=function(o){return e(this._secret,"KeyPair is public only"),t.encode(this.secret(),o)},s.prototype.getPublic=function(o){return t.encode(this.pubBytes(),o)},qd=s,qd}var Bd,qb;function sC(){if(qb)return Bd;qb=1;var t=Ds(),e=xi(),r=e.assert,i=e.cachedProperty,s=e.parseBytes;function n(o,a){this.eddsa=o,typeof a!="object"&&(a=s(a)),Array.isArray(a)&&(r(a.length===o.encodingLength*2,"Signature has invalid size"),a={R:a.slice(0,o.encodingLength),S:a.slice(o.encodingLength)}),r(a.R&&a.S,"Signature without R or S"),o.isPoint(a.R)&&(this._R=a.R),a.S instanceof t&&(this._S=a.S),this._Rencoded=Array.isArray(a.R)?a.R:a.Rencoded,this._Sencoded=Array.isArray(a.S)?a.S:a.Sencoded}return i(n,"S",function(){return this.eddsa.decodeInt(this.Sencoded())}),i(n,"R",function(){return this.eddsa.decodePoint(this.Rencoded())}),i(n,"Rencoded",function(){return this.eddsa.encodePoint(this.R())}),i(n,"Sencoded",function(){return this.eddsa.encodeInt(this.S())}),n.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},n.prototype.toHex=function(){return e.encode(this.toBytes(),"hex").toUpperCase()},Bd=n,Bd}var zd,Bb;function nC(){if(Bb)return zd;Bb=1;var t=fg(),e=pg(),r=xi(),i=r.assert,s=r.parseBytes,n=iC(),o=sC();function a(u){if(i(u==="ed25519","only tested with ed25519 so far"),!(this instanceof a))return new a(u);u=e[u].curve,this.curve=u,this.g=u.g,this.g.precompute(u.n.bitLength()+1),this.pointClass=u.point().constructor,this.encodingLength=Math.ceil(u.n.bitLength()/8),this.hash=t.sha512}return zd=a,a.prototype.sign=function(c,l){c=s(c);var h=this.keyFromSecret(l),f=this.hashInt(h.messagePrefix(),c),m=this.g.mul(f),g=this.encodePoint(m),y=this.hashInt(g,h.pubBytes(),c).mul(h.priv()),C=f.add(y).umod(this.curve.n);return this.makeSignature({R:m,S:C,Rencoded:g})},a.prototype.verify=function(c,l,h){if(c=s(c),l=this.makeSignature(l),l.S().gte(l.eddsa.curve.n)||l.S().isNeg())return!1;var f=this.keyFromPublic(h),m=this.hashInt(l.Rencoded(),f.pubBytes(),c),g=this.g.mul(l.S()),y=l.R().add(f.pub().mul(m));return y.eq(g)},a.prototype.hashInt=function(){for(var c=this.hash(),l=0;l<arguments.length;l++)c.update(arguments[l]);return r.intFromLE(c.digest()).umod(this.curve.n)},a.prototype.keyFromPublic=function(c){return n.fromPublic(this,c)},a.prototype.keyFromSecret=function(c){return n.fromSecret(this,c)},a.prototype.makeSignature=function(c){return c instanceof o?c:new o(this,c)},a.prototype.encodePoint=function(c){var l=c.getY().toArray("le",this.encodingLength);return l[this.encodingLength-1]|=c.getX().isOdd()?128:0,l},a.prototype.decodePoint=function(c){c=r.parseBytes(c);var l=c.length-1,h=c.slice(0,l).concat(c[l]&-129),f=(c[l]&128)!==0,m=r.intFromLE(h);return this.curve.pointFromY(m,f)},a.prototype.encodeInt=function(c){return c.toArray("le",this.encodingLength)},a.prototype.decodeInt=function(c){return r.intFromLE(c)},a.prototype.isPoint=function(c){return c instanceof this.pointClass},zd}var zb;function oC(){return zb||(zb=1,(function(t){var e=t;e.version=qS.version,e.utils=xi(),e.rand=t2(),e.curve=r2(),e.curves=pg(),e.ec=rC(),e.eddsa=nC()})(md)),md}var o2=oC();const a2={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 aC={};const c2=":";function ra(t){const[e,r]=t.split(c2);return{namespace:e,reference:r}}function cC(t){const[e,r,i]=t.split(c2);return{namespace:e,reference:r,address:i}}function u2(t,e){return t.includes(":")?[t]:e.chains||[]}const uC="ReactNative",ui={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},lC="js";function sh(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function un(){return!Qr.getDocument()&&!!Qr.getNavigator()&&navigator.product===uC}function hC(){return un()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="android"}function dC(){return un()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="ios"}function Su(){return!sh()&&!!Qr.getNavigator()&&!!Qr.getDocument()}function Cu(){return un()?ui.reactNative:sh()?ui.node:Su()?ui.browser:ui.unknown}function Hb(){var t;try{return un()&&typeof global<"u"&&typeof(global==null?void 0:global.Application)<"u"?(t=global.Application)==null?void 0:t.applicationId:void 0}catch{return}}function fC(t,e){const r=new URLSearchParams(t);for(const i of Object.keys(e).sort())if(e.hasOwnProperty(i)){const s=e[i];s!==void 0&&r.set(i,s)}return r.toString()}function l2(){return M1.getWindowMetadata()||{name:"",description:"",url:"",icons:[""]}}function pC(){if(Cu()===ui.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=D1();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 gC(){var t;const e=Cu();return e===ui.browser?[e,((t=Qr.getLocation())==null?void 0:t.host)||"unknown"].join(":"):e}function h2(t,e,r){const i=pC(),s=gC();return[[t,e].join("-"),[lC,r].join("-"),i,s].join("/")}function bC({protocol:t,version:e,relayUrl:r,sdkVersion:i,auth:s,projectId:n,useOnCloseEvent:o,bundleId:a,packageName:u}){const c=r.split("?"),l=h2(t,e,i),h={auth:s,ua:l,projectId:n,useOnCloseEvent:o,packageName:u||void 0,bundleId:a||void 0},f=fC(c[1]||"",h);return c[0]+"?"+f}function On(t,e){return t.filter(r=>e.includes(r)).length===t.length}function d2(t){return Object.fromEntries(t.entries())}function f2(t){return new Map(Object.entries(t))}function An(t=B.FIVE_MINUTES,e){const r=B.toMiliseconds(t||B.FIVE_MINUTES);let i,s,n,o;return{resolve:a=>{n&&i&&(clearTimeout(n),i(a),o=Promise.resolve(a))},reject:a=>{n&&s&&(clearTimeout(n),s(a))},done:()=>new Promise((a,u)=>{if(o)return a(o);n=setTimeout(()=>{const c=new Error(e);o=Promise.reject(c),u(c)},r),i=a,s=u})}}function Xs(t,e,r){return new Promise(async(i,s)=>{const n=setTimeout(()=>s(new Error(r)),e);try{const o=await t;i(o)}catch(o){s(o)}clearTimeout(n)})}function p2(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 mC(t){return p2("topic",t)}function yC(t){return p2("id",t)}function g2(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 Zt(t,e){return B.fromMiliseconds(Date.now()+B.toMiliseconds(t))}function Ws(t){return Date.now()>=B.toMiliseconds(t)}function Ue(t,e){return`${t}${e?`:${e}`:""}`}function Ul(t=[],e=[]){return[...new Set([...t,...e])]}async function wC({id:t,topic:e,wcDeepLink:r}){var i;try{if(!r)return;const s=typeof r=="string"?JSON.parse(r):r,n=s?.href;if(typeof n!="string")return;const o=vC(n,t,e),a=Cu();if(a===ui.browser){if(!((i=Qr.getDocument())!=null&&i.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}_C(o)}else a===ui.reactNative&&typeof(global==null?void 0:global.Linking)<"u"&&await global.Linking.openURL(o)}catch(s){console.error(s)}}function vC(t,e,r){const i=`requestId=${e}&sessionTopic=${r}`;t.endsWith("/")&&(t=t.slice(0,-1));let s=`${t}`;if(t.startsWith("https://t.me")){const n=t.includes("?")?"&startapp=":"?startapp=";s=`${s}${n}${SC(i,!0)}`}else s=`${s}/wc?${i}`;return s}function _C(t){let e="_self";AC()?e="_top":(IC()||t.startsWith("https://")||t.startsWith("http://"))&&(e="_blank"),window.open(t,e,"noreferrer noopener")}async function EC(t,e){let r="";try{if(Su()&&(r=localStorage.getItem(e),r))return r;r=await t.getItem(e)}catch(i){console.error(i)}return r}function Vb(t,e){if(!t.includes(e))return null;const r=t.split(/([&,?,=])/),i=r.indexOf(e);return r[i+2]}function Kb(){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 gg(){return typeof process<"u"&&aC.IS_VITEST==="true"}function IC(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function AC(){try{return window.self!==window.top}catch{return!1}}function SC(t,e=!1){const r=Buffer.from(t).toString("base64");return e?r.replace(/[=]/g,""):r}function b2(t){return Buffer.from(t,"base64").toString("utf-8")}function CC(t){return new Promise(e=>setTimeout(e,t))}function jc(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function $C(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Ph(t,...e){if(!$C(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 bg(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");jc(t.outputLen),jc(t.blockLen)}function aa(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 m2(t,e){Ph(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}const al=BigInt(2**32-1),Wb=BigInt(32);function xC(t,e=!1){return e?{h:Number(t&al),l:Number(t>>Wb&al)}:{h:Number(t>>Wb&al)|0,l:Number(t&al)|0}}function PC(t,e=!1){let r=new Uint32Array(t.length),i=new Uint32Array(t.length);for(let s=0;s<t.length;s++){const{h:n,l:o}=xC(t[s],e);[r[s],i[s]]=[n,o]}return[r,i]}const NC=(t,e,r)=>t<<r|e>>>32-r,OC=(t,e,r)=>e<<r|t>>>32-r,TC=(t,e,r)=>e<<r-32|t>>>64-r,DC=(t,e,r)=>t<<r-32|e>>>64-r,uo=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function RC(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function Hd(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Qi(t,e){return t<<32-e|t>>>e}const Gb=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function MC(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function Yb(t){for(let e=0;e<t.length;e++)t[e]=MC(t[e])}function kC(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function ca(t){return typeof t=="string"&&(t=kC(t)),Ph(t),t}let mg=class{clone(){return this._cloneInto()}};function y2(t){const e=i=>t().update(ca(i)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function $u(t=32){if(uo&&typeof uo.getRandomValues=="function")return uo.getRandomValues(new Uint8Array(t));if(uo&&typeof uo.randomBytes=="function")return uo.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}const w2=[],v2=[],_2=[],UC=BigInt(0),Za=BigInt(1),LC=BigInt(2),FC=BigInt(7),jC=BigInt(256),qC=BigInt(113);for(let t=0,e=Za,r=1,i=0;t<24;t++){[r,i]=[i,(2*r+3*i)%5],w2.push(2*(5*i+r)),v2.push((t+1)*(t+2)/2%64);let s=UC;for(let n=0;n<7;n++)e=(e<<Za^(e>>FC)*qC)%jC,e&LC&&(s^=Za<<(Za<<BigInt(n))-Za);_2.push(s)}const[BC,zC]=PC(_2,!0),Jb=(t,e,r)=>r>32?TC(t,e,r):NC(t,e,r),Qb=(t,e,r)=>r>32?DC(t,e,r):OC(t,e,r);function HC(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,u=(o+2)%10,c=r[u],l=r[u+1],h=Jb(c,l,1)^r[a],f=Qb(c,l,1)^r[a+1];for(let m=0;m<50;m+=10)t[o+m]^=h,t[o+m+1]^=f}let s=t[2],n=t[3];for(let o=0;o<24;o++){const a=v2[o],u=Jb(s,n,a),c=Qb(s,n,a),l=w2[o];s=t[l],n=t[l+1],t[l]=u,t[l+1]=c}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]^=BC[i],t[1]^=zC[i]}r.fill(0)}let VC=class E2 extends mg{constructor(e,r,i,s=!1,n=24){if(super(),this.blockLen=e,this.suffix=r,this.outputLen=i,this.enableXOF=s,this.rounds=n,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,jc(i),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=RC(this.state)}keccak(){Gb||Yb(this.state32),HC(this.state32,this.rounds),Gb||Yb(this.state32),this.posOut=0,this.pos=0}update(e){aa(this);const{blockLen:r,state:i}=this;e=ca(e);const s=e.length;for(let n=0;n<s;){const o=Math.min(r-this.pos,s-n);for(let a=0;a<o;a++)i[this.pos++]^=e[n++];this.pos===r&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:r,pos:i,blockLen:s}=this;e[i]^=r,(r&128)!==0&&i===s-1&&this.keccak(),e[s-1]^=128,this.keccak()}writeInto(e){aa(this,!1),Ph(e),this.finish();const r=this.state,{blockLen:i}=this;for(let s=0,n=e.length;s<n;){this.posOut>=i&&this.keccak();const o=Math.min(i-this.posOut,n-s);e.set(r.subarray(this.posOut,this.posOut+o),s),this.posOut+=o,s+=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 jc(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(m2(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,this.state.fill(0)}_cloneInto(e){const{blockLen:r,suffix:i,outputLen:s,rounds:n,enableXOF:o}=this;return e||(e=new E2(r,i,s,o,n)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=n,e.suffix=i,e.outputLen=s,e.enableXOF=o,e.destroyed=this.destroyed,e}};const KC=(t,e,r)=>y2(()=>new VC(e,t,r)),WC=KC(1,136,256/8),GC="https://rpc.walletconnect.org/v1";function I2(t){const e=`Ethereum Signed Message:
|
|
4
|
+
${t.length}`,r=new TextEncoder().encode(e+t);return"0x"+Buffer.from(WC(r)).toString("hex")}async function YC(t,e,r,i,s,n){switch(r.t){case"eip191":return await JC(t,e,r.s);case"eip1271":return await QC(t,e,r.s,i,s,n);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${r.t}`)}}async function JC(t,e,r){return(await zA({hash:I2(e),signature:r})).toLowerCase()===t.toLowerCase()}async function QC(t,e,r,i,s,n){const o=ra(i);if(!o.namespace||!o.reference)throw new Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${i}`);try{const a="0x1626ba7e",u="0000000000000000000000000000000000000000000000000000000000000040",c="0000000000000000000000000000000000000000000000000000000000000041",l=r.substring(2),h=I2(e).substring(2),f=a+h+u+c+l,m=await fetch(`${n||GC}/?chainId=${i}&projectId=${s}`,{method:"POST",body:JSON.stringify({id:XC(),jsonrpc:"2.0",method:"eth_call",params:[{to:t,data:f},"latest"]})}),{result:g}=await m.json();return g?g.slice(0,a.length).toLowerCase()===a.toLowerCase():!1}catch(a){return console.error("isValidEip1271Signature: ",a),!1}}function XC(){return Date.now()+Math.floor(Math.random()*1e3)}var ZC=Object.defineProperty,e$=Object.defineProperties,t$=Object.getOwnPropertyDescriptors,Xb=Object.getOwnPropertySymbols,r$=Object.prototype.hasOwnProperty,i$=Object.prototype.propertyIsEnumerable,Zb=(t,e,r)=>e in t?ZC(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,s$=(t,e)=>{for(var r in e||(e={}))r$.call(e,r)&&Zb(t,r,e[r]);if(Xb)for(var r of Xb(e))i$.call(e,r)&&Zb(t,r,e[r]);return t},n$=(t,e)=>e$(t,t$(e));const o$="did:pkh:",yg=t=>t?.split(":"),a$=t=>{const e=t&&yg(t);if(e)return t.includes(o$)?e[3]:e[1]},Zf=t=>{const e=t&&yg(t);if(e)return e[2]+":"+e[3]},nh=t=>{const e=t&&yg(t);if(e)return e.pop()};async function em(t){const{cacao:e,projectId:r}=t,{s:i,p:s}=e,n=A2(s,s.iss),o=nh(s.iss);return await YC(o,n,i,Zf(s.iss),r)}const A2=(t,e)=>{const r=`${t.domain} wants you to sign in with your Ethereum account:`,i=nh(e);if(!t.aud&&!t.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let s=t.statement||void 0;const n=`URI: ${t.aud||t.uri}`,o=`Version: ${t.version}`,a=`Chain ID: ${a$(e)}`,u=`Nonce: ${t.nonce}`,c=`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,m=t.resources?`Resources:${t.resources.map(y=>`
|
|
5
|
+
- ${y}`).join("")}`:void 0,g=Ll(t.resources);if(g){const y=qc(g);s=b$(s,y)}return[r,i,"",s,"",n,o,a,u,c,l,h,f,m].filter(y=>y!=null).join(`
|
|
6
|
+
`)};function c$(t){return Buffer.from(JSON.stringify(t)).toString("base64")}function u$(t){return JSON.parse(Buffer.from(t,"base64").toString("utf-8"))}function Un(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(s=>{const n=i[s];if(!Array.isArray(n))throw new Error(`Ability limits ${s} must be an array of objects, found: ${n}`);if(!n.length)throw new Error(`Value of ${s} is empty array, must be an array with objects`);n.forEach(o=>{if(typeof o!="object")throw new Error(`Ability limits (${s}) must be an array of objects, found: ${o}`)})})})}function l$(t,e,r,i={}){return r?.sort((s,n)=>s.localeCompare(n)),{att:{[t]:h$(e,r,i)}}}function h$(t,e,r={}){e=e?.sort((s,n)=>s.localeCompare(n));const i=e.map(s=>({[`${t}/${s}`]:[r]}));return Object.assign({},...i)}function S2(t){return Un(t),`urn:recap:${c$(t).replace(/=/g,"")}`}function qc(t){const e=u$(t.replace("urn:recap:",""));return Un(e),e}function d$(t,e,r){const i=l$(t,e,r);return S2(i)}function f$(t){return t&&t.includes("urn:recap:")}function p$(t,e){const r=qc(t),i=qc(e),s=g$(r,i);return S2(s)}function g$(t,e){Un(t),Un(e);const r=Object.keys(t.att).concat(Object.keys(e.att)).sort((s,n)=>s.localeCompare(n)),i={att:{}};return r.forEach(s=>{var n,o;Object.keys(((n=t.att)==null?void 0:n[s])||{}).concat(Object.keys(((o=e.att)==null?void 0:o[s])||{})).sort((a,u)=>a.localeCompare(u)).forEach(a=>{var u,c;i.att[s]=n$(s$({},i.att[s]),{[a]:((u=t.att[s])==null?void 0:u[a])||((c=e.att[s])==null?void 0:c[a])})})}),i}function b$(t="",e){Un(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 s=0;Object.keys(e.att).forEach(a=>{const u=Object.keys(e.att[a]).map(h=>({ability:h.split("/")[0],action:h.split("/")[1]}));u.sort((h,f)=>h.action.localeCompare(f.action));const c={};u.forEach(h=>{c[h.ability]||(c[h.ability]=[]),c[h.ability].push(h.action)});const l=Object.keys(c).map(h=>(s++,`(${s}) '${h}': '${c[h].join("', '")}' for '${a}'.`));i.push(l.join(", ").replace(".,","."))});const n=i.join(" "),o=`${r}${n}`;return`${t?t+" ":""}${o}`}function tm(t){var e;const r=qc(t);Un(r);const i=(e=r.att)==null?void 0:e.eip155;return i?Object.keys(i).map(s=>s.split("/")[1]):[]}function rm(t){const e=qc(t);Un(e);const r=[];return Object.values(e.att).forEach(i=>{Object.values(i).forEach(s=>{var n;(n=s?.[0])!=null&&n.chains&&r.push(s[0].chains)})}),[...new Set(r.flat())]}function Ll(t){if(!t)return;const e=t?.[t.length-1];return f$(e)?e:void 0}function Vd(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function C2(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function ai(t,...e){if(!C2(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 im(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 m$(t,e){ai(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function sm(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}const sn=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),y$=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),w$=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!w$)throw new Error("Non little-endian hardware is not supported");function v$(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function ep(t){if(typeof t=="string")t=v$(t);else if(C2(t))t=tp(t);else throw new Error("Uint8Array expected, got "+typeof t);return t}function _$(t,e){if(e==null||typeof e!="object")throw new Error("options must be defined");return Object.assign(t,e)}function E$(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 I$=(t,e)=>{function r(i,...s){if(ai(i),t.nonceLength!==void 0){const c=s[0];if(!c)throw new Error("nonce / iv required");t.varSizeNonce?ai(c):ai(c,t.nonceLength)}const n=t.tagLength;n&&s[1]!==void 0&&ai(s[1]);const o=e(i,...s),a=(c,l)=>{if(l!==void 0){if(c!==2)throw new Error("cipher output not supported");ai(l)}};let u=!1;return{encrypt(c,l){if(u)throw new Error("cannot encrypt() twice with same key + nonce");return u=!0,ai(c),a(o.encrypt.length,l),o.encrypt(c,l)},decrypt(c,l){if(ai(c),n&&c.length<n)throw new Error("invalid ciphertext length: smaller than tagLength="+n);return a(o.decrypt.length,l),o.decrypt(c,l)}}}return Object.assign(r,t),r};function nm(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&&!A$(e))throw new Error("invalid output, must be aligned");return e}function om(t,e,r,i){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,i);const s=BigInt(32),n=BigInt(4294967295),o=Number(r>>s&n),a=Number(r&n);t.setUint32(e+4,o,i),t.setUint32(e+0,a,i)}function A$(t){return t.byteOffset%4===0}function tp(t){return Uint8Array.from(t)}function ua(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}const $2=t=>Uint8Array.from(t.split("").map(e=>e.charCodeAt(0))),S$=$2("expand 16-byte k"),C$=$2("expand 32-byte k"),$$=sn(S$),x$=sn(C$);function Ce(t,e){return t<<e|t>>>32-e}function rp(t){return t.byteOffset%4===0}const cl=64,P$=16,x2=2**32-1,am=new Uint32Array;function N$(t,e,r,i,s,n,o,a){const u=s.length,c=new Uint8Array(cl),l=sn(c),h=rp(s)&&rp(n),f=h?sn(s):am,m=h?sn(n):am;for(let g=0;g<u;o++){if(t(e,r,i,l,o,a),o>=x2)throw new Error("arx: counter overflow");const y=Math.min(cl,u-g);if(h&&y===cl){const C=g/4;if(g%4!==0)throw new Error("arx: invalid block position");for(let S=0,A;S<P$;S++)A=C+S,m[A]=f[A]^l[S];g+=cl;continue}for(let C=0,S;C<y;C++)S=g+C,n[S]=s[S]^c[C];g+=y}}function O$(t,e){const{allowShortKeys:r,extendNonceFn:i,counterLength:s,counterRight:n,rounds:o}=_$({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},e);if(typeof t!="function")throw new Error("core must be a function");return Vd(s),Vd(o),sm(n),sm(r),(a,u,c,l,h=0)=>{ai(a),ai(u),ai(c);const f=c.length;if(l===void 0&&(l=new Uint8Array(f)),ai(l),Vd(h),h<0||h>=x2)throw new Error("arx: counter overflow");if(l.length<f)throw new Error(`arx: output (${l.length}) is shorter than data (${f})`);const m=[];let g=a.length,y,C;if(g===32)m.push(y=tp(a)),C=x$;else if(g===16&&r)y=new Uint8Array(32),y.set(a),y.set(a,16),C=$$,m.push(y);else throw new Error(`arx: invalid 32-byte key, got length=${g}`);rp(u)||m.push(u=tp(u));const S=sn(y);if(i){if(u.length!==24)throw new Error("arx: extended nonce must be 24 bytes");i(C,S,sn(u.subarray(0,16)),S),u=u.subarray(16)}const A=16-s;if(A!==u.length)throw new Error(`arx: nonce must be ${A} or 16 bytes`);if(A!==12){const O=new Uint8Array(12);O.set(u,n?0:12-u.length),u=O,m.push(u)}const D=sn(u);return N$(t,C,S,D,c,l,h,o),ua(...m),l}}const mr=(t,e)=>t[e++]&255|(t[e++]&255)<<8;let T$=class{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=ep(e),ai(e,32);const r=mr(e,0),i=mr(e,2),s=mr(e,4),n=mr(e,6),o=mr(e,8),a=mr(e,10),u=mr(e,12),c=mr(e,14);this.r[0]=r&8191,this.r[1]=(r>>>13|i<<3)&8191,this.r[2]=(i>>>10|s<<6)&7939,this.r[3]=(s>>>7|n<<9)&8191,this.r[4]=(n>>>4|o<<12)&255,this.r[5]=o>>>1&8190,this.r[6]=(o>>>14|a<<2)&8191,this.r[7]=(a>>>11|u<<5)&8065,this.r[8]=(u>>>8|c<<8)&8191,this.r[9]=c>>>5&127;for(let l=0;l<8;l++)this.pad[l]=mr(e,16+2*l)}process(e,r,i=!1){const s=i?0:2048,{h:n,r:o}=this,a=o[0],u=o[1],c=o[2],l=o[3],h=o[4],f=o[5],m=o[6],g=o[7],y=o[8],C=o[9],S=mr(e,r+0),A=mr(e,r+2),D=mr(e,r+4),O=mr(e,r+6),T=mr(e,r+8),x=mr(e,r+10),M=mr(e,r+12),U=mr(e,r+14);let R=n[0]+(S&8191),L=n[1]+((S>>>13|A<<3)&8191),$=n[2]+((A>>>10|D<<6)&8191),d=n[3]+((D>>>7|O<<9)&8191),b=n[4]+((O>>>4|T<<12)&8191),_=n[5]+(T>>>1&8191),w=n[6]+((T>>>14|x<<2)&8191),v=n[7]+((x>>>11|M<<5)&8191),I=n[8]+((M>>>8|U<<8)&8191),P=n[9]+(U>>>5|s),E=0,p=E+R*a+L*(5*C)+$*(5*y)+d*(5*g)+b*(5*m);E=p>>>13,p&=8191,p+=_*(5*f)+w*(5*h)+v*(5*l)+I*(5*c)+P*(5*u),E+=p>>>13,p&=8191;let N=E+R*u+L*a+$*(5*C)+d*(5*y)+b*(5*g);E=N>>>13,N&=8191,N+=_*(5*m)+w*(5*f)+v*(5*h)+I*(5*l)+P*(5*c),E+=N>>>13,N&=8191;let q=E+R*c+L*u+$*a+d*(5*C)+b*(5*y);E=q>>>13,q&=8191,q+=_*(5*g)+w*(5*m)+v*(5*f)+I*(5*h)+P*(5*l),E+=q>>>13,q&=8191;let H=E+R*l+L*c+$*u+d*a+b*(5*C);E=H>>>13,H&=8191,H+=_*(5*y)+w*(5*g)+v*(5*m)+I*(5*f)+P*(5*h),E+=H>>>13,H&=8191;let z=E+R*h+L*l+$*c+d*u+b*a;E=z>>>13,z&=8191,z+=_*(5*C)+w*(5*y)+v*(5*g)+I*(5*m)+P*(5*f),E+=z>>>13,z&=8191;let V=E+R*f+L*h+$*l+d*c+b*u;E=V>>>13,V&=8191,V+=_*a+w*(5*C)+v*(5*y)+I*(5*g)+P*(5*m),E+=V>>>13,V&=8191;let Y=E+R*m+L*f+$*h+d*l+b*c;E=Y>>>13,Y&=8191,Y+=_*u+w*a+v*(5*C)+I*(5*y)+P*(5*g),E+=Y>>>13,Y&=8191;let te=E+R*g+L*m+$*f+d*h+b*l;E=te>>>13,te&=8191,te+=_*c+w*u+v*a+I*(5*C)+P*(5*y),E+=te>>>13,te&=8191;let ie=E+R*y+L*g+$*m+d*f+b*h;E=ie>>>13,ie&=8191,ie+=_*l+w*c+v*u+I*a+P*(5*C),E+=ie>>>13,ie&=8191;let Z=E+R*C+L*y+$*g+d*m+b*f;E=Z>>>13,Z&=8191,Z+=_*h+w*l+v*c+I*u+P*a,E+=Z>>>13,Z&=8191,E=(E<<2)+E|0,E=E+p|0,p=E&8191,E=E>>>13,N+=E,n[0]=p,n[1]=N,n[2]=q,n[3]=H,n[4]=z,n[5]=V,n[6]=Y,n[7]=te,n[8]=ie,n[9]=Z}finalize(){const{h:e,pad:r}=this,i=new Uint16Array(10);let s=e[1]>>>13;e[1]&=8191;for(let a=2;a<10;a++)e[a]+=s,s=e[a]>>>13,e[a]&=8191;e[0]+=s*5,s=e[0]>>>13,e[0]&=8191,e[1]+=s,s=e[1]>>>13,e[1]&=8191,e[2]+=s,i[0]=e[0]+5,s=i[0]>>>13,i[0]&=8191;for(let a=1;a<10;a++)i[a]=e[a]+s,s=i[a]>>>13,i[a]&=8191;i[9]-=8192;let n=(s^1)-1;for(let a=0;a<10;a++)i[a]&=n;n=~n;for(let a=0;a<10;a++)e[a]=e[a]&n|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;ua(i)}update(e){im(this);const{buffer:r,blockLen:i}=this;e=ep(e);const s=e.length;for(let n=0;n<s;){const o=Math.min(i-this.pos,s-n);if(o===i){for(;i<=s-n;n+=i)this.process(e,n);continue}r.set(e.subarray(n,n+o),this.pos),this.pos+=o,n+=o,this.pos===i&&(this.process(r,0,!1),this.pos=0)}return this}destroy(){ua(this.h,this.r,this.buffer,this.pad)}digestInto(e){im(this),m$(e,this),this.finished=!0;const{buffer:r,h:i}=this;let{pos:s}=this;if(s){for(r[s++]=1;s<16;s++)r[s]=0;this.process(r,0,!0)}this.finalize();let n=0;for(let o=0;o<8;o++)e[n++]=i[o]>>>0,e[n++]=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 D$(t){const e=(i,s)=>t(s).update(ep(i)).digest(),r=t(new Uint8Array(32));return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=i=>t(i),e}const R$=D$(t=>new T$(t));function M$(t,e,r,i,s,n=20){let o=t[0],a=t[1],u=t[2],c=t[3],l=e[0],h=e[1],f=e[2],m=e[3],g=e[4],y=e[5],C=e[6],S=e[7],A=s,D=r[0],O=r[1],T=r[2],x=o,M=a,U=u,R=c,L=l,$=h,d=f,b=m,_=g,w=y,v=C,I=S,P=A,E=D,p=O,N=T;for(let H=0;H<n;H+=2)x=x+L|0,P=Ce(P^x,16),_=_+P|0,L=Ce(L^_,12),x=x+L|0,P=Ce(P^x,8),_=_+P|0,L=Ce(L^_,7),M=M+$|0,E=Ce(E^M,16),w=w+E|0,$=Ce($^w,12),M=M+$|0,E=Ce(E^M,8),w=w+E|0,$=Ce($^w,7),U=U+d|0,p=Ce(p^U,16),v=v+p|0,d=Ce(d^v,12),U=U+d|0,p=Ce(p^U,8),v=v+p|0,d=Ce(d^v,7),R=R+b|0,N=Ce(N^R,16),I=I+N|0,b=Ce(b^I,12),R=R+b|0,N=Ce(N^R,8),I=I+N|0,b=Ce(b^I,7),x=x+$|0,N=Ce(N^x,16),v=v+N|0,$=Ce($^v,12),x=x+$|0,N=Ce(N^x,8),v=v+N|0,$=Ce($^v,7),M=M+d|0,P=Ce(P^M,16),I=I+P|0,d=Ce(d^I,12),M=M+d|0,P=Ce(P^M,8),I=I+P|0,d=Ce(d^I,7),U=U+b|0,E=Ce(E^U,16),_=_+E|0,b=Ce(b^_,12),U=U+b|0,E=Ce(E^U,8),_=_+E|0,b=Ce(b^_,7),R=R+L|0,p=Ce(p^R,16),w=w+p|0,L=Ce(L^w,12),R=R+L|0,p=Ce(p^R,8),w=w+p|0,L=Ce(L^w,7);let q=0;i[q++]=o+x|0,i[q++]=a+M|0,i[q++]=u+U|0,i[q++]=c+R|0,i[q++]=l+L|0,i[q++]=h+$|0,i[q++]=f+d|0,i[q++]=m+b|0,i[q++]=g+_|0,i[q++]=y+w|0,i[q++]=C+v|0,i[q++]=S+I|0,i[q++]=A+P|0,i[q++]=D+E|0,i[q++]=O+p|0,i[q++]=T+N|0}const k$=O$(M$,{counterRight:!1,counterLength:4,allowShortKeys:!1}),U$=new Uint8Array(16),cm=(t,e)=>{t.update(e);const r=e.length%16;r&&t.update(U$.subarray(r))},L$=new Uint8Array(32);function um(t,e,r,i,s){const n=t(e,r,L$),o=R$.create(n);s&&cm(o,s),cm(o,i);const a=new Uint8Array(16),u=y$(a);om(u,0,BigInt(s?s.length:0),!0),om(u,8,BigInt(i.length),!0),o.update(a);const c=o.digest();return ua(n,a),c}const F$=t=>(e,r,i)=>({encrypt(s,n){const o=s.length;n=nm(o+16,n,!1),n.set(s);const a=n.subarray(0,-16);t(e,r,a,a,1);const u=um(t,e,r,a,i);return n.set(u,o),ua(u),n},decrypt(s,n){n=nm(s.length-16,n,!1);const o=s.subarray(0,-16),a=s.subarray(-16),u=um(t,e,r,o,i);if(!E$(a,u))throw new Error("invalid tag");return n.set(s.subarray(0,-16)),t(e,r,n,n,1),ua(u),n}}),P2=I$({blockSize:64,nonceLength:12,tagLength:16},F$(k$));let N2=class extends mg{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,bg(e);const i=ca(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 s=this.blockLen,n=new Uint8Array(s);n.set(i.length>s?e.create().update(i).digest():i);for(let o=0;o<n.length;o++)n[o]^=54;this.iHash.update(n),this.oHash=e.create();for(let o=0;o<n.length;o++)n[o]^=106;this.oHash.update(n),n.fill(0)}update(e){return aa(this),this.iHash.update(e),this}digestInto(e){aa(this),Ph(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:s,destroyed:n,blockLen:o,outputLen:a}=this;return e=e,e.finished=s,e.destroyed=n,e.blockLen=o,e.outputLen=a,e.oHash=r._cloneInto(e.oHash),e.iHash=i._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};const wg=(t,e,r)=>new N2(t,e).update(r).digest();wg.create=(t,e)=>new N2(t,e);function j$(t,e,r){return bg(t),r===void 0&&(r=new Uint8Array(t.outputLen)),wg(t,ca(r),ca(e))}const Kd=new Uint8Array([0]),lm=new Uint8Array;function q$(t,e,r,i=32){if(bg(t),jc(i),i>255*t.outputLen)throw new Error("Length should be <= 255*HashLen");const s=Math.ceil(i/t.outputLen);r===void 0&&(r=lm);const n=new Uint8Array(s*t.outputLen),o=wg.create(t,e),a=o._cloneInto(),u=new Uint8Array(o.outputLen);for(let c=0;c<s;c++)Kd[0]=c+1,a.update(c===0?lm:u).update(r).update(Kd).digestInto(u),n.set(u,t.outputLen*c),o._cloneInto(a);return o.destroy(),a.destroy(),u.fill(0),Kd.fill(0),n.slice(0,i)}const B$=(t,e,r,i,s)=>q$(t,j$(t,e,r),i,s);function z$(t,e,r,i){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,i);const s=BigInt(32),n=BigInt(4294967295),o=Number(r>>s&n),a=Number(r&n),u=i?4:0,c=i?0:4;t.setUint32(e+u,o,i),t.setUint32(e+c,a,i)}function H$(t,e,r){return t&e^~t&r}function V$(t,e,r){return t&e^t&r^e&r}let K$=class extends mg{constructor(e,r,i,s){super(),this.blockLen=e,this.outputLen=r,this.padOffset=i,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Hd(this.buffer)}update(e){aa(this);const{view:r,buffer:i,blockLen:s}=this;e=ca(e);const n=e.length;for(let o=0;o<n;){const a=Math.min(s-this.pos,n-o);if(a===s){const u=Hd(e);for(;s<=n-o;o+=s)this.process(u,o);continue}i.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===s&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){aa(this),m2(e,this),this.finished=!0;const{buffer:r,view:i,blockLen:s,isLE:n}=this;let{pos:o}=this;r[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>s-o&&(this.process(i,0),o=0);for(let h=o;h<s;h++)r[h]=0;z$(i,s-8,BigInt(this.length*8),n),this.process(i,0);const a=Hd(e),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=u/4,l=this.get();if(c>l.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<c;h++)a.setUint32(4*h,l[h],n)}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:s,finished:n,destroyed:o,pos:a}=this;return e.length=s,e.pos=a,e.finished=n,e.destroyed=o,s%r&&e.buffer.set(i),e}};const W$=new Uint32Array([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]),js=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),qs=new Uint32Array(64);let G$=class extends K${constructor(){super(64,32,8,!1),this.A=js[0]|0,this.B=js[1]|0,this.C=js[2]|0,this.D=js[3]|0,this.E=js[4]|0,this.F=js[5]|0,this.G=js[6]|0,this.H=js[7]|0}get(){const{A:e,B:r,C:i,D:s,E:n,F:o,G:a,H:u}=this;return[e,r,i,s,n,o,a,u]}set(e,r,i,s,n,o,a,u){this.A=e|0,this.B=r|0,this.C=i|0,this.D=s|0,this.E=n|0,this.F=o|0,this.G=a|0,this.H=u|0}process(e,r){for(let h=0;h<16;h++,r+=4)qs[h]=e.getUint32(r,!1);for(let h=16;h<64;h++){const f=qs[h-15],m=qs[h-2],g=Qi(f,7)^Qi(f,18)^f>>>3,y=Qi(m,17)^Qi(m,19)^m>>>10;qs[h]=y+qs[h-7]+g+qs[h-16]|0}let{A:i,B:s,C:n,D:o,E:a,F:u,G:c,H:l}=this;for(let h=0;h<64;h++){const f=Qi(a,6)^Qi(a,11)^Qi(a,25),m=l+f+H$(a,u,c)+W$[h]+qs[h]|0,g=(Qi(i,2)^Qi(i,13)^Qi(i,22))+V$(i,s,n)|0;l=c,c=u,u=a,a=o+m|0,o=n,n=s,s=i,i=m+g|0}i=i+this.A|0,s=s+this.B|0,n=n+this.C|0,o=o+this.D|0,a=a+this.E|0,u=u+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(i,s,n,o,a,u,c,l)}roundClean(){qs.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const Nh=y2(()=>new G$);const O2=BigInt(0);function vg(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function T2(t){if(!vg(t))throw new Error("Uint8Array expected")}const Y$=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function J$(t){T2(t);let e="";for(let r=0;r<t.length;r++)e+=Y$[t[r]];return e}function Q$(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?O2:BigInt("0x"+t)}const ys={_0:48,_9:57,A:65,F:70,a:97,f:102};function hm(t){if(t>=ys._0&&t<=ys._9)return t-ys._0;if(t>=ys.A&&t<=ys.F)return t-(ys.A-10);if(t>=ys.a&&t<=ys.f)return t-(ys.a-10)}function D2(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 s=0,n=0;s<r;s++,n+=2){const o=hm(t.charCodeAt(n)),a=hm(t.charCodeAt(n+1));if(o===void 0||a===void 0){const u=t[n]+t[n+1];throw new Error('hex string expected, got non-hex character "'+u+'" at index '+n)}i[s]=o*16+a}return i}function dm(t){return T2(t),Q$(J$(Uint8Array.from(t).reverse()))}function X$(t,e){return D2(t.toString(16).padStart(e*2,"0"))}function Z$(t,e){return X$(t,e).reverse()}function fm(t,e,r){let i;if(typeof e=="string")try{i=D2(e)}catch(n){throw new Error(t+" must be hex string or Uint8Array, cause: "+n)}else if(vg(e))i=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");const s=i.length;if(typeof r=="number"&&s!==r)throw new Error(t+" of length "+r+" expected, got "+s);return i}const Wd=t=>typeof t=="bigint"&&O2<=t;function ex(t,e,r){return Wd(t)&&Wd(e)&&Wd(r)&&e<=t&&t<r}function pm(t,e,r,i){if(!ex(e,r,i))throw new Error("expected valid "+t+": "+r+" <= n < "+i+", got "+e)}const tx={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"||vg(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 rx(t,e,r={}){const i=(s,n,o)=>{const a=tx[n];if(typeof a!="function")throw new Error("invalid validator function");const u=t[s];if(!(o&&u===void 0)&&!a(u,t))throw new Error("param "+String(s)+" is invalid. Expected "+n+", got "+u)};for(const[s,n]of Object.entries(e))i(s,n,!1);for(const[s,n]of Object.entries(r))i(s,n,!0);return t}const Qo=BigInt(0),ul=BigInt(1);function R2(t,e){const r=t%e;return r>=Qo?r:e+r}function ix(t,e,r){if(e<Qo)throw new Error("invalid exponent, negatives unsupported");if(r<=Qo)throw new Error("invalid modulus");if(r===ul)return Qo;let i=ul;for(;e>Qo;)e&ul&&(i=i*t%r),t=t*t%r,e>>=ul;return i}function qi(t,e,r){let i=t;for(;e-- >Qo;)i*=i,i%=r;return i}BigInt(0),BigInt(1),BigInt(0),BigInt(1),BigInt(2),BigInt(8);const lo=BigInt(0),Gd=BigInt(1);function sx(t){return rx(t,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...t})}function nx(t){const e=sx(t),{P:r}=e,i=A=>R2(A,r),s=e.montgomeryBits,n=Math.ceil(s/8),o=e.nByteLength,a=e.adjustScalarBytes||(A=>A),u=e.powPminus2||(A=>ix(A,r-BigInt(2),r));function c(A,D,O){const T=i(A*(D-O));return D=i(D-T),O=i(O+T),[D,O]}const l=(e.a-BigInt(2))/BigInt(4);function h(A,D){pm("u",A,lo,r),pm("scalar",D,lo,r);const O=D,T=A;let x=Gd,M=lo,U=A,R=Gd,L=lo,$;for(let b=BigInt(s-1);b>=lo;b--){const _=O>>b&Gd;L^=_,$=c(L,x,U),x=$[0],U=$[1],$=c(L,M,R),M=$[0],R=$[1],L=_;const w=x+M,v=i(w*w),I=x-M,P=i(I*I),E=v-P,p=U+R,N=U-R,q=i(N*w),H=i(p*I),z=q+H,V=q-H;U=i(z*z),R=i(T*i(V*V)),x=i(v*P),M=i(E*(v+i(l*E)))}$=c(L,x,U),x=$[0],U=$[1],$=c(L,M,R),M=$[0],R=$[1];const d=u(M);return i(x*d)}function f(A){return Z$(i(A),n)}function m(A){const D=fm("u coordinate",A,n);return o===32&&(D[31]&=127),dm(D)}function g(A){const D=fm("scalar",A),O=D.length;if(O!==n&&O!==o){let T=""+n+" or "+o;throw new Error("invalid scalar, expected "+T+" bytes, got "+O)}return dm(a(D))}function y(A,D){const O=m(D),T=g(A),x=h(O,T);if(x===lo)throw new Error("invalid private or public key received");return f(x)}const C=f(e.Gu);function S(A){return y(A,C)}return{scalarMult:y,scalarMultBase:S,getSharedSecret:(A,D)=>y(A,D),getPublicKey:A=>S(A),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:C}}const ip=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949");BigInt(0);const ox=BigInt(1),gm=BigInt(2),ax=BigInt(3),cx=BigInt(5);BigInt(8);function ux(t){const e=BigInt(10),r=BigInt(20),i=BigInt(40),s=BigInt(80),n=ip,o=t*t%n*t%n,a=qi(o,gm,n)*o%n,u=qi(a,ox,n)*t%n,c=qi(u,cx,n)*u%n,l=qi(c,e,n)*c%n,h=qi(l,r,n)*l%n,f=qi(h,i,n)*h%n,m=qi(f,s,n)*f%n,g=qi(m,s,n)*f%n,y=qi(g,e,n)*c%n;return{pow_p_5_8:qi(y,gm,n)*t%n,b2:o}}function lx(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}const sp=nx({P:ip,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:t=>{const e=ip,{pow_p_5_8:r,b2:i}=ux(t);return R2(qi(r,ax,e)*i,e)},adjustScalarBytes:lx,randomBytes:$u}),M2="base10",Dr="base16",Zs="base64pad",ec="base64url",xu="utf8",k2=0,xs=1,Pu=2,hx=0,bm=1,$c=12,_g=32;function dx(){const t=sp.utils.randomPrivateKey(),e=sp.getPublicKey(t);return{privateKey:Fe(t,Dr),publicKey:Fe(e,Dr)}}function np(){const t=$u(_g);return Fe(t,Dr)}function fx(t,e){const r=sp.getSharedSecret(_t(t,Dr),_t(e,Dr)),i=B$(Nh,r,void 0,void 0,_g);return Fe(i,Dr)}function Fl(t){const e=Nh(_t(t,Dr));return Fe(e,Dr)}function $s(t){const e=Nh(_t(t,xu));return Fe(e,Dr)}function U2(t){return _t(`${t}`,M2)}function Ln(t){return Number(Fe(t,M2))}function px(t){const e=U2(typeof t.type<"u"?t.type:k2);if(Ln(e)===xs&&typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const r=typeof t.senderPublicKey<"u"?_t(t.senderPublicKey,Dr):void 0,i=typeof t.iv<"u"?_t(t.iv,Dr):$u($c),s=_t(t.symKey,Dr),n=P2(s,i).encrypt(_t(t.message,xu));return L2({type:e,sealed:n,iv:i,senderPublicKey:r,encoding:t.encoding})}function gx(t){const e=_t(t.symKey,Dr),{sealed:r,iv:i}=Bc(t),s=P2(e,i).decrypt(r);if(s===null)throw new Error("Failed to decrypt");return Fe(s,xu)}function bx(t,e){const r=U2(Pu),i=$u($c),s=_t(t,xu);return L2({type:r,sealed:s,iv:i,encoding:e})}function mx(t,e){const{sealed:r}=Bc({encoded:t,encoding:e});return Fe(r,xu)}function L2(t){const{encoding:e=Zs}=t;if(Ln(t.type)===Pu)return Fe(ta([t.type,t.sealed]),e);if(Ln(t.type)===xs){if(typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return Fe(ta([t.type,t.senderPublicKey,t.iv,t.sealed]),e)}return Fe(ta([t.type,t.iv,t.sealed]),e)}function Bc(t){const{encoded:e,encoding:r=Zs}=t,i=_t(e,r),s=i.slice(hx,bm),n=bm;if(Ln(s)===xs){const c=n+_g,l=c+$c,h=i.slice(n,c),f=i.slice(c,l),m=i.slice(l);return{type:s,sealed:m,iv:f,senderPublicKey:h}}if(Ln(s)===Pu){const c=i.slice(n),l=$u($c);return{type:s,sealed:c,iv:l}}const o=n+$c,a=i.slice(n,o),u=i.slice(o);return{type:s,sealed:u,iv:a}}function yx(t,e){const r=Bc({encoded:t,encoding:e?.encoding});return F2({type:Ln(r.type),senderPublicKey:typeof r.senderPublicKey<"u"?Fe(r.senderPublicKey,Dr):void 0,receiverPublicKey:e?.receiverPublicKey})}function F2(t){const e=t?.type||k2;if(e===xs){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 mm(t){return t.type===xs&&typeof t.senderPublicKey=="string"&&typeof t.receiverPublicKey=="string"}function ym(t){return t.type===Pu}function wx(t){return new o2.ec("p256").keyFromPublic({x:Buffer.from(t.x,"base64").toString("hex"),y:Buffer.from(t.y,"base64").toString("hex")},"hex")}function vx(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");const r=e.length%4;return r>0&&(e+="=".repeat(4-r)),e}function _x(t){return Buffer.from(vx(t),"base64")}function Ex(t,e){const[r,i,s]=t.split("."),n=_x(s);if(n.length!==64)throw new Error("Invalid signature length");const o=n.slice(0,32).toString("hex"),a=n.slice(32,64).toString("hex"),u=`${r}.${i}`,c=Nh(u),l=wx(e),h=Fe(c,Dr);if(!l.verify(h,{r:o,s:a}))throw new Error("Invalid signature");return oa(t).payload}const Ix="irn";function oh(t){return t?.relay||{protocol:Ix}}function wc(t){const e=a2[t];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${t}`);return e}function Ax(t,e="-"){const r={},i="relay"+e;return Object.keys(t).forEach(s=>{if(s.startsWith(i)){const n=s.replace(i,""),o=t[s];r[n]=o}}),r}function wm(t){if(!t.includes("wc:")){const c=b2(t);c!=null&&c.includes("wc:")&&(t=c)}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),s=t.substring(e+1,r).split("@"),n=typeof r<"u"?t.substring(r):"",o=new URLSearchParams(n),a={};o.forEach((c,l)=>{a[l]=c});const u=typeof a.methods=="string"?a.methods.split(","):void 0;return{protocol:i,topic:Sx(s[0]),version:parseInt(s[1],10),symKey:a.symKey,relay:Ax(a),methods:u,expiryTimestamp:a.expiryTimestamp?parseInt(a.expiryTimestamp,10):void 0}}function Sx(t){return t.startsWith("//")?t.substring(2):t}function Cx(t,e="-"){const r="relay",i={};return Object.keys(t).forEach(s=>{const n=s,o=r+e+n;t[n]&&(i[o]=t[n])}),i}function vm(t){const e=new URLSearchParams,r=Cx(t.relay);Object.keys(r).sort().forEach(s=>{e.set(s,r[s])}),e.set("symKey",t.symKey),t.expiryTimestamp&&e.set("expiryTimestamp",t.expiryTimestamp.toString()),t.methods&&e.set("methods",t.methods.join(","));const i=e.toString();return`${t.protocol}:${t.topic}@${t.version}?${i}`}function ll(t,e,r){return`${t}?wc_ev=${r}&topic=${e}`}function Ia(t){const e=[];return t.forEach(r=>{const[i,s]=r.split(":");e.push(`${i}:${s}`)}),e}function $x(t){const e=[];return Object.values(t).forEach(r=>{e.push(...Ia(r.accounts))}),e}function xx(t,e){const r=[];return Object.values(t).forEach(i=>{Ia(i.accounts).includes(e)&&r.push(...i.methods)}),r}function Px(t,e){const r=[];return Object.values(t).forEach(i=>{Ia(i.accounts).includes(e)&&r.push(...i.events)}),r}function Eg(t){return t.includes(":")}function vc(t){return Eg(t)?t.split(":")[0]:t}function Nx(t){const e={};return t?.forEach(r=>{var i;const[s,n]=r.split(":");e[s]||(e[s]={accounts:[],chains:[],events:[],methods:[]}),e[s].accounts.push(r),(i=e[s].chains)==null||i.push(`${s}:${n}`)}),e}function _m(t,e){e=e.map(i=>i.replace("did:pkh:",""));const r=Nx(e);for(const[i,s]of Object.entries(r))s.methods?s.methods=Ul(s.methods,t):s.methods=t,s.events=["chainChanged","accountsChanged"];return r}const Ox={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}},Tx={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 Q(t,e){const{message:r,code:i}=Tx[t];return{message:e?`${r} ${e}`:r,code:i}}function Qe(t,e){const{message:r,code:i}=Ox[t];return{message:e?`${r} ${e}`:r,code:i}}function Fn(t,e){return!!Array.isArray(t)}function zc(t){return Object.getPrototypeOf(t)===Object.prototype&&Object.keys(t).length}function Ur(t){return typeof t>"u"}function Kt(t,e){return e&&Ur(t)?!0:typeof t=="string"&&!!t.trim().length}function Ig(t,e){return e&&Ur(t)?!0:typeof t=="number"&&!isNaN(t)}function Dx(t,e){const{requiredNamespaces:r}=e,i=Object.keys(t.namespaces),s=Object.keys(r);let n=!0;return On(s,i)?(i.forEach(o=>{const{accounts:a,methods:u,events:c}=t.namespaces[o],l=Ia(a),h=r[o];(!On(u2(o,h),l)||!On(h.methods,u)||!On(h.events,c))&&(n=!1)}),n):!1}function ah(t){return Kt(t,!1)&&t.includes(":")?t.split(":").length===2:!1}function Rx(t){if(Kt(t,!1)&&t.includes(":")){const e=t.split(":");if(e.length===3){const r=e[0]+":"+e[1];return!!e[2]&&ah(r)}}return!1}function Mx(t){function e(r){try{return typeof new URL(r)<"u"}catch{return!1}}try{if(Kt(t,!1)){if(e(t))return!0;const r=b2(t);return e(r)}}catch{}return!1}function kx(t){var e;return(e=t?.proposer)==null?void 0:e.publicKey}function Ux(t){return t?.topic}function Lx(t,e){let r=null;return Kt(t?.publicKey,!1)||(r=Q("MISSING_OR_INVALID",`${e} controller public key should be a string`)),r}function Em(t){let e=!0;return Fn(t)?t.length&&(e=t.every(r=>Kt(r,!1))):e=!1,e}function Fx(t,e,r){let i=null;return Fn(e)&&e.length?e.forEach(s=>{i||ah(s)||(i=Qe("UNSUPPORTED_CHAINS",`${r}, chain ${s} should be a string and conform to "namespace:chainId" format`))}):ah(t)||(i=Qe("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 jx(t,e,r){let i=null;return Object.entries(t).forEach(([s,n])=>{if(i)return;const o=Fx(s,u2(s,n),`${e} ${r}`);o&&(i=o)}),i}function qx(t,e){let r=null;return Fn(t)?t.forEach(i=>{r||Rx(i)||(r=Qe("UNSUPPORTED_ACCOUNTS",`${e}, account ${i} should be a string and conform to "namespace:chainId:address" format`))}):r=Qe("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),r}function Bx(t,e){let r=null;return Object.values(t).forEach(i=>{if(r)return;const s=qx(i?.accounts,`${e} namespace`);s&&(r=s)}),r}function zx(t,e){let r=null;return Em(t?.methods)?Em(t?.events)||(r=Qe("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):r=Qe("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),r}function j2(t,e){let r=null;return Object.values(t).forEach(i=>{if(r)return;const s=zx(i,`${e}, namespace`);s&&(r=s)}),r}function Hx(t,e,r){let i=null;if(t&&zc(t)){const s=j2(t,e);s&&(i=s);const n=jx(t,e,r);n&&(i=n)}else i=Q("MISSING_OR_INVALID",`${e}, ${r} should be an object with data`);return i}function Yd(t,e){let r=null;if(t&&zc(t)){const i=j2(t,e);i&&(r=i);const s=Bx(t,e);s&&(r=s)}else r=Q("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return r}function q2(t){return Kt(t.protocol,!0)}function Vx(t,e){let r=!1;return t?t&&Fn(t)&&t.length&&t.forEach(i=>{r=q2(i)}):r=!0,r}function Kx(t){return typeof t=="number"}function Wr(t){return typeof t<"u"&&typeof t!==null}function Wx(t){return!(!t||typeof t!="object"||!t.code||!Ig(t.code,!1)||!t.message||!Kt(t.message,!1))}function Gx(t){return!(Ur(t)||!Kt(t.method,!1))}function Yx(t){return!(Ur(t)||Ur(t.result)&&Ur(t.error)||!Ig(t.id,!1)||!Kt(t.jsonrpc,!1))}function Jx(t){return!(Ur(t)||!Kt(t.name,!1))}function Im(t,e){return!(!ah(e)||!$x(t).includes(e))}function Qx(t,e,r){return Kt(r,!1)?xx(t,e).includes(r):!1}function Xx(t,e,r){return Kt(r,!1)?Px(t,e).includes(r):!1}function Am(t,e,r){let i=null;const s=Zx(t),n=e9(e),o=Object.keys(s),a=Object.keys(n),u=Sm(Object.keys(t)),c=Sm(Object.keys(e)),l=u.filter(h=>!c.includes(h));return l.length&&(i=Q("NON_CONFORMING_NAMESPACES",`${r} namespaces keys don't satisfy requiredNamespaces.
|
|
7
|
+
Required: ${l.toString()}
|
|
8
|
+
Received: ${Object.keys(e).toString()}`)),On(o,a)||(i=Q("NON_CONFORMING_NAMESPACES",`${r} namespaces chains don't satisfy required namespaces.
|
|
9
|
+
Required: ${o.toString()}
|
|
10
|
+
Approved: ${a.toString()}`)),Object.keys(e).forEach(h=>{if(!h.includes(":")||i)return;const f=Ia(e[h].accounts);f.includes(h)||(i=Q("NON_CONFORMING_NAMESPACES",`${r} namespaces accounts don't satisfy namespace accounts for ${h}
|
|
11
|
+
Required: ${h}
|
|
12
|
+
Approved: ${f.toString()}`))}),o.forEach(h=>{i||(On(s[h].methods,n[h].methods)?On(s[h].events,n[h].events)||(i=Q("NON_CONFORMING_NAMESPACES",`${r} namespaces events don't satisfy namespace events for ${h}`)):i=Q("NON_CONFORMING_NAMESPACES",`${r} namespaces methods don't satisfy namespace methods for ${h}`))}),i}function Zx(t){const e={};return Object.keys(t).forEach(r=>{var i;r.includes(":")?e[r]=t[r]:(i=t[r].chains)==null||i.forEach(s=>{e[s]={methods:t[r].methods,events:t[r].events}})}),e}function Sm(t){return[...new Set(t.map(e=>e.includes(":")?e.split(":")[0]:e))]}function e9(t){const e={};return Object.keys(t).forEach(r=>{r.includes(":")?e[r]=t[r]:Ia(t[r].accounts)?.forEach(s=>{e[s]={accounts:t[r].accounts.filter(n=>n.includes(`${s}:`)),methods:t[r].methods,events:t[r].events}})}),e}function t9(t,e){return Ig(t,!1)&&t<=e.max&&t>=e.min}function Cm(){const t=Cu();return new Promise(e=>{switch(t){case ui.browser:e(r9());break;case ui.reactNative:e(i9());break;case ui.node:e(s9());break;default:e(!0)}})}function r9(){return Su()&&navigator?.onLine}async function i9(){return un()&&typeof global<"u"&&global!=null&&global.NetInfo?(await(global==null?void 0:global.NetInfo.fetch()))?.isConnected:!0}function s9(){return!0}function n9(t){switch(Cu()){case ui.browser:o9(t);break;case ui.reactNative:a9(t);break}}function o9(t){!un()&&Su()&&(window.addEventListener("online",()=>t(!0)),window.addEventListener("offline",()=>t(!1)))}function a9(t){un()&&typeof global<"u"&&global!=null&&global.NetInfo&&global?.NetInfo.addEventListener(e=>t(e?.isConnected))}const Jd={};let tc=class{static get(e){return Jd[e]}static set(e,r){Jd[e]=r}static delete(e){delete Jd[e]}};const c9="PARSE_ERROR",u9="INVALID_REQUEST",l9="METHOD_NOT_FOUND",h9="INVALID_PARAMS",B2="INTERNAL_ERROR",Ag="SERVER_ERROR",d9=[-32700,-32600,-32601,-32602,-32603],xc={[c9]:{code:-32700,message:"Parse error"},[u9]:{code:-32600,message:"Invalid Request"},[l9]:{code:-32601,message:"Method not found"},[h9]:{code:-32602,message:"Invalid params"},[B2]:{code:-32603,message:"Internal error"},[Ag]:{code:-32e3,message:"Server error"}},z2=Ag;function f9(t){return d9.includes(t)}function $m(t){return Object.keys(xc).includes(t)?xc[t]:xc[z2]}function p9(t){const e=Object.values(xc).find(r=>r.code===t);return e||xc[z2]}function H2(t,e,r){return t.message.includes("getaddrinfo ENOTFOUND")||t.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${r} RPC url at ${e}`):t}var Qd={};var op=function(t,e){return op=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var s in i)i.hasOwnProperty(s)&&(r[s]=i[s])},op(t,e)};function g9(t,e){op(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var ap=function(){return ap=Object.assign||function(e){for(var r,i=1,s=arguments.length;i<s;i++){r=arguments[i];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},ap.apply(this,arguments)};function b9(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 s=0,i=Object.getOwnPropertySymbols(t);s<i.length;s++)e.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(t,i[s])&&(r[i[s]]=t[i[s]]);return r}function m9(t,e,r,i){var s=arguments.length,n=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(n=(s<3?o(n):s>3?o(e,r,n):o(e,r))||n);return s>3&&n&&Object.defineProperty(e,r,n),n}function y9(t,e){return function(r,i){e(r,i,t)}}function w9(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function v9(t,e,r,i){function s(n){return n instanceof r?n:new r(function(o){o(n)})}return new(r||(r=Promise))(function(n,o){function a(l){try{c(i.next(l))}catch(h){o(h)}}function u(l){try{c(i.throw(l))}catch(h){o(h)}}function c(l){l.done?n(l.value):s(l.value).then(a,u)}c((i=i.apply(t,e||[])).next())})}function _9(t,e){var r={label:0,sent:function(){if(n[0]&1)throw n[1];return n[1]},trys:[],ops:[]},i,s,n,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(c){return function(l){return u([c,l])}}function u(c){if(i)throw new TypeError("Generator is already executing.");for(;r;)try{if(i=1,s&&(n=c[0]&2?s.return:c[0]?s.throw||((n=s.return)&&n.call(s),0):s.next)&&!(n=n.call(s,c[1])).done)return n;switch(s=0,n&&(c=[c[0]&2,n.value]),c[0]){case 0:case 1:n=c;break;case 4:return r.label++,{value:c[1],done:!1};case 5:r.label++,s=c[1],c=[0];continue;case 7:c=r.ops.pop(),r.trys.pop();continue;default:if(n=r.trys,!(n=n.length>0&&n[n.length-1])&&(c[0]===6||c[0]===2)){r=0;continue}if(c[0]===3&&(!n||c[1]>n[0]&&c[1]<n[3])){r.label=c[1];break}if(c[0]===6&&r.label<n[1]){r.label=n[1],n=c;break}if(n&&r.label<n[2]){r.label=n[2],r.ops.push(c);break}n[2]&&r.ops.pop(),r.trys.pop();continue}c=e.call(t,r)}catch(l){c=[6,l],s=0}finally{i=n=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}function E9(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}function I9(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function cp(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 V2(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var i=r.call(t),s,n=[],o;try{for(;(e===void 0||e-- >0)&&!(s=i.next()).done;)n.push(s.value)}catch(a){o={error:a}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return n}function A9(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(V2(arguments[e]));return t}function S9(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var i=Array(t),s=0,e=0;e<r;e++)for(var n=arguments[e],o=0,a=n.length;o<a;o++,s++)i[s]=n[o];return i}function Hc(t){return this instanceof Hc?(this.v=t,this):new Hc(t)}function C9(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=r.apply(t,e||[]),s,n=[];return s={},o("next"),o("throw"),o("return"),s[Symbol.asyncIterator]=function(){return this},s;function o(f){i[f]&&(s[f]=function(m){return new Promise(function(g,y){n.push([f,m,g,y])>1||a(f,m)})})}function a(f,m){try{u(i[f](m))}catch(g){h(n[0][3],g)}}function u(f){f.value instanceof Hc?Promise.resolve(f.value.v).then(c,l):h(n[0][2],f)}function c(f){a("next",f)}function l(f){a("throw",f)}function h(f,m){f(m),n.shift(),n.length&&a(n[0][0],n[0][1])}}function $9(t){var e,r;return e={},i("next"),i("throw",function(s){throw s}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(s,n){e[s]=t[s]?function(o){return(r=!r)?{value:Hc(t[s](o)),done:s==="return"}:n?n(o):o}:n}}function x9(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 cp=="function"?cp(t):t[Symbol.iterator](),r={},i("next"),i("throw"),i("return"),r[Symbol.asyncIterator]=function(){return this},r);function i(n){r[n]=t[n]&&function(o){return new Promise(function(a,u){o=t[n](o),s(a,u,o.done,o.value)})}}function s(n,o,a,u){Promise.resolve(u).then(function(c){n({value:c,done:a})},o)}}function P9(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function N9(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 O9(t){return t&&t.__esModule?t:{default:t}}function T9(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function D9(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 R9=Object.freeze(Object.defineProperty({__proto__:null,get __assign(){return ap},__asyncDelegator:$9,__asyncGenerator:C9,__asyncValues:x9,__await:Hc,__awaiter:v9,__classPrivateFieldGet:T9,__classPrivateFieldSet:D9,__createBinding:E9,__decorate:m9,__exportStar:I9,__extends:g9,__generator:_9,__importDefault:O9,__importStar:N9,__makeTemplateObject:P9,__metadata:w9,__param:y9,__read:V2,__rest:b9,__spread:A9,__spreadArrays:S9,__values:cp},Symbol.toStringTag,{value:"Module"})),M9=Yv(R9);var ws={},xm;function k9(){if(xm)return ws;xm=1,Object.defineProperty(ws,"__esModule",{value:!0}),ws.isBrowserCryptoAvailable=ws.getSubtleCrypto=ws.getBrowerCrypto=void 0;function t(){return(Yr===null||Yr===void 0?void 0:Yr.crypto)||(Yr===null||Yr===void 0?void 0:Yr.msCrypto)||{}}ws.getBrowerCrypto=t;function e(){const i=t();return i.subtle||i.webkitSubtle}ws.getSubtleCrypto=e;function r(){return!!t()&&!!e()}return ws.isBrowserCryptoAvailable=r,ws}var vs={},Pm;function U9(){if(Pm)return vs;Pm=1,Object.defineProperty(vs,"__esModule",{value:!0}),vs.isBrowser=vs.isNode=vs.isReactNative=void 0;function t(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}vs.isReactNative=t;function e(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}vs.isNode=e;function r(){return!t()&&!e()}return vs.isBrowser=r,vs}var Nm;function L9(){return Nm||(Nm=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=M9;e.__exportStar(k9(),t),e.__exportStar(U9(),t)})(Qd)),Qd}var F9=L9();function hr(t=3){const e=Date.now()*Math.pow(10,t),r=Math.floor(Math.random()*Math.pow(10,t));return e+r}function li(t=6){return BigInt(hr(t))}function Lr(t,e,r){return{id:r||hr(),jsonrpc:"2.0",method:t,params:e}}function ln(t,e){return{id:t,jsonrpc:"2.0",result:e}}function Aa(t,e,r){return{id:t,jsonrpc:"2.0",error:j9(e)}}function j9(t,e){return typeof t>"u"?$m(B2):(typeof t=="string"&&(t=Object.assign(Object.assign({},$m(Ag)),{message:t})),f9(t.code)&&(t=p9(t.code)),t)}let q9=class{},B9=class extends q9{constructor(){super()}},z9=class extends B9{constructor(e){super()}};const H9="^https?:",V9="^wss?:";function K9(t){const e=t.match(new RegExp(/^\w+:/,"gi"));if(!(!e||!e.length))return e[0]}function K2(t,e){const r=K9(t);return typeof r>"u"?!1:new RegExp(e).test(r)}function Om(t){return K2(t,H9)}function Tm(t){return K2(t,V9)}function W9(t){return new RegExp("wss?://localhost(:d{2,5})?").test(t)}function W2(t){return typeof t=="object"&&"id"in t&&"jsonrpc"in t&&t.jsonrpc==="2.0"}function Sa(t){return W2(t)&&"method"in t}function Yn(t){return W2(t)&&(ir(t)||Ht(t))}function ir(t){return"result"in t}function Ht(t){return"error"in t}let Et=class extends z9{constructor(e){super(e),this.events=new sr.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(Lr(e.method,e.params||[],e.id||li().toString()),r)}async requestStrict(e,r){return new Promise(async(i,s)=>{if(!this.connection.connected)try{await this.open()}catch(n){s(n)}this.events.on(`${e.id}`,n=>{Ht(n)?s(n.error):i(n.result)});try{await this.connection.send(e,r)}catch(n){s(n)}})}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),Yn(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 G9=()=>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"),Y9=()=>typeof WebSocket<"u"||typeof global<"u"&&typeof global.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",Dm=t=>t.split("?")[0],Rm=10,J9=G9();let G2=class{constructor(e){if(this.url=e,this.events=new sr.EventEmitter,this.registering=!1,!Tm(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(us(e))}catch(r){this.onError(e.id,r)}}register(e=this.url){if(!Tm(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,s)=>{this.events.once("register_error",n=>{this.resetMaxListeners(),s(n)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return s(new Error("WebSocket connection is missing or invalid"));i(this.socket)})})}return this.url=e,this.registering=!0,new Promise((r,i)=>{const s=F9.isReactNative()?void 0:{rejectUnauthorized:!W9(e)},n=new J9(e,[],s);Y9()?n.onerror=o=>{const a=o;i(this.emitError(a.error))}:n.on("error",o=>{i(this.emitError(o))}),n.onopen=()=>{this.onOpen(n),r(n)}})}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"?Os(e.data):e.data;this.events.emit("payload",r)}onError(e,r){const i=this.parseError(r),s=i.message||i.toString(),n=Aa(e,s);this.events.emit("payload",n)}parseError(e,r=this.url){return H2(e,Dm(r),"WS")}resetMaxListeners(){this.events.getMaxListeners()>Rm&&this.events.setMaxListeners(Rm)}emitError(e){const r=this.parseError(new Error(e?.message||`WebSocket connection failed for host: ${Dm(this.url)}`));return this.events.emit("register_error",r),r}};var _c={exports:{}};_c.exports;var Mm;function Q9(){return Mm||(Mm=1,(function(t,e){var r=200,i="__lodash_hash_undefined__",s=1,n=2,o=9007199254740991,a="[object Arguments]",u="[object Array]",c="[object AsyncFunction]",l="[object Boolean]",h="[object Date]",f="[object Error]",m="[object Function]",g="[object GeneratorFunction]",y="[object Map]",C="[object Number]",S="[object Null]",A="[object Object]",D="[object Promise]",O="[object Proxy]",T="[object RegExp]",x="[object Set]",M="[object String]",U="[object Symbol]",R="[object Undefined]",L="[object WeakMap]",$="[object ArrayBuffer]",d="[object DataView]",b="[object Float32Array]",_="[object Float64Array]",w="[object Int8Array]",v="[object Int16Array]",I="[object Int32Array]",P="[object Uint8Array]",E="[object Uint8ClampedArray]",p="[object Uint16Array]",N="[object Uint32Array]",q=/[\\^$.*+?()[\]{}|]/g,H=/^\[object .+?Constructor\]$/,z=/^(?:0|[1-9]\d*)$/,V={};V[b]=V[_]=V[w]=V[v]=V[I]=V[P]=V[E]=V[p]=V[N]=!0,V[a]=V[u]=V[$]=V[l]=V[d]=V[h]=V[f]=V[m]=V[y]=V[C]=V[A]=V[T]=V[x]=V[M]=V[L]=!1;var Y=typeof Yr=="object"&&Yr&&Yr.Object===Object&&Yr,te=typeof self=="object"&&self&&self.Object===Object&&self,ie=Y||te||Function("return this")(),Z=e&&!e.nodeType&&e,ae=Z&&!0&&t&&!t.nodeType&&t,ht=ae&&ae.exports===Z,ge=ht&&Y.process,ye=(function(){try{return ge&&ge.binding&&ge.binding("util")}catch{}})(),Dt=ye&&ye.isTypedArray;function Ie(k,j){for(var K=-1,re=k==null?0:k.length,dt=0,le=[];++K<re;){var zt=k[K];j(zt,K,k)&&(le[dt++]=zt)}return le}function Te(k,j){for(var K=-1,re=j.length,dt=k.length;++K<re;)k[dt+K]=j[K];return k}function bi(k,j){for(var K=-1,re=k==null?0:k.length;++K<re;)if(j(k[K],K,k))return!0;return!1}function Ze(k,j){for(var K=-1,re=Array(k);++K<k;)re[K]=j(K);return re}function Ke(k){return function(j){return k(j)}}function Vi(k,j){return k.has(j)}function qe(k,j){return k?.[j]}function We(k){var j=-1,K=Array(k.size);return k.forEach(function(re,dt){K[++j]=[dt,re]}),K}function Ki(k,j){return function(K){return k(j(K))}}function De(k){var j=-1,K=Array(k.size);return k.forEach(function(re){K[++j]=re}),K}var Re=Array.prototype,Wi=Function.prototype,Me=Object.prototype,st=ie["__core-js_shared__"],dn=Wi.toString,Se=Me.hasOwnProperty,It=(function(){var k=/[^.]+$/.exec(st&&st.keys&&st.keys.IE_PROTO||"");return k?"Symbol(src)_1."+k:""})(),Na=Me.toString,Rt=RegExp("^"+dn.call(Se).replace(q,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),At=ht?ie.Buffer:void 0,fn=ie.Symbol,St=ie.Uint8Array,Ct=Me.propertyIsEnumerable,qu=Re.splice,Ge=fn?fn.toStringTag:void 0,$t=Object.getOwnPropertySymbols,Bu=At?At.isBuffer:void 0,Mt=Ki(Object.keys,Object),bt=no(ie,"DataView"),Rs=no(ie,"Map"),mt=no(ie,"Promise"),yt=no(ie,"Set"),so=no(ie,"WeakMap"),nt=no(Object,"create"),kt=pn(bt),zu=pn(Rs),Ut=pn(mt),Lt=pn(yt),Hu=pn(so),xt=fn?fn.prototype:void 0,wt=xt?xt.valueOf:void 0;function Gi(k){var j=-1,K=k==null?0:k.length;for(this.clear();++j<K;){var re=k[j];this.set(re[0],re[1])}}function Ft(){this.__data__=nt?nt(null):{},this.size=0}function jt(k){var j=this.has(k)&&delete this.__data__[k];return this.size-=j?1:0,j}function Vu(k){var j=this.__data__;if(nt){var K=j[k];return K===i?void 0:K}return Se.call(j,k)?j[k]:void 0}function qt(k){var j=this.__data__;return nt?j[k]!==void 0:Se.call(j,k)}function Bt(k,j){var K=this.__data__;return this.size+=this.has(k)?0:1,K[k]=nt&&j===void 0?i:j,this}Gi.prototype.clear=Ft,Gi.prototype.delete=jt,Gi.prototype.get=Vu,Gi.prototype.has=qt,Gi.prototype.set=Bt;function ei(k){var j=-1,K=k==null?0:k.length;for(this.clear();++j<K;){var re=k[j];this.set(re[0],re[1])}}function Oa(){this.__data__=[],this.size=0}function Ta(k){var j=this.__data__,K=Ku(j,k);if(K<0)return!1;var re=j.length-1;return K==re?j.pop():qu.call(j,K,1),--this.size,!0}function Da(k){var j=this.__data__,K=Ku(j,k);return K<0?void 0:j[K][1]}function Ra(k){return Ku(this.__data__,k)>-1}function Ma(k,j){var K=this.__data__,re=Ku(K,k);return re<0?(++this.size,K.push([k,j])):K[re][1]=j,this}ei.prototype.clear=Oa,ei.prototype.delete=Ta,ei.prototype.get=Da,ei.prototype.has=Ra,ei.prototype.set=Ma;function Oi(k){var j=-1,K=k==null?0:k.length;for(this.clear();++j<K;){var re=k[j];this.set(re[0],re[1])}}function ka(){this.size=0,this.__data__={hash:new Gi,map:new(Rs||ei),string:new Gi}}function Ua(k){var j=Wu(this,k).delete(k);return this.size-=j?1:0,j}function La(k){return Wu(this,k).get(k)}function Fa(k){return Wu(this,k).has(k)}function ja(k,j){var K=Wu(this,k),re=K.size;return K.set(k,j),this.size+=K.size==re?0:1,this}Oi.prototype.clear=ka,Oi.prototype.delete=Ua,Oi.prototype.get=La,Oi.prototype.has=Fa,Oi.prototype.set=ja;function Ms(k){var j=-1,K=k==null?0:k.length;for(this.__data__=new Oi;++j<K;)this.add(k[j])}function qa(k){return this.__data__.set(k,i),this}function Ba(k){return this.__data__.has(k)}Ms.prototype.add=Ms.prototype.push=qa,Ms.prototype.has=Ba;function mi(k){var j=this.__data__=new ei(k);this.size=j.size}function za(){this.__data__=new ei,this.size=0}function Ha(k){var j=this.__data__,K=j.delete(k);return this.size=j.size,K}function Va(k){return this.__data__.get(k)}function NE(k){return this.__data__.has(k)}function OE(k,j){var K=this.__data__;if(K instanceof ei){var re=K.__data__;if(!Rs||re.length<r-1)return re.push([k,j]),this.size=++K.size,this;K=this.__data__=new Oi(re)}return K.set(k,j),this.size=K.size,this}mi.prototype.clear=za,mi.prototype.delete=Ha,mi.prototype.get=Va,mi.prototype.has=NE,mi.prototype.set=OE;function TE(k,j){var K=Gu(k),re=!K&&WE(k),dt=!K&&!re&&Gh(k),le=!K&&!re&&!dt&&o0(k),zt=K||re||dt||le,nr=zt?Ze(k.length,String):[],br=nr.length;for(var Pt in k)Se.call(k,Pt)&&!(zt&&(Pt=="length"||dt&&(Pt=="offset"||Pt=="parent")||le&&(Pt=="buffer"||Pt=="byteLength"||Pt=="byteOffset")||BE(Pt,br)))&&nr.push(Pt);return nr}function Ku(k,j){for(var K=k.length;K--;)if(r0(k[K][0],j))return K;return-1}function DE(k,j,K){var re=j(k);return Gu(k)?re:Te(re,K(k))}function Ka(k){return k==null?k===void 0?R:S:Ge&&Ge in Object(k)?jE(k):KE(k)}function Xg(k){return Wa(k)&&Ka(k)==a}function Zg(k,j,K,re,dt){return k===j?!0:k==null||j==null||!Wa(k)&&!Wa(j)?k!==k&&j!==j:RE(k,j,K,re,Zg,dt)}function RE(k,j,K,re,dt,le){var zt=Gu(k),nr=Gu(j),br=zt?u:ks(k),Pt=nr?u:ks(j);br=br==a?A:br,Pt=Pt==a?A:Pt;var ti=br==A,Ti=Pt==A,Pr=br==Pt;if(Pr&&Gh(k)){if(!Gh(j))return!1;zt=!0,ti=!1}if(Pr&&!ti)return le||(le=new mi),zt||o0(k)?e0(k,j,K,re,dt,le):LE(k,j,br,K,re,dt,le);if(!(K&s)){var yi=ti&&Se.call(k,"__wrapped__"),wi=Ti&&Se.call(j,"__wrapped__");if(yi||wi){var Us=yi?k.value():k,ps=wi?j.value():j;return le||(le=new mi),dt(Us,ps,K,re,le)}}return Pr?(le||(le=new mi),FE(k,j,K,re,dt,le)):!1}function ME(k){if(!n0(k)||HE(k))return!1;var j=i0(k)?Rt:H;return j.test(pn(k))}function kE(k){return Wa(k)&&s0(k.length)&&!!V[Ka(k)]}function UE(k){if(!VE(k))return Mt(k);var j=[];for(var K in Object(k))Se.call(k,K)&&K!="constructor"&&j.push(K);return j}function e0(k,j,K,re,dt,le){var zt=K&s,nr=k.length,br=j.length;if(nr!=br&&!(zt&&br>nr))return!1;var Pt=le.get(k);if(Pt&&le.get(j))return Pt==j;var ti=-1,Ti=!0,Pr=K&n?new Ms:void 0;for(le.set(k,j),le.set(j,k);++ti<nr;){var yi=k[ti],wi=j[ti];if(re)var Us=zt?re(wi,yi,ti,j,k,le):re(yi,wi,ti,k,j,le);if(Us!==void 0){if(Us)continue;Ti=!1;break}if(Pr){if(!bi(j,function(ps,gn){if(!Vi(Pr,gn)&&(yi===ps||dt(yi,ps,K,re,le)))return Pr.push(gn)})){Ti=!1;break}}else if(!(yi===wi||dt(yi,wi,K,re,le))){Ti=!1;break}}return le.delete(k),le.delete(j),Ti}function LE(k,j,K,re,dt,le,zt){switch(K){case d:if(k.byteLength!=j.byteLength||k.byteOffset!=j.byteOffset)return!1;k=k.buffer,j=j.buffer;case $:return!(k.byteLength!=j.byteLength||!le(new St(k),new St(j)));case l:case h:case C:return r0(+k,+j);case f:return k.name==j.name&&k.message==j.message;case T:case M:return k==j+"";case y:var nr=We;case x:var br=re&s;if(nr||(nr=De),k.size!=j.size&&!br)return!1;var Pt=zt.get(k);if(Pt)return Pt==j;re|=n,zt.set(k,j);var ti=e0(nr(k),nr(j),re,dt,le,zt);return zt.delete(k),ti;case U:if(wt)return wt.call(k)==wt.call(j)}return!1}function FE(k,j,K,re,dt,le){var zt=K&s,nr=t0(k),br=nr.length,Pt=t0(j),ti=Pt.length;if(br!=ti&&!zt)return!1;for(var Ti=br;Ti--;){var Pr=nr[Ti];if(!(zt?Pr in j:Se.call(j,Pr)))return!1}var yi=le.get(k);if(yi&&le.get(j))return yi==j;var wi=!0;le.set(k,j),le.set(j,k);for(var Us=zt;++Ti<br;){Pr=nr[Ti];var ps=k[Pr],gn=j[Pr];if(re)var a0=zt?re(gn,ps,Pr,j,k,le):re(ps,gn,Pr,k,j,le);if(!(a0===void 0?ps===gn||dt(ps,gn,K,re,le):a0)){wi=!1;break}Us||(Us=Pr=="constructor")}if(wi&&!Us){var Yu=k.constructor,Ju=j.constructor;Yu!=Ju&&"constructor"in k&&"constructor"in j&&!(typeof Yu=="function"&&Yu instanceof Yu&&typeof Ju=="function"&&Ju instanceof Ju)&&(wi=!1)}return le.delete(k),le.delete(j),wi}function t0(k){return DE(k,JE,qE)}function Wu(k,j){var K=k.__data__;return zE(j)?K[typeof j=="string"?"string":"hash"]:K.map}function no(k,j){var K=qe(k,j);return ME(K)?K:void 0}function jE(k){var j=Se.call(k,Ge),K=k[Ge];try{k[Ge]=void 0;var re=!0}catch{}var dt=Na.call(k);return re&&(j?k[Ge]=K:delete k[Ge]),dt}var qE=$t?function(k){return k==null?[]:(k=Object(k),Ie($t(k),function(j){return Ct.call(k,j)}))}:QE,ks=Ka;(bt&&ks(new bt(new ArrayBuffer(1)))!=d||Rs&&ks(new Rs)!=y||mt&&ks(mt.resolve())!=D||yt&&ks(new yt)!=x||so&&ks(new so)!=L)&&(ks=function(k){var j=Ka(k),K=j==A?k.constructor:void 0,re=K?pn(K):"";if(re)switch(re){case kt:return d;case zu:return y;case Ut:return D;case Lt:return x;case Hu:return L}return j});function BE(k,j){return j=j??o,!!j&&(typeof k=="number"||z.test(k))&&k>-1&&k%1==0&&k<j}function zE(k){var j=typeof k;return j=="string"||j=="number"||j=="symbol"||j=="boolean"?k!=="__proto__":k===null}function HE(k){return!!It&&It in k}function VE(k){var j=k&&k.constructor,K=typeof j=="function"&&j.prototype||Me;return k===K}function KE(k){return Na.call(k)}function pn(k){if(k!=null){try{return dn.call(k)}catch{}try{return k+""}catch{}}return""}function r0(k,j){return k===j||k!==k&&j!==j}var WE=Xg((function(){return arguments})())?Xg:function(k){return Wa(k)&&Se.call(k,"callee")&&!Ct.call(k,"callee")},Gu=Array.isArray;function GE(k){return k!=null&&s0(k.length)&&!i0(k)}var Gh=Bu||XE;function YE(k,j){return Zg(k,j)}function i0(k){if(!n0(k))return!1;var j=Ka(k);return j==m||j==g||j==c||j==O}function s0(k){return typeof k=="number"&&k>-1&&k%1==0&&k<=o}function n0(k){var j=typeof k;return k!=null&&(j=="object"||j=="function")}function Wa(k){return k!=null&&typeof k=="object"}var o0=Dt?Ke(Dt):kE;function JE(k){return GE(k)?TE(k):UE(k)}function QE(){return[]}function XE(){return!1}t.exports=YE})(_c,_c.exports)),_c.exports}var X9=Q9();const Z9=wh(X9),Y2="wc",J2=2,up="core",ls=`${Y2}@2:${up}:`,eP={logger:"error"},tP={database:":memory:"},rP="crypto",km="client_ed25519_seed",iP=B.ONE_DAY,sP="keychain",nP="0.3",oP="messages",aP="0.3",Um=B.SIX_HOURS,cP="publisher",Q2="irn",uP="error",X2="wss://relay.walletconnect.org",lP="relayer",dr={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"},hP="_subscription",vi={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},dP=.1,lp="2.19.0",pt={link_mode:"link_mode",relay:"relay"},fP="0.3",pP="WALLETCONNECT_CLIENT_ID",Lm="WALLETCONNECT_LINK_MODE_APPS",ni={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},gP="subscription",bP="0.3",mP=B.FIVE_SECONDS*1e3,yP="pairing",wP="0.3",rc={wc_pairingDelete:{req:{ttl:B.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:B.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:B.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:B.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:B.ONE_DAY,prompt:!1,tag:0},res:{ttl:B.ONE_DAY,prompt:!1,tag:0}}},xn={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},Ri={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},vP="history",_P="0.3",EP="expirer",Si={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},IP="0.3",AP="verify-api",SP="https://verify.walletconnect.com",Z2="https://verify.walletconnect.org",Pc=Z2,CP=`${Pc}/v3`,$P=[SP,Z2],xP="echo",PP="https://echo.walletconnect.com",ns={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"},Ss={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"},Mi={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"},wn={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"},vn={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"},ic={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"},NP=.1,OP="event-client",TP=86400,DP="https://pulse.walletconnect.org/batch";function RP(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 s=0;s<t.length;s++){var n=t.charAt(s),o=n.charCodeAt(0);if(r[o]!==255)throw new TypeError(n+" is ambiguous");r[o]=s}var a=t.length,u=t.charAt(0),c=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function h(g){if(g instanceof Uint8Array||(ArrayBuffer.isView(g)?g=new Uint8Array(g.buffer,g.byteOffset,g.byteLength):Array.isArray(g)&&(g=Uint8Array.from(g))),!(g instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(g.length===0)return"";for(var y=0,C=0,S=0,A=g.length;S!==A&&g[S]===0;)S++,y++;for(var D=(A-S)*l+1>>>0,O=new Uint8Array(D);S!==A;){for(var T=g[S],x=0,M=D-1;(T!==0||x<C)&&M!==-1;M--,x++)T+=256*O[M]>>>0,O[M]=T%a>>>0,T=T/a>>>0;if(T!==0)throw new Error("Non-zero carry");C=x,S++}for(var U=D-C;U!==D&&O[U]===0;)U++;for(var R=u.repeat(y);U<D;++U)R+=t.charAt(O[U]);return R}function f(g){if(typeof g!="string")throw new TypeError("Expected String");if(g.length===0)return new Uint8Array;var y=0;if(g[y]!==" "){for(var C=0,S=0;g[y]===u;)C++,y++;for(var A=(g.length-y)*c+1>>>0,D=new Uint8Array(A);g[y];){var O=r[g.charCodeAt(y)];if(O===255)return;for(var T=0,x=A-1;(O!==0||T<S)&&x!==-1;x--,T++)O+=a*D[x]>>>0,D[x]=O%256>>>0,O=O/256>>>0;if(O!==0)throw new Error("Non-zero carry");S=T,y++}if(g[y]!==" "){for(var M=A-S;M!==A&&D[M]===0;)M++;for(var U=new Uint8Array(C+(A-M)),R=C;M!==A;)U[R++]=D[M++];return U}}}function m(g){var y=f(g);if(y)return y;throw new Error(`Non-${e} character`)}return{encode:h,decodeUnsafe:f,decode:m}}var MP=RP,kP=MP;const e3=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")},UP=t=>new TextEncoder().encode(t),LP=t=>new TextDecoder().decode(t);let FP=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")}},jP=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 t3(this,e)}},qP=class{constructor(e){this.decoders=e}or(e){return t3(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 t3=(t,e)=>new qP({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});let BP=class{constructor(e,r,i,s){this.name=e,this.prefix=r,this.baseEncode=i,this.baseDecode=s,this.encoder=new FP(e,r,i),this.decoder=new jP(e,r,s)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};const Oh=({name:t,prefix:e,encode:r,decode:i})=>new BP(t,e,r,i),Nu=({prefix:t,name:e,alphabet:r})=>{const{encode:i,decode:s}=kP(r,e);return Oh({prefix:t,name:e,encode:i,decode:n=>e3(s(n))})},zP=(t,e,r,i)=>{const s={};for(let l=0;l<e.length;++l)s[e[l]]=l;let n=t.length;for(;t[n-1]==="=";)--n;const o=new Uint8Array(n*r/8|0);let a=0,u=0,c=0;for(let l=0;l<n;++l){const h=s[t[l]];if(h===void 0)throw new SyntaxError(`Non-${i} character`);u=u<<r|h,a+=r,a>=8&&(a-=8,o[c++]=255&u>>a)}if(a>=r||255&u<<8-a)throw new SyntaxError("Unexpected end of data");return o},HP=(t,e,r)=>{const i=e[e.length-1]==="=",s=(1<<r)-1;let n="",o=0,a=0;for(let u=0;u<t.length;++u)for(a=a<<8|t[u],o+=8;o>r;)o-=r,n+=e[s&a>>o];if(o&&(n+=e[s&a<<r-o]),i)for(;n.length*r&7;)n+="=";return n},$r=({name:t,prefix:e,bitsPerChar:r,alphabet:i})=>Oh({prefix:e,name:t,encode(s){return HP(s,i,r)},decode(s){return zP(s,i,r,t)}}),VP=Oh({prefix:"\0",name:"identity",encode:t=>LP(t),decode:t=>UP(t)});var KP=Object.freeze({__proto__:null,identity:VP});const WP=$r({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var GP=Object.freeze({__proto__:null,base2:WP});const YP=$r({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var JP=Object.freeze({__proto__:null,base8:YP});const QP=Nu({prefix:"9",name:"base10",alphabet:"0123456789"});var XP=Object.freeze({__proto__:null,base10:QP});const ZP=$r({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),eN=$r({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var tN=Object.freeze({__proto__:null,base16:ZP,base16upper:eN});const rN=$r({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),iN=$r({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),sN=$r({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),nN=$r({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),oN=$r({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),aN=$r({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),cN=$r({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),uN=$r({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),lN=$r({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var hN=Object.freeze({__proto__:null,base32:rN,base32upper:iN,base32pad:sN,base32padupper:nN,base32hex:oN,base32hexupper:aN,base32hexpad:cN,base32hexpadupper:uN,base32z:lN});const dN=Nu({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),fN=Nu({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var pN=Object.freeze({__proto__:null,base36:dN,base36upper:fN});const gN=Nu({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),bN=Nu({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var mN=Object.freeze({__proto__:null,base58btc:gN,base58flickr:bN});const yN=$r({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),wN=$r({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),vN=$r({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),_N=$r({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var EN=Object.freeze({__proto__:null,base64:yN,base64pad:wN,base64url:vN,base64urlpad:_N});const r3=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),IN=r3.reduce((t,e,r)=>(t[r]=e,t),[]),AN=r3.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function SN(t){return t.reduce((e,r)=>(e+=IN[r],e),"")}function CN(t){const e=[];for(const r of t){const i=AN[r.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(i)}return new Uint8Array(e)}const $N=Oh({prefix:"🚀",name:"base256emoji",encode:SN,decode:CN});var xN=Object.freeze({__proto__:null,base256emoji:$N}),PN=i3,Fm=128,NN=-128,ON=Math.pow(2,31);function i3(t,e,r){e=e||[],r=r||0;for(var i=r;t>=ON;)e[r++]=t&255|Fm,t/=128;for(;t&NN;)e[r++]=t&255|Fm,t>>>=7;return e[r]=t|0,i3.bytes=r-i+1,e}var TN=hp,DN=128,jm=127;function hp(t,i){var r=0,i=i||0,s=0,n=i,o,a=t.length;do{if(n>=a)throw hp.bytes=0,new RangeError("Could not decode varint");o=t[n++],r+=s<28?(o&jm)<<s:(o&jm)*Math.pow(2,s),s+=7}while(o>=DN);return hp.bytes=n-i,r}var RN=Math.pow(2,7),MN=Math.pow(2,14),kN=Math.pow(2,21),UN=Math.pow(2,28),LN=Math.pow(2,35),FN=Math.pow(2,42),jN=Math.pow(2,49),qN=Math.pow(2,56),BN=Math.pow(2,63),zN=function(t){return t<RN?1:t<MN?2:t<kN?3:t<UN?4:t<LN?5:t<FN?6:t<jN?7:t<qN?8:t<BN?9:10},HN={encode:PN,decode:TN,encodingLength:zN},s3=HN;const qm=(t,e,r=0)=>(s3.encode(t,e,r),e),Bm=t=>s3.encodingLength(t),dp=(t,e)=>{const r=e.byteLength,i=Bm(t),s=i+Bm(r),n=new Uint8Array(s+r);return qm(t,n,0),qm(r,n,i),n.set(e,s),new VN(t,r,e,n)};let VN=class{constructor(e,r,i,s){this.code=e,this.size=r,this.digest=i,this.bytes=s}};const n3=({name:t,code:e,encode:r})=>new KN(t,e,r);let KN=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?dp(this.code,r):r.then(i=>dp(this.code,i))}else throw Error("Unknown type, must be binary type")}};const o3=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),WN=n3({name:"sha2-256",code:18,encode:o3("SHA-256")}),GN=n3({name:"sha2-512",code:19,encode:o3("SHA-512")});var YN=Object.freeze({__proto__:null,sha256:WN,sha512:GN});const a3=0,JN="identity",c3=e3,QN=t=>dp(a3,c3(t)),XN={code:a3,name:JN,encode:c3,digest:QN};var ZN=Object.freeze({__proto__:null,identity:XN});new TextEncoder,new TextDecoder;const zm={...KP,...GP,...JP,...XP,...tN,...hN,...pN,...mN,...EN,...xN};({...YN,...ZN});function e7(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function u3(t,e,r,i){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:i}}}const Hm=u3("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Xd=u3("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=e7(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),t7={utf8:Hm,"utf-8":Hm,hex:zm.base16,latin1:Xd,ascii:Xd,binary:Xd,...zm};function r7(t,e="utf8"){const r=t7[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,"utf8"):r.decoder.decode(`${r.prefix}${t}`)}var i7=Object.defineProperty,s7=(t,e,r)=>e in t?i7(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Xi=(t,e,r)=>s7(t,typeof e!="symbol"?e+"":e,r);let n7=class{constructor(e,r){this.core=e,this.logger=r,Xi(this,"keychain",new Map),Xi(this,"name",sP),Xi(this,"version",nP),Xi(this,"initialized",!1),Xi(this,"storagePrefix",ls),Xi(this,"init",async()=>{if(!this.initialized){const i=await this.getKeyChain();typeof i<"u"&&(this.keychain=i),this.initialized=!0}}),Xi(this,"has",i=>(this.isInitialized(),this.keychain.has(i))),Xi(this,"set",async(i,s)=>{this.isInitialized(),this.keychain.set(i,s),await this.persist()}),Xi(this,"get",i=>{this.isInitialized();const s=this.keychain.get(i);if(typeof s>"u"){const{message:n}=Q("NO_MATCHING_KEY",`${this.name}: ${i}`);throw new Error(n)}return s}),Xi(this,"del",async i=>{this.isInitialized(),this.keychain.delete(i),await this.persist()}),this.core=e,this.logger=je(r,this.name)}get context(){return it(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,d2(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?f2(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}};var o7=Object.defineProperty,a7=(t,e,r)=>e in t?o7(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,yr=(t,e,r)=>a7(t,typeof e!="symbol"?e+"":e,r);let c7=class{constructor(e,r,i){this.core=e,this.logger=r,yr(this,"name",rP),yr(this,"keychain"),yr(this,"randomSessionIdentifier",np()),yr(this,"initialized",!1),yr(this,"init",async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)}),yr(this,"hasKeys",s=>(this.isInitialized(),this.keychain.has(s))),yr(this,"getClientId",async()=>{this.isInitialized();const s=await this.getClientSeed(),n=rh(s);return dg(n.publicKey)}),yr(this,"generateKeyPair",()=>{this.isInitialized();const s=dx();return this.setPrivateKey(s.publicKey,s.privateKey)}),yr(this,"signJWT",async s=>{this.isInitialized();const n=await this.getClientSeed(),o=rh(n),a=this.randomSessionIdentifier;return await T1(a,s,iP,o)}),yr(this,"generateSharedKey",(s,n,o)=>{this.isInitialized();const a=this.getPrivateKey(s),u=fx(a,n);return this.setSymKey(u,o)}),yr(this,"setSymKey",async(s,n)=>{this.isInitialized();const o=n||Fl(s);return await this.keychain.set(o,s),o}),yr(this,"deleteKeyPair",async s=>{this.isInitialized(),await this.keychain.del(s)}),yr(this,"deleteSymKey",async s=>{this.isInitialized(),await this.keychain.del(s)}),yr(this,"encode",async(s,n,o)=>{this.isInitialized();const a=F2(o),u=us(n);if(ym(a))return bx(u,o?.encoding);if(mm(a)){const f=a.senderPublicKey,m=a.receiverPublicKey;s=await this.generateSharedKey(f,m)}const c=this.getSymKey(s),{type:l,senderPublicKey:h}=a;return px({type:l,symKey:c,message:u,senderPublicKey:h,encoding:o?.encoding})}),yr(this,"decode",async(s,n,o)=>{this.isInitialized();const a=yx(n,o);if(ym(a)){const u=mx(n,o?.encoding);return Os(u)}if(mm(a)){const u=a.receiverPublicKey,c=a.senderPublicKey;s=await this.generateSharedKey(u,c)}try{const u=this.getSymKey(s),c=gx({symKey:u,encoded:n,encoding:o?.encoding});return Os(c)}catch(u){this.logger.error(`Failed to decode message from topic: '${s}', clientId: '${await this.getClientId()}'`),this.logger.error(u)}}),yr(this,"getPayloadType",(s,n=Zs)=>{const o=Bc({encoded:s,encoding:n});return Ln(o.type)}),yr(this,"getPayloadSenderPublicKey",(s,n=Zs)=>{const o=Bc({encoded:s,encoding:n});return o.senderPublicKey?Fe(o.senderPublicKey,Dr):void 0}),this.core=e,this.logger=je(r,this.name),this.keychain=i||new n7(this.core,this.logger)}get context(){return it(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(km)}catch{e=np(),await this.keychain.set(km,e)}return r7(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}};var u7=Object.defineProperty,l7=(t,e,r)=>e in t?u7(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Zi=(t,e,r)=>l7(t,typeof e!="symbol"?e+"":e,r);let h7=class extends H5{constructor(e,r){super(e,r),this.logger=e,this.core=r,Zi(this,"messages",new Map),Zi(this,"name",oP),Zi(this,"version",aP),Zi(this,"initialized",!1),Zi(this,"storagePrefix",ls),Zi(this,"init",async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const i=await this.getRelayerMessages();typeof i<"u"&&(this.messages=i),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}}}),Zi(this,"set",async(i,s)=>{this.isInitialized();const n=$s(s);let o=this.messages.get(i);return typeof o>"u"&&(o={}),typeof o[n]<"u"||(o[n]=s,this.messages.set(i,o),await this.persist()),n}),Zi(this,"get",i=>{this.isInitialized();let s=this.messages.get(i);return typeof s>"u"&&(s={}),s}),Zi(this,"has",(i,s)=>{this.isInitialized();const n=this.get(i),o=$s(s);return typeof n[o]<"u"}),Zi(this,"del",async i=>{this.isInitialized(),this.messages.delete(i),await this.persist()}),this.logger=je(e,this.name),this.core=r}get context(){return it(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,d2(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?f2(e):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}};var d7=Object.defineProperty,f7=Object.defineProperties,p7=Object.getOwnPropertyDescriptors,Vm=Object.getOwnPropertySymbols,g7=Object.prototype.hasOwnProperty,b7=Object.prototype.propertyIsEnumerable,fp=(t,e,r)=>e in t?d7(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,hl=(t,e)=>{for(var r in e||(e={}))g7.call(e,r)&&fp(t,r,e[r]);if(Vm)for(var r of Vm(e))b7.call(e,r)&&fp(t,r,e[r]);return t},Zd=(t,e)=>f7(t,p7(e)),ki=(t,e,r)=>fp(t,typeof e!="symbol"?e+"":e,r);let m7=class extends V5{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,ki(this,"events",new sr.EventEmitter),ki(this,"name",cP),ki(this,"queue",new Map),ki(this,"publishTimeout",B.toMiliseconds(B.ONE_MINUTE)),ki(this,"initialPublishTimeout",B.toMiliseconds(B.ONE_SECOND*15)),ki(this,"needsTransportRestart",!1),ki(this,"publish",async(i,s,n)=>{var o;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:i,message:s,opts:n}});const a=n?.ttl||Um,u=oh(n),c=n?.prompt||!1,l=n?.tag||0,h=n?.id||li().toString(),f={topic:i,message:s,opts:{ttl:a,relay:u,prompt:c,tag:l,id:h,attestation:n?.attestation,tvf:n?.tvf}},m=`Failed to publish payload, please try again. id:${h} tag:${l}`;try{const g=new Promise(async y=>{const C=({id:A})=>{f.opts.id===A&&(this.removeRequestFromQueue(A),this.relayer.events.removeListener(dr.publish,C),y(f))};this.relayer.events.on(dr.publish,C);const S=Xs(new Promise((A,D)=>{this.rpcPublish({topic:i,message:s,ttl:a,prompt:c,tag:l,id:h,attestation:n?.attestation,tvf:n?.tvf}).then(A).catch(O=>{this.logger.warn(O,O?.message),D(O)})}),this.initialPublishTimeout,`Failed initial publish, retrying.... id:${h} tag:${l}`);try{await S,this.events.removeListener(dr.publish,C)}catch(A){this.queue.set(h,Zd(hl({},f),{attempt:1})),this.logger.warn(A,A?.message)}});this.logger.trace({type:"method",method:"publish",params:{id:h,topic:i,message:s,opts:n}}),await Xs(g,this.publishTimeout,m)}catch(g){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(g),(o=n?.internal)!=null&&o.throwOnFailedPublish)throw g}finally{this.queue.delete(h)}}),ki(this,"on",(i,s)=>{this.events.on(i,s)}),ki(this,"once",(i,s)=>{this.events.once(i,s)}),ki(this,"off",(i,s)=>{this.events.off(i,s)}),ki(this,"removeListener",(i,s)=>{this.events.removeListener(i,s)}),this.relayer=e,this.logger=je(r,this.name),this.registerEventListeners()}get context(){return it(this.logger)}async rpcPublish(e){var r,i,s,n;const{topic:o,message:a,ttl:u=Um,prompt:c,tag:l,id:h,attestation:f,tvf:m}=e,g={method:wc(oh().protocol).publish,params:hl({topic:o,message:a,ttl:u,prompt:c,tag:l,attestation:f},m),id:h};Ur((r=g.params)==null?void 0:r.prompt)&&((i=g.params)==null||delete i.prompt),Ur((s=g.params)==null?void 0:s.tag)&&((n=g.params)==null||delete n.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:g});const y=await this.relayer.request(g);return this.relayer.events.emit(dr.publish,e),this.logger.debug("Successfully Published Payload"),y}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async(e,r)=>{const i=e.attempt+1;this.queue.set(r,Zd(hl({},e),{attempt:i}));const{topic:s,message:n,opts:o,attestation:a}=e;this.logger.warn({},`Publisher: queue->publishing: ${e.opts.id}, tag: ${e.opts.tag}, attempt: ${i}`),await this.rpcPublish(Zd(hl({},e),{topic:s,message:n,ttl:o.ttl,prompt:o.prompt,tag:o.tag,id:o.id,attestation:a,tvf:o.tvf})),this.logger.warn({},`Publisher: queue->published: ${e.opts.id}`)})}registerEventListeners(){this.relayer.core.heartbeat.on(Hi.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(dr.connection_stalled);return}this.checkQueue()}),this.relayer.on(dr.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}};var y7=Object.defineProperty,w7=(t,e,r)=>e in t?y7(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ho=(t,e,r)=>w7(t,typeof e!="symbol"?e+"":e,r);let v7=class{constructor(){ho(this,"map",new Map),ho(this,"set",(e,r)=>{const i=this.get(e);this.exists(e,r)||this.map.set(e,[...i,r])}),ho(this,"get",e=>this.map.get(e)||[]),ho(this,"exists",(e,r)=>this.get(e).includes(r)),ho(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 s=i.filter(n=>n!==r);if(!s.length){this.map.delete(e);return}this.map.set(e,s)}),ho(this,"clear",()=>{this.map.clear()})}get topics(){return Array.from(this.map.keys())}};var _7=Object.defineProperty,E7=Object.defineProperties,I7=Object.getOwnPropertyDescriptors,Km=Object.getOwnPropertySymbols,A7=Object.prototype.hasOwnProperty,S7=Object.prototype.propertyIsEnumerable,pp=(t,e,r)=>e in t?_7(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,sc=(t,e)=>{for(var r in e||(e={}))A7.call(e,r)&&pp(t,r,e[r]);if(Km)for(var r of Km(e))S7.call(e,r)&&pp(t,r,e[r]);return t},ef=(t,e)=>E7(t,I7(e)),Je=(t,e,r)=>pp(t,typeof e!="symbol"?e+"":e,r);let C7=class extends G5{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,Je(this,"subscriptions",new Map),Je(this,"topicMap",new v7),Je(this,"events",new sr.EventEmitter),Je(this,"name",gP),Je(this,"version",bP),Je(this,"pending",new Map),Je(this,"cached",[]),Je(this,"initialized",!1),Je(this,"pendingSubscriptionWatchLabel","pending_sub_watch_label"),Je(this,"pollingInterval",20),Je(this,"storagePrefix",ls),Je(this,"subscribeTimeout",B.toMiliseconds(B.ONE_MINUTE)),Je(this,"initialSubscribeTimeout",B.toMiliseconds(B.ONE_SECOND*15)),Je(this,"clientId"),Je(this,"batchSubscribeTopicsLimit",500),Je(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),await this.restore()),this.initialized=!0}),Je(this,"subscribe",async(i,s)=>{this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:s}});try{const n=oh(s),o={topic:i,relay:n,transportType:s?.transportType};this.pending.set(i,o);const a=await this.rpcSubscribe(i,n,s);return typeof a=="string"&&(this.onSubscribe(a,o),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:s}})),a}catch(n){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(n),n}}),Je(this,"unsubscribe",async(i,s)=>{this.isInitialized(),typeof s?.id<"u"?await this.unsubscribeById(i,s.id,s):await this.unsubscribeByTopic(i,s)}),Je(this,"isSubscribed",async i=>{if(this.topics.includes(i))return!0;const s=`${this.pendingSubscriptionWatchLabel}_${i}`;return await new Promise((n,o)=>{const a=new B.Watch;a.start(s);const u=setInterval(()=>{(!this.pending.has(i)&&this.topics.includes(i)||this.cached.some(c=>c.topic===i))&&(clearInterval(u),a.stop(s),n(!0)),a.elapsed(s)>=mP&&(clearInterval(u),a.stop(s),o(new Error("Subscription resolution timeout")))},this.pollingInterval)}).catch(()=>!1)}),Je(this,"on",(i,s)=>{this.events.on(i,s)}),Je(this,"once",(i,s)=>{this.events.once(i,s)}),Je(this,"off",(i,s)=>{this.events.off(i,s)}),Je(this,"removeListener",(i,s)=>{this.events.removeListener(i,s)}),Je(this,"start",async()=>{await this.onConnect()}),Je(this,"stop",async()=>{await this.onDisconnect()}),Je(this,"restart",async()=>{await this.restore(),await this.onRestart()}),Je(this,"checkPending",async()=>{if(this.pending.size===0&&(!this.initialized||!this.relayer.connected))return;const i=[];this.pending.forEach(s=>{i.push(s)}),await this.batchSubscribe(i)}),Je(this,"registerEventListeners",()=>{this.relayer.core.heartbeat.on(Hi.pulse,async()=>{await this.checkPending()}),this.events.on(ni.created,async i=>{const s=ni.created;this.logger.info(`Emitting ${s}`),this.logger.debug({type:"event",event:s,data:i}),await this.persist()}),this.events.on(ni.deleted,async i=>{const s=ni.deleted;this.logger.info(`Emitting ${s}`),this.logger.debug({type:"event",event:s,data:i}),await this.persist()})}),this.relayer=e,this.logger=je(r,this.name),this.clientId=""}get context(){return it(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.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 s=>await this.unsubscribeById(e,s,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 s=oh(i);await this.restartToComplete({topic:e,id:r,relay:s}),await this.rpcUnsubscribe(e,r,s);const n=Qe("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,r,n),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:r,opts:i}})}catch(s){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(s),s}}async rpcSubscribe(e,r,i){var s;(!i||i?.transportType===pt.relay)&&await this.restartToComplete({topic:e,id:e,relay:r});const n={method:wc(r.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n});const o=(s=i?.internal)==null?void 0:s.throwOnFailedPublish;try{const a=await this.getSubscriptionId(e);if(i?.transportType===pt.link_mode)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(n).catch(l=>this.logger.warn(l))},B.toMiliseconds(B.ONE_SECOND)),a;const u=new Promise(async l=>{const h=f=>{f.topic===e&&(this.events.removeListener(ni.created,h),l(f.id))};this.events.on(ni.created,h);try{const f=await Xs(new Promise((m,g)=>{this.relayer.request(n).catch(y=>{this.logger.warn(y,y?.message),g(y)}).then(m)}),this.initialSubscribeTimeout,`Subscribing to ${e} failed, please try again`);this.events.removeListener(ni.created,h),l(f)}catch{}}),c=await Xs(u,this.subscribeTimeout,`Subscribing to ${e} failed, please try again`);if(!c&&o)throw new Error(`Subscribing to ${e} failed, please try again`);return c?a:null}catch(a){if(this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(dr.connection_stalled),o)throw a}return null}async rpcBatchSubscribe(e){if(!e.length)return;const r=e[0].relay,i={method:wc(r.protocol).batchSubscribe,params:{topics:e.map(s=>s.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});try{await await Xs(new Promise(s=>{this.relayer.request(i).catch(n=>this.logger.warn(n)).then(s)}),this.subscribeTimeout,"rpcBatchSubscribe failed, please try again")}catch{this.relayer.events.emit(dr.connection_stalled)}}async rpcBatchFetchMessages(e){if(!e.length)return;const r=e[0].relay,i={method:wc(r.protocol).batchFetchMessages,params:{topics:e.map(n=>n.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});let s;try{s=await await Xs(new Promise((n,o)=>{this.relayer.request(i).catch(a=>{this.logger.warn(a),o(a)}).then(n)}),this.subscribeTimeout,"rpcBatchFetchMessages failed, please try again")}catch{this.relayer.events.emit(dr.connection_stalled)}return s}rpcUnsubscribe(e,r,i){const s={method:wc(i.protocol).unsubscribe,params:{topic:e,id:r}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s}),this.relayer.request(s)}onSubscribe(e,r){this.setSubscription(e,ef(sc({},r),{id:e})),this.pending.delete(r.topic)}onBatchSubscribe(e){e.length&&e.forEach(r=>{this.setSubscription(r.id,sc({},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,sc({},r)),this.topicMap.set(r.topic,e),this.events.emit(ni.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}=Q("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(ni.deleted,ef(sc({},i),{reason:r}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(ni.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 s=e.splice(0,this.batchSubscribeTopicsLimit);await this.batchSubscribe(s)}}this.events.emit(ni.resubscribed)}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){const{message:r}=Q("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=>ef(sc({},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 CC(B.toMiliseconds(B.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}=Q("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 $s(e+await this.getClientId())}};var $7=Object.defineProperty,Wm=Object.getOwnPropertySymbols,x7=Object.prototype.hasOwnProperty,P7=Object.prototype.propertyIsEnumerable,gp=(t,e,r)=>e in t?$7(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Gm=(t,e)=>{for(var r in e||(e={}))x7.call(e,r)&&gp(t,r,e[r]);if(Wm)for(var r of Wm(e))P7.call(e,r)&&gp(t,r,e[r]);return t},$e=(t,e,r)=>gp(t,typeof e!="symbol"?e+"":e,r);let N7=class extends K5{constructor(e){super(e),$e(this,"protocol","wc"),$e(this,"version",2),$e(this,"core"),$e(this,"logger"),$e(this,"events",new sr.EventEmitter),$e(this,"provider"),$e(this,"messages"),$e(this,"subscriber"),$e(this,"publisher"),$e(this,"name",lP),$e(this,"transportExplicitlyClosed",!1),$e(this,"initialized",!1),$e(this,"connectionAttemptInProgress",!1),$e(this,"relayUrl"),$e(this,"projectId"),$e(this,"packageName"),$e(this,"bundleId"),$e(this,"hasExperiencedNetworkDisruption",!1),$e(this,"pingTimeout"),$e(this,"heartBeatTimeout",B.toMiliseconds(B.THIRTY_SECONDS+B.FIVE_SECONDS)),$e(this,"reconnectTimeout"),$e(this,"connectPromise"),$e(this,"reconnectInProgress",!1),$e(this,"requestsInFlight",[]),$e(this,"connectTimeout",B.toMiliseconds(B.ONE_SECOND*15)),$e(this,"request",async r=>{var i,s;this.logger.debug("Publishing Request Payload");const n=r.id||li().toString();await this.toEstablishConnection();try{this.logger.trace({id:n,method:r.method,topic:(i=r.params)==null?void 0:i.topic},"relayer.request - publishing...");const o=`${n}:${((s=r.params)==null?void 0:s.tag)||""}`;this.requestsInFlight.push(o);const a=await this.provider.request(r);return this.requestsInFlight=this.requestsInFlight.filter(u=>u!==o),a}catch(o){throw this.logger.debug(`Failed to Publish Request: ${n}`),o}}),$e(this,"resetPingTimeout",()=>{if(sh())try{clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var r,i,s;this.logger.debug({},"pingTimeout: Connection stalled, terminating..."),(s=(i=(r=this.provider)==null?void 0:r.connection)==null?void 0:i.socket)==null||s.terminate()},this.heartBeatTimeout)}catch(r){this.logger.warn(r,r?.message)}}),$e(this,"onPayloadHandler",r=>{this.onProviderPayload(r),this.resetPingTimeout()}),$e(this,"onConnectHandler",()=>{this.logger.warn({},"Relayer connected 🛜"),this.startPingTimeout(),this.events.emit(dr.connect)}),$e(this,"onDisconnectHandler",()=>{this.logger.warn({},"Relayer disconnected 🛑"),this.requestsInFlight=[],this.onProviderDisconnect()}),$e(this,"onProviderErrorHandler",r=>{this.logger.fatal(`Fatal socket error: ${r.message}`),this.events.emit(dr.error,r),this.logger.fatal("Fatal socket error received, closing transport"),this.transportClose()}),$e(this,"registerProviderListeners",()=>{this.provider.on(vi.payload,this.onPayloadHandler),this.provider.on(vi.connect,this.onConnectHandler),this.provider.on(vi.disconnect,this.onDisconnectHandler),this.provider.on(vi.error,this.onProviderErrorHandler)}),this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?je(e.logger,this.name):cn(Ts({level:e.logger||uP})),this.messages=new h7(this.logger,e.core),this.subscriber=new C7(this,this.logger),this.publisher=new m7(this,this.logger),this.relayUrl=e?.relayUrl||X2,this.projectId=e.projectId,hC()?this.packageName=Hb():dC()&&(this.bundleId=Hb()),this.provider={}}async init(){if(this.logger.trace("Initialized"),this.registerEventListeners(),await Promise.all([this.messages.init(),this.subscriber.init()]),this.initialized=!0,this.subscriber.hasAnyTopics)try{await this.transportOpen()}catch(e){this.logger.warn(e,e?.message)}}get context(){return it(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:pt.relay})}async subscribe(e,r){var i,s,n;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:(s=r?.internal)==null?void 0:s.throwOnFailedPublish;let a=((n=this.subscriber.topicMap.get(e))==null?void 0:n[0])||"",u;const c=l=>{l.topic===e&&(this.subscriber.off(ni.created,c),u())};return await Promise.all([new Promise(l=>{u=l,this.subscriber.on(ni.created,c)}),new Promise(async(l,h)=>{a=await this.subscriber.subscribe(e,Gm({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 Xs(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.warn("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 Cm())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,s)=>i.publishedAt-s.publishedAt);this.logger.debug(`Batch of ${r.length} message events sorted`);for(const i of r)try{await this.onMessageEvent(i)}catch(s){this.logger.warn(s,"Error while processing batch message event: "+s?.message)}this.logger.trace(`Batch of ${r.length} message events processed`)}async onLinkMessageEvent(e,r){const{topic:i}=e;if(!r.sessionExists){const s=Zt(B.FIVE_MINUTES),n={topic:i,expiry:s,relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(i,n)}this.events.emit(dr.message,e),await this.recordMessageEvent(e)}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,s)=>{const n=()=>{s(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(vi.disconnect,n),await Xs(new Promise((o,a)=>{this.provider.connect().then(o).catch(a)}),this.connectTimeout,`Socket stalled when trying to connect to ${this.relayUrl}`).catch(o=>{s(o)}).finally(()=>{this.provider.off(vi.disconnect,n),clearTimeout(this.reconnectTimeout)}),await new Promise(async(o,a)=>{const u=()=>{a(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(vi.disconnect,u),await this.subscriber.start().then(o).catch(a).finally(()=>{this.provider.off(vi.disconnect,u)})}),this.hasExperiencedNetworkDisruption=!1,i()})}catch(i){await this.subscriber.stop();const s=i;this.logger.warn({},s.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,B.toMiliseconds(r*1))),r++}}startPingTimeout(){var e,r,i,s,n;if(sh())try{(r=(e=this.provider)==null?void 0:e.connection)!=null&&r.socket&&((n=(s=(i=this.provider)==null?void 0:i.connection)==null?void 0:s.socket)==null||n.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 Et(new G2(bC({sdkVersion:lp,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){const{topic:r,message:i}=e;await this.messages.set(r,i)}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.isSubscribed(r))return this.logger.warn(`Ignoring message for non-subscribed topic ${r}`),!0;const s=this.messages.has(r,i);return s&&this.logger.warn(`Ignoring duplicate message: ${i}`),s}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),Sa(e)){if(!e.method.endsWith(hP))return;const r=e.params,{topic:i,message:s,publishedAt:n,attestation:o}=r.data,a={topic:i,message:s,publishedAt:n,transportType:pt.relay,attestation:o};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(Gm({type:"event",event:r.id},a)),this.events.emit(r.id,a),await this.acknowledgePayload(e),await this.onMessageEvent(a)}else Yn(e)&&this.events.emit(dr.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(dr.message,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){const r=ln(e.id,!0);await this.provider.connection.send(r)}unregisterProviderListeners(){this.provider.off(vi.payload,this.onPayloadHandler),this.provider.off(vi.connect,this.onConnectHandler),this.provider.off(vi.disconnect,this.onDisconnectHandler),this.provider.off(vi.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await Cm();n9(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))})}async onProviderDisconnect(){clearTimeout(this.pingTimeout),this.events.emit(dr.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},B.toMiliseconds(dP)))))}isInitialized(){if(!this.initialized){const{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){await this.confirmOnlineStateOrThrow(),!this.connected&&await this.connect()}};var O7=Object.defineProperty,Ym=Object.getOwnPropertySymbols,T7=Object.prototype.hasOwnProperty,D7=Object.prototype.propertyIsEnumerable,bp=(t,e,r)=>e in t?O7(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Jm=(t,e)=>{for(var r in e||(e={}))T7.call(e,r)&&bp(t,r,e[r]);if(Ym)for(var r of Ym(e))D7.call(e,r)&&bp(t,r,e[r]);return t},qr=(t,e,r)=>bp(t,typeof e!="symbol"?e+"":e,r);let Jn=class extends W5{constructor(e,r,i,s=ls,n=void 0){super(e,r,i,s),this.core=e,this.logger=r,this.name=i,qr(this,"map",new Map),qr(this,"version",fP),qr(this,"cached",[]),qr(this,"initialized",!1),qr(this,"getKey"),qr(this,"storagePrefix",ls),qr(this,"recentlyDeleted",[]),qr(this,"recentlyDeletedLimit",200),qr(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(o=>{this.getKey&&o!==null&&!Ur(o)?this.map.set(this.getKey(o),o):kx(o)?this.map.set(o.id,o):Ux(o)&&this.map.set(o.topic,o)}),this.cached=[],this.initialized=!0)}),qr(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())}),qr(this,"get",o=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:o}),this.getData(o))),qr(this,"getAll",o=>(this.isInitialized(),o?this.values.filter(a=>Object.keys(o).every(u=>Z9(a[u],o[u]))):this.values)),qr(this,"update",async(o,a)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:o,update:a});const u=Jm(Jm({},this.getData(o)),a);this.map.set(o,u),await this.persist()}),qr(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=je(r,this.name),this.storagePrefix=s,this.getKey=n}get context(){return it(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:s}=Q("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(s),new Error(s)}const{message:i}=Q("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}=Q("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}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}};var R7=Object.defineProperty,M7=(t,e,r)=>e in t?R7(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,we=(t,e,r)=>M7(t,typeof e!="symbol"?e+"":e,r);let k7=class{constructor(e,r){this.core=e,this.logger=r,we(this,"name",yP),we(this,"version",wP),we(this,"events",new wa),we(this,"pairings"),we(this,"initialized",!1),we(this,"storagePrefix",ls),we(this,"ignoredPayloadTypes",[xs]),we(this,"registeredMethods",[]),we(this,"init",async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))}),we(this,"register",({methods:i})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...i])]}),we(this,"create",async i=>{this.isInitialized();const s=np(),n=await this.core.crypto.setSymKey(s),o=Zt(B.FIVE_MINUTES),a={protocol:Q2},u={topic:n,expiry:o,relay:a,active:!1,methods:i?.methods},c=vm({protocol:this.core.protocol,version:this.core.version,topic:n,symKey:s,relay:a,expiryTimestamp:o,methods:i?.methods});return this.events.emit(xn.create,u),this.core.expirer.set(n,o),await this.pairings.set(n,u),await this.core.relayer.subscribe(n,{transportType:i?.transportType}),{topic:n,uri:c}}),we(this,"pair",async i=>{this.isInitialized();const s=this.core.eventClient.createEvent({properties:{topic:i?.uri,trace:[ns.pairing_started]}});this.isValidPair(i,s);const{topic:n,symKey:o,relay:a,expiryTimestamp:u,methods:c}=wm(i.uri);s.props.properties.topic=n,s.addTrace(ns.pairing_uri_validation_success),s.addTrace(ns.pairing_uri_not_expired);let l;if(this.pairings.keys.includes(n)){if(l=this.pairings.get(n),s.addTrace(ns.existing_pairing),l.active)throw s.setError(Ss.active_pairing_already_exists),new Error(`Pairing already exists: ${n}. Please try again with a new connection URI.`);s.addTrace(ns.pairing_not_expired)}const h=u||Zt(B.FIVE_MINUTES),f={topic:n,relay:a,expiry:h,active:!1,methods:c};this.core.expirer.set(n,h),await this.pairings.set(n,f),s.addTrace(ns.store_new_pairing),i.activatePairing&&await this.activate({topic:n}),this.events.emit(xn.create,f),s.addTrace(ns.emit_inactive_pairing),this.core.crypto.keychain.has(n)||await this.core.crypto.setSymKey(o,n),s.addTrace(ns.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{s.setError(Ss.no_internet_connection)}try{await this.core.relayer.subscribe(n,{relay:a})}catch(m){throw s.setError(Ss.subscribe_pairing_topic_failure),m}return s.addTrace(ns.subscribe_pairing_topic_success),f}),we(this,"activate",async({topic:i})=>{this.isInitialized();const s=Zt(B.FIVE_MINUTES);this.core.expirer.set(i,s),await this.pairings.update(i,{active:!0,expiry:s})}),we(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:s}=i;if(this.pairings.keys.includes(s)){const n=await this.sendRequest(s,"wc_pairingPing",{}),{done:o,resolve:a,reject:u}=An();this.events.once(Ue("pairing_ping",n),({error:c})=>{c?u(c):a()}),await o()}}),we(this,"updateExpiry",async({topic:i,expiry:s})=>{this.isInitialized(),await this.pairings.update(i,{expiry:s})}),we(this,"updateMetadata",async({topic:i,metadata:s})=>{this.isInitialized(),await this.pairings.update(i,{peerMetadata:s})}),we(this,"getPairings",()=>(this.isInitialized(),this.pairings.values)),we(this,"disconnect",async i=>{this.isInitialized(),await this.isValidDisconnect(i);const{topic:s}=i;this.pairings.keys.includes(s)&&(await this.sendRequest(s,"wc_pairingDelete",Qe("USER_DISCONNECTED")),await this.deletePairing(s))}),we(this,"formatUriFromPairing",i=>{this.isInitialized();const{topic:s,relay:n,expiry:o,methods:a}=i,u=this.core.crypto.keychain.get(s);return vm({protocol:this.core.protocol,version:this.core.version,topic:s,symKey:u,relay:n,expiryTimestamp:o,methods:a})}),we(this,"sendRequest",async(i,s,n)=>{const o=Lr(s,n),a=await this.core.crypto.encode(i,o),u=rc[s].req;return this.core.history.set(i,o),this.core.relayer.publish(i,a,u),o.id}),we(this,"sendResult",async(i,s,n)=>{const o=ln(i,n),a=await this.core.crypto.encode(s,o),u=(await this.core.history.get(s,i)).request.method,c=rc[u].res;await this.core.relayer.publish(s,a,c),await this.core.history.resolve(o)}),we(this,"sendError",async(i,s,n)=>{const o=Aa(i,n),a=await this.core.crypto.encode(s,o),u=(await this.core.history.get(s,i)).request.method,c=rc[u]?rc[u].res:rc.unregistered_method.res;await this.core.relayer.publish(s,a,c),await this.core.history.resolve(o)}),we(this,"deletePairing",async(i,s)=>{await this.core.relayer.unsubscribe(i),await Promise.all([this.pairings.delete(i,Qe("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(i),s?Promise.resolve():this.core.expirer.del(i)])}),we(this,"cleanup",async()=>{const i=this.pairings.getAll().filter(s=>Ws(s.expiry));await Promise.all(i.map(s=>this.deletePairing(s.topic)))}),we(this,"onRelayEventRequest",i=>{const{topic:s,payload:n}=i;switch(n.method){case"wc_pairingPing":return this.onPairingPingRequest(s,n);case"wc_pairingDelete":return this.onPairingDeleteRequest(s,n);default:return this.onUnknownRpcMethodRequest(s,n)}}),we(this,"onRelayEventResponse",async i=>{const{topic:s,payload:n}=i,o=(await this.core.history.get(s,n.id)).request.method;return o==="wc_pairingPing"?this.onPairingPingResponse(s,n):this.onUnknownRpcMethodResponse(o)}),we(this,"onPairingPingRequest",async(i,s)=>{const{id:n}=s;try{this.isValidPing({topic:i}),await this.sendResult(n,i,!0),this.events.emit(xn.ping,{id:n,topic:i})}catch(o){await this.sendError(n,i,o),this.logger.error(o)}}),we(this,"onPairingPingResponse",(i,s)=>{const{id:n}=s;setTimeout(()=>{ir(s)?this.events.emit(Ue("pairing_ping",n),{}):Ht(s)&&this.events.emit(Ue("pairing_ping",n),{error:s.error})},500)}),we(this,"onPairingDeleteRequest",async(i,s)=>{const{id:n}=s;try{this.isValidDisconnect({topic:i}),await this.deletePairing(i),this.events.emit(xn.delete,{id:n,topic:i})}catch(o){await this.sendError(n,i,o),this.logger.error(o)}}),we(this,"onUnknownRpcMethodRequest",async(i,s)=>{const{id:n,method:o}=s;try{if(this.registeredMethods.includes(o))return;const a=Qe("WC_METHOD_UNSUPPORTED",o);await this.sendError(n,i,a),this.logger.error(a)}catch(a){await this.sendError(n,i,a),this.logger.error(a)}}),we(this,"onUnknownRpcMethodResponse",i=>{this.registeredMethods.includes(i)||this.logger.error(Qe("WC_METHOD_UNSUPPORTED",i))}),we(this,"isValidPair",(i,s)=>{var n;if(!Wr(i)){const{message:a}=Q("MISSING_OR_INVALID",`pair() params: ${i}`);throw s.setError(Ss.malformed_pairing_uri),new Error(a)}if(!Mx(i.uri)){const{message:a}=Q("MISSING_OR_INVALID",`pair() uri: ${i.uri}`);throw s.setError(Ss.malformed_pairing_uri),new Error(a)}const o=wm(i?.uri);if(!((n=o?.relay)!=null&&n.protocol)){const{message:a}=Q("MISSING_OR_INVALID","pair() uri#relay-protocol");throw s.setError(Ss.malformed_pairing_uri),new Error(a)}if(!(o!=null&&o.symKey)){const{message:a}=Q("MISSING_OR_INVALID","pair() uri#symKey");throw s.setError(Ss.malformed_pairing_uri),new Error(a)}if(o!=null&&o.expiryTimestamp&&B.toMiliseconds(o?.expiryTimestamp)<Date.now()){s.setError(Ss.pairing_expired);const{message:a}=Q("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw new Error(a)}}),we(this,"isValidPing",async i=>{if(!Wr(i)){const{message:n}=Q("MISSING_OR_INVALID",`ping() params: ${i}`);throw new Error(n)}const{topic:s}=i;await this.isValidPairingTopic(s)}),we(this,"isValidDisconnect",async i=>{if(!Wr(i)){const{message:n}=Q("MISSING_OR_INVALID",`disconnect() params: ${i}`);throw new Error(n)}const{topic:s}=i;await this.isValidPairingTopic(s)}),we(this,"isValidPairingTopic",async i=>{if(!Kt(i,!1)){const{message:s}=Q("MISSING_OR_INVALID",`pairing topic should be a string: ${i}`);throw new Error(s)}if(!this.pairings.keys.includes(i)){const{message:s}=Q("NO_MATCHING_KEY",`pairing topic doesn't exist: ${i}`);throw new Error(s)}if(Ws(this.pairings.get(i).expiry)){await this.deletePairing(i);const{message:s}=Q("EXPIRED",`pairing topic: ${i}`);throw new Error(s)}}),this.core=e,this.logger=je(r,this.name),this.pairings=new Jn(this.core,this.logger,this.name,this.storagePrefix)}get context(){return it(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(dr.message,async e=>{const{topic:r,message:i,transportType:s}=e;if(!this.pairings.keys.includes(r)||s===pt.link_mode||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i)))return;const n=await this.core.crypto.decode(r,i);try{Sa(n)?(this.core.history.set(r,n),this.onRelayEventRequest({topic:r,payload:n})):Yn(n)&&(await this.core.history.resolve(n),await this.onRelayEventResponse({topic:r,payload:n}),this.core.history.delete(r,n.id))}catch(o){this.logger.error(o)}})}registerExpirerEvents(){this.core.expirer.on(Si.expired,async e=>{const{topic:r}=g2(e.target);r&&this.pairings.keys.includes(r)&&(await this.deletePairing(r,!0),this.events.emit(xn.expire,{topic:r}))})}};var U7=Object.defineProperty,L7=(t,e,r)=>e in t?U7(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,wr=(t,e,r)=>L7(t,typeof e!="symbol"?e+"":e,r);let F7=class extends z5{constructor(e,r){super(e,r),this.core=e,this.logger=r,wr(this,"records",new Map),wr(this,"events",new sr.EventEmitter),wr(this,"name",vP),wr(this,"version",_P),wr(this,"cached",[]),wr(this,"initialized",!1),wr(this,"storagePrefix",ls),wr(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)}),wr(this,"set",(i,s,n)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:i,request:s,chainId:n}),this.records.has(s.id))return;const o={id:s.id,topic:i,request:{method:s.method,params:s.params||null},chainId:n,expiry:Zt(B.THIRTY_DAYS)};this.records.set(o.id,o),this.persist(),this.events.emit(Ri.created,o)}),wr(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 s=await this.getRecord(i.id);typeof s.response>"u"&&(s.response=Ht(i)?{error:i.error}:{result:i.result},this.records.set(s.id,s),this.persist(),this.events.emit(Ri.updated,s))}),wr(this,"get",async(i,s)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:i,id:s}),await this.getRecord(s))),wr(this,"delete",(i,s)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:s}),this.values.forEach(n=>{if(n.topic===i){if(typeof s<"u"&&n.id!==s)return;this.records.delete(n.id),this.events.emit(Ri.deleted,n)}}),this.persist()}),wr(this,"exists",async(i,s)=>(this.isInitialized(),this.records.has(s)?(await this.getRecord(s)).topic===i:!1)),wr(this,"on",(i,s)=>{this.events.on(i,s)}),wr(this,"once",(i,s)=>{this.events.once(i,s)}),wr(this,"off",(i,s)=>{this.events.off(i,s)}),wr(this,"removeListener",(i,s)=>{this.events.removeListener(i,s)}),this.logger=je(r,this.name)}get context(){return it(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:Lr(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}=Q("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return r}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(Ri.sync)}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:r}=Q("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(Ri.created,e=>{const r=Ri.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.events.on(Ri.updated,e=>{const r=Ri.updated;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.events.on(Ri.deleted,e=>{const r=Ri.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.core.heartbeat.on(Hi.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(r=>{B.toMiliseconds(r.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${r.id}`),this.records.delete(r.id),this.events.emit(Ri.deleted,r,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){const{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}};var j7=Object.defineProperty,q7=(t,e,r)=>e in t?j7(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Nr=(t,e,r)=>q7(t,typeof e!="symbol"?e+"":e,r);let B7=class extends Y5{constructor(e,r){super(e,r),this.core=e,this.logger=r,Nr(this,"expirations",new Map),Nr(this,"events",new sr.EventEmitter),Nr(this,"name",EP),Nr(this,"version",IP),Nr(this,"cached",[]),Nr(this,"initialized",!1),Nr(this,"storagePrefix",ls),Nr(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)}),Nr(this,"has",i=>{try{const s=this.formatTarget(i);return typeof this.getExpiration(s)<"u"}catch{return!1}}),Nr(this,"set",(i,s)=>{this.isInitialized();const n=this.formatTarget(i),o={target:n,expiry:s};this.expirations.set(n,o),this.checkExpiry(n,o),this.events.emit(Si.created,{target:n,expiration:o})}),Nr(this,"get",i=>{this.isInitialized();const s=this.formatTarget(i);return this.getExpiration(s)}),Nr(this,"del",i=>{if(this.isInitialized(),this.has(i)){const s=this.formatTarget(i),n=this.getExpiration(s);this.expirations.delete(s),this.events.emit(Si.deleted,{target:s,expiration:n})}}),Nr(this,"on",(i,s)=>{this.events.on(i,s)}),Nr(this,"once",(i,s)=>{this.events.once(i,s)}),Nr(this,"off",(i,s)=>{this.events.off(i,s)}),Nr(this,"removeListener",(i,s)=>{this.events.removeListener(i,s)}),this.logger=je(r,this.name)}get context(){return it(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 mC(e);if(typeof e=="number")return yC(e);const{message:r}=Q("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(Si.sync)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:r}=Q("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}=Q("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(i),new Error(i)}return r}checkExpiry(e,r){const{expiry:i}=r;B.toMiliseconds(i)-Date.now()<=0&&this.expire(e,r)}expire(e,r){this.expirations.delete(e),this.events.emit(Si.expired,{target:e,expiration:r})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,r)=>this.checkExpiry(r,e))}registerEventListeners(){this.core.heartbeat.on(Hi.pulse,()=>this.checkExpirations()),this.events.on(Si.created,e=>{const r=Si.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(Si.expired,e=>{const r=Si.expired;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(Si.deleted,e=>{const r=Si.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}};var z7=Object.defineProperty,H7=(t,e,r)=>e in t?z7(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Gt=(t,e,r)=>H7(t,typeof e!="symbol"?e+"":e,r);let V7=class extends J5{constructor(e,r,i){super(e,r,i),this.core=e,this.logger=r,this.store=i,Gt(this,"name",AP),Gt(this,"abortController"),Gt(this,"isDevEnv"),Gt(this,"verifyUrlV3",CP),Gt(this,"storagePrefix",ls),Gt(this,"version",J2),Gt(this,"publicKey"),Gt(this,"fetchPromise"),Gt(this,"init",async()=>{var s;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&B.toMiliseconds((s=this.publicKey)==null?void 0:s.expiresAt)<Date.now()&&(this.logger.debug("verify v2 public key expired"),await this.removePublicKey()))}),Gt(this,"register",async s=>{if(!Su()||this.isDevEnv)return;const n=window.location.origin,{id:o,decryptedId:a}=s,u=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${n}&id=${o}&decryptedId=${a}`;try{const c=Qr.getDocument(),l=this.startAbortTimer(B.ONE_SECOND*5),h=await new Promise((f,m)=>{const g=()=>{window.removeEventListener("message",C),c.body.removeChild(y),m("attestation aborted")};this.abortController.signal.addEventListener("abort",g);const y=c.createElement("iframe");y.src=u,y.style.display="none",y.addEventListener("error",g,{signal:this.abortController.signal});const C=S=>{if(S.data&&typeof S.data=="string")try{const A=JSON.parse(S.data);if(A.type==="verify_attestation"){if(oa(A.attestation).payload.id!==o)return;clearInterval(l),c.body.removeChild(y),this.abortController.signal.removeEventListener("abort",g),window.removeEventListener("message",C),f(A.attestation===null?"":A.attestation)}}catch(A){this.logger.warn(A)}};c.body.appendChild(y),window.addEventListener("message",C,{signal:this.abortController.signal})});return this.logger.debug("jwt attestation",h),h}catch(c){this.logger.warn(c)}return""}),Gt(this,"resolve",async s=>{if(this.isDevEnv)return"";const{attestationId:n,hash:o,encryptedId:a}=s;if(n===""){this.logger.debug("resolve: attestationId is empty, skipping");return}if(n){if(oa(n).payload.id!==a)return;const c=await this.isValidJwtAttestation(n);if(c){if(!c.isVerified){this.logger.warn("resolve: jwt attestation: origin url not verified");return}return c}}if(!o)return;const u=this.getVerifyUrl(s?.verifyUrl);return this.fetchAttestation(o,u)}),Gt(this,"fetchAttestation",async(s,n)=>{this.logger.debug(`resolving attestation: ${s} from url: ${n}`);const o=this.startAbortTimer(B.ONE_SECOND*5),a=await fetch(`${n}/attestation/${s}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(o),a.status===200?await a.json():void 0}),Gt(this,"getVerifyUrl",s=>{let n=s||Pc;return $P.includes(n)||(this.logger.info(`verify url: ${n}, not included in trusted list, assigning default: ${Pc}`),n=Pc),n}),Gt(this,"fetchPublicKey",async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);const s=this.startAbortTimer(B.FIVE_SECONDS),n=await fetch(`${this.verifyUrlV3}/public-key`,{signal:this.abortController.signal});return clearTimeout(s),await n.json()}catch(s){this.logger.warn(s)}}),Gt(this,"persistPublicKey",async s=>{this.logger.debug("persisting public key to local storage",s),await this.store.setItem(this.storeKey,s),this.publicKey=s}),Gt(this,"removePublicKey",async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0}),Gt(this,"isValidJwtAttestation",async s=>{const n=await this.getPublicKey();try{if(n)return this.validateAttestation(s,n)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation")}const o=await this.fetchAndPersistPublicKey();try{if(o)return this.validateAttestation(s,o)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation")}}),Gt(this,"getPublicKey",async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey()),Gt(this,"fetchAndPersistPublicKey",async()=>{if(this.fetchPromise)return await this.fetchPromise,this.publicKey;this.fetchPromise=new Promise(async n=>{const o=await this.fetchPublicKey();o&&(await this.persistPublicKey(o),n(o))});const s=await this.fetchPromise;return this.fetchPromise=void 0,s}),Gt(this,"validateAttestation",(s,n)=>{const o=Ex(s,n.publicKey),a={hasExpired:B.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=je(r,this.name),this.abortController=new AbortController,this.isDevEnv=gg(),this.init()}get storeKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//verify:public:key"}get context(){return it(this.logger)}startAbortTimer(e){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),B.toMiliseconds(e))}};var K7=Object.defineProperty,W7=(t,e,r)=>e in t?K7(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Qm=(t,e,r)=>W7(t,typeof e!="symbol"?e+"":e,r);let G7=class extends Q5{constructor(e,r){super(e,r),this.projectId=e,this.logger=r,Qm(this,"context",xP),Qm(this,"registerDeviceToken",async i=>{const{clientId:s,token:n,notificationType:o,enableEncrypted:a=!1}=i,u=`${PP}/${this.projectId}/clients`;await fetch(u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:s,type:o,token:n,always_raw:a})})}),this.logger=je(r,this.context)}};var Y7=Object.defineProperty,Xm=Object.getOwnPropertySymbols,J7=Object.prototype.hasOwnProperty,Q7=Object.prototype.propertyIsEnumerable,mp=(t,e,r)=>e in t?Y7(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,nc=(t,e)=>{for(var r in e||(e={}))J7.call(e,r)&&mp(t,r,e[r]);if(Xm)for(var r of Xm(e))Q7.call(e,r)&&mp(t,r,e[r]);return t},or=(t,e,r)=>mp(t,typeof e!="symbol"?e+"":e,r);let X7=class extends X5{constructor(e,r,i=!0){super(e,r,i),this.core=e,this.logger=r,or(this,"context",OP),or(this,"storagePrefix",ls),or(this,"storageVersion",NP),or(this,"events",new Map),or(this,"shouldPersist",!1),or(this,"init",async()=>{if(!gg())try{const s={eventId:Kb(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:h2(this.core.relayer.protocol,this.core.relayer.version,lp)}}};await this.sendEvent([s])}catch(s){this.logger.warn(s)}}),or(this,"createEvent",s=>{const{event:n="ERROR",type:o="",properties:{topic:a,trace:u}}=s,c=Kb(),l=this.core.projectId||"",h=Date.now(),f=nc({eventId:c,timestamp:h,props:{event:n,type:o,properties:{topic:a,trace:u}},bundleId:l,domain:this.getAppDomain()},this.setMethods(c));return this.telemetryEnabled&&(this.events.set(c,f),this.shouldPersist=!0),f}),or(this,"getEvent",s=>{const{eventId:n,topic:o}=s;if(n)return this.events.get(n);const a=Array.from(this.events.values()).find(u=>u.props.properties.topic===o);if(a)return nc(nc({},a),this.setMethods(a.eventId))}),or(this,"deleteEvent",s=>{const{eventId:n}=s;this.events.delete(n),this.shouldPersist=!0}),or(this,"setEventListeners",()=>{this.core.heartbeat.on(Hi.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(s=>{B.fromMiliseconds(Date.now())-B.fromMiliseconds(s.timestamp)>TP&&(this.events.delete(s.eventId),this.shouldPersist=!0)})})}),or(this,"setMethods",s=>({addTrace:n=>this.addTrace(s,n),setError:n=>this.setError(s,n)})),or(this,"addTrace",(s,n)=>{const o=this.events.get(s);o&&(o.props.properties.trace.push(n),this.events.set(s,o),this.shouldPersist=!0)}),or(this,"setError",(s,n)=>{const o=this.events.get(s);o&&(o.props.type=n,o.timestamp=Date.now(),this.events.set(s,o),this.shouldPersist=!0)}),or(this,"persist",async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1}),or(this,"restore",async()=>{try{const s=await this.core.storage.getItem(this.storageKey)||[];if(!s.length)return;s.forEach(n=>{this.events.set(n.eventId,nc(nc({},n),this.setMethods(n.eventId)))})}catch(s){this.logger.warn(s)}}),or(this,"submit",async()=>{if(!this.telemetryEnabled||this.events.size===0)return;const s=[];for(const[n,o]of this.events)o.props.type&&s.push(o);if(s.length!==0)try{if((await this.sendEvent(s)).ok)for(const n of s)this.events.delete(n.eventId),this.shouldPersist=!0}catch(n){this.logger.warn(n)}}),or(this,"sendEvent",async s=>{const n=this.getAppDomain()?"":"&sp=desktop";return await fetch(`${DP}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${lp}${n}`,{method:"POST",body:JSON.stringify(s)})}),or(this,"getAppDomain",()=>l2().url),this.logger=je(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 Z7=Object.defineProperty,Zm=Object.getOwnPropertySymbols,eO=Object.prototype.hasOwnProperty,tO=Object.prototype.propertyIsEnumerable,yp=(t,e,r)=>e in t?Z7(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ey=(t,e)=>{for(var r in e||(e={}))eO.call(e,r)&&yp(t,r,e[r]);if(Zm)for(var r of Zm(e))tO.call(e,r)&&yp(t,r,e[r]);return t},ot=(t,e,r)=>yp(t,typeof e!="symbol"?e+"":e,r);let rO=class l3 extends F5{constructor(e){var r;super(e),ot(this,"protocol",Y2),ot(this,"version",J2),ot(this,"name",up),ot(this,"relayUrl"),ot(this,"projectId"),ot(this,"customStoragePrefix"),ot(this,"events",new sr.EventEmitter),ot(this,"logger"),ot(this,"heartbeat"),ot(this,"relayer"),ot(this,"crypto"),ot(this,"storage"),ot(this,"history"),ot(this,"expirer"),ot(this,"pairing"),ot(this,"verify"),ot(this,"echoClient"),ot(this,"linkModeSupportedApps"),ot(this,"eventClient"),ot(this,"initialized",!1),ot(this,"logChunkController"),ot(this,"on",(o,a)=>this.events.on(o,a)),ot(this,"once",(o,a)=>this.events.once(o,a)),ot(this,"off",(o,a)=>this.events.off(o,a)),ot(this,"removeListener",(o,a)=>this.events.removeListener(o,a)),ot(this,"dispatchEnvelope",({topic:o,message:a,sessionExists:u})=>{if(!o||!a)return;const c={topic:o,message:a,publishedAt:Date.now(),transportType:pt.link_mode};this.relayer.onLinkMessageEvent(c,{sessionExists:u})}),this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||X2,this.customStoragePrefix=e!=null&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";const i=Ts({level:typeof e?.logger=="string"&&e.logger?e.logger:eP.logger,name:up}),{logger:s,chunkLoggerController:n}=sg({opts:i,maxSizeInBytes:e?.maxLogBlobSizeInBytes,loggerOverride:e?.logger});this.logChunkController=n,(r=this.logChunkController)!=null&&r.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var o,a;(o=this.logChunkController)!=null&&o.downloadLogsBlobInBrowser&&((a=this.logChunkController)==null||a.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=je(s,this.name),this.heartbeat=new Zv,this.crypto=new c7(this,this.logger,e?.keychain),this.history=new F7(this,this.logger),this.expirer=new B7(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new r1(ey(ey({},tP),e?.storageOptions)),this.relayer=new N7({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new k7(this,this.logger),this.verify=new V7(this,this.logger,this.storage),this.echoClient=new G7(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new X7(this,this.logger,e?.telemetryEnabled)}static async init(e){const r=new l3(e);await r.initialize();const i=await r.crypto.getClientId();return await r.storage.setItem(pP,i),r}get context(){return it(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(Lm,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(Lm)||[],this.initialized=!0,this.logger.info("Core Initialization Success")}catch(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}};const iO=rO;var sO=Object.defineProperty,nO=(t,e,r)=>e in t?sO(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ty=(t,e,r)=>nO(t,typeof e!="symbol"?e+"":e,r);let oO=class{constructor(e){this.opts=e,ty(this,"protocol","wc"),ty(this,"version",2)}},aO=class{constructor(e){this.client=e}};const h3="wc",d3=2,f3="client",Sg=`${h3}@${d3}:${f3}:`,tf={name:f3,logger:"error"},ry="WALLETCONNECT_DEEPLINK_CHOICE",cO="proposal",iy="Proposal expired",uO="session",fo=B.SEVEN_DAYS,lO="engine",ar={wc_sessionPropose:{req:{ttl:B.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:B.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:B.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:B.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:B.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:B.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:B.ONE_DAY,prompt:!1,tag:1104},res:{ttl:B.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:B.ONE_DAY,prompt:!1,tag:1106},res:{ttl:B.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:B.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:B.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:B.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:B.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:B.ONE_DAY,prompt:!1,tag:1112},res:{ttl:B.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:B.ONE_DAY,prompt:!1,tag:1114},res:{ttl:B.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:B.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:B.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:B.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:B.FIVE_MINUTES,prompt:!1,tag:1119}}},rf={min:B.FIVE_MINUTES,max:B.SEVEN_DAYS},es={idle:"IDLE",active:"ACTIVE"},sy={eth_sendTransaction:{key:""},eth_sendRawTransaction:{key:""},wallet_sendCalls:{key:""},solana_signTransaction:{key:"signature"},solana_signAllTransactions:{key:"transactions"},solana_signAndSendTransaction:{key:"signature"}},hO="request",dO=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],fO="wc",pO="auth",gO="authKeys",bO="pairingTopics",mO="requests",Th=`${fO}@${1.5}:${pO}:`,jl=`${Th}:PUB_KEY`;var yO=Object.defineProperty,wO=Object.defineProperties,vO=Object.getOwnPropertyDescriptors,ny=Object.getOwnPropertySymbols,_O=Object.prototype.hasOwnProperty,EO=Object.prototype.propertyIsEnumerable,wp=(t,e,r)=>e in t?yO(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Nt=(t,e)=>{for(var r in e||(e={}))_O.call(e,r)&&wp(t,r,e[r]);if(ny)for(var r of ny(e))EO.call(e,r)&&wp(t,r,e[r]);return t},Br=(t,e)=>wO(t,vO(e)),G=(t,e,r)=>wp(t,typeof e!="symbol"?e+"":e,r);let IO=class extends aO{constructor(e){super(e),G(this,"name",lO),G(this,"events",new wa),G(this,"initialized",!1),G(this,"requestQueue",{state:es.idle,queue:[]}),G(this,"sessionRequestQueue",{state:es.idle,queue:[]}),G(this,"requestQueueDelay",B.ONE_SECOND),G(this,"expectedPairingMethodMap",new Map),G(this,"recentlyDeletedMap",new Map),G(this,"recentlyDeletedLimit",200),G(this,"relayMessageCache",[]),G(this,"pendingSessions",new Map),G(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(ar)}),this.initialized=!0,setTimeout(()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},B.toMiliseconds(this.requestQueueDelay)))}),G(this,"connect",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();const i=Br(Nt({},r),{requiredNamespaces:r.requiredNamespaces||{},optionalNamespaces:r.optionalNamespaces||{}});await this.isValidConnect(i);const{pairingTopic:s,requiredNamespaces:n,optionalNamespaces:o,sessionProperties:a,relays:u}=i;let c=s,l,h=!1;try{if(c){const T=this.client.core.pairing.pairings.get(c);this.client.logger.warn("connect() with existing pairing topic is deprecated and will be removed in the next major release."),h=T.active}}catch(T){throw this.client.logger.error(`connect() -> pairing.get(${c}) failed`),T}if(!c||!h){const{topic:T,uri:x}=await this.client.core.pairing.create();c=T,l=x}if(!c){const{message:T}=Q("NO_MATCHING_KEY",`connect() pairing topic: ${c}`);throw new Error(T)}const f=await this.client.core.crypto.generateKeyPair(),m=ar.wc_sessionPropose.req.ttl||B.FIVE_MINUTES,g=Zt(m),y=Br(Nt({requiredNamespaces:n,optionalNamespaces:o,relays:u??[{protocol:Q2}],proposer:{publicKey:f,metadata:this.client.metadata},expiryTimestamp:g,pairingTopic:c},a&&{sessionProperties:a}),{id:hr()}),C=Ue("session_connect",y.id),{reject:S,resolve:A,done:D}=An(m,iy),O=({id:T})=>{T===y.id&&(this.client.events.off("proposal_expire",O),this.pendingSessions.delete(y.id),this.events.emit(C,{error:{message:iy,code:0}}))};return this.client.events.on("proposal_expire",O),this.events.once(C,({error:T,session:x})=>{this.client.events.off("proposal_expire",O),T?S(T):x&&A(x)}),await this.sendRequest({topic:c,method:"wc_sessionPropose",params:y,throwOnFailedPublish:!0,clientRpcId:y.id}),await this.setProposal(y.id,y),{uri:l,approval:D}}),G(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}}),G(this,"approve",async r=>{var i,s,n;const o=this.client.core.eventClient.createEvent({properties:{topic:(i=r?.id)==null?void 0:i.toString(),trace:[Mi.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(U){throw o.setError(wn.no_internet_connection),U}try{await this.isValidProposalId(r?.id)}catch(U){throw this.client.logger.error(`approve() -> proposal.get(${r?.id}) failed`),o.setError(wn.proposal_not_found),U}try{await this.isValidApprove(r)}catch(U){throw this.client.logger.error("approve() -> isValidApprove() failed"),o.setError(wn.session_approve_namespace_validation_failure),U}const{id:a,relayProtocol:u,namespaces:c,sessionProperties:l,sessionConfig:h}=r,f=this.client.proposal.get(a);this.client.core.eventClient.deleteEvent({eventId:o.eventId});const{pairingTopic:m,proposer:g,requiredNamespaces:y,optionalNamespaces:C}=f;let S=(s=this.client.core.eventClient)==null?void 0:s.getEvent({topic:m});S||(S=(n=this.client.core.eventClient)==null?void 0:n.createEvent({type:Mi.session_approve_started,properties:{topic:m,trace:[Mi.session_approve_started,Mi.session_namespaces_validation_success]}}));const A=await this.client.core.crypto.generateKeyPair(),D=g.publicKey,O=await this.client.core.crypto.generateSharedKey(A,D),T=Nt(Nt({relay:{protocol:u??"irn"},namespaces:c,controller:{publicKey:A,metadata:this.client.metadata},expiry:Zt(fo)},l&&{sessionProperties:l}),h&&{sessionConfig:h}),x=pt.relay;S.addTrace(Mi.subscribing_session_topic);try{await this.client.core.relayer.subscribe(O,{transportType:x})}catch(U){throw S.setError(wn.subscribe_session_topic_failure),U}S.addTrace(Mi.subscribe_session_topic_success);const M=Br(Nt({},T),{topic:O,requiredNamespaces:y,optionalNamespaces:C,pairingTopic:m,acknowledged:!1,self:T.controller,peer:{publicKey:g.publicKey,metadata:g.metadata},controller:A,transportType:pt.relay});await this.client.session.set(O,M),S.addTrace(Mi.store_session);try{S.addTrace(Mi.publishing_session_settle),await this.sendRequest({topic:O,method:"wc_sessionSettle",params:T,throwOnFailedPublish:!0}).catch(U=>{throw S?.setError(wn.session_settle_publish_failure),U}),S.addTrace(Mi.session_settle_publish_success),S.addTrace(Mi.publishing_session_approve),await this.sendResult({id:a,topic:m,result:{relay:{protocol:u??"irn"},responderPublicKey:A},throwOnFailedPublish:!0}).catch(U=>{throw S?.setError(wn.session_approve_publish_failure),U}),S.addTrace(Mi.session_approve_publish_success)}catch(U){throw this.client.logger.error(U),this.client.session.delete(O,Qe("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(O),U}return this.client.core.eventClient.deleteEvent({eventId:S.eventId}),await this.client.core.pairing.updateMetadata({topic:m,metadata:g.metadata}),await this.client.proposal.delete(a,Qe("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:m}),await this.setExpiry(O,Zt(fo)),{topic:O,acknowledged:()=>Promise.resolve(this.client.session.get(O))}}),G(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:s}=r;let n;try{n=this.client.proposal.get(i).pairingTopic}catch(o){throw this.client.logger.error(`reject() -> proposal.get(${i}) failed`),o}n&&(await this.sendError({id:i,topic:n,error:s,rpcOpts:ar.wc_sessionPropose.reject}),await this.client.proposal.delete(i,Qe("USER_DISCONNECTED")))}),G(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:s}=r,{done:n,resolve:o,reject:a}=An(),u=hr(),c=li().toString(),l=this.client.session.get(i).namespaces;return this.events.once(Ue("session_update",u),({error:h})=>{h?a(h):o()}),await this.client.session.update(i,{namespaces:s}),await this.sendRequest({topic:i,method:"wc_sessionUpdate",params:{namespaces:s},throwOnFailedPublish:!0,clientRpcId:u,relayRpcId:c}).catch(h=>{this.client.logger.error(h),this.client.session.update(i,{namespaces:l}),a(h)}),{acknowledged:n}}),G(this,"extend",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(r)}catch(u){throw this.client.logger.error("extend() -> isValidExtend() failed"),u}const{topic:i}=r,s=hr(),{done:n,resolve:o,reject:a}=An();return this.events.once(Ue("session_extend",s),({error:u})=>{u?a(u):o()}),await this.setExpiry(i,Zt(fo)),this.sendRequest({topic:i,method:"wc_sessionExtend",params:{},clientRpcId:s,throwOnFailedPublish:!0}).catch(u=>{a(u)}),{acknowledged:n}}),G(this,"request",async r=>{this.isInitialized();try{await this.isValidRequest(r)}catch(S){throw this.client.logger.error("request() -> isValidRequest() failed"),S}const{chainId:i,request:s,topic:n,expiry:o=ar.wc_sessionRequest.req.ttl}=r,a=this.client.session.get(n);a?.transportType===pt.relay&&await this.confirmOnlineStateOrThrow();const u=hr(),c=li().toString(),{done:l,resolve:h,reject:f}=An(o,"Request expired. Please try again.");this.events.once(Ue("session_request",u),({error:S,result:A})=>{S?f(S):h(A)});const m="wc_sessionRequest",g=this.getAppLinkIfEnabled(a.peer.metadata,a.transportType);if(g)return await this.sendRequest({clientRpcId:u,relayRpcId:c,topic:n,method:m,params:{request:Br(Nt({},s),{expiryTimestamp:Zt(o)}),chainId:i},expiry:o,throwOnFailedPublish:!0,appLink:g}).catch(S=>f(S)),this.client.events.emit("session_request_sent",{topic:n,request:s,chainId:i,id:u}),await l();const y={request:Br(Nt({},s),{expiryTimestamp:Zt(o)}),chainId:i},C=this.shouldSetTVF(m,y);return await Promise.all([new Promise(async S=>{await this.sendRequest(Nt({clientRpcId:u,relayRpcId:c,topic:n,method:m,params:y,expiry:o,throwOnFailedPublish:!0},C&&{tvf:this.getTVFParams(u,y)})).catch(A=>f(A)),this.client.events.emit("session_request_sent",{topic:n,request:s,chainId:i,id:u}),S()}),new Promise(async S=>{var A;if(!((A=a.sessionConfig)!=null&&A.disableDeepLink)){const D=await EC(this.client.core.storage,ry);await wC({id:u,topic:n,wcDeepLink:D})}S()}),l()]).then(S=>S[2])}),G(this,"respond",async r=>{this.isInitialized(),await this.isValidRespond(r);const{topic:i,response:s}=r,{id:n}=s,o=this.client.session.get(i);o.transportType===pt.relay&&await this.confirmOnlineStateOrThrow();const a=this.getAppLinkIfEnabled(o.peer.metadata,o.transportType);ir(s)?await this.sendResult({id:n,topic:i,result:s.result,throwOnFailedPublish:!0,appLink:a}):Ht(s)&&await this.sendError({id:n,topic:i,error:s.error,appLink:a}),this.cleanupAfterResponse(r)}),G(this,"ping",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(r)}catch(s){throw this.client.logger.error("ping() -> isValidPing() failed"),s}const{topic:i}=r;if(this.client.session.keys.includes(i)){const s=hr(),n=li().toString(),{done:o,resolve:a,reject:u}=An();this.events.once(Ue("session_ping",s),({error:c})=>{c?u(c):a()}),await Promise.all([this.sendRequest({topic:i,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:s,relayRpcId:n}),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}))}),G(this,"emit",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(r);const{topic:i,event:s,chainId:n}=r,o=li().toString(),a=hr();await this.sendRequest({topic:i,method:"wc_sessionEvent",params:{event:s,chainId:n},throwOnFailedPublish:!0,relayRpcId:o,clientRpcId:a})}),G(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:Qe("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:s}=Q("MISMATCHED_TOPIC",`Session or pairing topic not found: ${i}`);throw new Error(s)}}),G(this,"find",r=>(this.isInitialized(),this.client.session.getAll().filter(i=>Dx(i,r)))),G(this,"getPendingSessionRequests",()=>this.client.pendingRequest.getAll()),G(this,"authenticate",async(r,i)=>{var s;this.isInitialized(),this.isValidAuthenticate(r);const n=i&&this.client.core.linkModeSupportedApps.includes(i)&&((s=this.client.metadata.redirect)==null?void 0:s.linkMode),o=n?pt.link_mode:pt.relay;o===pt.relay&&await this.confirmOnlineStateOrThrow();const{chains:a,statement:u="",uri:c,domain:l,nonce:h,type:f,exp:m,nbf:g,methods:y=[],expiry:C}=r,S=[...r.resources||[]],{topic:A,uri:D}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:o});this.client.logger.info({message:"Generated new pairing",pairing:{topic:A,uri:D}});const O=await this.client.core.crypto.generateKeyPair(),T=Fl(O);if(await Promise.all([this.client.auth.authKeys.set(jl,{responseTopic:T,publicKey:O}),this.client.auth.pairingTopics.set(T,{topic:T,pairingTopic:A})]),await this.client.core.relayer.subscribe(T,{transportType:o}),this.client.logger.info(`sending request to new pairing topic: ${A}`),y.length>0){const{namespace:E}=ra(a[0]);let p=d$(E,"request",y);Ll(S)&&(p=p$(p,S.pop())),S.push(p)}const x=C&&C>ar.wc_sessionAuthenticate.req.ttl?C:ar.wc_sessionAuthenticate.req.ttl,M={authPayload:{type:f??"caip122",chains:a,statement:u,aud:c,domain:l,version:"1",nonce:h,iat:new Date().toISOString(),exp:m,nbf:g,resources:S},requester:{publicKey:O,metadata:this.client.metadata},expiryTimestamp:Zt(x)},U={eip155:{chains:a,methods:[...new Set(["personal_sign",...y])],events:["chainChanged","accountsChanged"]}},R={requiredNamespaces:{},optionalNamespaces:U,relays:[{protocol:"irn"}],pairingTopic:A,proposer:{publicKey:O,metadata:this.client.metadata},expiryTimestamp:Zt(ar.wc_sessionPropose.req.ttl),id:hr()},{done:L,resolve:$,reject:d}=An(x,"Request expired"),b=hr(),_=Ue("session_connect",R.id),w=Ue("session_request",b),v=async({error:E,session:p})=>{this.events.off(w,I),E?d(E):p&&$({session:p})},I=async E=>{var p,N,q;if(await this.deletePendingAuthRequest(b,{message:"fulfilled",code:0}),E.error){const Z=Qe("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return E.error.code===Z.code?void 0:(this.events.off(_,v),d(E.error.message))}await this.deleteProposal(R.id),this.events.off(_,v);const{cacaos:H,responder:z}=E.result,V=[],Y=[];for(const Z of H){await em({cacao:Z,projectId:this.client.core.projectId})||(this.client.logger.error(Z,"Signature verification failed"),d(Qe("SESSION_SETTLEMENT_FAILED","Signature verification failed")));const{p:ae}=Z,ht=Ll(ae.resources),ge=[Zf(ae.iss)],ye=nh(ae.iss);if(ht){const Dt=tm(ht),Ie=rm(ht);V.push(...Dt),ge.push(...Ie)}for(const Dt of ge)Y.push(`${Dt}:${ye}`)}const te=await this.client.core.crypto.generateSharedKey(O,z.publicKey);let ie;V.length>0&&(ie={topic:te,acknowledged:!0,self:{publicKey:O,metadata:this.client.metadata},peer:z,controller:z.publicKey,expiry:Zt(fo),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:A,namespaces:_m([...new Set(V)],[...new Set(Y)]),transportType:o},await this.client.core.relayer.subscribe(te,{transportType:o}),await this.client.session.set(te,ie),A&&await this.client.core.pairing.updateMetadata({topic:A,metadata:z.metadata}),ie=this.client.session.get(te)),(p=this.client.metadata.redirect)!=null&&p.linkMode&&(N=z.metadata.redirect)!=null&&N.linkMode&&(q=z.metadata.redirect)!=null&&q.universal&&i&&(this.client.core.addLinkModeSupportedApp(z.metadata.redirect.universal),this.client.session.update(te,{transportType:pt.link_mode})),$({auths:H,session:ie})};this.events.once(_,v),this.events.once(w,I);let P;try{if(n){const E=Lr("wc_sessionAuthenticate",M,b);this.client.core.history.set(A,E);const p=await this.client.core.crypto.encode("",E,{type:Pu,encoding:ec});P=ll(i,A,p)}else await Promise.all([this.sendRequest({topic:A,method:"wc_sessionAuthenticate",params:M,expiry:r.expiry,throwOnFailedPublish:!0,clientRpcId:b}),this.sendRequest({topic:A,method:"wc_sessionPropose",params:R,expiry:ar.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:R.id})])}catch(E){throw this.events.off(_,v),this.events.off(w,I),E}return await this.setProposal(R.id,R),await this.setAuthRequest(b,{request:Br(Nt({},M),{verifyContext:{}}),pairingTopic:A,transportType:o}),{uri:P??D,response:L}}),G(this,"approveSessionAuthenticate",async r=>{const{id:i,auths:s}=r,n=this.client.core.eventClient.createEvent({properties:{topic:i.toString(),trace:[vn.authenticated_session_approve_started]}});try{this.isInitialized()}catch(C){throw n.setError(ic.no_internet_connection),C}const o=this.getPendingAuthRequest(i);if(!o)throw n.setError(ic.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${i}`);const a=o.transportType||pt.relay;a===pt.relay&&await this.confirmOnlineStateOrThrow();const u=o.requester.publicKey,c=await this.client.core.crypto.generateKeyPair(),l=Fl(u),h={type:xs,receiverPublicKey:u,senderPublicKey:c},f=[],m=[];for(const C of s){if(!await em({cacao:C,projectId:this.client.core.projectId})){n.setError(ic.invalid_cacao);const T=Qe("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:i,topic:l,error:T,encodeOpts:h}),new Error(T.message)}n.addTrace(vn.cacaos_verified);const{p:S}=C,A=Ll(S.resources),D=[Zf(S.iss)],O=nh(S.iss);if(A){const T=tm(A),x=rm(A);f.push(...T),D.push(...x)}for(const T of D)m.push(`${T}:${O}`)}const g=await this.client.core.crypto.generateSharedKey(c,u);n.addTrace(vn.create_authenticated_session_topic);let y;if(f?.length>0){y={topic:g,acknowledged:!0,self:{publicKey:c,metadata:this.client.metadata},peer:{publicKey:u,metadata:o.requester.metadata},controller:u,expiry:Zt(fo),authentication:s,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:o.pairingTopic,namespaces:_m([...new Set(f)],[...new Set(m)]),transportType:a},n.addTrace(vn.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(g,{transportType:a})}catch(C){throw n.setError(ic.subscribe_authenticated_session_topic_failure),C}n.addTrace(vn.subscribe_authenticated_session_topic_success),await this.client.session.set(g,y),n.addTrace(vn.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:o.pairingTopic,metadata:o.requester.metadata})}n.addTrace(vn.publishing_authenticated_session_approve);try{await this.sendResult({topic:l,id:i,result:{cacaos:s,responder:{publicKey:c,metadata:this.client.metadata}},encodeOpts:h,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(o.requester.metadata,a)})}catch(C){throw n.setError(ic.authenticated_session_approve_publish_failure),C}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:n.eventId}),{session:y}}),G(this,"rejectSessionAuthenticate",async r=>{this.isInitialized();const{id:i,reason:s}=r,n=this.getPendingAuthRequest(i);if(!n)throw new Error(`Could not find pending auth request with id ${i}`);n.transportType===pt.relay&&await this.confirmOnlineStateOrThrow();const o=n.requester.publicKey,a=await this.client.core.crypto.generateKeyPair(),u=Fl(o),c={type:xs,receiverPublicKey:o,senderPublicKey:a};await this.sendError({id:i,topic:u,error:s,encodeOpts:c,rpcOpts:ar.wc_sessionAuthenticate.reject,appLink:this.getAppLinkIfEnabled(n.requester.metadata,n.transportType)}),await this.client.auth.requests.delete(i,{message:"rejected",code:0}),await this.client.proposal.delete(i,Qe("USER_DISCONNECTED"))}),G(this,"formatAuthMessage",r=>{this.isInitialized();const{request:i,iss:s}=r;return A2(i,s)}),G(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)}),G(this,"cleanupDuplicatePairings",async r=>{if(r.pairingTopic)try{const i=this.client.core.pairing.pairings.get(r.pairingTopic),s=this.client.core.pairing.pairings.getAll().filter(n=>{var o,a;return((o=n.peerMetadata)==null?void 0:o.url)&&((a=n.peerMetadata)==null?void 0:a.url)===r.peer.metadata.url&&n.topic&&n.topic!==i.topic});if(s.length===0)return;this.client.logger.info(`Cleaning up ${s.length} duplicate pairing(s)`),await Promise.all(s.map(n=>this.client.core.pairing.disconnect({topic:n.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(i){this.client.logger.error(i)}}),G(this,"deleteSession",async r=>{var i;const{topic:s,expirerHasDeleted:n=!1,emitEvent:o=!0,id:a=0}=r,{self:u}=this.client.session.get(s);await this.client.core.relayer.unsubscribe(s),await this.client.session.delete(s,Qe("USER_DISCONNECTED")),this.addToRecentlyDeleted(s,"session"),this.client.core.crypto.keychain.has(u.publicKey)&&await this.client.core.crypto.deleteKeyPair(u.publicKey),this.client.core.crypto.keychain.has(s)&&await this.client.core.crypto.deleteSymKey(s),n||this.client.core.expirer.del(s),this.client.core.storage.removeItem(ry).catch(c=>this.client.logger.warn(c)),this.getPendingSessionRequests().forEach(c=>{c.topic===s&&this.deletePendingSessionRequest(c.id,Qe("USER_DISCONNECTED"))}),s===((i=this.sessionRequestQueue.queue[0])==null?void 0:i.topic)&&(this.sessionRequestQueue.state=es.idle),o&&this.client.events.emit("session_delete",{id:a,topic:s})}),G(this,"deleteProposal",async(r,i)=>{if(i)try{const s=this.client.proposal.get(r);this.client.core.eventClient.getEvent({topic:s.pairingTopic})?.setError(wn.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(r,Qe("USER_DISCONNECTED")),i?Promise.resolve():this.client.core.expirer.del(r)]),this.addToRecentlyDeleted(r,"proposal")}),G(this,"deletePendingSessionRequest",async(r,i,s=!1)=>{await Promise.all([this.client.pendingRequest.delete(r,i),s?Promise.resolve():this.client.core.expirer.del(r)]),this.addToRecentlyDeleted(r,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(n=>n.id!==r),s&&(this.sessionRequestQueue.state=es.idle,this.client.events.emit("session_request_expire",{id:r}))}),G(this,"deletePendingAuthRequest",async(r,i,s=!1)=>{await Promise.all([this.client.auth.requests.delete(r,i),s?Promise.resolve():this.client.core.expirer.del(r)])}),G(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}))}),G(this,"setProposal",async(r,i)=>{this.client.core.expirer.set(r,Zt(ar.wc_sessionPropose.req.ttl)),await this.client.proposal.set(r,i)}),G(this,"setAuthRequest",async(r,i)=>{const{request:s,pairingTopic:n,transportType:o=pt.relay}=i;this.client.core.expirer.set(r,s.expiryTimestamp),await this.client.auth.requests.set(r,{authPayload:s.authPayload,requester:s.requester,expiryTimestamp:s.expiryTimestamp,id:r,pairingTopic:n,verifyContext:s.verifyContext,transportType:o})}),G(this,"setPendingSessionRequest",async r=>{const{id:i,topic:s,params:n,verifyContext:o}=r,a=n.request.expiryTimestamp||Zt(ar.wc_sessionRequest.req.ttl);this.client.core.expirer.set(i,a),await this.client.pendingRequest.set(i,{id:i,topic:s,params:n,verifyContext:o})}),G(this,"sendRequest",async r=>{const{topic:i,method:s,params:n,expiry:o,relayRpcId:a,clientRpcId:u,throwOnFailedPublish:c,appLink:l,tvf:h}=r,f=Lr(s,n,u);let m;const g=!!l;try{const S=g?ec:Zs;m=await this.client.core.crypto.encode(i,f,{encoding:S})}catch(S){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${i} failed`),S}let y;if(dO.includes(s)){const S=$s(JSON.stringify(f)),A=$s(m);y=await this.client.core.verify.register({id:A,decryptedId:S})}const C=ar[s].req;if(C.attestation=y,o&&(C.ttl=o),a&&(C.id=a),this.client.core.history.set(i,f),g){const S=ll(l,i,m);await global.Linking.openURL(S,this.client.name)}else{const S=ar[s].req;o&&(S.ttl=o),a&&(S.id=a),S.tvf=Br(Nt({},h),{correlationId:f.id}),c?(S.internal=Br(Nt({},S.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(i,m,S)):this.client.core.relayer.publish(i,m,S).catch(A=>this.client.logger.error(A))}return f.id}),G(this,"sendResult",async r=>{const{id:i,topic:s,result:n,throwOnFailedPublish:o,encodeOpts:a,appLink:u}=r,c=ln(i,n);let l;const h=u&&typeof(global==null?void 0:global.Linking)<"u";try{const g=h?ec:Zs;l=await this.client.core.crypto.encode(s,c,Br(Nt({},a||{}),{encoding:g}))}catch(g){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${s} failed`),g}let f,m;try{f=await this.client.core.history.get(s,i);const g=f.request;try{this.shouldSetTVF(g.method,g.params)&&(m=this.getTVFParams(i,g.params,n))}catch(y){this.client.logger.warn("sendResult() -> getTVFParams() failed",y)}}catch(g){throw this.client.logger.error(`sendResult() -> history.get(${s}, ${i}) failed`),g}if(h){const g=ll(u,s,l);await global.Linking.openURL(g,this.client.name)}else{const g=f.request.method,y=ar[g].res;y.tvf=Br(Nt({},m),{correlationId:i}),o?(y.internal=Br(Nt({},y.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(s,l,y)):this.client.core.relayer.publish(s,l,y).catch(C=>this.client.logger.error(C))}await this.client.core.history.resolve(c)}),G(this,"sendError",async r=>{const{id:i,topic:s,error:n,encodeOpts:o,rpcOpts:a,appLink:u}=r,c=Aa(i,n);let l;const h=u&&typeof(global==null?void 0:global.Linking)<"u";try{const m=h?ec:Zs;l=await this.client.core.crypto.encode(s,c,Br(Nt({},o||{}),{encoding:m}))}catch(m){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${s} failed`),m}let f;try{f=await this.client.core.history.get(s,i)}catch(m){throw this.client.logger.error(`sendError() -> history.get(${s}, ${i}) failed`),m}if(h){const m=ll(u,s,l);await global.Linking.openURL(m,this.client.name)}else{const m=f.request.method,g=a||ar[m].res;this.client.core.relayer.publish(s,l,g)}await this.client.core.history.resolve(c)}),G(this,"cleanup",async()=>{const r=[],i=[];this.client.session.getAll().forEach(s=>{let n=!1;Ws(s.expiry)&&(n=!0),this.client.core.crypto.keychain.has(s.topic)||(n=!0),n&&r.push(s.topic)}),this.client.proposal.getAll().forEach(s=>{Ws(s.expiryTimestamp)&&i.push(s.id)}),await Promise.all([...r.map(s=>this.deleteSession({topic:s})),...i.map(s=>this.deleteProposal(s))])}),G(this,"onRelayEventRequest",async r=>{this.requestQueue.queue.push(r),await this.processRequestsQueue()}),G(this,"processRequestsQueue",async()=>{if(this.requestQueue.state===es.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=es.active;const r=this.requestQueue.queue.shift();if(r)try{await this.processRequest(r)}catch(i){this.client.logger.warn(i)}}this.requestQueue.state=es.idle}),G(this,"processRequest",async r=>{const{topic:i,payload:s,attestation:n,transportType:o,encryptedId:a}=r,u=s.method;if(!this.shouldIgnorePairingRequest({topic:i,requestMethod:u}))switch(u){case"wc_sessionPropose":return await this.onSessionProposeRequest({topic:i,payload:s,attestation:n,encryptedId:a});case"wc_sessionSettle":return await this.onSessionSettleRequest(i,s);case"wc_sessionUpdate":return await this.onSessionUpdateRequest(i,s);case"wc_sessionExtend":return await this.onSessionExtendRequest(i,s);case"wc_sessionPing":return await this.onSessionPingRequest(i,s);case"wc_sessionDelete":return await this.onSessionDeleteRequest(i,s);case"wc_sessionRequest":return await this.onSessionRequest({topic:i,payload:s,attestation:n,encryptedId:a,transportType:o});case"wc_sessionEvent":return await this.onSessionEventRequest(i,s);case"wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:i,payload:s,attestation:n,encryptedId:a,transportType:o});default:return this.client.logger.info(`Unsupported request method ${u}`)}}),G(this,"onRelayEventResponse",async r=>{const{topic:i,payload:s,transportType:n}=r,o=(await this.client.core.history.get(i,s.id)).request.method;switch(o){case"wc_sessionPropose":return this.onSessionProposeResponse(i,s,n);case"wc_sessionSettle":return this.onSessionSettleResponse(i,s);case"wc_sessionUpdate":return this.onSessionUpdateResponse(i,s);case"wc_sessionExtend":return this.onSessionExtendResponse(i,s);case"wc_sessionPing":return this.onSessionPingResponse(i,s);case"wc_sessionRequest":return this.onSessionRequestResponse(i,s);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(i,s);default:return this.client.logger.info(`Unsupported response method ${o}`)}}),G(this,"onRelayEventUnknownPayload",r=>{const{topic:i}=r,{message:s}=Q("MISSING_OR_INVALID",`Decoded payload on topic ${i} is not identifiable as a JSON-RPC request or a response.`);throw new Error(s)}),G(this,"shouldIgnorePairingRequest",r=>{const{topic:i,requestMethod:s}=r,n=this.expectedPairingMethodMap.get(i);return!n||n.includes(s)?!1:!!(n.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0)}),G(this,"onSessionProposeRequest",async r=>{const{topic:i,payload:s,attestation:n,encryptedId:o}=r,{params:a,id:u}=s;try{const c=this.client.core.eventClient.getEvent({topic:i});this.client.events.listenerCount("session_proposal")===0&&(console.warn("No listener for session_proposal event"),c?.setError(Ss.proposal_listener_not_found)),this.isValidConnect(Nt({},s.params));const l=a.expiryTimestamp||Zt(ar.wc_sessionPropose.req.ttl),h=Nt({id:u,pairingTopic:i,expiryTimestamp:l},a);await this.setProposal(u,h);const f=await this.getVerifyContext({attestationId:n,hash:$s(JSON.stringify(s)),encryptedId:o,metadata:h.proposer.metadata});c?.addTrace(ns.emit_session_proposal),this.client.events.emit("session_proposal",{id:u,params:h,verifyContext:f})}catch(c){await this.sendError({id:u,topic:i,error:c,rpcOpts:ar.wc_sessionPropose.autoReject}),this.client.logger.error(c)}}),G(this,"onSessionProposeResponse",async(r,i,s)=>{const{id:n}=i;if(ir(i)){const{result:o}=i;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:o});const a=this.client.proposal.get(n);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:a});const u=a.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:u});const c=o.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:c});const l=await this.client.core.crypto.generateSharedKey(u,c);this.pendingSessions.set(n,{sessionTopic:l,pairingTopic:r,proposalId:n,publicKey:u});const h=await this.client.core.relayer.subscribe(l,{transportType:s});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:h}),await this.client.core.pairing.activate({topic:r})}else if(Ht(i)){await this.client.proposal.delete(n,Qe("USER_DISCONNECTED"));const o=Ue("session_connect",n);if(this.events.listenerCount(o)===0)throw new Error(`emitting ${o} without any listeners, 954`);this.events.emit(o,{error:i.error})}}),G(this,"onSessionSettleRequest",async(r,i)=>{const{id:s,params:n}=i;try{this.isValidSessionSettleRequest(n);const{relay:o,controller:a,expiry:u,namespaces:c,sessionProperties:l,sessionConfig:h}=i.params,f=[...this.pendingSessions.values()].find(y=>y.sessionTopic===r);if(!f)return this.client.logger.error(`Pending session not found for topic ${r}`);const m=this.client.proposal.get(f.proposalId),g=Br(Nt(Nt({topic:r,relay:o,expiry:u,namespaces:c,acknowledged:!0,pairingTopic:f.pairingTopic,requiredNamespaces:m.requiredNamespaces,optionalNamespaces:m.optionalNamespaces,controller:a.publicKey,self:{publicKey:f.publicKey,metadata:this.client.metadata},peer:{publicKey:a.publicKey,metadata:a.metadata}},l&&{sessionProperties:l}),h&&{sessionConfig:h}),{transportType:pt.relay});await this.client.session.set(g.topic,g),await this.setExpiry(g.topic,g.expiry),await this.client.core.pairing.updateMetadata({topic:f.pairingTopic,metadata:g.peer.metadata}),this.client.events.emit("session_connect",{session:g}),this.events.emit(Ue("session_connect",f.proposalId),{session:g}),this.pendingSessions.delete(f.proposalId),this.deleteProposal(f.proposalId,!1),this.cleanupDuplicatePairings(g),await this.sendResult({id:i.id,topic:r,result:!0,throwOnFailedPublish:!0})}catch(o){await this.sendError({id:s,topic:r,error:o}),this.client.logger.error(o)}}),G(this,"onSessionSettleResponse",async(r,i)=>{const{id:s}=i;ir(i)?(await this.client.session.update(r,{acknowledged:!0}),this.events.emit(Ue("session_approve",s),{})):Ht(i)&&(await this.client.session.delete(r,Qe("USER_DISCONNECTED")),this.events.emit(Ue("session_approve",s),{error:i.error}))}),G(this,"onSessionUpdateRequest",async(r,i)=>{const{params:s,id:n}=i;try{const o=`${r}_session_update`,a=tc.get(o);if(a&&this.isRequestOutOfSync(a,n)){this.client.logger.warn(`Discarding out of sync request - ${n}`),this.sendError({id:n,topic:r,error:Qe("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(Nt({topic:r},s));try{tc.set(o,n),await this.client.session.update(r,{namespaces:s.namespaces}),await this.sendResult({id:n,topic:r,result:!0,throwOnFailedPublish:!0})}catch(u){throw tc.delete(o),u}this.client.events.emit("session_update",{id:n,topic:r,params:s})}catch(o){await this.sendError({id:n,topic:r,error:o}),this.client.logger.error(o)}}),G(this,"isRequestOutOfSync",(r,i)=>i.toString().slice(0,-3)<r.toString().slice(0,-3)),G(this,"onSessionUpdateResponse",(r,i)=>{const{id:s}=i,n=Ue("session_update",s);if(this.events.listenerCount(n)===0)throw new Error(`emitting ${n} without any listeners`);ir(i)?this.events.emit(Ue("session_update",s),{}):Ht(i)&&this.events.emit(Ue("session_update",s),{error:i.error})}),G(this,"onSessionExtendRequest",async(r,i)=>{const{id:s}=i;try{this.isValidExtend({topic:r}),await this.setExpiry(r,Zt(fo)),await this.sendResult({id:s,topic:r,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_extend",{id:s,topic:r})}catch(n){await this.sendError({id:s,topic:r,error:n}),this.client.logger.error(n)}}),G(this,"onSessionExtendResponse",(r,i)=>{const{id:s}=i,n=Ue("session_extend",s);if(this.events.listenerCount(n)===0)throw new Error(`emitting ${n} without any listeners`);ir(i)?this.events.emit(Ue("session_extend",s),{}):Ht(i)&&this.events.emit(Ue("session_extend",s),{error:i.error})}),G(this,"onSessionPingRequest",async(r,i)=>{const{id:s}=i;try{this.isValidPing({topic:r}),await this.sendResult({id:s,topic:r,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:s,topic:r})}catch(n){await this.sendError({id:s,topic:r,error:n}),this.client.logger.error(n)}}),G(this,"onSessionPingResponse",(r,i)=>{const{id:s}=i,n=Ue("session_ping",s);if(this.events.listenerCount(n)===0)throw new Error(`emitting ${n} without any listeners`);setTimeout(()=>{ir(i)?this.events.emit(Ue("session_ping",s),{}):Ht(i)&&this.events.emit(Ue("session_ping",s),{error:i.error})},500)}),G(this,"onSessionDeleteRequest",async(r,i)=>{const{id:s}=i;try{this.isValidDisconnect({topic:r,reason:i.params}),Promise.all([new Promise(n=>{this.client.core.relayer.once(dr.publish,async()=>{n(await this.deleteSession({topic:r,id:s}))})}),this.sendResult({id:s,topic:r,result:!0,throwOnFailedPublish:!0}),this.cleanupPendingSentRequestsForTopic({topic:r,error:Qe("USER_DISCONNECTED")})]).catch(n=>this.client.logger.error(n))}catch(n){this.client.logger.error(n)}}),G(this,"onSessionRequest",async r=>{var i,s,n;const{topic:o,payload:a,attestation:u,encryptedId:c,transportType:l}=r,{id:h,params:f}=a;try{await this.isValidRequest(Nt({topic:o},f));const m=this.client.session.get(o),g=await this.getVerifyContext({attestationId:u,hash:$s(JSON.stringify(Lr("wc_sessionRequest",f,h))),encryptedId:c,metadata:m.peer.metadata,transportType:l}),y={id:h,topic:o,params:f,verifyContext:g};await this.setPendingSessionRequest(y),l===pt.link_mode&&(i=m.peer.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp((s=m.peer.metadata.redirect)==null?void 0:s.universal),(n=this.client.signConfig)!=null&&n.disableRequestQueue?this.emitSessionRequest(y):(this.addSessionRequestToSessionRequestQueue(y),this.processSessionRequestQueue())}catch(m){await this.sendError({id:h,topic:o,error:m}),this.client.logger.error(m)}}),G(this,"onSessionRequestResponse",(r,i)=>{const{id:s}=i,n=Ue("session_request",s);if(this.events.listenerCount(n)===0)throw new Error(`emitting ${n} without any listeners`);ir(i)?this.events.emit(Ue("session_request",s),{result:i.result}):Ht(i)&&this.events.emit(Ue("session_request",s),{error:i.error})}),G(this,"onSessionEventRequest",async(r,i)=>{const{id:s,params:n}=i;try{const o=`${r}_session_event_${n.event.name}`,a=tc.get(o);if(a&&this.isRequestOutOfSync(a,s)){this.client.logger.info(`Discarding out of sync request - ${s}`);return}this.isValidEmit(Nt({topic:r},n)),this.client.events.emit("session_event",{id:s,topic:r,params:n}),tc.set(o,s)}catch(o){await this.sendError({id:s,topic:r,error:o}),this.client.logger.error(o)}}),G(this,"onSessionAuthenticateResponse",(r,i)=>{const{id:s}=i;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:r,payload:i}),ir(i)?this.events.emit(Ue("session_request",s),{result:i.result}):Ht(i)&&this.events.emit(Ue("session_request",s),{error:i.error})}),G(this,"onSessionAuthenticateRequest",async r=>{var i;const{topic:s,payload:n,attestation:o,encryptedId:a,transportType:u}=r;try{const{requester:c,authPayload:l,expiryTimestamp:h}=n.params,f=await this.getVerifyContext({attestationId:o,hash:$s(JSON.stringify(n)),encryptedId:a,metadata:c.metadata,transportType:u}),m={requester:c,pairingTopic:s,id:n.id,authPayload:l,verifyContext:f,expiryTimestamp:h};await this.setAuthRequest(n.id,{request:m,pairingTopic:s,transportType:u}),u===pt.link_mode&&(i=c.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp(c.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:s,params:n.params,id:n.id,verifyContext:f})}catch(c){this.client.logger.error(c);const l=n.params.requester.publicKey,h=await this.client.core.crypto.generateKeyPair(),f=this.getAppLinkIfEnabled(n.params.requester.metadata,u),m={type:xs,receiverPublicKey:l,senderPublicKey:h};await this.sendError({id:n.id,topic:s,error:c,encodeOpts:m,rpcOpts:ar.wc_sessionAuthenticate.autoReject,appLink:f})}}),G(this,"addSessionRequestToSessionRequestQueue",r=>{this.sessionRequestQueue.queue.push(r)}),G(this,"cleanupAfterResponse",r=>{this.deletePendingSessionRequest(r.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=es.idle,this.processSessionRequestQueue()},B.toMiliseconds(this.requestQueueDelay))}),G(this,"cleanupPendingSentRequestsForTopic",({topic:r,error:i})=>{const s=this.client.core.history.pending;s.length>0&&s.filter(n=>n.topic===r&&n.request.method==="wc_sessionRequest").forEach(n=>{const o=n.request.id,a=Ue("session_request",o);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);this.events.emit(Ue("session_request",n.request.id),{error:i})})}),G(this,"processSessionRequestQueue",()=>{if(this.sessionRequestQueue.state===es.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.sessionRequestQueue.state=es.active,this.emitSessionRequest(r)}catch(i){this.client.logger.error(i)}}),G(this,"emitSessionRequest",r=>{this.client.events.emit("session_request",r)}),G(this,"onPairingCreated",r=>{if(r.methods&&this.expectedPairingMethodMap.set(r.topic,r.methods),r.active)return;const i=this.client.proposal.getAll().find(s=>s.pairingTopic===r.topic);i&&this.onSessionProposeRequest({topic:r.topic,payload:Lr("wc_sessionPropose",{requiredNamespaces:i.requiredNamespaces,optionalNamespaces:i.optionalNamespaces,relays:i.relays,proposer:i.proposer,sessionProperties:i.sessionProperties},i.id)})}),G(this,"isValidConnect",async r=>{if(!Wr(r)){const{message:u}=Q("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(r)}`);throw new Error(u)}const{pairingTopic:i,requiredNamespaces:s,optionalNamespaces:n,sessionProperties:o,relays:a}=r;if(Ur(i)||await this.isValidPairingTopic(i),!Vx(a)){const{message:u}=Q("MISSING_OR_INVALID",`connect() relays: ${a}`);throw new Error(u)}!Ur(s)&&zc(s)!==0&&this.validateNamespaces(s,"requiredNamespaces"),!Ur(n)&&zc(n)!==0&&this.validateNamespaces(n,"optionalNamespaces"),Ur(o)||this.validateSessionProps(o,"sessionProperties")}),G(this,"validateNamespaces",(r,i)=>{const s=Hx(r,"connect()",i);if(s)throw new Error(s.message)}),G(this,"isValidApprove",async r=>{if(!Wr(r))throw new Error(Q("MISSING_OR_INVALID",`approve() params: ${r}`).message);const{id:i,namespaces:s,relayProtocol:n,sessionProperties:o}=r;this.checkRecentlyDeleted(i),await this.isValidProposalId(i);const a=this.client.proposal.get(i),u=Yd(s,"approve()");if(u)throw new Error(u.message);const c=Am(a.requiredNamespaces,s,"approve()");if(c)throw new Error(c.message);if(!Kt(n,!0)){const{message:l}=Q("MISSING_OR_INVALID",`approve() relayProtocol: ${n}`);throw new Error(l)}Ur(o)||this.validateSessionProps(o,"sessionProperties")}),G(this,"isValidReject",async r=>{if(!Wr(r)){const{message:n}=Q("MISSING_OR_INVALID",`reject() params: ${r}`);throw new Error(n)}const{id:i,reason:s}=r;if(this.checkRecentlyDeleted(i),await this.isValidProposalId(i),!Wx(s)){const{message:n}=Q("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(s)}`);throw new Error(n)}}),G(this,"isValidSessionSettleRequest",r=>{if(!Wr(r)){const{message:c}=Q("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${r}`);throw new Error(c)}const{relay:i,controller:s,namespaces:n,expiry:o}=r;if(!q2(i)){const{message:c}=Q("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(c)}const a=Lx(s,"onSessionSettleRequest()");if(a)throw new Error(a.message);const u=Yd(n,"onSessionSettleRequest()");if(u)throw new Error(u.message);if(Ws(o)){const{message:c}=Q("EXPIRED","onSessionSettleRequest()");throw new Error(c)}}),G(this,"isValidUpdate",async r=>{if(!Wr(r)){const{message:u}=Q("MISSING_OR_INVALID",`update() params: ${r}`);throw new Error(u)}const{topic:i,namespaces:s}=r;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);const n=this.client.session.get(i),o=Yd(s,"update()");if(o)throw new Error(o.message);const a=Am(n.requiredNamespaces,s,"update()");if(a)throw new Error(a.message)}),G(this,"isValidExtend",async r=>{if(!Wr(r)){const{message:s}=Q("MISSING_OR_INVALID",`extend() params: ${r}`);throw new Error(s)}const{topic:i}=r;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i)}),G(this,"isValidRequest",async r=>{if(!Wr(r)){const{message:u}=Q("MISSING_OR_INVALID",`request() params: ${r}`);throw new Error(u)}const{topic:i,request:s,chainId:n,expiry:o}=r;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);const{namespaces:a}=this.client.session.get(i);if(!Im(a,n)){const{message:u}=Q("MISSING_OR_INVALID",`request() chainId: ${n}`);throw new Error(u)}if(!Gx(s)){const{message:u}=Q("MISSING_OR_INVALID",`request() ${JSON.stringify(s)}`);throw new Error(u)}if(!Qx(a,n,s.method)){const{message:u}=Q("MISSING_OR_INVALID",`request() method: ${s.method}`);throw new Error(u)}if(o&&!t9(o,rf)){const{message:u}=Q("MISSING_OR_INVALID",`request() expiry: ${o}. Expiry must be a number (in seconds) between ${rf.min} and ${rf.max}`);throw new Error(u)}}),G(this,"isValidRespond",async r=>{var i;if(!Wr(r)){const{message:o}=Q("MISSING_OR_INVALID",`respond() params: ${r}`);throw new Error(o)}const{topic:s,response:n}=r;try{await this.isValidSessionTopic(s)}catch(o){throw(i=r?.response)!=null&&i.id&&this.cleanupAfterResponse(r),o}if(!Yx(n)){const{message:o}=Q("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(n)}`);throw new Error(o)}}),G(this,"isValidPing",async r=>{if(!Wr(r)){const{message:s}=Q("MISSING_OR_INVALID",`ping() params: ${r}`);throw new Error(s)}const{topic:i}=r;await this.isValidSessionOrPairingTopic(i)}),G(this,"isValidEmit",async r=>{if(!Wr(r)){const{message:a}=Q("MISSING_OR_INVALID",`emit() params: ${r}`);throw new Error(a)}const{topic:i,event:s,chainId:n}=r;await this.isValidSessionTopic(i);const{namespaces:o}=this.client.session.get(i);if(!Im(o,n)){const{message:a}=Q("MISSING_OR_INVALID",`emit() chainId: ${n}`);throw new Error(a)}if(!Jx(s)){const{message:a}=Q("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(s)}`);throw new Error(a)}if(!Xx(o,n,s.name)){const{message:a}=Q("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(s)}`);throw new Error(a)}}),G(this,"isValidDisconnect",async r=>{if(!Wr(r)){const{message:s}=Q("MISSING_OR_INVALID",`disconnect() params: ${r}`);throw new Error(s)}const{topic:i}=r;await this.isValidSessionOrPairingTopic(i)}),G(this,"isValidAuthenticate",r=>{const{chains:i,uri:s,domain:n,nonce:o}=r;if(!Array.isArray(i)||i.length===0)throw new Error("chains is required and must be a non-empty array");if(!Kt(s,!1))throw new Error("uri is required parameter");if(!Kt(n,!1))throw new Error("domain is required parameter");if(!Kt(o,!1))throw new Error("nonce is required parameter");if([...new Set(i.map(u=>ra(u).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");const{namespace:a}=ra(i[0]);if(a!=="eip155")throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")}),G(this,"getVerifyContext",async r=>{const{attestationId:i,hash:s,encryptedId:n,metadata:o,transportType:a}=r,u={verified:{verifyUrl:o.verifyUrl||Pc,validation:"UNKNOWN",origin:o.url||""}};try{if(a===pt.link_mode){const l=this.getAppLinkIfEnabled(o,a);return u.verified.validation=l&&new URL(l).origin===new URL(o.url).origin?"VALID":"INVALID",u}const c=await this.client.core.verify.resolve({attestationId:i,hash:s,encryptedId:n,verifyUrl:o.verifyUrl});c&&(u.verified.origin=c.origin,u.verified.isScam=c.isScam,u.verified.validation=c.origin===new URL(o.url).origin?"VALID":"INVALID")}catch(c){this.client.logger.warn(c)}return this.client.logger.debug(`Verify context: ${JSON.stringify(u)}`),u}),G(this,"validateSessionProps",(r,i)=>{Object.values(r).forEach(s=>{if(!Kt(s,!1)){const{message:n}=Q("MISSING_OR_INVALID",`${i} must be in Record<string, string> format. Received: ${JSON.stringify(s)}`);throw new Error(n)}})}),G(this,"getPendingAuthRequest",r=>{const i=this.client.auth.requests.get(r);return typeof i=="object"?i:void 0}),G(this,"addToRecentlyDeleted",(r,i)=>{if(this.recentlyDeletedMap.set(r,i),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let s=0;const n=this.recentlyDeletedLimit/2;for(const o of this.recentlyDeletedMap.keys()){if(s++>=n)break;this.recentlyDeletedMap.delete(o)}}}),G(this,"checkRecentlyDeleted",r=>{const i=this.recentlyDeletedMap.get(r);if(i){const{message:s}=Q("MISSING_OR_INVALID",`Record was recently deleted - ${i}: ${r}`);throw new Error(s)}}),G(this,"isLinkModeEnabled",(r,i)=>{var s,n,o,a,u,c,l,h,f;return!r||i!==pt.link_mode?!1:((n=(s=this.client.metadata)==null?void 0:s.redirect)==null?void 0:n.linkMode)===!0&&((a=(o=this.client.metadata)==null?void 0:o.redirect)==null?void 0:a.universal)!==void 0&&((c=(u=this.client.metadata)==null?void 0:u.redirect)==null?void 0:c.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"}),G(this,"getAppLinkIfEnabled",(r,i)=>{var s;return this.isLinkModeEnabled(r,i)?(s=r?.redirect)==null?void 0:s.universal:void 0}),G(this,"handleLinkModeMessage",({url:r})=>{if(!r||!r.includes("wc_ev")||!r.includes("topic"))return;const i=Vb(r,"topic")||"",s=decodeURIComponent(Vb(r,"wc_ev")||""),n=this.client.session.keys.includes(i);n&&this.client.session.update(i,{transportType:pt.link_mode}),this.client.core.dispatchEnvelope({topic:i,message:s,sessionExists:n})}),G(this,"registerLinkModeListeners",async()=>{var r;if(gg()||un()&&(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 s=await i.getInitialURL();s&&setTimeout(()=>{this.handleLinkModeMessage({url:s})},50)}}}),G(this,"shouldSetTVF",(r,i)=>{if(!i||r!=="wc_sessionRequest")return!1;const{request:s}=i;return Object.keys(sy).includes(s.method)}),G(this,"getTVFParams",(r,i,s)=>{var n,o;try{const a=i.request.method,u=this.extractTxHashesFromResult(a,s);return Br(Nt({correlationId:r,rpcMethods:[a],chainId:i.chainId},this.isValidContractData(i.request.params)&&{contractAddresses:[(o=(n=i.request.params)==null?void 0:n[0])==null?void 0:o.to]}),{txHashes:u})}catch(a){this.client.logger.warn("Error getting TVF params",a)}return{}}),G(this,"isValidContractData",r=>{var i;if(!r)return!1;try{const s=r?.data||((i=r?.[0])==null?void 0:i.data);if(!s.startsWith("0x"))return!1;const n=s.slice(2);return/^[0-9a-fA-F]*$/.test(n)?n.length%2===0:!1}catch{}return!1}),G(this,"extractTxHashesFromResult",(r,i)=>{try{const s=sy[r];if(typeof i=="string")return[i];const n=i[s.key];if(Fn(n))return n;if(typeof n=="string")return[n]}catch(s){this.client.logger.warn("Error extracting tx hashes from result",s)}return[]})}isInitialized(){if(!this.initialized){const{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(dr.message,e=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(e):this.onRelayMessage(e)})}async onRelayMessage(e){const{topic:r,message:i,attestation:s,transportType:n}=e,{publicKey:o}=this.client.auth.authKeys.keys.includes(jl)?this.client.auth.authKeys.get(jl):{publicKey:void 0},a=await this.client.core.crypto.decode(r,i,{receiverPublicKey:o,encoding:n===pt.link_mode?ec:Zs});try{Sa(a)?(this.client.core.history.set(r,a),this.onRelayEventRequest({topic:r,payload:a,attestation:s,transportType:n,encryptedId:$s(i)})):Yn(a)?(await this.client.core.history.resolve(a),await this.onRelayEventResponse({topic:r,payload:a,transportType:n}),this.client.core.history.delete(r,a.id)):this.onRelayEventUnknownPayload({topic:r,payload:a,transportType:n})}catch(u){this.client.logger.error(u)}}registerExpirerEvents(){this.client.core.expirer.on(Si.expired,async e=>{const{topic:r,id:i}=g2(e.target);if(i&&this.client.pendingRequest.keys.includes(i))return await this.deletePendingSessionRequest(i,Q("EXPIRED"),!0);if(i&&this.client.auth.requests.keys.includes(i))return await this.deletePendingAuthRequest(i,Q("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(xn.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(xn.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!Kt(e,!1)){const{message:r}=Q("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}=Q("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(r)}if(Ws(this.client.core.pairing.pairings.get(e).expiry)){const{message:r}=Q("EXPIRED",`pairing topic: ${e}`);throw new Error(r)}}async isValidSessionTopic(e){if(!Kt(e,!1)){const{message:r}=Q("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}=Q("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(r)}if(Ws(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});const{message:r}=Q("EXPIRED",`session topic: ${e}`);throw new Error(r)}if(!this.client.core.crypto.keychain.has(e)){const{message:r}=Q("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(Kt(e,!1)){const{message:r}=Q("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(r)}else{const{message:r}=Q("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(r)}}async isValidProposalId(e){if(!Kx(e)){const{message:r}=Q("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(r)}if(!this.client.proposal.keys.includes(e)){const{message:r}=Q("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(r)}if(Ws(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);const{message:r}=Q("EXPIRED",`proposal id: ${e}`);throw new Error(r)}}},AO=class extends Jn{constructor(e,r){super(e,r,cO,Sg),this.core=e,this.logger=r}},SO=class extends Jn{constructor(e,r){super(e,r,uO,Sg),this.core=e,this.logger=r}},CO=class extends Jn{constructor(e,r){super(e,r,hO,Sg,i=>i.id),this.core=e,this.logger=r}},$O=class extends Jn{constructor(e,r){super(e,r,gO,Th,()=>jl),this.core=e,this.logger=r}},xO=class extends Jn{constructor(e,r){super(e,r,bO,Th),this.core=e,this.logger=r}},PO=class extends Jn{constructor(e,r){super(e,r,mO,Th,i=>i.id),this.core=e,this.logger=r}};var NO=Object.defineProperty,OO=(t,e,r)=>e in t?NO(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,sf=(t,e,r)=>OO(t,typeof e!="symbol"?e+"":e,r);let TO=class{constructor(e,r){this.core=e,this.logger=r,sf(this,"authKeys"),sf(this,"pairingTopics"),sf(this,"requests"),this.authKeys=new $O(this.core,this.logger),this.pairingTopics=new xO(this.core,this.logger),this.requests=new PO(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}};var DO=Object.defineProperty,RO=(t,e,r)=>e in t?DO(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ve=(t,e,r)=>RO(t,typeof e!="symbol"?e+"":e,r);let MO=class p3 extends oO{constructor(e){super(e),ve(this,"protocol",h3),ve(this,"version",d3),ve(this,"name",tf.name),ve(this,"metadata"),ve(this,"core"),ve(this,"logger"),ve(this,"events",new sr.EventEmitter),ve(this,"engine"),ve(this,"session"),ve(this,"proposal"),ve(this,"pendingRequest"),ve(this,"auth"),ve(this,"signConfig"),ve(this,"on",(i,s)=>this.events.on(i,s)),ve(this,"once",(i,s)=>this.events.once(i,s)),ve(this,"off",(i,s)=>this.events.off(i,s)),ve(this,"removeListener",(i,s)=>this.events.removeListener(i,s)),ve(this,"removeAllListeners",i=>this.events.removeAllListeners(i)),ve(this,"connect",async i=>{try{return await this.engine.connect(i)}catch(s){throw this.logger.error(s.message),s}}),ve(this,"pair",async i=>{try{return await this.engine.pair(i)}catch(s){throw this.logger.error(s.message),s}}),ve(this,"approve",async i=>{try{return await this.engine.approve(i)}catch(s){throw this.logger.error(s.message),s}}),ve(this,"reject",async i=>{try{return await this.engine.reject(i)}catch(s){throw this.logger.error(s.message),s}}),ve(this,"update",async i=>{try{return await this.engine.update(i)}catch(s){throw this.logger.error(s.message),s}}),ve(this,"extend",async i=>{try{return await this.engine.extend(i)}catch(s){throw this.logger.error(s.message),s}}),ve(this,"request",async i=>{try{return await this.engine.request(i)}catch(s){throw this.logger.error(s.message),s}}),ve(this,"respond",async i=>{try{return await this.engine.respond(i)}catch(s){throw this.logger.error(s.message),s}}),ve(this,"ping",async i=>{try{return await this.engine.ping(i)}catch(s){throw this.logger.error(s.message),s}}),ve(this,"emit",async i=>{try{return await this.engine.emit(i)}catch(s){throw this.logger.error(s.message),s}}),ve(this,"disconnect",async i=>{try{return await this.engine.disconnect(i)}catch(s){throw this.logger.error(s.message),s}}),ve(this,"find",i=>{try{return this.engine.find(i)}catch(s){throw this.logger.error(s.message),s}}),ve(this,"getPendingSessionRequests",()=>{try{return this.engine.getPendingSessionRequests()}catch(i){throw this.logger.error(i.message),i}}),ve(this,"authenticate",async(i,s)=>{try{return await this.engine.authenticate(i,s)}catch(n){throw this.logger.error(n.message),n}}),ve(this,"formatAuthMessage",i=>{try{return this.engine.formatAuthMessage(i)}catch(s){throw this.logger.error(s.message),s}}),ve(this,"approveSessionAuthenticate",async i=>{try{return await this.engine.approveSessionAuthenticate(i)}catch(s){throw this.logger.error(s.message),s}}),ve(this,"rejectSessionAuthenticate",async i=>{try{return await this.engine.rejectSessionAuthenticate(i)}catch(s){throw this.logger.error(s.message),s}}),this.name=e?.name||tf.name,this.metadata=e?.metadata||l2(),this.signConfig=e?.signConfig;const r=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:cn(Ts({level:e?.logger||tf.logger}));this.core=e?.core||new iO(e),this.logger=je(r,this.name),this.session=new SO(this.core,this.logger),this.proposal=new AO(this.core,this.logger),this.pendingRequest=new CO(this.core,this.logger),this.engine=new IO(this),this.auth=new TO(this.core,this.logger)}static async init(e){const r=new p3(e);return await r.initialize(),r}get context(){return it(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"),setTimeout(()=>{this.engine.processRelayMessageCache()},B.toMiliseconds(B.ONE_SECOND))}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}};var dl={exports:{}},oy;function kO(){return oy||(oy=1,(function(t,e){var r=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof Yr<"u"&&Yr,i=(function(){function n(){this.fetch=!1,this.DOMException=r.DOMException}return n.prototype=r,new n})();(function(n){(function(o){var a=typeof n<"u"&&n||typeof self<"u"&&self||typeof Yr<"u"&&Yr||{},u={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 c(w){return w&&DataView.prototype.isPrototypeOf(w)}if(u.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(w){return w&&l.indexOf(Object.prototype.toString.call(w))>-1};function f(w){if(typeof w!="string"&&(w=String(w)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(w)||w==="")throw new TypeError('Invalid character in header field name: "'+w+'"');return w.toLowerCase()}function m(w){return typeof w!="string"&&(w=String(w)),w}function g(w){var v={next:function(){var I=w.shift();return{done:I===void 0,value:I}}};return u.iterable&&(v[Symbol.iterator]=function(){return v}),v}function y(w){this.map={},w instanceof y?w.forEach(function(v,I){this.append(I,v)},this):Array.isArray(w)?w.forEach(function(v){if(v.length!=2)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+v.length);this.append(v[0],v[1])},this):w&&Object.getOwnPropertyNames(w).forEach(function(v){this.append(v,w[v])},this)}y.prototype.append=function(w,v){w=f(w),v=m(v);var I=this.map[w];this.map[w]=I?I+", "+v:v},y.prototype.delete=function(w){delete this.map[f(w)]},y.prototype.get=function(w){return w=f(w),this.has(w)?this.map[w]:null},y.prototype.has=function(w){return this.map.hasOwnProperty(f(w))},y.prototype.set=function(w,v){this.map[f(w)]=m(v)},y.prototype.forEach=function(w,v){for(var I in this.map)this.map.hasOwnProperty(I)&&w.call(v,this.map[I],I,this)},y.prototype.keys=function(){var w=[];return this.forEach(function(v,I){w.push(I)}),g(w)},y.prototype.values=function(){var w=[];return this.forEach(function(v){w.push(v)}),g(w)},y.prototype.entries=function(){var w=[];return this.forEach(function(v,I){w.push([I,v])}),g(w)},u.iterable&&(y.prototype[Symbol.iterator]=y.prototype.entries);function C(w){if(!w._noBody){if(w.bodyUsed)return Promise.reject(new TypeError("Already read"));w.bodyUsed=!0}}function S(w){return new Promise(function(v,I){w.onload=function(){v(w.result)},w.onerror=function(){I(w.error)}})}function A(w){var v=new FileReader,I=S(v);return v.readAsArrayBuffer(w),I}function D(w){var v=new FileReader,I=S(v),P=/charset=([A-Za-z0-9_-]+)/.exec(w.type),E=P?P[1]:"utf-8";return v.readAsText(w,E),I}function O(w){for(var v=new Uint8Array(w),I=new Array(v.length),P=0;P<v.length;P++)I[P]=String.fromCharCode(v[P]);return I.join("")}function T(w){if(w.slice)return w.slice(0);var v=new Uint8Array(w.byteLength);return v.set(new Uint8Array(w)),v.buffer}function x(){return this.bodyUsed=!1,this._initBody=function(w){this.bodyUsed=this.bodyUsed,this._bodyInit=w,w?typeof w=="string"?this._bodyText=w:u.blob&&Blob.prototype.isPrototypeOf(w)?this._bodyBlob=w:u.formData&&FormData.prototype.isPrototypeOf(w)?this._bodyFormData=w:u.searchParams&&URLSearchParams.prototype.isPrototypeOf(w)?this._bodyText=w.toString():u.arrayBuffer&&u.blob&&c(w)?(this._bodyArrayBuffer=T(w.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):u.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(w)||h(w))?this._bodyArrayBuffer=T(w):this._bodyText=w=Object.prototype.toString.call(w):(this._noBody=!0,this._bodyText=""),this.headers.get("content-type")||(typeof w=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):u.searchParams&&URLSearchParams.prototype.isPrototypeOf(w)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},u.blob&&(this.blob=function(){var w=C(this);if(w)return w;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 w=C(this);return w||(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(u.blob)return this.blob().then(A);throw new Error("could not read as ArrayBuffer")}},this.text=function(){var w=C(this);if(w)return w;if(this._bodyBlob)return D(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(O(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},u.formData&&(this.formData=function(){return this.text().then(L)}),this.json=function(){return this.text().then(JSON.parse)},this}var M=["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"];function U(w){var v=w.toUpperCase();return M.indexOf(v)>-1?v:w}function R(w,v){if(!(this instanceof R))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');v=v||{};var I=v.body;if(w instanceof R){if(w.bodyUsed)throw new TypeError("Already read");this.url=w.url,this.credentials=w.credentials,v.headers||(this.headers=new y(w.headers)),this.method=w.method,this.mode=w.mode,this.signal=w.signal,!I&&w._bodyInit!=null&&(I=w._bodyInit,w.bodyUsed=!0)}else this.url=String(w);if(this.credentials=v.credentials||this.credentials||"same-origin",(v.headers||!this.headers)&&(this.headers=new y(v.headers)),this.method=U(v.method||this.method||"GET"),this.mode=v.mode||this.mode||null,this.signal=v.signal||this.signal||(function(){if("AbortController"in a){var p=new AbortController;return p.signal}})(),this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&I)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(I),(this.method==="GET"||this.method==="HEAD")&&(v.cache==="no-store"||v.cache==="no-cache")){var P=/([?&])_=[^&]*/;if(P.test(this.url))this.url=this.url.replace(P,"$1_="+new Date().getTime());else{var E=/\?/;this.url+=(E.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}R.prototype.clone=function(){return new R(this,{body:this._bodyInit})};function L(w){var v=new FormData;return w.trim().split("&").forEach(function(I){if(I){var P=I.split("="),E=P.shift().replace(/\+/g," "),p=P.join("=").replace(/\+/g," ");v.append(decodeURIComponent(E),decodeURIComponent(p))}}),v}function $(w){var v=new y,I=w.replace(/\r?\n[\t ]+/g," ");return I.split("\r").map(function(P){return P.indexOf(`
|
|
13
|
+
`)===0?P.substr(1,P.length):P}).forEach(function(P){var E=P.split(":"),p=E.shift().trim();if(p){var N=E.join(":").trim();try{v.append(p,N)}catch(q){console.warn("Response "+q.message)}}}),v}x.call(R.prototype);function d(w,v){if(!(this instanceof d))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(v||(v={}),this.type="default",this.status=v.status===void 0?200:v.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=v.statusText===void 0?"":""+v.statusText,this.headers=new y(v.headers),this.url=v.url||"",this._initBody(w)}x.call(d.prototype),d.prototype.clone=function(){return new d(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new y(this.headers),url:this.url})},d.error=function(){var w=new d(null,{status:200,statusText:""});return w.ok=!1,w.status=0,w.type="error",w};var b=[301,302,303,307,308];d.redirect=function(w,v){if(b.indexOf(v)===-1)throw new RangeError("Invalid status code");return new d(null,{status:v,headers:{location:w}})},o.DOMException=a.DOMException;try{new o.DOMException}catch{o.DOMException=function(v,I){this.message=v,this.name=I;var P=Error(v);this.stack=P.stack},o.DOMException.prototype=Object.create(Error.prototype),o.DOMException.prototype.constructor=o.DOMException}function _(w,v){return new Promise(function(I,P){var E=new R(w,v);if(E.signal&&E.signal.aborted)return P(new o.DOMException("Aborted","AbortError"));var p=new XMLHttpRequest;function N(){p.abort()}p.onload=function(){var z={statusText:p.statusText,headers:$(p.getAllResponseHeaders()||"")};E.url.indexOf("file://")===0&&(p.status<200||p.status>599)?z.status=200:z.status=p.status,z.url="responseURL"in p?p.responseURL:z.headers.get("X-Request-URL");var V="response"in p?p.response:p.responseText;setTimeout(function(){I(new d(V,z))},0)},p.onerror=function(){setTimeout(function(){P(new TypeError("Network request failed"))},0)},p.ontimeout=function(){setTimeout(function(){P(new TypeError("Network request timed out"))},0)},p.onabort=function(){setTimeout(function(){P(new o.DOMException("Aborted","AbortError"))},0)};function q(z){try{return z===""&&a.location.href?a.location.href:z}catch{return z}}if(p.open(E.method,q(E.url),!0),E.credentials==="include"?p.withCredentials=!0:E.credentials==="omit"&&(p.withCredentials=!1),"responseType"in p&&(u.blob?p.responseType="blob":u.arrayBuffer&&(p.responseType="arraybuffer")),v&&typeof v.headers=="object"&&!(v.headers instanceof y||a.Headers&&v.headers instanceof a.Headers)){var H=[];Object.getOwnPropertyNames(v.headers).forEach(function(z){H.push(f(z)),p.setRequestHeader(z,m(v.headers[z]))}),E.headers.forEach(function(z,V){H.indexOf(V)===-1&&p.setRequestHeader(V,z)})}else E.headers.forEach(function(z,V){p.setRequestHeader(V,z)});E.signal&&(E.signal.addEventListener("abort",N),p.onreadystatechange=function(){p.readyState===4&&E.signal.removeEventListener("abort",N)}),p.send(typeof E._bodyInit>"u"?null:E._bodyInit)})}return _.polyfill=!0,a.fetch||(a.fetch=_,a.Headers=y,a.Request=R,a.Response=d),o.Headers=y,o.Request=R,o.Response=d,o.fetch=_,Object.defineProperty(o,"__esModule",{value:!0}),o})({})})(i),i.fetch.ponyfill=!0,delete i.fetch.polyfill;var s=r.fetch?r:i;e=s.fetch,e.default=s.fetch,e.fetch=s.fetch,e.Headers=s.Headers,e.Request=s.Request,e.Response=s.Response,t.exports=e})(dl,dl.exports)),dl.exports}var UO=kO();const ay=wh(UO);var LO=Object.defineProperty,FO=Object.defineProperties,jO=Object.getOwnPropertyDescriptors,cy=Object.getOwnPropertySymbols,qO=Object.prototype.hasOwnProperty,BO=Object.prototype.propertyIsEnumerable,uy=(t,e,r)=>e in t?LO(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ly=(t,e)=>{for(var r in e||(e={}))qO.call(e,r)&&uy(t,r,e[r]);if(cy)for(var r of cy(e))BO.call(e,r)&&uy(t,r,e[r]);return t},hy=(t,e)=>FO(t,jO(e));const zO={Accept:"application/json","Content-Type":"application/json"},HO="POST",dy={headers:zO,method:HO},fy=10;let Vt=class{constructor(e,r=!1){if(this.url=e,this.disableProviderPing=r,this.events=new sr.EventEmitter,this.isAvailable=!1,this.registering=!1,!Om(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=us(e),i=await(await ay(this.url,hy(ly({},dy),{body:r}))).json();this.onPayload({data:i})}catch(r){this.onError(e.id,r)}}async register(e=this.url){if(!Om(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,s)=>{this.events.once("register_error",n=>{this.resetMaxListeners(),s(n)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.isAvailable>"u")return s(new Error("HTTP connection is missing or invalid"));i()})})}this.url=e,this.registering=!0;try{if(!this.disableProviderPing){const r=us({id:1,jsonrpc:"2.0",method:"test",params:[]});await ay(e,hy(ly({},dy),{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"?Os(e.data):e.data;this.events.emit("payload",r)}onError(e,r){const i=this.parseError(r),s=i.message||i.toString(),n=Aa(e,s);this.events.emit("payload",n)}parseError(e,r=this.url){return H2(e,r,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>fy&&this.events.setMaxListeners(fy)}};const py="error",VO="wss://relay.walletconnect.org",KO="wc",WO="universal_provider",gy=`${KO}@2:${WO}:`,g3="https://rpc.walletconnect.org/v1/",zo="generic",GO=`${g3}bundler`,Pi={DEFAULT_CHAIN_CHANGED:"default_chain_changed"};var fl=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function YO(){this.__data__=[],this.size=0}var JO=YO;function QO(t,e){return t===e||t!==t&&e!==e}var Dh=QO,XO=Dh;function ZO(t,e){for(var r=t.length;r--;)if(XO(t[r][0],e))return r;return-1}var Rh=ZO,eT=Rh,tT=Array.prototype,rT=tT.splice;function iT(t){var e=this.__data__,r=eT(e,t);if(r<0)return!1;var i=e.length-1;return r==i?e.pop():rT.call(e,r,1),--this.size,!0}var sT=iT,nT=Rh;function oT(t){var e=this.__data__,r=nT(e,t);return r<0?void 0:e[r][1]}var aT=oT,cT=Rh;function uT(t){return cT(this.__data__,t)>-1}var lT=uT,hT=Rh;function dT(t,e){var r=this.__data__,i=hT(r,t);return i<0?(++this.size,r.push([t,e])):r[i][1]=e,this}var fT=dT,pT=JO,gT=sT,bT=aT,mT=lT,yT=fT;function Ho(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var i=t[e];this.set(i[0],i[1])}}Ho.prototype.clear=pT,Ho.prototype.delete=gT,Ho.prototype.get=bT,Ho.prototype.has=mT,Ho.prototype.set=yT;var Mh=Ho,wT=Mh;function vT(){this.__data__=new wT,this.size=0}var _T=vT;function ET(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var IT=ET;function AT(t){return this.__data__.get(t)}var ST=AT;function CT(t){return this.__data__.has(t)}var $T=CT,xT=typeof fl=="object"&&fl&&fl.Object===Object&&fl,b3=xT,PT=b3,NT=typeof self=="object"&&self&&self.Object===Object&&self,OT=PT||NT||Function("return this")(),Ca=OT,TT=Ca,DT=TT.Symbol,m3=DT,by=m3,y3=Object.prototype,RT=y3.hasOwnProperty,MT=y3.toString,oc=by?by.toStringTag:void 0;function kT(t){var e=RT.call(t,oc),r=t[oc];try{t[oc]=void 0;var i=!0}catch{}var s=MT.call(t);return i&&(e?t[oc]=r:delete t[oc]),s}var UT=kT,LT=Object.prototype,FT=LT.toString;function jT(t){return FT.call(t)}var qT=jT,my=m3,BT=UT,zT=qT,HT="[object Null]",VT="[object Undefined]",yy=my?my.toStringTag:void 0;function KT(t){return t==null?t===void 0?VT:HT:yy&&yy in Object(t)?BT(t):zT(t)}var kh=KT;function WT(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var Qn=WT,GT=kh,YT=Qn,JT="[object AsyncFunction]",QT="[object Function]",XT="[object GeneratorFunction]",ZT="[object Proxy]";function eD(t){if(!YT(t))return!1;var e=GT(t);return e==QT||e==XT||e==JT||e==ZT}var Cg=eD,tD=Ca,rD=tD["__core-js_shared__"],iD=rD,nf=iD,wy=(function(){var t=/[^.]+$/.exec(nf&&nf.keys&&nf.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""})();function sD(t){return!!wy&&wy in t}var nD=sD,oD=Function.prototype,aD=oD.toString;function cD(t){if(t!=null){try{return aD.call(t)}catch{}try{return t+""}catch{}}return""}var uD=cD,lD=Cg,hD=nD,dD=Qn,fD=uD,pD=/[\\^$.*+?()[\]{}|]/g,gD=/^\[object .+?Constructor\]$/,bD=Function.prototype,mD=Object.prototype,yD=bD.toString,wD=mD.hasOwnProperty,vD=RegExp("^"+yD.call(wD).replace(pD,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function _D(t){if(!dD(t)||hD(t))return!1;var e=lD(t)?vD:gD;return e.test(fD(t))}var ED=_D;function ID(t,e){return t?.[e]}var AD=ID,SD=ED,CD=AD;function $D(t,e){var r=CD(t,e);return SD(r)?r:void 0}var $g=$D,xD=$g,PD=Ca,ND=xD(PD,"Map"),w3=ND,OD=$g,TD=OD(Object,"create"),Uh=TD,vy=Uh;function DD(){this.__data__=vy?vy(null):{},this.size=0}var RD=DD;function MD(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var kD=MD,UD=Uh,LD="__lodash_hash_undefined__",FD=Object.prototype,jD=FD.hasOwnProperty;function qD(t){var e=this.__data__;if(UD){var r=e[t];return r===LD?void 0:r}return jD.call(e,t)?e[t]:void 0}var BD=qD,zD=Uh,HD=Object.prototype,VD=HD.hasOwnProperty;function KD(t){var e=this.__data__;return zD?e[t]!==void 0:VD.call(e,t)}var WD=KD,GD=Uh,YD="__lodash_hash_undefined__";function JD(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=GD&&e===void 0?YD:e,this}var QD=JD,XD=RD,ZD=kD,eR=BD,tR=WD,rR=QD;function Vo(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var i=t[e];this.set(i[0],i[1])}}Vo.prototype.clear=XD,Vo.prototype.delete=ZD,Vo.prototype.get=eR,Vo.prototype.has=tR,Vo.prototype.set=rR;var iR=Vo,_y=iR,sR=Mh,nR=w3;function oR(){this.size=0,this.__data__={hash:new _y,map:new(nR||sR),string:new _y}}var aR=oR;function cR(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var uR=cR,lR=uR;function hR(t,e){var r=t.__data__;return lR(e)?r[typeof e=="string"?"string":"hash"]:r.map}var Lh=hR,dR=Lh;function fR(t){var e=dR(this,t).delete(t);return this.size-=e?1:0,e}var pR=fR,gR=Lh;function bR(t){return gR(this,t).get(t)}var mR=bR,yR=Lh;function wR(t){return yR(this,t).has(t)}var vR=wR,_R=Lh;function ER(t,e){var r=_R(this,t),i=r.size;return r.set(t,e),this.size+=r.size==i?0:1,this}var IR=ER,AR=aR,SR=pR,CR=mR,$R=vR,xR=IR;function Ko(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var i=t[e];this.set(i[0],i[1])}}Ko.prototype.clear=AR,Ko.prototype.delete=SR,Ko.prototype.get=CR,Ko.prototype.has=$R,Ko.prototype.set=xR;var PR=Ko,NR=Mh,OR=w3,TR=PR,DR=200;function RR(t,e){var r=this.__data__;if(r instanceof NR){var i=r.__data__;if(!OR||i.length<DR-1)return i.push([t,e]),this.size=++r.size,this;r=this.__data__=new TR(i)}return r.set(t,e),this.size=r.size,this}var MR=RR,kR=Mh,UR=_T,LR=IT,FR=ST,jR=$T,qR=MR;function Wo(t){var e=this.__data__=new kR(t);this.size=e.size}Wo.prototype.clear=UR,Wo.prototype.delete=LR,Wo.prototype.get=FR,Wo.prototype.has=jR,Wo.prototype.set=qR;var BR=Wo,zR=$g,HR=(function(){try{var t=zR(Object,"defineProperty");return t({},"",{}),t}catch{}})(),v3=HR,Ey=v3;function VR(t,e,r){e=="__proto__"&&Ey?Ey(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var xg=VR,KR=xg,WR=Dh;function GR(t,e,r){(r!==void 0&&!WR(t[e],r)||r===void 0&&!(e in t))&&KR(t,e,r)}var _3=GR;function YR(t){return function(e,r,i){for(var s=-1,n=Object(e),o=i(e),a=o.length;a--;){var u=o[t?a:++s];if(r(n[u],u,n)===!1)break}return e}}var JR=YR,QR=JR,XR=QR(),ZR=XR,vp={exports:{}};(function(t,e){var r=Ca,i=e&&!e.nodeType&&e,s=i&&!0&&t&&!t.nodeType&&t,n=s&&s.exports===i,o=n?r.Buffer:void 0,a=o?o.allocUnsafe:void 0;function u(c,l){if(l)return c.slice();var h=c.length,f=a?a(h):new c.constructor(h);return c.copy(f),f}t.exports=u})(vp,vp.exports);var eM=Ca,tM=eM.Uint8Array,rM=tM,Iy=rM;function iM(t){var e=new t.constructor(t.byteLength);return new Iy(e).set(new Iy(t)),e}var sM=iM,nM=sM;function oM(t,e){var r=e?nM(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var aM=oM;function cM(t,e){var r=-1,i=t.length;for(e||(e=Array(i));++r<i;)e[r]=t[r];return e}var uM=cM,lM=Qn,Ay=Object.create,hM=(function(){function t(){}return function(e){if(!lM(e))return{};if(Ay)return Ay(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}})(),dM=hM;function fM(t,e){return function(r){return t(e(r))}}var pM=fM,gM=pM,bM=gM(Object.getPrototypeOf,Object),E3=bM,mM=Object.prototype;function yM(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||mM;return t===r}var I3=yM,wM=dM,vM=E3,_M=I3;function EM(t){return typeof t.constructor=="function"&&!_M(t)?wM(vM(t)):{}}var IM=EM;function AM(t){return t!=null&&typeof t=="object"}var Ou=AM,SM=kh,CM=Ou,$M="[object Arguments]";function xM(t){return CM(t)&&SM(t)==$M}var PM=xM,Sy=PM,NM=Ou,A3=Object.prototype,OM=A3.hasOwnProperty,TM=A3.propertyIsEnumerable,DM=Sy((function(){return arguments})())?Sy:function(t){return NM(t)&&OM.call(t,"callee")&&!TM.call(t,"callee")},S3=DM,RM=Array.isArray,C3=RM,MM=9007199254740991;function kM(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=MM}var $3=kM,UM=Cg,LM=$3;function FM(t){return t!=null&&LM(t.length)&&!UM(t)}var Pg=FM,jM=Pg,qM=Ou;function BM(t){return qM(t)&&jM(t)}var zM=BM,ch={exports:{}};function HM(){return!1}var VM=HM;(function(t,e){var r=Ca,i=VM,s=e&&!e.nodeType&&e,n=s&&!0&&t&&!t.nodeType&&t,o=n&&n.exports===s,a=o?r.Buffer:void 0,u=a?a.isBuffer:void 0,c=u||i;t.exports=c})(ch,ch.exports);var KM=kh,WM=E3,GM=Ou,YM="[object Object]",JM=Function.prototype,QM=Object.prototype,x3=JM.toString,XM=QM.hasOwnProperty,ZM=x3.call(Object);function ek(t){if(!GM(t)||KM(t)!=YM)return!1;var e=WM(t);if(e===null)return!0;var r=XM.call(e,"constructor")&&e.constructor;return typeof r=="function"&&r instanceof r&&x3.call(r)==ZM}var tk=ek,rk=kh,ik=$3,sk=Ou,nk="[object Arguments]",ok="[object Array]",ak="[object Boolean]",ck="[object Date]",uk="[object Error]",lk="[object Function]",hk="[object Map]",dk="[object Number]",fk="[object Object]",pk="[object RegExp]",gk="[object Set]",bk="[object String]",mk="[object WeakMap]",yk="[object ArrayBuffer]",wk="[object DataView]",vk="[object Float32Array]",_k="[object Float64Array]",Ek="[object Int8Array]",Ik="[object Int16Array]",Ak="[object Int32Array]",Sk="[object Uint8Array]",Ck="[object Uint8ClampedArray]",$k="[object Uint16Array]",xk="[object Uint32Array]",ft={};ft[vk]=ft[_k]=ft[Ek]=ft[Ik]=ft[Ak]=ft[Sk]=ft[Ck]=ft[$k]=ft[xk]=!0,ft[nk]=ft[ok]=ft[yk]=ft[ak]=ft[wk]=ft[ck]=ft[uk]=ft[lk]=ft[hk]=ft[dk]=ft[fk]=ft[pk]=ft[gk]=ft[bk]=ft[mk]=!1;function Pk(t){return sk(t)&&ik(t.length)&&!!ft[rk(t)]}var Nk=Pk;function Ok(t){return function(e){return t(e)}}var Tk=Ok,_p={exports:{}};(function(t,e){var r=b3,i=e&&!e.nodeType&&e,s=i&&!0&&t&&!t.nodeType&&t,n=s&&s.exports===i,o=n&&r.process,a=(function(){try{var u=s&&s.require&&s.require("util").types;return u||o&&o.binding&&o.binding("util")}catch{}})();t.exports=a})(_p,_p.exports);var Dk=Nk,Rk=Tk,Cy=_p.exports,$y=Cy&&Cy.isTypedArray,Mk=$y?Rk($y):Dk,P3=Mk;function kk(t,e){if(!(e==="constructor"&&typeof t[e]=="function")&&e!="__proto__")return t[e]}var N3=kk,Uk=xg,Lk=Dh,Fk=Object.prototype,jk=Fk.hasOwnProperty;function qk(t,e,r){var i=t[e];(!(jk.call(t,e)&&Lk(i,r))||r===void 0&&!(e in t))&&Uk(t,e,r)}var Bk=qk,zk=Bk,Hk=xg;function Vk(t,e,r,i){var s=!r;r||(r={});for(var n=-1,o=e.length;++n<o;){var a=e[n],u=i?i(r[a],t[a],a,r,t):void 0;u===void 0&&(u=t[a]),s?Hk(r,a,u):zk(r,a,u)}return r}var Kk=Vk;function Wk(t,e){for(var r=-1,i=Array(t);++r<t;)i[r]=e(r);return i}var Gk=Wk,Yk=9007199254740991,Jk=/^(?:0|[1-9]\d*)$/;function Qk(t,e){var r=typeof t;return e=e??Yk,!!e&&(r=="number"||r!="symbol"&&Jk.test(t))&&t>-1&&t%1==0&&t<e}var O3=Qk,Xk=Gk,Zk=S3,eU=C3,tU=ch.exports,rU=O3,iU=P3,sU=Object.prototype,nU=sU.hasOwnProperty;function oU(t,e){var r=eU(t),i=!r&&Zk(t),s=!r&&!i&&tU(t),n=!r&&!i&&!s&&iU(t),o=r||i||s||n,a=o?Xk(t.length,String):[],u=a.length;for(var c in t)(e||nU.call(t,c))&&!(o&&(c=="length"||s&&(c=="offset"||c=="parent")||n&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||rU(c,u)))&&a.push(c);return a}var aU=oU;function cU(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var uU=cU,lU=Qn,hU=I3,dU=uU,fU=Object.prototype,pU=fU.hasOwnProperty;function gU(t){if(!lU(t))return dU(t);var e=hU(t),r=[];for(var i in t)i=="constructor"&&(e||!pU.call(t,i))||r.push(i);return r}var bU=gU,mU=aU,yU=bU,wU=Pg;function vU(t){return wU(t)?mU(t,!0):yU(t)}var T3=vU,_U=Kk,EU=T3;function IU(t){return _U(t,EU(t))}var AU=IU,xy=_3,SU=vp.exports,CU=aM,$U=uM,xU=IM,Py=S3,Ny=C3,PU=zM,NU=ch.exports,OU=Cg,TU=Qn,DU=tk,RU=P3,Oy=N3,MU=AU;function kU(t,e,r,i,s,n,o){var a=Oy(t,r),u=Oy(e,r),c=o.get(u);if(c){xy(t,r,c);return}var l=n?n(a,u,r+"",t,e,o):void 0,h=l===void 0;if(h){var f=Ny(u),m=!f&&NU(u),g=!f&&!m&&RU(u);l=u,f||m||g?Ny(a)?l=a:PU(a)?l=$U(a):m?(h=!1,l=SU(u,!0)):g?(h=!1,l=CU(u,!0)):l=[]:DU(u)||Py(u)?(l=a,Py(a)?l=MU(a):(!TU(a)||OU(a))&&(l=xU(u))):h=!1}h&&(o.set(u,l),s(l,u,i,n,o),o.delete(u)),xy(t,r,l)}var UU=kU,LU=BR,FU=_3,jU=ZR,qU=UU,BU=Qn,zU=T3,HU=N3;function D3(t,e,r,i,s){t!==e&&jU(e,function(n,o){if(s||(s=new LU),BU(n))qU(t,e,o,r,D3,i,s);else{var a=i?i(HU(t,o),n,o+"",t,e,s):void 0;a===void 0&&(a=n),FU(t,o,a)}},zU)}var VU=D3;function KU(t){return t}var R3=KU;function WU(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}var GU=WU,YU=GU,Ty=Math.max;function JU(t,e,r){return e=Ty(e===void 0?t.length-1:e,0),function(){for(var i=arguments,s=-1,n=Ty(i.length-e,0),o=Array(n);++s<n;)o[s]=i[e+s];s=-1;for(var a=Array(e+1);++s<e;)a[s]=i[s];return a[e]=r(o),YU(t,this,a)}}var QU=JU;function XU(t){return function(){return t}}var ZU=XU,eL=ZU,Dy=v3,tL=R3,rL=Dy?function(t,e){return Dy(t,"toString",{configurable:!0,enumerable:!1,value:eL(e),writable:!0})}:tL,iL=rL,sL=800,nL=16,oL=Date.now;function aL(t){var e=0,r=0;return function(){var i=oL(),s=nL-(i-r);if(r=i,s>0){if(++e>=sL)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var cL=aL,uL=iL,lL=cL,hL=lL(uL),dL=hL,fL=R3,pL=QU,gL=dL;function bL(t,e){return gL(pL(t,e,fL),t+"")}var mL=bL,yL=Dh,wL=Pg,vL=O3,_L=Qn;function EL(t,e,r){if(!_L(r))return!1;var i=typeof e;return(i=="number"?wL(r)&&vL(e,r.length):i=="string"&&e in r)?yL(r[e],t):!1}var IL=EL,AL=mL,SL=IL;function CL(t){return AL(function(e,r){var i=-1,s=r.length,n=s>1?r[s-1]:void 0,o=s>2?r[2]:void 0;for(n=t.length>3&&typeof n=="function"?(s--,n):void 0,o&&SL(r[0],r[1],o)&&(n=s<3?void 0:n,s=1),e=Object(e);++i<s;){var a=r[i];a&&t(e,a,i,n)}return e})}var $L=CL,xL=VU,PL=$L,NL=PL(function(t,e,r){xL(t,e,r)}),OL=NL,TL=Object.defineProperty,DL=Object.defineProperties,RL=Object.getOwnPropertyDescriptors,Ry=Object.getOwnPropertySymbols,ML=Object.prototype.hasOwnProperty,kL=Object.prototype.propertyIsEnumerable,My=(t,e,r)=>e in t?TL(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,pl=(t,e)=>{for(var r in e||(e={}))ML.call(e,r)&&My(t,r,e[r]);if(Ry)for(var r of Ry(e))kL.call(e,r)&&My(t,r,e[r]);return t},UL=(t,e)=>DL(t,RL(e));function di(t,e,r){var i;const s=ra(t);return((i=e.rpcMap)==null?void 0:i[s.reference])||`${g3}?chainId=${s.namespace}:${s.reference}&projectId=${r}`}function Xn(t){return t.includes(":")?t.split(":")[1]:t}function M3(t){return t.map(e=>`${e.split(":")[0]}:${e.split(":")[1]}`)}function LL(t,e){const r=Object.keys(e.namespaces).filter(s=>s.includes(t));if(!r.length)return[];const i=[];return r.forEach(s=>{const n=e.namespaces[s].accounts;i.push(...n)}),i}function of(t={},e={}){const r=ky(t),i=ky(e);return OL(r,i)}function ky(t){var e,r,i,s;const n={};if(!zc(t))return n;for(const[o,a]of Object.entries(t)){const u=Eg(o)?[o]:a.chains,c=a.methods||[],l=a.events||[],h=a.rpcMap||{},f=vc(o);n[f]=UL(pl(pl({},n[f]),a),{chains:Ul(u,(e=n[f])==null?void 0:e.chains),methods:Ul(c,(r=n[f])==null?void 0:r.methods),events:Ul(l,(i=n[f])==null?void 0:i.events),rpcMap:pl(pl({},h),(s=n[f])==null?void 0:s.rpcMap)})}return n}function FL(t){return t.includes(":")?t.split(":")[2]:t}function Uy(t){const e={};for(const[r,i]of Object.entries(t)){const s=i.methods||[],n=i.events||[],o=i.accounts||[],a=Eg(r)?[r]:i.chains?i.chains:M3(i.accounts);e[r]={chains:a,methods:s,events:n,accounts:o}}return e}function af(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))}const k3={},Ne=t=>k3[t],cf=(t,e)=>{k3[t]=e};var jL=Object.defineProperty,qL=(t,e,r)=>e in t?jL(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,po=(t,e,r)=>qL(t,typeof e!="symbol"?e+"":e,r);class BL{constructor(e){po(this,"name","polkadot"),po(this,"client"),po(this,"httpProviders"),po(this,"events"),po(this,"namespace"),po(this,"chainId"),this.namespace=e.namespace,this.events=Ne("events"),this.client=Ne("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}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]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(Pi.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var i;const s=Xn(r);e[s]=this.createHttpProvider(s,(i=this.namespace.rpcMap)==null?void 0:i[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const i=this.createHttpProvider(e,r);i&&(this.httpProviders[e]=i)}createHttpProvider(e,r){const i=r||di(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new Et(new Vt(i,Ne("disableProviderPing")))}}var zL=Object.defineProperty,HL=Object.defineProperties,VL=Object.getOwnPropertyDescriptors,Ly=Object.getOwnPropertySymbols,KL=Object.prototype.hasOwnProperty,WL=Object.prototype.propertyIsEnumerable,Ep=(t,e,r)=>e in t?zL(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Fy=(t,e)=>{for(var r in e||(e={}))KL.call(e,r)&&Ep(t,r,e[r]);if(Ly)for(var r of Ly(e))WL.call(e,r)&&Ep(t,r,e[r]);return t},jy=(t,e)=>HL(t,VL(e)),go=(t,e,r)=>Ep(t,typeof e!="symbol"?e+"":e,r);class GL{constructor(e){go(this,"name","eip155"),go(this,"client"),go(this,"chainId"),go(this,"namespace"),go(this,"httpProviders"),go(this,"events"),this.namespace=e.namespace,this.events=Ne("events"),this.client=Ne("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}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)}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),this.chainId=parseInt(e),this.events.emit(Pi.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}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||di(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new Et(new Vt(i,Ne("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 s=parseInt(Xn(r));e[s]=this.createHttpProvider(s,(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(){const e=this.chainId,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}async handleSwitchChain(e){var r,i;let s=e.request.params?(r=e.request.params[0])==null?void 0:r.chainId:"0x0";s=s.startsWith("0x")?s:`0x${s}`;const n=parseInt(s,16);if(this.isChainApproved(n))this.setDefaultChain(`${n}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:e.topic,request:{method:e.request.method,params:[{chainId:s}]},chainId:(i=this.namespace.chains)==null?void 0:i[0]}),this.setDefaultChain(`${n}`);else throw new Error(`Failed to switch to chain 'eip155:${n}'. 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,s;const n=(i=(r=e.request)==null?void 0:r.params)==null?void 0:i[0];if(!n)throw new Error("Missing address parameter in `wallet_getCapabilities` request");const o=this.client.session.get(e.topic),a=((s=o?.sessionProperties)==null?void 0:s.capabilities)||{};if(a!=null&&a[n])return a?.[n];const u=await this.client.request(e);try{await this.client.session.update(e.topic,{sessionProperties:jy(Fy({},o.sessionProperties||{}),{capabilities:jy(Fy({},a||{}),{[n]:u})})})}catch(c){console.warn("Failed to update session with capabilities",c)}return u}async getCallStatus(e){var r,i;const s=this.client.session.get(e.topic),n=(r=s.sessionProperties)==null?void 0:r.bundler_name;if(n){const a=this.getBundlerUrl(e.chainId,n);try{return await this.getUserOperationReceipt(a,e)}catch(u){console.warn("Failed to fetch call status from bundler",u,a)}}const o=(i=s.sessionProperties)==null?void 0:i.bundler_url;if(o)try{return await this.getUserOperationReceipt(o,e)}catch(a){console.warn("Failed to fetch call status from custom bundler",a,o)}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 s=new URL(e),n=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Lr("eth_getUserOperationReceipt",[(i=r.request.params)==null?void 0:i[0]]))});if(!n.ok)throw new Error(`Failed to fetch user operation receipt - ${n.status}`);return await n.json()}getBundlerUrl(e,r){return`${GO}?projectId=${this.client.core.projectId}&chainId=${e}&bundler=${r}`}}var YL=Object.defineProperty,JL=(t,e,r)=>e in t?YL(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,bo=(t,e,r)=>JL(t,typeof e!="symbol"?e+"":e,r);class QL{constructor(e){bo(this,"name","solana"),bo(this,"client"),bo(this,"httpProviders"),bo(this,"events"),bo(this,"namespace"),bo(this,"chainId"),this.namespace=e.namespace,this.events=Ne("events"),this.client=Ne("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(Pi.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}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]}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(){const e={};return this.namespace.chains.forEach(r=>{var i;const s=Xn(r);e[s]=this.createHttpProvider(s,(i=this.namespace.rpcMap)==null?void 0:i[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const i=this.createHttpProvider(e,r);i&&(this.httpProviders[e]=i)}createHttpProvider(e,r){const i=r||di(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new Et(new Vt(i,Ne("disableProviderPing")))}}var XL=Object.defineProperty,ZL=(t,e,r)=>e in t?XL(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,mo=(t,e,r)=>ZL(t,typeof e!="symbol"?e+"":e,r);class eF{constructor(e){mo(this,"name","cosmos"),mo(this,"client"),mo(this,"httpProviders"),mo(this,"events"),mo(this,"namespace"),mo(this,"chainId"),this.namespace=e.namespace,this.events=Ne("events"),this.client=Ne("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}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]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(Pi.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}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(){const e={};return this.namespace.chains.forEach(r=>{var i;const s=Xn(r);e[s]=this.createHttpProvider(s,(i=this.namespace.rpcMap)==null?void 0:i[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const i=this.createHttpProvider(e,r);i&&(this.httpProviders[e]=i)}createHttpProvider(e,r){const i=r||di(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new Et(new Vt(i,Ne("disableProviderPing")))}}var tF=Object.defineProperty,rF=(t,e,r)=>e in t?tF(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,yo=(t,e,r)=>rF(t,typeof e!="symbol"?e+"":e,r);class iF{constructor(e){yo(this,"name","algorand"),yo(this,"client"),yo(this,"httpProviders"),yo(this,"events"),yo(this,"namespace"),yo(this,"chainId"),this.namespace=e.namespace,this.events=Ne("events"),this.client=Ne("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){if(!this.httpProviders[e]){const i=r||di(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,i)}this.chainId=e,this.events.emit(Pi.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}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]}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(){const e={};return this.namespace.chains.forEach(r=>{var i;e[r]=this.createHttpProvider(r,(i=this.namespace.rpcMap)==null?void 0:i[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const i=this.createHttpProvider(e,r);i&&(this.httpProviders[e]=i)}createHttpProvider(e,r){const i=r||di(e,this.namespace,this.client.core.projectId);return typeof i>"u"?void 0:new Et(new Vt(i,Ne("disableProviderPing")))}}var sF=Object.defineProperty,nF=(t,e,r)=>e in t?sF(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,wo=(t,e,r)=>nF(t,typeof e!="symbol"?e+"":e,r);class oF{constructor(e){wo(this,"name","cip34"),wo(this,"client"),wo(this,"httpProviders"),wo(this,"events"),wo(this,"namespace"),wo(this,"chainId"),this.namespace=e.namespace,this.events=Ne("events"),this.client=Ne("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}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]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(Pi.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}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(){const e={};return this.namespace.chains.forEach(r=>{const i=this.getCardanoRPCUrl(r),s=Xn(r);e[s]=this.createHttpProvider(s,i)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}getCardanoRPCUrl(e){const r=this.namespace.rpcMap;if(r)return r[e]}setHttpProvider(e,r){const i=this.createHttpProvider(e,r);i&&(this.httpProviders[e]=i)}createHttpProvider(e,r){const i=r||this.getCardanoRPCUrl(e);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new Et(new Vt(i,Ne("disableProviderPing")))}}var aF=Object.defineProperty,cF=(t,e,r)=>e in t?aF(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,vo=(t,e,r)=>cF(t,typeof e!="symbol"?e+"":e,r);class uF{constructor(e){vo(this,"name","elrond"),vo(this,"client"),vo(this,"httpProviders"),vo(this,"events"),vo(this,"namespace"),vo(this,"chainId"),this.namespace=e.namespace,this.events=Ne("events"),this.client=Ne("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(Pi.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}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]}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(){const e={};return this.namespace.chains.forEach(r=>{var i;const s=Xn(r);e[s]=this.createHttpProvider(s,(i=this.namespace.rpcMap)==null?void 0:i[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const i=this.createHttpProvider(e,r);i&&(this.httpProviders[e]=i)}createHttpProvider(e,r){const i=r||di(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new Et(new Vt(i,Ne("disableProviderPing")))}}var lF=Object.defineProperty,hF=(t,e,r)=>e in t?lF(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,_o=(t,e,r)=>hF(t,typeof e!="symbol"?e+"":e,r);class dF{constructor(e){_o(this,"name","multiversx"),_o(this,"client"),_o(this,"httpProviders"),_o(this,"events"),_o(this,"namespace"),_o(this,"chainId"),this.namespace=e.namespace,this.events=Ne("events"),this.client=Ne("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(Pi.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}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]}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(){const e={};return this.namespace.chains.forEach(r=>{var i;const s=Xn(r);e[s]=this.createHttpProvider(s,(i=this.namespace.rpcMap)==null?void 0:i[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const i=this.createHttpProvider(e,r);i&&(this.httpProviders[e]=i)}createHttpProvider(e,r){const i=r||di(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new Et(new Vt(i,Ne("disableProviderPing")))}}var fF=Object.defineProperty,pF=(t,e,r)=>e in t?fF(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Eo=(t,e,r)=>pF(t,typeof e!="symbol"?e+"":e,r);class gF{constructor(e){Eo(this,"name","near"),Eo(this,"client"),Eo(this,"httpProviders"),Eo(this,"events"),Eo(this,"namespace"),Eo(this,"chainId"),this.namespace=e.namespace,this.events=Ne("events"),this.client=Ne("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}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]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){if(this.chainId=e,!this.httpProviders[e]){const i=r||di(`${this.name}:${e}`,this.namespace);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,i)}this.events.emit(Pi.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var i;e[r]=this.createHttpProvider(r,(i=this.namespace.rpcMap)==null?void 0:i[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const i=this.createHttpProvider(e,r);i&&(this.httpProviders[e]=i)}createHttpProvider(e,r){const i=r||di(e,this.namespace);return typeof i>"u"?void 0:new Et(new Vt(i,Ne("disableProviderPing")))}}var bF=Object.defineProperty,mF=(t,e,r)=>e in t?bF(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Io=(t,e,r)=>mF(t,typeof e!="symbol"?e+"":e,r);class yF{constructor(e){Io(this,"name","tezos"),Io(this,"client"),Io(this,"httpProviders"),Io(this,"events"),Io(this,"namespace"),Io(this,"chainId"),this.namespace=e.namespace,this.events=Ne("events"),this.client=Ne("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}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]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){if(this.chainId=e,!this.httpProviders[e]){const i=r||di(`${this.name}:${e}`,this.namespace);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,i)}this.events.emit(Pi.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{e[r]=this.createHttpProvider(r)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const i=this.createHttpProvider(e,r);i&&(this.httpProviders[e]=i)}createHttpProvider(e,r){const i=r||di(e,this.namespace);return typeof i>"u"?void 0:new Et(new Vt(i))}}var wF=Object.defineProperty,vF=(t,e,r)=>e in t?wF(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ao=(t,e,r)=>vF(t,typeof e!="symbol"?e+"":e,r);class _F{constructor(e){Ao(this,"name",zo),Ao(this,"client"),Ao(this,"httpProviders"),Ao(this,"events"),Ao(this,"namespace"),Ao(this,"chainId"),this.namespace=e.namespace,this.events=Ne("events"),this.client=Ne("client"),this.chainId=this.getDefaultChain(),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),this.chainId=e,this.events.emit(Pi.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}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]}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(s=>{const n=ra(s);i[`${n.namespace}:${n.reference}`]=this.createHttpProvider(s)}),i}getHttpProvider(e){const r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const i=this.createHttpProvider(e,r);i&&(this.httpProviders[e]=i)}createHttpProvider(e,r){const i=r||di(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new Et(new Vt(i,Ne("disableProviderPing")))}}var EF=Object.defineProperty,IF=Object.defineProperties,AF=Object.getOwnPropertyDescriptors,qy=Object.getOwnPropertySymbols,SF=Object.prototype.hasOwnProperty,CF=Object.prototype.propertyIsEnumerable,Ip=(t,e,r)=>e in t?EF(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,gl=(t,e)=>{for(var r in e||(e={}))SF.call(e,r)&&Ip(t,r,e[r]);if(qy)for(var r of qy(e))CF.call(e,r)&&Ip(t,r,e[r]);return t},uf=(t,e)=>IF(t,AF(e)),Ui=(t,e,r)=>Ip(t,typeof e!="symbol"?e+"":e,r);let $F=class U3{constructor(e){Ui(this,"client"),Ui(this,"namespaces"),Ui(this,"optionalNamespaces"),Ui(this,"sessionProperties"),Ui(this,"events",new wa),Ui(this,"rpcProviders",{}),Ui(this,"session"),Ui(this,"providerOpts"),Ui(this,"logger"),Ui(this,"uri"),Ui(this,"disableProviderPing",!1),this.providerOpts=e,this.logger=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:cn(Ts({level:e?.logger||py})),this.disableProviderPing=e?.disableProviderPing||!1}static async init(e){const r=new U3(e);return await r.initialize(),r}async request(e,r,i){const[s,n]=this.validateChain(r);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(s).request({request:gl({},e),chainId:`${s}:${n}`,topic:this.session.topic,expiry:i})}sendAsync(e,r,i,s){const n=new Date().getTime();this.request(e,i,s).then(o=>r(null,ln(n,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}),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:Qe("USER_DISCONNECTED")}),await this.cleanup()}async connect(e){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(e),await 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:s}=await this.client.authenticate(e,r);i&&(this.uri=i,this.events.emit("display_uri",i));const n=await s();if(this.session=n.session,this.session){const o=Uy(this.session.namespaces);this.namespaces=of(this.namespaces,o),this.persist("namespaces",this.namespaces),this.onConnect()}return n}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});r&&(this.uri=r,this.events.emit("display_uri",r));const s=await i();this.session=s;const n=Uy(s.namespaces);return this.namespaces=of(this.namespaces,n),this.persist("namespaces",this.namespaces),this.onConnect(),this.session}setDefaultChain(e,r){try{if(!this.session)return;const[i,s]=this.validateChain(e),n=this.getProvider(i);n.name===zo?n.setDefaultChain(`${i}:${s}`,r):n.setDefaultChain(s,r)}catch(i){if(!/Please call connect/.test(i.message))throw i}}async cleanupPendingPairings(e={}){this.logger.info("Cleaning up inactive pairings...");const r=this.client.pairing.getAll();if(Fn(r)){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}`)}}abortPairingAttempt(){this.logger.warn("abortPairingAttempt is deprecated. This is now a no-op.")}async checkStorage(){if(this.namespaces=await this.getFromStore("namespaces"),this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.client.session.length){const e=this.client.session.keys.length-1;this.session=this.client.session.get(this.client.session.keys[e]),this.createProviders()}}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){this.client=this.providerOpts.client||await MO.init({core:this.providerOpts.core,logger:this.providerOpts.logger||py,relayUrl:this.providerOpts.relayUrl||VO,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.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=>vc(r)))];cf("client",this.client),cf("events",this.events),cf("disableProviderPing",this.disableProviderPing),e.forEach(r=>{if(!this.session)return;const i=LL(r,this.session),s=M3(i),n=of(this.namespaces,this.optionalNamespaces),o=uf(gl({},n[r]),{accounts:i,chains:s});switch(r){case"eip155":this.rpcProviders[r]=new GL({namespace:o});break;case"algorand":this.rpcProviders[r]=new iF({namespace:o});break;case"solana":this.rpcProviders[r]=new QL({namespace:o});break;case"cosmos":this.rpcProviders[r]=new eF({namespace:o});break;case"polkadot":this.rpcProviders[r]=new BL({namespace:o});break;case"cip34":this.rpcProviders[r]=new oF({namespace:o});break;case"elrond":this.rpcProviders[r]=new uF({namespace:o});break;case"multiversx":this.rpcProviders[r]=new dF({namespace:o});break;case"near":this.rpcProviders[r]=new gF({namespace:o});break;case"tezos":this.rpcProviders[r]=new yF({namespace:o});break;default:this.rpcProviders[zo]?this.rpcProviders[zo].updateNamespace(o):this.rpcProviders[zo]=new _F({namespace:o})}})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",e=>{this.events.emit("session_ping",e)}),this.client.on("session_event",e=>{const{params:r}=e,{event:i}=r;if(i.name==="accountsChanged"){const s=i.data;s&&Fn(s)&&this.events.emit("accountsChanged",s.map(FL))}else if(i.name==="chainChanged"){const s=r.chainId,n=r.event.data,o=vc(s),a=af(s)!==af(n)?`${o}:${af(n)}`:s;this.onChainChanged(a)}else this.events.emit(i.name,i.data);this.events.emit("session_event",e)}),this.client.on("session_update",({topic:e,params:r})=>{var i;const{namespaces:s}=r,n=(i=this.client)==null?void 0:i.session.get(e);this.session=uf(gl({},n),{namespaces:s}),this.onSessionUpdate(),this.events.emit("session_update",{topic:e,params:r})}),this.client.on("session_delete",async e=>{await this.cleanup(),this.events.emit("session_delete",e),this.events.emit("disconnect",uf(gl({},Qe("USER_DISCONNECTED")),{data:e.topic}))}),this.on(Pi.DEFAULT_CHAIN_CHANGED,e=>{this.onChainChanged(e,!0)})}getProvider(e){return this.rpcProviders[e]||this.rpcProviders[zo]}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:s}=e;r&&Object.keys(r).length&&(this.namespaces=r),i&&Object.keys(i).length&&(this.optionalNamespaces=i),this.sessionProperties=s,this.persist("namespaces",r),this.persist("optionalNamespaces",i)}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=>vc(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 s=vc(Object.keys(this.namespaces)[0]),n=this.rpcProviders[s].getDefaultChain();return[s,n]}async requestAccounts(){const[e]=this.validateChain();return await this.getProvider(e).requestAccounts()}onChainChanged(e,r=!1){if(!this.namespaces)return;const[i,s]=this.validateChain(e);s&&(r||this.getProvider(i).setDefaultChain(s),this.namespaces[i]?this.namespaces[i].defaultChain=s:this.namespaces[`${i}:${s}`]?this.namespaces[`${i}:${s}`].defaultChain=s:this.namespaces[`${i}:${s}`]={defaultChain:s},this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",s))}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.session=void 0,this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,this.persist("namespaces",void 0),this.persist("optionalNamespaces",void 0),this.persist("sessionProperties",void 0),await this.cleanupPendingPairings({deletePairings:!0})}persist(e,r){this.client.core.storage.setItem(`${gy}/${e}`,r)}async getFromStore(e){return await this.client.core.storage.getItem(`${gy}/${e}`)}};const xF=$F,L3={caipNetworkIdToNumber(t){return t?Number(t.split(":")[1]):void 0},parseEvmChainId(t){return typeof t=="string"?this.caipNetworkIdToNumber(t):t},getNetworksByNamespace(t,e){return t?.filter(r=>r.chainNamespace===e)||[]},getFirstNetworkByNamespace(t,e){return this.getNetworksByNamespace(t,e)[0]}};var PF=20,NF=1,jn=1e6,By=1e6,OF=-7,TF=21,DF=!1,Tu="[big.js] ",Zn=Tu+"Invalid ",Fh=Zn+"decimal places",RF=Zn+"rounding mode",F3=Tu+"Division by zero",Ve={},cs=void 0,MF=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function j3(){function t(e){var r=this;if(!(r instanceof t))return e===cs?j3():new t(e);if(e instanceof t)r.s=e.s,r.e=e.e,r.c=e.c.slice();else{if(typeof e!="string"){if(t.strict===!0&&typeof e!="bigint")throw TypeError(Zn+"value");e=e===0&&1/e<0?"-0":String(e)}kF(r,e)}r.constructor=t}return t.prototype=Ve,t.DP=PF,t.RM=NF,t.NE=OF,t.PE=TF,t.strict=DF,t.roundDown=0,t.roundHalfUp=1,t.roundHalfEven=2,t.roundUp=3,t}function kF(t,e){var r,i,s;if(!MF.test(e))throw Error(Zn+"number");for(t.s=e.charAt(0)=="-"?(e=e.slice(1),-1):1,(r=e.indexOf("."))>-1&&(e=e.replace(".","")),(i=e.search(/e/i))>0?(r<0&&(r=i),r+=+e.slice(i+1),e=e.substring(0,i)):r<0&&(r=e.length),s=e.length,i=0;i<s&&e.charAt(i)=="0";)++i;if(i==s)t.c=[t.e=0];else{for(;s>0&&e.charAt(--s)=="0";);for(t.e=r-i-1,t.c=[],r=0;i<=s;)t.c[r++]=+e.charAt(i++)}return t}function eo(t,e,r,i){var s=t.c;if(r===cs&&(r=t.constructor.RM),r!==0&&r!==1&&r!==2&&r!==3)throw Error(RF);if(e<1)i=r===3&&(i||!!s[0])||e===0&&(r===1&&s[0]>=5||r===2&&(s[0]>5||s[0]===5&&(i||s[1]!==cs))),s.length=1,i?(t.e=t.e-e+1,s[0]=1):s[0]=t.e=0;else if(e<s.length){if(i=r===1&&s[e]>=5||r===2&&(s[e]>5||s[e]===5&&(i||s[e+1]!==cs||s[e-1]&1))||r===3&&(i||!!s[0]),s.length=e,i){for(;++s[--e]>9;)if(s[e]=0,e===0){++t.e,s.unshift(1);break}}for(e=s.length;!s[--e];)s.pop()}return t}function to(t,e,r){var i=t.e,s=t.c.join(""),n=s.length;if(e)s=s.charAt(0)+(n>1?"."+s.slice(1):"")+(i<0?"e":"e+")+i;else if(i<0){for(;++i;)s="0"+s;s="0."+s}else if(i>0)if(++i>n)for(i-=n;i--;)s+="0";else i<n&&(s=s.slice(0,i)+"."+s.slice(i));else n>1&&(s=s.charAt(0)+"."+s.slice(1));return t.s<0&&r?"-"+s:s}Ve.abs=function(){var t=new this.constructor(this);return t.s=1,t};Ve.cmp=function(t){var e,r=this,i=r.c,s=(t=new r.constructor(t)).c,n=r.s,o=t.s,a=r.e,u=t.e;if(!i[0]||!s[0])return i[0]?n:s[0]?-o:0;if(n!=o)return n;if(e=n<0,a!=u)return a>u^e?1:-1;for(o=(a=i.length)<(u=s.length)?a:u,n=-1;++n<o;)if(i[n]!=s[n])return i[n]>s[n]^e?1:-1;return a==u?0:a>u^e?1:-1};Ve.div=function(t){var e=this,r=e.constructor,i=e.c,s=(t=new r(t)).c,n=e.s==t.s?1:-1,o=r.DP;if(o!==~~o||o<0||o>jn)throw Error(Fh);if(!s[0])throw Error(F3);if(!i[0])return t.s=n,t.c=[t.e=0],t;var a,u,c,l,h,f=s.slice(),m=a=s.length,g=i.length,y=i.slice(0,a),C=y.length,S=t,A=S.c=[],D=0,O=o+(S.e=e.e-t.e)+1;for(S.s=n,n=O<0?0:O,f.unshift(0);C++<a;)y.push(0);do{for(c=0;c<10;c++){if(a!=(C=y.length))l=a>C?1:-1;else for(h=-1,l=0;++h<a;)if(s[h]!=y[h]){l=s[h]>y[h]?1:-1;break}if(l<0){for(u=C==a?s:f;C;){if(y[--C]<u[C]){for(h=C;h&&!y[--h];)y[h]=9;--y[h],y[C]+=10}y[C]-=u[C]}for(;!y[0];)y.shift()}else break}A[D++]=l?c:++c,y[0]&&l?y[C]=i[m]||0:y=[i[m]]}while((m++<g||y[0]!==cs)&&n--);return!A[0]&&D!=1&&(A.shift(),S.e--,O--),D>O&&eo(S,O,r.RM,y[0]!==cs),S};Ve.eq=function(t){return this.cmp(t)===0};Ve.gt=function(t){return this.cmp(t)>0};Ve.gte=function(t){return this.cmp(t)>-1};Ve.lt=function(t){return this.cmp(t)<0};Ve.lte=function(t){return this.cmp(t)<1};Ve.minus=Ve.sub=function(t){var e,r,i,s,n=this,o=n.constructor,a=n.s,u=(t=new o(t)).s;if(a!=u)return t.s=-u,n.plus(t);var c=n.c.slice(),l=n.e,h=t.c,f=t.e;if(!c[0]||!h[0])return h[0]?t.s=-u:c[0]?t=new o(n):t.s=1,t;if(a=l-f){for((s=a<0)?(a=-a,i=c):(f=l,i=h),i.reverse(),u=a;u--;)i.push(0);i.reverse()}else for(r=((s=c.length<h.length)?c:h).length,a=u=0;u<r;u++)if(c[u]!=h[u]){s=c[u]<h[u];break}if(s&&(i=c,c=h,h=i,t.s=-t.s),(u=(r=h.length)-(e=c.length))>0)for(;u--;)c[e++]=0;for(u=e;r>a;){if(c[--r]<h[r]){for(e=r;e&&!c[--e];)c[e]=9;--c[e],c[r]+=10}c[r]-=h[r]}for(;c[--u]===0;)c.pop();for(;c[0]===0;)c.shift(),--f;return c[0]||(t.s=1,c=[f=0]),t.c=c,t.e=f,t};Ve.mod=function(t){var e,r=this,i=r.constructor,s=r.s,n=(t=new i(t)).s;if(!t.c[0])throw Error(F3);return r.s=t.s=1,e=t.cmp(r)==1,r.s=s,t.s=n,e?new i(r):(s=i.DP,n=i.RM,i.DP=i.RM=0,r=r.div(t),i.DP=s,i.RM=n,this.minus(r.times(t)))};Ve.neg=function(){var t=new this.constructor(this);return t.s=-t.s,t};Ve.plus=Ve.add=function(t){var e,r,i,s=this,n=s.constructor;if(t=new n(t),s.s!=t.s)return t.s=-t.s,s.minus(t);var o=s.e,a=s.c,u=t.e,c=t.c;if(!a[0]||!c[0])return c[0]||(a[0]?t=new n(s):t.s=s.s),t;if(a=a.slice(),e=o-u){for(e>0?(u=o,i=c):(e=-e,i=a),i.reverse();e--;)i.push(0);i.reverse()}for(a.length-c.length<0&&(i=c,c=a,a=i),e=c.length,r=0;e;a[e]%=10)r=(a[--e]=a[e]+c[e]+r)/10|0;for(r&&(a.unshift(r),++u),e=a.length;a[--e]===0;)a.pop();return t.c=a,t.e=u,t};Ve.pow=function(t){var e=this,r=new e.constructor("1"),i=r,s=t<0;if(t!==~~t||t<-By||t>By)throw Error(Zn+"exponent");for(s&&(t=-t);t&1&&(i=i.times(e)),t>>=1,!!t;)e=e.times(e);return s?r.div(i):i};Ve.prec=function(t,e){if(t!==~~t||t<1||t>jn)throw Error(Zn+"precision");return eo(new this.constructor(this),t,e)};Ve.round=function(t,e){if(t===cs)t=0;else if(t!==~~t||t<-jn||t>jn)throw Error(Fh);return eo(new this.constructor(this),t+this.e+1,e)};Ve.sqrt=function(){var t,e,r,i=this,s=i.constructor,n=i.s,o=i.e,a=new s("0.5");if(!i.c[0])return new s(i);if(n<0)throw Error(Tu+"No square root");n=Math.sqrt(+to(i,!0,!0)),n===0||n===1/0?(e=i.c.join(""),e.length+o&1||(e+="0"),n=Math.sqrt(e),o=((o+1)/2|0)-(o<0||o&1),t=new s((n==1/0?"5e":(n=n.toExponential()).slice(0,n.indexOf("e")+1))+o)):t=new s(n+""),o=t.e+(s.DP+=4);do r=t,t=a.times(r.plus(i.div(r)));while(r.c.slice(0,o).join("")!==t.c.slice(0,o).join(""));return eo(t,(s.DP-=4)+t.e+1,s.RM)};Ve.times=Ve.mul=function(t){var e,r=this,i=r.constructor,s=r.c,n=(t=new i(t)).c,o=s.length,a=n.length,u=r.e,c=t.e;if(t.s=r.s==t.s?1:-1,!s[0]||!n[0])return t.c=[t.e=0],t;for(t.e=u+c,o<a&&(e=s,s=n,n=e,c=o,o=a,a=c),e=new Array(c=o+a);c--;)e[c]=0;for(u=a;u--;){for(a=0,c=o+u;c>u;)a=e[c]+n[u]*s[c-u-1]+a,e[c--]=a%10,a=a/10|0;e[c]=a}for(a?++t.e:e.shift(),u=e.length;!e[--u];)e.pop();return t.c=e,t};Ve.toExponential=function(t,e){var r=this,i=r.c[0];if(t!==cs){if(t!==~~t||t<0||t>jn)throw Error(Fh);for(r=eo(new r.constructor(r),++t,e);r.c.length<t;)r.c.push(0)}return to(r,!0,!!i)};Ve.toFixed=function(t,e){var r=this,i=r.c[0];if(t!==cs){if(t!==~~t||t<0||t>jn)throw Error(Fh);for(r=eo(new r.constructor(r),t+r.e+1,e),t=t+r.e+1;r.c.length<t;)r.c.push(0)}return to(r,!1,!!i)};Ve[Symbol.for("nodejs.util.inspect.custom")]=Ve.toJSON=Ve.toString=function(){var t=this,e=t.constructor;return to(t,t.e<=e.NE||t.e>=e.PE,!!t.c[0])};Ve.toNumber=function(){var t=+to(this,!0,!0);if(this.constructor.strict===!0&&!this.eq(t.toString()))throw Error(Tu+"Imprecise conversion");return t};Ve.toPrecision=function(t,e){var r=this,i=r.constructor,s=r.c[0];if(t!==cs){if(t!==~~t||t<1||t>jn)throw Error(Zn+"precision");for(r=eo(new i(r),t,e);r.c.length<t;)r.c.push(0)}return to(r,t<=r.e||r.e<=i.NE||r.e>=i.PE,!!s)};Ve.valueOf=function(){var t=this,e=t.constructor;if(e.strict===!0)throw Error(Tu+"valueOf disallowed");return to(t,t.e<=e.NE||t.e>=e.PE,!0)};var ac=j3();const bl={bigNumber(t){return t?new ac(t):new ac(0)},multiply(t,e){if(t===void 0||e===void 0)return new ac(0);const r=new ac(t),i=new ac(e);return r.times(i)},formatNumberToLocalString(t,e=2){return t===void 0?"0.00":typeof t=="number"?t.toLocaleString("en-US",{maximumFractionDigits:e,minimumFractionDigits:e}):parseFloat(t).toLocaleString("en-US",{maximumFractionDigits:e,minimumFractionDigits:e})},parseLocalStringToNumber(t){return t===void 0?0:parseFloat(t.replace(/,/gu,""))}},UF=[{type:"function",name:"transfer",stateMutability:"nonpayable",inputs:[{name:"_to",type:"address"},{name:"_value",type:"uint256"}],outputs:[{name:"",type:"bool"}]},{type:"function",name:"transferFrom",stateMutability:"nonpayable",inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_value",type:"uint256"}],outputs:[{name:"",type:"bool"}]}],LF=[{type:"function",name:"approve",stateMutability:"nonpayable",inputs:[{name:"spender",type:"address"},{name:"amount",type:"uint256"}],outputs:[{type:"bool"}]}],FF=[{type:"function",name:"transfer",stateMutability:"nonpayable",inputs:[{name:"recipient",type:"address"},{name:"amount",type:"uint256"}],outputs:[]},{type:"function",name:"transferFrom",stateMutability:"nonpayable",inputs:[{name:"sender",type:"address"},{name:"recipient",type:"address"},{name:"amount",type:"uint256"}],outputs:[{name:"",type:"bool"}]}],ne={WC_NAME_SUFFIX:".reown.id",WC_NAME_SUFFIX_LEGACY:".wcn.id",BLOCKCHAIN_API_RPC_URL:"https://rpc.walletconnect.org",PULSE_API_URL:"https://pulse.walletconnect.org",W3M_API_URL:"https://api.web3modal.org",CONNECTOR_ID:{WALLET_CONNECT:"walletConnect",INJECTED:"injected",WALLET_STANDARD:"announced",COINBASE:"coinbaseWallet",COINBASE_SDK:"coinbaseWalletSDK",SAFE:"safe",LEDGER:"ledger",OKX:"okx",EIP6963:"eip6963",AUTH:"ID_AUTH"},CONNECTOR_NAMES:{AUTH:"Auth"},AUTH_CONNECTOR_SUPPORTED_CHAINS:["eip155","solana"],LIMITS:{PENDING_TRANSACTIONS:99},CHAIN:{EVM:"eip155",SOLANA:"solana",POLKADOT:"polkadot",BITCOIN:"bip122"},CHAIN_NAME_MAP:{eip155:"EVM Networks",solana:"Solana",polkadot:"Polkadot",bip122:"Bitcoin"},ADAPTER_TYPES:{BITCOIN:"bitcoin",SOLANA:"solana",WAGMI:"wagmi",ETHERS:"ethers",ETHERS5:"ethers5"},USDT_CONTRACT_ADDRESSES:["0xdac17f958d2ee523a2206206994597c13d831ec7","0xc2132d05d31c914a87c6611c10748aeb04b58e8f","0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7","0x919C1c267BC06a7039e03fcc2eF738525769109c","0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e","0x55d398326f99059fF775485246999027B3197955","0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9"],HTTP_STATUS_CODES:{SERVICE_UNAVAILABLE:503,FORBIDDEN:403},UNSUPPORTED_NETWORK_NAME:"Unknown Network"},jF={getERC20Abi:t=>ne.USDT_CONTRACT_ADDRESSES.includes(t)?FF:UF,getSwapAbi:()=>LF},Bs={validateCaipAddress(t){if(t.split(":")?.length!==3)throw new Error("Invalid CAIP Address");return t},parseCaipAddress(t){const e=t.split(":");if(e.length!==3)throw new Error(`Invalid CAIP-10 address: ${t}`);const[r,i,s]=e;if(!r||!i||!s)throw new Error(`Invalid CAIP-10 address: ${t}`);return{chainNamespace:r,chainId:i,address:s}},parseCaipNetworkId(t){const e=t.split(":");if(e.length!==2)throw new Error(`Invalid CAIP-2 network id: ${t}`);const[r,i]=e;if(!r||!i)throw new Error(`Invalid CAIP-2 network id: ${t}`);return{chainNamespace:r,chainId:i}}},me={WALLET_ID:"@appkit/wallet_id",WALLET_NAME:"@appkit/wallet_name",SOLANA_WALLET:"@appkit/solana_wallet",SOLANA_CAIP_CHAIN:"@appkit/solana_caip_chain",ACTIVE_CAIP_NETWORK_ID:"@appkit/active_caip_network_id",CONNECTED_SOCIAL:"@appkit/connected_social",CONNECTED_SOCIAL_USERNAME:"@appkit-wallet/SOCIAL_USERNAME",RECENT_WALLETS:"@appkit/recent_wallets",DEEPLINK_CHOICE:"WALLETCONNECT_DEEPLINK_CHOICE",ACTIVE_NAMESPACE:"@appkit/active_namespace",CONNECTED_NAMESPACES:"@appkit/connected_namespaces",CONNECTION_STATUS:"@appkit/connection_status",SIWX_AUTH_TOKEN:"@appkit/siwx-auth-token",SIWX_NONCE_TOKEN:"@appkit/siwx-nonce-token",TELEGRAM_SOCIAL_PROVIDER:"@appkit/social_provider",NATIVE_BALANCE_CACHE:"@appkit/native_balance_cache",PORTFOLIO_CACHE:"@appkit/portfolio_cache",ENS_CACHE:"@appkit/ens_cache",IDENTITY_CACHE:"@appkit/identity_cache"};function lf(t){if(!t)throw new Error("Namespace is required for CONNECTED_CONNECTOR_ID");return`@appkit/${t}:connected_connector_id`}const he={setItem(t,e){Ec()&&e!==void 0&&localStorage.setItem(t,e)},getItem(t){if(Ec())return localStorage.getItem(t)||void 0},removeItem(t){Ec()&&localStorage.removeItem(t)},clear(){Ec()&&localStorage.clear()}};function Ec(){return typeof window<"u"&&typeof localStorage<"u"}function en(t,e){return e==="light"?{"--w3m-accent":t?.["--w3m-accent"]||"hsla(231, 100%, 70%, 1)","--w3m-background":"#fff"}:{"--w3m-accent":t?.["--w3m-accent"]||"hsla(230, 100%, 67%, 1)","--w3m-background":"#121313"}}const qF=Symbol(),zy=Object.getPrototypeOf,Ap=new WeakMap,BF=t=>t&&(Ap.has(t)?Ap.get(t):zy(t)===Object.prototype||zy(t)===Array.prototype),zF=t=>BF(t)&&t[qF]||null,Hy=(t,e=!0)=>{Ap.set(t,e)},uh={},hf=t=>typeof t=="object"&&t!==null,Gs=new WeakMap,Ic=new WeakSet,HF=(t=Object.is,e=(c,l)=>new Proxy(c,l),r=c=>hf(c)&&!Ic.has(c)&&(Array.isArray(c)||!(Symbol.iterator in c))&&!(c instanceof WeakMap)&&!(c instanceof WeakSet)&&!(c instanceof Error)&&!(c instanceof Number)&&!(c instanceof Date)&&!(c instanceof String)&&!(c instanceof RegExp)&&!(c instanceof ArrayBuffer),i=c=>{switch(c.status){case"fulfilled":return c.value;case"rejected":throw c.reason;default:throw c}},s=new WeakMap,n=(c,l,h=i)=>{const f=s.get(c);if(f?.[0]===l)return f[1];const m=Array.isArray(c)?[]:Object.create(Object.getPrototypeOf(c));return Hy(m,!0),s.set(c,[l,m]),Reflect.ownKeys(c).forEach(g=>{if(Object.getOwnPropertyDescriptor(m,g))return;const y=Reflect.get(c,g),{enumerable:C}=Reflect.getOwnPropertyDescriptor(c,g),S={value:y,enumerable:C,configurable:!0};if(Ic.has(y))Hy(y,!1);else if(y instanceof Promise)delete S.value,S.get=()=>h(y);else if(Gs.has(y)){const[A,D]=Gs.get(y);S.value=n(A,D(),h)}Object.defineProperty(m,g,S)}),Object.preventExtensions(m)},o=new WeakMap,a=[1,1],u=c=>{if(!hf(c))throw new Error("object required");const l=o.get(c);if(l)return l;let h=a[0];const f=new Set,m=(R,L=++a[0])=>{h!==L&&(h=L,f.forEach($=>$(R,L)))};let g=a[1];const y=(R=++a[1])=>(g!==R&&!f.size&&(g=R,S.forEach(([L])=>{const $=L[1](R);$>h&&(h=$)})),h),C=R=>(L,$)=>{const d=[...L];d[1]=[R,...d[1]],m(d,$)},S=new Map,A=(R,L)=>{if((uh?"production":void 0)!=="production"&&S.has(R))throw new Error("prop listener already exists");if(f.size){const $=L[3](C(R));S.set(R,[L,$])}else S.set(R,[L])},D=R=>{var L;const $=S.get(R);$&&(S.delete(R),(L=$[1])==null||L.call($))},O=R=>(f.add(R),f.size===1&&S.forEach(([$,d],b)=>{if((uh?"production":void 0)!=="production"&&d)throw new Error("remove already exists");const _=$[3](C(b));S.set(b,[$,_])}),()=>{f.delete(R),f.size===0&&S.forEach(([$,d],b)=>{d&&(d(),S.set(b,[$]))})}),T=Array.isArray(c)?[]:Object.create(Object.getPrototypeOf(c)),M=e(T,{deleteProperty(R,L){const $=Reflect.get(R,L);D(L);const d=Reflect.deleteProperty(R,L);return d&&m(["delete",[L],$]),d},set(R,L,$,d){const b=Reflect.has(R,L),_=Reflect.get(R,L,d);if(b&&(t(_,$)||o.has($)&&t(_,o.get($))))return!0;D(L),hf($)&&($=zF($)||$);let w=$;if($ instanceof Promise)$.then(v=>{$.status="fulfilled",$.value=v,m(["resolve",[L],v])}).catch(v=>{$.status="rejected",$.reason=v,m(["reject",[L],v])});else{!Gs.has($)&&r($)&&(w=u($));const v=!Ic.has(w)&&Gs.get(w);v&&A(L,v)}return Reflect.set(R,L,w,d),m(["set",[L],$,_]),!0}});o.set(c,M);const U=[T,y,n,O];return Gs.set(M,U),Reflect.ownKeys(c).forEach(R=>{const L=Object.getOwnPropertyDescriptor(c,R);"value"in L&&(M[R]=c[R],delete L.value,delete L.writable),Object.defineProperty(T,R,L)}),M})=>[u,Gs,Ic,t,e,r,i,s,n,o,a],[VF]=HF();function Tt(t={}){return VF(t)}function Fr(t,e,r){const i=Gs.get(t);(uh?"production":void 0)!=="production"&&!i&&console.warn("Please use proxy object");let s;const n=[],o=i[3];let a=!1;const c=o(l=>{n.push(l),s||(s=Promise.resolve().then(()=>{s=void 0,a&&e(n.splice(0))}))});return a=!0,()=>{a=!1,c()}}function Vc(t,e){const r=Gs.get(t);(uh?"production":void 0)!=="production"&&!r&&console.warn("Please use proxy object");const[i,s,n]=r;return n(i,s(),e)}function qn(t){return Ic.add(t),t}function gi(t,e,r,i){let s=t[e];return Fr(t,()=>{const n=t[e];Object.is(s,n)||r(s=n)})}function KF(t){const e=Tt({data:Array.from([]),has(r){return this.data.some(i=>i[0]===r)},set(r,i){const s=this.data.find(n=>n[0]===r);return s?s[1]=i:this.data.push([r,i]),this},get(r){var i;return(i=this.data.find(s=>s[0]===r))==null?void 0:i[1]},delete(r){const i=this.data.findIndex(s=>s[0]===r);return i===-1?!1:(this.data.splice(i,1),!0)},clear(){this.data.splice(0)},get size(){return this.data.length},toJSON(){return new Map(this.data)},forEach(r){this.data.forEach(i=>{r(i[1],i[0],this)})},keys(){return this.data.map(r=>r[0]).values()},values(){return this.data.map(r=>r[1]).values()},entries(){return new Map(this.data).entries()},get[Symbol.toStringTag](){return"Map"},[Symbol.iterator](){return this.entries()}});return Object.defineProperties(e,{data:{enumerable:!1},size:{enumerable:!1},toJSON:{enumerable:!1}}),Object.seal(e),e}var Vy={};const df=(typeof process<"u"&&typeof Vy<"u"?Vy.NEXT_PUBLIC_SECURE_SITE_ORIGIN:void 0)||"https://secure.walletconnect.org",Jr={FOUR_MINUTES_MS:24e4,TEN_SEC_MS:1e4,FIVE_SEC_MS:5e3,THREE_SEC_MS:3e3,ONE_SEC_MS:1e3,SECURE_SITE:df,SECURE_SITE_DASHBOARD:`${df}/dashboard`,SECURE_SITE_FAVICON:`${df}/images/favicon.png`,RESTRICTED_TIMEZONES:["ASIA/SHANGHAI","ASIA/URUMQI","ASIA/CHONGQING","ASIA/HARBIN","ASIA/KASHGAR","ASIA/MACAU","ASIA/HONG_KONG","ASIA/MACAO","ASIA/BEIJING","ASIA/HARBIN"],WC_COINBASE_PAY_SDK_CHAINS:["ethereum","arbitrum","polygon","berachain","avalanche-c-chain","optimism","celo","base"],WC_COINBASE_PAY_SDK_FALLBACK_CHAIN:"ethereum",WC_COINBASE_PAY_SDK_CHAIN_NAME_MAP:{Ethereum:"ethereum","Arbitrum One":"arbitrum",Polygon:"polygon",Berachain:"berachain",Avalanche:"avalanche-c-chain","OP Mainnet":"optimism",Celo:"celo",Base:"base"},WC_COINBASE_ONRAMP_APP_ID:"bf18c88d-495a-463b-b249-0b9d3656cf5e",SWAP_SUGGESTED_TOKENS:["ETH","UNI","1INCH","AAVE","SOL","ADA","AVAX","DOT","LINK","NITRO","GAIA","MILK","TRX","NEAR","GNO","WBTC","DAI","WETH","USDC","USDT","ARB","BAL","BICO","CRV","ENS","MATIC","OP"],SWAP_POPULAR_TOKENS:["ETH","UNI","1INCH","AAVE","SOL","ADA","AVAX","DOT","LINK","NITRO","GAIA","MILK","TRX","NEAR","GNO","WBTC","DAI","WETH","USDC","USDT","ARB","BAL","BICO","CRV","ENS","MATIC","OP","METAL","DAI","CHAMP","WOLF","SALE","BAL","BUSD","MUST","BTCpx","ROUTE","HEX","WELT","amDAI","VSQ","VISION","AURUM","pSP","SNX","VC","LINK","CHP","amUSDT","SPHERE","FOX","GIDDY","GFC","OMEN","OX_OLD","DE","WNT"],BALANCE_SUPPORTED_CHAINS:["eip155","solana"],SWAP_SUPPORTED_NETWORKS:["eip155:1","eip155:42161","eip155:10","eip155:324","eip155:8453","eip155:56","eip155:137","eip155:100","eip155:43114","eip155:250","eip155:8217","eip155:1313161554"],NAMES_SUPPORTED_CHAIN_NAMESPACES:["eip155"],ONRAMP_SUPPORTED_CHAIN_NAMESPACES:["eip155","solana"],ACTIVITY_ENABLED_CHAIN_NAMESPACES:["eip155","solana"],NATIVE_TOKEN_ADDRESS:{eip155:"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",solana:"So11111111111111111111111111111111111111111",polkadot:"0x",bip122:"0x"},CONVERT_SLIPPAGE_TOLERANCE:1,CONNECT_LABELS:{MOBILE:"Open and continue in a new browser tab"},DEFAULT_FEATURES:{swaps:!0,onramp:!0,receive:!0,send:!0,email:!0,emailShowWallets:!0,socials:["google","x","discord","farcaster","github","apple","facebook"],connectorTypeOrder:["walletConnect","recent","injected","featured","custom","external","recommended"],history:!0,analytics:!0,allWallets:!0,legalCheckbox:!1,smartSessions:!1,collapseWallets:!1,walletFeaturesOrder:["onramp","swaps","receive","send"],connectMethodsOrder:void 0},DEFAULT_ACCOUNT_TYPES:{bip122:"payment",eip155:"smartAccount",polkadot:"eoa",solana:"eoa"},ADAPTER_TYPES:{UNIVERSAL:"universal",SOLANA:"solana",WAGMI:"wagmi",ETHERS:"ethers",ETHERS5:"ethers5",BITCOIN:"bitcoin"}},se={cacheExpiry:{portfolio:3e4,nativeBalance:3e4,ens:3e5,identity:3e5},isCacheExpired(t,e){return Date.now()-t>e},getActiveNetworkProps(){const t=se.getActiveNamespace(),e=se.getActiveCaipNetworkId(),r=e?e.split(":")[1]:void 0,i=r?isNaN(Number(r))?r:Number(r):void 0;return{namespace:t,caipNetworkId:e,chainId:i}},setWalletConnectDeepLink({name:t,href:e}){try{he.setItem(me.DEEPLINK_CHOICE,JSON.stringify({href:e,name:t}))}catch{console.info("Unable to set WalletConnect deep link")}},getWalletConnectDeepLink(){try{const t=he.getItem(me.DEEPLINK_CHOICE);if(t)return JSON.parse(t)}catch{console.info("Unable to get WalletConnect deep link")}},deleteWalletConnectDeepLink(){try{he.removeItem(me.DEEPLINK_CHOICE)}catch{console.info("Unable to delete WalletConnect deep link")}},setActiveNamespace(t){try{he.setItem(me.ACTIVE_NAMESPACE,t)}catch{console.info("Unable to set active namespace")}},setActiveCaipNetworkId(t){try{he.setItem(me.ACTIVE_CAIP_NETWORK_ID,t),se.setActiveNamespace(t.split(":")[0])}catch{console.info("Unable to set active caip network id")}},getActiveCaipNetworkId(){try{return he.getItem(me.ACTIVE_CAIP_NETWORK_ID)}catch{console.info("Unable to get active caip network id");return}},deleteActiveCaipNetworkId(){try{he.removeItem(me.ACTIVE_CAIP_NETWORK_ID)}catch{console.info("Unable to delete active caip network id")}},deleteConnectedConnectorId(t){try{const e=lf(t);he.removeItem(e)}catch{console.info("Unable to delete connected connector id")}},setAppKitRecent(t){try{const e=se.getRecentWallets();e.find(i=>i.id===t.id)||(e.unshift(t),e.length>2&&e.pop(),he.setItem(me.RECENT_WALLETS,JSON.stringify(e)))}catch{console.info("Unable to set AppKit recent")}},getRecentWallets(){try{const t=he.getItem(me.RECENT_WALLETS);return t?JSON.parse(t):[]}catch{console.info("Unable to get AppKit recent")}return[]},setConnectedConnectorId(t,e){try{const r=lf(t);he.setItem(r,e)}catch{console.info("Unable to set Connected Connector Id")}},getActiveNamespace(){try{return he.getItem(me.ACTIVE_NAMESPACE)}catch{console.info("Unable to get active namespace")}},getConnectedConnectorId(t){if(t)try{const e=lf(t);return he.getItem(e)}catch{console.info("Unable to get connected connector id in namespace ",t)}},setConnectedSocialProvider(t){try{he.setItem(me.CONNECTED_SOCIAL,t)}catch{console.info("Unable to set connected social provider")}},getConnectedSocialProvider(){try{return he.getItem(me.CONNECTED_SOCIAL)}catch{console.info("Unable to get connected social provider")}},deleteConnectedSocialProvider(){try{he.removeItem(me.CONNECTED_SOCIAL)}catch{console.info("Unable to delete connected social provider")}},getConnectedSocialUsername(){try{return he.getItem(me.CONNECTED_SOCIAL_USERNAME)}catch{console.info("Unable to get connected social username")}},getStoredActiveCaipNetworkId(){return he.getItem(me.ACTIVE_CAIP_NETWORK_ID)?.split(":")?.[1]},setConnectionStatus(t){try{he.setItem(me.CONNECTION_STATUS,t)}catch{console.info("Unable to set connection status")}},getConnectionStatus(){try{return he.getItem(me.CONNECTION_STATUS)}catch{return}},getConnectedNamespaces(){try{const t=he.getItem(me.CONNECTED_NAMESPACES);return t?.length?t.split(","):[]}catch{return[]}},setConnectedNamespaces(t){try{const e=Array.from(new Set(t));he.setItem(me.CONNECTED_NAMESPACES,e.join(","))}catch{console.info("Unable to set namespaces in storage")}},addConnectedNamespace(t){try{const e=se.getConnectedNamespaces();e.includes(t)||(e.push(t),se.setConnectedNamespaces(e))}catch{console.info("Unable to add connected namespace")}},removeConnectedNamespace(t){try{const e=se.getConnectedNamespaces(),r=e.indexOf(t);r>-1&&(e.splice(r,1),se.setConnectedNamespaces(e))}catch{console.info("Unable to remove connected namespace")}},getTelegramSocialProvider(){try{return he.getItem(me.TELEGRAM_SOCIAL_PROVIDER)}catch{return console.info("Unable to get telegram social provider"),null}},setTelegramSocialProvider(t){try{he.setItem(me.TELEGRAM_SOCIAL_PROVIDER,t)}catch{console.info("Unable to set telegram social provider")}},removeTelegramSocialProvider(){try{he.removeItem(me.TELEGRAM_SOCIAL_PROVIDER)}catch{console.info("Unable to remove telegram social provider")}},getBalanceCache(){let t={};try{const e=he.getItem(me.PORTFOLIO_CACHE);t=e?JSON.parse(e):{}}catch{console.info("Unable to get balance cache")}return t},removeAddressFromBalanceCache(t){try{const e=se.getBalanceCache();he.setItem(me.PORTFOLIO_CACHE,JSON.stringify({...e,[t]:void 0}))}catch{console.info("Unable to remove address from balance cache",t)}},getBalanceCacheForCaipAddress(t){try{const r=se.getBalanceCache()[t];if(r&&!this.isCacheExpired(r.timestamp,this.cacheExpiry.portfolio))return r.balance;se.removeAddressFromBalanceCache(t)}catch{console.info("Unable to get balance cache for address",t)}},updateBalanceCache(t){try{const e=se.getBalanceCache();e[t.caipAddress]=t,he.setItem(me.PORTFOLIO_CACHE,JSON.stringify(e))}catch{console.info("Unable to update balance cache",t)}},getNativeBalanceCache(){let t={};try{const e=he.getItem(me.NATIVE_BALANCE_CACHE);t=e?JSON.parse(e):{}}catch{console.info("Unable to get balance cache")}return t},removeAddressFromNativeBalanceCache(t){try{const e=se.getBalanceCache();he.setItem(me.NATIVE_BALANCE_CACHE,JSON.stringify({...e,[t]:void 0}))}catch{console.info("Unable to remove address from balance cache",t)}},getNativeBalanceCacheForCaipAddress(t){try{const r=se.getNativeBalanceCache()[t];if(r&&!this.isCacheExpired(r.timestamp,this.cacheExpiry.nativeBalance))return r;console.info("Discarding cache for address",t),se.removeAddressFromBalanceCache(t)}catch{console.info("Unable to get balance cache for address",t)}},updateNativeBalanceCache(t){try{const e=se.getNativeBalanceCache();e[t.caipAddress]=t,he.setItem(me.NATIVE_BALANCE_CACHE,JSON.stringify(e))}catch{console.info("Unable to update balance cache",t)}},getEnsCache(){let t={};try{const e=he.getItem(me.ENS_CACHE);t=e?JSON.parse(e):{}}catch{console.info("Unable to get ens name cache")}return t},getEnsFromCacheForAddress(t){try{const r=se.getEnsCache()[t];if(r&&!this.isCacheExpired(r.timestamp,this.cacheExpiry.ens))return r.ens;se.removeEnsFromCache(t)}catch{console.info("Unable to get ens name from cache",t)}},updateEnsCache(t){try{const e=se.getEnsCache();e[t.address]=t,he.setItem(me.ENS_CACHE,JSON.stringify(e))}catch{console.info("Unable to update ens name cache",t)}},removeEnsFromCache(t){try{const e=se.getEnsCache();he.setItem(me.ENS_CACHE,JSON.stringify({...e,[t]:void 0}))}catch{console.info("Unable to remove ens name from cache",t)}},getIdentityCache(){let t={};try{const e=he.getItem(me.IDENTITY_CACHE);t=e?JSON.parse(e):{}}catch{console.info("Unable to get identity cache")}return t},getIdentityFromCacheForAddress(t){try{const r=se.getIdentityCache()[t];if(r&&!this.isCacheExpired(r.timestamp,this.cacheExpiry.identity))return r.identity;se.removeIdentityFromCache(t)}catch{console.info("Unable to get identity from cache",t)}},updateIdentityCache(t){try{const e=se.getIdentityCache();e[t.address]={identity:t.identity,timestamp:t.timestamp},he.setItem(me.IDENTITY_CACHE,JSON.stringify(e))}catch{console.info("Unable to update identity cache",t)}},removeIdentityFromCache(t){try{const e=se.getIdentityCache();he.setItem(me.IDENTITY_CACHE,JSON.stringify({...e,[t]:void 0}))}catch{console.info("Unable to remove identity from cache",t)}},clearAddressCache(){try{he.removeItem(me.PORTFOLIO_CACHE),he.removeItem(me.NATIVE_BALANCE_CACHE),he.removeItem(me.ENS_CACHE),he.removeItem(me.IDENTITY_CACHE)}catch{console.info("Unable to clear address cache")}}},pe={isMobile(){return this.isClient()?!!(window?.matchMedia("(pointer:coarse)")?.matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1},checkCaipNetwork(t,e=""){return t?.caipNetworkId.toLocaleLowerCase().includes(e.toLowerCase())},isAndroid(){if(!this.isMobile())return!1;const t=window?.navigator.userAgent.toLowerCase();return pe.isMobile()&&t.includes("android")},isIos(){if(!this.isMobile())return!1;const t=window?.navigator.userAgent.toLowerCase();return t.includes("iphone")||t.includes("ipad")},isSafari(){return this.isClient()?(window?.navigator.userAgent.toLowerCase()).includes("safari"):!1},isClient(){return typeof window<"u"},isPairingExpired(t){return t?t-Date.now()<=Jr.TEN_SEC_MS:!0},isAllowedRetry(t,e=Jr.ONE_SEC_MS){return Date.now()-t>=e},copyToClopboard(t){navigator.clipboard.writeText(t)},isIframe(){try{return window?.self!==window?.top}catch{return!1}},getPairingExpiry(){return Date.now()+Jr.FOUR_MINUTES_MS},getNetworkId(t){return t?.split(":")[1]},getPlainAddress(t){return t?.split(":")[2]},async wait(t){return new Promise(e=>{setTimeout(e,t)})},debounce(t,e=500){let r;return(...i)=>{function s(){t(...i)}r&&clearTimeout(r),r=setTimeout(s,e)}},isHttpUrl(t){return t.startsWith("http://")||t.startsWith("https://")},formatNativeUrl(t,e){if(pe.isHttpUrl(t))return this.formatUniversalUrl(t,e);let r=t;r.includes("://")||(r=t.replaceAll("/","").replaceAll(":",""),r=`${r}://`),r.endsWith("/")||(r=`${r}/`),this.isTelegram()&&this.isAndroid()&&(e=encodeURIComponent(e));const i=encodeURIComponent(e);return{redirect:`${r}wc?uri=${i}`,href:r}},formatUniversalUrl(t,e){if(!pe.isHttpUrl(t))return this.formatNativeUrl(t,e);let r=t;r.endsWith("/")||(r=`${r}/`);const i=encodeURIComponent(e);return{redirect:`${r}wc?uri=${i}`,href:r}},getOpenTargetForPlatform(t){return t==="popupWindow"?t:this.isTelegram()?se.getTelegramSocialProvider()?"_top":"_blank":t},openHref(t,e,r){window?.open(t,this.getOpenTargetForPlatform(e),r||"noreferrer noopener")},returnOpenHref(t,e,r){return window?.open(t,this.getOpenTargetForPlatform(e),r||"noreferrer noopener")},isTelegram(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)},async preloadImage(t){const e=new Promise((r,i)=>{const s=new Image;s.onload=r,s.onerror=i,s.crossOrigin="anonymous",s.src=t});return Promise.race([e,pe.wait(2e3)])},formatBalance(t,e){let r="0.000";if(typeof t=="string"){const i=Number(t);if(i){const s=Math.floor(i*1e3)/1e3;s&&(r=s.toString())}}return`${r}${e?` ${e}`:""}`},formatBalance2(t,e){let r;if(t==="0")r="0";else if(typeof t=="string"){const i=Number(t);i&&(r=i.toString().match(/^-?\d+(?:\.\d{0,3})?/u)?.[0])}return{value:r??"0",rest:r==="0"?"000":"",symbol:e}},getApiUrl(){return ne.W3M_API_URL},getBlockchainApiUrl(){return ne.BLOCKCHAIN_API_RPC_URL},getAnalyticsUrl(){return ne.PULSE_API_URL},getUUID(){return 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)})},parseError(t){return typeof t=="string"?t:typeof t?.issues?.[0]?.message=="string"?t.issues[0].message:t instanceof Error?t.message:"Unknown error"},sortRequestedNetworks(t,e=[]){const r={};return e&&t&&(t.forEach((i,s)=>{r[i]=s}),e.sort((i,s)=>{const n=r[i.id],o=r[s.id];return n!==void 0&&o!==void 0?n-o:n!==void 0?-1:o!==void 0?1:0})),e},calculateBalance(t){let e=0;for(const r of t)e+=r.value??0;return e},formatTokenBalance(t){const e=t.toFixed(2),[r,i]=e.split(".");return{dollars:r,pennies:i}},isAddress(t,e="eip155"){switch(e){case"eip155":if(/^(?:0x)?[0-9a-f]{40}$/iu.test(t)){if(/^(?:0x)?[0-9a-f]{40}$/iu.test(t)||/^(?:0x)?[0-9A-F]{40}$/iu.test(t))return!0}else return!1;return!1;case"solana":return/[1-9A-HJ-NP-Za-km-z]{32,44}$/iu.test(t);default:return!1}},uniqueBy(t,e){const r=new Set;return t.filter(i=>{const s=i[e];return r.has(s)?!1:(r.add(s),!0)})},generateSdkVersion(t,e,r){const s=t.length===0?Jr.ADAPTER_TYPES.UNIVERSAL:t.map(n=>n.adapterType).join(",");return`${e}-${s}-${r}`},createAccount(t,e,r,i,s){return{namespace:t,address:e,type:r,publicKey:i,path:s}},isCaipAddress(t){if(typeof t!="string")return!1;const e=t.split(":"),r=e[0];return e.filter(Boolean).length===3&&r in ne.CHAIN_NAME_MAP},isMac(){const t=window?.navigator.userAgent.toLowerCase();return t.includes("macintosh")&&!t.includes("safari")},formatTelegramSocialLoginUrl(t){const e=`--${encodeURIComponent(window?.location.href)}`,r="state=";if(new URL(t).host==="auth.magic.link"){const s="provider_authorization_url=",n=t.substring(t.indexOf(s)+s.length),o=this.injectIntoUrl(decodeURIComponent(n),r,e);return t.replace(n,encodeURIComponent(o))}return this.injectIntoUrl(t,r,e)},injectIntoUrl(t,e,r){const i=t.indexOf(e);if(i===-1)throw new Error(`${e} parameter not found in the URL: ${t}`);const s=t.indexOf("&",i),n=e.length,o=s!==-1?s:t.length,a=t.substring(0,i+n),u=t.substring(i+n,o),c=t.substring(s),l=u+r;return a+l+c}};async function cc(...t){const e=await fetch(...t);if(!e.ok)throw new Error(`HTTP status code: ${e.status}`,{cause:e});return e}class jh{constructor({baseUrl:e,clientId:r}){this.baseUrl=e,this.clientId=r}async get({headers:e,signal:r,cache:i,...s}){const n=this.createUrl(s);return(await cc(n,{method:"GET",headers:e,signal:r,cache:i})).json()}async getBlob({headers:e,signal:r,...i}){const s=this.createUrl(i);return(await cc(s,{method:"GET",headers:e,signal:r})).blob()}async post({body:e,headers:r,signal:i,...s}){const n=this.createUrl(s);return(await cc(n,{method:"POST",headers:r,body:e?JSON.stringify(e):void 0,signal:i})).json()}async put({body:e,headers:r,signal:i,...s}){const n=this.createUrl(s);return(await cc(n,{method:"PUT",headers:r,body:e?JSON.stringify(e):void 0,signal:i})).json()}async delete({body:e,headers:r,signal:i,...s}){const n=this.createUrl(s);return(await cc(n,{method:"DELETE",headers:r,body:e?JSON.stringify(e):void 0,signal:i})).json()}createUrl({path:e,params:r}){const i=new URL(e,this.baseUrl);return r&&Object.entries(r).forEach(([s,n])=>{n&&i.searchParams.append(s,n)}),this.clientId&&i.searchParams.append("clientId",this.clientId),i}}const WF={handleSolanaDeeplinkRedirect(t){if(F.state.activeChain===ne.CHAIN.SOLANA){const e=window.location.href,r=encodeURIComponent(e);if(t==="Phantom"&&!("phantom"in window)){const i=e.startsWith("https")?"https":"http",s=e.split("/")[2],n=encodeURIComponent(`${i}://${s}`);window.location.href=`https://phantom.app/ul/browse/${r}?ref=${n}`}t==="Coinbase Wallet"&&!("coinbaseSolana"in window)&&(window.location.href=`https://go.cb-w.com/dapp?cb_url=${r}`)}}},ri=Tt({walletImages:{},networkImages:{},chainImages:{},connectorImages:{},tokenImages:{},currencyImages:{}}),zi={state:ri,subscribeNetworkImages(t){return Fr(ri.networkImages,()=>t(ri.networkImages))},subscribeKey(t,e){return gi(ri,t,e)},subscribe(t){return Fr(ri,()=>t(ri))},setWalletImage(t,e){ri.walletImages[t]=e},setNetworkImage(t,e){ri.networkImages[t]=e},setChainImage(t,e){ri.chainImages[t]=e},setConnectorImage(t,e){ri.connectorImages={...ri.connectorImages,[t]:e}},setTokenImage(t,e){ri.tokenImages[t]=e},setCurrencyImage(t,e){ri.currencyImages[t]=e}},GF={eip155:"ba0ba0cd-17c6-4806-ad93-f9d174f17900",solana:"a1b58899-f671-4276-6a5e-56ca5bd59700",polkadot:"",bip122:"0b4838db-0161-4ffe-022d-532bf03dba00"},ff=Tt({networkImagePromises:{}}),q3={async fetchWalletImage(t){if(t)return await be._fetchWalletImage(t),this.getWalletImageById(t)},async fetchNetworkImage(t){if(!t)return;const e=this.getNetworkImageById(t);return e||(ff.networkImagePromises[t]||(ff.networkImagePromises[t]=be._fetchNetworkImage(t)),await ff.networkImagePromises[t],this.getNetworkImageById(t))},getWalletImageById(t){if(t)return zi.state.walletImages[t]},getWalletImage(t){if(t?.image_url)return t?.image_url;if(t?.image_id)return zi.state.walletImages[t.image_id]},getNetworkImage(t){if(t?.assets?.imageUrl)return t?.assets?.imageUrl;if(t?.assets?.imageId)return zi.state.networkImages[t.assets.imageId]},getNetworkImageById(t){if(t)return zi.state.networkImages[t]},getConnectorImage(t){if(t?.imageUrl)return t.imageUrl;if(t?.imageId)return zi.state.connectorImages[t.imageId]},getChainImage(t){return zi.state.networkImages[GF[t]]}},YF={getFeatureValue(t,e){const r=e?.[t];return r===void 0?Jr.DEFAULT_FEATURES[t]:r},filterSocialsByPlatform(t){if(!t||!t.length)return t;if(pe.isTelegram()){if(pe.isIos())return t.filter(e=>e!=="google");if(pe.isMac())return t.filter(e=>e!=="x");if(pe.isAndroid())return t.filter(e=>!["facebook","x"].includes(e))}return t}},ce=Tt({features:Jr.DEFAULT_FEATURES,projectId:"",sdkType:"appkit",sdkVersion:"html-wagmi-undefined",defaultAccountTypes:Jr.DEFAULT_ACCOUNT_TYPES,enableNetworkSwitch:!0}),J={state:ce,subscribeKey(t,e){return gi(ce,t,e)},setOptions(t){Object.assign(ce,t)},setFeatures(t){if(!t)return;ce.features||(ce.features=Jr.DEFAULT_FEATURES);const e={...ce.features,...t};ce.features=e,ce.features.socials&&(ce.features.socials=YF.filterSocialsByPlatform(ce.features.socials))},setProjectId(t){ce.projectId=t},setCustomRpcUrls(t){ce.customRpcUrls=t},setAllWallets(t){ce.allWallets=t},setIncludeWalletIds(t){ce.includeWalletIds=t},setExcludeWalletIds(t){ce.excludeWalletIds=t},setFeaturedWalletIds(t){ce.featuredWalletIds=t},setTokens(t){ce.tokens=t},setTermsConditionsUrl(t){ce.termsConditionsUrl=t},setPrivacyPolicyUrl(t){ce.privacyPolicyUrl=t},setCustomWallets(t){ce.customWallets=t},setIsSiweEnabled(t){ce.isSiweEnabled=t},setIsUniversalProvider(t){ce.isUniversalProvider=t},setSdkVersion(t){ce.sdkVersion=t},setMetadata(t){ce.metadata=t},setDisableAppend(t){ce.disableAppend=t},setEIP6963Enabled(t){ce.enableEIP6963=t},setDebug(t){ce.debug=t},setEnableWalletConnect(t){ce.enableWalletConnect=t},setEnableWalletGuide(t){ce.enableWalletGuide=t},setEnableAuthLogger(t){ce.enableAuthLogger=t},setEnableWallets(t){ce.enableWallets=t},setHasMultipleAddresses(t){ce.hasMultipleAddresses=t},setSIWX(t){ce.siwx=t},setConnectMethodsOrder(t){ce.features={...ce.features,connectMethodsOrder:t}},setWalletFeaturesOrder(t){ce.features={...ce.features,walletFeaturesOrder:t}},setSocialsOrder(t){ce.features={...ce.features,socials:t}},setCollapseWallets(t){ce.features={...ce.features,collapseWallets:t}},setEnableEmbedded(t){ce.enableEmbedded=t},setAllowUnsupportedChain(t){ce.allowUnsupportedChain=t},setManualWCControl(t){ce.manualWCControl=t},setEnableNetworkSwitch(t){ce.enableNetworkSwitch=t},setDefaultAccountTypes(t={}){Object.entries(t).forEach(([e,r])=>{r&&(ce.defaultAccountTypes[e]=r)})},setUniversalProviderConfigOverride(t){ce.universalProviderConfigOverride=t},getUniversalProviderConfigOverride(){return ce.universalProviderConfigOverride},getSnapshot(){return Vc(ce)}},zs=Tt({message:"",variant:"info",open:!1}),ql={state:zs,subscribeKey(t,e){return gi(zs,t,e)},open(t,e){const{debug:r}=J.state,{shortMessage:i,longMessage:s}=t;r&&(zs.message=i,zs.variant=e,zs.open=!0),s&&console.error(typeof s=="function"?s():s)},close(){zs.open=!1,zs.message="",zs.variant="info"}},JF=pe.getAnalyticsUrl(),QF=new jh({baseUrl:JF,clientId:null}),XF=["MODAL_CREATED"],_s=Tt({timestamp:Date.now(),reportedErrors:{},data:{type:"track",event:"MODAL_CREATED"}}),lt={state:_s,subscribe(t){return Fr(_s,()=>t(_s))},getSdkProperties(){const{projectId:t,sdkType:e,sdkVersion:r}=J.state;return{projectId:t,st:e,sv:r||"html-wagmi-4.2.2"}},async _sendAnalyticsEvent(t){try{const e=oe.state.address;if(XF.includes(t.data.event)||typeof window>"u")return;await QF.post({path:"/e",params:lt.getSdkProperties(),body:{eventId:pe.getUUID(),url:window.location.href,domain:window.location.hostname,timestamp:t.timestamp,props:{...t.data,address:e}}}),_s.reportedErrors.FORBIDDEN=!1}catch(e){e instanceof Error&&e.cause instanceof Response&&e.cause.status===ne.HTTP_STATUS_CODES.FORBIDDEN&&!_s.reportedErrors.FORBIDDEN&&(ql.open({shortMessage:"Invalid App Configuration",longMessage:`Origin ${Ec()?window.origin:"uknown"} not found on Allowlist - update configuration on cloud.reown.com`},"error"),_s.reportedErrors.FORBIDDEN=!0)}},sendEvent(t){_s.timestamp=Date.now(),_s.data=t,J.state.features?.analytics&<._sendAnalyticsEvent(_s)}},ZF=pe.getApiUrl(),Or=new jh({baseUrl:ZF,clientId:null}),ej="40",Ky="4",tj=20,Be=Tt({promises:{},page:1,count:0,featured:[],allFeatured:[],recommended:[],allRecommended:[],wallets:[],search:[],isAnalyticsEnabled:!1,excludedWallets:[],isFetchingRecommendedWallets:!1}),be={state:Be,subscribeKey(t,e){return gi(Be,t,e)},_getSdkProperties(){const{projectId:t,sdkType:e,sdkVersion:r}=J.state;return{projectId:t,st:e||"appkit",sv:r||"html-wagmi-4.2.2"}},_filterOutExtensions(t){return J.state.isUniversalProvider?t.filter(e=>!!(e.mobile_link||e.desktop_link||e.webapp_link)):t},async _fetchWalletImage(t){const e=`${Or.baseUrl}/getWalletImage/${t}`,r=await Or.getBlob({path:e,params:be._getSdkProperties()});zi.setWalletImage(t,URL.createObjectURL(r))},async _fetchNetworkImage(t){const e=`${Or.baseUrl}/public/getAssetImage/${t}`,r=await Or.getBlob({path:e,params:be._getSdkProperties()});zi.setNetworkImage(t,URL.createObjectURL(r))},async _fetchConnectorImage(t){const e=`${Or.baseUrl}/public/getAssetImage/${t}`,r=await Or.getBlob({path:e,params:be._getSdkProperties()});zi.setConnectorImage(t,URL.createObjectURL(r))},async _fetchCurrencyImage(t){const e=`${Or.baseUrl}/public/getCurrencyImage/${t}`,r=await Or.getBlob({path:e,params:be._getSdkProperties()});zi.setCurrencyImage(t,URL.createObjectURL(r))},async _fetchTokenImage(t){const e=`${Or.baseUrl}/public/getTokenImage/${t}`,r=await Or.getBlob({path:e,params:be._getSdkProperties()});zi.setTokenImage(t,URL.createObjectURL(r))},async fetchNetworkImages(){const e=F.getAllRequestedCaipNetworks()?.map(({assets:r})=>r?.imageId).filter(Boolean).filter(r=>!q3.getNetworkImageById(r));e&&await Promise.allSettled(e.map(r=>be._fetchNetworkImage(r)))},async fetchConnectorImages(){const{connectors:t}=fe.state,e=t.map(({imageId:r})=>r).filter(Boolean);await Promise.allSettled(e.map(r=>be._fetchConnectorImage(r)))},async fetchCurrencyImages(t=[]){await Promise.allSettled(t.map(e=>be._fetchCurrencyImage(e)))},async fetchTokenImages(t=[]){await Promise.allSettled(t.map(e=>be._fetchTokenImage(e)))},async fetchFeaturedWallets(){const{featuredWalletIds:t}=J.state;if(t?.length){const{data:e}=await Or.get({path:"/getWallets",params:{...be._getSdkProperties(),page:"1",entries:t?.length?String(t.length):Ky,include:t?.join(",")}});e.sort((i,s)=>t.indexOf(i.id)-t.indexOf(s.id));const r=e.map(i=>i.image_id).filter(Boolean);await Promise.allSettled(r.map(i=>be._fetchWalletImage(i))),Be.featured=e,Be.allFeatured=e}},async fetchRecommendedWallets(){try{Be.isFetchingRecommendedWallets=!0;const{includeWalletIds:t,excludeWalletIds:e,featuredWalletIds:r}=J.state,i=[...e??[],...r??[]].filter(Boolean),s=F.getRequestedCaipNetworkIds().join(","),{data:n,count:o}=await Or.get({path:"/getWallets",params:{...be._getSdkProperties(),page:"1",chains:s,entries:Ky,include:t?.join(","),exclude:i?.join(",")}}),a=se.getRecentWallets(),u=n.map(l=>l.image_id).filter(Boolean),c=a.map(l=>l.image_id).filter(Boolean);await Promise.allSettled([...u,...c].map(l=>be._fetchWalletImage(l))),Be.recommended=n,Be.allRecommended=n,Be.count=o??0}catch{}finally{Be.isFetchingRecommendedWallets=!1}},async fetchWallets({page:t}){const{includeWalletIds:e,excludeWalletIds:r,featuredWalletIds:i}=J.state,s=F.getRequestedCaipNetworkIds().join(","),n=[...Be.recommended.map(({id:c})=>c),...r??[],...i??[]].filter(Boolean),{data:o,count:a}=await Or.get({path:"/getWallets",params:{...be._getSdkProperties(),page:String(t),entries:ej,chains:s,include:e?.join(","),exclude:n.join(",")}}),u=o.slice(0,tj).map(c=>c.image_id).filter(Boolean);await Promise.allSettled(u.map(c=>be._fetchWalletImage(c))),Be.wallets=pe.uniqueBy([...Be.wallets,...be._filterOutExtensions(o)],"id"),Be.count=a>Be.count?a:Be.count,Be.page=t},async initializeExcludedWallets({ids:t}){const e=F.getRequestedCaipNetworkIds().join(","),{data:r}=await Or.get({path:"/getWallets",params:{...be._getSdkProperties(),page:"1",entries:String(t.length),chains:e,include:t?.join(",")}});r&&r.forEach(i=>{i?.rdns&&Be.excludedWallets.push({rdns:i.rdns,name:i.name})})},async searchWallet({search:t,badge:e}){const{includeWalletIds:r,excludeWalletIds:i}=J.state;Be.search=[];const s=F.getRequestedCaipNetworkIds().join(","),{data:n}=await Or.get({path:"/getWallets",params:{...be._getSdkProperties(),page:"1",entries:"100",search:t?.trim(),badge_type:e,chains:s,include:r?.join(","),exclude:i?.join(",")}});lt.sendEvent({type:"track",event:"SEARCH_WALLET",properties:{badge:e??"",search:t??""}});const o=n.map(a=>a.image_id).filter(Boolean);await Promise.allSettled([...o.map(a=>be._fetchWalletImage(a)),pe.wait(300)]),Be.search=be._filterOutExtensions(n)},initPromise(t,e){const r=Be.promises[t];return r||(Be.promises[t]=e())},prefetch({fetchConnectorImages:t=!0,fetchFeaturedWallets:e=!0,fetchRecommendedWallets:r=!0,fetchNetworkImages:i=!0}={}){const s=[t&&be.initPromise("connectorImages",be.fetchConnectorImages),e&&be.initPromise("featuredWallets",be.fetchFeaturedWallets),r&&be.initPromise("recommendedWallets",be.fetchRecommendedWallets),i&&be.initPromise("networkImages",be.fetchNetworkImages)].filter(Boolean);return Promise.allSettled(s)},prefetchAnalyticsConfig(){J.state.features?.analytics&&be.fetchAnalyticsConfig()},async fetchAnalyticsConfig(){try{const{isAnalyticsEnabled:t}=await Or.get({path:"/getAnalyticsConfig",params:be._getSdkProperties()});J.setFeatures({analytics:t})}catch{J.setFeatures({analytics:!1})}},setFilterByNamespace(t){if(!t){Be.featured=Be.allFeatured,Be.recommended=Be.allRecommended;return}const e=F.getRequestedCaipNetworkIds().join(",");Be.featured=Be.allFeatured.filter(r=>r.chains?.some(i=>e.includes(i))),Be.recommended=Be.allRecommended.filter(r=>r.chains?.some(i=>e.includes(i)))}},ke=Tt({view:"Connect",history:["Connect"],transactionStack:[]}),He={state:ke,subscribeKey(t,e){return gi(ke,t,e)},pushTransactionStack(t){ke.transactionStack.push(t)},popTransactionStack(t){const e=ke.transactionStack.pop();if(e)if(t)this.goBack(),e?.onCancel?.();else{if(e.goBack)this.goBack();else if(e.replace){const i=ke.history.indexOf("ConnectingSiwe");i>0?this.goBackToIndex(i-1):(Qt.close(),ke.history=[])}else e.view&&this.reset(e.view);e?.onSuccess?.()}},push(t,e){t!==ke.view&&(ke.view=t,ke.history.push(t),ke.data=e)},reset(t,e){ke.view=t,ke.history=[t],ke.data=e},replace(t,e){ke.history.at(-1)===t||(ke.view=t,ke.history[ke.history.length-1]=t,ke.data=e)},goBack(){const t=!F.state.activeCaipAddress&&this.state.view==="ConnectingFarcaster";if(ke.history.length>1&&!ke.history.includes("UnsupportedChain")){ke.history.pop();const[e]=ke.history.slice(-1);e&&(ke.view=e)}else Qt.close();ke.data?.wallet&&(ke.data.wallet=void 0),setTimeout(()=>{if(t){oe.setFarcasterUrl(void 0,F.state.activeChain);const e=fe.getAuthConnector();e?.provider?.reload();const r=Vc(J.state);e?.provider?.syncDappData?.({metadata:r.metadata,sdkVersion:r.sdkVersion,projectId:r.projectId,sdkType:r.sdkType})}},100)},goBackToIndex(t){if(ke.history.length>1){ke.history=ke.history.slice(0,t+1);const[e]=ke.history.slice(-1);e&&(ke.view=e)}}},Es=Tt({themeMode:"dark",themeVariables:{},w3mThemeVariables:void 0}),kr={state:Es,subscribe(t){return Fr(Es,()=>t(Es))},setThemeMode(t){Es.themeMode=t;try{const e=fe.getAuthConnector();if(e){const r=kr.getSnapshot().themeVariables;e.provider.syncTheme({themeMode:t,themeVariables:r,w3mThemeVariables:en(r,t)})}}catch{console.info("Unable to sync theme to auth connector")}},setThemeVariables(t){Es.themeVariables={...Es.themeVariables,...t};try{const e=fe.getAuthConnector();if(e){const r=kr.getSnapshot().themeVariables;e.provider.syncTheme({themeVariables:r,w3mThemeVariables:en(Es.themeVariables,Es.themeMode)})}}catch{console.info("Unable to sync theme to auth connector")}},getSnapshot(){return Vc(Es)}},B3={eip155:void 0,solana:void 0,polkadot:void 0,bip122:void 0},ze=Tt({allConnectors:[],connectors:[],activeConnector:void 0,filterByNamespace:void 0,activeConnectorIds:{...B3}}),fe={state:ze,subscribe(t){return Fr(ze,()=>{t(ze)})},subscribeKey(t,e){return gi(ze,t,e)},initialize(t){t.forEach(e=>{const r=se.getConnectedConnectorId(e);r&&this.setConnectorId(r,e)})},setActiveConnector(t){t&&(ze.activeConnector=qn(t))},setConnectors(t){t.filter(r=>!ze.allConnectors.some(i=>i.id===r.id&&this.getConnectorName(i.name)===this.getConnectorName(r.name)&&i.chain===r.chain)).forEach(r=>{r.type!=="MULTI_CHAIN"&&ze.allConnectors.push(qn(r))}),ze.connectors=this.mergeMultiChainConnectors(ze.allConnectors)},removeAdapter(t){ze.allConnectors=ze.allConnectors.filter(e=>e.chain!==t),ze.connectors=this.mergeMultiChainConnectors(ze.allConnectors)},mergeMultiChainConnectors(t){const e=this.generateConnectorMapByName(t),r=[];return e.forEach(i=>{const s=i[0],n=s?.id===ne.CONNECTOR_ID.AUTH;i.length>1&&s?r.push({name:s.name,imageUrl:s.imageUrl,imageId:s.imageId,connectors:[...i],type:n?"AUTH":"MULTI_CHAIN",chain:"eip155",id:s?.id||""}):s&&r.push(s)}),r},generateConnectorMapByName(t){const e=new Map;return t.forEach(r=>{const{name:i}=r,s=this.getConnectorName(i);if(!s)return;const n=e.get(s)||[];n.find(a=>a.chain===r.chain)||n.push(r),e.set(s,n)}),e},getConnectorName(t){return t&&({"Trust Wallet":"Trust"}[t]||t)},getUniqueConnectorsByName(t){const e=[];return t.forEach(r=>{e.find(i=>i.chain===r.chain)||e.push(r)}),e},addConnector(t){if(t.id===ne.CONNECTOR_ID.AUTH){const e=t,r=Vc(J.state),i=kr.getSnapshot().themeMode,s=kr.getSnapshot().themeVariables;e?.provider?.syncDappData?.({metadata:r.metadata,sdkVersion:r.sdkVersion,projectId:r.projectId,sdkType:r.sdkType}),e?.provider?.syncTheme({themeMode:i,themeVariables:s,w3mThemeVariables:en(s,i)}),this.setConnectors([t])}else this.setConnectors([t])},getAuthConnector(t){const e=t||F.state.activeChain,r=ze.connectors.find(i=>i.id===ne.CONNECTOR_ID.AUTH);if(r)return r?.connectors?.length?r.connectors.find(s=>s.chain===e):r},getAnnouncedConnectorRdns(){return ze.connectors.filter(t=>t.type==="ANNOUNCED").map(t=>t.info?.rdns)},getConnectorById(t){return ze.allConnectors.find(e=>e.id===t)},getConnector(t,e){return ze.allConnectors.filter(i=>i.chain===F.state.activeChain).find(i=>i.explorerId===t||i.info?.rdns===e)},syncIfAuthConnector(t){if(t.id!=="ID_AUTH")return;const e=t,r=Vc(J.state),i=kr.getSnapshot().themeMode,s=kr.getSnapshot().themeVariables;e?.provider?.syncDappData?.({metadata:r.metadata,sdkVersion:r.sdkVersion,sdkType:r.sdkType,projectId:r.projectId}),e.provider.syncTheme({themeMode:i,themeVariables:s,w3mThemeVariables:en(s,i)})},getConnectorsByNamespace(t){const e=ze.allConnectors.filter(r=>r.chain===t);return this.mergeMultiChainConnectors(e)},selectWalletConnector(t){const e=fe.getConnector(t.id,t.rdns);F.state.activeChain===ne.CHAIN.SOLANA&&WF.handleSolanaDeeplinkRedirect(e?.name||t.name||""),e?He.push("ConnectingExternal",{connector:e}):He.push("ConnectingWalletConnect",{wallet:t})},getConnectors(t){return t?this.getConnectorsByNamespace(t):this.mergeMultiChainConnectors(ze.allConnectors)},setFilterByNamespace(t){ze.filterByNamespace=t,ze.connectors=this.getConnectors(t),be.setFilterByNamespace(t)},setConnectorId(t,e){t&&(ze.activeConnectorIds={...ze.activeConnectorIds,[e]:t},se.setConnectedConnectorId(e,t))},removeConnectorId(t){ze.activeConnectorIds={...ze.activeConnectorIds,[t]:void 0},se.deleteConnectedConnectorId(t)},getConnectorId(t){if(t)return ze.activeConnectorIds[t]},isConnected(t){return t?!!ze.activeConnectorIds[t]:Object.values(ze.activeConnectorIds).some(e=>!!e)},resetConnectorIds(){ze.activeConnectorIds={...B3}}};function ml(t,e){return fe.getConnectorId(t)===e}function rj(t){const e=Array.from(F.state.chains.keys());let r=[];return t?(r.push([t,F.state.chains.get(t)]),ml(t,ne.CONNECTOR_ID.WALLET_CONNECT)?e.forEach(i=>{i!==t&&ml(i,ne.CONNECTOR_ID.WALLET_CONNECT)&&r.push([i,F.state.chains.get(i)])}):ml(t,ne.CONNECTOR_ID.AUTH)&&e.forEach(i=>{i!==t&&ml(i,ne.CONNECTOR_ID.AUTH)&&r.push([i,F.state.chains.get(i)])})):r=Array.from(F.state.chains.entries()),r}var ij=Object.defineProperty,sj=(t,e,r)=>e in t?ij(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Wy=(t,e,r)=>sj(t,typeof e!="symbol"?e+"":e,r);let nj=class extends pi{constructor(e){super(),this.opts=e,Wy(this,"protocol","wc"),Wy(this,"version",2)}};var oj=Object.defineProperty,aj=(t,e,r)=>e in t?oj(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,cj=(t,e,r)=>aj(t,e+"",r);let uj=class extends pi{constructor(e,r){super(),this.core=e,this.logger=r,cj(this,"records",new Map)}},lj=class{constructor(e,r){this.logger=e,this.core=r}},hj=class extends pi{constructor(e,r){super(),this.relayer=e,this.logger=r}},dj=class extends pi{constructor(e){super()}},fj=class{constructor(e,r,i,s){this.core=e,this.logger=r,this.name=i}},pj=class extends pi{constructor(e,r){super(),this.relayer=e,this.logger=r}},gj=class extends pi{constructor(e,r){super(),this.core=e,this.logger=r}},bj=class{constructor(e,r,i){this.core=e,this.logger=r,this.store=i}},mj=class{constructor(e,r){this.projectId=e,this.logger=r}},yj=class{constructor(e,r,i){this.core=e,this.logger=r,this.telemetryEnabled=i}};var wj=Object.defineProperty,vj=(t,e,r)=>e in t?wj(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Gy=(t,e,r)=>vj(t,typeof e!="symbol"?e+"":e,r);let _j=class{constructor(e){this.opts=e,Gy(this,"protocol","wc"),Gy(this,"version",2)}},Ej=class{constructor(e){this.client=e}};function Ij(t){if(t.length>=255)throw new TypeError("Alphabet too long");const e=new Uint8Array(256);for(let c=0;c<e.length;c++)e[c]=255;for(let c=0;c<t.length;c++){const l=t.charAt(c),h=l.charCodeAt(0);if(e[h]!==255)throw new TypeError(l+" is ambiguous");e[h]=c}const r=t.length,i=t.charAt(0),s=Math.log(r)/Math.log(256),n=Math.log(256)/Math.log(r);function o(c){if(c instanceof Uint8Array||(ArrayBuffer.isView(c)?c=new Uint8Array(c.buffer,c.byteOffset,c.byteLength):Array.isArray(c)&&(c=Uint8Array.from(c))),!(c instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(c.length===0)return"";let l=0,h=0,f=0;const m=c.length;for(;f!==m&&c[f]===0;)f++,l++;const g=(m-f)*n+1>>>0,y=new Uint8Array(g);for(;f!==m;){let A=c[f],D=0;for(let O=g-1;(A!==0||D<h)&&O!==-1;O--,D++)A+=256*y[O]>>>0,y[O]=A%r>>>0,A=A/r>>>0;if(A!==0)throw new Error("Non-zero carry");h=D,f++}let C=g-h;for(;C!==g&&y[C]===0;)C++;let S=i.repeat(l);for(;C<g;++C)S+=t.charAt(y[C]);return S}function a(c){if(typeof c!="string")throw new TypeError("Expected String");if(c.length===0)return new Uint8Array;let l=0,h=0,f=0;for(;c[l]===i;)h++,l++;const m=(c.length-l)*s+1>>>0,g=new Uint8Array(m);for(;l<c.length;){const A=c.charCodeAt(l);if(A>255)return;let D=e[A];if(D===255)return;let O=0;for(let T=m-1;(D!==0||O<f)&&T!==-1;T--,O++)D+=r*g[T]>>>0,g[T]=D%256>>>0,D=D/256>>>0;if(D!==0)throw new Error("Non-zero carry");f=O,l++}let y=m-f;for(;y!==m&&g[y]===0;)y++;const C=new Uint8Array(h+(m-y));let S=h;for(;y!==m;)C[S++]=g[y++];return C}function u(c){const l=a(c);if(l)return l;throw new Error("Non-base"+r+" character")}return{encode:o,decodeUnsafe:a,decode:u}}var Aj="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";const Nc=Ij(Aj),Ys={SAFE_RPC_METHODS:["eth_accounts","eth_blockNumber","eth_call","eth_chainId","eth_estimateGas","eth_feeHistory","eth_gasPrice","eth_getAccount","eth_getBalance","eth_getBlockByHash","eth_getBlockByNumber","eth_getBlockReceipts","eth_getBlockTransactionCountByHash","eth_getBlockTransactionCountByNumber","eth_getCode","eth_getFilterChanges","eth_getFilterLogs","eth_getLogs","eth_getProof","eth_getStorageAt","eth_getTransactionByBlockHashAndIndex","eth_getTransactionByBlockNumberAndIndex","eth_getTransactionByHash","eth_getTransactionCount","eth_getTransactionReceipt","eth_getUncleCountByBlockHash","eth_getUncleCountByBlockNumber","eth_maxPriorityFeePerGas","eth_newBlockFilter","eth_newFilter","eth_newPendingTransactionFilter","eth_sendRawTransaction","eth_syncing","eth_uninstallFilter","wallet_getCapabilities","wallet_getCallsStatus","eth_getUserOperationReceipt","eth_estimateUserOperationGas","eth_getUserOperationByHash","eth_supportedEntryPoints","wallet_getAssets"],NOT_SAFE_RPC_METHODS:["personal_sign","eth_signTypedData_v4","eth_sendTransaction","solana_signMessage","solana_signTransaction","solana_signAllTransactions","solana_signAndSendTransaction","wallet_sendCalls","wallet_grantPermissions","wallet_revokePermissions","eth_sendUserOperation"],GET_CHAIN_ID:"eth_chainId",RPC_METHOD_NOT_ALLOWED_MESSAGE:"Requested RPC call is not allowed",RPC_METHOD_NOT_ALLOWED_UI_MESSAGE:"Action not allowed",ACCOUNT_TYPES:{EOA:"eoa",SMART_ACCOUNT:"smartAccount"}},Sn=Object.freeze({message:"",variant:"success",svg:void 0,open:!1,autoClose:!0}),Xt=Tt({...Sn}),Ir={state:Xt,subscribeKey(t,e){return gi(Xt,t,e)},showLoading(t,e={}){this._showMessage({message:t,variant:"loading",...e})},showSuccess(t){this._showMessage({message:t,variant:"success"})},showSvg(t,e){this._showMessage({message:t,svg:e})},showError(t){const e=pe.parseError(t);this._showMessage({message:e,variant:"error"})},hide(){Xt.message=Sn.message,Xt.variant=Sn.variant,Xt.svg=Sn.svg,Xt.open=Sn.open,Xt.autoClose=Sn.autoClose},_showMessage({message:t,svg:e,variant:r="success",autoClose:i=Sn.autoClose}){Xt.open?(Xt.open=!1,setTimeout(()=>{Xt.message=t,Xt.variant=r,Xt.svg=e,Xt.open=!0,Xt.autoClose=i},150)):(Xt.message=t,Xt.variant=r,Xt.svg=e,Xt.open=!0,Xt.autoClose=i)}},Oc={getSIWX(){return J.state.siwx},async initializeIfEnabled(){const t=J.state.siwx,e=F.getActiveCaipAddress();if(!(t&&e))return;const[r,i,s]=e.split(":");if(F.checkIfSupportedNetwork(r))try{if((await t.getSessions(`${r}:${i}`,s)).length)return;await Qt.open({view:"SIWXSignMessage"})}catch(n){console.error("SIWXUtil:initializeIfEnabled",n),lt.sendEvent({type:"track",event:"SIWX_AUTH_ERROR",properties:this.getSIWXEventProperties()}),await ut._getClient()?.disconnect().catch(console.error),He.reset("Connect"),Ir.showError("A problem occurred while trying initialize authentication")}},async requestSignMessage(){const t=J.state.siwx,e=pe.getPlainAddress(F.getActiveCaipAddress()),r=F.getActiveCaipNetwork(),i=ut._getClient();if(!t)throw new Error("SIWX is not enabled");if(!e)throw new Error("No ActiveCaipAddress found");if(!r)throw new Error("No ActiveCaipNetwork or client found");if(!i)throw new Error("No ConnectionController client found");try{const s=await t.createMessage({chainId:r.caipNetworkId,accountAddress:e}),n=s.toString();fe.getConnectorId(r.chainNamespace)===ne.CONNECTOR_ID.AUTH&&He.pushTransactionStack({view:null,goBack:!1,replace:!0});const a=await i.signMessage(n);await t.addSession({data:s,message:n,signature:a}),Qt.close(),lt.sendEvent({type:"track",event:"SIWX_AUTH_SUCCESS",properties:this.getSIWXEventProperties()})}catch(s){const n=this.getSIWXEventProperties();(!Qt.state.open||He.state.view==="ApproveTransaction")&&await Qt.open({view:"SIWXSignMessage"}),n.isSmartAccount?Ir.showError("This application might not support Smart Accounts"):Ir.showError("Signature declined"),lt.sendEvent({type:"track",event:"SIWX_AUTH_ERROR",properties:n}),console.error("SWIXUtil:requestSignMessage",s)}},async cancelSignMessage(){try{this.getSIWX()?.getRequired?.()?await ut.disconnect():Qt.close(),He.reset("Connect"),lt.sendEvent({event:"CLICK_CANCEL_SIWX",type:"track",properties:this.getSIWXEventProperties()})}catch(t){console.error("SIWXUtil:cancelSignMessage",t)}},async getSessions(){const t=J.state.siwx,e=pe.getPlainAddress(F.getActiveCaipAddress()),r=F.getActiveCaipNetwork();return t&&e&&r?t.getSessions(r.caipNetworkId,e):[]},async isSIWXCloseDisabled(){const t=this.getSIWX();if(t){const e=He.state.view==="ApproveTransaction",r=He.state.view==="SIWXSignMessage";if(e||r)return t.getRequired?.()&&(await this.getSessions()).length===0}return!1},async universalProviderAuthenticate({universalProvider:t,chains:e,methods:r}){const i=Oc.getSIWX(),s=new Set(e.map(a=>a.split(":")[0]));if(!i||s.size!==1||!s.has("eip155"))return!1;const n=await i.createMessage({chainId:F.getActiveCaipNetwork()?.caipNetworkId||"",accountAddress:""}),o=await t.authenticate({nonce:n.nonce,domain:n.domain,uri:n.uri,exp:n.expirationTime,iat:n.issuedAt,nbf:n.notBefore,requestId:n.requestId,version:n.version,resources:n.resources,statement:n.statement,chainId:n.chainId,methods:r,chains:[n.chainId,...e.filter(a=>a!==n.chainId)]});if(Ir.showLoading("Authenticating...",{autoClose:!1}),oe.setConnectedWalletInfo({...o.session.peer.metadata,name:o.session.peer.metadata.name,icon:o.session.peer.metadata.icons?.[0],type:"WALLET_CONNECT"},Array.from(s)[0]),o?.auths?.length){const a=o.auths.map(u=>{const c=t.client.formatAuthMessage({request:u.p,iss:u.p.iss});return{data:{...u.p,accountAddress:u.p.iss.split(":").slice(-1).join(""),chainId:u.p.iss.split(":").slice(2,4).join(":"),uri:u.p.aud,version:u.p.version||n.version,expirationTime:u.p.exp,issuedAt:u.p.iat,notBefore:u.p.nbf},message:c,signature:u.s.s,cacao:u}});try{await i.setSessions(a),lt.sendEvent({type:"track",event:"SIWX_AUTH_SUCCESS",properties:Oc.getSIWXEventProperties()})}catch(u){throw console.error("SIWX:universalProviderAuth - failed to set sessions",u),lt.sendEvent({type:"track",event:"SIWX_AUTH_ERROR",properties:Oc.getSIWXEventProperties()}),await t.disconnect().catch(console.error),u}finally{Ir.hide()}}return!0},getSIWXEventProperties(){return{network:F.state.activeCaipNetwork?.caipNetworkId||"",isSmartAccount:oe.state.preferredAccountType===Ys.ACCOUNT_TYPES.SMART_ACCOUNT}},async clearSessions(){const t=this.getSIWX();t&&await t.setSessions([])}},at=Tt({transactions:[],coinbaseTransactions:{},transactionsByYear:{},lastNetworkInView:void 0,loading:!1,empty:!1,next:void 0}),Sj={state:at,subscribe(t){return Fr(at,()=>t(at))},setLastNetworkInView(t){at.lastNetworkInView=t},async fetchTransactions(t,e){if(!t)throw new Error("Transactions can't be fetched without an accountAddress");at.loading=!0;try{const r=await ue.fetchTransactions({account:t,cursor:at.next,onramp:e,cache:e==="coinbase"?"no-cache":void 0,chainId:F.state.activeCaipNetwork?.caipNetworkId}),i=this.filterSpamTransactions(r.data),s=this.filterByConnectedChain(i),n=[...at.transactions,...s];at.loading=!1,e==="coinbase"?at.coinbaseTransactions=this.groupTransactionsByYearAndMonth(at.coinbaseTransactions,r.data):(at.transactions=n,at.transactionsByYear=this.groupTransactionsByYearAndMonth(at.transactionsByYear,s)),at.empty=n.length===0,at.next=r.next?r.next:void 0}catch{lt.sendEvent({type:"track",event:"ERROR_FETCH_TRANSACTIONS",properties:{address:t,projectId:J.state.projectId,cursor:at.next,isSmartAccount:oe.state.preferredAccountType===Ys.ACCOUNT_TYPES.SMART_ACCOUNT}}),Ir.showError("Failed to fetch transactions"),at.loading=!1,at.empty=!0,at.next=void 0}},groupTransactionsByYearAndMonth(t={},e=[]){const r=t;return e.forEach(i=>{const s=new Date(i.metadata.minedAt).getFullYear(),n=new Date(i.metadata.minedAt).getMonth(),o=r[s]??{},u=(o[n]??[]).filter(c=>c.id!==i.id);r[s]={...o,[n]:[...u,i].sort((c,l)=>new Date(l.metadata.minedAt).getTime()-new Date(c.metadata.minedAt).getTime())}}),r},filterSpamTransactions(t){return t.filter(e=>!e.transfers.every(i=>i.nft_info?.flags.is_spam===!0))},filterByConnectedChain(t){const e=F.state.activeCaipNetwork?.caipNetworkId;return t.filter(i=>i.metadata.chain===e)},clearCursor(){at.next=void 0},resetTransactions(){at.transactions=[],at.transactionsByYear={},at.lastNetworkInView=void 0,at.loading=!1,at.empty=!1,at.next=void 0}},vt=Tt({wcError:!1,buffering:!1,status:"disconnected"});let So;const ut={state:vt,subscribeKey(t,e){return gi(vt,t,e)},_getClient(){return vt._client},setClient(t){vt._client=qn(t)},async connectWalletConnect(){if(pe.isTelegram()||pe.isSafari()&&pe.isIos()){if(So){await So,So=void 0;return}if(!pe.isPairingExpired(vt?.wcPairingExpiry)){const t=vt.wcUri;vt.wcUri=t;return}So=this._getClient()?.connectWalletConnect?.().catch(()=>{}),this.state.status="connecting",await So,So=void 0,vt.wcPairingExpiry=void 0,this.state.status="connected"}else await this._getClient()?.connectWalletConnect?.()},async connectExternal(t,e,r=!0){await this._getClient()?.connectExternal?.(t),r&&F.setActiveNamespace(e)},async reconnectExternal(t){await this._getClient()?.reconnectExternal?.(t);const e=t.chain||F.state.activeChain;e&&fe.setConnectorId(t.id,e)},async setPreferredAccountType(t){Qt.setLoading(!0,F.state.activeChain);const e=fe.getAuthConnector();e&&(await e?.provider.setPreferredAccount(t),await this.reconnectExternal(e),Qt.setLoading(!1,F.state.activeChain),lt.sendEvent({type:"track",event:"SET_PREFERRED_ACCOUNT_TYPE",properties:{accountType:t,network:F.state.activeCaipNetwork?.caipNetworkId||""}}))},async signMessage(t){return this._getClient()?.signMessage(t)},parseUnits(t,e){return this._getClient()?.parseUnits(t,e)},formatUnits(t,e){return this._getClient()?.formatUnits(t,e)},async sendTransaction(t){return this._getClient()?.sendTransaction(t)},async getCapabilities(t){return this._getClient()?.getCapabilities(t)},async grantPermissions(t){return this._getClient()?.grantPermissions(t)},async walletGetAssets(t){return this._getClient()?.walletGetAssets(t)??{}},async estimateGas(t){return this._getClient()?.estimateGas(t)},async writeContract(t){return this._getClient()?.writeContract(t)},async getEnsAddress(t){return this._getClient()?.getEnsAddress(t)},async getEnsAvatar(t){return this._getClient()?.getEnsAvatar(t)},checkInstalled(t){return this._getClient()?.checkInstalled?.(t)||!1},resetWcConnection(){vt.wcUri=void 0,vt.wcPairingExpiry=void 0,vt.wcLinking=void 0,vt.recentWallet=void 0,vt.status="disconnected",Sj.resetTransactions(),se.deleteWalletConnectDeepLink()},resetUri(){vt.wcUri=void 0,vt.wcPairingExpiry=void 0},finalizeWcConnection(){const{wcLinking:t,recentWallet:e}=ut.state;t&&se.setWalletConnectDeepLink(t),e&&se.setAppKitRecent(e),lt.sendEvent({type:"track",event:"CONNECT_SUCCESS",properties:{method:t?"mobile":"qrcode",name:He.state.data?.wallet?.name||"Unknown"}})},setWcBasic(t){vt.wcBasic=t},setUri(t){vt.wcUri=t,vt.wcPairingExpiry=pe.getPairingExpiry()},setWcLinking(t){vt.wcLinking=t},setWcError(t){vt.wcError=t,vt.buffering=!1},setRecentWallet(t){vt.recentWallet=t},setBuffering(t){vt.buffering=t},setStatus(t){vt.status=t},async disconnect(t){try{Qt.setLoading(!0,t),await Oc.clearSessions(),await F.disconnect(t),Qt.setLoading(!1,t),fe.setFilterByNamespace(void 0)}catch{throw new Error("Failed to disconnect")}}},uc=Tt({loading:!1,open:!1,selectedNetworkId:void 0,activeChain:void 0,initialized:!1}),Ps={state:uc,subscribe(t){return Fr(uc,()=>t(uc))},set(t){Object.assign(uc,{...uc,...t})}};function Cj(t,{strict:e=!0}={}){return!t||typeof t!="string"?!1:e?/^0x[0-9a-fA-F]*$/.test(t):t.startsWith("0x")}function Yy(t){return Cj(t,{strict:!1})?Math.ceil((t.length-2)/2):t.length}const z3="2.48.8";let pf={getDocsUrl:({docsBaseUrl:t,docsPath:e="",docsSlug:r})=>e?`${t??"https://viem.sh"}${e}${r?`#${r}`:""}`:void 0,version:`viem@${z3}`},fs=class Sp extends Error{constructor(e,r={}){const i=r.cause instanceof Sp?r.cause.details:r.cause?.message?r.cause.message:r.details,s=r.cause instanceof Sp&&r.cause.docsPath||r.docsPath,n=pf.getDocsUrl?.({...r,docsPath:s}),o=[e||"An error occurred.","",...r.metaMessages?[...r.metaMessages,""]:[],...n?[`Docs: ${n}`]:[],...i?[`Details: ${i}`]:[],...pf.version?[`Version: ${pf.version}`]:[]].join(`
|
|
14
|
+
`);super(o,r.cause?{cause:r.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=i,this.docsPath=s,this.metaMessages=r.metaMessages,this.name=r.name??this.name,this.shortMessage=e,this.version=z3}walk(e){return H3(this,e)}};function H3(t,e){return e?.(t)?t:t&&typeof t=="object"&&"cause"in t&&t.cause!==void 0?H3(t.cause,e):e?null:t}let V3=class extends fs{constructor({size:e,targetSize:r,type:i}){super(`${i.charAt(0).toUpperCase()}${i.slice(1).toLowerCase()} size (${e}) exceeds padding size (${r}).`,{name:"SizeExceedsPaddingSizeError"})}};function Ng(t,{dir:e,size:r=32}={}){return typeof t=="string"?$j(t,{dir:e,size:r}):xj(t,{dir:e,size:r})}function $j(t,{dir:e,size:r=32}={}){if(r===null)return t;const i=t.replace("0x","");if(i.length>r*2)throw new V3({size:Math.ceil(i.length/2),targetSize:r,type:"hex"});return`0x${i[e==="right"?"padEnd":"padStart"](r*2,"0")}`}function xj(t,{dir:e,size:r=32}={}){if(r===null)return t;if(t.length>r)throw new V3({size:t.length,targetSize:r,type:"bytes"});const i=new Uint8Array(r);for(let s=0;s<r;s++){const n=e==="right";i[n?s:r-s-1]=t[n?s:t.length-s-1]}return i}let Pj=class extends fs{constructor({max:e,min:r,signed:i,size:s,value:n}){super(`Number "${n}" is not in safe ${s?`${s*8}-bit ${i?"signed":"unsigned"} `:""}integer range ${e?`(${r} to ${e})`:`(above ${r})`}`,{name:"IntegerOutOfRangeError"})}},Nj=class extends fs{constructor({givenSize:e,maxSize:r}){super(`Size cannot exceed ${r} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}};function K3(t,{size:e}){if(Yy(t)>e)throw new Nj({givenSize:Yy(t),maxSize:e})}const Oj=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Jy(t,e={}){return typeof t=="number"||typeof t=="bigint"?Dj(t,e):typeof t=="string"?Mj(t,e):typeof t=="boolean"?Tj(t,e):W3(t,e)}function Tj(t,e={}){const r=`0x${Number(t)}`;return typeof e.size=="number"?(K3(r,{size:e.size}),Ng(r,{size:e.size})):r}function W3(t,e={}){let r="";for(let s=0;s<t.length;s++)r+=Oj[t[s]];const i=`0x${r}`;return typeof e.size=="number"?(K3(i,{size:e.size}),Ng(i,{dir:"right",size:e.size})):i}function Dj(t,e={}){const{signed:r,size:i}=e,s=BigInt(t);let n;i?r?n=(1n<<BigInt(i)*8n-1n)-1n:n=2n**(BigInt(i)*8n)-1n:typeof t=="number"&&(n=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof n=="bigint"&&r?-n-1n:0;if(n&&s>n||s<o){const u=typeof t=="bigint"?"n":"";throw new Pj({max:n?`${n}${u}`:void 0,min:`${o}${u}`,signed:r,size:i,value:`${t}${u}`})}const a=`0x${(r&&s<0?(1n<<BigInt(i*8))+BigInt(s):s).toString(16)}`;return i?Ng(a,{size:i}):a}const Rj=new TextEncoder;function Mj(t,e={}){const r=Rj.encode(t);return W3(r,e)}let kj=class 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)&&(super.delete(e),super.set(e,r)),r}set(e,r){if(super.has(e)&&super.delete(e),super.set(e,r),this.maxSize&&this.size>this.maxSize){const i=super.keys().next().value;i!==void 0&&super.delete(i)}return this}};const Mn=(t,e,r)=>JSON.stringify(t,(i,s)=>typeof s=="bigint"?s.toString():s,r);function Uj(t,e){let r=t.toString();const i=r.startsWith("-");i&&(r=r.slice(1)),r=r.padStart(e,"0");let[s,n]=[r.slice(0,r.length-e),r.slice(r.length-e)];return n=n.replace(/(0+)$/,""),`${i?"-":""}${s||"0"}${n?`.${n}`:""}`}const Og=t=>{try{const e=new URL(t);return!e.username&&!e.password?t:(e.username="",e.password="",e.toString())}catch{return t}};class Tc extends fs{constructor({body:e,cause:r,details:i,headers:s,status:n,url:o}){super("HTTP request failed.",{cause:r,details:i,metaMessages:[n&&`Status: ${n}`,`URL: ${Og(o)}`,e&&`Request body: ${Mn(e)}`].filter(Boolean),name:"HttpRequestError"}),Object.defineProperty(this,"body",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"headers",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"status",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"url",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.body=e,this.headers=s,this.status=n,this.url=o}}class G3 extends fs{constructor({body:e,error:r,url:i}){super("RPC Request failed.",{cause:r,details:r.message,metaMessages:[`URL: ${Og(i)}`,`Request body: ${Mn(e)}`],name:"RpcRequestError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"url",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.code=r.code,this.data=r.data,this.url=i}}class Qy extends fs{constructor({body:e,url:r}){super("The request took too long to respond.",{details:"The request timed out.",metaMessages:[`URL: ${Og(r)}`,`Request body: ${Mn(e)}`],name:"TimeoutError"}),Object.defineProperty(this,"url",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.url=r}}const Lj=-1;class Xr extends fs{constructor(e,{code:r,docsPath:i,metaMessages:s,name:n,shortMessage:o}){super(o,{cause:e,docsPath:i,metaMessages:s||e?.metaMessages,name:n||"RpcError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=n||e.name,this.code=e instanceof G3?e.code:r??Lj}}class Zr extends Xr{constructor(e,r){super(e,r),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=r.data}}class Kc extends Xr{constructor(e){super(e,{code:Kc.code,name:"ParseRpcError",shortMessage:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."})}}Object.defineProperty(Kc,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32700});class Wc extends Xr{constructor(e){super(e,{code:Wc.code,name:"InvalidRequestRpcError",shortMessage:"JSON is not a valid request object."})}}Object.defineProperty(Wc,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32600});class Gc extends Xr{constructor(e,{method:r}={}){super(e,{code:Gc.code,name:"MethodNotFoundRpcError",shortMessage:`The method${r?` "${r}"`:""} does not exist / is not available.`})}}Object.defineProperty(Gc,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32601});class Yc extends Xr{constructor(e){super(e,{code:Yc.code,name:"InvalidParamsRpcError",shortMessage:["Invalid parameters were provided to the RPC method.","Double check you have provided the correct parameters."].join(`
|
|
15
|
+
`)})}}Object.defineProperty(Yc,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32602});class la extends Xr{constructor(e){super(e,{code:la.code,name:"InternalRpcError",shortMessage:"An internal error was received."})}}Object.defineProperty(la,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32603});class Jc extends Xr{constructor(e){super(e,{code:Jc.code,name:"InvalidInputRpcError",shortMessage:["Missing or invalid parameters.","Double check you have provided the correct parameters."].join(`
|
|
16
|
+
`)})}}Object.defineProperty(Jc,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32e3});class Qc extends Xr{constructor(e){super(e,{code:Qc.code,name:"ResourceNotFoundRpcError",shortMessage:"Requested resource not found."}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ResourceNotFoundRpcError"})}}Object.defineProperty(Qc,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32001});class Xc extends Xr{constructor(e){super(e,{code:Xc.code,name:"ResourceUnavailableRpcError",shortMessage:"Requested resource not available."})}}Object.defineProperty(Xc,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32002});class ha extends Xr{constructor(e){super(e,{code:ha.code,name:"TransactionRejectedRpcError",shortMessage:"Transaction creation failed."})}}Object.defineProperty(ha,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32003});class Tn extends Xr{constructor(e,{method:r}={}){super(e,{code:Tn.code,name:"MethodNotSupportedRpcError",shortMessage:`Method${r?` "${r}"`:""} is not supported.`})}}Object.defineProperty(Tn,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32004});class da extends Xr{constructor(e){super(e,{code:da.code,name:"LimitExceededRpcError",shortMessage:"Request exceeds defined limit."})}}Object.defineProperty(da,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32005});class Zc extends Xr{constructor(e){super(e,{code:Zc.code,name:"JsonRpcVersionUnsupportedError",shortMessage:"Version of JSON-RPC protocol is not supported."})}}Object.defineProperty(Zc,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32006});class kn extends Zr{constructor(e){super(e,{code:kn.code,name:"UserRejectedRequestError",shortMessage:"User rejected the request."})}}Object.defineProperty(kn,"code",{enumerable:!0,configurable:!0,writable:!0,value:4001});class eu extends Zr{constructor(e){super(e,{code:eu.code,name:"UnauthorizedProviderError",shortMessage:"The requested method and/or account has not been authorized by the user."})}}Object.defineProperty(eu,"code",{enumerable:!0,configurable:!0,writable:!0,value:4100});class tu extends Zr{constructor(e,{method:r}={}){super(e,{code:tu.code,name:"UnsupportedProviderMethodError",shortMessage:`The Provider does not support the requested method${r?` " ${r}"`:""}.`})}}Object.defineProperty(tu,"code",{enumerable:!0,configurable:!0,writable:!0,value:4200});class ru extends Zr{constructor(e){super(e,{code:ru.code,name:"ProviderDisconnectedError",shortMessage:"The Provider is disconnected from all chains."})}}Object.defineProperty(ru,"code",{enumerable:!0,configurable:!0,writable:!0,value:4900});class iu extends Zr{constructor(e){super(e,{code:iu.code,name:"ChainDisconnectedError",shortMessage:"The Provider is not connected to the requested chain."})}}Object.defineProperty(iu,"code",{enumerable:!0,configurable:!0,writable:!0,value:4901});class su extends Zr{constructor(e){super(e,{code:su.code,name:"SwitchChainError",shortMessage:"An error occurred when attempting to switch chain."})}}Object.defineProperty(su,"code",{enumerable:!0,configurable:!0,writable:!0,value:4902});class nu extends Zr{constructor(e){super(e,{code:nu.code,name:"UnsupportedNonOptionalCapabilityError",shortMessage:"This Wallet does not support a capability that was not marked as optional."})}}Object.defineProperty(nu,"code",{enumerable:!0,configurable:!0,writable:!0,value:5700});class ou extends Zr{constructor(e){super(e,{code:ou.code,name:"UnsupportedChainIdError",shortMessage:"This Wallet does not support the requested chain ID."})}}Object.defineProperty(ou,"code",{enumerable:!0,configurable:!0,writable:!0,value:5710});class au extends Zr{constructor(e){super(e,{code:au.code,name:"DuplicateIdError",shortMessage:"There is already a bundle submitted with this ID."})}}Object.defineProperty(au,"code",{enumerable:!0,configurable:!0,writable:!0,value:5720});class cu extends Zr{constructor(e){super(e,{code:cu.code,name:"UnknownBundleIdError",shortMessage:"This bundle id is unknown / has not been submitted"})}}Object.defineProperty(cu,"code",{enumerable:!0,configurable:!0,writable:!0,value:5730});class uu extends Zr{constructor(e){super(e,{code:uu.code,name:"BundleTooLargeError",shortMessage:"The call bundle is too large for the Wallet to process."})}}Object.defineProperty(uu,"code",{enumerable:!0,configurable:!0,writable:!0,value:5740});class lu extends Zr{constructor(e){super(e,{code:lu.code,name:"AtomicReadyWalletRejectedUpgradeError",shortMessage:"The Wallet can support atomicity after an upgrade, but the user rejected the upgrade."})}}Object.defineProperty(lu,"code",{enumerable:!0,configurable:!0,writable:!0,value:5750});class hu extends Zr{constructor(e){super(e,{code:hu.code,name:"AtomicityNotSupportedError",shortMessage:"The wallet does not support atomic execution but the request requires it."})}}Object.defineProperty(hu,"code",{enumerable:!0,configurable:!0,writable:!0,value:5760});class fa extends Zr{constructor(e){super(e,{code:fa.code,name:"WalletConnectSessionSettlementError",shortMessage:"WalletConnect session settlement failed."})}}Object.defineProperty(fa,"code",{enumerable:!0,configurable:!0,writable:!0,value:7e3});class Fj extends Xr{constructor(e){super(e,{name:"UnknownRpcError",shortMessage:"An unknown RPC error occurred."})}}class Tg extends fs{constructor({cause:e,message:r}={}){const i=r?.replace("execution reverted: ","")?.replace("execution reverted","");super(`Execution reverted ${i?`with reason: ${i}`:"for an unknown reason"}.`,{cause:e,name:"ExecutionRevertedError"})}}Object.defineProperty(Tg,"code",{enumerable:!0,configurable:!0,writable:!0,value:3});Object.defineProperty(Tg,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/execution reverted|gas required exceeds allowance/});function jj(){let t=()=>{},e=()=>{};return{promise:new Promise((i,s)=>{t=i,e=s}),resolve:t,reject:e}}const gf=new Map;function qj({fn:t,id:e,shouldSplitBatch:r,wait:i=0,sort:s}){const n=async()=>{const l=u();o();const h=l.map(({args:f})=>f);h.length!==0&&t(h).then(f=>{s&&Array.isArray(f)&&f.sort(s);for(let m=0;m<l.length;m++){const{resolve:g}=l[m];g?.([f[m],f])}}).catch(f=>{for(let m=0;m<l.length;m++){const{reject:g}=l[m];g?.(f)}})},o=()=>gf.delete(e),a=()=>u().map(({args:l})=>l),u=()=>gf.get(e)||[],c=l=>gf.set(e,[...u(),l]);return{flush:o,async schedule(l){const{promise:h,resolve:f,reject:m}=jj();return r?.([...a(),l])&&n(),u().length>0?(c({args:l,resolve:f,reject:m}),h):(c({args:l,resolve:f,reject:m}),setTimeout(n,i),h)}}}async function Y3(t){return new Promise(e=>setTimeout(e,t))}function Bj(t,{delay:e=100,retryCount:r=2,shouldRetry:i=()=>!0}={}){return new Promise((s,n)=>{const o=async({count:a=0}={})=>{const u=async({error:c})=>{const l=typeof e=="function"?e({count:a,error:c}):e;l&&await Y3(l),o({count:a+1})};try{const c=await t();s(c)}catch(c){if(a<r&&await i({count:a,error:c}))return u({error:c});n(c)}};o()})}const Cp=256;let yl=Cp,wl;function zj(t=11){if(!wl||yl+t>Cp*2){wl="",yl=0;for(let e=0;e<Cp;e++)wl+=(256+Math.random()*256|0).toString(16).substring(1)}return wl.substring(yl,yl+++t)}const vl=new kj(8192);function Hj(t,{enabled:e=!0,id:r}){if(!e||!r)return t();if(vl.get(r))return vl.get(r);const i=t().finally(()=>vl.delete(r));return vl.set(r,i),i}function Vj(t,e={}){return async(r,i={})=>{const{dedupe:s=!1,methods:n,retryDelay:o=150,retryCount:a=3,uid:u}={...e,...i},{method:c}=r;if(n?.exclude?.includes(c))throw new Tn(new Error("method not supported"),{method:c});if(n?.include&&!n.include.includes(c))throw new Tn(new Error("method not supported"),{method:c});const l=s?Wj(`${u}.${Mn(r)}`):void 0;return Hj(()=>Bj(async()=>{try{return await t(r)}catch(h){const f=h;switch(f.code){case Kc.code:throw new Kc(f);case Wc.code:throw new Wc(f);case Gc.code:throw new Gc(f,{method:r.method});case Yc.code:throw new Yc(f);case la.code:throw new la(f);case Jc.code:throw new Jc(f);case Qc.code:throw new Qc(f);case Xc.code:throw new Xc(f);case ha.code:throw new ha(f);case Tn.code:throw new Tn(f,{method:r.method});case da.code:throw new da(f);case Zc.code:throw new Zc(f);case kn.code:throw new kn(f);case eu.code:throw new eu(f);case tu.code:throw new tu(f);case ru.code:throw new ru(f);case iu.code:throw new iu(f);case su.code:throw new su(f);case nu.code:throw new nu(f);case ou.code:throw new ou(f);case au.code:throw new au(f);case cu.code:throw new cu(f);case uu.code:throw new uu(f);case lu.code:throw new lu(f);case hu.code:throw new hu(f);case 5e3:throw new kn(f);case fa.code:throw new fa(f);default:throw h instanceof fs?h:new Fj(f)}}},{delay:({count:h,error:f})=>{if(f&&f instanceof Tc){const m=f?.headers?.get("Retry-After");if(m?.match(/\d/))return Number.parseInt(m,10)*1e3}return~~(1<<h)*o},retryCount:a,shouldRetry:({error:h})=>Kj(h)}),{enabled:s,id:l})}}function Kj(t){return"code"in t&&typeof t.code=="number"?t.code===-1||t.code===da.code||t.code===la.code||t.code===429:t instanceof Tc&&t.status?t.status===403||t.status===408||t.status===413||t.status===429||t.status===500||t.status===502||t.status===503||t.status===504:!0}function Wj(t,e=0){let r=3735928559^e,i=1103547991^e;for(let s=0;s<t.length;s++){const n=t.charCodeAt(s);r=Math.imul(r^n,2654435761),i=Math.imul(i^n,1597334677)}return r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(i^i>>>16,3266489909),i=Math.imul(i^i>>>16,2246822507),i^=Math.imul(r^r>>>16,3266489909),(4294967296*(2097151&i)+(r>>>0)).toString(36)}function Gj(t,{errorInstance:e=new Error("timed out"),timeout:r,signal:i}){return new Promise((s,n)=>{(async()=>{let o;try{const a=new AbortController;r>0&&(o=setTimeout(()=>{i&&a.abort()},r)),s(await t({signal:a?.signal||null}))}catch(a){a?.name==="AbortError"&&n(e),n(a)}finally{clearTimeout(o)}})()})}function Yj(){return{current:0,take(){return this.current++},reset(){this.current=0}}}const Xy=Yj();function Jj(t,e={}){const{url:r,headers:i}=Qj(t);return{async request(s){const{body:n,fetchFn:o=e.fetchFn??fetch,onRequest:a=e.onRequest,onResponse:u=e.onResponse,timeout:c=e.timeout??1e4}=s,l={...e.fetchOptions??{},...s.fetchOptions??{}},{headers:h,method:f,signal:m}=l;try{const g=await Gj(async({signal:C})=>{const S={...l,body:Array.isArray(n)?Mn(n.map(T=>({jsonrpc:"2.0",id:T.id??Xy.take(),...T}))):Mn({jsonrpc:"2.0",id:n.id??Xy.take(),...n}),headers:{...i,"Content-Type":"application/json",...h},method:f||"POST",signal:m||(c>0?C:null)},A=new Request(r,S),D=await a?.(A,S)??{...S,url:r};return await o(D.url??r,D)},{errorInstance:new Qy({body:n,url:r}),timeout:c,signal:!0});u&&await u(g);let y;if(g.headers.get("Content-Type")?.startsWith("application/json"))y=await g.json();else{y=await g.text();try{y=JSON.parse(y||"{}")}catch(C){if(g.ok)throw C;y={error:y}}}if(!g.ok){if(typeof y.error?.code=="number"&&typeof y.error?.message=="string")return y;throw new Tc({body:n,details:Mn(y.error)||g.statusText,headers:g.headers,status:g.status,url:r})}return y}catch(g){throw g instanceof Tc||g instanceof Qy?g:new Tc({body:n,cause:g,url:r})}}}}function Qj(t){try{const e=new URL(t),r=(()=>{if(e.username){const i=`${decodeURIComponent(e.username)}:${decodeURIComponent(e.password)}`;return e.username="",e.password="",{url:e.toString(),headers:{Authorization:`Basic ${btoa(i)}`}}}})();return{url:e.toString(),...r}}catch{return{url:t}}}function J3({key:t,methods:e,name:r,request:i,retryCount:s=3,retryDelay:n=150,timeout:o,type:a},u){const c=zj();return{config:{key:t,methods:e,name:r,request:i,retryCount:s,retryDelay:n,timeout:o,type:a},request:Vj(i,{methods:e,retryCount:s,retryDelay:n,uid:c}),value:u}}function Zy(t,e={}){const{key:r="fallback",name:i="Fallback",rank:s=!1,shouldThrow:n=Xj,retryCount:o,retryDelay:a}=e;return(({chain:u,pollingInterval:c=4e3,timeout:l,...h})=>{let f=t,m=()=>{};const g=J3({key:r,name:i,async request({method:y,params:C}){let S;const A=async(D=0)=>{const O=f[D]({...h,chain:u,retryCount:0,timeout:l});try{const T=await O.request({method:y,params:C});return m({method:y,params:C,response:T,transport:O,status:"success"}),T}catch(T){if(m({error:T,method:y,params:C,transport:O,status:"error"}),n(T)||D===f.length-1||(S??=f.slice(D+1).some(x=>{const{include:M,exclude:U}=x({chain:u}).config.methods||{};return M?M.includes(y):U?!U.includes(y):!0}),!S))throw T;return A(D+1)}};return A()},retryCount:o,retryDelay:a,type:"fallback"},{onResponse:y=>m=y,transports:f.map(y=>y({chain:u,retryCount:0}))});if(s){const y=typeof s=="object"?s:{};Zj({chain:u,interval:y.interval??c,onTransports:C=>f=C,ping:y.ping,sampleCount:y.sampleCount,timeout:y.timeout,transports:f,weights:y.weights})}return g})}function Xj(t){return!!("code"in t&&typeof t.code=="number"&&(t.code===ha.code||t.code===kn.code||t.code===fa.code||Tg.nodeMessage.test(t.message)||t.code===5e3))}function Zj({chain:t,interval:e=4e3,onTransports:r,ping:i,sampleCount:s=10,timeout:n=1e3,transports:o,weights:a={}}){const{stability:u=.7,latency:c=.3}=a,l=[],h=async()=>{const f=await Promise.all(o.map(async y=>{const C=y({chain:t,retryCount:0,timeout:n}),S=Date.now();let A,D;try{await(i?i({transport:C}):C.request({method:"net_listening"})),D=1}catch{D=0}finally{A=Date.now()}return{latency:A-S,success:D}}));l.push(f),l.length>s&&l.shift();const m=Math.max(...l.map(y=>Math.max(...y.map(({latency:C})=>C)))),g=o.map((y,C)=>{const S=l.map(x=>x[C].latency),D=1-S.reduce((x,M)=>x+M,0)/S.length/m,O=l.map(x=>x[C].success),T=O.reduce((x,M)=>x+M,0)/O.length;return T===0?[0,C]:[c*D+u*T,C]}).sort((y,C)=>C[0]-y[0]);r(g.map(([,y])=>o[y])),await Y3(e),h()};h()}class eq extends fs{constructor(){super("No URL was provided to the Transport. Please provide a valid RPC URL to the Transport.",{docsPath:"/docs/clients/intro",name:"UrlRequiredError"})}}function bf(t,e={}){const{batch:r,fetchFn:i,fetchOptions:s,key:n="http",methods:o,name:a="HTTP JSON-RPC",onFetchRequest:u,onFetchResponse:c,retryDelay:l,raw:h}=e;return({chain:f,retryCount:m,timeout:g})=>{const{batchSize:y=1e3,wait:C=0}=typeof r=="object"?r:{},S=e.retryCount??m,A=g??e.timeout??1e4,D=t||f?.rpcUrls.default.http[0];if(!D)throw new eq;const O=Jj(D,{fetchFn:i,fetchOptions:s,onRequest:u,onResponse:c,timeout:A});return J3({key:n,methods:o,name:a,async request({method:T,params:x}){const M={method:T,params:x},{schedule:U}=qj({id:D,wait:C,shouldSplitBatch(d){return d.length>y},fn:d=>O.request({body:d}),sort:(d,b)=>d.id-b.id}),R=async d=>r?U(d):[await O.request({body:d})],[{error:L,result:$}]=await R(M);if(h)return{error:L,result:$};if(L)throw new G3({body:M,error:L,url:D});return $},retryCount:S,retryDelay:l,timeout:A,type:"http"},{fetchOptions:s,url:D})}}const mf={createBalance(t,e){const r={name:t.metadata.name||"",symbol:t.metadata.symbol||"",decimals:t.metadata.decimals||0,value:t.metadata.value||0,price:t.metadata.price||0,iconUrl:t.metadata.iconUrl||""};return{name:r.name,symbol:r.symbol,chainId:e,address:t.address==="native"?void 0:this.convertAddressToCAIP10Address(t.address,e),value:r.value,price:r.price,quantity:{decimals:r.decimals.toString(),numeric:this.convertHexToBalance({hex:t.balance,decimals:r.decimals})},iconUrl:r.iconUrl}},convertHexToBalance({hex:t,decimals:e}){return Uj(BigInt(t),e)},convertAddressToCAIP10Address(t,e){return`${e}:${t}`},createCAIP2ChainId(t,e){return`${e}:${parseInt(t,16)}`},getChainIdHexFromCAIP2ChainId(t){const e=t.split(":");if(e.length<2||!e[1])return"0x0";const r=e[1],i=parseInt(r,10);return isNaN(i)?"0x0":`0x${i.toString(16)}`},isWalletGetAssetsResponse(t){return typeof t!="object"||t===null?!1:Object.values(t).every(e=>Array.isArray(e)&&e.every(r=>this.isValidAsset(r)))},isValidAsset(t){return typeof t=="object"&&t!==null&&typeof t.address=="string"&&typeof t.balance=="string"&&(t.type==="ERC20"||t.type==="NATIVE")&&typeof t.metadata=="object"&&t.metadata!==null&&typeof t.metadata.name=="string"&&typeof t.metadata.symbol=="string"&&typeof t.metadata.decimals=="number"&&typeof t.metadata.price=="number"&&typeof t.metadata.iconUrl=="string"}},ew={async getMyTokensWithBalance(t){const e=oe.state.address,r=F.state.activeCaipNetwork;if(!e||!r)return[];if(r.chainNamespace==="eip155"){const s=await this.getEIP155Balances(e,r);if(s)return this.filterLowQualityTokens(s)}const i=await ue.getBalance(e,r.caipNetworkId,t);return this.filterLowQualityTokens(i.balances)},async getEIP155Balances(t,e){try{const r=mf.getChainIdHexFromCAIP2ChainId(e.caipNetworkId);if(!(await ut.getCapabilities(t))?.[r]?.assetDiscovery?.supported)return null;const s=await ut.walletGetAssets({account:t,chainFilter:[r]});return mf.isWalletGetAssetsResponse(s)?(s[r]||[]).map(o=>mf.createBalance(o,e.caipNetworkId)):null}catch{return null}},filterLowQualityTokens(t){return t.filter(e=>e.quantity.decimals!=="0")},mapBalancesToSwapTokens(t){return t?.map(e=>({...e,address:e?.address?e.address:F.getActiveNetworkTokenAddress(),decimals:parseInt(e.quantity.decimals,10),logoUri:e.iconUrl,eip2612:!1}))||[]}},Ae=Tt({tokenBalances:[],loading:!1}),tw={state:Ae,subscribe(t){return Fr(Ae,()=>t(Ae))},subscribeKey(t,e){return gi(Ae,t,e)},setToken(t){t&&(Ae.token=qn(t))},setTokenAmount(t){Ae.sendTokenAmount=t},setReceiverAddress(t){Ae.receiverAddress=t},setReceiverProfileImageUrl(t){Ae.receiverProfileImageUrl=t},setReceiverProfileName(t){Ae.receiverProfileName=t},setGasPrice(t){Ae.gasPrice=t},setGasPriceInUsd(t){Ae.gasPriceInUSD=t},setNetworkBalanceInUsd(t){Ae.networkBalanceInUSD=t},setLoading(t){Ae.loading=t},sendToken(){switch(F.state.activeCaipNetwork?.chainNamespace){case"eip155":this.sendEvmToken();return;case"solana":this.sendSolanaToken();return;default:throw new Error("Unsupported chain")}},sendEvmToken(){this.state.token?.address&&this.state.sendTokenAmount&&this.state.receiverAddress?(lt.sendEvent({type:"track",event:"SEND_INITIATED",properties:{isSmartAccount:oe.state.preferredAccountType===Ys.ACCOUNT_TYPES.SMART_ACCOUNT,token:this.state.token.address,amount:this.state.sendTokenAmount,network:F.state.activeCaipNetwork?.caipNetworkId||""}}),this.sendERC20Token({receiverAddress:this.state.receiverAddress,tokenAddress:this.state.token.address,sendTokenAmount:this.state.sendTokenAmount,decimals:this.state.token.quantity.decimals})):this.state.receiverAddress&&this.state.sendTokenAmount&&this.state.gasPrice&&this.state.token?.quantity.decimals&&(lt.sendEvent({type:"track",event:"SEND_INITIATED",properties:{isSmartAccount:oe.state.preferredAccountType===Ys.ACCOUNT_TYPES.SMART_ACCOUNT,token:this.state.token?.symbol,amount:this.state.sendTokenAmount,network:F.state.activeCaipNetwork?.caipNetworkId||""}}),this.sendNativeToken({receiverAddress:this.state.receiverAddress,sendTokenAmount:this.state.sendTokenAmount,gasPrice:this.state.gasPrice,decimals:this.state.token.quantity.decimals}))},async fetchTokenBalance(t){Ae.loading=!0;const e=F.state.activeCaipNetwork?.caipNetworkId,r=F.state.activeCaipNetwork?.chainNamespace,i=F.state.activeCaipAddress,s=i?pe.getPlainAddress(i):void 0;if(Ae.lastRetry&&!pe.isAllowedRetry(Ae.lastRetry,30*Jr.ONE_SEC_MS))return Ae.loading=!1,[];try{if(s&&e&&r){const n=await ew.getMyTokensWithBalance();return Ae.tokenBalances=n,Ae.lastRetry=void 0,n}}catch(n){Ae.lastRetry=Date.now(),t?.(n),Ir.showError("Token Balance Unavailable")}finally{Ae.loading=!1}return[]},fetchNetworkBalance(){if(Ae.tokenBalances.length===0)return;const t=ew.mapBalancesToSwapTokens(Ae.tokenBalances);if(!t)return;const e=t.find(r=>r.address===F.getActiveNetworkTokenAddress());e&&(Ae.networkBalanceInUSD=e?bl.multiply(e.quantity.numeric,e.price).toString():"0")},isInsufficientNetworkTokenForGas(t,e){const r=e||"0";return bl.bigNumber(t).eq(0)?!0:bl.bigNumber(bl.bigNumber(r)).gt(t)},hasInsufficientGasFunds(){let t=!0;return oe.state.preferredAccountType===Ys.ACCOUNT_TYPES.SMART_ACCOUNT?t=!1:Ae.networkBalanceInUSD&&(t=this.isInsufficientNetworkTokenForGas(Ae.networkBalanceInUSD,Ae.gasPriceInUSD)),t},async sendNativeToken(t){He.pushTransactionStack({view:"Account",goBack:!1});const e=t.receiverAddress,r=oe.state.address,i=ut.parseUnits(t.sendTokenAmount.toString(),Number(t.decimals)),s="0x";try{await ut.sendTransaction({chainNamespace:"eip155",to:e,address:r,data:s,value:i??BigInt(0),gasPrice:t.gasPrice}),Ir.showSuccess("Transaction started"),lt.sendEvent({type:"track",event:"SEND_SUCCESS",properties:{isSmartAccount:oe.state.preferredAccountType===Ys.ACCOUNT_TYPES.SMART_ACCOUNT,token:this.state.token?.symbol||"",amount:t.sendTokenAmount,network:F.state.activeCaipNetwork?.caipNetworkId||""}}),this.resetSend()}catch(n){console.error("SendController:sendERC20Token - failed to send native token",n);const o=n instanceof Error?n.message:"Unknown error";lt.sendEvent({type:"track",event:"SEND_ERROR",properties:{message:o,isSmartAccount:oe.state.preferredAccountType===Ys.ACCOUNT_TYPES.SMART_ACCOUNT,token:this.state.token?.symbol||"",amount:t.sendTokenAmount,network:F.state.activeCaipNetwork?.caipNetworkId||""}}),Ir.showError("Something went wrong")}},async sendERC20Token(t){He.pushTransactionStack({view:"Account",goBack:!1});const e=ut.parseUnits(t.sendTokenAmount.toString(),Number(t.decimals));try{if(oe.state.address&&t.sendTokenAmount&&t.receiverAddress&&t.tokenAddress){const r=pe.getPlainAddress(t.tokenAddress);await ut.writeContract({fromAddress:oe.state.address,tokenAddress:r,args:[t.receiverAddress,e??BigInt(0)],method:"transfer",abi:jF.getERC20Abi(r),chainNamespace:"eip155"}),Ir.showSuccess("Transaction started"),this.resetSend()}}catch(r){console.error("SendController:sendERC20Token - failed to send erc20 token",r);const i=r instanceof Error?r.message:"Unknown error";lt.sendEvent({type:"track",event:"SEND_ERROR",properties:{message:i,isSmartAccount:oe.state.preferredAccountType===Ys.ACCOUNT_TYPES.SMART_ACCOUNT,token:this.state.token?.symbol||"",amount:t.sendTokenAmount,network:F.state.activeCaipNetwork?.caipNetworkId||""}}),Ir.showError("Something went wrong")}},sendSolanaToken(){if(!this.state.sendTokenAmount||!this.state.receiverAddress){Ir.showError("Please enter a valid amount and receiver address");return}He.pushTransactionStack({view:"Account",goBack:!1}),ut.sendTransaction({chainNamespace:"solana",to:this.state.receiverAddress,value:this.state.sendTokenAmount}).then(()=>{this.resetSend(),oe.fetchTokenBalance()}).catch(t=>{Ir.showError("Failed to send transaction. Please try again."),console.error("SendController:sendToken - failed to send solana transaction",t)})},resetSend(){Ae.token=void 0,Ae.sendTokenAmount=void 0,Ae.receiverAddress=void 0,Ae.receiverProfileImageUrl=void 0,Ae.receiverProfileName=void 0,Ae.loading=!1,Ae.tokenBalances=[]}},yf={currentTab:0,tokenBalance:[],smartAccountDeployed:!1,addressLabels:new Map,allAccounts:[],user:void 0},_l={caipNetwork:void 0,supportsAllNetworks:!0,smartAccountEnabledNetworks:[]},ee=Tt({chains:KF(),activeCaipAddress:void 0,activeChain:void 0,activeCaipNetwork:void 0,noAdapters:!1,universalAdapter:{networkControllerClient:void 0,connectionControllerClient:void 0},isSwitchingNamespace:!1}),F={state:ee,subscribe(t){return Fr(ee,()=>{t(ee)})},subscribeKey(t,e){return gi(ee,t,e)},subscribeChainProp(t,e,r){let i;return Fr(ee.chains,()=>{const s=r||ee.activeChain;if(s){const n=ee.chains.get(s)?.[t];i!==n&&(i=n,e(n))}})},initialize(t,e,r){const{chainId:i,namespace:s}=se.getActiveNetworkProps(),n=e?.find(c=>c.id.toString()===i?.toString()),a=t.find(c=>c?.namespace===s)||t?.[0],u=new Set([...e?.map(c=>c.chainNamespace)??[]]);(t?.length===0||!a)&&(ee.noAdapters=!0),ee.noAdapters||(ee.activeChain=a?.namespace,ee.activeCaipNetwork=n,this.setChainNetworkData(a?.namespace,{caipNetwork:n}),ee.activeChain&&Ps.set({activeChain:a?.namespace})),u.forEach(c=>{const l=e?.filter(h=>h.chainNamespace===c);F.state.chains.set(c,{namespace:c,networkState:Tt({..._l,caipNetwork:l?.[0]}),accountState:Tt(yf),caipNetworks:l??[],...r}),this.setRequestedCaipNetworks(l??[],c)})},removeAdapter(t){if(ee.activeChain===t){const e=Array.from(ee.chains.entries()).find(([r])=>r!==t);if(e){const r=e[1]?.caipNetworks?.[0];r&&this.setActiveCaipNetwork(r)}}ee.chains.delete(t)},addAdapter(t,{networkControllerClient:e,connectionControllerClient:r},i){ee.chains.set(t.namespace,{namespace:t.namespace,networkState:{..._l,caipNetwork:i[0]},accountState:yf,caipNetworks:i,connectionControllerClient:r,networkControllerClient:e}),this.setRequestedCaipNetworks(i?.filter(s=>s.chainNamespace===t.namespace)??[],t.namespace)},addNetwork(t){const e=ee.chains.get(t.chainNamespace);if(e){const r=[...e.caipNetworks||[]];e.caipNetworks?.find(i=>i.id===t.id)||r.push(t),ee.chains.set(t.chainNamespace,{...e,caipNetworks:r}),this.setRequestedCaipNetworks(r,t.chainNamespace)}},removeNetwork(t,e){const r=ee.chains.get(t);if(r){const i=ee.activeCaipNetwork?.id===e,s=[...r.caipNetworks?.filter(n=>n.id!==e)||[]];i&&r?.caipNetworks?.[0]&&this.setActiveCaipNetwork(r.caipNetworks[0]),ee.chains.set(t,{...r,caipNetworks:s}),this.setRequestedCaipNetworks(s||[],t)}},setAdapterNetworkState(t,e){const r=ee.chains.get(t);r&&(r.networkState={...r.networkState||_l,...e},ee.chains.set(t,r))},setChainAccountData(t,e,r=!0){if(!t)throw new Error("Chain is required to update chain account data");const i=ee.chains.get(t);if(i){const s={...i.accountState||yf,...e};ee.chains.set(t,{...i,accountState:s}),(ee.chains.size===1||ee.activeChain===t)&&(e.caipAddress&&(ee.activeCaipAddress=e.caipAddress),oe.replaceState(s))}},setChainNetworkData(t,e){if(!t)return;const r=ee.chains.get(t);if(r){const i={...r.networkState||_l,...e};ee.chains.set(t,{...r,networkState:i})}},setAccountProp(t,e,r,i=!0){this.setChainAccountData(r,{[t]:e},i),t==="status"&&e==="disconnected"&&r&&fe.removeConnectorId(r)},setActiveNamespace(t){ee.activeChain=t;const e=t?ee.chains.get(t):void 0,r=e?.networkState?.caipNetwork;r?.id&&t&&(ee.activeCaipAddress=e?.accountState?.caipAddress,ee.activeCaipNetwork=r,this.setChainNetworkData(t,{caipNetwork:r}),se.setActiveCaipNetworkId(r?.caipNetworkId),Ps.set({activeChain:t,selectedNetworkId:r?.caipNetworkId}))},setActiveCaipNetwork(t){if(!t)return;ee.activeChain!==t.chainNamespace&&this.setIsSwitchingNamespace(!0);const e=ee.chains.get(t.chainNamespace);ee.activeChain=t.chainNamespace,ee.activeCaipNetwork=t,this.setChainNetworkData(t.chainNamespace,{caipNetwork:t}),e?.accountState?.address?ee.activeCaipAddress=`${t.chainNamespace}:${t.id}:${e?.accountState?.address}`:ee.activeCaipAddress=void 0,this.setAccountProp("caipAddress",ee.activeCaipAddress,t.chainNamespace),e&&oe.replaceState(e.accountState),tw.resetSend(),Ps.set({activeChain:ee.activeChain,selectedNetworkId:ee.activeCaipNetwork?.caipNetworkId}),se.setActiveCaipNetworkId(t.caipNetworkId),!this.checkIfSupportedNetwork(t.chainNamespace)&&J.state.enableNetworkSwitch&&!J.state.allowUnsupportedChain&&!ut.state.wcBasic&&this.showUnsupportedChainUI()},addCaipNetwork(t){if(!t)return;const e=ee.chains.get(t.chainNamespace);e&&e?.caipNetworks?.push(t)},async switchActiveNamespace(t){if(!t)return;const e=t!==F.state.activeChain,r=F.getNetworkData(t)?.caipNetwork,i=F.getCaipNetworkByNamespace(t,r?.id);e&&i&&await F.switchActiveNetwork(i)},async switchActiveNetwork(t){!F.state.chains.get(F.state.activeChain)?.caipNetworks?.some(s=>s.id===ee.activeCaipNetwork?.id)&&He.goBack();const i=this.getNetworkControllerClient(t.chainNamespace);i&&(await i.switchCaipNetwork(t),lt.sendEvent({type:"track",event:"SWITCH_NETWORK",properties:{network:t.caipNetworkId}}))},getNetworkControllerClient(t){const e=t||ee.activeChain,r=ee.chains.get(e);if(!r)throw new Error("Chain adapter not found");if(!r.networkControllerClient)throw new Error("NetworkController client not set");return r.networkControllerClient},getConnectionControllerClient(t){const e=t||ee.activeChain;if(!e)throw new Error("Chain is required to get connection controller client");const r=ee.chains.get(e);if(!r?.connectionControllerClient)throw new Error("ConnectionController client not set");return r.connectionControllerClient},getAccountProp(t,e){let r=ee.activeChain;if(e&&(r=e),!r)return;const i=ee.chains.get(r)?.accountState;if(i)return i[t]},getNetworkProp(t,e){const r=ee.chains.get(e)?.networkState;if(r)return r[t]},getRequestedCaipNetworks(t){const e=ee.chains.get(t),{approvedCaipNetworkIds:r=[],requestedCaipNetworks:i=[]}=e?.networkState||{};return pe.sortRequestedNetworks(r,i)},getAllRequestedCaipNetworks(){const t=[];return ee.chains.forEach(e=>{const r=this.getRequestedCaipNetworks(e.namespace);t.push(...r)}),t},setRequestedCaipNetworks(t,e){this.setAdapterNetworkState(e,{requestedCaipNetworks:t})},getAllApprovedCaipNetworkIds(){const t=[];return ee.chains.forEach(e=>{const r=this.getApprovedCaipNetworkIds(e.namespace);t.push(...r)}),t},getActiveCaipNetwork(){return ee.activeCaipNetwork},getActiveCaipAddress(){return ee.activeCaipAddress},getApprovedCaipNetworkIds(t){return ee.chains.get(t)?.networkState?.approvedCaipNetworkIds||[]},async setApprovedCaipNetworksData(t){const r=await this.getNetworkControllerClient()?.getApprovedCaipNetworksData();this.setAdapterNetworkState(t,{approvedCaipNetworkIds:r?.approvedCaipNetworkIds,supportsAllNetworks:r?.supportsAllNetworks})},checkIfSupportedNetwork(t,e){const r=e||ee.activeCaipNetwork,i=this.getRequestedCaipNetworks(t);return i.length?i?.some(s=>s.id===r?.id):!0},checkIfSupportedChainId(t){return ee.activeChain?this.getRequestedCaipNetworks(ee.activeChain)?.some(r=>r.id===t):!0},setSmartAccountEnabledNetworks(t,e){this.setAdapterNetworkState(e,{smartAccountEnabledNetworks:t})},checkIfSmartAccountEnabled(){const t=L3.caipNetworkIdToNumber(ee.activeCaipNetwork?.caipNetworkId),e=ee.activeChain;return!e||!t?!1:!!this.getNetworkProp("smartAccountEnabledNetworks",e)?.includes(Number(t))},getActiveNetworkTokenAddress(){const t=ee.activeCaipNetwork?.chainNamespace||"eip155",e=ee.activeCaipNetwork?.id||1,r=Jr.NATIVE_TOKEN_ADDRESS[t];return`${t}:${e}:${r}`},showUnsupportedChainUI(){Qt.open({view:"UnsupportedChain"})},checkIfNamesSupported(){const t=ee.activeCaipNetwork;return!!(t?.chainNamespace&&Jr.NAMES_SUPPORTED_CHAIN_NAMESPACES.includes(t.chainNamespace))},resetNetwork(t){this.setAdapterNetworkState(t,{approvedCaipNetworkIds:void 0,supportsAllNetworks:!0,smartAccountEnabledNetworks:[]})},resetAccount(t){const e=t;if(!e)throw new Error("Chain is required to set account prop");ee.activeCaipAddress=void 0,this.setChainAccountData(e,{smartAccountDeployed:!1,currentTab:0,caipAddress:void 0,address:void 0,balance:void 0,balanceSymbol:void 0,profileName:void 0,profileImage:void 0,addressExplorerUrl:void 0,tokenBalance:[],connectedWalletInfo:void 0,preferredAccountType:void 0,socialProvider:void 0,socialWindow:void 0,farcasterUrl:void 0,allAccounts:[],user:void 0,status:"disconnected"}),fe.removeConnectorId(e)},async disconnect(t){const e=rj(t);try{tw.resetSend();const r=await Promise.allSettled(e.map(async([s,n])=>{try{const{caipAddress:o}=this.getAccountData(s)||{};o&&n.connectionControllerClient?.disconnect&&await n.connectionControllerClient.disconnect(s),this.resetAccount(s),this.resetNetwork(s)}catch(o){throw new Error(`Failed to disconnect chain ${s}: ${o.message}`)}}));ut.resetWcConnection();const i=r.filter(s=>s.status==="rejected");if(i.length>0)throw new Error(i.map(s=>s.reason.message).join(", "));se.deleteConnectedSocialProvider(),t?fe.removeConnectorId(t):fe.resetConnectorIds(),lt.sendEvent({type:"track",event:"DISCONNECT_SUCCESS",properties:{namespace:t||"all"}})}catch(r){console.error(r.message||"Failed to disconnect chains"),lt.sendEvent({type:"track",event:"DISCONNECT_ERROR",properties:{message:r.message||"Failed to disconnect chains"}})}},setIsSwitchingNamespace(t){ee.isSwitchingNamespace=t},getFirstCaipNetworkSupportsAuthConnector(){const t=[];let e;if(ee.chains.forEach(r=>{ne.AUTH_CONNECTOR_SUPPORTED_CHAINS.find(i=>i===r.namespace)&&r.namespace&&t.push(r.namespace)}),t.length>0){const r=t[0];return e=r?ee.chains.get(r)?.caipNetworks?.[0]:void 0,e}},getAccountData(t){return t?F.state.chains.get(t)?.accountState:oe.state},getNetworkData(t){const e=t||ee.activeChain;if(e)return F.state.chains.get(e)?.networkState},getCaipNetworkByNamespace(t,e){if(!t)return;const r=F.state.chains.get(t),i=r?.caipNetworks?.find(s=>s.id===e);return i||r?.networkState?.caipNetwork||r?.caipNetworks?.[0]},getRequestedCaipNetworkIds(){const t=fe.state.filterByNamespace;return(t?[ee.chains.get(t)]:Array.from(ee.chains.values())).flatMap(r=>r?.caipNetworks||[]).map(r=>r.caipNetworkId)}},tq={purchaseCurrencies:[{id:"2b92315d-eab7-5bef-84fa-089a131333f5",name:"USD Coin",symbol:"USDC",networks:[{name:"ethereum-mainnet",display_name:"Ethereum",chain_id:"1",contract_address:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},{name:"polygon-mainnet",display_name:"Polygon",chain_id:"137",contract_address:"0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174"}]},{id:"2b92315d-eab7-5bef-84fa-089a131333f5",name:"Ether",symbol:"ETH",networks:[{name:"ethereum-mainnet",display_name:"Ethereum",chain_id:"1",contract_address:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},{name:"polygon-mainnet",display_name:"Polygon",chain_id:"137",contract_address:"0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174"}]}],paymentCurrencies:[{id:"USD",payment_method_limits:[{id:"card",min:"10.00",max:"7500.00"},{id:"ach_bank_account",min:"10.00",max:"25000.00"}]},{id:"EUR",payment_method_limits:[{id:"card",min:"10.00",max:"7500.00"},{id:"ach_bank_account",min:"10.00",max:"25000.00"}]}]},Q3=pe.getBlockchainApiUrl(),ii=Tt({clientId:null,api:new jh({baseUrl:Q3,clientId:null}),supportedChains:{http:[],ws:[]}}),ue={state:ii,async get(t){const{st:e,sv:r}=ue.getSdkProperties(),i=J.state.projectId,s={...t.params||{},st:e,sv:r,projectId:i};return ii.api.get({...t,params:s})},getSdkProperties(){const{sdkType:t,sdkVersion:e}=J.state;return{st:t||"unknown",sv:e||"unknown"}},async isNetworkSupported(t){if(!t)return!1;try{ii.supportedChains.http.length||await ue.getSupportedNetworks()}catch{return!1}return ii.supportedChains.http.includes(t)},async getSupportedNetworks(){const t=await ue.get({path:"v1/supported-chains"});return ii.supportedChains=t,t},async fetchIdentity({address:t,caipNetworkId:e}){if(!await ue.isNetworkSupported(e))return{avatar:"",name:""};const i=se.getIdentityFromCacheForAddress(t);if(i)return i;const s=await ue.get({path:`/v1/identity/${t}`,params:{sender:F.state.activeCaipAddress?pe.getPlainAddress(F.state.activeCaipAddress):void 0}});return se.updateIdentityCache({address:t,identity:s,timestamp:Date.now()}),s},async fetchTransactions({account:t,cursor:e,onramp:r,signal:i,cache:s,chainId:n}){return await ue.isNetworkSupported(F.state.activeCaipNetwork?.caipNetworkId)?ue.get({path:`/v1/account/${t}/history`,params:{cursor:e,onramp:r,chainId:n},signal:i,cache:s}):{data:[],next:void 0}},async fetchSwapQuote({amount:t,userAddress:e,from:r,to:i,gasPrice:s}){return await ue.isNetworkSupported(F.state.activeCaipNetwork?.caipNetworkId)?ue.get({path:"/v1/convert/quotes",headers:{"Content-Type":"application/json"},params:{amount:t,userAddress:e,from:r,to:i,gasPrice:s}}):{quotes:[]}},async fetchSwapTokens({chainId:t}){return await ue.isNetworkSupported(F.state.activeCaipNetwork?.caipNetworkId)?ue.get({path:"/v1/convert/tokens",params:{chainId:t}}):{tokens:[]}},async fetchTokenPrice({addresses:t}){return await ue.isNetworkSupported(F.state.activeCaipNetwork?.caipNetworkId)?ii.api.post({path:"/v1/fungible/price",body:{currency:"usd",addresses:t,projectId:J.state.projectId},headers:{"Content-Type":"application/json"}}):{fungibles:[]}},async fetchSwapAllowance({tokenAddress:t,userAddress:e}){return await ue.isNetworkSupported(F.state.activeCaipNetwork?.caipNetworkId)?ue.get({path:"/v1/convert/allowance",params:{tokenAddress:t,userAddress:e},headers:{"Content-Type":"application/json"}}):{allowance:"0"}},async fetchGasPrice({chainId:t}){const{st:e,sv:r}=ue.getSdkProperties();if(!await ue.isNetworkSupported(F.state.activeCaipNetwork?.caipNetworkId))throw new Error("Network not supported for Gas Price");return ue.get({path:"/v1/convert/gas-price",headers:{"Content-Type":"application/json"},params:{chainId:t,st:e,sv:r}})},async generateSwapCalldata({amount:t,from:e,to:r,userAddress:i,disableEstimate:s}){if(!await ue.isNetworkSupported(F.state.activeCaipNetwork?.caipNetworkId))throw new Error("Network not supported for Swaps");return ii.api.post({path:"/v1/convert/build-transaction",headers:{"Content-Type":"application/json"},body:{amount:t,eip155:{slippage:Jr.CONVERT_SLIPPAGE_TOLERANCE},projectId:J.state.projectId,from:e,to:r,userAddress:i,disableEstimate:s}})},async generateApproveCalldata({from:t,to:e,userAddress:r}){const{st:i,sv:s}=ue.getSdkProperties();if(!await ue.isNetworkSupported(F.state.activeCaipNetwork?.caipNetworkId))throw new Error("Network not supported for Swaps");return ue.get({path:"/v1/convert/build-approve",headers:{"Content-Type":"application/json"},params:{userAddress:r,from:t,to:e,st:i,sv:s}})},async getBalance(t,e,r){const{st:i,sv:s}=ue.getSdkProperties();if(!await ue.isNetworkSupported(F.state.activeCaipNetwork?.caipNetworkId))return Ir.showError("Token Balance Unavailable"),{balances:[]};const o=`${e}:${t}`,a=se.getBalanceCacheForCaipAddress(o);if(a)return a;const u=await ue.get({path:`/v1/account/${t}/balance`,params:{currency:"usd",chainId:e,forceUpdate:r,st:i,sv:s}});return se.updateBalanceCache({caipAddress:o,balance:u,timestamp:Date.now()}),u},async lookupEnsName(t){return await ue.isNetworkSupported(F.state.activeCaipNetwork?.caipNetworkId)?ue.get({path:`/v1/profile/account/${t}`,params:{apiVersion:"2"}}):{addresses:{},attributes:[]}},async reverseLookupEnsName({address:t}){return await ue.isNetworkSupported(F.state.activeCaipNetwork?.caipNetworkId)?ue.get({path:`/v1/profile/reverse/${t}`,params:{sender:oe.state.address,apiVersion:"2"}}):[]},async getEnsNameSuggestions(t){return await ue.isNetworkSupported(F.state.activeCaipNetwork?.caipNetworkId)?ue.get({path:`/v1/profile/suggestions/${t}`,params:{zone:"reown.id"}}):{suggestions:[]}},async registerEnsName({coinType:t,address:e,message:r,signature:i}){return await ue.isNetworkSupported(F.state.activeCaipNetwork?.caipNetworkId)?ii.api.post({path:"/v1/profile/account",body:{coin_type:t,address:e,message:r,signature:i},headers:{"Content-Type":"application/json"}}):{success:!1}},async generateOnRampURL({destinationWallets:t,partnerUserId:e,defaultNetwork:r,purchaseAmount:i,paymentAmount:s}){return await ue.isNetworkSupported(F.state.activeCaipNetwork?.caipNetworkId)?(await ii.api.post({path:"/v1/generators/onrampurl",params:{projectId:J.state.projectId},body:{destinationWallets:t,defaultNetwork:r,partnerUserId:e,defaultExperience:"buy",presetCryptoAmount:i,presetFiatAmount:s}})).url:""},async getOnrampOptions(){if(!await ue.isNetworkSupported(F.state.activeCaipNetwork?.caipNetworkId))return{paymentCurrencies:[],purchaseCurrencies:[]};try{return await ue.get({path:"/v1/onramp/options"})}catch{return tq}},async getOnrampQuote({purchaseCurrency:t,paymentCurrency:e,amount:r,network:i}){try{return await ue.isNetworkSupported(F.state.activeCaipNetwork?.caipNetworkId)?await ii.api.post({path:"/v1/onramp/quote",params:{projectId:J.state.projectId},body:{purchaseCurrency:t,paymentCurrency:e,amount:r,network:i}}):null}catch{return{coinbaseFee:{amount:r,currency:e.id},networkFee:{amount:r,currency:e.id},paymentSubtotal:{amount:r,currency:e.id},paymentTotal:{amount:r,currency:e.id},purchaseAmount:{amount:r,currency:e.id},quoteId:"mocked-quote-id"}}},async getSmartSessions(t){return await ue.isNetworkSupported(F.state.activeCaipNetwork?.caipNetworkId)?ue.get({path:`/v1/sessions/${t}`}):[]},async revokeSmartSession(t,e,r){return await ue.isNetworkSupported(F.state.activeCaipNetwork?.caipNetworkId)?ii.api.post({path:`/v1/sessions/${t}/revoke`,params:{projectId:J.state.projectId},body:{pci:e,signature:r}}):{success:!1}},setClientId(t){ii.clientId=t,ii.api=new jh({baseUrl:Q3,clientId:t})}},ts=Tt({currentTab:0,tokenBalance:[],smartAccountDeployed:!1,addressLabels:new Map,allAccounts:[]}),oe={state:ts,replaceState(t){t&&Object.assign(ts,qn(t))},subscribe(t){return F.subscribeChainProp("accountState",e=>{if(e)return t(e)})},subscribeKey(t,e,r){let i;return F.subscribeChainProp("accountState",s=>{if(s){const n=s[t];i!==n&&(i=n,e(n))}},r)},setStatus(t,e){F.setAccountProp("status",t,e)},getCaipAddress(t){return F.getAccountProp("caipAddress",t)},setCaipAddress(t,e){const r=t?pe.getPlainAddress(t):void 0;e===F.state.activeChain&&(F.state.activeCaipAddress=t),F.setAccountProp("caipAddress",t,e),F.setAccountProp("address",r,e)},setBalance(t,e,r){F.setAccountProp("balance",t,r),F.setAccountProp("balanceSymbol",e,r)},setProfileName(t,e){F.setAccountProp("profileName",t,e)},setProfileImage(t,e){F.setAccountProp("profileImage",t,e)},setUser(t,e){F.setAccountProp("user",t,e)},setAddressExplorerUrl(t,e){F.setAccountProp("addressExplorerUrl",t,e)},setSmartAccountDeployed(t,e){F.setAccountProp("smartAccountDeployed",t,e)},setCurrentTab(t){F.setAccountProp("currentTab",t,F.state.activeChain)},setTokenBalance(t,e){t&&F.setAccountProp("tokenBalance",t,e)},setShouldUpdateToAddress(t,e){F.setAccountProp("shouldUpdateToAddress",t,e)},setAllAccounts(t,e){F.setAccountProp("allAccounts",t,e)},addAddressLabel(t,e,r){const i=F.getAccountProp("addressLabels",r)||new Map;i.set(t,e),F.setAccountProp("addressLabels",i,r)},removeAddressLabel(t,e){const r=F.getAccountProp("addressLabels",e)||new Map;r.delete(t),F.setAccountProp("addressLabels",r,e)},setConnectedWalletInfo(t,e){F.setAccountProp("connectedWalletInfo",t,e,!1)},setPreferredAccountType(t,e){F.setAccountProp("preferredAccountType",t,e)},setSocialProvider(t,e){t&&F.setAccountProp("socialProvider",t,e)},setSocialWindow(t,e){F.setAccountProp("socialWindow",t?qn(t):void 0,e)},setFarcasterUrl(t,e){F.setAccountProp("farcasterUrl",t,e)},async fetchTokenBalance(t){ts.balanceLoading=!0;const e=F.state.activeCaipNetwork?.caipNetworkId,r=F.state.activeCaipNetwork?.chainNamespace,i=F.state.activeCaipAddress,s=i?pe.getPlainAddress(i):void 0;if(ts.lastRetry&&!pe.isAllowedRetry(ts.lastRetry,30*Jr.ONE_SEC_MS))return ts.balanceLoading=!1,[];try{if(s&&e&&r){const o=(await ue.getBalance(s,e)).balances.filter(a=>a.quantity.decimals!=="0");return this.setTokenBalance(o,r),ts.lastRetry=void 0,ts.balanceLoading=!1,o}}catch(n){ts.lastRetry=Date.now(),t?.(n),Ir.showError("Token Balance Unavailable")}finally{ts.balanceLoading=!1}return[]},resetAccount(t){F.resetAccount(t)}},zr=Tt({loading:!1,loadingNamespaceMap:new Map,open:!1,shake:!1,namespace:void 0}),Qt={state:zr,subscribe(t){return Fr(zr,()=>t(zr))},subscribeKey(t,e){return gi(zr,t,e)},async open(t){const e=oe.state.status==="connected";ut.state.wcBasic?be.prefetch({fetchNetworkImages:!1,fetchConnectorImages:!1}):await be.prefetch({fetchConnectorImages:!e,fetchFeaturedWallets:!e,fetchRecommendedWallets:!e}),t?.namespace?(await F.switchActiveNamespace(t.namespace),Qt.setLoading(!0,t.namespace)):Qt.setLoading(!0),fe.setFilterByNamespace(t?.namespace);const r=F.getAccountData(t?.namespace)?.caipAddress;F.state.noAdapters&&!r?pe.isMobile()?He.reset("AllWallets"):He.reset("ConnectingWalletConnectBasic"):t?.view?He.reset(t.view):r?He.reset("Account"):He.reset("Connect"),zr.open=!0,Ps.set({open:!0}),lt.sendEvent({type:"track",event:"MODAL_OPEN",properties:{connected:!!r}})},close(){const t=J.state.enableEmbedded,e=!!F.state.activeCaipAddress;zr.open&<.sendEvent({type:"track",event:"MODAL_CLOSE",properties:{connected:e}}),zr.open=!1,Qt.clearLoading(),t?e?He.replace("Account"):He.push("Connect"):Ps.set({open:!1}),ut.resetUri()},setLoading(t,e){e&&zr.loadingNamespaceMap.set(e,t),zr.loading=t,Ps.set({loading:t})},clearLoading(){zr.loadingNamespaceMap.clear(),zr.loading=!1},shake(){zr.shake||(zr.shake=!0,setTimeout(()=>{zr.shake=!1},500))}},rw=2147483648,rq={convertEVMChainIdToCoinType(t){if(t>=rw)throw new Error("Invalid chainId");return(rw|t)>>>0}},_i=Tt({suggestions:[],loading:!1}),X3={state:_i,subscribe(t){return Fr(_i,()=>t(_i))},subscribeKey(t,e){return gi(_i,t,e)},async resolveName(t){try{return await ue.lookupEnsName(t)}catch(e){const r=e;throw new Error(r?.reasons?.[0]?.description||"Error resolving name")}},async isNameRegistered(t){try{return await ue.lookupEnsName(t),!0}catch{return!1}},async getSuggestions(t){try{_i.loading=!0,_i.suggestions=[];const e=await ue.getEnsNameSuggestions(t);return _i.suggestions=e.suggestions.map(r=>({...r,name:r.name}))||[],_i.suggestions}catch(e){const r=this.parseEnsApiError(e,"Error fetching name suggestions");throw new Error(r)}finally{_i.loading=!1}},async getNamesForAddress(t){try{if(!F.state.activeCaipNetwork)return[];const r=se.getEnsFromCacheForAddress(t);if(r)return r;const i=await ue.reverseLookupEnsName({address:t});return se.updateEnsCache({address:t,ens:i,timestamp:Date.now()}),i}catch(e){const r=this.parseEnsApiError(e,"Error fetching names for address");throw new Error(r)}},async registerName(t){const e=F.state.activeCaipNetwork;if(!e)throw new Error("Network not found");const r=oe.state.address,i=fe.getAuthConnector();if(!r||!i)throw new Error("Address or auth connector not found");_i.loading=!0;try{const s=JSON.stringify({name:t,attributes:{},timestamp:Math.floor(Date.now()/1e3)});He.pushTransactionStack({view:"RegisterAccountNameSuccess",goBack:!1,replace:!0,onCancel(){_i.loading=!1}});const n=await ut.signMessage(s),o=e.id;if(!o)throw new Error("Network not found");const a=rq.convertEVMChainIdToCoinType(Number(o));await ue.registerEnsName({coinType:a,address:r,signature:n,message:s}),oe.setProfileName(t,e.chainNamespace),He.replace("RegisterAccountNameSuccess")}catch(s){const n=this.parseEnsApiError(s,`Error registering name ${t}`);throw He.replace("RegisterAccountName"),new Error(n)}finally{_i.loading=!1}},validateName(t){return/^[a-zA-Z0-9-]{4,}$/u.test(t)},parseEnsApiError(t,e){return t?.reasons?.[0]?.description||e}};function du(t,{strict:e=!0}={}){return!t||typeof t!="string"?!1:e?/^0x[0-9a-fA-F]*$/.test(t):t.startsWith("0x")}function iw(t){return du(t,{strict:!1})?Math.ceil((t.length-2)/2):t.length}const Z3="2.23.2";let wf={getDocsUrl:({docsBaseUrl:t,docsPath:e="",docsSlug:r})=>e?`${t??"https://viem.sh"}${e}${r?`#${r}`:""}`:void 0,version:`viem@${Z3}`};class Bn extends Error{constructor(e,r={}){const i=r.cause instanceof Bn?r.cause.details:r.cause?.message?r.cause.message:r.details,s=r.cause instanceof Bn&&r.cause.docsPath||r.docsPath,n=wf.getDocsUrl?.({...r,docsPath:s}),o=[e||"An error occurred.","",...r.metaMessages?[...r.metaMessages,""]:[],...n?[`Docs: ${n}`]:[],...i?[`Details: ${i}`]:[],...wf.version?[`Version: ${wf.version}`]:[]].join(`
|
|
17
|
+
`);super(o,r.cause?{cause:r.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=i,this.docsPath=s,this.metaMessages=r.metaMessages,this.name=r.name??this.name,this.shortMessage=e,this.version=Z3}walk(e){return e_(this,e)}}function e_(t,e){return e?.(t)?t:t&&typeof t=="object"&&"cause"in t&&t.cause!==void 0?e_(t.cause,e):e?null:t}class t_ extends Bn{constructor({size:e,targetSize:r,type:i}){super(`${i.charAt(0).toUpperCase()}${i.slice(1).toLowerCase()} size (${e}) exceeds padding size (${r}).`,{name:"SizeExceedsPaddingSizeError"})}}function $a(t,{dir:e,size:r=32}={}){return typeof t=="string"?iq(t,{dir:e,size:r}):sq(t,{dir:e,size:r})}function iq(t,{dir:e,size:r=32}={}){if(r===null)return t;const i=t.replace("0x","");if(i.length>r*2)throw new t_({size:Math.ceil(i.length/2),targetSize:r,type:"hex"});return`0x${i[e==="right"?"padEnd":"padStart"](r*2,"0")}`}function sq(t,{dir:e,size:r=32}={}){if(r===null)return t;if(t.length>r)throw new t_({size:t.length,targetSize:r,type:"bytes"});const i=new Uint8Array(r);for(let s=0;s<r;s++){const n=e==="right";i[n?s:r-s-1]=t[n?s:t.length-s-1]}return i}class nq extends Bn{constructor({max:e,min:r,signed:i,size:s,value:n}){super(`Number "${n}" is not in safe ${s?`${s*8}-bit ${i?"signed":"unsigned"} `:""}integer range ${e?`(${r} to ${e})`:`(above ${r})`}`,{name:"IntegerOutOfRangeError"})}}class oq extends Bn{constructor({givenSize:e,maxSize:r}){super(`Size cannot exceed ${r} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function xa(t,{size:e}){if(iw(t)>e)throw new oq({givenSize:iw(t),maxSize:e})}function $p(t,e={}){const{signed:r}=e;e.size&&xa(t,{size:e.size});const i=BigInt(t);if(!r)return i;const s=(t.length-2)/2,n=(1n<<BigInt(s)*8n-1n)-1n;return i<=n?i:i-BigInt(`0x${"f".padStart(s*2,"f")}`)-1n}function aq(t,e={}){return Number($p(t,e))}const cq=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function xp(t,e={}){return typeof t=="number"||typeof t=="bigint"?i_(t,e):typeof t=="string"?hq(t,e):typeof t=="boolean"?uq(t,e):r_(t,e)}function uq(t,e={}){const r=`0x${Number(t)}`;return typeof e.size=="number"?(xa(r,{size:e.size}),$a(r,{size:e.size})):r}function r_(t,e={}){let r="";for(let s=0;s<t.length;s++)r+=cq[t[s]];const i=`0x${r}`;return typeof e.size=="number"?(xa(i,{size:e.size}),$a(i,{dir:"right",size:e.size})):i}function i_(t,e={}){const{signed:r,size:i}=e,s=BigInt(t);let n;i?r?n=(1n<<BigInt(i)*8n-1n)-1n:n=2n**(BigInt(i)*8n)-1n:typeof t=="number"&&(n=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof n=="bigint"&&r?-n-1n:0;if(n&&s>n||s<o){const u=typeof t=="bigint"?"n":"";throw new nq({max:n?`${n}${u}`:void 0,min:`${o}${u}`,signed:r,size:i,value:`${t}${u}`})}const a=`0x${(r&&s<0?(1n<<BigInt(i*8))+BigInt(s):s).toString(16)}`;return i?$a(a,{size:i}):a}const lq=new TextEncoder;function hq(t,e={}){const r=lq.encode(t);return r_(r,e)}const dq=new TextEncoder;function fq(t,e={}){return typeof t=="number"||typeof t=="bigint"?gq(t,e):typeof t=="boolean"?pq(t,e):du(t)?s_(t,e):n_(t,e)}function pq(t,e={}){const r=new Uint8Array(1);return r[0]=Number(t),typeof e.size=="number"?(xa(r,{size:e.size}),$a(r,{size:e.size})):r}const Is={zero:48,nine:57,A:65,F:70,a:97,f:102};function sw(t){if(t>=Is.zero&&t<=Is.nine)return t-Is.zero;if(t>=Is.A&&t<=Is.F)return t-(Is.A-10);if(t>=Is.a&&t<=Is.f)return t-(Is.a-10)}function s_(t,e={}){let r=t;e.size&&(xa(r,{size:e.size}),r=$a(r,{dir:"right",size:e.size}));let i=r.slice(2);i.length%2&&(i=`0${i}`);const s=i.length/2,n=new Uint8Array(s);for(let o=0,a=0;o<s;o++){const u=sw(i.charCodeAt(a++)),c=sw(i.charCodeAt(a++));if(u===void 0||c===void 0)throw new Bn(`Invalid byte sequence ("${i[a-2]}${i[a-1]}" in "${i}").`);n[o]=u*16+c}return n}function gq(t,e){const r=i_(t,e);return s_(r)}function n_(t,e={}){const r=dq.encode(t);return typeof e.size=="number"?(xa(r,{size:e.size}),$a(r,{dir:"right",size:e.size})):r}function lh(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function bq(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function qh(t,...e){if(!bq(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 uZ(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");lh(t.outputLen),lh(t.blockLen)}function nw(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 mq(t,e){qh(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}const El=BigInt(2**32-1),ow=BigInt(32);function yq(t,e=!1){return e?{h:Number(t&El),l:Number(t>>ow&El)}:{h:Number(t>>ow&El)|0,l:Number(t&El)|0}}function wq(t,e=!1){let r=new Uint32Array(t.length),i=new Uint32Array(t.length);for(let s=0;s<t.length;s++){const{h:n,l:o}=yq(t[s],e);[r[s],i[s]]=[n,o]}return[r,i]}const vq=(t,e,r)=>t<<r|e>>>32-r,_q=(t,e,r)=>e<<r|t>>>32-r,Eq=(t,e,r)=>e<<r-32|t>>>64-r,Iq=(t,e,r)=>t<<r-32|e>>>64-r,Co=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function Aq(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function lZ(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function hZ(t,e){return t<<32-e|t>>>e}const aw=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Sq(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function cw(t){for(let e=0;e<t.length;e++)t[e]=Sq(t[e])}function Cq(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function o_(t){return typeof t=="string"&&(t=Cq(t)),qh(t),t}function dZ(...t){let e=0;for(let i=0;i<t.length;i++){const s=t[i];qh(s),e+=s.length}const r=new Uint8Array(e);for(let i=0,s=0;i<t.length;i++){const n=t[i];r.set(n,s),s+=n.length}return r}class $q{clone(){return this._cloneInto()}}function xq(t){const e=i=>t().update(o_(i)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function fZ(t=32){if(Co&&typeof Co.getRandomValues=="function")return Co.getRandomValues(new Uint8Array(t));if(Co&&typeof Co.randomBytes=="function")return Co.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}const a_=[],c_=[],u_=[],Pq=BigInt(0),lc=BigInt(1),Nq=BigInt(2),Oq=BigInt(7),Tq=BigInt(256),Dq=BigInt(113);for(let t=0,e=lc,r=1,i=0;t<24;t++){[r,i]=[i,(2*r+3*i)%5],a_.push(2*(5*i+r)),c_.push((t+1)*(t+2)/2%64);let s=Pq;for(let n=0;n<7;n++)e=(e<<lc^(e>>Oq)*Dq)%Tq,e&Nq&&(s^=lc<<(lc<<BigInt(n))-lc);u_.push(s)}const[Rq,Mq]=wq(u_,!0),uw=(t,e,r)=>r>32?Eq(t,e,r):vq(t,e,r),lw=(t,e,r)=>r>32?Iq(t,e,r):_q(t,e,r);function kq(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,u=(o+2)%10,c=r[u],l=r[u+1],h=uw(c,l,1)^r[a],f=lw(c,l,1)^r[a+1];for(let m=0;m<50;m+=10)t[o+m]^=h,t[o+m+1]^=f}let s=t[2],n=t[3];for(let o=0;o<24;o++){const a=c_[o],u=uw(s,n,a),c=lw(s,n,a),l=a_[o];s=t[l],n=t[l+1],t[l]=u,t[l+1]=c}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]^=Rq[i],t[1]^=Mq[i]}r.fill(0)}class Dg extends $q{constructor(e,r,i,s=!1,n=24){if(super(),this.blockLen=e,this.suffix=r,this.outputLen=i,this.enableXOF=s,this.rounds=n,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,lh(i),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=Aq(this.state)}keccak(){aw||cw(this.state32),kq(this.state32,this.rounds),aw||cw(this.state32),this.posOut=0,this.pos=0}update(e){nw(this);const{blockLen:r,state:i}=this;e=o_(e);const s=e.length;for(let n=0;n<s;){const o=Math.min(r-this.pos,s-n);for(let a=0;a<o;a++)i[this.pos++]^=e[n++];this.pos===r&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:r,pos:i,blockLen:s}=this;e[i]^=r,(r&128)!==0&&i===s-1&&this.keccak(),e[s-1]^=128,this.keccak()}writeInto(e){nw(this,!1),qh(e),this.finish();const r=this.state,{blockLen:i}=this;for(let s=0,n=e.length;s<n;){this.posOut>=i&&this.keccak();const o=Math.min(i-this.posOut,n-s);e.set(r.subarray(this.posOut,this.posOut+o),s),this.posOut+=o,s+=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 lh(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(mq(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,this.state.fill(0)}_cloneInto(e){const{blockLen:r,suffix:i,outputLen:s,rounds:n,enableXOF:o}=this;return e||(e=new Dg(r,i,s,o,n)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=n,e.suffix=i,e.outputLen=s,e.enableXOF=o,e.destroyed=this.destroyed,e}}const Uq=(t,e,r)=>xq(()=>new Dg(e,t,r)),Lq=Uq(1,136,256/8);function l_(t,e){const r=e||"hex",i=Lq(du(t,{strict:!1})?fq(t):t);return r==="bytes"?i:xp(i)}class Fq 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 vf=new Fq(8192);function jq(t,e){if(vf.has(`${t}.${e}`))return vf.get(`${t}.${e}`);const r=t.substring(2).toLowerCase(),i=l_(n_(r),"bytes"),s=r.split("");for(let o=0;o<40;o+=2)i[o>>1]>>4>=8&&s[o]&&(s[o]=s[o].toUpperCase()),(i[o>>1]&15)>=8&&s[o+1]&&(s[o+1]=s[o+1].toUpperCase());const n=`0x${s.join("")}`;return vf.set(`${t}.${e}`,n),n}function qq(t){const e=l_(`0x${t.substring(4)}`).substring(26);return jq(`0x${e}`)}async function Bq({hash:t,signature:e}){const r=du(t)?t:xp(t),{secp256k1:i}=await Jl(async()=>{const{secp256k1:o}=await import("./secp256k1-64NdIXXC.js");return{secp256k1:o}},__vite__mapDeps([11,1,2,3,4,5,6,7,8,9,10]));return`0x${(()=>{if(typeof e=="object"&&"r"in e&&"s"in e){const{r:c,s:l,v:h,yParity:f}=e,m=Number(f??h),g=hw(m);return new i.Signature($p(c),$p(l)).addRecoveryBit(g)}const o=du(e)?e:xp(e),a=aq(`0x${o.slice(130)}`),u=hw(a);return i.Signature.fromCompact(o.substring(2,130)).addRecoveryBit(u)})().recoverPublicKey(r.substring(2)).toHex(!1)}`}function hw(t){if(t===0||t===1)return t;if(t===27)return 0;if(t===28)return 1;throw new Error("Invalid yParityOrV value")}async function zq({hash:t,signature:e}){return qq(await Bq({hash:t,signature:e}))}var Hq={};const Vq=":";function ia(t){const[e,r]=t.split(Vq);return{namespace:e,reference:r}}function h_(t,e){return t.includes(":")?[t]:e.chains||[]}const Kq="ReactNative",hi={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},Wq="js";function hh(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function hn(){return!Qr.getDocument()&&!!Qr.getNavigator()&&navigator.product===Kq}function Gq(){return hn()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="android"}function Yq(){return hn()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="ios"}function Du(){return!hh()&&!!Qr.getNavigator()&&!!Qr.getDocument()}function Ru(){return hn()?hi.reactNative:hh()?hi.node:Du()?hi.browser:hi.unknown}function dw(){var t;try{return hn()&&typeof global<"u"&&typeof(global==null?void 0:global.Application)<"u"?(t=global.Application)==null?void 0:t.applicationId:void 0}catch{return}}function Jq(t,e){const r=new URLSearchParams(t);for(const i of Object.keys(e).sort())if(e.hasOwnProperty(i)){const s=e[i];s!==void 0&&r.set(i,s)}return r.toString()}function d_(){return M1.getWindowMetadata()||{name:"",description:"",url:"",icons:[""]}}function Qq(){if(Ru()===hi.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=D1();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 Xq(){var t;const e=Ru();return e===hi.browser?[e,((t=Qr.getLocation())==null?void 0:t.host)||"unknown"].join(":"):e}function f_(t,e,r){const i=Qq(),s=Xq();return[[t,e].join("-"),[Wq,r].join("-"),i,s].join("/")}function Zq({protocol:t,version:e,relayUrl:r,sdkVersion:i,auth:s,projectId:n,useOnCloseEvent:o,bundleId:a,packageName:u}){const c=r.split("?"),l=f_(t,e,i),h={auth:s,ua:l,projectId:n,useOnCloseEvent:o,packageName:u||void 0,bundleId:a||void 0},f=Jq(c[1]||"",h);return c[0]+"?"+f}function Dn(t,e){return t.filter(r=>e.includes(r)).length===t.length}function Pp(t){return Object.fromEntries(t.entries())}function Np(t){return new Map(Object.entries(t))}function Cn(t=B.FIVE_MINUTES,e){const r=B.toMiliseconds(t||B.FIVE_MINUTES);let i,s,n,o;return{resolve:a=>{n&&i&&(clearTimeout(n),i(a),o=Promise.resolve(a))},reject:a=>{n&&s&&(clearTimeout(n),s(a))},done:()=>new Promise((a,u)=>{if(o)return a(o);n=setTimeout(()=>{const c=new Error(e);o=Promise.reject(c),u(c)},r),i=a,s=u})}}function tn(t,e,r){return new Promise(async(i,s)=>{const n=setTimeout(()=>s(new Error(r)),e);try{const o=await t;i(o)}catch(o){s(o)}clearTimeout(n)})}function p_(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 eB(t){return p_("topic",t)}function tB(t){return p_("id",t)}function g_(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 er(t,e){return B.fromMiliseconds(Date.now()+B.toMiliseconds(t))}function Js(t){return Date.now()>=B.toMiliseconds(t)}function Le(t,e){return`${t}${e?`:${e}`:""}`}function Bl(t=[],e=[]){return[...new Set([...t,...e])]}async function rB({id:t,topic:e,wcDeepLink:r}){var i;try{if(!r)return;const s=typeof r=="string"?JSON.parse(r):r,n=s?.href;if(typeof n!="string")return;const o=iB(n,t,e),a=Ru();if(a===hi.browser){if(!((i=Qr.getDocument())!=null&&i.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}sB(o)}else a===hi.reactNative&&typeof(global==null?void 0:global.Linking)<"u"&&await global.Linking.openURL(o)}catch(s){console.error(s)}}function iB(t,e,r){const i=`requestId=${e}&sessionTopic=${r}`;t.endsWith("/")&&(t=t.slice(0,-1));let s=`${t}`;if(t.startsWith("https://t.me")){const n=t.includes("?")?"&startapp=":"?startapp=";s=`${s}${n}${cB(i,!0)}`}else s=`${s}/wc?${i}`;return s}function sB(t){let e="_self";aB()?e="_top":(oB()||t.startsWith("https://")||t.startsWith("http://"))&&(e="_blank"),window.open(t,e,"noreferrer noopener")}async function nB(t,e){let r="";try{if(Du()&&(r=localStorage.getItem(e),r))return r;r=await t.getItem(e)}catch(i){console.error(i)}return r}function fw(t,e){if(!t.includes(e))return null;const r=t.split(/([&,?,=])/),i=r.indexOf(e);return r[i+2]}function pw(){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 Rg(){return typeof process<"u"&&Hq.IS_VITEST==="true"}function oB(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function aB(){try{return window.self!==window.top}catch{return!1}}function cB(t,e=!1){const r=Buffer.from(t).toString("base64");return e?r.replace(/[=]/g,""):r}function b_(t){return Buffer.from(t,"base64").toString("utf-8")}function uB(t){return new Promise(e=>setTimeout(e,t))}function fu(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function lB(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Bh(t,...e){if(!lB(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 Mg(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");fu(t.outputLen),fu(t.blockLen)}function pa(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 m_(t,e){Bh(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}const Il=BigInt(2**32-1),gw=BigInt(32);function hB(t,e=!1){return e?{h:Number(t&Il),l:Number(t>>gw&Il)}:{h:Number(t>>gw&Il)|0,l:Number(t&Il)|0}}function dB(t,e=!1){let r=new Uint32Array(t.length),i=new Uint32Array(t.length);for(let s=0;s<t.length;s++){const{h:n,l:o}=hB(t[s],e);[r[s],i[s]]=[n,o]}return[r,i]}const fB=(t,e,r)=>t<<r|e>>>32-r,pB=(t,e,r)=>e<<r|t>>>32-r,gB=(t,e,r)=>e<<r-32|t>>>64-r,bB=(t,e,r)=>t<<r-32|e>>>64-r,$o=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function mB(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function _f(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function rs(t,e){return t<<32-e|t>>>e}const bw=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function yB(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function mw(t){for(let e=0;e<t.length;e++)t[e]=yB(t[e])}function wB(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function ga(t){return typeof t=="string"&&(t=wB(t)),Bh(t),t}let kg=class{clone(){return this._cloneInto()}};function y_(t){const e=i=>t().update(ga(i)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function Mu(t=32){if($o&&typeof $o.getRandomValues=="function")return $o.getRandomValues(new Uint8Array(t));if($o&&typeof $o.randomBytes=="function")return $o.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}const w_=[],v_=[],__=[],vB=BigInt(0),hc=BigInt(1),_B=BigInt(2),EB=BigInt(7),IB=BigInt(256),AB=BigInt(113);for(let t=0,e=hc,r=1,i=0;t<24;t++){[r,i]=[i,(2*r+3*i)%5],w_.push(2*(5*i+r)),v_.push((t+1)*(t+2)/2%64);let s=vB;for(let n=0;n<7;n++)e=(e<<hc^(e>>EB)*AB)%IB,e&_B&&(s^=hc<<(hc<<BigInt(n))-hc);__.push(s)}const[SB,CB]=dB(__,!0),yw=(t,e,r)=>r>32?gB(t,e,r):fB(t,e,r),ww=(t,e,r)=>r>32?bB(t,e,r):pB(t,e,r);function $B(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,u=(o+2)%10,c=r[u],l=r[u+1],h=yw(c,l,1)^r[a],f=ww(c,l,1)^r[a+1];for(let m=0;m<50;m+=10)t[o+m]^=h,t[o+m+1]^=f}let s=t[2],n=t[3];for(let o=0;o<24;o++){const a=v_[o],u=yw(s,n,a),c=ww(s,n,a),l=w_[o];s=t[l],n=t[l+1],t[l]=u,t[l+1]=c}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]^=SB[i],t[1]^=CB[i]}r.fill(0)}let xB=class E_ extends kg{constructor(e,r,i,s=!1,n=24){if(super(),this.blockLen=e,this.suffix=r,this.outputLen=i,this.enableXOF=s,this.rounds=n,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,fu(i),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=mB(this.state)}keccak(){bw||mw(this.state32),$B(this.state32,this.rounds),bw||mw(this.state32),this.posOut=0,this.pos=0}update(e){pa(this);const{blockLen:r,state:i}=this;e=ga(e);const s=e.length;for(let n=0;n<s;){const o=Math.min(r-this.pos,s-n);for(let a=0;a<o;a++)i[this.pos++]^=e[n++];this.pos===r&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:r,pos:i,blockLen:s}=this;e[i]^=r,(r&128)!==0&&i===s-1&&this.keccak(),e[s-1]^=128,this.keccak()}writeInto(e){pa(this,!1),Bh(e),this.finish();const r=this.state,{blockLen:i}=this;for(let s=0,n=e.length;s<n;){this.posOut>=i&&this.keccak();const o=Math.min(i-this.posOut,n-s);e.set(r.subarray(this.posOut,this.posOut+o),s),this.posOut+=o,s+=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 fu(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(m_(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,this.state.fill(0)}_cloneInto(e){const{blockLen:r,suffix:i,outputLen:s,rounds:n,enableXOF:o}=this;return e||(e=new E_(r,i,s,o,n)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=n,e.suffix=i,e.outputLen=s,e.enableXOF=o,e.destroyed=this.destroyed,e}};const PB=(t,e,r)=>y_(()=>new xB(e,t,r)),NB=PB(1,136,256/8),OB="https://rpc.walletconnect.org/v1";function I_(t){const e=`Ethereum Signed Message:
|
|
18
|
+
${t.length}`,r=new TextEncoder().encode(e+t);return"0x"+Buffer.from(NB(r)).toString("hex")}async function TB(t,e,r,i,s,n){switch(r.t){case"eip191":return await DB(t,e,r.s);case"eip1271":return await RB(t,e,r.s,i,s,n);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${r.t}`)}}async function DB(t,e,r){return(await zq({hash:I_(e),signature:r})).toLowerCase()===t.toLowerCase()}async function RB(t,e,r,i,s,n){const o=ia(i);if(!o.namespace||!o.reference)throw new Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${i}`);try{const a="0x1626ba7e",u="0000000000000000000000000000000000000000000000000000000000000040",c="0000000000000000000000000000000000000000000000000000000000000041",l=r.substring(2),h=I_(e).substring(2),f=a+h+u+c+l,m=await fetch(`${n||OB}/?chainId=${i}&projectId=${s}`,{method:"POST",body:JSON.stringify({id:MB(),jsonrpc:"2.0",method:"eth_call",params:[{to:t,data:f},"latest"]})}),{result:g}=await m.json();return g?g.slice(0,a.length).toLowerCase()===a.toLowerCase():!1}catch(a){return console.error("isValidEip1271Signature: ",a),!1}}function MB(){return Date.now()+Math.floor(Math.random()*1e3)}function kB(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 s=1+i*64;if(r.length<s)throw new Error("Transaction data too short for claimed signature count");if(r.length<100)throw new Error("Transaction too short");const n=Buffer.from(t,"base64").slice(1,65);return Nc.encode(n)}var UB=Object.defineProperty,LB=Object.defineProperties,FB=Object.getOwnPropertyDescriptors,vw=Object.getOwnPropertySymbols,jB=Object.prototype.hasOwnProperty,qB=Object.prototype.propertyIsEnumerable,_w=(t,e,r)=>e in t?UB(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,BB=(t,e)=>{for(var r in e||(e={}))jB.call(e,r)&&_w(t,r,e[r]);if(vw)for(var r of vw(e))qB.call(e,r)&&_w(t,r,e[r]);return t},zB=(t,e)=>LB(t,FB(e));const HB="did:pkh:",Ug=t=>t?.split(":"),VB=t=>{const e=t&&Ug(t);if(e)return t.includes(HB)?e[3]:e[1]},Op=t=>{const e=t&&Ug(t);if(e)return e[2]+":"+e[3]},dh=t=>{const e=t&&Ug(t);if(e)return e.pop()};async function Ew(t){const{cacao:e,projectId:r}=t,{s:i,p:s}=e,n=A_(s,s.iss),o=dh(s.iss);return await TB(o,n,i,Op(s.iss),r)}const A_=(t,e)=>{const r=`${t.domain} wants you to sign in with your Ethereum account:`,i=dh(e);if(!t.aud&&!t.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let s=t.statement||void 0;const n=`URI: ${t.aud||t.uri}`,o=`Version: ${t.version}`,a=`Chain ID: ${VB(e)}`,u=`Nonce: ${t.nonce}`,c=`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,m=t.resources?`Resources:${t.resources.map(y=>`
|
|
19
|
+
- ${y}`).join("")}`:void 0,g=zl(t.resources);if(g){const y=pu(g);s=ez(s,y)}return[r,i,"",s,"",n,o,a,u,c,l,h,f,m].filter(y=>y!=null).join(`
|
|
20
|
+
`)};function KB(t){return Buffer.from(JSON.stringify(t)).toString("base64")}function WB(t){return JSON.parse(Buffer.from(t,"base64").toString("utf-8"))}function zn(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(s=>{const n=i[s];if(!Array.isArray(n))throw new Error(`Ability limits ${s} must be an array of objects, found: ${n}`);if(!n.length)throw new Error(`Value of ${s} is empty array, must be an array with objects`);n.forEach(o=>{if(typeof o!="object")throw new Error(`Ability limits (${s}) must be an array of objects, found: ${o}`)})})})}function GB(t,e,r,i={}){return r?.sort((s,n)=>s.localeCompare(n)),{att:{[t]:YB(e,r,i)}}}function YB(t,e,r={}){e=e?.sort((s,n)=>s.localeCompare(n));const i=e.map(s=>({[`${t}/${s}`]:[r]}));return Object.assign({},...i)}function S_(t){return zn(t),`urn:recap:${KB(t).replace(/=/g,"")}`}function pu(t){const e=WB(t.replace("urn:recap:",""));return zn(e),e}function JB(t,e,r){const i=GB(t,e,r);return S_(i)}function QB(t){return t&&t.includes("urn:recap:")}function XB(t,e){const r=pu(t),i=pu(e),s=ZB(r,i);return S_(s)}function ZB(t,e){zn(t),zn(e);const r=Object.keys(t.att).concat(Object.keys(e.att)).sort((s,n)=>s.localeCompare(n)),i={att:{}};return r.forEach(s=>{var n,o;Object.keys(((n=t.att)==null?void 0:n[s])||{}).concat(Object.keys(((o=e.att)==null?void 0:o[s])||{})).sort((a,u)=>a.localeCompare(u)).forEach(a=>{var u,c;i.att[s]=zB(BB({},i.att[s]),{[a]:((u=t.att[s])==null?void 0:u[a])||((c=e.att[s])==null?void 0:c[a])})})}),i}function ez(t="",e){zn(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 s=0;Object.keys(e.att).forEach(a=>{const u=Object.keys(e.att[a]).map(h=>({ability:h.split("/")[0],action:h.split("/")[1]}));u.sort((h,f)=>h.action.localeCompare(f.action));const c={};u.forEach(h=>{c[h.ability]||(c[h.ability]=[]),c[h.ability].push(h.action)});const l=Object.keys(c).map(h=>(s++,`(${s}) '${h}': '${c[h].join("', '")}' for '${a}'.`));i.push(l.join(", ").replace(".,","."))});const n=i.join(" "),o=`${r}${n}`;return`${t?t+" ":""}${o}`}function Iw(t){var e;const r=pu(t);zn(r);const i=(e=r.att)==null?void 0:e.eip155;return i?Object.keys(i).map(s=>s.split("/")[1]):[]}function Aw(t){const e=pu(t);zn(e);const r=[];return Object.values(e.att).forEach(i=>{Object.values(i).forEach(s=>{var n;(n=s?.[0])!=null&&n.chains&&r.push(s[0].chains)})}),[...new Set(r.flat())]}function zl(t){if(!t)return;const e=t?.[t.length-1];return QB(e)?e:void 0}function Ef(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function C_(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function ci(t,...e){if(!C_(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 Sw(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 tz(t,e){ci(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function Cw(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}const nn=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),rz=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),iz=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!iz)throw new Error("Non little-endian hardware is not supported");function sz(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function Tp(t){if(typeof t=="string")t=sz(t);else if(C_(t))t=Dp(t);else throw new Error("Uint8Array expected, got "+typeof t);return t}function nz(t,e){if(e==null||typeof e!="object")throw new Error("options must be defined");return Object.assign(t,e)}function oz(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 az=(t,e)=>{function r(i,...s){if(ci(i),t.nonceLength!==void 0){const c=s[0];if(!c)throw new Error("nonce / iv required");t.varSizeNonce?ci(c):ci(c,t.nonceLength)}const n=t.tagLength;n&&s[1]!==void 0&&ci(s[1]);const o=e(i,...s),a=(c,l)=>{if(l!==void 0){if(c!==2)throw new Error("cipher output not supported");ci(l)}};let u=!1;return{encrypt(c,l){if(u)throw new Error("cannot encrypt() twice with same key + nonce");return u=!0,ci(c),a(o.encrypt.length,l),o.encrypt(c,l)},decrypt(c,l){if(ci(c),n&&c.length<n)throw new Error("invalid ciphertext length: smaller than tagLength="+n);return a(o.decrypt.length,l),o.decrypt(c,l)}}}return Object.assign(r,t),r};function $w(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&&!cz(e))throw new Error("invalid output, must be aligned");return e}function xw(t,e,r,i){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,i);const s=BigInt(32),n=BigInt(4294967295),o=Number(r>>s&n),a=Number(r&n);t.setUint32(e+4,o,i),t.setUint32(e+0,a,i)}function cz(t){return t.byteOffset%4===0}function Dp(t){return Uint8Array.from(t)}function ba(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}const $_=t=>Uint8Array.from(t.split("").map(e=>e.charCodeAt(0))),uz=$_("expand 16-byte k"),lz=$_("expand 32-byte k"),hz=nn(uz),dz=nn(lz);function xe(t,e){return t<<e|t>>>32-e}function Rp(t){return t.byteOffset%4===0}const Al=64,fz=16,x_=2**32-1,Pw=new Uint32Array;function pz(t,e,r,i,s,n,o,a){const u=s.length,c=new Uint8Array(Al),l=nn(c),h=Rp(s)&&Rp(n),f=h?nn(s):Pw,m=h?nn(n):Pw;for(let g=0;g<u;o++){if(t(e,r,i,l,o,a),o>=x_)throw new Error("arx: counter overflow");const y=Math.min(Al,u-g);if(h&&y===Al){const C=g/4;if(g%4!==0)throw new Error("arx: invalid block position");for(let S=0,A;S<fz;S++)A=C+S,m[A]=f[A]^l[S];g+=Al;continue}for(let C=0,S;C<y;C++)S=g+C,n[S]=s[S]^c[C];g+=y}}function gz(t,e){const{allowShortKeys:r,extendNonceFn:i,counterLength:s,counterRight:n,rounds:o}=nz({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},e);if(typeof t!="function")throw new Error("core must be a function");return Ef(s),Ef(o),Cw(n),Cw(r),(a,u,c,l,h=0)=>{ci(a),ci(u),ci(c);const f=c.length;if(l===void 0&&(l=new Uint8Array(f)),ci(l),Ef(h),h<0||h>=x_)throw new Error("arx: counter overflow");if(l.length<f)throw new Error(`arx: output (${l.length}) is shorter than data (${f})`);const m=[];let g=a.length,y,C;if(g===32)m.push(y=Dp(a)),C=dz;else if(g===16&&r)y=new Uint8Array(32),y.set(a),y.set(a,16),C=hz,m.push(y);else throw new Error(`arx: invalid 32-byte key, got length=${g}`);Rp(u)||m.push(u=Dp(u));const S=nn(y);if(i){if(u.length!==24)throw new Error("arx: extended nonce must be 24 bytes");i(C,S,nn(u.subarray(0,16)),S),u=u.subarray(16)}const A=16-s;if(A!==u.length)throw new Error(`arx: nonce must be ${A} or 16 bytes`);if(A!==12){const O=new Uint8Array(12);O.set(u,n?0:12-u.length),u=O,m.push(u)}const D=nn(u);return pz(t,C,S,D,c,l,h,o),ba(...m),l}}const vr=(t,e)=>t[e++]&255|(t[e++]&255)<<8;let bz=class{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=Tp(e),ci(e,32);const r=vr(e,0),i=vr(e,2),s=vr(e,4),n=vr(e,6),o=vr(e,8),a=vr(e,10),u=vr(e,12),c=vr(e,14);this.r[0]=r&8191,this.r[1]=(r>>>13|i<<3)&8191,this.r[2]=(i>>>10|s<<6)&7939,this.r[3]=(s>>>7|n<<9)&8191,this.r[4]=(n>>>4|o<<12)&255,this.r[5]=o>>>1&8190,this.r[6]=(o>>>14|a<<2)&8191,this.r[7]=(a>>>11|u<<5)&8065,this.r[8]=(u>>>8|c<<8)&8191,this.r[9]=c>>>5&127;for(let l=0;l<8;l++)this.pad[l]=vr(e,16+2*l)}process(e,r,i=!1){const s=i?0:2048,{h:n,r:o}=this,a=o[0],u=o[1],c=o[2],l=o[3],h=o[4],f=o[5],m=o[6],g=o[7],y=o[8],C=o[9],S=vr(e,r+0),A=vr(e,r+2),D=vr(e,r+4),O=vr(e,r+6),T=vr(e,r+8),x=vr(e,r+10),M=vr(e,r+12),U=vr(e,r+14);let R=n[0]+(S&8191),L=n[1]+((S>>>13|A<<3)&8191),$=n[2]+((A>>>10|D<<6)&8191),d=n[3]+((D>>>7|O<<9)&8191),b=n[4]+((O>>>4|T<<12)&8191),_=n[5]+(T>>>1&8191),w=n[6]+((T>>>14|x<<2)&8191),v=n[7]+((x>>>11|M<<5)&8191),I=n[8]+((M>>>8|U<<8)&8191),P=n[9]+(U>>>5|s),E=0,p=E+R*a+L*(5*C)+$*(5*y)+d*(5*g)+b*(5*m);E=p>>>13,p&=8191,p+=_*(5*f)+w*(5*h)+v*(5*l)+I*(5*c)+P*(5*u),E+=p>>>13,p&=8191;let N=E+R*u+L*a+$*(5*C)+d*(5*y)+b*(5*g);E=N>>>13,N&=8191,N+=_*(5*m)+w*(5*f)+v*(5*h)+I*(5*l)+P*(5*c),E+=N>>>13,N&=8191;let q=E+R*c+L*u+$*a+d*(5*C)+b*(5*y);E=q>>>13,q&=8191,q+=_*(5*g)+w*(5*m)+v*(5*f)+I*(5*h)+P*(5*l),E+=q>>>13,q&=8191;let H=E+R*l+L*c+$*u+d*a+b*(5*C);E=H>>>13,H&=8191,H+=_*(5*y)+w*(5*g)+v*(5*m)+I*(5*f)+P*(5*h),E+=H>>>13,H&=8191;let z=E+R*h+L*l+$*c+d*u+b*a;E=z>>>13,z&=8191,z+=_*(5*C)+w*(5*y)+v*(5*g)+I*(5*m)+P*(5*f),E+=z>>>13,z&=8191;let V=E+R*f+L*h+$*l+d*c+b*u;E=V>>>13,V&=8191,V+=_*a+w*(5*C)+v*(5*y)+I*(5*g)+P*(5*m),E+=V>>>13,V&=8191;let Y=E+R*m+L*f+$*h+d*l+b*c;E=Y>>>13,Y&=8191,Y+=_*u+w*a+v*(5*C)+I*(5*y)+P*(5*g),E+=Y>>>13,Y&=8191;let te=E+R*g+L*m+$*f+d*h+b*l;E=te>>>13,te&=8191,te+=_*c+w*u+v*a+I*(5*C)+P*(5*y),E+=te>>>13,te&=8191;let ie=E+R*y+L*g+$*m+d*f+b*h;E=ie>>>13,ie&=8191,ie+=_*l+w*c+v*u+I*a+P*(5*C),E+=ie>>>13,ie&=8191;let Z=E+R*C+L*y+$*g+d*m+b*f;E=Z>>>13,Z&=8191,Z+=_*h+w*l+v*c+I*u+P*a,E+=Z>>>13,Z&=8191,E=(E<<2)+E|0,E=E+p|0,p=E&8191,E=E>>>13,N+=E,n[0]=p,n[1]=N,n[2]=q,n[3]=H,n[4]=z,n[5]=V,n[6]=Y,n[7]=te,n[8]=ie,n[9]=Z}finalize(){const{h:e,pad:r}=this,i=new Uint16Array(10);let s=e[1]>>>13;e[1]&=8191;for(let a=2;a<10;a++)e[a]+=s,s=e[a]>>>13,e[a]&=8191;e[0]+=s*5,s=e[0]>>>13,e[0]&=8191,e[1]+=s,s=e[1]>>>13,e[1]&=8191,e[2]+=s,i[0]=e[0]+5,s=i[0]>>>13,i[0]&=8191;for(let a=1;a<10;a++)i[a]=e[a]+s,s=i[a]>>>13,i[a]&=8191;i[9]-=8192;let n=(s^1)-1;for(let a=0;a<10;a++)i[a]&=n;n=~n;for(let a=0;a<10;a++)e[a]=e[a]&n|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;ba(i)}update(e){Sw(this);const{buffer:r,blockLen:i}=this;e=Tp(e);const s=e.length;for(let n=0;n<s;){const o=Math.min(i-this.pos,s-n);if(o===i){for(;i<=s-n;n+=i)this.process(e,n);continue}r.set(e.subarray(n,n+o),this.pos),this.pos+=o,n+=o,this.pos===i&&(this.process(r,0,!1),this.pos=0)}return this}destroy(){ba(this.h,this.r,this.buffer,this.pad)}digestInto(e){Sw(this),tz(e,this),this.finished=!0;const{buffer:r,h:i}=this;let{pos:s}=this;if(s){for(r[s++]=1;s<16;s++)r[s]=0;this.process(r,0,!0)}this.finalize();let n=0;for(let o=0;o<8;o++)e[n++]=i[o]>>>0,e[n++]=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 mz(t){const e=(i,s)=>t(s).update(Tp(i)).digest(),r=t(new Uint8Array(32));return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=i=>t(i),e}const yz=mz(t=>new bz(t));function wz(t,e,r,i,s,n=20){let o=t[0],a=t[1],u=t[2],c=t[3],l=e[0],h=e[1],f=e[2],m=e[3],g=e[4],y=e[5],C=e[6],S=e[7],A=s,D=r[0],O=r[1],T=r[2],x=o,M=a,U=u,R=c,L=l,$=h,d=f,b=m,_=g,w=y,v=C,I=S,P=A,E=D,p=O,N=T;for(let H=0;H<n;H+=2)x=x+L|0,P=xe(P^x,16),_=_+P|0,L=xe(L^_,12),x=x+L|0,P=xe(P^x,8),_=_+P|0,L=xe(L^_,7),M=M+$|0,E=xe(E^M,16),w=w+E|0,$=xe($^w,12),M=M+$|0,E=xe(E^M,8),w=w+E|0,$=xe($^w,7),U=U+d|0,p=xe(p^U,16),v=v+p|0,d=xe(d^v,12),U=U+d|0,p=xe(p^U,8),v=v+p|0,d=xe(d^v,7),R=R+b|0,N=xe(N^R,16),I=I+N|0,b=xe(b^I,12),R=R+b|0,N=xe(N^R,8),I=I+N|0,b=xe(b^I,7),x=x+$|0,N=xe(N^x,16),v=v+N|0,$=xe($^v,12),x=x+$|0,N=xe(N^x,8),v=v+N|0,$=xe($^v,7),M=M+d|0,P=xe(P^M,16),I=I+P|0,d=xe(d^I,12),M=M+d|0,P=xe(P^M,8),I=I+P|0,d=xe(d^I,7),U=U+b|0,E=xe(E^U,16),_=_+E|0,b=xe(b^_,12),U=U+b|0,E=xe(E^U,8),_=_+E|0,b=xe(b^_,7),R=R+L|0,p=xe(p^R,16),w=w+p|0,L=xe(L^w,12),R=R+L|0,p=xe(p^R,8),w=w+p|0,L=xe(L^w,7);let q=0;i[q++]=o+x|0,i[q++]=a+M|0,i[q++]=u+U|0,i[q++]=c+R|0,i[q++]=l+L|0,i[q++]=h+$|0,i[q++]=f+d|0,i[q++]=m+b|0,i[q++]=g+_|0,i[q++]=y+w|0,i[q++]=C+v|0,i[q++]=S+I|0,i[q++]=A+P|0,i[q++]=D+E|0,i[q++]=O+p|0,i[q++]=T+N|0}const vz=gz(wz,{counterRight:!1,counterLength:4,allowShortKeys:!1}),_z=new Uint8Array(16),Nw=(t,e)=>{t.update(e);const r=e.length%16;r&&t.update(_z.subarray(r))},Ez=new Uint8Array(32);function Ow(t,e,r,i,s){const n=t(e,r,Ez),o=yz.create(n);s&&Nw(o,s),Nw(o,i);const a=new Uint8Array(16),u=rz(a);xw(u,0,BigInt(s?s.length:0),!0),xw(u,8,BigInt(i.length),!0),o.update(a);const c=o.digest();return ba(n,a),c}const Iz=t=>(e,r,i)=>({encrypt(s,n){const o=s.length;n=$w(o+16,n,!1),n.set(s);const a=n.subarray(0,-16);t(e,r,a,a,1);const u=Ow(t,e,r,a,i);return n.set(u,o),ba(u),n},decrypt(s,n){n=$w(s.length-16,n,!1);const o=s.subarray(0,-16),a=s.subarray(-16),u=Ow(t,e,r,o,i);if(!oz(a,u))throw new Error("invalid tag");return n.set(s.subarray(0,-16)),t(e,r,n,n,1),ba(u),n}}),P_=az({blockSize:64,nonceLength:12,tagLength:16},Iz(vz));let N_=class extends kg{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,Mg(e);const i=ga(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 s=this.blockLen,n=new Uint8Array(s);n.set(i.length>s?e.create().update(i).digest():i);for(let o=0;o<n.length;o++)n[o]^=54;this.iHash.update(n),this.oHash=e.create();for(let o=0;o<n.length;o++)n[o]^=106;this.oHash.update(n),n.fill(0)}update(e){return pa(this),this.iHash.update(e),this}digestInto(e){pa(this),Bh(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:s,destroyed:n,blockLen:o,outputLen:a}=this;return e=e,e.finished=s,e.destroyed=n,e.blockLen=o,e.outputLen=a,e.oHash=r._cloneInto(e.oHash),e.iHash=i._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};const Lg=(t,e,r)=>new N_(t,e).update(r).digest();Lg.create=(t,e)=>new N_(t,e);function Az(t,e,r){return Mg(t),r===void 0&&(r=new Uint8Array(t.outputLen)),Lg(t,ga(r),ga(e))}const If=new Uint8Array([0]),Tw=new Uint8Array;function Sz(t,e,r,i=32){if(Mg(t),fu(i),i>255*t.outputLen)throw new Error("Length should be <= 255*HashLen");const s=Math.ceil(i/t.outputLen);r===void 0&&(r=Tw);const n=new Uint8Array(s*t.outputLen),o=Lg.create(t,e),a=o._cloneInto(),u=new Uint8Array(o.outputLen);for(let c=0;c<s;c++)If[0]=c+1,a.update(c===0?Tw:u).update(r).update(If).digestInto(u),n.set(u,t.outputLen*c),o._cloneInto(a);return o.destroy(),a.destroy(),u.fill(0),If.fill(0),n.slice(0,i)}const Cz=(t,e,r,i,s)=>Sz(t,Az(t,e,r),i,s);function $z(t,e,r,i){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,i);const s=BigInt(32),n=BigInt(4294967295),o=Number(r>>s&n),a=Number(r&n),u=i?4:0,c=i?0:4;t.setUint32(e+u,o,i),t.setUint32(e+c,a,i)}function xz(t,e,r){return t&e^~t&r}function Pz(t,e,r){return t&e^t&r^e&r}class Nz extends kg{constructor(e,r,i,s){super(),this.blockLen=e,this.outputLen=r,this.padOffset=i,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=_f(this.buffer)}update(e){pa(this);const{view:r,buffer:i,blockLen:s}=this;e=ga(e);const n=e.length;for(let o=0;o<n;){const a=Math.min(s-this.pos,n-o);if(a===s){const u=_f(e);for(;s<=n-o;o+=s)this.process(u,o);continue}i.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===s&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){pa(this),m_(e,this),this.finished=!0;const{buffer:r,view:i,blockLen:s,isLE:n}=this;let{pos:o}=this;r[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>s-o&&(this.process(i,0),o=0);for(let h=o;h<s;h++)r[h]=0;$z(i,s-8,BigInt(this.length*8),n),this.process(i,0);const a=_f(e),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=u/4,l=this.get();if(c>l.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<c;h++)a.setUint32(4*h,l[h],n)}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:s,finished:n,destroyed:o,pos:a}=this;return e.length=s,e.pos=a,e.finished=n,e.destroyed=o,s%r&&e.buffer.set(i),e}}const Oz=new Uint32Array([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]),Hs=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Vs=new Uint32Array(64);let Tz=class extends Nz{constructor(){super(64,32,8,!1),this.A=Hs[0]|0,this.B=Hs[1]|0,this.C=Hs[2]|0,this.D=Hs[3]|0,this.E=Hs[4]|0,this.F=Hs[5]|0,this.G=Hs[6]|0,this.H=Hs[7]|0}get(){const{A:e,B:r,C:i,D:s,E:n,F:o,G:a,H:u}=this;return[e,r,i,s,n,o,a,u]}set(e,r,i,s,n,o,a,u){this.A=e|0,this.B=r|0,this.C=i|0,this.D=s|0,this.E=n|0,this.F=o|0,this.G=a|0,this.H=u|0}process(e,r){for(let h=0;h<16;h++,r+=4)Vs[h]=e.getUint32(r,!1);for(let h=16;h<64;h++){const f=Vs[h-15],m=Vs[h-2],g=rs(f,7)^rs(f,18)^f>>>3,y=rs(m,17)^rs(m,19)^m>>>10;Vs[h]=y+Vs[h-7]+g+Vs[h-16]|0}let{A:i,B:s,C:n,D:o,E:a,F:u,G:c,H:l}=this;for(let h=0;h<64;h++){const f=rs(a,6)^rs(a,11)^rs(a,25),m=l+f+xz(a,u,c)+Oz[h]+Vs[h]|0,g=(rs(i,2)^rs(i,13)^rs(i,22))+Pz(i,s,n)|0;l=c,c=u,u=a,a=o+m|0,o=n,n=s,s=i,i=m+g|0}i=i+this.A|0,s=s+this.B|0,n=n+this.C|0,o=o+this.D|0,a=a+this.E|0,u=u+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(i,s,n,o,a,u,c,l)}roundClean(){Vs.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const zh=y_(()=>new Tz);const O_=BigInt(0);function Fg(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function T_(t){if(!Fg(t))throw new Error("Uint8Array expected")}const Dz=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Rz(t){T_(t);let e="";for(let r=0;r<t.length;r++)e+=Dz[t[r]];return e}function Mz(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?O_:BigInt("0x"+t)}const As={_0:48,_9:57,A:65,F:70,a:97,f:102};function Dw(t){if(t>=As._0&&t<=As._9)return t-As._0;if(t>=As.A&&t<=As.F)return t-(As.A-10);if(t>=As.a&&t<=As.f)return t-(As.a-10)}function D_(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 s=0,n=0;s<r;s++,n+=2){const o=Dw(t.charCodeAt(n)),a=Dw(t.charCodeAt(n+1));if(o===void 0||a===void 0){const u=t[n]+t[n+1];throw new Error('hex string expected, got non-hex character "'+u+'" at index '+n)}i[s]=o*16+a}return i}function Rw(t){return T_(t),Mz(Rz(Uint8Array.from(t).reverse()))}function kz(t,e){return D_(t.toString(16).padStart(e*2,"0"))}function Uz(t,e){return kz(t,e).reverse()}function Mw(t,e,r){let i;if(typeof e=="string")try{i=D_(e)}catch(n){throw new Error(t+" must be hex string or Uint8Array, cause: "+n)}else if(Fg(e))i=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");const s=i.length;if(typeof r=="number"&&s!==r)throw new Error(t+" of length "+r+" expected, got "+s);return i}const Af=t=>typeof t=="bigint"&&O_<=t;function Lz(t,e,r){return Af(t)&&Af(e)&&Af(r)&&e<=t&&t<r}function kw(t,e,r,i){if(!Lz(e,r,i))throw new Error("expected valid "+t+": "+r+" <= n < "+i+", got "+e)}const Fz={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"||Fg(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 jz(t,e,r={}){const i=(s,n,o)=>{const a=Fz[n];if(typeof a!="function")throw new Error("invalid validator function");const u=t[s];if(!(o&&u===void 0)&&!a(u,t))throw new Error("param "+String(s)+" is invalid. Expected "+n+", got "+u)};for(const[s,n]of Object.entries(e))i(s,n,!1);for(const[s,n]of Object.entries(r))i(s,n,!0);return t}const Xo=BigInt(0),Sl=BigInt(1);function R_(t,e){const r=t%e;return r>=Xo?r:e+r}function qz(t,e,r){if(e<Xo)throw new Error("invalid exponent, negatives unsupported");if(r<=Xo)throw new Error("invalid modulus");if(r===Sl)return Xo;let i=Sl;for(;e>Xo;)e&Sl&&(i=i*t%r),t=t*t%r,e>>=Sl;return i}function Bi(t,e,r){let i=t;for(;e-- >Xo;)i*=i,i%=r;return i}BigInt(0),BigInt(1),BigInt(0),BigInt(1),BigInt(2),BigInt(8);const xo=BigInt(0),Sf=BigInt(1);function Bz(t){return jz(t,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...t})}function zz(t){const e=Bz(t),{P:r}=e,i=A=>R_(A,r),s=e.montgomeryBits,n=Math.ceil(s/8),o=e.nByteLength,a=e.adjustScalarBytes||(A=>A),u=e.powPminus2||(A=>qz(A,r-BigInt(2),r));function c(A,D,O){const T=i(A*(D-O));return D=i(D-T),O=i(O+T),[D,O]}const l=(e.a-BigInt(2))/BigInt(4);function h(A,D){kw("u",A,xo,r),kw("scalar",D,xo,r);const O=D,T=A;let x=Sf,M=xo,U=A,R=Sf,L=xo,$;for(let b=BigInt(s-1);b>=xo;b--){const _=O>>b&Sf;L^=_,$=c(L,x,U),x=$[0],U=$[1],$=c(L,M,R),M=$[0],R=$[1],L=_;const w=x+M,v=i(w*w),I=x-M,P=i(I*I),E=v-P,p=U+R,N=U-R,q=i(N*w),H=i(p*I),z=q+H,V=q-H;U=i(z*z),R=i(T*i(V*V)),x=i(v*P),M=i(E*(v+i(l*E)))}$=c(L,x,U),x=$[0],U=$[1],$=c(L,M,R),M=$[0],R=$[1];const d=u(M);return i(x*d)}function f(A){return Uz(i(A),n)}function m(A){const D=Mw("u coordinate",A,n);return o===32&&(D[31]&=127),Rw(D)}function g(A){const D=Mw("scalar",A),O=D.length;if(O!==n&&O!==o){let T=""+n+" or "+o;throw new Error("invalid scalar, expected "+T+" bytes, got "+O)}return Rw(a(D))}function y(A,D){const O=m(D),T=g(A),x=h(O,T);if(x===xo)throw new Error("invalid private or public key received");return f(x)}const C=f(e.Gu);function S(A){return y(A,C)}return{scalarMult:y,scalarMultBase:S,getSharedSecret:(A,D)=>y(A,D),getPublicKey:A=>S(A),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:C}}const Mp=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949");BigInt(0);const Hz=BigInt(1),Uw=BigInt(2),Vz=BigInt(3),Kz=BigInt(5);BigInt(8);function Wz(t){const e=BigInt(10),r=BigInt(20),i=BigInt(40),s=BigInt(80),n=Mp,o=t*t%n*t%n,a=Bi(o,Uw,n)*o%n,u=Bi(a,Hz,n)*t%n,c=Bi(u,Kz,n)*u%n,l=Bi(c,e,n)*c%n,h=Bi(l,r,n)*l%n,f=Bi(h,i,n)*h%n,m=Bi(f,s,n)*f%n,g=Bi(m,s,n)*f%n,y=Bi(g,e,n)*c%n;return{pow_p_5_8:Bi(y,Uw,n)*t%n,b2:o}}function Gz(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}const kp=zz({P:Mp,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:t=>{const e=Mp,{pow_p_5_8:r,b2:i}=Wz(t);return R_(Bi(r,Vz,e)*i,e)},adjustScalarBytes:Gz,randomBytes:Mu}),M_="base10",Rr="base16",rn="base64pad",dc="base64url",ku="utf8",k_=0,Ns=1,Uu=2,Yz=0,Lw=1,Dc=12,jg=32;function Jz(){const t=kp.utils.randomPrivateKey(),e=kp.getPublicKey(t);return{privateKey:Fe(t,Rr),publicKey:Fe(e,Rr)}}function Up(){const t=Mu(jg);return Fe(t,Rr)}function Qz(t,e){const r=kp.getSharedSecret(_t(t,Rr),_t(e,Rr)),i=Cz(zh,r,void 0,void 0,jg);return Fe(i,Rr)}function Hl(t){const e=zh(_t(t,Rr));return Fe(e,Rr)}function as(t){const e=zh(_t(t,ku));return Fe(e,Rr)}function U_(t){return _t(`${t}`,M_)}function Hn(t){return Number(Fe(t,M_))}function Xz(t){const e=U_(typeof t.type<"u"?t.type:k_);if(Hn(e)===Ns&&typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const r=typeof t.senderPublicKey<"u"?_t(t.senderPublicKey,Rr):void 0,i=typeof t.iv<"u"?_t(t.iv,Rr):Mu(Dc),s=_t(t.symKey,Rr),n=P_(s,i).encrypt(_t(t.message,ku));return L_({type:e,sealed:n,iv:i,senderPublicKey:r,encoding:t.encoding})}function Zz(t){const e=_t(t.symKey,Rr),{sealed:r,iv:i}=gu(t),s=P_(e,i).decrypt(r);if(s===null)throw new Error("Failed to decrypt");return Fe(s,ku)}function eH(t,e){const r=U_(Uu),i=Mu(Dc),s=_t(t,ku);return L_({type:r,sealed:s,iv:i,encoding:e})}function tH(t,e){const{sealed:r}=gu({encoded:t,encoding:e});return Fe(r,ku)}function L_(t){const{encoding:e=rn}=t;if(Hn(t.type)===Uu)return Fe(ta([t.type,t.sealed]),e);if(Hn(t.type)===Ns){if(typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return Fe(ta([t.type,t.senderPublicKey,t.iv,t.sealed]),e)}return Fe(ta([t.type,t.iv,t.sealed]),e)}function gu(t){const{encoded:e,encoding:r=rn}=t,i=_t(e,r),s=i.slice(Yz,Lw),n=Lw;if(Hn(s)===Ns){const c=n+jg,l=c+Dc,h=i.slice(n,c),f=i.slice(c,l),m=i.slice(l);return{type:s,sealed:m,iv:f,senderPublicKey:h}}if(Hn(s)===Uu){const c=i.slice(n),l=Mu(Dc);return{type:s,sealed:c,iv:l}}const o=n+Dc,a=i.slice(n,o),u=i.slice(o);return{type:s,sealed:u,iv:a}}function rH(t,e){const r=gu({encoded:t,encoding:e?.encoding});return F_({type:Hn(r.type),senderPublicKey:typeof r.senderPublicKey<"u"?Fe(r.senderPublicKey,Rr):void 0,receiverPublicKey:e?.receiverPublicKey})}function F_(t){const e=t?.type||k_;if(e===Ns){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 Fw(t){return t.type===Ns&&typeof t.senderPublicKey=="string"&&typeof t.receiverPublicKey=="string"}function jw(t){return t.type===Uu}function iH(t){return new o2.ec("p256").keyFromPublic({x:Buffer.from(t.x,"base64").toString("hex"),y:Buffer.from(t.y,"base64").toString("hex")},"hex")}function sH(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");const r=e.length%4;return r>0&&(e+="=".repeat(4-r)),e}function nH(t){return Buffer.from(sH(t),"base64")}function oH(t,e){const[r,i,s]=t.split("."),n=nH(s);if(n.length!==64)throw new Error("Invalid signature length");const o=n.slice(0,32).toString("hex"),a=n.slice(32,64).toString("hex"),u=`${r}.${i}`,c=zh(u),l=iH(e),h=Fe(c,Rr);if(!l.verify(h,{r:o,s:a}))throw new Error("Invalid signature");return oa(t).payload}const aH="irn";function fh(t){return t?.relay||{protocol:aH}}function Ac(t){const e=a2[t];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${t}`);return e}function cH(t,e="-"){const r={},i="relay"+e;return Object.keys(t).forEach(s=>{if(s.startsWith(i)){const n=s.replace(i,""),o=t[s];r[n]=o}}),r}function qw(t){if(!t.includes("wc:")){const c=b_(t);c!=null&&c.includes("wc:")&&(t=c)}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),s=t.substring(e+1,r).split("@"),n=typeof r<"u"?t.substring(r):"",o=new URLSearchParams(n),a={};o.forEach((c,l)=>{a[l]=c});const u=typeof a.methods=="string"?a.methods.split(","):void 0;return{protocol:i,topic:uH(s[0]),version:parseInt(s[1],10),symKey:a.symKey,relay:cH(a),methods:u,expiryTimestamp:a.expiryTimestamp?parseInt(a.expiryTimestamp,10):void 0}}function uH(t){return t.startsWith("//")?t.substring(2):t}function lH(t,e="-"){const r="relay",i={};return Object.keys(t).forEach(s=>{const n=s,o=r+e+n;t[n]&&(i[o]=t[n])}),i}function Bw(t){const e=new URLSearchParams,r=lH(t.relay);Object.keys(r).sort().forEach(s=>{e.set(s,r[s])}),e.set("symKey",t.symKey),t.expiryTimestamp&&e.set("expiryTimestamp",t.expiryTimestamp.toString()),t.methods&&e.set("methods",t.methods.join(","));const i=e.toString();return`${t.protocol}:${t.topic}@${t.version}?${i}`}function Cl(t,e,r){return`${t}?wc_ev=${r}&topic=${e}`}function Pa(t){const e=[];return t.forEach(r=>{const[i,s]=r.split(":");e.push(`${i}:${s}`)}),e}function hH(t){const e=[];return Object.values(t).forEach(r=>{e.push(...Pa(r.accounts))}),e}function dH(t,e){const r=[];return Object.values(t).forEach(i=>{Pa(i.accounts).includes(e)&&r.push(...i.methods)}),r}function fH(t,e){const r=[];return Object.values(t).forEach(i=>{Pa(i.accounts).includes(e)&&r.push(...i.events)}),r}function qg(t){return t.includes(":")}function Sc(t){return qg(t)?t.split(":")[0]:t}function pH(t){const e={};return t?.forEach(r=>{var i;const[s,n]=r.split(":");e[s]||(e[s]={accounts:[],chains:[],events:[],methods:[]}),e[s].accounts.push(r),(i=e[s].chains)==null||i.push(`${s}:${n}`)}),e}function zw(t,e){e=e.map(i=>i.replace("did:pkh:",""));const r=pH(e);for(const[i,s]of Object.entries(r))s.methods?s.methods=Bl(s.methods,t):s.methods=t,s.events=["chainChanged","accountsChanged"];return r}const gH={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}},bH={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 X(t,e){const{message:r,code:i}=bH[t];return{message:e?`${r} ${e}`:r,code:i}}function Xe(t,e){const{message:r,code:i}=gH[t];return{message:e?`${r} ${e}`:r,code:i}}function Vn(t,e){return!!Array.isArray(t)}function bu(t){return Object.getPrototypeOf(t)===Object.prototype&&Object.keys(t).length}function Ar(t){return typeof t>"u"}function Jt(t,e){return e&&Ar(t)?!0:typeof t=="string"&&!!t.trim().length}function Bg(t,e){return e&&Ar(t)?!0:typeof t=="number"&&!isNaN(t)}function mH(t,e){const{requiredNamespaces:r}=e,i=Object.keys(t.namespaces),s=Object.keys(r);let n=!0;return Dn(s,i)?(i.forEach(o=>{const{accounts:a,methods:u,events:c}=t.namespaces[o],l=Pa(a),h=r[o];(!Dn(h_(o,h),l)||!Dn(h.methods,u)||!Dn(h.events,c))&&(n=!1)}),n):!1}function ph(t){return Jt(t,!1)&&t.includes(":")?t.split(":").length===2:!1}function yH(t){if(Jt(t,!1)&&t.includes(":")){const e=t.split(":");if(e.length===3){const r=e[0]+":"+e[1];return!!e[2]&&ph(r)}}return!1}function wH(t){function e(r){try{return typeof new URL(r)<"u"}catch{return!1}}try{if(Jt(t,!1)){if(e(t))return!0;const r=b_(t);return e(r)}}catch{}return!1}function vH(t){var e;return(e=t?.proposer)==null?void 0:e.publicKey}function _H(t){return t?.topic}function EH(t,e){let r=null;return Jt(t?.publicKey,!1)||(r=X("MISSING_OR_INVALID",`${e} controller public key should be a string`)),r}function Hw(t){let e=!0;return Vn(t)?t.length&&(e=t.every(r=>Jt(r,!1))):e=!1,e}function IH(t,e,r){let i=null;return Vn(e)&&e.length?e.forEach(s=>{i||ph(s)||(i=Xe("UNSUPPORTED_CHAINS",`${r}, chain ${s} should be a string and conform to "namespace:chainId" format`))}):ph(t)||(i=Xe("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 AH(t,e,r){let i=null;return Object.entries(t).forEach(([s,n])=>{if(i)return;const o=IH(s,h_(s,n),`${e} ${r}`);o&&(i=o)}),i}function SH(t,e){let r=null;return Vn(t)?t.forEach(i=>{r||yH(i)||(r=Xe("UNSUPPORTED_ACCOUNTS",`${e}, account ${i} should be a string and conform to "namespace:chainId:address" format`))}):r=Xe("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),r}function CH(t,e){let r=null;return Object.values(t).forEach(i=>{if(r)return;const s=SH(i?.accounts,`${e} namespace`);s&&(r=s)}),r}function $H(t,e){let r=null;return Hw(t?.methods)?Hw(t?.events)||(r=Xe("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):r=Xe("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),r}function j_(t,e){let r=null;return Object.values(t).forEach(i=>{if(r)return;const s=$H(i,`${e}, namespace`);s&&(r=s)}),r}function xH(t,e,r){let i=null;if(t&&bu(t)){const s=j_(t,e);s&&(i=s);const n=AH(t,e,r);n&&(i=n)}else i=X("MISSING_OR_INVALID",`${e}, ${r} should be an object with data`);return i}function Cf(t,e){let r=null;if(t&&bu(t)){const i=j_(t,e);i&&(r=i);const s=CH(t,e);s&&(r=s)}else r=X("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return r}function q_(t){return Jt(t.protocol,!0)}function PH(t,e){let r=!1;return t?t&&Vn(t)&&t.length&&t.forEach(i=>{r=q_(i)}):r=!0,r}function NH(t){return typeof t=="number"}function Gr(t){return typeof t<"u"&&typeof t!==null}function OH(t){return!(!t||typeof t!="object"||!t.code||!Bg(t.code,!1)||!t.message||!Jt(t.message,!1))}function TH(t){return!(Ar(t)||!Jt(t.method,!1))}function DH(t){return!(Ar(t)||Ar(t.result)&&Ar(t.error)||!Bg(t.id,!1)||!Jt(t.jsonrpc,!1))}function RH(t){return!(Ar(t)||!Jt(t.name,!1))}function Vw(t,e){return!(!ph(e)||!hH(t).includes(e))}function MH(t,e,r){return Jt(r,!1)?dH(t,e).includes(r):!1}function kH(t,e,r){return Jt(r,!1)?fH(t,e).includes(r):!1}function Kw(t,e,r){let i=null;const s=UH(t),n=LH(e),o=Object.keys(s),a=Object.keys(n),u=Ww(Object.keys(t)),c=Ww(Object.keys(e)),l=u.filter(h=>!c.includes(h));return l.length&&(i=X("NON_CONFORMING_NAMESPACES",`${r} namespaces keys don't satisfy requiredNamespaces.
|
|
21
|
+
Required: ${l.toString()}
|
|
22
|
+
Received: ${Object.keys(e).toString()}`)),Dn(o,a)||(i=X("NON_CONFORMING_NAMESPACES",`${r} namespaces chains don't satisfy required namespaces.
|
|
23
|
+
Required: ${o.toString()}
|
|
24
|
+
Approved: ${a.toString()}`)),Object.keys(e).forEach(h=>{if(!h.includes(":")||i)return;const f=Pa(e[h].accounts);f.includes(h)||(i=X("NON_CONFORMING_NAMESPACES",`${r} namespaces accounts don't satisfy namespace accounts for ${h}
|
|
25
|
+
Required: ${h}
|
|
26
|
+
Approved: ${f.toString()}`))}),o.forEach(h=>{i||(Dn(s[h].methods,n[h].methods)?Dn(s[h].events,n[h].events)||(i=X("NON_CONFORMING_NAMESPACES",`${r} namespaces events don't satisfy namespace events for ${h}`)):i=X("NON_CONFORMING_NAMESPACES",`${r} namespaces methods don't satisfy namespace methods for ${h}`))}),i}function UH(t){const e={};return Object.keys(t).forEach(r=>{var i;r.includes(":")?e[r]=t[r]:(i=t[r].chains)==null||i.forEach(s=>{e[s]={methods:t[r].methods,events:t[r].events}})}),e}function Ww(t){return[...new Set(t.map(e=>e.includes(":")?e.split(":")[0]:e))]}function LH(t){const e={};return Object.keys(t).forEach(r=>{r.includes(":")?e[r]=t[r]:Pa(t[r].accounts)?.forEach(s=>{e[s]={accounts:t[r].accounts.filter(n=>n.includes(`${s}:`)),methods:t[r].methods,events:t[r].events}})}),e}function FH(t,e){return Bg(t,!1)&&t<=e.max&&t>=e.min}function Gw(){const t=Ru();return new Promise(e=>{switch(t){case hi.browser:e(jH());break;case hi.reactNative:e(qH());break;case hi.node:e(BH());break;default:e(!0)}})}function jH(){return Du()&&navigator?.onLine}async function qH(){return hn()&&typeof global<"u"&&global!=null&&global.NetInfo?(await(global==null?void 0:global.NetInfo.fetch()))?.isConnected:!0}function BH(){return!0}function zH(t){switch(Ru()){case hi.browser:HH(t);break;case hi.reactNative:VH(t);break}}function HH(t){!hn()&&Du()&&(window.addEventListener("online",()=>t(!0)),window.addEventListener("offline",()=>t(!1)))}function VH(t){hn()&&typeof global<"u"&&global!=null&&global.NetInfo&&global?.NetInfo.addEventListener(e=>t(e?.isConnected))}const $f={};class fc{static get(e){return $f[e]}static set(e,r){$f[e]=r}static delete(e){delete $f[e]}}const B_="wc",z_=2,Lp="core",hs=`${B_}@2:${Lp}:`,KH={logger:"error"},WH={database:":memory:"},GH="crypto",Yw="client_ed25519_seed",YH=B.ONE_DAY,JH="keychain",QH="0.3",XH="messages",ZH="0.3",Jw=B.SIX_HOURS,eV="publisher",H_="irn",tV="error",V_="wss://relay.walletconnect.org",rV="relayer",fr={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"},iV="_subscription",Ei={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},sV=.1,Fp="2.19.1",gt={link_mode:"link_mode",relay:"relay"},Vl={inbound:"inbound",outbound:"outbound"},nV="0.3",oV="WALLETCONNECT_CLIENT_ID",Qw="WALLETCONNECT_LINK_MODE_APPS",oi={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},aV="subscription",cV="0.3",uV="pairing",lV="0.3",pc={wc_pairingDelete:{req:{ttl:B.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:B.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:B.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:B.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:B.ONE_DAY,prompt:!1,tag:0},res:{ttl:B.ONE_DAY,prompt:!1,tag:0}}},Pn={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},Li={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},hV="history",dV="0.3",fV="expirer",Ci={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},pV="0.3",gV="verify-api",bV="https://verify.walletconnect.com",K_="https://verify.walletconnect.org",Rc=K_,mV=`${Rc}/v3`,yV=[bV,K_],wV="echo",vV="https://echo.walletconnect.com",os={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"},Cs={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"},Fi={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"},_n={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"},En={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"},gc={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"},_V=.1,EV="event-client",IV=86400,AV="https://pulse.walletconnect.org/batch";function SV(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 s=0;s<t.length;s++){var n=t.charAt(s),o=n.charCodeAt(0);if(r[o]!==255)throw new TypeError(n+" is ambiguous");r[o]=s}var a=t.length,u=t.charAt(0),c=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function h(g){if(g instanceof Uint8Array||(ArrayBuffer.isView(g)?g=new Uint8Array(g.buffer,g.byteOffset,g.byteLength):Array.isArray(g)&&(g=Uint8Array.from(g))),!(g instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(g.length===0)return"";for(var y=0,C=0,S=0,A=g.length;S!==A&&g[S]===0;)S++,y++;for(var D=(A-S)*l+1>>>0,O=new Uint8Array(D);S!==A;){for(var T=g[S],x=0,M=D-1;(T!==0||x<C)&&M!==-1;M--,x++)T+=256*O[M]>>>0,O[M]=T%a>>>0,T=T/a>>>0;if(T!==0)throw new Error("Non-zero carry");C=x,S++}for(var U=D-C;U!==D&&O[U]===0;)U++;for(var R=u.repeat(y);U<D;++U)R+=t.charAt(O[U]);return R}function f(g){if(typeof g!="string")throw new TypeError("Expected String");if(g.length===0)return new Uint8Array;var y=0;if(g[y]!==" "){for(var C=0,S=0;g[y]===u;)C++,y++;for(var A=(g.length-y)*c+1>>>0,D=new Uint8Array(A);g[y];){var O=r[g.charCodeAt(y)];if(O===255)return;for(var T=0,x=A-1;(O!==0||T<S)&&x!==-1;x--,T++)O+=a*D[x]>>>0,D[x]=O%256>>>0,O=O/256>>>0;if(O!==0)throw new Error("Non-zero carry");S=T,y++}if(g[y]!==" "){for(var M=A-S;M!==A&&D[M]===0;)M++;for(var U=new Uint8Array(C+(A-M)),R=C;M!==A;)U[R++]=D[M++];return U}}}function m(g){var y=f(g);if(y)return y;throw new Error(`Non-${e} character`)}return{encode:h,decodeUnsafe:f,decode:m}}var CV=SV,$V=CV;const W_=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")},xV=t=>new TextEncoder().encode(t),PV=t=>new TextDecoder().decode(t);class NV{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 OV{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 G_(this,e)}}class TV{constructor(e){this.decoders=e}or(e){return G_(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 G_=(t,e)=>new TV({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class DV{constructor(e,r,i,s){this.name=e,this.prefix=r,this.baseEncode=i,this.baseDecode=s,this.encoder=new NV(e,r,i),this.decoder=new OV(e,r,s)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Hh=({name:t,prefix:e,encode:r,decode:i})=>new DV(t,e,r,i),Lu=({prefix:t,name:e,alphabet:r})=>{const{encode:i,decode:s}=$V(r,e);return Hh({prefix:t,name:e,encode:i,decode:n=>W_(s(n))})},RV=(t,e,r,i)=>{const s={};for(let l=0;l<e.length;++l)s[e[l]]=l;let n=t.length;for(;t[n-1]==="=";)--n;const o=new Uint8Array(n*r/8|0);let a=0,u=0,c=0;for(let l=0;l<n;++l){const h=s[t[l]];if(h===void 0)throw new SyntaxError(`Non-${i} character`);u=u<<r|h,a+=r,a>=8&&(a-=8,o[c++]=255&u>>a)}if(a>=r||255&u<<8-a)throw new SyntaxError("Unexpected end of data");return o},MV=(t,e,r)=>{const i=e[e.length-1]==="=",s=(1<<r)-1;let n="",o=0,a=0;for(let u=0;u<t.length;++u)for(a=a<<8|t[u],o+=8;o>r;)o-=r,n+=e[s&a>>o];if(o&&(n+=e[s&a<<r-o]),i)for(;n.length*r&7;)n+="=";return n},xr=({name:t,prefix:e,bitsPerChar:r,alphabet:i})=>Hh({prefix:e,name:t,encode(s){return MV(s,i,r)},decode(s){return RV(s,i,r,t)}}),kV=Hh({prefix:"\0",name:"identity",encode:t=>PV(t),decode:t=>xV(t)});var UV=Object.freeze({__proto__:null,identity:kV});const LV=xr({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var FV=Object.freeze({__proto__:null,base2:LV});const jV=xr({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var qV=Object.freeze({__proto__:null,base8:jV});const BV=Lu({prefix:"9",name:"base10",alphabet:"0123456789"});var zV=Object.freeze({__proto__:null,base10:BV});const HV=xr({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),VV=xr({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var KV=Object.freeze({__proto__:null,base16:HV,base16upper:VV});const WV=xr({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),GV=xr({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),YV=xr({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),JV=xr({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),QV=xr({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),XV=xr({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),ZV=xr({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),eK=xr({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),tK=xr({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var rK=Object.freeze({__proto__:null,base32:WV,base32upper:GV,base32pad:YV,base32padupper:JV,base32hex:QV,base32hexupper:XV,base32hexpad:ZV,base32hexpadupper:eK,base32z:tK});const iK=Lu({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),sK=Lu({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var nK=Object.freeze({__proto__:null,base36:iK,base36upper:sK});const oK=Lu({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),aK=Lu({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var cK=Object.freeze({__proto__:null,base58btc:oK,base58flickr:aK});const uK=xr({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),lK=xr({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),hK=xr({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),dK=xr({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var fK=Object.freeze({__proto__:null,base64:uK,base64pad:lK,base64url:hK,base64urlpad:dK});const Y_=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),pK=Y_.reduce((t,e,r)=>(t[r]=e,t),[]),gK=Y_.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function bK(t){return t.reduce((e,r)=>(e+=pK[r],e),"")}function mK(t){const e=[];for(const r of t){const i=gK[r.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(i)}return new Uint8Array(e)}const yK=Hh({prefix:"🚀",name:"base256emoji",encode:bK,decode:mK});var wK=Object.freeze({__proto__:null,base256emoji:yK}),vK=J_,Xw=128,_K=-128,EK=Math.pow(2,31);function J_(t,e,r){e=e||[],r=r||0;for(var i=r;t>=EK;)e[r++]=t&255|Xw,t/=128;for(;t&_K;)e[r++]=t&255|Xw,t>>>=7;return e[r]=t|0,J_.bytes=r-i+1,e}var IK=jp,AK=128,Zw=127;function jp(t,i){var r=0,i=i||0,s=0,n=i,o,a=t.length;do{if(n>=a)throw jp.bytes=0,new RangeError("Could not decode varint");o=t[n++],r+=s<28?(o&Zw)<<s:(o&Zw)*Math.pow(2,s),s+=7}while(o>=AK);return jp.bytes=n-i,r}var SK=Math.pow(2,7),CK=Math.pow(2,14),$K=Math.pow(2,21),xK=Math.pow(2,28),PK=Math.pow(2,35),NK=Math.pow(2,42),OK=Math.pow(2,49),TK=Math.pow(2,56),DK=Math.pow(2,63),RK=function(t){return t<SK?1:t<CK?2:t<$K?3:t<xK?4:t<PK?5:t<NK?6:t<OK?7:t<TK?8:t<DK?9:10},MK={encode:vK,decode:IK,encodingLength:RK},Q_=MK;const ev=(t,e,r=0)=>(Q_.encode(t,e,r),e),tv=t=>Q_.encodingLength(t),qp=(t,e)=>{const r=e.byteLength,i=tv(t),s=i+tv(r),n=new Uint8Array(s+r);return ev(t,n,0),ev(r,n,i),n.set(e,s),new kK(t,r,e,n)};class kK{constructor(e,r,i,s){this.code=e,this.size=r,this.digest=i,this.bytes=s}}const X_=({name:t,code:e,encode:r})=>new UK(t,e,r);class UK{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?qp(this.code,r):r.then(i=>qp(this.code,i))}else throw Error("Unknown type, must be binary type")}}const Z_=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),LK=X_({name:"sha2-256",code:18,encode:Z_("SHA-256")}),FK=X_({name:"sha2-512",code:19,encode:Z_("SHA-512")});var jK=Object.freeze({__proto__:null,sha256:LK,sha512:FK});const eE=0,qK="identity",tE=W_,BK=t=>qp(eE,tE(t)),zK={code:eE,name:qK,encode:tE,digest:BK};var HK=Object.freeze({__proto__:null,identity:zK});new TextEncoder,new TextDecoder;const rv={...UV,...FV,...qV,...zV,...KV,...rK,...nK,...cK,...fK,...wK};({...jK,...HK});function VK(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function rE(t,e,r,i){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:i}}}const iv=rE("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),xf=rE("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=VK(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),KK={utf8:iv,"utf-8":iv,hex:rv.base16,latin1:xf,ascii:xf,binary:xf,...rv};function WK(t,e="utf8"){const r=KK[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,"utf8"):r.decoder.decode(`${r.prefix}${t}`)}var GK=Object.defineProperty,YK=(t,e,r)=>e in t?GK(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,is=(t,e,r)=>YK(t,typeof e!="symbol"?e+"":e,r);class JK{constructor(e,r){this.core=e,this.logger=r,is(this,"keychain",new Map),is(this,"name",JH),is(this,"version",QH),is(this,"initialized",!1),is(this,"storagePrefix",hs),is(this,"init",async()=>{if(!this.initialized){const i=await this.getKeyChain();typeof i<"u"&&(this.keychain=i),this.initialized=!0}}),is(this,"has",i=>(this.isInitialized(),this.keychain.has(i))),is(this,"set",async(i,s)=>{this.isInitialized(),this.keychain.set(i,s),await this.persist()}),is(this,"get",i=>{this.isInitialized();const s=this.keychain.get(i);if(typeof s>"u"){const{message:n}=X("NO_MATCHING_KEY",`${this.name}: ${i}`);throw new Error(n)}return s}),is(this,"del",async i=>{this.isInitialized(),this.keychain.delete(i),await this.persist()}),this.core=e,this.logger=je(r,this.name)}get context(){return it(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,Pp(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Np(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=X("NOT_INITIALIZED",this.name);throw new Error(e)}}}var QK=Object.defineProperty,XK=(t,e,r)=>e in t?QK(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,_r=(t,e,r)=>XK(t,typeof e!="symbol"?e+"":e,r);class ZK{constructor(e,r,i){this.core=e,this.logger=r,_r(this,"name",GH),_r(this,"keychain"),_r(this,"randomSessionIdentifier",Up()),_r(this,"initialized",!1),_r(this,"init",async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)}),_r(this,"hasKeys",s=>(this.isInitialized(),this.keychain.has(s))),_r(this,"getClientId",async()=>{this.isInitialized();const s=await this.getClientSeed(),n=rh(s);return dg(n.publicKey)}),_r(this,"generateKeyPair",()=>{this.isInitialized();const s=Jz();return this.setPrivateKey(s.publicKey,s.privateKey)}),_r(this,"signJWT",async s=>{this.isInitialized();const n=await this.getClientSeed(),o=rh(n),a=this.randomSessionIdentifier;return await T1(a,s,YH,o)}),_r(this,"generateSharedKey",(s,n,o)=>{this.isInitialized();const a=this.getPrivateKey(s),u=Qz(a,n);return this.setSymKey(u,o)}),_r(this,"setSymKey",async(s,n)=>{this.isInitialized();const o=n||Hl(s);return await this.keychain.set(o,s),o}),_r(this,"deleteKeyPair",async s=>{this.isInitialized(),await this.keychain.del(s)}),_r(this,"deleteSymKey",async s=>{this.isInitialized(),await this.keychain.del(s)}),_r(this,"encode",async(s,n,o)=>{this.isInitialized();const a=F_(o),u=us(n);if(jw(a))return eH(u,o?.encoding);if(Fw(a)){const f=a.senderPublicKey,m=a.receiverPublicKey;s=await this.generateSharedKey(f,m)}const c=this.getSymKey(s),{type:l,senderPublicKey:h}=a;return Xz({type:l,symKey:c,message:u,senderPublicKey:h,encoding:o?.encoding})}),_r(this,"decode",async(s,n,o)=>{this.isInitialized();const a=rH(n,o);if(jw(a)){const u=tH(n,o?.encoding);return Os(u)}if(Fw(a)){const u=a.receiverPublicKey,c=a.senderPublicKey;s=await this.generateSharedKey(u,c)}try{const u=this.getSymKey(s),c=Zz({symKey:u,encoded:n,encoding:o?.encoding});return Os(c)}catch(u){this.logger.error(`Failed to decode message from topic: '${s}', clientId: '${await this.getClientId()}'`),this.logger.error(u)}}),_r(this,"getPayloadType",(s,n=rn)=>{const o=gu({encoded:s,encoding:n});return Hn(o.type)}),_r(this,"getPayloadSenderPublicKey",(s,n=rn)=>{const o=gu({encoded:s,encoding:n});return o.senderPublicKey?Fe(o.senderPublicKey,Rr):void 0}),this.core=e,this.logger=je(r,this.name),this.keychain=i||new JK(this.core,this.logger)}get context(){return it(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(Yw)}catch{e=Up(),await this.keychain.set(Yw,e)}return WK(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=X("NOT_INITIALIZED",this.name);throw new Error(e)}}}var eW=Object.defineProperty,tW=Object.defineProperties,rW=Object.getOwnPropertyDescriptors,sv=Object.getOwnPropertySymbols,iW=Object.prototype.hasOwnProperty,sW=Object.prototype.propertyIsEnumerable,Bp=(t,e,r)=>e in t?eW(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,nW=(t,e)=>{for(var r in e||(e={}))iW.call(e,r)&&Bp(t,r,e[r]);if(sv)for(var r of sv(e))sW.call(e,r)&&Bp(t,r,e[r]);return t},oW=(t,e)=>tW(t,rW(e)),si=(t,e,r)=>Bp(t,typeof e!="symbol"?e+"":e,r);class aW extends lj{constructor(e,r){super(e,r),this.logger=e,this.core=r,si(this,"messages",new Map),si(this,"messagesWithoutClientAck",new Map),si(this,"name",XH),si(this,"version",ZH),si(this,"initialized",!1),si(this,"storagePrefix",hs),si(this,"init",async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const i=await this.getRelayerMessages();typeof i<"u"&&(this.messages=i);const s=await this.getRelayerMessagesWithoutClientAck();typeof s<"u"&&(this.messagesWithoutClientAck=s),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}}}),si(this,"set",async(i,s,n)=>{this.isInitialized();const o=as(s);let a=this.messages.get(i);if(typeof a>"u"&&(a={}),typeof a[o]<"u")return o;if(a[o]=s,this.messages.set(i,a),n===Vl.inbound){const u=this.messagesWithoutClientAck.get(i)||{};this.messagesWithoutClientAck.set(i,oW(nW({},u),{[o]:s}))}return await this.persist(),o}),si(this,"get",i=>{this.isInitialized();let s=this.messages.get(i);return typeof s>"u"&&(s={}),s}),si(this,"getWithoutAck",i=>{this.isInitialized();const s={};for(const n of i){const o=this.messagesWithoutClientAck.get(n)||{};s[n]=Object.values(o)}return s}),si(this,"has",(i,s)=>{this.isInitialized();const n=this.get(i),o=as(s);return typeof n[o]<"u"}),si(this,"ack",async(i,s)=>{this.isInitialized();const n=this.messagesWithoutClientAck.get(i);if(typeof n>"u")return;const o=as(s);delete n[o],Object.keys(n).length===0?this.messagesWithoutClientAck.delete(i):this.messagesWithoutClientAck.set(i,n),await this.persist()}),si(this,"del",async i=>{this.isInitialized(),this.messages.delete(i),this.messagesWithoutClientAck.delete(i),await this.persist()}),this.logger=je(e,this.name),this.core=r}get context(){return it(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,Pp(e))}async setRelayerMessagesWithoutClientAck(e){await this.core.storage.setItem(this.storageKeyWithoutClientAck,Pp(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Np(e):void 0}async getRelayerMessagesWithoutClientAck(){const e=await this.core.storage.getItem(this.storageKeyWithoutClientAck);return typeof e<"u"?Np(e):void 0}async persist(){await this.setRelayerMessages(this.messages),await this.setRelayerMessagesWithoutClientAck(this.messagesWithoutClientAck)}isInitialized(){if(!this.initialized){const{message:e}=X("NOT_INITIALIZED",this.name);throw new Error(e)}}}var cW=Object.defineProperty,uW=Object.defineProperties,lW=Object.getOwnPropertyDescriptors,nv=Object.getOwnPropertySymbols,hW=Object.prototype.hasOwnProperty,dW=Object.prototype.propertyIsEnumerable,zp=(t,e,r)=>e in t?cW(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,$l=(t,e)=>{for(var r in e||(e={}))hW.call(e,r)&&zp(t,r,e[r]);if(nv)for(var r of nv(e))dW.call(e,r)&&zp(t,r,e[r]);return t},Pf=(t,e)=>uW(t,lW(e)),ji=(t,e,r)=>zp(t,typeof e!="symbol"?e+"":e,r);class fW extends hj{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,ji(this,"events",new sr.EventEmitter),ji(this,"name",eV),ji(this,"queue",new Map),ji(this,"publishTimeout",B.toMiliseconds(B.ONE_MINUTE)),ji(this,"initialPublishTimeout",B.toMiliseconds(B.ONE_SECOND*15)),ji(this,"needsTransportRestart",!1),ji(this,"publish",async(i,s,n)=>{var o;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:i,message:s,opts:n}});const a=n?.ttl||Jw,u=fh(n),c=n?.prompt||!1,l=n?.tag||0,h=n?.id||li().toString(),f={topic:i,message:s,opts:{ttl:a,relay:u,prompt:c,tag:l,id:h,attestation:n?.attestation,tvf:n?.tvf}},m=`Failed to publish payload, please try again. id:${h} tag:${l}`;try{const g=new Promise(async y=>{const C=({id:A})=>{f.opts.id===A&&(this.removeRequestFromQueue(A),this.relayer.events.removeListener(fr.publish,C),y(f))};this.relayer.events.on(fr.publish,C);const S=tn(new Promise((A,D)=>{this.rpcPublish({topic:i,message:s,ttl:a,prompt:c,tag:l,id:h,attestation:n?.attestation,tvf:n?.tvf}).then(A).catch(O=>{this.logger.warn(O,O?.message),D(O)})}),this.initialPublishTimeout,`Failed initial publish, retrying.... id:${h} tag:${l}`);try{await S,this.events.removeListener(fr.publish,C)}catch(A){this.queue.set(h,Pf($l({},f),{attempt:1})),this.logger.warn(A,A?.message)}});this.logger.trace({type:"method",method:"publish",params:{id:h,topic:i,message:s,opts:n}}),await tn(g,this.publishTimeout,m)}catch(g){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(g),(o=n?.internal)!=null&&o.throwOnFailedPublish)throw g}finally{this.queue.delete(h)}}),ji(this,"on",(i,s)=>{this.events.on(i,s)}),ji(this,"once",(i,s)=>{this.events.once(i,s)}),ji(this,"off",(i,s)=>{this.events.off(i,s)}),ji(this,"removeListener",(i,s)=>{this.events.removeListener(i,s)}),this.relayer=e,this.logger=je(r,this.name),this.registerEventListeners()}get context(){return it(this.logger)}async rpcPublish(e){var r,i,s,n;const{topic:o,message:a,ttl:u=Jw,prompt:c,tag:l,id:h,attestation:f,tvf:m}=e,g={method:Ac(fh().protocol).publish,params:$l({topic:o,message:a,ttl:u,prompt:c,tag:l,attestation:f},m),id:h};Ar((r=g.params)==null?void 0:r.prompt)&&((i=g.params)==null||delete i.prompt),Ar((s=g.params)==null?void 0:s.tag)&&((n=g.params)==null||delete n.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:g});const y=await this.relayer.request(g);return this.relayer.events.emit(fr.publish,e),this.logger.debug("Successfully Published Payload"),y}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async(e,r)=>{const i=e.attempt+1;this.queue.set(r,Pf($l({},e),{attempt:i}));const{topic:s,message:n,opts:o,attestation:a}=e;this.logger.warn({},`Publisher: queue->publishing: ${e.opts.id}, tag: ${e.opts.tag}, attempt: ${i}`),await this.rpcPublish(Pf($l({},e),{topic:s,message:n,ttl:o.ttl,prompt:o.prompt,tag:o.tag,id:o.id,attestation:a,tvf:o.tvf})),this.logger.warn({},`Publisher: queue->published: ${e.opts.id}`)})}registerEventListeners(){this.relayer.core.heartbeat.on(Hi.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(fr.connection_stalled);return}this.checkQueue()}),this.relayer.on(fr.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}}var pW=Object.defineProperty,gW=(t,e,r)=>e in t?pW(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Po=(t,e,r)=>gW(t,typeof e!="symbol"?e+"":e,r);class bW{constructor(){Po(this,"map",new Map),Po(this,"set",(e,r)=>{const i=this.get(e);this.exists(e,r)||this.map.set(e,[...i,r])}),Po(this,"get",e=>this.map.get(e)||[]),Po(this,"exists",(e,r)=>this.get(e).includes(r)),Po(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 s=i.filter(n=>n!==r);if(!s.length){this.map.delete(e);return}this.map.set(e,s)}),Po(this,"clear",()=>{this.map.clear()})}get topics(){return Array.from(this.map.keys())}}var mW=Object.defineProperty,yW=Object.defineProperties,wW=Object.getOwnPropertyDescriptors,ov=Object.getOwnPropertySymbols,vW=Object.prototype.hasOwnProperty,_W=Object.prototype.propertyIsEnumerable,Hp=(t,e,r)=>e in t?mW(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,bc=(t,e)=>{for(var r in e||(e={}))vW.call(e,r)&&Hp(t,r,e[r]);if(ov)for(var r of ov(e))_W.call(e,r)&&Hp(t,r,e[r]);return t},Nf=(t,e)=>yW(t,wW(e)),tt=(t,e,r)=>Hp(t,typeof e!="symbol"?e+"":e,r);class EW extends pj{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,tt(this,"subscriptions",new Map),tt(this,"topicMap",new bW),tt(this,"events",new sr.EventEmitter),tt(this,"name",aV),tt(this,"version",cV),tt(this,"pending",new Map),tt(this,"cached",[]),tt(this,"initialized",!1),tt(this,"storagePrefix",hs),tt(this,"subscribeTimeout",B.toMiliseconds(B.ONE_MINUTE)),tt(this,"initialSubscribeTimeout",B.toMiliseconds(B.ONE_SECOND*15)),tt(this,"clientId"),tt(this,"batchSubscribeTopicsLimit",500),tt(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),await this.restore()),this.initialized=!0}),tt(this,"subscribe",async(i,s)=>{this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:s}});try{const n=fh(s),o={topic:i,relay:n,transportType:s?.transportType};this.pending.set(i,o);const a=await this.rpcSubscribe(i,n,s);return typeof a=="string"&&(this.onSubscribe(a,o),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:s}})),a}catch(n){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(n),n}}),tt(this,"unsubscribe",async(i,s)=>{this.isInitialized(),typeof s?.id<"u"?await this.unsubscribeById(i,s.id,s):await this.unsubscribeByTopic(i,s)}),tt(this,"isSubscribed",i=>new Promise(s=>{s(this.topicMap.topics.includes(i))})),tt(this,"isKnownTopic",i=>new Promise(s=>{s(this.topicMap.topics.includes(i)||this.pending.has(i)||this.cached.some(n=>n.topic===i))})),tt(this,"on",(i,s)=>{this.events.on(i,s)}),tt(this,"once",(i,s)=>{this.events.once(i,s)}),tt(this,"off",(i,s)=>{this.events.off(i,s)}),tt(this,"removeListener",(i,s)=>{this.events.removeListener(i,s)}),tt(this,"start",async()=>{await this.onConnect()}),tt(this,"stop",async()=>{await this.onDisconnect()}),tt(this,"restart",async()=>{await this.restore(),await this.onRestart()}),tt(this,"checkPending",async()=>{if(this.pending.size===0&&(!this.initialized||!this.relayer.connected))return;const i=[];this.pending.forEach(s=>{i.push(s)}),await this.batchSubscribe(i)}),tt(this,"registerEventListeners",()=>{this.relayer.core.heartbeat.on(Hi.pulse,async()=>{await this.checkPending()}),this.events.on(oi.created,async i=>{const s=oi.created;this.logger.info(`Emitting ${s}`),this.logger.debug({type:"event",event:s,data:i}),await this.persist()}),this.events.on(oi.deleted,async i=>{const s=oi.deleted;this.logger.info(`Emitting ${s}`),this.logger.debug({type:"event",event:s,data:i}),await this.persist()})}),this.relayer=e,this.logger=je(r,this.name),this.clientId=""}get context(){return it(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.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 s=>await this.unsubscribeById(e,s,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 s=fh(i);await this.restartToComplete({topic:e,id:r,relay:s}),await this.rpcUnsubscribe(e,r,s);const n=Xe("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,r,n),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:r,opts:i}})}catch(s){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(s),s}}async rpcSubscribe(e,r,i){var s;(!i||i?.transportType===gt.relay)&&await this.restartToComplete({topic:e,id:e,relay:r});const n={method:Ac(r.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n});const o=(s=i?.internal)==null?void 0:s.throwOnFailedPublish;try{const a=await this.getSubscriptionId(e);if(i?.transportType===gt.link_mode)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(n).catch(l=>this.logger.warn(l))},B.toMiliseconds(B.ONE_SECOND)),a;const u=new Promise(async l=>{const h=f=>{f.topic===e&&(this.events.removeListener(oi.created,h),l(f.id))};this.events.on(oi.created,h);try{const f=await tn(new Promise((m,g)=>{this.relayer.request(n).catch(y=>{this.logger.warn(y,y?.message),g(y)}).then(m)}),this.initialSubscribeTimeout,`Subscribing to ${e} failed, please try again`);this.events.removeListener(oi.created,h),l(f)}catch{}}),c=await tn(u,this.subscribeTimeout,`Subscribing to ${e} failed, please try again`);if(!c&&o)throw new Error(`Subscribing to ${e} failed, please try again`);return c?a:null}catch(a){if(this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(fr.connection_stalled),o)throw a}return null}async rpcBatchSubscribe(e){if(!e.length)return;const r=e[0].relay,i={method:Ac(r.protocol).batchSubscribe,params:{topics:e.map(s=>s.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});try{await await tn(new Promise(s=>{this.relayer.request(i).catch(n=>this.logger.warn(n)).then(s)}),this.subscribeTimeout,"rpcBatchSubscribe failed, please try again")}catch{this.relayer.events.emit(fr.connection_stalled)}}async rpcBatchFetchMessages(e){if(!e.length)return;const r=e[0].relay,i={method:Ac(r.protocol).batchFetchMessages,params:{topics:e.map(n=>n.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});let s;try{s=await await tn(new Promise((n,o)=>{this.relayer.request(i).catch(a=>{this.logger.warn(a),o(a)}).then(n)}),this.subscribeTimeout,"rpcBatchFetchMessages failed, please try again")}catch{this.relayer.events.emit(fr.connection_stalled)}return s}rpcUnsubscribe(e,r,i){const s={method:Ac(i.protocol).unsubscribe,params:{topic:e,id:r}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s}),this.relayer.request(s)}onSubscribe(e,r){this.setSubscription(e,Nf(bc({},r),{id:e})),this.pending.delete(r.topic)}onBatchSubscribe(e){e.length&&e.forEach(r=>{this.setSubscription(r.id,bc({},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,bc({},r)),this.topicMap.set(r.topic,e),this.events.emit(oi.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}=X("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(oi.deleted,Nf(bc({},i),{reason:r}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(oi.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 s=e.splice(0,this.batchSubscribeTopicsLimit);await this.batchSubscribe(s)}}this.events.emit(oi.resubscribed)}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){const{message:r}=X("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=>Nf(bc({},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 uB(B.toMiliseconds(B.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}=X("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 as(e+await this.getClientId())}}var IW=Object.defineProperty,av=Object.getOwnPropertySymbols,AW=Object.prototype.hasOwnProperty,SW=Object.prototype.propertyIsEnumerable,Vp=(t,e,r)=>e in t?IW(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,cv=(t,e)=>{for(var r in e||(e={}))AW.call(e,r)&&Vp(t,r,e[r]);if(av)for(var r of av(e))SW.call(e,r)&&Vp(t,r,e[r]);return t},Pe=(t,e,r)=>Vp(t,typeof e!="symbol"?e+"":e,r);class CW extends dj{constructor(e){super(e),Pe(this,"protocol","wc"),Pe(this,"version",2),Pe(this,"core"),Pe(this,"logger"),Pe(this,"events",new sr.EventEmitter),Pe(this,"provider"),Pe(this,"messages"),Pe(this,"subscriber"),Pe(this,"publisher"),Pe(this,"name",rV),Pe(this,"transportExplicitlyClosed",!1),Pe(this,"initialized",!1),Pe(this,"connectionAttemptInProgress",!1),Pe(this,"relayUrl"),Pe(this,"projectId"),Pe(this,"packageName"),Pe(this,"bundleId"),Pe(this,"hasExperiencedNetworkDisruption",!1),Pe(this,"pingTimeout"),Pe(this,"heartBeatTimeout",B.toMiliseconds(B.THIRTY_SECONDS+B.FIVE_SECONDS)),Pe(this,"reconnectTimeout"),Pe(this,"connectPromise"),Pe(this,"reconnectInProgress",!1),Pe(this,"requestsInFlight",[]),Pe(this,"connectTimeout",B.toMiliseconds(B.ONE_SECOND*15)),Pe(this,"request",async r=>{var i,s;this.logger.debug("Publishing Request Payload");const n=r.id||li().toString();await this.toEstablishConnection();try{this.logger.trace({id:n,method:r.method,topic:(i=r.params)==null?void 0:i.topic},"relayer.request - publishing...");const o=`${n}:${((s=r.params)==null?void 0:s.tag)||""}`;this.requestsInFlight.push(o);const a=await this.provider.request(r);return this.requestsInFlight=this.requestsInFlight.filter(u=>u!==o),a}catch(o){throw this.logger.debug(`Failed to Publish Request: ${n}`),o}}),Pe(this,"resetPingTimeout",()=>{hh()&&(clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var r,i,s,n;try{this.logger.debug({},"pingTimeout: Connection stalled, terminating..."),(n=(s=(i=(r=this.provider)==null?void 0:r.connection)==null?void 0:i.socket)==null?void 0:s.terminate)==null||n.call(s)}catch(o){this.logger.warn(o,o?.message)}},this.heartBeatTimeout))}),Pe(this,"onPayloadHandler",r=>{this.onProviderPayload(r),this.resetPingTimeout()}),Pe(this,"onConnectHandler",()=>{this.logger.warn({},"Relayer connected 🛜"),this.startPingTimeout(),this.events.emit(fr.connect)}),Pe(this,"onDisconnectHandler",()=>{this.logger.warn({},"Relayer disconnected 🛑"),this.requestsInFlight=[],this.onProviderDisconnect()}),Pe(this,"onProviderErrorHandler",r=>{this.logger.fatal(`Fatal socket error: ${r.message}`),this.events.emit(fr.error,r),this.logger.fatal("Fatal socket error received, closing transport"),this.transportClose()}),Pe(this,"registerProviderListeners",()=>{this.provider.on(Ei.payload,this.onPayloadHandler),this.provider.on(Ei.connect,this.onConnectHandler),this.provider.on(Ei.disconnect,this.onDisconnectHandler),this.provider.on(Ei.error,this.onProviderErrorHandler)}),this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?je(e.logger,this.name):cn(Ts({level:e.logger||tV})),this.messages=new aW(this.logger,e.core),this.subscriber=new EW(this,this.logger),this.publisher=new fW(this,this.logger),this.relayUrl=e?.relayUrl||V_,this.projectId=e.projectId,Gq()?this.packageName=dw():Yq()&&(this.bundleId=dw()),this.provider={}}async init(){if(this.logger.trace("Initialized"),this.registerEventListeners(),await Promise.all([this.messages.init(),this.subscriber.init()]),this.initialized=!0,this.subscriber.hasAnyTopics)try{await this.transportOpen()}catch(e){this.logger.warn(e,e?.message)}}get context(){return it(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:gt.relay},Vl.outbound)}async subscribe(e,r){var i,s,n;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:(s=r?.internal)==null?void 0:s.throwOnFailedPublish;let a=((n=this.subscriber.topicMap.get(e))==null?void 0:n[0])||"",u;const c=l=>{l.topic===e&&(this.subscriber.off(oi.created,c),u())};return await Promise.all([new Promise(l=>{u=l,this.subscriber.on(oi.created,c)}),new Promise(async(l,h)=>{a=await this.subscriber.subscribe(e,cv({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 tn(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.warn("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 Gw())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,s)=>i.publishedAt-s.publishedAt);this.logger.debug(`Batch of ${r.length} message events sorted`);for(const i of r)try{await this.onMessageEvent(i)}catch(s){this.logger.warn(s,"Error while processing batch message event: "+s?.message)}this.logger.trace(`Batch of ${r.length} message events processed`)}async onLinkMessageEvent(e,r){const{topic:i}=e;if(!r.sessionExists){const s=er(B.FIVE_MINUTES),n={topic:i,expiry:s,relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(i,n)}this.events.emit(fr.message,e),await this.recordMessageEvent(e,Vl.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,s)=>{const n=()=>{s(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(Ei.disconnect,n),await tn(new Promise((o,a)=>{this.provider.connect().then(o).catch(a)}),this.connectTimeout,`Socket stalled when trying to connect to ${this.relayUrl}`).catch(o=>{s(o)}).finally(()=>{this.provider.off(Ei.disconnect,n),clearTimeout(this.reconnectTimeout)}),await new Promise(async(o,a)=>{const u=()=>{a(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(Ei.disconnect,u),await this.subscriber.start().then(o).catch(a).finally(()=>{this.provider.off(Ei.disconnect,u)})}),this.hasExperiencedNetworkDisruption=!1,i()})}catch(i){await this.subscriber.stop();const s=i;this.logger.warn({},s.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,B.toMiliseconds(r*1))),r++}}startPingTimeout(){var e,r,i,s,n;if(hh())try{(r=(e=this.provider)==null?void 0:e.connection)!=null&&r.socket&&((n=(s=(i=this.provider)==null?void 0:i.connection)==null?void 0:s.socket)==null||n.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 Et(new G2(Zq({sdkVersion:Fp,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:s}=e;await this.messages.set(i,s,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 s=this.messages.has(r,i);return s&&this.logger.warn(`Ignoring duplicate message: ${i}`),s}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),Sa(e)){if(!e.method.endsWith(iV))return;const r=e.params,{topic:i,message:s,publishedAt:n,attestation:o}=r.data,a={topic:i,message:s,publishedAt:n,transportType:gt.relay,attestation:o};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(cv({type:"event",event:r.id},a)),this.events.emit(r.id,a),await this.acknowledgePayload(e),await this.onMessageEvent(a)}else Yn(e)&&this.events.emit(fr.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(await this.recordMessageEvent(e,Vl.inbound),this.events.emit(fr.message,e))}async acknowledgePayload(e){const r=ln(e.id,!0);await this.provider.connection.send(r)}unregisterProviderListeners(){this.provider.off(Ei.payload,this.onPayloadHandler),this.provider.off(Ei.connect,this.onConnectHandler),this.provider.off(Ei.disconnect,this.onDisconnectHandler),this.provider.off(Ei.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await Gw();zH(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))})}async onProviderDisconnect(){clearTimeout(this.pingTimeout),this.events.emit(fr.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},B.toMiliseconds(sV)))))}isInitialized(){if(!this.initialized){const{message:e}=X("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){await this.confirmOnlineStateOrThrow(),!this.connected&&await this.connect()}}function $W(){}function uv(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 lv(t){return Object.getOwnPropertySymbols(t).filter(e=>Object.prototype.propertyIsEnumerable.call(t,e))}function hv(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const xW="[object RegExp]",PW="[object String]",NW="[object Number]",OW="[object Boolean]",dv="[object Arguments]",TW="[object Symbol]",DW="[object Date]",RW="[object Map]",MW="[object Set]",kW="[object Array]",UW="[object Function]",LW="[object ArrayBuffer]",Of="[object Object]",FW="[object Error]",jW="[object DataView]",qW="[object Uint8Array]",BW="[object Uint8ClampedArray]",zW="[object Uint16Array]",HW="[object Uint32Array]",VW="[object BigUint64Array]",KW="[object Int8Array]",WW="[object Int16Array]",GW="[object Int32Array]",YW="[object BigInt64Array]",JW="[object Float32Array]",QW="[object Float64Array]";function XW(t,e){return t===e||Number.isNaN(t)&&Number.isNaN(e)}function ZW(t,e,r){return Cc(t,e,void 0,void 0,void 0,void 0,r)}function Cc(t,e,r,i,s,n,o){const a=o(t,e,r,i,s,n);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 Mc(t,e,n,o)}return Mc(t,e,n,o)}function Mc(t,e,r,i){if(Object.is(t,e))return!0;let s=hv(t),n=hv(e);if(s===dv&&(s=Of),n===dv&&(n=Of),s!==n)return!1;switch(s){case PW:return t.toString()===e.toString();case NW:{const u=t.valueOf(),c=e.valueOf();return XW(u,c)}case OW:case DW:case TW:return Object.is(t.valueOf(),e.valueOf());case xW:return t.source===e.source&&t.flags===e.flags;case UW: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(s){case RW:{if(t.size!==e.size)return!1;for(const[u,c]of t.entries())if(!e.has(u)||!Cc(c,e.get(u),u,t,e,r,i))return!1;return!0}case MW:{if(t.size!==e.size)return!1;const u=Array.from(t.values()),c=Array.from(e.values());for(let l=0;l<u.length;l++){const h=u[l],f=c.findIndex(m=>Cc(h,m,void 0,t,e,r,i));if(f===-1)return!1;c.splice(f,1)}return!0}case kW:case qW:case BW:case zW:case HW:case VW:case KW:case WW:case GW:case YW:case JW:case QW:{if(typeof Buffer<"u"&&Buffer.isBuffer(t)!==Buffer.isBuffer(e)||t.length!==e.length)return!1;for(let u=0;u<t.length;u++)if(!Cc(t[u],e[u],u,t,e,r,i))return!1;return!0}case LW:return t.byteLength!==e.byteLength?!1:Mc(new Uint8Array(t),new Uint8Array(e),r,i);case jW:return t.byteLength!==e.byteLength||t.byteOffset!==e.byteOffset?!1:Mc(new Uint8Array(t),new Uint8Array(e),r,i);case FW:return t.name===e.name&&t.message===e.message;case Of:{if(!(Mc(t.constructor,e.constructor,r,i)||uv(t)&&uv(e)))return!1;const u=[...Object.keys(t),...lv(t)],c=[...Object.keys(e),...lv(e)];if(u.length!==c.length)return!1;for(let l=0;l<u.length;l++){const h=u[l],f=t[h];if(!Object.hasOwn(e,h))return!1;const m=e[h];if(!Cc(f,m,h,t,e,r,i))return!1}return!0}default:return!1}}finally{r.delete(t),r.delete(e)}}function eG(t,e){return ZW(t,e,$W)}var tG=Object.defineProperty,fv=Object.getOwnPropertySymbols,rG=Object.prototype.hasOwnProperty,iG=Object.prototype.propertyIsEnumerable,Kp=(t,e,r)=>e in t?tG(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,pv=(t,e)=>{for(var r in e||(e={}))rG.call(e,r)&&Kp(t,r,e[r]);if(fv)for(var r of fv(e))iG.call(e,r)&&Kp(t,r,e[r]);return t},Hr=(t,e,r)=>Kp(t,typeof e!="symbol"?e+"":e,r);class ro extends fj{constructor(e,r,i,s=hs,n=void 0){super(e,r,i,s),this.core=e,this.logger=r,this.name=i,Hr(this,"map",new Map),Hr(this,"version",nV),Hr(this,"cached",[]),Hr(this,"initialized",!1),Hr(this,"getKey"),Hr(this,"storagePrefix",hs),Hr(this,"recentlyDeleted",[]),Hr(this,"recentlyDeletedLimit",200),Hr(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(o=>{this.getKey&&o!==null&&!Ar(o)?this.map.set(this.getKey(o),o):vH(o)?this.map.set(o.id,o):_H(o)&&this.map.set(o.topic,o)}),this.cached=[],this.initialized=!0)}),Hr(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())}),Hr(this,"get",o=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:o}),this.getData(o))),Hr(this,"getAll",o=>(this.isInitialized(),o?this.values.filter(a=>Object.keys(o).every(u=>eG(a[u],o[u]))):this.values)),Hr(this,"update",async(o,a)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:o,update:a});const u=pv(pv({},this.getData(o)),a);this.map.set(o,u),await this.persist()}),Hr(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=je(r,this.name),this.storagePrefix=s,this.getKey=n}get context(){return it(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:s}=X("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(s),new Error(s)}const{message:i}=X("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}=X("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}=X("NOT_INITIALIZED",this.name);throw new Error(e)}}}var sG=Object.defineProperty,nG=(t,e,r)=>e in t?sG(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,_e=(t,e,r)=>nG(t,typeof e!="symbol"?e+"":e,r);class oG{constructor(e,r){this.core=e,this.logger=r,_e(this,"name",uV),_e(this,"version",lV),_e(this,"events",new wa),_e(this,"pairings"),_e(this,"initialized",!1),_e(this,"storagePrefix",hs),_e(this,"ignoredPayloadTypes",[Ns]),_e(this,"registeredMethods",[]),_e(this,"init",async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))}),_e(this,"register",({methods:i})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...i])]}),_e(this,"create",async i=>{this.isInitialized();const s=Up(),n=await this.core.crypto.setSymKey(s),o=er(B.FIVE_MINUTES),a={protocol:H_},u={topic:n,expiry:o,relay:a,active:!1,methods:i?.methods},c=Bw({protocol:this.core.protocol,version:this.core.version,topic:n,symKey:s,relay:a,expiryTimestamp:o,methods:i?.methods});return this.events.emit(Pn.create,u),this.core.expirer.set(n,o),await this.pairings.set(n,u),await this.core.relayer.subscribe(n,{transportType:i?.transportType}),{topic:n,uri:c}}),_e(this,"pair",async i=>{this.isInitialized();const s=this.core.eventClient.createEvent({properties:{topic:i?.uri,trace:[os.pairing_started]}});this.isValidPair(i,s);const{topic:n,symKey:o,relay:a,expiryTimestamp:u,methods:c}=qw(i.uri);s.props.properties.topic=n,s.addTrace(os.pairing_uri_validation_success),s.addTrace(os.pairing_uri_not_expired);let l;if(this.pairings.keys.includes(n)){if(l=this.pairings.get(n),s.addTrace(os.existing_pairing),l.active)throw s.setError(Cs.active_pairing_already_exists),new Error(`Pairing already exists: ${n}. Please try again with a new connection URI.`);s.addTrace(os.pairing_not_expired)}const h=u||er(B.FIVE_MINUTES),f={topic:n,relay:a,expiry:h,active:!1,methods:c};this.core.expirer.set(n,h),await this.pairings.set(n,f),s.addTrace(os.store_new_pairing),i.activatePairing&&await this.activate({topic:n}),this.events.emit(Pn.create,f),s.addTrace(os.emit_inactive_pairing),this.core.crypto.keychain.has(n)||await this.core.crypto.setSymKey(o,n),s.addTrace(os.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{s.setError(Cs.no_internet_connection)}try{await this.core.relayer.subscribe(n,{relay:a})}catch(m){throw s.setError(Cs.subscribe_pairing_topic_failure),m}return s.addTrace(os.subscribe_pairing_topic_success),f}),_e(this,"activate",async({topic:i})=>{this.isInitialized();const s=er(B.FIVE_MINUTES);this.core.expirer.set(i,s),await this.pairings.update(i,{active:!0,expiry:s})}),_e(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:s}=i;if(this.pairings.keys.includes(s)){const n=await this.sendRequest(s,"wc_pairingPing",{}),{done:o,resolve:a,reject:u}=Cn();this.events.once(Le("pairing_ping",n),({error:c})=>{c?u(c):a()}),await o()}}),_e(this,"updateExpiry",async({topic:i,expiry:s})=>{this.isInitialized(),await this.pairings.update(i,{expiry:s})}),_e(this,"updateMetadata",async({topic:i,metadata:s})=>{this.isInitialized(),await this.pairings.update(i,{peerMetadata:s})}),_e(this,"getPairings",()=>(this.isInitialized(),this.pairings.values)),_e(this,"disconnect",async i=>{this.isInitialized(),await this.isValidDisconnect(i);const{topic:s}=i;this.pairings.keys.includes(s)&&(await this.sendRequest(s,"wc_pairingDelete",Xe("USER_DISCONNECTED")),await this.deletePairing(s))}),_e(this,"formatUriFromPairing",i=>{this.isInitialized();const{topic:s,relay:n,expiry:o,methods:a}=i,u=this.core.crypto.keychain.get(s);return Bw({protocol:this.core.protocol,version:this.core.version,topic:s,symKey:u,relay:n,expiryTimestamp:o,methods:a})}),_e(this,"sendRequest",async(i,s,n)=>{const o=Lr(s,n),a=await this.core.crypto.encode(i,o),u=pc[s].req;return this.core.history.set(i,o),this.core.relayer.publish(i,a,u),o.id}),_e(this,"sendResult",async(i,s,n)=>{const o=ln(i,n),a=await this.core.crypto.encode(s,o),u=(await this.core.history.get(s,i)).request.method,c=pc[u].res;await this.core.relayer.publish(s,a,c),await this.core.history.resolve(o)}),_e(this,"sendError",async(i,s,n)=>{const o=Aa(i,n),a=await this.core.crypto.encode(s,o),u=(await this.core.history.get(s,i)).request.method,c=pc[u]?pc[u].res:pc.unregistered_method.res;await this.core.relayer.publish(s,a,c),await this.core.history.resolve(o)}),_e(this,"deletePairing",async(i,s)=>{await this.core.relayer.unsubscribe(i),await Promise.all([this.pairings.delete(i,Xe("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(i),s?Promise.resolve():this.core.expirer.del(i)])}),_e(this,"cleanup",async()=>{const i=this.pairings.getAll().filter(s=>Js(s.expiry));await Promise.all(i.map(s=>this.deletePairing(s.topic)))}),_e(this,"onRelayEventRequest",async i=>{const{topic:s,payload:n}=i;switch(n.method){case"wc_pairingPing":return await this.onPairingPingRequest(s,n);case"wc_pairingDelete":return await this.onPairingDeleteRequest(s,n);default:return await this.onUnknownRpcMethodRequest(s,n)}}),_e(this,"onRelayEventResponse",async i=>{const{topic:s,payload:n}=i,o=(await this.core.history.get(s,n.id)).request.method;return o==="wc_pairingPing"?this.onPairingPingResponse(s,n):this.onUnknownRpcMethodResponse(o)}),_e(this,"onPairingPingRequest",async(i,s)=>{const{id:n}=s;try{this.isValidPing({topic:i}),await this.sendResult(n,i,!0),this.events.emit(Pn.ping,{id:n,topic:i})}catch(o){await this.sendError(n,i,o),this.logger.error(o)}}),_e(this,"onPairingPingResponse",(i,s)=>{const{id:n}=s;setTimeout(()=>{ir(s)?this.events.emit(Le("pairing_ping",n),{}):Ht(s)&&this.events.emit(Le("pairing_ping",n),{error:s.error})},500)}),_e(this,"onPairingDeleteRequest",async(i,s)=>{const{id:n}=s;try{this.isValidDisconnect({topic:i}),await this.deletePairing(i),this.events.emit(Pn.delete,{id:n,topic:i})}catch(o){await this.sendError(n,i,o),this.logger.error(o)}}),_e(this,"onUnknownRpcMethodRequest",async(i,s)=>{const{id:n,method:o}=s;try{if(this.registeredMethods.includes(o))return;const a=Xe("WC_METHOD_UNSUPPORTED",o);await this.sendError(n,i,a),this.logger.error(a)}catch(a){await this.sendError(n,i,a),this.logger.error(a)}}),_e(this,"onUnknownRpcMethodResponse",i=>{this.registeredMethods.includes(i)||this.logger.error(Xe("WC_METHOD_UNSUPPORTED",i))}),_e(this,"isValidPair",(i,s)=>{var n;if(!Gr(i)){const{message:a}=X("MISSING_OR_INVALID",`pair() params: ${i}`);throw s.setError(Cs.malformed_pairing_uri),new Error(a)}if(!wH(i.uri)){const{message:a}=X("MISSING_OR_INVALID",`pair() uri: ${i.uri}`);throw s.setError(Cs.malformed_pairing_uri),new Error(a)}const o=qw(i?.uri);if(!((n=o?.relay)!=null&&n.protocol)){const{message:a}=X("MISSING_OR_INVALID","pair() uri#relay-protocol");throw s.setError(Cs.malformed_pairing_uri),new Error(a)}if(!(o!=null&&o.symKey)){const{message:a}=X("MISSING_OR_INVALID","pair() uri#symKey");throw s.setError(Cs.malformed_pairing_uri),new Error(a)}if(o!=null&&o.expiryTimestamp&&B.toMiliseconds(o?.expiryTimestamp)<Date.now()){s.setError(Cs.pairing_expired);const{message:a}=X("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw new Error(a)}}),_e(this,"isValidPing",async i=>{if(!Gr(i)){const{message:n}=X("MISSING_OR_INVALID",`ping() params: ${i}`);throw new Error(n)}const{topic:s}=i;await this.isValidPairingTopic(s)}),_e(this,"isValidDisconnect",async i=>{if(!Gr(i)){const{message:n}=X("MISSING_OR_INVALID",`disconnect() params: ${i}`);throw new Error(n)}const{topic:s}=i;await this.isValidPairingTopic(s)}),_e(this,"isValidPairingTopic",async i=>{if(!Jt(i,!1)){const{message:s}=X("MISSING_OR_INVALID",`pairing topic should be a string: ${i}`);throw new Error(s)}if(!this.pairings.keys.includes(i)){const{message:s}=X("NO_MATCHING_KEY",`pairing topic doesn't exist: ${i}`);throw new Error(s)}if(Js(this.pairings.get(i).expiry)){await this.deletePairing(i);const{message:s}=X("EXPIRED",`pairing topic: ${i}`);throw new Error(s)}}),this.core=e,this.logger=je(r,this.name),this.pairings=new ro(this.core,this.logger,this.name,this.storagePrefix)}get context(){return it(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=X("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(fr.message,async e=>{const{topic:r,message:i,transportType:s}=e;if(this.pairings.keys.includes(r)&&s!==gt.link_mode&&!this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i)))try{const n=await this.core.crypto.decode(r,i);Sa(n)?(this.core.history.set(r,n),await this.onRelayEventRequest({topic:r,payload:n})):Yn(n)&&(await this.core.history.resolve(n),await this.onRelayEventResponse({topic:r,payload:n}),this.core.history.delete(r,n.id)),await this.core.relayer.messages.ack(r,i)}catch(n){this.logger.error(n)}})}registerExpirerEvents(){this.core.expirer.on(Ci.expired,async e=>{const{topic:r}=g_(e.target);r&&this.pairings.keys.includes(r)&&(await this.deletePairing(r,!0),this.events.emit(Pn.expire,{topic:r}))})}}var aG=Object.defineProperty,cG=(t,e,r)=>e in t?aG(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Er=(t,e,r)=>cG(t,typeof e!="symbol"?e+"":e,r);class uG extends uj{constructor(e,r){super(e,r),this.core=e,this.logger=r,Er(this,"records",new Map),Er(this,"events",new sr.EventEmitter),Er(this,"name",hV),Er(this,"version",dV),Er(this,"cached",[]),Er(this,"initialized",!1),Er(this,"storagePrefix",hs),Er(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)}),Er(this,"set",(i,s,n)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:i,request:s,chainId:n}),this.records.has(s.id))return;const o={id:s.id,topic:i,request:{method:s.method,params:s.params||null},chainId:n,expiry:er(B.THIRTY_DAYS)};this.records.set(o.id,o),this.persist(),this.events.emit(Li.created,o)}),Er(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 s=await this.getRecord(i.id);typeof s.response>"u"&&(s.response=Ht(i)?{error:i.error}:{result:i.result},this.records.set(s.id,s),this.persist(),this.events.emit(Li.updated,s))}),Er(this,"get",async(i,s)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:i,id:s}),await this.getRecord(s))),Er(this,"delete",(i,s)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:s}),this.values.forEach(n=>{if(n.topic===i){if(typeof s<"u"&&n.id!==s)return;this.records.delete(n.id),this.events.emit(Li.deleted,n)}}),this.persist()}),Er(this,"exists",async(i,s)=>(this.isInitialized(),this.records.has(s)?(await this.getRecord(s)).topic===i:!1)),Er(this,"on",(i,s)=>{this.events.on(i,s)}),Er(this,"once",(i,s)=>{this.events.once(i,s)}),Er(this,"off",(i,s)=>{this.events.off(i,s)}),Er(this,"removeListener",(i,s)=>{this.events.removeListener(i,s)}),this.logger=je(r,this.name)}get context(){return it(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:Lr(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}=X("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return r}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(Li.sync)}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:r}=X("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(Li.created,e=>{const r=Li.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.events.on(Li.updated,e=>{const r=Li.updated;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.events.on(Li.deleted,e=>{const r=Li.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.core.heartbeat.on(Hi.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(r=>{B.toMiliseconds(r.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${r.id}`),this.records.delete(r.id),this.events.emit(Li.deleted,r,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){const{message:e}=X("NOT_INITIALIZED",this.name);throw new Error(e)}}}var lG=Object.defineProperty,hG=(t,e,r)=>e in t?lG(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Tr=(t,e,r)=>hG(t,typeof e!="symbol"?e+"":e,r);class dG extends gj{constructor(e,r){super(e,r),this.core=e,this.logger=r,Tr(this,"expirations",new Map),Tr(this,"events",new sr.EventEmitter),Tr(this,"name",fV),Tr(this,"version",pV),Tr(this,"cached",[]),Tr(this,"initialized",!1),Tr(this,"storagePrefix",hs),Tr(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)}),Tr(this,"has",i=>{try{const s=this.formatTarget(i);return typeof this.getExpiration(s)<"u"}catch{return!1}}),Tr(this,"set",(i,s)=>{this.isInitialized();const n=this.formatTarget(i),o={target:n,expiry:s};this.expirations.set(n,o),this.checkExpiry(n,o),this.events.emit(Ci.created,{target:n,expiration:o})}),Tr(this,"get",i=>{this.isInitialized();const s=this.formatTarget(i);return this.getExpiration(s)}),Tr(this,"del",i=>{if(this.isInitialized(),this.has(i)){const s=this.formatTarget(i),n=this.getExpiration(s);this.expirations.delete(s),this.events.emit(Ci.deleted,{target:s,expiration:n})}}),Tr(this,"on",(i,s)=>{this.events.on(i,s)}),Tr(this,"once",(i,s)=>{this.events.once(i,s)}),Tr(this,"off",(i,s)=>{this.events.off(i,s)}),Tr(this,"removeListener",(i,s)=>{this.events.removeListener(i,s)}),this.logger=je(r,this.name)}get context(){return it(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 eB(e);if(typeof e=="number")return tB(e);const{message:r}=X("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(Ci.sync)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:r}=X("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}=X("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(i),new Error(i)}return r}checkExpiry(e,r){const{expiry:i}=r;B.toMiliseconds(i)-Date.now()<=0&&this.expire(e,r)}expire(e,r){this.expirations.delete(e),this.events.emit(Ci.expired,{target:e,expiration:r})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,r)=>this.checkExpiry(r,e))}registerEventListeners(){this.core.heartbeat.on(Hi.pulse,()=>this.checkExpirations()),this.events.on(Ci.created,e=>{const r=Ci.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(Ci.expired,e=>{const r=Ci.expired;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(Ci.deleted,e=>{const r=Ci.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=X("NOT_INITIALIZED",this.name);throw new Error(e)}}}var fG=Object.defineProperty,pG=(t,e,r)=>e in t?fG(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Yt=(t,e,r)=>pG(t,typeof e!="symbol"?e+"":e,r);class gG extends bj{constructor(e,r,i){super(e,r,i),this.core=e,this.logger=r,this.store=i,Yt(this,"name",gV),Yt(this,"abortController"),Yt(this,"isDevEnv"),Yt(this,"verifyUrlV3",mV),Yt(this,"storagePrefix",hs),Yt(this,"version",z_),Yt(this,"publicKey"),Yt(this,"fetchPromise"),Yt(this,"init",async()=>{var s;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&B.toMiliseconds((s=this.publicKey)==null?void 0:s.expiresAt)<Date.now()&&(this.logger.debug("verify v2 public key expired"),await this.removePublicKey()))}),Yt(this,"register",async s=>{if(!Du()||this.isDevEnv)return;const n=window.location.origin,{id:o,decryptedId:a}=s,u=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${n}&id=${o}&decryptedId=${a}`;try{const c=Qr.getDocument(),l=this.startAbortTimer(B.ONE_SECOND*5),h=await new Promise((f,m)=>{const g=()=>{window.removeEventListener("message",C),c.body.removeChild(y),m("attestation aborted")};this.abortController.signal.addEventListener("abort",g);const y=c.createElement("iframe");y.src=u,y.style.display="none",y.addEventListener("error",g,{signal:this.abortController.signal});const C=S=>{if(S.data&&typeof S.data=="string")try{const A=JSON.parse(S.data);if(A.type==="verify_attestation"){if(oa(A.attestation).payload.id!==o)return;clearInterval(l),c.body.removeChild(y),this.abortController.signal.removeEventListener("abort",g),window.removeEventListener("message",C),f(A.attestation===null?"":A.attestation)}}catch(A){this.logger.warn(A)}};c.body.appendChild(y),window.addEventListener("message",C,{signal:this.abortController.signal})});return this.logger.debug("jwt attestation",h),h}catch(c){this.logger.warn(c)}return""}),Yt(this,"resolve",async s=>{if(this.isDevEnv)return"";const{attestationId:n,hash:o,encryptedId:a}=s;if(n===""){this.logger.debug("resolve: attestationId is empty, skipping");return}if(n){if(oa(n).payload.id!==a)return;const c=await this.isValidJwtAttestation(n);if(c){if(!c.isVerified){this.logger.warn("resolve: jwt attestation: origin url not verified");return}return c}}if(!o)return;const u=this.getVerifyUrl(s?.verifyUrl);return this.fetchAttestation(o,u)}),Yt(this,"fetchAttestation",async(s,n)=>{this.logger.debug(`resolving attestation: ${s} from url: ${n}`);const o=this.startAbortTimer(B.ONE_SECOND*5),a=await fetch(`${n}/attestation/${s}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(o),a.status===200?await a.json():void 0}),Yt(this,"getVerifyUrl",s=>{let n=s||Rc;return yV.includes(n)||(this.logger.info(`verify url: ${n}, not included in trusted list, assigning default: ${Rc}`),n=Rc),n}),Yt(this,"fetchPublicKey",async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);const s=this.startAbortTimer(B.FIVE_SECONDS),n=await fetch(`${this.verifyUrlV3}/public-key`,{signal:this.abortController.signal});return clearTimeout(s),await n.json()}catch(s){this.logger.warn(s)}}),Yt(this,"persistPublicKey",async s=>{this.logger.debug("persisting public key to local storage",s),await this.store.setItem(this.storeKey,s),this.publicKey=s}),Yt(this,"removePublicKey",async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0}),Yt(this,"isValidJwtAttestation",async s=>{const n=await this.getPublicKey();try{if(n)return this.validateAttestation(s,n)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation")}const o=await this.fetchAndPersistPublicKey();try{if(o)return this.validateAttestation(s,o)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation")}}),Yt(this,"getPublicKey",async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey()),Yt(this,"fetchAndPersistPublicKey",async()=>{if(this.fetchPromise)return await this.fetchPromise,this.publicKey;this.fetchPromise=new Promise(async n=>{const o=await this.fetchPublicKey();o&&(await this.persistPublicKey(o),n(o))});const s=await this.fetchPromise;return this.fetchPromise=void 0,s}),Yt(this,"validateAttestation",(s,n)=>{const o=oH(s,n.publicKey),a={hasExpired:B.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=je(r,this.name),this.abortController=new AbortController,this.isDevEnv=Rg(),this.init()}get storeKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//verify:public:key"}get context(){return it(this.logger)}startAbortTimer(e){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),B.toMiliseconds(e))}}var bG=Object.defineProperty,mG=(t,e,r)=>e in t?bG(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,gv=(t,e,r)=>mG(t,typeof e!="symbol"?e+"":e,r);class yG extends mj{constructor(e,r){super(e,r),this.projectId=e,this.logger=r,gv(this,"context",wV),gv(this,"registerDeviceToken",async i=>{const{clientId:s,token:n,notificationType:o,enableEncrypted:a=!1}=i,u=`${vV}/${this.projectId}/clients`;await fetch(u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:s,type:o,token:n,always_raw:a})})}),this.logger=je(r,this.context)}}var wG=Object.defineProperty,bv=Object.getOwnPropertySymbols,vG=Object.prototype.hasOwnProperty,_G=Object.prototype.propertyIsEnumerable,Wp=(t,e,r)=>e in t?wG(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,mc=(t,e)=>{for(var r in e||(e={}))vG.call(e,r)&&Wp(t,r,e[r]);if(bv)for(var r of bv(e))_G.call(e,r)&&Wp(t,r,e[r]);return t},cr=(t,e,r)=>Wp(t,typeof e!="symbol"?e+"":e,r);class EG extends yj{constructor(e,r,i=!0){super(e,r,i),this.core=e,this.logger=r,cr(this,"context",EV),cr(this,"storagePrefix",hs),cr(this,"storageVersion",_V),cr(this,"events",new Map),cr(this,"shouldPersist",!1),cr(this,"init",async()=>{if(!Rg())try{const s={eventId:pw(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:f_(this.core.relayer.protocol,this.core.relayer.version,Fp)}}};await this.sendEvent([s])}catch(s){this.logger.warn(s)}}),cr(this,"createEvent",s=>{const{event:n="ERROR",type:o="",properties:{topic:a,trace:u}}=s,c=pw(),l=this.core.projectId||"",h=Date.now(),f=mc({eventId:c,timestamp:h,props:{event:n,type:o,properties:{topic:a,trace:u}},bundleId:l,domain:this.getAppDomain()},this.setMethods(c));return this.telemetryEnabled&&(this.events.set(c,f),this.shouldPersist=!0),f}),cr(this,"getEvent",s=>{const{eventId:n,topic:o}=s;if(n)return this.events.get(n);const a=Array.from(this.events.values()).find(u=>u.props.properties.topic===o);if(a)return mc(mc({},a),this.setMethods(a.eventId))}),cr(this,"deleteEvent",s=>{const{eventId:n}=s;this.events.delete(n),this.shouldPersist=!0}),cr(this,"setEventListeners",()=>{this.core.heartbeat.on(Hi.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(s=>{B.fromMiliseconds(Date.now())-B.fromMiliseconds(s.timestamp)>IV&&(this.events.delete(s.eventId),this.shouldPersist=!0)})})}),cr(this,"setMethods",s=>({addTrace:n=>this.addTrace(s,n),setError:n=>this.setError(s,n)})),cr(this,"addTrace",(s,n)=>{const o=this.events.get(s);o&&(o.props.properties.trace.push(n),this.events.set(s,o),this.shouldPersist=!0)}),cr(this,"setError",(s,n)=>{const o=this.events.get(s);o&&(o.props.type=n,o.timestamp=Date.now(),this.events.set(s,o),this.shouldPersist=!0)}),cr(this,"persist",async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1}),cr(this,"restore",async()=>{try{const s=await this.core.storage.getItem(this.storageKey)||[];if(!s.length)return;s.forEach(n=>{this.events.set(n.eventId,mc(mc({},n),this.setMethods(n.eventId)))})}catch(s){this.logger.warn(s)}}),cr(this,"submit",async()=>{if(!this.telemetryEnabled||this.events.size===0)return;const s=[];for(const[n,o]of this.events)o.props.type&&s.push(o);if(s.length!==0)try{if((await this.sendEvent(s)).ok)for(const n of s)this.events.delete(n.eventId),this.shouldPersist=!0}catch(n){this.logger.warn(n)}}),cr(this,"sendEvent",async s=>{const n=this.getAppDomain()?"":"&sp=desktop";return await fetch(`${AV}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${Fp}${n}`,{method:"POST",body:JSON.stringify(s)})}),cr(this,"getAppDomain",()=>d_().url),this.logger=je(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 IG=Object.defineProperty,mv=Object.getOwnPropertySymbols,AG=Object.prototype.hasOwnProperty,SG=Object.prototype.propertyIsEnumerable,Gp=(t,e,r)=>e in t?IG(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,yv=(t,e)=>{for(var r in e||(e={}))AG.call(e,r)&&Gp(t,r,e[r]);if(mv)for(var r of mv(e))SG.call(e,r)&&Gp(t,r,e[r]);return t},ct=(t,e,r)=>Gp(t,typeof e!="symbol"?e+"":e,r);let CG=class iE extends nj{constructor(e){var r;super(e),ct(this,"protocol",B_),ct(this,"version",z_),ct(this,"name",Lp),ct(this,"relayUrl"),ct(this,"projectId"),ct(this,"customStoragePrefix"),ct(this,"events",new sr.EventEmitter),ct(this,"logger"),ct(this,"heartbeat"),ct(this,"relayer"),ct(this,"crypto"),ct(this,"storage"),ct(this,"history"),ct(this,"expirer"),ct(this,"pairing"),ct(this,"verify"),ct(this,"echoClient"),ct(this,"linkModeSupportedApps"),ct(this,"eventClient"),ct(this,"initialized",!1),ct(this,"logChunkController"),ct(this,"on",(o,a)=>this.events.on(o,a)),ct(this,"once",(o,a)=>this.events.once(o,a)),ct(this,"off",(o,a)=>this.events.off(o,a)),ct(this,"removeListener",(o,a)=>this.events.removeListener(o,a)),ct(this,"dispatchEnvelope",({topic:o,message:a,sessionExists:u})=>{if(!o||!a)return;const c={topic:o,message:a,publishedAt:Date.now(),transportType:gt.link_mode};this.relayer.onLinkMessageEvent(c,{sessionExists:u})}),this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||V_,this.customStoragePrefix=e!=null&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";const i=Ts({level:typeof e?.logger=="string"&&e.logger?e.logger:KH.logger,name:Lp}),{logger:s,chunkLoggerController:n}=sg({opts:i,maxSizeInBytes:e?.maxLogBlobSizeInBytes,loggerOverride:e?.logger});this.logChunkController=n,(r=this.logChunkController)!=null&&r.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var o,a;(o=this.logChunkController)!=null&&o.downloadLogsBlobInBrowser&&((a=this.logChunkController)==null||a.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=je(s,this.name),this.heartbeat=new Zv,this.crypto=new ZK(this,this.logger,e?.keychain),this.history=new uG(this,this.logger),this.expirer=new dG(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new r1(yv(yv({},WH),e?.storageOptions)),this.relayer=new CW({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new oG(this,this.logger),this.verify=new gG(this,this.logger,this.storage),this.echoClient=new yG(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new EG(this,this.logger,e?.telemetryEnabled)}static async init(e){const r=new iE(e);await r.initialize();const i=await r.crypto.getClientId();return await r.storage.setItem(oV,i),r}get context(){return it(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(Qw,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(Qw)||[],this.initialized=!0,this.logger.info("Core Initialization Success")}catch(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}};const $G=CG,sE="wc",nE=2,oE="client",zg=`${sE}@${nE}:${oE}:`,Tf={name:oE,logger:"error"},wv="WALLETCONNECT_DEEPLINK_CHOICE",xG="proposal",vv="Proposal expired",PG="session",No=B.SEVEN_DAYS,NG="engine",ur={wc_sessionPropose:{req:{ttl:B.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:B.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:B.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:B.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:B.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:B.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:B.ONE_DAY,prompt:!1,tag:1104},res:{ttl:B.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:B.ONE_DAY,prompt:!1,tag:1106},res:{ttl:B.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:B.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:B.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:B.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:B.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:B.ONE_DAY,prompt:!1,tag:1112},res:{ttl:B.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:B.ONE_DAY,prompt:!1,tag:1114},res:{ttl:B.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:B.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:B.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:B.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:B.FIVE_MINUTES,prompt:!1,tag:1119}}},Df={min:B.FIVE_MINUTES,max:B.SEVEN_DAYS},ss={idle:"IDLE",active:"ACTIVE"},_v={eth_sendTransaction:{key:""},eth_sendRawTransaction:{key:""},wallet_sendCalls:{key:""},solana_signTransaction:{key:"signature"},solana_signAllTransactions:{key:"transactions"},solana_signAndSendTransaction:{key:"signature"}},OG="request",TG=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],DG="wc",RG="auth",MG="authKeys",kG="pairingTopics",UG="requests",Vh=`${DG}@${1.5}:${RG}:`,Kl=`${Vh}:PUB_KEY`;var LG=Object.defineProperty,FG=Object.defineProperties,jG=Object.getOwnPropertyDescriptors,Ev=Object.getOwnPropertySymbols,qG=Object.prototype.hasOwnProperty,BG=Object.prototype.propertyIsEnumerable,Yp=(t,e,r)=>e in t?LG(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,rt=(t,e)=>{for(var r in e||(e={}))qG.call(e,r)&&Yp(t,r,e[r]);if(Ev)for(var r of Ev(e))BG.call(e,r)&&Yp(t,r,e[r]);return t},Mr=(t,e)=>FG(t,jG(e)),W=(t,e,r)=>Yp(t,typeof e!="symbol"?e+"":e,r);class zG extends Ej{constructor(e){super(e),W(this,"name",NG),W(this,"events",new wa),W(this,"initialized",!1),W(this,"requestQueue",{state:ss.idle,queue:[]}),W(this,"sessionRequestQueue",{state:ss.idle,queue:[]}),W(this,"requestQueueDelay",B.ONE_SECOND),W(this,"expectedPairingMethodMap",new Map),W(this,"recentlyDeletedMap",new Map),W(this,"recentlyDeletedLimit",200),W(this,"relayMessageCache",[]),W(this,"pendingSessions",new Map),W(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(ur)}),this.initialized=!0,setTimeout(async()=>{await this.processPendingMessageEvents(),this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},B.toMiliseconds(this.requestQueueDelay)))}),W(this,"connect",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();const i=Mr(rt({},r),{requiredNamespaces:r.requiredNamespaces||{},optionalNamespaces:r.optionalNamespaces||{}});await this.isValidConnect(i);const{pairingTopic:s,requiredNamespaces:n,optionalNamespaces:o,sessionProperties:a,scopedProperties:u,relays:c}=i;let l=s,h,f=!1;try{if(l){const x=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=x.active}}catch(x){throw this.client.logger.error(`connect() -> pairing.get(${l}) failed`),x}if(!l||!f){const{topic:x,uri:M}=await this.client.core.pairing.create();l=x,h=M}if(!l){const{message:x}=X("NO_MATCHING_KEY",`connect() pairing topic: ${l}`);throw new Error(x)}const m=await this.client.core.crypto.generateKeyPair(),g=ur.wc_sessionPropose.req.ttl||B.FIVE_MINUTES,y=er(g),C=Mr(rt(rt({requiredNamespaces:n,optionalNamespaces:o,relays:c??[{protocol:H_}],proposer:{publicKey:m,metadata:this.client.metadata},expiryTimestamp:y,pairingTopic:l},a&&{sessionProperties:a}),u&&{scopedProperties:u}),{id:hr()}),S=Le("session_connect",C.id),{reject:A,resolve:D,done:O}=Cn(g,vv),T=({id:x})=>{x===C.id&&(this.client.events.off("proposal_expire",T),this.pendingSessions.delete(C.id),this.events.emit(S,{error:{message:vv,code:0}}))};return this.client.events.on("proposal_expire",T),this.events.once(S,({error:x,session:M})=>{this.client.events.off("proposal_expire",T),x?A(x):M&&D(M)}),await this.sendRequest({topic:l,method:"wc_sessionPropose",params:C,throwOnFailedPublish:!0,clientRpcId:C.id}),await this.setProposal(C.id,C),{uri:h,approval:O}}),W(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}}),W(this,"approve",async r=>{var i,s,n;const o=this.client.core.eventClient.createEvent({properties:{topic:(i=r?.id)==null?void 0:i.toString(),trace:[Fi.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(R){throw o.setError(_n.no_internet_connection),R}try{await this.isValidProposalId(r?.id)}catch(R){throw this.client.logger.error(`approve() -> proposal.get(${r?.id}) failed`),o.setError(_n.proposal_not_found),R}try{await this.isValidApprove(r)}catch(R){throw this.client.logger.error("approve() -> isValidApprove() failed"),o.setError(_n.session_approve_namespace_validation_failure),R}const{id:a,relayProtocol:u,namespaces:c,sessionProperties:l,scopedProperties:h,sessionConfig:f}=r,m=this.client.proposal.get(a);this.client.core.eventClient.deleteEvent({eventId:o.eventId});const{pairingTopic:g,proposer:y,requiredNamespaces:C,optionalNamespaces:S}=m;let A=(s=this.client.core.eventClient)==null?void 0:s.getEvent({topic:g});A||(A=(n=this.client.core.eventClient)==null?void 0:n.createEvent({type:Fi.session_approve_started,properties:{topic:g,trace:[Fi.session_approve_started,Fi.session_namespaces_validation_success]}}));const D=await this.client.core.crypto.generateKeyPair(),O=y.publicKey,T=await this.client.core.crypto.generateSharedKey(D,O),x=rt(rt(rt({relay:{protocol:u??"irn"},namespaces:c,controller:{publicKey:D,metadata:this.client.metadata},expiry:er(No)},l&&{sessionProperties:l}),h&&{scopedProperties:h}),f&&{sessionConfig:f}),M=gt.relay;A.addTrace(Fi.subscribing_session_topic);try{await this.client.core.relayer.subscribe(T,{transportType:M})}catch(R){throw A.setError(_n.subscribe_session_topic_failure),R}A.addTrace(Fi.subscribe_session_topic_success);const U=Mr(rt({},x),{topic:T,requiredNamespaces:C,optionalNamespaces:S,pairingTopic:g,acknowledged:!1,self:x.controller,peer:{publicKey:y.publicKey,metadata:y.metadata},controller:D,transportType:gt.relay});await this.client.session.set(T,U),A.addTrace(Fi.store_session);try{A.addTrace(Fi.publishing_session_settle),await this.sendRequest({topic:T,method:"wc_sessionSettle",params:x,throwOnFailedPublish:!0}).catch(R=>{throw A?.setError(_n.session_settle_publish_failure),R}),A.addTrace(Fi.session_settle_publish_success),A.addTrace(Fi.publishing_session_approve),await this.sendResult({id:a,topic:g,result:{relay:{protocol:u??"irn"},responderPublicKey:D},throwOnFailedPublish:!0}).catch(R=>{throw A?.setError(_n.session_approve_publish_failure),R}),A.addTrace(Fi.session_approve_publish_success)}catch(R){throw this.client.logger.error(R),this.client.session.delete(T,Xe("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(T),R}return this.client.core.eventClient.deleteEvent({eventId:A.eventId}),await this.client.core.pairing.updateMetadata({topic:g,metadata:y.metadata}),await this.client.proposal.delete(a,Xe("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:g}),await this.setExpiry(T,er(No)),{topic:T,acknowledged:()=>Promise.resolve(this.client.session.get(T))}}),W(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:s}=r;let n;try{n=this.client.proposal.get(i).pairingTopic}catch(o){throw this.client.logger.error(`reject() -> proposal.get(${i}) failed`),o}n&&(await this.sendError({id:i,topic:n,error:s,rpcOpts:ur.wc_sessionPropose.reject}),await this.client.proposal.delete(i,Xe("USER_DISCONNECTED")))}),W(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:s}=r,{done:n,resolve:o,reject:a}=Cn(),u=hr(),c=li().toString(),l=this.client.session.get(i).namespaces;return this.events.once(Le("session_update",u),({error:h})=>{h?a(h):o()}),await this.client.session.update(i,{namespaces:s}),await this.sendRequest({topic:i,method:"wc_sessionUpdate",params:{namespaces:s},throwOnFailedPublish:!0,clientRpcId:u,relayRpcId:c}).catch(h=>{this.client.logger.error(h),this.client.session.update(i,{namespaces:l}),a(h)}),{acknowledged:n}}),W(this,"extend",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(r)}catch(u){throw this.client.logger.error("extend() -> isValidExtend() failed"),u}const{topic:i}=r,s=hr(),{done:n,resolve:o,reject:a}=Cn();return this.events.once(Le("session_extend",s),({error:u})=>{u?a(u):o()}),await this.setExpiry(i,er(No)),this.sendRequest({topic:i,method:"wc_sessionExtend",params:{},clientRpcId:s,throwOnFailedPublish:!0}).catch(u=>{a(u)}),{acknowledged:n}}),W(this,"request",async r=>{this.isInitialized();try{await this.isValidRequest(r)}catch(S){throw this.client.logger.error("request() -> isValidRequest() failed"),S}const{chainId:i,request:s,topic:n,expiry:o=ur.wc_sessionRequest.req.ttl}=r,a=this.client.session.get(n);a?.transportType===gt.relay&&await this.confirmOnlineStateOrThrow();const u=hr(),c=li().toString(),{done:l,resolve:h,reject:f}=Cn(o,"Request expired. Please try again.");this.events.once(Le("session_request",u),({error:S,result:A})=>{S?f(S):h(A)});const m="wc_sessionRequest",g=this.getAppLinkIfEnabled(a.peer.metadata,a.transportType);if(g)return await this.sendRequest({clientRpcId:u,relayRpcId:c,topic:n,method:m,params:{request:Mr(rt({},s),{expiryTimestamp:er(o)}),chainId:i},expiry:o,throwOnFailedPublish:!0,appLink:g}).catch(S=>f(S)),this.client.events.emit("session_request_sent",{topic:n,request:s,chainId:i,id:u}),await l();const y={request:Mr(rt({},s),{expiryTimestamp:er(o)}),chainId:i},C=this.shouldSetTVF(m,y);return await Promise.all([new Promise(async S=>{await this.sendRequest(rt({clientRpcId:u,relayRpcId:c,topic:n,method:m,params:y,expiry:o,throwOnFailedPublish:!0},C&&{tvf:this.getTVFParams(u,y)})).catch(A=>f(A)),this.client.events.emit("session_request_sent",{topic:n,request:s,chainId:i,id:u}),S()}),new Promise(async S=>{var A;if(!((A=a.sessionConfig)!=null&&A.disableDeepLink)){const D=await nB(this.client.core.storage,wv);await rB({id:u,topic:n,wcDeepLink:D})}S()}),l()]).then(S=>S[2])}),W(this,"respond",async r=>{this.isInitialized(),await this.isValidRespond(r);const{topic:i,response:s}=r,{id:n}=s,o=this.client.session.get(i);o.transportType===gt.relay&&await this.confirmOnlineStateOrThrow();const a=this.getAppLinkIfEnabled(o.peer.metadata,o.transportType);ir(s)?await this.sendResult({id:n,topic:i,result:s.result,throwOnFailedPublish:!0,appLink:a}):Ht(s)&&await this.sendError({id:n,topic:i,error:s.error,appLink:a}),this.cleanupAfterResponse(r)}),W(this,"ping",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(r)}catch(s){throw this.client.logger.error("ping() -> isValidPing() failed"),s}const{topic:i}=r;if(this.client.session.keys.includes(i)){const s=hr(),n=li().toString(),{done:o,resolve:a,reject:u}=Cn();this.events.once(Le("session_ping",s),({error:c})=>{c?u(c):a()}),await Promise.all([this.sendRequest({topic:i,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:s,relayRpcId:n}),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}))}),W(this,"emit",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(r);const{topic:i,event:s,chainId:n}=r,o=li().toString(),a=hr();await this.sendRequest({topic:i,method:"wc_sessionEvent",params:{event:s,chainId:n},throwOnFailedPublish:!0,relayRpcId:o,clientRpcId:a})}),W(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:Xe("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:s}=X("MISMATCHED_TOPIC",`Session or pairing topic not found: ${i}`);throw new Error(s)}}),W(this,"find",r=>(this.isInitialized(),this.client.session.getAll().filter(i=>mH(i,r)))),W(this,"getPendingSessionRequests",()=>this.client.pendingRequest.getAll()),W(this,"authenticate",async(r,i)=>{var s;this.isInitialized(),this.isValidAuthenticate(r);const n=i&&this.client.core.linkModeSupportedApps.includes(i)&&((s=this.client.metadata.redirect)==null?void 0:s.linkMode),o=n?gt.link_mode:gt.relay;o===gt.relay&&await this.confirmOnlineStateOrThrow();const{chains:a,statement:u="",uri:c,domain:l,nonce:h,type:f,exp:m,nbf:g,methods:y=[],expiry:C}=r,S=[...r.resources||[]],{topic:A,uri:D}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:o});this.client.logger.info({message:"Generated new pairing",pairing:{topic:A,uri:D}});const O=await this.client.core.crypto.generateKeyPair(),T=Hl(O);if(await Promise.all([this.client.auth.authKeys.set(Kl,{responseTopic:T,publicKey:O}),this.client.auth.pairingTopics.set(T,{topic:T,pairingTopic:A})]),await this.client.core.relayer.subscribe(T,{transportType:o}),this.client.logger.info(`sending request to new pairing topic: ${A}`),y.length>0){const{namespace:E}=ia(a[0]);let p=JB(E,"request",y);zl(S)&&(p=XB(p,S.pop())),S.push(p)}const x=C&&C>ur.wc_sessionAuthenticate.req.ttl?C:ur.wc_sessionAuthenticate.req.ttl,M={authPayload:{type:f??"caip122",chains:a,statement:u,aud:c,domain:l,version:"1",nonce:h,iat:new Date().toISOString(),exp:m,nbf:g,resources:S},requester:{publicKey:O,metadata:this.client.metadata},expiryTimestamp:er(x)},U={eip155:{chains:a,methods:[...new Set(["personal_sign",...y])],events:["chainChanged","accountsChanged"]}},R={requiredNamespaces:{},optionalNamespaces:U,relays:[{protocol:"irn"}],pairingTopic:A,proposer:{publicKey:O,metadata:this.client.metadata},expiryTimestamp:er(ur.wc_sessionPropose.req.ttl),id:hr()},{done:L,resolve:$,reject:d}=Cn(x,"Request expired"),b=hr(),_=Le("session_connect",R.id),w=Le("session_request",b),v=async({error:E,session:p})=>{this.events.off(w,I),E?d(E):p&&$({session:p})},I=async E=>{var p,N,q;if(await this.deletePendingAuthRequest(b,{message:"fulfilled",code:0}),E.error){const Z=Xe("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return E.error.code===Z.code?void 0:(this.events.off(_,v),d(E.error.message))}await this.deleteProposal(R.id),this.events.off(_,v);const{cacaos:H,responder:z}=E.result,V=[],Y=[];for(const Z of H){await Ew({cacao:Z,projectId:this.client.core.projectId})||(this.client.logger.error(Z,"Signature verification failed"),d(Xe("SESSION_SETTLEMENT_FAILED","Signature verification failed")));const{p:ae}=Z,ht=zl(ae.resources),ge=[Op(ae.iss)],ye=dh(ae.iss);if(ht){const Dt=Iw(ht),Ie=Aw(ht);V.push(...Dt),ge.push(...Ie)}for(const Dt of ge)Y.push(`${Dt}:${ye}`)}const te=await this.client.core.crypto.generateSharedKey(O,z.publicKey);let ie;V.length>0&&(ie={topic:te,acknowledged:!0,self:{publicKey:O,metadata:this.client.metadata},peer:z,controller:z.publicKey,expiry:er(No),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:A,namespaces:zw([...new Set(V)],[...new Set(Y)]),transportType:o},await this.client.core.relayer.subscribe(te,{transportType:o}),await this.client.session.set(te,ie),A&&await this.client.core.pairing.updateMetadata({topic:A,metadata:z.metadata}),ie=this.client.session.get(te)),(p=this.client.metadata.redirect)!=null&&p.linkMode&&(N=z.metadata.redirect)!=null&&N.linkMode&&(q=z.metadata.redirect)!=null&&q.universal&&i&&(this.client.core.addLinkModeSupportedApp(z.metadata.redirect.universal),this.client.session.update(te,{transportType:gt.link_mode})),$({auths:H,session:ie})};this.events.once(_,v),this.events.once(w,I);let P;try{if(n){const E=Lr("wc_sessionAuthenticate",M,b);this.client.core.history.set(A,E);const p=await this.client.core.crypto.encode("",E,{type:Uu,encoding:dc});P=Cl(i,A,p)}else await Promise.all([this.sendRequest({topic:A,method:"wc_sessionAuthenticate",params:M,expiry:r.expiry,throwOnFailedPublish:!0,clientRpcId:b}),this.sendRequest({topic:A,method:"wc_sessionPropose",params:R,expiry:ur.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:R.id})])}catch(E){throw this.events.off(_,v),this.events.off(w,I),E}return await this.setProposal(R.id,R),await this.setAuthRequest(b,{request:Mr(rt({},M),{verifyContext:{}}),pairingTopic:A,transportType:o}),{uri:P??D,response:L}}),W(this,"approveSessionAuthenticate",async r=>{const{id:i,auths:s}=r,n=this.client.core.eventClient.createEvent({properties:{topic:i.toString(),trace:[En.authenticated_session_approve_started]}});try{this.isInitialized()}catch(C){throw n.setError(gc.no_internet_connection),C}const o=this.getPendingAuthRequest(i);if(!o)throw n.setError(gc.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${i}`);const a=o.transportType||gt.relay;a===gt.relay&&await this.confirmOnlineStateOrThrow();const u=o.requester.publicKey,c=await this.client.core.crypto.generateKeyPair(),l=Hl(u),h={type:Ns,receiverPublicKey:u,senderPublicKey:c},f=[],m=[];for(const C of s){if(!await Ew({cacao:C,projectId:this.client.core.projectId})){n.setError(gc.invalid_cacao);const T=Xe("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:i,topic:l,error:T,encodeOpts:h}),new Error(T.message)}n.addTrace(En.cacaos_verified);const{p:S}=C,A=zl(S.resources),D=[Op(S.iss)],O=dh(S.iss);if(A){const T=Iw(A),x=Aw(A);f.push(...T),D.push(...x)}for(const T of D)m.push(`${T}:${O}`)}const g=await this.client.core.crypto.generateSharedKey(c,u);n.addTrace(En.create_authenticated_session_topic);let y;if(f?.length>0){y={topic:g,acknowledged:!0,self:{publicKey:c,metadata:this.client.metadata},peer:{publicKey:u,metadata:o.requester.metadata},controller:u,expiry:er(No),authentication:s,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:o.pairingTopic,namespaces:zw([...new Set(f)],[...new Set(m)]),transportType:a},n.addTrace(En.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(g,{transportType:a})}catch(C){throw n.setError(gc.subscribe_authenticated_session_topic_failure),C}n.addTrace(En.subscribe_authenticated_session_topic_success),await this.client.session.set(g,y),n.addTrace(En.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:o.pairingTopic,metadata:o.requester.metadata})}n.addTrace(En.publishing_authenticated_session_approve);try{await this.sendResult({topic:l,id:i,result:{cacaos:s,responder:{publicKey:c,metadata:this.client.metadata}},encodeOpts:h,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(o.requester.metadata,a)})}catch(C){throw n.setError(gc.authenticated_session_approve_publish_failure),C}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:n.eventId}),{session:y}}),W(this,"rejectSessionAuthenticate",async r=>{this.isInitialized();const{id:i,reason:s}=r,n=this.getPendingAuthRequest(i);if(!n)throw new Error(`Could not find pending auth request with id ${i}`);n.transportType===gt.relay&&await this.confirmOnlineStateOrThrow();const o=n.requester.publicKey,a=await this.client.core.crypto.generateKeyPair(),u=Hl(o),c={type:Ns,receiverPublicKey:o,senderPublicKey:a};await this.sendError({id:i,topic:u,error:s,encodeOpts:c,rpcOpts:ur.wc_sessionAuthenticate.reject,appLink:this.getAppLinkIfEnabled(n.requester.metadata,n.transportType)}),await this.client.auth.requests.delete(i,{message:"rejected",code:0}),await this.client.proposal.delete(i,Xe("USER_DISCONNECTED"))}),W(this,"formatAuthMessage",r=>{this.isInitialized();const{request:i,iss:s}=r;return A_(i,s)}),W(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)}),W(this,"cleanupDuplicatePairings",async r=>{if(r.pairingTopic)try{const i=this.client.core.pairing.pairings.get(r.pairingTopic),s=this.client.core.pairing.pairings.getAll().filter(n=>{var o,a;return((o=n.peerMetadata)==null?void 0:o.url)&&((a=n.peerMetadata)==null?void 0:a.url)===r.peer.metadata.url&&n.topic&&n.topic!==i.topic});if(s.length===0)return;this.client.logger.info(`Cleaning up ${s.length} duplicate pairing(s)`),await Promise.all(s.map(n=>this.client.core.pairing.disconnect({topic:n.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(i){this.client.logger.error(i)}}),W(this,"deleteSession",async r=>{var i;const{topic:s,expirerHasDeleted:n=!1,emitEvent:o=!0,id:a=0}=r,{self:u}=this.client.session.get(s);await this.client.core.relayer.unsubscribe(s),await this.client.session.delete(s,Xe("USER_DISCONNECTED")),this.addToRecentlyDeleted(s,"session"),this.client.core.crypto.keychain.has(u.publicKey)&&await this.client.core.crypto.deleteKeyPair(u.publicKey),this.client.core.crypto.keychain.has(s)&&await this.client.core.crypto.deleteSymKey(s),n||this.client.core.expirer.del(s),this.client.core.storage.removeItem(wv).catch(c=>this.client.logger.warn(c)),this.getPendingSessionRequests().forEach(c=>{c.topic===s&&this.deletePendingSessionRequest(c.id,Xe("USER_DISCONNECTED"))}),s===((i=this.sessionRequestQueue.queue[0])==null?void 0:i.topic)&&(this.sessionRequestQueue.state=ss.idle),o&&this.client.events.emit("session_delete",{id:a,topic:s})}),W(this,"deleteProposal",async(r,i)=>{if(i)try{const s=this.client.proposal.get(r);this.client.core.eventClient.getEvent({topic:s.pairingTopic})?.setError(_n.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(r,Xe("USER_DISCONNECTED")),i?Promise.resolve():this.client.core.expirer.del(r)]),this.addToRecentlyDeleted(r,"proposal")}),W(this,"deletePendingSessionRequest",async(r,i,s=!1)=>{await Promise.all([this.client.pendingRequest.delete(r,i),s?Promise.resolve():this.client.core.expirer.del(r)]),this.addToRecentlyDeleted(r,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(n=>n.id!==r),s&&(this.sessionRequestQueue.state=ss.idle,this.client.events.emit("session_request_expire",{id:r}))}),W(this,"deletePendingAuthRequest",async(r,i,s=!1)=>{await Promise.all([this.client.auth.requests.delete(r,i),s?Promise.resolve():this.client.core.expirer.del(r)])}),W(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}))}),W(this,"setProposal",async(r,i)=>{this.client.core.expirer.set(r,er(ur.wc_sessionPropose.req.ttl)),await this.client.proposal.set(r,i)}),W(this,"setAuthRequest",async(r,i)=>{const{request:s,pairingTopic:n,transportType:o=gt.relay}=i;this.client.core.expirer.set(r,s.expiryTimestamp),await this.client.auth.requests.set(r,{authPayload:s.authPayload,requester:s.requester,expiryTimestamp:s.expiryTimestamp,id:r,pairingTopic:n,verifyContext:s.verifyContext,transportType:o})}),W(this,"setPendingSessionRequest",async r=>{const{id:i,topic:s,params:n,verifyContext:o}=r,a=n.request.expiryTimestamp||er(ur.wc_sessionRequest.req.ttl);this.client.core.expirer.set(i,a),await this.client.pendingRequest.set(i,{id:i,topic:s,params:n,verifyContext:o})}),W(this,"sendRequest",async r=>{const{topic:i,method:s,params:n,expiry:o,relayRpcId:a,clientRpcId:u,throwOnFailedPublish:c,appLink:l,tvf:h}=r,f=Lr(s,n,u);let m;const g=!!l;try{const S=g?dc:rn;m=await this.client.core.crypto.encode(i,f,{encoding:S})}catch(S){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${i} failed`),S}let y;if(TG.includes(s)){const S=as(JSON.stringify(f)),A=as(m);y=await this.client.core.verify.register({id:A,decryptedId:S})}const C=ur[s].req;if(C.attestation=y,o&&(C.ttl=o),a&&(C.id=a),this.client.core.history.set(i,f),g){const S=Cl(l,i,m);await global.Linking.openURL(S,this.client.name)}else{const S=ur[s].req;o&&(S.ttl=o),a&&(S.id=a),S.tvf=Mr(rt({},h),{correlationId:f.id}),c?(S.internal=Mr(rt({},S.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(i,m,S)):this.client.core.relayer.publish(i,m,S).catch(A=>this.client.logger.error(A))}return f.id}),W(this,"sendResult",async r=>{const{id:i,topic:s,result:n,throwOnFailedPublish:o,encodeOpts:a,appLink:u}=r,c=ln(i,n);let l;const h=u&&typeof(global==null?void 0:global.Linking)<"u";try{const g=h?dc:rn;l=await this.client.core.crypto.encode(s,c,Mr(rt({},a||{}),{encoding:g}))}catch(g){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${s} failed`),g}let f,m;try{f=await this.client.core.history.get(s,i);const g=f.request;try{this.shouldSetTVF(g.method,g.params)&&(m=this.getTVFParams(i,g.params,n))}catch(y){this.client.logger.warn("sendResult() -> getTVFParams() failed",y)}}catch(g){throw this.client.logger.error(`sendResult() -> history.get(${s}, ${i}) failed`),g}if(h){const g=Cl(u,s,l);await global.Linking.openURL(g,this.client.name)}else{const g=f.request.method,y=ur[g].res;y.tvf=Mr(rt({},m),{correlationId:i}),o?(y.internal=Mr(rt({},y.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(s,l,y)):this.client.core.relayer.publish(s,l,y).catch(C=>this.client.logger.error(C))}await this.client.core.history.resolve(c)}),W(this,"sendError",async r=>{const{id:i,topic:s,error:n,encodeOpts:o,rpcOpts:a,appLink:u}=r,c=Aa(i,n);let l;const h=u&&typeof(global==null?void 0:global.Linking)<"u";try{const m=h?dc:rn;l=await this.client.core.crypto.encode(s,c,Mr(rt({},o||{}),{encoding:m}))}catch(m){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${s} failed`),m}let f;try{f=await this.client.core.history.get(s,i)}catch(m){throw this.client.logger.error(`sendError() -> history.get(${s}, ${i}) failed`),m}if(h){const m=Cl(u,s,l);await global.Linking.openURL(m,this.client.name)}else{const m=f.request.method,g=a||ur[m].res;this.client.core.relayer.publish(s,l,g)}await this.client.core.history.resolve(c)}),W(this,"cleanup",async()=>{const r=[],i=[];this.client.session.getAll().forEach(s=>{let n=!1;Js(s.expiry)&&(n=!0),this.client.core.crypto.keychain.has(s.topic)||(n=!0),n&&r.push(s.topic)}),this.client.proposal.getAll().forEach(s=>{Js(s.expiryTimestamp)&&i.push(s.id)}),await Promise.all([...r.map(s=>this.deleteSession({topic:s})),...i.map(s=>this.deleteProposal(s))])}),W(this,"onProviderMessageEvent",async r=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(r):await this.onRelayMessage(r)}),W(this,"onRelayEventRequest",async r=>{this.requestQueue.queue.push(r),await this.processRequestsQueue()}),W(this,"processRequestsQueue",async()=>{if(this.requestQueue.state===ss.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=ss.active;const r=this.requestQueue.queue.shift();if(r)try{await this.processRequest(r)}catch(i){this.client.logger.warn(i)}}this.requestQueue.state=ss.idle}),W(this,"processRequest",async r=>{const{topic:i,payload:s,attestation:n,transportType:o,encryptedId:a}=r,u=s.method;if(!this.shouldIgnorePairingRequest({topic:i,requestMethod:u}))switch(u){case"wc_sessionPropose":return await this.onSessionProposeRequest({topic:i,payload:s,attestation:n,encryptedId:a});case"wc_sessionSettle":return await this.onSessionSettleRequest(i,s);case"wc_sessionUpdate":return await this.onSessionUpdateRequest(i,s);case"wc_sessionExtend":return await this.onSessionExtendRequest(i,s);case"wc_sessionPing":return await this.onSessionPingRequest(i,s);case"wc_sessionDelete":return await this.onSessionDeleteRequest(i,s);case"wc_sessionRequest":return await this.onSessionRequest({topic:i,payload:s,attestation:n,encryptedId:a,transportType:o});case"wc_sessionEvent":return await this.onSessionEventRequest(i,s);case"wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:i,payload:s,attestation:n,encryptedId:a,transportType:o});default:return this.client.logger.info(`Unsupported request method ${u}`)}}),W(this,"onRelayEventResponse",async r=>{const{topic:i,payload:s,transportType:n}=r,o=(await this.client.core.history.get(i,s.id)).request.method;switch(o){case"wc_sessionPropose":return this.onSessionProposeResponse(i,s,n);case"wc_sessionSettle":return this.onSessionSettleResponse(i,s);case"wc_sessionUpdate":return this.onSessionUpdateResponse(i,s);case"wc_sessionExtend":return this.onSessionExtendResponse(i,s);case"wc_sessionPing":return this.onSessionPingResponse(i,s);case"wc_sessionRequest":return this.onSessionRequestResponse(i,s);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(i,s);default:return this.client.logger.info(`Unsupported response method ${o}`)}}),W(this,"onRelayEventUnknownPayload",r=>{const{topic:i}=r,{message:s}=X("MISSING_OR_INVALID",`Decoded payload on topic ${i} is not identifiable as a JSON-RPC request or a response.`);throw new Error(s)}),W(this,"shouldIgnorePairingRequest",r=>{const{topic:i,requestMethod:s}=r,n=this.expectedPairingMethodMap.get(i);return!n||n.includes(s)?!1:!!(n.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0)}),W(this,"onSessionProposeRequest",async r=>{const{topic:i,payload:s,attestation:n,encryptedId:o}=r,{params:a,id:u}=s;try{const c=this.client.core.eventClient.getEvent({topic:i});this.client.events.listenerCount("session_proposal")===0&&(console.warn("No listener for session_proposal event"),c?.setError(Cs.proposal_listener_not_found)),this.isValidConnect(rt({},s.params));const l=a.expiryTimestamp||er(ur.wc_sessionPropose.req.ttl),h=rt({id:u,pairingTopic:i,expiryTimestamp:l},a);await this.setProposal(u,h);const f=await this.getVerifyContext({attestationId:n,hash:as(JSON.stringify(s)),encryptedId:o,metadata:h.proposer.metadata});c?.addTrace(os.emit_session_proposal),this.client.events.emit("session_proposal",{id:u,params:h,verifyContext:f})}catch(c){await this.sendError({id:u,topic:i,error:c,rpcOpts:ur.wc_sessionPropose.autoReject}),this.client.logger.error(c)}}),W(this,"onSessionProposeResponse",async(r,i,s)=>{const{id:n}=i;if(ir(i)){const{result:o}=i;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:o});const a=this.client.proposal.get(n);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:a});const u=a.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:u});const c=o.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:c});const l=await this.client.core.crypto.generateSharedKey(u,c);this.pendingSessions.set(n,{sessionTopic:l,pairingTopic:r,proposalId:n,publicKey:u});const h=await this.client.core.relayer.subscribe(l,{transportType:s});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:h}),await this.client.core.pairing.activate({topic:r})}else if(Ht(i)){await this.client.proposal.delete(n,Xe("USER_DISCONNECTED"));const o=Le("session_connect",n);if(this.events.listenerCount(o)===0)throw new Error(`emitting ${o} without any listeners, 954`);this.events.emit(o,{error:i.error})}}),W(this,"onSessionSettleRequest",async(r,i)=>{const{id:s,params:n}=i;try{this.isValidSessionSettleRequest(n);const{relay:o,controller:a,expiry:u,namespaces:c,sessionProperties:l,scopedProperties:h,sessionConfig:f}=i.params,m=[...this.pendingSessions.values()].find(C=>C.sessionTopic===r);if(!m)return this.client.logger.error(`Pending session not found for topic ${r}`);const g=this.client.proposal.get(m.proposalId),y=Mr(rt(rt(rt({topic:r,relay:o,expiry:u,namespaces:c,acknowledged:!0,pairingTopic:m.pairingTopic,requiredNamespaces:g.requiredNamespaces,optionalNamespaces:g.optionalNamespaces,controller:a.publicKey,self:{publicKey:m.publicKey,metadata:this.client.metadata},peer:{publicKey:a.publicKey,metadata:a.metadata}},l&&{sessionProperties:l}),h&&{scopedProperties:h}),f&&{sessionConfig:f}),{transportType:gt.relay});await this.client.session.set(y.topic,y),await this.setExpiry(y.topic,y.expiry),await this.client.core.pairing.updateMetadata({topic:m.pairingTopic,metadata:y.peer.metadata}),this.client.events.emit("session_connect",{session:y}),this.events.emit(Le("session_connect",m.proposalId),{session:y}),this.pendingSessions.delete(m.proposalId),this.deleteProposal(m.proposalId,!1),this.cleanupDuplicatePairings(y),await this.sendResult({id:i.id,topic:r,result:!0,throwOnFailedPublish:!0})}catch(o){await this.sendError({id:s,topic:r,error:o}),this.client.logger.error(o)}}),W(this,"onSessionSettleResponse",async(r,i)=>{const{id:s}=i;ir(i)?(await this.client.session.update(r,{acknowledged:!0}),this.events.emit(Le("session_approve",s),{})):Ht(i)&&(await this.client.session.delete(r,Xe("USER_DISCONNECTED")),this.events.emit(Le("session_approve",s),{error:i.error}))}),W(this,"onSessionUpdateRequest",async(r,i)=>{const{params:s,id:n}=i;try{const o=`${r}_session_update`,a=fc.get(o);if(a&&this.isRequestOutOfSync(a,n)){this.client.logger.warn(`Discarding out of sync request - ${n}`),this.sendError({id:n,topic:r,error:Xe("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(rt({topic:r},s));try{fc.set(o,n),await this.client.session.update(r,{namespaces:s.namespaces}),await this.sendResult({id:n,topic:r,result:!0,throwOnFailedPublish:!0})}catch(u){throw fc.delete(o),u}this.client.events.emit("session_update",{id:n,topic:r,params:s})}catch(o){await this.sendError({id:n,topic:r,error:o}),this.client.logger.error(o)}}),W(this,"isRequestOutOfSync",(r,i)=>i.toString().slice(0,-3)<r.toString().slice(0,-3)),W(this,"onSessionUpdateResponse",(r,i)=>{const{id:s}=i,n=Le("session_update",s);if(this.events.listenerCount(n)===0)throw new Error(`emitting ${n} without any listeners`);ir(i)?this.events.emit(Le("session_update",s),{}):Ht(i)&&this.events.emit(Le("session_update",s),{error:i.error})}),W(this,"onSessionExtendRequest",async(r,i)=>{const{id:s}=i;try{this.isValidExtend({topic:r}),await this.setExpiry(r,er(No)),await this.sendResult({id:s,topic:r,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_extend",{id:s,topic:r})}catch(n){await this.sendError({id:s,topic:r,error:n}),this.client.logger.error(n)}}),W(this,"onSessionExtendResponse",(r,i)=>{const{id:s}=i,n=Le("session_extend",s);if(this.events.listenerCount(n)===0)throw new Error(`emitting ${n} without any listeners`);ir(i)?this.events.emit(Le("session_extend",s),{}):Ht(i)&&this.events.emit(Le("session_extend",s),{error:i.error})}),W(this,"onSessionPingRequest",async(r,i)=>{const{id:s}=i;try{this.isValidPing({topic:r}),await this.sendResult({id:s,topic:r,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:s,topic:r})}catch(n){await this.sendError({id:s,topic:r,error:n}),this.client.logger.error(n)}}),W(this,"onSessionPingResponse",(r,i)=>{const{id:s}=i,n=Le("session_ping",s);setTimeout(()=>{if(this.events.listenerCount(n)===0)throw new Error(`emitting ${n} without any listeners 2176`);ir(i)?this.events.emit(Le("session_ping",s),{}):Ht(i)&&this.events.emit(Le("session_ping",s),{error:i.error})},500)}),W(this,"onSessionDeleteRequest",async(r,i)=>{const{id:s}=i;try{this.isValidDisconnect({topic:r,reason:i.params}),Promise.all([new Promise(n=>{this.client.core.relayer.once(fr.publish,async()=>{n(await this.deleteSession({topic:r,id:s}))})}),this.sendResult({id:s,topic:r,result:!0,throwOnFailedPublish:!0}),this.cleanupPendingSentRequestsForTopic({topic:r,error:Xe("USER_DISCONNECTED")})]).catch(n=>this.client.logger.error(n))}catch(n){this.client.logger.error(n)}}),W(this,"onSessionRequest",async r=>{var i,s,n;const{topic:o,payload:a,attestation:u,encryptedId:c,transportType:l}=r,{id:h,params:f}=a;try{await this.isValidRequest(rt({topic:o},f));const m=this.client.session.get(o),g=await this.getVerifyContext({attestationId:u,hash:as(JSON.stringify(Lr("wc_sessionRequest",f,h))),encryptedId:c,metadata:m.peer.metadata,transportType:l}),y={id:h,topic:o,params:f,verifyContext:g};await this.setPendingSessionRequest(y),l===gt.link_mode&&(i=m.peer.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp((s=m.peer.metadata.redirect)==null?void 0:s.universal),(n=this.client.signConfig)!=null&&n.disableRequestQueue?this.emitSessionRequest(y):(this.addSessionRequestToSessionRequestQueue(y),this.processSessionRequestQueue())}catch(m){await this.sendError({id:h,topic:o,error:m}),this.client.logger.error(m)}}),W(this,"onSessionRequestResponse",(r,i)=>{const{id:s}=i,n=Le("session_request",s);if(this.events.listenerCount(n)===0)throw new Error(`emitting ${n} without any listeners`);ir(i)?this.events.emit(Le("session_request",s),{result:i.result}):Ht(i)&&this.events.emit(Le("session_request",s),{error:i.error})}),W(this,"onSessionEventRequest",async(r,i)=>{const{id:s,params:n}=i;try{const o=`${r}_session_event_${n.event.name}`,a=fc.get(o);if(a&&this.isRequestOutOfSync(a,s)){this.client.logger.info(`Discarding out of sync request - ${s}`);return}this.isValidEmit(rt({topic:r},n)),this.client.events.emit("session_event",{id:s,topic:r,params:n}),fc.set(o,s)}catch(o){await this.sendError({id:s,topic:r,error:o}),this.client.logger.error(o)}}),W(this,"onSessionAuthenticateResponse",(r,i)=>{const{id:s}=i;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:r,payload:i}),ir(i)?this.events.emit(Le("session_request",s),{result:i.result}):Ht(i)&&this.events.emit(Le("session_request",s),{error:i.error})}),W(this,"onSessionAuthenticateRequest",async r=>{var i;const{topic:s,payload:n,attestation:o,encryptedId:a,transportType:u}=r;try{const{requester:c,authPayload:l,expiryTimestamp:h}=n.params,f=await this.getVerifyContext({attestationId:o,hash:as(JSON.stringify(n)),encryptedId:a,metadata:c.metadata,transportType:u}),m={requester:c,pairingTopic:s,id:n.id,authPayload:l,verifyContext:f,expiryTimestamp:h};await this.setAuthRequest(n.id,{request:m,pairingTopic:s,transportType:u}),u===gt.link_mode&&(i=c.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp(c.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:s,params:n.params,id:n.id,verifyContext:f})}catch(c){this.client.logger.error(c);const l=n.params.requester.publicKey,h=await this.client.core.crypto.generateKeyPair(),f=this.getAppLinkIfEnabled(n.params.requester.metadata,u),m={type:Ns,receiverPublicKey:l,senderPublicKey:h};await this.sendError({id:n.id,topic:s,error:c,encodeOpts:m,rpcOpts:ur.wc_sessionAuthenticate.autoReject,appLink:f})}}),W(this,"addSessionRequestToSessionRequestQueue",r=>{this.sessionRequestQueue.queue.push(r)}),W(this,"cleanupAfterResponse",r=>{this.deletePendingSessionRequest(r.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=ss.idle,this.processSessionRequestQueue()},B.toMiliseconds(this.requestQueueDelay))}),W(this,"cleanupPendingSentRequestsForTopic",({topic:r,error:i})=>{const s=this.client.core.history.pending;s.length>0&&s.filter(n=>n.topic===r&&n.request.method==="wc_sessionRequest").forEach(n=>{const o=n.request.id,a=Le("session_request",o);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);this.events.emit(Le("session_request",n.request.id),{error:i})})}),W(this,"processSessionRequestQueue",()=>{if(this.sessionRequestQueue.state===ss.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.sessionRequestQueue.state=ss.active,this.emitSessionRequest(r)}catch(i){this.client.logger.error(i)}}),W(this,"emitSessionRequest",r=>{this.client.events.emit("session_request",r)}),W(this,"onPairingCreated",r=>{if(r.methods&&this.expectedPairingMethodMap.set(r.topic,r.methods),r.active)return;const i=this.client.proposal.getAll().find(s=>s.pairingTopic===r.topic);i&&this.onSessionProposeRequest({topic:r.topic,payload:Lr("wc_sessionPropose",Mr(rt({},i),{requiredNamespaces:i.requiredNamespaces,optionalNamespaces:i.optionalNamespaces,relays:i.relays,proposer:i.proposer,sessionProperties:i.sessionProperties,scopedProperties:i.scopedProperties}),i.id)})}),W(this,"isValidConnect",async r=>{if(!Gr(r)){const{message:c}=X("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(r)}`);throw new Error(c)}const{pairingTopic:i,requiredNamespaces:s,optionalNamespaces:n,sessionProperties:o,scopedProperties:a,relays:u}=r;if(Ar(i)||await this.isValidPairingTopic(i),!PH(u)){const{message:c}=X("MISSING_OR_INVALID",`connect() relays: ${u}`);throw new Error(c)}if(!Ar(s)&&bu(s)!==0&&this.validateNamespaces(s,"requiredNamespaces"),!Ar(n)&&bu(n)!==0&&this.validateNamespaces(n,"optionalNamespaces"),Ar(o)||this.validateSessionProps(o,"sessionProperties"),!Ar(a)){this.validateSessionProps(a,"scopedProperties");const c=Object.keys(s||{}).concat(Object.keys(n||{}));if(!Object.keys(a).every(l=>c.includes(l)))throw new Error(`Scoped properties must be a subset of required/optional namespaces, received: ${JSON.stringify(a)}, required/optional namespaces: ${JSON.stringify(c)}`)}}),W(this,"validateNamespaces",(r,i)=>{const s=xH(r,"connect()",i);if(s)throw new Error(s.message)}),W(this,"isValidApprove",async r=>{if(!Gr(r))throw new Error(X("MISSING_OR_INVALID",`approve() params: ${r}`).message);const{id:i,namespaces:s,relayProtocol:n,sessionProperties:o,scopedProperties:a}=r;this.checkRecentlyDeleted(i),await this.isValidProposalId(i);const u=this.client.proposal.get(i),c=Cf(s,"approve()");if(c)throw new Error(c.message);const l=Kw(u.requiredNamespaces,s,"approve()");if(l)throw new Error(l.message);if(!Jt(n,!0)){const{message:h}=X("MISSING_OR_INVALID",`approve() relayProtocol: ${n}`);throw new Error(h)}if(Ar(o)||this.validateSessionProps(o,"sessionProperties"),!Ar(a)){this.validateSessionProps(a,"scopedProperties");const h=new Set(Object.keys(s));if(!Object.keys(a).every(f=>h.has(f)))throw new Error(`Scoped properties must be a subset of approved namespaces, received: ${JSON.stringify(a)}, approved namespaces: ${Array.from(h).join(", ")}`)}}),W(this,"isValidReject",async r=>{if(!Gr(r)){const{message:n}=X("MISSING_OR_INVALID",`reject() params: ${r}`);throw new Error(n)}const{id:i,reason:s}=r;if(this.checkRecentlyDeleted(i),await this.isValidProposalId(i),!OH(s)){const{message:n}=X("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(s)}`);throw new Error(n)}}),W(this,"isValidSessionSettleRequest",r=>{if(!Gr(r)){const{message:c}=X("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${r}`);throw new Error(c)}const{relay:i,controller:s,namespaces:n,expiry:o}=r;if(!q_(i)){const{message:c}=X("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(c)}const a=EH(s,"onSessionSettleRequest()");if(a)throw new Error(a.message);const u=Cf(n,"onSessionSettleRequest()");if(u)throw new Error(u.message);if(Js(o)){const{message:c}=X("EXPIRED","onSessionSettleRequest()");throw new Error(c)}}),W(this,"isValidUpdate",async r=>{if(!Gr(r)){const{message:u}=X("MISSING_OR_INVALID",`update() params: ${r}`);throw new Error(u)}const{topic:i,namespaces:s}=r;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);const n=this.client.session.get(i),o=Cf(s,"update()");if(o)throw new Error(o.message);const a=Kw(n.requiredNamespaces,s,"update()");if(a)throw new Error(a.message)}),W(this,"isValidExtend",async r=>{if(!Gr(r)){const{message:s}=X("MISSING_OR_INVALID",`extend() params: ${r}`);throw new Error(s)}const{topic:i}=r;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i)}),W(this,"isValidRequest",async r=>{if(!Gr(r)){const{message:u}=X("MISSING_OR_INVALID",`request() params: ${r}`);throw new Error(u)}const{topic:i,request:s,chainId:n,expiry:o}=r;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);const{namespaces:a}=this.client.session.get(i);if(!Vw(a,n)){const{message:u}=X("MISSING_OR_INVALID",`request() chainId: ${n}`);throw new Error(u)}if(!TH(s)){const{message:u}=X("MISSING_OR_INVALID",`request() ${JSON.stringify(s)}`);throw new Error(u)}if(!MH(a,n,s.method)){const{message:u}=X("MISSING_OR_INVALID",`request() method: ${s.method}`);throw new Error(u)}if(o&&!FH(o,Df)){const{message:u}=X("MISSING_OR_INVALID",`request() expiry: ${o}. Expiry must be a number (in seconds) between ${Df.min} and ${Df.max}`);throw new Error(u)}}),W(this,"isValidRespond",async r=>{var i;if(!Gr(r)){const{message:o}=X("MISSING_OR_INVALID",`respond() params: ${r}`);throw new Error(o)}const{topic:s,response:n}=r;try{await this.isValidSessionTopic(s)}catch(o){throw(i=r?.response)!=null&&i.id&&this.cleanupAfterResponse(r),o}if(!DH(n)){const{message:o}=X("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(n)}`);throw new Error(o)}}),W(this,"isValidPing",async r=>{if(!Gr(r)){const{message:s}=X("MISSING_OR_INVALID",`ping() params: ${r}`);throw new Error(s)}const{topic:i}=r;await this.isValidSessionOrPairingTopic(i)}),W(this,"isValidEmit",async r=>{if(!Gr(r)){const{message:a}=X("MISSING_OR_INVALID",`emit() params: ${r}`);throw new Error(a)}const{topic:i,event:s,chainId:n}=r;await this.isValidSessionTopic(i);const{namespaces:o}=this.client.session.get(i);if(!Vw(o,n)){const{message:a}=X("MISSING_OR_INVALID",`emit() chainId: ${n}`);throw new Error(a)}if(!RH(s)){const{message:a}=X("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(s)}`);throw new Error(a)}if(!kH(o,n,s.name)){const{message:a}=X("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(s)}`);throw new Error(a)}}),W(this,"isValidDisconnect",async r=>{if(!Gr(r)){const{message:s}=X("MISSING_OR_INVALID",`disconnect() params: ${r}`);throw new Error(s)}const{topic:i}=r;await this.isValidSessionOrPairingTopic(i)}),W(this,"isValidAuthenticate",r=>{const{chains:i,uri:s,domain:n,nonce:o}=r;if(!Array.isArray(i)||i.length===0)throw new Error("chains is required and must be a non-empty array");if(!Jt(s,!1))throw new Error("uri is required parameter");if(!Jt(n,!1))throw new Error("domain is required parameter");if(!Jt(o,!1))throw new Error("nonce is required parameter");if([...new Set(i.map(u=>ia(u).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");const{namespace:a}=ia(i[0]);if(a!=="eip155")throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")}),W(this,"getVerifyContext",async r=>{const{attestationId:i,hash:s,encryptedId:n,metadata:o,transportType:a}=r,u={verified:{verifyUrl:o.verifyUrl||Rc,validation:"UNKNOWN",origin:o.url||""}};try{if(a===gt.link_mode){const l=this.getAppLinkIfEnabled(o,a);return u.verified.validation=l&&new URL(l).origin===new URL(o.url).origin?"VALID":"INVALID",u}const c=await this.client.core.verify.resolve({attestationId:i,hash:s,encryptedId:n,verifyUrl:o.verifyUrl});c&&(u.verified.origin=c.origin,u.verified.isScam=c.isScam,u.verified.validation=c.origin===new URL(o.url).origin?"VALID":"INVALID")}catch(c){this.client.logger.warn(c)}return this.client.logger.debug(`Verify context: ${JSON.stringify(u)}`),u}),W(this,"validateSessionProps",(r,i)=>{Object.values(r).forEach((s,n)=>{if(s==null){const{message:o}=X("MISSING_OR_INVALID",`${i} must contain an existing value for each key. Received: ${s} for key ${Object.keys(r)[n]}`);throw new Error(o)}})}),W(this,"getPendingAuthRequest",r=>{const i=this.client.auth.requests.get(r);return typeof i=="object"?i:void 0}),W(this,"addToRecentlyDeleted",(r,i)=>{if(this.recentlyDeletedMap.set(r,i),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let s=0;const n=this.recentlyDeletedLimit/2;for(const o of this.recentlyDeletedMap.keys()){if(s++>=n)break;this.recentlyDeletedMap.delete(o)}}}),W(this,"checkRecentlyDeleted",r=>{const i=this.recentlyDeletedMap.get(r);if(i){const{message:s}=X("MISSING_OR_INVALID",`Record was recently deleted - ${i}: ${r}`);throw new Error(s)}}),W(this,"isLinkModeEnabled",(r,i)=>{var s,n,o,a,u,c,l,h,f;return!r||i!==gt.link_mode?!1:((n=(s=this.client.metadata)==null?void 0:s.redirect)==null?void 0:n.linkMode)===!0&&((a=(o=this.client.metadata)==null?void 0:o.redirect)==null?void 0:a.universal)!==void 0&&((c=(u=this.client.metadata)==null?void 0:u.redirect)==null?void 0:c.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"}),W(this,"getAppLinkIfEnabled",(r,i)=>{var s;return this.isLinkModeEnabled(r,i)?(s=r?.redirect)==null?void 0:s.universal:void 0}),W(this,"handleLinkModeMessage",({url:r})=>{if(!r||!r.includes("wc_ev")||!r.includes("topic"))return;const i=fw(r,"topic")||"",s=decodeURIComponent(fw(r,"wc_ev")||""),n=this.client.session.keys.includes(i);n&&this.client.session.update(i,{transportType:gt.link_mode}),this.client.core.dispatchEnvelope({topic:i,message:s,sessionExists:n})}),W(this,"registerLinkModeListeners",async()=>{var r;if(Rg()||hn()&&(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 s=await i.getInitialURL();s&&setTimeout(()=>{this.handleLinkModeMessage({url:s})},50)}}}),W(this,"shouldSetTVF",(r,i)=>{if(!i||r!=="wc_sessionRequest")return!1;const{request:s}=i;return Object.keys(_v).includes(s.method)}),W(this,"getTVFParams",(r,i,s)=>{var n,o;try{const a=i.request.method,u=this.extractTxHashesFromResult(a,s);return Mr(rt({correlationId:r,rpcMethods:[a],chainId:i.chainId},this.isValidContractData(i.request.params)&&{contractAddresses:[(o=(n=i.request.params)==null?void 0:n[0])==null?void 0:o.to]}),{txHashes:u})}catch(a){this.client.logger.warn("Error getting TVF params",a)}return{}}),W(this,"isValidContractData",r=>{var i;if(!r)return!1;try{const s=r?.data||((i=r?.[0])==null?void 0:i.data);if(!s.startsWith("0x"))return!1;const n=s.slice(2);return/^[0-9a-fA-F]*$/.test(n)?n.length%2===0:!1}catch{}return!1}),W(this,"extractTxHashesFromResult",(r,i)=>{try{const s=_v[r];if(typeof i=="string")return[i];const n=i[s.key];if(Vn(n))return r==="solana_signAllTransactions"?n.map(o=>kB(o)):n;if(typeof n=="string")return[n]}catch(s){this.client.logger.warn("Error extracting tx hashes from result",s)}return[]})}async processPendingMessageEvents(){try{const e=this.client.session.keys,r=this.client.core.relayer.messages.getWithoutAck(e);for(const[i,s]of Object.entries(r))for(const n of s)try{await this.onProviderMessageEvent({topic:i,message:n,publishedAt:Date.now()})}catch{this.client.logger.warn(`Error processing pending message event for topic: ${i}, message: ${n}`)}}catch(e){this.client.logger.warn("processPendingMessageEvents failed",e)}}isInitialized(){if(!this.initialized){const{message:e}=X("NOT_INITIALIZED",this.name);throw new Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(fr.message,e=>{this.onProviderMessageEvent(e)})}async onRelayMessage(e){const{topic:r,message:i,attestation:s,transportType:n}=e,{publicKey:o}=this.client.auth.authKeys.keys.includes(Kl)?this.client.auth.authKeys.get(Kl):{publicKey:void 0};try{const a=await this.client.core.crypto.decode(r,i,{receiverPublicKey:o,encoding:n===gt.link_mode?dc:rn});Sa(a)?(this.client.core.history.set(r,a),await this.onRelayEventRequest({topic:r,payload:a,attestation:s,transportType:n,encryptedId:as(i)})):Yn(a)?(await this.client.core.history.resolve(a),await this.onRelayEventResponse({topic:r,payload:a,transportType:n}),this.client.core.history.delete(r,a.id)):await this.onRelayEventUnknownPayload({topic:r,payload:a,transportType:n}),await this.client.core.relayer.messages.ack(r,i)}catch(a){this.client.logger.error(a)}}registerExpirerEvents(){this.client.core.expirer.on(Ci.expired,async e=>{const{topic:r,id:i}=g_(e.target);if(i&&this.client.pendingRequest.keys.includes(i))return await this.deletePendingSessionRequest(i,X("EXPIRED"),!0);if(i&&this.client.auth.requests.keys.includes(i))return await this.deletePendingAuthRequest(i,X("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(Pn.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(Pn.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!Jt(e,!1)){const{message:r}=X("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}=X("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(r)}if(Js(this.client.core.pairing.pairings.get(e).expiry)){const{message:r}=X("EXPIRED",`pairing topic: ${e}`);throw new Error(r)}}async isValidSessionTopic(e){if(!Jt(e,!1)){const{message:r}=X("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}=X("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(r)}if(Js(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});const{message:r}=X("EXPIRED",`session topic: ${e}`);throw new Error(r)}if(!this.client.core.crypto.keychain.has(e)){const{message:r}=X("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(Jt(e,!1)){const{message:r}=X("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(r)}else{const{message:r}=X("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(r)}}async isValidProposalId(e){if(!NH(e)){const{message:r}=X("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(r)}if(!this.client.proposal.keys.includes(e)){const{message:r}=X("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(r)}if(Js(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);const{message:r}=X("EXPIRED",`proposal id: ${e}`);throw new Error(r)}}}class HG extends ro{constructor(e,r){super(e,r,xG,zg),this.core=e,this.logger=r}}let VG=class extends ro{constructor(e,r){super(e,r,PG,zg),this.core=e,this.logger=r}};class KG extends ro{constructor(e,r){super(e,r,OG,zg,i=>i.id),this.core=e,this.logger=r}}class WG extends ro{constructor(e,r){super(e,r,MG,Vh,()=>Kl),this.core=e,this.logger=r}}class GG extends ro{constructor(e,r){super(e,r,kG,Vh),this.core=e,this.logger=r}}class YG extends ro{constructor(e,r){super(e,r,UG,Vh,i=>i.id),this.core=e,this.logger=r}}var JG=Object.defineProperty,QG=(t,e,r)=>e in t?JG(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Rf=(t,e,r)=>QG(t,typeof e!="symbol"?e+"":e,r);class XG{constructor(e,r){this.core=e,this.logger=r,Rf(this,"authKeys"),Rf(this,"pairingTopics"),Rf(this,"requests"),this.authKeys=new WG(this.core,this.logger),this.pairingTopics=new GG(this.core,this.logger),this.requests=new YG(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}}var ZG=Object.defineProperty,eY=(t,e,r)=>e in t?ZG(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ee=(t,e,r)=>eY(t,typeof e!="symbol"?e+"":e,r);let tY=class aE extends _j{constructor(e){super(e),Ee(this,"protocol",sE),Ee(this,"version",nE),Ee(this,"name",Tf.name),Ee(this,"metadata"),Ee(this,"core"),Ee(this,"logger"),Ee(this,"events",new sr.EventEmitter),Ee(this,"engine"),Ee(this,"session"),Ee(this,"proposal"),Ee(this,"pendingRequest"),Ee(this,"auth"),Ee(this,"signConfig"),Ee(this,"on",(i,s)=>this.events.on(i,s)),Ee(this,"once",(i,s)=>this.events.once(i,s)),Ee(this,"off",(i,s)=>this.events.off(i,s)),Ee(this,"removeListener",(i,s)=>this.events.removeListener(i,s)),Ee(this,"removeAllListeners",i=>this.events.removeAllListeners(i)),Ee(this,"connect",async i=>{try{return await this.engine.connect(i)}catch(s){throw this.logger.error(s.message),s}}),Ee(this,"pair",async i=>{try{return await this.engine.pair(i)}catch(s){throw this.logger.error(s.message),s}}),Ee(this,"approve",async i=>{try{return await this.engine.approve(i)}catch(s){throw this.logger.error(s.message),s}}),Ee(this,"reject",async i=>{try{return await this.engine.reject(i)}catch(s){throw this.logger.error(s.message),s}}),Ee(this,"update",async i=>{try{return await this.engine.update(i)}catch(s){throw this.logger.error(s.message),s}}),Ee(this,"extend",async i=>{try{return await this.engine.extend(i)}catch(s){throw this.logger.error(s.message),s}}),Ee(this,"request",async i=>{try{return await this.engine.request(i)}catch(s){throw this.logger.error(s.message),s}}),Ee(this,"respond",async i=>{try{return await this.engine.respond(i)}catch(s){throw this.logger.error(s.message),s}}),Ee(this,"ping",async i=>{try{return await this.engine.ping(i)}catch(s){throw this.logger.error(s.message),s}}),Ee(this,"emit",async i=>{try{return await this.engine.emit(i)}catch(s){throw this.logger.error(s.message),s}}),Ee(this,"disconnect",async i=>{try{return await this.engine.disconnect(i)}catch(s){throw this.logger.error(s.message),s}}),Ee(this,"find",i=>{try{return this.engine.find(i)}catch(s){throw this.logger.error(s.message),s}}),Ee(this,"getPendingSessionRequests",()=>{try{return this.engine.getPendingSessionRequests()}catch(i){throw this.logger.error(i.message),i}}),Ee(this,"authenticate",async(i,s)=>{try{return await this.engine.authenticate(i,s)}catch(n){throw this.logger.error(n.message),n}}),Ee(this,"formatAuthMessage",i=>{try{return this.engine.formatAuthMessage(i)}catch(s){throw this.logger.error(s.message),s}}),Ee(this,"approveSessionAuthenticate",async i=>{try{return await this.engine.approveSessionAuthenticate(i)}catch(s){throw this.logger.error(s.message),s}}),Ee(this,"rejectSessionAuthenticate",async i=>{try{return await this.engine.rejectSessionAuthenticate(i)}catch(s){throw this.logger.error(s.message),s}}),this.name=e?.name||Tf.name,this.metadata=e?.metadata||d_(),this.signConfig=e?.signConfig;const r=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:cn(Ts({level:e?.logger||Tf.logger}));this.core=e?.core||new $G(e),this.logger=je(r,this.name),this.session=new VG(this.core,this.logger),this.proposal=new HG(this.core,this.logger),this.pendingRequest=new KG(this.core,this.logger),this.engine=new zG(this),this.auth=new XG(this.core,this.logger)}static async init(e){const r=new aE(e);return await r.initialize(),r}get context(){return it(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"),setTimeout(()=>{this.engine.processRelayMessageCache()},B.toMiliseconds(B.ONE_SECOND))}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}};const Iv="error",rY="wss://relay.walletconnect.org",iY="wc",sY="universal_provider",xl=`${iY}@2:${sY}:`,cE="https://rpc.walletconnect.org/v1/",Go="generic",nY=`${cE}bundler`,Ni={DEFAULT_CHAIN_CHANGED:"default_chain_changed"};function oY(){}function Hg(t){return t==null||typeof t!="object"&&typeof t!="function"}function Vg(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function aY(t){if(Hg(t))return t;if(Array.isArray(t)||Vg(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 Av(t){return typeof t=="object"&&t!==null}function uE(t){return Object.getOwnPropertySymbols(t).filter(e=>Object.prototype.propertyIsEnumerable.call(t,e))}function lE(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const cY="[object RegExp]",hE="[object String]",dE="[object Number]",fE="[object Boolean]",pE="[object Arguments]",uY="[object Symbol]",lY="[object Date]",hY="[object Map]",dY="[object Set]",fY="[object Array]",pY="[object ArrayBuffer]",gY="[object Object]",bY="[object DataView]",mY="[object Uint8Array]",yY="[object Uint8ClampedArray]",wY="[object Uint16Array]",vY="[object Uint32Array]",_Y="[object Int8Array]",EY="[object Int16Array]",IY="[object Int32Array]",AY="[object Float32Array]",SY="[object Float64Array]";function CY(t,e){return Zo(t,void 0,t,new Map,e)}function Zo(t,e,r,i=new Map,s=void 0){const n=s?.(t,e,r,i);if(n!=null)return n;if(Hg(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]=Zo(t[a],a,r,i,s);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,u]of t)o.set(a,Zo(u,a,r,i,s));return o}if(t instanceof Set){const o=new Set;i.set(t,o);for(const a of t)o.add(Zo(a,void 0,r,i,s));return o}if(typeof Buffer<"u"&&Buffer.isBuffer(t))return t.subarray();if(Vg(t)){const o=new(Object.getPrototypeOf(t)).constructor(t.length);i.set(t,o);for(let a=0;a<t.length;a++)o[a]=Zo(t[a],a,r,i,s);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),Nn(o,t,r,i,s),o}if(typeof File<"u"&&t instanceof File){const o=new File([t],t.name,{type:t.type});return i.set(t,o),Nn(o,t,r,i,s),o}if(t instanceof Blob){const o=new Blob([t],{type:t.type});return i.set(t,o),Nn(o,t,r,i,s),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,Nn(o,t,r,i,s),o}if(typeof t=="object"&&$Y(t)){const o=Object.create(Object.getPrototypeOf(t));return i.set(t,o),Nn(o,t,r,i,s),o}return t}function Nn(t,e,r=t,i,s){const n=[...Object.keys(e),...uE(e)];for(let o=0;o<n.length;o++){const a=n[o],u=Object.getOwnPropertyDescriptor(t,a);(u==null||u.writable)&&(t[a]=Zo(e[a],a,r,i,s))}}function $Y(t){switch(lE(t)){case pE:case fY:case pY:case bY:case fE:case lY:case AY:case SY:case _Y:case EY:case IY:case hY:case dE:case gY:case cY:case dY:case hE:case uY:case mY:case yY:case wY:case vY:return!0;default:return!1}}function xY(t,e){return CY(t,(r,i,s,n)=>{if(typeof t=="object")switch(Object.prototype.toString.call(t)){case dE:case hE:case fE:{const o=new t.constructor(t?.valueOf());return Nn(o,t),o}case pE:{const o={};return Nn(o,t),o.length=t.length,o[Symbol.iterator]=t[Symbol.iterator],o}default:return}})}function Sv(t){return xY(t)}function Cv(t){return t!==null&&typeof t=="object"&&lE(t)==="[object Arguments]"}function PY(t){return Vg(t)}function NY(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 OY(t,...e){const r=e.slice(0,-1),i=e[e.length-1];let s=t;for(let n=0;n<r.length;n++){const o=r[n];s=Jp(s,o,i,new Map)}return s}function Jp(t,e,r,i){if(Hg(t)&&(t=Object(t)),e==null||typeof e!="object")return t;if(i.has(e))return aY(i.get(e));if(i.set(e,t),Array.isArray(e)){e=e.slice();for(let n=0;n<e.length;n++)e[n]=e[n]??void 0}const s=[...Object.keys(e),...uE(e)];for(let n=0;n<s.length;n++){const o=s[n];let a=e[o],u=t[o];if(Cv(a)&&(a={...a}),Cv(u)&&(u={...u}),typeof Buffer<"u"&&Buffer.isBuffer(a)&&(a=Sv(a)),Array.isArray(a))if(typeof u=="object"&&u!=null){const l=[],h=Reflect.ownKeys(u);for(let f=0;f<h.length;f++){const m=h[f];l[m]=u[m]}u=l}else u=[];const c=r(u,a,o,t,e,i);c!=null?t[o]=c:Array.isArray(a)||Av(u)&&Av(a)?t[o]=Jp(u,a,r,i):u==null&&NY(a)?t[o]=Jp({},a,r,i):u==null&&PY(a)?t[o]=Sv(a):(u===void 0||a!==void 0)&&(t[o]=a)}return t}function TY(t,...e){return OY(t,...e,oY)}var DY=Object.defineProperty,RY=Object.defineProperties,MY=Object.getOwnPropertyDescriptors,$v=Object.getOwnPropertySymbols,kY=Object.prototype.hasOwnProperty,UY=Object.prototype.propertyIsEnumerable,xv=(t,e,r)=>e in t?DY(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Pl=(t,e)=>{for(var r in e||(e={}))kY.call(e,r)&&xv(t,r,e[r]);if($v)for(var r of $v(e))UY.call(e,r)&&xv(t,r,e[r]);return t},LY=(t,e)=>RY(t,MY(e));function fi(t,e,r){var i;const s=ia(t);return((i=e.rpcMap)==null?void 0:i[s.reference])||`${cE}?chainId=${s.namespace}:${s.reference}&projectId=${r}`}function io(t){return t.includes(":")?t.split(":")[1]:t}function gE(t){return t.map(e=>`${e.split(":")[0]}:${e.split(":")[1]}`)}function FY(t,e){const r=Object.keys(e.namespaces).filter(s=>s.includes(t));if(!r.length)return[];const i=[];return r.forEach(s=>{const n=e.namespaces[s].accounts;i.push(...n)}),i}function Mf(t={},e={}){const r=Pv(t),i=Pv(e);return TY(r,i)}function Pv(t){var e,r,i,s;const n={};if(!bu(t))return n;for(const[o,a]of Object.entries(t)){const u=qg(o)?[o]:a.chains,c=a.methods||[],l=a.events||[],h=a.rpcMap||{},f=Sc(o);n[f]=LY(Pl(Pl({},n[f]),a),{chains:Bl(u,(e=n[f])==null?void 0:e.chains),methods:Bl(c,(r=n[f])==null?void 0:r.methods),events:Bl(l,(i=n[f])==null?void 0:i.events),rpcMap:Pl(Pl({},h),(s=n[f])==null?void 0:s.rpcMap)})}return n}function jY(t){return t.includes(":")?t.split(":")[2]:t}function Nv(t){const e={};for(const[r,i]of Object.entries(t)){const s=i.methods||[],n=i.events||[],o=i.accounts||[],a=qg(r)?[r]:i.chains?i.chains:gE(i.accounts);e[r]={chains:a,methods:s,events:n,accounts:o}}return e}function kf(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))}const bE={},Oe=t=>bE[t],Uf=(t,e)=>{bE[t]=e};var qY=Object.defineProperty,BY=(t,e,r)=>e in t?qY(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Oo=(t,e,r)=>BY(t,typeof e!="symbol"?e+"":e,r);class zY{constructor(e){Oo(this,"name","polkadot"),Oo(this,"client"),Oo(this,"httpProviders"),Oo(this,"events"),Oo(this,"namespace"),Oo(this,"chainId"),this.namespace=e.namespace,this.events=Oe("events"),this.client=Oe("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}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]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(Ni.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var i;const s=io(r);e[s]=this.createHttpProvider(s,(i=this.namespace.rpcMap)==null?void 0:i[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const i=this.createHttpProvider(e,r);i&&(this.httpProviders[e]=i)}createHttpProvider(e,r){const i=r||fi(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new Et(new Vt(i,Oe("disableProviderPing")))}}var HY=Object.defineProperty,VY=Object.defineProperties,KY=Object.getOwnPropertyDescriptors,Ov=Object.getOwnPropertySymbols,WY=Object.prototype.hasOwnProperty,GY=Object.prototype.propertyIsEnumerable,Qp=(t,e,r)=>e in t?HY(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Tv=(t,e)=>{for(var r in e||(e={}))WY.call(e,r)&&Qp(t,r,e[r]);if(Ov)for(var r of Ov(e))GY.call(e,r)&&Qp(t,r,e[r]);return t},Dv=(t,e)=>VY(t,KY(e)),To=(t,e,r)=>Qp(t,typeof e!="symbol"?e+"":e,r);class YY{constructor(e){To(this,"name","eip155"),To(this,"client"),To(this,"chainId"),To(this,"namespace"),To(this,"httpProviders"),To(this,"events"),this.namespace=e.namespace,this.events=Oe("events"),this.client=Oe("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}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)}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),this.chainId=parseInt(e),this.events.emit(Ni.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}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||fi(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new Et(new Vt(i,Oe("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 s=parseInt(io(r));e[s]=this.createHttpProvider(s,(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(){const e=this.chainId,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}async handleSwitchChain(e){var r,i;let s=e.request.params?(r=e.request.params[0])==null?void 0:r.chainId:"0x0";s=s.startsWith("0x")?s:`0x${s}`;const n=parseInt(s,16);if(this.isChainApproved(n))this.setDefaultChain(`${n}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:e.topic,request:{method:e.request.method,params:[{chainId:s}]},chainId:(i=this.namespace.chains)==null?void 0:i[0]}),this.setDefaultChain(`${n}`);else throw new Error(`Failed to switch to chain 'eip155:${n}'. 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,s;const n=(i=(r=e.request)==null?void 0:r.params)==null?void 0:i[0];if(!n)throw new Error("Missing address parameter in `wallet_getCapabilities` request");const o=this.client.session.get(e.topic),a=((s=o?.sessionProperties)==null?void 0:s.capabilities)||{};if(a!=null&&a[n])return a?.[n];const u=await this.client.request(e);try{await this.client.session.update(e.topic,{sessionProperties:Dv(Tv({},o.sessionProperties||{}),{capabilities:Dv(Tv({},a||{}),{[n]:u})})})}catch(c){console.warn("Failed to update session with capabilities",c)}return u}async getCallStatus(e){var r,i;const s=this.client.session.get(e.topic),n=(r=s.sessionProperties)==null?void 0:r.bundler_name;if(n){const a=this.getBundlerUrl(e.chainId,n);try{return await this.getUserOperationReceipt(a,e)}catch(u){console.warn("Failed to fetch call status from bundler",u,a)}}const o=(i=s.sessionProperties)==null?void 0:i.bundler_url;if(o)try{return await this.getUserOperationReceipt(o,e)}catch(a){console.warn("Failed to fetch call status from custom bundler",a,o)}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 s=new URL(e),n=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Lr("eth_getUserOperationReceipt",[(i=r.request.params)==null?void 0:i[0]]))});if(!n.ok)throw new Error(`Failed to fetch user operation receipt - ${n.status}`);return await n.json()}getBundlerUrl(e,r){return`${nY}?projectId=${this.client.core.projectId}&chainId=${e}&bundler=${r}`}}var JY=Object.defineProperty,QY=(t,e,r)=>e in t?JY(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Do=(t,e,r)=>QY(t,typeof e!="symbol"?e+"":e,r);class XY{constructor(e){Do(this,"name","solana"),Do(this,"client"),Do(this,"httpProviders"),Do(this,"events"),Do(this,"namespace"),Do(this,"chainId"),this.namespace=e.namespace,this.events=Oe("events"),this.client=Oe("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(Ni.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}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]}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(){const e={};return this.namespace.chains.forEach(r=>{var i;const s=io(r);e[s]=this.createHttpProvider(s,(i=this.namespace.rpcMap)==null?void 0:i[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const i=this.createHttpProvider(e,r);i&&(this.httpProviders[e]=i)}createHttpProvider(e,r){const i=r||fi(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new Et(new Vt(i,Oe("disableProviderPing")))}}var ZY=Object.defineProperty,eJ=(t,e,r)=>e in t?ZY(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ro=(t,e,r)=>eJ(t,typeof e!="symbol"?e+"":e,r);class tJ{constructor(e){Ro(this,"name","cosmos"),Ro(this,"client"),Ro(this,"httpProviders"),Ro(this,"events"),Ro(this,"namespace"),Ro(this,"chainId"),this.namespace=e.namespace,this.events=Oe("events"),this.client=Oe("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}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]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(Ni.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}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(){const e={};return this.namespace.chains.forEach(r=>{var i;const s=io(r);e[s]=this.createHttpProvider(s,(i=this.namespace.rpcMap)==null?void 0:i[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const i=this.createHttpProvider(e,r);i&&(this.httpProviders[e]=i)}createHttpProvider(e,r){const i=r||fi(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new Et(new Vt(i,Oe("disableProviderPing")))}}var rJ=Object.defineProperty,iJ=(t,e,r)=>e in t?rJ(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Mo=(t,e,r)=>iJ(t,typeof e!="symbol"?e+"":e,r);class sJ{constructor(e){Mo(this,"name","algorand"),Mo(this,"client"),Mo(this,"httpProviders"),Mo(this,"events"),Mo(this,"namespace"),Mo(this,"chainId"),this.namespace=e.namespace,this.events=Oe("events"),this.client=Oe("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){if(!this.httpProviders[e]){const i=r||fi(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,i)}this.chainId=e,this.events.emit(Ni.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}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]}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(){const e={};return this.namespace.chains.forEach(r=>{var i;e[r]=this.createHttpProvider(r,(i=this.namespace.rpcMap)==null?void 0:i[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const i=this.createHttpProvider(e,r);i&&(this.httpProviders[e]=i)}createHttpProvider(e,r){const i=r||fi(e,this.namespace,this.client.core.projectId);return typeof i>"u"?void 0:new Et(new Vt(i,Oe("disableProviderPing")))}}var nJ=Object.defineProperty,oJ=(t,e,r)=>e in t?nJ(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ko=(t,e,r)=>oJ(t,typeof e!="symbol"?e+"":e,r);class aJ{constructor(e){ko(this,"name","cip34"),ko(this,"client"),ko(this,"httpProviders"),ko(this,"events"),ko(this,"namespace"),ko(this,"chainId"),this.namespace=e.namespace,this.events=Oe("events"),this.client=Oe("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}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]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(Ni.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}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(){const e={};return this.namespace.chains.forEach(r=>{const i=this.getCardanoRPCUrl(r),s=io(r);e[s]=this.createHttpProvider(s,i)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}getCardanoRPCUrl(e){const r=this.namespace.rpcMap;if(r)return r[e]}setHttpProvider(e,r){const i=this.createHttpProvider(e,r);i&&(this.httpProviders[e]=i)}createHttpProvider(e,r){const i=r||this.getCardanoRPCUrl(e);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new Et(new Vt(i,Oe("disableProviderPing")))}}var cJ=Object.defineProperty,uJ=(t,e,r)=>e in t?cJ(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Uo=(t,e,r)=>uJ(t,typeof e!="symbol"?e+"":e,r);class lJ{constructor(e){Uo(this,"name","elrond"),Uo(this,"client"),Uo(this,"httpProviders"),Uo(this,"events"),Uo(this,"namespace"),Uo(this,"chainId"),this.namespace=e.namespace,this.events=Oe("events"),this.client=Oe("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(Ni.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}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]}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(){const e={};return this.namespace.chains.forEach(r=>{var i;const s=io(r);e[s]=this.createHttpProvider(s,(i=this.namespace.rpcMap)==null?void 0:i[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const i=this.createHttpProvider(e,r);i&&(this.httpProviders[e]=i)}createHttpProvider(e,r){const i=r||fi(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new Et(new Vt(i,Oe("disableProviderPing")))}}var hJ=Object.defineProperty,dJ=(t,e,r)=>e in t?hJ(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Lo=(t,e,r)=>dJ(t,typeof e!="symbol"?e+"":e,r);class fJ{constructor(e){Lo(this,"name","multiversx"),Lo(this,"client"),Lo(this,"httpProviders"),Lo(this,"events"),Lo(this,"namespace"),Lo(this,"chainId"),this.namespace=e.namespace,this.events=Oe("events"),this.client=Oe("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(Ni.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}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]}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(){const e={};return this.namespace.chains.forEach(r=>{var i;const s=io(r);e[s]=this.createHttpProvider(s,(i=this.namespace.rpcMap)==null?void 0:i[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const i=this.createHttpProvider(e,r);i&&(this.httpProviders[e]=i)}createHttpProvider(e,r){const i=r||fi(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new Et(new Vt(i,Oe("disableProviderPing")))}}var pJ=Object.defineProperty,gJ=(t,e,r)=>e in t?pJ(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Fo=(t,e,r)=>gJ(t,typeof e!="symbol"?e+"":e,r);class bJ{constructor(e){Fo(this,"name","near"),Fo(this,"client"),Fo(this,"httpProviders"),Fo(this,"events"),Fo(this,"namespace"),Fo(this,"chainId"),this.namespace=e.namespace,this.events=Oe("events"),this.client=Oe("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}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]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){if(this.chainId=e,!this.httpProviders[e]){const i=r||fi(`${this.name}:${e}`,this.namespace);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,i)}this.events.emit(Ni.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var i;e[r]=this.createHttpProvider(r,(i=this.namespace.rpcMap)==null?void 0:i[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const i=this.createHttpProvider(e,r);i&&(this.httpProviders[e]=i)}createHttpProvider(e,r){const i=r||fi(e,this.namespace);return typeof i>"u"?void 0:new Et(new Vt(i,Oe("disableProviderPing")))}}var mJ=Object.defineProperty,yJ=(t,e,r)=>e in t?mJ(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,jo=(t,e,r)=>yJ(t,typeof e!="symbol"?e+"":e,r);class wJ{constructor(e){jo(this,"name","tezos"),jo(this,"client"),jo(this,"httpProviders"),jo(this,"events"),jo(this,"namespace"),jo(this,"chainId"),this.namespace=e.namespace,this.events=Oe("events"),this.client=Oe("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}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]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){if(this.chainId=e,!this.httpProviders[e]){const i=r||fi(`${this.name}:${e}`,this.namespace);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,i)}this.events.emit(Ni.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{e[r]=this.createHttpProvider(r)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const i=this.createHttpProvider(e,r);i&&(this.httpProviders[e]=i)}createHttpProvider(e,r){const i=r||fi(e,this.namespace);return typeof i>"u"?void 0:new Et(new Vt(i))}}var vJ=Object.defineProperty,_J=(t,e,r)=>e in t?vJ(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,qo=(t,e,r)=>_J(t,typeof e!="symbol"?e+"":e,r);class EJ{constructor(e){qo(this,"name",Go),qo(this,"client"),qo(this,"httpProviders"),qo(this,"events"),qo(this,"namespace"),qo(this,"chainId"),this.namespace=e.namespace,this.events=Oe("events"),this.client=Oe("client"),this.chainId=this.getDefaultChain(),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),this.chainId=e,this.events.emit(Ni.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}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]}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(s=>{const n=ia(s);i[`${n.namespace}:${n.reference}`]=this.createHttpProvider(s)}),i}getHttpProvider(e){const r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const i=this.createHttpProvider(e,r);i&&(this.httpProviders[e]=i)}createHttpProvider(e,r){const i=r||fi(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new Et(new Vt(i,Oe("disableProviderPing")))}}var IJ=Object.defineProperty,AJ=Object.defineProperties,SJ=Object.getOwnPropertyDescriptors,Rv=Object.getOwnPropertySymbols,CJ=Object.prototype.hasOwnProperty,$J=Object.prototype.propertyIsEnumerable,Xp=(t,e,r)=>e in t?IJ(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Nl=(t,e)=>{for(var r in e||(e={}))CJ.call(e,r)&&Xp(t,r,e[r]);if(Rv)for(var r of Rv(e))$J.call(e,r)&&Xp(t,r,e[r]);return t},Lf=(t,e)=>AJ(t,SJ(e)),Ii=(t,e,r)=>Xp(t,typeof e!="symbol"?e+"":e,r);let xJ=class mE{constructor(e){Ii(this,"client"),Ii(this,"namespaces"),Ii(this,"optionalNamespaces"),Ii(this,"sessionProperties"),Ii(this,"scopedProperties"),Ii(this,"events",new wa),Ii(this,"rpcProviders",{}),Ii(this,"session"),Ii(this,"providerOpts"),Ii(this,"logger"),Ii(this,"uri"),Ii(this,"disableProviderPing",!1),this.providerOpts=e,this.logger=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:cn(Ts({level:e?.logger||Iv})),this.disableProviderPing=e?.disableProviderPing||!1}static async init(e){const r=new mE(e);return await r.initialize(),r}async request(e,r,i){const[s,n]=this.validateChain(r);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(s).request({request:Nl({},e),chainId:`${s}:${n}`,topic:this.session.topic,expiry:i})}sendAsync(e,r,i,s){const n=new Date().getTime();this.request(e,i,s).then(o=>r(null,ln(n,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:Xe("USER_DISCONNECTED")}),await this.cleanup()}async connect(e){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(e),await 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:s}=await this.client.authenticate(e,r);i&&(this.uri=i,this.events.emit("display_uri",i));const n=await s();if(this.session=n.session,this.session){const o=Nv(this.session.namespaces);this.namespaces=Mf(this.namespaces,o),await this.persist("namespaces",this.namespaces),this.onConnect()}return n}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 s=await i();this.session=s;const n=Nv(s.namespaces);return this.namespaces=Mf(this.namespaces,n),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,s]=this.validateChain(e),n=this.getProvider(i);n.name===Go?n.setDefaultChain(`${i}:${s}`,r):n.setDefaultChain(s,r)}catch(i){if(!/Please call connect/.test(i.message))throw i}}async cleanupPendingPairings(e={}){this.logger.info("Cleaning up inactive pairings...");const r=this.client.pairing.getAll();if(Vn(r)){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}`)}}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 tY.init({core:this.providerOpts.core,logger:this.providerOpts.logger||Iv,relayUrl:this.providerOpts.relayUrl||rY,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("Failed to get session",i),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=>Sc(r)))];Uf("client",this.client),Uf("events",this.events),Uf("disableProviderPing",this.disableProviderPing),e.forEach(r=>{if(!this.session)return;const i=FY(r,this.session),s=gE(i),n=Mf(this.namespaces,this.optionalNamespaces),o=Lf(Nl({},n[r]),{accounts:i,chains:s});switch(r){case"eip155":this.rpcProviders[r]=new YY({namespace:o});break;case"algorand":this.rpcProviders[r]=new sJ({namespace:o});break;case"solana":this.rpcProviders[r]=new XY({namespace:o});break;case"cosmos":this.rpcProviders[r]=new tJ({namespace:o});break;case"polkadot":this.rpcProviders[r]=new zY({namespace:o});break;case"cip34":this.rpcProviders[r]=new aJ({namespace:o});break;case"elrond":this.rpcProviders[r]=new lJ({namespace:o});break;case"multiversx":this.rpcProviders[r]=new fJ({namespace:o});break;case"near":this.rpcProviders[r]=new bJ({namespace:o});break;case"tezos":this.rpcProviders[r]=new wJ({namespace:o});break;default:this.rpcProviders[Go]?this.rpcProviders[Go].updateNamespace(o):this.rpcProviders[Go]=new EJ({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:s}=e;if(s!==((r=this.session)==null?void 0:r.topic))return;const{event:n}=i;if(n.name==="accountsChanged"){const o=n.data;o&&Vn(o)&&this.events.emit("accountsChanged",o.map(jY))}else if(n.name==="chainChanged"){const o=i.chainId,a=i.event.data,u=Sc(o),c=kf(o)!==kf(a)?`${u}:${kf(a)}`:o;this.onChainChanged(c)}else this.events.emit(n.name,n.data);this.events.emit("session_event",e)}),this.client.on("session_update",({topic:e,params:r})=>{var i,s;if(e!==((i=this.session)==null?void 0:i.topic))return;const{namespaces:n}=r,o=(s=this.client)==null?void 0:s.session.get(e);this.session=Lf(Nl({},o),{namespaces:n}),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",Lf(Nl({},Xe("USER_DISCONNECTED")),{data:e.topic})))}),this.on(Ni.DEFAULT_CHAIN_CHANGED,e=>{this.onChainChanged(e,!0)})}getProvider(e){return this.rpcProviders[e]||this.rpcProviders[Go]}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:s,scopedProperties:n}=e;r&&Object.keys(r).length&&(this.namespaces=r),i&&Object.keys(i).length&&(this.optionalNamespaces=i),this.sessionProperties=s,this.scopedProperties=n}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=>Sc(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 s=Sc(Object.keys(this.namespaces)[0]),n=this.rpcProviders[s].getDefaultChain();return[s,n]}async requestAccounts(){const[e]=this.validateChain();return await this.getProvider(e).requestAccounts()}async onChainChanged(e,r=!1){if(!this.namespaces)return;const[i,s]=this.validateChain(e);s&&(r||this.getProvider(i).setDefaultChain(s),this.namespaces[i]?this.namespaces[i].defaultChain=s:this.namespaces[`${i}:${s}`]?this.namespaces[`${i}:${s}`].defaultChain=s:this.namespaces[`${i}:${s}`]={defaultChain:s},this.events.emit("chainChanged",s),await this.persist("namespaces",this.namespaces))}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,await this.cleanupPendingPairings({deletePairings:!0}),await this.cleanupStorage()}async persist(e,r){var i;const s=((i=this.session)==null?void 0:i.topic)||"";await this.client.core.storage.setItem(`${xl}/${e}${s}`,r)}async getFromStore(e){var r;const i=((r=this.session)==null?void 0:r.topic)||"";return await this.client.core.storage.getItem(`${xl}/${e}${i}`)}async deleteFromStore(e){var r;const i=((r=this.session)==null?void 0:r.topic)||"";await this.client.core.storage.removeItem(`${xl}/${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(xl)&&await this.client.core.storage.removeItem(i)}catch(r){this.logger.warn("Failed to cleanup storage",r)}}};const Ks={EIP155:"eip155",CONNECTOR_TYPE_WALLET_CONNECT:"WALLET_CONNECT",CONNECTOR_TYPE_INJECTED:"INJECTED",CONNECTOR_TYPE_ANNOUNCED:"ANNOUNCED"},gh={NetworkImageIds:{1:"ba0ba0cd-17c6-4806-ad93-f9d174f17900",42161:"3bff954d-5cb0-47a0-9a23-d20192e74600",43114:"30c46e53-e989-45fb-4549-be3bd4eb3b00",56:"93564157-2e8e-4ce7-81df-b264dbee9b00",250:"06b26297-fe0c-4733-5d6b-ffa5498aac00",10:"ab9c186a-c52f-464b-2906-ca59d760a400",137:"41d04d42-da3b-4453-8506-668cc0727900",5e3:"e86fae9b-b770-4eea-e520-150e12c81100",295:"6a97d510-cac8-4e58-c7ce-e8681b044c00",11155111:"e909ea0a-f92a-4512-c8fc-748044ea6800",84532:"a18a7ecd-e307-4360-4746-283182228e00",1301:"4eeea7ef-0014-4649-5d1d-07271a80f600",130:"2257980a-3463-48c6-cbac-a42d2a956e00",10143:"0a728e83-bacb-46db-7844-948f05434900",100:"02b53f6a-e3d4-479e-1cb4-21178987d100",9001:"f926ff41-260d-4028-635e-91913fc28e00",324:"b310f07f-4ef7-49f3-7073-2a0a39685800",314:"5a73b3dd-af74-424e-cae0-0de859ee9400",4689:"34e68754-e536-40da-c153-6ef2e7188a00",1088:"3897a66d-40b9-4833-162f-a2c90531c900",1284:"161038da-44ae-4ec7-1208-0ea569454b00",1285:"f1d73bb6-5450-4e18-38f7-fb6484264a00",7777777:"845c60df-d429-4991-e687-91ae45791600",42220:"ab781bbc-ccc6-418d-d32d-789b15da1f00",8453:"7289c336-3981-4081-c5f4-efc26ac64a00",1313161554:"3ff73439-a619-4894-9262-4470c773a100",2020:"b8101fc0-9c19-4b6f-ec65-f6dfff106e00",2021:"b8101fc0-9c19-4b6f-ec65-f6dfff106e00",80094:"e329c2c9-59b0-4a02-83e4-212ff3779900","5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp":"a1b58899-f671-4276-6a5e-56ca5bd59700","4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z":"a1b58899-f671-4276-6a5e-56ca5bd59700",EtWTRABZaYq6iMfeYKouRu166VU2xqa1:"a1b58899-f671-4276-6a5e-56ca5bd59700","000000000019d6689c085ae165831e93":"0b4838db-0161-4ffe-022d-532bf03dba00","000000000933ea01ad0ee984209779ba":"39354064-d79b-420b-065d-f980c4b78200"},ConnectorImageIds:{[ne.CONNECTOR_ID.COINBASE]:"0c2840c3-5b04-4c44-9661-fbd4b49e1800",[ne.CONNECTOR_ID.COINBASE_SDK]:"0c2840c3-5b04-4c44-9661-fbd4b49e1800",[ne.CONNECTOR_ID.SAFE]:"461db637-8616-43ce-035a-d89b8a1d5800",[ne.CONNECTOR_ID.LEDGER]:"54a1aa77-d202-4f8d-0fb2-5d2bb6db0300",[ne.CONNECTOR_ID.WALLET_CONNECT]:"ef1a1fcf-7fe8-4d69-bd6d-fda1345b4400",[ne.CONNECTOR_ID.INJECTED]:"07ba87ed-43aa-4adf-4540-9e6a2b9cae00"},ConnectorNamesMap:{[ne.CONNECTOR_ID.INJECTED]:"Browser Wallet",[ne.CONNECTOR_ID.WALLET_CONNECT]:"WalletConnect",[ne.CONNECTOR_ID.COINBASE]:"Coinbase",[ne.CONNECTOR_ID.COINBASE_SDK]:"Coinbase",[ne.CONNECTOR_ID.LEDGER]:"Ledger",[ne.CONNECTOR_ID.SAFE]:"Safe"}},yE={getCaipTokens(t){if(!t)return;const e={};return Object.entries(t).forEach(([r,i])=>{e[`${Ks.EIP155}:${r}`]=i}),e},isLowerCaseMatch(t,e){return t?.toLowerCase()===e?.toLowerCase()}},Ol={UniversalProviderErrors:{UNAUTHORIZED_DOMAIN_NOT_ALLOWED:{message:"Unauthorized: origin not allowed",alertErrorKey:"INVALID_APP_CONFIGURATION"},JWT_VALIDATION_ERROR:{message:"JWT validation error: JWT Token is not yet valid",alertErrorKey:"JWT_TOKEN_NOT_VALID"},INVALID_KEY:{message:"Unauthorized: invalid key",alertErrorKey:"INVALID_PROJECT_ID"}},ALERT_ERRORS:{SWITCH_NETWORK_NOT_FOUND:{shortMessage:"Network Not Found",longMessage:"Network not found - please make sure it is included in 'networks' array in createAppKit function"},INVALID_APP_CONFIGURATION:{shortMessage:"Invalid App Configuration",longMessage:()=>`Origin ${PJ()?window.origin:"unknown"} not found on Allowlist - update configuration on cloud.reown.com`},SOCIALS_TIMEOUT:{shortMessage:"Invalid App Configuration",longMessage:()=>"There was an issue loading the embedded wallet. Please verify that your domain is allowed at cloud.reown.com"},JWT_TOKEN_NOT_VALID:{shortMessage:"Session Expired",longMessage:"Invalid session found on UniversalProvider - please check your time settings and connect again"},INVALID_PROJECT_ID:{shortMessage:"Invalid App Configuration",longMessage:"Invalid Project ID - update configuration"},PROJECT_ID_NOT_CONFIGURED:{shortMessage:"Project ID Not Configured",longMessage:"Project ID Not Configured - update configuration on cloud.reown.com"}}};function PJ(){return typeof window<"u"}const NJ={createLogger(t,e="error"){const r=Ts({level:e}),{logger:i}=sg({opts:r});return i.error=(...s)=>{for(const n of s)if(n instanceof Error){t(n,...s);return}t(void 0,...s)},i}},OJ="rpc.walletconnect.org";function TJ(t,e){const r=new URL("https://rpc.walletconnect.org/v1/");return r.searchParams.set("chainId",t),r.searchParams.set("projectId",e),r.toString()}const Ff=["near:mainnet","solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp","eip155:1101","eip155:56","eip155:42161","eip155:7777777","eip155:59144","eip155:324","solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1","eip155:5000","solana:4sgjmw1sunhzsxgspuhpqldx6wiyjntz","eip155:80084","eip155:5003","eip155:100","eip155:8453","eip155:42220","eip155:1313161555","eip155:17000","eip155:1","eip155:300","eip155:1313161554","eip155:1329","eip155:84532","eip155:421614","eip155:11155111","eip155:8217","eip155:43114","solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z","eip155:999999999","eip155:11155420","eip155:80002","eip155:97","eip155:43113","eip155:137","eip155:10","eip155:1301","bip122:000000000019d6689c085ae165831e93","bip122:000000000933ea01ad0ee984209779ba"],Yo={extendRpcUrlWithProjectId(t,e){let r=!1;try{r=new URL(t).host===OJ}catch{r=!1}if(r){const i=new URL(t);return i.searchParams.has("projectId")||i.searchParams.set("projectId",e),i.toString()}return t},isCaipNetwork(t){return"chainNamespace"in t&&"caipNetworkId"in t},getChainNamespace(t){return this.isCaipNetwork(t)?t.chainNamespace:ne.CHAIN.EVM},getCaipNetworkId(t){return this.isCaipNetwork(t)?t.caipNetworkId:`${ne.CHAIN.EVM}:${t.id}`},getDefaultRpcUrl(t,e,r){const i=t.rpcUrls?.default?.http?.[0];return Ff.includes(e)?TJ(e,r):i||""},extendCaipNetwork(t,{customNetworkImageUrls:e,projectId:r,customRpcUrls:i}){const s=this.getChainNamespace(t),n=this.getCaipNetworkId(t),o=t.rpcUrls.default.http?.[0],a=this.getDefaultRpcUrl(t,n,r),u=t?.rpcUrls?.chainDefault?.http?.[0]||o,c=i?.[n]?.map(f=>f.url)||[],l=[...c,a],h=[...c];return u&&!h.includes(u)&&h.push(u),{...t,chainNamespace:s,caipNetworkId:n,assets:{imageId:gh.NetworkImageIds[t.id],imageUrl:e?.[t.id]},rpcUrls:{...t.rpcUrls,default:{http:l},chainDefault:{http:h}}}},extendCaipNetworks(t,{customNetworkImageUrls:e,projectId:r,customRpcUrls:i}){return t.map(s=>Yo.extendCaipNetwork(s,{customNetworkImageUrls:e,customRpcUrls:i,projectId:r}))},getViemTransport(t,e,r){const i=[];if(r?.forEach(s=>{i.push(bf(s.url,s.config))}),Ff.includes(t.caipNetworkId)){const s=this.getDefaultRpcUrl(t,t.caipNetworkId,e);i.push(bf(s,{fetchOptions:{headers:{"Content-Type":"text/plain"}}}))}return Zy(i)},extendWagmiTransports(t,e,r){if(Ff.includes(t.caipNetworkId)){const i=this.getDefaultRpcUrl(t,t.caipNetworkId,e);return Zy([r,bf(i)])}return r},getUnsupportedNetwork(t){return{id:t.split(":")[1],caipNetworkId:t,name:ne.UNSUPPORTED_NETWORK_NAME,chainNamespace:t.split(":")[0],nativeCurrency:{name:"",decimals:0,symbol:""},rpcUrls:{default:{http:[]}}}},getCaipNetworkFromStorage(t){const e=se.getActiveCaipNetworkId(),r=F.getAllRequestedCaipNetworks(),i=Array.from(F.state.chains?.keys()||[]),s=e?.split(":")[0],n=s?i.includes(s):!1,o=r?.find(u=>u.caipNetworkId===e);return n&&!o&&e?this.getUnsupportedNetwork(e):o||t||r?.[0]}},bh={eip155:void 0,solana:void 0,polkadot:void 0,bip122:void 0},Vr=Tt({providers:{...bh},providerIds:{...bh}}),Ot={state:Vr,subscribeKey(t,e){return gi(Vr,t,e)},subscribe(t){return Fr(Vr,()=>{t(Vr)})},subscribeProviders(t){return Fr(Vr.providers,()=>t(Vr.providers))},setProvider(t,e){e&&(Vr.providers[t]=qn(e))},getProvider(t){return Vr.providers[t]},setProviderId(t,e){e&&(Vr.providerIds[t]=e)},getProviderId(t){if(t)return Vr.providerIds[t]},reset(){Vr.providers={...bh},Vr.providerIds={...bh}},resetChain(t){Vr.providers[t]=void 0,Vr.providerIds[t]=void 0}},DJ={VIEW_DIRECTION:{Next:"next",Prev:"prev"},DEFAULT_CONNECT_METHOD_ORDER:["email","social","wallet"],ANIMATION_DURATIONS:{HeaderText:120,ModalHeight:150,ViewTransition:150}},Zp={filterOutDuplicatesByRDNS(t){const e=J.state.enableEIP6963?fe.state.connectors:[],r=se.getRecentWallets(),i=e.map(a=>a.info?.rdns).filter(Boolean),s=r.map(a=>a.rdns).filter(Boolean),n=i.concat(s);if(n.includes("io.metamask.mobile")&&pe.isMobile()){const a=n.indexOf("io.metamask.mobile");n[a]="io.metamask"}return t.filter(a=>!n.includes(String(a?.rdns)))},filterOutDuplicatesByIds(t){const e=fe.state.connectors.filter(a=>a.type==="ANNOUNCED"||a.type==="INJECTED"),r=se.getRecentWallets(),i=e.map(a=>a.explorerId),s=r.map(a=>a.id),n=i.concat(s);return t.filter(a=>!n.includes(a?.id))},filterOutDuplicateWallets(t){const e=this.filterOutDuplicatesByRDNS(t);return this.filterOutDuplicatesByIds(e)},markWalletsAsInstalled(t){const{connectors:e}=fe.state,r=e.filter(n=>n.type==="ANNOUNCED").reduce((n,o)=>(o.info?.rdns&&(n[o.info.rdns]=!0),n),{});return t.map(n=>({...n,installed:!!n.rdns&&!!r[n.rdns??""]})).sort((n,o)=>Number(o.installed)-Number(n.installed))},getConnectOrderMethod(t,e){const r=t?.connectMethodsOrder||J.state.features?.connectMethodsOrder,i=e||fe.state.connectors;if(r)return r;const{injected:s,announced:n}=Wl.getConnectorsByType(i,be.state.recommended,be.state.featured),o=s.filter(Wl.showConnector),a=n.filter(Wl.showConnector);return o.length||a.length?["wallet","email","social"]:DJ.DEFAULT_CONNECT_METHOD_ORDER}},Wl={getConnectorsByType(t,e,r){const{customWallets:i}=J.state,s=se.getRecentWallets(),n=Zp.filterOutDuplicateWallets(e),o=Zp.filterOutDuplicateWallets(r),a=t.filter(h=>h.type==="MULTI_CHAIN"),u=t.filter(h=>h.type==="ANNOUNCED"),c=t.filter(h=>h.type==="INJECTED"),l=t.filter(h=>h.type==="EXTERNAL");return{custom:i,recent:s,external:l,multiChain:a,announced:u,injected:c,recommended:n,featured:o}},showConnector(t){const e=t.info?.rdns,r=!!e&&be.state.excludedWallets.some(s=>s.rdns===e),i=!!t.name&&be.state.excludedWallets.some(s=>yE.isLowerCaseMatch(s.name,t.name));return!(t.type==="INJECTED"&&(!pe.isMobile()&&t.name==="Browser Wallet"||!e&&!ut.checkInstalled()||r||i)||t.type==="ANNOUNCED"&&(r||i))},getIsConnectedWithWC(){return Array.from(F.state.chains.values()).some(r=>fe.getConnectorId(r.namespace)===ne.CONNECTOR_ID.WALLET_CONNECT)},getConnectorTypeOrder({recommended:t,featured:e,custom:r,recent:i,announced:s,injected:n,multiChain:o,external:a,overriddenConnectors:u=J.state.features?.connectorTypeOrder??[]}){const c=Wl.getIsConnectedWithWC(),f=[{type:"walletConnect",isEnabled:J.state.enableWalletConnect&&!c},{type:"recent",isEnabled:i.length>0},{type:"injected",isEnabled:[...n,...s,...o].length>0},{type:"featured",isEnabled:e.length>0},{type:"custom",isEnabled:r&&r.length>0},{type:"external",isEnabled:a.length>0},{type:"recommended",isEnabled:t.length>0}].filter(C=>C.isEnabled),m=new Set(f.map(C=>C.type)),g=u.filter(C=>m.has(C)).map(C=>({type:C,isEnabled:!0})),y=f.filter(({type:C})=>!g.some(({type:A})=>A===C));return Array.from(new Set([...g,...y].map(({type:C})=>C)))}};const Gl=globalThis,Kg=Gl.ShadowRoot&&(Gl.ShadyCSS===void 0||Gl.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Wg=Symbol(),Mv=new WeakMap;let wE=class{constructor(e,r,i){if(this._$cssResult$=!0,i!==Wg)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=r}get styleSheet(){let e=this.o;const r=this.t;if(Kg&&e===void 0){const i=r!==void 0&&r.length===1;i&&(e=Mv.get(r)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),i&&Mv.set(r,e))}return e}toString(){return this.cssText}};const Ai=t=>new wE(typeof t=="string"?t:t+"",void 0,Wg),sa=(t,...e)=>{const r=t.length===1?t[0]:e.reduce((i,s,n)=>i+(o=>{if(o._$cssResult$===!0)return o.cssText;if(typeof o=="number")return o;throw Error("Value passed to 'css' function must be a 'css' function result: "+o+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+t[n+1],t[0]);return new wE(r,t,Wg)},RJ=(t,e)=>{if(Kg)t.adoptedStyleSheets=e.map(r=>r instanceof CSSStyleSheet?r:r.styleSheet);else for(const r of e){const i=document.createElement("style"),s=Gl.litNonce;s!==void 0&&i.setAttribute("nonce",s),i.textContent=r.cssText,t.appendChild(i)}},kv=Kg?t=>t:t=>t instanceof CSSStyleSheet?(e=>{let r="";for(const i of e.cssRules)r+=i.cssText;return Ai(r)})(t):t;const{is:MJ,defineProperty:kJ,getOwnPropertyDescriptor:UJ,getOwnPropertyNames:LJ,getOwnPropertySymbols:FJ,getPrototypeOf:jJ}=Object,Kh=globalThis,Uv=Kh.trustedTypes,qJ=Uv?Uv.emptyScript:"",BJ=Kh.reactiveElementPolyfillSupport,kc=(t,e)=>t,eg={toAttribute(t,e){switch(e){case Boolean:t=t?qJ:null;break;case Object:case Array:t=t==null?t:JSON.stringify(t)}return t},fromAttribute(t,e){let r=t;switch(e){case Boolean:r=t!==null;break;case Number:r=t===null?null:Number(t);break;case Object:case Array:try{r=JSON.parse(t)}catch{r=null}}return r}},vE=(t,e)=>!MJ(t,e),Lv={attribute:!0,type:String,converter:eg,reflect:!1,useDefault:!1,hasChanged:vE};Symbol.metadata??=Symbol("metadata"),Kh.litPropertyMetadata??=new WeakMap;let Jo=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??=[]).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,r=Lv){if(r.state&&(r.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((r=Object.create(r)).wrapped=!0),this.elementProperties.set(e,r),!r.noAccessor){const i=Symbol(),s=this.getPropertyDescriptor(e,i,r);s!==void 0&&kJ(this.prototype,e,s)}}static getPropertyDescriptor(e,r,i){const{get:s,set:n}=UJ(this.prototype,e)??{get(){return this[r]},set(o){this[r]=o}};return{get:s,set(o){const a=s?.call(this);n?.call(this,o),this.requestUpdate(e,a,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??Lv}static _$Ei(){if(this.hasOwnProperty(kc("elementProperties")))return;const e=jJ(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(kc("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(kc("properties"))){const r=this.properties,i=[...LJ(r),...FJ(r)];for(const s of i)this.createProperty(s,r[s])}const e=this[Symbol.metadata];if(e!==null){const r=litPropertyMetadata.get(e);if(r!==void 0)for(const[i,s]of r)this.elementProperties.set(i,s)}this._$Eh=new Map;for(const[r,i]of this.elementProperties){const s=this._$Eu(r,i);s!==void 0&&this._$Eh.set(s,r)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){const r=[];if(Array.isArray(e)){const i=new Set(e.flat(1/0).reverse());for(const s of i)r.unshift(kv(s))}else e!==void 0&&r.push(kv(e));return r}static _$Eu(e,r){const i=r.attribute;return i===!1?void 0:typeof i=="string"?i:typeof e=="string"?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(e=>e(this))}addController(e){(this._$EO??=new Set).add(e),this.renderRoot!==void 0&&this.isConnected&&e.hostConnected?.()}removeController(e){this._$EO?.delete(e)}_$E_(){const e=new Map,r=this.constructor.elementProperties;for(const i of r.keys())this.hasOwnProperty(i)&&(e.set(i,this[i]),delete this[i]);e.size>0&&(this._$Ep=e)}createRenderRoot(){const e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return RJ(e,this.constructor.elementStyles),e}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(e=>e.hostConnected?.())}enableUpdating(e){}disconnectedCallback(){this._$EO?.forEach(e=>e.hostDisconnected?.())}attributeChangedCallback(e,r,i){this._$AK(e,i)}_$ET(e,r){const i=this.constructor.elementProperties.get(e),s=this.constructor._$Eu(e,i);if(s!==void 0&&i.reflect===!0){const n=(i.converter?.toAttribute!==void 0?i.converter:eg).toAttribute(r,i.type);this._$Em=e,n==null?this.removeAttribute(s):this.setAttribute(s,n),this._$Em=null}}_$AK(e,r){const i=this.constructor,s=i._$Eh.get(e);if(s!==void 0&&this._$Em!==s){const n=i.getPropertyOptions(s),o=typeof n.converter=="function"?{fromAttribute:n.converter}:n.converter?.fromAttribute!==void 0?n.converter:eg;this._$Em=s;const a=o.fromAttribute(r,n.type);this[s]=a??this._$Ej?.get(s)??a,this._$Em=null}}requestUpdate(e,r,i,s=!1,n){if(e!==void 0){const o=this.constructor;if(s===!1&&(n=this[e]),i??=o.getPropertyOptions(e),!((i.hasChanged??vE)(n,r)||i.useDefault&&i.reflect&&n===this._$Ej?.get(e)&&!this.hasAttribute(o._$Eu(e,i))))return;this.C(e,r,i)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(e,r,{useDefault:i,reflect:s,wrapped:n},o){i&&!(this._$Ej??=new Map).has(e)&&(this._$Ej.set(e,o??r??this[e]),n!==!0||o!==void 0)||(this._$AL.has(e)||(this.hasUpdated||i||(r=void 0),this._$AL.set(e,r)),s===!0&&this._$Em!==e&&(this._$Eq??=new Set).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(r){Promise.reject(r)}const e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[s,n]of this._$Ep)this[s]=n;this._$Ep=void 0}const i=this.constructor.elementProperties;if(i.size>0)for(const[s,n]of i){const{wrapped:o}=n,a=this[s];o!==!0||this._$AL.has(s)||a===void 0||this.C(s,void 0,n,a)}}let e=!1;const r=this._$AL;try{e=this.shouldUpdate(r),e?(this.willUpdate(r),this._$EO?.forEach(i=>i.hostUpdate?.()),this.update(r)):this._$EM()}catch(i){throw e=!1,this._$EM(),i}e&&this._$AE(r)}willUpdate(e){}_$AE(e){this._$EO?.forEach(r=>r.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&=this._$Eq.forEach(r=>this._$ET(r,this[r])),this._$EM()}updated(e){}firstUpdated(e){}};Jo.elementStyles=[],Jo.shadowRootOptions={mode:"open"},Jo[kc("elementProperties")]=new Map,Jo[kc("finalized")]=new Map,BJ?.({ReactiveElement:Jo}),(Kh.reactiveElementVersions??=[]).push("2.1.2");const Gg=globalThis,Fv=t=>t,mh=Gg.trustedTypes,jv=mh?mh.createPolicy("lit-html",{createHTML:t=>t}):void 0,_E="$lit$",Qs=`lit$${Math.random().toFixed(9).slice(2)}$`,EE="?"+Qs,zJ=`<${EE}>`,Kn=document,mu=()=>Kn.createComment(""),yu=t=>t===null||typeof t!="object"&&typeof t!="function",Yg=Array.isArray,HJ=t=>Yg(t)||typeof t?.[Symbol.iterator]=="function",jf=`[
|
|
27
|
+
\f\r]`,yc=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,qv=/-->/g,Bv=/>/g,In=RegExp(`>|${jf}(?:([^\\s"'>=/]+)(${jf}*=${jf}*(?:[^
|
|
28
|
+
\f\r"'\`<>=]|("|')|))|$)`,"g"),zv=/'/g,Hv=/"/g,IE=/^(?:script|style|textarea|title)$/i,AE=t=>(e,...r)=>({_$litType$:t,strings:e,values:r}),_Z=AE(1),EZ=AE(2),ma=Symbol.for("lit-noChange"),pr=Symbol.for("lit-nothing"),Vv=new WeakMap,Rn=Kn.createTreeWalker(Kn,129);function SE(t,e){if(!Yg(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return jv!==void 0?jv.createHTML(e):e}const VJ=(t,e)=>{const r=t.length-1,i=[];let s,n=e===2?"<svg>":e===3?"<math>":"",o=yc;for(let a=0;a<r;a++){const u=t[a];let c,l,h=-1,f=0;for(;f<u.length&&(o.lastIndex=f,l=o.exec(u),l!==null);)f=o.lastIndex,o===yc?l[1]==="!--"?o=qv:l[1]!==void 0?o=Bv:l[2]!==void 0?(IE.test(l[2])&&(s=RegExp("</"+l[2],"g")),o=In):l[3]!==void 0&&(o=In):o===In?l[0]===">"?(o=s??yc,h=-1):l[1]===void 0?h=-2:(h=o.lastIndex-l[2].length,c=l[1],o=l[3]===void 0?In:l[3]==='"'?Hv:zv):o===Hv||o===zv?o=In:o===qv||o===Bv?o=yc:(o=In,s=void 0);const m=o===In&&t[a+1].startsWith("/>")?" ":"";n+=o===yc?u+zJ:h>=0?(i.push(c),u.slice(0,h)+_E+u.slice(h)+Qs+m):u+Qs+(h===-2?a:m)}return[SE(t,n+(t[r]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),i]};class wu{constructor({strings:e,_$litType$:r},i){let s;this.parts=[];let n=0,o=0;const a=e.length-1,u=this.parts,[c,l]=VJ(e,r);if(this.el=wu.createElement(c,i),Rn.currentNode=this.el.content,r===2||r===3){const h=this.el.content.firstChild;h.replaceWith(...h.childNodes)}for(;(s=Rn.nextNode())!==null&&u.length<a;){if(s.nodeType===1){if(s.hasAttributes())for(const h of s.getAttributeNames())if(h.endsWith(_E)){const f=l[o++],m=s.getAttribute(h).split(Qs),g=/([.?@])?(.*)/.exec(f);u.push({type:1,index:n,name:g[2],strings:m,ctor:g[1]==="."?WJ:g[1]==="?"?GJ:g[1]==="@"?YJ:Wh}),s.removeAttribute(h)}else h.startsWith(Qs)&&(u.push({type:6,index:n}),s.removeAttribute(h));if(IE.test(s.tagName)){const h=s.textContent.split(Qs),f=h.length-1;if(f>0){s.textContent=mh?mh.emptyScript:"";for(let m=0;m<f;m++)s.append(h[m],mu()),Rn.nextNode(),u.push({type:2,index:++n});s.append(h[f],mu())}}}else if(s.nodeType===8)if(s.data===EE)u.push({type:2,index:n});else{let h=-1;for(;(h=s.data.indexOf(Qs,h+1))!==-1;)u.push({type:7,index:n}),h+=Qs.length-1}n++}}static createElement(e,r){const i=Kn.createElement("template");return i.innerHTML=e,i}}function ya(t,e,r=t,i){if(e===ma)return e;let s=i!==void 0?r._$Co?.[i]:r._$Cl;const n=yu(e)?void 0:e._$litDirective$;return s?.constructor!==n&&(s?._$AO?.(!1),n===void 0?s=void 0:(s=new n(t),s._$AT(t,r,i)),i!==void 0?(r._$Co??=[])[i]=s:r._$Cl=s),s!==void 0&&(e=ya(t,s._$AS(t,e.values),s,i)),e}class KJ{constructor(e,r){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=r}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:r},parts:i}=this._$AD,s=(e?.creationScope??Kn).importNode(r,!0);Rn.currentNode=s;let n=Rn.nextNode(),o=0,a=0,u=i[0];for(;u!==void 0;){if(o===u.index){let c;u.type===2?c=new Fu(n,n.nextSibling,this,e):u.type===1?c=new u.ctor(n,u.name,u.strings,this,e):u.type===6&&(c=new JJ(n,this,e)),this._$AV.push(c),u=i[++a]}o!==u?.index&&(n=Rn.nextNode(),o++)}return Rn.currentNode=Kn,s}p(e){let r=0;for(const i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(e,i,r),r+=i.strings.length-2):i._$AI(e[r])),r++}}class Fu{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,r,i,s){this.type=2,this._$AH=pr,this._$AN=void 0,this._$AA=e,this._$AB=r,this._$AM=i,this.options=s,this._$Cv=s?.isConnected??!0}get parentNode(){let e=this._$AA.parentNode;const r=this._$AM;return r!==void 0&&e?.nodeType===11&&(e=r.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,r=this){e=ya(this,e,r),yu(e)?e===pr||e==null||e===""?(this._$AH!==pr&&this._$AR(),this._$AH=pr):e!==this._$AH&&e!==ma&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):HJ(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==pr&&yu(this._$AH)?this._$AA.nextSibling.data=e:this.T(Kn.createTextNode(e)),this._$AH=e}$(e){const{values:r,_$litType$:i}=e,s=typeof i=="number"?this._$AC(e):(i.el===void 0&&(i.el=wu.createElement(SE(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===s)this._$AH.p(r);else{const n=new KJ(s,this),o=n.u(this.options);n.p(r),this.T(o),this._$AH=n}}_$AC(e){let r=Vv.get(e.strings);return r===void 0&&Vv.set(e.strings,r=new wu(e)),r}k(e){Yg(this._$AH)||(this._$AH=[],this._$AR());const r=this._$AH;let i,s=0;for(const n of e)s===r.length?r.push(i=new Fu(this.O(mu()),this.O(mu()),this,this.options)):i=r[s],i._$AI(n),s++;s<r.length&&(this._$AR(i&&i._$AB.nextSibling,s),r.length=s)}_$AR(e=this._$AA.nextSibling,r){for(this._$AP?.(!1,!0,r);e!==this._$AB;){const i=Fv(e).nextSibling;Fv(e).remove(),e=i}}setConnected(e){this._$AM===void 0&&(this._$Cv=e,this._$AP?.(e))}}class Wh{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,r,i,s,n){this.type=1,this._$AH=pr,this._$AN=void 0,this.element=e,this.name=r,this._$AM=s,this.options=n,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=pr}_$AI(e,r=this,i,s){const n=this.strings;let o=!1;if(n===void 0)e=ya(this,e,r,0),o=!yu(e)||e!==this._$AH&&e!==ma,o&&(this._$AH=e);else{const a=e;let u,c;for(e=n[0],u=0;u<n.length-1;u++)c=ya(this,a[i+u],r,u),c===ma&&(c=this._$AH[u]),o||=!yu(c)||c!==this._$AH[u],c===pr?e=pr:e!==pr&&(e+=(c??"")+n[u+1]),this._$AH[u]=c}o&&!s&&this.j(e)}j(e){e===pr?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}}class WJ extends Wh{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===pr?void 0:e}}class GJ extends Wh{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==pr)}}class YJ extends Wh{constructor(e,r,i,s,n){super(e,r,i,s,n),this.type=5}_$AI(e,r=this){if((e=ya(this,e,r,0)??pr)===ma)return;const i=this._$AH,s=e===pr&&i!==pr||e.capture!==i.capture||e.once!==i.once||e.passive!==i.passive,n=e!==pr&&(i===pr||s);s&&this.element.removeEventListener(this.name,this,i),n&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,e):this._$AH.handleEvent(e)}}class JJ{constructor(e,r,i){this.element=e,this.type=6,this._$AN=void 0,this._$AM=r,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(e){ya(this,e)}}const QJ=Gg.litHtmlPolyfillSupport;QJ?.(wu,Fu),(Gg.litHtmlVersions??=[]).push("3.3.2");const XJ=(t,e,r)=>{const i=r?.renderBefore??e;let s=i._$litPart$;if(s===void 0){const n=r?.renderBefore??null;i._$litPart$=s=new Fu(e.insertBefore(mu(),n),n,void 0,r??{})}return s._$AI(t),s};const Jg=globalThis;class Yl extends Jo{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const e=super.createRenderRoot();return this.renderOptions.renderBefore??=e.firstChild,e}update(e){const r=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=XJ(r,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return ma}}Yl._$litElement$=!0,Yl.finalized=!0,Jg.litElementHydrateSupport?.({LitElement:Yl});const ZJ=Jg.litElementPolyfillSupport;ZJ?.({LitElement:Yl});(Jg.litElementVersions??=[]).push("4.2.2");let Uc,on,an;function IZ(t,e){Uc=document.createElement("style"),on=document.createElement("style"),an=document.createElement("style"),Uc.textContent=na(t).core.cssText,on.textContent=na(t).dark.cssText,an.textContent=na(t).light.cssText,document.head.appendChild(Uc),document.head.appendChild(on),document.head.appendChild(an),CE(e)}function CE(t){on&&an&&(t==="light"?(on.removeAttribute("media"),an.media="enabled"):(an.removeAttribute("media"),on.media="enabled"))}function eQ(t){Uc&&on&&an&&(Uc.textContent=na(t).core.cssText,on.textContent=na(t).dark.cssText,an.textContent=na(t).light.cssText)}function na(t){return{core:sa`
|
|
29
|
+
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
|
|
30
|
+
@keyframes w3m-shake {
|
|
31
|
+
0% {
|
|
32
|
+
transform: scale(1) rotate(0deg);
|
|
33
|
+
}
|
|
34
|
+
20% {
|
|
35
|
+
transform: scale(1) rotate(-1deg);
|
|
36
|
+
}
|
|
37
|
+
40% {
|
|
38
|
+
transform: scale(1) rotate(1.5deg);
|
|
39
|
+
}
|
|
40
|
+
60% {
|
|
41
|
+
transform: scale(1) rotate(-1.5deg);
|
|
42
|
+
}
|
|
43
|
+
80% {
|
|
44
|
+
transform: scale(1) rotate(1deg);
|
|
45
|
+
}
|
|
46
|
+
100% {
|
|
47
|
+
transform: scale(1) rotate(0deg);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
@keyframes w3m-iframe-fade-out {
|
|
51
|
+
0% {
|
|
52
|
+
opacity: 1;
|
|
53
|
+
}
|
|
54
|
+
100% {
|
|
55
|
+
opacity: 0;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
@keyframes w3m-iframe-zoom-in {
|
|
59
|
+
0% {
|
|
60
|
+
transform: translateY(50px);
|
|
61
|
+
opacity: 0;
|
|
62
|
+
}
|
|
63
|
+
100% {
|
|
64
|
+
transform: translateY(0px);
|
|
65
|
+
opacity: 1;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
@keyframes w3m-iframe-zoom-in-mobile {
|
|
69
|
+
0% {
|
|
70
|
+
transform: scale(0.95);
|
|
71
|
+
opacity: 0;
|
|
72
|
+
}
|
|
73
|
+
100% {
|
|
74
|
+
transform: scale(1);
|
|
75
|
+
opacity: 1;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
:root {
|
|
79
|
+
--w3m-modal-width: 360px;
|
|
80
|
+
--w3m-color-mix-strength: ${Ai(t?.["--w3m-color-mix-strength"]?`${t["--w3m-color-mix-strength"]}%`:"0%")};
|
|
81
|
+
--w3m-font-family: ${Ai(t?.["--w3m-font-family"]||"Inter, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;")};
|
|
82
|
+
--w3m-font-size-master: ${Ai(t?.["--w3m-font-size-master"]||"10px")};
|
|
83
|
+
--w3m-border-radius-master: ${Ai(t?.["--w3m-border-radius-master"]||"4px")};
|
|
84
|
+
--w3m-z-index: ${Ai(t?.["--w3m-z-index"]||999)};
|
|
85
|
+
|
|
86
|
+
--wui-font-family: var(--w3m-font-family);
|
|
87
|
+
|
|
88
|
+
--wui-font-size-mini: calc(var(--w3m-font-size-master) * 0.8);
|
|
89
|
+
--wui-font-size-micro: var(--w3m-font-size-master);
|
|
90
|
+
--wui-font-size-tiny: calc(var(--w3m-font-size-master) * 1.2);
|
|
91
|
+
--wui-font-size-small: calc(var(--w3m-font-size-master) * 1.4);
|
|
92
|
+
--wui-font-size-paragraph: calc(var(--w3m-font-size-master) * 1.6);
|
|
93
|
+
--wui-font-size-medium: calc(var(--w3m-font-size-master) * 1.8);
|
|
94
|
+
--wui-font-size-large: calc(var(--w3m-font-size-master) * 2);
|
|
95
|
+
--wui-font-size-title-6: calc(var(--w3m-font-size-master) * 2.2);
|
|
96
|
+
--wui-font-size-medium-title: calc(var(--w3m-font-size-master) * 2.4);
|
|
97
|
+
--wui-font-size-2xl: calc(var(--w3m-font-size-master) * 4);
|
|
98
|
+
|
|
99
|
+
--wui-border-radius-5xs: var(--w3m-border-radius-master);
|
|
100
|
+
--wui-border-radius-4xs: calc(var(--w3m-border-radius-master) * 1.5);
|
|
101
|
+
--wui-border-radius-3xs: calc(var(--w3m-border-radius-master) * 2);
|
|
102
|
+
--wui-border-radius-xxs: calc(var(--w3m-border-radius-master) * 3);
|
|
103
|
+
--wui-border-radius-xs: calc(var(--w3m-border-radius-master) * 4);
|
|
104
|
+
--wui-border-radius-s: calc(var(--w3m-border-radius-master) * 5);
|
|
105
|
+
--wui-border-radius-m: calc(var(--w3m-border-radius-master) * 7);
|
|
106
|
+
--wui-border-radius-l: calc(var(--w3m-border-radius-master) * 9);
|
|
107
|
+
--wui-border-radius-3xl: calc(var(--w3m-border-radius-master) * 20);
|
|
108
|
+
|
|
109
|
+
--wui-font-weight-light: 400;
|
|
110
|
+
--wui-font-weight-regular: 500;
|
|
111
|
+
--wui-font-weight-medium: 600;
|
|
112
|
+
--wui-font-weight-bold: 700;
|
|
113
|
+
|
|
114
|
+
--wui-letter-spacing-2xl: -1.6px;
|
|
115
|
+
--wui-letter-spacing-medium-title: -0.96px;
|
|
116
|
+
--wui-letter-spacing-title-6: -0.88px;
|
|
117
|
+
--wui-letter-spacing-large: -0.8px;
|
|
118
|
+
--wui-letter-spacing-medium: -0.72px;
|
|
119
|
+
--wui-letter-spacing-paragraph: -0.64px;
|
|
120
|
+
--wui-letter-spacing-small: -0.56px;
|
|
121
|
+
--wui-letter-spacing-tiny: -0.48px;
|
|
122
|
+
--wui-letter-spacing-micro: -0.2px;
|
|
123
|
+
--wui-letter-spacing-mini: -0.16px;
|
|
124
|
+
|
|
125
|
+
--wui-spacing-0: 0px;
|
|
126
|
+
--wui-spacing-4xs: 2px;
|
|
127
|
+
--wui-spacing-3xs: 4px;
|
|
128
|
+
--wui-spacing-xxs: 6px;
|
|
129
|
+
--wui-spacing-2xs: 7px;
|
|
130
|
+
--wui-spacing-xs: 8px;
|
|
131
|
+
--wui-spacing-1xs: 10px;
|
|
132
|
+
--wui-spacing-s: 12px;
|
|
133
|
+
--wui-spacing-m: 14px;
|
|
134
|
+
--wui-spacing-l: 16px;
|
|
135
|
+
--wui-spacing-2l: 18px;
|
|
136
|
+
--wui-spacing-xl: 20px;
|
|
137
|
+
--wui-spacing-xxl: 24px;
|
|
138
|
+
--wui-spacing-2xl: 32px;
|
|
139
|
+
--wui-spacing-3xl: 40px;
|
|
140
|
+
--wui-spacing-4xl: 90px;
|
|
141
|
+
--wui-spacing-5xl: 95px;
|
|
142
|
+
|
|
143
|
+
--wui-icon-box-size-xxs: 14px;
|
|
144
|
+
--wui-icon-box-size-xs: 20px;
|
|
145
|
+
--wui-icon-box-size-sm: 24px;
|
|
146
|
+
--wui-icon-box-size-md: 32px;
|
|
147
|
+
--wui-icon-box-size-mdl: 36px;
|
|
148
|
+
--wui-icon-box-size-lg: 40px;
|
|
149
|
+
--wui-icon-box-size-2lg: 48px;
|
|
150
|
+
--wui-icon-box-size-xl: 64px;
|
|
151
|
+
|
|
152
|
+
--wui-icon-size-inherit: inherit;
|
|
153
|
+
--wui-icon-size-xxs: 10px;
|
|
154
|
+
--wui-icon-size-xs: 12px;
|
|
155
|
+
--wui-icon-size-sm: 14px;
|
|
156
|
+
--wui-icon-size-md: 16px;
|
|
157
|
+
--wui-icon-size-mdl: 18px;
|
|
158
|
+
--wui-icon-size-lg: 20px;
|
|
159
|
+
--wui-icon-size-xl: 24px;
|
|
160
|
+
--wui-icon-size-xxl: 28px;
|
|
161
|
+
|
|
162
|
+
--wui-wallet-image-size-inherit: inherit;
|
|
163
|
+
--wui-wallet-image-size-sm: 40px;
|
|
164
|
+
--wui-wallet-image-size-md: 56px;
|
|
165
|
+
--wui-wallet-image-size-lg: 80px;
|
|
166
|
+
|
|
167
|
+
--wui-visual-size-size-inherit: inherit;
|
|
168
|
+
--wui-visual-size-sm: 40px;
|
|
169
|
+
--wui-visual-size-md: 55px;
|
|
170
|
+
--wui-visual-size-lg: 80px;
|
|
171
|
+
|
|
172
|
+
--wui-box-size-md: 100px;
|
|
173
|
+
--wui-box-size-lg: 120px;
|
|
174
|
+
|
|
175
|
+
--wui-ease-out-power-2: cubic-bezier(0, 0, 0.22, 1);
|
|
176
|
+
--wui-ease-out-power-1: cubic-bezier(0, 0, 0.55, 1);
|
|
177
|
+
|
|
178
|
+
--wui-ease-in-power-3: cubic-bezier(0.66, 0, 1, 1);
|
|
179
|
+
--wui-ease-in-power-2: cubic-bezier(0.45, 0, 1, 1);
|
|
180
|
+
--wui-ease-in-power-1: cubic-bezier(0.3, 0, 1, 1);
|
|
181
|
+
|
|
182
|
+
--wui-ease-inout-power-1: cubic-bezier(0.45, 0, 0.55, 1);
|
|
183
|
+
|
|
184
|
+
--wui-duration-lg: 200ms;
|
|
185
|
+
--wui-duration-md: 125ms;
|
|
186
|
+
--wui-duration-sm: 75ms;
|
|
187
|
+
|
|
188
|
+
--wui-path-network-sm: path(
|
|
189
|
+
'M15.4 2.1a5.21 5.21 0 0 1 5.2 0l11.61 6.7a5.21 5.21 0 0 1 2.61 4.52v13.4c0 1.87-1 3.59-2.6 4.52l-11.61 6.7c-1.62.93-3.6.93-5.22 0l-11.6-6.7a5.21 5.21 0 0 1-2.61-4.51v-13.4c0-1.87 1-3.6 2.6-4.52L15.4 2.1Z'
|
|
190
|
+
);
|
|
191
|
+
|
|
192
|
+
--wui-path-network-md: path(
|
|
193
|
+
'M43.4605 10.7248L28.0485 1.61089C25.5438 0.129705 22.4562 0.129705 19.9515 1.61088L4.53951 10.7248C2.03626 12.2051 0.5 14.9365 0.5 17.886V36.1139C0.5 39.0635 2.03626 41.7949 4.53951 43.2752L19.9515 52.3891C22.4562 53.8703 25.5438 53.8703 28.0485 52.3891L43.4605 43.2752C45.9637 41.7949 47.5 39.0635 47.5 36.114V17.8861C47.5 14.9365 45.9637 12.2051 43.4605 10.7248Z'
|
|
194
|
+
);
|
|
195
|
+
|
|
196
|
+
--wui-path-network-lg: path(
|
|
197
|
+
'M78.3244 18.926L50.1808 2.45078C45.7376 -0.150261 40.2624 -0.150262 35.8192 2.45078L7.6756 18.926C3.23322 21.5266 0.5 26.3301 0.5 31.5248V64.4752C0.5 69.6699 3.23322 74.4734 7.6756 77.074L35.8192 93.5492C40.2624 96.1503 45.7376 96.1503 50.1808 93.5492L78.3244 77.074C82.7668 74.4734 85.5 69.6699 85.5 64.4752V31.5248C85.5 26.3301 82.7668 21.5266 78.3244 18.926Z'
|
|
198
|
+
);
|
|
199
|
+
|
|
200
|
+
--wui-width-network-sm: 36px;
|
|
201
|
+
--wui-width-network-md: 48px;
|
|
202
|
+
--wui-width-network-lg: 86px;
|
|
203
|
+
|
|
204
|
+
--wui-height-network-sm: 40px;
|
|
205
|
+
--wui-height-network-md: 54px;
|
|
206
|
+
--wui-height-network-lg: 96px;
|
|
207
|
+
|
|
208
|
+
--wui-icon-size-network-xs: 12px;
|
|
209
|
+
--wui-icon-size-network-sm: 16px;
|
|
210
|
+
--wui-icon-size-network-md: 24px;
|
|
211
|
+
--wui-icon-size-network-lg: 42px;
|
|
212
|
+
|
|
213
|
+
--wui-color-inherit: inherit;
|
|
214
|
+
|
|
215
|
+
--wui-color-inverse-100: #fff;
|
|
216
|
+
--wui-color-inverse-000: #000;
|
|
217
|
+
|
|
218
|
+
--wui-cover: rgba(20, 20, 20, 0.8);
|
|
219
|
+
|
|
220
|
+
--wui-color-modal-bg: var(--wui-color-modal-bg-base);
|
|
221
|
+
|
|
222
|
+
--wui-color-accent-100: var(--wui-color-accent-base-100);
|
|
223
|
+
--wui-color-accent-090: var(--wui-color-accent-base-090);
|
|
224
|
+
--wui-color-accent-080: var(--wui-color-accent-base-080);
|
|
225
|
+
|
|
226
|
+
--wui-color-success-100: var(--wui-color-success-base-100);
|
|
227
|
+
--wui-color-success-125: var(--wui-color-success-base-125);
|
|
228
|
+
|
|
229
|
+
--wui-color-warning-100: var(--wui-color-warning-base-100);
|
|
230
|
+
|
|
231
|
+
--wui-color-error-100: var(--wui-color-error-base-100);
|
|
232
|
+
--wui-color-error-125: var(--wui-color-error-base-125);
|
|
233
|
+
|
|
234
|
+
--wui-color-blue-100: var(--wui-color-blue-base-100);
|
|
235
|
+
--wui-color-blue-90: var(--wui-color-blue-base-90);
|
|
236
|
+
|
|
237
|
+
--wui-icon-box-bg-error-100: var(--wui-icon-box-bg-error-base-100);
|
|
238
|
+
--wui-icon-box-bg-blue-100: var(--wui-icon-box-bg-blue-base-100);
|
|
239
|
+
--wui-icon-box-bg-success-100: var(--wui-icon-box-bg-success-base-100);
|
|
240
|
+
--wui-icon-box-bg-inverse-100: var(--wui-icon-box-bg-inverse-base-100);
|
|
241
|
+
|
|
242
|
+
--wui-all-wallets-bg-100: var(--wui-all-wallets-bg-100);
|
|
243
|
+
|
|
244
|
+
--wui-avatar-border: var(--wui-avatar-border-base);
|
|
245
|
+
|
|
246
|
+
--wui-thumbnail-border: var(--wui-thumbnail-border-base);
|
|
247
|
+
|
|
248
|
+
--wui-wallet-button-bg: var(--wui-wallet-button-bg-base);
|
|
249
|
+
|
|
250
|
+
--wui-box-shadow-blue: var(--wui-color-accent-glass-020);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
@supports (background: color-mix(in srgb, white 50%, black)) {
|
|
254
|
+
:root {
|
|
255
|
+
--wui-color-modal-bg: color-mix(
|
|
256
|
+
in srgb,
|
|
257
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
258
|
+
var(--wui-color-modal-bg-base)
|
|
259
|
+
);
|
|
260
|
+
|
|
261
|
+
--wui-box-shadow-blue: color-mix(in srgb, var(--wui-color-accent-100) 20%, transparent);
|
|
262
|
+
|
|
263
|
+
--wui-color-accent-100: color-mix(
|
|
264
|
+
in srgb,
|
|
265
|
+
var(--wui-color-accent-base-100) 100%,
|
|
266
|
+
transparent
|
|
267
|
+
);
|
|
268
|
+
--wui-color-accent-090: color-mix(
|
|
269
|
+
in srgb,
|
|
270
|
+
var(--wui-color-accent-base-100) 90%,
|
|
271
|
+
transparent
|
|
272
|
+
);
|
|
273
|
+
--wui-color-accent-080: color-mix(
|
|
274
|
+
in srgb,
|
|
275
|
+
var(--wui-color-accent-base-100) 80%,
|
|
276
|
+
transparent
|
|
277
|
+
);
|
|
278
|
+
--wui-color-accent-glass-090: color-mix(
|
|
279
|
+
in srgb,
|
|
280
|
+
var(--wui-color-accent-base-100) 90%,
|
|
281
|
+
transparent
|
|
282
|
+
);
|
|
283
|
+
--wui-color-accent-glass-080: color-mix(
|
|
284
|
+
in srgb,
|
|
285
|
+
var(--wui-color-accent-base-100) 80%,
|
|
286
|
+
transparent
|
|
287
|
+
);
|
|
288
|
+
--wui-color-accent-glass-020: color-mix(
|
|
289
|
+
in srgb,
|
|
290
|
+
var(--wui-color-accent-base-100) 20%,
|
|
291
|
+
transparent
|
|
292
|
+
);
|
|
293
|
+
--wui-color-accent-glass-015: color-mix(
|
|
294
|
+
in srgb,
|
|
295
|
+
var(--wui-color-accent-base-100) 15%,
|
|
296
|
+
transparent
|
|
297
|
+
);
|
|
298
|
+
--wui-color-accent-glass-010: color-mix(
|
|
299
|
+
in srgb,
|
|
300
|
+
var(--wui-color-accent-base-100) 10%,
|
|
301
|
+
transparent
|
|
302
|
+
);
|
|
303
|
+
--wui-color-accent-glass-005: color-mix(
|
|
304
|
+
in srgb,
|
|
305
|
+
var(--wui-color-accent-base-100) 5%,
|
|
306
|
+
transparent
|
|
307
|
+
);
|
|
308
|
+
--wui-color-accent-002: color-mix(
|
|
309
|
+
in srgb,
|
|
310
|
+
var(--wui-color-accent-base-100) 2%,
|
|
311
|
+
transparent
|
|
312
|
+
);
|
|
313
|
+
|
|
314
|
+
--wui-color-fg-100: color-mix(
|
|
315
|
+
in srgb,
|
|
316
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
317
|
+
var(--wui-color-fg-100)
|
|
318
|
+
);
|
|
319
|
+
--wui-color-fg-125: color-mix(
|
|
320
|
+
in srgb,
|
|
321
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
322
|
+
var(--wui-color-fg-125)
|
|
323
|
+
);
|
|
324
|
+
--wui-color-fg-150: color-mix(
|
|
325
|
+
in srgb,
|
|
326
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
327
|
+
var(--wui-color-fg-150)
|
|
328
|
+
);
|
|
329
|
+
--wui-color-fg-175: color-mix(
|
|
330
|
+
in srgb,
|
|
331
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
332
|
+
var(--wui-color-fg-175)
|
|
333
|
+
);
|
|
334
|
+
--wui-color-fg-200: color-mix(
|
|
335
|
+
in srgb,
|
|
336
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
337
|
+
var(--wui-color-fg-200)
|
|
338
|
+
);
|
|
339
|
+
--wui-color-fg-225: color-mix(
|
|
340
|
+
in srgb,
|
|
341
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
342
|
+
var(--wui-color-fg-225)
|
|
343
|
+
);
|
|
344
|
+
--wui-color-fg-250: color-mix(
|
|
345
|
+
in srgb,
|
|
346
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
347
|
+
var(--wui-color-fg-250)
|
|
348
|
+
);
|
|
349
|
+
--wui-color-fg-275: color-mix(
|
|
350
|
+
in srgb,
|
|
351
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
352
|
+
var(--wui-color-fg-275)
|
|
353
|
+
);
|
|
354
|
+
--wui-color-fg-300: color-mix(
|
|
355
|
+
in srgb,
|
|
356
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
357
|
+
var(--wui-color-fg-300)
|
|
358
|
+
);
|
|
359
|
+
--wui-color-fg-325: color-mix(
|
|
360
|
+
in srgb,
|
|
361
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
362
|
+
var(--wui-color-fg-325)
|
|
363
|
+
);
|
|
364
|
+
--wui-color-fg-350: color-mix(
|
|
365
|
+
in srgb,
|
|
366
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
367
|
+
var(--wui-color-fg-350)
|
|
368
|
+
);
|
|
369
|
+
|
|
370
|
+
--wui-color-bg-100: color-mix(
|
|
371
|
+
in srgb,
|
|
372
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
373
|
+
var(--wui-color-bg-100)
|
|
374
|
+
);
|
|
375
|
+
--wui-color-bg-125: color-mix(
|
|
376
|
+
in srgb,
|
|
377
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
378
|
+
var(--wui-color-bg-125)
|
|
379
|
+
);
|
|
380
|
+
--wui-color-bg-150: color-mix(
|
|
381
|
+
in srgb,
|
|
382
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
383
|
+
var(--wui-color-bg-150)
|
|
384
|
+
);
|
|
385
|
+
--wui-color-bg-175: color-mix(
|
|
386
|
+
in srgb,
|
|
387
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
388
|
+
var(--wui-color-bg-175)
|
|
389
|
+
);
|
|
390
|
+
--wui-color-bg-200: color-mix(
|
|
391
|
+
in srgb,
|
|
392
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
393
|
+
var(--wui-color-bg-200)
|
|
394
|
+
);
|
|
395
|
+
--wui-color-bg-225: color-mix(
|
|
396
|
+
in srgb,
|
|
397
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
398
|
+
var(--wui-color-bg-225)
|
|
399
|
+
);
|
|
400
|
+
--wui-color-bg-250: color-mix(
|
|
401
|
+
in srgb,
|
|
402
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
403
|
+
var(--wui-color-bg-250)
|
|
404
|
+
);
|
|
405
|
+
--wui-color-bg-275: color-mix(
|
|
406
|
+
in srgb,
|
|
407
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
408
|
+
var(--wui-color-bg-275)
|
|
409
|
+
);
|
|
410
|
+
--wui-color-bg-300: color-mix(
|
|
411
|
+
in srgb,
|
|
412
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
413
|
+
var(--wui-color-bg-300)
|
|
414
|
+
);
|
|
415
|
+
--wui-color-bg-325: color-mix(
|
|
416
|
+
in srgb,
|
|
417
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
418
|
+
var(--wui-color-bg-325)
|
|
419
|
+
);
|
|
420
|
+
--wui-color-bg-350: color-mix(
|
|
421
|
+
in srgb,
|
|
422
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
423
|
+
var(--wui-color-bg-350)
|
|
424
|
+
);
|
|
425
|
+
|
|
426
|
+
--wui-color-success-100: color-mix(
|
|
427
|
+
in srgb,
|
|
428
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
429
|
+
var(--wui-color-success-base-100)
|
|
430
|
+
);
|
|
431
|
+
--wui-color-success-125: color-mix(
|
|
432
|
+
in srgb,
|
|
433
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
434
|
+
var(--wui-color-success-base-125)
|
|
435
|
+
);
|
|
436
|
+
|
|
437
|
+
--wui-color-warning-100: color-mix(
|
|
438
|
+
in srgb,
|
|
439
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
440
|
+
var(--wui-color-warning-base-100)
|
|
441
|
+
);
|
|
442
|
+
|
|
443
|
+
--wui-color-error-100: color-mix(
|
|
444
|
+
in srgb,
|
|
445
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
446
|
+
var(--wui-color-error-base-100)
|
|
447
|
+
);
|
|
448
|
+
--wui-color-blue-100: color-mix(
|
|
449
|
+
in srgb,
|
|
450
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
451
|
+
var(--wui-color-blue-base-100)
|
|
452
|
+
);
|
|
453
|
+
--wui-color-blue-90: color-mix(
|
|
454
|
+
in srgb,
|
|
455
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
456
|
+
var(--wui-color-blue-base-90)
|
|
457
|
+
);
|
|
458
|
+
--wui-color-error-125: color-mix(
|
|
459
|
+
in srgb,
|
|
460
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
461
|
+
var(--wui-color-error-base-125)
|
|
462
|
+
);
|
|
463
|
+
|
|
464
|
+
--wui-icon-box-bg-error-100: color-mix(
|
|
465
|
+
in srgb,
|
|
466
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
467
|
+
var(--wui-icon-box-bg-error-base-100)
|
|
468
|
+
);
|
|
469
|
+
--wui-icon-box-bg-accent-100: color-mix(
|
|
470
|
+
in srgb,
|
|
471
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
472
|
+
var(--wui-icon-box-bg-blue-base-100)
|
|
473
|
+
);
|
|
474
|
+
--wui-icon-box-bg-success-100: color-mix(
|
|
475
|
+
in srgb,
|
|
476
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
477
|
+
var(--wui-icon-box-bg-success-base-100)
|
|
478
|
+
);
|
|
479
|
+
--wui-icon-box-bg-inverse-100: color-mix(
|
|
480
|
+
in srgb,
|
|
481
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
482
|
+
var(--wui-icon-box-bg-inverse-base-100)
|
|
483
|
+
);
|
|
484
|
+
|
|
485
|
+
--wui-all-wallets-bg-100: color-mix(
|
|
486
|
+
in srgb,
|
|
487
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
488
|
+
var(--wui-all-wallets-bg-100)
|
|
489
|
+
);
|
|
490
|
+
|
|
491
|
+
--wui-avatar-border: color-mix(
|
|
492
|
+
in srgb,
|
|
493
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
494
|
+
var(--wui-avatar-border-base)
|
|
495
|
+
);
|
|
496
|
+
|
|
497
|
+
--wui-thumbnail-border: color-mix(
|
|
498
|
+
in srgb,
|
|
499
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
500
|
+
var(--wui-thumbnail-border-base)
|
|
501
|
+
);
|
|
502
|
+
|
|
503
|
+
--wui-wallet-button-bg: color-mix(
|
|
504
|
+
in srgb,
|
|
505
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
506
|
+
var(--wui-wallet-button-bg-base)
|
|
507
|
+
);
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
`,light:sa`
|
|
511
|
+
:root {
|
|
512
|
+
--w3m-color-mix: ${Ai(t?.["--w3m-color-mix"]||"#fff")};
|
|
513
|
+
--w3m-accent: ${Ai(en(t,"dark")["--w3m-accent"])};
|
|
514
|
+
--w3m-default: #fff;
|
|
515
|
+
|
|
516
|
+
--wui-color-modal-bg-base: ${Ai(en(t,"dark")["--w3m-background"])};
|
|
517
|
+
--wui-color-accent-base-100: var(--w3m-accent);
|
|
518
|
+
|
|
519
|
+
--wui-color-blueberry-100: hsla(230, 100%, 67%, 1);
|
|
520
|
+
--wui-color-blueberry-090: hsla(231, 76%, 61%, 1);
|
|
521
|
+
--wui-color-blueberry-080: hsla(230, 59%, 55%, 1);
|
|
522
|
+
--wui-color-blueberry-050: hsla(231, 100%, 70%, 0.1);
|
|
523
|
+
|
|
524
|
+
--wui-color-fg-100: #e4e7e7;
|
|
525
|
+
--wui-color-fg-125: #d0d5d5;
|
|
526
|
+
--wui-color-fg-150: #a8b1b1;
|
|
527
|
+
--wui-color-fg-175: #a8b0b0;
|
|
528
|
+
--wui-color-fg-200: #949e9e;
|
|
529
|
+
--wui-color-fg-225: #868f8f;
|
|
530
|
+
--wui-color-fg-250: #788080;
|
|
531
|
+
--wui-color-fg-275: #788181;
|
|
532
|
+
--wui-color-fg-300: #6e7777;
|
|
533
|
+
--wui-color-fg-325: #9a9a9a;
|
|
534
|
+
--wui-color-fg-350: #363636;
|
|
535
|
+
|
|
536
|
+
--wui-color-bg-100: #141414;
|
|
537
|
+
--wui-color-bg-125: #191a1a;
|
|
538
|
+
--wui-color-bg-150: #1e1f1f;
|
|
539
|
+
--wui-color-bg-175: #222525;
|
|
540
|
+
--wui-color-bg-200: #272a2a;
|
|
541
|
+
--wui-color-bg-225: #2c3030;
|
|
542
|
+
--wui-color-bg-250: #313535;
|
|
543
|
+
--wui-color-bg-275: #363b3b;
|
|
544
|
+
--wui-color-bg-300: #3b4040;
|
|
545
|
+
--wui-color-bg-325: #252525;
|
|
546
|
+
--wui-color-bg-350: #ffffff;
|
|
547
|
+
|
|
548
|
+
--wui-color-success-base-100: #26d962;
|
|
549
|
+
--wui-color-success-base-125: #30a46b;
|
|
550
|
+
|
|
551
|
+
--wui-color-warning-base-100: #f3a13f;
|
|
552
|
+
|
|
553
|
+
--wui-color-error-base-100: #f25a67;
|
|
554
|
+
--wui-color-error-base-125: #df4a34;
|
|
555
|
+
|
|
556
|
+
--wui-color-blue-base-100: rgba(102, 125, 255, 1);
|
|
557
|
+
--wui-color-blue-base-90: rgba(102, 125, 255, 0.9);
|
|
558
|
+
|
|
559
|
+
--wui-color-success-glass-001: rgba(38, 217, 98, 0.01);
|
|
560
|
+
--wui-color-success-glass-002: rgba(38, 217, 98, 0.02);
|
|
561
|
+
--wui-color-success-glass-005: rgba(38, 217, 98, 0.05);
|
|
562
|
+
--wui-color-success-glass-010: rgba(38, 217, 98, 0.1);
|
|
563
|
+
--wui-color-success-glass-015: rgba(38, 217, 98, 0.15);
|
|
564
|
+
--wui-color-success-glass-020: rgba(38, 217, 98, 0.2);
|
|
565
|
+
--wui-color-success-glass-025: rgba(38, 217, 98, 0.25);
|
|
566
|
+
--wui-color-success-glass-030: rgba(38, 217, 98, 0.3);
|
|
567
|
+
--wui-color-success-glass-060: rgba(38, 217, 98, 0.6);
|
|
568
|
+
--wui-color-success-glass-080: rgba(38, 217, 98, 0.8);
|
|
569
|
+
|
|
570
|
+
--wui-color-success-glass-reown-020: rgba(48, 164, 107, 0.2);
|
|
571
|
+
|
|
572
|
+
--wui-color-warning-glass-reown-020: rgba(243, 161, 63, 0.2);
|
|
573
|
+
|
|
574
|
+
--wui-color-error-glass-001: rgba(242, 90, 103, 0.01);
|
|
575
|
+
--wui-color-error-glass-002: rgba(242, 90, 103, 0.02);
|
|
576
|
+
--wui-color-error-glass-005: rgba(242, 90, 103, 0.05);
|
|
577
|
+
--wui-color-error-glass-010: rgba(242, 90, 103, 0.1);
|
|
578
|
+
--wui-color-error-glass-015: rgba(242, 90, 103, 0.15);
|
|
579
|
+
--wui-color-error-glass-020: rgba(242, 90, 103, 0.2);
|
|
580
|
+
--wui-color-error-glass-025: rgba(242, 90, 103, 0.25);
|
|
581
|
+
--wui-color-error-glass-030: rgba(242, 90, 103, 0.3);
|
|
582
|
+
--wui-color-error-glass-060: rgba(242, 90, 103, 0.6);
|
|
583
|
+
--wui-color-error-glass-080: rgba(242, 90, 103, 0.8);
|
|
584
|
+
|
|
585
|
+
--wui-color-error-glass-reown-020: rgba(223, 74, 52, 0.2);
|
|
586
|
+
|
|
587
|
+
--wui-color-gray-glass-001: rgba(255, 255, 255, 0.01);
|
|
588
|
+
--wui-color-gray-glass-002: rgba(255, 255, 255, 0.02);
|
|
589
|
+
--wui-color-gray-glass-005: rgba(255, 255, 255, 0.05);
|
|
590
|
+
--wui-color-gray-glass-010: rgba(255, 255, 255, 0.1);
|
|
591
|
+
--wui-color-gray-glass-015: rgba(255, 255, 255, 0.15);
|
|
592
|
+
--wui-color-gray-glass-020: rgba(255, 255, 255, 0.2);
|
|
593
|
+
--wui-color-gray-glass-025: rgba(255, 255, 255, 0.25);
|
|
594
|
+
--wui-color-gray-glass-030: rgba(255, 255, 255, 0.3);
|
|
595
|
+
--wui-color-gray-glass-060: rgba(255, 255, 255, 0.6);
|
|
596
|
+
--wui-color-gray-glass-080: rgba(255, 255, 255, 0.8);
|
|
597
|
+
--wui-color-gray-glass-090: rgba(255, 255, 255, 0.9);
|
|
598
|
+
|
|
599
|
+
--wui-color-dark-glass-100: rgba(42, 42, 42, 1);
|
|
600
|
+
|
|
601
|
+
--wui-icon-box-bg-error-base-100: #3c2426;
|
|
602
|
+
--wui-icon-box-bg-blue-base-100: #20303f;
|
|
603
|
+
--wui-icon-box-bg-success-base-100: #1f3a28;
|
|
604
|
+
--wui-icon-box-bg-inverse-base-100: #243240;
|
|
605
|
+
|
|
606
|
+
--wui-all-wallets-bg-100: #222b35;
|
|
607
|
+
|
|
608
|
+
--wui-avatar-border-base: #252525;
|
|
609
|
+
|
|
610
|
+
--wui-thumbnail-border-base: #252525;
|
|
611
|
+
|
|
612
|
+
--wui-wallet-button-bg-base: var(--wui-color-bg-125);
|
|
613
|
+
|
|
614
|
+
--w3m-card-embedded-shadow-color: rgb(17 17 18 / 25%);
|
|
615
|
+
}
|
|
616
|
+
`,dark:sa`
|
|
617
|
+
:root {
|
|
618
|
+
--w3m-color-mix: ${Ai(t?.["--w3m-color-mix"]||"#000")};
|
|
619
|
+
--w3m-accent: ${Ai(en(t,"light")["--w3m-accent"])};
|
|
620
|
+
--w3m-default: #000;
|
|
621
|
+
|
|
622
|
+
--wui-color-modal-bg-base: ${Ai(en(t,"light")["--w3m-background"])};
|
|
623
|
+
--wui-color-accent-base-100: var(--w3m-accent);
|
|
624
|
+
|
|
625
|
+
--wui-color-blueberry-100: hsla(231, 100%, 70%, 1);
|
|
626
|
+
--wui-color-blueberry-090: hsla(231, 97%, 72%, 1);
|
|
627
|
+
--wui-color-blueberry-080: hsla(231, 92%, 74%, 1);
|
|
628
|
+
|
|
629
|
+
--wui-color-fg-100: #141414;
|
|
630
|
+
--wui-color-fg-125: #2d3131;
|
|
631
|
+
--wui-color-fg-150: #474d4d;
|
|
632
|
+
--wui-color-fg-175: #636d6d;
|
|
633
|
+
--wui-color-fg-200: #798686;
|
|
634
|
+
--wui-color-fg-225: #828f8f;
|
|
635
|
+
--wui-color-fg-250: #8b9797;
|
|
636
|
+
--wui-color-fg-275: #95a0a0;
|
|
637
|
+
--wui-color-fg-300: #9ea9a9;
|
|
638
|
+
--wui-color-fg-325: #9a9a9a;
|
|
639
|
+
--wui-color-fg-350: #d0d0d0;
|
|
640
|
+
|
|
641
|
+
--wui-color-bg-100: #ffffff;
|
|
642
|
+
--wui-color-bg-125: #f5fafa;
|
|
643
|
+
--wui-color-bg-150: #f3f8f8;
|
|
644
|
+
--wui-color-bg-175: #eef4f4;
|
|
645
|
+
--wui-color-bg-200: #eaf1f1;
|
|
646
|
+
--wui-color-bg-225: #e5eded;
|
|
647
|
+
--wui-color-bg-250: #e1e9e9;
|
|
648
|
+
--wui-color-bg-275: #dce7e7;
|
|
649
|
+
--wui-color-bg-300: #d8e3e3;
|
|
650
|
+
--wui-color-bg-325: #f3f3f3;
|
|
651
|
+
--wui-color-bg-350: #202020;
|
|
652
|
+
|
|
653
|
+
--wui-color-success-base-100: #26b562;
|
|
654
|
+
--wui-color-success-base-125: #30a46b;
|
|
655
|
+
|
|
656
|
+
--wui-color-warning-base-100: #f3a13f;
|
|
657
|
+
|
|
658
|
+
--wui-color-error-base-100: #f05142;
|
|
659
|
+
--wui-color-error-base-125: #df4a34;
|
|
660
|
+
|
|
661
|
+
--wui-color-blue-base-100: rgba(102, 125, 255, 1);
|
|
662
|
+
--wui-color-blue-base-90: rgba(102, 125, 255, 0.9);
|
|
663
|
+
|
|
664
|
+
--wui-color-success-glass-001: rgba(38, 181, 98, 0.01);
|
|
665
|
+
--wui-color-success-glass-002: rgba(38, 181, 98, 0.02);
|
|
666
|
+
--wui-color-success-glass-005: rgba(38, 181, 98, 0.05);
|
|
667
|
+
--wui-color-success-glass-010: rgba(38, 181, 98, 0.1);
|
|
668
|
+
--wui-color-success-glass-015: rgba(38, 181, 98, 0.15);
|
|
669
|
+
--wui-color-success-glass-020: rgba(38, 181, 98, 0.2);
|
|
670
|
+
--wui-color-success-glass-025: rgba(38, 181, 98, 0.25);
|
|
671
|
+
--wui-color-success-glass-030: rgba(38, 181, 98, 0.3);
|
|
672
|
+
--wui-color-success-glass-060: rgba(38, 181, 98, 0.6);
|
|
673
|
+
--wui-color-success-glass-080: rgba(38, 181, 98, 0.8);
|
|
674
|
+
|
|
675
|
+
--wui-color-success-glass-reown-020: rgba(48, 164, 107, 0.2);
|
|
676
|
+
|
|
677
|
+
--wui-color-warning-glass-reown-020: rgba(243, 161, 63, 0.2);
|
|
678
|
+
|
|
679
|
+
--wui-color-error-glass-001: rgba(240, 81, 66, 0.01);
|
|
680
|
+
--wui-color-error-glass-002: rgba(240, 81, 66, 0.02);
|
|
681
|
+
--wui-color-error-glass-005: rgba(240, 81, 66, 0.05);
|
|
682
|
+
--wui-color-error-glass-010: rgba(240, 81, 66, 0.1);
|
|
683
|
+
--wui-color-error-glass-015: rgba(240, 81, 66, 0.15);
|
|
684
|
+
--wui-color-error-glass-020: rgba(240, 81, 66, 0.2);
|
|
685
|
+
--wui-color-error-glass-025: rgba(240, 81, 66, 0.25);
|
|
686
|
+
--wui-color-error-glass-030: rgba(240, 81, 66, 0.3);
|
|
687
|
+
--wui-color-error-glass-060: rgba(240, 81, 66, 0.6);
|
|
688
|
+
--wui-color-error-glass-080: rgba(240, 81, 66, 0.8);
|
|
689
|
+
|
|
690
|
+
--wui-color-error-glass-reown-020: rgba(223, 74, 52, 0.2);
|
|
691
|
+
|
|
692
|
+
--wui-icon-box-bg-error-base-100: #f4dfdd;
|
|
693
|
+
--wui-icon-box-bg-blue-base-100: #d9ecfb;
|
|
694
|
+
--wui-icon-box-bg-success-base-100: #daf0e4;
|
|
695
|
+
--wui-icon-box-bg-inverse-base-100: #dcecfc;
|
|
696
|
+
|
|
697
|
+
--wui-all-wallets-bg-100: #e8f1fa;
|
|
698
|
+
|
|
699
|
+
--wui-avatar-border-base: #f3f4f4;
|
|
700
|
+
|
|
701
|
+
--wui-thumbnail-border-base: #eaefef;
|
|
702
|
+
|
|
703
|
+
--wui-wallet-button-bg-base: var(--wui-color-bg-125);
|
|
704
|
+
|
|
705
|
+
--wui-color-gray-glass-001: rgba(0, 0, 0, 0.01);
|
|
706
|
+
--wui-color-gray-glass-002: rgba(0, 0, 0, 0.02);
|
|
707
|
+
--wui-color-gray-glass-005: rgba(0, 0, 0, 0.05);
|
|
708
|
+
--wui-color-gray-glass-010: rgba(0, 0, 0, 0.1);
|
|
709
|
+
--wui-color-gray-glass-015: rgba(0, 0, 0, 0.15);
|
|
710
|
+
--wui-color-gray-glass-020: rgba(0, 0, 0, 0.2);
|
|
711
|
+
--wui-color-gray-glass-025: rgba(0, 0, 0, 0.25);
|
|
712
|
+
--wui-color-gray-glass-030: rgba(0, 0, 0, 0.3);
|
|
713
|
+
--wui-color-gray-glass-060: rgba(0, 0, 0, 0.6);
|
|
714
|
+
--wui-color-gray-glass-080: rgba(0, 0, 0, 0.8);
|
|
715
|
+
--wui-color-gray-glass-090: rgba(0, 0, 0, 0.9);
|
|
716
|
+
|
|
717
|
+
--wui-color-dark-glass-100: rgba(233, 233, 233, 1);
|
|
718
|
+
|
|
719
|
+
--w3m-card-embedded-shadow-color: rgb(224 225 233 / 25%);
|
|
720
|
+
}
|
|
721
|
+
`}}const AZ=sa`
|
|
722
|
+
*,
|
|
723
|
+
*::after,
|
|
724
|
+
*::before,
|
|
725
|
+
:host {
|
|
726
|
+
margin: 0;
|
|
727
|
+
padding: 0;
|
|
728
|
+
box-sizing: border-box;
|
|
729
|
+
font-style: normal;
|
|
730
|
+
text-rendering: optimizeSpeed;
|
|
731
|
+
-webkit-font-smoothing: antialiased;
|
|
732
|
+
-moz-osx-font-smoothing: grayscale;
|
|
733
|
+
-webkit-tap-highlight-color: transparent;
|
|
734
|
+
font-family: var(--wui-font-family);
|
|
735
|
+
backface-visibility: hidden;
|
|
736
|
+
}
|
|
737
|
+
`,SZ=sa`
|
|
738
|
+
button,
|
|
739
|
+
a {
|
|
740
|
+
cursor: pointer;
|
|
741
|
+
display: flex;
|
|
742
|
+
justify-content: center;
|
|
743
|
+
align-items: center;
|
|
744
|
+
position: relative;
|
|
745
|
+
transition:
|
|
746
|
+
color var(--wui-duration-lg) var(--wui-ease-out-power-1),
|
|
747
|
+
background-color var(--wui-duration-lg) var(--wui-ease-out-power-1),
|
|
748
|
+
border var(--wui-duration-lg) var(--wui-ease-out-power-1),
|
|
749
|
+
border-radius var(--wui-duration-lg) var(--wui-ease-out-power-1),
|
|
750
|
+
box-shadow var(--wui-duration-lg) var(--wui-ease-out-power-1);
|
|
751
|
+
will-change: background-color, color, border, box-shadow, border-radius;
|
|
752
|
+
outline: none;
|
|
753
|
+
border: none;
|
|
754
|
+
column-gap: var(--wui-spacing-3xs);
|
|
755
|
+
background-color: transparent;
|
|
756
|
+
text-decoration: none;
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
wui-flex {
|
|
760
|
+
transition: border-radius var(--wui-duration-lg) var(--wui-ease-out-power-1);
|
|
761
|
+
will-change: border-radius;
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
button:disabled > wui-wallet-image,
|
|
765
|
+
button:disabled > wui-all-wallets-image,
|
|
766
|
+
button:disabled > wui-network-image,
|
|
767
|
+
button:disabled > wui-image,
|
|
768
|
+
button:disabled > wui-transaction-visual,
|
|
769
|
+
button:disabled > wui-logo {
|
|
770
|
+
filter: grayscale(1);
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
@media (hover: hover) and (pointer: fine) {
|
|
774
|
+
button:hover:enabled {
|
|
775
|
+
background-color: var(--wui-color-gray-glass-005);
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
button:active:enabled {
|
|
779
|
+
background-color: var(--wui-color-gray-glass-010);
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
button:disabled > wui-icon-box {
|
|
784
|
+
opacity: 0.5;
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
input {
|
|
788
|
+
border: none;
|
|
789
|
+
outline: none;
|
|
790
|
+
appearance: none;
|
|
791
|
+
}
|
|
792
|
+
`,CZ=sa`
|
|
793
|
+
.wui-color-inherit {
|
|
794
|
+
color: var(--wui-color-inherit);
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
.wui-color-accent-100 {
|
|
798
|
+
color: var(--wui-color-accent-100);
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
.wui-color-error-100 {
|
|
802
|
+
color: var(--wui-color-error-100);
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
.wui-color-blue-100 {
|
|
806
|
+
color: var(--wui-color-blue-100);
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
.wui-color-blue-90 {
|
|
810
|
+
color: var(--wui-color-blue-90);
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
.wui-color-error-125 {
|
|
814
|
+
color: var(--wui-color-error-125);
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
.wui-color-success-100 {
|
|
818
|
+
color: var(--wui-color-success-100);
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
.wui-color-success-125 {
|
|
822
|
+
color: var(--wui-color-success-125);
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
.wui-color-inverse-100 {
|
|
826
|
+
color: var(--wui-color-inverse-100);
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
.wui-color-inverse-000 {
|
|
830
|
+
color: var(--wui-color-inverse-000);
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
.wui-color-fg-100 {
|
|
834
|
+
color: var(--wui-color-fg-100);
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
.wui-color-fg-200 {
|
|
838
|
+
color: var(--wui-color-fg-200);
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
.wui-color-fg-300 {
|
|
842
|
+
color: var(--wui-color-fg-300);
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
.wui-color-fg-325 {
|
|
846
|
+
color: var(--wui-color-fg-325);
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
.wui-color-fg-350 {
|
|
850
|
+
color: var(--wui-color-fg-350);
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
.wui-bg-color-inherit {
|
|
854
|
+
background-color: var(--wui-color-inherit);
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
.wui-bg-color-blue-100 {
|
|
858
|
+
background-color: var(--wui-color-accent-100);
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
.wui-bg-color-error-100 {
|
|
862
|
+
background-color: var(--wui-color-error-100);
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
.wui-bg-color-error-125 {
|
|
866
|
+
background-color: var(--wui-color-error-125);
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
.wui-bg-color-success-100 {
|
|
870
|
+
background-color: var(--wui-color-success-100);
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
.wui-bg-color-success-125 {
|
|
874
|
+
background-color: var(--wui-color-success-100);
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
.wui-bg-color-inverse-100 {
|
|
878
|
+
background-color: var(--wui-color-inverse-100);
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
.wui-bg-color-inverse-000 {
|
|
882
|
+
background-color: var(--wui-color-inverse-000);
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
.wui-bg-color-fg-100 {
|
|
886
|
+
background-color: var(--wui-color-fg-100);
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
.wui-bg-color-fg-200 {
|
|
890
|
+
background-color: var(--wui-color-fg-200);
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
.wui-bg-color-fg-300 {
|
|
894
|
+
background-color: var(--wui-color-fg-300);
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
.wui-color-fg-325 {
|
|
898
|
+
background-color: var(--wui-color-fg-325);
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
.wui-color-fg-350 {
|
|
902
|
+
background-color: var(--wui-color-fg-350);
|
|
903
|
+
}
|
|
904
|
+
`,Tl={ERROR_CODE_UNRECOGNIZED_CHAIN_ID:4902,ERROR_CODE_DEFAULT:5e3,ERROR_INVALID_CHAIN_ID:32603};function ju(t){return{formatters:void 0,fees:void 0,serializers:void 0,...t}}const tg=ju({id:"5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",name:"Solana",network:"solana-mainnet",nativeCurrency:{name:"Solana",symbol:"SOL",decimals:9},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}},blockExplorers:{default:{name:"Solscan",url:"https://solscan.io"}},testnet:!1,chainNamespace:"solana",caipNetworkId:"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",deprecatedCaipNetworkId:"solana:4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ"}),rg=ju({id:"EtWTRABZaYq6iMfeYKouRu166VU2xqa1",name:"Solana Devnet",network:"solana-devnet",nativeCurrency:{name:"Solana",symbol:"SOL",decimals:9},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}},blockExplorers:{default:{name:"Solscan",url:"https://solscan.io"}},testnet:!0,chainNamespace:"solana",caipNetworkId:"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",deprecatedCaipNetworkId:"solana:8E9rvCKLFQia2Y35HXjjpWzj8weVo44K"}),tQ=ju({id:"4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z",name:"Solana Testnet",network:"solana-testnet",nativeCurrency:{name:"Solana",symbol:"SOL",decimals:9},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}},blockExplorers:{default:{name:"Solscan",url:"https://solscan.io"}},testnet:!0,chainNamespace:"solana",caipNetworkId:"solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z"});ju({id:"000000000019d6689c085ae165831e93",caipNetworkId:"bip122:000000000019d6689c085ae165831e93",chainNamespace:"bip122",name:"Bitcoin",nativeCurrency:{name:"Bitcoin",symbol:"BTC",decimals:8},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}}});ju({id:"000000000933ea01ad0ee984209779ba",caipNetworkId:"bip122:000000000933ea01ad0ee984209779ba",chainNamespace:"bip122",name:"Bitcoin Testnet",nativeCurrency:{name:"Bitcoin",symbol:"BTC",decimals:8},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}},testnet:!0});const rQ={solana:["solana_signMessage","solana_signTransaction","solana_requestAccounts","solana_getAccounts","solana_signAllTransactions","solana_signAndSendTransaction"],eip155:["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_getCallsStatus","wallet_showCallsStatus","wallet_sendCalls","wallet_getCapabilities","wallet_grantPermissions","wallet_revokePermissions","wallet_getAssets"],bip122:["sendTransfer","signMessage","signPsbt","getAccountAddresses"]},$E={getMethodsByChainNamespace(t){return rQ[t]||[]},createDefaultNamespace(t){return{methods:this.getMethodsByChainNamespace(t),events:["accountsChanged","chainChanged"],chains:[],rpcMap:{}}},applyNamespaceOverrides(t,e){if(!e)return{...t};const r={...t},i=new Set;if(e.methods&&Object.keys(e.methods).forEach(s=>i.add(s)),e.chains&&Object.keys(e.chains).forEach(s=>i.add(s)),e.events&&Object.keys(e.events).forEach(s=>i.add(s)),e.rpcMap&&Object.keys(e.rpcMap).forEach(s=>{const[n]=s.split(":");n&&i.add(n)}),i.forEach(s=>{r[s]||(r[s]=this.createDefaultNamespace(s))}),e.methods&&Object.entries(e.methods).forEach(([s,n])=>{r[s]&&(r[s].methods=n)}),e.chains&&Object.entries(e.chains).forEach(([s,n])=>{r[s]&&(r[s].chains=n)}),e.events&&Object.entries(e.events).forEach(([s,n])=>{r[s]&&(r[s].events=n)}),e.rpcMap){const s=new Set;Object.entries(e.rpcMap).forEach(([n,o])=>{const[a,u]=n.split(":");!a||!u||!r[a]||(r[a].rpcMap||(r[a].rpcMap={}),s.has(a)||(r[a].rpcMap={},s.add(a)),r[a].rpcMap[u]=o)})}return r},createNamespaces(t,e){const r=t.reduce((i,s)=>{const{id:n,chainNamespace:o,rpcUrls:a}=s,u=a.default.http[0];i[o]||(i[o]=this.createDefaultNamespace(o));const c=`${o}:${n}`,l=i[o];switch(l.chains.push(c),c){case tg.caipNetworkId:l.chains.push(tg.deprecatedCaipNetworkId);break;case rg.caipNetworkId:l.chains.push(rg.deprecatedCaipNetworkId);break}return l?.rpcMap&&u&&(l.rpcMap[n]=u),i},{});return this.applyNamespaceOverrides(r,e)},resolveReownName:async t=>{const e=await X3.resolveName(t);return(Object.values(e?.addresses)||[])[0]?.address||!1},getChainsFromNamespaces(t={}){return Object.values(t).flatMap(e=>{const r=e.chains||[],i=e.accounts.map(s=>{const[n,o]=s.split(":");return`${n}:${o}`});return Array.from(new Set([...r,...i]))})},isSessionEventData(t){return typeof t=="object"&&t!==null&&"id"in t&&"topic"in t&&"params"in t&&typeof t.params=="object"&&t.params!==null&&"chainId"in t.params&&"event"in t.params&&typeof t.params.event=="object"&&t.params.event!==null}};class xE{constructor({provider:e,caipNetworks:r,namespace:i}){this.id=ne.CONNECTOR_ID.WALLET_CONNECT,this.name=gh.ConnectorNamesMap[ne.CONNECTOR_ID.WALLET_CONNECT],this.type="WALLET_CONNECT",this.imageId=gh.ConnectorImageIds[ne.CONNECTOR_ID.WALLET_CONNECT],this.caipNetworks=r,this.provider=e,this.chain=i}get chains(){return this.caipNetworks}async connectWalletConnect(){if(!await this.authenticate()){const r=J.state.universalProviderConfigOverride,i=$E.createNamespaces(this.caipNetworks,r);await this.provider.connect({optionalNamespaces:i})}return{clientId:await this.provider.client.core.crypto.getClientId(),session:this.provider.session}}async disconnect(){await this.provider.disconnect()}async authenticate(){const e=this.chains.map(r=>r.caipNetworkId);return Oc.universalProviderAuthenticate({universalProvider:this.provider,chains:e,methods:iQ})}}const iQ=["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_getCallsStatus","wallet_sendCalls","wallet_getCapabilities","wallet_grantPermissions","wallet_revokePermissions","wallet_getAssets"];class sQ{constructor(e){this.availableConnectors=[],this.eventListeners=new Map,e&&this.construct(e)}construct(e){this.caipNetworks=e.networks,this.projectId=e.projectId,this.namespace=e.namespace,this.adapterType=e.adapterType}get connectors(){return this.availableConnectors}get networks(){return this.caipNetworks||[]}setAuthProvider(e){this.addConnector({id:ne.CONNECTOR_ID.AUTH,type:"AUTH",name:ne.CONNECTOR_NAMES.AUTH,provider:e,imageId:gh.ConnectorImageIds[ne.CONNECTOR_ID.AUTH],chain:this.namespace,chains:[]})}addConnector(...e){const r=new Set;this.availableConnectors=[...e,...this.availableConnectors].filter(i=>r.has(i.id)?!1:(r.add(i.id),!0)),this.emit("connectors",this.availableConnectors)}setStatus(e,r){oe.setStatus(e,r)}on(e,r){this.eventListeners.has(e)||this.eventListeners.set(e,new Set),this.eventListeners.get(e)?.add(r)}off(e,r){const i=this.eventListeners.get(e);i&&i.delete(r)}removeAllEventListeners(){this.eventListeners.forEach(e=>{e.clear()})}emit(e,r){const i=this.eventListeners.get(e);i&&i.forEach(s=>s(r))}async connectWalletConnect(e){return{clientId:(await this.getWalletConnectConnector().connectWalletConnect()).clientId}}async switchNetwork(e){const{caipNetwork:r,providerType:i}=e;if(!e.provider)return;const s="provider"in e.provider?e.provider.provider:e.provider;if(i==="WALLET_CONNECT"){s.setDefaultChain(r.caipNetworkId);return}if(s&&i==="AUTH"){const n=s;await n.switchNetwork(r.caipNetworkId);const o=await n.getUser({chainId:r.caipNetworkId,preferredAccountType:J.state.defaultAccountTypes[r.chainNamespace]});this.emit("switchNetwork",o)}}getWalletConnectConnector(){const e=this.connectors.find(r=>r instanceof xE);if(!e)throw new Error("WalletConnectConnector not found");return e}}class nQ extends sQ{setUniversalProvider(e){this.addConnector(new xE({provider:e,caipNetworks:this.caipNetworks||[],namespace:this.namespace}))}async connect(e){return Promise.resolve({id:"WALLET_CONNECT",type:"WALLET_CONNECT",chainId:Number(e.chainId),provider:this.provider,address:""})}async disconnect(){try{await this.getWalletConnectConnector().disconnect()}catch(e){console.warn("UniversalAdapter:disconnect - error",e)}}async getAccounts({namespace:e}){const i=this.provider?.session?.namespaces?.[e]?.accounts?.map(s=>{const[,,n]=s.split(":");return n}).filter((s,n,o)=>o.indexOf(s)===n)||[];return Promise.resolve({accounts:i.map(s=>pe.createAccount(e,s,e==="bip122"?"payment":"eoa"))})}async syncConnectors(){return Promise.resolve()}async getBalance(e){if(!(e.caipNetwork&&Jr.BALANCE_SUPPORTED_CHAINS.includes(e.caipNetwork?.chainNamespace))||e.caipNetwork?.testnet)return{balance:"0.00",symbol:e.caipNetwork?.nativeCurrency.symbol||""};if(oe.state.balanceLoading&&e.chainId===F.state.activeCaipNetwork?.id)return{balance:oe.state.balance||"0.00",symbol:oe.state.balanceSymbol||""};const s=(await oe.fetchTokenBalance()).find(n=>n.chainId===`${e.caipNetwork?.chainNamespace}:${e.chainId}`&&n.symbol===e.caipNetwork?.nativeCurrency.symbol);return{balance:s?.quantity.numeric||"0.00",symbol:s?.symbol||e.caipNetwork?.nativeCurrency.symbol||""}}async signMessage(e){const{provider:r,message:i,address:s}=e;if(!r)throw new Error("UniversalAdapter:signMessage - provider is undefined");let n="";return F.state.activeCaipNetwork?.chainNamespace===ne.CHAIN.SOLANA?n=(await r.request({method:"solana_signMessage",params:{message:Nc.encode(new TextEncoder().encode(i)),pubkey:s}},F.state.activeCaipNetwork?.caipNetworkId)).signature:n=await r.request({method:"personal_sign",params:[i,s]},F.state.activeCaipNetwork?.caipNetworkId),{signature:n}}async estimateGas(){return Promise.resolve({gas:BigInt(0)})}async getProfile(){return Promise.resolve({profileImage:"",profileName:""})}async sendTransaction(){return Promise.resolve({hash:""})}walletGetAssets(e){return Promise.resolve({})}async writeContract(){return Promise.resolve({hash:""})}async getEnsAddress(){return Promise.resolve({address:!1})}parseUnits(){return 0n}formatUnits(){return"0"}async getCapabilities(){return Promise.resolve({})}async grantPermissions(){return Promise.resolve({})}async revokePermissions(){return Promise.resolve("0x")}async syncConnection(){return Promise.resolve({id:"WALLET_CONNECT",type:"WALLET_CONNECT",chainId:1,provider:this.provider,address:""})}async switchNetwork(e){const{caipNetwork:r}=e,i=this.getWalletConnectConnector();if(r.chainNamespace===ne.CHAIN.EVM)try{await i.provider?.request({method:"wallet_switchEthereumChain",params:[{chainId:Jy(r.id)}]})}catch(s){if(s.code===Tl.ERROR_CODE_UNRECOGNIZED_CHAIN_ID||s.code===Tl.ERROR_INVALID_CHAIN_ID||s.code===Tl.ERROR_CODE_DEFAULT||s?.data?.originalError?.code===Tl.ERROR_CODE_UNRECOGNIZED_CHAIN_ID)try{await i.provider?.request({method:"wallet_addEthereumChain",params:[{chainId:Jy(r.id),rpcUrls:[r?.rpcUrls.chainDefault?.http],chainName:r.name,nativeCurrency:r.nativeCurrency,blockExplorerUrls:[r.blockExplorers?.default.url]}]})}catch{throw new Error("Chain is not supported")}}i.provider.setDefaultChain(r.caipNetworkId)}getWalletConnectProvider(){return this.connectors.find(i=>i.type==="WALLET_CONNECT")?.provider}}class oQ{constructor(e){this.hasSwitchedToPreferredAccountTypeOnConnect=!1,this.chainNamespaces=[],this.reportedAlertErrors={},this.getCaipNetwork=r=>{if(r){const i=F.getNetworkData(r)?.caipNetwork;return i||F.getRequestedCaipNetworks(r).filter(s=>s.chainNamespace===r)?.[0]}return F.state.activeCaipNetwork||this.defaultCaipNetwork},this.getCaipNetworkId=()=>{const r=this.getCaipNetwork();if(r)return r.id},this.getCaipNetworks=r=>F.getRequestedCaipNetworks(r),this.getActiveChainNamespace=()=>F.state.activeChain,this.setRequestedCaipNetworks=(r,i)=>{F.setRequestedCaipNetworks(r,i)},this.getApprovedCaipNetworkIds=()=>F.getAllApprovedCaipNetworkIds(),this.getCaipAddress=r=>F.state.activeChain===r||!r?F.state.activeCaipAddress:F.getAccountProp("caipAddress",r),this.setClientId=r=>{ue.setClientId(r)},this.getProvider=r=>Ot.getProvider(r),this.getProviderType=r=>Ot.getProviderId(r),this.getPreferredAccountType=()=>oe.state.preferredAccountType,this.setCaipAddress=(r,i)=>{oe.setCaipAddress(r,i)},this.setBalance=(r,i,s)=>{oe.setBalance(r,i,s)},this.setProfileName=(r,i)=>{oe.setProfileName(r,i)},this.setProfileImage=(r,i)=>{oe.setProfileImage(r,i)},this.setUser=(r,i)=>{oe.setUser(r,i),J.state.enableEmbedded&&Qt.close()},this.resetAccount=r=>{oe.resetAccount(r)},this.setCaipNetwork=r=>{F.setActiveCaipNetwork(r)},this.setCaipNetworkOfNamespace=(r,i)=>{F.setChainNetworkData(i,{caipNetwork:r})},this.setAllAccounts=(r,i)=>{oe.setAllAccounts(r,i),J.setHasMultipleAddresses(r?.length>1)},this.setStatus=(r,i)=>{oe.setStatus(r,i),fe.isConnected()?se.setConnectionStatus("connected"):se.setConnectionStatus("disconnected")},this.getAddressByChainNamespace=r=>F.getAccountProp("address",r),this.setConnectors=r=>{const i=[...fe.getConnectors(),...r];fe.setConnectors(i)},this.fetchIdentity=r=>ue.fetchIdentity(r),this.getReownName=r=>X3.getNamesForAddress(r),this.getConnectors=()=>fe.getConnectors(),this.getConnectorImage=r=>q3.getConnectorImage(r),this.setConnectedWalletInfo=(r,i)=>{const s=Ot.getProviderId(i),n=r?{...r,type:s}:void 0;oe.setConnectedWalletInfo(n,i)},this.getIsConnectedState=()=>!!F.state.activeCaipAddress,this.addAddressLabel=(r,i,s)=>{oe.addAddressLabel(r,i,s)},this.removeAddressLabel=(r,i)=>{oe.removeAddressLabel(r,i)},this.getAddress=r=>F.state.activeChain===r||!r?oe.state.address:F.getAccountProp("address",r),this.setApprovedCaipNetworksData=r=>F.setApprovedCaipNetworksData(r),this.resetNetwork=r=>{F.resetNetwork(r)},this.addConnector=r=>{fe.addConnector(r)},this.resetWcConnection=()=>{ut.resetWcConnection()},this.setAddressExplorerUrl=(r,i)=>{oe.setAddressExplorerUrl(r,i)},this.setSmartAccountDeployed=(r,i)=>{oe.setSmartAccountDeployed(r,i)},this.setSmartAccountEnabledNetworks=(r,i)=>{F.setSmartAccountEnabledNetworks(r,i)},this.setPreferredAccountType=(r,i)=>{oe.setPreferredAccountType(r,i)},this.setEIP6963Enabled=r=>{J.setEIP6963Enabled(r)},this.handleUnsafeRPCRequest=()=>{if(this.isOpen()){if(this.isTransactionStackEmpty())return;this.redirect("ApproveTransaction")}else this.open({view:"ApproveTransaction"})},this.options=e,this.version=e.sdkVersion,this.caipNetworks=this.extendCaipNetworks(e),this.chainNamespaces=[...new Set(this.caipNetworks?.map(r=>r.chainNamespace))],this.defaultCaipNetwork=this.extendDefaultCaipNetwork(e),this.chainAdapters=this.createAdapters(e.adapters),this.initialize(e),this.sendInitializeEvent(e)}async initialize(e){this.initControllers(e),await this.initChainAdapters(),await this.injectModalUi(),await this.syncExistingConnection(),Ps.set({initialized:!0})}sendInitializeEvent(e){const{...r}=e;delete r.adapters,lt.sendEvent({type:"track",event:"INITIALIZE",properties:{...r,networks:e.networks.map(i=>i.id),siweConfig:{options:e.siweConfig?.options||{}}}})}initControllers(e){this.initializeOptionsController(e),this.initializeChainController(e),this.initializeThemeController(e),this.initializeConnectionController(e),this.initializeConnectorController()}initializeThemeController(e){e.themeMode&&kr.setThemeMode(e.themeMode),e.themeVariables&&kr.setThemeVariables(e.themeVariables)}initializeChainController(e){if(!this.connectionControllerClient||!this.networkControllerClient)throw new Error("ConnectionControllerClient and NetworkControllerClient must be set");F.initialize(e.adapters??[],this.caipNetworks,{connectionControllerClient:this.connectionControllerClient,networkControllerClient:this.networkControllerClient});const r=this.getDefaultNetwork();r&&F.setActiveCaipNetwork(r)}initializeConnectionController(e){ut.setWcBasic(e.basic??!1)}initializeConnectorController(){fe.initialize(this.chainNamespaces)}initializeOptionsController(e){J.setDebug(e.debug!==!1),J.setEnableWalletConnect(e.enableWalletConnect!==!1),J.setEnableWalletGuide(e.enableWalletGuide!==!1),J.setEnableWallets(e.enableWallets!==!1),J.setEIP6963Enabled(e.enableEIP6963!==!1),J.setEnableNetworkSwitch(e.enableNetworkSwitch!==!1),J.setEnableAuthLogger(e.enableAuthLogger!==!1),J.setCustomRpcUrls(e.customRpcUrls),J.setSdkVersion(e.sdkVersion),J.setProjectId(e.projectId),J.setEnableEmbedded(e.enableEmbedded),J.setAllWallets(e.allWallets),J.setIncludeWalletIds(e.includeWalletIds),J.setExcludeWalletIds(e.excludeWalletIds),J.setFeaturedWalletIds(e.featuredWalletIds),J.setTokens(e.tokens),J.setTermsConditionsUrl(e.termsConditionsUrl),J.setPrivacyPolicyUrl(e.privacyPolicyUrl),J.setCustomWallets(e.customWallets),J.setFeatures(e.features),J.setAllowUnsupportedChain(e.allowUnsupportedChain),J.setDefaultAccountTypes(e.defaultAccountTypes),J.setUniversalProviderConfigOverride(e.universalProviderConfigOverride);const r=this.getDefaultMetaData();if(!e.metadata&&r&&(e.metadata=r),J.setMetadata(e.metadata),J.setDisableAppend(e.disableAppend),J.setEnableEmbedded(e.enableEmbedded),J.setSIWX(e.siwx),!e.projectId){ql.open(Ol.ALERT_ERRORS.PROJECT_ID_NOT_CONFIGURED,"error");return}if(e.adapters?.find(s=>s.namespace===ne.CHAIN.EVM)&&e.siweConfig){if(e.siwx)throw new Error("Cannot set both `siweConfig` and `siwx` options");J.setSIWX(e.siweConfig.mapToSIWX())}}getDefaultMetaData(){return typeof window<"u"&&typeof document<"u"?{name:document.getElementsByTagName("title")?.[0]?.textContent||"",description:document.querySelector('meta[property="og:description"]')?.content||"",url:window.location.origin,icons:[document.querySelector('link[rel~="icon"]')?.href||""]}:null}setUnsupportedNetwork(e){const r=this.getActiveChainNamespace();if(r){const i=Yo.getUnsupportedNetwork(`${r}:${e}`);F.setActiveCaipNetwork(i)}}getDefaultNetwork(){return Yo.getCaipNetworkFromStorage(this.defaultCaipNetwork)}extendCaipNetwork(e,r){return Yo.extendCaipNetwork(e,{customNetworkImageUrls:r.chainImages,projectId:r.projectId})}extendCaipNetworks(e){return Yo.extendCaipNetworks(e.networks,{customNetworkImageUrls:e.chainImages,customRpcUrls:e.customRpcUrls,projectId:e.projectId})}extendDefaultCaipNetwork(e){const r=e.networks.find(s=>s.id===e.defaultNetwork?.id);return r?Yo.extendCaipNetwork(r,{customNetworkImageUrls:e.chainImages,customRpcUrls:e.customRpcUrls,projectId:e.projectId}):void 0}createClients(){this.connectionControllerClient={connectWalletConnect:async()=>{const e=F.state.activeChain,r=this.getAdapter(e),i=this.getCaipNetwork(e)?.id;if(!r)throw new Error("Adapter not found");const s=await r.connectWalletConnect(i);this.close(),this.setClientId(s?.clientId||null),se.setConnectedNamespaces([...F.state.chains.keys()]),this.chainNamespaces.forEach(n=>{fe.setConnectorId(Ks.CONNECTOR_TYPE_WALLET_CONNECT,n)}),await this.syncWalletConnectAccount()},connectExternal:async({id:e,info:r,type:i,provider:s,chain:n,caipNetwork:o})=>{const a=F.state.activeChain,u=n||a,c=this.getAdapter(u);if(n&&n!==a&&!o){const m=this.caipNetworks?.find(g=>g.chainNamespace===n);m&&this.setCaipNetwork(m)}if(!c)throw new Error("Adapter not found");const l=this.getCaipNetwork(u),h=await c.connect({id:e,info:r,type:i,provider:s,chainId:o?.id||l?.id,rpcUrl:o?.rpcUrls?.default?.http?.[0]||l?.rpcUrls?.default?.http?.[0]});if(!h)return;se.addConnectedNamespace(u),this.syncProvider({...h,chainNamespace:u}),await this.syncAccount({...h,chainNamespace:u});const{accounts:f}=await c.getAccounts({namespace:u,id:e});this.setAllAccounts(f,u)},reconnectExternal:async({id:e,info:r,type:i,provider:s})=>{const n=F.state.activeChain,o=this.getAdapter(n);o?.reconnect&&(await o?.reconnect({id:e,info:r,type:i,provider:s,chainId:this.getCaipNetwork()?.id}),se.addConnectedNamespace(n))},disconnect:async e=>{const r=e||F.state.activeChain,i=this.getAdapter(r),s=Ot.getProvider(r),n=Ot.getProviderId(r);await i?.disconnect({provider:s,providerType:n}),se.removeConnectedNamespace(r),Ot.resetChain(r),this.setUser(void 0,r),this.setStatus("disconnected",r),this.hasSwitchedToPreferredAccountTypeOnConnect=!1},checkInstalled:e=>e?e.some(r=>!!window.ethereum?.[String(r)]):!!window.ethereum,signMessage:async e=>(await this.getAdapter(F.state.activeChain)?.signMessage({message:e,address:oe.state.address,provider:Ot.getProvider(F.state.activeChain)}))?.signature||"",sendTransaction:async e=>{if(e.chainNamespace===ne.CHAIN.EVM){const r=this.getAdapter(F.state.activeChain),i=Ot.getProvider(F.state.activeChain);return(await r?.sendTransaction({...e,caipNetwork:this.getCaipNetwork(),provider:i}))?.hash||""}return""},estimateGas:async e=>{if(e.chainNamespace===ne.CHAIN.EVM){const r=this.getAdapter(F.state.activeChain),i=Ot.getProvider(F.state.activeChain),s=this.getCaipNetwork();if(!s)throw new Error("CaipNetwork is undefined");return(await r?.estimateGas({...e,provider:i,caipNetwork:s}))?.gas||0n}return 0n},getEnsAvatar:async()=>(await this.getAdapter(F.state.activeChain)?.getProfile({address:oe.state.address,chainId:Number(this.getCaipNetwork()?.id)}))?.profileImage||!1,getEnsAddress:async e=>{const r=this.getAdapter(F.state.activeChain),i=this.getCaipNetwork();return i&&(await r?.getEnsAddress({name:e,caipNetwork:i}))?.address||!1},writeContract:async e=>{const r=this.getAdapter(F.state.activeChain),i=this.getCaipNetwork(),s=this.getCaipAddress(),n=Ot.getProvider(F.state.activeChain);if(!i||!s)throw new Error("CaipNetwork or CaipAddress is undefined");return(await r?.writeContract({...e,caipNetwork:i,provider:n,caipAddress:s}))?.hash},parseUnits:(e,r)=>this.getAdapter(F.state.activeChain)?.parseUnits({value:e,decimals:r})??0n,formatUnits:(e,r)=>this.getAdapter(F.state.activeChain)?.formatUnits({value:e,decimals:r})??"0",getCapabilities:async e=>await this.getAdapter(F.state.activeChain)?.getCapabilities(e),grantPermissions:async e=>await this.getAdapter(F.state.activeChain)?.grantPermissions(e),revokePermissions:async e=>{const r=this.getAdapter(F.state.activeChain);return r?.revokePermissions?await r.revokePermissions(e):"0x"},walletGetAssets:async e=>await this.getAdapter(F.state.activeChain)?.walletGetAssets(e)??{}},this.networkControllerClient={switchCaipNetwork:async e=>await this.switchCaipNetwork(e),getApprovedCaipNetworksData:async()=>this.getApprovedCaipNetworksData()},ut.setClient(this.connectionControllerClient)}getApprovedCaipNetworksData(){if(Ot.getProviderId(F.state.activeChain)===Ks.CONNECTOR_TYPE_WALLET_CONNECT){const r=this.universalProvider?.session?.namespaces;return{supportsAllNetworks:this.universalProvider?.session?.peer?.metadata.name==="MetaMask Wallet",approvedCaipNetworkIds:this.getChainsFromNamespaces(r)}}return{supportsAllNetworks:!0,approvedCaipNetworkIds:[]}}async switchCaipNetwork(e){if(!e)return;const r=e.chainNamespace;if(this.getAddressByChainNamespace(e.chainNamespace)){const s=Ot.getProvider(r),n=Ot.getProviderId(r);if(e.chainNamespace===F.state.activeChain)await this.getAdapter(r)?.switchNetwork({caipNetwork:e,provider:s,providerType:n});else if(this.setCaipNetwork(e),n===Ks.CONNECTOR_TYPE_WALLET_CONNECT)this.syncWalletConnectAccount();else{const o=this.getAddressByChainNamespace(r);o&&this.syncAccount({address:o,chainId:e.id,chainNamespace:r})}}else this.setCaipNetwork(e)}getChainsFromNamespaces(e={}){return Object.values(e).flatMap(r=>{const i=r.chains||[],s=r.accounts.map(n=>{const{chainId:o,chainNamespace:a}=Bs.parseCaipAddress(n);return`${a}:${o}`});return Array.from(new Set([...i,...s]))})}createAdapters(e){return this.createClients(),this.chainNamespaces.reduce((r,i)=>{const s=e?.find(n=>n.namespace===i);return s?(r[i]=s,r[i].namespace=i,r[i].construct({namespace:i,projectId:this.options?.projectId,networks:this.caipNetworks})):r[i]=new nQ({namespace:i,networks:this.caipNetworks}),r},{})}async initChainAdapter(e){this.onConnectors(e),this.listenAdapter(e),this.chainAdapters?.[e].syncConnectors(this.options,this),await this.createUniversalProviderForAdapter(e)}async initChainAdapters(){await Promise.all(this.chainNamespaces.map(async e=>{await this.initChainAdapter(e)}))}onConnectors(e){this.getAdapter(e)?.on("connectors",this.setConnectors.bind(this))}listenAdapter(e){const r=this.getAdapter(e);if(!r)return;const i=se.getConnectionStatus();i==="connected"?this.setStatus("connecting",e):i==="disconnected"?(se.clearAddressCache(),this.setStatus(i,e)):this.setStatus(i,e),r.on("switchNetwork",({address:s,chainId:n})=>{const o=this.caipNetworks?.find(c=>c.id===n||c.caipNetworkId===n),a=F.state.activeChain===e,u=F.getAccountProp("address",e);if(o){const c=a&&s?s:u;c&&this.syncAccount({address:c,chainId:n,chainNamespace:e})}else this.setUnsupportedNetwork(n)}),r.on("disconnect",this.disconnect.bind(this,e)),r.on("pendingTransactions",()=>{const s=oe.state.address,n=F.state.activeCaipNetwork;!s||!n?.id||this.updateNativeBalance(s,n.id,n.chainNamespace)}),r.on("accountChanged",({address:s,chainId:n})=>{const o=F.state.activeChain===e;o&&n?this.syncAccount({address:s,chainId:n,chainNamespace:e}):o&&F.state.activeCaipNetwork?.id?this.syncAccount({address:s,chainId:F.state.activeCaipNetwork?.id,chainNamespace:e}):this.syncAccountInfo(s,n,e)})}async createUniversalProviderForAdapter(e){await this.getUniversalProvider(),this.universalProvider&&this.chainAdapters?.[e]?.setUniversalProvider?.(this.universalProvider)}async syncExistingConnection(){await Promise.allSettled(this.chainNamespaces.map(e=>this.syncNamespaceConnection(e)))}async syncNamespaceConnection(e){try{const r=fe.getConnectorId(e);switch(this.setStatus("connecting",e),r){case ne.CONNECTOR_ID.WALLET_CONNECT:await this.syncWalletConnectAccount();break;case ne.CONNECTOR_ID.AUTH:break;default:await this.syncAdapterConnection(e)}}catch(r){console.warn("AppKit couldn't sync existing connection",r),this.setStatus("disconnected",e)}}async syncAdapterConnection(e){const r=this.getAdapter(e),i=fe.getConnectorId(e),s=this.getCaipNetwork(e),n=fe.getConnectors(e).find(o=>o.id===i);try{if(!r||!n)throw new Error(`Adapter or connector not found for namespace ${e}`);if(!s?.id)throw new Error("CaipNetwork not found");const o=await r?.syncConnection({namespace:e,id:n.id,chainId:s.id,rpcUrl:s?.rpcUrls?.default?.http?.[0]});if(o){const a=await r?.getAccounts({namespace:e,id:n.id});a&&a.accounts.length>0?this.setAllAccounts(a.accounts,e):this.setAllAccounts([pe.createAccount(e,o.address,"eoa")],e),this.syncProvider({...o,chainNamespace:e}),await this.syncAccount({...o,chainNamespace:e}),this.setStatus("connected",e)}else this.setStatus("disconnected",e)}catch{this.setStatus("disconnected",e)}}async syncWalletConnectAccount(){const e=this.chainNamespaces.map(async r=>{const i=this.getAdapter(r),s=this.universalProvider?.session?.namespaces?.[r]?.accounts||[],n=F.state.activeCaipNetwork?.id,o=s.find(a=>{const{chainId:u}=Bs.parseCaipAddress(a);return u===n?.toString()})||s[0];if(o){const a=Bs.validateCaipAddress(o),{chainId:u,address:c}=Bs.parseCaipAddress(a);if(Ot.setProviderId(r,Ks.CONNECTOR_TYPE_WALLET_CONNECT),this.caipNetworks&&F.state.activeCaipNetwork&&i?.namespace!==ne.CHAIN.EVM){const l=i?.getWalletConnectProvider({caipNetworks:this.caipNetworks,provider:this.universalProvider,activeCaipNetwork:F.state.activeCaipNetwork});Ot.setProvider(r,l)}else Ot.setProvider(r,this.universalProvider);fe.setConnectorId(ne.CONNECTOR_ID.WALLET_CONNECT,r),se.addConnectedNamespace(r),this.syncWalletConnectAccounts(r),await this.syncAccount({address:c,chainId:u,chainNamespace:r})}else this.setStatus("disconnected",r);await F.setApprovedCaipNetworksData(r)});await Promise.all(e)}syncWalletConnectAccounts(e){const r=this.universalProvider?.session?.namespaces?.[e]?.accounts?.map(i=>{const{address:s}=Bs.parseCaipAddress(i);return s}).filter((i,s,n)=>n.indexOf(i)===s);r&&this.setAllAccounts(r.map(i=>pe.createAccount(e,i,e==="bip122"?"payment":"eoa")),e)}syncProvider({type:e,provider:r,id:i,chainNamespace:s}){Ot.setProviderId(s,e),Ot.setProvider(s,r),fe.setConnectorId(i,s)}async syncAccount(e){const r=e.chainNamespace===F.state.activeChain,i=F.getCaipNetworkByNamespace(e.chainNamespace,e.chainId),{address:s,chainId:n,chainNamespace:o}=e,{chainId:a}=se.getActiveNetworkProps(),u=n||a,c=F.state.activeCaipNetwork?.name===ne.UNSUPPORTED_NETWORK_NAME,l=F.getNetworkProp("supportsAllNetworks",o);if(this.setStatus("connected",o),!(c&&!l)&&u){let h=this.caipNetworks?.find(g=>g.id.toString()===u.toString()),f=this.caipNetworks?.find(g=>g.chainNamespace===o);if(!l&&!h&&!f){const g=this.getApprovedCaipNetworkIds()||[],y=g.find(S=>Bs.parseCaipNetworkId(S)?.chainId===u.toString()),C=g.find(S=>Bs.parseCaipNetworkId(S)?.chainNamespace===o);h=this.caipNetworks?.find(S=>S.caipNetworkId===y),f=this.caipNetworks?.find(S=>S.caipNetworkId===C||"deprecatedCaipNetworkId"in S&&S.deprecatedCaipNetworkId===C)}const m=h||f;m?.chainNamespace===F.state.activeChain?J.state.enableNetworkSwitch&&!J.state.allowUnsupportedChain&&F.state.activeCaipNetwork?.name===ne.UNSUPPORTED_NETWORK_NAME?F.showUnsupportedChainUI():this.setCaipNetwork(m):r||i&&this.setCaipNetworkOfNamespace(i,o),this.syncConnectedWalletInfo(o),yE.isLowerCaseMatch(s,oe.state.address)||this.syncAccountInfo(s,m?.id,o),r?await this.syncBalance({address:s,chainId:m?.id,chainNamespace:o}):await this.syncBalance({address:s,chainId:i?.id,chainNamespace:o})}}async syncAccountInfo(e,r,i){const s=this.getCaipAddress(i),n=r||s?.split(":")[1];if(!n)return;const o=`${i}:${n}:${e}`;this.setCaipAddress(o,i),await this.syncIdentity({address:e,chainId:n,chainNamespace:i})}async syncReownName(e,r){try{const i=await this.getReownName(e);if(i[0]){const s=i[0];this.setProfileName(s.name,r)}else this.setProfileName(null,r)}catch{this.setProfileName(null,r)}}syncConnectedWalletInfo(e){const r=fe.getConnectorId(e),i=Ot.getProviderId(e);if(i===Ks.CONNECTOR_TYPE_ANNOUNCED||i===Ks.CONNECTOR_TYPE_INJECTED){if(r){const s=this.getConnectors().find(n=>n.id===r);if(s){const{info:n,name:o,imageUrl:a}=s,u=a||this.getConnectorImage(s);this.setConnectedWalletInfo({name:o,icon:u,...n},e)}}}else if(i===Ks.CONNECTOR_TYPE_WALLET_CONNECT){const s=Ot.getProvider(e);s?.session&&this.setConnectedWalletInfo({...s.session.peer.metadata,name:s.session.peer.metadata.name,icon:s.session.peer.metadata.icons?.[0]},e)}else if(r)if(r===ne.CONNECTOR_ID.COINBASE){const s=this.getConnectors().find(n=>n.id===ne.CONNECTOR_ID.COINBASE);this.setConnectedWalletInfo({name:"Coinbase Wallet",icon:this.getConnectorImage(s)},e)}else this.setConnectedWalletInfo({name:r},e)}async syncBalance(e){!L3.getNetworksByNamespace(this.caipNetworks,e.chainNamespace).find(i=>i.id.toString()===e.chainId?.toString())||!e.chainId||await this.updateNativeBalance(e.address,e.chainId,e.chainNamespace)}async updateNativeBalance(e,r,i){const s=this.getAdapter(i);if(s){const n=await s.getBalance({address:e,chainId:r,caipNetwork:this.getCaipNetwork(i),tokens:this.options.tokens});this.setBalance(n.balance,n.symbol,i)}}async initializeUniversalAdapter(){const e=NJ.createLogger((i,...s)=>{i&&this.handleAlertError(i),console.error(...s)}),r={projectId:this.options?.projectId,metadata:{name:this.options?.metadata?this.options?.metadata.name:"",description:this.options?.metadata?this.options?.metadata.description:"",url:this.options?.metadata?this.options?.metadata.url:"",icons:this.options?.metadata?this.options?.metadata.icons:[""]},logger:e};J.setManualWCControl(!!this.options?.manualWCControl),this.universalProvider=this.options.universalProvider??await xJ.init(r),this.listenWalletConnect()}listenWalletConnect(){this.universalProvider&&(this.universalProvider.on("display_uri",e=>{ut.setUri(e)}),this.universalProvider.on("connect",ut.finalizeWcConnection),this.universalProvider.on("disconnect",()=>{this.chainNamespaces.forEach(e=>{this.resetAccount(e)}),ut.resetWcConnection()}),this.universalProvider.on("chainChanged",e=>{const r=this.caipNetworks?.find(s=>s.id==e),i=this.getCaipNetwork();if(!r){this.setUnsupportedNetwork(e);return}i?.id!==r?.id&&this.setCaipNetwork(r)}),this.universalProvider.on("session_event",e=>{if($E.isSessionEventData(e)){const{name:r,data:i}=e.params.event;r==="accountsChanged"&&Array.isArray(i)&&pe.isCaipAddress(i[0])&&this.syncAccount(Bs.parseCaipAddress(i[0]))}}))}createUniversalProvider(){return!this.universalProviderInitPromise&&pe.isClient()&&this.options?.projectId&&(this.universalProviderInitPromise=this.initializeUniversalAdapter()),this.universalProviderInitPromise}async getUniversalProvider(){if(!this.universalProvider)try{await this.createUniversalProvider()}catch(e){lt.sendEvent({type:"error",event:"INTERNAL_SDK_ERROR",properties:{errorType:"UniversalProviderInitError",errorMessage:e instanceof Error?e.message:"Unknown",uncaught:!1}}),console.error("AppKit:getUniversalProvider - Cannot create provider",e)}return this.universalProvider}handleAlertError(e){const r=Object.entries(Ol.UniversalProviderErrors).find(([,{message:a}])=>e.message.includes(a)),[i,s]=r??[],{message:n,alertErrorKey:o}=s??{};if(i&&n&&!this.reportedAlertErrors[i]){const a=Ol.ALERT_ERRORS[o];a&&(ql.open(a,"error"),this.reportedAlertErrors[i]=!0)}}getAdapter(e){if(e)return this.chainAdapters?.[e]}createAdapter(e){if(!e)return;const r=e.namespace;if(!r)return;this.createClients();const i=e;i.namespace=r,i.construct({namespace:r,projectId:this.options?.projectId,networks:this.caipNetworks}),this.chainNamespaces.includes(r)||this.chainNamespaces.push(r),this.chainAdapters&&(this.chainAdapters[r]=i)}async open(e){await this.injectModalUi(),e?.uri&&ut.setUri(e.uri),await Qt.open(e)}async close(){await this.injectModalUi(),Qt.close()}setLoading(e,r){Qt.setLoading(e,r)}async disconnect(e){await ut.disconnect(e)}getError(){return""}getChainId(){return F.state.activeCaipNetwork?.id}async switchNetwork(e){const r=this.caipNetworks?.find(i=>i.id===e.id);if(!r){ql.open(Ol.ALERT_ERRORS.SWITCH_NETWORK_NOT_FOUND,"error");return}await F.switchActiveNetwork(r)}getWalletProvider(){return F.state.activeChain?Ot.state.providers[F.state.activeChain]:null}getWalletProviderType(){return Ot.getProviderId(F.state.activeChain)}subscribeProviders(e){return Ot.subscribeProviders(e)}getThemeMode(){return kr.state.themeMode}getThemeVariables(){return kr.state.themeVariables}setThemeMode(e){kr.setThemeMode(e),CE(kr.state.themeMode)}setTermsConditionsUrl(e){J.setTermsConditionsUrl(e)}setPrivacyPolicyUrl(e){J.setPrivacyPolicyUrl(e)}setThemeVariables(e){kr.setThemeVariables(e),eQ(kr.state.themeVariables)}subscribeTheme(e){return kr.subscribe(e)}getWalletInfo(){return oe.state.connectedWalletInfo}getAccount(e){const r=fe.getAuthConnector(e),i=F.getAccountData(e);if(i)return{allAccounts:i.allAccounts,caipAddress:i.caipAddress,address:pe.getPlainAddress(i.caipAddress),isConnected:!!i.caipAddress,status:i.status,embeddedWalletInfo:r?{user:i.user,authProvider:i.socialProvider||"email",accountType:i.preferredAccountType,isSmartAccountDeployed:!!i.smartAccountDeployed}:void 0}}subscribeAccount(e,r){const i=()=>{const s=this.getAccount(r);s&&e(s)};r?F.subscribeChainProp("accountState",i,r):F.subscribe(i),fe.subscribe(i)}subscribeNetwork(e){return F.subscribe(({activeCaipNetwork:r})=>{e({caipNetwork:r,chainId:r?.id,caipNetworkId:r?.caipNetworkId})})}subscribeWalletInfo(e){return oe.subscribeKey("connectedWalletInfo",e)}subscribeShouldUpdateToAddress(e){oe.subscribeKey("shouldUpdateToAddress",e)}subscribeCaipNetworkChange(e){F.subscribeKey("activeCaipNetwork",e)}getState(){return Ps.state}subscribeState(e){return Ps.subscribe(e)}showErrorMessage(e){Ir.showError(e)}showSuccessMessage(e){Ir.showSuccess(e)}getEvent(){return{...lt.state}}subscribeEvents(e){return lt.subscribe(e)}replace(e){He.replace(e)}redirect(e){He.push(e)}popTransactionStack(e){He.popTransactionStack(e)}isOpen(){return Qt.state.open}isTransactionStackEmpty(){return He.state.transactionStack.length===0}isTransactionShouldReplaceView(){return He.state.transactionStack[He.state.transactionStack.length-1]?.replace}static getInstance(){return this.instance}updateFeatures(e){J.setFeatures(e)}updateOptions(e){const i={...J.state||{},...e};J.setOptions(i)}setConnectMethodsOrder(e){J.setConnectMethodsOrder(e)}setWalletFeaturesOrder(e){J.setWalletFeaturesOrder(e)}setCollapseWallets(e){J.setCollapseWallets(e)}setSocialsOrder(e){J.setSocialsOrder(e)}getConnectMethodsOrder(){return Zp.getConnectOrderMethod(J.state.features,fe.getConnectors())}removeAdapter(e){const r=this.getIsConnectedState(),i=this.getAdapter(e);if(!i||!this.chainAdapters||r)return;const s=this.caipNetworks?.filter(n=>n.chainNamespace!==e);F.removeAdapter(e),fe.removeAdapter(e),this.chainNamespaces=this.chainNamespaces.filter(n=>n!==e),this.caipNetworks=s,i.removeAllEventListeners(),Reflect.deleteProperty(this.chainAdapters,e)}addAdapter(e,r){const i=e.namespace;if(!this.connectionControllerClient||!this.networkControllerClient||!this.chainAdapters||!i)return;const s=this.extendCaipNetworks({...this.options,networks:r});this.caipNetworks=[...this.caipNetworks||[],...s],this.createAdapter(e),this.initChainAdapter(i),F.addAdapter(e,{connectionControllerClient:this.connectionControllerClient,networkControllerClient:this.networkControllerClient},s)}addNetwork(e,r){if(this.chainAdapters&&!this.chainAdapters[e])throw new Error(`Adapter for namespace ${e} doesn't exist`);const i=this.extendCaipNetwork(r,this.options);F.addNetwork(i),this.caipNetworks&&!this.caipNetworks?.find(s=>s.id===i.id)&&this.caipNetworks.push(i)}removeNetwork(e,r){if(this.chainAdapters&&!this.chainAdapters[e])throw new Error(`Adapter for namespace ${e} doesn't exist`);if(!this.caipNetworks?.find(n=>n.id===r))throw new Error(`Network with ID ${r} not found`);if(!this.caipNetworks)return;const s=this.caipNetworks.filter(n=>n.chainNamespace===e&&n.id!==r);if(!s?.length)throw new Error("Cannot remove last network for a namespace");F.removeNetwork(e,r),this.caipNetworks=[...s]}}let Kv=!1;class aQ extends oQ{async open(e){fe.isConnected()||await super.open(e)}async close(){await super.close(),this.options.manualWCControl&&ut.finalizeWcConnection()}async syncIdentity(e){return Promise.resolve()}async syncBalance(e){return Promise.resolve()}async injectModalUi(){if(!Kv&&pe.isClient()){if(await Jl(()=>import("./basic-BATfqZ4A.js"),__vite__mapDeps([12,13,3,4,5,2,6,7,1,8,9,10])),await Jl(()=>import("./w3m-modal-DejLuZa8.js"),__vite__mapDeps([14,13,3,4,5,2,6,7,1,8,9,10])),!document.querySelector("w3m-modal")){const r=document.createElement("w3m-modal");!J.state.disableAppend&&!J.state.enableEmbedded&&document.body.insertAdjacentElement("beforeend",r)}Kv=!0}}}const cQ="1.7.2";function uQ(t){return new aQ({...t,basic:!0,sdkVersion:`html-core-${cQ}`})}class ea extends Error{constructor(){super(),Object.setPrototypeOf(this,ea.prototype)}}class Wv extends Error{constructor(e){super(`WalletConnect Adapter - Method ${e} is not supported by the wallet`),this.name="WalletConnectFeatureNotSupportedError"}}function lQ(t){let e=[t];return t===tr.Mainnet||t===tr.Deprecated_Mainnet?(e=[tr.Mainnet,tr.Deprecated_Mainnet],t===tr.Deprecated_Mainnet&&console.warn(yh.mainnet)):(t===tr.Deprecated_Devnet||t===tr.Devnet)&&(e=[tr.Devnet,tr.Deprecated_Devnet],console.warn(yh.devnet)),e}const yh={mainnet:`You are using a deprecated chain ID for Solana Mainnet, please use ${tr.Mainnet} instead.`,devnet:`You are using a deprecated chain ID for Solana Devnet, please use ${tr.Devnet} instead.`,wallet:"The connected wallet is using a deprecated chain ID for Solana. Please, contact them to upgrade. You can learn more at https://github.com/ChainAgnostic/namespaces/blob/main/solana/caip10.md#chain-ids"};function Gv(t,e){const r=t.namespaces.solana?.accounts.map(i=>`solana:${i.split(":")[1]}`);if(e===tr.Mainnet)return r?.find(i=>i===tr.Mainnet)?tr.Mainnet:(console.warn(yh.wallet),tr.Deprecated_Mainnet);if(e===tr.Devnet)return r?.find(i=>i===tr.Devnet)?tr.Devnet:(console.warn(yh.wallet),tr.Deprecated_Devnet);throw Error("WalletConnect Solana Adapter: Unable to get a default chain from the session.")}function hQ(t){return{optionalNamespaces:{solana:{chains:lQ(t),methods:[$i.signTransaction,$i.signMessage],events:[]}}}}class Qg extends Error{constructor(){super("QR Code Modal was closed by user"),Object.setPrototypeOf(this,Qg.prototype),this.name="QRCodeModalError"}}class dQ{_UniversalProvider;_session;_modal;_projectId;_network;_ConnectQueueResolver;constructor(e){if(this.initClient(e.options),this._network=e.network,!e.options.projectId)throw Error("WalletConnect Adapter: Project ID is undefined");this._projectId=e.options.projectId}async connect(){if(this._UniversalProvider||await new Promise(s=>{this._ConnectQueueResolver=s}),!this._UniversalProvider)throw new Error("WalletConnect Adapter - Universal Provider was undefined while calling 'connect()'");if(this._UniversalProvider.session){this._session=this._UniversalProvider.session;const s=Gv(this._session,this._network);return this._network=s,this._UniversalProvider.setDefaultChain(s),{publicKey:this.publicKey}}await this.initModal();const e=hQ(this._network);this._modal?.open();const r=new AbortController,i=r.signal;this._modal?.subscribeState(s=>{s.open||r.abort(new Qg)});try{const s=await Promise.race([this._UniversalProvider?.connect(e),new Promise((o,a)=>{i.addEventListener("abort",()=>{a(i.reason)})})]);if(this._modal?.close(),this._session=s,!s)throw new r4;const n=Gv(s,this._network);return this._network=n,this._UniversalProvider?.setDefaultChain(n),{publicKey:this.publicKey}}catch(s){throw this._modal?.close(),s}}async disconnect(){if(this._UniversalProvider?.session){if(await this.initModal(),!this._modal)throw Error("WalletConnect Adapter -Modal is undefined: unable to disconnect");await this.client.disconnect(),this._session=void 0}else throw new ea}get client(){if(this._UniversalProvider)return this._UniversalProvider;throw new ea}get session(){if(!this._session)throw new ea;return this._session}get publicKey(){if(this._UniversalProvider?.session&&this._session){const{address:e}=cC(this._session?.namespaces.solana?.accounts[0]??"");return new ZE(e)}throw new ea}async signTransaction(e){this.checkIfWalletSupportsMethod($i.signTransaction);const r=c0(e),i=r?{}:e,{signature:s,transaction:n}=await this.client.client.request({chainId:this._network,topic:this.session.topic,request:{method:$i.signTransaction,params:{...i,transaction:this.serialize(e)}}});return n?this.deserialize(n,r):(e.addSignature(this.publicKey,Buffer.from(Nc.decode(s))),e)}async signMessage(e){this.checkIfWalletSupportsMethod($i.signMessage);const{signature:r}=await this.client.client.request({chainId:this._network,topic:this.session.topic,request:{method:$i.signMessage,params:{pubkey:this.publicKey.toString(),message:Nc.encode(e)}}});return Nc.decode(r)}async signAndSendTransaction(e){this.checkIfWalletSupportsMethod($i.signAndSendTransaction);const{signature:r}=await this.client.client.request({chainId:this._network,topic:this.session.topic,request:{method:$i.signAndSendTransaction,params:{transaction:this.serialize(e)}}});return r}async signAllTransactions(e){try{this.checkIfWalletSupportsMethod($i.signAllTransactions);const r=e.map(s=>this.serialize(s)),{transactions:i}=await this.client.client.request({chainId:this._network,topic:this.session.topic,request:{method:$i.signAllTransactions,params:{transactions:r}}});return e.map((s,n)=>c0(s)?this.deserialize(i[n]??"",!0):this.deserialize(i[n]??""))}catch(r){if(r instanceof Wv){const i=e.map(n=>this.signTransaction(n));return await Promise.all(i)}throw r}}async initClient(e){const r=await xF.init(e);this._UniversalProvider=r,this._ConnectQueueResolver&&this._ConnectQueueResolver(!0)}async initModal(){if(!this._modal){if(!this._UniversalProvider)throw new Error("WalletConnect Adapter - cannot init modal when Universal Provider is undefined");this._modal=uQ({projectId:this._projectId,universalProvider:this._UniversalProvider,networks:[tg,rg,tQ],manualWCControl:!0})}}serialize(e){return Buffer.from(e.serialize({verifySignatures:!1})).toString("base64")}deserialize(e,r=!1){return r?e4.deserialize(Buffer.from(e,"base64")):t4.from(Buffer.from(e,"base64"))}checkIfWalletSupportsMethod(e){if(!this.session.namespaces.solana?.methods.includes(e))throw new Wv(e)}}const PE="WalletConnect";class fQ extends i4{name=PE;url="https://walletconnect.org";icon="data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjE4NSIgdmlld0JveD0iMCAwIDMwMCAxODUiIHdpZHRoPSIzMDAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0ibTYxLjQzODU0MjkgMzYuMjU2MjYxMmM0OC45MTEyMjQxLTQ3Ljg4ODE2NjMgMTI4LjIxMTk4NzEtNDcuODg4MTY2MyAxNzcuMTIzMjA5MSAwbDUuODg2NTQ1IDUuNzYzNDE3NGMyLjQ0NTU2MSAyLjM5NDQwODEgMi40NDU1NjEgNi4yNzY1MTEyIDAgOC42NzA5MjA0bC0yMC4xMzY2OTUgMTkuNzE1NTAzYy0xLjIyMjc4MSAxLjE5NzIwNTEtMy4yMDUzIDEuMTk3MjA1MS00LjQyODA4MSAwbC04LjEwMDU4NC03LjkzMTE0NzljLTM0LjEyMTY5Mi0zMy40MDc5ODE3LTg5LjQ0Mzg4Ni0zMy40MDc5ODE3LTEyMy41NjU1Nzg4IDBsLTguNjc1MDU2MiA4LjQ5MzYwNTFjLTEuMjIyNzgxNiAxLjE5NzIwNDEtMy4yMDUzMDEgMS4xOTcyMDQxLTQuNDI4MDgwNiAwbC0yMC4xMzY2OTQ5LTE5LjcxNTUwMzFjLTIuNDQ1NTYxMi0yLjM5NDQwOTItMi40NDU1NjEyLTYuMjc2NTEyMiAwLTguNjcwOTIwNHptMjE4Ljc2Nzc5NjEgNDAuNzczNzQ0OSAxNy45MjE2OTcgMTcuNTQ2ODk3YzIuNDQ1NTQ5IDIuMzk0Mzk2OSAyLjQ0NTU2MyA2LjI3NjQ3NjkuMDAwMDMxIDguNjcwODg5OWwtODAuODEwMTcxIDc5LjEyMTEzNGMtMi40NDU1NDQgMi4zOTQ0MjYtNi40MTA1ODIgMi4zOTQ0NTMtOC44NTYxNi4wMDAwNjItLjAwMDAxLS4wMDAwMS0uMDAwMDIyLS4wMDAwMjItLjAwMDAzMi0uMDAwMDMybC01Ny4zNTQxNDMtNTYuMTU0NTcyYy0uNjExMzktLjU5ODYwMi0xLjYwMjY1LS41OTg2MDItMi4yMTQwNCAwLS4wMDAwMDQuMDAwMDA0LS4wMDAwMDcuMDAwMDA4LS4wMDAwMTEuMDAwMDExbC01Ny4zNTI5MjEyIDU2LjE1NDUzMWMtMi40NDU1MzY4IDIuMzk0NDMyLTYuNDEwNTc1NSAyLjM5NDQ3Mi04Ljg1NjE2MTIuMDAwMDg3LS4wMDAwMTQzLS4wMDAwMTQtLjAwMDAyOTYtLjAwMDAyOC0uMDAwMDQ0OS0uMDAwMDQ0bC04MC44MTI0MTk0My03OS4xMjIxODVjLTIuNDQ1NTYwMjEtMi4zOTQ0MDgtMi40NDU1NjAyMS02LjI3NjUxMTUgMC04LjY3MDkxOTdsMTcuOTIxNzI5NjMtMTcuNTQ2ODY3M2MyLjQ0NTU2MDItMi4zOTQ0MDgyIDYuNDEwNTk4OS0yLjM5NDQwODIgOC44NTYxNjAyIDBsNTcuMzU0OTc3NSA1Ni4xNTUzNTdjLjYxMTM5MDguNTk4NjAyIDEuNjAyNjQ5LjU5ODYwMiAyLjIxNDAzOTggMCAuMDAwMDA5Mi0uMDAwMDA5LjAwMDAxNzQtLjAwMDAxNy4wMDAwMjY1LS4wMDAwMjRsNTcuMzUyMTAzMS01Ni4xNTUzMzNjMi40NDU1MDUtMi4zOTQ0NjMzIDYuNDEwNTQ0LTIuMzk0NTUzMSA4Ljg1NjE2MS0uMDAwMi4wMDAwMzQuMDAwMDMzNi4wMDAwNjguMDAwMDY3My4wMDAxMDEuMDAwMTAxbDU3LjM1NDkwMiA1Ni4xNTU0MzJjLjYxMTM5LjU5ODYwMSAxLjYwMjY1LjU5ODYwMSAyLjIxNDA0IDBsNTcuMzUzOTc1LTU2LjE1NDMyNDljMi40NDU1NjEtMi4zOTQ0MDkyIDYuNDEwNTk5LTIuMzk0NDA5MiA4Ljg1NjE2IDB6IiBmaWxsPSIjM2I5OWZjIi8+PC9zdmc+";supportedTransactionVersions=new Set(["legacy",0]);_publicKey;_connecting;_wallet;_config;_readyState;_onDisconnect;constructor(e){super(),this._publicKey=null,this._connecting=!1,this._config=e,this._wallet=null,this._readyState=typeof window>"u"?Yh.Unsupported:Yh.Loadable,this._onDisconnect=this.disconnect.bind(this)}get publicKey(){return this._publicKey}get connecting(){return this._connecting}get readyState(){return this._readyState}async connect(){try{if(this.connected||this.connecting)return;if(this._readyState!==Yh.Loadable)throw new s4;this._connecting=!0,this._wallet=new dQ({network:this._config.network===c4.Mainnet?Ql.Mainnet:Ql.Devnet,options:this._config.options});const{publicKey:e}=await this._wallet.connect();this._publicKey=e,this.emit("connect",e),this._wallet.client.on("session_delete",this._onDisconnect)}catch(e){throw e.constructor.name==="QRCodeModalError"||e instanceof Error&&e.name==="QRCodeModalError"?new n4:(this._connecting=!1,e)}finally{this._connecting=!1}}async disconnect(){const e=this._wallet;if(e){e.client.off("session_delete",this._onDisconnect),this._publicKey=null;try{e.client.session&&await e.disconnect()}catch(r){console.error("WalletConnectWalletAdapter: disconnect error",r),this.emit("error",new o4(r?.message,r))}}this.emit("disconnect")}async signTransaction(e){try{const r=this._wallet;if(!r)throw new Qu;try{return await r.signTransaction(e)}catch(i){throw new Jh(i?.message,i)}}catch(r){throw this.emit("error",r),r}}async signMessage(e){try{const r=this._wallet;if(!r)throw new Qu;try{return await r.signMessage(e)}catch(i){throw new a4(i?.message,i)}}catch(r){throw this.emit("error",r),r}}async signAndSendTransaction(e){try{const r=this._wallet;if(!r)throw new Qu;try{return await r.signAndSendTransaction(e)}catch(i){throw new Jh(i?.message,i)}}catch(r){throw this.emit("error",r),r}}async signAllTransactions(e){try{const r=this._wallet;if(!r)throw new Qu;try{return await r.signAllTransactions(e)}catch(i){throw new Jh(i?.message,i)}}catch(r){throw this.emit("error",r),r}}}const $Z=Object.freeze(Object.defineProperty({__proto__:null,WalletConnectWalletAdapter:fQ,WalletConnectWalletName:PE},Symbol.toStringTag,{value:"Module"}));export{pr as $,AZ as A,Yl as B,_Z as C,ql as D,SZ as E,CZ as F,F as G,CA as H,q3 as I,zi as J,DJ as K,ut as L,lt as M,Qt as N,J as O,fe as P,oe as Q,He as R,Oc as S,Ir as T,be as U,kr as V,IZ as W,pe as X,ne as Y,vE as Z,eg as _,rb as a,ma as a0,Wl as a1,se as a2,Zp as a3,Jr as a4,$Z as a5,bA as b,XQ as c,$A as d,QQ as e,Sh as f,rX as g,eX as h,$q as i,lZ as j,nw as k,o_ as l,mq as m,xq as n,hZ as o,uZ as p,qh as q,ZQ as r,fZ as s,z1 as t,dZ as u,gi as v,EZ as w,Fr as x,Tt as y,sa as z};
|