@w3payments/react 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +308 -0
- package/dist/assets/3.svg +1 -0
- package/dist/assets/io.svg +1 -0
- package/dist/assets/main.css +1 -0
- package/dist/assets/vite.svg +1 -0
- package/dist/assets/w.svg +1 -0
- package/dist/components/PaymentButton.d.ts +18 -0
- package/dist/components/PaymentButton.d.ts.map +1 -0
- package/dist/components/PaymentFooter.d.ts +10 -0
- package/dist/components/PaymentFooter.d.ts.map +1 -0
- package/dist/components/PaymentHeader.d.ts +10 -0
- package/dist/components/PaymentHeader.d.ts.map +1 -0
- package/dist/components/PaymentInput.d.ts +23 -0
- package/dist/components/PaymentInput.d.ts.map +1 -0
- package/dist/components/PaymentMethodGroup.d.ts +14 -0
- package/dist/components/PaymentMethodGroup.d.ts.map +1 -0
- package/dist/components/PaymentMethodOption.d.ts +16 -0
- package/dist/components/PaymentMethodOption.d.ts.map +1 -0
- package/dist/components/PaymentMethodSelection.d.ts +14 -0
- package/dist/components/PaymentMethodSelection.d.ts.map +1 -0
- package/dist/components/PaymentSummary.d.ts +13 -0
- package/dist/components/PaymentSummary.d.ts.map +1 -0
- package/dist/components/W3PaymentWidget.d.ts +63 -0
- package/dist/components/W3PaymentWidget.d.ts.map +1 -0
- package/dist/components/W3PaymentsProvider.d.ts +24 -0
- package/dist/components/W3PaymentsProvider.d.ts.map +1 -0
- package/dist/components/index.d.ts +12 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/context/W3PaymentsContext.d.ts +31 -0
- package/dist/context/W3PaymentsContext.d.ts.map +1 -0
- package/dist/hooks/index.d.ts +8 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/useW3Payments.d.ts +32 -0
- package/dist/hooks/useW3Payments.d.ts.map +1 -0
- package/dist/http/W3PaymentsClient.d.ts +16 -0
- package/dist/http/W3PaymentsClient.d.ts.map +1 -0
- package/dist/index-B9KdNmCT.cjs +94 -0
- package/dist/index-Cu_k1Q9p.js +13544 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +67 -0
- package/dist/index.mjs +5815 -0
- package/dist/main.d.ts +10 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/types.d.ts +48 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils/numbers.d.ts +16 -0
- package/dist/utils/numbers.d.ts.map +1 -0
- package/dist/utils/theme.d.ts +6 -0
- package/dist/utils/theme.d.ts.map +1 -0
- package/package.json +112 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";var bc=Object.defineProperty,Ac=Object.defineProperties;var Sc=Object.getOwnPropertyDescriptors;var hr=Object.getOwnPropertySymbols;var Vs=Object.prototype.hasOwnProperty,Gs=Object.prototype.propertyIsEnumerable;var bt=Math.pow,Ri=(r,t,e)=>t in r?bc(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,lt=(r,t)=>{for(var e in t||(t={}))Vs.call(t,e)&&Ri(r,e,t[e]);if(hr)for(var e of hr(t))Gs.call(t,e)&&Ri(r,e,t[e]);return r},yt=(r,t)=>Ac(r,Sc(t));var qe=(r,t)=>{var e={};for(var n in r)Vs.call(r,n)&&t.indexOf(n)<0&&(e[n]=r[n]);if(r!=null&&hr)for(var n of hr(r))t.indexOf(n)<0&&Gs.call(r,n)&&(e[n]=r[n]);return e};var Mt=(r,t,e)=>Ri(r,typeof t!="symbol"?t+"":t,e);var H=(r,t,e)=>new Promise((n,s)=>{var i=d=>{try{c(e.next(d))}catch(_){s(_)}},o=d=>{try{c(e.throw(d))}catch(_){s(_)}},c=d=>d.done?n(d.value):Promise.resolve(d.value).then(i,o);c((e=e.apply(r,t)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function Hr(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function hs(r){if(Object.prototype.hasOwnProperty.call(r,"__esModule"))return r;var t=r.default;if(typeof t=="function"){var e=function n(){var s=!1;try{s=this instanceof n}catch(i){}return s?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(r).forEach(function(n){var s=Object.getOwnPropertyDescriptor(r,n);Object.defineProperty(e,n,s.get?s:{enumerable:!0,get:function(){return r[n]}})}),e}var vc=["integrationConnected","integrationConnectionError","integrationMfaRequired","integrationMfaEntered","integrationOAuthStarted","integrationAccountSelectionRequired","transferCompleted","integrationSelected","credentialsEntered","transferStarted","transferPreviewed","transferPreviewError","transferExecutionError","pageLoaded","transferAssetSelected","transferNetworkSelected","transferAmountEntered","transferMfaRequired","transferMfaEntered","transferKycRequired","transferExecuted","transferInitiated","transferNoEligibleAssets","walletMessageSigned","verifyDonePage","verifyWalletRejected","connectionDeclined","transferConfigureError","connectionUnavailable","transferDeclined","done","close","SDKinjectedWalletProviders","legalTermsViewed","seeWhatHappenedClicked","executeFundingStep","fundingOptionsUpdated","fundingOptionsViewed","gasIncreaseWarning","linkTransferQRGenerated","methodSelected"];function Ho(r){return vc.includes(r)}function Ic(r){try{var t=new URLSearchParams(new URL(r).search),e=t.get("link_style");return e&&JSON.parse(window.atob(e))}catch(n){return}}function bi(r,t){return t!==void 0?t:r}var ds="mesh-link-popup",Wo="mesh-link-popup__backdrop",vn="mesh-link-popup__popup-content",jo="mesh-link-popup__styles",ps="mesh-link-popup__iframe",Oc=function(r){return`
|
|
2
|
+
body {
|
|
3
|
+
position: fixed;
|
|
4
|
+
left: 0;
|
|
5
|
+
top: 0;
|
|
6
|
+
bottom: 0;
|
|
7
|
+
right: 0;
|
|
8
|
+
overflow: hidden;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
#`.concat(ds,` {
|
|
12
|
+
all: unset;
|
|
13
|
+
position: fixed;
|
|
14
|
+
left: 0;
|
|
15
|
+
top: 0;
|
|
16
|
+
bottom: 0;
|
|
17
|
+
right: 0;
|
|
18
|
+
display: flex;
|
|
19
|
+
flex-direction: column;
|
|
20
|
+
align-items: center;
|
|
21
|
+
justify-content: center;
|
|
22
|
+
z-index: 10000;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
#`).concat(Wo,` {
|
|
26
|
+
position: absolute;
|
|
27
|
+
left: 0;
|
|
28
|
+
top: 0;
|
|
29
|
+
bottom: 0;
|
|
30
|
+
right: 0;
|
|
31
|
+
z-index: 10000;
|
|
32
|
+
background: black;
|
|
33
|
+
opacity: `).concat(bi(.6,r==null?void 0:r.io),`;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
#`).concat(vn,` {
|
|
37
|
+
position: absolute;
|
|
38
|
+
height: 80%;
|
|
39
|
+
max-height: 710px;
|
|
40
|
+
min-height: 685px;
|
|
41
|
+
margin: auto;
|
|
42
|
+
z-index: 10001;
|
|
43
|
+
width: 30%;
|
|
44
|
+
max-width: 430px;
|
|
45
|
+
min-width: 380px;
|
|
46
|
+
display: flex;
|
|
47
|
+
flex-direction: column;
|
|
48
|
+
border-radius: `).concat(bi(24,r==null?void 0:r.ir),`px;
|
|
49
|
+
flex-grow: 1;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
#`).concat(vn,` iframe {
|
|
53
|
+
border: none;
|
|
54
|
+
width: 100%;
|
|
55
|
+
flex-grow: 1;
|
|
56
|
+
border-radius: `).concat(bi(24,r==null?void 0:r.ir),`px;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@media only screen and (max-width: 768px) {
|
|
60
|
+
#`).concat(vn,` {
|
|
61
|
+
height: 100vh;
|
|
62
|
+
width: 100vw;
|
|
63
|
+
max-width: 100%;
|
|
64
|
+
min-width: 100%;
|
|
65
|
+
max-height: 100%;
|
|
66
|
+
min-height: 100%;
|
|
67
|
+
border-radius: 0px;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
#`).concat(vn,` iframe {
|
|
71
|
+
border-radius: 0px;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
@media only screen and (max-height: 710px) {
|
|
76
|
+
#`).concat(vn,` {
|
|
77
|
+
max-height: 100%;
|
|
78
|
+
min-height: 100%;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
`)};function gs(){var r,t,e=window.document.getElementById(ds);(r=e==null?void 0:e.parentElement)===null||r===void 0||r.removeChild(e);var n=window.document.getElementById(jo);(t=n==null?void 0:n.parentElement)===null||t===void 0||t.removeChild(n)}function xc(r){gs();var t=document.createElement("style");t.id=jo;var e=Ic(r);t.textContent=Oc(e),window.document.head.appendChild(t);var n=document.createElement("div");n.id=ds;var s=document.createElement("div");s.id=Wo,n.appendChild(s);var i=document.createElement("div");i.id=vn;var o=document.createElement("iframe");o.id=ps,o.src=r,o.allow="clipboard-read *; clipboard-write *",i.appendChild(o),n.appendChild(i),window.document.body.appendChild(n)}var Nc="3.4.1",Tc={platform:"web",version:Nc,origin:window.location.origin};const Xo=Symbol("Comlink.proxy"),Bc=Symbol("Comlink.endpoint"),Cc=Symbol("Comlink.releaseProxy"),Ai=Symbol("Comlink.finalizer"),Ar=Symbol("Comlink.thrown"),Yo=r=>typeof r=="object"&&r!==null||typeof r=="function",Lc={canHandle:r=>Yo(r)&&r[Xo],serialize(r){const{port1:t,port2:e}=new MessageChannel;return _s(r,t),[e,[e]]},deserialize(r){return r.start(),Dc(r)}},Mc={canHandle:r=>Yo(r)&&Ar in r,serialize({value:r}){let t;return r instanceof Error?t={isError:!0,value:{message:r.message,name:r.name,stack:r.stack}}:t={isError:!1,value:r},[t,[]]},deserialize(r){throw r.isError?Object.assign(new Error(r.value.message),r.value):r.value}},Zo=new Map([["proxy",Lc],["throw",Mc]]);function kc(r,t){for(const e of r)if(t===e||e==="*"||e instanceof RegExp&&e.test(t))return!0;return!1}function _s(r,t=globalThis,e=["*"]){t.addEventListener("message",function n(s){if(!s||!s.data)return;if(!kc(e,s.origin)){console.warn(`Invalid origin '${s.origin}' for comlink proxy`);return}const{id:i,type:o,path:c}=Object.assign({path:[]},s.data),d=(s.data.argumentList||[]).map(on);let _;try{const b=c.slice(0,-1).reduce((x,S)=>x[S],r),O=c.reduce((x,S)=>x[S],r);switch(o){case"GET":_=O;break;case"SET":b[c.slice(-1)[0]]=on(s.data.value),_=!0;break;case"APPLY":_=O.apply(b,d);break;case"CONSTRUCT":{const x=new O(...d);_=ea(x)}break;case"ENDPOINT":{const{port1:x,port2:S}=new MessageChannel;_s(r,S),_=$c(x,[x])}break;case"RELEASE":_=void 0;break;default:return}}catch(b){_={value:b,[Ar]:0}}Promise.resolve(_).catch(b=>({value:b,[Ar]:0})).then(b=>{const[O,x]=Tr(b);t.postMessage(Object.assign(Object.assign({},O),{id:i}),x),o==="RELEASE"&&(t.removeEventListener("message",n),Jo(t),Ai in r&&typeof r[Ai]=="function"&&r[Ai]())}).catch(b=>{const[O,x]=Tr({value:new TypeError("Unserializable return value"),[Ar]:0});t.postMessage(Object.assign(Object.assign({},O),{id:i}),x)})}),t.start&&t.start()}function Uc(r){return r.constructor.name==="MessagePort"}function Jo(r){Uc(r)&&r.close()}function Dc(r,t){const e=new Map;return r.addEventListener("message",function(s){const{data:i}=s;if(!i||!i.id)return;const o=e.get(i.id);if(o)try{o(i)}finally{e.delete(i.id)}}),Ji(r,e,[],t)}function dr(r){if(r)throw new Error("Proxy has been released and is not useable")}function Qo(r){return In(r,new Map,{type:"RELEASE"}).then(()=>{Jo(r)})}const xr=new WeakMap,Nr="FinalizationRegistry"in globalThis&&new FinalizationRegistry(r=>{const t=(xr.get(r)||0)-1;xr.set(r,t),t===0&&Qo(r)});function Pc(r,t){const e=(xr.get(t)||0)+1;xr.set(t,e),Nr&&Nr.register(r,t,r)}function Fc(r){Nr&&Nr.unregister(r)}function Ji(r,t,e=[],n=function(){}){let s=!1;const i=new Proxy(n,{get(o,c){if(dr(s),c===Cc)return()=>{Fc(i),Qo(r),t.clear(),s=!0};if(c==="then"){if(e.length===0)return{then:()=>i};const d=In(r,t,{type:"GET",path:e.map(_=>_.toString())}).then(on);return d.then.bind(d)}return Ji(r,t,[...e,c])},set(o,c,d){dr(s);const[_,b]=Tr(d);return In(r,t,{type:"SET",path:[...e,c].map(O=>O.toString()),value:_},b).then(on)},apply(o,c,d){dr(s);const _=e[e.length-1];if(_===Bc)return In(r,t,{type:"ENDPOINT"}).then(on);if(_==="bind")return Ji(r,t,e.slice(0,-1));const[b,O]=Ks(d);return In(r,t,{type:"APPLY",path:e.map(x=>x.toString()),argumentList:b},O).then(on)},construct(o,c){dr(s);const[d,_]=Ks(c);return In(r,t,{type:"CONSTRUCT",path:e.map(b=>b.toString()),argumentList:d},_).then(on)}});return Pc(i,r),i}function qc(r){return Array.prototype.concat.apply([],r)}function Ks(r){const t=r.map(Tr);return[t.map(e=>e[0]),qc(t.map(e=>e[1]))]}const ta=new WeakMap;function $c(r,t){return ta.set(r,t),r}function ea(r){return Object.assign(r,{[Xo]:!0})}function zc(r,t=globalThis,e="*"){return{postMessage:(n,s)=>r.postMessage(n,e,s),addEventListener:t.addEventListener.bind(t),removeEventListener:t.removeEventListener.bind(t)}}function Tr(r){for(const[t,e]of Zo)if(e.canHandle(r)){const[n,s]=e.serialize(r);return[{type:"HANDLER",name:t,value:n},s]}return[{type:"RAW",value:r},ta.get(r)||[]]}function on(r){switch(r.type){case"HANDLER":return Zo.get(r.name).deserialize(r.value);case"RAW":return r.value}}function In(r,t,e,n){return new Promise(s=>{const i=Vc();t.set(i,s),r.start&&r.start(),r.postMessage(Object.assign({id:i},e),n)})}function Vc(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}var Gc=function(r,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?r!==t||!n:!t.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(r):n?n.value:t.get(r)},Kc=function(r,t,e,n,s){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?r!==t||!s:!t.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?s.call(r,e):s?s.value=e:t.set(r,e),e},Sr;let zn;const Wr=new Set;function Hc(r){Yn=void 0,Wr.add(r)}function Wc(r){Yn=void 0,Wr.delete(r)}const xn={};function jc(){if(zn||(zn=Object.freeze({register:Hs,get:Xc,on:Yc}),typeof window=="undefined"))return zn;const r=Object.freeze({register:Hs});try{window.addEventListener("wallet-standard:register-wallet",({detail:t})=>t(r))}catch(t){console.error(`wallet-standard:register-wallet event listener could not be added
|
|
82
|
+
`,t)}try{window.dispatchEvent(new Zc(r))}catch(t){console.error(`wallet-standard:app-ready event could not be dispatched
|
|
83
|
+
`,t)}return zn}function Hs(...r){var t;return r=r.filter(e=>!Wr.has(e)),r.length?(r.forEach(e=>Hc(e)),(t=xn.register)==null||t.forEach(e=>Ws(()=>e(...r))),function(){var n;r.forEach(s=>Wc(s)),(n=xn.unregister)==null||n.forEach(s=>Ws(()=>s(...r)))}):()=>{}}let Yn;function Xc(){return Yn||(Yn=[...Wr]),Yn}function Yc(r,t){var e;return(e=xn[r])!=null&&e.push(t)||(xn[r]=[t]),function(){var s;xn[r]=(s=xn[r])==null?void 0:s.filter(i=>t!==i)}}function Ws(r){try{r()}catch(t){console.error(t)}}class Zc extends Event{get detail(){return Gc(this,Sr,"f")}get type(){return"wallet-standard:app-ready"}constructor(t){super("wallet-standard:app-ready",{bubbles:!1,cancelable:!1,composed:!1}),Sr.set(this,void 0),Kc(this,Sr,t,"f")}preventDefault(){throw new Error("preventDefault cannot be called")}stopImmediatePropagation(){throw new Error("stopImmediatePropagation cannot be called")}stopPropagation(){throw new Error("stopPropagation cannot be called")}}Sr=new WeakMap;var Si={exports:{}},js;function Jc(){return js||(js=1,(function(r){var t=Object.prototype.hasOwnProperty,e="~";function n(){}Object.create&&(n.prototype=Object.create(null),new n().__proto__||(e=!1));function s(d,_,b){this.fn=d,this.context=_,this.once=b||!1}function i(d,_,b,O,x){if(typeof b!="function")throw new TypeError("The listener must be a function");var S=new s(b,O||d,x),T=e?e+_:_;return d._events[T]?d._events[T].fn?d._events[T]=[d._events[T],S]:d._events[T].push(S):(d._events[T]=S,d._eventsCount++),d}function o(d,_){--d._eventsCount===0?d._events=new n:delete d._events[_]}function c(){this._events=new n,this._eventsCount=0}c.prototype.eventNames=function(){var _=[],b,O;if(this._eventsCount===0)return _;for(O in b=this._events)t.call(b,O)&&_.push(e?O.slice(1):O);return Object.getOwnPropertySymbols?_.concat(Object.getOwnPropertySymbols(b)):_},c.prototype.listeners=function(_){var b=e?e+_:_,O=this._events[b];if(!O)return[];if(O.fn)return[O.fn];for(var x=0,S=O.length,T=new Array(S);x<S;x++)T[x]=O[x].fn;return T},c.prototype.listenerCount=function(_){var b=e?e+_:_,O=this._events[b];return O?O.fn?1:O.length:0},c.prototype.emit=function(_,b,O,x,S,T){var C=e?e+_:_;if(!this._events[C])return!1;var M=this._events[C],P=arguments.length,W,z;if(M.fn){switch(M.once&&this.removeListener(_,M.fn,void 0,!0),P){case 1:return M.fn.call(M.context),!0;case 2:return M.fn.call(M.context,b),!0;case 3:return M.fn.call(M.context,b,O),!0;case 4:return M.fn.call(M.context,b,O,x),!0;case 5:return M.fn.call(M.context,b,O,x,S),!0;case 6:return M.fn.call(M.context,b,O,x,S,T),!0}for(z=1,W=new Array(P-1);z<P;z++)W[z-1]=arguments[z];M.fn.apply(M.context,W)}else{var Q=M.length,Z;for(z=0;z<Q;z++)switch(M[z].once&&this.removeListener(_,M[z].fn,void 0,!0),P){case 1:M[z].fn.call(M[z].context);break;case 2:M[z].fn.call(M[z].context,b);break;case 3:M[z].fn.call(M[z].context,b,O);break;case 4:M[z].fn.call(M[z].context,b,O,x);break;default:if(!W)for(Z=1,W=new Array(P-1);Z<P;Z++)W[Z-1]=arguments[Z];M[z].fn.apply(M[z].context,W)}}return!0},c.prototype.on=function(_,b,O){return i(this,_,b,O,!1)},c.prototype.once=function(_,b,O){return i(this,_,b,O,!0)},c.prototype.removeListener=function(_,b,O,x){var S=e?e+_:_;if(!this._events[S])return this;if(!b)return o(this,S),this;var T=this._events[S];if(T.fn)T.fn===b&&(!x||T.once)&&(!O||T.context===O)&&o(this,S);else{for(var C=0,M=[],P=T.length;C<P;C++)(T[C].fn!==b||x&&!T[C].once||O&&T[C].context!==O)&&M.push(T[C]);M.length?this._events[S]=M.length===1?M[0]:M:o(this,S)}return this},c.prototype.removeAllListeners=function(_){var b;return _?(b=e?e+_:_,this._events[b]&&o(this,b)):(this._events=new n,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=e,c.EventEmitter=c,r.exports=c})(Si)),Si.exports}var Qc=Jc();const ms=Hr(Qc);class ve extends Error{constructor(t,e){super(t),this.error=e}}class tu extends ve{constructor(){super(...arguments),this.name="WalletNotReadyError"}}class Hn extends ve{constructor(){super(...arguments),this.name="WalletConfigError"}}class eu extends ve{constructor(){super(...arguments),this.name="WalletConnectionError"}}class nu extends ve{constructor(){super(...arguments),this.name="WalletDisconnectedError"}}class ru extends ve{constructor(){super(...arguments),this.name="WalletDisconnectionError"}}class Nn extends ve{constructor(){super(...arguments),this.name="WalletAccountError"}}class iu extends ve{constructor(){super(...arguments),this.name="WalletPublicKeyError"}}class Zn extends ve{constructor(){super(...arguments),this.name="WalletNotConnectedError"}}class Xs extends ve{constructor(){super(...arguments),this.name="WalletSendTransactionError"}}class Ys extends ve{constructor(){super(...arguments),this.name="WalletSignTransactionError"}}class su extends ve{constructor(){super(...arguments),this.name="WalletSignMessageError"}}class Zs extends ve{constructor(){super(...arguments),this.name="WalletSignInError"}}var Qn;(function(r){r.Installed="Installed",r.NotDetected="NotDetected",r.Loadable="Loadable",r.Unsupported="Unsupported"})(Qn||(Qn={}));class ou extends ms{get connected(){return!!this.publicKey}autoConnect(){return H(this,null,function*(){yield this.connect()})}prepareTransaction(s,i){return H(this,arguments,function*(t,e,n={}){const o=this.publicKey;if(!o)throw new Zn;return t.feePayer=t.feePayer||o,t.recentBlockhash=t.recentBlockhash||(yield e.getLatestBlockhash({commitment:n.preflightCommitment,minContextSlot:n.minContextSlot})).blockhash,t})}}function Wn(r){return"version"in r}const en="solana:signAndSendTransaction",vi="solana:signIn",Vn="solana:signMessage",pe="solana:signTransaction",na="standard:connect",Js="standard:disconnect",ra="standard:events";function au(r){return na in r.features&&ra in r.features&&(en in r.features||pe in r.features)}var Ii={},Gn={},Qs;function cu(){if(Qs)return Gn;Qs=1,Gn.byteLength=c,Gn.toByteArray=_,Gn.fromByteArray=x;for(var r=[],t=[],e=typeof Uint8Array!="undefined"?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,i=n.length;s<i;++s)r[s]=n[s],t[n.charCodeAt(s)]=s;t[45]=62,t[95]=63;function o(S){var T=S.length;if(T%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var C=S.indexOf("=");C===-1&&(C=T);var M=C===T?0:4-C%4;return[C,M]}function c(S){var T=o(S),C=T[0],M=T[1];return(C+M)*3/4-M}function d(S,T,C){return(T+C)*3/4-C}function _(S){var T,C=o(S),M=C[0],P=C[1],W=new e(d(S,M,P)),z=0,Q=P>0?M-4:M,Z;for(Z=0;Z<Q;Z+=4)T=t[S.charCodeAt(Z)]<<18|t[S.charCodeAt(Z+1)]<<12|t[S.charCodeAt(Z+2)]<<6|t[S.charCodeAt(Z+3)],W[z++]=T>>16&255,W[z++]=T>>8&255,W[z++]=T&255;return P===2&&(T=t[S.charCodeAt(Z)]<<2|t[S.charCodeAt(Z+1)]>>4,W[z++]=T&255),P===1&&(T=t[S.charCodeAt(Z)]<<10|t[S.charCodeAt(Z+1)]<<4|t[S.charCodeAt(Z+2)]>>2,W[z++]=T>>8&255,W[z++]=T&255),W}function b(S){return r[S>>18&63]+r[S>>12&63]+r[S>>6&63]+r[S&63]}function O(S,T,C){for(var M,P=[],W=T;W<C;W+=3)M=(S[W]<<16&16711680)+(S[W+1]<<8&65280)+(S[W+2]&255),P.push(b(M));return P.join("")}function x(S){for(var T,C=S.length,M=C%3,P=[],W=16383,z=0,Q=C-M;z<Q;z+=W)P.push(O(S,z,z+W>Q?Q:z+W));return M===1?(T=S[C-1],P.push(r[T>>2]+r[T<<4&63]+"==")):M===2&&(T=(S[C-2]<<8)+S[C-1],P.push(r[T>>10]+r[T>>4&63]+r[T<<2&63]+"=")),P.join("")}return Gn}var pr={};var to;function uu(){return to||(to=1,pr.read=function(r,t,e,n,s){var i,o,c=s*8-n-1,d=(1<<c)-1,_=d>>1,b=-7,O=e?s-1:0,x=e?-1:1,S=r[t+O];for(O+=x,i=S&(1<<-b)-1,S>>=-b,b+=c;b>0;i=i*256+r[t+O],O+=x,b-=8);for(o=i&(1<<-b)-1,i>>=-b,b+=n;b>0;o=o*256+r[t+O],O+=x,b-=8);if(i===0)i=1-_;else{if(i===d)return o?NaN:(S?-1:1)*(1/0);o=o+Math.pow(2,n),i=i-_}return(S?-1:1)*o*Math.pow(2,i-n)},pr.write=function(r,t,e,n,s,i){var o,c,d,_=i*8-s-1,b=(1<<_)-1,O=b>>1,x=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,S=n?0:i-1,T=n?1:-1,C=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(c=isNaN(t)?1:0,o=b):(o=Math.floor(Math.log(t)/Math.LN2),t*(d=Math.pow(2,-o))<1&&(o--,d*=2),o+O>=1?t+=x/d:t+=x*Math.pow(2,1-O),t*d>=2&&(o++,d/=2),o+O>=b?(c=0,o=b):o+O>=1?(c=(t*d-1)*Math.pow(2,s),o=o+O):(c=t*Math.pow(2,O-1)*Math.pow(2,s),o=0));s>=8;r[e+S]=c&255,S+=T,c/=256,s-=8);for(o=o<<s|c,_+=s;_>0;r[e+S]=o&255,S+=T,o/=256,_-=8);r[e+S-T]|=C*128}),pr}var eo;function ys(){return eo||(eo=1,(function(r){const t=cu(),e=uu(),n=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;r.Buffer=c,r.SlowBuffer=W,r.INSPECT_MAX_BYTES=50;const s=2147483647;r.kMaxLength=s,c.TYPED_ARRAY_SUPPORT=i(),!c.TYPED_ARRAY_SUPPORT&&typeof console!="undefined"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function i(){try{const y=new Uint8Array(1),f={foo:function(){return 42}};return Object.setPrototypeOf(f,Uint8Array.prototype),Object.setPrototypeOf(y,f),y.foo()===42}catch(y){return!1}}Object.defineProperty(c.prototype,"parent",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.buffer}}),Object.defineProperty(c.prototype,"offset",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.byteOffset}});function o(y){if(y>s)throw new RangeError('The value "'+y+'" is invalid for option "size"');const f=new Uint8Array(y);return Object.setPrototypeOf(f,c.prototype),f}function c(y,f,p){if(typeof y=="number"){if(typeof f=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return O(y)}return d(y,f,p)}c.poolSize=8192;function d(y,f,p){if(typeof y=="string")return x(y,f);if(ArrayBuffer.isView(y))return T(y);if(y==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof y);if(Ie(y,ArrayBuffer)||y&&Ie(y.buffer,ArrayBuffer)||typeof SharedArrayBuffer!="undefined"&&(Ie(y,SharedArrayBuffer)||y&&Ie(y.buffer,SharedArrayBuffer)))return C(y,f,p);if(typeof y=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const A=y.valueOf&&y.valueOf();if(A!=null&&A!==y)return c.from(A,f,p);const U=M(y);if(U)return U;if(typeof Symbol!="undefined"&&Symbol.toPrimitive!=null&&typeof y[Symbol.toPrimitive]=="function")return c.from(y[Symbol.toPrimitive]("string"),f,p);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof y)}c.from=function(y,f,p){return d(y,f,p)},Object.setPrototypeOf(c.prototype,Uint8Array.prototype),Object.setPrototypeOf(c,Uint8Array);function _(y){if(typeof y!="number")throw new TypeError('"size" argument must be of type number');if(y<0)throw new RangeError('The value "'+y+'" is invalid for option "size"')}function b(y,f,p){return _(y),y<=0?o(y):f!==void 0?typeof p=="string"?o(y).fill(f,p):o(y).fill(f):o(y)}c.alloc=function(y,f,p){return b(y,f,p)};function O(y){return _(y),o(y<0?0:P(y)|0)}c.allocUnsafe=function(y){return O(y)},c.allocUnsafeSlow=function(y){return O(y)};function x(y,f){if((typeof f!="string"||f==="")&&(f="utf8"),!c.isEncoding(f))throw new TypeError("Unknown encoding: "+f);const p=z(y,f)|0;let A=o(p);const U=A.write(y,f);return U!==p&&(A=A.slice(0,U)),A}function S(y){const f=y.length<0?0:P(y.length)|0,p=o(f);for(let A=0;A<f;A+=1)p[A]=y[A]&255;return p}function T(y){if(Ie(y,Uint8Array)){const f=new Uint8Array(y);return C(f.buffer,f.byteOffset,f.byteLength)}return S(y)}function C(y,f,p){if(f<0||y.byteLength<f)throw new RangeError('"offset" is outside of buffer bounds');if(y.byteLength<f+(p||0))throw new RangeError('"length" is outside of buffer bounds');let A;return f===void 0&&p===void 0?A=new Uint8Array(y):p===void 0?A=new Uint8Array(y,f):A=new Uint8Array(y,f,p),Object.setPrototypeOf(A,c.prototype),A}function M(y){if(c.isBuffer(y)){const f=P(y.length)|0,p=o(f);return p.length===0||y.copy(p,0,0,f),p}if(y.length!==void 0)return typeof y.length!="number"||Lt(y.length)?o(0):S(y);if(y.type==="Buffer"&&Array.isArray(y.data))return S(y.data)}function P(y){if(y>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return y|0}function W(y){return+y!=y&&(y=0),c.alloc(+y)}c.isBuffer=function(f){return f!=null&&f._isBuffer===!0&&f!==c.prototype},c.compare=function(f,p){if(Ie(f,Uint8Array)&&(f=c.from(f,f.offset,f.byteLength)),Ie(p,Uint8Array)&&(p=c.from(p,p.offset,p.byteLength)),!c.isBuffer(f)||!c.isBuffer(p))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(f===p)return 0;let A=f.length,U=p.length;for(let q=0,j=Math.min(A,U);q<j;++q)if(f[q]!==p[q]){A=f[q],U=p[q];break}return A<U?-1:U<A?1:0},c.isEncoding=function(f){switch(String(f).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},c.concat=function(f,p){if(!Array.isArray(f))throw new TypeError('"list" argument must be an Array of Buffers');if(f.length===0)return c.alloc(0);let A;if(p===void 0)for(p=0,A=0;A<f.length;++A)p+=f[A].length;const U=c.allocUnsafe(p);let q=0;for(A=0;A<f.length;++A){let j=f[A];if(Ie(j,Uint8Array))q+j.length>U.length?(c.isBuffer(j)||(j=c.from(j)),j.copy(U,q)):Uint8Array.prototype.set.call(U,j,q);else if(c.isBuffer(j))j.copy(U,q);else throw new TypeError('"list" argument must be an Array of Buffers');q+=j.length}return U};function z(y,f){if(c.isBuffer(y))return y.length;if(ArrayBuffer.isView(y)||Ie(y,ArrayBuffer))return y.byteLength;if(typeof y!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof y);const p=y.length,A=arguments.length>2&&arguments[2]===!0;if(!A&&p===0)return 0;let U=!1;for(;;)switch(f){case"ascii":case"latin1":case"binary":return p;case"utf8":case"utf-8":return Ct(y).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return p*2;case"hex":return p>>>1;case"base64":return Ut(y).length;default:if(U)return A?-1:Ct(y).length;f=(""+f).toLowerCase(),U=!0}}c.byteLength=z;function Q(y,f,p){let A=!1;if((f===void 0||f<0)&&(f=0),f>this.length||((p===void 0||p>this.length)&&(p=this.length),p<=0)||(p>>>=0,f>>>=0,p<=f))return"";for(y||(y="utf8");;)switch(y){case"hex":return N(this,f,p);case"utf8":case"utf-8":return a(this,f,p);case"ascii":return R(this,f,p);case"latin1":case"binary":return v(this,f,p);case"base64":return m(this,f,p);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return L(this,f,p);default:if(A)throw new TypeError("Unknown encoding: "+y);y=(y+"").toLowerCase(),A=!0}}c.prototype._isBuffer=!0;function Z(y,f,p){const A=y[f];y[f]=y[p],y[p]=A}c.prototype.swap16=function(){const f=this.length;if(f%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let p=0;p<f;p+=2)Z(this,p,p+1);return this},c.prototype.swap32=function(){const f=this.length;if(f%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let p=0;p<f;p+=4)Z(this,p,p+3),Z(this,p+1,p+2);return this},c.prototype.swap64=function(){const f=this.length;if(f%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let p=0;p<f;p+=8)Z(this,p,p+7),Z(this,p+1,p+6),Z(this,p+2,p+5),Z(this,p+3,p+4);return this},c.prototype.toString=function(){const f=this.length;return f===0?"":arguments.length===0?a(this,0,f):Q.apply(this,arguments)},c.prototype.toLocaleString=c.prototype.toString,c.prototype.equals=function(f){if(!c.isBuffer(f))throw new TypeError("Argument must be a Buffer");return this===f?!0:c.compare(this,f)===0},c.prototype.inspect=function(){let f="";const p=r.INSPECT_MAX_BYTES;return f=this.toString("hex",0,p).replace(/(.{2})/g,"$1 ").trim(),this.length>p&&(f+=" ... "),"<Buffer "+f+">"},n&&(c.prototype[n]=c.prototype.inspect),c.prototype.compare=function(f,p,A,U,q){if(Ie(f,Uint8Array)&&(f=c.from(f,f.offset,f.byteLength)),!c.isBuffer(f))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof f);if(p===void 0&&(p=0),A===void 0&&(A=f?f.length:0),U===void 0&&(U=0),q===void 0&&(q=this.length),p<0||A>f.length||U<0||q>this.length)throw new RangeError("out of range index");if(U>=q&&p>=A)return 0;if(U>=q)return-1;if(p>=A)return 1;if(p>>>=0,A>>>=0,U>>>=0,q>>>=0,this===f)return 0;let j=q-U,mt=A-p;const _t=Math.min(j,mt),gt=this.slice(U,q),Bt=f.slice(p,A);for(let dt=0;dt<_t;++dt)if(gt[dt]!==Bt[dt]){j=gt[dt],mt=Bt[dt];break}return j<mt?-1:mt<j?1:0};function st(y,f,p,A,U){if(y.length===0)return-1;if(typeof p=="string"?(A=p,p=0):p>2147483647?p=2147483647:p<-2147483648&&(p=-2147483648),p=+p,Lt(p)&&(p=U?0:y.length-1),p<0&&(p=y.length+p),p>=y.length){if(U)return-1;p=y.length-1}else if(p<0)if(U)p=0;else return-1;if(typeof f=="string"&&(f=c.from(f,A)),c.isBuffer(f))return f.length===0?-1:pt(y,f,p,A,U);if(typeof f=="number")return f=f&255,typeof Uint8Array.prototype.indexOf=="function"?U?Uint8Array.prototype.indexOf.call(y,f,p):Uint8Array.prototype.lastIndexOf.call(y,f,p):pt(y,[f],p,A,U);throw new TypeError("val must be string, number or Buffer")}function pt(y,f,p,A,U){let q=1,j=y.length,mt=f.length;if(A!==void 0&&(A=String(A).toLowerCase(),A==="ucs2"||A==="ucs-2"||A==="utf16le"||A==="utf-16le")){if(y.length<2||f.length<2)return-1;q=2,j/=2,mt/=2,p/=2}function _t(Bt,dt){return q===1?Bt[dt]:Bt.readUInt16BE(dt*q)}let gt;if(U){let Bt=-1;for(gt=p;gt<j;gt++)if(_t(y,gt)===_t(f,Bt===-1?0:gt-Bt)){if(Bt===-1&&(Bt=gt),gt-Bt+1===mt)return Bt*q}else Bt!==-1&&(gt-=gt-Bt),Bt=-1}else for(p+mt>j&&(p=j-mt),gt=p;gt>=0;gt--){let Bt=!0;for(let dt=0;dt<mt;dt++)if(_t(y,gt+dt)!==_t(f,dt)){Bt=!1;break}if(Bt)return gt}return-1}c.prototype.includes=function(f,p,A){return this.indexOf(f,p,A)!==-1},c.prototype.indexOf=function(f,p,A){return st(this,f,p,A,!0)},c.prototype.lastIndexOf=function(f,p,A){return st(this,f,p,A,!1)};function ct(y,f,p,A){p=Number(p)||0;const U=y.length-p;A?(A=Number(A),A>U&&(A=U)):A=U;const q=f.length;A>q/2&&(A=q/2);let j;for(j=0;j<A;++j){const mt=parseInt(f.substr(j*2,2),16);if(Lt(mt))return j;y[p+j]=mt}return j}function k(y,f,p,A){return Tt(Ct(f,y.length-p),y,p,A)}function D(y,f,p,A){return Tt(qt(f),y,p,A)}function V(y,f,p,A){return Tt(Ut(f),y,p,A)}function K(y,f,p,A){return Tt(fr(f,y.length-p),y,p,A)}c.prototype.write=function(f,p,A,U){if(p===void 0)U="utf8",A=this.length,p=0;else if(A===void 0&&typeof p=="string")U=p,A=this.length,p=0;else if(isFinite(p))p=p>>>0,isFinite(A)?(A=A>>>0,U===void 0&&(U="utf8")):(U=A,A=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const q=this.length-p;if((A===void 0||A>q)&&(A=q),f.length>0&&(A<0||p<0)||p>this.length)throw new RangeError("Attempt to write outside buffer bounds");U||(U="utf8");let j=!1;for(;;)switch(U){case"hex":return ct(this,f,p,A);case"utf8":case"utf-8":return k(this,f,p,A);case"ascii":case"latin1":case"binary":return D(this,f,p,A);case"base64":return V(this,f,p,A);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return K(this,f,p,A);default:if(j)throw new TypeError("Unknown encoding: "+U);U=(""+U).toLowerCase(),j=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function m(y,f,p){return f===0&&p===y.length?t.fromByteArray(y):t.fromByteArray(y.slice(f,p))}function a(y,f,p){p=Math.min(y.length,p);const A=[];let U=f;for(;U<p;){const q=y[U];let j=null,mt=q>239?4:q>223?3:q>191?2:1;if(U+mt<=p){let _t,gt,Bt,dt;switch(mt){case 1:q<128&&(j=q);break;case 2:_t=y[U+1],(_t&192)===128&&(dt=(q&31)<<6|_t&63,dt>127&&(j=dt));break;case 3:_t=y[U+1],gt=y[U+2],(_t&192)===128&&(gt&192)===128&&(dt=(q&15)<<12|(_t&63)<<6|gt&63,dt>2047&&(dt<55296||dt>57343)&&(j=dt));break;case 4:_t=y[U+1],gt=y[U+2],Bt=y[U+3],(_t&192)===128&&(gt&192)===128&&(Bt&192)===128&&(dt=(q&15)<<18|(_t&63)<<12|(gt&63)<<6|Bt&63,dt>65535&&dt<1114112&&(j=dt))}}j===null?(j=65533,mt=1):j>65535&&(j-=65536,A.push(j>>>10&1023|55296),j=56320|j&1023),A.push(j),U+=mt}return g(A)}const h=4096;function g(y){const f=y.length;if(f<=h)return String.fromCharCode.apply(String,y);let p="",A=0;for(;A<f;)p+=String.fromCharCode.apply(String,y.slice(A,A+=h));return p}function R(y,f,p){let A="";p=Math.min(y.length,p);for(let U=f;U<p;++U)A+=String.fromCharCode(y[U]&127);return A}function v(y,f,p){let A="";p=Math.min(y.length,p);for(let U=f;U<p;++U)A+=String.fromCharCode(y[U]);return A}function N(y,f,p){const A=y.length;(!f||f<0)&&(f=0),(!p||p<0||p>A)&&(p=A);let U="";for(let q=f;q<p;++q)U+=$t[y[q]];return U}function L(y,f,p){const A=y.slice(f,p);let U="";for(let q=0;q<A.length-1;q+=2)U+=String.fromCharCode(A[q]+A[q+1]*256);return U}c.prototype.slice=function(f,p){const A=this.length;f=~~f,p=p===void 0?A:~~p,f<0?(f+=A,f<0&&(f=0)):f>A&&(f=A),p<0?(p+=A,p<0&&(p=0)):p>A&&(p=A),p<f&&(p=f);const U=this.subarray(f,p);return Object.setPrototypeOf(U,c.prototype),U};function E(y,f,p){if(y%1!==0||y<0)throw new RangeError("offset is not uint");if(y+f>p)throw new RangeError("Trying to access beyond buffer length")}c.prototype.readUintLE=c.prototype.readUIntLE=function(f,p,A){f=f>>>0,p=p>>>0,A||E(f,p,this.length);let U=this[f],q=1,j=0;for(;++j<p&&(q*=256);)U+=this[f+j]*q;return U},c.prototype.readUintBE=c.prototype.readUIntBE=function(f,p,A){f=f>>>0,p=p>>>0,A||E(f,p,this.length);let U=this[f+--p],q=1;for(;p>0&&(q*=256);)U+=this[f+--p]*q;return U},c.prototype.readUint8=c.prototype.readUInt8=function(f,p){return f=f>>>0,p||E(f,1,this.length),this[f]},c.prototype.readUint16LE=c.prototype.readUInt16LE=function(f,p){return f=f>>>0,p||E(f,2,this.length),this[f]|this[f+1]<<8},c.prototype.readUint16BE=c.prototype.readUInt16BE=function(f,p){return f=f>>>0,p||E(f,2,this.length),this[f]<<8|this[f+1]},c.prototype.readUint32LE=c.prototype.readUInt32LE=function(f,p){return f=f>>>0,p||E(f,4,this.length),(this[f]|this[f+1]<<8|this[f+2]<<16)+this[f+3]*16777216},c.prototype.readUint32BE=c.prototype.readUInt32BE=function(f,p){return f=f>>>0,p||E(f,4,this.length),this[f]*16777216+(this[f+1]<<16|this[f+2]<<8|this[f+3])},c.prototype.readBigUInt64LE=Ce(function(f){f=f>>>0,Be(f,"offset");const p=this[f],A=this[f+7];(p===void 0||A===void 0)&&xt(f,this.length-8);const U=p+this[++f]*bt(2,8)+this[++f]*bt(2,16)+this[++f]*bt(2,24),q=this[++f]+this[++f]*bt(2,8)+this[++f]*bt(2,16)+A*bt(2,24);return BigInt(U)+(BigInt(q)<<BigInt(32))}),c.prototype.readBigUInt64BE=Ce(function(f){f=f>>>0,Be(f,"offset");const p=this[f],A=this[f+7];(p===void 0||A===void 0)&&xt(f,this.length-8);const U=p*bt(2,24)+this[++f]*bt(2,16)+this[++f]*bt(2,8)+this[++f],q=this[++f]*bt(2,24)+this[++f]*bt(2,16)+this[++f]*bt(2,8)+A;return(BigInt(U)<<BigInt(32))+BigInt(q)}),c.prototype.readIntLE=function(f,p,A){f=f>>>0,p=p>>>0,A||E(f,p,this.length);let U=this[f],q=1,j=0;for(;++j<p&&(q*=256);)U+=this[f+j]*q;return q*=128,U>=q&&(U-=Math.pow(2,8*p)),U},c.prototype.readIntBE=function(f,p,A){f=f>>>0,p=p>>>0,A||E(f,p,this.length);let U=p,q=1,j=this[f+--U];for(;U>0&&(q*=256);)j+=this[f+--U]*q;return q*=128,j>=q&&(j-=Math.pow(2,8*p)),j},c.prototype.readInt8=function(f,p){return f=f>>>0,p||E(f,1,this.length),this[f]&128?(255-this[f]+1)*-1:this[f]},c.prototype.readInt16LE=function(f,p){f=f>>>0,p||E(f,2,this.length);const A=this[f]|this[f+1]<<8;return A&32768?A|4294901760:A},c.prototype.readInt16BE=function(f,p){f=f>>>0,p||E(f,2,this.length);const A=this[f+1]|this[f]<<8;return A&32768?A|4294901760:A},c.prototype.readInt32LE=function(f,p){return f=f>>>0,p||E(f,4,this.length),this[f]|this[f+1]<<8|this[f+2]<<16|this[f+3]<<24},c.prototype.readInt32BE=function(f,p){return f=f>>>0,p||E(f,4,this.length),this[f]<<24|this[f+1]<<16|this[f+2]<<8|this[f+3]},c.prototype.readBigInt64LE=Ce(function(f){f=f>>>0,Be(f,"offset");const p=this[f],A=this[f+7];(p===void 0||A===void 0)&&xt(f,this.length-8);const U=this[f+4]+this[f+5]*bt(2,8)+this[f+6]*bt(2,16)+(A<<24);return(BigInt(U)<<BigInt(32))+BigInt(p+this[++f]*bt(2,8)+this[++f]*bt(2,16)+this[++f]*bt(2,24))}),c.prototype.readBigInt64BE=Ce(function(f){f=f>>>0,Be(f,"offset");const p=this[f],A=this[f+7];(p===void 0||A===void 0)&&xt(f,this.length-8);const U=(p<<24)+this[++f]*bt(2,16)+this[++f]*bt(2,8)+this[++f];return(BigInt(U)<<BigInt(32))+BigInt(this[++f]*bt(2,24)+this[++f]*bt(2,16)+this[++f]*bt(2,8)+A)}),c.prototype.readFloatLE=function(f,p){return f=f>>>0,p||E(f,4,this.length),e.read(this,f,!0,23,4)},c.prototype.readFloatBE=function(f,p){return f=f>>>0,p||E(f,4,this.length),e.read(this,f,!1,23,4)},c.prototype.readDoubleLE=function(f,p){return f=f>>>0,p||E(f,8,this.length),e.read(this,f,!0,52,8)},c.prototype.readDoubleBE=function(f,p){return f=f>>>0,p||E(f,8,this.length),e.read(this,f,!1,52,8)};function u(y,f,p,A,U,q){if(!c.isBuffer(y))throw new TypeError('"buffer" argument must be a Buffer instance');if(f>U||f<q)throw new RangeError('"value" argument is out of bounds');if(p+A>y.length)throw new RangeError("Index out of range")}c.prototype.writeUintLE=c.prototype.writeUIntLE=function(f,p,A,U){if(f=+f,p=p>>>0,A=A>>>0,!U){const mt=Math.pow(2,8*A)-1;u(this,f,p,A,mt,0)}let q=1,j=0;for(this[p]=f&255;++j<A&&(q*=256);)this[p+j]=f/q&255;return p+A},c.prototype.writeUintBE=c.prototype.writeUIntBE=function(f,p,A,U){if(f=+f,p=p>>>0,A=A>>>0,!U){const mt=Math.pow(2,8*A)-1;u(this,f,p,A,mt,0)}let q=A-1,j=1;for(this[p+q]=f&255;--q>=0&&(j*=256);)this[p+q]=f/j&255;return p+A},c.prototype.writeUint8=c.prototype.writeUInt8=function(f,p,A){return f=+f,p=p>>>0,A||u(this,f,p,1,255,0),this[p]=f&255,p+1},c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(f,p,A){return f=+f,p=p>>>0,A||u(this,f,p,2,65535,0),this[p]=f&255,this[p+1]=f>>>8,p+2},c.prototype.writeUint16BE=c.prototype.writeUInt16BE=function(f,p,A){return f=+f,p=p>>>0,A||u(this,f,p,2,65535,0),this[p]=f>>>8,this[p+1]=f&255,p+2},c.prototype.writeUint32LE=c.prototype.writeUInt32LE=function(f,p,A){return f=+f,p=p>>>0,A||u(this,f,p,4,4294967295,0),this[p+3]=f>>>24,this[p+2]=f>>>16,this[p+1]=f>>>8,this[p]=f&255,p+4},c.prototype.writeUint32BE=c.prototype.writeUInt32BE=function(f,p,A){return f=+f,p=p>>>0,A||u(this,f,p,4,4294967295,0),this[p]=f>>>24,this[p+1]=f>>>16,this[p+2]=f>>>8,this[p+3]=f&255,p+4};function l(y,f,p,A,U){Ot(f,A,U,y,p,7);let q=Number(f&BigInt(4294967295));y[p++]=q,q=q>>8,y[p++]=q,q=q>>8,y[p++]=q,q=q>>8,y[p++]=q;let j=Number(f>>BigInt(32)&BigInt(4294967295));return y[p++]=j,j=j>>8,y[p++]=j,j=j>>8,y[p++]=j,j=j>>8,y[p++]=j,p}function w(y,f,p,A,U){Ot(f,A,U,y,p,7);let q=Number(f&BigInt(4294967295));y[p+7]=q,q=q>>8,y[p+6]=q,q=q>>8,y[p+5]=q,q=q>>8,y[p+4]=q;let j=Number(f>>BigInt(32)&BigInt(4294967295));return y[p+3]=j,j=j>>8,y[p+2]=j,j=j>>8,y[p+1]=j,j=j>>8,y[p]=j,p+8}c.prototype.writeBigUInt64LE=Ce(function(f,p=0){return l(this,f,p,BigInt(0),BigInt("0xffffffffffffffff"))}),c.prototype.writeBigUInt64BE=Ce(function(f,p=0){return w(this,f,p,BigInt(0),BigInt("0xffffffffffffffff"))}),c.prototype.writeIntLE=function(f,p,A,U){if(f=+f,p=p>>>0,!U){const _t=Math.pow(2,8*A-1);u(this,f,p,A,_t-1,-_t)}let q=0,j=1,mt=0;for(this[p]=f&255;++q<A&&(j*=256);)f<0&&mt===0&&this[p+q-1]!==0&&(mt=1),this[p+q]=(f/j>>0)-mt&255;return p+A},c.prototype.writeIntBE=function(f,p,A,U){if(f=+f,p=p>>>0,!U){const _t=Math.pow(2,8*A-1);u(this,f,p,A,_t-1,-_t)}let q=A-1,j=1,mt=0;for(this[p+q]=f&255;--q>=0&&(j*=256);)f<0&&mt===0&&this[p+q+1]!==0&&(mt=1),this[p+q]=(f/j>>0)-mt&255;return p+A},c.prototype.writeInt8=function(f,p,A){return f=+f,p=p>>>0,A||u(this,f,p,1,127,-128),f<0&&(f=255+f+1),this[p]=f&255,p+1},c.prototype.writeInt16LE=function(f,p,A){return f=+f,p=p>>>0,A||u(this,f,p,2,32767,-32768),this[p]=f&255,this[p+1]=f>>>8,p+2},c.prototype.writeInt16BE=function(f,p,A){return f=+f,p=p>>>0,A||u(this,f,p,2,32767,-32768),this[p]=f>>>8,this[p+1]=f&255,p+2},c.prototype.writeInt32LE=function(f,p,A){return f=+f,p=p>>>0,A||u(this,f,p,4,2147483647,-2147483648),this[p]=f&255,this[p+1]=f>>>8,this[p+2]=f>>>16,this[p+3]=f>>>24,p+4},c.prototype.writeInt32BE=function(f,p,A){return f=+f,p=p>>>0,A||u(this,f,p,4,2147483647,-2147483648),f<0&&(f=4294967295+f+1),this[p]=f>>>24,this[p+1]=f>>>16,this[p+2]=f>>>8,this[p+3]=f&255,p+4},c.prototype.writeBigInt64LE=Ce(function(f,p=0){return l(this,f,p,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),c.prototype.writeBigInt64BE=Ce(function(f,p=0){return w(this,f,p,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function I(y,f,p,A,U,q){if(p+A>y.length)throw new RangeError("Index out of range");if(p<0)throw new RangeError("Index out of range")}function F(y,f,p,A,U){return f=+f,p=p>>>0,U||I(y,f,p,4),e.write(y,f,p,A,23,4),p+4}c.prototype.writeFloatLE=function(f,p,A){return F(this,f,p,!0,A)},c.prototype.writeFloatBE=function(f,p,A){return F(this,f,p,!1,A)};function X(y,f,p,A,U){return f=+f,p=p>>>0,U||I(y,f,p,8),e.write(y,f,p,A,52,8),p+8}c.prototype.writeDoubleLE=function(f,p,A){return X(this,f,p,!0,A)},c.prototype.writeDoubleBE=function(f,p,A){return X(this,f,p,!1,A)},c.prototype.copy=function(f,p,A,U){if(!c.isBuffer(f))throw new TypeError("argument should be a Buffer");if(A||(A=0),!U&&U!==0&&(U=this.length),p>=f.length&&(p=f.length),p||(p=0),U>0&&U<A&&(U=A),U===A||f.length===0||this.length===0)return 0;if(p<0)throw new RangeError("targetStart out of bounds");if(A<0||A>=this.length)throw new RangeError("Index out of range");if(U<0)throw new RangeError("sourceEnd out of bounds");U>this.length&&(U=this.length),f.length-p<U-A&&(U=f.length-p+A);const q=U-A;return this===f&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(p,A,U):Uint8Array.prototype.set.call(f,this.subarray(A,U),p),q},c.prototype.fill=function(f,p,A,U){if(typeof f=="string"){if(typeof p=="string"?(U=p,p=0,A=this.length):typeof A=="string"&&(U=A,A=this.length),U!==void 0&&typeof U!="string")throw new TypeError("encoding must be a string");if(typeof U=="string"&&!c.isEncoding(U))throw new TypeError("Unknown encoding: "+U);if(f.length===1){const j=f.charCodeAt(0);(U==="utf8"&&j<128||U==="latin1")&&(f=j)}}else typeof f=="number"?f=f&255:typeof f=="boolean"&&(f=Number(f));if(p<0||this.length<p||this.length<A)throw new RangeError("Out of range index");if(A<=p)return this;p=p>>>0,A=A===void 0?this.length:A>>>0,f||(f=0);let q;if(typeof f=="number")for(q=p;q<A;++q)this[q]=f;else{const j=c.isBuffer(f)?f:c.from(f,U),mt=j.length;if(mt===0)throw new TypeError('The value "'+f+'" is invalid for argument "value"');for(q=0;q<A-p;++q)this[q+p]=j[q%mt]}return this};const et={};function it(y,f,p){et[y]=class extends p{constructor(){super(),Object.defineProperty(this,"message",{value:f.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${y}]`,this.stack,delete this.name}get code(){return y}set code(U){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:U,writable:!0})}toString(){return`${this.name} [${y}]: ${this.message}`}}}it("ERR_BUFFER_OUT_OF_BOUNDS",function(y){return y?`${y} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),it("ERR_INVALID_ARG_TYPE",function(y,f){return`The "${y}" argument must be of type number. Received type ${typeof f}`},TypeError),it("ERR_OUT_OF_RANGE",function(y,f,p){let A=`The value of "${y}" is out of range.`,U=p;return Number.isInteger(p)&&Math.abs(p)>bt(2,32)?U=St(String(p)):typeof p=="bigint"&&(U=String(p),(p>bt(BigInt(2),BigInt(32))||p<-bt(BigInt(2),BigInt(32)))&&(U=St(U)),U+="n"),A+=` It must be ${f}. Received ${U}`,A},RangeError);function St(y){let f="",p=y.length;const A=y[0]==="-"?1:0;for(;p>=A+4;p-=3)f=`_${y.slice(p-3,p)}${f}`;return`${y.slice(0,p)}${f}`}function vt(y,f,p){Be(f,"offset"),(y[f]===void 0||y[f+p]===void 0)&&xt(f,y.length-(p+1))}function Ot(y,f,p,A,U,q){if(y>p||y<f){const j=typeof f=="bigint"?"n":"";let mt;throw f===0||f===BigInt(0)?mt=`>= 0${j} and < 2${j} ** ${(q+1)*8}${j}`:mt=`>= -(2${j} ** ${(q+1)*8-1}${j}) and < 2 ** ${(q+1)*8-1}${j}`,new et.ERR_OUT_OF_RANGE("value",mt,y)}vt(A,U,q)}function Be(y,f){if(typeof y!="number")throw new et.ERR_INVALID_ARG_TYPE(f,"number",y)}function xt(y,f,p){throw Math.floor(y)!==y?(Be(y,p),new et.ERR_OUT_OF_RANGE("offset","an integer",y)):f<0?new et.ERR_BUFFER_OUT_OF_BOUNDS:new et.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${f}`,y)}const Ft=/[^+/0-9A-Za-z-_]/g;function lr(y){if(y=y.split("=")[0],y=y.trim().replace(Ft,""),y.length<2)return"";for(;y.length%4!==0;)y=y+"=";return y}function Ct(y,f){f=f||1/0;let p;const A=y.length;let U=null;const q=[];for(let j=0;j<A;++j){if(p=y.charCodeAt(j),p>55295&&p<57344){if(!U){if(p>56319){(f-=3)>-1&&q.push(239,191,189);continue}else if(j+1===A){(f-=3)>-1&&q.push(239,191,189);continue}U=p;continue}if(p<56320){(f-=3)>-1&&q.push(239,191,189),U=p;continue}p=(U-55296<<10|p-56320)+65536}else U&&(f-=3)>-1&&q.push(239,191,189);if(U=null,p<128){if((f-=1)<0)break;q.push(p)}else if(p<2048){if((f-=2)<0)break;q.push(p>>6|192,p&63|128)}else if(p<65536){if((f-=3)<0)break;q.push(p>>12|224,p>>6&63|128,p&63|128)}else if(p<1114112){if((f-=4)<0)break;q.push(p>>18|240,p>>12&63|128,p>>6&63|128,p&63|128)}else throw new Error("Invalid code point")}return q}function qt(y){const f=[];for(let p=0;p<y.length;++p)f.push(y.charCodeAt(p)&255);return f}function fr(y,f){let p,A,U;const q=[];for(let j=0;j<y.length&&!((f-=2)<0);++j)p=y.charCodeAt(j),A=p>>8,U=p%256,q.push(U),q.push(A);return q}function Ut(y){return t.toByteArray(lr(y))}function Tt(y,f,p,A){let U;for(U=0;U<A&&!(U+p>=f.length||U>=y.length);++U)f[U+p]=y[U];return U}function Ie(y,f){return y instanceof f||y!=null&&y.constructor!=null&&y.constructor.name!=null&&y.constructor.name===f.name}function Lt(y){return y!==y}const $t=(function(){const y="0123456789abcdef",f=new Array(256);for(let p=0;p<16;++p){const A=p*16;for(let U=0;U<16;++U)f[A+U]=y[p]+y[U]}return f})();function Ce(y){return typeof BigInt=="undefined"?zt:y}function zt(){throw new Error("BigInt not supported")}})(Ii)),Ii}var Et=ys();const Rn=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function rr(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function Qi(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function _n(r,...t){if(!rr(r))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(r.length))throw new Error("Uint8Array expected of length "+t+", got length="+r.length)}function ia(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");Qi(r.outputLen),Qi(r.blockLen)}function Br(r,t=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(t&&r.finished)throw new Error("Hash#digest() has already been called")}function lu(r,t){_n(r);const e=t.outputLen;if(r.length<e)throw new Error("digestInto() expects output buffer of length at least "+e)}function kn(...r){for(let t=0;t<r.length;t++)r[t].fill(0)}function Oi(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function ke(r,t){return r<<32-t|r>>>t}const sa=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",fu=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function dn(r){if(_n(r),sa)return r.toHex();let t="";for(let e=0;e<r.length;e++)t+=fu[r[e]];return t}const $e={_0:48,_9:57,A:65,F:70,a:97,f:102};function no(r){if(r>=$e._0&&r<=$e._9)return r-$e._0;if(r>=$e.A&&r<=$e.F)return r-($e.A-10);if(r>=$e.a&&r<=$e.f)return r-($e.a-10)}function Cr(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);if(sa)return Uint8Array.fromHex(r);const t=r.length,e=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const n=new Uint8Array(e);for(let s=0,i=0;s<e;s++,i+=2){const o=no(r.charCodeAt(i)),c=no(r.charCodeAt(i+1));if(o===void 0||c===void 0){const d=r[i]+r[i+1];throw new Error('hex string expected, got non-hex character "'+d+'" at index '+i)}n[s]=o*16+c}return n}function hu(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}function ws(r){return typeof r=="string"&&(r=hu(r)),_n(r),r}function De(...r){let t=0;for(let n=0;n<r.length;n++){const s=r[n];_n(s),t+=s.length}const e=new Uint8Array(t);for(let n=0,s=0;n<r.length;n++){const i=r[n];e.set(i,s),s+=i.length}return e}class oa{}function aa(r){const t=n=>r().update(ws(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function Es(r=32){if(Rn&&typeof Rn.getRandomValues=="function")return Rn.getRandomValues(new Uint8Array(r));if(Rn&&typeof Rn.randomBytes=="function")return Uint8Array.from(Rn.randomBytes(r));throw new Error("crypto.getRandomValues must be defined")}function du(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);const s=BigInt(32),i=BigInt(4294967295),o=Number(e>>s&i),c=Number(e&i),d=n?4:0,_=n?0:4;r.setUint32(t+d,o,n),r.setUint32(t+_,c,n)}function pu(r,t,e){return r&t^~r&e}function gu(r,t,e){return r&t^r&e^t&e}class ca extends oa{constructor(t,e,n,s){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=s,this.buffer=new Uint8Array(t),this.view=Oi(this.buffer)}update(t){Br(this),t=ws(t),_n(t);const{view:e,buffer:n,blockLen:s}=this,i=t.length;for(let o=0;o<i;){const c=Math.min(s-this.pos,i-o);if(c===s){const d=Oi(t);for(;s<=i-o;o+=s)this.process(d,o);continue}n.set(t.subarray(o,o+c),this.pos),this.pos+=c,o+=c,this.pos===s&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Br(this),lu(t,this),this.finished=!0;const{buffer:e,view:n,blockLen:s,isLE:i}=this;let{pos:o}=this;e[o++]=128,kn(this.buffer.subarray(o)),this.padOffset>s-o&&(this.process(n,0),o=0);for(let O=o;O<s;O++)e[O]=0;du(n,s-8,BigInt(this.length*8),i),this.process(n,0);const c=Oi(t),d=this.outputLen;if(d%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const _=d/4,b=this.get();if(_>b.length)throw new Error("_sha2: outputLen bigger than state");for(let O=0;O<_;O++)c.setUint32(4*O,b[O],i)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:n,length:s,finished:i,destroyed:o,pos:c}=this;return t.destroyed=o,t.finished=i,t.length=s,t.pos=c,s%e&&t.buffer.set(n),t}clone(){return this._cloneInto()}}const Xe=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),me=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),gr=BigInt(bt(2,32)-1),ro=BigInt(32);function _u(r,t=!1){return t?{h:Number(r&gr),l:Number(r>>ro&gr)}:{h:Number(r>>ro&gr)|0,l:Number(r&gr)|0}}function mu(r,t=!1){const e=r.length;let n=new Uint32Array(e),s=new Uint32Array(e);for(let i=0;i<e;i++){const{h:o,l:c}=_u(r[i],t);[n[i],s[i]]=[o,c]}return[n,s]}const io=(r,t,e)=>r>>>e,so=(r,t,e)=>r<<32-e|t>>>e,bn=(r,t,e)=>r>>>e|t<<32-e,An=(r,t,e)=>r<<32-e|t>>>e,_r=(r,t,e)=>r<<64-e|t>>>e-32,mr=(r,t,e)=>r>>>e-32|t<<64-e;function ze(r,t,e,n){const s=(t>>>0)+(n>>>0);return{h:r+e+(s/bt(2,32)|0)|0,l:s|0}}const yu=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),wu=(r,t,e,n)=>t+e+n+(r/bt(2,32)|0)|0,Eu=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),Ru=(r,t,e,n,s)=>t+e+n+s+(r/bt(2,32)|0)|0,bu=(r,t,e,n,s)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(s>>>0),Au=(r,t,e,n,s,i)=>t+e+n+s+i+(r/bt(2,32)|0)|0,Su=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Ye=new Uint32Array(64);class vu extends ca{constructor(t=32){super(64,t,8,!1),this.A=Xe[0]|0,this.B=Xe[1]|0,this.C=Xe[2]|0,this.D=Xe[3]|0,this.E=Xe[4]|0,this.F=Xe[5]|0,this.G=Xe[6]|0,this.H=Xe[7]|0}get(){const{A:t,B:e,C:n,D:s,E:i,F:o,G:c,H:d}=this;return[t,e,n,s,i,o,c,d]}set(t,e,n,s,i,o,c,d){this.A=t|0,this.B=e|0,this.C=n|0,this.D=s|0,this.E=i|0,this.F=o|0,this.G=c|0,this.H=d|0}process(t,e){for(let O=0;O<16;O++,e+=4)Ye[O]=t.getUint32(e,!1);for(let O=16;O<64;O++){const x=Ye[O-15],S=Ye[O-2],T=ke(x,7)^ke(x,18)^x>>>3,C=ke(S,17)^ke(S,19)^S>>>10;Ye[O]=C+Ye[O-7]+T+Ye[O-16]|0}let{A:n,B:s,C:i,D:o,E:c,F:d,G:_,H:b}=this;for(let O=0;O<64;O++){const x=ke(c,6)^ke(c,11)^ke(c,25),S=b+x+pu(c,d,_)+Su[O]+Ye[O]|0,C=(ke(n,2)^ke(n,13)^ke(n,22))+gu(n,s,i)|0;b=_,_=d,d=c,c=o+S|0,o=i,i=s,s=n,n=S+C|0}n=n+this.A|0,s=s+this.B|0,i=i+this.C|0,o=o+this.D|0,c=c+this.E|0,d=d+this.F|0,_=_+this.G|0,b=b+this.H|0,this.set(n,s,i,o,c,d,_,b)}roundClean(){kn(Ye)}destroy(){this.set(0,0,0,0,0,0,0,0),kn(this.buffer)}}const ua=mu(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(r=>BigInt(r))),Iu=ua[0],Ou=ua[1],Ze=new Uint32Array(80),Je=new Uint32Array(80);class xu extends ca{constructor(t=64){super(128,t,16,!1),this.Ah=me[0]|0,this.Al=me[1]|0,this.Bh=me[2]|0,this.Bl=me[3]|0,this.Ch=me[4]|0,this.Cl=me[5]|0,this.Dh=me[6]|0,this.Dl=me[7]|0,this.Eh=me[8]|0,this.El=me[9]|0,this.Fh=me[10]|0,this.Fl=me[11]|0,this.Gh=me[12]|0,this.Gl=me[13]|0,this.Hh=me[14]|0,this.Hl=me[15]|0}get(){const{Ah:t,Al:e,Bh:n,Bl:s,Ch:i,Cl:o,Dh:c,Dl:d,Eh:_,El:b,Fh:O,Fl:x,Gh:S,Gl:T,Hh:C,Hl:M}=this;return[t,e,n,s,i,o,c,d,_,b,O,x,S,T,C,M]}set(t,e,n,s,i,o,c,d,_,b,O,x,S,T,C,M){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=s|0,this.Ch=i|0,this.Cl=o|0,this.Dh=c|0,this.Dl=d|0,this.Eh=_|0,this.El=b|0,this.Fh=O|0,this.Fl=x|0,this.Gh=S|0,this.Gl=T|0,this.Hh=C|0,this.Hl=M|0}process(t,e){for(let z=0;z<16;z++,e+=4)Ze[z]=t.getUint32(e),Je[z]=t.getUint32(e+=4);for(let z=16;z<80;z++){const Q=Ze[z-15]|0,Z=Je[z-15]|0,st=bn(Q,Z,1)^bn(Q,Z,8)^io(Q,Z,7),pt=An(Q,Z,1)^An(Q,Z,8)^so(Q,Z,7),ct=Ze[z-2]|0,k=Je[z-2]|0,D=bn(ct,k,19)^_r(ct,k,61)^io(ct,k,6),V=An(ct,k,19)^mr(ct,k,61)^so(ct,k,6),K=Eu(pt,V,Je[z-7],Je[z-16]),m=Ru(K,st,D,Ze[z-7],Ze[z-16]);Ze[z]=m|0,Je[z]=K|0}let{Ah:n,Al:s,Bh:i,Bl:o,Ch:c,Cl:d,Dh:_,Dl:b,Eh:O,El:x,Fh:S,Fl:T,Gh:C,Gl:M,Hh:P,Hl:W}=this;for(let z=0;z<80;z++){const Q=bn(O,x,14)^bn(O,x,18)^_r(O,x,41),Z=An(O,x,14)^An(O,x,18)^mr(O,x,41),st=O&S^~O&C,pt=x&T^~x&M,ct=bu(W,Z,pt,Ou[z],Je[z]),k=Au(ct,P,Q,st,Iu[z],Ze[z]),D=ct|0,V=bn(n,s,28)^_r(n,s,34)^_r(n,s,39),K=An(n,s,28)^mr(n,s,34)^mr(n,s,39),m=n&i^n&c^i&c,a=s&o^s&d^o&d;P=C|0,W=M|0,C=S|0,M=T|0,S=O|0,T=x|0,{h:O,l:x}=ze(_|0,b|0,k|0,D|0),_=c|0,b=d|0,c=i|0,d=o|0,i=n|0,o=s|0;const h=yu(D,K,a);n=wu(h,k,V,m),s=h|0}({h:n,l:s}=ze(this.Ah|0,this.Al|0,n|0,s|0)),{h:i,l:o}=ze(this.Bh|0,this.Bl|0,i|0,o|0),{h:c,l:d}=ze(this.Ch|0,this.Cl|0,c|0,d|0),{h:_,l:b}=ze(this.Dh|0,this.Dl|0,_|0,b|0),{h:O,l:x}=ze(this.Eh|0,this.El|0,O|0,x|0),{h:S,l:T}=ze(this.Fh|0,this.Fl|0,S|0,T|0),{h:C,l:M}=ze(this.Gh|0,this.Gl|0,C|0,M|0),{h:P,l:W}=ze(this.Hh|0,this.Hl|0,P|0,W|0),this.set(n,s,i,o,c,d,_,b,O,x,S,T,C,M,P,W)}roundClean(){kn(Ze,Je)}destroy(){kn(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const la=aa(()=>new vu),Nu=aa(()=>new xu);const Rs=BigInt(0),ts=BigInt(1);function gn(r,t=""){if(typeof r!="boolean"){const e=t&&`"${t}"`;throw new Error(e+"expected boolean, got type="+typeof r)}return r}function Le(r,t,e=""){const n=rr(r),s=r==null?void 0:r.length,i=t!==void 0;if(!n||i&&s!==t){const o=e&&`"${e}" `,c=i?` of length ${t}`:"",d=n?`length=${s}`:`type=${typeof r}`;throw new Error(o+"expected Uint8Array"+c+", got "+d)}return r}function yr(r){const t=r.toString(16);return t.length&1?"0"+t:t}function fa(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?Rs:BigInt("0x"+r)}function jr(r){return fa(dn(r))}function tr(r){return _n(r),fa(dn(Uint8Array.from(r).reverse()))}function bs(r,t){return Cr(r.toString(16).padStart(t*2,"0"))}function ha(r,t){return bs(r,t).reverse()}function Gt(r,t,e){let n;if(typeof t=="string")try{n=Cr(t)}catch(i){throw new Error(r+" must be hex string or Uint8Array, cause: "+i)}else if(rr(t))n=Uint8Array.from(t);else throw new Error(r+" must be hex string or Uint8Array");const s=n.length;if(typeof e=="number"&&s!==e)throw new Error(r+" of length "+e+" expected, got "+s);return n}function oo(r){return Uint8Array.from(r)}const xi=r=>typeof r=="bigint"&&Rs<=r;function Tu(r,t,e){return xi(r)&&xi(t)&&xi(e)&&t<=r&&r<e}function es(r,t,e,n){if(!Tu(t,e,n))throw new Error("expected valid "+r+": "+e+" <= n < "+n+", got "+t)}function da(r){let t;for(t=0;r>Rs;r>>=ts,t+=1);return t}const ir=r=>(ts<<BigInt(r))-ts;function Bu(r,t,e){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof e!="function")throw new Error("hmacFn must be a function");const n=S=>new Uint8Array(S),s=S=>Uint8Array.of(S);let i=n(r),o=n(r),c=0;const d=()=>{i.fill(1),o.fill(0),c=0},_=(...S)=>e(o,i,...S),b=(S=n(0))=>{o=_(s(0),S),i=_(),S.length!==0&&(o=_(s(1),S),i=_())},O=()=>{if(c++>=1e3)throw new Error("drbg: tried 1000 values");let S=0;const T=[];for(;S<t;){i=_();const C=i.slice();T.push(C),S+=i.length}return De(...T)};return(S,T)=>{d(),b(S);let C;for(;!(C=T(O()));)b();return d(),C}}function sr(r,t,e={}){if(!r||typeof r!="object")throw new Error("expected valid options object");function n(s,i,o){const c=r[s];if(o&&c===void 0)return;const d=typeof c;if(d!==i||c===null)throw new Error(`param "${s}" is invalid: expected ${i}, got ${d}`)}Object.entries(t).forEach(([s,i])=>n(s,i,!1)),Object.entries(e).forEach(([s,i])=>n(s,i,!0))}function Lr(r){const t=new WeakMap;return(e,...n)=>{const s=t.get(e);if(s!==void 0)return s;const i=r(e,...n);return t.set(e,i),i}}const Se=BigInt(0),_e=BigInt(1),an=BigInt(2),pa=BigInt(3),ga=BigInt(4),_a=BigInt(5),Cu=BigInt(7),ma=BigInt(8),Lu=BigInt(9),ya=BigInt(16);function le(r,t){const e=r%t;return e>=Se?e:t+e}function Vt(r,t,e){let n=r;for(;t-- >Se;)n*=n,n%=e;return n}function ao(r,t){if(r===Se)throw new Error("invert: expected non-zero number");if(t<=Se)throw new Error("invert: expected positive modulus, got "+t);let e=le(r,t),n=t,s=Se,i=_e;for(;e!==Se;){const c=n/e,d=n%e,_=s-i*c;n=e,e=d,s=i,i=_}if(n!==_e)throw new Error("invert: does not exist");return le(s,t)}function As(r,t,e){if(!r.eql(r.sqr(t),e))throw new Error("Cannot find square root")}function wa(r,t){const e=(r.ORDER+_e)/ga,n=r.pow(t,e);return As(r,n,t),n}function Mu(r,t){const e=(r.ORDER-_a)/ma,n=r.mul(t,an),s=r.pow(n,e),i=r.mul(t,s),o=r.mul(r.mul(i,an),s),c=r.mul(i,r.sub(o,r.ONE));return As(r,c,t),c}function ku(r){const t=mn(r),e=Ea(r),n=e(t,t.neg(t.ONE)),s=e(t,n),i=e(t,t.neg(n)),o=(r+Cu)/ya;return(c,d)=>{let _=c.pow(d,o),b=c.mul(_,n);const O=c.mul(_,s),x=c.mul(_,i),S=c.eql(c.sqr(b),d),T=c.eql(c.sqr(O),d);_=c.cmov(_,b,S),b=c.cmov(x,O,T);const C=c.eql(c.sqr(b),d),M=c.cmov(_,b,C);return As(c,M,d),M}}function Ea(r){if(r<pa)throw new Error("sqrt is not defined for small field");let t=r-_e,e=0;for(;t%an===Se;)t/=an,e++;let n=an;const s=mn(r);for(;co(s,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(e===1)return wa;let i=s.pow(n,t);const o=(t+_e)/an;return function(d,_){if(d.is0(_))return _;if(co(d,_)!==1)throw new Error("Cannot find square root");let b=e,O=d.mul(d.ONE,i),x=d.pow(_,t),S=d.pow(_,o);for(;!d.eql(x,d.ONE);){if(d.is0(x))return d.ZERO;let T=1,C=d.sqr(x);for(;!d.eql(C,d.ONE);)if(T++,C=d.sqr(C),T===b)throw new Error("Cannot find square root");const M=_e<<BigInt(b-T-1),P=d.pow(O,M);b=T,O=d.sqr(P),x=d.mul(x,O),S=d.mul(S,P)}return S}}function Uu(r){return r%ga===pa?wa:r%ma===_a?Mu:r%ya===Lu?ku(r):Ea(r)}const Du=(r,t)=>(le(r,t)&_e)===_e,Pu=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Fu(r){const t={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},e=Pu.reduce((n,s)=>(n[s]="function",n),t);return sr(r,e),r}function qu(r,t,e){if(e<Se)throw new Error("invalid exponent, negatives unsupported");if(e===Se)return r.ONE;if(e===_e)return t;let n=r.ONE,s=t;for(;e>Se;)e&_e&&(n=r.mul(n,s)),s=r.sqr(s),e>>=_e;return n}function Ra(r,t,e=!1){const n=new Array(t.length).fill(e?r.ZERO:void 0),s=t.reduce((o,c,d)=>r.is0(c)?o:(n[d]=o,r.mul(o,c)),r.ONE),i=r.inv(s);return t.reduceRight((o,c,d)=>r.is0(c)?o:(n[d]=r.mul(o,n[d]),r.mul(o,c)),i),n}function co(r,t){const e=(r.ORDER-_e)/an,n=r.pow(t,e),s=r.eql(n,r.ONE),i=r.eql(n,r.ZERO),o=r.eql(n,r.neg(r.ONE));if(!s&&!i&&!o)throw new Error("invalid Legendre symbol result");return s?1:i?0:-1}function ba(r,t){t!==void 0&&Qi(t);const e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function mn(r,t,e=!1,n={}){if(r<=Se)throw new Error("invalid field: expected ORDER > 0, got "+r);let s,i,o=!1,c;if(typeof t=="object"&&t!=null){if(n.sqrt||e)throw new Error("cannot specify opts in two arguments");const x=t;x.BITS&&(s=x.BITS),x.sqrt&&(i=x.sqrt),typeof x.isLE=="boolean"&&(e=x.isLE),typeof x.modFromBytes=="boolean"&&(o=x.modFromBytes),c=x.allowedLengths}else typeof t=="number"&&(s=t),n.sqrt&&(i=n.sqrt);const{nBitLength:d,nByteLength:_}=ba(r,s);if(_>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let b;const O=Object.freeze({ORDER:r,isLE:e,BITS:d,BYTES:_,MASK:ir(d),ZERO:Se,ONE:_e,allowedLengths:c,create:x=>le(x,r),isValid:x=>{if(typeof x!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof x);return Se<=x&&x<r},is0:x=>x===Se,isValidNot0:x=>!O.is0(x)&&O.isValid(x),isOdd:x=>(x&_e)===_e,neg:x=>le(-x,r),eql:(x,S)=>x===S,sqr:x=>le(x*x,r),add:(x,S)=>le(x+S,r),sub:(x,S)=>le(x-S,r),mul:(x,S)=>le(x*S,r),pow:(x,S)=>qu(O,x,S),div:(x,S)=>le(x*ao(S,r),r),sqrN:x=>x*x,addN:(x,S)=>x+S,subN:(x,S)=>x-S,mulN:(x,S)=>x*S,inv:x=>ao(x,r),sqrt:i||(x=>(b||(b=Uu(r)),b(O,x))),toBytes:x=>e?ha(x,_):bs(x,_),fromBytes:(x,S=!0)=>{if(c){if(!c.includes(x.length)||x.length>_)throw new Error("Field.fromBytes: expected "+c+" bytes, got "+x.length);const C=new Uint8Array(_);C.set(x,e?0:C.length-x.length),x=C}if(x.length!==_)throw new Error("Field.fromBytes: expected "+_+" bytes, got "+x.length);let T=e?tr(x):jr(x);if(o&&(T=le(T,r)),!S&&!O.isValid(T))throw new Error("invalid field element: outside of range 0..ORDER");return T},invertBatch:x=>Ra(O,x),cmov:(x,S,T)=>T?S:x});return Object.freeze(O)}function Aa(r){if(typeof r!="bigint")throw new Error("field order must be bigint");const t=r.toString(2).length;return Math.ceil(t/8)}function Sa(r){const t=Aa(r);return t+Math.ceil(t/2)}function $u(r,t,e=!1){const n=r.length,s=Aa(t),i=Sa(t);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);const o=e?tr(r):jr(r),c=le(o,t-_e)+_e;return e?ha(c,s):bs(c,s)}const Un=BigInt(0),cn=BigInt(1);function Mr(r,t){const e=t.negate();return r?e:t}function un(r,t){const e=Ra(r.Fp,t.map(n=>n.Z));return t.map((n,s)=>r.fromAffine(n.toAffine(e[s])))}function va(r,t){if(!Number.isSafeInteger(r)||r<=0||r>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+r)}function Ni(r,t){va(r,t);const e=Math.ceil(t/r)+1,n=bt(2,r-1),s=bt(2,r),i=ir(r),o=BigInt(r);return{windows:e,windowSize:n,mask:i,maxNumber:s,shiftBy:o}}function uo(r,t,e){const{windowSize:n,mask:s,maxNumber:i,shiftBy:o}=e;let c=Number(r&s),d=r>>o;c>n&&(c-=i,d+=cn);const _=t*n,b=_+Math.abs(c)-1,O=c===0,x=c<0,S=t%2!==0;return{nextN:d,offset:b,isZero:O,isNeg:x,isNegF:S,offsetF:_}}function zu(r,t){if(!Array.isArray(r))throw new Error("array expected");r.forEach((e,n)=>{if(!(e instanceof t))throw new Error("invalid point at index "+n)})}function Vu(r,t){if(!Array.isArray(r))throw new Error("array of scalars expected");r.forEach((e,n)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+n)})}const Ti=new WeakMap,Ia=new WeakMap;function Bi(r){return Ia.get(r)||1}function lo(r){if(r!==Un)throw new Error("invalid wNAF")}class Oa{constructor(t,e){this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=e}_unsafeLadder(t,e,n=this.ZERO){let s=t;for(;e>Un;)e&cn&&(n=n.add(s)),s=s.double(),e>>=cn;return n}precomputeWindow(t,e){const{windows:n,windowSize:s}=Ni(e,this.bits),i=[];let o=t,c=o;for(let d=0;d<n;d++){c=o,i.push(c);for(let _=1;_<s;_++)c=c.add(o),i.push(c);o=c.double()}return i}wNAF(t,e,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let s=this.ZERO,i=this.BASE;const o=Ni(t,this.bits);for(let c=0;c<o.windows;c++){const{nextN:d,offset:_,isZero:b,isNeg:O,isNegF:x,offsetF:S}=uo(n,c,o);n=d,b?i=i.add(Mr(x,e[S])):s=s.add(Mr(O,e[_]))}return lo(n),{p:s,f:i}}wNAFUnsafe(t,e,n,s=this.ZERO){const i=Ni(t,this.bits);for(let o=0;o<i.windows&&n!==Un;o++){const{nextN:c,offset:d,isZero:_,isNeg:b}=uo(n,o,i);if(n=c,!_){const O=e[d];s=s.add(b?O.negate():O)}}return lo(n),s}getPrecomputes(t,e,n){let s=Ti.get(e);return s||(s=this.precomputeWindow(e,t),t!==1&&(typeof n=="function"&&(s=n(s)),Ti.set(e,s))),s}cached(t,e,n){const s=Bi(t);return this.wNAF(s,this.getPrecomputes(s,t,n),e)}unsafe(t,e,n,s){const i=Bi(t);return i===1?this._unsafeLadder(t,e,s):this.wNAFUnsafe(i,this.getPrecomputes(i,t,n),e,s)}createCache(t,e){va(e,this.bits),Ia.set(t,e),Ti.delete(t)}hasCache(t){return Bi(t)!==1}}function Gu(r,t,e,n){let s=t,i=r.ZERO,o=r.ZERO;for(;e>Un||n>Un;)e&cn&&(i=i.add(s)),n&cn&&(o=o.add(s)),s=s.double(),e>>=cn,n>>=cn;return{p1:i,p2:o}}function xa(r,t,e,n){zu(e,r),Vu(n,t);const s=e.length,i=n.length;if(s!==i)throw new Error("arrays of points and scalars must have equal length");const o=r.ZERO,c=da(BigInt(s));let d=1;c>12?d=c-3:c>4?d=c-2:c>0&&(d=2);const _=ir(d),b=new Array(Number(_)+1).fill(o),O=Math.floor((t.BITS-1)/d)*d;let x=o;for(let S=O;S>=0;S-=d){b.fill(o);for(let C=0;C<i;C++){const M=n[C],P=Number(M>>BigInt(S)&_);b[P]=b[P].add(e[C])}let T=o;for(let C=b.length-1,M=o;C>0;C--)M=M.add(b[C]),T=T.add(M);if(x=x.add(T),S!==0)for(let C=0;C<d;C++)x=x.double()}return x}function fo(r,t,e){if(t){if(t.ORDER!==r)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return Fu(t),t}else return mn(r,{isLE:e})}function Na(r,t,e={},n){if(n===void 0&&(n=r==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${r} CURVE object`);for(const d of["p","n","h"]){const _=t[d];if(!(typeof _=="bigint"&&_>Un))throw new Error(`CURVE.${d} must be positive bigint`)}const s=fo(t.p,e.Fp,n),i=fo(t.n,e.Fn,n),c=["Gx","Gy","a",r==="weierstrass"?"b":"d"];for(const d of c)if(!s.isValid(t[d]))throw new Error(`CURVE.${d} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:s,Fn:i}}const Qe=BigInt(0),fe=BigInt(1),Ci=BigInt(2),Ku=BigInt(8);function Hu(r,t,e,n){const s=r.sqr(e),i=r.sqr(n),o=r.add(r.mul(t.a,s),i),c=r.add(r.ONE,r.mul(t.d,r.mul(s,i)));return r.eql(o,c)}function Wu(r,t={}){const e=Na("edwards",r,t,t.FpFnLE),{Fp:n,Fn:s}=e;let i=e.CURVE;const{h:o}=i;sr(t,{},{uvRatio:"function"});const c=Ci<<BigInt(s.BYTES*8)-fe,d=M=>n.create(M),_=t.uvRatio||((M,P)=>{try{return{isValid:!0,value:n.sqrt(n.div(M,P))}}catch(W){return{isValid:!1,value:Qe}}});if(!Hu(n,i,i.Gx,i.Gy))throw new Error("bad curve params: generator point");function b(M,P,W=!1){const z=W?fe:Qe;return es("coordinate "+M,P,z,c),P}function O(M){if(!(M instanceof T))throw new Error("ExtendedPoint expected")}const x=Lr((M,P)=>{const{X:W,Y:z,Z:Q}=M,Z=M.is0();P==null&&(P=Z?Ku:n.inv(Q));const st=d(W*P),pt=d(z*P),ct=n.mul(Q,P);if(Z)return{x:Qe,y:fe};if(ct!==fe)throw new Error("invZ was invalid");return{x:st,y:pt}}),S=Lr(M=>{const{a:P,d:W}=i;if(M.is0())throw new Error("bad point: ZERO");const{X:z,Y:Q,Z,T:st}=M,pt=d(z*z),ct=d(Q*Q),k=d(Z*Z),D=d(k*k),V=d(pt*P),K=d(k*d(V+ct)),m=d(D+d(W*d(pt*ct)));if(K!==m)throw new Error("bad point: equation left != right (1)");const a=d(z*Q),h=d(Z*st);if(a!==h)throw new Error("bad point: equation left != right (2)");return!0});class T{constructor(P,W,z,Q){this.X=b("x",P),this.Y=b("y",W),this.Z=b("z",z,!0),this.T=b("t",Q),Object.freeze(this)}static CURVE(){return i}static fromAffine(P){if(P instanceof T)throw new Error("extended point not allowed");const{x:W,y:z}=P||{};return b("x",W),b("y",z),new T(W,z,fe,d(W*z))}static fromBytes(P,W=!1){const z=n.BYTES,{a:Q,d:Z}=i;P=oo(Le(P,z,"point")),gn(W,"zip215");const st=oo(P),pt=P[z-1];st[z-1]=pt&-129;const ct=tr(st),k=W?c:n.ORDER;es("point.y",ct,Qe,k);const D=d(ct*ct),V=d(D-fe),K=d(Z*D-Q);let{isValid:m,value:a}=_(V,K);if(!m)throw new Error("bad point: invalid y coordinate");const h=(a&fe)===fe,g=(pt&128)!==0;if(!W&&a===Qe&&g)throw new Error("bad point: x=0 and x_0=1");return g!==h&&(a=d(-a)),T.fromAffine({x:a,y:ct})}static fromHex(P,W=!1){return T.fromBytes(Gt("point",P),W)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(P=8,W=!0){return C.createCache(this,P),W||this.multiply(Ci),this}assertValidity(){S(this)}equals(P){O(P);const{X:W,Y:z,Z:Q}=this,{X:Z,Y:st,Z:pt}=P,ct=d(W*pt),k=d(Z*Q),D=d(z*pt),V=d(st*Q);return ct===k&&D===V}is0(){return this.equals(T.ZERO)}negate(){return new T(d(-this.X),this.Y,this.Z,d(-this.T))}double(){const{a:P}=i,{X:W,Y:z,Z:Q}=this,Z=d(W*W),st=d(z*z),pt=d(Ci*d(Q*Q)),ct=d(P*Z),k=W+z,D=d(d(k*k)-Z-st),V=ct+st,K=V-pt,m=ct-st,a=d(D*K),h=d(V*m),g=d(D*m),R=d(K*V);return new T(a,h,R,g)}add(P){O(P);const{a:W,d:z}=i,{X:Q,Y:Z,Z:st,T:pt}=this,{X:ct,Y:k,Z:D,T:V}=P,K=d(Q*ct),m=d(Z*k),a=d(pt*z*V),h=d(st*D),g=d((Q+Z)*(ct+k)-K-m),R=h-a,v=h+a,N=d(m-W*K),L=d(g*R),E=d(v*N),u=d(g*N),l=d(R*v);return new T(L,E,l,u)}subtract(P){return this.add(P.negate())}multiply(P){if(!s.isValidNot0(P))throw new Error("invalid scalar: expected 1 <= sc < curve.n");const{p:W,f:z}=C.cached(this,P,Q=>un(T,Q));return un(T,[W,z])[0]}multiplyUnsafe(P,W=T.ZERO){if(!s.isValid(P))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return P===Qe?T.ZERO:this.is0()||P===fe?this:C.unsafe(this,P,z=>un(T,z),W)}isSmallOrder(){return this.multiplyUnsafe(o).is0()}isTorsionFree(){return C.unsafe(this,i.n).is0()}toAffine(P){return x(this,P)}clearCofactor(){return o===fe?this:this.multiplyUnsafe(o)}toBytes(){const{x:P,y:W}=this.toAffine(),z=n.toBytes(W);return z[z.length-1]|=P&fe?128:0,z}toHex(){return dn(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get ex(){return this.X}get ey(){return this.Y}get ez(){return this.Z}get et(){return this.T}static normalizeZ(P){return un(T,P)}static msm(P,W){return xa(T,s,P,W)}_setWindowSize(P){this.precompute(P)}toRawBytes(){return this.toBytes()}}T.BASE=new T(i.Gx,i.Gy,fe,d(i.Gx*i.Gy)),T.ZERO=new T(Qe,fe,fe,Qe),T.Fp=n,T.Fn=s;const C=new Oa(T,s.BITS);return T.BASE.precompute(8),T}function ju(r,t,e={}){if(typeof t!="function")throw new Error('"hash" function param is required');sr(e,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});const{prehash:n}=e,{BASE:s,Fp:i,Fn:o}=r,c=e.randomBytes||Es,d=e.adjustScalarBytes||(k=>k),_=e.domain||((k,D,V)=>{if(gn(V,"phflag"),D.length||V)throw new Error("Contexts/pre-hash are not supported");return k});function b(k){return o.create(tr(k))}function O(k){const D=z.secretKey;k=Gt("private key",k,D);const V=Gt("hashed private key",t(k),2*D),K=d(V.slice(0,D)),m=V.slice(D,2*D),a=b(K);return{head:K,prefix:m,scalar:a}}function x(k){const{head:D,prefix:V,scalar:K}=O(k),m=s.multiply(K),a=m.toBytes();return{head:D,prefix:V,scalar:K,point:m,pointBytes:a}}function S(k){return x(k).pointBytes}function T(k=Uint8Array.of(),...D){const V=De(...D);return b(t(_(V,Gt("context",k),!!n)))}function C(k,D,V={}){k=Gt("message",k),n&&(k=n(k));const{prefix:K,scalar:m,pointBytes:a}=x(D),h=T(V.context,K,k),g=s.multiply(h).toBytes(),R=T(V.context,g,a,k),v=o.create(h+R*m);if(!o.isValid(v))throw new Error("sign failed: invalid s");const N=De(g,o.toBytes(v));return Le(N,z.signature,"result")}const M={zip215:!0};function P(k,D,V,K=M){const{context:m,zip215:a}=K,h=z.signature;k=Gt("signature",k,h),D=Gt("message",D),V=Gt("publicKey",V,z.publicKey),a!==void 0&&gn(a,"zip215"),n&&(D=n(D));const g=h/2,R=k.subarray(0,g),v=tr(k.subarray(g,h));let N,L,E;try{N=r.fromBytes(V,a),L=r.fromBytes(R,a),E=s.multiplyUnsafe(v)}catch(w){return!1}if(!a&&N.isSmallOrder())return!1;const u=T(m,L.toBytes(),N.toBytes(),D);return L.add(N.multiplyUnsafe(u)).subtract(E).clearCofactor().is0()}const W=i.BYTES,z={secretKey:W,publicKey:W,signature:2*W,seed:W};function Q(k=c(z.seed)){return Le(k,z.seed,"seed")}function Z(k){const D=ct.randomSecretKey(k);return{secretKey:D,publicKey:S(D)}}function st(k){return rr(k)&&k.length===o.BYTES}function pt(k,D){try{return!!r.fromBytes(k,D)}catch(V){return!1}}const ct={getExtendedPublicKey:x,randomSecretKey:Q,isValidSecretKey:st,isValidPublicKey:pt,toMontgomery(k){const{y:D}=r.fromBytes(k),V=z.publicKey,K=V===32;if(!K&&V!==57)throw new Error("only defined for 25519 and 448");const m=K?i.div(fe+D,fe-D):i.div(D-fe,D+fe);return i.toBytes(m)},toMontgomerySecret(k){const D=z.secretKey;Le(k,D);const V=t(k.subarray(0,D));return d(V).subarray(0,D)},randomPrivateKey:Q,precompute(k=8,D=r.BASE){return D.precompute(k,!1)}};return Object.freeze({keygen:Z,getPublicKey:S,sign:C,verify:P,utils:ct,Point:r,lengths:z})}function Xu(r){const t={a:r.a,d:r.d,p:r.Fp.ORDER,n:r.n,h:r.h,Gx:r.Gx,Gy:r.Gy},e=r.Fp,n=mn(t.n,r.nBitLength,!0),s={Fp:e,Fn:n,uvRatio:r.uvRatio},i={randomBytes:r.randomBytes,adjustScalarBytes:r.adjustScalarBytes,domain:r.domain,prehash:r.prehash,mapToCurve:r.mapToCurve};return{CURVE:t,curveOpts:s,hash:r.hash,eddsaOpts:i}}function Yu(r,t){const e=t.Point;return Object.assign({},t,{ExtendedPoint:e,CURVE:r,nBitLength:e.Fn.BITS,nByteLength:e.Fn.BYTES})}function Zu(r){const{CURVE:t,curveOpts:e,hash:n,eddsaOpts:s}=Xu(r),i=Wu(t,e),o=ju(i,n,s);return Yu(r,o)}const Ju=BigInt(1),ho=BigInt(2);BigInt(3);const Qu=BigInt(5),tl=BigInt(8),Ss=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),Ta={p:Ss,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:tl,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function el(r){const t=BigInt(10),e=BigInt(20),n=BigInt(40),s=BigInt(80),i=Ss,c=r*r%i*r%i,d=Vt(c,ho,i)*c%i,_=Vt(d,Ju,i)*r%i,b=Vt(_,Qu,i)*_%i,O=Vt(b,t,i)*b%i,x=Vt(O,e,i)*O%i,S=Vt(x,n,i)*x%i,T=Vt(S,s,i)*S%i,C=Vt(T,s,i)*S%i,M=Vt(C,t,i)*b%i;return{pow_p_5_8:Vt(M,ho,i)*r%i,b2:c}}function nl(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}const po=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function rl(r,t){const e=Ss,n=le(t*t*t,e),s=le(n*n*t,e),i=el(r*s).pow_p_5_8;let o=le(r*n*i,e);const c=le(t*o*o,e),d=o,_=le(o*po,e),b=c===r,O=c===le(-r,e),x=c===le(-r*po,e);return b&&(o=d),(O||x)&&(o=_),Du(o,e)&&(o=le(-o,e)),{isValid:b||O,value:o}}const il=mn(Ta.p,{isLE:!0}),sl=yt(lt({},Ta),{Fp:il,hash:Nu,adjustScalarBytes:nl,uvRatio:rl}),or=Zu(sl);var vr={exports:{}};const ol={},al=Object.freeze(Object.defineProperty({__proto__:null,default:ol},Symbol.toStringTag,{value:"Module"})),cl=hs(al);var ul=vr.exports,go;function Ba(){return go||(go=1,(function(r){(function(t,e){function n(m,a){if(!m)throw new Error(a||"Assertion failed")}function s(m,a){m.super_=a;var h=function(){};h.prototype=a.prototype,m.prototype=new h,m.prototype.constructor=m}function i(m,a,h){if(i.isBN(m))return m;this.negative=0,this.words=null,this.length=0,this.red=null,m!==null&&((a==="le"||a==="be")&&(h=a,a=10),this._init(m||0,a||10,h||"be"))}typeof t=="object"?t.exports=i:e.BN=i,i.BN=i,i.wordSize=26;var o;try{typeof window!="undefined"&&typeof window.Buffer!="undefined"?o=window.Buffer:o=cl.Buffer}catch(m){}i.isBN=function(a){return a instanceof i?!0:a!==null&&typeof a=="object"&&a.constructor.wordSize===i.wordSize&&Array.isArray(a.words)},i.max=function(a,h){return a.cmp(h)>0?a:h},i.min=function(a,h){return a.cmp(h)<0?a:h},i.prototype._init=function(a,h,g){if(typeof a=="number")return this._initNumber(a,h,g);if(typeof a=="object")return this._initArray(a,h,g);h==="hex"&&(h=16),n(h===(h|0)&&h>=2&&h<=36),a=a.toString().replace(/\s+/g,"");var R=0;a[0]==="-"&&(R++,this.negative=1),R<a.length&&(h===16?this._parseHex(a,R,g):(this._parseBase(a,h,R),g==="le"&&this._initArray(this.toArray(),h,g)))},i.prototype._initNumber=function(a,h,g){a<0&&(this.negative=1,a=-a),a<67108864?(this.words=[a&67108863],this.length=1):a<4503599627370496?(this.words=[a&67108863,a/67108864&67108863],this.length=2):(n(a<9007199254740992),this.words=[a&67108863,a/67108864&67108863,1],this.length=3),g==="le"&&this._initArray(this.toArray(),h,g)},i.prototype._initArray=function(a,h,g){if(n(typeof a.length=="number"),a.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(a.length/3),this.words=new Array(this.length);for(var R=0;R<this.length;R++)this.words[R]=0;var v,N,L=0;if(g==="be")for(R=a.length-1,v=0;R>=0;R-=3)N=a[R]|a[R-1]<<8|a[R-2]<<16,this.words[v]|=N<<L&67108863,this.words[v+1]=N>>>26-L&67108863,L+=24,L>=26&&(L-=26,v++);else if(g==="le")for(R=0,v=0;R<a.length;R+=3)N=a[R]|a[R+1]<<8|a[R+2]<<16,this.words[v]|=N<<L&67108863,this.words[v+1]=N>>>26-L&67108863,L+=24,L>=26&&(L-=26,v++);return this._strip()};function c(m,a){var h=m.charCodeAt(a);if(h>=48&&h<=57)return h-48;if(h>=65&&h<=70)return h-55;if(h>=97&&h<=102)return h-87;n(!1,"Invalid character in "+m)}function d(m,a,h){var g=c(m,h);return h-1>=a&&(g|=c(m,h-1)<<4),g}i.prototype._parseHex=function(a,h,g){this.length=Math.ceil((a.length-h)/6),this.words=new Array(this.length);for(var R=0;R<this.length;R++)this.words[R]=0;var v=0,N=0,L;if(g==="be")for(R=a.length-1;R>=h;R-=2)L=d(a,h,R)<<v,this.words[N]|=L&67108863,v>=18?(v-=18,N+=1,this.words[N]|=L>>>26):v+=8;else{var E=a.length-h;for(R=E%2===0?h+1:h;R<a.length;R+=2)L=d(a,h,R)<<v,this.words[N]|=L&67108863,v>=18?(v-=18,N+=1,this.words[N]|=L>>>26):v+=8}this._strip()};function _(m,a,h,g){for(var R=0,v=0,N=Math.min(m.length,h),L=a;L<N;L++){var E=m.charCodeAt(L)-48;R*=g,E>=49?v=E-49+10:E>=17?v=E-17+10:v=E,n(E>=0&&v<g,"Invalid character"),R+=v}return R}i.prototype._parseBase=function(a,h,g){this.words=[0],this.length=1;for(var R=0,v=1;v<=67108863;v*=h)R++;R--,v=v/h|0;for(var N=a.length-g,L=N%R,E=Math.min(N,N-L)+g,u=0,l=g;l<E;l+=R)u=_(a,l,l+R,h),this.imuln(v),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(L!==0){var w=1;for(u=_(a,l,a.length,h),l=0;l<L;l++)w*=h;this.imuln(w),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}this._strip()},i.prototype.copy=function(a){a.words=new Array(this.length);for(var h=0;h<this.length;h++)a.words[h]=this.words[h];a.length=this.length,a.negative=this.negative,a.red=this.red};function b(m,a){m.words=a.words,m.length=a.length,m.negative=a.negative,m.red=a.red}if(i.prototype._move=function(a){b(a,this)},i.prototype.clone=function(){var a=new i(null);return this.copy(a),a},i.prototype._expand=function(a){for(;this.length<a;)this.words[this.length++]=0;return this},i.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},i.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol!="undefined"&&typeof Symbol.for=="function")try{i.prototype[Symbol.for("nodejs.util.inspect.custom")]=O}catch(m){i.prototype.inspect=O}else i.prototype.inspect=O;function O(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var x=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],S=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],T=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];i.prototype.toString=function(a,h){a=a||10,h=h|0||1;var g;if(a===16||a==="hex"){g="";for(var R=0,v=0,N=0;N<this.length;N++){var L=this.words[N],E=((L<<R|v)&16777215).toString(16);v=L>>>24-R&16777215,R+=2,R>=26&&(R-=26,N--),v!==0||N!==this.length-1?g=x[6-E.length]+E+g:g=E+g}for(v!==0&&(g=v.toString(16)+g);g.length%h!==0;)g="0"+g;return this.negative!==0&&(g="-"+g),g}if(a===(a|0)&&a>=2&&a<=36){var u=S[a],l=T[a];g="";var w=this.clone();for(w.negative=0;!w.isZero();){var I=w.modrn(l).toString(a);w=w.idivn(l),w.isZero()?g=I+g:g=x[u-I.length]+I+g}for(this.isZero()&&(g="0"+g);g.length%h!==0;)g="0"+g;return this.negative!==0&&(g="-"+g),g}n(!1,"Base should be between 2 and 36")},i.prototype.toNumber=function(){var a=this.words[0];return this.length===2?a+=this.words[1]*67108864:this.length===3&&this.words[2]===1?a+=4503599627370496+this.words[1]*67108864:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-a:a},i.prototype.toJSON=function(){return this.toString(16,2)},o&&(i.prototype.toBuffer=function(a,h){return this.toArrayLike(o,a,h)}),i.prototype.toArray=function(a,h){return this.toArrayLike(Array,a,h)};var C=function(a,h){return a.allocUnsafe?a.allocUnsafe(h):new a(h)};i.prototype.toArrayLike=function(a,h,g){this._strip();var R=this.byteLength(),v=g||Math.max(1,R);n(R<=v,"byte array longer than desired length"),n(v>0,"Requested array length <= 0");var N=C(a,v),L=h==="le"?"LE":"BE";return this["_toArrayLike"+L](N,R),N},i.prototype._toArrayLikeLE=function(a,h){for(var g=0,R=0,v=0,N=0;v<this.length;v++){var L=this.words[v]<<N|R;a[g++]=L&255,g<a.length&&(a[g++]=L>>8&255),g<a.length&&(a[g++]=L>>16&255),N===6?(g<a.length&&(a[g++]=L>>24&255),R=0,N=0):(R=L>>>24,N+=2)}if(g<a.length)for(a[g++]=R;g<a.length;)a[g++]=0},i.prototype._toArrayLikeBE=function(a,h){for(var g=a.length-1,R=0,v=0,N=0;v<this.length;v++){var L=this.words[v]<<N|R;a[g--]=L&255,g>=0&&(a[g--]=L>>8&255),g>=0&&(a[g--]=L>>16&255),N===6?(g>=0&&(a[g--]=L>>24&255),R=0,N=0):(R=L>>>24,N+=2)}if(g>=0)for(a[g--]=R;g>=0;)a[g--]=0},Math.clz32?i.prototype._countBits=function(a){return 32-Math.clz32(a)}:i.prototype._countBits=function(a){var h=a,g=0;return h>=4096&&(g+=13,h>>>=13),h>=64&&(g+=7,h>>>=7),h>=8&&(g+=4,h>>>=4),h>=2&&(g+=2,h>>>=2),g+h},i.prototype._zeroBits=function(a){if(a===0)return 26;var h=a,g=0;return(h&8191)===0&&(g+=13,h>>>=13),(h&127)===0&&(g+=7,h>>>=7),(h&15)===0&&(g+=4,h>>>=4),(h&3)===0&&(g+=2,h>>>=2),(h&1)===0&&g++,g},i.prototype.bitLength=function(){var a=this.words[this.length-1],h=this._countBits(a);return(this.length-1)*26+h};function M(m){for(var a=new Array(m.bitLength()),h=0;h<a.length;h++){var g=h/26|0,R=h%26;a[h]=m.words[g]>>>R&1}return a}i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var a=0,h=0;h<this.length;h++){var g=this._zeroBits(this.words[h]);if(a+=g,g!==26)break}return a},i.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},i.prototype.toTwos=function(a){return this.negative!==0?this.abs().inotn(a).iaddn(1):this.clone()},i.prototype.fromTwos=function(a){return this.testn(a-1)?this.notn(a).iaddn(1).ineg():this.clone()},i.prototype.isNeg=function(){return this.negative!==0},i.prototype.neg=function(){return this.clone().ineg()},i.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},i.prototype.iuor=function(a){for(;this.length<a.length;)this.words[this.length++]=0;for(var h=0;h<a.length;h++)this.words[h]=this.words[h]|a.words[h];return this._strip()},i.prototype.ior=function(a){return n((this.negative|a.negative)===0),this.iuor(a)},i.prototype.or=function(a){return this.length>a.length?this.clone().ior(a):a.clone().ior(this)},i.prototype.uor=function(a){return this.length>a.length?this.clone().iuor(a):a.clone().iuor(this)},i.prototype.iuand=function(a){var h;this.length>a.length?h=a:h=this;for(var g=0;g<h.length;g++)this.words[g]=this.words[g]&a.words[g];return this.length=h.length,this._strip()},i.prototype.iand=function(a){return n((this.negative|a.negative)===0),this.iuand(a)},i.prototype.and=function(a){return this.length>a.length?this.clone().iand(a):a.clone().iand(this)},i.prototype.uand=function(a){return this.length>a.length?this.clone().iuand(a):a.clone().iuand(this)},i.prototype.iuxor=function(a){var h,g;this.length>a.length?(h=this,g=a):(h=a,g=this);for(var R=0;R<g.length;R++)this.words[R]=h.words[R]^g.words[R];if(this!==h)for(;R<h.length;R++)this.words[R]=h.words[R];return this.length=h.length,this._strip()},i.prototype.ixor=function(a){return n((this.negative|a.negative)===0),this.iuxor(a)},i.prototype.xor=function(a){return this.length>a.length?this.clone().ixor(a):a.clone().ixor(this)},i.prototype.uxor=function(a){return this.length>a.length?this.clone().iuxor(a):a.clone().iuxor(this)},i.prototype.inotn=function(a){n(typeof a=="number"&&a>=0);var h=Math.ceil(a/26)|0,g=a%26;this._expand(h),g>0&&h--;for(var R=0;R<h;R++)this.words[R]=~this.words[R]&67108863;return g>0&&(this.words[R]=~this.words[R]&67108863>>26-g),this._strip()},i.prototype.notn=function(a){return this.clone().inotn(a)},i.prototype.setn=function(a,h){n(typeof a=="number"&&a>=0);var g=a/26|0,R=a%26;return this._expand(g+1),h?this.words[g]=this.words[g]|1<<R:this.words[g]=this.words[g]&~(1<<R),this._strip()},i.prototype.iadd=function(a){var h;if(this.negative!==0&&a.negative===0)return this.negative=0,h=this.isub(a),this.negative^=1,this._normSign();if(this.negative===0&&a.negative!==0)return a.negative=0,h=this.isub(a),a.negative=1,h._normSign();var g,R;this.length>a.length?(g=this,R=a):(g=a,R=this);for(var v=0,N=0;N<R.length;N++)h=(g.words[N]|0)+(R.words[N]|0)+v,this.words[N]=h&67108863,v=h>>>26;for(;v!==0&&N<g.length;N++)h=(g.words[N]|0)+v,this.words[N]=h&67108863,v=h>>>26;if(this.length=g.length,v!==0)this.words[this.length]=v,this.length++;else if(g!==this)for(;N<g.length;N++)this.words[N]=g.words[N];return this},i.prototype.add=function(a){var h;return a.negative!==0&&this.negative===0?(a.negative=0,h=this.sub(a),a.negative^=1,h):a.negative===0&&this.negative!==0?(this.negative=0,h=a.sub(this),this.negative=1,h):this.length>a.length?this.clone().iadd(a):a.clone().iadd(this)},i.prototype.isub=function(a){if(a.negative!==0){a.negative=0;var h=this.iadd(a);return a.negative=1,h._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(a),this.negative=1,this._normSign();var g=this.cmp(a);if(g===0)return this.negative=0,this.length=1,this.words[0]=0,this;var R,v;g>0?(R=this,v=a):(R=a,v=this);for(var N=0,L=0;L<v.length;L++)h=(R.words[L]|0)-(v.words[L]|0)+N,N=h>>26,this.words[L]=h&67108863;for(;N!==0&&L<R.length;L++)h=(R.words[L]|0)+N,N=h>>26,this.words[L]=h&67108863;if(N===0&&L<R.length&&R!==this)for(;L<R.length;L++)this.words[L]=R.words[L];return this.length=Math.max(this.length,L),R!==this&&(this.negative=1),this._strip()},i.prototype.sub=function(a){return this.clone().isub(a)};function P(m,a,h){h.negative=a.negative^m.negative;var g=m.length+a.length|0;h.length=g,g=g-1|0;var R=m.words[0]|0,v=a.words[0]|0,N=R*v,L=N&67108863,E=N/67108864|0;h.words[0]=L;for(var u=1;u<g;u++){for(var l=E>>>26,w=E&67108863,I=Math.min(u,a.length-1),F=Math.max(0,u-m.length+1);F<=I;F++){var X=u-F|0;R=m.words[X]|0,v=a.words[F]|0,N=R*v+w,l+=N/67108864|0,w=N&67108863}h.words[u]=w|0,E=l|0}return E!==0?h.words[u]=E|0:h.length--,h._strip()}var W=function(a,h,g){var R=a.words,v=h.words,N=g.words,L=0,E,u,l,w=R[0]|0,I=w&8191,F=w>>>13,X=R[1]|0,et=X&8191,it=X>>>13,St=R[2]|0,vt=St&8191,Ot=St>>>13,Be=R[3]|0,xt=Be&8191,Ft=Be>>>13,lr=R[4]|0,Ct=lr&8191,qt=lr>>>13,fr=R[5]|0,Ut=fr&8191,Tt=fr>>>13,Ie=R[6]|0,Lt=Ie&8191,$t=Ie>>>13,Ce=R[7]|0,zt=Ce&8191,y=Ce>>>13,f=R[8]|0,p=f&8191,A=f>>>13,U=R[9]|0,q=U&8191,j=U>>>13,mt=v[0]|0,_t=mt&8191,gt=mt>>>13,Bt=v[1]|0,dt=Bt&8191,Ht=Bt>>>13,ks=v[2]|0,Wt=ks&8191,jt=ks>>>13,Us=v[3]|0,Xt=Us&8191,Yt=Us>>>13,Ds=v[4]|0,Zt=Ds&8191,Jt=Ds>>>13,Ps=v[5]|0,Qt=Ps&8191,te=Ps>>>13,Fs=v[6]|0,ee=Fs&8191,ne=Fs>>>13,qs=v[7]|0,re=qs&8191,ie=qs>>>13,$s=v[8]|0,se=$s&8191,oe=$s>>>13,zs=v[9]|0,ae=zs&8191,ce=zs>>>13;g.negative=a.negative^h.negative,g.length=19,E=Math.imul(I,_t),u=Math.imul(I,gt),u=u+Math.imul(F,_t)|0,l=Math.imul(F,gt);var ni=(L+E|0)+((u&8191)<<13)|0;L=(l+(u>>>13)|0)+(ni>>>26)|0,ni&=67108863,E=Math.imul(et,_t),u=Math.imul(et,gt),u=u+Math.imul(it,_t)|0,l=Math.imul(it,gt),E=E+Math.imul(I,dt)|0,u=u+Math.imul(I,Ht)|0,u=u+Math.imul(F,dt)|0,l=l+Math.imul(F,Ht)|0;var ri=(L+E|0)+((u&8191)<<13)|0;L=(l+(u>>>13)|0)+(ri>>>26)|0,ri&=67108863,E=Math.imul(vt,_t),u=Math.imul(vt,gt),u=u+Math.imul(Ot,_t)|0,l=Math.imul(Ot,gt),E=E+Math.imul(et,dt)|0,u=u+Math.imul(et,Ht)|0,u=u+Math.imul(it,dt)|0,l=l+Math.imul(it,Ht)|0,E=E+Math.imul(I,Wt)|0,u=u+Math.imul(I,jt)|0,u=u+Math.imul(F,Wt)|0,l=l+Math.imul(F,jt)|0;var ii=(L+E|0)+((u&8191)<<13)|0;L=(l+(u>>>13)|0)+(ii>>>26)|0,ii&=67108863,E=Math.imul(xt,_t),u=Math.imul(xt,gt),u=u+Math.imul(Ft,_t)|0,l=Math.imul(Ft,gt),E=E+Math.imul(vt,dt)|0,u=u+Math.imul(vt,Ht)|0,u=u+Math.imul(Ot,dt)|0,l=l+Math.imul(Ot,Ht)|0,E=E+Math.imul(et,Wt)|0,u=u+Math.imul(et,jt)|0,u=u+Math.imul(it,Wt)|0,l=l+Math.imul(it,jt)|0,E=E+Math.imul(I,Xt)|0,u=u+Math.imul(I,Yt)|0,u=u+Math.imul(F,Xt)|0,l=l+Math.imul(F,Yt)|0;var si=(L+E|0)+((u&8191)<<13)|0;L=(l+(u>>>13)|0)+(si>>>26)|0,si&=67108863,E=Math.imul(Ct,_t),u=Math.imul(Ct,gt),u=u+Math.imul(qt,_t)|0,l=Math.imul(qt,gt),E=E+Math.imul(xt,dt)|0,u=u+Math.imul(xt,Ht)|0,u=u+Math.imul(Ft,dt)|0,l=l+Math.imul(Ft,Ht)|0,E=E+Math.imul(vt,Wt)|0,u=u+Math.imul(vt,jt)|0,u=u+Math.imul(Ot,Wt)|0,l=l+Math.imul(Ot,jt)|0,E=E+Math.imul(et,Xt)|0,u=u+Math.imul(et,Yt)|0,u=u+Math.imul(it,Xt)|0,l=l+Math.imul(it,Yt)|0,E=E+Math.imul(I,Zt)|0,u=u+Math.imul(I,Jt)|0,u=u+Math.imul(F,Zt)|0,l=l+Math.imul(F,Jt)|0;var oi=(L+E|0)+((u&8191)<<13)|0;L=(l+(u>>>13)|0)+(oi>>>26)|0,oi&=67108863,E=Math.imul(Ut,_t),u=Math.imul(Ut,gt),u=u+Math.imul(Tt,_t)|0,l=Math.imul(Tt,gt),E=E+Math.imul(Ct,dt)|0,u=u+Math.imul(Ct,Ht)|0,u=u+Math.imul(qt,dt)|0,l=l+Math.imul(qt,Ht)|0,E=E+Math.imul(xt,Wt)|0,u=u+Math.imul(xt,jt)|0,u=u+Math.imul(Ft,Wt)|0,l=l+Math.imul(Ft,jt)|0,E=E+Math.imul(vt,Xt)|0,u=u+Math.imul(vt,Yt)|0,u=u+Math.imul(Ot,Xt)|0,l=l+Math.imul(Ot,Yt)|0,E=E+Math.imul(et,Zt)|0,u=u+Math.imul(et,Jt)|0,u=u+Math.imul(it,Zt)|0,l=l+Math.imul(it,Jt)|0,E=E+Math.imul(I,Qt)|0,u=u+Math.imul(I,te)|0,u=u+Math.imul(F,Qt)|0,l=l+Math.imul(F,te)|0;var ai=(L+E|0)+((u&8191)<<13)|0;L=(l+(u>>>13)|0)+(ai>>>26)|0,ai&=67108863,E=Math.imul(Lt,_t),u=Math.imul(Lt,gt),u=u+Math.imul($t,_t)|0,l=Math.imul($t,gt),E=E+Math.imul(Ut,dt)|0,u=u+Math.imul(Ut,Ht)|0,u=u+Math.imul(Tt,dt)|0,l=l+Math.imul(Tt,Ht)|0,E=E+Math.imul(Ct,Wt)|0,u=u+Math.imul(Ct,jt)|0,u=u+Math.imul(qt,Wt)|0,l=l+Math.imul(qt,jt)|0,E=E+Math.imul(xt,Xt)|0,u=u+Math.imul(xt,Yt)|0,u=u+Math.imul(Ft,Xt)|0,l=l+Math.imul(Ft,Yt)|0,E=E+Math.imul(vt,Zt)|0,u=u+Math.imul(vt,Jt)|0,u=u+Math.imul(Ot,Zt)|0,l=l+Math.imul(Ot,Jt)|0,E=E+Math.imul(et,Qt)|0,u=u+Math.imul(et,te)|0,u=u+Math.imul(it,Qt)|0,l=l+Math.imul(it,te)|0,E=E+Math.imul(I,ee)|0,u=u+Math.imul(I,ne)|0,u=u+Math.imul(F,ee)|0,l=l+Math.imul(F,ne)|0;var ci=(L+E|0)+((u&8191)<<13)|0;L=(l+(u>>>13)|0)+(ci>>>26)|0,ci&=67108863,E=Math.imul(zt,_t),u=Math.imul(zt,gt),u=u+Math.imul(y,_t)|0,l=Math.imul(y,gt),E=E+Math.imul(Lt,dt)|0,u=u+Math.imul(Lt,Ht)|0,u=u+Math.imul($t,dt)|0,l=l+Math.imul($t,Ht)|0,E=E+Math.imul(Ut,Wt)|0,u=u+Math.imul(Ut,jt)|0,u=u+Math.imul(Tt,Wt)|0,l=l+Math.imul(Tt,jt)|0,E=E+Math.imul(Ct,Xt)|0,u=u+Math.imul(Ct,Yt)|0,u=u+Math.imul(qt,Xt)|0,l=l+Math.imul(qt,Yt)|0,E=E+Math.imul(xt,Zt)|0,u=u+Math.imul(xt,Jt)|0,u=u+Math.imul(Ft,Zt)|0,l=l+Math.imul(Ft,Jt)|0,E=E+Math.imul(vt,Qt)|0,u=u+Math.imul(vt,te)|0,u=u+Math.imul(Ot,Qt)|0,l=l+Math.imul(Ot,te)|0,E=E+Math.imul(et,ee)|0,u=u+Math.imul(et,ne)|0,u=u+Math.imul(it,ee)|0,l=l+Math.imul(it,ne)|0,E=E+Math.imul(I,re)|0,u=u+Math.imul(I,ie)|0,u=u+Math.imul(F,re)|0,l=l+Math.imul(F,ie)|0;var ui=(L+E|0)+((u&8191)<<13)|0;L=(l+(u>>>13)|0)+(ui>>>26)|0,ui&=67108863,E=Math.imul(p,_t),u=Math.imul(p,gt),u=u+Math.imul(A,_t)|0,l=Math.imul(A,gt),E=E+Math.imul(zt,dt)|0,u=u+Math.imul(zt,Ht)|0,u=u+Math.imul(y,dt)|0,l=l+Math.imul(y,Ht)|0,E=E+Math.imul(Lt,Wt)|0,u=u+Math.imul(Lt,jt)|0,u=u+Math.imul($t,Wt)|0,l=l+Math.imul($t,jt)|0,E=E+Math.imul(Ut,Xt)|0,u=u+Math.imul(Ut,Yt)|0,u=u+Math.imul(Tt,Xt)|0,l=l+Math.imul(Tt,Yt)|0,E=E+Math.imul(Ct,Zt)|0,u=u+Math.imul(Ct,Jt)|0,u=u+Math.imul(qt,Zt)|0,l=l+Math.imul(qt,Jt)|0,E=E+Math.imul(xt,Qt)|0,u=u+Math.imul(xt,te)|0,u=u+Math.imul(Ft,Qt)|0,l=l+Math.imul(Ft,te)|0,E=E+Math.imul(vt,ee)|0,u=u+Math.imul(vt,ne)|0,u=u+Math.imul(Ot,ee)|0,l=l+Math.imul(Ot,ne)|0,E=E+Math.imul(et,re)|0,u=u+Math.imul(et,ie)|0,u=u+Math.imul(it,re)|0,l=l+Math.imul(it,ie)|0,E=E+Math.imul(I,se)|0,u=u+Math.imul(I,oe)|0,u=u+Math.imul(F,se)|0,l=l+Math.imul(F,oe)|0;var li=(L+E|0)+((u&8191)<<13)|0;L=(l+(u>>>13)|0)+(li>>>26)|0,li&=67108863,E=Math.imul(q,_t),u=Math.imul(q,gt),u=u+Math.imul(j,_t)|0,l=Math.imul(j,gt),E=E+Math.imul(p,dt)|0,u=u+Math.imul(p,Ht)|0,u=u+Math.imul(A,dt)|0,l=l+Math.imul(A,Ht)|0,E=E+Math.imul(zt,Wt)|0,u=u+Math.imul(zt,jt)|0,u=u+Math.imul(y,Wt)|0,l=l+Math.imul(y,jt)|0,E=E+Math.imul(Lt,Xt)|0,u=u+Math.imul(Lt,Yt)|0,u=u+Math.imul($t,Xt)|0,l=l+Math.imul($t,Yt)|0,E=E+Math.imul(Ut,Zt)|0,u=u+Math.imul(Ut,Jt)|0,u=u+Math.imul(Tt,Zt)|0,l=l+Math.imul(Tt,Jt)|0,E=E+Math.imul(Ct,Qt)|0,u=u+Math.imul(Ct,te)|0,u=u+Math.imul(qt,Qt)|0,l=l+Math.imul(qt,te)|0,E=E+Math.imul(xt,ee)|0,u=u+Math.imul(xt,ne)|0,u=u+Math.imul(Ft,ee)|0,l=l+Math.imul(Ft,ne)|0,E=E+Math.imul(vt,re)|0,u=u+Math.imul(vt,ie)|0,u=u+Math.imul(Ot,re)|0,l=l+Math.imul(Ot,ie)|0,E=E+Math.imul(et,se)|0,u=u+Math.imul(et,oe)|0,u=u+Math.imul(it,se)|0,l=l+Math.imul(it,oe)|0,E=E+Math.imul(I,ae)|0,u=u+Math.imul(I,ce)|0,u=u+Math.imul(F,ae)|0,l=l+Math.imul(F,ce)|0;var fi=(L+E|0)+((u&8191)<<13)|0;L=(l+(u>>>13)|0)+(fi>>>26)|0,fi&=67108863,E=Math.imul(q,dt),u=Math.imul(q,Ht),u=u+Math.imul(j,dt)|0,l=Math.imul(j,Ht),E=E+Math.imul(p,Wt)|0,u=u+Math.imul(p,jt)|0,u=u+Math.imul(A,Wt)|0,l=l+Math.imul(A,jt)|0,E=E+Math.imul(zt,Xt)|0,u=u+Math.imul(zt,Yt)|0,u=u+Math.imul(y,Xt)|0,l=l+Math.imul(y,Yt)|0,E=E+Math.imul(Lt,Zt)|0,u=u+Math.imul(Lt,Jt)|0,u=u+Math.imul($t,Zt)|0,l=l+Math.imul($t,Jt)|0,E=E+Math.imul(Ut,Qt)|0,u=u+Math.imul(Ut,te)|0,u=u+Math.imul(Tt,Qt)|0,l=l+Math.imul(Tt,te)|0,E=E+Math.imul(Ct,ee)|0,u=u+Math.imul(Ct,ne)|0,u=u+Math.imul(qt,ee)|0,l=l+Math.imul(qt,ne)|0,E=E+Math.imul(xt,re)|0,u=u+Math.imul(xt,ie)|0,u=u+Math.imul(Ft,re)|0,l=l+Math.imul(Ft,ie)|0,E=E+Math.imul(vt,se)|0,u=u+Math.imul(vt,oe)|0,u=u+Math.imul(Ot,se)|0,l=l+Math.imul(Ot,oe)|0,E=E+Math.imul(et,ae)|0,u=u+Math.imul(et,ce)|0,u=u+Math.imul(it,ae)|0,l=l+Math.imul(it,ce)|0;var hi=(L+E|0)+((u&8191)<<13)|0;L=(l+(u>>>13)|0)+(hi>>>26)|0,hi&=67108863,E=Math.imul(q,Wt),u=Math.imul(q,jt),u=u+Math.imul(j,Wt)|0,l=Math.imul(j,jt),E=E+Math.imul(p,Xt)|0,u=u+Math.imul(p,Yt)|0,u=u+Math.imul(A,Xt)|0,l=l+Math.imul(A,Yt)|0,E=E+Math.imul(zt,Zt)|0,u=u+Math.imul(zt,Jt)|0,u=u+Math.imul(y,Zt)|0,l=l+Math.imul(y,Jt)|0,E=E+Math.imul(Lt,Qt)|0,u=u+Math.imul(Lt,te)|0,u=u+Math.imul($t,Qt)|0,l=l+Math.imul($t,te)|0,E=E+Math.imul(Ut,ee)|0,u=u+Math.imul(Ut,ne)|0,u=u+Math.imul(Tt,ee)|0,l=l+Math.imul(Tt,ne)|0,E=E+Math.imul(Ct,re)|0,u=u+Math.imul(Ct,ie)|0,u=u+Math.imul(qt,re)|0,l=l+Math.imul(qt,ie)|0,E=E+Math.imul(xt,se)|0,u=u+Math.imul(xt,oe)|0,u=u+Math.imul(Ft,se)|0,l=l+Math.imul(Ft,oe)|0,E=E+Math.imul(vt,ae)|0,u=u+Math.imul(vt,ce)|0,u=u+Math.imul(Ot,ae)|0,l=l+Math.imul(Ot,ce)|0;var di=(L+E|0)+((u&8191)<<13)|0;L=(l+(u>>>13)|0)+(di>>>26)|0,di&=67108863,E=Math.imul(q,Xt),u=Math.imul(q,Yt),u=u+Math.imul(j,Xt)|0,l=Math.imul(j,Yt),E=E+Math.imul(p,Zt)|0,u=u+Math.imul(p,Jt)|0,u=u+Math.imul(A,Zt)|0,l=l+Math.imul(A,Jt)|0,E=E+Math.imul(zt,Qt)|0,u=u+Math.imul(zt,te)|0,u=u+Math.imul(y,Qt)|0,l=l+Math.imul(y,te)|0,E=E+Math.imul(Lt,ee)|0,u=u+Math.imul(Lt,ne)|0,u=u+Math.imul($t,ee)|0,l=l+Math.imul($t,ne)|0,E=E+Math.imul(Ut,re)|0,u=u+Math.imul(Ut,ie)|0,u=u+Math.imul(Tt,re)|0,l=l+Math.imul(Tt,ie)|0,E=E+Math.imul(Ct,se)|0,u=u+Math.imul(Ct,oe)|0,u=u+Math.imul(qt,se)|0,l=l+Math.imul(qt,oe)|0,E=E+Math.imul(xt,ae)|0,u=u+Math.imul(xt,ce)|0,u=u+Math.imul(Ft,ae)|0,l=l+Math.imul(Ft,ce)|0;var pi=(L+E|0)+((u&8191)<<13)|0;L=(l+(u>>>13)|0)+(pi>>>26)|0,pi&=67108863,E=Math.imul(q,Zt),u=Math.imul(q,Jt),u=u+Math.imul(j,Zt)|0,l=Math.imul(j,Jt),E=E+Math.imul(p,Qt)|0,u=u+Math.imul(p,te)|0,u=u+Math.imul(A,Qt)|0,l=l+Math.imul(A,te)|0,E=E+Math.imul(zt,ee)|0,u=u+Math.imul(zt,ne)|0,u=u+Math.imul(y,ee)|0,l=l+Math.imul(y,ne)|0,E=E+Math.imul(Lt,re)|0,u=u+Math.imul(Lt,ie)|0,u=u+Math.imul($t,re)|0,l=l+Math.imul($t,ie)|0,E=E+Math.imul(Ut,se)|0,u=u+Math.imul(Ut,oe)|0,u=u+Math.imul(Tt,se)|0,l=l+Math.imul(Tt,oe)|0,E=E+Math.imul(Ct,ae)|0,u=u+Math.imul(Ct,ce)|0,u=u+Math.imul(qt,ae)|0,l=l+Math.imul(qt,ce)|0;var gi=(L+E|0)+((u&8191)<<13)|0;L=(l+(u>>>13)|0)+(gi>>>26)|0,gi&=67108863,E=Math.imul(q,Qt),u=Math.imul(q,te),u=u+Math.imul(j,Qt)|0,l=Math.imul(j,te),E=E+Math.imul(p,ee)|0,u=u+Math.imul(p,ne)|0,u=u+Math.imul(A,ee)|0,l=l+Math.imul(A,ne)|0,E=E+Math.imul(zt,re)|0,u=u+Math.imul(zt,ie)|0,u=u+Math.imul(y,re)|0,l=l+Math.imul(y,ie)|0,E=E+Math.imul(Lt,se)|0,u=u+Math.imul(Lt,oe)|0,u=u+Math.imul($t,se)|0,l=l+Math.imul($t,oe)|0,E=E+Math.imul(Ut,ae)|0,u=u+Math.imul(Ut,ce)|0,u=u+Math.imul(Tt,ae)|0,l=l+Math.imul(Tt,ce)|0;var _i=(L+E|0)+((u&8191)<<13)|0;L=(l+(u>>>13)|0)+(_i>>>26)|0,_i&=67108863,E=Math.imul(q,ee),u=Math.imul(q,ne),u=u+Math.imul(j,ee)|0,l=Math.imul(j,ne),E=E+Math.imul(p,re)|0,u=u+Math.imul(p,ie)|0,u=u+Math.imul(A,re)|0,l=l+Math.imul(A,ie)|0,E=E+Math.imul(zt,se)|0,u=u+Math.imul(zt,oe)|0,u=u+Math.imul(y,se)|0,l=l+Math.imul(y,oe)|0,E=E+Math.imul(Lt,ae)|0,u=u+Math.imul(Lt,ce)|0,u=u+Math.imul($t,ae)|0,l=l+Math.imul($t,ce)|0;var mi=(L+E|0)+((u&8191)<<13)|0;L=(l+(u>>>13)|0)+(mi>>>26)|0,mi&=67108863,E=Math.imul(q,re),u=Math.imul(q,ie),u=u+Math.imul(j,re)|0,l=Math.imul(j,ie),E=E+Math.imul(p,se)|0,u=u+Math.imul(p,oe)|0,u=u+Math.imul(A,se)|0,l=l+Math.imul(A,oe)|0,E=E+Math.imul(zt,ae)|0,u=u+Math.imul(zt,ce)|0,u=u+Math.imul(y,ae)|0,l=l+Math.imul(y,ce)|0;var yi=(L+E|0)+((u&8191)<<13)|0;L=(l+(u>>>13)|0)+(yi>>>26)|0,yi&=67108863,E=Math.imul(q,se),u=Math.imul(q,oe),u=u+Math.imul(j,se)|0,l=Math.imul(j,oe),E=E+Math.imul(p,ae)|0,u=u+Math.imul(p,ce)|0,u=u+Math.imul(A,ae)|0,l=l+Math.imul(A,ce)|0;var wi=(L+E|0)+((u&8191)<<13)|0;L=(l+(u>>>13)|0)+(wi>>>26)|0,wi&=67108863,E=Math.imul(q,ae),u=Math.imul(q,ce),u=u+Math.imul(j,ae)|0,l=Math.imul(j,ce);var Ei=(L+E|0)+((u&8191)<<13)|0;return L=(l+(u>>>13)|0)+(Ei>>>26)|0,Ei&=67108863,N[0]=ni,N[1]=ri,N[2]=ii,N[3]=si,N[4]=oi,N[5]=ai,N[6]=ci,N[7]=ui,N[8]=li,N[9]=fi,N[10]=hi,N[11]=di,N[12]=pi,N[13]=gi,N[14]=_i,N[15]=mi,N[16]=yi,N[17]=wi,N[18]=Ei,L!==0&&(N[19]=L,g.length++),g};Math.imul||(W=P);function z(m,a,h){h.negative=a.negative^m.negative,h.length=m.length+a.length;for(var g=0,R=0,v=0;v<h.length-1;v++){var N=R;R=0;for(var L=g&67108863,E=Math.min(v,a.length-1),u=Math.max(0,v-m.length+1);u<=E;u++){var l=v-u,w=m.words[l]|0,I=a.words[u]|0,F=w*I,X=F&67108863;N=N+(F/67108864|0)|0,X=X+L|0,L=X&67108863,N=N+(X>>>26)|0,R+=N>>>26,N&=67108863}h.words[v]=L,g=N,N=R}return g!==0?h.words[v]=g:h.length--,h._strip()}function Q(m,a,h){return z(m,a,h)}i.prototype.mulTo=function(a,h){var g,R=this.length+a.length;return this.length===10&&a.length===10?g=W(this,a,h):R<63?g=P(this,a,h):R<1024?g=z(this,a,h):g=Q(this,a,h),g},i.prototype.mul=function(a){var h=new i(null);return h.words=new Array(this.length+a.length),this.mulTo(a,h)},i.prototype.mulf=function(a){var h=new i(null);return h.words=new Array(this.length+a.length),Q(this,a,h)},i.prototype.imul=function(a){return this.clone().mulTo(a,this)},i.prototype.imuln=function(a){var h=a<0;h&&(a=-a),n(typeof a=="number"),n(a<67108864);for(var g=0,R=0;R<this.length;R++){var v=(this.words[R]|0)*a,N=(v&67108863)+(g&67108863);g>>=26,g+=v/67108864|0,g+=N>>>26,this.words[R]=N&67108863}return g!==0&&(this.words[R]=g,this.length++),this.length=a===0?1:this.length,h?this.ineg():this},i.prototype.muln=function(a){return this.clone().imuln(a)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(a){var h=M(a);if(h.length===0)return new i(1);for(var g=this,R=0;R<h.length&&h[R]===0;R++,g=g.sqr());if(++R<h.length)for(var v=g.sqr();R<h.length;R++,v=v.sqr())h[R]!==0&&(g=g.mul(v));return g},i.prototype.iushln=function(a){n(typeof a=="number"&&a>=0);var h=a%26,g=(a-h)/26,R=67108863>>>26-h<<26-h,v;if(h!==0){var N=0;for(v=0;v<this.length;v++){var L=this.words[v]&R,E=(this.words[v]|0)-L<<h;this.words[v]=E|N,N=L>>>26-h}N&&(this.words[v]=N,this.length++)}if(g!==0){for(v=this.length-1;v>=0;v--)this.words[v+g]=this.words[v];for(v=0;v<g;v++)this.words[v]=0;this.length+=g}return this._strip()},i.prototype.ishln=function(a){return n(this.negative===0),this.iushln(a)},i.prototype.iushrn=function(a,h,g){n(typeof a=="number"&&a>=0);var R;h?R=(h-h%26)/26:R=0;var v=a%26,N=Math.min((a-v)/26,this.length),L=67108863^67108863>>>v<<v,E=g;if(R-=N,R=Math.max(0,R),E){for(var u=0;u<N;u++)E.words[u]=this.words[u];E.length=N}if(N!==0)if(this.length>N)for(this.length-=N,u=0;u<this.length;u++)this.words[u]=this.words[u+N];else this.words[0]=0,this.length=1;var l=0;for(u=this.length-1;u>=0&&(l!==0||u>=R);u--){var w=this.words[u]|0;this.words[u]=l<<26-v|w>>>v,l=w&L}return E&&l!==0&&(E.words[E.length++]=l),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},i.prototype.ishrn=function(a,h,g){return n(this.negative===0),this.iushrn(a,h,g)},i.prototype.shln=function(a){return this.clone().ishln(a)},i.prototype.ushln=function(a){return this.clone().iushln(a)},i.prototype.shrn=function(a){return this.clone().ishrn(a)},i.prototype.ushrn=function(a){return this.clone().iushrn(a)},i.prototype.testn=function(a){n(typeof a=="number"&&a>=0);var h=a%26,g=(a-h)/26,R=1<<h;if(this.length<=g)return!1;var v=this.words[g];return!!(v&R)},i.prototype.imaskn=function(a){n(typeof a=="number"&&a>=0);var h=a%26,g=(a-h)/26;if(n(this.negative===0,"imaskn works only with positive numbers"),this.length<=g)return this;if(h!==0&&g++,this.length=Math.min(g,this.length),h!==0){var R=67108863^67108863>>>h<<h;this.words[this.length-1]&=R}return this._strip()},i.prototype.maskn=function(a){return this.clone().imaskn(a)},i.prototype.iaddn=function(a){return n(typeof a=="number"),n(a<67108864),a<0?this.isubn(-a):this.negative!==0?this.length===1&&(this.words[0]|0)<=a?(this.words[0]=a-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(a),this.negative=1,this):this._iaddn(a)},i.prototype._iaddn=function(a){this.words[0]+=a;for(var h=0;h<this.length&&this.words[h]>=67108864;h++)this.words[h]-=67108864,h===this.length-1?this.words[h+1]=1:this.words[h+1]++;return this.length=Math.max(this.length,h+1),this},i.prototype.isubn=function(a){if(n(typeof a=="number"),n(a<67108864),a<0)return this.iaddn(-a);if(this.negative!==0)return this.negative=0,this.iaddn(a),this.negative=1,this;if(this.words[0]-=a,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var h=0;h<this.length&&this.words[h]<0;h++)this.words[h]+=67108864,this.words[h+1]-=1;return this._strip()},i.prototype.addn=function(a){return this.clone().iaddn(a)},i.prototype.subn=function(a){return this.clone().isubn(a)},i.prototype.iabs=function(){return this.negative=0,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(a,h,g){var R=a.length+g,v;this._expand(R);var N,L=0;for(v=0;v<a.length;v++){N=(this.words[v+g]|0)+L;var E=(a.words[v]|0)*h;N-=E&67108863,L=(N>>26)-(E/67108864|0),this.words[v+g]=N&67108863}for(;v<this.length-g;v++)N=(this.words[v+g]|0)+L,L=N>>26,this.words[v+g]=N&67108863;if(L===0)return this._strip();for(n(L===-1),L=0,v=0;v<this.length;v++)N=-(this.words[v]|0)+L,L=N>>26,this.words[v]=N&67108863;return this.negative=1,this._strip()},i.prototype._wordDiv=function(a,h){var g=this.length-a.length,R=this.clone(),v=a,N=v.words[v.length-1]|0,L=this._countBits(N);g=26-L,g!==0&&(v=v.ushln(g),R.iushln(g),N=v.words[v.length-1]|0);var E=R.length-v.length,u;if(h!=="mod"){u=new i(null),u.length=E+1,u.words=new Array(u.length);for(var l=0;l<u.length;l++)u.words[l]=0}var w=R.clone()._ishlnsubmul(v,1,E);w.negative===0&&(R=w,u&&(u.words[E]=1));for(var I=E-1;I>=0;I--){var F=(R.words[v.length+I]|0)*67108864+(R.words[v.length+I-1]|0);for(F=Math.min(F/N|0,67108863),R._ishlnsubmul(v,F,I);R.negative!==0;)F--,R.negative=0,R._ishlnsubmul(v,1,I),R.isZero()||(R.negative^=1);u&&(u.words[I]=F)}return u&&u._strip(),R._strip(),h!=="div"&&g!==0&&R.iushrn(g),{div:u||null,mod:R}},i.prototype.divmod=function(a,h,g){if(n(!a.isZero()),this.isZero())return{div:new i(0),mod:new i(0)};var R,v,N;return this.negative!==0&&a.negative===0?(N=this.neg().divmod(a,h),h!=="mod"&&(R=N.div.neg()),h!=="div"&&(v=N.mod.neg(),g&&v.negative!==0&&v.iadd(a)),{div:R,mod:v}):this.negative===0&&a.negative!==0?(N=this.divmod(a.neg(),h),h!=="mod"&&(R=N.div.neg()),{div:R,mod:N.mod}):(this.negative&a.negative)!==0?(N=this.neg().divmod(a.neg(),h),h!=="div"&&(v=N.mod.neg(),g&&v.negative!==0&&v.isub(a)),{div:N.div,mod:v}):a.length>this.length||this.cmp(a)<0?{div:new i(0),mod:this}:a.length===1?h==="div"?{div:this.divn(a.words[0]),mod:null}:h==="mod"?{div:null,mod:new i(this.modrn(a.words[0]))}:{div:this.divn(a.words[0]),mod:new i(this.modrn(a.words[0]))}:this._wordDiv(a,h)},i.prototype.div=function(a){return this.divmod(a,"div",!1).div},i.prototype.mod=function(a){return this.divmod(a,"mod",!1).mod},i.prototype.umod=function(a){return this.divmod(a,"mod",!0).mod},i.prototype.divRound=function(a){var h=this.divmod(a);if(h.mod.isZero())return h.div;var g=h.div.negative!==0?h.mod.isub(a):h.mod,R=a.ushrn(1),v=a.andln(1),N=g.cmp(R);return N<0||v===1&&N===0?h.div:h.div.negative!==0?h.div.isubn(1):h.div.iaddn(1)},i.prototype.modrn=function(a){var h=a<0;h&&(a=-a),n(a<=67108863);for(var g=(1<<26)%a,R=0,v=this.length-1;v>=0;v--)R=(g*R+(this.words[v]|0))%a;return h?-R:R},i.prototype.modn=function(a){return this.modrn(a)},i.prototype.idivn=function(a){var h=a<0;h&&(a=-a),n(a<=67108863);for(var g=0,R=this.length-1;R>=0;R--){var v=(this.words[R]|0)+g*67108864;this.words[R]=v/a|0,g=v%a}return this._strip(),h?this.ineg():this},i.prototype.divn=function(a){return this.clone().idivn(a)},i.prototype.egcd=function(a){n(a.negative===0),n(!a.isZero());var h=this,g=a.clone();h.negative!==0?h=h.umod(a):h=h.clone();for(var R=new i(1),v=new i(0),N=new i(0),L=new i(1),E=0;h.isEven()&&g.isEven();)h.iushrn(1),g.iushrn(1),++E;for(var u=g.clone(),l=h.clone();!h.isZero();){for(var w=0,I=1;(h.words[0]&I)===0&&w<26;++w,I<<=1);if(w>0)for(h.iushrn(w);w-- >0;)(R.isOdd()||v.isOdd())&&(R.iadd(u),v.isub(l)),R.iushrn(1),v.iushrn(1);for(var F=0,X=1;(g.words[0]&X)===0&&F<26;++F,X<<=1);if(F>0)for(g.iushrn(F);F-- >0;)(N.isOdd()||L.isOdd())&&(N.iadd(u),L.isub(l)),N.iushrn(1),L.iushrn(1);h.cmp(g)>=0?(h.isub(g),R.isub(N),v.isub(L)):(g.isub(h),N.isub(R),L.isub(v))}return{a:N,b:L,gcd:g.iushln(E)}},i.prototype._invmp=function(a){n(a.negative===0),n(!a.isZero());var h=this,g=a.clone();h.negative!==0?h=h.umod(a):h=h.clone();for(var R=new i(1),v=new i(0),N=g.clone();h.cmpn(1)>0&&g.cmpn(1)>0;){for(var L=0,E=1;(h.words[0]&E)===0&&L<26;++L,E<<=1);if(L>0)for(h.iushrn(L);L-- >0;)R.isOdd()&&R.iadd(N),R.iushrn(1);for(var u=0,l=1;(g.words[0]&l)===0&&u<26;++u,l<<=1);if(u>0)for(g.iushrn(u);u-- >0;)v.isOdd()&&v.iadd(N),v.iushrn(1);h.cmp(g)>=0?(h.isub(g),R.isub(v)):(g.isub(h),v.isub(R))}var w;return h.cmpn(1)===0?w=R:w=v,w.cmpn(0)<0&&w.iadd(a),w},i.prototype.gcd=function(a){if(this.isZero())return a.abs();if(a.isZero())return this.abs();var h=this.clone(),g=a.clone();h.negative=0,g.negative=0;for(var R=0;h.isEven()&&g.isEven();R++)h.iushrn(1),g.iushrn(1);do{for(;h.isEven();)h.iushrn(1);for(;g.isEven();)g.iushrn(1);var v=h.cmp(g);if(v<0){var N=h;h=g,g=N}else if(v===0||g.cmpn(1)===0)break;h.isub(g)}while(!0);return g.iushln(R)},i.prototype.invm=function(a){return this.egcd(a).a.umod(a)},i.prototype.isEven=function(){return(this.words[0]&1)===0},i.prototype.isOdd=function(){return(this.words[0]&1)===1},i.prototype.andln=function(a){return this.words[0]&a},i.prototype.bincn=function(a){n(typeof a=="number");var h=a%26,g=(a-h)/26,R=1<<h;if(this.length<=g)return this._expand(g+1),this.words[g]|=R,this;for(var v=R,N=g;v!==0&&N<this.length;N++){var L=this.words[N]|0;L+=v,v=L>>>26,L&=67108863,this.words[N]=L}return v!==0&&(this.words[N]=v,this.length++),this},i.prototype.isZero=function(){return this.length===1&&this.words[0]===0},i.prototype.cmpn=function(a){var h=a<0;if(this.negative!==0&&!h)return-1;if(this.negative===0&&h)return 1;this._strip();var g;if(this.length>1)g=1;else{h&&(a=-a),n(a<=67108863,"Number is too big");var R=this.words[0]|0;g=R===a?0:R<a?-1:1}return this.negative!==0?-g|0:g},i.prototype.cmp=function(a){if(this.negative!==0&&a.negative===0)return-1;if(this.negative===0&&a.negative!==0)return 1;var h=this.ucmp(a);return this.negative!==0?-h|0:h},i.prototype.ucmp=function(a){if(this.length>a.length)return 1;if(this.length<a.length)return-1;for(var h=0,g=this.length-1;g>=0;g--){var R=this.words[g]|0,v=a.words[g]|0;if(R!==v){R<v?h=-1:R>v&&(h=1);break}}return h},i.prototype.gtn=function(a){return this.cmpn(a)===1},i.prototype.gt=function(a){return this.cmp(a)===1},i.prototype.gten=function(a){return this.cmpn(a)>=0},i.prototype.gte=function(a){return this.cmp(a)>=0},i.prototype.ltn=function(a){return this.cmpn(a)===-1},i.prototype.lt=function(a){return this.cmp(a)===-1},i.prototype.lten=function(a){return this.cmpn(a)<=0},i.prototype.lte=function(a){return this.cmp(a)<=0},i.prototype.eqn=function(a){return this.cmpn(a)===0},i.prototype.eq=function(a){return this.cmp(a)===0},i.red=function(a){return new V(a)},i.prototype.toRed=function(a){return n(!this.red,"Already a number in reduction context"),n(this.negative===0,"red works only with positives"),a.convertTo(this)._forceRed(a)},i.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(a){return this.red=a,this},i.prototype.forceRed=function(a){return n(!this.red,"Already a number in reduction context"),this._forceRed(a)},i.prototype.redAdd=function(a){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,a)},i.prototype.redIAdd=function(a){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,a)},i.prototype.redSub=function(a){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,a)},i.prototype.redISub=function(a){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,a)},i.prototype.redShl=function(a){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,a)},i.prototype.redMul=function(a){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,a),this.red.mul(this,a)},i.prototype.redIMul=function(a){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,a),this.red.imul(this,a)},i.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(a){return n(this.red&&!a.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,a)};var Z={k256:null,p224:null,p192:null,p25519:null};function st(m,a){this.name=m,this.p=new i(a,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}st.prototype._tmp=function(){var a=new i(null);return a.words=new Array(Math.ceil(this.n/13)),a},st.prototype.ireduce=function(a){var h=a,g;do this.split(h,this.tmp),h=this.imulK(h),h=h.iadd(this.tmp),g=h.bitLength();while(g>this.n);var R=g<this.n?-1:h.ucmp(this.p);return R===0?(h.words[0]=0,h.length=1):R>0?h.isub(this.p):h.strip!==void 0?h.strip():h._strip(),h},st.prototype.split=function(a,h){a.iushrn(this.n,0,h)},st.prototype.imulK=function(a){return a.imul(this.k)};function pt(){st.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}s(pt,st),pt.prototype.split=function(a,h){for(var g=4194303,R=Math.min(a.length,9),v=0;v<R;v++)h.words[v]=a.words[v];if(h.length=R,a.length<=9){a.words[0]=0,a.length=1;return}var N=a.words[9];for(h.words[h.length++]=N&g,v=10;v<a.length;v++){var L=a.words[v]|0;a.words[v-10]=(L&g)<<4|N>>>22,N=L}N>>>=22,a.words[v-10]=N,N===0&&a.length>10?a.length-=10:a.length-=9},pt.prototype.imulK=function(a){a.words[a.length]=0,a.words[a.length+1]=0,a.length+=2;for(var h=0,g=0;g<a.length;g++){var R=a.words[g]|0;h+=R*977,a.words[g]=h&67108863,h=R*64+(h/67108864|0)}return a.words[a.length-1]===0&&(a.length--,a.words[a.length-1]===0&&a.length--),a};function ct(){st.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}s(ct,st);function k(){st.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}s(k,st);function D(){st.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}s(D,st),D.prototype.imulK=function(a){for(var h=0,g=0;g<a.length;g++){var R=(a.words[g]|0)*19+h,v=R&67108863;R>>>=26,a.words[g]=v,h=R}return h!==0&&(a.words[a.length++]=h),a},i._prime=function(a){if(Z[a])return Z[a];var h;if(a==="k256")h=new pt;else if(a==="p224")h=new ct;else if(a==="p192")h=new k;else if(a==="p25519")h=new D;else throw new Error("Unknown prime "+a);return Z[a]=h,h};function V(m){if(typeof m=="string"){var a=i._prime(m);this.m=a.p,this.prime=a}else n(m.gtn(1),"modulus must be greater than 1"),this.m=m,this.prime=null}V.prototype._verify1=function(a){n(a.negative===0,"red works only with positives"),n(a.red,"red works only with red numbers")},V.prototype._verify2=function(a,h){n((a.negative|h.negative)===0,"red works only with positives"),n(a.red&&a.red===h.red,"red works only with red numbers")},V.prototype.imod=function(a){return this.prime?this.prime.ireduce(a)._forceRed(this):(b(a,a.umod(this.m)._forceRed(this)),a)},V.prototype.neg=function(a){return a.isZero()?a.clone():this.m.sub(a)._forceRed(this)},V.prototype.add=function(a,h){this._verify2(a,h);var g=a.add(h);return g.cmp(this.m)>=0&&g.isub(this.m),g._forceRed(this)},V.prototype.iadd=function(a,h){this._verify2(a,h);var g=a.iadd(h);return g.cmp(this.m)>=0&&g.isub(this.m),g},V.prototype.sub=function(a,h){this._verify2(a,h);var g=a.sub(h);return g.cmpn(0)<0&&g.iadd(this.m),g._forceRed(this)},V.prototype.isub=function(a,h){this._verify2(a,h);var g=a.isub(h);return g.cmpn(0)<0&&g.iadd(this.m),g},V.prototype.shl=function(a,h){return this._verify1(a),this.imod(a.ushln(h))},V.prototype.imul=function(a,h){return this._verify2(a,h),this.imod(a.imul(h))},V.prototype.mul=function(a,h){return this._verify2(a,h),this.imod(a.mul(h))},V.prototype.isqr=function(a){return this.imul(a,a.clone())},V.prototype.sqr=function(a){return this.mul(a,a)},V.prototype.sqrt=function(a){if(a.isZero())return a.clone();var h=this.m.andln(3);if(n(h%2===1),h===3){var g=this.m.add(new i(1)).iushrn(2);return this.pow(a,g)}for(var R=this.m.subn(1),v=0;!R.isZero()&&R.andln(1)===0;)v++,R.iushrn(1);n(!R.isZero());var N=new i(1).toRed(this),L=N.redNeg(),E=this.m.subn(1).iushrn(1),u=this.m.bitLength();for(u=new i(2*u*u).toRed(this);this.pow(u,E).cmp(L)!==0;)u.redIAdd(L);for(var l=this.pow(u,R),w=this.pow(a,R.addn(1).iushrn(1)),I=this.pow(a,R),F=v;I.cmp(N)!==0;){for(var X=I,et=0;X.cmp(N)!==0;et++)X=X.redSqr();n(et<F);var it=this.pow(l,new i(1).iushln(F-et-1));w=w.redMul(it),l=it.redSqr(),I=I.redMul(l),F=et}return w},V.prototype.invm=function(a){var h=a._invmp(this.m);return h.negative!==0?(h.negative=0,this.imod(h).redNeg()):this.imod(h)},V.prototype.pow=function(a,h){if(h.isZero())return new i(1).toRed(this);if(h.cmpn(1)===0)return a.clone();var g=4,R=new Array(1<<g);R[0]=new i(1).toRed(this),R[1]=a;for(var v=2;v<R.length;v++)R[v]=this.mul(R[v-1],a);var N=R[0],L=0,E=0,u=h.bitLength()%26;for(u===0&&(u=26),v=h.length-1;v>=0;v--){for(var l=h.words[v],w=u-1;w>=0;w--){var I=l>>w&1;if(N!==R[0]&&(N=this.sqr(N)),I===0&&L===0){E=0;continue}L<<=1,L|=I,E++,!(E!==g&&(v!==0||w!==0))&&(N=this.mul(N,R[L]),E=0,L=0)}u=26}return N},V.prototype.convertTo=function(a){var h=a.umod(this.m);return h===a?h.clone():h},V.prototype.convertFrom=function(a){var h=a.clone();return h.red=null,h},i.mont=function(a){return new K(a)};function K(m){V.call(this,m),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new i(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}s(K,V),K.prototype.convertTo=function(a){return this.imod(a.ushln(this.shift))},K.prototype.convertFrom=function(a){var h=this.imod(a.mul(this.rinv));return h.red=null,h},K.prototype.imul=function(a,h){if(a.isZero()||h.isZero())return a.words[0]=0,a.length=1,a;var g=a.imul(h),R=g.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),v=g.isub(R).iushrn(this.shift),N=v;return v.cmp(this.m)>=0?N=v.isub(this.m):v.cmpn(0)<0&&(N=v.iadd(this.m)),N._forceRed(this)},K.prototype.mul=function(a,h){if(a.isZero()||h.isZero())return new i(0)._forceRed(this);var g=a.mul(h),R=g.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),v=g.isub(R).iushrn(this.shift),N=v;return v.cmp(this.m)>=0?N=v.isub(this.m):v.cmpn(0)<0&&(N=v.iadd(this.m)),N._forceRed(this)},K.prototype.invm=function(a){var h=this.imod(a._invmp(this.m).mul(this.r2));return h._forceRed(this)}})(r,ul)})(vr)),vr.exports}var ll=Ba();const _o=Hr(ll);var wr={exports:{}};var mo;function fl(){return mo||(mo=1,(function(r,t){var e=ys(),n=e.Buffer;function s(o,c){for(var d in o)c[d]=o[d]}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?r.exports=e:(s(e,t),t.Buffer=i);function i(o,c,d){return n(o,c,d)}i.prototype=Object.create(n.prototype),s(n,i),i.from=function(o,c,d){if(typeof o=="number")throw new TypeError("Argument must not be a number");return n(o,c,d)},i.alloc=function(o,c,d){if(typeof o!="number")throw new TypeError("Argument must be a number");var _=n(o);return c!==void 0?typeof d=="string"?_.fill(c,d):_.fill(c):_.fill(0),_},i.allocUnsafe=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return n(o)},i.allocUnsafeSlow=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return e.SlowBuffer(o)}})(wr,wr.exports)),wr.exports}var Li,yo;function hl(){if(yo)return Li;yo=1;var r=fl().Buffer;function t(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var n=new Uint8Array(256),s=0;s<n.length;s++)n[s]=255;for(var i=0;i<e.length;i++){var o=e.charAt(i),c=o.charCodeAt(0);if(n[c]!==255)throw new TypeError(o+" is ambiguous");n[c]=i}var d=e.length,_=e.charAt(0),b=Math.log(d)/Math.log(256),O=Math.log(256)/Math.log(d);function x(C){if((Array.isArray(C)||C instanceof Uint8Array)&&(C=r.from(C)),!r.isBuffer(C))throw new TypeError("Expected Buffer");if(C.length===0)return"";for(var M=0,P=0,W=0,z=C.length;W!==z&&C[W]===0;)W++,M++;for(var Q=(z-W)*O+1>>>0,Z=new Uint8Array(Q);W!==z;){for(var st=C[W],pt=0,ct=Q-1;(st!==0||pt<P)&&ct!==-1;ct--,pt++)st+=256*Z[ct]>>>0,Z[ct]=st%d>>>0,st=st/d>>>0;if(st!==0)throw new Error("Non-zero carry");P=pt,W++}for(var k=Q-P;k!==Q&&Z[k]===0;)k++;for(var D=_.repeat(M);k<Q;++k)D+=e.charAt(Z[k]);return D}function S(C){if(typeof C!="string")throw new TypeError("Expected String");if(C.length===0)return r.alloc(0);for(var M=0,P=0,W=0;C[M]===_;)P++,M++;for(var z=(C.length-M)*b+1>>>0,Q=new Uint8Array(z);M<C.length;){var Z=C.charCodeAt(M);if(Z>255)return;var st=n[Z];if(st===255)return;for(var pt=0,ct=z-1;(st!==0||pt<W)&&ct!==-1;ct--,pt++)st+=d*Q[ct]>>>0,Q[ct]=st%256>>>0,st=st/256>>>0;if(st!==0)throw new Error("Non-zero carry");W=pt,M++}for(var k=z-W;k!==z&&Q[k]===0;)k++;var D=r.allocUnsafe(P+(z-k));D.fill(0,0,P);for(var V=P;k!==z;)D[V++]=Q[k++];return D}function T(C){var M=S(C);if(M)return M;throw new Error("Non-base"+d+" character")}return{encode:x,decodeUnsafe:S,decode:T}}return Li=t,Li}var Mi,wo;function Ca(){if(wo)return Mi;wo=1;var r=hl(),t="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";return Mi=r(t),Mi}var dl=Ca();const he=Hr(dl),Eo=la;var It={};function Ke(r,t,e){return t<=r&&r<=e}function Xr(r){if(r===void 0)return{};if(r===Object(r))return r;throw TypeError("Could not convert argument to dictionary")}function pl(r){for(var t=String(r),e=t.length,n=0,s=[];n<e;){var i=t.charCodeAt(n);if(i<55296||i>57343)s.push(i);else if(56320<=i&&i<=57343)s.push(65533);else if(55296<=i&&i<=56319)if(n===e-1)s.push(65533);else{var o=r.charCodeAt(n+1);if(56320<=o&&o<=57343){var c=i&1023,d=o&1023;s.push(65536+(c<<10)+d),n+=1}else s.push(65533)}n+=1}return s}function gl(r){for(var t="",e=0;e<r.length;++e){var n=r[e];n<=65535?t+=String.fromCharCode(n):(n-=65536,t+=String.fromCharCode((n>>10)+55296,(n&1023)+56320))}return t}var kr=-1;function vs(r){this.tokens=[].slice.call(r)}vs.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():kr},prepend:function(r){if(Array.isArray(r))for(var t=r;t.length;)this.tokens.unshift(t.pop());else this.tokens.unshift(r)},push:function(r){if(Array.isArray(r))for(var t=r;t.length;)this.tokens.push(t.shift());else this.tokens.push(r)}};var Dn=-1;function ki(r,t){if(r)throw TypeError("Decoder error");return t||65533}var Ur="utf-8";function Dr(r,t){if(!(this instanceof Dr))return new Dr(r,t);if(r=r!==void 0?String(r).toLowerCase():Ur,r!==Ur)throw new Error("Encoding not supported. Only utf-8 is supported");t=Xr(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})}Dr.prototype={decode:function(t,e){var n;typeof t=="object"&&t instanceof ArrayBuffer?n=new Uint8Array(t):typeof t=="object"&&"buffer"in t&&t.buffer instanceof ArrayBuffer?n=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):n=new Uint8Array(0),e=Xr(e),this._streaming||(this._decoder=new _l({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!e.stream;for(var s=new vs(n),i=[],o;!s.endOfStream()&&(o=this._decoder.handler(s,s.read()),o!==Dn);)o!==null&&(Array.isArray(o)?i.push.apply(i,o):i.push(o));if(!this._streaming){do{if(o=this._decoder.handler(s,s.read()),o===Dn)break;o!==null&&(Array.isArray(o)?i.push.apply(i,o):i.push(o))}while(!s.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),gl(i)}};function Pr(r,t){if(!(this instanceof Pr))return new Pr(r,t);if(r=r!==void 0?String(r).toLowerCase():Ur,r!==Ur)throw new Error("Encoding not supported. Only utf-8 is supported");t=Xr(t),this._streaming=!1,this._encoder=null,this._options={fatal:!!t.fatal},Object.defineProperty(this,"encoding",{value:"utf-8"})}Pr.prototype={encode:function(t,e){t=t?String(t):"",e=Xr(e),this._streaming||(this._encoder=new ml(this._options)),this._streaming=!!e.stream;for(var n=[],s=new vs(pl(t)),i;!s.endOfStream()&&(i=this._encoder.handler(s,s.read()),i!==Dn);)Array.isArray(i)?n.push.apply(n,i):n.push(i);if(!this._streaming){for(;i=this._encoder.handler(s,s.read()),i!==Dn;)Array.isArray(i)?n.push.apply(n,i):n.push(i);this._encoder=null}return new Uint8Array(n)}};function _l(r){var t=r.fatal,e=0,n=0,s=0,i=128,o=191;this.handler=function(c,d){if(d===kr&&s!==0)return s=0,ki(t);if(d===kr)return Dn;if(s===0){if(Ke(d,0,127))return d;if(Ke(d,194,223))s=1,e=d-192;else if(Ke(d,224,239))d===224&&(i=160),d===237&&(o=159),s=2,e=d-224;else if(Ke(d,240,244))d===240&&(i=144),d===244&&(o=143),s=3,e=d-240;else return ki(t);return e=e<<6*s,null}if(!Ke(d,i,o))return e=s=n=0,i=128,o=191,c.prepend(d),ki(t);if(i=128,o=191,n+=1,e+=d-128<<6*(s-n),n!==s)return null;var _=e;return e=s=n=0,_}}function ml(r){r.fatal,this.handler=function(t,e){if(e===kr)return Dn;if(Ke(e,0,127))return e;var n,s;Ke(e,128,2047)?(n=1,s=192):Ke(e,2048,65535)?(n=2,s=224):Ke(e,65536,1114111)&&(n=3,s=240);for(var i=[(e>>6*n)+s];n>0;){var o=e>>6*(n-1);i.push(128|o&63),n-=1}return i}}const yl=Object.freeze(Object.defineProperty({__proto__:null,TextDecoder:Dr,TextEncoder:Pr},Symbol.toStringTag,{value:"Module"})),wl=hs(yl);var Ro;function El(){if(Ro)return It;Ro=1;var r=It&&It.__createBinding||(Object.create?(function(k,D,V,K){K===void 0&&(K=V),Object.defineProperty(k,K,{enumerable:!0,get:function(){return D[V]}})}):(function(k,D,V,K){K===void 0&&(K=V),k[K]=D[V]})),t=It&&It.__setModuleDefault||(Object.create?(function(k,D){Object.defineProperty(k,"default",{enumerable:!0,value:D})}):function(k,D){k.default=D}),e=It&&It.__decorate||function(k,D,V,K){var m=arguments.length,a=m<3?D:K===null?K=Object.getOwnPropertyDescriptor(D,V):K,h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(k,D,V,K);else for(var g=k.length-1;g>=0;g--)(h=k[g])&&(a=(m<3?h(a):m>3?h(D,V,a):h(D,V))||a);return m>3&&a&&Object.defineProperty(D,V,a),a},n=It&&It.__importStar||function(k){if(k&&k.__esModule)return k;var D={};if(k!=null)for(var V in k)V!=="default"&&Object.hasOwnProperty.call(k,V)&&r(D,k,V);return t(D,k),D},s=It&&It.__importDefault||function(k){return k&&k.__esModule?k:{default:k}};Object.defineProperty(It,"__esModule",{value:!0}),It.deserializeUnchecked=It.deserialize=It.serialize=It.BinaryReader=It.BinaryWriter=It.BorshError=It.baseDecode=It.baseEncode=void 0;const i=s(Ba()),o=s(Ca()),c=n(wl),d=typeof TextDecoder!="function"?c.TextDecoder:TextDecoder,_=new d("utf-8",{fatal:!0});function b(k){return typeof k=="string"&&(k=Buffer.from(k,"utf8")),o.default.encode(Buffer.from(k))}It.baseEncode=b;function O(k){return Buffer.from(o.default.decode(k))}It.baseDecode=O;const x=1024;class S extends Error{constructor(D){super(D),this.fieldPath=[],this.originalMessage=D}addToFieldPath(D){this.fieldPath.splice(0,0,D),this.message=this.originalMessage+": "+this.fieldPath.join(".")}}It.BorshError=S;class T{constructor(){this.buf=Buffer.alloc(x),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Buffer.concat([this.buf,Buffer.alloc(x)]))}writeU8(D){this.maybeResize(),this.buf.writeUInt8(D,this.length),this.length+=1}writeU16(D){this.maybeResize(),this.buf.writeUInt16LE(D,this.length),this.length+=2}writeU32(D){this.maybeResize(),this.buf.writeUInt32LE(D,this.length),this.length+=4}writeU64(D){this.maybeResize(),this.writeBuffer(Buffer.from(new i.default(D).toArray("le",8)))}writeU128(D){this.maybeResize(),this.writeBuffer(Buffer.from(new i.default(D).toArray("le",16)))}writeU256(D){this.maybeResize(),this.writeBuffer(Buffer.from(new i.default(D).toArray("le",32)))}writeU512(D){this.maybeResize(),this.writeBuffer(Buffer.from(new i.default(D).toArray("le",64)))}writeBuffer(D){this.buf=Buffer.concat([Buffer.from(this.buf.subarray(0,this.length)),D,Buffer.alloc(x)]),this.length+=D.length}writeString(D){this.maybeResize();const V=Buffer.from(D,"utf8");this.writeU32(V.length),this.writeBuffer(V)}writeFixedArray(D){this.writeBuffer(Buffer.from(D))}writeArray(D,V){this.maybeResize(),this.writeU32(D.length);for(const K of D)this.maybeResize(),V(K)}toArray(){return this.buf.subarray(0,this.length)}}It.BinaryWriter=T;function C(k,D,V){const K=V.value;V.value=function(...m){try{return K.apply(this,m)}catch(a){if(a instanceof RangeError){const h=a.code;if(["ERR_BUFFER_OUT_OF_BOUNDS","ERR_OUT_OF_RANGE"].indexOf(h)>=0)throw new S("Reached the end of buffer when deserializing")}throw a}}}class M{constructor(D){this.buf=D,this.offset=0}readU8(){const D=this.buf.readUInt8(this.offset);return this.offset+=1,D}readU16(){const D=this.buf.readUInt16LE(this.offset);return this.offset+=2,D}readU32(){const D=this.buf.readUInt32LE(this.offset);return this.offset+=4,D}readU64(){const D=this.readBuffer(8);return new i.default(D,"le")}readU128(){const D=this.readBuffer(16);return new i.default(D,"le")}readU256(){const D=this.readBuffer(32);return new i.default(D,"le")}readU512(){const D=this.readBuffer(64);return new i.default(D,"le")}readBuffer(D){if(this.offset+D>this.buf.length)throw new S(`Expected buffer length ${D} isn't within bounds`);const V=this.buf.slice(this.offset,this.offset+D);return this.offset+=D,V}readString(){const D=this.readU32(),V=this.readBuffer(D);try{return _.decode(V)}catch(K){throw new S(`Error decoding UTF-8 string: ${K}`)}}readFixedArray(D){return new Uint8Array(this.readBuffer(D))}readArray(D){const V=this.readU32(),K=Array();for(let m=0;m<V;++m)K.push(D());return K}}e([C],M.prototype,"readU8",null),e([C],M.prototype,"readU16",null),e([C],M.prototype,"readU32",null),e([C],M.prototype,"readU64",null),e([C],M.prototype,"readU128",null),e([C],M.prototype,"readU256",null),e([C],M.prototype,"readU512",null),e([C],M.prototype,"readString",null),e([C],M.prototype,"readFixedArray",null),e([C],M.prototype,"readArray",null),It.BinaryReader=M;function P(k){return k.charAt(0).toUpperCase()+k.slice(1)}function W(k,D,V,K,m){try{if(typeof K=="string")m[`write${P(K)}`](V);else if(K instanceof Array)if(typeof K[0]=="number"){if(V.length!==K[0])throw new S(`Expecting byte array of length ${K[0]}, but got ${V.length} bytes`);m.writeFixedArray(V)}else if(K.length===2&&typeof K[1]=="number"){if(V.length!==K[1])throw new S(`Expecting byte array of length ${K[1]}, but got ${V.length} bytes`);for(let a=0;a<K[1];a++)W(k,null,V[a],K[0],m)}else m.writeArray(V,a=>{W(k,D,a,K[0],m)});else if(K.kind!==void 0)switch(K.kind){case"option":{V==null?m.writeU8(0):(m.writeU8(1),W(k,D,V,K.type,m));break}case"map":{m.writeU32(V.size),V.forEach((a,h)=>{W(k,D,h,K.key,m),W(k,D,a,K.value,m)});break}default:throw new S(`FieldType ${K} unrecognized`)}else z(k,V,m)}catch(a){throw a instanceof S&&a.addToFieldPath(D),a}}function z(k,D,V){if(typeof D.borshSerialize=="function"){D.borshSerialize(V);return}const K=k.get(D.constructor);if(!K)throw new S(`Class ${D.constructor.name} is missing in schema`);if(K.kind==="struct")K.fields.map(([m,a])=>{W(k,m,D[m],a,V)});else if(K.kind==="enum"){const m=D[K.field];for(let a=0;a<K.values.length;++a){const[h,g]=K.values[a];if(h===m){V.writeU8(a),W(k,h,D[h],g,V);break}}}else throw new S(`Unexpected schema kind: ${K.kind} for ${D.constructor.name}`)}function Q(k,D,V=T){const K=new V;return z(k,D,K),K.toArray()}It.serialize=Q;function Z(k,D,V,K){try{if(typeof V=="string")return K[`read${P(V)}`]();if(V instanceof Array){if(typeof V[0]=="number")return K.readFixedArray(V[0]);if(typeof V[1]=="number"){const m=[];for(let a=0;a<V[1];a++)m.push(Z(k,null,V[0],K));return m}else return K.readArray(()=>Z(k,D,V[0],K))}if(V.kind==="option")return K.readU8()?Z(k,D,V.type,K):void 0;if(V.kind==="map"){let m=new Map;const a=K.readU32();for(let h=0;h<a;h++){const g=Z(k,D,V.key,K),R=Z(k,D,V.value,K);m.set(g,R)}return m}return st(k,V,K)}catch(m){throw m instanceof S&&m.addToFieldPath(D),m}}function st(k,D,V){if(typeof D.borshDeserialize=="function")return D.borshDeserialize(V);const K=k.get(D);if(!K)throw new S(`Class ${D.name} is missing in schema`);if(K.kind==="struct"){const m={};for(const[a,h]of k.get(D).fields)m[a]=Z(k,a,h,V);return new D(m)}if(K.kind==="enum"){const m=V.readU8();if(m>=K.values.length)throw new S(`Enum index: ${m} is out of range`);const[a,h]=K.values[m],g=Z(k,a,h,V);return new D({[a]:g})}throw new S(`Unexpected schema kind: ${K.kind} for ${D.constructor.name}`)}function pt(k,D,V,K=M){const m=new K(V),a=st(k,D,m);if(m.offset<V.length)throw new S(`Unexpected ${V.length-m.offset} bytes after deserialized data`);return a}It.deserialize=pt;function ct(k,D,V,K=M){const m=new K(V);return st(k,D,m)}return It.deserializeUnchecked=ct,It}var Ui=El(),G={},bo;function Rl(){if(bo)return G;bo=1,Object.defineProperty(G,"__esModule",{value:!0}),G.s16=G.s8=G.nu64be=G.u48be=G.u40be=G.u32be=G.u24be=G.u16be=G.nu64=G.u48=G.u40=G.u32=G.u24=G.u16=G.u8=G.offset=G.greedy=G.Constant=G.UTF8=G.CString=G.Blob=G.Boolean=G.BitField=G.BitStructure=G.VariantLayout=G.Union=G.UnionLayoutDiscriminator=G.UnionDiscriminator=G.Structure=G.Sequence=G.DoubleBE=G.Double=G.FloatBE=G.Float=G.NearInt64BE=G.NearInt64=G.NearUInt64BE=G.NearUInt64=G.IntBE=G.Int=G.UIntBE=G.UInt=G.OffsetLayout=G.GreedyCount=G.ExternalLayout=G.bindConstructorLayout=G.nameWithProperty=G.Layout=G.uint8ArrayToBuffer=G.checkUint8Array=void 0,G.constant=G.utf8=G.cstr=G.blob=G.unionLayoutDiscriminator=G.union=G.seq=G.bits=G.struct=G.f64be=G.f64=G.f32be=G.f32=G.ns64be=G.s48be=G.s40be=G.s32be=G.s24be=G.s16be=G.ns64=G.s48=G.s40=G.s32=G.s24=void 0;const r=ys();function t(u){if(!(u instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}G.checkUint8Array=t;function e(u){return t(u),r.Buffer.from(u.buffer,u.byteOffset,u.length)}G.uint8ArrayToBuffer=e;let n=class{constructor(l,w){if(!Number.isInteger(l))throw new TypeError("span must be an integer");this.span=l,this.property=w}makeDestinationObject(){return{}}getSpan(l,w){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(l){const w=Object.create(this.constructor.prototype);return Object.assign(w,this),w.property=l,w}fromArray(l){}};G.Layout=n;function s(u,l){return l.property?u+"["+l.property+"]":u}G.nameWithProperty=s;function i(u,l){if(typeof u!="function")throw new TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(u,"layout_"))throw new Error("Class is already bound to a layout");if(!(l&&l instanceof n))throw new TypeError("layout must be a Layout");if(Object.prototype.hasOwnProperty.call(l,"boundConstructor_"))throw new Error("layout is already bound to a constructor");u.layout_=l,l.boundConstructor_=u,l.makeDestinationObject=(()=>new u),Object.defineProperty(u.prototype,"encode",{value(w,I){return l.encode(this,w,I)},writable:!0}),Object.defineProperty(u,"decode",{value(w,I){return l.decode(w,I)},writable:!0})}G.bindConstructorLayout=i;class o extends n{isCount(){throw new Error("ExternalLayout is abstract")}}G.ExternalLayout=o;class c extends o{constructor(l=1,w){if(!Number.isInteger(l)||0>=l)throw new TypeError("elementSpan must be a (positive) integer");super(-1,w),this.elementSpan=l}isCount(){return!0}decode(l,w=0){t(l);const I=l.length-w;return Math.floor(I/this.elementSpan)}encode(l,w,I){return 0}}G.GreedyCount=c;class d extends o{constructor(l,w=0,I){if(!(l instanceof n))throw new TypeError("layout must be a Layout");if(!Number.isInteger(w))throw new TypeError("offset must be integer or undefined");super(l.span,I||l.property),this.layout=l,this.offset=w}isCount(){return this.layout instanceof _||this.layout instanceof b}decode(l,w=0){return this.layout.decode(l,w+this.offset)}encode(l,w,I=0){return this.layout.encode(l,w,I+this.offset)}}G.OffsetLayout=d;class _ extends n{constructor(l,w){if(super(l,w),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(l,w=0){return e(l).readUIntLE(w,this.span)}encode(l,w,I=0){return e(w).writeUIntLE(l,I,this.span),this.span}}G.UInt=_;class b extends n{constructor(l,w){if(super(l,w),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(l,w=0){return e(l).readUIntBE(w,this.span)}encode(l,w,I=0){return e(w).writeUIntBE(l,I,this.span),this.span}}G.UIntBE=b;class O extends n{constructor(l,w){if(super(l,w),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(l,w=0){return e(l).readIntLE(w,this.span)}encode(l,w,I=0){return e(w).writeIntLE(l,I,this.span),this.span}}G.Int=O;class x extends n{constructor(l,w){if(super(l,w),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(l,w=0){return e(l).readIntBE(w,this.span)}encode(l,w,I=0){return e(w).writeIntBE(l,I,this.span),this.span}}G.IntBE=x;const S=Math.pow(2,32);function T(u){const l=Math.floor(u/S),w=u-l*S;return{hi32:l,lo32:w}}function C(u,l){return u*S+l}class M extends n{constructor(l){super(8,l)}decode(l,w=0){const I=e(l),F=I.readUInt32LE(w),X=I.readUInt32LE(w+4);return C(X,F)}encode(l,w,I=0){const F=T(l),X=e(w);return X.writeUInt32LE(F.lo32,I),X.writeUInt32LE(F.hi32,I+4),8}}G.NearUInt64=M;class P extends n{constructor(l){super(8,l)}decode(l,w=0){const I=e(l),F=I.readUInt32BE(w),X=I.readUInt32BE(w+4);return C(F,X)}encode(l,w,I=0){const F=T(l),X=e(w);return X.writeUInt32BE(F.hi32,I),X.writeUInt32BE(F.lo32,I+4),8}}G.NearUInt64BE=P;class W extends n{constructor(l){super(8,l)}decode(l,w=0){const I=e(l),F=I.readUInt32LE(w),X=I.readInt32LE(w+4);return C(X,F)}encode(l,w,I=0){const F=T(l),X=e(w);return X.writeUInt32LE(F.lo32,I),X.writeInt32LE(F.hi32,I+4),8}}G.NearInt64=W;class z extends n{constructor(l){super(8,l)}decode(l,w=0){const I=e(l),F=I.readInt32BE(w),X=I.readUInt32BE(w+4);return C(F,X)}encode(l,w,I=0){const F=T(l),X=e(w);return X.writeInt32BE(F.hi32,I),X.writeUInt32BE(F.lo32,I+4),8}}G.NearInt64BE=z;class Q extends n{constructor(l){super(4,l)}decode(l,w=0){return e(l).readFloatLE(w)}encode(l,w,I=0){return e(w).writeFloatLE(l,I),4}}G.Float=Q;class Z extends n{constructor(l){super(4,l)}decode(l,w=0){return e(l).readFloatBE(w)}encode(l,w,I=0){return e(w).writeFloatBE(l,I),4}}G.FloatBE=Z;class st extends n{constructor(l){super(8,l)}decode(l,w=0){return e(l).readDoubleLE(w)}encode(l,w,I=0){return e(w).writeDoubleLE(l,I),8}}G.Double=st;class pt extends n{constructor(l){super(8,l)}decode(l,w=0){return e(l).readDoubleBE(w)}encode(l,w,I=0){return e(w).writeDoubleBE(l,I),8}}G.DoubleBE=pt;class ct extends n{constructor(l,w,I){if(!(l instanceof n))throw new TypeError("elementLayout must be a Layout");if(!(w instanceof o&&w.isCount()||Number.isInteger(w)&&0<=w))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let F=-1;!(w instanceof o)&&0<l.span&&(F=w*l.span),super(F,I),this.elementLayout=l,this.count=w}getSpan(l,w=0){if(0<=this.span)return this.span;let I=0,F=this.count;if(F instanceof o&&(F=F.decode(l,w)),0<this.elementLayout.span)I=F*this.elementLayout.span;else{let X=0;for(;X<F;)I+=this.elementLayout.getSpan(l,w+I),++X}return I}decode(l,w=0){const I=[];let F=0,X=this.count;for(X instanceof o&&(X=X.decode(l,w));F<X;)I.push(this.elementLayout.decode(l,w)),w+=this.elementLayout.getSpan(l,w),F+=1;return I}encode(l,w,I=0){const F=this.elementLayout,X=l.reduce((et,it)=>et+F.encode(it,w,I+et),0);return this.count instanceof o&&this.count.encode(l.length,w,I),X}}G.Sequence=ct;class k extends n{constructor(l,w,I){if(!(Array.isArray(l)&&l.reduce((X,et)=>X&&et instanceof n,!0)))throw new TypeError("fields must be array of Layout instances");typeof w=="boolean"&&I===void 0&&(I=w,w=void 0);for(const X of l)if(0>X.span&&X.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let F=-1;try{F=l.reduce((X,et)=>X+et.getSpan(),0)}catch(X){}super(F,w),this.fields=l,this.decodePrefixes=!!I}getSpan(l,w=0){if(0<=this.span)return this.span;let I=0;try{I=this.fields.reduce((F,X)=>{const et=X.getSpan(l,w);return w+=et,F+et},0)}catch(F){throw new RangeError("indeterminate span")}return I}decode(l,w=0){t(l);const I=this.makeDestinationObject();for(const F of this.fields)if(F.property!==void 0&&(I[F.property]=F.decode(l,w)),w+=F.getSpan(l,w),this.decodePrefixes&&l.length===w)break;return I}encode(l,w,I=0){const F=I;let X=0,et=0;for(const it of this.fields){let St=it.span;if(et=0<St?St:0,it.property!==void 0){const vt=l[it.property];vt!==void 0&&(et=it.encode(vt,w,I),0>St&&(St=it.getSpan(w,I)))}X=I,I+=St}return X+et-F}fromArray(l){const w=this.makeDestinationObject();for(const I of this.fields)I.property!==void 0&&0<l.length&&(w[I.property]=l.shift());return w}layoutFor(l){if(typeof l!="string")throw new TypeError("property must be string");for(const w of this.fields)if(w.property===l)return w}offsetOf(l){if(typeof l!="string")throw new TypeError("property must be string");let w=0;for(const I of this.fields){if(I.property===l)return w;0>I.span?w=-1:0<=w&&(w+=I.span)}}}G.Structure=k;class D{constructor(l){this.property=l}decode(l,w){throw new Error("UnionDiscriminator is abstract")}encode(l,w,I){throw new Error("UnionDiscriminator is abstract")}}G.UnionDiscriminator=D;class V extends D{constructor(l,w){if(!(l instanceof o&&l.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(w||l.property||"variant"),this.layout=l}decode(l,w){return this.layout.decode(l,w)}encode(l,w,I){return this.layout.encode(l,w,I)}}G.UnionLayoutDiscriminator=V;class K extends n{constructor(l,w,I){let F;if(l instanceof _||l instanceof b)F=new V(new d(l));else if(l instanceof o&&l.isCount())F=new V(l);else if(l instanceof D)F=l;else throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(w===void 0&&(w=null),!(w===null||w instanceof n))throw new TypeError("defaultLayout must be null or a Layout");if(w!==null){if(0>w.span)throw new Error("defaultLayout must have constant span");w.property===void 0&&(w=w.replicate("content"))}let X=-1;w&&(X=w.span,0<=X&&(l instanceof _||l instanceof b)&&(X+=F.layout.span)),super(X,I),this.discriminator=F,this.usesPrefixDiscriminator=l instanceof _||l instanceof b,this.defaultLayout=w,this.registry={};let et=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(it){return et(it)},this.configGetSourceVariant=function(it){et=it.bind(this)}}getSpan(l,w=0){if(0<=this.span)return this.span;const I=this.getVariant(l,w);if(!I)throw new Error("unable to determine span for unrecognized variant");return I.getSpan(l,w)}defaultGetSourceVariant(l){if(Object.prototype.hasOwnProperty.call(l,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(l,this.defaultLayout.property))return;const w=this.registry[l[this.discriminator.property]];if(w&&(!w.layout||w.property&&Object.prototype.hasOwnProperty.call(l,w.property)))return w}else for(const w in this.registry){const I=this.registry[w];if(I.property&&Object.prototype.hasOwnProperty.call(l,I.property))return I}throw new Error("unable to infer src variant")}decode(l,w=0){let I;const F=this.discriminator,X=F.decode(l,w),et=this.registry[X];if(et===void 0){const it=this.defaultLayout;let St=0;this.usesPrefixDiscriminator&&(St=F.layout.span),I=this.makeDestinationObject(),I[F.property]=X,I[it.property]=it.decode(l,w+St)}else I=et.decode(l,w);return I}encode(l,w,I=0){const F=this.getSourceVariant(l);if(F===void 0){const X=this.discriminator,et=this.defaultLayout;let it=0;return this.usesPrefixDiscriminator&&(it=X.layout.span),X.encode(l[X.property],w,I),it+et.encode(l[et.property],w,I+it)}return F.encode(l,w,I)}addVariant(l,w,I){const F=new m(this,l,w,I);return this.registry[l]=F,F}getVariant(l,w=0){let I;return l instanceof Uint8Array?I=this.discriminator.decode(l,w):I=l,this.registry[I]}}G.Union=K;class m extends n{constructor(l,w,I,F){if(!(l instanceof K))throw new TypeError("union must be a Union");if(!Number.isInteger(w)||0>w)throw new TypeError("variant must be a (non-negative) integer");if(typeof I=="string"&&F===void 0&&(F=I,I=null),I){if(!(I instanceof n))throw new TypeError("layout must be a Layout");if(l.defaultLayout!==null&&0<=I.span&&I.span>l.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if(typeof F!="string")throw new TypeError("variant must have a String property")}let X=l.span;0>l.span&&(X=I?I.span:0,0<=X&&l.usesPrefixDiscriminator&&(X+=l.discriminator.layout.span)),super(X,F),this.union=l,this.variant=w,this.layout=I||null}getSpan(l,w=0){if(0<=this.span)return this.span;let I=0;this.union.usesPrefixDiscriminator&&(I=this.union.discriminator.layout.span);let F=0;return this.layout&&(F=this.layout.getSpan(l,w+I)),I+F}decode(l,w=0){const I=this.makeDestinationObject();if(this!==this.union.getVariant(l,w))throw new Error("variant mismatch");let F=0;return this.union.usesPrefixDiscriminator&&(F=this.union.discriminator.layout.span),this.layout?I[this.property]=this.layout.decode(l,w+F):this.property?I[this.property]=!0:this.union.usesPrefixDiscriminator&&(I[this.union.discriminator.property]=this.variant),I}encode(l,w,I=0){let F=0;if(this.union.usesPrefixDiscriminator&&(F=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(l,this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,w,I);let X=F;if(this.layout&&(this.layout.encode(l[this.property],w,I+F),X+=this.layout.getSpan(w,I+F),0<=this.union.span&&X>this.union.span))throw new Error("encoded variant overruns containing union");return X}fromArray(l){if(this.layout)return this.layout.fromArray(l)}}G.VariantLayout=m;function a(u){return 0>u&&(u+=4294967296),u}class h extends n{constructor(l,w,I){if(!(l instanceof _||l instanceof b))throw new TypeError("word must be a UInt or UIntBE layout");if(typeof w=="string"&&I===void 0&&(I=w,w=!1),4<l.span)throw new RangeError("word cannot exceed 32 bits");super(l.span,I),this.word=l,this.msb=!!w,this.fields=[];let F=0;this._packedSetValue=function(X){return F=a(X),this},this._packedGetValue=function(){return F}}decode(l,w=0){const I=this.makeDestinationObject(),F=this.word.decode(l,w);this._packedSetValue(F);for(const X of this.fields)X.property!==void 0&&(I[X.property]=X.decode(l));return I}encode(l,w,I=0){const F=this.word.decode(w,I);this._packedSetValue(F);for(const X of this.fields)if(X.property!==void 0){const et=l[X.property];et!==void 0&&X.encode(et)}return this.word.encode(this._packedGetValue(),w,I)}addField(l,w){const I=new g(this,l,w);return this.fields.push(I),I}addBoolean(l){const w=new R(this,l);return this.fields.push(w),w}fieldFor(l){if(typeof l!="string")throw new TypeError("property must be string");for(const w of this.fields)if(w.property===l)return w}}G.BitStructure=h;class g{constructor(l,w,I){if(!(l instanceof h))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(w)||0>=w)throw new TypeError("bits must be positive integer");const F=8*l.span,X=l.fields.reduce((et,it)=>et+it.bits,0);if(w+X>F)throw new Error("bits too long for span remainder ("+(F-X)+" of "+F+" remain)");this.container=l,this.bits=w,this.valueMask=(1<<w)-1,w===32&&(this.valueMask=4294967295),this.start=X,this.container.msb&&(this.start=F-X-w),this.wordMask=a(this.valueMask<<this.start),this.property=I}decode(l,w){const I=this.container._packedGetValue();return a(I&this.wordMask)>>>this.start}encode(l){if(typeof l!="number"||!Number.isInteger(l)||l!==a(l&this.valueMask))throw new TypeError(s("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const w=this.container._packedGetValue(),I=a(l<<this.start);this.container._packedSetValue(a(w&~this.wordMask)|I)}}G.BitField=g;class R extends g{constructor(l,w){super(l,1,w)}decode(l,w){return!!super.decode(l,w)}encode(l){typeof l=="boolean"&&(l=+l),super.encode(l)}}G.Boolean=R;class v extends n{constructor(l,w){if(!(l instanceof o&&l.isCount()||Number.isInteger(l)&&0<=l))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let I=-1;l instanceof o||(I=l),super(I,w),this.length=l}getSpan(l,w){let I=this.span;return 0>I&&(I=this.length.decode(l,w)),I}decode(l,w=0){let I=this.span;return 0>I&&(I=this.length.decode(l,w)),e(l).slice(w,w+I)}encode(l,w,I){let F=this.length;if(this.length instanceof o&&(F=l.length),!(l instanceof Uint8Array&&F===l.length))throw new TypeError(s("Blob.encode",this)+" requires (length "+F+") Uint8Array as src");if(I+F>w.length)throw new RangeError("encoding overruns Uint8Array");const X=e(l);return e(w).write(X.toString("hex"),I,F,"hex"),this.length instanceof o&&this.length.encode(F,w,I),F}}G.Blob=v;class N extends n{constructor(l){super(-1,l)}getSpan(l,w=0){t(l);let I=w;for(;I<l.length&&l[I]!==0;)I+=1;return 1+I-w}decode(l,w=0){const I=this.getSpan(l,w);return e(l).slice(w,w+I-1).toString("utf-8")}encode(l,w,I=0){typeof l!="string"&&(l=String(l));const F=r.Buffer.from(l,"utf8"),X=F.length;if(I+X>w.length)throw new RangeError("encoding overruns Buffer");const et=e(w);return F.copy(et,I),et[I+X]=0,X+1}}G.CString=N;class L extends n{constructor(l,w){if(typeof l=="string"&&w===void 0&&(w=l,l=void 0),l===void 0)l=-1;else if(!Number.isInteger(l))throw new TypeError("maxSpan must be an integer");super(-1,w),this.maxSpan=l}getSpan(l,w=0){return t(l),l.length-w}decode(l,w=0){const I=this.getSpan(l,w);if(0<=this.maxSpan&&this.maxSpan<I)throw new RangeError("text length exceeds maxSpan");return e(l).slice(w,w+I).toString("utf-8")}encode(l,w,I=0){typeof l!="string"&&(l=String(l));const F=r.Buffer.from(l,"utf8"),X=F.length;if(0<=this.maxSpan&&this.maxSpan<X)throw new RangeError("text length exceeds maxSpan");if(I+X>w.length)throw new RangeError("encoding overruns Buffer");return F.copy(e(w),I),X}}G.UTF8=L;class E extends n{constructor(l,w){super(0,w),this.value=l}decode(l,w){return this.value}encode(l,w,I){return 0}}return G.Constant=E,G.greedy=((u,l)=>new c(u,l)),G.offset=((u,l,w)=>new d(u,l,w)),G.u8=(u=>new _(1,u)),G.u16=(u=>new _(2,u)),G.u24=(u=>new _(3,u)),G.u32=(u=>new _(4,u)),G.u40=(u=>new _(5,u)),G.u48=(u=>new _(6,u)),G.nu64=(u=>new M(u)),G.u16be=(u=>new b(2,u)),G.u24be=(u=>new b(3,u)),G.u32be=(u=>new b(4,u)),G.u40be=(u=>new b(5,u)),G.u48be=(u=>new b(6,u)),G.nu64be=(u=>new P(u)),G.s8=(u=>new O(1,u)),G.s16=(u=>new O(2,u)),G.s24=(u=>new O(3,u)),G.s32=(u=>new O(4,u)),G.s40=(u=>new O(5,u)),G.s48=(u=>new O(6,u)),G.ns64=(u=>new W(u)),G.s16be=(u=>new x(2,u)),G.s24be=(u=>new x(3,u)),G.s32be=(u=>new x(4,u)),G.s40be=(u=>new x(5,u)),G.s48be=(u=>new x(6,u)),G.ns64be=(u=>new z(u)),G.f32=(u=>new Q(u)),G.f32be=(u=>new Z(u)),G.f64=(u=>new st(u)),G.f64be=(u=>new pt(u)),G.struct=((u,l,w)=>new k(u,l,w)),G.bits=((u,l,w)=>new h(u,l,w)),G.seq=((u,l,w)=>new ct(u,l,w)),G.union=((u,l,w)=>new K(u,l,w)),G.unionLayoutDiscriminator=((u,l)=>new V(u,l)),G.blob=((u,l)=>new v(u,l)),G.cstr=(u=>new N(u)),G.utf8=((u,l)=>new L(u,l)),G.constant=((u,l)=>new E(u,l)),G}var B=Rl(),bl=1,Al=2,Sl=3,vl=4,Il=5,Ol=6,xl=7,Nl=8,Tl=9,Bl=10,Cl=-32700,Ll=-32603,Ml=-32602,kl=-32601,Ul=-32600,Dl=-32016,Pl=-32015,Fl=-32014,ql=-32013,$l=-32012,zl=-32011,Vl=-32010,Gl=-32009,Kl=-32008,Hl=-32007,Wl=-32006,jl=-32005,Xl=-32004,Yl=-32003,Zl=-32002,Jl=-32001,Ql=28e5,tf=2800001,ef=2800002,nf=2800003,rf=2800004,sf=2800005,of=2800006,af=2800007,cf=2800008,uf=2800009,lf=2800010,ff=2800011,hf=323e4,df=32300001,pf=3230002,gf=3230003,_f=3230004,mf=361e4,yf=3610001,wf=3610002,Ef=3610003,Rf=3610004,bf=3610005,Af=3610006,Sf=3610007,vf=3611e3,If=3704e3,Of=3704001,xf=3704002,Nf=3704003,Tf=3704004,Bf=4128e3,Cf=4128001,Lf=4128002,Mf=4615e3,kf=4615001,Uf=4615002,Df=4615003,Pf=4615004,Ff=4615005,qf=4615006,$f=4615007,zf=4615008,Vf=4615009,Gf=4615010,Kf=4615011,Hf=4615012,Wf=4615013,jf=4615014,Xf=4615015,Yf=4615016,Zf=4615017,Jf=4615018,Qf=4615019,th=4615020,eh=4615021,nh=4615022,rh=4615023,ih=4615024,sh=4615025,oh=4615026,ah=4615027,ch=4615028,uh=4615029,lh=4615030,fh=4615031,hh=4615032,dh=4615033,ph=4615034,gh=4615035,_h=4615036,mh=4615037,yh=4615038,wh=4615039,Eh=4615040,Rh=4615041,bh=4615042,Ah=4615043,Sh=4615044,vh=4615045,Ih=4615046,Oh=4615047,xh=4615048,Nh=4615049,Th=4615050,Bh=4615051,Ch=4615052,Lh=4615053,Mh=4615054,kh=5508e3,Uh=5508001,Dh=5508002,Ph=5508003,Fh=5508004,qh=5508005,$h=5508006,zh=5508007,Vh=5508008,Gh=5508009,Kh=5508010,Hh=5508011,Wh=5663e3,jh=5663001,Xh=5663002,Yh=5663003,Zh=5663004,Jh=5663005,Qh=5663006,td=5663007,ed=5663008,nd=5663009,rd=5663010,id=5663011,sd=5663012,od=5663013,ad=5663014,cd=5663015,ud=5663016,ld=5663017,fd=5663018,hd=5663019,dd=5663020,pd=705e4,gd=7050001,_d=7050002,md=7050003,yd=7050004,wd=7050005,Ed=7050006,Rd=7050007,bd=7050008,Ad=7050009,Sd=7050010,vd=7050011,Id=7050012,Od=7050013,xd=7050014,Nd=7050015,Td=7050016,Bd=7050017,Cd=7050018,Ld=7050019,Md=7050020,kd=7050021,Ud=7050022,Dd=7050023,Pd=7050024,Fd=7050025,qd=7050026,$d=7050027,zd=7050028,Vd=7050029,Gd=7050030,Kd=7050031,Hd=7050032,Wd=7050033,jd=7050034,Xd=7050035,Yd=7050036,La=8078e3,Ma=8078001,Zd=8078002,Jd=8078003,ka=8078004,Ua=8078005,Da=8078006,Qd=8078007,t0=8078008,e0=8078009,n0=8078010,Pa=8078011,r0=8078012,i0=8078013,s0=8078014,o0=8078015,a0=8078016,c0=8078017,u0=8078018,l0=8078019,f0=8078020,h0=8078021,d0=8078022,p0=81e5,g0=8100001,_0=8100002,m0=8100003,y0=819e4,w0=8190001,E0=8190002,R0=8190003,b0=8190004,A0=99e5,S0=9900001,v0=9900002,I0=9900003,O0=9900004;function Fa(r){return Array.isArray(r)?"%5B"+r.map(Fa).join("%2C%20")+"%5D":typeof r=="bigint"?`${r}n`:encodeURIComponent(String(r!=null&&Object.getPrototypeOf(r)===null?lt({},r):r))}function x0([r,t]){return`${r}=${Fa(t)}`}function N0(r){const t=Object.entries(r).map(x0).join("&");return btoa(t)}var T0={[hf]:"Account not found at address: $address",[_f]:"Not all accounts were decoded. Encoded accounts found at addresses: $addresses.",[gf]:"Expected decoded account at address: $address",[pf]:"Failed to decode account data at address: $address",[df]:"Accounts not found at addresses: $addresses",[uf]:"Unable to find a viable program address bump seed.",[ef]:"$putativeAddress is not a base58-encoded address.",[Ql]:"Expected base58 encoded address to decode to a byte array of length 32. Actual length: $actualLength.",[nf]:"The `CryptoKey` must be an `Ed25519` public key.",[ff]:"$putativeOffCurveAddress is not a base58-encoded off-curve address.",[cf]:"Invalid seeds; point must fall off the Ed25519 curve.",[rf]:"Expected given program derived address to have the following format: [Address, ProgramDerivedAddressBump].",[of]:"A maximum of $maxSeeds seeds, including the bump seed, may be supplied when creating an address. Received: $actual.",[af]:"The seed at index $index with length $actual exceeds the maximum length of $maxSeedLength bytes.",[sf]:"Expected program derived address bump to be in the range [0, 255], got: $bump.",[lf]:"Program address cannot end with PDA marker.",[tf]:"Expected base58-encoded address string of length in the range [32, 44]. Actual length: $actualLength.",[vl]:"Expected base58-encoded blockash string of length in the range [32, 44]. Actual length: $actualLength.",[bl]:"The network has progressed past the last block for which this transaction could have been committed.",[La]:"Codec [$codecDescription] cannot decode empty byte arrays.",[d0]:"Enum codec cannot use lexical values [$stringValues] as discriminators. Either remove all lexical values or set `useValuesAsDiscriminators` to `false`.",[f0]:"Sentinel [$hexSentinel] must not be present in encoded bytes [$hexEncodedBytes].",[Ua]:"Encoder and decoder must have the same fixed size, got [$encoderFixedSize] and [$decoderFixedSize].",[Da]:"Encoder and decoder must have the same max size, got [$encoderMaxSize] and [$decoderMaxSize].",[ka]:"Encoder and decoder must either both be fixed-size or variable-size.",[t0]:"Enum discriminator out of range. Expected a number in [$formattedValidDiscriminators], got $discriminator.",[Zd]:"Expected a fixed-size codec, got a variable-size one.",[i0]:"Codec [$codecDescription] expected a positive byte length, got $bytesLength.",[Jd]:"Expected a variable-size codec, got a fixed-size one.",[l0]:"Codec [$codecDescription] expected zero-value [$hexZeroValue] to have the same size as the provided fixed-size item [$expectedSize bytes].",[Ma]:"Codec [$codecDescription] expected $expected bytes, got $bytesLength.",[u0]:"Expected byte array constant [$hexConstant] to be present in data [$hexData] at offset [$offset].",[e0]:"Invalid discriminated union variant. Expected one of [$variants], got $value.",[n0]:"Invalid enum variant. Expected one of [$stringValues] or a number in [$formattedNumericalValues], got $variant.",[o0]:"Invalid literal union variant. Expected one of [$variants], got $value.",[Qd]:"Expected [$codecDescription] to have $expected items, got $actual.",[r0]:"Invalid value $value for base $base with alphabet $alphabet.",[a0]:"Literal union discriminator out of range. Expected a number between $minRange and $maxRange, got $discriminator.",[Pa]:"Codec [$codecDescription] expected number to be in the range [$min, $max], got $value.",[s0]:"Codec [$codecDescription] expected offset to be in the range [0, $bytesLength], got $offset.",[h0]:"Expected sentinel [$hexSentinel] to be present in decoded bytes [$hexDecodedBytes].",[c0]:"Union variant out of range. Expected an index between $minRange and $maxRange, got $variant.",[vf]:"No random values implementation could be found.",[Vf]:"instruction requires an uninitialized account",[rh]:"instruction tries to borrow reference for an account which is already borrowed",[ih]:"instruction left account with an outstanding borrowed reference",[eh]:"program other than the account's owner changed the size of the account data",[Ff]:"account data too small for instruction",[nh]:"instruction expected an executable account",[Ih]:"An account does not have enough lamports to be rent-exempt",[xh]:"Program arithmetic overflowed",[vh]:"Failed to serialize or deserialize account data: $encodedData",[Mh]:"Builtin programs must consume compute units",[hh]:"Cross-program invocation call depth too deep",[yh]:"Computational budget exceeded",[oh]:"custom program error: #$code",[Zf]:"instruction contains duplicate accounts",[sh]:"instruction modifications of multiply-passed account differ",[lh]:"executable accounts must be rent exempt",[ch]:"instruction changed executable accounts data",[uh]:"instruction changed the balance of an executable account",[Jf]:"instruction changed executable bit of an account",[jf]:"instruction modified data of an account it does not own",[Wf]:"instruction spent from the balance of an account it does not own",[kf]:"generic instruction error",[Th]:"Provided owner is not allowed",[Ah]:"Account is immutable",[Sh]:"Incorrect authority provided",[$f]:"incorrect program id for instruction",[qf]:"insufficient funds for instruction",[Pf]:"invalid account data for instruction",[Oh]:"Invalid account owner",[Uf]:"invalid program argument",[ah]:"program returned invalid error code",[Df]:"invalid instruction data",[mh]:"Failed to reallocate account data",[_h]:"Provided seeds do not result in a valid address",[Bh]:"Accounts data allocations exceeded the maximum allowed per transaction",[Ch]:"Max accounts exceeded",[Lh]:"Max instruction trace length exceeded",[gh]:"Length of the seed is too long for address generation",[dh]:"An account required by the instruction is missing",[zf]:"missing required signature for instruction",[Hf]:"instruction illegally modified the program id of an account",[th]:"insufficient account keys for instruction",[wh]:"Cross-program invocation with unauthorized signer or writable account",[Eh]:"Failed to create program execution environment",[bh]:"Program failed to compile",[Rh]:"Program failed to complete",[Yf]:"instruction modified data of a read-only account",[Xf]:"instruction changed the balance of a read-only account",[ph]:"Cross-program invocation reentrancy not allowed for this instruction",[Qf]:"instruction modified rent epoch of an account",[Kf]:"sum of account balances before and after instruction do not match",[Gf]:"instruction requires an initialized account",[Mf]:"",[fh]:"Unsupported program id",[Nh]:"Unsupported sysvar",[Bf]:"The instruction does not have any accounts.",[Cf]:"The instruction does not have any data.",[Lf]:"Expected instruction to have progress address $expectedProgramAddress, got $actualProgramAddress.",[Il]:"Expected base58 encoded blockhash to decode to a byte array of length 32. Actual length: $actualLength.",[Al]:"The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",[v0]:"Invariant violation: Found no abortable iterable cache entry for key `$cacheKey`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[O0]:"Invariant violation: This data publisher does not publish to the channel named `$channelName`. Supported channels include $supportedChannelNames.",[S0]:"Invariant violation: WebSocket message iterator state is corrupt; iterated without first resolving existing message promise. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[A0]:"Invariant violation: WebSocket message iterator is missing state storage. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[I0]:"Invariant violation: Switch statement non-exhaustive. Received unexpected value `$unexpectedValue`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[Ll]:"JSON-RPC error: Internal JSON-RPC error ($__serverMessage)",[Ml]:"JSON-RPC error: Invalid method parameter(s) ($__serverMessage)",[Ul]:"JSON-RPC error: The JSON sent is not a valid `Request` object ($__serverMessage)",[kl]:"JSON-RPC error: The method does not exist / is not available ($__serverMessage)",[Cl]:"JSON-RPC error: An error occurred on the server while parsing the JSON text ($__serverMessage)",[$l]:"$__serverMessage",[Jl]:"$__serverMessage",[Xl]:"$__serverMessage",[Fl]:"$__serverMessage",[Vl]:"$__serverMessage",[Gl]:"$__serverMessage",[Dl]:"Minimum context slot has not been reached",[jl]:"Node is unhealthy; behind by $numSlotsBehind slots",[Kl]:"No snapshot",[Zl]:"Transaction simulation failed",[Hl]:"$__serverMessage",[zl]:"Transaction history is not available from this node",[Wl]:"$__serverMessage",[ql]:"Transaction signature length mismatch",[Yl]:"Transaction signature verification failure",[Pl]:"$__serverMessage",[If]:"Key pair bytes must be of length 64, got $byteLength.",[Of]:"Expected private key bytes with length 32. Actual length: $actualLength.",[xf]:"Expected base58-encoded signature to decode to a byte array of length 64. Actual length: $actualLength.",[Tf]:"The provided private key does not match the provided public key.",[Nf]:"Expected base58-encoded signature string of length in the range [64, 88]. Actual length: $actualLength.",[Ol]:"Lamports value must be in the range [0, 2e64-1]",[xl]:"`$value` cannot be parsed as a `BigInt`",[Bl]:"$message",[Nl]:"`$value` cannot be parsed as a `Number`",[Sl]:"No nonce account could be found at address `$nonceAccountAddress`",[y0]:"The notification name must end in 'Notifications' and the API must supply a subscription plan creator function for the notification '$notificationName'.",[E0]:"WebSocket was closed before payload could be added to the send buffer",[R0]:"WebSocket connection closed",[b0]:"WebSocket failed to connect",[w0]:"Failed to obtain a subscription id from the server",[m0]:"Could not find an API plan for RPC method: `$method`",[p0]:"The $argumentLabel argument to the `$methodName` RPC method$optionalPathLabel was `$value`. This number is unsafe for use with the Solana JSON-RPC because it exceeds `Number.MAX_SAFE_INTEGER`.",[_0]:"HTTP error ($statusCode): $message",[g0]:"HTTP header(s) forbidden: $headers. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.",[kh]:"Multiple distinct signers were identified for address `$address`. Please ensure that you are using the same signer instance for each address.",[Uh]:"The provided value does not implement the `KeyPairSigner` interface",[Ph]:"The provided value does not implement the `MessageModifyingSigner` interface",[Fh]:"The provided value does not implement the `MessagePartialSigner` interface",[Dh]:"The provided value does not implement any of the `MessageSigner` interfaces",[$h]:"The provided value does not implement the `TransactionModifyingSigner` interface",[zh]:"The provided value does not implement the `TransactionPartialSigner` interface",[Vh]:"The provided value does not implement the `TransactionSendingSigner` interface",[qh]:"The provided value does not implement any of the `TransactionSigner` interfaces",[Gh]:"More than one `TransactionSendingSigner` was identified.",[Kh]:"No `TransactionSendingSigner` was identified. Please provide a valid `TransactionWithSingleSendingSigner` transaction.",[Hh]:"Wallet account signers do not support signing multiple messages/transactions in a single operation",[Sf]:"Cannot export a non-extractable key.",[yf]:"No digest implementation could be found.",[mf]:"Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts.",[wf]:`This runtime does not support the generation of Ed25519 key pairs.
|
|
84
|
+
|
|
85
|
+
Install @solana/webcrypto-ed25519-polyfill and call its \`install\` function before generating keys in environments that do not support Ed25519.
|
|
86
|
+
|
|
87
|
+
For a list of runtimes that currently support Ed25519 operations, visit https://github.com/WICG/webcrypto-secure-curves/issues/20.`,[Ef]:"No signature verification implementation could be found.",[Rf]:"No key generation implementation could be found.",[bf]:"No signing implementation could be found.",[Af]:"No key export implementation could be found.",[Tl]:"Timestamp value must be in the range [-(2n ** 63n), (2n ** 63n) - 1]. `$value` given",[Td]:"Transaction processing left an account with an outstanding borrowed reference",[gd]:"Account in use",[_d]:"Account loaded twice",[md]:"Attempt to debit an account but found no record of a prior credit.",[Dd]:"Transaction loads an address table account that doesn't exist",[Rd]:"This transaction has already been processed",[bd]:"Blockhash not found",[Ad]:"Loader call chain is too deep",[Nd]:"Transactions are currently disabled due to cluster maintenance",[Gd]:"Transaction contains a duplicate instruction ($index) that is not allowed",[wd]:"Insufficient funds for fee",[Kd]:"Transaction results in an account ($accountIndex) with insufficient funds for rent",[Ed]:"This account may not be used to pay transaction fees",[vd]:"Transaction contains an invalid account reference",[Fd]:"Transaction loads an address table account with invalid data",[qd]:"Transaction address table lookup uses an invalid index",[Pd]:"Transaction loads an address table account with an invalid owner",[Wd]:"LoadedAccountsDataSizeLimit set for transaction must be greater than 0.",[Od]:"This program may not be used for executing instructions",[$d]:"Transaction leaves an account with a lower balance than rent-exempt minimum",[Ld]:"Transaction loads a writable account that cannot be written",[Hd]:"Transaction exceeded max loaded accounts data size cap",[Sd]:"Transaction requires a fee but has no signature present",[yd]:"Attempt to load a program that does not exist",[Xd]:"Execution of the program referenced by account at index $accountIndex is temporarily restricted.",[jd]:"ResanitizationNeeded",[xd]:"Transaction failed to sanitize accounts offsets correctly",[Id]:"Transaction did not pass signature verification",[Ud]:"Transaction locked too many accounts",[Yd]:"Sum of account balances before and after transaction do not match",[pd]:"The transaction failed with the error `$errorName`",[Cd]:"Transaction version is unsupported",[kd]:"Transaction would exceed account data limit within the block",[Vd]:"Transaction would exceed total account data limit",[Md]:"Transaction would exceed max account limit within the block",[Bd]:"Transaction would exceed max Block Cost Limit",[zd]:"Transaction would exceed max Vote Cost Limit",[cd]:"Attempted to sign a transaction with an address that is not a signer for it",[rd]:"Transaction is missing an address at index: $index.",[ud]:"Transaction has no expected signers therefore it cannot be encoded",[dd]:"Transaction size $transactionSize exceeds limit of $transactionSizeLimit bytes",[Xh]:"Transaction does not have a blockhash lifetime",[Yh]:"Transaction is not a durable nonce transaction",[Jh]:"Contents of these address lookup tables unknown: $lookupTableAddresses",[Qh]:"Lookup of address at index $highestRequestedIndex failed for lookup table `$lookupTableAddress`. Highest known index is $highestKnownIndex. The lookup table may have been extended since its contents were retrieved",[ed]:"No fee payer set in CompiledTransaction",[td]:"Could not find program address at index $index",[fd]:"Failed to estimate the compute unit consumption for this transaction message. This is likely because simulating the transaction failed. Inspect the `cause` property of this error to learn more",[hd]:"Transaction failed when it was simulated in order to estimate the compute unit consumption. The compute unit estimate provided is for a transaction that failed when simulated and may not be representative of the compute units this transaction would consume if successful. Inspect the `cause` property of this error to learn more",[id]:"Transaction is missing a fee payer.",[sd]:"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer.",[ad]:"Transaction first instruction is not advance nonce account instruction.",[od]:"Transaction with no instructions cannot be durable nonce transaction.",[Wh]:"This transaction includes an address (`$programAddress`) which is both invoked and set as the fee payer. Program addresses may not pay fees",[jh]:"This transaction includes an address (`$programAddress`) which is both invoked and marked writable. Program addresses may not be writable",[ld]:"The transaction message expected the transaction to have $signerAddressesLength signatures, got $signaturesLength.",[nd]:"Transaction is missing signatures for addresses: $addresses.",[Zh]:"Transaction version must be in the range [0, 127]. `$actualVersion` given"},Ve="i",Ue="t";function B0(r,t={}){const e=T0[r];if(e.length===0)return"";let n;function s(o){if(n[Ue]===2){const c=e.slice(n[Ve]+1,o);i.push(c in t?`${t[c]}`:`$${c}`)}else n[Ue]===1&&i.push(e.slice(n[Ve],o))}const i=[];return e.split("").forEach((o,c)=>{if(c===0){n={[Ve]:0,[Ue]:e[0]==="\\"?0:e[0]==="$"?2:1};return}let d;switch(n[Ue]){case 0:d={[Ve]:c,[Ue]:1};break;case 1:o==="\\"?d={[Ve]:c,[Ue]:0}:o==="$"&&(d={[Ve]:c,[Ue]:2});break;case 2:o==="\\"?d={[Ve]:c,[Ue]:0}:o==="$"?d={[Ve]:c,[Ue]:2}:o.match(/\w/)||(d={[Ve]:c,[Ue]:1});break}d&&(n!==d&&s(c),n=d)}),s(),i.join("")}function C0(r,t={}){if(process.env.NODE_ENV!=="production")return B0(r,t);{let e=`Solana error #${r}; Decode this error by running \`npx @solana/errors decode -- ${r}`;return Object.keys(t).length&&(e+=` '${N0(t)}'`),`${e}\``}}var Cn=class extends Error{constructor(...[t,e]){let n,s;if(e){const o=e,{cause:c}=o,d=qe(o,["cause"]);c&&(s={cause:c}),Object.keys(d).length>0&&(n=d)}const i=C0(t,n);super(i,s);Mt(this,"cause",this.cause);Mt(this,"context");this.context=lt({__code:t},n),this.name="SolanaError"}};function L0(r,t){return"fixedSize"in t?t.fixedSize:t.getSizeFromValue(r)}function M0(r){return Object.freeze(yt(lt({},r),{encode:t=>{const e=new Uint8Array(L0(t,r));return r.write(t,e,0),e}}))}function k0(r){return Object.freeze(yt(lt({},r),{decode:(t,e=0)=>r.read(t,e)[0]}))}function Sn(r){return"fixedSize"in r&&typeof r.fixedSize=="number"}function U0(r,t){if(Sn(r)!==Sn(t))throw new Cn(ka);if(Sn(r)&&Sn(t)&&r.fixedSize!==t.fixedSize)throw new Cn(Ua,{decoderFixedSize:t.fixedSize,encoderFixedSize:r.fixedSize});if(!Sn(r)&&!Sn(t)&&r.maxSize!==t.maxSize)throw new Cn(Da,{decoderMaxSize:t.maxSize,encoderMaxSize:r.maxSize});return yt(lt(lt({},t),r),{decode:t.decode,encode:r.encode,read:t.read,write:r.write})}function D0(r,t,e=0){if(t.length-e<=0)throw new Cn(La,{codecDescription:r})}function P0(r,t,e,n=0){const s=e.length-n;if(s<t)throw new Cn(Ma,{bytesLength:s,codecDescription:r,expected:t})}function F0(r,t,e,n){if(n<t||n>e)throw new Cn(Pa,{codecDescription:r,max:e,min:t,value:n})}function qa(r){return(r==null?void 0:r.endian)!==1}function q0(r){return M0({fixedSize:r.size,write(t,e,n){r.range&&F0(r.name,r.range[0],r.range[1],t);const s=new ArrayBuffer(r.size);return r.set(new DataView(s),t,qa(r.config)),e.set(new Uint8Array(s),n),n+r.size}})}function $0(r){return k0({fixedSize:r.size,read(t,e=0){D0(r.name,t,e),P0(r.name,r.size,t,e);const n=new DataView(z0(t,e,r.size));return[r.get(n,qa(r.config)),e+r.size]}})}function z0(r,t,e){const n=r.byteOffset+(t!=null?t:0),s=e!=null?e:r.byteLength;return r.buffer.slice(n,n+s)}var V0=(r={})=>q0({config:r,name:"u64",range:[BigInt(0),BigInt("0xffffffffffffffff")],set:(t,e,n)=>t.setBigUint64(0,BigInt(e),n),size:8}),G0=(r={})=>$0({config:r,get:(t,e)=>t.getBigUint64(0,e),name:"u64",size:8}),K0=(r={})=>U0(V0(r),G0(r));class H0 extends TypeError{constructor(t,e){let n;const _=t,{message:s,explanation:i}=_,o=qe(_,["message","explanation"]),{path:c}=t,d=c.length===0?s:`At path: ${c.join(".")} -- ${s}`;super(i!=null?i:d),i!=null&&(this.cause=d),Object.assign(this,o),this.name=this.constructor.name,this.failures=()=>n!=null?n:n=[t,...e()]}}function W0(r){return ar(r)&&typeof r[Symbol.iterator]=="function"}function ar(r){return typeof r=="object"&&r!=null}function Fr(r){return ar(r)&&!Array.isArray(r)}function Me(r){return typeof r=="symbol"?r.toString():typeof r=="string"?JSON.stringify(r):`${r}`}function j0(r){const{done:t,value:e}=r.next();return t?void 0:e}function X0(r,t,e,n){if(r===!0)return;r===!1?r={}:typeof r=="string"&&(r={message:r});const{path:s,branch:i}=t,{type:o}=e,{refinement:c,message:d=`Expected a value of type \`${o}\`${c?` with refinement \`${c}\``:""}, but received: \`${Me(n)}\``}=r;return yt(lt({value:n,type:o,refinement:c,key:s[s.length-1],path:s,branch:i},r),{message:d})}function*Ao(r,t,e,n){W0(r)||(r=[r]);for(const s of r){const i=X0(s,t,e,n);i&&(yield i)}}function*Is(r,t,e={}){const{path:n=[],branch:s=[r],coerce:i=!1,mask:o=!1}=e,c={path:n,branch:s,mask:o};i&&(r=t.coercer(r,c));let d="valid";for(const _ of t.validator(r,c))_.explanation=e.message,d="not_valid",yield[_,void 0];for(let[_,b,O]of t.entries(r,c)){const x=Is(b,O,{path:_===void 0?n:[...n,_],branch:_===void 0?s:[...s,b],coerce:i,mask:o,message:e.message});for(const S of x)S[0]?(d=S[0].refinement!=null?"not_refined":"not_valid",yield[S[0],void 0]):i&&(b=S[1],_===void 0?r=b:r instanceof Map?r.set(_,b):r instanceof Set?r.add(b):ar(r)&&(b!==void 0||_ in r)&&(r[_]=b))}if(d!=="not_valid")for(const _ of t.refiner(r,c))_.explanation=e.message,d="not_refined",yield[_,void 0];d==="valid"&&(yield[void 0,r])}let Fe=class{constructor(t){const{type:e,schema:n,validator:s,refiner:i,coercer:o=d=>d,entries:c=function*(){}}=t;this.type=e,this.schema=n,this.entries=c,this.coercer=o,s?this.validator=(d,_)=>{const b=s(d,_);return Ao(b,_,this,d)}:this.validator=()=>[],i?this.refiner=(d,_)=>{const b=i(d,_);return Ao(b,_,this,d)}:this.refiner=()=>[]}assert(t,e){return Y0(t,this,e)}create(t,e){return tt(t,this,e)}is(t){return $a(t,this)}mask(t,e){return Z0(t,this,e)}validate(t,e={}){return cr(t,this,e)}};function Y0(r,t,e){const n=cr(r,t,{message:e});if(n[0])throw n[0]}function tt(r,t,e){const n=cr(r,t,{coerce:!0,message:e});if(n[0])throw n[0];return n[1]}function Z0(r,t,e){const n=cr(r,t,{coerce:!0,mask:!0,message:e});if(n[0])throw n[0];return n[1]}function $a(r,t){return!cr(r,t)[0]}function cr(r,t,e={}){const n=Is(r,t,e),s=j0(n);return s[0]?[new H0(s[0],function*(){for(const o of n)o[0]&&(yield o[0])}),void 0]:[void 0,s[1]]}function yn(r,t){return new Fe({type:r,schema:null,validator:t})}function J0(){return yn("any",()=>!0)}function nt(r){return new Fe({type:"array",schema:r,*entries(t){if(r&&Array.isArray(t))for(const[e,n]of t.entries())yield[e,n,r]},coercer(t){return Array.isArray(t)?t.slice():t},validator(t){return Array.isArray(t)||`Expected an array value, but received: ${Me(t)}`}})}function Pe(){return yn("boolean",r=>typeof r=="boolean")}function Os(r){return yn("instance",t=>t instanceof r||`Expected a \`${r.name}\` instance, but received: ${Me(t)}`)}function Dt(r){const t=Me(r),e=typeof r;return new Fe({type:"literal",schema:e==="string"||e==="number"||e==="boolean"?r:null,validator(n){return n===r||`Expected the literal \`${t}\`, but received: ${Me(n)}`}})}function Q0(){return yn("never",()=>!1)}function rt(r){return new Fe(yt(lt({},r),{validator:(t,e)=>t===null||r.validator(t,e),refiner:(t,e)=>t===null||r.refiner(t,e)}))}function $(){return yn("number",r=>typeof r=="number"&&!isNaN(r)||`Expected a number, but received: ${Me(r)}`)}function ut(r){return new Fe(yt(lt({},r),{validator:(t,e)=>t===void 0||r.validator(t,e),refiner:(t,e)=>t===void 0||r.refiner(t,e)}))}function za(r,t){return new Fe({type:"record",schema:null,*entries(e){if(ar(e))for(const n in e){const s=e[n];yield[n,n,r],yield[n,s,t]}},validator(e){return Fr(e)||`Expected an object, but received: ${Me(e)}`},coercer(e){return Fr(e)?lt({},e):e}})}function J(){return yn("string",r=>typeof r=="string"||`Expected a string, but received: ${Me(r)}`)}function xs(r){const t=Q0();return new Fe({type:"tuple",schema:null,*entries(e){if(Array.isArray(e)){const n=Math.max(r.length,e.length);for(let s=0;s<n;s++)yield[s,e[s],r[s]||t]}},validator(e){return Array.isArray(e)||`Expected an array, but received: ${Me(e)}`},coercer(e){return Array.isArray(e)?e.slice():e}})}function Y(r){const t=Object.keys(r);return new Fe({type:"type",schema:r,*entries(e){if(ar(e))for(const n of t)yield[n,e[n],r[n]]},validator(e){return Fr(e)||`Expected an object, but received: ${Me(e)}`},coercer(e){return Fr(e)?lt({},e):e}})}function be(r){const t=r.map(e=>e.type).join(" | ");return new Fe({type:"union",schema:null,coercer(e,n){for(const s of r){const[i,o]=s.validate(e,{coerce:!0,mask:n.mask});if(!i)return o}return e},validator(e,n){const s=[];for(const i of r){const[...o]=Is(e,i,n),[c]=o;if(c[0])for(const[d]of o)d&&s.push(d);else return[]}return[`Expected the value to satisfy a union of \`${t}\`, but received: ${Me(e)}`,...s]}})}function qn(){return yn("unknown",()=>!0)}function ur(r,t,e){return new Fe(yt(lt({},r),{coercer:(n,s)=>$a(n,t)?r.coercer(e(n,s),s):r.coercer(n,s)}))}var Er,tp=new Uint8Array(16);function Va(){if(!Er&&(Er=typeof crypto!="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto!="undefined"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!Er))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Er(tp)}const ep=/^(?:[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 Yr(r){return typeof r=="string"&&ep.test(r)}var de=[];for(var Di=0;Di<256;++Di)de.push((Di+256).toString(16).substr(1));function Zr(r){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,e=(de[r[t+0]]+de[r[t+1]]+de[r[t+2]]+de[r[t+3]]+"-"+de[r[t+4]]+de[r[t+5]]+"-"+de[r[t+6]]+de[r[t+7]]+"-"+de[r[t+8]]+de[r[t+9]]+"-"+de[r[t+10]]+de[r[t+11]]+de[r[t+12]]+de[r[t+13]]+de[r[t+14]]+de[r[t+15]]).toLowerCase();if(!Yr(e))throw TypeError("Stringified UUID is invalid");return e}var So,Pi,Fi=0,qi=0;function np(r,t,e){var n=t&&e||0,s=t||new Array(16);r=r||{};var i=r.node||So,o=r.clockseq!==void 0?r.clockseq:Pi;if(i==null||o==null){var c=r.random||(r.rng||Va)();i==null&&(i=So=[c[0]|1,c[1],c[2],c[3],c[4],c[5]]),o==null&&(o=Pi=(c[6]<<8|c[7])&16383)}var d=r.msecs!==void 0?r.msecs:Date.now(),_=r.nsecs!==void 0?r.nsecs:qi+1,b=d-Fi+(_-qi)/1e4;if(b<0&&r.clockseq===void 0&&(o=o+1&16383),(b<0||d>Fi)&&r.nsecs===void 0&&(_=0),_>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Fi=d,qi=_,Pi=o,d+=122192928e5;var O=((d&268435455)*1e4+_)%4294967296;s[n++]=O>>>24&255,s[n++]=O>>>16&255,s[n++]=O>>>8&255,s[n++]=O&255;var x=d/4294967296*1e4&268435455;s[n++]=x>>>8&255,s[n++]=x&255,s[n++]=x>>>24&15|16,s[n++]=x>>>16&255,s[n++]=o>>>8|128,s[n++]=o&255;for(var S=0;S<6;++S)s[n+S]=i[S];return t||Zr(s)}function Ga(r){if(!Yr(r))throw TypeError("Invalid UUID");var t,e=new Uint8Array(16);return e[0]=(t=parseInt(r.slice(0,8),16))>>>24,e[1]=t>>>16&255,e[2]=t>>>8&255,e[3]=t&255,e[4]=(t=parseInt(r.slice(9,13),16))>>>8,e[5]=t&255,e[6]=(t=parseInt(r.slice(14,18),16))>>>8,e[7]=t&255,e[8]=(t=parseInt(r.slice(19,23),16))>>>8,e[9]=t&255,e[10]=(t=parseInt(r.slice(24,36),16))/1099511627776&255,e[11]=t/4294967296&255,e[12]=t>>>24&255,e[13]=t>>>16&255,e[14]=t>>>8&255,e[15]=t&255,e}function rp(r){r=unescape(encodeURIComponent(r));for(var t=[],e=0;e<r.length;++e)t.push(r.charCodeAt(e));return t}var ip="6ba7b810-9dad-11d1-80b4-00c04fd430c8",sp="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function Ka(r,t,e){function n(s,i,o,c){if(typeof s=="string"&&(s=rp(s)),typeof i=="string"&&(i=Ga(i)),i.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var d=new Uint8Array(16+s.length);if(d.set(i),d.set(s,i.length),d=e(d),d[6]=d[6]&15|t,d[8]=d[8]&63|128,o){c=c||0;for(var _=0;_<16;++_)o[c+_]=d[_];return o}return Zr(d)}try{n.name=r}catch(s){}return n.DNS=ip,n.URL=sp,n}function op(r){if(typeof r=="string"){var t=unescape(encodeURIComponent(r));r=new Uint8Array(t.length);for(var e=0;e<t.length;++e)r[e]=t.charCodeAt(e)}return ap(cp(up(r),r.length*8))}function ap(r){for(var t=[],e=r.length*32,n="0123456789abcdef",s=0;s<e;s+=8){var i=r[s>>5]>>>s%32&255,o=parseInt(n.charAt(i>>>4&15)+n.charAt(i&15),16);t.push(o)}return t}function Ha(r){return(r+64>>>9<<4)+14+1}function cp(r,t){r[t>>5]|=128<<t%32,r[Ha(t)-1]=t;for(var e=1732584193,n=-271733879,s=-1732584194,i=271733878,o=0;o<r.length;o+=16){var c=e,d=n,_=s,b=i;e=ye(e,n,s,i,r[o],7,-680876936),i=ye(i,e,n,s,r[o+1],12,-389564586),s=ye(s,i,e,n,r[o+2],17,606105819),n=ye(n,s,i,e,r[o+3],22,-1044525330),e=ye(e,n,s,i,r[o+4],7,-176418897),i=ye(i,e,n,s,r[o+5],12,1200080426),s=ye(s,i,e,n,r[o+6],17,-1473231341),n=ye(n,s,i,e,r[o+7],22,-45705983),e=ye(e,n,s,i,r[o+8],7,1770035416),i=ye(i,e,n,s,r[o+9],12,-1958414417),s=ye(s,i,e,n,r[o+10],17,-42063),n=ye(n,s,i,e,r[o+11],22,-1990404162),e=ye(e,n,s,i,r[o+12],7,1804603682),i=ye(i,e,n,s,r[o+13],12,-40341101),s=ye(s,i,e,n,r[o+14],17,-1502002290),n=ye(n,s,i,e,r[o+15],22,1236535329),e=we(e,n,s,i,r[o+1],5,-165796510),i=we(i,e,n,s,r[o+6],9,-1069501632),s=we(s,i,e,n,r[o+11],14,643717713),n=we(n,s,i,e,r[o],20,-373897302),e=we(e,n,s,i,r[o+5],5,-701558691),i=we(i,e,n,s,r[o+10],9,38016083),s=we(s,i,e,n,r[o+15],14,-660478335),n=we(n,s,i,e,r[o+4],20,-405537848),e=we(e,n,s,i,r[o+9],5,568446438),i=we(i,e,n,s,r[o+14],9,-1019803690),s=we(s,i,e,n,r[o+3],14,-187363961),n=we(n,s,i,e,r[o+8],20,1163531501),e=we(e,n,s,i,r[o+13],5,-1444681467),i=we(i,e,n,s,r[o+2],9,-51403784),s=we(s,i,e,n,r[o+7],14,1735328473),n=we(n,s,i,e,r[o+12],20,-1926607734),e=Ee(e,n,s,i,r[o+5],4,-378558),i=Ee(i,e,n,s,r[o+8],11,-2022574463),s=Ee(s,i,e,n,r[o+11],16,1839030562),n=Ee(n,s,i,e,r[o+14],23,-35309556),e=Ee(e,n,s,i,r[o+1],4,-1530992060),i=Ee(i,e,n,s,r[o+4],11,1272893353),s=Ee(s,i,e,n,r[o+7],16,-155497632),n=Ee(n,s,i,e,r[o+10],23,-1094730640),e=Ee(e,n,s,i,r[o+13],4,681279174),i=Ee(i,e,n,s,r[o],11,-358537222),s=Ee(s,i,e,n,r[o+3],16,-722521979),n=Ee(n,s,i,e,r[o+6],23,76029189),e=Ee(e,n,s,i,r[o+9],4,-640364487),i=Ee(i,e,n,s,r[o+12],11,-421815835),s=Ee(s,i,e,n,r[o+15],16,530742520),n=Ee(n,s,i,e,r[o+2],23,-995338651),e=Re(e,n,s,i,r[o],6,-198630844),i=Re(i,e,n,s,r[o+7],10,1126891415),s=Re(s,i,e,n,r[o+14],15,-1416354905),n=Re(n,s,i,e,r[o+5],21,-57434055),e=Re(e,n,s,i,r[o+12],6,1700485571),i=Re(i,e,n,s,r[o+3],10,-1894986606),s=Re(s,i,e,n,r[o+10],15,-1051523),n=Re(n,s,i,e,r[o+1],21,-2054922799),e=Re(e,n,s,i,r[o+8],6,1873313359),i=Re(i,e,n,s,r[o+15],10,-30611744),s=Re(s,i,e,n,r[o+6],15,-1560198380),n=Re(n,s,i,e,r[o+13],21,1309151649),e=Re(e,n,s,i,r[o+4],6,-145523070),i=Re(i,e,n,s,r[o+11],10,-1120210379),s=Re(s,i,e,n,r[o+2],15,718787259),n=Re(n,s,i,e,r[o+9],21,-343485551),e=nn(e,c),n=nn(n,d),s=nn(s,_),i=nn(i,b)}return[e,n,s,i]}function up(r){if(r.length===0)return[];for(var t=r.length*8,e=new Uint32Array(Ha(t)),n=0;n<t;n+=8)e[n>>5]|=(r[n/8]&255)<<n%32;return e}function nn(r,t){var e=(r&65535)+(t&65535),n=(r>>16)+(t>>16)+(e>>16);return n<<16|e&65535}function lp(r,t){return r<<t|r>>>32-t}function Jr(r,t,e,n,s,i){return nn(lp(nn(nn(t,r),nn(n,i)),s),e)}function ye(r,t,e,n,s,i,o){return Jr(t&e|~t&n,r,t,s,i,o)}function we(r,t,e,n,s,i,o){return Jr(t&n|e&~n,r,t,s,i,o)}function Ee(r,t,e,n,s,i,o){return Jr(t^e^n,r,t,s,i,o)}function Re(r,t,e,n,s,i,o){return Jr(e^(t|~n),r,t,s,i,o)}var fp=Ka("v3",48,op);function hp(r,t,e){r=r||{};var n=r.random||(r.rng||Va)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){e=e||0;for(var s=0;s<16;++s)t[e+s]=n[s];return t}return Zr(n)}function dp(r,t,e,n){switch(r){case 0:return t&e^~t&n;case 1:return t^e^n;case 2:return t&e^t&n^e&n;case 3:return t^e^n}}function $i(r,t){return r<<t|r>>>32-t}function pp(r){var t=[1518500249,1859775393,2400959708,3395469782],e=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof r=="string"){var n=unescape(encodeURIComponent(r));r=[];for(var s=0;s<n.length;++s)r.push(n.charCodeAt(s))}else Array.isArray(r)||(r=Array.prototype.slice.call(r));r.push(128);for(var i=r.length/4+2,o=Math.ceil(i/16),c=new Array(o),d=0;d<o;++d){for(var _=new Uint32Array(16),b=0;b<16;++b)_[b]=r[d*64+b*4]<<24|r[d*64+b*4+1]<<16|r[d*64+b*4+2]<<8|r[d*64+b*4+3];c[d]=_}c[o-1][14]=(r.length-1)*8/Math.pow(2,32),c[o-1][14]=Math.floor(c[o-1][14]),c[o-1][15]=(r.length-1)*8&4294967295;for(var O=0;O<o;++O){for(var x=new Uint32Array(80),S=0;S<16;++S)x[S]=c[O][S];for(var T=16;T<80;++T)x[T]=$i(x[T-3]^x[T-8]^x[T-14]^x[T-16],1);for(var C=e[0],M=e[1],P=e[2],W=e[3],z=e[4],Q=0;Q<80;++Q){var Z=Math.floor(Q/20),st=$i(C,5)+dp(Z,M,P,W)+z+t[Z]+x[Q]>>>0;z=W,W=P,P=$i(M,30)>>>0,M=C,C=st}e[0]=e[0]+C>>>0,e[1]=e[1]+M>>>0,e[2]=e[2]+P>>>0,e[3]=e[3]+W>>>0,e[4]=e[4]+z>>>0}return[e[0]>>24&255,e[0]>>16&255,e[0]>>8&255,e[0]&255,e[1]>>24&255,e[1]>>16&255,e[1]>>8&255,e[1]&255,e[2]>>24&255,e[2]>>16&255,e[2]>>8&255,e[2]&255,e[3]>>24&255,e[3]>>16&255,e[3]>>8&255,e[3]&255,e[4]>>24&255,e[4]>>16&255,e[4]>>8&255,e[4]&255]}var gp=Ka("v5",80,pp);const _p="00000000-0000-0000-0000-000000000000";function mp(r){if(!Yr(r))throw TypeError("Invalid UUID");return parseInt(r.substr(14,1),16)}const yp=Object.freeze(Object.defineProperty({__proto__:null,NIL:_p,parse:Ga,stringify:Zr,v1:np,v3:fp,v4:hp,v5:gp,validate:Yr,version:mp},Symbol.toStringTag,{value:"Module"})),Wa=hs(yp);var zi,vo;function wp(){if(vo)return zi;vo=1;const r=Wa.v4;return zi=function(e,n,s,i){if(typeof e!="string")throw new TypeError(e+" must be a string");i=i||{};const o=typeof i.version=="number"?i.version:2;if(o!==1&&o!==2)throw new TypeError(o+" must be 1 or 2");const c={method:e};if(o===2&&(c.jsonrpc="2.0"),n){if(typeof n!="object"&&!Array.isArray(n))throw new TypeError(n+" must be an object, array or omitted");c.params=n}if(typeof s=="undefined"){const d=typeof i.generator=="function"?i.generator:function(){return r()};c.id=d(c,i)}else o===2&&s===null?i.notificationIdNull&&(c.id=null):c.id=s;return c},zi}var Vi,Io;function Ep(){if(Io)return Vi;Io=1;const r=Wa.v4,t=wp(),e=function(n,s){if(!(this instanceof e))return new e(n,s);s||(s={}),this.options={reviver:typeof s.reviver!="undefined"?s.reviver:null,replacer:typeof s.replacer!="undefined"?s.replacer:null,generator:typeof s.generator!="undefined"?s.generator:function(){return r()},version:typeof s.version!="undefined"?s.version:2,notificationIdNull:typeof s.notificationIdNull=="boolean"?s.notificationIdNull:!1},this.callServer=n};return Vi=e,e.prototype.request=function(n,s,i,o){const c=this;let d=null;const _=Array.isArray(n)&&typeof s=="function";if(this.options.version===1&&_)throw new TypeError("JSON-RPC 1.0 does not support batching");if(_||!_&&n&&typeof n=="object"&&typeof s=="function")o=s,d=n;else{typeof i=="function"&&(o=i,i=void 0);const x=typeof o=="function";try{d=t(n,s,i,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(S){if(x)return o(S);throw S}if(!x)return d}let O;try{O=JSON.stringify(d,this.options.replacer)}catch(x){return o(x)}return this.callServer(O,function(x,S){c._parseResponse(x,S,o)}),d},e.prototype._parseResponse=function(n,s,i){if(n){i(n);return}if(!s)return i();let o;try{o=JSON.parse(s,this.options.reviver)}catch(c){return i(c)}if(i.length===3)if(Array.isArray(o)){const c=function(_){return typeof _.error!="undefined"},d=function(_){return!c(_)};return i(null,o.filter(c),o.filter(d))}else return i(null,o.error,o.result);i(null,o)},Vi}var Rp=Ep();const bp=Hr(Rp);var Ap=class extends ms{constructor(t,e){super();Mt(this,"socket");this.socket=new window.WebSocket(t,e.protocols),this.socket.onopen=()=>this.emit("open"),this.socket.onmessage=n=>this.emit("message",n.data),this.socket.onerror=n=>this.emit("error",n),this.socket.onclose=n=>{this.emit("close",n.code,n.reason)}}send(t,e,n){const s=n||e;try{this.socket.send(t),s()}catch(i){s(i)}}close(t,e){this.socket.close(t,e)}addEventListener(t,e,n){this.socket.addEventListener(t,e,n)}};function Sp(r,t){return new Ap(r,t)}var vp=class{encode(r){return JSON.stringify(r)}decode(r){return JSON.parse(r)}},Ip=class extends ms{constructor(t,e="ws://localhost:8080",b={},d,_){var O=b,{autoconnect:n=!0,reconnect:s=!0,reconnect_interval:i=1e3,max_reconnects:o=5}=O,c=qe(O,["autoconnect","reconnect","reconnect_interval","max_reconnects"]);super();Mt(this,"address");Mt(this,"rpc_id");Mt(this,"queue");Mt(this,"options");Mt(this,"autoconnect");Mt(this,"ready");Mt(this,"reconnect");Mt(this,"reconnect_timer_id");Mt(this,"reconnect_interval");Mt(this,"max_reconnects");Mt(this,"rest_options");Mt(this,"current_reconnects");Mt(this,"generate_request_id");Mt(this,"socket");Mt(this,"webSocketFactory");Mt(this,"dataPack");this.webSocketFactory=t,this.queue={},this.rpc_id=0,this.address=e,this.autoconnect=n,this.ready=!1,this.reconnect=s,this.reconnect_timer_id=void 0,this.reconnect_interval=i,this.max_reconnects=o,this.rest_options=c,this.current_reconnects=0,this.generate_request_id=d||(()=>typeof this.rpc_id=="number"?++this.rpc_id:Number(this.rpc_id)+1),_?this.dataPack=_:this.dataPack=new vp,this.autoconnect&&this._connect(this.address,lt({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,lt({autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects},this.rest_options))}call(t,e,n,s){return!s&&typeof n=="object"&&(s=n,n=null),new Promise((i,o)=>{if(!this.ready)return o(new Error("socket not ready"));const c=this.generate_request_id(t,e),d={jsonrpc:"2.0",method:t,params:e||void 0,id:c};this.socket.send(this.dataPack.encode(d),s,_=>{if(_)return o(_);this.queue[c]={promise:[i,o]},n&&(this.queue[c].timeout=setTimeout(()=>{delete this.queue[c],o(new Error("reply timeout"))},n))})})}login(t){return H(this,null,function*(){const e=yield this.call("rpc.login",t);if(!e)throw new Error("authentication failed");return e})}listMethods(){return H(this,null,function*(){return yield this.call("__listMethods")})}notify(t,e){return new Promise((n,s)=>{if(!this.ready)return s(new Error("socket not ready"));const i={jsonrpc:"2.0",method:t,params:e};this.socket.send(this.dataPack.encode(i),o=>{if(o)return s(o);n()})})}subscribe(t){return H(this,null,function*(){typeof t=="string"&&(t=[t]);const e=yield this.call("rpc.on",t);if(typeof t=="string"&&e[t]!=="ok")throw new Error("Failed subscribing to an event '"+t+"' with: "+e[t]);return e})}unsubscribe(t){return H(this,null,function*(){typeof t=="string"&&(t=[t]);const e=yield this.call("rpc.off",t);if(typeof t=="string"&&e[t]!=="ok")throw new Error("Failed unsubscribing from an event with: "+e);return e})}close(t,e){this.socket&&this.socket.close(t||1e3,e)}setAutoReconnect(t){this.reconnect=t}setReconnectInterval(t){this.reconnect_interval=t}setMaxReconnects(t){this.max_reconnects=t}getCurrentReconnects(){return this.current_reconnects}getMaxReconnects(){return this.max_reconnects}isReconnecting(){return this.reconnect_timer_id!==void 0}willReconnect(){return this.reconnect&&(this.max_reconnects===0||this.current_reconnects<this.max_reconnects)}_connect(t,e){clearTimeout(this.reconnect_timer_id),this.socket=this.webSocketFactory(t,e),this.socket.addEventListener("open",()=>{this.ready=!0,this.emit("open"),this.current_reconnects=0}),this.socket.addEventListener("message",({data:n})=>{n instanceof ArrayBuffer&&(n=Et.Buffer.from(n).toString());try{n=this.dataPack.decode(n)}catch(s){return}if(n.notification&&this.listeners(n.notification).length){if(!Object.keys(n.params).length)return this.emit(n.notification);const s=[n.notification];if(n.params.constructor===Object)s.push(n.params);else for(let i=0;i<n.params.length;i++)s.push(n.params[i]);return Promise.resolve().then(()=>{this.emit.apply(this,s)})}if(!this.queue[n.id])return n.method?Promise.resolve().then(()=>{this.emit(n.method,n==null?void 0:n.params)}):void 0;"error"in n=="result"in n&&this.queue[n.id].promise[1](new Error('Server response malformed. Response must include either "result" or "error", but not both.')),this.queue[n.id].timeout&&clearTimeout(this.queue[n.id].timeout),n.error?this.queue[n.id].promise[1](n.error):this.queue[n.id].promise[0](n.result),delete this.queue[n.id]}),this.socket.addEventListener("error",n=>this.emit("error",n)),this.socket.addEventListener("close",({code:n,reason:s})=>{this.ready&&setTimeout(()=>this.emit("close",n,s),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(t,e),this.reconnect_interval):this.reconnect&&this.max_reconnects>0&&this.current_reconnects>=this.max_reconnects&&setTimeout(()=>this.emit("max_reconnects_reached",n,s),1))})}};class ja extends oa{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,ia(t);const n=ws(e);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const s=this.blockLen,i=new Uint8Array(s);i.set(n.length>s?t.create().update(n).digest():n);for(let o=0;o<i.length;o++)i[o]^=54;this.iHash.update(i),this.oHash=t.create();for(let o=0;o<i.length;o++)i[o]^=106;this.oHash.update(i),kn(i)}update(t){return Br(this),this.iHash.update(t),this}digestInto(t){Br(this),_n(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:e,iHash:n,finished:s,destroyed:i,blockLen:o,outputLen:c}=this;return t=t,t.finished=s,t.destroyed=i,t.blockLen=o,t.outputLen=c,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Xa=(r,t,e)=>new ja(r,t).update(e).digest();Xa.create=(r,t)=>new ja(r,t);const Oo=(r,t)=>(r+(r>=0?t:-t)/Ya)/t;function Op(r,t,e){const[[n,s],[i,o]]=t,c=Oo(o*r,e),d=Oo(-s*r,e);let _=r-c*n-d*i,b=-c*s-d*o;const O=_<We,x=b<We;O&&(_=-_),x&&(b=-b);const S=ir(Math.ceil(da(e)/2))+Ln;if(_<We||_>=S||b<We||b>=S)throw new Error("splitScalar (endomorphism): failed, k="+r);return{k1neg:O,k1:_,k2neg:x,k2:b}}function ns(r){if(!["compact","recovered","der"].includes(r))throw new Error('Signature format must be "compact", "recovered", or "der"');return r}function Gi(r,t){const e={};for(let n of Object.keys(t))e[n]=r[n]===void 0?t[n]:r[n];return gn(e.lowS,"lowS"),gn(e.prehash,"prehash"),e.format!==void 0&&ns(e.format),e}class xp extends Error{constructor(t=""){super(t)}}const Ge={Err:xp,_tlv:{encode:(r,t)=>{const{Err:e}=Ge;if(r<0||r>256)throw new e("tlv.encode: wrong tag");if(t.length&1)throw new e("tlv.encode: unpadded data");const n=t.length/2,s=yr(n);if(s.length/2&128)throw new e("tlv.encode: long form length too big");const i=n>127?yr(s.length/2|128):"";return yr(r)+i+s+t},decode(r,t){const{Err:e}=Ge;let n=0;if(r<0||r>256)throw new e("tlv.encode: wrong tag");if(t.length<2||t[n++]!==r)throw new e("tlv.decode: wrong tlv");const s=t[n++],i=!!(s&128);let o=0;if(!i)o=s;else{const d=s&127;if(!d)throw new e("tlv.decode(long): indefinite length not supported");if(d>4)throw new e("tlv.decode(long): byte length is too big");const _=t.subarray(n,n+d);if(_.length!==d)throw new e("tlv.decode: length bytes not complete");if(_[0]===0)throw new e("tlv.decode(long): zero leftmost byte");for(const b of _)o=o<<8|b;if(n+=d,o<128)throw new e("tlv.decode(long): not minimal encoding")}const c=t.subarray(n,n+o);if(c.length!==o)throw new e("tlv.decode: wrong value length");return{v:c,l:t.subarray(n+o)}}},_int:{encode(r){const{Err:t}=Ge;if(r<We)throw new t("integer: negative integers are not allowed");let e=yr(r);if(Number.parseInt(e[0],16)&8&&(e="00"+e),e.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return e},decode(r){const{Err:t}=Ge;if(r[0]&128)throw new t("invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return jr(r)}},toSig(r){const{Err:t,_int:e,_tlv:n}=Ge,s=Gt("signature",r),{v:i,l:o}=n.decode(48,s);if(o.length)throw new t("invalid signature: left bytes after parsing");const{v:c,l:d}=n.decode(2,i),{v:_,l:b}=n.decode(2,d);if(b.length)throw new t("invalid signature: left bytes after parsing");return{r:e.decode(c),s:e.decode(_)}},hexFromSig(r){const{_tlv:t,_int:e}=Ge,n=t.encode(2,e.encode(r.r)),s=t.encode(2,e.encode(r.s)),i=n+s;return t.encode(48,i)}},We=BigInt(0),Ln=BigInt(1),Ya=BigInt(2),Rr=BigInt(3),Np=BigInt(4);function Tn(r,t){const{BYTES:e}=r;let n;if(typeof t=="bigint")n=t;else{let s=Gt("private key",t);try{n=r.fromBytes(s)}catch(i){throw new Error(`invalid private key: expected ui8a of size ${e}, got ${typeof t}`)}}if(!r.isValidNot0(n))throw new Error("invalid private key: out of range [1..N-1]");return n}function Tp(r,t={}){const e=Na("weierstrass",r,t),{Fp:n,Fn:s}=e;let i=e.CURVE;const{h:o,n:c}=i;sr(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});const{endo:d}=t;if(d&&(!n.is0(i.a)||typeof d.beta!="bigint"||!Array.isArray(d.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');const _=Ja(n,s);function b(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function O(K,m,a){const{x:h,y:g}=m.toAffine(),R=n.toBytes(h);if(gn(a,"isCompressed"),a){b();const v=!n.isOdd(g);return De(Za(v),R)}else return De(Uint8Array.of(4),R,n.toBytes(g))}function x(K){Le(K,void 0,"Point");const{publicKey:m,publicKeyUncompressed:a}=_,h=K.length,g=K[0],R=K.subarray(1);if(h===m&&(g===2||g===3)){const v=n.fromBytes(R);if(!n.isValid(v))throw new Error("bad point: is not on curve, wrong x");const N=C(v);let L;try{L=n.sqrt(N)}catch(l){const w=l instanceof Error?": "+l.message:"";throw new Error("bad point: is not on curve, sqrt error"+w)}b();const E=n.isOdd(L);return(g&1)===1!==E&&(L=n.neg(L)),{x:v,y:L}}else if(h===a&&g===4){const v=n.BYTES,N=n.fromBytes(R.subarray(0,v)),L=n.fromBytes(R.subarray(v,v*2));if(!M(N,L))throw new Error("bad point: is not on curve");return{x:N,y:L}}else throw new Error(`bad point: got length ${h}, expected compressed=${m} or uncompressed=${a}`)}const S=t.toBytes||O,T=t.fromBytes||x;function C(K){const m=n.sqr(K),a=n.mul(m,K);return n.add(n.add(a,n.mul(K,i.a)),i.b)}function M(K,m){const a=n.sqr(m),h=C(K);return n.eql(a,h)}if(!M(i.Gx,i.Gy))throw new Error("bad curve params: generator point");const P=n.mul(n.pow(i.a,Rr),Np),W=n.mul(n.sqr(i.b),BigInt(27));if(n.is0(n.add(P,W)))throw new Error("bad curve params: a or b");function z(K,m,a=!1){if(!n.isValid(m)||a&&n.is0(m))throw new Error(`bad point coordinate ${K}`);return m}function Q(K){if(!(K instanceof k))throw new Error("ProjectivePoint expected")}function Z(K){if(!d||!d.basises)throw new Error("no endo");return Op(K,d.basises,s.ORDER)}const st=Lr((K,m)=>{const{X:a,Y:h,Z:g}=K;if(n.eql(g,n.ONE))return{x:a,y:h};const R=K.is0();m==null&&(m=R?n.ONE:n.inv(g));const v=n.mul(a,m),N=n.mul(h,m),L=n.mul(g,m);if(R)return{x:n.ZERO,y:n.ZERO};if(!n.eql(L,n.ONE))throw new Error("invZ was invalid");return{x:v,y:N}}),pt=Lr(K=>{if(K.is0()){if(t.allowInfinityPoint&&!n.is0(K.Y))return;throw new Error("bad point: ZERO")}const{x:m,y:a}=K.toAffine();if(!n.isValid(m)||!n.isValid(a))throw new Error("bad point: x or y not field elements");if(!M(m,a))throw new Error("bad point: equation left != right");if(!K.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function ct(K,m,a,h,g){return a=new k(n.mul(a.X,K),a.Y,a.Z),m=Mr(h,m),a=Mr(g,a),m.add(a)}class k{constructor(m,a,h){this.X=z("x",m),this.Y=z("y",a,!0),this.Z=z("z",h),Object.freeze(this)}static CURVE(){return i}static fromAffine(m){const{x:a,y:h}=m||{};if(!m||!n.isValid(a)||!n.isValid(h))throw new Error("invalid affine point");if(m instanceof k)throw new Error("projective point not allowed");return n.is0(a)&&n.is0(h)?k.ZERO:new k(a,h,n.ONE)}static fromBytes(m){const a=k.fromAffine(T(Le(m,void 0,"point")));return a.assertValidity(),a}static fromHex(m){return k.fromBytes(Gt("pointHex",m))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(m=8,a=!0){return V.createCache(this,m),a||this.multiply(Rr),this}assertValidity(){pt(this)}hasEvenY(){const{y:m}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(m)}equals(m){Q(m);const{X:a,Y:h,Z:g}=this,{X:R,Y:v,Z:N}=m,L=n.eql(n.mul(a,N),n.mul(R,g)),E=n.eql(n.mul(h,N),n.mul(v,g));return L&&E}negate(){return new k(this.X,n.neg(this.Y),this.Z)}double(){const{a:m,b:a}=i,h=n.mul(a,Rr),{X:g,Y:R,Z:v}=this;let N=n.ZERO,L=n.ZERO,E=n.ZERO,u=n.mul(g,g),l=n.mul(R,R),w=n.mul(v,v),I=n.mul(g,R);return I=n.add(I,I),E=n.mul(g,v),E=n.add(E,E),N=n.mul(m,E),L=n.mul(h,w),L=n.add(N,L),N=n.sub(l,L),L=n.add(l,L),L=n.mul(N,L),N=n.mul(I,N),E=n.mul(h,E),w=n.mul(m,w),I=n.sub(u,w),I=n.mul(m,I),I=n.add(I,E),E=n.add(u,u),u=n.add(E,u),u=n.add(u,w),u=n.mul(u,I),L=n.add(L,u),w=n.mul(R,v),w=n.add(w,w),u=n.mul(w,I),N=n.sub(N,u),E=n.mul(w,l),E=n.add(E,E),E=n.add(E,E),new k(N,L,E)}add(m){Q(m);const{X:a,Y:h,Z:g}=this,{X:R,Y:v,Z:N}=m;let L=n.ZERO,E=n.ZERO,u=n.ZERO;const l=i.a,w=n.mul(i.b,Rr);let I=n.mul(a,R),F=n.mul(h,v),X=n.mul(g,N),et=n.add(a,h),it=n.add(R,v);et=n.mul(et,it),it=n.add(I,F),et=n.sub(et,it),it=n.add(a,g);let St=n.add(R,N);return it=n.mul(it,St),St=n.add(I,X),it=n.sub(it,St),St=n.add(h,g),L=n.add(v,N),St=n.mul(St,L),L=n.add(F,X),St=n.sub(St,L),u=n.mul(l,it),L=n.mul(w,X),u=n.add(L,u),L=n.sub(F,u),u=n.add(F,u),E=n.mul(L,u),F=n.add(I,I),F=n.add(F,I),X=n.mul(l,X),it=n.mul(w,it),F=n.add(F,X),X=n.sub(I,X),X=n.mul(l,X),it=n.add(it,X),I=n.mul(F,it),E=n.add(E,I),I=n.mul(St,it),L=n.mul(et,L),L=n.sub(L,I),I=n.mul(et,F),u=n.mul(St,u),u=n.add(u,I),new k(L,E,u)}subtract(m){return this.add(m.negate())}is0(){return this.equals(k.ZERO)}multiply(m){const{endo:a}=t;if(!s.isValidNot0(m))throw new Error("invalid scalar: out of range");let h,g;const R=v=>V.cached(this,v,N=>un(k,N));if(a){const{k1neg:v,k1:N,k2neg:L,k2:E}=Z(m),{p:u,f:l}=R(N),{p:w,f:I}=R(E);g=l.add(I),h=ct(a.beta,u,w,v,L)}else{const{p:v,f:N}=R(m);h=v,g=N}return un(k,[h,g])[0]}multiplyUnsafe(m){const{endo:a}=t,h=this;if(!s.isValid(m))throw new Error("invalid scalar: out of range");if(m===We||h.is0())return k.ZERO;if(m===Ln)return h;if(V.hasCache(this))return this.multiply(m);if(a){const{k1neg:g,k1:R,k2neg:v,k2:N}=Z(m),{p1:L,p2:E}=Gu(k,h,R,N);return ct(a.beta,L,E,g,v)}else return V.unsafe(h,m)}multiplyAndAddUnsafe(m,a,h){const g=this.multiplyUnsafe(a).add(m.multiplyUnsafe(h));return g.is0()?void 0:g}toAffine(m){return st(this,m)}isTorsionFree(){const{isTorsionFree:m}=t;return o===Ln?!0:m?m(k,this):V.unsafe(this,c).is0()}clearCofactor(){const{clearCofactor:m}=t;return o===Ln?this:m?m(k,this):this.multiplyUnsafe(o)}isSmallOrder(){return this.multiplyUnsafe(o).is0()}toBytes(m=!0){return gn(m,"isCompressed"),this.assertValidity(),S(k,this,m)}toHex(m=!0){return dn(this.toBytes(m))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(m=!0){return this.toBytes(m)}_setWindowSize(m){this.precompute(m)}static normalizeZ(m){return un(k,m)}static msm(m,a){return xa(k,s,m,a)}static fromPrivateKey(m){return k.BASE.multiply(Tn(s,m))}}k.BASE=new k(i.Gx,i.Gy,n.ONE),k.ZERO=new k(n.ZERO,n.ONE,n.ZERO),k.Fp=n,k.Fn=s;const D=s.BITS,V=new Oa(k,t.endo?Math.ceil(D/2):D);return k.BASE.precompute(8),k}function Za(r){return Uint8Array.of(r?2:3)}function Ja(r,t){return{secretKey:t.BYTES,publicKey:1+r.BYTES,publicKeyUncompressed:1+2*r.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function Bp(r,t={}){const{Fn:e}=r,n=t.randomBytes||Es,s=Object.assign(Ja(r.Fp,e),{seed:Sa(e.ORDER)});function i(S){try{return!!Tn(e,S)}catch(T){return!1}}function o(S,T){const{publicKey:C,publicKeyUncompressed:M}=s;try{const P=S.length;return T===!0&&P!==C||T===!1&&P!==M?!1:!!r.fromBytes(S)}catch(P){return!1}}function c(S=n(s.seed)){return $u(Le(S,s.seed,"seed"),e.ORDER)}function d(S,T=!0){return r.BASE.multiply(Tn(e,S)).toBytes(T)}function _(S){const T=c(S);return{secretKey:T,publicKey:d(T)}}function b(S){if(typeof S=="bigint")return!1;if(S instanceof r)return!0;const{secretKey:T,publicKey:C,publicKeyUncompressed:M}=s;if(e.allowedLengths||T===C)return;const P=Gt("key",S).length;return P===C||P===M}function O(S,T,C=!0){if(b(S)===!0)throw new Error("first arg must be private key");if(b(T)===!1)throw new Error("second arg must be public key");const M=Tn(e,S);return r.fromHex(T).multiply(M).toBytes(C)}return Object.freeze({getPublicKey:d,getSharedSecret:O,keygen:_,Point:r,utils:{isValidSecretKey:i,isValidPublicKey:o,randomSecretKey:c,isValidPrivateKey:i,randomPrivateKey:c,normPrivateKeyToScalar:S=>Tn(e,S),precompute(S=8,T=r.BASE){return T.precompute(S,!1)}},lengths:s})}function Cp(r,t,e={}){ia(t),sr(e,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const n=e.randomBytes||Es,s=e.hmac||((a,...h)=>Xa(t,a,De(...h))),{Fp:i,Fn:o}=r,{ORDER:c,BITS:d}=o,{keygen:_,getPublicKey:b,getSharedSecret:O,utils:x,lengths:S}=Bp(r,e),T={prehash:!1,lowS:typeof e.lowS=="boolean"?e.lowS:!1,format:void 0,extraEntropy:!1},C="compact";function M(a){const h=c>>Ln;return a>h}function P(a,h){if(!o.isValidNot0(h))throw new Error(`invalid signature ${a}: out of range 1..Point.Fn.ORDER`);return h}function W(a,h){ns(h);const g=S.signature,R=h==="compact"?g:h==="recovered"?g+1:void 0;return Le(a,R,`${h} signature`)}class z{constructor(h,g,R){this.r=P("r",h),this.s=P("s",g),R!=null&&(this.recovery=R),Object.freeze(this)}static fromBytes(h,g=C){W(h,g);let R;if(g==="der"){const{r:E,s:u}=Ge.toSig(Le(h));return new z(E,u)}g==="recovered"&&(R=h[0],g="compact",h=h.subarray(1));const v=o.BYTES,N=h.subarray(0,v),L=h.subarray(v,v*2);return new z(o.fromBytes(N),o.fromBytes(L),R)}static fromHex(h,g){return this.fromBytes(Cr(h),g)}addRecoveryBit(h){return new z(this.r,this.s,h)}recoverPublicKey(h){const g=i.ORDER,{r:R,s:v,recovery:N}=this;if(N==null||![0,1,2,3].includes(N))throw new Error("recovery id invalid");if(c*Ya<g&&N>1)throw new Error("recovery id is ambiguous for h>1 curve");const E=N===2||N===3?R+c:R;if(!i.isValid(E))throw new Error("recovery id 2 or 3 invalid");const u=i.toBytes(E),l=r.fromBytes(De(Za((N&1)===0),u)),w=o.inv(E),I=Z(Gt("msgHash",h)),F=o.create(-I*w),X=o.create(v*w),et=r.BASE.multiplyUnsafe(F).add(l.multiplyUnsafe(X));if(et.is0())throw new Error("point at infinify");return et.assertValidity(),et}hasHighS(){return M(this.s)}toBytes(h=C){if(ns(h),h==="der")return Cr(Ge.hexFromSig(this));const g=o.toBytes(this.r),R=o.toBytes(this.s);if(h==="recovered"){if(this.recovery==null)throw new Error("recovery bit must be present");return De(Uint8Array.of(this.recovery),g,R)}return De(g,R)}toHex(h){return dn(this.toBytes(h))}assertValidity(){}static fromCompact(h){return z.fromBytes(Gt("sig",h),"compact")}static fromDER(h){return z.fromBytes(Gt("sig",h),"der")}normalizeS(){return this.hasHighS()?new z(this.r,o.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return dn(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return dn(this.toBytes("compact"))}}const Q=e.bits2int||function(h){if(h.length>8192)throw new Error("input is too large");const g=jr(h),R=h.length*8-d;return R>0?g>>BigInt(R):g},Z=e.bits2int_modN||function(h){return o.create(Q(h))},st=ir(d);function pt(a){return es("num < 2^"+d,a,We,st),o.toBytes(a)}function ct(a,h){return Le(a,void 0,"message"),h?Le(t(a),void 0,"prehashed message"):a}function k(a,h,g){if(["recovered","canonical"].some(F=>F in g))throw new Error("sign() legacy options not supported");const{lowS:R,prehash:v,extraEntropy:N}=Gi(g,T);a=ct(a,v);const L=Z(a),E=Tn(o,h),u=[pt(E),pt(L)];if(N!=null&&N!==!1){const F=N===!0?n(S.secretKey):N;u.push(Gt("extraEntropy",F))}const l=De(...u),w=L;function I(F){const X=Q(F);if(!o.isValidNot0(X))return;const et=o.inv(X),it=r.BASE.multiply(X).toAffine(),St=o.create(it.x);if(St===We)return;const vt=o.create(et*o.create(w+St*E));if(vt===We)return;let Ot=(it.x===St?0:2)|Number(it.y&Ln),Be=vt;return R&&M(vt)&&(Be=o.neg(vt),Ot^=1),new z(St,Be,Ot)}return{seed:l,k2sig:I}}function D(a,h,g={}){a=Gt("message",a);const{seed:R,k2sig:v}=k(a,h,g);return Bu(t.outputLen,o.BYTES,s)(R,v)}function V(a){let h;const g=typeof a=="string"||rr(a),R=!g&&a!==null&&typeof a=="object"&&typeof a.r=="bigint"&&typeof a.s=="bigint";if(!g&&!R)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(R)h=new z(a.r,a.s);else if(g){try{h=z.fromBytes(Gt("sig",a),"der")}catch(v){if(!(v instanceof Ge.Err))throw v}if(!h)try{h=z.fromBytes(Gt("sig",a),"compact")}catch(v){return!1}}return h||!1}function K(a,h,g,R={}){const{lowS:v,prehash:N,format:L}=Gi(R,T);if(g=Gt("publicKey",g),h=ct(Gt("message",h),N),"strict"in R)throw new Error("options.strict was renamed to lowS");const E=L===void 0?V(a):z.fromBytes(Gt("sig",a),L);if(E===!1)return!1;try{const u=r.fromBytes(g);if(v&&E.hasHighS())return!1;const{r:l,s:w}=E,I=Z(h),F=o.inv(w),X=o.create(I*F),et=o.create(l*F),it=r.BASE.multiplyUnsafe(X).add(u.multiplyUnsafe(et));return it.is0()?!1:o.create(it.x)===l}catch(u){return!1}}function m(a,h,g={}){const{prehash:R}=Gi(g,T);return h=ct(h,R),z.fromBytes(a,"recovered").recoverPublicKey(h).toBytes()}return Object.freeze({keygen:_,getPublicKey:b,getSharedSecret:O,utils:x,lengths:S,Point:r,sign:D,verify:K,recoverPublicKey:m,Signature:z,hash:t})}function Lp(r){const t={a:r.a,b:r.b,p:r.Fp.ORDER,n:r.n,h:r.h,Gx:r.Gx,Gy:r.Gy},e=r.Fp;let n=r.allowedPrivateKeyLengths?Array.from(new Set(r.allowedPrivateKeyLengths.map(o=>Math.ceil(o/2)))):void 0;const s=mn(t.n,{BITS:r.nBitLength,allowedLengths:n,modFromBytes:r.wrapPrivateKey}),i={Fp:e,Fn:s,allowInfinityPoint:r.allowInfinityPoint,endo:r.endo,isTorsionFree:r.isTorsionFree,clearCofactor:r.clearCofactor,fromBytes:r.fromBytes,toBytes:r.toBytes};return{CURVE:t,curveOpts:i}}function Mp(r){const{CURVE:t,curveOpts:e}=Lp(r),n={hmac:r.hmac,randomBytes:r.randomBytes,lowS:r.lowS,bits2int:r.bits2int,bits2int_modN:r.bits2int_modN};return{CURVE:t,curveOpts:e,hash:r.hash,ecdsaOpts:n}}function kp(r,t){const e=t.Point;return Object.assign({},t,{ProjectivePoint:e,CURVE:Object.assign({},r,ba(e.Fn.ORDER,e.Fn.BITS))})}function Up(r){const{CURVE:t,curveOpts:e,hash:n,ecdsaOpts:s}=Mp(r),i=Tp(t,e),o=Cp(i,n,s);return kp(r,o)}function Dp(r,t){const e=n=>Up(yt(lt({},r),{hash:n}));return yt(lt({},e(t)),{create:e})}const Ns={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},Pp={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},xo=BigInt(2);function Fp(r){const t=Ns.p,e=BigInt(3),n=BigInt(6),s=BigInt(11),i=BigInt(22),o=BigInt(23),c=BigInt(44),d=BigInt(88),_=r*r*r%t,b=_*_*r%t,O=Vt(b,e,t)*b%t,x=Vt(O,e,t)*b%t,S=Vt(x,xo,t)*_%t,T=Vt(S,s,t)*S%t,C=Vt(T,i,t)*T%t,M=Vt(C,c,t)*C%t,P=Vt(M,d,t)*M%t,W=Vt(P,c,t)*C%t,z=Vt(W,e,t)*b%t,Q=Vt(z,o,t)*T%t,Z=Vt(Q,n,t)*_%t,st=Vt(Z,xo,t);if(!rs.eql(rs.sqr(st),r))throw new Error("Cannot find square root");return st}const rs=mn(Ns.p,{sqrt:Fp}),qp=Dp(yt(lt({},Ns),{Fp:rs,lowS:!0,endo:Pp}),la);or.utils.randomPrivateKey;or.getPublicKey;function No(r){try{return or.ExtendedPoint.fromHex(r),!0}catch(t){return!1}}const Qa=(r,t)=>or.sign(r,t.slice(0,32)),$p=or.verify,Pn=r=>Et.Buffer.isBuffer(r)?r:r instanceof Uint8Array?Et.Buffer.from(r.buffer,r.byteOffset,r.byteLength):Et.Buffer.from(r);class zp{constructor(t){Object.assign(this,t)}encode(){return Et.Buffer.from(Ui.serialize(Ir,this))}static decode(t){return Ui.deserialize(Ir,this,t)}static decodeUnchecked(t){return Ui.deserializeUnchecked(Ir,this,t)}}const Ir=new Map;var tc;const Vp=32,rn=32;function Gp(r){return r._bn!==void 0}let To=1;class ht extends zp{constructor(t){if(super({}),this._bn=void 0,Gp(t))this._bn=t._bn;else{if(typeof t=="string"){const e=he.decode(t);if(e.length!=rn)throw new Error("Invalid public key input");this._bn=new _o(e)}else this._bn=new _o(t);if(this._bn.byteLength()>rn)throw new Error("Invalid public key input")}}static unique(){const t=new ht(To);return To+=1,new ht(t.toBuffer())}equals(t){return this._bn.eq(t._bn)}toBase58(){return he.encode(this.toBytes())}toJSON(){return this.toBase58()}toBytes(){const t=this.toBuffer();return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}toBuffer(){const t=this._bn.toArrayLike(Et.Buffer);if(t.length===rn)return t;const e=Et.Buffer.alloc(32);return t.copy(e,32-t.length),e}get[Symbol.toStringTag](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static createWithSeed(t,e,n){return H(this,null,function*(){const s=Et.Buffer.concat([t.toBuffer(),Et.Buffer.from(e),n.toBuffer()]),i=Eo(s);return new ht(i)})}static createProgramAddressSync(t,e){let n=Et.Buffer.alloc(0);t.forEach(function(i){if(i.length>Vp)throw new TypeError("Max seed length exceeded");n=Et.Buffer.concat([n,Pn(i)])}),n=Et.Buffer.concat([n,e.toBuffer(),Et.Buffer.from("ProgramDerivedAddress")]);const s=Eo(n);if(No(s))throw new Error("Invalid seeds, address must fall off the curve");return new ht(s)}static createProgramAddress(t,e){return H(this,null,function*(){return this.createProgramAddressSync(t,e)})}static findProgramAddressSync(t,e){let n=255,s;for(;n!=0;){try{const i=t.concat(Et.Buffer.from([n]));s=this.createProgramAddressSync(i,e)}catch(i){if(i instanceof TypeError)throw i;n--;continue}return[s,n]}throw new Error("Unable to find a viable program address nonce")}static findProgramAddress(t,e){return H(this,null,function*(){return this.findProgramAddressSync(t,e)})}static isOnCurve(t){const e=new ht(t);return No(e.toBytes())}}tc=ht;ht.default=new tc("11111111111111111111111111111111");Ir.set(ht,{kind:"struct",fields:[["_bn","u256"]]});new ht("BPFLoader1111111111111111111111111111111111");const Mn=1232,Ts=127,qr=64;class ec extends Error{constructor(t){super(`Signature ${t} has expired: block height exceeded.`),this.signature=void 0,this.signature=t}}Object.defineProperty(ec.prototype,"name",{value:"TransactionExpiredBlockheightExceededError"});class nc extends Error{constructor(t,e){super(`Transaction was not confirmed in ${e.toFixed(2)} seconds. It is unknown if it succeeded or failed. Check signature ${t} using the Solana Explorer or CLI tools.`),this.signature=void 0,this.signature=t}}Object.defineProperty(nc.prototype,"name",{value:"TransactionExpiredTimeoutError"});class jn extends Error{constructor(t){super(`Signature ${t} has expired: the nonce is no longer valid.`),this.signature=void 0,this.signature=t}}Object.defineProperty(jn.prototype,"name",{value:"TransactionExpiredNonceInvalidError"});class $r{constructor(t,e){this.staticAccountKeys=void 0,this.accountKeysFromLookups=void 0,this.staticAccountKeys=t,this.accountKeysFromLookups=e}keySegments(){const t=[this.staticAccountKeys];return this.accountKeysFromLookups&&(t.push(this.accountKeysFromLookups.writable),t.push(this.accountKeysFromLookups.readonly)),t}get(t){for(const e of this.keySegments()){if(t<e.length)return e[t];t-=e.length}}get length(){return this.keySegments().flat().length}compileInstructions(t){if(this.length>256)throw new Error("Account index overflow encountered during compilation");const n=new Map;this.keySegments().flat().forEach((i,o)=>{n.set(i.toBase58(),o)});const s=i=>{const o=n.get(i.toBase58());if(o===void 0)throw new Error("Encountered an unknown instruction account key during compilation");return o};return t.map(i=>({programIdIndex:s(i.programId),accountKeyIndexes:i.keys.map(o=>s(o.pubkey)),data:i.data}))}}const Rt=(r="publicKey")=>B.blob(32,r),Kp=(r="signature")=>B.blob(64,r),Bn=(r="string")=>{const t=B.struct([B.u32("length"),B.u32("lengthPadding"),B.blob(B.offset(B.u32(),-8),"chars")],r),e=t.decode.bind(t),n=t.encode.bind(t),s=t;return s.decode=(i,o)=>e(i,o).chars.toString(),s.encode=(i,o,c)=>{const d={chars:Et.Buffer.from(i,"utf8")};return n(d,o,c)},s.alloc=i=>B.u32().span+B.u32().span+Et.Buffer.from(i,"utf8").length,s},Hp=(r="authorized")=>B.struct([Rt("staker"),Rt("withdrawer")],r),Wp=(r="lockup")=>B.struct([B.ns64("unixTimestamp"),B.ns64("epoch"),Rt("custodian")],r),jp=(r="voteInit")=>B.struct([Rt("nodePubkey"),Rt("authorizedVoter"),Rt("authorizedWithdrawer"),B.u8("commission")],r),Xp=(r="voteAuthorizeWithSeedArgs")=>B.struct([B.u32("voteAuthorizationType"),Rt("currentAuthorityDerivedKeyOwnerPubkey"),Bn("currentAuthorityDerivedKeySeed"),Rt("newAuthorized")],r);function Oe(r){let t=0,e=0;for(;;){let n=r.shift();if(t|=(n&127)<<e*7,e+=1,(n&128)===0)break}return t}function xe(r,t){let e=t;for(;;){let n=e&127;if(e>>=7,e==0){r.push(n);break}else n|=128,r.push(n)}}function kt(r,t){if(!r)throw new Error(t||"Assertion failed")}class Qr{constructor(t,e){this.payer=void 0,this.keyMetaMap=void 0,this.payer=t,this.keyMetaMap=e}static compile(t,e){const n=new Map,s=o=>{const c=o.toBase58();let d=n.get(c);return d===void 0&&(d={isSigner:!1,isWritable:!1,isInvoked:!1},n.set(c,d)),d},i=s(e);i.isSigner=!0,i.isWritable=!0;for(const o of t){s(o.programId).isInvoked=!0;for(const c of o.keys){const d=s(c.pubkey);d.isSigner||(d.isSigner=c.isSigner),d.isWritable||(d.isWritable=c.isWritable)}}return new Qr(e,n)}getMessageComponents(){const t=[...this.keyMetaMap.entries()];kt(t.length<=256,"Max static account keys length exceeded");const e=t.filter(([,d])=>d.isSigner&&d.isWritable),n=t.filter(([,d])=>d.isSigner&&!d.isWritable),s=t.filter(([,d])=>!d.isSigner&&d.isWritable),i=t.filter(([,d])=>!d.isSigner&&!d.isWritable),o={numRequiredSignatures:e.length+n.length,numReadonlySignedAccounts:n.length,numReadonlyUnsignedAccounts:i.length};{kt(e.length>0,"Expected at least one writable signer key");const[d]=e[0];kt(d===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}const c=[...e.map(([d])=>new ht(d)),...n.map(([d])=>new ht(d)),...s.map(([d])=>new ht(d)),...i.map(([d])=>new ht(d))];return[o,c]}extractTableLookup(t){const[e,n]=this.drainKeysFoundInLookupTable(t.state.addresses,o=>!o.isSigner&&!o.isInvoked&&o.isWritable),[s,i]=this.drainKeysFoundInLookupTable(t.state.addresses,o=>!o.isSigner&&!o.isInvoked&&!o.isWritable);if(!(e.length===0&&s.length===0))return[{accountKey:t.key,writableIndexes:e,readonlyIndexes:s},{writable:n,readonly:i}]}drainKeysFoundInLookupTable(t,e){const n=new Array,s=new Array;for(const[i,o]of this.keyMetaMap.entries())if(e(o)){const c=new ht(i),d=t.findIndex(_=>_.equals(c));d>=0&&(kt(d<256,"Max lookup table index exceeded"),n.push(d),s.push(c),this.keyMetaMap.delete(i))}return[n,s]}}const rc="Reached end of buffer unexpectedly";function He(r){if(r.length===0)throw new Error(rc);return r.shift()}function Ne(r,...t){var n;const[e]=t;if(t.length===2?e+((n=t[1])!=null?n:0)>r.length:e>=r.length)throw new Error(rc);return r.splice(...t)}class je{constructor(t){this.header=void 0,this.accountKeys=void 0,this.recentBlockhash=void 0,this.instructions=void 0,this.indexToProgramIds=new Map,this.header=t.header,this.accountKeys=t.accountKeys.map(e=>new ht(e)),this.recentBlockhash=t.recentBlockhash,this.instructions=t.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(t=>({programIdIndex:t.programIdIndex,accountKeyIndexes:t.accounts,data:he.decode(t.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new $r(this.staticAccountKeys)}static compile(t){const e=Qr.compile(t.instructions,t.payerKey),[n,s]=e.getMessageComponents(),o=new $r(s).compileInstructions(t.instructions).map(c=>({programIdIndex:c.programIdIndex,accounts:c.accountKeyIndexes,data:he.encode(c.data)}));return new je({header:n,accountKeys:s,recentBlockhash:t.recentBlockhash,instructions:o})}isAccountSigner(t){return t<this.header.numRequiredSignatures}isAccountWritable(t){const e=this.header.numRequiredSignatures;if(t>=this.header.numRequiredSignatures){const n=t-e,i=this.accountKeys.length-e-this.header.numReadonlyUnsignedAccounts;return n<i}else{const n=e-this.header.numReadonlySignedAccounts;return t<n}}isProgramId(t){return this.indexToProgramIds.has(t)}programIds(){return[...this.indexToProgramIds.values()]}nonProgramIds(){return this.accountKeys.filter((t,e)=>!this.isProgramId(e))}serialize(){const t=this.accountKeys.length;let e=[];xe(e,t);const n=this.instructions.map(O=>{const{accounts:x,programIdIndex:S}=O,T=Array.from(he.decode(O.data));let C=[];xe(C,x.length);let M=[];return xe(M,T.length),{programIdIndex:S,keyIndicesCount:Et.Buffer.from(C),keyIndices:x,dataLength:Et.Buffer.from(M),data:T}});let s=[];xe(s,n.length);let i=Et.Buffer.alloc(Mn);Et.Buffer.from(s).copy(i);let o=s.length;n.forEach(O=>{const S=B.struct([B.u8("programIdIndex"),B.blob(O.keyIndicesCount.length,"keyIndicesCount"),B.seq(B.u8("keyIndex"),O.keyIndices.length,"keyIndices"),B.blob(O.dataLength.length,"dataLength"),B.seq(B.u8("userdatum"),O.data.length,"data")]).encode(O,i,o);o+=S}),i=i.slice(0,o);const c=B.struct([B.blob(1,"numRequiredSignatures"),B.blob(1,"numReadonlySignedAccounts"),B.blob(1,"numReadonlyUnsignedAccounts"),B.blob(e.length,"keyCount"),B.seq(Rt("key"),t,"keys"),Rt("recentBlockhash")]),d={numRequiredSignatures:Et.Buffer.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:Et.Buffer.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:Et.Buffer.from([this.header.numReadonlyUnsignedAccounts]),keyCount:Et.Buffer.from(e),keys:this.accountKeys.map(O=>Pn(O.toBytes())),recentBlockhash:he.decode(this.recentBlockhash)};let _=Et.Buffer.alloc(2048);const b=c.encode(d,_);return i.copy(_,b),_.slice(0,b+i.length)}static from(t){let e=[...t];const n=He(e);if(n!==(n&Ts))throw new Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");const s=He(e),i=He(e),o=Oe(e);let c=[];for(let x=0;x<o;x++){const S=Ne(e,0,rn);c.push(new ht(Et.Buffer.from(S)))}const d=Ne(e,0,rn),_=Oe(e);let b=[];for(let x=0;x<_;x++){const S=He(e),T=Oe(e),C=Ne(e,0,T),M=Oe(e),P=Ne(e,0,M),W=he.encode(Et.Buffer.from(P));b.push({programIdIndex:S,accounts:C,data:W})}const O={header:{numRequiredSignatures:n,numReadonlySignedAccounts:s,numReadonlyUnsignedAccounts:i},recentBlockhash:he.encode(Et.Buffer.from(d)),accountKeys:c,instructions:b};return new je(O)}}class er{constructor(t){this.header=void 0,this.staticAccountKeys=void 0,this.recentBlockhash=void 0,this.compiledInstructions=void 0,this.addressTableLookups=void 0,this.header=t.header,this.staticAccountKeys=t.staticAccountKeys,this.recentBlockhash=t.recentBlockhash,this.compiledInstructions=t.compiledInstructions,this.addressTableLookups=t.addressTableLookups}get version(){return 0}get numAccountKeysFromLookups(){let t=0;for(const e of this.addressTableLookups)t+=e.readonlyIndexes.length+e.writableIndexes.length;return t}getAccountKeys(t){let e;if(t&&"accountKeysFromLookups"in t&&t.accountKeysFromLookups){if(this.numAccountKeysFromLookups!=t.accountKeysFromLookups.writable.length+t.accountKeysFromLookups.readonly.length)throw new Error("Failed to get account keys because of a mismatch in the number of account keys from lookups");e=t.accountKeysFromLookups}else if(t&&"addressLookupTableAccounts"in t&&t.addressLookupTableAccounts)e=this.resolveAddressTableLookups(t.addressLookupTableAccounts);else if(this.addressTableLookups.length>0)throw new Error("Failed to get account keys because address table lookups were not resolved");return new $r(this.staticAccountKeys,e)}isAccountSigner(t){return t<this.header.numRequiredSignatures}isAccountWritable(t){const e=this.header.numRequiredSignatures,n=this.staticAccountKeys.length;if(t>=n){const s=t-n,i=this.addressTableLookups.reduce((o,c)=>o+c.writableIndexes.length,0);return s<i}else if(t>=this.header.numRequiredSignatures){const s=t-e,o=n-e-this.header.numReadonlyUnsignedAccounts;return s<o}else{const s=e-this.header.numReadonlySignedAccounts;return t<s}}resolveAddressTableLookups(t){const e={writable:[],readonly:[]};for(const n of this.addressTableLookups){const s=t.find(i=>i.key.equals(n.accountKey));if(!s)throw new Error(`Failed to find address lookup table account for table key ${n.accountKey.toBase58()}`);for(const i of n.writableIndexes)if(i<s.state.addresses.length)e.writable.push(s.state.addresses[i]);else throw new Error(`Failed to find address for index ${i} in address lookup table ${n.accountKey.toBase58()}`);for(const i of n.readonlyIndexes)if(i<s.state.addresses.length)e.readonly.push(s.state.addresses[i]);else throw new Error(`Failed to find address for index ${i} in address lookup table ${n.accountKey.toBase58()}`)}return e}static compile(t){const e=Qr.compile(t.instructions,t.payerKey),n=new Array,s={writable:new Array,readonly:new Array},i=t.addressLookupTableAccounts||[];for(const b of i){const O=e.extractTableLookup(b);if(O!==void 0){const[x,{writable:S,readonly:T}]=O;n.push(x),s.writable.push(...S),s.readonly.push(...T)}}const[o,c]=e.getMessageComponents(),_=new $r(c,s).compileInstructions(t.instructions);return new er({header:o,staticAccountKeys:c,recentBlockhash:t.recentBlockhash,compiledInstructions:_,addressTableLookups:n})}serialize(){const t=Array();xe(t,this.staticAccountKeys.length);const e=this.serializeInstructions(),n=Array();xe(n,this.compiledInstructions.length);const s=this.serializeAddressTableLookups(),i=Array();xe(i,this.addressTableLookups.length);const o=B.struct([B.u8("prefix"),B.struct([B.u8("numRequiredSignatures"),B.u8("numReadonlySignedAccounts"),B.u8("numReadonlyUnsignedAccounts")],"header"),B.blob(t.length,"staticAccountKeysLength"),B.seq(Rt(),this.staticAccountKeys.length,"staticAccountKeys"),Rt("recentBlockhash"),B.blob(n.length,"instructionsLength"),B.blob(e.length,"serializedInstructions"),B.blob(i.length,"addressTableLookupsLength"),B.blob(s.length,"serializedAddressTableLookups")]),c=new Uint8Array(Mn),_=o.encode({prefix:128,header:this.header,staticAccountKeysLength:new Uint8Array(t),staticAccountKeys:this.staticAccountKeys.map(b=>b.toBytes()),recentBlockhash:he.decode(this.recentBlockhash),instructionsLength:new Uint8Array(n),serializedInstructions:e,addressTableLookupsLength:new Uint8Array(i),serializedAddressTableLookups:s},c);return c.slice(0,_)}serializeInstructions(){let t=0;const e=new Uint8Array(Mn);for(const n of this.compiledInstructions){const s=Array();xe(s,n.accountKeyIndexes.length);const i=Array();xe(i,n.data.length);const o=B.struct([B.u8("programIdIndex"),B.blob(s.length,"encodedAccountKeyIndexesLength"),B.seq(B.u8(),n.accountKeyIndexes.length,"accountKeyIndexes"),B.blob(i.length,"encodedDataLength"),B.blob(n.data.length,"data")]);t+=o.encode({programIdIndex:n.programIdIndex,encodedAccountKeyIndexesLength:new Uint8Array(s),accountKeyIndexes:n.accountKeyIndexes,encodedDataLength:new Uint8Array(i),data:n.data},e,t)}return e.slice(0,t)}serializeAddressTableLookups(){let t=0;const e=new Uint8Array(Mn);for(const n of this.addressTableLookups){const s=Array();xe(s,n.writableIndexes.length);const i=Array();xe(i,n.readonlyIndexes.length);const o=B.struct([Rt("accountKey"),B.blob(s.length,"encodedWritableIndexesLength"),B.seq(B.u8(),n.writableIndexes.length,"writableIndexes"),B.blob(i.length,"encodedReadonlyIndexesLength"),B.seq(B.u8(),n.readonlyIndexes.length,"readonlyIndexes")]);t+=o.encode({accountKey:n.accountKey.toBytes(),encodedWritableIndexesLength:new Uint8Array(s),writableIndexes:n.writableIndexes,encodedReadonlyIndexesLength:new Uint8Array(i),readonlyIndexes:n.readonlyIndexes},e,t)}return e.slice(0,t)}static deserialize(t){let e=[...t];const n=He(e),s=n&Ts;kt(n!==s,"Expected versioned message but received legacy message");const i=s;kt(i===0,`Expected versioned message with version 0 but found version ${i}`);const o={numRequiredSignatures:He(e),numReadonlySignedAccounts:He(e),numReadonlyUnsignedAccounts:He(e)},c=[],d=Oe(e);for(let T=0;T<d;T++)c.push(new ht(Ne(e,0,rn)));const _=he.encode(Ne(e,0,rn)),b=Oe(e),O=[];for(let T=0;T<b;T++){const C=He(e),M=Oe(e),P=Ne(e,0,M),W=Oe(e),z=new Uint8Array(Ne(e,0,W));O.push({programIdIndex:C,accountKeyIndexes:P,data:z})}const x=Oe(e),S=[];for(let T=0;T<x;T++){const C=new ht(Ne(e,0,rn)),M=Oe(e),P=Ne(e,0,M),W=Oe(e),z=Ne(e,0,W);S.push({accountKey:C,writableIndexes:P,readonlyIndexes:z})}return new er({header:o,staticAccountKeys:c,recentBlockhash:_,compiledInstructions:O,addressTableLookups:S})}}const ic={deserializeMessageVersion(r){const t=r[0],e=t&Ts;return e===t?"legacy":e},deserialize:r=>{const t=ic.deserializeMessageVersion(r);if(t==="legacy")return je.from(r);if(t===0)return er.deserialize(r);throw new Error(`Transaction message version ${t} deserialization is not supported`)}};let tn=(function(r){return r[r.BLOCKHEIGHT_EXCEEDED=0]="BLOCKHEIGHT_EXCEEDED",r[r.PROCESSED=1]="PROCESSED",r[r.TIMED_OUT=2]="TIMED_OUT",r[r.NONCE_INVALID=3]="NONCE_INVALID",r})({});const Yp=Et.Buffer.alloc(qr).fill(0);class Bo{constructor(t){this.keys=void 0,this.programId=void 0,this.data=Et.Buffer.alloc(0),this.programId=t.programId,this.keys=t.keys,t.data&&(this.data=t.data)}toJSON(){return{keys:this.keys.map(({pubkey:t,isSigner:e,isWritable:n})=>({pubkey:t.toJSON(),isSigner:e,isWritable:n})),programId:this.programId.toJSON(),data:[...this.data]}}}class Te{get signature(){return this.signatures.length>0?this.signatures[0].signature:null}constructor(t){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,!!t)if(t.feePayer&&(this.feePayer=t.feePayer),t.signatures&&(this.signatures=t.signatures),Object.prototype.hasOwnProperty.call(t,"nonceInfo")){const{minContextSlot:e,nonceInfo:n}=t;this.minNonceContextSlot=e,this.nonceInfo=n}else if(Object.prototype.hasOwnProperty.call(t,"lastValidBlockHeight")){const{blockhash:e,lastValidBlockHeight:n}=t;this.recentBlockhash=e,this.lastValidBlockHeight=n}else{const{recentBlockhash:e,nonceInfo:n}=t;n&&(this.nonceInfo=n),this.recentBlockhash=e}}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(t=>t.toJSON()),signers:this.signatures.map(({publicKey:t})=>t.toJSON())}}add(...t){if(t.length===0)throw new Error("No instructions");return t.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 Bo(e))}),this}compileMessage(){if(this._message&&JSON.stringify(this.toJSON())===JSON.stringify(this._json))return this._message;let t,e;if(this.nonceInfo?(t=this.nonceInfo.nonce,this.instructions[0]!=this.nonceInfo.nonceInstruction?e=[this.nonceInfo.nonceInstruction,...this.instructions]:e=this.instructions):(t=this.recentBlockhash,e=this.instructions),!t)throw new Error("Transaction recentBlockhash required");e.length<1&&console.warn("No instructions provided");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 new Error("Transaction fee payer required");for(let C=0;C<e.length;C++)if(e[C].programId===void 0)throw new Error(`Transaction instruction index ${C} has undefined program id`);const s=[],i=[];e.forEach(C=>{C.keys.forEach(P=>{i.push(lt({},P))});const M=C.programId.toString();s.includes(M)||s.push(M)}),s.forEach(C=>{i.push({pubkey:new ht(C),isSigner:!1,isWritable:!1})});const o=[];i.forEach(C=>{const M=C.pubkey.toString(),P=o.findIndex(W=>W.pubkey.toString()===M);P>-1?(o[P].isWritable=o[P].isWritable||C.isWritable,o[P].isSigner=o[P].isSigner||C.isSigner):o.push(C)}),o.sort(function(C,M){if(C.isSigner!==M.isSigner)return C.isSigner?-1:1;if(C.isWritable!==M.isWritable)return C.isWritable?-1:1;const P={localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"};return C.pubkey.toBase58().localeCompare(M.pubkey.toBase58(),"en",P)});const c=o.findIndex(C=>C.pubkey.equals(n));if(c>-1){const[C]=o.splice(c,1);C.isSigner=!0,C.isWritable=!0,o.unshift(C)}else o.unshift({pubkey:n,isSigner:!0,isWritable:!0});for(const C of this.signatures){const M=o.findIndex(P=>P.pubkey.equals(C.publicKey));if(M>-1)o[M].isSigner||(o[M].isSigner=!0,console.warn("Transaction references a signature that is unnecessary, only the fee payer and instruction signer accounts should sign a transaction. This behavior is deprecated and will throw an error in the next major version release."));else throw new Error(`unknown signer: ${C.publicKey.toString()}`)}let d=0,_=0,b=0;const O=[],x=[];o.forEach(({pubkey:C,isSigner:M,isWritable:P})=>{M?(O.push(C.toString()),d+=1,P||(_+=1)):(x.push(C.toString()),P||(b+=1))});const S=O.concat(x),T=e.map(C=>{const{data:M,programId:P}=C;return{programIdIndex:S.indexOf(P.toString()),accounts:C.keys.map(W=>S.indexOf(W.pubkey.toString())),data:he.encode(M)}});return T.forEach(C=>{kt(C.programIdIndex>=0),C.accounts.forEach(M=>kt(M>=0))}),new je({header:{numRequiredSignatures:d,numReadonlySignedAccounts:_,numReadonlyUnsignedAccounts:b},accountKeys:S,recentBlockhash:t,instructions:T})}_compile(){const t=this.compileMessage(),e=t.accountKeys.slice(0,t.header.numRequiredSignatures);return this.signatures.length===e.length&&this.signatures.every((s,i)=>e[i].equals(s.publicKey))||(this.signatures=e.map(n=>({signature:null,publicKey:n}))),t}serializeMessage(){return this._compile().serialize()}getEstimatedFee(t){return H(this,null,function*(){return(yield t.getFeeForMessage(this.compileMessage())).value})}setSigners(...t){if(t.length===0)throw new Error("No signers");const e=new Set;this.signatures=t.filter(n=>{const s=n.toString();return e.has(s)?!1:(e.add(s),!0)}).map(n=>({signature:null,publicKey:n}))}sign(...t){if(t.length===0)throw new Error("No signers");const e=new Set,n=[];for(const i of t){const o=i.publicKey.toString();e.has(o)||(e.add(o),n.push(i))}this.signatures=n.map(i=>({signature:null,publicKey:i.publicKey}));const s=this._compile();this._partialSign(s,...n)}partialSign(...t){if(t.length===0)throw new Error("No signers");const e=new Set,n=[];for(const i of t){const o=i.publicKey.toString();e.has(o)||(e.add(o),n.push(i))}const s=this._compile();this._partialSign(s,...n)}_partialSign(t,...e){const n=t.serialize();e.forEach(s=>{const i=Qa(n,s.secretKey);this._addSignature(s.publicKey,Pn(i))})}addSignature(t,e){this._compile(),this._addSignature(t,e)}_addSignature(t,e){kt(e.length===64);const n=this.signatures.findIndex(s=>t.equals(s.publicKey));if(n<0)throw new Error(`unknown signer: ${t.toString()}`);this.signatures[n].signature=Et.Buffer.from(e)}verifySignatures(t=!0){return!this._getMessageSignednessErrors(this.serializeMessage(),t)}_getMessageSignednessErrors(t,e){const n={};for(const{signature:s,publicKey:i}of this.signatures)s===null?e&&(n.missing||(n.missing=[])).push(i):$p(s,t,i.toBytes())||(n.invalid||(n.invalid=[])).push(i);return n.invalid||n.missing?n:void 0}serialize(t){const{requireAllSignatures:e,verifySignatures:n}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},t),s=this.serializeMessage();if(n){const i=this._getMessageSignednessErrors(s,e);if(i){let o="Signature verification failed.";throw i.invalid&&(o+=`
|
|
88
|
+
Invalid signature for public key${i.invalid.length===1?"":"(s)"} [\`${i.invalid.map(c=>c.toBase58()).join("`, `")}\`].`),i.missing&&(o+=`
|
|
89
|
+
Missing signature for public key${i.missing.length===1?"":"(s)"} [\`${i.missing.map(c=>c.toBase58()).join("`, `")}\`].`),new Error(o)}}return this._serialize(s)}_serialize(t){const{signatures:e}=this,n=[];xe(n,e.length);const s=n.length+e.length*64+t.length,i=Et.Buffer.alloc(s);return kt(e.length<256),Et.Buffer.from(n).copy(i,0),e.forEach(({signature:o},c)=>{o!==null&&(kt(o.length===64,"signature has invalid length"),Et.Buffer.from(o).copy(i,n.length+c*64))}),t.copy(i,n.length+e.length*64),kt(i.length<=Mn,`Transaction too large: ${i.length} > ${Mn}`),i}get keys(){return kt(this.instructions.length===1),this.instructions[0].keys.map(t=>t.pubkey)}get programId(){return kt(this.instructions.length===1),this.instructions[0].programId}get data(){return kt(this.instructions.length===1),this.instructions[0].data}static from(t){let e=[...t];const n=Oe(e);let s=[];for(let i=0;i<n;i++){const o=Ne(e,0,qr);s.push(he.encode(Et.Buffer.from(o)))}return Te.populate(je.from(e),s)}static populate(t,e=[]){const n=new Te;return n.recentBlockhash=t.recentBlockhash,t.header.numRequiredSignatures>0&&(n.feePayer=t.accountKeys[0]),e.forEach((s,i)=>{const o={signature:s==he.encode(Yp)?null:he.decode(s),publicKey:t.accountKeys[i]};n.signatures.push(o)}),t.instructions.forEach(s=>{const i=s.accounts.map(o=>{const c=t.accountKeys[o];return{pubkey:c,isSigner:n.signatures.some(d=>d.publicKey.toString()===c.toString())||t.isAccountSigner(o),isWritable:t.isAccountWritable(o)}});n.instructions.push(new Bo({keys:i,programId:t.accountKeys[s.programIdIndex],data:he.decode(s.data)}))}),n._message=t,n._json=n.toJSON(),n}}class pn{get version(){return this.message.version}constructor(t,e){if(this.signatures=void 0,this.message=void 0,e!==void 0)kt(e.length===t.header.numRequiredSignatures,"Expected signatures length to be equal to the number of required signatures"),this.signatures=e;else{const n=[];for(let s=0;s<t.header.numRequiredSignatures;s++)n.push(new Uint8Array(qr));this.signatures=n}this.message=t}serialize(){const t=this.message.serialize(),e=Array();xe(e,this.signatures.length);const n=B.struct([B.blob(e.length,"encodedSignaturesLength"),B.seq(Kp(),this.signatures.length,"signatures"),B.blob(t.length,"serializedMessage")]),s=new Uint8Array(2048),i=n.encode({encodedSignaturesLength:new Uint8Array(e),signatures:this.signatures,serializedMessage:t},s);return s.slice(0,i)}static deserialize(t){let e=[...t];const n=[],s=Oe(e);for(let o=0;o<s;o++)n.push(new Uint8Array(Ne(e,0,qr)));const i=ic.deserialize(new Uint8Array(e));return new pn(i,n)}sign(t){const e=this.message.serialize(),n=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures);for(const s of t){const i=n.findIndex(o=>o.equals(s.publicKey));kt(i>=0,`Cannot sign with non signer key ${s.publicKey.toBase58()}`),this.signatures[i]=Qa(e,s.secretKey)}}addSignature(t,e){kt(e.byteLength===64,"Signature must be 64 bytes long");const s=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures).findIndex(i=>i.equals(t));kt(s>=0,`Can not add signature; \`${t.toBase58()}\` is not required to sign this transaction`),this.signatures[s]=e}}const Zp=160,Jp=64,Qp=Zp/Jp,tg=1e3/Qp;new ht("SysvarC1ock11111111111111111111111111111111");new ht("SysvarEpochSchedu1e111111111111111111111111");new ht("Sysvar1nstructions1111111111111111111111111");new ht("SysvarRecentB1ockHashes11111111111111111111");new ht("SysvarRent111111111111111111111111111111111");new ht("SysvarRewards111111111111111111111111111111");new ht("SysvarS1otHashes111111111111111111111111111");new ht("SysvarS1otHistory11111111111111111111111111");new ht("SysvarStakeHistory1111111111111111111111111");class Co extends Error{constructor({action:t,signature:e,transactionMessage:n,logs:s}){const i=s?`Logs:
|
|
90
|
+
${JSON.stringify(s.slice(-10),null,2)}. `:"",o="\nCatch the `SendTransactionError` and call `getLogs()` on it for full details.";let c;switch(t){case"send":c=`Transaction ${e} resulted in an error.
|
|
91
|
+
${n}. `+i+o;break;case"simulate":c=`Simulation failed.
|
|
92
|
+
Message: ${n}.
|
|
93
|
+
`+i+o;break;default:c=`Unknown action '${(d=>d)(t)}'`}super(c),this.signature=void 0,this.transactionMessage=void 0,this.transactionLogs=void 0,this.signature=e,this.transactionMessage=n,this.transactionLogs=s||void 0}get transactionError(){return{message:this.transactionMessage,logs:Array.isArray(this.transactionLogs)?this.transactionLogs:void 0}}get logs(){const t=this.transactionLogs;if(!(t!=null&&typeof t=="object"&&"then"in t))return t}getLogs(t){return H(this,null,function*(){return Array.isArray(this.transactionLogs)||(this.transactionLogs=new Promise((e,n)=>{t.getTransaction(this.signature).then(s=>{if(s&&s.meta&&s.meta.logMessages){const i=s.meta.logMessages;this.transactionLogs=i,e(i)}else n(new Error("Log messages not found"))}).catch(n)})),yield this.transactionLogs})}}class at extends Error{constructor({code:t,message:e,data:n},s){super(s!=null?`${s}: ${e}`:e),this.code=void 0,this.data=void 0,this.code=t,this.data=n,this.name="SolanaJSONRPCError"}}function On(r){return new Promise(t=>setTimeout(t,r))}const eg=B.nu64("lamportsPerSignature"),sc=B.struct([B.u32("version"),B.u32("state"),Rt("authorizedPubkey"),Rt("nonce"),B.struct([eg],"feeCalculator")]);sc.span;class Bs{constructor(t){this.authorizedPubkey=void 0,this.nonce=void 0,this.feeCalculator=void 0,this.authorizedPubkey=t.authorizedPubkey,this.nonce=t.nonce,this.feeCalculator=t.feeCalculator}static fromAccountData(t){const e=sc.decode(Pn(t),0);return new Bs({authorizedPubkey:new ht(e.authorizedPubkey),nonce:new ht(e.nonce).toString(),feeCalculator:e.feeCalculator})}}function Fn(r){const t=B.blob(8,r),e=t.decode.bind(t),n=t.encode.bind(t),s=t,i=K0();return s.decode=(o,c)=>{const d=e(o,c);return i.decode(d)},s.encode=(o,c,d)=>{const _=i.encode(o);return n(_,c,d)},s}Object.freeze({Create:{index:0,layout:B.struct([B.u32("instruction"),B.ns64("lamports"),B.ns64("space"),Rt("programId")])},Assign:{index:1,layout:B.struct([B.u32("instruction"),Rt("programId")])},Transfer:{index:2,layout:B.struct([B.u32("instruction"),Fn("lamports")])},CreateWithSeed:{index:3,layout:B.struct([B.u32("instruction"),Rt("base"),Bn("seed"),B.ns64("lamports"),B.ns64("space"),Rt("programId")])},AdvanceNonceAccount:{index:4,layout:B.struct([B.u32("instruction")])},WithdrawNonceAccount:{index:5,layout:B.struct([B.u32("instruction"),B.ns64("lamports")])},InitializeNonceAccount:{index:6,layout:B.struct([B.u32("instruction"),Rt("authorized")])},AuthorizeNonceAccount:{index:7,layout:B.struct([B.u32("instruction"),Rt("authorized")])},Allocate:{index:8,layout:B.struct([B.u32("instruction"),B.ns64("space")])},AllocateWithSeed:{index:9,layout:B.struct([B.u32("instruction"),Rt("base"),Bn("seed"),B.ns64("space"),Rt("programId")])},AssignWithSeed:{index:10,layout:B.struct([B.u32("instruction"),Rt("base"),Bn("seed"),Rt("programId")])},TransferWithSeed:{index:11,layout:B.struct([B.u32("instruction"),Fn("lamports"),Bn("seed"),Rt("programId")])},UpgradeNonceAccount:{index:12,layout:B.struct([B.u32("instruction")])}});new ht("11111111111111111111111111111111");new ht("BPFLoader2111111111111111111111111111111111");function ng(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Ki,Lo;function rg(){if(Lo)return Ki;Lo=1;var r=Object.prototype.toString,t=Object.keys||function(n){var s=[];for(var i in n)s.push(i);return s};function e(n,s){var i,o,c,d,_,b,O;if(n===!0)return"true";if(n===!1)return"false";switch(typeof n){case"object":if(n===null)return null;if(n.toJSON&&typeof n.toJSON=="function")return e(n.toJSON(),s);if(O=r.call(n),O==="[object Array]"){for(c="[",o=n.length-1,i=0;i<o;i++)c+=e(n[i],!0)+",";return o>-1&&(c+=e(n[i],!0)),c+"]"}else if(O==="[object Object]"){for(d=t(n).sort(),o=d.length,c="",i=0;i<o;)_=d[i],b=e(n[_],!1),b!==void 0&&(c&&(c+=","),c+=JSON.stringify(_)+":"+b),i++;return"{"+c+"}"}else return JSON.stringify(n);case"function":case"undefined":return s?null:void 0;case"string":return JSON.stringify(n);default:return isFinite(n)?n:null}}return Ki=function(n){var s=e(n,!1);if(s!==void 0)return""+s},Ki}var ig=rg(),Mo=ng(ig);const Kn=32;function Hi(r){let t=0;for(;r>1;)r/=2,t++;return t}function sg(r){return r===0?1:(r--,r|=r>>1,r|=r>>2,r|=r>>4,r|=r>>8,r|=r>>16,r|=r>>32,r+1)}class og{constructor(t,e,n,s,i){this.slotsPerEpoch=void 0,this.leaderScheduleSlotOffset=void 0,this.warmup=void 0,this.firstNormalEpoch=void 0,this.firstNormalSlot=void 0,this.slotsPerEpoch=t,this.leaderScheduleSlotOffset=e,this.warmup=n,this.firstNormalEpoch=s,this.firstNormalSlot=i}getEpoch(t){return this.getEpochAndSlotIndex(t)[0]}getEpochAndSlotIndex(t){if(t<this.firstNormalSlot){const e=Hi(sg(t+Kn+1))-Hi(Kn)-1,n=this.getSlotsInEpoch(e),s=t-(n-Kn);return[e,s]}else{const e=t-this.firstNormalSlot,n=Math.floor(e/this.slotsPerEpoch),s=this.firstNormalEpoch+n,i=e%this.slotsPerEpoch;return[s,i]}}getFirstSlotInEpoch(t){return t<=this.firstNormalEpoch?(Math.pow(2,t)-1)*Kn:(t-this.firstNormalEpoch)*this.slotsPerEpoch+this.firstNormalSlot}getLastSlotInEpoch(t){return this.getFirstSlotInEpoch(t)+this.getSlotsInEpoch(t)-1}getSlotsInEpoch(t){return t<this.firstNormalEpoch?Math.pow(2,t+Hi(Kn)):this.slotsPerEpoch}}var ag=globalThis.fetch;class cg extends Ip{constructor(t,e,n){const s=i=>{const o=Sp(i,lt({autoconnect:!0,max_reconnects:5,reconnect:!0,reconnect_interval:1e3},e));return"socket"in o?this.underlyingSocket=o.socket:this.underlyingSocket=o,o};super(s,t,e,n),this.underlyingSocket=void 0}call(...t){var n;const e=(n=this.underlyingSocket)==null?void 0:n.readyState;return e===1?super.call(...t):Promise.reject(new Error("Tried to call a JSON-RPC method `"+t[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+e+")"))}notify(...t){var n;const e=(n=this.underlyingSocket)==null?void 0:n.readyState;return e===1?super.notify(...t):Promise.reject(new Error("Tried to send a JSON-RPC notification `"+t[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+e+")"))}}function ug(r,t){let e;try{e=r.layout.decode(t)}catch(n){throw new Error("invalid instruction; "+n)}if(e.typeIndex!==r.index)throw new Error(`invalid account data; account type mismatch ${e.typeIndex} != ${r.index}`);return e}const ko=56;class Uo{constructor(t){this.key=void 0,this.state=void 0,this.key=t.key,this.state=t.state}isActive(){const t=BigInt("0xffffffffffffffff");return this.state.deactivationSlot===t}static deserialize(t){const e=ug(lg,t),n=t.length-ko;kt(n>=0,"lookup table is invalid"),kt(n%32===0,"lookup table is invalid");const s=n/32,{addresses:i}=B.struct([B.seq(Rt(),s,"addresses")]).decode(t.slice(ko));return{deactivationSlot:e.deactivationSlot,lastExtendedSlot:e.lastExtendedSlot,lastExtendedSlotStartIndex:e.lastExtendedStartIndex,authority:e.authority.length!==0?new ht(e.authority[0]):void 0,addresses:i.map(o=>new ht(o))}}}const lg={index:1,layout:B.struct([B.u32("typeIndex"),Fn("deactivationSlot"),B.nu64("lastExtendedSlot"),B.u8("lastExtendedStartIndex"),B.u8(),B.seq(Rt(),B.offset(B.u8(),-1),"authority")])},fg=/^[^:]+:\/\/([^:[]+|\[[^\]]+\])(:\d+)?(.*)/i;function hg(r){const t=r.match(fg);if(t==null)throw TypeError(`Failed to validate endpoint URL \`${r}\``);const[e,n,s,i]=t,o=r.startsWith("https:")?"wss:":"ws:",c=s==null?null:parseInt(s.slice(1),10),d=c==null?"":`:${c+1}`;return`${o}//${n}${d}${i}`}const Pt=ur(Os(ht),J(),r=>new ht(r)),oc=xs([J(),Dt("base64")]),Cs=ur(Os(Et.Buffer),oc,r=>Et.Buffer.from(r[0],"base64")),dg=30*1e3;function pg(r){if(/^https?:/.test(r)===!1)throw new TypeError("Endpoint URL must start with `http:` or `https:`.");return r}function Nt(r){let t,e;if(typeof r=="string")t=r;else if(r){const n=r,{commitment:s}=n,i=qe(n,["commitment"]);t=s,e=i}return{commitment:t,config:e}}function Do(r){return r.map(t=>{var e;return"memcmp"in t?yt(lt({},t),{memcmp:yt(lt({},t.memcmp),{encoding:(e=t.memcmp.encoding)!=null?e:"base58"})}):t})}function ac(r){return be([Y({jsonrpc:Dt("2.0"),id:J(),result:r}),Y({jsonrpc:Dt("2.0"),id:J(),error:Y({code:qn(),message:J(),data:ut(J0())})})])}const gg=ac(qn());function wt(r){return ur(ac(r),gg,t=>"error"in t?t:yt(lt({},t),{result:tt(t.result,r)}))}function Kt(r){return wt(Y({context:Y({slot:$()}),value:r}))}function ti(r){return Y({context:Y({slot:$()}),value:r})}function Wi(r,t){return r===0?new er({header:t.header,staticAccountKeys:t.accountKeys.map(e=>new ht(e)),recentBlockhash:t.recentBlockhash,compiledInstructions:t.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:he.decode(e.data)})),addressTableLookups:t.addressTableLookups}):new je(t)}const _g=Y({foundation:$(),foundationTerm:$(),initial:$(),taper:$(),terminal:$()}),mg=wt(nt(rt(Y({epoch:$(),effectiveSlot:$(),amount:$(),postBalance:$(),commission:ut(rt($()))})))),yg=nt(Y({slot:$(),prioritizationFee:$()})),wg=Y({total:$(),validator:$(),foundation:$(),epoch:$()}),Eg=Y({epoch:$(),slotIndex:$(),slotsInEpoch:$(),absoluteSlot:$(),blockHeight:ut($()),transactionCount:ut($())}),Rg=Y({slotsPerEpoch:$(),leaderScheduleSlotOffset:$(),warmup:Pe(),firstNormalEpoch:$(),firstNormalSlot:$()}),bg=za(J(),nt($())),wn=rt(be([Y({}),J()])),Ag=Y({err:wn}),Sg=Dt("receivedSignature"),vg=Y({"solana-core":J(),"feature-set":ut($())}),Ig=Y({program:J(),programId:Pt,parsed:qn()}),Og=Y({programId:Pt,accounts:nt(Pt),data:J()}),Po=Kt(Y({err:rt(be([Y({}),J()])),logs:rt(nt(J())),accounts:ut(rt(nt(rt(Y({executable:Pe(),owner:J(),lamports:$(),data:nt(J()),rentEpoch:ut($())}))))),unitsConsumed:ut($()),returnData:ut(rt(Y({programId:J(),data:xs([J(),Dt("base64")])}))),innerInstructions:ut(rt(nt(Y({index:$(),instructions:nt(be([Ig,Og]))}))))})),xg=Kt(Y({byIdentity:za(J(),nt($())),range:Y({firstSlot:$(),lastSlot:$()})}));function Ng(r,t,e,n,s,i){const o=e||ag;let c;i!=null&&console.warn("You have supplied an `httpAgent` when creating a `Connection` in a browser environment.It has been ignored; `httpAgent` is only used in Node environments.");let d;return n&&(d=(b,O)=>H(null,null,function*(){const x=yield new Promise((S,T)=>{try{n(b,O,(C,M)=>S([C,M]))}catch(C){T(C)}});return yield o(...x)})),new bp((b,O)=>H(null,null,function*(){const x={method:"POST",body:b,agent:c,headers:Object.assign({"Content-Type":"application/json"},t||{},N_)};try{let S=5,T,C=500;for(;d?T=yield d(r,x):T=yield o(r,x),!(T.status!==429||s===!0||(S-=1,S===0));)console.error(`Server responded with ${T.status} ${T.statusText}. Retrying after ${C}ms delay...`),yield On(C),C*=2;const M=yield T.text();T.ok?O(null,M):O(new Error(`${T.status} ${T.statusText}: ${M}`))}catch(S){S instanceof Error&&O(S)}}),{})}function Tg(r){return(t,e)=>new Promise((n,s)=>{r.request(t,e,(i,o)=>{if(i){s(i);return}n(o)})})}function Bg(r){return t=>new Promise((e,n)=>{t.length===0&&e([]);const s=t.map(i=>r.request(i.methodName,i.args));r.request(s,(i,o)=>{if(i){n(i);return}e(o)})})}const Cg=wt(_g),Lg=wt(wg),Mg=wt(yg),kg=wt(Eg),Ug=wt(Rg),Dg=wt(bg),Pg=wt($()),Fg=Kt(Y({total:$(),circulating:$(),nonCirculating:$(),nonCirculatingAccounts:nt(Pt)})),is=Y({amount:J(),uiAmount:rt($()),decimals:$(),uiAmountString:ut(J())}),qg=Kt(nt(Y({address:Pt,amount:J(),uiAmount:rt($()),decimals:$(),uiAmountString:ut(J())}))),$g=Kt(nt(Y({pubkey:Pt,account:Y({executable:Pe(),owner:Pt,lamports:$(),data:Cs,rentEpoch:$()})}))),ss=Y({program:J(),parsed:qn(),space:$()}),zg=Kt(nt(Y({pubkey:Pt,account:Y({executable:Pe(),owner:Pt,lamports:$(),data:ss,rentEpoch:$()})}))),Vg=Kt(nt(Y({lamports:$(),address:Pt}))),nr=Y({executable:Pe(),owner:Pt,lamports:$(),data:Cs,rentEpoch:$()}),Gg=Y({pubkey:Pt,account:nr}),Kg=ur(be([Os(Et.Buffer),ss]),be([oc,ss]),r=>Array.isArray(r)?tt(r,Cs):r),os=Y({executable:Pe(),owner:Pt,lamports:$(),data:Kg,rentEpoch:$()}),Hg=Y({pubkey:Pt,account:os}),Wg=Y({state:be([Dt("active"),Dt("inactive"),Dt("activating"),Dt("deactivating")]),active:$(),inactive:$()}),jg=wt(nt(Y({signature:J(),slot:$(),err:wn,memo:rt(J()),blockTime:ut(rt($()))}))),Xg=wt(nt(Y({signature:J(),slot:$(),err:wn,memo:rt(J()),blockTime:ut(rt($()))}))),Yg=Y({subscription:$(),result:ti(nr)}),Zg=Y({pubkey:Pt,account:nr}),Jg=Y({subscription:$(),result:ti(Zg)}),Qg=Y({parent:$(),slot:$(),root:$()}),t_=Y({subscription:$(),result:Qg}),e_=be([Y({type:be([Dt("firstShredReceived"),Dt("completed"),Dt("optimisticConfirmation"),Dt("root")]),slot:$(),timestamp:$()}),Y({type:Dt("createdBank"),parent:$(),slot:$(),timestamp:$()}),Y({type:Dt("frozen"),slot:$(),timestamp:$(),stats:Y({numTransactionEntries:$(),numSuccessfulTransactions:$(),numFailedTransactions:$(),maxTransactionsPerEntry:$()})}),Y({type:Dt("dead"),slot:$(),timestamp:$(),err:J()})]),n_=Y({subscription:$(),result:e_}),r_=Y({subscription:$(),result:ti(be([Ag,Sg]))}),i_=Y({subscription:$(),result:$()}),s_=Y({pubkey:J(),gossip:rt(J()),tpu:rt(J()),rpc:rt(J()),version:rt(J())}),Fo=Y({votePubkey:J(),nodePubkey:J(),activatedStake:$(),epochVoteAccount:Pe(),epochCredits:nt(xs([$(),$(),$()])),commission:$(),lastVote:$(),rootSlot:rt($())}),o_=wt(Y({current:nt(Fo),delinquent:nt(Fo)})),a_=be([Dt("processed"),Dt("confirmed"),Dt("finalized")]),c_=Y({slot:$(),confirmations:rt($()),err:wn,confirmationStatus:ut(a_)}),u_=Kt(nt(rt(c_))),l_=wt($()),cc=Y({accountKey:Pt,writableIndexes:nt($()),readonlyIndexes:nt($())}),Ls=Y({signatures:nt(J()),message:Y({accountKeys:nt(J()),header:Y({numRequiredSignatures:$(),numReadonlySignedAccounts:$(),numReadonlyUnsignedAccounts:$()}),instructions:nt(Y({accounts:nt($()),data:J(),programIdIndex:$()})),recentBlockhash:J(),addressTableLookups:ut(nt(cc))})}),uc=Y({pubkey:Pt,signer:Pe(),writable:Pe(),source:ut(be([Dt("transaction"),Dt("lookupTable")]))}),lc=Y({accountKeys:nt(uc),signatures:nt(J())}),fc=Y({parsed:qn(),program:J(),programId:Pt}),hc=Y({accounts:nt(Pt),data:J(),programId:Pt}),f_=be([hc,fc]),h_=be([Y({parsed:qn(),program:J(),programId:J()}),Y({accounts:nt(J()),data:J(),programId:J()})]),dc=ur(f_,h_,r=>"accounts"in r?tt(r,hc):tt(r,fc)),pc=Y({signatures:nt(J()),message:Y({accountKeys:nt(uc),instructions:nt(dc),recentBlockhash:J(),addressTableLookups:ut(rt(nt(cc)))})}),zr=Y({accountIndex:$(),mint:J(),owner:ut(J()),programId:ut(J()),uiTokenAmount:is}),gc=Y({writable:nt(Pt),readonly:nt(Pt)}),ei=Y({err:wn,fee:$(),innerInstructions:ut(rt(nt(Y({index:$(),instructions:nt(Y({accounts:nt($()),data:J(),programIdIndex:$()}))})))),preBalances:nt($()),postBalances:nt($()),logMessages:ut(rt(nt(J()))),preTokenBalances:ut(rt(nt(zr))),postTokenBalances:ut(rt(nt(zr))),loadedAddresses:ut(gc),computeUnitsConsumed:ut($()),costUnits:ut($())}),Ms=Y({err:wn,fee:$(),innerInstructions:ut(rt(nt(Y({index:$(),instructions:nt(dc)})))),preBalances:nt($()),postBalances:nt($()),logMessages:ut(rt(nt(J()))),preTokenBalances:ut(rt(nt(zr))),postTokenBalances:ut(rt(nt(zr))),loadedAddresses:ut(gc),computeUnitsConsumed:ut($()),costUnits:ut($())}),$n=be([Dt(0),Dt("legacy")]),En=Y({pubkey:J(),lamports:$(),postBalance:rt($()),rewardType:rt(J()),commission:ut(rt($()))}),d_=wt(rt(Y({blockhash:J(),previousBlockhash:J(),parentSlot:$(),transactions:nt(Y({transaction:Ls,meta:rt(ei),version:ut($n)})),rewards:ut(nt(En)),blockTime:rt($()),blockHeight:rt($())}))),p_=wt(rt(Y({blockhash:J(),previousBlockhash:J(),parentSlot:$(),rewards:ut(nt(En)),blockTime:rt($()),blockHeight:rt($())}))),g_=wt(rt(Y({blockhash:J(),previousBlockhash:J(),parentSlot:$(),transactions:nt(Y({transaction:lc,meta:rt(ei),version:ut($n)})),rewards:ut(nt(En)),blockTime:rt($()),blockHeight:rt($())}))),__=wt(rt(Y({blockhash:J(),previousBlockhash:J(),parentSlot:$(),transactions:nt(Y({transaction:pc,meta:rt(Ms),version:ut($n)})),rewards:ut(nt(En)),blockTime:rt($()),blockHeight:rt($())}))),m_=wt(rt(Y({blockhash:J(),previousBlockhash:J(),parentSlot:$(),transactions:nt(Y({transaction:lc,meta:rt(Ms),version:ut($n)})),rewards:ut(nt(En)),blockTime:rt($()),blockHeight:rt($())}))),y_=wt(rt(Y({blockhash:J(),previousBlockhash:J(),parentSlot:$(),rewards:ut(nt(En)),blockTime:rt($()),blockHeight:rt($())}))),w_=wt(rt(Y({blockhash:J(),previousBlockhash:J(),parentSlot:$(),transactions:nt(Y({transaction:Ls,meta:rt(ei)})),rewards:ut(nt(En)),blockTime:rt($())}))),qo=wt(rt(Y({blockhash:J(),previousBlockhash:J(),parentSlot:$(),signatures:nt(J()),blockTime:rt($())}))),ji=wt(rt(Y({slot:$(),meta:rt(ei),blockTime:ut(rt($())),transaction:Ls,version:ut($n)}))),br=wt(rt(Y({slot:$(),transaction:pc,meta:rt(Ms),blockTime:ut(rt($())),version:ut($n)}))),E_=Kt(Y({blockhash:J(),lastValidBlockHeight:$()})),R_=Kt(Pe()),b_=Y({slot:$(),numTransactions:$(),numSlots:$(),samplePeriodSecs:$()}),A_=wt(nt(b_)),S_=Kt(rt(Y({feeCalculator:Y({lamportsPerSignature:$()})}))),v_=wt(J()),I_=wt(J()),O_=Y({err:wn,logs:nt(J()),signature:J()}),x_=Y({result:ti(O_),subscription:$()}),N_={"solana-client":"js/1.0.0-maintenance"};class T_{constructor(t,e){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=(()=>{const _={};return b=>H(this,null,function*(){var C;const{commitment:O,config:x}=Nt(b),S=this._buildArgs([],O,void 0,x),T=Mo(S);return _[T]=(C=_[T])!=null?C:H(this,null,function*(){try{const M=yield this._rpcRequest("getBlockHeight",S),P=tt(M,wt($()));if("error"in P)throw new at(P.error,"failed to get block height information");return P.result}finally{delete _[T]}}),yield _[T]})})();let n,s,i,o,c,d;e&&typeof e=="string"?this._commitment=e:e&&(this._commitment=e.commitment,this._confirmTransactionInitialTimeout=e.confirmTransactionInitialTimeout,n=e.wsEndpoint,s=e.httpHeaders,i=e.fetch,o=e.fetchMiddleware,c=e.disableRetryOnRateLimit,d=e.httpAgent),this._rpcEndpoint=pg(t),this._rpcWsEndpoint=n||hg(t),this._rpcClient=Ng(t,s,i,o,c,d),this._rpcRequest=Tg(this._rpcClient),this._rpcBatchRequest=Bg(this._rpcClient),this._rpcWebSocket=new cg(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}getBalanceAndContext(t,e){return H(this,null,function*(){const{commitment:n,config:s}=Nt(e),i=this._buildArgs([t.toBase58()],n,void 0,s),o=yield this._rpcRequest("getBalance",i),c=tt(o,Kt($()));if("error"in c)throw new at(c.error,`failed to get balance for ${t.toBase58()}`);return c.result})}getBalance(t,e){return H(this,null,function*(){return yield this.getBalanceAndContext(t,e).then(n=>n.value).catch(n=>{throw new Error("failed to get balance of account "+t.toBase58()+": "+n)})})}getBlockTime(t){return H(this,null,function*(){const e=yield this._rpcRequest("getBlockTime",[t]),n=tt(e,wt(rt($())));if("error"in n)throw new at(n.error,`failed to get block time for slot ${t}`);return n.result})}getMinimumLedgerSlot(){return H(this,null,function*(){const t=yield this._rpcRequest("minimumLedgerSlot",[]),e=tt(t,wt($()));if("error"in e)throw new at(e.error,"failed to get minimum ledger slot");return e.result})}getFirstAvailableBlock(){return H(this,null,function*(){const t=yield this._rpcRequest("getFirstAvailableBlock",[]),e=tt(t,Pg);if("error"in e)throw new at(e.error,"failed to get first available block");return e.result})}getSupply(t){return H(this,null,function*(){let e={};typeof t=="string"?e={commitment:t}:t?e=yt(lt({},t),{commitment:t&&t.commitment||this.commitment}):e={commitment:this.commitment};const n=yield this._rpcRequest("getSupply",[e]),s=tt(n,Fg);if("error"in s)throw new at(s.error,"failed to get supply");return s.result})}getTokenSupply(t,e){return H(this,null,function*(){const n=this._buildArgs([t.toBase58()],e),s=yield this._rpcRequest("getTokenSupply",n),i=tt(s,Kt(is));if("error"in i)throw new at(i.error,"failed to get token supply");return i.result})}getTokenAccountBalance(t,e){return H(this,null,function*(){const n=this._buildArgs([t.toBase58()],e),s=yield this._rpcRequest("getTokenAccountBalance",n),i=tt(s,Kt(is));if("error"in i)throw new at(i.error,"failed to get token account balance");return i.result})}getTokenAccountsByOwner(t,e,n){return H(this,null,function*(){const{commitment:s,config:i}=Nt(n);let o=[t.toBase58()];"mint"in e?o.push({mint:e.mint.toBase58()}):o.push({programId:e.programId.toBase58()});const c=this._buildArgs(o,s,"base64",i),d=yield this._rpcRequest("getTokenAccountsByOwner",c),_=tt(d,$g);if("error"in _)throw new at(_.error,`failed to get token accounts owned by account ${t.toBase58()}`);return _.result})}getParsedTokenAccountsByOwner(t,e,n){return H(this,null,function*(){let s=[t.toBase58()];"mint"in e?s.push({mint:e.mint.toBase58()}):s.push({programId:e.programId.toBase58()});const i=this._buildArgs(s,n,"jsonParsed"),o=yield this._rpcRequest("getTokenAccountsByOwner",i),c=tt(o,zg);if("error"in c)throw new at(c.error,`failed to get token accounts owned by account ${t.toBase58()}`);return c.result})}getLargestAccounts(t){return H(this,null,function*(){const e=yt(lt({},t),{commitment:t&&t.commitment||this.commitment}),n=e.filter||e.commitment?[e]:[],s=yield this._rpcRequest("getLargestAccounts",n),i=tt(s,Vg);if("error"in i)throw new at(i.error,"failed to get largest accounts");return i.result})}getTokenLargestAccounts(t,e){return H(this,null,function*(){const n=this._buildArgs([t.toBase58()],e),s=yield this._rpcRequest("getTokenLargestAccounts",n),i=tt(s,qg);if("error"in i)throw new at(i.error,"failed to get token largest accounts");return i.result})}getAccountInfoAndContext(t,e){return H(this,null,function*(){const{commitment:n,config:s}=Nt(e),i=this._buildArgs([t.toBase58()],n,"base64",s),o=yield this._rpcRequest("getAccountInfo",i),c=tt(o,Kt(rt(nr)));if("error"in c)throw new at(c.error,`failed to get info about account ${t.toBase58()}`);return c.result})}getParsedAccountInfo(t,e){return H(this,null,function*(){const{commitment:n,config:s}=Nt(e),i=this._buildArgs([t.toBase58()],n,"jsonParsed",s),o=yield this._rpcRequest("getAccountInfo",i),c=tt(o,Kt(rt(os)));if("error"in c)throw new at(c.error,`failed to get info about account ${t.toBase58()}`);return c.result})}getAccountInfo(t,e){return H(this,null,function*(){try{return(yield this.getAccountInfoAndContext(t,e)).value}catch(n){throw new Error("failed to get info about account "+t.toBase58()+": "+n)}})}getMultipleParsedAccounts(t,e){return H(this,null,function*(){const{commitment:n,config:s}=Nt(e),i=t.map(_=>_.toBase58()),o=this._buildArgs([i],n,"jsonParsed",s),c=yield this._rpcRequest("getMultipleAccounts",o),d=tt(c,Kt(nt(rt(os))));if("error"in d)throw new at(d.error,`failed to get info for accounts ${i}`);return d.result})}getMultipleAccountsInfoAndContext(t,e){return H(this,null,function*(){const{commitment:n,config:s}=Nt(e),i=t.map(_=>_.toBase58()),o=this._buildArgs([i],n,"base64",s),c=yield this._rpcRequest("getMultipleAccounts",o),d=tt(c,Kt(nt(rt(nr))));if("error"in d)throw new at(d.error,`failed to get info for accounts ${i}`);return d.result})}getMultipleAccountsInfo(t,e){return H(this,null,function*(){return(yield this.getMultipleAccountsInfoAndContext(t,e)).value})}getStakeActivation(t,e,n){return H(this,null,function*(){const{commitment:s,config:i}=Nt(e),o=this._buildArgs([t.toBase58()],s,void 0,yt(lt({},i),{epoch:n!=null?n:i==null?void 0:i.epoch})),c=yield this._rpcRequest("getStakeActivation",o),d=tt(c,wt(Wg));if("error"in d)throw new at(d.error,`failed to get Stake Activation ${t.toBase58()}`);return d.result})}getProgramAccounts(t,e){return H(this,null,function*(){const{commitment:n,config:s}=Nt(e),O=s||{},{encoding:i}=O,o=qe(O,["encoding"]),c=this._buildArgs([t.toBase58()],n,i||"base64",lt(lt({},o),o.filters?{filters:Do(o.filters)}:null)),d=yield this._rpcRequest("getProgramAccounts",c),_=nt(Gg),b=o.withContext===!0?tt(d,Kt(_)):tt(d,wt(_));if("error"in b)throw new at(b.error,`failed to get accounts owned by program ${t.toBase58()}`);return b.result})}getParsedProgramAccounts(t,e){return H(this,null,function*(){const{commitment:n,config:s}=Nt(e),i=this._buildArgs([t.toBase58()],n,"jsonParsed",s),o=yield this._rpcRequest("getProgramAccounts",i),c=tt(o,wt(nt(Hg)));if("error"in c)throw new at(c.error,`failed to get accounts owned by program ${t.toBase58()}`);return c.result})}confirmTransaction(t,e){return H(this,null,function*(){var i;let n;if(typeof t=="string")n=t;else{const o=t;if((i=o.abortSignal)!=null&&i.aborted)return Promise.reject(o.abortSignal.reason);n=o.signature}let s;try{s=he.decode(n)}catch(o){throw new Error("signature must be base58 encoded: "+n)}return kt(s.length===64,"signature has invalid length"),typeof t=="string"?yield this.confirmTransactionUsingLegacyTimeoutStrategy({commitment:e||this.commitment,signature:n}):"lastValidBlockHeight"in t?yield this.confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:e||this.commitment,strategy:t}):yield this.confirmTransactionUsingDurableNonceStrategy({commitment:e||this.commitment,strategy:t})})}getCancellationPromise(t){return new Promise((e,n)=>{t!=null&&(t.aborted?n(t.reason):t.addEventListener("abort",()=>{n(t.reason)}))})}getTransactionConfirmationPromise({commitment:t,signature:e}){let n,s,i=!1;const o=new Promise((d,_)=>{try{n=this.onSignature(e,(O,x)=>{n=void 0;const S={context:x,value:O};d({__type:tn.PROCESSED,response:S})},t);const b=new Promise(O=>{n==null?O():s=this._onSubscriptionStateChange(n,x=>{x==="subscribed"&&O()})});H(this,null,function*(){if(yield b,i)return;const O=yield this.getSignatureStatus(e);if(i||O==null)return;const{context:x,value:S}=O;if(S!=null)if(S!=null&&S.err)_(S.err);else{switch(t){case"confirmed":case"single":case"singleGossip":{if(S.confirmationStatus==="processed")return;break}case"finalized":case"max":case"root":{if(S.confirmationStatus==="processed"||S.confirmationStatus==="confirmed")return;break}case"processed":case"recent":}i=!0,d({__type:tn.PROCESSED,response:{context:x,value:S}})}})}catch(b){_(b)}});return{abortConfirmation:()=>{s&&(s(),s=void 0),n!=null&&(this.removeSignatureListener(n),n=void 0)},confirmationPromise:o}}confirmTransactionUsingBlockHeightExceedanceStrategy(i){return H(this,arguments,function*({commitment:t,strategy:{abortSignal:e,lastValidBlockHeight:n,signature:s}}){let o=!1;const c=new Promise(x=>{const S=()=>H(this,null,function*(){try{return yield this.getBlockHeight(t)}catch(T){return-1}});H(this,null,function*(){let T=yield S();if(!o){for(;T<=n;)if(yield On(1e3),o||(T=yield S(),o))return;x({__type:tn.BLOCKHEIGHT_EXCEEDED})}})}),{abortConfirmation:d,confirmationPromise:_}=this.getTransactionConfirmationPromise({commitment:t,signature:s}),b=this.getCancellationPromise(e);let O;try{const x=yield Promise.race([b,_,c]);if(x.__type===tn.PROCESSED)O=x.response;else throw new ec(s)}finally{o=!0,d()}return O})}confirmTransactionUsingDurableNonceStrategy(c){return H(this,arguments,function*({commitment:t,strategy:{abortSignal:e,minContextSlot:n,nonceAccountPubkey:s,nonceValue:i,signature:o}}){var T;let d=!1;const _=new Promise(C=>{let M=i,P=null;const W=()=>H(this,null,function*(){try{const{context:z,value:Q}=yield this.getNonceAndContext(s,{commitment:t,minContextSlot:n});return P=z.slot,Q==null?void 0:Q.nonce}catch(z){return M}});H(this,null,function*(){if(M=yield W(),!d)for(;;){if(i!==M){C({__type:tn.NONCE_INVALID,slotInWhichNonceDidAdvance:P});return}if(yield On(2e3),d||(M=yield W(),d))return}})}),{abortConfirmation:b,confirmationPromise:O}=this.getTransactionConfirmationPromise({commitment:t,signature:o}),x=this.getCancellationPromise(e);let S;try{const C=yield Promise.race([x,O,_]);if(C.__type===tn.PROCESSED)S=C.response;else{let M;for(;;){const P=yield this.getSignatureStatus(o);if(P==null)break;if(P.context.slot<((T=C.slotInWhichNonceDidAdvance)!=null?T:n)){yield On(400);continue}M=P;break}if(M!=null&&M.value){const P=t||"finalized",{confirmationStatus:W}=M.value;switch(P){case"processed":case"recent":if(W!=="processed"&&W!=="confirmed"&&W!=="finalized")throw new jn(o);break;case"confirmed":case"single":case"singleGossip":if(W!=="confirmed"&&W!=="finalized")throw new jn(o);break;case"finalized":case"max":case"root":if(W!=="finalized")throw new jn(o);break;default:}S={context:M.context,value:{err:M.value.err}}}else throw new jn(o)}}finally{d=!0,b()}return S})}confirmTransactionUsingLegacyTimeoutStrategy(n){return H(this,arguments,function*({commitment:t,signature:e}){let s;const i=new Promise(_=>{let b=this._confirmTransactionInitialTimeout||6e4;switch(t){case"processed":case"recent":case"single":case"confirmed":case"singleGossip":{b=this._confirmTransactionInitialTimeout||3e4;break}}s=setTimeout(()=>_({__type:tn.TIMED_OUT,timeoutMs:b}),b)}),{abortConfirmation:o,confirmationPromise:c}=this.getTransactionConfirmationPromise({commitment:t,signature:e});let d;try{const _=yield Promise.race([c,i]);if(_.__type===tn.PROCESSED)d=_.response;else throw new nc(e,_.timeoutMs/1e3)}finally{clearTimeout(s),o()}return d})}getClusterNodes(){return H(this,null,function*(){const t=yield this._rpcRequest("getClusterNodes",[]),e=tt(t,wt(nt(s_)));if("error"in e)throw new at(e.error,"failed to get cluster nodes");return e.result})}getVoteAccounts(t){return H(this,null,function*(){const e=this._buildArgs([],t),n=yield this._rpcRequest("getVoteAccounts",e),s=tt(n,o_);if("error"in s)throw new at(s.error,"failed to get vote accounts");return s.result})}getSlot(t){return H(this,null,function*(){const{commitment:e,config:n}=Nt(t),s=this._buildArgs([],e,void 0,n),i=yield this._rpcRequest("getSlot",s),o=tt(i,wt($()));if("error"in o)throw new at(o.error,"failed to get slot");return o.result})}getSlotLeader(t){return H(this,null,function*(){const{commitment:e,config:n}=Nt(t),s=this._buildArgs([],e,void 0,n),i=yield this._rpcRequest("getSlotLeader",s),o=tt(i,wt(J()));if("error"in o)throw new at(o.error,"failed to get slot leader");return o.result})}getSlotLeaders(t,e){return H(this,null,function*(){const n=[t,e],s=yield this._rpcRequest("getSlotLeaders",n),i=tt(s,wt(nt(Pt)));if("error"in i)throw new at(i.error,"failed to get slot leaders");return i.result})}getSignatureStatus(t,e){return H(this,null,function*(){const{context:n,value:s}=yield this.getSignatureStatuses([t],e);kt(s.length===1);const i=s[0];return{context:n,value:i}})}getSignatureStatuses(t,e){return H(this,null,function*(){const n=[t];e&&n.push(e);const s=yield this._rpcRequest("getSignatureStatuses",n),i=tt(s,u_);if("error"in i)throw new at(i.error,"failed to get signature status");return i.result})}getTransactionCount(t){return H(this,null,function*(){const{commitment:e,config:n}=Nt(t),s=this._buildArgs([],e,void 0,n),i=yield this._rpcRequest("getTransactionCount",s),o=tt(i,wt($()));if("error"in o)throw new at(o.error,"failed to get transaction count");return o.result})}getTotalSupply(t){return H(this,null,function*(){return(yield this.getSupply({commitment:t,excludeNonCirculatingAccountsList:!0})).value.total})}getInflationGovernor(t){return H(this,null,function*(){const e=this._buildArgs([],t),n=yield this._rpcRequest("getInflationGovernor",e),s=tt(n,Cg);if("error"in s)throw new at(s.error,"failed to get inflation");return s.result})}getInflationReward(t,e,n){return H(this,null,function*(){const{commitment:s,config:i}=Nt(n),o=this._buildArgs([t.map(_=>_.toBase58())],s,void 0,yt(lt({},i),{epoch:e!=null?e:i==null?void 0:i.epoch})),c=yield this._rpcRequest("getInflationReward",o),d=tt(c,mg);if("error"in d)throw new at(d.error,"failed to get inflation reward");return d.result})}getInflationRate(){return H(this,null,function*(){const t=yield this._rpcRequest("getInflationRate",[]),e=tt(t,Lg);if("error"in e)throw new at(e.error,"failed to get inflation rate");return e.result})}getEpochInfo(t){return H(this,null,function*(){const{commitment:e,config:n}=Nt(t),s=this._buildArgs([],e,void 0,n),i=yield this._rpcRequest("getEpochInfo",s),o=tt(i,kg);if("error"in o)throw new at(o.error,"failed to get epoch info");return o.result})}getEpochSchedule(){return H(this,null,function*(){const t=yield this._rpcRequest("getEpochSchedule",[]),e=tt(t,Ug);if("error"in e)throw new at(e.error,"failed to get epoch schedule");const n=e.result;return new og(n.slotsPerEpoch,n.leaderScheduleSlotOffset,n.warmup,n.firstNormalEpoch,n.firstNormalSlot)})}getLeaderSchedule(){return H(this,null,function*(){const t=yield this._rpcRequest("getLeaderSchedule",[]),e=tt(t,Dg);if("error"in e)throw new at(e.error,"failed to get leader schedule");return e.result})}getMinimumBalanceForRentExemption(t,e){return H(this,null,function*(){const n=this._buildArgs([t],e),s=yield this._rpcRequest("getMinimumBalanceForRentExemption",n),i=tt(s,l_);return"error"in i?(console.warn("Unable to fetch minimum balance for rent exemption"),0):i.result})}getRecentBlockhashAndContext(t){return H(this,null,function*(){const{context:e,value:{blockhash:n}}=yield this.getLatestBlockhashAndContext(t);return{context:e,value:{blockhash:n,feeCalculator:{get lamportsPerSignature(){throw new 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{}}}}}})}getRecentPerformanceSamples(t){return H(this,null,function*(){const e=yield this._rpcRequest("getRecentPerformanceSamples",t?[t]:[]),n=tt(e,A_);if("error"in n)throw new at(n.error,"failed to get recent performance samples");return n.result})}getFeeCalculatorForBlockhash(t,e){return H(this,null,function*(){const n=this._buildArgs([t],e),s=yield this._rpcRequest("getFeeCalculatorForBlockhash",n),i=tt(s,S_);if("error"in i)throw new at(i.error,"failed to get fee calculator");const{context:o,value:c}=i.result;return{context:o,value:c!==null?c.feeCalculator:null}})}getFeeForMessage(t,e){return H(this,null,function*(){const n=Pn(t.serialize()).toString("base64"),s=this._buildArgs([n],e),i=yield this._rpcRequest("getFeeForMessage",s),o=tt(i,Kt(rt($())));if("error"in o)throw new at(o.error,"failed to get fee for message");if(o.result===null)throw new Error("invalid blockhash");return o.result})}getRecentPrioritizationFees(t){return H(this,null,function*(){var o;const e=(o=t==null?void 0:t.lockedWritableAccounts)==null?void 0:o.map(c=>c.toBase58()),n=e!=null&&e.length?[e]:[],s=yield this._rpcRequest("getRecentPrioritizationFees",n),i=tt(s,Mg);if("error"in i)throw new at(i.error,"failed to get recent prioritization fees");return i.result})}getRecentBlockhash(t){return H(this,null,function*(){try{return(yield this.getRecentBlockhashAndContext(t)).value}catch(e){throw new Error("failed to get recent blockhash: "+e)}})}getLatestBlockhash(t){return H(this,null,function*(){try{return(yield this.getLatestBlockhashAndContext(t)).value}catch(e){throw new Error("failed to get recent blockhash: "+e)}})}getLatestBlockhashAndContext(t){return H(this,null,function*(){const{commitment:e,config:n}=Nt(t),s=this._buildArgs([],e,void 0,n),i=yield this._rpcRequest("getLatestBlockhash",s),o=tt(i,E_);if("error"in o)throw new at(o.error,"failed to get latest blockhash");return o.result})}isBlockhashValid(t,e){return H(this,null,function*(){const{commitment:n,config:s}=Nt(e),i=this._buildArgs([t],n,void 0,s),o=yield this._rpcRequest("isBlockhashValid",i),c=tt(o,R_);if("error"in c)throw new at(c.error,"failed to determine if the blockhash `"+t+"`is valid");return c.result})}getVersion(){return H(this,null,function*(){const t=yield this._rpcRequest("getVersion",[]),e=tt(t,wt(vg));if("error"in e)throw new at(e.error,"failed to get version");return e.result})}getGenesisHash(){return H(this,null,function*(){const t=yield this._rpcRequest("getGenesisHash",[]),e=tt(t,wt(J()));if("error"in e)throw new at(e.error,"failed to get genesis hash");return e.result})}getBlock(t,e){return H(this,null,function*(){const{commitment:n,config:s}=Nt(e),i=this._buildArgsAtLeastConfirmed([t],n,void 0,s),o=yield this._rpcRequest("getBlock",i);try{switch(s==null?void 0:s.transactionDetails){case"accounts":{const c=tt(o,g_);if("error"in c)throw c.error;return c.result}case"none":{const c=tt(o,p_);if("error"in c)throw c.error;return c.result}default:{const c=tt(o,d_);if("error"in c)throw c.error;const{result:d}=c;return d?yt(lt({},d),{transactions:d.transactions.map(({transaction:_,meta:b,version:O})=>({meta:b,transaction:yt(lt({},_),{message:Wi(O,_.message)}),version:O}))}):null}}}catch(c){throw new at(c,"failed to get confirmed block")}})}getParsedBlock(t,e){return H(this,null,function*(){const{commitment:n,config:s}=Nt(e),i=this._buildArgsAtLeastConfirmed([t],n,"jsonParsed",s),o=yield this._rpcRequest("getBlock",i);try{switch(s==null?void 0:s.transactionDetails){case"accounts":{const c=tt(o,m_);if("error"in c)throw c.error;return c.result}case"none":{const c=tt(o,y_);if("error"in c)throw c.error;return c.result}default:{const c=tt(o,__);if("error"in c)throw c.error;return c.result}}}catch(c){throw new at(c,"failed to get block")}})}getBlockProduction(t){return H(this,null,function*(){let e,n;if(typeof t=="string")n=t;else if(t){const c=t,{commitment:d}=c,_=qe(c,["commitment"]);n=d,e=_}const s=this._buildArgs([],n,"base64",e),i=yield this._rpcRequest("getBlockProduction",s),o=tt(i,xg);if("error"in o)throw new at(o.error,"failed to get block production information");return o.result})}getTransaction(t,e){return H(this,null,function*(){const{commitment:n,config:s}=Nt(e),i=this._buildArgsAtLeastConfirmed([t],n,void 0,s),o=yield this._rpcRequest("getTransaction",i),c=tt(o,ji);if("error"in c)throw new at(c.error,"failed to get transaction");const d=c.result;return d&&yt(lt({},d),{transaction:yt(lt({},d.transaction),{message:Wi(d.version,d.transaction.message)})})})}getParsedTransaction(t,e){return H(this,null,function*(){const{commitment:n,config:s}=Nt(e),i=this._buildArgsAtLeastConfirmed([t],n,"jsonParsed",s),o=yield this._rpcRequest("getTransaction",i),c=tt(o,br);if("error"in c)throw new at(c.error,"failed to get transaction");return c.result})}getParsedTransactions(t,e){return H(this,null,function*(){const{commitment:n,config:s}=Nt(e),i=t.map(d=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([d],n,"jsonParsed",s)}));return(yield this._rpcBatchRequest(i)).map(d=>{const _=tt(d,br);if("error"in _)throw new at(_.error,"failed to get transactions");return _.result})})}getTransactions(t,e){return H(this,null,function*(){const{commitment:n,config:s}=Nt(e),i=t.map(d=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([d],n,void 0,s)}));return(yield this._rpcBatchRequest(i)).map(d=>{const _=tt(d,ji);if("error"in _)throw new at(_.error,"failed to get transactions");const b=_.result;return b&&yt(lt({},b),{transaction:yt(lt({},b.transaction),{message:Wi(b.version,b.transaction.message)})})})})}getConfirmedBlock(t,e){return H(this,null,function*(){const n=this._buildArgsAtLeastConfirmed([t],e),s=yield this._rpcRequest("getBlock",n),i=tt(s,w_);if("error"in i)throw new at(i.error,"failed to get confirmed block");const o=i.result;if(!o)throw new Error("Confirmed block "+t+" not found");const c=yt(lt({},o),{transactions:o.transactions.map(({transaction:d,meta:_})=>{const b=new je(d.message);return{meta:_,transaction:yt(lt({},d),{message:b})}})});return yt(lt({},c),{transactions:c.transactions.map(({transaction:d,meta:_})=>({meta:_,transaction:Te.populate(d.message,d.signatures)}))})})}getBlocks(t,e,n){return H(this,null,function*(){const s=this._buildArgsAtLeastConfirmed(e!==void 0?[t,e]:[t],n),i=yield this._rpcRequest("getBlocks",s),o=tt(i,wt(nt($())));if("error"in o)throw new at(o.error,"failed to get blocks");return o.result})}getBlockSignatures(t,e){return H(this,null,function*(){const n=this._buildArgsAtLeastConfirmed([t],e,void 0,{transactionDetails:"signatures",rewards:!1}),s=yield this._rpcRequest("getBlock",n),i=tt(s,qo);if("error"in i)throw new at(i.error,"failed to get block");const o=i.result;if(!o)throw new Error("Block "+t+" not found");return o})}getConfirmedBlockSignatures(t,e){return H(this,null,function*(){const n=this._buildArgsAtLeastConfirmed([t],e,void 0,{transactionDetails:"signatures",rewards:!1}),s=yield this._rpcRequest("getBlock",n),i=tt(s,qo);if("error"in i)throw new at(i.error,"failed to get confirmed block");const o=i.result;if(!o)throw new Error("Confirmed block "+t+" not found");return o})}getConfirmedTransaction(t,e){return H(this,null,function*(){const n=this._buildArgsAtLeastConfirmed([t],e),s=yield this._rpcRequest("getTransaction",n),i=tt(s,ji);if("error"in i)throw new at(i.error,"failed to get transaction");const o=i.result;if(!o)return o;const c=new je(o.transaction.message),d=o.transaction.signatures;return yt(lt({},o),{transaction:Te.populate(c,d)})})}getParsedConfirmedTransaction(t,e){return H(this,null,function*(){const n=this._buildArgsAtLeastConfirmed([t],e,"jsonParsed"),s=yield this._rpcRequest("getTransaction",n),i=tt(s,br);if("error"in i)throw new at(i.error,"failed to get confirmed transaction");return i.result})}getParsedConfirmedTransactions(t,e){return H(this,null,function*(){const n=t.map(o=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([o],e,"jsonParsed")}));return(yield this._rpcBatchRequest(n)).map(o=>{const c=tt(o,br);if("error"in c)throw new at(c.error,"failed to get confirmed transactions");return c.result})})}getConfirmedSignaturesForAddress(t,e,n){return H(this,null,function*(){let s={},i=yield this.getFirstAvailableBlock();for(;!("until"in s)&&(e--,!(e<=0||e<i));)try{const d=yield this.getConfirmedBlockSignatures(e,"finalized");d.signatures.length>0&&(s.until=d.signatures[d.signatures.length-1].toString())}catch(d){if(d instanceof Error&&d.message.includes("skipped"))continue;throw d}let o=yield this.getSlot("finalized");for(;!("before"in s)&&(n++,!(n>o));)try{const d=yield this.getConfirmedBlockSignatures(n);d.signatures.length>0&&(s.before=d.signatures[d.signatures.length-1].toString())}catch(d){if(d instanceof Error&&d.message.includes("skipped"))continue;throw d}return(yield this.getConfirmedSignaturesForAddress2(t,s)).map(d=>d.signature)})}getConfirmedSignaturesForAddress2(t,e,n){return H(this,null,function*(){const s=this._buildArgsAtLeastConfirmed([t.toBase58()],n,void 0,e),i=yield this._rpcRequest("getConfirmedSignaturesForAddress2",s),o=tt(i,jg);if("error"in o)throw new at(o.error,"failed to get confirmed signatures for address");return o.result})}getSignaturesForAddress(t,e,n){return H(this,null,function*(){const s=this._buildArgsAtLeastConfirmed([t.toBase58()],n,void 0,e),i=yield this._rpcRequest("getSignaturesForAddress",s),o=tt(i,Xg);if("error"in o)throw new at(o.error,"failed to get signatures for address");return o.result})}getAddressLookupTable(t,e){return H(this,null,function*(){const{context:n,value:s}=yield this.getAccountInfoAndContext(t,e);let i=null;return s!==null&&(i=new Uo({key:t,state:Uo.deserialize(s.data)})),{context:n,value:i}})}getNonceAndContext(t,e){return H(this,null,function*(){const{context:n,value:s}=yield this.getAccountInfoAndContext(t,e);let i=null;return s!==null&&(i=Bs.fromAccountData(s.data)),{context:n,value:i}})}getNonce(t,e){return H(this,null,function*(){return yield this.getNonceAndContext(t,e).then(n=>n.value).catch(n=>{throw new Error("failed to get nonce for account "+t.toBase58()+": "+n)})})}requestAirdrop(t,e){return H(this,null,function*(){const n=yield this._rpcRequest("requestAirdrop",[t.toBase58(),e]),s=tt(n,v_);if("error"in s)throw new at(s.error,`airdrop to ${t.toBase58()} failed`);return s.result})}_blockhashWithExpiryBlockHeight(t){return H(this,null,function*(){if(!t){for(;this._pollingBlockhash;)yield On(100);const n=Date.now()-this._blockhashInfo.lastFetch>=dg;if(this._blockhashInfo.latestBlockhash!==null&&!n)return this._blockhashInfo.latestBlockhash}return yield this._pollNewBlockhash()})}_pollNewBlockhash(){return H(this,null,function*(){this._pollingBlockhash=!0;try{const t=Date.now(),e=this._blockhashInfo.latestBlockhash,n=e?e.blockhash:null;for(let s=0;s<50;s++){const i=yield this.getLatestBlockhash("finalized");if(n!==i.blockhash)return this._blockhashInfo={latestBlockhash:i,lastFetch:Date.now(),transactionSignatures:[],simulatedSignatures:[]},i;yield On(tg/2)}throw new Error(`Unable to obtain a new blockhash after ${Date.now()-t}ms`)}finally{this._pollingBlockhash=!1}})}getStakeMinimumDelegation(t){return H(this,null,function*(){const{commitment:e,config:n}=Nt(t),s=this._buildArgs([],e,"base64",n),i=yield this._rpcRequest("getStakeMinimumDelegation",s),o=tt(i,Kt($()));if("error"in o)throw new at(o.error,"failed to get stake minimum delegation");return o.result})}simulateTransaction(t,e,n){return H(this,null,function*(){if("message"in t){const C=t.serialize(),M=Et.Buffer.from(C).toString("base64");if(Array.isArray(e)||n!==void 0)throw new Error("Invalid arguments");const P=e||{};P.encoding="base64","commitment"in P||(P.commitment=this.commitment),e&&typeof e=="object"&&"innerInstructions"in e&&(P.innerInstructions=e.innerInstructions);const W=[M,P],z=yield this._rpcRequest("simulateTransaction",W),Q=tt(z,Po);if("error"in Q)throw new Error("failed to simulate transaction: "+Q.error.message);return Q.result}let s;if(t instanceof Te){let T=t;s=new Te,s.feePayer=T.feePayer,s.instructions=t.instructions,s.nonceInfo=T.nonceInfo,s.signatures=T.signatures}else s=Te.populate(t),s._message=s._json=void 0;if(e!==void 0&&!Array.isArray(e))throw new Error("Invalid arguments");const i=e;if(s.nonceInfo&&i)s.sign(...i);else{let T=this._disableBlockhashCaching;for(;;){const C=yield this._blockhashWithExpiryBlockHeight(T);if(s.lastValidBlockHeight=C.lastValidBlockHeight,s.recentBlockhash=C.blockhash,!i)break;if(s.sign(...i),!s.signature)throw new Error("!signature");const M=s.signature.toString("base64");if(!this._blockhashInfo.simulatedSignatures.includes(M)&&!this._blockhashInfo.transactionSignatures.includes(M)){this._blockhashInfo.simulatedSignatures.push(M);break}else T=!0}}const o=s._compile(),c=o.serialize(),_=s._serialize(c).toString("base64"),b={encoding:"base64",commitment:this.commitment};if(n){const T=(Array.isArray(n)?n:o.nonProgramIds()).map(C=>C.toBase58());b.accounts={encoding:"base64",addresses:T}}i&&(b.sigVerify=!0),e&&typeof e=="object"&&"innerInstructions"in e&&(b.innerInstructions=e.innerInstructions);const O=[_,b],x=yield this._rpcRequest("simulateTransaction",O),S=tt(x,Po);if("error"in S){let T;if("data"in S.error&&(T=S.error.data.logs,T&&Array.isArray(T))){const C=`
|
|
94
|
+
`,M=C+T.join(C);console.error(S.error.message,M)}throw new Co({action:"simulate",signature:"",transactionMessage:S.error.message,logs:T})}return S.result})}sendTransaction(t,e,n){return H(this,null,function*(){if("version"in t){if(e&&Array.isArray(e))throw new Error("Invalid arguments");const o=t.serialize();return yield this.sendRawTransaction(o,e)}if(e===void 0||!Array.isArray(e))throw new Error("Invalid arguments");const s=e;if(t.nonceInfo)t.sign(...s);else{let o=this._disableBlockhashCaching;for(;;){const c=yield this._blockhashWithExpiryBlockHeight(o);if(t.lastValidBlockHeight=c.lastValidBlockHeight,t.recentBlockhash=c.blockhash,t.sign(...s),!t.signature)throw new Error("!signature");const d=t.signature.toString("base64");if(this._blockhashInfo.transactionSignatures.includes(d))o=!0;else{this._blockhashInfo.transactionSignatures.push(d);break}}}const i=t.serialize();return yield this.sendRawTransaction(i,n)})}sendRawTransaction(t,e){return H(this,null,function*(){const n=Pn(t).toString("base64");return yield this.sendEncodedTransaction(n,e)})}sendEncodedTransaction(t,e){return H(this,null,function*(){const n={encoding:"base64"},s=e&&e.skipPreflight,i=s===!0?"processed":e&&e.preflightCommitment||this.commitment;e&&e.maxRetries!=null&&(n.maxRetries=e.maxRetries),e&&e.minContextSlot!=null&&(n.minContextSlot=e.minContextSlot),s&&(n.skipPreflight=s),i&&(n.preflightCommitment=i);const o=[t,n],c=yield this._rpcRequest("sendTransaction",o),d=tt(c,I_);if("error"in d){let _;throw"data"in d.error&&(_=d.error.data.logs),new Co({action:s?"send":"simulate",signature:"",transactionMessage:d.error.message,logs:_})}return d.result})}_wsOnOpen(){this._rpcWebSocketConnected=!0,this._rpcWebSocketHeartbeat=setInterval(()=>{H(this,null,function*(){try{yield this._rpcWebSocket.notify("ping")}catch(t){}})},5e3),this._updateSubscriptions()}_wsOnError(t){this._rpcWebSocketConnected=!1,console.error("ws error:",t.message)}_wsOnClose(t){if(this._rpcWebSocketConnected=!1,this._rpcWebSocketGeneration=(this._rpcWebSocketGeneration+1)%Number.MAX_SAFE_INTEGER,this._rpcWebSocketIdleTimeout&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null),this._rpcWebSocketHeartbeat&&(clearInterval(this._rpcWebSocketHeartbeat),this._rpcWebSocketHeartbeat=null),t===1e3){this._updateSubscriptions();return}this._subscriptionCallbacksByServerSubscriptionId={},Object.entries(this._subscriptionsByHash).forEach(([e,n])=>{this._setSubscription(e,yt(lt({},n),{state:"pending"}))})}_setSubscription(t,e){var s;const n=(s=this._subscriptionsByHash[t])==null?void 0:s.state;if(this._subscriptionsByHash[t]=e,n!==e.state){const i=this._subscriptionStateChangeCallbacksByHash[t];i&&i.forEach(o=>{try{o(e.state)}catch(c){}})}}_onSubscriptionStateChange(t,e){var i;const n=this._subscriptionHashByClientSubscriptionId[t];if(n==null)return()=>{};const s=(i=this._subscriptionStateChangeCallbacksByHash)[n]||(i[n]=new Set);return s.add(e),()=>{s.delete(e),s.size===0&&delete this._subscriptionStateChangeCallbacksByHash[n]}}_updateSubscriptions(){return H(this,null,function*(){if(Object.keys(this._subscriptionsByHash).length===0){this._rpcWebSocketConnected&&(this._rpcWebSocketConnected=!1,this._rpcWebSocketIdleTimeout=setTimeout(()=>{this._rpcWebSocketIdleTimeout=null;try{this._rpcWebSocket.close()}catch(n){n instanceof Error&&console.log(`Error when closing socket connection: ${n.message}`)}},500));return}if(this._rpcWebSocketIdleTimeout!==null&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketConnected=!0),!this._rpcWebSocketConnected){this._rpcWebSocket.connect();return}const t=this._rpcWebSocketGeneration,e=()=>t===this._rpcWebSocketGeneration;yield Promise.all(Object.keys(this._subscriptionsByHash).map(n=>H(this,null,function*(){const s=this._subscriptionsByHash[n];if(s!==void 0)switch(s.state){case"pending":case"unsubscribed":if(s.callbacks.size===0){delete this._subscriptionsByHash[n],s.state==="unsubscribed"&&delete this._subscriptionCallbacksByServerSubscriptionId[s.serverSubscriptionId],yield this._updateSubscriptions();return}yield H(this,null,function*(){const{args:i,method:o}=s;try{this._setSubscription(n,yt(lt({},s),{state:"subscribing"}));const c=yield this._rpcWebSocket.call(o,i);this._setSubscription(n,yt(lt({},s),{serverSubscriptionId:c,state:"subscribed"})),this._subscriptionCallbacksByServerSubscriptionId[c]=s.callbacks,yield this._updateSubscriptions()}catch(c){if(console.error(`Received ${c instanceof Error?"":"JSON-RPC "}error calling \`${o}\``,{args:i,error:c}),!e())return;this._setSubscription(n,yt(lt({},s),{state:"pending"})),yield this._updateSubscriptions()}});break;case"subscribed":s.callbacks.size===0&&(yield H(this,null,function*(){const{serverSubscriptionId:i,unsubscribeMethod:o}=s;if(this._subscriptionsAutoDisposedByRpc.has(i))this._subscriptionsAutoDisposedByRpc.delete(i);else{this._setSubscription(n,yt(lt({},s),{state:"unsubscribing"})),this._setSubscription(n,yt(lt({},s),{state:"unsubscribing"}));try{yield this._rpcWebSocket.call(o,[i])}catch(c){if(c instanceof Error&&console.error(`${o} error:`,c.message),!e())return;this._setSubscription(n,yt(lt({},s),{state:"subscribed"})),yield this._updateSubscriptions();return}}this._setSubscription(n,yt(lt({},s),{state:"unsubscribed"})),yield this._updateSubscriptions()}));break}})))})}_handleServerNotification(t,e){const n=this._subscriptionCallbacksByServerSubscriptionId[t];n!==void 0&&n.forEach(s=>{try{s(...e)}catch(i){console.error(i)}})}_wsOnAccountNotification(t){const{result:e,subscription:n}=tt(t,Yg);this._handleServerNotification(n,[e.value,e.context])}_makeSubscription(t,e){const n=this._nextClientSubscriptionId++,s=Mo([t.method,e]),i=this._subscriptionsByHash[s];return i===void 0?this._subscriptionsByHash[s]=yt(lt({},t),{args:e,callbacks:new Set([t.callback]),state:"pending"}):i.callbacks.add(t.callback),this._subscriptionHashByClientSubscriptionId[n]=s,this._subscriptionDisposeFunctionsByClientSubscriptionId[n]=()=>H(this,null,function*(){delete this._subscriptionDisposeFunctionsByClientSubscriptionId[n],delete this._subscriptionHashByClientSubscriptionId[n];const o=this._subscriptionsByHash[s];kt(o!==void 0,`Could not find a \`Subscription\` when tearing down client subscription #${n}`),o.callbacks.delete(t.callback),yield this._updateSubscriptions()}),this._updateSubscriptions(),n}onAccountChange(t,e,n){const{commitment:s,config:i}=Nt(n),o=this._buildArgs([t.toBase58()],s||this._commitment||"finalized","base64",i);return this._makeSubscription({callback:e,method:"accountSubscribe",unsubscribeMethod:"accountUnsubscribe"},o)}removeAccountChangeListener(t){return H(this,null,function*(){yield this._unsubscribeClientSubscription(t,"account change")})}_wsOnProgramAccountNotification(t){const{result:e,subscription:n}=tt(t,Jg);this._handleServerNotification(n,[{accountId:e.value.pubkey,accountInfo:e.value.account},e.context])}onProgramAccountChange(t,e,n,s){const{commitment:i,config:o}=Nt(n),c=this._buildArgs([t.toBase58()],i||this._commitment||"finalized","base64",o||(s?{filters:Do(s)}:void 0));return this._makeSubscription({callback:e,method:"programSubscribe",unsubscribeMethod:"programUnsubscribe"},c)}removeProgramAccountChangeListener(t){return H(this,null,function*(){yield this._unsubscribeClientSubscription(t,"program account change")})}onLogs(t,e,n){const s=this._buildArgs([typeof t=="object"?{mentions:[t.toString()]}:t],n||this._commitment||"finalized");return this._makeSubscription({callback:e,method:"logsSubscribe",unsubscribeMethod:"logsUnsubscribe"},s)}removeOnLogsListener(t){return H(this,null,function*(){yield this._unsubscribeClientSubscription(t,"logs")})}_wsOnLogsNotification(t){const{result:e,subscription:n}=tt(t,x_);this._handleServerNotification(n,[e.value,e.context])}_wsOnSlotNotification(t){const{result:e,subscription:n}=tt(t,t_);this._handleServerNotification(n,[e])}onSlotChange(t){return this._makeSubscription({callback:t,method:"slotSubscribe",unsubscribeMethod:"slotUnsubscribe"},[])}removeSlotChangeListener(t){return H(this,null,function*(){yield this._unsubscribeClientSubscription(t,"slot change")})}_wsOnSlotUpdatesNotification(t){const{result:e,subscription:n}=tt(t,n_);this._handleServerNotification(n,[e])}onSlotUpdate(t){return this._makeSubscription({callback:t,method:"slotsUpdatesSubscribe",unsubscribeMethod:"slotsUpdatesUnsubscribe"},[])}removeSlotUpdateListener(t){return H(this,null,function*(){yield this._unsubscribeClientSubscription(t,"slot update")})}_unsubscribeClientSubscription(t,e){return H(this,null,function*(){const n=this._subscriptionDisposeFunctionsByClientSubscriptionId[t];n?yield n():console.warn(`Ignored unsubscribe request because an active subscription with id \`${t}\` for '${e}' events could not be found.`)})}_buildArgs(t,e,n,s){const i=e||this._commitment;if(i||n||s){let o={};n&&(o.encoding=n),i&&(o.commitment=i),s&&(o=Object.assign(o,s)),t.push(o)}return t}_buildArgsAtLeastConfirmed(t,e,n,s){const i=e||this._commitment;if(i&&!["confirmed","finalized"].includes(i))throw new Error("Using Connection with default commitment: `"+this._commitment+"`, but method requires at least `confirmed`");return this._buildArgs(t,e,n,s)}_wsOnSignatureNotification(t){const{result:e,subscription:n}=tt(t,r_);e.value!=="receivedSignature"&&this._subscriptionsAutoDisposedByRpc.add(n),this._handleServerNotification(n,e.value==="receivedSignature"?[{type:"received"},e.context]:[{type:"status",result:e.value},e.context])}onSignature(t,e,n){const s=this._buildArgs([t],n||this._commitment||"finalized"),i=this._makeSubscription({callback:(o,c)=>{if(o.type==="status"){e(o.result,c);try{this.removeSignatureListener(i)}catch(d){}}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},s);return i}onSignatureWithOptions(t,e,n){const d=yt(lt({},n),{commitment:n&&n.commitment||this._commitment||"finalized"}),{commitment:s}=d,i=qe(d,["commitment"]),o=this._buildArgs([t],s,void 0,i),c=this._makeSubscription({callback:(_,b)=>{e(_,b);try{this.removeSignatureListener(c)}catch(O){}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},o);return c}removeSignatureListener(t){return H(this,null,function*(){yield this._unsubscribeClientSubscription(t,"signature result")})}_wsOnRootNotification(t){const{result:e,subscription:n}=tt(t,i_);this._handleServerNotification(n,[e])}onRootChange(t){return this._makeSubscription({callback:t,method:"rootSubscribe",unsubscribeMethod:"rootUnsubscribe"},[])}removeRootChangeListener(t){return H(this,null,function*(){yield this._unsubscribeClientSubscription(t,"root change")})}}Object.freeze({CreateLookupTable:{index:0,layout:B.struct([B.u32("instruction"),Fn("recentSlot"),B.u8("bumpSeed")])},FreezeLookupTable:{index:1,layout:B.struct([B.u32("instruction")])},ExtendLookupTable:{index:2,layout:B.struct([B.u32("instruction"),Fn(),B.seq(Rt(),B.offset(B.u32(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:B.struct([B.u32("instruction")])},CloseLookupTable:{index:4,layout:B.struct([B.u32("instruction")])}});new ht("AddressLookupTab1e1111111111111111111111111");Object.freeze({RequestUnits:{index:0,layout:B.struct([B.u8("instruction"),B.u32("units"),B.u32("additionalFee")])},RequestHeapFrame:{index:1,layout:B.struct([B.u8("instruction"),B.u32("bytes")])},SetComputeUnitLimit:{index:2,layout:B.struct([B.u8("instruction"),B.u32("units")])},SetComputeUnitPrice:{index:3,layout:B.struct([B.u8("instruction"),Fn("microLamports")])}});new ht("ComputeBudget111111111111111111111111111111");B.struct([B.u8("numSignatures"),B.u8("padding"),B.u16("signatureOffset"),B.u16("signatureInstructionIndex"),B.u16("publicKeyOffset"),B.u16("publicKeyInstructionIndex"),B.u16("messageDataOffset"),B.u16("messageDataSize"),B.u16("messageInstructionIndex")]);new ht("Ed25519SigVerify111111111111111111111111111");qp.utils.isValidPrivateKey;B.struct([B.u8("numSignatures"),B.u16("signatureOffset"),B.u8("signatureInstructionIndex"),B.u16("ethAddressOffset"),B.u8("ethAddressInstructionIndex"),B.u16("messageDataOffset"),B.u16("messageDataSize"),B.u8("messageInstructionIndex"),B.blob(20,"ethAddress"),B.blob(64,"signature"),B.u8("recoveryId")]);new ht("KeccakSecp256k11111111111111111111111111111");var _c;new ht("StakeConfig11111111111111111111111111111111");class mc{constructor(t,e,n){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=t,this.epoch=e,this.custodian=n}}_c=mc;mc.default=new _c(0,0,ht.default);Object.freeze({Initialize:{index:0,layout:B.struct([B.u32("instruction"),Hp(),Wp()])},Authorize:{index:1,layout:B.struct([B.u32("instruction"),Rt("newAuthorized"),B.u32("stakeAuthorizationType")])},Delegate:{index:2,layout:B.struct([B.u32("instruction")])},Split:{index:3,layout:B.struct([B.u32("instruction"),B.ns64("lamports")])},Withdraw:{index:4,layout:B.struct([B.u32("instruction"),B.ns64("lamports")])},Deactivate:{index:5,layout:B.struct([B.u32("instruction")])},Merge:{index:7,layout:B.struct([B.u32("instruction")])},AuthorizeWithSeed:{index:8,layout:B.struct([B.u32("instruction"),Rt("newAuthorized"),B.u32("stakeAuthorizationType"),Bn("authoritySeed"),Rt("authorityOwner")])}});new ht("Stake11111111111111111111111111111111111111");Object.freeze({InitializeAccount:{index:0,layout:B.struct([B.u32("instruction"),jp()])},Authorize:{index:1,layout:B.struct([B.u32("instruction"),Rt("newAuthorized"),B.u32("voteAuthorizationType")])},Withdraw:{index:3,layout:B.struct([B.u32("instruction"),B.ns64("lamports")])},UpdateValidatorIdentity:{index:4,layout:B.struct([B.u32("instruction")])},AuthorizeWithSeed:{index:10,layout:B.struct([B.u32("instruction"),Xp()])}});new ht("Vote111111111111111111111111111111111111111");new ht("Va1idator1nfo111111111111111111111111111111");Y({name:J(),website:ut(J()),details:ut(J()),iconUrl:ut(J()),keybaseUsername:ut(J())});new ht("Vote111111111111111111111111111111111111111");B.struct([Rt("nodePubkey"),Rt("authorizedWithdrawer"),B.u8("commission"),B.nu64(),B.seq(B.struct([B.nu64("slot"),B.u32("confirmationCount")]),B.offset(B.u32(),-8),"votes"),B.u8("rootSlotValid"),B.nu64("rootSlot"),B.nu64(),B.seq(B.struct([B.nu64("epoch"),Rt("authorizedVoter")]),B.offset(B.u32(),-8),"authorizedVoters"),B.struct([B.seq(B.struct([Rt("authorizedPubkey"),B.nu64("epochOfLastAuthorizedSwitch"),B.nu64("targetEpoch")]),32,"buf"),B.nu64("idx"),B.u8("isEmpty")],"priorVoters"),B.nu64(),B.seq(B.struct([B.nu64("epoch"),B.nu64("credits"),B.nu64("prevCredits")]),B.offset(B.u32(),-8),"epochCredits"),B.struct([B.nu64("slot"),B.nu64("timestamp")],"lastTimestamp")]);function Xi(r){switch(r){case"processed":case"confirmed":case"finalized":case void 0:return r;case"recent":return"processed";case"single":case"singleGossip":return"confirmed";case"max":case"root":return"finalized";default:return}}const $o="solana:mainnet",B_="solana:devnet",C_="solana:testnet",L_="solana:localnet",M_="https://api.mainnet-beta.solana.com";function k_(r){return r.includes(M_)?$o:/\bdevnet\b/i.test(r)?B_:/\btestnet\b/i.test(r)?C_:/\blocalhost\b/i.test(r)||/\b127\.0\.0\.1\b/.test(r)?L_:$o}function U_(r,t){if(r===t)return!0;const e=r.length;if(e!==t.length)return!1;for(let n=0;n<e;n++)if(r[n]!==t[n])return!1;return!0}var ot=function(r,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?r!==t||!n:!t.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(r):n?n.value:t.get(r)},ue=function(r,t,e,n,s){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?r!==t||!s:!t.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?s.call(r,e):s?s.value=e:t.set(r,e),e},ge,Ae,ln,fn,sn,Xn,Vr,At,Gr,as,Or,cs,Jn,us,zo,Vo,Go,Ko;class D_ extends ou{get name(){return ot(this,At,"f").name}get url(){return"https://github.com/solana-labs/wallet-standard"}get icon(){return ot(this,At,"f").icon}get readyState(){return ot(this,Gr,"f")}get publicKey(){return ot(this,ln,"f")}get connecting(){return ot(this,fn,"f")}get supportedTransactionVersions(){return ot(this,Vr,"f")}get wallet(){return ot(this,At,"f")}get standard(){return!0}constructor({wallet:t}){super(),ge.add(this),Ae.set(this,void 0),ln.set(this,void 0),fn.set(this,void 0),sn.set(this,void 0),Xn.set(this,void 0),Vr.set(this,void 0),At.set(this,void 0),Gr.set(this,typeof window=="undefined"||typeof document=="undefined"?Qn.Unsupported:Qn.Installed),us.set(this,e=>{if("accounts"in e){const n=ot(this,At,"f").accounts[0];ot(this,Ae,"f")&&!ot(this,sn,"f")&&n!==ot(this,Ae,"f")&&(n?ot(this,ge,"m",Or).call(this,n):(this.emit("error",new nu),ot(this,ge,"m",cs).call(this)))}"features"in e&&ot(this,ge,"m",Jn).call(this)}),ue(this,At,t,"f"),ue(this,Ae,null,"f"),ue(this,ln,null,"f"),ue(this,fn,!1,"f"),ue(this,sn,!1,"f"),ue(this,Xn,ot(this,At,"f").features[ra].on("change",ot(this,us,"f")),"f"),ot(this,ge,"m",Jn).call(this)}destroy(){ue(this,Ae,null,"f"),ue(this,ln,null,"f"),ue(this,fn,!1,"f"),ue(this,sn,!1,"f");const t=ot(this,Xn,"f");t&&(ue(this,Xn,null,"f"),t())}autoConnect(){return H(this,null,function*(){return ot(this,ge,"m",as).call(this,{silent:!0})})}connect(){return H(this,null,function*(){return ot(this,ge,"m",as).call(this)})}disconnect(){return H(this,null,function*(){if(Js in ot(this,At,"f").features)try{ue(this,sn,!0,"f"),yield ot(this,At,"f").features[Js].disconnect()}catch(t){this.emit("error",new ru(t==null?void 0:t.message,t))}finally{ue(this,sn,!1,"f")}ot(this,ge,"m",cs).call(this)})}sendTransaction(s,i){return H(this,arguments,function*(t,e,n={}){try{const c=ot(this,Ae,"f");if(!c)throw new Zn;let d;if(en in ot(this,At,"f").features)if(c.features.includes(en))d=en;else if(pe in ot(this,At,"f").features&&c.features.includes(pe))d=pe;else throw new Nn;else if(pe in ot(this,At,"f").features){if(!c.features.includes(pe))throw new Nn;d=pe}else throw new Hn;const _=k_(e.rpcEndpoint);if(!c.chains.includes(_))throw new Xs;try{const o=n,{signers:b}=o,O=qe(o,["signers"]);let x;if(Wn(t)?(b!=null&&b.length&&t.sign(b),x=t.serialize()):(t=yield this.prepareTransaction(t,e,O),b!=null&&b.length&&t.partialSign(...b),x=new Uint8Array(t.serialize({requireAllSignatures:!1,verifySignatures:!1}))),d===en){const[S]=yield ot(this,At,"f").features[en].signAndSendTransaction({account:c,chain:_,transaction:x,options:{preflightCommitment:Xi(O.preflightCommitment||e.commitment),skipPreflight:O.skipPreflight,maxRetries:O.maxRetries,minContextSlot:O.minContextSlot}});return he.encode(S.signature)}else{const[S]=yield ot(this,At,"f").features[pe].signTransaction({account:c,chain:_,transaction:x,options:{preflightCommitment:Xi(O.preflightCommitment||e.commitment),minContextSlot:O.minContextSlot}});return yield e.sendRawTransaction(S.signedTransaction,yt(lt({},O),{preflightCommitment:Xi(O.preflightCommitment||e.commitment)}))}}catch(b){throw b instanceof ve?b:new Xs(b==null?void 0:b.message,b)}}catch(c){throw this.emit("error",c),c}})}}Ae=new WeakMap,ln=new WeakMap,fn=new WeakMap,sn=new WeakMap,Xn=new WeakMap,Vr=new WeakMap,At=new WeakMap,Gr=new WeakMap,us=new WeakMap,ge=new WeakSet,as=function(t){return H(this,null,function*(){try{if(this.connected||this.connecting)return;if(ot(this,Gr,"f")!==Qn.Installed)throw new tu;if(ue(this,fn,!0,"f"),!ot(this,At,"f").accounts.length)try{yield ot(this,At,"f").features[na].connect(t)}catch(n){throw new eu(n==null?void 0:n.message,n)}const e=ot(this,At,"f").accounts[0];if(!e)throw new Nn;ot(this,ge,"m",Or).call(this,e)}catch(e){throw this.emit("error",e),e}finally{ue(this,fn,!1,"f")}})},Or=function(t){let e;try{e=new ht(t.address)}catch(n){throw new iu(n==null?void 0:n.message,n)}ue(this,Ae,t,"f"),ue(this,ln,e,"f"),ot(this,ge,"m",Jn).call(this),this.emit("connect",e)},cs=function(){ue(this,Ae,null,"f"),ue(this,ln,null,"f"),ot(this,ge,"m",Jn).call(this),this.emit("disconnect")},Jn=function(){var e,n;const t=en in ot(this,At,"f").features?ot(this,At,"f").features[en].supportedTransactionVersions:ot(this,At,"f").features[pe].supportedTransactionVersions;ue(this,Vr,U_(t,["legacy"])?null:new Set(t),"f"),pe in ot(this,At,"f").features&&((e=ot(this,Ae,"f"))!=null&&e.features.includes(pe))?(this.signTransaction=ot(this,ge,"m",zo),this.signAllTransactions=ot(this,ge,"m",Vo)):(delete this.signTransaction,delete this.signAllTransactions),Vn in ot(this,At,"f").features&&((n=ot(this,Ae,"f"))!=null&&n.features.includes(Vn))?this.signMessage=ot(this,ge,"m",Go):delete this.signMessage,vi in ot(this,At,"f").features?this.signIn=ot(this,ge,"m",Ko):delete this.signIn},zo=function(t){return H(this,null,function*(){try{const e=ot(this,Ae,"f");if(!e)throw new Zn;if(!(pe in ot(this,At,"f").features))throw new Hn;if(!e.features.includes(pe))throw new Nn;try{const s=(yield ot(this,At,"f").features[pe].signTransaction({account:e,transaction:Wn(t)?t.serialize():new Uint8Array(t.serialize({requireAllSignatures:!1,verifySignatures:!1}))}))[0].signedTransaction;return Wn(t)?pn.deserialize(s):Te.from(s)}catch(n){throw n instanceof ve?n:new Ys(n==null?void 0:n.message,n)}}catch(e){throw this.emit("error",e),e}})},Vo=function(t){return H(this,null,function*(){try{const e=ot(this,Ae,"f");if(!e)throw new Zn;if(!(pe in ot(this,At,"f").features))throw new Hn;if(!e.features.includes(pe))throw new Nn;try{const n=yield ot(this,At,"f").features[pe].signTransaction(...t.map(s=>({account:e,transaction:Wn(s)?s.serialize():new Uint8Array(s.serialize({requireAllSignatures:!1,verifySignatures:!1}))})));return t.map((s,i)=>{const o=n[i].signedTransaction;return Wn(s)?pn.deserialize(o):Te.from(o)})}catch(n){throw new Ys(n==null?void 0:n.message,n)}}catch(e){throw this.emit("error",e),e}})},Go=function(t){return H(this,null,function*(){try{const e=ot(this,Ae,"f");if(!e)throw new Zn;if(!(Vn in ot(this,At,"f").features))throw new Hn;if(!e.features.includes(Vn))throw new Nn;try{return(yield ot(this,At,"f").features[Vn].signMessage({account:e,message:t}))[0].signature}catch(n){throw new su(n==null?void 0:n.message,n)}}catch(e){throw this.emit("error",e),e}})},Ko=function(){return H(this,arguments,function*(t={}){try{if(!(vi in ot(this,At,"f").features))throw new Hn;let e;try{[e]=yield ot(this,At,"f").features[vi].signIn(t)}catch(n){throw new Zs(n==null?void 0:n.message,n)}if(!e)throw new Zs;return ot(this,ge,"m",Or).call(this,e.account),e}catch(e){throw this.emit("error",e),e}})};class P_{constructor(t){Mt(this,"iframe");Mt(this,"handshakeComplete",!1);Mt(this,"parentAPI",null);Mt(this,"endpoint",null);if(!t)throw new Error("BridgeParent requires an iframe element");this.iframe=t,this.initializeConnection()}initializeConnection(){return H(this,null,function*(){if(!this.iframe||!this.iframe.contentWindow)return;const t=yield this.discoverWallets(),e=this.getSolanaWallets();this.parentAPI={eip6963Wallets:t,eip6963WalletsReady:!0,walletStandardWallets:e,walletStandardWalletsReady:!0},this.endpoint=zc(this.iframe.contentWindow,window,"*"),_s(this.parentAPI,this.endpoint),this.handshakeComplete=!0})}isConnected(){return this.handshakeComplete}discoverWallets(){return H(this,null,function*(){return new Promise(t=>{const e=[],s=i=>{const o=i,{info:c,provider:d}=o.detail;e.findIndex(b=>b.uuid===c.uuid)===-1&&e.push({uuid:c.uuid,name:c.name,icon:c.icon,rdns:c.rdns,provider:d})};window.addEventListener("eip6963:announceProvider",s),window.dispatchEvent(new Event("eip6963:requestProvider")),setTimeout(()=>{window.removeEventListener("eip6963:announceProvider",s),t(e)},1e3)})})}getSolanaWallets(){const{get:t}=jc(),e=t(),n=[],s=new Set;for(const i of e)if(this.isSolanaWallet(i)){let o;au(i)&&(o=new D_({wallet:i})),n.push({uuid:this.generateWalletId(i),name:i.name,chains:i.chains||[],features:Object.keys(i.features),adapter:o?{name:o.name,url:o.url,icon:o.icon,readyState:o.readyState,publicKey:ea({get value(){return o.publicKey},toBase58:()=>H(this,null,function*(){var c;return(c=o.publicKey)==null?void 0:c.toBase58()}),toJSON:()=>H(this,null,function*(){var c;return(c=o.publicKey)==null?void 0:c.toJSON()}),toBytes:()=>H(this,null,function*(){var c;return(c=o.publicKey)==null?void 0:c.toBytes()}),toBuffer:()=>H(this,null,function*(){var c;return(c=o.publicKey)==null?void 0:c.toBuffer()}),toString:()=>H(this,null,function*(){var c;return(c=o.publicKey)==null?void 0:c.toString()})}),connecting:o.connecting,connected:o.connected,supportedTransactionVersions:o.supportedTransactionVersions,wallet:o.wallet,standard:o.standard,destroy:()=>H(this,null,function*(){return yield o.destroy()}),autoConnect:()=>H(this,null,function*(){return yield o.autoConnect()}),connect:()=>H(this,null,function*(){return yield o.connect()}),disconnect:()=>H(this,null,function*(){return yield o.disconnect()}),sendTransaction:(c,d,_)=>H(this,null,function*(){return yield o.sendTransaction(c,d,_)}),signTransaction:c=>H(this,null,function*(){return o.signTransaction!==void 0?yield o.signTransaction(c):new Error("Adapter does not support signTransaction")}),signAllTransactions:c=>H(this,null,function*(){return o.signAllTransactions!==void 0?yield o.signAllTransactions(c):new Error("Adapter does not support signAllTransactions")}),signMessage:c=>H(this,null,function*(){return o.signMessage!==void 0?yield o.signMessage(c):new Error("Adapter does not support signMessage")}),signIn:c=>H(this,null,function*(){return o.signIn!==void 0?yield o.signIn(c):new Error("Adapter does not support signIn")}),customFunctions:["sendSerializedTransaction","signAllSerializedTransactions","signSerializedTransaction"],sendSerializedTransaction:(c,d)=>H(this,null,function*(){const _=new T_(d),b=new Uint8Array(c);let O;try{O=pn.deserialize(b)}catch(x){try{O=Te.from(b)}catch(S){throw new Error("Failed to deserialize transaction as either versioned or legacy format")}}return yield o.sendTransaction(O,_)}),signSerializedTransaction:c=>H(this,null,function*(){if(o.signTransaction===void 0)return new Error("Adapter does not support signTransaction");const d=new Uint8Array(c);let _;try{_=pn.deserialize(d)}catch(b){try{_=Te.from(d)}catch(O){return new Error("Failed to deserialize transaction as either versioned or legacy format")}}return yield o.signTransaction(_)}),signAllSerializedTransactions:c=>H(this,null,function*(){if(o.signAllTransactions===void 0)return new Error("Adapter does not support signAllTransactions");const d=[];for(const _ of c){const b=new Uint8Array(_);let O;try{O=pn.deserialize(b)}catch(x){try{O=Te.from(b)}catch(S){return new Error("Failed to deserialize one or more transactions")}}d.push(O)}return yield o.signAllTransactions(d)})}:void 0}),s.add(i.name)}return n}isSolanaWallet(t){return(t.chains||[]).some(s=>s.startsWith("solana:"))}generateWalletId(t){var n;const e=((n=t.chains)==null?void 0:n[0])||"unknown";return`${t.name}-${e}`.toLowerCase().replace(/\s+/g,"-")}destroy(){this.handshakeComplete=!1,this.parentAPI&&(this.parentAPI.eip6963Wallets=[],this.parentAPI.walletStandardWallets=[],this.parentAPI=null),this.endpoint=null,this.iframe=null}}var ls=function(){return ls=Object.assign||function(r){for(var t,e=1,n=arguments.length;e<n;e++){t=arguments[e];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(r[s]=t[s])}return r},ls.apply(this,arguments)},yc=function(r,t,e,n){function s(i){return i instanceof e?i:new e(function(o){o(i)})}return new(e||(e=Promise))(function(i,o){function c(b){try{_(n.next(b))}catch(O){o(O)}}function d(b){try{_(n.throw(b))}catch(O){o(O)}}function _(b){b.done?i(b.value):s(b.value).then(c,d)}_((n=n.apply(r,t||[])).next())})},wc=function(r,t){var e={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},n,s,i,o=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return o.next=c(0),o.throw=c(1),o.return=c(2),typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function c(_){return function(b){return d([_,b])}}function d(_){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,_[0]&&(e=0)),e;)try{if(n=1,s&&(i=_[0]&2?s.return:_[0]?s.throw||((i=s.return)&&i.call(s),0):s.next)&&!(i=i.call(s,_[1])).done)return i;switch(s=0,i&&(_=[_[0]&2,i.value]),_[0]){case 0:case 1:i=_;break;case 4:return e.label++,{value:_[1],done:!1};case 5:e.label++,s=_[1],_=[0];continue;case 7:_=e.ops.pop(),e.trys.pop();continue;default:if(i=e.trys,!(i=i.length>0&&i[i.length-1])&&(_[0]===6||_[0]===2)){e=0;continue}if(_[0]===3&&(!i||_[1]>i[0]&&_[1]<i[3])){e.label=_[1];break}if(_[0]===6&&e.label<i[1]){e.label=i[1],i=_;break}if(i&&e.label<i[2]){e.label=i[2],e.ops.push(_);break}i[2]&&e.ops.pop(),e.trys.pop();continue}_=t.call(r,e)}catch(b){_=[6,b],s=0}finally{n=i=0}if(_[0]&5)throw _[1];return{value:_[0]?_[1]:void 0,done:!0}}},ft,Ec,Kr,fs=ps,hn=null,Rc=function(){return document.getElementById(fs)};function Yi(r){var t,e=Rc();if(!e){console.warn("Mesh SDK: Failed to deliver ".concat(r.type," message to the iframe - no iframe element found"));return}if(!Kr){console.warn("Mesh SDK: Failed to deliver ".concat(r.type," message to the iframe - no link token origin found"));return}try{(t=e.contentWindow)===null||t===void 0||t.postMessage(r,Kr)}catch(n){console.error("Mesh SDK: Failed to deliver ".concat(r.type," message to the iframe")),console.error(n)}}function F_(r){return yc(this,void 0,void 0,function(){var t,t,t,t,e,n,s,i,o,c,d,_,b,O;return wc(this,function(x){switch(r.data.type){case"brokerageAccountAccessToken":{t={accessToken:r.data.payload},(e=ft==null?void 0:ft.onEvent)===null||e===void 0||e.call(ft,{type:"integrationConnected",payload:t}),(n=ft==null?void 0:ft.onIntegrationConnected)===null||n===void 0||n.call(ft,t);break}case"delayedAuthentication":{t={delayedAuth:r.data.payload},(s=ft==null?void 0:ft.onEvent)===null||s===void 0||s.call(ft,{type:"integrationConnected",payload:t}),(i=ft==null?void 0:ft.onIntegrationConnected)===null||i===void 0||i.call(ft,t);break}case"transferFinished":{t=r.data.payload,(o=ft==null?void 0:ft.onEvent)===null||o===void 0||o.call(ft,{type:"transferCompleted",payload:t}),(c=ft==null?void 0:ft.onTransferFinished)===null||c===void 0||c.call(ft,t);break}case"close":case"done":{t=(d=r.data)===null||d===void 0?void 0:d.payload,(_=ft==null?void 0:ft.onExit)===null||_===void 0||_.call(ft,t==null?void 0:t.errorMessage,t),hn==null||hn.destroy(),gs();break}case"loaded":{Yi({type:"meshSDKSpecs",payload:ls({},Tc)}),ft!=null&&ft.accessTokens&&Yi({type:"frontAccessTokens",payload:ft.accessTokens}),ft!=null&&ft.transferDestinationTokens&&Yi({type:"frontTransferDestinationTokens",payload:ft.transferDestinationTokens}),(b=ft==null?void 0:ft.onEvent)===null||b===void 0||b.call(ft,{type:"pageLoaded"});break}default:{Ho(r.data.type)&&((O=ft==null?void 0:ft.onEvent)===null||O===void 0||O.call(ft,r.data));break}}return[2]})})}function Zi(r){return yc(this,void 0,void 0,function(){return wc(this,function(t){switch(t.label){case 0:return r.origin!==Ec&&r.origin!==Kr?(console.warn("Received message from untrusted origin:",r.origin),[3,3]):[3,1];case 1:return[4,F_(r)];case 2:t.sent(),t.label=3;case 3:return[2]}})})}var q_=function(r){var t=function(n,s){var i,o;if(!n){(i=r==null?void 0:r.onExit)===null||i===void 0||i.call(r,"Invalid link token!");return}ft=r;var c=window.atob(n),d=c.startsWith("http://")||c.startsWith("https://");if(!d){(o=r==null?void 0:r.onExit)===null||o===void 0||o.call(r,"Invalid link token!");return}if(c=$_(c,ft==null?void 0:ft.language),c=z_(c,ft==null?void 0:ft.displayFiatCurrency),Kr=new URL(c).origin,window.removeEventListener("message",Zi),s){var _=document.getElementById(s);_?(_.allow="clipboard-read *; clipboard-write *",_.src=c,fs=s):console.warn("Mesh SDK: No iframe found with id ".concat(s))}else fs=ps,xc(c);window.addEventListener("message",Zi),Ec=window.location.origin;var b=Rc();b&&(hn=new P_(b))},e=function(){var n;hn==null||hn.destroy(),gs(),window.removeEventListener("message",Zi),(n=r.onExit)===null||n===void 0||n.call(r)};return{openLink:t,closeLink:e}};function $_(r,t){return t==="system"&&(t=typeof navigator!="undefined"&&navigator.language?encodeURIComponent(navigator.language):void 0),"".concat(r).concat(r.includes("?")?"&":"?","lng=").concat(t||"en")}function z_(r,t){return t?"".concat(r).concat(r.includes("?")?"&":"?","fiatCur=").concat(t):r}exports.createLink=q_;exports.isLinkEventTypeKey=Ho;
|