@stakekit/widget 0.0.287 → 0.0.289

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 (89) hide show
  1. package/dist/bundle/Result-D66k67e4.js +3 -0
  2. package/dist/bundle/Schema-CnO1Nnkx.js +2 -0
  3. package/dist/bundle/{cardano-connector-Cg1NVNSz.js → cardano-connector-BdmhtPwK.js} +1 -1
  4. package/dist/{website/assets/configured-chains-C5lih9lm.js → bundle/configured-chains-BVaAJPl7.js} +1 -1
  5. package/dist/bundle/{cosmos-connector-meta-B3hXlZyj.js → cosmos-connector-meta-CsjY5xv_.js} +1 -1
  6. package/dist/bundle/{current-value-stream-sEIwrVMJ.js → current-value-stream-BphKxe9G.js} +1 -1
  7. package/dist/bundle/{esm-B8ixy8Ti.js → esm-BioWy-zm.js} +1 -1
  8. package/dist/bundle/index.bundle.css +1 -1
  9. package/dist/bundle/index.bundle.js +132 -100
  10. package/dist/bundle/{ledger-connector-ScKbHFK2.js → ledger-connector-BeFXqMQm.js} +2 -2
  11. package/dist/bundle/{network-DRjEa3NO.js → network-BR2dx0lQ.js} +1 -1
  12. package/dist/bundle/{polkadot-ledger-transaction-CSI9csNM.js → polkadot-ledger-transaction-CCpzhicj.js} +1 -1
  13. package/dist/bundle/{safe-connector-BuI_vM2N.js → safe-connector-BW8tBAGV.js} +1 -1
  14. package/dist/bundle/{solana-connector-BXIkWGi1.js → solana-connector-CEoNnJWx.js} +1 -1
  15. package/dist/bundle/{stellar-connector-D5G2p6aO.js → stellar-connector-C3GFN35d.js} +1 -1
  16. package/dist/bundle/{substrate-connector-AJ6EWjQP.js → substrate-connector-B7COXHL7.js} +1 -1
  17. package/dist/{website/assets/ton-connector-DWz2WVCw.js → bundle/ton-connector-DnPSYtXm.js} +1 -1
  18. package/dist/bundle/transaction-3CLRKFvX.js +1 -0
  19. package/dist/{website/assets/transaction-BJ3RmuAw.js → bundle/transaction-BDuN1rLk.js} +2 -2
  20. package/dist/bundle/{transaction-NX-vBbnh.js → transaction-DU8AaOQz.js} +1 -1
  21. package/dist/bundle/{tron-connector-nZfhLwx4.js → tron-connector-iA7bb0__.js} +1 -1
  22. package/dist/bundle/{utils-CfBIlQsz.js → utils-llPzGe7v.js} +1 -1
  23. package/dist/bundle/wagmi-connect-result-DOu6hDDM.js +11 -0
  24. package/dist/bundle/{wallet-errors-Bvwwydi9.js → wallet-errors-MrbcJr3I.js} +1 -1
  25. package/dist/bundle/{wallet-manager-C-MB05Qs.js → wallet-manager-D2AeCPRs.js} +2 -2
  26. package/dist/package/{Result-Cem4lYBf.js → Result-BA6lrqKV.js} +117 -49
  27. package/dist/package/{Schema-DFoi51wt.js → Schema-CUut1r-H.js} +1135 -1310
  28. package/dist/package/{cardano-connector-B9UToMFP.js → cardano-connector-ApyBIRYL.js} +3 -3
  29. package/dist/package/{configured-chains-BfQ8ESmR.js → configured-chains-CeRB7Tdy.js} +1 -1
  30. package/dist/package/{cosmos-connector-meta-UMFrkViG.js → cosmos-connector-meta-NNACISY5.js} +1 -1
  31. package/dist/package/{current-value-stream-BPaLLDf4.js → current-value-stream-Cs2IFPhP.js} +1 -1
  32. package/dist/package/{esm-89IrCtWy.js → esm-3BtHXmV9.js} +1 -1
  33. package/dist/package/index.package.css +31 -10
  34. package/dist/package/index.package.js +8695 -3962
  35. package/dist/package/{ledger-connector-B8D8xJOD.js → ledger-connector-ebEnv7IA.js} +9 -9
  36. package/dist/package/{network-DiYap-9L.js → network-Df21Fcdz.js} +1 -1
  37. package/dist/package/{polkadot-ledger-transaction-Bi14PyTF.js → polkadot-ledger-transaction-Cq_ImU8s.js} +1 -1
  38. package/dist/package/{safe-connector-lVCS_bS5.js → safe-connector-CMgopygU.js} +4 -4
  39. package/dist/package/{solana-connector-P-TqgNNC.js → solana-connector-B2Rf5Tyj.js} +3 -3
  40. package/dist/package/{stellar-connector-BMB2Cql4.js → stellar-connector-DdzqZgoG.js} +4 -4
  41. package/dist/package/{substrate-connector-a7SNpKjf.js → substrate-connector-DO7OAvZ9.js} +2 -2
  42. package/dist/package/{ton-connector-CMzOI2bi.js → ton-connector-CUtYVysK.js} +5 -5
  43. package/dist/package/{transaction-CmOScFm6.js → transaction-BjGgdyu0.js} +5 -5
  44. package/dist/package/{transaction-Do9wZHM8.js → transaction-MMiSjtGI.js} +1 -1
  45. package/dist/package/{transaction-C1e6h8J1.js → transaction-fIZimEky.js} +1 -1
  46. package/dist/package/{tron-connector-PLpMhB65.js → tron-connector-DT1NdAaP.js} +2 -2
  47. package/dist/package/{wagmi-connect-result-BJ91_jis.js → wagmi-connect-result-Bh6qH5iI.js} +593 -462
  48. package/dist/package/{wallet-errors-B4cGcGNy.js → wallet-errors-BMdJQ_kv.js} +1 -1
  49. package/dist/package/{wallet-manager-BsDss9DQ.js → wallet-manager-BbL7EBi6.js} +5 -5
  50. package/dist/types/domain/network/network.d.ts +2 -2
  51. package/dist/types/generated/api/legacy-schema.d.ts +3503 -1952
  52. package/dist/types/generated/api/yield-schema.d.ts +1491 -1114
  53. package/dist/types/public-api/types.d.ts +2 -2
  54. package/dist/website/assets/Result-D66k67e4.js +3 -0
  55. package/dist/website/assets/Schema-CnO1Nnkx.js +2 -0
  56. package/dist/website/assets/{cardano-connector-JluaLQJr.js → cardano-connector-DkgQsbib.js} +1 -1
  57. package/dist/{bundle/configured-chains-C5lih9lm.js → website/assets/configured-chains-BVaAJPl7.js} +1 -1
  58. package/dist/website/assets/{cosmos-connector-meta-B3hXlZyj.js → cosmos-connector-meta-CsjY5xv_.js} +1 -1
  59. package/dist/website/assets/{current-value-stream-sEIwrVMJ.js → current-value-stream-BphKxe9G.js} +1 -1
  60. package/dist/website/assets/{esm-DmRWC3up.js → esm-DJUTv1_r.js} +1 -1
  61. package/dist/website/assets/index-BYTj9y8r.js +592 -0
  62. package/dist/website/assets/{index-CYwddl65.css → index-m2lpHJ_u.css} +1 -1
  63. package/dist/website/assets/{ledger-connector-zHWvy_21.js → ledger-connector-CMFH1Z0M.js} +3 -3
  64. package/dist/website/assets/{network-DRjEa3NO.js → network-BR2dx0lQ.js} +1 -1
  65. package/dist/website/assets/{polkadot-ledger-transaction-CSI9csNM.js → polkadot-ledger-transaction-CCpzhicj.js} +1 -1
  66. package/dist/website/assets/{safe-connector-B_IWbdsx.js → safe-connector-BDc3OqKV.js} +1 -1
  67. package/dist/website/assets/{solana-connector-DUrUEFXI.js → solana-connector-Ij-Dm1HM.js} +1 -1
  68. package/dist/website/assets/{stellar-connector-D5G2p6aO.js → stellar-connector-C3GFN35d.js} +1 -1
  69. package/dist/website/assets/{substrate-connector-DxgYUQY4.js → substrate-connector-B-LTNtpz.js} +1 -1
  70. package/dist/{bundle/ton-connector-DWz2WVCw.js → website/assets/ton-connector-DnPSYtXm.js} +1 -1
  71. package/dist/{bundle/transaction-BJ3RmuAw.js → website/assets/transaction-BDuN1rLk.js} +2 -2
  72. package/dist/website/assets/{transaction-BIBBEBi6.js → transaction-Cth5mVGJ.js} +1 -1
  73. package/dist/website/assets/transaction-peV0IJTV.js +1 -0
  74. package/dist/website/assets/{tron-connector-C3nKPxdx.js → tron-connector-D_NeRPfc.js} +1 -1
  75. package/dist/website/assets/{utils-DVCp0qSW.js → utils-DOZR2zEE.js} +1 -1
  76. package/dist/website/assets/wagmi-connect-result-DOu6hDDM.js +11 -0
  77. package/dist/website/assets/{wallet-errors-Bvwwydi9.js → wallet-errors-MrbcJr3I.js} +1 -1
  78. package/dist/website/assets/{wallet-manager-9-XcN6SR.js → wallet-manager-DGQAWJIz.js} +3 -3
  79. package/dist/website/index.html +13 -13
  80. package/package.json +12 -11
  81. package/dist/bundle/Result-3MQjLy1V.js +0 -3
  82. package/dist/bundle/Schema-DgreXIef.js +0 -2
  83. package/dist/bundle/transaction-BnkP6nIP.js +0 -1
  84. package/dist/bundle/wagmi-connect-result-CqXaJhOa.js +0 -11
  85. package/dist/website/assets/Result-3MQjLy1V.js +0 -3
  86. package/dist/website/assets/Schema-DgreXIef.js +0 -2
  87. package/dist/website/assets/index-CbH5OQ2T.js +0 -560
  88. package/dist/website/assets/transaction-Sqg4_vo7.js +0 -1
  89. package/dist/website/assets/wagmi-connect-result-CqXaJhOa.js +0 -11
@@ -1,5 +1,5 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/basic-PXrgAeL2.js","assets/rolldown-runtime-BcKkbAw3.js","assets/exports-CeDbIN9g.js","assets/dist-C9i0DjyB.js","assets/dist-D6L6gF64.js","assets/_esm-DNvytb5d.js","assets/preload-helper-Czpn1I53.js","assets/ccip-B_AhQiTz.js","assets/sha3-DTWsE4Uo.js","assets/_u64-DvzUbHl5.js","assets/sha256-B81eAX-m.js","assets/hmac-DLdeyits.js","assets/secp256k1-BAgBRavp.js","assets/dist-KkMRwAp9.js","assets/elliptic-BkWObsOB.js","assets/bn-F_BR-QG7.js","assets/events-D2w4OsQJ.js","assets/has-property-descriptors-BgbN2I7Y.js","assets/esm-DhvlA6gG.js","assets/index.es-6FknJabw.js","assets/browser-ponyfill-8IsXQqGl.js","assets/index.es-DqXS4GHm.js","assets/quick-format-unescaped-1XDtDA5D.js","assets/src-CHcFzXUJ.js","assets/utils-Br0svb7K.js","assets/index.es-B-vaqu71.js","assets/big-BfyPLUzq.js","assets/utils-CXyOXcxm.js","assets/lit-element-Bu7U205x.js","assets/lit-CEhUywSr.js","assets/ConnectorUtil-BpVhiuM2.js","assets/wui-text-G1pFTKhY.js","assets/class-map-TXrFtM6H.js","assets/until-DDsx909N.js","assets/async-directive-otRSpNLh.js","assets/browser-CjvShX69.js","assets/dijkstra-Drfl93V4.js","assets/ref-B9vJPGGM.js","assets/w3m-modal-CIkt2Oiw.js"])))=>i.map(i=>d[i]);
2
- import{n as e,o as t,r as n,s as r,t as i}from"./rolldown-runtime-BcKkbAw3.js";import{n as a,t as o}from"./dist-C9i0DjyB.js";import{C as s}from"./Schema-DgreXIef.js";import{n as c,t as l}from"./dist-D6L6gF64.js";import{t as u}from"./preload-helper-Czpn1I53.js";import{n as d}from"./_esm-DNvytb5d.js";import{vn as f}from"./ccip-B_AhQiTz.js";import{n as p,t as m}from"./sha256-B81eAX-m.js";import{n as h,t as g}from"./sha3-DTWsE4Uo.js";import{n as _,r as v,t as y}from"./dist-KkMRwAp9.js";import{t as ee}from"./fallback-hOVnOuYU.js";import{n as te,t as ne}from"./ed25519-0TVA-MrV.js";import{n as re,t as b}from"./bn-F_BR-QG7.js";import{t as x}from"./elliptic-BkWObsOB.js";import{t as S}from"./bs58-Cepc0rNH.js";import{n as C,t as w}from"./secp256k1-KrmNoC0i.js";import{t as T}from"./esm-DhvlA6gG.js";import{t as E}from"./events-D2w4OsQJ.js";import{a as ie,c as ae,d as oe,f as D,i as se,l as ce,o as le,r as ue,s as de,t as fe,u as pe}from"./index.es-6FknJabw.js";import{_ as me,a as O,d as he,f as ge,g as _e,h as ve,i as ye,l as be,n as xe,o as Se,p as Ce,r as we,s as Te,u as Ee,v as De}from"./browser-ponyfill-8IsXQqGl.js";import{a as Oe,i as ke,n as Ae,r as je,t as Me}from"./index.es-DqXS4GHm.js";import{i as Ne,n as Pe,r as Fe,t as Ie}from"./src-CHcFzXUJ.js";import{t as Le}from"./index.es-B-vaqu71.js";import{A as Re,C as k,D as ze,E as Be,O as Ve,S as He,_ as Ue,a as We,c as Ge,d as A,f as Ke,g as qe,h as Je,k as j,l as M,m as Ye,o as Xe,p as Ze,u as Qe,v as $e,w as et,x as tt,y as nt}from"./exports-CeDbIN9g.js";import{i as rt,n as it,o as at,r as ot}from"./utils-CXyOXcxm.js";import{i as st,n as ct,r as lt}from"./ConnectorUtil-BpVhiuM2.js";var ut=i(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=`~`;function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(r=!1));function a(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(e,t,n,i,o){if(typeof n!=`function`)throw TypeError(`The listener must be a function`);var s=new a(n,i||e,o),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],s]:e._events[c].push(s):(e._events[c]=s,e._eventsCount++),e}function s(e,t){--e._eventsCount===0?e._events=new i:delete e._events[t]}function c(){this._events=new i,this._eventsCount=0}c.prototype.eventNames=function(){var e=[],t,i;if(this._eventsCount===0)return e;for(i in t=this._events)n.call(t,i)&&e.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e},c.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,a=n.length,o=Array(a);i<a;i++)o[i]=n[i].fn;return o},c.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},c.prototype.emit=function(e,t,n,i,a,o){var s=r?r+e:e;if(!this._events[s])return!1;var c=this._events[s],l=arguments.length,u,d;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,i),!0;case 5:return c.fn.call(c.context,t,n,i,a),!0;case 6:return c.fn.call(c.context,t,n,i,a,o),!0}for(d=1,u=Array(l-1);d<l;d++)u[d-1]=arguments[d];c.fn.apply(c.context,u)}else{var f=c.length,p;for(d=0;d<f;d++)switch(c[d].once&&this.removeListener(e,c[d].fn,void 0,!0),l){case 1:c[d].fn.call(c[d].context);break;case 2:c[d].fn.call(c[d].context,t);break;case 3:c[d].fn.call(c[d].context,t,n);break;case 4:c[d].fn.call(c[d].context,t,n,i);break;default:if(!u)for(p=1,u=Array(l-1);p<l;p++)u[p-1]=arguments[p];c[d].fn.apply(c[d].context,u)}}return!0},c.prototype.on=function(e,t,n){return o(this,e,t,n,!1)},c.prototype.once=function(e,t,n){return o(this,e,t,n,!0)},c.prototype.removeListener=function(e,t,n,i){var a=r?r+e:e;if(!this._events[a])return this;if(!t)return s(this,a),this;var o=this._events[a];if(o.fn)o.fn===t&&(!i||o.once)&&(!n||o.context===n)&&s(this,a);else{for(var c=0,l=[],u=o.length;c<u;c++)(o[c].fn!==t||i&&!o[c].once||n&&o[c].context!==n)&&l.push(o[c]);l.length?this._events[a]=l.length===1?l[0]:l:s(this,a)}return this},c.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&s(this,t)):(this._events=new i,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=r,c.EventEmitter=c,t!==void 0&&(t.exports=c)})),dt,ft,pt=e((()=>{dt=r(ut(),1),ft=dt.default}));pt();var mt=class extends Error{constructor(e,t){super(e),this.error=t}},ht=class extends mt{constructor(){super(...arguments),this.name=`WalletNotReadyError`}},gt=class extends mt{constructor(){super(...arguments),this.name=`WalletConfigError`}},_t=class extends mt{constructor(){super(...arguments),this.name=`WalletConnectionError`}},vt=class extends mt{constructor(){super(...arguments),this.name=`WalletDisconnectedError`}},yt=class extends mt{constructor(){super(...arguments),this.name=`WalletDisconnectionError`}},bt=class extends mt{constructor(){super(...arguments),this.name=`WalletAccountError`}},xt=class extends mt{constructor(){super(...arguments),this.name=`WalletPublicKeyError`}},St=class extends mt{constructor(){super(...arguments),this.name=`WalletNotConnectedError`}},Ct=class extends mt{constructor(){super(...arguments),this.name=`WalletSendTransactionError`}},wt=class extends mt{constructor(){super(...arguments),this.name=`WalletSignTransactionError`}},Tt=class extends mt{constructor(){super(...arguments),this.name=`WalletSignMessageError`}},Et=class extends mt{constructor(){super(...arguments),this.name=`WalletSignInError`}},Dt=class extends mt{constructor(){super(...arguments),this.name=`WalletWindowClosedError`}},Ot;(function(e){e.Installed=`Installed`,e.NotDetected=`NotDetected`,e.Loadable=`Loadable`,e.Unsupported=`Unsupported`})(Ot||={});var kt=class extends ft{get connected(){return!!this.publicKey}async autoConnect(){await this.connect()}async prepareTransaction(e,t,n={}){let r=this.publicKey;if(!r)throw new St;return e.feePayer=e.feePayer||r,e.recentBlockhash=e.recentBlockhash||(await t.getLatestBlockhash({commitment:n.preflightCommitment,minContextSlot:n.minContextSlot})).blockhash,e}};function At(e){if(typeof window>`u`||typeof document>`u`)return;let t=[];function n(){if(e())for(let e of t)e()}let r=setInterval(n,1e3);t.push(()=>clearInterval(r)),document.readyState===`loading`&&(document.addEventListener(`DOMContentLoaded`,n,{once:!0}),t.push(()=>document.removeEventListener(`DOMContentLoaded`,n))),document.readyState!==`complete`&&(window.addEventListener(`load`,n,{once:!0}),t.push(()=>window.removeEventListener(`load`,n))),n()}function jt(){if(!navigator)return!1;let e=navigator.userAgent.toLowerCase(),t=e.includes(`iphone`)||e.includes(`ipad`),n=e.includes(`safari`);return t&&n}function Mt(e){return`version`in e}var Nt=class extends kt{async sendTransaction(e,t,n={}){let r=!0;try{if(Mt(e)){if(!this.supportedTransactionVersions)throw new Ct(`Sending versioned transactions isn't supported by this wallet`);if(!this.supportedTransactionVersions.has(e.version))throw new Ct(`Sending transaction version ${e.version} isn't supported by this wallet`);try{e=await this.signTransaction(e);let r=e.serialize();return await t.sendRawTransaction(r,n)}catch(e){throw e instanceof wt?(r=!1,e):new Ct(e?.message,e)}}try{let{signers:r,...i}=n;e=await this.prepareTransaction(e,t,i),r?.length&&e.partialSign(...r),e=await this.signTransaction(e);let a=e.serialize();return await t.sendRawTransaction(a,i)}catch(e){throw e instanceof wt?(r=!1,e):new Ct(e?.message,e)}}catch(e){throw r&&this.emit(`error`,e),e}}async signAllTransactions(e){for(let t of e)if(Mt(t)){if(!this.supportedTransactionVersions)throw new wt(`Signing versioned transactions isn't supported by this wallet`);if(!this.supportedTransactionVersions.has(t.version))throw new wt(`Signing transaction version ${t.version} isn't supported by this wallet`)}let t=[];for(let n of e)t.push(await this.signTransaction(n));return t}},Pt=class extends Nt{},Ft=class extends Pt{},It;(function(e){e.Mainnet=`mainnet-beta`,e.Testnet=`testnet`,e.Devnet=`devnet`})(It||={});var Lt=n({TextDecoder:()=>Wt,TextEncoder:()=>Gt});function Rt(e,t,n){return t<=e&&e<=n}function zt(e){if(e===void 0)return{};if(e===Object(e))return e;throw TypeError(`Could not convert argument to dictionary`)}function Bt(e){for(var t=String(e),n=t.length,r=0,i=[];r<n;){var a=t.charCodeAt(r);if(a<55296||a>57343)i.push(a);else if(56320<=a&&a<=57343)i.push(65533);else if(55296<=a&&a<=56319){if(r===n-1)i.push(65533);else{var o=e.charCodeAt(r+1);if(56320<=o&&o<=57343){var s=a&1023,c=o&1023;i.push(65536+(s<<10)+c),r+=1}else i.push(65533)}}r+=1}return i}function Vt(e){for(var t=``,n=0;n<e.length;++n){var r=e[n];r<=65535?t+=String.fromCharCode(r):(r-=65536,t+=String.fromCharCode((r>>10)+55296,(r&1023)+56320))}return t}function Ht(e){this.tokens=[].slice.call(e)}function Ut(e,t){if(e)throw TypeError(`Decoder error`);return t||65533}function Wt(e,t){if(!(this instanceof Wt))return new Wt(e,t);if(e=e===void 0?Xt:String(e).toLowerCase(),e!==Xt)throw Error(`Encoding not supported. Only utf-8 is supported`);t=zt(t),this._streaming=!1,this._BOMseen=!1,this._decoder=null,this._fatal=!!t.fatal,this._ignoreBOM=!!t.ignoreBOM,Object.defineProperty(this,"encoding",{value:`utf-8`}),Object.defineProperty(this,"fatal",{value:this._fatal}),Object.defineProperty(this,"ignoreBOM",{value:this._ignoreBOM})}function Gt(e,t){if(!(this instanceof Gt))return new Gt(e,t);if(e=e===void 0?Xt:String(e).toLowerCase(),e!==Xt)throw Error(`Encoding not supported. Only utf-8 is supported`);t=zt(t),this._streaming=!1,this._encoder=null,this._options={fatal:!!t.fatal},Object.defineProperty(this,"encoding",{value:`utf-8`})}function Kt(e){var t=e.fatal,n=0,r=0,i=0,a=128,o=191;this.handler=function(e,s){if(s===Jt&&i!==0)return i=0,Ut(t);if(s===Jt)return Yt;if(i===0){if(Rt(s,0,127))return s;if(Rt(s,194,223))i=1,n=s-192;else if(Rt(s,224,239))s===224&&(a=160),s===237&&(o=159),i=2,n=s-224;else if(Rt(s,240,244))s===240&&(a=144),s===244&&(o=143),i=3,n=s-240;else return Ut(t);return n<<=6*i,null}if(!Rt(s,a,o))return n=i=r=0,a=128,o=191,e.prepend(s),Ut(t);if(a=128,o=191,r+=1,n+=s-128<<6*(i-r),r!==i)return null;var c=n;return n=i=r=0,c}}function qt(e){e.fatal,this.handler=function(e,t){if(t===Jt)return Yt;if(Rt(t,0,127))return t;var n,r;Rt(t,128,2047)?(n=1,r=192):Rt(t,2048,65535)?(n=2,r=224):Rt(t,65536,1114111)&&(n=3,r=240);for(var i=[(t>>6*n)+r];n>0;){var a=t>>6*(n-1);i.push(128|a&63),--n}return i}}var Jt,Yt,Xt,Zt=e((()=>{Jt=-1,Ht.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():Jt},prepend:function(e){if(Array.isArray(e))for(var t=e;t.length;)this.tokens.unshift(t.pop());else this.tokens.unshift(e)},push:function(e){if(Array.isArray(e))for(var t=e;t.length;)this.tokens.push(t.shift());else this.tokens.push(e)}},Yt=-1,Xt=`utf-8`,Wt.prototype={decode:function(e,t){var n=typeof e==`object`&&e instanceof ArrayBuffer?new Uint8Array(e):typeof e==`object`&&`buffer`in e&&e.buffer instanceof ArrayBuffer?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array;t=zt(t),this._streaming||(this._decoder=new Kt({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!t.stream;for(var r=new Ht(n),i=[],a;!r.endOfStream()&&(a=this._decoder.handler(r,r.read()),a!==Yt);)a!==null&&(Array.isArray(a)?i.push.apply(i,a):i.push(a));if(!this._streaming){do{if(a=this._decoder.handler(r,r.read()),a===Yt)break;a!==null&&(Array.isArray(a)?i.push.apply(i,a):i.push(a))}while(!r.endOfStream());this._decoder=null}return i.length&&[`utf-8`].indexOf(this.encoding)!==-1&&!this._ignoreBOM&&!this._BOMseen&&(i[0]===65279?(this._BOMseen=!0,i.shift()):this._BOMseen=!0),Vt(i)}},Gt.prototype={encode:function(e,t){e=e?String(e):``,t=zt(t),this._streaming||(this._encoder=new qt(this._options)),this._streaming=!!t.stream;for(var n=[],r=new Ht(Bt(e)),i;!r.endOfStream()&&(i=this._encoder.handler(r,r.read()),i!==Yt);)Array.isArray(i)?n.push.apply(n,i):n.push(i);if(!this._streaming){for(;i=this._encoder.handler(r,r.read()),i!==Yt;)Array.isArray(i)?n.push.apply(n,i):n.push(i);this._encoder=null}return new Uint8Array(n)}}})),Qt=i((e=>{v();var n=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),r=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),i=e&&e.__decorate||function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},a=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var i in e)i!=="default"&&Object.hasOwnProperty.call(e,i)&&n(t,e,i);return r(t,e),t},o=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.deserializeUnchecked=e.deserialize=e.serialize=e.BinaryReader=e.BinaryWriter=e.BorshError=e.baseDecode=e.baseEncode=void 0;var s=o(b()),c=o(S()),l=a((Zt(),t(Lt))),u=new(typeof TextDecoder==`function`?TextDecoder:l.TextDecoder)(`utf-8`,{fatal:!0});function d(e){return typeof e==`string`&&(e=y.from(e,`utf8`)),c.default.encode(y.from(e))}e.baseEncode=d;function f(e){return y.from(c.default.decode(e))}e.baseDecode=f;var p=1024,m=class extends Error{constructor(e){super(e),this.fieldPath=[],this.originalMessage=e}addToFieldPath(e){this.fieldPath.splice(0,0,e),this.message=this.originalMessage+`: `+this.fieldPath.join(`.`)}};e.BorshError=m;var h=class{constructor(){this.buf=y.alloc(p),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=y.concat([this.buf,y.alloc(p)]))}writeU8(e){this.maybeResize(),this.buf.writeUInt8(e,this.length),this.length+=1}writeU16(e){this.maybeResize(),this.buf.writeUInt16LE(e,this.length),this.length+=2}writeU32(e){this.maybeResize(),this.buf.writeUInt32LE(e,this.length),this.length+=4}writeU64(e){this.maybeResize(),this.writeBuffer(y.from(new s.default(e).toArray(`le`,8)))}writeU128(e){this.maybeResize(),this.writeBuffer(y.from(new s.default(e).toArray(`le`,16)))}writeU256(e){this.maybeResize(),this.writeBuffer(y.from(new s.default(e).toArray(`le`,32)))}writeU512(e){this.maybeResize(),this.writeBuffer(y.from(new s.default(e).toArray(`le`,64)))}writeBuffer(e){this.buf=y.concat([y.from(this.buf.subarray(0,this.length)),e,y.alloc(p)]),this.length+=e.length}writeString(e){this.maybeResize();let t=y.from(e,`utf8`);this.writeU32(t.length),this.writeBuffer(t)}writeFixedArray(e){this.writeBuffer(y.from(e))}writeArray(e,t){this.maybeResize(),this.writeU32(e.length);for(let n of e)this.maybeResize(),t(n)}toArray(){return this.buf.subarray(0,this.length)}};e.BinaryWriter=h;function g(e,t,n){let r=n.value;n.value=function(...e){try{return r.apply(this,e)}catch(e){if(e instanceof RangeError){let t=e.code;if([`ERR_BUFFER_OUT_OF_BOUNDS`,`ERR_OUT_OF_RANGE`].indexOf(t)>=0)throw new m(`Reached the end of buffer when deserializing`)}throw e}}}var _=class{constructor(e){this.buf=e,this.offset=0}readU8(){let e=this.buf.readUInt8(this.offset);return this.offset+=1,e}readU16(){let e=this.buf.readUInt16LE(this.offset);return this.offset+=2,e}readU32(){let e=this.buf.readUInt32LE(this.offset);return this.offset+=4,e}readU64(){let e=this.readBuffer(8);return new s.default(e,`le`)}readU128(){let e=this.readBuffer(16);return new s.default(e,`le`)}readU256(){let e=this.readBuffer(32);return new s.default(e,`le`)}readU512(){let e=this.readBuffer(64);return new s.default(e,`le`)}readBuffer(e){if(this.offset+e>this.buf.length)throw new m(`Expected buffer length ${e} isn't within bounds`);let t=this.buf.slice(this.offset,this.offset+e);return this.offset+=e,t}readString(){let e=this.readU32(),t=this.readBuffer(e);try{return u.decode(t)}catch(e){throw new m(`Error decoding UTF-8 string: ${e}`)}}readFixedArray(e){return new Uint8Array(this.readBuffer(e))}readArray(e){let t=this.readU32(),n=[];for(let r=0;r<t;++r)n.push(e());return n}};i([g],_.prototype,`readU8`,null),i([g],_.prototype,`readU16`,null),i([g],_.prototype,`readU32`,null),i([g],_.prototype,`readU64`,null),i([g],_.prototype,`readU128`,null),i([g],_.prototype,`readU256`,null),i([g],_.prototype,`readU512`,null),i([g],_.prototype,`readString`,null),i([g],_.prototype,`readFixedArray`,null),i([g],_.prototype,`readArray`,null),e.BinaryReader=_;function ee(e){return e.charAt(0).toUpperCase()+e.slice(1)}function te(e,t,n,r,i){try{if(typeof r==`string`)i[`write${ee(r)}`](n);else if(r instanceof Array){if(typeof r[0]==`number`){if(n.length!==r[0])throw new m(`Expecting byte array of length ${r[0]}, but got ${n.length} bytes`);i.writeFixedArray(n)}else if(r.length===2&&typeof r[1]==`number`){if(n.length!==r[1])throw new m(`Expecting byte array of length ${r[1]}, but got ${n.length} bytes`);for(let t=0;t<r[1];t++)te(e,null,n[t],r[0],i)}else i.writeArray(n,n=>{te(e,t,n,r[0],i)})}else if(r.kind!==void 0)switch(r.kind){case`option`:n==null?i.writeU8(0):(i.writeU8(1),te(e,t,n,r.type,i));break;case`map`:i.writeU32(n.size),n.forEach((n,a)=>{te(e,t,a,r.key,i),te(e,t,n,r.value,i)});break;default:throw new m(`FieldType ${r} unrecognized`)}else ne(e,n,i)}catch(e){throw e instanceof m&&e.addToFieldPath(t),e}}function ne(e,t,n){if(typeof t.borshSerialize==`function`){t.borshSerialize(n);return}let r=e.get(t.constructor);if(!r)throw new m(`Class ${t.constructor.name} is missing in schema`);if(r.kind===`struct`)r.fields.map(([r,i])=>{te(e,r,t[r],i,n)});else if(r.kind===`enum`){let i=t[r.field];for(let a=0;a<r.values.length;++a){let[o,s]=r.values[a];if(o===i){n.writeU8(a),te(e,o,t[o],s,n);break}}}else throw new m(`Unexpected schema kind: ${r.kind} for ${t.constructor.name}`)}function re(e,t,n=h){let r=new n;return ne(e,t,r),r.toArray()}e.serialize=re;function x(e,t,n,r){try{if(typeof n==`string`)return r[`read${ee(n)}`]();if(n instanceof Array){if(typeof n[0]==`number`)return r.readFixedArray(n[0]);if(typeof n[1]==`number`){let t=[];for(let i=0;i<n[1];i++)t.push(x(e,null,n[0],r));return t}return r.readArray(()=>x(e,t,n[0],r))}if(n.kind===`option`)return r.readU8()?x(e,t,n.type,r):void 0;if(n.kind===`map`){let i=new Map,a=r.readU32();for(let o=0;o<a;o++){let a=x(e,t,n.key,r),o=x(e,t,n.value,r);i.set(a,o)}return i}return C(e,n,r)}catch(e){throw e instanceof m&&e.addToFieldPath(t),e}}function C(e,t,n){if(typeof t.borshDeserialize==`function`)return t.borshDeserialize(n);let r=e.get(t);if(!r)throw new m(`Class ${t.name} is missing in schema`);if(r.kind===`struct`){let r={};for(let[i,a]of e.get(t).fields)r[i]=x(e,i,a,n);return new t(r)}if(r.kind===`enum`){let i=n.readU8();if(i>=r.values.length)throw new m(`Enum index: ${i} is out of range`);let[a,o]=r.values[i],s=x(e,a,o,n);return new t({[a]:s})}throw new m(`Unexpected schema kind: ${r.kind} for ${t.constructor.name}`)}function w(e,t,n,r=_){let i=new r(n),a=C(e,t,i);if(i.offset<n.length)throw new m(`Unexpected ${n.length-i.offset} bytes after deserialized data`);return a}e.deserialize=w;function T(e,t,n,r=_){return C(e,t,new r(n))}e.deserializeUnchecked=T})),$t=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.s16=e.s8=e.nu64be=e.u48be=e.u40be=e.u32be=e.u24be=e.u16be=e.nu64=e.u48=e.u40=e.u32=e.u24=e.u16=e.u8=e.offset=e.greedy=e.Constant=e.UTF8=e.CString=e.Blob=e.Boolean=e.BitField=e.BitStructure=e.VariantLayout=e.Union=e.UnionLayoutDiscriminator=e.UnionDiscriminator=e.Structure=e.Sequence=e.DoubleBE=e.Double=e.FloatBE=e.Float=e.NearInt64BE=e.NearInt64=e.NearUInt64BE=e.NearUInt64=e.IntBE=e.Int=e.UIntBE=e.UInt=e.OffsetLayout=e.GreedyCount=e.ExternalLayout=e.bindConstructorLayout=e.nameWithProperty=e.Layout=e.uint8ArrayToBuffer=e.checkUint8Array=void 0,e.constant=e.utf8=e.cstr=e.blob=e.unionLayoutDiscriminator=e.union=e.seq=e.bits=e.struct=e.f64be=e.f64=e.f32be=e.f32=e.ns64be=e.s48be=e.s40be=e.s32be=e.s24be=e.s16be=e.ns64=e.s48=e.s40=e.s32=e.s24=void 0;var t=re();function n(e){if(!(e instanceof Uint8Array))throw TypeError(`b must be a Uint8Array`)}e.checkUint8Array=n;function r(e){return n(e),t.Buffer.from(e.buffer,e.byteOffset,e.length)}e.uint8ArrayToBuffer=r;var i=class{constructor(e,t){if(!Number.isInteger(e))throw TypeError(`span must be an integer`);this.span=e,this.property=t}makeDestinationObject(){return{}}getSpan(e,t){if(0>this.span)throw RangeError(`indeterminate span`);return this.span}replicate(e){let t=Object.create(this.constructor.prototype);return Object.assign(t,this),t.property=e,t}fromArray(e){}};e.Layout=i;function a(e,t){return t.property?e+`[`+t.property+`]`:e}e.nameWithProperty=a;function o(e,t){if(typeof e!=`function`)throw TypeError(`Class must be constructor`);if(Object.prototype.hasOwnProperty.call(e,`layout_`))throw Error(`Class is already bound to a layout`);if(!(t&&t instanceof i))throw TypeError(`layout must be a Layout`);if(Object.prototype.hasOwnProperty.call(t,`boundConstructor_`))throw Error(`layout is already bound to a constructor`);e.layout_=t,t.boundConstructor_=e,t.makeDestinationObject=(()=>new e),Object.defineProperty(e.prototype,"encode",{value(e,n){return t.encode(this,e,n)},writable:!0}),Object.defineProperty(e,"decode",{value(e,n){return t.decode(e,n)},writable:!0})}e.bindConstructorLayout=o;var s=class extends i{isCount(){throw Error(`ExternalLayout is abstract`)}};e.ExternalLayout=s;var c=class extends s{constructor(e=1,t){if(!Number.isInteger(e)||0>=e)throw TypeError(`elementSpan must be a (positive) integer`);super(-1,t),this.elementSpan=e}isCount(){return!0}decode(e,t=0){n(e);let r=e.length-t;return Math.floor(r/this.elementSpan)}encode(e,t,n){return 0}};e.GreedyCount=c;var l=class extends s{constructor(e,t=0,n){if(!(e instanceof i))throw TypeError(`layout must be a Layout`);if(!Number.isInteger(t))throw TypeError(`offset must be integer or undefined`);super(e.span,n||e.property),this.layout=e,this.offset=t}isCount(){return this.layout instanceof u||this.layout instanceof d}decode(e,t=0){return this.layout.decode(e,t+this.offset)}encode(e,t,n=0){return this.layout.encode(e,t,n+this.offset)}};e.OffsetLayout=l;var u=class extends i{constructor(e,t){if(super(e,t),6<this.span)throw RangeError(`span must not exceed 6 bytes`)}decode(e,t=0){return r(e).readUIntLE(t,this.span)}encode(e,t,n=0){return r(t).writeUIntLE(e,n,this.span),this.span}};e.UInt=u;var d=class extends i{constructor(e,t){if(super(e,t),6<this.span)throw RangeError(`span must not exceed 6 bytes`)}decode(e,t=0){return r(e).readUIntBE(t,this.span)}encode(e,t,n=0){return r(t).writeUIntBE(e,n,this.span),this.span}};e.UIntBE=d;var f=class extends i{constructor(e,t){if(super(e,t),6<this.span)throw RangeError(`span must not exceed 6 bytes`)}decode(e,t=0){return r(e).readIntLE(t,this.span)}encode(e,t,n=0){return r(t).writeIntLE(e,n,this.span),this.span}};e.Int=f;var p=class extends i{constructor(e,t){if(super(e,t),6<this.span)throw RangeError(`span must not exceed 6 bytes`)}decode(e,t=0){return r(e).readIntBE(t,this.span)}encode(e,t,n=0){return r(t).writeIntBE(e,n,this.span),this.span}};e.IntBE=p;var m=2**32;function h(e){let t=Math.floor(e/m);return{hi32:t,lo32:e-t*m}}function g(e,t){return e*m+t}var _=class extends i{constructor(e){super(8,e)}decode(e,t=0){let n=r(e),i=n.readUInt32LE(t);return g(n.readUInt32LE(t+4),i)}encode(e,t,n=0){let i=h(e),a=r(t);return a.writeUInt32LE(i.lo32,n),a.writeUInt32LE(i.hi32,n+4),8}};e.NearUInt64=_;var v=class extends i{constructor(e){super(8,e)}decode(e,t=0){let n=r(e);return g(n.readUInt32BE(t),n.readUInt32BE(t+4))}encode(e,t,n=0){let i=h(e),a=r(t);return a.writeUInt32BE(i.hi32,n),a.writeUInt32BE(i.lo32,n+4),8}};e.NearUInt64BE=v;var y=class extends i{constructor(e){super(8,e)}decode(e,t=0){let n=r(e),i=n.readUInt32LE(t);return g(n.readInt32LE(t+4),i)}encode(e,t,n=0){let i=h(e),a=r(t);return a.writeUInt32LE(i.lo32,n),a.writeInt32LE(i.hi32,n+4),8}};e.NearInt64=y;var ee=class extends i{constructor(e){super(8,e)}decode(e,t=0){let n=r(e);return g(n.readInt32BE(t),n.readUInt32BE(t+4))}encode(e,t,n=0){let i=h(e),a=r(t);return a.writeInt32BE(i.hi32,n),a.writeUInt32BE(i.lo32,n+4),8}};e.NearInt64BE=ee;var te=class extends i{constructor(e){super(4,e)}decode(e,t=0){return r(e).readFloatLE(t)}encode(e,t,n=0){return r(t).writeFloatLE(e,n),4}};e.Float=te;var ne=class extends i{constructor(e){super(4,e)}decode(e,t=0){return r(e).readFloatBE(t)}encode(e,t,n=0){return r(t).writeFloatBE(e,n),4}};e.FloatBE=ne;var b=class extends i{constructor(e){super(8,e)}decode(e,t=0){return r(e).readDoubleLE(t)}encode(e,t,n=0){return r(t).writeDoubleLE(e,n),8}};e.Double=b;var x=class extends i{constructor(e){super(8,e)}decode(e,t=0){return r(e).readDoubleBE(t)}encode(e,t,n=0){return r(t).writeDoubleBE(e,n),8}};e.DoubleBE=x;var S=class extends i{constructor(e,t,n){if(!(e instanceof i))throw TypeError(`elementLayout must be a Layout`);if(!(t instanceof s&&t.isCount()||Number.isInteger(t)&&0<=t))throw TypeError(`count must be non-negative integer or an unsigned integer ExternalLayout`);let r=-1;!(t instanceof s)&&0<e.span&&(r=t*e.span),super(r,n),this.elementLayout=e,this.count=t}getSpan(e,t=0){if(0<=this.span)return this.span;let n=0,r=this.count;if(r instanceof s&&(r=r.decode(e,t)),0<this.elementLayout.span)n=r*this.elementLayout.span;else{let i=0;for(;i<r;)n+=this.elementLayout.getSpan(e,t+n),++i}return n}decode(e,t=0){let n=[],r=0,i=this.count;for(i instanceof s&&(i=i.decode(e,t));r<i;)n.push(this.elementLayout.decode(e,t)),t+=this.elementLayout.getSpan(e,t),r+=1;return n}encode(e,t,n=0){let r=this.elementLayout,i=e.reduce((e,i)=>e+r.encode(i,t,n+e),0);return this.count instanceof s&&this.count.encode(e.length,t,n),i}};e.Sequence=S;var C=class extends i{constructor(e,t,n){if(!(Array.isArray(e)&&e.reduce((e,t)=>e&&t instanceof i,!0)))throw TypeError(`fields must be array of Layout instances`);typeof t==`boolean`&&n===void 0&&(n=t,t=void 0);for(let t of e)if(0>t.span&&t.property===void 0)throw Error(`fields cannot contain unnamed variable-length layout`);let r=-1;try{r=e.reduce((e,t)=>e+t.getSpan(),0)}catch{}super(r,t),this.fields=e,this.decodePrefixes=!!n}getSpan(e,t=0){if(0<=this.span)return this.span;let n=0;try{n=this.fields.reduce((n,r)=>{let i=r.getSpan(e,t);return t+=i,n+i},0)}catch{throw RangeError(`indeterminate span`)}return n}decode(e,t=0){n(e);let r=this.makeDestinationObject();for(let n of this.fields)if(n.property!==void 0&&(r[n.property]=n.decode(e,t)),t+=n.getSpan(e,t),this.decodePrefixes&&e.length===t)break;return r}encode(e,t,n=0){let r=n,i=0,a=0;for(let r of this.fields){let o=r.span;if(a=0<o?o:0,r.property!==void 0){let i=e[r.property];i!==void 0&&(a=r.encode(i,t,n),0>o&&(o=r.getSpan(t,n)))}i=n,n+=o}return i+a-r}fromArray(e){let t=this.makeDestinationObject();for(let n of this.fields)n.property!==void 0&&0<e.length&&(t[n.property]=e.shift());return t}layoutFor(e){if(typeof e!=`string`)throw TypeError(`property must be string`);for(let t of this.fields)if(t.property===e)return t}offsetOf(e){if(typeof e!=`string`)throw TypeError(`property must be string`);let t=0;for(let n of this.fields){if(n.property===e)return t;0>n.span?t=-1:0<=t&&(t+=n.span)}}};e.Structure=C;var w=class{constructor(e){this.property=e}decode(e,t){throw Error(`UnionDiscriminator is abstract`)}encode(e,t,n){throw Error(`UnionDiscriminator is abstract`)}};e.UnionDiscriminator=w;var T=class extends w{constructor(e,t){if(!(e instanceof s&&e.isCount()))throw TypeError(`layout must be an unsigned integer ExternalLayout`);super(t||e.property||`variant`),this.layout=e}decode(e,t){return this.layout.decode(e,t)}encode(e,t,n){return this.layout.encode(e,t,n)}};e.UnionLayoutDiscriminator=T;var E=class extends i{constructor(e,t,n){let r;if(e instanceof u||e instanceof d)r=new T(new l(e));else if(e instanceof s&&e.isCount())r=new T(e);else if(e instanceof w)r=e;else throw TypeError(`discr must be a UnionDiscriminator or an unsigned integer layout`);if(t===void 0&&(t=null),!(t===null||t instanceof i))throw TypeError(`defaultLayout must be null or a Layout`);if(t!==null){if(0>t.span)throw Error(`defaultLayout must have constant span`);t.property===void 0&&(t=t.replicate(`content`))}let a=-1;t&&(a=t.span,0<=a&&(e instanceof u||e instanceof d)&&(a+=r.layout.span)),super(a,n),this.discriminator=r,this.usesPrefixDiscriminator=e instanceof u||e instanceof d,this.defaultLayout=t,this.registry={};let o=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(e){return o(e)},this.configGetSourceVariant=function(e){o=e.bind(this)}}getSpan(e,t=0){if(0<=this.span)return this.span;let n=this.getVariant(e,t);if(!n)throw Error(`unable to determine span for unrecognized variant`);return n.getSpan(e,t)}defaultGetSourceVariant(e){if(Object.prototype.hasOwnProperty.call(e,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(e,this.defaultLayout.property))return;let t=this.registry[e[this.discriminator.property]];if(t&&(!t.layout||t.property&&Object.prototype.hasOwnProperty.call(e,t.property)))return t}else for(let t in this.registry){let n=this.registry[t];if(n.property&&Object.prototype.hasOwnProperty.call(e,n.property))return n}throw Error(`unable to infer src variant`)}decode(e,t=0){let n,r=this.discriminator,i=r.decode(e,t),a=this.registry[i];if(a===void 0){let a=this.defaultLayout,o=0;this.usesPrefixDiscriminator&&(o=r.layout.span),n=this.makeDestinationObject(),n[r.property]=i,n[a.property]=a.decode(e,t+o)}else n=a.decode(e,t);return n}encode(e,t,n=0){let r=this.getSourceVariant(e);if(r===void 0){let r=this.discriminator,i=this.defaultLayout,a=0;return this.usesPrefixDiscriminator&&(a=r.layout.span),r.encode(e[r.property],t,n),a+i.encode(e[i.property],t,n+a)}return r.encode(e,t,n)}addVariant(e,t,n){let r=new ie(this,e,t,n);return this.registry[e]=r,r}getVariant(e,t=0){let n;return n=e instanceof Uint8Array?this.discriminator.decode(e,t):e,this.registry[n]}};e.Union=E;var ie=class extends i{constructor(e,t,n,r){if(!(e instanceof E))throw TypeError(`union must be a Union`);if(!Number.isInteger(t)||0>t)throw TypeError(`variant must be a (non-negative) integer`);if(typeof n==`string`&&r===void 0&&(r=n,n=null),n){if(!(n instanceof i))throw TypeError(`layout must be a Layout`);if(e.defaultLayout!==null&&0<=n.span&&n.span>e.defaultLayout.span)throw Error(`variant span exceeds span of containing union`);if(typeof r!=`string`)throw TypeError(`variant must have a String property`)}let a=e.span;0>e.span&&(a=n?n.span:0,0<=a&&e.usesPrefixDiscriminator&&(a+=e.discriminator.layout.span)),super(a,r),this.union=e,this.variant=t,this.layout=n||null}getSpan(e,t=0){if(0<=this.span)return this.span;let n=0;this.union.usesPrefixDiscriminator&&(n=this.union.discriminator.layout.span);let r=0;return this.layout&&(r=this.layout.getSpan(e,t+n)),n+r}decode(e,t=0){let n=this.makeDestinationObject();if(this!==this.union.getVariant(e,t))throw Error(`variant mismatch`);let r=0;return this.union.usesPrefixDiscriminator&&(r=this.union.discriminator.layout.span),this.layout?n[this.property]=this.layout.decode(e,t+r):this.property?n[this.property]=!0:this.union.usesPrefixDiscriminator&&(n[this.union.discriminator.property]=this.variant),n}encode(e,t,n=0){let r=0;if(this.union.usesPrefixDiscriminator&&(r=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(e,this.property))throw TypeError(`variant lacks property `+this.property);this.union.discriminator.encode(this.variant,t,n);let i=r;if(this.layout&&(this.layout.encode(e[this.property],t,n+r),i+=this.layout.getSpan(t,n+r),0<=this.union.span&&i>this.union.span))throw Error(`encoded variant overruns containing union`);return i}fromArray(e){if(this.layout)return this.layout.fromArray(e)}};e.VariantLayout=ie;function ae(e){return 0>e&&(e+=4294967296),e}var oe=class extends i{constructor(e,t,n){if(!(e instanceof u||e instanceof d))throw TypeError(`word must be a UInt or UIntBE layout`);if(typeof t==`string`&&n===void 0&&(n=t,t=!1),4<e.span)throw RangeError(`word cannot exceed 32 bits`);super(e.span,n),this.word=e,this.msb=!!t,this.fields=[];let r=0;this._packedSetValue=function(e){return r=ae(e),this},this._packedGetValue=function(){return r}}decode(e,t=0){let n=this.makeDestinationObject(),r=this.word.decode(e,t);this._packedSetValue(r);for(let t of this.fields)t.property!==void 0&&(n[t.property]=t.decode(e));return n}encode(e,t,n=0){let r=this.word.decode(t,n);this._packedSetValue(r);for(let t of this.fields)if(t.property!==void 0){let n=e[t.property];n!==void 0&&t.encode(n)}return this.word.encode(this._packedGetValue(),t,n)}addField(e,t){let n=new D(this,e,t);return this.fields.push(n),n}addBoolean(e){let t=new se(this,e);return this.fields.push(t),t}fieldFor(e){if(typeof e!=`string`)throw TypeError(`property must be string`);for(let t of this.fields)if(t.property===e)return t}};e.BitStructure=oe;var D=class{constructor(e,t,n){if(!(e instanceof oe))throw TypeError(`container must be a BitStructure`);if(!Number.isInteger(t)||0>=t)throw TypeError(`bits must be positive integer`);let r=8*e.span,i=e.fields.reduce((e,t)=>e+t.bits,0);if(t+i>r)throw Error(`bits too long for span remainder (`+(r-i)+` of `+r+` remain)`);this.container=e,this.bits=t,this.valueMask=(1<<t)-1,t===32&&(this.valueMask=4294967295),this.start=i,this.container.msb&&(this.start=r-i-t),this.wordMask=ae(this.valueMask<<this.start),this.property=n}decode(e,t){return ae(this.container._packedGetValue()&this.wordMask)>>>this.start}encode(e){if(typeof e!=`number`||!Number.isInteger(e)||e!==ae(e&this.valueMask))throw TypeError(a(`BitField.encode`,this)+` value must be integer not exceeding `+this.valueMask);let t=this.container._packedGetValue(),n=ae(e<<this.start);this.container._packedSetValue(ae(t&~this.wordMask)|n)}};e.BitField=D;var se=class extends D{constructor(e,t){super(e,1,t)}decode(e,t){return!!super.decode(e,t)}encode(e){typeof e==`boolean`&&(e=+e),super.encode(e)}};e.Boolean=se;var ce=class extends i{constructor(e,t){if(!(e instanceof s&&e.isCount()||Number.isInteger(e)&&0<=e))throw TypeError(`length must be positive integer or an unsigned integer ExternalLayout`);let n=-1;e instanceof s||(n=e),super(n,t),this.length=e}getSpan(e,t){let n=this.span;return 0>n&&(n=this.length.decode(e,t)),n}decode(e,t=0){let n=this.span;return 0>n&&(n=this.length.decode(e,t)),r(e).slice(t,t+n)}encode(e,t,n){let i=this.length;if(this.length instanceof s&&(i=e.length),!(e instanceof Uint8Array&&i===e.length))throw TypeError(a(`Blob.encode`,this)+` requires (length `+i+`) Uint8Array as src`);if(n+i>t.length)throw RangeError(`encoding overruns Uint8Array`);let o=r(e);return r(t).write(o.toString(`hex`),n,i,`hex`),this.length instanceof s&&this.length.encode(i,t,n),i}};e.Blob=ce;var le=class extends i{constructor(e){super(-1,e)}getSpan(e,t=0){n(e);let r=t;for(;r<e.length&&e[r]!==0;)r+=1;return 1+r-t}decode(e,t=0){let n=this.getSpan(e,t);return r(e).slice(t,t+n-1).toString(`utf-8`)}encode(e,n,i=0){typeof e!=`string`&&(e=String(e));let a=t.Buffer.from(e,`utf8`),o=a.length;if(i+o>n.length)throw RangeError(`encoding overruns Buffer`);let s=r(n);return a.copy(s,i),s[i+o]=0,o+1}};e.CString=le;var ue=class extends i{constructor(e,t){if(typeof e==`string`&&t===void 0&&(t=e,e=void 0),e===void 0)e=-1;else if(!Number.isInteger(e))throw TypeError(`maxSpan must be an integer`);super(-1,t),this.maxSpan=e}getSpan(e,t=0){return n(e),e.length-t}decode(e,t=0){let n=this.getSpan(e,t);if(0<=this.maxSpan&&this.maxSpan<n)throw RangeError(`text length exceeds maxSpan`);return r(e).slice(t,t+n).toString(`utf-8`)}encode(e,n,i=0){typeof e!=`string`&&(e=String(e));let a=t.Buffer.from(e,`utf8`),o=a.length;if(0<=this.maxSpan&&this.maxSpan<o)throw RangeError(`text length exceeds maxSpan`);if(i+o>n.length)throw RangeError(`encoding overruns Buffer`);return a.copy(r(n),i),o}};e.UTF8=ue;var de=class extends i{constructor(e,t){super(0,t),this.value=e}decode(e,t){return this.value}encode(e,t,n){return 0}};e.Constant=de,e.greedy=((e,t)=>new c(e,t)),e.offset=((e,t,n)=>new l(e,t,n)),e.u8=(e=>new u(1,e)),e.u16=(e=>new u(2,e)),e.u24=(e=>new u(3,e)),e.u32=(e=>new u(4,e)),e.u40=(e=>new u(5,e)),e.u48=(e=>new u(6,e)),e.nu64=(e=>new _(e)),e.u16be=(e=>new d(2,e)),e.u24be=(e=>new d(3,e)),e.u32be=(e=>new d(4,e)),e.u40be=(e=>new d(5,e)),e.u48be=(e=>new d(6,e)),e.nu64be=(e=>new v(e)),e.s8=(e=>new f(1,e)),e.s16=(e=>new f(2,e)),e.s24=(e=>new f(3,e)),e.s32=(e=>new f(4,e)),e.s40=(e=>new f(5,e)),e.s48=(e=>new f(6,e)),e.ns64=(e=>new y(e)),e.s16be=(e=>new p(2,e)),e.s24be=(e=>new p(3,e)),e.s32be=(e=>new p(4,e)),e.s40be=(e=>new p(5,e)),e.s48be=(e=>new p(6,e)),e.ns64be=(e=>new ee(e)),e.f32=(e=>new te(e)),e.f32be=(e=>new ne(e)),e.f64=(e=>new b(e)),e.f64be=(e=>new x(e)),e.struct=((e,t,n)=>new C(e,t,n)),e.bits=((e,t,n)=>new oe(e,t,n)),e.seq=((e,t,n)=>new S(e,t,n)),e.union=((e,t,n)=>new E(e,t,n)),e.unionLayoutDiscriminator=((e,t)=>new T(e,t)),e.blob=((e,t)=>new ce(e,t)),e.cstr=(e=>new le(e)),e.utf8=((e,t)=>new ue(e,t)),e.constant=((e,t)=>new de(e,t))}));function en(e){return Array.isArray(e)?`%5B`+e.map(en).join(`%2C%20`)+`%5D`:typeof e==`bigint`?`${e}n`:encodeURIComponent(String(e!=null&&Object.getPrototypeOf(e)===null?{...e}:e))}function tn([e,t]){return`${e}=${en(t)}`}function nn(e){let t=Object.entries(e).map(tn).join(`&`);return btoa(t)}function rn(e,t={}){{let n=`Solana error #${e}; Decode this error by running \`npx @solana/errors decode -- ${e}`;return Object.keys(t).length&&(n+=` '${nn(t)}'`),`${n}\``}}var an,on,sn,cn,ln,un,dn,fn=e((()=>{an=8078e3,on=8078001,sn=8078004,cn=8078005,ln=8078006,un=8078011,dn=class extends Error{cause=this.cause;context;constructor(...[e,t]){let n,r;if(t){let{cause:e,...i}=t;e&&(r={cause:e}),Object.keys(i).length>0&&(n=i)}let i=rn(e,n);super(i,r),this.context={__code:e,...n},this.name=`SolanaError`}}}));function pn(e,t){return`fixedSize`in t?t.fixedSize:t.getSizeFromValue(e)}function mn(e){return Object.freeze({...e,encode:t=>{let n=new Uint8Array(pn(t,e));return e.write(t,n,0),n}})}function hn(e){return Object.freeze({...e,decode:(t,n=0)=>e.read(t,n)[0]})}function gn(e){return`fixedSize`in e&&typeof e.fixedSize==`number`}function _n(e,t){if(gn(e)!==gn(t))throw new dn(sn);if(gn(e)&&gn(t)&&e.fixedSize!==t.fixedSize)throw new dn(cn,{decoderFixedSize:t.fixedSize,encoderFixedSize:e.fixedSize});if(!gn(e)&&!gn(t)&&e.maxSize!==t.maxSize)throw new dn(ln,{decoderMaxSize:t.maxSize,encoderMaxSize:e.maxSize});return{...t,...e,decode:t.decode,encode:e.encode,read:t.read,write:e.write}}function vn(e,t,n=0){if(t.length-n<=0)throw new dn(an,{codecDescription:e})}function yn(e,t,n,r=0){let i=n.length-r;if(i<t)throw new dn(on,{bytesLength:i,codecDescription:e,expected:t})}var bn=e((()=>{fn()}));function xn(e,t,n,r){if(r<t||r>n)throw new dn(un,{codecDescription:e,max:n,min:t,value:r})}function Sn(e){return e?.endian!==1}function Cn(e){return mn({fixedSize:e.size,write(t,n,r){e.range&&xn(e.name,e.range[0],e.range[1],t);let i=new ArrayBuffer(e.size);return e.set(new DataView(i),t,Sn(e.config)),n.set(new Uint8Array(i),r),r+e.size}})}function wn(e){return hn({fixedSize:e.size,read(t,n=0){vn(e.name,t,n),yn(e.name,e.size,t,n);let r=new DataView(Tn(t,n,e.size));return[e.get(r,Sn(e.config)),n+e.size]}})}function Tn(e,t,n){let r=e.byteOffset+(t??0),i=n??e.byteLength;return e.buffer.slice(r,r+i)}var En,Dn,On,kn=e((()=>{fn(),bn(),En=(e={})=>Cn({config:e,name:`u64`,range:[0n,BigInt(`0xffffffffffffffff`)],set:(e,t,n)=>e.setBigUint64(0,BigInt(t),n),size:8}),Dn=(e={})=>wn({config:e,get:(e,t)=>e.getBigUint64(0,t),name:`u64`,size:8}),On=(e={})=>_n(En(e),Dn(e))}));function An(e){return jn(e)&&typeof e[Symbol.iterator]==`function`}function jn(e){return typeof e==`object`&&!!e}function Mn(e){return jn(e)&&!Array.isArray(e)}function Nn(e){return typeof e==`symbol`?e.toString():typeof e==`string`?JSON.stringify(e):`${e}`}function Pn(e){let{done:t,value:n}=e.next();return t?void 0:n}function Fn(e,t,n,r){if(e===!0)return;e===!1?e={}:typeof e==`string`&&(e={message:e});let{path:i,branch:a}=t,{type:o}=n,{refinement:s,message:c=`Expected a value of type \`${o}\`${s?` with refinement \`${s}\``:``}, but received: \`${Nn(r)}\``}=e;return{value:r,type:o,refinement:s,key:i[i.length-1],path:i,branch:a,...e,message:c}}function*In(e,t,n,r){An(e)||(e=[e]);for(let i of e){let e=Fn(i,t,n,r);e&&(yield e)}}function*Ln(e,t,n={}){let{path:r=[],branch:i=[e],coerce:a=!1,mask:o=!1}=n,s={path:r,branch:i,mask:o};a&&(e=t.coercer(e,s));let c=`valid`;for(let r of t.validator(e,s))r.explanation=n.message,c=`not_valid`,yield[r,void 0];for(let[l,u,d]of t.entries(e,s)){let t=Ln(u,d,{path:l===void 0?r:[...r,l],branch:l===void 0?i:[...i,u],coerce:a,mask:o,message:n.message});for(let n of t)n[0]?(c=n[0].refinement==null?`not_valid`:`not_refined`,yield[n[0],void 0]):a&&(u=n[1],l===void 0?e=u:e instanceof Map?e.set(l,u):e instanceof Set?e.add(u):jn(e)&&(u!==void 0||l in e)&&(e[l]=u))}if(c!==`not_valid`)for(let r of t.refiner(e,s))r.explanation=n.message,c=`not_refined`,yield[r,void 0];c===`valid`&&(yield[void 0,e])}function Rn(e,t,n){let r=Vn(e,t,{message:n});if(r[0])throw r[0]}function N(e,t,n){let r=Vn(e,t,{coerce:!0,message:n});if(r[0])throw r[0];return r[1]}function zn(e,t,n){let r=Vn(e,t,{coerce:!0,mask:!0,message:n});if(r[0])throw r[0];return r[1]}function Bn(e,t){return!Vn(e,t)[0]}function Vn(e,t,n={}){let r=Ln(e,t,n),i=Pn(r);return i[0]?[new $n(i[0],function*(){for(let e of r)e[0]&&(yield e[0])}),void 0]:[void 0,i[1]]}function Hn(e,t){return new er({type:e,schema:null,validator:t})}function Un(){return Hn(`any`,()=>!0)}function P(e){return new er({type:`array`,schema:e,*entries(t){if(e&&Array.isArray(t))for(let[n,r]of t.entries())yield[n,r,e]},coercer(e){return Array.isArray(e)?e.slice():e},validator(e){return Array.isArray(e)||`Expected an array value, but received: ${Nn(e)}`}})}function Wn(){return Hn(`boolean`,e=>typeof e==`boolean`)}function Gn(e){return Hn(`instance`,t=>t instanceof e||`Expected a \`${e.name}\` instance, but received: ${Nn(t)}`)}function Kn(e){let t=Nn(e),n=typeof e;return new er({type:`literal`,schema:n===`string`||n===`number`||n===`boolean`?e:null,validator(n){return n===e||`Expected the literal \`${t}\`, but received: ${Nn(n)}`}})}function qn(){return Hn(`never`,()=>!1)}function F(e){return new er({...e,validator:(t,n)=>t===null||e.validator(t,n),refiner:(t,n)=>t===null||e.refiner(t,n)})}function I(){return Hn(`number`,e=>typeof e==`number`&&!isNaN(e)||`Expected a number, but received: ${Nn(e)}`)}function L(e){return new er({...e,validator:(t,n)=>t===void 0||e.validator(t,n),refiner:(t,n)=>t===void 0||e.refiner(t,n)})}function Jn(e,t){return new er({type:`record`,schema:null,*entries(n){if(jn(n))for(let r in n){let i=n[r];yield[r,r,e],yield[r,i,t]}},validator(e){return Mn(e)||`Expected an object, but received: ${Nn(e)}`},coercer(e){return Mn(e)?{...e}:e}})}function R(){return Hn(`string`,e=>typeof e==`string`||`Expected a string, but received: ${Nn(e)}`)}function Yn(e){let t=qn();return new er({type:`tuple`,schema:null,*entries(n){if(Array.isArray(n)){let r=Math.max(e.length,n.length);for(let i=0;i<r;i++)yield[i,n[i],e[i]||t]}},validator(e){return Array.isArray(e)||`Expected an array, but received: ${Nn(e)}`},coercer(e){return Array.isArray(e)?e.slice():e}})}function z(e){let t=Object.keys(e);return new er({type:`type`,schema:e,*entries(n){if(jn(n))for(let r of t)yield[r,n[r],e[r]]},validator(e){return Mn(e)||`Expected an object, but received: ${Nn(e)}`},coercer(e){return Mn(e)?{...e}:e}})}function Xn(e){let t=e.map(e=>e.type).join(` | `);return new er({type:`union`,schema:null,coercer(t,n){for(let r of e){let[e,i]=r.validate(t,{coerce:!0,mask:n.mask});if(!e)return i}return t},validator(n,r){let i=[];for(let t of e){let[...e]=Ln(n,t,r),[a]=e;if(a[0])for(let[t]of e)t&&i.push(t);else return[]}return[`Expected the value to satisfy a union of \`${t}\`, but received: ${Nn(n)}`,...i]}})}function Zn(){return Hn(`unknown`,()=>!0)}function Qn(e,t,n){return new er({...e,coercer:(r,i)=>Bn(r,t)?e.coercer(n(r,i),i):e.coercer(r,i)})}var $n,er,tr=e((()=>{$n=class extends TypeError{constructor(e,t){let n,{message:r,explanation:i,...a}=e,{path:o}=e,s=o.length===0?r:`At path: ${o.join(`.`)} -- ${r}`;super(i??s),i!=null&&(this.cause=s),Object.assign(this,a),this.name=this.constructor.name,this.failures=()=>n??=[e,...t()]}},er=class{constructor(e){let{type:t,schema:n,validator:r,refiner:i,coercer:a=e=>e,entries:o=function*(){}}=e;this.type=t,this.schema=n,this.entries=o,this.coercer=a,this.validator=r?(e,t)=>In(r(e,t),t,this,e):()=>[],this.refiner=i?(e,t)=>In(i(e,t),t,this,e):()=>[]}assert(e,t){return Rn(e,this,t)}create(e,t){return N(e,this,t)}is(e){return Bn(e,this)}mask(e,t){return zn(e,this,t)}validate(e,t={}){return Vn(e,this,t)}}}));function nr(){if(!rr&&(rr=typeof crypto<`u`&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<`u`&&typeof msCrypto.getRandomValues==`function`&&msCrypto.getRandomValues.bind(msCrypto),!rr))throw Error(`crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported`);return rr(ir)}var rr,ir,ar=e((()=>{ir=new Uint8Array(16)})),or,sr=e((()=>{or=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i}));function cr(e){return typeof e==`string`&&or.test(e)}var lr=e((()=>{sr()}));function ur(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=(dr[e[t+0]]+dr[e[t+1]]+dr[e[t+2]]+dr[e[t+3]]+`-`+dr[e[t+4]]+dr[e[t+5]]+`-`+dr[e[t+6]]+dr[e[t+7]]+`-`+dr[e[t+8]]+dr[e[t+9]]+`-`+dr[e[t+10]]+dr[e[t+11]]+dr[e[t+12]]+dr[e[t+13]]+dr[e[t+14]]+dr[e[t+15]]).toLowerCase();if(!cr(n))throw TypeError(`Stringified UUID is invalid`);return n}var dr,fr,pr=e((()=>{for(lr(),dr=[],fr=0;fr<256;++fr)dr.push((fr+256).toString(16).substr(1))}));function mr(e,t,n){var r=t&&n||0,i=t||Array(16);e||={};var a=e.node||hr,o=e.clockseq===void 0?gr:e.clockseq;if(a==null||o==null){var s=e.random||(e.rng||nr)();a??=hr=[s[0]|1,s[1],s[2],s[3],s[4],s[5]],o??=gr=(s[6]<<8|s[7])&16383}var c=e.msecs===void 0?Date.now():e.msecs,l=e.nsecs===void 0?vr+1:e.nsecs,u=c-_r+(l-vr)/1e4;if(u<0&&e.clockseq===void 0&&(o=o+1&16383),(u<0||c>_r)&&e.nsecs===void 0&&(l=0),l>=1e4)throw Error(`uuid.v1(): Can't create more than 10M uuids/sec`);_r=c,vr=l,gr=o,c+=0xb1d069b5400;var d=((c&268435455)*1e4+l)%4294967296;i[r++]=d>>>24&255,i[r++]=d>>>16&255,i[r++]=d>>>8&255,i[r++]=d&255;var f=c/4294967296*1e4&268435455;i[r++]=f>>>8&255,i[r++]=f&255,i[r++]=f>>>24&15|16,i[r++]=f>>>16&255,i[r++]=o>>>8|128,i[r++]=o&255;for(var p=0;p<6;++p)i[r+p]=a[p];return t||ur(i)}var hr,gr,_r,vr,yr=e((()=>{ar(),pr(),_r=0,vr=0}));function br(e){if(!cr(e))throw TypeError(`Invalid UUID`);var t,n=new Uint8Array(16);return n[0]=(t=parseInt(e.slice(0,8),16))>>>24,n[1]=t>>>16&255,n[2]=t>>>8&255,n[3]=t&255,n[4]=(t=parseInt(e.slice(9,13),16))>>>8,n[5]=t&255,n[6]=(t=parseInt(e.slice(14,18),16))>>>8,n[7]=t&255,n[8]=(t=parseInt(e.slice(19,23),16))>>>8,n[9]=t&255,n[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,n[11]=t/4294967296&255,n[12]=t>>>24&255,n[13]=t>>>16&255,n[14]=t>>>8&255,n[15]=t&255,n}var xr=e((()=>{lr()}));function Sr(e){e=unescape(encodeURIComponent(e));for(var t=[],n=0;n<e.length;++n)t.push(e.charCodeAt(n));return t}function Cr(e,t,n){function r(e,r,i,a){if(typeof e==`string`&&(e=Sr(e)),typeof r==`string`&&(r=br(r)),r.length!==16)throw TypeError(`Namespace must be array-like (16 iterable integer values, 0-255)`);var o=new Uint8Array(16+e.length);if(o.set(r),o.set(e,r.length),o=n(o),o[6]=o[6]&15|t,o[8]=o[8]&63|128,i){a||=0;for(var s=0;s<16;++s)i[a+s]=o[s];return i}return ur(o)}try{r.name=e}catch{}return r.DNS=wr,r.URL=Tr,r}var wr,Tr,Er=e((()=>{pr(),xr(),wr=`6ba7b810-9dad-11d1-80b4-00c04fd430c8`,Tr=`6ba7b811-9dad-11d1-80b4-00c04fd430c8`}));function Dr(e){if(typeof e==`string`){var t=unescape(encodeURIComponent(e));e=new Uint8Array(t.length);for(var n=0;n<t.length;++n)e[n]=t.charCodeAt(n)}return Or(Ar(jr(e),e.length*8))}function Or(e){for(var t=[],n=e.length*32,r=`0123456789abcdef`,i=0;i<n;i+=8){var a=e[i>>5]>>>i%32&255,o=parseInt(r.charAt(a>>>4&15)+r.charAt(a&15),16);t.push(o)}return t}function kr(e){return(e+64>>>9<<4)+14+1}function Ar(e,t){e[t>>5]|=128<<t%32,e[kr(t)-1]=t;for(var n=1732584193,r=-271733879,i=-1732584194,a=271733878,o=0;o<e.length;o+=16){var s=n,c=r,l=i,u=a;n=Fr(n,r,i,a,e[o],7,-680876936),a=Fr(a,n,r,i,e[o+1],12,-389564586),i=Fr(i,a,n,r,e[o+2],17,606105819),r=Fr(r,i,a,n,e[o+3],22,-1044525330),n=Fr(n,r,i,a,e[o+4],7,-176418897),a=Fr(a,n,r,i,e[o+5],12,1200080426),i=Fr(i,a,n,r,e[o+6],17,-1473231341),r=Fr(r,i,a,n,e[o+7],22,-45705983),n=Fr(n,r,i,a,e[o+8],7,1770035416),a=Fr(a,n,r,i,e[o+9],12,-1958414417),i=Fr(i,a,n,r,e[o+10],17,-42063),r=Fr(r,i,a,n,e[o+11],22,-1990404162),n=Fr(n,r,i,a,e[o+12],7,1804603682),a=Fr(a,n,r,i,e[o+13],12,-40341101),i=Fr(i,a,n,r,e[o+14],17,-1502002290),r=Fr(r,i,a,n,e[o+15],22,1236535329),n=Ir(n,r,i,a,e[o+1],5,-165796510),a=Ir(a,n,r,i,e[o+6],9,-1069501632),i=Ir(i,a,n,r,e[o+11],14,643717713),r=Ir(r,i,a,n,e[o],20,-373897302),n=Ir(n,r,i,a,e[o+5],5,-701558691),a=Ir(a,n,r,i,e[o+10],9,38016083),i=Ir(i,a,n,r,e[o+15],14,-660478335),r=Ir(r,i,a,n,e[o+4],20,-405537848),n=Ir(n,r,i,a,e[o+9],5,568446438),a=Ir(a,n,r,i,e[o+14],9,-1019803690),i=Ir(i,a,n,r,e[o+3],14,-187363961),r=Ir(r,i,a,n,e[o+8],20,1163531501),n=Ir(n,r,i,a,e[o+13],5,-1444681467),a=Ir(a,n,r,i,e[o+2],9,-51403784),i=Ir(i,a,n,r,e[o+7],14,1735328473),r=Ir(r,i,a,n,e[o+12],20,-1926607734),n=Lr(n,r,i,a,e[o+5],4,-378558),a=Lr(a,n,r,i,e[o+8],11,-2022574463),i=Lr(i,a,n,r,e[o+11],16,1839030562),r=Lr(r,i,a,n,e[o+14],23,-35309556),n=Lr(n,r,i,a,e[o+1],4,-1530992060),a=Lr(a,n,r,i,e[o+4],11,1272893353),i=Lr(i,a,n,r,e[o+7],16,-155497632),r=Lr(r,i,a,n,e[o+10],23,-1094730640),n=Lr(n,r,i,a,e[o+13],4,681279174),a=Lr(a,n,r,i,e[o],11,-358537222),i=Lr(i,a,n,r,e[o+3],16,-722521979),r=Lr(r,i,a,n,e[o+6],23,76029189),n=Lr(n,r,i,a,e[o+9],4,-640364487),a=Lr(a,n,r,i,e[o+12],11,-421815835),i=Lr(i,a,n,r,e[o+15],16,530742520),r=Lr(r,i,a,n,e[o+2],23,-995338651),n=Rr(n,r,i,a,e[o],6,-198630844),a=Rr(a,n,r,i,e[o+7],10,1126891415),i=Rr(i,a,n,r,e[o+14],15,-1416354905),r=Rr(r,i,a,n,e[o+5],21,-57434055),n=Rr(n,r,i,a,e[o+12],6,1700485571),a=Rr(a,n,r,i,e[o+3],10,-1894986606),i=Rr(i,a,n,r,e[o+10],15,-1051523),r=Rr(r,i,a,n,e[o+1],21,-2054922799),n=Rr(n,r,i,a,e[o+8],6,1873313359),a=Rr(a,n,r,i,e[o+15],10,-30611744),i=Rr(i,a,n,r,e[o+6],15,-1560198380),r=Rr(r,i,a,n,e[o+13],21,1309151649),n=Rr(n,r,i,a,e[o+4],6,-145523070),a=Rr(a,n,r,i,e[o+11],10,-1120210379),i=Rr(i,a,n,r,e[o+2],15,718787259),r=Rr(r,i,a,n,e[o+9],21,-343485551),n=Mr(n,s),r=Mr(r,c),i=Mr(i,l),a=Mr(a,u)}return[n,r,i,a]}function jr(e){if(e.length===0)return[];for(var t=e.length*8,n=new Uint32Array(kr(t)),r=0;r<t;r+=8)n[r>>5]|=(e[r/8]&255)<<r%32;return n}function Mr(e,t){var n=(e&65535)+(t&65535);return(e>>16)+(t>>16)+(n>>16)<<16|n&65535}function Nr(e,t){return e<<t|e>>>32-t}function Pr(e,t,n,r,i,a){return Mr(Nr(Mr(Mr(t,e),Mr(r,a)),i),n)}function Fr(e,t,n,r,i,a,o){return Pr(t&n|~t&r,e,t,i,a,o)}function Ir(e,t,n,r,i,a,o){return Pr(t&r|n&~r,e,t,i,a,o)}function Lr(e,t,n,r,i,a,o){return Pr(t^n^r,e,t,i,a,o)}function Rr(e,t,n,r,i,a,o){return Pr(n^(t|~r),e,t,i,a,o)}var zr=e((()=>{})),Br,Vr=e((()=>{Er(),zr(),Br=Cr(`v3`,48,Dr)}));function Hr(e,t,n){e||={};var r=e.random||(e.rng||nr)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){n||=0;for(var i=0;i<16;++i)t[n+i]=r[i];return t}return ur(r)}var Ur=e((()=>{ar(),pr()}));function Wr(e,t,n,r){switch(e){case 0:return t&n^~t&r;case 1:return t^n^r;case 2:return t&n^t&r^n&r;case 3:return t^n^r}}function Gr(e,t){return e<<t|e>>>32-t}function Kr(e){var t=[1518500249,1859775393,2400959708,3395469782],n=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof e==`string`){var r=unescape(encodeURIComponent(e));e=[];for(var i=0;i<r.length;++i)e.push(r.charCodeAt(i))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);for(var a=e.length/4+2,o=Math.ceil(a/16),s=Array(o),c=0;c<o;++c){for(var l=new Uint32Array(16),u=0;u<16;++u)l[u]=e[c*64+u*4]<<24|e[c*64+u*4+1]<<16|e[c*64+u*4+2]<<8|e[c*64+u*4+3];s[c]=l}s[o-1][14]=(e.length-1)*8/2**32,s[o-1][14]=Math.floor(s[o-1][14]),s[o-1][15]=(e.length-1)*8&4294967295;for(var d=0;d<o;++d){for(var f=new Uint32Array(80),p=0;p<16;++p)f[p]=s[d][p];for(var m=16;m<80;++m)f[m]=Gr(f[m-3]^f[m-8]^f[m-14]^f[m-16],1);for(var h=n[0],g=n[1],_=n[2],v=n[3],y=n[4],ee=0;ee<80;++ee){var te=Math.floor(ee/20),ne=Gr(h,5)+Wr(te,g,_,v)+y+t[te]+f[ee]>>>0;y=v,v=_,_=Gr(g,30)>>>0,g=h,h=ne}n[0]=n[0]+h>>>0,n[1]=n[1]+g>>>0,n[2]=n[2]+_>>>0,n[3]=n[3]+v>>>0,n[4]=n[4]+y>>>0}return[n[0]>>24&255,n[0]>>16&255,n[0]>>8&255,n[0]&255,n[1]>>24&255,n[1]>>16&255,n[1]>>8&255,n[1]&255,n[2]>>24&255,n[2]>>16&255,n[2]>>8&255,n[2]&255,n[3]>>24&255,n[3]>>16&255,n[3]>>8&255,n[3]&255,n[4]>>24&255,n[4]>>16&255,n[4]>>8&255,n[4]&255]}var qr=e((()=>{})),Jr,Yr=e((()=>{Er(),qr(),Jr=Cr(`v5`,80,Kr)})),Xr,Zr=e((()=>{Xr=`00000000-0000-0000-0000-000000000000`}));function Qr(e){if(!cr(e))throw TypeError(`Invalid UUID`);return parseInt(e.substr(14,1),16)}var $r=e((()=>{lr()})),ei=n({NIL:()=>Xr,parse:()=>br,stringify:()=>ur,v1:()=>mr,v3:()=>Br,v4:()=>Hr,v5:()=>Jr,validate:()=>cr,version:()=>Qr}),ti=e((()=>{yr(),Vr(),Ur(),Yr(),Zr(),$r(),lr(),pr(),xr()})),ni=i(((e,n)=>{var r=(ti(),t(ei)).v4;n.exports=function(e,t,n,i){if(typeof e!=`string`)throw TypeError(e+` must be a string`);i||={};let a=typeof i.version==`number`?i.version:2;if(a!==1&&a!==2)throw TypeError(a+` must be 1 or 2`);let o={method:e};if(a===2&&(o.jsonrpc=`2.0`),t){if(typeof t!=`object`&&!Array.isArray(t))throw TypeError(t+` must be an object, array or omitted`);o.params=t}return n===void 0?o.id=(typeof i.generator==`function`?i.generator:function(){return r()})(o,i):a===2&&n===null?i.notificationIdNull&&(o.id=null):o.id=n,o}})),ri=i(((e,n)=>{var r=(ti(),t(ei)).v4,i=ni(),a=function(e,t){if(!(this instanceof a))return new a(e,t);t||={},this.options={reviver:t.reviver===void 0?null:t.reviver,replacer:t.replacer===void 0?null:t.replacer,generator:t.generator===void 0?function(){return r()}:t.generator,version:t.version===void 0?2:t.version,notificationIdNull:typeof t.notificationIdNull==`boolean`&&t.notificationIdNull},this.callServer=e};n.exports=a,a.prototype.request=function(e,t,n,r){let a=this,o=null,s=Array.isArray(e)&&typeof t==`function`;if(this.options.version===1&&s)throw TypeError(`JSON-RPC 1.0 does not support batching`);if(s||!s&&e&&typeof e==`object`&&typeof t==`function`)r=t,o=e;else{typeof n==`function`&&(r=n,n=void 0);let a=typeof r==`function`;try{o=i(e,t,n,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(e){if(a)return r(e);throw e}if(!a)return o}let c;try{c=JSON.stringify(o,this.options.replacer)}catch(e){return r(e)}return this.callServer(c,function(e,t){a._parseResponse(e,t,r)}),o},a.prototype._parseResponse=function(e,t,n){if(e){n(e);return}if(!t)return n();let r;try{r=JSON.parse(t,this.options.reviver)}catch(e){return n(e)}if(n.length===3){if(Array.isArray(r)){let e=function(e){return e.error!==void 0};return n(null,r.filter(e),r.filter(function(t){return!e(t)}))}return n(null,r.error,r.result)}n(null,r)}}));function ii(e,t){return new ai(e,t)}var ai,oi,si,ci=e((()=>{v(),pt(),ai=class extends dt.default{socket;constructor(e,t,n){super(),this.socket=new window.WebSocket(e,n),this.socket.onopen=()=>this.emit(`open`),this.socket.onmessage=e=>this.emit(`message`,e.data),this.socket.onerror=e=>this.emit(`error`,e),this.socket.onclose=e=>{this.emit(`close`,e.code,e.reason)}}send(e,t,n){let r=n||t;try{this.socket.send(e),r()}catch(e){r(e)}}close(e,t){this.socket.close(e,t)}addEventListener(e,t,n){this.socket.addEventListener(e,t,n)}},oi=class{encode(e){return JSON.stringify(e)}decode(e){return JSON.parse(e)}},si=class extends dt.default{address;rpc_id;queue;options;autoconnect;ready;reconnect;reconnect_timer_id;reconnect_interval;max_reconnects;rest_options;current_reconnects;generate_request_id;socket;webSocketFactory;dataPack;constructor(e,t=`ws://localhost:8080`,{autoconnect:n=!0,reconnect:r=!0,reconnect_interval:i=1e3,max_reconnects:a=5,...o}={},s,c){super(),this.webSocketFactory=e,this.queue={},this.rpc_id=0,this.address=t,this.autoconnect=n,this.ready=!1,this.reconnect=r,this.reconnect_timer_id=void 0,this.reconnect_interval=i,this.max_reconnects=a,this.rest_options=o,this.current_reconnects=0,this.generate_request_id=s||(()=>typeof this.rpc_id==`number`?++this.rpc_id:Number(this.rpc_id)+1),this.dataPack=c||new oi,this.autoconnect&&this._connect(this.address,{autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects,...this.rest_options})}connect(){this.socket||this._connect(this.address,{autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects,...this.rest_options})}call(e,t,n,r){return!r&&typeof n==`object`&&(r=n,n=null),new Promise((i,a)=>{if(!this.ready)return a(Error(`socket not ready`));let o=this.generate_request_id(e,t),s={jsonrpc:`2.0`,method:e,params:t||void 0,id:o};this.socket.send(this.dataPack.encode(s),r,e=>{if(e)return a(e);this.queue[o]={promise:[i,a]},n&&(this.queue[o].timeout=setTimeout(()=>{delete this.queue[o],a(Error(`reply timeout`))},n))})})}async login(e){let t=await this.call(`rpc.login`,e);if(!t)throw Error(`authentication failed`);return t}async listMethods(){return await this.call(`__listMethods`)}notify(e,t){return new Promise((n,r)=>{if(!this.ready)return r(Error(`socket not ready`));let i={jsonrpc:`2.0`,method:e,params:t};this.socket.send(this.dataPack.encode(i),e=>{if(e)return r(e);n()})})}async subscribe(e){typeof e==`string`&&(e=[e]);let t=await this.call(`rpc.on`,e);if(typeof e==`string`&&t[e]!==`ok`)throw Error(`Failed subscribing to an event '`+e+`' with: `+t[e]);return t}async unsubscribe(e){typeof e==`string`&&(e=[e]);let t=await this.call(`rpc.off`,e);if(typeof e==`string`&&t[e]!==`ok`)throw Error(`Failed unsubscribing from an event with: `+t);return t}close(e,t){this.socket.close(e||1e3,t)}setAutoReconnect(e){this.reconnect=e}setReconnectInterval(e){this.reconnect_interval=e}setMaxReconnects(e){this.max_reconnects=e}_connect(e,t){clearTimeout(this.reconnect_timer_id),this.socket=this.webSocketFactory(e,t),this.socket.addEventListener(`open`,()=>{this.ready=!0,this.emit(`open`),this.current_reconnects=0}),this.socket.addEventListener(`message`,({data:e})=>{e instanceof ArrayBuffer&&(e=_.from(e).toString());try{e=this.dataPack.decode(e)}catch{return}if(e.notification&&this.listeners(e.notification).length){if(!Object.keys(e.params).length)return this.emit(e.notification);let t=[e.notification];if(e.params.constructor===Object)t.push(e.params);else for(let n=0;n<e.params.length;n++)t.push(e.params[n]);return Promise.resolve().then(()=>{this.emit.apply(this,t)})}if(!this.queue[e.id])return e.method?Promise.resolve().then(()=>{this.emit(e.method,e?.params)}):void 0;`error`in e==`result`in e&&this.queue[e.id].promise[1](Error(`Server response malformed. Response must include either "result" or "error", but not both.`)),this.queue[e.id].timeout&&clearTimeout(this.queue[e.id].timeout),e.error?this.queue[e.id].promise[1](e.error):this.queue[e.id].promise[0](e.result),delete this.queue[e.id]}),this.socket.addEventListener(`error`,e=>this.emit(`error`,e)),this.socket.addEventListener(`close`,({code:n,reason:r})=>{this.ready&&setTimeout(()=>this.emit(`close`,n,r),0),this.ready=!1,this.socket=void 0,n!==1e3&&(this.current_reconnects++,this.reconnect&&(this.max_reconnects>this.current_reconnects||this.max_reconnects===0)&&(this.reconnect_timer_id=setTimeout(()=>this._connect(e,t),this.reconnect_interval)))})}}}));function li(e){try{return ne.ExtendedPoint.fromHex(e),!0}catch{return!1}}function ui(e){return e._bn!==void 0}function di(e,t){let n=e=>{if(e.span>=0)return e.span;if(typeof e.alloc==`function`)return e.alloc(t[e.property]);if(`count`in e&&`elementLayout`in e){let r=t[e.property];if(Array.isArray(r))return r.length*n(e.elementLayout)}else if(`fields`in e)return di({layout:e},t[e.property]);return 0},r=0;return e.layout.fields.forEach(e=>{r+=n(e)}),r}function fi(e){let t=0,n=0;for(;;){let r=e.shift();if(t|=(r&127)<<n*7,n+=1,!(r&128))break}return t}function pi(e,t){let n=t;for(;;){let t=n&127;if(n>>=7,n==0){e.push(t);break}t|=128,e.push(t)}}function mi(e,t){if(!e)throw Error(t||`Assertion failed`)}function hi(e){if(e.length===0)throw Error(ca);return e.shift()}function gi(e,...t){let[n]=t;if(t.length===2?n+(t[1]??0)>e.length:n>=e.length)throw Error(ca);return e.splice(...t)}async function _i(e,t,n,r){let i=r&&{skipPreflight:r.skipPreflight,preflightCommitment:r.preflightCommitment||r.commitment,maxRetries:r.maxRetries,minContextSlot:r.minContextSlot},a=await e.sendTransaction(t,n,i),o;if(t.recentBlockhash!=null&&t.lastValidBlockHeight!=null)o=(await e.confirmTransaction({abortSignal:r?.abortSignal,signature:a,blockhash:t.recentBlockhash,lastValidBlockHeight:t.lastValidBlockHeight},r&&r.commitment)).value;else if(t.minNonceContextSlot!=null&&t.nonceInfo!=null){let{nonceInstruction:n}=t.nonceInfo,i=n.keys[0].pubkey;o=(await e.confirmTransaction({abortSignal:r?.abortSignal,minContextSlot:t.minNonceContextSlot,nonceAccountPubkey:i,nonceValue:t.nonceInfo.nonce,signature:a},r&&r.commitment)).value}else r?.abortSignal,o=(await e.confirmTransaction(a,r&&r.commitment)).value;if(o.err)throw a==null?Error(`Transaction ${a} failed (${JSON.stringify(o)})`):new Sa({action:`send`,signature:a,transactionMessage:`Status: (${JSON.stringify(o)})`});return a}function vi(e){return new Promise(t=>setTimeout(t,e))}function B(e,t){let n=e.layout.span>=0?e.layout.span:di(e,t),r=_.alloc(n),i=Object.assign({instruction:e.index},t);return e.layout.encode(i,r),r}function yi(e){let t=(0,Bi.blob)(8,e),n=t.decode.bind(t),r=t.encode.bind(t),i=t,a=On();return i.decode=(e,t)=>{let r=n(e,t);return a.decode(r)},i.encode=(e,t,n)=>{let i=a.encode(e);return r(i,t,n)},i}function bi(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}function xi(){if(Ma)return ja;Ma=1;var e=Object.prototype.toString,t=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};function n(r,i){var a,o,s,c,l,u,d;if(r===!0)return`true`;if(r===!1)return`false`;switch(typeof r){case`object`:if(r===null)return null;if(r.toJSON&&typeof r.toJSON==`function`)return n(r.toJSON(),i);if(d=e.call(r),d===`[object Array]`){for(s=`[`,o=r.length-1,a=0;a<o;a++)s+=n(r[a],!0)+`,`;return o>-1&&(s+=n(r[a],!0)),s+`]`}if(d===`[object Object]`){for(c=t(r).sort(),o=c.length,s=``,a=0;a<o;)l=c[a],u=n(r[l],!1),u!==void 0&&(s&&(s+=`,`),s+=JSON.stringify(l)+`:`+u),a++;return`{`+s+`}`}return JSON.stringify(r);case`function`:case`undefined`:return i?null:void 0;case`string`:return JSON.stringify(r);default:return isFinite(r)?r:null}}return ja=function(e){var t=n(e,!1);if(t!==void 0)return``+t},ja}function Si(e){let t=0;for(;e>1;)e/=2,t++;return t}function Ci(e){return e===0?1:(e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,e|=e>>32,e+1)}function wi(e,t){let n;try{n=e.layout.decode(t)}catch(e){throw Error(`invalid instruction; `+e)}if(n.typeIndex!==e.index)throw Error(`invalid account data; account type mismatch ${n.typeIndex} != ${e.index}`);return n}function Ti(e){let t=e.match(Va);if(t==null)throw TypeError(`Failed to validate endpoint URL \`${e}\``);let[n,r,i,a]=t,o=e.startsWith(`https:`)?`wss:`:`ws:`,s=i==null?null:parseInt(i.slice(1),10);return`${o}//${r}${s==null?``:`:${s+1}`}${a}`}function Ei(e){if(/^https?:/.test(e)===!1)throw TypeError("Endpoint URL must start with `http:` or `https:`.");return e}function Di(e){let t,n;if(typeof e==`string`)t=e;else if(e){let{commitment:r,...i}=e;t=r,n=i}return{commitment:t,config:n}}function Oi(e){return e.map(e=>`memcmp`in e?{...e,memcmp:{...e.memcmp,encoding:e.memcmp.encoding??`base58`}}:e)}function ki(e){return Xn([z({jsonrpc:Kn(`2.0`),id:R(),result:e}),z({jsonrpc:Kn(`2.0`),id:R(),error:z({code:Zn(),message:R(),data:L(Un())})})])}function V(e){return Qn(ki(e),Ka,t=>`error`in t?t:{...t,result:N(t.result,e)})}function Ai(e){return V(z({context:z({slot:I()}),value:e}))}function ji(e){return z({context:z({slot:I()}),value:e})}function Mi(e,t){return e===0?new ua({header:t.header,staticAccountKeys:t.accountKeys.map(e=>new W(e)),recentBlockhash:t.recentBlockhash,compiledInstructions:t.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:Ri.default.decode(e.data)})),addressTableLookups:t.addressTableLookups}):new la(t)}function Ni(e,t,n,r,i,a){let o=n||Ia,s,c;return r&&(c=async(e,t)=>{let n=await new Promise((n,i)=>{try{r(e,t,(e,t)=>n([e,t]))}catch(e){i(e)}});return await o(...n)}),new Vi.default(async(n,r)=>{let a={method:`POST`,body:n,agent:s,headers:Object.assign({"Content-Type":`application/json`},t||{},Os)};try{let t=5,n,s=500;for(;n=c?await c(e,a):await o(e,a),!(n.status!==429||i===!0||(--t,t===0));)await vi(s),s*=2;let l=await n.text();n.ok?r(null,l):r(Error(`${n.status} ${n.statusText}: ${l}`))}catch(e){e instanceof Error&&r(e)}},{})}function Pi(e){return(t,n)=>new Promise((r,i)=>{e.request(t,n,(e,t)=>{if(e){i(e);return}r(t)})})}function Fi(e){return t=>new Promise((n,r)=>{t.length===0&&n([]);let i=t.map(t=>e.request(t.methodName,t.args));e.request(i,(e,t)=>{if(e){r(e);return}n(t)})})}function Ii(e,t){let n=t===!1?`http`:`https`;if(!e)return ec[n].devnet;let r=ec[n][e];if(!r)throw Error(`Unknown ${n} cluster: ${e}`);return r}var Li,Ri,zi,H,Bi,Vi,Hi,Ui,Wi,Gi,U,Ki,qi,Ji,Yi,W,Xi,Zi,Qi,$i,ea,G,ta,na,ra,ia,aa,oa,sa,ca,la,ua,da,fa,pa,ma,ha,ga,_a,va,ya,ba,xa,Sa,K,Ca,wa,Ta,Ea,Da,Oa,ka,Aa,ja,Ma,Na,Pa,Fa,Ia,La,Ra,za,Ba,Va,Ha,Ua,Wa,Ga,Ka,qa,Ja,Ya,Xa,Za,Qa,$a,eo,to,no,ro,io,ao,oo,so,co,lo,uo,fo,po,mo,ho,go,_o,vo,yo,bo,xo,So,Co,wo,To,Eo,Do,Oo,ko,Ao,jo,Mo,No,Po,Fo,Io,Lo,Ro,zo,Bo,Vo,Ho,Uo,Wo,Go,Ko,qo,Jo,Yo,Xo,Zo,Qo,$o,es,ts,ns,rs,is,as,os,ss,cs,ls,us,ds,fs,ps,ms,hs,gs,_s,vs,ys,bs,xs,Ss,Cs,ws,Ts,Es,Ds,Os,ks,As,js,Ms,Ns,Ps,Fs,Is,Ls,Rs,zs,Bs,Vs,Hs,Us,Ws,Gs,Ks,qs,Js,Ys,Xs,Zs,Qs,$s,ec,tc=e((()=>{v(),te(),Li=r(b()),Ri=r(S()),m(),zi=Qt(),H=r($t()),Bi=r($t()),kn(),tr(),Vi=r(ri()),ci(),g(),w(),ne.utils.randomPrivateKey,Hi=()=>{let e=ne.utils.randomPrivateKey(),t=Ui(e),n=new Uint8Array(64);return n.set(e),n.set(t,32),{publicKey:t,secretKey:n}},Ui=ne.getPublicKey,Wi=(e,t)=>ne.sign(e,t.slice(0,32)),Gi=ne.verify,U=e=>_.isBuffer(e)?e:e instanceof Uint8Array?_.from(e.buffer,e.byteOffset,e.byteLength):_.from(e),Ki=class{constructor(e){Object.assign(this,e)}encode(){return _.from((0,zi.serialize)(qi,this))}static decode(e){return(0,zi.deserialize)(qi,this,e)}static decodeUnchecked(e){return(0,zi.deserializeUnchecked)(qi,this,e)}},qi=new Map,Yi=1,W=class e extends Ki{constructor(e){if(super({}),this._bn=void 0,ui(e))this._bn=e._bn;else{if(typeof e==`string`){let t=Ri.default.decode(e);if(t.length!=32)throw Error(`Invalid public key input`);this._bn=new Li.default(t)}else this._bn=new Li.default(e);if(this._bn.byteLength()>32)throw Error(`Invalid public key input`)}}static unique(){let t=new e(Yi);return Yi+=1,new e(t.toBuffer())}equals(e){return this._bn.eq(e._bn)}toBase58(){return Ri.default.encode(this.toBytes())}toJSON(){return this.toBase58()}toBytes(){let e=this.toBuffer();return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}toBuffer(){let e=this._bn.toArrayLike(_);if(e.length===32)return e;let t=_.alloc(32);return e.copy(t,32-e.length),t}get[Symbol.toStringTag](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(t,n,r){let i=_.concat([t.toBuffer(),_.from(n),r.toBuffer()]),a=p(i);return new e(a)}static createProgramAddressSync(t,n){let r=_.alloc(0);t.forEach(function(e){if(e.length>32)throw TypeError(`Max seed length exceeded`);r=_.concat([r,U(e)])}),r=_.concat([r,n.toBuffer(),_.from(`ProgramDerivedAddress`)]);let i=p(r);if(li(i))throw Error(`Invalid seeds, address must fall off the curve`);return new e(i)}static async createProgramAddress(e,t){return this.createProgramAddressSync(e,t)}static findProgramAddressSync(e,t){let n=255,r;for(;n!=0;){try{let i=e.concat(_.from([n]));r=this.createProgramAddressSync(i,t)}catch(e){if(e instanceof TypeError)throw e;n--;continue}return[r,n]}throw Error(`Unable to find a viable program address nonce`)}static async findProgramAddress(e,t){return this.findProgramAddressSync(e,t)}static isOnCurve(t){return li(new e(t).toBytes())}},Ji=W,W.default=new Ji(`11111111111111111111111111111111`),qi.set(W,{kind:`struct`,fields:[[`_bn`,`u256`]]}),new W(`BPFLoader1111111111111111111111111111111111`),Xi=1232,Zi=class extends Error{constructor(e){super(`Signature ${e} has expired: block height exceeded.`),this.signature=void 0,this.signature=e}},Object.defineProperty(Zi.prototype,"name",{value:`TransactionExpiredBlockheightExceededError`}),Qi=class extends Error{constructor(e,t){super(`Transaction was not confirmed in ${t.toFixed(2)} seconds. It is unknown if it succeeded or failed. Check signature ${e} using the Solana Explorer or CLI tools.`),this.signature=void 0,this.signature=e}},Object.defineProperty(Qi.prototype,"name",{value:`TransactionExpiredTimeoutError`}),$i=class extends Error{constructor(e){super(`Signature ${e} has expired: the nonce is no longer valid.`),this.signature=void 0,this.signature=e}},Object.defineProperty($i.prototype,"name",{value:`TransactionExpiredNonceInvalidError`}),ea=class{constructor(e,t){this.staticAccountKeys=void 0,this.accountKeysFromLookups=void 0,this.staticAccountKeys=e,this.accountKeysFromLookups=t}keySegments(){let e=[this.staticAccountKeys];return this.accountKeysFromLookups&&(e.push(this.accountKeysFromLookups.writable),e.push(this.accountKeysFromLookups.readonly)),e}get(e){for(let t of this.keySegments())if(e<t.length)return t[e];else e-=t.length}get length(){return this.keySegments().flat().length}compileInstructions(e){if(this.length>256)throw Error(`Account index overflow encountered during compilation`);let t=new Map;this.keySegments().flat().forEach((e,n)=>{t.set(e.toBase58(),n)});let n=e=>{let n=t.get(e.toBase58());if(n===void 0)throw Error(`Encountered an unknown instruction account key during compilation`);return n};return e.map(e=>({programIdIndex:n(e.programId),accountKeyIndexes:e.keys.map(e=>n(e.pubkey)),data:e.data}))}},G=(e=`publicKey`)=>H.blob(32,e),ta=(e=`signature`)=>H.blob(64,e),na=(e=`string`)=>{let t=H.struct([H.u32(`length`),H.u32(`lengthPadding`),H.blob(H.offset(H.u32(),-8),`chars`)],e),n=t.decode.bind(t),r=t.encode.bind(t),i=t;return i.decode=(e,t)=>n(e,t).chars.toString(),i.encode=(e,t,n)=>{let i={chars:_.from(e,`utf8`)};return r(i,t,n)},i.alloc=e=>H.u32().span+H.u32().span+_.from(e,`utf8`).length,i},ra=(e=`authorized`)=>H.struct([G(`staker`),G(`withdrawer`)],e),ia=(e=`lockup`)=>H.struct([H.ns64(`unixTimestamp`),H.ns64(`epoch`),G(`custodian`)],e),aa=(e=`voteInit`)=>H.struct([G(`nodePubkey`),G(`authorizedVoter`),G(`authorizedWithdrawer`),H.u8(`commission`)],e),oa=(e=`voteAuthorizeWithSeedArgs`)=>H.struct([H.u32(`voteAuthorizationType`),G(`currentAuthorityDerivedKeyOwnerPubkey`),na(`currentAuthorityDerivedKeySeed`),G(`newAuthorized`)],e),sa=class e{constructor(e,t){this.payer=void 0,this.keyMetaMap=void 0,this.payer=e,this.keyMetaMap=t}static compile(t,n){let r=new Map,i=e=>{let t=e.toBase58(),n=r.get(t);return n===void 0&&(n={isSigner:!1,isWritable:!1,isInvoked:!1},r.set(t,n)),n},a=i(n);a.isSigner=!0,a.isWritable=!0;for(let e of t){i(e.programId).isInvoked=!0;for(let t of e.keys){let e=i(t.pubkey);e.isSigner||=t.isSigner,e.isWritable||=t.isWritable}}return new e(n,r)}getMessageComponents(){let e=[...this.keyMetaMap.entries()];mi(e.length<=256,`Max static account keys length exceeded`);let t=e.filter(([,e])=>e.isSigner&&e.isWritable),n=e.filter(([,e])=>e.isSigner&&!e.isWritable),r=e.filter(([,e])=>!e.isSigner&&e.isWritable),i=e.filter(([,e])=>!e.isSigner&&!e.isWritable),a={numRequiredSignatures:t.length+n.length,numReadonlySignedAccounts:n.length,numReadonlyUnsignedAccounts:i.length};{mi(t.length>0,`Expected at least one writable signer key`);let[e]=t[0];mi(e===this.payer.toBase58(),`Expected first writable signer key to be the fee payer`)}return[a,[...t.map(([e])=>new W(e)),...n.map(([e])=>new W(e)),...r.map(([e])=>new W(e)),...i.map(([e])=>new W(e))]]}extractTableLookup(e){let[t,n]=this.drainKeysFoundInLookupTable(e.state.addresses,e=>!e.isSigner&&!e.isInvoked&&e.isWritable),[r,i]=this.drainKeysFoundInLookupTable(e.state.addresses,e=>!e.isSigner&&!e.isInvoked&&!e.isWritable);if(t.length!==0||r.length!==0)return[{accountKey:e.key,writableIndexes:t,readonlyIndexes:r},{writable:n,readonly:i}]}drainKeysFoundInLookupTable(e,t){let n=[],r=[];for(let[i,a]of this.keyMetaMap.entries())if(t(a)){let t=new W(i),a=e.findIndex(e=>e.equals(t));a>=0&&(mi(a<256,`Max lookup table index exceeded`),n.push(a),r.push(t),this.keyMetaMap.delete(i))}return[n,r]}},ca=`Reached end of buffer unexpectedly`,la=class e{constructor(e){this.header=void 0,this.accountKeys=void 0,this.recentBlockhash=void 0,this.instructions=void 0,this.indexToProgramIds=new Map,this.header=e.header,this.accountKeys=e.accountKeys.map(e=>new W(e)),this.recentBlockhash=e.recentBlockhash,this.instructions=e.instructions,this.instructions.forEach(e=>this.indexToProgramIds.set(e.programIdIndex,this.accountKeys[e.programIdIndex]))}get version(){return`legacy`}get staticAccountKeys(){return this.accountKeys}get compiledInstructions(){return this.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:Ri.default.decode(e.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new ea(this.staticAccountKeys)}static compile(t){let[n,r]=sa.compile(t.instructions,t.payerKey).getMessageComponents(),i=new ea(r).compileInstructions(t.instructions).map(e=>({programIdIndex:e.programIdIndex,accounts:e.accountKeyIndexes,data:Ri.default.encode(e.data)}));return new e({header:n,accountKeys:r,recentBlockhash:t.recentBlockhash,instructions:i})}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){let t=this.header.numRequiredSignatures;return e>=this.header.numRequiredSignatures?e-t<this.accountKeys.length-t-this.header.numReadonlyUnsignedAccounts:e<t-this.header.numReadonlySignedAccounts}isProgramId(e){return this.indexToProgramIds.has(e)}programIds(){return[...this.indexToProgramIds.values()]}nonProgramIds(){return this.accountKeys.filter((e,t)=>!this.isProgramId(t))}serialize(){let e=this.accountKeys.length,t=[];pi(t,e);let n=this.instructions.map(e=>{let{accounts:t,programIdIndex:n}=e,r=Array.from(Ri.default.decode(e.data)),i=[];pi(i,t.length);let a=[];return pi(a,r.length),{programIdIndex:n,keyIndicesCount:_.from(i),keyIndices:t,dataLength:_.from(a),data:r}}),r=[];pi(r,n.length);let i=_.alloc(Xi);_.from(r).copy(i);let a=r.length;n.forEach(e=>{let t=H.struct([H.u8(`programIdIndex`),H.blob(e.keyIndicesCount.length,`keyIndicesCount`),H.seq(H.u8(`keyIndex`),e.keyIndices.length,`keyIndices`),H.blob(e.dataLength.length,`dataLength`),H.seq(H.u8(`userdatum`),e.data.length,`data`)]).encode(e,i,a);a+=t}),i=i.slice(0,a);let o=H.struct([H.blob(1,`numRequiredSignatures`),H.blob(1,`numReadonlySignedAccounts`),H.blob(1,`numReadonlyUnsignedAccounts`),H.blob(t.length,`keyCount`),H.seq(G(`key`),e,`keys`),G(`recentBlockhash`)]),s={numRequiredSignatures:_.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:_.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:_.from([this.header.numReadonlyUnsignedAccounts]),keyCount:_.from(t),keys:this.accountKeys.map(e=>U(e.toBytes())),recentBlockhash:Ri.default.decode(this.recentBlockhash)},c=_.alloc(2048),l=o.encode(s,c);return i.copy(c,l),c.slice(0,l+i.length)}static from(t){let n=[...t],r=hi(n);if(r!==(r&127))throw Error(`Versioned messages must be deserialized with VersionedMessage.deserialize()`);let i=hi(n),a=hi(n),o=fi(n),s=[];for(let e=0;e<o;e++){let e=gi(n,0,32);s.push(new W(_.from(e)))}let c=gi(n,0,32),l=fi(n),u=[];for(let e=0;e<l;e++){let e=hi(n),t=gi(n,0,fi(n)),r=gi(n,0,fi(n)),i=Ri.default.encode(_.from(r));u.push({programIdIndex:e,accounts:t,data:i})}let d={header:{numRequiredSignatures:r,numReadonlySignedAccounts:i,numReadonlyUnsignedAccounts:a},recentBlockhash:Ri.default.encode(_.from(c)),accountKeys:s,instructions:u};return new e(d)}},ua=class e{constructor(e){this.header=void 0,this.staticAccountKeys=void 0,this.recentBlockhash=void 0,this.compiledInstructions=void 0,this.addressTableLookups=void 0,this.header=e.header,this.staticAccountKeys=e.staticAccountKeys,this.recentBlockhash=e.recentBlockhash,this.compiledInstructions=e.compiledInstructions,this.addressTableLookups=e.addressTableLookups}get version(){return 0}get numAccountKeysFromLookups(){let e=0;for(let t of this.addressTableLookups)e+=t.readonlyIndexes.length+t.writableIndexes.length;return e}getAccountKeys(e){let t;if(e&&`accountKeysFromLookups`in e&&e.accountKeysFromLookups){if(this.numAccountKeysFromLookups!=e.accountKeysFromLookups.writable.length+e.accountKeysFromLookups.readonly.length)throw Error(`Failed to get account keys because of a mismatch in the number of account keys from lookups`);t=e.accountKeysFromLookups}else if(e&&`addressLookupTableAccounts`in e&&e.addressLookupTableAccounts)t=this.resolveAddressTableLookups(e.addressLookupTableAccounts);else if(this.addressTableLookups.length>0)throw Error(`Failed to get account keys because address table lookups were not resolved`);return new ea(this.staticAccountKeys,t)}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){let t=this.header.numRequiredSignatures,n=this.staticAccountKeys.length;return e>=n?e-n<this.addressTableLookups.reduce((e,t)=>e+t.writableIndexes.length,0):e>=this.header.numRequiredSignatures?e-t<n-t-this.header.numReadonlyUnsignedAccounts:e<t-this.header.numReadonlySignedAccounts}resolveAddressTableLookups(e){let t={writable:[],readonly:[]};for(let n of this.addressTableLookups){let r=e.find(e=>e.key.equals(n.accountKey));if(!r)throw Error(`Failed to find address lookup table account for table key ${n.accountKey.toBase58()}`);for(let e of n.writableIndexes)if(e<r.state.addresses.length)t.writable.push(r.state.addresses[e]);else throw Error(`Failed to find address for index ${e} in address lookup table ${n.accountKey.toBase58()}`);for(let e of n.readonlyIndexes)if(e<r.state.addresses.length)t.readonly.push(r.state.addresses[e]);else throw Error(`Failed to find address for index ${e} in address lookup table ${n.accountKey.toBase58()}`)}return t}static compile(t){let n=sa.compile(t.instructions,t.payerKey),r=[],i={writable:[],readonly:[]},a=t.addressLookupTableAccounts||[];for(let e of a){let t=n.extractTableLookup(e);if(t!==void 0){let[e,{writable:n,readonly:a}]=t;r.push(e),i.writable.push(...n),i.readonly.push(...a)}}let[o,s]=n.getMessageComponents(),c=new ea(s,i).compileInstructions(t.instructions);return new e({header:o,staticAccountKeys:s,recentBlockhash:t.recentBlockhash,compiledInstructions:c,addressTableLookups:r})}serialize(){let e=[];pi(e,this.staticAccountKeys.length);let t=this.serializeInstructions(),n=[];pi(n,this.compiledInstructions.length);let r=this.serializeAddressTableLookups(),i=[];pi(i,this.addressTableLookups.length);let a=H.struct([H.u8(`prefix`),H.struct([H.u8(`numRequiredSignatures`),H.u8(`numReadonlySignedAccounts`),H.u8(`numReadonlyUnsignedAccounts`)],`header`),H.blob(e.length,`staticAccountKeysLength`),H.seq(G(),this.staticAccountKeys.length,`staticAccountKeys`),G(`recentBlockhash`),H.blob(n.length,`instructionsLength`),H.blob(t.length,`serializedInstructions`),H.blob(i.length,`addressTableLookupsLength`),H.blob(r.length,`serializedAddressTableLookups`)]),o=new Uint8Array(Xi),s=a.encode({prefix:128,header:this.header,staticAccountKeysLength:new Uint8Array(e),staticAccountKeys:this.staticAccountKeys.map(e=>e.toBytes()),recentBlockhash:Ri.default.decode(this.recentBlockhash),instructionsLength:new Uint8Array(n),serializedInstructions:t,addressTableLookupsLength:new Uint8Array(i),serializedAddressTableLookups:r},o);return o.slice(0,s)}serializeInstructions(){let e=0,t=new Uint8Array(Xi);for(let n of this.compiledInstructions){let r=[];pi(r,n.accountKeyIndexes.length);let i=[];pi(i,n.data.length);let a=H.struct([H.u8(`programIdIndex`),H.blob(r.length,`encodedAccountKeyIndexesLength`),H.seq(H.u8(),n.accountKeyIndexes.length,`accountKeyIndexes`),H.blob(i.length,`encodedDataLength`),H.blob(n.data.length,`data`)]);e+=a.encode({programIdIndex:n.programIdIndex,encodedAccountKeyIndexesLength:new Uint8Array(r),accountKeyIndexes:n.accountKeyIndexes,encodedDataLength:new Uint8Array(i),data:n.data},t,e)}return t.slice(0,e)}serializeAddressTableLookups(){let e=0,t=new Uint8Array(Xi);for(let n of this.addressTableLookups){let r=[];pi(r,n.writableIndexes.length);let i=[];pi(i,n.readonlyIndexes.length);let a=H.struct([G(`accountKey`),H.blob(r.length,`encodedWritableIndexesLength`),H.seq(H.u8(),n.writableIndexes.length,`writableIndexes`),H.blob(i.length,`encodedReadonlyIndexesLength`),H.seq(H.u8(),n.readonlyIndexes.length,`readonlyIndexes`)]);e+=a.encode({accountKey:n.accountKey.toBytes(),encodedWritableIndexesLength:new Uint8Array(r),writableIndexes:n.writableIndexes,encodedReadonlyIndexesLength:new Uint8Array(i),readonlyIndexes:n.readonlyIndexes},t,e)}return t.slice(0,e)}static deserialize(t){let n=[...t],r=hi(n),i=r&127;mi(r!==i,`Expected versioned message but received legacy message`);let a=i;mi(a===0,`Expected versioned message with version 0 but found version ${a}`);let o={numRequiredSignatures:hi(n),numReadonlySignedAccounts:hi(n),numReadonlyUnsignedAccounts:hi(n)},s=[],c=fi(n);for(let e=0;e<c;e++)s.push(new W(gi(n,0,32)));let l=Ri.default.encode(gi(n,0,32)),u=fi(n),d=[];for(let e=0;e<u;e++){let e=hi(n),t=gi(n,0,fi(n)),r=fi(n),i=new Uint8Array(gi(n,0,r));d.push({programIdIndex:e,accountKeyIndexes:t,data:i})}let f=fi(n),p=[];for(let e=0;e<f;e++){let e=new W(gi(n,0,32)),t=gi(n,0,fi(n)),r=gi(n,0,fi(n));p.push({accountKey:e,writableIndexes:t,readonlyIndexes:r})}return new e({header:o,staticAccountKeys:s,recentBlockhash:l,compiledInstructions:d,addressTableLookups:p})}},da={deserializeMessageVersion(e){let t=e[0],n=t&127;return n===t?`legacy`:n},deserialize:e=>{let t=da.deserializeMessageVersion(e);if(t===`legacy`)return la.from(e);if(t===0)return ua.deserialize(e);throw Error(`Transaction message version ${t} deserialization is not supported`)}},fa=function(e){return e[e.BLOCKHEIGHT_EXCEEDED=0]=`BLOCKHEIGHT_EXCEEDED`,e[e.PROCESSED=1]=`PROCESSED`,e[e.TIMED_OUT=2]=`TIMED_OUT`,e[e.NONCE_INVALID=3]=`NONCE_INVALID`,e}({}),pa=_.alloc(64).fill(0),ma=class{constructor(e){this.keys=void 0,this.programId=void 0,this.data=_.alloc(0),this.programId=e.programId,this.keys=e.keys,e.data&&(this.data=e.data)}toJSON(){return{keys:this.keys.map(({pubkey:e,isSigner:t,isWritable:n})=>({pubkey:e.toJSON(),isSigner:t,isWritable:n})),programId:this.programId.toJSON(),data:[...this.data]}}},ha=class e{get signature(){return this.signatures.length>0?this.signatures[0].signature:null}constructor(e){if(this.signatures=[],this.feePayer=void 0,this.instructions=[],this.recentBlockhash=void 0,this.lastValidBlockHeight=void 0,this.nonceInfo=void 0,this.minNonceContextSlot=void 0,this._message=void 0,this._json=void 0,e){if(e.feePayer&&(this.feePayer=e.feePayer),e.signatures&&(this.signatures=e.signatures),Object.prototype.hasOwnProperty.call(e,`nonceInfo`)){let{minContextSlot:t,nonceInfo:n}=e;this.minNonceContextSlot=t,this.nonceInfo=n}else if(Object.prototype.hasOwnProperty.call(e,`lastValidBlockHeight`)){let{blockhash:t,lastValidBlockHeight:n}=e;this.recentBlockhash=t,this.lastValidBlockHeight=n}else{let{recentBlockhash:t,nonceInfo:n}=e;n&&(this.nonceInfo=n),this.recentBlockhash=t}}}toJSON(){return{recentBlockhash:this.recentBlockhash||null,feePayer:this.feePayer?this.feePayer.toJSON():null,nonceInfo:this.nonceInfo?{nonce:this.nonceInfo.nonce,nonceInstruction:this.nonceInfo.nonceInstruction.toJSON()}:null,instructions:this.instructions.map(e=>e.toJSON()),signers:this.signatures.map(({publicKey:e})=>e.toJSON())}}add(...e){if(e.length===0)throw Error(`No instructions`);return e.forEach(e=>{`instructions`in e?this.instructions=this.instructions.concat(e.instructions):`data`in e&&`programId`in e&&`keys`in e?this.instructions.push(e):this.instructions.push(new ma(e))}),this}compileMessage(){if(this._message&&JSON.stringify(this.toJSON())===JSON.stringify(this._json))return this._message;let e,t;if(this.nonceInfo?(e=this.nonceInfo.nonce,t=this.instructions[0]==this.nonceInfo.nonceInstruction?this.instructions:[this.nonceInfo.nonceInstruction,...this.instructions]):(e=this.recentBlockhash,t=this.instructions),!e)throw Error(`Transaction recentBlockhash required`);t.length;let n;if(this.feePayer)n=this.feePayer;else if(this.signatures.length>0&&this.signatures[0].publicKey)n=this.signatures[0].publicKey;else throw Error(`Transaction fee payer required`);for(let e=0;e<t.length;e++)if(t[e].programId===void 0)throw Error(`Transaction instruction index ${e} has undefined program id`);let r=[],i=[];t.forEach(e=>{e.keys.forEach(e=>{i.push({...e})});let t=e.programId.toString();r.includes(t)||r.push(t)}),r.forEach(e=>{i.push({pubkey:new W(e),isSigner:!1,isWritable:!1})});let a=[];i.forEach(e=>{let t=e.pubkey.toString(),n=a.findIndex(e=>e.pubkey.toString()===t);n>-1?(a[n].isWritable=a[n].isWritable||e.isWritable,a[n].isSigner=a[n].isSigner||e.isSigner):a.push(e)}),a.sort(function(e,t){return e.isSigner===t.isSigner?e.isWritable===t.isWritable?e.pubkey.toBase58().localeCompare(t.pubkey.toBase58(),`en`,{localeMatcher:`best fit`,usage:`sort`,sensitivity:`variant`,ignorePunctuation:!1,numeric:!1,caseFirst:`lower`}):e.isWritable?-1:1:e.isSigner?-1:1});let o=a.findIndex(e=>e.pubkey.equals(n));if(o>-1){let[e]=a.splice(o,1);e.isSigner=!0,e.isWritable=!0,a.unshift(e)}else a.unshift({pubkey:n,isSigner:!0,isWritable:!0});for(let e of this.signatures){let t=a.findIndex(t=>t.pubkey.equals(e.publicKey));if(t>-1)a[t].isSigner||(a[t].isSigner=!0);else throw Error(`unknown signer: ${e.publicKey.toString()}`)}let s=0,c=0,l=0,u=[],d=[];a.forEach(({pubkey:e,isSigner:t,isWritable:n})=>{t?(u.push(e.toString()),s+=1,n||(c+=1)):(d.push(e.toString()),n||(l+=1))});let f=u.concat(d),p=t.map(e=>{let{data:t,programId:n}=e;return{programIdIndex:f.indexOf(n.toString()),accounts:e.keys.map(e=>f.indexOf(e.pubkey.toString())),data:Ri.default.encode(t)}});return p.forEach(e=>{mi(e.programIdIndex>=0),e.accounts.forEach(e=>mi(e>=0))}),new la({header:{numRequiredSignatures:s,numReadonlySignedAccounts:c,numReadonlyUnsignedAccounts:l},accountKeys:f,recentBlockhash:e,instructions:p})}_compile(){let e=this.compileMessage(),t=e.accountKeys.slice(0,e.header.numRequiredSignatures);return this.signatures.length===t.length&&this.signatures.every((e,n)=>t[n].equals(e.publicKey))||(this.signatures=t.map(e=>({signature:null,publicKey:e}))),e}serializeMessage(){return this._compile().serialize()}async getEstimatedFee(e){return(await e.getFeeForMessage(this.compileMessage())).value}setSigners(...e){if(e.length===0)throw Error(`No signers`);let t=new Set;this.signatures=e.filter(e=>{let n=e.toString();return!t.has(n)&&(t.add(n),!0)}).map(e=>({signature:null,publicKey:e}))}sign(...e){if(e.length===0)throw Error(`No signers`);let t=new Set,n=[];for(let r of e){let e=r.publicKey.toString();t.has(e)||(t.add(e),n.push(r))}this.signatures=n.map(e=>({signature:null,publicKey:e.publicKey}));let r=this._compile();this._partialSign(r,...n)}partialSign(...e){if(e.length===0)throw Error(`No signers`);let t=new Set,n=[];for(let r of e){let e=r.publicKey.toString();t.has(e)||(t.add(e),n.push(r))}let r=this._compile();this._partialSign(r,...n)}_partialSign(e,...t){let n=e.serialize();t.forEach(e=>{let t=Wi(n,e.secretKey);this._addSignature(e.publicKey,U(t))})}addSignature(e,t){this._compile(),this._addSignature(e,t)}_addSignature(e,t){mi(t.length===64);let n=this.signatures.findIndex(t=>e.equals(t.publicKey));if(n<0)throw Error(`unknown signer: ${e.toString()}`);this.signatures[n].signature=_.from(t)}verifySignatures(e=!0){return!this._getMessageSignednessErrors(this.serializeMessage(),e)}_getMessageSignednessErrors(e,t){let n={};for(let{signature:r,publicKey:i}of this.signatures)r===null?t&&(n.missing||=[]).push(i):Gi(r,e,i.toBytes())||(n.invalid||=[]).push(i);return n.invalid||n.missing?n:void 0}serialize(e){let{requireAllSignatures:t,verifySignatures:n}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},e),r=this.serializeMessage();if(n){let e=this._getMessageSignednessErrors(r,t);if(e){let t=`Signature verification failed.`;throw e.invalid&&(t+=`\nInvalid signature for public key${e.invalid.length===1?``:`(s)`} [\`${e.invalid.map(e=>e.toBase58()).join("`, `")}\`].`),e.missing&&(t+=`\nMissing signature for public key${e.missing.length===1?``:`(s)`} [\`${e.missing.map(e=>e.toBase58()).join("`, `")}\`].`),Error(t)}}return this._serialize(r)}_serialize(e){let{signatures:t}=this,n=[];pi(n,t.length);let r=n.length+t.length*64+e.length,i=_.alloc(r);return mi(t.length<256),_.from(n).copy(i,0),t.forEach(({signature:e},t)=>{e!==null&&(mi(e.length===64,`signature has invalid length`),_.from(e).copy(i,n.length+t*64))}),e.copy(i,n.length+t.length*64),mi(i.length<=Xi,`Transaction too large: ${i.length} > ${Xi}`),i}get keys(){return mi(this.instructions.length===1),this.instructions[0].keys.map(e=>e.pubkey)}get programId(){return mi(this.instructions.length===1),this.instructions[0].programId}get data(){return mi(this.instructions.length===1),this.instructions[0].data}static from(t){let n=[...t],r=fi(n),i=[];for(let e=0;e<r;e++){let e=gi(n,0,64);i.push(Ri.default.encode(_.from(e)))}return e.populate(la.from(n),i)}static populate(t,n=[]){let r=new e;return r.recentBlockhash=t.recentBlockhash,t.header.numRequiredSignatures>0&&(r.feePayer=t.accountKeys[0]),n.forEach((e,n)=>{let i={signature:e==Ri.default.encode(pa)?null:Ri.default.decode(e),publicKey:t.accountKeys[n]};r.signatures.push(i)}),t.instructions.forEach(e=>{let n=e.accounts.map(e=>{let n=t.accountKeys[e];return{pubkey:n,isSigner:r.signatures.some(e=>e.publicKey.toString()===n.toString())||t.isAccountSigner(e),isWritable:t.isAccountWritable(e)}});r.instructions.push(new ma({keys:n,programId:t.accountKeys[e.programIdIndex],data:Ri.default.decode(e.data)}))}),r._message=t,r._json=r.toJSON(),r}},ga=class e{get version(){return this.message.version}constructor(e,t){if(this.signatures=void 0,this.message=void 0,t!==void 0)mi(t.length===e.header.numRequiredSignatures,`Expected signatures length to be equal to the number of required signatures`),this.signatures=t;else{let t=[];for(let n=0;n<e.header.numRequiredSignatures;n++)t.push(new Uint8Array(64));this.signatures=t}this.message=e}serialize(){let e=this.message.serialize(),t=[];pi(t,this.signatures.length);let n=H.struct([H.blob(t.length,`encodedSignaturesLength`),H.seq(ta(),this.signatures.length,`signatures`),H.blob(e.length,`serializedMessage`)]),r=new Uint8Array(2048),i=n.encode({encodedSignaturesLength:new Uint8Array(t),signatures:this.signatures,serializedMessage:e},r);return r.slice(0,i)}static deserialize(t){let n=[...t],r=[],i=fi(n);for(let e=0;e<i;e++)r.push(new Uint8Array(gi(n,0,64)));let a=da.deserialize(new Uint8Array(n));return new e(a,r)}sign(e){let t=this.message.serialize(),n=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures);for(let r of e){let e=n.findIndex(e=>e.equals(r.publicKey));mi(e>=0,`Cannot sign with non signer key ${r.publicKey.toBase58()}`),this.signatures[e]=Wi(t,r.secretKey)}}addSignature(e,t){mi(t.byteLength===64,`Signature must be 64 bytes long`);let n=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures).findIndex(t=>t.equals(e));mi(n>=0,`Can not add signature; \`${e.toBase58()}\` is not required to sign this transaction`),this.signatures[n]=t}},_a=1e3/(160/64),va=new W(`SysvarC1ock11111111111111111111111111111111`),new W(`SysvarEpochSchedu1e111111111111111111111111`),new W(`Sysvar1nstructions1111111111111111111111111`),ya=new W(`SysvarRecentB1ockHashes11111111111111111111`),ba=new W(`SysvarRent111111111111111111111111111111111`),new W(`SysvarRewards111111111111111111111111111111`),new W(`SysvarS1otHashes111111111111111111111111111`),new W(`SysvarS1otHistory11111111111111111111111111`),xa=new W(`SysvarStakeHistory1111111111111111111111111`),Sa=class extends Error{constructor({action:e,signature:t,transactionMessage:n,logs:r}){let i=r?`Logs: \n${JSON.stringify(r.slice(-10),null,2)}. `:``,a="\nCatch the `SendTransactionError` and call `getLogs()` on it for full details.",o;switch(e){case`send`:o=`Transaction ${t} resulted in an error. \n${n}. `+i+a;break;case`simulate`:o=`Simulation failed. \nMessage: ${n}. \n`+i+a;break;default:o=`Unknown action '${(e=>e)(e)}'`}super(o),this.signature=void 0,this.transactionMessage=void 0,this.transactionLogs=void 0,this.signature=t,this.transactionMessage=n,this.transactionLogs=r||void 0}get transactionError(){return{message:this.transactionMessage,logs:Array.isArray(this.transactionLogs)?this.transactionLogs:void 0}}get logs(){let e=this.transactionLogs;if(!(typeof e==`object`&&e&&`then`in e))return e}async getLogs(e){return Array.isArray(this.transactionLogs)||(this.transactionLogs=new Promise((t,n)=>{e.getTransaction(this.signature).then(e=>{if(e&&e.meta&&e.meta.logMessages){let n=e.meta.logMessages;this.transactionLogs=n,t(n)}else n(Error(`Log messages not found`))}).catch(n)})),await this.transactionLogs}},K=class extends Error{constructor({code:e,message:t,data:n},r){super(r==null?t:`${r}: ${t}`),this.code=void 0,this.data=void 0,this.code=e,this.data=n,this.name=`SolanaJSONRPCError`}},Ca=H.nu64(`lamportsPerSignature`),wa=H.struct([H.u32(`version`),H.u32(`state`),G(`authorizedPubkey`),G(`nonce`),H.struct([Ca],`feeCalculator`)]),Ta=wa.span,Ea=class e{constructor(e){this.authorizedPubkey=void 0,this.nonce=void 0,this.feeCalculator=void 0,this.authorizedPubkey=e.authorizedPubkey,this.nonce=e.nonce,this.feeCalculator=e.feeCalculator}static fromAccountData(t){let n=wa.decode(U(t),0);return new e({authorizedPubkey:new W(n.authorizedPubkey),nonce:new W(n.nonce).toString(),feeCalculator:n.feeCalculator})}},Da=Object.freeze({Create:{index:0,layout:H.struct([H.u32(`instruction`),H.ns64(`lamports`),H.ns64(`space`),G(`programId`)])},Assign:{index:1,layout:H.struct([H.u32(`instruction`),G(`programId`)])},Transfer:{index:2,layout:H.struct([H.u32(`instruction`),yi(`lamports`)])},CreateWithSeed:{index:3,layout:H.struct([H.u32(`instruction`),G(`base`),na(`seed`),H.ns64(`lamports`),H.ns64(`space`),G(`programId`)])},AdvanceNonceAccount:{index:4,layout:H.struct([H.u32(`instruction`)])},WithdrawNonceAccount:{index:5,layout:H.struct([H.u32(`instruction`),H.ns64(`lamports`)])},InitializeNonceAccount:{index:6,layout:H.struct([H.u32(`instruction`),G(`authorized`)])},AuthorizeNonceAccount:{index:7,layout:H.struct([H.u32(`instruction`),G(`authorized`)])},Allocate:{index:8,layout:H.struct([H.u32(`instruction`),H.ns64(`space`)])},AllocateWithSeed:{index:9,layout:H.struct([H.u32(`instruction`),G(`base`),na(`seed`),H.ns64(`space`),G(`programId`)])},AssignWithSeed:{index:10,layout:H.struct([H.u32(`instruction`),G(`base`),na(`seed`),G(`programId`)])},TransferWithSeed:{index:11,layout:H.struct([H.u32(`instruction`),yi(`lamports`),na(`seed`),G(`programId`)])},UpgradeNonceAccount:{index:12,layout:H.struct([H.u32(`instruction`)])}}),Oa=class e{constructor(){}static createAccount(e){let t=Da.Create,n=B(t,{lamports:e.lamports,space:e.space,programId:U(e.programId.toBuffer())});return new ma({keys:[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.newAccountPubkey,isSigner:!0,isWritable:!0}],programId:this.programId,data:n})}static transfer(e){let t,n;if(`basePubkey`in e){let r=Da.TransferWithSeed;t=B(r,{lamports:BigInt(e.lamports),seed:e.seed,programId:U(e.programId.toBuffer())}),n=[{pubkey:e.fromPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0}]}else{let r=Da.Transfer;t=B(r,{lamports:BigInt(e.lamports)}),n=[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0}]}return new ma({keys:n,programId:this.programId,data:t})}static assign(e){let t,n;if(`basePubkey`in e){let r=Da.AssignWithSeed;t=B(r,{base:U(e.basePubkey.toBuffer()),seed:e.seed,programId:U(e.programId.toBuffer())}),n=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]}else{let r=Da.Assign;t=B(r,{programId:U(e.programId.toBuffer())}),n=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]}return new ma({keys:n,programId:this.programId,data:t})}static createAccountWithSeed(e){let t=Da.CreateWithSeed,n=B(t,{base:U(e.basePubkey.toBuffer()),seed:e.seed,lamports:e.lamports,space:e.space,programId:U(e.programId.toBuffer())}),r=[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.newAccountPubkey,isSigner:!1,isWritable:!0}];return e.basePubkey.equals(e.fromPubkey)||r.push({pubkey:e.basePubkey,isSigner:!0,isWritable:!1}),new ma({keys:r,programId:this.programId,data:n})}static createNonceAccount(t){let n=new ha;`basePubkey`in t&&`seed`in t?n.add(e.createAccountWithSeed({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,basePubkey:t.basePubkey,seed:t.seed,lamports:t.lamports,space:Ta,programId:this.programId})):n.add(e.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,lamports:t.lamports,space:Ta,programId:this.programId}));let r={noncePubkey:t.noncePubkey,authorizedPubkey:t.authorizedPubkey};return n.add(this.nonceInitialize(r)),n}static nonceInitialize(e){let t=Da.InitializeNonceAccount,n=B(t,{authorized:U(e.authorizedPubkey.toBuffer())}),r={keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:ya,isSigner:!1,isWritable:!1},{pubkey:ba,isSigner:!1,isWritable:!1}],programId:this.programId,data:n};return new ma(r)}static nonceAdvance(e){let t=Da.AdvanceNonceAccount,n=B(t),r={keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:ya,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n};return new ma(r)}static nonceWithdraw(e){let t=Da.WithdrawNonceAccount,n=B(t,{lamports:e.lamports});return new ma({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0},{pubkey:ya,isSigner:!1,isWritable:!1},{pubkey:ba,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static nonceAuthorize(e){let t=Da.AuthorizeNonceAccount,n=B(t,{authorized:U(e.newAuthorizedPubkey.toBuffer())});return new ma({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static allocate(e){let t,n;if(`basePubkey`in e){let r=Da.AllocateWithSeed;t=B(r,{base:U(e.basePubkey.toBuffer()),seed:e.seed,space:e.space,programId:U(e.programId.toBuffer())}),n=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]}else{let r=Da.Allocate;t=B(r,{space:e.space}),n=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]}return new ma({keys:n,programId:this.programId,data:t})}},Oa.programId=new W(`11111111111111111111111111111111`),ka=932,Aa=class e{constructor(){}static getMinNumSignatures(t){return 2*(Math.ceil(t/e.chunkSize)+1+1)}static async load(t,n,r,i,a){{let e=await t.getMinimumBalanceForRentExemption(a.length),o=await t.getAccountInfo(r.publicKey,`confirmed`),s=null;if(o!==null){if(o.executable)return!1;o.data.length!==a.length&&(s||=new ha,s.add(Oa.allocate({accountPubkey:r.publicKey,space:a.length}))),o.owner.equals(i)||(s||=new ha,s.add(Oa.assign({accountPubkey:r.publicKey,programId:i}))),o.lamports<e&&(s||=new ha,s.add(Oa.transfer({fromPubkey:n.publicKey,toPubkey:r.publicKey,lamports:e-o.lamports})))}else s=new ha().add(Oa.createAccount({fromPubkey:n.publicKey,newAccountPubkey:r.publicKey,lamports:e>0?e:1,space:a.length,programId:i}));s!==null&&await _i(t,s,[n,r],{commitment:`confirmed`})}let o=H.struct([H.u32(`instruction`),H.u32(`offset`),H.u32(`bytesLength`),H.u32(`bytesLengthPadding`),H.seq(H.u8(`byte`),H.offset(H.u32(),-8),`bytes`)]),s=e.chunkSize,c=0,l=a,u=[];for(;l.length>0;){let e=l.slice(0,s),a=_.alloc(s+16);o.encode({instruction:0,offset:c,bytes:e,bytesLength:0,bytesLengthPadding:0},a);let d=new ha().add({keys:[{pubkey:r.publicKey,isSigner:!0,isWritable:!0}],programId:i,data:a});u.push(_i(t,d,[n,r],{commitment:`confirmed`})),t._rpcEndpoint.includes(`solana.com`)&&await vi(250),c+=s,l=l.slice(s)}await Promise.all(u);{let e=H.struct([H.u32(`instruction`)]),a=_.alloc(e.span);e.encode({instruction:1},a);let o=new ha().add({keys:[{pubkey:r.publicKey,isSigner:!0,isWritable:!0},{pubkey:ba,isSigner:!1,isWritable:!1}],programId:i,data:a}),s=`processed`,c=await t.sendTransaction(o,[n,r],{preflightCommitment:s}),{context:l,value:u}=await t.confirmTransaction({signature:c,lastValidBlockHeight:o.lastValidBlockHeight,blockhash:o.recentBlockhash},s);if(u.err)throw Error(`Transaction ${c} failed (${JSON.stringify(u)})`);for(;;){try{if(await t.getSlot({commitment:s})>l.slot)break}catch{}await new Promise(e=>setTimeout(e,Math.round(_a/2)))}}return!0}},Aa.chunkSize=ka,new W(`BPFLoader2111111111111111111111111111111111`),Na=bi(xi()),Pa=32,Fa=class{constructor(e,t,n,r,i){this.slotsPerEpoch=void 0,this.leaderScheduleSlotOffset=void 0,this.warmup=void 0,this.firstNormalEpoch=void 0,this.firstNormalSlot=void 0,this.slotsPerEpoch=e,this.leaderScheduleSlotOffset=t,this.warmup=n,this.firstNormalEpoch=r,this.firstNormalSlot=i}getEpoch(e){return this.getEpochAndSlotIndex(e)[0]}getEpochAndSlotIndex(e){if(e<this.firstNormalSlot){let t=Si(Ci(e+Pa+1))-Si(Pa)-1;return[t,e-(this.getSlotsInEpoch(t)-Pa)]}{let t=e-this.firstNormalSlot,n=Math.floor(t/this.slotsPerEpoch);return[this.firstNormalEpoch+n,t%this.slotsPerEpoch]}}getFirstSlotInEpoch(e){return e<=this.firstNormalEpoch?(2**e-1)*Pa:(e-this.firstNormalEpoch)*this.slotsPerEpoch+this.firstNormalSlot}getLastSlotInEpoch(e){return this.getFirstSlotInEpoch(e)+this.getSlotsInEpoch(e)-1}getSlotsInEpoch(e){return e<this.firstNormalEpoch?2**(e+Si(Pa)):this.slotsPerEpoch}},Ia=globalThis.fetch,La=class extends si{constructor(e,t,n){super(e=>{let n=ii(e,{autoconnect:!0,max_reconnects:5,reconnect:!0,reconnect_interval:1e3,...t});return`socket`in n?this.underlyingSocket=n.socket:this.underlyingSocket=n,n},e,t,n),this.underlyingSocket=void 0}call(...e){let t=this.underlyingSocket?.readyState;return t===1?super.call(...e):Promise.reject(Error("Tried to call a JSON-RPC method `"+e[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+t+`)`))}notify(...e){let t=this.underlyingSocket?.readyState;return t===1?super.notify(...e):Promise.reject(Error("Tried to send a JSON-RPC notification `"+e[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+t+`)`))}},Ra=56,za=class{constructor(e){this.key=void 0,this.state=void 0,this.key=e.key,this.state=e.state}isActive(){let e=BigInt(`0xffffffffffffffff`);return this.state.deactivationSlot===e}static deserialize(e){let t=wi(Ba,e),n=e.length-Ra;mi(n>=0,`lookup table is invalid`),mi(n%32==0,`lookup table is invalid`);let r=n/32,{addresses:i}=H.struct([H.seq(G(),r,`addresses`)]).decode(e.slice(Ra));return{deactivationSlot:t.deactivationSlot,lastExtendedSlot:t.lastExtendedSlot,lastExtendedSlotStartIndex:t.lastExtendedStartIndex,authority:t.authority.length===0?void 0:new W(t.authority[0]),addresses:i.map(e=>new W(e))}}},Ba={index:1,layout:H.struct([H.u32(`typeIndex`),yi(`deactivationSlot`),H.nu64(`lastExtendedSlot`),H.u8(`lastExtendedStartIndex`),H.u8(),H.seq(G(),H.offset(H.u8(),-1),`authority`)])},Va=/^[^:]+:\/\/([^:[]+|\[[^\]]+\])(:\d+)?(.*)/i,Ha=Qn(Gn(W),R(),e=>new W(e)),Ua=Yn([R(),Kn(`base64`)]),Wa=Qn(Gn(_),Ua,e=>_.from(e[0],`base64`)),Ga=3e4,Ka=ki(Zn()),qa=z({foundation:I(),foundationTerm:I(),initial:I(),taper:I(),terminal:I()}),Ja=V(P(F(z({epoch:I(),effectiveSlot:I(),amount:I(),postBalance:I(),commission:L(F(I()))})))),Ya=P(z({slot:I(),prioritizationFee:I()})),Xa=z({total:I(),validator:I(),foundation:I(),epoch:I()}),Za=z({epoch:I(),slotIndex:I(),slotsInEpoch:I(),absoluteSlot:I(),blockHeight:L(I()),transactionCount:L(I())}),Qa=z({slotsPerEpoch:I(),leaderScheduleSlotOffset:I(),warmup:Wn(),firstNormalEpoch:I(),firstNormalSlot:I()}),$a=Jn(R(),P(I())),eo=F(Xn([z({}),R()])),to=z({err:eo}),no=Kn(`receivedSignature`),ro=z({"solana-core":R(),"feature-set":L(I())}),io=z({program:R(),programId:Ha,parsed:Zn()}),ao=z({programId:Ha,accounts:P(Ha),data:R()}),oo=Ai(z({err:F(Xn([z({}),R()])),logs:F(P(R())),accounts:L(F(P(F(z({executable:Wn(),owner:R(),lamports:I(),data:P(R()),rentEpoch:L(I())}))))),unitsConsumed:L(I()),returnData:L(F(z({programId:R(),data:Yn([R(),Kn(`base64`)])}))),innerInstructions:L(F(P(z({index:I(),instructions:P(Xn([io,ao]))}))))})),so=Ai(z({byIdentity:Jn(R(),P(I())),range:z({firstSlot:I(),lastSlot:I()})})),co=V(qa),lo=V(Xa),uo=V(Ya),fo=V(Za),po=V(Qa),mo=V($a),ho=V(I()),go=Ai(z({total:I(),circulating:I(),nonCirculating:I(),nonCirculatingAccounts:P(Ha)})),_o=z({amount:R(),uiAmount:F(I()),decimals:I(),uiAmountString:L(R())}),vo=Ai(P(z({address:Ha,amount:R(),uiAmount:F(I()),decimals:I(),uiAmountString:L(R())}))),yo=Ai(P(z({pubkey:Ha,account:z({executable:Wn(),owner:Ha,lamports:I(),data:Wa,rentEpoch:I()})}))),bo=z({program:R(),parsed:Zn(),space:I()}),xo=Ai(P(z({pubkey:Ha,account:z({executable:Wn(),owner:Ha,lamports:I(),data:bo,rentEpoch:I()})}))),So=Ai(P(z({lamports:I(),address:Ha}))),Co=z({executable:Wn(),owner:Ha,lamports:I(),data:Wa,rentEpoch:I()}),wo=z({pubkey:Ha,account:Co}),To=Qn(Xn([Gn(_),bo]),Xn([Ua,bo]),e=>Array.isArray(e)?N(e,Wa):e),Eo=z({executable:Wn(),owner:Ha,lamports:I(),data:To,rentEpoch:I()}),Do=z({pubkey:Ha,account:Eo}),Oo=z({state:Xn([Kn(`active`),Kn(`inactive`),Kn(`activating`),Kn(`deactivating`)]),active:I(),inactive:I()}),ko=V(P(z({signature:R(),slot:I(),err:eo,memo:F(R()),blockTime:L(F(I()))}))),Ao=V(P(z({signature:R(),slot:I(),err:eo,memo:F(R()),blockTime:L(F(I()))}))),jo=z({subscription:I(),result:ji(Co)}),Mo=z({pubkey:Ha,account:Co}),No=z({subscription:I(),result:ji(Mo)}),Po=z({parent:I(),slot:I(),root:I()}),Fo=z({subscription:I(),result:Po}),Io=Xn([z({type:Xn([Kn(`firstShredReceived`),Kn(`completed`),Kn(`optimisticConfirmation`),Kn(`root`)]),slot:I(),timestamp:I()}),z({type:Kn(`createdBank`),parent:I(),slot:I(),timestamp:I()}),z({type:Kn(`frozen`),slot:I(),timestamp:I(),stats:z({numTransactionEntries:I(),numSuccessfulTransactions:I(),numFailedTransactions:I(),maxTransactionsPerEntry:I()})}),z({type:Kn(`dead`),slot:I(),timestamp:I(),err:R()})]),Lo=z({subscription:I(),result:Io}),Ro=z({subscription:I(),result:ji(Xn([to,no]))}),zo=z({subscription:I(),result:I()}),Bo=z({pubkey:R(),gossip:F(R()),tpu:F(R()),rpc:F(R()),version:F(R())}),Vo=z({votePubkey:R(),nodePubkey:R(),activatedStake:I(),epochVoteAccount:Wn(),epochCredits:P(Yn([I(),I(),I()])),commission:I(),lastVote:I(),rootSlot:F(I())}),Ho=V(z({current:P(Vo),delinquent:P(Vo)})),Uo=Xn([Kn(`processed`),Kn(`confirmed`),Kn(`finalized`)]),Wo=z({slot:I(),confirmations:F(I()),err:eo,confirmationStatus:L(Uo)}),Go=Ai(P(F(Wo))),Ko=V(I()),qo=z({accountKey:Ha,writableIndexes:P(I()),readonlyIndexes:P(I())}),Jo=z({signatures:P(R()),message:z({accountKeys:P(R()),header:z({numRequiredSignatures:I(),numReadonlySignedAccounts:I(),numReadonlyUnsignedAccounts:I()}),instructions:P(z({accounts:P(I()),data:R(),programIdIndex:I()})),recentBlockhash:R(),addressTableLookups:L(P(qo))})}),Yo=z({pubkey:Ha,signer:Wn(),writable:Wn(),source:L(Xn([Kn(`transaction`),Kn(`lookupTable`)]))}),Xo=z({accountKeys:P(Yo),signatures:P(R())}),Zo=z({parsed:Zn(),program:R(),programId:Ha}),Qo=z({accounts:P(Ha),data:R(),programId:Ha}),$o=Xn([Qo,Zo]),es=Xn([z({parsed:Zn(),program:R(),programId:R()}),z({accounts:P(R()),data:R(),programId:R()})]),ts=Qn($o,es,e=>`accounts`in e?N(e,Qo):N(e,Zo)),ns=z({signatures:P(R()),message:z({accountKeys:P(Yo),instructions:P(ts),recentBlockhash:R(),addressTableLookups:L(F(P(qo)))})}),rs=z({accountIndex:I(),mint:R(),owner:L(R()),programId:L(R()),uiTokenAmount:_o}),is=z({writable:P(Ha),readonly:P(Ha)}),as=z({err:eo,fee:I(),innerInstructions:L(F(P(z({index:I(),instructions:P(z({accounts:P(I()),data:R(),programIdIndex:I()}))})))),preBalances:P(I()),postBalances:P(I()),logMessages:L(F(P(R()))),preTokenBalances:L(F(P(rs))),postTokenBalances:L(F(P(rs))),loadedAddresses:L(is),computeUnitsConsumed:L(I()),costUnits:L(I())}),os=z({err:eo,fee:I(),innerInstructions:L(F(P(z({index:I(),instructions:P(ts)})))),preBalances:P(I()),postBalances:P(I()),logMessages:L(F(P(R()))),preTokenBalances:L(F(P(rs))),postTokenBalances:L(F(P(rs))),loadedAddresses:L(is),computeUnitsConsumed:L(I()),costUnits:L(I())}),ss=Xn([Kn(0),Kn(`legacy`)]),cs=z({pubkey:R(),lamports:I(),postBalance:F(I()),rewardType:F(R()),commission:L(F(I()))}),ls=V(F(z({blockhash:R(),previousBlockhash:R(),parentSlot:I(),transactions:P(z({transaction:Jo,meta:F(as),version:L(ss)})),rewards:L(P(cs)),blockTime:F(I()),blockHeight:F(I())}))),us=V(F(z({blockhash:R(),previousBlockhash:R(),parentSlot:I(),rewards:L(P(cs)),blockTime:F(I()),blockHeight:F(I())}))),ds=V(F(z({blockhash:R(),previousBlockhash:R(),parentSlot:I(),transactions:P(z({transaction:Xo,meta:F(as),version:L(ss)})),rewards:L(P(cs)),blockTime:F(I()),blockHeight:F(I())}))),fs=V(F(z({blockhash:R(),previousBlockhash:R(),parentSlot:I(),transactions:P(z({transaction:ns,meta:F(os),version:L(ss)})),rewards:L(P(cs)),blockTime:F(I()),blockHeight:F(I())}))),ps=V(F(z({blockhash:R(),previousBlockhash:R(),parentSlot:I(),transactions:P(z({transaction:Xo,meta:F(os),version:L(ss)})),rewards:L(P(cs)),blockTime:F(I()),blockHeight:F(I())}))),ms=V(F(z({blockhash:R(),previousBlockhash:R(),parentSlot:I(),rewards:L(P(cs)),blockTime:F(I()),blockHeight:F(I())}))),hs=V(F(z({blockhash:R(),previousBlockhash:R(),parentSlot:I(),transactions:P(z({transaction:Jo,meta:F(as)})),rewards:L(P(cs)),blockTime:F(I())}))),gs=V(F(z({blockhash:R(),previousBlockhash:R(),parentSlot:I(),signatures:P(R()),blockTime:F(I())}))),_s=V(F(z({slot:I(),meta:F(as),blockTime:L(F(I())),transaction:Jo,version:L(ss)}))),vs=V(F(z({slot:I(),transaction:ns,meta:F(os),blockTime:L(F(I())),version:L(ss)}))),ys=Ai(z({blockhash:R(),lastValidBlockHeight:I()})),bs=Ai(Wn()),xs=z({slot:I(),numTransactions:I(),numSlots:I(),samplePeriodSecs:I()}),Ss=V(P(xs)),Cs=Ai(F(z({feeCalculator:z({lamportsPerSignature:I()})}))),ws=V(R()),Ts=V(R()),Es=z({err:eo,logs:P(R()),signature:R()}),Ds=z({result:ji(Es),subscription:I()}),Os={"solana-client":`js/1.0.0-maintenance`},ks=class{constructor(e,t){this._commitment=void 0,this._confirmTransactionInitialTimeout=void 0,this._rpcEndpoint=void 0,this._rpcWsEndpoint=void 0,this._rpcClient=void 0,this._rpcRequest=void 0,this._rpcBatchRequest=void 0,this._rpcWebSocket=void 0,this._rpcWebSocketConnected=!1,this._rpcWebSocketHeartbeat=null,this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketGeneration=0,this._disableBlockhashCaching=!1,this._pollingBlockhash=!1,this._blockhashInfo={latestBlockhash:null,lastFetch:0,transactionSignatures:[],simulatedSignatures:[]},this._nextClientSubscriptionId=0,this._subscriptionDisposeFunctionsByClientSubscriptionId={},this._subscriptionHashByClientSubscriptionId={},this._subscriptionStateChangeCallbacksByHash={},this._subscriptionCallbacksByServerSubscriptionId={},this._subscriptionsByHash={},this._subscriptionsAutoDisposedByRpc=new Set,this.getBlockHeight=(()=>{let e={};return async t=>{let{commitment:n,config:r}=Di(t),i=this._buildArgs([],n,void 0,r),a=Na(i);return e[a]=e[a]??(async()=>{try{let e=N(await this._rpcRequest(`getBlockHeight`,i),V(I()));if(`error`in e)throw new K(e.error,`failed to get block height information`);return e.result}finally{delete e[a]}})(),await e[a]}})();let n,r,i,a,o,s;t&&typeof t==`string`?this._commitment=t:t&&(this._commitment=t.commitment,this._confirmTransactionInitialTimeout=t.confirmTransactionInitialTimeout,n=t.wsEndpoint,r=t.httpHeaders,i=t.fetch,a=t.fetchMiddleware,o=t.disableRetryOnRateLimit,s=t.httpAgent),this._rpcEndpoint=Ei(e),this._rpcWsEndpoint=n||Ti(e),this._rpcClient=Ni(e,r,i,a,o,s),this._rpcRequest=Pi(this._rpcClient),this._rpcBatchRequest=Fi(this._rpcClient),this._rpcWebSocket=new La(this._rpcWsEndpoint,{autoconnect:!1,max_reconnects:1/0}),this._rpcWebSocket.on(`open`,this._wsOnOpen.bind(this)),this._rpcWebSocket.on(`error`,this._wsOnError.bind(this)),this._rpcWebSocket.on(`close`,this._wsOnClose.bind(this)),this._rpcWebSocket.on(`accountNotification`,this._wsOnAccountNotification.bind(this)),this._rpcWebSocket.on(`programNotification`,this._wsOnProgramAccountNotification.bind(this)),this._rpcWebSocket.on(`slotNotification`,this._wsOnSlotNotification.bind(this)),this._rpcWebSocket.on(`slotsUpdatesNotification`,this._wsOnSlotUpdatesNotification.bind(this)),this._rpcWebSocket.on(`signatureNotification`,this._wsOnSignatureNotification.bind(this)),this._rpcWebSocket.on(`rootNotification`,this._wsOnRootNotification.bind(this)),this._rpcWebSocket.on(`logsNotification`,this._wsOnLogsNotification.bind(this))}get commitment(){return this._commitment}get rpcEndpoint(){return this._rpcEndpoint}async getBalanceAndContext(e,t){let{commitment:n,config:r}=Di(t),i=this._buildArgs([e.toBase58()],n,void 0,r),a=N(await this._rpcRequest(`getBalance`,i),Ai(I()));if(`error`in a)throw new K(a.error,`failed to get balance for ${e.toBase58()}`);return a.result}async getBalance(e,t){return await this.getBalanceAndContext(e,t).then(e=>e.value).catch(t=>{throw Error(`failed to get balance of account `+e.toBase58()+`: `+t)})}async getBlockTime(e){let t=N(await this._rpcRequest(`getBlockTime`,[e]),V(F(I())));if(`error`in t)throw new K(t.error,`failed to get block time for slot ${e}`);return t.result}async getMinimumLedgerSlot(){let e=N(await this._rpcRequest(`minimumLedgerSlot`,[]),V(I()));if(`error`in e)throw new K(e.error,`failed to get minimum ledger slot`);return e.result}async getFirstAvailableBlock(){let e=N(await this._rpcRequest(`getFirstAvailableBlock`,[]),ho);if(`error`in e)throw new K(e.error,`failed to get first available block`);return e.result}async getSupply(e){let t={};t=typeof e==`string`?{commitment:e}:e?{...e,commitment:e&&e.commitment||this.commitment}:{commitment:this.commitment};let n=N(await this._rpcRequest(`getSupply`,[t]),go);if(`error`in n)throw new K(n.error,`failed to get supply`);return n.result}async getTokenSupply(e,t){let n=this._buildArgs([e.toBase58()],t),r=N(await this._rpcRequest(`getTokenSupply`,n),Ai(_o));if(`error`in r)throw new K(r.error,`failed to get token supply`);return r.result}async getTokenAccountBalance(e,t){let n=this._buildArgs([e.toBase58()],t),r=N(await this._rpcRequest(`getTokenAccountBalance`,n),Ai(_o));if(`error`in r)throw new K(r.error,`failed to get token account balance`);return r.result}async getTokenAccountsByOwner(e,t,n){let{commitment:r,config:i}=Di(n),a=[e.toBase58()];`mint`in t?a.push({mint:t.mint.toBase58()}):a.push({programId:t.programId.toBase58()});let o=this._buildArgs(a,r,`base64`,i),s=N(await this._rpcRequest(`getTokenAccountsByOwner`,o),yo);if(`error`in s)throw new K(s.error,`failed to get token accounts owned by account ${e.toBase58()}`);return s.result}async getParsedTokenAccountsByOwner(e,t,n){let r=[e.toBase58()];`mint`in t?r.push({mint:t.mint.toBase58()}):r.push({programId:t.programId.toBase58()});let i=this._buildArgs(r,n,`jsonParsed`),a=N(await this._rpcRequest(`getTokenAccountsByOwner`,i),xo);if(`error`in a)throw new K(a.error,`failed to get token accounts owned by account ${e.toBase58()}`);return a.result}async getLargestAccounts(e){let t={...e,commitment:e&&e.commitment||this.commitment},n=t.filter||t.commitment?[t]:[],r=N(await this._rpcRequest(`getLargestAccounts`,n),So);if(`error`in r)throw new K(r.error,`failed to get largest accounts`);return r.result}async getTokenLargestAccounts(e,t){let n=this._buildArgs([e.toBase58()],t),r=N(await this._rpcRequest(`getTokenLargestAccounts`,n),vo);if(`error`in r)throw new K(r.error,`failed to get token largest accounts`);return r.result}async getAccountInfoAndContext(e,t){let{commitment:n,config:r}=Di(t),i=this._buildArgs([e.toBase58()],n,`base64`,r),a=N(await this._rpcRequest(`getAccountInfo`,i),Ai(F(Co)));if(`error`in a)throw new K(a.error,`failed to get info about account ${e.toBase58()}`);return a.result}async getParsedAccountInfo(e,t){let{commitment:n,config:r}=Di(t),i=this._buildArgs([e.toBase58()],n,`jsonParsed`,r),a=N(await this._rpcRequest(`getAccountInfo`,i),Ai(F(Eo)));if(`error`in a)throw new K(a.error,`failed to get info about account ${e.toBase58()}`);return a.result}async getAccountInfo(e,t){try{return(await this.getAccountInfoAndContext(e,t)).value}catch(t){throw Error(`failed to get info about account `+e.toBase58()+`: `+t)}}async getMultipleParsedAccounts(e,t){let{commitment:n,config:r}=Di(t),i=e.map(e=>e.toBase58()),a=this._buildArgs([i],n,`jsonParsed`,r),o=N(await this._rpcRequest(`getMultipleAccounts`,a),Ai(P(F(Eo))));if(`error`in o)throw new K(o.error,`failed to get info for accounts ${i}`);return o.result}async getMultipleAccountsInfoAndContext(e,t){let{commitment:n,config:r}=Di(t),i=e.map(e=>e.toBase58()),a=this._buildArgs([i],n,`base64`,r),o=N(await this._rpcRequest(`getMultipleAccounts`,a),Ai(P(F(Co))));if(`error`in o)throw new K(o.error,`failed to get info for accounts ${i}`);return o.result}async getMultipleAccountsInfo(e,t){return(await this.getMultipleAccountsInfoAndContext(e,t)).value}async getStakeActivation(e,t,n){let{commitment:r,config:i}=Di(t),a=this._buildArgs([e.toBase58()],r,void 0,{...i,epoch:n??i?.epoch}),o=N(await this._rpcRequest(`getStakeActivation`,a),V(Oo));if(`error`in o)throw new K(o.error,`failed to get Stake Activation ${e.toBase58()}`);return o.result}async getProgramAccounts(e,t){let{commitment:n,config:r}=Di(t),{encoding:i,...a}=r||{},o=this._buildArgs([e.toBase58()],n,i||`base64`,{...a,...a.filters?{filters:Oi(a.filters)}:null}),s=await this._rpcRequest(`getProgramAccounts`,o),c=P(wo),l=a.withContext===!0?N(s,Ai(c)):N(s,V(c));if(`error`in l)throw new K(l.error,`failed to get accounts owned by program ${e.toBase58()}`);return l.result}async getParsedProgramAccounts(e,t){let{commitment:n,config:r}=Di(t),i=this._buildArgs([e.toBase58()],n,`jsonParsed`,r),a=N(await this._rpcRequest(`getProgramAccounts`,i),V(P(Do)));if(`error`in a)throw new K(a.error,`failed to get accounts owned by program ${e.toBase58()}`);return a.result}async confirmTransaction(e,t){let n;if(typeof e==`string`)n=e;else{let t=e;if(t.abortSignal?.aborted)return Promise.reject(t.abortSignal.reason);n=t.signature}let r;try{r=Ri.default.decode(n)}catch{throw Error(`signature must be base58 encoded: `+n)}return mi(r.length===64,`signature has invalid length`),typeof e==`string`?await this.confirmTransactionUsingLegacyTimeoutStrategy({commitment:t||this.commitment,signature:n}):`lastValidBlockHeight`in e?await this.confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:t||this.commitment,strategy:e}):await this.confirmTransactionUsingDurableNonceStrategy({commitment:t||this.commitment,strategy:e})}getCancellationPromise(e){return new Promise((t,n)=>{e!=null&&(e.aborted?n(e.reason):e.addEventListener(`abort`,()=>{n(e.reason)}))})}getTransactionConfirmationPromise({commitment:e,signature:t}){let n,r,i=!1;return{abortConfirmation:()=>{r&&=(r(),void 0),n!=null&&(this.removeSignatureListener(n),n=void 0)},confirmationPromise:new Promise((a,o)=>{try{n=this.onSignature(t,(e,t)=>{n=void 0;let r={context:t,value:e};a({__type:fa.PROCESSED,response:r})},e);let s=new Promise(e=>{n==null?e():r=this._onSubscriptionStateChange(n,t=>{t===`subscribed`&&e()})});(async()=>{if(await s,i)return;let n=await this.getSignatureStatus(t);if(i||n==null)return;let{context:r,value:c}=n;if(c!=null){if(c?.err)o(c.err);else{switch(e){case`confirmed`:case`single`:case`singleGossip`:if(c.confirmationStatus===`processed`)return;break;case`finalized`:case`max`:case`root`:if(c.confirmationStatus===`processed`||c.confirmationStatus===`confirmed`)return}i=!0,a({__type:fa.PROCESSED,response:{context:r,value:c}})}}})()}catch(e){o(e)}})}}async confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:e,strategy:{abortSignal:t,lastValidBlockHeight:n,signature:r}}){let i=!1,a=new Promise(t=>{let r=async()=>{try{return await this.getBlockHeight(e)}catch{return-1}};(async()=>{let e=await r();if(!i){for(;e<=n;)if(await vi(1e3),i||(e=await r(),i))return;t({__type:fa.BLOCKHEIGHT_EXCEEDED})}})()}),{abortConfirmation:o,confirmationPromise:s}=this.getTransactionConfirmationPromise({commitment:e,signature:r}),c=this.getCancellationPromise(t),l;try{let e=await Promise.race([c,s,a]);if(e.__type===fa.PROCESSED)l=e.response;else throw new Zi(r)}finally{i=!0,o()}return l}async confirmTransactionUsingDurableNonceStrategy({commitment:e,strategy:{abortSignal:t,minContextSlot:n,nonceAccountPubkey:r,nonceValue:i,signature:a}}){let o=!1,s=new Promise(t=>{let a=i,s=null,c=async()=>{try{let{context:t,value:i}=await this.getNonceAndContext(r,{commitment:e,minContextSlot:n});return s=t.slot,i?.nonce}catch{return a}};(async()=>{if(a=await c(),!o)for(;;){if(i!==a){t({__type:fa.NONCE_INVALID,slotInWhichNonceDidAdvance:s});return}if(await vi(2e3),o||(a=await c(),o))return}})()}),{abortConfirmation:c,confirmationPromise:l}=this.getTransactionConfirmationPromise({commitment:e,signature:a}),u=this.getCancellationPromise(t),d;try{let t=await Promise.race([u,l,s]);if(t.__type===fa.PROCESSED)d=t.response;else{let r;for(;;){let e=await this.getSignatureStatus(a);if(e==null)break;if(e.context.slot<(t.slotInWhichNonceDidAdvance??n)){await vi(400);continue}r=e;break}if(r?.value){let t=e||`finalized`,{confirmationStatus:n}=r.value;switch(t){case`processed`:case`recent`:if(n!==`processed`&&n!==`confirmed`&&n!==`finalized`)throw new $i(a);break;case`confirmed`:case`single`:case`singleGossip`:if(n!==`confirmed`&&n!==`finalized`)throw new $i(a);break;case`finalized`:case`max`:case`root`:if(n!==`finalized`)throw new $i(a)}d={context:r.context,value:{err:r.value.err}}}else throw new $i(a)}}finally{o=!0,c()}return d}async confirmTransactionUsingLegacyTimeoutStrategy({commitment:e,signature:t}){let n,r=new Promise(t=>{let r=this._confirmTransactionInitialTimeout||6e4;switch(e){case`processed`:case`recent`:case`single`:case`confirmed`:case`singleGossip`:r=this._confirmTransactionInitialTimeout||3e4}n=setTimeout(()=>t({__type:fa.TIMED_OUT,timeoutMs:r}),r)}),{abortConfirmation:i,confirmationPromise:a}=this.getTransactionConfirmationPromise({commitment:e,signature:t}),o;try{let e=await Promise.race([a,r]);if(e.__type===fa.PROCESSED)o=e.response;else throw new Qi(t,e.timeoutMs/1e3)}finally{clearTimeout(n),i()}return o}async getClusterNodes(){let e=N(await this._rpcRequest(`getClusterNodes`,[]),V(P(Bo)));if(`error`in e)throw new K(e.error,`failed to get cluster nodes`);return e.result}async getVoteAccounts(e){let t=this._buildArgs([],e),n=N(await this._rpcRequest(`getVoteAccounts`,t),Ho);if(`error`in n)throw new K(n.error,`failed to get vote accounts`);return n.result}async getSlot(e){let{commitment:t,config:n}=Di(e),r=this._buildArgs([],t,void 0,n),i=N(await this._rpcRequest(`getSlot`,r),V(I()));if(`error`in i)throw new K(i.error,`failed to get slot`);return i.result}async getSlotLeader(e){let{commitment:t,config:n}=Di(e),r=this._buildArgs([],t,void 0,n),i=N(await this._rpcRequest(`getSlotLeader`,r),V(R()));if(`error`in i)throw new K(i.error,`failed to get slot leader`);return i.result}async getSlotLeaders(e,t){let n=[e,t],r=N(await this._rpcRequest(`getSlotLeaders`,n),V(P(Ha)));if(`error`in r)throw new K(r.error,`failed to get slot leaders`);return r.result}async getSignatureStatus(e,t){let{context:n,value:r}=await this.getSignatureStatuses([e],t);return mi(r.length===1),{context:n,value:r[0]}}async getSignatureStatuses(e,t){let n=[e];t&&n.push(t);let r=N(await this._rpcRequest(`getSignatureStatuses`,n),Go);if(`error`in r)throw new K(r.error,`failed to get signature status`);return r.result}async getTransactionCount(e){let{commitment:t,config:n}=Di(e),r=this._buildArgs([],t,void 0,n),i=N(await this._rpcRequest(`getTransactionCount`,r),V(I()));if(`error`in i)throw new K(i.error,`failed to get transaction count`);return i.result}async getTotalSupply(e){return(await this.getSupply({commitment:e,excludeNonCirculatingAccountsList:!0})).value.total}async getInflationGovernor(e){let t=this._buildArgs([],e),n=N(await this._rpcRequest(`getInflationGovernor`,t),co);if(`error`in n)throw new K(n.error,`failed to get inflation`);return n.result}async getInflationReward(e,t,n){let{commitment:r,config:i}=Di(n),a=this._buildArgs([e.map(e=>e.toBase58())],r,void 0,{...i,epoch:t??i?.epoch}),o=N(await this._rpcRequest(`getInflationReward`,a),Ja);if(`error`in o)throw new K(o.error,`failed to get inflation reward`);return o.result}async getInflationRate(){let e=N(await this._rpcRequest(`getInflationRate`,[]),lo);if(`error`in e)throw new K(e.error,`failed to get inflation rate`);return e.result}async getEpochInfo(e){let{commitment:t,config:n}=Di(e),r=this._buildArgs([],t,void 0,n),i=N(await this._rpcRequest(`getEpochInfo`,r),fo);if(`error`in i)throw new K(i.error,`failed to get epoch info`);return i.result}async getEpochSchedule(){let e=N(await this._rpcRequest(`getEpochSchedule`,[]),po);if(`error`in e)throw new K(e.error,`failed to get epoch schedule`);let t=e.result;return new Fa(t.slotsPerEpoch,t.leaderScheduleSlotOffset,t.warmup,t.firstNormalEpoch,t.firstNormalSlot)}async getLeaderSchedule(){let e=N(await this._rpcRequest(`getLeaderSchedule`,[]),mo);if(`error`in e)throw new K(e.error,`failed to get leader schedule`);return e.result}async getMinimumBalanceForRentExemption(e,t){let n=this._buildArgs([e],t),r=N(await this._rpcRequest(`getMinimumBalanceForRentExemption`,n),Ko);return`error`in r?0:r.result}async getRecentBlockhashAndContext(e){let{context:t,value:{blockhash:n}}=await this.getLatestBlockhashAndContext(e);return{context:t,value:{blockhash:n,feeCalculator:{get lamportsPerSignature(){throw Error("The capability to fetch `lamportsPerSignature` using the `getRecentBlockhash` API is no longer offered by the network. Use the `getFeeForMessage` API to obtain the fee for a given message.")},toJSON(){return{}}}}}}async getRecentPerformanceSamples(e){let t=N(await this._rpcRequest(`getRecentPerformanceSamples`,e?[e]:[]),Ss);if(`error`in t)throw new K(t.error,`failed to get recent performance samples`);return t.result}async getFeeCalculatorForBlockhash(e,t){let n=this._buildArgs([e],t),r=N(await this._rpcRequest(`getFeeCalculatorForBlockhash`,n),Cs);if(`error`in r)throw new K(r.error,`failed to get fee calculator`);let{context:i,value:a}=r.result;return{context:i,value:a===null?null:a.feeCalculator}}async getFeeForMessage(e,t){let n=U(e.serialize()).toString(`base64`),r=this._buildArgs([n],t),i=N(await this._rpcRequest(`getFeeForMessage`,r),Ai(F(I())));if(`error`in i)throw new K(i.error,`failed to get fee for message`);if(i.result===null)throw Error(`invalid blockhash`);return i.result}async getRecentPrioritizationFees(e){let t=e?.lockedWritableAccounts?.map(e=>e.toBase58()),n=t?.length?[t]:[],r=N(await this._rpcRequest(`getRecentPrioritizationFees`,n),uo);if(`error`in r)throw new K(r.error,`failed to get recent prioritization fees`);return r.result}async getRecentBlockhash(e){try{return(await this.getRecentBlockhashAndContext(e)).value}catch(e){throw Error(`failed to get recent blockhash: `+e)}}async getLatestBlockhash(e){try{return(await this.getLatestBlockhashAndContext(e)).value}catch(e){throw Error(`failed to get recent blockhash: `+e)}}async getLatestBlockhashAndContext(e){let{commitment:t,config:n}=Di(e),r=this._buildArgs([],t,void 0,n),i=N(await this._rpcRequest(`getLatestBlockhash`,r),ys);if(`error`in i)throw new K(i.error,`failed to get latest blockhash`);return i.result}async isBlockhashValid(e,t){let{commitment:n,config:r}=Di(t),i=this._buildArgs([e],n,void 0,r),a=N(await this._rpcRequest(`isBlockhashValid`,i),bs);if(`error`in a)throw new K(a.error,"failed to determine if the blockhash `"+e+"`is valid");return a.result}async getVersion(){let e=N(await this._rpcRequest(`getVersion`,[]),V(ro));if(`error`in e)throw new K(e.error,`failed to get version`);return e.result}async getGenesisHash(){let e=N(await this._rpcRequest(`getGenesisHash`,[]),V(R()));if(`error`in e)throw new K(e.error,`failed to get genesis hash`);return e.result}async getBlock(e,t){let{commitment:n,config:r}=Di(t),i=this._buildArgsAtLeastConfirmed([e],n,void 0,r),a=await this._rpcRequest(`getBlock`,i);try{switch(r?.transactionDetails){case`accounts`:{let e=N(a,ds);if(`error`in e)throw e.error;return e.result}case`none`:{let e=N(a,us);if(`error`in e)throw e.error;return e.result}default:{let e=N(a,ls);if(`error`in e)throw e.error;let{result:t}=e;return t?{...t,transactions:t.transactions.map(({transaction:e,meta:t,version:n})=>({meta:t,transaction:{...e,message:Mi(n,e.message)},version:n}))}:null}}}catch(e){throw new K(e,`failed to get confirmed block`)}}async getParsedBlock(e,t){let{commitment:n,config:r}=Di(t),i=this._buildArgsAtLeastConfirmed([e],n,`jsonParsed`,r),a=await this._rpcRequest(`getBlock`,i);try{switch(r?.transactionDetails){case`accounts`:{let e=N(a,ps);if(`error`in e)throw e.error;return e.result}case`none`:{let e=N(a,ms);if(`error`in e)throw e.error;return e.result}default:{let e=N(a,fs);if(`error`in e)throw e.error;return e.result}}}catch(e){throw new K(e,`failed to get block`)}}async getBlockProduction(e){let t,n;if(typeof e==`string`)n=e;else if(e){let{commitment:r,...i}=e;n=r,t=i}let r=this._buildArgs([],n,`base64`,t),i=N(await this._rpcRequest(`getBlockProduction`,r),so);if(`error`in i)throw new K(i.error,`failed to get block production information`);return i.result}async getTransaction(e,t){let{commitment:n,config:r}=Di(t),i=this._buildArgsAtLeastConfirmed([e],n,void 0,r),a=N(await this._rpcRequest(`getTransaction`,i),_s);if(`error`in a)throw new K(a.error,`failed to get transaction`);let o=a.result;return o&&{...o,transaction:{...o.transaction,message:Mi(o.version,o.transaction.message)}}}async getParsedTransaction(e,t){let{commitment:n,config:r}=Di(t),i=this._buildArgsAtLeastConfirmed([e],n,`jsonParsed`,r),a=N(await this._rpcRequest(`getTransaction`,i),vs);if(`error`in a)throw new K(a.error,`failed to get transaction`);return a.result}async getParsedTransactions(e,t){let{commitment:n,config:r}=Di(t),i=e.map(e=>({methodName:`getTransaction`,args:this._buildArgsAtLeastConfirmed([e],n,`jsonParsed`,r)}));return(await this._rpcBatchRequest(i)).map(e=>{let t=N(e,vs);if(`error`in t)throw new K(t.error,`failed to get transactions`);return t.result})}async getTransactions(e,t){let{commitment:n,config:r}=Di(t),i=e.map(e=>({methodName:`getTransaction`,args:this._buildArgsAtLeastConfirmed([e],n,void 0,r)}));return(await this._rpcBatchRequest(i)).map(e=>{let t=N(e,_s);if(`error`in t)throw new K(t.error,`failed to get transactions`);let n=t.result;return n&&{...n,transaction:{...n.transaction,message:Mi(n.version,n.transaction.message)}}})}async getConfirmedBlock(e,t){let n=this._buildArgsAtLeastConfirmed([e],t),r=N(await this._rpcRequest(`getBlock`,n),hs);if(`error`in r)throw new K(r.error,`failed to get confirmed block`);let i=r.result;if(!i)throw Error(`Confirmed block `+e+` not found`);let a={...i,transactions:i.transactions.map(({transaction:e,meta:t})=>{let n=new la(e.message);return{meta:t,transaction:{...e,message:n}}})};return{...a,transactions:a.transactions.map(({transaction:e,meta:t})=>({meta:t,transaction:ha.populate(e.message,e.signatures)}))}}async getBlocks(e,t,n){let r=this._buildArgsAtLeastConfirmed(t===void 0?[e]:[e,t],n),i=N(await this._rpcRequest(`getBlocks`,r),V(P(I())));if(`error`in i)throw new K(i.error,`failed to get blocks`);return i.result}async getBlockSignatures(e,t){let n=this._buildArgsAtLeastConfirmed([e],t,void 0,{transactionDetails:`signatures`,rewards:!1}),r=N(await this._rpcRequest(`getBlock`,n),gs);if(`error`in r)throw new K(r.error,`failed to get block`);let i=r.result;if(!i)throw Error(`Block `+e+` not found`);return i}async getConfirmedBlockSignatures(e,t){let n=this._buildArgsAtLeastConfirmed([e],t,void 0,{transactionDetails:`signatures`,rewards:!1}),r=N(await this._rpcRequest(`getBlock`,n),gs);if(`error`in r)throw new K(r.error,`failed to get confirmed block`);let i=r.result;if(!i)throw Error(`Confirmed block `+e+` not found`);return i}async getConfirmedTransaction(e,t){let n=this._buildArgsAtLeastConfirmed([e],t),r=N(await this._rpcRequest(`getTransaction`,n),_s);if(`error`in r)throw new K(r.error,`failed to get transaction`);let i=r.result;if(!i)return i;let a=new la(i.transaction.message),o=i.transaction.signatures;return{...i,transaction:ha.populate(a,o)}}async getParsedConfirmedTransaction(e,t){let n=this._buildArgsAtLeastConfirmed([e],t,`jsonParsed`),r=N(await this._rpcRequest(`getTransaction`,n),vs);if(`error`in r)throw new K(r.error,`failed to get confirmed transaction`);return r.result}async getParsedConfirmedTransactions(e,t){let n=e.map(e=>({methodName:`getTransaction`,args:this._buildArgsAtLeastConfirmed([e],t,`jsonParsed`)}));return(await this._rpcBatchRequest(n)).map(e=>{let t=N(e,vs);if(`error`in t)throw new K(t.error,`failed to get confirmed transactions`);return t.result})}async getConfirmedSignaturesForAddress(e,t,n){let r={},i=await this.getFirstAvailableBlock();for(;!(`until`in r)&&(t--,!(t<=0||t<i));)try{let e=await this.getConfirmedBlockSignatures(t,`finalized`);e.signatures.length>0&&(r.until=e.signatures[e.signatures.length-1].toString())}catch(e){if(e instanceof Error&&e.message.includes(`skipped`))continue;throw e}let a=await this.getSlot(`finalized`);for(;!(`before`in r)&&(n++,!(n>a));)try{let e=await this.getConfirmedBlockSignatures(n);e.signatures.length>0&&(r.before=e.signatures[e.signatures.length-1].toString())}catch(e){if(e instanceof Error&&e.message.includes(`skipped`))continue;throw e}return(await this.getConfirmedSignaturesForAddress2(e,r)).map(e=>e.signature)}async getConfirmedSignaturesForAddress2(e,t,n){let r=this._buildArgsAtLeastConfirmed([e.toBase58()],n,void 0,t),i=N(await this._rpcRequest(`getConfirmedSignaturesForAddress2`,r),ko);if(`error`in i)throw new K(i.error,`failed to get confirmed signatures for address`);return i.result}async getSignaturesForAddress(e,t,n){let r=this._buildArgsAtLeastConfirmed([e.toBase58()],n,void 0,t),i=N(await this._rpcRequest(`getSignaturesForAddress`,r),Ao);if(`error`in i)throw new K(i.error,`failed to get signatures for address`);return i.result}async getAddressLookupTable(e,t){let{context:n,value:r}=await this.getAccountInfoAndContext(e,t),i=null;return r!==null&&(i=new za({key:e,state:za.deserialize(r.data)})),{context:n,value:i}}async getNonceAndContext(e,t){let{context:n,value:r}=await this.getAccountInfoAndContext(e,t),i=null;return r!==null&&(i=Ea.fromAccountData(r.data)),{context:n,value:i}}async getNonce(e,t){return await this.getNonceAndContext(e,t).then(e=>e.value).catch(t=>{throw Error(`failed to get nonce for account `+e.toBase58()+`: `+t)})}async requestAirdrop(e,t){let n=N(await this._rpcRequest(`requestAirdrop`,[e.toBase58(),t]),ws);if(`error`in n)throw new K(n.error,`airdrop to ${e.toBase58()} failed`);return n.result}async _blockhashWithExpiryBlockHeight(e){if(!e){for(;this._pollingBlockhash;)await vi(100);let e=Date.now()-this._blockhashInfo.lastFetch>=Ga;if(this._blockhashInfo.latestBlockhash!==null&&!e)return this._blockhashInfo.latestBlockhash}return await this._pollNewBlockhash()}async _pollNewBlockhash(){this._pollingBlockhash=!0;try{let e=Date.now(),t=this._blockhashInfo.latestBlockhash,n=t?t.blockhash:null;for(let e=0;e<50;e++){let e=await this.getLatestBlockhash(`finalized`);if(n!==e.blockhash)return this._blockhashInfo={latestBlockhash:e,lastFetch:Date.now(),transactionSignatures:[],simulatedSignatures:[]},e;await vi(_a/2)}throw Error(`Unable to obtain a new blockhash after ${Date.now()-e}ms`)}finally{this._pollingBlockhash=!1}}async getStakeMinimumDelegation(e){let{commitment:t,config:n}=Di(e),r=this._buildArgs([],t,`base64`,n),i=N(await this._rpcRequest(`getStakeMinimumDelegation`,r),Ai(I()));if(`error`in i)throw new K(i.error,`failed to get stake minimum delegation`);return i.result}async simulateTransaction(e,t,n){if(`message`in e){let r=e.serialize(),i=_.from(r).toString(`base64`);if(Array.isArray(t)||n!==void 0)throw Error(`Invalid arguments`);let a=t||{};a.encoding=`base64`,`commitment`in a||(a.commitment=this.commitment),t&&typeof t==`object`&&`innerInstructions`in t&&(a.innerInstructions=t.innerInstructions);let o=[i,a],s=N(await this._rpcRequest(`simulateTransaction`,o),oo);if(`error`in s)throw Error(`failed to simulate transaction: `+s.error.message);return s.result}let r;if(e instanceof ha){let t=e;r=new ha,r.feePayer=t.feePayer,r.instructions=e.instructions,r.nonceInfo=t.nonceInfo,r.signatures=t.signatures}else r=ha.populate(e),r._message=r._json=void 0;if(t!==void 0&&!Array.isArray(t))throw Error(`Invalid arguments`);let i=t;if(r.nonceInfo&&i)r.sign(...i);else{let e=this._disableBlockhashCaching;for(;;){let t=await this._blockhashWithExpiryBlockHeight(e);if(r.lastValidBlockHeight=t.lastValidBlockHeight,r.recentBlockhash=t.blockhash,!i)break;if(r.sign(...i),!r.signature)throw Error(`!signature`);let n=r.signature.toString(`base64`);if(!this._blockhashInfo.simulatedSignatures.includes(n)&&!this._blockhashInfo.transactionSignatures.includes(n)){this._blockhashInfo.simulatedSignatures.push(n);break}e=!0}}let a=r._compile(),o=a.serialize(),s=r._serialize(o).toString(`base64`),c={encoding:`base64`,commitment:this.commitment};n&&(c.accounts={encoding:`base64`,addresses:(Array.isArray(n)?n:a.nonProgramIds()).map(e=>e.toBase58())}),i&&(c.sigVerify=!0),t&&typeof t==`object`&&`innerInstructions`in t&&(c.innerInstructions=t.innerInstructions);let l=[s,c],u=N(await this._rpcRequest(`simulateTransaction`,l),oo);if(`error`in u){let e;throw`data`in u.error&&(e=u.error.data.logs,e&&Array.isArray(e))&&``+e.join(`
2
+ import{n as e,o as t,r as n,s as r,t as i}from"./rolldown-runtime-BcKkbAw3.js";import{n as a,t as o}from"./dist-C9i0DjyB.js";import{C as s}from"./Schema-CnO1Nnkx.js";import{n as c,t as l}from"./dist-D6L6gF64.js";import{t as u}from"./preload-helper-Czpn1I53.js";import{n as d}from"./_esm-DNvytb5d.js";import{vn as f}from"./ccip-B_AhQiTz.js";import{n as p,t as m}from"./sha256-B81eAX-m.js";import{n as h,t as g}from"./sha3-DTWsE4Uo.js";import{n as _,r as v,t as y}from"./dist-KkMRwAp9.js";import{t as ee}from"./fallback-hOVnOuYU.js";import{n as te,t as ne}from"./ed25519-0TVA-MrV.js";import{n as re,t as b}from"./bn-F_BR-QG7.js";import{t as x}from"./elliptic-BkWObsOB.js";import{t as S}from"./bs58-Cepc0rNH.js";import{n as C,t as w}from"./secp256k1-KrmNoC0i.js";import{t as T}from"./esm-DhvlA6gG.js";import{t as E}from"./events-D2w4OsQJ.js";import{a as ie,c as ae,d as oe,f as D,i as se,l as ce,o as le,r as ue,s as de,t as fe,u as pe}from"./index.es-6FknJabw.js";import{_ as me,a as O,d as he,f as ge,g as _e,h as ve,i as ye,l as be,n as xe,o as Se,p as Ce,r as we,s as Te,u as Ee,v as De}from"./browser-ponyfill-8IsXQqGl.js";import{a as Oe,i as ke,n as Ae,r as je,t as Me}from"./index.es-DqXS4GHm.js";import{i as Ne,n as Pe,r as Fe,t as Ie}from"./src-CHcFzXUJ.js";import{t as Le}from"./index.es-B-vaqu71.js";import{A as Re,C as k,D as ze,E as Be,O as Ve,S as He,_ as Ue,a as We,c as Ge,d as A,f as Ke,g as qe,h as Je,k as j,l as M,m as Ye,o as Xe,p as Ze,u as Qe,v as $e,w as et,x as tt,y as nt}from"./exports-CeDbIN9g.js";import{i as rt,n as it,o as at,r as ot}from"./utils-CXyOXcxm.js";import{i as st,n as ct,r as lt}from"./ConnectorUtil-BpVhiuM2.js";var ut=i(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=`~`;function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(r=!1));function a(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(e,t,n,i,o){if(typeof n!=`function`)throw TypeError(`The listener must be a function`);var s=new a(n,i||e,o),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],s]:e._events[c].push(s):(e._events[c]=s,e._eventsCount++),e}function s(e,t){--e._eventsCount===0?e._events=new i:delete e._events[t]}function c(){this._events=new i,this._eventsCount=0}c.prototype.eventNames=function(){var e=[],t,i;if(this._eventsCount===0)return e;for(i in t=this._events)n.call(t,i)&&e.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e},c.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,a=n.length,o=Array(a);i<a;i++)o[i]=n[i].fn;return o},c.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},c.prototype.emit=function(e,t,n,i,a,o){var s=r?r+e:e;if(!this._events[s])return!1;var c=this._events[s],l=arguments.length,u,d;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,i),!0;case 5:return c.fn.call(c.context,t,n,i,a),!0;case 6:return c.fn.call(c.context,t,n,i,a,o),!0}for(d=1,u=Array(l-1);d<l;d++)u[d-1]=arguments[d];c.fn.apply(c.context,u)}else{var f=c.length,p;for(d=0;d<f;d++)switch(c[d].once&&this.removeListener(e,c[d].fn,void 0,!0),l){case 1:c[d].fn.call(c[d].context);break;case 2:c[d].fn.call(c[d].context,t);break;case 3:c[d].fn.call(c[d].context,t,n);break;case 4:c[d].fn.call(c[d].context,t,n,i);break;default:if(!u)for(p=1,u=Array(l-1);p<l;p++)u[p-1]=arguments[p];c[d].fn.apply(c[d].context,u)}}return!0},c.prototype.on=function(e,t,n){return o(this,e,t,n,!1)},c.prototype.once=function(e,t,n){return o(this,e,t,n,!0)},c.prototype.removeListener=function(e,t,n,i){var a=r?r+e:e;if(!this._events[a])return this;if(!t)return s(this,a),this;var o=this._events[a];if(o.fn)o.fn===t&&(!i||o.once)&&(!n||o.context===n)&&s(this,a);else{for(var c=0,l=[],u=o.length;c<u;c++)(o[c].fn!==t||i&&!o[c].once||n&&o[c].context!==n)&&l.push(o[c]);l.length?this._events[a]=l.length===1?l[0]:l:s(this,a)}return this},c.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&s(this,t)):(this._events=new i,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=r,c.EventEmitter=c,t!==void 0&&(t.exports=c)})),dt,ft,pt=e((()=>{dt=r(ut(),1),ft=dt.default}));pt();var mt=class extends Error{constructor(e,t){super(e),this.error=t}},ht=class extends mt{constructor(){super(...arguments),this.name=`WalletNotReadyError`}},gt=class extends mt{constructor(){super(...arguments),this.name=`WalletConfigError`}},_t=class extends mt{constructor(){super(...arguments),this.name=`WalletConnectionError`}},vt=class extends mt{constructor(){super(...arguments),this.name=`WalletDisconnectedError`}},yt=class extends mt{constructor(){super(...arguments),this.name=`WalletDisconnectionError`}},bt=class extends mt{constructor(){super(...arguments),this.name=`WalletAccountError`}},xt=class extends mt{constructor(){super(...arguments),this.name=`WalletPublicKeyError`}},St=class extends mt{constructor(){super(...arguments),this.name=`WalletNotConnectedError`}},Ct=class extends mt{constructor(){super(...arguments),this.name=`WalletSendTransactionError`}},wt=class extends mt{constructor(){super(...arguments),this.name=`WalletSignTransactionError`}},Tt=class extends mt{constructor(){super(...arguments),this.name=`WalletSignMessageError`}},Et=class extends mt{constructor(){super(...arguments),this.name=`WalletSignInError`}},Dt=class extends mt{constructor(){super(...arguments),this.name=`WalletWindowClosedError`}},Ot;(function(e){e.Installed=`Installed`,e.NotDetected=`NotDetected`,e.Loadable=`Loadable`,e.Unsupported=`Unsupported`})(Ot||={});var kt=class extends ft{get connected(){return!!this.publicKey}async autoConnect(){await this.connect()}async prepareTransaction(e,t,n={}){let r=this.publicKey;if(!r)throw new St;return e.feePayer=e.feePayer||r,e.recentBlockhash=e.recentBlockhash||(await t.getLatestBlockhash({commitment:n.preflightCommitment,minContextSlot:n.minContextSlot})).blockhash,e}};function At(e){if(typeof window>`u`||typeof document>`u`)return;let t=[];function n(){if(e())for(let e of t)e()}let r=setInterval(n,1e3);t.push(()=>clearInterval(r)),document.readyState===`loading`&&(document.addEventListener(`DOMContentLoaded`,n,{once:!0}),t.push(()=>document.removeEventListener(`DOMContentLoaded`,n))),document.readyState!==`complete`&&(window.addEventListener(`load`,n,{once:!0}),t.push(()=>window.removeEventListener(`load`,n))),n()}function jt(){if(!navigator)return!1;let e=navigator.userAgent.toLowerCase(),t=e.includes(`iphone`)||e.includes(`ipad`),n=e.includes(`safari`);return t&&n}function Mt(e){return`version`in e}var Nt=class extends kt{async sendTransaction(e,t,n={}){let r=!0;try{if(Mt(e)){if(!this.supportedTransactionVersions)throw new Ct(`Sending versioned transactions isn't supported by this wallet`);if(!this.supportedTransactionVersions.has(e.version))throw new Ct(`Sending transaction version ${e.version} isn't supported by this wallet`);try{e=await this.signTransaction(e);let r=e.serialize();return await t.sendRawTransaction(r,n)}catch(e){throw e instanceof wt?(r=!1,e):new Ct(e?.message,e)}}try{let{signers:r,...i}=n;e=await this.prepareTransaction(e,t,i),r?.length&&e.partialSign(...r),e=await this.signTransaction(e);let a=e.serialize();return await t.sendRawTransaction(a,i)}catch(e){throw e instanceof wt?(r=!1,e):new Ct(e?.message,e)}}catch(e){throw r&&this.emit(`error`,e),e}}async signAllTransactions(e){for(let t of e)if(Mt(t)){if(!this.supportedTransactionVersions)throw new wt(`Signing versioned transactions isn't supported by this wallet`);if(!this.supportedTransactionVersions.has(t.version))throw new wt(`Signing transaction version ${t.version} isn't supported by this wallet`)}let t=[];for(let n of e)t.push(await this.signTransaction(n));return t}},Pt=class extends Nt{},Ft=class extends Pt{},It;(function(e){e.Mainnet=`mainnet-beta`,e.Testnet=`testnet`,e.Devnet=`devnet`})(It||={});var Lt=n({TextDecoder:()=>Wt,TextEncoder:()=>Gt});function Rt(e,t,n){return t<=e&&e<=n}function zt(e){if(e===void 0)return{};if(e===Object(e))return e;throw TypeError(`Could not convert argument to dictionary`)}function Bt(e){for(var t=String(e),n=t.length,r=0,i=[];r<n;){var a=t.charCodeAt(r);if(a<55296||a>57343)i.push(a);else if(56320<=a&&a<=57343)i.push(65533);else if(55296<=a&&a<=56319){if(r===n-1)i.push(65533);else{var o=e.charCodeAt(r+1);if(56320<=o&&o<=57343){var s=a&1023,c=o&1023;i.push(65536+(s<<10)+c),r+=1}else i.push(65533)}}r+=1}return i}function Vt(e){for(var t=``,n=0;n<e.length;++n){var r=e[n];r<=65535?t+=String.fromCharCode(r):(r-=65536,t+=String.fromCharCode((r>>10)+55296,(r&1023)+56320))}return t}function Ht(e){this.tokens=[].slice.call(e)}function Ut(e,t){if(e)throw TypeError(`Decoder error`);return t||65533}function Wt(e,t){if(!(this instanceof Wt))return new Wt(e,t);if(e=e===void 0?Xt:String(e).toLowerCase(),e!==Xt)throw Error(`Encoding not supported. Only utf-8 is supported`);t=zt(t),this._streaming=!1,this._BOMseen=!1,this._decoder=null,this._fatal=!!t.fatal,this._ignoreBOM=!!t.ignoreBOM,Object.defineProperty(this,"encoding",{value:`utf-8`}),Object.defineProperty(this,"fatal",{value:this._fatal}),Object.defineProperty(this,"ignoreBOM",{value:this._ignoreBOM})}function Gt(e,t){if(!(this instanceof Gt))return new Gt(e,t);if(e=e===void 0?Xt:String(e).toLowerCase(),e!==Xt)throw Error(`Encoding not supported. Only utf-8 is supported`);t=zt(t),this._streaming=!1,this._encoder=null,this._options={fatal:!!t.fatal},Object.defineProperty(this,"encoding",{value:`utf-8`})}function Kt(e){var t=e.fatal,n=0,r=0,i=0,a=128,o=191;this.handler=function(e,s){if(s===Jt&&i!==0)return i=0,Ut(t);if(s===Jt)return Yt;if(i===0){if(Rt(s,0,127))return s;if(Rt(s,194,223))i=1,n=s-192;else if(Rt(s,224,239))s===224&&(a=160),s===237&&(o=159),i=2,n=s-224;else if(Rt(s,240,244))s===240&&(a=144),s===244&&(o=143),i=3,n=s-240;else return Ut(t);return n<<=6*i,null}if(!Rt(s,a,o))return n=i=r=0,a=128,o=191,e.prepend(s),Ut(t);if(a=128,o=191,r+=1,n+=s-128<<6*(i-r),r!==i)return null;var c=n;return n=i=r=0,c}}function qt(e){e.fatal,this.handler=function(e,t){if(t===Jt)return Yt;if(Rt(t,0,127))return t;var n,r;Rt(t,128,2047)?(n=1,r=192):Rt(t,2048,65535)?(n=2,r=224):Rt(t,65536,1114111)&&(n=3,r=240);for(var i=[(t>>6*n)+r];n>0;){var a=t>>6*(n-1);i.push(128|a&63),--n}return i}}var Jt,Yt,Xt,Zt=e((()=>{Jt=-1,Ht.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():Jt},prepend:function(e){if(Array.isArray(e))for(var t=e;t.length;)this.tokens.unshift(t.pop());else this.tokens.unshift(e)},push:function(e){if(Array.isArray(e))for(var t=e;t.length;)this.tokens.push(t.shift());else this.tokens.push(e)}},Yt=-1,Xt=`utf-8`,Wt.prototype={decode:function(e,t){var n=typeof e==`object`&&e instanceof ArrayBuffer?new Uint8Array(e):typeof e==`object`&&`buffer`in e&&e.buffer instanceof ArrayBuffer?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array;t=zt(t),this._streaming||(this._decoder=new Kt({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!t.stream;for(var r=new Ht(n),i=[],a;!r.endOfStream()&&(a=this._decoder.handler(r,r.read()),a!==Yt);)a!==null&&(Array.isArray(a)?i.push.apply(i,a):i.push(a));if(!this._streaming){do{if(a=this._decoder.handler(r,r.read()),a===Yt)break;a!==null&&(Array.isArray(a)?i.push.apply(i,a):i.push(a))}while(!r.endOfStream());this._decoder=null}return i.length&&[`utf-8`].indexOf(this.encoding)!==-1&&!this._ignoreBOM&&!this._BOMseen&&(i[0]===65279?(this._BOMseen=!0,i.shift()):this._BOMseen=!0),Vt(i)}},Gt.prototype={encode:function(e,t){e=e?String(e):``,t=zt(t),this._streaming||(this._encoder=new qt(this._options)),this._streaming=!!t.stream;for(var n=[],r=new Ht(Bt(e)),i;!r.endOfStream()&&(i=this._encoder.handler(r,r.read()),i!==Yt);)Array.isArray(i)?n.push.apply(n,i):n.push(i);if(!this._streaming){for(;i=this._encoder.handler(r,r.read()),i!==Yt;)Array.isArray(i)?n.push.apply(n,i):n.push(i);this._encoder=null}return new Uint8Array(n)}}})),Qt=i((e=>{v();var n=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),r=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),i=e&&e.__decorate||function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},a=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var i in e)i!=="default"&&Object.hasOwnProperty.call(e,i)&&n(t,e,i);return r(t,e),t},o=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.deserializeUnchecked=e.deserialize=e.serialize=e.BinaryReader=e.BinaryWriter=e.BorshError=e.baseDecode=e.baseEncode=void 0;var s=o(b()),c=o(S()),l=a((Zt(),t(Lt))),u=new(typeof TextDecoder==`function`?TextDecoder:l.TextDecoder)(`utf-8`,{fatal:!0});function d(e){return typeof e==`string`&&(e=y.from(e,`utf8`)),c.default.encode(y.from(e))}e.baseEncode=d;function f(e){return y.from(c.default.decode(e))}e.baseDecode=f;var p=1024,m=class extends Error{constructor(e){super(e),this.fieldPath=[],this.originalMessage=e}addToFieldPath(e){this.fieldPath.splice(0,0,e),this.message=this.originalMessage+`: `+this.fieldPath.join(`.`)}};e.BorshError=m;var h=class{constructor(){this.buf=y.alloc(p),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=y.concat([this.buf,y.alloc(p)]))}writeU8(e){this.maybeResize(),this.buf.writeUInt8(e,this.length),this.length+=1}writeU16(e){this.maybeResize(),this.buf.writeUInt16LE(e,this.length),this.length+=2}writeU32(e){this.maybeResize(),this.buf.writeUInt32LE(e,this.length),this.length+=4}writeU64(e){this.maybeResize(),this.writeBuffer(y.from(new s.default(e).toArray(`le`,8)))}writeU128(e){this.maybeResize(),this.writeBuffer(y.from(new s.default(e).toArray(`le`,16)))}writeU256(e){this.maybeResize(),this.writeBuffer(y.from(new s.default(e).toArray(`le`,32)))}writeU512(e){this.maybeResize(),this.writeBuffer(y.from(new s.default(e).toArray(`le`,64)))}writeBuffer(e){this.buf=y.concat([y.from(this.buf.subarray(0,this.length)),e,y.alloc(p)]),this.length+=e.length}writeString(e){this.maybeResize();let t=y.from(e,`utf8`);this.writeU32(t.length),this.writeBuffer(t)}writeFixedArray(e){this.writeBuffer(y.from(e))}writeArray(e,t){this.maybeResize(),this.writeU32(e.length);for(let n of e)this.maybeResize(),t(n)}toArray(){return this.buf.subarray(0,this.length)}};e.BinaryWriter=h;function g(e,t,n){let r=n.value;n.value=function(...e){try{return r.apply(this,e)}catch(e){if(e instanceof RangeError){let t=e.code;if([`ERR_BUFFER_OUT_OF_BOUNDS`,`ERR_OUT_OF_RANGE`].indexOf(t)>=0)throw new m(`Reached the end of buffer when deserializing`)}throw e}}}var _=class{constructor(e){this.buf=e,this.offset=0}readU8(){let e=this.buf.readUInt8(this.offset);return this.offset+=1,e}readU16(){let e=this.buf.readUInt16LE(this.offset);return this.offset+=2,e}readU32(){let e=this.buf.readUInt32LE(this.offset);return this.offset+=4,e}readU64(){let e=this.readBuffer(8);return new s.default(e,`le`)}readU128(){let e=this.readBuffer(16);return new s.default(e,`le`)}readU256(){let e=this.readBuffer(32);return new s.default(e,`le`)}readU512(){let e=this.readBuffer(64);return new s.default(e,`le`)}readBuffer(e){if(this.offset+e>this.buf.length)throw new m(`Expected buffer length ${e} isn't within bounds`);let t=this.buf.slice(this.offset,this.offset+e);return this.offset+=e,t}readString(){let e=this.readU32(),t=this.readBuffer(e);try{return u.decode(t)}catch(e){throw new m(`Error decoding UTF-8 string: ${e}`)}}readFixedArray(e){return new Uint8Array(this.readBuffer(e))}readArray(e){let t=this.readU32(),n=[];for(let r=0;r<t;++r)n.push(e());return n}};i([g],_.prototype,`readU8`,null),i([g],_.prototype,`readU16`,null),i([g],_.prototype,`readU32`,null),i([g],_.prototype,`readU64`,null),i([g],_.prototype,`readU128`,null),i([g],_.prototype,`readU256`,null),i([g],_.prototype,`readU512`,null),i([g],_.prototype,`readString`,null),i([g],_.prototype,`readFixedArray`,null),i([g],_.prototype,`readArray`,null),e.BinaryReader=_;function ee(e){return e.charAt(0).toUpperCase()+e.slice(1)}function te(e,t,n,r,i){try{if(typeof r==`string`)i[`write${ee(r)}`](n);else if(r instanceof Array){if(typeof r[0]==`number`){if(n.length!==r[0])throw new m(`Expecting byte array of length ${r[0]}, but got ${n.length} bytes`);i.writeFixedArray(n)}else if(r.length===2&&typeof r[1]==`number`){if(n.length!==r[1])throw new m(`Expecting byte array of length ${r[1]}, but got ${n.length} bytes`);for(let t=0;t<r[1];t++)te(e,null,n[t],r[0],i)}else i.writeArray(n,n=>{te(e,t,n,r[0],i)})}else if(r.kind!==void 0)switch(r.kind){case`option`:n==null?i.writeU8(0):(i.writeU8(1),te(e,t,n,r.type,i));break;case`map`:i.writeU32(n.size),n.forEach((n,a)=>{te(e,t,a,r.key,i),te(e,t,n,r.value,i)});break;default:throw new m(`FieldType ${r} unrecognized`)}else ne(e,n,i)}catch(e){throw e instanceof m&&e.addToFieldPath(t),e}}function ne(e,t,n){if(typeof t.borshSerialize==`function`){t.borshSerialize(n);return}let r=e.get(t.constructor);if(!r)throw new m(`Class ${t.constructor.name} is missing in schema`);if(r.kind===`struct`)r.fields.map(([r,i])=>{te(e,r,t[r],i,n)});else if(r.kind===`enum`){let i=t[r.field];for(let a=0;a<r.values.length;++a){let[o,s]=r.values[a];if(o===i){n.writeU8(a),te(e,o,t[o],s,n);break}}}else throw new m(`Unexpected schema kind: ${r.kind} for ${t.constructor.name}`)}function re(e,t,n=h){let r=new n;return ne(e,t,r),r.toArray()}e.serialize=re;function x(e,t,n,r){try{if(typeof n==`string`)return r[`read${ee(n)}`]();if(n instanceof Array){if(typeof n[0]==`number`)return r.readFixedArray(n[0]);if(typeof n[1]==`number`){let t=[];for(let i=0;i<n[1];i++)t.push(x(e,null,n[0],r));return t}return r.readArray(()=>x(e,t,n[0],r))}if(n.kind===`option`)return r.readU8()?x(e,t,n.type,r):void 0;if(n.kind===`map`){let i=new Map,a=r.readU32();for(let o=0;o<a;o++){let a=x(e,t,n.key,r),o=x(e,t,n.value,r);i.set(a,o)}return i}return C(e,n,r)}catch(e){throw e instanceof m&&e.addToFieldPath(t),e}}function C(e,t,n){if(typeof t.borshDeserialize==`function`)return t.borshDeserialize(n);let r=e.get(t);if(!r)throw new m(`Class ${t.name} is missing in schema`);if(r.kind===`struct`){let r={};for(let[i,a]of e.get(t).fields)r[i]=x(e,i,a,n);return new t(r)}if(r.kind===`enum`){let i=n.readU8();if(i>=r.values.length)throw new m(`Enum index: ${i} is out of range`);let[a,o]=r.values[i],s=x(e,a,o,n);return new t({[a]:s})}throw new m(`Unexpected schema kind: ${r.kind} for ${t.constructor.name}`)}function w(e,t,n,r=_){let i=new r(n),a=C(e,t,i);if(i.offset<n.length)throw new m(`Unexpected ${n.length-i.offset} bytes after deserialized data`);return a}e.deserialize=w;function T(e,t,n,r=_){return C(e,t,new r(n))}e.deserializeUnchecked=T})),$t=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.s16=e.s8=e.nu64be=e.u48be=e.u40be=e.u32be=e.u24be=e.u16be=e.nu64=e.u48=e.u40=e.u32=e.u24=e.u16=e.u8=e.offset=e.greedy=e.Constant=e.UTF8=e.CString=e.Blob=e.Boolean=e.BitField=e.BitStructure=e.VariantLayout=e.Union=e.UnionLayoutDiscriminator=e.UnionDiscriminator=e.Structure=e.Sequence=e.DoubleBE=e.Double=e.FloatBE=e.Float=e.NearInt64BE=e.NearInt64=e.NearUInt64BE=e.NearUInt64=e.IntBE=e.Int=e.UIntBE=e.UInt=e.OffsetLayout=e.GreedyCount=e.ExternalLayout=e.bindConstructorLayout=e.nameWithProperty=e.Layout=e.uint8ArrayToBuffer=e.checkUint8Array=void 0,e.constant=e.utf8=e.cstr=e.blob=e.unionLayoutDiscriminator=e.union=e.seq=e.bits=e.struct=e.f64be=e.f64=e.f32be=e.f32=e.ns64be=e.s48be=e.s40be=e.s32be=e.s24be=e.s16be=e.ns64=e.s48=e.s40=e.s32=e.s24=void 0;var t=re();function n(e){if(!(e instanceof Uint8Array))throw TypeError(`b must be a Uint8Array`)}e.checkUint8Array=n;function r(e){return n(e),t.Buffer.from(e.buffer,e.byteOffset,e.length)}e.uint8ArrayToBuffer=r;var i=class{constructor(e,t){if(!Number.isInteger(e))throw TypeError(`span must be an integer`);this.span=e,this.property=t}makeDestinationObject(){return{}}getSpan(e,t){if(0>this.span)throw RangeError(`indeterminate span`);return this.span}replicate(e){let t=Object.create(this.constructor.prototype);return Object.assign(t,this),t.property=e,t}fromArray(e){}};e.Layout=i;function a(e,t){return t.property?e+`[`+t.property+`]`:e}e.nameWithProperty=a;function o(e,t){if(typeof e!=`function`)throw TypeError(`Class must be constructor`);if(Object.prototype.hasOwnProperty.call(e,`layout_`))throw Error(`Class is already bound to a layout`);if(!(t&&t instanceof i))throw TypeError(`layout must be a Layout`);if(Object.prototype.hasOwnProperty.call(t,`boundConstructor_`))throw Error(`layout is already bound to a constructor`);e.layout_=t,t.boundConstructor_=e,t.makeDestinationObject=(()=>new e),Object.defineProperty(e.prototype,"encode",{value(e,n){return t.encode(this,e,n)},writable:!0}),Object.defineProperty(e,"decode",{value(e,n){return t.decode(e,n)},writable:!0})}e.bindConstructorLayout=o;var s=class extends i{isCount(){throw Error(`ExternalLayout is abstract`)}};e.ExternalLayout=s;var c=class extends s{constructor(e=1,t){if(!Number.isInteger(e)||0>=e)throw TypeError(`elementSpan must be a (positive) integer`);super(-1,t),this.elementSpan=e}isCount(){return!0}decode(e,t=0){n(e);let r=e.length-t;return Math.floor(r/this.elementSpan)}encode(e,t,n){return 0}};e.GreedyCount=c;var l=class extends s{constructor(e,t=0,n){if(!(e instanceof i))throw TypeError(`layout must be a Layout`);if(!Number.isInteger(t))throw TypeError(`offset must be integer or undefined`);super(e.span,n||e.property),this.layout=e,this.offset=t}isCount(){return this.layout instanceof u||this.layout instanceof d}decode(e,t=0){return this.layout.decode(e,t+this.offset)}encode(e,t,n=0){return this.layout.encode(e,t,n+this.offset)}};e.OffsetLayout=l;var u=class extends i{constructor(e,t){if(super(e,t),6<this.span)throw RangeError(`span must not exceed 6 bytes`)}decode(e,t=0){return r(e).readUIntLE(t,this.span)}encode(e,t,n=0){return r(t).writeUIntLE(e,n,this.span),this.span}};e.UInt=u;var d=class extends i{constructor(e,t){if(super(e,t),6<this.span)throw RangeError(`span must not exceed 6 bytes`)}decode(e,t=0){return r(e).readUIntBE(t,this.span)}encode(e,t,n=0){return r(t).writeUIntBE(e,n,this.span),this.span}};e.UIntBE=d;var f=class extends i{constructor(e,t){if(super(e,t),6<this.span)throw RangeError(`span must not exceed 6 bytes`)}decode(e,t=0){return r(e).readIntLE(t,this.span)}encode(e,t,n=0){return r(t).writeIntLE(e,n,this.span),this.span}};e.Int=f;var p=class extends i{constructor(e,t){if(super(e,t),6<this.span)throw RangeError(`span must not exceed 6 bytes`)}decode(e,t=0){return r(e).readIntBE(t,this.span)}encode(e,t,n=0){return r(t).writeIntBE(e,n,this.span),this.span}};e.IntBE=p;var m=2**32;function h(e){let t=Math.floor(e/m);return{hi32:t,lo32:e-t*m}}function g(e,t){return e*m+t}var _=class extends i{constructor(e){super(8,e)}decode(e,t=0){let n=r(e),i=n.readUInt32LE(t);return g(n.readUInt32LE(t+4),i)}encode(e,t,n=0){let i=h(e),a=r(t);return a.writeUInt32LE(i.lo32,n),a.writeUInt32LE(i.hi32,n+4),8}};e.NearUInt64=_;var v=class extends i{constructor(e){super(8,e)}decode(e,t=0){let n=r(e);return g(n.readUInt32BE(t),n.readUInt32BE(t+4))}encode(e,t,n=0){let i=h(e),a=r(t);return a.writeUInt32BE(i.hi32,n),a.writeUInt32BE(i.lo32,n+4),8}};e.NearUInt64BE=v;var y=class extends i{constructor(e){super(8,e)}decode(e,t=0){let n=r(e),i=n.readUInt32LE(t);return g(n.readInt32LE(t+4),i)}encode(e,t,n=0){let i=h(e),a=r(t);return a.writeUInt32LE(i.lo32,n),a.writeInt32LE(i.hi32,n+4),8}};e.NearInt64=y;var ee=class extends i{constructor(e){super(8,e)}decode(e,t=0){let n=r(e);return g(n.readInt32BE(t),n.readUInt32BE(t+4))}encode(e,t,n=0){let i=h(e),a=r(t);return a.writeInt32BE(i.hi32,n),a.writeUInt32BE(i.lo32,n+4),8}};e.NearInt64BE=ee;var te=class extends i{constructor(e){super(4,e)}decode(e,t=0){return r(e).readFloatLE(t)}encode(e,t,n=0){return r(t).writeFloatLE(e,n),4}};e.Float=te;var ne=class extends i{constructor(e){super(4,e)}decode(e,t=0){return r(e).readFloatBE(t)}encode(e,t,n=0){return r(t).writeFloatBE(e,n),4}};e.FloatBE=ne;var b=class extends i{constructor(e){super(8,e)}decode(e,t=0){return r(e).readDoubleLE(t)}encode(e,t,n=0){return r(t).writeDoubleLE(e,n),8}};e.Double=b;var x=class extends i{constructor(e){super(8,e)}decode(e,t=0){return r(e).readDoubleBE(t)}encode(e,t,n=0){return r(t).writeDoubleBE(e,n),8}};e.DoubleBE=x;var S=class extends i{constructor(e,t,n){if(!(e instanceof i))throw TypeError(`elementLayout must be a Layout`);if(!(t instanceof s&&t.isCount()||Number.isInteger(t)&&0<=t))throw TypeError(`count must be non-negative integer or an unsigned integer ExternalLayout`);let r=-1;!(t instanceof s)&&0<e.span&&(r=t*e.span),super(r,n),this.elementLayout=e,this.count=t}getSpan(e,t=0){if(0<=this.span)return this.span;let n=0,r=this.count;if(r instanceof s&&(r=r.decode(e,t)),0<this.elementLayout.span)n=r*this.elementLayout.span;else{let i=0;for(;i<r;)n+=this.elementLayout.getSpan(e,t+n),++i}return n}decode(e,t=0){let n=[],r=0,i=this.count;for(i instanceof s&&(i=i.decode(e,t));r<i;)n.push(this.elementLayout.decode(e,t)),t+=this.elementLayout.getSpan(e,t),r+=1;return n}encode(e,t,n=0){let r=this.elementLayout,i=e.reduce((e,i)=>e+r.encode(i,t,n+e),0);return this.count instanceof s&&this.count.encode(e.length,t,n),i}};e.Sequence=S;var C=class extends i{constructor(e,t,n){if(!(Array.isArray(e)&&e.reduce((e,t)=>e&&t instanceof i,!0)))throw TypeError(`fields must be array of Layout instances`);typeof t==`boolean`&&n===void 0&&(n=t,t=void 0);for(let t of e)if(0>t.span&&t.property===void 0)throw Error(`fields cannot contain unnamed variable-length layout`);let r=-1;try{r=e.reduce((e,t)=>e+t.getSpan(),0)}catch{}super(r,t),this.fields=e,this.decodePrefixes=!!n}getSpan(e,t=0){if(0<=this.span)return this.span;let n=0;try{n=this.fields.reduce((n,r)=>{let i=r.getSpan(e,t);return t+=i,n+i},0)}catch{throw RangeError(`indeterminate span`)}return n}decode(e,t=0){n(e);let r=this.makeDestinationObject();for(let n of this.fields)if(n.property!==void 0&&(r[n.property]=n.decode(e,t)),t+=n.getSpan(e,t),this.decodePrefixes&&e.length===t)break;return r}encode(e,t,n=0){let r=n,i=0,a=0;for(let r of this.fields){let o=r.span;if(a=0<o?o:0,r.property!==void 0){let i=e[r.property];i!==void 0&&(a=r.encode(i,t,n),0>o&&(o=r.getSpan(t,n)))}i=n,n+=o}return i+a-r}fromArray(e){let t=this.makeDestinationObject();for(let n of this.fields)n.property!==void 0&&0<e.length&&(t[n.property]=e.shift());return t}layoutFor(e){if(typeof e!=`string`)throw TypeError(`property must be string`);for(let t of this.fields)if(t.property===e)return t}offsetOf(e){if(typeof e!=`string`)throw TypeError(`property must be string`);let t=0;for(let n of this.fields){if(n.property===e)return t;0>n.span?t=-1:0<=t&&(t+=n.span)}}};e.Structure=C;var w=class{constructor(e){this.property=e}decode(e,t){throw Error(`UnionDiscriminator is abstract`)}encode(e,t,n){throw Error(`UnionDiscriminator is abstract`)}};e.UnionDiscriminator=w;var T=class extends w{constructor(e,t){if(!(e instanceof s&&e.isCount()))throw TypeError(`layout must be an unsigned integer ExternalLayout`);super(t||e.property||`variant`),this.layout=e}decode(e,t){return this.layout.decode(e,t)}encode(e,t,n){return this.layout.encode(e,t,n)}};e.UnionLayoutDiscriminator=T;var E=class extends i{constructor(e,t,n){let r;if(e instanceof u||e instanceof d)r=new T(new l(e));else if(e instanceof s&&e.isCount())r=new T(e);else if(e instanceof w)r=e;else throw TypeError(`discr must be a UnionDiscriminator or an unsigned integer layout`);if(t===void 0&&(t=null),!(t===null||t instanceof i))throw TypeError(`defaultLayout must be null or a Layout`);if(t!==null){if(0>t.span)throw Error(`defaultLayout must have constant span`);t.property===void 0&&(t=t.replicate(`content`))}let a=-1;t&&(a=t.span,0<=a&&(e instanceof u||e instanceof d)&&(a+=r.layout.span)),super(a,n),this.discriminator=r,this.usesPrefixDiscriminator=e instanceof u||e instanceof d,this.defaultLayout=t,this.registry={};let o=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(e){return o(e)},this.configGetSourceVariant=function(e){o=e.bind(this)}}getSpan(e,t=0){if(0<=this.span)return this.span;let n=this.getVariant(e,t);if(!n)throw Error(`unable to determine span for unrecognized variant`);return n.getSpan(e,t)}defaultGetSourceVariant(e){if(Object.prototype.hasOwnProperty.call(e,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(e,this.defaultLayout.property))return;let t=this.registry[e[this.discriminator.property]];if(t&&(!t.layout||t.property&&Object.prototype.hasOwnProperty.call(e,t.property)))return t}else for(let t in this.registry){let n=this.registry[t];if(n.property&&Object.prototype.hasOwnProperty.call(e,n.property))return n}throw Error(`unable to infer src variant`)}decode(e,t=0){let n,r=this.discriminator,i=r.decode(e,t),a=this.registry[i];if(a===void 0){let a=this.defaultLayout,o=0;this.usesPrefixDiscriminator&&(o=r.layout.span),n=this.makeDestinationObject(),n[r.property]=i,n[a.property]=a.decode(e,t+o)}else n=a.decode(e,t);return n}encode(e,t,n=0){let r=this.getSourceVariant(e);if(r===void 0){let r=this.discriminator,i=this.defaultLayout,a=0;return this.usesPrefixDiscriminator&&(a=r.layout.span),r.encode(e[r.property],t,n),a+i.encode(e[i.property],t,n+a)}return r.encode(e,t,n)}addVariant(e,t,n){let r=new ie(this,e,t,n);return this.registry[e]=r,r}getVariant(e,t=0){let n;return n=e instanceof Uint8Array?this.discriminator.decode(e,t):e,this.registry[n]}};e.Union=E;var ie=class extends i{constructor(e,t,n,r){if(!(e instanceof E))throw TypeError(`union must be a Union`);if(!Number.isInteger(t)||0>t)throw TypeError(`variant must be a (non-negative) integer`);if(typeof n==`string`&&r===void 0&&(r=n,n=null),n){if(!(n instanceof i))throw TypeError(`layout must be a Layout`);if(e.defaultLayout!==null&&0<=n.span&&n.span>e.defaultLayout.span)throw Error(`variant span exceeds span of containing union`);if(typeof r!=`string`)throw TypeError(`variant must have a String property`)}let a=e.span;0>e.span&&(a=n?n.span:0,0<=a&&e.usesPrefixDiscriminator&&(a+=e.discriminator.layout.span)),super(a,r),this.union=e,this.variant=t,this.layout=n||null}getSpan(e,t=0){if(0<=this.span)return this.span;let n=0;this.union.usesPrefixDiscriminator&&(n=this.union.discriminator.layout.span);let r=0;return this.layout&&(r=this.layout.getSpan(e,t+n)),n+r}decode(e,t=0){let n=this.makeDestinationObject();if(this!==this.union.getVariant(e,t))throw Error(`variant mismatch`);let r=0;return this.union.usesPrefixDiscriminator&&(r=this.union.discriminator.layout.span),this.layout?n[this.property]=this.layout.decode(e,t+r):this.property?n[this.property]=!0:this.union.usesPrefixDiscriminator&&(n[this.union.discriminator.property]=this.variant),n}encode(e,t,n=0){let r=0;if(this.union.usesPrefixDiscriminator&&(r=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(e,this.property))throw TypeError(`variant lacks property `+this.property);this.union.discriminator.encode(this.variant,t,n);let i=r;if(this.layout&&(this.layout.encode(e[this.property],t,n+r),i+=this.layout.getSpan(t,n+r),0<=this.union.span&&i>this.union.span))throw Error(`encoded variant overruns containing union`);return i}fromArray(e){if(this.layout)return this.layout.fromArray(e)}};e.VariantLayout=ie;function ae(e){return 0>e&&(e+=4294967296),e}var oe=class extends i{constructor(e,t,n){if(!(e instanceof u||e instanceof d))throw TypeError(`word must be a UInt or UIntBE layout`);if(typeof t==`string`&&n===void 0&&(n=t,t=!1),4<e.span)throw RangeError(`word cannot exceed 32 bits`);super(e.span,n),this.word=e,this.msb=!!t,this.fields=[];let r=0;this._packedSetValue=function(e){return r=ae(e),this},this._packedGetValue=function(){return r}}decode(e,t=0){let n=this.makeDestinationObject(),r=this.word.decode(e,t);this._packedSetValue(r);for(let t of this.fields)t.property!==void 0&&(n[t.property]=t.decode(e));return n}encode(e,t,n=0){let r=this.word.decode(t,n);this._packedSetValue(r);for(let t of this.fields)if(t.property!==void 0){let n=e[t.property];n!==void 0&&t.encode(n)}return this.word.encode(this._packedGetValue(),t,n)}addField(e,t){let n=new D(this,e,t);return this.fields.push(n),n}addBoolean(e){let t=new se(this,e);return this.fields.push(t),t}fieldFor(e){if(typeof e!=`string`)throw TypeError(`property must be string`);for(let t of this.fields)if(t.property===e)return t}};e.BitStructure=oe;var D=class{constructor(e,t,n){if(!(e instanceof oe))throw TypeError(`container must be a BitStructure`);if(!Number.isInteger(t)||0>=t)throw TypeError(`bits must be positive integer`);let r=8*e.span,i=e.fields.reduce((e,t)=>e+t.bits,0);if(t+i>r)throw Error(`bits too long for span remainder (`+(r-i)+` of `+r+` remain)`);this.container=e,this.bits=t,this.valueMask=(1<<t)-1,t===32&&(this.valueMask=4294967295),this.start=i,this.container.msb&&(this.start=r-i-t),this.wordMask=ae(this.valueMask<<this.start),this.property=n}decode(e,t){return ae(this.container._packedGetValue()&this.wordMask)>>>this.start}encode(e){if(typeof e!=`number`||!Number.isInteger(e)||e!==ae(e&this.valueMask))throw TypeError(a(`BitField.encode`,this)+` value must be integer not exceeding `+this.valueMask);let t=this.container._packedGetValue(),n=ae(e<<this.start);this.container._packedSetValue(ae(t&~this.wordMask)|n)}};e.BitField=D;var se=class extends D{constructor(e,t){super(e,1,t)}decode(e,t){return!!super.decode(e,t)}encode(e){typeof e==`boolean`&&(e=+e),super.encode(e)}};e.Boolean=se;var ce=class extends i{constructor(e,t){if(!(e instanceof s&&e.isCount()||Number.isInteger(e)&&0<=e))throw TypeError(`length must be positive integer or an unsigned integer ExternalLayout`);let n=-1;e instanceof s||(n=e),super(n,t),this.length=e}getSpan(e,t){let n=this.span;return 0>n&&(n=this.length.decode(e,t)),n}decode(e,t=0){let n=this.span;return 0>n&&(n=this.length.decode(e,t)),r(e).slice(t,t+n)}encode(e,t,n){let i=this.length;if(this.length instanceof s&&(i=e.length),!(e instanceof Uint8Array&&i===e.length))throw TypeError(a(`Blob.encode`,this)+` requires (length `+i+`) Uint8Array as src`);if(n+i>t.length)throw RangeError(`encoding overruns Uint8Array`);let o=r(e);return r(t).write(o.toString(`hex`),n,i,`hex`),this.length instanceof s&&this.length.encode(i,t,n),i}};e.Blob=ce;var le=class extends i{constructor(e){super(-1,e)}getSpan(e,t=0){n(e);let r=t;for(;r<e.length&&e[r]!==0;)r+=1;return 1+r-t}decode(e,t=0){let n=this.getSpan(e,t);return r(e).slice(t,t+n-1).toString(`utf-8`)}encode(e,n,i=0){typeof e!=`string`&&(e=String(e));let a=t.Buffer.from(e,`utf8`),o=a.length;if(i+o>n.length)throw RangeError(`encoding overruns Buffer`);let s=r(n);return a.copy(s,i),s[i+o]=0,o+1}};e.CString=le;var ue=class extends i{constructor(e,t){if(typeof e==`string`&&t===void 0&&(t=e,e=void 0),e===void 0)e=-1;else if(!Number.isInteger(e))throw TypeError(`maxSpan must be an integer`);super(-1,t),this.maxSpan=e}getSpan(e,t=0){return n(e),e.length-t}decode(e,t=0){let n=this.getSpan(e,t);if(0<=this.maxSpan&&this.maxSpan<n)throw RangeError(`text length exceeds maxSpan`);return r(e).slice(t,t+n).toString(`utf-8`)}encode(e,n,i=0){typeof e!=`string`&&(e=String(e));let a=t.Buffer.from(e,`utf8`),o=a.length;if(0<=this.maxSpan&&this.maxSpan<o)throw RangeError(`text length exceeds maxSpan`);if(i+o>n.length)throw RangeError(`encoding overruns Buffer`);return a.copy(r(n),i),o}};e.UTF8=ue;var de=class extends i{constructor(e,t){super(0,t),this.value=e}decode(e,t){return this.value}encode(e,t,n){return 0}};e.Constant=de,e.greedy=((e,t)=>new c(e,t)),e.offset=((e,t,n)=>new l(e,t,n)),e.u8=(e=>new u(1,e)),e.u16=(e=>new u(2,e)),e.u24=(e=>new u(3,e)),e.u32=(e=>new u(4,e)),e.u40=(e=>new u(5,e)),e.u48=(e=>new u(6,e)),e.nu64=(e=>new _(e)),e.u16be=(e=>new d(2,e)),e.u24be=(e=>new d(3,e)),e.u32be=(e=>new d(4,e)),e.u40be=(e=>new d(5,e)),e.u48be=(e=>new d(6,e)),e.nu64be=(e=>new v(e)),e.s8=(e=>new f(1,e)),e.s16=(e=>new f(2,e)),e.s24=(e=>new f(3,e)),e.s32=(e=>new f(4,e)),e.s40=(e=>new f(5,e)),e.s48=(e=>new f(6,e)),e.ns64=(e=>new y(e)),e.s16be=(e=>new p(2,e)),e.s24be=(e=>new p(3,e)),e.s32be=(e=>new p(4,e)),e.s40be=(e=>new p(5,e)),e.s48be=(e=>new p(6,e)),e.ns64be=(e=>new ee(e)),e.f32=(e=>new te(e)),e.f32be=(e=>new ne(e)),e.f64=(e=>new b(e)),e.f64be=(e=>new x(e)),e.struct=((e,t,n)=>new C(e,t,n)),e.bits=((e,t,n)=>new oe(e,t,n)),e.seq=((e,t,n)=>new S(e,t,n)),e.union=((e,t,n)=>new E(e,t,n)),e.unionLayoutDiscriminator=((e,t)=>new T(e,t)),e.blob=((e,t)=>new ce(e,t)),e.cstr=(e=>new le(e)),e.utf8=((e,t)=>new ue(e,t)),e.constant=((e,t)=>new de(e,t))}));function en(e){return Array.isArray(e)?`%5B`+e.map(en).join(`%2C%20`)+`%5D`:typeof e==`bigint`?`${e}n`:encodeURIComponent(String(e!=null&&Object.getPrototypeOf(e)===null?{...e}:e))}function tn([e,t]){return`${e}=${en(t)}`}function nn(e){let t=Object.entries(e).map(tn).join(`&`);return btoa(t)}function rn(e,t={}){{let n=`Solana error #${e}; Decode this error by running \`npx @solana/errors decode -- ${e}`;return Object.keys(t).length&&(n+=` '${nn(t)}'`),`${n}\``}}var an,on,sn,cn,ln,un,dn,fn=e((()=>{an=8078e3,on=8078001,sn=8078004,cn=8078005,ln=8078006,un=8078011,dn=class extends Error{cause=this.cause;context;constructor(...[e,t]){let n,r;if(t){let{cause:e,...i}=t;e&&(r={cause:e}),Object.keys(i).length>0&&(n=i)}let i=rn(e,n);super(i,r),this.context={__code:e,...n},this.name=`SolanaError`}}}));function pn(e,t){return`fixedSize`in t?t.fixedSize:t.getSizeFromValue(e)}function mn(e){return Object.freeze({...e,encode:t=>{let n=new Uint8Array(pn(t,e));return e.write(t,n,0),n}})}function hn(e){return Object.freeze({...e,decode:(t,n=0)=>e.read(t,n)[0]})}function gn(e){return`fixedSize`in e&&typeof e.fixedSize==`number`}function _n(e,t){if(gn(e)!==gn(t))throw new dn(sn);if(gn(e)&&gn(t)&&e.fixedSize!==t.fixedSize)throw new dn(cn,{decoderFixedSize:t.fixedSize,encoderFixedSize:e.fixedSize});if(!gn(e)&&!gn(t)&&e.maxSize!==t.maxSize)throw new dn(ln,{decoderMaxSize:t.maxSize,encoderMaxSize:e.maxSize});return{...t,...e,decode:t.decode,encode:e.encode,read:t.read,write:e.write}}function vn(e,t,n=0){if(t.length-n<=0)throw new dn(an,{codecDescription:e})}function yn(e,t,n,r=0){let i=n.length-r;if(i<t)throw new dn(on,{bytesLength:i,codecDescription:e,expected:t})}var bn=e((()=>{fn()}));function xn(e,t,n,r){if(r<t||r>n)throw new dn(un,{codecDescription:e,max:n,min:t,value:r})}function Sn(e){return e?.endian!==1}function Cn(e){return mn({fixedSize:e.size,write(t,n,r){e.range&&xn(e.name,e.range[0],e.range[1],t);let i=new ArrayBuffer(e.size);return e.set(new DataView(i),t,Sn(e.config)),n.set(new Uint8Array(i),r),r+e.size}})}function wn(e){return hn({fixedSize:e.size,read(t,n=0){vn(e.name,t,n),yn(e.name,e.size,t,n);let r=new DataView(Tn(t,n,e.size));return[e.get(r,Sn(e.config)),n+e.size]}})}function Tn(e,t,n){let r=e.byteOffset+(t??0),i=n??e.byteLength;return e.buffer.slice(r,r+i)}var En,Dn,On,kn=e((()=>{fn(),bn(),En=(e={})=>Cn({config:e,name:`u64`,range:[0n,BigInt(`0xffffffffffffffff`)],set:(e,t,n)=>e.setBigUint64(0,BigInt(t),n),size:8}),Dn=(e={})=>wn({config:e,get:(e,t)=>e.getBigUint64(0,t),name:`u64`,size:8}),On=(e={})=>_n(En(e),Dn(e))}));function An(e){return jn(e)&&typeof e[Symbol.iterator]==`function`}function jn(e){return typeof e==`object`&&!!e}function Mn(e){return jn(e)&&!Array.isArray(e)}function Nn(e){return typeof e==`symbol`?e.toString():typeof e==`string`?JSON.stringify(e):`${e}`}function Pn(e){let{done:t,value:n}=e.next();return t?void 0:n}function Fn(e,t,n,r){if(e===!0)return;e===!1?e={}:typeof e==`string`&&(e={message:e});let{path:i,branch:a}=t,{type:o}=n,{refinement:s,message:c=`Expected a value of type \`${o}\`${s?` with refinement \`${s}\``:``}, but received: \`${Nn(r)}\``}=e;return{value:r,type:o,refinement:s,key:i[i.length-1],path:i,branch:a,...e,message:c}}function*In(e,t,n,r){An(e)||(e=[e]);for(let i of e){let e=Fn(i,t,n,r);e&&(yield e)}}function*Ln(e,t,n={}){let{path:r=[],branch:i=[e],coerce:a=!1,mask:o=!1}=n,s={path:r,branch:i,mask:o};a&&(e=t.coercer(e,s));let c=`valid`;for(let r of t.validator(e,s))r.explanation=n.message,c=`not_valid`,yield[r,void 0];for(let[l,u,d]of t.entries(e,s)){let t=Ln(u,d,{path:l===void 0?r:[...r,l],branch:l===void 0?i:[...i,u],coerce:a,mask:o,message:n.message});for(let n of t)n[0]?(c=n[0].refinement==null?`not_valid`:`not_refined`,yield[n[0],void 0]):a&&(u=n[1],l===void 0?e=u:e instanceof Map?e.set(l,u):e instanceof Set?e.add(u):jn(e)&&(u!==void 0||l in e)&&(e[l]=u))}if(c!==`not_valid`)for(let r of t.refiner(e,s))r.explanation=n.message,c=`not_refined`,yield[r,void 0];c===`valid`&&(yield[void 0,e])}function Rn(e,t,n){let r=Vn(e,t,{message:n});if(r[0])throw r[0]}function N(e,t,n){let r=Vn(e,t,{coerce:!0,message:n});if(r[0])throw r[0];return r[1]}function zn(e,t,n){let r=Vn(e,t,{coerce:!0,mask:!0,message:n});if(r[0])throw r[0];return r[1]}function Bn(e,t){return!Vn(e,t)[0]}function Vn(e,t,n={}){let r=Ln(e,t,n),i=Pn(r);return i[0]?[new $n(i[0],function*(){for(let e of r)e[0]&&(yield e[0])}),void 0]:[void 0,i[1]]}function Hn(e,t){return new er({type:e,schema:null,validator:t})}function Un(){return Hn(`any`,()=>!0)}function P(e){return new er({type:`array`,schema:e,*entries(t){if(e&&Array.isArray(t))for(let[n,r]of t.entries())yield[n,r,e]},coercer(e){return Array.isArray(e)?e.slice():e},validator(e){return Array.isArray(e)||`Expected an array value, but received: ${Nn(e)}`}})}function Wn(){return Hn(`boolean`,e=>typeof e==`boolean`)}function Gn(e){return Hn(`instance`,t=>t instanceof e||`Expected a \`${e.name}\` instance, but received: ${Nn(t)}`)}function Kn(e){let t=Nn(e),n=typeof e;return new er({type:`literal`,schema:n===`string`||n===`number`||n===`boolean`?e:null,validator(n){return n===e||`Expected the literal \`${t}\`, but received: ${Nn(n)}`}})}function qn(){return Hn(`never`,()=>!1)}function F(e){return new er({...e,validator:(t,n)=>t===null||e.validator(t,n),refiner:(t,n)=>t===null||e.refiner(t,n)})}function I(){return Hn(`number`,e=>typeof e==`number`&&!isNaN(e)||`Expected a number, but received: ${Nn(e)}`)}function L(e){return new er({...e,validator:(t,n)=>t===void 0||e.validator(t,n),refiner:(t,n)=>t===void 0||e.refiner(t,n)})}function Jn(e,t){return new er({type:`record`,schema:null,*entries(n){if(jn(n))for(let r in n){let i=n[r];yield[r,r,e],yield[r,i,t]}},validator(e){return Mn(e)||`Expected an object, but received: ${Nn(e)}`},coercer(e){return Mn(e)?{...e}:e}})}function R(){return Hn(`string`,e=>typeof e==`string`||`Expected a string, but received: ${Nn(e)}`)}function Yn(e){let t=qn();return new er({type:`tuple`,schema:null,*entries(n){if(Array.isArray(n)){let r=Math.max(e.length,n.length);for(let i=0;i<r;i++)yield[i,n[i],e[i]||t]}},validator(e){return Array.isArray(e)||`Expected an array, but received: ${Nn(e)}`},coercer(e){return Array.isArray(e)?e.slice():e}})}function z(e){let t=Object.keys(e);return new er({type:`type`,schema:e,*entries(n){if(jn(n))for(let r of t)yield[r,n[r],e[r]]},validator(e){return Mn(e)||`Expected an object, but received: ${Nn(e)}`},coercer(e){return Mn(e)?{...e}:e}})}function Xn(e){let t=e.map(e=>e.type).join(` | `);return new er({type:`union`,schema:null,coercer(t,n){for(let r of e){let[e,i]=r.validate(t,{coerce:!0,mask:n.mask});if(!e)return i}return t},validator(n,r){let i=[];for(let t of e){let[...e]=Ln(n,t,r),[a]=e;if(a[0])for(let[t]of e)t&&i.push(t);else return[]}return[`Expected the value to satisfy a union of \`${t}\`, but received: ${Nn(n)}`,...i]}})}function Zn(){return Hn(`unknown`,()=>!0)}function Qn(e,t,n){return new er({...e,coercer:(r,i)=>Bn(r,t)?e.coercer(n(r,i),i):e.coercer(r,i)})}var $n,er,tr=e((()=>{$n=class extends TypeError{constructor(e,t){let n,{message:r,explanation:i,...a}=e,{path:o}=e,s=o.length===0?r:`At path: ${o.join(`.`)} -- ${r}`;super(i??s),i!=null&&(this.cause=s),Object.assign(this,a),this.name=this.constructor.name,this.failures=()=>n??=[e,...t()]}},er=class{constructor(e){let{type:t,schema:n,validator:r,refiner:i,coercer:a=e=>e,entries:o=function*(){}}=e;this.type=t,this.schema=n,this.entries=o,this.coercer=a,this.validator=r?(e,t)=>In(r(e,t),t,this,e):()=>[],this.refiner=i?(e,t)=>In(i(e,t),t,this,e):()=>[]}assert(e,t){return Rn(e,this,t)}create(e,t){return N(e,this,t)}is(e){return Bn(e,this)}mask(e,t){return zn(e,this,t)}validate(e,t={}){return Vn(e,this,t)}}}));function nr(){if(!rr&&(rr=typeof crypto<`u`&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<`u`&&typeof msCrypto.getRandomValues==`function`&&msCrypto.getRandomValues.bind(msCrypto),!rr))throw Error(`crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported`);return rr(ir)}var rr,ir,ar=e((()=>{ir=new Uint8Array(16)})),or,sr=e((()=>{or=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i}));function cr(e){return typeof e==`string`&&or.test(e)}var lr=e((()=>{sr()}));function ur(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=(dr[e[t+0]]+dr[e[t+1]]+dr[e[t+2]]+dr[e[t+3]]+`-`+dr[e[t+4]]+dr[e[t+5]]+`-`+dr[e[t+6]]+dr[e[t+7]]+`-`+dr[e[t+8]]+dr[e[t+9]]+`-`+dr[e[t+10]]+dr[e[t+11]]+dr[e[t+12]]+dr[e[t+13]]+dr[e[t+14]]+dr[e[t+15]]).toLowerCase();if(!cr(n))throw TypeError(`Stringified UUID is invalid`);return n}var dr,fr,pr=e((()=>{for(lr(),dr=[],fr=0;fr<256;++fr)dr.push((fr+256).toString(16).substr(1))}));function mr(e,t,n){var r=t&&n||0,i=t||Array(16);e||={};var a=e.node||hr,o=e.clockseq===void 0?gr:e.clockseq;if(a==null||o==null){var s=e.random||(e.rng||nr)();a??=hr=[s[0]|1,s[1],s[2],s[3],s[4],s[5]],o??=gr=(s[6]<<8|s[7])&16383}var c=e.msecs===void 0?Date.now():e.msecs,l=e.nsecs===void 0?vr+1:e.nsecs,u=c-_r+(l-vr)/1e4;if(u<0&&e.clockseq===void 0&&(o=o+1&16383),(u<0||c>_r)&&e.nsecs===void 0&&(l=0),l>=1e4)throw Error(`uuid.v1(): Can't create more than 10M uuids/sec`);_r=c,vr=l,gr=o,c+=0xb1d069b5400;var d=((c&268435455)*1e4+l)%4294967296;i[r++]=d>>>24&255,i[r++]=d>>>16&255,i[r++]=d>>>8&255,i[r++]=d&255;var f=c/4294967296*1e4&268435455;i[r++]=f>>>8&255,i[r++]=f&255,i[r++]=f>>>24&15|16,i[r++]=f>>>16&255,i[r++]=o>>>8|128,i[r++]=o&255;for(var p=0;p<6;++p)i[r+p]=a[p];return t||ur(i)}var hr,gr,_r,vr,yr=e((()=>{ar(),pr(),_r=0,vr=0}));function br(e){if(!cr(e))throw TypeError(`Invalid UUID`);var t,n=new Uint8Array(16);return n[0]=(t=parseInt(e.slice(0,8),16))>>>24,n[1]=t>>>16&255,n[2]=t>>>8&255,n[3]=t&255,n[4]=(t=parseInt(e.slice(9,13),16))>>>8,n[5]=t&255,n[6]=(t=parseInt(e.slice(14,18),16))>>>8,n[7]=t&255,n[8]=(t=parseInt(e.slice(19,23),16))>>>8,n[9]=t&255,n[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,n[11]=t/4294967296&255,n[12]=t>>>24&255,n[13]=t>>>16&255,n[14]=t>>>8&255,n[15]=t&255,n}var xr=e((()=>{lr()}));function Sr(e){e=unescape(encodeURIComponent(e));for(var t=[],n=0;n<e.length;++n)t.push(e.charCodeAt(n));return t}function Cr(e,t,n){function r(e,r,i,a){if(typeof e==`string`&&(e=Sr(e)),typeof r==`string`&&(r=br(r)),r.length!==16)throw TypeError(`Namespace must be array-like (16 iterable integer values, 0-255)`);var o=new Uint8Array(16+e.length);if(o.set(r),o.set(e,r.length),o=n(o),o[6]=o[6]&15|t,o[8]=o[8]&63|128,i){a||=0;for(var s=0;s<16;++s)i[a+s]=o[s];return i}return ur(o)}try{r.name=e}catch{}return r.DNS=wr,r.URL=Tr,r}var wr,Tr,Er=e((()=>{pr(),xr(),wr=`6ba7b810-9dad-11d1-80b4-00c04fd430c8`,Tr=`6ba7b811-9dad-11d1-80b4-00c04fd430c8`}));function Dr(e){if(typeof e==`string`){var t=unescape(encodeURIComponent(e));e=new Uint8Array(t.length);for(var n=0;n<t.length;++n)e[n]=t.charCodeAt(n)}return Or(Ar(jr(e),e.length*8))}function Or(e){for(var t=[],n=e.length*32,r=`0123456789abcdef`,i=0;i<n;i+=8){var a=e[i>>5]>>>i%32&255,o=parseInt(r.charAt(a>>>4&15)+r.charAt(a&15),16);t.push(o)}return t}function kr(e){return(e+64>>>9<<4)+14+1}function Ar(e,t){e[t>>5]|=128<<t%32,e[kr(t)-1]=t;for(var n=1732584193,r=-271733879,i=-1732584194,a=271733878,o=0;o<e.length;o+=16){var s=n,c=r,l=i,u=a;n=Fr(n,r,i,a,e[o],7,-680876936),a=Fr(a,n,r,i,e[o+1],12,-389564586),i=Fr(i,a,n,r,e[o+2],17,606105819),r=Fr(r,i,a,n,e[o+3],22,-1044525330),n=Fr(n,r,i,a,e[o+4],7,-176418897),a=Fr(a,n,r,i,e[o+5],12,1200080426),i=Fr(i,a,n,r,e[o+6],17,-1473231341),r=Fr(r,i,a,n,e[o+7],22,-45705983),n=Fr(n,r,i,a,e[o+8],7,1770035416),a=Fr(a,n,r,i,e[o+9],12,-1958414417),i=Fr(i,a,n,r,e[o+10],17,-42063),r=Fr(r,i,a,n,e[o+11],22,-1990404162),n=Fr(n,r,i,a,e[o+12],7,1804603682),a=Fr(a,n,r,i,e[o+13],12,-40341101),i=Fr(i,a,n,r,e[o+14],17,-1502002290),r=Fr(r,i,a,n,e[o+15],22,1236535329),n=Ir(n,r,i,a,e[o+1],5,-165796510),a=Ir(a,n,r,i,e[o+6],9,-1069501632),i=Ir(i,a,n,r,e[o+11],14,643717713),r=Ir(r,i,a,n,e[o],20,-373897302),n=Ir(n,r,i,a,e[o+5],5,-701558691),a=Ir(a,n,r,i,e[o+10],9,38016083),i=Ir(i,a,n,r,e[o+15],14,-660478335),r=Ir(r,i,a,n,e[o+4],20,-405537848),n=Ir(n,r,i,a,e[o+9],5,568446438),a=Ir(a,n,r,i,e[o+14],9,-1019803690),i=Ir(i,a,n,r,e[o+3],14,-187363961),r=Ir(r,i,a,n,e[o+8],20,1163531501),n=Ir(n,r,i,a,e[o+13],5,-1444681467),a=Ir(a,n,r,i,e[o+2],9,-51403784),i=Ir(i,a,n,r,e[o+7],14,1735328473),r=Ir(r,i,a,n,e[o+12],20,-1926607734),n=Lr(n,r,i,a,e[o+5],4,-378558),a=Lr(a,n,r,i,e[o+8],11,-2022574463),i=Lr(i,a,n,r,e[o+11],16,1839030562),r=Lr(r,i,a,n,e[o+14],23,-35309556),n=Lr(n,r,i,a,e[o+1],4,-1530992060),a=Lr(a,n,r,i,e[o+4],11,1272893353),i=Lr(i,a,n,r,e[o+7],16,-155497632),r=Lr(r,i,a,n,e[o+10],23,-1094730640),n=Lr(n,r,i,a,e[o+13],4,681279174),a=Lr(a,n,r,i,e[o],11,-358537222),i=Lr(i,a,n,r,e[o+3],16,-722521979),r=Lr(r,i,a,n,e[o+6],23,76029189),n=Lr(n,r,i,a,e[o+9],4,-640364487),a=Lr(a,n,r,i,e[o+12],11,-421815835),i=Lr(i,a,n,r,e[o+15],16,530742520),r=Lr(r,i,a,n,e[o+2],23,-995338651),n=Rr(n,r,i,a,e[o],6,-198630844),a=Rr(a,n,r,i,e[o+7],10,1126891415),i=Rr(i,a,n,r,e[o+14],15,-1416354905),r=Rr(r,i,a,n,e[o+5],21,-57434055),n=Rr(n,r,i,a,e[o+12],6,1700485571),a=Rr(a,n,r,i,e[o+3],10,-1894986606),i=Rr(i,a,n,r,e[o+10],15,-1051523),r=Rr(r,i,a,n,e[o+1],21,-2054922799),n=Rr(n,r,i,a,e[o+8],6,1873313359),a=Rr(a,n,r,i,e[o+15],10,-30611744),i=Rr(i,a,n,r,e[o+6],15,-1560198380),r=Rr(r,i,a,n,e[o+13],21,1309151649),n=Rr(n,r,i,a,e[o+4],6,-145523070),a=Rr(a,n,r,i,e[o+11],10,-1120210379),i=Rr(i,a,n,r,e[o+2],15,718787259),r=Rr(r,i,a,n,e[o+9],21,-343485551),n=Mr(n,s),r=Mr(r,c),i=Mr(i,l),a=Mr(a,u)}return[n,r,i,a]}function jr(e){if(e.length===0)return[];for(var t=e.length*8,n=new Uint32Array(kr(t)),r=0;r<t;r+=8)n[r>>5]|=(e[r/8]&255)<<r%32;return n}function Mr(e,t){var n=(e&65535)+(t&65535);return(e>>16)+(t>>16)+(n>>16)<<16|n&65535}function Nr(e,t){return e<<t|e>>>32-t}function Pr(e,t,n,r,i,a){return Mr(Nr(Mr(Mr(t,e),Mr(r,a)),i),n)}function Fr(e,t,n,r,i,a,o){return Pr(t&n|~t&r,e,t,i,a,o)}function Ir(e,t,n,r,i,a,o){return Pr(t&r|n&~r,e,t,i,a,o)}function Lr(e,t,n,r,i,a,o){return Pr(t^n^r,e,t,i,a,o)}function Rr(e,t,n,r,i,a,o){return Pr(n^(t|~r),e,t,i,a,o)}var zr=e((()=>{})),Br,Vr=e((()=>{Er(),zr(),Br=Cr(`v3`,48,Dr)}));function Hr(e,t,n){e||={};var r=e.random||(e.rng||nr)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){n||=0;for(var i=0;i<16;++i)t[n+i]=r[i];return t}return ur(r)}var Ur=e((()=>{ar(),pr()}));function Wr(e,t,n,r){switch(e){case 0:return t&n^~t&r;case 1:return t^n^r;case 2:return t&n^t&r^n&r;case 3:return t^n^r}}function Gr(e,t){return e<<t|e>>>32-t}function Kr(e){var t=[1518500249,1859775393,2400959708,3395469782],n=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof e==`string`){var r=unescape(encodeURIComponent(e));e=[];for(var i=0;i<r.length;++i)e.push(r.charCodeAt(i))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);for(var a=e.length/4+2,o=Math.ceil(a/16),s=Array(o),c=0;c<o;++c){for(var l=new Uint32Array(16),u=0;u<16;++u)l[u]=e[c*64+u*4]<<24|e[c*64+u*4+1]<<16|e[c*64+u*4+2]<<8|e[c*64+u*4+3];s[c]=l}s[o-1][14]=(e.length-1)*8/2**32,s[o-1][14]=Math.floor(s[o-1][14]),s[o-1][15]=(e.length-1)*8&4294967295;for(var d=0;d<o;++d){for(var f=new Uint32Array(80),p=0;p<16;++p)f[p]=s[d][p];for(var m=16;m<80;++m)f[m]=Gr(f[m-3]^f[m-8]^f[m-14]^f[m-16],1);for(var h=n[0],g=n[1],_=n[2],v=n[3],y=n[4],ee=0;ee<80;++ee){var te=Math.floor(ee/20),ne=Gr(h,5)+Wr(te,g,_,v)+y+t[te]+f[ee]>>>0;y=v,v=_,_=Gr(g,30)>>>0,g=h,h=ne}n[0]=n[0]+h>>>0,n[1]=n[1]+g>>>0,n[2]=n[2]+_>>>0,n[3]=n[3]+v>>>0,n[4]=n[4]+y>>>0}return[n[0]>>24&255,n[0]>>16&255,n[0]>>8&255,n[0]&255,n[1]>>24&255,n[1]>>16&255,n[1]>>8&255,n[1]&255,n[2]>>24&255,n[2]>>16&255,n[2]>>8&255,n[2]&255,n[3]>>24&255,n[3]>>16&255,n[3]>>8&255,n[3]&255,n[4]>>24&255,n[4]>>16&255,n[4]>>8&255,n[4]&255]}var qr=e((()=>{})),Jr,Yr=e((()=>{Er(),qr(),Jr=Cr(`v5`,80,Kr)})),Xr,Zr=e((()=>{Xr=`00000000-0000-0000-0000-000000000000`}));function Qr(e){if(!cr(e))throw TypeError(`Invalid UUID`);return parseInt(e.substr(14,1),16)}var $r=e((()=>{lr()})),ei=n({NIL:()=>Xr,parse:()=>br,stringify:()=>ur,v1:()=>mr,v3:()=>Br,v4:()=>Hr,v5:()=>Jr,validate:()=>cr,version:()=>Qr}),ti=e((()=>{yr(),Vr(),Ur(),Yr(),Zr(),$r(),lr(),pr(),xr()})),ni=i(((e,n)=>{var r=(ti(),t(ei)).v4;n.exports=function(e,t,n,i){if(typeof e!=`string`)throw TypeError(e+` must be a string`);i||={};let a=typeof i.version==`number`?i.version:2;if(a!==1&&a!==2)throw TypeError(a+` must be 1 or 2`);let o={method:e};if(a===2&&(o.jsonrpc=`2.0`),t){if(typeof t!=`object`&&!Array.isArray(t))throw TypeError(t+` must be an object, array or omitted`);o.params=t}return n===void 0?o.id=(typeof i.generator==`function`?i.generator:function(){return r()})(o,i):a===2&&n===null?i.notificationIdNull&&(o.id=null):o.id=n,o}})),ri=i(((e,n)=>{var r=(ti(),t(ei)).v4,i=ni(),a=function(e,t){if(!(this instanceof a))return new a(e,t);t||={},this.options={reviver:t.reviver===void 0?null:t.reviver,replacer:t.replacer===void 0?null:t.replacer,generator:t.generator===void 0?function(){return r()}:t.generator,version:t.version===void 0?2:t.version,notificationIdNull:typeof t.notificationIdNull==`boolean`&&t.notificationIdNull},this.callServer=e};n.exports=a,a.prototype.request=function(e,t,n,r){let a=this,o=null,s=Array.isArray(e)&&typeof t==`function`;if(this.options.version===1&&s)throw TypeError(`JSON-RPC 1.0 does not support batching`);if(s||!s&&e&&typeof e==`object`&&typeof t==`function`)r=t,o=e;else{typeof n==`function`&&(r=n,n=void 0);let a=typeof r==`function`;try{o=i(e,t,n,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(e){if(a)return r(e);throw e}if(!a)return o}let c;try{c=JSON.stringify(o,this.options.replacer)}catch(e){return r(e)}return this.callServer(c,function(e,t){a._parseResponse(e,t,r)}),o},a.prototype._parseResponse=function(e,t,n){if(e){n(e);return}if(!t)return n();let r;try{r=JSON.parse(t,this.options.reviver)}catch(e){return n(e)}if(n.length===3){if(Array.isArray(r)){let e=function(e){return e.error!==void 0};return n(null,r.filter(e),r.filter(function(t){return!e(t)}))}return n(null,r.error,r.result)}n(null,r)}}));function ii(e,t){return new ai(e,t)}var ai,oi,si,ci=e((()=>{v(),pt(),ai=class extends dt.default{socket;constructor(e,t,n){super(),this.socket=new window.WebSocket(e,n),this.socket.onopen=()=>this.emit(`open`),this.socket.onmessage=e=>this.emit(`message`,e.data),this.socket.onerror=e=>this.emit(`error`,e),this.socket.onclose=e=>{this.emit(`close`,e.code,e.reason)}}send(e,t,n){let r=n||t;try{this.socket.send(e),r()}catch(e){r(e)}}close(e,t){this.socket.close(e,t)}addEventListener(e,t,n){this.socket.addEventListener(e,t,n)}},oi=class{encode(e){return JSON.stringify(e)}decode(e){return JSON.parse(e)}},si=class extends dt.default{address;rpc_id;queue;options;autoconnect;ready;reconnect;reconnect_timer_id;reconnect_interval;max_reconnects;rest_options;current_reconnects;generate_request_id;socket;webSocketFactory;dataPack;constructor(e,t=`ws://localhost:8080`,{autoconnect:n=!0,reconnect:r=!0,reconnect_interval:i=1e3,max_reconnects:a=5,...o}={},s,c){super(),this.webSocketFactory=e,this.queue={},this.rpc_id=0,this.address=t,this.autoconnect=n,this.ready=!1,this.reconnect=r,this.reconnect_timer_id=void 0,this.reconnect_interval=i,this.max_reconnects=a,this.rest_options=o,this.current_reconnects=0,this.generate_request_id=s||(()=>typeof this.rpc_id==`number`?++this.rpc_id:Number(this.rpc_id)+1),this.dataPack=c||new oi,this.autoconnect&&this._connect(this.address,{autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects,...this.rest_options})}connect(){this.socket||this._connect(this.address,{autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects,...this.rest_options})}call(e,t,n,r){return!r&&typeof n==`object`&&(r=n,n=null),new Promise((i,a)=>{if(!this.ready)return a(Error(`socket not ready`));let o=this.generate_request_id(e,t),s={jsonrpc:`2.0`,method:e,params:t||void 0,id:o};this.socket.send(this.dataPack.encode(s),r,e=>{if(e)return a(e);this.queue[o]={promise:[i,a]},n&&(this.queue[o].timeout=setTimeout(()=>{delete this.queue[o],a(Error(`reply timeout`))},n))})})}async login(e){let t=await this.call(`rpc.login`,e);if(!t)throw Error(`authentication failed`);return t}async listMethods(){return await this.call(`__listMethods`)}notify(e,t){return new Promise((n,r)=>{if(!this.ready)return r(Error(`socket not ready`));let i={jsonrpc:`2.0`,method:e,params:t};this.socket.send(this.dataPack.encode(i),e=>{if(e)return r(e);n()})})}async subscribe(e){typeof e==`string`&&(e=[e]);let t=await this.call(`rpc.on`,e);if(typeof e==`string`&&t[e]!==`ok`)throw Error(`Failed subscribing to an event '`+e+`' with: `+t[e]);return t}async unsubscribe(e){typeof e==`string`&&(e=[e]);let t=await this.call(`rpc.off`,e);if(typeof e==`string`&&t[e]!==`ok`)throw Error(`Failed unsubscribing from an event with: `+t);return t}close(e,t){this.socket.close(e||1e3,t)}setAutoReconnect(e){this.reconnect=e}setReconnectInterval(e){this.reconnect_interval=e}setMaxReconnects(e){this.max_reconnects=e}_connect(e,t){clearTimeout(this.reconnect_timer_id),this.socket=this.webSocketFactory(e,t),this.socket.addEventListener(`open`,()=>{this.ready=!0,this.emit(`open`),this.current_reconnects=0}),this.socket.addEventListener(`message`,({data:e})=>{e instanceof ArrayBuffer&&(e=_.from(e).toString());try{e=this.dataPack.decode(e)}catch{return}if(e.notification&&this.listeners(e.notification).length){if(!Object.keys(e.params).length)return this.emit(e.notification);let t=[e.notification];if(e.params.constructor===Object)t.push(e.params);else for(let n=0;n<e.params.length;n++)t.push(e.params[n]);return Promise.resolve().then(()=>{this.emit.apply(this,t)})}if(!this.queue[e.id])return e.method?Promise.resolve().then(()=>{this.emit(e.method,e?.params)}):void 0;`error`in e==`result`in e&&this.queue[e.id].promise[1](Error(`Server response malformed. Response must include either "result" or "error", but not both.`)),this.queue[e.id].timeout&&clearTimeout(this.queue[e.id].timeout),e.error?this.queue[e.id].promise[1](e.error):this.queue[e.id].promise[0](e.result),delete this.queue[e.id]}),this.socket.addEventListener(`error`,e=>this.emit(`error`,e)),this.socket.addEventListener(`close`,({code:n,reason:r})=>{this.ready&&setTimeout(()=>this.emit(`close`,n,r),0),this.ready=!1,this.socket=void 0,n!==1e3&&(this.current_reconnects++,this.reconnect&&(this.max_reconnects>this.current_reconnects||this.max_reconnects===0)&&(this.reconnect_timer_id=setTimeout(()=>this._connect(e,t),this.reconnect_interval)))})}}}));function li(e){try{return ne.ExtendedPoint.fromHex(e),!0}catch{return!1}}function ui(e){return e._bn!==void 0}function di(e,t){let n=e=>{if(e.span>=0)return e.span;if(typeof e.alloc==`function`)return e.alloc(t[e.property]);if(`count`in e&&`elementLayout`in e){let r=t[e.property];if(Array.isArray(r))return r.length*n(e.elementLayout)}else if(`fields`in e)return di({layout:e},t[e.property]);return 0},r=0;return e.layout.fields.forEach(e=>{r+=n(e)}),r}function fi(e){let t=0,n=0;for(;;){let r=e.shift();if(t|=(r&127)<<n*7,n+=1,!(r&128))break}return t}function pi(e,t){let n=t;for(;;){let t=n&127;if(n>>=7,n==0){e.push(t);break}t|=128,e.push(t)}}function mi(e,t){if(!e)throw Error(t||`Assertion failed`)}function hi(e){if(e.length===0)throw Error(ca);return e.shift()}function gi(e,...t){let[n]=t;if(t.length===2?n+(t[1]??0)>e.length:n>=e.length)throw Error(ca);return e.splice(...t)}async function _i(e,t,n,r){let i=r&&{skipPreflight:r.skipPreflight,preflightCommitment:r.preflightCommitment||r.commitment,maxRetries:r.maxRetries,minContextSlot:r.minContextSlot},a=await e.sendTransaction(t,n,i),o;if(t.recentBlockhash!=null&&t.lastValidBlockHeight!=null)o=(await e.confirmTransaction({abortSignal:r?.abortSignal,signature:a,blockhash:t.recentBlockhash,lastValidBlockHeight:t.lastValidBlockHeight},r&&r.commitment)).value;else if(t.minNonceContextSlot!=null&&t.nonceInfo!=null){let{nonceInstruction:n}=t.nonceInfo,i=n.keys[0].pubkey;o=(await e.confirmTransaction({abortSignal:r?.abortSignal,minContextSlot:t.minNonceContextSlot,nonceAccountPubkey:i,nonceValue:t.nonceInfo.nonce,signature:a},r&&r.commitment)).value}else r?.abortSignal,o=(await e.confirmTransaction(a,r&&r.commitment)).value;if(o.err)throw a==null?Error(`Transaction ${a} failed (${JSON.stringify(o)})`):new Sa({action:`send`,signature:a,transactionMessage:`Status: (${JSON.stringify(o)})`});return a}function vi(e){return new Promise(t=>setTimeout(t,e))}function B(e,t){let n=e.layout.span>=0?e.layout.span:di(e,t),r=_.alloc(n),i=Object.assign({instruction:e.index},t);return e.layout.encode(i,r),r}function yi(e){let t=(0,Bi.blob)(8,e),n=t.decode.bind(t),r=t.encode.bind(t),i=t,a=On();return i.decode=(e,t)=>{let r=n(e,t);return a.decode(r)},i.encode=(e,t,n)=>{let i=a.encode(e);return r(i,t,n)},i}function bi(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}function xi(){if(Ma)return ja;Ma=1;var e=Object.prototype.toString,t=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};function n(r,i){var a,o,s,c,l,u,d;if(r===!0)return`true`;if(r===!1)return`false`;switch(typeof r){case`object`:if(r===null)return null;if(r.toJSON&&typeof r.toJSON==`function`)return n(r.toJSON(),i);if(d=e.call(r),d===`[object Array]`){for(s=`[`,o=r.length-1,a=0;a<o;a++)s+=n(r[a],!0)+`,`;return o>-1&&(s+=n(r[a],!0)),s+`]`}if(d===`[object Object]`){for(c=t(r).sort(),o=c.length,s=``,a=0;a<o;)l=c[a],u=n(r[l],!1),u!==void 0&&(s&&(s+=`,`),s+=JSON.stringify(l)+`:`+u),a++;return`{`+s+`}`}return JSON.stringify(r);case`function`:case`undefined`:return i?null:void 0;case`string`:return JSON.stringify(r);default:return isFinite(r)?r:null}}return ja=function(e){var t=n(e,!1);if(t!==void 0)return``+t},ja}function Si(e){let t=0;for(;e>1;)e/=2,t++;return t}function Ci(e){return e===0?1:(e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,e|=e>>32,e+1)}function wi(e,t){let n;try{n=e.layout.decode(t)}catch(e){throw Error(`invalid instruction; `+e)}if(n.typeIndex!==e.index)throw Error(`invalid account data; account type mismatch ${n.typeIndex} != ${e.index}`);return n}function Ti(e){let t=e.match(Va);if(t==null)throw TypeError(`Failed to validate endpoint URL \`${e}\``);let[n,r,i,a]=t,o=e.startsWith(`https:`)?`wss:`:`ws:`,s=i==null?null:parseInt(i.slice(1),10);return`${o}//${r}${s==null?``:`:${s+1}`}${a}`}function Ei(e){if(/^https?:/.test(e)===!1)throw TypeError("Endpoint URL must start with `http:` or `https:`.");return e}function Di(e){let t,n;if(typeof e==`string`)t=e;else if(e){let{commitment:r,...i}=e;t=r,n=i}return{commitment:t,config:n}}function Oi(e){return e.map(e=>`memcmp`in e?{...e,memcmp:{...e.memcmp,encoding:e.memcmp.encoding??`base58`}}:e)}function ki(e){return Xn([z({jsonrpc:Kn(`2.0`),id:R(),result:e}),z({jsonrpc:Kn(`2.0`),id:R(),error:z({code:Zn(),message:R(),data:L(Un())})})])}function V(e){return Qn(ki(e),Ka,t=>`error`in t?t:{...t,result:N(t.result,e)})}function Ai(e){return V(z({context:z({slot:I()}),value:e}))}function ji(e){return z({context:z({slot:I()}),value:e})}function Mi(e,t){return e===0?new ua({header:t.header,staticAccountKeys:t.accountKeys.map(e=>new W(e)),recentBlockhash:t.recentBlockhash,compiledInstructions:t.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:Ri.default.decode(e.data)})),addressTableLookups:t.addressTableLookups}):new la(t)}function Ni(e,t,n,r,i,a){let o=n||Ia,s,c;return r&&(c=async(e,t)=>{let n=await new Promise((n,i)=>{try{r(e,t,(e,t)=>n([e,t]))}catch(e){i(e)}});return await o(...n)}),new Vi.default(async(n,r)=>{let a={method:`POST`,body:n,agent:s,headers:Object.assign({"Content-Type":`application/json`},t||{},Os)};try{let t=5,n,s=500;for(;n=c?await c(e,a):await o(e,a),!(n.status!==429||i===!0||(--t,t===0));)await vi(s),s*=2;let l=await n.text();n.ok?r(null,l):r(Error(`${n.status} ${n.statusText}: ${l}`))}catch(e){e instanceof Error&&r(e)}},{})}function Pi(e){return(t,n)=>new Promise((r,i)=>{e.request(t,n,(e,t)=>{if(e){i(e);return}r(t)})})}function Fi(e){return t=>new Promise((n,r)=>{t.length===0&&n([]);let i=t.map(t=>e.request(t.methodName,t.args));e.request(i,(e,t)=>{if(e){r(e);return}n(t)})})}function Ii(e,t){let n=t===!1?`http`:`https`;if(!e)return ec[n].devnet;let r=ec[n][e];if(!r)throw Error(`Unknown ${n} cluster: ${e}`);return r}var Li,Ri,zi,H,Bi,Vi,Hi,Ui,Wi,Gi,U,Ki,qi,Ji,Yi,W,Xi,Zi,Qi,$i,ea,G,ta,na,ra,ia,aa,oa,sa,ca,la,ua,da,fa,pa,ma,ha,ga,_a,va,ya,ba,xa,Sa,K,Ca,wa,Ta,Ea,Da,Oa,ka,Aa,ja,Ma,Na,Pa,Fa,Ia,La,Ra,za,Ba,Va,Ha,Ua,Wa,Ga,Ka,qa,Ja,Ya,Xa,Za,Qa,$a,eo,to,no,ro,io,ao,oo,so,co,lo,uo,fo,po,mo,ho,go,_o,vo,yo,bo,xo,So,Co,wo,To,Eo,Do,Oo,ko,Ao,jo,Mo,No,Po,Fo,Io,Lo,Ro,zo,Bo,Vo,Ho,Uo,Wo,Go,Ko,qo,Jo,Yo,Xo,Zo,Qo,$o,es,ts,ns,rs,is,as,os,ss,cs,ls,us,ds,fs,ps,ms,hs,gs,_s,vs,ys,bs,xs,Ss,Cs,ws,Ts,Es,Ds,Os,ks,As,js,Ms,Ns,Ps,Fs,Is,Ls,Rs,zs,Bs,Vs,Hs,Us,Ws,Gs,Ks,qs,Js,Ys,Xs,Zs,Qs,$s,ec,tc=e((()=>{v(),te(),Li=r(b()),Ri=r(S()),m(),zi=Qt(),H=r($t()),Bi=r($t()),kn(),tr(),Vi=r(ri()),ci(),g(),w(),ne.utils.randomPrivateKey,Hi=()=>{let e=ne.utils.randomPrivateKey(),t=Ui(e),n=new Uint8Array(64);return n.set(e),n.set(t,32),{publicKey:t,secretKey:n}},Ui=ne.getPublicKey,Wi=(e,t)=>ne.sign(e,t.slice(0,32)),Gi=ne.verify,U=e=>_.isBuffer(e)?e:e instanceof Uint8Array?_.from(e.buffer,e.byteOffset,e.byteLength):_.from(e),Ki=class{constructor(e){Object.assign(this,e)}encode(){return _.from((0,zi.serialize)(qi,this))}static decode(e){return(0,zi.deserialize)(qi,this,e)}static decodeUnchecked(e){return(0,zi.deserializeUnchecked)(qi,this,e)}},qi=new Map,Yi=1,W=class e extends Ki{constructor(e){if(super({}),this._bn=void 0,ui(e))this._bn=e._bn;else{if(typeof e==`string`){let t=Ri.default.decode(e);if(t.length!=32)throw Error(`Invalid public key input`);this._bn=new Li.default(t)}else this._bn=new Li.default(e);if(this._bn.byteLength()>32)throw Error(`Invalid public key input`)}}static unique(){let t=new e(Yi);return Yi+=1,new e(t.toBuffer())}equals(e){return this._bn.eq(e._bn)}toBase58(){return Ri.default.encode(this.toBytes())}toJSON(){return this.toBase58()}toBytes(){let e=this.toBuffer();return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}toBuffer(){let e=this._bn.toArrayLike(_);if(e.length===32)return e;let t=_.alloc(32);return e.copy(t,32-e.length),t}get[Symbol.toStringTag](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(t,n,r){let i=_.concat([t.toBuffer(),_.from(n),r.toBuffer()]),a=p(i);return new e(a)}static createProgramAddressSync(t,n){let r=_.alloc(0);t.forEach(function(e){if(e.length>32)throw TypeError(`Max seed length exceeded`);r=_.concat([r,U(e)])}),r=_.concat([r,n.toBuffer(),_.from(`ProgramDerivedAddress`)]);let i=p(r);if(li(i))throw Error(`Invalid seeds, address must fall off the curve`);return new e(i)}static async createProgramAddress(e,t){return this.createProgramAddressSync(e,t)}static findProgramAddressSync(e,t){let n=255,r;for(;n!=0;){try{let i=e.concat(_.from([n]));r=this.createProgramAddressSync(i,t)}catch(e){if(e instanceof TypeError)throw e;n--;continue}return[r,n]}throw Error(`Unable to find a viable program address nonce`)}static async findProgramAddress(e,t){return this.findProgramAddressSync(e,t)}static isOnCurve(t){return li(new e(t).toBytes())}},Ji=W,W.default=new Ji(`11111111111111111111111111111111`),qi.set(W,{kind:`struct`,fields:[[`_bn`,`u256`]]}),new W(`BPFLoader1111111111111111111111111111111111`),Xi=1232,Zi=class extends Error{constructor(e){super(`Signature ${e} has expired: block height exceeded.`),this.signature=void 0,this.signature=e}},Object.defineProperty(Zi.prototype,"name",{value:`TransactionExpiredBlockheightExceededError`}),Qi=class extends Error{constructor(e,t){super(`Transaction was not confirmed in ${t.toFixed(2)} seconds. It is unknown if it succeeded or failed. Check signature ${e} using the Solana Explorer or CLI tools.`),this.signature=void 0,this.signature=e}},Object.defineProperty(Qi.prototype,"name",{value:`TransactionExpiredTimeoutError`}),$i=class extends Error{constructor(e){super(`Signature ${e} has expired: the nonce is no longer valid.`),this.signature=void 0,this.signature=e}},Object.defineProperty($i.prototype,"name",{value:`TransactionExpiredNonceInvalidError`}),ea=class{constructor(e,t){this.staticAccountKeys=void 0,this.accountKeysFromLookups=void 0,this.staticAccountKeys=e,this.accountKeysFromLookups=t}keySegments(){let e=[this.staticAccountKeys];return this.accountKeysFromLookups&&(e.push(this.accountKeysFromLookups.writable),e.push(this.accountKeysFromLookups.readonly)),e}get(e){for(let t of this.keySegments())if(e<t.length)return t[e];else e-=t.length}get length(){return this.keySegments().flat().length}compileInstructions(e){if(this.length>256)throw Error(`Account index overflow encountered during compilation`);let t=new Map;this.keySegments().flat().forEach((e,n)=>{t.set(e.toBase58(),n)});let n=e=>{let n=t.get(e.toBase58());if(n===void 0)throw Error(`Encountered an unknown instruction account key during compilation`);return n};return e.map(e=>({programIdIndex:n(e.programId),accountKeyIndexes:e.keys.map(e=>n(e.pubkey)),data:e.data}))}},G=(e=`publicKey`)=>H.blob(32,e),ta=(e=`signature`)=>H.blob(64,e),na=(e=`string`)=>{let t=H.struct([H.u32(`length`),H.u32(`lengthPadding`),H.blob(H.offset(H.u32(),-8),`chars`)],e),n=t.decode.bind(t),r=t.encode.bind(t),i=t;return i.decode=(e,t)=>n(e,t).chars.toString(),i.encode=(e,t,n)=>{let i={chars:_.from(e,`utf8`)};return r(i,t,n)},i.alloc=e=>H.u32().span+H.u32().span+_.from(e,`utf8`).length,i},ra=(e=`authorized`)=>H.struct([G(`staker`),G(`withdrawer`)],e),ia=(e=`lockup`)=>H.struct([H.ns64(`unixTimestamp`),H.ns64(`epoch`),G(`custodian`)],e),aa=(e=`voteInit`)=>H.struct([G(`nodePubkey`),G(`authorizedVoter`),G(`authorizedWithdrawer`),H.u8(`commission`)],e),oa=(e=`voteAuthorizeWithSeedArgs`)=>H.struct([H.u32(`voteAuthorizationType`),G(`currentAuthorityDerivedKeyOwnerPubkey`),na(`currentAuthorityDerivedKeySeed`),G(`newAuthorized`)],e),sa=class e{constructor(e,t){this.payer=void 0,this.keyMetaMap=void 0,this.payer=e,this.keyMetaMap=t}static compile(t,n){let r=new Map,i=e=>{let t=e.toBase58(),n=r.get(t);return n===void 0&&(n={isSigner:!1,isWritable:!1,isInvoked:!1},r.set(t,n)),n},a=i(n);a.isSigner=!0,a.isWritable=!0;for(let e of t){i(e.programId).isInvoked=!0;for(let t of e.keys){let e=i(t.pubkey);e.isSigner||=t.isSigner,e.isWritable||=t.isWritable}}return new e(n,r)}getMessageComponents(){let e=[...this.keyMetaMap.entries()];mi(e.length<=256,`Max static account keys length exceeded`);let t=e.filter(([,e])=>e.isSigner&&e.isWritable),n=e.filter(([,e])=>e.isSigner&&!e.isWritable),r=e.filter(([,e])=>!e.isSigner&&e.isWritable),i=e.filter(([,e])=>!e.isSigner&&!e.isWritable),a={numRequiredSignatures:t.length+n.length,numReadonlySignedAccounts:n.length,numReadonlyUnsignedAccounts:i.length};{mi(t.length>0,`Expected at least one writable signer key`);let[e]=t[0];mi(e===this.payer.toBase58(),`Expected first writable signer key to be the fee payer`)}return[a,[...t.map(([e])=>new W(e)),...n.map(([e])=>new W(e)),...r.map(([e])=>new W(e)),...i.map(([e])=>new W(e))]]}extractTableLookup(e){let[t,n]=this.drainKeysFoundInLookupTable(e.state.addresses,e=>!e.isSigner&&!e.isInvoked&&e.isWritable),[r,i]=this.drainKeysFoundInLookupTable(e.state.addresses,e=>!e.isSigner&&!e.isInvoked&&!e.isWritable);if(t.length!==0||r.length!==0)return[{accountKey:e.key,writableIndexes:t,readonlyIndexes:r},{writable:n,readonly:i}]}drainKeysFoundInLookupTable(e,t){let n=[],r=[];for(let[i,a]of this.keyMetaMap.entries())if(t(a)){let t=new W(i),a=e.findIndex(e=>e.equals(t));a>=0&&(mi(a<256,`Max lookup table index exceeded`),n.push(a),r.push(t),this.keyMetaMap.delete(i))}return[n,r]}},ca=`Reached end of buffer unexpectedly`,la=class e{constructor(e){this.header=void 0,this.accountKeys=void 0,this.recentBlockhash=void 0,this.instructions=void 0,this.indexToProgramIds=new Map,this.header=e.header,this.accountKeys=e.accountKeys.map(e=>new W(e)),this.recentBlockhash=e.recentBlockhash,this.instructions=e.instructions,this.instructions.forEach(e=>this.indexToProgramIds.set(e.programIdIndex,this.accountKeys[e.programIdIndex]))}get version(){return`legacy`}get staticAccountKeys(){return this.accountKeys}get compiledInstructions(){return this.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:Ri.default.decode(e.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new ea(this.staticAccountKeys)}static compile(t){let[n,r]=sa.compile(t.instructions,t.payerKey).getMessageComponents(),i=new ea(r).compileInstructions(t.instructions).map(e=>({programIdIndex:e.programIdIndex,accounts:e.accountKeyIndexes,data:Ri.default.encode(e.data)}));return new e({header:n,accountKeys:r,recentBlockhash:t.recentBlockhash,instructions:i})}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){let t=this.header.numRequiredSignatures;return e>=this.header.numRequiredSignatures?e-t<this.accountKeys.length-t-this.header.numReadonlyUnsignedAccounts:e<t-this.header.numReadonlySignedAccounts}isProgramId(e){return this.indexToProgramIds.has(e)}programIds(){return[...this.indexToProgramIds.values()]}nonProgramIds(){return this.accountKeys.filter((e,t)=>!this.isProgramId(t))}serialize(){let e=this.accountKeys.length,t=[];pi(t,e);let n=this.instructions.map(e=>{let{accounts:t,programIdIndex:n}=e,r=Array.from(Ri.default.decode(e.data)),i=[];pi(i,t.length);let a=[];return pi(a,r.length),{programIdIndex:n,keyIndicesCount:_.from(i),keyIndices:t,dataLength:_.from(a),data:r}}),r=[];pi(r,n.length);let i=_.alloc(Xi);_.from(r).copy(i);let a=r.length;n.forEach(e=>{let t=H.struct([H.u8(`programIdIndex`),H.blob(e.keyIndicesCount.length,`keyIndicesCount`),H.seq(H.u8(`keyIndex`),e.keyIndices.length,`keyIndices`),H.blob(e.dataLength.length,`dataLength`),H.seq(H.u8(`userdatum`),e.data.length,`data`)]).encode(e,i,a);a+=t}),i=i.slice(0,a);let o=H.struct([H.blob(1,`numRequiredSignatures`),H.blob(1,`numReadonlySignedAccounts`),H.blob(1,`numReadonlyUnsignedAccounts`),H.blob(t.length,`keyCount`),H.seq(G(`key`),e,`keys`),G(`recentBlockhash`)]),s={numRequiredSignatures:_.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:_.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:_.from([this.header.numReadonlyUnsignedAccounts]),keyCount:_.from(t),keys:this.accountKeys.map(e=>U(e.toBytes())),recentBlockhash:Ri.default.decode(this.recentBlockhash)},c=_.alloc(2048),l=o.encode(s,c);return i.copy(c,l),c.slice(0,l+i.length)}static from(t){let n=[...t],r=hi(n);if(r!==(r&127))throw Error(`Versioned messages must be deserialized with VersionedMessage.deserialize()`);let i=hi(n),a=hi(n),o=fi(n),s=[];for(let e=0;e<o;e++){let e=gi(n,0,32);s.push(new W(_.from(e)))}let c=gi(n,0,32),l=fi(n),u=[];for(let e=0;e<l;e++){let e=hi(n),t=gi(n,0,fi(n)),r=gi(n,0,fi(n)),i=Ri.default.encode(_.from(r));u.push({programIdIndex:e,accounts:t,data:i})}let d={header:{numRequiredSignatures:r,numReadonlySignedAccounts:i,numReadonlyUnsignedAccounts:a},recentBlockhash:Ri.default.encode(_.from(c)),accountKeys:s,instructions:u};return new e(d)}},ua=class e{constructor(e){this.header=void 0,this.staticAccountKeys=void 0,this.recentBlockhash=void 0,this.compiledInstructions=void 0,this.addressTableLookups=void 0,this.header=e.header,this.staticAccountKeys=e.staticAccountKeys,this.recentBlockhash=e.recentBlockhash,this.compiledInstructions=e.compiledInstructions,this.addressTableLookups=e.addressTableLookups}get version(){return 0}get numAccountKeysFromLookups(){let e=0;for(let t of this.addressTableLookups)e+=t.readonlyIndexes.length+t.writableIndexes.length;return e}getAccountKeys(e){let t;if(e&&`accountKeysFromLookups`in e&&e.accountKeysFromLookups){if(this.numAccountKeysFromLookups!=e.accountKeysFromLookups.writable.length+e.accountKeysFromLookups.readonly.length)throw Error(`Failed to get account keys because of a mismatch in the number of account keys from lookups`);t=e.accountKeysFromLookups}else if(e&&`addressLookupTableAccounts`in e&&e.addressLookupTableAccounts)t=this.resolveAddressTableLookups(e.addressLookupTableAccounts);else if(this.addressTableLookups.length>0)throw Error(`Failed to get account keys because address table lookups were not resolved`);return new ea(this.staticAccountKeys,t)}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){let t=this.header.numRequiredSignatures,n=this.staticAccountKeys.length;return e>=n?e-n<this.addressTableLookups.reduce((e,t)=>e+t.writableIndexes.length,0):e>=this.header.numRequiredSignatures?e-t<n-t-this.header.numReadonlyUnsignedAccounts:e<t-this.header.numReadonlySignedAccounts}resolveAddressTableLookups(e){let t={writable:[],readonly:[]};for(let n of this.addressTableLookups){let r=e.find(e=>e.key.equals(n.accountKey));if(!r)throw Error(`Failed to find address lookup table account for table key ${n.accountKey.toBase58()}`);for(let e of n.writableIndexes)if(e<r.state.addresses.length)t.writable.push(r.state.addresses[e]);else throw Error(`Failed to find address for index ${e} in address lookup table ${n.accountKey.toBase58()}`);for(let e of n.readonlyIndexes)if(e<r.state.addresses.length)t.readonly.push(r.state.addresses[e]);else throw Error(`Failed to find address for index ${e} in address lookup table ${n.accountKey.toBase58()}`)}return t}static compile(t){let n=sa.compile(t.instructions,t.payerKey),r=[],i={writable:[],readonly:[]},a=t.addressLookupTableAccounts||[];for(let e of a){let t=n.extractTableLookup(e);if(t!==void 0){let[e,{writable:n,readonly:a}]=t;r.push(e),i.writable.push(...n),i.readonly.push(...a)}}let[o,s]=n.getMessageComponents(),c=new ea(s,i).compileInstructions(t.instructions);return new e({header:o,staticAccountKeys:s,recentBlockhash:t.recentBlockhash,compiledInstructions:c,addressTableLookups:r})}serialize(){let e=[];pi(e,this.staticAccountKeys.length);let t=this.serializeInstructions(),n=[];pi(n,this.compiledInstructions.length);let r=this.serializeAddressTableLookups(),i=[];pi(i,this.addressTableLookups.length);let a=H.struct([H.u8(`prefix`),H.struct([H.u8(`numRequiredSignatures`),H.u8(`numReadonlySignedAccounts`),H.u8(`numReadonlyUnsignedAccounts`)],`header`),H.blob(e.length,`staticAccountKeysLength`),H.seq(G(),this.staticAccountKeys.length,`staticAccountKeys`),G(`recentBlockhash`),H.blob(n.length,`instructionsLength`),H.blob(t.length,`serializedInstructions`),H.blob(i.length,`addressTableLookupsLength`),H.blob(r.length,`serializedAddressTableLookups`)]),o=new Uint8Array(Xi),s=a.encode({prefix:128,header:this.header,staticAccountKeysLength:new Uint8Array(e),staticAccountKeys:this.staticAccountKeys.map(e=>e.toBytes()),recentBlockhash:Ri.default.decode(this.recentBlockhash),instructionsLength:new Uint8Array(n),serializedInstructions:t,addressTableLookupsLength:new Uint8Array(i),serializedAddressTableLookups:r},o);return o.slice(0,s)}serializeInstructions(){let e=0,t=new Uint8Array(Xi);for(let n of this.compiledInstructions){let r=[];pi(r,n.accountKeyIndexes.length);let i=[];pi(i,n.data.length);let a=H.struct([H.u8(`programIdIndex`),H.blob(r.length,`encodedAccountKeyIndexesLength`),H.seq(H.u8(),n.accountKeyIndexes.length,`accountKeyIndexes`),H.blob(i.length,`encodedDataLength`),H.blob(n.data.length,`data`)]);e+=a.encode({programIdIndex:n.programIdIndex,encodedAccountKeyIndexesLength:new Uint8Array(r),accountKeyIndexes:n.accountKeyIndexes,encodedDataLength:new Uint8Array(i),data:n.data},t,e)}return t.slice(0,e)}serializeAddressTableLookups(){let e=0,t=new Uint8Array(Xi);for(let n of this.addressTableLookups){let r=[];pi(r,n.writableIndexes.length);let i=[];pi(i,n.readonlyIndexes.length);let a=H.struct([G(`accountKey`),H.blob(r.length,`encodedWritableIndexesLength`),H.seq(H.u8(),n.writableIndexes.length,`writableIndexes`),H.blob(i.length,`encodedReadonlyIndexesLength`),H.seq(H.u8(),n.readonlyIndexes.length,`readonlyIndexes`)]);e+=a.encode({accountKey:n.accountKey.toBytes(),encodedWritableIndexesLength:new Uint8Array(r),writableIndexes:n.writableIndexes,encodedReadonlyIndexesLength:new Uint8Array(i),readonlyIndexes:n.readonlyIndexes},t,e)}return t.slice(0,e)}static deserialize(t){let n=[...t],r=hi(n),i=r&127;mi(r!==i,`Expected versioned message but received legacy message`);let a=i;mi(a===0,`Expected versioned message with version 0 but found version ${a}`);let o={numRequiredSignatures:hi(n),numReadonlySignedAccounts:hi(n),numReadonlyUnsignedAccounts:hi(n)},s=[],c=fi(n);for(let e=0;e<c;e++)s.push(new W(gi(n,0,32)));let l=Ri.default.encode(gi(n,0,32)),u=fi(n),d=[];for(let e=0;e<u;e++){let e=hi(n),t=gi(n,0,fi(n)),r=fi(n),i=new Uint8Array(gi(n,0,r));d.push({programIdIndex:e,accountKeyIndexes:t,data:i})}let f=fi(n),p=[];for(let e=0;e<f;e++){let e=new W(gi(n,0,32)),t=gi(n,0,fi(n)),r=gi(n,0,fi(n));p.push({accountKey:e,writableIndexes:t,readonlyIndexes:r})}return new e({header:o,staticAccountKeys:s,recentBlockhash:l,compiledInstructions:d,addressTableLookups:p})}},da={deserializeMessageVersion(e){let t=e[0],n=t&127;return n===t?`legacy`:n},deserialize:e=>{let t=da.deserializeMessageVersion(e);if(t===`legacy`)return la.from(e);if(t===0)return ua.deserialize(e);throw Error(`Transaction message version ${t} deserialization is not supported`)}},fa=function(e){return e[e.BLOCKHEIGHT_EXCEEDED=0]=`BLOCKHEIGHT_EXCEEDED`,e[e.PROCESSED=1]=`PROCESSED`,e[e.TIMED_OUT=2]=`TIMED_OUT`,e[e.NONCE_INVALID=3]=`NONCE_INVALID`,e}({}),pa=_.alloc(64).fill(0),ma=class{constructor(e){this.keys=void 0,this.programId=void 0,this.data=_.alloc(0),this.programId=e.programId,this.keys=e.keys,e.data&&(this.data=e.data)}toJSON(){return{keys:this.keys.map(({pubkey:e,isSigner:t,isWritable:n})=>({pubkey:e.toJSON(),isSigner:t,isWritable:n})),programId:this.programId.toJSON(),data:[...this.data]}}},ha=class e{get signature(){return this.signatures.length>0?this.signatures[0].signature:null}constructor(e){if(this.signatures=[],this.feePayer=void 0,this.instructions=[],this.recentBlockhash=void 0,this.lastValidBlockHeight=void 0,this.nonceInfo=void 0,this.minNonceContextSlot=void 0,this._message=void 0,this._json=void 0,e){if(e.feePayer&&(this.feePayer=e.feePayer),e.signatures&&(this.signatures=e.signatures),Object.prototype.hasOwnProperty.call(e,`nonceInfo`)){let{minContextSlot:t,nonceInfo:n}=e;this.minNonceContextSlot=t,this.nonceInfo=n}else if(Object.prototype.hasOwnProperty.call(e,`lastValidBlockHeight`)){let{blockhash:t,lastValidBlockHeight:n}=e;this.recentBlockhash=t,this.lastValidBlockHeight=n}else{let{recentBlockhash:t,nonceInfo:n}=e;n&&(this.nonceInfo=n),this.recentBlockhash=t}}}toJSON(){return{recentBlockhash:this.recentBlockhash||null,feePayer:this.feePayer?this.feePayer.toJSON():null,nonceInfo:this.nonceInfo?{nonce:this.nonceInfo.nonce,nonceInstruction:this.nonceInfo.nonceInstruction.toJSON()}:null,instructions:this.instructions.map(e=>e.toJSON()),signers:this.signatures.map(({publicKey:e})=>e.toJSON())}}add(...e){if(e.length===0)throw Error(`No instructions`);return e.forEach(e=>{`instructions`in e?this.instructions=this.instructions.concat(e.instructions):`data`in e&&`programId`in e&&`keys`in e?this.instructions.push(e):this.instructions.push(new ma(e))}),this}compileMessage(){if(this._message&&JSON.stringify(this.toJSON())===JSON.stringify(this._json))return this._message;let e,t;if(this.nonceInfo?(e=this.nonceInfo.nonce,t=this.instructions[0]==this.nonceInfo.nonceInstruction?this.instructions:[this.nonceInfo.nonceInstruction,...this.instructions]):(e=this.recentBlockhash,t=this.instructions),!e)throw Error(`Transaction recentBlockhash required`);t.length;let n;if(this.feePayer)n=this.feePayer;else if(this.signatures.length>0&&this.signatures[0].publicKey)n=this.signatures[0].publicKey;else throw Error(`Transaction fee payer required`);for(let e=0;e<t.length;e++)if(t[e].programId===void 0)throw Error(`Transaction instruction index ${e} has undefined program id`);let r=[],i=[];t.forEach(e=>{e.keys.forEach(e=>{i.push({...e})});let t=e.programId.toString();r.includes(t)||r.push(t)}),r.forEach(e=>{i.push({pubkey:new W(e),isSigner:!1,isWritable:!1})});let a=[];i.forEach(e=>{let t=e.pubkey.toString(),n=a.findIndex(e=>e.pubkey.toString()===t);n>-1?(a[n].isWritable=a[n].isWritable||e.isWritable,a[n].isSigner=a[n].isSigner||e.isSigner):a.push(e)}),a.sort(function(e,t){return e.isSigner===t.isSigner?e.isWritable===t.isWritable?e.pubkey.toBase58().localeCompare(t.pubkey.toBase58(),`en`,{localeMatcher:`best fit`,usage:`sort`,sensitivity:`variant`,ignorePunctuation:!1,numeric:!1,caseFirst:`lower`}):e.isWritable?-1:1:e.isSigner?-1:1});let o=a.findIndex(e=>e.pubkey.equals(n));if(o>-1){let[e]=a.splice(o,1);e.isSigner=!0,e.isWritable=!0,a.unshift(e)}else a.unshift({pubkey:n,isSigner:!0,isWritable:!0});for(let e of this.signatures){let t=a.findIndex(t=>t.pubkey.equals(e.publicKey));if(t>-1)a[t].isSigner||(a[t].isSigner=!0);else throw Error(`unknown signer: ${e.publicKey.toString()}`)}let s=0,c=0,l=0,u=[],d=[];a.forEach(({pubkey:e,isSigner:t,isWritable:n})=>{t?(u.push(e.toString()),s+=1,n||(c+=1)):(d.push(e.toString()),n||(l+=1))});let f=u.concat(d),p=t.map(e=>{let{data:t,programId:n}=e;return{programIdIndex:f.indexOf(n.toString()),accounts:e.keys.map(e=>f.indexOf(e.pubkey.toString())),data:Ri.default.encode(t)}});return p.forEach(e=>{mi(e.programIdIndex>=0),e.accounts.forEach(e=>mi(e>=0))}),new la({header:{numRequiredSignatures:s,numReadonlySignedAccounts:c,numReadonlyUnsignedAccounts:l},accountKeys:f,recentBlockhash:e,instructions:p})}_compile(){let e=this.compileMessage(),t=e.accountKeys.slice(0,e.header.numRequiredSignatures);return this.signatures.length===t.length&&this.signatures.every((e,n)=>t[n].equals(e.publicKey))||(this.signatures=t.map(e=>({signature:null,publicKey:e}))),e}serializeMessage(){return this._compile().serialize()}async getEstimatedFee(e){return(await e.getFeeForMessage(this.compileMessage())).value}setSigners(...e){if(e.length===0)throw Error(`No signers`);let t=new Set;this.signatures=e.filter(e=>{let n=e.toString();return!t.has(n)&&(t.add(n),!0)}).map(e=>({signature:null,publicKey:e}))}sign(...e){if(e.length===0)throw Error(`No signers`);let t=new Set,n=[];for(let r of e){let e=r.publicKey.toString();t.has(e)||(t.add(e),n.push(r))}this.signatures=n.map(e=>({signature:null,publicKey:e.publicKey}));let r=this._compile();this._partialSign(r,...n)}partialSign(...e){if(e.length===0)throw Error(`No signers`);let t=new Set,n=[];for(let r of e){let e=r.publicKey.toString();t.has(e)||(t.add(e),n.push(r))}let r=this._compile();this._partialSign(r,...n)}_partialSign(e,...t){let n=e.serialize();t.forEach(e=>{let t=Wi(n,e.secretKey);this._addSignature(e.publicKey,U(t))})}addSignature(e,t){this._compile(),this._addSignature(e,t)}_addSignature(e,t){mi(t.length===64);let n=this.signatures.findIndex(t=>e.equals(t.publicKey));if(n<0)throw Error(`unknown signer: ${e.toString()}`);this.signatures[n].signature=_.from(t)}verifySignatures(e=!0){return!this._getMessageSignednessErrors(this.serializeMessage(),e)}_getMessageSignednessErrors(e,t){let n={};for(let{signature:r,publicKey:i}of this.signatures)r===null?t&&(n.missing||=[]).push(i):Gi(r,e,i.toBytes())||(n.invalid||=[]).push(i);return n.invalid||n.missing?n:void 0}serialize(e){let{requireAllSignatures:t,verifySignatures:n}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},e),r=this.serializeMessage();if(n){let e=this._getMessageSignednessErrors(r,t);if(e){let t=`Signature verification failed.`;throw e.invalid&&(t+=`\nInvalid signature for public key${e.invalid.length===1?``:`(s)`} [\`${e.invalid.map(e=>e.toBase58()).join("`, `")}\`].`),e.missing&&(t+=`\nMissing signature for public key${e.missing.length===1?``:`(s)`} [\`${e.missing.map(e=>e.toBase58()).join("`, `")}\`].`),Error(t)}}return this._serialize(r)}_serialize(e){let{signatures:t}=this,n=[];pi(n,t.length);let r=n.length+t.length*64+e.length,i=_.alloc(r);return mi(t.length<256),_.from(n).copy(i,0),t.forEach(({signature:e},t)=>{e!==null&&(mi(e.length===64,`signature has invalid length`),_.from(e).copy(i,n.length+t*64))}),e.copy(i,n.length+t.length*64),mi(i.length<=Xi,`Transaction too large: ${i.length} > ${Xi}`),i}get keys(){return mi(this.instructions.length===1),this.instructions[0].keys.map(e=>e.pubkey)}get programId(){return mi(this.instructions.length===1),this.instructions[0].programId}get data(){return mi(this.instructions.length===1),this.instructions[0].data}static from(t){let n=[...t],r=fi(n),i=[];for(let e=0;e<r;e++){let e=gi(n,0,64);i.push(Ri.default.encode(_.from(e)))}return e.populate(la.from(n),i)}static populate(t,n=[]){let r=new e;return r.recentBlockhash=t.recentBlockhash,t.header.numRequiredSignatures>0&&(r.feePayer=t.accountKeys[0]),n.forEach((e,n)=>{let i={signature:e==Ri.default.encode(pa)?null:Ri.default.decode(e),publicKey:t.accountKeys[n]};r.signatures.push(i)}),t.instructions.forEach(e=>{let n=e.accounts.map(e=>{let n=t.accountKeys[e];return{pubkey:n,isSigner:r.signatures.some(e=>e.publicKey.toString()===n.toString())||t.isAccountSigner(e),isWritable:t.isAccountWritable(e)}});r.instructions.push(new ma({keys:n,programId:t.accountKeys[e.programIdIndex],data:Ri.default.decode(e.data)}))}),r._message=t,r._json=r.toJSON(),r}},ga=class e{get version(){return this.message.version}constructor(e,t){if(this.signatures=void 0,this.message=void 0,t!==void 0)mi(t.length===e.header.numRequiredSignatures,`Expected signatures length to be equal to the number of required signatures`),this.signatures=t;else{let t=[];for(let n=0;n<e.header.numRequiredSignatures;n++)t.push(new Uint8Array(64));this.signatures=t}this.message=e}serialize(){let e=this.message.serialize(),t=[];pi(t,this.signatures.length);let n=H.struct([H.blob(t.length,`encodedSignaturesLength`),H.seq(ta(),this.signatures.length,`signatures`),H.blob(e.length,`serializedMessage`)]),r=new Uint8Array(2048),i=n.encode({encodedSignaturesLength:new Uint8Array(t),signatures:this.signatures,serializedMessage:e},r);return r.slice(0,i)}static deserialize(t){let n=[...t],r=[],i=fi(n);for(let e=0;e<i;e++)r.push(new Uint8Array(gi(n,0,64)));let a=da.deserialize(new Uint8Array(n));return new e(a,r)}sign(e){let t=this.message.serialize(),n=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures);for(let r of e){let e=n.findIndex(e=>e.equals(r.publicKey));mi(e>=0,`Cannot sign with non signer key ${r.publicKey.toBase58()}`),this.signatures[e]=Wi(t,r.secretKey)}}addSignature(e,t){mi(t.byteLength===64,`Signature must be 64 bytes long`);let n=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures).findIndex(t=>t.equals(e));mi(n>=0,`Can not add signature; \`${e.toBase58()}\` is not required to sign this transaction`),this.signatures[n]=t}},_a=1e3/(160/64),va=new W(`SysvarC1ock11111111111111111111111111111111`),new W(`SysvarEpochSchedu1e111111111111111111111111`),new W(`Sysvar1nstructions1111111111111111111111111`),ya=new W(`SysvarRecentB1ockHashes11111111111111111111`),ba=new W(`SysvarRent111111111111111111111111111111111`),new W(`SysvarRewards111111111111111111111111111111`),new W(`SysvarS1otHashes111111111111111111111111111`),new W(`SysvarS1otHistory11111111111111111111111111`),xa=new W(`SysvarStakeHistory1111111111111111111111111`),Sa=class extends Error{constructor({action:e,signature:t,transactionMessage:n,logs:r}){let i=r?`Logs: \n${JSON.stringify(r.slice(-10),null,2)}. `:``,a="\nCatch the `SendTransactionError` and call `getLogs()` on it for full details.",o;switch(e){case`send`:o=`Transaction ${t} resulted in an error. \n${n}. `+i+a;break;case`simulate`:o=`Simulation failed. \nMessage: ${n}. \n`+i+a;break;default:o=`Unknown action '${(e=>e)(e)}'`}super(o),this.signature=void 0,this.transactionMessage=void 0,this.transactionLogs=void 0,this.signature=t,this.transactionMessage=n,this.transactionLogs=r||void 0}get transactionError(){return{message:this.transactionMessage,logs:Array.isArray(this.transactionLogs)?this.transactionLogs:void 0}}get logs(){let e=this.transactionLogs;if(!(typeof e==`object`&&e&&`then`in e))return e}async getLogs(e){return Array.isArray(this.transactionLogs)||(this.transactionLogs=new Promise((t,n)=>{e.getTransaction(this.signature).then(e=>{if(e&&e.meta&&e.meta.logMessages){let n=e.meta.logMessages;this.transactionLogs=n,t(n)}else n(Error(`Log messages not found`))}).catch(n)})),await this.transactionLogs}},K=class extends Error{constructor({code:e,message:t,data:n},r){super(r==null?t:`${r}: ${t}`),this.code=void 0,this.data=void 0,this.code=e,this.data=n,this.name=`SolanaJSONRPCError`}},Ca=H.nu64(`lamportsPerSignature`),wa=H.struct([H.u32(`version`),H.u32(`state`),G(`authorizedPubkey`),G(`nonce`),H.struct([Ca],`feeCalculator`)]),Ta=wa.span,Ea=class e{constructor(e){this.authorizedPubkey=void 0,this.nonce=void 0,this.feeCalculator=void 0,this.authorizedPubkey=e.authorizedPubkey,this.nonce=e.nonce,this.feeCalculator=e.feeCalculator}static fromAccountData(t){let n=wa.decode(U(t),0);return new e({authorizedPubkey:new W(n.authorizedPubkey),nonce:new W(n.nonce).toString(),feeCalculator:n.feeCalculator})}},Da=Object.freeze({Create:{index:0,layout:H.struct([H.u32(`instruction`),H.ns64(`lamports`),H.ns64(`space`),G(`programId`)])},Assign:{index:1,layout:H.struct([H.u32(`instruction`),G(`programId`)])},Transfer:{index:2,layout:H.struct([H.u32(`instruction`),yi(`lamports`)])},CreateWithSeed:{index:3,layout:H.struct([H.u32(`instruction`),G(`base`),na(`seed`),H.ns64(`lamports`),H.ns64(`space`),G(`programId`)])},AdvanceNonceAccount:{index:4,layout:H.struct([H.u32(`instruction`)])},WithdrawNonceAccount:{index:5,layout:H.struct([H.u32(`instruction`),H.ns64(`lamports`)])},InitializeNonceAccount:{index:6,layout:H.struct([H.u32(`instruction`),G(`authorized`)])},AuthorizeNonceAccount:{index:7,layout:H.struct([H.u32(`instruction`),G(`authorized`)])},Allocate:{index:8,layout:H.struct([H.u32(`instruction`),H.ns64(`space`)])},AllocateWithSeed:{index:9,layout:H.struct([H.u32(`instruction`),G(`base`),na(`seed`),H.ns64(`space`),G(`programId`)])},AssignWithSeed:{index:10,layout:H.struct([H.u32(`instruction`),G(`base`),na(`seed`),G(`programId`)])},TransferWithSeed:{index:11,layout:H.struct([H.u32(`instruction`),yi(`lamports`),na(`seed`),G(`programId`)])},UpgradeNonceAccount:{index:12,layout:H.struct([H.u32(`instruction`)])}}),Oa=class e{constructor(){}static createAccount(e){let t=Da.Create,n=B(t,{lamports:e.lamports,space:e.space,programId:U(e.programId.toBuffer())});return new ma({keys:[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.newAccountPubkey,isSigner:!0,isWritable:!0}],programId:this.programId,data:n})}static transfer(e){let t,n;if(`basePubkey`in e){let r=Da.TransferWithSeed;t=B(r,{lamports:BigInt(e.lamports),seed:e.seed,programId:U(e.programId.toBuffer())}),n=[{pubkey:e.fromPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0}]}else{let r=Da.Transfer;t=B(r,{lamports:BigInt(e.lamports)}),n=[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0}]}return new ma({keys:n,programId:this.programId,data:t})}static assign(e){let t,n;if(`basePubkey`in e){let r=Da.AssignWithSeed;t=B(r,{base:U(e.basePubkey.toBuffer()),seed:e.seed,programId:U(e.programId.toBuffer())}),n=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]}else{let r=Da.Assign;t=B(r,{programId:U(e.programId.toBuffer())}),n=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]}return new ma({keys:n,programId:this.programId,data:t})}static createAccountWithSeed(e){let t=Da.CreateWithSeed,n=B(t,{base:U(e.basePubkey.toBuffer()),seed:e.seed,lamports:e.lamports,space:e.space,programId:U(e.programId.toBuffer())}),r=[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.newAccountPubkey,isSigner:!1,isWritable:!0}];return e.basePubkey.equals(e.fromPubkey)||r.push({pubkey:e.basePubkey,isSigner:!0,isWritable:!1}),new ma({keys:r,programId:this.programId,data:n})}static createNonceAccount(t){let n=new ha;`basePubkey`in t&&`seed`in t?n.add(e.createAccountWithSeed({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,basePubkey:t.basePubkey,seed:t.seed,lamports:t.lamports,space:Ta,programId:this.programId})):n.add(e.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,lamports:t.lamports,space:Ta,programId:this.programId}));let r={noncePubkey:t.noncePubkey,authorizedPubkey:t.authorizedPubkey};return n.add(this.nonceInitialize(r)),n}static nonceInitialize(e){let t=Da.InitializeNonceAccount,n=B(t,{authorized:U(e.authorizedPubkey.toBuffer())}),r={keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:ya,isSigner:!1,isWritable:!1},{pubkey:ba,isSigner:!1,isWritable:!1}],programId:this.programId,data:n};return new ma(r)}static nonceAdvance(e){let t=Da.AdvanceNonceAccount,n=B(t),r={keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:ya,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n};return new ma(r)}static nonceWithdraw(e){let t=Da.WithdrawNonceAccount,n=B(t,{lamports:e.lamports});return new ma({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0},{pubkey:ya,isSigner:!1,isWritable:!1},{pubkey:ba,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static nonceAuthorize(e){let t=Da.AuthorizeNonceAccount,n=B(t,{authorized:U(e.newAuthorizedPubkey.toBuffer())});return new ma({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static allocate(e){let t,n;if(`basePubkey`in e){let r=Da.AllocateWithSeed;t=B(r,{base:U(e.basePubkey.toBuffer()),seed:e.seed,space:e.space,programId:U(e.programId.toBuffer())}),n=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]}else{let r=Da.Allocate;t=B(r,{space:e.space}),n=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]}return new ma({keys:n,programId:this.programId,data:t})}},Oa.programId=new W(`11111111111111111111111111111111`),ka=932,Aa=class e{constructor(){}static getMinNumSignatures(t){return 2*(Math.ceil(t/e.chunkSize)+1+1)}static async load(t,n,r,i,a){{let e=await t.getMinimumBalanceForRentExemption(a.length),o=await t.getAccountInfo(r.publicKey,`confirmed`),s=null;if(o!==null){if(o.executable)return!1;o.data.length!==a.length&&(s||=new ha,s.add(Oa.allocate({accountPubkey:r.publicKey,space:a.length}))),o.owner.equals(i)||(s||=new ha,s.add(Oa.assign({accountPubkey:r.publicKey,programId:i}))),o.lamports<e&&(s||=new ha,s.add(Oa.transfer({fromPubkey:n.publicKey,toPubkey:r.publicKey,lamports:e-o.lamports})))}else s=new ha().add(Oa.createAccount({fromPubkey:n.publicKey,newAccountPubkey:r.publicKey,lamports:e>0?e:1,space:a.length,programId:i}));s!==null&&await _i(t,s,[n,r],{commitment:`confirmed`})}let o=H.struct([H.u32(`instruction`),H.u32(`offset`),H.u32(`bytesLength`),H.u32(`bytesLengthPadding`),H.seq(H.u8(`byte`),H.offset(H.u32(),-8),`bytes`)]),s=e.chunkSize,c=0,l=a,u=[];for(;l.length>0;){let e=l.slice(0,s),a=_.alloc(s+16);o.encode({instruction:0,offset:c,bytes:e,bytesLength:0,bytesLengthPadding:0},a);let d=new ha().add({keys:[{pubkey:r.publicKey,isSigner:!0,isWritable:!0}],programId:i,data:a});u.push(_i(t,d,[n,r],{commitment:`confirmed`})),t._rpcEndpoint.includes(`solana.com`)&&await vi(250),c+=s,l=l.slice(s)}await Promise.all(u);{let e=H.struct([H.u32(`instruction`)]),a=_.alloc(e.span);e.encode({instruction:1},a);let o=new ha().add({keys:[{pubkey:r.publicKey,isSigner:!0,isWritable:!0},{pubkey:ba,isSigner:!1,isWritable:!1}],programId:i,data:a}),s=`processed`,c=await t.sendTransaction(o,[n,r],{preflightCommitment:s}),{context:l,value:u}=await t.confirmTransaction({signature:c,lastValidBlockHeight:o.lastValidBlockHeight,blockhash:o.recentBlockhash},s);if(u.err)throw Error(`Transaction ${c} failed (${JSON.stringify(u)})`);for(;;){try{if(await t.getSlot({commitment:s})>l.slot)break}catch{}await new Promise(e=>setTimeout(e,Math.round(_a/2)))}}return!0}},Aa.chunkSize=ka,new W(`BPFLoader2111111111111111111111111111111111`),Na=bi(xi()),Pa=32,Fa=class{constructor(e,t,n,r,i){this.slotsPerEpoch=void 0,this.leaderScheduleSlotOffset=void 0,this.warmup=void 0,this.firstNormalEpoch=void 0,this.firstNormalSlot=void 0,this.slotsPerEpoch=e,this.leaderScheduleSlotOffset=t,this.warmup=n,this.firstNormalEpoch=r,this.firstNormalSlot=i}getEpoch(e){return this.getEpochAndSlotIndex(e)[0]}getEpochAndSlotIndex(e){if(e<this.firstNormalSlot){let t=Si(Ci(e+Pa+1))-Si(Pa)-1;return[t,e-(this.getSlotsInEpoch(t)-Pa)]}{let t=e-this.firstNormalSlot,n=Math.floor(t/this.slotsPerEpoch);return[this.firstNormalEpoch+n,t%this.slotsPerEpoch]}}getFirstSlotInEpoch(e){return e<=this.firstNormalEpoch?(2**e-1)*Pa:(e-this.firstNormalEpoch)*this.slotsPerEpoch+this.firstNormalSlot}getLastSlotInEpoch(e){return this.getFirstSlotInEpoch(e)+this.getSlotsInEpoch(e)-1}getSlotsInEpoch(e){return e<this.firstNormalEpoch?2**(e+Si(Pa)):this.slotsPerEpoch}},Ia=globalThis.fetch,La=class extends si{constructor(e,t,n){super(e=>{let n=ii(e,{autoconnect:!0,max_reconnects:5,reconnect:!0,reconnect_interval:1e3,...t});return`socket`in n?this.underlyingSocket=n.socket:this.underlyingSocket=n,n},e,t,n),this.underlyingSocket=void 0}call(...e){let t=this.underlyingSocket?.readyState;return t===1?super.call(...e):Promise.reject(Error("Tried to call a JSON-RPC method `"+e[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+t+`)`))}notify(...e){let t=this.underlyingSocket?.readyState;return t===1?super.notify(...e):Promise.reject(Error("Tried to send a JSON-RPC notification `"+e[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+t+`)`))}},Ra=56,za=class{constructor(e){this.key=void 0,this.state=void 0,this.key=e.key,this.state=e.state}isActive(){let e=BigInt(`0xffffffffffffffff`);return this.state.deactivationSlot===e}static deserialize(e){let t=wi(Ba,e),n=e.length-Ra;mi(n>=0,`lookup table is invalid`),mi(n%32==0,`lookup table is invalid`);let r=n/32,{addresses:i}=H.struct([H.seq(G(),r,`addresses`)]).decode(e.slice(Ra));return{deactivationSlot:t.deactivationSlot,lastExtendedSlot:t.lastExtendedSlot,lastExtendedSlotStartIndex:t.lastExtendedStartIndex,authority:t.authority.length===0?void 0:new W(t.authority[0]),addresses:i.map(e=>new W(e))}}},Ba={index:1,layout:H.struct([H.u32(`typeIndex`),yi(`deactivationSlot`),H.nu64(`lastExtendedSlot`),H.u8(`lastExtendedStartIndex`),H.u8(),H.seq(G(),H.offset(H.u8(),-1),`authority`)])},Va=/^[^:]+:\/\/([^:[]+|\[[^\]]+\])(:\d+)?(.*)/i,Ha=Qn(Gn(W),R(),e=>new W(e)),Ua=Yn([R(),Kn(`base64`)]),Wa=Qn(Gn(_),Ua,e=>_.from(e[0],`base64`)),Ga=3e4,Ka=ki(Zn()),qa=z({foundation:I(),foundationTerm:I(),initial:I(),taper:I(),terminal:I()}),Ja=V(P(F(z({epoch:I(),effectiveSlot:I(),amount:I(),postBalance:I(),commission:L(F(I()))})))),Ya=P(z({slot:I(),prioritizationFee:I()})),Xa=z({total:I(),validator:I(),foundation:I(),epoch:I()}),Za=z({epoch:I(),slotIndex:I(),slotsInEpoch:I(),absoluteSlot:I(),blockHeight:L(I()),transactionCount:L(I())}),Qa=z({slotsPerEpoch:I(),leaderScheduleSlotOffset:I(),warmup:Wn(),firstNormalEpoch:I(),firstNormalSlot:I()}),$a=Jn(R(),P(I())),eo=F(Xn([z({}),R()])),to=z({err:eo}),no=Kn(`receivedSignature`),ro=z({"solana-core":R(),"feature-set":L(I())}),io=z({program:R(),programId:Ha,parsed:Zn()}),ao=z({programId:Ha,accounts:P(Ha),data:R()}),oo=Ai(z({err:F(Xn([z({}),R()])),logs:F(P(R())),accounts:L(F(P(F(z({executable:Wn(),owner:R(),lamports:I(),data:P(R()),rentEpoch:L(I())}))))),unitsConsumed:L(I()),returnData:L(F(z({programId:R(),data:Yn([R(),Kn(`base64`)])}))),innerInstructions:L(F(P(z({index:I(),instructions:P(Xn([io,ao]))}))))})),so=Ai(z({byIdentity:Jn(R(),P(I())),range:z({firstSlot:I(),lastSlot:I()})})),co=V(qa),lo=V(Xa),uo=V(Ya),fo=V(Za),po=V(Qa),mo=V($a),ho=V(I()),go=Ai(z({total:I(),circulating:I(),nonCirculating:I(),nonCirculatingAccounts:P(Ha)})),_o=z({amount:R(),uiAmount:F(I()),decimals:I(),uiAmountString:L(R())}),vo=Ai(P(z({address:Ha,amount:R(),uiAmount:F(I()),decimals:I(),uiAmountString:L(R())}))),yo=Ai(P(z({pubkey:Ha,account:z({executable:Wn(),owner:Ha,lamports:I(),data:Wa,rentEpoch:I()})}))),bo=z({program:R(),parsed:Zn(),space:I()}),xo=Ai(P(z({pubkey:Ha,account:z({executable:Wn(),owner:Ha,lamports:I(),data:bo,rentEpoch:I()})}))),So=Ai(P(z({lamports:I(),address:Ha}))),Co=z({executable:Wn(),owner:Ha,lamports:I(),data:Wa,rentEpoch:I()}),wo=z({pubkey:Ha,account:Co}),To=Qn(Xn([Gn(_),bo]),Xn([Ua,bo]),e=>Array.isArray(e)?N(e,Wa):e),Eo=z({executable:Wn(),owner:Ha,lamports:I(),data:To,rentEpoch:I()}),Do=z({pubkey:Ha,account:Eo}),Oo=z({state:Xn([Kn(`active`),Kn(`inactive`),Kn(`activating`),Kn(`deactivating`)]),active:I(),inactive:I()}),ko=V(P(z({signature:R(),slot:I(),err:eo,memo:F(R()),blockTime:L(F(I()))}))),Ao=V(P(z({signature:R(),slot:I(),err:eo,memo:F(R()),blockTime:L(F(I()))}))),jo=z({subscription:I(),result:ji(Co)}),Mo=z({pubkey:Ha,account:Co}),No=z({subscription:I(),result:ji(Mo)}),Po=z({parent:I(),slot:I(),root:I()}),Fo=z({subscription:I(),result:Po}),Io=Xn([z({type:Xn([Kn(`firstShredReceived`),Kn(`completed`),Kn(`optimisticConfirmation`),Kn(`root`)]),slot:I(),timestamp:I()}),z({type:Kn(`createdBank`),parent:I(),slot:I(),timestamp:I()}),z({type:Kn(`frozen`),slot:I(),timestamp:I(),stats:z({numTransactionEntries:I(),numSuccessfulTransactions:I(),numFailedTransactions:I(),maxTransactionsPerEntry:I()})}),z({type:Kn(`dead`),slot:I(),timestamp:I(),err:R()})]),Lo=z({subscription:I(),result:Io}),Ro=z({subscription:I(),result:ji(Xn([to,no]))}),zo=z({subscription:I(),result:I()}),Bo=z({pubkey:R(),gossip:F(R()),tpu:F(R()),rpc:F(R()),version:F(R())}),Vo=z({votePubkey:R(),nodePubkey:R(),activatedStake:I(),epochVoteAccount:Wn(),epochCredits:P(Yn([I(),I(),I()])),commission:I(),lastVote:I(),rootSlot:F(I())}),Ho=V(z({current:P(Vo),delinquent:P(Vo)})),Uo=Xn([Kn(`processed`),Kn(`confirmed`),Kn(`finalized`)]),Wo=z({slot:I(),confirmations:F(I()),err:eo,confirmationStatus:L(Uo)}),Go=Ai(P(F(Wo))),Ko=V(I()),qo=z({accountKey:Ha,writableIndexes:P(I()),readonlyIndexes:P(I())}),Jo=z({signatures:P(R()),message:z({accountKeys:P(R()),header:z({numRequiredSignatures:I(),numReadonlySignedAccounts:I(),numReadonlyUnsignedAccounts:I()}),instructions:P(z({accounts:P(I()),data:R(),programIdIndex:I()})),recentBlockhash:R(),addressTableLookups:L(P(qo))})}),Yo=z({pubkey:Ha,signer:Wn(),writable:Wn(),source:L(Xn([Kn(`transaction`),Kn(`lookupTable`)]))}),Xo=z({accountKeys:P(Yo),signatures:P(R())}),Zo=z({parsed:Zn(),program:R(),programId:Ha}),Qo=z({accounts:P(Ha),data:R(),programId:Ha}),$o=Xn([Qo,Zo]),es=Xn([z({parsed:Zn(),program:R(),programId:R()}),z({accounts:P(R()),data:R(),programId:R()})]),ts=Qn($o,es,e=>`accounts`in e?N(e,Qo):N(e,Zo)),ns=z({signatures:P(R()),message:z({accountKeys:P(Yo),instructions:P(ts),recentBlockhash:R(),addressTableLookups:L(F(P(qo)))})}),rs=z({accountIndex:I(),mint:R(),owner:L(R()),programId:L(R()),uiTokenAmount:_o}),is=z({writable:P(Ha),readonly:P(Ha)}),as=z({err:eo,fee:I(),innerInstructions:L(F(P(z({index:I(),instructions:P(z({accounts:P(I()),data:R(),programIdIndex:I()}))})))),preBalances:P(I()),postBalances:P(I()),logMessages:L(F(P(R()))),preTokenBalances:L(F(P(rs))),postTokenBalances:L(F(P(rs))),loadedAddresses:L(is),computeUnitsConsumed:L(I()),costUnits:L(I())}),os=z({err:eo,fee:I(),innerInstructions:L(F(P(z({index:I(),instructions:P(ts)})))),preBalances:P(I()),postBalances:P(I()),logMessages:L(F(P(R()))),preTokenBalances:L(F(P(rs))),postTokenBalances:L(F(P(rs))),loadedAddresses:L(is),computeUnitsConsumed:L(I()),costUnits:L(I())}),ss=Xn([Kn(0),Kn(`legacy`)]),cs=z({pubkey:R(),lamports:I(),postBalance:F(I()),rewardType:F(R()),commission:L(F(I()))}),ls=V(F(z({blockhash:R(),previousBlockhash:R(),parentSlot:I(),transactions:P(z({transaction:Jo,meta:F(as),version:L(ss)})),rewards:L(P(cs)),blockTime:F(I()),blockHeight:F(I())}))),us=V(F(z({blockhash:R(),previousBlockhash:R(),parentSlot:I(),rewards:L(P(cs)),blockTime:F(I()),blockHeight:F(I())}))),ds=V(F(z({blockhash:R(),previousBlockhash:R(),parentSlot:I(),transactions:P(z({transaction:Xo,meta:F(as),version:L(ss)})),rewards:L(P(cs)),blockTime:F(I()),blockHeight:F(I())}))),fs=V(F(z({blockhash:R(),previousBlockhash:R(),parentSlot:I(),transactions:P(z({transaction:ns,meta:F(os),version:L(ss)})),rewards:L(P(cs)),blockTime:F(I()),blockHeight:F(I())}))),ps=V(F(z({blockhash:R(),previousBlockhash:R(),parentSlot:I(),transactions:P(z({transaction:Xo,meta:F(os),version:L(ss)})),rewards:L(P(cs)),blockTime:F(I()),blockHeight:F(I())}))),ms=V(F(z({blockhash:R(),previousBlockhash:R(),parentSlot:I(),rewards:L(P(cs)),blockTime:F(I()),blockHeight:F(I())}))),hs=V(F(z({blockhash:R(),previousBlockhash:R(),parentSlot:I(),transactions:P(z({transaction:Jo,meta:F(as)})),rewards:L(P(cs)),blockTime:F(I())}))),gs=V(F(z({blockhash:R(),previousBlockhash:R(),parentSlot:I(),signatures:P(R()),blockTime:F(I())}))),_s=V(F(z({slot:I(),meta:F(as),blockTime:L(F(I())),transaction:Jo,version:L(ss)}))),vs=V(F(z({slot:I(),transaction:ns,meta:F(os),blockTime:L(F(I())),version:L(ss)}))),ys=Ai(z({blockhash:R(),lastValidBlockHeight:I()})),bs=Ai(Wn()),xs=z({slot:I(),numTransactions:I(),numSlots:I(),samplePeriodSecs:I()}),Ss=V(P(xs)),Cs=Ai(F(z({feeCalculator:z({lamportsPerSignature:I()})}))),ws=V(R()),Ts=V(R()),Es=z({err:eo,logs:P(R()),signature:R()}),Ds=z({result:ji(Es),subscription:I()}),Os={"solana-client":`js/1.0.0-maintenance`},ks=class{constructor(e,t){this._commitment=void 0,this._confirmTransactionInitialTimeout=void 0,this._rpcEndpoint=void 0,this._rpcWsEndpoint=void 0,this._rpcClient=void 0,this._rpcRequest=void 0,this._rpcBatchRequest=void 0,this._rpcWebSocket=void 0,this._rpcWebSocketConnected=!1,this._rpcWebSocketHeartbeat=null,this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketGeneration=0,this._disableBlockhashCaching=!1,this._pollingBlockhash=!1,this._blockhashInfo={latestBlockhash:null,lastFetch:0,transactionSignatures:[],simulatedSignatures:[]},this._nextClientSubscriptionId=0,this._subscriptionDisposeFunctionsByClientSubscriptionId={},this._subscriptionHashByClientSubscriptionId={},this._subscriptionStateChangeCallbacksByHash={},this._subscriptionCallbacksByServerSubscriptionId={},this._subscriptionsByHash={},this._subscriptionsAutoDisposedByRpc=new Set,this.getBlockHeight=(()=>{let e={};return async t=>{let{commitment:n,config:r}=Di(t),i=this._buildArgs([],n,void 0,r),a=Na(i);return e[a]=e[a]??(async()=>{try{let e=N(await this._rpcRequest(`getBlockHeight`,i),V(I()));if(`error`in e)throw new K(e.error,`failed to get block height information`);return e.result}finally{delete e[a]}})(),await e[a]}})();let n,r,i,a,o,s;t&&typeof t==`string`?this._commitment=t:t&&(this._commitment=t.commitment,this._confirmTransactionInitialTimeout=t.confirmTransactionInitialTimeout,n=t.wsEndpoint,r=t.httpHeaders,i=t.fetch,a=t.fetchMiddleware,o=t.disableRetryOnRateLimit,s=t.httpAgent),this._rpcEndpoint=Ei(e),this._rpcWsEndpoint=n||Ti(e),this._rpcClient=Ni(e,r,i,a,o,s),this._rpcRequest=Pi(this._rpcClient),this._rpcBatchRequest=Fi(this._rpcClient),this._rpcWebSocket=new La(this._rpcWsEndpoint,{autoconnect:!1,max_reconnects:1/0}),this._rpcWebSocket.on(`open`,this._wsOnOpen.bind(this)),this._rpcWebSocket.on(`error`,this._wsOnError.bind(this)),this._rpcWebSocket.on(`close`,this._wsOnClose.bind(this)),this._rpcWebSocket.on(`accountNotification`,this._wsOnAccountNotification.bind(this)),this._rpcWebSocket.on(`programNotification`,this._wsOnProgramAccountNotification.bind(this)),this._rpcWebSocket.on(`slotNotification`,this._wsOnSlotNotification.bind(this)),this._rpcWebSocket.on(`slotsUpdatesNotification`,this._wsOnSlotUpdatesNotification.bind(this)),this._rpcWebSocket.on(`signatureNotification`,this._wsOnSignatureNotification.bind(this)),this._rpcWebSocket.on(`rootNotification`,this._wsOnRootNotification.bind(this)),this._rpcWebSocket.on(`logsNotification`,this._wsOnLogsNotification.bind(this))}get commitment(){return this._commitment}get rpcEndpoint(){return this._rpcEndpoint}async getBalanceAndContext(e,t){let{commitment:n,config:r}=Di(t),i=this._buildArgs([e.toBase58()],n,void 0,r),a=N(await this._rpcRequest(`getBalance`,i),Ai(I()));if(`error`in a)throw new K(a.error,`failed to get balance for ${e.toBase58()}`);return a.result}async getBalance(e,t){return await this.getBalanceAndContext(e,t).then(e=>e.value).catch(t=>{throw Error(`failed to get balance of account `+e.toBase58()+`: `+t)})}async getBlockTime(e){let t=N(await this._rpcRequest(`getBlockTime`,[e]),V(F(I())));if(`error`in t)throw new K(t.error,`failed to get block time for slot ${e}`);return t.result}async getMinimumLedgerSlot(){let e=N(await this._rpcRequest(`minimumLedgerSlot`,[]),V(I()));if(`error`in e)throw new K(e.error,`failed to get minimum ledger slot`);return e.result}async getFirstAvailableBlock(){let e=N(await this._rpcRequest(`getFirstAvailableBlock`,[]),ho);if(`error`in e)throw new K(e.error,`failed to get first available block`);return e.result}async getSupply(e){let t={};t=typeof e==`string`?{commitment:e}:e?{...e,commitment:e&&e.commitment||this.commitment}:{commitment:this.commitment};let n=N(await this._rpcRequest(`getSupply`,[t]),go);if(`error`in n)throw new K(n.error,`failed to get supply`);return n.result}async getTokenSupply(e,t){let n=this._buildArgs([e.toBase58()],t),r=N(await this._rpcRequest(`getTokenSupply`,n),Ai(_o));if(`error`in r)throw new K(r.error,`failed to get token supply`);return r.result}async getTokenAccountBalance(e,t){let n=this._buildArgs([e.toBase58()],t),r=N(await this._rpcRequest(`getTokenAccountBalance`,n),Ai(_o));if(`error`in r)throw new K(r.error,`failed to get token account balance`);return r.result}async getTokenAccountsByOwner(e,t,n){let{commitment:r,config:i}=Di(n),a=[e.toBase58()];`mint`in t?a.push({mint:t.mint.toBase58()}):a.push({programId:t.programId.toBase58()});let o=this._buildArgs(a,r,`base64`,i),s=N(await this._rpcRequest(`getTokenAccountsByOwner`,o),yo);if(`error`in s)throw new K(s.error,`failed to get token accounts owned by account ${e.toBase58()}`);return s.result}async getParsedTokenAccountsByOwner(e,t,n){let r=[e.toBase58()];`mint`in t?r.push({mint:t.mint.toBase58()}):r.push({programId:t.programId.toBase58()});let i=this._buildArgs(r,n,`jsonParsed`),a=N(await this._rpcRequest(`getTokenAccountsByOwner`,i),xo);if(`error`in a)throw new K(a.error,`failed to get token accounts owned by account ${e.toBase58()}`);return a.result}async getLargestAccounts(e){let t={...e,commitment:e&&e.commitment||this.commitment},n=t.filter||t.commitment?[t]:[],r=N(await this._rpcRequest(`getLargestAccounts`,n),So);if(`error`in r)throw new K(r.error,`failed to get largest accounts`);return r.result}async getTokenLargestAccounts(e,t){let n=this._buildArgs([e.toBase58()],t),r=N(await this._rpcRequest(`getTokenLargestAccounts`,n),vo);if(`error`in r)throw new K(r.error,`failed to get token largest accounts`);return r.result}async getAccountInfoAndContext(e,t){let{commitment:n,config:r}=Di(t),i=this._buildArgs([e.toBase58()],n,`base64`,r),a=N(await this._rpcRequest(`getAccountInfo`,i),Ai(F(Co)));if(`error`in a)throw new K(a.error,`failed to get info about account ${e.toBase58()}`);return a.result}async getParsedAccountInfo(e,t){let{commitment:n,config:r}=Di(t),i=this._buildArgs([e.toBase58()],n,`jsonParsed`,r),a=N(await this._rpcRequest(`getAccountInfo`,i),Ai(F(Eo)));if(`error`in a)throw new K(a.error,`failed to get info about account ${e.toBase58()}`);return a.result}async getAccountInfo(e,t){try{return(await this.getAccountInfoAndContext(e,t)).value}catch(t){throw Error(`failed to get info about account `+e.toBase58()+`: `+t)}}async getMultipleParsedAccounts(e,t){let{commitment:n,config:r}=Di(t),i=e.map(e=>e.toBase58()),a=this._buildArgs([i],n,`jsonParsed`,r),o=N(await this._rpcRequest(`getMultipleAccounts`,a),Ai(P(F(Eo))));if(`error`in o)throw new K(o.error,`failed to get info for accounts ${i}`);return o.result}async getMultipleAccountsInfoAndContext(e,t){let{commitment:n,config:r}=Di(t),i=e.map(e=>e.toBase58()),a=this._buildArgs([i],n,`base64`,r),o=N(await this._rpcRequest(`getMultipleAccounts`,a),Ai(P(F(Co))));if(`error`in o)throw new K(o.error,`failed to get info for accounts ${i}`);return o.result}async getMultipleAccountsInfo(e,t){return(await this.getMultipleAccountsInfoAndContext(e,t)).value}async getStakeActivation(e,t,n){let{commitment:r,config:i}=Di(t),a=this._buildArgs([e.toBase58()],r,void 0,{...i,epoch:n??i?.epoch}),o=N(await this._rpcRequest(`getStakeActivation`,a),V(Oo));if(`error`in o)throw new K(o.error,`failed to get Stake Activation ${e.toBase58()}`);return o.result}async getProgramAccounts(e,t){let{commitment:n,config:r}=Di(t),{encoding:i,...a}=r||{},o=this._buildArgs([e.toBase58()],n,i||`base64`,{...a,...a.filters?{filters:Oi(a.filters)}:null}),s=await this._rpcRequest(`getProgramAccounts`,o),c=P(wo),l=a.withContext===!0?N(s,Ai(c)):N(s,V(c));if(`error`in l)throw new K(l.error,`failed to get accounts owned by program ${e.toBase58()}`);return l.result}async getParsedProgramAccounts(e,t){let{commitment:n,config:r}=Di(t),i=this._buildArgs([e.toBase58()],n,`jsonParsed`,r),a=N(await this._rpcRequest(`getProgramAccounts`,i),V(P(Do)));if(`error`in a)throw new K(a.error,`failed to get accounts owned by program ${e.toBase58()}`);return a.result}async confirmTransaction(e,t){let n;if(typeof e==`string`)n=e;else{let t=e;if(t.abortSignal?.aborted)return Promise.reject(t.abortSignal.reason);n=t.signature}let r;try{r=Ri.default.decode(n)}catch{throw Error(`signature must be base58 encoded: `+n)}return mi(r.length===64,`signature has invalid length`),typeof e==`string`?await this.confirmTransactionUsingLegacyTimeoutStrategy({commitment:t||this.commitment,signature:n}):`lastValidBlockHeight`in e?await this.confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:t||this.commitment,strategy:e}):await this.confirmTransactionUsingDurableNonceStrategy({commitment:t||this.commitment,strategy:e})}getCancellationPromise(e){return new Promise((t,n)=>{e!=null&&(e.aborted?n(e.reason):e.addEventListener(`abort`,()=>{n(e.reason)}))})}getTransactionConfirmationPromise({commitment:e,signature:t}){let n,r,i=!1;return{abortConfirmation:()=>{r&&=(r(),void 0),n!=null&&(this.removeSignatureListener(n),n=void 0)},confirmationPromise:new Promise((a,o)=>{try{n=this.onSignature(t,(e,t)=>{n=void 0;let r={context:t,value:e};a({__type:fa.PROCESSED,response:r})},e);let s=new Promise(e=>{n==null?e():r=this._onSubscriptionStateChange(n,t=>{t===`subscribed`&&e()})});(async()=>{if(await s,i)return;let n=await this.getSignatureStatus(t);if(i||n==null)return;let{context:r,value:c}=n;if(c!=null){if(c?.err)o(c.err);else{switch(e){case`confirmed`:case`single`:case`singleGossip`:if(c.confirmationStatus===`processed`)return;break;case`finalized`:case`max`:case`root`:if(c.confirmationStatus===`processed`||c.confirmationStatus===`confirmed`)return}i=!0,a({__type:fa.PROCESSED,response:{context:r,value:c}})}}})()}catch(e){o(e)}})}}async confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:e,strategy:{abortSignal:t,lastValidBlockHeight:n,signature:r}}){let i=!1,a=new Promise(t=>{let r=async()=>{try{return await this.getBlockHeight(e)}catch{return-1}};(async()=>{let e=await r();if(!i){for(;e<=n;)if(await vi(1e3),i||(e=await r(),i))return;t({__type:fa.BLOCKHEIGHT_EXCEEDED})}})()}),{abortConfirmation:o,confirmationPromise:s}=this.getTransactionConfirmationPromise({commitment:e,signature:r}),c=this.getCancellationPromise(t),l;try{let e=await Promise.race([c,s,a]);if(e.__type===fa.PROCESSED)l=e.response;else throw new Zi(r)}finally{i=!0,o()}return l}async confirmTransactionUsingDurableNonceStrategy({commitment:e,strategy:{abortSignal:t,minContextSlot:n,nonceAccountPubkey:r,nonceValue:i,signature:a}}){let o=!1,s=new Promise(t=>{let a=i,s=null,c=async()=>{try{let{context:t,value:i}=await this.getNonceAndContext(r,{commitment:e,minContextSlot:n});return s=t.slot,i?.nonce}catch{return a}};(async()=>{if(a=await c(),!o)for(;;){if(i!==a){t({__type:fa.NONCE_INVALID,slotInWhichNonceDidAdvance:s});return}if(await vi(2e3),o||(a=await c(),o))return}})()}),{abortConfirmation:c,confirmationPromise:l}=this.getTransactionConfirmationPromise({commitment:e,signature:a}),u=this.getCancellationPromise(t),d;try{let t=await Promise.race([u,l,s]);if(t.__type===fa.PROCESSED)d=t.response;else{let r;for(;;){let e=await this.getSignatureStatus(a);if(e==null)break;if(e.context.slot<(t.slotInWhichNonceDidAdvance??n)){await vi(400);continue}r=e;break}if(r?.value){let t=e||`finalized`,{confirmationStatus:n}=r.value;switch(t){case`processed`:case`recent`:if(n!==`processed`&&n!==`confirmed`&&n!==`finalized`)throw new $i(a);break;case`confirmed`:case`single`:case`singleGossip`:if(n!==`confirmed`&&n!==`finalized`)throw new $i(a);break;case`finalized`:case`max`:case`root`:if(n!==`finalized`)throw new $i(a)}d={context:r.context,value:{err:r.value.err}}}else throw new $i(a)}}finally{o=!0,c()}return d}async confirmTransactionUsingLegacyTimeoutStrategy({commitment:e,signature:t}){let n,r=new Promise(t=>{let r=this._confirmTransactionInitialTimeout||6e4;switch(e){case`processed`:case`recent`:case`single`:case`confirmed`:case`singleGossip`:r=this._confirmTransactionInitialTimeout||3e4}n=setTimeout(()=>t({__type:fa.TIMED_OUT,timeoutMs:r}),r)}),{abortConfirmation:i,confirmationPromise:a}=this.getTransactionConfirmationPromise({commitment:e,signature:t}),o;try{let e=await Promise.race([a,r]);if(e.__type===fa.PROCESSED)o=e.response;else throw new Qi(t,e.timeoutMs/1e3)}finally{clearTimeout(n),i()}return o}async getClusterNodes(){let e=N(await this._rpcRequest(`getClusterNodes`,[]),V(P(Bo)));if(`error`in e)throw new K(e.error,`failed to get cluster nodes`);return e.result}async getVoteAccounts(e){let t=this._buildArgs([],e),n=N(await this._rpcRequest(`getVoteAccounts`,t),Ho);if(`error`in n)throw new K(n.error,`failed to get vote accounts`);return n.result}async getSlot(e){let{commitment:t,config:n}=Di(e),r=this._buildArgs([],t,void 0,n),i=N(await this._rpcRequest(`getSlot`,r),V(I()));if(`error`in i)throw new K(i.error,`failed to get slot`);return i.result}async getSlotLeader(e){let{commitment:t,config:n}=Di(e),r=this._buildArgs([],t,void 0,n),i=N(await this._rpcRequest(`getSlotLeader`,r),V(R()));if(`error`in i)throw new K(i.error,`failed to get slot leader`);return i.result}async getSlotLeaders(e,t){let n=[e,t],r=N(await this._rpcRequest(`getSlotLeaders`,n),V(P(Ha)));if(`error`in r)throw new K(r.error,`failed to get slot leaders`);return r.result}async getSignatureStatus(e,t){let{context:n,value:r}=await this.getSignatureStatuses([e],t);return mi(r.length===1),{context:n,value:r[0]}}async getSignatureStatuses(e,t){let n=[e];t&&n.push(t);let r=N(await this._rpcRequest(`getSignatureStatuses`,n),Go);if(`error`in r)throw new K(r.error,`failed to get signature status`);return r.result}async getTransactionCount(e){let{commitment:t,config:n}=Di(e),r=this._buildArgs([],t,void 0,n),i=N(await this._rpcRequest(`getTransactionCount`,r),V(I()));if(`error`in i)throw new K(i.error,`failed to get transaction count`);return i.result}async getTotalSupply(e){return(await this.getSupply({commitment:e,excludeNonCirculatingAccountsList:!0})).value.total}async getInflationGovernor(e){let t=this._buildArgs([],e),n=N(await this._rpcRequest(`getInflationGovernor`,t),co);if(`error`in n)throw new K(n.error,`failed to get inflation`);return n.result}async getInflationReward(e,t,n){let{commitment:r,config:i}=Di(n),a=this._buildArgs([e.map(e=>e.toBase58())],r,void 0,{...i,epoch:t??i?.epoch}),o=N(await this._rpcRequest(`getInflationReward`,a),Ja);if(`error`in o)throw new K(o.error,`failed to get inflation reward`);return o.result}async getInflationRate(){let e=N(await this._rpcRequest(`getInflationRate`,[]),lo);if(`error`in e)throw new K(e.error,`failed to get inflation rate`);return e.result}async getEpochInfo(e){let{commitment:t,config:n}=Di(e),r=this._buildArgs([],t,void 0,n),i=N(await this._rpcRequest(`getEpochInfo`,r),fo);if(`error`in i)throw new K(i.error,`failed to get epoch info`);return i.result}async getEpochSchedule(){let e=N(await this._rpcRequest(`getEpochSchedule`,[]),po);if(`error`in e)throw new K(e.error,`failed to get epoch schedule`);let t=e.result;return new Fa(t.slotsPerEpoch,t.leaderScheduleSlotOffset,t.warmup,t.firstNormalEpoch,t.firstNormalSlot)}async getLeaderSchedule(){let e=N(await this._rpcRequest(`getLeaderSchedule`,[]),mo);if(`error`in e)throw new K(e.error,`failed to get leader schedule`);return e.result}async getMinimumBalanceForRentExemption(e,t){let n=this._buildArgs([e],t),r=N(await this._rpcRequest(`getMinimumBalanceForRentExemption`,n),Ko);return`error`in r?0:r.result}async getRecentBlockhashAndContext(e){let{context:t,value:{blockhash:n}}=await this.getLatestBlockhashAndContext(e);return{context:t,value:{blockhash:n,feeCalculator:{get lamportsPerSignature(){throw Error("The capability to fetch `lamportsPerSignature` using the `getRecentBlockhash` API is no longer offered by the network. Use the `getFeeForMessage` API to obtain the fee for a given message.")},toJSON(){return{}}}}}}async getRecentPerformanceSamples(e){let t=N(await this._rpcRequest(`getRecentPerformanceSamples`,e?[e]:[]),Ss);if(`error`in t)throw new K(t.error,`failed to get recent performance samples`);return t.result}async getFeeCalculatorForBlockhash(e,t){let n=this._buildArgs([e],t),r=N(await this._rpcRequest(`getFeeCalculatorForBlockhash`,n),Cs);if(`error`in r)throw new K(r.error,`failed to get fee calculator`);let{context:i,value:a}=r.result;return{context:i,value:a===null?null:a.feeCalculator}}async getFeeForMessage(e,t){let n=U(e.serialize()).toString(`base64`),r=this._buildArgs([n],t),i=N(await this._rpcRequest(`getFeeForMessage`,r),Ai(F(I())));if(`error`in i)throw new K(i.error,`failed to get fee for message`);if(i.result===null)throw Error(`invalid blockhash`);return i.result}async getRecentPrioritizationFees(e){let t=e?.lockedWritableAccounts?.map(e=>e.toBase58()),n=t?.length?[t]:[],r=N(await this._rpcRequest(`getRecentPrioritizationFees`,n),uo);if(`error`in r)throw new K(r.error,`failed to get recent prioritization fees`);return r.result}async getRecentBlockhash(e){try{return(await this.getRecentBlockhashAndContext(e)).value}catch(e){throw Error(`failed to get recent blockhash: `+e)}}async getLatestBlockhash(e){try{return(await this.getLatestBlockhashAndContext(e)).value}catch(e){throw Error(`failed to get recent blockhash: `+e)}}async getLatestBlockhashAndContext(e){let{commitment:t,config:n}=Di(e),r=this._buildArgs([],t,void 0,n),i=N(await this._rpcRequest(`getLatestBlockhash`,r),ys);if(`error`in i)throw new K(i.error,`failed to get latest blockhash`);return i.result}async isBlockhashValid(e,t){let{commitment:n,config:r}=Di(t),i=this._buildArgs([e],n,void 0,r),a=N(await this._rpcRequest(`isBlockhashValid`,i),bs);if(`error`in a)throw new K(a.error,"failed to determine if the blockhash `"+e+"`is valid");return a.result}async getVersion(){let e=N(await this._rpcRequest(`getVersion`,[]),V(ro));if(`error`in e)throw new K(e.error,`failed to get version`);return e.result}async getGenesisHash(){let e=N(await this._rpcRequest(`getGenesisHash`,[]),V(R()));if(`error`in e)throw new K(e.error,`failed to get genesis hash`);return e.result}async getBlock(e,t){let{commitment:n,config:r}=Di(t),i=this._buildArgsAtLeastConfirmed([e],n,void 0,r),a=await this._rpcRequest(`getBlock`,i);try{switch(r?.transactionDetails){case`accounts`:{let e=N(a,ds);if(`error`in e)throw e.error;return e.result}case`none`:{let e=N(a,us);if(`error`in e)throw e.error;return e.result}default:{let e=N(a,ls);if(`error`in e)throw e.error;let{result:t}=e;return t?{...t,transactions:t.transactions.map(({transaction:e,meta:t,version:n})=>({meta:t,transaction:{...e,message:Mi(n,e.message)},version:n}))}:null}}}catch(e){throw new K(e,`failed to get confirmed block`)}}async getParsedBlock(e,t){let{commitment:n,config:r}=Di(t),i=this._buildArgsAtLeastConfirmed([e],n,`jsonParsed`,r),a=await this._rpcRequest(`getBlock`,i);try{switch(r?.transactionDetails){case`accounts`:{let e=N(a,ps);if(`error`in e)throw e.error;return e.result}case`none`:{let e=N(a,ms);if(`error`in e)throw e.error;return e.result}default:{let e=N(a,fs);if(`error`in e)throw e.error;return e.result}}}catch(e){throw new K(e,`failed to get block`)}}async getBlockProduction(e){let t,n;if(typeof e==`string`)n=e;else if(e){let{commitment:r,...i}=e;n=r,t=i}let r=this._buildArgs([],n,`base64`,t),i=N(await this._rpcRequest(`getBlockProduction`,r),so);if(`error`in i)throw new K(i.error,`failed to get block production information`);return i.result}async getTransaction(e,t){let{commitment:n,config:r}=Di(t),i=this._buildArgsAtLeastConfirmed([e],n,void 0,r),a=N(await this._rpcRequest(`getTransaction`,i),_s);if(`error`in a)throw new K(a.error,`failed to get transaction`);let o=a.result;return o&&{...o,transaction:{...o.transaction,message:Mi(o.version,o.transaction.message)}}}async getParsedTransaction(e,t){let{commitment:n,config:r}=Di(t),i=this._buildArgsAtLeastConfirmed([e],n,`jsonParsed`,r),a=N(await this._rpcRequest(`getTransaction`,i),vs);if(`error`in a)throw new K(a.error,`failed to get transaction`);return a.result}async getParsedTransactions(e,t){let{commitment:n,config:r}=Di(t),i=e.map(e=>({methodName:`getTransaction`,args:this._buildArgsAtLeastConfirmed([e],n,`jsonParsed`,r)}));return(await this._rpcBatchRequest(i)).map(e=>{let t=N(e,vs);if(`error`in t)throw new K(t.error,`failed to get transactions`);return t.result})}async getTransactions(e,t){let{commitment:n,config:r}=Di(t),i=e.map(e=>({methodName:`getTransaction`,args:this._buildArgsAtLeastConfirmed([e],n,void 0,r)}));return(await this._rpcBatchRequest(i)).map(e=>{let t=N(e,_s);if(`error`in t)throw new K(t.error,`failed to get transactions`);let n=t.result;return n&&{...n,transaction:{...n.transaction,message:Mi(n.version,n.transaction.message)}}})}async getConfirmedBlock(e,t){let n=this._buildArgsAtLeastConfirmed([e],t),r=N(await this._rpcRequest(`getBlock`,n),hs);if(`error`in r)throw new K(r.error,`failed to get confirmed block`);let i=r.result;if(!i)throw Error(`Confirmed block `+e+` not found`);let a={...i,transactions:i.transactions.map(({transaction:e,meta:t})=>{let n=new la(e.message);return{meta:t,transaction:{...e,message:n}}})};return{...a,transactions:a.transactions.map(({transaction:e,meta:t})=>({meta:t,transaction:ha.populate(e.message,e.signatures)}))}}async getBlocks(e,t,n){let r=this._buildArgsAtLeastConfirmed(t===void 0?[e]:[e,t],n),i=N(await this._rpcRequest(`getBlocks`,r),V(P(I())));if(`error`in i)throw new K(i.error,`failed to get blocks`);return i.result}async getBlockSignatures(e,t){let n=this._buildArgsAtLeastConfirmed([e],t,void 0,{transactionDetails:`signatures`,rewards:!1}),r=N(await this._rpcRequest(`getBlock`,n),gs);if(`error`in r)throw new K(r.error,`failed to get block`);let i=r.result;if(!i)throw Error(`Block `+e+` not found`);return i}async getConfirmedBlockSignatures(e,t){let n=this._buildArgsAtLeastConfirmed([e],t,void 0,{transactionDetails:`signatures`,rewards:!1}),r=N(await this._rpcRequest(`getBlock`,n),gs);if(`error`in r)throw new K(r.error,`failed to get confirmed block`);let i=r.result;if(!i)throw Error(`Confirmed block `+e+` not found`);return i}async getConfirmedTransaction(e,t){let n=this._buildArgsAtLeastConfirmed([e],t),r=N(await this._rpcRequest(`getTransaction`,n),_s);if(`error`in r)throw new K(r.error,`failed to get transaction`);let i=r.result;if(!i)return i;let a=new la(i.transaction.message),o=i.transaction.signatures;return{...i,transaction:ha.populate(a,o)}}async getParsedConfirmedTransaction(e,t){let n=this._buildArgsAtLeastConfirmed([e],t,`jsonParsed`),r=N(await this._rpcRequest(`getTransaction`,n),vs);if(`error`in r)throw new K(r.error,`failed to get confirmed transaction`);return r.result}async getParsedConfirmedTransactions(e,t){let n=e.map(e=>({methodName:`getTransaction`,args:this._buildArgsAtLeastConfirmed([e],t,`jsonParsed`)}));return(await this._rpcBatchRequest(n)).map(e=>{let t=N(e,vs);if(`error`in t)throw new K(t.error,`failed to get confirmed transactions`);return t.result})}async getConfirmedSignaturesForAddress(e,t,n){let r={},i=await this.getFirstAvailableBlock();for(;!(`until`in r)&&(t--,!(t<=0||t<i));)try{let e=await this.getConfirmedBlockSignatures(t,`finalized`);e.signatures.length>0&&(r.until=e.signatures[e.signatures.length-1].toString())}catch(e){if(e instanceof Error&&e.message.includes(`skipped`))continue;throw e}let a=await this.getSlot(`finalized`);for(;!(`before`in r)&&(n++,!(n>a));)try{let e=await this.getConfirmedBlockSignatures(n);e.signatures.length>0&&(r.before=e.signatures[e.signatures.length-1].toString())}catch(e){if(e instanceof Error&&e.message.includes(`skipped`))continue;throw e}return(await this.getConfirmedSignaturesForAddress2(e,r)).map(e=>e.signature)}async getConfirmedSignaturesForAddress2(e,t,n){let r=this._buildArgsAtLeastConfirmed([e.toBase58()],n,void 0,t),i=N(await this._rpcRequest(`getConfirmedSignaturesForAddress2`,r),ko);if(`error`in i)throw new K(i.error,`failed to get confirmed signatures for address`);return i.result}async getSignaturesForAddress(e,t,n){let r=this._buildArgsAtLeastConfirmed([e.toBase58()],n,void 0,t),i=N(await this._rpcRequest(`getSignaturesForAddress`,r),Ao);if(`error`in i)throw new K(i.error,`failed to get signatures for address`);return i.result}async getAddressLookupTable(e,t){let{context:n,value:r}=await this.getAccountInfoAndContext(e,t),i=null;return r!==null&&(i=new za({key:e,state:za.deserialize(r.data)})),{context:n,value:i}}async getNonceAndContext(e,t){let{context:n,value:r}=await this.getAccountInfoAndContext(e,t),i=null;return r!==null&&(i=Ea.fromAccountData(r.data)),{context:n,value:i}}async getNonce(e,t){return await this.getNonceAndContext(e,t).then(e=>e.value).catch(t=>{throw Error(`failed to get nonce for account `+e.toBase58()+`: `+t)})}async requestAirdrop(e,t){let n=N(await this._rpcRequest(`requestAirdrop`,[e.toBase58(),t]),ws);if(`error`in n)throw new K(n.error,`airdrop to ${e.toBase58()} failed`);return n.result}async _blockhashWithExpiryBlockHeight(e){if(!e){for(;this._pollingBlockhash;)await vi(100);let e=Date.now()-this._blockhashInfo.lastFetch>=Ga;if(this._blockhashInfo.latestBlockhash!==null&&!e)return this._blockhashInfo.latestBlockhash}return await this._pollNewBlockhash()}async _pollNewBlockhash(){this._pollingBlockhash=!0;try{let e=Date.now(),t=this._blockhashInfo.latestBlockhash,n=t?t.blockhash:null;for(let e=0;e<50;e++){let e=await this.getLatestBlockhash(`finalized`);if(n!==e.blockhash)return this._blockhashInfo={latestBlockhash:e,lastFetch:Date.now(),transactionSignatures:[],simulatedSignatures:[]},e;await vi(_a/2)}throw Error(`Unable to obtain a new blockhash after ${Date.now()-e}ms`)}finally{this._pollingBlockhash=!1}}async getStakeMinimumDelegation(e){let{commitment:t,config:n}=Di(e),r=this._buildArgs([],t,`base64`,n),i=N(await this._rpcRequest(`getStakeMinimumDelegation`,r),Ai(I()));if(`error`in i)throw new K(i.error,`failed to get stake minimum delegation`);return i.result}async simulateTransaction(e,t,n){if(`message`in e){let r=e.serialize(),i=_.from(r).toString(`base64`);if(Array.isArray(t)||n!==void 0)throw Error(`Invalid arguments`);let a=t||{};a.encoding=`base64`,`commitment`in a||(a.commitment=this.commitment),t&&typeof t==`object`&&`innerInstructions`in t&&(a.innerInstructions=t.innerInstructions);let o=[i,a],s=N(await this._rpcRequest(`simulateTransaction`,o),oo);if(`error`in s)throw Error(`failed to simulate transaction: `+s.error.message);return s.result}let r;if(e instanceof ha){let t=e;r=new ha,r.feePayer=t.feePayer,r.instructions=e.instructions,r.nonceInfo=t.nonceInfo,r.signatures=t.signatures}else r=ha.populate(e),r._message=r._json=void 0;if(t!==void 0&&!Array.isArray(t))throw Error(`Invalid arguments`);let i=t;if(r.nonceInfo&&i)r.sign(...i);else{let e=this._disableBlockhashCaching;for(;;){let t=await this._blockhashWithExpiryBlockHeight(e);if(r.lastValidBlockHeight=t.lastValidBlockHeight,r.recentBlockhash=t.blockhash,!i)break;if(r.sign(...i),!r.signature)throw Error(`!signature`);let n=r.signature.toString(`base64`);if(!this._blockhashInfo.simulatedSignatures.includes(n)&&!this._blockhashInfo.transactionSignatures.includes(n)){this._blockhashInfo.simulatedSignatures.push(n);break}e=!0}}let a=r._compile(),o=a.serialize(),s=r._serialize(o).toString(`base64`),c={encoding:`base64`,commitment:this.commitment};n&&(c.accounts={encoding:`base64`,addresses:(Array.isArray(n)?n:a.nonProgramIds()).map(e=>e.toBase58())}),i&&(c.sigVerify=!0),t&&typeof t==`object`&&`innerInstructions`in t&&(c.innerInstructions=t.innerInstructions);let l=[s,c],u=N(await this._rpcRequest(`simulateTransaction`,l),oo);if(`error`in u){let e;throw`data`in u.error&&(e=u.error.data.logs,e&&Array.isArray(e))&&``+e.join(`
3
3
  `),new Sa({action:`simulate`,signature:``,transactionMessage:u.error.message,logs:e})}return u.result}async sendTransaction(e,t,n){if(`version`in e){if(t&&Array.isArray(t))throw Error(`Invalid arguments`);let n=e.serialize();return await this.sendRawTransaction(n,t)}if(t===void 0||!Array.isArray(t))throw Error(`Invalid arguments`);let r=t;if(e.nonceInfo)e.sign(...r);else{let t=this._disableBlockhashCaching;for(;;){let n=await this._blockhashWithExpiryBlockHeight(t);if(e.lastValidBlockHeight=n.lastValidBlockHeight,e.recentBlockhash=n.blockhash,e.sign(...r),!e.signature)throw Error(`!signature`);let i=e.signature.toString(`base64`);if(this._blockhashInfo.transactionSignatures.includes(i))t=!0;else{this._blockhashInfo.transactionSignatures.push(i);break}}}let i=e.serialize();return await this.sendRawTransaction(i,n)}async sendRawTransaction(e,t){let n=U(e).toString(`base64`);return await this.sendEncodedTransaction(n,t)}async sendEncodedTransaction(e,t){let n={encoding:`base64`},r=t&&t.skipPreflight,i=r===!0?`processed`:t&&t.preflightCommitment||this.commitment;t&&t.maxRetries!=null&&(n.maxRetries=t.maxRetries),t&&t.minContextSlot!=null&&(n.minContextSlot=t.minContextSlot),r&&(n.skipPreflight=r),i&&(n.preflightCommitment=i);let a=[e,n],o=N(await this._rpcRequest(`sendTransaction`,a),Ts);if(`error`in o){let e;throw`data`in o.error&&(e=o.error.data.logs),new Sa({action:r?`send`:`simulate`,signature:``,transactionMessage:o.error.message,logs:e})}return o.result}_wsOnOpen(){this._rpcWebSocketConnected=!0,this._rpcWebSocketHeartbeat=setInterval(()=>{(async()=>{try{await this._rpcWebSocket.notify(`ping`)}catch{}})()},5e3),this._updateSubscriptions()}_wsOnError(e){this._rpcWebSocketConnected=!1}_wsOnClose(e){if(this._rpcWebSocketConnected=!1,this._rpcWebSocketGeneration=(this._rpcWebSocketGeneration+1)%(2**53-1),this._rpcWebSocketIdleTimeout&&=(clearTimeout(this._rpcWebSocketIdleTimeout),null),this._rpcWebSocketHeartbeat&&=(clearInterval(this._rpcWebSocketHeartbeat),null),e===1e3){this._updateSubscriptions();return}this._subscriptionCallbacksByServerSubscriptionId={},Object.entries(this._subscriptionsByHash).forEach(([e,t])=>{this._setSubscription(e,{...t,state:`pending`})})}_setSubscription(e,t){let n=this._subscriptionsByHash[e]?.state;if(this._subscriptionsByHash[e]=t,n!==t.state){let n=this._subscriptionStateChangeCallbacksByHash[e];n&&n.forEach(e=>{try{e(t.state)}catch{}})}}_onSubscriptionStateChange(e,t){let n=this._subscriptionHashByClientSubscriptionId[e];if(n==null)return()=>{};let r=this._subscriptionStateChangeCallbacksByHash[n]||=new Set;return r.add(t),()=>{r.delete(t),r.size===0&&delete this._subscriptionStateChangeCallbacksByHash[n]}}async _updateSubscriptions(){if(Object.keys(this._subscriptionsByHash).length===0){this._rpcWebSocketConnected&&(this._rpcWebSocketConnected=!1,this._rpcWebSocketIdleTimeout=setTimeout(()=>{this._rpcWebSocketIdleTimeout=null;try{this._rpcWebSocket.close()}catch(e){e instanceof Error}},500));return}if(this._rpcWebSocketIdleTimeout!==null&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketConnected=!0),!this._rpcWebSocketConnected){this._rpcWebSocket.connect();return}let e=this._rpcWebSocketGeneration,t=()=>e===this._rpcWebSocketGeneration;await Promise.all(Object.keys(this._subscriptionsByHash).map(async e=>{let n=this._subscriptionsByHash[e];if(n!==void 0)switch(n.state){case`pending`:case`unsubscribed`:if(n.callbacks.size===0){delete this._subscriptionsByHash[e],n.state===`unsubscribed`&&delete this._subscriptionCallbacksByServerSubscriptionId[n.serverSubscriptionId],await this._updateSubscriptions();return}await(async()=>{let{args:r,method:i}=n;try{this._setSubscription(e,{...n,state:`subscribing`});let t=await this._rpcWebSocket.call(i,r);this._setSubscription(e,{...n,serverSubscriptionId:t,state:`subscribed`}),this._subscriptionCallbacksByServerSubscriptionId[t]=n.callbacks,await this._updateSubscriptions()}catch{if(!t())return;this._setSubscription(e,{...n,state:`pending`}),await this._updateSubscriptions()}})();break;case`subscribed`:n.callbacks.size===0&&await(async()=>{let{serverSubscriptionId:r,unsubscribeMethod:i}=n;if(this._subscriptionsAutoDisposedByRpc.has(r))this._subscriptionsAutoDisposedByRpc.delete(r);else{this._setSubscription(e,{...n,state:`unsubscribing`}),this._setSubscription(e,{...n,state:`unsubscribing`});try{await this._rpcWebSocket.call(i,[r])}catch(r){if(r instanceof Error,!t())return;this._setSubscription(e,{...n,state:`subscribed`}),await this._updateSubscriptions();return}}this._setSubscription(e,{...n,state:`unsubscribed`}),await this._updateSubscriptions()})()}}))}_handleServerNotification(e,t){let n=this._subscriptionCallbacksByServerSubscriptionId[e];n!==void 0&&n.forEach(e=>{try{e(...t)}catch{}})}_wsOnAccountNotification(e){let{result:t,subscription:n}=N(e,jo);this._handleServerNotification(n,[t.value,t.context])}_makeSubscription(e,t){let n=this._nextClientSubscriptionId++,r=Na([e.method,t]),i=this._subscriptionsByHash[r];return i===void 0?this._subscriptionsByHash[r]={...e,args:t,callbacks:new Set([e.callback]),state:`pending`}:i.callbacks.add(e.callback),this._subscriptionHashByClientSubscriptionId[n]=r,this._subscriptionDisposeFunctionsByClientSubscriptionId[n]=async()=>{delete this._subscriptionDisposeFunctionsByClientSubscriptionId[n],delete this._subscriptionHashByClientSubscriptionId[n];let t=this._subscriptionsByHash[r];mi(t!==void 0,`Could not find a \`Subscription\` when tearing down client subscription #${n}`),t.callbacks.delete(e.callback),await this._updateSubscriptions()},this._updateSubscriptions(),n}onAccountChange(e,t,n){let{commitment:r,config:i}=Di(n),a=this._buildArgs([e.toBase58()],r||this._commitment||`finalized`,`base64`,i);return this._makeSubscription({callback:t,method:`accountSubscribe`,unsubscribeMethod:`accountUnsubscribe`},a)}async removeAccountChangeListener(e){await this._unsubscribeClientSubscription(e,`account change`)}_wsOnProgramAccountNotification(e){let{result:t,subscription:n}=N(e,No);this._handleServerNotification(n,[{accountId:t.value.pubkey,accountInfo:t.value.account},t.context])}onProgramAccountChange(e,t,n,r){let{commitment:i,config:a}=Di(n),o=this._buildArgs([e.toBase58()],i||this._commitment||`finalized`,`base64`,a||(r?{filters:Oi(r)}:void 0));return this._makeSubscription({callback:t,method:`programSubscribe`,unsubscribeMethod:`programUnsubscribe`},o)}async removeProgramAccountChangeListener(e){await this._unsubscribeClientSubscription(e,`program account change`)}onLogs(e,t,n){let r=this._buildArgs([typeof e==`object`?{mentions:[e.toString()]}:e],n||this._commitment||`finalized`);return this._makeSubscription({callback:t,method:`logsSubscribe`,unsubscribeMethod:`logsUnsubscribe`},r)}async removeOnLogsListener(e){await this._unsubscribeClientSubscription(e,`logs`)}_wsOnLogsNotification(e){let{result:t,subscription:n}=N(e,Ds);this._handleServerNotification(n,[t.value,t.context])}_wsOnSlotNotification(e){let{result:t,subscription:n}=N(e,Fo);this._handleServerNotification(n,[t])}onSlotChange(e){return this._makeSubscription({callback:e,method:`slotSubscribe`,unsubscribeMethod:`slotUnsubscribe`},[])}async removeSlotChangeListener(e){await this._unsubscribeClientSubscription(e,`slot change`)}_wsOnSlotUpdatesNotification(e){let{result:t,subscription:n}=N(e,Lo);this._handleServerNotification(n,[t])}onSlotUpdate(e){return this._makeSubscription({callback:e,method:`slotsUpdatesSubscribe`,unsubscribeMethod:`slotsUpdatesUnsubscribe`},[])}async removeSlotUpdateListener(e){await this._unsubscribeClientSubscription(e,`slot update`)}async _unsubscribeClientSubscription(e,t){let n=this._subscriptionDisposeFunctionsByClientSubscriptionId[e];n&&await n()}_buildArgs(e,t,n,r){let i=t||this._commitment;if(i||n||r){let t={};n&&(t.encoding=n),i&&(t.commitment=i),r&&(t=Object.assign(t,r)),e.push(t)}return e}_buildArgsAtLeastConfirmed(e,t,n,r){let i=t||this._commitment;if(i&&![`confirmed`,`finalized`].includes(i))throw Error("Using Connection with default commitment: `"+this._commitment+"`, but method requires at least `confirmed`");return this._buildArgs(e,t,n,r)}_wsOnSignatureNotification(e){let{result:t,subscription:n}=N(e,Ro);t.value!==`receivedSignature`&&this._subscriptionsAutoDisposedByRpc.add(n),this._handleServerNotification(n,t.value===`receivedSignature`?[{type:`received`},t.context]:[{type:`status`,result:t.value},t.context])}onSignature(e,t,n){let r=this._buildArgs([e],n||this._commitment||`finalized`),i=this._makeSubscription({callback:(e,n)=>{if(e.type===`status`){t(e.result,n);try{this.removeSignatureListener(i)}catch{}}},method:`signatureSubscribe`,unsubscribeMethod:`signatureUnsubscribe`},r);return i}onSignatureWithOptions(e,t,n){let{commitment:r,...i}={...n,commitment:n&&n.commitment||this._commitment||`finalized`},a=this._buildArgs([e],r,void 0,i),o=this._makeSubscription({callback:(e,n)=>{t(e,n);try{this.removeSignatureListener(o)}catch{}},method:`signatureSubscribe`,unsubscribeMethod:`signatureUnsubscribe`},a);return o}async removeSignatureListener(e){await this._unsubscribeClientSubscription(e,`signature result`)}_wsOnRootNotification(e){let{result:t,subscription:n}=N(e,zo);this._handleServerNotification(n,[t])}onRootChange(e){return this._makeSubscription({callback:e,method:`rootSubscribe`,unsubscribeMethod:`rootUnsubscribe`},[])}async removeRootChangeListener(e){await this._unsubscribeClientSubscription(e,`root change`)}},As=class e{constructor(e){this._keypair=void 0,this._keypair=e??Hi()}static generate(){return new e(Hi())}static fromSecretKey(t,n){if(t.byteLength!==64)throw Error(`bad secret key size`);let r=t.slice(32,64);if(!n||!n.skipValidation){let e=t.slice(0,32),n=Ui(e);for(let e=0;e<32;e++)if(r[e]!==n[e])throw Error(`provided secretKey is invalid`)}return new e({publicKey:r,secretKey:t})}static fromSeed(t){let n=Ui(t),r=new Uint8Array(64);return r.set(t),r.set(n,32),new e({publicKey:n,secretKey:r})}get publicKey(){return new W(this._keypair.publicKey)}get secretKey(){return new Uint8Array(this._keypair.secretKey)}},js=Object.freeze({CreateLookupTable:{index:0,layout:H.struct([H.u32(`instruction`),yi(`recentSlot`),H.u8(`bumpSeed`)])},FreezeLookupTable:{index:1,layout:H.struct([H.u32(`instruction`)])},ExtendLookupTable:{index:2,layout:H.struct([H.u32(`instruction`),yi(),H.seq(G(),H.offset(H.u32(),-8),`addresses`)])},DeactivateLookupTable:{index:3,layout:H.struct([H.u32(`instruction`)])},CloseLookupTable:{index:4,layout:H.struct([H.u32(`instruction`)])}}),Ms=class{constructor(){}static createLookupTable(e){let[t,n]=W.findProgramAddressSync([e.authority.toBuffer(),En().encode(e.recentSlot)],this.programId),r=js.CreateLookupTable,i=B(r,{recentSlot:BigInt(e.recentSlot),bumpSeed:n}),a=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1},{pubkey:e.payer,isSigner:!0,isWritable:!0},{pubkey:Oa.programId,isSigner:!1,isWritable:!1}];return[new ma({programId:this.programId,keys:a,data:i}),t]}static freezeLookupTable(e){let t=js.FreezeLookupTable,n=B(t),r=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return new ma({programId:this.programId,keys:r,data:n})}static extendLookupTable(e){let t=js.ExtendLookupTable,n=B(t,{addresses:e.addresses.map(e=>e.toBytes())}),r=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return e.payer&&r.push({pubkey:e.payer,isSigner:!0,isWritable:!0},{pubkey:Oa.programId,isSigner:!1,isWritable:!1}),new ma({programId:this.programId,keys:r,data:n})}static deactivateLookupTable(e){let t=js.DeactivateLookupTable,n=B(t),r=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return new ma({programId:this.programId,keys:r,data:n})}static closeLookupTable(e){let t=js.CloseLookupTable,n=B(t),r=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1},{pubkey:e.recipient,isSigner:!1,isWritable:!0}];return new ma({programId:this.programId,keys:r,data:n})}},Ms.programId=new W(`AddressLookupTab1e1111111111111111111111111`),Ns=Object.freeze({RequestUnits:{index:0,layout:H.struct([H.u8(`instruction`),H.u32(`units`),H.u32(`additionalFee`)])},RequestHeapFrame:{index:1,layout:H.struct([H.u8(`instruction`),H.u32(`bytes`)])},SetComputeUnitLimit:{index:2,layout:H.struct([H.u8(`instruction`),H.u32(`units`)])},SetComputeUnitPrice:{index:3,layout:H.struct([H.u8(`instruction`),yi(`microLamports`)])}}),Ps=class{constructor(){}static requestUnits(e){let t=Ns.RequestUnits,n=B(t,e);return new ma({keys:[],programId:this.programId,data:n})}static requestHeapFrame(e){let t=Ns.RequestHeapFrame,n=B(t,e);return new ma({keys:[],programId:this.programId,data:n})}static setComputeUnitLimit(e){let t=Ns.SetComputeUnitLimit,n=B(t,e);return new ma({keys:[],programId:this.programId,data:n})}static setComputeUnitPrice(e){let t=Ns.SetComputeUnitPrice,n=B(t,{microLamports:BigInt(e.microLamports)});return new ma({keys:[],programId:this.programId,data:n})}},Ps.programId=new W(`ComputeBudget111111111111111111111111111111`),Fs=64,Is=32,Ls=64,Rs=H.struct([H.u8(`numSignatures`),H.u8(`padding`),H.u16(`signatureOffset`),H.u16(`signatureInstructionIndex`),H.u16(`publicKeyOffset`),H.u16(`publicKeyInstructionIndex`),H.u16(`messageDataOffset`),H.u16(`messageDataSize`),H.u16(`messageInstructionIndex`)]),zs=class e{constructor(){}static createInstructionWithPublicKey(t){let{publicKey:n,message:r,signature:i,instructionIndex:a}=t;mi(n.length===Is,`Public Key must be ${Is} bytes but received ${n.length} bytes`),mi(i.length===Ls,`Signature must be ${Ls} bytes but received ${i.length} bytes`);let o=Rs.span,s=o+n.length,c=s+i.length,l=_.alloc(c+r.length),u=a??65535;return Rs.encode({numSignatures:1,padding:0,signatureOffset:s,signatureInstructionIndex:u,publicKeyOffset:o,publicKeyInstructionIndex:u,messageDataOffset:c,messageDataSize:r.length,messageInstructionIndex:u},l),l.fill(n,o),l.fill(i,s),l.fill(r,c),new ma({keys:[],programId:e.programId,data:l})}static createInstructionWithPrivateKey(e){let{privateKey:t,message:n,instructionIndex:r}=e;mi(t.length===Fs,`Private key must be ${Fs} bytes but received ${t.length} bytes`);try{let e=As.fromSecretKey(t),i=e.publicKey.toBytes(),a=Wi(n,e.secretKey);return this.createInstructionWithPublicKey({publicKey:i,message:n,signature:a,instructionIndex:r})}catch(e){throw Error(`Error creating instruction; ${e}`)}}},zs.programId=new W(`Ed25519SigVerify111111111111111111111111111`),Bs=(e,t)=>{let n=C.sign(e,t);return[n.toCompactRawBytes(),n.recovery]},C.utils.isValidPrivateKey,Vs=C.getPublicKey,Hs=32,Us=20,Ws=64,Gs=H.struct([H.u8(`numSignatures`),H.u16(`signatureOffset`),H.u8(`signatureInstructionIndex`),H.u16(`ethAddressOffset`),H.u8(`ethAddressInstructionIndex`),H.u16(`messageDataOffset`),H.u16(`messageDataSize`),H.u8(`messageInstructionIndex`),H.blob(20,`ethAddress`),H.blob(64,`signature`),H.u8(`recoveryId`)]),Ks=class e{constructor(){}static publicKeyToEthAddress(e){mi(e.length===Ws,`Public key must be ${Ws} bytes but received ${e.length} bytes`);try{return _.from(h(U(e))).slice(-20)}catch(e){throw Error(`Error constructing Ethereum address: ${e}`)}}static createInstructionWithPublicKey(t){let{publicKey:n,message:r,signature:i,recoveryId:a,instructionIndex:o}=t;return e.createInstructionWithEthAddress({ethAddress:e.publicKeyToEthAddress(n),message:r,signature:i,recoveryId:a,instructionIndex:o})}static createInstructionWithEthAddress(t){let{ethAddress:n,message:r,signature:i,recoveryId:a,instructionIndex:o=0}=t,s;s=typeof n==`string`?n.startsWith(`0x`)?_.from(n.substr(2),`hex`):_.from(n,`hex`):n,mi(s.length===Us,`Address must be ${Us} bytes but received ${s.length} bytes`);let c=12+s.length,l=c+i.length+1,u=_.alloc(Gs.span+r.length);return Gs.encode({numSignatures:1,signatureOffset:c,signatureInstructionIndex:o,ethAddressOffset:12,ethAddressInstructionIndex:o,messageDataOffset:l,messageDataSize:r.length,messageInstructionIndex:o,signature:U(i),ethAddress:U(s),recoveryId:a},u),u.fill(U(r),Gs.span),new ma({keys:[],programId:e.programId,data:u})}static createInstructionWithPrivateKey(e){let{privateKey:t,message:n,instructionIndex:r}=e;mi(t.length===Hs,`Private key must be ${Hs} bytes but received ${t.length} bytes`);try{let e=U(t),i=Vs(e,!1).slice(1),a=_.from(h(U(n))),[o,s]=Bs(a,e);return this.createInstructionWithPublicKey({publicKey:i,message:n,signature:o,recoveryId:s,instructionIndex:r})}catch(e){throw Error(`Error creating instruction; ${e}`)}}},Ks.programId=new W(`KeccakSecp256k11111111111111111111111111111`),Js=new W(`StakeConfig11111111111111111111111111111111`),Ys=class{constructor(e,t,n){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=e,this.epoch=t,this.custodian=n}},qs=Ys,Ys.default=new qs(0,0,W.default),Xs=Object.freeze({Initialize:{index:0,layout:H.struct([H.u32(`instruction`),ra(),ia()])},Authorize:{index:1,layout:H.struct([H.u32(`instruction`),G(`newAuthorized`),H.u32(`stakeAuthorizationType`)])},Delegate:{index:2,layout:H.struct([H.u32(`instruction`)])},Split:{index:3,layout:H.struct([H.u32(`instruction`),H.ns64(`lamports`)])},Withdraw:{index:4,layout:H.struct([H.u32(`instruction`),H.ns64(`lamports`)])},Deactivate:{index:5,layout:H.struct([H.u32(`instruction`)])},Merge:{index:7,layout:H.struct([H.u32(`instruction`)])},AuthorizeWithSeed:{index:8,layout:H.struct([H.u32(`instruction`),G(`newAuthorized`),H.u32(`stakeAuthorizationType`),na(`authoritySeed`),G(`authorityOwner`)])}}),Object.freeze({Staker:{index:0},Withdrawer:{index:1}}),Zs=class{constructor(){}static initialize(e){let{stakePubkey:t,authorized:n,lockup:r}=e,i=r||Ys.default,a=Xs.Initialize,o=B(a,{authorized:{staker:U(n.staker.toBuffer()),withdrawer:U(n.withdrawer.toBuffer())},lockup:{unixTimestamp:i.unixTimestamp,epoch:i.epoch,custodian:U(i.custodian.toBuffer())}}),s={keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:ba,isSigner:!1,isWritable:!1}],programId:this.programId,data:o};return new ma(s)}static createAccountWithSeed(e){let t=new ha;t.add(Oa.createAccountWithSeed({fromPubkey:e.fromPubkey,newAccountPubkey:e.stakePubkey,basePubkey:e.basePubkey,seed:e.seed,lamports:e.lamports,space:this.space,programId:this.programId}));let{stakePubkey:n,authorized:r,lockup:i}=e;return t.add(this.initialize({stakePubkey:n,authorized:r,lockup:i}))}static createAccount(e){let t=new ha;t.add(Oa.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.stakePubkey,lamports:e.lamports,space:this.space,programId:this.programId}));let{stakePubkey:n,authorized:r,lockup:i}=e;return t.add(this.initialize({stakePubkey:n,authorized:r,lockup:i}))}static delegate(e){let{stakePubkey:t,authorizedPubkey:n,votePubkey:r}=e,i=Xs.Delegate,a=B(i);return new ha().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!1},{pubkey:va,isSigner:!1,isWritable:!1},{pubkey:xa,isSigner:!1,isWritable:!1},{pubkey:Js,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:a})}static authorize(e){let{stakePubkey:t,authorizedPubkey:n,newAuthorizedPubkey:r,stakeAuthorizationType:i,custodianPubkey:a}=e,o=Xs.Authorize,s=B(o,{newAuthorized:U(r.toBuffer()),stakeAuthorizationType:i.index}),c=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:va,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}];return a&&c.push({pubkey:a,isSigner:!0,isWritable:!1}),new ha().add({keys:c,programId:this.programId,data:s})}static authorizeWithSeed(e){let{stakePubkey:t,authorityBase:n,authoritySeed:r,authorityOwner:i,newAuthorizedPubkey:a,stakeAuthorizationType:o,custodianPubkey:s}=e,c=Xs.AuthorizeWithSeed,l=B(c,{newAuthorized:U(a.toBuffer()),stakeAuthorizationType:o.index,authoritySeed:r,authorityOwner:U(i.toBuffer())}),u=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1},{pubkey:va,isSigner:!1,isWritable:!1}];return s&&u.push({pubkey:s,isSigner:!0,isWritable:!1}),new ha().add({keys:u,programId:this.programId,data:l})}static splitInstruction(e){let{stakePubkey:t,authorizedPubkey:n,splitStakePubkey:r,lamports:i}=e,a=Xs.Split,o=B(a,{lamports:i});return new ma({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:o})}static split(e,t){let n=new ha;return n.add(Oa.createAccount({fromPubkey:e.authorizedPubkey,newAccountPubkey:e.splitStakePubkey,lamports:t,space:this.space,programId:this.programId})),n.add(this.splitInstruction(e))}static splitWithSeed(e,t){let{stakePubkey:n,authorizedPubkey:r,splitStakePubkey:i,basePubkey:a,seed:o,lamports:s}=e,c=new ha;return c.add(Oa.allocate({accountPubkey:i,basePubkey:a,seed:o,space:this.space,programId:this.programId})),t&&t>0&&c.add(Oa.transfer({fromPubkey:e.authorizedPubkey,toPubkey:i,lamports:t})),c.add(this.splitInstruction({stakePubkey:n,authorizedPubkey:r,splitStakePubkey:i,lamports:s}))}static merge(e){let{stakePubkey:t,sourceStakePubKey:n,authorizedPubkey:r}=e,i=Xs.Merge,a=B(i);return new ha().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!0},{pubkey:va,isSigner:!1,isWritable:!1},{pubkey:xa,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:a})}static withdraw(e){let{stakePubkey:t,authorizedPubkey:n,toPubkey:r,lamports:i,custodianPubkey:a}=e,o=Xs.Withdraw,s=B(o,{lamports:i}),c=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:va,isSigner:!1,isWritable:!1},{pubkey:xa,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return a&&c.push({pubkey:a,isSigner:!0,isWritable:!1}),new ha().add({keys:c,programId:this.programId,data:s})}static deactivate(e){let{stakePubkey:t,authorizedPubkey:n}=e,r=Xs.Deactivate,i=B(r);return new ha().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:va,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:i})}},Zs.programId=new W(`Stake11111111111111111111111111111111111111`),Zs.space=200,Qs=Object.freeze({InitializeAccount:{index:0,layout:H.struct([H.u32(`instruction`),aa()])},Authorize:{index:1,layout:H.struct([H.u32(`instruction`),G(`newAuthorized`),H.u32(`voteAuthorizationType`)])},Withdraw:{index:3,layout:H.struct([H.u32(`instruction`),H.ns64(`lamports`)])},UpdateValidatorIdentity:{index:4,layout:H.struct([H.u32(`instruction`)])},AuthorizeWithSeed:{index:10,layout:H.struct([H.u32(`instruction`),oa()])}}),Object.freeze({Voter:{index:0},Withdrawer:{index:1}}),$s=class e{constructor(){}static initializeAccount(e){let{votePubkey:t,nodePubkey:n,voteInit:r}=e,i=Qs.InitializeAccount,a=B(i,{voteInit:{nodePubkey:U(r.nodePubkey.toBuffer()),authorizedVoter:U(r.authorizedVoter.toBuffer()),authorizedWithdrawer:U(r.authorizedWithdrawer.toBuffer()),commission:r.commission}}),o={keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:ba,isSigner:!1,isWritable:!1},{pubkey:va,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:a};return new ma(o)}static createAccount(e){let t=new ha;return t.add(Oa.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.votePubkey,lamports:e.lamports,space:this.space,programId:this.programId})),t.add(this.initializeAccount({votePubkey:e.votePubkey,nodePubkey:e.voteInit.nodePubkey,voteInit:e.voteInit}))}static authorize(e){let{votePubkey:t,authorizedPubkey:n,newAuthorizedPubkey:r,voteAuthorizationType:i}=e,a=Qs.Authorize,o=B(a,{newAuthorized:U(r.toBuffer()),voteAuthorizationType:i.index}),s=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:va,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return new ha().add({keys:s,programId:this.programId,data:o})}static authorizeWithSeed(e){let{currentAuthorityDerivedKeyBasePubkey:t,currentAuthorityDerivedKeyOwnerPubkey:n,currentAuthorityDerivedKeySeed:r,newAuthorizedPubkey:i,voteAuthorizationType:a,votePubkey:o}=e,s=Qs.AuthorizeWithSeed,c=B(s,{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:U(n.toBuffer()),currentAuthorityDerivedKeySeed:r,newAuthorized:U(i.toBuffer()),voteAuthorizationType:a.index}}),l=[{pubkey:o,isSigner:!1,isWritable:!0},{pubkey:va,isSigner:!1,isWritable:!1},{pubkey:t,isSigner:!0,isWritable:!1}];return new ha().add({keys:l,programId:this.programId,data:c})}static withdraw(e){let{votePubkey:t,authorizedWithdrawerPubkey:n,lamports:r,toPubkey:i}=e,a=Qs.Withdraw,o=B(a,{lamports:r}),s=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}];return new ha().add({keys:s,programId:this.programId,data:o})}static safeWithdraw(t,n,r){if(t.lamports>n-r)throw Error(`Withdraw will leave vote account with insufficient funds.`);return e.withdraw(t)}static updateValidatorIdentity(e){let{votePubkey:t,authorizedWithdrawerPubkey:n,nodePubkey:r}=e,i=Qs.UpdateValidatorIdentity,a=B(i),o=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return new ha().add({keys:o,programId:this.programId,data:a})}},$s.programId=new W(`Vote111111111111111111111111111111111111111`),$s.space=3762,new W(`Va1idator1nfo111111111111111111111111111111`),z({name:R(),website:L(R()),details:L(R()),iconUrl:L(R()),keybaseUsername:L(R())}),new W(`Vote111111111111111111111111111111111111111`),H.struct([G(`nodePubkey`),G(`authorizedWithdrawer`),H.u8(`commission`),H.nu64(),H.seq(H.struct([H.nu64(`slot`),H.u32(`confirmationCount`)]),H.offset(H.u32(),-8),`votes`),H.u8(`rootSlotValid`),H.nu64(`rootSlot`),H.nu64(),H.seq(H.struct([H.nu64(`epoch`),G(`authorizedVoter`)]),H.offset(H.u32(),-8),`authorizedVoters`),H.struct([H.seq(H.struct([G(`authorizedPubkey`),H.nu64(`epochOfLastAuthorizedSwitch`),H.nu64(`targetEpoch`)]),32,`buf`),H.nu64(`idx`),H.u8(`isEmpty`)],`priorVoters`),H.nu64(),H.seq(H.struct([H.nu64(`epoch`),H.nu64(`credits`),H.nu64(`prevCredits`)]),H.offset(H.u32(),-8),`epochCredits`),H.struct([H.nu64(`slot`),H.nu64(`timestamp`)],`lastTimestamp`)]),ec={http:{devnet:`http://api.devnet.solana.com`,testnet:`http://api.testnet.solana.com`,"mainnet-beta":`http://api.mainnet-beta.solana.com/`},https:{devnet:`https://api.devnet.solana.com`,testnet:`https://api.testnet.solana.com`,"mainnet-beta":`https://api.mainnet-beta.solana.com/`}}}));tc();var nc=`Phantom`,rc=class extends Pt{constructor(e={}){super(),this.name=nc,this.url=`https://phantom.app`,this.icon=`data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMDgiIGhlaWdodD0iMTA4IiB2aWV3Qm94PSIwIDAgMTA4IDEwOCIgZmlsbD0ibm9uZSI+CjxyZWN0IHdpZHRoPSIxMDgiIGhlaWdodD0iMTA4IiByeD0iMjYiIGZpbGw9IiNBQjlGRjIiLz4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik00Ni41MjY3IDY5LjkyMjlDNDIuMDA1NCA3Ni44NTA5IDM0LjQyOTIgODUuNjE4MiAyNC4zNDggODUuNjE4MkMxOS41ODI0IDg1LjYxODIgMTUgODMuNjU2MyAxNSA3NS4xMzQyQzE1IDUzLjQzMDUgNDQuNjMyNiAxOS44MzI3IDcyLjEyNjggMTkuODMyN0M4Ny43NjggMTkuODMyNyA5NCAzMC42ODQ2IDk0IDQzLjAwNzlDOTQgNTguODI1OCA4My43MzU1IDc2LjkxMjIgNzMuNTMyMSA3Ni45MTIyQzcwLjI5MzkgNzYuOTEyMiA2OC43MDUzIDc1LjEzNDIgNjguNzA1MyA3Mi4zMTRDNjguNzA1MyA3MS41NzgzIDY4LjgyNzUgNzAuNzgxMiA2OS4wNzE5IDY5LjkyMjlDNjUuNTg5MyA3NS44Njk5IDU4Ljg2ODUgODEuMzg3OCA1Mi41NzU0IDgxLjM4NzhDNDcuOTkzIDgxLjM4NzggNDUuNjcxMyA3OC41MDYzIDQ1LjY3MTMgNzQuNDU5OEM0NS42NzEzIDcyLjk4ODQgNDUuOTc2OCA3MS40NTU2IDQ2LjUyNjcgNjkuOTIyOVpNODMuNjc2MSA0Mi41Nzk0QzgzLjY3NjEgNDYuMTcwNCA4MS41NTc1IDQ3Ljk2NTggNzkuMTg3NSA0Ny45NjU4Qzc2Ljc4MTYgNDcuOTY1OCA3NC42OTg5IDQ2LjE3MDQgNzQuNjk4OSA0Mi41Nzk0Qzc0LjY5ODkgMzguOTg4NSA3Ni43ODE2IDM3LjE5MzEgNzkuMTg3NSAzNy4xOTMxQzgxLjU1NzUgMzcuMTkzMSA4My42NzYxIDM4Ljk4ODUgODMuNjc2MSA0Mi41Nzk0Wk03MC4yMTAzIDQyLjU3OTVDNzAuMjEwMyA0Ni4xNzA0IDY4LjA5MTYgNDcuOTY1OCA2NS43MjE2IDQ3Ljk2NThDNjMuMzE1NyA0Ny45NjU4IDYxLjIzMyA0Ni4xNzA0IDYxLjIzMyA0Mi41Nzk1QzYxLjIzMyAzOC45ODg1IDYzLjMxNTcgMzcuMTkzMSA2NS43MjE2IDM3LjE5MzFDNjguMDkxNiAzNy4xOTMxIDcwLjIxMDMgMzguOTg4NSA3MC4yMTAzIDQyLjU3OTVaIiBmaWxsPSIjRkZGREY4Ii8+Cjwvc3ZnPg==`,this.supportedTransactionVersions=new Set([`legacy`,0]),this._readyState=typeof window>`u`||typeof document>`u`?Ot.Unsupported:Ot.NotDetected,this._disconnected=()=>{let e=this._wallet;e&&(e.off(`disconnect`,this._disconnected),e.off(`accountChanged`,this._accountChanged),this._wallet=null,this._publicKey=null,this.emit(`error`,new vt),this.emit(`disconnect`))},this._accountChanged=e=>{let t=this._publicKey;if(t){try{e=new W(e.toBytes())}catch(e){this.emit(`error`,new xt(e?.message,e));return}t.equals(e)||(this._publicKey=e,this.emit(`connect`,e))}},this._connecting=!1,this._wallet=null,this._publicKey=null,this._readyState!==Ot.Unsupported&&(jt()?(this._readyState=Ot.Loadable,this.emit(`readyStateChange`,this._readyState)):At(()=>window?.isPhantomInstalled&&(window.phantom?.solana?.isPhantom||window.solana?.isPhantom)?(this._readyState=Ot.Installed,this.emit(`readyStateChange`,this._readyState),!0):!1))}get publicKey(){return this._publicKey}get connecting(){return this._connecting}get readyState(){return this._readyState}async autoConnect(){this.readyState===Ot.Installed&&await this.connect()}async connect(){try{if(this.connected||this.connecting)return;if(this.readyState===Ot.Loadable){let e=encodeURIComponent(window.location.href),t=encodeURIComponent(window.location.origin);window.location.href=`https://phantom.app/ul/browse/${e}?ref=${t}`;return}if(this.readyState!==Ot.Installed)throw new ht;this._connecting=!0;let e=window.phantom?.solana||window.solana;if(!e.isConnected)try{await e.connect()}catch(e){throw new _t(e?.message,e)}if(!e.publicKey)throw new bt;let t;try{t=new W(e.publicKey.toBytes())}catch(e){throw new xt(e?.message,e)}e.on(`disconnect`,this._disconnected),e.on(`accountChanged`,this._accountChanged),this._wallet=e,this._publicKey=t,this.emit(`connect`,t)}catch(e){throw this.emit(`error`,e),e}finally{this._connecting=!1}}async disconnect(){let e=this._wallet;if(e){e.off(`disconnect`,this._disconnected),e.off(`accountChanged`,this._accountChanged),this._wallet=null,this._publicKey=null;try{await e.disconnect()}catch(e){this.emit(`error`,new yt(e?.message,e))}}this.emit(`disconnect`)}async sendTransaction(e,t,n={}){try{let r=this._wallet;if(!r)throw new St;try{let{signers:i,...a}=n;Mt(e)?i?.length&&e.sign(i):(e=await this.prepareTransaction(e,t,a),i?.length&&e.partialSign(...i)),a.preflightCommitment=a.preflightCommitment||t.commitment;let{signature:o}=await r.signAndSendTransaction(e,a);return o}catch(e){throw e instanceof mt?e:new Ct(e?.message,e)}}catch(e){throw this.emit(`error`,e),e}}async signTransaction(e){try{let t=this._wallet;if(!t)throw new St;try{return await t.signTransaction(e)||e}catch(e){throw new wt(e?.message,e)}}catch(e){throw this.emit(`error`,e),e}}async signAllTransactions(e){try{let t=this._wallet;if(!t)throw new St;try{return await t.signAllTransactions(e)||e}catch(e){throw new wt(e?.message,e)}}catch(e){throw this.emit(`error`,e),e}}async signMessage(e){try{let t=this._wallet;if(!t)throw new St;try{let{signature:n}=await t.signMessage(e);return n}catch(e){throw new Tt(e?.message,e)}}catch(e){throw this.emit(`error`,e),e}}};tc();var ic=`Trust`,ac=class extends Pt{constructor(e={}){super(),this.name=ic,this.url=`https://trustwallet.com`,this.icon=`data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48c3ZnIGlkPSJMYXllcl8xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2aWV3Qm94PSIwIDAgMTkyMCAxMDgwIj48ZGVmcz48c3R5bGU+LmNscy0xe2ZpbGw6dXJsKCNsaW5lYXItZ3JhZGllbnQpO30uY2xzLTJ7ZmlsbDojMDUwMGZmO308L3N0eWxlPjxsaW5lYXJHcmFkaWVudCBpZD0ibGluZWFyLWdyYWRpZW50IiB4MT0iMTEyMy4yNiIgeTE9IjE4NjUuNzgiIHgyPSI5NTQuNjEiIHkyPSIxMzM3LjUiIGdyYWRpZW50VHJhbnNmb3JtPSJ0cmFuc2xhdGUoMCAyMTgyKSBzY2FsZSgxIC0xKSIgZ3JhZGllbnRVbml0cz0idXNlclNwYWNlT25Vc2UiPjxzdG9wIG9mZnNldD0iLjAyIiBzdG9wLWNvbG9yPSJibHVlIi8+PHN0b3Agb2Zmc2V0PSIuMDgiIHN0b3AtY29sb3I9IiMwMDk0ZmYiLz48c3RvcCBvZmZzZXQ9Ii4xNiIgc3RvcC1jb2xvcj0iIzQ4ZmY5MSIvPjxzdG9wIG9mZnNldD0iLjQyIiBzdG9wLWNvbG9yPSIjMDA5NGZmIi8+PHN0b3Agb2Zmc2V0PSIuNjgiIHN0b3AtY29sb3I9IiMwMDM4ZmYiLz48c3RvcCBvZmZzZXQ9Ii45IiBzdG9wLWNvbG9yPSIjMDUwMGZmIi8+PC9saW5lYXJHcmFkaWVudD48L2RlZnM+PHBhdGggY2xhc3M9ImNscy0yIiBkPSJtNzM4LjcxLDQyMy40MWwyMjEuNDUtNzIuM3Y1MDAuNTJjLTE1OC4xOC02Ni43NC0yMjEuNDUtMTk0LjY1LTIyMS40NS0yNjYuOTR2LTE2MS4yOFoiLz48cGF0aCBjbGFzcz0iY2xzLTEiIGQ9Im0xMTgxLjYyLDQyMy40MWwtMjIxLjQ1LTcyLjN2NTAwLjUyYzE1OC4xOC02Ni43NCwyMjEuNDUtMTk0LjY1LDIyMS40NS0yNjYuOTR2LTE2MS4yOFoiLz48cGF0aCBjbGFzcz0iY2xzLTIiIGQ9Im04MjUuOTEsMjMwLjg1aDMwLjl2MTcuMzFjMTAuMTMtMTUuNTYsMjEuNzgtMTcuMzEsMzguODQtMTcuMzF2MzAuNmgtNy43N2MtMjAuNDQsMC0zMC4yMyw5LjYyLTMwLjIzLDI4LjY3djMyLjUyaC0zMS43NXYtOTEuNzlaIi8+PHBhdGggY2xhc3M9ImNscy0yIiBkPSJtOTk4Ljc4LDMyMi42M2gtMzEuNzV2LTguNzVjLTYuOTMsOC4wNS0xNi4zOCwxMS41NC0yOC4wMywxMS41NC0yMi4xMiwwLTM0LjYyLTEzLjExLTM0LjYyLTM3LjI0di01Ny4zNGgzMS43NXY1MC4xOGMwLDExLjM2LDUuNTcsMTgsMTUuMDIsMThzMTUuODgtNi40NywxNS44OC0xNy40OHYtNTAuN2gzMS43NXY5MS43OVoiLz48cGF0aCBjbGFzcz0iY2xzLTIiIGQ9Im0xMDA2LjU0LDI5NC4zaDI5LjczYzEuMzYsNi42NCw1LjkxLDkuNDMsMTYuODgsOS40Myw4Ljk1LDAsMTQuMTktMi4wOSwxNC4xOS01Ljk0LDAtMi45OC0yLjU0LTQuOS05Ljc5LTYuNDdsLTIzLjk4LTUuNDJjLTE2LjA0LTMuNjYtMjQuMTUtMTIuOTMtMjQuMTUtMjcuOCwwLTE5LjU5LDE0LjM1LTI5LjczLDQyLjIxLTI5LjczczQxLjU0LDkuODgsNDMuOTEsMzEuMDRoLTI5LjU1Yy0uNS01LjU5LTYuMjUtOS4wMS0xNS43LTkuMDEtNy41OSwwLTEyLjQ5LDIuNDQtMTIuNDksNi4xMiwwLDMuMTQsMy4yLDUuNTksOS42Myw3LjE4bDI1LjE2LDYuMTJjMTYuNTQsNC4wMSwyNC40OSwxMi40MSwyNC40OSwyNi4wNSwwLDE4Ljg5LTE2LjM4LDMwLjA4LTQ0LjIzLDMwLjA4cy00Ni4yNy0xMi4wNi00Ni4yNy0zMS42NWgtLjAzWiIvPjxwYXRoIGNsYXNzPSJjbHMtMiIgZD0ibTExODEuNjIsMjU5LjR2LTI4LjU1aC03OC4zNXYyOC41NmgyMy4zOHY2My4yMmgzMS41OHYtNjMuMjRoMjMuMzlaIi8+PHBhdGggY2xhc3M9ImNscy0yIiBkPSJtODE3LjA4LDI1OS40di0yOC41NWgtNzguMzV2MjguNTZoMjMuMzh2NjMuMjJoMzEuNTh2LTYzLjI0aDIzLjM4WiIvPjwvc3ZnPg==`,this.supportedTransactionVersions=null,this._readyState=typeof window>`u`||typeof document>`u`?Ot.Unsupported:Ot.NotDetected,this._disconnected=()=>{let e=this._wallet;e&&(e.off(`disconnect`,this._disconnected),this._wallet=null,this._publicKey=null,this.emit(`error`,new vt),this.emit(`disconnect`))},this._connecting=!1,this._wallet=null,this._publicKey=null,this._readyState!==Ot.Unsupported&&At(()=>window.trustwallet?.solana?.isTrust?(this._readyState=Ot.Installed,this.emit(`readyStateChange`,this._readyState),!0):!1)}get publicKey(){return this._publicKey}get connecting(){return this._connecting}get connected(){return!!this._wallet?.isConnected}get readyState(){return this._readyState}async connect(){try{if(this.connected||this.connecting)return;if(this._readyState!==Ot.Installed)throw new ht;this._connecting=!0;let e=window.trustwallet.solana;if(!e.isConnected)try{await e.connect()}catch(e){throw new _t(e?.message,e)}if(!e.publicKey)throw new bt;let t;try{t=new W(e.publicKey.toBytes())}catch(e){throw new xt(e?.message,e)}e.on(`disconnect`,this._disconnected),this._wallet=e,this._publicKey=t,this.emit(`connect`,t)}catch(e){throw this.emit(`error`,e),e}finally{this._connecting=!1}}async disconnect(){let e=this._wallet;if(e){e.off(`disconnect`,this._disconnected),this._wallet=null,this._publicKey=null;try{await e.disconnect()}catch(e){this.emit(`error`,new yt(e?.message,e))}}this.emit(`disconnect`)}async sendTransaction(e,t,n={}){try{let r=this._wallet;if(!r)throw new St;try{let{signers:i,...a}=n;e=await this.prepareTransaction(e,t,a),i?.length&&e.partialSign(...i),a.preflightCommitment=a.preflightCommitment||t.commitment;let{signature:o}=await r.signAndSendTransaction(e,a);return o}catch(e){throw e instanceof mt?e:new Ct(e?.message,e)}}catch(e){throw this.emit(`error`,e),e}}async signTransaction(e){try{let t=this._wallet;if(!t)throw new St;try{return await t.signTransaction(e)||e}catch(e){throw new wt(e?.message,e)}}catch(e){throw this.emit(`error`,e),e}}async signAllTransactions(e){try{let t=this._wallet;if(!t)throw new St;try{return await t.signAllTransactions(e)||e}catch(e){throw new wt(e?.message,e)}}catch(e){throw this.emit(`error`,e),e}}async signMessage(e){try{let t=this._wallet;if(!t)throw new St;try{let{signature:n}=await t.signMessage(e);return n}catch(e){throw new Tt(e?.message,e)}}catch(e){throw this.emit(`error`,e),e}}},oc;(function(e){e.Mainnet=`solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp`,e.Devnet=`solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1`,e.Deprecated_Mainnet=`solana:4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ`,e.Deprecated_Devnet=`solana:8E9rvCKLFQia2Y35HXjjpWzj8weVo44K`})(oc||={});var sc;(function(e){e.signTransaction=`solana_signTransaction`,e.signMessage=`solana_signMessage`,e.signAndSendTransaction=`solana_signAndSendTransaction`,e.signAndSendAllTransactions=`solana_signAndSendAllTransactions`,e.signAllTransactions=`solana_signAllTransactions`})(sc||={});var cc={Mainnet:`solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp`,Devnet:`solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1`,Deprecated_Mainnet:`solana:4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ`,Deprecated_Devnet:`solana:8E9rvCKLFQia2Y35HXjjpWzj8weVo44K`};c();var lc=r(E()),uc=Object.defineProperty,dc=(e,t,n)=>t in e?uc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,fc=(e,t,n)=>dc(e,typeof t==`symbol`?t:t+``,n),pc=class extends De{constructor(e){super(),this.opts=e,fc(this,`protocol`,`wc`),fc(this,`version`,2)}},mc=Object.defineProperty,hc=(e,t,n)=>t in e?mc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,gc=(e,t,n)=>hc(e,typeof t==`symbol`?t:t+``,n),_c=class extends De{constructor(e,t){super(),this.core=e,this.logger=t,gc(this,`records`,new Map)}},vc=class{constructor(e,t){this.logger=e,this.core=t}},yc=class extends De{constructor(e,t){super(),this.relayer=e,this.logger=t}},bc=class extends De{constructor(e){super()}},xc=class{constructor(e,t,n,r){this.core=e,this.logger=t,this.name=n}},Sc=class extends De{constructor(e,t){super(),this.relayer=e,this.logger=t}},Cc=class extends De{constructor(e,t){super(),this.core=e,this.logger=t}},wc=class{constructor(e,t,n){this.core=e,this.logger=t,this.store=n}},Tc=class{constructor(e,t){this.projectId=e,this.logger=t}},Ec=class{constructor(e,t,n){this.core=e,this.logger=t,this.telemetryEnabled=n}},Dc=Object.defineProperty,Oc=(e,t,n)=>t in e?Dc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,kc=(e,t,n)=>Oc(e,typeof t==`symbol`?t:t+``,n),Ac=class{constructor(e){this.opts=e,kc(this,`protocol`,`wc`),kc(this,`version`,2)}},jc=class{constructor(e){this.client=e}};v(),o();var q=D(),Mc=se(),Nc=ue(),Pc=x(),Fc=`:`;function Ic(e){let[t,n]=e.split(Fc);return{namespace:t,reference:n}}function Lc(e){let[t,n,r]=e.split(Fc);return{namespace:t,reference:n,address:r}}function Rc(e,t){return e.includes(`:`)?[e]:t.chains||[]}var zc={reactNative:`react-native`,node:`node`,browser:`browser`,unknown:`unknown`};function Bc(){return typeof a<`u`&&typeof a.versions<`u`&&typeof a.versions.node<`u`}function Vc(){return!(0,Mc.getDocument)()&&!!(0,Mc.getNavigator)()&&navigator.product===`ReactNative`}function Hc(){return Vc()&&typeof l<`u`&&typeof l?.Platform<`u`&&l?.Platform.OS===`android`}function Uc(){return Vc()&&typeof l<`u`&&typeof l?.Platform<`u`&&l?.Platform.OS===`ios`}function Wc(){return!Bc()&&!!(0,Mc.getNavigator)()&&!!(0,Mc.getDocument)()}function Gc(){return Vc()?zc.reactNative:Bc()?zc.node:Wc()?zc.browser:zc.unknown}function Kc(){try{return Vc()&&typeof l<`u`&&typeof l?.Application<`u`?l.Application?.applicationId:void 0}catch{return}}function qc(e,t){let n=new URLSearchParams(e);for(let e of Object.keys(t).sort())if(t.hasOwnProperty(e)){let r=t[e];r!==void 0&&n.set(e,r)}return n.toString()}function Jc(){return(0,Nc.getWindowMetadata)()||{name:``,description:``,url:``,icons:[``]}}function Yc(){if(Gc()===zc.reactNative&&typeof l<`u`&&typeof l?.Platform<`u`){let{OS:e,Version:t}=l.Platform;return[e,t].join(`-`)}let e=ie();if(e===null)return`unknown`;let t=e.os?e.os.replace(` `,``).toLowerCase():`unknown`;return e.type===`browser`?[t,e.name,e.version].join(`-`):[t,e.version].join(`-`)}function Xc(){let e=Gc();return e===zc.browser?[e,(0,Mc.getLocation)()?.host||`unknown`].join(`:`):e}function Zc(e,t,n){let r=Yc(),i=Xc();return[[e,t].join(`-`),[`js`,n].join(`-`),r,i].join(`/`)}function Qc({protocol:e,version:t,relayUrl:n,sdkVersion:r,auth:i,projectId:a,useOnCloseEvent:o,bundleId:s,packageName:c}){let l=n.split(`?`),u={auth:i,ua:Zc(e,t,r),projectId:a,useOnCloseEvent:o||void 0,packageName:c||void 0,bundleId:s||void 0},d=qc(l[1]||``,u);return l[0]+`?`+d}function $c(e,t){return e.filter(e=>t.includes(e)).length===e.length}function el(e){return Object.fromEntries(e.entries())}function tl(e){return new Map(Object.entries(e))}function nl(e=q.FIVE_MINUTES,t){let n=(0,q.toMiliseconds)(e||q.FIVE_MINUTES),r,i,a,o;return{resolve:e=>{a&&r&&(clearTimeout(a),r(e),o=Promise.resolve(e))},reject:e=>{a&&i&&(clearTimeout(a),i(e))},done:()=>new Promise((e,s)=>{if(o)return e(o);a=setTimeout(()=>{let e=Error(t);o=Promise.reject(e),s(e)},n),r=e,i=s})}}function rl(e,t,n){return new Promise(async(r,i)=>{let a=setTimeout(()=>i(Error(n)),t);try{r(await e)}catch(e){i(e)}clearTimeout(a)})}function il(e,t){if(typeof t==`string`&&t.startsWith(`${e}:`))return t;if(e.toLowerCase()===`topic`){if(typeof t!=`string`)throw Error(`Value must be "string" for expirer target type: topic`);return`topic:${t}`}if(e.toLowerCase()===`id`){if(typeof t!=`number`)throw Error(`Value must be "number" for expirer target type: id`);return`id:${t}`}throw Error(`Unknown expirer target type: ${e}`)}function al(e){return il(`topic`,e)}function ol(e){return il(`id`,e)}function sl(e){let[t,n]=e.split(`:`),r={id:void 0,topic:void 0};if(t===`topic`&&typeof n==`string`)r.topic=n;else if(t===`id`&&Number.isInteger(Number(n)))r.id=Number(n);else throw Error(`Invalid target, expected id:number or topic:string, got ${t}:${n}`);return r}function cl(e,t){return(0,q.fromMiliseconds)((t||Date.now())+(0,q.toMiliseconds)(e))}function ll(e){return Date.now()>=(0,q.toMiliseconds)(e)}function ul(e,t){return`${e}${t?`:${t}`:``}`}function dl(e=[],t=[]){return[...new Set([...e,...t])]}async function fl({id:e,topic:t,wcDeepLink:n}){var r;try{if(!n)return;let i=(typeof n==`string`?JSON.parse(n):n)?.href;if(typeof i!=`string`)return;let a=pl(i,e,t),o=Gc();if(o===zc.browser){if(!((r=(0,Mc.getDocument)())!=null&&r.hasFocus()))return;ml(a)}else o===zc.reactNative&&typeof l?.Linking<`u`&&await l.Linking.openURL(a)}catch{}}function pl(e,t,n){let r=`requestId=${t}&sessionTopic=${n}`;e.endsWith(`/`)&&(e=e.slice(0,-1));let i=`${e}`;if(e.startsWith(`https://t.me`)){let t=e.includes(`?`)?`&startapp=`:`?startapp=`;i=`${i}${t}${xl(r,!0)}`}else i=`${i}/wc?${r}`;return i}function ml(e){let t=`_self`;bl()?t=`_top`:(yl()||e.startsWith(`https://`)||e.startsWith(`http://`))&&(t=`_blank`),window.open(e,t,`noreferrer noopener`)}async function hl(e,t){let n=``;try{if(Wc()&&(n=localStorage.getItem(t),n))return n;n=await e.getItem(t)}catch{}return n}function gl(e,t){if(!e.includes(t))return null;let n=e.split(/([&,?,=])/);return n[n.indexOf(t)+2]}function _l(){return typeof crypto<`u`&&crypto!=null&&crypto.randomUUID?crypto.randomUUID():`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/gu,e=>{let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)})}function vl(){return typeof a<`u`&&{}.IS_VITEST===`true`}function yl(){return typeof window<`u`&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function bl(){try{return window.self!==window.top}catch{return!1}}function xl(e,t=!1){let n=y.from(e).toString(`base64`);return t?n.replace(/[=]/g,``):n}function Sl(e){return y.from(e,`base64`).toString(`utf-8`)}function Cl(e){return new Promise(t=>setTimeout(t,e))}function wl(e){if(!Number.isSafeInteger(e)||e<0)throw Error(`positive integer expected, got `+e)}function Tl(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`}function El(e,...t){if(!Tl(e))throw Error(`Uint8Array expected`);if(t.length>0&&!t.includes(e.length))throw Error(`Uint8Array expected of length `+t+`, got length=`+e.length)}function Dl(e){if(typeof e!=`function`||typeof e.create!=`function`)throw Error(`Hash should be wrapped by utils.wrapConstructor`);wl(e.outputLen),wl(e.blockLen)}function Ol(e,t=!0){if(e.destroyed)throw Error(`Hash instance has been destroyed`);if(t&&e.finished)throw Error(`Hash#digest() has already been called`)}function kl(e,t){El(e);let n=t.outputLen;if(e.length<n)throw Error(`digestInto() expects output buffer of length at least `+n)}var Al=BigInt(2**32-1),jl=BigInt(32);function Ml(e,t=!1){return t?{h:Number(e&Al),l:Number(e>>jl&Al)}:{h:Number(e>>jl&Al)|0,l:Number(e&Al)|0}}function Nl(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let i=0;i<e.length;i++){let{h:a,l:o}=Ml(e[i],t);[n[i],r[i]]=[a,o]}return[n,r]}var Pl=(e,t,n)=>e<<n|t>>>32-n,Fl=(e,t,n)=>t<<n|e>>>32-n,Il=(e,t,n)=>t<<n-32|e>>>64-n,Ll=(e,t,n)=>e<<n-32|t>>>64-n,Rl=typeof globalThis==`object`&&`crypto`in globalThis?globalThis.crypto:void 0;function zl(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Bl(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Vl(e,t){return e<<32-t|e>>>t}var Hl=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Ul(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function Wl(e){for(let t=0;t<e.length;t++)e[t]=Ul(e[t])}function Gl(e){if(typeof e!=`string`)throw Error(`utf8ToBytes expected string, got `+typeof e);return new Uint8Array(new TextEncoder().encode(e))}function Kl(e){return typeof e==`string`&&(e=Gl(e)),El(e),e}var ql=class{clone(){return this._cloneInto()}};function Jl(e){let t=t=>e().update(Kl(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Yl(e=32){if(Rl&&typeof Rl.getRandomValues==`function`)return Rl.getRandomValues(new Uint8Array(e));if(Rl&&typeof Rl.randomBytes==`function`)return Rl.randomBytes(e);throw Error(`crypto.getRandomValues must be defined`)}var Xl=[],Zl=[],Ql=[],$l=BigInt(0),eu=BigInt(1),tu=BigInt(2),nu=BigInt(7),ru=BigInt(256),iu=BigInt(113);for(let e=0,t=eu,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],Xl.push(2*(5*r+n)),Zl.push((e+1)*(e+2)/2%64);let i=$l;for(let e=0;e<7;e++)t=(t<<eu^(t>>nu)*iu)%ru,t&tu&&(i^=eu<<(eu<<BigInt(e))-eu);Ql.push(i)}var[au,ou]=Nl(Ql,!0),su=(e,t,n)=>n>32?Il(e,t,n):Pl(e,t,n),cu=(e,t,n)=>n>32?Ll(e,t,n):Fl(e,t,n);function lu(e,t=24){let n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let t=0;t<10;t++)n[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){let r=(t+8)%10,i=(t+2)%10,a=n[i],o=n[i+1],s=su(a,o,1)^n[r],c=cu(a,o,1)^n[r+1];for(let n=0;n<50;n+=10)e[t+n]^=s,e[t+n+1]^=c}let t=e[2],i=e[3];for(let n=0;n<24;n++){let r=Zl[n],a=su(t,i,r),o=cu(t,i,r),s=Xl[n];t=e[s],i=e[s+1],e[s]=a,e[s+1]=o}for(let t=0;t<50;t+=10){for(let r=0;r<10;r++)n[r]=e[t+r];for(let r=0;r<10;r++)e[t+r]^=~n[(r+2)%10]&n[(r+4)%10]}e[0]^=au[r],e[1]^=ou[r]}n.fill(0)}var uu=class e extends ql{constructor(e,t,n,r=!1,i=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=r,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,wl(n),0>=this.blockLen||this.blockLen>=200)throw Error(`Sha3 supports only keccak-f1600 function`);this.state=new Uint8Array(200),this.state32=zl(this.state)}keccak(){Hl||Wl(this.state32),lu(this.state32,this.rounds),Hl||Wl(this.state32),this.posOut=0,this.pos=0}update(e){Ol(this);let{blockLen:t,state:n}=this;e=Kl(e);let r=e.length;for(let i=0;i<r;){let a=Math.min(t-this.pos,r-i);for(let t=0;t<a;t++)n[this.pos++]^=e[i++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:t,pos:n,blockLen:r}=this;e[n]^=t,t&128&&n===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){Ol(this,!1),El(e),this.finish();let t=this.state,{blockLen:n}=this;for(let r=0,i=e.length;r<i;){this.posOut>=n&&this.keccak();let a=Math.min(n-this.posOut,i-r);e.set(t.subarray(this.posOut,this.posOut+a),r),this.posOut+=a,r+=a}return e}xofInto(e){if(!this.enableXOF)throw Error(`XOF is not possible for this instance`);return this.writeInto(e)}xof(e){return wl(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(kl(e,this),this.finished)throw Error(`digest() was already called`);return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){let{blockLen:n,suffix:r,outputLen:i,rounds:a,enableXOF:o}=this;return t||=new e(n,r,i,o,a),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=a,t.suffix=r,t.outputLen=i,t.enableXOF=o,t.destroyed=this.destroyed,t}},du=((e,t,n)=>Jl(()=>new uu(t,e,n)))(1,136,32),fu=`https://rpc.walletconnect.org/v1`;function pu(e){let t=`Ethereum Signed Message:
4
4
  ${e.length}`,n=new TextEncoder().encode(t+e);return`0x`+y.from(du(n)).toString(`hex`)}async function mu(e,t,n,r,i,a){switch(n.t){case`eip191`:return await hu(e,t,n.s);case`eip1271`:return await gu(e,t,n.s,r,i,a);default:throw Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${n.t}`)}}async function hu(e,t,n){return(await Ne({hash:pu(t),signature:n})).toLowerCase()===e.toLowerCase()}async function gu(e,t,n,r,i,a){let o=Ic(r);if(!o.namespace||!o.reference)throw Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${r}`);try{let o=n.substring(2),s=`0x1626ba7e`+pu(t).substring(2)+`00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000041`+o,{result:c}=await(await fetch(`${a||fu}/?chainId=${r}&projectId=${i}`,{method:`POST`,body:JSON.stringify({id:_u(),jsonrpc:`2.0`,method:`eth_call`,params:[{to:e,data:s},`latest`]})})).json();return c?c.slice(0,10).toLowerCase()===`0x1626ba7e`:!1}catch{return!1}}function _u(){return Date.now()+Math.floor(Math.random()*1e3)}var vu=Object.defineProperty,yu=Object.defineProperties,bu=Object.getOwnPropertyDescriptors,xu=Object.getOwnPropertySymbols,Su=Object.prototype.hasOwnProperty,Cu=Object.prototype.propertyIsEnumerable,wu=(e,t,n)=>t in e?vu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Tu=(e,t)=>{for(var n in t||={})Su.call(t,n)&&wu(e,n,t[n]);if(xu)for(var n of xu(t))Cu.call(t,n)&&wu(e,n,t[n]);return e},Eu=(e,t)=>yu(e,bu(t)),Du=`did:pkh:`,Ou=e=>e?.split(`:`),ku=e=>{let t=e&&Ou(e);if(t)return e.includes(Du)?t[3]:t[1]},Au=e=>{let t=e&&Ou(e);if(t)return t[2]+`:`+t[3]},ju=e=>{let t=e&&Ou(e);if(t)return t.pop()};async function Mu(e){let{cacao:t,projectId:n}=e,{s:r,p:i}=t,a=Nu(i,i.iss);return await mu(ju(i.iss),a,r,Au(i.iss),n)}var Nu=(e,t)=>{let n=`${e.domain} wants you to sign in with your Ethereum account:`,r=ju(t);if(!e.aud&&!e.uri)throw Error("Either `aud` or `uri` is required to construct the message");let i=e.statement||void 0,a=`URI: ${e.aud||e.uri}`,o=`Version: ${e.version}`,s=`Chain ID: ${ku(t)}`,c=`Nonce: ${e.nonce}`,l=`Issued At: ${e.iat}`,u=e.exp?`Expiration Time: ${e.exp}`:void 0,d=e.nbf?`Not Before: ${e.nbf}`:void 0,f=e.requestId?`Request ID: ${e.requestId}`:void 0,p=e.resources?`Resources:${e.resources.map(e=>`
5
5
  - ${e}`).join(``)}`:void 0,m=Ju(e.resources);if(m){let e=Bu(m);i=Gu(i,e)}return[n,r,``,i,``,a,o,s,c,l,u,d,f,p].filter(e=>e!=null).join(`