@aptos-labs/ts-sdk 5.1.1 → 5.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (185) hide show
  1. package/README.md +4 -4
  2. package/dist/common/{account-Dr4y1uZG.d.ts → account-147vfOGb.d.ts} +1 -0
  3. package/dist/common/{chunk-A2XB7TVI.js → chunk-347THBDE.js} +3 -3
  4. package/dist/common/chunk-347THBDE.js.map +1 -0
  5. package/dist/common/cli/index.d.ts +3 -1
  6. package/dist/common/cli/index.js +1 -1
  7. package/dist/common/cli/index.js.map +1 -1
  8. package/dist/common/index.d.ts +14 -3
  9. package/dist/common/index.js +6 -6
  10. package/dist/common/index.js.map +1 -1
  11. package/dist/esm/account/AbstractKeylessAccount.mjs +1 -1
  12. package/dist/esm/account/AbstractedAccount.mjs +1 -1
  13. package/dist/esm/account/Account.mjs +1 -1
  14. package/dist/esm/account/AccountUtils.mjs +1 -1
  15. package/dist/esm/account/DerivableAbstractedAccount.mjs +1 -1
  16. package/dist/esm/account/Ed25519Account.mjs +1 -1
  17. package/dist/esm/account/EphemeralKeyPair.mjs +1 -1
  18. package/dist/esm/account/FederatedKeylessAccount.mjs +1 -1
  19. package/dist/esm/account/KeylessAccount.mjs +1 -1
  20. package/dist/esm/account/MultiEd25519Account.mjs +1 -1
  21. package/dist/esm/account/MultiKeyAccount.mjs +1 -1
  22. package/dist/esm/account/SingleKeyAccount.mjs +1 -1
  23. package/dist/esm/account/index.mjs +1 -1
  24. package/dist/esm/account/utils.mjs +1 -1
  25. package/dist/esm/api/account/abstraction.mjs +1 -1
  26. package/dist/esm/api/account.mjs +1 -1
  27. package/dist/esm/api/ans.mjs +1 -1
  28. package/dist/esm/api/aptos.mjs +1 -1
  29. package/dist/esm/api/aptosConfig.mjs +1 -1
  30. package/dist/esm/api/coin.mjs +1 -1
  31. package/dist/esm/api/digitalAsset.mjs +1 -1
  32. package/dist/esm/api/faucet.mjs +1 -1
  33. package/dist/esm/api/fungibleAsset.mjs +1 -1
  34. package/dist/esm/api/general.mjs +1 -1
  35. package/dist/esm/api/index.mjs +1 -1
  36. package/dist/esm/api/keyless.mjs +1 -1
  37. package/dist/esm/api/object.mjs +1 -1
  38. package/dist/esm/api/staking.mjs +1 -1
  39. package/dist/esm/api/table.mjs +1 -1
  40. package/dist/esm/api/transaction.mjs +1 -1
  41. package/dist/esm/api/transactionSubmission/build.mjs +1 -1
  42. package/dist/esm/api/transactionSubmission/management.mjs +1 -1
  43. package/dist/esm/api/transactionSubmission/sign.mjs +1 -1
  44. package/dist/esm/api/transactionSubmission/simulate.mjs +1 -1
  45. package/dist/esm/api/transactionSubmission/submit.mjs +1 -1
  46. package/dist/esm/api/utils.mjs +1 -1
  47. package/dist/esm/bcs/index.mjs +1 -1
  48. package/dist/esm/bcs/serializable/movePrimitives.mjs +1 -1
  49. package/dist/esm/bcs/serializable/moveStructs.mjs +1 -1
  50. package/dist/esm/{chunk-ADJMFL73.mjs → chunk-2OPKZKOB.mjs} +2 -2
  51. package/dist/esm/{chunk-O26BHE5H.mjs → chunk-626KB2UQ.mjs} +2 -2
  52. package/dist/esm/{chunk-KB4XOTCR.mjs → chunk-AQW4BUKF.mjs} +2 -2
  53. package/dist/esm/{chunk-3LJVXUPB.mjs → chunk-E2U27PNC.mjs} +2 -2
  54. package/dist/esm/{chunk-TT3MPSBB.mjs → chunk-FC72YL4B.mjs} +2 -2
  55. package/dist/esm/chunk-GQ3UIDPQ.mjs +2 -0
  56. package/dist/esm/chunk-GQ3UIDPQ.mjs.map +1 -0
  57. package/dist/esm/chunk-H3EP5CGP.mjs +2 -0
  58. package/dist/esm/{chunk-GUPVZIYS.mjs.map → chunk-H3EP5CGP.mjs.map} +1 -1
  59. package/dist/esm/{chunk-7DQDJ2SA.mjs → chunk-LA56UDUK.mjs} +2 -2
  60. package/dist/esm/{chunk-CZDNBI5K.mjs → chunk-LAPXUUHK.mjs} +2 -2
  61. package/dist/esm/{chunk-7ZESTCBD.mjs → chunk-NCKJ7X57.mjs} +2 -2
  62. package/dist/esm/chunk-P5HCJN3A.mjs +2 -0
  63. package/dist/esm/chunk-P5HCJN3A.mjs.map +1 -0
  64. package/dist/esm/{chunk-PGUSBALH.mjs → chunk-PJTG745G.mjs} +3 -3
  65. package/dist/esm/{chunk-PGUSBALH.mjs.map → chunk-PJTG745G.mjs.map} +1 -1
  66. package/dist/esm/{chunk-57YZ7I7V.mjs → chunk-PSSIJHHC.mjs} +2 -2
  67. package/dist/esm/{chunk-I7XT6L7S.mjs → chunk-QNARIAVM.mjs} +2 -2
  68. package/dist/esm/{chunk-DHCGYW3W.mjs → chunk-R7FWJP3N.mjs} +2 -2
  69. package/dist/esm/{chunk-EF4FA5I6.mjs → chunk-RQX6JOEN.mjs} +2 -2
  70. package/dist/esm/{chunk-TSEAIF34.mjs → chunk-YS5IUILF.mjs} +2 -2
  71. package/dist/esm/{chunk-6WDVDEQZ.mjs → chunk-YZHAI55C.mjs} +2 -2
  72. package/dist/esm/chunk-ZYE7UTJZ.mjs +2 -0
  73. package/dist/esm/chunk-ZYE7UTJZ.mjs.map +1 -0
  74. package/dist/esm/cli/index.mjs +1 -1
  75. package/dist/esm/cli/localNode.d.mts +2 -0
  76. package/dist/esm/cli/localNode.mjs +1 -1
  77. package/dist/esm/client/core.mjs +1 -1
  78. package/dist/esm/client/get.mjs +1 -1
  79. package/dist/esm/client/index.mjs +1 -1
  80. package/dist/esm/client/post.mjs +1 -1
  81. package/dist/esm/core/account/index.d.mts +1 -1
  82. package/dist/esm/core/account/index.mjs +1 -1
  83. package/dist/esm/core/account/utils/address.d.mts +12 -1
  84. package/dist/esm/core/account/utils/address.mjs +1 -1
  85. package/dist/esm/core/account/utils/index.d.mts +1 -1
  86. package/dist/esm/core/account/utils/index.mjs +1 -1
  87. package/dist/esm/core/accountAddress.mjs +1 -1
  88. package/dist/esm/core/authenticationKey.mjs +1 -1
  89. package/dist/esm/core/crypto/abstraction.mjs +1 -1
  90. package/dist/esm/core/crypto/deserializationUtils.mjs +1 -1
  91. package/dist/esm/core/crypto/ed25519.mjs +1 -1
  92. package/dist/esm/core/crypto/ephemeral.mjs +1 -1
  93. package/dist/esm/core/crypto/federatedKeyless.mjs +1 -1
  94. package/dist/esm/core/crypto/index.mjs +1 -1
  95. package/dist/esm/core/crypto/keyless.mjs +1 -1
  96. package/dist/esm/core/crypto/multiEd25519.mjs +1 -1
  97. package/dist/esm/core/crypto/multiKey.mjs +1 -1
  98. package/dist/esm/core/crypto/privateKey.mjs +1 -1
  99. package/dist/esm/core/crypto/proof.mjs +1 -1
  100. package/dist/esm/core/crypto/publicKey.mjs +1 -1
  101. package/dist/esm/core/crypto/secp256k1.mjs +1 -1
  102. package/dist/esm/core/crypto/secp256r1.mjs +1 -1
  103. package/dist/esm/core/crypto/signature.mjs +1 -1
  104. package/dist/esm/core/crypto/singleKey.mjs +1 -1
  105. package/dist/esm/core/crypto/utils.mjs +1 -1
  106. package/dist/esm/core/index.d.mts +1 -1
  107. package/dist/esm/core/index.mjs +1 -1
  108. package/dist/esm/errors/index.mjs +1 -1
  109. package/dist/esm/index.d.mts +1 -1
  110. package/dist/esm/index.mjs +1 -1
  111. package/dist/esm/internal/abstraction.mjs +1 -1
  112. package/dist/esm/internal/account.mjs +1 -1
  113. package/dist/esm/internal/ans.mjs +1 -1
  114. package/dist/esm/internal/coin.mjs +1 -1
  115. package/dist/esm/internal/digitalAsset.mjs +1 -1
  116. package/dist/esm/internal/faucet.mjs +1 -1
  117. package/dist/esm/internal/fungibleAsset.mjs +1 -1
  118. package/dist/esm/internal/general.mjs +1 -1
  119. package/dist/esm/internal/keyless.mjs +1 -1
  120. package/dist/esm/internal/object.mjs +1 -1
  121. package/dist/esm/internal/staking.mjs +1 -1
  122. package/dist/esm/internal/table.mjs +1 -1
  123. package/dist/esm/internal/transaction.mjs +1 -1
  124. package/dist/esm/internal/transactionSubmission.mjs +1 -1
  125. package/dist/esm/internal/utils/index.mjs +1 -1
  126. package/dist/esm/internal/utils/utils.mjs +1 -1
  127. package/dist/esm/internal/view.mjs +1 -1
  128. package/dist/esm/transactions/authenticator/account.mjs +1 -1
  129. package/dist/esm/transactions/authenticator/index.mjs +1 -1
  130. package/dist/esm/transactions/authenticator/transaction.mjs +1 -1
  131. package/dist/esm/transactions/index.mjs +1 -1
  132. package/dist/esm/transactions/instances/index.mjs +1 -1
  133. package/dist/esm/transactions/instances/moduleId.mjs +1 -1
  134. package/dist/esm/transactions/instances/multiAgentTransaction.mjs +1 -1
  135. package/dist/esm/transactions/instances/rawTransaction.mjs +1 -1
  136. package/dist/esm/transactions/instances/rotationProofChallenge.mjs +1 -1
  137. package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
  138. package/dist/esm/transactions/instances/simpleTransaction.mjs +1 -1
  139. package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
  140. package/dist/esm/transactions/management/accountSequenceNumber.mjs +1 -1
  141. package/dist/esm/transactions/management/index.mjs +1 -1
  142. package/dist/esm/transactions/management/transactionWorker.mjs +1 -1
  143. package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
  144. package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
  145. package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
  146. package/dist/esm/transactions/transactionBuilder/signingMessage.mjs +1 -1
  147. package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +1 -1
  148. package/dist/esm/transactions/typeTag/index.mjs +1 -1
  149. package/dist/esm/transactions/typeTag/parser.mjs +1 -1
  150. package/dist/esm/types/index.mjs +1 -1
  151. package/dist/esm/utils/apiEndpoints.d.mts +1 -0
  152. package/dist/esm/utils/apiEndpoints.mjs +1 -1
  153. package/dist/esm/utils/helpers.mjs +1 -1
  154. package/dist/esm/utils/index.mjs +1 -1
  155. package/dist/esm/utils/normalizeBundle.mjs +1 -1
  156. package/dist/esm/version.d.mts +1 -1
  157. package/dist/esm/version.mjs +1 -1
  158. package/package.json +18 -20
  159. package/src/cli/localNode.ts +13 -2
  160. package/src/core/account/utils/address.ts +22 -0
  161. package/src/internal/ans.ts +1 -0
  162. package/src/utils/apiEndpoints.ts +9 -2
  163. package/src/version.ts +1 -1
  164. package/dist/common/chunk-A2XB7TVI.js.map +0 -1
  165. package/dist/esm/chunk-B563XRSZ.mjs +0 -2
  166. package/dist/esm/chunk-B563XRSZ.mjs.map +0 -1
  167. package/dist/esm/chunk-EMR3S3VO.mjs +0 -2
  168. package/dist/esm/chunk-EMR3S3VO.mjs.map +0 -1
  169. package/dist/esm/chunk-GUPVZIYS.mjs +0 -2
  170. package/dist/esm/chunk-HNBVYE3N.mjs +0 -2
  171. package/dist/esm/chunk-HNBVYE3N.mjs.map +0 -1
  172. /package/dist/esm/{chunk-ADJMFL73.mjs.map → chunk-2OPKZKOB.mjs.map} +0 -0
  173. /package/dist/esm/{chunk-O26BHE5H.mjs.map → chunk-626KB2UQ.mjs.map} +0 -0
  174. /package/dist/esm/{chunk-KB4XOTCR.mjs.map → chunk-AQW4BUKF.mjs.map} +0 -0
  175. /package/dist/esm/{chunk-3LJVXUPB.mjs.map → chunk-E2U27PNC.mjs.map} +0 -0
  176. /package/dist/esm/{chunk-TT3MPSBB.mjs.map → chunk-FC72YL4B.mjs.map} +0 -0
  177. /package/dist/esm/{chunk-7DQDJ2SA.mjs.map → chunk-LA56UDUK.mjs.map} +0 -0
  178. /package/dist/esm/{chunk-CZDNBI5K.mjs.map → chunk-LAPXUUHK.mjs.map} +0 -0
  179. /package/dist/esm/{chunk-7ZESTCBD.mjs.map → chunk-NCKJ7X57.mjs.map} +0 -0
  180. /package/dist/esm/{chunk-57YZ7I7V.mjs.map → chunk-PSSIJHHC.mjs.map} +0 -0
  181. /package/dist/esm/{chunk-I7XT6L7S.mjs.map → chunk-QNARIAVM.mjs.map} +0 -0
  182. /package/dist/esm/{chunk-DHCGYW3W.mjs.map → chunk-R7FWJP3N.mjs.map} +0 -0
  183. /package/dist/esm/{chunk-EF4FA5I6.mjs.map → chunk-RQX6JOEN.mjs.map} +0 -0
  184. /package/dist/esm/{chunk-TSEAIF34.mjs.map → chunk-YS5IUILF.mjs.map} +0 -0
  185. /package/dist/esm/{chunk-6WDVDEQZ.mjs.map → chunk-YZHAI55C.mjs.map} +0 -0
@@ -1,4 +1,4 @@
1
- import{a as Nn}from"./chunk-XKUIMGKU.mjs";import{a as z}from"./chunk-N6YTF76Q.mjs";import{a as Xi}from"./chunk-V74WPKSY.mjs";import{a as Bn,b as wo}from"./chunk-O26BHE5H.mjs";import{a as Hn,b as Nr}from"./chunk-A5L76YP7.mjs";import{a as kr,c as Fr}from"./chunk-I7XT6L7S.mjs";import{a as Fe,b as Rn,c as Ft,d as Er,e as zt}from"./chunk-GOXRBEIJ.mjs";import{a as kt}from"./chunk-2PASUPUO.mjs";import{a as Di}from"./chunk-XJJVJOX5.mjs";import{a as Ir,b as Ci}from"./chunk-EF4FA5I6.mjs";import{a as Q}from"./chunk-WCMW2L3P.mjs";import{a as zn,b as ke}from"./chunk-WSR5EBJM.mjs";import{d as vi,e as _i,f as Ui,g as ki,h as Fi,i as zi,j as Dn}from"./chunk-C3Q23D22.mjs";import{a as Rr,b as Or}from"./chunk-QREVMGQZ.mjs";import{a as ne}from"./chunk-FGFLPH5K.mjs";import{a as Gr}from"./chunk-ADJMFL73.mjs";import{a as To}from"./chunk-TT3MPSBB.mjs";import{a as T}from"./chunk-TSEAIF34.mjs";import{a as So,b as Vn,c as Po,d as Ko,e as xo,g as Gt,h as Io,k as Eo,l as Co}from"./chunk-57YZ7I7V.mjs";import{a as Ot}from"./chunk-YOZBVVKL.mjs";import{a as Mn,b as Ao,c as P,e as ho,f as bo}from"./chunk-DHCGYW3W.mjs";import{A as mo,B as Dr,C as fo,d as eo,e as to,f as no,g as ro,h as io,j as oo,k as so,l as ao,m as co,o as uo,p as po,q as lo,s as go,t as yo,u as Nt,v as zr,w as Gn}from"./chunk-UL777LTI.mjs";import{b as st,d as Qi,e as _r,f as Ur}from"./chunk-KB4XOTCR.mjs";import{b as Rt,d as Ji,e as Zi,f as Yi}from"./chunk-3LJVXUPB.mjs";import{a as Bi}from"./chunk-CW35YAMN.mjs";import{d as S,e as ji}from"./chunk-6WDVDEQZ.mjs";import{a as xi}from"./chunk-TOBQ5UE6.mjs";import{a as Et}from"./chunk-MT2RJ7H3.mjs";import{a as K,b as Ei,c as F,d as te}from"./chunk-Q4W3WJ2U.mjs";import{a as H,b as Se,c as Ct,d as vt,e as fe,f as _t,g as Ut}from"./chunk-ORMOQWWH.mjs";import{a as k}from"./chunk-FLZPUYXQ.mjs";import{a as cn,b as Vi,c as Ve,d as Hi,e as Li,f as $i,i as qi,j as Wi,k as ue,l as Dt}from"./chunk-7DQDJ2SA.mjs";import{a as On}from"./chunk-HNBVYE3N.mjs";import{b as u}from"./chunk-RGKRCZ36.mjs";import{J as j,m as Ii}from"./chunk-MCFQE4GC.mjs";import{a as w,b as ee}from"./chunk-EBMEXURY.mjs";import{b as m,c as Ki}from"./chunk-STY74NUA.mjs";import{d as Pi}from"./chunk-56CNRT2K.mjs";import{a as vo}from"./chunk-7ZESTCBD.mjs";import{g as Cr}from"./chunk-EMR3S3VO.mjs";import{d as Ri,e as Be,f as Oi,g as Ni,h as vr,i as Gi,k as Mi}from"./chunk-OLILO7VD.mjs";import{a as xr}from"./chunk-KDMSOCZY.mjs";import{ed25519 as Kr}from"@noble/curves/ed25519";import{jwtDecode as wa}from"jwt-decode";import{sha3_256 as zc}from"@noble/hashes/sha3";import{bn254 as Ue}from"@noble/curves/bn254";import{bytesToNumberBE as Dc}from"@noble/curves/abstract/utils";import{encode as Rc}from"js-base64";import{sha3_256 as _o}from"@noble/hashes/sha3";import{secp256k1 as un}from"@noble/curves/secp256k1";import{HDKey as Sa}from"@scure/bip32";var Pe=class Pe extends zn{constructor(t){super();this.keyType="secp256k1";let r=m.fromHexInput(t),{length:i}=r.toUint8Array();if(i===Pe.LENGTH)this.key=r;else if(i===Pe.COMPRESSED_LENGTH){let o=un.ProjectivePoint.fromHex(r.toUint8Array());this.key=m.fromHexInput(o.toRawBytes(!1))}else throw new Error(`PublicKey length should be ${Pe.LENGTH} or ${Pe.COMPRESSED_LENGTH}, received ${i}`)}verifySignature(t){let{message:r,signature:i}=t,o=Bt(r),s=m.fromHexInput(o).toUint8Array(),a=_o(s),c=i.toUint8Array();return un.verify(c,a,this.key.toUint8Array(),{lowS:!0})}async verifySignatureAsync(t){return this.verifySignature(t)}toUint8Array(){return this.key.toUint8Array()}serialize(t){t.serializeBytes(this.key.toUint8Array())}deserialize(t){let r=t.deserializeBytes();return new Le(r)}static deserialize(t){let r=t.deserializeBytes();return new Pe(r)}static isPublicKey(t){return t instanceof Pe}static isInstance(t){return"key"in t&&t.key?.data?.length===Pe.LENGTH&&"keyType"in t&&t.keyType==="secp256k1"}};Pe.LENGTH=65,Pe.COMPRESSED_LENGTH=33;var Ke=Pe,ze=class ze extends w{constructor(e,t){super();let r=kt.parseHexInput(e,"secp256k1",t);if(r.toUint8Array().length!==ze.LENGTH)throw new Error(`PrivateKey length should be ${ze.LENGTH}`);this.key=r}static generate(){let e=un.utils.randomPrivateKey();return new ze(e,!1)}static fromDerivationPath(e,t){if(!_i(e))throw new Error(`Invalid derivation path ${e}`);return ze.fromDerivationPathInner(e,Dn(t))}static fromDerivationPathInner(e,t){let{privateKey:r}=Sa.fromMasterSeed(t).derive(e);if(r===null)throw new Error("Invalid key");return new ze(r,!1)}sign(e){let t=Bt(e),r=m.fromHexInput(t),i=_o(r.toUint8Array()),o=un.sign(i,this.key.toUint8Array(),{lowS:!0});return new Le(o.toCompactRawBytes())}publicKey(){let e=un.getPublicKey(this.key.toUint8Array(),!1);return new Ke(e)}toUint8Array(){return this.key.toUint8Array()}toString(){return this.toAIP80String()}toHexString(){return this.key.toString()}toAIP80String(){return kt.formatPrivateKey(this.key.toString(),"secp256k1")}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new ze(t,!1)}static isPrivateKey(e){return e instanceof ze}};ze.LENGTH=32;var He=ze,Mt=class Mt extends Q{constructor(e){super();let t=m.fromHexInput(e);if(t.toUint8Array().length!==Mt.LENGTH)throw new Error(`Signature length should be ${Mt.LENGTH}, received ${t.toUint8Array().length}`);this.data=t}toUint8Array(){return this.data.toUint8Array()}serialize(e){e.serializeBytes(this.data.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new Mt(t)}};Mt.LENGTH=64;var Le=Mt;var x=class n extends ke{constructor(e){if(super(),this.publicKey=e,e instanceof b)this.variant=0;else if(e instanceof Ke)this.variant=1;else if(e instanceof kr)this.variant=2;else if(e instanceof E)this.variant=3;else if(e instanceof G)this.variant=4;else throw new Error("Unsupported public key type")}verifySignature(e){let{message:t,signature:r}=e;if(this.publicKey instanceof E)throw new Error("Use verifySignatureAsync to verify Keyless signatures");return this.publicKey.verifySignature({message:t,signature:r.signature})}async verifySignatureAsync(e){if(!(e.signature instanceof D)){if(e.options?.throwErrorWithReason)throw new Error("Signature must be an instance of AnySignature");return!1}return await this.publicKey.verifySignatureAsync({...e,signature:e.signature.signature})}authKey(){return ne.fromSchemeAndBytes({scheme:2,input:this.toUint8Array()})}toUint8Array(){return this.bcsToBytes()}serialize(e){e.serializeU32AsUleb128(this.variant),this.publicKey.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32(),r;switch(t){case 0:r=b.deserialize(e);break;case 1:r=Ke.deserialize(e);break;case 2:r=kr.deserialize(e);break;case 3:r=E.deserialize(e);break;case 4:r=G.deserialize(e);break;default:throw new Error(`Unknown variant index for AnyPublicKey: ${t}`)}return new n(r)}static isPublicKey(e){return e instanceof n}isEd25519(){return this.publicKey instanceof b}isSecp256k1PublicKey(){return this.publicKey instanceof Ke}static isInstance(e){return"publicKey"in e&&"variant"in e}},D=class n extends Q{constructor(e){if(super(),this.signature=e,e instanceof C)this.variant=0;else if(e instanceof Le)this.variant=1;else if(e instanceof Fr)this.variant=2;else if(e instanceof re)this.variant=3;else throw new Error("Unsupported signature type")}toUint8Array(){return console.warn("[Aptos SDK] Calls to AnySignature.toUint8Array() will soon return the underlying signature bytes. Use AnySignature.bcsToBytes() instead."),this.bcsToBytes()}serialize(e){e.serializeU32AsUleb128(this.variant),this.signature.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32(),r;switch(t){case 0:r=C.deserialize(e);break;case 1:r=Le.deserialize(e);break;case 2:r=Fr.deserialize(e);break;case 3:r=re.deserialize(e);break;default:throw new Error(`Unknown variant index for AnySignature: ${t}`)}return new n(r)}static isInstance(e){return"signature"in e&&typeof e.signature=="object"&&e.signature!==null&&"toUint8Array"in e.signature}};function Pa(n){let e=n;return e-=e>>1&1431655765,e=(e&858993459)+(e>>2&858993459),(e+(e>>4)&252645135)*16843009>>24}var $n=3,xe=class extends ke{constructor(e){super(),this.publicKeys=e.publicKeys}createBitmap(e){let{bits:t}=e,r=128,i=new Uint8Array([0,0,0,0]),o=new Set;return t.forEach((s,a)=>{if(a+1>this.publicKeys.length)throw new Error(`Signature index ${a+1} is out of public keys range, ${this.publicKeys.length}.`);if(o.has(s))throw new Error(`Duplicate bit ${s} detected.`);o.add(s);let c=Math.floor(s/8),d=i[c];d|=r>>s%8,i[c]=d}),i}getIndex(e){let t=this.publicKeys.findIndex(r=>r.toString()===e.toString());if(t!==-1)return t;throw new Error(`Public key ${e} not found in multi key set ${this.publicKeys}`)}},B=class n extends xe{constructor(e){let{publicKeys:t,signaturesRequired:r}=e;if(super({publicKeys:t}),r<1)throw new Error("The number of required signatures needs to be greater than 0");if(t.length<r)throw new Error(`Provided ${t.length} public keys is smaller than the ${r} required signatures`);if(this.publicKeys=t.map(i=>i instanceof x?i:new x(i)),r>$n&&this.publicKeys.filter(o=>o.variant===3||o.variant===4).length>$n)throw new Error(`Construction of MultiKey with more than ${$n} keyless public keys is not allowed when signaturesRequired
1
+ import{a as Hn,b as Nr}from"./chunk-A5L76YP7.mjs";import{a as Fe,b as Rn,c as Ft,d as Er,e as zt}from"./chunk-GOXRBEIJ.mjs";import{a as Di}from"./chunk-XJJVJOX5.mjs";import{a as kr,c as Fr}from"./chunk-QNARIAVM.mjs";import{a as kt}from"./chunk-2PASUPUO.mjs";import{d as vi,e as _i,f as Ui,g as ki,h as Fi,i as zi,j as Dn}from"./chunk-C3Q23D22.mjs";import{a as Ir,b as Ci}from"./chunk-RQX6JOEN.mjs";import{a as zn,b as ke}from"./chunk-WSR5EBJM.mjs";import{a as Q}from"./chunk-WCMW2L3P.mjs";import{a as Xi}from"./chunk-V74WPKSY.mjs";import{a as Bn,b as wo}from"./chunk-626KB2UQ.mjs";import{a as Nn}from"./chunk-XKUIMGKU.mjs";import{a as z}from"./chunk-N6YTF76Q.mjs";import{a as ne}from"./chunk-FGFLPH5K.mjs";import{a as Rr,b as Or}from"./chunk-QREVMGQZ.mjs";import{a as Gr}from"./chunk-2OPKZKOB.mjs";import{a as To}from"./chunk-FC72YL4B.mjs";import{a as T}from"./chunk-YS5IUILF.mjs";import{a as So,b as Vn,c as Po,d as Ko,e as xo,g as Gt,h as Io,k as Eo,l as Co}from"./chunk-PSSIJHHC.mjs";import{a as Ot}from"./chunk-YOZBVVKL.mjs";import{a as Mn,b as Ao,c as P,e as ho,f as bo}from"./chunk-R7FWJP3N.mjs";import{A as mo,B as Dr,C as fo,d as eo,e as to,f as no,g as ro,h as io,j as oo,k as so,l as ao,m as co,o as uo,p as po,q as lo,s as go,t as yo,u as Nt,v as zr,w as Gn}from"./chunk-UL777LTI.mjs";import{b as st,d as Qi,e as _r,f as Ur}from"./chunk-AQW4BUKF.mjs";import{b as Rt,d as Ji,e as Zi,f as Yi}from"./chunk-E2U27PNC.mjs";import{a as Bi}from"./chunk-CW35YAMN.mjs";import{d as S,e as ji}from"./chunk-YZHAI55C.mjs";import{a as xi}from"./chunk-TOBQ5UE6.mjs";import{a as Et}from"./chunk-MT2RJ7H3.mjs";import{a as K,b as Ei,c as F,d as te}from"./chunk-Q4W3WJ2U.mjs";import{a as H,b as Se,c as Ct,d as vt,e as fe,f as _t,g as Ut}from"./chunk-ORMOQWWH.mjs";import{a as k}from"./chunk-FLZPUYXQ.mjs";import{a as cn,b as Vi,c as Ve,d as Hi,e as Li,f as $i,i as qi,j as Wi,k as ue,l as Dt}from"./chunk-LA56UDUK.mjs";import{a as On}from"./chunk-ZYE7UTJZ.mjs";import{b as u}from"./chunk-RGKRCZ36.mjs";import{J as j,m as Ii}from"./chunk-MCFQE4GC.mjs";import{a as w,b as ee}from"./chunk-EBMEXURY.mjs";import{b as m,c as Ki}from"./chunk-STY74NUA.mjs";import{d as Pi}from"./chunk-56CNRT2K.mjs";import{a as vo}from"./chunk-NCKJ7X57.mjs";import{g as Cr}from"./chunk-P5HCJN3A.mjs";import{d as Ri,e as Be,f as Oi,g as Ni,h as vr,i as Gi,k as Mi}from"./chunk-OLILO7VD.mjs";import{a as xr}from"./chunk-KDMSOCZY.mjs";import{ed25519 as Kr}from"@noble/curves/ed25519";import{jwtDecode as wa}from"jwt-decode";import{sha3_256 as zc}from"@noble/hashes/sha3";import{bn254 as Ue}from"@noble/curves/bn254";import{bytesToNumberBE as Dc}from"@noble/curves/abstract/utils";import{encode as Rc}from"js-base64";import{sha3_256 as _o}from"@noble/hashes/sha3";import{secp256k1 as un}from"@noble/curves/secp256k1";import{HDKey as Sa}from"@scure/bip32";var Pe=class Pe extends zn{constructor(t){super();this.keyType="secp256k1";let r=m.fromHexInput(t),{length:i}=r.toUint8Array();if(i===Pe.LENGTH)this.key=r;else if(i===Pe.COMPRESSED_LENGTH){let o=un.ProjectivePoint.fromHex(r.toUint8Array());this.key=m.fromHexInput(o.toRawBytes(!1))}else throw new Error(`PublicKey length should be ${Pe.LENGTH} or ${Pe.COMPRESSED_LENGTH}, received ${i}`)}verifySignature(t){let{message:r,signature:i}=t,o=Bt(r),s=m.fromHexInput(o).toUint8Array(),a=_o(s),c=i.toUint8Array();return un.verify(c,a,this.key.toUint8Array(),{lowS:!0})}async verifySignatureAsync(t){return this.verifySignature(t)}toUint8Array(){return this.key.toUint8Array()}serialize(t){t.serializeBytes(this.key.toUint8Array())}deserialize(t){let r=t.deserializeBytes();return new Le(r)}static deserialize(t){let r=t.deserializeBytes();return new Pe(r)}static isPublicKey(t){return t instanceof Pe}static isInstance(t){return"key"in t&&t.key?.data?.length===Pe.LENGTH&&"keyType"in t&&t.keyType==="secp256k1"}};Pe.LENGTH=65,Pe.COMPRESSED_LENGTH=33;var Ke=Pe,ze=class ze extends w{constructor(e,t){super();let r=kt.parseHexInput(e,"secp256k1",t);if(r.toUint8Array().length!==ze.LENGTH)throw new Error(`PrivateKey length should be ${ze.LENGTH}`);this.key=r}static generate(){let e=un.utils.randomPrivateKey();return new ze(e,!1)}static fromDerivationPath(e,t){if(!_i(e))throw new Error(`Invalid derivation path ${e}`);return ze.fromDerivationPathInner(e,Dn(t))}static fromDerivationPathInner(e,t){let{privateKey:r}=Sa.fromMasterSeed(t).derive(e);if(r===null)throw new Error("Invalid key");return new ze(r,!1)}sign(e){let t=Bt(e),r=m.fromHexInput(t),i=_o(r.toUint8Array()),o=un.sign(i,this.key.toUint8Array(),{lowS:!0});return new Le(o.toCompactRawBytes())}publicKey(){let e=un.getPublicKey(this.key.toUint8Array(),!1);return new Ke(e)}toUint8Array(){return this.key.toUint8Array()}toString(){return this.toAIP80String()}toHexString(){return this.key.toString()}toAIP80String(){return kt.formatPrivateKey(this.key.toString(),"secp256k1")}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new ze(t,!1)}static isPrivateKey(e){return e instanceof ze}};ze.LENGTH=32;var He=ze,Mt=class Mt extends Q{constructor(e){super();let t=m.fromHexInput(e);if(t.toUint8Array().length!==Mt.LENGTH)throw new Error(`Signature length should be ${Mt.LENGTH}, received ${t.toUint8Array().length}`);this.data=t}toUint8Array(){return this.data.toUint8Array()}serialize(e){e.serializeBytes(this.data.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new Mt(t)}};Mt.LENGTH=64;var Le=Mt;var x=class n extends ke{constructor(e){if(super(),this.publicKey=e,e instanceof b)this.variant=0;else if(e instanceof Ke)this.variant=1;else if(e instanceof kr)this.variant=2;else if(e instanceof E)this.variant=3;else if(e instanceof G)this.variant=4;else throw new Error("Unsupported public key type")}verifySignature(e){let{message:t,signature:r}=e;if(this.publicKey instanceof E)throw new Error("Use verifySignatureAsync to verify Keyless signatures");return this.publicKey.verifySignature({message:t,signature:r.signature})}async verifySignatureAsync(e){if(!(e.signature instanceof D)){if(e.options?.throwErrorWithReason)throw new Error("Signature must be an instance of AnySignature");return!1}return await this.publicKey.verifySignatureAsync({...e,signature:e.signature.signature})}authKey(){return ne.fromSchemeAndBytes({scheme:2,input:this.toUint8Array()})}toUint8Array(){return this.bcsToBytes()}serialize(e){e.serializeU32AsUleb128(this.variant),this.publicKey.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32(),r;switch(t){case 0:r=b.deserialize(e);break;case 1:r=Ke.deserialize(e);break;case 2:r=kr.deserialize(e);break;case 3:r=E.deserialize(e);break;case 4:r=G.deserialize(e);break;default:throw new Error(`Unknown variant index for AnyPublicKey: ${t}`)}return new n(r)}static isPublicKey(e){return e instanceof n}isEd25519(){return this.publicKey instanceof b}isSecp256k1PublicKey(){return this.publicKey instanceof Ke}static isInstance(e){return"publicKey"in e&&"variant"in e}},D=class n extends Q{constructor(e){if(super(),this.signature=e,e instanceof C)this.variant=0;else if(e instanceof Le)this.variant=1;else if(e instanceof Fr)this.variant=2;else if(e instanceof re)this.variant=3;else throw new Error("Unsupported signature type")}toUint8Array(){return console.warn("[Aptos SDK] Calls to AnySignature.toUint8Array() will soon return the underlying signature bytes. Use AnySignature.bcsToBytes() instead."),this.bcsToBytes()}serialize(e){e.serializeU32AsUleb128(this.variant),this.signature.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32(),r;switch(t){case 0:r=C.deserialize(e);break;case 1:r=Le.deserialize(e);break;case 2:r=Fr.deserialize(e);break;case 3:r=re.deserialize(e);break;default:throw new Error(`Unknown variant index for AnySignature: ${t}`)}return new n(r)}static isInstance(e){return"signature"in e&&typeof e.signature=="object"&&e.signature!==null&&"toUint8Array"in e.signature}};function Pa(n){let e=n;return e-=e>>1&1431655765,e=(e&858993459)+(e>>2&858993459),(e+(e>>4)&252645135)*16843009>>24}var $n=3,xe=class extends ke{constructor(e){super(),this.publicKeys=e.publicKeys}createBitmap(e){let{bits:t}=e,r=128,i=new Uint8Array([0,0,0,0]),o=new Set;return t.forEach((s,a)=>{if(a+1>this.publicKeys.length)throw new Error(`Signature index ${a+1} is out of public keys range, ${this.publicKeys.length}.`);if(o.has(s))throw new Error(`Duplicate bit ${s} detected.`);o.add(s);let c=Math.floor(s/8),d=i[c];d|=r>>s%8,i[c]=d}),i}getIndex(e){let t=this.publicKeys.findIndex(r=>r.toString()===e.toString());if(t!==-1)return t;throw new Error(`Public key ${e} not found in multi key set ${this.publicKeys}`)}},B=class n extends xe{constructor(e){let{publicKeys:t,signaturesRequired:r}=e;if(super({publicKeys:t}),r<1)throw new Error("The number of required signatures needs to be greater than 0");if(t.length<r)throw new Error(`Provided ${t.length} public keys is smaller than the ${r} required signatures`);if(this.publicKeys=t.map(i=>i instanceof x?i:new x(i)),r>$n&&this.publicKeys.filter(o=>o.variant===3||o.variant===4).length>$n)throw new Error(`Construction of MultiKey with more than ${$n} keyless public keys is not allowed when signaturesRequired
2
2
  is greater than ${$n}. This is because a maximum of 3 keyless signatures are supported for a
3
- K-of-N MultiKey transaction.`);this.signaturesRequired=r}getSignaturesRequired(){return this.signaturesRequired}verifySignature(e){let{message:t,signature:r}=e;if(r.signatures.length!==this.signaturesRequired)throw new Error("The number of signatures does not match the number of required signatures");let i=r.bitMapToSignerIndices();for(let o=0;o<r.signatures.length;o+=1){let s=r.signatures[o];if(!this.publicKeys[i[o]].verifySignature({message:t,signature:s}))return!1}return!0}async verifySignatureAsync(e){let{signature:t}=e;try{if(!(t instanceof Ae))throw new Error("Signature is not a MultiKeySignature");if(t.signatures.length!==this.signaturesRequired)throw new Error("The number of signatures does not match the number of required signatures");let r=t.bitMapToSignerIndices();for(let i=0;i<t.signatures.length;i+=1){let o=t.signatures[i];if(!await this.publicKeys[r[i]].verifySignatureAsync({...e,signature:o}))return!1}return!0}catch(r){if(e.options?.throwErrorWithReason)throw r;return!1}}authKey(){return ne.fromSchemeAndBytes({scheme:3,input:this.toUint8Array()})}serialize(e){e.serializeVector(this.publicKeys),e.serializeU8(this.signaturesRequired)}static deserialize(e){let t=e.deserializeVector(x),r=e.deserializeU8();return new n({publicKeys:t,signaturesRequired:r})}getIndex(e){let t=e instanceof x?e:new x(e);return super.getIndex(t)}static isInstance(e){return"publicKeys"in e&&"signaturesRequired"in e}},de=class de extends Q{constructor(e){super();let{signatures:t,bitmap:r}=e;if(t.length>de.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${de.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=t.map(o=>o instanceof D?o:new D(o)),!(r instanceof Uint8Array))this.bitmap=de.createBitmap({bits:r});else{if(r.length!==de.BITMAP_LEN)throw new Error(`"bitmap" length should be ${de.BITMAP_LEN}`);this.bitmap=r}let i=this.bitmap.reduce((o,s)=>o+Pa(s),0);if(i!==this.signatures.length)throw new Error(`Expecting ${i} signatures from the bitmap, but got ${this.signatures.length}`)}static createBitmap(e){let{bits:t}=e,r=128,i=new Uint8Array([0,0,0,0]),o=new Set;return t.forEach(s=>{if(s>=de.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${de.MAX_SIGNATURES_SUPPORTED-1}.`);if(o.has(s))throw new Error("Duplicate bits detected.");o.add(s);let a=Math.floor(s/8),c=i[a];c|=r>>s%8,i[a]=c}),i}bitMapToSignerIndices(){let e=[];for(let t=0;t<this.bitmap.length;t+=1){let r=this.bitmap[t];for(let i=0;i<8;i+=1)(r&128>>i)!==0&&e.push(t*8+i)}return e}serialize(e){e.serializeVector(this.signatures),e.serializeBytes(this.bitmap)}static deserialize(e){let t=e.deserializeVector(D),r=e.deserializeBytes();return new de({signatures:t,bitmap:r})}};de.BITMAP_LEN=4,de.MAX_SIGNATURES_SUPPORTED=de.BITMAP_LEN*8;var Ae=de;var pe=class pe extends xe{constructor(e){let{publicKeys:t,threshold:r}=e;if(super({publicKeys:t}),t.length>pe.MAX_KEYS||t.length<pe.MIN_KEYS)throw new Error(`Must have between ${pe.MIN_KEYS} and ${pe.MAX_KEYS} public keys, inclusive`);if(r<pe.MIN_THRESHOLD||r>t.length)throw new Error(`Threshold must be between ${pe.MIN_THRESHOLD} and ${t.length}, inclusive`);this.publicKeys=t,this.threshold=r}getSignaturesRequired(){return this.threshold}verifySignature(e){let{message:t,signature:r}=e;if(!(r instanceof Ie))return!1;let i=[];for(let o=0;o<4;o+=1)for(let s=0;s<8;s+=1)if((r.bitmap[o]&1<<7-s)!==0){let c=o*8+s;i.push(c)}if(i.length!==r.signatures.length)throw new Error("Bitmap and signatures length mismatch");if(i.length<this.threshold)throw new Error("Not enough signatures");for(let o=0;o<i.length;o+=1)if(!this.publicKeys[i[o]].verifySignature({message:t,signature:r.signatures[o]}))return!1;return!0}async verifySignatureAsync(e){return this.verifySignature(e)}authKey(){return ne.fromSchemeAndBytes({scheme:1,input:this.toUint8Array()})}toUint8Array(){let e=new Uint8Array(this.publicKeys.length*b.LENGTH+1);return this.publicKeys.forEach((t,r)=>{e.set(t.toUint8Array(),r*b.LENGTH)}),e[this.publicKeys.length*b.LENGTH]=this.threshold,e}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes(),r=t[t.length-1],i=[];for(let o=0;o<t.length-1;o+=b.LENGTH){let s=o;i.push(new b(t.subarray(s,s+b.LENGTH)))}return new pe({publicKeys:i,threshold:r})}static deserializeWithoutLength(e){let t=e.remaining(),r=e.deserializeFixedBytes(t),i=r[r.length-1],o=[];for(let s=0;s<r.length-1;s+=b.LENGTH){let a=s;o.push(new b(r.subarray(a,a+b.LENGTH)))}return new pe({publicKeys:o,threshold:i})}getIndex(e){return super.getIndex(e)}};pe.MAX_KEYS=32,pe.MIN_KEYS=2,pe.MIN_THRESHOLD=1;var Z=pe,le=class le extends Q{constructor(e){super();let{signatures:t,bitmap:r}=e;if(t.length>le.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${le.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=t,!(r instanceof Uint8Array))this.bitmap=le.createBitmap({bits:r});else{if(r.length!==le.BITMAP_LEN)throw new Error(`"bitmap" length should be ${le.BITMAP_LEN}`);this.bitmap=r}}toUint8Array(){let e=new Uint8Array(this.signatures.length*C.LENGTH+le.BITMAP_LEN);return this.signatures.forEach((t,r)=>{e.set(t.toUint8Array(),r*C.LENGTH)}),e.set(this.bitmap,this.signatures.length*C.LENGTH),e}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes(),r=t.subarray(t.length-4),i=[];for(let o=0;o<t.length-r.length;o+=C.LENGTH){let s=o;i.push(new C(t.subarray(s,s+C.LENGTH)))}return new le({signatures:i,bitmap:r})}static createBitmap(e){let{bits:t}=e,r=128,i=new Uint8Array([0,0,0,0]),o=new Set;return t.forEach((s,a)=>{if(s>=le.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${le.MAX_SIGNATURES_SUPPORTED-1}.`);if(o.has(s))throw new Error("Duplicate bits detected.");if(a>0&&s<=t[a-1])throw new Error("The bits need to be sorted in ascending order.");o.add(s);let c=Math.floor(s/8),d=i[c];d|=r>>s%8,i[c]=d}),i}};le.MAX_SIGNATURES_SUPPORTED=32,le.BITMAP_LEN=4;var Ie=le;var qn="Multiple possible deserializations found";function ed(n){let e=[b,x,Z,B,E,G,Ke],t;for(let r of e)try{let i=k.fromHex(n),o=r.deserialize(i);if(i.assertFinished(),t)throw new Error(`${qn}: ${n}`);t=o}catch(i){if(i instanceof Error&&i.message.includes(qn))throw i}if(!t)throw new Error(`Failed to deserialize public key: ${n}`);return t}function td(n){let e=[C,D,Ie,Ae,re,Le],t;for(let r of e)try{let i=k.fromHex(n),o=r.deserialize(i);if(i.assertFinished(),t)throw new Error(`${qn}: ${n}`);t=o}catch(i){if(i instanceof Error&&i.message.includes(qn))throw i}if(!t)throw new Error(`Failed to deserialize signature: ${n}`);return t}var q=class extends w{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return Ee.load(e);case 1:return $e.load(e);case 2:return ie.load(e);case 3:return De.load(e);case 4:return Vt.load(e);case 5:return yt.load(e);default:throw new Error(`Unknown variant index for AccountAuthenticator: ${t}`)}}isEd25519(){return this instanceof Ee}isMultiEd25519(){return this instanceof $e}isSingleKey(){return this instanceof ie}isMultiKey(){return this instanceof De}},Ee=class n extends q{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(0),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=b.deserialize(e),r=C.deserialize(e);return new n(t,r)}},$e=class n extends q{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(1),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=Z.deserialize(e),r=Ie.deserialize(e);return new n(t,r)}},ie=class n extends q{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(2),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=x.deserialize(e),r=D.deserialize(e);return new n(t,r)}},De=class n extends q{constructor(e,t){super(),this.public_keys=e,this.signatures=t}serialize(e){e.serializeU32AsUleb128(3),this.public_keys.serialize(e),this.signatures.serialize(e)}static load(e){let t=B.deserialize(e),r=Ae.deserialize(e);return new n(t,r)}},Vt=class n extends q{serialize(e){e.serializeU32AsUleb128(4)}static load(e){return new n}},yt=class n extends q{constructor(e,t,r,i){if(super(),!Dt(e))throw new Error(`Invalid function info ${e} passed into AccountAuthenticatorAbstraction`);this.functionInfo=e,this.abstractionSignature=r,this.signingMessageDigest=m.fromHexInput(m.fromHexInput(t).toUint8Array()),this.accountIdentity=i}serialize(e){e.serializeU32AsUleb128(5);let{moduleAddress:t,moduleName:r,functionName:i}=ue(this.functionInfo);u.fromString(t).serialize(e),e.serializeStr(r),e.serializeStr(i),this.accountIdentity?e.serializeU32AsUleb128(1):e.serializeU32AsUleb128(0),e.serializeBytes(this.signingMessageDigest.toUint8Array()),this.accountIdentity?e.serializeBytes(this.abstractionSignature):e.serializeFixedBytes(this.abstractionSignature),this.accountIdentity&&e.serializeBytes(this.accountIdentity)}static load(e){let t=u.deserialize(e),r=e.deserializeStr(),i=e.deserializeStr(),o=e.deserializeUleb128AsU32(),s=e.deserializeBytes();if(o===0){let a=e.deserializeFixedBytes(e.remaining());return new n(`${t}::${r}::${i}`,s,a)}if(o===1){let a=e.deserializeBytes(),c=e.deserializeBytes();return new n(`${t}::${r}::${i}`,s,a,c)}throw new Error(`Unknown variant index for AccountAuthenticatorAbstraction: ${o}`)}},Wn=class n extends w{constructor(e,t){super(),this.originalSigningMessage=m.fromHexInput(m.fromHexInput(e).toUint8Array()),this.functionInfo=t}serialize(e){e.serializeU32AsUleb128(0),e.serializeBytes(this.originalSigningMessage.toUint8Array());let{moduleAddress:t,moduleName:r,functionName:i}=ue(this.functionInfo);u.fromString(t).serialize(e),e.serializeStr(r),e.serializeStr(i)}static deserialize(e){let t=e.deserializeUleb128AsU32();if(t!==0)throw new Error(`Unknown variant index for AccountAbstractionMessage: ${t}`);let r=e.deserializeBytes(),i=u.deserialize(e),o=e.deserializeStr(),s=e.deserializeStr(),a=`${i}::${o}::${s}`;return new n(r,a)}};import{sha3_256 as xa}from"@noble/hashes/sha3";var dn=class n extends w{constructor(e,t){super(),this.address=e,this.name=t}static fromStr(e){let t=e.split("::");if(t.length!==2)throw new Error("Invalid module id.");return new n(u.fromString(t[0]),new z(t[1]))}serialize(e){this.address.serialize(e),this.name.serialize(e)}static deserialize(e){let t=u.deserialize(e),r=z.deserialize(e);return new n(t,r)}};var O=class n extends w{deserialize(e){let t=u.deserialize(e),r=z.deserialize(e),i=z.deserialize(e),o=e.deserializeVector(n);return new Re(t,r,i,o)}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return V.load(e);case 1:return oe.load(e);case 2:return W.load(e);case 3:return je.load(e);case 4:return R.load(e);case 5:return mt.load(e);case 6:return v.load(e);case 7:return f.load(e);case 8:return qe.load(e);case 9:return We.load(e);case 10:return Qe.load(e);case 255:return N.load(e);default:throw new Error(`Unknown variant index for TypeTag: ${t}`)}}isBool(){return this instanceof V}isAddress(){return this instanceof R}isGeneric(){return this instanceof N}isSigner(){return this instanceof mt}isVector(){return this instanceof v}isStruct(){return this instanceof f}isU8(){return this instanceof oe}isU16(){return this instanceof qe}isU32(){return this instanceof We}isU64(){return this instanceof W}isU128(){return this instanceof je}isU256(){return this instanceof Qe}isPrimitive(){return this instanceof mt||this instanceof R||this instanceof V||this instanceof oe||this instanceof qe||this instanceof We||this instanceof W||this instanceof je||this instanceof Qe}},V=class n extends O{toString(){return"bool"}serialize(e){e.serializeU32AsUleb128(0)}static load(e){return new n}},oe=class n extends O{toString(){return"u8"}serialize(e){e.serializeU32AsUleb128(1)}static load(e){return new n}},qe=class n extends O{toString(){return"u16"}serialize(e){e.serializeU32AsUleb128(8)}static load(e){return new n}},We=class n extends O{toString(){return"u32"}serialize(e){e.serializeU32AsUleb128(9)}static load(e){return new n}},W=class n extends O{toString(){return"u64"}serialize(e){e.serializeU32AsUleb128(2)}static load(e){return new n}},je=class n extends O{toString(){return"u128"}serialize(e){e.serializeU32AsUleb128(3)}static load(e){return new n}},Qe=class n extends O{toString(){return"u256"}serialize(e){e.serializeU32AsUleb128(10)}static load(e){return new n}},R=class n extends O{toString(){return"address"}serialize(e){e.serializeU32AsUleb128(4)}static load(e){return new n}},mt=class n extends O{toString(){return"signer"}serialize(e){e.serializeU32AsUleb128(5)}static load(e){return new n}},jn=class n extends O{constructor(t){super();this.value=t}toString(){return`&${this.value.toString()}`}serialize(t){t.serializeU32AsUleb128(254)}static load(t){let r=O.deserialize(t);return new n(r)}},N=class n extends O{constructor(t){super();this.value=t;if(t<0)throw new Error("Generic type parameter index cannot be negative")}toString(){return`T${this.value}`}serialize(t){t.serializeU32AsUleb128(255),t.serializeU32(this.value)}static load(t){let r=t.deserializeU32();return new n(r)}},v=class n extends O{constructor(t){super();this.value=t}toString(){return`vector<${this.value.toString()}>`}static u8(){return new n(new oe)}serialize(t){t.serializeU32AsUleb128(6),this.value.serialize(t)}static load(t){let r=O.deserialize(t);return new n(r)}},f=class n extends O{constructor(t){super();this.value=t}toString(){let t="";return this.value.typeArgs.length>0&&(t=`<${this.value.typeArgs.map(r=>r.toString()).join(", ")}>`),`${this.value.address.toString()}::${this.value.moduleName.identifier}::${this.value.name.identifier}${t}`}serialize(t){t.serializeU32AsUleb128(7),this.value.serialize(t)}static load(t){let r=Re.deserialize(t);return new n(r)}isTypeTag(t,r,i){return this.value.moduleName.identifier===r&&this.value.name.identifier===i&&this.value.address.equals(t)}isString(){return this.isTypeTag(u.ONE,"string","String")}isOption(){return this.isTypeTag(u.ONE,"option","Option")}isObject(){return this.isTypeTag(u.ONE,"object","Object")}isDelegationKey(){return this.isTypeTag(u.ONE,"permissioned_delegation","DelegationKey")}isRateLimiter(){return this.isTypeTag(u.ONE,"rate_limiter","RateLimiter")}},Re=class n extends w{constructor(e,t,r,i){super(),this.address=e,this.moduleName=t,this.name=r,this.typeArgs=i}serialize(e){e.serialize(this.address),e.serialize(this.moduleName),e.serialize(this.name),e.serializeVector(this.typeArgs)}static deserialize(e){let t=u.deserialize(e),r=z.deserialize(e),i=z.deserialize(e),o=e.deserializeVector(O);return new n(t,r,i,o)}};function Qd(){return new Re(u.ONE,new z("aptos_coin"),new z("AptosCoin"),[])}function I(){return new Re(u.ONE,new z("string"),new z("String"),[])}function Jd(n){return new Re(u.ONE,new z("option"),new z("Option"),[n])}function ge(n){return new Re(u.ONE,new z("object"),new z("Object"),[n])}function Ka(n){let e=n.deserializeUleb128AsU32();switch(e){case 0:return Se.deserialize(n);case 1:return fe.deserialize(n);case 2:return _t.deserialize(n);case 3:return u.deserialize(n);case 4:return K.deserialize(n,Se);case 5:return H.deserialize(n);case 6:return Ct.deserialize(n);case 7:return vt.deserialize(n);case 8:return Ut.deserialize(n);case 9:return Ei.deserialize(n);default:throw new Error(`Unknown variant index for ScriptTransactionArgument: ${e}`)}}var at=class extends w{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return Ht.load(e);case 2:return Lt.load(e);case 3:return $t.load(e);case 4:return Qn.deserialize(e);default:throw new Error(`Unknown variant index for TransactionPayload: ${t}`)}}},Ht=class n extends at{constructor(e){super(),this.script=e}serialize(e){e.serializeU32AsUleb128(0),this.script.serialize(e)}static load(e){let t=qt.deserialize(e);return new n(t)}},Lt=class n extends at{constructor(e){super(),this.entryFunction=e}serialize(e){e.serializeU32AsUleb128(2),this.entryFunction.serialize(e)}static load(e){let t=Je.deserialize(e);return new n(t)}},$t=class n extends at{constructor(e){super(),this.multiSig=e}serialize(e){e.serializeU32AsUleb128(3),this.multiSig.serialize(e)}static load(e){let t=pn.deserialize(e);return new n(t)}},Je=class n{constructor(e,t,r,i){this.module_name=e,this.function_name=t,this.type_args=r,this.args=i}static build(e,t,r,i){return new n(dn.fromStr(e),new z(t),r,i)}serialize(e){this.module_name.serialize(e),this.function_name.serialize(e),e.serializeVector(this.type_args),e.serializeU32AsUleb128(this.args.length),this.args.forEach(t=>{t.serializeForEntryFunction(e)})}static deserialize(e){let t=dn.deserialize(e),r=z.deserialize(e),i=e.deserializeVector(O),o=e.deserializeUleb128AsU32(),s=new Array;for(let a=0;a<o;a+=1){let c=e.deserializeUleb128AsU32(),d=xi.deserialize(e,c);s.push(d)}return new n(t,r,i,s)}},qt=class n{constructor(e,t,r){this.bytecode=e,this.type_args=t,this.args=r}serialize(e){e.serializeBytes(this.bytecode),e.serializeVector(this.type_args),e.serializeU32AsUleb128(this.args.length),this.args.forEach(t=>{t.serializeForScriptFunction(e)})}static deserialize(e){let t=e.deserializeBytes(),r=e.deserializeVector(O),i=e.deserializeUleb128AsU32(),o=new Array;for(let s=0;s<i;s+=1){let a=Ka(e);o.push(a)}return new n(t,r,o)}},pn=class n{constructor(e,t){this.multisig_address=e,this.transaction_payload=t}serialize(e){this.multisig_address.serialize(e),this.transaction_payload===void 0?e.serializeBool(!1):(e.serializeBool(!0),this.transaction_payload.serialize(e))}static deserialize(e){let t=u.deserialize(e),r=e.deserializeBool(),i;return r&&(i=ln.deserialize(e)),new n(t,i)}},ln=class n extends w{constructor(e){super(),this.transaction_payload=e}serialize(e){e.serializeU32AsUleb128(0),this.transaction_payload.serialize(e)}static deserialize(e){return e.deserializeUleb128AsU32(),new n(Je.deserialize(e))}},Qn=class extends at{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return ft.load(e);default:throw new Error(`Unknown variant index for TransactionInnerPayload: ${t}`)}}},ft=class n extends Qn{constructor(e,t){super(),this.executable=e,this.extra_config=t}serialize(e){e.serializeU32AsUleb128(4),e.serializeU32AsUleb128(0),this.executable.serialize(e),this.extra_config.serialize(e)}static load(e){let t=Wt.deserialize(e),r=Jn.deserialize(e);return new n(t,r)}},Wt=class{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return gn.load(e);case 1:return jt.load(e);case 2:return yn.load(e);default:throw new Error(`Unknown variant index for TransactionExecutable: ${t}`)}}},gn=class n extends Wt{constructor(e){super(),this.script=e}serialize(e){e.serializeU32AsUleb128(0),this.script.serialize(e)}static load(e){let t=qt.deserialize(e);return new n(t)}},jt=class n extends Wt{constructor(e){super(),this.entryFunction=e}serialize(e){e.serializeU32AsUleb128(1),this.entryFunction.serialize(e)}static load(e){let t=Je.deserialize(e);return new n(t)}},yn=class n extends Wt{serialize(e){e.serializeU32AsUleb128(2)}static load(e){return new n}},Jn=class{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return At.load(e);default:throw new Error(`Unknown variant index for TransactionExtraConfig: ${t}`)}}},At=class n extends Jn{constructor(e,t){super(),this.multisigAddress=e,this.replayProtectionNonce=t!==void 0?BigInt(t):void 0}serialize(e){e.serializeU32AsUleb128(0),e.serializeOption(this.multisigAddress),e.serializeOption(this.replayProtectionNonce!==void 0?new fe(this.replayProtectionNonce):void 0)}static load(e){let t=e.deserializeOption(u),r=e.deserializeOption(fe);return new n(t,r?.value)}};var he=class n extends w{constructor(e,t,r,i,o,s,a){super(),this.sender=e,this.sequence_number=t,this.payload=r,this.max_gas_amount=i,this.gas_unit_price=o,this.expiration_timestamp_secs=s,this.chain_id=a}serialize(e){this.sender.serialize(e),e.serializeU64(this.sequence_number),this.payload.serialize(e),e.serializeU64(this.max_gas_amount),e.serializeU64(this.gas_unit_price),e.serializeU64(this.expiration_timestamp_secs),this.chain_id.serialize(e)}static deserialize(e){let t=u.deserialize(e),r=e.deserializeU64(),i=at.deserialize(e),o=e.deserializeU64(),s=e.deserializeU64(),a=e.deserializeU64(),c=Nn.deserialize(e);return new n(t,r,i,o,s,a,c)}},Zn=class extends w{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return ht.load(e);case 1:return bt.load(e);default:throw new Error(`Unknown variant index for RawTransactionWithData: ${t}`)}}},ht=class n extends Zn{constructor(e,t){super(),this.raw_txn=e,this.secondary_signer_addresses=t}serialize(e){e.serializeU32AsUleb128(0),this.raw_txn.serialize(e),e.serializeVector(this.secondary_signer_addresses)}static load(e){let t=he.deserialize(e),r=e.deserializeVector(u);return new n(t,r)}},bt=class n extends Zn{constructor(e,t,r){super(),this.raw_txn=e,this.secondary_signer_addresses=t,this.fee_payer_address=r}serialize(e){e.serializeU32AsUleb128(1),this.raw_txn.serialize(e),e.serializeVector(this.secondary_signer_addresses),this.fee_payer_address.serialize(e)}static load(e){let t=he.deserialize(e),r=e.deserializeVector(u),i=u.deserialize(e);return new n(t,r,i)}};var Ze=class extends w{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return wt.load(e);case 1:return Qt.load(e);case 2:return Tt.load(e);case 3:return St.load(e);case 4:return ct.load(e);default:throw new Error(`Unknown variant index for TransactionAuthenticator: ${t}`)}}isEd25519(){return this instanceof wt}isMultiEd25519(){return this instanceof Qt}isMultiAgent(){return this instanceof Tt}isFeePayer(){return this instanceof St}isSingleSender(){return this instanceof ct}},wt=class n extends Ze{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(0),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=b.deserialize(e),r=C.deserialize(e);return new n(t,r)}},Qt=class n extends Ze{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(1),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=Z.deserialize(e),r=Ie.deserialize(e);return new n(t,r)}},Tt=class n extends Ze{constructor(e,t,r){super(),this.sender=e,this.secondary_signer_addresses=t,this.secondary_signers=r}serialize(e){e.serializeU32AsUleb128(2),this.sender.serialize(e),e.serializeVector(this.secondary_signer_addresses),e.serializeVector(this.secondary_signers)}static load(e){let t=q.deserialize(e),r=e.deserializeVector(u),i=e.deserializeVector(q);return new n(t,r,i)}},St=class n extends Ze{constructor(e,t,r,i){super(),this.sender=e,this.secondary_signer_addresses=t,this.secondary_signers=r,this.fee_payer=i}serialize(e){e.serializeU32AsUleb128(3),this.sender.serialize(e),e.serializeVector(this.secondary_signer_addresses),e.serializeVector(this.secondary_signers),this.fee_payer.address.serialize(e),this.fee_payer.authenticator.serialize(e)}static load(e){let t=q.deserialize(e),r=e.deserializeVector(u),i=e.deserializeVector(q),o=u.deserialize(e),s=q.deserialize(e),a={address:o,authenticator:s};return new n(t,r,i,a)}},ct=class n extends Ze{constructor(e){super(),this.sender=e}serialize(e){e.serializeU32AsUleb128(4),this.sender.serialize(e)}static load(e){let t=q.deserialize(e);return new n(t)}};var Ye=class n extends w{constructor(e,t){super(),this.raw_txn=e,this.authenticator=t}serialize(e){this.raw_txn.serialize(e),this.authenticator.serialize(e)}static deserialize(e){let t=he.deserialize(e),r=Ze.deserialize(e);return new n(t,r)}};var Yn=class n extends w{constructor(e,t){super(),this.rawTransaction=e,this.feePayerAddress=t}serialize(e){this.rawTransaction.serialize(e),this.feePayerAddress===void 0?e.serializeBool(!1):(e.serializeBool(!0),this.feePayerAddress.serialize(e))}static deserialize(e){let t=he.deserialize(e),r=e.deserializeBool(),i;return r&&(i=u.deserialize(e)),new n(t,i)}};var Xn=class n extends w{constructor(e,t,r){super(),this.rawTransaction=e,this.feePayerAddress=r,this.secondarySignerAddresses=t}serialize(e){this.rawTransaction.serialize(e),e.serializeVector(this.secondarySignerAddresses),this.feePayerAddress===void 0?e.serializeBool(!1):(e.serializeBool(!0),this.feePayerAddress.serialize(e))}static deserialize(e){let t=he.deserialize(e),r=e.deserializeVector(u),i=e.deserializeBool(),o;return i&&(o=u.deserialize(e)),new n(t,r,o)}};function er(n){return n.feePayerAddress?new bt(n.rawTransaction,n.secondarySignerAddresses??[],n.feePayerAddress):n.secondarySignerAddresses?new ht(n.rawTransaction,n.secondarySignerAddresses):n.rawTransaction}function Oe(n,e){let t=xa.create();if(!e.startsWith("APTOS::"))throw new Error(`Domain separator needs to start with 'APTOS::'. Provided - ${e}`);t.update(e);let r=t.digest(),i=n,o=new Uint8Array(r.length+i.length);return o.set(r),o.set(i,r.length),o}function dl(n){return Oe(n.bcsToBytes(),`APTOS::${n.constructor.name}`)}function Ce(n){let e=er(n);return n.feePayerAddress?Oe(e.bcsToBytes(),vr):n.secondarySignerAddresses?Oe(e.bcsToBytes(),vr):Oe(e.bcsToBytes(),Ni)}var Y=class n{constructor(e){this.signingScheme=0;let{privateKey:t,address:r}=e;this.privateKey=t,this.publicKey=t.publicKey(),this.accountAddress=r?u.from(r):this.publicKey.authKey().derivedAddress()}static generate(){let e=L.generate();return new n({privateKey:e})}static fromDerivationPath(e){let{path:t,mnemonic:r}=e,i=L.fromDerivationPath(t,r);return new n({privateKey:i})}verifySignature(e){return this.publicKey.verifySignature(e)}async verifySignatureAsync(e){return this.publicKey.verifySignatureAsync({...e,signature:e.signature})}signWithAuthenticator(e){return new Ee(this.publicKey,this.privateKey.sign(e))}signTransactionWithAuthenticator(e){return new Ee(this.publicKey,this.signTransaction(e))}sign(e){return this.privateKey.sign(e)}signTransaction(e){return this.sign(Ce(e))}};function Mr(n){return typeof n=="object"&&n!==null&&"getAnyPublicKey"in n&&typeof n.getAnyPublicKey=="function"}var se=class n{constructor(e){this.signingScheme=2;let{privateKey:t,address:r}=e;this.privateKey=t,this.publicKey=new x(t.publicKey()),this.accountAddress=r?u.from(r):this.publicKey.authKey().derivedAddress()}getAnyPublicKey(){return this.publicKey}static generate(e={}){let{scheme:t=0}=e,r;switch(t){case 0:r=L.generate();break;case 2:r=He.generate();break;default:throw new Error(`Unsupported signature scheme ${t}`)}return new n({privateKey:r})}static fromDerivationPath(e){let{scheme:t=0,path:r,mnemonic:i}=e,o;switch(t){case 0:o=L.fromDerivationPath(r,i);break;case 2:o=He.fromDerivationPath(r,i);break;default:throw new Error(`Unsupported signature scheme ${t}`)}return new n({privateKey:o})}verifySignature(e){return this.publicKey.verifySignature(e)}async verifySignatureAsync(e){return this.publicKey.verifySignatureAsync({...e,signature:e.signature})}signWithAuthenticator(e){return new ie(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new ie(this.publicKey,this.signTransaction(e))}sign(e){return new D(this.privateKey.sign(e))}signTransaction(e){return this.sign(Ce(e))}static fromEd25519Account(e){return new n({privateKey:e.privateKey,address:e.accountAddress})}};var Xe=class{static generate(e={}){let{scheme:t=0,legacy:r=!0}=e;return t===0&&r?Y.generate():se.generate({scheme:t})}static fromPrivateKey(e){let{privateKey:t,address:r,legacy:i=!0}=e;return t instanceof L&&i?new Y({privateKey:t,address:r}):new se({privateKey:t,address:r})}static fromPrivateKeyAndAddress(e){return this.fromPrivateKey(e)}static fromDerivationPath(e){let{scheme:t=0,mnemonic:r,path:i,legacy:o=!0}=e;return t===0&&o?Y.fromDerivationPath({mnemonic:r,path:i}):se.fromDerivationPath({scheme:t,mnemonic:r,path:i})}static authKey(e){let{publicKey:t}=e;return t.authKey()}verifySignature(e){return this.publicKey.verifySignature(e)}async verifySignatureAsync(e){return this.publicKey.verifySignatureAsync(e)}};import{randomBytes as Ca}from"@noble/hashes/utils";var va=1209600,Jt=class Jt extends w{constructor(e){super();let{privateKey:t,expiryDateSecs:r,blinder:i}=e;this.privateKey=t,this.publicKey=new ut(t.publicKey()),this.expiryDateSecs=r||Hi(Ve()+va),this.blinder=i!==void 0?m.fromHexInput(i).toUint8Array():_a();let o=Rn(this.publicKey.bcsToBytes(),93);o.push(BigInt(this.expiryDateSecs)),o.push(Ft(this.blinder));let s=zt(o);this.nonce=s.toString()}getPublicKey(){return this.publicKey}isExpired(){return Math.floor(Date.now()/1e3)>this.expiryDateSecs}serialize(e){e.serializeU32AsUleb128(this.publicKey.variant),e.serializeBytes(this.privateKey.toUint8Array()),e.serializeU64(this.expiryDateSecs),e.serializeFixedBytes(this.blinder)}static deserialize(e){let t=e.deserializeUleb128AsU32(),r;switch(t){case 0:r=L.deserialize(e);break;default:throw new Error(`Unknown variant index for EphemeralPublicKey: ${t}`)}let i=e.deserializeU64(),o=e.deserializeFixedBytes(31);return new Jt({privateKey:r,expiryDateSecs:Number(i),blinder:o})}static fromBytes(e){return Jt.deserialize(new k(e))}static generate(e){let t;switch(e?.scheme){case 0:default:t=L.generate()}return new Jt({privateKey:t,expiryDateSecs:e?.expiryDateSecs})}sign(e){if(this.isExpired())throw new Error("EphemeralKeyPair has expired");return new Ne(this.privateKey.sign(e))}};Jt.BLINDER_LENGTH=31;var Pt=Jt;function _a(){return Ca(Pt.BLINDER_LENGTH)}import ka from"eventemitter3";import{jwtDecode as Fa}from"jwt-decode";function nr(n){return n!=null&&typeof n.checkKeylessAccountValidity=="function"}var Zt=class Zt extends w{constructor(t){super();this.signingScheme=2;let{address:r,ephemeralKeyPair:i,publicKey:o,uidKey:s,uidVal:a,aud:c,pepper:d,proof:l,proofFetchCallback:g,jwt:p,verificationKeyHash:y}=t;if(this.ephemeralKeyPair=i,this.publicKey=o,this.accountAddress=r?u.from(r):this.publicKey.authKey().derivedAddress(),this.uidKey=s,this.uidVal=a,this.aud=c,this.jwt=p,this.emitter=new ka,this.proofOrPromise=l,l instanceof ye)this.proof=l;else{if(g===void 0)throw new Error("Must provide callback for async proof fetch");this.emitter.on("proofFetchFinish",async U=>{await g(U),this.emitter.removeAllListeners()}),this.init(l)}let h=m.fromHexInput(d).toUint8Array();if(h.length!==Zt.PEPPER_LENGTH)throw new Error(`Pepper length in bytes should be ${Zt.PEPPER_LENGTH}`);if(this.pepper=h,y!==void 0){if(m.hexInputToUint8Array(y).length!==32)throw new Error("verificationKeyHash must be 32 bytes");this.verificationKeyHash=m.hexInputToUint8Array(y)}}getAnyPublicKey(){return new x(this.publicKey)}async init(t){try{this.proof=await t,this.emitter.emit("proofFetchFinish",{status:"Success"})}catch(r){r instanceof Error?this.emitter.emit("proofFetchFinish",{status:"Failed",error:r.toString()}):this.emitter.emit("proofFetchFinish",{status:"Failed",error:"Unknown"})}}serialize(t){if(this.accountAddress.serialize(t),t.serializeStr(this.jwt),t.serializeStr(this.uidKey),t.serializeFixedBytes(this.pepper),this.ephemeralKeyPair.serialize(t),this.proof===void 0)throw new Error("Cannot serialize - proof undefined");this.proof.serialize(t),t.serializeOption(this.verificationKeyHash,32)}static partialDeserialize(t){let r=u.deserialize(t),i=t.deserializeStr(),o=t.deserializeStr(),s=t.deserializeFixedBytes(31),a=Pt.deserialize(t),c=ye.deserialize(t),d=t.deserializeOption("fixedBytes",32);return{address:r,jwt:i,uidKey:o,pepper:s,ephemeralKeyPair:a,proof:c,verificationKeyHash:d}}isExpired(){return this.ephemeralKeyPair.isExpired()}signWithAuthenticator(t){let r=new D(this.sign(t)),i=new x(this.publicKey);return new ie(i,r)}signTransactionWithAuthenticator(t){let r=new D(this.signTransaction(t)),i=new x(this.publicKey);return new ie(i,r)}async waitForProofFetch(){this.proofOrPromise instanceof Promise&&await this.proofOrPromise}async checkKeylessAccountValidity(t){if(this.isExpired())throw S.fromErrorType({type:0});if(await this.waitForProofFetch(),this.proof===void 0)throw S.fromErrorType({type:2});let r=Fa(this.jwt,{header:!0});if(r.kid===void 0)throw S.fromErrorType({type:12,details:"checkKeylessAccountValidity failed. JWT is missing 'kid' in header. This should never happen."});if(this.verificationKeyHash!==void 0){let{verificationKey:i}=await Xt({aptosConfig:t});if(m.hexInputToString(i.hash())!==m.hexInputToString(this.verificationKeyHash))throw S.fromErrorType({type:4})}else console.warn("[Aptos SDK] The verification key hash was not set. Proof may be invalid if the verification key has rotated.");await Zt.fetchJWK({aptosConfig:t,publicKey:this.publicKey,kid:r.kid})}sign(t){let{expiryDateSecs:r}=this.ephemeralKeyPair;if(this.isExpired())throw S.fromErrorType({type:0});if(this.proof===void 0)throw S.fromErrorType({type:1,details:"Proof not found - make sure to call `await account.checkKeylessAccountValidity()` before signing."});let i=this.ephemeralKeyPair.getPublicKey(),o=this.ephemeralKeyPair.sign(t);return new re({jwtHeader:Li(this.jwt.split(".")[0]),ephemeralCertificate:new Yt(this.proof,0),expiryDateSecs:r,ephemeralPublicKey:i,ephemeralSignature:o})}signTransaction(t){if(this.proof===void 0)throw S.fromErrorType({type:1,details:"Proof not found - make sure to call `await account.checkKeylessAccountValidity()` before signing."});let r=er(t),o=new tr(r,this.proof.proof).hash();return this.sign(o)}getSigningMessage(t){if(this.proof===void 0)throw S.fromErrorType({type:1,details:"Proof not found - make sure to call `await account.checkKeylessAccountValidity()` before signing."});let r=er(t);return new tr(r,this.proof.proof).hash()}verifySignature(t){return this.publicKey.verifySignature(t)}async verifySignatureAsync(t){return this.publicKey.verifySignatureAsync({...t})}static async fetchJWK(t){return Br(t)}};Zt.PEPPER_LENGTH=31;var me=Zt,tr=class extends w{constructor(t,r){super();this.domainSeparator="APTOS::TransactionAndProof";this.transaction=t,this.proof=r}serialize(t){t.serializeFixedBytes(this.transaction.bcsToBytes()),t.serializeOption(this.proof)}hash(){return Oe(this.bcsToBytes(),this.domainSeparator)}};var be=class n extends me{constructor(e){let t=E.create(e);super({publicKey:t,...e}),this.publicKey=t}serialize(e){super.serialize(e)}static deserialize(e){let{address:t,proof:r,ephemeralKeyPair:i,jwt:o,uidKey:s,pepper:a,verificationKeyHash:c}=me.partialDeserialize(e),{iss:d,aud:l,uidVal:g}=et({jwt:o,uidKey:s});return new n({address:t,proof:r,ephemeralKeyPair:i,iss:d,uidKey:s,uidVal:g,aud:l,pepper:a,jwt:o,verificationKeyHash:c})}static fromBytes(e){return n.deserialize(new k(m.hexInputToUint8Array(e)))}static create(e){let{address:t,proof:r,jwt:i,ephemeralKeyPair:o,pepper:s,uidKey:a="sub",proofFetchCallback:c,verificationKey:d,verificationKeyHash:l}=e;if(l&&d)throw new Error("Cannot provide both verificationKey and verificationKeyHash");let{iss:g,aud:p,uidVal:y}=et({jwt:i,uidKey:a});return new n({address:t,proof:r,ephemeralKeyPair:o,iss:g,uidKey:a,uidVal:y,aud:p,pepper:s,jwt:i,proofFetchCallback:c,verificationKeyHash:l??(d?d.hash():void 0)})}};var ve=class n extends me{constructor(e){let t=G.create(e);super({publicKey:t,...e}),this.publicKey=t,this.audless=e.audless??!1}serialize(e){super.serialize(e),this.publicKey.jwkAddress.serialize(e)}static deserialize(e){let{address:t,proof:r,ephemeralKeyPair:i,jwt:o,uidKey:s,pepper:a,verificationKeyHash:c}=me.partialDeserialize(e),d=u.deserialize(e),{iss:l,aud:g,uidVal:p}=et({jwt:o,uidKey:s});return new n({address:t,proof:r,ephemeralKeyPair:i,iss:l,uidKey:s,uidVal:p,aud:g,pepper:a,jwt:o,verificationKeyHash:c,jwkAddress:d})}static fromBytes(e){return n.deserialize(k.fromHex(e))}static create(e){let{address:t,proof:r,jwt:i,ephemeralKeyPair:o,pepper:s,jwkAddress:a,uidKey:c="sub",proofFetchCallback:d,verificationKey:l,verificationKeyHash:g}=e;if(g&&l)throw new Error("Cannot provide both verificationKey and verificationKeyHash");let{iss:p,aud:y,uidVal:h}=et({jwt:i,uidKey:c});return new n({address:t,proof:r,ephemeralKeyPair:o,iss:p,uidKey:c,uidVal:h,aud:y,pepper:s,jwkAddress:u.from(a),jwt:i,proofFetchCallback:d,verificationKeyHash:g??(l?l.hash():void 0)})}};var tt=class n{constructor(e){this.signingScheme=3;let{multiKey:t,address:r}=e,i=e.signers.map(a=>a instanceof Y?se.fromEd25519Account(a):a);if(t.signaturesRequired>i.length)throw new Error(`Not enough signers provided to satisfy the required signatures. Need ${t.signaturesRequired} signers, but only ${i.length} provided`);if(t.signaturesRequired<i.length)throw new Error(`More signers provided than required. Need ${t.signaturesRequired} signers, but ${i.length} provided`);this.publicKey=t,this.accountAddress=r?u.from(r):this.publicKey.authKey().derivedAddress();let o=[];for(let a of i)o.push(this.publicKey.getIndex(a.getAnyPublicKey()));let s=i.map((a,c)=>[a,o[c]]);s.sort((a,c)=>a[1]-c[1]),this.signers=s.map(a=>a[0]),this.signerIndicies=s.map(a=>a[1]),this.signaturesBitmap=this.publicKey.createBitmap({bits:o})}static fromPublicKeysAndSigners(e){let{address:t,publicKeys:r,signaturesRequired:i,signers:o}=e,s=new B({publicKeys:r,signaturesRequired:i});return new n({multiKey:s,signers:o,address:t})}static isMultiKeySigner(e){return e instanceof n}signWithAuthenticator(e){return new De(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new De(this.publicKey,this.signTransaction(e))}async waitForProofFetch(){let t=this.signers.filter(r=>r instanceof me).map(async r=>r.waitForProofFetch());await Promise.all(t)}async checkKeylessAccountValidity(e){let r=this.signers.filter(i=>i instanceof me).map(i=>i.checkKeylessAccountValidity(e));await Promise.all(r)}sign(e){let t=[];for(let r of this.signers)t.push(r.sign(e));return new Ae({signatures:t,bitmap:this.signaturesBitmap})}signTransaction(e){let t=[];for(let r of this.signers)t.push(r.signTransaction(e));return new Ae({signatures:t,bitmap:this.signaturesBitmap})}verifySignature(e){return this.publicKey.verifySignature(e)}async verifySignatureAsync(e){return await this.publicKey.verifySignatureAsync(e)}};var mn=class{constructor(e){this.signingScheme=1;let{signers:t,publicKey:r,address:i}=e;if(this.publicKey=r,this.accountAddress=i?u.from(i):this.publicKey.authKey().derivedAddress(),r.threshold>t.length)throw new Error(`Not enough signers provided to satisfy the required signatures. Need ${r.threshold} signers, but only ${t.length} provided`);if(r.threshold<t.length)throw new Error(`More signers provided than required. Need ${r.threshold} signers, but ${t.length} provided`);let o=[];for(let a of t)o.push(this.publicKey.getIndex(a.publicKey()));let s=t.map((a,c)=>[a,o[c]]);s.sort((a,c)=>a[1]-c[1]),this.signers=s.map(a=>a[0]),this.signerIndices=s.map(a=>a[1]),this.signaturesBitmap=this.publicKey.createBitmap({bits:o})}verifySignature(e){return this.publicKey.verifySignature(e)}async verifySignatureAsync(e){return this.publicKey.verifySignatureAsync({...e,signature:e.signature})}signWithAuthenticator(e){return new $e(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new $e(this.publicKey,this.signTransaction(e))}sign(e){let t=[];for(let r of this.signers)t.push(r.sign(e));return new Ie({signatures:t,bitmap:this.signaturesBitmap})}signTransaction(e){return this.sign(Ce(e))}};function ko(n){let e=n.deserializeUleb128AsU32();if(!Object.values(j).includes(e))throw new Error(`Deserialization of Account failed: SigningScheme variant ${e} is invalid`);return{address:u.deserialize(n),signingScheme:e}}function Fo(n,e){if(e.serializeStr(n.jwt),e.serializeStr(n.uidKey),e.serializeFixedBytes(n.pepper),n.ephemeralKeyPair.serialize(e),n.proof===void 0)throw new Error("Cannot serialize - proof undefined");n.proof.serialize(e),e.serializeOption(n.verificationKeyHash,32)}function zo(n){let e=n.deserializeStr(),t=n.deserializeStr(),r=n.deserializeFixedBytes(31),i=Pt.deserialize(n),o=ye.deserialize(n),s=n.deserializeOption("fixedBytes",32);return{jwt:e,uidKey:t,pepper:r,ephemeralKeyPair:i,proof:o,verificationKeyHash:s}}var Do;(g=>{function n(p){let y=new ee;switch(y.serializeU32AsUleb128(p.signingScheme),p.accountAddress.serialize(y),p.signingScheme){case 0:return p.privateKey.serialize(y),y.toUint8Array();case 2:{if(!Mr(p))throw new Error("Account is not a SingleKeySigner");let h=p.getAnyPublicKey();switch(y.serializeU32AsUleb128(h.variant),h.variant){case 3:return Fo(p,y),y.toUint8Array();case 4:{let U=p;return Fo(U,y),U.publicKey.jwkAddress.serialize(y),y.serializeBool(U.audless),y.toUint8Array()}case 1:case 0:return p.privateKey.serialize(y),y.toUint8Array();default:throw new Error(`Invalid public key variant: ${h.variant}`)}}case 3:{let h=p;return h.publicKey.serialize(y),y.serializeU32AsUleb128(h.signers.length),h.signers.forEach(U=>{y.serializeFixedBytes(n(U))}),y.toUint8Array()}default:throw new Error(`Deserialization of Account failed: invalid signingScheme value ${p.signingScheme}`)}}g.toBytes=n;function e(p){return m.hexInputToStringWithoutPrefix(n(p))}g.toHexStringWithoutPrefix=e;function t(p){return m.hexInputToString(n(p))}g.toHexString=t;function r(p){let{address:y,signingScheme:h}=ko(p);switch(h){case 0:{let U=L.deserialize(p);return new Y({privateKey:U,address:y})}case 2:{let U=p.deserializeUleb128AsU32();switch(U){case 0:{let M=L.deserialize(p);return new se({privateKey:M,address:y})}case 1:{let M=He.deserialize(p);return new se({privateKey:M,address:y})}case 3:{let M=zo(p),X=et(M);return new be({...M,...X})}case 4:{let M=zo(p),X=u.deserialize(p),Me=p.deserializeBool(),ot=et(M);return new ve({...M,...ot,jwkAddress:X,audless:Me})}default:throw new Error(`Unsupported public key variant ${U}`)}}case 3:{let U=B.deserialize(p),M=p.deserializeUleb128AsU32(),X=new Array;for(let Me=0;Me<M;Me+=1){let ot=r(p);if(!Mr(ot)&&!(ot instanceof Y))throw new Error("Deserialization of MultiKeyAccount failed. Signer is not a SingleKeySigner or Ed25519Account");X.push(ot)}return new tt({multiKey:U,signers:X,address:y})}default:throw new Error(`Deserialization of Account failed: invalid signingScheme value ${h}`)}}g.deserialize=r;function i(p){let y=d(p);if(!(y instanceof be))throw new Error("Deserialization of KeylessAccount failed");return y}g.keylessAccountFromHex=i;function o(p){let y=d(p);if(!(y instanceof ve))throw new Error("Deserialization of FederatedKeylessAccount failed");return y}g.federatedKeylessAccountFromHex=o;function s(p){let y=d(p);if(!(y instanceof tt))throw new Error("Deserialization of MultiKeyAccount failed");return y}g.multiKeyAccountFromHex=s;function a(p){let y=d(p);if(!(y instanceof se))throw new Error("Deserialization of SingleKeyAccount failed");return y}g.singleKeyAccountFromHex=a;function c(p){let y=d(p);if(!(y instanceof Y))throw new Error("Deserialization of Ed25519Account failed");return y}g.ed25519AccountFromHex=c;function d(p){return r(k.fromHex(p))}g.fromHex=d;function l(p){return d(p)}g.fromBytes=l})(Do||(Do={}));import{sha3_256 as Ro}from"@noble/hashes/sha3";var rr=class n extends Xe{constructor({signer:t,accountAddress:r,authenticationFunction:i}){super();this.signingScheme=2;if(!Dt(i))throw new Error(`Invalid authentication function ${i} passed into AbstractedAccount`);this.authenticationFunction=i,this.accountAddress=r,this.publicKey=new Ci(this.accountAddress),this.sign=o=>new Ir(t(o))}static fromPermissionedSigner({signer:t,accountAddress:r}){return new n({signer:i=>{let o=new ee;return t.publicKey.serialize(o),t.sign(i).serialize(o),o.toUint8Array()},accountAddress:r??t.accountAddress,authenticationFunction:"0x1::permissioned_delegation::authenticate"})}static generateAccountAbstractionMessage(t,r){let i=new Wn(t,r);return Oe(i.bcsToBytes(),Gi)}signWithAuthenticator(t){return new yt(this.authenticationFunction,Ro(t),this.sign(Ro(t)).toUint8Array())}signTransactionWithAuthenticator(t){let r=n.generateAccountAbstractionMessage(Ce(t),this.authenticationFunction);return this.signWithAuthenticator(r)}signTransaction(t){return this.sign(Ce(t))}setSigner(t){this.sign=r=>new Ir(t(r))}};import{sha3_256 as Vr}from"@noble/hashes/sha3";var fn=class fn extends rr{constructor({signer:e,authenticationFunction:t,abstractPublicKey:r}){let i=new u(fn.computeAccountAddress(t,r));super({accountAddress:i,signer:e,authenticationFunction:t}),this.abstractPublicKey=r}static computeAccountAddress(e,t){if(!Dt(e))throw new Error(`Invalid authentication function ${e} passed into DerivableAbstractedAccount`);let[r,i,o]=e.split("::"),s=Vr.create(),a=new ee;u.fromString(r).serialize(a),a.serializeStr(i),a.serializeStr(o),s.update(a.toUint8Array());let c=new ee;return c.serializeBytes(t),s.update(c.toUint8Array()),s.update(new Uint8Array([fn.ADDRESS_DOMAIN_SEPERATOR])),s.digest()}signWithAuthenticator(e){return new yt(this.authenticationFunction,Vr(e),this.sign(Vr(e)).value,this.abstractPublicKey)}};fn.ADDRESS_DOMAIN_SEPERATOR=5;var Oo=fn;import{sha3_256 as La}from"@noble/hashes/sha3";function No(n){return!!n.match(/^[_a-zA-Z0-9]+$/)}function Go(n){return!!n.match(/\s/)}function za(n){return!!n.match(/^T[0-9]+$/)}function Da(n){return!!n.match(/^&.+$/)}function Ra(n){switch(n){case"signer":case"address":case"bool":case"u8":case"u16":case"u32":case"u64":case"u128":case"u256":return!0;default:return!1}}function Oa(n,e){let t=e;for(;t<n.length;t+=1){let r=n[t];if(!Go(r))break}return t}var Na=(h=>(h.InvalidTypeTag="unknown type",h.UnexpectedGenericType="unexpected generic type",h.UnexpectedTypeArgumentClose="unexpected '>'",h.UnexpectedWhitespaceCharacter="unexpected whitespace character",h.UnexpectedComma="unexpected ','",h.TypeArgumentCountMismatch="type argument count doesn't match expected amount",h.MissingTypeArgumentClose="no matching '>' for '<'",h.MissingTypeArgument="no type argument before ','",h.UnexpectedPrimitiveTypeArguments="primitive types not expected to have type arguments",h.UnexpectedVectorTypeArgumentCount="vector type expected to have exactly one type argument",h.UnexpectedStructFormat="unexpected struct format, must be of the form 0xaddress::module_name::struct_name",h.InvalidModuleNameCharacter="module name must only contain alphanumeric or '_' characters",h.InvalidStructNameCharacter="struct name must only contain alphanumeric or '_' characters",h.InvalidAddress="struct address must be valid",h))(Na||{}),$=class extends Error{constructor(e,t){super(`Failed to parse typeTag '${e}', ${t}`)}};function _e(n,e){let t=e?.allowGenerics??!1,r=[],i=[],o=[],s=0,a="",c=1;for(;s<n.length;){let d=n[s];if(d==="<")r.push({savedExpectedTypes:c,savedStr:a,savedTypes:o}),a="",o=[],c=1;else if(d===">"){if(a!==""){let h=An(a,i,t);o.push(h)}let l=r.pop();if(l===void 0)throw new $(n,"unexpected '>'");if(c!==o.length)throw new $(n,"type argument count doesn't match expected amount");let{savedStr:g,savedTypes:p,savedExpectedTypes:y}=l;i=o,o=p,a=g,c=y}else if(d===","){if(r.length===0)throw new $(n,"unexpected ','");if(a.length===0)throw new $(n,"no type argument before ','");let l=An(a,i,t);i=[],o.push(l),a="",c+=1}else if(Go(d)){let l=!1;if(a.length!==0){let p=An(a,i,t);i=[],o.push(p),a="",l=!0}s=Oa(n,s);let g=n[s];if(s<n.length&&l&&g!==","&&g!==">")throw new $(n,"unexpected whitespace character");continue}else a+=d;s+=1}if(r.length>0)throw new $(n,"no matching '>' for '<'");switch(o.length){case 0:return An(a,i,t);case 1:if(a==="")return o[0];throw new $(n,"unexpected ','");default:throw new $(n,"unexpected whitespace character")}}function An(n,e,t){let r=n.trim(),i=r.toLowerCase();if(Ra(i)&&e.length>0)throw new $(n,"primitive types not expected to have type arguments");switch(r.toLowerCase()){case"signer":return new mt;case"bool":return new V;case"address":return new R;case"u8":return new oe;case"u16":return new qe;case"u32":return new We;case"u64":return new W;case"u128":return new je;case"u256":return new Qe;case"vector":if(e.length!==1)throw new $(n,"vector type expected to have exactly one type argument");return new v(e[0]);default:if(Da(r)){let a=r.substring(1);return new jn(An(a,e,t))}if(za(r)){if(t)return new N(Number(r.split("T")[1]));throw new $(n,"unexpected generic type")}if(!r.match(/:/))throw new $(n,"unknown type");let o=r.split("::");if(o.length!==3)throw new $(n,"unexpected struct format, must be of the form 0xaddress::module_name::struct_name");let s;try{s=u.fromString(o[0])}catch{throw new $(n,"struct address must be valid")}if(!No(o[1]))throw new $(n,"module name must only contain alphanumeric or '_' characters");if(!No(o[2]))throw new $(n,"struct name must only contain alphanumeric or '_' characters");return new f(new Re(s,new z(o[1]),new z(o[2]),e))}}function Mo(n){return typeof n=="boolean"}function nt(n){return typeof n=="string"}function Ga(n){return typeof n=="number"}function ir(n){if(Ga(n))return n;if(nt(n)&&n!=="")return Number.parseInt(n,10)}function or(n){return typeof n=="number"||typeof n=="bigint"||typeof n=="string"}function Bo(n){return n==null}function Vo(n){return Hr(n)||$r(n)||qr(n)||Wr(n)||jr(n)||Qr(n)||Jr(n)||sr(n)||Lr(n)||Ma(n)||n instanceof K||n instanceof te}function Hr(n){return n instanceof H}function sr(n){return n instanceof u}function Lr(n){return n instanceof F}function Ma(n){return n instanceof Et}function $r(n){return n instanceof Se}function qr(n){return n instanceof Ct}function Wr(n){return n instanceof vt}function jr(n){return n instanceof fe}function Qr(n){return n instanceof _t}function Jr(n){return n instanceof Ut}function Ho(n){return"bytecode"in n}function _(n,e){throw new Error(`Type mismatch for argument ${e}, expected '${n}'`)}function Lo(n){let e=n.params.findIndex(t=>t!=="signer"&&t!=="&signer");return e<0?n.params.length:e}var Ba=new TextEncoder;function ar(n){return n?.map(e=>nt(e)?_e(e):e)??[]}async function Va(n,e,t){return(await cr({aptosConfig:t,accountAddress:n,moduleName:e})).abi}async function Yr(n,e,t,r){let i=await Va(n,e,r);if(!i)throw new Error(`Could not find module ABI for '${n}::${e}'`);return i.exposed_functions.find(o=>o.name===t)}async function hm(n,e,t,r){let i=await Yr(n,e,t,r);if(!i)throw new Error(`Could not find function ABI for '${n}::${e}::${t}'`);let o=[];for(let s=0;s<i.params.length;s+=1)o.push(_e(i.params[s],{allowGenerics:!0}));return{typeParameters:i.generic_type_params,parameters:o}}async function $o(n,e,t,r){let i=await Yr(n,e,t,r);if(!i)throw new Error(`Could not find entry function ABI for '${n}::${e}::${t}'`);if(!i.is_entry)throw new Error(`'${n}::${e}::${t}' is not an entry function`);let o=Lo(i),s=[];for(let a=o;a<i.params.length;a+=1)s.push(_e(i.params[a],{allowGenerics:!0}));return{signers:o,typeParameters:i.generic_type_params,parameters:s}}async function qo(n,e,t,r){let i=await Yr(n,e,t,r);if(!i)throw new Error(`Could not find view function ABI for '${n}::${e}::${t}'`);if(!i.is_view)throw new Error(`'${n}::${e}::${t}' is not an view function`);let o=[];for(let a=0;a<i.params.length;a+=1)o.push(_e(i.params[a],{allowGenerics:!0}));let s=[];for(let a=0;a<i.return.length;a+=1)s.push(_e(i.return[a],{allowGenerics:!0}));return{typeParameters:i.generic_type_params,parameters:o,returnTypes:s}}function Xr(n,e,t,r,i,o){let s;if("exposed_functions"in e){let a=e.exposed_functions.find(c=>c.name===n);if(!a)throw new Error(`Could not find function ABI for '${e.address}::${e.name}::${n}'`);if(r>=a.params.length)throw new Error(`Too many arguments for '${n}', expected ${a.params.length}`);s=_e(a.params[r],{allowGenerics:!0})}else{if(r>=e.parameters.length)throw new Error(`Too many arguments for '${n}', expected ${e.parameters.length}`);s=e.parameters[r]}return Kt(t,s,r,i,"exposed_functions"in e?e:void 0,o)}function Kt(n,e,t,r,i,o){return Vo(n)?(Zr(e,n,t),n):Ha(n,e,t,r,i,o)}function Ha(n,e,t,r,i,o){if(e.isBool()){if(Mo(n))return new H(n);if(nt(n)){if(n==="true")return new H(!0);if(n==="false")return new H(!1)}_("boolean",t)}if(e.isAddress()){if(nt(n))return u.fromString(n);if(n&&typeof n=="object"&&"data"in n&&n.data instanceof Uint8Array)return new u(n.data);_("string | AccountAddress",t)}if(e.isU8()){let s=ir(n);if(s!==void 0)return new Se(s);_("number | string",t)}if(e.isU16()){let s=ir(n);if(s!==void 0)return new Ct(s);_("number | string",t)}if(e.isU32()){let s=ir(n);if(s!==void 0)return new vt(s);_("number | string",t)}if(e.isU64()){if(or(n))return new fe(BigInt(n));_("bigint | number | string",t)}if(e.isU128()){if(or(n))return new _t(BigInt(n));_("bigint | number | string",t)}if(e.isU256()){if(or(n))return new Ut(BigInt(n));_("bigint | number | string",t)}if(e.isGeneric()){let s=e.value;if(s<0||s>=r.length)throw new Error(`Generic argument ${e.toString()} is invalid for argument ${t}`);return Kt(n,r[s],t,r,i)}if(e.isVector()){if(e.value.isU8()){if(nt(n))return K.U8(Ba.encode(n));if(n instanceof Uint8Array)return K.U8(n);if(n instanceof ArrayBuffer)return K.U8(new Uint8Array(n))}if(nt(n)&&n.startsWith("["))return Kt(JSON.parse(n),e,t,r);if(Array.isArray(n))return new K(n.map(s=>Kt(s,e.value,t,r,i)));throw new Error(`Type mismatch for argument ${t}, type '${e.toString()}'`)}if(e.isStruct()){if(e.isString()){if(nt(n))return new F(n);_("string",t)}if(e.isObject()){if(nt(n))return u.fromString(n);if(n&&typeof n=="object"&&"data"in n&&n.data instanceof Uint8Array)return new u(n.data);_("string | AccountAddress",t)}if(e.isDelegationKey()||e.isRateLimiter()){if(n instanceof Uint8Array)return new Et(n);_("Uint8Array",t)}if(e.isOption()){if(Bo(n)){let a=e.value.typeArgs[0];return a instanceof V?new te(null):a instanceof R?new te(null):a instanceof oe?new te(null):a instanceof qe?new te(null):a instanceof We?new te(null):a instanceof W?new te(null):a instanceof je?new te(null):a instanceof Qe?new te(null):new te(null)}return new te(Kt(n,e.value.typeArgs[0],t,r,i))}if(i?.structs.find(a=>a.name===e.value.name.identifier)?.fields.length===0&&n instanceof Uint8Array)return new Et(n);if(n instanceof Uint8Array&&o?.allowUnknownStructs)return console.warn(`Unsupported struct input type for argument ${t}. Continuing since 'allowUnknownStructs' is enabled.`),new Et(n);throw new Error(`Unsupported struct input type for argument ${t}, type '${e.toString()}'`)}throw new Error(`Type mismatch for argument ${t}, type '${e.toString()}'`)}function Zr(n,e,t){if(n.isBool()){if(Hr(e))return;_("Bool",t)}if(n.isAddress()){if(sr(e))return;_("AccountAddress",t)}if(n.isU8()){if($r(e))return;_("U8",t)}if(n.isU16()){if(qr(e))return;_("U16",t)}if(n.isU32()){if(Wr(e))return;_("U32",t)}if(n.isU64()){if(jr(e))return;_("U64",t)}if(n.isU128()){if(Qr(e))return;_("U128",t)}if(n.isU256()){if(Jr(e))return;_("U256",t)}if(n.isVector()){if(e instanceof K){e.values.length>0&&Zr(n.value,e.values[0],t);return}_("MoveVector",t)}if(n instanceof f){if(n.isString()){if(Lr(e))return;_("MoveString",t)}if(n.isObject()){if(sr(e))return;_("AccountAddress",t)}if(n.isOption()){if(e instanceof te){e.value!==void 0&&Zr(n.value.typeArgs[0],e.value,t);return}_("MoveOption",t)}}throw new Error(`Type mismatch for argument ${t}, expected '${n.toString()}'`)}async function ur(n){if(Ho(n))return Wa(n);let{moduleAddress:e,moduleName:t,functionName:r}=ue(n.function),i=await Jo({key:"entry-function",moduleAddress:e,moduleName:t,functionName:r,aptosConfig:n.aptosConfig,abi:n.abi,fetch:$o});return $a({...n,abi:i})}function $a(n){let e=n.abi,{moduleAddress:t,moduleName:r,functionName:i}=ue(n.function),o=ar(n.typeArguments);if(o.length!==e.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${e.typeParameters.length}, received ${o.length}`);let s=n.functionArguments.map((c,d)=>Xr(n.function,e,c,d,o));if(s.length!==e.parameters.length)throw new Error(`Too few arguments for '${t}::${r}::${i}', expected ${e.parameters.length} but got ${s.length}`);let a=Je.build(`${t}::${r}`,i,o,s);if("multisigAddress"in n){let c=u.from(n.multisigAddress);return new $t(new pn(c,new ln(a)))}return new Lt(a)}async function Wo(n){let{moduleAddress:e,moduleName:t,functionName:r}=ue(n.function),i=await Jo({key:"view-function",moduleAddress:e,moduleName:t,functionName:r,aptosConfig:n.aptosConfig,abi:n.abi,fetch:qo});return qa({abi:i,...n})}function qa(n){let e=n.abi,{moduleAddress:t,moduleName:r,functionName:i}=ue(n.function),o=ar(n.typeArguments);if(o.length!==e.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${e.typeParameters.length}, received ${o.length}`);let s=n?.functionArguments?.map((a,c)=>Xr(n.function,e,a,c,o))??[];if(s.length!==e.parameters.length)throw new Error(`Too few arguments for '${t}::${r}::${i}', expected ${e.parameters.length} but got ${s.length}`);return Je.build(`${t}::${r}`,i,o,s)}function Wa(n){return new Ht(new qt(m.fromHexInput(n.bytecode).toUint8Array(),ar(n.typeArguments),n.functionArguments))}async function ja(n){let{aptosConfig:e,sender:t,payload:r,options:i,feePayerAddress:o}=n;if(i?.replayProtectionNonce!==void 0&&i?.accountSequenceNumber!==void 0)throw new Error("Cannot specify both replayProtectionNonce and accountSequenceNumber in options.");let s=async()=>Cr[e.network]?{chainId:Cr[e.network]}:{chainId:(await Mn({aptosConfig:e})).chain_id},a=async()=>i?.gasUnitPrice?{gasEstimate:i.gasUnitPrice}:{gasEstimate:(await Vn({aptosConfig:e})).gas_estimate},c=async()=>{let X=async()=>i?.accountSequenceNumber!==void 0?i.accountSequenceNumber:i?.replayProtectionNonce!==void 0?0xdeadbeefn:(await Bn({aptosConfig:e,accountAddress:t})).sequence_number;if(o&&u.from(o).equals(u.ZERO))try{return await X()}catch{return 0}else return X()},[{chainId:d},{gasEstimate:l},g]=await Promise.all([s(),a(),c()]),{maxGasAmount:p,gasUnitPrice:y,expireTimestamp:h,replayProtectionNonce:U}={maxGasAmount:i?.maxGasAmount?BigInt(i.maxGasAmount):BigInt(e.getDefaultMaxGasAmount()),gasUnitPrice:i?.gasUnitPrice??BigInt(l),expireTimestamp:i?.expireTimestamp??BigInt(Math.floor(Date.now()/1e3)+e.getDefaultTxnExpirySecFromNow()),replayProtectionNonce:i?.replayProtectionNonce?BigInt(i.replayProtectionNonce):void 0},M=r;return U!==void 0&&(M=Qa(r,U)),new he(u.from(t),BigInt(g),M,BigInt(p),BigInt(y),BigInt(h),new Nn(d))}function Qa(n,e){if(n instanceof Ht)return new ft(new gn(n.script),new At(void 0,e));if(n instanceof Lt)return new ft(new jt(n.entryFunction),new At(void 0,e));if(n instanceof $t){let t=n.multiSig.transaction_payload,r;if(t===void 0||t?.transaction_payload===void 0)r=new yn;else if(t.transaction_payload instanceof Je)r=new jt(t.transaction_payload);else throw new Error("Scripts are not supported in multi-sig transactions.");return new ft(r,new At(n.multiSig.multisig_address,e))}else throw new Error(`Unsupported payload type: ${n}`)}async function ei(n){let{aptosConfig:e,sender:t,payload:r,options:i,feePayerAddress:o}=n,s=await ja({aptosConfig:e,sender:t,payload:r,options:i,feePayerAddress:o});if("secondarySignerAddresses"in n){let a=n.secondarySignerAddresses?.map(c=>u.from(c))??[];return new Xn(s,a,n.feePayerAddress?u.from(n.feePayerAddress):void 0)}return new Yn(s,n.feePayerAddress?u.from(n.feePayerAddress):void 0)}function jo(n){let{signerPublicKey:e,transaction:t,secondarySignersPublicKeys:r,feePayerPublicKey:i}=n,o=en(e);if(t.feePayerAddress){let a=new bt(t.rawTransaction,t.secondarySignerAddresses??[],t.feePayerAddress),c=[];t.secondarySignerAddresses&&(r?c=r.map(g=>en(g)):c=Array.from({length:t.secondarySignerAddresses.length},()=>en(void 0)));let d=en(i),l=new St(o,t.secondarySignerAddresses??[],c,{address:t.feePayerAddress,authenticator:d});return new Ye(a.raw_txn,l).bcsToBytes()}if(t.secondarySignerAddresses){let a=new ht(t.rawTransaction,t.secondarySignerAddresses),c=[];r?c=r.map(l=>en(l)):c=Array.from({length:t.secondarySignerAddresses.length},()=>en(void 0));let d=new Tt(o,t.secondarySignerAddresses,c);return new Ye(a.raw_txn,d).bcsToBytes()}let s;if(o instanceof Ee)s=new wt(o.public_key,o.signature);else if(o instanceof ie||o instanceof De)s=new ct(o);else if(o instanceof Vt)s=new ct(o);else throw new Error("Invalid public key");return new Ye(t.rawTransaction,s).bcsToBytes()}function en(n){if(!n)return new Vt;let t=E.isInstance(n)||G.isInstance(n)||Ke.isInstance(n)?new x(n):n,r=new C(new Uint8Array(64));if(b.isInstance(t))return new Ee(t,r);if(x.isInstance(t))return E.isInstance(t.publicKey)?new ie(t,new D(re.getSimulationSignature())):new ie(t,new D(r));if(B.isInstance(t))return new De(t,new Ae({signatures:t.publicKeys.map(i=>E.isInstance(i.publicKey)||G.isInstance(i.publicKey)?new D(re.getSimulationSignature()):new D(r)),bitmap:t.createBitmap({bits:Array(t.publicKeys.length).fill(0).map((i,o)=>o)})}));throw new Error("Unsupported PublicKey used for simulations")}function ti(n){let{transaction:e,feePayerAuthenticator:t,additionalSignersAuthenticators:r}=n,i=Bi(q,n.senderAuthenticator),o;if(e.feePayerAddress){if(!t)throw new Error("Must provide a feePayerAuthenticator argument to generate a signed fee payer transaction");o=new St(i,e.secondarySignerAddresses??[],r??[],{address:e.feePayerAddress,authenticator:t})}else if(e.secondarySignerAddresses){if(!r)throw new Error("Must provide a additionalSignersAuthenticators argument to generate a signed multi agent transaction");o=new Tt(i,e.secondarySignerAddresses,r)}else i instanceof Ee?o=new wt(i.public_key,i.signature):i instanceof $e?o=new Qt(i.public_key,i.signature):o=new ct(i);return new Ye(e.rawTransaction,o).bcsToBytes()}function Qo(n){let e=La.create();for(let t of n)e.update(t);return e.digest()}var Ja=Qo(["APTOS::Transaction"]);function $m(n){let e=ti(n);return new m(Qo([Ja,new Uint8Array([0]),e])).toString()}async function Jo({key:n,moduleAddress:e,moduleName:t,functionName:r,aptosConfig:i,abi:o,fetch:s}){return o!==void 0?o:Ot(async()=>s(e,t,r,i),`${n}-${i.network}-${e}-${t}-${r}`,1e3*60*5)()}async function A(n){let e=await Ya(n);return Xa(n,e)}async function Ya(n){let{aptosConfig:e,data:t}=n,r,i;return"bytecode"in t?i=await ur(t):"multisigAddress"in t?(r={aptosConfig:e,multisigAddress:t.multisigAddress,function:t.function,functionArguments:t.functionArguments,typeArguments:t.typeArguments,abi:t.abi},i=await ur(r)):(r={aptosConfig:e,function:t.function,functionArguments:t.functionArguments,typeArguments:t.typeArguments,abi:t.abi},i=await ur(r)),i}async function Xa(n,e){let{aptosConfig:t,sender:r,options:i}=n,o;if(ec(n)&&(o=u.ZERO.toString()),tc(n)){let{secondarySignerAddresses:s}=n;return ei({aptosConfig:t,sender:r,payload:e,options:i,secondarySignerAddresses:s,feePayerAddress:o})}return ei({aptosConfig:t,sender:r,payload:e,options:i,feePayerAddress:o})}function ec(n){return n.withFeePayer===!0}function tc(n){return"secondarySignerAddresses"in n}function Zo(n){let{transaction:e}=n;return Ce(e)}function dr(n){let{signer:e,transaction:t}=n;return e.signTransactionWithAuthenticator(t)}function pr(n){let{signer:e,transaction:t}=n;if(!t.feePayerAddress)throw new Error(`Transaction ${t} is not a Fee Payer transaction`);return t.feePayerAddress=e.accountAddress,dr({signer:e,transaction:t})}async function ni(n){let{aptosConfig:e,transaction:t,signerPublicKey:r,secondarySignersPublicKeys:i,feePayerPublicKey:o,options:s}=n,a=jo({transaction:t,signerPublicKey:r,secondarySignersPublicKeys:i,feePayerPublicKey:o,options:s}),{data:c}=await Rt({aptosConfig:e,body:a,path:"transactions/simulate",params:{estimate_gas_unit_price:n.options?.estimateGasUnitPrice??!1,estimate_max_gas_amount:n.options?.estimateMaxGasAmount??!1,estimate_prioritized_gas_unit_price:n.options?.estimatePrioritizedGasUnitPrice??!1},originMethod:"simulateTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return c}async function hn(n){let{aptosConfig:e,transactionSubmitter:t}=n,r=t===void 0?e.getTransactionSubmitter():t;if(r)return r.submitTransaction(n);let i=ti({...n});try{let{data:o}=await Rt({aptosConfig:e,body:i,path:"transactions",originMethod:"submitTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return o}catch(o){let s=Ye.deserialize(new k(i));throw s.authenticator.isSingleSender()&&s.authenticator.sender.isSingleKey()&&(s.authenticator.sender.public_key.publicKey instanceof E||s.authenticator.sender.public_key.publicKey instanceof G)&&await me.fetchJWK({aptosConfig:e,publicKey:s.authenticator.sender.public_key.publicKey,kid:s.authenticator.sender.signature.signature.getJwkKid()}),o}}async function lr(n){let{aptosConfig:e,signer:t,feePayer:r,transaction:i,...o}=n;nr(t)&&await t.checkKeylessAccountValidity(e),nr(r)&&await r.checkKeylessAccountValidity(e);let s=n.feePayerAuthenticator||r&&pr({signer:r,transaction:i}),a=dr({signer:t,transaction:i});return hn({aptosConfig:e,transaction:i,senderAuthenticator:a,feePayerAuthenticator:s,...o})}async function Yo(n){let{aptosConfig:e,senderAuthenticator:t,feePayer:r,transaction:i,...o}=n;nr(r)&&await r.checkKeylessAccountValidity(e);let s=pr({signer:r,transaction:i});return hn({aptosConfig:e,transaction:i,senderAuthenticator:t,feePayerAuthenticator:s,...o})}var nc={typeParameters:[],parameters:[v.u8(),new v(v.u8())]};async function Xo(n){let{aptosConfig:e,account:t,metadataBytes:r,moduleBytecode:i,options:o}=n,s=i.map(a=>K.U8(a));return A({aptosConfig:e,sender:u.from(t),data:{function:"0x1::code::publish_package_txn",functionArguments:[K.U8(r),new K(s)],abi:nc},options:o})}async function tn(n){return Bn(n)}async function ts(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return _r({aptosConfig:e,originMethod:"getModules",path:`accounts/${u.from(t).toString()}/modules`,params:{ledger_version:r?.ledgerVersion,limit:r?.limit??1e3}})}async function ns(n){let{aptosConfig:e,accountAddress:t,options:r}=n,{response:i,cursor:o}=await Ur({aptosConfig:e,originMethod:"getModulesPage",path:`accounts/${u.from(t).toString()}/modules`,params:{ledger_version:r?.ledgerVersion,cursor:r?.cursor,limit:r?.limit??100}});return{modules:i.data,cursor:o}}async function cr(n){return wo(n)}async function oi(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return Qi({aptosConfig:e,originMethod:"getTransactions",path:`accounts/${u.from(t).toString()}/transactions`,params:{start:r?.offset,limit:r?.limit}})}async function si(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return _r({aptosConfig:e,originMethod:"getResources",path:`accounts/${u.from(t).toString()}/resources`,params:{ledger_version:r?.ledgerVersion,limit:r?.limit??999}})}async function rs(n){let{aptosConfig:e,accountAddress:t,options:r}=n,{response:i,cursor:o}=await Ur({aptosConfig:e,originMethod:"getResourcesPage",path:`accounts/${u.from(t).toString()}/resources`,params:{ledger_version:r?.ledgerVersion,cursor:r?.cursor,limit:r?.limit??100}});return{resources:i.data,cursor:o}}async function ai(n){let{aptosConfig:e,accountAddress:t,resourceType:r,options:i}=n,{data:o}=await st({aptosConfig:e,originMethod:"getResource",path:`accounts/${u.from(t).toString()}/resource/${r}`,params:{ledger_version:i?.ledgerVersion}});return o.data}async function nn(n){let{aptosConfig:e,authenticationKey:t,options:r}=n,i=await ai({aptosConfig:e,accountAddress:"0x1",resourceType:"0x1::account::OriginatingAddress",options:r}),{address_map:{handle:o}}=i,s=u.from(t);try{let a=await To({aptosConfig:e,handle:o,data:{key:s.toString(),key_type:"address",value_type:"address"},options:r});return u.from(a)}catch(a){if(a instanceof ji&&a.data.error_code==="table_item_not_found")return s;throw a}}async function is(n){let{aptosConfig:e,accountAddress:t}=n,i={owner_address:{_eq:u.from(t).toStringLong()},amount:{_gt:0}},s=await P({aptosConfig:e,query:{query:so,variables:{where_condition:i}},originMethod:"getAccountTokensCount"});return s.current_token_ownerships_v2_aggregate.aggregate?s.current_token_ownerships_v2_aggregate.aggregate.count:0}async function os(n){let{aptosConfig:e,accountAddress:t,options:r}=n,o={owner_address:{_eq:u.from(t).toStringLong()},amount:{_gt:0}};r?.tokenStandard&&(o.token_standard={_eq:r?.tokenStandard});let s={query:io,variables:{where_condition:o,offset:r?.offset,limit:r?.limit,order_by:r?.orderBy}};return(await P({aptosConfig:e,query:s,originMethod:"getAccountOwnedTokens"})).current_token_ownerships_v2}async function ss(n){let{aptosConfig:e,accountAddress:t,collectionAddress:r,options:i}=n,o=u.from(t).toStringLong(),s=u.from(r).toStringLong(),a={owner_address:{_eq:o},current_token_data:{collection_id:{_eq:s}},amount:{_gt:0}};i?.tokenStandard&&(a.token_standard={_eq:i?.tokenStandard});let c={query:oo,variables:{where_condition:a,offset:i?.offset,limit:i?.limit,order_by:i?.orderBy}};return(await P({aptosConfig:e,query:c,originMethod:"getAccountOwnedTokensFromCollectionAddress"})).current_token_ownerships_v2}async function as(n){let{aptosConfig:e,accountAddress:t,options:r}=n,o={owner_address:{_eq:u.from(t).toStringLong()}};r?.tokenStandard&&(o.current_collection={token_standard:{_eq:r?.tokenStandard}});let s={query:ro,variables:{where_condition:o,offset:r?.offset,limit:r?.limit,order_by:r?.orderBy}};return(await P({aptosConfig:e,query:s,originMethod:"getAccountCollectionsWithOwnedTokens"})).current_collection_ownership_v2_view}async function cs(n){let{aptosConfig:e,accountAddress:t}=n,r=u.from(t).toStringLong(),o=await P({aptosConfig:e,query:{query:ao,variables:{address:r}},originMethod:"getAccountTransactionsCount"});return o.account_transactions_aggregate.aggregate?o.account_transactions_aggregate.aggregate.count:0}async function gA(n){let{aptosConfig:e,accountAddress:t,coinType:r,faMetadataAddress:i}=n,o=r,s;if(r!==void 0&&i!==void 0)s=u.from(i).toStringLong();else if(r!==void 0&&i===void 0)r===Be?s=u.A.toStringLong():s=On(u.A,r).toStringLong();else if(r===void 0&&i!==void 0){let l=u.from(i);s=l.toStringLong(),l===u.A&&(o=Be)}else throw new Error("Either coinType, fungibleAssetAddress, or both must be provided");let a=u.from(t).toStringLong(),c={asset_type:{_eq:s}};o!==void 0&&(c={asset_type:{_in:[o,s]}});let d=await ci({aptosConfig:e,accountAddress:a,options:{where:c}});return d[0]?d[0].amount:0}async function ci(n){let{aptosConfig:e,accountAddress:t,options:r}=n,i=u.from(t).toStringLong(),o={...r?.where,owner_address:{_eq:i}},s={query:no,variables:{where_condition:o,offset:r?.offset,limit:r?.limit,order_by:r?.orderBy}};return(await P({aptosConfig:e,query:s,originMethod:"getAccountCoinsData"})).current_fungible_asset_balances}async function us(n){let{aptosConfig:e,accountAddress:t}=n,r=u.from(t).toStringLong(),o=await P({aptosConfig:e,query:{query:to,variables:{address:r}},originMethod:"getAccountCoinsCount"});if(!o.current_fungible_asset_balances_aggregate.aggregate)throw Error("Failed to get the count of account coins");return o.current_fungible_asset_balances_aggregate.aggregate.count}async function ds(n){let{aptosConfig:e,accountAddress:t,asset:r}=n,i=await st({aptosConfig:e,originMethod:"getBalance",path:`accounts/${t}/balance/${r}`,params:{accountAddress:t.toString(),asset:r instanceof Uint8Array?u.from(r).toString():r.toString()}});return parseInt(i.data.toString(),10)}async function ui(n){let{aptosConfig:e,accountAddress:t,options:r}=n,o={owner_address:{_eq:u.from(t).toStringLong()}},s={query:Gn,variables:{where_condition:o,offset:r?.offset,limit:r?.limit,order_by:r?.orderBy}};return(await P({aptosConfig:e,query:s,originMethod:"getAccountOwnedObjects"})).current_objects}async function ps(n){let{aptosConfig:e,privateKey:t,options:r}=n,i=r?.throwIfNoAccountFound??!1,o=await gr({aptosConfig:e,privateKey:t});if(o.length===0){if(i)throw new Error("No existing account found for private key.");return Xe.fromPrivateKey({privateKey:t})}return o[0]}async function yA(n){let{aptosConfig:e,authKey:t}=n,r=await nn({aptosConfig:e,authenticationKey:t.derivedAddress()});return ls({aptosConfig:e,accountAddress:r})}async function ls(n){let{aptosConfig:e,accountAddress:t,options:r}=n;try{let[i,o]=await Promise.all([si({aptosConfig:e,accountAddress:t}),ui({aptosConfig:e,accountAddress:t,options:{limit:1}})]),s=i.find(c=>c.type==="0x1::account::Account");if(!s&&o.length===0)return!1;if(!r?.withAuthKey)return!0;let a;return s?a=s.data.authentication_key:a=t.toStringLong(),a===r.withAuthKey.toString()}catch(i){throw new Error(`Error while checking if account exists at ${t.toString()}: ${i}`)}}var rc={typeParameters:[],parameters:[new oe,v.u8(),new oe,v.u8(),v.u8(),v.u8()]};async function gs(n){let{aptosConfig:e,fromAccount:t,options:r}=n;if("toNewPrivateKey"in n)return ri({aptosConfig:e,fromAccount:t,toNewPrivateKey:n.toNewPrivateKey,options:r});if("toAccount"in n)return n.toAccount instanceof Y?ri({aptosConfig:e,fromAccount:t,toNewPrivateKey:n.toAccount.privateKey,options:r}):ri({aptosConfig:e,fromAccount:t,toAccount:n.toAccount,options:r});throw new Error("Invalid arguments")}async function ri(n){let{aptosConfig:e,fromAccount:t,options:r}=n,i=await tn({aptosConfig:e,accountAddress:t.accountAddress}),o;"toNewPrivateKey"in n?o=Xe.fromPrivateKey({privateKey:n.toNewPrivateKey,legacy:!0}):o=n.toAccount;let a=new Xi({sequenceNumber:BigInt(i.sequence_number),originator:t.accountAddress,currentAuthKey:u.from(i.authentication_key),newPublicKey:o.publicKey}).bcsToBytes(),c=t.sign(a),d=o.sign(a);return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::account::rotate_authentication_key",functionArguments:[new Se(t.signingScheme),K.U8(t.publicKey.toUint8Array()),new Se(o.signingScheme),K.U8(o.publicKey.toUint8Array()),K.U8(c.toUint8Array()),K.U8(d.toUint8Array())],abi:rc},options:r})}var ic={typeParameters:[],parameters:[new oe,v.u8()]};async function ys(n){let{aptosConfig:e,fromAccount:t,toNewPublicKey:r,options:i}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::account::rotate_authentication_key_from_public_key",functionArguments:[new Se(es(r)),K.U8(ii(r).toUint8Array())],abi:ic},options:i})}async function yr(n){let{aptosConfig:e,publicKey:t,options:r}=n,i=r?.noMultiKey??!1;if(i&&t instanceof xe)throw new Error("Multi-key accounts are not supported when noMultiKey is true.");let o=[t];t instanceof x&&t.publicKey instanceof b?o.push(t.publicKey):t instanceof b&&o.push(new x(t));let[s,a]=await Promise.all([Promise.all(o.map(async g=>{let p=await uc({aptosConfig:e,publicKey:g});if(p)return{...p,publicKey:g}})),!(t instanceof xe)&&!i?sc({aptosConfig:e,publicKey:t,options:r}):Promise.resolve([])]),c=[];for(let g of s)g&&c.push(g);o.push(...a);let d=new Map(o.map(g=>[g.authKey().toString(),g])),l=await ac({aptosConfig:e,authKeys:o.map(g=>g.authKey()),options:r});for(let g of l){if(c.find(y=>y.accountAddress===g.accountAddress))continue;let p=d.get(g.authKey.toString());if(!p)throw new Error(`No publicKey found for authentication key ${g.authKey}. This should never happen.`);c.push({accountAddress:g.accountAddress,publicKey:p,lastTransactionVersion:g.lastTransactionVersion})}return c.sort((g,p)=>p.lastTransactionVersion-g.lastTransactionVersion)}async function di(n){let{aptosConfig:e,signer:t,options:r}=n;if(t instanceof L||t instanceof He)return gr({aptosConfig:e,privateKey:t,options:r});if(t instanceof Y||t instanceof se)return gr({aptosConfig:e,privateKey:t.privateKey,options:r});if(t instanceof be||t instanceof ve)return oc({aptosConfig:e,keylessAccount:t,options:r});if(t instanceof tt&&t.signers.length===1)return di({aptosConfig:e,signer:t.signers[0],options:r});if(t instanceof mn&&t.signers.length===1)return gr({aptosConfig:e,privateKey:t.signers[0],options:r});throw new Error("Unknown signer type")}async function oc(n){let{aptosConfig:e,keylessAccount:t,options:r}=n,i=await yr({aptosConfig:e,publicKey:t.getAnyPublicKey(),options:r}),o={proof:t.proofOrPromise,jwt:t.jwt,ephemeralKeyPair:t.ephemeralKeyPair,pepper:t.pepper,verificationKeyHash:t.verificationKeyHash},s=[];for(let{accountAddress:a,publicKey:c}of i)if(c instanceof xe){if(c.getSignaturesRequired()>1)continue;if(c instanceof Z)throw new Error("Keyless authentication cannot be used for multi-ed25519 accounts. This should never happen.");c instanceof B&&s.push(new tt({multiKey:c,signers:[t],address:a}))}else t instanceof ve?s.push(ve.create({...o,address:a,jwkAddress:t.publicKey.jwkAddress})):s.push(be.create({...o,address:a}));return s}async function gr(n){let{aptosConfig:e,privateKey:t,options:r}=n,i=Xe.fromPrivateKey({privateKey:t,legacy:!1}),o=await yr({aptosConfig:e,publicKey:new x(t.publicKey()),options:r}),s=[];for(let{accountAddress:a,publicKey:c}of o)if(c instanceof xe){if(c.getSignaturesRequired()>1)continue;c instanceof Z?s.push(new mn({publicKey:c,signers:[t],address:a})):c instanceof B&&s.push(new tt({multiKey:c,signers:[i],address:a}))}else{let d=c instanceof b;s.push(Xe.fromPrivateKey({privateKey:t,address:a,legacy:d}))}return s}async function sc(n){let{aptosConfig:e,publicKey:t,options:r}=n;if(t instanceof xe)throw new Error("Public key is a multi-key.");let i=r?.includeUnverified??!1,o=t instanceof x?t:new x(t),s=o.publicKey,a=Ii(o.variant),c={public_key:{_eq:s.toString()},public_key_type:{_eq:a},...i?{}:{is_public_key_used:{_eq:!0}}},d={query:co,variables:{where_condition:c}},{public_key_auth_keys:l}=await P({aptosConfig:e,query:d,originMethod:"getMultiKeysForPublicKey"});return l.map(p=>{switch(p.signature_type){case"multi_ed25519_signature":return Z.deserializeWithoutLength(k.fromHex(p.account_public_key));case"multi_key_signature":return B.deserialize(k.fromHex(p.account_public_key));default:throw new Error(`Unknown multi-signature type: ${p.signature_type}`)}})}async function ac(n){let{aptosConfig:e,authKeys:t,options:r}=n,i=r?.includeUnverified??!1;if(t.length===0)throw new Error("No authentication keys provided");let o={auth_key:{_in:t.map(c=>c.toString())},...i?{}:{is_auth_key_used:{_eq:!0}}},s={query:eo,variables:{where_condition:o,order_by:[{last_transaction_version:"desc"}]}},{auth_key_account_addresses:a}=await P({aptosConfig:e,query:s,originMethod:"getAccountAddressesForAuthKeys"});return a.map(c=>({authKey:new ne({data:c.auth_key}),accountAddress:new u(m.hexInputToUint8Array(c.account_address)),lastTransactionVersion:Number(c.last_transaction_version)}))}async function cc(n){let{aptosConfig:e,accountAddress:t}=n,r=await oi({aptosConfig:e,accountAddress:t,options:{limit:1}});return r.length===0?0:Number(r[0].version)}async function uc(n){let{aptosConfig:e,publicKey:t}=n,r=t.authKey().derivedAddress(),[i,o]=await Promise.all([cc({aptosConfig:e,accountAddress:r}),ls({aptosConfig:e,accountAddress:r,options:{withAuthKey:t.authKey()}})]);if(o)return{accountAddress:r,lastTransactionVersion:i}}async function ae(n){let{aptosConfig:e,payload:t,options:r}=n,i=await Wo({...t,aptosConfig:e}),o=new ee;i.serialize(o);let s=o.toUint8Array(),{data:a}=await Rt({aptosConfig:e,path:"view",originMethod:"view",contentType:"application/x.aptos.view_function+bcs",params:{ledger_version:r?.ledgerVersion},body:s});return a}async function ms(n){let{aptosConfig:e,payload:t,options:r}=n,{data:i}=await Rt({aptosConfig:e,originMethod:"viewJson",path:"view",params:{ledger_version:r?.ledgerVersion},body:{function:t.function,type_arguments:t.typeArguments??[],arguments:t.functionArguments??[]}});return i}async function fs(n){let{aptosConfig:e,sender:t,authenticationFunction:r,options:i}=n,{moduleAddress:o,moduleName:s,functionName:a}=ue(r);return A({aptosConfig:e,sender:t,data:{function:"0x1::account_abstraction::add_authentication_function",typeArguments:[],functionArguments:[o,s,a],abi:{typeParameters:[],parameters:[new R,new f(I()),new f(I())]}},options:i})}async function As(n){let{aptosConfig:e,sender:t,authenticationFunction:r,options:i}=n,{moduleAddress:o,moduleName:s,functionName:a}=ue(r);return A({aptosConfig:e,sender:t,data:{function:"0x1::account_abstraction::remove_authentication_function",typeArguments:[],functionArguments:[o,s,a],abi:{typeParameters:[],parameters:[new R,new f(I()),new f(I())]}},options:i})}async function hs(n){let{aptosConfig:e,sender:t,options:r}=n;return A({aptosConfig:e,sender:t,data:{function:"0x1::account_abstraction::remove_authenticator",typeArguments:[],functionArguments:[],abi:{typeParameters:[],parameters:[]}},options:r})}var xt=class{constructor(e){this.config=e;this.isAccountAbstractionEnabled=async e=>{let t=await this.getAuthenticationFunction(e),{moduleAddress:r,moduleName:i,functionName:o}=ue(e.authenticationFunction);return t?.some(s=>u.fromString(r).equals(s.moduleAddress)&&i===s.moduleName&&o===s.functionName)??!1};this.enableAccountAbstractionTransaction=this.addAuthenticationFunctionTransaction;this.disableAccountAbstractionTransaction=async e=>{let{accountAddress:t,authenticationFunction:r,options:i}=e;return r?this.removeAuthenticationFunctionTransaction({accountAddress:t,authenticationFunction:r,options:i}):this.removeDispatchableAuthenticatorTransaction({accountAddress:t,options:i})}}async addAuthenticationFunctionTransaction(e){let{accountAddress:t,authenticationFunction:r,options:i}=e;return fs({aptosConfig:this.config,authenticationFunction:r,sender:t,options:i})}async removeAuthenticationFunctionTransaction(e){let{accountAddress:t,authenticationFunction:r,options:i}=e;return As({aptosConfig:this.config,sender:t,authenticationFunction:r,options:i})}async removeDispatchableAuthenticatorTransaction(e){let{accountAddress:t,options:r}=e;return hs({aptosConfig:this.config,sender:t,options:r})}async getAuthenticationFunction(e){let{accountAddress:t}=e,[{vec:r}]=await ae({aptosConfig:this.config,payload:{function:"0x1::account_abstraction::dispatchable_authenticator",functionArguments:[u.from(t)],abi:{typeParameters:[],parameters:[new R],returnTypes:[]}}});if(r.length!==0)return r[0].map(i=>({moduleAddress:u.fromString(i.module_address),moduleName:i.module_name,functionName:i.function_name}))}};var bn=class{constructor(e){this.config=e;this.abstraction=new xt(e)}async getAccountInfo(e){return tn({aptosConfig:this.config,...e})}async getAccountModules(e){return ts({aptosConfig:this.config,...e})}async getAccountModulesPage(e){return ns({aptosConfig:this.config,...e})}async getAccountModule(e){return cr({aptosConfig:this.config,...e})}async getAccountTransactions(e){return oi({aptosConfig:this.config,...e})}async getAccountResources(e){return si({aptosConfig:this.config,...e})}async getAccountResourcesPage(e){return rs({aptosConfig:this.config,...e})}async getAccountResource(e){return ai({aptosConfig:this.config,...e})}async lookupOriginalAccountAddress(e){return nn({aptosConfig:this.config,...e})}async getAccountTokensCount(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_transactions_processor"}),is({aptosConfig:this.config,...e})}async getAccountOwnedTokens(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),os({aptosConfig:this.config,...e})}async getAccountOwnedTokensFromCollectionAddress(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),ss({aptosConfig:this.config,...e})}async getAccountCollectionsWithOwnedTokens(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),as({aptosConfig:this.config,...e})}async getAccountTransactionsCount(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_transactions_processor"}),cs({aptosConfig:this.config,...e})}async getAccountCoinsData(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),ci({aptosConfig:this.config,...e})}async getAccountCoinsCount(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),us({aptosConfig:this.config,...e})}async getAccountAPTAmount(e){return this.getAccountCoinAmount({coinType:Be,faMetadataAddress:Oi,...e})}async getAccountCoinAmount(e){let{accountAddress:t,coinType:r,faMetadataAddress:i}=e,o=r;r===void 0&&i!==void 0&&(o=await Ot(async()=>{try{let c=(await ae({aptosConfig:this.config,payload:{function:"0x1::coin::paired_coin",functionArguments:[i]}}))[0];if(c.vec.length>0&&Wi(c.vec[0]))return qi(c.vec[0])}catch{}},`coin-mapping-${i.toString()}`,1e3*60*5)());let s;if(r!==void 0&&i!==void 0)s=u.from(i).toStringLong();else if(r!==void 0&&i===void 0)r===Be?s=u.A.toStringLong():s=On(u.A,r).toStringLong();else if(r===void 0&&i!==void 0){let c=u.from(i);s=c.toStringLong(),c===u.A&&(o=Be)}else throw new Error("Either coinType, faMetadataAddress, or both must be provided");if(o!==void 0){let[c]=await ae({aptosConfig:this.config,payload:{function:"0x1::coin::balance",typeArguments:[o],functionArguments:[t]}});return parseInt(c,10)}let[a]=await ae({aptosConfig:this.config,payload:{function:"0x1::primary_fungible_store::balance",typeArguments:["0x1::object::ObjectCore"],functionArguments:[t,s]}});return parseInt(a,10)}async getBalance(e){return ds({aptosConfig:this.config,...e})}async getAccountOwnedObjects(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),ui({aptosConfig:this.config,...e})}async deriveAccountFromPrivateKey(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_restoration_processor"}),await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"objects_processor"}),ps({aptosConfig:this.config,...e})}async deriveOwnedAccountsFromSigner(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_restoration_processor"}),await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"objects_processor"}),di({aptosConfig:this.config,...e})}async getAccountsForPublicKey(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_restoration_processor"}),await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"objects_processor"}),yr({aptosConfig:this.config,...e})}};var dc={typeParameters:[{constraints:[]}],parameters:[new R,new W]};async function bs(n){let{aptosConfig:e,sender:t,recipient:r,amount:i,coinType:o,options:s}=n;return A({aptosConfig:e,sender:t,data:{function:"0x1::aptos_account::transfer_coins",typeArguments:[o??Be],functionArguments:[r,i],abi:dc},options:s})}var Tn=class{constructor(e){this.config=e}async transferCoinTransaction(e){return bs({aptosConfig:this.config,...e})}};var dt={BOOLEAN:"bool",U8:"u8",U16:"u16",U32:"u32",U64:"u64",U128:"u128",U256:"u256",ADDRESS:"address",STRING:"0x1::string::String",ARRAY:"vector<u8>"},we="0x4::token::Token";async function ws(n){let{aptosConfig:e,digitalAssetAddress:t}=n,r={token_data_id:{_eq:u.from(t).toStringLong()}};return(await P({aptosConfig:e,query:{query:fo,variables:{where_condition:r}},originMethod:"getDigitalAssetData"})).current_token_datas_v2[0]}async function Ts(n){let{aptosConfig:e,digitalAssetAddress:t}=n,r={token_data_id:{_eq:u.from(t).toStringLong()},amount:{_gt:0}};return(await P({aptosConfig:e,query:{query:Dr,variables:{where_condition:r}},originMethod:"getCurrentDigitalAssetOwnership"})).current_token_ownerships_v2[0]}async function Ss(n){let{aptosConfig:e,ownerAddress:t,options:r}=n,i={owner_address:{_eq:u.from(t).toStringLong()},amount:{_gt:0}},o={query:Dr,variables:{where_condition:i,offset:r?.offset,limit:r?.limit,order_by:r?.orderBy}};return(await P({aptosConfig:e,query:o,originMethod:"getOwnedDigitalAssets"})).current_token_ownerships_v2}async function Ps(n){let{aptosConfig:e,digitalAssetAddress:t,options:r}=n,i={token_data_id:{_eq:u.from(t).toStringLong()}},o={query:mo,variables:{where_condition:i,offset:r?.offset,limit:r?.limit,order_by:r?.orderBy}};return(await P({aptosConfig:e,query:o,originMethod:"getDigitalAssetActivity"})).token_activities_v2}var pc={typeParameters:[],parameters:[new f(I()),new W,new f(I()),new f(I()),new V,new V,new V,new V,new V,new V,new V,new V,new V,new W,new W]};async function Ks(n){let{aptosConfig:e,options:t,creator:r}=n;return A({aptosConfig:e,sender:r.accountAddress,data:{function:"0x4::aptos_token::create_collection",functionArguments:[new F(n.description),new fe(n.maxSupply??Pi),new F(n.name),new F(n.uri),new H(n.mutableDescription??!0),new H(n.mutableRoyalty??!0),new H(n.mutableURI??!0),new H(n.mutableTokenDescription??!0),new H(n.mutableTokenName??!0),new H(n.mutableTokenProperties??!0),new H(n.mutableTokenURI??!0),new H(n.tokensBurnableByCreator??!0),new H(n.tokensFreezableByCreator??!0),new fe(n.royaltyNumerator??0),new fe(n.royaltyDenominator??1)],abi:pc},options:t})}async function rn(n){let{aptosConfig:e,options:t}=n,r=t?.where;t?.tokenStandard&&(r.token_standard={_eq:t?.tokenStandard??"v2"});let i={query:uo,variables:{where_condition:r,offset:t?.offset,limit:t?.limit}};return(await P({aptosConfig:e,query:i,originMethod:"getCollectionData"})).current_collections_v2[0]}async function xs(n){let{aptosConfig:e,creatorAddress:t,collectionName:r,options:i}=n,o=u.from(t),s={collection_name:{_eq:r},creator_address:{_eq:o.toStringLong()}};return i?.tokenStandard&&(s.token_standard={_eq:i?.tokenStandard??"v2"}),rn({aptosConfig:e,options:{...i,where:s}})}async function Is(n){let{aptosConfig:e,creatorAddress:t,options:r}=n,o={creator_address:{_eq:u.from(t).toStringLong()}};return r?.tokenStandard&&(o.token_standard={_eq:r?.tokenStandard??"v2"}),rn({aptosConfig:e,options:{...r,where:o}})}async function Es(n){let{aptosConfig:e,collectionId:t,options:r}=n,o={collection_id:{_eq:u.from(t).toStringLong()}};return r?.tokenStandard&&(o.token_standard={_eq:r?.tokenStandard??"v2"}),rn({aptosConfig:e,options:{...r,where:o}})}async function Cs(n){let{creatorAddress:e,collectionName:t,options:r,aptosConfig:i}=n,o=u.from(e),s={collection_name:{_eq:t},creator_address:{_eq:o.toStringLong()}};return r?.tokenStandard&&(s.token_standard={_eq:r?.tokenStandard??"v2"}),(await rn({aptosConfig:i,options:{where:s}})).collection_id}var lc={typeParameters:[],parameters:[new f(I()),new f(I()),new f(I()),new f(I()),new v(new f(I())),new v(new f(I())),new v(v.u8())]};async function vs(n){let{aptosConfig:e,options:t,creator:r,collection:i,description:o,name:s,uri:a,propertyKeys:c,propertyTypes:d,propertyValues:l}=n,g=d?.map(p=>dt[p]);return A({aptosConfig:e,sender:r.accountAddress,data:{function:"0x4::aptos_token::mint",functionArguments:[new F(i),new F(o),new F(s),new F(a),K.MoveString(c??[]),K.MoveString(g??[]),Hs(l??[],g??[])],abi:lc},options:t})}var gc={typeParameters:[{constraints:["key"]}],parameters:[new f(ge(new N(0))),new R]};async function _s(n){let{aptosConfig:e,sender:t,digitalAssetAddress:r,recipient:i,digitalAssetType:o,options:s}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::object::transfer",typeArguments:[o??we],functionArguments:[u.from(r),u.from(i)],abi:gc},options:s})}var yc={typeParameters:[],parameters:[new f(I()),new f(I()),new f(I()),new f(I()),new v(new f(I())),new v(new f(I())),new v(v.u8()),new R]};async function Us(n){let{aptosConfig:e,account:t,collection:r,description:i,name:o,uri:s,recipient:a,propertyKeys:c,propertyTypes:d,propertyValues:l,options:g}=n;if(c?.length!==l?.length)throw new Error("Property keys and property values counts do not match");if(d?.length!==l?.length)throw new Error("Property types and property values counts do not match");let p=d?.map(y=>dt[y]);return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::mint_soul_bound",functionArguments:[r,i,o,s,K.MoveString(c??[]),K.MoveString(p??[]),Hs(l??[],p??[]),a],abi:yc},options:g})}var mc={typeParameters:[{constraints:["key"]}],parameters:[new f(ge(new N(0)))]};async function ks(n){let{aptosConfig:e,creator:t,digitalAssetAddress:r,digitalAssetType:i,options:o}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::burn",typeArguments:[i??we],functionArguments:[u.from(r)],abi:mc},options:o})}var fc={typeParameters:[{constraints:["key"]}],parameters:[new f(ge(new N(0)))]};async function Fs(n){let{aptosConfig:e,creator:t,digitalAssetAddress:r,digitalAssetType:i,options:o}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::freeze_transfer",typeArguments:[i??we],functionArguments:[r],abi:fc},options:o})}var Ac={typeParameters:[{constraints:["key"]}],parameters:[new f(ge(new N(0)))]};async function zs(n){let{aptosConfig:e,creator:t,digitalAssetAddress:r,digitalAssetType:i,options:o}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::unfreeze_transfer",typeArguments:[i??we],functionArguments:[r],abi:Ac},options:o})}var hc={typeParameters:[{constraints:["key"]}],parameters:[new f(ge(new N(0))),new f(I())]};async function Ds(n){let{aptosConfig:e,creator:t,description:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::set_description",typeArguments:[o??we],functionArguments:[u.from(i),new F(r)],abi:hc},options:s})}var bc={typeParameters:[{constraints:["key"]}],parameters:[new f(ge(new N(0))),new f(I())]};async function Rs(n){let{aptosConfig:e,creator:t,name:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::set_name",typeArguments:[o??we],functionArguments:[u.from(i),new F(r)],abi:bc},options:s})}var wc={typeParameters:[{constraints:["key"]}],parameters:[new f(ge(new N(0))),new f(I())]};async function Os(n){let{aptosConfig:e,creator:t,uri:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::set_uri",typeArguments:[o??we],functionArguments:[u.from(i),new F(r)],abi:wc},options:s})}var Tc={typeParameters:[{constraints:["key"]}],parameters:[new f(ge(new N(0))),new f(I()),new f(I()),v.u8()]};async function Ns(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::add_property",typeArguments:[a??we],functionArguments:[u.from(s),new F(r),new F(dt[i]),K.U8(pi(o,dt[i]))],abi:Tc},options:c})}var Sc={typeParameters:[{constraints:["key"]}],parameters:[new f(ge(new N(0))),new f(I())]};async function Gs(n){let{aptosConfig:e,creator:t,propertyKey:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::remove_property",typeArguments:[o??we],functionArguments:[u.from(i),new F(r)],abi:Sc},options:s})}var Pc={typeParameters:[{constraints:["key"]}],parameters:[new f(ge(new N(0))),new f(I()),new f(I()),v.u8()]};async function Ms(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::update_property",typeArguments:[a??we],functionArguments:[u.from(s),new F(r),new F(dt[i]),pi(o,dt[i])],abi:Pc},options:c})}var Kc={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new f(ge(new N(0))),new f(I()),new N(1)]};async function Bs(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::add_typed_property",typeArguments:[a??we,dt[i]],functionArguments:[u.from(s),new F(r),o],abi:Kc},options:c})}var xc={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new f(ge(new N(0))),new f(I()),new N(1)]};async function Vs(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::update_typed_property",typeArguments:[a??we,dt[i]],functionArguments:[u.from(s),new F(r),o],abi:xc},options:c})}function Hs(n,e){let t=new Array;return e.forEach((r,i)=>{t.push(pi(n[i],r))}),t}function pi(n,e){let t=_e(e);return Kt(n,t,0,[]).bcsToBytes()}var Sn=class{constructor(e){this.config=e}async getCollectionData(e){await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"});let{creatorAddress:t,collectionName:r,options:i}=e,o=u.from(t),s={collection_name:{_eq:r},creator_address:{_eq:o.toStringLong()}};return i?.tokenStandard&&(s.token_standard={_eq:i?.tokenStandard??"v2"}),rn({aptosConfig:this.config,options:{where:s}})}async getCollectionDataByCreatorAddressAndCollectionName(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),xs({aptosConfig:this.config,...e})}async getCollectionDataByCreatorAddress(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Is({aptosConfig:this.config,...e})}async getCollectionDataByCollectionId(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Es({aptosConfig:this.config,...e})}async getCollectionId(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Cs({aptosConfig:this.config,...e})}async getDigitalAssetData(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),ws({aptosConfig:this.config,...e})}async getCurrentDigitalAssetOwnership(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Ts({aptosConfig:this.config,...e})}async getOwnedDigitalAssets(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Ss({aptosConfig:this.config,...e})}async getDigitalAssetActivity(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Ps({aptosConfig:this.config,...e})}async createCollectionTransaction(e){return Ks({aptosConfig:this.config,...e})}async mintDigitalAssetTransaction(e){return vs({aptosConfig:this.config,...e})}async transferDigitalAssetTransaction(e){return _s({aptosConfig:this.config,...e})}async mintSoulBoundTransaction(e){return Us({aptosConfig:this.config,...e})}async burnDigitalAssetTransaction(e){return ks({aptosConfig:this.config,...e})}async freezeDigitalAssetTransaferTransaction(e){return Fs({aptosConfig:this.config,...e})}async unfreezeDigitalAssetTransaferTransaction(e){return zs({aptosConfig:this.config,...e})}async setDigitalAssetDescriptionTransaction(e){return Ds({aptosConfig:this.config,...e})}async setDigitalAssetNameTransaction(e){return Rs({aptosConfig:this.config,...e})}async setDigitalAssetURITransaction(e){return Os({aptosConfig:this.config,...e})}async addDigitalAssetPropertyTransaction(e){return Ns({aptosConfig:this.config,...e})}async removeDigitalAssetPropertyTransaction(e){return Gs({aptosConfig:this.config,...e})}async updateDigitalAssetPropertyTransaction(e){return Ms({aptosConfig:this.config,...e})}async addDigitalAssetTypedPropertyTransaction(e){return Bs({aptosConfig:this.config,...e})}async updateDigitalAssetTypedPropertyTransaction(e){return Vs({aptosConfig:this.config,...e})}};async function Ls(n){let{aptosConfig:e,accountAddress:t,amount:r,options:i}=n,o=i?.timeoutSecs||20,{data:s}=await Ji({aptosConfig:e,path:"fund",body:{address:u.from(t).toString(),amount:r},originMethod:"fundAccount"}),a=s.txn_hashes[0],c=await Gt({aptosConfig:e,transactionHash:a,options:{timeoutSecs:o,checkSuccess:i?.checkSuccess}});if(c.type==="user_transaction")return c;throw new Error(`Unexpected transaction received for fund account: ${c.type}`)}var Pn=class{constructor(e){this.config=e}async fundAccount(e){let t=await Ls({aptosConfig:this.config,...e});return(e.options?.waitForIndexer===void 0||e.options?.waitForIndexer)&&await Io({aptosConfig:this.config,minimumLedgerVersion:BigInt(t.version),processorType:"fungible_asset_processor"}),t}};async function mr(n){let{aptosConfig:e,options:t}=n,r={query:yo,variables:{where_condition:t?.where,limit:t?.limit,offset:t?.offset}};return(await P({aptosConfig:e,query:r,originMethod:"getFungibleAssetMetadata"})).fungible_asset_metadata}async function $s(n){let{aptosConfig:e,options:t}=n,r={query:go,variables:{where_condition:t?.where,limit:t?.limit,offset:t?.offset}};return(await P({aptosConfig:e,query:r,originMethod:"getFungibleAssetActivities"})).fungible_asset_activities}async function qs(n){let{aptosConfig:e,options:t}=n,r={query:po,variables:{where_condition:t?.where,limit:t?.limit,offset:t?.offset}};return(await P({aptosConfig:e,query:r,originMethod:"getCurrentFungibleAssetBalances"})).current_fungible_asset_balances}var Ws={typeParameters:[{constraints:[]}],parameters:[_e("0x1::object::Object"),new R,new W]};async function js(n){let{aptosConfig:e,sender:t,fungibleAssetMetadataAddress:r,recipient:i,amount:o,options:s}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::primary_fungible_store::transfer",typeArguments:["0x1::fungible_asset::Metadata"],functionArguments:[r,i,o],abi:Ws},options:s})}async function Qs(n){let{aptosConfig:e,sender:t,fromStore:r,toStore:i,amount:o,options:s}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::dispatchable_fungible_asset::transfer",typeArguments:["0x1::fungible_asset::FungibleStore"],functionArguments:[r,i,o],abi:Ws},options:s})}var Kn=class{constructor(e){this.config=e}async getFungibleAssetMetadata(e){return await T({config:this.config,minimumLedgerVersion:e?.minimumLedgerVersion,processorType:"fungible_asset_processor"}),mr({aptosConfig:this.config,...e})}async getFungibleAssetMetadataByAssetType(e){return await T({config:this.config,minimumLedgerVersion:e?.minimumLedgerVersion,processorType:"fungible_asset_processor"}),(await mr({aptosConfig:this.config,options:{where:{asset_type:{_eq:e.assetType}}}}))[0]}async getFungibleAssetMetadataByCreatorAddress(e){return await T({config:this.config,minimumLedgerVersion:e?.minimumLedgerVersion,processorType:"fungible_asset_processor"}),await mr({aptosConfig:this.config,options:{where:{creator_address:{_eq:u.from(e.creatorAddress).toStringLong()}}}})}async getFungibleAssetActivities(e){return await T({config:this.config,minimumLedgerVersion:e?.minimumLedgerVersion,processorType:"fungible_asset_processor"}),$s({aptosConfig:this.config,...e})}async getCurrentFungibleAssetBalances(e){return await T({config:this.config,minimumLedgerVersion:e?.minimumLedgerVersion,processorType:"fungible_asset_processor"}),qs({aptosConfig:this.config,...e})}async transferFungibleAsset(e){return js({aptosConfig:this.config,...e})}async transferFungibleAssetBetweenStores(e){return Qs({aptosConfig:this.config,...e})}};var xn=class{constructor(e){this.config=e}async getLedgerInfo(){return Mn({aptosConfig:this.config})}async getChainId(){return(await this.getLedgerInfo()).chain_id}async getBlockByVersion(e){return Eo({aptosConfig:this.config,...e})}async getBlockByHeight(e){return Co({aptosConfig:this.config,...e})}async view(e){return ae({aptosConfig:this.config,...e})}async viewJson(e){return ms({aptosConfig:this.config,...e})}async getChainTopUserTransactions(e){return Ao({aptosConfig:this.config,...e})}async queryIndexer(e){return P({aptosConfig:this.config,...e})}async getIndexerLastSuccessVersion(){return ho({aptosConfig:this.config})}async getProcessorStatus(e){return bo({aptosConfig:this.config,processorType:e})}};var Js=["A name must be between 3 and 63 characters long,","and can only contain lowercase a-z, 0-9, and hyphens.","A name may not start or end with a hyphen."].join(" ");function Zs(n){return!(!n||n.length<3||n.length>63||!/^[a-z\d][a-z\d-]{1,61}[a-z\d]$/.test(n))}function pt(n){let[e,t,...r]=n.replace(/\.apt$/,"").split(".");if(r.length>0)throw new Error(`${n} is invalid. A name can only have two parts, a domain and a subdomain separated by a "."`);if(!Zs(e))throw new Error(`${e} is not valid. ${Js}`);if(t&&!Zs(t))throw new Error(`${t} is not valid. ${Js}`);return{domainName:t||e,subdomainName:t?e:void 0}}var Ic=(t=>(t[t.Independent=0]="Independent",t[t.FollowsDomain=1]="FollowsDomain",t))(Ic||{});function Ys(n){if(!n)return!1;let e=new Date(n.domain_expiration_timestamp).getTime()<Date.now(),t=new Date(n.expiration_timestamp).getTime()<Date.now();return n.subdomain&&e?!1:n.subdomain&&n.subdomain_expiration_policy===1?!0:!t}var Tb="0x37368b46ce665362562c6d1d4ec01a08c8644c488690df5a17e13ba163e20221",Ec="0x585fc9f0f0c54183b039ffc770ca282ebd87307916c215a3e692f2f8e4305e82",Cc={testnet:"0x5f8fd2347449685cf41d4db97926ec3a096eaf381332be4f1318ad4d16a8497c",mainnet:"0x867ed1f6bf916171b1de3ee92849b8978b7d1b9e0a8cc982a3d19d535dfd9c0c",local:Ec,custom:null,devnet:null,shelbynet:null};function rt(n){let e=Cc[n.network];if(!e)throw new Error(`The ANS contract is not deployed to ${n.network}`);return e}var fr=n=>{if(n&&typeof n=="object"&&"vec"in n&&Array.isArray(n.vec))return n.vec[0]};async function Xs(n){let{aptosConfig:e,name:t}=n,r=rt(e),{domainName:i,subdomainName:o}=pt(t),s=await ae({aptosConfig:e,payload:{function:`${r}::router::get_owner_addr`,functionArguments:[i,o]}}),a=fr(s[0]);return a?u.from(a):void 0}async function ea(n){let{aptosConfig:e,expiration:t,name:r,sender:i,targetAddress:o,toAddress:s,options:a,transferable:c}=n,d=rt(e),{domainName:l,subdomainName:g}=pt(r),p=t.policy==="subdomain:independent"||t.policy==="subdomain:follow-domain";if(g&&!p)throw new Error("Subdomains must have an expiration policy of either 'subdomain:independent' or 'subdomain:follow-domain'");if(p&&!g)throw new Error(`Policy is set to ${t.policy} but no subdomain was provided`);if(t.policy==="domain"){let M=t.years??1;if(M!==1)throw new Error("For now, names can only be registered for 1 year at a time");let Me=M*31536e3;return await A({aptosConfig:e,sender:i.accountAddress.toString(),data:{function:`${d}::router::register_domain`,functionArguments:[l,Me,o,s]},options:a})}if(!g)throw new Error(`${t.policy} requires a subdomain to be provided.`);let y=await li({aptosConfig:e,name:l});if(!y)throw new Error("The domain does not exist");let h=t.policy==="subdomain:independent"?t.expirationDate:y;if(h>y)throw new Error("The subdomain expiration time cannot be greater than the domain expiration time");return await A({aptosConfig:e,sender:i.accountAddress.toString(),data:{function:`${d}::router::register_subdomain`,functionArguments:[l,g,Math.round(h/1e3),t.policy==="subdomain:follow-domain"?1:0,!!c,o,s]},options:a})}async function li(n){let{aptosConfig:e,name:t}=n,r=rt(e),{domainName:i,subdomainName:o}=pt(t);try{let s=await ae({aptosConfig:e,payload:{function:`${r}::router::get_expiration`,functionArguments:[i,o]}});return Number(s[0])*1e3}catch{return}}async function ta(n){let{aptosConfig:e,address:t}=n,r=rt(e),i=await ae({aptosConfig:e,payload:{function:`${r}::router::get_primary_name`,functionArguments:[u.from(t).toString()]}}),o=fr(i[1]),s=fr(i[0]);if(o)return[s,o].filter(Boolean).join(".")}async function na(n){let{aptosConfig:e,sender:t,name:r,options:i}=n,o=rt(e);if(!r)return await A({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${o}::router::clear_primary_name`,functionArguments:[]},options:i});let{domainName:s,subdomainName:a}=pt(r);return await A({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${o}::router::set_primary_name`,functionArguments:[s,a]},options:i})}async function ra(n){let{aptosConfig:e,name:t}=n,r=rt(e),{domainName:i,subdomainName:o}=pt(t),s=await ae({aptosConfig:e,payload:{function:`${r}::router::get_target_addr`,functionArguments:[i,o]}}),a=fr(s[0]);return a?u.from(a):void 0}async function ia(n){let{aptosConfig:e,sender:t,name:r,address:i,options:o}=n,s=rt(e),{domainName:a,subdomainName:c}=pt(r);return await A({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${s}::router::set_target_addr`,functionArguments:[a,c,i]},options:o})}async function oa(n){let{aptosConfig:e,name:t}=n,{domainName:r,subdomainName:i=""}=pt(t),a=(await P({aptosConfig:e,query:{query:Nt,variables:{where_condition:{domain:{_eq:r},subdomain:{_eq:i}},limit:1}},originMethod:"getName"})).current_aptos_names[0];return a&&(a=In(a)),Ys(a)?a:void 0}async function sa(n){let{aptosConfig:e,options:t,accountAddress:r}=n,i=await gi({aptosConfig:e});return(await P({aptosConfig:e,originMethod:"getAccountNames",query:{query:Nt,variables:{limit:t?.limit,offset:t?.offset,order_by:t?.orderBy,where_condition:{...n.options?.where??{},owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:i}}}}})).current_aptos_names.map(In)}async function aa(n){let{aptosConfig:e,options:t,accountAddress:r}=n,i=await gi({aptosConfig:e});return(await P({aptosConfig:e,originMethod:"getAccountDomains",query:{query:Nt,variables:{limit:t?.limit,offset:t?.offset,order_by:t?.orderBy,where_condition:{...n.options?.where??{},owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:i},subdomain:{_eq:""}}}}})).current_aptos_names.map(In)}async function ca(n){let{aptosConfig:e,options:t,accountAddress:r}=n,i=await gi({aptosConfig:e});return(await P({aptosConfig:e,originMethod:"getAccountSubdomains",query:{query:Nt,variables:{limit:t?.limit,offset:t?.offset,order_by:t?.orderBy,where_condition:{...n.options?.where??{},owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:i},subdomain:{_neq:""}}}}})).current_aptos_names.map(In)}async function ua(n){let{aptosConfig:e,options:t,domain:r}=n;return(await P({aptosConfig:e,originMethod:"getDomainSubdomains",query:{query:Nt,variables:{limit:t?.limit,offset:t?.offset,order_by:t?.orderBy,where_condition:{...n.options?.where??{},domain:{_eq:r},subdomain:{_neq:""}}}}})).current_aptos_names.map(In).filter(Ys)}async function gi(n){let{aptosConfig:e}=n,t=rt(e),[r]=await ae({aptosConfig:e,payload:{function:`${t}::config::reregistration_grace_sec`,functionArguments:[]}}),i=r/60/60/24,o=()=>new Date;return new Date(o().setDate(o().getDate()-i)).toISOString()}async function da(n){let{aptosConfig:e,sender:t,name:r,years:i=1,options:o}=n,s=rt(e),a=i*31536e3,{domainName:c,subdomainName:d}=pt(r);if(d)throw new Error("Subdomains cannot be renewed");if(i!==1)throw new Error("Currently, only 1 year renewals are supported");return await A({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${s}::router::renew_domain`,functionArguments:[c,a]},options:o})}function In(n){return{...n,expiration_timestamp:new Date(n.expiration_timestamp).getTime()}}var En=class{constructor(e){this.config=e}async getOwnerAddress(e){return Xs({aptosConfig:this.config,...e})}async getExpiration(e){return li({aptosConfig:this.config,...e})}async getTargetAddress(e){return ra({aptosConfig:this.config,...e})}async setTargetAddress(e){return ia({aptosConfig:this.config,...e})}async getPrimaryName(e){return ta({aptosConfig:this.config,...e})}async setPrimaryName(e){return na({aptosConfig:this.config,...e})}async registerName(e){return ea({aptosConfig:this.config,...e})}async renewDomain(e){return da({aptosConfig:this.config,...e})}async getName(e){return oa({aptosConfig:this.config,...e})}async getAccountNames(e){return sa({aptosConfig:this.config,...e})}async getAccountDomains(e){return aa({aptosConfig:this.config,...e})}async getAccountSubdomains(e){return ca({aptosConfig:this.config,...e})}async getDomainSubdomains(e){return ua({aptosConfig:this.config,...e})}};async function pa(n){let{aptosConfig:e,poolAddress:t}=n,r=u.from(t).toStringLong(),o=await P({aptosConfig:e,query:{query:zr,variables:{where_condition:{pool_address:{_eq:r}}}}});return o.num_active_delegator_per_pool[0]?o.num_active_delegator_per_pool[0].num_active_delegator:0}async function la(n){let{aptosConfig:e,options:t}=n,r={query:zr,variables:{order_by:t?.orderBy}};return(await P({aptosConfig:e,query:r})).num_active_delegator_per_pool}async function ga(n){let{aptosConfig:e,delegatorAddress:t,poolAddress:r}=n,i={query:lo,variables:{delegatorAddress:u.from(t).toStringLong(),poolAddress:u.from(r).toStringLong()}};return(await P({aptosConfig:e,query:i})).delegated_staking_activities}var Cn=class{constructor(e){this.config=e}async getNumberOfDelegators(e){return await T({config:this.config,minimumLedgerVersion:e?.minimumLedgerVersion,processorType:"stake_processor"}),pa({aptosConfig:this.config,...e})}async getNumberOfDelegatorsForAllPools(e){return await T({config:this.config,minimumLedgerVersion:e?.minimumLedgerVersion,processorType:"stake_processor"}),la({aptosConfig:this.config,...e})}async getDelegatedStakingActivities(e){return await T({config:this.config,minimumLedgerVersion:e?.minimumLedgerVersion,processorType:"stake_processor"}),ga({aptosConfig:this.config,...e})}};var Ar=class{constructor(e){this.config=e}async simple(e){return A({aptosConfig:this.config,...e})}async multiAgent(e){return A({aptosConfig:this.config,...e})}};var on=class{constructor(e){this.config=e}async simple(e){return ni({aptosConfig:this.config,...e})}async multiAgent(e){return ni({aptosConfig:this.config,...e})}};xr([Or],on.prototype,"simple",1),xr([Or],on.prototype,"multiAgent",1);var hr=class{constructor(e){this.config=e}async simple(e){return Rr(this.config,e),hn({aptosConfig:this.config,...e})}async multiAgent(e){return Rr(this.config,e),hn({aptosConfig:this.config,...e})}};import _c from"eventemitter3";var br=class{constructor(e,t,r,i,o){this.lastUncommintedNumber=null;this.currentNumber=null;this.lock=!1;this.aptosConfig=e,this.account=t,this.maxWaitTime=r,this.maximumInFlight=i,this.sleepTime=o}async nextSequenceNumber(){for(;this.lock;)await cn(this.sleepTime);this.lock=!0;let e=BigInt(0);try{if((this.lastUncommintedNumber===null||this.currentNumber===null)&&await this.initialize(),this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight){await this.update();let t=Ve();for(;this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight;)await cn(this.sleepTime),Ve()-t>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, re-syncing ${this.account.accountAddress.toString()}`),await this.initialize()):await this.update()}e=this.currentNumber,this.currentNumber+=BigInt(1)}catch(t){console.error("error in getting next sequence number for this account",t)}finally{this.lock=!1}return e}async initialize(){let{sequence_number:e}=await tn({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});this.currentNumber=BigInt(e),this.lastUncommintedNumber=BigInt(e)}async update(){let{sequence_number:e}=await tn({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});return this.lastUncommintedNumber=BigInt(e),this.lastUncommintedNumber}async synchronize(){if(this.lastUncommintedNumber!==this.currentNumber){for(;this.lock;)await cn(this.sleepTime);this.lock=!0;try{await this.update();let e=Ve();for(;this.lastUncommintedNumber!==this.currentNumber;)Ve()-e>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, re-syncing ${this.account.accountAddress.toString()}`),await this.initialize()):(await cn(this.sleepTime),await this.update())}catch(e){console.error("error in synchronizing this account sequence number with the one on chain",e)}finally{this.lock=!1}}}};import vc from"eventemitter3";var ya="fulfilled",ma=(o=>(o.TransactionSent="transactionSent",o.TransactionSendFailed="transactionSendFailed",o.TransactionExecuted="transactionExecuted",o.TransactionExecutionFailed="transactionExecutionFailed",o.ExecutionFinish="executionFinish",o))(ma||{}),wr=class extends vc{constructor(t,r,i=30,o=100,s=10){super();this.taskQueue=new Hn;this.transactionsQueue=new Hn;this.outstandingTransactions=new Hn;this.sentTransactions=[];this.executedTransactions=[];this.aptosConfig=t,this.account=r,this.started=!1,this.accountSequnceNumber=new br(t,r,i,o,s)}async submitNextTransaction(){try{for(;;){let t=await this.accountSequnceNumber.nextSequenceNumber();if(t===null)return;let r=await this.generateNextTransaction(this.account,t);if(!r)return;let i=lr({aptosConfig:this.aptosConfig,transaction:r,signer:this.account});await this.outstandingTransactions.enqueue([i,t])}}catch(t){if(t instanceof Nr)return;throw new Error(`Submit transaction failed for ${this.account.accountAddress.toString()} with error ${t}`)}}async processTransactions(){try{for(;;){let t=[],r=[],[i,o]=await this.outstandingTransactions.dequeue();for(t.push(i),r.push(o);!this.outstandingTransactions.isEmpty();)[i,o]=await this.outstandingTransactions.dequeue(),t.push(i),r.push(o);let s=await Promise.allSettled(t);for(let a=0;a<s.length&&a<r.length;a+=1){let c=s[a];o=r[a],c.status===ya?(this.sentTransactions.push([c.value.hash,o,null]),this.emit("transactionSent",{message:`transaction hash ${c.value.hash} has been committed to chain`,transactionHash:c.value.hash}),await this.checkTransaction(c,o)):(this.sentTransactions.push([c.status,o,c.reason]),this.emit("transactionSendFailed",{message:`failed to commit transaction ${this.sentTransactions.length} with error ${c.reason}`,error:c.reason}))}this.emit("executionFinish",{message:`execute ${s.length} transactions finished`})}}catch(t){if(t instanceof Nr)return;throw new Error(`Process execution failed for ${this.account.accountAddress.toString()} with error ${t}`)}}async checkTransaction(t,r){try{let i=[];i.push(Gt({aptosConfig:this.aptosConfig,transactionHash:t.value.hash}));let o=await Promise.allSettled(i);for(let s=0;s<o.length;s+=1){let a=o[s];a.status===ya?(this.executedTransactions.push([a.value.hash,r,null]),this.emit("transactionExecuted",{message:`transaction hash ${a.value.hash} has been executed on chain`,transactionHash:t.value.hash})):(this.executedTransactions.push([a.status,r,a.reason]),this.emit("transactionExecutionFailed",{message:`failed to execute transaction ${this.executedTransactions.length} with error ${a.reason}`,error:a.reason}))}}catch(i){throw new Error(`Check transaction failed for ${this.account.accountAddress.toString()} with error ${i}`)}}async push(t,r){this.transactionsQueue.enqueue([t,r])}async generateNextTransaction(t,r){if(this.transactionsQueue.isEmpty())return;let[i,o]=await this.transactionsQueue.dequeue();return A({aptosConfig:this.aptosConfig,sender:t.accountAddress,data:i,options:{...o,accountSequenceNumber:r,replayProtectionNonce:void 0}})}async run(){try{for(;!this.taskQueue.isCancelled();)await(await this.taskQueue.dequeue())()}catch(t){throw new Error(`Unable to start transaction batching: ${t}`)}}start(){if(this.started)throw new Error("worker has already started");this.started=!0,this.taskQueue.enqueue(()=>this.submitNextTransaction()),this.taskQueue.enqueue(()=>this.processTransactions()),this.run()}stop(){if(this.taskQueue.isCancelled())throw new Error("worker has already stopped");this.started=!1,this.taskQueue.cancel()}};var Tr=class extends _c{constructor(e){super(),this.config=e}start(e){let{sender:t}=e;this.account=t,this.transactionWorker=new wr(this.config,t),this.transactionWorker.start(),this.registerToEvents()}push(e){let{data:t,options:r}=e;for(let i of t)this.transactionWorker.push(i,r)}registerToEvents(){this.transactionWorker.on("transactionSent",async e=>{this.emit("transactionSent",e)}),this.transactionWorker.on("transactionSendFailed",async e=>{this.emit("transactionSendFailed",e)}),this.transactionWorker.on("transactionExecuted",async e=>{this.emit("transactionExecuted",e)}),this.transactionWorker.on("transactionExecutionFailed",async e=>{this.emit("transactionExecutionFailed",e)}),this.transactionWorker.on("executionFinish",async e=>{this.emit("executionFinish",e)})}forSingleAccount(e){try{let{sender:t,data:r,options:i}=e;this.start({sender:t}),this.push({data:r,options:i})}catch(t){throw new Error(`failed to submit transactions with error: ${t}`)}}};var vn=class{constructor(e){this.config=e,this.build=new Ar(this.config),this.simulate=new on(this.config),this.submit=new hr(this.config),this.batch=new Tr(this.config)}async getTransactions(e){return So({aptosConfig:this.config,...e})}async getTransactionByVersion(e){return Po({aptosConfig:this.config,...e})}async getTransactionByHash(e){return Ko({aptosConfig:this.config,...e})}async isPendingTransaction(e){return xo({aptosConfig:this.config,...e})}async waitForTransaction(e){return Gt({aptosConfig:this.config,...e})}async getGasPriceEstimation(){return Vn({aptosConfig:this.config})}getSigningMessage(e){return Zo(e)}async publishPackageTransaction(e){return Xo({aptosConfig:this.config,...e})}async rotateAuthKey(e){return gs({aptosConfig:this.config,...e})}async rotateAuthKeyUnverified(e){return ys({aptosConfig:this.config,...e})}sign(e){return dr({...e})}signAsFeePayer(e){return pr({...e})}async batchTransactionsForSingleAccount(e){try{let{sender:t,data:r,options:i}=e;this.batch.forSingleAccount({sender:t,data:r,options:i})}catch(t){throw new Error(`failed to submit transactions with error: ${t}`)}}async signAndSubmitTransaction(e){return lr({aptosConfig:this.config,...e})}async signAndSubmitAsFeePayer(e){return Yo({aptosConfig:this.config,...e})}};import{jwtDecode as kc}from"jwt-decode";async function Sr(n){let{aptosConfig:e,jwt:t,ephemeralKeyPair:r,uidKey:i="sub",derivationPath:o}=n,s={jwt_b64:t,epk:r.getPublicKey().bcsToHex().toStringWithoutPrefix(),exp_date_secs:r.expiryDateSecs,epk_blinder:m.fromHexInput(r.blinder).toStringWithoutPrefix(),uid_key:i,derivation_path:o},{data:a}=await Zi({aptosConfig:e,path:"fetch",body:s,originMethod:"getPepper",overrides:{WITH_CREDENTIALS:!1}});return m.fromHexInput(a.pepper).toUint8Array()}async function yi(n){let{aptosConfig:e,jwt:t,ephemeralKeyPair:r,pepper:i=await Sr(n),uidKey:o="sub",maxExpHorizonSecs:s=(await Xt({aptosConfig:e})).maxExpHorizonSecs}=n;if(m.fromHexInput(i).toUint8Array().length!==be.PEPPER_LENGTH)throw new Error(`Pepper needs to be ${be.PEPPER_LENGTH} bytes`);let a=kc(t);if(typeof a.iat!="number")throw new Error("iat was not found");if(s<r.expiryDateSecs-a.iat)throw Error(`The EphemeralKeyPair is too long lived. It's lifespan must be less than ${s}`);let c={jwt_b64:t,epk:r.getPublicKey().bcsToHex().toStringWithoutPrefix(),epk_blinder:m.fromHexInput(r.blinder).toStringWithoutPrefix(),exp_date_secs:r.expiryDateSecs,exp_horizon_secs:s,pepper:m.fromHexInput(i).toStringWithoutPrefix(),uid_key:o},{data:d}=await Yi({aptosConfig:e,path:"prove",body:c,originMethod:"getProof",overrides:{WITH_CREDENTIALS:!1}}),l=d.proof,g=new lt({a:l.a,b:l.b,c:l.c});return new ye({proof:new sn(g,0),trainingWheelsSignature:Ne.fromHex(d.training_wheels_signature),expHorizonSecs:s})}async function fa(n){let{aptosConfig:e,jwt:t,jwkAddress:r,uidKey:i,proofFetchCallback:o,pepper:s=await Sr(n)}=n,{verificationKey:a,maxExpHorizonSecs:c}=await Xt({aptosConfig:e}),d=yi({...n,pepper:s,maxExpHorizonSecs:c}),l=o?d:await d;if(r!==void 0){let y=G.fromJwtAndPepper({jwt:t,pepper:s,jwkAddress:r,uidKey:i}),h=await nn({aptosConfig:e,authenticationKey:y.authKey().derivedAddress()});return ve.create({...n,address:h,proof:l,pepper:s,proofFetchCallback:o,jwkAddress:r,verificationKey:a})}let g=E.fromJwtAndPepper({jwt:t,pepper:s,uidKey:i}),p=await nn({aptosConfig:e,authenticationKey:g.authKey().derivedAddress()});return be.create({...n,address:p,proof:l,pepper:s,proofFetchCallback:o,verificationKey:a})}async function Aa(n){let{aptosConfig:e,sender:t,iss:r,options:i}=n,{jwksUrl:o}=n;o===void 0&&(Mi.test(r)?o="https://www.googleapis.com/service_accounts/v1/jwk/securetoken@system.gserviceaccount.com":o=r.endsWith("/")?`${r}.well-known/jwks.json`:`${r}/.well-known/jwks.json`);let s;try{if(s=await fetch(o),!s.ok)throw new Error(`${s.status} ${s.statusText}`)}catch(c){let d;throw c instanceof Error?d=`${c.message}`:d=`error unknown - ${c}`,S.fromErrorType({type:14,details:`Failed to fetch JWKS at ${o}: ${d}`})}let a=await s.json();return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::jwks::update_federated_jwk_set",functionArguments:[r,K.MoveString(a.keys.map(c=>c.kid)),K.MoveString(a.keys.map(c=>c.alg)),K.MoveString(a.keys.map(c=>c.e)),K.MoveString(a.keys.map(c=>c.n))]},options:i})}var _n=class{constructor(e){this.config=e}async getPepper(e){return Sr({aptosConfig:this.config,...e})}async getProof(e){return yi({aptosConfig:this.config,...e})}async deriveKeylessAccount(e){return fa({aptosConfig:this.config,...e})}async updateFederatedKeylessJwkSetTransaction(e){return Aa({aptosConfig:this.config,...e})}};async function Fc(n){let{aptosConfig:e,options:t}=n,r={query:Gn,variables:{where_condition:t?.where,offset:t?.offset,limit:t?.limit,order_by:t?.orderBy}};return(await P({aptosConfig:e,query:r,originMethod:"getObjectData"})).current_objects}async function ha(n){let{aptosConfig:e,objectAddress:t,options:r}=n,o={object_address:{_eq:u.from(t).toStringLong()}};return(await Fc({aptosConfig:e,options:{...r,where:o}}))[0]}var Un=class{constructor(e){this.config=e}async getObjectDataByObjectAddress(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"objects_processor"}),ha({aptosConfig:this.config,...e})}};var J=class{constructor(e){this.config=e??new vo,this.account=new bn(this.config),this.abstraction=new xt(this.config),this.ans=new En(this.config),this.coin=new Tn(this.config),this.digitalAsset=new Sn(this.config),this.faucet=new Pn(this.config),this.fungibleAsset=new Kn(this.config),this.general=new xn(this.config),this.staking=new Cn(this.config),this.transaction=new vn(this.config),this.table=new Gr(this.config),this.keyless=new _n(this.config),this.object=new Un(this.config)}setIgnoreTransactionSubmitter(e){this.config.setIgnoreTransactionSubmitter(e)}};function ce(n,e,t){Object.getOwnPropertyNames(e.prototype).forEach(r=>{let i=Object.getOwnPropertyDescriptor(e.prototype,r);i&&Object.defineProperty(n.prototype,r,{value:function(...o){return this[t][r](...o)},writable:i.writable,configurable:i.configurable,enumerable:i.enumerable})})}ce(J,bn,"account");ce(J,xt,"abstraction");ce(J,En,"ans");ce(J,Tn,"coin");ce(J,Sn,"digitalAsset");ce(J,Event,"event");ce(J,Pn,"faucet");ce(J,Kn,"fungibleAsset");ce(J,xn,"general");ce(J,Cn,"staking");ce(J,vn,"transaction");ce(J,Gr,"table");ce(J,_n,"keyless");ce(J,Un,"object");var Oc=1e7,mi=120,Nc=30,Gc=330,Mc=120,Bc=350,Vc=300,Hc=93,Ge=class Ge extends ke{constructor(e,t){super();let r=m.fromHexInput(t).toUint8Array();if(r.length!==Ge.ID_COMMITMENT_LENGTH)throw new Error(`Id Commitment length in bytes should be ${Ge.ID_COMMITMENT_LENGTH}`);this.iss=e,this.idCommitment=r}authKey(){let e=new ee;return e.serializeU32AsUleb128(3),e.serializeFixedBytes(this.bcsToBytes()),ne.fromSchemeAndBytes({scheme:2,input:e.toUint8Array()})}verifySignature(e){try{return Pr({...e,publicKey:this}),!0}catch(t){if(t instanceof S)return!1;throw t}}async verifySignatureAsync(e){return Ti({...e,publicKey:this})}serialize(e){e.serializeStr(this.iss),e.serializeBytes(this.idCommitment)}static deserialize(e){let t=e.deserializeStr(),r=e.deserializeBytes();return new Ge(t,r)}static load(e){let t=e.deserializeStr(),r=e.deserializeBytes();return new Ge(t,r)}static isPublicKey(e){return e instanceof Ge}static create(e){return ba(e),new Ge(e.iss,ba(e))}static fromJwtAndPepper(e){let{jwt:t,pepper:r,uidKey:i="sub"}=e,o=wa(t);if(typeof o.iss!="string")throw new Error("iss was not found");if(typeof o.aud!="string")throw new Error("aud was not found or an array of values");let s=o[i];return Ge.create({iss:o.iss,uidKey:i,uidVal:s,aud:o.aud,pepper:r})}static isInstance(e){return"iss"in e&&typeof e.iss=="string"&&"idCommitment"in e&&e.idCommitment instanceof Uint8Array}};Ge.ID_COMMITMENT_LENGTH=32;var E=Ge;async function Ti(n){let{aptosConfig:e,publicKey:t,message:r,signature:i,jwk:o,keylessConfig:s=await Xt({aptosConfig:e}),options:a}=n;try{if(!(i instanceof re))throw S.fromErrorType({type:26,details:"Not a keyless signature"});return Pr({message:r,publicKey:t,signature:i,jwk:o||await Br({aptosConfig:e,publicKey:t,kid:i.getJwkKid()}),keylessConfig:s}),!0}catch(c){if(a?.throwErrorWithReason)throw c;return!1}}function Pr(n){let{publicKey:e,message:t,signature:r,keylessConfig:i,jwk:o}=n,{verificationKey:s,maxExpHorizonSecs:a,trainingWheelsPubkey:c}=i;if(!(r instanceof re))throw S.fromErrorType({type:26,details:"Not a keyless signature"});if(!(r.ephemeralCertificate.signature instanceof ye))throw S.fromErrorType({type:26,details:"Unsupported ephemeral certificate variant"});let d=r.ephemeralCertificate.signature;if(!(d.proof.proof instanceof lt))throw S.fromErrorType({type:26,details:"Unsupported proof variant for ZeroKnowledgeSig"});let l=d.proof.proof;if(r.expiryDateSecs<Ve())throw S.fromErrorType({type:27,details:"The expiryDateSecs is in the past"});if(d.expHorizonSecs>a)throw S.fromErrorType({type:28});if(!r.ephemeralPublicKey.verifySignature({message:t,signature:r.ephemeralSignature}))throw S.fromErrorType({type:29});let g=Lc({publicKey:e,signature:r,jwk:o,keylessConfig:i});if(!s.verifyProof({publicInputsHash:g,groth16Proof:l}))throw S.fromErrorType({type:32});if(c){if(!d.trainingWheelsSignature)throw S.fromErrorType({type:30});let p=new Ai(l,g);if(!c.verifySignature({message:p.hash(),signature:d.trainingWheelsSignature}))throw S.fromErrorType({type:31})}}function Lc(n){let{publicKey:e,signature:t,jwk:r,keylessConfig:i}=n,o=e instanceof E?e:e.keylessPublicKey;if(!(t.ephemeralCertificate.signature instanceof ye))throw new Error("Signature is not a ZeroKnowledgeSig");let s=t.ephemeralCertificate.signature,a=[];return a.push(...Rn(t.ephemeralPublicKey.toUint8Array(),i.maxCommitedEpkBytes)),a.push(Ft(o.idCommitment)),a.push(t.expiryDateSecs),a.push(s.expHorizonSecs),a.push(Fe(o.iss,i.maxIssValBytes)),s.extraField?(a.push(1n),a.push(Fe(s.extraField,i.maxExtraFieldBytes))):(a.push(0n),a.push(Fe(" ",i.maxExtraFieldBytes))),a.push(Fe(Rc(t.jwtHeader,!0)+".",i.maxJwtHeaderB64Bytes)),a.push(r.toScalar()),s.overrideAudVal?(a.push(Fe(s.overrideAudVal,mi)),a.push(1n)):(a.push(Fe("",mi)),a.push(0n)),zt(a)}async function Br(n){let{aptosConfig:e,publicKey:t,kid:r}=n,i=t instanceof E?t:t.keylessPublicKey,{iss:o}=i,s,a=t instanceof G?t.jwkAddress:void 0;try{s=await Wc({aptosConfig:e,jwkAddr:a})}catch(l){throw S.fromErrorType({type:24,error:l,details:`Failed to fetch ${a?"Federated":"Patched"}JWKs ${a?`for address ${a}`:"0x1"}`})}let c=s.get(o);if(c===void 0)throw S.fromErrorType({type:7,details:`JWKs for issuer ${o} not found.`});let d=c.find(l=>l.kid===r);if(d===void 0)throw S.fromErrorType({type:6,details:`JWK with kid '${r}' for issuer '${o}' not found.`});return d}function ba(n){let{uidKey:e,uidVal:t,aud:r,pepper:i}=n,o=[Ft(m.fromHexInput(i).toUint8Array()),Fe(r,mi),Fe(t,Gc),Fe(e,Nc)];return Er(zt(o),E.ID_COMMITMENT_LENGTH)}var re=class n extends Q{constructor(e){super();let{jwtHeader:t,ephemeralCertificate:r,expiryDateSecs:i,ephemeralPublicKey:o,ephemeralSignature:s}=e;this.jwtHeader=t,this.ephemeralCertificate=r,this.expiryDateSecs=i,this.ephemeralPublicKey=o,this.ephemeralSignature=s}getJwkKid(){return Qc(this.jwtHeader).kid}serialize(e){this.ephemeralCertificate.serialize(e),e.serializeStr(this.jwtHeader),e.serializeU64(this.expiryDateSecs),this.ephemeralPublicKey.serialize(e),this.ephemeralSignature.serialize(e)}static deserialize(e){let t=Yt.deserialize(e),r=e.deserializeStr(),i=e.deserializeU64(),o=ut.deserialize(e),s=Ne.deserialize(e);return new n({jwtHeader:r,expiryDateSecs:Number(i),ephemeralCertificate:t,ephemeralPublicKey:o,ephemeralSignature:s})}static getSimulationSignature(){return new n({jwtHeader:"{}",ephemeralCertificate:new Yt(new ye({proof:new sn(new lt({a:new Uint8Array(32),b:new Uint8Array(64),c:new Uint8Array(32)}),0),expHorizonSecs:0}),0),expiryDateSecs:0,ephemeralPublicKey:new ut(new b(new Uint8Array(32))),ephemeralSignature:new Ne(new C(new Uint8Array(64)))})}static isSignature(e){return e instanceof n}},Yt=class n extends Q{constructor(e,t){super(),this.signature=e,this.variant=t}toUint8Array(){return this.signature.toUint8Array()}serialize(e){e.serializeU32AsUleb128(this.variant),this.signature.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new n(ye.deserialize(e),t);default:throw new Error(`Unknown variant index for EphemeralCertificate: ${t}`)}}},kn=class kn extends w{constructor(e){if(super(),this.data=m.fromHexInput(e).toUint8Array(),this.data.length!==32)throw new Error("Input needs to be 32 bytes")}serialize(e){e.serializeFixedBytes(this.data)}static deserialize(e){let t=e.deserializeFixedBytes(32);return new kn(t)}toArray(){let e=this.toProjectivePoint();return[e.x.toString(),e.y.toString(),e.pz.toString()]}toProjectivePoint(){let e=new Uint8Array(this.data);e.reverse();let t=(e[0]&128)>>7,{Fp:r}=Ue.fields,i=r.create(fi(e)),o=r.sqrt(r.add(r.pow(i,3n),kn.B)),s=r.neg(o),a=o>s==(t===1)?o:s;return Ue.G1.ProjectivePoint.fromAffine({x:i,y:a})}};kn.B=Ue.fields.Fp.create(3n);var it=kn;function fi(n){if(n.length!==32)throw new Error("Input should be 32 bytes");let e=new Uint8Array(n);return e[0]=e[0]&63,Dc(e)}var Fn=class Fn extends w{constructor(e){if(super(),this.data=m.fromHexInput(e).toUint8Array(),this.data.length!==64)throw new Error("Input needs to be 64 bytes")}serialize(e){e.serializeFixedBytes(this.data)}static deserialize(e){let t=e.deserializeFixedBytes(64);return new Fn(t)}toArray(){let e=this.toProjectivePoint();return[[e.x.c0.toString(),e.x.c1.toString()],[e.y.c0.toString(),e.y.c1.toString()],[e.pz.c0.toString(),e.pz.c1.toString()]]}toProjectivePoint(){let e=new Uint8Array(this.data),t=e.slice(0,32).reverse(),r=e.slice(32,64).reverse(),i=(r[0]&128)>>7,{Fp2:o}=Ue.fields,s=o.fromBigTuple([fi(t),fi(r)]),a=o.sqrt(o.add(o.pow(s,3n),Fn.B)),c=o.neg(a),l=(a.c1>c.c1||a.c1===c.c1&&a.c0>c.c0)===(i===1)?a:c;return Ue.G2.ProjectivePoint.fromAffine({x:s,y:l})}};Fn.B=Ue.fields.Fp2.fromBigTuple([19485874751759354771024239261021720505790618469301721065564631296452457478373n,266929791119991161246907387137283842545076965332900288569378510910307636690n]);var It=Fn,lt=class n extends Di{constructor(e){super();let{a:t,b:r,c:i}=e;this.a=new it(t),this.b=new It(r),this.c=new it(i)}serialize(e){this.a.serialize(e),this.b.serialize(e),this.c.serialize(e)}static deserialize(e){let t=it.deserialize(e).bcsToBytes(),r=It.deserialize(e).bcsToBytes(),i=it.deserialize(e).bcsToBytes();return new n({a:t,b:r,c:i})}toSnarkJsJson(){return{protocol:"groth16",curve:"bn128",pi_a:this.a.toArray(),pi_b:this.b.toArray(),pi_c:this.c.toArray()}}},Ai=class n extends w{constructor(t,r){super();this.domainSeparator="APTOS::Groth16ProofAndStatement";if(this.proof=t,this.publicInputsHash=typeof r=="bigint"?Er(r,32):m.fromHexInput(r).toUint8Array(),this.publicInputsHash.length!==32)throw new Error("Invalid public inputs hash")}serialize(t){this.proof.serialize(t),t.serializeFixedBytes(this.publicInputsHash)}static deserialize(t){return new n(lt.deserialize(t),t.deserializeFixedBytes(32))}hash(){return Oe(this.bcsToBytes(),this.domainSeparator)}},sn=class n extends w{constructor(e,t){super(),this.proof=e,this.variant=t}serialize(e){e.serializeU32AsUleb128(this.variant),this.proof.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new n(lt.deserialize(e),t);default:throw new Error(`Unknown variant index for ZkProof: ${t}`)}}},ye=class n extends Q{constructor(e){super();let{proof:t,expHorizonSecs:r,trainingWheelsSignature:i,extraField:o,overrideAudVal:s}=e;this.proof=t,this.expHorizonSecs=r,this.trainingWheelsSignature=i,this.extraField=o,this.overrideAudVal=s}static fromBytes(e){return n.deserialize(new k(e))}serialize(e){this.proof.serialize(e),e.serializeU64(this.expHorizonSecs),e.serializeOption(this.extraField),e.serializeOption(this.overrideAudVal),e.serializeOption(this.trainingWheelsSignature)}static deserialize(e){let t=sn.deserialize(e),r=Number(e.deserializeU64()),i=e.deserializeOption("string"),o=e.deserializeOption("string"),s=e.deserializeOption(Ne);return new n({proof:t,expHorizonSecs:r,trainingWheelsSignature:s,extraField:i,overrideAudVal:o})}},hi=class n{constructor(e){let{verificationKey:t,trainingWheelsPubkey:r,maxExpHorizonSecs:i=Oc,maxExtraFieldBytes:o=Bc,maxJwtHeaderB64Bytes:s=Vc,maxIssValBytes:a=Mc,maxCommitedEpkBytes:c=Hc}=e;this.verificationKey=t,this.maxExpHorizonSecs=i,r&&(this.trainingWheelsPubkey=new ut(new b(r))),this.maxExtraFieldBytes=o,this.maxJwtHeaderB64Bytes=s,this.maxIssValBytes=a,this.maxCommitedEpkBytes=c}static create(e,t){return new n({verificationKey:new bi({alphaG1:e.alpha_g1,betaG2:e.beta_g2,deltaG2:e.delta_g2,gammaAbcG1:e.gamma_abc_g1,gammaG2:e.gamma_g2}),maxExpHorizonSecs:Number(t.max_exp_horizon_secs),trainingWheelsPubkey:t.training_wheels_pubkey.vec[0],maxExtraFieldBytes:t.max_extra_field_bytes,maxJwtHeaderB64Bytes:t.max_jwt_header_b64_bytes,maxIssValBytes:t.max_iss_val_bytes,maxCommitedEpkBytes:t.max_commited_epk_bytes})}},bi=class n{constructor(e){let{alphaG1:t,betaG2:r,deltaG2:i,gammaAbcG1:o,gammaG2:s}=e;this.alphaG1=new it(t),this.betaG2=new It(r),this.deltaG2=new It(i),this.gammaAbcG1=[new it(o[0]),new it(o[1])],this.gammaG2=new It(s)}hash(){let e=new ee;return this.serialize(e),zc.create().update(e.toUint8Array()).digest()}serialize(e){this.alphaG1.serialize(e),this.betaG2.serialize(e),this.deltaG2.serialize(e),this.gammaAbcG1[0].serialize(e),this.gammaAbcG1[1].serialize(e),this.gammaG2.serialize(e)}static fromGroth16VerificationKeyResponse(e){return new n({alphaG1:e.alpha_g1,betaG2:e.beta_g2,deltaG2:e.delta_g2,gammaAbcG1:e.gamma_abc_g1,gammaG2:e.gamma_g2})}verifyProof(e){let{publicInputsHash:t,groth16Proof:r}=e;try{let i=r.a.toProjectivePoint(),o=r.b.toProjectivePoint(),s=r.c.toProjectivePoint(),a=this.alphaG1.toProjectivePoint(),c=this.betaG2.toProjectivePoint(),d=this.gammaG2.toProjectivePoint(),l=this.deltaG2.toProjectivePoint(),g=this.gammaAbcG1.map(ot=>ot.toProjectivePoint()),{Fp12:p}=Ue.fields,y=g[0].add(g[1].multiply(t)),h=Ue.pairing(y,d),U=Ue.pairing(i,o),M=Ue.pairing(a,c),X=Ue.pairing(s,l),Me=p.mul(M,p.mul(h,X));return p.eql(U,Me)}catch(i){throw S.fromErrorType({type:32,error:i,details:"Error encountered when checking zero knowledge relation"})}}toSnarkJsJson(){return{protocol:"groth16",curve:"bn128",nPublic:1,vk_alpha_1:this.alphaG1.toArray(),vk_beta_2:this.betaG2.toArray(),vk_gamma_2:this.gammaG2.toArray(),vk_delta_2:this.deltaG2.toArray(),IC:this.gammaAbcG1.map(e=>e.toArray())}}};async function Xt(n){let{aptosConfig:e}=n;try{return await Ot(async()=>{let[t,r]=await Promise.all([$c(n),qc(n)]);return hi.create(r,t)},`keyless-configuration-${e.network}`,1e3*60*5)()}catch(t){throw t instanceof S?t:S.fromErrorType({type:25,error:t})}}function et(n){let{jwt:e,uidKey:t="sub"}=n,r;try{r=wa(e)}catch(o){throw S.fromErrorType({type:12,details:`Failed to parse JWT - ${Vi(o)}`})}if(typeof r.iss!="string")throw S.fromErrorType({type:12,details:"JWT is missing 'iss' in the payload. This should never happen."});if(typeof r.aud!="string")throw S.fromErrorType({type:12,details:"JWT is missing 'aud' in the payload or 'aud' is an array of values."});let i=r[t];return{iss:r.iss,aud:r.aud,uidVal:i}}async function $c(n){let{aptosConfig:e,options:t}=n,r="0x1::keyless_account::Configuration";try{let{data:i}=await st({aptosConfig:e,originMethod:"getKeylessConfigurationResource",path:`accounts/${u.from("0x1").toString()}/resource/${r}`,params:{ledger_version:t?.ledgerVersion}});return i.data}catch(i){throw S.fromErrorType({type:22,error:i})}}async function qc(n){let{aptosConfig:e,options:t}=n,r="0x1::keyless_account::Groth16VerificationKey";try{let{data:i}=await st({aptosConfig:e,originMethod:"getGroth16VerificationKeyResource",path:`accounts/${u.from("0x1").toString()}/resource/${r}`,params:{ledger_version:t?.ledgerVersion}});return i.data}catch(i){throw S.fromErrorType({type:23,error:i})}}async function Wc(n){let{aptosConfig:e,jwkAddr:t,options:r}=n,i;if(t){let s="0x1::jwks::FederatedJWKs",{data:a}=await st({aptosConfig:e,originMethod:"getKeylessJWKs",path:`accounts/${u.from(t).toString()}/resource/${s}`,params:{ledger_version:r?.ledgerVersion}});i=a}else{let s="0x1::jwks::PatchedJWKs",{data:a}=await st({aptosConfig:e,originMethod:"getKeylessJWKs",path:`accounts/0x1/resource/${s}`,params:{ledger_version:r?.ledgerVersion}});i=a}let o=new Map;for(let s of i.data.jwks.entries){let a=[];for(let c of s.jwks){let{data:d}=c.variant,l=new k(m.fromHexInput(d).toUint8Array()),g=wi.deserialize(l);a.push(g)}o.set(Ki(s.issuer),a)}return o}var wi=class n extends w{constructor(e){super();let{kid:t,kty:r,alg:i,e:o,n:s}=e;this.kid=t,this.kty=r,this.alg=i,this.e=o,this.n=s}serialize(e){e.serializeStr(this.kid),e.serializeStr(this.kty),e.serializeStr(this.alg),e.serializeStr(this.e),e.serializeStr(this.n)}static fromMoveStruct(e){let{data:t}=e.variant,r=new k(m.fromHexInput(t).toUint8Array());return n.deserialize(r)}toScalar(){if(this.alg!=="RS256")throw S.fromErrorType({type:32,details:"Failed to convert JWK to scalar when calculating the public inputs hash. Only RSA 256 is supported currently"});let e=$i(this.n),r=jc(e.reverse()).map(i=>Ft(i));return r.push(256n),zt(r)}static deserialize(e){let t=e.deserializeStr(),r=e.deserializeStr(),i=e.deserializeStr(),o=e.deserializeStr(),s=e.deserializeStr();return new n({kid:t,kty:r,alg:i,n:s,e:o})}};function jc(n){let e=[];for(let t=0;t<n.length;t+=24){let r=n.slice(t,Math.min(t+24,n.length));if(r.length<24){let i=new Uint8Array(24);i.set(r),e.push(i)}else e.push(r)}return e}function Qc(n){try{let e=JSON.parse(n);if(e.kid===void 0)throw new Error("JWT header missing kid");return e}catch{throw new Error("Failed to parse JWT header.")}}var G=class n extends ke{constructor(e,t){super(),this.jwkAddress=u.from(e),this.keylessPublicKey=t}authKey(){let e=new ee;return e.serializeU32AsUleb128(4),e.serializeFixedBytes(this.bcsToBytes()),ne.fromSchemeAndBytes({scheme:2,input:e.toUint8Array()})}verifySignature(e){try{return Pr({...e,publicKey:this}),!0}catch{return!1}}serialize(e){this.jwkAddress.serialize(e),this.keylessPublicKey.serialize(e)}static deserialize(e){let t=u.deserialize(e),r=E.deserialize(e);return new n(t,r)}static isPublicKey(e){return e instanceof n}async verifySignatureAsync(e){return Ti({...e,publicKey:this})}static create(e){return new n(e.jwkAddress,E.create(e))}static fromJwtAndPepper(e){return new n(e.jwkAddress,E.fromJwtAndPepper(e))}static isInstance(e){return"jwkAddress"in e&&e.jwkAddress instanceof u&&"keylessPublicKey"in e&&e.keylessPublicKey instanceof E}};var Bt=n=>typeof n=="string"?m.isValid(n).valid?n:new TextEncoder().encode(n):n,ii=n=>{if(n instanceof b||n instanceof x||n instanceof Z||n instanceof B)return n;if(n instanceof E||n instanceof G)return new x(n);throw new Error(`Unknown account public key: ${n}`)},es=n=>{let e=ii(n);if(e instanceof b)return 0;if(e instanceof x)return 2;if(e instanceof Z)return 1;if(e instanceof B)return 3;throw new Error(`Unknown signing scheme: ${e}`)};var Si=[237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16];function Jc(n){let e=n.toUint8Array().slice(32);for(let t=Si.length-1;t>=0;t-=1){if(e[t]<Si[t])return!0;if(e[t]>Si[t])return!1}return!1}var gt=class gt extends ke{constructor(e){super();let t=m.fromHexInput(e);if(t.toUint8Array().length!==gt.LENGTH)throw new Error(`PublicKey length should be ${gt.LENGTH}`);this.key=t}verifySignature(e){let{message:t,signature:r}=e;if(!Jc(r))return!1;let i=Bt(t),o=m.fromHexInput(i).toUint8Array(),s=r.toUint8Array(),a=this.key.toUint8Array();return Kr.verify(s,o,a)}async verifySignatureAsync(e){return this.verifySignature(e)}authKey(){return ne.fromSchemeAndBytes({scheme:0,input:this.toUint8Array()})}toUint8Array(){return this.key.toUint8Array()}serialize(e){e.serializeBytes(this.key.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new gt(t)}static isPublicKey(e){return e instanceof gt}static isInstance(e){return"key"in e&&e.key?.data?.length===gt.LENGTH}};gt.LENGTH=32;var b=gt,Te=class Te extends w{constructor(e,t){super();let r=kt.parseHexInput(e,"ed25519",t);if(r.toUint8Array().length!==Te.LENGTH)throw new Error(`PrivateKey length should be ${Te.LENGTH}`);this.signingKey=r}static generate(){let e=Kr.utils.randomPrivateKey();return new Te(e,!1)}static fromDerivationPath(e,t){if(!Ui(e))throw new Error(`Invalid derivation path ${e}`);return Te.fromDerivationPathInner(e,Dn(t))}static fromDerivationPathInner(e,t,r=vi){let{key:i,chainCode:o}=ki(Te.SLIP_0010_SEED,t),s=zi(e).map(c=>parseInt(c,10)),{key:a}=s.reduce((c,d)=>Fi(c,d+r),{key:i,chainCode:o});return new Te(a,!1)}publicKey(){let e=Kr.getPublicKey(this.signingKey.toUint8Array());return new b(e)}sign(e){let t=Bt(e),r=m.fromHexInput(t).toUint8Array(),i=Kr.sign(r,this.signingKey.toUint8Array());return new C(i)}toUint8Array(){return this.signingKey.toUint8Array()}toString(){return this.toAIP80String()}toHexString(){return this.signingKey.toString()}toAIP80String(){return kt.formatPrivateKey(this.signingKey.toString(),"ed25519")}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new Te(t,!1)}static isPrivateKey(e){return e instanceof Te}};Te.LENGTH=32,Te.SLIP_0010_SEED="ed25519 seed";var L=Te,an=class an extends Q{constructor(e){super();let t=m.fromHexInput(e);if(t.toUint8Array().length!==an.LENGTH)throw new Error(`Signature length should be ${an.LENGTH}`);this.data=t}toUint8Array(){return this.data.toUint8Array()}serialize(e){e.serializeBytes(this.data.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new an(t)}};an.LENGTH=64;var C=an;var ut=class n extends zn{constructor(e){super();let t=e.constructor.name;switch(t){case b.name:this.publicKey=e,this.variant=0;break;default:throw new Error(`Unsupported key for EphemeralPublicKey - ${t}`)}}verifySignature(e){let{message:t,signature:r}=e;return this.publicKey.verifySignature({message:t,signature:r.signature})}async verifySignatureAsync(e){return this.verifySignature(e)}serialize(e){if(this.publicKey instanceof b)e.serializeU32AsUleb128(0),this.publicKey.serialize(e);else throw new Error("Unknown public key type")}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new n(b.deserialize(e));default:throw new Error(`Unknown variant index for EphemeralPublicKey: ${t}`)}}static isPublicKey(e){return e instanceof n}},Ne=class n extends Q{constructor(e){super();let t=e.constructor.name;switch(t){case C.name:this.signature=e;break;default:throw new Error(`Unsupported signature for EphemeralSignature - ${t}`)}}static fromHex(e){let t=m.fromHexInput(e),r=new k(t.toUint8Array());return n.deserialize(r)}serialize(e){if(this.signature instanceof C)e.serializeU32AsUleb128(0),this.signature.serialize(e);else throw new Error("Unknown signature type")}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new n(C.deserialize(e));default:throw new Error(`Unknown variant index for EphemeralSignature: ${t}`)}}};export{ut as a,Ne as b,Oc as c,mi as d,Nc as e,Gc as f,Mc as g,Bc as h,Vc as i,Hc as j,E as k,Ti as l,Pr as m,Br as n,re as o,Yt as p,lt as q,Ai as r,sn as s,ye as t,hi as u,bi as v,Xt as w,et as x,Wc as y,wi as z,Qc as A,G as B,Ke as C,He as D,Le as E,x as F,D as G,xe as H,B as I,Ae as J,Z as K,Ie as L,Bt as M,ii as N,es as O,Jc as P,b as Q,L as R,C as S,ed as T,td as U,q as V,Ee as W,$e as X,ie as Y,De as Z,Vt as _,yt as $,Wn as aa,dn as ba,O as ca,V as da,oe as ea,qe as fa,We as ga,W as ha,je as ia,Qe as ja,R as ka,mt as la,jn as ma,N as na,v as oa,f as pa,Re as qa,Qd as ra,I as sa,Jd as ta,ge as ua,Ka as va,at as wa,Ht as xa,Lt as ya,$t as za,Je as Aa,qt as Ba,pn as Ca,ln as Da,Qn as Ea,ft as Fa,Wt as Ga,gn as Ha,jt as Ia,yn as Ja,Jn as Ka,At as La,he as Ma,Zn as Na,ht as Oa,bt as Pa,Ze as Qa,wt as Ra,Qt as Sa,Tt as Ta,St as Ua,ct as Va,Ye as Wa,Yn as Xa,Xn as Ya,er as Za,Oe as _a,dl as $a,Ce as ab,Y as bb,Mr as cb,se as db,Xe as eb,Pt as fb,nr as gb,me as hb,tr as ib,be as jb,ve as kb,tt as lb,mn as mb,ko as nb,Do as ob,rr as pb,Oo as qb,Na as rb,$ as sb,_e as tb,Mo as ub,nt as vb,Ga as wb,ir as xb,or as yb,Bo as zb,Vo as Ab,Hr as Bb,sr as Cb,Lr as Db,Ma as Eb,$r as Fb,qr as Gb,Wr as Hb,jr as Ib,Qr as Jb,Jr as Kb,Ho as Lb,_ as Mb,Lo as Nb,ar as Ob,Va as Pb,Yr as Qb,hm as Rb,$o as Sb,qo as Tb,Xr as Ub,Kt as Vb,ur as Wb,$a as Xb,Wo as Yb,qa as Zb,ja as _b,Qa as $b,ei as ac,jo as bc,en as cc,ti as dc,Qo as ec,$m as fc,A as gc,Ya as hc,Xa as ic,Zo as jc,dr as kc,pr as lc,ni as mc,hn as nc,lr as oc,Yo as pc,Xo as qc,tn as rc,ts as sc,ns as tc,cr as uc,oi as vc,si as wc,rs as xc,ai as yc,nn as zc,is as Ac,os as Bc,ss as Cc,as as Dc,cs as Ec,gA as Fc,ci as Gc,us as Hc,ds as Ic,ui as Jc,ps as Kc,yA as Lc,gs as Mc,ys as Nc,yr as Oc,di as Pc,ae as Qc,ms as Rc,fs as Sc,As as Tc,hs as Uc,xt as Vc,bn as Wc,bs as Xc,Tn as Yc,ws as Zc,Ts as _c,Ss as $c,Ps as ad,Ks as bd,rn as cd,xs as dd,Is as ed,Es as fd,Cs as gd,vs as hd,_s as id,Us as jd,ks as kd,Fs as ld,zs as md,Ds as nd,Rs as od,Os as pd,Ns as qd,Gs as rd,Ms as sd,Bs as td,Vs as ud,Sn as vd,Ls as wd,Pn as xd,mr as yd,$s as zd,qs as Ad,js as Bd,Qs as Cd,Kn as Dd,xn as Ed,Js as Fd,Zs as Gd,pt as Hd,Ic as Id,Ys as Jd,Tb as Kd,Ec as Ld,Xs as Md,ea as Nd,li as Od,ta as Pd,na as Qd,ra as Rd,ia as Sd,oa as Td,sa as Ud,aa as Vd,ca as Wd,ua as Xd,da as Yd,En as Zd,pa as _d,la as $d,ga as ae,Cn as be,Ar as ce,on as de,hr as ee,br as fe,ya as ge,ma as he,wr as ie,Tr as je,vn as ke,Sr as le,yi as me,fa as ne,Aa as oe,_n as pe,Fc as qe,ha as re,Un as se,J as te};
4
- //# sourceMappingURL=chunk-PGUSBALH.mjs.map
3
+ K-of-N MultiKey transaction.`);this.signaturesRequired=r}getSignaturesRequired(){return this.signaturesRequired}verifySignature(e){let{message:t,signature:r}=e;if(r.signatures.length!==this.signaturesRequired)throw new Error("The number of signatures does not match the number of required signatures");let i=r.bitMapToSignerIndices();for(let o=0;o<r.signatures.length;o+=1){let s=r.signatures[o];if(!this.publicKeys[i[o]].verifySignature({message:t,signature:s}))return!1}return!0}async verifySignatureAsync(e){let{signature:t}=e;try{if(!(t instanceof Ae))throw new Error("Signature is not a MultiKeySignature");if(t.signatures.length!==this.signaturesRequired)throw new Error("The number of signatures does not match the number of required signatures");let r=t.bitMapToSignerIndices();for(let i=0;i<t.signatures.length;i+=1){let o=t.signatures[i];if(!await this.publicKeys[r[i]].verifySignatureAsync({...e,signature:o}))return!1}return!0}catch(r){if(e.options?.throwErrorWithReason)throw r;return!1}}authKey(){return ne.fromSchemeAndBytes({scheme:3,input:this.toUint8Array()})}serialize(e){e.serializeVector(this.publicKeys),e.serializeU8(this.signaturesRequired)}static deserialize(e){let t=e.deserializeVector(x),r=e.deserializeU8();return new n({publicKeys:t,signaturesRequired:r})}getIndex(e){let t=e instanceof x?e:new x(e);return super.getIndex(t)}static isInstance(e){return"publicKeys"in e&&"signaturesRequired"in e}},de=class de extends Q{constructor(e){super();let{signatures:t,bitmap:r}=e;if(t.length>de.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${de.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=t.map(o=>o instanceof D?o:new D(o)),!(r instanceof Uint8Array))this.bitmap=de.createBitmap({bits:r});else{if(r.length!==de.BITMAP_LEN)throw new Error(`"bitmap" length should be ${de.BITMAP_LEN}`);this.bitmap=r}let i=this.bitmap.reduce((o,s)=>o+Pa(s),0);if(i!==this.signatures.length)throw new Error(`Expecting ${i} signatures from the bitmap, but got ${this.signatures.length}`)}static createBitmap(e){let{bits:t}=e,r=128,i=new Uint8Array([0,0,0,0]),o=new Set;return t.forEach(s=>{if(s>=de.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${de.MAX_SIGNATURES_SUPPORTED-1}.`);if(o.has(s))throw new Error("Duplicate bits detected.");o.add(s);let a=Math.floor(s/8),c=i[a];c|=r>>s%8,i[a]=c}),i}bitMapToSignerIndices(){let e=[];for(let t=0;t<this.bitmap.length;t+=1){let r=this.bitmap[t];for(let i=0;i<8;i+=1)(r&128>>i)!==0&&e.push(t*8+i)}return e}serialize(e){e.serializeVector(this.signatures),e.serializeBytes(this.bitmap)}static deserialize(e){let t=e.deserializeVector(D),r=e.deserializeBytes();return new de({signatures:t,bitmap:r})}};de.BITMAP_LEN=4,de.MAX_SIGNATURES_SUPPORTED=de.BITMAP_LEN*8;var Ae=de;var pe=class pe extends xe{constructor(e){let{publicKeys:t,threshold:r}=e;if(super({publicKeys:t}),t.length>pe.MAX_KEYS||t.length<pe.MIN_KEYS)throw new Error(`Must have between ${pe.MIN_KEYS} and ${pe.MAX_KEYS} public keys, inclusive`);if(r<pe.MIN_THRESHOLD||r>t.length)throw new Error(`Threshold must be between ${pe.MIN_THRESHOLD} and ${t.length}, inclusive`);this.publicKeys=t,this.threshold=r}getSignaturesRequired(){return this.threshold}verifySignature(e){let{message:t,signature:r}=e;if(!(r instanceof Ie))return!1;let i=[];for(let o=0;o<4;o+=1)for(let s=0;s<8;s+=1)if((r.bitmap[o]&1<<7-s)!==0){let c=o*8+s;i.push(c)}if(i.length!==r.signatures.length)throw new Error("Bitmap and signatures length mismatch");if(i.length<this.threshold)throw new Error("Not enough signatures");for(let o=0;o<i.length;o+=1)if(!this.publicKeys[i[o]].verifySignature({message:t,signature:r.signatures[o]}))return!1;return!0}async verifySignatureAsync(e){return this.verifySignature(e)}authKey(){return ne.fromSchemeAndBytes({scheme:1,input:this.toUint8Array()})}toUint8Array(){let e=new Uint8Array(this.publicKeys.length*b.LENGTH+1);return this.publicKeys.forEach((t,r)=>{e.set(t.toUint8Array(),r*b.LENGTH)}),e[this.publicKeys.length*b.LENGTH]=this.threshold,e}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes(),r=t[t.length-1],i=[];for(let o=0;o<t.length-1;o+=b.LENGTH){let s=o;i.push(new b(t.subarray(s,s+b.LENGTH)))}return new pe({publicKeys:i,threshold:r})}static deserializeWithoutLength(e){let t=e.remaining(),r=e.deserializeFixedBytes(t),i=r[r.length-1],o=[];for(let s=0;s<r.length-1;s+=b.LENGTH){let a=s;o.push(new b(r.subarray(a,a+b.LENGTH)))}return new pe({publicKeys:o,threshold:i})}getIndex(e){return super.getIndex(e)}};pe.MAX_KEYS=32,pe.MIN_KEYS=2,pe.MIN_THRESHOLD=1;var Z=pe,le=class le extends Q{constructor(e){super();let{signatures:t,bitmap:r}=e;if(t.length>le.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${le.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=t,!(r instanceof Uint8Array))this.bitmap=le.createBitmap({bits:r});else{if(r.length!==le.BITMAP_LEN)throw new Error(`"bitmap" length should be ${le.BITMAP_LEN}`);this.bitmap=r}}toUint8Array(){let e=new Uint8Array(this.signatures.length*C.LENGTH+le.BITMAP_LEN);return this.signatures.forEach((t,r)=>{e.set(t.toUint8Array(),r*C.LENGTH)}),e.set(this.bitmap,this.signatures.length*C.LENGTH),e}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes(),r=t.subarray(t.length-4),i=[];for(let o=0;o<t.length-r.length;o+=C.LENGTH){let s=o;i.push(new C(t.subarray(s,s+C.LENGTH)))}return new le({signatures:i,bitmap:r})}static createBitmap(e){let{bits:t}=e,r=128,i=new Uint8Array([0,0,0,0]),o=new Set;return t.forEach((s,a)=>{if(s>=le.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${le.MAX_SIGNATURES_SUPPORTED-1}.`);if(o.has(s))throw new Error("Duplicate bits detected.");if(a>0&&s<=t[a-1])throw new Error("The bits need to be sorted in ascending order.");o.add(s);let c=Math.floor(s/8),d=i[c];d|=r>>s%8,i[c]=d}),i}};le.MAX_SIGNATURES_SUPPORTED=32,le.BITMAP_LEN=4;var Ie=le;var qn="Multiple possible deserializations found";function ed(n){let e=[b,x,Z,B,E,G,Ke],t;for(let r of e)try{let i=k.fromHex(n),o=r.deserialize(i);if(i.assertFinished(),t)throw new Error(`${qn}: ${n}`);t=o}catch(i){if(i instanceof Error&&i.message.includes(qn))throw i}if(!t)throw new Error(`Failed to deserialize public key: ${n}`);return t}function td(n){let e=[C,D,Ie,Ae,re,Le],t;for(let r of e)try{let i=k.fromHex(n),o=r.deserialize(i);if(i.assertFinished(),t)throw new Error(`${qn}: ${n}`);t=o}catch(i){if(i instanceof Error&&i.message.includes(qn))throw i}if(!t)throw new Error(`Failed to deserialize signature: ${n}`);return t}var q=class extends w{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return Ee.load(e);case 1:return $e.load(e);case 2:return ie.load(e);case 3:return De.load(e);case 4:return Vt.load(e);case 5:return yt.load(e);default:throw new Error(`Unknown variant index for AccountAuthenticator: ${t}`)}}isEd25519(){return this instanceof Ee}isMultiEd25519(){return this instanceof $e}isSingleKey(){return this instanceof ie}isMultiKey(){return this instanceof De}},Ee=class n extends q{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(0),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=b.deserialize(e),r=C.deserialize(e);return new n(t,r)}},$e=class n extends q{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(1),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=Z.deserialize(e),r=Ie.deserialize(e);return new n(t,r)}},ie=class n extends q{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(2),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=x.deserialize(e),r=D.deserialize(e);return new n(t,r)}},De=class n extends q{constructor(e,t){super(),this.public_keys=e,this.signatures=t}serialize(e){e.serializeU32AsUleb128(3),this.public_keys.serialize(e),this.signatures.serialize(e)}static load(e){let t=B.deserialize(e),r=Ae.deserialize(e);return new n(t,r)}},Vt=class n extends q{serialize(e){e.serializeU32AsUleb128(4)}static load(e){return new n}},yt=class n extends q{constructor(e,t,r,i){if(super(),!Dt(e))throw new Error(`Invalid function info ${e} passed into AccountAuthenticatorAbstraction`);this.functionInfo=e,this.abstractionSignature=r,this.signingMessageDigest=m.fromHexInput(m.fromHexInput(t).toUint8Array()),this.accountIdentity=i}serialize(e){e.serializeU32AsUleb128(5);let{moduleAddress:t,moduleName:r,functionName:i}=ue(this.functionInfo);u.fromString(t).serialize(e),e.serializeStr(r),e.serializeStr(i),this.accountIdentity?e.serializeU32AsUleb128(1):e.serializeU32AsUleb128(0),e.serializeBytes(this.signingMessageDigest.toUint8Array()),this.accountIdentity?e.serializeBytes(this.abstractionSignature):e.serializeFixedBytes(this.abstractionSignature),this.accountIdentity&&e.serializeBytes(this.accountIdentity)}static load(e){let t=u.deserialize(e),r=e.deserializeStr(),i=e.deserializeStr(),o=e.deserializeUleb128AsU32(),s=e.deserializeBytes();if(o===0){let a=e.deserializeFixedBytes(e.remaining());return new n(`${t}::${r}::${i}`,s,a)}if(o===1){let a=e.deserializeBytes(),c=e.deserializeBytes();return new n(`${t}::${r}::${i}`,s,a,c)}throw new Error(`Unknown variant index for AccountAuthenticatorAbstraction: ${o}`)}},Wn=class n extends w{constructor(e,t){super(),this.originalSigningMessage=m.fromHexInput(m.fromHexInput(e).toUint8Array()),this.functionInfo=t}serialize(e){e.serializeU32AsUleb128(0),e.serializeBytes(this.originalSigningMessage.toUint8Array());let{moduleAddress:t,moduleName:r,functionName:i}=ue(this.functionInfo);u.fromString(t).serialize(e),e.serializeStr(r),e.serializeStr(i)}static deserialize(e){let t=e.deserializeUleb128AsU32();if(t!==0)throw new Error(`Unknown variant index for AccountAbstractionMessage: ${t}`);let r=e.deserializeBytes(),i=u.deserialize(e),o=e.deserializeStr(),s=e.deserializeStr(),a=`${i}::${o}::${s}`;return new n(r,a)}};import{sha3_256 as xa}from"@noble/hashes/sha3";var dn=class n extends w{constructor(e,t){super(),this.address=e,this.name=t}static fromStr(e){let t=e.split("::");if(t.length!==2)throw new Error("Invalid module id.");return new n(u.fromString(t[0]),new z(t[1]))}serialize(e){this.address.serialize(e),this.name.serialize(e)}static deserialize(e){let t=u.deserialize(e),r=z.deserialize(e);return new n(t,r)}};var O=class n extends w{deserialize(e){let t=u.deserialize(e),r=z.deserialize(e),i=z.deserialize(e),o=e.deserializeVector(n);return new Re(t,r,i,o)}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return V.load(e);case 1:return oe.load(e);case 2:return W.load(e);case 3:return je.load(e);case 4:return R.load(e);case 5:return mt.load(e);case 6:return v.load(e);case 7:return f.load(e);case 8:return qe.load(e);case 9:return We.load(e);case 10:return Qe.load(e);case 255:return N.load(e);default:throw new Error(`Unknown variant index for TypeTag: ${t}`)}}isBool(){return this instanceof V}isAddress(){return this instanceof R}isGeneric(){return this instanceof N}isSigner(){return this instanceof mt}isVector(){return this instanceof v}isStruct(){return this instanceof f}isU8(){return this instanceof oe}isU16(){return this instanceof qe}isU32(){return this instanceof We}isU64(){return this instanceof W}isU128(){return this instanceof je}isU256(){return this instanceof Qe}isPrimitive(){return this instanceof mt||this instanceof R||this instanceof V||this instanceof oe||this instanceof qe||this instanceof We||this instanceof W||this instanceof je||this instanceof Qe}},V=class n extends O{toString(){return"bool"}serialize(e){e.serializeU32AsUleb128(0)}static load(e){return new n}},oe=class n extends O{toString(){return"u8"}serialize(e){e.serializeU32AsUleb128(1)}static load(e){return new n}},qe=class n extends O{toString(){return"u16"}serialize(e){e.serializeU32AsUleb128(8)}static load(e){return new n}},We=class n extends O{toString(){return"u32"}serialize(e){e.serializeU32AsUleb128(9)}static load(e){return new n}},W=class n extends O{toString(){return"u64"}serialize(e){e.serializeU32AsUleb128(2)}static load(e){return new n}},je=class n extends O{toString(){return"u128"}serialize(e){e.serializeU32AsUleb128(3)}static load(e){return new n}},Qe=class n extends O{toString(){return"u256"}serialize(e){e.serializeU32AsUleb128(10)}static load(e){return new n}},R=class n extends O{toString(){return"address"}serialize(e){e.serializeU32AsUleb128(4)}static load(e){return new n}},mt=class n extends O{toString(){return"signer"}serialize(e){e.serializeU32AsUleb128(5)}static load(e){return new n}},jn=class n extends O{constructor(t){super();this.value=t}toString(){return`&${this.value.toString()}`}serialize(t){t.serializeU32AsUleb128(254)}static load(t){let r=O.deserialize(t);return new n(r)}},N=class n extends O{constructor(t){super();this.value=t;if(t<0)throw new Error("Generic type parameter index cannot be negative")}toString(){return`T${this.value}`}serialize(t){t.serializeU32AsUleb128(255),t.serializeU32(this.value)}static load(t){let r=t.deserializeU32();return new n(r)}},v=class n extends O{constructor(t){super();this.value=t}toString(){return`vector<${this.value.toString()}>`}static u8(){return new n(new oe)}serialize(t){t.serializeU32AsUleb128(6),this.value.serialize(t)}static load(t){let r=O.deserialize(t);return new n(r)}},f=class n extends O{constructor(t){super();this.value=t}toString(){let t="";return this.value.typeArgs.length>0&&(t=`<${this.value.typeArgs.map(r=>r.toString()).join(", ")}>`),`${this.value.address.toString()}::${this.value.moduleName.identifier}::${this.value.name.identifier}${t}`}serialize(t){t.serializeU32AsUleb128(7),this.value.serialize(t)}static load(t){let r=Re.deserialize(t);return new n(r)}isTypeTag(t,r,i){return this.value.moduleName.identifier===r&&this.value.name.identifier===i&&this.value.address.equals(t)}isString(){return this.isTypeTag(u.ONE,"string","String")}isOption(){return this.isTypeTag(u.ONE,"option","Option")}isObject(){return this.isTypeTag(u.ONE,"object","Object")}isDelegationKey(){return this.isTypeTag(u.ONE,"permissioned_delegation","DelegationKey")}isRateLimiter(){return this.isTypeTag(u.ONE,"rate_limiter","RateLimiter")}},Re=class n extends w{constructor(e,t,r,i){super(),this.address=e,this.moduleName=t,this.name=r,this.typeArgs=i}serialize(e){e.serialize(this.address),e.serialize(this.moduleName),e.serialize(this.name),e.serializeVector(this.typeArgs)}static deserialize(e){let t=u.deserialize(e),r=z.deserialize(e),i=z.deserialize(e),o=e.deserializeVector(O);return new n(t,r,i,o)}};function Qd(){return new Re(u.ONE,new z("aptos_coin"),new z("AptosCoin"),[])}function I(){return new Re(u.ONE,new z("string"),new z("String"),[])}function Jd(n){return new Re(u.ONE,new z("option"),new z("Option"),[n])}function ge(n){return new Re(u.ONE,new z("object"),new z("Object"),[n])}function Ka(n){let e=n.deserializeUleb128AsU32();switch(e){case 0:return Se.deserialize(n);case 1:return fe.deserialize(n);case 2:return _t.deserialize(n);case 3:return u.deserialize(n);case 4:return K.deserialize(n,Se);case 5:return H.deserialize(n);case 6:return Ct.deserialize(n);case 7:return vt.deserialize(n);case 8:return Ut.deserialize(n);case 9:return Ei.deserialize(n);default:throw new Error(`Unknown variant index for ScriptTransactionArgument: ${e}`)}}var at=class extends w{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return Ht.load(e);case 2:return Lt.load(e);case 3:return $t.load(e);case 4:return Qn.deserialize(e);default:throw new Error(`Unknown variant index for TransactionPayload: ${t}`)}}},Ht=class n extends at{constructor(e){super(),this.script=e}serialize(e){e.serializeU32AsUleb128(0),this.script.serialize(e)}static load(e){let t=qt.deserialize(e);return new n(t)}},Lt=class n extends at{constructor(e){super(),this.entryFunction=e}serialize(e){e.serializeU32AsUleb128(2),this.entryFunction.serialize(e)}static load(e){let t=Je.deserialize(e);return new n(t)}},$t=class n extends at{constructor(e){super(),this.multiSig=e}serialize(e){e.serializeU32AsUleb128(3),this.multiSig.serialize(e)}static load(e){let t=pn.deserialize(e);return new n(t)}},Je=class n{constructor(e,t,r,i){this.module_name=e,this.function_name=t,this.type_args=r,this.args=i}static build(e,t,r,i){return new n(dn.fromStr(e),new z(t),r,i)}serialize(e){this.module_name.serialize(e),this.function_name.serialize(e),e.serializeVector(this.type_args),e.serializeU32AsUleb128(this.args.length),this.args.forEach(t=>{t.serializeForEntryFunction(e)})}static deserialize(e){let t=dn.deserialize(e),r=z.deserialize(e),i=e.deserializeVector(O),o=e.deserializeUleb128AsU32(),s=new Array;for(let a=0;a<o;a+=1){let c=e.deserializeUleb128AsU32(),d=xi.deserialize(e,c);s.push(d)}return new n(t,r,i,s)}},qt=class n{constructor(e,t,r){this.bytecode=e,this.type_args=t,this.args=r}serialize(e){e.serializeBytes(this.bytecode),e.serializeVector(this.type_args),e.serializeU32AsUleb128(this.args.length),this.args.forEach(t=>{t.serializeForScriptFunction(e)})}static deserialize(e){let t=e.deserializeBytes(),r=e.deserializeVector(O),i=e.deserializeUleb128AsU32(),o=new Array;for(let s=0;s<i;s+=1){let a=Ka(e);o.push(a)}return new n(t,r,o)}},pn=class n{constructor(e,t){this.multisig_address=e,this.transaction_payload=t}serialize(e){this.multisig_address.serialize(e),this.transaction_payload===void 0?e.serializeBool(!1):(e.serializeBool(!0),this.transaction_payload.serialize(e))}static deserialize(e){let t=u.deserialize(e),r=e.deserializeBool(),i;return r&&(i=ln.deserialize(e)),new n(t,i)}},ln=class n extends w{constructor(e){super(),this.transaction_payload=e}serialize(e){e.serializeU32AsUleb128(0),this.transaction_payload.serialize(e)}static deserialize(e){return e.deserializeUleb128AsU32(),new n(Je.deserialize(e))}},Qn=class extends at{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return ft.load(e);default:throw new Error(`Unknown variant index for TransactionInnerPayload: ${t}`)}}},ft=class n extends Qn{constructor(e,t){super(),this.executable=e,this.extra_config=t}serialize(e){e.serializeU32AsUleb128(4),e.serializeU32AsUleb128(0),this.executable.serialize(e),this.extra_config.serialize(e)}static load(e){let t=Wt.deserialize(e),r=Jn.deserialize(e);return new n(t,r)}},Wt=class{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return gn.load(e);case 1:return jt.load(e);case 2:return yn.load(e);default:throw new Error(`Unknown variant index for TransactionExecutable: ${t}`)}}},gn=class n extends Wt{constructor(e){super(),this.script=e}serialize(e){e.serializeU32AsUleb128(0),this.script.serialize(e)}static load(e){let t=qt.deserialize(e);return new n(t)}},jt=class n extends Wt{constructor(e){super(),this.entryFunction=e}serialize(e){e.serializeU32AsUleb128(1),this.entryFunction.serialize(e)}static load(e){let t=Je.deserialize(e);return new n(t)}},yn=class n extends Wt{serialize(e){e.serializeU32AsUleb128(2)}static load(e){return new n}},Jn=class{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return At.load(e);default:throw new Error(`Unknown variant index for TransactionExtraConfig: ${t}`)}}},At=class n extends Jn{constructor(e,t){super(),this.multisigAddress=e,this.replayProtectionNonce=t!==void 0?BigInt(t):void 0}serialize(e){e.serializeU32AsUleb128(0),e.serializeOption(this.multisigAddress),e.serializeOption(this.replayProtectionNonce!==void 0?new fe(this.replayProtectionNonce):void 0)}static load(e){let t=e.deserializeOption(u),r=e.deserializeOption(fe);return new n(t,r?.value)}};var he=class n extends w{constructor(e,t,r,i,o,s,a){super(),this.sender=e,this.sequence_number=t,this.payload=r,this.max_gas_amount=i,this.gas_unit_price=o,this.expiration_timestamp_secs=s,this.chain_id=a}serialize(e){this.sender.serialize(e),e.serializeU64(this.sequence_number),this.payload.serialize(e),e.serializeU64(this.max_gas_amount),e.serializeU64(this.gas_unit_price),e.serializeU64(this.expiration_timestamp_secs),this.chain_id.serialize(e)}static deserialize(e){let t=u.deserialize(e),r=e.deserializeU64(),i=at.deserialize(e),o=e.deserializeU64(),s=e.deserializeU64(),a=e.deserializeU64(),c=Nn.deserialize(e);return new n(t,r,i,o,s,a,c)}},Zn=class extends w{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return ht.load(e);case 1:return bt.load(e);default:throw new Error(`Unknown variant index for RawTransactionWithData: ${t}`)}}},ht=class n extends Zn{constructor(e,t){super(),this.raw_txn=e,this.secondary_signer_addresses=t}serialize(e){e.serializeU32AsUleb128(0),this.raw_txn.serialize(e),e.serializeVector(this.secondary_signer_addresses)}static load(e){let t=he.deserialize(e),r=e.deserializeVector(u);return new n(t,r)}},bt=class n extends Zn{constructor(e,t,r){super(),this.raw_txn=e,this.secondary_signer_addresses=t,this.fee_payer_address=r}serialize(e){e.serializeU32AsUleb128(1),this.raw_txn.serialize(e),e.serializeVector(this.secondary_signer_addresses),this.fee_payer_address.serialize(e)}static load(e){let t=he.deserialize(e),r=e.deserializeVector(u),i=u.deserialize(e);return new n(t,r,i)}};var Ze=class extends w{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return wt.load(e);case 1:return Qt.load(e);case 2:return Tt.load(e);case 3:return St.load(e);case 4:return ct.load(e);default:throw new Error(`Unknown variant index for TransactionAuthenticator: ${t}`)}}isEd25519(){return this instanceof wt}isMultiEd25519(){return this instanceof Qt}isMultiAgent(){return this instanceof Tt}isFeePayer(){return this instanceof St}isSingleSender(){return this instanceof ct}},wt=class n extends Ze{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(0),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=b.deserialize(e),r=C.deserialize(e);return new n(t,r)}},Qt=class n extends Ze{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(1),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=Z.deserialize(e),r=Ie.deserialize(e);return new n(t,r)}},Tt=class n extends Ze{constructor(e,t,r){super(),this.sender=e,this.secondary_signer_addresses=t,this.secondary_signers=r}serialize(e){e.serializeU32AsUleb128(2),this.sender.serialize(e),e.serializeVector(this.secondary_signer_addresses),e.serializeVector(this.secondary_signers)}static load(e){let t=q.deserialize(e),r=e.deserializeVector(u),i=e.deserializeVector(q);return new n(t,r,i)}},St=class n extends Ze{constructor(e,t,r,i){super(),this.sender=e,this.secondary_signer_addresses=t,this.secondary_signers=r,this.fee_payer=i}serialize(e){e.serializeU32AsUleb128(3),this.sender.serialize(e),e.serializeVector(this.secondary_signer_addresses),e.serializeVector(this.secondary_signers),this.fee_payer.address.serialize(e),this.fee_payer.authenticator.serialize(e)}static load(e){let t=q.deserialize(e),r=e.deserializeVector(u),i=e.deserializeVector(q),o=u.deserialize(e),s=q.deserialize(e),a={address:o,authenticator:s};return new n(t,r,i,a)}},ct=class n extends Ze{constructor(e){super(),this.sender=e}serialize(e){e.serializeU32AsUleb128(4),this.sender.serialize(e)}static load(e){let t=q.deserialize(e);return new n(t)}};var Ye=class n extends w{constructor(e,t){super(),this.raw_txn=e,this.authenticator=t}serialize(e){this.raw_txn.serialize(e),this.authenticator.serialize(e)}static deserialize(e){let t=he.deserialize(e),r=Ze.deserialize(e);return new n(t,r)}};var Yn=class n extends w{constructor(e,t){super(),this.rawTransaction=e,this.feePayerAddress=t}serialize(e){this.rawTransaction.serialize(e),this.feePayerAddress===void 0?e.serializeBool(!1):(e.serializeBool(!0),this.feePayerAddress.serialize(e))}static deserialize(e){let t=he.deserialize(e),r=e.deserializeBool(),i;return r&&(i=u.deserialize(e)),new n(t,i)}};var Xn=class n extends w{constructor(e,t,r){super(),this.rawTransaction=e,this.feePayerAddress=r,this.secondarySignerAddresses=t}serialize(e){this.rawTransaction.serialize(e),e.serializeVector(this.secondarySignerAddresses),this.feePayerAddress===void 0?e.serializeBool(!1):(e.serializeBool(!0),this.feePayerAddress.serialize(e))}static deserialize(e){let t=he.deserialize(e),r=e.deserializeVector(u),i=e.deserializeBool(),o;return i&&(o=u.deserialize(e)),new n(t,r,o)}};function er(n){return n.feePayerAddress?new bt(n.rawTransaction,n.secondarySignerAddresses??[],n.feePayerAddress):n.secondarySignerAddresses?new ht(n.rawTransaction,n.secondarySignerAddresses):n.rawTransaction}function Oe(n,e){let t=xa.create();if(!e.startsWith("APTOS::"))throw new Error(`Domain separator needs to start with 'APTOS::'. Provided - ${e}`);t.update(e);let r=t.digest(),i=n,o=new Uint8Array(r.length+i.length);return o.set(r),o.set(i,r.length),o}function dl(n){return Oe(n.bcsToBytes(),`APTOS::${n.constructor.name}`)}function Ce(n){let e=er(n);return n.feePayerAddress?Oe(e.bcsToBytes(),vr):n.secondarySignerAddresses?Oe(e.bcsToBytes(),vr):Oe(e.bcsToBytes(),Ni)}var Y=class n{constructor(e){this.signingScheme=0;let{privateKey:t,address:r}=e;this.privateKey=t,this.publicKey=t.publicKey(),this.accountAddress=r?u.from(r):this.publicKey.authKey().derivedAddress()}static generate(){let e=L.generate();return new n({privateKey:e})}static fromDerivationPath(e){let{path:t,mnemonic:r}=e,i=L.fromDerivationPath(t,r);return new n({privateKey:i})}verifySignature(e){return this.publicKey.verifySignature(e)}async verifySignatureAsync(e){return this.publicKey.verifySignatureAsync({...e,signature:e.signature})}signWithAuthenticator(e){return new Ee(this.publicKey,this.privateKey.sign(e))}signTransactionWithAuthenticator(e){return new Ee(this.publicKey,this.signTransaction(e))}sign(e){return this.privateKey.sign(e)}signTransaction(e){return this.sign(Ce(e))}};function Mr(n){return typeof n=="object"&&n!==null&&"getAnyPublicKey"in n&&typeof n.getAnyPublicKey=="function"}var se=class n{constructor(e){this.signingScheme=2;let{privateKey:t,address:r}=e;this.privateKey=t,this.publicKey=new x(t.publicKey()),this.accountAddress=r?u.from(r):this.publicKey.authKey().derivedAddress()}getAnyPublicKey(){return this.publicKey}static generate(e={}){let{scheme:t=0}=e,r;switch(t){case 0:r=L.generate();break;case 2:r=He.generate();break;default:throw new Error(`Unsupported signature scheme ${t}`)}return new n({privateKey:r})}static fromDerivationPath(e){let{scheme:t=0,path:r,mnemonic:i}=e,o;switch(t){case 0:o=L.fromDerivationPath(r,i);break;case 2:o=He.fromDerivationPath(r,i);break;default:throw new Error(`Unsupported signature scheme ${t}`)}return new n({privateKey:o})}verifySignature(e){return this.publicKey.verifySignature(e)}async verifySignatureAsync(e){return this.publicKey.verifySignatureAsync({...e,signature:e.signature})}signWithAuthenticator(e){return new ie(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new ie(this.publicKey,this.signTransaction(e))}sign(e){return new D(this.privateKey.sign(e))}signTransaction(e){return this.sign(Ce(e))}static fromEd25519Account(e){return new n({privateKey:e.privateKey,address:e.accountAddress})}};var Xe=class{static generate(e={}){let{scheme:t=0,legacy:r=!0}=e;return t===0&&r?Y.generate():se.generate({scheme:t})}static fromPrivateKey(e){let{privateKey:t,address:r,legacy:i=!0}=e;return t instanceof L&&i?new Y({privateKey:t,address:r}):new se({privateKey:t,address:r})}static fromPrivateKeyAndAddress(e){return this.fromPrivateKey(e)}static fromDerivationPath(e){let{scheme:t=0,mnemonic:r,path:i,legacy:o=!0}=e;return t===0&&o?Y.fromDerivationPath({mnemonic:r,path:i}):se.fromDerivationPath({scheme:t,mnemonic:r,path:i})}static authKey(e){let{publicKey:t}=e;return t.authKey()}verifySignature(e){return this.publicKey.verifySignature(e)}async verifySignatureAsync(e){return this.publicKey.verifySignatureAsync(e)}};import{randomBytes as Ca}from"@noble/hashes/utils";var va=1209600,Jt=class Jt extends w{constructor(e){super();let{privateKey:t,expiryDateSecs:r,blinder:i}=e;this.privateKey=t,this.publicKey=new ut(t.publicKey()),this.expiryDateSecs=r||Hi(Ve()+va),this.blinder=i!==void 0?m.fromHexInput(i).toUint8Array():_a();let o=Rn(this.publicKey.bcsToBytes(),93);o.push(BigInt(this.expiryDateSecs)),o.push(Ft(this.blinder));let s=zt(o);this.nonce=s.toString()}getPublicKey(){return this.publicKey}isExpired(){return Math.floor(Date.now()/1e3)>this.expiryDateSecs}serialize(e){e.serializeU32AsUleb128(this.publicKey.variant),e.serializeBytes(this.privateKey.toUint8Array()),e.serializeU64(this.expiryDateSecs),e.serializeFixedBytes(this.blinder)}static deserialize(e){let t=e.deserializeUleb128AsU32(),r;switch(t){case 0:r=L.deserialize(e);break;default:throw new Error(`Unknown variant index for EphemeralPublicKey: ${t}`)}let i=e.deserializeU64(),o=e.deserializeFixedBytes(31);return new Jt({privateKey:r,expiryDateSecs:Number(i),blinder:o})}static fromBytes(e){return Jt.deserialize(new k(e))}static generate(e){let t;switch(e?.scheme){case 0:default:t=L.generate()}return new Jt({privateKey:t,expiryDateSecs:e?.expiryDateSecs})}sign(e){if(this.isExpired())throw new Error("EphemeralKeyPair has expired");return new Ne(this.privateKey.sign(e))}};Jt.BLINDER_LENGTH=31;var Pt=Jt;function _a(){return Ca(Pt.BLINDER_LENGTH)}import ka from"eventemitter3";import{jwtDecode as Fa}from"jwt-decode";function nr(n){return n!=null&&typeof n.checkKeylessAccountValidity=="function"}var Zt=class Zt extends w{constructor(t){super();this.signingScheme=2;let{address:r,ephemeralKeyPair:i,publicKey:o,uidKey:s,uidVal:a,aud:c,pepper:d,proof:l,proofFetchCallback:g,jwt:p,verificationKeyHash:y}=t;if(this.ephemeralKeyPair=i,this.publicKey=o,this.accountAddress=r?u.from(r):this.publicKey.authKey().derivedAddress(),this.uidKey=s,this.uidVal=a,this.aud=c,this.jwt=p,this.emitter=new ka,this.proofOrPromise=l,l instanceof ye)this.proof=l;else{if(g===void 0)throw new Error("Must provide callback for async proof fetch");this.emitter.on("proofFetchFinish",async U=>{await g(U),this.emitter.removeAllListeners()}),this.init(l)}let h=m.fromHexInput(d).toUint8Array();if(h.length!==Zt.PEPPER_LENGTH)throw new Error(`Pepper length in bytes should be ${Zt.PEPPER_LENGTH}`);if(this.pepper=h,y!==void 0){if(m.hexInputToUint8Array(y).length!==32)throw new Error("verificationKeyHash must be 32 bytes");this.verificationKeyHash=m.hexInputToUint8Array(y)}}getAnyPublicKey(){return new x(this.publicKey)}async init(t){try{this.proof=await t,this.emitter.emit("proofFetchFinish",{status:"Success"})}catch(r){r instanceof Error?this.emitter.emit("proofFetchFinish",{status:"Failed",error:r.toString()}):this.emitter.emit("proofFetchFinish",{status:"Failed",error:"Unknown"})}}serialize(t){if(this.accountAddress.serialize(t),t.serializeStr(this.jwt),t.serializeStr(this.uidKey),t.serializeFixedBytes(this.pepper),this.ephemeralKeyPair.serialize(t),this.proof===void 0)throw new Error("Cannot serialize - proof undefined");this.proof.serialize(t),t.serializeOption(this.verificationKeyHash,32)}static partialDeserialize(t){let r=u.deserialize(t),i=t.deserializeStr(),o=t.deserializeStr(),s=t.deserializeFixedBytes(31),a=Pt.deserialize(t),c=ye.deserialize(t),d=t.deserializeOption("fixedBytes",32);return{address:r,jwt:i,uidKey:o,pepper:s,ephemeralKeyPair:a,proof:c,verificationKeyHash:d}}isExpired(){return this.ephemeralKeyPair.isExpired()}signWithAuthenticator(t){let r=new D(this.sign(t)),i=new x(this.publicKey);return new ie(i,r)}signTransactionWithAuthenticator(t){let r=new D(this.signTransaction(t)),i=new x(this.publicKey);return new ie(i,r)}async waitForProofFetch(){this.proofOrPromise instanceof Promise&&await this.proofOrPromise}async checkKeylessAccountValidity(t){if(this.isExpired())throw S.fromErrorType({type:0});if(await this.waitForProofFetch(),this.proof===void 0)throw S.fromErrorType({type:2});let r=Fa(this.jwt,{header:!0});if(r.kid===void 0)throw S.fromErrorType({type:12,details:"checkKeylessAccountValidity failed. JWT is missing 'kid' in header. This should never happen."});if(this.verificationKeyHash!==void 0){let{verificationKey:i}=await Xt({aptosConfig:t});if(m.hexInputToString(i.hash())!==m.hexInputToString(this.verificationKeyHash))throw S.fromErrorType({type:4})}else console.warn("[Aptos SDK] The verification key hash was not set. Proof may be invalid if the verification key has rotated.");await Zt.fetchJWK({aptosConfig:t,publicKey:this.publicKey,kid:r.kid})}sign(t){let{expiryDateSecs:r}=this.ephemeralKeyPair;if(this.isExpired())throw S.fromErrorType({type:0});if(this.proof===void 0)throw S.fromErrorType({type:1,details:"Proof not found - make sure to call `await account.checkKeylessAccountValidity()` before signing."});let i=this.ephemeralKeyPair.getPublicKey(),o=this.ephemeralKeyPair.sign(t);return new re({jwtHeader:Li(this.jwt.split(".")[0]),ephemeralCertificate:new Yt(this.proof,0),expiryDateSecs:r,ephemeralPublicKey:i,ephemeralSignature:o})}signTransaction(t){if(this.proof===void 0)throw S.fromErrorType({type:1,details:"Proof not found - make sure to call `await account.checkKeylessAccountValidity()` before signing."});let r=er(t),o=new tr(r,this.proof.proof).hash();return this.sign(o)}getSigningMessage(t){if(this.proof===void 0)throw S.fromErrorType({type:1,details:"Proof not found - make sure to call `await account.checkKeylessAccountValidity()` before signing."});let r=er(t);return new tr(r,this.proof.proof).hash()}verifySignature(t){return this.publicKey.verifySignature(t)}async verifySignatureAsync(t){return this.publicKey.verifySignatureAsync({...t})}static async fetchJWK(t){return Br(t)}};Zt.PEPPER_LENGTH=31;var me=Zt,tr=class extends w{constructor(t,r){super();this.domainSeparator="APTOS::TransactionAndProof";this.transaction=t,this.proof=r}serialize(t){t.serializeFixedBytes(this.transaction.bcsToBytes()),t.serializeOption(this.proof)}hash(){return Oe(this.bcsToBytes(),this.domainSeparator)}};var be=class n extends me{constructor(e){let t=E.create(e);super({publicKey:t,...e}),this.publicKey=t}serialize(e){super.serialize(e)}static deserialize(e){let{address:t,proof:r,ephemeralKeyPair:i,jwt:o,uidKey:s,pepper:a,verificationKeyHash:c}=me.partialDeserialize(e),{iss:d,aud:l,uidVal:g}=et({jwt:o,uidKey:s});return new n({address:t,proof:r,ephemeralKeyPair:i,iss:d,uidKey:s,uidVal:g,aud:l,pepper:a,jwt:o,verificationKeyHash:c})}static fromBytes(e){return n.deserialize(new k(m.hexInputToUint8Array(e)))}static create(e){let{address:t,proof:r,jwt:i,ephemeralKeyPair:o,pepper:s,uidKey:a="sub",proofFetchCallback:c,verificationKey:d,verificationKeyHash:l}=e;if(l&&d)throw new Error("Cannot provide both verificationKey and verificationKeyHash");let{iss:g,aud:p,uidVal:y}=et({jwt:i,uidKey:a});return new n({address:t,proof:r,ephemeralKeyPair:o,iss:g,uidKey:a,uidVal:y,aud:p,pepper:s,jwt:i,proofFetchCallback:c,verificationKeyHash:l??(d?d.hash():void 0)})}};var ve=class n extends me{constructor(e){let t=G.create(e);super({publicKey:t,...e}),this.publicKey=t,this.audless=e.audless??!1}serialize(e){super.serialize(e),this.publicKey.jwkAddress.serialize(e)}static deserialize(e){let{address:t,proof:r,ephemeralKeyPair:i,jwt:o,uidKey:s,pepper:a,verificationKeyHash:c}=me.partialDeserialize(e),d=u.deserialize(e),{iss:l,aud:g,uidVal:p}=et({jwt:o,uidKey:s});return new n({address:t,proof:r,ephemeralKeyPair:i,iss:l,uidKey:s,uidVal:p,aud:g,pepper:a,jwt:o,verificationKeyHash:c,jwkAddress:d})}static fromBytes(e){return n.deserialize(k.fromHex(e))}static create(e){let{address:t,proof:r,jwt:i,ephemeralKeyPair:o,pepper:s,jwkAddress:a,uidKey:c="sub",proofFetchCallback:d,verificationKey:l,verificationKeyHash:g}=e;if(g&&l)throw new Error("Cannot provide both verificationKey and verificationKeyHash");let{iss:p,aud:y,uidVal:h}=et({jwt:i,uidKey:c});return new n({address:t,proof:r,ephemeralKeyPair:o,iss:p,uidKey:c,uidVal:h,aud:y,pepper:s,jwkAddress:u.from(a),jwt:i,proofFetchCallback:d,verificationKeyHash:g??(l?l.hash():void 0)})}};var tt=class n{constructor(e){this.signingScheme=3;let{multiKey:t,address:r}=e,i=e.signers.map(a=>a instanceof Y?se.fromEd25519Account(a):a);if(t.signaturesRequired>i.length)throw new Error(`Not enough signers provided to satisfy the required signatures. Need ${t.signaturesRequired} signers, but only ${i.length} provided`);if(t.signaturesRequired<i.length)throw new Error(`More signers provided than required. Need ${t.signaturesRequired} signers, but ${i.length} provided`);this.publicKey=t,this.accountAddress=r?u.from(r):this.publicKey.authKey().derivedAddress();let o=[];for(let a of i)o.push(this.publicKey.getIndex(a.getAnyPublicKey()));let s=i.map((a,c)=>[a,o[c]]);s.sort((a,c)=>a[1]-c[1]),this.signers=s.map(a=>a[0]),this.signerIndicies=s.map(a=>a[1]),this.signaturesBitmap=this.publicKey.createBitmap({bits:o})}static fromPublicKeysAndSigners(e){let{address:t,publicKeys:r,signaturesRequired:i,signers:o}=e,s=new B({publicKeys:r,signaturesRequired:i});return new n({multiKey:s,signers:o,address:t})}static isMultiKeySigner(e){return e instanceof n}signWithAuthenticator(e){return new De(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new De(this.publicKey,this.signTransaction(e))}async waitForProofFetch(){let t=this.signers.filter(r=>r instanceof me).map(async r=>r.waitForProofFetch());await Promise.all(t)}async checkKeylessAccountValidity(e){let r=this.signers.filter(i=>i instanceof me).map(i=>i.checkKeylessAccountValidity(e));await Promise.all(r)}sign(e){let t=[];for(let r of this.signers)t.push(r.sign(e));return new Ae({signatures:t,bitmap:this.signaturesBitmap})}signTransaction(e){let t=[];for(let r of this.signers)t.push(r.signTransaction(e));return new Ae({signatures:t,bitmap:this.signaturesBitmap})}verifySignature(e){return this.publicKey.verifySignature(e)}async verifySignatureAsync(e){return await this.publicKey.verifySignatureAsync(e)}};var mn=class{constructor(e){this.signingScheme=1;let{signers:t,publicKey:r,address:i}=e;if(this.publicKey=r,this.accountAddress=i?u.from(i):this.publicKey.authKey().derivedAddress(),r.threshold>t.length)throw new Error(`Not enough signers provided to satisfy the required signatures. Need ${r.threshold} signers, but only ${t.length} provided`);if(r.threshold<t.length)throw new Error(`More signers provided than required. Need ${r.threshold} signers, but ${t.length} provided`);let o=[];for(let a of t)o.push(this.publicKey.getIndex(a.publicKey()));let s=t.map((a,c)=>[a,o[c]]);s.sort((a,c)=>a[1]-c[1]),this.signers=s.map(a=>a[0]),this.signerIndices=s.map(a=>a[1]),this.signaturesBitmap=this.publicKey.createBitmap({bits:o})}verifySignature(e){return this.publicKey.verifySignature(e)}async verifySignatureAsync(e){return this.publicKey.verifySignatureAsync({...e,signature:e.signature})}signWithAuthenticator(e){return new $e(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new $e(this.publicKey,this.signTransaction(e))}sign(e){let t=[];for(let r of this.signers)t.push(r.sign(e));return new Ie({signatures:t,bitmap:this.signaturesBitmap})}signTransaction(e){return this.sign(Ce(e))}};function ko(n){let e=n.deserializeUleb128AsU32();if(!Object.values(j).includes(e))throw new Error(`Deserialization of Account failed: SigningScheme variant ${e} is invalid`);return{address:u.deserialize(n),signingScheme:e}}function Fo(n,e){if(e.serializeStr(n.jwt),e.serializeStr(n.uidKey),e.serializeFixedBytes(n.pepper),n.ephemeralKeyPair.serialize(e),n.proof===void 0)throw new Error("Cannot serialize - proof undefined");n.proof.serialize(e),e.serializeOption(n.verificationKeyHash,32)}function zo(n){let e=n.deserializeStr(),t=n.deserializeStr(),r=n.deserializeFixedBytes(31),i=Pt.deserialize(n),o=ye.deserialize(n),s=n.deserializeOption("fixedBytes",32);return{jwt:e,uidKey:t,pepper:r,ephemeralKeyPair:i,proof:o,verificationKeyHash:s}}var Do;(g=>{function n(p){let y=new ee;switch(y.serializeU32AsUleb128(p.signingScheme),p.accountAddress.serialize(y),p.signingScheme){case 0:return p.privateKey.serialize(y),y.toUint8Array();case 2:{if(!Mr(p))throw new Error("Account is not a SingleKeySigner");let h=p.getAnyPublicKey();switch(y.serializeU32AsUleb128(h.variant),h.variant){case 3:return Fo(p,y),y.toUint8Array();case 4:{let U=p;return Fo(U,y),U.publicKey.jwkAddress.serialize(y),y.serializeBool(U.audless),y.toUint8Array()}case 1:case 0:return p.privateKey.serialize(y),y.toUint8Array();default:throw new Error(`Invalid public key variant: ${h.variant}`)}}case 3:{let h=p;return h.publicKey.serialize(y),y.serializeU32AsUleb128(h.signers.length),h.signers.forEach(U=>{y.serializeFixedBytes(n(U))}),y.toUint8Array()}default:throw new Error(`Deserialization of Account failed: invalid signingScheme value ${p.signingScheme}`)}}g.toBytes=n;function e(p){return m.hexInputToStringWithoutPrefix(n(p))}g.toHexStringWithoutPrefix=e;function t(p){return m.hexInputToString(n(p))}g.toHexString=t;function r(p){let{address:y,signingScheme:h}=ko(p);switch(h){case 0:{let U=L.deserialize(p);return new Y({privateKey:U,address:y})}case 2:{let U=p.deserializeUleb128AsU32();switch(U){case 0:{let M=L.deserialize(p);return new se({privateKey:M,address:y})}case 1:{let M=He.deserialize(p);return new se({privateKey:M,address:y})}case 3:{let M=zo(p),X=et(M);return new be({...M,...X})}case 4:{let M=zo(p),X=u.deserialize(p),Me=p.deserializeBool(),ot=et(M);return new ve({...M,...ot,jwkAddress:X,audless:Me})}default:throw new Error(`Unsupported public key variant ${U}`)}}case 3:{let U=B.deserialize(p),M=p.deserializeUleb128AsU32(),X=new Array;for(let Me=0;Me<M;Me+=1){let ot=r(p);if(!Mr(ot)&&!(ot instanceof Y))throw new Error("Deserialization of MultiKeyAccount failed. Signer is not a SingleKeySigner or Ed25519Account");X.push(ot)}return new tt({multiKey:U,signers:X,address:y})}default:throw new Error(`Deserialization of Account failed: invalid signingScheme value ${h}`)}}g.deserialize=r;function i(p){let y=d(p);if(!(y instanceof be))throw new Error("Deserialization of KeylessAccount failed");return y}g.keylessAccountFromHex=i;function o(p){let y=d(p);if(!(y instanceof ve))throw new Error("Deserialization of FederatedKeylessAccount failed");return y}g.federatedKeylessAccountFromHex=o;function s(p){let y=d(p);if(!(y instanceof tt))throw new Error("Deserialization of MultiKeyAccount failed");return y}g.multiKeyAccountFromHex=s;function a(p){let y=d(p);if(!(y instanceof se))throw new Error("Deserialization of SingleKeyAccount failed");return y}g.singleKeyAccountFromHex=a;function c(p){let y=d(p);if(!(y instanceof Y))throw new Error("Deserialization of Ed25519Account failed");return y}g.ed25519AccountFromHex=c;function d(p){return r(k.fromHex(p))}g.fromHex=d;function l(p){return d(p)}g.fromBytes=l})(Do||(Do={}));import{sha3_256 as Ro}from"@noble/hashes/sha3";var rr=class n extends Xe{constructor({signer:t,accountAddress:r,authenticationFunction:i}){super();this.signingScheme=2;if(!Dt(i))throw new Error(`Invalid authentication function ${i} passed into AbstractedAccount`);this.authenticationFunction=i,this.accountAddress=r,this.publicKey=new Ci(this.accountAddress),this.sign=o=>new Ir(t(o))}static fromPermissionedSigner({signer:t,accountAddress:r}){return new n({signer:i=>{let o=new ee;return t.publicKey.serialize(o),t.sign(i).serialize(o),o.toUint8Array()},accountAddress:r??t.accountAddress,authenticationFunction:"0x1::permissioned_delegation::authenticate"})}static generateAccountAbstractionMessage(t,r){let i=new Wn(t,r);return Oe(i.bcsToBytes(),Gi)}signWithAuthenticator(t){return new yt(this.authenticationFunction,Ro(t),this.sign(Ro(t)).toUint8Array())}signTransactionWithAuthenticator(t){let r=n.generateAccountAbstractionMessage(Ce(t),this.authenticationFunction);return this.signWithAuthenticator(r)}signTransaction(t){return this.sign(Ce(t))}setSigner(t){this.sign=r=>new Ir(t(r))}};import{sha3_256 as Vr}from"@noble/hashes/sha3";var fn=class fn extends rr{constructor({signer:e,authenticationFunction:t,abstractPublicKey:r}){let i=new u(fn.computeAccountAddress(t,r));super({accountAddress:i,signer:e,authenticationFunction:t}),this.abstractPublicKey=r}static computeAccountAddress(e,t){if(!Dt(e))throw new Error(`Invalid authentication function ${e} passed into DerivableAbstractedAccount`);let[r,i,o]=e.split("::"),s=Vr.create(),a=new ee;u.fromString(r).serialize(a),a.serializeStr(i),a.serializeStr(o),s.update(a.toUint8Array());let c=new ee;return c.serializeBytes(t),s.update(c.toUint8Array()),s.update(new Uint8Array([fn.ADDRESS_DOMAIN_SEPERATOR])),s.digest()}signWithAuthenticator(e){return new yt(this.authenticationFunction,Vr(e),this.sign(Vr(e)).value,this.abstractPublicKey)}};fn.ADDRESS_DOMAIN_SEPERATOR=5;var Oo=fn;import{sha3_256 as La}from"@noble/hashes/sha3";function No(n){return!!n.match(/^[_a-zA-Z0-9]+$/)}function Go(n){return!!n.match(/\s/)}function za(n){return!!n.match(/^T[0-9]+$/)}function Da(n){return!!n.match(/^&.+$/)}function Ra(n){switch(n){case"signer":case"address":case"bool":case"u8":case"u16":case"u32":case"u64":case"u128":case"u256":return!0;default:return!1}}function Oa(n,e){let t=e;for(;t<n.length;t+=1){let r=n[t];if(!Go(r))break}return t}var Na=(h=>(h.InvalidTypeTag="unknown type",h.UnexpectedGenericType="unexpected generic type",h.UnexpectedTypeArgumentClose="unexpected '>'",h.UnexpectedWhitespaceCharacter="unexpected whitespace character",h.UnexpectedComma="unexpected ','",h.TypeArgumentCountMismatch="type argument count doesn't match expected amount",h.MissingTypeArgumentClose="no matching '>' for '<'",h.MissingTypeArgument="no type argument before ','",h.UnexpectedPrimitiveTypeArguments="primitive types not expected to have type arguments",h.UnexpectedVectorTypeArgumentCount="vector type expected to have exactly one type argument",h.UnexpectedStructFormat="unexpected struct format, must be of the form 0xaddress::module_name::struct_name",h.InvalidModuleNameCharacter="module name must only contain alphanumeric or '_' characters",h.InvalidStructNameCharacter="struct name must only contain alphanumeric or '_' characters",h.InvalidAddress="struct address must be valid",h))(Na||{}),$=class extends Error{constructor(e,t){super(`Failed to parse typeTag '${e}', ${t}`)}};function _e(n,e){let t=e?.allowGenerics??!1,r=[],i=[],o=[],s=0,a="",c=1;for(;s<n.length;){let d=n[s];if(d==="<")r.push({savedExpectedTypes:c,savedStr:a,savedTypes:o}),a="",o=[],c=1;else if(d===">"){if(a!==""){let h=An(a,i,t);o.push(h)}let l=r.pop();if(l===void 0)throw new $(n,"unexpected '>'");if(c!==o.length)throw new $(n,"type argument count doesn't match expected amount");let{savedStr:g,savedTypes:p,savedExpectedTypes:y}=l;i=o,o=p,a=g,c=y}else if(d===","){if(r.length===0)throw new $(n,"unexpected ','");if(a.length===0)throw new $(n,"no type argument before ','");let l=An(a,i,t);i=[],o.push(l),a="",c+=1}else if(Go(d)){let l=!1;if(a.length!==0){let p=An(a,i,t);i=[],o.push(p),a="",l=!0}s=Oa(n,s);let g=n[s];if(s<n.length&&l&&g!==","&&g!==">")throw new $(n,"unexpected whitespace character");continue}else a+=d;s+=1}if(r.length>0)throw new $(n,"no matching '>' for '<'");switch(o.length){case 0:return An(a,i,t);case 1:if(a==="")return o[0];throw new $(n,"unexpected ','");default:throw new $(n,"unexpected whitespace character")}}function An(n,e,t){let r=n.trim(),i=r.toLowerCase();if(Ra(i)&&e.length>0)throw new $(n,"primitive types not expected to have type arguments");switch(r.toLowerCase()){case"signer":return new mt;case"bool":return new V;case"address":return new R;case"u8":return new oe;case"u16":return new qe;case"u32":return new We;case"u64":return new W;case"u128":return new je;case"u256":return new Qe;case"vector":if(e.length!==1)throw new $(n,"vector type expected to have exactly one type argument");return new v(e[0]);default:if(Da(r)){let a=r.substring(1);return new jn(An(a,e,t))}if(za(r)){if(t)return new N(Number(r.split("T")[1]));throw new $(n,"unexpected generic type")}if(!r.match(/:/))throw new $(n,"unknown type");let o=r.split("::");if(o.length!==3)throw new $(n,"unexpected struct format, must be of the form 0xaddress::module_name::struct_name");let s;try{s=u.fromString(o[0])}catch{throw new $(n,"struct address must be valid")}if(!No(o[1]))throw new $(n,"module name must only contain alphanumeric or '_' characters");if(!No(o[2]))throw new $(n,"struct name must only contain alphanumeric or '_' characters");return new f(new Re(s,new z(o[1]),new z(o[2]),e))}}function Mo(n){return typeof n=="boolean"}function nt(n){return typeof n=="string"}function Ga(n){return typeof n=="number"}function ir(n){if(Ga(n))return n;if(nt(n)&&n!=="")return Number.parseInt(n,10)}function or(n){return typeof n=="number"||typeof n=="bigint"||typeof n=="string"}function Bo(n){return n==null}function Vo(n){return Hr(n)||$r(n)||qr(n)||Wr(n)||jr(n)||Qr(n)||Jr(n)||sr(n)||Lr(n)||Ma(n)||n instanceof K||n instanceof te}function Hr(n){return n instanceof H}function sr(n){return n instanceof u}function Lr(n){return n instanceof F}function Ma(n){return n instanceof Et}function $r(n){return n instanceof Se}function qr(n){return n instanceof Ct}function Wr(n){return n instanceof vt}function jr(n){return n instanceof fe}function Qr(n){return n instanceof _t}function Jr(n){return n instanceof Ut}function Ho(n){return"bytecode"in n}function _(n,e){throw new Error(`Type mismatch for argument ${e}, expected '${n}'`)}function Lo(n){let e=n.params.findIndex(t=>t!=="signer"&&t!=="&signer");return e<0?n.params.length:e}var Ba=new TextEncoder;function ar(n){return n?.map(e=>nt(e)?_e(e):e)??[]}async function Va(n,e,t){return(await cr({aptosConfig:t,accountAddress:n,moduleName:e})).abi}async function Yr(n,e,t,r){let i=await Va(n,e,r);if(!i)throw new Error(`Could not find module ABI for '${n}::${e}'`);return i.exposed_functions.find(o=>o.name===t)}async function hm(n,e,t,r){let i=await Yr(n,e,t,r);if(!i)throw new Error(`Could not find function ABI for '${n}::${e}::${t}'`);let o=[];for(let s=0;s<i.params.length;s+=1)o.push(_e(i.params[s],{allowGenerics:!0}));return{typeParameters:i.generic_type_params,parameters:o}}async function $o(n,e,t,r){let i=await Yr(n,e,t,r);if(!i)throw new Error(`Could not find entry function ABI for '${n}::${e}::${t}'`);if(!i.is_entry)throw new Error(`'${n}::${e}::${t}' is not an entry function`);let o=Lo(i),s=[];for(let a=o;a<i.params.length;a+=1)s.push(_e(i.params[a],{allowGenerics:!0}));return{signers:o,typeParameters:i.generic_type_params,parameters:s}}async function qo(n,e,t,r){let i=await Yr(n,e,t,r);if(!i)throw new Error(`Could not find view function ABI for '${n}::${e}::${t}'`);if(!i.is_view)throw new Error(`'${n}::${e}::${t}' is not an view function`);let o=[];for(let a=0;a<i.params.length;a+=1)o.push(_e(i.params[a],{allowGenerics:!0}));let s=[];for(let a=0;a<i.return.length;a+=1)s.push(_e(i.return[a],{allowGenerics:!0}));return{typeParameters:i.generic_type_params,parameters:o,returnTypes:s}}function Xr(n,e,t,r,i,o){let s;if("exposed_functions"in e){let a=e.exposed_functions.find(c=>c.name===n);if(!a)throw new Error(`Could not find function ABI for '${e.address}::${e.name}::${n}'`);if(r>=a.params.length)throw new Error(`Too many arguments for '${n}', expected ${a.params.length}`);s=_e(a.params[r],{allowGenerics:!0})}else{if(r>=e.parameters.length)throw new Error(`Too many arguments for '${n}', expected ${e.parameters.length}`);s=e.parameters[r]}return Kt(t,s,r,i,"exposed_functions"in e?e:void 0,o)}function Kt(n,e,t,r,i,o){return Vo(n)?(Zr(e,n,t),n):Ha(n,e,t,r,i,o)}function Ha(n,e,t,r,i,o){if(e.isBool()){if(Mo(n))return new H(n);if(nt(n)){if(n==="true")return new H(!0);if(n==="false")return new H(!1)}_("boolean",t)}if(e.isAddress()){if(nt(n))return u.fromString(n);if(n&&typeof n=="object"&&"data"in n&&n.data instanceof Uint8Array)return new u(n.data);_("string | AccountAddress",t)}if(e.isU8()){let s=ir(n);if(s!==void 0)return new Se(s);_("number | string",t)}if(e.isU16()){let s=ir(n);if(s!==void 0)return new Ct(s);_("number | string",t)}if(e.isU32()){let s=ir(n);if(s!==void 0)return new vt(s);_("number | string",t)}if(e.isU64()){if(or(n))return new fe(BigInt(n));_("bigint | number | string",t)}if(e.isU128()){if(or(n))return new _t(BigInt(n));_("bigint | number | string",t)}if(e.isU256()){if(or(n))return new Ut(BigInt(n));_("bigint | number | string",t)}if(e.isGeneric()){let s=e.value;if(s<0||s>=r.length)throw new Error(`Generic argument ${e.toString()} is invalid for argument ${t}`);return Kt(n,r[s],t,r,i)}if(e.isVector()){if(e.value.isU8()){if(nt(n))return K.U8(Ba.encode(n));if(n instanceof Uint8Array)return K.U8(n);if(n instanceof ArrayBuffer)return K.U8(new Uint8Array(n))}if(nt(n)&&n.startsWith("["))return Kt(JSON.parse(n),e,t,r);if(Array.isArray(n))return new K(n.map(s=>Kt(s,e.value,t,r,i)));throw new Error(`Type mismatch for argument ${t}, type '${e.toString()}'`)}if(e.isStruct()){if(e.isString()){if(nt(n))return new F(n);_("string",t)}if(e.isObject()){if(nt(n))return u.fromString(n);if(n&&typeof n=="object"&&"data"in n&&n.data instanceof Uint8Array)return new u(n.data);_("string | AccountAddress",t)}if(e.isDelegationKey()||e.isRateLimiter()){if(n instanceof Uint8Array)return new Et(n);_("Uint8Array",t)}if(e.isOption()){if(Bo(n)){let a=e.value.typeArgs[0];return a instanceof V?new te(null):a instanceof R?new te(null):a instanceof oe?new te(null):a instanceof qe?new te(null):a instanceof We?new te(null):a instanceof W?new te(null):a instanceof je?new te(null):a instanceof Qe?new te(null):new te(null)}return new te(Kt(n,e.value.typeArgs[0],t,r,i))}if(i?.structs.find(a=>a.name===e.value.name.identifier)?.fields.length===0&&n instanceof Uint8Array)return new Et(n);if(n instanceof Uint8Array&&o?.allowUnknownStructs)return console.warn(`Unsupported struct input type for argument ${t}. Continuing since 'allowUnknownStructs' is enabled.`),new Et(n);throw new Error(`Unsupported struct input type for argument ${t}, type '${e.toString()}'`)}throw new Error(`Type mismatch for argument ${t}, type '${e.toString()}'`)}function Zr(n,e,t){if(n.isBool()){if(Hr(e))return;_("Bool",t)}if(n.isAddress()){if(sr(e))return;_("AccountAddress",t)}if(n.isU8()){if($r(e))return;_("U8",t)}if(n.isU16()){if(qr(e))return;_("U16",t)}if(n.isU32()){if(Wr(e))return;_("U32",t)}if(n.isU64()){if(jr(e))return;_("U64",t)}if(n.isU128()){if(Qr(e))return;_("U128",t)}if(n.isU256()){if(Jr(e))return;_("U256",t)}if(n.isVector()){if(e instanceof K){e.values.length>0&&Zr(n.value,e.values[0],t);return}_("MoveVector",t)}if(n instanceof f){if(n.isString()){if(Lr(e))return;_("MoveString",t)}if(n.isObject()){if(sr(e))return;_("AccountAddress",t)}if(n.isOption()){if(e instanceof te){e.value!==void 0&&Zr(n.value.typeArgs[0],e.value,t);return}_("MoveOption",t)}}throw new Error(`Type mismatch for argument ${t}, expected '${n.toString()}'`)}async function ur(n){if(Ho(n))return Wa(n);let{moduleAddress:e,moduleName:t,functionName:r}=ue(n.function),i=await Jo({key:"entry-function",moduleAddress:e,moduleName:t,functionName:r,aptosConfig:n.aptosConfig,abi:n.abi,fetch:$o});return $a({...n,abi:i})}function $a(n){let e=n.abi,{moduleAddress:t,moduleName:r,functionName:i}=ue(n.function),o=ar(n.typeArguments);if(o.length!==e.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${e.typeParameters.length}, received ${o.length}`);let s=n.functionArguments.map((c,d)=>Xr(n.function,e,c,d,o));if(s.length!==e.parameters.length)throw new Error(`Too few arguments for '${t}::${r}::${i}', expected ${e.parameters.length} but got ${s.length}`);let a=Je.build(`${t}::${r}`,i,o,s);if("multisigAddress"in n){let c=u.from(n.multisigAddress);return new $t(new pn(c,new ln(a)))}return new Lt(a)}async function Wo(n){let{moduleAddress:e,moduleName:t,functionName:r}=ue(n.function),i=await Jo({key:"view-function",moduleAddress:e,moduleName:t,functionName:r,aptosConfig:n.aptosConfig,abi:n.abi,fetch:qo});return qa({abi:i,...n})}function qa(n){let e=n.abi,{moduleAddress:t,moduleName:r,functionName:i}=ue(n.function),o=ar(n.typeArguments);if(o.length!==e.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${e.typeParameters.length}, received ${o.length}`);let s=n?.functionArguments?.map((a,c)=>Xr(n.function,e,a,c,o))??[];if(s.length!==e.parameters.length)throw new Error(`Too few arguments for '${t}::${r}::${i}', expected ${e.parameters.length} but got ${s.length}`);return Je.build(`${t}::${r}`,i,o,s)}function Wa(n){return new Ht(new qt(m.fromHexInput(n.bytecode).toUint8Array(),ar(n.typeArguments),n.functionArguments))}async function ja(n){let{aptosConfig:e,sender:t,payload:r,options:i,feePayerAddress:o}=n;if(i?.replayProtectionNonce!==void 0&&i?.accountSequenceNumber!==void 0)throw new Error("Cannot specify both replayProtectionNonce and accountSequenceNumber in options.");let s=async()=>Cr[e.network]?{chainId:Cr[e.network]}:{chainId:(await Mn({aptosConfig:e})).chain_id},a=async()=>i?.gasUnitPrice?{gasEstimate:i.gasUnitPrice}:{gasEstimate:(await Vn({aptosConfig:e})).gas_estimate},c=async()=>{let X=async()=>i?.accountSequenceNumber!==void 0?i.accountSequenceNumber:i?.replayProtectionNonce!==void 0?0xdeadbeefn:(await Bn({aptosConfig:e,accountAddress:t})).sequence_number;if(o&&u.from(o).equals(u.ZERO))try{return await X()}catch{return 0}else return X()},[{chainId:d},{gasEstimate:l},g]=await Promise.all([s(),a(),c()]),{maxGasAmount:p,gasUnitPrice:y,expireTimestamp:h,replayProtectionNonce:U}={maxGasAmount:i?.maxGasAmount?BigInt(i.maxGasAmount):BigInt(e.getDefaultMaxGasAmount()),gasUnitPrice:i?.gasUnitPrice??BigInt(l),expireTimestamp:i?.expireTimestamp??BigInt(Math.floor(Date.now()/1e3)+e.getDefaultTxnExpirySecFromNow()),replayProtectionNonce:i?.replayProtectionNonce?BigInt(i.replayProtectionNonce):void 0},M=r;return U!==void 0&&(M=Qa(r,U)),new he(u.from(t),BigInt(g),M,BigInt(p),BigInt(y),BigInt(h),new Nn(d))}function Qa(n,e){if(n instanceof Ht)return new ft(new gn(n.script),new At(void 0,e));if(n instanceof Lt)return new ft(new jt(n.entryFunction),new At(void 0,e));if(n instanceof $t){let t=n.multiSig.transaction_payload,r;if(t===void 0||t?.transaction_payload===void 0)r=new yn;else if(t.transaction_payload instanceof Je)r=new jt(t.transaction_payload);else throw new Error("Scripts are not supported in multi-sig transactions.");return new ft(r,new At(n.multiSig.multisig_address,e))}else throw new Error(`Unsupported payload type: ${n}`)}async function ei(n){let{aptosConfig:e,sender:t,payload:r,options:i,feePayerAddress:o}=n,s=await ja({aptosConfig:e,sender:t,payload:r,options:i,feePayerAddress:o});if("secondarySignerAddresses"in n){let a=n.secondarySignerAddresses?.map(c=>u.from(c))??[];return new Xn(s,a,n.feePayerAddress?u.from(n.feePayerAddress):void 0)}return new Yn(s,n.feePayerAddress?u.from(n.feePayerAddress):void 0)}function jo(n){let{signerPublicKey:e,transaction:t,secondarySignersPublicKeys:r,feePayerPublicKey:i}=n,o=en(e);if(t.feePayerAddress){let a=new bt(t.rawTransaction,t.secondarySignerAddresses??[],t.feePayerAddress),c=[];t.secondarySignerAddresses&&(r?c=r.map(g=>en(g)):c=Array.from({length:t.secondarySignerAddresses.length},()=>en(void 0)));let d=en(i),l=new St(o,t.secondarySignerAddresses??[],c,{address:t.feePayerAddress,authenticator:d});return new Ye(a.raw_txn,l).bcsToBytes()}if(t.secondarySignerAddresses){let a=new ht(t.rawTransaction,t.secondarySignerAddresses),c=[];r?c=r.map(l=>en(l)):c=Array.from({length:t.secondarySignerAddresses.length},()=>en(void 0));let d=new Tt(o,t.secondarySignerAddresses,c);return new Ye(a.raw_txn,d).bcsToBytes()}let s;if(o instanceof Ee)s=new wt(o.public_key,o.signature);else if(o instanceof ie||o instanceof De)s=new ct(o);else if(o instanceof Vt)s=new ct(o);else throw new Error("Invalid public key");return new Ye(t.rawTransaction,s).bcsToBytes()}function en(n){if(!n)return new Vt;let t=E.isInstance(n)||G.isInstance(n)||Ke.isInstance(n)?new x(n):n,r=new C(new Uint8Array(64));if(b.isInstance(t))return new Ee(t,r);if(x.isInstance(t))return E.isInstance(t.publicKey)?new ie(t,new D(re.getSimulationSignature())):new ie(t,new D(r));if(B.isInstance(t))return new De(t,new Ae({signatures:t.publicKeys.map(i=>E.isInstance(i.publicKey)||G.isInstance(i.publicKey)?new D(re.getSimulationSignature()):new D(r)),bitmap:t.createBitmap({bits:Array(t.publicKeys.length).fill(0).map((i,o)=>o)})}));throw new Error("Unsupported PublicKey used for simulations")}function ti(n){let{transaction:e,feePayerAuthenticator:t,additionalSignersAuthenticators:r}=n,i=Bi(q,n.senderAuthenticator),o;if(e.feePayerAddress){if(!t)throw new Error("Must provide a feePayerAuthenticator argument to generate a signed fee payer transaction");o=new St(i,e.secondarySignerAddresses??[],r??[],{address:e.feePayerAddress,authenticator:t})}else if(e.secondarySignerAddresses){if(!r)throw new Error("Must provide a additionalSignersAuthenticators argument to generate a signed multi agent transaction");o=new Tt(i,e.secondarySignerAddresses,r)}else i instanceof Ee?o=new wt(i.public_key,i.signature):i instanceof $e?o=new Qt(i.public_key,i.signature):o=new ct(i);return new Ye(e.rawTransaction,o).bcsToBytes()}function Qo(n){let e=La.create();for(let t of n)e.update(t);return e.digest()}var Ja=Qo(["APTOS::Transaction"]);function $m(n){let e=ti(n);return new m(Qo([Ja,new Uint8Array([0]),e])).toString()}async function Jo({key:n,moduleAddress:e,moduleName:t,functionName:r,aptosConfig:i,abi:o,fetch:s}){return o!==void 0?o:Ot(async()=>s(e,t,r,i),`${n}-${i.network}-${e}-${t}-${r}`,1e3*60*5)()}async function A(n){let e=await Ya(n);return Xa(n,e)}async function Ya(n){let{aptosConfig:e,data:t}=n,r,i;return"bytecode"in t?i=await ur(t):"multisigAddress"in t?(r={aptosConfig:e,multisigAddress:t.multisigAddress,function:t.function,functionArguments:t.functionArguments,typeArguments:t.typeArguments,abi:t.abi},i=await ur(r)):(r={aptosConfig:e,function:t.function,functionArguments:t.functionArguments,typeArguments:t.typeArguments,abi:t.abi},i=await ur(r)),i}async function Xa(n,e){let{aptosConfig:t,sender:r,options:i}=n,o;if(ec(n)&&(o=u.ZERO.toString()),tc(n)){let{secondarySignerAddresses:s}=n;return ei({aptosConfig:t,sender:r,payload:e,options:i,secondarySignerAddresses:s,feePayerAddress:o})}return ei({aptosConfig:t,sender:r,payload:e,options:i,feePayerAddress:o})}function ec(n){return n.withFeePayer===!0}function tc(n){return"secondarySignerAddresses"in n}function Zo(n){let{transaction:e}=n;return Ce(e)}function dr(n){let{signer:e,transaction:t}=n;return e.signTransactionWithAuthenticator(t)}function pr(n){let{signer:e,transaction:t}=n;if(!t.feePayerAddress)throw new Error(`Transaction ${t} is not a Fee Payer transaction`);return t.feePayerAddress=e.accountAddress,dr({signer:e,transaction:t})}async function ni(n){let{aptosConfig:e,transaction:t,signerPublicKey:r,secondarySignersPublicKeys:i,feePayerPublicKey:o,options:s}=n,a=jo({transaction:t,signerPublicKey:r,secondarySignersPublicKeys:i,feePayerPublicKey:o,options:s}),{data:c}=await Rt({aptosConfig:e,body:a,path:"transactions/simulate",params:{estimate_gas_unit_price:n.options?.estimateGasUnitPrice??!1,estimate_max_gas_amount:n.options?.estimateMaxGasAmount??!1,estimate_prioritized_gas_unit_price:n.options?.estimatePrioritizedGasUnitPrice??!1},originMethod:"simulateTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return c}async function hn(n){let{aptosConfig:e,transactionSubmitter:t}=n,r=t===void 0?e.getTransactionSubmitter():t;if(r)return r.submitTransaction(n);let i=ti({...n});try{let{data:o}=await Rt({aptosConfig:e,body:i,path:"transactions",originMethod:"submitTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return o}catch(o){let s=Ye.deserialize(new k(i));throw s.authenticator.isSingleSender()&&s.authenticator.sender.isSingleKey()&&(s.authenticator.sender.public_key.publicKey instanceof E||s.authenticator.sender.public_key.publicKey instanceof G)&&await me.fetchJWK({aptosConfig:e,publicKey:s.authenticator.sender.public_key.publicKey,kid:s.authenticator.sender.signature.signature.getJwkKid()}),o}}async function lr(n){let{aptosConfig:e,signer:t,feePayer:r,transaction:i,...o}=n;nr(t)&&await t.checkKeylessAccountValidity(e),nr(r)&&await r.checkKeylessAccountValidity(e);let s=n.feePayerAuthenticator||r&&pr({signer:r,transaction:i}),a=dr({signer:t,transaction:i});return hn({aptosConfig:e,transaction:i,senderAuthenticator:a,feePayerAuthenticator:s,...o})}async function Yo(n){let{aptosConfig:e,senderAuthenticator:t,feePayer:r,transaction:i,...o}=n;nr(r)&&await r.checkKeylessAccountValidity(e);let s=pr({signer:r,transaction:i});return hn({aptosConfig:e,transaction:i,senderAuthenticator:t,feePayerAuthenticator:s,...o})}var nc={typeParameters:[],parameters:[v.u8(),new v(v.u8())]};async function Xo(n){let{aptosConfig:e,account:t,metadataBytes:r,moduleBytecode:i,options:o}=n,s=i.map(a=>K.U8(a));return A({aptosConfig:e,sender:u.from(t),data:{function:"0x1::code::publish_package_txn",functionArguments:[K.U8(r),new K(s)],abi:nc},options:o})}async function tn(n){return Bn(n)}async function ts(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return _r({aptosConfig:e,originMethod:"getModules",path:`accounts/${u.from(t).toString()}/modules`,params:{ledger_version:r?.ledgerVersion,limit:r?.limit??1e3}})}async function ns(n){let{aptosConfig:e,accountAddress:t,options:r}=n,{response:i,cursor:o}=await Ur({aptosConfig:e,originMethod:"getModulesPage",path:`accounts/${u.from(t).toString()}/modules`,params:{ledger_version:r?.ledgerVersion,cursor:r?.cursor,limit:r?.limit??100}});return{modules:i.data,cursor:o}}async function cr(n){return wo(n)}async function oi(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return Qi({aptosConfig:e,originMethod:"getTransactions",path:`accounts/${u.from(t).toString()}/transactions`,params:{start:r?.offset,limit:r?.limit}})}async function si(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return _r({aptosConfig:e,originMethod:"getResources",path:`accounts/${u.from(t).toString()}/resources`,params:{ledger_version:r?.ledgerVersion,limit:r?.limit??999}})}async function rs(n){let{aptosConfig:e,accountAddress:t,options:r}=n,{response:i,cursor:o}=await Ur({aptosConfig:e,originMethod:"getResourcesPage",path:`accounts/${u.from(t).toString()}/resources`,params:{ledger_version:r?.ledgerVersion,cursor:r?.cursor,limit:r?.limit??100}});return{resources:i.data,cursor:o}}async function ai(n){let{aptosConfig:e,accountAddress:t,resourceType:r,options:i}=n,{data:o}=await st({aptosConfig:e,originMethod:"getResource",path:`accounts/${u.from(t).toString()}/resource/${r}`,params:{ledger_version:i?.ledgerVersion}});return o.data}async function nn(n){let{aptosConfig:e,authenticationKey:t,options:r}=n,i=await ai({aptosConfig:e,accountAddress:"0x1",resourceType:"0x1::account::OriginatingAddress",options:r}),{address_map:{handle:o}}=i,s=u.from(t);try{let a=await To({aptosConfig:e,handle:o,data:{key:s.toString(),key_type:"address",value_type:"address"},options:r});return u.from(a)}catch(a){if(a instanceof ji&&a.data.error_code==="table_item_not_found")return s;throw a}}async function is(n){let{aptosConfig:e,accountAddress:t}=n,i={owner_address:{_eq:u.from(t).toStringLong()},amount:{_gt:0}},s=await P({aptosConfig:e,query:{query:so,variables:{where_condition:i}},originMethod:"getAccountTokensCount"});return s.current_token_ownerships_v2_aggregate.aggregate?s.current_token_ownerships_v2_aggregate.aggregate.count:0}async function os(n){let{aptosConfig:e,accountAddress:t,options:r}=n,o={owner_address:{_eq:u.from(t).toStringLong()},amount:{_gt:0}};r?.tokenStandard&&(o.token_standard={_eq:r?.tokenStandard});let s={query:io,variables:{where_condition:o,offset:r?.offset,limit:r?.limit,order_by:r?.orderBy}};return(await P({aptosConfig:e,query:s,originMethod:"getAccountOwnedTokens"})).current_token_ownerships_v2}async function ss(n){let{aptosConfig:e,accountAddress:t,collectionAddress:r,options:i}=n,o=u.from(t).toStringLong(),s=u.from(r).toStringLong(),a={owner_address:{_eq:o},current_token_data:{collection_id:{_eq:s}},amount:{_gt:0}};i?.tokenStandard&&(a.token_standard={_eq:i?.tokenStandard});let c={query:oo,variables:{where_condition:a,offset:i?.offset,limit:i?.limit,order_by:i?.orderBy}};return(await P({aptosConfig:e,query:c,originMethod:"getAccountOwnedTokensFromCollectionAddress"})).current_token_ownerships_v2}async function as(n){let{aptosConfig:e,accountAddress:t,options:r}=n,o={owner_address:{_eq:u.from(t).toStringLong()}};r?.tokenStandard&&(o.current_collection={token_standard:{_eq:r?.tokenStandard}});let s={query:ro,variables:{where_condition:o,offset:r?.offset,limit:r?.limit,order_by:r?.orderBy}};return(await P({aptosConfig:e,query:s,originMethod:"getAccountCollectionsWithOwnedTokens"})).current_collection_ownership_v2_view}async function cs(n){let{aptosConfig:e,accountAddress:t}=n,r=u.from(t).toStringLong(),o=await P({aptosConfig:e,query:{query:ao,variables:{address:r}},originMethod:"getAccountTransactionsCount"});return o.account_transactions_aggregate.aggregate?o.account_transactions_aggregate.aggregate.count:0}async function gA(n){let{aptosConfig:e,accountAddress:t,coinType:r,faMetadataAddress:i}=n,o=r,s;if(r!==void 0&&i!==void 0)s=u.from(i).toStringLong();else if(r!==void 0&&i===void 0)r===Be?s=u.A.toStringLong():s=On(u.A,r).toStringLong();else if(r===void 0&&i!==void 0){let l=u.from(i);s=l.toStringLong(),l===u.A&&(o=Be)}else throw new Error("Either coinType, fungibleAssetAddress, or both must be provided");let a=u.from(t).toStringLong(),c={asset_type:{_eq:s}};o!==void 0&&(c={asset_type:{_in:[o,s]}});let d=await ci({aptosConfig:e,accountAddress:a,options:{where:c}});return d[0]?d[0].amount:0}async function ci(n){let{aptosConfig:e,accountAddress:t,options:r}=n,i=u.from(t).toStringLong(),o={...r?.where,owner_address:{_eq:i}},s={query:no,variables:{where_condition:o,offset:r?.offset,limit:r?.limit,order_by:r?.orderBy}};return(await P({aptosConfig:e,query:s,originMethod:"getAccountCoinsData"})).current_fungible_asset_balances}async function us(n){let{aptosConfig:e,accountAddress:t}=n,r=u.from(t).toStringLong(),o=await P({aptosConfig:e,query:{query:to,variables:{address:r}},originMethod:"getAccountCoinsCount"});if(!o.current_fungible_asset_balances_aggregate.aggregate)throw Error("Failed to get the count of account coins");return o.current_fungible_asset_balances_aggregate.aggregate.count}async function ds(n){let{aptosConfig:e,accountAddress:t,asset:r}=n,i=await st({aptosConfig:e,originMethod:"getBalance",path:`accounts/${t}/balance/${r}`,params:{accountAddress:t.toString(),asset:r instanceof Uint8Array?u.from(r).toString():r.toString()}});return parseInt(i.data.toString(),10)}async function ui(n){let{aptosConfig:e,accountAddress:t,options:r}=n,o={owner_address:{_eq:u.from(t).toStringLong()}},s={query:Gn,variables:{where_condition:o,offset:r?.offset,limit:r?.limit,order_by:r?.orderBy}};return(await P({aptosConfig:e,query:s,originMethod:"getAccountOwnedObjects"})).current_objects}async function ps(n){let{aptosConfig:e,privateKey:t,options:r}=n,i=r?.throwIfNoAccountFound??!1,o=await gr({aptosConfig:e,privateKey:t});if(o.length===0){if(i)throw new Error("No existing account found for private key.");return Xe.fromPrivateKey({privateKey:t})}return o[0]}async function yA(n){let{aptosConfig:e,authKey:t}=n,r=await nn({aptosConfig:e,authenticationKey:t.derivedAddress()});return ls({aptosConfig:e,accountAddress:r})}async function ls(n){let{aptosConfig:e,accountAddress:t,options:r}=n;try{let[i,o]=await Promise.all([si({aptosConfig:e,accountAddress:t}),ui({aptosConfig:e,accountAddress:t,options:{limit:1}})]),s=i.find(c=>c.type==="0x1::account::Account");if(!s&&o.length===0)return!1;if(!r?.withAuthKey)return!0;let a;return s?a=s.data.authentication_key:a=t.toStringLong(),a===r.withAuthKey.toString()}catch(i){throw new Error(`Error while checking if account exists at ${t.toString()}: ${i}`)}}var rc={typeParameters:[],parameters:[new oe,v.u8(),new oe,v.u8(),v.u8(),v.u8()]};async function gs(n){let{aptosConfig:e,fromAccount:t,options:r}=n;if("toNewPrivateKey"in n)return ri({aptosConfig:e,fromAccount:t,toNewPrivateKey:n.toNewPrivateKey,options:r});if("toAccount"in n)return n.toAccount instanceof Y?ri({aptosConfig:e,fromAccount:t,toNewPrivateKey:n.toAccount.privateKey,options:r}):ri({aptosConfig:e,fromAccount:t,toAccount:n.toAccount,options:r});throw new Error("Invalid arguments")}async function ri(n){let{aptosConfig:e,fromAccount:t,options:r}=n,i=await tn({aptosConfig:e,accountAddress:t.accountAddress}),o;"toNewPrivateKey"in n?o=Xe.fromPrivateKey({privateKey:n.toNewPrivateKey,legacy:!0}):o=n.toAccount;let a=new Xi({sequenceNumber:BigInt(i.sequence_number),originator:t.accountAddress,currentAuthKey:u.from(i.authentication_key),newPublicKey:o.publicKey}).bcsToBytes(),c=t.sign(a),d=o.sign(a);return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::account::rotate_authentication_key",functionArguments:[new Se(t.signingScheme),K.U8(t.publicKey.toUint8Array()),new Se(o.signingScheme),K.U8(o.publicKey.toUint8Array()),K.U8(c.toUint8Array()),K.U8(d.toUint8Array())],abi:rc},options:r})}var ic={typeParameters:[],parameters:[new oe,v.u8()]};async function ys(n){let{aptosConfig:e,fromAccount:t,toNewPublicKey:r,options:i}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::account::rotate_authentication_key_from_public_key",functionArguments:[new Se(es(r)),K.U8(ii(r).toUint8Array())],abi:ic},options:i})}async function yr(n){let{aptosConfig:e,publicKey:t,options:r}=n,i=r?.noMultiKey??!1;if(i&&t instanceof xe)throw new Error("Multi-key accounts are not supported when noMultiKey is true.");let o=[t];t instanceof x&&t.publicKey instanceof b?o.push(t.publicKey):t instanceof b&&o.push(new x(t));let[s,a]=await Promise.all([Promise.all(o.map(async g=>{let p=await uc({aptosConfig:e,publicKey:g});if(p)return{...p,publicKey:g}})),!(t instanceof xe)&&!i?sc({aptosConfig:e,publicKey:t,options:r}):Promise.resolve([])]),c=[];for(let g of s)g&&c.push(g);o.push(...a);let d=new Map(o.map(g=>[g.authKey().toString(),g])),l=await ac({aptosConfig:e,authKeys:o.map(g=>g.authKey()),options:r});for(let g of l){if(c.find(y=>y.accountAddress===g.accountAddress))continue;let p=d.get(g.authKey.toString());if(!p)throw new Error(`No publicKey found for authentication key ${g.authKey}. This should never happen.`);c.push({accountAddress:g.accountAddress,publicKey:p,lastTransactionVersion:g.lastTransactionVersion})}return c.sort((g,p)=>p.lastTransactionVersion-g.lastTransactionVersion)}async function di(n){let{aptosConfig:e,signer:t,options:r}=n;if(t instanceof L||t instanceof He)return gr({aptosConfig:e,privateKey:t,options:r});if(t instanceof Y||t instanceof se)return gr({aptosConfig:e,privateKey:t.privateKey,options:r});if(t instanceof be||t instanceof ve)return oc({aptosConfig:e,keylessAccount:t,options:r});if(t instanceof tt&&t.signers.length===1)return di({aptosConfig:e,signer:t.signers[0],options:r});if(t instanceof mn&&t.signers.length===1)return gr({aptosConfig:e,privateKey:t.signers[0],options:r});throw new Error("Unknown signer type")}async function oc(n){let{aptosConfig:e,keylessAccount:t,options:r}=n,i=await yr({aptosConfig:e,publicKey:t.getAnyPublicKey(),options:r}),o={proof:t.proofOrPromise,jwt:t.jwt,ephemeralKeyPair:t.ephemeralKeyPair,pepper:t.pepper,verificationKeyHash:t.verificationKeyHash},s=[];for(let{accountAddress:a,publicKey:c}of i)if(c instanceof xe){if(c.getSignaturesRequired()>1)continue;if(c instanceof Z)throw new Error("Keyless authentication cannot be used for multi-ed25519 accounts. This should never happen.");c instanceof B&&s.push(new tt({multiKey:c,signers:[t],address:a}))}else t instanceof ve?s.push(ve.create({...o,address:a,jwkAddress:t.publicKey.jwkAddress})):s.push(be.create({...o,address:a}));return s}async function gr(n){let{aptosConfig:e,privateKey:t,options:r}=n,i=Xe.fromPrivateKey({privateKey:t,legacy:!1}),o=await yr({aptosConfig:e,publicKey:new x(t.publicKey()),options:r}),s=[];for(let{accountAddress:a,publicKey:c}of o)if(c instanceof xe){if(c.getSignaturesRequired()>1)continue;c instanceof Z?s.push(new mn({publicKey:c,signers:[t],address:a})):c instanceof B&&s.push(new tt({multiKey:c,signers:[i],address:a}))}else{let d=c instanceof b;s.push(Xe.fromPrivateKey({privateKey:t,address:a,legacy:d}))}return s}async function sc(n){let{aptosConfig:e,publicKey:t,options:r}=n;if(t instanceof xe)throw new Error("Public key is a multi-key.");let i=r?.includeUnverified??!1,o=t instanceof x?t:new x(t),s=o.publicKey,a=Ii(o.variant),c={public_key:{_eq:s.toString()},public_key_type:{_eq:a},...i?{}:{is_public_key_used:{_eq:!0}}},d={query:co,variables:{where_condition:c}},{public_key_auth_keys:l}=await P({aptosConfig:e,query:d,originMethod:"getMultiKeysForPublicKey"});return l.map(p=>{switch(p.signature_type){case"multi_ed25519_signature":return Z.deserializeWithoutLength(k.fromHex(p.account_public_key));case"multi_key_signature":return B.deserialize(k.fromHex(p.account_public_key));default:throw new Error(`Unknown multi-signature type: ${p.signature_type}`)}})}async function ac(n){let{aptosConfig:e,authKeys:t,options:r}=n,i=r?.includeUnverified??!1;if(t.length===0)throw new Error("No authentication keys provided");let o={auth_key:{_in:t.map(c=>c.toString())},...i?{}:{is_auth_key_used:{_eq:!0}}},s={query:eo,variables:{where_condition:o,order_by:[{last_transaction_version:"desc"}]}},{auth_key_account_addresses:a}=await P({aptosConfig:e,query:s,originMethod:"getAccountAddressesForAuthKeys"});return a.map(c=>({authKey:new ne({data:c.auth_key}),accountAddress:new u(m.hexInputToUint8Array(c.account_address)),lastTransactionVersion:Number(c.last_transaction_version)}))}async function cc(n){let{aptosConfig:e,accountAddress:t}=n,r=await oi({aptosConfig:e,accountAddress:t,options:{limit:1}});return r.length===0?0:Number(r[0].version)}async function uc(n){let{aptosConfig:e,publicKey:t}=n,r=t.authKey().derivedAddress(),[i,o]=await Promise.all([cc({aptosConfig:e,accountAddress:r}),ls({aptosConfig:e,accountAddress:r,options:{withAuthKey:t.authKey()}})]);if(o)return{accountAddress:r,lastTransactionVersion:i}}async function ae(n){let{aptosConfig:e,payload:t,options:r}=n,i=await Wo({...t,aptosConfig:e}),o=new ee;i.serialize(o);let s=o.toUint8Array(),{data:a}=await Rt({aptosConfig:e,path:"view",originMethod:"view",contentType:"application/x.aptos.view_function+bcs",params:{ledger_version:r?.ledgerVersion},body:s});return a}async function ms(n){let{aptosConfig:e,payload:t,options:r}=n,{data:i}=await Rt({aptosConfig:e,originMethod:"viewJson",path:"view",params:{ledger_version:r?.ledgerVersion},body:{function:t.function,type_arguments:t.typeArguments??[],arguments:t.functionArguments??[]}});return i}async function fs(n){let{aptosConfig:e,sender:t,authenticationFunction:r,options:i}=n,{moduleAddress:o,moduleName:s,functionName:a}=ue(r);return A({aptosConfig:e,sender:t,data:{function:"0x1::account_abstraction::add_authentication_function",typeArguments:[],functionArguments:[o,s,a],abi:{typeParameters:[],parameters:[new R,new f(I()),new f(I())]}},options:i})}async function As(n){let{aptosConfig:e,sender:t,authenticationFunction:r,options:i}=n,{moduleAddress:o,moduleName:s,functionName:a}=ue(r);return A({aptosConfig:e,sender:t,data:{function:"0x1::account_abstraction::remove_authentication_function",typeArguments:[],functionArguments:[o,s,a],abi:{typeParameters:[],parameters:[new R,new f(I()),new f(I())]}},options:i})}async function hs(n){let{aptosConfig:e,sender:t,options:r}=n;return A({aptosConfig:e,sender:t,data:{function:"0x1::account_abstraction::remove_authenticator",typeArguments:[],functionArguments:[],abi:{typeParameters:[],parameters:[]}},options:r})}var xt=class{constructor(e){this.config=e;this.isAccountAbstractionEnabled=async e=>{let t=await this.getAuthenticationFunction(e),{moduleAddress:r,moduleName:i,functionName:o}=ue(e.authenticationFunction);return t?.some(s=>u.fromString(r).equals(s.moduleAddress)&&i===s.moduleName&&o===s.functionName)??!1};this.enableAccountAbstractionTransaction=this.addAuthenticationFunctionTransaction;this.disableAccountAbstractionTransaction=async e=>{let{accountAddress:t,authenticationFunction:r,options:i}=e;return r?this.removeAuthenticationFunctionTransaction({accountAddress:t,authenticationFunction:r,options:i}):this.removeDispatchableAuthenticatorTransaction({accountAddress:t,options:i})}}async addAuthenticationFunctionTransaction(e){let{accountAddress:t,authenticationFunction:r,options:i}=e;return fs({aptosConfig:this.config,authenticationFunction:r,sender:t,options:i})}async removeAuthenticationFunctionTransaction(e){let{accountAddress:t,authenticationFunction:r,options:i}=e;return As({aptosConfig:this.config,sender:t,authenticationFunction:r,options:i})}async removeDispatchableAuthenticatorTransaction(e){let{accountAddress:t,options:r}=e;return hs({aptosConfig:this.config,sender:t,options:r})}async getAuthenticationFunction(e){let{accountAddress:t}=e,[{vec:r}]=await ae({aptosConfig:this.config,payload:{function:"0x1::account_abstraction::dispatchable_authenticator",functionArguments:[u.from(t)],abi:{typeParameters:[],parameters:[new R],returnTypes:[]}}});if(r.length!==0)return r[0].map(i=>({moduleAddress:u.fromString(i.module_address),moduleName:i.module_name,functionName:i.function_name}))}};var bn=class{constructor(e){this.config=e;this.abstraction=new xt(e)}async getAccountInfo(e){return tn({aptosConfig:this.config,...e})}async getAccountModules(e){return ts({aptosConfig:this.config,...e})}async getAccountModulesPage(e){return ns({aptosConfig:this.config,...e})}async getAccountModule(e){return cr({aptosConfig:this.config,...e})}async getAccountTransactions(e){return oi({aptosConfig:this.config,...e})}async getAccountResources(e){return si({aptosConfig:this.config,...e})}async getAccountResourcesPage(e){return rs({aptosConfig:this.config,...e})}async getAccountResource(e){return ai({aptosConfig:this.config,...e})}async lookupOriginalAccountAddress(e){return nn({aptosConfig:this.config,...e})}async getAccountTokensCount(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_transactions_processor"}),is({aptosConfig:this.config,...e})}async getAccountOwnedTokens(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),os({aptosConfig:this.config,...e})}async getAccountOwnedTokensFromCollectionAddress(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),ss({aptosConfig:this.config,...e})}async getAccountCollectionsWithOwnedTokens(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),as({aptosConfig:this.config,...e})}async getAccountTransactionsCount(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_transactions_processor"}),cs({aptosConfig:this.config,...e})}async getAccountCoinsData(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),ci({aptosConfig:this.config,...e})}async getAccountCoinsCount(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),us({aptosConfig:this.config,...e})}async getAccountAPTAmount(e){return this.getAccountCoinAmount({coinType:Be,faMetadataAddress:Oi,...e})}async getAccountCoinAmount(e){let{accountAddress:t,coinType:r,faMetadataAddress:i}=e,o=r;r===void 0&&i!==void 0&&(o=await Ot(async()=>{try{let c=(await ae({aptosConfig:this.config,payload:{function:"0x1::coin::paired_coin",functionArguments:[i]}}))[0];if(c.vec.length>0&&Wi(c.vec[0]))return qi(c.vec[0])}catch{}},`coin-mapping-${i.toString()}`,1e3*60*5)());let s;if(r!==void 0&&i!==void 0)s=u.from(i).toStringLong();else if(r!==void 0&&i===void 0)r===Be?s=u.A.toStringLong():s=On(u.A,r).toStringLong();else if(r===void 0&&i!==void 0){let c=u.from(i);s=c.toStringLong(),c===u.A&&(o=Be)}else throw new Error("Either coinType, faMetadataAddress, or both must be provided");if(o!==void 0){let[c]=await ae({aptosConfig:this.config,payload:{function:"0x1::coin::balance",typeArguments:[o],functionArguments:[t]}});return parseInt(c,10)}let[a]=await ae({aptosConfig:this.config,payload:{function:"0x1::primary_fungible_store::balance",typeArguments:["0x1::object::ObjectCore"],functionArguments:[t,s]}});return parseInt(a,10)}async getBalance(e){return ds({aptosConfig:this.config,...e})}async getAccountOwnedObjects(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),ui({aptosConfig:this.config,...e})}async deriveAccountFromPrivateKey(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_restoration_processor"}),await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"objects_processor"}),ps({aptosConfig:this.config,...e})}async deriveOwnedAccountsFromSigner(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_restoration_processor"}),await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"objects_processor"}),di({aptosConfig:this.config,...e})}async getAccountsForPublicKey(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_restoration_processor"}),await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"objects_processor"}),yr({aptosConfig:this.config,...e})}};var dc={typeParameters:[{constraints:[]}],parameters:[new R,new W]};async function bs(n){let{aptosConfig:e,sender:t,recipient:r,amount:i,coinType:o,options:s}=n;return A({aptosConfig:e,sender:t,data:{function:"0x1::aptos_account::transfer_coins",typeArguments:[o??Be],functionArguments:[r,i],abi:dc},options:s})}var Tn=class{constructor(e){this.config=e}async transferCoinTransaction(e){return bs({aptosConfig:this.config,...e})}};var dt={BOOLEAN:"bool",U8:"u8",U16:"u16",U32:"u32",U64:"u64",U128:"u128",U256:"u256",ADDRESS:"address",STRING:"0x1::string::String",ARRAY:"vector<u8>"},we="0x4::token::Token";async function ws(n){let{aptosConfig:e,digitalAssetAddress:t}=n,r={token_data_id:{_eq:u.from(t).toStringLong()}};return(await P({aptosConfig:e,query:{query:fo,variables:{where_condition:r}},originMethod:"getDigitalAssetData"})).current_token_datas_v2[0]}async function Ts(n){let{aptosConfig:e,digitalAssetAddress:t}=n,r={token_data_id:{_eq:u.from(t).toStringLong()},amount:{_gt:0}};return(await P({aptosConfig:e,query:{query:Dr,variables:{where_condition:r}},originMethod:"getCurrentDigitalAssetOwnership"})).current_token_ownerships_v2[0]}async function Ss(n){let{aptosConfig:e,ownerAddress:t,options:r}=n,i={owner_address:{_eq:u.from(t).toStringLong()},amount:{_gt:0}},o={query:Dr,variables:{where_condition:i,offset:r?.offset,limit:r?.limit,order_by:r?.orderBy}};return(await P({aptosConfig:e,query:o,originMethod:"getOwnedDigitalAssets"})).current_token_ownerships_v2}async function Ps(n){let{aptosConfig:e,digitalAssetAddress:t,options:r}=n,i={token_data_id:{_eq:u.from(t).toStringLong()}},o={query:mo,variables:{where_condition:i,offset:r?.offset,limit:r?.limit,order_by:r?.orderBy}};return(await P({aptosConfig:e,query:o,originMethod:"getDigitalAssetActivity"})).token_activities_v2}var pc={typeParameters:[],parameters:[new f(I()),new W,new f(I()),new f(I()),new V,new V,new V,new V,new V,new V,new V,new V,new V,new W,new W]};async function Ks(n){let{aptosConfig:e,options:t,creator:r}=n;return A({aptosConfig:e,sender:r.accountAddress,data:{function:"0x4::aptos_token::create_collection",functionArguments:[new F(n.description),new fe(n.maxSupply??Pi),new F(n.name),new F(n.uri),new H(n.mutableDescription??!0),new H(n.mutableRoyalty??!0),new H(n.mutableURI??!0),new H(n.mutableTokenDescription??!0),new H(n.mutableTokenName??!0),new H(n.mutableTokenProperties??!0),new H(n.mutableTokenURI??!0),new H(n.tokensBurnableByCreator??!0),new H(n.tokensFreezableByCreator??!0),new fe(n.royaltyNumerator??0),new fe(n.royaltyDenominator??1)],abi:pc},options:t})}async function rn(n){let{aptosConfig:e,options:t}=n,r=t?.where;t?.tokenStandard&&(r.token_standard={_eq:t?.tokenStandard??"v2"});let i={query:uo,variables:{where_condition:r,offset:t?.offset,limit:t?.limit}};return(await P({aptosConfig:e,query:i,originMethod:"getCollectionData"})).current_collections_v2[0]}async function xs(n){let{aptosConfig:e,creatorAddress:t,collectionName:r,options:i}=n,o=u.from(t),s={collection_name:{_eq:r},creator_address:{_eq:o.toStringLong()}};return i?.tokenStandard&&(s.token_standard={_eq:i?.tokenStandard??"v2"}),rn({aptosConfig:e,options:{...i,where:s}})}async function Is(n){let{aptosConfig:e,creatorAddress:t,options:r}=n,o={creator_address:{_eq:u.from(t).toStringLong()}};return r?.tokenStandard&&(o.token_standard={_eq:r?.tokenStandard??"v2"}),rn({aptosConfig:e,options:{...r,where:o}})}async function Es(n){let{aptosConfig:e,collectionId:t,options:r}=n,o={collection_id:{_eq:u.from(t).toStringLong()}};return r?.tokenStandard&&(o.token_standard={_eq:r?.tokenStandard??"v2"}),rn({aptosConfig:e,options:{...r,where:o}})}async function Cs(n){let{creatorAddress:e,collectionName:t,options:r,aptosConfig:i}=n,o=u.from(e),s={collection_name:{_eq:t},creator_address:{_eq:o.toStringLong()}};return r?.tokenStandard&&(s.token_standard={_eq:r?.tokenStandard??"v2"}),(await rn({aptosConfig:i,options:{where:s}})).collection_id}var lc={typeParameters:[],parameters:[new f(I()),new f(I()),new f(I()),new f(I()),new v(new f(I())),new v(new f(I())),new v(v.u8())]};async function vs(n){let{aptosConfig:e,options:t,creator:r,collection:i,description:o,name:s,uri:a,propertyKeys:c,propertyTypes:d,propertyValues:l}=n,g=d?.map(p=>dt[p]);return A({aptosConfig:e,sender:r.accountAddress,data:{function:"0x4::aptos_token::mint",functionArguments:[new F(i),new F(o),new F(s),new F(a),K.MoveString(c??[]),K.MoveString(g??[]),Hs(l??[],g??[])],abi:lc},options:t})}var gc={typeParameters:[{constraints:["key"]}],parameters:[new f(ge(new N(0))),new R]};async function _s(n){let{aptosConfig:e,sender:t,digitalAssetAddress:r,recipient:i,digitalAssetType:o,options:s}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::object::transfer",typeArguments:[o??we],functionArguments:[u.from(r),u.from(i)],abi:gc},options:s})}var yc={typeParameters:[],parameters:[new f(I()),new f(I()),new f(I()),new f(I()),new v(new f(I())),new v(new f(I())),new v(v.u8()),new R]};async function Us(n){let{aptosConfig:e,account:t,collection:r,description:i,name:o,uri:s,recipient:a,propertyKeys:c,propertyTypes:d,propertyValues:l,options:g}=n;if(c?.length!==l?.length)throw new Error("Property keys and property values counts do not match");if(d?.length!==l?.length)throw new Error("Property types and property values counts do not match");let p=d?.map(y=>dt[y]);return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::mint_soul_bound",functionArguments:[r,i,o,s,K.MoveString(c??[]),K.MoveString(p??[]),Hs(l??[],p??[]),a],abi:yc},options:g})}var mc={typeParameters:[{constraints:["key"]}],parameters:[new f(ge(new N(0)))]};async function ks(n){let{aptosConfig:e,creator:t,digitalAssetAddress:r,digitalAssetType:i,options:o}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::burn",typeArguments:[i??we],functionArguments:[u.from(r)],abi:mc},options:o})}var fc={typeParameters:[{constraints:["key"]}],parameters:[new f(ge(new N(0)))]};async function Fs(n){let{aptosConfig:e,creator:t,digitalAssetAddress:r,digitalAssetType:i,options:o}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::freeze_transfer",typeArguments:[i??we],functionArguments:[r],abi:fc},options:o})}var Ac={typeParameters:[{constraints:["key"]}],parameters:[new f(ge(new N(0)))]};async function zs(n){let{aptosConfig:e,creator:t,digitalAssetAddress:r,digitalAssetType:i,options:o}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::unfreeze_transfer",typeArguments:[i??we],functionArguments:[r],abi:Ac},options:o})}var hc={typeParameters:[{constraints:["key"]}],parameters:[new f(ge(new N(0))),new f(I())]};async function Ds(n){let{aptosConfig:e,creator:t,description:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::set_description",typeArguments:[o??we],functionArguments:[u.from(i),new F(r)],abi:hc},options:s})}var bc={typeParameters:[{constraints:["key"]}],parameters:[new f(ge(new N(0))),new f(I())]};async function Rs(n){let{aptosConfig:e,creator:t,name:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::set_name",typeArguments:[o??we],functionArguments:[u.from(i),new F(r)],abi:bc},options:s})}var wc={typeParameters:[{constraints:["key"]}],parameters:[new f(ge(new N(0))),new f(I())]};async function Os(n){let{aptosConfig:e,creator:t,uri:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::set_uri",typeArguments:[o??we],functionArguments:[u.from(i),new F(r)],abi:wc},options:s})}var Tc={typeParameters:[{constraints:["key"]}],parameters:[new f(ge(new N(0))),new f(I()),new f(I()),v.u8()]};async function Ns(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::add_property",typeArguments:[a??we],functionArguments:[u.from(s),new F(r),new F(dt[i]),K.U8(pi(o,dt[i]))],abi:Tc},options:c})}var Sc={typeParameters:[{constraints:["key"]}],parameters:[new f(ge(new N(0))),new f(I())]};async function Gs(n){let{aptosConfig:e,creator:t,propertyKey:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::remove_property",typeArguments:[o??we],functionArguments:[u.from(i),new F(r)],abi:Sc},options:s})}var Pc={typeParameters:[{constraints:["key"]}],parameters:[new f(ge(new N(0))),new f(I()),new f(I()),v.u8()]};async function Ms(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::update_property",typeArguments:[a??we],functionArguments:[u.from(s),new F(r),new F(dt[i]),pi(o,dt[i])],abi:Pc},options:c})}var Kc={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new f(ge(new N(0))),new f(I()),new N(1)]};async function Bs(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::add_typed_property",typeArguments:[a??we,dt[i]],functionArguments:[u.from(s),new F(r),o],abi:Kc},options:c})}var xc={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new f(ge(new N(0))),new f(I()),new N(1)]};async function Vs(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::update_typed_property",typeArguments:[a??we,dt[i]],functionArguments:[u.from(s),new F(r),o],abi:xc},options:c})}function Hs(n,e){let t=new Array;return e.forEach((r,i)=>{t.push(pi(n[i],r))}),t}function pi(n,e){let t=_e(e);return Kt(n,t,0,[]).bcsToBytes()}var Sn=class{constructor(e){this.config=e}async getCollectionData(e){await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"});let{creatorAddress:t,collectionName:r,options:i}=e,o=u.from(t),s={collection_name:{_eq:r},creator_address:{_eq:o.toStringLong()}};return i?.tokenStandard&&(s.token_standard={_eq:i?.tokenStandard??"v2"}),rn({aptosConfig:this.config,options:{where:s}})}async getCollectionDataByCreatorAddressAndCollectionName(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),xs({aptosConfig:this.config,...e})}async getCollectionDataByCreatorAddress(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Is({aptosConfig:this.config,...e})}async getCollectionDataByCollectionId(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Es({aptosConfig:this.config,...e})}async getCollectionId(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Cs({aptosConfig:this.config,...e})}async getDigitalAssetData(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),ws({aptosConfig:this.config,...e})}async getCurrentDigitalAssetOwnership(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Ts({aptosConfig:this.config,...e})}async getOwnedDigitalAssets(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Ss({aptosConfig:this.config,...e})}async getDigitalAssetActivity(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Ps({aptosConfig:this.config,...e})}async createCollectionTransaction(e){return Ks({aptosConfig:this.config,...e})}async mintDigitalAssetTransaction(e){return vs({aptosConfig:this.config,...e})}async transferDigitalAssetTransaction(e){return _s({aptosConfig:this.config,...e})}async mintSoulBoundTransaction(e){return Us({aptosConfig:this.config,...e})}async burnDigitalAssetTransaction(e){return ks({aptosConfig:this.config,...e})}async freezeDigitalAssetTransaferTransaction(e){return Fs({aptosConfig:this.config,...e})}async unfreezeDigitalAssetTransaferTransaction(e){return zs({aptosConfig:this.config,...e})}async setDigitalAssetDescriptionTransaction(e){return Ds({aptosConfig:this.config,...e})}async setDigitalAssetNameTransaction(e){return Rs({aptosConfig:this.config,...e})}async setDigitalAssetURITransaction(e){return Os({aptosConfig:this.config,...e})}async addDigitalAssetPropertyTransaction(e){return Ns({aptosConfig:this.config,...e})}async removeDigitalAssetPropertyTransaction(e){return Gs({aptosConfig:this.config,...e})}async updateDigitalAssetPropertyTransaction(e){return Ms({aptosConfig:this.config,...e})}async addDigitalAssetTypedPropertyTransaction(e){return Bs({aptosConfig:this.config,...e})}async updateDigitalAssetTypedPropertyTransaction(e){return Vs({aptosConfig:this.config,...e})}};async function Ls(n){let{aptosConfig:e,accountAddress:t,amount:r,options:i}=n,o=i?.timeoutSecs||20,{data:s}=await Ji({aptosConfig:e,path:"fund",body:{address:u.from(t).toString(),amount:r},originMethod:"fundAccount"}),a=s.txn_hashes[0],c=await Gt({aptosConfig:e,transactionHash:a,options:{timeoutSecs:o,checkSuccess:i?.checkSuccess}});if(c.type==="user_transaction")return c;throw new Error(`Unexpected transaction received for fund account: ${c.type}`)}var Pn=class{constructor(e){this.config=e}async fundAccount(e){let t=await Ls({aptosConfig:this.config,...e});return(e.options?.waitForIndexer===void 0||e.options?.waitForIndexer)&&await Io({aptosConfig:this.config,minimumLedgerVersion:BigInt(t.version),processorType:"fungible_asset_processor"}),t}};async function mr(n){let{aptosConfig:e,options:t}=n,r={query:yo,variables:{where_condition:t?.where,limit:t?.limit,offset:t?.offset}};return(await P({aptosConfig:e,query:r,originMethod:"getFungibleAssetMetadata"})).fungible_asset_metadata}async function $s(n){let{aptosConfig:e,options:t}=n,r={query:go,variables:{where_condition:t?.where,limit:t?.limit,offset:t?.offset}};return(await P({aptosConfig:e,query:r,originMethod:"getFungibleAssetActivities"})).fungible_asset_activities}async function qs(n){let{aptosConfig:e,options:t}=n,r={query:po,variables:{where_condition:t?.where,limit:t?.limit,offset:t?.offset}};return(await P({aptosConfig:e,query:r,originMethod:"getCurrentFungibleAssetBalances"})).current_fungible_asset_balances}var Ws={typeParameters:[{constraints:[]}],parameters:[_e("0x1::object::Object"),new R,new W]};async function js(n){let{aptosConfig:e,sender:t,fungibleAssetMetadataAddress:r,recipient:i,amount:o,options:s}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::primary_fungible_store::transfer",typeArguments:["0x1::fungible_asset::Metadata"],functionArguments:[r,i,o],abi:Ws},options:s})}async function Qs(n){let{aptosConfig:e,sender:t,fromStore:r,toStore:i,amount:o,options:s}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::dispatchable_fungible_asset::transfer",typeArguments:["0x1::fungible_asset::FungibleStore"],functionArguments:[r,i,o],abi:Ws},options:s})}var Kn=class{constructor(e){this.config=e}async getFungibleAssetMetadata(e){return await T({config:this.config,minimumLedgerVersion:e?.minimumLedgerVersion,processorType:"fungible_asset_processor"}),mr({aptosConfig:this.config,...e})}async getFungibleAssetMetadataByAssetType(e){return await T({config:this.config,minimumLedgerVersion:e?.minimumLedgerVersion,processorType:"fungible_asset_processor"}),(await mr({aptosConfig:this.config,options:{where:{asset_type:{_eq:e.assetType}}}}))[0]}async getFungibleAssetMetadataByCreatorAddress(e){return await T({config:this.config,minimumLedgerVersion:e?.minimumLedgerVersion,processorType:"fungible_asset_processor"}),await mr({aptosConfig:this.config,options:{where:{creator_address:{_eq:u.from(e.creatorAddress).toStringLong()}}}})}async getFungibleAssetActivities(e){return await T({config:this.config,minimumLedgerVersion:e?.minimumLedgerVersion,processorType:"fungible_asset_processor"}),$s({aptosConfig:this.config,...e})}async getCurrentFungibleAssetBalances(e){return await T({config:this.config,minimumLedgerVersion:e?.minimumLedgerVersion,processorType:"fungible_asset_processor"}),qs({aptosConfig:this.config,...e})}async transferFungibleAsset(e){return js({aptosConfig:this.config,...e})}async transferFungibleAssetBetweenStores(e){return Qs({aptosConfig:this.config,...e})}};var xn=class{constructor(e){this.config=e}async getLedgerInfo(){return Mn({aptosConfig:this.config})}async getChainId(){return(await this.getLedgerInfo()).chain_id}async getBlockByVersion(e){return Eo({aptosConfig:this.config,...e})}async getBlockByHeight(e){return Co({aptosConfig:this.config,...e})}async view(e){return ae({aptosConfig:this.config,...e})}async viewJson(e){return ms({aptosConfig:this.config,...e})}async getChainTopUserTransactions(e){return Ao({aptosConfig:this.config,...e})}async queryIndexer(e){return P({aptosConfig:this.config,...e})}async getIndexerLastSuccessVersion(){return ho({aptosConfig:this.config})}async getProcessorStatus(e){return bo({aptosConfig:this.config,processorType:e})}};var Js=["A name must be between 3 and 63 characters long,","and can only contain lowercase a-z, 0-9, and hyphens.","A name may not start or end with a hyphen."].join(" ");function Zs(n){return!(!n||n.length<3||n.length>63||!/^[a-z\d][a-z\d-]{1,61}[a-z\d]$/.test(n))}function pt(n){let[e,t,...r]=n.replace(/\.apt$/,"").split(".");if(r.length>0)throw new Error(`${n} is invalid. A name can only have two parts, a domain and a subdomain separated by a "."`);if(!Zs(e))throw new Error(`${e} is not valid. ${Js}`);if(t&&!Zs(t))throw new Error(`${t} is not valid. ${Js}`);return{domainName:t||e,subdomainName:t?e:void 0}}var Ic=(t=>(t[t.Independent=0]="Independent",t[t.FollowsDomain=1]="FollowsDomain",t))(Ic||{});function Ys(n){if(!n)return!1;let e=new Date(n.domain_expiration_timestamp).getTime()<Date.now(),t=new Date(n.expiration_timestamp).getTime()<Date.now();return n.subdomain&&e?!1:n.subdomain&&n.subdomain_expiration_policy===1?!0:!t}var Tb="0x37368b46ce665362562c6d1d4ec01a08c8644c488690df5a17e13ba163e20221",Ec="0x585fc9f0f0c54183b039ffc770ca282ebd87307916c215a3e692f2f8e4305e82",Cc={testnet:"0x5f8fd2347449685cf41d4db97926ec3a096eaf381332be4f1318ad4d16a8497c",mainnet:"0x867ed1f6bf916171b1de3ee92849b8978b7d1b9e0a8cc982a3d19d535dfd9c0c",local:Ec,custom:null,devnet:null,shelbynet:null,netna:null};function rt(n){let e=Cc[n.network];if(!e)throw new Error(`The ANS contract is not deployed to ${n.network}`);return e}var fr=n=>{if(n&&typeof n=="object"&&"vec"in n&&Array.isArray(n.vec))return n.vec[0]};async function Xs(n){let{aptosConfig:e,name:t}=n,r=rt(e),{domainName:i,subdomainName:o}=pt(t),s=await ae({aptosConfig:e,payload:{function:`${r}::router::get_owner_addr`,functionArguments:[i,o]}}),a=fr(s[0]);return a?u.from(a):void 0}async function ea(n){let{aptosConfig:e,expiration:t,name:r,sender:i,targetAddress:o,toAddress:s,options:a,transferable:c}=n,d=rt(e),{domainName:l,subdomainName:g}=pt(r),p=t.policy==="subdomain:independent"||t.policy==="subdomain:follow-domain";if(g&&!p)throw new Error("Subdomains must have an expiration policy of either 'subdomain:independent' or 'subdomain:follow-domain'");if(p&&!g)throw new Error(`Policy is set to ${t.policy} but no subdomain was provided`);if(t.policy==="domain"){let M=t.years??1;if(M!==1)throw new Error("For now, names can only be registered for 1 year at a time");let Me=M*31536e3;return await A({aptosConfig:e,sender:i.accountAddress.toString(),data:{function:`${d}::router::register_domain`,functionArguments:[l,Me,o,s]},options:a})}if(!g)throw new Error(`${t.policy} requires a subdomain to be provided.`);let y=await li({aptosConfig:e,name:l});if(!y)throw new Error("The domain does not exist");let h=t.policy==="subdomain:independent"?t.expirationDate:y;if(h>y)throw new Error("The subdomain expiration time cannot be greater than the domain expiration time");return await A({aptosConfig:e,sender:i.accountAddress.toString(),data:{function:`${d}::router::register_subdomain`,functionArguments:[l,g,Math.round(h/1e3),t.policy==="subdomain:follow-domain"?1:0,!!c,o,s]},options:a})}async function li(n){let{aptosConfig:e,name:t}=n,r=rt(e),{domainName:i,subdomainName:o}=pt(t);try{let s=await ae({aptosConfig:e,payload:{function:`${r}::router::get_expiration`,functionArguments:[i,o]}});return Number(s[0])*1e3}catch{return}}async function ta(n){let{aptosConfig:e,address:t}=n,r=rt(e),i=await ae({aptosConfig:e,payload:{function:`${r}::router::get_primary_name`,functionArguments:[u.from(t).toString()]}}),o=fr(i[1]),s=fr(i[0]);if(o)return[s,o].filter(Boolean).join(".")}async function na(n){let{aptosConfig:e,sender:t,name:r,options:i}=n,o=rt(e);if(!r)return await A({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${o}::router::clear_primary_name`,functionArguments:[]},options:i});let{domainName:s,subdomainName:a}=pt(r);return await A({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${o}::router::set_primary_name`,functionArguments:[s,a]},options:i})}async function ra(n){let{aptosConfig:e,name:t}=n,r=rt(e),{domainName:i,subdomainName:o}=pt(t),s=await ae({aptosConfig:e,payload:{function:`${r}::router::get_target_addr`,functionArguments:[i,o]}}),a=fr(s[0]);return a?u.from(a):void 0}async function ia(n){let{aptosConfig:e,sender:t,name:r,address:i,options:o}=n,s=rt(e),{domainName:a,subdomainName:c}=pt(r);return await A({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${s}::router::set_target_addr`,functionArguments:[a,c,i]},options:o})}async function oa(n){let{aptosConfig:e,name:t}=n,{domainName:r,subdomainName:i=""}=pt(t),a=(await P({aptosConfig:e,query:{query:Nt,variables:{where_condition:{domain:{_eq:r},subdomain:{_eq:i}},limit:1}},originMethod:"getName"})).current_aptos_names[0];return a&&(a=In(a)),Ys(a)?a:void 0}async function sa(n){let{aptosConfig:e,options:t,accountAddress:r}=n,i=await gi({aptosConfig:e});return(await P({aptosConfig:e,originMethod:"getAccountNames",query:{query:Nt,variables:{limit:t?.limit,offset:t?.offset,order_by:t?.orderBy,where_condition:{...n.options?.where??{},owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:i}}}}})).current_aptos_names.map(In)}async function aa(n){let{aptosConfig:e,options:t,accountAddress:r}=n,i=await gi({aptosConfig:e});return(await P({aptosConfig:e,originMethod:"getAccountDomains",query:{query:Nt,variables:{limit:t?.limit,offset:t?.offset,order_by:t?.orderBy,where_condition:{...n.options?.where??{},owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:i},subdomain:{_eq:""}}}}})).current_aptos_names.map(In)}async function ca(n){let{aptosConfig:e,options:t,accountAddress:r}=n,i=await gi({aptosConfig:e});return(await P({aptosConfig:e,originMethod:"getAccountSubdomains",query:{query:Nt,variables:{limit:t?.limit,offset:t?.offset,order_by:t?.orderBy,where_condition:{...n.options?.where??{},owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:i},subdomain:{_neq:""}}}}})).current_aptos_names.map(In)}async function ua(n){let{aptosConfig:e,options:t,domain:r}=n;return(await P({aptosConfig:e,originMethod:"getDomainSubdomains",query:{query:Nt,variables:{limit:t?.limit,offset:t?.offset,order_by:t?.orderBy,where_condition:{...n.options?.where??{},domain:{_eq:r},subdomain:{_neq:""}}}}})).current_aptos_names.map(In).filter(Ys)}async function gi(n){let{aptosConfig:e}=n,t=rt(e),[r]=await ae({aptosConfig:e,payload:{function:`${t}::config::reregistration_grace_sec`,functionArguments:[]}}),i=r/60/60/24,o=()=>new Date;return new Date(o().setDate(o().getDate()-i)).toISOString()}async function da(n){let{aptosConfig:e,sender:t,name:r,years:i=1,options:o}=n,s=rt(e),a=i*31536e3,{domainName:c,subdomainName:d}=pt(r);if(d)throw new Error("Subdomains cannot be renewed");if(i!==1)throw new Error("Currently, only 1 year renewals are supported");return await A({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${s}::router::renew_domain`,functionArguments:[c,a]},options:o})}function In(n){return{...n,expiration_timestamp:new Date(n.expiration_timestamp).getTime()}}var En=class{constructor(e){this.config=e}async getOwnerAddress(e){return Xs({aptosConfig:this.config,...e})}async getExpiration(e){return li({aptosConfig:this.config,...e})}async getTargetAddress(e){return ra({aptosConfig:this.config,...e})}async setTargetAddress(e){return ia({aptosConfig:this.config,...e})}async getPrimaryName(e){return ta({aptosConfig:this.config,...e})}async setPrimaryName(e){return na({aptosConfig:this.config,...e})}async registerName(e){return ea({aptosConfig:this.config,...e})}async renewDomain(e){return da({aptosConfig:this.config,...e})}async getName(e){return oa({aptosConfig:this.config,...e})}async getAccountNames(e){return sa({aptosConfig:this.config,...e})}async getAccountDomains(e){return aa({aptosConfig:this.config,...e})}async getAccountSubdomains(e){return ca({aptosConfig:this.config,...e})}async getDomainSubdomains(e){return ua({aptosConfig:this.config,...e})}};async function pa(n){let{aptosConfig:e,poolAddress:t}=n,r=u.from(t).toStringLong(),o=await P({aptosConfig:e,query:{query:zr,variables:{where_condition:{pool_address:{_eq:r}}}}});return o.num_active_delegator_per_pool[0]?o.num_active_delegator_per_pool[0].num_active_delegator:0}async function la(n){let{aptosConfig:e,options:t}=n,r={query:zr,variables:{order_by:t?.orderBy}};return(await P({aptosConfig:e,query:r})).num_active_delegator_per_pool}async function ga(n){let{aptosConfig:e,delegatorAddress:t,poolAddress:r}=n,i={query:lo,variables:{delegatorAddress:u.from(t).toStringLong(),poolAddress:u.from(r).toStringLong()}};return(await P({aptosConfig:e,query:i})).delegated_staking_activities}var Cn=class{constructor(e){this.config=e}async getNumberOfDelegators(e){return await T({config:this.config,minimumLedgerVersion:e?.minimumLedgerVersion,processorType:"stake_processor"}),pa({aptosConfig:this.config,...e})}async getNumberOfDelegatorsForAllPools(e){return await T({config:this.config,minimumLedgerVersion:e?.minimumLedgerVersion,processorType:"stake_processor"}),la({aptosConfig:this.config,...e})}async getDelegatedStakingActivities(e){return await T({config:this.config,minimumLedgerVersion:e?.minimumLedgerVersion,processorType:"stake_processor"}),ga({aptosConfig:this.config,...e})}};var Ar=class{constructor(e){this.config=e}async simple(e){return A({aptosConfig:this.config,...e})}async multiAgent(e){return A({aptosConfig:this.config,...e})}};var on=class{constructor(e){this.config=e}async simple(e){return ni({aptosConfig:this.config,...e})}async multiAgent(e){return ni({aptosConfig:this.config,...e})}};xr([Or],on.prototype,"simple",1),xr([Or],on.prototype,"multiAgent",1);var hr=class{constructor(e){this.config=e}async simple(e){return Rr(this.config,e),hn({aptosConfig:this.config,...e})}async multiAgent(e){return Rr(this.config,e),hn({aptosConfig:this.config,...e})}};import _c from"eventemitter3";var br=class{constructor(e,t,r,i,o){this.lastUncommintedNumber=null;this.currentNumber=null;this.lock=!1;this.aptosConfig=e,this.account=t,this.maxWaitTime=r,this.maximumInFlight=i,this.sleepTime=o}async nextSequenceNumber(){for(;this.lock;)await cn(this.sleepTime);this.lock=!0;let e=BigInt(0);try{if((this.lastUncommintedNumber===null||this.currentNumber===null)&&await this.initialize(),this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight){await this.update();let t=Ve();for(;this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight;)await cn(this.sleepTime),Ve()-t>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, re-syncing ${this.account.accountAddress.toString()}`),await this.initialize()):await this.update()}e=this.currentNumber,this.currentNumber+=BigInt(1)}catch(t){console.error("error in getting next sequence number for this account",t)}finally{this.lock=!1}return e}async initialize(){let{sequence_number:e}=await tn({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});this.currentNumber=BigInt(e),this.lastUncommintedNumber=BigInt(e)}async update(){let{sequence_number:e}=await tn({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});return this.lastUncommintedNumber=BigInt(e),this.lastUncommintedNumber}async synchronize(){if(this.lastUncommintedNumber!==this.currentNumber){for(;this.lock;)await cn(this.sleepTime);this.lock=!0;try{await this.update();let e=Ve();for(;this.lastUncommintedNumber!==this.currentNumber;)Ve()-e>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, re-syncing ${this.account.accountAddress.toString()}`),await this.initialize()):(await cn(this.sleepTime),await this.update())}catch(e){console.error("error in synchronizing this account sequence number with the one on chain",e)}finally{this.lock=!1}}}};import vc from"eventemitter3";var ya="fulfilled",ma=(o=>(o.TransactionSent="transactionSent",o.TransactionSendFailed="transactionSendFailed",o.TransactionExecuted="transactionExecuted",o.TransactionExecutionFailed="transactionExecutionFailed",o.ExecutionFinish="executionFinish",o))(ma||{}),wr=class extends vc{constructor(t,r,i=30,o=100,s=10){super();this.taskQueue=new Hn;this.transactionsQueue=new Hn;this.outstandingTransactions=new Hn;this.sentTransactions=[];this.executedTransactions=[];this.aptosConfig=t,this.account=r,this.started=!1,this.accountSequnceNumber=new br(t,r,i,o,s)}async submitNextTransaction(){try{for(;;){let t=await this.accountSequnceNumber.nextSequenceNumber();if(t===null)return;let r=await this.generateNextTransaction(this.account,t);if(!r)return;let i=lr({aptosConfig:this.aptosConfig,transaction:r,signer:this.account});await this.outstandingTransactions.enqueue([i,t])}}catch(t){if(t instanceof Nr)return;throw new Error(`Submit transaction failed for ${this.account.accountAddress.toString()} with error ${t}`)}}async processTransactions(){try{for(;;){let t=[],r=[],[i,o]=await this.outstandingTransactions.dequeue();for(t.push(i),r.push(o);!this.outstandingTransactions.isEmpty();)[i,o]=await this.outstandingTransactions.dequeue(),t.push(i),r.push(o);let s=await Promise.allSettled(t);for(let a=0;a<s.length&&a<r.length;a+=1){let c=s[a];o=r[a],c.status===ya?(this.sentTransactions.push([c.value.hash,o,null]),this.emit("transactionSent",{message:`transaction hash ${c.value.hash} has been committed to chain`,transactionHash:c.value.hash}),await this.checkTransaction(c,o)):(this.sentTransactions.push([c.status,o,c.reason]),this.emit("transactionSendFailed",{message:`failed to commit transaction ${this.sentTransactions.length} with error ${c.reason}`,error:c.reason}))}this.emit("executionFinish",{message:`execute ${s.length} transactions finished`})}}catch(t){if(t instanceof Nr)return;throw new Error(`Process execution failed for ${this.account.accountAddress.toString()} with error ${t}`)}}async checkTransaction(t,r){try{let i=[];i.push(Gt({aptosConfig:this.aptosConfig,transactionHash:t.value.hash}));let o=await Promise.allSettled(i);for(let s=0;s<o.length;s+=1){let a=o[s];a.status===ya?(this.executedTransactions.push([a.value.hash,r,null]),this.emit("transactionExecuted",{message:`transaction hash ${a.value.hash} has been executed on chain`,transactionHash:t.value.hash})):(this.executedTransactions.push([a.status,r,a.reason]),this.emit("transactionExecutionFailed",{message:`failed to execute transaction ${this.executedTransactions.length} with error ${a.reason}`,error:a.reason}))}}catch(i){throw new Error(`Check transaction failed for ${this.account.accountAddress.toString()} with error ${i}`)}}async push(t,r){this.transactionsQueue.enqueue([t,r])}async generateNextTransaction(t,r){if(this.transactionsQueue.isEmpty())return;let[i,o]=await this.transactionsQueue.dequeue();return A({aptosConfig:this.aptosConfig,sender:t.accountAddress,data:i,options:{...o,accountSequenceNumber:r,replayProtectionNonce:void 0}})}async run(){try{for(;!this.taskQueue.isCancelled();)await(await this.taskQueue.dequeue())()}catch(t){throw new Error(`Unable to start transaction batching: ${t}`)}}start(){if(this.started)throw new Error("worker has already started");this.started=!0,this.taskQueue.enqueue(()=>this.submitNextTransaction()),this.taskQueue.enqueue(()=>this.processTransactions()),this.run()}stop(){if(this.taskQueue.isCancelled())throw new Error("worker has already stopped");this.started=!1,this.taskQueue.cancel()}};var Tr=class extends _c{constructor(e){super(),this.config=e}start(e){let{sender:t}=e;this.account=t,this.transactionWorker=new wr(this.config,t),this.transactionWorker.start(),this.registerToEvents()}push(e){let{data:t,options:r}=e;for(let i of t)this.transactionWorker.push(i,r)}registerToEvents(){this.transactionWorker.on("transactionSent",async e=>{this.emit("transactionSent",e)}),this.transactionWorker.on("transactionSendFailed",async e=>{this.emit("transactionSendFailed",e)}),this.transactionWorker.on("transactionExecuted",async e=>{this.emit("transactionExecuted",e)}),this.transactionWorker.on("transactionExecutionFailed",async e=>{this.emit("transactionExecutionFailed",e)}),this.transactionWorker.on("executionFinish",async e=>{this.emit("executionFinish",e)})}forSingleAccount(e){try{let{sender:t,data:r,options:i}=e;this.start({sender:t}),this.push({data:r,options:i})}catch(t){throw new Error(`failed to submit transactions with error: ${t}`)}}};var vn=class{constructor(e){this.config=e,this.build=new Ar(this.config),this.simulate=new on(this.config),this.submit=new hr(this.config),this.batch=new Tr(this.config)}async getTransactions(e){return So({aptosConfig:this.config,...e})}async getTransactionByVersion(e){return Po({aptosConfig:this.config,...e})}async getTransactionByHash(e){return Ko({aptosConfig:this.config,...e})}async isPendingTransaction(e){return xo({aptosConfig:this.config,...e})}async waitForTransaction(e){return Gt({aptosConfig:this.config,...e})}async getGasPriceEstimation(){return Vn({aptosConfig:this.config})}getSigningMessage(e){return Zo(e)}async publishPackageTransaction(e){return Xo({aptosConfig:this.config,...e})}async rotateAuthKey(e){return gs({aptosConfig:this.config,...e})}async rotateAuthKeyUnverified(e){return ys({aptosConfig:this.config,...e})}sign(e){return dr({...e})}signAsFeePayer(e){return pr({...e})}async batchTransactionsForSingleAccount(e){try{let{sender:t,data:r,options:i}=e;this.batch.forSingleAccount({sender:t,data:r,options:i})}catch(t){throw new Error(`failed to submit transactions with error: ${t}`)}}async signAndSubmitTransaction(e){return lr({aptosConfig:this.config,...e})}async signAndSubmitAsFeePayer(e){return Yo({aptosConfig:this.config,...e})}};import{jwtDecode as kc}from"jwt-decode";async function Sr(n){let{aptosConfig:e,jwt:t,ephemeralKeyPair:r,uidKey:i="sub",derivationPath:o}=n,s={jwt_b64:t,epk:r.getPublicKey().bcsToHex().toStringWithoutPrefix(),exp_date_secs:r.expiryDateSecs,epk_blinder:m.fromHexInput(r.blinder).toStringWithoutPrefix(),uid_key:i,derivation_path:o},{data:a}=await Zi({aptosConfig:e,path:"fetch",body:s,originMethod:"getPepper",overrides:{WITH_CREDENTIALS:!1}});return m.fromHexInput(a.pepper).toUint8Array()}async function yi(n){let{aptosConfig:e,jwt:t,ephemeralKeyPair:r,pepper:i=await Sr(n),uidKey:o="sub",maxExpHorizonSecs:s=(await Xt({aptosConfig:e})).maxExpHorizonSecs}=n;if(m.fromHexInput(i).toUint8Array().length!==be.PEPPER_LENGTH)throw new Error(`Pepper needs to be ${be.PEPPER_LENGTH} bytes`);let a=kc(t);if(typeof a.iat!="number")throw new Error("iat was not found");if(s<r.expiryDateSecs-a.iat)throw Error(`The EphemeralKeyPair is too long lived. It's lifespan must be less than ${s}`);let c={jwt_b64:t,epk:r.getPublicKey().bcsToHex().toStringWithoutPrefix(),epk_blinder:m.fromHexInput(r.blinder).toStringWithoutPrefix(),exp_date_secs:r.expiryDateSecs,exp_horizon_secs:s,pepper:m.fromHexInput(i).toStringWithoutPrefix(),uid_key:o},{data:d}=await Yi({aptosConfig:e,path:"prove",body:c,originMethod:"getProof",overrides:{WITH_CREDENTIALS:!1}}),l=d.proof,g=new lt({a:l.a,b:l.b,c:l.c});return new ye({proof:new sn(g,0),trainingWheelsSignature:Ne.fromHex(d.training_wheels_signature),expHorizonSecs:s})}async function fa(n){let{aptosConfig:e,jwt:t,jwkAddress:r,uidKey:i,proofFetchCallback:o,pepper:s=await Sr(n)}=n,{verificationKey:a,maxExpHorizonSecs:c}=await Xt({aptosConfig:e}),d=yi({...n,pepper:s,maxExpHorizonSecs:c}),l=o?d:await d;if(r!==void 0){let y=G.fromJwtAndPepper({jwt:t,pepper:s,jwkAddress:r,uidKey:i}),h=await nn({aptosConfig:e,authenticationKey:y.authKey().derivedAddress()});return ve.create({...n,address:h,proof:l,pepper:s,proofFetchCallback:o,jwkAddress:r,verificationKey:a})}let g=E.fromJwtAndPepper({jwt:t,pepper:s,uidKey:i}),p=await nn({aptosConfig:e,authenticationKey:g.authKey().derivedAddress()});return be.create({...n,address:p,proof:l,pepper:s,proofFetchCallback:o,verificationKey:a})}async function Aa(n){let{aptosConfig:e,sender:t,iss:r,options:i}=n,{jwksUrl:o}=n;o===void 0&&(Mi.test(r)?o="https://www.googleapis.com/service_accounts/v1/jwk/securetoken@system.gserviceaccount.com":o=r.endsWith("/")?`${r}.well-known/jwks.json`:`${r}/.well-known/jwks.json`);let s;try{if(s=await fetch(o),!s.ok)throw new Error(`${s.status} ${s.statusText}`)}catch(c){let d;throw c instanceof Error?d=`${c.message}`:d=`error unknown - ${c}`,S.fromErrorType({type:14,details:`Failed to fetch JWKS at ${o}: ${d}`})}let a=await s.json();return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::jwks::update_federated_jwk_set",functionArguments:[r,K.MoveString(a.keys.map(c=>c.kid)),K.MoveString(a.keys.map(c=>c.alg)),K.MoveString(a.keys.map(c=>c.e)),K.MoveString(a.keys.map(c=>c.n))]},options:i})}var _n=class{constructor(e){this.config=e}async getPepper(e){return Sr({aptosConfig:this.config,...e})}async getProof(e){return yi({aptosConfig:this.config,...e})}async deriveKeylessAccount(e){return fa({aptosConfig:this.config,...e})}async updateFederatedKeylessJwkSetTransaction(e){return Aa({aptosConfig:this.config,...e})}};async function Fc(n){let{aptosConfig:e,options:t}=n,r={query:Gn,variables:{where_condition:t?.where,offset:t?.offset,limit:t?.limit,order_by:t?.orderBy}};return(await P({aptosConfig:e,query:r,originMethod:"getObjectData"})).current_objects}async function ha(n){let{aptosConfig:e,objectAddress:t,options:r}=n,o={object_address:{_eq:u.from(t).toStringLong()}};return(await Fc({aptosConfig:e,options:{...r,where:o}}))[0]}var Un=class{constructor(e){this.config=e}async getObjectDataByObjectAddress(e){return await T({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"objects_processor"}),ha({aptosConfig:this.config,...e})}};var J=class{constructor(e){this.config=e??new vo,this.account=new bn(this.config),this.abstraction=new xt(this.config),this.ans=new En(this.config),this.coin=new Tn(this.config),this.digitalAsset=new Sn(this.config),this.faucet=new Pn(this.config),this.fungibleAsset=new Kn(this.config),this.general=new xn(this.config),this.staking=new Cn(this.config),this.transaction=new vn(this.config),this.table=new Gr(this.config),this.keyless=new _n(this.config),this.object=new Un(this.config)}setIgnoreTransactionSubmitter(e){this.config.setIgnoreTransactionSubmitter(e)}};function ce(n,e,t){Object.getOwnPropertyNames(e.prototype).forEach(r=>{let i=Object.getOwnPropertyDescriptor(e.prototype,r);i&&Object.defineProperty(n.prototype,r,{value:function(...o){return this[t][r](...o)},writable:i.writable,configurable:i.configurable,enumerable:i.enumerable})})}ce(J,bn,"account");ce(J,xt,"abstraction");ce(J,En,"ans");ce(J,Tn,"coin");ce(J,Sn,"digitalAsset");ce(J,Event,"event");ce(J,Pn,"faucet");ce(J,Kn,"fungibleAsset");ce(J,xn,"general");ce(J,Cn,"staking");ce(J,vn,"transaction");ce(J,Gr,"table");ce(J,_n,"keyless");ce(J,Un,"object");var Oc=1e7,mi=120,Nc=30,Gc=330,Mc=120,Bc=350,Vc=300,Hc=93,Ge=class Ge extends ke{constructor(e,t){super();let r=m.fromHexInput(t).toUint8Array();if(r.length!==Ge.ID_COMMITMENT_LENGTH)throw new Error(`Id Commitment length in bytes should be ${Ge.ID_COMMITMENT_LENGTH}`);this.iss=e,this.idCommitment=r}authKey(){let e=new ee;return e.serializeU32AsUleb128(3),e.serializeFixedBytes(this.bcsToBytes()),ne.fromSchemeAndBytes({scheme:2,input:e.toUint8Array()})}verifySignature(e){try{return Pr({...e,publicKey:this}),!0}catch(t){if(t instanceof S)return!1;throw t}}async verifySignatureAsync(e){return Ti({...e,publicKey:this})}serialize(e){e.serializeStr(this.iss),e.serializeBytes(this.idCommitment)}static deserialize(e){let t=e.deserializeStr(),r=e.deserializeBytes();return new Ge(t,r)}static load(e){let t=e.deserializeStr(),r=e.deserializeBytes();return new Ge(t,r)}static isPublicKey(e){return e instanceof Ge}static create(e){return ba(e),new Ge(e.iss,ba(e))}static fromJwtAndPepper(e){let{jwt:t,pepper:r,uidKey:i="sub"}=e,o=wa(t);if(typeof o.iss!="string")throw new Error("iss was not found");if(typeof o.aud!="string")throw new Error("aud was not found or an array of values");let s=o[i];return Ge.create({iss:o.iss,uidKey:i,uidVal:s,aud:o.aud,pepper:r})}static isInstance(e){return"iss"in e&&typeof e.iss=="string"&&"idCommitment"in e&&e.idCommitment instanceof Uint8Array}};Ge.ID_COMMITMENT_LENGTH=32;var E=Ge;async function Ti(n){let{aptosConfig:e,publicKey:t,message:r,signature:i,jwk:o,keylessConfig:s=await Xt({aptosConfig:e}),options:a}=n;try{if(!(i instanceof re))throw S.fromErrorType({type:26,details:"Not a keyless signature"});return Pr({message:r,publicKey:t,signature:i,jwk:o||await Br({aptosConfig:e,publicKey:t,kid:i.getJwkKid()}),keylessConfig:s}),!0}catch(c){if(a?.throwErrorWithReason)throw c;return!1}}function Pr(n){let{publicKey:e,message:t,signature:r,keylessConfig:i,jwk:o}=n,{verificationKey:s,maxExpHorizonSecs:a,trainingWheelsPubkey:c}=i;if(!(r instanceof re))throw S.fromErrorType({type:26,details:"Not a keyless signature"});if(!(r.ephemeralCertificate.signature instanceof ye))throw S.fromErrorType({type:26,details:"Unsupported ephemeral certificate variant"});let d=r.ephemeralCertificate.signature;if(!(d.proof.proof instanceof lt))throw S.fromErrorType({type:26,details:"Unsupported proof variant for ZeroKnowledgeSig"});let l=d.proof.proof;if(r.expiryDateSecs<Ve())throw S.fromErrorType({type:27,details:"The expiryDateSecs is in the past"});if(d.expHorizonSecs>a)throw S.fromErrorType({type:28});if(!r.ephemeralPublicKey.verifySignature({message:t,signature:r.ephemeralSignature}))throw S.fromErrorType({type:29});let g=Lc({publicKey:e,signature:r,jwk:o,keylessConfig:i});if(!s.verifyProof({publicInputsHash:g,groth16Proof:l}))throw S.fromErrorType({type:32});if(c){if(!d.trainingWheelsSignature)throw S.fromErrorType({type:30});let p=new Ai(l,g);if(!c.verifySignature({message:p.hash(),signature:d.trainingWheelsSignature}))throw S.fromErrorType({type:31})}}function Lc(n){let{publicKey:e,signature:t,jwk:r,keylessConfig:i}=n,o=e instanceof E?e:e.keylessPublicKey;if(!(t.ephemeralCertificate.signature instanceof ye))throw new Error("Signature is not a ZeroKnowledgeSig");let s=t.ephemeralCertificate.signature,a=[];return a.push(...Rn(t.ephemeralPublicKey.toUint8Array(),i.maxCommitedEpkBytes)),a.push(Ft(o.idCommitment)),a.push(t.expiryDateSecs),a.push(s.expHorizonSecs),a.push(Fe(o.iss,i.maxIssValBytes)),s.extraField?(a.push(1n),a.push(Fe(s.extraField,i.maxExtraFieldBytes))):(a.push(0n),a.push(Fe(" ",i.maxExtraFieldBytes))),a.push(Fe(Rc(t.jwtHeader,!0)+".",i.maxJwtHeaderB64Bytes)),a.push(r.toScalar()),s.overrideAudVal?(a.push(Fe(s.overrideAudVal,mi)),a.push(1n)):(a.push(Fe("",mi)),a.push(0n)),zt(a)}async function Br(n){let{aptosConfig:e,publicKey:t,kid:r}=n,i=t instanceof E?t:t.keylessPublicKey,{iss:o}=i,s,a=t instanceof G?t.jwkAddress:void 0;try{s=await Wc({aptosConfig:e,jwkAddr:a})}catch(l){throw S.fromErrorType({type:24,error:l,details:`Failed to fetch ${a?"Federated":"Patched"}JWKs ${a?`for address ${a}`:"0x1"}`})}let c=s.get(o);if(c===void 0)throw S.fromErrorType({type:7,details:`JWKs for issuer ${o} not found.`});let d=c.find(l=>l.kid===r);if(d===void 0)throw S.fromErrorType({type:6,details:`JWK with kid '${r}' for issuer '${o}' not found.`});return d}function ba(n){let{uidKey:e,uidVal:t,aud:r,pepper:i}=n,o=[Ft(m.fromHexInput(i).toUint8Array()),Fe(r,mi),Fe(t,Gc),Fe(e,Nc)];return Er(zt(o),E.ID_COMMITMENT_LENGTH)}var re=class n extends Q{constructor(e){super();let{jwtHeader:t,ephemeralCertificate:r,expiryDateSecs:i,ephemeralPublicKey:o,ephemeralSignature:s}=e;this.jwtHeader=t,this.ephemeralCertificate=r,this.expiryDateSecs=i,this.ephemeralPublicKey=o,this.ephemeralSignature=s}getJwkKid(){return Qc(this.jwtHeader).kid}serialize(e){this.ephemeralCertificate.serialize(e),e.serializeStr(this.jwtHeader),e.serializeU64(this.expiryDateSecs),this.ephemeralPublicKey.serialize(e),this.ephemeralSignature.serialize(e)}static deserialize(e){let t=Yt.deserialize(e),r=e.deserializeStr(),i=e.deserializeU64(),o=ut.deserialize(e),s=Ne.deserialize(e);return new n({jwtHeader:r,expiryDateSecs:Number(i),ephemeralCertificate:t,ephemeralPublicKey:o,ephemeralSignature:s})}static getSimulationSignature(){return new n({jwtHeader:"{}",ephemeralCertificate:new Yt(new ye({proof:new sn(new lt({a:new Uint8Array(32),b:new Uint8Array(64),c:new Uint8Array(32)}),0),expHorizonSecs:0}),0),expiryDateSecs:0,ephemeralPublicKey:new ut(new b(new Uint8Array(32))),ephemeralSignature:new Ne(new C(new Uint8Array(64)))})}static isSignature(e){return e instanceof n}},Yt=class n extends Q{constructor(e,t){super(),this.signature=e,this.variant=t}toUint8Array(){return this.signature.toUint8Array()}serialize(e){e.serializeU32AsUleb128(this.variant),this.signature.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new n(ye.deserialize(e),t);default:throw new Error(`Unknown variant index for EphemeralCertificate: ${t}`)}}},kn=class kn extends w{constructor(e){if(super(),this.data=m.fromHexInput(e).toUint8Array(),this.data.length!==32)throw new Error("Input needs to be 32 bytes")}serialize(e){e.serializeFixedBytes(this.data)}static deserialize(e){let t=e.deserializeFixedBytes(32);return new kn(t)}toArray(){let e=this.toProjectivePoint();return[e.x.toString(),e.y.toString(),e.pz.toString()]}toProjectivePoint(){let e=new Uint8Array(this.data);e.reverse();let t=(e[0]&128)>>7,{Fp:r}=Ue.fields,i=r.create(fi(e)),o=r.sqrt(r.add(r.pow(i,3n),kn.B)),s=r.neg(o),a=o>s==(t===1)?o:s;return Ue.G1.ProjectivePoint.fromAffine({x:i,y:a})}};kn.B=Ue.fields.Fp.create(3n);var it=kn;function fi(n){if(n.length!==32)throw new Error("Input should be 32 bytes");let e=new Uint8Array(n);return e[0]=e[0]&63,Dc(e)}var Fn=class Fn extends w{constructor(e){if(super(),this.data=m.fromHexInput(e).toUint8Array(),this.data.length!==64)throw new Error("Input needs to be 64 bytes")}serialize(e){e.serializeFixedBytes(this.data)}static deserialize(e){let t=e.deserializeFixedBytes(64);return new Fn(t)}toArray(){let e=this.toProjectivePoint();return[[e.x.c0.toString(),e.x.c1.toString()],[e.y.c0.toString(),e.y.c1.toString()],[e.pz.c0.toString(),e.pz.c1.toString()]]}toProjectivePoint(){let e=new Uint8Array(this.data),t=e.slice(0,32).reverse(),r=e.slice(32,64).reverse(),i=(r[0]&128)>>7,{Fp2:o}=Ue.fields,s=o.fromBigTuple([fi(t),fi(r)]),a=o.sqrt(o.add(o.pow(s,3n),Fn.B)),c=o.neg(a),l=(a.c1>c.c1||a.c1===c.c1&&a.c0>c.c0)===(i===1)?a:c;return Ue.G2.ProjectivePoint.fromAffine({x:s,y:l})}};Fn.B=Ue.fields.Fp2.fromBigTuple([19485874751759354771024239261021720505790618469301721065564631296452457478373n,266929791119991161246907387137283842545076965332900288569378510910307636690n]);var It=Fn,lt=class n extends Di{constructor(e){super();let{a:t,b:r,c:i}=e;this.a=new it(t),this.b=new It(r),this.c=new it(i)}serialize(e){this.a.serialize(e),this.b.serialize(e),this.c.serialize(e)}static deserialize(e){let t=it.deserialize(e).bcsToBytes(),r=It.deserialize(e).bcsToBytes(),i=it.deserialize(e).bcsToBytes();return new n({a:t,b:r,c:i})}toSnarkJsJson(){return{protocol:"groth16",curve:"bn128",pi_a:this.a.toArray(),pi_b:this.b.toArray(),pi_c:this.c.toArray()}}},Ai=class n extends w{constructor(t,r){super();this.domainSeparator="APTOS::Groth16ProofAndStatement";if(this.proof=t,this.publicInputsHash=typeof r=="bigint"?Er(r,32):m.fromHexInput(r).toUint8Array(),this.publicInputsHash.length!==32)throw new Error("Invalid public inputs hash")}serialize(t){this.proof.serialize(t),t.serializeFixedBytes(this.publicInputsHash)}static deserialize(t){return new n(lt.deserialize(t),t.deserializeFixedBytes(32))}hash(){return Oe(this.bcsToBytes(),this.domainSeparator)}},sn=class n extends w{constructor(e,t){super(),this.proof=e,this.variant=t}serialize(e){e.serializeU32AsUleb128(this.variant),this.proof.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new n(lt.deserialize(e),t);default:throw new Error(`Unknown variant index for ZkProof: ${t}`)}}},ye=class n extends Q{constructor(e){super();let{proof:t,expHorizonSecs:r,trainingWheelsSignature:i,extraField:o,overrideAudVal:s}=e;this.proof=t,this.expHorizonSecs=r,this.trainingWheelsSignature=i,this.extraField=o,this.overrideAudVal=s}static fromBytes(e){return n.deserialize(new k(e))}serialize(e){this.proof.serialize(e),e.serializeU64(this.expHorizonSecs),e.serializeOption(this.extraField),e.serializeOption(this.overrideAudVal),e.serializeOption(this.trainingWheelsSignature)}static deserialize(e){let t=sn.deserialize(e),r=Number(e.deserializeU64()),i=e.deserializeOption("string"),o=e.deserializeOption("string"),s=e.deserializeOption(Ne);return new n({proof:t,expHorizonSecs:r,trainingWheelsSignature:s,extraField:i,overrideAudVal:o})}},hi=class n{constructor(e){let{verificationKey:t,trainingWheelsPubkey:r,maxExpHorizonSecs:i=Oc,maxExtraFieldBytes:o=Bc,maxJwtHeaderB64Bytes:s=Vc,maxIssValBytes:a=Mc,maxCommitedEpkBytes:c=Hc}=e;this.verificationKey=t,this.maxExpHorizonSecs=i,r&&(this.trainingWheelsPubkey=new ut(new b(r))),this.maxExtraFieldBytes=o,this.maxJwtHeaderB64Bytes=s,this.maxIssValBytes=a,this.maxCommitedEpkBytes=c}static create(e,t){return new n({verificationKey:new bi({alphaG1:e.alpha_g1,betaG2:e.beta_g2,deltaG2:e.delta_g2,gammaAbcG1:e.gamma_abc_g1,gammaG2:e.gamma_g2}),maxExpHorizonSecs:Number(t.max_exp_horizon_secs),trainingWheelsPubkey:t.training_wheels_pubkey.vec[0],maxExtraFieldBytes:t.max_extra_field_bytes,maxJwtHeaderB64Bytes:t.max_jwt_header_b64_bytes,maxIssValBytes:t.max_iss_val_bytes,maxCommitedEpkBytes:t.max_commited_epk_bytes})}},bi=class n{constructor(e){let{alphaG1:t,betaG2:r,deltaG2:i,gammaAbcG1:o,gammaG2:s}=e;this.alphaG1=new it(t),this.betaG2=new It(r),this.deltaG2=new It(i),this.gammaAbcG1=[new it(o[0]),new it(o[1])],this.gammaG2=new It(s)}hash(){let e=new ee;return this.serialize(e),zc.create().update(e.toUint8Array()).digest()}serialize(e){this.alphaG1.serialize(e),this.betaG2.serialize(e),this.deltaG2.serialize(e),this.gammaAbcG1[0].serialize(e),this.gammaAbcG1[1].serialize(e),this.gammaG2.serialize(e)}static fromGroth16VerificationKeyResponse(e){return new n({alphaG1:e.alpha_g1,betaG2:e.beta_g2,deltaG2:e.delta_g2,gammaAbcG1:e.gamma_abc_g1,gammaG2:e.gamma_g2})}verifyProof(e){let{publicInputsHash:t,groth16Proof:r}=e;try{let i=r.a.toProjectivePoint(),o=r.b.toProjectivePoint(),s=r.c.toProjectivePoint(),a=this.alphaG1.toProjectivePoint(),c=this.betaG2.toProjectivePoint(),d=this.gammaG2.toProjectivePoint(),l=this.deltaG2.toProjectivePoint(),g=this.gammaAbcG1.map(ot=>ot.toProjectivePoint()),{Fp12:p}=Ue.fields,y=g[0].add(g[1].multiply(t)),h=Ue.pairing(y,d),U=Ue.pairing(i,o),M=Ue.pairing(a,c),X=Ue.pairing(s,l),Me=p.mul(M,p.mul(h,X));return p.eql(U,Me)}catch(i){throw S.fromErrorType({type:32,error:i,details:"Error encountered when checking zero knowledge relation"})}}toSnarkJsJson(){return{protocol:"groth16",curve:"bn128",nPublic:1,vk_alpha_1:this.alphaG1.toArray(),vk_beta_2:this.betaG2.toArray(),vk_gamma_2:this.gammaG2.toArray(),vk_delta_2:this.deltaG2.toArray(),IC:this.gammaAbcG1.map(e=>e.toArray())}}};async function Xt(n){let{aptosConfig:e}=n;try{return await Ot(async()=>{let[t,r]=await Promise.all([$c(n),qc(n)]);return hi.create(r,t)},`keyless-configuration-${e.network}`,1e3*60*5)()}catch(t){throw t instanceof S?t:S.fromErrorType({type:25,error:t})}}function et(n){let{jwt:e,uidKey:t="sub"}=n,r;try{r=wa(e)}catch(o){throw S.fromErrorType({type:12,details:`Failed to parse JWT - ${Vi(o)}`})}if(typeof r.iss!="string")throw S.fromErrorType({type:12,details:"JWT is missing 'iss' in the payload. This should never happen."});if(typeof r.aud!="string")throw S.fromErrorType({type:12,details:"JWT is missing 'aud' in the payload or 'aud' is an array of values."});let i=r[t];return{iss:r.iss,aud:r.aud,uidVal:i}}async function $c(n){let{aptosConfig:e,options:t}=n,r="0x1::keyless_account::Configuration";try{let{data:i}=await st({aptosConfig:e,originMethod:"getKeylessConfigurationResource",path:`accounts/${u.from("0x1").toString()}/resource/${r}`,params:{ledger_version:t?.ledgerVersion}});return i.data}catch(i){throw S.fromErrorType({type:22,error:i})}}async function qc(n){let{aptosConfig:e,options:t}=n,r="0x1::keyless_account::Groth16VerificationKey";try{let{data:i}=await st({aptosConfig:e,originMethod:"getGroth16VerificationKeyResource",path:`accounts/${u.from("0x1").toString()}/resource/${r}`,params:{ledger_version:t?.ledgerVersion}});return i.data}catch(i){throw S.fromErrorType({type:23,error:i})}}async function Wc(n){let{aptosConfig:e,jwkAddr:t,options:r}=n,i;if(t){let s="0x1::jwks::FederatedJWKs",{data:a}=await st({aptosConfig:e,originMethod:"getKeylessJWKs",path:`accounts/${u.from(t).toString()}/resource/${s}`,params:{ledger_version:r?.ledgerVersion}});i=a}else{let s="0x1::jwks::PatchedJWKs",{data:a}=await st({aptosConfig:e,originMethod:"getKeylessJWKs",path:`accounts/0x1/resource/${s}`,params:{ledger_version:r?.ledgerVersion}});i=a}let o=new Map;for(let s of i.data.jwks.entries){let a=[];for(let c of s.jwks){let{data:d}=c.variant,l=new k(m.fromHexInput(d).toUint8Array()),g=wi.deserialize(l);a.push(g)}o.set(Ki(s.issuer),a)}return o}var wi=class n extends w{constructor(e){super();let{kid:t,kty:r,alg:i,e:o,n:s}=e;this.kid=t,this.kty=r,this.alg=i,this.e=o,this.n=s}serialize(e){e.serializeStr(this.kid),e.serializeStr(this.kty),e.serializeStr(this.alg),e.serializeStr(this.e),e.serializeStr(this.n)}static fromMoveStruct(e){let{data:t}=e.variant,r=new k(m.fromHexInput(t).toUint8Array());return n.deserialize(r)}toScalar(){if(this.alg!=="RS256")throw S.fromErrorType({type:32,details:"Failed to convert JWK to scalar when calculating the public inputs hash. Only RSA 256 is supported currently"});let e=$i(this.n),r=jc(e.reverse()).map(i=>Ft(i));return r.push(256n),zt(r)}static deserialize(e){let t=e.deserializeStr(),r=e.deserializeStr(),i=e.deserializeStr(),o=e.deserializeStr(),s=e.deserializeStr();return new n({kid:t,kty:r,alg:i,n:s,e:o})}};function jc(n){let e=[];for(let t=0;t<n.length;t+=24){let r=n.slice(t,Math.min(t+24,n.length));if(r.length<24){let i=new Uint8Array(24);i.set(r),e.push(i)}else e.push(r)}return e}function Qc(n){try{let e=JSON.parse(n);if(e.kid===void 0)throw new Error("JWT header missing kid");return e}catch{throw new Error("Failed to parse JWT header.")}}var G=class n extends ke{constructor(e,t){super(),this.jwkAddress=u.from(e),this.keylessPublicKey=t}authKey(){let e=new ee;return e.serializeU32AsUleb128(4),e.serializeFixedBytes(this.bcsToBytes()),ne.fromSchemeAndBytes({scheme:2,input:e.toUint8Array()})}verifySignature(e){try{return Pr({...e,publicKey:this}),!0}catch{return!1}}serialize(e){this.jwkAddress.serialize(e),this.keylessPublicKey.serialize(e)}static deserialize(e){let t=u.deserialize(e),r=E.deserialize(e);return new n(t,r)}static isPublicKey(e){return e instanceof n}async verifySignatureAsync(e){return Ti({...e,publicKey:this})}static create(e){return new n(e.jwkAddress,E.create(e))}static fromJwtAndPepper(e){return new n(e.jwkAddress,E.fromJwtAndPepper(e))}static isInstance(e){return"jwkAddress"in e&&e.jwkAddress instanceof u&&"keylessPublicKey"in e&&e.keylessPublicKey instanceof E}};var Bt=n=>typeof n=="string"?m.isValid(n).valid?n:new TextEncoder().encode(n):n,ii=n=>{if(n instanceof b||n instanceof x||n instanceof Z||n instanceof B)return n;if(n instanceof E||n instanceof G)return new x(n);throw new Error(`Unknown account public key: ${n}`)},es=n=>{let e=ii(n);if(e instanceof b)return 0;if(e instanceof x)return 2;if(e instanceof Z)return 1;if(e instanceof B)return 3;throw new Error(`Unknown signing scheme: ${e}`)};var Si=[237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16];function Jc(n){let e=n.toUint8Array().slice(32);for(let t=Si.length-1;t>=0;t-=1){if(e[t]<Si[t])return!0;if(e[t]>Si[t])return!1}return!1}var gt=class gt extends ke{constructor(e){super();let t=m.fromHexInput(e);if(t.toUint8Array().length!==gt.LENGTH)throw new Error(`PublicKey length should be ${gt.LENGTH}`);this.key=t}verifySignature(e){let{message:t,signature:r}=e;if(!Jc(r))return!1;let i=Bt(t),o=m.fromHexInput(i).toUint8Array(),s=r.toUint8Array(),a=this.key.toUint8Array();return Kr.verify(s,o,a)}async verifySignatureAsync(e){return this.verifySignature(e)}authKey(){return ne.fromSchemeAndBytes({scheme:0,input:this.toUint8Array()})}toUint8Array(){return this.key.toUint8Array()}serialize(e){e.serializeBytes(this.key.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new gt(t)}static isPublicKey(e){return e instanceof gt}static isInstance(e){return"key"in e&&e.key?.data?.length===gt.LENGTH}};gt.LENGTH=32;var b=gt,Te=class Te extends w{constructor(e,t){super();let r=kt.parseHexInput(e,"ed25519",t);if(r.toUint8Array().length!==Te.LENGTH)throw new Error(`PrivateKey length should be ${Te.LENGTH}`);this.signingKey=r}static generate(){let e=Kr.utils.randomPrivateKey();return new Te(e,!1)}static fromDerivationPath(e,t){if(!Ui(e))throw new Error(`Invalid derivation path ${e}`);return Te.fromDerivationPathInner(e,Dn(t))}static fromDerivationPathInner(e,t,r=vi){let{key:i,chainCode:o}=ki(Te.SLIP_0010_SEED,t),s=zi(e).map(c=>parseInt(c,10)),{key:a}=s.reduce((c,d)=>Fi(c,d+r),{key:i,chainCode:o});return new Te(a,!1)}publicKey(){let e=Kr.getPublicKey(this.signingKey.toUint8Array());return new b(e)}sign(e){let t=Bt(e),r=m.fromHexInput(t).toUint8Array(),i=Kr.sign(r,this.signingKey.toUint8Array());return new C(i)}toUint8Array(){return this.signingKey.toUint8Array()}toString(){return this.toAIP80String()}toHexString(){return this.signingKey.toString()}toAIP80String(){return kt.formatPrivateKey(this.signingKey.toString(),"ed25519")}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new Te(t,!1)}static isPrivateKey(e){return e instanceof Te}};Te.LENGTH=32,Te.SLIP_0010_SEED="ed25519 seed";var L=Te,an=class an extends Q{constructor(e){super();let t=m.fromHexInput(e);if(t.toUint8Array().length!==an.LENGTH)throw new Error(`Signature length should be ${an.LENGTH}`);this.data=t}toUint8Array(){return this.data.toUint8Array()}serialize(e){e.serializeBytes(this.data.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new an(t)}};an.LENGTH=64;var C=an;var ut=class n extends zn{constructor(e){super();let t=e.constructor.name;switch(t){case b.name:this.publicKey=e,this.variant=0;break;default:throw new Error(`Unsupported key for EphemeralPublicKey - ${t}`)}}verifySignature(e){let{message:t,signature:r}=e;return this.publicKey.verifySignature({message:t,signature:r.signature})}async verifySignatureAsync(e){return this.verifySignature(e)}serialize(e){if(this.publicKey instanceof b)e.serializeU32AsUleb128(0),this.publicKey.serialize(e);else throw new Error("Unknown public key type")}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new n(b.deserialize(e));default:throw new Error(`Unknown variant index for EphemeralPublicKey: ${t}`)}}static isPublicKey(e){return e instanceof n}},Ne=class n extends Q{constructor(e){super();let t=e.constructor.name;switch(t){case C.name:this.signature=e;break;default:throw new Error(`Unsupported signature for EphemeralSignature - ${t}`)}}static fromHex(e){let t=m.fromHexInput(e),r=new k(t.toUint8Array());return n.deserialize(r)}serialize(e){if(this.signature instanceof C)e.serializeU32AsUleb128(0),this.signature.serialize(e);else throw new Error("Unknown signature type")}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new n(C.deserialize(e));default:throw new Error(`Unknown variant index for EphemeralSignature: ${t}`)}}};export{ut as a,Ne as b,Oc as c,mi as d,Nc as e,Gc as f,Mc as g,Bc as h,Vc as i,Hc as j,E as k,Ti as l,Pr as m,Br as n,re as o,Yt as p,lt as q,Ai as r,sn as s,ye as t,hi as u,bi as v,Xt as w,et as x,Wc as y,wi as z,Qc as A,G as B,Ke as C,He as D,Le as E,x as F,D as G,xe as H,B as I,Ae as J,Z as K,Ie as L,Bt as M,ii as N,es as O,Jc as P,b as Q,L as R,C as S,ed as T,td as U,q as V,Ee as W,$e as X,ie as Y,De as Z,Vt as _,yt as $,Wn as aa,dn as ba,O as ca,V as da,oe as ea,qe as fa,We as ga,W as ha,je as ia,Qe as ja,R as ka,mt as la,jn as ma,N as na,v as oa,f as pa,Re as qa,Qd as ra,I as sa,Jd as ta,ge as ua,Ka as va,at as wa,Ht as xa,Lt as ya,$t as za,Je as Aa,qt as Ba,pn as Ca,ln as Da,Qn as Ea,ft as Fa,Wt as Ga,gn as Ha,jt as Ia,yn as Ja,Jn as Ka,At as La,he as Ma,Zn as Na,ht as Oa,bt as Pa,Ze as Qa,wt as Ra,Qt as Sa,Tt as Ta,St as Ua,ct as Va,Ye as Wa,Yn as Xa,Xn as Ya,er as Za,Oe as _a,dl as $a,Ce as ab,Y as bb,Mr as cb,se as db,Xe as eb,Pt as fb,nr as gb,me as hb,tr as ib,be as jb,ve as kb,tt as lb,mn as mb,ko as nb,Do as ob,rr as pb,Oo as qb,Na as rb,$ as sb,_e as tb,Mo as ub,nt as vb,Ga as wb,ir as xb,or as yb,Bo as zb,Vo as Ab,Hr as Bb,sr as Cb,Lr as Db,Ma as Eb,$r as Fb,qr as Gb,Wr as Hb,jr as Ib,Qr as Jb,Jr as Kb,Ho as Lb,_ as Mb,Lo as Nb,ar as Ob,Va as Pb,Yr as Qb,hm as Rb,$o as Sb,qo as Tb,Xr as Ub,Kt as Vb,ur as Wb,$a as Xb,Wo as Yb,qa as Zb,ja as _b,Qa as $b,ei as ac,jo as bc,en as cc,ti as dc,Qo as ec,$m as fc,A as gc,Ya as hc,Xa as ic,Zo as jc,dr as kc,pr as lc,ni as mc,hn as nc,lr as oc,Yo as pc,Xo as qc,tn as rc,ts as sc,ns as tc,cr as uc,oi as vc,si as wc,rs as xc,ai as yc,nn as zc,is as Ac,os as Bc,ss as Cc,as as Dc,cs as Ec,gA as Fc,ci as Gc,us as Hc,ds as Ic,ui as Jc,ps as Kc,yA as Lc,gs as Mc,ys as Nc,yr as Oc,di as Pc,ae as Qc,ms as Rc,fs as Sc,As as Tc,hs as Uc,xt as Vc,bn as Wc,bs as Xc,Tn as Yc,ws as Zc,Ts as _c,Ss as $c,Ps as ad,Ks as bd,rn as cd,xs as dd,Is as ed,Es as fd,Cs as gd,vs as hd,_s as id,Us as jd,ks as kd,Fs as ld,zs as md,Ds as nd,Rs as od,Os as pd,Ns as qd,Gs as rd,Ms as sd,Bs as td,Vs as ud,Sn as vd,Ls as wd,Pn as xd,mr as yd,$s as zd,qs as Ad,js as Bd,Qs as Cd,Kn as Dd,xn as Ed,Js as Fd,Zs as Gd,pt as Hd,Ic as Id,Ys as Jd,Tb as Kd,Ec as Ld,Xs as Md,ea as Nd,li as Od,ta as Pd,na as Qd,ra as Rd,ia as Sd,oa as Td,sa as Ud,aa as Vd,ca as Wd,ua as Xd,da as Yd,En as Zd,pa as _d,la as $d,ga as ae,Cn as be,Ar as ce,on as de,hr as ee,br as fe,ya as ge,ma as he,wr as ie,Tr as je,vn as ke,Sr as le,yi as me,fa as ne,Aa as oe,_n as pe,Fc as qe,ha as re,Un as se,J as te};
4
+ //# sourceMappingURL=chunk-PJTG745G.mjs.map