@wormhole-foundation/wormhole-connect 1.0.0-beta.3-development → 1.0.0-beta.4-development

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. package/dist/assets/{ccip-YN27M9dL.js → ccip-Dn5z57Cx.js} +1 -1
  2. package/dist/assets/{evm-wKiUiV3-.js → evm-Ci-t-8ei.js} +4 -4
  3. package/dist/assets/{index-8fbGA94c.js → index-Da59NFoY.js} +1 -1
  4. package/dist/assets/{index-B9_Snb-C.js → index-DlyJ6Tua.js} +2 -2
  5. package/dist/assets/{index-BBy_QGBB.js → index-yInQCZK6.js} +1 -1
  6. package/dist/assets/{index.es-BY7lrdO_.js → index.es-DUffrgf3.js} +2 -2
  7. package/dist/main.js +115 -62
  8. package/dist/src/components/v2/Button.d.ts +1 -1
  9. package/dist/src/components/v2/Button.d.ts.map +1 -1
  10. package/dist/src/config/types.d.ts +17 -3
  11. package/dist/src/config/types.d.ts.map +1 -1
  12. package/dist/src/hooks/useTransactionHistory.d.ts +1 -1
  13. package/dist/src/hooks/useTransactionHistory.d.ts.map +1 -1
  14. package/dist/src/hooks/useTransactionHistoryMayan.d.ts.map +1 -1
  15. package/dist/src/hooks/useTransactionHistoryWHScan.d.ts.map +1 -1
  16. package/dist/src/icons/TxReadyForClaim.d.ts +2 -2
  17. package/dist/src/icons/TxReadyForClaim.d.ts.map +1 -1
  18. package/dist/src/utils/inProgressTxCache.d.ts +5 -0
  19. package/dist/src/utils/inProgressTxCache.d.ts.map +1 -0
  20. package/dist/src/utils/polling.d.ts +5 -0
  21. package/dist/src/utils/polling.d.ts.map +1 -0
  22. package/dist/src/utils/sdkv2.d.ts +3 -2
  23. package/dist/src/utils/sdkv2.d.ts.map +1 -1
  24. package/dist/src/views/v2/Bridge/ReviewTransaction/index.d.ts.map +1 -1
  25. package/dist/src/views/v2/Bridge/index.d.ts.map +1 -1
  26. package/dist/src/views/v2/Redeem/index.d.ts.map +1 -1
  27. package/dist/src/views/v2/TxHistory/Widget/Item.d.ts +8 -0
  28. package/dist/src/views/v2/TxHistory/Widget/Item.d.ts.map +1 -0
  29. package/dist/src/views/v2/TxHistory/Widget/index.d.ts +4 -0
  30. package/dist/src/views/v2/TxHistory/Widget/index.d.ts.map +1 -0
  31. package/dist/src/views/v2/TxHistory/index.d.ts.map +1 -1
  32. package/lib/{algorand-BZLSulqp.mjs → algorand-B9ai7AKk.mjs} +3 -3
  33. package/lib/{algorand-DIrI8hux.js → algorand-BZfir-Gt.js} +1 -1
  34. package/lib/{aptos-BXyptrTk.mjs → aptos-BiWZASIH.mjs} +3 -3
  35. package/lib/{aptos-B61S9Mku.js → aptos-CX7jOv1y.js} +1 -1
  36. package/lib/{aptos-poOCeL-e.js → aptos-D_w5IEUK.js} +2 -2
  37. package/lib/{aptos-ClFQX748.mjs → aptos-ZpPdNMHJ.mjs} +1 -1
  38. package/lib/{ccip-CROSeCCn.js → ccip-CLMQ2RsP.js} +1 -1
  39. package/lib/{ccip-BcLqF-ov.mjs → ccip-lVzudYcQ.mjs} +1 -1
  40. package/lib/{cosmos-D-fRtzTz.js → cosmos-6rjmrhY_.js} +1 -1
  41. package/lib/{cosmos-B7IowZE9.mjs → cosmos-B3YMB-qs.mjs} +6 -6
  42. package/lib/{cosmwasm-BU28GqyN.js → cosmwasm-DMVssDjU.js} +2 -2
  43. package/lib/{cosmwasm-i8-2LBd4.mjs → cosmwasm-SnVdtN68.mjs} +7 -7
  44. package/lib/{events-BIfEV615.mjs → events-pgsgrP1S.mjs} +1 -1
  45. package/lib/{events-CG085uVS.js → events-t6i_QSEn.js} +1 -1
  46. package/lib/{evm-BG4p6wWc.mjs → evm-Bd3DzKCY.mjs} +7 -7
  47. package/lib/{evm-DSo1klm4.js → evm-D7GRIPdg.js} +4 -4
  48. package/lib/{evm-z72BQwjo.js → evm-DFJuxSg1.js} +1 -1
  49. package/lib/{evm-DqVh4NBz.mjs → evm-DiQodX72.mjs} +5 -5
  50. package/lib/{index-BrFyHtHO.js → index-048e7Uvl.js} +1 -1
  51. package/lib/{index-Bn9MsO0e.mjs → index-0QJFchou.mjs} +2 -2
  52. package/lib/{index-DjSK9SdK.mjs → index-0YCaekiF.mjs} +2 -2
  53. package/lib/{index-GyFHGs5Z.js → index-2LZtNZ5P.js} +1 -1
  54. package/lib/{index-C1XMdJFH.js → index-B2aC_g_3.js} +1 -1
  55. package/lib/{index-Cf-xLfst.js → index-B5TmFc4M.js} +1 -1
  56. package/lib/{index-l3VuXtv4.mjs → index-B64jLBfI.mjs} +2 -2
  57. package/lib/{index-CkrE6mmF.js → index-BAqClXT6.js} +1 -1
  58. package/lib/{index--orPBbEs.mjs → index-BT7_dDgl.mjs} +3 -3
  59. package/lib/{index-DTj0BYI6.mjs → index-BYv5Tbwe.mjs} +1 -1
  60. package/lib/{index-ByG9EJHX.js → index-BZ7LatAr.js} +137 -84
  61. package/lib/{index-BhfoV5RZ.js → index-B_FxM4qi.js} +1 -1
  62. package/lib/{index-B3uNul6-.mjs → index-BcbPoWss.mjs} +3 -3
  63. package/lib/{index-C262JAz4.mjs → index-Bd6ExIDW.mjs} +4 -4
  64. package/lib/{index-C2ZrCXVv.mjs → index-BhrO8yNx.mjs} +2 -2
  65. package/lib/{index--kQS0wX-.js → index-BjpzXqrL.js} +1 -1
  66. package/lib/{index-2u6Q9y32.js → index-BkyCouQJ.js} +1 -1
  67. package/lib/{index-DGI2tbSC.mjs → index-C4NKqUWK.mjs} +1 -1
  68. package/lib/{index-3CEBQmCn.mjs → index-C9xfXphF.mjs} +2 -2
  69. package/lib/{index-CdnXAZl6.js → index-CE4mRmPN.js} +1 -1
  70. package/lib/{index-CJJaUncM.js → index-CFVJznfe.js} +1 -1
  71. package/lib/{index-Coqx-ZYc.js → index-C_JBf5AE.js} +1 -1
  72. package/lib/{index-9Ifk_2V6.js → index-CcKxlhe-.js} +1 -1
  73. package/lib/{index-C3Ztf7te.mjs → index-CdFX-OBR.mjs} +4 -4
  74. package/lib/{index-BUcxdUpo.mjs → index-CkyGUP8I.mjs} +2 -2
  75. package/lib/{index-eY_q88kc.js → index-Cl110Yt1.js} +1 -1
  76. package/lib/{index-C8UyzBg3.mjs → index-CpM8O4af.mjs} +4 -4
  77. package/lib/{index-CytdQ1id.js → index-CvRFH7pa.js} +1 -1
  78. package/lib/{index-DkmEXbbA.js → index-D4-zCm-j.js} +1 -1
  79. package/lib/{index-B-bMfv9J.mjs → index-DG5KwGj7.mjs} +3 -3
  80. package/lib/{index-Cfu2mlWW.mjs → index-DJgWkkqj.mjs} +2 -2
  81. package/lib/{index-xrevpHY6.js → index-DLXjX60f.js} +1 -1
  82. package/lib/{index-B51snNHX.mjs → index-DPq8nS1b.mjs} +1 -1
  83. package/lib/{index-DTtBAHqC.mjs → index-DUn9bDrk.mjs} +2 -2
  84. package/lib/{index-C8tIBuyM.mjs → index-DVnPDtFx.mjs} +1 -1
  85. package/lib/{index-DEfagu36.js → index-DWmEAYa2.js} +1 -1
  86. package/lib/{index-DTLOaiZ5.mjs → index-DZbeM9gY.mjs} +2 -2
  87. package/lib/{index-CLiemfL3.js → index-Dk2OkATw.js} +1 -1
  88. package/lib/{index-x3yNXPc-.js → index-DllSkb9h.js} +1 -1
  89. package/lib/{index-CQ_e_FtW.js → index-EPcXyhD3.js} +1 -1
  90. package/lib/{index-BDhzG0Bz.mjs → index-EhUlCH18.mjs} +5312 -4798
  91. package/lib/{index-CYfEuKEC.js → index-QqzqKjF9.js} +1 -1
  92. package/lib/{index-D1GFc9u_.js → index-VI9qDjx0.js} +1 -1
  93. package/lib/{index-C1t8_dYP.mjs → index-bpVbPzFG.mjs} +1 -1
  94. package/lib/{index-BM3TrHYu.mjs → index-fD6yeQDw.mjs} +7 -7
  95. package/lib/{index-C1fq1xT0.mjs → index-fPs98C_X.mjs} +2 -2
  96. package/lib/{index-Xxsx46yX.mjs → index-hiGmsL0b.mjs} +1 -1
  97. package/lib/{index-CGmv-GLf.js → index-mAuqp4GD.js} +1 -1
  98. package/lib/{index.es-zlUSra_a.mjs → index.es-B4wQLKJO.mjs} +5 -5
  99. package/lib/{index.es-CTYy3A6V.js → index.es-WCp4WrVw.js} +2 -2
  100. package/lib/index.js +1 -1
  101. package/lib/index.mjs +1 -1
  102. package/lib/{libsodium-wrappers-_Sv3nUjE.js → libsodium-wrappers-BdZeVEOK.js} +1 -1
  103. package/lib/{libsodium-wrappers-BL6m46dv.mjs → libsodium-wrappers-DnY3rBzj.mjs} +1 -1
  104. package/lib/{pako.esm-CEjOh_1P.js → pako.esm-CpOVp0Fg.js} +1 -1
  105. package/lib/{pako.esm-Bf33_673.mjs → pako.esm-doGHPq3v.mjs} +3 -3
  106. package/lib/{pbkdf2-C3vdgkb4.mjs → pbkdf2-CR1mMO6P.mjs} +1 -1
  107. package/lib/{pbkdf2-BJ3CFykt.js → pbkdf2-DRrUaAek.js} +1 -1
  108. package/lib/{sei-LGYYUG8M.js → sei-BHskcl2R.js} +1 -1
  109. package/lib/{sei-BXWrZef6.mjs → sei-ReMraEM4.mjs} +4 -4
  110. package/lib/{signer-DaJj3hCp.mjs → signer-BwkEV8NR.mjs} +1 -1
  111. package/lib/{signer-BQ4T60Nz.js → signer-C5udfQih.js} +1 -1
  112. package/lib/{solana-AQlZomQ6.js → solana-BWRzXH9-.js} +1 -1
  113. package/lib/solana-ci1dqiv5.mjs +16 -0
  114. package/lib/solana-gFEm46ZS.js +1 -0
  115. package/lib/{solana-Cl4jwD2F.mjs → solana-kr2Et-_M.mjs} +4 -4
  116. package/lib/{solanaEmbed.esm-B_5axZif.js → solanaEmbed.esm-8hegnauD.js} +1 -1
  117. package/lib/{solanaEmbed.esm-DEMxZG02.mjs → solanaEmbed.esm-HLygiesN.mjs} +4 -4
  118. package/lib/src/components/v2/Button.d.ts +1 -1
  119. package/lib/src/components/v2/Button.d.ts.map +1 -1
  120. package/lib/src/config/types.d.ts +17 -3
  121. package/lib/src/config/types.d.ts.map +1 -1
  122. package/lib/src/hooks/useTransactionHistory.d.ts +1 -1
  123. package/lib/src/hooks/useTransactionHistory.d.ts.map +1 -1
  124. package/lib/src/hooks/useTransactionHistoryMayan.d.ts.map +1 -1
  125. package/lib/src/hooks/useTransactionHistoryWHScan.d.ts.map +1 -1
  126. package/lib/src/icons/TxReadyForClaim.d.ts +2 -2
  127. package/lib/src/icons/TxReadyForClaim.d.ts.map +1 -1
  128. package/lib/src/utils/inProgressTxCache.d.ts +5 -0
  129. package/lib/src/utils/inProgressTxCache.d.ts.map +1 -0
  130. package/lib/src/utils/polling.d.ts +5 -0
  131. package/lib/src/utils/polling.d.ts.map +1 -0
  132. package/lib/src/utils/sdkv2.d.ts +3 -2
  133. package/lib/src/utils/sdkv2.d.ts.map +1 -1
  134. package/lib/src/views/v2/Bridge/ReviewTransaction/index.d.ts.map +1 -1
  135. package/lib/src/views/v2/Bridge/index.d.ts.map +1 -1
  136. package/lib/src/views/v2/Redeem/index.d.ts.map +1 -1
  137. package/lib/src/views/v2/TxHistory/Widget/Item.d.ts +8 -0
  138. package/lib/src/views/v2/TxHistory/Widget/Item.d.ts.map +1 -0
  139. package/lib/src/views/v2/TxHistory/Widget/index.d.ts +4 -0
  140. package/lib/src/views/v2/TxHistory/Widget/index.d.ts.map +1 -0
  141. package/lib/src/views/v2/TxHistory/index.d.ts.map +1 -1
  142. package/lib/{sui-DfdFzATl.mjs → sui-B6XCpe1d.mjs} +1 -1
  143. package/lib/{sui-IAt2YxVB.js → sui-BWRqoTdl.js} +2 -2
  144. package/lib/{sui-tX-807Bw.js → sui-BocrppL0.js} +1 -1
  145. package/lib/{sui-BpKCqOiX.mjs → sui-BuZPAcI0.mjs} +4 -4
  146. package/lib/{unsignedTransaction-BzNQ2WFS.js → unsignedTransaction-DSuqsGgb.js} +1 -1
  147. package/lib/{unsignedTransaction-B1rzGa0o.mjs → unsignedTransaction-oXk8lD5s.mjs} +2 -2
  148. package/lib/{utils-DZZcQv7V.js → utils-SML27G4C.js} +1 -1
  149. package/lib/{utils-Xa6ErDQY.mjs → utils-fI-uXUZk.mjs} +2 -2
  150. package/package.json +1 -1
  151. package/lib/solana-6EZacoKb.js +0 -1
  152. package/lib/solana-CbB3tRah.mjs +0 -16
@@ -1,5 +1,5 @@
1
- "use strict";var on=Object.defineProperty;var cn=(t,e,r)=>e in t?on(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var pe=(t,e,r)=>cn(t,typeof e!="symbol"?e+"":e,r);const d=require("./index-ByG9EJHX.js"),un=require("./pbkdf2-BJ3CFykt.js");function H(t){return Uint8Array.from(atob(t),e=>e.charCodeAt(0))}const st=8192;function $(t){if(t.length<st)return btoa(String.fromCharCode(...t));let e="";for(var r=0;r<t.length;r+=st){const n=t.slice(r,r+st);e+=String.fromCharCode(...n)}return btoa(e)}function Ue(t){var s;const e=t.startsWith("0x")?t.slice(2):t,n=((s=(e.length%2===0?e:`0${e}}`).match(/.{2}/g))==null?void 0:s.map(i=>parseInt(i,16)))??[];return Uint8Array.from(n)}function ge(t){return t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),"")}function kt(t){let e=[],r=0;if(t===0)return[0];for(;t>0;)e[r]=t&127,(t>>=7)&&(e[r]|=128),r+=1;return e}function dn(t){let e=0,r=0,n=0;for(;;){let s=t[n];if(n+=1,e|=(s&127)<<r,!(s&128))break;r+=7}return{value:e,length:n}}class fr{constructor(e){this.bytePosition=0,this.dataView=new DataView(e.buffer)}shift(e){return this.bytePosition+=e,this}read8(){let e=this.dataView.getUint8(this.bytePosition);return this.shift(1),e}read16(){let e=this.dataView.getUint16(this.bytePosition,!0);return this.shift(2),e}read32(){let e=this.dataView.getUint32(this.bytePosition,!0);return this.shift(4),e}read64(){let e=this.read32(),n=this.read32().toString(16)+e.toString(16).padStart(8,"0");return BigInt("0x"+n).toString(10)}read128(){let e=BigInt(this.read64()),n=BigInt(this.read64()).toString(16)+e.toString(16).padStart(16,"0");return BigInt("0x"+n).toString(10)}read256(){let e=BigInt(this.read128()),n=BigInt(this.read128()).toString(16)+e.toString(16).padStart(32,"0");return BigInt("0x"+n).toString(10)}readBytes(e){let r=this.bytePosition+this.dataView.byteOffset,n=new Uint8Array(this.dataView.buffer,r,e);return this.shift(e),n}readULEB(){let e=this.bytePosition+this.dataView.byteOffset,r=new Uint8Array(this.dataView.buffer,e),{value:n,length:s}=dn(r);return this.shift(s),n}readVec(e){let r=this.readULEB(),n=[];for(let s=0;s<r;s++)n.push(e(this,s,r));return n}}function ln(t,e){switch(e){case"base58":return d.toB58(t);case"base64":return $(t);case"hex":return ge(t);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}function fn(t,e){switch(e){case"base58":return d.fromB58(t);case"base64":return H(t);case"hex":return Ue(t);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}function hr(t,e=["<",">"]){const[r,n]=e,s=[];let i="",a=0;for(let o=0;o<t.length;o++){const u=t[o];if(u===r&&a++,u===n&&a--,a===0&&u===","){s.push(i.trim()),i="";continue}i+=u}return s.push(i.trim()),s}class gr{constructor({size:e=1024,maxSize:r,allocateSize:n=1024}={}){this.bytePosition=0,this.size=e,this.maxSize=r||e,this.allocateSize=n,this.dataView=new DataView(new ArrayBuffer(e))}ensureSizeOrGrow(e){const r=this.bytePosition+e;if(r>this.size){const n=Math.min(this.maxSize,this.size+this.allocateSize);if(r>n)throw new Error(`Attempting to serialize to BCS, but buffer does not have enough size. Allocated size: ${this.size}, Max size: ${this.maxSize}, Required size: ${r}`);this.size=n;const s=new ArrayBuffer(this.size);new Uint8Array(s).set(new Uint8Array(this.dataView.buffer)),this.dataView=new DataView(s)}}shift(e){return this.bytePosition+=e,this}write8(e){return this.ensureSizeOrGrow(1),this.dataView.setUint8(this.bytePosition,Number(e)),this.shift(1)}write16(e){return this.ensureSizeOrGrow(2),this.dataView.setUint16(this.bytePosition,Number(e),!0),this.shift(2)}write32(e){return this.ensureSizeOrGrow(4),this.dataView.setUint32(this.bytePosition,Number(e),!0),this.shift(4)}write64(e){return it(BigInt(e),8).forEach(r=>this.write8(r)),this}write128(e){return it(BigInt(e),16).forEach(r=>this.write8(r)),this}write256(e){return it(BigInt(e),32).forEach(r=>this.write8(r)),this}writeULEB(e){return kt(e).forEach(r=>this.write8(r)),this}writeVec(e,r){return this.writeULEB(e.length),Array.from(e).forEach((n,s)=>r(this,n,s,e.length)),this}*[Symbol.iterator](){for(let e=0;e<this.bytePosition;e++)yield this.dataView.getUint8(e);return this.toBytes()}toBytes(){return new Uint8Array(this.dataView.buffer.slice(0,this.bytePosition))}toString(e){return ln(this.toBytes(),e)}}function it(t,e){let r=new Uint8Array(e),n=0;for(;t>0;)r[n]=Number(t%BigInt(256)),t=t/BigInt(256),n+=1;return r}var pr=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},W=(t,e,r)=>(pr(t,e,"read from private field"),r?r.call(t):e.get(t)),Ze=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},Je=(t,e,r,n)=>(pr(t,e,"write to private field"),e.set(t,r),r),ye,ke,We,ae;const yr=class{constructor(t){Ze(this,ye,void 0),Ze(this,ke,void 0),this.name=t.name,this.read=t.read,this.serializedSize=t.serializedSize??(()=>null),Je(this,ye,t.write),Je(this,ke,t.serialize??((e,r)=>{const n=new gr({size:this.serializedSize(e)??void 0,...r});return W(this,ye).call(this,e,n),n.toBytes()})),this.validate=t.validate??(()=>{})}write(t,e){this.validate(t),W(this,ye).call(this,t,e)}serialize(t,e){return this.validate(t),new hn(this,W(this,ke).call(this,t,e))}parse(t){const e=new fr(t);return this.read(e)}transform({name:t,input:e,output:r}){return new yr({name:t??this.name,read:n=>r(this.read(n)),write:(n,s)=>W(this,ye).call(this,e(n),s),serializedSize:n=>this.serializedSize(e(n)),serialize:(n,s)=>W(this,ke).call(this,e(n),s),validate:n=>this.validate(e(n))})}};let K=yr;ye=new WeakMap;ke=new WeakMap;const mr=Symbol.for("@mysten/serialized-bcs");function xt(t){return!!t&&typeof t=="object"&&t[mr]===!0}class hn{constructor(e,r){Ze(this,We,void 0),Ze(this,ae,void 0),Je(this,We,e),Je(this,ae,r)}get[mr](){return!0}toBytes(){return W(this,ae)}toHex(){return ge(W(this,ae))}toBase64(){return $(W(this,ae))}toBase58(){return d.toB58(W(this,ae))}parse(){return W(this,We).parse(W(this,ae))}}We=new WeakMap;ae=new WeakMap;function Xe({size:t,...e}){return new K({...e,serializedSize:()=>t})}function at({readMethod:t,writeMethod:e,...r}){return Xe({...r,read:n=>n[t](),write:(n,s)=>s[e](n),validate:n=>{var s;if(n<0||n>r.maxValue)throw new TypeError(`Invalid ${r.name} value: ${n}. Expected value in range 0-${r.maxValue}`);(s=r.validate)==null||s.call(r,n)}})}function ot({readMethod:t,writeMethod:e,...r}){return Xe({...r,read:n=>n[t](),write:(n,s)=>s[e](BigInt(n)),validate:n=>{var i;const s=BigInt(n);if(s<0||s>r.maxValue)throw new TypeError(`Invalid ${r.name} value: ${s}. Expected value in range 0-${r.maxValue}`);(i=r.validate)==null||i.call(r,s)}})}function gn({serialize:t,...e}){const r=new K({...e,serialize:t,write:(n,s)=>{for(const i of r.serialize(n).toBytes())s.write8(i)}});return r}function pn({toBytes:t,fromBytes:e,...r}){return new K({...r,read:n=>{const s=n.readULEB(),i=n.readBytes(s);return e(i)},write:(n,s)=>{const i=t(n);s.writeULEB(i.length);for(let a=0;a<i.length;a++)s.write8(i[a])},serialize:n=>{const s=t(n),i=kt(s.length),a=new Uint8Array(i.length+s.length);return a.set(i,0),a.set(s,i.length),a},validate:n=>{var s;if(typeof n!="string")throw new TypeError(`Invalid ${r.name} value: ${n}. Expected string`);(s=r.validate)==null||s.call(r,n)}})}function yn(t){let e=null;function r(){return e||(e=t()),e}return new K({name:"lazy",read:n=>r().read(n),serializedSize:n=>r().serializedSize(n),write:(n,s)=>r().write(n,s),serialize:(n,s)=>r().serialize(n,s).toBytes()})}const c={u8(t){return at({name:"u8",readMethod:"read8",writeMethod:"write8",size:1,maxValue:2**8-1,...t})},u16(t){return at({name:"u16",readMethod:"read16",writeMethod:"write16",size:2,maxValue:2**16-1,...t})},u32(t){return at({name:"u32",readMethod:"read32",writeMethod:"write32",size:4,maxValue:2**32-1,...t})},u64(t){return ot({name:"u64",readMethod:"read64",writeMethod:"write64",size:8,maxValue:2n**64n-1n,...t})},u128(t){return ot({name:"u128",readMethod:"read128",writeMethod:"write128",size:16,maxValue:2n**128n-1n,...t})},u256(t){return ot({name:"u256",readMethod:"read256",writeMethod:"write256",size:32,maxValue:2n**256n-1n,...t})},bool(t){return Xe({name:"bool",size:1,read:e=>e.read8()===1,write:(e,r)=>r.write8(e?1:0),...t,validate:e=>{var r;if((r=t==null?void 0:t.validate)==null||r.call(t,e),typeof e!="boolean")throw new TypeError(`Expected boolean, found ${typeof e}`)}})},uleb128(t){return gn({name:"uleb128",read:e=>e.readULEB(),serialize:e=>Uint8Array.from(kt(e)),...t})},bytes(t,e){return Xe({name:`bytes[${t}]`,size:t,read:r=>r.readBytes(t),write:(r,n)=>{for(let s=0;s<t;s++)n.write8(r[s]??0)},...e,validate:r=>{var n;if((n=e==null?void 0:e.validate)==null||n.call(e,r),!("length"in r))throw new TypeError(`Expected array, found ${typeof r}`);if(r.length!==t)throw new TypeError(`Expected array of length ${t}, found ${r.length}`)}})},string(t){return pn({name:"string",toBytes:e=>new TextEncoder().encode(e),fromBytes:e=>new TextDecoder().decode(e),...t})},fixedArray(t,e,r){return new K({name:`${e.name}[${t}]`,read:n=>{const s=new Array(t);for(let i=0;i<t;i++)s[i]=e.read(n);return s},write:(n,s)=>{for(const i of n)e.write(i,s)},...r,validate:n=>{var s;if((s=r==null?void 0:r.validate)==null||s.call(r,n),!("length"in n))throw new TypeError(`Expected array, found ${typeof n}`);if(n.length!==t)throw new TypeError(`Expected array of length ${t}, found ${n.length}`)}})},option(t){return c.enum(`Option<${t.name}>`,{None:null,Some:t}).transform({input:e=>e==null?{None:!0}:{Some:e},output:e=>"Some"in e?e.Some:null})},vector(t,e){return new K({name:`vector<${t.name}>`,read:r=>{const n=r.readULEB(),s=new Array(n);for(let i=0;i<n;i++)s[i]=t.read(r);return s},write:(r,n)=>{n.writeULEB(r.length);for(const s of r)t.write(s,n)},...e,validate:r=>{var n;if((n=e==null?void 0:e.validate)==null||n.call(e,r),!("length"in r))throw new TypeError(`Expected array, found ${typeof r}`)}})},tuple(t,e){return new K({name:`(${t.map(r=>r.name).join(", ")})`,serializedSize:r=>{let n=0;for(let s=0;s<t.length;s++){const i=t[s].serializedSize(r[s]);if(i==null)return null;n+=i}return n},read:r=>{const n=[];for(const s of t)n.push(s.read(r));return n},write:(r,n)=>{for(let s=0;s<t.length;s++)t[s].write(r[s],n)},...e,validate:r=>{var n;if((n=e==null?void 0:e.validate)==null||n.call(e,r),!Array.isArray(r))throw new TypeError(`Expected array, found ${typeof r}`);if(r.length!==t.length)throw new TypeError(`Expected array of length ${t.length}, found ${r.length}`)}})},struct(t,e,r){const n=Object.entries(e);return new K({name:t,serializedSize:s=>{let i=0;for(const[a,o]of n){const u=o.serializedSize(s[a]);if(u==null)return null;i+=u}return i},read:s=>{const i={};for(const[a,o]of n)i[a]=o.read(s);return i},write:(s,i)=>{for(const[a,o]of n)o.write(s[a],i)},...r,validate:s=>{var i;if((i=r==null?void 0:r.validate)==null||i.call(r,s),typeof s!="object"||s==null)throw new TypeError(`Expected object, found ${typeof s}`)}})},enum(t,e,r){const n=Object.entries(e);return new K({name:t,read:s=>{const i=s.readULEB(),[a,o]=n[i];return{[a]:(o==null?void 0:o.read(s))??!0}},write:(s,i)=>{const[a,o]=Object.entries(s)[0];for(let u=0;u<n.length;u++){const[l,h]=n[u];if(l===a){i.writeULEB(u),h==null||h.write(o,i);return}}},...r,validate:s=>{var o;if((o=r==null?void 0:r.validate)==null||o.call(r,s),typeof s!="object"||s==null)throw new TypeError(`Expected object, found ${typeof s}`);const i=Object.keys(s);if(i.length!==1)throw new TypeError(`Expected object with one key, found ${i.length}`);const[a]=i;if(!Object.hasOwn(e,a))throw new TypeError(`Invalid enum variant ${a}`)}})},map(t,e){return c.vector(c.tuple([t,e])).transform({name:`Map<${t.name}, ${e.name}>`,input:r=>[...r.entries()],output:r=>{const n=new Map;for(const[s,i]of r)n.set(s,i);return n}})},generic(t,e){return(...r)=>e(...r).transform({name:`${e.name}<${r.map(n=>n.name).join(", ")}>`,input:n=>n,output:n=>n})},lazy(t){return yn(t)}},mn=32,xe=class{constructor(t){if(this.types=new Map,this.counter=0,t instanceof xe){this.schema=t.schema,this.types=new Map(t.types);return}if(this.schema=t,this.registerAddressType(xe.ADDRESS,t.addressLength,t.addressEncoding),this.registerVectorType(t.vectorType),t.types&&t.types.structs)for(let e of Object.keys(t.types.structs))this.registerStructType(e,t.types.structs[e]);if(t.types&&t.types.enums)for(let e of Object.keys(t.types.enums))this.registerEnumType(e,t.types.enums[e]);if(t.types&&t.types.aliases)for(let e of Object.keys(t.types.aliases))this.registerAlias(e,t.types.aliases[e]);t.withPrimitives!==!1&&wn(this)}tempKey(){return`bcs-struct-${++this.counter}`}ser(t,e,r){if(typeof t=="string"||Array.isArray(t)){const{name:n,params:s}=this.parseTypeName(t);return this.getTypeInterface(n).encode(this,e,r,s)}if(typeof t=="object"){const n=this.tempKey();return new xe(this).registerStructType(n,t).ser(n,e,r)}throw new Error(`Incorrect type passed into the '.ser()' function.
1
+ "use strict";var on=Object.defineProperty;var cn=(t,e,r)=>e in t?on(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var pe=(t,e,r)=>cn(t,typeof e!="symbol"?e+"":e,r);const d=require("./index-BZ7LatAr.js"),un=require("./pbkdf2-DRrUaAek.js");function H(t){return Uint8Array.from(atob(t),e=>e.charCodeAt(0))}const st=8192;function $(t){if(t.length<st)return btoa(String.fromCharCode(...t));let e="";for(var r=0;r<t.length;r+=st){const n=t.slice(r,r+st);e+=String.fromCharCode(...n)}return btoa(e)}function Ue(t){var s;const e=t.startsWith("0x")?t.slice(2):t,n=((s=(e.length%2===0?e:`0${e}}`).match(/.{2}/g))==null?void 0:s.map(i=>parseInt(i,16)))??[];return Uint8Array.from(n)}function ge(t){return t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),"")}function kt(t){let e=[],r=0;if(t===0)return[0];for(;t>0;)e[r]=t&127,(t>>=7)&&(e[r]|=128),r+=1;return e}function dn(t){let e=0,r=0,n=0;for(;;){let s=t[n];if(n+=1,e|=(s&127)<<r,!(s&128))break;r+=7}return{value:e,length:n}}class fr{constructor(e){this.bytePosition=0,this.dataView=new DataView(e.buffer)}shift(e){return this.bytePosition+=e,this}read8(){let e=this.dataView.getUint8(this.bytePosition);return this.shift(1),e}read16(){let e=this.dataView.getUint16(this.bytePosition,!0);return this.shift(2),e}read32(){let e=this.dataView.getUint32(this.bytePosition,!0);return this.shift(4),e}read64(){let e=this.read32(),n=this.read32().toString(16)+e.toString(16).padStart(8,"0");return BigInt("0x"+n).toString(10)}read128(){let e=BigInt(this.read64()),n=BigInt(this.read64()).toString(16)+e.toString(16).padStart(16,"0");return BigInt("0x"+n).toString(10)}read256(){let e=BigInt(this.read128()),n=BigInt(this.read128()).toString(16)+e.toString(16).padStart(32,"0");return BigInt("0x"+n).toString(10)}readBytes(e){let r=this.bytePosition+this.dataView.byteOffset,n=new Uint8Array(this.dataView.buffer,r,e);return this.shift(e),n}readULEB(){let e=this.bytePosition+this.dataView.byteOffset,r=new Uint8Array(this.dataView.buffer,e),{value:n,length:s}=dn(r);return this.shift(s),n}readVec(e){let r=this.readULEB(),n=[];for(let s=0;s<r;s++)n.push(e(this,s,r));return n}}function ln(t,e){switch(e){case"base58":return d.toB58(t);case"base64":return $(t);case"hex":return ge(t);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}function fn(t,e){switch(e){case"base58":return d.fromB58(t);case"base64":return H(t);case"hex":return Ue(t);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}function hr(t,e=["<",">"]){const[r,n]=e,s=[];let i="",a=0;for(let o=0;o<t.length;o++){const u=t[o];if(u===r&&a++,u===n&&a--,a===0&&u===","){s.push(i.trim()),i="";continue}i+=u}return s.push(i.trim()),s}class gr{constructor({size:e=1024,maxSize:r,allocateSize:n=1024}={}){this.bytePosition=0,this.size=e,this.maxSize=r||e,this.allocateSize=n,this.dataView=new DataView(new ArrayBuffer(e))}ensureSizeOrGrow(e){const r=this.bytePosition+e;if(r>this.size){const n=Math.min(this.maxSize,this.size+this.allocateSize);if(r>n)throw new Error(`Attempting to serialize to BCS, but buffer does not have enough size. Allocated size: ${this.size}, Max size: ${this.maxSize}, Required size: ${r}`);this.size=n;const s=new ArrayBuffer(this.size);new Uint8Array(s).set(new Uint8Array(this.dataView.buffer)),this.dataView=new DataView(s)}}shift(e){return this.bytePosition+=e,this}write8(e){return this.ensureSizeOrGrow(1),this.dataView.setUint8(this.bytePosition,Number(e)),this.shift(1)}write16(e){return this.ensureSizeOrGrow(2),this.dataView.setUint16(this.bytePosition,Number(e),!0),this.shift(2)}write32(e){return this.ensureSizeOrGrow(4),this.dataView.setUint32(this.bytePosition,Number(e),!0),this.shift(4)}write64(e){return it(BigInt(e),8).forEach(r=>this.write8(r)),this}write128(e){return it(BigInt(e),16).forEach(r=>this.write8(r)),this}write256(e){return it(BigInt(e),32).forEach(r=>this.write8(r)),this}writeULEB(e){return kt(e).forEach(r=>this.write8(r)),this}writeVec(e,r){return this.writeULEB(e.length),Array.from(e).forEach((n,s)=>r(this,n,s,e.length)),this}*[Symbol.iterator](){for(let e=0;e<this.bytePosition;e++)yield this.dataView.getUint8(e);return this.toBytes()}toBytes(){return new Uint8Array(this.dataView.buffer.slice(0,this.bytePosition))}toString(e){return ln(this.toBytes(),e)}}function it(t,e){let r=new Uint8Array(e),n=0;for(;t>0;)r[n]=Number(t%BigInt(256)),t=t/BigInt(256),n+=1;return r}var pr=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},W=(t,e,r)=>(pr(t,e,"read from private field"),r?r.call(t):e.get(t)),Ze=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},Je=(t,e,r,n)=>(pr(t,e,"write to private field"),e.set(t,r),r),ye,ke,We,ae;const yr=class{constructor(t){Ze(this,ye,void 0),Ze(this,ke,void 0),this.name=t.name,this.read=t.read,this.serializedSize=t.serializedSize??(()=>null),Je(this,ye,t.write),Je(this,ke,t.serialize??((e,r)=>{const n=new gr({size:this.serializedSize(e)??void 0,...r});return W(this,ye).call(this,e,n),n.toBytes()})),this.validate=t.validate??(()=>{})}write(t,e){this.validate(t),W(this,ye).call(this,t,e)}serialize(t,e){return this.validate(t),new hn(this,W(this,ke).call(this,t,e))}parse(t){const e=new fr(t);return this.read(e)}transform({name:t,input:e,output:r}){return new yr({name:t??this.name,read:n=>r(this.read(n)),write:(n,s)=>W(this,ye).call(this,e(n),s),serializedSize:n=>this.serializedSize(e(n)),serialize:(n,s)=>W(this,ke).call(this,e(n),s),validate:n=>this.validate(e(n))})}};let K=yr;ye=new WeakMap;ke=new WeakMap;const mr=Symbol.for("@mysten/serialized-bcs");function xt(t){return!!t&&typeof t=="object"&&t[mr]===!0}class hn{constructor(e,r){Ze(this,We,void 0),Ze(this,ae,void 0),Je(this,We,e),Je(this,ae,r)}get[mr](){return!0}toBytes(){return W(this,ae)}toHex(){return ge(W(this,ae))}toBase64(){return $(W(this,ae))}toBase58(){return d.toB58(W(this,ae))}parse(){return W(this,We).parse(W(this,ae))}}We=new WeakMap;ae=new WeakMap;function Xe({size:t,...e}){return new K({...e,serializedSize:()=>t})}function at({readMethod:t,writeMethod:e,...r}){return Xe({...r,read:n=>n[t](),write:(n,s)=>s[e](n),validate:n=>{var s;if(n<0||n>r.maxValue)throw new TypeError(`Invalid ${r.name} value: ${n}. Expected value in range 0-${r.maxValue}`);(s=r.validate)==null||s.call(r,n)}})}function ot({readMethod:t,writeMethod:e,...r}){return Xe({...r,read:n=>n[t](),write:(n,s)=>s[e](BigInt(n)),validate:n=>{var i;const s=BigInt(n);if(s<0||s>r.maxValue)throw new TypeError(`Invalid ${r.name} value: ${s}. Expected value in range 0-${r.maxValue}`);(i=r.validate)==null||i.call(r,s)}})}function gn({serialize:t,...e}){const r=new K({...e,serialize:t,write:(n,s)=>{for(const i of r.serialize(n).toBytes())s.write8(i)}});return r}function pn({toBytes:t,fromBytes:e,...r}){return new K({...r,read:n=>{const s=n.readULEB(),i=n.readBytes(s);return e(i)},write:(n,s)=>{const i=t(n);s.writeULEB(i.length);for(let a=0;a<i.length;a++)s.write8(i[a])},serialize:n=>{const s=t(n),i=kt(s.length),a=new Uint8Array(i.length+s.length);return a.set(i,0),a.set(s,i.length),a},validate:n=>{var s;if(typeof n!="string")throw new TypeError(`Invalid ${r.name} value: ${n}. Expected string`);(s=r.validate)==null||s.call(r,n)}})}function yn(t){let e=null;function r(){return e||(e=t()),e}return new K({name:"lazy",read:n=>r().read(n),serializedSize:n=>r().serializedSize(n),write:(n,s)=>r().write(n,s),serialize:(n,s)=>r().serialize(n,s).toBytes()})}const c={u8(t){return at({name:"u8",readMethod:"read8",writeMethod:"write8",size:1,maxValue:2**8-1,...t})},u16(t){return at({name:"u16",readMethod:"read16",writeMethod:"write16",size:2,maxValue:2**16-1,...t})},u32(t){return at({name:"u32",readMethod:"read32",writeMethod:"write32",size:4,maxValue:2**32-1,...t})},u64(t){return ot({name:"u64",readMethod:"read64",writeMethod:"write64",size:8,maxValue:2n**64n-1n,...t})},u128(t){return ot({name:"u128",readMethod:"read128",writeMethod:"write128",size:16,maxValue:2n**128n-1n,...t})},u256(t){return ot({name:"u256",readMethod:"read256",writeMethod:"write256",size:32,maxValue:2n**256n-1n,...t})},bool(t){return Xe({name:"bool",size:1,read:e=>e.read8()===1,write:(e,r)=>r.write8(e?1:0),...t,validate:e=>{var r;if((r=t==null?void 0:t.validate)==null||r.call(t,e),typeof e!="boolean")throw new TypeError(`Expected boolean, found ${typeof e}`)}})},uleb128(t){return gn({name:"uleb128",read:e=>e.readULEB(),serialize:e=>Uint8Array.from(kt(e)),...t})},bytes(t,e){return Xe({name:`bytes[${t}]`,size:t,read:r=>r.readBytes(t),write:(r,n)=>{for(let s=0;s<t;s++)n.write8(r[s]??0)},...e,validate:r=>{var n;if((n=e==null?void 0:e.validate)==null||n.call(e,r),!("length"in r))throw new TypeError(`Expected array, found ${typeof r}`);if(r.length!==t)throw new TypeError(`Expected array of length ${t}, found ${r.length}`)}})},string(t){return pn({name:"string",toBytes:e=>new TextEncoder().encode(e),fromBytes:e=>new TextDecoder().decode(e),...t})},fixedArray(t,e,r){return new K({name:`${e.name}[${t}]`,read:n=>{const s=new Array(t);for(let i=0;i<t;i++)s[i]=e.read(n);return s},write:(n,s)=>{for(const i of n)e.write(i,s)},...r,validate:n=>{var s;if((s=r==null?void 0:r.validate)==null||s.call(r,n),!("length"in n))throw new TypeError(`Expected array, found ${typeof n}`);if(n.length!==t)throw new TypeError(`Expected array of length ${t}, found ${n.length}`)}})},option(t){return c.enum(`Option<${t.name}>`,{None:null,Some:t}).transform({input:e=>e==null?{None:!0}:{Some:e},output:e=>"Some"in e?e.Some:null})},vector(t,e){return new K({name:`vector<${t.name}>`,read:r=>{const n=r.readULEB(),s=new Array(n);for(let i=0;i<n;i++)s[i]=t.read(r);return s},write:(r,n)=>{n.writeULEB(r.length);for(const s of r)t.write(s,n)},...e,validate:r=>{var n;if((n=e==null?void 0:e.validate)==null||n.call(e,r),!("length"in r))throw new TypeError(`Expected array, found ${typeof r}`)}})},tuple(t,e){return new K({name:`(${t.map(r=>r.name).join(", ")})`,serializedSize:r=>{let n=0;for(let s=0;s<t.length;s++){const i=t[s].serializedSize(r[s]);if(i==null)return null;n+=i}return n},read:r=>{const n=[];for(const s of t)n.push(s.read(r));return n},write:(r,n)=>{for(let s=0;s<t.length;s++)t[s].write(r[s],n)},...e,validate:r=>{var n;if((n=e==null?void 0:e.validate)==null||n.call(e,r),!Array.isArray(r))throw new TypeError(`Expected array, found ${typeof r}`);if(r.length!==t.length)throw new TypeError(`Expected array of length ${t.length}, found ${r.length}`)}})},struct(t,e,r){const n=Object.entries(e);return new K({name:t,serializedSize:s=>{let i=0;for(const[a,o]of n){const u=o.serializedSize(s[a]);if(u==null)return null;i+=u}return i},read:s=>{const i={};for(const[a,o]of n)i[a]=o.read(s);return i},write:(s,i)=>{for(const[a,o]of n)o.write(s[a],i)},...r,validate:s=>{var i;if((i=r==null?void 0:r.validate)==null||i.call(r,s),typeof s!="object"||s==null)throw new TypeError(`Expected object, found ${typeof s}`)}})},enum(t,e,r){const n=Object.entries(e);return new K({name:t,read:s=>{const i=s.readULEB(),[a,o]=n[i];return{[a]:(o==null?void 0:o.read(s))??!0}},write:(s,i)=>{const[a,o]=Object.entries(s)[0];for(let u=0;u<n.length;u++){const[l,h]=n[u];if(l===a){i.writeULEB(u),h==null||h.write(o,i);return}}},...r,validate:s=>{var o;if((o=r==null?void 0:r.validate)==null||o.call(r,s),typeof s!="object"||s==null)throw new TypeError(`Expected object, found ${typeof s}`);const i=Object.keys(s);if(i.length!==1)throw new TypeError(`Expected object with one key, found ${i.length}`);const[a]=i;if(!Object.hasOwn(e,a))throw new TypeError(`Invalid enum variant ${a}`)}})},map(t,e){return c.vector(c.tuple([t,e])).transform({name:`Map<${t.name}, ${e.name}>`,input:r=>[...r.entries()],output:r=>{const n=new Map;for(const[s,i]of r)n.set(s,i);return n}})},generic(t,e){return(...r)=>e(...r).transform({name:`${e.name}<${r.map(n=>n.name).join(", ")}>`,input:n=>n,output:n=>n})},lazy(t){return yn(t)}},mn=32,xe=class{constructor(t){if(this.types=new Map,this.counter=0,t instanceof xe){this.schema=t.schema,this.types=new Map(t.types);return}if(this.schema=t,this.registerAddressType(xe.ADDRESS,t.addressLength,t.addressEncoding),this.registerVectorType(t.vectorType),t.types&&t.types.structs)for(let e of Object.keys(t.types.structs))this.registerStructType(e,t.types.structs[e]);if(t.types&&t.types.enums)for(let e of Object.keys(t.types.enums))this.registerEnumType(e,t.types.enums[e]);if(t.types&&t.types.aliases)for(let e of Object.keys(t.types.aliases))this.registerAlias(e,t.types.aliases[e]);t.withPrimitives!==!1&&wn(this)}tempKey(){return`bcs-struct-${++this.counter}`}ser(t,e,r){if(typeof t=="string"||Array.isArray(t)){const{name:n,params:s}=this.parseTypeName(t);return this.getTypeInterface(n).encode(this,e,r,s)}if(typeof t=="object"){const n=this.tempKey();return new xe(this).registerStructType(n,t).ser(n,e,r)}throw new Error(`Incorrect type passed into the '.ser()' function.
2
2
  ${JSON.stringify(t)}`)}de(t,e,r){if(typeof e=="string")if(r)e=fn(e,r);else throw new Error("To pass a string to `bcs.de`, specify encoding");if(typeof t=="string"||Array.isArray(t)){const{name:n,params:s}=this.parseTypeName(t);return this.getTypeInterface(n).decode(this,e,s)}if(typeof t=="object"){const n=new xe(this),s=this.tempKey();return n.registerStructType(s,t).de(s,e,r)}throw new Error(`Incorrect type passed into the '.de()' function.
3
3
  ${JSON.stringify(t)}`)}hasType(t){return this.types.has(t)}registerAlias(t,e){return this.types.set(t,e),this}registerType(t,e,r,n=()=>!0){const{name:s,params:i}=this.parseTypeName(t);return this.types.set(s,{encode(a,o,u,l){const h=i.reduce((p,y,m)=>Object.assign(p,{[y]:l[m]}),{});return this._encodeRaw.call(a,new gr(u),o,l,h)},decode(a,o,u){const l=i.reduce((h,p,y)=>Object.assign(h,{[p]:u[y]}),{});return this._decodeRaw.call(a,new fr(o),u,l)},_encodeRaw(a,o,u,l){if(n(o))return e.call(this,a,o,u,l);throw new Error(`Validation failed for type ${s}, data: ${o}`)},_decodeRaw(a,o,u){return r.call(this,a,o,u)}}),this}registerBcsType(t,e){return this.registerType(t,(r,n,s)=>{const i=s.map(a=>new K({name:String(a),write:(o,u)=>{const{name:l,params:h}=this.parseTypeName(a),p=this.getTypeInterface(l),y=h.reduce((m,x,T)=>Object.assign(m,{[x]:s[T]}),{});return p._encodeRaw.call(this,u,o,h,y)},read:()=>{throw new Error("Not implemented")}}));return e(...i).write(n,r),r},(r,n)=>{const s=n.map(i=>new K({name:String(i),write:(a,o)=>{throw new Error("Not implemented")},read:a=>{const{name:o,params:u}=this.parseTypeName(i),l=this.getTypeInterface(o),h=u.reduce((p,y,m)=>Object.assign(p,{[y]:n[m]}),{});return l._decodeRaw.call(this,a,u,h)}}));return e(...s).read(r)}),this}registerAddressType(t,e,r="hex"){switch(r){case"base64":return this.registerType(t,function(s,i){return H(i).reduce((a,o)=>a.write8(o),s)},function(s){return $(s.readBytes(e))});case"hex":return this.registerType(t,function(s,i){return Ue(i).reduce((a,o)=>a.write8(o),s)},function(s){return ge(s.readBytes(e))});default:throw new Error("Unsupported encoding! Use either hex or base64")}}registerVectorType(t){let{name:e,params:r}=this.parseTypeName(t);if(r.length>1)throw new Error("Vector can have only one type parameter; got "+e);return this.registerType(t,function(s,i,a,o){return s.writeVec(i,(u,l)=>{let h=a[0];if(!h)throw new Error(`Incorrect number of type parameters passed a to vector '${t}'`);let{name:p,params:y}=this.parseTypeName(h);if(this.hasType(p))return this.getTypeInterface(p)._encodeRaw.call(this,u,l,y,o);if(!(p in o))throw new Error(`Unable to find a matching type definition for ${p} in vector; make sure you passed a generic`);let{name:m,params:x}=this.parseTypeName(o[p]);return this.getTypeInterface(m)._encodeRaw.call(this,u,l,x,o)})},function(s,i,a){return s.readVec(o=>{let u=i[0];if(!u)throw new Error(`Incorrect number of type parameters passed to a vector '${t}'`);let{name:l,params:h}=this.parseTypeName(u);if(this.hasType(l))return this.getTypeInterface(l)._decodeRaw.call(this,o,h,a);if(!(l in a))throw new Error(`Unable to find a matching type definition for ${l} in vector; make sure you passed a generic`);let{name:p,params:y}=this.parseTypeName(a[l]);return this.getTypeInterface(p)._decodeRaw.call(this,o,y,a)})})}registerStructType(t,e){for(let a in e){let o=this.tempKey(),u=e[a];!Array.isArray(u)&&typeof u!="string"&&(e[a]=o,this.registerStructType(o,u))}let r=Object.freeze(e),n=Object.keys(r),{name:s,params:i}=this.parseTypeName(t);return this.registerType(t,function(o,u,l,h){if(!u||u.constructor!==Object)throw new Error(`Expected ${s} to be an Object, got: ${u}`);if(l.length!==i.length)throw new Error(`Incorrect number of generic parameters passed; expected: ${i.length}, got: ${l.length}`);for(let p of n){if(!(p in u))throw new Error(`Struct ${s} requires field ${p}:${r[p]}`);const{name:y,params:m}=this.parseTypeName(r[p]);if(!i.includes(y))this.getTypeInterface(y)._encodeRaw.call(this,o,u[p],m,h);else{const x=i.indexOf(y);let{name:T,params:C}=this.parseTypeName(l[x]);if(this.hasType(T)){this.getTypeInterface(T)._encodeRaw.call(this,o,u[p],C,h);continue}if(!(T in h))throw new Error(`Unable to find a matching type definition for ${T} in ${s}; make sure you passed a generic`);let{name:M,params:se}=this.parseTypeName(h[T]);this.getTypeInterface(M)._encodeRaw.call(this,o,u[p],se,h)}}return o},function(o,u,l){if(u.length!==i.length)throw new Error(`Incorrect number of generic parameters passed; expected: ${i.length}, got: ${u.length}`);let h={};for(let p of n){const{name:y,params:m}=this.parseTypeName(r[p]);if(!i.includes(y))h[p]=this.getTypeInterface(y)._decodeRaw.call(this,o,m,l);else{const x=i.indexOf(y);let{name:T,params:C}=this.parseTypeName(u[x]);if(this.hasType(T)){h[p]=this.getTypeInterface(T)._decodeRaw.call(this,o,C,l);continue}if(!(T in l))throw new Error(`Unable to find a matching type definition for ${T} in ${s}; make sure you passed a generic`);let{name:M,params:se}=this.parseTypeName(l[T]);h[p]=this.getTypeInterface(M)._decodeRaw.call(this,o,se,l)}}return h})}registerEnumType(t,e){for(let a in e){let o=this.tempKey(),u=e[a];u!==null&&!Array.isArray(u)&&typeof u!="string"&&(e[a]=o,this.registerStructType(o,u))}let r=Object.freeze(e),n=Object.keys(r),{name:s,params:i}=this.parseTypeName(t);return this.registerType(t,function(o,u,l,h){if(!u)throw new Error(`Unable to write enum "${s}", missing data.
4
4
  Received: "${u}"`);if(typeof u!="object")throw new Error(`Incorrect data passed into enum "${s}", expected object with properties: "${n.join(" | ")}".
5
- Received: "${JSON.stringify(u)}"`);let p=Object.keys(u)[0];if(p===void 0)throw new Error(`Empty object passed as invariant of the enum "${s}"`);let y=n.indexOf(p);if(y===-1)throw new Error(`Unknown invariant of the enum "${s}", allowed values: "${n.join(" | ")}"; received "${p}"`);let m=n[y],x=r[m];if(o.write8(y),x===null)return o;let T=i.indexOf(x),C=T===-1?x:l[T];{let{name:M,params:se}=this.parseTypeName(C);return this.getTypeInterface(M)._encodeRaw.call(this,o,u[p],se,h)}},function(o,u,l){let h=o.readULEB(),p=n[h],y=r[p];if(h===-1)throw new Error(`Decoding type mismatch, expected enum "${s}" invariant index, received "${h}"`);if(y===null)return{[p]:!0};let m=i.indexOf(y),x=m===-1?y:u[m];{let{name:T,params:C}=this.parseTypeName(x);return{[p]:this.getTypeInterface(T)._decodeRaw.call(this,o,C,l)}}})}getTypeInterface(t){let e=this.types.get(t);if(typeof e=="string"){let r=[];for(;typeof e=="string";){if(r.includes(e))throw new Error(`Recursive definition found: ${r.join(" -> ")} -> ${e}`);r.push(e),e=this.types.get(e)}}if(e===void 0)throw new Error(`Type ${t} is not registered`);return e}parseTypeName(t){if(Array.isArray(t)){let[o,...u]=t;return{name:o,params:u}}if(typeof t!="string")throw new Error(`Illegal type passed as a name of the type: ${t}`);let[e,r]=this.schema.genericSeparators||["<",">"],n=t.indexOf(e),s=Array.from(t).reverse().indexOf(r);if(n===-1&&s===-1)return{name:t,params:[]};if(n===-1||s===-1)throw new Error(`Unclosed generic in name '${t}'`);let i=t.slice(0,n),a=hr(t.slice(n+1,t.length-s-1),this.schema.genericSeparators);return{name:i,params:a}}};let I=xe;I.U8="u8";I.U16="u16";I.U32="u32";I.U64="u64";I.U128="u128";I.U256="u256";I.BOOL="bool";I.VECTOR="vector";I.ADDRESS="address";I.STRING="string";I.HEX="hex-string";I.BASE58="base58-string";I.BASE64="base64-string";function wn(t){t.registerType(I.U8,function(e,r){return e.write8(r)},function(e){return e.read8()},e=>e<256),t.registerType(I.U16,function(e,r){return e.write16(r)},function(e){return e.read16()},e=>e<65536),t.registerType(I.U32,function(e,r){return e.write32(r)},function(e){return e.read32()},e=>e<=4294967296n),t.registerType(I.U64,function(e,r){return e.write64(r)},function(e){return e.read64()}),t.registerType(I.U128,function(e,r){return e.write128(r)},function(e){return e.read128()}),t.registerType(I.U256,function(e,r){return e.write256(r)},function(e){return e.read256()}),t.registerType(I.BOOL,function(e,r){return e.write8(r)},function(e){return e.read8().toString(10)==="1"}),t.registerType(I.STRING,function(e,r){return e.writeVec(Array.from(r),(n,s)=>n.write8(s.charCodeAt(0)))},function(e){return e.readVec(r=>r.read8()).map(r=>String.fromCharCode(Number(r))).join("")},e=>!0),t.registerType(I.HEX,function(e,r){return e.writeVec(Array.from(Ue(r)),(n,s)=>n.write8(s))},function(e){let r=e.readVec(n=>n.read8());return ge(new Uint8Array(r))}),t.registerType(I.BASE58,function(e,r){return e.writeVec(Array.from(d.fromB58(r)),(n,s)=>n.write8(s))},function(e){let r=e.readVec(n=>n.read8());return d.toB58(new Uint8Array(r))}),t.registerType(I.BASE64,function(e,r){return e.writeVec(Array.from(H(r)),(n,s)=>n.write8(s))},function(e){let r=e.readVec(n=>n.read8());return $(new Uint8Array(r))})}function bn(){return{genericSeparators:["<",">"],vectorType:"vector",addressLength:mn,addressEncoding:"hex"}}class Sn extends TypeError{constructor(e,r){let n;const{message:s,explanation:i,...a}=e,{path:o}=e,u=o.length===0?s:`At path: ${o.join(".")} -- ${s}`;super(i??u),i!=null&&(this.cause=u),Object.assign(this,a),this.name=this.constructor.name,this.failures=()=>n??(n=[e,...r()])}}function Tn(t){return V(t)&&typeof t[Symbol.iterator]=="function"}function V(t){return typeof t=="object"&&t!=null}function L(t){return typeof t=="symbol"?t.toString():typeof t=="string"?JSON.stringify(t):`${t}`}function En(t){const{done:e,value:r}=t.next();return e?void 0:r}function vn(t,e,r,n){if(t===!0)return;t===!1?t={}:typeof t=="string"&&(t={message:t});const{path:s,branch:i}=e,{type:a}=r,{refinement:o,message:u=`Expected a value of type \`${a}\`${o?` with refinement \`${o}\``:""}, but received: \`${L(n)}\``}=t;return{value:n,type:a,refinement:o,key:s[s.length-1],path:s,branch:i,...t,message:u}}function*nr(t,e,r,n){Tn(t)||(t=[t]);for(const s of t){const i=vn(s,e,r,n);i&&(yield i)}}function*It(t,e,r={}){const{path:n=[],branch:s=[t],coerce:i=!1,mask:a=!1}=r,o={path:n,branch:s};if(i&&(t=e.coercer(t,o),a&&e.type!=="type"&&V(e.schema)&&V(t)&&!Array.isArray(t)))for(const l in t)e.schema[l]===void 0&&delete t[l];let u="valid";for(const l of e.validator(t,o))l.explanation=r.message,u="not_valid",yield[l,void 0];for(let[l,h,p]of e.entries(t,o)){const y=It(h,p,{path:l===void 0?n:[...n,l],branch:l===void 0?s:[...s,h],coerce:i,mask:a,message:r.message});for(const m of y)m[0]?(u=m[0].refinement!=null?"not_refined":"not_valid",yield[m[0],void 0]):i&&(h=m[1],l===void 0?t=h:t instanceof Map?t.set(l,h):t instanceof Set?t.add(h):V(t)&&(h!==void 0||l in t)&&(t[l]=h))}if(u!=="not_valid")for(const l of e.refiner(t,o))l.explanation=r.message,u="not_refined",yield[l,void 0];u==="valid"&&(yield[void 0,t])}class X{constructor(e){const{type:r,schema:n,validator:s,refiner:i,coercer:a=u=>u,entries:o=function*(){}}=e;this.type=r,this.schema=n,this.entries=o,this.coercer=a,s?this.validator=(u,l)=>{const h=s(u,l);return nr(h,l,this,u)}:this.validator=()=>[],i?this.refiner=(u,l)=>{const h=i(u,l);return nr(h,l,this,u)}:this.refiner=()=>[]}assert(e,r){return lt(e,this,r)}create(e,r){return wr(e,this,r)}is(e){return U(e,this)}mask(e,r){return br(e,this,r)}validate(e,r={}){return De(e,this,r)}}function lt(t,e,r){const n=De(t,e,{message:r});if(n[0])throw n[0]}function wr(t,e,r){const n=De(t,e,{coerce:!0,message:r});if(n[0])throw n[0];return n[1]}function br(t,e,r){const n=De(t,e,{coerce:!0,mask:!0,message:r});if(n[0])throw n[0];return n[1]}function U(t,e){return!De(t,e)[0]}function De(t,e,r={}){const n=It(t,e,r),s=En(n);return s[0]?[new Sn(s[0],function*(){for(const a of n)a[0]&&(yield a[0])}),void 0]:[void 0,s[1]]}function Ce(...t){const e=t[0].type==="type",r=t.map(s=>s.schema),n=Object.assign({},...r);return e?xn(n):g(n)}function D(t,e){return new X({type:t,schema:null,validator:e})}function ft(){return D("any",()=>!0)}function E(t){return new X({type:"array",schema:t,*entries(e){if(t&&Array.isArray(e))for(const[r,n]of e.entries())yield[r,n,t]},coercer(e){return Array.isArray(e)?e.slice():e},validator(e){return Array.isArray(e)||`Expected an array value, but received: ${L(e)}`}})}function kn(){return D("bigint",t=>typeof t=="bigint")}function P(){return D("boolean",t=>typeof t=="boolean")}function J(){return D("integer",t=>typeof t=="number"&&!isNaN(t)&&Number.isInteger(t)||`Expected an integer, but received: ${L(t)}`)}function b(t){const e=L(t),r=typeof t;return new X({type:"literal",schema:r==="string"||r==="number"||r==="boolean"?t:null,validator(n){return n===t||`Expected the literal \`${e}\`, but received: ${L(n)}`}})}function Sr(){return D("never",()=>!1)}function O(t){return new X({...t,validator:(e,r)=>e===null||t.validator(e,r),refiner:(e,r)=>e===null||t.refiner(e,r)})}function fe(){return D("number",t=>typeof t=="number"&&!isNaN(t)||`Expected a number, but received: ${L(t)}`)}function g(t){const e=t?Object.keys(t):[],r=Sr();return new X({type:"object",schema:t||null,*entries(n){if(t&&V(n)){const s=new Set(Object.keys(n));for(const i of e)s.delete(i),yield[i,n[i],t[i]];for(const i of s)yield[i,n[i],r]}},validator(n){return V(n)||`Expected an object, but received: ${L(n)}`},coercer(n){return V(n)?{...n}:n}})}function w(t){return new X({...t,validator:(e,r)=>e===void 0||t.validator(e,r),refiner:(e,r)=>e===void 0||t.refiner(e,r)})}function Z(t,e){return new X({type:"record",schema:null,*entries(r){if(V(r))for(const n in r){const s=r[n];yield[n,n,t],yield[n,s,e]}},validator(r){return V(r)||`Expected an object, but received: ${L(r)}`}})}function f(){return D("string",t=>typeof t=="string"||`Expected a string, but received: ${L(t)}`)}function Tr(t){const e=Sr();return new X({type:"tuple",schema:null,*entries(r){if(Array.isArray(r)){const n=Math.max(t.length,r.length);for(let s=0;s<n;s++)yield[s,r[s],t[s]||e]}},validator(r){return Array.isArray(r)||`Expected an array, but received: ${L(r)}`}})}function xn(t){const e=Object.keys(t);return new X({type:"type",schema:t,*entries(r){if(V(r))for(const n of e)yield[n,r[n],t[n]]},validator(r){return V(r)||`Expected an object, but received: ${L(r)}`},coercer(r){return V(r)?{...r}:r}})}function j(t){const e=t.map(r=>r.type).join(" | ");return new X({type:"union",schema:null,coercer(r){for(const n of t){const[s,i]=n.validate(r,{coerce:!0});if(!s)return i}return r},validator(r,n){const s=[];for(const i of t){const[...a]=It(r,i,n),[o]=a;if(o[0])for(const[u]of a)u&&s.push(u);else return[]}return[`Expected the value to satisfy a union of \`${e}\`, but received: ${L(r)}`,...s]}})}function Er(){return D("unknown",()=>!0)}/*! scure-bip39 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) */function vr(t){if(typeof t!="string")throw new TypeError(`Invalid mnemonic type: ${typeof t}`);return t.normalize("NFKD")}function In(t){const e=vr(t),r=e.split(" ");if(![12,15,18,21,24].includes(r.length))throw new Error("Invalid mnemonic");return{nfkd:e,words:r}}const _n=t=>vr(`mnemonic${t}`);function An(t,e=""){return un.pbkdf2(d.sha512,In(t).nfkd,_n(e),{c:2048,dkLen:64})}const On="0.50.1",jn="1.19.0",Cn={"-32700":"ParseError","-32600":"InvalidRequest","-32601":"MethodNotFound","-32602":"InvalidParams","-32603":"InternalError"};class kr extends Error{}class xr extends kr{constructor(e,r){super(e),this.code=r,this.type=Cn[r]??"ServerError"}}class Bn extends kr{constructor(e,r,n){super(e),this.status=r,this.statusText=n}}var _t=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},_=(t,e,r)=>(_t(t,e,"read from private field"),r?r.call(t):e.get(t)),ie=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},we=(t,e,r,n)=>(_t(t,e,"write to private field"),e.set(t,r),r),Mn=(t,e,r,n)=>({set _(s){we(t,e,s)},get _(){return _(t,e,n)}}),Ir=(t,e,r)=>(_t(t,e,"access private method"),r),de,Oe,ee,le,Be,be,ht,_r,At,Ar;function Pn(t){const e=new URL(t);return e.protocol=e.protocol.replace("http","ws"),e.toString()}const Rn={WebSocketConstructor:typeof WebSocket<"u"?WebSocket:void 0,callTimeout:3e4,reconnectTimeout:3e3,maxReconnects:5};class Nn{constructor(e,r={}){if(ie(this,ht),ie(this,At),ie(this,de,0),ie(this,Oe,0),ie(this,ee,null),ie(this,le,null),ie(this,Be,new Set),ie(this,be,new Map),this.endpoint=e,this.options={...Rn,...r},!this.options.WebSocketConstructor)throw new Error("Missing WebSocket constructor");this.endpoint.startsWith("http")&&(this.endpoint=Pn(this.endpoint))}async makeRequest(e,r){const n=await Ir(this,ht,_r).call(this);return new Promise((s,i)=>{we(this,de,_(this,de)+1),_(this,be).set(_(this,de),{resolve:s,reject:i,timeout:setTimeout(()=>{_(this,be).delete(_(this,de)),i(new Error(`Request timeout: ${e}`))},this.options.callTimeout)}),n.send(JSON.stringify({jsonrpc:"2.0",id:_(this,de),method:e,params:r}))}).then(({error:s,result:i})=>{if(s)throw new xr(s.message,s.code);return i})}async subscribe(e){const r=new $n(e);return _(this,Be).add(r),await r.subscribe(this),()=>r.unsubscribe(this)}}de=new WeakMap;Oe=new WeakMap;ee=new WeakMap;le=new WeakMap;Be=new WeakMap;be=new WeakMap;ht=new WeakSet;_r=function(){return _(this,le)?_(this,le):(we(this,le,new Promise(t=>{var e;(e=_(this,ee))==null||e.close(),we(this,ee,new this.options.WebSocketConstructor(this.endpoint)),_(this,ee).addEventListener("open",()=>{we(this,Oe,0),t(_(this,ee))}),_(this,ee).addEventListener("close",()=>{Mn(this,Oe)._++,_(this,Oe)<=this.options.maxReconnects&&setTimeout(()=>{Ir(this,At,Ar).call(this)},this.options.reconnectTimeout)}),_(this,ee).addEventListener("message",({data:r})=>{let n;try{n=JSON.parse(r)}catch(s){console.error(new Error(`Failed to parse RPC message: ${r}`,{cause:s}));return}if("id"in n&&n.id!=null&&_(this,be).has(n.id)){const{resolve:s,timeout:i}=_(this,be).get(n.id);clearTimeout(i),s(n)}else if("params"in n){const{params:s}=n;_(this,Be).forEach(i=>{i.subscriptionId===s.subscription&&s.subscription===i.subscriptionId&&i.onMessage(s.result)})}})})),_(this,le))};At=new WeakSet;Ar=async function(){var t;return(t=_(this,ee))==null||t.close(),we(this,le,null),Promise.allSettled([..._(this,Be)].map(e=>e.subscribe(this)))};class $n{constructor(e){this.subscriptionId=null,this.subscribed=!1,this.input=e}onMessage(e){this.subscribed&&this.input.onMessage(e)}async unsubscribe(e){const{subscriptionId:r}=this;return this.subscribed=!1,r==null?!1:(this.subscriptionId=null,e.makeRequest(this.input.unsubscribe,[r]))}async subscribe(e){this.subscriptionId=null,this.subscribed=!0;const r=await e.makeRequest(this.input.method,this.input.params);this.subscribed&&(this.subscriptionId=r)}}var Ot=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},z=(t,e,r)=>(Ot(t,e,"read from private field"),r?r.call(t):e.get(t)),ze=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},gt=(t,e,r,n)=>(Ot(t,e,"write to private field"),e.set(t,r),r),Un=(t,e,r)=>(Ot(t,e,"access private method"),r),Ie,F,je,pt,Or;class Dn{constructor(e){ze(this,pt),ze(this,Ie,0),ze(this,F,void 0),ze(this,je,void 0),gt(this,F,e)}fetch(e,r){const n=z(this,F).fetch??globalThis.fetch;if(!this.fetch)throw new Error("The current environment does not support fetch, you can provide a fetch implementation in the options for SuiHTTPTransport.");return n(e,r)}async request(e){var s,i;gt(this,Ie,z(this,Ie)+1);const r=await this.fetch(((s=z(this,F).rpc)==null?void 0:s.url)??z(this,F).url,{method:"POST",headers:{"Content-Type":"application/json","Client-Sdk-Type":"typescript","Client-Sdk-Version":On,"Client-Target-Api-Version":jn,...(i=z(this,F).rpc)==null?void 0:i.headers},body:JSON.stringify({jsonrpc:"2.0",id:z(this,Ie),method:e.method,params:e.params})});if(!r.ok)throw new Bn(`Unexpected status code: ${r.status}`,r.status,r.statusText);const n=await r.json();if("error"in n&&n.error!=null)throw new xr(n.error.message,n.error.code);return n.result}async subscribe(e){const r=await Un(this,pt,Or).call(this).subscribe(e);return async()=>!!await r()}}Ie=new WeakMap;F=new WeakMap;je=new WeakMap;pt=new WeakSet;Or=function(){var t;if(!z(this,je)){const e=z(this,F).WebSocketConstructor??globalThis.WebSocket;if(!e)throw new Error("The current environment does not support WebSocket, you can provide a WebSocketConstructor in the options for SuiHTTPTransport.");gt(this,je,new Nn(((t=z(this,F).websocket)==null?void 0:t.url)??z(this,F).url,{WebSocketConstructor:e,...z(this,F).websocket}))}return z(this,je)};const zn=/^vector<(.+)>$/,Vn=/^([^:]+)::([^:]+)::([^<]+)(<(.+)>)?/;class te{static parseFromStr(e,r=!1){if(e==="address")return{address:null};if(e==="bool")return{bool:null};if(e==="u8")return{u8:null};if(e==="u16")return{u16:null};if(e==="u32")return{u32:null};if(e==="u64")return{u64:null};if(e==="u128")return{u128:null};if(e==="u256")return{u256:null};if(e==="signer")return{signer:null};const n=e.match(zn);if(n)return{vector:te.parseFromStr(n[1],r)};const s=e.match(Vn);if(s)return{struct:{address:r?d.normalizeSuiAddress(s[1]):s[1],module:s[2],name:s[3],typeParams:s[5]===void 0?[]:te.parseStructTypeArgs(s[5],r)}};throw new Error(`Encountered unexpected token when parsing type args for ${e}`)}static parseStructTypeArgs(e,r=!1){return hr(e).map(n=>te.parseFromStr(n,r))}static tagToString(e){if("bool"in e)return"bool";if("u8"in e)return"u8";if("u16"in e)return"u16";if("u32"in e)return"u32";if("u64"in e)return"u64";if("u128"in e)return"u128";if("u256"in e)return"u256";if("address"in e)return"address";if("signer"in e)return"signer";if("vector"in e)return`vector<${te.tagToString(e.vector)}>`;if("struct"in e){const r=e.struct,n=r.typeParams.map(te.tagToString).join(", ");return`${r.address}::${r.module}::${r.name}${n?`<${n}>`:""}`}throw new Error("Invalid TypeTag")}}const k=new I({...bn(),types:{enums:{"Option<T>":{None:null,Some:"T"}}}});function jr(t){return c.u64({name:"unsafe_u64",...t}).transform({input:e=>e,output:e=>Number(e)})}function Ln(t){return c.enum("Option",{None:null,Some:t})}function jt(t){return t.transform({input:e=>({[e.kind]:e}),output:e=>{const r=Object.keys(e)[0];return{kind:r,...e[r]}}})}const G=c.bytes(d.SUI_ADDRESS_LENGTH).transform({input:t=>typeof t=="string"?Ue(d.normalizeSuiAddress(t)):t,output:t=>d.normalizeSuiAddress(ge(t))}),Ct=c.vector(c.u8()).transform({name:"ObjectDigest",input:t=>d.fromB58(t),output:t=>d.toB58(new Uint8Array(t))}),Me=c.struct("SuiObjectRef",{objectId:G,version:c.u64(),digest:Ct}),Bt=c.struct("SharedObjectRef",{objectId:G,initialSharedVersion:c.u64(),mutable:c.bool()}),Ye=c.enum("ObjectArg",{ImmOrOwned:Me,Shared:Bt,Receiving:Me}),Mt=c.enum("CallArg",{Pure:c.vector(c.u8()),Object:Ye,ObjVec:c.vector(Ye)}),ve=c.enum("TypeTag",{bool:null,u8:null,u64:null,u128:null,address:null,signer:null,vector:c.lazy(()=>ve),struct:c.lazy(()=>Dt),u16:null,u32:null,u256:null}),q=jt(c.enum("Argument",{GasCoin:null,Input:c.struct("Input",{index:c.u16()}),Result:c.struct("Result",{index:c.u16()}),NestedResult:c.struct("NestedResult",{index:c.u16(),resultIndex:c.u16()})})),Pt=c.struct("ProgrammableMoveCall",{package:G,module:c.string(),function:c.string(),type_arguments:c.vector(ve),arguments:c.vector(q)}).transform({input:t=>{const[e,r,n]=t.target.split("::"),s=t.typeArguments.map(i=>te.parseFromStr(i,!0));return{package:d.normalizeSuiAddress(e),module:r,function:n,type_arguments:s,arguments:t.arguments}},output:t=>({target:[t.package,t.module,t.function].join("::"),arguments:t.arguments,typeArguments:t.type_arguments.map(te.tagToString)})}),Rt=jt(c.enum("Transaction",{MoveCall:Pt,TransferObjects:c.struct("TransferObjects",{objects:c.vector(q),address:q}),SplitCoins:c.struct("SplitCoins",{coin:q,amounts:c.vector(q)}),MergeCoins:c.struct("MergeCoins",{destination:q,sources:c.vector(q)}),Publish:c.struct("Publish",{modules:c.vector(c.vector(c.u8())),dependencies:c.vector(G)}),MakeMoveVec:c.struct("MakeMoveVec",{type:Ln(ve),objects:c.vector(q)}),Upgrade:c.struct("Upgrade",{modules:c.vector(c.vector(c.u8())),dependencies:c.vector(G),packageId:G,ticket:q})})),Nt=c.struct("ProgrammableTransaction",{inputs:c.vector(Mt),transactions:c.vector(Rt)}),$t=c.enum("TransactionKind",{ProgrammableTransaction:Nt,ChangeEpoch:null,Genesis:null,ConsensusCommitPrologue:null}),Ut=c.enum("TransactionExpiration",{None:null,Epoch:jr()}),Dt=c.struct("StructTag",{address:G,module:c.string(),name:c.string(),typeParams:c.vector(ve)}),zt=c.struct("GasData",{payment:c.vector(Me),owner:G,price:c.u64(),budget:c.u64()}),Vt=c.struct("TransactionDataV1",{kind:$t,sender:G,gasData:zt,expiration:Ut}),Lt=c.enum("TransactionData",{V1:Vt}),qn=c.enum("IntentScope",{TransactionData:null,TransactionEffects:null,CheckpointSummary:null,PersonalMessage:null}),Wn=c.enum("IntentVersion",{V0:null}),Fn=c.enum("AppId",{Sui:null}),Kn=c.struct("Intent",{scope:qn,version:Wn,appId:Fn}),Gn=c.generic(["T"],t=>c.struct("IntentMessage<T>",{intent:Kn,value:t})),qt=c.enum("CompressedSignature",{ED25519:c.fixedArray(64,c.u8()),Secp256k1:c.fixedArray(64,c.u8()),Secp256r1:c.fixedArray(64,c.u8()),ZkLogin:c.vector(c.u8())}),Wt=c.enum("PublicKey",{ED25519:c.fixedArray(32,c.u8()),Secp256k1:c.fixedArray(33,c.u8()),Secp256r1:c.fixedArray(33,c.u8()),ZkLogin:c.vector(c.u8())}),Ft=c.struct("MultiSigPkMap",{pubKey:Wt,weight:c.u8()}),Kt=c.struct("MultiSigPublicKey",{pk_map:c.vector(Ft),threshold:c.u16()}),Cr=c.struct("MultiSig",{sigs:c.vector(qt),bitmap:c.u16(),multisig_pk:Kt}),Hn=c.vector(c.u8()).transform({input:t=>typeof t=="string"?H(t):t,output:t=>$(new Uint8Array(t))}),Br=c.struct("SenderSignedTransaction",{intentMessage:Gn(Lt),txSignatures:c.vector(Hn)}),Mr=c.vector(Br,{name:"SenderSignedData"}),A={...c,U8:c.u8(),U16:c.u16(),U32:c.u32(),U64:c.u64(),U128:c.u128(),U256:c.u256(),ULEB128:c.uleb128(),Bool:c.bool(),String:c.string(),Address:G,Argument:q,CallArg:Mt,CompressedSignature:qt,GasData:zt,MultiSig:Cr,MultiSigPkMap:Ft,MultiSigPublicKey:Kt,ObjectArg:Ye,ObjectDigest:Ct,ProgrammableMoveCall:Pt,ProgrammableTransaction:Nt,PublicKey:Wt,SenderSignedData:Mr,SenderSignedTransaction:Br,SharedObjectRef:Bt,StructTag:Dt,SuiObjectRef:Me,Transaction:Rt,TransactionData:Lt,TransactionDataV1:Vt,TransactionExpiration:Ut,TransactionKind:$t,TypeTag:ve,ser:k.ser.bind(k),de:k.de.bind(k),getTypeInterface:k.getTypeInterface.bind(k),hasType:k.hasType.bind(k),parseTypeName:k.parseTypeName.bind(k),registerAddressType:k.registerAddressType.bind(k),registerAlias:k.registerAlias.bind(k),registerBcsType:k.registerBcsType.bind(k),registerEnumType:k.registerEnumType.bind(k),registerStructType:k.registerStructType.bind(k),registerType:k.registerType.bind(k),types:k.types};k.registerBcsType("utf8string",()=>c.string({name:"utf8string"}));k.registerBcsType("unsafe_u64",()=>jr());k.registerBcsType("enumKind",t=>jt(t));[G,q,Mt,qt,zt,Cr,Ft,Kt,Ye,Ct,Pt,Nt,Wt,Mr,Bt,Dt,Me,Rt,Lt,Vt,Ut,$t,ve].forEach(t=>{k.registerBcsType(t.name,()=>t)});const Gt=j([g({AddressOwner:f()}),g({ObjectOwner:f()}),g({Shared:g({initial_shared_version:O(f())})}),b("Immutable")]);D("SuiJsonValue",()=>!0);const Zn=j([g({u32:f()}),g({u64:f()}),g({f64:f()})]);g({attributes:Z(f(),O(Zn)),featureFlags:Z(f(),P()),maxSupportedProtocolVersion:f(),minSupportedProtocolVersion:f(),protocolVersion:f()});j([f(),b("package")]);const oe=g({digest:f(),objectId:f(),version:j([fe(),f(),kn()])});g({owner:Gt,reference:oe});g({objectId:f(),sequenceNumber:f()});g({payment:E(oe),owner:f(),price:f(),budget:f()});const Jn=Ce(oe,g({type:f(),owner:Gt,previousTransaction:f()})),Xn=Z(f(),ft()),Yn=Z(f(),Er()),Qn=g({type:f(),fields:Xn,hasPublicTransfer:P()}),es=g({disassembled:Yn}),ts=j([Ce(Qn,g({dataType:b("moveObject")})),Ce(es,g({dataType:b("package")}))]),rs=g({type:f(),hasPublicTransfer:P(),version:f(),bcsBytes:f()}),ns=g({id:f(),moduleMap:Z(f(),f())}),ss=j([Ce(rs,g({dataType:b("moveObject")})),Ce(ns,g({dataType:b("package")}))]);BigInt(1e9);const Pr=g({code:f(),error:w(f()),object_id:w(f()),parent_object_id:w(f()),version:w(f()),digest:w(f())}),is=g({data:O(w(Z(f(),f()))),error:O(w(Pr))}),as=j([is,w(Z(f(),f()))]),Rr=g({objectId:f(),version:f(),digest:f(),type:O(w(f())),content:O(w(ts)),bcs:O(w(ss)),owner:O(w(Gt)),previousTransaction:O(w(f())),storageRebate:O(w(f())),display:O(w(as))});g({showType:O(w(P())),showContent:O(w(P())),showBcs:O(w(P())),showOwner:O(w(P())),showPreviousTransaction:O(w(P())),showStorageRebate:O(w(P())),showDisplay:O(w(P()))});j([b("Exists"),b("notExists"),b("Deleted")]);E(Jn);const os=g({data:O(w(Rr)),error:O(w(Pr))});function cs(t){return t.data}function us(t){if(t.error&&"object_id"in t.error&&"version"in t.error&&"digest"in t.error){const e=t.error;return{objectId:e.object_id,version:e.version,digest:e.digest}}}function sr(t){if("reference"in t)return t.reference;const e=cs(t);return e?{objectId:e.objectId,version:e.version,digest:e.digest}:us(t)}g({objectId:f(),atCheckpoint:w(fe())});g({data:E(os),nextCursor:w(O(f())),hasNextPage:P()});j([g({details:Rr,status:b("VersionFound")}),g({details:f(),status:b("ObjectNotExists")}),g({details:oe,status:b("ObjectDeleted")}),g({details:Tr([f(),fe()]),status:b("VersionNotFound")}),g({details:g({asked_version:fe(),latest_version:fe(),object_id:f()}),status:b("VersionTooHigh")})]);const ds=j([f(),g({Object:f()})]);E(ds);const ls=g({address:f(),name:f()}),fs=j([b("Private"),b("Public"),b("Friend")]),Ht=g({abilities:E(f())}),hs=g({constraints:Ht,isPhantom:P()}),gs=g({TypeParameter:fe()}),ct=Tr([g({module:f(),package:f(),function:f()}),f()]);g({rank3Days:E(ct),rank7Days:E(ct),rank30Days:E(ct)});function Nr(t){if(!t)return!1;if(typeof t=="string"||U(t,gs)||$r(t))return!0;if(typeof t!="object")return!1;const e=t;return!!(U(e.Reference,Se)||U(e.MutableReference,Se)||U(e.Vector,Se))}const Se=D("SuiMoveNormalizedType",Nr);function $r(t){if(!t||typeof t!="object")return!1;const e=t;if(!e.Struct||typeof e.Struct!="object")return!1;const r=e.Struct;return!(typeof r.address!="string"||typeof r.module!="string"||typeof r.name!="string"||!Array.isArray(r.typeArguments)||!r.typeArguments.every(n=>Nr(n)))}D("SuiMoveNormalizedStructType",$r);const ps=g({visibility:fs,isEntry:P(),typeParameters:E(Ht),parameters:E(Se),return:E(Se)}),ys=g({name:f(),type:Se}),ms=g({abilities:Ht,typeParameters:E(hs),fields:E(ys)}),ws=g({fileFormatVersion:fe(),address:f(),name:f(),friends:E(ls),structs:Z(f(),ms),exposedFunctions:Z(f(),ps)});Z(f(),ws);function yt(t){return typeof t=="object"&&"MutableReference"in t?t.MutableReference:void 0}function Ur(t){return typeof t=="object"&&"Reference"in t?t.Reference:void 0}function Zt(t){if(typeof t=="object"&&"Struct"in t)return t;const e=Ur(t),r=yt(t);if(typeof e=="object"&&"Struct"in e)return e;if(typeof r=="object"&&"Struct"in r)return r}const bs=j([g({ImmOrOwned:oe}),g({Shared:g({objectId:f(),initialSharedVersion:j([J(),f()]),mutable:P()})}),g({Receiving:oe})]),Qe=g({Pure:E(J())}),mt=g({Object:bs}),et=j([Qe,mt]);function Ss(t,e){return{Pure:Array.from(t instanceof Uint8Array?t:xt(t)?t.toBytes():A.ser(e,t,{maxSize:1/0}).toBytes())}}const N={Pure:Ss,ObjectRef({objectId:t,digest:e,version:r}){return{Object:{ImmOrOwned:{digest:e,version:r,objectId:d.normalizeSuiAddress(t)}}}},SharedObjectRef({objectId:t,mutable:e,initialSharedVersion:r}){return{Object:{Shared:{mutable:e,initialSharedVersion:r,objectId:d.normalizeSuiAddress(t)}}}},ReceivingRef({objectId:t,digest:e,version:r}){return{Object:{Receiving:{digest:e,version:r,objectId:d.normalizeSuiAddress(t)}}}}};function ir(t){return typeof t=="string"?d.normalizeSuiAddress(t):"ImmOrOwned"in t.Object?d.normalizeSuiAddress(t.Object.ImmOrOwned.objectId):"Receiving"in t.Object?d.normalizeSuiAddress(t.Object.Receiving.objectId):d.normalizeSuiAddress(t.Object.Shared.objectId)}function Ts(t){return typeof t=="object"&&"Object"in t&&"Shared"in t.Object?t.Object.Shared:void 0}function Es(t){var e;return((e=Ts(t))==null?void 0:e.mutable)??!1}function vs(t){function e(r,n){return t(r,n)}return e.u8=r=>t(A.U8.serialize(r)),e.u16=r=>t(A.U16.serialize(r)),e.u32=r=>t(A.U32.serialize(r)),e.u64=r=>t(A.U64.serialize(r)),e.u128=r=>t(A.U128.serialize(r)),e.u256=r=>t(A.U256.serialize(r)),e.bool=r=>t(A.Bool.serialize(r)),e.string=r=>t(A.String.serialize(r)),e.address=r=>t(A.Address.serialize(r)),e.id=e.address,e}const ks="object",xs="ID",Is="ascii",_s="String",As="string",Os="String",js="option",Cs="Option",Bs={address:d.SUI_FRAMEWORK_ADDRESS,module:ks,name:xs},Ms={address:d.MOVE_STDLIB_ADDRESS,module:Is,name:_s},Ps={address:d.MOVE_STDLIB_ADDRESS,module:As,name:Os},Rs={address:d.MOVE_STDLIB_ADDRESS,module:js,name:Cs},Ve=(t,e)=>t.address===e.address&&t.module===e.module&&t.name===e.name;function Ns(t){var r;const e=(r=Zt(t))==null?void 0:r.Struct;return(e==null?void 0:e.address)==="0x2"&&(e==null?void 0:e.module)==="tx_context"&&(e==null?void 0:e.name)==="TxContext"}function ut(t,e){if(!(typeof e>"u")&&typeof e!==t)throw new Error(`Expect ${e} to be ${t}, received ${typeof e}`)}const $s=["Address","Bool","U8","U16","U32","U64","U128","U256"];function wt(t,e){if(typeof t=="string"&&$s.includes(t)){if(t in["U8","U16","U32","U64","U128","U256"])ut("number",e);else if(t==="Bool")ut("boolean",e);else if(t==="Address"&&(ut("string",e),e&&!d.isValidSuiAddress(e)))throw new Error("Invalid Sui Address");return t.toLowerCase()}else if(typeof t=="string")throw new Error(`Unknown pure normalized type ${JSON.stringify(t,null,2)}`);if("Vector"in t){if((e===void 0||typeof e=="string")&&t.Vector==="U8")return"string";if(e!==void 0&&!Array.isArray(e))throw new Error(`Expect ${e} to be a array, received ${typeof e}`);const r=wt(t.Vector,e?e[0]:void 0);return r===void 0?void 0:`vector<${r}>`}if("Struct"in t){if(Ve(t.Struct,Ms))return"string";if(Ve(t.Struct,Ps))return"utf8string";if(Ve(t.Struct,Bs))return"address";if(Ve(t.Struct,Rs)){const r={Vector:t.Struct.typeArguments[0]};return wt(r,e)}}}function Us(t,e){const r=Array.from(`${t}::`).map(s=>s.charCodeAt(0)),n=new Uint8Array(r.length+e.length);return n.set(r),n.set(e,r.length),d.blake2b(n,{dkLen:32})}function R(t,e){return wr(t,e)}const Ds=t=>j([g({None:j([b(!0),b(null)])}),g({Some:t})]),Pe=j([g({kind:b("Input"),index:J(),value:w(ft()),type:w(b("object"))}),g({kind:b("Input"),index:J(),value:w(ft()),type:b("pure")})]),zs=[Pe,g({kind:b("GasCoin")}),g({kind:b("Result"),index:J()}),g({kind:b("NestedResult"),index:J(),resultIndex:J()})],ne=j([...zs]),Dr=g({kind:b("MoveCall"),target:D("target",f().validator),typeArguments:E(f()),arguments:E(ne)}),zr=g({kind:b("TransferObjects"),objects:E(ne),address:ne}),Vr=g({kind:b("SplitCoins"),coin:ne,amounts:E(ne)}),Lr=g({kind:b("MergeCoins"),destination:ne,sources:E(ne)}),qr=g({kind:b("MakeMoveVec"),type:w(Ds(Z(f(),Er()))),objects:E(ne)}),Wr=g({kind:b("Publish"),modules:E(E(J())),dependencies:E(f())}),Fr=g({kind:b("Upgrade"),modules:E(E(J())),dependencies:E(f()),packageId:f(),ticket:ne}),Vs=[Dr,zr,Vr,Lr,Wr,Fr,qr],Ls=j([...Vs]),ue={MoveCall(t){return R({kind:"MoveCall",target:t.target,arguments:t.arguments??[],typeArguments:t.typeArguments??[]},Dr)},TransferObjects(t,e){return e.kind==="Input"&&e.type==="pure"&&typeof e.value!="object"&&(e.value=N.Pure(A.Address.serialize(e.value))),R({kind:"TransferObjects",objects:t,address:e},zr)},SplitCoins(t,e){return e.forEach(r=>{r.kind==="Input"&&r.type==="pure"&&typeof r.value!="object"&&(r.value=N.Pure(A.U64.serialize(r.value)))}),R({kind:"SplitCoins",coin:t,amounts:e},Vr)},MergeCoins(t,e){return R({kind:"MergeCoins",destination:t,sources:e},Lr)},Publish({modules:t,dependencies:e}){return R({kind:"Publish",modules:t.map(r=>typeof r=="string"?Array.from(H(r)):r),dependencies:e.map(r=>d.normalizeSuiObjectId(r))},Wr)},Upgrade({modules:t,dependencies:e,packageId:r,ticket:n}){return R({kind:"Upgrade",modules:t.map(s=>typeof s=="string"?Array.from(H(s)):s),dependencies:e.map(s=>d.normalizeSuiObjectId(s)),packageId:r,ticket:n},Fr)},MakeMoveVec({type:t,objects:e}){return R({kind:"MakeMoveVec",type:t?{Some:te.parseFromStr(t)}:{None:null},objects:e},qr)}},qs=w(O(j([g({Epoch:J()}),g({None:j([b(!0),b(null)])})]))),ar=D("StringEncodedBigint",t=>{if(!["string","number","bigint"].includes(typeof t))return!1;try{return BigInt(t),!0}catch{return!1}}),Ws=g({budget:w(ar),price:w(ar),payment:w(E(oe)),owner:w(f())}),Le=g({version:b(1),sender:w(f()),expiration:qs,gasConfig:Ws,inputs:E(Pe),transactions:E(Ls)});function or(t){return d.normalizeSuiAddress(t).replace("0x","")}class re{constructor(e){this.version=1,this.sender=e==null?void 0:e.sender,this.expiration=e==null?void 0:e.expiration,this.gasConfig=(e==null?void 0:e.gasConfig)??{},this.inputs=(e==null?void 0:e.inputs)??[],this.transactions=(e==null?void 0:e.transactions)??[]}static fromKindBytes(e){const r=A.TransactionKind.parse(e),n="ProgrammableTransaction"in r?r.ProgrammableTransaction:null;if(!n)throw new Error("Unable to deserialize from bytes.");const s=R({version:1,gasConfig:{},inputs:n.inputs.map((i,a)=>R({kind:"Input",value:i,index:a,type:U(i,Qe)?"pure":"object"},Pe)),transactions:n.transactions},Le);return re.restore(s)}static fromBytes(e){var a;const r=A.TransactionData.parse(e),n=r==null?void 0:r.V1,s="ProgrammableTransaction"in n.kind?(a=n==null?void 0:n.kind)==null?void 0:a.ProgrammableTransaction:null;if(!n||!s)throw new Error("Unable to deserialize from bytes.");const i=R({version:1,sender:n.sender,expiration:n.expiration,gasConfig:n.gasData,inputs:s.inputs.map((o,u)=>R({kind:"Input",value:o,index:u,type:U(o,Qe)?"pure":"object"},Pe)),transactions:s.transactions},Le);return re.restore(i)}static restore(e){lt(e,Le);const r=new re;return Object.assign(r,e),r}static getDigestFromBytes(e){const r=Us("TransactionData",e);return d.toB58(r)}build({maxSizeBytes:e=1/0,overrides:r,onlyTransactionKind:n}={}){const s=this.inputs.map(h=>(lt(h.value,et),h.value)),i={ProgrammableTransaction:{inputs:s,transactions:this.transactions}};if(n)return A.TransactionKind.serialize(i,{maxSize:e}).toBytes();const a=(r==null?void 0:r.expiration)??this.expiration,o=(r==null?void 0:r.sender)??this.sender,u={...this.gasConfig,...r==null?void 0:r.gasConfig};if(!o)throw new Error("Missing transaction sender");if(!u.budget)throw new Error("Missing gas budget");if(!u.payment)throw new Error("Missing gas payment");if(!u.price)throw new Error("Missing gas price");const l={sender:or(o),expiration:a||{None:!0},gasData:{payment:u.payment,owner:or(this.gasConfig.owner??o),price:BigInt(u.price),budget:BigInt(u.budget)},kind:{ProgrammableTransaction:{inputs:s,transactions:this.transactions}}};return A.TransactionData.serialize({V1:l},{maxSize:e}).toBytes()}getDigest(){const e=this.build({onlyTransactionKind:!1});return re.getDigestFromBytes(e)}snapshot(){return R(this,Le)}}var Jt=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},v=(t,e,r)=>(Jt(t,e,"read from private field"),r?r.call(t):e.get(t)),Y=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},qe=(t,e,r,n)=>(Jt(t,e,"write to private field"),e.set(t,r),r),B=(t,e,r)=>(Jt(t,e,"access private method"),r),S,_e,Fe,Ae,Ke,ce,he,Xt,Kr,Yt,Gr,Qt,Hr,er,Zr,Ge,bt;const Fs={maxPureArgumentSize:16*1024,maxTxGas:5e10,maxGasObjects:256,maxTxSizeBytes:128*1024};function Ks(t){const e={kind:"Result",index:t},r=[],n=s=>r[s]??(r[s]={kind:"NestedResult",index:t,resultIndex:s});return new Proxy(e,{set(){throw new Error("The transaction result is a proxy, and does not support setting properties directly")},get(s,i){if(i in s)return Reflect.get(s,i);if(i===Symbol.iterator)return function*(){let o=0;for(;;)yield n(o),o++};if(typeof i=="symbol")return;const a=parseInt(i,10);if(!(Number.isNaN(a)||a<0))return n(a)}})}function Gs(t){const e=Zt(t);return e?e.Struct.address==="0x2"&&e.Struct.module==="transfer"&&e.Struct.name==="Receiving":!1}function Re(t){if(!t.client)throw new Error("No provider passed to Transaction#build, but transaction data was not sufficient to build offline.");return t.client}const Jr=Symbol.for("@mysten/transaction"),dt={maxTxGas:"max_tx_gas",maxGasObjects:"max_gas_payment_objects",maxTxSizeBytes:"max_tx_size_bytes",maxPureArgumentSize:"max_pure_argument_size"},Hs=1000n,Zs=50,Js=(t,e)=>Array.from({length:Math.ceil(t.length/e)},(r,n)=>t.slice(n*e,n*e+e));function Xs(t){return!!t&&typeof t=="object"&&t[Jr]===!0}const St=class{constructor(t){Y(this,_e),Y(this,Ae),Y(this,ce),Y(this,Xt),Y(this,Yt),Y(this,Qt),Y(this,er),Y(this,Ge),Y(this,S,void 0),qe(this,S,new re(t?t.blockData:void 0))}static fromKind(t){const e=new St;return qe(e,S,re.fromKindBytes(typeof t=="string"?H(t):t)),e}static from(t){const e=new St;return typeof t!="string"||!t.startsWith("{")?qe(e,S,re.fromBytes(typeof t=="string"?H(t):t)):qe(e,S,re.restore(JSON.parse(t))),e}setSender(t){v(this,S).sender=t}setSenderIfNotSet(t){v(this,S).sender||(v(this,S).sender=t)}setExpiration(t){v(this,S).expiration=t}setGasPrice(t){v(this,S).gasConfig.price=String(t)}setGasBudget(t){v(this,S).gasConfig.budget=String(t)}setGasOwner(t){v(this,S).gasConfig.owner=t}setGasPayment(t){v(this,S).gasConfig.payment=t.map(e=>br(e,oe))}get blockData(){return v(this,S).snapshot()}get[Jr](){return!0}get pure(){return Object.defineProperty(this,"pure",{enumerable:!1,value:vs((t,e)=>xt(t)?B(this,_e,Fe).call(this,"pure",{Pure:Array.from(t.toBytes())}):B(this,_e,Fe).call(this,"pure",t instanceof Uint8Array?N.Pure(t):e?N.Pure(t,e):t))}),this.pure}get gas(){return{kind:"GasCoin"}}object(t){if(typeof t=="object"&&"kind"in t)return t;const e=ir(t),r=v(this,S).inputs.find(n=>n.type==="object"&&e===ir(n.value));return r&&U(r.value,mt)&&"Shared"in r.value.Object&&U(t,mt)&&"Shared"in t.Object&&(r.value.Object.Shared.mutable=r.value.Object.Shared.mutable||t.Object.Shared.mutable),r??B(this,_e,Fe).call(this,"object",typeof t=="string"?d.normalizeSuiAddress(t):t)}objectRef(...t){return this.object(N.ObjectRef(...t))}receivingRef(...t){return this.object(N.ReceivingRef(...t))}sharedObjectRef(...t){return this.object(N.SharedObjectRef(...t))}add(t){const e=v(this,S).transactions.push(t);return Ks(e-1)}splitCoins(t,e){return this.add(ue.SplitCoins(typeof t=="string"?this.object(t):t,e.map(r=>typeof r=="number"||typeof r=="bigint"||typeof r=="string"?this.pure.u64(r):B(this,Ae,Ke).call(this,r))))}mergeCoins(t,e){return this.add(ue.MergeCoins(typeof t=="string"?this.object(t):t,e.map(r=>typeof r=="string"?this.object(r):r)))}publish({modules:t,dependencies:e}){return this.add(ue.Publish({modules:t,dependencies:e}))}upgrade({modules:t,dependencies:e,packageId:r,ticket:n}){return this.add(ue.Upgrade({modules:t,dependencies:e,packageId:r,ticket:typeof n=="string"?this.object(n):n}))}moveCall({arguments:t,typeArguments:e,target:r}){return this.add(ue.MoveCall({arguments:t==null?void 0:t.map(n=>B(this,Ae,Ke).call(this,n)),typeArguments:e,target:r}))}transferObjects(t,e){return this.add(ue.TransferObjects(t.map(r=>typeof r=="string"?this.object(r):r),typeof e=="string"?this.pure.address(e):B(this,Ae,Ke).call(this,e)))}makeMoveVec({type:t,objects:e}){return this.add(ue.MakeMoveVec({type:t,objects:e.map(r=>typeof r=="string"?this.object(r):r)}))}serialize(){return JSON.stringify(v(this,S).snapshot())}async sign(t){const{signer:e,...r}=t,n=await this.build(r);return e.signTransactionBlock(n)}async build(t={}){return await B(this,Ge,bt).call(this,t),v(this,S).build({maxSizeBytes:B(this,ce,he).call(this,"maxTxSizeBytes",t),onlyTransactionKind:t.onlyTransactionKind})}async getDigest(t={}){return await B(this,Ge,bt).call(this,t),v(this,S).getDigest()}};let Ys=St;S=new WeakMap;_e=new WeakSet;Fe=function(t,e){const r=v(this,S).inputs.length,n=R({kind:"Input",value:typeof e=="bigint"?String(e):e,index:r,type:t},Pe);return v(this,S).inputs.push(n),n};Ae=new WeakSet;Ke=function(t){return xt(t)?this.pure(t):t};ce=new WeakSet;he=function(t,{protocolConfig:e,limits:r}){if(r&&typeof r[t]=="number")return r[t];if(!e)return Fs[t];const n=e==null?void 0:e.attributes[dt[t]];if(!n)throw new Error(`Missing expected protocol config: "${dt[t]}"`);const s="u64"in n?n.u64:"u32"in n?n.u32:n.f64;if(!s)throw new Error(`Unexpected protocol config value found for: "${dt[t]}"`);return Number(s)};Xt=new WeakSet;Kr=function(t){const e=B(this,ce,he).call(this,"maxPureArgumentSize",t);v(this,S).inputs.forEach((r,n)=>{if(U(r.value,Qe)&&r.value.Pure.length>e)throw new Error(`Input at index ${n} is too large, max pure input size is ${e} bytes, got ${r.value.Pure.length} bytes`)})};Yt=new WeakSet;Gr=async function(t){if(v(this,S).gasConfig.payment){const s=B(this,ce,he).call(this,"maxGasObjects",t);if(v(this,S).gasConfig.payment.length>s)throw new Error(`Payment objects exceed maximum amount: ${s}`)}if(t.onlyTransactionKind||v(this,S).gasConfig.payment)return;const e=v(this,S).gasConfig.owner??v(this,S).sender,n=(await Re(t).getCoins({owner:e,coinType:d.SUI_TYPE_ARG})).data.filter(s=>!v(this,S).inputs.find(a=>U(a.value,et)&&"Object"in a.value&&"ImmOrOwned"in a.value.Object?s.coinObjectId===a.value.Object.ImmOrOwned.objectId:!1)).slice(0,B(this,ce,he).call(this,"maxGasObjects",t)-1).map(s=>({objectId:s.coinObjectId,digest:s.digest,version:s.version}));if(!n.length)throw new Error("No valid gas coins found for the transaction.");this.setGasPayment(n)};Qt=new WeakSet;Hr=async function(t){t.onlyTransactionKind||v(this,S).gasConfig.price||this.setGasPrice(await Re(t).getReferenceGasPrice())};er=new WeakSet;Zr=async function(t){const{inputs:e,transactions:r}=v(this,S),n=[],s=[];if(e.forEach(i=>{if(i.type==="object"&&typeof i.value=="string"){s.push({id:d.normalizeSuiAddress(i.value),input:i});return}}),r.forEach(i=>{if(i.kind==="MoveCall"&&i.arguments.some(o=>o.kind==="Input"&&!U(e[o.index].value,et))&&n.push(i),i.kind==="SplitCoins"&&i.amounts.forEach(a=>{if(a.kind==="Input"){const o=e[a.index];typeof o.value!="object"&&(o.value=N.Pure(A.U64.serialize(o.value)))}}),i.kind==="TransferObjects"&&i.address.kind==="Input"){const a=e[i.address.index];typeof a.value!="object"&&(a.value=N.Pure(A.Address.serialize(a.value)))}}),n.length&&await Promise.all(n.map(async i=>{const[a,o,u]=i.target.split("::"),l=await Re(t).getNormalizedMoveFunction({package:d.normalizeSuiObjectId(a),module:o,function:u}),p=l.parameters.length>0&&Ns(l.parameters.at(-1))?l.parameters.slice(0,l.parameters.length-1):l.parameters;if(p.length!==i.arguments.length)throw new Error("Incorrect number of arguments.");p.forEach((y,m)=>{const x=i.arguments[m];if(x.kind!=="Input")return;const T=e[x.index];if(U(T.value,et))return;const C=T.value,M=wt(y,C);if(M){T.value=N.Pure(C,M);return}if(Zt(y)!=null||typeof y=="object"&&"TypeParameter"in y){if(typeof C!="string")throw new Error(`Expect the argument to be an object id string, got ${JSON.stringify(C,null,2)}`);s.push({id:C,input:T,normalizedType:y});return}throw new Error(`Unknown call arg type ${JSON.stringify(y,null,2)} for value ${JSON.stringify(C,null,2)}`)})})),s.length){const i=[...new Set(s.map(({id:h})=>h))],a=Js(i,Zs),o=(await Promise.all(a.map(h=>Re(t).multiGetObjects({ids:h,options:{showOwner:!0}})))).flat();let u=new Map(i.map((h,p)=>[h,o[p]]));const l=Array.from(u).filter(([h,p])=>p.error).map(([h,p])=>h);if(l.length)throw new Error(`The following input objects are invalid: ${l.join(", ")}`);s.forEach(({id:h,input:p,normalizedType:y})=>{var C;const m=u.get(h),x=(C=m.data)==null?void 0:C.owner,T=x&&typeof x=="object"&&"Shared"in x?x.Shared.initial_shared_version:void 0;if(T){const M=y!=null&&yt(y)==null&&Ur(y)==null,se=Es(p.value)||M||y!=null&&yt(y)!=null;p.value=N.SharedObjectRef({objectId:h,initialSharedVersion:T,mutable:se})}else y&&Gs(y)?p.value=N.ReceivingRef(sr(m)):p.value=N.ObjectRef(sr(m))})}};Ge=new WeakSet;bt=async function(t){if(!t.onlyTransactionKind&&!v(this,S).sender)throw new Error("Missing transaction sender");if(!t.protocolConfig&&!t.limits&&t.client&&(t.protocolConfig=await t.client.getProtocolConfig()),await Promise.all([B(this,Qt,Hr).call(this,t),B(this,er,Zr).call(this,t)]),!t.onlyTransactionKind&&(await B(this,Yt,Gr).call(this,t),!v(this,S).gasConfig.budget)){const e=await Re(t).dryRunTransactionBlock({transactionBlock:v(this,S).build({maxSizeBytes:B(this,ce,he).call(this,"maxTxSizeBytes",t),overrides:{gasConfig:{budget:String(B(this,ce,he).call(this,"maxTxGas",t)),payment:[]}}})});if(e.effects.status.status!=="success")throw new Error(`Dry run failed, could not automatically determine a budget: ${e.effects.status.error}`,{cause:e});const r=Hs*BigInt(this.blockData.gasConfig.price||1n),n=BigInt(e.effects.gasUsed.computationCost)+r,s=n+BigInt(e.effects.gasUsed.storageCost)-BigInt(e.effects.gasUsed.storageRebate);this.setGasBudget(s>n?s:n)}B(this,Xt,Kr).call(this,t)};const Qs=Symbol.for("@mysten/SuiClient");class ei{get[Qs](){return!0}constructor(e){this.transport=e.transport??new Dn({url:e.url})}async getRpcApiVersion(){return(await this.transport.request({method:"rpc.discover",params:[]})).info.version}async getCoins(e){if(!e.owner||!d.isValidSuiAddress(d.normalizeSuiAddress(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getCoins",params:[e.owner,e.coinType,e.cursor,e.limit]})}async getAllCoins(e){if(!e.owner||!d.isValidSuiAddress(d.normalizeSuiAddress(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getAllCoins",params:[e.owner,e.cursor,e.limit]})}async getBalance(e){if(!e.owner||!d.isValidSuiAddress(d.normalizeSuiAddress(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getBalance",params:[e.owner,e.coinType]})}async getAllBalances(e){if(!e.owner||!d.isValidSuiAddress(d.normalizeSuiAddress(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getAllBalances",params:[e.owner]})}async getCoinMetadata(e){return await this.transport.request({method:"suix_getCoinMetadata",params:[e.coinType]})}async getTotalSupply(e){return await this.transport.request({method:"suix_getTotalSupply",params:[e.coinType]})}async call(e,r){return await this.transport.request({method:e,params:r})}async getMoveFunctionArgTypes(e){return await this.transport.request({method:"sui_getMoveFunctionArgTypes",params:[e.package,e.module,e.function]})}async getNormalizedMoveModulesByPackage(e){return await this.transport.request({method:"sui_getNormalizedMoveModulesByPackage",params:[e.package]})}async getNormalizedMoveModule(e){return await this.transport.request({method:"sui_getNormalizedMoveModule",params:[e.package,e.module]})}async getNormalizedMoveFunction(e){return await this.transport.request({method:"sui_getNormalizedMoveFunction",params:[e.package,e.module,e.function]})}async getNormalizedMoveStruct(e){return await this.transport.request({method:"sui_getNormalizedMoveStruct",params:[e.package,e.module,e.struct]})}async getOwnedObjects(e){if(!e.owner||!d.isValidSuiAddress(d.normalizeSuiAddress(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getOwnedObjects",params:[e.owner,{filter:e.filter,options:e.options},e.cursor,e.limit]})}async getObject(e){if(!e.id||!d.isValidSuiObjectId(d.normalizeSuiObjectId(e.id)))throw new Error("Invalid Sui Object id");return await this.transport.request({method:"sui_getObject",params:[e.id,e.options]})}async tryGetPastObject(e){return await this.transport.request({method:"sui_tryGetPastObject",params:[e.id,e.version,e.options]})}async multiGetObjects(e){if(e.ids.forEach(n=>{if(!n||!d.isValidSuiObjectId(d.normalizeSuiObjectId(n)))throw new Error(`Invalid Sui Object id ${n}`)}),e.ids.length!==new Set(e.ids).size)throw new Error(`Duplicate object ids in batch call ${e.ids}`);return await this.transport.request({method:"sui_multiGetObjects",params:[e.ids,e.options]})}async queryTransactionBlocks(e){return await this.transport.request({method:"suix_queryTransactionBlocks",params:[{filter:e.filter,options:e.options},e.cursor,e.limit,(e.order||"descending")==="descending"]})}async getTransactionBlock(e){if(!d.isValidTransactionDigest(e.digest))throw new Error("Invalid Transaction digest");return await this.transport.request({method:"sui_getTransactionBlock",params:[e.digest,e.options]})}async multiGetTransactionBlocks(e){if(e.digests.forEach(n=>{if(!d.isValidTransactionDigest(n))throw new Error(`Invalid Transaction digest ${n}`)}),e.digests.length!==new Set(e.digests).size)throw new Error(`Duplicate digests in batch call ${e.digests}`);return await this.transport.request({method:"sui_multiGetTransactionBlocks",params:[e.digests,e.options]})}async executeTransactionBlock(e){return await this.transport.request({method:"sui_executeTransactionBlock",params:[typeof e.transactionBlock=="string"?e.transactionBlock:$(e.transactionBlock),Array.isArray(e.signature)?e.signature:[e.signature],e.options,e.requestType]})}async signAndExecuteTransactionBlock({transactionBlock:e,signer:r,...n}){let s;e instanceof Uint8Array?s=e:(e.setSenderIfNotSet(r.toSuiAddress()),s=await e.build({client:this}));const{signature:i,bytes:a}=await r.signTransactionBlock(s);return this.executeTransactionBlock({transactionBlock:a,signature:i,...n})}async getTotalTransactionBlocks(){const e=await this.transport.request({method:"sui_getTotalTransactionBlocks",params:[]});return BigInt(e)}async getReferenceGasPrice(){const e=await this.transport.request({method:"suix_getReferenceGasPrice",params:[]});return BigInt(e)}async getStakes(e){if(!e.owner||!d.isValidSuiAddress(d.normalizeSuiAddress(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getStakes",params:[e.owner]})}async getStakesByIds(e){return e.stakedSuiIds.forEach(r=>{if(!r||!d.isValidSuiObjectId(d.normalizeSuiObjectId(r)))throw new Error(`Invalid Sui Stake id ${r}`)}),await this.transport.request({method:"suix_getStakesByIds",params:[e.stakedSuiIds]})}async getLatestSuiSystemState(){return await this.transport.request({method:"suix_getLatestSuiSystemState",params:[]})}async queryEvents(e){return await this.transport.request({method:"suix_queryEvents",params:[e.query,e.cursor,e.limit,(e.order||"descending")==="descending"]})}async subscribeEvent(e){return this.transport.subscribe({method:"suix_subscribeEvent",unsubscribe:"suix_unsubscribeEvent",params:[e.filter],onMessage:e.onMessage})}async subscribeTransaction(e){return this.transport.subscribe({method:"suix_subscribeTransaction",unsubscribe:"suix_unsubscribeTransaction",params:[e.filter],onMessage:e.onMessage})}async devInspectTransactionBlock(e){var n;let r;if(Xs(e.transactionBlock))e.transactionBlock.setSenderIfNotSet(e.sender),r=$(await e.transactionBlock.build({client:this,onlyTransactionKind:!0}));else if(typeof e.transactionBlock=="string")r=e.transactionBlock;else if(e.transactionBlock instanceof Uint8Array)r=$(e.transactionBlock);else throw new Error("Unknown transaction block format.");return await this.transport.request({method:"sui_devInspectTransactionBlock",params:[e.sender,r,(n=e.gasPrice)==null?void 0:n.toString(),e.epoch]})}async dryRunTransactionBlock(e){return await this.transport.request({method:"sui_dryRunTransactionBlock",params:[typeof e.transactionBlock=="string"?e.transactionBlock:$(e.transactionBlock)]})}async getDynamicFields(e){if(!e.parentId||!d.isValidSuiObjectId(d.normalizeSuiObjectId(e.parentId)))throw new Error("Invalid Sui Object id");return await this.transport.request({method:"suix_getDynamicFields",params:[e.parentId,e.cursor,e.limit]})}async getDynamicFieldObject(e){return await this.transport.request({method:"suix_getDynamicFieldObject",params:[e.parentId,e.name]})}async getLatestCheckpointSequenceNumber(){const e=await this.transport.request({method:"sui_getLatestCheckpointSequenceNumber",params:[]});return String(e)}async getCheckpoint(e){return await this.transport.request({method:"sui_getCheckpoint",params:[e.id]})}async getCheckpoints(e){return await this.transport.request({method:"sui_getCheckpoints",params:[e.cursor,e==null?void 0:e.limit,e.descendingOrder]})}async getCommitteeInfo(e){return await this.transport.request({method:"suix_getCommitteeInfo",params:[e==null?void 0:e.epoch]})}async getNetworkMetrics(){return await this.transport.request({method:"suix_getNetworkMetrics",params:[]})}async getAddressMetrics(){return await this.transport.request({method:"suix_getLatestAddressMetrics",params:[]})}async getEpochMetrics(e){return await this.transport.request({method:"suix_getEpochMetrics",params:[e==null?void 0:e.cursor,e==null?void 0:e.limit,e==null?void 0:e.descendingOrder]})}async getAllEpochAddressMetrics(e){return await this.transport.request({method:"suix_getAllEpochAddressMetrics",params:[e==null?void 0:e.descendingOrder]})}async getEpochs(e){return await this.transport.request({method:"suix_getEpochs",params:[e==null?void 0:e.cursor,e==null?void 0:e.limit,e==null?void 0:e.descendingOrder]})}async getMoveCallMetrics(){return await this.transport.request({method:"suix_getMoveCallMetrics",params:[]})}async getCurrentEpoch(){return await this.transport.request({method:"suix_getCurrentEpoch",params:[]})}async getValidatorsApy(){return await this.transport.request({method:"suix_getValidatorsApy",params:[]})}async getChainIdentifier(){const e=await this.getCheckpoint({id:"0"}),r=d.fromB58(e.digest);return ge(r.slice(0,4))}async resolveNameServiceAddress(e){return await this.transport.request({method:"suix_resolveNameServiceAddress",params:[e.name]})}async resolveNameServiceNames(e){return await this.transport.request({method:"suix_resolveNameServiceNames",params:[e.address,e.cursor,e.limit]})}async getProtocolConfig(e){return await this.transport.request({method:"sui_getProtocolConfig",params:[e==null?void 0:e.version]})}async waitForTransactionBlock({signal:e,timeout:r=60*1e3,pollInterval:n=2*1e3,...s}){const i=AbortSignal.timeout(r),a=new Promise((o,u)=>{i.addEventListener("abort",()=>u(i.reason))});for(a.catch(()=>{});!i.aborted;){e==null||e.throwIfAborted();try{return await this.getTransactionBlock(s)}catch{await Promise.race([new Promise(u=>setTimeout(u,n)),a])}}throw i.throwIfAborted(),new Error("Unexpected error while waiting for transaction block.")}}class Xr extends d.ChainContext{}const Tt="Sui",tr=t=>{var r;const e=(r=t.data)==null?void 0:r.content;return e&&e.dataType==="moveObject"?e.fields:null},ti=(t,e)=>{try{return d.normalizeSuiType(t)===d.normalizeSuiType(e)}catch{return!1}},ri=t=>(t==null?void 0:t.type)==="created",ni=t=>(t==null?void 0:t.type)==="published";function si(t){return Array.isArray(t)}function rt(t){return!Array.isArray(t)&&typeof t=="object"&&"fields"in t&&"type"in t}function Yr(t){return typeof t=="object"&&!si(t)&&!rt(t)}function ii(t){return typeof t=="object"&&"id"in t}const ai=16*1024,oi=t=>A.ser("vector<u8>",t,{maxSize:ai}).toBytes(),ci=async(t,e)=>{const{data:r,error:n}=await t.getObject({id:e,options:{showContent:!0}});if(n)throw new Error("Error getting object: "+n);if(!r||!rt(r.content))throw new Error(`Cannot get oject for state id ${e}: `+r);return d.getPackageIdFromType(r.content.type)},Qr=async(t,e)=>{if(!d.isValidSuiAddress(e))throw new Error(`Invalid object ID: ${e}`);const r=await t.getObject({id:e,options:{showContent:!0}});return tr(r)},ui=async(t,e)=>{let r,n;do{const a=await t.getDynamicFields({parentId:e,cursor:n});r=a.data.find(o=>o.name.type.endsWith("CurrentPackage")),n=a.hasNextPage?a.nextCursor:null}while(n&&!r);if(!r)throw new Error("CurrentPackage not found");const s=await t.getObject({id:r.objectId,options:{showContent:!0}}),i=tr(s);if(!i||!Yr(i))throw new Error("Unable to get fields from object response");if(!("value"in i)||!rt(i.value))throw new Error("Unable to get package id");return i.value.fields.package},di=async(t,e,r)=>{let n=null,s=null,i=null,a;do{if(i=await t.getOwnedObjects({owner:r,filter:{StructType:`${e}::emitter::EmitterCap`},options:{showContent:!0},cursor:a}),!i||!i.data)throw Error("Failed to get owned objects");for(const o of i.data){if(!o.data)continue;const{version:u,objectId:l}=o.data;(n===null||u<n)&&(n=u,s=l)}a=i.hasNextPage?i.nextCursor:void 0}while(a);return s},li=async(t,e)=>{const r=new Ys,[n]=r.publish({modules:t.modules.map(s=>Array.from(d.b64.decode(s))),dependencies:t.dependencies.map(s=>d.normalizeSuiObjectId(s))});return r.transferObjects([n],r.pure(e)),r},Q=class Q extends d.PlatformContext{constructor(e,r){super(e,r??d.networkPlatformConfigs(e,Q._platform))}getRpc(e){if(e in this.config)return new ei({url:this.config[e].rpc});throw new Error("No configuration available for chain: "+e)}getChain(e){if(e in this.config)return new Xr(e,this);throw new Error("No configuration available for chain: "+e)}static nativeTokenId(e,r){if(!Q.isSupportedChain(r))throw new Error(`invalid chain for ${Tt}: ${r}`);return d.Wormhole.tokenId(r,d.SUI_COIN)}static isNativeTokenId(e,r,n){return!Q.isSupportedChain(r)||n.chain!==r?!1:this.nativeTokenId(e,r)===n}static isSupportedChain(e){return d.chainToPlatform(e)===Q._platform}static async getDecimals(e,r,n){if(d.isNative(n))return d.nativeDecimals(Q._platform);const s=new d.SuiAddress(n);try{const a=await Qr(r,s.toString());if(a&&"decimals"in a)return a.decimals}catch{}const i=await r.getCoinMetadata({coinType:s.getCoinType()});if(i===null)throw new Error(`Can't fetch decimals for token ${s.toString()}`);return i.decimals}static async getCoins(e,r,n){let s=[],i=null;const a=new d.SuiAddress(r).toString();do{const o=await e.getCoins({owner:a,coinType:n,cursor:i});s=[...s,...o.data],i=o.hasNextPage?o.nextCursor:null}while(i);return s}static async getBalance(e,r,n,s){if(d.isNative(s)){const{totalBalance:a}=await r.getBalance({owner:n});return BigInt(a)}const{totalBalance:i}=await r.getBalance({owner:n,coinType:s.toString()});return BigInt(i)}static async getBalances(e,r,n,s){return(await Promise.all(s.map(async a=>{const o=await this.getBalance(e,r,n,a);return{[d.isNative(a)?"native":new d.SuiAddress(a).toString()]:o}}))).reduce((a,o)=>Object.assign(a,o),{})}static async sendWait(e,r,n){const s=[];for(const i of n){const a=await r.executeTransactionBlock(i);await r.waitForTransactionBlock({digest:a.digest}),s.push(a.digest)}return s}static async getLatestBlock(e){return Number(await e.getLatestCheckpointSequenceNumber())}static async getLatestFinalizedBlock(e){return this.getLatestBlock(e)}static chainFromChainId(e){const r=d.platformNativeChainIdToNetworkChain(Q._platform,e);if(r===void 0)throw new Error(`Unknown native chain id ${e}`);const[n,s]=r;return[n,s]}static async chainFromRpc(e){const r=await e.call("sui_getChainIdentifier",[]);return this.chainFromChainId(r)}};pe(Q,"_platform",Tt);let Ee=Q;var Ne={};Object.defineProperty(Ne,"__esModule",{value:!0});Ne.bech32m=Et=Ne.bech32=void 0;const tt="qpzry9x8gf2tvdw0s3jn54khce6mua7l",en={};for(let t=0;t<tt.length;t++){const e=tt.charAt(t);en[e]=t}function Te(t){const e=t>>25;return(t&33554431)<<5^-(e>>0&1)&996825010^-(e>>1&1)&642813549^-(e>>2&1)&513874426^-(e>>3&1)&1027748829^-(e>>4&1)&705979059}function cr(t){let e=1;for(let r=0;r<t.length;++r){const n=t.charCodeAt(r);if(n<33||n>126)return"Invalid prefix ("+t+")";e=Te(e)^n>>5}e=Te(e);for(let r=0;r<t.length;++r){const n=t.charCodeAt(r);e=Te(e)^n&31}return e}function rr(t,e,r,n){let s=0,i=0;const a=(1<<r)-1,o=[];for(let u=0;u<t.length;++u)for(s=s<<e|t[u],i+=e;i>=r;)i-=r,o.push(s>>i&a);if(n)i>0&&o.push(s<<r-i&a);else{if(i>=e)return"Excess padding";if(s<<r-i&a)return"Non-zero padding"}return o}function fi(t){return rr(t,8,5,!0)}function hi(t){const e=rr(t,5,8,!1);if(Array.isArray(e))return e}function gi(t){const e=rr(t,5,8,!1);if(Array.isArray(e))return e;throw new Error(e)}function tn(t){let e;t==="bech32"?e=1:e=734539939;function r(a,o,u){if(u=u||90,a.length+7+o.length>u)throw new TypeError("Exceeds length limit");a=a.toLowerCase();let l=cr(a);if(typeof l=="string")throw new Error(l);let h=a+"1";for(let p=0;p<o.length;++p){const y=o[p];if(y>>5)throw new Error("Non 5-bit word");l=Te(l)^y,h+=tt.charAt(y)}for(let p=0;p<6;++p)l=Te(l);l^=e;for(let p=0;p<6;++p){const y=l>>(5-p)*5&31;h+=tt.charAt(y)}return h}function n(a,o){if(o=o||90,a.length<8)return a+" too short";if(a.length>o)return"Exceeds length limit";const u=a.toLowerCase(),l=a.toUpperCase();if(a!==u&&a!==l)return"Mixed-case string "+a;a=u;const h=a.lastIndexOf("1");if(h===-1)return"No separator character for "+a;if(h===0)return"Missing prefix for "+a;const p=a.slice(0,h),y=a.slice(h+1);if(y.length<6)return"Data too short";let m=cr(p);if(typeof m=="string")return m;const x=[];for(let T=0;T<y.length;++T){const C=y.charAt(T),M=en[C];if(M===void 0)return"Unknown character "+C;m=Te(m)^M,!(T+6>=y.length)&&x.push(M)}return m!==e?"Invalid checksum for "+a:{prefix:p,words:x}}function s(a,o){const u=n(a,o);if(typeof u=="object")return u}function i(a,o){const u=n(a,o);if(typeof u=="object")return u;throw new Error(u)}return{decodeUnsafe:s,decode:i,encode:r,toWords:fi,fromWordsUnsafe:hi,fromWords:gi}}var Et=Ne.bech32=tn("bech32");Ne.bech32m=tn("bech32m");var $e=(t=>(t[t.TransactionData=0]="TransactionData",t[t.TransactionEffects=1]="TransactionEffects",t[t.CheckpointSummary=2]="CheckpointSummary",t[t.PersonalMessage=3]="PersonalMessage",t))($e||{});function pi(t){return[t,0,0]}function rn(t,e){const r=pi(t),n=new Uint8Array(r.length+e.length);return n.set(r),n.set(e,r.length),n}const nt={ED25519:0,Secp256k1:1,Secp256r1:2,MultiSig:3,ZkLogin:5},yi={ED25519:32,Secp256k1:33,Secp256r1:33},mi={0:"ED25519",1:"Secp256k1",2:"Secp256r1",3:"MultiSig",5:"ZkLogin"};function wi(t){for(let e=0;e<t.length;e++)if(t[e]!==0)return e;return-1}function bi(t,e){const r=t.toString(16);return d.hexToBytes(r.padStart(e*2,"0").slice(-e*2))}function Si(t,e){const r=bi(t,e),n=wi(r);return n===-1?new Uint8Array([0]):r.slice(n)}function Ti(t,e){const r=Si(t,32);e==="accounts.google.com"&&(e="https://accounts.google.com");const n=new TextEncoder().encode(e),s=new Uint8Array(2+r.length+n.length);return s.set([nt.ZkLogin]),s.set([n.length],1),s.set(n,2),s.set(r,2+n.length),d.normalizeSuiAddress(d.bytesToHex(d.blake2b(s,{dkLen:32})).slice(0,d.SUI_ADDRESS_LENGTH*2))}function Ei(t){if(t.length!==1)throw new Error("Invalid base64Url character: "+t);const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".indexOf(t);if(r===-1)throw new Error("Invalid base64Url character: "+t);const n=r.toString(2).padStart(6,"0");return Array.from(n).map(Number)}function vi(t){let e=[];for(let r=0;r<t.length;r++){const n=t.charAt(r),s=Ei(n);e=e.concat(s)}return e}function ki(t,e){if(t.length<2)throw new Error(`Input (s = ${t}) is not tightly packed because s.length < 2`);let r=vi(t);const n=e%4;if(n!==0)if(n===1)r=r.slice(2);else if(n===2)r=r.slice(4);else throw new Error(`Input (s = ${t}) is not tightly packed because i%4 = 3 (i = ${e}))`);const s=(e+t.length-1)%4;if(s!==3)if(s===2)r=r.slice(0,r.length-2);else if(s===1)r=r.slice(0,r.length-4);else throw new Error(`Input (s = ${t}) is not tightly packed because (i + s.length - 1)%4 = 0 (i = ${e}))`);if(r.length%8!==0)throw new Error("We should never reach here...");const i=new Uint8Array(Math.floor(r.length/8));let a=0;for(let o=0;o<r.length;o+=8){const u=r.slice(o,o+8),l=parseInt(u.join(""),2);i[a++]=l}return new TextDecoder().decode(i)}function xi(t){if(!(t.slice(-1)==="}"||t.slice(-1)===","))throw new Error("Invalid claim");const e=JSON.parse("{"+t.slice(0,-1)+"}");if(Object.keys(e).length!==1)throw new Error("Invalid claim");const r=Object.keys(e)[0];return[r,e[r]]}function Ii(t,e){const r=ki(t.value,t.indexMod4),[n,s]=xi(r);if(n!==e)throw new Error(`Invalid field name: found ${n} expected ${e}`);return s}const _i=c.struct("ZkLoginSignature",{inputs:c.struct("ZkLoginSignatureInputs",{proofPoints:c.struct("ZkLoginSignatureInputsProofPoints",{a:c.vector(c.string()),b:c.vector(c.vector(c.string())),c:c.vector(c.string())}),issBase64Details:c.struct("ZkLoginSignatureInputsClaim",{value:c.string(),indexMod4:c.u8()}),headerBase64:c.string(),addressSeed:c.string()}),maxEpoch:c.u64(),userSignature:c.vector(c.u8())});function Ai(t){return _i.parse(typeof t=="string"?H(t):t)}function Oi({signature:t,signatureScheme:e,publicKey:r}){if(!r)throw new Error("`publicKey` is required");const n=r.toRawBytes(),s=new Uint8Array(1+t.length+n.length);return s.set([nt[e]]),s.set(t,1),s.set(n,1+t.length),$(s)}function ji(t){const e=H(t),r=mi[e[0]];switch(r){case"MultiSig":const n=A.MultiSig.parse(e.slice(1));return{serializedSignature:t,signatureScheme:r,multisig:n,bytes:e};case"ZkLogin":const s=e.slice(1),{inputs:i,maxEpoch:a,userSignature:o}=Ai(s),{issBase64Details:u,addressSeed:l}=i,h=Ii(u,"iss"),p=Ti(BigInt(l),h);return{serializedSignature:t,signatureScheme:r,zkLogin:{inputs:i,maxEpoch:a,userSignature:o,iss:h,address:p,addressSeed:BigInt(l)},signature:e};case"ED25519":case"Secp256k1":case"Secp256r1":const y=yi[r],m=e.slice(1,e.length-y),x=e.slice(1+m.length);return{serializedSignature:t,signatureScheme:r,signature:m,publicKey:x,bytes:e};default:throw new Error("Unsupported signature scheme")}}const He=32,Ci="suiprivkey";class Bi{async signWithIntent(e,r){const n=rn(r,e),s=d.blake2b(n,{dkLen:32});return{signature:Oi({signature:await this.sign(s),signatureScheme:this.getKeyScheme(),publicKey:this.getPublicKey()}),bytes:$(e)}}async signTransactionBlock(e){return this.signWithIntent(e,$e.TransactionData)}async signPersonalMessage(e){return this.signWithIntent(c.vector(c.u8()).serialize(e).toBytes(),$e.PersonalMessage)}toSuiAddress(){return this.getPublicKey().toSuiAddress()}}class Mi extends Bi{export(){return{schema:this.getKeyScheme(),privateKey:this.getSecretKey()}}}function Pi(t,e){if(t.length!==He)throw new Error("Invalid bytes length");const r=nt[e],n=new Uint8Array(t.length+1);return n.set([r]),n.set(t,1),Et.encode(Ci,Et.toWords(n))}function ur(t){return!!new RegExp("^m\\/44'\\/784'\\/[0-9]+'\\/[0-9]+'\\/[0-9]+'+$").test(t)}function Ri(t){return An(t,"")}function Ni(t){return ge(Ri(t))}const $i="ed25519 seed",Ui=2147483648,Di=new RegExp("^m(\\/[0-9]+')+$"),nn=t=>t.replace("'",""),zi=t=>{const r=d.hmac.create(d.sha512,$i).update(Ue(t)).digest(),n=r.slice(0,32),s=r.slice(32);return{key:n,chainCode:s}},Vi=({key:t,chainCode:e},r)=>{const n=new ArrayBuffer(4);new DataView(n).setUint32(0,r);const i=new Uint8Array(1+t.length+n.byteLength);i.set(new Uint8Array(1).fill(0)),i.set(t,1),i.set(new Uint8Array(n,0,n.byteLength),t.length+1);const a=d.hmac.create(d.sha512,e).update(i).digest(),o=a.slice(0,32),u=a.slice(32);return{key:o,chainCode:u}},Li=t=>Di.test(t)?!t.split("/").slice(1).map(nn).some(isNaN):!1,dr=(t,e,r=Ui)=>{if(!Li(t))throw new Error("Invalid derivation path");const{key:n,chainCode:s}=zi(e);return t.split("/").slice(1).map(nn).map(a=>parseInt(a,10)).reduce((a,o)=>Vi(a,o+r),{key:n,chainCode:s})};function sn(t,e){if(t===e)return!0;if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[r])return!1;return!0}class qi{equals(e){return sn(this.toRawBytes(),e.toRawBytes())}toBase64(){return $(this.toRawBytes())}toString(){throw new Error("`toString` is not implemented on public keys. Use `toBase64()` or `toRawBytes()` instead.")}toSuiPublicKey(){const e=this.toSuiBytes();return $(e)}verifyWithIntent(e,r,n){const s=rn(n,e),i=d.blake2b(s,{dkLen:32});return this.verify(i,r)}verifyPersonalMessage(e,r){return this.verifyWithIntent(A.vector(A.u8()).serialize(e).toBytes(),r,$e.PersonalMessage)}verifyTransactionBlock(e,r){return this.verifyWithIntent(e,r,$e.TransactionData)}toSuiBytes(){const e=this.toRawBytes(),r=new Uint8Array(e.length+1);return r.set([this.flag()]),r.set(e,1),r}toSuiAddress(){return d.normalizeSuiAddress(d.bytesToHex(d.blake2b(this.toSuiBytes(),{dkLen:32})).slice(0,d.SUI_ADDRESS_LENGTH*2))}}const vt=32;class an extends qi{constructor(e){if(super(),typeof e=="string"?this.data=H(e):e instanceof Uint8Array?this.data=e:this.data=Uint8Array.from(e),this.data.length!==vt)throw new Error(`Invalid public key input. Expected ${vt} bytes, got ${this.data.length}`)}equals(e){return super.equals(e)}toRawBytes(){return this.data}flag(){return nt.ED25519}async verify(e,r){let n;if(typeof r=="string"){const s=ji(r);if(s.signatureScheme!=="ED25519")throw new Error("Invalid signature scheme");if(!sn(this.toRawBytes(),s.publicKey))throw new Error("Signature does not match public key");n=s.signature}else n=r;return d.nacl2.sign.detached.verify(e,n,this.toRawBytes())}}an.SIZE=vt;const lr="m/44'/784'/0'/0'/0'";class me extends Mi{constructor(e){super(),e?this.keypair=e:this.keypair=d.nacl2.sign.keyPair()}getKeyScheme(){return"ED25519"}static generate(){return new me(d.nacl2.sign.keyPair())}static fromSecretKey(e,r){const n=e.length;if(n!==He)throw new Error(`Wrong secretKey size. Expected ${He} bytes, got ${n}.`);const s=d.nacl2.sign.keyPair.fromSeed(e);if(!r||!r.skipValidation){const a=new TextEncoder().encode("sui validation"),o=d.nacl2.sign.detached(a,s.secretKey);if(!d.nacl2.sign.detached.verify(a,o,s.publicKey))throw new Error("provided secretKey is invalid")}return new me(s)}getPublicKey(){return new an(this.keypair.publicKey)}getSecretKey(){return Pi(this.keypair.secretKey.slice(0,He),this.getKeyScheme())}async sign(e){return this.signData(e)}signData(e){return d.nacl2.sign.detached(e,this.keypair.secretKey)}static deriveKeypair(e,r){if(r==null&&(r=lr),!ur(r))throw new Error("Invalid derivation path");const{key:n}=dr(r,Ni(e));return me.fromSecretKey(n)}static deriveKeypairFromSeed(e,r){if(r==null&&(r=lr),!ur(r))throw new Error("Invalid derivation path");const{key:n}=dr(r,e);return me.fromSecretKey(n)}}async function Wi(t,e){const[,r]=await Ee.chainFromRpc(t);return new Fi(r,t,me.deriveKeypair(e,"m/44'/784'/0'/0'/0'"))}class Fi{constructor(e,r,n,s){pe(this,"_chain");pe(this,"_client");pe(this,"_signer");pe(this,"_debug");this._chain=e,this._client=r,this._signer=n,this._debug=s}chain(){return this._chain}address(){return this._signer.toSuiAddress()}async signAndSend(e){const r=[];for(const n of e){const{description:s,transaction:i}=n;this._debug&&console.log(`Signing ${s} for ${this.address()}`);try{const a=await this._client.signAndExecuteTransactionBlock({transactionBlock:i,signer:this._signer});r.push(a.digest)}catch(a){throw a}}return r}}const Ki={Address:d.SuiAddress,Platform:Ee,getSigner:Wi,protocols:{WormholeCore:()=>Promise.resolve().then(()=>require("./index-Cf-xLfst.js")),TokenBridge:()=>Promise.resolve().then(()=>require("./index-CLiemfL3.js"))},getChain:(t,e,r)=>new Xr(e,new Ee(t,d.applyChainsConfigConfigOverrides(t,Tt,{[e]:r})))},Gi=Object.freeze(Object.defineProperty({__proto__:null,default:Ki},Symbol.toStringTag,{value:"Module"}));exports.SuiPlatform=Ee;exports.getFieldsFromObjectResponse=tr;exports.getObjectFields=Qr;exports.getOldestEmitterCapObjectId=di;exports.getOriginalPackageId=ci;exports.getPackageId=ui;exports.isMoveStructId=ii;exports.isMoveStructObject=Yr;exports.isMoveStructStruct=rt;exports.isSameType=ti;exports.isSuiCreateEvent=ri;exports.isSuiPublishEvent=ni;exports.publishPackage=li;exports.sui=Gi;exports.uint8ArrayToBCS=oi;
5
+ Received: "${JSON.stringify(u)}"`);let p=Object.keys(u)[0];if(p===void 0)throw new Error(`Empty object passed as invariant of the enum "${s}"`);let y=n.indexOf(p);if(y===-1)throw new Error(`Unknown invariant of the enum "${s}", allowed values: "${n.join(" | ")}"; received "${p}"`);let m=n[y],x=r[m];if(o.write8(y),x===null)return o;let T=i.indexOf(x),C=T===-1?x:l[T];{let{name:M,params:se}=this.parseTypeName(C);return this.getTypeInterface(M)._encodeRaw.call(this,o,u[p],se,h)}},function(o,u,l){let h=o.readULEB(),p=n[h],y=r[p];if(h===-1)throw new Error(`Decoding type mismatch, expected enum "${s}" invariant index, received "${h}"`);if(y===null)return{[p]:!0};let m=i.indexOf(y),x=m===-1?y:u[m];{let{name:T,params:C}=this.parseTypeName(x);return{[p]:this.getTypeInterface(T)._decodeRaw.call(this,o,C,l)}}})}getTypeInterface(t){let e=this.types.get(t);if(typeof e=="string"){let r=[];for(;typeof e=="string";){if(r.includes(e))throw new Error(`Recursive definition found: ${r.join(" -> ")} -> ${e}`);r.push(e),e=this.types.get(e)}}if(e===void 0)throw new Error(`Type ${t} is not registered`);return e}parseTypeName(t){if(Array.isArray(t)){let[o,...u]=t;return{name:o,params:u}}if(typeof t!="string")throw new Error(`Illegal type passed as a name of the type: ${t}`);let[e,r]=this.schema.genericSeparators||["<",">"],n=t.indexOf(e),s=Array.from(t).reverse().indexOf(r);if(n===-1&&s===-1)return{name:t,params:[]};if(n===-1||s===-1)throw new Error(`Unclosed generic in name '${t}'`);let i=t.slice(0,n),a=hr(t.slice(n+1,t.length-s-1),this.schema.genericSeparators);return{name:i,params:a}}};let I=xe;I.U8="u8";I.U16="u16";I.U32="u32";I.U64="u64";I.U128="u128";I.U256="u256";I.BOOL="bool";I.VECTOR="vector";I.ADDRESS="address";I.STRING="string";I.HEX="hex-string";I.BASE58="base58-string";I.BASE64="base64-string";function wn(t){t.registerType(I.U8,function(e,r){return e.write8(r)},function(e){return e.read8()},e=>e<256),t.registerType(I.U16,function(e,r){return e.write16(r)},function(e){return e.read16()},e=>e<65536),t.registerType(I.U32,function(e,r){return e.write32(r)},function(e){return e.read32()},e=>e<=4294967296n),t.registerType(I.U64,function(e,r){return e.write64(r)},function(e){return e.read64()}),t.registerType(I.U128,function(e,r){return e.write128(r)},function(e){return e.read128()}),t.registerType(I.U256,function(e,r){return e.write256(r)},function(e){return e.read256()}),t.registerType(I.BOOL,function(e,r){return e.write8(r)},function(e){return e.read8().toString(10)==="1"}),t.registerType(I.STRING,function(e,r){return e.writeVec(Array.from(r),(n,s)=>n.write8(s.charCodeAt(0)))},function(e){return e.readVec(r=>r.read8()).map(r=>String.fromCharCode(Number(r))).join("")},e=>!0),t.registerType(I.HEX,function(e,r){return e.writeVec(Array.from(Ue(r)),(n,s)=>n.write8(s))},function(e){let r=e.readVec(n=>n.read8());return ge(new Uint8Array(r))}),t.registerType(I.BASE58,function(e,r){return e.writeVec(Array.from(d.fromB58(r)),(n,s)=>n.write8(s))},function(e){let r=e.readVec(n=>n.read8());return d.toB58(new Uint8Array(r))}),t.registerType(I.BASE64,function(e,r){return e.writeVec(Array.from(H(r)),(n,s)=>n.write8(s))},function(e){let r=e.readVec(n=>n.read8());return $(new Uint8Array(r))})}function bn(){return{genericSeparators:["<",">"],vectorType:"vector",addressLength:mn,addressEncoding:"hex"}}class Sn extends TypeError{constructor(e,r){let n;const{message:s,explanation:i,...a}=e,{path:o}=e,u=o.length===0?s:`At path: ${o.join(".")} -- ${s}`;super(i??u),i!=null&&(this.cause=u),Object.assign(this,a),this.name=this.constructor.name,this.failures=()=>n??(n=[e,...r()])}}function Tn(t){return V(t)&&typeof t[Symbol.iterator]=="function"}function V(t){return typeof t=="object"&&t!=null}function L(t){return typeof t=="symbol"?t.toString():typeof t=="string"?JSON.stringify(t):`${t}`}function En(t){const{done:e,value:r}=t.next();return e?void 0:r}function vn(t,e,r,n){if(t===!0)return;t===!1?t={}:typeof t=="string"&&(t={message:t});const{path:s,branch:i}=e,{type:a}=r,{refinement:o,message:u=`Expected a value of type \`${a}\`${o?` with refinement \`${o}\``:""}, but received: \`${L(n)}\``}=t;return{value:n,type:a,refinement:o,key:s[s.length-1],path:s,branch:i,...t,message:u}}function*nr(t,e,r,n){Tn(t)||(t=[t]);for(const s of t){const i=vn(s,e,r,n);i&&(yield i)}}function*It(t,e,r={}){const{path:n=[],branch:s=[t],coerce:i=!1,mask:a=!1}=r,o={path:n,branch:s};if(i&&(t=e.coercer(t,o),a&&e.type!=="type"&&V(e.schema)&&V(t)&&!Array.isArray(t)))for(const l in t)e.schema[l]===void 0&&delete t[l];let u="valid";for(const l of e.validator(t,o))l.explanation=r.message,u="not_valid",yield[l,void 0];for(let[l,h,p]of e.entries(t,o)){const y=It(h,p,{path:l===void 0?n:[...n,l],branch:l===void 0?s:[...s,h],coerce:i,mask:a,message:r.message});for(const m of y)m[0]?(u=m[0].refinement!=null?"not_refined":"not_valid",yield[m[0],void 0]):i&&(h=m[1],l===void 0?t=h:t instanceof Map?t.set(l,h):t instanceof Set?t.add(h):V(t)&&(h!==void 0||l in t)&&(t[l]=h))}if(u!=="not_valid")for(const l of e.refiner(t,o))l.explanation=r.message,u="not_refined",yield[l,void 0];u==="valid"&&(yield[void 0,t])}class X{constructor(e){const{type:r,schema:n,validator:s,refiner:i,coercer:a=u=>u,entries:o=function*(){}}=e;this.type=r,this.schema=n,this.entries=o,this.coercer=a,s?this.validator=(u,l)=>{const h=s(u,l);return nr(h,l,this,u)}:this.validator=()=>[],i?this.refiner=(u,l)=>{const h=i(u,l);return nr(h,l,this,u)}:this.refiner=()=>[]}assert(e,r){return lt(e,this,r)}create(e,r){return wr(e,this,r)}is(e){return U(e,this)}mask(e,r){return br(e,this,r)}validate(e,r={}){return De(e,this,r)}}function lt(t,e,r){const n=De(t,e,{message:r});if(n[0])throw n[0]}function wr(t,e,r){const n=De(t,e,{coerce:!0,message:r});if(n[0])throw n[0];return n[1]}function br(t,e,r){const n=De(t,e,{coerce:!0,mask:!0,message:r});if(n[0])throw n[0];return n[1]}function U(t,e){return!De(t,e)[0]}function De(t,e,r={}){const n=It(t,e,r),s=En(n);return s[0]?[new Sn(s[0],function*(){for(const a of n)a[0]&&(yield a[0])}),void 0]:[void 0,s[1]]}function Ce(...t){const e=t[0].type==="type",r=t.map(s=>s.schema),n=Object.assign({},...r);return e?xn(n):g(n)}function D(t,e){return new X({type:t,schema:null,validator:e})}function ft(){return D("any",()=>!0)}function E(t){return new X({type:"array",schema:t,*entries(e){if(t&&Array.isArray(e))for(const[r,n]of e.entries())yield[r,n,t]},coercer(e){return Array.isArray(e)?e.slice():e},validator(e){return Array.isArray(e)||`Expected an array value, but received: ${L(e)}`}})}function kn(){return D("bigint",t=>typeof t=="bigint")}function P(){return D("boolean",t=>typeof t=="boolean")}function J(){return D("integer",t=>typeof t=="number"&&!isNaN(t)&&Number.isInteger(t)||`Expected an integer, but received: ${L(t)}`)}function b(t){const e=L(t),r=typeof t;return new X({type:"literal",schema:r==="string"||r==="number"||r==="boolean"?t:null,validator(n){return n===t||`Expected the literal \`${e}\`, but received: ${L(n)}`}})}function Sr(){return D("never",()=>!1)}function O(t){return new X({...t,validator:(e,r)=>e===null||t.validator(e,r),refiner:(e,r)=>e===null||t.refiner(e,r)})}function fe(){return D("number",t=>typeof t=="number"&&!isNaN(t)||`Expected a number, but received: ${L(t)}`)}function g(t){const e=t?Object.keys(t):[],r=Sr();return new X({type:"object",schema:t||null,*entries(n){if(t&&V(n)){const s=new Set(Object.keys(n));for(const i of e)s.delete(i),yield[i,n[i],t[i]];for(const i of s)yield[i,n[i],r]}},validator(n){return V(n)||`Expected an object, but received: ${L(n)}`},coercer(n){return V(n)?{...n}:n}})}function w(t){return new X({...t,validator:(e,r)=>e===void 0||t.validator(e,r),refiner:(e,r)=>e===void 0||t.refiner(e,r)})}function Z(t,e){return new X({type:"record",schema:null,*entries(r){if(V(r))for(const n in r){const s=r[n];yield[n,n,t],yield[n,s,e]}},validator(r){return V(r)||`Expected an object, but received: ${L(r)}`}})}function f(){return D("string",t=>typeof t=="string"||`Expected a string, but received: ${L(t)}`)}function Tr(t){const e=Sr();return new X({type:"tuple",schema:null,*entries(r){if(Array.isArray(r)){const n=Math.max(t.length,r.length);for(let s=0;s<n;s++)yield[s,r[s],t[s]||e]}},validator(r){return Array.isArray(r)||`Expected an array, but received: ${L(r)}`}})}function xn(t){const e=Object.keys(t);return new X({type:"type",schema:t,*entries(r){if(V(r))for(const n of e)yield[n,r[n],t[n]]},validator(r){return V(r)||`Expected an object, but received: ${L(r)}`},coercer(r){return V(r)?{...r}:r}})}function j(t){const e=t.map(r=>r.type).join(" | ");return new X({type:"union",schema:null,coercer(r){for(const n of t){const[s,i]=n.validate(r,{coerce:!0});if(!s)return i}return r},validator(r,n){const s=[];for(const i of t){const[...a]=It(r,i,n),[o]=a;if(o[0])for(const[u]of a)u&&s.push(u);else return[]}return[`Expected the value to satisfy a union of \`${e}\`, but received: ${L(r)}`,...s]}})}function Er(){return D("unknown",()=>!0)}/*! scure-bip39 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) */function vr(t){if(typeof t!="string")throw new TypeError(`Invalid mnemonic type: ${typeof t}`);return t.normalize("NFKD")}function In(t){const e=vr(t),r=e.split(" ");if(![12,15,18,21,24].includes(r.length))throw new Error("Invalid mnemonic");return{nfkd:e,words:r}}const _n=t=>vr(`mnemonic${t}`);function An(t,e=""){return un.pbkdf2(d.sha512,In(t).nfkd,_n(e),{c:2048,dkLen:64})}const On="0.50.1",jn="1.19.0",Cn={"-32700":"ParseError","-32600":"InvalidRequest","-32601":"MethodNotFound","-32602":"InvalidParams","-32603":"InternalError"};class kr extends Error{}class xr extends kr{constructor(e,r){super(e),this.code=r,this.type=Cn[r]??"ServerError"}}class Bn extends kr{constructor(e,r,n){super(e),this.status=r,this.statusText=n}}var _t=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},_=(t,e,r)=>(_t(t,e,"read from private field"),r?r.call(t):e.get(t)),ie=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},we=(t,e,r,n)=>(_t(t,e,"write to private field"),e.set(t,r),r),Mn=(t,e,r,n)=>({set _(s){we(t,e,s)},get _(){return _(t,e,n)}}),Ir=(t,e,r)=>(_t(t,e,"access private method"),r),de,Oe,ee,le,Be,be,ht,_r,At,Ar;function Pn(t){const e=new URL(t);return e.protocol=e.protocol.replace("http","ws"),e.toString()}const Rn={WebSocketConstructor:typeof WebSocket<"u"?WebSocket:void 0,callTimeout:3e4,reconnectTimeout:3e3,maxReconnects:5};class Nn{constructor(e,r={}){if(ie(this,ht),ie(this,At),ie(this,de,0),ie(this,Oe,0),ie(this,ee,null),ie(this,le,null),ie(this,Be,new Set),ie(this,be,new Map),this.endpoint=e,this.options={...Rn,...r},!this.options.WebSocketConstructor)throw new Error("Missing WebSocket constructor");this.endpoint.startsWith("http")&&(this.endpoint=Pn(this.endpoint))}async makeRequest(e,r){const n=await Ir(this,ht,_r).call(this);return new Promise((s,i)=>{we(this,de,_(this,de)+1),_(this,be).set(_(this,de),{resolve:s,reject:i,timeout:setTimeout(()=>{_(this,be).delete(_(this,de)),i(new Error(`Request timeout: ${e}`))},this.options.callTimeout)}),n.send(JSON.stringify({jsonrpc:"2.0",id:_(this,de),method:e,params:r}))}).then(({error:s,result:i})=>{if(s)throw new xr(s.message,s.code);return i})}async subscribe(e){const r=new $n(e);return _(this,Be).add(r),await r.subscribe(this),()=>r.unsubscribe(this)}}de=new WeakMap;Oe=new WeakMap;ee=new WeakMap;le=new WeakMap;Be=new WeakMap;be=new WeakMap;ht=new WeakSet;_r=function(){return _(this,le)?_(this,le):(we(this,le,new Promise(t=>{var e;(e=_(this,ee))==null||e.close(),we(this,ee,new this.options.WebSocketConstructor(this.endpoint)),_(this,ee).addEventListener("open",()=>{we(this,Oe,0),t(_(this,ee))}),_(this,ee).addEventListener("close",()=>{Mn(this,Oe)._++,_(this,Oe)<=this.options.maxReconnects&&setTimeout(()=>{Ir(this,At,Ar).call(this)},this.options.reconnectTimeout)}),_(this,ee).addEventListener("message",({data:r})=>{let n;try{n=JSON.parse(r)}catch(s){console.error(new Error(`Failed to parse RPC message: ${r}`,{cause:s}));return}if("id"in n&&n.id!=null&&_(this,be).has(n.id)){const{resolve:s,timeout:i}=_(this,be).get(n.id);clearTimeout(i),s(n)}else if("params"in n){const{params:s}=n;_(this,Be).forEach(i=>{i.subscriptionId===s.subscription&&s.subscription===i.subscriptionId&&i.onMessage(s.result)})}})})),_(this,le))};At=new WeakSet;Ar=async function(){var t;return(t=_(this,ee))==null||t.close(),we(this,le,null),Promise.allSettled([..._(this,Be)].map(e=>e.subscribe(this)))};class $n{constructor(e){this.subscriptionId=null,this.subscribed=!1,this.input=e}onMessage(e){this.subscribed&&this.input.onMessage(e)}async unsubscribe(e){const{subscriptionId:r}=this;return this.subscribed=!1,r==null?!1:(this.subscriptionId=null,e.makeRequest(this.input.unsubscribe,[r]))}async subscribe(e){this.subscriptionId=null,this.subscribed=!0;const r=await e.makeRequest(this.input.method,this.input.params);this.subscribed&&(this.subscriptionId=r)}}var Ot=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},z=(t,e,r)=>(Ot(t,e,"read from private field"),r?r.call(t):e.get(t)),ze=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},gt=(t,e,r,n)=>(Ot(t,e,"write to private field"),e.set(t,r),r),Un=(t,e,r)=>(Ot(t,e,"access private method"),r),Ie,F,je,pt,Or;class Dn{constructor(e){ze(this,pt),ze(this,Ie,0),ze(this,F,void 0),ze(this,je,void 0),gt(this,F,e)}fetch(e,r){const n=z(this,F).fetch??globalThis.fetch;if(!this.fetch)throw new Error("The current environment does not support fetch, you can provide a fetch implementation in the options for SuiHTTPTransport.");return n(e,r)}async request(e){var s,i;gt(this,Ie,z(this,Ie)+1);const r=await this.fetch(((s=z(this,F).rpc)==null?void 0:s.url)??z(this,F).url,{method:"POST",headers:{"Content-Type":"application/json","Client-Sdk-Type":"typescript","Client-Sdk-Version":On,"Client-Target-Api-Version":jn,...(i=z(this,F).rpc)==null?void 0:i.headers},body:JSON.stringify({jsonrpc:"2.0",id:z(this,Ie),method:e.method,params:e.params})});if(!r.ok)throw new Bn(`Unexpected status code: ${r.status}`,r.status,r.statusText);const n=await r.json();if("error"in n&&n.error!=null)throw new xr(n.error.message,n.error.code);return n.result}async subscribe(e){const r=await Un(this,pt,Or).call(this).subscribe(e);return async()=>!!await r()}}Ie=new WeakMap;F=new WeakMap;je=new WeakMap;pt=new WeakSet;Or=function(){var t;if(!z(this,je)){const e=z(this,F).WebSocketConstructor??globalThis.WebSocket;if(!e)throw new Error("The current environment does not support WebSocket, you can provide a WebSocketConstructor in the options for SuiHTTPTransport.");gt(this,je,new Nn(((t=z(this,F).websocket)==null?void 0:t.url)??z(this,F).url,{WebSocketConstructor:e,...z(this,F).websocket}))}return z(this,je)};const zn=/^vector<(.+)>$/,Vn=/^([^:]+)::([^:]+)::([^<]+)(<(.+)>)?/;class te{static parseFromStr(e,r=!1){if(e==="address")return{address:null};if(e==="bool")return{bool:null};if(e==="u8")return{u8:null};if(e==="u16")return{u16:null};if(e==="u32")return{u32:null};if(e==="u64")return{u64:null};if(e==="u128")return{u128:null};if(e==="u256")return{u256:null};if(e==="signer")return{signer:null};const n=e.match(zn);if(n)return{vector:te.parseFromStr(n[1],r)};const s=e.match(Vn);if(s)return{struct:{address:r?d.normalizeSuiAddress(s[1]):s[1],module:s[2],name:s[3],typeParams:s[5]===void 0?[]:te.parseStructTypeArgs(s[5],r)}};throw new Error(`Encountered unexpected token when parsing type args for ${e}`)}static parseStructTypeArgs(e,r=!1){return hr(e).map(n=>te.parseFromStr(n,r))}static tagToString(e){if("bool"in e)return"bool";if("u8"in e)return"u8";if("u16"in e)return"u16";if("u32"in e)return"u32";if("u64"in e)return"u64";if("u128"in e)return"u128";if("u256"in e)return"u256";if("address"in e)return"address";if("signer"in e)return"signer";if("vector"in e)return`vector<${te.tagToString(e.vector)}>`;if("struct"in e){const r=e.struct,n=r.typeParams.map(te.tagToString).join(", ");return`${r.address}::${r.module}::${r.name}${n?`<${n}>`:""}`}throw new Error("Invalid TypeTag")}}const k=new I({...bn(),types:{enums:{"Option<T>":{None:null,Some:"T"}}}});function jr(t){return c.u64({name:"unsafe_u64",...t}).transform({input:e=>e,output:e=>Number(e)})}function Ln(t){return c.enum("Option",{None:null,Some:t})}function jt(t){return t.transform({input:e=>({[e.kind]:e}),output:e=>{const r=Object.keys(e)[0];return{kind:r,...e[r]}}})}const G=c.bytes(d.SUI_ADDRESS_LENGTH).transform({input:t=>typeof t=="string"?Ue(d.normalizeSuiAddress(t)):t,output:t=>d.normalizeSuiAddress(ge(t))}),Ct=c.vector(c.u8()).transform({name:"ObjectDigest",input:t=>d.fromB58(t),output:t=>d.toB58(new Uint8Array(t))}),Me=c.struct("SuiObjectRef",{objectId:G,version:c.u64(),digest:Ct}),Bt=c.struct("SharedObjectRef",{objectId:G,initialSharedVersion:c.u64(),mutable:c.bool()}),Ye=c.enum("ObjectArg",{ImmOrOwned:Me,Shared:Bt,Receiving:Me}),Mt=c.enum("CallArg",{Pure:c.vector(c.u8()),Object:Ye,ObjVec:c.vector(Ye)}),ve=c.enum("TypeTag",{bool:null,u8:null,u64:null,u128:null,address:null,signer:null,vector:c.lazy(()=>ve),struct:c.lazy(()=>Dt),u16:null,u32:null,u256:null}),q=jt(c.enum("Argument",{GasCoin:null,Input:c.struct("Input",{index:c.u16()}),Result:c.struct("Result",{index:c.u16()}),NestedResult:c.struct("NestedResult",{index:c.u16(),resultIndex:c.u16()})})),Pt=c.struct("ProgrammableMoveCall",{package:G,module:c.string(),function:c.string(),type_arguments:c.vector(ve),arguments:c.vector(q)}).transform({input:t=>{const[e,r,n]=t.target.split("::"),s=t.typeArguments.map(i=>te.parseFromStr(i,!0));return{package:d.normalizeSuiAddress(e),module:r,function:n,type_arguments:s,arguments:t.arguments}},output:t=>({target:[t.package,t.module,t.function].join("::"),arguments:t.arguments,typeArguments:t.type_arguments.map(te.tagToString)})}),Rt=jt(c.enum("Transaction",{MoveCall:Pt,TransferObjects:c.struct("TransferObjects",{objects:c.vector(q),address:q}),SplitCoins:c.struct("SplitCoins",{coin:q,amounts:c.vector(q)}),MergeCoins:c.struct("MergeCoins",{destination:q,sources:c.vector(q)}),Publish:c.struct("Publish",{modules:c.vector(c.vector(c.u8())),dependencies:c.vector(G)}),MakeMoveVec:c.struct("MakeMoveVec",{type:Ln(ve),objects:c.vector(q)}),Upgrade:c.struct("Upgrade",{modules:c.vector(c.vector(c.u8())),dependencies:c.vector(G),packageId:G,ticket:q})})),Nt=c.struct("ProgrammableTransaction",{inputs:c.vector(Mt),transactions:c.vector(Rt)}),$t=c.enum("TransactionKind",{ProgrammableTransaction:Nt,ChangeEpoch:null,Genesis:null,ConsensusCommitPrologue:null}),Ut=c.enum("TransactionExpiration",{None:null,Epoch:jr()}),Dt=c.struct("StructTag",{address:G,module:c.string(),name:c.string(),typeParams:c.vector(ve)}),zt=c.struct("GasData",{payment:c.vector(Me),owner:G,price:c.u64(),budget:c.u64()}),Vt=c.struct("TransactionDataV1",{kind:$t,sender:G,gasData:zt,expiration:Ut}),Lt=c.enum("TransactionData",{V1:Vt}),qn=c.enum("IntentScope",{TransactionData:null,TransactionEffects:null,CheckpointSummary:null,PersonalMessage:null}),Wn=c.enum("IntentVersion",{V0:null}),Fn=c.enum("AppId",{Sui:null}),Kn=c.struct("Intent",{scope:qn,version:Wn,appId:Fn}),Gn=c.generic(["T"],t=>c.struct("IntentMessage<T>",{intent:Kn,value:t})),qt=c.enum("CompressedSignature",{ED25519:c.fixedArray(64,c.u8()),Secp256k1:c.fixedArray(64,c.u8()),Secp256r1:c.fixedArray(64,c.u8()),ZkLogin:c.vector(c.u8())}),Wt=c.enum("PublicKey",{ED25519:c.fixedArray(32,c.u8()),Secp256k1:c.fixedArray(33,c.u8()),Secp256r1:c.fixedArray(33,c.u8()),ZkLogin:c.vector(c.u8())}),Ft=c.struct("MultiSigPkMap",{pubKey:Wt,weight:c.u8()}),Kt=c.struct("MultiSigPublicKey",{pk_map:c.vector(Ft),threshold:c.u16()}),Cr=c.struct("MultiSig",{sigs:c.vector(qt),bitmap:c.u16(),multisig_pk:Kt}),Hn=c.vector(c.u8()).transform({input:t=>typeof t=="string"?H(t):t,output:t=>$(new Uint8Array(t))}),Br=c.struct("SenderSignedTransaction",{intentMessage:Gn(Lt),txSignatures:c.vector(Hn)}),Mr=c.vector(Br,{name:"SenderSignedData"}),A={...c,U8:c.u8(),U16:c.u16(),U32:c.u32(),U64:c.u64(),U128:c.u128(),U256:c.u256(),ULEB128:c.uleb128(),Bool:c.bool(),String:c.string(),Address:G,Argument:q,CallArg:Mt,CompressedSignature:qt,GasData:zt,MultiSig:Cr,MultiSigPkMap:Ft,MultiSigPublicKey:Kt,ObjectArg:Ye,ObjectDigest:Ct,ProgrammableMoveCall:Pt,ProgrammableTransaction:Nt,PublicKey:Wt,SenderSignedData:Mr,SenderSignedTransaction:Br,SharedObjectRef:Bt,StructTag:Dt,SuiObjectRef:Me,Transaction:Rt,TransactionData:Lt,TransactionDataV1:Vt,TransactionExpiration:Ut,TransactionKind:$t,TypeTag:ve,ser:k.ser.bind(k),de:k.de.bind(k),getTypeInterface:k.getTypeInterface.bind(k),hasType:k.hasType.bind(k),parseTypeName:k.parseTypeName.bind(k),registerAddressType:k.registerAddressType.bind(k),registerAlias:k.registerAlias.bind(k),registerBcsType:k.registerBcsType.bind(k),registerEnumType:k.registerEnumType.bind(k),registerStructType:k.registerStructType.bind(k),registerType:k.registerType.bind(k),types:k.types};k.registerBcsType("utf8string",()=>c.string({name:"utf8string"}));k.registerBcsType("unsafe_u64",()=>jr());k.registerBcsType("enumKind",t=>jt(t));[G,q,Mt,qt,zt,Cr,Ft,Kt,Ye,Ct,Pt,Nt,Wt,Mr,Bt,Dt,Me,Rt,Lt,Vt,Ut,$t,ve].forEach(t=>{k.registerBcsType(t.name,()=>t)});const Gt=j([g({AddressOwner:f()}),g({ObjectOwner:f()}),g({Shared:g({initial_shared_version:O(f())})}),b("Immutable")]);D("SuiJsonValue",()=>!0);const Zn=j([g({u32:f()}),g({u64:f()}),g({f64:f()})]);g({attributes:Z(f(),O(Zn)),featureFlags:Z(f(),P()),maxSupportedProtocolVersion:f(),minSupportedProtocolVersion:f(),protocolVersion:f()});j([f(),b("package")]);const oe=g({digest:f(),objectId:f(),version:j([fe(),f(),kn()])});g({owner:Gt,reference:oe});g({objectId:f(),sequenceNumber:f()});g({payment:E(oe),owner:f(),price:f(),budget:f()});const Jn=Ce(oe,g({type:f(),owner:Gt,previousTransaction:f()})),Xn=Z(f(),ft()),Yn=Z(f(),Er()),Qn=g({type:f(),fields:Xn,hasPublicTransfer:P()}),es=g({disassembled:Yn}),ts=j([Ce(Qn,g({dataType:b("moveObject")})),Ce(es,g({dataType:b("package")}))]),rs=g({type:f(),hasPublicTransfer:P(),version:f(),bcsBytes:f()}),ns=g({id:f(),moduleMap:Z(f(),f())}),ss=j([Ce(rs,g({dataType:b("moveObject")})),Ce(ns,g({dataType:b("package")}))]);BigInt(1e9);const Pr=g({code:f(),error:w(f()),object_id:w(f()),parent_object_id:w(f()),version:w(f()),digest:w(f())}),is=g({data:O(w(Z(f(),f()))),error:O(w(Pr))}),as=j([is,w(Z(f(),f()))]),Rr=g({objectId:f(),version:f(),digest:f(),type:O(w(f())),content:O(w(ts)),bcs:O(w(ss)),owner:O(w(Gt)),previousTransaction:O(w(f())),storageRebate:O(w(f())),display:O(w(as))});g({showType:O(w(P())),showContent:O(w(P())),showBcs:O(w(P())),showOwner:O(w(P())),showPreviousTransaction:O(w(P())),showStorageRebate:O(w(P())),showDisplay:O(w(P()))});j([b("Exists"),b("notExists"),b("Deleted")]);E(Jn);const os=g({data:O(w(Rr)),error:O(w(Pr))});function cs(t){return t.data}function us(t){if(t.error&&"object_id"in t.error&&"version"in t.error&&"digest"in t.error){const e=t.error;return{objectId:e.object_id,version:e.version,digest:e.digest}}}function sr(t){if("reference"in t)return t.reference;const e=cs(t);return e?{objectId:e.objectId,version:e.version,digest:e.digest}:us(t)}g({objectId:f(),atCheckpoint:w(fe())});g({data:E(os),nextCursor:w(O(f())),hasNextPage:P()});j([g({details:Rr,status:b("VersionFound")}),g({details:f(),status:b("ObjectNotExists")}),g({details:oe,status:b("ObjectDeleted")}),g({details:Tr([f(),fe()]),status:b("VersionNotFound")}),g({details:g({asked_version:fe(),latest_version:fe(),object_id:f()}),status:b("VersionTooHigh")})]);const ds=j([f(),g({Object:f()})]);E(ds);const ls=g({address:f(),name:f()}),fs=j([b("Private"),b("Public"),b("Friend")]),Ht=g({abilities:E(f())}),hs=g({constraints:Ht,isPhantom:P()}),gs=g({TypeParameter:fe()}),ct=Tr([g({module:f(),package:f(),function:f()}),f()]);g({rank3Days:E(ct),rank7Days:E(ct),rank30Days:E(ct)});function Nr(t){if(!t)return!1;if(typeof t=="string"||U(t,gs)||$r(t))return!0;if(typeof t!="object")return!1;const e=t;return!!(U(e.Reference,Se)||U(e.MutableReference,Se)||U(e.Vector,Se))}const Se=D("SuiMoveNormalizedType",Nr);function $r(t){if(!t||typeof t!="object")return!1;const e=t;if(!e.Struct||typeof e.Struct!="object")return!1;const r=e.Struct;return!(typeof r.address!="string"||typeof r.module!="string"||typeof r.name!="string"||!Array.isArray(r.typeArguments)||!r.typeArguments.every(n=>Nr(n)))}D("SuiMoveNormalizedStructType",$r);const ps=g({visibility:fs,isEntry:P(),typeParameters:E(Ht),parameters:E(Se),return:E(Se)}),ys=g({name:f(),type:Se}),ms=g({abilities:Ht,typeParameters:E(hs),fields:E(ys)}),ws=g({fileFormatVersion:fe(),address:f(),name:f(),friends:E(ls),structs:Z(f(),ms),exposedFunctions:Z(f(),ps)});Z(f(),ws);function yt(t){return typeof t=="object"&&"MutableReference"in t?t.MutableReference:void 0}function Ur(t){return typeof t=="object"&&"Reference"in t?t.Reference:void 0}function Zt(t){if(typeof t=="object"&&"Struct"in t)return t;const e=Ur(t),r=yt(t);if(typeof e=="object"&&"Struct"in e)return e;if(typeof r=="object"&&"Struct"in r)return r}const bs=j([g({ImmOrOwned:oe}),g({Shared:g({objectId:f(),initialSharedVersion:j([J(),f()]),mutable:P()})}),g({Receiving:oe})]),Qe=g({Pure:E(J())}),mt=g({Object:bs}),et=j([Qe,mt]);function Ss(t,e){return{Pure:Array.from(t instanceof Uint8Array?t:xt(t)?t.toBytes():A.ser(e,t,{maxSize:1/0}).toBytes())}}const N={Pure:Ss,ObjectRef({objectId:t,digest:e,version:r}){return{Object:{ImmOrOwned:{digest:e,version:r,objectId:d.normalizeSuiAddress(t)}}}},SharedObjectRef({objectId:t,mutable:e,initialSharedVersion:r}){return{Object:{Shared:{mutable:e,initialSharedVersion:r,objectId:d.normalizeSuiAddress(t)}}}},ReceivingRef({objectId:t,digest:e,version:r}){return{Object:{Receiving:{digest:e,version:r,objectId:d.normalizeSuiAddress(t)}}}}};function ir(t){return typeof t=="string"?d.normalizeSuiAddress(t):"ImmOrOwned"in t.Object?d.normalizeSuiAddress(t.Object.ImmOrOwned.objectId):"Receiving"in t.Object?d.normalizeSuiAddress(t.Object.Receiving.objectId):d.normalizeSuiAddress(t.Object.Shared.objectId)}function Ts(t){return typeof t=="object"&&"Object"in t&&"Shared"in t.Object?t.Object.Shared:void 0}function Es(t){var e;return((e=Ts(t))==null?void 0:e.mutable)??!1}function vs(t){function e(r,n){return t(r,n)}return e.u8=r=>t(A.U8.serialize(r)),e.u16=r=>t(A.U16.serialize(r)),e.u32=r=>t(A.U32.serialize(r)),e.u64=r=>t(A.U64.serialize(r)),e.u128=r=>t(A.U128.serialize(r)),e.u256=r=>t(A.U256.serialize(r)),e.bool=r=>t(A.Bool.serialize(r)),e.string=r=>t(A.String.serialize(r)),e.address=r=>t(A.Address.serialize(r)),e.id=e.address,e}const ks="object",xs="ID",Is="ascii",_s="String",As="string",Os="String",js="option",Cs="Option",Bs={address:d.SUI_FRAMEWORK_ADDRESS,module:ks,name:xs},Ms={address:d.MOVE_STDLIB_ADDRESS,module:Is,name:_s},Ps={address:d.MOVE_STDLIB_ADDRESS,module:As,name:Os},Rs={address:d.MOVE_STDLIB_ADDRESS,module:js,name:Cs},Ve=(t,e)=>t.address===e.address&&t.module===e.module&&t.name===e.name;function Ns(t){var r;const e=(r=Zt(t))==null?void 0:r.Struct;return(e==null?void 0:e.address)==="0x2"&&(e==null?void 0:e.module)==="tx_context"&&(e==null?void 0:e.name)==="TxContext"}function ut(t,e){if(!(typeof e>"u")&&typeof e!==t)throw new Error(`Expect ${e} to be ${t}, received ${typeof e}`)}const $s=["Address","Bool","U8","U16","U32","U64","U128","U256"];function wt(t,e){if(typeof t=="string"&&$s.includes(t)){if(t in["U8","U16","U32","U64","U128","U256"])ut("number",e);else if(t==="Bool")ut("boolean",e);else if(t==="Address"&&(ut("string",e),e&&!d.isValidSuiAddress(e)))throw new Error("Invalid Sui Address");return t.toLowerCase()}else if(typeof t=="string")throw new Error(`Unknown pure normalized type ${JSON.stringify(t,null,2)}`);if("Vector"in t){if((e===void 0||typeof e=="string")&&t.Vector==="U8")return"string";if(e!==void 0&&!Array.isArray(e))throw new Error(`Expect ${e} to be a array, received ${typeof e}`);const r=wt(t.Vector,e?e[0]:void 0);return r===void 0?void 0:`vector<${r}>`}if("Struct"in t){if(Ve(t.Struct,Ms))return"string";if(Ve(t.Struct,Ps))return"utf8string";if(Ve(t.Struct,Bs))return"address";if(Ve(t.Struct,Rs)){const r={Vector:t.Struct.typeArguments[0]};return wt(r,e)}}}function Us(t,e){const r=Array.from(`${t}::`).map(s=>s.charCodeAt(0)),n=new Uint8Array(r.length+e.length);return n.set(r),n.set(e,r.length),d.blake2b(n,{dkLen:32})}function R(t,e){return wr(t,e)}const Ds=t=>j([g({None:j([b(!0),b(null)])}),g({Some:t})]),Pe=j([g({kind:b("Input"),index:J(),value:w(ft()),type:w(b("object"))}),g({kind:b("Input"),index:J(),value:w(ft()),type:b("pure")})]),zs=[Pe,g({kind:b("GasCoin")}),g({kind:b("Result"),index:J()}),g({kind:b("NestedResult"),index:J(),resultIndex:J()})],ne=j([...zs]),Dr=g({kind:b("MoveCall"),target:D("target",f().validator),typeArguments:E(f()),arguments:E(ne)}),zr=g({kind:b("TransferObjects"),objects:E(ne),address:ne}),Vr=g({kind:b("SplitCoins"),coin:ne,amounts:E(ne)}),Lr=g({kind:b("MergeCoins"),destination:ne,sources:E(ne)}),qr=g({kind:b("MakeMoveVec"),type:w(Ds(Z(f(),Er()))),objects:E(ne)}),Wr=g({kind:b("Publish"),modules:E(E(J())),dependencies:E(f())}),Fr=g({kind:b("Upgrade"),modules:E(E(J())),dependencies:E(f()),packageId:f(),ticket:ne}),Vs=[Dr,zr,Vr,Lr,Wr,Fr,qr],Ls=j([...Vs]),ue={MoveCall(t){return R({kind:"MoveCall",target:t.target,arguments:t.arguments??[],typeArguments:t.typeArguments??[]},Dr)},TransferObjects(t,e){return e.kind==="Input"&&e.type==="pure"&&typeof e.value!="object"&&(e.value=N.Pure(A.Address.serialize(e.value))),R({kind:"TransferObjects",objects:t,address:e},zr)},SplitCoins(t,e){return e.forEach(r=>{r.kind==="Input"&&r.type==="pure"&&typeof r.value!="object"&&(r.value=N.Pure(A.U64.serialize(r.value)))}),R({kind:"SplitCoins",coin:t,amounts:e},Vr)},MergeCoins(t,e){return R({kind:"MergeCoins",destination:t,sources:e},Lr)},Publish({modules:t,dependencies:e}){return R({kind:"Publish",modules:t.map(r=>typeof r=="string"?Array.from(H(r)):r),dependencies:e.map(r=>d.normalizeSuiObjectId(r))},Wr)},Upgrade({modules:t,dependencies:e,packageId:r,ticket:n}){return R({kind:"Upgrade",modules:t.map(s=>typeof s=="string"?Array.from(H(s)):s),dependencies:e.map(s=>d.normalizeSuiObjectId(s)),packageId:r,ticket:n},Fr)},MakeMoveVec({type:t,objects:e}){return R({kind:"MakeMoveVec",type:t?{Some:te.parseFromStr(t)}:{None:null},objects:e},qr)}},qs=w(O(j([g({Epoch:J()}),g({None:j([b(!0),b(null)])})]))),ar=D("StringEncodedBigint",t=>{if(!["string","number","bigint"].includes(typeof t))return!1;try{return BigInt(t),!0}catch{return!1}}),Ws=g({budget:w(ar),price:w(ar),payment:w(E(oe)),owner:w(f())}),Le=g({version:b(1),sender:w(f()),expiration:qs,gasConfig:Ws,inputs:E(Pe),transactions:E(Ls)});function or(t){return d.normalizeSuiAddress(t).replace("0x","")}class re{constructor(e){this.version=1,this.sender=e==null?void 0:e.sender,this.expiration=e==null?void 0:e.expiration,this.gasConfig=(e==null?void 0:e.gasConfig)??{},this.inputs=(e==null?void 0:e.inputs)??[],this.transactions=(e==null?void 0:e.transactions)??[]}static fromKindBytes(e){const r=A.TransactionKind.parse(e),n="ProgrammableTransaction"in r?r.ProgrammableTransaction:null;if(!n)throw new Error("Unable to deserialize from bytes.");const s=R({version:1,gasConfig:{},inputs:n.inputs.map((i,a)=>R({kind:"Input",value:i,index:a,type:U(i,Qe)?"pure":"object"},Pe)),transactions:n.transactions},Le);return re.restore(s)}static fromBytes(e){var a;const r=A.TransactionData.parse(e),n=r==null?void 0:r.V1,s="ProgrammableTransaction"in n.kind?(a=n==null?void 0:n.kind)==null?void 0:a.ProgrammableTransaction:null;if(!n||!s)throw new Error("Unable to deserialize from bytes.");const i=R({version:1,sender:n.sender,expiration:n.expiration,gasConfig:n.gasData,inputs:s.inputs.map((o,u)=>R({kind:"Input",value:o,index:u,type:U(o,Qe)?"pure":"object"},Pe)),transactions:s.transactions},Le);return re.restore(i)}static restore(e){lt(e,Le);const r=new re;return Object.assign(r,e),r}static getDigestFromBytes(e){const r=Us("TransactionData",e);return d.toB58(r)}build({maxSizeBytes:e=1/0,overrides:r,onlyTransactionKind:n}={}){const s=this.inputs.map(h=>(lt(h.value,et),h.value)),i={ProgrammableTransaction:{inputs:s,transactions:this.transactions}};if(n)return A.TransactionKind.serialize(i,{maxSize:e}).toBytes();const a=(r==null?void 0:r.expiration)??this.expiration,o=(r==null?void 0:r.sender)??this.sender,u={...this.gasConfig,...r==null?void 0:r.gasConfig};if(!o)throw new Error("Missing transaction sender");if(!u.budget)throw new Error("Missing gas budget");if(!u.payment)throw new Error("Missing gas payment");if(!u.price)throw new Error("Missing gas price");const l={sender:or(o),expiration:a||{None:!0},gasData:{payment:u.payment,owner:or(this.gasConfig.owner??o),price:BigInt(u.price),budget:BigInt(u.budget)},kind:{ProgrammableTransaction:{inputs:s,transactions:this.transactions}}};return A.TransactionData.serialize({V1:l},{maxSize:e}).toBytes()}getDigest(){const e=this.build({onlyTransactionKind:!1});return re.getDigestFromBytes(e)}snapshot(){return R(this,Le)}}var Jt=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},v=(t,e,r)=>(Jt(t,e,"read from private field"),r?r.call(t):e.get(t)),Y=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},qe=(t,e,r,n)=>(Jt(t,e,"write to private field"),e.set(t,r),r),B=(t,e,r)=>(Jt(t,e,"access private method"),r),S,_e,Fe,Ae,Ke,ce,he,Xt,Kr,Yt,Gr,Qt,Hr,er,Zr,Ge,bt;const Fs={maxPureArgumentSize:16*1024,maxTxGas:5e10,maxGasObjects:256,maxTxSizeBytes:128*1024};function Ks(t){const e={kind:"Result",index:t},r=[],n=s=>r[s]??(r[s]={kind:"NestedResult",index:t,resultIndex:s});return new Proxy(e,{set(){throw new Error("The transaction result is a proxy, and does not support setting properties directly")},get(s,i){if(i in s)return Reflect.get(s,i);if(i===Symbol.iterator)return function*(){let o=0;for(;;)yield n(o),o++};if(typeof i=="symbol")return;const a=parseInt(i,10);if(!(Number.isNaN(a)||a<0))return n(a)}})}function Gs(t){const e=Zt(t);return e?e.Struct.address==="0x2"&&e.Struct.module==="transfer"&&e.Struct.name==="Receiving":!1}function Re(t){if(!t.client)throw new Error("No provider passed to Transaction#build, but transaction data was not sufficient to build offline.");return t.client}const Jr=Symbol.for("@mysten/transaction"),dt={maxTxGas:"max_tx_gas",maxGasObjects:"max_gas_payment_objects",maxTxSizeBytes:"max_tx_size_bytes",maxPureArgumentSize:"max_pure_argument_size"},Hs=1000n,Zs=50,Js=(t,e)=>Array.from({length:Math.ceil(t.length/e)},(r,n)=>t.slice(n*e,n*e+e));function Xs(t){return!!t&&typeof t=="object"&&t[Jr]===!0}const St=class{constructor(t){Y(this,_e),Y(this,Ae),Y(this,ce),Y(this,Xt),Y(this,Yt),Y(this,Qt),Y(this,er),Y(this,Ge),Y(this,S,void 0),qe(this,S,new re(t?t.blockData:void 0))}static fromKind(t){const e=new St;return qe(e,S,re.fromKindBytes(typeof t=="string"?H(t):t)),e}static from(t){const e=new St;return typeof t!="string"||!t.startsWith("{")?qe(e,S,re.fromBytes(typeof t=="string"?H(t):t)):qe(e,S,re.restore(JSON.parse(t))),e}setSender(t){v(this,S).sender=t}setSenderIfNotSet(t){v(this,S).sender||(v(this,S).sender=t)}setExpiration(t){v(this,S).expiration=t}setGasPrice(t){v(this,S).gasConfig.price=String(t)}setGasBudget(t){v(this,S).gasConfig.budget=String(t)}setGasOwner(t){v(this,S).gasConfig.owner=t}setGasPayment(t){v(this,S).gasConfig.payment=t.map(e=>br(e,oe))}get blockData(){return v(this,S).snapshot()}get[Jr](){return!0}get pure(){return Object.defineProperty(this,"pure",{enumerable:!1,value:vs((t,e)=>xt(t)?B(this,_e,Fe).call(this,"pure",{Pure:Array.from(t.toBytes())}):B(this,_e,Fe).call(this,"pure",t instanceof Uint8Array?N.Pure(t):e?N.Pure(t,e):t))}),this.pure}get gas(){return{kind:"GasCoin"}}object(t){if(typeof t=="object"&&"kind"in t)return t;const e=ir(t),r=v(this,S).inputs.find(n=>n.type==="object"&&e===ir(n.value));return r&&U(r.value,mt)&&"Shared"in r.value.Object&&U(t,mt)&&"Shared"in t.Object&&(r.value.Object.Shared.mutable=r.value.Object.Shared.mutable||t.Object.Shared.mutable),r??B(this,_e,Fe).call(this,"object",typeof t=="string"?d.normalizeSuiAddress(t):t)}objectRef(...t){return this.object(N.ObjectRef(...t))}receivingRef(...t){return this.object(N.ReceivingRef(...t))}sharedObjectRef(...t){return this.object(N.SharedObjectRef(...t))}add(t){const e=v(this,S).transactions.push(t);return Ks(e-1)}splitCoins(t,e){return this.add(ue.SplitCoins(typeof t=="string"?this.object(t):t,e.map(r=>typeof r=="number"||typeof r=="bigint"||typeof r=="string"?this.pure.u64(r):B(this,Ae,Ke).call(this,r))))}mergeCoins(t,e){return this.add(ue.MergeCoins(typeof t=="string"?this.object(t):t,e.map(r=>typeof r=="string"?this.object(r):r)))}publish({modules:t,dependencies:e}){return this.add(ue.Publish({modules:t,dependencies:e}))}upgrade({modules:t,dependencies:e,packageId:r,ticket:n}){return this.add(ue.Upgrade({modules:t,dependencies:e,packageId:r,ticket:typeof n=="string"?this.object(n):n}))}moveCall({arguments:t,typeArguments:e,target:r}){return this.add(ue.MoveCall({arguments:t==null?void 0:t.map(n=>B(this,Ae,Ke).call(this,n)),typeArguments:e,target:r}))}transferObjects(t,e){return this.add(ue.TransferObjects(t.map(r=>typeof r=="string"?this.object(r):r),typeof e=="string"?this.pure.address(e):B(this,Ae,Ke).call(this,e)))}makeMoveVec({type:t,objects:e}){return this.add(ue.MakeMoveVec({type:t,objects:e.map(r=>typeof r=="string"?this.object(r):r)}))}serialize(){return JSON.stringify(v(this,S).snapshot())}async sign(t){const{signer:e,...r}=t,n=await this.build(r);return e.signTransactionBlock(n)}async build(t={}){return await B(this,Ge,bt).call(this,t),v(this,S).build({maxSizeBytes:B(this,ce,he).call(this,"maxTxSizeBytes",t),onlyTransactionKind:t.onlyTransactionKind})}async getDigest(t={}){return await B(this,Ge,bt).call(this,t),v(this,S).getDigest()}};let Ys=St;S=new WeakMap;_e=new WeakSet;Fe=function(t,e){const r=v(this,S).inputs.length,n=R({kind:"Input",value:typeof e=="bigint"?String(e):e,index:r,type:t},Pe);return v(this,S).inputs.push(n),n};Ae=new WeakSet;Ke=function(t){return xt(t)?this.pure(t):t};ce=new WeakSet;he=function(t,{protocolConfig:e,limits:r}){if(r&&typeof r[t]=="number")return r[t];if(!e)return Fs[t];const n=e==null?void 0:e.attributes[dt[t]];if(!n)throw new Error(`Missing expected protocol config: "${dt[t]}"`);const s="u64"in n?n.u64:"u32"in n?n.u32:n.f64;if(!s)throw new Error(`Unexpected protocol config value found for: "${dt[t]}"`);return Number(s)};Xt=new WeakSet;Kr=function(t){const e=B(this,ce,he).call(this,"maxPureArgumentSize",t);v(this,S).inputs.forEach((r,n)=>{if(U(r.value,Qe)&&r.value.Pure.length>e)throw new Error(`Input at index ${n} is too large, max pure input size is ${e} bytes, got ${r.value.Pure.length} bytes`)})};Yt=new WeakSet;Gr=async function(t){if(v(this,S).gasConfig.payment){const s=B(this,ce,he).call(this,"maxGasObjects",t);if(v(this,S).gasConfig.payment.length>s)throw new Error(`Payment objects exceed maximum amount: ${s}`)}if(t.onlyTransactionKind||v(this,S).gasConfig.payment)return;const e=v(this,S).gasConfig.owner??v(this,S).sender,n=(await Re(t).getCoins({owner:e,coinType:d.SUI_TYPE_ARG})).data.filter(s=>!v(this,S).inputs.find(a=>U(a.value,et)&&"Object"in a.value&&"ImmOrOwned"in a.value.Object?s.coinObjectId===a.value.Object.ImmOrOwned.objectId:!1)).slice(0,B(this,ce,he).call(this,"maxGasObjects",t)-1).map(s=>({objectId:s.coinObjectId,digest:s.digest,version:s.version}));if(!n.length)throw new Error("No valid gas coins found for the transaction.");this.setGasPayment(n)};Qt=new WeakSet;Hr=async function(t){t.onlyTransactionKind||v(this,S).gasConfig.price||this.setGasPrice(await Re(t).getReferenceGasPrice())};er=new WeakSet;Zr=async function(t){const{inputs:e,transactions:r}=v(this,S),n=[],s=[];if(e.forEach(i=>{if(i.type==="object"&&typeof i.value=="string"){s.push({id:d.normalizeSuiAddress(i.value),input:i});return}}),r.forEach(i=>{if(i.kind==="MoveCall"&&i.arguments.some(o=>o.kind==="Input"&&!U(e[o.index].value,et))&&n.push(i),i.kind==="SplitCoins"&&i.amounts.forEach(a=>{if(a.kind==="Input"){const o=e[a.index];typeof o.value!="object"&&(o.value=N.Pure(A.U64.serialize(o.value)))}}),i.kind==="TransferObjects"&&i.address.kind==="Input"){const a=e[i.address.index];typeof a.value!="object"&&(a.value=N.Pure(A.Address.serialize(a.value)))}}),n.length&&await Promise.all(n.map(async i=>{const[a,o,u]=i.target.split("::"),l=await Re(t).getNormalizedMoveFunction({package:d.normalizeSuiObjectId(a),module:o,function:u}),p=l.parameters.length>0&&Ns(l.parameters.at(-1))?l.parameters.slice(0,l.parameters.length-1):l.parameters;if(p.length!==i.arguments.length)throw new Error("Incorrect number of arguments.");p.forEach((y,m)=>{const x=i.arguments[m];if(x.kind!=="Input")return;const T=e[x.index];if(U(T.value,et))return;const C=T.value,M=wt(y,C);if(M){T.value=N.Pure(C,M);return}if(Zt(y)!=null||typeof y=="object"&&"TypeParameter"in y){if(typeof C!="string")throw new Error(`Expect the argument to be an object id string, got ${JSON.stringify(C,null,2)}`);s.push({id:C,input:T,normalizedType:y});return}throw new Error(`Unknown call arg type ${JSON.stringify(y,null,2)} for value ${JSON.stringify(C,null,2)}`)})})),s.length){const i=[...new Set(s.map(({id:h})=>h))],a=Js(i,Zs),o=(await Promise.all(a.map(h=>Re(t).multiGetObjects({ids:h,options:{showOwner:!0}})))).flat();let u=new Map(i.map((h,p)=>[h,o[p]]));const l=Array.from(u).filter(([h,p])=>p.error).map(([h,p])=>h);if(l.length)throw new Error(`The following input objects are invalid: ${l.join(", ")}`);s.forEach(({id:h,input:p,normalizedType:y})=>{var C;const m=u.get(h),x=(C=m.data)==null?void 0:C.owner,T=x&&typeof x=="object"&&"Shared"in x?x.Shared.initial_shared_version:void 0;if(T){const M=y!=null&&yt(y)==null&&Ur(y)==null,se=Es(p.value)||M||y!=null&&yt(y)!=null;p.value=N.SharedObjectRef({objectId:h,initialSharedVersion:T,mutable:se})}else y&&Gs(y)?p.value=N.ReceivingRef(sr(m)):p.value=N.ObjectRef(sr(m))})}};Ge=new WeakSet;bt=async function(t){if(!t.onlyTransactionKind&&!v(this,S).sender)throw new Error("Missing transaction sender");if(!t.protocolConfig&&!t.limits&&t.client&&(t.protocolConfig=await t.client.getProtocolConfig()),await Promise.all([B(this,Qt,Hr).call(this,t),B(this,er,Zr).call(this,t)]),!t.onlyTransactionKind&&(await B(this,Yt,Gr).call(this,t),!v(this,S).gasConfig.budget)){const e=await Re(t).dryRunTransactionBlock({transactionBlock:v(this,S).build({maxSizeBytes:B(this,ce,he).call(this,"maxTxSizeBytes",t),overrides:{gasConfig:{budget:String(B(this,ce,he).call(this,"maxTxGas",t)),payment:[]}}})});if(e.effects.status.status!=="success")throw new Error(`Dry run failed, could not automatically determine a budget: ${e.effects.status.error}`,{cause:e});const r=Hs*BigInt(this.blockData.gasConfig.price||1n),n=BigInt(e.effects.gasUsed.computationCost)+r,s=n+BigInt(e.effects.gasUsed.storageCost)-BigInt(e.effects.gasUsed.storageRebate);this.setGasBudget(s>n?s:n)}B(this,Xt,Kr).call(this,t)};const Qs=Symbol.for("@mysten/SuiClient");class ei{get[Qs](){return!0}constructor(e){this.transport=e.transport??new Dn({url:e.url})}async getRpcApiVersion(){return(await this.transport.request({method:"rpc.discover",params:[]})).info.version}async getCoins(e){if(!e.owner||!d.isValidSuiAddress(d.normalizeSuiAddress(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getCoins",params:[e.owner,e.coinType,e.cursor,e.limit]})}async getAllCoins(e){if(!e.owner||!d.isValidSuiAddress(d.normalizeSuiAddress(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getAllCoins",params:[e.owner,e.cursor,e.limit]})}async getBalance(e){if(!e.owner||!d.isValidSuiAddress(d.normalizeSuiAddress(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getBalance",params:[e.owner,e.coinType]})}async getAllBalances(e){if(!e.owner||!d.isValidSuiAddress(d.normalizeSuiAddress(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getAllBalances",params:[e.owner]})}async getCoinMetadata(e){return await this.transport.request({method:"suix_getCoinMetadata",params:[e.coinType]})}async getTotalSupply(e){return await this.transport.request({method:"suix_getTotalSupply",params:[e.coinType]})}async call(e,r){return await this.transport.request({method:e,params:r})}async getMoveFunctionArgTypes(e){return await this.transport.request({method:"sui_getMoveFunctionArgTypes",params:[e.package,e.module,e.function]})}async getNormalizedMoveModulesByPackage(e){return await this.transport.request({method:"sui_getNormalizedMoveModulesByPackage",params:[e.package]})}async getNormalizedMoveModule(e){return await this.transport.request({method:"sui_getNormalizedMoveModule",params:[e.package,e.module]})}async getNormalizedMoveFunction(e){return await this.transport.request({method:"sui_getNormalizedMoveFunction",params:[e.package,e.module,e.function]})}async getNormalizedMoveStruct(e){return await this.transport.request({method:"sui_getNormalizedMoveStruct",params:[e.package,e.module,e.struct]})}async getOwnedObjects(e){if(!e.owner||!d.isValidSuiAddress(d.normalizeSuiAddress(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getOwnedObjects",params:[e.owner,{filter:e.filter,options:e.options},e.cursor,e.limit]})}async getObject(e){if(!e.id||!d.isValidSuiObjectId(d.normalizeSuiObjectId(e.id)))throw new Error("Invalid Sui Object id");return await this.transport.request({method:"sui_getObject",params:[e.id,e.options]})}async tryGetPastObject(e){return await this.transport.request({method:"sui_tryGetPastObject",params:[e.id,e.version,e.options]})}async multiGetObjects(e){if(e.ids.forEach(n=>{if(!n||!d.isValidSuiObjectId(d.normalizeSuiObjectId(n)))throw new Error(`Invalid Sui Object id ${n}`)}),e.ids.length!==new Set(e.ids).size)throw new Error(`Duplicate object ids in batch call ${e.ids}`);return await this.transport.request({method:"sui_multiGetObjects",params:[e.ids,e.options]})}async queryTransactionBlocks(e){return await this.transport.request({method:"suix_queryTransactionBlocks",params:[{filter:e.filter,options:e.options},e.cursor,e.limit,(e.order||"descending")==="descending"]})}async getTransactionBlock(e){if(!d.isValidTransactionDigest(e.digest))throw new Error("Invalid Transaction digest");return await this.transport.request({method:"sui_getTransactionBlock",params:[e.digest,e.options]})}async multiGetTransactionBlocks(e){if(e.digests.forEach(n=>{if(!d.isValidTransactionDigest(n))throw new Error(`Invalid Transaction digest ${n}`)}),e.digests.length!==new Set(e.digests).size)throw new Error(`Duplicate digests in batch call ${e.digests}`);return await this.transport.request({method:"sui_multiGetTransactionBlocks",params:[e.digests,e.options]})}async executeTransactionBlock(e){return await this.transport.request({method:"sui_executeTransactionBlock",params:[typeof e.transactionBlock=="string"?e.transactionBlock:$(e.transactionBlock),Array.isArray(e.signature)?e.signature:[e.signature],e.options,e.requestType]})}async signAndExecuteTransactionBlock({transactionBlock:e,signer:r,...n}){let s;e instanceof Uint8Array?s=e:(e.setSenderIfNotSet(r.toSuiAddress()),s=await e.build({client:this}));const{signature:i,bytes:a}=await r.signTransactionBlock(s);return this.executeTransactionBlock({transactionBlock:a,signature:i,...n})}async getTotalTransactionBlocks(){const e=await this.transport.request({method:"sui_getTotalTransactionBlocks",params:[]});return BigInt(e)}async getReferenceGasPrice(){const e=await this.transport.request({method:"suix_getReferenceGasPrice",params:[]});return BigInt(e)}async getStakes(e){if(!e.owner||!d.isValidSuiAddress(d.normalizeSuiAddress(e.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getStakes",params:[e.owner]})}async getStakesByIds(e){return e.stakedSuiIds.forEach(r=>{if(!r||!d.isValidSuiObjectId(d.normalizeSuiObjectId(r)))throw new Error(`Invalid Sui Stake id ${r}`)}),await this.transport.request({method:"suix_getStakesByIds",params:[e.stakedSuiIds]})}async getLatestSuiSystemState(){return await this.transport.request({method:"suix_getLatestSuiSystemState",params:[]})}async queryEvents(e){return await this.transport.request({method:"suix_queryEvents",params:[e.query,e.cursor,e.limit,(e.order||"descending")==="descending"]})}async subscribeEvent(e){return this.transport.subscribe({method:"suix_subscribeEvent",unsubscribe:"suix_unsubscribeEvent",params:[e.filter],onMessage:e.onMessage})}async subscribeTransaction(e){return this.transport.subscribe({method:"suix_subscribeTransaction",unsubscribe:"suix_unsubscribeTransaction",params:[e.filter],onMessage:e.onMessage})}async devInspectTransactionBlock(e){var n;let r;if(Xs(e.transactionBlock))e.transactionBlock.setSenderIfNotSet(e.sender),r=$(await e.transactionBlock.build({client:this,onlyTransactionKind:!0}));else if(typeof e.transactionBlock=="string")r=e.transactionBlock;else if(e.transactionBlock instanceof Uint8Array)r=$(e.transactionBlock);else throw new Error("Unknown transaction block format.");return await this.transport.request({method:"sui_devInspectTransactionBlock",params:[e.sender,r,(n=e.gasPrice)==null?void 0:n.toString(),e.epoch]})}async dryRunTransactionBlock(e){return await this.transport.request({method:"sui_dryRunTransactionBlock",params:[typeof e.transactionBlock=="string"?e.transactionBlock:$(e.transactionBlock)]})}async getDynamicFields(e){if(!e.parentId||!d.isValidSuiObjectId(d.normalizeSuiObjectId(e.parentId)))throw new Error("Invalid Sui Object id");return await this.transport.request({method:"suix_getDynamicFields",params:[e.parentId,e.cursor,e.limit]})}async getDynamicFieldObject(e){return await this.transport.request({method:"suix_getDynamicFieldObject",params:[e.parentId,e.name]})}async getLatestCheckpointSequenceNumber(){const e=await this.transport.request({method:"sui_getLatestCheckpointSequenceNumber",params:[]});return String(e)}async getCheckpoint(e){return await this.transport.request({method:"sui_getCheckpoint",params:[e.id]})}async getCheckpoints(e){return await this.transport.request({method:"sui_getCheckpoints",params:[e.cursor,e==null?void 0:e.limit,e.descendingOrder]})}async getCommitteeInfo(e){return await this.transport.request({method:"suix_getCommitteeInfo",params:[e==null?void 0:e.epoch]})}async getNetworkMetrics(){return await this.transport.request({method:"suix_getNetworkMetrics",params:[]})}async getAddressMetrics(){return await this.transport.request({method:"suix_getLatestAddressMetrics",params:[]})}async getEpochMetrics(e){return await this.transport.request({method:"suix_getEpochMetrics",params:[e==null?void 0:e.cursor,e==null?void 0:e.limit,e==null?void 0:e.descendingOrder]})}async getAllEpochAddressMetrics(e){return await this.transport.request({method:"suix_getAllEpochAddressMetrics",params:[e==null?void 0:e.descendingOrder]})}async getEpochs(e){return await this.transport.request({method:"suix_getEpochs",params:[e==null?void 0:e.cursor,e==null?void 0:e.limit,e==null?void 0:e.descendingOrder]})}async getMoveCallMetrics(){return await this.transport.request({method:"suix_getMoveCallMetrics",params:[]})}async getCurrentEpoch(){return await this.transport.request({method:"suix_getCurrentEpoch",params:[]})}async getValidatorsApy(){return await this.transport.request({method:"suix_getValidatorsApy",params:[]})}async getChainIdentifier(){const e=await this.getCheckpoint({id:"0"}),r=d.fromB58(e.digest);return ge(r.slice(0,4))}async resolveNameServiceAddress(e){return await this.transport.request({method:"suix_resolveNameServiceAddress",params:[e.name]})}async resolveNameServiceNames(e){return await this.transport.request({method:"suix_resolveNameServiceNames",params:[e.address,e.cursor,e.limit]})}async getProtocolConfig(e){return await this.transport.request({method:"sui_getProtocolConfig",params:[e==null?void 0:e.version]})}async waitForTransactionBlock({signal:e,timeout:r=60*1e3,pollInterval:n=2*1e3,...s}){const i=AbortSignal.timeout(r),a=new Promise((o,u)=>{i.addEventListener("abort",()=>u(i.reason))});for(a.catch(()=>{});!i.aborted;){e==null||e.throwIfAborted();try{return await this.getTransactionBlock(s)}catch{await Promise.race([new Promise(u=>setTimeout(u,n)),a])}}throw i.throwIfAborted(),new Error("Unexpected error while waiting for transaction block.")}}class Xr extends d.ChainContext{}const Tt="Sui",tr=t=>{var r;const e=(r=t.data)==null?void 0:r.content;return e&&e.dataType==="moveObject"?e.fields:null},ti=(t,e)=>{try{return d.normalizeSuiType(t)===d.normalizeSuiType(e)}catch{return!1}},ri=t=>(t==null?void 0:t.type)==="created",ni=t=>(t==null?void 0:t.type)==="published";function si(t){return Array.isArray(t)}function rt(t){return!Array.isArray(t)&&typeof t=="object"&&"fields"in t&&"type"in t}function Yr(t){return typeof t=="object"&&!si(t)&&!rt(t)}function ii(t){return typeof t=="object"&&"id"in t}const ai=16*1024,oi=t=>A.ser("vector<u8>",t,{maxSize:ai}).toBytes(),ci=async(t,e)=>{const{data:r,error:n}=await t.getObject({id:e,options:{showContent:!0}});if(n)throw new Error("Error getting object: "+n);if(!r||!rt(r.content))throw new Error(`Cannot get oject for state id ${e}: `+r);return d.getPackageIdFromType(r.content.type)},Qr=async(t,e)=>{if(!d.isValidSuiAddress(e))throw new Error(`Invalid object ID: ${e}`);const r=await t.getObject({id:e,options:{showContent:!0}});return tr(r)},ui=async(t,e)=>{let r,n;do{const a=await t.getDynamicFields({parentId:e,cursor:n});r=a.data.find(o=>o.name.type.endsWith("CurrentPackage")),n=a.hasNextPage?a.nextCursor:null}while(n&&!r);if(!r)throw new Error("CurrentPackage not found");const s=await t.getObject({id:r.objectId,options:{showContent:!0}}),i=tr(s);if(!i||!Yr(i))throw new Error("Unable to get fields from object response");if(!("value"in i)||!rt(i.value))throw new Error("Unable to get package id");return i.value.fields.package},di=async(t,e,r)=>{let n=null,s=null,i=null,a;do{if(i=await t.getOwnedObjects({owner:r,filter:{StructType:`${e}::emitter::EmitterCap`},options:{showContent:!0},cursor:a}),!i||!i.data)throw Error("Failed to get owned objects");for(const o of i.data){if(!o.data)continue;const{version:u,objectId:l}=o.data;(n===null||u<n)&&(n=u,s=l)}a=i.hasNextPage?i.nextCursor:void 0}while(a);return s},li=async(t,e)=>{const r=new Ys,[n]=r.publish({modules:t.modules.map(s=>Array.from(d.b64.decode(s))),dependencies:t.dependencies.map(s=>d.normalizeSuiObjectId(s))});return r.transferObjects([n],r.pure(e)),r},Q=class Q extends d.PlatformContext{constructor(e,r){super(e,r??d.networkPlatformConfigs(e,Q._platform))}getRpc(e){if(e in this.config)return new ei({url:this.config[e].rpc});throw new Error("No configuration available for chain: "+e)}getChain(e){if(e in this.config)return new Xr(e,this);throw new Error("No configuration available for chain: "+e)}static nativeTokenId(e,r){if(!Q.isSupportedChain(r))throw new Error(`invalid chain for ${Tt}: ${r}`);return d.Wormhole.tokenId(r,d.SUI_COIN)}static isNativeTokenId(e,r,n){return!Q.isSupportedChain(r)||n.chain!==r?!1:this.nativeTokenId(e,r)===n}static isSupportedChain(e){return d.chainToPlatform(e)===Q._platform}static async getDecimals(e,r,n){if(d.isNative(n))return d.nativeDecimals(Q._platform);const s=new d.SuiAddress(n);try{const a=await Qr(r,s.toString());if(a&&"decimals"in a)return a.decimals}catch{}const i=await r.getCoinMetadata({coinType:s.getCoinType()});if(i===null)throw new Error(`Can't fetch decimals for token ${s.toString()}`);return i.decimals}static async getCoins(e,r,n){let s=[],i=null;const a=new d.SuiAddress(r).toString();do{const o=await e.getCoins({owner:a,coinType:n,cursor:i});s=[...s,...o.data],i=o.hasNextPage?o.nextCursor:null}while(i);return s}static async getBalance(e,r,n,s){if(d.isNative(s)){const{totalBalance:a}=await r.getBalance({owner:n});return BigInt(a)}const{totalBalance:i}=await r.getBalance({owner:n,coinType:s.toString()});return BigInt(i)}static async getBalances(e,r,n,s){return(await Promise.all(s.map(async a=>{const o=await this.getBalance(e,r,n,a);return{[d.isNative(a)?"native":new d.SuiAddress(a).toString()]:o}}))).reduce((a,o)=>Object.assign(a,o),{})}static async sendWait(e,r,n){const s=[];for(const i of n){const a=await r.executeTransactionBlock(i);await r.waitForTransactionBlock({digest:a.digest}),s.push(a.digest)}return s}static async getLatestBlock(e){return Number(await e.getLatestCheckpointSequenceNumber())}static async getLatestFinalizedBlock(e){return this.getLatestBlock(e)}static chainFromChainId(e){const r=d.platformNativeChainIdToNetworkChain(Q._platform,e);if(r===void 0)throw new Error(`Unknown native chain id ${e}`);const[n,s]=r;return[n,s]}static async chainFromRpc(e){const r=await e.call("sui_getChainIdentifier",[]);return this.chainFromChainId(r)}};pe(Q,"_platform",Tt);let Ee=Q;var Ne={};Object.defineProperty(Ne,"__esModule",{value:!0});Ne.bech32m=Et=Ne.bech32=void 0;const tt="qpzry9x8gf2tvdw0s3jn54khce6mua7l",en={};for(let t=0;t<tt.length;t++){const e=tt.charAt(t);en[e]=t}function Te(t){const e=t>>25;return(t&33554431)<<5^-(e>>0&1)&996825010^-(e>>1&1)&642813549^-(e>>2&1)&513874426^-(e>>3&1)&1027748829^-(e>>4&1)&705979059}function cr(t){let e=1;for(let r=0;r<t.length;++r){const n=t.charCodeAt(r);if(n<33||n>126)return"Invalid prefix ("+t+")";e=Te(e)^n>>5}e=Te(e);for(let r=0;r<t.length;++r){const n=t.charCodeAt(r);e=Te(e)^n&31}return e}function rr(t,e,r,n){let s=0,i=0;const a=(1<<r)-1,o=[];for(let u=0;u<t.length;++u)for(s=s<<e|t[u],i+=e;i>=r;)i-=r,o.push(s>>i&a);if(n)i>0&&o.push(s<<r-i&a);else{if(i>=e)return"Excess padding";if(s<<r-i&a)return"Non-zero padding"}return o}function fi(t){return rr(t,8,5,!0)}function hi(t){const e=rr(t,5,8,!1);if(Array.isArray(e))return e}function gi(t){const e=rr(t,5,8,!1);if(Array.isArray(e))return e;throw new Error(e)}function tn(t){let e;t==="bech32"?e=1:e=734539939;function r(a,o,u){if(u=u||90,a.length+7+o.length>u)throw new TypeError("Exceeds length limit");a=a.toLowerCase();let l=cr(a);if(typeof l=="string")throw new Error(l);let h=a+"1";for(let p=0;p<o.length;++p){const y=o[p];if(y>>5)throw new Error("Non 5-bit word");l=Te(l)^y,h+=tt.charAt(y)}for(let p=0;p<6;++p)l=Te(l);l^=e;for(let p=0;p<6;++p){const y=l>>(5-p)*5&31;h+=tt.charAt(y)}return h}function n(a,o){if(o=o||90,a.length<8)return a+" too short";if(a.length>o)return"Exceeds length limit";const u=a.toLowerCase(),l=a.toUpperCase();if(a!==u&&a!==l)return"Mixed-case string "+a;a=u;const h=a.lastIndexOf("1");if(h===-1)return"No separator character for "+a;if(h===0)return"Missing prefix for "+a;const p=a.slice(0,h),y=a.slice(h+1);if(y.length<6)return"Data too short";let m=cr(p);if(typeof m=="string")return m;const x=[];for(let T=0;T<y.length;++T){const C=y.charAt(T),M=en[C];if(M===void 0)return"Unknown character "+C;m=Te(m)^M,!(T+6>=y.length)&&x.push(M)}return m!==e?"Invalid checksum for "+a:{prefix:p,words:x}}function s(a,o){const u=n(a,o);if(typeof u=="object")return u}function i(a,o){const u=n(a,o);if(typeof u=="object")return u;throw new Error(u)}return{decodeUnsafe:s,decode:i,encode:r,toWords:fi,fromWordsUnsafe:hi,fromWords:gi}}var Et=Ne.bech32=tn("bech32");Ne.bech32m=tn("bech32m");var $e=(t=>(t[t.TransactionData=0]="TransactionData",t[t.TransactionEffects=1]="TransactionEffects",t[t.CheckpointSummary=2]="CheckpointSummary",t[t.PersonalMessage=3]="PersonalMessage",t))($e||{});function pi(t){return[t,0,0]}function rn(t,e){const r=pi(t),n=new Uint8Array(r.length+e.length);return n.set(r),n.set(e,r.length),n}const nt={ED25519:0,Secp256k1:1,Secp256r1:2,MultiSig:3,ZkLogin:5},yi={ED25519:32,Secp256k1:33,Secp256r1:33},mi={0:"ED25519",1:"Secp256k1",2:"Secp256r1",3:"MultiSig",5:"ZkLogin"};function wi(t){for(let e=0;e<t.length;e++)if(t[e]!==0)return e;return-1}function bi(t,e){const r=t.toString(16);return d.hexToBytes(r.padStart(e*2,"0").slice(-e*2))}function Si(t,e){const r=bi(t,e),n=wi(r);return n===-1?new Uint8Array([0]):r.slice(n)}function Ti(t,e){const r=Si(t,32);e==="accounts.google.com"&&(e="https://accounts.google.com");const n=new TextEncoder().encode(e),s=new Uint8Array(2+r.length+n.length);return s.set([nt.ZkLogin]),s.set([n.length],1),s.set(n,2),s.set(r,2+n.length),d.normalizeSuiAddress(d.bytesToHex(d.blake2b(s,{dkLen:32})).slice(0,d.SUI_ADDRESS_LENGTH*2))}function Ei(t){if(t.length!==1)throw new Error("Invalid base64Url character: "+t);const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".indexOf(t);if(r===-1)throw new Error("Invalid base64Url character: "+t);const n=r.toString(2).padStart(6,"0");return Array.from(n).map(Number)}function vi(t){let e=[];for(let r=0;r<t.length;r++){const n=t.charAt(r),s=Ei(n);e=e.concat(s)}return e}function ki(t,e){if(t.length<2)throw new Error(`Input (s = ${t}) is not tightly packed because s.length < 2`);let r=vi(t);const n=e%4;if(n!==0)if(n===1)r=r.slice(2);else if(n===2)r=r.slice(4);else throw new Error(`Input (s = ${t}) is not tightly packed because i%4 = 3 (i = ${e}))`);const s=(e+t.length-1)%4;if(s!==3)if(s===2)r=r.slice(0,r.length-2);else if(s===1)r=r.slice(0,r.length-4);else throw new Error(`Input (s = ${t}) is not tightly packed because (i + s.length - 1)%4 = 0 (i = ${e}))`);if(r.length%8!==0)throw new Error("We should never reach here...");const i=new Uint8Array(Math.floor(r.length/8));let a=0;for(let o=0;o<r.length;o+=8){const u=r.slice(o,o+8),l=parseInt(u.join(""),2);i[a++]=l}return new TextDecoder().decode(i)}function xi(t){if(!(t.slice(-1)==="}"||t.slice(-1)===","))throw new Error("Invalid claim");const e=JSON.parse("{"+t.slice(0,-1)+"}");if(Object.keys(e).length!==1)throw new Error("Invalid claim");const r=Object.keys(e)[0];return[r,e[r]]}function Ii(t,e){const r=ki(t.value,t.indexMod4),[n,s]=xi(r);if(n!==e)throw new Error(`Invalid field name: found ${n} expected ${e}`);return s}const _i=c.struct("ZkLoginSignature",{inputs:c.struct("ZkLoginSignatureInputs",{proofPoints:c.struct("ZkLoginSignatureInputsProofPoints",{a:c.vector(c.string()),b:c.vector(c.vector(c.string())),c:c.vector(c.string())}),issBase64Details:c.struct("ZkLoginSignatureInputsClaim",{value:c.string(),indexMod4:c.u8()}),headerBase64:c.string(),addressSeed:c.string()}),maxEpoch:c.u64(),userSignature:c.vector(c.u8())});function Ai(t){return _i.parse(typeof t=="string"?H(t):t)}function Oi({signature:t,signatureScheme:e,publicKey:r}){if(!r)throw new Error("`publicKey` is required");const n=r.toRawBytes(),s=new Uint8Array(1+t.length+n.length);return s.set([nt[e]]),s.set(t,1),s.set(n,1+t.length),$(s)}function ji(t){const e=H(t),r=mi[e[0]];switch(r){case"MultiSig":const n=A.MultiSig.parse(e.slice(1));return{serializedSignature:t,signatureScheme:r,multisig:n,bytes:e};case"ZkLogin":const s=e.slice(1),{inputs:i,maxEpoch:a,userSignature:o}=Ai(s),{issBase64Details:u,addressSeed:l}=i,h=Ii(u,"iss"),p=Ti(BigInt(l),h);return{serializedSignature:t,signatureScheme:r,zkLogin:{inputs:i,maxEpoch:a,userSignature:o,iss:h,address:p,addressSeed:BigInt(l)},signature:e};case"ED25519":case"Secp256k1":case"Secp256r1":const y=yi[r],m=e.slice(1,e.length-y),x=e.slice(1+m.length);return{serializedSignature:t,signatureScheme:r,signature:m,publicKey:x,bytes:e};default:throw new Error("Unsupported signature scheme")}}const He=32,Ci="suiprivkey";class Bi{async signWithIntent(e,r){const n=rn(r,e),s=d.blake2b(n,{dkLen:32});return{signature:Oi({signature:await this.sign(s),signatureScheme:this.getKeyScheme(),publicKey:this.getPublicKey()}),bytes:$(e)}}async signTransactionBlock(e){return this.signWithIntent(e,$e.TransactionData)}async signPersonalMessage(e){return this.signWithIntent(c.vector(c.u8()).serialize(e).toBytes(),$e.PersonalMessage)}toSuiAddress(){return this.getPublicKey().toSuiAddress()}}class Mi extends Bi{export(){return{schema:this.getKeyScheme(),privateKey:this.getSecretKey()}}}function Pi(t,e){if(t.length!==He)throw new Error("Invalid bytes length");const r=nt[e],n=new Uint8Array(t.length+1);return n.set([r]),n.set(t,1),Et.encode(Ci,Et.toWords(n))}function ur(t){return!!new RegExp("^m\\/44'\\/784'\\/[0-9]+'\\/[0-9]+'\\/[0-9]+'+$").test(t)}function Ri(t){return An(t,"")}function Ni(t){return ge(Ri(t))}const $i="ed25519 seed",Ui=2147483648,Di=new RegExp("^m(\\/[0-9]+')+$"),nn=t=>t.replace("'",""),zi=t=>{const r=d.hmac.create(d.sha512,$i).update(Ue(t)).digest(),n=r.slice(0,32),s=r.slice(32);return{key:n,chainCode:s}},Vi=({key:t,chainCode:e},r)=>{const n=new ArrayBuffer(4);new DataView(n).setUint32(0,r);const i=new Uint8Array(1+t.length+n.byteLength);i.set(new Uint8Array(1).fill(0)),i.set(t,1),i.set(new Uint8Array(n,0,n.byteLength),t.length+1);const a=d.hmac.create(d.sha512,e).update(i).digest(),o=a.slice(0,32),u=a.slice(32);return{key:o,chainCode:u}},Li=t=>Di.test(t)?!t.split("/").slice(1).map(nn).some(isNaN):!1,dr=(t,e,r=Ui)=>{if(!Li(t))throw new Error("Invalid derivation path");const{key:n,chainCode:s}=zi(e);return t.split("/").slice(1).map(nn).map(a=>parseInt(a,10)).reduce((a,o)=>Vi(a,o+r),{key:n,chainCode:s})};function sn(t,e){if(t===e)return!0;if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[r])return!1;return!0}class qi{equals(e){return sn(this.toRawBytes(),e.toRawBytes())}toBase64(){return $(this.toRawBytes())}toString(){throw new Error("`toString` is not implemented on public keys. Use `toBase64()` or `toRawBytes()` instead.")}toSuiPublicKey(){const e=this.toSuiBytes();return $(e)}verifyWithIntent(e,r,n){const s=rn(n,e),i=d.blake2b(s,{dkLen:32});return this.verify(i,r)}verifyPersonalMessage(e,r){return this.verifyWithIntent(A.vector(A.u8()).serialize(e).toBytes(),r,$e.PersonalMessage)}verifyTransactionBlock(e,r){return this.verifyWithIntent(e,r,$e.TransactionData)}toSuiBytes(){const e=this.toRawBytes(),r=new Uint8Array(e.length+1);return r.set([this.flag()]),r.set(e,1),r}toSuiAddress(){return d.normalizeSuiAddress(d.bytesToHex(d.blake2b(this.toSuiBytes(),{dkLen:32})).slice(0,d.SUI_ADDRESS_LENGTH*2))}}const vt=32;class an extends qi{constructor(e){if(super(),typeof e=="string"?this.data=H(e):e instanceof Uint8Array?this.data=e:this.data=Uint8Array.from(e),this.data.length!==vt)throw new Error(`Invalid public key input. Expected ${vt} bytes, got ${this.data.length}`)}equals(e){return super.equals(e)}toRawBytes(){return this.data}flag(){return nt.ED25519}async verify(e,r){let n;if(typeof r=="string"){const s=ji(r);if(s.signatureScheme!=="ED25519")throw new Error("Invalid signature scheme");if(!sn(this.toRawBytes(),s.publicKey))throw new Error("Signature does not match public key");n=s.signature}else n=r;return d.nacl2.sign.detached.verify(e,n,this.toRawBytes())}}an.SIZE=vt;const lr="m/44'/784'/0'/0'/0'";class me extends Mi{constructor(e){super(),e?this.keypair=e:this.keypair=d.nacl2.sign.keyPair()}getKeyScheme(){return"ED25519"}static generate(){return new me(d.nacl2.sign.keyPair())}static fromSecretKey(e,r){const n=e.length;if(n!==He)throw new Error(`Wrong secretKey size. Expected ${He} bytes, got ${n}.`);const s=d.nacl2.sign.keyPair.fromSeed(e);if(!r||!r.skipValidation){const a=new TextEncoder().encode("sui validation"),o=d.nacl2.sign.detached(a,s.secretKey);if(!d.nacl2.sign.detached.verify(a,o,s.publicKey))throw new Error("provided secretKey is invalid")}return new me(s)}getPublicKey(){return new an(this.keypair.publicKey)}getSecretKey(){return Pi(this.keypair.secretKey.slice(0,He),this.getKeyScheme())}async sign(e){return this.signData(e)}signData(e){return d.nacl2.sign.detached(e,this.keypair.secretKey)}static deriveKeypair(e,r){if(r==null&&(r=lr),!ur(r))throw new Error("Invalid derivation path");const{key:n}=dr(r,Ni(e));return me.fromSecretKey(n)}static deriveKeypairFromSeed(e,r){if(r==null&&(r=lr),!ur(r))throw new Error("Invalid derivation path");const{key:n}=dr(r,e);return me.fromSecretKey(n)}}async function Wi(t,e){const[,r]=await Ee.chainFromRpc(t);return new Fi(r,t,me.deriveKeypair(e,"m/44'/784'/0'/0'/0'"))}class Fi{constructor(e,r,n,s){pe(this,"_chain");pe(this,"_client");pe(this,"_signer");pe(this,"_debug");this._chain=e,this._client=r,this._signer=n,this._debug=s}chain(){return this._chain}address(){return this._signer.toSuiAddress()}async signAndSend(e){const r=[];for(const n of e){const{description:s,transaction:i}=n;this._debug&&console.log(`Signing ${s} for ${this.address()}`);try{const a=await this._client.signAndExecuteTransactionBlock({transactionBlock:i,signer:this._signer});r.push(a.digest)}catch(a){throw a}}return r}}const Ki={Address:d.SuiAddress,Platform:Ee,getSigner:Wi,protocols:{WormholeCore:()=>Promise.resolve().then(()=>require("./index-B5TmFc4M.js")),TokenBridge:()=>Promise.resolve().then(()=>require("./index-Dk2OkATw.js"))},getChain:(t,e,r)=>new Xr(e,new Ee(t,d.applyChainsConfigConfigOverrides(t,Tt,{[e]:r})))},Gi=Object.freeze(Object.defineProperty({__proto__:null,default:Ki},Symbol.toStringTag,{value:"Module"}));exports.SuiPlatform=Ee;exports.getFieldsFromObjectResponse=tr;exports.getObjectFields=Qr;exports.getOldestEmitterCapObjectId=di;exports.getOriginalPackageId=ci;exports.getPackageId=ui;exports.isMoveStructId=ii;exports.isMoveStructObject=Yr;exports.isMoveStructStruct=rt;exports.isSameType=ti;exports.isSuiCreateEvent=ri;exports.isSuiPublishEvent=ni;exports.publishPackage=li;exports.sui=Gi;exports.uint8ArrayToBCS=oi;