@acedatacloud/nexior 3.276.8 → 3.276.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{ApiCodeButton-Bh7MvG8M.js → ApiCodeButton-Bbnpv2we.js} +1 -1
- package/dist/assets/{AskUserQuestionCard-DAnli3JF.js → AskUserQuestionCard-BVxoetPM.js} +1 -1
- package/dist/assets/{Auth-DhRA4HXb.js → Auth-CNen58mm.js} +1 -1
- package/dist/assets/{Bare-CLamPr99.js → Bare-CGAgBPOB.js} +1 -1
- package/dist/assets/{BotPlaceholder-BEoJFSAj.js → BotPlaceholder-DwmD_q7g.js} +1 -1
- package/dist/assets/{BottomFooter-Cd8czJ_H.js → BottomFooter-CEzUsQct.js} +1 -1
- package/dist/assets/{Callback-CM3iAVeO.js → Callback-iH6gl5RZ.js} +1 -1
- package/dist/assets/{Console-gA1oY5q7.js → Console-D-TGm246.js} +1 -1
- package/dist/assets/{Consumption-Dz9ldr1b.js → Consumption-fBw5c2fv.js} +1 -1
- package/dist/assets/{Conversation-D1fPa0__.js → Conversation-Db8OI0L6.js} +1 -1
- package/dist/assets/{CopyToClipboard-B6VjUELv.js → CopyToClipboard-Dw5puTqb.js} +1 -1
- package/dist/assets/{Detail-DCDYMp2j.js → Detail-CwyQYM3g.js} +2 -2
- package/dist/assets/{Extra-BzexvI4u.js → Extra-BBboONST.js} +1 -1
- package/dist/assets/{FilePreview-DS15--Gg.js → FilePreview-QJNK0WA2.js} +1 -1
- package/dist/assets/{Hailuo-CtNs819u.js → Hailuo-oOc1n_8n.js} +1 -1
- package/dist/assets/{History-BMUcgBTo.js → History-DUBBRNc_.js} +1 -1
- package/dist/assets/{ImagePreview-BmXAQ9NR.js → ImagePreview-j8UOiTmY.js} +1 -1
- package/dist/assets/{ImageWrapper-8aZD0Rkr.js → ImageWrapper-B2i7ZIND.js} +1 -1
- package/dist/assets/{Index-DIbs_ENJ.js → Index-81Ej0AoN.js} +1 -1
- package/dist/assets/{Index-N5K1ZS-C.js → Index-B4FOwiSY.js} +1 -1
- package/dist/assets/{Index-BHddoJua.css → Index-BTLk2lYy.css} +1 -1
- package/dist/assets/{Index-BvG95EIg.js → Index-BTdyPJrt.js} +1 -1
- package/dist/assets/{Index-D5cOnzWS.css → Index-Be5la0_9.css} +1 -1
- package/dist/assets/Index-BuHPy3VQ.js +1 -0
- package/dist/assets/{Index-CWlAa0Ua.css → Index-C2JSQHAI.css} +1 -1
- package/dist/assets/{Index-DgJOijMV.css → Index-C7fQZrR7.css} +1 -1
- package/dist/assets/Index-CDkRF2hQ.js +1 -0
- package/dist/assets/{Index-CW6ptuq8.js → Index-CFo7aI_z.js} +1 -1
- package/dist/assets/{Index-AAuXyOqs.css → Index-CP3thN21.css} +1 -1
- package/dist/assets/{Index-DJaHsv0E.css → Index-CUINP6wJ.css} +1 -1
- package/dist/assets/{Index-CTuqGMHy.js → Index-CWc2Xre6.js} +1 -1
- package/dist/assets/{Index-B3X70am-.js → Index-Cf2TydGq.js} +1 -1
- package/dist/assets/{Index-Dz4AjgBe.js → Index-CiXvUNJ8.js} +1 -1
- package/dist/assets/{Index-BefGvk5t.js → Index-Cic686gl.js} +1 -1
- package/dist/assets/{Index-Bvq-Py50.js → Index-Craz4iUs.js} +1 -1
- package/dist/assets/{Index-NQ7RzA14.js → Index-Csm8l8XE.js} +1 -1
- package/dist/assets/{Index-CU8SPmug.js → Index-D21pa7we.js} +1 -1
- package/dist/assets/{Index-ffRs3wGY.js → Index-DCtMoJPV.js} +1 -1
- package/dist/assets/{Index-yQjKaM44.js → Index-DRkOF5di.js} +1 -1
- package/dist/assets/{Index-AFjytgld.js → Index-DSkkPOuY.js} +1 -1
- package/dist/assets/{Index-DA1Bfeae.js → Index-DqWmPcIJ.js} +1 -1
- package/dist/assets/{Index-HrcKfEst.js → Index-DrYXsJXl.js} +1 -1
- package/dist/assets/{Index-BKno8b1B.js → Index-Dt5nN_pF.js} +1 -1
- package/dist/assets/{Index-BAY2gHzH.js → Index-PwBzw5zz.js} +1 -1
- package/dist/assets/{Index-dBHrDNCH.js → Index-UHom_TYH.js} +1 -1
- package/dist/assets/{Index-CPuDvzSR.js → Index-bZ2eC93Z.js} +1 -1
- package/dist/assets/{Index-CP8kMi0H.js → Index-d-cy26fm.js} +1 -1
- package/dist/assets/{Index-Bhn_LThd.js → Index-eUm2e3Dg.js} +1 -1
- package/dist/assets/{Index-1tKaVlvl.js → Index-t6Jgc_Ua.js} +1 -1
- package/dist/assets/{Index-BbpYWnH2.js → Index-tJVQwQxJ.js} +1 -1
- package/dist/assets/{Invitees-C-58dkCU.js → Invitees-X-GM1iAs.js} +1 -1
- package/dist/assets/{List-w1-Nb80i.js → List-BjzUfDGL.js} +1 -1
- package/dist/assets/{List-D9mFlDId.js → List-C57rcn3v.js} +1 -1
- package/dist/assets/{List-ScwNFzCv.js → List-Dule_pxm.js} +1 -1
- package/dist/assets/{Main-saY93xm-.js → Main-0LOwc6E9.js} +1 -1
- package/dist/assets/{Model-CfcBado1.js → Model-CzvoV7ym.js} +1 -1
- package/dist/assets/{Navigator-CKVfErP9.js → Navigator-D31Vqv1W.js} +1 -1
- package/dist/assets/{NoTasks-CC3qAIGB.js → NoTasks-vOEmwSFQ.js} +1 -1
- package/dist/assets/{NotFound-D13r78Cy.js → NotFound-g-g99Hgd.js} +1 -1
- package/dist/assets/{Pagination-BthTDXD8.js → Pagination-BrKhHCVU.js} +1 -1
- package/dist/assets/{Pay-BejKoKha.js → Pay-CasL-0lk.js} +1 -1
- package/dist/assets/{Player-DpTwGN-K.js → Player-BeKsc7BW.js} +1 -1
- package/dist/assets/{Seedance-CRrMgJTS.js → Seedance-aCh0t58m.js} +1 -1
- package/dist/assets/{Status-BaU7dcng.js → Status-BZbIXVeT.js} +1 -1
- package/dist/assets/{Subscribe-CkfNCZhk.js → Subscribe-DFm1FT9k.js} +1 -1
- package/dist/assets/{TabSwitcher-BU_ROT2b.js → TabSwitcher-ChpsZAHj.js} +1 -1
- package/dist/assets/{Tts-rYPR7eWt.js → Tts-DHy0H9vF.js} +1 -1
- package/dist/assets/{VideoPlayer-DhMF5hh_.js → VideoPlayer-C6O7JCcj.js} +1 -1
- package/dist/assets/{avatar-C7T6nDHr.js → avatar-CJaAkR4u.js} +1 -1
- package/dist/assets/{basic-BoLaf3WL.js → basic-fTQpqVx3.js} +1 -1
- package/dist/assets/{chat-2mywacwx.js → chat-4c2gdzaU.js} +1 -1
- package/dist/assets/{codingBridge-ChlOPHaQ.js → codingBridge-Dgq-US77.js} +1 -1
- package/dist/assets/{codingBridgeNotify-DlAeIpRs.js → codingBridgeNotify-Cd3sO6PS.js} +2 -2
- package/dist/assets/{collapse-BNQsbKoD.js → collapse-6hEfnElE.js} +1 -1
- package/dist/assets/{createTaskActions-CRnKwswS.js → createTaskActions-Bqo-fGQq.js} +1 -1
- package/dist/assets/{date-picker-ChUYmRRu.js → date-picker-BULvgRJu.js} +1 -1
- package/dist/assets/{dropdown-Bn7lLCwK.js → dropdown-CPemIUgw.js} +1 -1
- package/dist/assets/{esm-B6aa11co.js → esm-B-63frdI.js} +1 -1
- package/dist/assets/{esm-5mg-DChh.js → esm-B09dJTiV.js} +2 -2
- package/dist/assets/{esm-C-8zkKoQ.js → esm-BwKgXwfT.js} +3 -3
- package/dist/assets/{esm-CPVmW96q.js → esm-CSszv0A8.js} +1 -1
- package/dist/assets/{esm-Cy9AGPk3.js → esm-C_mhJFSi.js} +2 -2
- package/dist/assets/esm-DS6UqAt9.js +1 -0
- package/dist/assets/{esm-DqmrbsZj.js → esm-dDvPMSAk.js} +1 -1
- package/dist/assets/{fish-BdyZ_dei.js → fish-D0MRHzev.js} +1 -1
- package/dist/assets/{flux-DY5KnKSo.js → flux-Q8UP_79t.js} +1 -1
- package/dist/assets/{grokvideo-DXWYcv6c.js → grokvideo-BmGuOcoY.js} +1 -1
- package/dist/assets/{hailuo-Co2caePa.js → hailuo-D4t3b5r0.js} +1 -1
- package/dist/assets/{headshots-J8X2JLJ8.js → headshots-oed2z6H2.js} +1 -1
- package/dist/assets/{image-afx4VAs8.js → image-DhZ3AYYg.js} +1 -1
- package/dist/assets/{index-BLOAxTz6.css → index-8HYiV8-4.css} +1 -1
- package/dist/assets/{index-C_fXMz33.js → index-CZaid7Ez.js} +3 -3
- package/dist/assets/{index.browser.esm-B8mvVuXe.js → index.browser.esm-DP3TGf8g.js} +1 -1
- package/dist/assets/{index.es-c1dbE6io.js → index.es-SMgxJgUT.js} +1 -1
- package/dist/assets/{input-number-DdTvn5Mo.js → input-number-BLiYIcDP.js} +1 -1
- package/dist/assets/{kling-Ba0hgKL0.js → kling-BzClI2Ea.js} +1 -1
- package/dist/assets/{luma-HwwyTs-K.js → luma-DU9G57WM.js} +1 -1
- package/dist/assets/{midjourney-D_QA16FX.js → midjourney-Cc0ajBsl.js} +1 -1
- package/dist/assets/{nanobanana-BF4b6iq_.js → nanobanana-BY58gC77.js} +1 -1
- package/dist/assets/{openaiimage-BLbpVTTI.js → openaiimage-tGjAf4lm.js} +1 -1
- package/dist/assets/{pagination-BjQtI9TY.js → pagination-8ujfpoRu.js} +1 -1
- package/dist/assets/{pika-CaLoQ_Of.js → pika-CgJnavji.js} +1 -1
- package/dist/assets/{pixverse-Dh8FbD68.js → pixverse-BCJeX-Nw.js} +1 -1
- package/dist/assets/{popover-BWuwcNn-.js → popover-l_NEWD77.js} +1 -1
- package/dist/assets/{producer-Cp3PTPJf.js → producer-D4z9F8wF.js} +1 -1
- package/dist/assets/{qrart-B81Oc4_A.js → qrart-BBrOqeL5.js} +1 -1
- package/dist/assets/{row-BC1rqeFh.js → row-UUMjQQpA.js} +1 -1
- package/dist/assets/{seedance-D-Z6nJxh.js → seedance-dkFENRGb.js} +1 -1
- package/dist/assets/{seedream-uiWKXuIG.js → seedream-pZlfw7_H.js} +1 -1
- package/dist/assets/{select-Bt5H7nZr.js → select-BdxNJvVA.js} +1 -1
- package/dist/assets/{serp-BJOSgQYk.js → serp-FUo1xZRs.js} +1 -1
- package/dist/assets/{slider-BcWhugAv.js → slider-DCyKC0oi.js} +1 -1
- package/dist/assets/{solana-wallets-DtMBbfQH.js → solana-wallets-BUDqS69n.js} +2 -2
- package/dist/assets/{solana-wallets-vue-vFrY1_Vp.js → solana-wallets-vue-Dpf0qyDD.js} +1 -1
- package/dist/assets/{sora-CQ_5dXAq.js → sora-BlVuN_Ii.js} +1 -1
- package/dist/assets/{suno-Cu8Ic9zN.js → suno-CMBHVDrg.js} +1 -1
- package/dist/assets/{switch-CQ6QMIHh.js → switch-BLmaNxij.js} +1 -1
- package/dist/assets/{tabs-7LX0WWGI.js → tabs-Vpcr2eiv.js} +1 -1
- package/dist/assets/{upload-DbS-qeHo.js → upload-cst9ChUG.js} +1 -1
- package/dist/assets/{veo-DAy7lO7I.js → veo-CxUtDftf.js} +1 -1
- package/dist/assets/{wan-DcQ8r4Lk.js → wan-CWDRGL7F.js} +1 -1
- package/dist/assets/{web-BkR2LoJT.js → web-CVFBwohm.js} +1 -1
- package/dist/assets/{web-cMBizojx.js → web-CxcIP-Cm.js} +1 -1
- package/dist/assets/{web-TEd2Ixw2.js → web-DjicWepk.js} +1 -1
- package/dist/assets/{web-BLPgMp8V.js → web-GneIBay4.js} +1 -1
- package/dist/assets/{web-DfQ_G6ra.js → web-c3SDcorL.js} +1 -1
- package/dist/assets/{webextrator-qwMTjFJL.js → webextrator-I0TZD5lE.js} +1 -1
- package/dist/index.html +2 -2
- package/package.json +1 -1
- package/dist/assets/Index-BvWOJi4N.js +0 -1
- package/dist/assets/Index-CffFGZyq.js +0 -1
- package/dist/assets/esm-Cr21PbL5.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e,n as t,o as n,r,t as i}from"./rolldown-runtime--c01j_DQ.js";import{Pn as a}from"./index-C_fXMz33.js";import{n as o}from"./eventemitter3-CwKRT-4Q.js";var s=BigInt(2**32-1),c=BigInt(32);function l(e,t=!1){return t?{h:Number(e&s),l:Number(e>>c&s)}:{h:Number(e>>c&s)|0,l:Number(e&s)|0}}function u(e,t=!1){let n=e.length,r=new Uint32Array(n),i=new Uint32Array(n);for(let a=0;a<n;a++){let{h:n,l:o}=l(e[a],t);[r[a],i[a]]=[n,o]}return[r,i]}var d=(e,t,n)=>e>>>n,f=(e,t,n)=>e<<32-n|t>>>n,p=(e,t,n)=>e>>>n|t<<32-n,m=(e,t,n)=>e<<32-n|t>>>n,h=(e,t,n)=>e<<64-n|t>>>n-32,g=(e,t,n)=>e>>>n-32|t<<64-n,_=(e,t,n)=>e<<n|t>>>32-n,v=(e,t,n)=>t<<n|e>>>32-n,y=(e,t,n)=>t<<n-32|e>>>64-n,b=(e,t,n)=>e<<n-32|t>>>64-n;function x(e,t,n,r){let i=(t>>>0)+(r>>>0);return{h:e+n+(i/2**32|0)|0,l:i|0}}var ee=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),S=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,C=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),w=(e,t,n,r,i)=>t+n+r+i+(e/2**32|0)|0,T=(e,t,n,r,i)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(i>>>0),E=(e,t,n,r,i,a)=>t+n+r+i+a+(e/2**32|0)|0,D=typeof globalThis==`object`&&`crypto`in globalThis?globalThis.crypto:void 0;function O(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`}function k(e){if(!Number.isSafeInteger(e)||e<0)throw Error(`positive integer expected, got `+e)}function te(e,...t){if(!O(e))throw Error(`Uint8Array expected`);if(t.length>0&&!t.includes(e.length))throw Error(`Uint8Array expected of length `+t+`, got length=`+e.length)}function ne(e){if(typeof e!=`function`||typeof e.create!=`function`)throw Error(`Hash should be wrapped by utils.createHasher`);k(e.outputLen),k(e.blockLen)}function A(e,t=!0){if(e.destroyed)throw Error(`Hash instance has been destroyed`);if(t&&e.finished)throw Error(`Hash#digest() has already been called`)}function re(e,t){te(e);let n=t.outputLen;if(e.length<n)throw Error(`digestInto() expects output buffer of length at least `+n)}function ie(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function j(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function ae(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function M(e,t){return e<<32-t|e>>>t}var oe=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function se(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function ce(e){for(let t=0;t<e.length;t++)e[t]=se(e[t]);return e}var le=oe?e=>e:ce,ue=typeof Uint8Array.from([]).toHex==`function`&&typeof Uint8Array.fromHex==`function`,de=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function N(e){if(te(e),ue)return e.toHex();let t=``;for(let n=0;n<e.length;n++)t+=de[e[n]];return t}var fe={_0:48,_9:57,A:65,F:70,a:97,f:102};function pe(e){if(e>=fe._0&&e<=fe._9)return e-fe._0;if(e>=fe.A&&e<=fe.F)return e-(fe.A-10);if(e>=fe.a&&e<=fe.f)return e-(fe.a-10)}function me(e){if(typeof e!=`string`)throw Error(`hex string expected, got `+typeof e);if(ue)return Uint8Array.fromHex(e);let t=e.length,n=t/2;if(t%2)throw Error(`hex string expected, got unpadded hex of length `+t);let r=new Uint8Array(n);for(let t=0,i=0;t<n;t++,i+=2){let n=pe(e.charCodeAt(i)),a=pe(e.charCodeAt(i+1));if(n===void 0||a===void 0){let t=e[i]+e[i+1];throw Error(`hex string expected, got non-hex character "`+t+`" at index `+i)}r[t]=n*16+a}return r}function he(e){if(typeof e!=`string`)throw Error(`string expected`);return new Uint8Array(new TextEncoder().encode(e))}function P(e){return typeof e==`string`&&(e=he(e)),te(e),e}function F(...e){let t=0;for(let n=0;n<e.length;n++){let r=e[n];te(r),t+=r.length}let n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){let i=e[t];n.set(i,r),r+=i.length}return n}var ge=class{};function _e(e){let t=t=>e().update(P(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function ve(e=32){if(D&&typeof D.getRandomValues==`function`)return D.getRandomValues(new Uint8Array(e));if(D&&typeof D.randomBytes==`function`)return Uint8Array.from(D.randomBytes(e));throw Error(`crypto.getRandomValues must be defined`)}var ye=BigInt(0),be=BigInt(1),xe=BigInt(2),Se=BigInt(7),Ce=BigInt(256),we=BigInt(113),Te=[],Ee=[],De=[];for(let e=0,t=be,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],Te.push(2*(5*r+n)),Ee.push((e+1)*(e+2)/2%64);let i=ye;for(let e=0;e<7;e++)t=(t<<be^(t>>Se)*we)%Ce,t&xe&&(i^=be<<(be<<BigInt(e))-be);De.push(i)}var Oe=u(De,!0),ke=Oe[0],Ae=Oe[1],je=(e,t,n)=>n>32?y(e,t,n):_(e,t,n),Me=(e,t,n)=>n>32?b(e,t,n):v(e,t,n);function Ne(e,t=24){let n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let t=0;t<10;t++)n[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){let r=(t+8)%10,i=(t+2)%10,a=n[i],o=n[i+1],s=je(a,o,1)^n[r],c=Me(a,o,1)^n[r+1];for(let n=0;n<50;n+=10)e[t+n]^=s,e[t+n+1]^=c}let t=e[2],i=e[3];for(let n=0;n<24;n++){let r=Ee[n],a=je(t,i,r),o=Me(t,i,r),s=Te[n];t=e[s],i=e[s+1],e[s]=a,e[s+1]=o}for(let t=0;t<50;t+=10){for(let r=0;r<10;r++)n[r]=e[t+r];for(let r=0;r<10;r++)e[t+r]^=~n[(r+2)%10]&n[(r+4)%10]}e[0]^=ke[r],e[1]^=Ae[r]}j(n)}var Pe=class e extends ge{constructor(e,t,n,r=!1,i=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=r,this.rounds=i,k(n),!(0<e&&e<200))throw Error(`only keccak-f1600 function is supported`);this.state=new Uint8Array(200),this.state32=ie(this.state)}clone(){return this._cloneInto()}keccak(){le(this.state32),Ne(this.state32,this.rounds),le(this.state32),this.posOut=0,this.pos=0}update(e){A(this),e=P(e),te(e);let{blockLen:t,state:n}=this,r=e.length;for(let i=0;i<r;){let a=Math.min(t-this.pos,r-i);for(let t=0;t<a;t++)n[this.pos++]^=e[i++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:t,pos:n,blockLen:r}=this;e[n]^=t,t&128&&n===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){A(this,!1),te(e),this.finish();let t=this.state,{blockLen:n}=this;for(let r=0,i=e.length;r<i;){this.posOut>=n&&this.keccak();let a=Math.min(n-this.posOut,i-r);e.set(t.subarray(this.posOut,this.posOut+a),r),this.posOut+=a,r+=a}return e}xofInto(e){if(!this.enableXOF)throw Error(`XOF is not possible for this instance`);return this.writeInto(e)}xof(e){return k(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(re(e,this),this.finished)throw Error(`digest() was already called`);return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,j(this.state)}_cloneInto(t){let{blockLen:n,suffix:r,outputLen:i,rounds:a,enableXOF:o}=this;return t||=new e(n,r,i,o,a),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=a,t.suffix=r,t.outputLen=i,t.enableXOF=o,t.destroyed=this.destroyed,t}},Fe=((e,t,n)=>_e(()=>new Pe(t,e,n)))(1,136,256/8);function Ie(e,t,n,r){if(typeof e.setBigUint64==`function`)return e.setBigUint64(t,n,r);let i=BigInt(32),a=BigInt(4294967295),o=Number(n>>i&a),s=Number(n&a),c=r?4:0,l=r?0:4;e.setUint32(t+c,o,r),e.setUint32(t+l,s,r)}function Le(e,t,n){return e&t^~e&n}function Re(e,t,n){return e&t^e&n^t&n}var ze=class extends ge{constructor(e,t,n,r){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=ae(this.buffer)}update(e){A(this),e=P(e),te(e);let{view:t,buffer:n,blockLen:r}=this,i=e.length;for(let a=0;a<i;){let o=Math.min(r-this.pos,i-a);if(o===r){let t=ae(e);for(;r<=i-a;a+=r)this.process(t,a);continue}n.set(e.subarray(a,a+o),this.pos),this.pos+=o,a+=o,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){A(this),re(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:r,isLE:i}=this,{pos:a}=this;t[a++]=128,j(this.buffer.subarray(a)),this.padOffset>r-a&&(this.process(n,0),a=0);for(let e=a;e<r;e++)t[e]=0;Ie(n,r-8,BigInt(this.length*8),i),this.process(n,0);let o=ae(e),s=this.outputLen;if(s%4)throw Error(`_sha2: outputLen should be aligned to 32bit`);let c=s/4,l=this.get();if(c>l.length)throw Error(`_sha2: outputLen bigger than state`);for(let e=0;e<c;e++)o.setUint32(4*e,l[e],i)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||=new this.constructor,e.set(...this.get());let{blockLen:t,buffer:n,length:r,finished:i,destroyed:a,pos:o}=this;return e.destroyed=a,e.finished=i,e.length=r,e.pos=o,r%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}},Be=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ve=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),He=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]),Ue=new Uint32Array(64),We=class extends ze{constructor(e=32){super(64,e,8,!1),this.A=Be[0]|0,this.B=Be[1]|0,this.C=Be[2]|0,this.D=Be[3]|0,this.E=Be[4]|0,this.F=Be[5]|0,this.G=Be[6]|0,this.H=Be[7]|0}get(){let{A:e,B:t,C:n,D:r,E:i,F:a,G:o,H:s}=this;return[e,t,n,r,i,a,o,s]}set(e,t,n,r,i,a,o,s){this.A=e|0,this.B=t|0,this.C=n|0,this.D=r|0,this.E=i|0,this.F=a|0,this.G=o|0,this.H=s|0}process(e,t){for(let n=0;n<16;n++,t+=4)Ue[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){let t=Ue[e-15],n=Ue[e-2],r=M(t,7)^M(t,18)^t>>>3;Ue[e]=(M(n,17)^M(n,19)^n>>>10)+Ue[e-7]+r+Ue[e-16]|0}let{A:n,B:r,C:i,D:a,E:o,F:s,G:c,H:l}=this;for(let e=0;e<64;e++){let t=M(o,6)^M(o,11)^M(o,25),u=l+t+Le(o,s,c)+He[e]+Ue[e]|0,d=(M(n,2)^M(n,13)^M(n,22))+Re(n,r,i)|0;l=c,c=s,s=o,o=a+u|0,a=i,i=r,r=n,n=u+d|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,a=a+this.D|0,o=o+this.E|0,s=s+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,i,a,o,s,c,l)}roundClean(){j(Ue)}destroy(){this.set(0,0,0,0,0,0,0,0),j(this.buffer)}},Ge=u(`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`.split(`.`).map(e=>BigInt(e))),Ke=Ge[0],qe=Ge[1],Je=new Uint32Array(80),Ye=new Uint32Array(80),Xe=class extends ze{constructor(e=64){super(128,e,16,!1),this.Ah=Ve[0]|0,this.Al=Ve[1]|0,this.Bh=Ve[2]|0,this.Bl=Ve[3]|0,this.Ch=Ve[4]|0,this.Cl=Ve[5]|0,this.Dh=Ve[6]|0,this.Dl=Ve[7]|0,this.Eh=Ve[8]|0,this.El=Ve[9]|0,this.Fh=Ve[10]|0,this.Fl=Ve[11]|0,this.Gh=Ve[12]|0,this.Gl=Ve[13]|0,this.Hh=Ve[14]|0,this.Hl=Ve[15]|0}get(){let{Ah:e,Al:t,Bh:n,Bl:r,Ch:i,Cl:a,Dh:o,Dl:s,Eh:c,El:l,Fh:u,Fl:d,Gh:f,Gl:p,Hh:m,Hl:h}=this;return[e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h]}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=r|0,this.Ch=i|0,this.Cl=a|0,this.Dh=o|0,this.Dl=s|0,this.Eh=c|0,this.El=l|0,this.Fh=u|0,this.Fl=d|0,this.Gh=f|0,this.Gl=p|0,this.Hh=m|0,this.Hl=h|0}process(e,t){for(let n=0;n<16;n++,t+=4)Je[n]=e.getUint32(t),Ye[n]=e.getUint32(t+=4);for(let e=16;e<80;e++){let t=Je[e-15]|0,n=Ye[e-15]|0,r=p(t,n,1)^p(t,n,8)^d(t,n,7),i=m(t,n,1)^m(t,n,8)^f(t,n,7),a=Je[e-2]|0,o=Ye[e-2]|0,s=p(a,o,19)^h(a,o,61)^d(a,o,6),c=C(i,m(a,o,19)^g(a,o,61)^f(a,o,6),Ye[e-7],Ye[e-16]);Je[e]=w(c,r,s,Je[e-7],Je[e-16])|0,Ye[e]=c|0}let{Ah:n,Al:r,Bh:i,Bl:a,Ch:o,Cl:s,Dh:c,Dl:l,Eh:u,El:_,Fh:v,Fl:y,Gh:b,Gl:D,Hh:O,Hl:k}=this;for(let e=0;e<80;e++){let t=p(u,_,14)^p(u,_,18)^h(u,_,41),d=m(u,_,14)^m(u,_,18)^g(u,_,41),f=u&v^~u&b,C=_&y^~_&D,w=T(k,d,C,qe[e],Ye[e]),te=E(w,O,t,f,Ke[e],Je[e]),ne=w|0,A=p(n,r,28)^h(n,r,34)^h(n,r,39),re=m(n,r,28)^g(n,r,34)^g(n,r,39),ie=n&i^n&o^i&o,j=r&a^r&s^a&s;O=b|0,k=D|0,b=v|0,D=y|0,v=u|0,y=_|0,{h:u,l:_}=x(c|0,l|0,te|0,ne|0),c=o|0,l=s|0,o=i|0,s=a|0,i=n|0,a=r|0;let ae=ee(ne,re,j);n=S(ae,te,A,ie),r=ae|0}({h:n,l:r}=x(this.Ah|0,this.Al|0,n|0,r|0)),{h:i,l:a}=x(this.Bh|0,this.Bl|0,i|0,a|0),{h:o,l:s}=x(this.Ch|0,this.Cl|0,o|0,s|0),{h:c,l}=x(this.Dh|0,this.Dl|0,c|0,l|0),{h:u,l:_}=x(this.Eh|0,this.El|0,u|0,_|0),{h:v,l:y}=x(this.Fh|0,this.Fl|0,v|0,y|0),{h:b,l:D}=x(this.Gh|0,this.Gl|0,b|0,D|0),{h:O,l:k}=x(this.Hh|0,this.Hl|0,O|0,k|0),this.set(n,r,i,a,o,s,c,l,u,_,v,y,b,D,O,k)}roundClean(){j(Je,Ye)}destroy(){j(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},Ze=_e(()=>new We),Qe=_e(()=>new Xe),$e=Ze,et=class extends ge{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,ne(e);let n=P(t);if(this.iHash=e.create(),typeof this.iHash.update!=`function`)throw Error(`Expected instance of class which extends utils.Hash`);this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let r=this.blockLen,i=new Uint8Array(r);i.set(n.length>r?e.create().update(n).digest():n);for(let e=0;e<i.length;e++)i[e]^=54;this.iHash.update(i),this.oHash=e.create();for(let e=0;e<i.length;e++)i[e]^=106;this.oHash.update(i),j(i)}update(e){return A(this),this.iHash.update(e),this}digestInto(e){A(this),te(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:t,iHash:n,finished:r,destroyed:i,blockLen:a,outputLen:o}=this;return e=e,e.finished=r,e.destroyed=i,e.blockLen=a,e.outputLen=o,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},tt=(e,t,n)=>new et(e,t).update(n).digest();tt.create=(e,t)=>new et(e,t);var nt=i((e=>{e.byteLength=c,e.toByteArray=u,e.fromByteArray=p;for(var t=[],n=[],r=typeof Uint8Array<`u`?Uint8Array:Array,i=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,a=0,o=i.length;a<o;++a)t[a]=i[a],n[i.charCodeAt(a)]=a;n[45]=62,n[95]=63;function s(e){var t=e.length;if(t%4>0)throw Error(`Invalid string. Length must be a multiple of 4`);var n=e.indexOf(`=`);n===-1&&(n=t);var r=n===t?0:4-n%4;return[n,r]}function c(e){var t=s(e),n=t[0],r=t[1];return(n+r)*3/4-r}function l(e,t,n){return(t+n)*3/4-n}function u(e){var t,i=s(e),a=i[0],o=i[1],c=new r(l(e,a,o)),u=0,d=o>0?a-4:a,f;for(f=0;f<d;f+=4)t=n[e.charCodeAt(f)]<<18|n[e.charCodeAt(f+1)]<<12|n[e.charCodeAt(f+2)]<<6|n[e.charCodeAt(f+3)],c[u++]=t>>16&255,c[u++]=t>>8&255,c[u++]=t&255;return o===2&&(t=n[e.charCodeAt(f)]<<2|n[e.charCodeAt(f+1)]>>4,c[u++]=t&255),o===1&&(t=n[e.charCodeAt(f)]<<10|n[e.charCodeAt(f+1)]<<4|n[e.charCodeAt(f+2)]>>2,c[u++]=t>>8&255,c[u++]=t&255),c}function d(e){return t[e>>18&63]+t[e>>12&63]+t[e>>6&63]+t[e&63]}function f(e,t,n){for(var r,i=[],a=t;a<n;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(e[a+2]&255),i.push(d(r));return i.join(``)}function p(e){for(var n,r=e.length,i=r%3,a=[],o=16383,s=0,c=r-i;s<c;s+=o)a.push(f(e,s,s+o>c?c:s+o));return i===1?(n=e[r-1],a.push(t[n>>2]+t[n<<4&63]+`==`)):i===2&&(n=(e[r-2]<<8)+e[r-1],a.push(t[n>>10]+t[n>>4&63]+t[n<<2&63]+`=`)),a.join(``)}})),rt=i((e=>{e.read=function(e,t,n,r,i){var a,o,s=i*8-r-1,c=(1<<s)-1,l=c>>1,u=-7,d=n?i-1:0,f=n?-1:1,p=e[t+d];for(d+=f,a=p&(1<<-u)-1,p>>=-u,u+=s;u>0;a=a*256+e[t+d],d+=f,u-=8);for(o=a&(1<<-u)-1,a>>=-u,u+=r;u>0;o=o*256+e[t+d],d+=f,u-=8);if(a===0)a=1-l;else if(a===c)return o?NaN:(p?-1:1)*(1/0);else o+=2**r,a-=l;return(p?-1:1)*o*2**(a-r)},e.write=function(e,t,n,r,i,a){var o,s,c,l=a*8-i-1,u=(1<<l)-1,d=u>>1,f=i===23?2**-24-2**-77:0,p=r?0:a-1,m=r?1:-1,h=+(t<0||t===0&&1/t<0);for(t=Math.abs(t),isNaN(t)||t===1/0?(s=+!!isNaN(t),o=u):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=2**-o)<1&&(o--,c*=2),o+d>=1?t+=f/c:t+=f*2**(1-d),t*c>=2&&(o++,c/=2),o+d>=u?(s=0,o=u):o+d>=1?(s=(t*c-1)*2**i,o+=d):(s=t*2**(d-1)*2**i,o=0));i>=8;e[n+p]=s&255,p+=m,s/=256,i-=8);for(o=o<<i|s,l+=i;l>0;e[n+p]=o&255,p+=m,o/=256,l-=8);e[n+p-m]|=h*128}})),it=i((e=>{var t=nt(),n=rt(),r=typeof Symbol==`function`&&typeof Symbol.for==`function`?Symbol.for(`nodejs.util.inspect.custom`):null;e.Buffer=s,e.SlowBuffer=v,e.INSPECT_MAX_BYTES=50;var i=2147483647;e.kMaxLength=i,s.TYPED_ARRAY_SUPPORT=a(),!s.TYPED_ARRAY_SUPPORT&&typeof console<`u`&&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 a(){try{let e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),e.foo()===42}catch{return!1}}Object.defineProperty(s.prototype,"parent",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.buffer}}),Object.defineProperty(s.prototype,"offset",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.byteOffset}});function o(e){if(e>i)throw RangeError(`The value "`+e+`" is invalid for option "size"`);let t=new Uint8Array(e);return Object.setPrototypeOf(t,s.prototype),t}function s(e,t,n){if(typeof e==`number`){if(typeof t==`string`)throw TypeError(`The "string" argument must be of type string. Received type number`);return d(e)}return c(e,t,n)}s.poolSize=8192;function c(e,t,n){if(typeof e==`string`)return f(e,t);if(ArrayBuffer.isView(e))return m(e);if(e==null)throw TypeError(`The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type `+typeof e);if(Se(e,ArrayBuffer)||e&&Se(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<`u`&&(Se(e,SharedArrayBuffer)||e&&Se(e.buffer,SharedArrayBuffer)))return h(e,t,n);if(typeof e==`number`)throw TypeError(`The "value" argument must not be of type number. Received type number`);let r=e.valueOf&&e.valueOf();if(r!=null&&r!==e)return s.from(r,t,n);let i=g(e);if(i)return i;if(typeof Symbol<`u`&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]==`function`)return s.from(e[Symbol.toPrimitive](`string`),t,n);throw TypeError(`The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type `+typeof e)}s.from=function(e,t,n){return c(e,t,n)},Object.setPrototypeOf(s.prototype,Uint8Array.prototype),Object.setPrototypeOf(s,Uint8Array);function l(e){if(typeof e!=`number`)throw TypeError(`"size" argument must be of type number`);if(e<0)throw RangeError(`The value "`+e+`" is invalid for option "size"`)}function u(e,t,n){return l(e),e<=0||t===void 0?o(e):typeof n==`string`?o(e).fill(t,n):o(e).fill(t)}s.alloc=function(e,t,n){return u(e,t,n)};function d(e){return l(e),o(e<0?0:_(e)|0)}s.allocUnsafe=function(e){return d(e)},s.allocUnsafeSlow=function(e){return d(e)};function f(e,t){if((typeof t!=`string`||t===``)&&(t=`utf8`),!s.isEncoding(t))throw TypeError(`Unknown encoding: `+t);let n=y(e,t)|0,r=o(n),i=r.write(e,t);return i!==n&&(r=r.slice(0,i)),r}function p(e){let t=e.length<0?0:_(e.length)|0,n=o(t);for(let r=0;r<t;r+=1)n[r]=e[r]&255;return n}function m(e){if(Se(e,Uint8Array)){let t=new Uint8Array(e);return h(t.buffer,t.byteOffset,t.byteLength)}return p(e)}function h(e,t,n){if(t<0||e.byteLength<t)throw RangeError(`"offset" is outside of buffer bounds`);if(e.byteLength<t+(n||0))throw RangeError(`"length" is outside of buffer bounds`);let r;return r=t===void 0&&n===void 0?new Uint8Array(e):n===void 0?new Uint8Array(e,t):new Uint8Array(e,t,n),Object.setPrototypeOf(r,s.prototype),r}function g(e){if(s.isBuffer(e)){let t=_(e.length)|0,n=o(t);return n.length===0||e.copy(n,0,0,t),n}if(e.length!==void 0)return typeof e.length!=`number`||Ce(e.length)?o(0):p(e);if(e.type===`Buffer`&&Array.isArray(e.data))return p(e.data)}function _(e){if(e>=i)throw RangeError(`Attempt to allocate Buffer larger than maximum size: 0x`+i.toString(16)+` bytes`);return e|0}function v(e){return+e!=e&&(e=0),s.alloc(+e)}s.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==s.prototype},s.compare=function(e,t){if(Se(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),Se(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(e)||!s.isBuffer(t))throw TypeError(`The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array`);if(e===t)return 0;let n=e.length,r=t.length;for(let i=0,a=Math.min(n,r);i<a;++i)if(e[i]!==t[i]){n=e[i],r=t[i];break}return n<r?-1:+(r<n)},s.isEncoding=function(e){switch(String(e).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}},s.concat=function(e,t){if(!Array.isArray(e))throw TypeError(`"list" argument must be an Array of Buffers`);if(e.length===0)return s.alloc(0);let n;if(t===void 0)for(t=0,n=0;n<e.length;++n)t+=e[n].length;let r=s.allocUnsafe(t),i=0;for(n=0;n<e.length;++n){let t=e[n];if(Se(t,Uint8Array))i+t.length>r.length?(s.isBuffer(t)||(t=s.from(t)),t.copy(r,i)):Uint8Array.prototype.set.call(r,t,i);else if(s.isBuffer(t))t.copy(r,i);else throw TypeError(`"list" argument must be an Array of Buffers`);i+=t.length}return r};function y(e,t){if(s.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||Se(e,ArrayBuffer))return e.byteLength;if(typeof e!=`string`)throw TypeError(`The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type `+typeof e);let n=e.length,r=arguments.length>2&&arguments[2]===!0;if(!r&&n===0)return 0;let i=!1;for(;;)switch(t){case`ascii`:case`latin1`:case`binary`:return n;case`utf8`:case`utf-8`:return _e(e).length;case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return n*2;case`hex`:return n>>>1;case`base64`:return be(e).length;default:if(i)return r?-1:_e(e).length;t=(``+t).toLowerCase(),i=!0}}s.byteLength=y;function b(e,t,n){let r=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((n===void 0||n>this.length)&&(n=this.length),n<=0)||(n>>>=0,t>>>=0,n<=t))return``;for(e||=`utf8`;;)switch(e){case`hex`:return ie(this,t,n);case`utf8`:case`utf-8`:return k(this,t,n);case`ascii`:return A(this,t,n);case`latin1`:case`binary`:return re(this,t,n);case`base64`:return O(this,t,n);case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return j(this,t,n);default:if(r)throw TypeError(`Unknown encoding: `+e);e=(e+``).toLowerCase(),r=!0}}s.prototype._isBuffer=!0;function x(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}s.prototype.swap16=function(){let e=this.length;if(e%2!=0)throw RangeError(`Buffer size must be a multiple of 16-bits`);for(let t=0;t<e;t+=2)x(this,t,t+1);return this},s.prototype.swap32=function(){let e=this.length;if(e%4!=0)throw RangeError(`Buffer size must be a multiple of 32-bits`);for(let t=0;t<e;t+=4)x(this,t,t+3),x(this,t+1,t+2);return this},s.prototype.swap64=function(){let e=this.length;if(e%8!=0)throw RangeError(`Buffer size must be a multiple of 64-bits`);for(let t=0;t<e;t+=8)x(this,t,t+7),x(this,t+1,t+6),x(this,t+2,t+5),x(this,t+3,t+4);return this},s.prototype.toString=function(){let e=this.length;return e===0?``:arguments.length===0?k(this,0,e):b.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(e){if(!s.isBuffer(e))throw TypeError(`Argument must be a Buffer`);return this===e?!0:s.compare(this,e)===0},s.prototype.inspect=function(){let t=``,n=e.INSPECT_MAX_BYTES;return t=this.toString(`hex`,0,n).replace(/(.{2})/g,`$1 `).trim(),this.length>n&&(t+=` ... `),`<Buffer `+t+`>`},r&&(s.prototype[r]=s.prototype.inspect),s.prototype.compare=function(e,t,n,r,i){if(Se(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),!s.isBuffer(e))throw TypeError(`The "target" argument must be one of type Buffer or Uint8Array. Received type `+typeof e);if(t===void 0&&(t=0),n===void 0&&(n=e?e.length:0),r===void 0&&(r=0),i===void 0&&(i=this.length),t<0||n>e.length||r<0||i>this.length)throw RangeError(`out of range index`);if(r>=i&&t>=n)return 0;if(r>=i)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,r>>>=0,i>>>=0,this===e)return 0;let a=i-r,o=n-t,c=Math.min(a,o),l=this.slice(r,i),u=e.slice(t,n);for(let e=0;e<c;++e)if(l[e]!==u[e]){a=l[e],o=u[e];break}return a<o?-1:+(o<a)};function ee(e,t,n,r,i){if(e.length===0)return-1;if(typeof n==`string`?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,Ce(n)&&(n=i?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(i)return-1;n=e.length-1}else if(n<0)if(i)n=0;else return-1;if(typeof t==`string`&&(t=s.from(t,r)),s.isBuffer(t))return t.length===0?-1:S(e,t,n,r,i);if(typeof t==`number`)return t&=255,typeof Uint8Array.prototype.indexOf==`function`?i?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):S(e,[t],n,r,i);throw TypeError(`val must be string, number or Buffer`)}function S(e,t,n,r,i){let a=1,o=e.length,s=t.length;if(r!==void 0&&(r=String(r).toLowerCase(),r===`ucs2`||r===`ucs-2`||r===`utf16le`||r===`utf-16le`)){if(e.length<2||t.length<2)return-1;a=2,o/=2,s/=2,n/=2}function c(e,t){return a===1?e[t]:e.readUInt16BE(t*a)}let l;if(i){let r=-1;for(l=n;l<o;l++)if(c(e,l)===c(t,r===-1?0:l-r)){if(r===-1&&(r=l),l-r+1===s)return r*a}else r!==-1&&(l-=l-r),r=-1}else for(n+s>o&&(n=o-s),l=n;l>=0;l--){let n=!0;for(let r=0;r<s;r++)if(c(e,l+r)!==c(t,r)){n=!1;break}if(n)return l}return-1}s.prototype.includes=function(e,t,n){return this.indexOf(e,t,n)!==-1},s.prototype.indexOf=function(e,t,n){return ee(this,e,t,n,!0)},s.prototype.lastIndexOf=function(e,t,n){return ee(this,e,t,n,!1)};function C(e,t,n,r){n=Number(n)||0;let i=e.length-n;r?(r=Number(r),r>i&&(r=i)):r=i;let a=t.length;r>a/2&&(r=a/2);let o;for(o=0;o<r;++o){let r=parseInt(t.substr(o*2,2),16);if(Ce(r))return o;e[n+o]=r}return o}function w(e,t,n,r){return xe(_e(t,e.length-n),e,n,r)}function T(e,t,n,r){return xe(ve(t),e,n,r)}function E(e,t,n,r){return xe(be(t),e,n,r)}function D(e,t,n,r){return xe(ye(t,e.length-n),e,n,r)}s.prototype.write=function(e,t,n,r){if(t===void 0)r=`utf8`,n=this.length,t=0;else if(n===void 0&&typeof t==`string`)r=t,n=this.length,t=0;else if(isFinite(t))t>>>=0,isFinite(n)?(n>>>=0,r===void 0&&(r=`utf8`)):(r=n,n=void 0);else throw Error(`Buffer.write(string, encoding, offset[, length]) is no longer supported`);let i=this.length-t;if((n===void 0||n>i)&&(n=i),e.length>0&&(n<0||t<0)||t>this.length)throw RangeError(`Attempt to write outside buffer bounds`);r||=`utf8`;let a=!1;for(;;)switch(r){case`hex`:return C(this,e,t,n);case`utf8`:case`utf-8`:return w(this,e,t,n);case`ascii`:case`latin1`:case`binary`:return T(this,e,t,n);case`base64`:return E(this,e,t,n);case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return D(this,e,t,n);default:if(a)throw TypeError(`Unknown encoding: `+r);r=(``+r).toLowerCase(),a=!0}},s.prototype.toJSON=function(){return{type:`Buffer`,data:Array.prototype.slice.call(this._arr||this,0)}};function O(e,n,r){return n===0&&r===e.length?t.fromByteArray(e):t.fromByteArray(e.slice(n,r))}function k(e,t,n){n=Math.min(e.length,n);let r=[],i=t;for(;i<n;){let t=e[i],a=null,o=t>239?4:t>223?3:t>191?2:1;if(i+o<=n){let n,r,s,c;switch(o){case 1:t<128&&(a=t);break;case 2:n=e[i+1],(n&192)==128&&(c=(t&31)<<6|n&63,c>127&&(a=c));break;case 3:n=e[i+1],r=e[i+2],(n&192)==128&&(r&192)==128&&(c=(t&15)<<12|(n&63)<<6|r&63,c>2047&&(c<55296||c>57343)&&(a=c));break;case 4:n=e[i+1],r=e[i+2],s=e[i+3],(n&192)==128&&(r&192)==128&&(s&192)==128&&(c=(t&15)<<18|(n&63)<<12|(r&63)<<6|s&63,c>65535&&c<1114112&&(a=c))}}a===null?(a=65533,o=1):a>65535&&(a-=65536,r.push(a>>>10&1023|55296),a=56320|a&1023),r.push(a),i+=o}return ne(r)}var te=4096;function ne(e){let t=e.length;if(t<=te)return String.fromCharCode.apply(String,e);let n=``,r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=te));return n}function A(e,t,n){let r=``;n=Math.min(e.length,n);for(let i=t;i<n;++i)r+=String.fromCharCode(e[i]&127);return r}function re(e,t,n){let r=``;n=Math.min(e.length,n);for(let i=t;i<n;++i)r+=String.fromCharCode(e[i]);return r}function ie(e,t,n){let r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);let i=``;for(let r=t;r<n;++r)i+=we[e[r]];return i}function j(e,t,n){let r=e.slice(t,n),i=``;for(let e=0;e<r.length-1;e+=2)i+=String.fromCharCode(r[e]+r[e+1]*256);return i}s.prototype.slice=function(e,t){let n=this.length;e=~~e,t=t===void 0?n:~~t,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),t<e&&(t=e);let r=this.subarray(e,t);return Object.setPrototypeOf(r,s.prototype),r};function ae(e,t,n){if(e%1!=0||e<0)throw RangeError(`offset is not uint`);if(e+t>n)throw RangeError(`Trying to access beyond buffer length`)}s.prototype.readUintLE=s.prototype.readUIntLE=function(e,t,n){e>>>=0,t>>>=0,n||ae(e,t,this.length);let r=this[e],i=1,a=0;for(;++a<t&&(i*=256);)r+=this[e+a]*i;return r},s.prototype.readUintBE=s.prototype.readUIntBE=function(e,t,n){e>>>=0,t>>>=0,n||ae(e,t,this.length);let r=this[e+--t],i=1;for(;t>0&&(i*=256);)r+=this[e+--t]*i;return r},s.prototype.readUint8=s.prototype.readUInt8=function(e,t){return e>>>=0,t||ae(e,1,this.length),this[e]},s.prototype.readUint16LE=s.prototype.readUInt16LE=function(e,t){return e>>>=0,t||ae(e,2,this.length),this[e]|this[e+1]<<8},s.prototype.readUint16BE=s.prototype.readUInt16BE=function(e,t){return e>>>=0,t||ae(e,2,this.length),this[e]<<8|this[e+1]},s.prototype.readUint32LE=s.prototype.readUInt32LE=function(e,t){return e>>>=0,t||ae(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216},s.prototype.readUint32BE=s.prototype.readUInt32BE=function(e,t){return e>>>=0,t||ae(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])},s.prototype.readBigUInt64LE=Te(function(e){e>>>=0,he(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&P(e,this.length-8);let r=t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,i=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(r)+(BigInt(i)<<BigInt(32))}),s.prototype.readBigUInt64BE=Te(function(e){e>>>=0,he(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&P(e,this.length-8);let r=t*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],i=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(r)<<BigInt(32))+BigInt(i)}),s.prototype.readIntLE=function(e,t,n){e>>>=0,t>>>=0,n||ae(e,t,this.length);let r=this[e],i=1,a=0;for(;++a<t&&(i*=256);)r+=this[e+a]*i;return i*=128,r>=i&&(r-=2**(8*t)),r},s.prototype.readIntBE=function(e,t,n){e>>>=0,t>>>=0,n||ae(e,t,this.length);let r=t,i=1,a=this[e+--r];for(;r>0&&(i*=256);)a+=this[e+--r]*i;return i*=128,a>=i&&(a-=2**(8*t)),a},s.prototype.readInt8=function(e,t){return e>>>=0,t||ae(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]},s.prototype.readInt16LE=function(e,t){e>>>=0,t||ae(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n},s.prototype.readInt16BE=function(e,t){e>>>=0,t||ae(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n},s.prototype.readInt32LE=function(e,t){return e>>>=0,t||ae(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},s.prototype.readInt32BE=function(e,t){return e>>>=0,t||ae(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},s.prototype.readBigInt64LE=Te(function(e){e>>>=0,he(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&P(e,this.length-8);let r=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(r)<<BigInt(32))+BigInt(t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)}),s.prototype.readBigInt64BE=Te(function(e){e>>>=0,he(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&P(e,this.length-8);let r=(t<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(r)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)}),s.prototype.readFloatLE=function(e,t){return e>>>=0,t||ae(e,4,this.length),n.read(this,e,!0,23,4)},s.prototype.readFloatBE=function(e,t){return e>>>=0,t||ae(e,4,this.length),n.read(this,e,!1,23,4)},s.prototype.readDoubleLE=function(e,t){return e>>>=0,t||ae(e,8,this.length),n.read(this,e,!0,52,8)},s.prototype.readDoubleBE=function(e,t){return e>>>=0,t||ae(e,8,this.length),n.read(this,e,!1,52,8)};function M(e,t,n,r,i,a){if(!s.isBuffer(e))throw TypeError(`"buffer" argument must be a Buffer instance`);if(t>i||t<a)throw RangeError(`"value" argument is out of bounds`);if(n+r>e.length)throw RangeError(`Index out of range`)}s.prototype.writeUintLE=s.prototype.writeUIntLE=function(e,t,n,r){if(e=+e,t>>>=0,n>>>=0,!r){let r=2**(8*n)-1;M(this,e,t,n,r,0)}let i=1,a=0;for(this[t]=e&255;++a<n&&(i*=256);)this[t+a]=e/i&255;return t+n},s.prototype.writeUintBE=s.prototype.writeUIntBE=function(e,t,n,r){if(e=+e,t>>>=0,n>>>=0,!r){let r=2**(8*n)-1;M(this,e,t,n,r,0)}let i=n-1,a=1;for(this[t+i]=e&255;--i>=0&&(a*=256);)this[t+i]=e/a&255;return t+n},s.prototype.writeUint8=s.prototype.writeUInt8=function(e,t,n){return e=+e,t>>>=0,n||M(this,e,t,1,255,0),this[t]=e&255,t+1},s.prototype.writeUint16LE=s.prototype.writeUInt16LE=function(e,t,n){return e=+e,t>>>=0,n||M(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2},s.prototype.writeUint16BE=s.prototype.writeUInt16BE=function(e,t,n){return e=+e,t>>>=0,n||M(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2},s.prototype.writeUint32LE=s.prototype.writeUInt32LE=function(e,t,n){return e=+e,t>>>=0,n||M(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4},s.prototype.writeUint32BE=s.prototype.writeUInt32BE=function(e,t,n){return e=+e,t>>>=0,n||M(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};function oe(e,t,n,r,i){me(t,r,i,e,n,7);let a=Number(t&BigInt(4294967295));e[n++]=a,a>>=8,e[n++]=a,a>>=8,e[n++]=a,a>>=8,e[n++]=a;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[n++]=o,o>>=8,e[n++]=o,o>>=8,e[n++]=o,o>>=8,e[n++]=o,n}function se(e,t,n,r,i){me(t,r,i,e,n,7);let a=Number(t&BigInt(4294967295));e[n+7]=a,a>>=8,e[n+6]=a,a>>=8,e[n+5]=a,a>>=8,e[n+4]=a;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[n+3]=o,o>>=8,e[n+2]=o,o>>=8,e[n+1]=o,o>>=8,e[n]=o,n+8}s.prototype.writeBigUInt64LE=Te(function(e,t=0){return oe(this,e,t,BigInt(0),BigInt(`0xffffffffffffffff`))}),s.prototype.writeBigUInt64BE=Te(function(e,t=0){return se(this,e,t,BigInt(0),BigInt(`0xffffffffffffffff`))}),s.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t>>>=0,!r){let r=2**(8*n-1);M(this,e,t,n,r-1,-r)}let i=0,a=1,o=0;for(this[t]=e&255;++i<n&&(a*=256);)e<0&&o===0&&this[t+i-1]!==0&&(o=1),this[t+i]=(e/a>>0)-o&255;return t+n},s.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t>>>=0,!r){let r=2**(8*n-1);M(this,e,t,n,r-1,-r)}let i=n-1,a=1,o=0;for(this[t+i]=e&255;--i>=0&&(a*=256);)e<0&&o===0&&this[t+i+1]!==0&&(o=1),this[t+i]=(e/a>>0)-o&255;return t+n},s.prototype.writeInt8=function(e,t,n){return e=+e,t>>>=0,n||M(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1},s.prototype.writeInt16LE=function(e,t,n){return e=+e,t>>>=0,n||M(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2},s.prototype.writeInt16BE=function(e,t,n){return e=+e,t>>>=0,n||M(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2},s.prototype.writeInt32LE=function(e,t,n){return e=+e,t>>>=0,n||M(this,e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},s.prototype.writeInt32BE=function(e,t,n){return e=+e,t>>>=0,n||M(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4},s.prototype.writeBigInt64LE=Te(function(e,t=0){return oe(this,e,t,-BigInt(`0x8000000000000000`),BigInt(`0x7fffffffffffffff`))}),s.prototype.writeBigInt64BE=Te(function(e,t=0){return se(this,e,t,-BigInt(`0x8000000000000000`),BigInt(`0x7fffffffffffffff`))});function ce(e,t,n,r,i,a){if(n+r>e.length||n<0)throw RangeError(`Index out of range`)}function le(e,t,r,i,a){return t=+t,r>>>=0,a||ce(e,t,r,4,34028234663852886e22,-34028234663852886e22),n.write(e,t,r,i,23,4),r+4}s.prototype.writeFloatLE=function(e,t,n){return le(this,e,t,!0,n)},s.prototype.writeFloatBE=function(e,t,n){return le(this,e,t,!1,n)};function ue(e,t,r,i,a){return t=+t,r>>>=0,a||ce(e,t,r,8,17976931348623157e292,-17976931348623157e292),n.write(e,t,r,i,52,8),r+8}s.prototype.writeDoubleLE=function(e,t,n){return ue(this,e,t,!0,n)},s.prototype.writeDoubleBE=function(e,t,n){return ue(this,e,t,!1,n)},s.prototype.copy=function(e,t,n,r){if(!s.isBuffer(e))throw TypeError(`argument should be a Buffer`);if(n||=0,!r&&r!==0&&(r=this.length),t>=e.length&&(t=e.length),t||=0,r>0&&r<n&&(r=n),r===n||e.length===0||this.length===0)return 0;if(t<0)throw RangeError(`targetStart out of bounds`);if(n<0||n>=this.length)throw RangeError(`Index out of range`);if(r<0)throw RangeError(`sourceEnd out of bounds`);r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);let i=r-n;return this===e&&typeof Uint8Array.prototype.copyWithin==`function`?this.copyWithin(t,n,r):Uint8Array.prototype.set.call(e,this.subarray(n,r),t),i},s.prototype.fill=function(e,t,n,r){if(typeof e==`string`){if(typeof t==`string`?(r=t,t=0,n=this.length):typeof n==`string`&&(r=n,n=this.length),r!==void 0&&typeof r!=`string`)throw TypeError(`encoding must be a string`);if(typeof r==`string`&&!s.isEncoding(r))throw TypeError(`Unknown encoding: `+r);if(e.length===1){let t=e.charCodeAt(0);(r===`utf8`&&t<128||r===`latin1`)&&(e=t)}}else typeof e==`number`?e&=255:typeof e==`boolean`&&(e=Number(e));if(t<0||this.length<t||this.length<n)throw RangeError(`Out of range index`);if(n<=t)return this;t>>>=0,n=n===void 0?this.length:n>>>0,e||=0;let i;if(typeof e==`number`)for(i=t;i<n;++i)this[i]=e;else{let a=s.isBuffer(e)?e:s.from(e,r),o=a.length;if(o===0)throw TypeError(`The value "`+e+`" is invalid for argument "value"`);for(i=0;i<n-t;++i)this[i+t]=a[i%o]}return this};var de={};function N(e,t,n){de[e]=class extends n{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(e){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:e,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}N(`ERR_BUFFER_OUT_OF_BOUNDS`,function(e){return e?`${e} is outside of buffer bounds`:`Attempt to access memory outside buffer bounds`},RangeError),N(`ERR_INVALID_ARG_TYPE`,function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError),N(`ERR_OUT_OF_RANGE`,function(e,t,n){let r=`The value of "${e}" is out of range.`,i=n;return Number.isInteger(n)&&Math.abs(n)>2**32?i=fe(String(n)):typeof n==`bigint`&&(i=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(i=fe(i)),i+=`n`),r+=` It must be ${t}. Received ${i}`,r},RangeError);function fe(e){let t=``,n=e.length,r=+(e[0]===`-`);for(;n>=r+4;n-=3)t=`_${e.slice(n-3,n)}${t}`;return`${e.slice(0,n)}${t}`}function pe(e,t,n){he(t,`offset`),(e[t]===void 0||e[t+n]===void 0)&&P(t,e.length-(n+1))}function me(e,t,n,r,i,a){if(e>n||e<t){let r=typeof t==`bigint`?`n`:``,i;throw i=a>3?t===0||t===BigInt(0)?`>= 0${r} and < 2${r} ** ${(a+1)*8}${r}`:`>= -(2${r} ** ${(a+1)*8-1}${r}) and < 2 ** ${(a+1)*8-1}${r}`:`>= ${t}${r} and <= ${n}${r}`,new de.ERR_OUT_OF_RANGE(`value`,i,e)}pe(r,i,a)}function he(e,t){if(typeof e!=`number`)throw new de.ERR_INVALID_ARG_TYPE(t,`number`,e)}function P(e,t,n){throw Math.floor(e)===e?t<0?new de.ERR_BUFFER_OUT_OF_BOUNDS:new de.ERR_OUT_OF_RANGE(n||`offset`,`>= ${+!!n} and <= ${t}`,e):(he(e,n),new de.ERR_OUT_OF_RANGE(n||`offset`,`an integer`,e))}var F=/[^+/0-9A-Za-z-_]/g;function ge(e){if(e=e.split(`=`)[0],e=e.trim().replace(F,``),e.length<2)return``;for(;e.length%4!=0;)e+=`=`;return e}function _e(e,t){t||=1/0;let n,r=e.length,i=null,a=[];for(let o=0;o<r;++o){if(n=e.charCodeAt(o),n>55295&&n<57344){if(!i){if(n>56319){(t-=3)>-1&&a.push(239,191,189);continue}else if(o+1===r){(t-=3)>-1&&a.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&a.push(239,191,189),i=n;continue}n=(i-55296<<10|n-56320)+65536}else i&&(t-=3)>-1&&a.push(239,191,189);if(i=null,n<128){if(--t<0)break;a.push(n)}else if(n<2048){if((t-=2)<0)break;a.push(n>>6|192,n&63|128)}else if(n<65536){if((t-=3)<0)break;a.push(n>>12|224,n>>6&63|128,n&63|128)}else if(n<1114112){if((t-=4)<0)break;a.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128)}else throw Error(`Invalid code point`)}return a}function ve(e){let t=[];for(let n=0;n<e.length;++n)t.push(e.charCodeAt(n)&255);return t}function ye(e,t){let n,r,i,a=[];for(let o=0;o<e.length&&!((t-=2)<0);++o)n=e.charCodeAt(o),r=n>>8,i=n%256,a.push(i),a.push(r);return a}function be(e){return t.toByteArray(ge(e))}function xe(e,t,n,r){let i;for(i=0;i<r&&!(i+n>=t.length||i>=e.length);++i)t[i+n]=e[i];return i}function Se(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function Ce(e){return e!==e}var we=(function(){let e=`0123456789abcdef`,t=Array(256);for(let n=0;n<16;++n){let r=n*16;for(let i=0;i<16;++i)t[r+i]=e[n]+e[i]}return t})();function Te(e){return typeof BigInt>`u`?Ee:e}function Ee(){throw Error(`BigInt not supported`)}})),I=it(),at=BigInt(0),ot=BigInt(1);function st(e,t=``){if(typeof e!=`boolean`){let n=t&&`"${t}"`;throw Error(n+`expected boolean, got type=`+typeof e)}return e}function ct(e,t,n=``){let r=O(e),i=e?.length,a=t!==void 0;if(!r||a&&i!==t){let o=n&&`"${n}" `,s=a?` of length ${t}`:``,c=r?`length=${i}`:`type=${typeof e}`;throw Error(o+`expected Uint8Array`+s+`, got `+c)}return e}function lt(e){let t=e.toString(16);return t.length&1?`0`+t:t}function ut(e){if(typeof e!=`string`)throw Error(`hex string expected, got `+typeof e);return e===``?at:BigInt(`0x`+e)}function dt(e){return ut(N(e))}function ft(e){return te(e),ut(N(Uint8Array.from(e).reverse()))}function pt(e,t){return me(e.toString(16).padStart(t*2,`0`))}function mt(e,t){return pt(e,t).reverse()}function ht(e,t,n){let r;if(typeof t==`string`)try{r=me(t)}catch(t){throw Error(e+` must be hex string or Uint8Array, cause: `+t)}else if(O(t))r=Uint8Array.from(t);else throw Error(e+` must be hex string or Uint8Array`);let i=r.length;if(typeof n==`number`&&i!==n)throw Error(e+` of length `+n+` expected, got `+i);return r}function gt(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return n===0}function _t(e){return Uint8Array.from(e)}var vt=e=>typeof e==`bigint`&&at<=e;function yt(e,t,n){return vt(e)&&vt(t)&&vt(n)&&t<=e&&e<n}function bt(e,t,n,r){if(!yt(t,n,r))throw Error(`expected valid `+e+`: `+n+` <= n < `+r+`, got `+t)}function xt(e){let t;for(t=0;e>at;e>>=ot,t+=1);return t}var St=e=>(ot<<BigInt(e))-ot;function Ct(e,t,n){if(typeof e!=`number`||e<2)throw Error(`hashLen must be a number`);if(typeof t!=`number`||t<2)throw Error(`qByteLen must be a number`);if(typeof n!=`function`)throw Error(`hmacFn must be a function`);let r=e=>new Uint8Array(e),i=e=>Uint8Array.of(e),a=r(e),o=r(e),s=0,c=()=>{a.fill(1),o.fill(0),s=0},l=(...e)=>n(o,a,...e),u=(e=r(0))=>{o=l(i(0),e),a=l(),e.length!==0&&(o=l(i(1),e),a=l())},d=()=>{if(s++>=1e3)throw Error(`drbg: tried 1000 values`);let e=0,n=[];for(;e<t;){a=l();let t=a.slice();n.push(t),e+=a.length}return F(...n)};return(e,t)=>{c(),u(e);let n;for(;!(n=t(d()));)u();return c(),n}}function wt(e,t,n={}){if(!e||typeof e!=`object`)throw Error(`expected valid options object`);function r(t,n,r){let i=e[t];if(r&&i===void 0)return;let a=typeof i;if(a!==n||i===null)throw Error(`param "${t}" is invalid: expected ${n}, got ${a}`)}Object.entries(t).forEach(([e,t])=>r(e,t,!1)),Object.entries(n).forEach(([e,t])=>r(e,t,!0))}var Tt=()=>{throw Error(`not implemented`)};function Et(e){let t=new WeakMap;return(n,...r)=>{let i=t.get(n);if(i!==void 0)return i;let a=e(n,...r);return t.set(n,a),a}}var Dt=BigInt(0),Ot=BigInt(1),kt=BigInt(2),At=BigInt(3),jt=BigInt(4),Mt=BigInt(5),Nt=BigInt(7),Pt=BigInt(8),Ft=BigInt(9),It=BigInt(16);function Lt(e,t){let n=e%t;return n>=Dt?n:t+n}function Rt(e,t,n){let r=e;for(;t-- >Dt;)r*=r,r%=n;return r}function zt(e,t){if(e===Dt)throw Error(`invert: expected non-zero number`);if(t<=Dt)throw Error(`invert: expected positive modulus, got `+t);let n=Lt(e,t),r=t,i=Dt,a=Ot,o=Ot,s=Dt;for(;n!==Dt;){let e=r/n,t=r%n,c=i-o*e,l=a-s*e;r=n,n=t,i=o,a=s,o=c,s=l}if(r!==Ot)throw Error(`invert: does not exist`);return Lt(i,t)}function Bt(e,t,n){if(!e.eql(e.sqr(t),n))throw Error(`Cannot find square root`)}function Vt(e,t){let n=(e.ORDER+Ot)/jt,r=e.pow(t,n);return Bt(e,r,t),r}function Ht(e,t){let n=(e.ORDER-Mt)/Pt,r=e.mul(t,kt),i=e.pow(r,n),a=e.mul(t,i),o=e.mul(e.mul(a,kt),i),s=e.mul(a,e.sub(o,e.ONE));return Bt(e,s,t),s}function Ut(e){let t=$t(e),n=Wt(e),r=n(t,t.neg(t.ONE)),i=n(t,r),a=n(t,t.neg(r)),o=(e+Nt)/It;return(e,t)=>{let n=e.pow(t,o),s=e.mul(n,r),c=e.mul(n,i),l=e.mul(n,a),u=e.eql(e.sqr(s),t),d=e.eql(e.sqr(c),t);n=e.cmov(n,s,u),s=e.cmov(l,c,d);let f=e.eql(e.sqr(s),t),p=e.cmov(n,s,f);return Bt(e,p,t),p}}function Wt(e){if(e<At)throw Error(`sqrt is not defined for small field`);let t=e-Ot,n=0;for(;t%kt===Dt;)t/=kt,n++;let r=kt,i=$t(e);for(;Zt(i,r)===1;)if(r++>1e3)throw Error(`Cannot find square root: probably non-prime P`);if(n===1)return Vt;let a=i.pow(r,t),o=(t+Ot)/kt;return function(e,r){if(e.is0(r))return r;if(Zt(e,r)!==1)throw Error(`Cannot find square root`);let i=n,s=e.mul(e.ONE,a),c=e.pow(r,t),l=e.pow(r,o);for(;!e.eql(c,e.ONE);){if(e.is0(c))return e.ZERO;let t=1,n=e.sqr(c);for(;!e.eql(n,e.ONE);)if(t++,n=e.sqr(n),t===i)throw Error(`Cannot find square root`);let r=Ot<<BigInt(i-t-1),a=e.pow(s,r);i=t,s=e.sqr(a),c=e.mul(c,s),l=e.mul(l,a)}return l}}function Gt(e){return e%jt===At?Vt:e%Pt===Mt?Ht:e%It===Ft?Ut(e):Wt(e)}var Kt=(e,t)=>(Lt(e,t)&Ot)===Ot,qt=[`create`,`isValid`,`is0`,`neg`,`inv`,`sqrt`,`sqr`,`eql`,`add`,`sub`,`mul`,`pow`,`div`,`addN`,`subN`,`mulN`,`sqrN`];function Jt(e){return wt(e,qt.reduce((e,t)=>(e[t]=`function`,e),{ORDER:`bigint`,MASK:`bigint`,BYTES:`number`,BITS:`number`})),e}function Yt(e,t,n){if(n<Dt)throw Error(`invalid exponent, negatives unsupported`);if(n===Dt)return e.ONE;if(n===Ot)return t;let r=e.ONE,i=t;for(;n>Dt;)n&Ot&&(r=e.mul(r,i)),i=e.sqr(i),n>>=Ot;return r}function Xt(e,t,n=!1){let r=Array(t.length).fill(n?e.ZERO:void 0),i=t.reduce((t,n,i)=>e.is0(n)?t:(r[i]=t,e.mul(t,n)),e.ONE),a=e.inv(i);return t.reduceRight((t,n,i)=>e.is0(n)?t:(r[i]=e.mul(t,r[i]),e.mul(t,n)),a),r}function Zt(e,t){let n=(e.ORDER-Ot)/kt,r=e.pow(t,n),i=e.eql(r,e.ONE),a=e.eql(r,e.ZERO),o=e.eql(r,e.neg(e.ONE));if(!i&&!a&&!o)throw Error(`invalid Legendre symbol result`);return i?1:a?0:-1}function Qt(e,t){t!==void 0&&k(t);let n=t===void 0?e.toString(2).length:t;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function $t(e,t,n=!1,r={}){if(e<=Dt)throw Error(`invalid field: expected ORDER > 0, got `+e);let i,a,o=!1,s;if(typeof t==`object`&&t){if(r.sqrt||n)throw Error(`cannot specify opts in two arguments`);let e=t;e.BITS&&(i=e.BITS),e.sqrt&&(a=e.sqrt),typeof e.isLE==`boolean`&&(n=e.isLE),typeof e.modFromBytes==`boolean`&&(o=e.modFromBytes),s=e.allowedLengths}else typeof t==`number`&&(i=t),r.sqrt&&(a=r.sqrt);let{nBitLength:c,nByteLength:l}=Qt(e,i);if(l>2048)throw Error(`invalid field: expected ORDER of <= 2048 bytes`);let u,d=Object.freeze({ORDER:e,isLE:n,BITS:c,BYTES:l,MASK:St(c),ZERO:Dt,ONE:Ot,allowedLengths:s,create:t=>Lt(t,e),isValid:t=>{if(typeof t!=`bigint`)throw Error(`invalid field element: expected bigint, got `+typeof t);return Dt<=t&&t<e},is0:e=>e===Dt,isValidNot0:e=>!d.is0(e)&&d.isValid(e),isOdd:e=>(e&Ot)===Ot,neg:t=>Lt(-t,e),eql:(e,t)=>e===t,sqr:t=>Lt(t*t,e),add:(t,n)=>Lt(t+n,e),sub:(t,n)=>Lt(t-n,e),mul:(t,n)=>Lt(t*n,e),pow:(e,t)=>Yt(d,e,t),div:(t,n)=>Lt(t*zt(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>zt(t,e),sqrt:a||(t=>(u||=Gt(e),u(d,t))),toBytes:e=>n?mt(e,l):pt(e,l),fromBytes:(t,r=!0)=>{if(s){if(!s.includes(t.length)||t.length>l)throw Error(`Field.fromBytes: expected `+s+` bytes, got `+t.length);let e=new Uint8Array(l);e.set(t,n?0:e.length-t.length),t=e}if(t.length!==l)throw Error(`Field.fromBytes: expected `+l+` bytes, got `+t.length);let i=n?ft(t):dt(t);if(o&&(i=Lt(i,e)),!r&&!d.isValid(i))throw Error(`invalid field element: outside of range 0..ORDER`);return i},invertBatch:e=>Xt(d,e),cmov:(e,t,n)=>n?t:e});return Object.freeze(d)}function en(e){if(typeof e!=`bigint`)throw Error(`field order must be bigint`);let t=e.toString(2).length;return Math.ceil(t/8)}function tn(e){let t=en(e);return t+Math.ceil(t/2)}function nn(e,t,n=!1){let r=e.length,i=en(t),a=tn(t);if(r<16||r<a||r>1024)throw Error(`expected `+a+`-1024 bytes of input, got `+r);let o=Lt(n?ft(e):dt(e),t-Ot)+Ot;return n?mt(o,i):pt(o,i)}var rn=BigInt(0),an=BigInt(1);function on(e,t){let n=t.negate();return e?n:t}function sn(e,t){let n=Xt(e.Fp,t.map(e=>e.Z));return t.map((t,r)=>e.fromAffine(t.toAffine(n[r])))}function cn(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw Error(`invalid window size, expected [1..`+t+`], got W=`+e)}function ln(e,t){cn(e,t);let n=Math.ceil(t/e)+1,r=2**(e-1),i=2**e;return{windows:n,windowSize:r,mask:St(e),maxNumber:i,shiftBy:BigInt(e)}}function un(e,t,n){let{windowSize:r,mask:i,maxNumber:a,shiftBy:o}=n,s=Number(e&i),c=e>>o;s>r&&(s-=a,c+=an);let l=t*r,u=l+Math.abs(s)-1,d=s===0,f=s<0,p=t%2!=0;return{nextN:c,offset:u,isZero:d,isNeg:f,isNegF:p,offsetF:l}}function dn(e,t){if(!Array.isArray(e))throw Error(`array expected`);e.forEach((e,n)=>{if(!(e instanceof t))throw Error(`invalid point at index `+n)})}function fn(e,t){if(!Array.isArray(e))throw Error(`array of scalars expected`);e.forEach((e,n)=>{if(!t.isValid(e))throw Error(`invalid scalar at index `+n)})}var pn=new WeakMap,mn=new WeakMap;function hn(e){return mn.get(e)||1}function gn(e){if(e!==rn)throw Error(`invalid wNAF`)}var _n=class{constructor(e,t){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=t}_unsafeLadder(e,t,n=this.ZERO){let r=e;for(;t>rn;)t&an&&(n=n.add(r)),r=r.double(),t>>=an;return n}precomputeWindow(e,t){let{windows:n,windowSize:r}=ln(t,this.bits),i=[],a=e,o=a;for(let e=0;e<n;e++){o=a,i.push(o);for(let e=1;e<r;e++)o=o.add(a),i.push(o);a=o.double()}return i}wNAF(e,t,n){if(!this.Fn.isValid(n))throw Error(`invalid scalar`);let r=this.ZERO,i=this.BASE,a=ln(e,this.bits);for(let e=0;e<a.windows;e++){let{nextN:o,offset:s,isZero:c,isNeg:l,isNegF:u,offsetF:d}=un(n,e,a);n=o,c?i=i.add(on(u,t[d])):r=r.add(on(l,t[s]))}return gn(n),{p:r,f:i}}wNAFUnsafe(e,t,n,r=this.ZERO){let i=ln(e,this.bits);for(let e=0;e<i.windows&&n!==rn;e++){let{nextN:a,offset:o,isZero:s,isNeg:c}=un(n,e,i);if(n=a,!s){let e=t[o];r=r.add(c?e.negate():e)}}return gn(n),r}getPrecomputes(e,t,n){let r=pn.get(t);return r||(r=this.precomputeWindow(t,e),e!==1&&(typeof n==`function`&&(r=n(r)),pn.set(t,r))),r}cached(e,t,n){let r=hn(e);return this.wNAF(r,this.getPrecomputes(r,e,n),t)}unsafe(e,t,n,r){let i=hn(e);return i===1?this._unsafeLadder(e,t,r):this.wNAFUnsafe(i,this.getPrecomputes(i,e,n),t,r)}createCache(e,t){cn(t,this.bits),mn.set(e,t),pn.delete(e)}hasCache(e){return hn(e)!==1}};function vn(e,t,n,r){let i=t,a=e.ZERO,o=e.ZERO;for(;n>rn||r>rn;)n&an&&(a=a.add(i)),r&an&&(o=o.add(i)),i=i.double(),n>>=an,r>>=an;return{p1:a,p2:o}}function yn(e,t,n,r){dn(n,e),fn(r,t);let i=n.length,a=r.length;if(i!==a)throw Error(`arrays of points and scalars must have equal length`);let o=e.ZERO,s=xt(BigInt(i)),c=1;s>12?c=s-3:s>4?c=s-2:s>0&&(c=2);let l=St(c),u=Array(Number(l)+1).fill(o),d=Math.floor((t.BITS-1)/c)*c,f=o;for(let e=d;e>=0;e-=c){u.fill(o);for(let t=0;t<a;t++){let i=r[t],a=Number(i>>BigInt(e)&l);u[a]=u[a].add(n[t])}let t=o;for(let e=u.length-1,n=o;e>0;e--)n=n.add(u[e]),t=t.add(n);if(f=f.add(t),e!==0)for(let e=0;e<c;e++)f=f.double()}return f}function bn(e,t,n){if(t){if(t.ORDER!==e)throw Error(`Field.ORDER must match order: Fp == p, Fn == n`);return Jt(t),t}else return $t(e,{isLE:n})}function xn(e,t,n={},r){if(r===void 0&&(r=e===`edwards`),!t||typeof t!=`object`)throw Error(`expected valid ${e} CURVE object`);for(let e of[`p`,`n`,`h`]){let n=t[e];if(!(typeof n==`bigint`&&n>rn))throw Error(`CURVE.${e} must be positive bigint`)}let i=bn(t.p,n.Fp,r),a=bn(t.n,n.Fn,r),o=[`Gx`,`Gy`,`a`,e===`weierstrass`?`b`:`d`];for(let e of o)if(!i.isValid(t[e]))throw Error(`CURVE.${e} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:i,Fn:a}}var Sn=BigInt(0),Cn=BigInt(1),wn=BigInt(2),Tn=BigInt(8);function En(e,t,n,r){let i=e.sqr(n),a=e.sqr(r),o=e.add(e.mul(t.a,i),a),s=e.add(e.ONE,e.mul(t.d,e.mul(i,a)));return e.eql(o,s)}function Dn(e,t={}){let n=xn(`edwards`,e,t,t.FpFnLE),{Fp:r,Fn:i}=n,a=n.CURVE,{h:o}=a;wt(t,{},{uvRatio:`function`});let s=wn<<BigInt(i.BYTES*8)-Cn,c=e=>r.create(e),l=t.uvRatio||((e,t)=>{try{return{isValid:!0,value:r.sqrt(r.div(e,t))}}catch{return{isValid:!1,value:Sn}}});if(!En(r,a,a.Gx,a.Gy))throw Error(`bad curve params: generator point`);function u(e,t,n=!1){let r=n?Cn:Sn;return bt(`coordinate `+e,t,r,s),t}function d(e){if(!(e instanceof m))throw Error(`ExtendedPoint expected`)}let f=Et((e,t)=>{let{X:n,Y:i,Z:a}=e,o=e.is0();t??=o?Tn:r.inv(a);let s=c(n*t),l=c(i*t),u=r.mul(a,t);if(o)return{x:Sn,y:Cn};if(u!==Cn)throw Error(`invZ was invalid`);return{x:s,y:l}}),p=Et(e=>{let{a:t,d:n}=a;if(e.is0())throw Error(`bad point: ZERO`);let{X:r,Y:i,Z:o,T:s}=e,l=c(r*r),u=c(i*i),d=c(o*o),f=c(d*d);if(c(d*c(c(l*t)+u))!==c(f+c(n*c(l*u))))throw Error(`bad point: equation left != right (1)`);if(c(r*i)!==c(o*s))throw Error(`bad point: equation left != right (2)`);return!0});class m{constructor(e,t,n,r){this.X=u(`x`,e),this.Y=u(`y`,t),this.Z=u(`z`,n,!0),this.T=u(`t`,r),Object.freeze(this)}static CURVE(){return a}static fromAffine(e){if(e instanceof m)throw Error(`extended point not allowed`);let{x:t,y:n}=e||{};return u(`x`,t),u(`y`,n),new m(t,n,Cn,c(t*n))}static fromBytes(e,t=!1){let n=r.BYTES,{a:i,d:o}=a;e=_t(ct(e,n,`point`)),st(t,`zip215`);let u=_t(e),d=e[n-1];u[n-1]=d&-129;let f=ft(u);bt(`point.y`,f,Sn,t?s:r.ORDER);let p=c(f*f),{isValid:h,value:g}=l(c(p-Cn),c(o*p-i));if(!h)throw Error(`bad point: invalid y coordinate`);let _=(g&Cn)===Cn,v=(d&128)!=0;if(!t&&g===Sn&&v)throw Error(`bad point: x=0 and x_0=1`);return v!==_&&(g=c(-g)),m.fromAffine({x:g,y:f})}static fromHex(e,t=!1){return m.fromBytes(ht(`point`,e),t)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(e=8,t=!0){return h.createCache(this,e),t||this.multiply(wn),this}assertValidity(){p(this)}equals(e){d(e);let{X:t,Y:n,Z:r}=this,{X:i,Y:a,Z:o}=e,s=c(t*o),l=c(i*r),u=c(n*o),f=c(a*r);return s===l&&u===f}is0(){return this.equals(m.ZERO)}negate(){return new m(c(-this.X),this.Y,this.Z,c(-this.T))}double(){let{a:e}=a,{X:t,Y:n,Z:r}=this,i=c(t*t),o=c(n*n),s=c(wn*c(r*r)),l=c(e*i),u=t+n,d=c(c(u*u)-i-o),f=l+o,p=f-s,h=l-o,g=c(d*p),_=c(f*h),v=c(d*h);return new m(g,_,c(p*f),v)}add(e){d(e);let{a:t,d:n}=a,{X:r,Y:i,Z:o,T:s}=this,{X:l,Y:u,Z:f,T:p}=e,h=c(r*l),g=c(i*u),_=c(s*n*p),v=c(o*f),y=c((r+i)*(l+u)-h-g),b=v-_,x=v+_,ee=c(g-t*h),S=c(y*b),C=c(x*ee),w=c(y*ee);return new m(S,C,c(b*x),w)}subtract(e){return this.add(e.negate())}multiply(e){if(!i.isValidNot0(e))throw Error(`invalid scalar: expected 1 <= sc < curve.n`);let{p:t,f:n}=h.cached(this,e,e=>sn(m,e));return sn(m,[t,n])[0]}multiplyUnsafe(e,t=m.ZERO){if(!i.isValid(e))throw Error(`invalid scalar: expected 0 <= sc < curve.n`);return e===Sn?m.ZERO:this.is0()||e===Cn?this:h.unsafe(this,e,e=>sn(m,e),t)}isSmallOrder(){return this.multiplyUnsafe(o).is0()}isTorsionFree(){return h.unsafe(this,a.n).is0()}toAffine(e){return f(this,e)}clearCofactor(){return o===Cn?this:this.multiplyUnsafe(o)}toBytes(){let{x:e,y:t}=this.toAffine(),n=r.toBytes(t);return n[n.length-1]|=e&Cn?128:0,n}toHex(){return N(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(e){return sn(m,e)}static msm(e,t){return yn(m,i,e,t)}_setWindowSize(e){this.precompute(e)}toRawBytes(){return this.toBytes()}}m.BASE=new m(a.Gx,a.Gy,Cn,c(a.Gx*a.Gy)),m.ZERO=new m(Sn,Cn,Cn,Sn),m.Fp=r,m.Fn=i;let h=new _n(m,i.BITS);return m.BASE.precompute(8),m}var On=class{constructor(e){this.ep=e}static fromBytes(e){Tt()}static fromHex(e){Tt()}get x(){return this.toAffine().x}get y(){return this.toAffine().y}clearCofactor(){return this}assertValidity(){this.ep.assertValidity()}toAffine(e){return this.ep.toAffine(e)}toHex(){return N(this.toBytes())}toString(){return this.toHex()}isTorsionFree(){return!0}isSmallOrder(){return!1}add(e){return this.assertSame(e),this.init(this.ep.add(e.ep))}subtract(e){return this.assertSame(e),this.init(this.ep.subtract(e.ep))}multiply(e){return this.init(this.ep.multiply(e))}multiplyUnsafe(e){return this.init(this.ep.multiplyUnsafe(e))}double(){return this.init(this.ep.double())}negate(){return this.init(this.ep.negate())}precompute(e,t){return this.init(this.ep.precompute(e,t))}toRawBytes(){return this.toBytes()}};function kn(e,t,n={}){if(typeof t!=`function`)throw Error(`"hash" function param is required`);wt(n,{},{adjustScalarBytes:`function`,randomBytes:`function`,domain:`function`,prehash:`function`,mapToCurve:`function`});let{prehash:r}=n,{BASE:i,Fp:a,Fn:o}=e,s=n.randomBytes||ve,c=n.adjustScalarBytes||(e=>e),l=n.domain||((e,t,n)=>{if(st(n,`phflag`),t.length||n)throw Error(`Contexts/pre-hash are not supported`);return e});function u(e){return o.create(ft(e))}function d(e){let n=y.secretKey;e=ht(`private key`,e,n);let r=ht(`hashed private key`,t(e),2*n),i=c(r.slice(0,n));return{head:i,prefix:r.slice(n,2*n),scalar:u(i)}}function f(e){let{head:t,prefix:n,scalar:r}=d(e),a=i.multiply(r);return{head:t,prefix:n,scalar:r,point:a,pointBytes:a.toBytes()}}function p(e){return f(e).pointBytes}function m(e=Uint8Array.of(),...n){return u(t(l(F(...n),ht(`context`,e),!!r)))}function h(e,t,n={}){e=ht(`message`,e),r&&(e=r(e));let{prefix:a,scalar:s,pointBytes:c}=f(t),l=m(n.context,a,e),u=i.multiply(l).toBytes(),d=m(n.context,u,c,e),p=o.create(l+d*s);if(!o.isValid(p))throw Error(`sign failed: invalid s`);return ct(F(u,o.toBytes(p)),y.signature,`result`)}let g={zip215:!0};function _(t,n,a,o=g){let{context:s,zip215:c}=o,l=y.signature;t=ht(`signature`,t,l),n=ht(`message`,n),a=ht(`publicKey`,a,y.publicKey),c!==void 0&&st(c,`zip215`),r&&(n=r(n));let u=l/2,d=t.subarray(0,u),f=ft(t.subarray(u,l)),p,h,_;try{p=e.fromBytes(a,c),h=e.fromBytes(d,c),_=i.multiplyUnsafe(f)}catch{return!1}if(!c&&p.isSmallOrder())return!1;let v=m(s,h.toBytes(),p.toBytes(),n);return h.add(p.multiplyUnsafe(v)).subtract(_).clearCofactor().is0()}let v=a.BYTES,y={secretKey:v,publicKey:v,signature:2*v,seed:v};function b(e=s(y.seed)){return ct(e,y.seed,`seed`)}function x(e){let t=C.randomSecretKey(e);return{secretKey:t,publicKey:p(t)}}function ee(e){return O(e)&&e.length===o.BYTES}function S(t,n){try{return!!e.fromBytes(t,n)}catch{return!1}}let C={getExtendedPublicKey:f,randomSecretKey:b,isValidSecretKey:ee,isValidPublicKey:S,toMontgomery(t){let{y:n}=e.fromBytes(t),r=y.publicKey,i=r===32;if(!i&&r!==57)throw Error(`only defined for 25519 and 448`);let o=i?a.div(Cn+n,Cn-n):a.div(n-Cn,n+Cn);return a.toBytes(o)},toMontgomerySecret(e){let n=y.secretKey;return ct(e,n),c(t(e.subarray(0,n))).subarray(0,n)},randomPrivateKey:b,precompute(t=8,n=e.BASE){return n.precompute(t,!1)}};return Object.freeze({keygen:x,getPublicKey:p,sign:h,verify:_,utils:C,Point:e,lengths:y})}function An(e){let t={a:e.a,d:e.d,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},n={Fp:e.Fp,Fn:$t(t.n,e.nBitLength,!0),uvRatio:e.uvRatio},r={randomBytes:e.randomBytes,adjustScalarBytes:e.adjustScalarBytes,domain:e.domain,prehash:e.prehash,mapToCurve:e.mapToCurve};return{CURVE:t,curveOpts:n,hash:e.hash,eddsaOpts:r}}function jn(e,t){let n=t.Point;return Object.assign({},t,{ExtendedPoint:n,CURVE:e,nBitLength:n.Fn.BITS,nByteLength:n.Fn.BYTES})}function Mn(e){let{CURVE:t,curveOpts:n,hash:r,eddsaOpts:i}=An(e);return jn(e,kn(Dn(t,n),r,i))}var Nn=BigInt(0),Pn=BigInt(1),Fn=BigInt(2),In=BigInt(5),Ln=BigInt(8),Rn=BigInt(`0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed`),zn={p:Rn,n:BigInt(`0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed`),h:Ln,a:BigInt(`0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec`),d:BigInt(`0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3`),Gx:BigInt(`0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a`),Gy:BigInt(`0x6666666666666666666666666666666666666666666666666666666666666658`)};function Bn(e){let t=BigInt(10),n=BigInt(20),r=BigInt(40),i=BigInt(80),a=Rn,o=e*e%a*e%a,s=Rt(Rt(o,Fn,a)*o%a,Pn,a)*e%a,c=Rt(s,In,a)*s%a,l=Rt(c,t,a)*c%a,u=Rt(l,n,a)*l%a,d=Rt(u,r,a)*u%a;return{pow_p_5_8:Rt(Rt(Rt(Rt(d,i,a)*d%a,i,a)*d%a,t,a)*c%a,Fn,a)*e%a,b2:o}}function Vn(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var Hn=BigInt(`19681161376707505956807079304988542015446066515923890162744021073123829784752`);function Un(e,t){let n=Rn,r=Lt(t*t*t,n),i=Bn(e*Lt(r*r*t,n)).pow_p_5_8,a=Lt(e*r*i,n),o=Lt(t*a*a,n),s=a,c=Lt(a*Hn,n),l=o===e,u=o===Lt(-e,n),d=o===Lt(-e*Hn,n);return l&&(a=s),(u||d)&&(a=c),Kt(a,n)&&(a=Lt(-a,n)),{isValid:l||u,value:a}}var Wn=$t(zn.p,{isLE:!0}),Gn=$t(zn.n,{isLE:!0}),Kn=Mn({...zn,Fp:Wn,hash:Qe,adjustScalarBytes:Vn,uvRatio:Un}),qn=Hn,Jn=BigInt(`25063068953384623474111414158702152701244531502492656460079210482610430750235`),Yn=BigInt(`54469307008909316920995813868745141605393597292927456921205312896311721017578`),Xn=BigInt(`1159843021668779879193775521855586647937357759715417654439879720876111806838`),Zn=BigInt(`40440834346308536858101042469323190826248399146238708352240133220865137265952`),Qn=e=>Un(Pn,e),$n=BigInt(`0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff`),er=e=>Kn.Point.Fp.create(ft(e)&$n);function tr(e){let{d:t}=zn,n=Rn,r=e=>Wn.create(e),i=r(qn*e*e),a=r((i+Pn)*Xn),o=BigInt(-1),s=r((o-t*i)*r(i+t)),{isValid:c,value:l}=Un(a,s),u=r(l*e);Kt(u,n)||(u=r(-u)),c||(l=u),c||(o=i);let d=r(o*(i-Pn)*Zn-s),f=l*l,p=r((l+l)*s),m=r(d*Jn),h=r(Pn-f),g=r(Pn+f);return new Kn.Point(r(p*g),r(h*m),r(m*g),r(p*h))}function nr(e){te(e,64);let t=tr(er(e.subarray(0,32))),n=tr(er(e.subarray(32,64)));return new rr(t.add(n))}var rr=class e extends On{constructor(e){super(e)}static fromAffine(t){return new e(Kn.Point.fromAffine(t))}assertSame(t){if(!(t instanceof e))throw Error(`RistrettoPoint expected`)}init(t){return new e(t)}static hashToCurve(e){return nr(ht(`ristrettoHash`,e,64))}static fromBytes(t){te(t,32);let{a:n,d:r}=zn,i=Rn,a=e=>Wn.create(e),o=er(t);if(!gt(Wn.toBytes(o),t)||Kt(o,i))throw Error(`invalid ristretto255 encoding 1`);let s=a(o*o),c=a(Pn+n*s),l=a(Pn-n*s),u=a(c*c),d=a(l*l),f=a(n*r*u-d),{isValid:p,value:m}=Qn(a(f*d)),h=a(m*l),g=a(m*h*f),_=a((o+o)*h);Kt(_,i)&&(_=a(-_));let v=a(c*g),y=a(_*v);if(!p||Kt(y,i)||v===Nn)throw Error(`invalid ristretto255 encoding 2`);return new e(new Kn.Point(_,v,Pn,y))}static fromHex(t){return e.fromBytes(ht(`ristrettoHex`,t,32))}static msm(t,n){return yn(e,Kn.Point.Fn,t,n)}toBytes(){let{X:e,Y:t,Z:n,T:r}=this.ep,i=Rn,a=e=>Wn.create(e),o=a(a(n+t)*a(n-t)),s=a(e*t),{value:c}=Qn(a(o*a(s*s))),l=a(c*o),u=a(c*s),d=a(l*u*r),f;if(Kt(r*d,i)){let n=a(t*qn),r=a(e*qn);e=n,t=r,f=a(l*Yn)}else f=u;Kt(e*d,i)&&(t=a(-t));let p=a((n-t)*f);return Kt(p,i)&&(p=a(-p)),Wn.toBytes(p)}equals(e){this.assertSame(e);let{X:t,Y:n}=this.ep,{X:r,Y:i}=e.ep,a=e=>Wn.create(e),o=a(t*i)===a(n*r),s=a(n*i)===a(t*r);return o||s}is0(){return this.equals(e.ZERO)}};rr.BASE=new rr(Kn.Point.BASE),rr.ZERO=new rr(Kn.Point.ZERO),rr.Fp=Wn,rr.Fn=Gn;var ir=i(((e,t)=>{(function(e,t){function n(e,t){if(!e)throw Error(t||`Assertion failed`)}function r(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}function i(e,t,n){if(i.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,e!==null&&((t===`le`||t===`be`)&&(n=t,t=10),this._init(e||0,t||10,n||`be`))}typeof e==`object`?e.exports=i:t.BN=i,i.BN=i,i.wordSize=26;var o;try{o=typeof window<`u`&&window.Buffer!==void 0?window.Buffer:a().Buffer}catch{}i.isBN=function(e){return e instanceof i?!0:typeof e==`object`&&!!e&&e.constructor.wordSize===i.wordSize&&Array.isArray(e.words)},i.max=function(e,t){return e.cmp(t)>0?e:t},i.min=function(e,t){return e.cmp(t)<0?e:t},i.prototype._init=function(e,t,r){if(typeof e==`number`)return this._initNumber(e,t,r);if(typeof e==`object`)return this._initArray(e,t,r);t===`hex`&&(t=16),n(t===(t|0)&&t>=2&&t<=36),e=e.toString().replace(/\s+/g,``);var i=0;e[0]===`-`&&(i++,this.negative=1),i<e.length&&(t===16?this._parseHex(e,i,r):(this._parseBase(e,t,i),r===`le`&&this._initArray(this.toArray(),t,r)))},i.prototype._initNumber=function(e,t,r){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[e&67108863],this.length=1):e<4503599627370496?(this.words=[e&67108863,e/67108864&67108863],this.length=2):(n(e<9007199254740992),this.words=[e&67108863,e/67108864&67108863,1],this.length=3),r===`le`&&this._initArray(this.toArray(),t,r)},i.prototype._initArray=function(e,t,r){if(n(typeof e.length==`number`),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var a,o,s=0;if(r===`be`)for(i=e.length-1,a=0;i>=0;i-=3)o=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[a]|=o<<s&67108863,this.words[a+1]=o>>>26-s&67108863,s+=24,s>=26&&(s-=26,a++);else if(r===`le`)for(i=0,a=0;i<e.length;i+=3)o=e[i]|e[i+1]<<8|e[i+2]<<16,this.words[a]|=o<<s&67108863,this.words[a+1]=o>>>26-s&67108863,s+=24,s>=26&&(s-=26,a++);return this._strip()};function s(e,t){var r=e.charCodeAt(t);if(r>=48&&r<=57)return r-48;if(r>=65&&r<=70)return r-55;if(r>=97&&r<=102)return r-87;n(!1,`Invalid character in `+e)}function c(e,t,n){var r=s(e,n);return n-1>=t&&(r|=s(e,n-1)<<4),r}i.prototype._parseHex=function(e,t,n){this.length=Math.ceil((e.length-t)/6),this.words=Array(this.length);for(var r=0;r<this.length;r++)this.words[r]=0;var i=0,a=0,o;if(n===`be`)for(r=e.length-1;r>=t;r-=2)o=c(e,t,r)<<i,this.words[a]|=o&67108863,i>=18?(i-=18,a+=1,this.words[a]|=o>>>26):i+=8;else for(r=(e.length-t)%2==0?t+1:t;r<e.length;r+=2)o=c(e,t,r)<<i,this.words[a]|=o&67108863,i>=18?(i-=18,a+=1,this.words[a]|=o>>>26):i+=8;this._strip()};function l(e,t,r,i){for(var a=0,o=0,s=Math.min(e.length,r),c=t;c<s;c++){var l=e.charCodeAt(c)-48;a*=i,o=l>=49?l-49+10:l>=17?l-17+10:l,n(l>=0&&o<i,`Invalid character`),a+=o}return a}i.prototype._parseBase=function(e,t,n){this.words=[0],this.length=1;for(var r=0,i=1;i<=67108863;i*=t)r++;r--,i=i/t|0;for(var a=e.length-n,o=a%r,s=Math.min(a,a-o)+n,c=0,u=n;u<s;u+=r)c=l(e,u,u+r,t),this.imuln(i),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c);if(o!==0){var d=1;for(c=l(e,u,e.length,t),u=0;u<o;u++)d*=t;this.imuln(d),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c)}this._strip()},i.prototype.copy=function(e){e.words=Array(this.length);for(var t=0;t<this.length;t++)e.words[t]=this.words[t];e.length=this.length,e.negative=this.negative,e.red=this.red};function u(e,t){e.words=t.words,e.length=t.length,e.negative=t.negative,e.red=t.red}if(i.prototype._move=function(e){u(e,this)},i.prototype.clone=function(){var e=new i(null);return this.copy(e),e},i.prototype._expand=function(e){for(;this.length<e;)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<`u`&&typeof Symbol.for==`function`)try{i.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=d}catch{i.prototype.inspect=d}else i.prototype.inspect=d;function d(){return(this.red?`<BN-R: `:`<BN: `)+this.toString(16)+`>`}var f=`.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`.split(`.`),p=[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],m=[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(e,t){e||=10,t=t|0||1;var r;if(e===16||e===`hex`){r=``;for(var i=0,a=0,o=0;o<this.length;o++){var s=this.words[o],c=((s<<i|a)&16777215).toString(16);a=s>>>24-i&16777215,i+=2,i>=26&&(i-=26,o--),r=a!==0||o!==this.length-1?f[6-c.length]+c+r:c+r}for(a!==0&&(r=a.toString(16)+r);r.length%t!==0;)r=`0`+r;return this.negative!==0&&(r=`-`+r),r}if(e===(e|0)&&e>=2&&e<=36){var l=p[e],u=m[e];r=``;var d=this.clone();for(d.negative=0;!d.isZero();){var h=d.modrn(u).toString(e);d=d.idivn(u),r=d.isZero()?h+r:f[l-h.length]+h+r}for(this.isZero()&&(r=`0`+r);r.length%t!==0;)r=`0`+r;return this.negative!==0&&(r=`-`+r),r}n(!1,`Base should be between 2 and 36`)},i.prototype.toNumber=function(){var e=this.words[0];return this.length===2?e+=this.words[1]*67108864:this.length===3&&this.words[2]===1?e+=4503599627370496+this.words[1]*67108864:this.length>2&&n(!1,`Number can only safely store up to 53 bits`),this.negative===0?e:-e},i.prototype.toJSON=function(){return this.toString(16,2)},o&&(i.prototype.toBuffer=function(e,t){return this.toArrayLike(o,e,t)}),i.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)};var h=function(e,t){return e.allocUnsafe?e.allocUnsafe(t):new e(t)};i.prototype.toArrayLike=function(e,t,r){this._strip();var i=this.byteLength(),a=r||Math.max(1,i);n(i<=a,`byte array longer than desired length`),n(a>0,`Requested array length <= 0`);var o=h(e,a),s=t===`le`?`LE`:`BE`;return this[`_toArrayLike`+s](o,i),o},i.prototype._toArrayLikeLE=function(e,t){for(var n=0,r=0,i=0,a=0;i<this.length;i++){var o=this.words[i]<<a|r;e[n++]=o&255,n<e.length&&(e[n++]=o>>8&255),n<e.length&&(e[n++]=o>>16&255),a===6?(n<e.length&&(e[n++]=o>>24&255),r=0,a=0):(r=o>>>24,a+=2)}if(n<e.length)for(e[n++]=r;n<e.length;)e[n++]=0},i.prototype._toArrayLikeBE=function(e,t){for(var n=e.length-1,r=0,i=0,a=0;i<this.length;i++){var o=this.words[i]<<a|r;e[n--]=o&255,n>=0&&(e[n--]=o>>8&255),n>=0&&(e[n--]=o>>16&255),a===6?(n>=0&&(e[n--]=o>>24&255),r=0,a=0):(r=o>>>24,a+=2)}if(n>=0)for(e[n--]=r;n>=0;)e[n--]=0},Math.clz32?i.prototype._countBits=function(e){return 32-Math.clz32(e)}:i.prototype._countBits=function(e){var t=e,n=0;return t>=4096&&(n+=13,t>>>=13),t>=64&&(n+=7,t>>>=7),t>=8&&(n+=4,t>>>=4),t>=2&&(n+=2,t>>>=2),n+t},i.prototype._zeroBits=function(e){if(e===0)return 26;var t=e,n=0;return t&8191||(n+=13,t>>>=13),t&127||(n+=7,t>>>=7),t&15||(n+=4,t>>>=4),t&3||(n+=2,t>>>=2),t&1||n++,n},i.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return(this.length-1)*26+t};function g(e){for(var t=Array(e.bitLength()),n=0;n<t.length;n++){var r=n/26|0,i=n%26;t[n]=e.words[r]>>>i&1}return t}i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;t<this.length;t++){var n=this._zeroBits(this.words[t]);if(e+=n,n!==26)break}return e},i.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},i.prototype.toTwos=function(e){return this.negative===0?this.clone():this.abs().inotn(e).iaddn(1)},i.prototype.fromTwos=function(e){return this.testn(e-1)?this.notn(e).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(e){for(;this.length<e.length;)this.words[this.length++]=0;for(var t=0;t<e.length;t++)this.words[t]=this.words[t]|e.words[t];return this._strip()},i.prototype.ior=function(e){return n((this.negative|e.negative)===0),this.iuor(e)},i.prototype.or=function(e){return this.length>e.length?this.clone().ior(e):e.clone().ior(this)},i.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},i.prototype.iuand=function(e){for(var t=this.length>e.length?e:this,n=0;n<t.length;n++)this.words[n]=this.words[n]&e.words[n];return this.length=t.length,this._strip()},i.prototype.iand=function(e){return n((this.negative|e.negative)===0),this.iuand(e)},i.prototype.and=function(e){return this.length>e.length?this.clone().iand(e):e.clone().iand(this)},i.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},i.prototype.iuxor=function(e){var t,n;this.length>e.length?(t=this,n=e):(t=e,n=this);for(var r=0;r<n.length;r++)this.words[r]=t.words[r]^n.words[r];if(this!==t)for(;r<t.length;r++)this.words[r]=t.words[r];return this.length=t.length,this._strip()},i.prototype.ixor=function(e){return n((this.negative|e.negative)===0),this.iuxor(e)},i.prototype.xor=function(e){return this.length>e.length?this.clone().ixor(e):e.clone().ixor(this)},i.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},i.prototype.inotn=function(e){n(typeof e==`number`&&e>=0);var t=Math.ceil(e/26)|0,r=e%26;this._expand(t),r>0&&t--;for(var i=0;i<t;i++)this.words[i]=~this.words[i]&67108863;return r>0&&(this.words[i]=~this.words[i]&67108863>>26-r),this._strip()},i.prototype.notn=function(e){return this.clone().inotn(e)},i.prototype.setn=function(e,t){n(typeof e==`number`&&e>=0);var r=e/26|0,i=e%26;return this._expand(r+1),t?this.words[r]=this.words[r]|1<<i:this.words[r]=this.words[r]&~(1<<i),this._strip()},i.prototype.iadd=function(e){var t;if(this.negative!==0&&e.negative===0)return this.negative=0,t=this.isub(e),this.negative^=1,this._normSign();if(this.negative===0&&e.negative!==0)return e.negative=0,t=this.isub(e),e.negative=1,t._normSign();var n,r;this.length>e.length?(n=this,r=e):(n=e,r=this);for(var i=0,a=0;a<r.length;a++)t=(n.words[a]|0)+(r.words[a]|0)+i,this.words[a]=t&67108863,i=t>>>26;for(;i!==0&&a<n.length;a++)t=(n.words[a]|0)+i,this.words[a]=t&67108863,i=t>>>26;if(this.length=n.length,i!==0)this.words[this.length]=i,this.length++;else if(n!==this)for(;a<n.length;a++)this.words[a]=n.words[a];return this},i.prototype.add=function(e){var t;return e.negative!==0&&this.negative===0?(e.negative=0,t=this.sub(e),e.negative^=1,t):e.negative===0&&this.negative!==0?(this.negative=0,t=e.sub(this),this.negative=1,t):this.length>e.length?this.clone().iadd(e):e.clone().iadd(this)},i.prototype.isub=function(e){if(e.negative!==0){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var n=this.cmp(e);if(n===0)return this.negative=0,this.length=1,this.words[0]=0,this;var r,i;n>0?(r=this,i=e):(r=e,i=this);for(var a=0,o=0;o<i.length;o++)t=(r.words[o]|0)-(i.words[o]|0)+a,a=t>>26,this.words[o]=t&67108863;for(;a!==0&&o<r.length;o++)t=(r.words[o]|0)+a,a=t>>26,this.words[o]=t&67108863;if(a===0&&o<r.length&&r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this.length=Math.max(this.length,o),r!==this&&(this.negative=1),this._strip()},i.prototype.sub=function(e){return this.clone().isub(e)};function _(e,t,n){n.negative=t.negative^e.negative;var r=e.length+t.length|0;n.length=r,r=r-1|0;var i=e.words[0]|0,a=t.words[0]|0,o=i*a,s=o&67108863,c=o/67108864|0;n.words[0]=s;for(var l=1;l<r;l++){for(var u=c>>>26,d=c&67108863,f=Math.min(l,t.length-1),p=Math.max(0,l-e.length+1);p<=f;p++){var m=l-p|0;i=e.words[m]|0,a=t.words[p]|0,o=i*a+d,u+=o/67108864|0,d=o&67108863}n.words[l]=d|0,c=u|0}return c===0?n.length--:n.words[l]=c|0,n._strip()}var v=function(e,t,n){var r=e.words,i=t.words,a=n.words,o=0,s,c,l,u=r[0]|0,d=u&8191,f=u>>>13,p=r[1]|0,m=p&8191,h=p>>>13,g=r[2]|0,_=g&8191,v=g>>>13,y=r[3]|0,b=y&8191,x=y>>>13,ee=r[4]|0,S=ee&8191,C=ee>>>13,w=r[5]|0,T=w&8191,E=w>>>13,D=r[6]|0,O=D&8191,k=D>>>13,te=r[7]|0,ne=te&8191,A=te>>>13,re=r[8]|0,ie=re&8191,j=re>>>13,ae=r[9]|0,M=ae&8191,oe=ae>>>13,se=i[0]|0,ce=se&8191,le=se>>>13,ue=i[1]|0,de=ue&8191,N=ue>>>13,fe=i[2]|0,pe=fe&8191,me=fe>>>13,he=i[3]|0,P=he&8191,F=he>>>13,ge=i[4]|0,_e=ge&8191,ve=ge>>>13,ye=i[5]|0,be=ye&8191,xe=ye>>>13,Se=i[6]|0,Ce=Se&8191,we=Se>>>13,Te=i[7]|0,Ee=Te&8191,De=Te>>>13,Oe=i[8]|0,ke=Oe&8191,Ae=Oe>>>13,je=i[9]|0,Me=je&8191,Ne=je>>>13;n.negative=e.negative^t.negative,n.length=19,s=Math.imul(d,ce),c=Math.imul(d,le),c=c+Math.imul(f,ce)|0,l=Math.imul(f,le);var Pe=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Pe>>>26)|0,Pe&=67108863,s=Math.imul(m,ce),c=Math.imul(m,le),c=c+Math.imul(h,ce)|0,l=Math.imul(h,le),s=s+Math.imul(d,de)|0,c=c+Math.imul(d,N)|0,c=c+Math.imul(f,de)|0,l=l+Math.imul(f,N)|0;var Fe=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Fe>>>26)|0,Fe&=67108863,s=Math.imul(_,ce),c=Math.imul(_,le),c=c+Math.imul(v,ce)|0,l=Math.imul(v,le),s=s+Math.imul(m,de)|0,c=c+Math.imul(m,N)|0,c=c+Math.imul(h,de)|0,l=l+Math.imul(h,N)|0,s=s+Math.imul(d,pe)|0,c=c+Math.imul(d,me)|0,c=c+Math.imul(f,pe)|0,l=l+Math.imul(f,me)|0;var Ie=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,s=Math.imul(b,ce),c=Math.imul(b,le),c=c+Math.imul(x,ce)|0,l=Math.imul(x,le),s=s+Math.imul(_,de)|0,c=c+Math.imul(_,N)|0,c=c+Math.imul(v,de)|0,l=l+Math.imul(v,N)|0,s=s+Math.imul(m,pe)|0,c=c+Math.imul(m,me)|0,c=c+Math.imul(h,pe)|0,l=l+Math.imul(h,me)|0,s=s+Math.imul(d,P)|0,c=c+Math.imul(d,F)|0,c=c+Math.imul(f,P)|0,l=l+Math.imul(f,F)|0;var Le=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Le>>>26)|0,Le&=67108863,s=Math.imul(S,ce),c=Math.imul(S,le),c=c+Math.imul(C,ce)|0,l=Math.imul(C,le),s=s+Math.imul(b,de)|0,c=c+Math.imul(b,N)|0,c=c+Math.imul(x,de)|0,l=l+Math.imul(x,N)|0,s=s+Math.imul(_,pe)|0,c=c+Math.imul(_,me)|0,c=c+Math.imul(v,pe)|0,l=l+Math.imul(v,me)|0,s=s+Math.imul(m,P)|0,c=c+Math.imul(m,F)|0,c=c+Math.imul(h,P)|0,l=l+Math.imul(h,F)|0,s=s+Math.imul(d,_e)|0,c=c+Math.imul(d,ve)|0,c=c+Math.imul(f,_e)|0,l=l+Math.imul(f,ve)|0;var Re=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Re>>>26)|0,Re&=67108863,s=Math.imul(T,ce),c=Math.imul(T,le),c=c+Math.imul(E,ce)|0,l=Math.imul(E,le),s=s+Math.imul(S,de)|0,c=c+Math.imul(S,N)|0,c=c+Math.imul(C,de)|0,l=l+Math.imul(C,N)|0,s=s+Math.imul(b,pe)|0,c=c+Math.imul(b,me)|0,c=c+Math.imul(x,pe)|0,l=l+Math.imul(x,me)|0,s=s+Math.imul(_,P)|0,c=c+Math.imul(_,F)|0,c=c+Math.imul(v,P)|0,l=l+Math.imul(v,F)|0,s=s+Math.imul(m,_e)|0,c=c+Math.imul(m,ve)|0,c=c+Math.imul(h,_e)|0,l=l+Math.imul(h,ve)|0,s=s+Math.imul(d,be)|0,c=c+Math.imul(d,xe)|0,c=c+Math.imul(f,be)|0,l=l+Math.imul(f,xe)|0;var ze=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(ze>>>26)|0,ze&=67108863,s=Math.imul(O,ce),c=Math.imul(O,le),c=c+Math.imul(k,ce)|0,l=Math.imul(k,le),s=s+Math.imul(T,de)|0,c=c+Math.imul(T,N)|0,c=c+Math.imul(E,de)|0,l=l+Math.imul(E,N)|0,s=s+Math.imul(S,pe)|0,c=c+Math.imul(S,me)|0,c=c+Math.imul(C,pe)|0,l=l+Math.imul(C,me)|0,s=s+Math.imul(b,P)|0,c=c+Math.imul(b,F)|0,c=c+Math.imul(x,P)|0,l=l+Math.imul(x,F)|0,s=s+Math.imul(_,_e)|0,c=c+Math.imul(_,ve)|0,c=c+Math.imul(v,_e)|0,l=l+Math.imul(v,ve)|0,s=s+Math.imul(m,be)|0,c=c+Math.imul(m,xe)|0,c=c+Math.imul(h,be)|0,l=l+Math.imul(h,xe)|0,s=s+Math.imul(d,Ce)|0,c=c+Math.imul(d,we)|0,c=c+Math.imul(f,Ce)|0,l=l+Math.imul(f,we)|0;var Be=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Be>>>26)|0,Be&=67108863,s=Math.imul(ne,ce),c=Math.imul(ne,le),c=c+Math.imul(A,ce)|0,l=Math.imul(A,le),s=s+Math.imul(O,de)|0,c=c+Math.imul(O,N)|0,c=c+Math.imul(k,de)|0,l=l+Math.imul(k,N)|0,s=s+Math.imul(T,pe)|0,c=c+Math.imul(T,me)|0,c=c+Math.imul(E,pe)|0,l=l+Math.imul(E,me)|0,s=s+Math.imul(S,P)|0,c=c+Math.imul(S,F)|0,c=c+Math.imul(C,P)|0,l=l+Math.imul(C,F)|0,s=s+Math.imul(b,_e)|0,c=c+Math.imul(b,ve)|0,c=c+Math.imul(x,_e)|0,l=l+Math.imul(x,ve)|0,s=s+Math.imul(_,be)|0,c=c+Math.imul(_,xe)|0,c=c+Math.imul(v,be)|0,l=l+Math.imul(v,xe)|0,s=s+Math.imul(m,Ce)|0,c=c+Math.imul(m,we)|0,c=c+Math.imul(h,Ce)|0,l=l+Math.imul(h,we)|0,s=s+Math.imul(d,Ee)|0,c=c+Math.imul(d,De)|0,c=c+Math.imul(f,Ee)|0,l=l+Math.imul(f,De)|0;var Ve=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Ve>>>26)|0,Ve&=67108863,s=Math.imul(ie,ce),c=Math.imul(ie,le),c=c+Math.imul(j,ce)|0,l=Math.imul(j,le),s=s+Math.imul(ne,de)|0,c=c+Math.imul(ne,N)|0,c=c+Math.imul(A,de)|0,l=l+Math.imul(A,N)|0,s=s+Math.imul(O,pe)|0,c=c+Math.imul(O,me)|0,c=c+Math.imul(k,pe)|0,l=l+Math.imul(k,me)|0,s=s+Math.imul(T,P)|0,c=c+Math.imul(T,F)|0,c=c+Math.imul(E,P)|0,l=l+Math.imul(E,F)|0,s=s+Math.imul(S,_e)|0,c=c+Math.imul(S,ve)|0,c=c+Math.imul(C,_e)|0,l=l+Math.imul(C,ve)|0,s=s+Math.imul(b,be)|0,c=c+Math.imul(b,xe)|0,c=c+Math.imul(x,be)|0,l=l+Math.imul(x,xe)|0,s=s+Math.imul(_,Ce)|0,c=c+Math.imul(_,we)|0,c=c+Math.imul(v,Ce)|0,l=l+Math.imul(v,we)|0,s=s+Math.imul(m,Ee)|0,c=c+Math.imul(m,De)|0,c=c+Math.imul(h,Ee)|0,l=l+Math.imul(h,De)|0,s=s+Math.imul(d,ke)|0,c=c+Math.imul(d,Ae)|0,c=c+Math.imul(f,ke)|0,l=l+Math.imul(f,Ae)|0;var He=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(He>>>26)|0,He&=67108863,s=Math.imul(M,ce),c=Math.imul(M,le),c=c+Math.imul(oe,ce)|0,l=Math.imul(oe,le),s=s+Math.imul(ie,de)|0,c=c+Math.imul(ie,N)|0,c=c+Math.imul(j,de)|0,l=l+Math.imul(j,N)|0,s=s+Math.imul(ne,pe)|0,c=c+Math.imul(ne,me)|0,c=c+Math.imul(A,pe)|0,l=l+Math.imul(A,me)|0,s=s+Math.imul(O,P)|0,c=c+Math.imul(O,F)|0,c=c+Math.imul(k,P)|0,l=l+Math.imul(k,F)|0,s=s+Math.imul(T,_e)|0,c=c+Math.imul(T,ve)|0,c=c+Math.imul(E,_e)|0,l=l+Math.imul(E,ve)|0,s=s+Math.imul(S,be)|0,c=c+Math.imul(S,xe)|0,c=c+Math.imul(C,be)|0,l=l+Math.imul(C,xe)|0,s=s+Math.imul(b,Ce)|0,c=c+Math.imul(b,we)|0,c=c+Math.imul(x,Ce)|0,l=l+Math.imul(x,we)|0,s=s+Math.imul(_,Ee)|0,c=c+Math.imul(_,De)|0,c=c+Math.imul(v,Ee)|0,l=l+Math.imul(v,De)|0,s=s+Math.imul(m,ke)|0,c=c+Math.imul(m,Ae)|0,c=c+Math.imul(h,ke)|0,l=l+Math.imul(h,Ae)|0,s=s+Math.imul(d,Me)|0,c=c+Math.imul(d,Ne)|0,c=c+Math.imul(f,Me)|0,l=l+Math.imul(f,Ne)|0;var Ue=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Ue>>>26)|0,Ue&=67108863,s=Math.imul(M,de),c=Math.imul(M,N),c=c+Math.imul(oe,de)|0,l=Math.imul(oe,N),s=s+Math.imul(ie,pe)|0,c=c+Math.imul(ie,me)|0,c=c+Math.imul(j,pe)|0,l=l+Math.imul(j,me)|0,s=s+Math.imul(ne,P)|0,c=c+Math.imul(ne,F)|0,c=c+Math.imul(A,P)|0,l=l+Math.imul(A,F)|0,s=s+Math.imul(O,_e)|0,c=c+Math.imul(O,ve)|0,c=c+Math.imul(k,_e)|0,l=l+Math.imul(k,ve)|0,s=s+Math.imul(T,be)|0,c=c+Math.imul(T,xe)|0,c=c+Math.imul(E,be)|0,l=l+Math.imul(E,xe)|0,s=s+Math.imul(S,Ce)|0,c=c+Math.imul(S,we)|0,c=c+Math.imul(C,Ce)|0,l=l+Math.imul(C,we)|0,s=s+Math.imul(b,Ee)|0,c=c+Math.imul(b,De)|0,c=c+Math.imul(x,Ee)|0,l=l+Math.imul(x,De)|0,s=s+Math.imul(_,ke)|0,c=c+Math.imul(_,Ae)|0,c=c+Math.imul(v,ke)|0,l=l+Math.imul(v,Ae)|0,s=s+Math.imul(m,Me)|0,c=c+Math.imul(m,Ne)|0,c=c+Math.imul(h,Me)|0,l=l+Math.imul(h,Ne)|0;var We=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(We>>>26)|0,We&=67108863,s=Math.imul(M,pe),c=Math.imul(M,me),c=c+Math.imul(oe,pe)|0,l=Math.imul(oe,me),s=s+Math.imul(ie,P)|0,c=c+Math.imul(ie,F)|0,c=c+Math.imul(j,P)|0,l=l+Math.imul(j,F)|0,s=s+Math.imul(ne,_e)|0,c=c+Math.imul(ne,ve)|0,c=c+Math.imul(A,_e)|0,l=l+Math.imul(A,ve)|0,s=s+Math.imul(O,be)|0,c=c+Math.imul(O,xe)|0,c=c+Math.imul(k,be)|0,l=l+Math.imul(k,xe)|0,s=s+Math.imul(T,Ce)|0,c=c+Math.imul(T,we)|0,c=c+Math.imul(E,Ce)|0,l=l+Math.imul(E,we)|0,s=s+Math.imul(S,Ee)|0,c=c+Math.imul(S,De)|0,c=c+Math.imul(C,Ee)|0,l=l+Math.imul(C,De)|0,s=s+Math.imul(b,ke)|0,c=c+Math.imul(b,Ae)|0,c=c+Math.imul(x,ke)|0,l=l+Math.imul(x,Ae)|0,s=s+Math.imul(_,Me)|0,c=c+Math.imul(_,Ne)|0,c=c+Math.imul(v,Me)|0,l=l+Math.imul(v,Ne)|0;var Ge=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Ge>>>26)|0,Ge&=67108863,s=Math.imul(M,P),c=Math.imul(M,F),c=c+Math.imul(oe,P)|0,l=Math.imul(oe,F),s=s+Math.imul(ie,_e)|0,c=c+Math.imul(ie,ve)|0,c=c+Math.imul(j,_e)|0,l=l+Math.imul(j,ve)|0,s=s+Math.imul(ne,be)|0,c=c+Math.imul(ne,xe)|0,c=c+Math.imul(A,be)|0,l=l+Math.imul(A,xe)|0,s=s+Math.imul(O,Ce)|0,c=c+Math.imul(O,we)|0,c=c+Math.imul(k,Ce)|0,l=l+Math.imul(k,we)|0,s=s+Math.imul(T,Ee)|0,c=c+Math.imul(T,De)|0,c=c+Math.imul(E,Ee)|0,l=l+Math.imul(E,De)|0,s=s+Math.imul(S,ke)|0,c=c+Math.imul(S,Ae)|0,c=c+Math.imul(C,ke)|0,l=l+Math.imul(C,Ae)|0,s=s+Math.imul(b,Me)|0,c=c+Math.imul(b,Ne)|0,c=c+Math.imul(x,Me)|0,l=l+Math.imul(x,Ne)|0;var Ke=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Ke>>>26)|0,Ke&=67108863,s=Math.imul(M,_e),c=Math.imul(M,ve),c=c+Math.imul(oe,_e)|0,l=Math.imul(oe,ve),s=s+Math.imul(ie,be)|0,c=c+Math.imul(ie,xe)|0,c=c+Math.imul(j,be)|0,l=l+Math.imul(j,xe)|0,s=s+Math.imul(ne,Ce)|0,c=c+Math.imul(ne,we)|0,c=c+Math.imul(A,Ce)|0,l=l+Math.imul(A,we)|0,s=s+Math.imul(O,Ee)|0,c=c+Math.imul(O,De)|0,c=c+Math.imul(k,Ee)|0,l=l+Math.imul(k,De)|0,s=s+Math.imul(T,ke)|0,c=c+Math.imul(T,Ae)|0,c=c+Math.imul(E,ke)|0,l=l+Math.imul(E,Ae)|0,s=s+Math.imul(S,Me)|0,c=c+Math.imul(S,Ne)|0,c=c+Math.imul(C,Me)|0,l=l+Math.imul(C,Ne)|0;var qe=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(qe>>>26)|0,qe&=67108863,s=Math.imul(M,be),c=Math.imul(M,xe),c=c+Math.imul(oe,be)|0,l=Math.imul(oe,xe),s=s+Math.imul(ie,Ce)|0,c=c+Math.imul(ie,we)|0,c=c+Math.imul(j,Ce)|0,l=l+Math.imul(j,we)|0,s=s+Math.imul(ne,Ee)|0,c=c+Math.imul(ne,De)|0,c=c+Math.imul(A,Ee)|0,l=l+Math.imul(A,De)|0,s=s+Math.imul(O,ke)|0,c=c+Math.imul(O,Ae)|0,c=c+Math.imul(k,ke)|0,l=l+Math.imul(k,Ae)|0,s=s+Math.imul(T,Me)|0,c=c+Math.imul(T,Ne)|0,c=c+Math.imul(E,Me)|0,l=l+Math.imul(E,Ne)|0;var Je=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Je>>>26)|0,Je&=67108863,s=Math.imul(M,Ce),c=Math.imul(M,we),c=c+Math.imul(oe,Ce)|0,l=Math.imul(oe,we),s=s+Math.imul(ie,Ee)|0,c=c+Math.imul(ie,De)|0,c=c+Math.imul(j,Ee)|0,l=l+Math.imul(j,De)|0,s=s+Math.imul(ne,ke)|0,c=c+Math.imul(ne,Ae)|0,c=c+Math.imul(A,ke)|0,l=l+Math.imul(A,Ae)|0,s=s+Math.imul(O,Me)|0,c=c+Math.imul(O,Ne)|0,c=c+Math.imul(k,Me)|0,l=l+Math.imul(k,Ne)|0;var Ye=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Ye>>>26)|0,Ye&=67108863,s=Math.imul(M,Ee),c=Math.imul(M,De),c=c+Math.imul(oe,Ee)|0,l=Math.imul(oe,De),s=s+Math.imul(ie,ke)|0,c=c+Math.imul(ie,Ae)|0,c=c+Math.imul(j,ke)|0,l=l+Math.imul(j,Ae)|0,s=s+Math.imul(ne,Me)|0,c=c+Math.imul(ne,Ne)|0,c=c+Math.imul(A,Me)|0,l=l+Math.imul(A,Ne)|0;var Xe=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Xe>>>26)|0,Xe&=67108863,s=Math.imul(M,ke),c=Math.imul(M,Ae),c=c+Math.imul(oe,ke)|0,l=Math.imul(oe,Ae),s=s+Math.imul(ie,Me)|0,c=c+Math.imul(ie,Ne)|0,c=c+Math.imul(j,Me)|0,l=l+Math.imul(j,Ne)|0;var Ze=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Ze>>>26)|0,Ze&=67108863,s=Math.imul(M,Me),c=Math.imul(M,Ne),c=c+Math.imul(oe,Me)|0,l=Math.imul(oe,Ne);var Qe=(o+s|0)+((c&8191)<<13)|0;return o=(l+(c>>>13)|0)+(Qe>>>26)|0,Qe&=67108863,a[0]=Pe,a[1]=Fe,a[2]=Ie,a[3]=Le,a[4]=Re,a[5]=ze,a[6]=Be,a[7]=Ve,a[8]=He,a[9]=Ue,a[10]=We,a[11]=Ge,a[12]=Ke,a[13]=qe,a[14]=Je,a[15]=Ye,a[16]=Xe,a[17]=Ze,a[18]=Qe,o!==0&&(a[19]=o,n.length++),n};Math.imul||(v=_);function y(e,t,n){n.negative=t.negative^e.negative,n.length=e.length+t.length;for(var r=0,i=0,a=0;a<n.length-1;a++){var o=i;i=0;for(var s=r&67108863,c=Math.min(a,t.length-1),l=Math.max(0,a-e.length+1);l<=c;l++){var u=a-l,d=(e.words[u]|0)*(t.words[l]|0),f=d&67108863;o=o+(d/67108864|0)|0,f=f+s|0,s=f&67108863,o=o+(f>>>26)|0,i+=o>>>26,o&=67108863}n.words[a]=s,r=o,o=i}return r===0?n.length--:n.words[a]=r,n._strip()}function b(e,t,n){return y(e,t,n)}i.prototype.mulTo=function(e,t){var n,r=this.length+e.length;return n=this.length===10&&e.length===10?v(this,e,t):r<63?_(this,e,t):r<1024?y(this,e,t):b(this,e,t),n};function x(e,t){this.x=e,this.y=t}x.prototype.makeRBT=function(e){for(var t=Array(e),n=i.prototype._countBits(e)-1,r=0;r<e;r++)t[r]=this.revBin(r,n,e);return t},x.prototype.revBin=function(e,t,n){if(e===0||e===n-1)return e;for(var r=0,i=0;i<t;i++)r|=(e&1)<<t-i-1,e>>=1;return r},x.prototype.permute=function(e,t,n,r,i,a){for(var o=0;o<a;o++)r[o]=t[e[o]],i[o]=n[e[o]]},x.prototype.transform=function(e,t,n,r,i,a){this.permute(a,e,t,n,r,i);for(var o=1;o<i;o<<=1)for(var s=o<<1,c=Math.cos(2*Math.PI/s),l=Math.sin(2*Math.PI/s),u=0;u<i;u+=s)for(var d=c,f=l,p=0;p<o;p++){var m=n[u+p],h=r[u+p],g=n[u+p+o],_=r[u+p+o],v=d*g-f*_;_=d*_+f*g,g=v,n[u+p]=m+g,r[u+p]=h+_,n[u+p+o]=m-g,r[u+p+o]=h-_,p!==s&&(v=c*d-l*f,f=c*f+l*d,d=v)}},x.prototype.guessLen13b=function(e,t){var n=Math.max(t,e)|1,r=n&1,i=0;for(n=n/2|0;n;n>>>=1)i++;return 1<<i+1+r},x.prototype.conjugate=function(e,t,n){if(!(n<=1))for(var r=0;r<n/2;r++){var i=e[r];e[r]=e[n-r-1],e[n-r-1]=i,i=t[r],t[r]=-t[n-r-1],t[n-r-1]=-i}},x.prototype.normalize13b=function(e,t){for(var n=0,r=0;r<t/2;r++){var i=Math.round(e[2*r+1]/t)*8192+Math.round(e[2*r]/t)+n;e[r]=i&67108863,n=i<67108864?0:i/67108864|0}return e},x.prototype.convert13b=function(e,t,r,i){for(var a=0,o=0;o<t;o++)a+=e[o]|0,r[2*o]=a&8191,a>>>=13,r[2*o+1]=a&8191,a>>>=13;for(o=2*t;o<i;++o)r[o]=0;n(a===0),n((a&-8192)==0)},x.prototype.stub=function(e){for(var t=Array(e),n=0;n<e;n++)t[n]=0;return t},x.prototype.mulp=function(e,t,n){var r=2*this.guessLen13b(e.length,t.length),i=this.makeRBT(r),a=this.stub(r),o=Array(r),s=Array(r),c=Array(r),l=Array(r),u=Array(r),d=Array(r),f=n.words;f.length=r,this.convert13b(e.words,e.length,o,r),this.convert13b(t.words,t.length,l,r),this.transform(o,a,s,c,r,i),this.transform(l,a,u,d,r,i);for(var p=0;p<r;p++){var m=s[p]*u[p]-c[p]*d[p];c[p]=s[p]*d[p]+c[p]*u[p],s[p]=m}return this.conjugate(s,c,r),this.transform(s,c,f,a,r,i),this.conjugate(f,a,r),this.normalize13b(f,r),n.negative=e.negative^t.negative,n.length=e.length+t.length,n._strip()},i.prototype.mul=function(e){var t=new i(null);return t.words=Array(this.length+e.length),this.mulTo(e,t)},i.prototype.mulf=function(e){var t=new i(null);return t.words=Array(this.length+e.length),b(this,e,t)},i.prototype.imul=function(e){return this.clone().mulTo(e,this)},i.prototype.imuln=function(e){var t=e<0;t&&(e=-e),n(typeof e==`number`),n(e<67108864);for(var r=0,i=0;i<this.length;i++){var a=(this.words[i]|0)*e,o=(a&67108863)+(r&67108863);r>>=26,r+=a/67108864|0,r+=o>>>26,this.words[i]=o&67108863}return r!==0&&(this.words[i]=r,this.length++),this.length=e===0?1:this.length,t?this.ineg():this},i.prototype.muln=function(e){return this.clone().imuln(e)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(e){var t=g(e);if(t.length===0)return new i(1);for(var n=this,r=0;r<t.length&&t[r]===0;r++,n=n.sqr());if(++r<t.length)for(var a=n.sqr();r<t.length;r++,a=a.sqr())t[r]!==0&&(n=n.mul(a));return n},i.prototype.iushln=function(e){n(typeof e==`number`&&e>=0);var t=e%26,r=(e-t)/26,i=67108863>>>26-t<<26-t,a;if(t!==0){var o=0;for(a=0;a<this.length;a++){var s=this.words[a]&i,c=(this.words[a]|0)-s<<t;this.words[a]=c|o,o=s>>>26-t}o&&(this.words[a]=o,this.length++)}if(r!==0){for(a=this.length-1;a>=0;a--)this.words[a+r]=this.words[a];for(a=0;a<r;a++)this.words[a]=0;this.length+=r}return this._strip()},i.prototype.ishln=function(e){return n(this.negative===0),this.iushln(e)},i.prototype.iushrn=function(e,t,r){n(typeof e==`number`&&e>=0);var i=t?(t-t%26)/26:0,a=e%26,o=Math.min((e-a)/26,this.length),s=67108863^67108863>>>a<<a,c=r;if(i-=o,i=Math.max(0,i),c){for(var l=0;l<o;l++)c.words[l]=this.words[l];c.length=o}if(o!==0)if(this.length>o)for(this.length-=o,l=0;l<this.length;l++)this.words[l]=this.words[l+o];else this.words[0]=0,this.length=1;var u=0;for(l=this.length-1;l>=0&&(u!==0||l>=i);l--){var d=this.words[l]|0;this.words[l]=u<<26-a|d>>>a,u=d&s}return c&&u!==0&&(c.words[c.length++]=u),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},i.prototype.ishrn=function(e,t,r){return n(this.negative===0),this.iushrn(e,t,r)},i.prototype.shln=function(e){return this.clone().ishln(e)},i.prototype.ushln=function(e){return this.clone().iushln(e)},i.prototype.shrn=function(e){return this.clone().ishrn(e)},i.prototype.ushrn=function(e){return this.clone().iushrn(e)},i.prototype.testn=function(e){n(typeof e==`number`&&e>=0);var t=e%26,r=(e-t)/26,i=1<<t;return this.length<=r?!1:!!(this.words[r]&i)},i.prototype.imaskn=function(e){n(typeof e==`number`&&e>=0);var t=e%26,r=(e-t)/26;if(n(this.negative===0,`imaskn works only with positive numbers`),this.length<=r)return this;if(t!==0&&r++,this.length=Math.min(r,this.length),t!==0){var i=67108863^67108863>>>t<<t;this.words[this.length-1]&=i}return this.length===0&&(this.words[0]=0,this.length=1),this._strip()},i.prototype.maskn=function(e){return this.clone().imaskn(e)},i.prototype.iaddn=function(e){return n(typeof e==`number`),n(e<67108864),e<0?this.isubn(-e):this.negative===0?this._iaddn(e):this.length===1&&(this.words[0]|0)<=e?(this.words[0]=e-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(e),this.negative=1,this)},i.prototype._iaddn=function(e){this.words[0]+=e;for(var t=0;t<this.length&&this.words[t]>=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},i.prototype.isubn=function(e){if(n(typeof e==`number`),n(e<67108864),e<0)return this.iaddn(-e);if(this.negative!==0)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t<this.length&&this.words[t]<0;t++)this.words[t]+=67108864,--this.words[t+1];return this._strip()},i.prototype.addn=function(e){return this.clone().iaddn(e)},i.prototype.subn=function(e){return this.clone().isubn(e)},i.prototype.iabs=function(){return this.negative=0,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(e,t,r){var i=e.length+r,a;this._expand(i);var o,s=0;for(a=0;a<e.length;a++){o=(this.words[a+r]|0)+s;var c=(e.words[a]|0)*t;o-=c&67108863,s=(o>>26)-(c/67108864|0),this.words[a+r]=o&67108863}for(;a<this.length-r;a++)o=(this.words[a+r]|0)+s,s=o>>26,this.words[a+r]=o&67108863;if(s===0)return this._strip();for(n(s===-1),s=0,a=0;a<this.length;a++)o=-(this.words[a]|0)+s,s=o>>26,this.words[a]=o&67108863;return this.negative=1,this._strip()},i.prototype._wordDiv=function(e,t){var n=this.length-e.length,r=this.clone(),a=e,o=a.words[a.length-1]|0;n=26-this._countBits(o),n!==0&&(a=a.ushln(n),r.iushln(n),o=a.words[a.length-1]|0);var s=r.length-a.length,c;if(t!==`mod`){c=new i(null),c.length=s+1,c.words=Array(c.length);for(var l=0;l<c.length;l++)c.words[l]=0}var u=r.clone()._ishlnsubmul(a,1,s);u.negative===0&&(r=u,c&&(c.words[s]=1));for(var d=s-1;d>=0;d--){var f=(r.words[a.length+d]|0)*67108864+(r.words[a.length+d-1]|0);for(f=Math.min(f/o|0,67108863),r._ishlnsubmul(a,f,d);r.negative!==0;)f--,r.negative=0,r._ishlnsubmul(a,1,d),r.isZero()||(r.negative^=1);c&&(c.words[d]=f)}return c&&c._strip(),r._strip(),t!==`div`&&n!==0&&r.iushrn(n),{div:c||null,mod:r}},i.prototype.divmod=function(e,t,r){if(n(!e.isZero()),this.isZero())return{div:new i(0),mod:new i(0)};var a,o,s;return this.negative!==0&&e.negative===0?(s=this.neg().divmod(e,t),t!==`mod`&&(a=s.div.neg()),t!==`div`&&(o=s.mod.neg(),r&&o.negative!==0&&o.iadd(e)),{div:a,mod:o}):this.negative===0&&e.negative!==0?(s=this.divmod(e.neg(),t),t!==`mod`&&(a=s.div.neg()),{div:a,mod:s.mod}):(this.negative&e.negative)===0?e.length>this.length||this.cmp(e)<0?{div:new i(0),mod:this}:e.length===1?t===`div`?{div:this.divn(e.words[0]),mod:null}:t===`mod`?{div:null,mod:new i(this.modrn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new i(this.modrn(e.words[0]))}:this._wordDiv(e,t):(s=this.neg().divmod(e.neg(),t),t!==`div`&&(o=s.mod.neg(),r&&o.negative!==0&&o.isub(e)),{div:s.div,mod:o})},i.prototype.div=function(e){return this.divmod(e,`div`,!1).div},i.prototype.mod=function(e){return this.divmod(e,`mod`,!1).mod},i.prototype.umod=function(e){return this.divmod(e,`mod`,!0).mod},i.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var n=t.div.negative===0?t.mod:t.mod.isub(e),r=e.ushrn(1),i=e.andln(1),a=n.cmp(r);return a<0||i===1&&a===0?t.div:t.div.negative===0?t.div.iaddn(1):t.div.isubn(1)},i.prototype.modrn=function(e){var t=e<0;t&&(e=-e),n(e<=67108863);for(var r=(1<<26)%e,i=0,a=this.length-1;a>=0;a--)i=(r*i+(this.words[a]|0))%e;return t?-i:i},i.prototype.modn=function(e){return this.modrn(e)},i.prototype.idivn=function(e){var t=e<0;t&&(e=-e),n(e<=67108863);for(var r=0,i=this.length-1;i>=0;i--){var a=(this.words[i]|0)+r*67108864;this.words[i]=a/e|0,r=a%e}return this._strip(),t?this.ineg():this},i.prototype.divn=function(e){return this.clone().idivn(e)},i.prototype.egcd=function(e){n(e.negative===0),n(!e.isZero());var t=this,r=e.clone();t=t.negative===0?t.clone():t.umod(e);for(var a=new i(1),o=new i(0),s=new i(0),c=new i(1),l=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++l;for(var u=r.clone(),d=t.clone();!t.isZero();){for(var f=0,p=1;(t.words[0]&p)===0&&f<26;++f,p<<=1);if(f>0)for(t.iushrn(f);f-- >0;)(a.isOdd()||o.isOdd())&&(a.iadd(u),o.isub(d)),a.iushrn(1),o.iushrn(1);for(var m=0,h=1;(r.words[0]&h)===0&&m<26;++m,h<<=1);if(m>0)for(r.iushrn(m);m-- >0;)(s.isOdd()||c.isOdd())&&(s.iadd(u),c.isub(d)),s.iushrn(1),c.iushrn(1);t.cmp(r)>=0?(t.isub(r),a.isub(s),o.isub(c)):(r.isub(t),s.isub(a),c.isub(o))}return{a:s,b:c,gcd:r.iushln(l)}},i.prototype._invmp=function(e){n(e.negative===0),n(!e.isZero());var t=this,r=e.clone();t=t.negative===0?t.clone():t.umod(e);for(var a=new i(1),o=new i(0),s=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var c=0,l=1;(t.words[0]&l)===0&&c<26;++c,l<<=1);if(c>0)for(t.iushrn(c);c-- >0;)a.isOdd()&&a.iadd(s),a.iushrn(1);for(var u=0,d=1;(r.words[0]&d)===0&&u<26;++u,d<<=1);if(u>0)for(r.iushrn(u);u-- >0;)o.isOdd()&&o.iadd(s),o.iushrn(1);t.cmp(r)>=0?(t.isub(r),a.isub(o)):(r.isub(t),o.isub(a))}var f=t.cmpn(1)===0?a:o;return f.cmpn(0)<0&&f.iadd(e),f},i.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),n=e.clone();t.negative=0,n.negative=0;for(var r=0;t.isEven()&&n.isEven();r++)t.iushrn(1),n.iushrn(1);do{for(;t.isEven();)t.iushrn(1);for(;n.isEven();)n.iushrn(1);var i=t.cmp(n);if(i<0){var a=t;t=n,n=a}else if(i===0||n.cmpn(1)===0)break;t.isub(n)}while(!0);return n.iushln(r)},i.prototype.invm=function(e){return this.egcd(e).a.umod(e)},i.prototype.isEven=function(){return(this.words[0]&1)==0},i.prototype.isOdd=function(){return(this.words[0]&1)==1},i.prototype.andln=function(e){return this.words[0]&e},i.prototype.bincn=function(e){n(typeof e==`number`);var t=e%26,r=(e-t)/26,i=1<<t;if(this.length<=r)return this._expand(r+1),this.words[r]|=i,this;for(var a=i,o=r;a!==0&&o<this.length;o++){var s=this.words[o]|0;s+=a,a=s>>>26,s&=67108863,this.words[o]=s}return a!==0&&(this.words[o]=a,this.length++),this},i.prototype.isZero=function(){return this.length===1&&this.words[0]===0},i.prototype.cmpn=function(e){var t=e<0;if(this.negative!==0&&!t)return-1;if(this.negative===0&&t)return 1;this._strip();var r;if(this.length>1)r=1;else{t&&(e=-e),n(e<=67108863,`Number is too big`);var i=this.words[0]|0;r=i===e?0:i<e?-1:1}return this.negative===0?r:-r|0},i.prototype.cmp=function(e){if(this.negative!==0&&e.negative===0)return-1;if(this.negative===0&&e.negative!==0)return 1;var t=this.ucmp(e);return this.negative===0?t:-t|0},i.prototype.ucmp=function(e){if(this.length>e.length)return 1;if(this.length<e.length)return-1;for(var t=0,n=this.length-1;n>=0;n--){var r=this.words[n]|0,i=e.words[n]|0;if(r!==i){r<i?t=-1:r>i&&(t=1);break}}return t},i.prototype.gtn=function(e){return this.cmpn(e)===1},i.prototype.gt=function(e){return this.cmp(e)===1},i.prototype.gten=function(e){return this.cmpn(e)>=0},i.prototype.gte=function(e){return this.cmp(e)>=0},i.prototype.ltn=function(e){return this.cmpn(e)===-1},i.prototype.lt=function(e){return this.cmp(e)===-1},i.prototype.lten=function(e){return this.cmpn(e)<=0},i.prototype.lte=function(e){return this.cmp(e)<=0},i.prototype.eqn=function(e){return this.cmpn(e)===0},i.prototype.eq=function(e){return this.cmp(e)===0},i.red=function(e){return new D(e)},i.prototype.toRed=function(e){return n(!this.red,`Already a number in reduction context`),n(this.negative===0,`red works only with positives`),e.convertTo(this)._forceRed(e)},i.prototype.fromRed=function(){return n(this.red,`fromRed works only with numbers in reduction context`),this.red.convertFrom(this)},i.prototype._forceRed=function(e){return this.red=e,this},i.prototype.forceRed=function(e){return n(!this.red,`Already a number in reduction context`),this._forceRed(e)},i.prototype.redAdd=function(e){return n(this.red,`redAdd works only with red numbers`),this.red.add(this,e)},i.prototype.redIAdd=function(e){return n(this.red,`redIAdd works only with red numbers`),this.red.iadd(this,e)},i.prototype.redSub=function(e){return n(this.red,`redSub works only with red numbers`),this.red.sub(this,e)},i.prototype.redISub=function(e){return n(this.red,`redISub works only with red numbers`),this.red.isub(this,e)},i.prototype.redShl=function(e){return n(this.red,`redShl works only with red numbers`),this.red.shl(this,e)},i.prototype.redMul=function(e){return n(this.red,`redMul works only with red numbers`),this.red._verify2(this,e),this.red.mul(this,e)},i.prototype.redIMul=function(e){return n(this.red,`redMul works only with red numbers`),this.red._verify2(this,e),this.red.imul(this,e)},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(e){return n(this.red&&!e.red,`redPow(normalNum)`),this.red._verify1(this),this.red.pow(this,e)};var ee={k256:null,p224:null,p192:null,p25519:null};function S(e,t){this.name=e,this.p=new i(t,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}S.prototype._tmp=function(){var e=new i(null);return e.words=Array(Math.ceil(this.n/13)),e},S.prototype.ireduce=function(e){var t=e,n;do this.split(t,this.tmp),t=this.imulK(t),t=t.iadd(this.tmp),n=t.bitLength();while(n>this.n);var r=n<this.n?-1:t.ucmp(this.p);return r===0?(t.words[0]=0,t.length=1):r>0?t.isub(this.p):t.strip===void 0?t._strip():t.strip(),t},S.prototype.split=function(e,t){e.iushrn(this.n,0,t)},S.prototype.imulK=function(e){return e.imul(this.k)};function C(){S.call(this,`k256`,`ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f`)}r(C,S),C.prototype.split=function(e,t){for(var n=4194303,r=Math.min(e.length,9),i=0;i<r;i++)t.words[i]=e.words[i];if(t.length=r,e.length<=9){e.words[0]=0,e.length=1;return}var a=e.words[9];for(t.words[t.length++]=a&n,i=10;i<e.length;i++){var o=e.words[i]|0;e.words[i-10]=(o&n)<<4|a>>>22,a=o}a>>>=22,e.words[i-10]=a,a===0&&e.length>10?e.length-=10:e.length-=9},C.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,n=0;n<e.length;n++){var r=e.words[n]|0;t+=r*977,e.words[n]=t&67108863,t=r*64+(t/67108864|0)}return e.words[e.length-1]===0&&(e.length--,e.words[e.length-1]===0&&e.length--),e};function w(){S.call(this,`p224`,`ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001`)}r(w,S);function T(){S.call(this,`p192`,`ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff`)}r(T,S);function E(){S.call(this,`25519`,`7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed`)}r(E,S),E.prototype.imulK=function(e){for(var t=0,n=0;n<e.length;n++){var r=(e.words[n]|0)*19+t,i=r&67108863;r>>>=26,e.words[n]=i,t=r}return t!==0&&(e.words[e.length++]=t),e},i._prime=function(e){if(ee[e])return ee[e];var t;if(e===`k256`)t=new C;else if(e===`p224`)t=new w;else if(e===`p192`)t=new T;else if(e===`p25519`)t=new E;else throw Error(`Unknown prime `+e);return ee[e]=t,t};function D(e){if(typeof e==`string`){var t=i._prime(e);this.m=t.p,this.prime=t}else n(e.gtn(1),`modulus must be greater than 1`),this.m=e,this.prime=null}D.prototype._verify1=function(e){n(e.negative===0,`red works only with positives`),n(e.red,`red works only with red numbers`)},D.prototype._verify2=function(e,t){n((e.negative|t.negative)===0,`red works only with positives`),n(e.red&&e.red===t.red,`red works only with red numbers`)},D.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):(u(e,e.umod(this.m)._forceRed(this)),e)},D.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},D.prototype.add=function(e,t){this._verify2(e,t);var n=e.add(t);return n.cmp(this.m)>=0&&n.isub(this.m),n._forceRed(this)},D.prototype.iadd=function(e,t){this._verify2(e,t);var n=e.iadd(t);return n.cmp(this.m)>=0&&n.isub(this.m),n},D.prototype.sub=function(e,t){this._verify2(e,t);var n=e.sub(t);return n.cmpn(0)<0&&n.iadd(this.m),n._forceRed(this)},D.prototype.isub=function(e,t){this._verify2(e,t);var n=e.isub(t);return n.cmpn(0)<0&&n.iadd(this.m),n},D.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},D.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},D.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},D.prototype.isqr=function(e){return this.imul(e,e.clone())},D.prototype.sqr=function(e){return this.mul(e,e)},D.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(n(t%2==1),t===3){var r=this.m.add(new i(1)).iushrn(2);return this.pow(e,r)}for(var a=this.m.subn(1),o=0;!a.isZero()&&a.andln(1)===0;)o++,a.iushrn(1);n(!a.isZero());var s=new i(1).toRed(this),c=s.redNeg(),l=this.m.subn(1).iushrn(1),u=this.m.bitLength();for(u=new i(2*u*u).toRed(this);this.pow(u,l).cmp(c)!==0;)u.redIAdd(c);for(var d=this.pow(u,a),f=this.pow(e,a.addn(1).iushrn(1)),p=this.pow(e,a),m=o;p.cmp(s)!==0;){for(var h=p,g=0;h.cmp(s)!==0;g++)h=h.redSqr();n(g<m);var _=this.pow(d,new i(1).iushln(m-g-1));f=f.redMul(_),d=_.redSqr(),p=p.redMul(d),m=g}return f},D.prototype.invm=function(e){var t=e._invmp(this.m);return t.negative===0?this.imod(t):(t.negative=0,this.imod(t).redNeg())},D.prototype.pow=function(e,t){if(t.isZero())return new i(1).toRed(this);if(t.cmpn(1)===0)return e.clone();var n=4,r=Array(1<<n);r[0]=new i(1).toRed(this),r[1]=e;for(var a=2;a<r.length;a++)r[a]=this.mul(r[a-1],e);var o=r[0],s=0,c=0,l=t.bitLength()%26;for(l===0&&(l=26),a=t.length-1;a>=0;a--){for(var u=t.words[a],d=l-1;d>=0;d--){var f=u>>d&1;if(o!==r[0]&&(o=this.sqr(o)),f===0&&s===0){c=0;continue}s<<=1,s|=f,c++,!(c!==n&&(a!==0||d!==0))&&(o=this.mul(o,r[s]),c=0,s=0)}l=26}return o},D.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},D.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},i.mont=function(e){return new O(e)};function O(e){D.call(this,e),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)}r(O,D),O.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},O.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},O.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var n=e.imul(t),r=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=n.isub(r).iushrn(this.shift),a=i;return i.cmp(this.m)>=0?a=i.isub(this.m):i.cmpn(0)<0&&(a=i.iadd(this.m)),a._forceRed(this)},O.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new i(0)._forceRed(this);var n=e.mul(t),r=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),a=n.isub(r).iushrn(this.shift),o=a;return a.cmp(this.m)>=0?o=a.isub(this.m):a.cmpn(0)<0&&(o=a.iadd(this.m)),o._forceRed(this)},O.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}})(t===void 0||t,e)})),ar=i(((e,t)=>{var n=it(),r=n.Buffer;function i(e,t){for(var n in e)t[n]=e[n]}r.from&&r.alloc&&r.allocUnsafe&&r.allocUnsafeSlow?t.exports=n:(i(n,e),e.Buffer=a);function a(e,t,n){return r(e,t,n)}a.prototype=Object.create(r.prototype),i(r,a),a.from=function(e,t,n){if(typeof e==`number`)throw TypeError(`Argument must not be a number`);return r(e,t,n)},a.alloc=function(e,t,n){if(typeof e!=`number`)throw TypeError(`Argument must be a number`);var i=r(e);return t===void 0?i.fill(0):typeof n==`string`?i.fill(t,n):i.fill(t),i},a.allocUnsafe=function(e){if(typeof e!=`number`)throw TypeError(`Argument must be a number`);return r(e)},a.allocUnsafeSlow=function(e){if(typeof e!=`number`)throw TypeError(`Argument must be a number`);return n.SlowBuffer(e)}})),or=i(((e,t)=>{var n=ar().Buffer;function r(e){if(e.length>=255)throw TypeError(`Alphabet too long`);for(var t=new Uint8Array(256),r=0;r<t.length;r++)t[r]=255;for(var i=0;i<e.length;i++){var a=e.charAt(i),o=a.charCodeAt(0);if(t[o]!==255)throw TypeError(a+` is ambiguous`);t[o]=i}var s=e.length,c=e.charAt(0),l=Math.log(s)/Math.log(256),u=Math.log(256)/Math.log(s);function d(t){if((Array.isArray(t)||t instanceof Uint8Array)&&(t=n.from(t)),!n.isBuffer(t))throw TypeError(`Expected Buffer`);if(t.length===0)return``;for(var r=0,i=0,a=0,o=t.length;a!==o&&t[a]===0;)a++,r++;for(var l=(o-a)*u+1>>>0,d=new Uint8Array(l);a!==o;){for(var f=t[a],p=0,m=l-1;(f!==0||p<i)&&m!==-1;m--,p++)f+=256*d[m]>>>0,d[m]=f%s>>>0,f=f/s>>>0;if(f!==0)throw Error(`Non-zero carry`);i=p,a++}for(var h=l-i;h!==l&&d[h]===0;)h++;for(var g=c.repeat(r);h<l;++h)g+=e.charAt(d[h]);return g}function f(e){if(typeof e!=`string`)throw TypeError(`Expected String`);if(e.length===0)return n.alloc(0);for(var r=0,i=0,a=0;e[r]===c;)i++,r++;for(var o=(e.length-r)*l+1>>>0,u=new Uint8Array(o);r<e.length;){var d=e.charCodeAt(r);if(d>255)return;var f=t[d];if(f===255)return;for(var p=0,m=o-1;(f!==0||p<a)&&m!==-1;m--,p++)f+=s*u[m]>>>0,u[m]=f%256>>>0,f=f/256>>>0;if(f!==0)throw Error(`Non-zero carry`);a=p,r++}for(var h=o-a;h!==o&&u[h]===0;)h++;var g=n.allocUnsafe(i+(o-h));g.fill(0,0,i);for(var _=i;h!==o;)g[_++]=u[h++];return g}function p(e){var t=f(e);if(t)return t;throw Error(`Non-base`+s+` character`)}return{encode:d,decodeUnsafe:f,decode:p}}t.exports=r})),sr=i(((e,t)=>{t.exports=or()(`123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz`)})),cr=i(((e,t)=>{var n=ar().Buffer;function r(e){if(e.length>=255)throw TypeError(`Alphabet too long`);for(var t=new Uint8Array(256),r=0;r<t.length;r++)t[r]=255;for(var i=0;i<e.length;i++){var a=e.charAt(i),o=a.charCodeAt(0);if(t[o]!==255)throw TypeError(a+` is ambiguous`);t[o]=i}var s=e.length,c=e.charAt(0),l=Math.log(s)/Math.log(256),u=Math.log(256)/Math.log(s);function d(t){if((Array.isArray(t)||t instanceof Uint8Array)&&(t=n.from(t)),!n.isBuffer(t))throw TypeError(`Expected Buffer`);if(t.length===0)return``;for(var r=0,i=0,a=0,o=t.length;a!==o&&t[a]===0;)a++,r++;for(var l=(o-a)*u+1>>>0,d=new Uint8Array(l);a!==o;){for(var f=t[a],p=0,m=l-1;(f!==0||p<i)&&m!==-1;m--,p++)f+=256*d[m]>>>0,d[m]=f%s>>>0,f=f/s>>>0;if(f!==0)throw Error(`Non-zero carry`);i=p,a++}for(var h=l-i;h!==l&&d[h]===0;)h++;for(var g=c.repeat(r);h<l;++h)g+=e.charAt(d[h]);return g}function f(e){if(typeof e!=`string`)throw TypeError(`Expected String`);if(e.length===0)return n.alloc(0);for(var r=0,i=0,a=0;e[r]===c;)i++,r++;for(var o=(e.length-r)*l+1>>>0,u=new Uint8Array(o);r<e.length;){var d=e.charCodeAt(r);if(d>255)return;var f=t[d];if(f===255)return;for(var p=0,m=o-1;(f!==0||p<a)&&m!==-1;m--,p++)f+=s*u[m]>>>0,u[m]=f%256>>>0,f=f/256>>>0;if(f!==0)throw Error(`Non-zero carry`);a=p,r++}for(var h=o-a;h!==o&&u[h]===0;)h++;var g=n.allocUnsafe(i+(o-h));g.fill(0,0,i);for(var _=i;h!==o;)g[_++]=u[h++];return g}function p(e){var t=f(e);if(t)return t;throw Error(`Non-base`+s+` character`)}return{encode:d,decodeUnsafe:f,decode:p}}t.exports=r})),lr=i(((e,t)=>{t.exports=cr()(`123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz`)})),ur=r({TextDecoder:()=>yr,TextEncoder:()=>br});function dr(e,t,n){return t<=e&&e<=n}function fr(e){if(e===void 0)return{};if(e===Object(e))return e;throw TypeError(`Could not convert argument to dictionary`)}function pr(e){for(var t=String(e),n=t.length,r=0,i=[];r<n;){var a=t.charCodeAt(r);if(a<55296||a>57343)i.push(a);else if(56320<=a&&a<=57343)i.push(65533);else if(55296<=a&&a<=56319)if(r===n-1)i.push(65533);else{var o=e.charCodeAt(r+1);if(56320<=o&&o<=57343){var s=a&1023,c=o&1023;i.push(65536+(s<<10)+c),r+=1}else i.push(65533)}r+=1}return i}function mr(e){for(var t=``,n=0;n<e.length;++n){var r=e[n];r<=65535?t+=String.fromCharCode(r):(r-=65536,t+=String.fromCharCode((r>>10)+55296,(r&1023)+56320))}return t}function hr(e){this.tokens=[].slice.call(e)}function gr(e,t){if(e)throw TypeError(`Decoder error`);return t||65533}function _r(){}function vr(){}function yr(e,t){if(!(this instanceof yr))return new yr(e,t);if(e=e===void 0?Tr:String(e).toLowerCase(),e!==Tr)throw Error(`Encoding not supported. Only utf-8 is supported`);t=fr(t),this._streaming=!1,this._BOMseen=!1,this._decoder=null,this._fatal=!!t.fatal,this._ignoreBOM=!!t.ignoreBOM,Object.defineProperty(this,"encoding",{value:`utf-8`}),Object.defineProperty(this,"fatal",{value:this._fatal}),Object.defineProperty(this,"ignoreBOM",{value:this._ignoreBOM})}function br(e,t){if(!(this instanceof br))return new br(e,t);if(e=e===void 0?Tr:String(e).toLowerCase(),e!==Tr)throw Error(`Encoding not supported. Only utf-8 is supported`);t=fr(t),this._streaming=!1,this._encoder=null,this._options={fatal:!!t.fatal},Object.defineProperty(this,"encoding",{value:`utf-8`})}function xr(e){var t=e.fatal,n=0,r=0,i=0,a=128,o=191;this.handler=function(e,s){if(s===Cr&&i!==0)return i=0,gr(t);if(s===Cr)return wr;if(i===0){if(dr(s,0,127))return s;if(dr(s,194,223))i=1,n=s-192;else if(dr(s,224,239))s===224&&(a=160),s===237&&(o=159),i=2,n=s-224;else if(dr(s,240,244))s===240&&(a=144),s===244&&(o=143),i=3,n=s-240;else return gr(t);return n<<=6*i,null}if(!dr(s,a,o))return n=i=r=0,a=128,o=191,e.prepend(s),gr(t);if(a=128,o=191,r+=1,n+=s-128<<6*(i-r),r!==i)return null;var c=n;return n=i=r=0,c}}function Sr(e){e.fatal,this.handler=function(e,t){if(t===Cr)return wr;if(dr(t,0,127))return t;var n,r;dr(t,128,2047)?(n=1,r=192):dr(t,2048,65535)?(n=2,r=224):dr(t,65536,1114111)&&(n=3,r=240);for(var i=[(t>>6*n)+r];n>0;){var a=t>>6*(n-1);i.push(128|a&63),--n}return i}}var Cr,wr,Tr,Er=t((()=>{Cr=-1,hr.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():Cr},prepend:function(e){if(Array.isArray(e))for(var t=e;t.length;)this.tokens.unshift(t.pop());else this.tokens.unshift(e)},push:function(e){if(Array.isArray(e))for(var t=e;t.length;)this.tokens.push(t.shift());else this.tokens.push(e)}},wr=-1,_r.prototype={handler:function(e,t){}},vr.prototype={handler:function(e,t){}},Tr=`utf-8`,yr.prototype={decode:function(e,t){var n=typeof e==`object`&&e instanceof ArrayBuffer?new Uint8Array(e):typeof e==`object`&&`buffer`in e&&e.buffer instanceof ArrayBuffer?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array;t=fr(t),this._streaming||(this._decoder=new xr({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!t.stream;for(var r=new hr(n),i=[],a;!r.endOfStream()&&(a=this._decoder.handler(r,r.read()),a!==wr);)a!==null&&(Array.isArray(a)?i.push.apply(i,a):i.push(a));if(!this._streaming){do{if(a=this._decoder.handler(r,r.read()),a===wr)break;if(a===null)continue;Array.isArray(a)?i.push.apply(i,a):i.push(a)}while(!r.endOfStream());this._decoder=null}return i.length&&[`utf-8`].indexOf(this.encoding)!==-1&&!this._ignoreBOM&&!this._BOMseen&&(i[0]===65279?(this._BOMseen=!0,i.shift()):this._BOMseen=!0),mr(i)}},br.prototype={encode:function(e,t){e=e?String(e):``,t=fr(t),this._streaming||(this._encoder=new Sr(this._options)),this._streaming=!!t.stream;for(var n=[],r=new hr(pr(e)),i;!r.endOfStream()&&(i=this._encoder.handler(r,r.read()),i!==wr);)Array.isArray(i)?n.push.apply(n,i):n.push(i);if(!this._streaming){for(;i=this._encoder.handler(r,r.read()),i!==wr;)Array.isArray(i)?n.push.apply(n,i):n.push(i);this._encoder=null}return new Uint8Array(n)}}})),Dr=i((t=>{var n=t&&t.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),r=t&&t.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),i=t&&t.__decorate||function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},a=t&&t.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var i in e)i!==`default`&&Object.hasOwnProperty.call(e,i)&&n(t,e,i);return r(t,e),t},o=t&&t.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.deserializeUnchecked=t.deserialize=t.serialize=t.BinaryReader=t.BinaryWriter=t.BorshError=t.baseDecode=t.baseEncode=void 0;var s=o(ir()),c=o(lr()),l=a((Er(),e(ur))),u=new(typeof TextDecoder==`function`?TextDecoder:l.TextDecoder)(`utf-8`,{fatal:!0});function d(e){return typeof e==`string`&&(e=Buffer.from(e,`utf8`)),c.default.encode(Buffer.from(e))}t.baseEncode=d;function f(e){return Buffer.from(c.default.decode(e))}t.baseDecode=f;var p=1024,m=class extends Error{constructor(e){super(e),this.fieldPath=[],this.originalMessage=e}addToFieldPath(e){this.fieldPath.splice(0,0,e),this.message=this.originalMessage+`: `+this.fieldPath.join(`.`)}};t.BorshError=m;var h=class{constructor(){this.buf=Buffer.alloc(p),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Buffer.concat([this.buf,Buffer.alloc(p)]))}writeU8(e){this.maybeResize(),this.buf.writeUInt8(e,this.length),this.length+=1}writeU16(e){this.maybeResize(),this.buf.writeUInt16LE(e,this.length),this.length+=2}writeU32(e){this.maybeResize(),this.buf.writeUInt32LE(e,this.length),this.length+=4}writeU64(e){this.maybeResize(),this.writeBuffer(Buffer.from(new s.default(e).toArray(`le`,8)))}writeU128(e){this.maybeResize(),this.writeBuffer(Buffer.from(new s.default(e).toArray(`le`,16)))}writeU256(e){this.maybeResize(),this.writeBuffer(Buffer.from(new s.default(e).toArray(`le`,32)))}writeU512(e){this.maybeResize(),this.writeBuffer(Buffer.from(new s.default(e).toArray(`le`,64)))}writeBuffer(e){this.buf=Buffer.concat([Buffer.from(this.buf.subarray(0,this.length)),e,Buffer.alloc(p)]),this.length+=e.length}writeString(e){this.maybeResize();let t=Buffer.from(e,`utf8`);this.writeU32(t.length),this.writeBuffer(t)}writeFixedArray(e){this.writeBuffer(Buffer.from(e))}writeArray(e,t){this.maybeResize(),this.writeU32(e.length);for(let n of e)this.maybeResize(),t(n)}toArray(){return this.buf.subarray(0,this.length)}};t.BinaryWriter=h;function g(e,t,n){let r=n.value;n.value=function(...e){try{return r.apply(this,e)}catch(e){if(e instanceof RangeError){let t=e.code;if([`ERR_BUFFER_OUT_OF_BOUNDS`,`ERR_OUT_OF_RANGE`].indexOf(t)>=0)throw new m(`Reached the end of buffer when deserializing`)}throw e}}}var _=class{constructor(e){this.buf=e,this.offset=0}readU8(){let e=this.buf.readUInt8(this.offset);return this.offset+=1,e}readU16(){let e=this.buf.readUInt16LE(this.offset);return this.offset+=2,e}readU32(){let e=this.buf.readUInt32LE(this.offset);return this.offset+=4,e}readU64(){let e=this.readBuffer(8);return new s.default(e,`le`)}readU128(){let e=this.readBuffer(16);return new s.default(e,`le`)}readU256(){let e=this.readBuffer(32);return new s.default(e,`le`)}readU512(){let e=this.readBuffer(64);return new s.default(e,`le`)}readBuffer(e){if(this.offset+e>this.buf.length)throw new m(`Expected buffer length ${e} isn't within bounds`);let t=this.buf.slice(this.offset,this.offset+e);return this.offset+=e,t}readString(){let e=this.readU32(),t=this.readBuffer(e);try{return u.decode(t)}catch(e){throw new m(`Error decoding UTF-8 string: ${e}`)}}readFixedArray(e){return new Uint8Array(this.readBuffer(e))}readArray(e){let t=this.readU32(),n=[];for(let r=0;r<t;++r)n.push(e());return n}};i([g],_.prototype,`readU8`,null),i([g],_.prototype,`readU16`,null),i([g],_.prototype,`readU32`,null),i([g],_.prototype,`readU64`,null),i([g],_.prototype,`readU128`,null),i([g],_.prototype,`readU256`,null),i([g],_.prototype,`readU512`,null),i([g],_.prototype,`readString`,null),i([g],_.prototype,`readFixedArray`,null),i([g],_.prototype,`readArray`,null),t.BinaryReader=_;function v(e){return e.charAt(0).toUpperCase()+e.slice(1)}function y(e,t,n,r,i){try{if(typeof r==`string`)i[`write${v(r)}`](n);else if(r instanceof Array)if(typeof r[0]==`number`){if(n.length!==r[0])throw new m(`Expecting byte array of length ${r[0]}, but got ${n.length} bytes`);i.writeFixedArray(n)}else if(r.length===2&&typeof r[1]==`number`){if(n.length!==r[1])throw new m(`Expecting byte array of length ${r[1]}, but got ${n.length} bytes`);for(let t=0;t<r[1];t++)y(e,null,n[t],r[0],i)}else i.writeArray(n,n=>{y(e,t,n,r[0],i)});else if(r.kind!==void 0)switch(r.kind){case`option`:n==null?i.writeU8(0):(i.writeU8(1),y(e,t,n,r.type,i));break;case`map`:i.writeU32(n.size),n.forEach((n,a)=>{y(e,t,a,r.key,i),y(e,t,n,r.value,i)});break;default:throw new m(`FieldType ${r} unrecognized`)}else b(e,n,i)}catch(e){throw e instanceof m&&e.addToFieldPath(t),e}}function b(e,t,n){if(typeof t.borshSerialize==`function`){t.borshSerialize(n);return}let r=e.get(t.constructor);if(!r)throw new m(`Class ${t.constructor.name} is missing in schema`);if(r.kind===`struct`)r.fields.map(([r,i])=>{y(e,r,t[r],i,n)});else if(r.kind===`enum`){let i=t[r.field];for(let a=0;a<r.values.length;++a){let[o,s]=r.values[a];if(o===i){n.writeU8(a),y(e,o,t[o],s,n);break}}}else throw new m(`Unexpected schema kind: ${r.kind} for ${t.constructor.name}`)}function x(e,t,n=h){let r=new n;return b(e,t,r),r.toArray()}t.serialize=x;function ee(e,t,n,r){try{if(typeof n==`string`)return r[`read${v(n)}`]();if(n instanceof Array){if(typeof n[0]==`number`)return r.readFixedArray(n[0]);if(typeof n[1]==`number`){let t=[];for(let i=0;i<n[1];i++)t.push(ee(e,null,n[0],r));return t}else return r.readArray(()=>ee(e,t,n[0],r))}if(n.kind===`option`)return r.readU8()?ee(e,t,n.type,r):void 0;if(n.kind===`map`){let i=new Map,a=r.readU32();for(let o=0;o<a;o++){let a=ee(e,t,n.key,r),o=ee(e,t,n.value,r);i.set(a,o)}return i}return S(e,n,r)}catch(e){throw e instanceof m&&e.addToFieldPath(t),e}}function S(e,t,n){if(typeof t.borshDeserialize==`function`)return t.borshDeserialize(n);let r=e.get(t);if(!r)throw new m(`Class ${t.name} is missing in schema`);if(r.kind===`struct`){let r={};for(let[i,a]of e.get(t).fields)r[i]=ee(e,i,a,n);return new t(r)}if(r.kind===`enum`){let i=n.readU8();if(i>=r.values.length)throw new m(`Enum index: ${i} is out of range`);let[a,o]=r.values[i],s=ee(e,a,o,n);return new t({[a]:s})}throw new m(`Unexpected schema kind: ${r.kind} for ${t.constructor.name}`)}function C(e,t,n,r=_){let i=new r(n),a=S(e,t,i);if(i.offset<n.length)throw new m(`Unexpected ${n.length-i.offset} bytes after deserialized data`);return a}t.deserialize=C;function w(e,t,n,r=_){return S(e,t,new r(n))}t.deserializeUnchecked=w})),Or=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.s16=e.s8=e.nu64be=e.u48be=e.u40be=e.u32be=e.u24be=e.u16be=e.nu64=e.u48=e.u40=e.u32=e.u24=e.u16=e.u8=e.offset=e.greedy=e.Constant=e.UTF8=e.CString=e.Blob=e.Boolean=e.BitField=e.BitStructure=e.VariantLayout=e.Union=e.UnionLayoutDiscriminator=e.UnionDiscriminator=e.Structure=e.Sequence=e.DoubleBE=e.Double=e.FloatBE=e.Float=e.NearInt64BE=e.NearInt64=e.NearUInt64BE=e.NearUInt64=e.IntBE=e.Int=e.UIntBE=e.UInt=e.OffsetLayout=e.GreedyCount=e.ExternalLayout=e.bindConstructorLayout=e.nameWithProperty=e.Layout=e.uint8ArrayToBuffer=e.checkUint8Array=void 0,e.constant=e.utf8=e.cstr=e.blob=e.unionLayoutDiscriminator=e.union=e.seq=e.bits=e.struct=e.f64be=e.f64=e.f32be=e.f32=e.ns64be=e.s48be=e.s40be=e.s32be=e.s24be=e.s16be=e.ns64=e.s48=e.s40=e.s32=e.s24=void 0;var t=it();function n(e){if(!(e instanceof Uint8Array))throw TypeError(`b must be a Uint8Array`)}e.checkUint8Array=n;function r(e){return n(e),t.Buffer.from(e.buffer,e.byteOffset,e.length)}e.uint8ArrayToBuffer=r;var i=class{constructor(e,t){if(!Number.isInteger(e))throw TypeError(`span must be an integer`);this.span=e,this.property=t}makeDestinationObject(){return{}}getSpan(e,t){if(0>this.span)throw RangeError(`indeterminate span`);return this.span}replicate(e){let t=Object.create(this.constructor.prototype);return Object.assign(t,this),t.property=e,t}fromArray(e){}};e.Layout=i;function a(e,t){return t.property?e+`[`+t.property+`]`:e}e.nameWithProperty=a;function o(e,t){if(typeof e!=`function`)throw TypeError(`Class must be constructor`);if(Object.prototype.hasOwnProperty.call(e,`layout_`))throw Error(`Class is already bound to a layout`);if(!(t&&t instanceof i))throw TypeError(`layout must be a Layout`);if(Object.prototype.hasOwnProperty.call(t,`boundConstructor_`))throw Error(`layout is already bound to a constructor`);e.layout_=t,t.boundConstructor_=e,t.makeDestinationObject=(()=>new e),Object.defineProperty(e.prototype,"encode",{value(e,n){return t.encode(this,e,n)},writable:!0}),Object.defineProperty(e,"decode",{value(e,n){return t.decode(e,n)},writable:!0})}e.bindConstructorLayout=o;var s=class extends i{isCount(){throw Error(`ExternalLayout is abstract`)}};e.ExternalLayout=s;var c=class extends s{constructor(e=1,t){if(!Number.isInteger(e)||0>=e)throw TypeError(`elementSpan must be a (positive) integer`);super(-1,t),this.elementSpan=e}isCount(){return!0}decode(e,t=0){n(e);let r=e.length-t;return Math.floor(r/this.elementSpan)}encode(e,t,n){return 0}};e.GreedyCount=c;var l=class extends s{constructor(e,t=0,n){if(!(e instanceof i))throw TypeError(`layout must be a Layout`);if(!Number.isInteger(t))throw TypeError(`offset must be integer or undefined`);super(e.span,n||e.property),this.layout=e,this.offset=t}isCount(){return this.layout instanceof u||this.layout instanceof d}decode(e,t=0){return this.layout.decode(e,t+this.offset)}encode(e,t,n=0){return this.layout.encode(e,t,n+this.offset)}};e.OffsetLayout=l;var u=class extends i{constructor(e,t){if(super(e,t),6<this.span)throw RangeError(`span must not exceed 6 bytes`)}decode(e,t=0){return r(e).readUIntLE(t,this.span)}encode(e,t,n=0){return r(t).writeUIntLE(e,n,this.span),this.span}};e.UInt=u;var d=class extends i{constructor(e,t){if(super(e,t),6<this.span)throw RangeError(`span must not exceed 6 bytes`)}decode(e,t=0){return r(e).readUIntBE(t,this.span)}encode(e,t,n=0){return r(t).writeUIntBE(e,n,this.span),this.span}};e.UIntBE=d;var f=class extends i{constructor(e,t){if(super(e,t),6<this.span)throw RangeError(`span must not exceed 6 bytes`)}decode(e,t=0){return r(e).readIntLE(t,this.span)}encode(e,t,n=0){return r(t).writeIntLE(e,n,this.span),this.span}};e.Int=f;var p=class extends i{constructor(e,t){if(super(e,t),6<this.span)throw RangeError(`span must not exceed 6 bytes`)}decode(e,t=0){return r(e).readIntBE(t,this.span)}encode(e,t,n=0){return r(t).writeIntBE(e,n,this.span),this.span}};e.IntBE=p;var m=2**32;function h(e){let t=Math.floor(e/m);return{hi32:t,lo32:e-t*m}}function g(e,t){return e*m+t}var _=class extends i{constructor(e){super(8,e)}decode(e,t=0){let n=r(e),i=n.readUInt32LE(t);return g(n.readUInt32LE(t+4),i)}encode(e,t,n=0){let i=h(e),a=r(t);return a.writeUInt32LE(i.lo32,n),a.writeUInt32LE(i.hi32,n+4),8}};e.NearUInt64=_;var v=class extends i{constructor(e){super(8,e)}decode(e,t=0){let n=r(e);return g(n.readUInt32BE(t),n.readUInt32BE(t+4))}encode(e,t,n=0){let i=h(e),a=r(t);return a.writeUInt32BE(i.hi32,n),a.writeUInt32BE(i.lo32,n+4),8}};e.NearUInt64BE=v;var y=class extends i{constructor(e){super(8,e)}decode(e,t=0){let n=r(e),i=n.readUInt32LE(t);return g(n.readInt32LE(t+4),i)}encode(e,t,n=0){let i=h(e),a=r(t);return a.writeUInt32LE(i.lo32,n),a.writeInt32LE(i.hi32,n+4),8}};e.NearInt64=y;var b=class extends i{constructor(e){super(8,e)}decode(e,t=0){let n=r(e);return g(n.readInt32BE(t),n.readUInt32BE(t+4))}encode(e,t,n=0){let i=h(e),a=r(t);return a.writeInt32BE(i.hi32,n),a.writeUInt32BE(i.lo32,n+4),8}};e.NearInt64BE=b;var x=class extends i{constructor(e){super(4,e)}decode(e,t=0){return r(e).readFloatLE(t)}encode(e,t,n=0){return r(t).writeFloatLE(e,n),4}};e.Float=x;var ee=class extends i{constructor(e){super(4,e)}decode(e,t=0){return r(e).readFloatBE(t)}encode(e,t,n=0){return r(t).writeFloatBE(e,n),4}};e.FloatBE=ee;var S=class extends i{constructor(e){super(8,e)}decode(e,t=0){return r(e).readDoubleLE(t)}encode(e,t,n=0){return r(t).writeDoubleLE(e,n),8}};e.Double=S;var C=class extends i{constructor(e){super(8,e)}decode(e,t=0){return r(e).readDoubleBE(t)}encode(e,t,n=0){return r(t).writeDoubleBE(e,n),8}};e.DoubleBE=C;var w=class extends i{constructor(e,t,n){if(!(e instanceof i))throw TypeError(`elementLayout must be a Layout`);if(!(t instanceof s&&t.isCount()||Number.isInteger(t)&&0<=t))throw TypeError(`count must be non-negative integer or an unsigned integer ExternalLayout`);let r=-1;!(t instanceof s)&&0<e.span&&(r=t*e.span),super(r,n),this.elementLayout=e,this.count=t}getSpan(e,t=0){if(0<=this.span)return this.span;let n=0,r=this.count;if(r instanceof s&&(r=r.decode(e,t)),0<this.elementLayout.span)n=r*this.elementLayout.span;else{let i=0;for(;i<r;)n+=this.elementLayout.getSpan(e,t+n),++i}return n}decode(e,t=0){let n=[],r=0,i=this.count;for(i instanceof s&&(i=i.decode(e,t));r<i;)n.push(this.elementLayout.decode(e,t)),t+=this.elementLayout.getSpan(e,t),r+=1;return n}encode(e,t,n=0){let r=this.elementLayout,i=e.reduce((e,i)=>e+r.encode(i,t,n+e),0);return this.count instanceof s&&this.count.encode(e.length,t,n),i}};e.Sequence=w;var T=class extends i{constructor(e,t,n){if(!(Array.isArray(e)&&e.reduce((e,t)=>e&&t instanceof i,!0)))throw TypeError(`fields must be array of Layout instances`);typeof t==`boolean`&&n===void 0&&(n=t,t=void 0);for(let t of e)if(0>t.span&&t.property===void 0)throw Error(`fields cannot contain unnamed variable-length layout`);let r=-1;try{r=e.reduce((e,t)=>e+t.getSpan(),0)}catch{}super(r,t),this.fields=e,this.decodePrefixes=!!n}getSpan(e,t=0){if(0<=this.span)return this.span;let n=0;try{n=this.fields.reduce((n,r)=>{let i=r.getSpan(e,t);return t+=i,n+i},0)}catch{throw RangeError(`indeterminate span`)}return n}decode(e,t=0){n(e);let r=this.makeDestinationObject();for(let n of this.fields)if(n.property!==void 0&&(r[n.property]=n.decode(e,t)),t+=n.getSpan(e,t),this.decodePrefixes&&e.length===t)break;return r}encode(e,t,n=0){let r=n,i=0,a=0;for(let r of this.fields){let o=r.span;if(a=0<o?o:0,r.property!==void 0){let i=e[r.property];i!==void 0&&(a=r.encode(i,t,n),0>o&&(o=r.getSpan(t,n)))}i=n,n+=o}return i+a-r}fromArray(e){let t=this.makeDestinationObject();for(let n of this.fields)n.property!==void 0&&0<e.length&&(t[n.property]=e.shift());return t}layoutFor(e){if(typeof e!=`string`)throw TypeError(`property must be string`);for(let t of this.fields)if(t.property===e)return t}offsetOf(e){if(typeof e!=`string`)throw TypeError(`property must be string`);let t=0;for(let n of this.fields){if(n.property===e)return t;0>n.span?t=-1:0<=t&&(t+=n.span)}}};e.Structure=T;var E=class{constructor(e){this.property=e}decode(e,t){throw Error(`UnionDiscriminator is abstract`)}encode(e,t,n){throw Error(`UnionDiscriminator is abstract`)}};e.UnionDiscriminator=E;var D=class extends E{constructor(e,t){if(!(e instanceof s&&e.isCount()))throw TypeError(`layout must be an unsigned integer ExternalLayout`);super(t||e.property||`variant`),this.layout=e}decode(e,t){return this.layout.decode(e,t)}encode(e,t,n){return this.layout.encode(e,t,n)}};e.UnionLayoutDiscriminator=D;var O=class extends i{constructor(e,t,n){let r;if(e instanceof u||e instanceof d)r=new D(new l(e));else if(e instanceof s&&e.isCount())r=new D(e);else if(e instanceof E)r=e;else throw TypeError(`discr must be a UnionDiscriminator or an unsigned integer layout`);if(t===void 0&&(t=null),!(t===null||t instanceof i))throw TypeError(`defaultLayout must be null or a Layout`);if(t!==null){if(0>t.span)throw Error(`defaultLayout must have constant span`);t.property===void 0&&(t=t.replicate(`content`))}let a=-1;t&&(a=t.span,0<=a&&(e instanceof u||e instanceof d)&&(a+=r.layout.span)),super(a,n),this.discriminator=r,this.usesPrefixDiscriminator=e instanceof u||e instanceof d,this.defaultLayout=t,this.registry={};let o=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(e){return o(e)},this.configGetSourceVariant=function(e){o=e.bind(this)}}getSpan(e,t=0){if(0<=this.span)return this.span;let n=this.getVariant(e,t);if(!n)throw Error(`unable to determine span for unrecognized variant`);return n.getSpan(e,t)}defaultGetSourceVariant(e){if(Object.prototype.hasOwnProperty.call(e,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(e,this.defaultLayout.property))return;let t=this.registry[e[this.discriminator.property]];if(t&&(!t.layout||t.property&&Object.prototype.hasOwnProperty.call(e,t.property)))return t}else for(let t in this.registry){let n=this.registry[t];if(n.property&&Object.prototype.hasOwnProperty.call(e,n.property))return n}throw Error(`unable to infer src variant`)}decode(e,t=0){let n,r=this.discriminator,i=r.decode(e,t),a=this.registry[i];if(a===void 0){let a=this.defaultLayout,o=0;this.usesPrefixDiscriminator&&(o=r.layout.span),n=this.makeDestinationObject(),n[r.property]=i,n[a.property]=a.decode(e,t+o)}else n=a.decode(e,t);return n}encode(e,t,n=0){let r=this.getSourceVariant(e);if(r===void 0){let r=this.discriminator,i=this.defaultLayout,a=0;return this.usesPrefixDiscriminator&&(a=r.layout.span),r.encode(e[r.property],t,n),a+i.encode(e[i.property],t,n+a)}return r.encode(e,t,n)}addVariant(e,t,n){let r=new k(this,e,t,n);return this.registry[e]=r,r}getVariant(e,t=0){let n;return n=e instanceof Uint8Array?this.discriminator.decode(e,t):e,this.registry[n]}};e.Union=O;var k=class extends i{constructor(e,t,n,r){if(!(e instanceof O))throw TypeError(`union must be a Union`);if(!Number.isInteger(t)||0>t)throw TypeError(`variant must be a (non-negative) integer`);if(typeof n==`string`&&r===void 0&&(r=n,n=null),n){if(!(n instanceof i))throw TypeError(`layout must be a Layout`);if(e.defaultLayout!==null&&0<=n.span&&n.span>e.defaultLayout.span)throw Error(`variant span exceeds span of containing union`);if(typeof r!=`string`)throw TypeError(`variant must have a String property`)}let a=e.span;0>e.span&&(a=n?n.span:0,0<=a&&e.usesPrefixDiscriminator&&(a+=e.discriminator.layout.span)),super(a,r),this.union=e,this.variant=t,this.layout=n||null}getSpan(e,t=0){if(0<=this.span)return this.span;let n=0;this.union.usesPrefixDiscriminator&&(n=this.union.discriminator.layout.span);let r=0;return this.layout&&(r=this.layout.getSpan(e,t+n)),n+r}decode(e,t=0){let n=this.makeDestinationObject();if(this!==this.union.getVariant(e,t))throw Error(`variant mismatch`);let r=0;return this.union.usesPrefixDiscriminator&&(r=this.union.discriminator.layout.span),this.layout?n[this.property]=this.layout.decode(e,t+r):this.property?n[this.property]=!0:this.union.usesPrefixDiscriminator&&(n[this.union.discriminator.property]=this.variant),n}encode(e,t,n=0){let r=0;if(this.union.usesPrefixDiscriminator&&(r=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(e,this.property))throw TypeError(`variant lacks property `+this.property);this.union.discriminator.encode(this.variant,t,n);let i=r;if(this.layout&&(this.layout.encode(e[this.property],t,n+r),i+=this.layout.getSpan(t,n+r),0<=this.union.span&&i>this.union.span))throw Error(`encoded variant overruns containing union`);return i}fromArray(e){if(this.layout)return this.layout.fromArray(e)}};e.VariantLayout=k;function te(e){return 0>e&&(e+=4294967296),e}var ne=class extends i{constructor(e,t,n){if(!(e instanceof u||e instanceof d))throw TypeError(`word must be a UInt or UIntBE layout`);if(typeof t==`string`&&n===void 0&&(n=t,t=!1),4<e.span)throw RangeError(`word cannot exceed 32 bits`);super(e.span,n),this.word=e,this.msb=!!t,this.fields=[];let r=0;this._packedSetValue=function(e){return r=te(e),this},this._packedGetValue=function(){return r}}decode(e,t=0){let n=this.makeDestinationObject(),r=this.word.decode(e,t);this._packedSetValue(r);for(let t of this.fields)t.property!==void 0&&(n[t.property]=t.decode(e));return n}encode(e,t,n=0){let r=this.word.decode(t,n);this._packedSetValue(r);for(let t of this.fields)if(t.property!==void 0){let n=e[t.property];n!==void 0&&t.encode(n)}return this.word.encode(this._packedGetValue(),t,n)}addField(e,t){let n=new A(this,e,t);return this.fields.push(n),n}addBoolean(e){let t=new re(this,e);return this.fields.push(t),t}fieldFor(e){if(typeof e!=`string`)throw TypeError(`property must be string`);for(let t of this.fields)if(t.property===e)return t}};e.BitStructure=ne;var A=class{constructor(e,t,n){if(!(e instanceof ne))throw TypeError(`container must be a BitStructure`);if(!Number.isInteger(t)||0>=t)throw TypeError(`bits must be positive integer`);let r=8*e.span,i=e.fields.reduce((e,t)=>e+t.bits,0);if(t+i>r)throw Error(`bits too long for span remainder (`+(r-i)+` of `+r+` remain)`);this.container=e,this.bits=t,this.valueMask=(1<<t)-1,t===32&&(this.valueMask=4294967295),this.start=i,this.container.msb&&(this.start=r-i-t),this.wordMask=te(this.valueMask<<this.start),this.property=n}decode(e,t){return te(this.container._packedGetValue()&this.wordMask)>>>this.start}encode(e){if(typeof e!=`number`||!Number.isInteger(e)||e!==te(e&this.valueMask))throw TypeError(a(`BitField.encode`,this)+` value must be integer not exceeding `+this.valueMask);let t=this.container._packedGetValue(),n=te(e<<this.start);this.container._packedSetValue(te(t&~this.wordMask)|n)}};e.BitField=A;var re=class extends A{constructor(e,t){super(e,1,t)}decode(e,t){return!!super.decode(e,t)}encode(e){typeof e==`boolean`&&(e=+e),super.encode(e)}};e.Boolean=re;var ie=class extends i{constructor(e,t){if(!(e instanceof s&&e.isCount()||Number.isInteger(e)&&0<=e))throw TypeError(`length must be positive integer or an unsigned integer ExternalLayout`);let n=-1;e instanceof s||(n=e),super(n,t),this.length=e}getSpan(e,t){let n=this.span;return 0>n&&(n=this.length.decode(e,t)),n}decode(e,t=0){let n=this.span;return 0>n&&(n=this.length.decode(e,t)),r(e).slice(t,t+n)}encode(e,t,n){let i=this.length;if(this.length instanceof s&&(i=e.length),!(e instanceof Uint8Array&&i===e.length))throw TypeError(a(`Blob.encode`,this)+` requires (length `+i+`) Uint8Array as src`);if(n+i>t.length)throw RangeError(`encoding overruns Uint8Array`);let o=r(e);return r(t).write(o.toString(`hex`),n,i,`hex`),this.length instanceof s&&this.length.encode(i,t,n),i}};e.Blob=ie;var j=class extends i{constructor(e){super(-1,e)}getSpan(e,t=0){n(e);let r=t;for(;r<e.length&&e[r]!==0;)r+=1;return 1+r-t}decode(e,t=0){let n=this.getSpan(e,t);return r(e).slice(t,t+n-1).toString(`utf-8`)}encode(e,n,i=0){typeof e!=`string`&&(e=String(e));let a=t.Buffer.from(e,`utf8`),o=a.length;if(i+o>n.length)throw RangeError(`encoding overruns Buffer`);let s=r(n);return a.copy(s,i),s[i+o]=0,o+1}};e.CString=j;var ae=class extends i{constructor(e,t){if(typeof e==`string`&&t===void 0&&(t=e,e=void 0),e===void 0)e=-1;else if(!Number.isInteger(e))throw TypeError(`maxSpan must be an integer`);super(-1,t),this.maxSpan=e}getSpan(e,t=0){return n(e),e.length-t}decode(e,t=0){let n=this.getSpan(e,t);if(0<=this.maxSpan&&this.maxSpan<n)throw RangeError(`text length exceeds maxSpan`);return r(e).slice(t,t+n).toString(`utf-8`)}encode(e,n,i=0){typeof e!=`string`&&(e=String(e));let a=t.Buffer.from(e,`utf8`),o=a.length;if(0<=this.maxSpan&&this.maxSpan<o)throw RangeError(`text length exceeds maxSpan`);if(i+o>n.length)throw RangeError(`encoding overruns Buffer`);return a.copy(r(n),i),o}};e.UTF8=ae;var M=class extends i{constructor(e,t){super(0,t),this.value=e}decode(e,t){return this.value}encode(e,t,n){return 0}};e.Constant=M,e.greedy=((e,t)=>new c(e,t)),e.offset=((e,t,n)=>new l(e,t,n)),e.u8=(e=>new u(1,e)),e.u16=(e=>new u(2,e)),e.u24=(e=>new u(3,e)),e.u32=(e=>new u(4,e)),e.u40=(e=>new u(5,e)),e.u48=(e=>new u(6,e)),e.nu64=(e=>new _(e)),e.u16be=(e=>new d(2,e)),e.u24be=(e=>new d(3,e)),e.u32be=(e=>new d(4,e)),e.u40be=(e=>new d(5,e)),e.u48be=(e=>new d(6,e)),e.nu64be=(e=>new v(e)),e.s8=(e=>new f(1,e)),e.s16=(e=>new f(2,e)),e.s24=(e=>new f(3,e)),e.s32=(e=>new f(4,e)),e.s40=(e=>new f(5,e)),e.s48=(e=>new f(6,e)),e.ns64=(e=>new y(e)),e.s16be=(e=>new p(2,e)),e.s24be=(e=>new p(3,e)),e.s32be=(e=>new p(4,e)),e.s40be=(e=>new p(5,e)),e.s48be=(e=>new p(6,e)),e.ns64be=(e=>new b(e)),e.f32=(e=>new x(e)),e.f32be=(e=>new ee(e)),e.f64=(e=>new S(e)),e.f64be=(e=>new C(e)),e.struct=((e,t,n)=>new T(e,t,n)),e.bits=((e,t,n)=>new ne(e,t,n)),e.seq=((e,t,n)=>new w(e,t,n)),e.union=((e,t,n)=>new O(e,t,n)),e.unionLayoutDiscriminator=((e,t)=>new D(e,t)),e.blob=((e,t)=>new ie(e,t)),e.cstr=(e=>new j(e)),e.utf8=((e,t)=>new ae(e,t)),e.constant=((e,t)=>new M(e,t))})),kr=n(ir()),Ar=n(sr()),jr=Dr(),L=n(Or()),Mr=8078e3,Nr=8078001,Pr=8078004,Fr=8078005,Ir=8078006,Lr=8078011;function Rr(e){return Array.isArray(e)?`%5B`+e.map(Rr).join(`%2C%20`)+`%5D`:typeof e==`bigint`?`${e}n`:encodeURIComponent(String(e!=null&&Object.getPrototypeOf(e)===null?{...e}:e))}function zr([e,t]){return`${e}=${Rr(t)}`}function Br(e){let t=Object.entries(e).map(zr).join(`&`);return btoa(t)}function Vr(e,t={}){{let n=`Solana error #${e}; Decode this error by running \`npx @solana/errors decode -- ${e}`;return Object.keys(t).length&&(n+=` '${Br(t)}'`),`${n}\``}}var Hr=class extends Error{cause=this.cause;context;constructor(...[e,t]){let n,r;if(t){let{cause:e,...i}=t;e&&(r={cause:e}),Object.keys(i).length>0&&(n=i)}let i=Vr(e,n);super(i,r),this.context={__code:e,...n},this.name=`SolanaError`}};function Ur(e,t){return`fixedSize`in t?t.fixedSize:t.getSizeFromValue(e)}function Wr(e){return Object.freeze({...e,encode:t=>{let n=new Uint8Array(Ur(t,e));return e.write(t,n,0),n}})}function Gr(e){return Object.freeze({...e,decode:(t,n=0)=>e.read(t,n)[0]})}function Kr(e){return`fixedSize`in e&&typeof e.fixedSize==`number`}function qr(e,t){if(Kr(e)!==Kr(t))throw new Hr(Pr);if(Kr(e)&&Kr(t)&&e.fixedSize!==t.fixedSize)throw new Hr(Fr,{decoderFixedSize:t.fixedSize,encoderFixedSize:e.fixedSize});if(!Kr(e)&&!Kr(t)&&e.maxSize!==t.maxSize)throw new Hr(Ir,{decoderMaxSize:t.maxSize,encoderMaxSize:e.maxSize});return{...t,...e,decode:t.decode,encode:e.encode,read:t.read,write:e.write}}function Jr(e,t,n=0){if(t.length-n<=0)throw new Hr(Mr,{codecDescription:e})}function Yr(e,t,n,r=0){let i=n.length-r;if(i<t)throw new Hr(Nr,{bytesLength:i,codecDescription:e,expected:t})}function Xr(e,t,n,r){if(r<t||r>n)throw new Hr(Lr,{codecDescription:e,max:n,min:t,value:r})}function Zr(e){return e?.endian!==1}function Qr(e){return Wr({fixedSize:e.size,write(t,n,r){e.range&&Xr(e.name,e.range[0],e.range[1],t);let i=new ArrayBuffer(e.size);return e.set(new DataView(i),t,Zr(e.config)),n.set(new Uint8Array(i),r),r+e.size}})}function $r(e){return Gr({fixedSize:e.size,read(t,n=0){Jr(e.name,t,n),Yr(e.name,e.size,t,n);let r=new DataView(ei(t,n,e.size));return[e.get(r,Zr(e.config)),n+e.size]}})}function ei(e,t,n){let r=e.byteOffset+(t??0),i=n??e.byteLength;return e.buffer.slice(r,r+i)}var ti=(e={})=>Qr({config:e,name:`u64`,range:[0n,BigInt(`0xffffffffffffffff`)],set:(e,t,n)=>e.setBigUint64(0,BigInt(t),n),size:8}),ni=(e={})=>$r({config:e,get:(e,t)=>e.getBigUint64(0,t),name:`u64`,size:8}),ri=(e={})=>qr(ti(e),ni(e)),ii=class extends TypeError{constructor(e,t){let n,{message:r,explanation:i,...a}=e,{path:o}=e,s=o.length===0?r:`At path: ${o.join(`.`)} -- ${r}`;super(i??s),i!=null&&(this.cause=s),Object.assign(this,a),this.name=this.constructor.name,this.failures=()=>n??=[e,...t()]}};function ai(e){return oi(e)&&typeof e[Symbol.iterator]==`function`}function oi(e){return typeof e==`object`&&!!e}function si(e){return oi(e)&&!Array.isArray(e)}function ci(e){return typeof e==`symbol`?e.toString():typeof e==`string`?JSON.stringify(e):`${e}`}function li(e){let{done:t,value:n}=e.next();return t?void 0:n}function ui(e,t,n,r){if(e===!0)return;e===!1?e={}:typeof e==`string`&&(e={message:e});let{path:i,branch:a}=t,{type:o}=n,{refinement:s,message:c=`Expected a value of type \`${o}\`${s?` with refinement \`${s}\``:``}, but received: \`${ci(r)}\``}=e;return{value:r,type:o,refinement:s,key:i[i.length-1],path:i,branch:a,...e,message:c}}function*di(e,t,n,r){ai(e)||(e=[e]);for(let i of e){let e=ui(i,t,n,r);e&&(yield e)}}function*fi(e,t,n={}){let{path:r=[],branch:i=[e],coerce:a=!1,mask:o=!1}=n,s={path:r,branch:i,mask:o};a&&(e=t.coercer(e,s));let c=`valid`;for(let r of t.validator(e,s))r.explanation=n.message,c=`not_valid`,yield[r,void 0];for(let[l,u,d]of t.entries(e,s)){let t=fi(u,d,{path:l===void 0?r:[...r,l],branch:l===void 0?i:[...i,u],coerce:a,mask:o,message:n.message});for(let n of t)n[0]?(c=n[0].refinement==null?`not_valid`:`not_refined`,yield[n[0],void 0]):a&&(u=n[1],l===void 0?e=u:e instanceof Map?e.set(l,u):e instanceof Set?e.add(u):oi(e)&&(u!==void 0||l in e)&&(e[l]=u))}if(c!==`not_valid`)for(let r of t.refiner(e,s))r.explanation=n.message,c=`not_refined`,yield[r,void 0];c===`valid`&&(yield[void 0,e])}var pi=class{constructor(e){let{type:t,schema:n,validator:r,refiner:i,coercer:a=e=>e,entries:o=function*(){}}=e;this.type=t,this.schema=n,this.entries=o,this.coercer=a,r?this.validator=(e,t)=>di(r(e,t),t,this,e):this.validator=()=>[],i?this.refiner=(e,t)=>di(i(e,t),t,this,e):this.refiner=()=>[]}assert(e,t){return mi(e,this,t)}create(e,t){return R(e,this,t)}is(e){return gi(e,this)}mask(e,t){return hi(e,this,t)}validate(e,t={}){return _i(e,this,t)}};function mi(e,t,n){let r=_i(e,t,{message:n});if(r[0])throw r[0]}function R(e,t,n){let r=_i(e,t,{coerce:!0,message:n});if(r[0])throw r[0];return r[1]}function hi(e,t,n){let r=_i(e,t,{coerce:!0,mask:!0,message:n});if(r[0])throw r[0];return r[1]}function gi(e,t){return!_i(e,t)[0]}function _i(e,t,n={}){let r=fi(e,t,n),i=li(r);return i[0]?[new ii(i[0],function*(){for(let e of r)e[0]&&(yield e[0])}),void 0]:[void 0,i[1]]}function vi(e,t){return new pi({type:e,schema:null,validator:t})}function yi(){return vi(`any`,()=>!0)}function z(e){return new pi({type:`array`,schema:e,*entries(t){if(e&&Array.isArray(t))for(let[n,r]of t.entries())yield[n,r,e]},coercer(e){return Array.isArray(e)?e.slice():e},validator(e){return Array.isArray(e)||`Expected an array value, but received: ${ci(e)}`}})}function bi(){return vi(`boolean`,e=>typeof e==`boolean`)}function xi(e){return vi(`instance`,t=>t instanceof e||`Expected a \`${e.name}\` instance, but received: ${ci(t)}`)}function Si(e){let t=ci(e),n=typeof e;return new pi({type:`literal`,schema:n===`string`||n===`number`||n===`boolean`?e:null,validator(n){return n===e||`Expected the literal \`${t}\`, but received: ${ci(n)}`}})}function Ci(){return vi(`never`,()=>!1)}function B(e){return new pi({...e,validator:(t,n)=>t===null||e.validator(t,n),refiner:(t,n)=>t===null||e.refiner(t,n)})}function V(){return vi(`number`,e=>typeof e==`number`&&!isNaN(e)||`Expected a number, but received: ${ci(e)}`)}function H(e){return new pi({...e,validator:(t,n)=>t===void 0||e.validator(t,n),refiner:(t,n)=>t===void 0||e.refiner(t,n)})}function wi(e,t){return new pi({type:`record`,schema:null,*entries(n){if(oi(n))for(let r in n){let i=n[r];yield[r,r,e],yield[r,i,t]}},validator(e){return si(e)||`Expected an object, but received: ${ci(e)}`},coercer(e){return si(e)?{...e}:e}})}function U(){return vi(`string`,e=>typeof e==`string`||`Expected a string, but received: ${ci(e)}`)}function Ti(e){let t=Ci();return new pi({type:`tuple`,schema:null,*entries(n){if(Array.isArray(n)){let r=Math.max(e.length,n.length);for(let i=0;i<r;i++)yield[i,n[i],e[i]||t]}},validator(e){return Array.isArray(e)||`Expected an array, but received: ${ci(e)}`},coercer(e){return Array.isArray(e)?e.slice():e}})}function W(e){let t=Object.keys(e);return new pi({type:`type`,schema:e,*entries(n){if(oi(n))for(let r of t)yield[r,n[r],e[r]]},validator(e){return si(e)||`Expected an object, but received: ${ci(e)}`},coercer(e){return si(e)?{...e}:e}})}function Ei(e){let t=e.map(e=>e.type).join(` | `);return new pi({type:`union`,schema:null,coercer(t,n){for(let r of e){let[e,i]=r.validate(t,{coerce:!0,mask:n.mask});if(!e)return i}return t},validator(n,r){let i=[];for(let t of e){let[...e]=fi(n,t,r),[a]=e;if(a[0])for(let[t]of e)t&&i.push(t);else return[]}return[`Expected the value to satisfy a union of \`${t}\`, but received: ${ci(n)}`,...i]}})}function Di(){return vi(`unknown`,()=>!0)}function Oi(e,t,n){return new pi({...e,coercer:(r,i)=>gi(r,t)?e.coercer(n(r,i),i):e.coercer(r,i)})}function ki(){if(!Ai&&(Ai=typeof crypto<`u`&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<`u`&&typeof msCrypto.getRandomValues==`function`&&msCrypto.getRandomValues.bind(msCrypto),!Ai))throw Error(`crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported`);return Ai(ji)}var Ai,ji,Mi=t((()=>{ji=new Uint8Array(16)})),Ni,Pi=t((()=>{Ni=/^(?:[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 Fi(e){return typeof e==`string`&&Ni.test(e)}var Ii=t((()=>{Pi()}));function Li(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=(Ri[e[t+0]]+Ri[e[t+1]]+Ri[e[t+2]]+Ri[e[t+3]]+`-`+Ri[e[t+4]]+Ri[e[t+5]]+`-`+Ri[e[t+6]]+Ri[e[t+7]]+`-`+Ri[e[t+8]]+Ri[e[t+9]]+`-`+Ri[e[t+10]]+Ri[e[t+11]]+Ri[e[t+12]]+Ri[e[t+13]]+Ri[e[t+14]]+Ri[e[t+15]]).toLowerCase();if(!Fi(n))throw TypeError(`Stringified UUID is invalid`);return n}var Ri,zi,Bi=t((()=>{for(Ii(),Ri=[],zi=0;zi<256;++zi)Ri.push((zi+256).toString(16).substr(1))}));function Vi(e,t,n){var r=t&&n||0,i=t||Array(16);e||={};var a=e.node||Hi,o=e.clockseq===void 0?Ui:e.clockseq;if(a==null||o==null){var s=e.random||(e.rng||ki)();a??=Hi=[s[0]|1,s[1],s[2],s[3],s[4],s[5]],o??=Ui=(s[6]<<8|s[7])&16383}var c=e.msecs===void 0?Date.now():e.msecs,l=e.nsecs===void 0?Gi+1:e.nsecs,u=c-Wi+(l-Gi)/1e4;if(u<0&&e.clockseq===void 0&&(o=o+1&16383),(u<0||c>Wi)&&e.nsecs===void 0&&(l=0),l>=1e4)throw Error(`uuid.v1(): Can't create more than 10M uuids/sec`);Wi=c,Gi=l,Ui=o,c+=0xb1d069b5400;var d=((c&268435455)*1e4+l)%4294967296;i[r++]=d>>>24&255,i[r++]=d>>>16&255,i[r++]=d>>>8&255,i[r++]=d&255;var f=c/4294967296*1e4&268435455;i[r++]=f>>>8&255,i[r++]=f&255,i[r++]=f>>>24&15|16,i[r++]=f>>>16&255,i[r++]=o>>>8|128,i[r++]=o&255;for(var p=0;p<6;++p)i[r+p]=a[p];return t||Li(i)}var Hi,Ui,Wi,Gi,Ki=t((()=>{Mi(),Bi(),Wi=0,Gi=0}));function qi(e){if(!Fi(e))throw TypeError(`Invalid UUID`);var t,n=new Uint8Array(16);return n[0]=(t=parseInt(e.slice(0,8),16))>>>24,n[1]=t>>>16&255,n[2]=t>>>8&255,n[3]=t&255,n[4]=(t=parseInt(e.slice(9,13),16))>>>8,n[5]=t&255,n[6]=(t=parseInt(e.slice(14,18),16))>>>8,n[7]=t&255,n[8]=(t=parseInt(e.slice(19,23),16))>>>8,n[9]=t&255,n[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,n[11]=t/4294967296&255,n[12]=t>>>24&255,n[13]=t>>>16&255,n[14]=t>>>8&255,n[15]=t&255,n}var Ji=t((()=>{Ii()}));function Yi(e){e=unescape(encodeURIComponent(e));for(var t=[],n=0;n<e.length;++n)t.push(e.charCodeAt(n));return t}function Xi(e,t,n){function r(e,r,i,a){if(typeof e==`string`&&(e=Yi(e)),typeof r==`string`&&(r=qi(r)),r.length!==16)throw TypeError(`Namespace must be array-like (16 iterable integer values, 0-255)`);var o=new Uint8Array(16+e.length);if(o.set(r),o.set(e,r.length),o=n(o),o[6]=o[6]&15|t,o[8]=o[8]&63|128,i){a||=0;for(var s=0;s<16;++s)i[a+s]=o[s];return i}return Li(o)}try{r.name=e}catch{}return r.DNS=Zi,r.URL=Qi,r}var Zi,Qi,$i=t((()=>{Bi(),Ji(),Zi=`6ba7b810-9dad-11d1-80b4-00c04fd430c8`,Qi=`6ba7b811-9dad-11d1-80b4-00c04fd430c8`}));function ea(e){if(typeof e==`string`){var t=unescape(encodeURIComponent(e));e=new Uint8Array(t.length);for(var n=0;n<t.length;++n)e[n]=t.charCodeAt(n)}return ta(ra(ia(e),e.length*8))}function ta(e){for(var t=[],n=e.length*32,r=`0123456789abcdef`,i=0;i<n;i+=8){var a=e[i>>5]>>>i%32&255,o=parseInt(r.charAt(a>>>4&15)+r.charAt(a&15),16);t.push(o)}return t}function na(e){return(e+64>>>9<<4)+14+1}function ra(e,t){e[t>>5]|=128<<t%32,e[na(t)-1]=t;for(var n=1732584193,r=-271733879,i=-1732584194,a=271733878,o=0;o<e.length;o+=16){var s=n,c=r,l=i,u=a;n=ca(n,r,i,a,e[o],7,-680876936),a=ca(a,n,r,i,e[o+1],12,-389564586),i=ca(i,a,n,r,e[o+2],17,606105819),r=ca(r,i,a,n,e[o+3],22,-1044525330),n=ca(n,r,i,a,e[o+4],7,-176418897),a=ca(a,n,r,i,e[o+5],12,1200080426),i=ca(i,a,n,r,e[o+6],17,-1473231341),r=ca(r,i,a,n,e[o+7],22,-45705983),n=ca(n,r,i,a,e[o+8],7,1770035416),a=ca(a,n,r,i,e[o+9],12,-1958414417),i=ca(i,a,n,r,e[o+10],17,-42063),r=ca(r,i,a,n,e[o+11],22,-1990404162),n=ca(n,r,i,a,e[o+12],7,1804603682),a=ca(a,n,r,i,e[o+13],12,-40341101),i=ca(i,a,n,r,e[o+14],17,-1502002290),r=ca(r,i,a,n,e[o+15],22,1236535329),n=la(n,r,i,a,e[o+1],5,-165796510),a=la(a,n,r,i,e[o+6],9,-1069501632),i=la(i,a,n,r,e[o+11],14,643717713),r=la(r,i,a,n,e[o],20,-373897302),n=la(n,r,i,a,e[o+5],5,-701558691),a=la(a,n,r,i,e[o+10],9,38016083),i=la(i,a,n,r,e[o+15],14,-660478335),r=la(r,i,a,n,e[o+4],20,-405537848),n=la(n,r,i,a,e[o+9],5,568446438),a=la(a,n,r,i,e[o+14],9,-1019803690),i=la(i,a,n,r,e[o+3],14,-187363961),r=la(r,i,a,n,e[o+8],20,1163531501),n=la(n,r,i,a,e[o+13],5,-1444681467),a=la(a,n,r,i,e[o+2],9,-51403784),i=la(i,a,n,r,e[o+7],14,1735328473),r=la(r,i,a,n,e[o+12],20,-1926607734),n=ua(n,r,i,a,e[o+5],4,-378558),a=ua(a,n,r,i,e[o+8],11,-2022574463),i=ua(i,a,n,r,e[o+11],16,1839030562),r=ua(r,i,a,n,e[o+14],23,-35309556),n=ua(n,r,i,a,e[o+1],4,-1530992060),a=ua(a,n,r,i,e[o+4],11,1272893353),i=ua(i,a,n,r,e[o+7],16,-155497632),r=ua(r,i,a,n,e[o+10],23,-1094730640),n=ua(n,r,i,a,e[o+13],4,681279174),a=ua(a,n,r,i,e[o],11,-358537222),i=ua(i,a,n,r,e[o+3],16,-722521979),r=ua(r,i,a,n,e[o+6],23,76029189),n=ua(n,r,i,a,e[o+9],4,-640364487),a=ua(a,n,r,i,e[o+12],11,-421815835),i=ua(i,a,n,r,e[o+15],16,530742520),r=ua(r,i,a,n,e[o+2],23,-995338651),n=da(n,r,i,a,e[o],6,-198630844),a=da(a,n,r,i,e[o+7],10,1126891415),i=da(i,a,n,r,e[o+14],15,-1416354905),r=da(r,i,a,n,e[o+5],21,-57434055),n=da(n,r,i,a,e[o+12],6,1700485571),a=da(a,n,r,i,e[o+3],10,-1894986606),i=da(i,a,n,r,e[o+10],15,-1051523),r=da(r,i,a,n,e[o+1],21,-2054922799),n=da(n,r,i,a,e[o+8],6,1873313359),a=da(a,n,r,i,e[o+15],10,-30611744),i=da(i,a,n,r,e[o+6],15,-1560198380),r=da(r,i,a,n,e[o+13],21,1309151649),n=da(n,r,i,a,e[o+4],6,-145523070),a=da(a,n,r,i,e[o+11],10,-1120210379),i=da(i,a,n,r,e[o+2],15,718787259),r=da(r,i,a,n,e[o+9],21,-343485551),n=aa(n,s),r=aa(r,c),i=aa(i,l),a=aa(a,u)}return[n,r,i,a]}function ia(e){if(e.length===0)return[];for(var t=e.length*8,n=new Uint32Array(na(t)),r=0;r<t;r+=8)n[r>>5]|=(e[r/8]&255)<<r%32;return n}function aa(e,t){var n=(e&65535)+(t&65535);return(e>>16)+(t>>16)+(n>>16)<<16|n&65535}function oa(e,t){return e<<t|e>>>32-t}function sa(e,t,n,r,i,a){return aa(oa(aa(aa(t,e),aa(r,a)),i),n)}function ca(e,t,n,r,i,a,o){return sa(t&n|~t&r,e,t,i,a,o)}function la(e,t,n,r,i,a,o){return sa(t&r|n&~r,e,t,i,a,o)}function ua(e,t,n,r,i,a,o){return sa(t^n^r,e,t,i,a,o)}function da(e,t,n,r,i,a,o){return sa(n^(t|~r),e,t,i,a,o)}var fa=t((()=>{})),pa,ma=t((()=>{$i(),fa(),pa=Xi(`v3`,48,ea)}));function ha(e,t,n){e||={};var r=e.random||(e.rng||ki)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){n||=0;for(var i=0;i<16;++i)t[n+i]=r[i];return t}return Li(r)}var ga=t((()=>{Mi(),Bi()}));function _a(e,t,n,r){switch(e){case 0:return t&n^~t&r;case 1:return t^n^r;case 2:return t&n^t&r^n&r;case 3:return t^n^r}}function va(e,t){return e<<t|e>>>32-t}function ya(e){var t=[1518500249,1859775393,2400959708,3395469782],n=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof e==`string`){var r=unescape(encodeURIComponent(e));e=[];for(var i=0;i<r.length;++i)e.push(r.charCodeAt(i))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);for(var a=e.length/4+2,o=Math.ceil(a/16),s=Array(o),c=0;c<o;++c){for(var l=new Uint32Array(16),u=0;u<16;++u)l[u]=e[c*64+u*4]<<24|e[c*64+u*4+1]<<16|e[c*64+u*4+2]<<8|e[c*64+u*4+3];s[c]=l}s[o-1][14]=(e.length-1)*8/2**32,s[o-1][14]=Math.floor(s[o-1][14]),s[o-1][15]=(e.length-1)*8&4294967295;for(var d=0;d<o;++d){for(var f=new Uint32Array(80),p=0;p<16;++p)f[p]=s[d][p];for(var m=16;m<80;++m)f[m]=va(f[m-3]^f[m-8]^f[m-14]^f[m-16],1);for(var h=n[0],g=n[1],_=n[2],v=n[3],y=n[4],b=0;b<80;++b){var x=Math.floor(b/20),ee=va(h,5)+_a(x,g,_,v)+y+t[x]+f[b]>>>0;y=v,v=_,_=va(g,30)>>>0,g=h,h=ee}n[0]=n[0]+h>>>0,n[1]=n[1]+g>>>0,n[2]=n[2]+_>>>0,n[3]=n[3]+v>>>0,n[4]=n[4]+y>>>0}return[n[0]>>24&255,n[0]>>16&255,n[0]>>8&255,n[0]&255,n[1]>>24&255,n[1]>>16&255,n[1]>>8&255,n[1]&255,n[2]>>24&255,n[2]>>16&255,n[2]>>8&255,n[2]&255,n[3]>>24&255,n[3]>>16&255,n[3]>>8&255,n[3]&255,n[4]>>24&255,n[4]>>16&255,n[4]>>8&255,n[4]&255]}var ba=t((()=>{})),xa,Sa=t((()=>{$i(),ba(),xa=Xi(`v5`,80,ya)})),Ca,wa=t((()=>{Ca=`00000000-0000-0000-0000-000000000000`}));function Ta(e){if(!Fi(e))throw TypeError(`Invalid UUID`);return parseInt(e.substr(14,1),16)}var Ea=t((()=>{Ii()})),Da=r({NIL:()=>Ca,parse:()=>qi,stringify:()=>Li,v1:()=>Vi,v3:()=>pa,v4:()=>ha,v5:()=>xa,validate:()=>Fi,version:()=>Ta}),Oa=t((()=>{Ki(),ma(),ga(),Sa(),wa(),Ea(),Ii(),Bi(),Ji()})),ka=i(((t,n)=>{var r=(Oa(),e(Da)).v4;n.exports=function(e,t,n,i){if(typeof e!=`string`)throw TypeError(e+` must be a string`);i||={};let a=typeof i.version==`number`?i.version:2;if(a!==1&&a!==2)throw TypeError(a+` must be 1 or 2`);let o={method:e};if(a===2&&(o.jsonrpc=`2.0`),t){if(typeof t!=`object`&&!Array.isArray(t))throw TypeError(t+` must be an object, array or omitted`);o.params=t}return n===void 0?o.id=(typeof i.generator==`function`?i.generator:function(){return r()})(o,i):a===2&&n===null?i.notificationIdNull&&(o.id=null):o.id=n,o}})),Aa=n(i(((t,n)=>{var r=(Oa(),e(Da)).v4,i=ka(),a=function(e,t){if(!(this instanceof a))return new a(e,t);t||={},this.options={reviver:t.reviver===void 0?null:t.reviver,replacer:t.replacer===void 0?null:t.replacer,generator:t.generator===void 0?function(){return r()}:t.generator,version:t.version===void 0?2:t.version,notificationIdNull:typeof t.notificationIdNull==`boolean`?t.notificationIdNull:!1},this.callServer=e};n.exports=a,a.prototype.request=function(e,t,n,r){let a=this,o=null,s=Array.isArray(e)&&typeof t==`function`;if(this.options.version===1&&s)throw TypeError(`JSON-RPC 1.0 does not support batching`);if(s||!s&&e&&typeof e==`object`&&typeof t==`function`)r=t,o=e;else{typeof n==`function`&&(r=n,n=void 0);let a=typeof r==`function`;try{o=i(e,t,n,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(e){if(a){r(e);return}throw e}if(!a)return o}let c;try{c=JSON.stringify(o,this.options.replacer)}catch(e){r(e);return}return this.callServer(c,function(e,t){a._parseResponse(e,t,r)}),o},a.prototype._parseResponse=function(e,t,n){if(e){n(e);return}if(!t){n();return}let r;try{r=JSON.parse(t,this.options.reviver)}catch(e){n(e);return}if(n.length===3)if(Array.isArray(r)){let e=function(e){return e.error!==void 0};n(null,r.filter(e),r.filter(function(t){return!e(t)}));return}else{n(null,r.error,r.result);return}n(null,r)}}))()),ja=class extends o.default{socket;constructor(e,t){super(),this.socket=new window.WebSocket(e,t.protocols),this.socket.onopen=()=>this.emit(`open`),this.socket.onmessage=e=>this.emit(`message`,e.data),this.socket.onerror=e=>this.emit(`error`,e),this.socket.onclose=e=>{this.emit(`close`,e.code,e.reason)}}send(e,t,n){let r=n||t;try{this.socket.send(e),r()}catch(e){r(e)}}close(e,t){this.socket.close(e,t)}addEventListener(e,t,n){this.socket.addEventListener(e,t,n)}};function Ma(e,t){return new ja(e,t)}var Na=class{encode(e){return JSON.stringify(e)}decode(e){return JSON.parse(e)}},Pa=class extends o.default{address;rpc_id;queue;options;autoconnect;ready;reconnect;reconnect_timer_id;reconnect_interval;max_reconnects;rest_options;current_reconnects;generate_request_id;socket;webSocketFactory;dataPack;constructor(e,t=`ws://localhost:8080`,{autoconnect:n=!0,reconnect:r=!0,reconnect_interval:i=1e3,max_reconnects:a=5,...o}={},s,c){super(),this.webSocketFactory=e,this.queue={},this.rpc_id=0,this.address=t,this.autoconnect=n,this.ready=!1,this.reconnect=r,this.reconnect_timer_id=void 0,this.reconnect_interval=i,this.max_reconnects=a,this.rest_options=o,this.current_reconnects=0,this.generate_request_id=s||(()=>typeof this.rpc_id==`number`?++this.rpc_id:Number(this.rpc_id)+1),c?this.dataPack=c:this.dataPack=new Na,this.autoconnect&&this._connect(this.address,{autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects,...this.rest_options})}connect(){this.socket||this._connect(this.address,{autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects,...this.rest_options})}call(e,t,n,r){return!r&&typeof n==`object`&&(r=n,n=null),new Promise((i,a)=>{if(!this.ready)return a(Error(`socket not ready`));let o=this.generate_request_id(e,t),s={jsonrpc:`2.0`,method:e,params:t||void 0,id:o};this.socket.send(this.dataPack.encode(s),r,e=>{if(e)return a(e);this.queue[o]={promise:[i,a]},n&&(this.queue[o].timeout=setTimeout(()=>{delete this.queue[o],a(Error(`reply timeout`))},n))})})}async login(e){let t=await this.call(`rpc.login`,e);if(!t)throw Error(`authentication failed`);return t}async listMethods(){return await this.call(`__listMethods`)}notify(e,t){return new Promise((n,r)=>{if(!this.ready)return r(Error(`socket not ready`));let i={jsonrpc:`2.0`,method:e,params:t};this.socket.send(this.dataPack.encode(i),e=>{if(e)return r(e);n()})})}async subscribe(e){typeof e==`string`&&(e=[e]);let t=await this.call(`rpc.on`,e);if(typeof e==`string`&&t[e]!==`ok`)throw Error(`Failed subscribing to an event '`+e+`' with: `+t[e]);return t}async unsubscribe(e){typeof e==`string`&&(e=[e]);let t=await this.call(`rpc.off`,e);if(typeof e==`string`&&t[e]!==`ok`)throw Error(`Failed unsubscribing from an event with: `+t);return t}close(e,t){this.socket&&this.socket.close(e||1e3,t)}setAutoReconnect(e){this.reconnect=e}setReconnectInterval(e){this.reconnect_interval=e}setMaxReconnects(e){this.max_reconnects=e}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(e,t){clearTimeout(this.reconnect_timer_id),this.socket=this.webSocketFactory(e,t),this.socket.addEventListener(`open`,()=>{this.ready=!0,this.emit(`open`),this.current_reconnects=0}),this.socket.addEventListener(`message`,({data:e})=>{e instanceof ArrayBuffer&&(e=I.Buffer.from(e).toString());try{e=this.dataPack.decode(e)}catch{return}if(e.notification&&this.listeners(e.notification).length){if(!Object.keys(e.params).length)return this.emit(e.notification);let t=[e.notification];if(e.params.constructor===Object)t.push(e.params);else for(let n=0;n<e.params.length;n++)t.push(e.params[n]);return Promise.resolve().then(()=>{this.emit.apply(this,t)})}if(!this.queue[e.id])return e.method?Promise.resolve().then(()=>{this.emit(e.method,e?.params)}):void 0;`error`in e==`result`in e&&this.queue[e.id].promise[1](Error(`Server response malformed. Response must include either "result" or "error", but not both.`)),this.queue[e.id].timeout&&clearTimeout(this.queue[e.id].timeout),e.error?this.queue[e.id].promise[1](e.error):this.queue[e.id].promise[0](e.result),delete this.queue[e.id]}),this.socket.addEventListener(`error`,e=>this.emit(`error`,e)),this.socket.addEventListener(`close`,({code:n,reason:r})=>{this.ready&&setTimeout(()=>this.emit(`close`,n,r),0),this.ready=!1,this.socket=void 0,n!==1e3&&(this.current_reconnects++,this.reconnect&&(this.max_reconnects>this.current_reconnects||this.max_reconnects===0)?this.reconnect_timer_id=setTimeout(()=>this._connect(e,t),this.reconnect_interval):this.reconnect&&this.max_reconnects>0&&this.current_reconnects>=this.max_reconnects&&setTimeout(()=>this.emit(`max_reconnects_reached`,n,r),1))})}},Fa=(e,t)=>(e+(e>=0?t:-t)/Ha)/t;function Ia(e,t,n){let[[r,i],[a,o]]=t,s=Fa(o*e,n),c=Fa(-i*e,n),l=e-s*r-c*a,u=-s*i-c*o,d=l<Ba,f=u<Ba;d&&(l=-l),f&&(u=-u);let p=St(Math.ceil(xt(n)/2))+Va;if(l<Ba||l>=p||u<Ba||u>=p)throw Error(`splitScalar (endomorphism): failed, k=`+e);return{k1neg:d,k1:l,k2neg:f,k2:u}}function La(e){if(![`compact`,`recovered`,`der`].includes(e))throw Error(`Signature format must be "compact", "recovered", or "der"`);return e}function Ra(e,t){let n={};for(let r of Object.keys(t))n[r]=e[r]===void 0?t[r]:e[r];return st(n.lowS,`lowS`),st(n.prehash,`prehash`),n.format!==void 0&&La(n.format),n}var za={Err:class extends Error{constructor(e=``){super(e)}},_tlv:{encode:(e,t)=>{let{Err:n}=za;if(e<0||e>256)throw new n(`tlv.encode: wrong tag`);if(t.length&1)throw new n(`tlv.encode: unpadded data`);let r=t.length/2,i=lt(r);if(i.length/2&128)throw new n(`tlv.encode: long form length too big`);let a=r>127?lt(i.length/2|128):``;return lt(e)+a+i+t},decode(e,t){let{Err:n}=za,r=0;if(e<0||e>256)throw new n(`tlv.encode: wrong tag`);if(t.length<2||t[r++]!==e)throw new n(`tlv.decode: wrong tlv`);let i=t[r++],a=!!(i&128),o=0;if(!a)o=i;else{let e=i&127;if(!e)throw new n(`tlv.decode(long): indefinite length not supported`);if(e>4)throw new n(`tlv.decode(long): byte length is too big`);let a=t.subarray(r,r+e);if(a.length!==e)throw new n(`tlv.decode: length bytes not complete`);if(a[0]===0)throw new n(`tlv.decode(long): zero leftmost byte`);for(let e of a)o=o<<8|e;if(r+=e,o<128)throw new n(`tlv.decode(long): not minimal encoding`)}let s=t.subarray(r,r+o);if(s.length!==o)throw new n(`tlv.decode: wrong value length`);return{v:s,l:t.subarray(r+o)}}},_int:{encode(e){let{Err:t}=za;if(e<Ba)throw new t(`integer: negative integers are not allowed`);let n=lt(e);if(Number.parseInt(n[0],16)&8&&(n=`00`+n),n.length&1)throw new t(`unexpected DER parsing assertion: unpadded hex`);return n},decode(e){let{Err:t}=za;if(e[0]&128)throw new t(`invalid signature integer: negative`);if(e[0]===0&&!(e[1]&128))throw new t(`invalid signature integer: unnecessary leading zero`);return dt(e)}},toSig(e){let{Err:t,_int:n,_tlv:r}=za,i=ht(`signature`,e),{v:a,l:o}=r.decode(48,i);if(o.length)throw new t(`invalid signature: left bytes after parsing`);let{v:s,l:c}=r.decode(2,a),{v:l,l:u}=r.decode(2,c);if(u.length)throw new t(`invalid signature: left bytes after parsing`);return{r:n.decode(s),s:n.decode(l)}},hexFromSig(e){let{_tlv:t,_int:n}=za,r=t.encode(2,n.encode(e.r))+t.encode(2,n.encode(e.s));return t.encode(48,r)}},Ba=BigInt(0),Va=BigInt(1),Ha=BigInt(2),Ua=BigInt(3),Wa=BigInt(4);function Ga(e,t){let{BYTES:n}=e,r;if(typeof t==`bigint`)r=t;else{let i=ht(`private key`,t);try{r=e.fromBytes(i)}catch{throw Error(`invalid private key: expected ui8a of size ${n}, got ${typeof t}`)}}if(!e.isValidNot0(r))throw Error(`invalid private key: out of range [1..N-1]`);return r}function Ka(e,t={}){let n=xn(`weierstrass`,e,t),{Fp:r,Fn:i}=n,a=n.CURVE,{h:o,n:s}=a;wt(t,{},{allowInfinityPoint:`boolean`,clearCofactor:`function`,isTorsionFree:`function`,fromBytes:`function`,toBytes:`function`,endo:`object`,wrapPrivateKey:`boolean`});let{endo:c}=t;if(c&&(!r.is0(a.a)||typeof c.beta!=`bigint`||!Array.isArray(c.basises)))throw Error(`invalid endo: expected "beta": bigint and "basises": array`);let l=Ja(r,i);function u(){if(!r.isOdd)throw Error(`compression is not supported: Field does not have .isOdd()`)}function d(e,t,n){let{x:i,y:a}=t.toAffine(),o=r.toBytes(i);return st(n,`isCompressed`),n?(u(),F(qa(!r.isOdd(a)),o)):F(Uint8Array.of(4),o,r.toBytes(a))}function f(e){ct(e,void 0,`Point`);let{publicKey:t,publicKeyUncompressed:n}=l,i=e.length,a=e[0],o=e.subarray(1);if(i===t&&(a===2||a===3)){let e=r.fromBytes(o);if(!r.isValid(e))throw Error(`bad point: is not on curve, wrong x`);let t=h(e),n;try{n=r.sqrt(t)}catch(e){let t=e instanceof Error?`: `+e.message:``;throw Error(`bad point: is not on curve, sqrt error`+t)}u();let i=r.isOdd(n);return(a&1)==1!==i&&(n=r.neg(n)),{x:e,y:n}}else if(i===n&&a===4){let e=r.BYTES,t=r.fromBytes(o.subarray(0,e)),n=r.fromBytes(o.subarray(e,e*2));if(!g(t,n))throw Error(`bad point: is not on curve`);return{x:t,y:n}}else throw Error(`bad point: got length ${i}, expected compressed=${t} or uncompressed=${n}`)}let p=t.toBytes||d,m=t.fromBytes||f;function h(e){let t=r.sqr(e),n=r.mul(t,e);return r.add(r.add(n,r.mul(e,a.a)),a.b)}function g(e,t){let n=r.sqr(t),i=h(e);return r.eql(n,i)}if(!g(a.Gx,a.Gy))throw Error(`bad curve params: generator point`);let _=r.mul(r.pow(a.a,Ua),Wa),v=r.mul(r.sqr(a.b),BigInt(27));if(r.is0(r.add(_,v)))throw Error(`bad curve params: a or b`);function y(e,t,n=!1){if(!r.isValid(t)||n&&r.is0(t))throw Error(`bad point coordinate ${e}`);return t}function b(e){if(!(e instanceof w))throw Error(`ProjectivePoint expected`)}function x(e){if(!c||!c.basises)throw Error(`no endo`);return Ia(e,c.basises,i.ORDER)}let ee=Et((e,t)=>{let{X:n,Y:i,Z:a}=e;if(r.eql(a,r.ONE))return{x:n,y:i};let o=e.is0();t??=o?r.ONE:r.inv(a);let s=r.mul(n,t),c=r.mul(i,t),l=r.mul(a,t);if(o)return{x:r.ZERO,y:r.ZERO};if(!r.eql(l,r.ONE))throw Error(`invZ was invalid`);return{x:s,y:c}}),S=Et(e=>{if(e.is0()){if(t.allowInfinityPoint&&!r.is0(e.Y))return;throw Error(`bad point: ZERO`)}let{x:n,y:i}=e.toAffine();if(!r.isValid(n)||!r.isValid(i))throw Error(`bad point: x or y not field elements`);if(!g(n,i))throw Error(`bad point: equation left != right`);if(!e.isTorsionFree())throw Error(`bad point: not in prime-order subgroup`);return!0});function C(e,t,n,i,a){return n=new w(r.mul(n.X,e),n.Y,n.Z),t=on(i,t),n=on(a,n),t.add(n)}class w{constructor(e,t,n){this.X=y(`x`,e),this.Y=y(`y`,t,!0),this.Z=y(`z`,n),Object.freeze(this)}static CURVE(){return a}static fromAffine(e){let{x:t,y:n}=e||{};if(!e||!r.isValid(t)||!r.isValid(n))throw Error(`invalid affine point`);if(e instanceof w)throw Error(`projective point not allowed`);return r.is0(t)&&r.is0(n)?w.ZERO:new w(t,n,r.ONE)}static fromBytes(e){let t=w.fromAffine(m(ct(e,void 0,`point`)));return t.assertValidity(),t}static fromHex(e){return w.fromBytes(ht(`pointHex`,e))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(e=8,t=!0){return E.createCache(this,e),t||this.multiply(Ua),this}assertValidity(){S(this)}hasEvenY(){let{y:e}=this.toAffine();if(!r.isOdd)throw Error(`Field doesn't support isOdd`);return!r.isOdd(e)}equals(e){b(e);let{X:t,Y:n,Z:i}=this,{X:a,Y:o,Z:s}=e,c=r.eql(r.mul(t,s),r.mul(a,i)),l=r.eql(r.mul(n,s),r.mul(o,i));return c&&l}negate(){return new w(this.X,r.neg(this.Y),this.Z)}double(){let{a:e,b:t}=a,n=r.mul(t,Ua),{X:i,Y:o,Z:s}=this,c=r.ZERO,l=r.ZERO,u=r.ZERO,d=r.mul(i,i),f=r.mul(o,o),p=r.mul(s,s),m=r.mul(i,o);return m=r.add(m,m),u=r.mul(i,s),u=r.add(u,u),c=r.mul(e,u),l=r.mul(n,p),l=r.add(c,l),c=r.sub(f,l),l=r.add(f,l),l=r.mul(c,l),c=r.mul(m,c),u=r.mul(n,u),p=r.mul(e,p),m=r.sub(d,p),m=r.mul(e,m),m=r.add(m,u),u=r.add(d,d),d=r.add(u,d),d=r.add(d,p),d=r.mul(d,m),l=r.add(l,d),p=r.mul(o,s),p=r.add(p,p),d=r.mul(p,m),c=r.sub(c,d),u=r.mul(p,f),u=r.add(u,u),u=r.add(u,u),new w(c,l,u)}add(e){b(e);let{X:t,Y:n,Z:i}=this,{X:o,Y:s,Z:c}=e,l=r.ZERO,u=r.ZERO,d=r.ZERO,f=a.a,p=r.mul(a.b,Ua),m=r.mul(t,o),h=r.mul(n,s),g=r.mul(i,c),_=r.add(t,n),v=r.add(o,s);_=r.mul(_,v),v=r.add(m,h),_=r.sub(_,v),v=r.add(t,i);let y=r.add(o,c);return v=r.mul(v,y),y=r.add(m,g),v=r.sub(v,y),y=r.add(n,i),l=r.add(s,c),y=r.mul(y,l),l=r.add(h,g),y=r.sub(y,l),d=r.mul(f,v),l=r.mul(p,g),d=r.add(l,d),l=r.sub(h,d),d=r.add(h,d),u=r.mul(l,d),h=r.add(m,m),h=r.add(h,m),g=r.mul(f,g),v=r.mul(p,v),h=r.add(h,g),g=r.sub(m,g),g=r.mul(f,g),v=r.add(v,g),m=r.mul(h,v),u=r.add(u,m),m=r.mul(y,v),l=r.mul(_,l),l=r.sub(l,m),m=r.mul(_,h),d=r.mul(y,d),d=r.add(d,m),new w(l,u,d)}subtract(e){return this.add(e.negate())}is0(){return this.equals(w.ZERO)}multiply(e){let{endo:n}=t;if(!i.isValidNot0(e))throw Error(`invalid scalar: out of range`);let r,a,o=e=>E.cached(this,e,e=>sn(w,e));if(n){let{k1neg:t,k1:i,k2neg:s,k2:c}=x(e),{p:l,f:u}=o(i),{p:d,f}=o(c);a=u.add(f),r=C(n.beta,l,d,t,s)}else{let{p:t,f:n}=o(e);r=t,a=n}return sn(w,[r,a])[0]}multiplyUnsafe(e){let{endo:n}=t,r=this;if(!i.isValid(e))throw Error(`invalid scalar: out of range`);if(e===Ba||r.is0())return w.ZERO;if(e===Va)return r;if(E.hasCache(this))return this.multiply(e);if(n){let{k1neg:t,k1:i,k2neg:a,k2:o}=x(e),{p1:s,p2:c}=vn(w,r,i,o);return C(n.beta,s,c,t,a)}else return E.unsafe(r,e)}multiplyAndAddUnsafe(e,t,n){let r=this.multiplyUnsafe(t).add(e.multiplyUnsafe(n));return r.is0()?void 0:r}toAffine(e){return ee(this,e)}isTorsionFree(){let{isTorsionFree:e}=t;return o===Va?!0:e?e(w,this):E.unsafe(this,s).is0()}clearCofactor(){let{clearCofactor:e}=t;return o===Va?this:e?e(w,this):this.multiplyUnsafe(o)}isSmallOrder(){return this.multiplyUnsafe(o).is0()}toBytes(e=!0){return st(e,`isCompressed`),this.assertValidity(),p(w,this,e)}toHex(e=!0){return N(this.toBytes(e))}toString(){return`<Point ${this.is0()?`ZERO`:this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(e=!0){return this.toBytes(e)}_setWindowSize(e){this.precompute(e)}static normalizeZ(e){return sn(w,e)}static msm(e,t){return yn(w,i,e,t)}static fromPrivateKey(e){return w.BASE.multiply(Ga(i,e))}}w.BASE=new w(a.Gx,a.Gy,r.ONE),w.ZERO=new w(r.ZERO,r.ONE,r.ZERO),w.Fp=r,w.Fn=i;let T=i.BITS,E=new _n(w,t.endo?Math.ceil(T/2):T);return w.BASE.precompute(8),w}function qa(e){return Uint8Array.of(e?2:3)}function Ja(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function Ya(e,t={}){let{Fn:n}=e,r=t.randomBytes||ve,i=Object.assign(Ja(e.Fp,n),{seed:tn(n.ORDER)});function a(e){try{return!!Ga(n,e)}catch{return!1}}function o(t,n){let{publicKey:r,publicKeyUncompressed:a}=i;try{let i=t.length;return n===!0&&i!==r||n===!1&&i!==a?!1:!!e.fromBytes(t)}catch{return!1}}function s(e=r(i.seed)){return nn(ct(e,i.seed,`seed`),n.ORDER)}function c(t,r=!0){return e.BASE.multiply(Ga(n,t)).toBytes(r)}function l(e){let t=s(e);return{secretKey:t,publicKey:c(t)}}function u(t){if(typeof t==`bigint`)return!1;if(t instanceof e)return!0;let{secretKey:r,publicKey:a,publicKeyUncompressed:o}=i;if(n.allowedLengths||r===a)return;let s=ht(`key`,t).length;return s===a||s===o}function d(t,r,i=!0){if(u(t)===!0)throw Error(`first arg must be private key`);if(u(r)===!1)throw Error(`second arg must be public key`);let a=Ga(n,t);return e.fromHex(r).multiply(a).toBytes(i)}return Object.freeze({getPublicKey:c,getSharedSecret:d,keygen:l,Point:e,utils:{isValidSecretKey:a,isValidPublicKey:o,randomSecretKey:s,isValidPrivateKey:a,randomPrivateKey:s,normPrivateKeyToScalar:e=>Ga(n,e),precompute(t=8,n=e.BASE){return n.precompute(t,!1)}},lengths:i})}function Xa(e,t,n={}){ne(t),wt(n,{},{hmac:`function`,lowS:`boolean`,randomBytes:`function`,bits2int:`function`,bits2int_modN:`function`});let r=n.randomBytes||ve,i=n.hmac||((e,...n)=>tt(t,e,F(...n))),{Fp:a,Fn:o}=e,{ORDER:s,BITS:c}=o,{keygen:l,getPublicKey:u,getSharedSecret:d,utils:f,lengths:p}=Ya(e,n),m={prehash:!1,lowS:typeof n.lowS==`boolean`?n.lowS:!1,format:void 0,extraEntropy:!1},h=`compact`;function g(e){return e>s>>Va}function _(e,t){if(!o.isValidNot0(t))throw Error(`invalid signature ${e}: out of range 1..Point.Fn.ORDER`);return t}function v(e,t){La(t);let n=p.signature;return ct(e,t===`compact`?n:t===`recovered`?n+1:void 0,`${t} signature`)}class y{constructor(e,t,n){this.r=_(`r`,e),this.s=_(`s`,t),n!=null&&(this.recovery=n),Object.freeze(this)}static fromBytes(e,t=h){v(e,t);let n;if(t===`der`){let{r:t,s:n}=za.toSig(ct(e));return new y(t,n)}t===`recovered`&&(n=e[0],t=`compact`,e=e.subarray(1));let r=o.BYTES,i=e.subarray(0,r),a=e.subarray(r,r*2);return new y(o.fromBytes(i),o.fromBytes(a),n)}static fromHex(e,t){return this.fromBytes(me(e),t)}addRecoveryBit(e){return new y(this.r,this.s,e)}recoverPublicKey(t){let n=a.ORDER,{r,s:i,recovery:c}=this;if(c==null||![0,1,2,3].includes(c))throw Error(`recovery id invalid`);if(s*Ha<n&&c>1)throw Error(`recovery id is ambiguous for h>1 curve`);let l=c===2||c===3?r+s:r;if(!a.isValid(l))throw Error(`recovery id 2 or 3 invalid`);let u=a.toBytes(l),d=e.fromBytes(F(qa((c&1)==0),u)),f=o.inv(l),p=x(ht(`msgHash`,t)),m=o.create(-p*f),h=o.create(i*f),g=e.BASE.multiplyUnsafe(m).add(d.multiplyUnsafe(h));if(g.is0())throw Error(`point at infinify`);return g.assertValidity(),g}hasHighS(){return g(this.s)}toBytes(e=h){if(La(e),e===`der`)return me(za.hexFromSig(this));let t=o.toBytes(this.r),n=o.toBytes(this.s);if(e===`recovered`){if(this.recovery==null)throw Error(`recovery bit must be present`);return F(Uint8Array.of(this.recovery),t,n)}return F(t,n)}toHex(e){return N(this.toBytes(e))}assertValidity(){}static fromCompact(e){return y.fromBytes(ht(`sig`,e),`compact`)}static fromDER(e){return y.fromBytes(ht(`sig`,e),`der`)}normalizeS(){return this.hasHighS()?new y(this.r,o.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes(`der`)}toDERHex(){return N(this.toBytes(`der`))}toCompactRawBytes(){return this.toBytes(`compact`)}toCompactHex(){return N(this.toBytes(`compact`))}}let b=n.bits2int||function(e){if(e.length>8192)throw Error(`input is too large`);let t=dt(e),n=e.length*8-c;return n>0?t>>BigInt(n):t},x=n.bits2int_modN||function(e){return o.create(b(e))},ee=St(c);function S(e){return bt(`num < 2^`+c,e,Ba,ee),o.toBytes(e)}function C(e,n){return ct(e,void 0,`message`),n?ct(t(e),void 0,`prehashed message`):e}function w(t,n,i){if([`recovered`,`canonical`].some(e=>e in i))throw Error(`sign() legacy options not supported`);let{lowS:a,prehash:s,extraEntropy:c}=Ra(i,m);t=C(t,s);let l=x(t),u=Ga(o,n),d=[S(u),S(l)];if(c!=null&&c!==!1){let e=c===!0?r(p.secretKey):c;d.push(ht(`extraEntropy`,e))}let f=F(...d),h=l;function _(t){let n=b(t);if(!o.isValidNot0(n))return;let r=o.inv(n),i=e.BASE.multiply(n).toAffine(),s=o.create(i.x);if(s===Ba)return;let c=o.create(r*o.create(h+s*u));if(c===Ba)return;let l=(i.x===s?0:2)|Number(i.y&Va),d=c;return a&&g(c)&&(d=o.neg(c),l^=1),new y(s,d,l)}return{seed:f,k2sig:_}}function T(e,n,r={}){e=ht(`message`,e);let{seed:a,k2sig:s}=w(e,n,r);return Ct(t.outputLen,o.BYTES,i)(a,s)}function E(e){let t,n=typeof e==`string`||O(e),r=!n&&typeof e==`object`&&!!e&&typeof e.r==`bigint`&&typeof e.s==`bigint`;if(!n&&!r)throw Error(`invalid signature, expected Uint8Array, hex string or Signature instance`);if(r)t=new y(e.r,e.s);else if(n){try{t=y.fromBytes(ht(`sig`,e),`der`)}catch(e){if(!(e instanceof za.Err))throw e}if(!t)try{t=y.fromBytes(ht(`sig`,e),`compact`)}catch{return!1}}return t||!1}function D(t,n,r,i={}){let{lowS:a,prehash:s,format:c}=Ra(i,m);if(r=ht(`publicKey`,r),n=C(ht(`message`,n),s),`strict`in i)throw Error(`options.strict was renamed to lowS`);let l=c===void 0?E(t):y.fromBytes(ht(`sig`,t),c);if(l===!1)return!1;try{let t=e.fromBytes(r);if(a&&l.hasHighS())return!1;let{r:i,s}=l,c=x(n),u=o.inv(s),d=o.create(c*u),f=o.create(i*u),p=e.BASE.multiplyUnsafe(d).add(t.multiplyUnsafe(f));return p.is0()?!1:o.create(p.x)===i}catch{return!1}}function k(e,t,n={}){let{prehash:r}=Ra(n,m);return t=C(t,r),y.fromBytes(e,`recovered`).recoverPublicKey(t).toBytes()}return Object.freeze({keygen:l,getPublicKey:u,getSharedSecret:d,utils:f,lengths:p,Point:e,sign:T,verify:D,recoverPublicKey:k,Signature:y,hash:t})}function Za(e){let t={a:e.a,b:e.b,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},n=e.Fp,r=e.allowedPrivateKeyLengths?Array.from(new Set(e.allowedPrivateKeyLengths.map(e=>Math.ceil(e/2)))):void 0;return{CURVE:t,curveOpts:{Fp:n,Fn:$t(t.n,{BITS:e.nBitLength,allowedLengths:r,modFromBytes:e.wrapPrivateKey}),allowInfinityPoint:e.allowInfinityPoint,endo:e.endo,isTorsionFree:e.isTorsionFree,clearCofactor:e.clearCofactor,fromBytes:e.fromBytes,toBytes:e.toBytes}}}function Qa(e){let{CURVE:t,curveOpts:n}=Za(e),r={hmac:e.hmac,randomBytes:e.randomBytes,lowS:e.lowS,bits2int:e.bits2int,bits2int_modN:e.bits2int_modN};return{CURVE:t,curveOpts:n,hash:e.hash,ecdsaOpts:r}}function $a(e,t){let n=t.Point;return Object.assign({},t,{ProjectivePoint:n,CURVE:Object.assign({},e,Qt(n.Fn.ORDER,n.Fn.BITS))})}function eo(e){let{CURVE:t,curveOpts:n,hash:r,ecdsaOpts:i}=Qa(e);return $a(e,Xa(Ka(t,n),r,i))}function to(e,t){let n=t=>eo({...e,hash:t});return{...n(t),create:n}}var no={p:BigInt(`0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f`),n:BigInt(`0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141`),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt(`0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798`),Gy:BigInt(`0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8`)},ro={beta:BigInt(`0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee`),basises:[[BigInt(`0x3086d221a7d46bcde86c90e49284eb15`),-BigInt(`0xe4437ed6010e88286f547fa90abfe4c3`)],[BigInt(`0x114ca50f7a8e2f3f657c1108d9d44cfd8`),BigInt(`0x3086d221a7d46bcde86c90e49284eb15`)]]},io=BigInt(2);function ao(e){let t=no.p,n=BigInt(3),r=BigInt(6),i=BigInt(11),a=BigInt(22),o=BigInt(23),s=BigInt(44),c=BigInt(88),l=e*e*e%t,u=l*l*e%t,d=Rt(Rt(Rt(u,n,t)*u%t,n,t)*u%t,io,t)*l%t,f=Rt(d,i,t)*d%t,p=Rt(f,a,t)*f%t,m=Rt(p,s,t)*p%t,h=Rt(Rt(Rt(Rt(Rt(Rt(m,c,t)*m%t,s,t)*p%t,n,t)*u%t,o,t)*f%t,r,t)*l%t,io,t);if(!oo.eql(oo.sqr(h),e))throw Error(`Cannot find square root`);return h}var oo=$t(no.p,{sqrt:ao}),so=to({...no,Fp:oo,lowS:!0,endo:ro},Ze),co=r({Account:()=>So,AddressLookupTableAccount:()=>Is,AddressLookupTableInstruction:()=>Pl,AddressLookupTableProgram:()=>Fl,Authorized:()=>$l,BLOCKHASH_CACHE_TIMEOUT_MS:()=>Us,BPF_LOADER_DEPRECATED_PROGRAM_ID:()=>Co,BPF_LOADER_PROGRAM_ID:()=>xs,BpfLoader:()=>Ss,COMPUTE_BUDGET_INSTRUCTION_LAYOUTS:()=>Ll,ComputeBudgetInstruction:()=>Il,ComputeBudgetProgram:()=>Rl,Connection:()=>jl,Ed25519Program:()=>Ul,Enum:()=>_o,EpochSchedule:()=>js,FeeCalculatorLayout:()=>ds,Keypair:()=>Ml,LAMPORTS_PER_SOL:()=>Su,LOOKUP_TABLE_INSTRUCTION_LAYOUTS:()=>Nl,Loader:()=>bs,Lockup:()=>eu,MAX_SEED_LENGTH:()=>32,Message:()=>Uo,MessageAccountKeys:()=>ko,MessageV0:()=>Wo,NONCE_ACCOUNT_LENGTH:()=>ps,NonceAccount:()=>ms,PACKET_DATA_SIZE:()=>wo,PUBLIC_KEY_LENGTH:()=>32,PublicKey:()=>K,SIGNATURE_LENGTH_IN_BYTES:()=>64,SOLANA_SCHEMA:()=>vo,STAKE_CONFIG_ID:()=>Ql,STAKE_INSTRUCTION_LAYOUTS:()=>nu,SYSTEM_INSTRUCTION_LAYOUTS:()=>_s,SYSVAR_CLOCK_PUBKEY:()=>Qo,SYSVAR_EPOCH_SCHEDULE_PUBKEY:()=>$o,SYSVAR_INSTRUCTIONS_PUBKEY:()=>es,SYSVAR_RECENT_BLOCKHASHES_PUBKEY:()=>ts,SYSVAR_RENT_PUBKEY:()=>ns,SYSVAR_REWARDS_PUBKEY:()=>rs,SYSVAR_SLOT_HASHES_PUBKEY:()=>is,SYSVAR_SLOT_HISTORY_PUBKEY:()=>as,SYSVAR_STAKE_HISTORY_PUBKEY:()=>os,Secp256k1Program:()=>Xl,SendTransactionError:()=>ss,SolanaJSONRPCError:()=>X,SolanaJSONRPCErrorCode:()=>cs,StakeAuthorizationLayout:()=>ru,StakeInstruction:()=>tu,StakeProgram:()=>iu,Struct:()=>go,SystemInstruction:()=>gs,SystemProgram:()=>vs,Transaction:()=>Y,TransactionExpiredBlockheightExceededError:()=>Eo,TransactionExpiredNonceInvalidError:()=>Oo,TransactionExpiredTimeoutError:()=>Do,TransactionInstruction:()=>Jo,TransactionMessage:()=>Yo,TransactionStatus:()=>Ko,VALIDATOR_INFO_KEY:()=>uu,VERSION_PREFIX_MASK:()=>127,VOTE_PROGRAM_ID:()=>pu,ValidatorInfo:()=>fu,VersionedMessage:()=>Go,VersionedTransaction:()=>Xo,VoteAccount:()=>hu,VoteAuthorizationLayout:()=>cu,VoteInit:()=>au,VoteInstruction:()=>ou,VoteProgram:()=>lu,clusterApiUrl:()=>bu,sendAndConfirmRawTransaction:()=>xu,sendAndConfirmTransaction:()=>ls}),lo=Kn.utils.randomPrivateKey,uo=()=>{let e=Kn.utils.randomPrivateKey(),t=fo(e),n=new Uint8Array(64);return n.set(e),n.set(t,32),{publicKey:t,secretKey:n}},fo=Kn.getPublicKey;function po(e){try{return Kn.ExtendedPoint.fromHex(e),!0}catch{return!1}}var mo=(e,t)=>Kn.sign(e,t.slice(0,32)),ho=Kn.verify,G=e=>I.Buffer.isBuffer(e)?e:e instanceof Uint8Array?I.Buffer.from(e.buffer,e.byteOffset,e.byteLength):I.Buffer.from(e),go=class{constructor(e){Object.assign(this,e)}encode(){return I.Buffer.from((0,jr.serialize)(vo,this))}static decode(e){return(0,jr.deserialize)(vo,this,e)}static decodeUnchecked(e){return(0,jr.deserializeUnchecked)(vo,this,e)}},_o=class extends go{constructor(e){if(super(e),this.enum=``,Object.keys(e).length!==1)throw Error(`Enum can only take single value`);Object.keys(e).map(e=>{this.enum=e})}},vo=new Map,yo;function bo(e){return e._bn!==void 0}var xo=1,K=class e extends go{constructor(e){if(super({}),this._bn=void 0,bo(e))this._bn=e._bn;else{if(typeof e==`string`){let t=Ar.default.decode(e);if(t.length!=32)throw Error(`Invalid public key input`);this._bn=new kr.default(t)}else this._bn=new kr.default(e);if(this._bn.byteLength()>32)throw Error(`Invalid public key input`)}}static unique(){let t=new e(xo);return xo+=1,new e(t.toBuffer())}equals(e){return this._bn.eq(e._bn)}toBase58(){return Ar.default.encode(this.toBytes())}toJSON(){return this.toBase58()}toBytes(){let e=this.toBuffer();return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}toBuffer(){let e=this._bn.toArrayLike(I.Buffer);if(e.length===32)return e;let t=I.Buffer.alloc(32);return e.copy(t,32-e.length),t}get[Symbol.toStringTag](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(t,n,r){return new e($e(I.Buffer.concat([t.toBuffer(),I.Buffer.from(n),r.toBuffer()])))}static createProgramAddressSync(t,n){let r=I.Buffer.alloc(0);t.forEach(function(e){if(e.length>32)throw TypeError(`Max seed length exceeded`);r=I.Buffer.concat([r,G(e)])}),r=I.Buffer.concat([r,n.toBuffer(),I.Buffer.from(`ProgramDerivedAddress`)]);let i=$e(r);if(po(i))throw Error(`Invalid seeds, address must fall off the curve`);return new e(i)}static async createProgramAddress(e,t){return this.createProgramAddressSync(e,t)}static findProgramAddressSync(e,t){let n=255,r;for(;n!=0;){try{let i=e.concat(I.Buffer.from([n]));r=this.createProgramAddressSync(i,t)}catch(e){if(e instanceof TypeError)throw e;n--;continue}return[r,n]}throw Error(`Unable to find a viable program address nonce`)}static async findProgramAddress(e,t){return this.findProgramAddressSync(e,t)}static isOnCurve(t){return po(new e(t).toBytes())}};yo=K,K.default=new yo(`11111111111111111111111111111111`),vo.set(K,{kind:`struct`,fields:[[`_bn`,`u256`]]});var So=class{constructor(e){if(this._publicKey=void 0,this._secretKey=void 0,e){let t=G(e);if(e.length!==64)throw Error(`bad secret key size`);this._publicKey=t.slice(32,64),this._secretKey=t.slice(0,32)}else this._secretKey=G(lo()),this._publicKey=G(fo(this._secretKey))}get publicKey(){return new K(this._publicKey)}get secretKey(){return I.Buffer.concat([this._secretKey,this._publicKey],64)}},Co=new K(`BPFLoader1111111111111111111111111111111111`),wo=1232,To=64,Eo=class extends Error{constructor(e){super(`Signature ${e} has expired: block height exceeded.`),this.signature=void 0,this.signature=e}};Object.defineProperty(Eo.prototype,"name",{value:`TransactionExpiredBlockheightExceededError`});var Do=class extends Error{constructor(e,t){super(`Transaction was not confirmed in ${t.toFixed(2)} seconds. It is unknown if it succeeded or failed. Check signature ${e} using the Solana Explorer or CLI tools.`),this.signature=void 0,this.signature=e}};Object.defineProperty(Do.prototype,"name",{value:`TransactionExpiredTimeoutError`});var Oo=class extends Error{constructor(e){super(`Signature ${e} has expired: the nonce is no longer valid.`),this.signature=void 0,this.signature=e}};Object.defineProperty(Oo.prototype,"name",{value:`TransactionExpiredNonceInvalidError`});var ko=class{constructor(e,t){this.staticAccountKeys=void 0,this.accountKeysFromLookups=void 0,this.staticAccountKeys=e,this.accountKeysFromLookups=t}keySegments(){let e=[this.staticAccountKeys];return this.accountKeysFromLookups&&(e.push(this.accountKeysFromLookups.writable),e.push(this.accountKeysFromLookups.readonly)),e}get(e){for(let t of this.keySegments())if(e<t.length)return t[e];else e-=t.length}get length(){return this.keySegments().flat().length}compileInstructions(e){if(this.length>256)throw Error(`Account index overflow encountered during compilation`);let t=new Map;this.keySegments().flat().forEach((e,n)=>{t.set(e.toBase58(),n)});let n=e=>{let n=t.get(e.toBase58());if(n===void 0)throw Error(`Encountered an unknown instruction account key during compilation`);return n};return e.map(e=>({programIdIndex:n(e.programId),accountKeyIndexes:e.keys.map(e=>n(e.pubkey)),data:e.data}))}},q=(e=`publicKey`)=>L.blob(32,e),Ao=(e=`signature`)=>L.blob(64,e),jo=(e=`string`)=>{let t=L.struct([L.u32(`length`),L.u32(`lengthPadding`),L.blob(L.offset(L.u32(),-8),`chars`)],e),n=t.decode.bind(t),r=t.encode.bind(t),i=t;return i.decode=(e,t)=>n(e,t).chars.toString(),i.encode=(e,t,n)=>r({chars:I.Buffer.from(e,`utf8`)},t,n),i.alloc=e=>L.u32().span+L.u32().span+I.Buffer.from(e,`utf8`).length,i},Mo=(e=`authorized`)=>L.struct([q(`staker`),q(`withdrawer`)],e),No=(e=`lockup`)=>L.struct([L.ns64(`unixTimestamp`),L.ns64(`epoch`),q(`custodian`)],e),Po=(e=`voteInit`)=>L.struct([q(`nodePubkey`),q(`authorizedVoter`),q(`authorizedWithdrawer`),L.u8(`commission`)],e),Fo=(e=`voteAuthorizeWithSeedArgs`)=>L.struct([L.u32(`voteAuthorizationType`),q(`currentAuthorityDerivedKeyOwnerPubkey`),jo(`currentAuthorityDerivedKeySeed`),q(`newAuthorized`)],e);function Io(e,t){let n=e=>{if(e.span>=0)return e.span;if(typeof e.alloc==`function`)return e.alloc(t[e.property]);if(`count`in e&&`elementLayout`in e){let r=t[e.property];if(Array.isArray(r))return r.length*n(e.elementLayout)}else if(`fields`in e)return Io({layout:e},t[e.property]);return 0},r=0;return e.layout.fields.forEach(e=>{r+=n(e)}),r}function Lo(e){let t=0,n=0;for(;;){let r=e.shift();if(t|=(r&127)<<n*7,n+=1,!(r&128))break}return t}function Ro(e,t){let n=t;for(;;){let t=n&127;if(n>>=7,n==0){e.push(t);break}else t|=128,e.push(t)}}function J(e,t){if(!e)throw Error(t||`Assertion failed`)}var zo=class e{constructor(e,t){this.payer=void 0,this.keyMetaMap=void 0,this.payer=e,this.keyMetaMap=t}static compile(t,n){let r=new Map,i=e=>{let t=e.toBase58(),n=r.get(t);return n===void 0&&(n={isSigner:!1,isWritable:!1,isInvoked:!1},r.set(t,n)),n},a=i(n);a.isSigner=!0,a.isWritable=!0;for(let e of t){i(e.programId).isInvoked=!0;for(let t of e.keys){let e=i(t.pubkey);e.isSigner||=t.isSigner,e.isWritable||=t.isWritable}}return new e(n,r)}getMessageComponents(){let e=[...this.keyMetaMap.entries()];J(e.length<=256,`Max static account keys length exceeded`);let t=e.filter(([,e])=>e.isSigner&&e.isWritable),n=e.filter(([,e])=>e.isSigner&&!e.isWritable),r=e.filter(([,e])=>!e.isSigner&&e.isWritable),i=e.filter(([,e])=>!e.isSigner&&!e.isWritable),a={numRequiredSignatures:t.length+n.length,numReadonlySignedAccounts:n.length,numReadonlyUnsignedAccounts:i.length};{J(t.length>0,`Expected at least one writable signer key`);let[e]=t[0];J(e===this.payer.toBase58(),`Expected first writable signer key to be the fee payer`)}return[a,[...t.map(([e])=>new K(e)),...n.map(([e])=>new K(e)),...r.map(([e])=>new K(e)),...i.map(([e])=>new K(e))]]}extractTableLookup(e){let[t,n]=this.drainKeysFoundInLookupTable(e.state.addresses,e=>!e.isSigner&&!e.isInvoked&&e.isWritable),[r,i]=this.drainKeysFoundInLookupTable(e.state.addresses,e=>!e.isSigner&&!e.isInvoked&&!e.isWritable);if(!(t.length===0&&r.length===0))return[{accountKey:e.key,writableIndexes:t,readonlyIndexes:r},{writable:n,readonly:i}]}drainKeysFoundInLookupTable(e,t){let n=[],r=[];for(let[i,a]of this.keyMetaMap.entries())if(t(a)){let t=new K(i),a=e.findIndex(e=>e.equals(t));a>=0&&(J(a<256,`Max lookup table index exceeded`),n.push(a),r.push(t),this.keyMetaMap.delete(i))}return[n,r]}},Bo=`Reached end of buffer unexpectedly`;function Vo(e){if(e.length===0)throw Error(Bo);return e.shift()}function Ho(e,...t){let[n]=t;if(t.length===2?n+(t[1]??0)>e.length:n>=e.length)throw Error(Bo);return e.splice(...t)}var Uo=class e{constructor(e){this.header=void 0,this.accountKeys=void 0,this.recentBlockhash=void 0,this.instructions=void 0,this.indexToProgramIds=new Map,this.header=e.header,this.accountKeys=e.accountKeys.map(e=>new K(e)),this.recentBlockhash=e.recentBlockhash,this.instructions=e.instructions,this.instructions.forEach(e=>this.indexToProgramIds.set(e.programIdIndex,this.accountKeys[e.programIdIndex]))}get version(){return`legacy`}get staticAccountKeys(){return this.accountKeys}get compiledInstructions(){return this.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:Ar.default.decode(e.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new ko(this.staticAccountKeys)}static compile(t){let[n,r]=zo.compile(t.instructions,t.payerKey).getMessageComponents(),i=new ko(r).compileInstructions(t.instructions).map(e=>({programIdIndex:e.programIdIndex,accounts:e.accountKeyIndexes,data:Ar.default.encode(e.data)}));return new e({header:n,accountKeys:r,recentBlockhash:t.recentBlockhash,instructions:i})}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){let t=this.header.numRequiredSignatures;return e>=this.header.numRequiredSignatures?e-t<this.accountKeys.length-t-this.header.numReadonlyUnsignedAccounts:e<t-this.header.numReadonlySignedAccounts}isProgramId(e){return this.indexToProgramIds.has(e)}programIds(){return[...this.indexToProgramIds.values()]}nonProgramIds(){return this.accountKeys.filter((e,t)=>!this.isProgramId(t))}serialize(){let e=this.accountKeys.length,t=[];Ro(t,e);let n=this.instructions.map(e=>{let{accounts:t,programIdIndex:n}=e,r=Array.from(Ar.default.decode(e.data)),i=[];Ro(i,t.length);let a=[];return Ro(a,r.length),{programIdIndex:n,keyIndicesCount:I.Buffer.from(i),keyIndices:t,dataLength:I.Buffer.from(a),data:r}}),r=[];Ro(r,n.length);let i=I.Buffer.alloc(wo);I.Buffer.from(r).copy(i);let a=r.length;n.forEach(e=>{let t=L.struct([L.u8(`programIdIndex`),L.blob(e.keyIndicesCount.length,`keyIndicesCount`),L.seq(L.u8(`keyIndex`),e.keyIndices.length,`keyIndices`),L.blob(e.dataLength.length,`dataLength`),L.seq(L.u8(`userdatum`),e.data.length,`data`)]).encode(e,i,a);a+=t}),i=i.slice(0,a);let o=L.struct([L.blob(1,`numRequiredSignatures`),L.blob(1,`numReadonlySignedAccounts`),L.blob(1,`numReadonlyUnsignedAccounts`),L.blob(t.length,`keyCount`),L.seq(q(`key`),e,`keys`),q(`recentBlockhash`)]),s={numRequiredSignatures:I.Buffer.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:I.Buffer.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:I.Buffer.from([this.header.numReadonlyUnsignedAccounts]),keyCount:I.Buffer.from(t),keys:this.accountKeys.map(e=>G(e.toBytes())),recentBlockhash:Ar.default.decode(this.recentBlockhash)},c=I.Buffer.alloc(2048),l=o.encode(s,c);return i.copy(c,l),c.slice(0,l+i.length)}static from(t){let n=[...t],r=Vo(n);if(r!==(r&127))throw Error(`Versioned messages must be deserialized with VersionedMessage.deserialize()`);let i=Vo(n),a=Vo(n),o=Lo(n),s=[];for(let e=0;e<o;e++){let e=Ho(n,0,32);s.push(new K(I.Buffer.from(e)))}let c=Ho(n,0,32),l=Lo(n),u=[];for(let e=0;e<l;e++){let e=Vo(n),t=Ho(n,0,Lo(n)),r=Ho(n,0,Lo(n)),i=Ar.default.encode(I.Buffer.from(r));u.push({programIdIndex:e,accounts:t,data:i})}return new e({header:{numRequiredSignatures:r,numReadonlySignedAccounts:i,numReadonlyUnsignedAccounts:a},recentBlockhash:Ar.default.encode(I.Buffer.from(c)),accountKeys:s,instructions:u})}},Wo=class e{constructor(e){this.header=void 0,this.staticAccountKeys=void 0,this.recentBlockhash=void 0,this.compiledInstructions=void 0,this.addressTableLookups=void 0,this.header=e.header,this.staticAccountKeys=e.staticAccountKeys,this.recentBlockhash=e.recentBlockhash,this.compiledInstructions=e.compiledInstructions,this.addressTableLookups=e.addressTableLookups}get version(){return 0}get numAccountKeysFromLookups(){let e=0;for(let t of this.addressTableLookups)e+=t.readonlyIndexes.length+t.writableIndexes.length;return e}getAccountKeys(e){let t;if(e&&`accountKeysFromLookups`in e&&e.accountKeysFromLookups){if(this.numAccountKeysFromLookups!=e.accountKeysFromLookups.writable.length+e.accountKeysFromLookups.readonly.length)throw Error(`Failed to get account keys because of a mismatch in the number of account keys from lookups`);t=e.accountKeysFromLookups}else if(e&&`addressLookupTableAccounts`in e&&e.addressLookupTableAccounts)t=this.resolveAddressTableLookups(e.addressLookupTableAccounts);else if(this.addressTableLookups.length>0)throw Error(`Failed to get account keys because address table lookups were not resolved`);return new ko(this.staticAccountKeys,t)}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){let t=this.header.numRequiredSignatures,n=this.staticAccountKeys.length;return e>=n?e-n<this.addressTableLookups.reduce((e,t)=>e+t.writableIndexes.length,0):e>=this.header.numRequiredSignatures?e-t<n-t-this.header.numReadonlyUnsignedAccounts:e<t-this.header.numReadonlySignedAccounts}resolveAddressTableLookups(e){let t={writable:[],readonly:[]};for(let n of this.addressTableLookups){let r=e.find(e=>e.key.equals(n.accountKey));if(!r)throw Error(`Failed to find address lookup table account for table key ${n.accountKey.toBase58()}`);for(let e of n.writableIndexes)if(e<r.state.addresses.length)t.writable.push(r.state.addresses[e]);else throw Error(`Failed to find address for index ${e} in address lookup table ${n.accountKey.toBase58()}`);for(let e of n.readonlyIndexes)if(e<r.state.addresses.length)t.readonly.push(r.state.addresses[e]);else throw Error(`Failed to find address for index ${e} in address lookup table ${n.accountKey.toBase58()}`)}return t}static compile(t){let n=zo.compile(t.instructions,t.payerKey),r=[],i={writable:[],readonly:[]},a=t.addressLookupTableAccounts||[];for(let e of a){let t=n.extractTableLookup(e);if(t!==void 0){let[e,{writable:n,readonly:a}]=t;r.push(e),i.writable.push(...n),i.readonly.push(...a)}}let[o,s]=n.getMessageComponents(),c=new ko(s,i).compileInstructions(t.instructions);return new e({header:o,staticAccountKeys:s,recentBlockhash:t.recentBlockhash,compiledInstructions:c,addressTableLookups:r})}serialize(){let e=[];Ro(e,this.staticAccountKeys.length);let t=this.serializeInstructions(),n=[];Ro(n,this.compiledInstructions.length);let r=this.serializeAddressTableLookups(),i=[];Ro(i,this.addressTableLookups.length);let a=L.struct([L.u8(`prefix`),L.struct([L.u8(`numRequiredSignatures`),L.u8(`numReadonlySignedAccounts`),L.u8(`numReadonlyUnsignedAccounts`)],`header`),L.blob(e.length,`staticAccountKeysLength`),L.seq(q(),this.staticAccountKeys.length,`staticAccountKeys`),q(`recentBlockhash`),L.blob(n.length,`instructionsLength`),L.blob(t.length,`serializedInstructions`),L.blob(i.length,`addressTableLookupsLength`),L.blob(r.length,`serializedAddressTableLookups`)]),o=new Uint8Array(wo),s=a.encode({prefix:128,header:this.header,staticAccountKeysLength:new Uint8Array(e),staticAccountKeys:this.staticAccountKeys.map(e=>e.toBytes()),recentBlockhash:Ar.default.decode(this.recentBlockhash),instructionsLength:new Uint8Array(n),serializedInstructions:t,addressTableLookupsLength:new Uint8Array(i),serializedAddressTableLookups:r},o);return o.slice(0,s)}serializeInstructions(){let e=0,t=new Uint8Array(wo);for(let n of this.compiledInstructions){let r=[];Ro(r,n.accountKeyIndexes.length);let i=[];Ro(i,n.data.length);let a=L.struct([L.u8(`programIdIndex`),L.blob(r.length,`encodedAccountKeyIndexesLength`),L.seq(L.u8(),n.accountKeyIndexes.length,`accountKeyIndexes`),L.blob(i.length,`encodedDataLength`),L.blob(n.data.length,`data`)]);e+=a.encode({programIdIndex:n.programIdIndex,encodedAccountKeyIndexesLength:new Uint8Array(r),accountKeyIndexes:n.accountKeyIndexes,encodedDataLength:new Uint8Array(i),data:n.data},t,e)}return t.slice(0,e)}serializeAddressTableLookups(){let e=0,t=new Uint8Array(wo);for(let n of this.addressTableLookups){let r=[];Ro(r,n.writableIndexes.length);let i=[];Ro(i,n.readonlyIndexes.length);let a=L.struct([q(`accountKey`),L.blob(r.length,`encodedWritableIndexesLength`),L.seq(L.u8(),n.writableIndexes.length,`writableIndexes`),L.blob(i.length,`encodedReadonlyIndexesLength`),L.seq(L.u8(),n.readonlyIndexes.length,`readonlyIndexes`)]);e+=a.encode({accountKey:n.accountKey.toBytes(),encodedWritableIndexesLength:new Uint8Array(r),writableIndexes:n.writableIndexes,encodedReadonlyIndexesLength:new Uint8Array(i),readonlyIndexes:n.readonlyIndexes},t,e)}return t.slice(0,e)}static deserialize(t){let n=[...t],r=Vo(n),i=r&127;J(r!==i,`Expected versioned message but received legacy message`);let a=i;J(a===0,`Expected versioned message with version 0 but found version ${a}`);let o={numRequiredSignatures:Vo(n),numReadonlySignedAccounts:Vo(n),numReadonlyUnsignedAccounts:Vo(n)},s=[],c=Lo(n);for(let e=0;e<c;e++)s.push(new K(Ho(n,0,32)));let l=Ar.default.encode(Ho(n,0,32)),u=Lo(n),d=[];for(let e=0;e<u;e++){let e=Vo(n),t=Ho(n,0,Lo(n)),r=Lo(n),i=new Uint8Array(Ho(n,0,r));d.push({programIdIndex:e,accountKeyIndexes:t,data:i})}let f=Lo(n),p=[];for(let e=0;e<f;e++){let e=new K(Ho(n,0,32)),t=Ho(n,0,Lo(n)),r=Ho(n,0,Lo(n));p.push({accountKey:e,writableIndexes:t,readonlyIndexes:r})}return new e({header:o,staticAccountKeys:s,recentBlockhash:l,compiledInstructions:d,addressTableLookups:p})}},Go={deserializeMessageVersion(e){let t=e[0],n=t&127;return n===t?`legacy`:n},deserialize:e=>{let t=Go.deserializeMessageVersion(e);if(t===`legacy`)return Uo.from(e);if(t===0)return Wo.deserialize(e);throw Error(`Transaction message version ${t} deserialization is not supported`)}},Ko=function(e){return e[e.BLOCKHEIGHT_EXCEEDED=0]=`BLOCKHEIGHT_EXCEEDED`,e[e.PROCESSED=1]=`PROCESSED`,e[e.TIMED_OUT=2]=`TIMED_OUT`,e[e.NONCE_INVALID=3]=`NONCE_INVALID`,e}({}),qo=I.Buffer.alloc(64).fill(0),Jo=class{constructor(e){this.keys=void 0,this.programId=void 0,this.data=I.Buffer.alloc(0),this.programId=e.programId,this.keys=e.keys,e.data&&(this.data=e.data)}toJSON(){return{keys:this.keys.map(({pubkey:e,isSigner:t,isWritable:n})=>({pubkey:e.toJSON(),isSigner:t,isWritable:n})),programId:this.programId.toJSON(),data:[...this.data]}}},Y=class e{get signature(){return this.signatures.length>0?this.signatures[0].signature:null}constructor(e){if(this.signatures=[],this.feePayer=void 0,this.instructions=[],this.recentBlockhash=void 0,this.lastValidBlockHeight=void 0,this.nonceInfo=void 0,this.minNonceContextSlot=void 0,this._message=void 0,this._json=void 0,e)if(e.feePayer&&(this.feePayer=e.feePayer),e.signatures&&(this.signatures=e.signatures),Object.prototype.hasOwnProperty.call(e,`nonceInfo`)){let{minContextSlot:t,nonceInfo:n}=e;this.minNonceContextSlot=t,this.nonceInfo=n}else if(Object.prototype.hasOwnProperty.call(e,`lastValidBlockHeight`)){let{blockhash:t,lastValidBlockHeight:n}=e;this.recentBlockhash=t,this.lastValidBlockHeight=n}else{let{recentBlockhash:t,nonceInfo:n}=e;n&&(this.nonceInfo=n),this.recentBlockhash=t}}toJSON(){return{recentBlockhash:this.recentBlockhash||null,feePayer:this.feePayer?this.feePayer.toJSON():null,nonceInfo:this.nonceInfo?{nonce:this.nonceInfo.nonce,nonceInstruction:this.nonceInfo.nonceInstruction.toJSON()}:null,instructions:this.instructions.map(e=>e.toJSON()),signers:this.signatures.map(({publicKey:e})=>e.toJSON())}}add(...e){if(e.length===0)throw Error(`No instructions`);return e.forEach(e=>{`instructions`in e?this.instructions=this.instructions.concat(e.instructions):`data`in e&&`programId`in e&&`keys`in e?this.instructions.push(e):this.instructions.push(new Jo(e))}),this}compileMessage(){if(this._message&&JSON.stringify(this.toJSON())===JSON.stringify(this._json))return this._message;let e,t;if(this.nonceInfo?(e=this.nonceInfo.nonce,t=this.instructions[0]==this.nonceInfo.nonceInstruction?this.instructions:[this.nonceInfo.nonceInstruction,...this.instructions]):(e=this.recentBlockhash,t=this.instructions),!e)throw Error(`Transaction recentBlockhash required`);t.length<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 Error(`Transaction fee payer required`);for(let e=0;e<t.length;e++)if(t[e].programId===void 0)throw Error(`Transaction instruction index ${e} has undefined program id`);let r=[],i=[];t.forEach(e=>{e.keys.forEach(e=>{i.push({...e})});let t=e.programId.toString();r.includes(t)||r.push(t)}),r.forEach(e=>{i.push({pubkey:new K(e),isSigner:!1,isWritable:!1})});let a=[];i.forEach(e=>{let t=e.pubkey.toString(),n=a.findIndex(e=>e.pubkey.toString()===t);n>-1?(a[n].isWritable=a[n].isWritable||e.isWritable,a[n].isSigner=a[n].isSigner||e.isSigner):a.push(e)}),a.sort(function(e,t){return e.isSigner===t.isSigner?e.isWritable===t.isWritable?e.pubkey.toBase58().localeCompare(t.pubkey.toBase58(),`en`,{localeMatcher:`best fit`,usage:`sort`,sensitivity:`variant`,ignorePunctuation:!1,numeric:!1,caseFirst:`lower`}):e.isWritable?-1:1:e.isSigner?-1:1});let o=a.findIndex(e=>e.pubkey.equals(n));if(o>-1){let[e]=a.splice(o,1);e.isSigner=!0,e.isWritable=!0,a.unshift(e)}else a.unshift({pubkey:n,isSigner:!0,isWritable:!0});for(let e of this.signatures){let t=a.findIndex(t=>t.pubkey.equals(e.publicKey));if(t>-1)a[t].isSigner||(a[t].isSigner=!0,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 Error(`unknown signer: ${e.publicKey.toString()}`)}let s=0,c=0,l=0,u=[],d=[];a.forEach(({pubkey:e,isSigner:t,isWritable:n})=>{t?(u.push(e.toString()),s+=1,n||(c+=1)):(d.push(e.toString()),n||(l+=1))});let f=u.concat(d),p=t.map(e=>{let{data:t,programId:n}=e;return{programIdIndex:f.indexOf(n.toString()),accounts:e.keys.map(e=>f.indexOf(e.pubkey.toString())),data:Ar.default.encode(t)}});return p.forEach(e=>{J(e.programIdIndex>=0),e.accounts.forEach(e=>J(e>=0))}),new Uo({header:{numRequiredSignatures:s,numReadonlySignedAccounts:c,numReadonlyUnsignedAccounts:l},accountKeys:f,recentBlockhash:e,instructions:p})}_compile(){let e=this.compileMessage(),t=e.accountKeys.slice(0,e.header.numRequiredSignatures);return this.signatures.length===t.length&&this.signatures.every((e,n)=>t[n].equals(e.publicKey))||(this.signatures=t.map(e=>({signature:null,publicKey:e}))),e}serializeMessage(){return this._compile().serialize()}async getEstimatedFee(e){return(await e.getFeeForMessage(this.compileMessage())).value}setSigners(...e){if(e.length===0)throw Error(`No signers`);let t=new Set;this.signatures=e.filter(e=>{let n=e.toString();return t.has(n)?!1:(t.add(n),!0)}).map(e=>({signature:null,publicKey:e}))}sign(...e){if(e.length===0)throw Error(`No signers`);let t=new Set,n=[];for(let r of e){let e=r.publicKey.toString();t.has(e)||(t.add(e),n.push(r))}this.signatures=n.map(e=>({signature:null,publicKey:e.publicKey}));let r=this._compile();this._partialSign(r,...n)}partialSign(...e){if(e.length===0)throw Error(`No signers`);let t=new Set,n=[];for(let r of e){let e=r.publicKey.toString();t.has(e)||(t.add(e),n.push(r))}let r=this._compile();this._partialSign(r,...n)}_partialSign(e,...t){let n=e.serialize();t.forEach(e=>{let t=mo(n,e.secretKey);this._addSignature(e.publicKey,G(t))})}addSignature(e,t){this._compile(),this._addSignature(e,t)}_addSignature(e,t){J(t.length===64);let n=this.signatures.findIndex(t=>e.equals(t.publicKey));if(n<0)throw Error(`unknown signer: ${e.toString()}`);this.signatures[n].signature=I.Buffer.from(t)}verifySignatures(e=!0){return!this._getMessageSignednessErrors(this.serializeMessage(),e)}_getMessageSignednessErrors(e,t){let n={};for(let{signature:r,publicKey:i}of this.signatures)r===null?t&&(n.missing||=[]).push(i):ho(r,e,i.toBytes())||(n.invalid||=[]).push(i);return n.invalid||n.missing?n:void 0}serialize(e){let{requireAllSignatures:t,verifySignatures:n}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},e),r=this.serializeMessage();if(n){let e=this._getMessageSignednessErrors(r,t);if(e){let t=`Signature verification failed.`;throw e.invalid&&(t+=`\nInvalid signature for public key${e.invalid.length===1?``:`(s)`} [\`${e.invalid.map(e=>e.toBase58()).join("`, `")}\`].`),e.missing&&(t+=`\nMissing signature for public key${e.missing.length===1?``:`(s)`} [\`${e.missing.map(e=>e.toBase58()).join("`, `")}\`].`),Error(t)}}return this._serialize(r)}_serialize(e){let{signatures:t}=this,n=[];Ro(n,t.length);let r=n.length+t.length*64+e.length,i=I.Buffer.alloc(r);return J(t.length<256),I.Buffer.from(n).copy(i,0),t.forEach(({signature:e},t)=>{e!==null&&(J(e.length===64,`signature has invalid length`),I.Buffer.from(e).copy(i,n.length+t*64))}),e.copy(i,n.length+t.length*64),J(i.length<=wo,`Transaction too large: ${i.length} > ${wo}`),i}get keys(){return J(this.instructions.length===1),this.instructions[0].keys.map(e=>e.pubkey)}get programId(){return J(this.instructions.length===1),this.instructions[0].programId}get data(){return J(this.instructions.length===1),this.instructions[0].data}static from(t){let n=[...t],r=Lo(n),i=[];for(let e=0;e<r;e++){let e=Ho(n,0,64);i.push(Ar.default.encode(I.Buffer.from(e)))}return e.populate(Uo.from(n),i)}static populate(t,n=[]){let r=new e;return r.recentBlockhash=t.recentBlockhash,t.header.numRequiredSignatures>0&&(r.feePayer=t.accountKeys[0]),n.forEach((e,n)=>{let i={signature:e==Ar.default.encode(qo)?null:Ar.default.decode(e),publicKey:t.accountKeys[n]};r.signatures.push(i)}),t.instructions.forEach(e=>{let n=e.accounts.map(e=>{let n=t.accountKeys[e];return{pubkey:n,isSigner:r.signatures.some(e=>e.publicKey.toString()===n.toString())||t.isAccountSigner(e),isWritable:t.isAccountWritable(e)}});r.instructions.push(new Jo({keys:n,programId:t.accountKeys[e.programIdIndex],data:Ar.default.decode(e.data)}))}),r._message=t,r._json=r.toJSON(),r}},Yo=class e{constructor(e){this.payerKey=void 0,this.instructions=void 0,this.recentBlockhash=void 0,this.payerKey=e.payerKey,this.instructions=e.instructions,this.recentBlockhash=e.recentBlockhash}static decompile(t,n){let{header:r,compiledInstructions:i,recentBlockhash:a}=t,{numRequiredSignatures:o,numReadonlySignedAccounts:s,numReadonlyUnsignedAccounts:c}=r,l=o-s;J(l>0,`Message header is invalid`);let u=t.staticAccountKeys.length-o-c;J(u>=0,`Message header is invalid`);let d=t.getAccountKeys(n),f=d.get(0);if(f===void 0)throw Error(`Failed to decompile message because no account keys were found`);let p=[];for(let e of i){let t=[];for(let n of e.accountKeyIndexes){let e=d.get(n);if(e===void 0)throw Error(`Failed to find key for account key index ${n}`);let i=n<o,a;a=i?n<l:n<d.staticAccountKeys.length?n-o<u:n-d.staticAccountKeys.length<d.accountKeysFromLookups.writable.length,t.push({pubkey:e,isSigner:n<r.numRequiredSignatures,isWritable:a})}let n=d.get(e.programIdIndex);if(n===void 0)throw Error(`Failed to find program id for program id index ${e.programIdIndex}`);p.push(new Jo({programId:n,data:G(e.data),keys:t}))}return new e({payerKey:f,instructions:p,recentBlockhash:a})}compileToLegacyMessage(){return Uo.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions})}compileToV0Message(e){return Wo.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions,addressLookupTableAccounts:e})}},Xo=class e{get version(){return this.message.version}constructor(e,t){if(this.signatures=void 0,this.message=void 0,t!==void 0)J(t.length===e.header.numRequiredSignatures,`Expected signatures length to be equal to the number of required signatures`),this.signatures=t;else{let t=[];for(let n=0;n<e.header.numRequiredSignatures;n++)t.push(new Uint8Array(64));this.signatures=t}this.message=e}serialize(){let e=this.message.serialize(),t=[];Ro(t,this.signatures.length);let n=L.struct([L.blob(t.length,`encodedSignaturesLength`),L.seq(Ao(),this.signatures.length,`signatures`),L.blob(e.length,`serializedMessage`)]),r=new Uint8Array(2048),i=n.encode({encodedSignaturesLength:new Uint8Array(t),signatures:this.signatures,serializedMessage:e},r);return r.slice(0,i)}static deserialize(t){let n=[...t],r=[],i=Lo(n);for(let e=0;e<i;e++)r.push(new Uint8Array(Ho(n,0,64)));return new e(Go.deserialize(new Uint8Array(n)),r)}sign(e){let t=this.message.serialize(),n=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures);for(let r of e){let e=n.findIndex(e=>e.equals(r.publicKey));J(e>=0,`Cannot sign with non signer key ${r.publicKey.toBase58()}`),this.signatures[e]=mo(t,r.secretKey)}}addSignature(e,t){J(t.byteLength===64,`Signature must be 64 bytes long`);let n=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures).findIndex(t=>t.equals(e));J(n>=0,`Can not add signature; \`${e.toBase58()}\` is not required to sign this transaction`),this.signatures[n]=t}},Zo=1e3/(160/64),Qo=new K(`SysvarC1ock11111111111111111111111111111111`),$o=new K(`SysvarEpochSchedu1e111111111111111111111111`),es=new K(`Sysvar1nstructions1111111111111111111111111`),ts=new K(`SysvarRecentB1ockHashes11111111111111111111`),ns=new K(`SysvarRent111111111111111111111111111111111`),rs=new K(`SysvarRewards111111111111111111111111111111`),is=new K(`SysvarS1otHashes111111111111111111111111111`),as=new K(`SysvarS1otHistory11111111111111111111111111`),os=new K(`SysvarStakeHistory1111111111111111111111111`),ss=class extends Error{constructor({action:e,signature:t,transactionMessage:n,logs:r}){let i=r?`Logs: \n${JSON.stringify(r.slice(-10),null,2)}. `:``,a="\nCatch the `SendTransactionError` and call `getLogs()` on it for full details.",o;switch(e){case`send`:o=`Transaction ${t} resulted in an error. \n${n}. `+i+a;break;case`simulate`:o=`Simulation failed. \nMessage: ${n}. \n`+i+a;break;default:o=`Unknown action '${(e=>e)(e)}'`}super(o),this.signature=void 0,this.transactionMessage=void 0,this.transactionLogs=void 0,this.signature=t,this.transactionMessage=n,this.transactionLogs=r||void 0}get transactionError(){return{message:this.transactionMessage,logs:Array.isArray(this.transactionLogs)?this.transactionLogs:void 0}}get logs(){let e=this.transactionLogs;if(!(typeof e==`object`&&e&&`then`in e))return e}async getLogs(e){return Array.isArray(this.transactionLogs)||(this.transactionLogs=new Promise((t,n)=>{e.getTransaction(this.signature).then(e=>{if(e&&e.meta&&e.meta.logMessages){let n=e.meta.logMessages;this.transactionLogs=n,t(n)}else n(Error(`Log messages not found`))}).catch(n)})),await this.transactionLogs}},cs={JSON_RPC_SERVER_ERROR_BLOCK_CLEANED_UP:-32001,JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE:-32002,JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE:-32003,JSON_RPC_SERVER_ERROR_BLOCK_NOT_AVAILABLE:-32004,JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY:-32005,JSON_RPC_SERVER_ERROR_TRANSACTION_PRECOMPILE_VERIFICATION_FAILURE:-32006,JSON_RPC_SERVER_ERROR_SLOT_SKIPPED:-32007,JSON_RPC_SERVER_ERROR_NO_SNAPSHOT:-32008,JSON_RPC_SERVER_ERROR_LONG_TERM_STORAGE_SLOT_SKIPPED:-32009,JSON_RPC_SERVER_ERROR_KEY_EXCLUDED_FROM_SECONDARY_INDEX:-32010,JSON_RPC_SERVER_ERROR_TRANSACTION_HISTORY_NOT_AVAILABLE:-32011,JSON_RPC_SCAN_ERROR:-32012,JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_LEN_MISMATCH:-32013,JSON_RPC_SERVER_ERROR_BLOCK_STATUS_NOT_AVAILABLE_YET:-32014,JSON_RPC_SERVER_ERROR_UNSUPPORTED_TRANSACTION_VERSION:-32015,JSON_RPC_SERVER_ERROR_MIN_CONTEXT_SLOT_NOT_REACHED:-32016},X=class extends Error{constructor({code:e,message:t,data:n},r){super(r==null?t:`${r}: ${t}`),this.code=void 0,this.data=void 0,this.code=e,this.data=n,this.name=`SolanaJSONRPCError`}};async function ls(e,t,n,r){let i=r&&{skipPreflight:r.skipPreflight,preflightCommitment:r.preflightCommitment||r.commitment,maxRetries:r.maxRetries,minContextSlot:r.minContextSlot},a=await e.sendTransaction(t,n,i),o;if(t.recentBlockhash!=null&&t.lastValidBlockHeight!=null)o=(await e.confirmTransaction({abortSignal:r?.abortSignal,signature:a,blockhash:t.recentBlockhash,lastValidBlockHeight:t.lastValidBlockHeight},r&&r.commitment)).value;else if(t.minNonceContextSlot!=null&&t.nonceInfo!=null){let{nonceInstruction:n}=t.nonceInfo,i=n.keys[0].pubkey;o=(await e.confirmTransaction({abortSignal:r?.abortSignal,minContextSlot:t.minNonceContextSlot,nonceAccountPubkey:i,nonceValue:t.nonceInfo.nonce,signature:a},r&&r.commitment)).value}else r?.abortSignal!=null&&console.warn("sendAndConfirmTransaction(): A transaction with a deprecated confirmation strategy was supplied along with an `abortSignal`. Only transactions having `lastValidBlockHeight` or a combination of `nonceInfo` and `minNonceContextSlot` are abortable."),o=(await e.confirmTransaction(a,r&&r.commitment)).value;if(o.err)throw a==null?Error(`Transaction ${a} failed (${JSON.stringify(o)})`):new ss({action:`send`,signature:a,transactionMessage:`Status: (${JSON.stringify(o)})`});return a}function us(e){return new Promise(t=>setTimeout(t,e))}function Z(e,t){let n=e.layout.span>=0?e.layout.span:Io(e,t),r=I.Buffer.alloc(n),i=Object.assign({instruction:e.index},t);return e.layout.encode(i,r),r}function Q(e,t){let n;try{n=e.layout.decode(t)}catch(e){throw Error(`invalid instruction; `+e)}if(n.instruction!==e.index)throw Error(`invalid instruction; instruction index mismatch ${n.instruction} != ${e.index}`);return n}var ds=L.nu64(`lamportsPerSignature`),fs=L.struct([L.u32(`version`),L.u32(`state`),q(`authorizedPubkey`),q(`nonce`),L.struct([ds],`feeCalculator`)]),ps=fs.span,ms=class e{constructor(e){this.authorizedPubkey=void 0,this.nonce=void 0,this.feeCalculator=void 0,this.authorizedPubkey=e.authorizedPubkey,this.nonce=e.nonce,this.feeCalculator=e.feeCalculator}static fromAccountData(t){let n=fs.decode(G(t),0);return new e({authorizedPubkey:new K(n.authorizedPubkey),nonce:new K(n.nonce).toString(),feeCalculator:n.feeCalculator})}};function hs(e){let t=(0,L.blob)(8,e),n=t.decode.bind(t),r=t.encode.bind(t),i=t,a=ri();return i.decode=(e,t)=>{let r=n(e,t);return a.decode(r)},i.encode=(e,t,n)=>r(a.encode(e),t,n),i}var gs=class{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);let t=L.u32(`instruction`).decode(e.data),n;for(let[e,r]of Object.entries(_s))if(r.index==t){n=e;break}if(!n)throw Error(`Instruction type incorrect; not a SystemInstruction`);return n}static decodeCreateAccount(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);let{lamports:t,space:n,programId:r}=Q(_s.Create,e.data);return{fromPubkey:e.keys[0].pubkey,newAccountPubkey:e.keys[1].pubkey,lamports:t,space:n,programId:new K(r)}}static decodeTransfer(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);let{lamports:t}=Q(_s.Transfer,e.data);return{fromPubkey:e.keys[0].pubkey,toPubkey:e.keys[1].pubkey,lamports:t}}static decodeTransferWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);let{lamports:t,seed:n,programId:r}=Q(_s.TransferWithSeed,e.data);return{fromPubkey:e.keys[0].pubkey,basePubkey:e.keys[1].pubkey,toPubkey:e.keys[2].pubkey,lamports:t,seed:n,programId:new K(r)}}static decodeAllocate(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);let{space:t}=Q(_s.Allocate,e.data);return{accountPubkey:e.keys[0].pubkey,space:t}}static decodeAllocateWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);let{base:t,seed:n,space:r,programId:i}=Q(_s.AllocateWithSeed,e.data);return{accountPubkey:e.keys[0].pubkey,basePubkey:new K(t),seed:n,space:r,programId:new K(i)}}static decodeAssign(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);let{programId:t}=Q(_s.Assign,e.data);return{accountPubkey:e.keys[0].pubkey,programId:new K(t)}}static decodeAssignWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);let{base:t,seed:n,programId:r}=Q(_s.AssignWithSeed,e.data);return{accountPubkey:e.keys[0].pubkey,basePubkey:new K(t),seed:n,programId:new K(r)}}static decodeCreateWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);let{base:t,seed:n,lamports:r,space:i,programId:a}=Q(_s.CreateWithSeed,e.data);return{fromPubkey:e.keys[0].pubkey,newAccountPubkey:e.keys[1].pubkey,basePubkey:new K(t),seed:n,lamports:r,space:i,programId:new K(a)}}static decodeNonceInitialize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);let{authorized:t}=Q(_s.InitializeNonceAccount,e.data);return{noncePubkey:e.keys[0].pubkey,authorizedPubkey:new K(t)}}static decodeNonceAdvance(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3),Q(_s.AdvanceNonceAccount,e.data),{noncePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey}}static decodeNonceWithdraw(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,5);let{lamports:t}=Q(_s.WithdrawNonceAccount,e.data);return{noncePubkey:e.keys[0].pubkey,toPubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[4].pubkey,lamports:t}}static decodeNonceAuthorize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);let{authorized:t}=Q(_s.AuthorizeNonceAccount,e.data);return{noncePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[1].pubkey,newAuthorizedPubkey:new K(t)}}static checkProgramId(e){if(!e.equals(vs.programId))throw Error(`invalid instruction; programId is not SystemProgram`)}static checkKeyLength(e,t){if(e.length<t)throw Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}},_s=Object.freeze({Create:{index:0,layout:L.struct([L.u32(`instruction`),L.ns64(`lamports`),L.ns64(`space`),q(`programId`)])},Assign:{index:1,layout:L.struct([L.u32(`instruction`),q(`programId`)])},Transfer:{index:2,layout:L.struct([L.u32(`instruction`),hs(`lamports`)])},CreateWithSeed:{index:3,layout:L.struct([L.u32(`instruction`),q(`base`),jo(`seed`),L.ns64(`lamports`),L.ns64(`space`),q(`programId`)])},AdvanceNonceAccount:{index:4,layout:L.struct([L.u32(`instruction`)])},WithdrawNonceAccount:{index:5,layout:L.struct([L.u32(`instruction`),L.ns64(`lamports`)])},InitializeNonceAccount:{index:6,layout:L.struct([L.u32(`instruction`),q(`authorized`)])},AuthorizeNonceAccount:{index:7,layout:L.struct([L.u32(`instruction`),q(`authorized`)])},Allocate:{index:8,layout:L.struct([L.u32(`instruction`),L.ns64(`space`)])},AllocateWithSeed:{index:9,layout:L.struct([L.u32(`instruction`),q(`base`),jo(`seed`),L.ns64(`space`),q(`programId`)])},AssignWithSeed:{index:10,layout:L.struct([L.u32(`instruction`),q(`base`),jo(`seed`),q(`programId`)])},TransferWithSeed:{index:11,layout:L.struct([L.u32(`instruction`),hs(`lamports`),jo(`seed`),q(`programId`)])},UpgradeNonceAccount:{index:12,layout:L.struct([L.u32(`instruction`)])}}),vs=class e{constructor(){}static createAccount(e){let t=_s.Create,n=Z(t,{lamports:e.lamports,space:e.space,programId:G(e.programId.toBuffer())});return new Jo({keys:[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.newAccountPubkey,isSigner:!0,isWritable:!0}],programId:this.programId,data:n})}static transfer(e){let t,n;if(`basePubkey`in e){let r=_s.TransferWithSeed;t=Z(r,{lamports:BigInt(e.lamports),seed:e.seed,programId:G(e.programId.toBuffer())}),n=[{pubkey:e.fromPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0}]}else{let r=_s.Transfer;t=Z(r,{lamports:BigInt(e.lamports)}),n=[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0}]}return new Jo({keys:n,programId:this.programId,data:t})}static assign(e){let t,n;if(`basePubkey`in e){let r=_s.AssignWithSeed;t=Z(r,{base:G(e.basePubkey.toBuffer()),seed:e.seed,programId:G(e.programId.toBuffer())}),n=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]}else{let r=_s.Assign;t=Z(r,{programId:G(e.programId.toBuffer())}),n=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]}return new Jo({keys:n,programId:this.programId,data:t})}static createAccountWithSeed(e){let t=_s.CreateWithSeed,n=Z(t,{base:G(e.basePubkey.toBuffer()),seed:e.seed,lamports:e.lamports,space:e.space,programId:G(e.programId.toBuffer())}),r=[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.newAccountPubkey,isSigner:!1,isWritable:!0}];return e.basePubkey.equals(e.fromPubkey)||r.push({pubkey:e.basePubkey,isSigner:!0,isWritable:!1}),new Jo({keys:r,programId:this.programId,data:n})}static createNonceAccount(t){let n=new Y;`basePubkey`in t&&`seed`in t?n.add(e.createAccountWithSeed({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,basePubkey:t.basePubkey,seed:t.seed,lamports:t.lamports,space:ps,programId:this.programId})):n.add(e.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,lamports:t.lamports,space:ps,programId:this.programId}));let r={noncePubkey:t.noncePubkey,authorizedPubkey:t.authorizedPubkey};return n.add(this.nonceInitialize(r)),n}static nonceInitialize(e){let t=_s.InitializeNonceAccount,n=Z(t,{authorized:G(e.authorizedPubkey.toBuffer())});return new Jo({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:ts,isSigner:!1,isWritable:!1},{pubkey:ns,isSigner:!1,isWritable:!1}],programId:this.programId,data:n})}static nonceAdvance(e){let t=_s.AdvanceNonceAccount,n=Z(t);return new Jo({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:ts,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static nonceWithdraw(e){let t=_s.WithdrawNonceAccount,n=Z(t,{lamports:e.lamports});return new Jo({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0},{pubkey:ts,isSigner:!1,isWritable:!1},{pubkey:ns,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static nonceAuthorize(e){let t=_s.AuthorizeNonceAccount,n=Z(t,{authorized:G(e.newAuthorizedPubkey.toBuffer())});return new Jo({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static allocate(e){let t,n;if(`basePubkey`in e){let r=_s.AllocateWithSeed;t=Z(r,{base:G(e.basePubkey.toBuffer()),seed:e.seed,space:e.space,programId:G(e.programId.toBuffer())}),n=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]}else{let r=_s.Allocate;t=Z(r,{space:e.space}),n=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]}return new Jo({keys:n,programId:this.programId,data:t})}};vs.programId=new K(`11111111111111111111111111111111`);var ys=wo-300,bs=class e{constructor(){}static getMinNumSignatures(t){return 2*(Math.ceil(t/e.chunkSize)+1+1)}static async load(t,n,r,i,a){{let e=await t.getMinimumBalanceForRentExemption(a.length),o=await t.getAccountInfo(r.publicKey,`confirmed`),s=null;if(o!==null){if(o.executable)return console.error(`Program load failed, account is already executable`),!1;o.data.length!==a.length&&(s||=new Y,s.add(vs.allocate({accountPubkey:r.publicKey,space:a.length}))),o.owner.equals(i)||(s||=new Y,s.add(vs.assign({accountPubkey:r.publicKey,programId:i}))),o.lamports<e&&(s||=new Y,s.add(vs.transfer({fromPubkey:n.publicKey,toPubkey:r.publicKey,lamports:e-o.lamports})))}else s=new Y().add(vs.createAccount({fromPubkey:n.publicKey,newAccountPubkey:r.publicKey,lamports:e>0?e:1,space:a.length,programId:i}));s!==null&&await ls(t,s,[n,r],{commitment:`confirmed`})}let o=L.struct([L.u32(`instruction`),L.u32(`offset`),L.u32(`bytesLength`),L.u32(`bytesLengthPadding`),L.seq(L.u8(`byte`),L.offset(L.u32(),-8),`bytes`)]),s=e.chunkSize,c=0,l=a,u=[];for(;l.length>0;){let e=l.slice(0,s),a=I.Buffer.alloc(s+16);o.encode({instruction:0,offset:c,bytes:e,bytesLength:0,bytesLengthPadding:0},a);let d=new Y().add({keys:[{pubkey:r.publicKey,isSigner:!0,isWritable:!0}],programId:i,data:a});u.push(ls(t,d,[n,r],{commitment:`confirmed`})),t._rpcEndpoint.includes(`solana.com`)&&await us(1e3/4),c+=s,l=l.slice(s)}await Promise.all(u);{let e=L.struct([L.u32(`instruction`)]),a=I.Buffer.alloc(e.span);e.encode({instruction:1},a);let o=new Y().add({keys:[{pubkey:r.publicKey,isSigner:!0,isWritable:!0},{pubkey:ns,isSigner:!1,isWritable:!1}],programId:i,data:a}),s=`processed`,c=await t.sendTransaction(o,[n,r],{preflightCommitment:s}),{context:l,value:u}=await t.confirmTransaction({signature:c,lastValidBlockHeight:o.lastValidBlockHeight,blockhash:o.recentBlockhash},s);if(u.err)throw Error(`Transaction ${c} failed (${JSON.stringify(u)})`);for(;;){try{if(await t.getSlot({commitment:s})>l.slot)break}catch{}await new Promise(e=>setTimeout(e,Math.round(Zo/2)))}}return!0}};bs.chunkSize=ys;var xs=new K(`BPFLoader2111111111111111111111111111111111`),Ss=class{static getMinNumSignatures(e){return bs.getMinNumSignatures(e)}static load(e,t,n,r,i){return bs.load(e,t,n,i,r)}};function Cs(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}var ws,Ts;function Es(){if(Ts)return ws;Ts=1;var e=Object.prototype.toString,t=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};function n(r,i){var a,o,s,c,l,u,d;if(r===!0)return`true`;if(r===!1)return`false`;switch(typeof r){case`object`:if(r===null)return null;if(r.toJSON&&typeof r.toJSON==`function`)return n(r.toJSON(),i);if(d=e.call(r),d===`[object Array]`){for(s=`[`,o=r.length-1,a=0;a<o;a++)s+=n(r[a],!0)+`,`;return o>-1&&(s+=n(r[a],!0)),s+`]`}else if(d===`[object Object]`){for(c=t(r).sort(),o=c.length,s=``,a=0;a<o;)l=c[a],u=n(r[l],!1),u!==void 0&&(s&&(s+=`,`),s+=JSON.stringify(l)+`:`+u),a++;return`{`+s+`}`}else return JSON.stringify(r);case`function`:case`undefined`:return i?null:void 0;case`string`:return JSON.stringify(r);default:return isFinite(r)?r:null}}return ws=function(e){var t=n(e,!1);if(t!==void 0)return``+t},ws}var Ds=Cs(Es()),Os=32;function ks(e){let t=0;for(;e>1;)e/=2,t++;return t}function As(e){return e===0?1:(e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,e|=e>>32,e+1)}var js=class{constructor(e,t,n,r,i){this.slotsPerEpoch=void 0,this.leaderScheduleSlotOffset=void 0,this.warmup=void 0,this.firstNormalEpoch=void 0,this.firstNormalSlot=void 0,this.slotsPerEpoch=e,this.leaderScheduleSlotOffset=t,this.warmup=n,this.firstNormalEpoch=r,this.firstNormalSlot=i}getEpoch(e){return this.getEpochAndSlotIndex(e)[0]}getEpochAndSlotIndex(e){if(e<this.firstNormalSlot){let t=ks(As(e+Os+1))-ks(Os)-1;return[t,e-(this.getSlotsInEpoch(t)-Os)]}else{let t=e-this.firstNormalSlot,n=Math.floor(t/this.slotsPerEpoch);return[this.firstNormalEpoch+n,t%this.slotsPerEpoch]}}getFirstSlotInEpoch(e){return e<=this.firstNormalEpoch?(2**e-1)*Os:(e-this.firstNormalEpoch)*this.slotsPerEpoch+this.firstNormalSlot}getLastSlotInEpoch(e){return this.getFirstSlotInEpoch(e)+this.getSlotsInEpoch(e)-1}getSlotsInEpoch(e){return e<this.firstNormalEpoch?2**(e+ks(Os)):this.slotsPerEpoch}},Ms=globalThis.fetch,Ns=class extends Pa{constructor(e,t,n){super(e=>{let n=Ma(e,{autoconnect:!0,max_reconnects:5,reconnect:!0,reconnect_interval:1e3,...t});return`socket`in n?this.underlyingSocket=n.socket:this.underlyingSocket=n,n},e,t,n),this.underlyingSocket=void 0}call(...e){let t=this.underlyingSocket?.readyState;return t===1?super.call(...e):Promise.reject(Error("Tried to call a JSON-RPC method `"+e[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+t+`)`))}notify(...e){let t=this.underlyingSocket?.readyState;return t===1?super.notify(...e):Promise.reject(Error("Tried to send a JSON-RPC notification `"+e[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+t+`)`))}};function Ps(e,t){let n;try{n=e.layout.decode(t)}catch(e){throw Error(`invalid instruction; `+e)}if(n.typeIndex!==e.index)throw Error(`invalid account data; account type mismatch ${n.typeIndex} != ${e.index}`);return n}var Fs=56,Is=class{constructor(e){this.key=void 0,this.state=void 0,this.key=e.key,this.state=e.state}isActive(){let e=BigInt(`0xffffffffffffffff`);return this.state.deactivationSlot===e}static deserialize(e){let t=Ps(Ls,e),n=e.length-Fs;J(n>=0,`lookup table is invalid`),J(n%32==0,`lookup table is invalid`);let r=n/32,{addresses:i}=L.struct([L.seq(q(),r,`addresses`)]).decode(e.slice(Fs));return{deactivationSlot:t.deactivationSlot,lastExtendedSlot:t.lastExtendedSlot,lastExtendedSlotStartIndex:t.lastExtendedStartIndex,authority:t.authority.length===0?void 0:new K(t.authority[0]),addresses:i.map(e=>new K(e))}}},Ls={index:1,layout:L.struct([L.u32(`typeIndex`),hs(`deactivationSlot`),L.nu64(`lastExtendedSlot`),L.u8(`lastExtendedStartIndex`),L.u8(),L.seq(q(),L.offset(L.u8(),-1),`authority`)])},Rs=/^[^:]+:\/\/([^:[]+|\[[^\]]+\])(:\d+)?(.*)/i;function zs(e){let t=e.match(Rs);if(t==null)throw TypeError(`Failed to validate endpoint URL \`${e}\``);let[n,r,i,a]=t,o=e.startsWith(`https:`)?`wss:`:`ws:`,s=i==null?null:parseInt(i.slice(1),10);return`${o}//${r}${s==null?``:`:${s+1}`}${a}`}var Bs=Oi(xi(K),U(),e=>new K(e)),Vs=Ti([U(),Si(`base64`)]),Hs=Oi(xi(I.Buffer),Vs,e=>I.Buffer.from(e[0],`base64`)),Us=30*1e3;function Ws(e){if(/^https?:/.test(e)===!1)throw TypeError("Endpoint URL must start with `http:` or `https:`.");return e}function Gs(e){let t,n;if(typeof e==`string`)t=e;else if(e){let{commitment:r,...i}=e;t=r,n=i}return{commitment:t,config:n}}function Ks(e){return e.map(e=>`memcmp`in e?{...e,memcmp:{...e.memcmp,encoding:e.memcmp.encoding??`base58`}}:e)}function qs(e){return Ei([W({jsonrpc:Si(`2.0`),id:U(),result:e}),W({jsonrpc:Si(`2.0`),id:U(),error:W({code:Di(),message:U(),data:H(yi())})})])}var Js=qs(Di());function $(e){return Oi(qs(e),Js,t=>`error`in t?t:{...t,result:R(t.result,e)})}function Ys(e){return $(W({context:W({slot:V()}),value:e}))}function Xs(e){return W({context:W({slot:V()}),value:e})}function Zs(e,t){return e===0?new Wo({header:t.header,staticAccountKeys:t.accountKeys.map(e=>new K(e)),recentBlockhash:t.recentBlockhash,compiledInstructions:t.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:Ar.default.decode(e.data)})),addressTableLookups:t.addressTableLookups}):new Uo(t)}var Qs=W({foundation:V(),foundationTerm:V(),initial:V(),taper:V(),terminal:V()}),$s=$(z(B(W({epoch:V(),effectiveSlot:V(),amount:V(),postBalance:V(),commission:H(B(V()))})))),ec=z(W({slot:V(),prioritizationFee:V()})),tc=W({total:V(),validator:V(),foundation:V(),epoch:V()}),nc=W({epoch:V(),slotIndex:V(),slotsInEpoch:V(),absoluteSlot:V(),blockHeight:H(V()),transactionCount:H(V())}),rc=W({slotsPerEpoch:V(),leaderScheduleSlotOffset:V(),warmup:bi(),firstNormalEpoch:V(),firstNormalSlot:V()}),ic=wi(U(),z(V())),ac=B(Ei([W({}),U()])),oc=W({err:ac}),sc=Si(`receivedSignature`),cc=W({"solana-core":U(),"feature-set":H(V())}),lc=W({program:U(),programId:Bs,parsed:Di()}),uc=W({programId:Bs,accounts:z(Bs),data:U()}),dc=Ys(W({err:B(Ei([W({}),U()])),logs:B(z(U())),accounts:H(B(z(B(W({executable:bi(),owner:U(),lamports:V(),data:z(U()),rentEpoch:H(V())}))))),unitsConsumed:H(V()),returnData:H(B(W({programId:U(),data:Ti([U(),Si(`base64`)])}))),innerInstructions:H(B(z(W({index:V(),instructions:z(Ei([lc,uc]))}))))})),fc=Ys(W({byIdentity:wi(U(),z(V())),range:W({firstSlot:V(),lastSlot:V()})}));function pc(e,t,n,r,i,a){let o=n||Ms;a!=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 s;return r&&(s=async(e,t)=>await o(...await new Promise((n,i)=>{try{r(e,t,(e,t)=>n([e,t]))}catch(e){i(e)}}))),new Aa.default(async(n,r)=>{let a={method:`POST`,body:n,agent:void 0,headers:Object.assign({"Content-Type":`application/json`},t||{},Al)};try{let t=5,n,c=500;for(;n=s?await s(e,a):await o(e,a),!(n.status!==429||i===!0||(--t,t===0));)console.error(`Server responded with ${n.status} ${n.statusText}. Retrying after ${c}ms delay...`),await us(c),c*=2;let l=await n.text();n.ok?r(null,l):r(Error(`${n.status} ${n.statusText}: ${l}`))}catch(e){e instanceof Error&&r(e)}},{})}function mc(e){return(t,n)=>new Promise((r,i)=>{e.request(t,n,(e,t)=>{if(e){i(e);return}r(t)})})}function hc(e){return t=>new Promise((n,r)=>{t.length===0&&n([]);let i=t.map(t=>e.request(t.methodName,t.args));e.request(i,(e,t)=>{if(e){r(e);return}n(t)})})}var gc=$(Qs),_c=$(tc),vc=$(ec),yc=$(nc),bc=$(rc),xc=$(ic),Sc=$(V()),Cc=Ys(W({total:V(),circulating:V(),nonCirculating:V(),nonCirculatingAccounts:z(Bs)})),wc=W({amount:U(),uiAmount:B(V()),decimals:V(),uiAmountString:H(U())}),Tc=Ys(z(W({address:Bs,amount:U(),uiAmount:B(V()),decimals:V(),uiAmountString:H(U())}))),Ec=Ys(z(W({pubkey:Bs,account:W({executable:bi(),owner:Bs,lamports:V(),data:Hs,rentEpoch:V()})}))),Dc=W({program:U(),parsed:Di(),space:V()}),Oc=Ys(z(W({pubkey:Bs,account:W({executable:bi(),owner:Bs,lamports:V(),data:Dc,rentEpoch:V()})}))),kc=Ys(z(W({lamports:V(),address:Bs}))),Ac=W({executable:bi(),owner:Bs,lamports:V(),data:Hs,rentEpoch:V()}),jc=W({pubkey:Bs,account:Ac}),Mc=Oi(Ei([xi(I.Buffer),Dc]),Ei([Vs,Dc]),e=>Array.isArray(e)?R(e,Hs):e),Nc=W({executable:bi(),owner:Bs,lamports:V(),data:Mc,rentEpoch:V()}),Pc=W({pubkey:Bs,account:Nc}),Fc=W({state:Ei([Si(`active`),Si(`inactive`),Si(`activating`),Si(`deactivating`)]),active:V(),inactive:V()}),Ic=$(z(W({signature:U(),slot:V(),err:ac,memo:B(U()),blockTime:H(B(V()))}))),Lc=$(z(W({signature:U(),slot:V(),err:ac,memo:B(U()),blockTime:H(B(V()))}))),Rc=W({subscription:V(),result:Xs(Ac)}),zc=W({pubkey:Bs,account:Ac}),Bc=W({subscription:V(),result:Xs(zc)}),Vc=W({parent:V(),slot:V(),root:V()}),Hc=W({subscription:V(),result:Vc}),Uc=Ei([W({type:Ei([Si(`firstShredReceived`),Si(`completed`),Si(`optimisticConfirmation`),Si(`root`)]),slot:V(),timestamp:V()}),W({type:Si(`createdBank`),parent:V(),slot:V(),timestamp:V()}),W({type:Si(`frozen`),slot:V(),timestamp:V(),stats:W({numTransactionEntries:V(),numSuccessfulTransactions:V(),numFailedTransactions:V(),maxTransactionsPerEntry:V()})}),W({type:Si(`dead`),slot:V(),timestamp:V(),err:U()})]),Wc=W({subscription:V(),result:Uc}),Gc=W({subscription:V(),result:Xs(Ei([oc,sc]))}),Kc=W({subscription:V(),result:V()}),qc=W({pubkey:U(),gossip:B(U()),tpu:B(U()),rpc:B(U()),version:B(U())}),Jc=W({votePubkey:U(),nodePubkey:U(),activatedStake:V(),epochVoteAccount:bi(),epochCredits:z(Ti([V(),V(),V()])),commission:V(),lastVote:V(),rootSlot:B(V())}),Yc=$(W({current:z(Jc),delinquent:z(Jc)})),Xc=Ei([Si(`processed`),Si(`confirmed`),Si(`finalized`)]),Zc=Ys(z(B(W({slot:V(),confirmations:B(V()),err:ac,confirmationStatus:H(Xc)})))),Qc=$(V()),$c=W({accountKey:Bs,writableIndexes:z(V()),readonlyIndexes:z(V())}),el=W({signatures:z(U()),message:W({accountKeys:z(U()),header:W({numRequiredSignatures:V(),numReadonlySignedAccounts:V(),numReadonlyUnsignedAccounts:V()}),instructions:z(W({accounts:z(V()),data:U(),programIdIndex:V()})),recentBlockhash:U(),addressTableLookups:H(z($c))})}),tl=W({pubkey:Bs,signer:bi(),writable:bi(),source:H(Ei([Si(`transaction`),Si(`lookupTable`)]))}),nl=W({accountKeys:z(tl),signatures:z(U())}),rl=W({parsed:Di(),program:U(),programId:Bs}),il=W({accounts:z(Bs),data:U(),programId:Bs}),al=Oi(Ei([il,rl]),Ei([W({parsed:Di(),program:U(),programId:U()}),W({accounts:z(U()),data:U(),programId:U()})]),e=>`accounts`in e?R(e,il):R(e,rl)),ol=W({signatures:z(U()),message:W({accountKeys:z(tl),instructions:z(al),recentBlockhash:U(),addressTableLookups:H(B(z($c)))})}),sl=W({accountIndex:V(),mint:U(),owner:H(U()),programId:H(U()),uiTokenAmount:wc}),cl=W({writable:z(Bs),readonly:z(Bs)}),ll=W({err:ac,fee:V(),innerInstructions:H(B(z(W({index:V(),instructions:z(W({accounts:z(V()),data:U(),programIdIndex:V()}))})))),preBalances:z(V()),postBalances:z(V()),logMessages:H(B(z(U()))),preTokenBalances:H(B(z(sl))),postTokenBalances:H(B(z(sl))),loadedAddresses:H(cl),computeUnitsConsumed:H(V()),costUnits:H(V())}),ul=W({err:ac,fee:V(),innerInstructions:H(B(z(W({index:V(),instructions:z(al)})))),preBalances:z(V()),postBalances:z(V()),logMessages:H(B(z(U()))),preTokenBalances:H(B(z(sl))),postTokenBalances:H(B(z(sl))),loadedAddresses:H(cl),computeUnitsConsumed:H(V()),costUnits:H(V())}),dl=Ei([Si(0),Si(`legacy`)]),fl=W({pubkey:U(),lamports:V(),postBalance:B(V()),rewardType:B(U()),commission:H(B(V()))}),pl=$(B(W({blockhash:U(),previousBlockhash:U(),parentSlot:V(),transactions:z(W({transaction:el,meta:B(ll),version:H(dl)})),rewards:H(z(fl)),blockTime:B(V()),blockHeight:B(V())}))),ml=$(B(W({blockhash:U(),previousBlockhash:U(),parentSlot:V(),rewards:H(z(fl)),blockTime:B(V()),blockHeight:B(V())}))),hl=$(B(W({blockhash:U(),previousBlockhash:U(),parentSlot:V(),transactions:z(W({transaction:nl,meta:B(ll),version:H(dl)})),rewards:H(z(fl)),blockTime:B(V()),blockHeight:B(V())}))),gl=$(B(W({blockhash:U(),previousBlockhash:U(),parentSlot:V(),transactions:z(W({transaction:ol,meta:B(ul),version:H(dl)})),rewards:H(z(fl)),blockTime:B(V()),blockHeight:B(V())}))),_l=$(B(W({blockhash:U(),previousBlockhash:U(),parentSlot:V(),transactions:z(W({transaction:nl,meta:B(ul),version:H(dl)})),rewards:H(z(fl)),blockTime:B(V()),blockHeight:B(V())}))),vl=$(B(W({blockhash:U(),previousBlockhash:U(),parentSlot:V(),rewards:H(z(fl)),blockTime:B(V()),blockHeight:B(V())}))),yl=$(B(W({blockhash:U(),previousBlockhash:U(),parentSlot:V(),transactions:z(W({transaction:el,meta:B(ll)})),rewards:H(z(fl)),blockTime:B(V())}))),bl=$(B(W({blockhash:U(),previousBlockhash:U(),parentSlot:V(),signatures:z(U()),blockTime:B(V())}))),xl=$(B(W({slot:V(),meta:B(ll),blockTime:H(B(V())),transaction:el,version:H(dl)}))),Sl=$(B(W({slot:V(),transaction:ol,meta:B(ul),blockTime:H(B(V())),version:H(dl)}))),Cl=Ys(W({blockhash:U(),lastValidBlockHeight:V()})),wl=Ys(bi()),Tl=$(z(W({slot:V(),numTransactions:V(),numSlots:V(),samplePeriodSecs:V()}))),El=Ys(B(W({feeCalculator:W({lamportsPerSignature:V()})}))),Dl=$(U()),Ol=$(U()),kl=W({result:Xs(W({err:ac,logs:z(U()),signature:U()})),subscription:V()}),Al={"solana-client":`js/1.0.0-maintenance`},jl=class{constructor(e,t){this._commitment=void 0,this._confirmTransactionInitialTimeout=void 0,this._rpcEndpoint=void 0,this._rpcWsEndpoint=void 0,this._rpcClient=void 0,this._rpcRequest=void 0,this._rpcBatchRequest=void 0,this._rpcWebSocket=void 0,this._rpcWebSocketConnected=!1,this._rpcWebSocketHeartbeat=null,this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketGeneration=0,this._disableBlockhashCaching=!1,this._pollingBlockhash=!1,this._blockhashInfo={latestBlockhash:null,lastFetch:0,transactionSignatures:[],simulatedSignatures:[]},this._nextClientSubscriptionId=0,this._subscriptionDisposeFunctionsByClientSubscriptionId={},this._subscriptionHashByClientSubscriptionId={},this._subscriptionStateChangeCallbacksByHash={},this._subscriptionCallbacksByServerSubscriptionId={},this._subscriptionsByHash={},this._subscriptionsAutoDisposedByRpc=new Set,this.getBlockHeight=(()=>{let e={};return async t=>{let{commitment:n,config:r}=Gs(t),i=this._buildArgs([],n,void 0,r),a=Ds(i);return e[a]=e[a]??(async()=>{try{let e=R(await this._rpcRequest(`getBlockHeight`,i),$(V()));if(`error`in e)throw new X(e.error,`failed to get block height information`);return e.result}finally{delete e[a]}})(),await e[a]}})();let n,r,i,a,o,s;t&&typeof t==`string`?this._commitment=t:t&&(this._commitment=t.commitment,this._confirmTransactionInitialTimeout=t.confirmTransactionInitialTimeout,n=t.wsEndpoint,r=t.httpHeaders,i=t.fetch,a=t.fetchMiddleware,o=t.disableRetryOnRateLimit,s=t.httpAgent),this._rpcEndpoint=Ws(e),this._rpcWsEndpoint=n||zs(e),this._rpcClient=pc(e,r,i,a,o,s),this._rpcRequest=mc(this._rpcClient),this._rpcBatchRequest=hc(this._rpcClient),this._rpcWebSocket=new Ns(this._rpcWsEndpoint,{autoconnect:!1,max_reconnects:1/0}),this._rpcWebSocket.on(`open`,this._wsOnOpen.bind(this)),this._rpcWebSocket.on(`error`,this._wsOnError.bind(this)),this._rpcWebSocket.on(`close`,this._wsOnClose.bind(this)),this._rpcWebSocket.on(`accountNotification`,this._wsOnAccountNotification.bind(this)),this._rpcWebSocket.on(`programNotification`,this._wsOnProgramAccountNotification.bind(this)),this._rpcWebSocket.on(`slotNotification`,this._wsOnSlotNotification.bind(this)),this._rpcWebSocket.on(`slotsUpdatesNotification`,this._wsOnSlotUpdatesNotification.bind(this)),this._rpcWebSocket.on(`signatureNotification`,this._wsOnSignatureNotification.bind(this)),this._rpcWebSocket.on(`rootNotification`,this._wsOnRootNotification.bind(this)),this._rpcWebSocket.on(`logsNotification`,this._wsOnLogsNotification.bind(this))}get commitment(){return this._commitment}get rpcEndpoint(){return this._rpcEndpoint}async getBalanceAndContext(e,t){let{commitment:n,config:r}=Gs(t),i=this._buildArgs([e.toBase58()],n,void 0,r),a=R(await this._rpcRequest(`getBalance`,i),Ys(V()));if(`error`in a)throw new X(a.error,`failed to get balance for ${e.toBase58()}`);return a.result}async getBalance(e,t){return await this.getBalanceAndContext(e,t).then(e=>e.value).catch(t=>{throw Error(`failed to get balance of account `+e.toBase58()+`: `+t)})}async getBlockTime(e){let t=R(await this._rpcRequest(`getBlockTime`,[e]),$(B(V())));if(`error`in t)throw new X(t.error,`failed to get block time for slot ${e}`);return t.result}async getMinimumLedgerSlot(){let e=R(await this._rpcRequest(`minimumLedgerSlot`,[]),$(V()));if(`error`in e)throw new X(e.error,`failed to get minimum ledger slot`);return e.result}async getFirstAvailableBlock(){let e=R(await this._rpcRequest(`getFirstAvailableBlock`,[]),Sc);if(`error`in e)throw new X(e.error,`failed to get first available block`);return e.result}async getSupply(e){let t={};t=typeof e==`string`?{commitment:e}:e?{...e,commitment:e&&e.commitment||this.commitment}:{commitment:this.commitment};let n=R(await this._rpcRequest(`getSupply`,[t]),Cc);if(`error`in n)throw new X(n.error,`failed to get supply`);return n.result}async getTokenSupply(e,t){let n=this._buildArgs([e.toBase58()],t),r=R(await this._rpcRequest(`getTokenSupply`,n),Ys(wc));if(`error`in r)throw new X(r.error,`failed to get token supply`);return r.result}async getTokenAccountBalance(e,t){let n=this._buildArgs([e.toBase58()],t),r=R(await this._rpcRequest(`getTokenAccountBalance`,n),Ys(wc));if(`error`in r)throw new X(r.error,`failed to get token account balance`);return r.result}async getTokenAccountsByOwner(e,t,n){let{commitment:r,config:i}=Gs(n),a=[e.toBase58()];`mint`in t?a.push({mint:t.mint.toBase58()}):a.push({programId:t.programId.toBase58()});let o=this._buildArgs(a,r,`base64`,i),s=R(await this._rpcRequest(`getTokenAccountsByOwner`,o),Ec);if(`error`in s)throw new X(s.error,`failed to get token accounts owned by account ${e.toBase58()}`);return s.result}async getParsedTokenAccountsByOwner(e,t,n){let r=[e.toBase58()];`mint`in t?r.push({mint:t.mint.toBase58()}):r.push({programId:t.programId.toBase58()});let i=this._buildArgs(r,n,`jsonParsed`),a=R(await this._rpcRequest(`getTokenAccountsByOwner`,i),Oc);if(`error`in a)throw new X(a.error,`failed to get token accounts owned by account ${e.toBase58()}`);return a.result}async getLargestAccounts(e){let t={...e,commitment:e&&e.commitment||this.commitment},n=t.filter||t.commitment?[t]:[],r=R(await this._rpcRequest(`getLargestAccounts`,n),kc);if(`error`in r)throw new X(r.error,`failed to get largest accounts`);return r.result}async getTokenLargestAccounts(e,t){let n=this._buildArgs([e.toBase58()],t),r=R(await this._rpcRequest(`getTokenLargestAccounts`,n),Tc);if(`error`in r)throw new X(r.error,`failed to get token largest accounts`);return r.result}async getAccountInfoAndContext(e,t){let{commitment:n,config:r}=Gs(t),i=this._buildArgs([e.toBase58()],n,`base64`,r),a=R(await this._rpcRequest(`getAccountInfo`,i),Ys(B(Ac)));if(`error`in a)throw new X(a.error,`failed to get info about account ${e.toBase58()}`);return a.result}async getParsedAccountInfo(e,t){let{commitment:n,config:r}=Gs(t),i=this._buildArgs([e.toBase58()],n,`jsonParsed`,r),a=R(await this._rpcRequest(`getAccountInfo`,i),Ys(B(Nc)));if(`error`in a)throw new X(a.error,`failed to get info about account ${e.toBase58()}`);return a.result}async getAccountInfo(e,t){try{return(await this.getAccountInfoAndContext(e,t)).value}catch(t){throw Error(`failed to get info about account `+e.toBase58()+`: `+t)}}async getMultipleParsedAccounts(e,t){let{commitment:n,config:r}=Gs(t),i=e.map(e=>e.toBase58()),a=this._buildArgs([i],n,`jsonParsed`,r),o=R(await this._rpcRequest(`getMultipleAccounts`,a),Ys(z(B(Nc))));if(`error`in o)throw new X(o.error,`failed to get info for accounts ${i}`);return o.result}async getMultipleAccountsInfoAndContext(e,t){let{commitment:n,config:r}=Gs(t),i=e.map(e=>e.toBase58()),a=this._buildArgs([i],n,`base64`,r),o=R(await this._rpcRequest(`getMultipleAccounts`,a),Ys(z(B(Ac))));if(`error`in o)throw new X(o.error,`failed to get info for accounts ${i}`);return o.result}async getMultipleAccountsInfo(e,t){return(await this.getMultipleAccountsInfoAndContext(e,t)).value}async getStakeActivation(e,t,n){let{commitment:r,config:i}=Gs(t),a=this._buildArgs([e.toBase58()],r,void 0,{...i,epoch:n??i?.epoch}),o=R(await this._rpcRequest(`getStakeActivation`,a),$(Fc));if(`error`in o)throw new X(o.error,`failed to get Stake Activation ${e.toBase58()}`);return o.result}async getProgramAccounts(e,t){let{commitment:n,config:r}=Gs(t),{encoding:i,...a}=r||{},o=this._buildArgs([e.toBase58()],n,i||`base64`,{...a,...a.filters?{filters:Ks(a.filters)}:null}),s=await this._rpcRequest(`getProgramAccounts`,o),c=z(jc),l=a.withContext===!0?R(s,Ys(c)):R(s,$(c));if(`error`in l)throw new X(l.error,`failed to get accounts owned by program ${e.toBase58()}`);return l.result}async getParsedProgramAccounts(e,t){let{commitment:n,config:r}=Gs(t),i=this._buildArgs([e.toBase58()],n,`jsonParsed`,r),a=R(await this._rpcRequest(`getProgramAccounts`,i),$(z(Pc)));if(`error`in a)throw new X(a.error,`failed to get accounts owned by program ${e.toBase58()}`);return a.result}async confirmTransaction(e,t){let n;if(typeof e==`string`)n=e;else{let t=e;if(t.abortSignal?.aborted)return Promise.reject(t.abortSignal.reason);n=t.signature}let r;try{r=Ar.default.decode(n)}catch{throw Error(`signature must be base58 encoded: `+n)}return J(r.length===64,`signature has invalid length`),typeof e==`string`?await this.confirmTransactionUsingLegacyTimeoutStrategy({commitment:t||this.commitment,signature:n}):`lastValidBlockHeight`in e?await this.confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:t||this.commitment,strategy:e}):await this.confirmTransactionUsingDurableNonceStrategy({commitment:t||this.commitment,strategy:e})}getCancellationPromise(e){return new Promise((t,n)=>{e!=null&&(e.aborted?n(e.reason):e.addEventListener(`abort`,()=>{n(e.reason)}))})}getTransactionConfirmationPromise({commitment:e,signature:t}){let n,r,i=!1;return{abortConfirmation:()=>{r&&=(r(),void 0),n!=null&&(this.removeSignatureListener(n),n=void 0)},confirmationPromise:new Promise((a,o)=>{try{n=this.onSignature(t,(e,t)=>{n=void 0;let r={context:t,value:e};a({__type:Ko.PROCESSED,response:r})},e);let s=new Promise(e=>{n==null?e():r=this._onSubscriptionStateChange(n,t=>{t===`subscribed`&&e()})});(async()=>{if(await s,i)return;let n=await this.getSignatureStatus(t);if(i||n==null)return;let{context:r,value:c}=n;if(c!=null)if(c?.err)o(c.err);else{switch(e){case`confirmed`:case`single`:case`singleGossip`:if(c.confirmationStatus===`processed`)return;break;case`finalized`:case`max`:case`root`:if(c.confirmationStatus===`processed`||c.confirmationStatus===`confirmed`)return;break;case`processed`:case`recent`:}i=!0,a({__type:Ko.PROCESSED,response:{context:r,value:c}})}})()}catch(e){o(e)}})}}async confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:e,strategy:{abortSignal:t,lastValidBlockHeight:n,signature:r}}){let i=!1,a=new Promise(t=>{let r=async()=>{try{return await this.getBlockHeight(e)}catch{return-1}};(async()=>{let e=await r();if(!i){for(;e<=n;)if(await us(1e3),i||(e=await r(),i))return;t({__type:Ko.BLOCKHEIGHT_EXCEEDED})}})()}),{abortConfirmation:o,confirmationPromise:s}=this.getTransactionConfirmationPromise({commitment:e,signature:r}),c=this.getCancellationPromise(t),l;try{let e=await Promise.race([c,s,a]);if(e.__type===Ko.PROCESSED)l=e.response;else throw new Eo(r)}finally{i=!0,o()}return l}async confirmTransactionUsingDurableNonceStrategy({commitment:e,strategy:{abortSignal:t,minContextSlot:n,nonceAccountPubkey:r,nonceValue:i,signature:a}}){let o=!1,s=new Promise(t=>{let a=i,s=null,c=async()=>{try{let{context:t,value:i}=await this.getNonceAndContext(r,{commitment:e,minContextSlot:n});return s=t.slot,i?.nonce}catch{return a}};(async()=>{if(a=await c(),!o)for(;;){if(i!==a){t({__type:Ko.NONCE_INVALID,slotInWhichNonceDidAdvance:s});return}if(await us(2e3),o||(a=await c(),o))return}})()}),{abortConfirmation:c,confirmationPromise:l}=this.getTransactionConfirmationPromise({commitment:e,signature:a}),u=this.getCancellationPromise(t),d;try{let t=await Promise.race([u,l,s]);if(t.__type===Ko.PROCESSED)d=t.response;else{let r;for(;;){let e=await this.getSignatureStatus(a);if(e==null)break;if(e.context.slot<(t.slotInWhichNonceDidAdvance??n)){await us(400);continue}r=e;break}if(r?.value){let t=e||`finalized`,{confirmationStatus:n}=r.value;switch(t){case`processed`:case`recent`:if(n!==`processed`&&n!==`confirmed`&&n!==`finalized`)throw new Oo(a);break;case`confirmed`:case`single`:case`singleGossip`:if(n!==`confirmed`&&n!==`finalized`)throw new Oo(a);break;case`finalized`:case`max`:case`root`:if(n!==`finalized`)throw new Oo(a);break;default:(e=>{})(t)}d={context:r.context,value:{err:r.value.err}}}else throw new Oo(a)}}finally{o=!0,c()}return d}async confirmTransactionUsingLegacyTimeoutStrategy({commitment:e,signature:t}){let n,r=new Promise(t=>{let r=this._confirmTransactionInitialTimeout||60*1e3;switch(e){case`processed`:case`recent`:case`single`:case`confirmed`:case`singleGossip`:r=this._confirmTransactionInitialTimeout||30*1e3;break}n=setTimeout(()=>t({__type:Ko.TIMED_OUT,timeoutMs:r}),r)}),{abortConfirmation:i,confirmationPromise:a}=this.getTransactionConfirmationPromise({commitment:e,signature:t}),o;try{let e=await Promise.race([a,r]);if(e.__type===Ko.PROCESSED)o=e.response;else throw new Do(t,e.timeoutMs/1e3)}finally{clearTimeout(n),i()}return o}async getClusterNodes(){let e=R(await this._rpcRequest(`getClusterNodes`,[]),$(z(qc)));if(`error`in e)throw new X(e.error,`failed to get cluster nodes`);return e.result}async getVoteAccounts(e){let t=this._buildArgs([],e),n=R(await this._rpcRequest(`getVoteAccounts`,t),Yc);if(`error`in n)throw new X(n.error,`failed to get vote accounts`);return n.result}async getSlot(e){let{commitment:t,config:n}=Gs(e),r=this._buildArgs([],t,void 0,n),i=R(await this._rpcRequest(`getSlot`,r),$(V()));if(`error`in i)throw new X(i.error,`failed to get slot`);return i.result}async getSlotLeader(e){let{commitment:t,config:n}=Gs(e),r=this._buildArgs([],t,void 0,n),i=R(await this._rpcRequest(`getSlotLeader`,r),$(U()));if(`error`in i)throw new X(i.error,`failed to get slot leader`);return i.result}async getSlotLeaders(e,t){let n=[e,t],r=R(await this._rpcRequest(`getSlotLeaders`,n),$(z(Bs)));if(`error`in r)throw new X(r.error,`failed to get slot leaders`);return r.result}async getSignatureStatus(e,t){let{context:n,value:r}=await this.getSignatureStatuses([e],t);return J(r.length===1),{context:n,value:r[0]}}async getSignatureStatuses(e,t){let n=[e];t&&n.push(t);let r=R(await this._rpcRequest(`getSignatureStatuses`,n),Zc);if(`error`in r)throw new X(r.error,`failed to get signature status`);return r.result}async getTransactionCount(e){let{commitment:t,config:n}=Gs(e),r=this._buildArgs([],t,void 0,n),i=R(await this._rpcRequest(`getTransactionCount`,r),$(V()));if(`error`in i)throw new X(i.error,`failed to get transaction count`);return i.result}async getTotalSupply(e){return(await this.getSupply({commitment:e,excludeNonCirculatingAccountsList:!0})).value.total}async getInflationGovernor(e){let t=this._buildArgs([],e),n=R(await this._rpcRequest(`getInflationGovernor`,t),gc);if(`error`in n)throw new X(n.error,`failed to get inflation`);return n.result}async getInflationReward(e,t,n){let{commitment:r,config:i}=Gs(n),a=this._buildArgs([e.map(e=>e.toBase58())],r,void 0,{...i,epoch:t??i?.epoch}),o=R(await this._rpcRequest(`getInflationReward`,a),$s);if(`error`in o)throw new X(o.error,`failed to get inflation reward`);return o.result}async getInflationRate(){let e=R(await this._rpcRequest(`getInflationRate`,[]),_c);if(`error`in e)throw new X(e.error,`failed to get inflation rate`);return e.result}async getEpochInfo(e){let{commitment:t,config:n}=Gs(e),r=this._buildArgs([],t,void 0,n),i=R(await this._rpcRequest(`getEpochInfo`,r),yc);if(`error`in i)throw new X(i.error,`failed to get epoch info`);return i.result}async getEpochSchedule(){let e=R(await this._rpcRequest(`getEpochSchedule`,[]),bc);if(`error`in e)throw new X(e.error,`failed to get epoch schedule`);let t=e.result;return new js(t.slotsPerEpoch,t.leaderScheduleSlotOffset,t.warmup,t.firstNormalEpoch,t.firstNormalSlot)}async getLeaderSchedule(){let e=R(await this._rpcRequest(`getLeaderSchedule`,[]),xc);if(`error`in e)throw new X(e.error,`failed to get leader schedule`);return e.result}async getMinimumBalanceForRentExemption(e,t){let n=this._buildArgs([e],t),r=R(await this._rpcRequest(`getMinimumBalanceForRentExemption`,n),Qc);return`error`in r?(console.warn(`Unable to fetch minimum balance for rent exemption`),0):r.result}async getRecentBlockhashAndContext(e){let{context:t,value:{blockhash:n}}=await this.getLatestBlockhashAndContext(e);return{context:t,value:{blockhash:n,feeCalculator:{get lamportsPerSignature(){throw Error("The capability to fetch `lamportsPerSignature` using the `getRecentBlockhash` API is no longer offered by the network. Use the `getFeeForMessage` API to obtain the fee for a given message.")},toJSON(){return{}}}}}}async getRecentPerformanceSamples(e){let t=R(await this._rpcRequest(`getRecentPerformanceSamples`,e?[e]:[]),Tl);if(`error`in t)throw new X(t.error,`failed to get recent performance samples`);return t.result}async getFeeCalculatorForBlockhash(e,t){let n=this._buildArgs([e],t),r=R(await this._rpcRequest(`getFeeCalculatorForBlockhash`,n),El);if(`error`in r)throw new X(r.error,`failed to get fee calculator`);let{context:i,value:a}=r.result;return{context:i,value:a===null?null:a.feeCalculator}}async getFeeForMessage(e,t){let n=G(e.serialize()).toString(`base64`),r=this._buildArgs([n],t),i=R(await this._rpcRequest(`getFeeForMessage`,r),Ys(B(V())));if(`error`in i)throw new X(i.error,`failed to get fee for message`);if(i.result===null)throw Error(`invalid blockhash`);return i.result}async getRecentPrioritizationFees(e){let t=e?.lockedWritableAccounts?.map(e=>e.toBase58()),n=t?.length?[t]:[],r=R(await this._rpcRequest(`getRecentPrioritizationFees`,n),vc);if(`error`in r)throw new X(r.error,`failed to get recent prioritization fees`);return r.result}async getRecentBlockhash(e){try{return(await this.getRecentBlockhashAndContext(e)).value}catch(e){throw Error(`failed to get recent blockhash: `+e)}}async getLatestBlockhash(e){try{return(await this.getLatestBlockhashAndContext(e)).value}catch(e){throw Error(`failed to get recent blockhash: `+e)}}async getLatestBlockhashAndContext(e){let{commitment:t,config:n}=Gs(e),r=this._buildArgs([],t,void 0,n),i=R(await this._rpcRequest(`getLatestBlockhash`,r),Cl);if(`error`in i)throw new X(i.error,`failed to get latest blockhash`);return i.result}async isBlockhashValid(e,t){let{commitment:n,config:r}=Gs(t),i=this._buildArgs([e],n,void 0,r),a=R(await this._rpcRequest(`isBlockhashValid`,i),wl);if(`error`in a)throw new X(a.error,"failed to determine if the blockhash `"+e+"`is valid");return a.result}async getVersion(){let e=R(await this._rpcRequest(`getVersion`,[]),$(cc));if(`error`in e)throw new X(e.error,`failed to get version`);return e.result}async getGenesisHash(){let e=R(await this._rpcRequest(`getGenesisHash`,[]),$(U()));if(`error`in e)throw new X(e.error,`failed to get genesis hash`);return e.result}async getBlock(e,t){let{commitment:n,config:r}=Gs(t),i=this._buildArgsAtLeastConfirmed([e],n,void 0,r),a=await this._rpcRequest(`getBlock`,i);try{switch(r?.transactionDetails){case`accounts`:{let e=R(a,hl);if(`error`in e)throw e.error;return e.result}case`none`:{let e=R(a,ml);if(`error`in e)throw e.error;return e.result}default:{let e=R(a,pl);if(`error`in e)throw e.error;let{result:t}=e;return t?{...t,transactions:t.transactions.map(({transaction:e,meta:t,version:n})=>({meta:t,transaction:{...e,message:Zs(n,e.message)},version:n}))}:null}}}catch(e){throw new X(e,`failed to get confirmed block`)}}async getParsedBlock(e,t){let{commitment:n,config:r}=Gs(t),i=this._buildArgsAtLeastConfirmed([e],n,`jsonParsed`,r),a=await this._rpcRequest(`getBlock`,i);try{switch(r?.transactionDetails){case`accounts`:{let e=R(a,_l);if(`error`in e)throw e.error;return e.result}case`none`:{let e=R(a,vl);if(`error`in e)throw e.error;return e.result}default:{let e=R(a,gl);if(`error`in e)throw e.error;return e.result}}}catch(e){throw new X(e,`failed to get block`)}}async getBlockProduction(e){let t,n;if(typeof e==`string`)n=e;else if(e){let{commitment:r,...i}=e;n=r,t=i}let r=this._buildArgs([],n,`base64`,t),i=R(await this._rpcRequest(`getBlockProduction`,r),fc);if(`error`in i)throw new X(i.error,`failed to get block production information`);return i.result}async getTransaction(e,t){let{commitment:n,config:r}=Gs(t),i=this._buildArgsAtLeastConfirmed([e],n,void 0,r),a=R(await this._rpcRequest(`getTransaction`,i),xl);if(`error`in a)throw new X(a.error,`failed to get transaction`);let o=a.result;return o&&{...o,transaction:{...o.transaction,message:Zs(o.version,o.transaction.message)}}}async getParsedTransaction(e,t){let{commitment:n,config:r}=Gs(t),i=this._buildArgsAtLeastConfirmed([e],n,`jsonParsed`,r),a=R(await this._rpcRequest(`getTransaction`,i),Sl);if(`error`in a)throw new X(a.error,`failed to get transaction`);return a.result}async getParsedTransactions(e,t){let{commitment:n,config:r}=Gs(t),i=e.map(e=>({methodName:`getTransaction`,args:this._buildArgsAtLeastConfirmed([e],n,`jsonParsed`,r)}));return(await this._rpcBatchRequest(i)).map(e=>{let t=R(e,Sl);if(`error`in t)throw new X(t.error,`failed to get transactions`);return t.result})}async getTransactions(e,t){let{commitment:n,config:r}=Gs(t),i=e.map(e=>({methodName:`getTransaction`,args:this._buildArgsAtLeastConfirmed([e],n,void 0,r)}));return(await this._rpcBatchRequest(i)).map(e=>{let t=R(e,xl);if(`error`in t)throw new X(t.error,`failed to get transactions`);let n=t.result;return n&&{...n,transaction:{...n.transaction,message:Zs(n.version,n.transaction.message)}}})}async getConfirmedBlock(e,t){let n=this._buildArgsAtLeastConfirmed([e],t),r=R(await this._rpcRequest(`getBlock`,n),yl);if(`error`in r)throw new X(r.error,`failed to get confirmed block`);let i=r.result;if(!i)throw Error(`Confirmed block `+e+` not found`);let a={...i,transactions:i.transactions.map(({transaction:e,meta:t})=>{let n=new Uo(e.message);return{meta:t,transaction:{...e,message:n}}})};return{...a,transactions:a.transactions.map(({transaction:e,meta:t})=>({meta:t,transaction:Y.populate(e.message,e.signatures)}))}}async getBlocks(e,t,n){let r=this._buildArgsAtLeastConfirmed(t===void 0?[e]:[e,t],n),i=R(await this._rpcRequest(`getBlocks`,r),$(z(V())));if(`error`in i)throw new X(i.error,`failed to get blocks`);return i.result}async getBlockSignatures(e,t){let n=this._buildArgsAtLeastConfirmed([e],t,void 0,{transactionDetails:`signatures`,rewards:!1}),r=R(await this._rpcRequest(`getBlock`,n),bl);if(`error`in r)throw new X(r.error,`failed to get block`);let i=r.result;if(!i)throw Error(`Block `+e+` not found`);return i}async getConfirmedBlockSignatures(e,t){let n=this._buildArgsAtLeastConfirmed([e],t,void 0,{transactionDetails:`signatures`,rewards:!1}),r=R(await this._rpcRequest(`getBlock`,n),bl);if(`error`in r)throw new X(r.error,`failed to get confirmed block`);let i=r.result;if(!i)throw Error(`Confirmed block `+e+` not found`);return i}async getConfirmedTransaction(e,t){let n=this._buildArgsAtLeastConfirmed([e],t),r=R(await this._rpcRequest(`getTransaction`,n),xl);if(`error`in r)throw new X(r.error,`failed to get transaction`);let i=r.result;if(!i)return i;let a=new Uo(i.transaction.message),o=i.transaction.signatures;return{...i,transaction:Y.populate(a,o)}}async getParsedConfirmedTransaction(e,t){let n=this._buildArgsAtLeastConfirmed([e],t,`jsonParsed`),r=R(await this._rpcRequest(`getTransaction`,n),Sl);if(`error`in r)throw new X(r.error,`failed to get confirmed transaction`);return r.result}async getParsedConfirmedTransactions(e,t){let n=e.map(e=>({methodName:`getTransaction`,args:this._buildArgsAtLeastConfirmed([e],t,`jsonParsed`)}));return(await this._rpcBatchRequest(n)).map(e=>{let t=R(e,Sl);if(`error`in t)throw new X(t.error,`failed to get confirmed transactions`);return t.result})}async getConfirmedSignaturesForAddress(e,t,n){let r={},i=await this.getFirstAvailableBlock();for(;!(`until`in r)&&(t--,!(t<=0||t<i));)try{let e=await this.getConfirmedBlockSignatures(t,`finalized`);e.signatures.length>0&&(r.until=e.signatures[e.signatures.length-1].toString())}catch(e){if(e instanceof Error&&e.message.includes(`skipped`))continue;throw e}let a=await this.getSlot(`finalized`);for(;!(`before`in r)&&(n++,!(n>a));)try{let e=await this.getConfirmedBlockSignatures(n);e.signatures.length>0&&(r.before=e.signatures[e.signatures.length-1].toString())}catch(e){if(e instanceof Error&&e.message.includes(`skipped`))continue;throw e}return(await this.getConfirmedSignaturesForAddress2(e,r)).map(e=>e.signature)}async getConfirmedSignaturesForAddress2(e,t,n){let r=this._buildArgsAtLeastConfirmed([e.toBase58()],n,void 0,t),i=R(await this._rpcRequest(`getConfirmedSignaturesForAddress2`,r),Ic);if(`error`in i)throw new X(i.error,`failed to get confirmed signatures for address`);return i.result}async getSignaturesForAddress(e,t,n){let r=this._buildArgsAtLeastConfirmed([e.toBase58()],n,void 0,t),i=R(await this._rpcRequest(`getSignaturesForAddress`,r),Lc);if(`error`in i)throw new X(i.error,`failed to get signatures for address`);return i.result}async getAddressLookupTable(e,t){let{context:n,value:r}=await this.getAccountInfoAndContext(e,t),i=null;return r!==null&&(i=new Is({key:e,state:Is.deserialize(r.data)})),{context:n,value:i}}async getNonceAndContext(e,t){let{context:n,value:r}=await this.getAccountInfoAndContext(e,t),i=null;return r!==null&&(i=ms.fromAccountData(r.data)),{context:n,value:i}}async getNonce(e,t){return await this.getNonceAndContext(e,t).then(e=>e.value).catch(t=>{throw Error(`failed to get nonce for account `+e.toBase58()+`: `+t)})}async requestAirdrop(e,t){let n=R(await this._rpcRequest(`requestAirdrop`,[e.toBase58(),t]),Dl);if(`error`in n)throw new X(n.error,`airdrop to ${e.toBase58()} failed`);return n.result}async _blockhashWithExpiryBlockHeight(e){if(!e){for(;this._pollingBlockhash;)await us(100);let e=Date.now()-this._blockhashInfo.lastFetch>=Us;if(this._blockhashInfo.latestBlockhash!==null&&!e)return this._blockhashInfo.latestBlockhash}return await this._pollNewBlockhash()}async _pollNewBlockhash(){this._pollingBlockhash=!0;try{let e=Date.now(),t=this._blockhashInfo.latestBlockhash,n=t?t.blockhash:null;for(let e=0;e<50;e++){let e=await this.getLatestBlockhash(`finalized`);if(n!==e.blockhash)return this._blockhashInfo={latestBlockhash:e,lastFetch:Date.now(),transactionSignatures:[],simulatedSignatures:[]},e;await us(Zo/2)}throw Error(`Unable to obtain a new blockhash after ${Date.now()-e}ms`)}finally{this._pollingBlockhash=!1}}async getStakeMinimumDelegation(e){let{commitment:t,config:n}=Gs(e),r=this._buildArgs([],t,`base64`,n),i=R(await this._rpcRequest(`getStakeMinimumDelegation`,r),Ys(V()));if(`error`in i)throw new X(i.error,`failed to get stake minimum delegation`);return i.result}async simulateTransaction(e,t,n){if(`message`in e){let r=e.serialize(),i=I.Buffer.from(r).toString(`base64`);if(Array.isArray(t)||n!==void 0)throw Error(`Invalid arguments`);let a=t||{};a.encoding=`base64`,`commitment`in a||(a.commitment=this.commitment),t&&typeof t==`object`&&`innerInstructions`in t&&(a.innerInstructions=t.innerInstructions);let o=[i,a],s=R(await this._rpcRequest(`simulateTransaction`,o),dc);if(`error`in s)throw Error(`failed to simulate transaction: `+s.error.message);return s.result}let r;if(e instanceof Y){let t=e;r=new Y,r.feePayer=t.feePayer,r.instructions=e.instructions,r.nonceInfo=t.nonceInfo,r.signatures=t.signatures}else r=Y.populate(e),r._message=r._json=void 0;if(t!==void 0&&!Array.isArray(t))throw Error(`Invalid arguments`);let i=t;if(r.nonceInfo&&i)r.sign(...i);else{let e=this._disableBlockhashCaching;for(;;){let t=await this._blockhashWithExpiryBlockHeight(e);if(r.lastValidBlockHeight=t.lastValidBlockHeight,r.recentBlockhash=t.blockhash,!i)break;if(r.sign(...i),!r.signature)throw Error(`!signature`);let n=r.signature.toString(`base64`);if(!this._blockhashInfo.simulatedSignatures.includes(n)&&!this._blockhashInfo.transactionSignatures.includes(n)){this._blockhashInfo.simulatedSignatures.push(n);break}else e=!0}}let a=r._compile(),o=a.serialize(),s=r._serialize(o).toString(`base64`),c={encoding:`base64`,commitment:this.commitment};n&&(c.accounts={encoding:`base64`,addresses:(Array.isArray(n)?n:a.nonProgramIds()).map(e=>e.toBase58())}),i&&(c.sigVerify=!0),t&&typeof t==`object`&&`innerInstructions`in t&&(c.innerInstructions=t.innerInstructions);let l=[s,c],u=R(await this._rpcRequest(`simulateTransaction`,l),dc);if(`error`in u){let e;if(`data`in u.error&&(e=u.error.data.logs,e&&Array.isArray(e))){let t=`
|
|
1
|
+
import{a as e,n as t,o as n,r,t as i}from"./rolldown-runtime--c01j_DQ.js";import{Pn as a}from"./index-CZaid7Ez.js";import{n as o}from"./eventemitter3-CwKRT-4Q.js";var s=BigInt(2**32-1),c=BigInt(32);function l(e,t=!1){return t?{h:Number(e&s),l:Number(e>>c&s)}:{h:Number(e>>c&s)|0,l:Number(e&s)|0}}function u(e,t=!1){let n=e.length,r=new Uint32Array(n),i=new Uint32Array(n);for(let a=0;a<n;a++){let{h:n,l:o}=l(e[a],t);[r[a],i[a]]=[n,o]}return[r,i]}var d=(e,t,n)=>e>>>n,f=(e,t,n)=>e<<32-n|t>>>n,p=(e,t,n)=>e>>>n|t<<32-n,m=(e,t,n)=>e<<32-n|t>>>n,h=(e,t,n)=>e<<64-n|t>>>n-32,g=(e,t,n)=>e>>>n-32|t<<64-n,_=(e,t,n)=>e<<n|t>>>32-n,v=(e,t,n)=>t<<n|e>>>32-n,y=(e,t,n)=>t<<n-32|e>>>64-n,b=(e,t,n)=>e<<n-32|t>>>64-n;function x(e,t,n,r){let i=(t>>>0)+(r>>>0);return{h:e+n+(i/2**32|0)|0,l:i|0}}var ee=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),S=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,C=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),w=(e,t,n,r,i)=>t+n+r+i+(e/2**32|0)|0,T=(e,t,n,r,i)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(i>>>0),E=(e,t,n,r,i,a)=>t+n+r+i+a+(e/2**32|0)|0,D=typeof globalThis==`object`&&`crypto`in globalThis?globalThis.crypto:void 0;function O(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`}function k(e){if(!Number.isSafeInteger(e)||e<0)throw Error(`positive integer expected, got `+e)}function te(e,...t){if(!O(e))throw Error(`Uint8Array expected`);if(t.length>0&&!t.includes(e.length))throw Error(`Uint8Array expected of length `+t+`, got length=`+e.length)}function ne(e){if(typeof e!=`function`||typeof e.create!=`function`)throw Error(`Hash should be wrapped by utils.createHasher`);k(e.outputLen),k(e.blockLen)}function A(e,t=!0){if(e.destroyed)throw Error(`Hash instance has been destroyed`);if(t&&e.finished)throw Error(`Hash#digest() has already been called`)}function re(e,t){te(e);let n=t.outputLen;if(e.length<n)throw Error(`digestInto() expects output buffer of length at least `+n)}function ie(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function j(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function ae(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function M(e,t){return e<<32-t|e>>>t}var oe=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function se(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function ce(e){for(let t=0;t<e.length;t++)e[t]=se(e[t]);return e}var le=oe?e=>e:ce,ue=typeof Uint8Array.from([]).toHex==`function`&&typeof Uint8Array.fromHex==`function`,de=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function N(e){if(te(e),ue)return e.toHex();let t=``;for(let n=0;n<e.length;n++)t+=de[e[n]];return t}var fe={_0:48,_9:57,A:65,F:70,a:97,f:102};function pe(e){if(e>=fe._0&&e<=fe._9)return e-fe._0;if(e>=fe.A&&e<=fe.F)return e-(fe.A-10);if(e>=fe.a&&e<=fe.f)return e-(fe.a-10)}function me(e){if(typeof e!=`string`)throw Error(`hex string expected, got `+typeof e);if(ue)return Uint8Array.fromHex(e);let t=e.length,n=t/2;if(t%2)throw Error(`hex string expected, got unpadded hex of length `+t);let r=new Uint8Array(n);for(let t=0,i=0;t<n;t++,i+=2){let n=pe(e.charCodeAt(i)),a=pe(e.charCodeAt(i+1));if(n===void 0||a===void 0){let t=e[i]+e[i+1];throw Error(`hex string expected, got non-hex character "`+t+`" at index `+i)}r[t]=n*16+a}return r}function he(e){if(typeof e!=`string`)throw Error(`string expected`);return new Uint8Array(new TextEncoder().encode(e))}function P(e){return typeof e==`string`&&(e=he(e)),te(e),e}function F(...e){let t=0;for(let n=0;n<e.length;n++){let r=e[n];te(r),t+=r.length}let n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){let i=e[t];n.set(i,r),r+=i.length}return n}var ge=class{};function _e(e){let t=t=>e().update(P(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function ve(e=32){if(D&&typeof D.getRandomValues==`function`)return D.getRandomValues(new Uint8Array(e));if(D&&typeof D.randomBytes==`function`)return Uint8Array.from(D.randomBytes(e));throw Error(`crypto.getRandomValues must be defined`)}var ye=BigInt(0),be=BigInt(1),xe=BigInt(2),Se=BigInt(7),Ce=BigInt(256),we=BigInt(113),Te=[],Ee=[],De=[];for(let e=0,t=be,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],Te.push(2*(5*r+n)),Ee.push((e+1)*(e+2)/2%64);let i=ye;for(let e=0;e<7;e++)t=(t<<be^(t>>Se)*we)%Ce,t&xe&&(i^=be<<(be<<BigInt(e))-be);De.push(i)}var Oe=u(De,!0),ke=Oe[0],Ae=Oe[1],je=(e,t,n)=>n>32?y(e,t,n):_(e,t,n),Me=(e,t,n)=>n>32?b(e,t,n):v(e,t,n);function Ne(e,t=24){let n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let t=0;t<10;t++)n[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){let r=(t+8)%10,i=(t+2)%10,a=n[i],o=n[i+1],s=je(a,o,1)^n[r],c=Me(a,o,1)^n[r+1];for(let n=0;n<50;n+=10)e[t+n]^=s,e[t+n+1]^=c}let t=e[2],i=e[3];for(let n=0;n<24;n++){let r=Ee[n],a=je(t,i,r),o=Me(t,i,r),s=Te[n];t=e[s],i=e[s+1],e[s]=a,e[s+1]=o}for(let t=0;t<50;t+=10){for(let r=0;r<10;r++)n[r]=e[t+r];for(let r=0;r<10;r++)e[t+r]^=~n[(r+2)%10]&n[(r+4)%10]}e[0]^=ke[r],e[1]^=Ae[r]}j(n)}var Pe=class e extends ge{constructor(e,t,n,r=!1,i=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=r,this.rounds=i,k(n),!(0<e&&e<200))throw Error(`only keccak-f1600 function is supported`);this.state=new Uint8Array(200),this.state32=ie(this.state)}clone(){return this._cloneInto()}keccak(){le(this.state32),Ne(this.state32,this.rounds),le(this.state32),this.posOut=0,this.pos=0}update(e){A(this),e=P(e),te(e);let{blockLen:t,state:n}=this,r=e.length;for(let i=0;i<r;){let a=Math.min(t-this.pos,r-i);for(let t=0;t<a;t++)n[this.pos++]^=e[i++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:t,pos:n,blockLen:r}=this;e[n]^=t,t&128&&n===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){A(this,!1),te(e),this.finish();let t=this.state,{blockLen:n}=this;for(let r=0,i=e.length;r<i;){this.posOut>=n&&this.keccak();let a=Math.min(n-this.posOut,i-r);e.set(t.subarray(this.posOut,this.posOut+a),r),this.posOut+=a,r+=a}return e}xofInto(e){if(!this.enableXOF)throw Error(`XOF is not possible for this instance`);return this.writeInto(e)}xof(e){return k(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(re(e,this),this.finished)throw Error(`digest() was already called`);return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,j(this.state)}_cloneInto(t){let{blockLen:n,suffix:r,outputLen:i,rounds:a,enableXOF:o}=this;return t||=new e(n,r,i,o,a),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=a,t.suffix=r,t.outputLen=i,t.enableXOF=o,t.destroyed=this.destroyed,t}},Fe=((e,t,n)=>_e(()=>new Pe(t,e,n)))(1,136,256/8);function Ie(e,t,n,r){if(typeof e.setBigUint64==`function`)return e.setBigUint64(t,n,r);let i=BigInt(32),a=BigInt(4294967295),o=Number(n>>i&a),s=Number(n&a),c=r?4:0,l=r?0:4;e.setUint32(t+c,o,r),e.setUint32(t+l,s,r)}function Le(e,t,n){return e&t^~e&n}function Re(e,t,n){return e&t^e&n^t&n}var ze=class extends ge{constructor(e,t,n,r){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=ae(this.buffer)}update(e){A(this),e=P(e),te(e);let{view:t,buffer:n,blockLen:r}=this,i=e.length;for(let a=0;a<i;){let o=Math.min(r-this.pos,i-a);if(o===r){let t=ae(e);for(;r<=i-a;a+=r)this.process(t,a);continue}n.set(e.subarray(a,a+o),this.pos),this.pos+=o,a+=o,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){A(this),re(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:r,isLE:i}=this,{pos:a}=this;t[a++]=128,j(this.buffer.subarray(a)),this.padOffset>r-a&&(this.process(n,0),a=0);for(let e=a;e<r;e++)t[e]=0;Ie(n,r-8,BigInt(this.length*8),i),this.process(n,0);let o=ae(e),s=this.outputLen;if(s%4)throw Error(`_sha2: outputLen should be aligned to 32bit`);let c=s/4,l=this.get();if(c>l.length)throw Error(`_sha2: outputLen bigger than state`);for(let e=0;e<c;e++)o.setUint32(4*e,l[e],i)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||=new this.constructor,e.set(...this.get());let{blockLen:t,buffer:n,length:r,finished:i,destroyed:a,pos:o}=this;return e.destroyed=a,e.finished=i,e.length=r,e.pos=o,r%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}},Be=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ve=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),He=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]),Ue=new Uint32Array(64),We=class extends ze{constructor(e=32){super(64,e,8,!1),this.A=Be[0]|0,this.B=Be[1]|0,this.C=Be[2]|0,this.D=Be[3]|0,this.E=Be[4]|0,this.F=Be[5]|0,this.G=Be[6]|0,this.H=Be[7]|0}get(){let{A:e,B:t,C:n,D:r,E:i,F:a,G:o,H:s}=this;return[e,t,n,r,i,a,o,s]}set(e,t,n,r,i,a,o,s){this.A=e|0,this.B=t|0,this.C=n|0,this.D=r|0,this.E=i|0,this.F=a|0,this.G=o|0,this.H=s|0}process(e,t){for(let n=0;n<16;n++,t+=4)Ue[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){let t=Ue[e-15],n=Ue[e-2],r=M(t,7)^M(t,18)^t>>>3;Ue[e]=(M(n,17)^M(n,19)^n>>>10)+Ue[e-7]+r+Ue[e-16]|0}let{A:n,B:r,C:i,D:a,E:o,F:s,G:c,H:l}=this;for(let e=0;e<64;e++){let t=M(o,6)^M(o,11)^M(o,25),u=l+t+Le(o,s,c)+He[e]+Ue[e]|0,d=(M(n,2)^M(n,13)^M(n,22))+Re(n,r,i)|0;l=c,c=s,s=o,o=a+u|0,a=i,i=r,r=n,n=u+d|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,a=a+this.D|0,o=o+this.E|0,s=s+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,i,a,o,s,c,l)}roundClean(){j(Ue)}destroy(){this.set(0,0,0,0,0,0,0,0),j(this.buffer)}},Ge=u(`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`.split(`.`).map(e=>BigInt(e))),Ke=Ge[0],qe=Ge[1],Je=new Uint32Array(80),Ye=new Uint32Array(80),Xe=class extends ze{constructor(e=64){super(128,e,16,!1),this.Ah=Ve[0]|0,this.Al=Ve[1]|0,this.Bh=Ve[2]|0,this.Bl=Ve[3]|0,this.Ch=Ve[4]|0,this.Cl=Ve[5]|0,this.Dh=Ve[6]|0,this.Dl=Ve[7]|0,this.Eh=Ve[8]|0,this.El=Ve[9]|0,this.Fh=Ve[10]|0,this.Fl=Ve[11]|0,this.Gh=Ve[12]|0,this.Gl=Ve[13]|0,this.Hh=Ve[14]|0,this.Hl=Ve[15]|0}get(){let{Ah:e,Al:t,Bh:n,Bl:r,Ch:i,Cl:a,Dh:o,Dl:s,Eh:c,El:l,Fh:u,Fl:d,Gh:f,Gl:p,Hh:m,Hl:h}=this;return[e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h]}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=r|0,this.Ch=i|0,this.Cl=a|0,this.Dh=o|0,this.Dl=s|0,this.Eh=c|0,this.El=l|0,this.Fh=u|0,this.Fl=d|0,this.Gh=f|0,this.Gl=p|0,this.Hh=m|0,this.Hl=h|0}process(e,t){for(let n=0;n<16;n++,t+=4)Je[n]=e.getUint32(t),Ye[n]=e.getUint32(t+=4);for(let e=16;e<80;e++){let t=Je[e-15]|0,n=Ye[e-15]|0,r=p(t,n,1)^p(t,n,8)^d(t,n,7),i=m(t,n,1)^m(t,n,8)^f(t,n,7),a=Je[e-2]|0,o=Ye[e-2]|0,s=p(a,o,19)^h(a,o,61)^d(a,o,6),c=C(i,m(a,o,19)^g(a,o,61)^f(a,o,6),Ye[e-7],Ye[e-16]);Je[e]=w(c,r,s,Je[e-7],Je[e-16])|0,Ye[e]=c|0}let{Ah:n,Al:r,Bh:i,Bl:a,Ch:o,Cl:s,Dh:c,Dl:l,Eh:u,El:_,Fh:v,Fl:y,Gh:b,Gl:D,Hh:O,Hl:k}=this;for(let e=0;e<80;e++){let t=p(u,_,14)^p(u,_,18)^h(u,_,41),d=m(u,_,14)^m(u,_,18)^g(u,_,41),f=u&v^~u&b,C=_&y^~_&D,w=T(k,d,C,qe[e],Ye[e]),te=E(w,O,t,f,Ke[e],Je[e]),ne=w|0,A=p(n,r,28)^h(n,r,34)^h(n,r,39),re=m(n,r,28)^g(n,r,34)^g(n,r,39),ie=n&i^n&o^i&o,j=r&a^r&s^a&s;O=b|0,k=D|0,b=v|0,D=y|0,v=u|0,y=_|0,{h:u,l:_}=x(c|0,l|0,te|0,ne|0),c=o|0,l=s|0,o=i|0,s=a|0,i=n|0,a=r|0;let ae=ee(ne,re,j);n=S(ae,te,A,ie),r=ae|0}({h:n,l:r}=x(this.Ah|0,this.Al|0,n|0,r|0)),{h:i,l:a}=x(this.Bh|0,this.Bl|0,i|0,a|0),{h:o,l:s}=x(this.Ch|0,this.Cl|0,o|0,s|0),{h:c,l}=x(this.Dh|0,this.Dl|0,c|0,l|0),{h:u,l:_}=x(this.Eh|0,this.El|0,u|0,_|0),{h:v,l:y}=x(this.Fh|0,this.Fl|0,v|0,y|0),{h:b,l:D}=x(this.Gh|0,this.Gl|0,b|0,D|0),{h:O,l:k}=x(this.Hh|0,this.Hl|0,O|0,k|0),this.set(n,r,i,a,o,s,c,l,u,_,v,y,b,D,O,k)}roundClean(){j(Je,Ye)}destroy(){j(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},Ze=_e(()=>new We),Qe=_e(()=>new Xe),$e=Ze,et=class extends ge{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,ne(e);let n=P(t);if(this.iHash=e.create(),typeof this.iHash.update!=`function`)throw Error(`Expected instance of class which extends utils.Hash`);this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let r=this.blockLen,i=new Uint8Array(r);i.set(n.length>r?e.create().update(n).digest():n);for(let e=0;e<i.length;e++)i[e]^=54;this.iHash.update(i),this.oHash=e.create();for(let e=0;e<i.length;e++)i[e]^=106;this.oHash.update(i),j(i)}update(e){return A(this),this.iHash.update(e),this}digestInto(e){A(this),te(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:t,iHash:n,finished:r,destroyed:i,blockLen:a,outputLen:o}=this;return e=e,e.finished=r,e.destroyed=i,e.blockLen=a,e.outputLen=o,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},tt=(e,t,n)=>new et(e,t).update(n).digest();tt.create=(e,t)=>new et(e,t);var nt=i((e=>{e.byteLength=c,e.toByteArray=u,e.fromByteArray=p;for(var t=[],n=[],r=typeof Uint8Array<`u`?Uint8Array:Array,i=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,a=0,o=i.length;a<o;++a)t[a]=i[a],n[i.charCodeAt(a)]=a;n[45]=62,n[95]=63;function s(e){var t=e.length;if(t%4>0)throw Error(`Invalid string. Length must be a multiple of 4`);var n=e.indexOf(`=`);n===-1&&(n=t);var r=n===t?0:4-n%4;return[n,r]}function c(e){var t=s(e),n=t[0],r=t[1];return(n+r)*3/4-r}function l(e,t,n){return(t+n)*3/4-n}function u(e){var t,i=s(e),a=i[0],o=i[1],c=new r(l(e,a,o)),u=0,d=o>0?a-4:a,f;for(f=0;f<d;f+=4)t=n[e.charCodeAt(f)]<<18|n[e.charCodeAt(f+1)]<<12|n[e.charCodeAt(f+2)]<<6|n[e.charCodeAt(f+3)],c[u++]=t>>16&255,c[u++]=t>>8&255,c[u++]=t&255;return o===2&&(t=n[e.charCodeAt(f)]<<2|n[e.charCodeAt(f+1)]>>4,c[u++]=t&255),o===1&&(t=n[e.charCodeAt(f)]<<10|n[e.charCodeAt(f+1)]<<4|n[e.charCodeAt(f+2)]>>2,c[u++]=t>>8&255,c[u++]=t&255),c}function d(e){return t[e>>18&63]+t[e>>12&63]+t[e>>6&63]+t[e&63]}function f(e,t,n){for(var r,i=[],a=t;a<n;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(e[a+2]&255),i.push(d(r));return i.join(``)}function p(e){for(var n,r=e.length,i=r%3,a=[],o=16383,s=0,c=r-i;s<c;s+=o)a.push(f(e,s,s+o>c?c:s+o));return i===1?(n=e[r-1],a.push(t[n>>2]+t[n<<4&63]+`==`)):i===2&&(n=(e[r-2]<<8)+e[r-1],a.push(t[n>>10]+t[n>>4&63]+t[n<<2&63]+`=`)),a.join(``)}})),rt=i((e=>{e.read=function(e,t,n,r,i){var a,o,s=i*8-r-1,c=(1<<s)-1,l=c>>1,u=-7,d=n?i-1:0,f=n?-1:1,p=e[t+d];for(d+=f,a=p&(1<<-u)-1,p>>=-u,u+=s;u>0;a=a*256+e[t+d],d+=f,u-=8);for(o=a&(1<<-u)-1,a>>=-u,u+=r;u>0;o=o*256+e[t+d],d+=f,u-=8);if(a===0)a=1-l;else if(a===c)return o?NaN:(p?-1:1)*(1/0);else o+=2**r,a-=l;return(p?-1:1)*o*2**(a-r)},e.write=function(e,t,n,r,i,a){var o,s,c,l=a*8-i-1,u=(1<<l)-1,d=u>>1,f=i===23?2**-24-2**-77:0,p=r?0:a-1,m=r?1:-1,h=+(t<0||t===0&&1/t<0);for(t=Math.abs(t),isNaN(t)||t===1/0?(s=+!!isNaN(t),o=u):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=2**-o)<1&&(o--,c*=2),o+d>=1?t+=f/c:t+=f*2**(1-d),t*c>=2&&(o++,c/=2),o+d>=u?(s=0,o=u):o+d>=1?(s=(t*c-1)*2**i,o+=d):(s=t*2**(d-1)*2**i,o=0));i>=8;e[n+p]=s&255,p+=m,s/=256,i-=8);for(o=o<<i|s,l+=i;l>0;e[n+p]=o&255,p+=m,o/=256,l-=8);e[n+p-m]|=h*128}})),it=i((e=>{var t=nt(),n=rt(),r=typeof Symbol==`function`&&typeof Symbol.for==`function`?Symbol.for(`nodejs.util.inspect.custom`):null;e.Buffer=s,e.SlowBuffer=v,e.INSPECT_MAX_BYTES=50;var i=2147483647;e.kMaxLength=i,s.TYPED_ARRAY_SUPPORT=a(),!s.TYPED_ARRAY_SUPPORT&&typeof console<`u`&&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 a(){try{let e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),e.foo()===42}catch{return!1}}Object.defineProperty(s.prototype,"parent",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.buffer}}),Object.defineProperty(s.prototype,"offset",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.byteOffset}});function o(e){if(e>i)throw RangeError(`The value "`+e+`" is invalid for option "size"`);let t=new Uint8Array(e);return Object.setPrototypeOf(t,s.prototype),t}function s(e,t,n){if(typeof e==`number`){if(typeof t==`string`)throw TypeError(`The "string" argument must be of type string. Received type number`);return d(e)}return c(e,t,n)}s.poolSize=8192;function c(e,t,n){if(typeof e==`string`)return f(e,t);if(ArrayBuffer.isView(e))return m(e);if(e==null)throw TypeError(`The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type `+typeof e);if(Se(e,ArrayBuffer)||e&&Se(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<`u`&&(Se(e,SharedArrayBuffer)||e&&Se(e.buffer,SharedArrayBuffer)))return h(e,t,n);if(typeof e==`number`)throw TypeError(`The "value" argument must not be of type number. Received type number`);let r=e.valueOf&&e.valueOf();if(r!=null&&r!==e)return s.from(r,t,n);let i=g(e);if(i)return i;if(typeof Symbol<`u`&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]==`function`)return s.from(e[Symbol.toPrimitive](`string`),t,n);throw TypeError(`The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type `+typeof e)}s.from=function(e,t,n){return c(e,t,n)},Object.setPrototypeOf(s.prototype,Uint8Array.prototype),Object.setPrototypeOf(s,Uint8Array);function l(e){if(typeof e!=`number`)throw TypeError(`"size" argument must be of type number`);if(e<0)throw RangeError(`The value "`+e+`" is invalid for option "size"`)}function u(e,t,n){return l(e),e<=0||t===void 0?o(e):typeof n==`string`?o(e).fill(t,n):o(e).fill(t)}s.alloc=function(e,t,n){return u(e,t,n)};function d(e){return l(e),o(e<0?0:_(e)|0)}s.allocUnsafe=function(e){return d(e)},s.allocUnsafeSlow=function(e){return d(e)};function f(e,t){if((typeof t!=`string`||t===``)&&(t=`utf8`),!s.isEncoding(t))throw TypeError(`Unknown encoding: `+t);let n=y(e,t)|0,r=o(n),i=r.write(e,t);return i!==n&&(r=r.slice(0,i)),r}function p(e){let t=e.length<0?0:_(e.length)|0,n=o(t);for(let r=0;r<t;r+=1)n[r]=e[r]&255;return n}function m(e){if(Se(e,Uint8Array)){let t=new Uint8Array(e);return h(t.buffer,t.byteOffset,t.byteLength)}return p(e)}function h(e,t,n){if(t<0||e.byteLength<t)throw RangeError(`"offset" is outside of buffer bounds`);if(e.byteLength<t+(n||0))throw RangeError(`"length" is outside of buffer bounds`);let r;return r=t===void 0&&n===void 0?new Uint8Array(e):n===void 0?new Uint8Array(e,t):new Uint8Array(e,t,n),Object.setPrototypeOf(r,s.prototype),r}function g(e){if(s.isBuffer(e)){let t=_(e.length)|0,n=o(t);return n.length===0||e.copy(n,0,0,t),n}if(e.length!==void 0)return typeof e.length!=`number`||Ce(e.length)?o(0):p(e);if(e.type===`Buffer`&&Array.isArray(e.data))return p(e.data)}function _(e){if(e>=i)throw RangeError(`Attempt to allocate Buffer larger than maximum size: 0x`+i.toString(16)+` bytes`);return e|0}function v(e){return+e!=e&&(e=0),s.alloc(+e)}s.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==s.prototype},s.compare=function(e,t){if(Se(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),Se(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(e)||!s.isBuffer(t))throw TypeError(`The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array`);if(e===t)return 0;let n=e.length,r=t.length;for(let i=0,a=Math.min(n,r);i<a;++i)if(e[i]!==t[i]){n=e[i],r=t[i];break}return n<r?-1:+(r<n)},s.isEncoding=function(e){switch(String(e).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}},s.concat=function(e,t){if(!Array.isArray(e))throw TypeError(`"list" argument must be an Array of Buffers`);if(e.length===0)return s.alloc(0);let n;if(t===void 0)for(t=0,n=0;n<e.length;++n)t+=e[n].length;let r=s.allocUnsafe(t),i=0;for(n=0;n<e.length;++n){let t=e[n];if(Se(t,Uint8Array))i+t.length>r.length?(s.isBuffer(t)||(t=s.from(t)),t.copy(r,i)):Uint8Array.prototype.set.call(r,t,i);else if(s.isBuffer(t))t.copy(r,i);else throw TypeError(`"list" argument must be an Array of Buffers`);i+=t.length}return r};function y(e,t){if(s.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||Se(e,ArrayBuffer))return e.byteLength;if(typeof e!=`string`)throw TypeError(`The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type `+typeof e);let n=e.length,r=arguments.length>2&&arguments[2]===!0;if(!r&&n===0)return 0;let i=!1;for(;;)switch(t){case`ascii`:case`latin1`:case`binary`:return n;case`utf8`:case`utf-8`:return _e(e).length;case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return n*2;case`hex`:return n>>>1;case`base64`:return be(e).length;default:if(i)return r?-1:_e(e).length;t=(``+t).toLowerCase(),i=!0}}s.byteLength=y;function b(e,t,n){let r=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((n===void 0||n>this.length)&&(n=this.length),n<=0)||(n>>>=0,t>>>=0,n<=t))return``;for(e||=`utf8`;;)switch(e){case`hex`:return ie(this,t,n);case`utf8`:case`utf-8`:return k(this,t,n);case`ascii`:return A(this,t,n);case`latin1`:case`binary`:return re(this,t,n);case`base64`:return O(this,t,n);case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return j(this,t,n);default:if(r)throw TypeError(`Unknown encoding: `+e);e=(e+``).toLowerCase(),r=!0}}s.prototype._isBuffer=!0;function x(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}s.prototype.swap16=function(){let e=this.length;if(e%2!=0)throw RangeError(`Buffer size must be a multiple of 16-bits`);for(let t=0;t<e;t+=2)x(this,t,t+1);return this},s.prototype.swap32=function(){let e=this.length;if(e%4!=0)throw RangeError(`Buffer size must be a multiple of 32-bits`);for(let t=0;t<e;t+=4)x(this,t,t+3),x(this,t+1,t+2);return this},s.prototype.swap64=function(){let e=this.length;if(e%8!=0)throw RangeError(`Buffer size must be a multiple of 64-bits`);for(let t=0;t<e;t+=8)x(this,t,t+7),x(this,t+1,t+6),x(this,t+2,t+5),x(this,t+3,t+4);return this},s.prototype.toString=function(){let e=this.length;return e===0?``:arguments.length===0?k(this,0,e):b.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(e){if(!s.isBuffer(e))throw TypeError(`Argument must be a Buffer`);return this===e?!0:s.compare(this,e)===0},s.prototype.inspect=function(){let t=``,n=e.INSPECT_MAX_BYTES;return t=this.toString(`hex`,0,n).replace(/(.{2})/g,`$1 `).trim(),this.length>n&&(t+=` ... `),`<Buffer `+t+`>`},r&&(s.prototype[r]=s.prototype.inspect),s.prototype.compare=function(e,t,n,r,i){if(Se(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),!s.isBuffer(e))throw TypeError(`The "target" argument must be one of type Buffer or Uint8Array. Received type `+typeof e);if(t===void 0&&(t=0),n===void 0&&(n=e?e.length:0),r===void 0&&(r=0),i===void 0&&(i=this.length),t<0||n>e.length||r<0||i>this.length)throw RangeError(`out of range index`);if(r>=i&&t>=n)return 0;if(r>=i)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,r>>>=0,i>>>=0,this===e)return 0;let a=i-r,o=n-t,c=Math.min(a,o),l=this.slice(r,i),u=e.slice(t,n);for(let e=0;e<c;++e)if(l[e]!==u[e]){a=l[e],o=u[e];break}return a<o?-1:+(o<a)};function ee(e,t,n,r,i){if(e.length===0)return-1;if(typeof n==`string`?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,Ce(n)&&(n=i?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(i)return-1;n=e.length-1}else if(n<0)if(i)n=0;else return-1;if(typeof t==`string`&&(t=s.from(t,r)),s.isBuffer(t))return t.length===0?-1:S(e,t,n,r,i);if(typeof t==`number`)return t&=255,typeof Uint8Array.prototype.indexOf==`function`?i?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):S(e,[t],n,r,i);throw TypeError(`val must be string, number or Buffer`)}function S(e,t,n,r,i){let a=1,o=e.length,s=t.length;if(r!==void 0&&(r=String(r).toLowerCase(),r===`ucs2`||r===`ucs-2`||r===`utf16le`||r===`utf-16le`)){if(e.length<2||t.length<2)return-1;a=2,o/=2,s/=2,n/=2}function c(e,t){return a===1?e[t]:e.readUInt16BE(t*a)}let l;if(i){let r=-1;for(l=n;l<o;l++)if(c(e,l)===c(t,r===-1?0:l-r)){if(r===-1&&(r=l),l-r+1===s)return r*a}else r!==-1&&(l-=l-r),r=-1}else for(n+s>o&&(n=o-s),l=n;l>=0;l--){let n=!0;for(let r=0;r<s;r++)if(c(e,l+r)!==c(t,r)){n=!1;break}if(n)return l}return-1}s.prototype.includes=function(e,t,n){return this.indexOf(e,t,n)!==-1},s.prototype.indexOf=function(e,t,n){return ee(this,e,t,n,!0)},s.prototype.lastIndexOf=function(e,t,n){return ee(this,e,t,n,!1)};function C(e,t,n,r){n=Number(n)||0;let i=e.length-n;r?(r=Number(r),r>i&&(r=i)):r=i;let a=t.length;r>a/2&&(r=a/2);let o;for(o=0;o<r;++o){let r=parseInt(t.substr(o*2,2),16);if(Ce(r))return o;e[n+o]=r}return o}function w(e,t,n,r){return xe(_e(t,e.length-n),e,n,r)}function T(e,t,n,r){return xe(ve(t),e,n,r)}function E(e,t,n,r){return xe(be(t),e,n,r)}function D(e,t,n,r){return xe(ye(t,e.length-n),e,n,r)}s.prototype.write=function(e,t,n,r){if(t===void 0)r=`utf8`,n=this.length,t=0;else if(n===void 0&&typeof t==`string`)r=t,n=this.length,t=0;else if(isFinite(t))t>>>=0,isFinite(n)?(n>>>=0,r===void 0&&(r=`utf8`)):(r=n,n=void 0);else throw Error(`Buffer.write(string, encoding, offset[, length]) is no longer supported`);let i=this.length-t;if((n===void 0||n>i)&&(n=i),e.length>0&&(n<0||t<0)||t>this.length)throw RangeError(`Attempt to write outside buffer bounds`);r||=`utf8`;let a=!1;for(;;)switch(r){case`hex`:return C(this,e,t,n);case`utf8`:case`utf-8`:return w(this,e,t,n);case`ascii`:case`latin1`:case`binary`:return T(this,e,t,n);case`base64`:return E(this,e,t,n);case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return D(this,e,t,n);default:if(a)throw TypeError(`Unknown encoding: `+r);r=(``+r).toLowerCase(),a=!0}},s.prototype.toJSON=function(){return{type:`Buffer`,data:Array.prototype.slice.call(this._arr||this,0)}};function O(e,n,r){return n===0&&r===e.length?t.fromByteArray(e):t.fromByteArray(e.slice(n,r))}function k(e,t,n){n=Math.min(e.length,n);let r=[],i=t;for(;i<n;){let t=e[i],a=null,o=t>239?4:t>223?3:t>191?2:1;if(i+o<=n){let n,r,s,c;switch(o){case 1:t<128&&(a=t);break;case 2:n=e[i+1],(n&192)==128&&(c=(t&31)<<6|n&63,c>127&&(a=c));break;case 3:n=e[i+1],r=e[i+2],(n&192)==128&&(r&192)==128&&(c=(t&15)<<12|(n&63)<<6|r&63,c>2047&&(c<55296||c>57343)&&(a=c));break;case 4:n=e[i+1],r=e[i+2],s=e[i+3],(n&192)==128&&(r&192)==128&&(s&192)==128&&(c=(t&15)<<18|(n&63)<<12|(r&63)<<6|s&63,c>65535&&c<1114112&&(a=c))}}a===null?(a=65533,o=1):a>65535&&(a-=65536,r.push(a>>>10&1023|55296),a=56320|a&1023),r.push(a),i+=o}return ne(r)}var te=4096;function ne(e){let t=e.length;if(t<=te)return String.fromCharCode.apply(String,e);let n=``,r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=te));return n}function A(e,t,n){let r=``;n=Math.min(e.length,n);for(let i=t;i<n;++i)r+=String.fromCharCode(e[i]&127);return r}function re(e,t,n){let r=``;n=Math.min(e.length,n);for(let i=t;i<n;++i)r+=String.fromCharCode(e[i]);return r}function ie(e,t,n){let r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);let i=``;for(let r=t;r<n;++r)i+=we[e[r]];return i}function j(e,t,n){let r=e.slice(t,n),i=``;for(let e=0;e<r.length-1;e+=2)i+=String.fromCharCode(r[e]+r[e+1]*256);return i}s.prototype.slice=function(e,t){let n=this.length;e=~~e,t=t===void 0?n:~~t,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),t<e&&(t=e);let r=this.subarray(e,t);return Object.setPrototypeOf(r,s.prototype),r};function ae(e,t,n){if(e%1!=0||e<0)throw RangeError(`offset is not uint`);if(e+t>n)throw RangeError(`Trying to access beyond buffer length`)}s.prototype.readUintLE=s.prototype.readUIntLE=function(e,t,n){e>>>=0,t>>>=0,n||ae(e,t,this.length);let r=this[e],i=1,a=0;for(;++a<t&&(i*=256);)r+=this[e+a]*i;return r},s.prototype.readUintBE=s.prototype.readUIntBE=function(e,t,n){e>>>=0,t>>>=0,n||ae(e,t,this.length);let r=this[e+--t],i=1;for(;t>0&&(i*=256);)r+=this[e+--t]*i;return r},s.prototype.readUint8=s.prototype.readUInt8=function(e,t){return e>>>=0,t||ae(e,1,this.length),this[e]},s.prototype.readUint16LE=s.prototype.readUInt16LE=function(e,t){return e>>>=0,t||ae(e,2,this.length),this[e]|this[e+1]<<8},s.prototype.readUint16BE=s.prototype.readUInt16BE=function(e,t){return e>>>=0,t||ae(e,2,this.length),this[e]<<8|this[e+1]},s.prototype.readUint32LE=s.prototype.readUInt32LE=function(e,t){return e>>>=0,t||ae(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216},s.prototype.readUint32BE=s.prototype.readUInt32BE=function(e,t){return e>>>=0,t||ae(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])},s.prototype.readBigUInt64LE=Te(function(e){e>>>=0,he(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&P(e,this.length-8);let r=t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,i=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(r)+(BigInt(i)<<BigInt(32))}),s.prototype.readBigUInt64BE=Te(function(e){e>>>=0,he(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&P(e,this.length-8);let r=t*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],i=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(r)<<BigInt(32))+BigInt(i)}),s.prototype.readIntLE=function(e,t,n){e>>>=0,t>>>=0,n||ae(e,t,this.length);let r=this[e],i=1,a=0;for(;++a<t&&(i*=256);)r+=this[e+a]*i;return i*=128,r>=i&&(r-=2**(8*t)),r},s.prototype.readIntBE=function(e,t,n){e>>>=0,t>>>=0,n||ae(e,t,this.length);let r=t,i=1,a=this[e+--r];for(;r>0&&(i*=256);)a+=this[e+--r]*i;return i*=128,a>=i&&(a-=2**(8*t)),a},s.prototype.readInt8=function(e,t){return e>>>=0,t||ae(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]},s.prototype.readInt16LE=function(e,t){e>>>=0,t||ae(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n},s.prototype.readInt16BE=function(e,t){e>>>=0,t||ae(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n},s.prototype.readInt32LE=function(e,t){return e>>>=0,t||ae(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},s.prototype.readInt32BE=function(e,t){return e>>>=0,t||ae(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},s.prototype.readBigInt64LE=Te(function(e){e>>>=0,he(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&P(e,this.length-8);let r=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(r)<<BigInt(32))+BigInt(t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)}),s.prototype.readBigInt64BE=Te(function(e){e>>>=0,he(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&P(e,this.length-8);let r=(t<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(r)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)}),s.prototype.readFloatLE=function(e,t){return e>>>=0,t||ae(e,4,this.length),n.read(this,e,!0,23,4)},s.prototype.readFloatBE=function(e,t){return e>>>=0,t||ae(e,4,this.length),n.read(this,e,!1,23,4)},s.prototype.readDoubleLE=function(e,t){return e>>>=0,t||ae(e,8,this.length),n.read(this,e,!0,52,8)},s.prototype.readDoubleBE=function(e,t){return e>>>=0,t||ae(e,8,this.length),n.read(this,e,!1,52,8)};function M(e,t,n,r,i,a){if(!s.isBuffer(e))throw TypeError(`"buffer" argument must be a Buffer instance`);if(t>i||t<a)throw RangeError(`"value" argument is out of bounds`);if(n+r>e.length)throw RangeError(`Index out of range`)}s.prototype.writeUintLE=s.prototype.writeUIntLE=function(e,t,n,r){if(e=+e,t>>>=0,n>>>=0,!r){let r=2**(8*n)-1;M(this,e,t,n,r,0)}let i=1,a=0;for(this[t]=e&255;++a<n&&(i*=256);)this[t+a]=e/i&255;return t+n},s.prototype.writeUintBE=s.prototype.writeUIntBE=function(e,t,n,r){if(e=+e,t>>>=0,n>>>=0,!r){let r=2**(8*n)-1;M(this,e,t,n,r,0)}let i=n-1,a=1;for(this[t+i]=e&255;--i>=0&&(a*=256);)this[t+i]=e/a&255;return t+n},s.prototype.writeUint8=s.prototype.writeUInt8=function(e,t,n){return e=+e,t>>>=0,n||M(this,e,t,1,255,0),this[t]=e&255,t+1},s.prototype.writeUint16LE=s.prototype.writeUInt16LE=function(e,t,n){return e=+e,t>>>=0,n||M(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2},s.prototype.writeUint16BE=s.prototype.writeUInt16BE=function(e,t,n){return e=+e,t>>>=0,n||M(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2},s.prototype.writeUint32LE=s.prototype.writeUInt32LE=function(e,t,n){return e=+e,t>>>=0,n||M(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4},s.prototype.writeUint32BE=s.prototype.writeUInt32BE=function(e,t,n){return e=+e,t>>>=0,n||M(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};function oe(e,t,n,r,i){me(t,r,i,e,n,7);let a=Number(t&BigInt(4294967295));e[n++]=a,a>>=8,e[n++]=a,a>>=8,e[n++]=a,a>>=8,e[n++]=a;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[n++]=o,o>>=8,e[n++]=o,o>>=8,e[n++]=o,o>>=8,e[n++]=o,n}function se(e,t,n,r,i){me(t,r,i,e,n,7);let a=Number(t&BigInt(4294967295));e[n+7]=a,a>>=8,e[n+6]=a,a>>=8,e[n+5]=a,a>>=8,e[n+4]=a;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[n+3]=o,o>>=8,e[n+2]=o,o>>=8,e[n+1]=o,o>>=8,e[n]=o,n+8}s.prototype.writeBigUInt64LE=Te(function(e,t=0){return oe(this,e,t,BigInt(0),BigInt(`0xffffffffffffffff`))}),s.prototype.writeBigUInt64BE=Te(function(e,t=0){return se(this,e,t,BigInt(0),BigInt(`0xffffffffffffffff`))}),s.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t>>>=0,!r){let r=2**(8*n-1);M(this,e,t,n,r-1,-r)}let i=0,a=1,o=0;for(this[t]=e&255;++i<n&&(a*=256);)e<0&&o===0&&this[t+i-1]!==0&&(o=1),this[t+i]=(e/a>>0)-o&255;return t+n},s.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t>>>=0,!r){let r=2**(8*n-1);M(this,e,t,n,r-1,-r)}let i=n-1,a=1,o=0;for(this[t+i]=e&255;--i>=0&&(a*=256);)e<0&&o===0&&this[t+i+1]!==0&&(o=1),this[t+i]=(e/a>>0)-o&255;return t+n},s.prototype.writeInt8=function(e,t,n){return e=+e,t>>>=0,n||M(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1},s.prototype.writeInt16LE=function(e,t,n){return e=+e,t>>>=0,n||M(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2},s.prototype.writeInt16BE=function(e,t,n){return e=+e,t>>>=0,n||M(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2},s.prototype.writeInt32LE=function(e,t,n){return e=+e,t>>>=0,n||M(this,e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},s.prototype.writeInt32BE=function(e,t,n){return e=+e,t>>>=0,n||M(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4},s.prototype.writeBigInt64LE=Te(function(e,t=0){return oe(this,e,t,-BigInt(`0x8000000000000000`),BigInt(`0x7fffffffffffffff`))}),s.prototype.writeBigInt64BE=Te(function(e,t=0){return se(this,e,t,-BigInt(`0x8000000000000000`),BigInt(`0x7fffffffffffffff`))});function ce(e,t,n,r,i,a){if(n+r>e.length||n<0)throw RangeError(`Index out of range`)}function le(e,t,r,i,a){return t=+t,r>>>=0,a||ce(e,t,r,4,34028234663852886e22,-34028234663852886e22),n.write(e,t,r,i,23,4),r+4}s.prototype.writeFloatLE=function(e,t,n){return le(this,e,t,!0,n)},s.prototype.writeFloatBE=function(e,t,n){return le(this,e,t,!1,n)};function ue(e,t,r,i,a){return t=+t,r>>>=0,a||ce(e,t,r,8,17976931348623157e292,-17976931348623157e292),n.write(e,t,r,i,52,8),r+8}s.prototype.writeDoubleLE=function(e,t,n){return ue(this,e,t,!0,n)},s.prototype.writeDoubleBE=function(e,t,n){return ue(this,e,t,!1,n)},s.prototype.copy=function(e,t,n,r){if(!s.isBuffer(e))throw TypeError(`argument should be a Buffer`);if(n||=0,!r&&r!==0&&(r=this.length),t>=e.length&&(t=e.length),t||=0,r>0&&r<n&&(r=n),r===n||e.length===0||this.length===0)return 0;if(t<0)throw RangeError(`targetStart out of bounds`);if(n<0||n>=this.length)throw RangeError(`Index out of range`);if(r<0)throw RangeError(`sourceEnd out of bounds`);r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);let i=r-n;return this===e&&typeof Uint8Array.prototype.copyWithin==`function`?this.copyWithin(t,n,r):Uint8Array.prototype.set.call(e,this.subarray(n,r),t),i},s.prototype.fill=function(e,t,n,r){if(typeof e==`string`){if(typeof t==`string`?(r=t,t=0,n=this.length):typeof n==`string`&&(r=n,n=this.length),r!==void 0&&typeof r!=`string`)throw TypeError(`encoding must be a string`);if(typeof r==`string`&&!s.isEncoding(r))throw TypeError(`Unknown encoding: `+r);if(e.length===1){let t=e.charCodeAt(0);(r===`utf8`&&t<128||r===`latin1`)&&(e=t)}}else typeof e==`number`?e&=255:typeof e==`boolean`&&(e=Number(e));if(t<0||this.length<t||this.length<n)throw RangeError(`Out of range index`);if(n<=t)return this;t>>>=0,n=n===void 0?this.length:n>>>0,e||=0;let i;if(typeof e==`number`)for(i=t;i<n;++i)this[i]=e;else{let a=s.isBuffer(e)?e:s.from(e,r),o=a.length;if(o===0)throw TypeError(`The value "`+e+`" is invalid for argument "value"`);for(i=0;i<n-t;++i)this[i+t]=a[i%o]}return this};var de={};function N(e,t,n){de[e]=class extends n{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(e){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:e,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}N(`ERR_BUFFER_OUT_OF_BOUNDS`,function(e){return e?`${e} is outside of buffer bounds`:`Attempt to access memory outside buffer bounds`},RangeError),N(`ERR_INVALID_ARG_TYPE`,function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError),N(`ERR_OUT_OF_RANGE`,function(e,t,n){let r=`The value of "${e}" is out of range.`,i=n;return Number.isInteger(n)&&Math.abs(n)>2**32?i=fe(String(n)):typeof n==`bigint`&&(i=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(i=fe(i)),i+=`n`),r+=` It must be ${t}. Received ${i}`,r},RangeError);function fe(e){let t=``,n=e.length,r=+(e[0]===`-`);for(;n>=r+4;n-=3)t=`_${e.slice(n-3,n)}${t}`;return`${e.slice(0,n)}${t}`}function pe(e,t,n){he(t,`offset`),(e[t]===void 0||e[t+n]===void 0)&&P(t,e.length-(n+1))}function me(e,t,n,r,i,a){if(e>n||e<t){let r=typeof t==`bigint`?`n`:``,i;throw i=a>3?t===0||t===BigInt(0)?`>= 0${r} and < 2${r} ** ${(a+1)*8}${r}`:`>= -(2${r} ** ${(a+1)*8-1}${r}) and < 2 ** ${(a+1)*8-1}${r}`:`>= ${t}${r} and <= ${n}${r}`,new de.ERR_OUT_OF_RANGE(`value`,i,e)}pe(r,i,a)}function he(e,t){if(typeof e!=`number`)throw new de.ERR_INVALID_ARG_TYPE(t,`number`,e)}function P(e,t,n){throw Math.floor(e)===e?t<0?new de.ERR_BUFFER_OUT_OF_BOUNDS:new de.ERR_OUT_OF_RANGE(n||`offset`,`>= ${+!!n} and <= ${t}`,e):(he(e,n),new de.ERR_OUT_OF_RANGE(n||`offset`,`an integer`,e))}var F=/[^+/0-9A-Za-z-_]/g;function ge(e){if(e=e.split(`=`)[0],e=e.trim().replace(F,``),e.length<2)return``;for(;e.length%4!=0;)e+=`=`;return e}function _e(e,t){t||=1/0;let n,r=e.length,i=null,a=[];for(let o=0;o<r;++o){if(n=e.charCodeAt(o),n>55295&&n<57344){if(!i){if(n>56319){(t-=3)>-1&&a.push(239,191,189);continue}else if(o+1===r){(t-=3)>-1&&a.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&a.push(239,191,189),i=n;continue}n=(i-55296<<10|n-56320)+65536}else i&&(t-=3)>-1&&a.push(239,191,189);if(i=null,n<128){if(--t<0)break;a.push(n)}else if(n<2048){if((t-=2)<0)break;a.push(n>>6|192,n&63|128)}else if(n<65536){if((t-=3)<0)break;a.push(n>>12|224,n>>6&63|128,n&63|128)}else if(n<1114112){if((t-=4)<0)break;a.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128)}else throw Error(`Invalid code point`)}return a}function ve(e){let t=[];for(let n=0;n<e.length;++n)t.push(e.charCodeAt(n)&255);return t}function ye(e,t){let n,r,i,a=[];for(let o=0;o<e.length&&!((t-=2)<0);++o)n=e.charCodeAt(o),r=n>>8,i=n%256,a.push(i),a.push(r);return a}function be(e){return t.toByteArray(ge(e))}function xe(e,t,n,r){let i;for(i=0;i<r&&!(i+n>=t.length||i>=e.length);++i)t[i+n]=e[i];return i}function Se(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function Ce(e){return e!==e}var we=(function(){let e=`0123456789abcdef`,t=Array(256);for(let n=0;n<16;++n){let r=n*16;for(let i=0;i<16;++i)t[r+i]=e[n]+e[i]}return t})();function Te(e){return typeof BigInt>`u`?Ee:e}function Ee(){throw Error(`BigInt not supported`)}})),I=it(),at=BigInt(0),ot=BigInt(1);function st(e,t=``){if(typeof e!=`boolean`){let n=t&&`"${t}"`;throw Error(n+`expected boolean, got type=`+typeof e)}return e}function ct(e,t,n=``){let r=O(e),i=e?.length,a=t!==void 0;if(!r||a&&i!==t){let o=n&&`"${n}" `,s=a?` of length ${t}`:``,c=r?`length=${i}`:`type=${typeof e}`;throw Error(o+`expected Uint8Array`+s+`, got `+c)}return e}function lt(e){let t=e.toString(16);return t.length&1?`0`+t:t}function ut(e){if(typeof e!=`string`)throw Error(`hex string expected, got `+typeof e);return e===``?at:BigInt(`0x`+e)}function dt(e){return ut(N(e))}function ft(e){return te(e),ut(N(Uint8Array.from(e).reverse()))}function pt(e,t){return me(e.toString(16).padStart(t*2,`0`))}function mt(e,t){return pt(e,t).reverse()}function ht(e,t,n){let r;if(typeof t==`string`)try{r=me(t)}catch(t){throw Error(e+` must be hex string or Uint8Array, cause: `+t)}else if(O(t))r=Uint8Array.from(t);else throw Error(e+` must be hex string or Uint8Array`);let i=r.length;if(typeof n==`number`&&i!==n)throw Error(e+` of length `+n+` expected, got `+i);return r}function gt(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return n===0}function _t(e){return Uint8Array.from(e)}var vt=e=>typeof e==`bigint`&&at<=e;function yt(e,t,n){return vt(e)&&vt(t)&&vt(n)&&t<=e&&e<n}function bt(e,t,n,r){if(!yt(t,n,r))throw Error(`expected valid `+e+`: `+n+` <= n < `+r+`, got `+t)}function xt(e){let t;for(t=0;e>at;e>>=ot,t+=1);return t}var St=e=>(ot<<BigInt(e))-ot;function Ct(e,t,n){if(typeof e!=`number`||e<2)throw Error(`hashLen must be a number`);if(typeof t!=`number`||t<2)throw Error(`qByteLen must be a number`);if(typeof n!=`function`)throw Error(`hmacFn must be a function`);let r=e=>new Uint8Array(e),i=e=>Uint8Array.of(e),a=r(e),o=r(e),s=0,c=()=>{a.fill(1),o.fill(0),s=0},l=(...e)=>n(o,a,...e),u=(e=r(0))=>{o=l(i(0),e),a=l(),e.length!==0&&(o=l(i(1),e),a=l())},d=()=>{if(s++>=1e3)throw Error(`drbg: tried 1000 values`);let e=0,n=[];for(;e<t;){a=l();let t=a.slice();n.push(t),e+=a.length}return F(...n)};return(e,t)=>{c(),u(e);let n;for(;!(n=t(d()));)u();return c(),n}}function wt(e,t,n={}){if(!e||typeof e!=`object`)throw Error(`expected valid options object`);function r(t,n,r){let i=e[t];if(r&&i===void 0)return;let a=typeof i;if(a!==n||i===null)throw Error(`param "${t}" is invalid: expected ${n}, got ${a}`)}Object.entries(t).forEach(([e,t])=>r(e,t,!1)),Object.entries(n).forEach(([e,t])=>r(e,t,!0))}var Tt=()=>{throw Error(`not implemented`)};function Et(e){let t=new WeakMap;return(n,...r)=>{let i=t.get(n);if(i!==void 0)return i;let a=e(n,...r);return t.set(n,a),a}}var Dt=BigInt(0),Ot=BigInt(1),kt=BigInt(2),At=BigInt(3),jt=BigInt(4),Mt=BigInt(5),Nt=BigInt(7),Pt=BigInt(8),Ft=BigInt(9),It=BigInt(16);function Lt(e,t){let n=e%t;return n>=Dt?n:t+n}function Rt(e,t,n){let r=e;for(;t-- >Dt;)r*=r,r%=n;return r}function zt(e,t){if(e===Dt)throw Error(`invert: expected non-zero number`);if(t<=Dt)throw Error(`invert: expected positive modulus, got `+t);let n=Lt(e,t),r=t,i=Dt,a=Ot,o=Ot,s=Dt;for(;n!==Dt;){let e=r/n,t=r%n,c=i-o*e,l=a-s*e;r=n,n=t,i=o,a=s,o=c,s=l}if(r!==Ot)throw Error(`invert: does not exist`);return Lt(i,t)}function Bt(e,t,n){if(!e.eql(e.sqr(t),n))throw Error(`Cannot find square root`)}function Vt(e,t){let n=(e.ORDER+Ot)/jt,r=e.pow(t,n);return Bt(e,r,t),r}function Ht(e,t){let n=(e.ORDER-Mt)/Pt,r=e.mul(t,kt),i=e.pow(r,n),a=e.mul(t,i),o=e.mul(e.mul(a,kt),i),s=e.mul(a,e.sub(o,e.ONE));return Bt(e,s,t),s}function Ut(e){let t=$t(e),n=Wt(e),r=n(t,t.neg(t.ONE)),i=n(t,r),a=n(t,t.neg(r)),o=(e+Nt)/It;return(e,t)=>{let n=e.pow(t,o),s=e.mul(n,r),c=e.mul(n,i),l=e.mul(n,a),u=e.eql(e.sqr(s),t),d=e.eql(e.sqr(c),t);n=e.cmov(n,s,u),s=e.cmov(l,c,d);let f=e.eql(e.sqr(s),t),p=e.cmov(n,s,f);return Bt(e,p,t),p}}function Wt(e){if(e<At)throw Error(`sqrt is not defined for small field`);let t=e-Ot,n=0;for(;t%kt===Dt;)t/=kt,n++;let r=kt,i=$t(e);for(;Zt(i,r)===1;)if(r++>1e3)throw Error(`Cannot find square root: probably non-prime P`);if(n===1)return Vt;let a=i.pow(r,t),o=(t+Ot)/kt;return function(e,r){if(e.is0(r))return r;if(Zt(e,r)!==1)throw Error(`Cannot find square root`);let i=n,s=e.mul(e.ONE,a),c=e.pow(r,t),l=e.pow(r,o);for(;!e.eql(c,e.ONE);){if(e.is0(c))return e.ZERO;let t=1,n=e.sqr(c);for(;!e.eql(n,e.ONE);)if(t++,n=e.sqr(n),t===i)throw Error(`Cannot find square root`);let r=Ot<<BigInt(i-t-1),a=e.pow(s,r);i=t,s=e.sqr(a),c=e.mul(c,s),l=e.mul(l,a)}return l}}function Gt(e){return e%jt===At?Vt:e%Pt===Mt?Ht:e%It===Ft?Ut(e):Wt(e)}var Kt=(e,t)=>(Lt(e,t)&Ot)===Ot,qt=[`create`,`isValid`,`is0`,`neg`,`inv`,`sqrt`,`sqr`,`eql`,`add`,`sub`,`mul`,`pow`,`div`,`addN`,`subN`,`mulN`,`sqrN`];function Jt(e){return wt(e,qt.reduce((e,t)=>(e[t]=`function`,e),{ORDER:`bigint`,MASK:`bigint`,BYTES:`number`,BITS:`number`})),e}function Yt(e,t,n){if(n<Dt)throw Error(`invalid exponent, negatives unsupported`);if(n===Dt)return e.ONE;if(n===Ot)return t;let r=e.ONE,i=t;for(;n>Dt;)n&Ot&&(r=e.mul(r,i)),i=e.sqr(i),n>>=Ot;return r}function Xt(e,t,n=!1){let r=Array(t.length).fill(n?e.ZERO:void 0),i=t.reduce((t,n,i)=>e.is0(n)?t:(r[i]=t,e.mul(t,n)),e.ONE),a=e.inv(i);return t.reduceRight((t,n,i)=>e.is0(n)?t:(r[i]=e.mul(t,r[i]),e.mul(t,n)),a),r}function Zt(e,t){let n=(e.ORDER-Ot)/kt,r=e.pow(t,n),i=e.eql(r,e.ONE),a=e.eql(r,e.ZERO),o=e.eql(r,e.neg(e.ONE));if(!i&&!a&&!o)throw Error(`invalid Legendre symbol result`);return i?1:a?0:-1}function Qt(e,t){t!==void 0&&k(t);let n=t===void 0?e.toString(2).length:t;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function $t(e,t,n=!1,r={}){if(e<=Dt)throw Error(`invalid field: expected ORDER > 0, got `+e);let i,a,o=!1,s;if(typeof t==`object`&&t){if(r.sqrt||n)throw Error(`cannot specify opts in two arguments`);let e=t;e.BITS&&(i=e.BITS),e.sqrt&&(a=e.sqrt),typeof e.isLE==`boolean`&&(n=e.isLE),typeof e.modFromBytes==`boolean`&&(o=e.modFromBytes),s=e.allowedLengths}else typeof t==`number`&&(i=t),r.sqrt&&(a=r.sqrt);let{nBitLength:c,nByteLength:l}=Qt(e,i);if(l>2048)throw Error(`invalid field: expected ORDER of <= 2048 bytes`);let u,d=Object.freeze({ORDER:e,isLE:n,BITS:c,BYTES:l,MASK:St(c),ZERO:Dt,ONE:Ot,allowedLengths:s,create:t=>Lt(t,e),isValid:t=>{if(typeof t!=`bigint`)throw Error(`invalid field element: expected bigint, got `+typeof t);return Dt<=t&&t<e},is0:e=>e===Dt,isValidNot0:e=>!d.is0(e)&&d.isValid(e),isOdd:e=>(e&Ot)===Ot,neg:t=>Lt(-t,e),eql:(e,t)=>e===t,sqr:t=>Lt(t*t,e),add:(t,n)=>Lt(t+n,e),sub:(t,n)=>Lt(t-n,e),mul:(t,n)=>Lt(t*n,e),pow:(e,t)=>Yt(d,e,t),div:(t,n)=>Lt(t*zt(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>zt(t,e),sqrt:a||(t=>(u||=Gt(e),u(d,t))),toBytes:e=>n?mt(e,l):pt(e,l),fromBytes:(t,r=!0)=>{if(s){if(!s.includes(t.length)||t.length>l)throw Error(`Field.fromBytes: expected `+s+` bytes, got `+t.length);let e=new Uint8Array(l);e.set(t,n?0:e.length-t.length),t=e}if(t.length!==l)throw Error(`Field.fromBytes: expected `+l+` bytes, got `+t.length);let i=n?ft(t):dt(t);if(o&&(i=Lt(i,e)),!r&&!d.isValid(i))throw Error(`invalid field element: outside of range 0..ORDER`);return i},invertBatch:e=>Xt(d,e),cmov:(e,t,n)=>n?t:e});return Object.freeze(d)}function en(e){if(typeof e!=`bigint`)throw Error(`field order must be bigint`);let t=e.toString(2).length;return Math.ceil(t/8)}function tn(e){let t=en(e);return t+Math.ceil(t/2)}function nn(e,t,n=!1){let r=e.length,i=en(t),a=tn(t);if(r<16||r<a||r>1024)throw Error(`expected `+a+`-1024 bytes of input, got `+r);let o=Lt(n?ft(e):dt(e),t-Ot)+Ot;return n?mt(o,i):pt(o,i)}var rn=BigInt(0),an=BigInt(1);function on(e,t){let n=t.negate();return e?n:t}function sn(e,t){let n=Xt(e.Fp,t.map(e=>e.Z));return t.map((t,r)=>e.fromAffine(t.toAffine(n[r])))}function cn(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw Error(`invalid window size, expected [1..`+t+`], got W=`+e)}function ln(e,t){cn(e,t);let n=Math.ceil(t/e)+1,r=2**(e-1),i=2**e;return{windows:n,windowSize:r,mask:St(e),maxNumber:i,shiftBy:BigInt(e)}}function un(e,t,n){let{windowSize:r,mask:i,maxNumber:a,shiftBy:o}=n,s=Number(e&i),c=e>>o;s>r&&(s-=a,c+=an);let l=t*r,u=l+Math.abs(s)-1,d=s===0,f=s<0,p=t%2!=0;return{nextN:c,offset:u,isZero:d,isNeg:f,isNegF:p,offsetF:l}}function dn(e,t){if(!Array.isArray(e))throw Error(`array expected`);e.forEach((e,n)=>{if(!(e instanceof t))throw Error(`invalid point at index `+n)})}function fn(e,t){if(!Array.isArray(e))throw Error(`array of scalars expected`);e.forEach((e,n)=>{if(!t.isValid(e))throw Error(`invalid scalar at index `+n)})}var pn=new WeakMap,mn=new WeakMap;function hn(e){return mn.get(e)||1}function gn(e){if(e!==rn)throw Error(`invalid wNAF`)}var _n=class{constructor(e,t){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=t}_unsafeLadder(e,t,n=this.ZERO){let r=e;for(;t>rn;)t&an&&(n=n.add(r)),r=r.double(),t>>=an;return n}precomputeWindow(e,t){let{windows:n,windowSize:r}=ln(t,this.bits),i=[],a=e,o=a;for(let e=0;e<n;e++){o=a,i.push(o);for(let e=1;e<r;e++)o=o.add(a),i.push(o);a=o.double()}return i}wNAF(e,t,n){if(!this.Fn.isValid(n))throw Error(`invalid scalar`);let r=this.ZERO,i=this.BASE,a=ln(e,this.bits);for(let e=0;e<a.windows;e++){let{nextN:o,offset:s,isZero:c,isNeg:l,isNegF:u,offsetF:d}=un(n,e,a);n=o,c?i=i.add(on(u,t[d])):r=r.add(on(l,t[s]))}return gn(n),{p:r,f:i}}wNAFUnsafe(e,t,n,r=this.ZERO){let i=ln(e,this.bits);for(let e=0;e<i.windows&&n!==rn;e++){let{nextN:a,offset:o,isZero:s,isNeg:c}=un(n,e,i);if(n=a,!s){let e=t[o];r=r.add(c?e.negate():e)}}return gn(n),r}getPrecomputes(e,t,n){let r=pn.get(t);return r||(r=this.precomputeWindow(t,e),e!==1&&(typeof n==`function`&&(r=n(r)),pn.set(t,r))),r}cached(e,t,n){let r=hn(e);return this.wNAF(r,this.getPrecomputes(r,e,n),t)}unsafe(e,t,n,r){let i=hn(e);return i===1?this._unsafeLadder(e,t,r):this.wNAFUnsafe(i,this.getPrecomputes(i,e,n),t,r)}createCache(e,t){cn(t,this.bits),mn.set(e,t),pn.delete(e)}hasCache(e){return hn(e)!==1}};function vn(e,t,n,r){let i=t,a=e.ZERO,o=e.ZERO;for(;n>rn||r>rn;)n&an&&(a=a.add(i)),r&an&&(o=o.add(i)),i=i.double(),n>>=an,r>>=an;return{p1:a,p2:o}}function yn(e,t,n,r){dn(n,e),fn(r,t);let i=n.length,a=r.length;if(i!==a)throw Error(`arrays of points and scalars must have equal length`);let o=e.ZERO,s=xt(BigInt(i)),c=1;s>12?c=s-3:s>4?c=s-2:s>0&&(c=2);let l=St(c),u=Array(Number(l)+1).fill(o),d=Math.floor((t.BITS-1)/c)*c,f=o;for(let e=d;e>=0;e-=c){u.fill(o);for(let t=0;t<a;t++){let i=r[t],a=Number(i>>BigInt(e)&l);u[a]=u[a].add(n[t])}let t=o;for(let e=u.length-1,n=o;e>0;e--)n=n.add(u[e]),t=t.add(n);if(f=f.add(t),e!==0)for(let e=0;e<c;e++)f=f.double()}return f}function bn(e,t,n){if(t){if(t.ORDER!==e)throw Error(`Field.ORDER must match order: Fp == p, Fn == n`);return Jt(t),t}else return $t(e,{isLE:n})}function xn(e,t,n={},r){if(r===void 0&&(r=e===`edwards`),!t||typeof t!=`object`)throw Error(`expected valid ${e} CURVE object`);for(let e of[`p`,`n`,`h`]){let n=t[e];if(!(typeof n==`bigint`&&n>rn))throw Error(`CURVE.${e} must be positive bigint`)}let i=bn(t.p,n.Fp,r),a=bn(t.n,n.Fn,r),o=[`Gx`,`Gy`,`a`,e===`weierstrass`?`b`:`d`];for(let e of o)if(!i.isValid(t[e]))throw Error(`CURVE.${e} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:i,Fn:a}}var Sn=BigInt(0),Cn=BigInt(1),wn=BigInt(2),Tn=BigInt(8);function En(e,t,n,r){let i=e.sqr(n),a=e.sqr(r),o=e.add(e.mul(t.a,i),a),s=e.add(e.ONE,e.mul(t.d,e.mul(i,a)));return e.eql(o,s)}function Dn(e,t={}){let n=xn(`edwards`,e,t,t.FpFnLE),{Fp:r,Fn:i}=n,a=n.CURVE,{h:o}=a;wt(t,{},{uvRatio:`function`});let s=wn<<BigInt(i.BYTES*8)-Cn,c=e=>r.create(e),l=t.uvRatio||((e,t)=>{try{return{isValid:!0,value:r.sqrt(r.div(e,t))}}catch{return{isValid:!1,value:Sn}}});if(!En(r,a,a.Gx,a.Gy))throw Error(`bad curve params: generator point`);function u(e,t,n=!1){let r=n?Cn:Sn;return bt(`coordinate `+e,t,r,s),t}function d(e){if(!(e instanceof m))throw Error(`ExtendedPoint expected`)}let f=Et((e,t)=>{let{X:n,Y:i,Z:a}=e,o=e.is0();t??=o?Tn:r.inv(a);let s=c(n*t),l=c(i*t),u=r.mul(a,t);if(o)return{x:Sn,y:Cn};if(u!==Cn)throw Error(`invZ was invalid`);return{x:s,y:l}}),p=Et(e=>{let{a:t,d:n}=a;if(e.is0())throw Error(`bad point: ZERO`);let{X:r,Y:i,Z:o,T:s}=e,l=c(r*r),u=c(i*i),d=c(o*o),f=c(d*d);if(c(d*c(c(l*t)+u))!==c(f+c(n*c(l*u))))throw Error(`bad point: equation left != right (1)`);if(c(r*i)!==c(o*s))throw Error(`bad point: equation left != right (2)`);return!0});class m{constructor(e,t,n,r){this.X=u(`x`,e),this.Y=u(`y`,t),this.Z=u(`z`,n,!0),this.T=u(`t`,r),Object.freeze(this)}static CURVE(){return a}static fromAffine(e){if(e instanceof m)throw Error(`extended point not allowed`);let{x:t,y:n}=e||{};return u(`x`,t),u(`y`,n),new m(t,n,Cn,c(t*n))}static fromBytes(e,t=!1){let n=r.BYTES,{a:i,d:o}=a;e=_t(ct(e,n,`point`)),st(t,`zip215`);let u=_t(e),d=e[n-1];u[n-1]=d&-129;let f=ft(u);bt(`point.y`,f,Sn,t?s:r.ORDER);let p=c(f*f),{isValid:h,value:g}=l(c(p-Cn),c(o*p-i));if(!h)throw Error(`bad point: invalid y coordinate`);let _=(g&Cn)===Cn,v=(d&128)!=0;if(!t&&g===Sn&&v)throw Error(`bad point: x=0 and x_0=1`);return v!==_&&(g=c(-g)),m.fromAffine({x:g,y:f})}static fromHex(e,t=!1){return m.fromBytes(ht(`point`,e),t)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(e=8,t=!0){return h.createCache(this,e),t||this.multiply(wn),this}assertValidity(){p(this)}equals(e){d(e);let{X:t,Y:n,Z:r}=this,{X:i,Y:a,Z:o}=e,s=c(t*o),l=c(i*r),u=c(n*o),f=c(a*r);return s===l&&u===f}is0(){return this.equals(m.ZERO)}negate(){return new m(c(-this.X),this.Y,this.Z,c(-this.T))}double(){let{a:e}=a,{X:t,Y:n,Z:r}=this,i=c(t*t),o=c(n*n),s=c(wn*c(r*r)),l=c(e*i),u=t+n,d=c(c(u*u)-i-o),f=l+o,p=f-s,h=l-o,g=c(d*p),_=c(f*h),v=c(d*h);return new m(g,_,c(p*f),v)}add(e){d(e);let{a:t,d:n}=a,{X:r,Y:i,Z:o,T:s}=this,{X:l,Y:u,Z:f,T:p}=e,h=c(r*l),g=c(i*u),_=c(s*n*p),v=c(o*f),y=c((r+i)*(l+u)-h-g),b=v-_,x=v+_,ee=c(g-t*h),S=c(y*b),C=c(x*ee),w=c(y*ee);return new m(S,C,c(b*x),w)}subtract(e){return this.add(e.negate())}multiply(e){if(!i.isValidNot0(e))throw Error(`invalid scalar: expected 1 <= sc < curve.n`);let{p:t,f:n}=h.cached(this,e,e=>sn(m,e));return sn(m,[t,n])[0]}multiplyUnsafe(e,t=m.ZERO){if(!i.isValid(e))throw Error(`invalid scalar: expected 0 <= sc < curve.n`);return e===Sn?m.ZERO:this.is0()||e===Cn?this:h.unsafe(this,e,e=>sn(m,e),t)}isSmallOrder(){return this.multiplyUnsafe(o).is0()}isTorsionFree(){return h.unsafe(this,a.n).is0()}toAffine(e){return f(this,e)}clearCofactor(){return o===Cn?this:this.multiplyUnsafe(o)}toBytes(){let{x:e,y:t}=this.toAffine(),n=r.toBytes(t);return n[n.length-1]|=e&Cn?128:0,n}toHex(){return N(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(e){return sn(m,e)}static msm(e,t){return yn(m,i,e,t)}_setWindowSize(e){this.precompute(e)}toRawBytes(){return this.toBytes()}}m.BASE=new m(a.Gx,a.Gy,Cn,c(a.Gx*a.Gy)),m.ZERO=new m(Sn,Cn,Cn,Sn),m.Fp=r,m.Fn=i;let h=new _n(m,i.BITS);return m.BASE.precompute(8),m}var On=class{constructor(e){this.ep=e}static fromBytes(e){Tt()}static fromHex(e){Tt()}get x(){return this.toAffine().x}get y(){return this.toAffine().y}clearCofactor(){return this}assertValidity(){this.ep.assertValidity()}toAffine(e){return this.ep.toAffine(e)}toHex(){return N(this.toBytes())}toString(){return this.toHex()}isTorsionFree(){return!0}isSmallOrder(){return!1}add(e){return this.assertSame(e),this.init(this.ep.add(e.ep))}subtract(e){return this.assertSame(e),this.init(this.ep.subtract(e.ep))}multiply(e){return this.init(this.ep.multiply(e))}multiplyUnsafe(e){return this.init(this.ep.multiplyUnsafe(e))}double(){return this.init(this.ep.double())}negate(){return this.init(this.ep.negate())}precompute(e,t){return this.init(this.ep.precompute(e,t))}toRawBytes(){return this.toBytes()}};function kn(e,t,n={}){if(typeof t!=`function`)throw Error(`"hash" function param is required`);wt(n,{},{adjustScalarBytes:`function`,randomBytes:`function`,domain:`function`,prehash:`function`,mapToCurve:`function`});let{prehash:r}=n,{BASE:i,Fp:a,Fn:o}=e,s=n.randomBytes||ve,c=n.adjustScalarBytes||(e=>e),l=n.domain||((e,t,n)=>{if(st(n,`phflag`),t.length||n)throw Error(`Contexts/pre-hash are not supported`);return e});function u(e){return o.create(ft(e))}function d(e){let n=y.secretKey;e=ht(`private key`,e,n);let r=ht(`hashed private key`,t(e),2*n),i=c(r.slice(0,n));return{head:i,prefix:r.slice(n,2*n),scalar:u(i)}}function f(e){let{head:t,prefix:n,scalar:r}=d(e),a=i.multiply(r);return{head:t,prefix:n,scalar:r,point:a,pointBytes:a.toBytes()}}function p(e){return f(e).pointBytes}function m(e=Uint8Array.of(),...n){return u(t(l(F(...n),ht(`context`,e),!!r)))}function h(e,t,n={}){e=ht(`message`,e),r&&(e=r(e));let{prefix:a,scalar:s,pointBytes:c}=f(t),l=m(n.context,a,e),u=i.multiply(l).toBytes(),d=m(n.context,u,c,e),p=o.create(l+d*s);if(!o.isValid(p))throw Error(`sign failed: invalid s`);return ct(F(u,o.toBytes(p)),y.signature,`result`)}let g={zip215:!0};function _(t,n,a,o=g){let{context:s,zip215:c}=o,l=y.signature;t=ht(`signature`,t,l),n=ht(`message`,n),a=ht(`publicKey`,a,y.publicKey),c!==void 0&&st(c,`zip215`),r&&(n=r(n));let u=l/2,d=t.subarray(0,u),f=ft(t.subarray(u,l)),p,h,_;try{p=e.fromBytes(a,c),h=e.fromBytes(d,c),_=i.multiplyUnsafe(f)}catch{return!1}if(!c&&p.isSmallOrder())return!1;let v=m(s,h.toBytes(),p.toBytes(),n);return h.add(p.multiplyUnsafe(v)).subtract(_).clearCofactor().is0()}let v=a.BYTES,y={secretKey:v,publicKey:v,signature:2*v,seed:v};function b(e=s(y.seed)){return ct(e,y.seed,`seed`)}function x(e){let t=C.randomSecretKey(e);return{secretKey:t,publicKey:p(t)}}function ee(e){return O(e)&&e.length===o.BYTES}function S(t,n){try{return!!e.fromBytes(t,n)}catch{return!1}}let C={getExtendedPublicKey:f,randomSecretKey:b,isValidSecretKey:ee,isValidPublicKey:S,toMontgomery(t){let{y:n}=e.fromBytes(t),r=y.publicKey,i=r===32;if(!i&&r!==57)throw Error(`only defined for 25519 and 448`);let o=i?a.div(Cn+n,Cn-n):a.div(n-Cn,n+Cn);return a.toBytes(o)},toMontgomerySecret(e){let n=y.secretKey;return ct(e,n),c(t(e.subarray(0,n))).subarray(0,n)},randomPrivateKey:b,precompute(t=8,n=e.BASE){return n.precompute(t,!1)}};return Object.freeze({keygen:x,getPublicKey:p,sign:h,verify:_,utils:C,Point:e,lengths:y})}function An(e){let t={a:e.a,d:e.d,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},n={Fp:e.Fp,Fn:$t(t.n,e.nBitLength,!0),uvRatio:e.uvRatio},r={randomBytes:e.randomBytes,adjustScalarBytes:e.adjustScalarBytes,domain:e.domain,prehash:e.prehash,mapToCurve:e.mapToCurve};return{CURVE:t,curveOpts:n,hash:e.hash,eddsaOpts:r}}function jn(e,t){let n=t.Point;return Object.assign({},t,{ExtendedPoint:n,CURVE:e,nBitLength:n.Fn.BITS,nByteLength:n.Fn.BYTES})}function Mn(e){let{CURVE:t,curveOpts:n,hash:r,eddsaOpts:i}=An(e);return jn(e,kn(Dn(t,n),r,i))}var Nn=BigInt(0),Pn=BigInt(1),Fn=BigInt(2),In=BigInt(5),Ln=BigInt(8),Rn=BigInt(`0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed`),zn={p:Rn,n:BigInt(`0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed`),h:Ln,a:BigInt(`0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec`),d:BigInt(`0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3`),Gx:BigInt(`0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a`),Gy:BigInt(`0x6666666666666666666666666666666666666666666666666666666666666658`)};function Bn(e){let t=BigInt(10),n=BigInt(20),r=BigInt(40),i=BigInt(80),a=Rn,o=e*e%a*e%a,s=Rt(Rt(o,Fn,a)*o%a,Pn,a)*e%a,c=Rt(s,In,a)*s%a,l=Rt(c,t,a)*c%a,u=Rt(l,n,a)*l%a,d=Rt(u,r,a)*u%a;return{pow_p_5_8:Rt(Rt(Rt(Rt(d,i,a)*d%a,i,a)*d%a,t,a)*c%a,Fn,a)*e%a,b2:o}}function Vn(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var Hn=BigInt(`19681161376707505956807079304988542015446066515923890162744021073123829784752`);function Un(e,t){let n=Rn,r=Lt(t*t*t,n),i=Bn(e*Lt(r*r*t,n)).pow_p_5_8,a=Lt(e*r*i,n),o=Lt(t*a*a,n),s=a,c=Lt(a*Hn,n),l=o===e,u=o===Lt(-e,n),d=o===Lt(-e*Hn,n);return l&&(a=s),(u||d)&&(a=c),Kt(a,n)&&(a=Lt(-a,n)),{isValid:l||u,value:a}}var Wn=$t(zn.p,{isLE:!0}),Gn=$t(zn.n,{isLE:!0}),Kn=Mn({...zn,Fp:Wn,hash:Qe,adjustScalarBytes:Vn,uvRatio:Un}),qn=Hn,Jn=BigInt(`25063068953384623474111414158702152701244531502492656460079210482610430750235`),Yn=BigInt(`54469307008909316920995813868745141605393597292927456921205312896311721017578`),Xn=BigInt(`1159843021668779879193775521855586647937357759715417654439879720876111806838`),Zn=BigInt(`40440834346308536858101042469323190826248399146238708352240133220865137265952`),Qn=e=>Un(Pn,e),$n=BigInt(`0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff`),er=e=>Kn.Point.Fp.create(ft(e)&$n);function tr(e){let{d:t}=zn,n=Rn,r=e=>Wn.create(e),i=r(qn*e*e),a=r((i+Pn)*Xn),o=BigInt(-1),s=r((o-t*i)*r(i+t)),{isValid:c,value:l}=Un(a,s),u=r(l*e);Kt(u,n)||(u=r(-u)),c||(l=u),c||(o=i);let d=r(o*(i-Pn)*Zn-s),f=l*l,p=r((l+l)*s),m=r(d*Jn),h=r(Pn-f),g=r(Pn+f);return new Kn.Point(r(p*g),r(h*m),r(m*g),r(p*h))}function nr(e){te(e,64);let t=tr(er(e.subarray(0,32))),n=tr(er(e.subarray(32,64)));return new rr(t.add(n))}var rr=class e extends On{constructor(e){super(e)}static fromAffine(t){return new e(Kn.Point.fromAffine(t))}assertSame(t){if(!(t instanceof e))throw Error(`RistrettoPoint expected`)}init(t){return new e(t)}static hashToCurve(e){return nr(ht(`ristrettoHash`,e,64))}static fromBytes(t){te(t,32);let{a:n,d:r}=zn,i=Rn,a=e=>Wn.create(e),o=er(t);if(!gt(Wn.toBytes(o),t)||Kt(o,i))throw Error(`invalid ristretto255 encoding 1`);let s=a(o*o),c=a(Pn+n*s),l=a(Pn-n*s),u=a(c*c),d=a(l*l),f=a(n*r*u-d),{isValid:p,value:m}=Qn(a(f*d)),h=a(m*l),g=a(m*h*f),_=a((o+o)*h);Kt(_,i)&&(_=a(-_));let v=a(c*g),y=a(_*v);if(!p||Kt(y,i)||v===Nn)throw Error(`invalid ristretto255 encoding 2`);return new e(new Kn.Point(_,v,Pn,y))}static fromHex(t){return e.fromBytes(ht(`ristrettoHex`,t,32))}static msm(t,n){return yn(e,Kn.Point.Fn,t,n)}toBytes(){let{X:e,Y:t,Z:n,T:r}=this.ep,i=Rn,a=e=>Wn.create(e),o=a(a(n+t)*a(n-t)),s=a(e*t),{value:c}=Qn(a(o*a(s*s))),l=a(c*o),u=a(c*s),d=a(l*u*r),f;if(Kt(r*d,i)){let n=a(t*qn),r=a(e*qn);e=n,t=r,f=a(l*Yn)}else f=u;Kt(e*d,i)&&(t=a(-t));let p=a((n-t)*f);return Kt(p,i)&&(p=a(-p)),Wn.toBytes(p)}equals(e){this.assertSame(e);let{X:t,Y:n}=this.ep,{X:r,Y:i}=e.ep,a=e=>Wn.create(e),o=a(t*i)===a(n*r),s=a(n*i)===a(t*r);return o||s}is0(){return this.equals(e.ZERO)}};rr.BASE=new rr(Kn.Point.BASE),rr.ZERO=new rr(Kn.Point.ZERO),rr.Fp=Wn,rr.Fn=Gn;var ir=i(((e,t)=>{(function(e,t){function n(e,t){if(!e)throw Error(t||`Assertion failed`)}function r(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}function i(e,t,n){if(i.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,e!==null&&((t===`le`||t===`be`)&&(n=t,t=10),this._init(e||0,t||10,n||`be`))}typeof e==`object`?e.exports=i:t.BN=i,i.BN=i,i.wordSize=26;var o;try{o=typeof window<`u`&&window.Buffer!==void 0?window.Buffer:a().Buffer}catch{}i.isBN=function(e){return e instanceof i?!0:typeof e==`object`&&!!e&&e.constructor.wordSize===i.wordSize&&Array.isArray(e.words)},i.max=function(e,t){return e.cmp(t)>0?e:t},i.min=function(e,t){return e.cmp(t)<0?e:t},i.prototype._init=function(e,t,r){if(typeof e==`number`)return this._initNumber(e,t,r);if(typeof e==`object`)return this._initArray(e,t,r);t===`hex`&&(t=16),n(t===(t|0)&&t>=2&&t<=36),e=e.toString().replace(/\s+/g,``);var i=0;e[0]===`-`&&(i++,this.negative=1),i<e.length&&(t===16?this._parseHex(e,i,r):(this._parseBase(e,t,i),r===`le`&&this._initArray(this.toArray(),t,r)))},i.prototype._initNumber=function(e,t,r){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[e&67108863],this.length=1):e<4503599627370496?(this.words=[e&67108863,e/67108864&67108863],this.length=2):(n(e<9007199254740992),this.words=[e&67108863,e/67108864&67108863,1],this.length=3),r===`le`&&this._initArray(this.toArray(),t,r)},i.prototype._initArray=function(e,t,r){if(n(typeof e.length==`number`),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var a,o,s=0;if(r===`be`)for(i=e.length-1,a=0;i>=0;i-=3)o=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[a]|=o<<s&67108863,this.words[a+1]=o>>>26-s&67108863,s+=24,s>=26&&(s-=26,a++);else if(r===`le`)for(i=0,a=0;i<e.length;i+=3)o=e[i]|e[i+1]<<8|e[i+2]<<16,this.words[a]|=o<<s&67108863,this.words[a+1]=o>>>26-s&67108863,s+=24,s>=26&&(s-=26,a++);return this._strip()};function s(e,t){var r=e.charCodeAt(t);if(r>=48&&r<=57)return r-48;if(r>=65&&r<=70)return r-55;if(r>=97&&r<=102)return r-87;n(!1,`Invalid character in `+e)}function c(e,t,n){var r=s(e,n);return n-1>=t&&(r|=s(e,n-1)<<4),r}i.prototype._parseHex=function(e,t,n){this.length=Math.ceil((e.length-t)/6),this.words=Array(this.length);for(var r=0;r<this.length;r++)this.words[r]=0;var i=0,a=0,o;if(n===`be`)for(r=e.length-1;r>=t;r-=2)o=c(e,t,r)<<i,this.words[a]|=o&67108863,i>=18?(i-=18,a+=1,this.words[a]|=o>>>26):i+=8;else for(r=(e.length-t)%2==0?t+1:t;r<e.length;r+=2)o=c(e,t,r)<<i,this.words[a]|=o&67108863,i>=18?(i-=18,a+=1,this.words[a]|=o>>>26):i+=8;this._strip()};function l(e,t,r,i){for(var a=0,o=0,s=Math.min(e.length,r),c=t;c<s;c++){var l=e.charCodeAt(c)-48;a*=i,o=l>=49?l-49+10:l>=17?l-17+10:l,n(l>=0&&o<i,`Invalid character`),a+=o}return a}i.prototype._parseBase=function(e,t,n){this.words=[0],this.length=1;for(var r=0,i=1;i<=67108863;i*=t)r++;r--,i=i/t|0;for(var a=e.length-n,o=a%r,s=Math.min(a,a-o)+n,c=0,u=n;u<s;u+=r)c=l(e,u,u+r,t),this.imuln(i),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c);if(o!==0){var d=1;for(c=l(e,u,e.length,t),u=0;u<o;u++)d*=t;this.imuln(d),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c)}this._strip()},i.prototype.copy=function(e){e.words=Array(this.length);for(var t=0;t<this.length;t++)e.words[t]=this.words[t];e.length=this.length,e.negative=this.negative,e.red=this.red};function u(e,t){e.words=t.words,e.length=t.length,e.negative=t.negative,e.red=t.red}if(i.prototype._move=function(e){u(e,this)},i.prototype.clone=function(){var e=new i(null);return this.copy(e),e},i.prototype._expand=function(e){for(;this.length<e;)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<`u`&&typeof Symbol.for==`function`)try{i.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=d}catch{i.prototype.inspect=d}else i.prototype.inspect=d;function d(){return(this.red?`<BN-R: `:`<BN: `)+this.toString(16)+`>`}var f=`.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`.split(`.`),p=[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],m=[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(e,t){e||=10,t=t|0||1;var r;if(e===16||e===`hex`){r=``;for(var i=0,a=0,o=0;o<this.length;o++){var s=this.words[o],c=((s<<i|a)&16777215).toString(16);a=s>>>24-i&16777215,i+=2,i>=26&&(i-=26,o--),r=a!==0||o!==this.length-1?f[6-c.length]+c+r:c+r}for(a!==0&&(r=a.toString(16)+r);r.length%t!==0;)r=`0`+r;return this.negative!==0&&(r=`-`+r),r}if(e===(e|0)&&e>=2&&e<=36){var l=p[e],u=m[e];r=``;var d=this.clone();for(d.negative=0;!d.isZero();){var h=d.modrn(u).toString(e);d=d.idivn(u),r=d.isZero()?h+r:f[l-h.length]+h+r}for(this.isZero()&&(r=`0`+r);r.length%t!==0;)r=`0`+r;return this.negative!==0&&(r=`-`+r),r}n(!1,`Base should be between 2 and 36`)},i.prototype.toNumber=function(){var e=this.words[0];return this.length===2?e+=this.words[1]*67108864:this.length===3&&this.words[2]===1?e+=4503599627370496+this.words[1]*67108864:this.length>2&&n(!1,`Number can only safely store up to 53 bits`),this.negative===0?e:-e},i.prototype.toJSON=function(){return this.toString(16,2)},o&&(i.prototype.toBuffer=function(e,t){return this.toArrayLike(o,e,t)}),i.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)};var h=function(e,t){return e.allocUnsafe?e.allocUnsafe(t):new e(t)};i.prototype.toArrayLike=function(e,t,r){this._strip();var i=this.byteLength(),a=r||Math.max(1,i);n(i<=a,`byte array longer than desired length`),n(a>0,`Requested array length <= 0`);var o=h(e,a),s=t===`le`?`LE`:`BE`;return this[`_toArrayLike`+s](o,i),o},i.prototype._toArrayLikeLE=function(e,t){for(var n=0,r=0,i=0,a=0;i<this.length;i++){var o=this.words[i]<<a|r;e[n++]=o&255,n<e.length&&(e[n++]=o>>8&255),n<e.length&&(e[n++]=o>>16&255),a===6?(n<e.length&&(e[n++]=o>>24&255),r=0,a=0):(r=o>>>24,a+=2)}if(n<e.length)for(e[n++]=r;n<e.length;)e[n++]=0},i.prototype._toArrayLikeBE=function(e,t){for(var n=e.length-1,r=0,i=0,a=0;i<this.length;i++){var o=this.words[i]<<a|r;e[n--]=o&255,n>=0&&(e[n--]=o>>8&255),n>=0&&(e[n--]=o>>16&255),a===6?(n>=0&&(e[n--]=o>>24&255),r=0,a=0):(r=o>>>24,a+=2)}if(n>=0)for(e[n--]=r;n>=0;)e[n--]=0},Math.clz32?i.prototype._countBits=function(e){return 32-Math.clz32(e)}:i.prototype._countBits=function(e){var t=e,n=0;return t>=4096&&(n+=13,t>>>=13),t>=64&&(n+=7,t>>>=7),t>=8&&(n+=4,t>>>=4),t>=2&&(n+=2,t>>>=2),n+t},i.prototype._zeroBits=function(e){if(e===0)return 26;var t=e,n=0;return t&8191||(n+=13,t>>>=13),t&127||(n+=7,t>>>=7),t&15||(n+=4,t>>>=4),t&3||(n+=2,t>>>=2),t&1||n++,n},i.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return(this.length-1)*26+t};function g(e){for(var t=Array(e.bitLength()),n=0;n<t.length;n++){var r=n/26|0,i=n%26;t[n]=e.words[r]>>>i&1}return t}i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;t<this.length;t++){var n=this._zeroBits(this.words[t]);if(e+=n,n!==26)break}return e},i.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},i.prototype.toTwos=function(e){return this.negative===0?this.clone():this.abs().inotn(e).iaddn(1)},i.prototype.fromTwos=function(e){return this.testn(e-1)?this.notn(e).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(e){for(;this.length<e.length;)this.words[this.length++]=0;for(var t=0;t<e.length;t++)this.words[t]=this.words[t]|e.words[t];return this._strip()},i.prototype.ior=function(e){return n((this.negative|e.negative)===0),this.iuor(e)},i.prototype.or=function(e){return this.length>e.length?this.clone().ior(e):e.clone().ior(this)},i.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},i.prototype.iuand=function(e){for(var t=this.length>e.length?e:this,n=0;n<t.length;n++)this.words[n]=this.words[n]&e.words[n];return this.length=t.length,this._strip()},i.prototype.iand=function(e){return n((this.negative|e.negative)===0),this.iuand(e)},i.prototype.and=function(e){return this.length>e.length?this.clone().iand(e):e.clone().iand(this)},i.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},i.prototype.iuxor=function(e){var t,n;this.length>e.length?(t=this,n=e):(t=e,n=this);for(var r=0;r<n.length;r++)this.words[r]=t.words[r]^n.words[r];if(this!==t)for(;r<t.length;r++)this.words[r]=t.words[r];return this.length=t.length,this._strip()},i.prototype.ixor=function(e){return n((this.negative|e.negative)===0),this.iuxor(e)},i.prototype.xor=function(e){return this.length>e.length?this.clone().ixor(e):e.clone().ixor(this)},i.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},i.prototype.inotn=function(e){n(typeof e==`number`&&e>=0);var t=Math.ceil(e/26)|0,r=e%26;this._expand(t),r>0&&t--;for(var i=0;i<t;i++)this.words[i]=~this.words[i]&67108863;return r>0&&(this.words[i]=~this.words[i]&67108863>>26-r),this._strip()},i.prototype.notn=function(e){return this.clone().inotn(e)},i.prototype.setn=function(e,t){n(typeof e==`number`&&e>=0);var r=e/26|0,i=e%26;return this._expand(r+1),t?this.words[r]=this.words[r]|1<<i:this.words[r]=this.words[r]&~(1<<i),this._strip()},i.prototype.iadd=function(e){var t;if(this.negative!==0&&e.negative===0)return this.negative=0,t=this.isub(e),this.negative^=1,this._normSign();if(this.negative===0&&e.negative!==0)return e.negative=0,t=this.isub(e),e.negative=1,t._normSign();var n,r;this.length>e.length?(n=this,r=e):(n=e,r=this);for(var i=0,a=0;a<r.length;a++)t=(n.words[a]|0)+(r.words[a]|0)+i,this.words[a]=t&67108863,i=t>>>26;for(;i!==0&&a<n.length;a++)t=(n.words[a]|0)+i,this.words[a]=t&67108863,i=t>>>26;if(this.length=n.length,i!==0)this.words[this.length]=i,this.length++;else if(n!==this)for(;a<n.length;a++)this.words[a]=n.words[a];return this},i.prototype.add=function(e){var t;return e.negative!==0&&this.negative===0?(e.negative=0,t=this.sub(e),e.negative^=1,t):e.negative===0&&this.negative!==0?(this.negative=0,t=e.sub(this),this.negative=1,t):this.length>e.length?this.clone().iadd(e):e.clone().iadd(this)},i.prototype.isub=function(e){if(e.negative!==0){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var n=this.cmp(e);if(n===0)return this.negative=0,this.length=1,this.words[0]=0,this;var r,i;n>0?(r=this,i=e):(r=e,i=this);for(var a=0,o=0;o<i.length;o++)t=(r.words[o]|0)-(i.words[o]|0)+a,a=t>>26,this.words[o]=t&67108863;for(;a!==0&&o<r.length;o++)t=(r.words[o]|0)+a,a=t>>26,this.words[o]=t&67108863;if(a===0&&o<r.length&&r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this.length=Math.max(this.length,o),r!==this&&(this.negative=1),this._strip()},i.prototype.sub=function(e){return this.clone().isub(e)};function _(e,t,n){n.negative=t.negative^e.negative;var r=e.length+t.length|0;n.length=r,r=r-1|0;var i=e.words[0]|0,a=t.words[0]|0,o=i*a,s=o&67108863,c=o/67108864|0;n.words[0]=s;for(var l=1;l<r;l++){for(var u=c>>>26,d=c&67108863,f=Math.min(l,t.length-1),p=Math.max(0,l-e.length+1);p<=f;p++){var m=l-p|0;i=e.words[m]|0,a=t.words[p]|0,o=i*a+d,u+=o/67108864|0,d=o&67108863}n.words[l]=d|0,c=u|0}return c===0?n.length--:n.words[l]=c|0,n._strip()}var v=function(e,t,n){var r=e.words,i=t.words,a=n.words,o=0,s,c,l,u=r[0]|0,d=u&8191,f=u>>>13,p=r[1]|0,m=p&8191,h=p>>>13,g=r[2]|0,_=g&8191,v=g>>>13,y=r[3]|0,b=y&8191,x=y>>>13,ee=r[4]|0,S=ee&8191,C=ee>>>13,w=r[5]|0,T=w&8191,E=w>>>13,D=r[6]|0,O=D&8191,k=D>>>13,te=r[7]|0,ne=te&8191,A=te>>>13,re=r[8]|0,ie=re&8191,j=re>>>13,ae=r[9]|0,M=ae&8191,oe=ae>>>13,se=i[0]|0,ce=se&8191,le=se>>>13,ue=i[1]|0,de=ue&8191,N=ue>>>13,fe=i[2]|0,pe=fe&8191,me=fe>>>13,he=i[3]|0,P=he&8191,F=he>>>13,ge=i[4]|0,_e=ge&8191,ve=ge>>>13,ye=i[5]|0,be=ye&8191,xe=ye>>>13,Se=i[6]|0,Ce=Se&8191,we=Se>>>13,Te=i[7]|0,Ee=Te&8191,De=Te>>>13,Oe=i[8]|0,ke=Oe&8191,Ae=Oe>>>13,je=i[9]|0,Me=je&8191,Ne=je>>>13;n.negative=e.negative^t.negative,n.length=19,s=Math.imul(d,ce),c=Math.imul(d,le),c=c+Math.imul(f,ce)|0,l=Math.imul(f,le);var Pe=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Pe>>>26)|0,Pe&=67108863,s=Math.imul(m,ce),c=Math.imul(m,le),c=c+Math.imul(h,ce)|0,l=Math.imul(h,le),s=s+Math.imul(d,de)|0,c=c+Math.imul(d,N)|0,c=c+Math.imul(f,de)|0,l=l+Math.imul(f,N)|0;var Fe=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Fe>>>26)|0,Fe&=67108863,s=Math.imul(_,ce),c=Math.imul(_,le),c=c+Math.imul(v,ce)|0,l=Math.imul(v,le),s=s+Math.imul(m,de)|0,c=c+Math.imul(m,N)|0,c=c+Math.imul(h,de)|0,l=l+Math.imul(h,N)|0,s=s+Math.imul(d,pe)|0,c=c+Math.imul(d,me)|0,c=c+Math.imul(f,pe)|0,l=l+Math.imul(f,me)|0;var Ie=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,s=Math.imul(b,ce),c=Math.imul(b,le),c=c+Math.imul(x,ce)|0,l=Math.imul(x,le),s=s+Math.imul(_,de)|0,c=c+Math.imul(_,N)|0,c=c+Math.imul(v,de)|0,l=l+Math.imul(v,N)|0,s=s+Math.imul(m,pe)|0,c=c+Math.imul(m,me)|0,c=c+Math.imul(h,pe)|0,l=l+Math.imul(h,me)|0,s=s+Math.imul(d,P)|0,c=c+Math.imul(d,F)|0,c=c+Math.imul(f,P)|0,l=l+Math.imul(f,F)|0;var Le=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Le>>>26)|0,Le&=67108863,s=Math.imul(S,ce),c=Math.imul(S,le),c=c+Math.imul(C,ce)|0,l=Math.imul(C,le),s=s+Math.imul(b,de)|0,c=c+Math.imul(b,N)|0,c=c+Math.imul(x,de)|0,l=l+Math.imul(x,N)|0,s=s+Math.imul(_,pe)|0,c=c+Math.imul(_,me)|0,c=c+Math.imul(v,pe)|0,l=l+Math.imul(v,me)|0,s=s+Math.imul(m,P)|0,c=c+Math.imul(m,F)|0,c=c+Math.imul(h,P)|0,l=l+Math.imul(h,F)|0,s=s+Math.imul(d,_e)|0,c=c+Math.imul(d,ve)|0,c=c+Math.imul(f,_e)|0,l=l+Math.imul(f,ve)|0;var Re=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Re>>>26)|0,Re&=67108863,s=Math.imul(T,ce),c=Math.imul(T,le),c=c+Math.imul(E,ce)|0,l=Math.imul(E,le),s=s+Math.imul(S,de)|0,c=c+Math.imul(S,N)|0,c=c+Math.imul(C,de)|0,l=l+Math.imul(C,N)|0,s=s+Math.imul(b,pe)|0,c=c+Math.imul(b,me)|0,c=c+Math.imul(x,pe)|0,l=l+Math.imul(x,me)|0,s=s+Math.imul(_,P)|0,c=c+Math.imul(_,F)|0,c=c+Math.imul(v,P)|0,l=l+Math.imul(v,F)|0,s=s+Math.imul(m,_e)|0,c=c+Math.imul(m,ve)|0,c=c+Math.imul(h,_e)|0,l=l+Math.imul(h,ve)|0,s=s+Math.imul(d,be)|0,c=c+Math.imul(d,xe)|0,c=c+Math.imul(f,be)|0,l=l+Math.imul(f,xe)|0;var ze=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(ze>>>26)|0,ze&=67108863,s=Math.imul(O,ce),c=Math.imul(O,le),c=c+Math.imul(k,ce)|0,l=Math.imul(k,le),s=s+Math.imul(T,de)|0,c=c+Math.imul(T,N)|0,c=c+Math.imul(E,de)|0,l=l+Math.imul(E,N)|0,s=s+Math.imul(S,pe)|0,c=c+Math.imul(S,me)|0,c=c+Math.imul(C,pe)|0,l=l+Math.imul(C,me)|0,s=s+Math.imul(b,P)|0,c=c+Math.imul(b,F)|0,c=c+Math.imul(x,P)|0,l=l+Math.imul(x,F)|0,s=s+Math.imul(_,_e)|0,c=c+Math.imul(_,ve)|0,c=c+Math.imul(v,_e)|0,l=l+Math.imul(v,ve)|0,s=s+Math.imul(m,be)|0,c=c+Math.imul(m,xe)|0,c=c+Math.imul(h,be)|0,l=l+Math.imul(h,xe)|0,s=s+Math.imul(d,Ce)|0,c=c+Math.imul(d,we)|0,c=c+Math.imul(f,Ce)|0,l=l+Math.imul(f,we)|0;var Be=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Be>>>26)|0,Be&=67108863,s=Math.imul(ne,ce),c=Math.imul(ne,le),c=c+Math.imul(A,ce)|0,l=Math.imul(A,le),s=s+Math.imul(O,de)|0,c=c+Math.imul(O,N)|0,c=c+Math.imul(k,de)|0,l=l+Math.imul(k,N)|0,s=s+Math.imul(T,pe)|0,c=c+Math.imul(T,me)|0,c=c+Math.imul(E,pe)|0,l=l+Math.imul(E,me)|0,s=s+Math.imul(S,P)|0,c=c+Math.imul(S,F)|0,c=c+Math.imul(C,P)|0,l=l+Math.imul(C,F)|0,s=s+Math.imul(b,_e)|0,c=c+Math.imul(b,ve)|0,c=c+Math.imul(x,_e)|0,l=l+Math.imul(x,ve)|0,s=s+Math.imul(_,be)|0,c=c+Math.imul(_,xe)|0,c=c+Math.imul(v,be)|0,l=l+Math.imul(v,xe)|0,s=s+Math.imul(m,Ce)|0,c=c+Math.imul(m,we)|0,c=c+Math.imul(h,Ce)|0,l=l+Math.imul(h,we)|0,s=s+Math.imul(d,Ee)|0,c=c+Math.imul(d,De)|0,c=c+Math.imul(f,Ee)|0,l=l+Math.imul(f,De)|0;var Ve=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Ve>>>26)|0,Ve&=67108863,s=Math.imul(ie,ce),c=Math.imul(ie,le),c=c+Math.imul(j,ce)|0,l=Math.imul(j,le),s=s+Math.imul(ne,de)|0,c=c+Math.imul(ne,N)|0,c=c+Math.imul(A,de)|0,l=l+Math.imul(A,N)|0,s=s+Math.imul(O,pe)|0,c=c+Math.imul(O,me)|0,c=c+Math.imul(k,pe)|0,l=l+Math.imul(k,me)|0,s=s+Math.imul(T,P)|0,c=c+Math.imul(T,F)|0,c=c+Math.imul(E,P)|0,l=l+Math.imul(E,F)|0,s=s+Math.imul(S,_e)|0,c=c+Math.imul(S,ve)|0,c=c+Math.imul(C,_e)|0,l=l+Math.imul(C,ve)|0,s=s+Math.imul(b,be)|0,c=c+Math.imul(b,xe)|0,c=c+Math.imul(x,be)|0,l=l+Math.imul(x,xe)|0,s=s+Math.imul(_,Ce)|0,c=c+Math.imul(_,we)|0,c=c+Math.imul(v,Ce)|0,l=l+Math.imul(v,we)|0,s=s+Math.imul(m,Ee)|0,c=c+Math.imul(m,De)|0,c=c+Math.imul(h,Ee)|0,l=l+Math.imul(h,De)|0,s=s+Math.imul(d,ke)|0,c=c+Math.imul(d,Ae)|0,c=c+Math.imul(f,ke)|0,l=l+Math.imul(f,Ae)|0;var He=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(He>>>26)|0,He&=67108863,s=Math.imul(M,ce),c=Math.imul(M,le),c=c+Math.imul(oe,ce)|0,l=Math.imul(oe,le),s=s+Math.imul(ie,de)|0,c=c+Math.imul(ie,N)|0,c=c+Math.imul(j,de)|0,l=l+Math.imul(j,N)|0,s=s+Math.imul(ne,pe)|0,c=c+Math.imul(ne,me)|0,c=c+Math.imul(A,pe)|0,l=l+Math.imul(A,me)|0,s=s+Math.imul(O,P)|0,c=c+Math.imul(O,F)|0,c=c+Math.imul(k,P)|0,l=l+Math.imul(k,F)|0,s=s+Math.imul(T,_e)|0,c=c+Math.imul(T,ve)|0,c=c+Math.imul(E,_e)|0,l=l+Math.imul(E,ve)|0,s=s+Math.imul(S,be)|0,c=c+Math.imul(S,xe)|0,c=c+Math.imul(C,be)|0,l=l+Math.imul(C,xe)|0,s=s+Math.imul(b,Ce)|0,c=c+Math.imul(b,we)|0,c=c+Math.imul(x,Ce)|0,l=l+Math.imul(x,we)|0,s=s+Math.imul(_,Ee)|0,c=c+Math.imul(_,De)|0,c=c+Math.imul(v,Ee)|0,l=l+Math.imul(v,De)|0,s=s+Math.imul(m,ke)|0,c=c+Math.imul(m,Ae)|0,c=c+Math.imul(h,ke)|0,l=l+Math.imul(h,Ae)|0,s=s+Math.imul(d,Me)|0,c=c+Math.imul(d,Ne)|0,c=c+Math.imul(f,Me)|0,l=l+Math.imul(f,Ne)|0;var Ue=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Ue>>>26)|0,Ue&=67108863,s=Math.imul(M,de),c=Math.imul(M,N),c=c+Math.imul(oe,de)|0,l=Math.imul(oe,N),s=s+Math.imul(ie,pe)|0,c=c+Math.imul(ie,me)|0,c=c+Math.imul(j,pe)|0,l=l+Math.imul(j,me)|0,s=s+Math.imul(ne,P)|0,c=c+Math.imul(ne,F)|0,c=c+Math.imul(A,P)|0,l=l+Math.imul(A,F)|0,s=s+Math.imul(O,_e)|0,c=c+Math.imul(O,ve)|0,c=c+Math.imul(k,_e)|0,l=l+Math.imul(k,ve)|0,s=s+Math.imul(T,be)|0,c=c+Math.imul(T,xe)|0,c=c+Math.imul(E,be)|0,l=l+Math.imul(E,xe)|0,s=s+Math.imul(S,Ce)|0,c=c+Math.imul(S,we)|0,c=c+Math.imul(C,Ce)|0,l=l+Math.imul(C,we)|0,s=s+Math.imul(b,Ee)|0,c=c+Math.imul(b,De)|0,c=c+Math.imul(x,Ee)|0,l=l+Math.imul(x,De)|0,s=s+Math.imul(_,ke)|0,c=c+Math.imul(_,Ae)|0,c=c+Math.imul(v,ke)|0,l=l+Math.imul(v,Ae)|0,s=s+Math.imul(m,Me)|0,c=c+Math.imul(m,Ne)|0,c=c+Math.imul(h,Me)|0,l=l+Math.imul(h,Ne)|0;var We=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(We>>>26)|0,We&=67108863,s=Math.imul(M,pe),c=Math.imul(M,me),c=c+Math.imul(oe,pe)|0,l=Math.imul(oe,me),s=s+Math.imul(ie,P)|0,c=c+Math.imul(ie,F)|0,c=c+Math.imul(j,P)|0,l=l+Math.imul(j,F)|0,s=s+Math.imul(ne,_e)|0,c=c+Math.imul(ne,ve)|0,c=c+Math.imul(A,_e)|0,l=l+Math.imul(A,ve)|0,s=s+Math.imul(O,be)|0,c=c+Math.imul(O,xe)|0,c=c+Math.imul(k,be)|0,l=l+Math.imul(k,xe)|0,s=s+Math.imul(T,Ce)|0,c=c+Math.imul(T,we)|0,c=c+Math.imul(E,Ce)|0,l=l+Math.imul(E,we)|0,s=s+Math.imul(S,Ee)|0,c=c+Math.imul(S,De)|0,c=c+Math.imul(C,Ee)|0,l=l+Math.imul(C,De)|0,s=s+Math.imul(b,ke)|0,c=c+Math.imul(b,Ae)|0,c=c+Math.imul(x,ke)|0,l=l+Math.imul(x,Ae)|0,s=s+Math.imul(_,Me)|0,c=c+Math.imul(_,Ne)|0,c=c+Math.imul(v,Me)|0,l=l+Math.imul(v,Ne)|0;var Ge=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Ge>>>26)|0,Ge&=67108863,s=Math.imul(M,P),c=Math.imul(M,F),c=c+Math.imul(oe,P)|0,l=Math.imul(oe,F),s=s+Math.imul(ie,_e)|0,c=c+Math.imul(ie,ve)|0,c=c+Math.imul(j,_e)|0,l=l+Math.imul(j,ve)|0,s=s+Math.imul(ne,be)|0,c=c+Math.imul(ne,xe)|0,c=c+Math.imul(A,be)|0,l=l+Math.imul(A,xe)|0,s=s+Math.imul(O,Ce)|0,c=c+Math.imul(O,we)|0,c=c+Math.imul(k,Ce)|0,l=l+Math.imul(k,we)|0,s=s+Math.imul(T,Ee)|0,c=c+Math.imul(T,De)|0,c=c+Math.imul(E,Ee)|0,l=l+Math.imul(E,De)|0,s=s+Math.imul(S,ke)|0,c=c+Math.imul(S,Ae)|0,c=c+Math.imul(C,ke)|0,l=l+Math.imul(C,Ae)|0,s=s+Math.imul(b,Me)|0,c=c+Math.imul(b,Ne)|0,c=c+Math.imul(x,Me)|0,l=l+Math.imul(x,Ne)|0;var Ke=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Ke>>>26)|0,Ke&=67108863,s=Math.imul(M,_e),c=Math.imul(M,ve),c=c+Math.imul(oe,_e)|0,l=Math.imul(oe,ve),s=s+Math.imul(ie,be)|0,c=c+Math.imul(ie,xe)|0,c=c+Math.imul(j,be)|0,l=l+Math.imul(j,xe)|0,s=s+Math.imul(ne,Ce)|0,c=c+Math.imul(ne,we)|0,c=c+Math.imul(A,Ce)|0,l=l+Math.imul(A,we)|0,s=s+Math.imul(O,Ee)|0,c=c+Math.imul(O,De)|0,c=c+Math.imul(k,Ee)|0,l=l+Math.imul(k,De)|0,s=s+Math.imul(T,ke)|0,c=c+Math.imul(T,Ae)|0,c=c+Math.imul(E,ke)|0,l=l+Math.imul(E,Ae)|0,s=s+Math.imul(S,Me)|0,c=c+Math.imul(S,Ne)|0,c=c+Math.imul(C,Me)|0,l=l+Math.imul(C,Ne)|0;var qe=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(qe>>>26)|0,qe&=67108863,s=Math.imul(M,be),c=Math.imul(M,xe),c=c+Math.imul(oe,be)|0,l=Math.imul(oe,xe),s=s+Math.imul(ie,Ce)|0,c=c+Math.imul(ie,we)|0,c=c+Math.imul(j,Ce)|0,l=l+Math.imul(j,we)|0,s=s+Math.imul(ne,Ee)|0,c=c+Math.imul(ne,De)|0,c=c+Math.imul(A,Ee)|0,l=l+Math.imul(A,De)|0,s=s+Math.imul(O,ke)|0,c=c+Math.imul(O,Ae)|0,c=c+Math.imul(k,ke)|0,l=l+Math.imul(k,Ae)|0,s=s+Math.imul(T,Me)|0,c=c+Math.imul(T,Ne)|0,c=c+Math.imul(E,Me)|0,l=l+Math.imul(E,Ne)|0;var Je=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Je>>>26)|0,Je&=67108863,s=Math.imul(M,Ce),c=Math.imul(M,we),c=c+Math.imul(oe,Ce)|0,l=Math.imul(oe,we),s=s+Math.imul(ie,Ee)|0,c=c+Math.imul(ie,De)|0,c=c+Math.imul(j,Ee)|0,l=l+Math.imul(j,De)|0,s=s+Math.imul(ne,ke)|0,c=c+Math.imul(ne,Ae)|0,c=c+Math.imul(A,ke)|0,l=l+Math.imul(A,Ae)|0,s=s+Math.imul(O,Me)|0,c=c+Math.imul(O,Ne)|0,c=c+Math.imul(k,Me)|0,l=l+Math.imul(k,Ne)|0;var Ye=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Ye>>>26)|0,Ye&=67108863,s=Math.imul(M,Ee),c=Math.imul(M,De),c=c+Math.imul(oe,Ee)|0,l=Math.imul(oe,De),s=s+Math.imul(ie,ke)|0,c=c+Math.imul(ie,Ae)|0,c=c+Math.imul(j,ke)|0,l=l+Math.imul(j,Ae)|0,s=s+Math.imul(ne,Me)|0,c=c+Math.imul(ne,Ne)|0,c=c+Math.imul(A,Me)|0,l=l+Math.imul(A,Ne)|0;var Xe=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Xe>>>26)|0,Xe&=67108863,s=Math.imul(M,ke),c=Math.imul(M,Ae),c=c+Math.imul(oe,ke)|0,l=Math.imul(oe,Ae),s=s+Math.imul(ie,Me)|0,c=c+Math.imul(ie,Ne)|0,c=c+Math.imul(j,Me)|0,l=l+Math.imul(j,Ne)|0;var Ze=(o+s|0)+((c&8191)<<13)|0;o=(l+(c>>>13)|0)+(Ze>>>26)|0,Ze&=67108863,s=Math.imul(M,Me),c=Math.imul(M,Ne),c=c+Math.imul(oe,Me)|0,l=Math.imul(oe,Ne);var Qe=(o+s|0)+((c&8191)<<13)|0;return o=(l+(c>>>13)|0)+(Qe>>>26)|0,Qe&=67108863,a[0]=Pe,a[1]=Fe,a[2]=Ie,a[3]=Le,a[4]=Re,a[5]=ze,a[6]=Be,a[7]=Ve,a[8]=He,a[9]=Ue,a[10]=We,a[11]=Ge,a[12]=Ke,a[13]=qe,a[14]=Je,a[15]=Ye,a[16]=Xe,a[17]=Ze,a[18]=Qe,o!==0&&(a[19]=o,n.length++),n};Math.imul||(v=_);function y(e,t,n){n.negative=t.negative^e.negative,n.length=e.length+t.length;for(var r=0,i=0,a=0;a<n.length-1;a++){var o=i;i=0;for(var s=r&67108863,c=Math.min(a,t.length-1),l=Math.max(0,a-e.length+1);l<=c;l++){var u=a-l,d=(e.words[u]|0)*(t.words[l]|0),f=d&67108863;o=o+(d/67108864|0)|0,f=f+s|0,s=f&67108863,o=o+(f>>>26)|0,i+=o>>>26,o&=67108863}n.words[a]=s,r=o,o=i}return r===0?n.length--:n.words[a]=r,n._strip()}function b(e,t,n){return y(e,t,n)}i.prototype.mulTo=function(e,t){var n,r=this.length+e.length;return n=this.length===10&&e.length===10?v(this,e,t):r<63?_(this,e,t):r<1024?y(this,e,t):b(this,e,t),n};function x(e,t){this.x=e,this.y=t}x.prototype.makeRBT=function(e){for(var t=Array(e),n=i.prototype._countBits(e)-1,r=0;r<e;r++)t[r]=this.revBin(r,n,e);return t},x.prototype.revBin=function(e,t,n){if(e===0||e===n-1)return e;for(var r=0,i=0;i<t;i++)r|=(e&1)<<t-i-1,e>>=1;return r},x.prototype.permute=function(e,t,n,r,i,a){for(var o=0;o<a;o++)r[o]=t[e[o]],i[o]=n[e[o]]},x.prototype.transform=function(e,t,n,r,i,a){this.permute(a,e,t,n,r,i);for(var o=1;o<i;o<<=1)for(var s=o<<1,c=Math.cos(2*Math.PI/s),l=Math.sin(2*Math.PI/s),u=0;u<i;u+=s)for(var d=c,f=l,p=0;p<o;p++){var m=n[u+p],h=r[u+p],g=n[u+p+o],_=r[u+p+o],v=d*g-f*_;_=d*_+f*g,g=v,n[u+p]=m+g,r[u+p]=h+_,n[u+p+o]=m-g,r[u+p+o]=h-_,p!==s&&(v=c*d-l*f,f=c*f+l*d,d=v)}},x.prototype.guessLen13b=function(e,t){var n=Math.max(t,e)|1,r=n&1,i=0;for(n=n/2|0;n;n>>>=1)i++;return 1<<i+1+r},x.prototype.conjugate=function(e,t,n){if(!(n<=1))for(var r=0;r<n/2;r++){var i=e[r];e[r]=e[n-r-1],e[n-r-1]=i,i=t[r],t[r]=-t[n-r-1],t[n-r-1]=-i}},x.prototype.normalize13b=function(e,t){for(var n=0,r=0;r<t/2;r++){var i=Math.round(e[2*r+1]/t)*8192+Math.round(e[2*r]/t)+n;e[r]=i&67108863,n=i<67108864?0:i/67108864|0}return e},x.prototype.convert13b=function(e,t,r,i){for(var a=0,o=0;o<t;o++)a+=e[o]|0,r[2*o]=a&8191,a>>>=13,r[2*o+1]=a&8191,a>>>=13;for(o=2*t;o<i;++o)r[o]=0;n(a===0),n((a&-8192)==0)},x.prototype.stub=function(e){for(var t=Array(e),n=0;n<e;n++)t[n]=0;return t},x.prototype.mulp=function(e,t,n){var r=2*this.guessLen13b(e.length,t.length),i=this.makeRBT(r),a=this.stub(r),o=Array(r),s=Array(r),c=Array(r),l=Array(r),u=Array(r),d=Array(r),f=n.words;f.length=r,this.convert13b(e.words,e.length,o,r),this.convert13b(t.words,t.length,l,r),this.transform(o,a,s,c,r,i),this.transform(l,a,u,d,r,i);for(var p=0;p<r;p++){var m=s[p]*u[p]-c[p]*d[p];c[p]=s[p]*d[p]+c[p]*u[p],s[p]=m}return this.conjugate(s,c,r),this.transform(s,c,f,a,r,i),this.conjugate(f,a,r),this.normalize13b(f,r),n.negative=e.negative^t.negative,n.length=e.length+t.length,n._strip()},i.prototype.mul=function(e){var t=new i(null);return t.words=Array(this.length+e.length),this.mulTo(e,t)},i.prototype.mulf=function(e){var t=new i(null);return t.words=Array(this.length+e.length),b(this,e,t)},i.prototype.imul=function(e){return this.clone().mulTo(e,this)},i.prototype.imuln=function(e){var t=e<0;t&&(e=-e),n(typeof e==`number`),n(e<67108864);for(var r=0,i=0;i<this.length;i++){var a=(this.words[i]|0)*e,o=(a&67108863)+(r&67108863);r>>=26,r+=a/67108864|0,r+=o>>>26,this.words[i]=o&67108863}return r!==0&&(this.words[i]=r,this.length++),this.length=e===0?1:this.length,t?this.ineg():this},i.prototype.muln=function(e){return this.clone().imuln(e)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(e){var t=g(e);if(t.length===0)return new i(1);for(var n=this,r=0;r<t.length&&t[r]===0;r++,n=n.sqr());if(++r<t.length)for(var a=n.sqr();r<t.length;r++,a=a.sqr())t[r]!==0&&(n=n.mul(a));return n},i.prototype.iushln=function(e){n(typeof e==`number`&&e>=0);var t=e%26,r=(e-t)/26,i=67108863>>>26-t<<26-t,a;if(t!==0){var o=0;for(a=0;a<this.length;a++){var s=this.words[a]&i,c=(this.words[a]|0)-s<<t;this.words[a]=c|o,o=s>>>26-t}o&&(this.words[a]=o,this.length++)}if(r!==0){for(a=this.length-1;a>=0;a--)this.words[a+r]=this.words[a];for(a=0;a<r;a++)this.words[a]=0;this.length+=r}return this._strip()},i.prototype.ishln=function(e){return n(this.negative===0),this.iushln(e)},i.prototype.iushrn=function(e,t,r){n(typeof e==`number`&&e>=0);var i=t?(t-t%26)/26:0,a=e%26,o=Math.min((e-a)/26,this.length),s=67108863^67108863>>>a<<a,c=r;if(i-=o,i=Math.max(0,i),c){for(var l=0;l<o;l++)c.words[l]=this.words[l];c.length=o}if(o!==0)if(this.length>o)for(this.length-=o,l=0;l<this.length;l++)this.words[l]=this.words[l+o];else this.words[0]=0,this.length=1;var u=0;for(l=this.length-1;l>=0&&(u!==0||l>=i);l--){var d=this.words[l]|0;this.words[l]=u<<26-a|d>>>a,u=d&s}return c&&u!==0&&(c.words[c.length++]=u),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},i.prototype.ishrn=function(e,t,r){return n(this.negative===0),this.iushrn(e,t,r)},i.prototype.shln=function(e){return this.clone().ishln(e)},i.prototype.ushln=function(e){return this.clone().iushln(e)},i.prototype.shrn=function(e){return this.clone().ishrn(e)},i.prototype.ushrn=function(e){return this.clone().iushrn(e)},i.prototype.testn=function(e){n(typeof e==`number`&&e>=0);var t=e%26,r=(e-t)/26,i=1<<t;return this.length<=r?!1:!!(this.words[r]&i)},i.prototype.imaskn=function(e){n(typeof e==`number`&&e>=0);var t=e%26,r=(e-t)/26;if(n(this.negative===0,`imaskn works only with positive numbers`),this.length<=r)return this;if(t!==0&&r++,this.length=Math.min(r,this.length),t!==0){var i=67108863^67108863>>>t<<t;this.words[this.length-1]&=i}return this.length===0&&(this.words[0]=0,this.length=1),this._strip()},i.prototype.maskn=function(e){return this.clone().imaskn(e)},i.prototype.iaddn=function(e){return n(typeof e==`number`),n(e<67108864),e<0?this.isubn(-e):this.negative===0?this._iaddn(e):this.length===1&&(this.words[0]|0)<=e?(this.words[0]=e-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(e),this.negative=1,this)},i.prototype._iaddn=function(e){this.words[0]+=e;for(var t=0;t<this.length&&this.words[t]>=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},i.prototype.isubn=function(e){if(n(typeof e==`number`),n(e<67108864),e<0)return this.iaddn(-e);if(this.negative!==0)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t<this.length&&this.words[t]<0;t++)this.words[t]+=67108864,--this.words[t+1];return this._strip()},i.prototype.addn=function(e){return this.clone().iaddn(e)},i.prototype.subn=function(e){return this.clone().isubn(e)},i.prototype.iabs=function(){return this.negative=0,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(e,t,r){var i=e.length+r,a;this._expand(i);var o,s=0;for(a=0;a<e.length;a++){o=(this.words[a+r]|0)+s;var c=(e.words[a]|0)*t;o-=c&67108863,s=(o>>26)-(c/67108864|0),this.words[a+r]=o&67108863}for(;a<this.length-r;a++)o=(this.words[a+r]|0)+s,s=o>>26,this.words[a+r]=o&67108863;if(s===0)return this._strip();for(n(s===-1),s=0,a=0;a<this.length;a++)o=-(this.words[a]|0)+s,s=o>>26,this.words[a]=o&67108863;return this.negative=1,this._strip()},i.prototype._wordDiv=function(e,t){var n=this.length-e.length,r=this.clone(),a=e,o=a.words[a.length-1]|0;n=26-this._countBits(o),n!==0&&(a=a.ushln(n),r.iushln(n),o=a.words[a.length-1]|0);var s=r.length-a.length,c;if(t!==`mod`){c=new i(null),c.length=s+1,c.words=Array(c.length);for(var l=0;l<c.length;l++)c.words[l]=0}var u=r.clone()._ishlnsubmul(a,1,s);u.negative===0&&(r=u,c&&(c.words[s]=1));for(var d=s-1;d>=0;d--){var f=(r.words[a.length+d]|0)*67108864+(r.words[a.length+d-1]|0);for(f=Math.min(f/o|0,67108863),r._ishlnsubmul(a,f,d);r.negative!==0;)f--,r.negative=0,r._ishlnsubmul(a,1,d),r.isZero()||(r.negative^=1);c&&(c.words[d]=f)}return c&&c._strip(),r._strip(),t!==`div`&&n!==0&&r.iushrn(n),{div:c||null,mod:r}},i.prototype.divmod=function(e,t,r){if(n(!e.isZero()),this.isZero())return{div:new i(0),mod:new i(0)};var a,o,s;return this.negative!==0&&e.negative===0?(s=this.neg().divmod(e,t),t!==`mod`&&(a=s.div.neg()),t!==`div`&&(o=s.mod.neg(),r&&o.negative!==0&&o.iadd(e)),{div:a,mod:o}):this.negative===0&&e.negative!==0?(s=this.divmod(e.neg(),t),t!==`mod`&&(a=s.div.neg()),{div:a,mod:s.mod}):(this.negative&e.negative)===0?e.length>this.length||this.cmp(e)<0?{div:new i(0),mod:this}:e.length===1?t===`div`?{div:this.divn(e.words[0]),mod:null}:t===`mod`?{div:null,mod:new i(this.modrn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new i(this.modrn(e.words[0]))}:this._wordDiv(e,t):(s=this.neg().divmod(e.neg(),t),t!==`div`&&(o=s.mod.neg(),r&&o.negative!==0&&o.isub(e)),{div:s.div,mod:o})},i.prototype.div=function(e){return this.divmod(e,`div`,!1).div},i.prototype.mod=function(e){return this.divmod(e,`mod`,!1).mod},i.prototype.umod=function(e){return this.divmod(e,`mod`,!0).mod},i.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var n=t.div.negative===0?t.mod:t.mod.isub(e),r=e.ushrn(1),i=e.andln(1),a=n.cmp(r);return a<0||i===1&&a===0?t.div:t.div.negative===0?t.div.iaddn(1):t.div.isubn(1)},i.prototype.modrn=function(e){var t=e<0;t&&(e=-e),n(e<=67108863);for(var r=(1<<26)%e,i=0,a=this.length-1;a>=0;a--)i=(r*i+(this.words[a]|0))%e;return t?-i:i},i.prototype.modn=function(e){return this.modrn(e)},i.prototype.idivn=function(e){var t=e<0;t&&(e=-e),n(e<=67108863);for(var r=0,i=this.length-1;i>=0;i--){var a=(this.words[i]|0)+r*67108864;this.words[i]=a/e|0,r=a%e}return this._strip(),t?this.ineg():this},i.prototype.divn=function(e){return this.clone().idivn(e)},i.prototype.egcd=function(e){n(e.negative===0),n(!e.isZero());var t=this,r=e.clone();t=t.negative===0?t.clone():t.umod(e);for(var a=new i(1),o=new i(0),s=new i(0),c=new i(1),l=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++l;for(var u=r.clone(),d=t.clone();!t.isZero();){for(var f=0,p=1;(t.words[0]&p)===0&&f<26;++f,p<<=1);if(f>0)for(t.iushrn(f);f-- >0;)(a.isOdd()||o.isOdd())&&(a.iadd(u),o.isub(d)),a.iushrn(1),o.iushrn(1);for(var m=0,h=1;(r.words[0]&h)===0&&m<26;++m,h<<=1);if(m>0)for(r.iushrn(m);m-- >0;)(s.isOdd()||c.isOdd())&&(s.iadd(u),c.isub(d)),s.iushrn(1),c.iushrn(1);t.cmp(r)>=0?(t.isub(r),a.isub(s),o.isub(c)):(r.isub(t),s.isub(a),c.isub(o))}return{a:s,b:c,gcd:r.iushln(l)}},i.prototype._invmp=function(e){n(e.negative===0),n(!e.isZero());var t=this,r=e.clone();t=t.negative===0?t.clone():t.umod(e);for(var a=new i(1),o=new i(0),s=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var c=0,l=1;(t.words[0]&l)===0&&c<26;++c,l<<=1);if(c>0)for(t.iushrn(c);c-- >0;)a.isOdd()&&a.iadd(s),a.iushrn(1);for(var u=0,d=1;(r.words[0]&d)===0&&u<26;++u,d<<=1);if(u>0)for(r.iushrn(u);u-- >0;)o.isOdd()&&o.iadd(s),o.iushrn(1);t.cmp(r)>=0?(t.isub(r),a.isub(o)):(r.isub(t),o.isub(a))}var f=t.cmpn(1)===0?a:o;return f.cmpn(0)<0&&f.iadd(e),f},i.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),n=e.clone();t.negative=0,n.negative=0;for(var r=0;t.isEven()&&n.isEven();r++)t.iushrn(1),n.iushrn(1);do{for(;t.isEven();)t.iushrn(1);for(;n.isEven();)n.iushrn(1);var i=t.cmp(n);if(i<0){var a=t;t=n,n=a}else if(i===0||n.cmpn(1)===0)break;t.isub(n)}while(!0);return n.iushln(r)},i.prototype.invm=function(e){return this.egcd(e).a.umod(e)},i.prototype.isEven=function(){return(this.words[0]&1)==0},i.prototype.isOdd=function(){return(this.words[0]&1)==1},i.prototype.andln=function(e){return this.words[0]&e},i.prototype.bincn=function(e){n(typeof e==`number`);var t=e%26,r=(e-t)/26,i=1<<t;if(this.length<=r)return this._expand(r+1),this.words[r]|=i,this;for(var a=i,o=r;a!==0&&o<this.length;o++){var s=this.words[o]|0;s+=a,a=s>>>26,s&=67108863,this.words[o]=s}return a!==0&&(this.words[o]=a,this.length++),this},i.prototype.isZero=function(){return this.length===1&&this.words[0]===0},i.prototype.cmpn=function(e){var t=e<0;if(this.negative!==0&&!t)return-1;if(this.negative===0&&t)return 1;this._strip();var r;if(this.length>1)r=1;else{t&&(e=-e),n(e<=67108863,`Number is too big`);var i=this.words[0]|0;r=i===e?0:i<e?-1:1}return this.negative===0?r:-r|0},i.prototype.cmp=function(e){if(this.negative!==0&&e.negative===0)return-1;if(this.negative===0&&e.negative!==0)return 1;var t=this.ucmp(e);return this.negative===0?t:-t|0},i.prototype.ucmp=function(e){if(this.length>e.length)return 1;if(this.length<e.length)return-1;for(var t=0,n=this.length-1;n>=0;n--){var r=this.words[n]|0,i=e.words[n]|0;if(r!==i){r<i?t=-1:r>i&&(t=1);break}}return t},i.prototype.gtn=function(e){return this.cmpn(e)===1},i.prototype.gt=function(e){return this.cmp(e)===1},i.prototype.gten=function(e){return this.cmpn(e)>=0},i.prototype.gte=function(e){return this.cmp(e)>=0},i.prototype.ltn=function(e){return this.cmpn(e)===-1},i.prototype.lt=function(e){return this.cmp(e)===-1},i.prototype.lten=function(e){return this.cmpn(e)<=0},i.prototype.lte=function(e){return this.cmp(e)<=0},i.prototype.eqn=function(e){return this.cmpn(e)===0},i.prototype.eq=function(e){return this.cmp(e)===0},i.red=function(e){return new D(e)},i.prototype.toRed=function(e){return n(!this.red,`Already a number in reduction context`),n(this.negative===0,`red works only with positives`),e.convertTo(this)._forceRed(e)},i.prototype.fromRed=function(){return n(this.red,`fromRed works only with numbers in reduction context`),this.red.convertFrom(this)},i.prototype._forceRed=function(e){return this.red=e,this},i.prototype.forceRed=function(e){return n(!this.red,`Already a number in reduction context`),this._forceRed(e)},i.prototype.redAdd=function(e){return n(this.red,`redAdd works only with red numbers`),this.red.add(this,e)},i.prototype.redIAdd=function(e){return n(this.red,`redIAdd works only with red numbers`),this.red.iadd(this,e)},i.prototype.redSub=function(e){return n(this.red,`redSub works only with red numbers`),this.red.sub(this,e)},i.prototype.redISub=function(e){return n(this.red,`redISub works only with red numbers`),this.red.isub(this,e)},i.prototype.redShl=function(e){return n(this.red,`redShl works only with red numbers`),this.red.shl(this,e)},i.prototype.redMul=function(e){return n(this.red,`redMul works only with red numbers`),this.red._verify2(this,e),this.red.mul(this,e)},i.prototype.redIMul=function(e){return n(this.red,`redMul works only with red numbers`),this.red._verify2(this,e),this.red.imul(this,e)},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(e){return n(this.red&&!e.red,`redPow(normalNum)`),this.red._verify1(this),this.red.pow(this,e)};var ee={k256:null,p224:null,p192:null,p25519:null};function S(e,t){this.name=e,this.p=new i(t,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}S.prototype._tmp=function(){var e=new i(null);return e.words=Array(Math.ceil(this.n/13)),e},S.prototype.ireduce=function(e){var t=e,n;do this.split(t,this.tmp),t=this.imulK(t),t=t.iadd(this.tmp),n=t.bitLength();while(n>this.n);var r=n<this.n?-1:t.ucmp(this.p);return r===0?(t.words[0]=0,t.length=1):r>0?t.isub(this.p):t.strip===void 0?t._strip():t.strip(),t},S.prototype.split=function(e,t){e.iushrn(this.n,0,t)},S.prototype.imulK=function(e){return e.imul(this.k)};function C(){S.call(this,`k256`,`ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f`)}r(C,S),C.prototype.split=function(e,t){for(var n=4194303,r=Math.min(e.length,9),i=0;i<r;i++)t.words[i]=e.words[i];if(t.length=r,e.length<=9){e.words[0]=0,e.length=1;return}var a=e.words[9];for(t.words[t.length++]=a&n,i=10;i<e.length;i++){var o=e.words[i]|0;e.words[i-10]=(o&n)<<4|a>>>22,a=o}a>>>=22,e.words[i-10]=a,a===0&&e.length>10?e.length-=10:e.length-=9},C.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,n=0;n<e.length;n++){var r=e.words[n]|0;t+=r*977,e.words[n]=t&67108863,t=r*64+(t/67108864|0)}return e.words[e.length-1]===0&&(e.length--,e.words[e.length-1]===0&&e.length--),e};function w(){S.call(this,`p224`,`ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001`)}r(w,S);function T(){S.call(this,`p192`,`ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff`)}r(T,S);function E(){S.call(this,`25519`,`7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed`)}r(E,S),E.prototype.imulK=function(e){for(var t=0,n=0;n<e.length;n++){var r=(e.words[n]|0)*19+t,i=r&67108863;r>>>=26,e.words[n]=i,t=r}return t!==0&&(e.words[e.length++]=t),e},i._prime=function(e){if(ee[e])return ee[e];var t;if(e===`k256`)t=new C;else if(e===`p224`)t=new w;else if(e===`p192`)t=new T;else if(e===`p25519`)t=new E;else throw Error(`Unknown prime `+e);return ee[e]=t,t};function D(e){if(typeof e==`string`){var t=i._prime(e);this.m=t.p,this.prime=t}else n(e.gtn(1),`modulus must be greater than 1`),this.m=e,this.prime=null}D.prototype._verify1=function(e){n(e.negative===0,`red works only with positives`),n(e.red,`red works only with red numbers`)},D.prototype._verify2=function(e,t){n((e.negative|t.negative)===0,`red works only with positives`),n(e.red&&e.red===t.red,`red works only with red numbers`)},D.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):(u(e,e.umod(this.m)._forceRed(this)),e)},D.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},D.prototype.add=function(e,t){this._verify2(e,t);var n=e.add(t);return n.cmp(this.m)>=0&&n.isub(this.m),n._forceRed(this)},D.prototype.iadd=function(e,t){this._verify2(e,t);var n=e.iadd(t);return n.cmp(this.m)>=0&&n.isub(this.m),n},D.prototype.sub=function(e,t){this._verify2(e,t);var n=e.sub(t);return n.cmpn(0)<0&&n.iadd(this.m),n._forceRed(this)},D.prototype.isub=function(e,t){this._verify2(e,t);var n=e.isub(t);return n.cmpn(0)<0&&n.iadd(this.m),n},D.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},D.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},D.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},D.prototype.isqr=function(e){return this.imul(e,e.clone())},D.prototype.sqr=function(e){return this.mul(e,e)},D.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(n(t%2==1),t===3){var r=this.m.add(new i(1)).iushrn(2);return this.pow(e,r)}for(var a=this.m.subn(1),o=0;!a.isZero()&&a.andln(1)===0;)o++,a.iushrn(1);n(!a.isZero());var s=new i(1).toRed(this),c=s.redNeg(),l=this.m.subn(1).iushrn(1),u=this.m.bitLength();for(u=new i(2*u*u).toRed(this);this.pow(u,l).cmp(c)!==0;)u.redIAdd(c);for(var d=this.pow(u,a),f=this.pow(e,a.addn(1).iushrn(1)),p=this.pow(e,a),m=o;p.cmp(s)!==0;){for(var h=p,g=0;h.cmp(s)!==0;g++)h=h.redSqr();n(g<m);var _=this.pow(d,new i(1).iushln(m-g-1));f=f.redMul(_),d=_.redSqr(),p=p.redMul(d),m=g}return f},D.prototype.invm=function(e){var t=e._invmp(this.m);return t.negative===0?this.imod(t):(t.negative=0,this.imod(t).redNeg())},D.prototype.pow=function(e,t){if(t.isZero())return new i(1).toRed(this);if(t.cmpn(1)===0)return e.clone();var n=4,r=Array(1<<n);r[0]=new i(1).toRed(this),r[1]=e;for(var a=2;a<r.length;a++)r[a]=this.mul(r[a-1],e);var o=r[0],s=0,c=0,l=t.bitLength()%26;for(l===0&&(l=26),a=t.length-1;a>=0;a--){for(var u=t.words[a],d=l-1;d>=0;d--){var f=u>>d&1;if(o!==r[0]&&(o=this.sqr(o)),f===0&&s===0){c=0;continue}s<<=1,s|=f,c++,!(c!==n&&(a!==0||d!==0))&&(o=this.mul(o,r[s]),c=0,s=0)}l=26}return o},D.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},D.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},i.mont=function(e){return new O(e)};function O(e){D.call(this,e),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)}r(O,D),O.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},O.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},O.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var n=e.imul(t),r=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=n.isub(r).iushrn(this.shift),a=i;return i.cmp(this.m)>=0?a=i.isub(this.m):i.cmpn(0)<0&&(a=i.iadd(this.m)),a._forceRed(this)},O.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new i(0)._forceRed(this);var n=e.mul(t),r=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),a=n.isub(r).iushrn(this.shift),o=a;return a.cmp(this.m)>=0?o=a.isub(this.m):a.cmpn(0)<0&&(o=a.iadd(this.m)),o._forceRed(this)},O.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}})(t===void 0||t,e)})),ar=i(((e,t)=>{var n=it(),r=n.Buffer;function i(e,t){for(var n in e)t[n]=e[n]}r.from&&r.alloc&&r.allocUnsafe&&r.allocUnsafeSlow?t.exports=n:(i(n,e),e.Buffer=a);function a(e,t,n){return r(e,t,n)}a.prototype=Object.create(r.prototype),i(r,a),a.from=function(e,t,n){if(typeof e==`number`)throw TypeError(`Argument must not be a number`);return r(e,t,n)},a.alloc=function(e,t,n){if(typeof e!=`number`)throw TypeError(`Argument must be a number`);var i=r(e);return t===void 0?i.fill(0):typeof n==`string`?i.fill(t,n):i.fill(t),i},a.allocUnsafe=function(e){if(typeof e!=`number`)throw TypeError(`Argument must be a number`);return r(e)},a.allocUnsafeSlow=function(e){if(typeof e!=`number`)throw TypeError(`Argument must be a number`);return n.SlowBuffer(e)}})),or=i(((e,t)=>{var n=ar().Buffer;function r(e){if(e.length>=255)throw TypeError(`Alphabet too long`);for(var t=new Uint8Array(256),r=0;r<t.length;r++)t[r]=255;for(var i=0;i<e.length;i++){var a=e.charAt(i),o=a.charCodeAt(0);if(t[o]!==255)throw TypeError(a+` is ambiguous`);t[o]=i}var s=e.length,c=e.charAt(0),l=Math.log(s)/Math.log(256),u=Math.log(256)/Math.log(s);function d(t){if((Array.isArray(t)||t instanceof Uint8Array)&&(t=n.from(t)),!n.isBuffer(t))throw TypeError(`Expected Buffer`);if(t.length===0)return``;for(var r=0,i=0,a=0,o=t.length;a!==o&&t[a]===0;)a++,r++;for(var l=(o-a)*u+1>>>0,d=new Uint8Array(l);a!==o;){for(var f=t[a],p=0,m=l-1;(f!==0||p<i)&&m!==-1;m--,p++)f+=256*d[m]>>>0,d[m]=f%s>>>0,f=f/s>>>0;if(f!==0)throw Error(`Non-zero carry`);i=p,a++}for(var h=l-i;h!==l&&d[h]===0;)h++;for(var g=c.repeat(r);h<l;++h)g+=e.charAt(d[h]);return g}function f(e){if(typeof e!=`string`)throw TypeError(`Expected String`);if(e.length===0)return n.alloc(0);for(var r=0,i=0,a=0;e[r]===c;)i++,r++;for(var o=(e.length-r)*l+1>>>0,u=new Uint8Array(o);r<e.length;){var d=e.charCodeAt(r);if(d>255)return;var f=t[d];if(f===255)return;for(var p=0,m=o-1;(f!==0||p<a)&&m!==-1;m--,p++)f+=s*u[m]>>>0,u[m]=f%256>>>0,f=f/256>>>0;if(f!==0)throw Error(`Non-zero carry`);a=p,r++}for(var h=o-a;h!==o&&u[h]===0;)h++;var g=n.allocUnsafe(i+(o-h));g.fill(0,0,i);for(var _=i;h!==o;)g[_++]=u[h++];return g}function p(e){var t=f(e);if(t)return t;throw Error(`Non-base`+s+` character`)}return{encode:d,decodeUnsafe:f,decode:p}}t.exports=r})),sr=i(((e,t)=>{t.exports=or()(`123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz`)})),cr=i(((e,t)=>{var n=ar().Buffer;function r(e){if(e.length>=255)throw TypeError(`Alphabet too long`);for(var t=new Uint8Array(256),r=0;r<t.length;r++)t[r]=255;for(var i=0;i<e.length;i++){var a=e.charAt(i),o=a.charCodeAt(0);if(t[o]!==255)throw TypeError(a+` is ambiguous`);t[o]=i}var s=e.length,c=e.charAt(0),l=Math.log(s)/Math.log(256),u=Math.log(256)/Math.log(s);function d(t){if((Array.isArray(t)||t instanceof Uint8Array)&&(t=n.from(t)),!n.isBuffer(t))throw TypeError(`Expected Buffer`);if(t.length===0)return``;for(var r=0,i=0,a=0,o=t.length;a!==o&&t[a]===0;)a++,r++;for(var l=(o-a)*u+1>>>0,d=new Uint8Array(l);a!==o;){for(var f=t[a],p=0,m=l-1;(f!==0||p<i)&&m!==-1;m--,p++)f+=256*d[m]>>>0,d[m]=f%s>>>0,f=f/s>>>0;if(f!==0)throw Error(`Non-zero carry`);i=p,a++}for(var h=l-i;h!==l&&d[h]===0;)h++;for(var g=c.repeat(r);h<l;++h)g+=e.charAt(d[h]);return g}function f(e){if(typeof e!=`string`)throw TypeError(`Expected String`);if(e.length===0)return n.alloc(0);for(var r=0,i=0,a=0;e[r]===c;)i++,r++;for(var o=(e.length-r)*l+1>>>0,u=new Uint8Array(o);r<e.length;){var d=e.charCodeAt(r);if(d>255)return;var f=t[d];if(f===255)return;for(var p=0,m=o-1;(f!==0||p<a)&&m!==-1;m--,p++)f+=s*u[m]>>>0,u[m]=f%256>>>0,f=f/256>>>0;if(f!==0)throw Error(`Non-zero carry`);a=p,r++}for(var h=o-a;h!==o&&u[h]===0;)h++;var g=n.allocUnsafe(i+(o-h));g.fill(0,0,i);for(var _=i;h!==o;)g[_++]=u[h++];return g}function p(e){var t=f(e);if(t)return t;throw Error(`Non-base`+s+` character`)}return{encode:d,decodeUnsafe:f,decode:p}}t.exports=r})),lr=i(((e,t)=>{t.exports=cr()(`123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz`)})),ur=r({TextDecoder:()=>yr,TextEncoder:()=>br});function dr(e,t,n){return t<=e&&e<=n}function fr(e){if(e===void 0)return{};if(e===Object(e))return e;throw TypeError(`Could not convert argument to dictionary`)}function pr(e){for(var t=String(e),n=t.length,r=0,i=[];r<n;){var a=t.charCodeAt(r);if(a<55296||a>57343)i.push(a);else if(56320<=a&&a<=57343)i.push(65533);else if(55296<=a&&a<=56319)if(r===n-1)i.push(65533);else{var o=e.charCodeAt(r+1);if(56320<=o&&o<=57343){var s=a&1023,c=o&1023;i.push(65536+(s<<10)+c),r+=1}else i.push(65533)}r+=1}return i}function mr(e){for(var t=``,n=0;n<e.length;++n){var r=e[n];r<=65535?t+=String.fromCharCode(r):(r-=65536,t+=String.fromCharCode((r>>10)+55296,(r&1023)+56320))}return t}function hr(e){this.tokens=[].slice.call(e)}function gr(e,t){if(e)throw TypeError(`Decoder error`);return t||65533}function _r(){}function vr(){}function yr(e,t){if(!(this instanceof yr))return new yr(e,t);if(e=e===void 0?Tr:String(e).toLowerCase(),e!==Tr)throw Error(`Encoding not supported. Only utf-8 is supported`);t=fr(t),this._streaming=!1,this._BOMseen=!1,this._decoder=null,this._fatal=!!t.fatal,this._ignoreBOM=!!t.ignoreBOM,Object.defineProperty(this,"encoding",{value:`utf-8`}),Object.defineProperty(this,"fatal",{value:this._fatal}),Object.defineProperty(this,"ignoreBOM",{value:this._ignoreBOM})}function br(e,t){if(!(this instanceof br))return new br(e,t);if(e=e===void 0?Tr:String(e).toLowerCase(),e!==Tr)throw Error(`Encoding not supported. Only utf-8 is supported`);t=fr(t),this._streaming=!1,this._encoder=null,this._options={fatal:!!t.fatal},Object.defineProperty(this,"encoding",{value:`utf-8`})}function xr(e){var t=e.fatal,n=0,r=0,i=0,a=128,o=191;this.handler=function(e,s){if(s===Cr&&i!==0)return i=0,gr(t);if(s===Cr)return wr;if(i===0){if(dr(s,0,127))return s;if(dr(s,194,223))i=1,n=s-192;else if(dr(s,224,239))s===224&&(a=160),s===237&&(o=159),i=2,n=s-224;else if(dr(s,240,244))s===240&&(a=144),s===244&&(o=143),i=3,n=s-240;else return gr(t);return n<<=6*i,null}if(!dr(s,a,o))return n=i=r=0,a=128,o=191,e.prepend(s),gr(t);if(a=128,o=191,r+=1,n+=s-128<<6*(i-r),r!==i)return null;var c=n;return n=i=r=0,c}}function Sr(e){e.fatal,this.handler=function(e,t){if(t===Cr)return wr;if(dr(t,0,127))return t;var n,r;dr(t,128,2047)?(n=1,r=192):dr(t,2048,65535)?(n=2,r=224):dr(t,65536,1114111)&&(n=3,r=240);for(var i=[(t>>6*n)+r];n>0;){var a=t>>6*(n-1);i.push(128|a&63),--n}return i}}var Cr,wr,Tr,Er=t((()=>{Cr=-1,hr.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():Cr},prepend:function(e){if(Array.isArray(e))for(var t=e;t.length;)this.tokens.unshift(t.pop());else this.tokens.unshift(e)},push:function(e){if(Array.isArray(e))for(var t=e;t.length;)this.tokens.push(t.shift());else this.tokens.push(e)}},wr=-1,_r.prototype={handler:function(e,t){}},vr.prototype={handler:function(e,t){}},Tr=`utf-8`,yr.prototype={decode:function(e,t){var n=typeof e==`object`&&e instanceof ArrayBuffer?new Uint8Array(e):typeof e==`object`&&`buffer`in e&&e.buffer instanceof ArrayBuffer?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array;t=fr(t),this._streaming||(this._decoder=new xr({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!t.stream;for(var r=new hr(n),i=[],a;!r.endOfStream()&&(a=this._decoder.handler(r,r.read()),a!==wr);)a!==null&&(Array.isArray(a)?i.push.apply(i,a):i.push(a));if(!this._streaming){do{if(a=this._decoder.handler(r,r.read()),a===wr)break;if(a===null)continue;Array.isArray(a)?i.push.apply(i,a):i.push(a)}while(!r.endOfStream());this._decoder=null}return i.length&&[`utf-8`].indexOf(this.encoding)!==-1&&!this._ignoreBOM&&!this._BOMseen&&(i[0]===65279?(this._BOMseen=!0,i.shift()):this._BOMseen=!0),mr(i)}},br.prototype={encode:function(e,t){e=e?String(e):``,t=fr(t),this._streaming||(this._encoder=new Sr(this._options)),this._streaming=!!t.stream;for(var n=[],r=new hr(pr(e)),i;!r.endOfStream()&&(i=this._encoder.handler(r,r.read()),i!==wr);)Array.isArray(i)?n.push.apply(n,i):n.push(i);if(!this._streaming){for(;i=this._encoder.handler(r,r.read()),i!==wr;)Array.isArray(i)?n.push.apply(n,i):n.push(i);this._encoder=null}return new Uint8Array(n)}}})),Dr=i((t=>{var n=t&&t.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),r=t&&t.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),i=t&&t.__decorate||function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},a=t&&t.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var i in e)i!==`default`&&Object.hasOwnProperty.call(e,i)&&n(t,e,i);return r(t,e),t},o=t&&t.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.deserializeUnchecked=t.deserialize=t.serialize=t.BinaryReader=t.BinaryWriter=t.BorshError=t.baseDecode=t.baseEncode=void 0;var s=o(ir()),c=o(lr()),l=a((Er(),e(ur))),u=new(typeof TextDecoder==`function`?TextDecoder:l.TextDecoder)(`utf-8`,{fatal:!0});function d(e){return typeof e==`string`&&(e=Buffer.from(e,`utf8`)),c.default.encode(Buffer.from(e))}t.baseEncode=d;function f(e){return Buffer.from(c.default.decode(e))}t.baseDecode=f;var p=1024,m=class extends Error{constructor(e){super(e),this.fieldPath=[],this.originalMessage=e}addToFieldPath(e){this.fieldPath.splice(0,0,e),this.message=this.originalMessage+`: `+this.fieldPath.join(`.`)}};t.BorshError=m;var h=class{constructor(){this.buf=Buffer.alloc(p),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Buffer.concat([this.buf,Buffer.alloc(p)]))}writeU8(e){this.maybeResize(),this.buf.writeUInt8(e,this.length),this.length+=1}writeU16(e){this.maybeResize(),this.buf.writeUInt16LE(e,this.length),this.length+=2}writeU32(e){this.maybeResize(),this.buf.writeUInt32LE(e,this.length),this.length+=4}writeU64(e){this.maybeResize(),this.writeBuffer(Buffer.from(new s.default(e).toArray(`le`,8)))}writeU128(e){this.maybeResize(),this.writeBuffer(Buffer.from(new s.default(e).toArray(`le`,16)))}writeU256(e){this.maybeResize(),this.writeBuffer(Buffer.from(new s.default(e).toArray(`le`,32)))}writeU512(e){this.maybeResize(),this.writeBuffer(Buffer.from(new s.default(e).toArray(`le`,64)))}writeBuffer(e){this.buf=Buffer.concat([Buffer.from(this.buf.subarray(0,this.length)),e,Buffer.alloc(p)]),this.length+=e.length}writeString(e){this.maybeResize();let t=Buffer.from(e,`utf8`);this.writeU32(t.length),this.writeBuffer(t)}writeFixedArray(e){this.writeBuffer(Buffer.from(e))}writeArray(e,t){this.maybeResize(),this.writeU32(e.length);for(let n of e)this.maybeResize(),t(n)}toArray(){return this.buf.subarray(0,this.length)}};t.BinaryWriter=h;function g(e,t,n){let r=n.value;n.value=function(...e){try{return r.apply(this,e)}catch(e){if(e instanceof RangeError){let t=e.code;if([`ERR_BUFFER_OUT_OF_BOUNDS`,`ERR_OUT_OF_RANGE`].indexOf(t)>=0)throw new m(`Reached the end of buffer when deserializing`)}throw e}}}var _=class{constructor(e){this.buf=e,this.offset=0}readU8(){let e=this.buf.readUInt8(this.offset);return this.offset+=1,e}readU16(){let e=this.buf.readUInt16LE(this.offset);return this.offset+=2,e}readU32(){let e=this.buf.readUInt32LE(this.offset);return this.offset+=4,e}readU64(){let e=this.readBuffer(8);return new s.default(e,`le`)}readU128(){let e=this.readBuffer(16);return new s.default(e,`le`)}readU256(){let e=this.readBuffer(32);return new s.default(e,`le`)}readU512(){let e=this.readBuffer(64);return new s.default(e,`le`)}readBuffer(e){if(this.offset+e>this.buf.length)throw new m(`Expected buffer length ${e} isn't within bounds`);let t=this.buf.slice(this.offset,this.offset+e);return this.offset+=e,t}readString(){let e=this.readU32(),t=this.readBuffer(e);try{return u.decode(t)}catch(e){throw new m(`Error decoding UTF-8 string: ${e}`)}}readFixedArray(e){return new Uint8Array(this.readBuffer(e))}readArray(e){let t=this.readU32(),n=[];for(let r=0;r<t;++r)n.push(e());return n}};i([g],_.prototype,`readU8`,null),i([g],_.prototype,`readU16`,null),i([g],_.prototype,`readU32`,null),i([g],_.prototype,`readU64`,null),i([g],_.prototype,`readU128`,null),i([g],_.prototype,`readU256`,null),i([g],_.prototype,`readU512`,null),i([g],_.prototype,`readString`,null),i([g],_.prototype,`readFixedArray`,null),i([g],_.prototype,`readArray`,null),t.BinaryReader=_;function v(e){return e.charAt(0).toUpperCase()+e.slice(1)}function y(e,t,n,r,i){try{if(typeof r==`string`)i[`write${v(r)}`](n);else if(r instanceof Array)if(typeof r[0]==`number`){if(n.length!==r[0])throw new m(`Expecting byte array of length ${r[0]}, but got ${n.length} bytes`);i.writeFixedArray(n)}else if(r.length===2&&typeof r[1]==`number`){if(n.length!==r[1])throw new m(`Expecting byte array of length ${r[1]}, but got ${n.length} bytes`);for(let t=0;t<r[1];t++)y(e,null,n[t],r[0],i)}else i.writeArray(n,n=>{y(e,t,n,r[0],i)});else if(r.kind!==void 0)switch(r.kind){case`option`:n==null?i.writeU8(0):(i.writeU8(1),y(e,t,n,r.type,i));break;case`map`:i.writeU32(n.size),n.forEach((n,a)=>{y(e,t,a,r.key,i),y(e,t,n,r.value,i)});break;default:throw new m(`FieldType ${r} unrecognized`)}else b(e,n,i)}catch(e){throw e instanceof m&&e.addToFieldPath(t),e}}function b(e,t,n){if(typeof t.borshSerialize==`function`){t.borshSerialize(n);return}let r=e.get(t.constructor);if(!r)throw new m(`Class ${t.constructor.name} is missing in schema`);if(r.kind===`struct`)r.fields.map(([r,i])=>{y(e,r,t[r],i,n)});else if(r.kind===`enum`){let i=t[r.field];for(let a=0;a<r.values.length;++a){let[o,s]=r.values[a];if(o===i){n.writeU8(a),y(e,o,t[o],s,n);break}}}else throw new m(`Unexpected schema kind: ${r.kind} for ${t.constructor.name}`)}function x(e,t,n=h){let r=new n;return b(e,t,r),r.toArray()}t.serialize=x;function ee(e,t,n,r){try{if(typeof n==`string`)return r[`read${v(n)}`]();if(n instanceof Array){if(typeof n[0]==`number`)return r.readFixedArray(n[0]);if(typeof n[1]==`number`){let t=[];for(let i=0;i<n[1];i++)t.push(ee(e,null,n[0],r));return t}else return r.readArray(()=>ee(e,t,n[0],r))}if(n.kind===`option`)return r.readU8()?ee(e,t,n.type,r):void 0;if(n.kind===`map`){let i=new Map,a=r.readU32();for(let o=0;o<a;o++){let a=ee(e,t,n.key,r),o=ee(e,t,n.value,r);i.set(a,o)}return i}return S(e,n,r)}catch(e){throw e instanceof m&&e.addToFieldPath(t),e}}function S(e,t,n){if(typeof t.borshDeserialize==`function`)return t.borshDeserialize(n);let r=e.get(t);if(!r)throw new m(`Class ${t.name} is missing in schema`);if(r.kind===`struct`){let r={};for(let[i,a]of e.get(t).fields)r[i]=ee(e,i,a,n);return new t(r)}if(r.kind===`enum`){let i=n.readU8();if(i>=r.values.length)throw new m(`Enum index: ${i} is out of range`);let[a,o]=r.values[i],s=ee(e,a,o,n);return new t({[a]:s})}throw new m(`Unexpected schema kind: ${r.kind} for ${t.constructor.name}`)}function C(e,t,n,r=_){let i=new r(n),a=S(e,t,i);if(i.offset<n.length)throw new m(`Unexpected ${n.length-i.offset} bytes after deserialized data`);return a}t.deserialize=C;function w(e,t,n,r=_){return S(e,t,new r(n))}t.deserializeUnchecked=w})),Or=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.s16=e.s8=e.nu64be=e.u48be=e.u40be=e.u32be=e.u24be=e.u16be=e.nu64=e.u48=e.u40=e.u32=e.u24=e.u16=e.u8=e.offset=e.greedy=e.Constant=e.UTF8=e.CString=e.Blob=e.Boolean=e.BitField=e.BitStructure=e.VariantLayout=e.Union=e.UnionLayoutDiscriminator=e.UnionDiscriminator=e.Structure=e.Sequence=e.DoubleBE=e.Double=e.FloatBE=e.Float=e.NearInt64BE=e.NearInt64=e.NearUInt64BE=e.NearUInt64=e.IntBE=e.Int=e.UIntBE=e.UInt=e.OffsetLayout=e.GreedyCount=e.ExternalLayout=e.bindConstructorLayout=e.nameWithProperty=e.Layout=e.uint8ArrayToBuffer=e.checkUint8Array=void 0,e.constant=e.utf8=e.cstr=e.blob=e.unionLayoutDiscriminator=e.union=e.seq=e.bits=e.struct=e.f64be=e.f64=e.f32be=e.f32=e.ns64be=e.s48be=e.s40be=e.s32be=e.s24be=e.s16be=e.ns64=e.s48=e.s40=e.s32=e.s24=void 0;var t=it();function n(e){if(!(e instanceof Uint8Array))throw TypeError(`b must be a Uint8Array`)}e.checkUint8Array=n;function r(e){return n(e),t.Buffer.from(e.buffer,e.byteOffset,e.length)}e.uint8ArrayToBuffer=r;var i=class{constructor(e,t){if(!Number.isInteger(e))throw TypeError(`span must be an integer`);this.span=e,this.property=t}makeDestinationObject(){return{}}getSpan(e,t){if(0>this.span)throw RangeError(`indeterminate span`);return this.span}replicate(e){let t=Object.create(this.constructor.prototype);return Object.assign(t,this),t.property=e,t}fromArray(e){}};e.Layout=i;function a(e,t){return t.property?e+`[`+t.property+`]`:e}e.nameWithProperty=a;function o(e,t){if(typeof e!=`function`)throw TypeError(`Class must be constructor`);if(Object.prototype.hasOwnProperty.call(e,`layout_`))throw Error(`Class is already bound to a layout`);if(!(t&&t instanceof i))throw TypeError(`layout must be a Layout`);if(Object.prototype.hasOwnProperty.call(t,`boundConstructor_`))throw Error(`layout is already bound to a constructor`);e.layout_=t,t.boundConstructor_=e,t.makeDestinationObject=(()=>new e),Object.defineProperty(e.prototype,"encode",{value(e,n){return t.encode(this,e,n)},writable:!0}),Object.defineProperty(e,"decode",{value(e,n){return t.decode(e,n)},writable:!0})}e.bindConstructorLayout=o;var s=class extends i{isCount(){throw Error(`ExternalLayout is abstract`)}};e.ExternalLayout=s;var c=class extends s{constructor(e=1,t){if(!Number.isInteger(e)||0>=e)throw TypeError(`elementSpan must be a (positive) integer`);super(-1,t),this.elementSpan=e}isCount(){return!0}decode(e,t=0){n(e);let r=e.length-t;return Math.floor(r/this.elementSpan)}encode(e,t,n){return 0}};e.GreedyCount=c;var l=class extends s{constructor(e,t=0,n){if(!(e instanceof i))throw TypeError(`layout must be a Layout`);if(!Number.isInteger(t))throw TypeError(`offset must be integer or undefined`);super(e.span,n||e.property),this.layout=e,this.offset=t}isCount(){return this.layout instanceof u||this.layout instanceof d}decode(e,t=0){return this.layout.decode(e,t+this.offset)}encode(e,t,n=0){return this.layout.encode(e,t,n+this.offset)}};e.OffsetLayout=l;var u=class extends i{constructor(e,t){if(super(e,t),6<this.span)throw RangeError(`span must not exceed 6 bytes`)}decode(e,t=0){return r(e).readUIntLE(t,this.span)}encode(e,t,n=0){return r(t).writeUIntLE(e,n,this.span),this.span}};e.UInt=u;var d=class extends i{constructor(e,t){if(super(e,t),6<this.span)throw RangeError(`span must not exceed 6 bytes`)}decode(e,t=0){return r(e).readUIntBE(t,this.span)}encode(e,t,n=0){return r(t).writeUIntBE(e,n,this.span),this.span}};e.UIntBE=d;var f=class extends i{constructor(e,t){if(super(e,t),6<this.span)throw RangeError(`span must not exceed 6 bytes`)}decode(e,t=0){return r(e).readIntLE(t,this.span)}encode(e,t,n=0){return r(t).writeIntLE(e,n,this.span),this.span}};e.Int=f;var p=class extends i{constructor(e,t){if(super(e,t),6<this.span)throw RangeError(`span must not exceed 6 bytes`)}decode(e,t=0){return r(e).readIntBE(t,this.span)}encode(e,t,n=0){return r(t).writeIntBE(e,n,this.span),this.span}};e.IntBE=p;var m=2**32;function h(e){let t=Math.floor(e/m);return{hi32:t,lo32:e-t*m}}function g(e,t){return e*m+t}var _=class extends i{constructor(e){super(8,e)}decode(e,t=0){let n=r(e),i=n.readUInt32LE(t);return g(n.readUInt32LE(t+4),i)}encode(e,t,n=0){let i=h(e),a=r(t);return a.writeUInt32LE(i.lo32,n),a.writeUInt32LE(i.hi32,n+4),8}};e.NearUInt64=_;var v=class extends i{constructor(e){super(8,e)}decode(e,t=0){let n=r(e);return g(n.readUInt32BE(t),n.readUInt32BE(t+4))}encode(e,t,n=0){let i=h(e),a=r(t);return a.writeUInt32BE(i.hi32,n),a.writeUInt32BE(i.lo32,n+4),8}};e.NearUInt64BE=v;var y=class extends i{constructor(e){super(8,e)}decode(e,t=0){let n=r(e),i=n.readUInt32LE(t);return g(n.readInt32LE(t+4),i)}encode(e,t,n=0){let i=h(e),a=r(t);return a.writeUInt32LE(i.lo32,n),a.writeInt32LE(i.hi32,n+4),8}};e.NearInt64=y;var b=class extends i{constructor(e){super(8,e)}decode(e,t=0){let n=r(e);return g(n.readInt32BE(t),n.readUInt32BE(t+4))}encode(e,t,n=0){let i=h(e),a=r(t);return a.writeInt32BE(i.hi32,n),a.writeUInt32BE(i.lo32,n+4),8}};e.NearInt64BE=b;var x=class extends i{constructor(e){super(4,e)}decode(e,t=0){return r(e).readFloatLE(t)}encode(e,t,n=0){return r(t).writeFloatLE(e,n),4}};e.Float=x;var ee=class extends i{constructor(e){super(4,e)}decode(e,t=0){return r(e).readFloatBE(t)}encode(e,t,n=0){return r(t).writeFloatBE(e,n),4}};e.FloatBE=ee;var S=class extends i{constructor(e){super(8,e)}decode(e,t=0){return r(e).readDoubleLE(t)}encode(e,t,n=0){return r(t).writeDoubleLE(e,n),8}};e.Double=S;var C=class extends i{constructor(e){super(8,e)}decode(e,t=0){return r(e).readDoubleBE(t)}encode(e,t,n=0){return r(t).writeDoubleBE(e,n),8}};e.DoubleBE=C;var w=class extends i{constructor(e,t,n){if(!(e instanceof i))throw TypeError(`elementLayout must be a Layout`);if(!(t instanceof s&&t.isCount()||Number.isInteger(t)&&0<=t))throw TypeError(`count must be non-negative integer or an unsigned integer ExternalLayout`);let r=-1;!(t instanceof s)&&0<e.span&&(r=t*e.span),super(r,n),this.elementLayout=e,this.count=t}getSpan(e,t=0){if(0<=this.span)return this.span;let n=0,r=this.count;if(r instanceof s&&(r=r.decode(e,t)),0<this.elementLayout.span)n=r*this.elementLayout.span;else{let i=0;for(;i<r;)n+=this.elementLayout.getSpan(e,t+n),++i}return n}decode(e,t=0){let n=[],r=0,i=this.count;for(i instanceof s&&(i=i.decode(e,t));r<i;)n.push(this.elementLayout.decode(e,t)),t+=this.elementLayout.getSpan(e,t),r+=1;return n}encode(e,t,n=0){let r=this.elementLayout,i=e.reduce((e,i)=>e+r.encode(i,t,n+e),0);return this.count instanceof s&&this.count.encode(e.length,t,n),i}};e.Sequence=w;var T=class extends i{constructor(e,t,n){if(!(Array.isArray(e)&&e.reduce((e,t)=>e&&t instanceof i,!0)))throw TypeError(`fields must be array of Layout instances`);typeof t==`boolean`&&n===void 0&&(n=t,t=void 0);for(let t of e)if(0>t.span&&t.property===void 0)throw Error(`fields cannot contain unnamed variable-length layout`);let r=-1;try{r=e.reduce((e,t)=>e+t.getSpan(),0)}catch{}super(r,t),this.fields=e,this.decodePrefixes=!!n}getSpan(e,t=0){if(0<=this.span)return this.span;let n=0;try{n=this.fields.reduce((n,r)=>{let i=r.getSpan(e,t);return t+=i,n+i},0)}catch{throw RangeError(`indeterminate span`)}return n}decode(e,t=0){n(e);let r=this.makeDestinationObject();for(let n of this.fields)if(n.property!==void 0&&(r[n.property]=n.decode(e,t)),t+=n.getSpan(e,t),this.decodePrefixes&&e.length===t)break;return r}encode(e,t,n=0){let r=n,i=0,a=0;for(let r of this.fields){let o=r.span;if(a=0<o?o:0,r.property!==void 0){let i=e[r.property];i!==void 0&&(a=r.encode(i,t,n),0>o&&(o=r.getSpan(t,n)))}i=n,n+=o}return i+a-r}fromArray(e){let t=this.makeDestinationObject();for(let n of this.fields)n.property!==void 0&&0<e.length&&(t[n.property]=e.shift());return t}layoutFor(e){if(typeof e!=`string`)throw TypeError(`property must be string`);for(let t of this.fields)if(t.property===e)return t}offsetOf(e){if(typeof e!=`string`)throw TypeError(`property must be string`);let t=0;for(let n of this.fields){if(n.property===e)return t;0>n.span?t=-1:0<=t&&(t+=n.span)}}};e.Structure=T;var E=class{constructor(e){this.property=e}decode(e,t){throw Error(`UnionDiscriminator is abstract`)}encode(e,t,n){throw Error(`UnionDiscriminator is abstract`)}};e.UnionDiscriminator=E;var D=class extends E{constructor(e,t){if(!(e instanceof s&&e.isCount()))throw TypeError(`layout must be an unsigned integer ExternalLayout`);super(t||e.property||`variant`),this.layout=e}decode(e,t){return this.layout.decode(e,t)}encode(e,t,n){return this.layout.encode(e,t,n)}};e.UnionLayoutDiscriminator=D;var O=class extends i{constructor(e,t,n){let r;if(e instanceof u||e instanceof d)r=new D(new l(e));else if(e instanceof s&&e.isCount())r=new D(e);else if(e instanceof E)r=e;else throw TypeError(`discr must be a UnionDiscriminator or an unsigned integer layout`);if(t===void 0&&(t=null),!(t===null||t instanceof i))throw TypeError(`defaultLayout must be null or a Layout`);if(t!==null){if(0>t.span)throw Error(`defaultLayout must have constant span`);t.property===void 0&&(t=t.replicate(`content`))}let a=-1;t&&(a=t.span,0<=a&&(e instanceof u||e instanceof d)&&(a+=r.layout.span)),super(a,n),this.discriminator=r,this.usesPrefixDiscriminator=e instanceof u||e instanceof d,this.defaultLayout=t,this.registry={};let o=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(e){return o(e)},this.configGetSourceVariant=function(e){o=e.bind(this)}}getSpan(e,t=0){if(0<=this.span)return this.span;let n=this.getVariant(e,t);if(!n)throw Error(`unable to determine span for unrecognized variant`);return n.getSpan(e,t)}defaultGetSourceVariant(e){if(Object.prototype.hasOwnProperty.call(e,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(e,this.defaultLayout.property))return;let t=this.registry[e[this.discriminator.property]];if(t&&(!t.layout||t.property&&Object.prototype.hasOwnProperty.call(e,t.property)))return t}else for(let t in this.registry){let n=this.registry[t];if(n.property&&Object.prototype.hasOwnProperty.call(e,n.property))return n}throw Error(`unable to infer src variant`)}decode(e,t=0){let n,r=this.discriminator,i=r.decode(e,t),a=this.registry[i];if(a===void 0){let a=this.defaultLayout,o=0;this.usesPrefixDiscriminator&&(o=r.layout.span),n=this.makeDestinationObject(),n[r.property]=i,n[a.property]=a.decode(e,t+o)}else n=a.decode(e,t);return n}encode(e,t,n=0){let r=this.getSourceVariant(e);if(r===void 0){let r=this.discriminator,i=this.defaultLayout,a=0;return this.usesPrefixDiscriminator&&(a=r.layout.span),r.encode(e[r.property],t,n),a+i.encode(e[i.property],t,n+a)}return r.encode(e,t,n)}addVariant(e,t,n){let r=new k(this,e,t,n);return this.registry[e]=r,r}getVariant(e,t=0){let n;return n=e instanceof Uint8Array?this.discriminator.decode(e,t):e,this.registry[n]}};e.Union=O;var k=class extends i{constructor(e,t,n,r){if(!(e instanceof O))throw TypeError(`union must be a Union`);if(!Number.isInteger(t)||0>t)throw TypeError(`variant must be a (non-negative) integer`);if(typeof n==`string`&&r===void 0&&(r=n,n=null),n){if(!(n instanceof i))throw TypeError(`layout must be a Layout`);if(e.defaultLayout!==null&&0<=n.span&&n.span>e.defaultLayout.span)throw Error(`variant span exceeds span of containing union`);if(typeof r!=`string`)throw TypeError(`variant must have a String property`)}let a=e.span;0>e.span&&(a=n?n.span:0,0<=a&&e.usesPrefixDiscriminator&&(a+=e.discriminator.layout.span)),super(a,r),this.union=e,this.variant=t,this.layout=n||null}getSpan(e,t=0){if(0<=this.span)return this.span;let n=0;this.union.usesPrefixDiscriminator&&(n=this.union.discriminator.layout.span);let r=0;return this.layout&&(r=this.layout.getSpan(e,t+n)),n+r}decode(e,t=0){let n=this.makeDestinationObject();if(this!==this.union.getVariant(e,t))throw Error(`variant mismatch`);let r=0;return this.union.usesPrefixDiscriminator&&(r=this.union.discriminator.layout.span),this.layout?n[this.property]=this.layout.decode(e,t+r):this.property?n[this.property]=!0:this.union.usesPrefixDiscriminator&&(n[this.union.discriminator.property]=this.variant),n}encode(e,t,n=0){let r=0;if(this.union.usesPrefixDiscriminator&&(r=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(e,this.property))throw TypeError(`variant lacks property `+this.property);this.union.discriminator.encode(this.variant,t,n);let i=r;if(this.layout&&(this.layout.encode(e[this.property],t,n+r),i+=this.layout.getSpan(t,n+r),0<=this.union.span&&i>this.union.span))throw Error(`encoded variant overruns containing union`);return i}fromArray(e){if(this.layout)return this.layout.fromArray(e)}};e.VariantLayout=k;function te(e){return 0>e&&(e+=4294967296),e}var ne=class extends i{constructor(e,t,n){if(!(e instanceof u||e instanceof d))throw TypeError(`word must be a UInt or UIntBE layout`);if(typeof t==`string`&&n===void 0&&(n=t,t=!1),4<e.span)throw RangeError(`word cannot exceed 32 bits`);super(e.span,n),this.word=e,this.msb=!!t,this.fields=[];let r=0;this._packedSetValue=function(e){return r=te(e),this},this._packedGetValue=function(){return r}}decode(e,t=0){let n=this.makeDestinationObject(),r=this.word.decode(e,t);this._packedSetValue(r);for(let t of this.fields)t.property!==void 0&&(n[t.property]=t.decode(e));return n}encode(e,t,n=0){let r=this.word.decode(t,n);this._packedSetValue(r);for(let t of this.fields)if(t.property!==void 0){let n=e[t.property];n!==void 0&&t.encode(n)}return this.word.encode(this._packedGetValue(),t,n)}addField(e,t){let n=new A(this,e,t);return this.fields.push(n),n}addBoolean(e){let t=new re(this,e);return this.fields.push(t),t}fieldFor(e){if(typeof e!=`string`)throw TypeError(`property must be string`);for(let t of this.fields)if(t.property===e)return t}};e.BitStructure=ne;var A=class{constructor(e,t,n){if(!(e instanceof ne))throw TypeError(`container must be a BitStructure`);if(!Number.isInteger(t)||0>=t)throw TypeError(`bits must be positive integer`);let r=8*e.span,i=e.fields.reduce((e,t)=>e+t.bits,0);if(t+i>r)throw Error(`bits too long for span remainder (`+(r-i)+` of `+r+` remain)`);this.container=e,this.bits=t,this.valueMask=(1<<t)-1,t===32&&(this.valueMask=4294967295),this.start=i,this.container.msb&&(this.start=r-i-t),this.wordMask=te(this.valueMask<<this.start),this.property=n}decode(e,t){return te(this.container._packedGetValue()&this.wordMask)>>>this.start}encode(e){if(typeof e!=`number`||!Number.isInteger(e)||e!==te(e&this.valueMask))throw TypeError(a(`BitField.encode`,this)+` value must be integer not exceeding `+this.valueMask);let t=this.container._packedGetValue(),n=te(e<<this.start);this.container._packedSetValue(te(t&~this.wordMask)|n)}};e.BitField=A;var re=class extends A{constructor(e,t){super(e,1,t)}decode(e,t){return!!super.decode(e,t)}encode(e){typeof e==`boolean`&&(e=+e),super.encode(e)}};e.Boolean=re;var ie=class extends i{constructor(e,t){if(!(e instanceof s&&e.isCount()||Number.isInteger(e)&&0<=e))throw TypeError(`length must be positive integer or an unsigned integer ExternalLayout`);let n=-1;e instanceof s||(n=e),super(n,t),this.length=e}getSpan(e,t){let n=this.span;return 0>n&&(n=this.length.decode(e,t)),n}decode(e,t=0){let n=this.span;return 0>n&&(n=this.length.decode(e,t)),r(e).slice(t,t+n)}encode(e,t,n){let i=this.length;if(this.length instanceof s&&(i=e.length),!(e instanceof Uint8Array&&i===e.length))throw TypeError(a(`Blob.encode`,this)+` requires (length `+i+`) Uint8Array as src`);if(n+i>t.length)throw RangeError(`encoding overruns Uint8Array`);let o=r(e);return r(t).write(o.toString(`hex`),n,i,`hex`),this.length instanceof s&&this.length.encode(i,t,n),i}};e.Blob=ie;var j=class extends i{constructor(e){super(-1,e)}getSpan(e,t=0){n(e);let r=t;for(;r<e.length&&e[r]!==0;)r+=1;return 1+r-t}decode(e,t=0){let n=this.getSpan(e,t);return r(e).slice(t,t+n-1).toString(`utf-8`)}encode(e,n,i=0){typeof e!=`string`&&(e=String(e));let a=t.Buffer.from(e,`utf8`),o=a.length;if(i+o>n.length)throw RangeError(`encoding overruns Buffer`);let s=r(n);return a.copy(s,i),s[i+o]=0,o+1}};e.CString=j;var ae=class extends i{constructor(e,t){if(typeof e==`string`&&t===void 0&&(t=e,e=void 0),e===void 0)e=-1;else if(!Number.isInteger(e))throw TypeError(`maxSpan must be an integer`);super(-1,t),this.maxSpan=e}getSpan(e,t=0){return n(e),e.length-t}decode(e,t=0){let n=this.getSpan(e,t);if(0<=this.maxSpan&&this.maxSpan<n)throw RangeError(`text length exceeds maxSpan`);return r(e).slice(t,t+n).toString(`utf-8`)}encode(e,n,i=0){typeof e!=`string`&&(e=String(e));let a=t.Buffer.from(e,`utf8`),o=a.length;if(0<=this.maxSpan&&this.maxSpan<o)throw RangeError(`text length exceeds maxSpan`);if(i+o>n.length)throw RangeError(`encoding overruns Buffer`);return a.copy(r(n),i),o}};e.UTF8=ae;var M=class extends i{constructor(e,t){super(0,t),this.value=e}decode(e,t){return this.value}encode(e,t,n){return 0}};e.Constant=M,e.greedy=((e,t)=>new c(e,t)),e.offset=((e,t,n)=>new l(e,t,n)),e.u8=(e=>new u(1,e)),e.u16=(e=>new u(2,e)),e.u24=(e=>new u(3,e)),e.u32=(e=>new u(4,e)),e.u40=(e=>new u(5,e)),e.u48=(e=>new u(6,e)),e.nu64=(e=>new _(e)),e.u16be=(e=>new d(2,e)),e.u24be=(e=>new d(3,e)),e.u32be=(e=>new d(4,e)),e.u40be=(e=>new d(5,e)),e.u48be=(e=>new d(6,e)),e.nu64be=(e=>new v(e)),e.s8=(e=>new f(1,e)),e.s16=(e=>new f(2,e)),e.s24=(e=>new f(3,e)),e.s32=(e=>new f(4,e)),e.s40=(e=>new f(5,e)),e.s48=(e=>new f(6,e)),e.ns64=(e=>new y(e)),e.s16be=(e=>new p(2,e)),e.s24be=(e=>new p(3,e)),e.s32be=(e=>new p(4,e)),e.s40be=(e=>new p(5,e)),e.s48be=(e=>new p(6,e)),e.ns64be=(e=>new b(e)),e.f32=(e=>new x(e)),e.f32be=(e=>new ee(e)),e.f64=(e=>new S(e)),e.f64be=(e=>new C(e)),e.struct=((e,t,n)=>new T(e,t,n)),e.bits=((e,t,n)=>new ne(e,t,n)),e.seq=((e,t,n)=>new w(e,t,n)),e.union=((e,t,n)=>new O(e,t,n)),e.unionLayoutDiscriminator=((e,t)=>new D(e,t)),e.blob=((e,t)=>new ie(e,t)),e.cstr=(e=>new j(e)),e.utf8=((e,t)=>new ae(e,t)),e.constant=((e,t)=>new M(e,t))})),kr=n(ir()),Ar=n(sr()),jr=Dr(),L=n(Or()),Mr=8078e3,Nr=8078001,Pr=8078004,Fr=8078005,Ir=8078006,Lr=8078011;function Rr(e){return Array.isArray(e)?`%5B`+e.map(Rr).join(`%2C%20`)+`%5D`:typeof e==`bigint`?`${e}n`:encodeURIComponent(String(e!=null&&Object.getPrototypeOf(e)===null?{...e}:e))}function zr([e,t]){return`${e}=${Rr(t)}`}function Br(e){let t=Object.entries(e).map(zr).join(`&`);return btoa(t)}function Vr(e,t={}){{let n=`Solana error #${e}; Decode this error by running \`npx @solana/errors decode -- ${e}`;return Object.keys(t).length&&(n+=` '${Br(t)}'`),`${n}\``}}var Hr=class extends Error{cause=this.cause;context;constructor(...[e,t]){let n,r;if(t){let{cause:e,...i}=t;e&&(r={cause:e}),Object.keys(i).length>0&&(n=i)}let i=Vr(e,n);super(i,r),this.context={__code:e,...n},this.name=`SolanaError`}};function Ur(e,t){return`fixedSize`in t?t.fixedSize:t.getSizeFromValue(e)}function Wr(e){return Object.freeze({...e,encode:t=>{let n=new Uint8Array(Ur(t,e));return e.write(t,n,0),n}})}function Gr(e){return Object.freeze({...e,decode:(t,n=0)=>e.read(t,n)[0]})}function Kr(e){return`fixedSize`in e&&typeof e.fixedSize==`number`}function qr(e,t){if(Kr(e)!==Kr(t))throw new Hr(Pr);if(Kr(e)&&Kr(t)&&e.fixedSize!==t.fixedSize)throw new Hr(Fr,{decoderFixedSize:t.fixedSize,encoderFixedSize:e.fixedSize});if(!Kr(e)&&!Kr(t)&&e.maxSize!==t.maxSize)throw new Hr(Ir,{decoderMaxSize:t.maxSize,encoderMaxSize:e.maxSize});return{...t,...e,decode:t.decode,encode:e.encode,read:t.read,write:e.write}}function Jr(e,t,n=0){if(t.length-n<=0)throw new Hr(Mr,{codecDescription:e})}function Yr(e,t,n,r=0){let i=n.length-r;if(i<t)throw new Hr(Nr,{bytesLength:i,codecDescription:e,expected:t})}function Xr(e,t,n,r){if(r<t||r>n)throw new Hr(Lr,{codecDescription:e,max:n,min:t,value:r})}function Zr(e){return e?.endian!==1}function Qr(e){return Wr({fixedSize:e.size,write(t,n,r){e.range&&Xr(e.name,e.range[0],e.range[1],t);let i=new ArrayBuffer(e.size);return e.set(new DataView(i),t,Zr(e.config)),n.set(new Uint8Array(i),r),r+e.size}})}function $r(e){return Gr({fixedSize:e.size,read(t,n=0){Jr(e.name,t,n),Yr(e.name,e.size,t,n);let r=new DataView(ei(t,n,e.size));return[e.get(r,Zr(e.config)),n+e.size]}})}function ei(e,t,n){let r=e.byteOffset+(t??0),i=n??e.byteLength;return e.buffer.slice(r,r+i)}var ti=(e={})=>Qr({config:e,name:`u64`,range:[0n,BigInt(`0xffffffffffffffff`)],set:(e,t,n)=>e.setBigUint64(0,BigInt(t),n),size:8}),ni=(e={})=>$r({config:e,get:(e,t)=>e.getBigUint64(0,t),name:`u64`,size:8}),ri=(e={})=>qr(ti(e),ni(e)),ii=class extends TypeError{constructor(e,t){let n,{message:r,explanation:i,...a}=e,{path:o}=e,s=o.length===0?r:`At path: ${o.join(`.`)} -- ${r}`;super(i??s),i!=null&&(this.cause=s),Object.assign(this,a),this.name=this.constructor.name,this.failures=()=>n??=[e,...t()]}};function ai(e){return oi(e)&&typeof e[Symbol.iterator]==`function`}function oi(e){return typeof e==`object`&&!!e}function si(e){return oi(e)&&!Array.isArray(e)}function ci(e){return typeof e==`symbol`?e.toString():typeof e==`string`?JSON.stringify(e):`${e}`}function li(e){let{done:t,value:n}=e.next();return t?void 0:n}function ui(e,t,n,r){if(e===!0)return;e===!1?e={}:typeof e==`string`&&(e={message:e});let{path:i,branch:a}=t,{type:o}=n,{refinement:s,message:c=`Expected a value of type \`${o}\`${s?` with refinement \`${s}\``:``}, but received: \`${ci(r)}\``}=e;return{value:r,type:o,refinement:s,key:i[i.length-1],path:i,branch:a,...e,message:c}}function*di(e,t,n,r){ai(e)||(e=[e]);for(let i of e){let e=ui(i,t,n,r);e&&(yield e)}}function*fi(e,t,n={}){let{path:r=[],branch:i=[e],coerce:a=!1,mask:o=!1}=n,s={path:r,branch:i,mask:o};a&&(e=t.coercer(e,s));let c=`valid`;for(let r of t.validator(e,s))r.explanation=n.message,c=`not_valid`,yield[r,void 0];for(let[l,u,d]of t.entries(e,s)){let t=fi(u,d,{path:l===void 0?r:[...r,l],branch:l===void 0?i:[...i,u],coerce:a,mask:o,message:n.message});for(let n of t)n[0]?(c=n[0].refinement==null?`not_valid`:`not_refined`,yield[n[0],void 0]):a&&(u=n[1],l===void 0?e=u:e instanceof Map?e.set(l,u):e instanceof Set?e.add(u):oi(e)&&(u!==void 0||l in e)&&(e[l]=u))}if(c!==`not_valid`)for(let r of t.refiner(e,s))r.explanation=n.message,c=`not_refined`,yield[r,void 0];c===`valid`&&(yield[void 0,e])}var pi=class{constructor(e){let{type:t,schema:n,validator:r,refiner:i,coercer:a=e=>e,entries:o=function*(){}}=e;this.type=t,this.schema=n,this.entries=o,this.coercer=a,r?this.validator=(e,t)=>di(r(e,t),t,this,e):this.validator=()=>[],i?this.refiner=(e,t)=>di(i(e,t),t,this,e):this.refiner=()=>[]}assert(e,t){return mi(e,this,t)}create(e,t){return R(e,this,t)}is(e){return gi(e,this)}mask(e,t){return hi(e,this,t)}validate(e,t={}){return _i(e,this,t)}};function mi(e,t,n){let r=_i(e,t,{message:n});if(r[0])throw r[0]}function R(e,t,n){let r=_i(e,t,{coerce:!0,message:n});if(r[0])throw r[0];return r[1]}function hi(e,t,n){let r=_i(e,t,{coerce:!0,mask:!0,message:n});if(r[0])throw r[0];return r[1]}function gi(e,t){return!_i(e,t)[0]}function _i(e,t,n={}){let r=fi(e,t,n),i=li(r);return i[0]?[new ii(i[0],function*(){for(let e of r)e[0]&&(yield e[0])}),void 0]:[void 0,i[1]]}function vi(e,t){return new pi({type:e,schema:null,validator:t})}function yi(){return vi(`any`,()=>!0)}function z(e){return new pi({type:`array`,schema:e,*entries(t){if(e&&Array.isArray(t))for(let[n,r]of t.entries())yield[n,r,e]},coercer(e){return Array.isArray(e)?e.slice():e},validator(e){return Array.isArray(e)||`Expected an array value, but received: ${ci(e)}`}})}function bi(){return vi(`boolean`,e=>typeof e==`boolean`)}function xi(e){return vi(`instance`,t=>t instanceof e||`Expected a \`${e.name}\` instance, but received: ${ci(t)}`)}function Si(e){let t=ci(e),n=typeof e;return new pi({type:`literal`,schema:n===`string`||n===`number`||n===`boolean`?e:null,validator(n){return n===e||`Expected the literal \`${t}\`, but received: ${ci(n)}`}})}function Ci(){return vi(`never`,()=>!1)}function B(e){return new pi({...e,validator:(t,n)=>t===null||e.validator(t,n),refiner:(t,n)=>t===null||e.refiner(t,n)})}function V(){return vi(`number`,e=>typeof e==`number`&&!isNaN(e)||`Expected a number, but received: ${ci(e)}`)}function H(e){return new pi({...e,validator:(t,n)=>t===void 0||e.validator(t,n),refiner:(t,n)=>t===void 0||e.refiner(t,n)})}function wi(e,t){return new pi({type:`record`,schema:null,*entries(n){if(oi(n))for(let r in n){let i=n[r];yield[r,r,e],yield[r,i,t]}},validator(e){return si(e)||`Expected an object, but received: ${ci(e)}`},coercer(e){return si(e)?{...e}:e}})}function U(){return vi(`string`,e=>typeof e==`string`||`Expected a string, but received: ${ci(e)}`)}function Ti(e){let t=Ci();return new pi({type:`tuple`,schema:null,*entries(n){if(Array.isArray(n)){let r=Math.max(e.length,n.length);for(let i=0;i<r;i++)yield[i,n[i],e[i]||t]}},validator(e){return Array.isArray(e)||`Expected an array, but received: ${ci(e)}`},coercer(e){return Array.isArray(e)?e.slice():e}})}function W(e){let t=Object.keys(e);return new pi({type:`type`,schema:e,*entries(n){if(oi(n))for(let r of t)yield[r,n[r],e[r]]},validator(e){return si(e)||`Expected an object, but received: ${ci(e)}`},coercer(e){return si(e)?{...e}:e}})}function Ei(e){let t=e.map(e=>e.type).join(` | `);return new pi({type:`union`,schema:null,coercer(t,n){for(let r of e){let[e,i]=r.validate(t,{coerce:!0,mask:n.mask});if(!e)return i}return t},validator(n,r){let i=[];for(let t of e){let[...e]=fi(n,t,r),[a]=e;if(a[0])for(let[t]of e)t&&i.push(t);else return[]}return[`Expected the value to satisfy a union of \`${t}\`, but received: ${ci(n)}`,...i]}})}function Di(){return vi(`unknown`,()=>!0)}function Oi(e,t,n){return new pi({...e,coercer:(r,i)=>gi(r,t)?e.coercer(n(r,i),i):e.coercer(r,i)})}function ki(){if(!Ai&&(Ai=typeof crypto<`u`&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<`u`&&typeof msCrypto.getRandomValues==`function`&&msCrypto.getRandomValues.bind(msCrypto),!Ai))throw Error(`crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported`);return Ai(ji)}var Ai,ji,Mi=t((()=>{ji=new Uint8Array(16)})),Ni,Pi=t((()=>{Ni=/^(?:[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 Fi(e){return typeof e==`string`&&Ni.test(e)}var Ii=t((()=>{Pi()}));function Li(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=(Ri[e[t+0]]+Ri[e[t+1]]+Ri[e[t+2]]+Ri[e[t+3]]+`-`+Ri[e[t+4]]+Ri[e[t+5]]+`-`+Ri[e[t+6]]+Ri[e[t+7]]+`-`+Ri[e[t+8]]+Ri[e[t+9]]+`-`+Ri[e[t+10]]+Ri[e[t+11]]+Ri[e[t+12]]+Ri[e[t+13]]+Ri[e[t+14]]+Ri[e[t+15]]).toLowerCase();if(!Fi(n))throw TypeError(`Stringified UUID is invalid`);return n}var Ri,zi,Bi=t((()=>{for(Ii(),Ri=[],zi=0;zi<256;++zi)Ri.push((zi+256).toString(16).substr(1))}));function Vi(e,t,n){var r=t&&n||0,i=t||Array(16);e||={};var a=e.node||Hi,o=e.clockseq===void 0?Ui:e.clockseq;if(a==null||o==null){var s=e.random||(e.rng||ki)();a??=Hi=[s[0]|1,s[1],s[2],s[3],s[4],s[5]],o??=Ui=(s[6]<<8|s[7])&16383}var c=e.msecs===void 0?Date.now():e.msecs,l=e.nsecs===void 0?Gi+1:e.nsecs,u=c-Wi+(l-Gi)/1e4;if(u<0&&e.clockseq===void 0&&(o=o+1&16383),(u<0||c>Wi)&&e.nsecs===void 0&&(l=0),l>=1e4)throw Error(`uuid.v1(): Can't create more than 10M uuids/sec`);Wi=c,Gi=l,Ui=o,c+=0xb1d069b5400;var d=((c&268435455)*1e4+l)%4294967296;i[r++]=d>>>24&255,i[r++]=d>>>16&255,i[r++]=d>>>8&255,i[r++]=d&255;var f=c/4294967296*1e4&268435455;i[r++]=f>>>8&255,i[r++]=f&255,i[r++]=f>>>24&15|16,i[r++]=f>>>16&255,i[r++]=o>>>8|128,i[r++]=o&255;for(var p=0;p<6;++p)i[r+p]=a[p];return t||Li(i)}var Hi,Ui,Wi,Gi,Ki=t((()=>{Mi(),Bi(),Wi=0,Gi=0}));function qi(e){if(!Fi(e))throw TypeError(`Invalid UUID`);var t,n=new Uint8Array(16);return n[0]=(t=parseInt(e.slice(0,8),16))>>>24,n[1]=t>>>16&255,n[2]=t>>>8&255,n[3]=t&255,n[4]=(t=parseInt(e.slice(9,13),16))>>>8,n[5]=t&255,n[6]=(t=parseInt(e.slice(14,18),16))>>>8,n[7]=t&255,n[8]=(t=parseInt(e.slice(19,23),16))>>>8,n[9]=t&255,n[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,n[11]=t/4294967296&255,n[12]=t>>>24&255,n[13]=t>>>16&255,n[14]=t>>>8&255,n[15]=t&255,n}var Ji=t((()=>{Ii()}));function Yi(e){e=unescape(encodeURIComponent(e));for(var t=[],n=0;n<e.length;++n)t.push(e.charCodeAt(n));return t}function Xi(e,t,n){function r(e,r,i,a){if(typeof e==`string`&&(e=Yi(e)),typeof r==`string`&&(r=qi(r)),r.length!==16)throw TypeError(`Namespace must be array-like (16 iterable integer values, 0-255)`);var o=new Uint8Array(16+e.length);if(o.set(r),o.set(e,r.length),o=n(o),o[6]=o[6]&15|t,o[8]=o[8]&63|128,i){a||=0;for(var s=0;s<16;++s)i[a+s]=o[s];return i}return Li(o)}try{r.name=e}catch{}return r.DNS=Zi,r.URL=Qi,r}var Zi,Qi,$i=t((()=>{Bi(),Ji(),Zi=`6ba7b810-9dad-11d1-80b4-00c04fd430c8`,Qi=`6ba7b811-9dad-11d1-80b4-00c04fd430c8`}));function ea(e){if(typeof e==`string`){var t=unescape(encodeURIComponent(e));e=new Uint8Array(t.length);for(var n=0;n<t.length;++n)e[n]=t.charCodeAt(n)}return ta(ra(ia(e),e.length*8))}function ta(e){for(var t=[],n=e.length*32,r=`0123456789abcdef`,i=0;i<n;i+=8){var a=e[i>>5]>>>i%32&255,o=parseInt(r.charAt(a>>>4&15)+r.charAt(a&15),16);t.push(o)}return t}function na(e){return(e+64>>>9<<4)+14+1}function ra(e,t){e[t>>5]|=128<<t%32,e[na(t)-1]=t;for(var n=1732584193,r=-271733879,i=-1732584194,a=271733878,o=0;o<e.length;o+=16){var s=n,c=r,l=i,u=a;n=ca(n,r,i,a,e[o],7,-680876936),a=ca(a,n,r,i,e[o+1],12,-389564586),i=ca(i,a,n,r,e[o+2],17,606105819),r=ca(r,i,a,n,e[o+3],22,-1044525330),n=ca(n,r,i,a,e[o+4],7,-176418897),a=ca(a,n,r,i,e[o+5],12,1200080426),i=ca(i,a,n,r,e[o+6],17,-1473231341),r=ca(r,i,a,n,e[o+7],22,-45705983),n=ca(n,r,i,a,e[o+8],7,1770035416),a=ca(a,n,r,i,e[o+9],12,-1958414417),i=ca(i,a,n,r,e[o+10],17,-42063),r=ca(r,i,a,n,e[o+11],22,-1990404162),n=ca(n,r,i,a,e[o+12],7,1804603682),a=ca(a,n,r,i,e[o+13],12,-40341101),i=ca(i,a,n,r,e[o+14],17,-1502002290),r=ca(r,i,a,n,e[o+15],22,1236535329),n=la(n,r,i,a,e[o+1],5,-165796510),a=la(a,n,r,i,e[o+6],9,-1069501632),i=la(i,a,n,r,e[o+11],14,643717713),r=la(r,i,a,n,e[o],20,-373897302),n=la(n,r,i,a,e[o+5],5,-701558691),a=la(a,n,r,i,e[o+10],9,38016083),i=la(i,a,n,r,e[o+15],14,-660478335),r=la(r,i,a,n,e[o+4],20,-405537848),n=la(n,r,i,a,e[o+9],5,568446438),a=la(a,n,r,i,e[o+14],9,-1019803690),i=la(i,a,n,r,e[o+3],14,-187363961),r=la(r,i,a,n,e[o+8],20,1163531501),n=la(n,r,i,a,e[o+13],5,-1444681467),a=la(a,n,r,i,e[o+2],9,-51403784),i=la(i,a,n,r,e[o+7],14,1735328473),r=la(r,i,a,n,e[o+12],20,-1926607734),n=ua(n,r,i,a,e[o+5],4,-378558),a=ua(a,n,r,i,e[o+8],11,-2022574463),i=ua(i,a,n,r,e[o+11],16,1839030562),r=ua(r,i,a,n,e[o+14],23,-35309556),n=ua(n,r,i,a,e[o+1],4,-1530992060),a=ua(a,n,r,i,e[o+4],11,1272893353),i=ua(i,a,n,r,e[o+7],16,-155497632),r=ua(r,i,a,n,e[o+10],23,-1094730640),n=ua(n,r,i,a,e[o+13],4,681279174),a=ua(a,n,r,i,e[o],11,-358537222),i=ua(i,a,n,r,e[o+3],16,-722521979),r=ua(r,i,a,n,e[o+6],23,76029189),n=ua(n,r,i,a,e[o+9],4,-640364487),a=ua(a,n,r,i,e[o+12],11,-421815835),i=ua(i,a,n,r,e[o+15],16,530742520),r=ua(r,i,a,n,e[o+2],23,-995338651),n=da(n,r,i,a,e[o],6,-198630844),a=da(a,n,r,i,e[o+7],10,1126891415),i=da(i,a,n,r,e[o+14],15,-1416354905),r=da(r,i,a,n,e[o+5],21,-57434055),n=da(n,r,i,a,e[o+12],6,1700485571),a=da(a,n,r,i,e[o+3],10,-1894986606),i=da(i,a,n,r,e[o+10],15,-1051523),r=da(r,i,a,n,e[o+1],21,-2054922799),n=da(n,r,i,a,e[o+8],6,1873313359),a=da(a,n,r,i,e[o+15],10,-30611744),i=da(i,a,n,r,e[o+6],15,-1560198380),r=da(r,i,a,n,e[o+13],21,1309151649),n=da(n,r,i,a,e[o+4],6,-145523070),a=da(a,n,r,i,e[o+11],10,-1120210379),i=da(i,a,n,r,e[o+2],15,718787259),r=da(r,i,a,n,e[o+9],21,-343485551),n=aa(n,s),r=aa(r,c),i=aa(i,l),a=aa(a,u)}return[n,r,i,a]}function ia(e){if(e.length===0)return[];for(var t=e.length*8,n=new Uint32Array(na(t)),r=0;r<t;r+=8)n[r>>5]|=(e[r/8]&255)<<r%32;return n}function aa(e,t){var n=(e&65535)+(t&65535);return(e>>16)+(t>>16)+(n>>16)<<16|n&65535}function oa(e,t){return e<<t|e>>>32-t}function sa(e,t,n,r,i,a){return aa(oa(aa(aa(t,e),aa(r,a)),i),n)}function ca(e,t,n,r,i,a,o){return sa(t&n|~t&r,e,t,i,a,o)}function la(e,t,n,r,i,a,o){return sa(t&r|n&~r,e,t,i,a,o)}function ua(e,t,n,r,i,a,o){return sa(t^n^r,e,t,i,a,o)}function da(e,t,n,r,i,a,o){return sa(n^(t|~r),e,t,i,a,o)}var fa=t((()=>{})),pa,ma=t((()=>{$i(),fa(),pa=Xi(`v3`,48,ea)}));function ha(e,t,n){e||={};var r=e.random||(e.rng||ki)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){n||=0;for(var i=0;i<16;++i)t[n+i]=r[i];return t}return Li(r)}var ga=t((()=>{Mi(),Bi()}));function _a(e,t,n,r){switch(e){case 0:return t&n^~t&r;case 1:return t^n^r;case 2:return t&n^t&r^n&r;case 3:return t^n^r}}function va(e,t){return e<<t|e>>>32-t}function ya(e){var t=[1518500249,1859775393,2400959708,3395469782],n=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof e==`string`){var r=unescape(encodeURIComponent(e));e=[];for(var i=0;i<r.length;++i)e.push(r.charCodeAt(i))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);for(var a=e.length/4+2,o=Math.ceil(a/16),s=Array(o),c=0;c<o;++c){for(var l=new Uint32Array(16),u=0;u<16;++u)l[u]=e[c*64+u*4]<<24|e[c*64+u*4+1]<<16|e[c*64+u*4+2]<<8|e[c*64+u*4+3];s[c]=l}s[o-1][14]=(e.length-1)*8/2**32,s[o-1][14]=Math.floor(s[o-1][14]),s[o-1][15]=(e.length-1)*8&4294967295;for(var d=0;d<o;++d){for(var f=new Uint32Array(80),p=0;p<16;++p)f[p]=s[d][p];for(var m=16;m<80;++m)f[m]=va(f[m-3]^f[m-8]^f[m-14]^f[m-16],1);for(var h=n[0],g=n[1],_=n[2],v=n[3],y=n[4],b=0;b<80;++b){var x=Math.floor(b/20),ee=va(h,5)+_a(x,g,_,v)+y+t[x]+f[b]>>>0;y=v,v=_,_=va(g,30)>>>0,g=h,h=ee}n[0]=n[0]+h>>>0,n[1]=n[1]+g>>>0,n[2]=n[2]+_>>>0,n[3]=n[3]+v>>>0,n[4]=n[4]+y>>>0}return[n[0]>>24&255,n[0]>>16&255,n[0]>>8&255,n[0]&255,n[1]>>24&255,n[1]>>16&255,n[1]>>8&255,n[1]&255,n[2]>>24&255,n[2]>>16&255,n[2]>>8&255,n[2]&255,n[3]>>24&255,n[3]>>16&255,n[3]>>8&255,n[3]&255,n[4]>>24&255,n[4]>>16&255,n[4]>>8&255,n[4]&255]}var ba=t((()=>{})),xa,Sa=t((()=>{$i(),ba(),xa=Xi(`v5`,80,ya)})),Ca,wa=t((()=>{Ca=`00000000-0000-0000-0000-000000000000`}));function Ta(e){if(!Fi(e))throw TypeError(`Invalid UUID`);return parseInt(e.substr(14,1),16)}var Ea=t((()=>{Ii()})),Da=r({NIL:()=>Ca,parse:()=>qi,stringify:()=>Li,v1:()=>Vi,v3:()=>pa,v4:()=>ha,v5:()=>xa,validate:()=>Fi,version:()=>Ta}),Oa=t((()=>{Ki(),ma(),ga(),Sa(),wa(),Ea(),Ii(),Bi(),Ji()})),ka=i(((t,n)=>{var r=(Oa(),e(Da)).v4;n.exports=function(e,t,n,i){if(typeof e!=`string`)throw TypeError(e+` must be a string`);i||={};let a=typeof i.version==`number`?i.version:2;if(a!==1&&a!==2)throw TypeError(a+` must be 1 or 2`);let o={method:e};if(a===2&&(o.jsonrpc=`2.0`),t){if(typeof t!=`object`&&!Array.isArray(t))throw TypeError(t+` must be an object, array or omitted`);o.params=t}return n===void 0?o.id=(typeof i.generator==`function`?i.generator:function(){return r()})(o,i):a===2&&n===null?i.notificationIdNull&&(o.id=null):o.id=n,o}})),Aa=n(i(((t,n)=>{var r=(Oa(),e(Da)).v4,i=ka(),a=function(e,t){if(!(this instanceof a))return new a(e,t);t||={},this.options={reviver:t.reviver===void 0?null:t.reviver,replacer:t.replacer===void 0?null:t.replacer,generator:t.generator===void 0?function(){return r()}:t.generator,version:t.version===void 0?2:t.version,notificationIdNull:typeof t.notificationIdNull==`boolean`?t.notificationIdNull:!1},this.callServer=e};n.exports=a,a.prototype.request=function(e,t,n,r){let a=this,o=null,s=Array.isArray(e)&&typeof t==`function`;if(this.options.version===1&&s)throw TypeError(`JSON-RPC 1.0 does not support batching`);if(s||!s&&e&&typeof e==`object`&&typeof t==`function`)r=t,o=e;else{typeof n==`function`&&(r=n,n=void 0);let a=typeof r==`function`;try{o=i(e,t,n,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(e){if(a){r(e);return}throw e}if(!a)return o}let c;try{c=JSON.stringify(o,this.options.replacer)}catch(e){r(e);return}return this.callServer(c,function(e,t){a._parseResponse(e,t,r)}),o},a.prototype._parseResponse=function(e,t,n){if(e){n(e);return}if(!t){n();return}let r;try{r=JSON.parse(t,this.options.reviver)}catch(e){n(e);return}if(n.length===3)if(Array.isArray(r)){let e=function(e){return e.error!==void 0};n(null,r.filter(e),r.filter(function(t){return!e(t)}));return}else{n(null,r.error,r.result);return}n(null,r)}}))()),ja=class extends o.default{socket;constructor(e,t){super(),this.socket=new window.WebSocket(e,t.protocols),this.socket.onopen=()=>this.emit(`open`),this.socket.onmessage=e=>this.emit(`message`,e.data),this.socket.onerror=e=>this.emit(`error`,e),this.socket.onclose=e=>{this.emit(`close`,e.code,e.reason)}}send(e,t,n){let r=n||t;try{this.socket.send(e),r()}catch(e){r(e)}}close(e,t){this.socket.close(e,t)}addEventListener(e,t,n){this.socket.addEventListener(e,t,n)}};function Ma(e,t){return new ja(e,t)}var Na=class{encode(e){return JSON.stringify(e)}decode(e){return JSON.parse(e)}},Pa=class extends o.default{address;rpc_id;queue;options;autoconnect;ready;reconnect;reconnect_timer_id;reconnect_interval;max_reconnects;rest_options;current_reconnects;generate_request_id;socket;webSocketFactory;dataPack;constructor(e,t=`ws://localhost:8080`,{autoconnect:n=!0,reconnect:r=!0,reconnect_interval:i=1e3,max_reconnects:a=5,...o}={},s,c){super(),this.webSocketFactory=e,this.queue={},this.rpc_id=0,this.address=t,this.autoconnect=n,this.ready=!1,this.reconnect=r,this.reconnect_timer_id=void 0,this.reconnect_interval=i,this.max_reconnects=a,this.rest_options=o,this.current_reconnects=0,this.generate_request_id=s||(()=>typeof this.rpc_id==`number`?++this.rpc_id:Number(this.rpc_id)+1),c?this.dataPack=c:this.dataPack=new Na,this.autoconnect&&this._connect(this.address,{autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects,...this.rest_options})}connect(){this.socket||this._connect(this.address,{autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects,...this.rest_options})}call(e,t,n,r){return!r&&typeof n==`object`&&(r=n,n=null),new Promise((i,a)=>{if(!this.ready)return a(Error(`socket not ready`));let o=this.generate_request_id(e,t),s={jsonrpc:`2.0`,method:e,params:t||void 0,id:o};this.socket.send(this.dataPack.encode(s),r,e=>{if(e)return a(e);this.queue[o]={promise:[i,a]},n&&(this.queue[o].timeout=setTimeout(()=>{delete this.queue[o],a(Error(`reply timeout`))},n))})})}async login(e){let t=await this.call(`rpc.login`,e);if(!t)throw Error(`authentication failed`);return t}async listMethods(){return await this.call(`__listMethods`)}notify(e,t){return new Promise((n,r)=>{if(!this.ready)return r(Error(`socket not ready`));let i={jsonrpc:`2.0`,method:e,params:t};this.socket.send(this.dataPack.encode(i),e=>{if(e)return r(e);n()})})}async subscribe(e){typeof e==`string`&&(e=[e]);let t=await this.call(`rpc.on`,e);if(typeof e==`string`&&t[e]!==`ok`)throw Error(`Failed subscribing to an event '`+e+`' with: `+t[e]);return t}async unsubscribe(e){typeof e==`string`&&(e=[e]);let t=await this.call(`rpc.off`,e);if(typeof e==`string`&&t[e]!==`ok`)throw Error(`Failed unsubscribing from an event with: `+t);return t}close(e,t){this.socket&&this.socket.close(e||1e3,t)}setAutoReconnect(e){this.reconnect=e}setReconnectInterval(e){this.reconnect_interval=e}setMaxReconnects(e){this.max_reconnects=e}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(e,t){clearTimeout(this.reconnect_timer_id),this.socket=this.webSocketFactory(e,t),this.socket.addEventListener(`open`,()=>{this.ready=!0,this.emit(`open`),this.current_reconnects=0}),this.socket.addEventListener(`message`,({data:e})=>{e instanceof ArrayBuffer&&(e=I.Buffer.from(e).toString());try{e=this.dataPack.decode(e)}catch{return}if(e.notification&&this.listeners(e.notification).length){if(!Object.keys(e.params).length)return this.emit(e.notification);let t=[e.notification];if(e.params.constructor===Object)t.push(e.params);else for(let n=0;n<e.params.length;n++)t.push(e.params[n]);return Promise.resolve().then(()=>{this.emit.apply(this,t)})}if(!this.queue[e.id])return e.method?Promise.resolve().then(()=>{this.emit(e.method,e?.params)}):void 0;`error`in e==`result`in e&&this.queue[e.id].promise[1](Error(`Server response malformed. Response must include either "result" or "error", but not both.`)),this.queue[e.id].timeout&&clearTimeout(this.queue[e.id].timeout),e.error?this.queue[e.id].promise[1](e.error):this.queue[e.id].promise[0](e.result),delete this.queue[e.id]}),this.socket.addEventListener(`error`,e=>this.emit(`error`,e)),this.socket.addEventListener(`close`,({code:n,reason:r})=>{this.ready&&setTimeout(()=>this.emit(`close`,n,r),0),this.ready=!1,this.socket=void 0,n!==1e3&&(this.current_reconnects++,this.reconnect&&(this.max_reconnects>this.current_reconnects||this.max_reconnects===0)?this.reconnect_timer_id=setTimeout(()=>this._connect(e,t),this.reconnect_interval):this.reconnect&&this.max_reconnects>0&&this.current_reconnects>=this.max_reconnects&&setTimeout(()=>this.emit(`max_reconnects_reached`,n,r),1))})}},Fa=(e,t)=>(e+(e>=0?t:-t)/Ha)/t;function Ia(e,t,n){let[[r,i],[a,o]]=t,s=Fa(o*e,n),c=Fa(-i*e,n),l=e-s*r-c*a,u=-s*i-c*o,d=l<Ba,f=u<Ba;d&&(l=-l),f&&(u=-u);let p=St(Math.ceil(xt(n)/2))+Va;if(l<Ba||l>=p||u<Ba||u>=p)throw Error(`splitScalar (endomorphism): failed, k=`+e);return{k1neg:d,k1:l,k2neg:f,k2:u}}function La(e){if(![`compact`,`recovered`,`der`].includes(e))throw Error(`Signature format must be "compact", "recovered", or "der"`);return e}function Ra(e,t){let n={};for(let r of Object.keys(t))n[r]=e[r]===void 0?t[r]:e[r];return st(n.lowS,`lowS`),st(n.prehash,`prehash`),n.format!==void 0&&La(n.format),n}var za={Err:class extends Error{constructor(e=``){super(e)}},_tlv:{encode:(e,t)=>{let{Err:n}=za;if(e<0||e>256)throw new n(`tlv.encode: wrong tag`);if(t.length&1)throw new n(`tlv.encode: unpadded data`);let r=t.length/2,i=lt(r);if(i.length/2&128)throw new n(`tlv.encode: long form length too big`);let a=r>127?lt(i.length/2|128):``;return lt(e)+a+i+t},decode(e,t){let{Err:n}=za,r=0;if(e<0||e>256)throw new n(`tlv.encode: wrong tag`);if(t.length<2||t[r++]!==e)throw new n(`tlv.decode: wrong tlv`);let i=t[r++],a=!!(i&128),o=0;if(!a)o=i;else{let e=i&127;if(!e)throw new n(`tlv.decode(long): indefinite length not supported`);if(e>4)throw new n(`tlv.decode(long): byte length is too big`);let a=t.subarray(r,r+e);if(a.length!==e)throw new n(`tlv.decode: length bytes not complete`);if(a[0]===0)throw new n(`tlv.decode(long): zero leftmost byte`);for(let e of a)o=o<<8|e;if(r+=e,o<128)throw new n(`tlv.decode(long): not minimal encoding`)}let s=t.subarray(r,r+o);if(s.length!==o)throw new n(`tlv.decode: wrong value length`);return{v:s,l:t.subarray(r+o)}}},_int:{encode(e){let{Err:t}=za;if(e<Ba)throw new t(`integer: negative integers are not allowed`);let n=lt(e);if(Number.parseInt(n[0],16)&8&&(n=`00`+n),n.length&1)throw new t(`unexpected DER parsing assertion: unpadded hex`);return n},decode(e){let{Err:t}=za;if(e[0]&128)throw new t(`invalid signature integer: negative`);if(e[0]===0&&!(e[1]&128))throw new t(`invalid signature integer: unnecessary leading zero`);return dt(e)}},toSig(e){let{Err:t,_int:n,_tlv:r}=za,i=ht(`signature`,e),{v:a,l:o}=r.decode(48,i);if(o.length)throw new t(`invalid signature: left bytes after parsing`);let{v:s,l:c}=r.decode(2,a),{v:l,l:u}=r.decode(2,c);if(u.length)throw new t(`invalid signature: left bytes after parsing`);return{r:n.decode(s),s:n.decode(l)}},hexFromSig(e){let{_tlv:t,_int:n}=za,r=t.encode(2,n.encode(e.r))+t.encode(2,n.encode(e.s));return t.encode(48,r)}},Ba=BigInt(0),Va=BigInt(1),Ha=BigInt(2),Ua=BigInt(3),Wa=BigInt(4);function Ga(e,t){let{BYTES:n}=e,r;if(typeof t==`bigint`)r=t;else{let i=ht(`private key`,t);try{r=e.fromBytes(i)}catch{throw Error(`invalid private key: expected ui8a of size ${n}, got ${typeof t}`)}}if(!e.isValidNot0(r))throw Error(`invalid private key: out of range [1..N-1]`);return r}function Ka(e,t={}){let n=xn(`weierstrass`,e,t),{Fp:r,Fn:i}=n,a=n.CURVE,{h:o,n:s}=a;wt(t,{},{allowInfinityPoint:`boolean`,clearCofactor:`function`,isTorsionFree:`function`,fromBytes:`function`,toBytes:`function`,endo:`object`,wrapPrivateKey:`boolean`});let{endo:c}=t;if(c&&(!r.is0(a.a)||typeof c.beta!=`bigint`||!Array.isArray(c.basises)))throw Error(`invalid endo: expected "beta": bigint and "basises": array`);let l=Ja(r,i);function u(){if(!r.isOdd)throw Error(`compression is not supported: Field does not have .isOdd()`)}function d(e,t,n){let{x:i,y:a}=t.toAffine(),o=r.toBytes(i);return st(n,`isCompressed`),n?(u(),F(qa(!r.isOdd(a)),o)):F(Uint8Array.of(4),o,r.toBytes(a))}function f(e){ct(e,void 0,`Point`);let{publicKey:t,publicKeyUncompressed:n}=l,i=e.length,a=e[0],o=e.subarray(1);if(i===t&&(a===2||a===3)){let e=r.fromBytes(o);if(!r.isValid(e))throw Error(`bad point: is not on curve, wrong x`);let t=h(e),n;try{n=r.sqrt(t)}catch(e){let t=e instanceof Error?`: `+e.message:``;throw Error(`bad point: is not on curve, sqrt error`+t)}u();let i=r.isOdd(n);return(a&1)==1!==i&&(n=r.neg(n)),{x:e,y:n}}else if(i===n&&a===4){let e=r.BYTES,t=r.fromBytes(o.subarray(0,e)),n=r.fromBytes(o.subarray(e,e*2));if(!g(t,n))throw Error(`bad point: is not on curve`);return{x:t,y:n}}else throw Error(`bad point: got length ${i}, expected compressed=${t} or uncompressed=${n}`)}let p=t.toBytes||d,m=t.fromBytes||f;function h(e){let t=r.sqr(e),n=r.mul(t,e);return r.add(r.add(n,r.mul(e,a.a)),a.b)}function g(e,t){let n=r.sqr(t),i=h(e);return r.eql(n,i)}if(!g(a.Gx,a.Gy))throw Error(`bad curve params: generator point`);let _=r.mul(r.pow(a.a,Ua),Wa),v=r.mul(r.sqr(a.b),BigInt(27));if(r.is0(r.add(_,v)))throw Error(`bad curve params: a or b`);function y(e,t,n=!1){if(!r.isValid(t)||n&&r.is0(t))throw Error(`bad point coordinate ${e}`);return t}function b(e){if(!(e instanceof w))throw Error(`ProjectivePoint expected`)}function x(e){if(!c||!c.basises)throw Error(`no endo`);return Ia(e,c.basises,i.ORDER)}let ee=Et((e,t)=>{let{X:n,Y:i,Z:a}=e;if(r.eql(a,r.ONE))return{x:n,y:i};let o=e.is0();t??=o?r.ONE:r.inv(a);let s=r.mul(n,t),c=r.mul(i,t),l=r.mul(a,t);if(o)return{x:r.ZERO,y:r.ZERO};if(!r.eql(l,r.ONE))throw Error(`invZ was invalid`);return{x:s,y:c}}),S=Et(e=>{if(e.is0()){if(t.allowInfinityPoint&&!r.is0(e.Y))return;throw Error(`bad point: ZERO`)}let{x:n,y:i}=e.toAffine();if(!r.isValid(n)||!r.isValid(i))throw Error(`bad point: x or y not field elements`);if(!g(n,i))throw Error(`bad point: equation left != right`);if(!e.isTorsionFree())throw Error(`bad point: not in prime-order subgroup`);return!0});function C(e,t,n,i,a){return n=new w(r.mul(n.X,e),n.Y,n.Z),t=on(i,t),n=on(a,n),t.add(n)}class w{constructor(e,t,n){this.X=y(`x`,e),this.Y=y(`y`,t,!0),this.Z=y(`z`,n),Object.freeze(this)}static CURVE(){return a}static fromAffine(e){let{x:t,y:n}=e||{};if(!e||!r.isValid(t)||!r.isValid(n))throw Error(`invalid affine point`);if(e instanceof w)throw Error(`projective point not allowed`);return r.is0(t)&&r.is0(n)?w.ZERO:new w(t,n,r.ONE)}static fromBytes(e){let t=w.fromAffine(m(ct(e,void 0,`point`)));return t.assertValidity(),t}static fromHex(e){return w.fromBytes(ht(`pointHex`,e))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(e=8,t=!0){return E.createCache(this,e),t||this.multiply(Ua),this}assertValidity(){S(this)}hasEvenY(){let{y:e}=this.toAffine();if(!r.isOdd)throw Error(`Field doesn't support isOdd`);return!r.isOdd(e)}equals(e){b(e);let{X:t,Y:n,Z:i}=this,{X:a,Y:o,Z:s}=e,c=r.eql(r.mul(t,s),r.mul(a,i)),l=r.eql(r.mul(n,s),r.mul(o,i));return c&&l}negate(){return new w(this.X,r.neg(this.Y),this.Z)}double(){let{a:e,b:t}=a,n=r.mul(t,Ua),{X:i,Y:o,Z:s}=this,c=r.ZERO,l=r.ZERO,u=r.ZERO,d=r.mul(i,i),f=r.mul(o,o),p=r.mul(s,s),m=r.mul(i,o);return m=r.add(m,m),u=r.mul(i,s),u=r.add(u,u),c=r.mul(e,u),l=r.mul(n,p),l=r.add(c,l),c=r.sub(f,l),l=r.add(f,l),l=r.mul(c,l),c=r.mul(m,c),u=r.mul(n,u),p=r.mul(e,p),m=r.sub(d,p),m=r.mul(e,m),m=r.add(m,u),u=r.add(d,d),d=r.add(u,d),d=r.add(d,p),d=r.mul(d,m),l=r.add(l,d),p=r.mul(o,s),p=r.add(p,p),d=r.mul(p,m),c=r.sub(c,d),u=r.mul(p,f),u=r.add(u,u),u=r.add(u,u),new w(c,l,u)}add(e){b(e);let{X:t,Y:n,Z:i}=this,{X:o,Y:s,Z:c}=e,l=r.ZERO,u=r.ZERO,d=r.ZERO,f=a.a,p=r.mul(a.b,Ua),m=r.mul(t,o),h=r.mul(n,s),g=r.mul(i,c),_=r.add(t,n),v=r.add(o,s);_=r.mul(_,v),v=r.add(m,h),_=r.sub(_,v),v=r.add(t,i);let y=r.add(o,c);return v=r.mul(v,y),y=r.add(m,g),v=r.sub(v,y),y=r.add(n,i),l=r.add(s,c),y=r.mul(y,l),l=r.add(h,g),y=r.sub(y,l),d=r.mul(f,v),l=r.mul(p,g),d=r.add(l,d),l=r.sub(h,d),d=r.add(h,d),u=r.mul(l,d),h=r.add(m,m),h=r.add(h,m),g=r.mul(f,g),v=r.mul(p,v),h=r.add(h,g),g=r.sub(m,g),g=r.mul(f,g),v=r.add(v,g),m=r.mul(h,v),u=r.add(u,m),m=r.mul(y,v),l=r.mul(_,l),l=r.sub(l,m),m=r.mul(_,h),d=r.mul(y,d),d=r.add(d,m),new w(l,u,d)}subtract(e){return this.add(e.negate())}is0(){return this.equals(w.ZERO)}multiply(e){let{endo:n}=t;if(!i.isValidNot0(e))throw Error(`invalid scalar: out of range`);let r,a,o=e=>E.cached(this,e,e=>sn(w,e));if(n){let{k1neg:t,k1:i,k2neg:s,k2:c}=x(e),{p:l,f:u}=o(i),{p:d,f}=o(c);a=u.add(f),r=C(n.beta,l,d,t,s)}else{let{p:t,f:n}=o(e);r=t,a=n}return sn(w,[r,a])[0]}multiplyUnsafe(e){let{endo:n}=t,r=this;if(!i.isValid(e))throw Error(`invalid scalar: out of range`);if(e===Ba||r.is0())return w.ZERO;if(e===Va)return r;if(E.hasCache(this))return this.multiply(e);if(n){let{k1neg:t,k1:i,k2neg:a,k2:o}=x(e),{p1:s,p2:c}=vn(w,r,i,o);return C(n.beta,s,c,t,a)}else return E.unsafe(r,e)}multiplyAndAddUnsafe(e,t,n){let r=this.multiplyUnsafe(t).add(e.multiplyUnsafe(n));return r.is0()?void 0:r}toAffine(e){return ee(this,e)}isTorsionFree(){let{isTorsionFree:e}=t;return o===Va?!0:e?e(w,this):E.unsafe(this,s).is0()}clearCofactor(){let{clearCofactor:e}=t;return o===Va?this:e?e(w,this):this.multiplyUnsafe(o)}isSmallOrder(){return this.multiplyUnsafe(o).is0()}toBytes(e=!0){return st(e,`isCompressed`),this.assertValidity(),p(w,this,e)}toHex(e=!0){return N(this.toBytes(e))}toString(){return`<Point ${this.is0()?`ZERO`:this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(e=!0){return this.toBytes(e)}_setWindowSize(e){this.precompute(e)}static normalizeZ(e){return sn(w,e)}static msm(e,t){return yn(w,i,e,t)}static fromPrivateKey(e){return w.BASE.multiply(Ga(i,e))}}w.BASE=new w(a.Gx,a.Gy,r.ONE),w.ZERO=new w(r.ZERO,r.ONE,r.ZERO),w.Fp=r,w.Fn=i;let T=i.BITS,E=new _n(w,t.endo?Math.ceil(T/2):T);return w.BASE.precompute(8),w}function qa(e){return Uint8Array.of(e?2:3)}function Ja(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function Ya(e,t={}){let{Fn:n}=e,r=t.randomBytes||ve,i=Object.assign(Ja(e.Fp,n),{seed:tn(n.ORDER)});function a(e){try{return!!Ga(n,e)}catch{return!1}}function o(t,n){let{publicKey:r,publicKeyUncompressed:a}=i;try{let i=t.length;return n===!0&&i!==r||n===!1&&i!==a?!1:!!e.fromBytes(t)}catch{return!1}}function s(e=r(i.seed)){return nn(ct(e,i.seed,`seed`),n.ORDER)}function c(t,r=!0){return e.BASE.multiply(Ga(n,t)).toBytes(r)}function l(e){let t=s(e);return{secretKey:t,publicKey:c(t)}}function u(t){if(typeof t==`bigint`)return!1;if(t instanceof e)return!0;let{secretKey:r,publicKey:a,publicKeyUncompressed:o}=i;if(n.allowedLengths||r===a)return;let s=ht(`key`,t).length;return s===a||s===o}function d(t,r,i=!0){if(u(t)===!0)throw Error(`first arg must be private key`);if(u(r)===!1)throw Error(`second arg must be public key`);let a=Ga(n,t);return e.fromHex(r).multiply(a).toBytes(i)}return Object.freeze({getPublicKey:c,getSharedSecret:d,keygen:l,Point:e,utils:{isValidSecretKey:a,isValidPublicKey:o,randomSecretKey:s,isValidPrivateKey:a,randomPrivateKey:s,normPrivateKeyToScalar:e=>Ga(n,e),precompute(t=8,n=e.BASE){return n.precompute(t,!1)}},lengths:i})}function Xa(e,t,n={}){ne(t),wt(n,{},{hmac:`function`,lowS:`boolean`,randomBytes:`function`,bits2int:`function`,bits2int_modN:`function`});let r=n.randomBytes||ve,i=n.hmac||((e,...n)=>tt(t,e,F(...n))),{Fp:a,Fn:o}=e,{ORDER:s,BITS:c}=o,{keygen:l,getPublicKey:u,getSharedSecret:d,utils:f,lengths:p}=Ya(e,n),m={prehash:!1,lowS:typeof n.lowS==`boolean`?n.lowS:!1,format:void 0,extraEntropy:!1},h=`compact`;function g(e){return e>s>>Va}function _(e,t){if(!o.isValidNot0(t))throw Error(`invalid signature ${e}: out of range 1..Point.Fn.ORDER`);return t}function v(e,t){La(t);let n=p.signature;return ct(e,t===`compact`?n:t===`recovered`?n+1:void 0,`${t} signature`)}class y{constructor(e,t,n){this.r=_(`r`,e),this.s=_(`s`,t),n!=null&&(this.recovery=n),Object.freeze(this)}static fromBytes(e,t=h){v(e,t);let n;if(t===`der`){let{r:t,s:n}=za.toSig(ct(e));return new y(t,n)}t===`recovered`&&(n=e[0],t=`compact`,e=e.subarray(1));let r=o.BYTES,i=e.subarray(0,r),a=e.subarray(r,r*2);return new y(o.fromBytes(i),o.fromBytes(a),n)}static fromHex(e,t){return this.fromBytes(me(e),t)}addRecoveryBit(e){return new y(this.r,this.s,e)}recoverPublicKey(t){let n=a.ORDER,{r,s:i,recovery:c}=this;if(c==null||![0,1,2,3].includes(c))throw Error(`recovery id invalid`);if(s*Ha<n&&c>1)throw Error(`recovery id is ambiguous for h>1 curve`);let l=c===2||c===3?r+s:r;if(!a.isValid(l))throw Error(`recovery id 2 or 3 invalid`);let u=a.toBytes(l),d=e.fromBytes(F(qa((c&1)==0),u)),f=o.inv(l),p=x(ht(`msgHash`,t)),m=o.create(-p*f),h=o.create(i*f),g=e.BASE.multiplyUnsafe(m).add(d.multiplyUnsafe(h));if(g.is0())throw Error(`point at infinify`);return g.assertValidity(),g}hasHighS(){return g(this.s)}toBytes(e=h){if(La(e),e===`der`)return me(za.hexFromSig(this));let t=o.toBytes(this.r),n=o.toBytes(this.s);if(e===`recovered`){if(this.recovery==null)throw Error(`recovery bit must be present`);return F(Uint8Array.of(this.recovery),t,n)}return F(t,n)}toHex(e){return N(this.toBytes(e))}assertValidity(){}static fromCompact(e){return y.fromBytes(ht(`sig`,e),`compact`)}static fromDER(e){return y.fromBytes(ht(`sig`,e),`der`)}normalizeS(){return this.hasHighS()?new y(this.r,o.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes(`der`)}toDERHex(){return N(this.toBytes(`der`))}toCompactRawBytes(){return this.toBytes(`compact`)}toCompactHex(){return N(this.toBytes(`compact`))}}let b=n.bits2int||function(e){if(e.length>8192)throw Error(`input is too large`);let t=dt(e),n=e.length*8-c;return n>0?t>>BigInt(n):t},x=n.bits2int_modN||function(e){return o.create(b(e))},ee=St(c);function S(e){return bt(`num < 2^`+c,e,Ba,ee),o.toBytes(e)}function C(e,n){return ct(e,void 0,`message`),n?ct(t(e),void 0,`prehashed message`):e}function w(t,n,i){if([`recovered`,`canonical`].some(e=>e in i))throw Error(`sign() legacy options not supported`);let{lowS:a,prehash:s,extraEntropy:c}=Ra(i,m);t=C(t,s);let l=x(t),u=Ga(o,n),d=[S(u),S(l)];if(c!=null&&c!==!1){let e=c===!0?r(p.secretKey):c;d.push(ht(`extraEntropy`,e))}let f=F(...d),h=l;function _(t){let n=b(t);if(!o.isValidNot0(n))return;let r=o.inv(n),i=e.BASE.multiply(n).toAffine(),s=o.create(i.x);if(s===Ba)return;let c=o.create(r*o.create(h+s*u));if(c===Ba)return;let l=(i.x===s?0:2)|Number(i.y&Va),d=c;return a&&g(c)&&(d=o.neg(c),l^=1),new y(s,d,l)}return{seed:f,k2sig:_}}function T(e,n,r={}){e=ht(`message`,e);let{seed:a,k2sig:s}=w(e,n,r);return Ct(t.outputLen,o.BYTES,i)(a,s)}function E(e){let t,n=typeof e==`string`||O(e),r=!n&&typeof e==`object`&&!!e&&typeof e.r==`bigint`&&typeof e.s==`bigint`;if(!n&&!r)throw Error(`invalid signature, expected Uint8Array, hex string or Signature instance`);if(r)t=new y(e.r,e.s);else if(n){try{t=y.fromBytes(ht(`sig`,e),`der`)}catch(e){if(!(e instanceof za.Err))throw e}if(!t)try{t=y.fromBytes(ht(`sig`,e),`compact`)}catch{return!1}}return t||!1}function D(t,n,r,i={}){let{lowS:a,prehash:s,format:c}=Ra(i,m);if(r=ht(`publicKey`,r),n=C(ht(`message`,n),s),`strict`in i)throw Error(`options.strict was renamed to lowS`);let l=c===void 0?E(t):y.fromBytes(ht(`sig`,t),c);if(l===!1)return!1;try{let t=e.fromBytes(r);if(a&&l.hasHighS())return!1;let{r:i,s}=l,c=x(n),u=o.inv(s),d=o.create(c*u),f=o.create(i*u),p=e.BASE.multiplyUnsafe(d).add(t.multiplyUnsafe(f));return p.is0()?!1:o.create(p.x)===i}catch{return!1}}function k(e,t,n={}){let{prehash:r}=Ra(n,m);return t=C(t,r),y.fromBytes(e,`recovered`).recoverPublicKey(t).toBytes()}return Object.freeze({keygen:l,getPublicKey:u,getSharedSecret:d,utils:f,lengths:p,Point:e,sign:T,verify:D,recoverPublicKey:k,Signature:y,hash:t})}function Za(e){let t={a:e.a,b:e.b,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},n=e.Fp,r=e.allowedPrivateKeyLengths?Array.from(new Set(e.allowedPrivateKeyLengths.map(e=>Math.ceil(e/2)))):void 0;return{CURVE:t,curveOpts:{Fp:n,Fn:$t(t.n,{BITS:e.nBitLength,allowedLengths:r,modFromBytes:e.wrapPrivateKey}),allowInfinityPoint:e.allowInfinityPoint,endo:e.endo,isTorsionFree:e.isTorsionFree,clearCofactor:e.clearCofactor,fromBytes:e.fromBytes,toBytes:e.toBytes}}}function Qa(e){let{CURVE:t,curveOpts:n}=Za(e),r={hmac:e.hmac,randomBytes:e.randomBytes,lowS:e.lowS,bits2int:e.bits2int,bits2int_modN:e.bits2int_modN};return{CURVE:t,curveOpts:n,hash:e.hash,ecdsaOpts:r}}function $a(e,t){let n=t.Point;return Object.assign({},t,{ProjectivePoint:n,CURVE:Object.assign({},e,Qt(n.Fn.ORDER,n.Fn.BITS))})}function eo(e){let{CURVE:t,curveOpts:n,hash:r,ecdsaOpts:i}=Qa(e);return $a(e,Xa(Ka(t,n),r,i))}function to(e,t){let n=t=>eo({...e,hash:t});return{...n(t),create:n}}var no={p:BigInt(`0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f`),n:BigInt(`0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141`),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt(`0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798`),Gy:BigInt(`0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8`)},ro={beta:BigInt(`0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee`),basises:[[BigInt(`0x3086d221a7d46bcde86c90e49284eb15`),-BigInt(`0xe4437ed6010e88286f547fa90abfe4c3`)],[BigInt(`0x114ca50f7a8e2f3f657c1108d9d44cfd8`),BigInt(`0x3086d221a7d46bcde86c90e49284eb15`)]]},io=BigInt(2);function ao(e){let t=no.p,n=BigInt(3),r=BigInt(6),i=BigInt(11),a=BigInt(22),o=BigInt(23),s=BigInt(44),c=BigInt(88),l=e*e*e%t,u=l*l*e%t,d=Rt(Rt(Rt(u,n,t)*u%t,n,t)*u%t,io,t)*l%t,f=Rt(d,i,t)*d%t,p=Rt(f,a,t)*f%t,m=Rt(p,s,t)*p%t,h=Rt(Rt(Rt(Rt(Rt(Rt(m,c,t)*m%t,s,t)*p%t,n,t)*u%t,o,t)*f%t,r,t)*l%t,io,t);if(!oo.eql(oo.sqr(h),e))throw Error(`Cannot find square root`);return h}var oo=$t(no.p,{sqrt:ao}),so=to({...no,Fp:oo,lowS:!0,endo:ro},Ze),co=r({Account:()=>So,AddressLookupTableAccount:()=>Is,AddressLookupTableInstruction:()=>Pl,AddressLookupTableProgram:()=>Fl,Authorized:()=>$l,BLOCKHASH_CACHE_TIMEOUT_MS:()=>Us,BPF_LOADER_DEPRECATED_PROGRAM_ID:()=>Co,BPF_LOADER_PROGRAM_ID:()=>xs,BpfLoader:()=>Ss,COMPUTE_BUDGET_INSTRUCTION_LAYOUTS:()=>Ll,ComputeBudgetInstruction:()=>Il,ComputeBudgetProgram:()=>Rl,Connection:()=>jl,Ed25519Program:()=>Ul,Enum:()=>_o,EpochSchedule:()=>js,FeeCalculatorLayout:()=>ds,Keypair:()=>Ml,LAMPORTS_PER_SOL:()=>Su,LOOKUP_TABLE_INSTRUCTION_LAYOUTS:()=>Nl,Loader:()=>bs,Lockup:()=>eu,MAX_SEED_LENGTH:()=>32,Message:()=>Uo,MessageAccountKeys:()=>ko,MessageV0:()=>Wo,NONCE_ACCOUNT_LENGTH:()=>ps,NonceAccount:()=>ms,PACKET_DATA_SIZE:()=>wo,PUBLIC_KEY_LENGTH:()=>32,PublicKey:()=>K,SIGNATURE_LENGTH_IN_BYTES:()=>64,SOLANA_SCHEMA:()=>vo,STAKE_CONFIG_ID:()=>Ql,STAKE_INSTRUCTION_LAYOUTS:()=>nu,SYSTEM_INSTRUCTION_LAYOUTS:()=>_s,SYSVAR_CLOCK_PUBKEY:()=>Qo,SYSVAR_EPOCH_SCHEDULE_PUBKEY:()=>$o,SYSVAR_INSTRUCTIONS_PUBKEY:()=>es,SYSVAR_RECENT_BLOCKHASHES_PUBKEY:()=>ts,SYSVAR_RENT_PUBKEY:()=>ns,SYSVAR_REWARDS_PUBKEY:()=>rs,SYSVAR_SLOT_HASHES_PUBKEY:()=>is,SYSVAR_SLOT_HISTORY_PUBKEY:()=>as,SYSVAR_STAKE_HISTORY_PUBKEY:()=>os,Secp256k1Program:()=>Xl,SendTransactionError:()=>ss,SolanaJSONRPCError:()=>X,SolanaJSONRPCErrorCode:()=>cs,StakeAuthorizationLayout:()=>ru,StakeInstruction:()=>tu,StakeProgram:()=>iu,Struct:()=>go,SystemInstruction:()=>gs,SystemProgram:()=>vs,Transaction:()=>Y,TransactionExpiredBlockheightExceededError:()=>Eo,TransactionExpiredNonceInvalidError:()=>Oo,TransactionExpiredTimeoutError:()=>Do,TransactionInstruction:()=>Jo,TransactionMessage:()=>Yo,TransactionStatus:()=>Ko,VALIDATOR_INFO_KEY:()=>uu,VERSION_PREFIX_MASK:()=>127,VOTE_PROGRAM_ID:()=>pu,ValidatorInfo:()=>fu,VersionedMessage:()=>Go,VersionedTransaction:()=>Xo,VoteAccount:()=>hu,VoteAuthorizationLayout:()=>cu,VoteInit:()=>au,VoteInstruction:()=>ou,VoteProgram:()=>lu,clusterApiUrl:()=>bu,sendAndConfirmRawTransaction:()=>xu,sendAndConfirmTransaction:()=>ls}),lo=Kn.utils.randomPrivateKey,uo=()=>{let e=Kn.utils.randomPrivateKey(),t=fo(e),n=new Uint8Array(64);return n.set(e),n.set(t,32),{publicKey:t,secretKey:n}},fo=Kn.getPublicKey;function po(e){try{return Kn.ExtendedPoint.fromHex(e),!0}catch{return!1}}var mo=(e,t)=>Kn.sign(e,t.slice(0,32)),ho=Kn.verify,G=e=>I.Buffer.isBuffer(e)?e:e instanceof Uint8Array?I.Buffer.from(e.buffer,e.byteOffset,e.byteLength):I.Buffer.from(e),go=class{constructor(e){Object.assign(this,e)}encode(){return I.Buffer.from((0,jr.serialize)(vo,this))}static decode(e){return(0,jr.deserialize)(vo,this,e)}static decodeUnchecked(e){return(0,jr.deserializeUnchecked)(vo,this,e)}},_o=class extends go{constructor(e){if(super(e),this.enum=``,Object.keys(e).length!==1)throw Error(`Enum can only take single value`);Object.keys(e).map(e=>{this.enum=e})}},vo=new Map,yo;function bo(e){return e._bn!==void 0}var xo=1,K=class e extends go{constructor(e){if(super({}),this._bn=void 0,bo(e))this._bn=e._bn;else{if(typeof e==`string`){let t=Ar.default.decode(e);if(t.length!=32)throw Error(`Invalid public key input`);this._bn=new kr.default(t)}else this._bn=new kr.default(e);if(this._bn.byteLength()>32)throw Error(`Invalid public key input`)}}static unique(){let t=new e(xo);return xo+=1,new e(t.toBuffer())}equals(e){return this._bn.eq(e._bn)}toBase58(){return Ar.default.encode(this.toBytes())}toJSON(){return this.toBase58()}toBytes(){let e=this.toBuffer();return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}toBuffer(){let e=this._bn.toArrayLike(I.Buffer);if(e.length===32)return e;let t=I.Buffer.alloc(32);return e.copy(t,32-e.length),t}get[Symbol.toStringTag](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(t,n,r){return new e($e(I.Buffer.concat([t.toBuffer(),I.Buffer.from(n),r.toBuffer()])))}static createProgramAddressSync(t,n){let r=I.Buffer.alloc(0);t.forEach(function(e){if(e.length>32)throw TypeError(`Max seed length exceeded`);r=I.Buffer.concat([r,G(e)])}),r=I.Buffer.concat([r,n.toBuffer(),I.Buffer.from(`ProgramDerivedAddress`)]);let i=$e(r);if(po(i))throw Error(`Invalid seeds, address must fall off the curve`);return new e(i)}static async createProgramAddress(e,t){return this.createProgramAddressSync(e,t)}static findProgramAddressSync(e,t){let n=255,r;for(;n!=0;){try{let i=e.concat(I.Buffer.from([n]));r=this.createProgramAddressSync(i,t)}catch(e){if(e instanceof TypeError)throw e;n--;continue}return[r,n]}throw Error(`Unable to find a viable program address nonce`)}static async findProgramAddress(e,t){return this.findProgramAddressSync(e,t)}static isOnCurve(t){return po(new e(t).toBytes())}};yo=K,K.default=new yo(`11111111111111111111111111111111`),vo.set(K,{kind:`struct`,fields:[[`_bn`,`u256`]]});var So=class{constructor(e){if(this._publicKey=void 0,this._secretKey=void 0,e){let t=G(e);if(e.length!==64)throw Error(`bad secret key size`);this._publicKey=t.slice(32,64),this._secretKey=t.slice(0,32)}else this._secretKey=G(lo()),this._publicKey=G(fo(this._secretKey))}get publicKey(){return new K(this._publicKey)}get secretKey(){return I.Buffer.concat([this._secretKey,this._publicKey],64)}},Co=new K(`BPFLoader1111111111111111111111111111111111`),wo=1232,To=64,Eo=class extends Error{constructor(e){super(`Signature ${e} has expired: block height exceeded.`),this.signature=void 0,this.signature=e}};Object.defineProperty(Eo.prototype,"name",{value:`TransactionExpiredBlockheightExceededError`});var Do=class extends Error{constructor(e,t){super(`Transaction was not confirmed in ${t.toFixed(2)} seconds. It is unknown if it succeeded or failed. Check signature ${e} using the Solana Explorer or CLI tools.`),this.signature=void 0,this.signature=e}};Object.defineProperty(Do.prototype,"name",{value:`TransactionExpiredTimeoutError`});var Oo=class extends Error{constructor(e){super(`Signature ${e} has expired: the nonce is no longer valid.`),this.signature=void 0,this.signature=e}};Object.defineProperty(Oo.prototype,"name",{value:`TransactionExpiredNonceInvalidError`});var ko=class{constructor(e,t){this.staticAccountKeys=void 0,this.accountKeysFromLookups=void 0,this.staticAccountKeys=e,this.accountKeysFromLookups=t}keySegments(){let e=[this.staticAccountKeys];return this.accountKeysFromLookups&&(e.push(this.accountKeysFromLookups.writable),e.push(this.accountKeysFromLookups.readonly)),e}get(e){for(let t of this.keySegments())if(e<t.length)return t[e];else e-=t.length}get length(){return this.keySegments().flat().length}compileInstructions(e){if(this.length>256)throw Error(`Account index overflow encountered during compilation`);let t=new Map;this.keySegments().flat().forEach((e,n)=>{t.set(e.toBase58(),n)});let n=e=>{let n=t.get(e.toBase58());if(n===void 0)throw Error(`Encountered an unknown instruction account key during compilation`);return n};return e.map(e=>({programIdIndex:n(e.programId),accountKeyIndexes:e.keys.map(e=>n(e.pubkey)),data:e.data}))}},q=(e=`publicKey`)=>L.blob(32,e),Ao=(e=`signature`)=>L.blob(64,e),jo=(e=`string`)=>{let t=L.struct([L.u32(`length`),L.u32(`lengthPadding`),L.blob(L.offset(L.u32(),-8),`chars`)],e),n=t.decode.bind(t),r=t.encode.bind(t),i=t;return i.decode=(e,t)=>n(e,t).chars.toString(),i.encode=(e,t,n)=>r({chars:I.Buffer.from(e,`utf8`)},t,n),i.alloc=e=>L.u32().span+L.u32().span+I.Buffer.from(e,`utf8`).length,i},Mo=(e=`authorized`)=>L.struct([q(`staker`),q(`withdrawer`)],e),No=(e=`lockup`)=>L.struct([L.ns64(`unixTimestamp`),L.ns64(`epoch`),q(`custodian`)],e),Po=(e=`voteInit`)=>L.struct([q(`nodePubkey`),q(`authorizedVoter`),q(`authorizedWithdrawer`),L.u8(`commission`)],e),Fo=(e=`voteAuthorizeWithSeedArgs`)=>L.struct([L.u32(`voteAuthorizationType`),q(`currentAuthorityDerivedKeyOwnerPubkey`),jo(`currentAuthorityDerivedKeySeed`),q(`newAuthorized`)],e);function Io(e,t){let n=e=>{if(e.span>=0)return e.span;if(typeof e.alloc==`function`)return e.alloc(t[e.property]);if(`count`in e&&`elementLayout`in e){let r=t[e.property];if(Array.isArray(r))return r.length*n(e.elementLayout)}else if(`fields`in e)return Io({layout:e},t[e.property]);return 0},r=0;return e.layout.fields.forEach(e=>{r+=n(e)}),r}function Lo(e){let t=0,n=0;for(;;){let r=e.shift();if(t|=(r&127)<<n*7,n+=1,!(r&128))break}return t}function Ro(e,t){let n=t;for(;;){let t=n&127;if(n>>=7,n==0){e.push(t);break}else t|=128,e.push(t)}}function J(e,t){if(!e)throw Error(t||`Assertion failed`)}var zo=class e{constructor(e,t){this.payer=void 0,this.keyMetaMap=void 0,this.payer=e,this.keyMetaMap=t}static compile(t,n){let r=new Map,i=e=>{let t=e.toBase58(),n=r.get(t);return n===void 0&&(n={isSigner:!1,isWritable:!1,isInvoked:!1},r.set(t,n)),n},a=i(n);a.isSigner=!0,a.isWritable=!0;for(let e of t){i(e.programId).isInvoked=!0;for(let t of e.keys){let e=i(t.pubkey);e.isSigner||=t.isSigner,e.isWritable||=t.isWritable}}return new e(n,r)}getMessageComponents(){let e=[...this.keyMetaMap.entries()];J(e.length<=256,`Max static account keys length exceeded`);let t=e.filter(([,e])=>e.isSigner&&e.isWritable),n=e.filter(([,e])=>e.isSigner&&!e.isWritable),r=e.filter(([,e])=>!e.isSigner&&e.isWritable),i=e.filter(([,e])=>!e.isSigner&&!e.isWritable),a={numRequiredSignatures:t.length+n.length,numReadonlySignedAccounts:n.length,numReadonlyUnsignedAccounts:i.length};{J(t.length>0,`Expected at least one writable signer key`);let[e]=t[0];J(e===this.payer.toBase58(),`Expected first writable signer key to be the fee payer`)}return[a,[...t.map(([e])=>new K(e)),...n.map(([e])=>new K(e)),...r.map(([e])=>new K(e)),...i.map(([e])=>new K(e))]]}extractTableLookup(e){let[t,n]=this.drainKeysFoundInLookupTable(e.state.addresses,e=>!e.isSigner&&!e.isInvoked&&e.isWritable),[r,i]=this.drainKeysFoundInLookupTable(e.state.addresses,e=>!e.isSigner&&!e.isInvoked&&!e.isWritable);if(!(t.length===0&&r.length===0))return[{accountKey:e.key,writableIndexes:t,readonlyIndexes:r},{writable:n,readonly:i}]}drainKeysFoundInLookupTable(e,t){let n=[],r=[];for(let[i,a]of this.keyMetaMap.entries())if(t(a)){let t=new K(i),a=e.findIndex(e=>e.equals(t));a>=0&&(J(a<256,`Max lookup table index exceeded`),n.push(a),r.push(t),this.keyMetaMap.delete(i))}return[n,r]}},Bo=`Reached end of buffer unexpectedly`;function Vo(e){if(e.length===0)throw Error(Bo);return e.shift()}function Ho(e,...t){let[n]=t;if(t.length===2?n+(t[1]??0)>e.length:n>=e.length)throw Error(Bo);return e.splice(...t)}var Uo=class e{constructor(e){this.header=void 0,this.accountKeys=void 0,this.recentBlockhash=void 0,this.instructions=void 0,this.indexToProgramIds=new Map,this.header=e.header,this.accountKeys=e.accountKeys.map(e=>new K(e)),this.recentBlockhash=e.recentBlockhash,this.instructions=e.instructions,this.instructions.forEach(e=>this.indexToProgramIds.set(e.programIdIndex,this.accountKeys[e.programIdIndex]))}get version(){return`legacy`}get staticAccountKeys(){return this.accountKeys}get compiledInstructions(){return this.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:Ar.default.decode(e.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new ko(this.staticAccountKeys)}static compile(t){let[n,r]=zo.compile(t.instructions,t.payerKey).getMessageComponents(),i=new ko(r).compileInstructions(t.instructions).map(e=>({programIdIndex:e.programIdIndex,accounts:e.accountKeyIndexes,data:Ar.default.encode(e.data)}));return new e({header:n,accountKeys:r,recentBlockhash:t.recentBlockhash,instructions:i})}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){let t=this.header.numRequiredSignatures;return e>=this.header.numRequiredSignatures?e-t<this.accountKeys.length-t-this.header.numReadonlyUnsignedAccounts:e<t-this.header.numReadonlySignedAccounts}isProgramId(e){return this.indexToProgramIds.has(e)}programIds(){return[...this.indexToProgramIds.values()]}nonProgramIds(){return this.accountKeys.filter((e,t)=>!this.isProgramId(t))}serialize(){let e=this.accountKeys.length,t=[];Ro(t,e);let n=this.instructions.map(e=>{let{accounts:t,programIdIndex:n}=e,r=Array.from(Ar.default.decode(e.data)),i=[];Ro(i,t.length);let a=[];return Ro(a,r.length),{programIdIndex:n,keyIndicesCount:I.Buffer.from(i),keyIndices:t,dataLength:I.Buffer.from(a),data:r}}),r=[];Ro(r,n.length);let i=I.Buffer.alloc(wo);I.Buffer.from(r).copy(i);let a=r.length;n.forEach(e=>{let t=L.struct([L.u8(`programIdIndex`),L.blob(e.keyIndicesCount.length,`keyIndicesCount`),L.seq(L.u8(`keyIndex`),e.keyIndices.length,`keyIndices`),L.blob(e.dataLength.length,`dataLength`),L.seq(L.u8(`userdatum`),e.data.length,`data`)]).encode(e,i,a);a+=t}),i=i.slice(0,a);let o=L.struct([L.blob(1,`numRequiredSignatures`),L.blob(1,`numReadonlySignedAccounts`),L.blob(1,`numReadonlyUnsignedAccounts`),L.blob(t.length,`keyCount`),L.seq(q(`key`),e,`keys`),q(`recentBlockhash`)]),s={numRequiredSignatures:I.Buffer.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:I.Buffer.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:I.Buffer.from([this.header.numReadonlyUnsignedAccounts]),keyCount:I.Buffer.from(t),keys:this.accountKeys.map(e=>G(e.toBytes())),recentBlockhash:Ar.default.decode(this.recentBlockhash)},c=I.Buffer.alloc(2048),l=o.encode(s,c);return i.copy(c,l),c.slice(0,l+i.length)}static from(t){let n=[...t],r=Vo(n);if(r!==(r&127))throw Error(`Versioned messages must be deserialized with VersionedMessage.deserialize()`);let i=Vo(n),a=Vo(n),o=Lo(n),s=[];for(let e=0;e<o;e++){let e=Ho(n,0,32);s.push(new K(I.Buffer.from(e)))}let c=Ho(n,0,32),l=Lo(n),u=[];for(let e=0;e<l;e++){let e=Vo(n),t=Ho(n,0,Lo(n)),r=Ho(n,0,Lo(n)),i=Ar.default.encode(I.Buffer.from(r));u.push({programIdIndex:e,accounts:t,data:i})}return new e({header:{numRequiredSignatures:r,numReadonlySignedAccounts:i,numReadonlyUnsignedAccounts:a},recentBlockhash:Ar.default.encode(I.Buffer.from(c)),accountKeys:s,instructions:u})}},Wo=class e{constructor(e){this.header=void 0,this.staticAccountKeys=void 0,this.recentBlockhash=void 0,this.compiledInstructions=void 0,this.addressTableLookups=void 0,this.header=e.header,this.staticAccountKeys=e.staticAccountKeys,this.recentBlockhash=e.recentBlockhash,this.compiledInstructions=e.compiledInstructions,this.addressTableLookups=e.addressTableLookups}get version(){return 0}get numAccountKeysFromLookups(){let e=0;for(let t of this.addressTableLookups)e+=t.readonlyIndexes.length+t.writableIndexes.length;return e}getAccountKeys(e){let t;if(e&&`accountKeysFromLookups`in e&&e.accountKeysFromLookups){if(this.numAccountKeysFromLookups!=e.accountKeysFromLookups.writable.length+e.accountKeysFromLookups.readonly.length)throw Error(`Failed to get account keys because of a mismatch in the number of account keys from lookups`);t=e.accountKeysFromLookups}else if(e&&`addressLookupTableAccounts`in e&&e.addressLookupTableAccounts)t=this.resolveAddressTableLookups(e.addressLookupTableAccounts);else if(this.addressTableLookups.length>0)throw Error(`Failed to get account keys because address table lookups were not resolved`);return new ko(this.staticAccountKeys,t)}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){let t=this.header.numRequiredSignatures,n=this.staticAccountKeys.length;return e>=n?e-n<this.addressTableLookups.reduce((e,t)=>e+t.writableIndexes.length,0):e>=this.header.numRequiredSignatures?e-t<n-t-this.header.numReadonlyUnsignedAccounts:e<t-this.header.numReadonlySignedAccounts}resolveAddressTableLookups(e){let t={writable:[],readonly:[]};for(let n of this.addressTableLookups){let r=e.find(e=>e.key.equals(n.accountKey));if(!r)throw Error(`Failed to find address lookup table account for table key ${n.accountKey.toBase58()}`);for(let e of n.writableIndexes)if(e<r.state.addresses.length)t.writable.push(r.state.addresses[e]);else throw Error(`Failed to find address for index ${e} in address lookup table ${n.accountKey.toBase58()}`);for(let e of n.readonlyIndexes)if(e<r.state.addresses.length)t.readonly.push(r.state.addresses[e]);else throw Error(`Failed to find address for index ${e} in address lookup table ${n.accountKey.toBase58()}`)}return t}static compile(t){let n=zo.compile(t.instructions,t.payerKey),r=[],i={writable:[],readonly:[]},a=t.addressLookupTableAccounts||[];for(let e of a){let t=n.extractTableLookup(e);if(t!==void 0){let[e,{writable:n,readonly:a}]=t;r.push(e),i.writable.push(...n),i.readonly.push(...a)}}let[o,s]=n.getMessageComponents(),c=new ko(s,i).compileInstructions(t.instructions);return new e({header:o,staticAccountKeys:s,recentBlockhash:t.recentBlockhash,compiledInstructions:c,addressTableLookups:r})}serialize(){let e=[];Ro(e,this.staticAccountKeys.length);let t=this.serializeInstructions(),n=[];Ro(n,this.compiledInstructions.length);let r=this.serializeAddressTableLookups(),i=[];Ro(i,this.addressTableLookups.length);let a=L.struct([L.u8(`prefix`),L.struct([L.u8(`numRequiredSignatures`),L.u8(`numReadonlySignedAccounts`),L.u8(`numReadonlyUnsignedAccounts`)],`header`),L.blob(e.length,`staticAccountKeysLength`),L.seq(q(),this.staticAccountKeys.length,`staticAccountKeys`),q(`recentBlockhash`),L.blob(n.length,`instructionsLength`),L.blob(t.length,`serializedInstructions`),L.blob(i.length,`addressTableLookupsLength`),L.blob(r.length,`serializedAddressTableLookups`)]),o=new Uint8Array(wo),s=a.encode({prefix:128,header:this.header,staticAccountKeysLength:new Uint8Array(e),staticAccountKeys:this.staticAccountKeys.map(e=>e.toBytes()),recentBlockhash:Ar.default.decode(this.recentBlockhash),instructionsLength:new Uint8Array(n),serializedInstructions:t,addressTableLookupsLength:new Uint8Array(i),serializedAddressTableLookups:r},o);return o.slice(0,s)}serializeInstructions(){let e=0,t=new Uint8Array(wo);for(let n of this.compiledInstructions){let r=[];Ro(r,n.accountKeyIndexes.length);let i=[];Ro(i,n.data.length);let a=L.struct([L.u8(`programIdIndex`),L.blob(r.length,`encodedAccountKeyIndexesLength`),L.seq(L.u8(),n.accountKeyIndexes.length,`accountKeyIndexes`),L.blob(i.length,`encodedDataLength`),L.blob(n.data.length,`data`)]);e+=a.encode({programIdIndex:n.programIdIndex,encodedAccountKeyIndexesLength:new Uint8Array(r),accountKeyIndexes:n.accountKeyIndexes,encodedDataLength:new Uint8Array(i),data:n.data},t,e)}return t.slice(0,e)}serializeAddressTableLookups(){let e=0,t=new Uint8Array(wo);for(let n of this.addressTableLookups){let r=[];Ro(r,n.writableIndexes.length);let i=[];Ro(i,n.readonlyIndexes.length);let a=L.struct([q(`accountKey`),L.blob(r.length,`encodedWritableIndexesLength`),L.seq(L.u8(),n.writableIndexes.length,`writableIndexes`),L.blob(i.length,`encodedReadonlyIndexesLength`),L.seq(L.u8(),n.readonlyIndexes.length,`readonlyIndexes`)]);e+=a.encode({accountKey:n.accountKey.toBytes(),encodedWritableIndexesLength:new Uint8Array(r),writableIndexes:n.writableIndexes,encodedReadonlyIndexesLength:new Uint8Array(i),readonlyIndexes:n.readonlyIndexes},t,e)}return t.slice(0,e)}static deserialize(t){let n=[...t],r=Vo(n),i=r&127;J(r!==i,`Expected versioned message but received legacy message`);let a=i;J(a===0,`Expected versioned message with version 0 but found version ${a}`);let o={numRequiredSignatures:Vo(n),numReadonlySignedAccounts:Vo(n),numReadonlyUnsignedAccounts:Vo(n)},s=[],c=Lo(n);for(let e=0;e<c;e++)s.push(new K(Ho(n,0,32)));let l=Ar.default.encode(Ho(n,0,32)),u=Lo(n),d=[];for(let e=0;e<u;e++){let e=Vo(n),t=Ho(n,0,Lo(n)),r=Lo(n),i=new Uint8Array(Ho(n,0,r));d.push({programIdIndex:e,accountKeyIndexes:t,data:i})}let f=Lo(n),p=[];for(let e=0;e<f;e++){let e=new K(Ho(n,0,32)),t=Ho(n,0,Lo(n)),r=Ho(n,0,Lo(n));p.push({accountKey:e,writableIndexes:t,readonlyIndexes:r})}return new e({header:o,staticAccountKeys:s,recentBlockhash:l,compiledInstructions:d,addressTableLookups:p})}},Go={deserializeMessageVersion(e){let t=e[0],n=t&127;return n===t?`legacy`:n},deserialize:e=>{let t=Go.deserializeMessageVersion(e);if(t===`legacy`)return Uo.from(e);if(t===0)return Wo.deserialize(e);throw Error(`Transaction message version ${t} deserialization is not supported`)}},Ko=function(e){return e[e.BLOCKHEIGHT_EXCEEDED=0]=`BLOCKHEIGHT_EXCEEDED`,e[e.PROCESSED=1]=`PROCESSED`,e[e.TIMED_OUT=2]=`TIMED_OUT`,e[e.NONCE_INVALID=3]=`NONCE_INVALID`,e}({}),qo=I.Buffer.alloc(64).fill(0),Jo=class{constructor(e){this.keys=void 0,this.programId=void 0,this.data=I.Buffer.alloc(0),this.programId=e.programId,this.keys=e.keys,e.data&&(this.data=e.data)}toJSON(){return{keys:this.keys.map(({pubkey:e,isSigner:t,isWritable:n})=>({pubkey:e.toJSON(),isSigner:t,isWritable:n})),programId:this.programId.toJSON(),data:[...this.data]}}},Y=class e{get signature(){return this.signatures.length>0?this.signatures[0].signature:null}constructor(e){if(this.signatures=[],this.feePayer=void 0,this.instructions=[],this.recentBlockhash=void 0,this.lastValidBlockHeight=void 0,this.nonceInfo=void 0,this.minNonceContextSlot=void 0,this._message=void 0,this._json=void 0,e)if(e.feePayer&&(this.feePayer=e.feePayer),e.signatures&&(this.signatures=e.signatures),Object.prototype.hasOwnProperty.call(e,`nonceInfo`)){let{minContextSlot:t,nonceInfo:n}=e;this.minNonceContextSlot=t,this.nonceInfo=n}else if(Object.prototype.hasOwnProperty.call(e,`lastValidBlockHeight`)){let{blockhash:t,lastValidBlockHeight:n}=e;this.recentBlockhash=t,this.lastValidBlockHeight=n}else{let{recentBlockhash:t,nonceInfo:n}=e;n&&(this.nonceInfo=n),this.recentBlockhash=t}}toJSON(){return{recentBlockhash:this.recentBlockhash||null,feePayer:this.feePayer?this.feePayer.toJSON():null,nonceInfo:this.nonceInfo?{nonce:this.nonceInfo.nonce,nonceInstruction:this.nonceInfo.nonceInstruction.toJSON()}:null,instructions:this.instructions.map(e=>e.toJSON()),signers:this.signatures.map(({publicKey:e})=>e.toJSON())}}add(...e){if(e.length===0)throw Error(`No instructions`);return e.forEach(e=>{`instructions`in e?this.instructions=this.instructions.concat(e.instructions):`data`in e&&`programId`in e&&`keys`in e?this.instructions.push(e):this.instructions.push(new Jo(e))}),this}compileMessage(){if(this._message&&JSON.stringify(this.toJSON())===JSON.stringify(this._json))return this._message;let e,t;if(this.nonceInfo?(e=this.nonceInfo.nonce,t=this.instructions[0]==this.nonceInfo.nonceInstruction?this.instructions:[this.nonceInfo.nonceInstruction,...this.instructions]):(e=this.recentBlockhash,t=this.instructions),!e)throw Error(`Transaction recentBlockhash required`);t.length<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 Error(`Transaction fee payer required`);for(let e=0;e<t.length;e++)if(t[e].programId===void 0)throw Error(`Transaction instruction index ${e} has undefined program id`);let r=[],i=[];t.forEach(e=>{e.keys.forEach(e=>{i.push({...e})});let t=e.programId.toString();r.includes(t)||r.push(t)}),r.forEach(e=>{i.push({pubkey:new K(e),isSigner:!1,isWritable:!1})});let a=[];i.forEach(e=>{let t=e.pubkey.toString(),n=a.findIndex(e=>e.pubkey.toString()===t);n>-1?(a[n].isWritable=a[n].isWritable||e.isWritable,a[n].isSigner=a[n].isSigner||e.isSigner):a.push(e)}),a.sort(function(e,t){return e.isSigner===t.isSigner?e.isWritable===t.isWritable?e.pubkey.toBase58().localeCompare(t.pubkey.toBase58(),`en`,{localeMatcher:`best fit`,usage:`sort`,sensitivity:`variant`,ignorePunctuation:!1,numeric:!1,caseFirst:`lower`}):e.isWritable?-1:1:e.isSigner?-1:1});let o=a.findIndex(e=>e.pubkey.equals(n));if(o>-1){let[e]=a.splice(o,1);e.isSigner=!0,e.isWritable=!0,a.unshift(e)}else a.unshift({pubkey:n,isSigner:!0,isWritable:!0});for(let e of this.signatures){let t=a.findIndex(t=>t.pubkey.equals(e.publicKey));if(t>-1)a[t].isSigner||(a[t].isSigner=!0,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 Error(`unknown signer: ${e.publicKey.toString()}`)}let s=0,c=0,l=0,u=[],d=[];a.forEach(({pubkey:e,isSigner:t,isWritable:n})=>{t?(u.push(e.toString()),s+=1,n||(c+=1)):(d.push(e.toString()),n||(l+=1))});let f=u.concat(d),p=t.map(e=>{let{data:t,programId:n}=e;return{programIdIndex:f.indexOf(n.toString()),accounts:e.keys.map(e=>f.indexOf(e.pubkey.toString())),data:Ar.default.encode(t)}});return p.forEach(e=>{J(e.programIdIndex>=0),e.accounts.forEach(e=>J(e>=0))}),new Uo({header:{numRequiredSignatures:s,numReadonlySignedAccounts:c,numReadonlyUnsignedAccounts:l},accountKeys:f,recentBlockhash:e,instructions:p})}_compile(){let e=this.compileMessage(),t=e.accountKeys.slice(0,e.header.numRequiredSignatures);return this.signatures.length===t.length&&this.signatures.every((e,n)=>t[n].equals(e.publicKey))||(this.signatures=t.map(e=>({signature:null,publicKey:e}))),e}serializeMessage(){return this._compile().serialize()}async getEstimatedFee(e){return(await e.getFeeForMessage(this.compileMessage())).value}setSigners(...e){if(e.length===0)throw Error(`No signers`);let t=new Set;this.signatures=e.filter(e=>{let n=e.toString();return t.has(n)?!1:(t.add(n),!0)}).map(e=>({signature:null,publicKey:e}))}sign(...e){if(e.length===0)throw Error(`No signers`);let t=new Set,n=[];for(let r of e){let e=r.publicKey.toString();t.has(e)||(t.add(e),n.push(r))}this.signatures=n.map(e=>({signature:null,publicKey:e.publicKey}));let r=this._compile();this._partialSign(r,...n)}partialSign(...e){if(e.length===0)throw Error(`No signers`);let t=new Set,n=[];for(let r of e){let e=r.publicKey.toString();t.has(e)||(t.add(e),n.push(r))}let r=this._compile();this._partialSign(r,...n)}_partialSign(e,...t){let n=e.serialize();t.forEach(e=>{let t=mo(n,e.secretKey);this._addSignature(e.publicKey,G(t))})}addSignature(e,t){this._compile(),this._addSignature(e,t)}_addSignature(e,t){J(t.length===64);let n=this.signatures.findIndex(t=>e.equals(t.publicKey));if(n<0)throw Error(`unknown signer: ${e.toString()}`);this.signatures[n].signature=I.Buffer.from(t)}verifySignatures(e=!0){return!this._getMessageSignednessErrors(this.serializeMessage(),e)}_getMessageSignednessErrors(e,t){let n={};for(let{signature:r,publicKey:i}of this.signatures)r===null?t&&(n.missing||=[]).push(i):ho(r,e,i.toBytes())||(n.invalid||=[]).push(i);return n.invalid||n.missing?n:void 0}serialize(e){let{requireAllSignatures:t,verifySignatures:n}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},e),r=this.serializeMessage();if(n){let e=this._getMessageSignednessErrors(r,t);if(e){let t=`Signature verification failed.`;throw e.invalid&&(t+=`\nInvalid signature for public key${e.invalid.length===1?``:`(s)`} [\`${e.invalid.map(e=>e.toBase58()).join("`, `")}\`].`),e.missing&&(t+=`\nMissing signature for public key${e.missing.length===1?``:`(s)`} [\`${e.missing.map(e=>e.toBase58()).join("`, `")}\`].`),Error(t)}}return this._serialize(r)}_serialize(e){let{signatures:t}=this,n=[];Ro(n,t.length);let r=n.length+t.length*64+e.length,i=I.Buffer.alloc(r);return J(t.length<256),I.Buffer.from(n).copy(i,0),t.forEach(({signature:e},t)=>{e!==null&&(J(e.length===64,`signature has invalid length`),I.Buffer.from(e).copy(i,n.length+t*64))}),e.copy(i,n.length+t.length*64),J(i.length<=wo,`Transaction too large: ${i.length} > ${wo}`),i}get keys(){return J(this.instructions.length===1),this.instructions[0].keys.map(e=>e.pubkey)}get programId(){return J(this.instructions.length===1),this.instructions[0].programId}get data(){return J(this.instructions.length===1),this.instructions[0].data}static from(t){let n=[...t],r=Lo(n),i=[];for(let e=0;e<r;e++){let e=Ho(n,0,64);i.push(Ar.default.encode(I.Buffer.from(e)))}return e.populate(Uo.from(n),i)}static populate(t,n=[]){let r=new e;return r.recentBlockhash=t.recentBlockhash,t.header.numRequiredSignatures>0&&(r.feePayer=t.accountKeys[0]),n.forEach((e,n)=>{let i={signature:e==Ar.default.encode(qo)?null:Ar.default.decode(e),publicKey:t.accountKeys[n]};r.signatures.push(i)}),t.instructions.forEach(e=>{let n=e.accounts.map(e=>{let n=t.accountKeys[e];return{pubkey:n,isSigner:r.signatures.some(e=>e.publicKey.toString()===n.toString())||t.isAccountSigner(e),isWritable:t.isAccountWritable(e)}});r.instructions.push(new Jo({keys:n,programId:t.accountKeys[e.programIdIndex],data:Ar.default.decode(e.data)}))}),r._message=t,r._json=r.toJSON(),r}},Yo=class e{constructor(e){this.payerKey=void 0,this.instructions=void 0,this.recentBlockhash=void 0,this.payerKey=e.payerKey,this.instructions=e.instructions,this.recentBlockhash=e.recentBlockhash}static decompile(t,n){let{header:r,compiledInstructions:i,recentBlockhash:a}=t,{numRequiredSignatures:o,numReadonlySignedAccounts:s,numReadonlyUnsignedAccounts:c}=r,l=o-s;J(l>0,`Message header is invalid`);let u=t.staticAccountKeys.length-o-c;J(u>=0,`Message header is invalid`);let d=t.getAccountKeys(n),f=d.get(0);if(f===void 0)throw Error(`Failed to decompile message because no account keys were found`);let p=[];for(let e of i){let t=[];for(let n of e.accountKeyIndexes){let e=d.get(n);if(e===void 0)throw Error(`Failed to find key for account key index ${n}`);let i=n<o,a;a=i?n<l:n<d.staticAccountKeys.length?n-o<u:n-d.staticAccountKeys.length<d.accountKeysFromLookups.writable.length,t.push({pubkey:e,isSigner:n<r.numRequiredSignatures,isWritable:a})}let n=d.get(e.programIdIndex);if(n===void 0)throw Error(`Failed to find program id for program id index ${e.programIdIndex}`);p.push(new Jo({programId:n,data:G(e.data),keys:t}))}return new e({payerKey:f,instructions:p,recentBlockhash:a})}compileToLegacyMessage(){return Uo.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions})}compileToV0Message(e){return Wo.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions,addressLookupTableAccounts:e})}},Xo=class e{get version(){return this.message.version}constructor(e,t){if(this.signatures=void 0,this.message=void 0,t!==void 0)J(t.length===e.header.numRequiredSignatures,`Expected signatures length to be equal to the number of required signatures`),this.signatures=t;else{let t=[];for(let n=0;n<e.header.numRequiredSignatures;n++)t.push(new Uint8Array(64));this.signatures=t}this.message=e}serialize(){let e=this.message.serialize(),t=[];Ro(t,this.signatures.length);let n=L.struct([L.blob(t.length,`encodedSignaturesLength`),L.seq(Ao(),this.signatures.length,`signatures`),L.blob(e.length,`serializedMessage`)]),r=new Uint8Array(2048),i=n.encode({encodedSignaturesLength:new Uint8Array(t),signatures:this.signatures,serializedMessage:e},r);return r.slice(0,i)}static deserialize(t){let n=[...t],r=[],i=Lo(n);for(let e=0;e<i;e++)r.push(new Uint8Array(Ho(n,0,64)));return new e(Go.deserialize(new Uint8Array(n)),r)}sign(e){let t=this.message.serialize(),n=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures);for(let r of e){let e=n.findIndex(e=>e.equals(r.publicKey));J(e>=0,`Cannot sign with non signer key ${r.publicKey.toBase58()}`),this.signatures[e]=mo(t,r.secretKey)}}addSignature(e,t){J(t.byteLength===64,`Signature must be 64 bytes long`);let n=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures).findIndex(t=>t.equals(e));J(n>=0,`Can not add signature; \`${e.toBase58()}\` is not required to sign this transaction`),this.signatures[n]=t}},Zo=1e3/(160/64),Qo=new K(`SysvarC1ock11111111111111111111111111111111`),$o=new K(`SysvarEpochSchedu1e111111111111111111111111`),es=new K(`Sysvar1nstructions1111111111111111111111111`),ts=new K(`SysvarRecentB1ockHashes11111111111111111111`),ns=new K(`SysvarRent111111111111111111111111111111111`),rs=new K(`SysvarRewards111111111111111111111111111111`),is=new K(`SysvarS1otHashes111111111111111111111111111`),as=new K(`SysvarS1otHistory11111111111111111111111111`),os=new K(`SysvarStakeHistory1111111111111111111111111`),ss=class extends Error{constructor({action:e,signature:t,transactionMessage:n,logs:r}){let i=r?`Logs: \n${JSON.stringify(r.slice(-10),null,2)}. `:``,a="\nCatch the `SendTransactionError` and call `getLogs()` on it for full details.",o;switch(e){case`send`:o=`Transaction ${t} resulted in an error. \n${n}. `+i+a;break;case`simulate`:o=`Simulation failed. \nMessage: ${n}. \n`+i+a;break;default:o=`Unknown action '${(e=>e)(e)}'`}super(o),this.signature=void 0,this.transactionMessage=void 0,this.transactionLogs=void 0,this.signature=t,this.transactionMessage=n,this.transactionLogs=r||void 0}get transactionError(){return{message:this.transactionMessage,logs:Array.isArray(this.transactionLogs)?this.transactionLogs:void 0}}get logs(){let e=this.transactionLogs;if(!(typeof e==`object`&&e&&`then`in e))return e}async getLogs(e){return Array.isArray(this.transactionLogs)||(this.transactionLogs=new Promise((t,n)=>{e.getTransaction(this.signature).then(e=>{if(e&&e.meta&&e.meta.logMessages){let n=e.meta.logMessages;this.transactionLogs=n,t(n)}else n(Error(`Log messages not found`))}).catch(n)})),await this.transactionLogs}},cs={JSON_RPC_SERVER_ERROR_BLOCK_CLEANED_UP:-32001,JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE:-32002,JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE:-32003,JSON_RPC_SERVER_ERROR_BLOCK_NOT_AVAILABLE:-32004,JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY:-32005,JSON_RPC_SERVER_ERROR_TRANSACTION_PRECOMPILE_VERIFICATION_FAILURE:-32006,JSON_RPC_SERVER_ERROR_SLOT_SKIPPED:-32007,JSON_RPC_SERVER_ERROR_NO_SNAPSHOT:-32008,JSON_RPC_SERVER_ERROR_LONG_TERM_STORAGE_SLOT_SKIPPED:-32009,JSON_RPC_SERVER_ERROR_KEY_EXCLUDED_FROM_SECONDARY_INDEX:-32010,JSON_RPC_SERVER_ERROR_TRANSACTION_HISTORY_NOT_AVAILABLE:-32011,JSON_RPC_SCAN_ERROR:-32012,JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_LEN_MISMATCH:-32013,JSON_RPC_SERVER_ERROR_BLOCK_STATUS_NOT_AVAILABLE_YET:-32014,JSON_RPC_SERVER_ERROR_UNSUPPORTED_TRANSACTION_VERSION:-32015,JSON_RPC_SERVER_ERROR_MIN_CONTEXT_SLOT_NOT_REACHED:-32016},X=class extends Error{constructor({code:e,message:t,data:n},r){super(r==null?t:`${r}: ${t}`),this.code=void 0,this.data=void 0,this.code=e,this.data=n,this.name=`SolanaJSONRPCError`}};async function ls(e,t,n,r){let i=r&&{skipPreflight:r.skipPreflight,preflightCommitment:r.preflightCommitment||r.commitment,maxRetries:r.maxRetries,minContextSlot:r.minContextSlot},a=await e.sendTransaction(t,n,i),o;if(t.recentBlockhash!=null&&t.lastValidBlockHeight!=null)o=(await e.confirmTransaction({abortSignal:r?.abortSignal,signature:a,blockhash:t.recentBlockhash,lastValidBlockHeight:t.lastValidBlockHeight},r&&r.commitment)).value;else if(t.minNonceContextSlot!=null&&t.nonceInfo!=null){let{nonceInstruction:n}=t.nonceInfo,i=n.keys[0].pubkey;o=(await e.confirmTransaction({abortSignal:r?.abortSignal,minContextSlot:t.minNonceContextSlot,nonceAccountPubkey:i,nonceValue:t.nonceInfo.nonce,signature:a},r&&r.commitment)).value}else r?.abortSignal!=null&&console.warn("sendAndConfirmTransaction(): A transaction with a deprecated confirmation strategy was supplied along with an `abortSignal`. Only transactions having `lastValidBlockHeight` or a combination of `nonceInfo` and `minNonceContextSlot` are abortable."),o=(await e.confirmTransaction(a,r&&r.commitment)).value;if(o.err)throw a==null?Error(`Transaction ${a} failed (${JSON.stringify(o)})`):new ss({action:`send`,signature:a,transactionMessage:`Status: (${JSON.stringify(o)})`});return a}function us(e){return new Promise(t=>setTimeout(t,e))}function Z(e,t){let n=e.layout.span>=0?e.layout.span:Io(e,t),r=I.Buffer.alloc(n),i=Object.assign({instruction:e.index},t);return e.layout.encode(i,r),r}function Q(e,t){let n;try{n=e.layout.decode(t)}catch(e){throw Error(`invalid instruction; `+e)}if(n.instruction!==e.index)throw Error(`invalid instruction; instruction index mismatch ${n.instruction} != ${e.index}`);return n}var ds=L.nu64(`lamportsPerSignature`),fs=L.struct([L.u32(`version`),L.u32(`state`),q(`authorizedPubkey`),q(`nonce`),L.struct([ds],`feeCalculator`)]),ps=fs.span,ms=class e{constructor(e){this.authorizedPubkey=void 0,this.nonce=void 0,this.feeCalculator=void 0,this.authorizedPubkey=e.authorizedPubkey,this.nonce=e.nonce,this.feeCalculator=e.feeCalculator}static fromAccountData(t){let n=fs.decode(G(t),0);return new e({authorizedPubkey:new K(n.authorizedPubkey),nonce:new K(n.nonce).toString(),feeCalculator:n.feeCalculator})}};function hs(e){let t=(0,L.blob)(8,e),n=t.decode.bind(t),r=t.encode.bind(t),i=t,a=ri();return i.decode=(e,t)=>{let r=n(e,t);return a.decode(r)},i.encode=(e,t,n)=>r(a.encode(e),t,n),i}var gs=class{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);let t=L.u32(`instruction`).decode(e.data),n;for(let[e,r]of Object.entries(_s))if(r.index==t){n=e;break}if(!n)throw Error(`Instruction type incorrect; not a SystemInstruction`);return n}static decodeCreateAccount(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);let{lamports:t,space:n,programId:r}=Q(_s.Create,e.data);return{fromPubkey:e.keys[0].pubkey,newAccountPubkey:e.keys[1].pubkey,lamports:t,space:n,programId:new K(r)}}static decodeTransfer(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);let{lamports:t}=Q(_s.Transfer,e.data);return{fromPubkey:e.keys[0].pubkey,toPubkey:e.keys[1].pubkey,lamports:t}}static decodeTransferWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);let{lamports:t,seed:n,programId:r}=Q(_s.TransferWithSeed,e.data);return{fromPubkey:e.keys[0].pubkey,basePubkey:e.keys[1].pubkey,toPubkey:e.keys[2].pubkey,lamports:t,seed:n,programId:new K(r)}}static decodeAllocate(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);let{space:t}=Q(_s.Allocate,e.data);return{accountPubkey:e.keys[0].pubkey,space:t}}static decodeAllocateWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);let{base:t,seed:n,space:r,programId:i}=Q(_s.AllocateWithSeed,e.data);return{accountPubkey:e.keys[0].pubkey,basePubkey:new K(t),seed:n,space:r,programId:new K(i)}}static decodeAssign(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);let{programId:t}=Q(_s.Assign,e.data);return{accountPubkey:e.keys[0].pubkey,programId:new K(t)}}static decodeAssignWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);let{base:t,seed:n,programId:r}=Q(_s.AssignWithSeed,e.data);return{accountPubkey:e.keys[0].pubkey,basePubkey:new K(t),seed:n,programId:new K(r)}}static decodeCreateWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);let{base:t,seed:n,lamports:r,space:i,programId:a}=Q(_s.CreateWithSeed,e.data);return{fromPubkey:e.keys[0].pubkey,newAccountPubkey:e.keys[1].pubkey,basePubkey:new K(t),seed:n,lamports:r,space:i,programId:new K(a)}}static decodeNonceInitialize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);let{authorized:t}=Q(_s.InitializeNonceAccount,e.data);return{noncePubkey:e.keys[0].pubkey,authorizedPubkey:new K(t)}}static decodeNonceAdvance(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3),Q(_s.AdvanceNonceAccount,e.data),{noncePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey}}static decodeNonceWithdraw(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,5);let{lamports:t}=Q(_s.WithdrawNonceAccount,e.data);return{noncePubkey:e.keys[0].pubkey,toPubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[4].pubkey,lamports:t}}static decodeNonceAuthorize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);let{authorized:t}=Q(_s.AuthorizeNonceAccount,e.data);return{noncePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[1].pubkey,newAuthorizedPubkey:new K(t)}}static checkProgramId(e){if(!e.equals(vs.programId))throw Error(`invalid instruction; programId is not SystemProgram`)}static checkKeyLength(e,t){if(e.length<t)throw Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}},_s=Object.freeze({Create:{index:0,layout:L.struct([L.u32(`instruction`),L.ns64(`lamports`),L.ns64(`space`),q(`programId`)])},Assign:{index:1,layout:L.struct([L.u32(`instruction`),q(`programId`)])},Transfer:{index:2,layout:L.struct([L.u32(`instruction`),hs(`lamports`)])},CreateWithSeed:{index:3,layout:L.struct([L.u32(`instruction`),q(`base`),jo(`seed`),L.ns64(`lamports`),L.ns64(`space`),q(`programId`)])},AdvanceNonceAccount:{index:4,layout:L.struct([L.u32(`instruction`)])},WithdrawNonceAccount:{index:5,layout:L.struct([L.u32(`instruction`),L.ns64(`lamports`)])},InitializeNonceAccount:{index:6,layout:L.struct([L.u32(`instruction`),q(`authorized`)])},AuthorizeNonceAccount:{index:7,layout:L.struct([L.u32(`instruction`),q(`authorized`)])},Allocate:{index:8,layout:L.struct([L.u32(`instruction`),L.ns64(`space`)])},AllocateWithSeed:{index:9,layout:L.struct([L.u32(`instruction`),q(`base`),jo(`seed`),L.ns64(`space`),q(`programId`)])},AssignWithSeed:{index:10,layout:L.struct([L.u32(`instruction`),q(`base`),jo(`seed`),q(`programId`)])},TransferWithSeed:{index:11,layout:L.struct([L.u32(`instruction`),hs(`lamports`),jo(`seed`),q(`programId`)])},UpgradeNonceAccount:{index:12,layout:L.struct([L.u32(`instruction`)])}}),vs=class e{constructor(){}static createAccount(e){let t=_s.Create,n=Z(t,{lamports:e.lamports,space:e.space,programId:G(e.programId.toBuffer())});return new Jo({keys:[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.newAccountPubkey,isSigner:!0,isWritable:!0}],programId:this.programId,data:n})}static transfer(e){let t,n;if(`basePubkey`in e){let r=_s.TransferWithSeed;t=Z(r,{lamports:BigInt(e.lamports),seed:e.seed,programId:G(e.programId.toBuffer())}),n=[{pubkey:e.fromPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0}]}else{let r=_s.Transfer;t=Z(r,{lamports:BigInt(e.lamports)}),n=[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0}]}return new Jo({keys:n,programId:this.programId,data:t})}static assign(e){let t,n;if(`basePubkey`in e){let r=_s.AssignWithSeed;t=Z(r,{base:G(e.basePubkey.toBuffer()),seed:e.seed,programId:G(e.programId.toBuffer())}),n=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]}else{let r=_s.Assign;t=Z(r,{programId:G(e.programId.toBuffer())}),n=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]}return new Jo({keys:n,programId:this.programId,data:t})}static createAccountWithSeed(e){let t=_s.CreateWithSeed,n=Z(t,{base:G(e.basePubkey.toBuffer()),seed:e.seed,lamports:e.lamports,space:e.space,programId:G(e.programId.toBuffer())}),r=[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.newAccountPubkey,isSigner:!1,isWritable:!0}];return e.basePubkey.equals(e.fromPubkey)||r.push({pubkey:e.basePubkey,isSigner:!0,isWritable:!1}),new Jo({keys:r,programId:this.programId,data:n})}static createNonceAccount(t){let n=new Y;`basePubkey`in t&&`seed`in t?n.add(e.createAccountWithSeed({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,basePubkey:t.basePubkey,seed:t.seed,lamports:t.lamports,space:ps,programId:this.programId})):n.add(e.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,lamports:t.lamports,space:ps,programId:this.programId}));let r={noncePubkey:t.noncePubkey,authorizedPubkey:t.authorizedPubkey};return n.add(this.nonceInitialize(r)),n}static nonceInitialize(e){let t=_s.InitializeNonceAccount,n=Z(t,{authorized:G(e.authorizedPubkey.toBuffer())});return new Jo({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:ts,isSigner:!1,isWritable:!1},{pubkey:ns,isSigner:!1,isWritable:!1}],programId:this.programId,data:n})}static nonceAdvance(e){let t=_s.AdvanceNonceAccount,n=Z(t);return new Jo({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:ts,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static nonceWithdraw(e){let t=_s.WithdrawNonceAccount,n=Z(t,{lamports:e.lamports});return new Jo({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0},{pubkey:ts,isSigner:!1,isWritable:!1},{pubkey:ns,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static nonceAuthorize(e){let t=_s.AuthorizeNonceAccount,n=Z(t,{authorized:G(e.newAuthorizedPubkey.toBuffer())});return new Jo({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static allocate(e){let t,n;if(`basePubkey`in e){let r=_s.AllocateWithSeed;t=Z(r,{base:G(e.basePubkey.toBuffer()),seed:e.seed,space:e.space,programId:G(e.programId.toBuffer())}),n=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]}else{let r=_s.Allocate;t=Z(r,{space:e.space}),n=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]}return new Jo({keys:n,programId:this.programId,data:t})}};vs.programId=new K(`11111111111111111111111111111111`);var ys=wo-300,bs=class e{constructor(){}static getMinNumSignatures(t){return 2*(Math.ceil(t/e.chunkSize)+1+1)}static async load(t,n,r,i,a){{let e=await t.getMinimumBalanceForRentExemption(a.length),o=await t.getAccountInfo(r.publicKey,`confirmed`),s=null;if(o!==null){if(o.executable)return console.error(`Program load failed, account is already executable`),!1;o.data.length!==a.length&&(s||=new Y,s.add(vs.allocate({accountPubkey:r.publicKey,space:a.length}))),o.owner.equals(i)||(s||=new Y,s.add(vs.assign({accountPubkey:r.publicKey,programId:i}))),o.lamports<e&&(s||=new Y,s.add(vs.transfer({fromPubkey:n.publicKey,toPubkey:r.publicKey,lamports:e-o.lamports})))}else s=new Y().add(vs.createAccount({fromPubkey:n.publicKey,newAccountPubkey:r.publicKey,lamports:e>0?e:1,space:a.length,programId:i}));s!==null&&await ls(t,s,[n,r],{commitment:`confirmed`})}let o=L.struct([L.u32(`instruction`),L.u32(`offset`),L.u32(`bytesLength`),L.u32(`bytesLengthPadding`),L.seq(L.u8(`byte`),L.offset(L.u32(),-8),`bytes`)]),s=e.chunkSize,c=0,l=a,u=[];for(;l.length>0;){let e=l.slice(0,s),a=I.Buffer.alloc(s+16);o.encode({instruction:0,offset:c,bytes:e,bytesLength:0,bytesLengthPadding:0},a);let d=new Y().add({keys:[{pubkey:r.publicKey,isSigner:!0,isWritable:!0}],programId:i,data:a});u.push(ls(t,d,[n,r],{commitment:`confirmed`})),t._rpcEndpoint.includes(`solana.com`)&&await us(1e3/4),c+=s,l=l.slice(s)}await Promise.all(u);{let e=L.struct([L.u32(`instruction`)]),a=I.Buffer.alloc(e.span);e.encode({instruction:1},a);let o=new Y().add({keys:[{pubkey:r.publicKey,isSigner:!0,isWritable:!0},{pubkey:ns,isSigner:!1,isWritable:!1}],programId:i,data:a}),s=`processed`,c=await t.sendTransaction(o,[n,r],{preflightCommitment:s}),{context:l,value:u}=await t.confirmTransaction({signature:c,lastValidBlockHeight:o.lastValidBlockHeight,blockhash:o.recentBlockhash},s);if(u.err)throw Error(`Transaction ${c} failed (${JSON.stringify(u)})`);for(;;){try{if(await t.getSlot({commitment:s})>l.slot)break}catch{}await new Promise(e=>setTimeout(e,Math.round(Zo/2)))}}return!0}};bs.chunkSize=ys;var xs=new K(`BPFLoader2111111111111111111111111111111111`),Ss=class{static getMinNumSignatures(e){return bs.getMinNumSignatures(e)}static load(e,t,n,r,i){return bs.load(e,t,n,i,r)}};function Cs(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}var ws,Ts;function Es(){if(Ts)return ws;Ts=1;var e=Object.prototype.toString,t=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};function n(r,i){var a,o,s,c,l,u,d;if(r===!0)return`true`;if(r===!1)return`false`;switch(typeof r){case`object`:if(r===null)return null;if(r.toJSON&&typeof r.toJSON==`function`)return n(r.toJSON(),i);if(d=e.call(r),d===`[object Array]`){for(s=`[`,o=r.length-1,a=0;a<o;a++)s+=n(r[a],!0)+`,`;return o>-1&&(s+=n(r[a],!0)),s+`]`}else if(d===`[object Object]`){for(c=t(r).sort(),o=c.length,s=``,a=0;a<o;)l=c[a],u=n(r[l],!1),u!==void 0&&(s&&(s+=`,`),s+=JSON.stringify(l)+`:`+u),a++;return`{`+s+`}`}else return JSON.stringify(r);case`function`:case`undefined`:return i?null:void 0;case`string`:return JSON.stringify(r);default:return isFinite(r)?r:null}}return ws=function(e){var t=n(e,!1);if(t!==void 0)return``+t},ws}var Ds=Cs(Es()),Os=32;function ks(e){let t=0;for(;e>1;)e/=2,t++;return t}function As(e){return e===0?1:(e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,e|=e>>32,e+1)}var js=class{constructor(e,t,n,r,i){this.slotsPerEpoch=void 0,this.leaderScheduleSlotOffset=void 0,this.warmup=void 0,this.firstNormalEpoch=void 0,this.firstNormalSlot=void 0,this.slotsPerEpoch=e,this.leaderScheduleSlotOffset=t,this.warmup=n,this.firstNormalEpoch=r,this.firstNormalSlot=i}getEpoch(e){return this.getEpochAndSlotIndex(e)[0]}getEpochAndSlotIndex(e){if(e<this.firstNormalSlot){let t=ks(As(e+Os+1))-ks(Os)-1;return[t,e-(this.getSlotsInEpoch(t)-Os)]}else{let t=e-this.firstNormalSlot,n=Math.floor(t/this.slotsPerEpoch);return[this.firstNormalEpoch+n,t%this.slotsPerEpoch]}}getFirstSlotInEpoch(e){return e<=this.firstNormalEpoch?(2**e-1)*Os:(e-this.firstNormalEpoch)*this.slotsPerEpoch+this.firstNormalSlot}getLastSlotInEpoch(e){return this.getFirstSlotInEpoch(e)+this.getSlotsInEpoch(e)-1}getSlotsInEpoch(e){return e<this.firstNormalEpoch?2**(e+ks(Os)):this.slotsPerEpoch}},Ms=globalThis.fetch,Ns=class extends Pa{constructor(e,t,n){super(e=>{let n=Ma(e,{autoconnect:!0,max_reconnects:5,reconnect:!0,reconnect_interval:1e3,...t});return`socket`in n?this.underlyingSocket=n.socket:this.underlyingSocket=n,n},e,t,n),this.underlyingSocket=void 0}call(...e){let t=this.underlyingSocket?.readyState;return t===1?super.call(...e):Promise.reject(Error("Tried to call a JSON-RPC method `"+e[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+t+`)`))}notify(...e){let t=this.underlyingSocket?.readyState;return t===1?super.notify(...e):Promise.reject(Error("Tried to send a JSON-RPC notification `"+e[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+t+`)`))}};function Ps(e,t){let n;try{n=e.layout.decode(t)}catch(e){throw Error(`invalid instruction; `+e)}if(n.typeIndex!==e.index)throw Error(`invalid account data; account type mismatch ${n.typeIndex} != ${e.index}`);return n}var Fs=56,Is=class{constructor(e){this.key=void 0,this.state=void 0,this.key=e.key,this.state=e.state}isActive(){let e=BigInt(`0xffffffffffffffff`);return this.state.deactivationSlot===e}static deserialize(e){let t=Ps(Ls,e),n=e.length-Fs;J(n>=0,`lookup table is invalid`),J(n%32==0,`lookup table is invalid`);let r=n/32,{addresses:i}=L.struct([L.seq(q(),r,`addresses`)]).decode(e.slice(Fs));return{deactivationSlot:t.deactivationSlot,lastExtendedSlot:t.lastExtendedSlot,lastExtendedSlotStartIndex:t.lastExtendedStartIndex,authority:t.authority.length===0?void 0:new K(t.authority[0]),addresses:i.map(e=>new K(e))}}},Ls={index:1,layout:L.struct([L.u32(`typeIndex`),hs(`deactivationSlot`),L.nu64(`lastExtendedSlot`),L.u8(`lastExtendedStartIndex`),L.u8(),L.seq(q(),L.offset(L.u8(),-1),`authority`)])},Rs=/^[^:]+:\/\/([^:[]+|\[[^\]]+\])(:\d+)?(.*)/i;function zs(e){let t=e.match(Rs);if(t==null)throw TypeError(`Failed to validate endpoint URL \`${e}\``);let[n,r,i,a]=t,o=e.startsWith(`https:`)?`wss:`:`ws:`,s=i==null?null:parseInt(i.slice(1),10);return`${o}//${r}${s==null?``:`:${s+1}`}${a}`}var Bs=Oi(xi(K),U(),e=>new K(e)),Vs=Ti([U(),Si(`base64`)]),Hs=Oi(xi(I.Buffer),Vs,e=>I.Buffer.from(e[0],`base64`)),Us=30*1e3;function Ws(e){if(/^https?:/.test(e)===!1)throw TypeError("Endpoint URL must start with `http:` or `https:`.");return e}function Gs(e){let t,n;if(typeof e==`string`)t=e;else if(e){let{commitment:r,...i}=e;t=r,n=i}return{commitment:t,config:n}}function Ks(e){return e.map(e=>`memcmp`in e?{...e,memcmp:{...e.memcmp,encoding:e.memcmp.encoding??`base58`}}:e)}function qs(e){return Ei([W({jsonrpc:Si(`2.0`),id:U(),result:e}),W({jsonrpc:Si(`2.0`),id:U(),error:W({code:Di(),message:U(),data:H(yi())})})])}var Js=qs(Di());function $(e){return Oi(qs(e),Js,t=>`error`in t?t:{...t,result:R(t.result,e)})}function Ys(e){return $(W({context:W({slot:V()}),value:e}))}function Xs(e){return W({context:W({slot:V()}),value:e})}function Zs(e,t){return e===0?new Wo({header:t.header,staticAccountKeys:t.accountKeys.map(e=>new K(e)),recentBlockhash:t.recentBlockhash,compiledInstructions:t.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:Ar.default.decode(e.data)})),addressTableLookups:t.addressTableLookups}):new Uo(t)}var Qs=W({foundation:V(),foundationTerm:V(),initial:V(),taper:V(),terminal:V()}),$s=$(z(B(W({epoch:V(),effectiveSlot:V(),amount:V(),postBalance:V(),commission:H(B(V()))})))),ec=z(W({slot:V(),prioritizationFee:V()})),tc=W({total:V(),validator:V(),foundation:V(),epoch:V()}),nc=W({epoch:V(),slotIndex:V(),slotsInEpoch:V(),absoluteSlot:V(),blockHeight:H(V()),transactionCount:H(V())}),rc=W({slotsPerEpoch:V(),leaderScheduleSlotOffset:V(),warmup:bi(),firstNormalEpoch:V(),firstNormalSlot:V()}),ic=wi(U(),z(V())),ac=B(Ei([W({}),U()])),oc=W({err:ac}),sc=Si(`receivedSignature`),cc=W({"solana-core":U(),"feature-set":H(V())}),lc=W({program:U(),programId:Bs,parsed:Di()}),uc=W({programId:Bs,accounts:z(Bs),data:U()}),dc=Ys(W({err:B(Ei([W({}),U()])),logs:B(z(U())),accounts:H(B(z(B(W({executable:bi(),owner:U(),lamports:V(),data:z(U()),rentEpoch:H(V())}))))),unitsConsumed:H(V()),returnData:H(B(W({programId:U(),data:Ti([U(),Si(`base64`)])}))),innerInstructions:H(B(z(W({index:V(),instructions:z(Ei([lc,uc]))}))))})),fc=Ys(W({byIdentity:wi(U(),z(V())),range:W({firstSlot:V(),lastSlot:V()})}));function pc(e,t,n,r,i,a){let o=n||Ms;a!=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 s;return r&&(s=async(e,t)=>await o(...await new Promise((n,i)=>{try{r(e,t,(e,t)=>n([e,t]))}catch(e){i(e)}}))),new Aa.default(async(n,r)=>{let a={method:`POST`,body:n,agent:void 0,headers:Object.assign({"Content-Type":`application/json`},t||{},Al)};try{let t=5,n,c=500;for(;n=s?await s(e,a):await o(e,a),!(n.status!==429||i===!0||(--t,t===0));)console.error(`Server responded with ${n.status} ${n.statusText}. Retrying after ${c}ms delay...`),await us(c),c*=2;let l=await n.text();n.ok?r(null,l):r(Error(`${n.status} ${n.statusText}: ${l}`))}catch(e){e instanceof Error&&r(e)}},{})}function mc(e){return(t,n)=>new Promise((r,i)=>{e.request(t,n,(e,t)=>{if(e){i(e);return}r(t)})})}function hc(e){return t=>new Promise((n,r)=>{t.length===0&&n([]);let i=t.map(t=>e.request(t.methodName,t.args));e.request(i,(e,t)=>{if(e){r(e);return}n(t)})})}var gc=$(Qs),_c=$(tc),vc=$(ec),yc=$(nc),bc=$(rc),xc=$(ic),Sc=$(V()),Cc=Ys(W({total:V(),circulating:V(),nonCirculating:V(),nonCirculatingAccounts:z(Bs)})),wc=W({amount:U(),uiAmount:B(V()),decimals:V(),uiAmountString:H(U())}),Tc=Ys(z(W({address:Bs,amount:U(),uiAmount:B(V()),decimals:V(),uiAmountString:H(U())}))),Ec=Ys(z(W({pubkey:Bs,account:W({executable:bi(),owner:Bs,lamports:V(),data:Hs,rentEpoch:V()})}))),Dc=W({program:U(),parsed:Di(),space:V()}),Oc=Ys(z(W({pubkey:Bs,account:W({executable:bi(),owner:Bs,lamports:V(),data:Dc,rentEpoch:V()})}))),kc=Ys(z(W({lamports:V(),address:Bs}))),Ac=W({executable:bi(),owner:Bs,lamports:V(),data:Hs,rentEpoch:V()}),jc=W({pubkey:Bs,account:Ac}),Mc=Oi(Ei([xi(I.Buffer),Dc]),Ei([Vs,Dc]),e=>Array.isArray(e)?R(e,Hs):e),Nc=W({executable:bi(),owner:Bs,lamports:V(),data:Mc,rentEpoch:V()}),Pc=W({pubkey:Bs,account:Nc}),Fc=W({state:Ei([Si(`active`),Si(`inactive`),Si(`activating`),Si(`deactivating`)]),active:V(),inactive:V()}),Ic=$(z(W({signature:U(),slot:V(),err:ac,memo:B(U()),blockTime:H(B(V()))}))),Lc=$(z(W({signature:U(),slot:V(),err:ac,memo:B(U()),blockTime:H(B(V()))}))),Rc=W({subscription:V(),result:Xs(Ac)}),zc=W({pubkey:Bs,account:Ac}),Bc=W({subscription:V(),result:Xs(zc)}),Vc=W({parent:V(),slot:V(),root:V()}),Hc=W({subscription:V(),result:Vc}),Uc=Ei([W({type:Ei([Si(`firstShredReceived`),Si(`completed`),Si(`optimisticConfirmation`),Si(`root`)]),slot:V(),timestamp:V()}),W({type:Si(`createdBank`),parent:V(),slot:V(),timestamp:V()}),W({type:Si(`frozen`),slot:V(),timestamp:V(),stats:W({numTransactionEntries:V(),numSuccessfulTransactions:V(),numFailedTransactions:V(),maxTransactionsPerEntry:V()})}),W({type:Si(`dead`),slot:V(),timestamp:V(),err:U()})]),Wc=W({subscription:V(),result:Uc}),Gc=W({subscription:V(),result:Xs(Ei([oc,sc]))}),Kc=W({subscription:V(),result:V()}),qc=W({pubkey:U(),gossip:B(U()),tpu:B(U()),rpc:B(U()),version:B(U())}),Jc=W({votePubkey:U(),nodePubkey:U(),activatedStake:V(),epochVoteAccount:bi(),epochCredits:z(Ti([V(),V(),V()])),commission:V(),lastVote:V(),rootSlot:B(V())}),Yc=$(W({current:z(Jc),delinquent:z(Jc)})),Xc=Ei([Si(`processed`),Si(`confirmed`),Si(`finalized`)]),Zc=Ys(z(B(W({slot:V(),confirmations:B(V()),err:ac,confirmationStatus:H(Xc)})))),Qc=$(V()),$c=W({accountKey:Bs,writableIndexes:z(V()),readonlyIndexes:z(V())}),el=W({signatures:z(U()),message:W({accountKeys:z(U()),header:W({numRequiredSignatures:V(),numReadonlySignedAccounts:V(),numReadonlyUnsignedAccounts:V()}),instructions:z(W({accounts:z(V()),data:U(),programIdIndex:V()})),recentBlockhash:U(),addressTableLookups:H(z($c))})}),tl=W({pubkey:Bs,signer:bi(),writable:bi(),source:H(Ei([Si(`transaction`),Si(`lookupTable`)]))}),nl=W({accountKeys:z(tl),signatures:z(U())}),rl=W({parsed:Di(),program:U(),programId:Bs}),il=W({accounts:z(Bs),data:U(),programId:Bs}),al=Oi(Ei([il,rl]),Ei([W({parsed:Di(),program:U(),programId:U()}),W({accounts:z(U()),data:U(),programId:U()})]),e=>`accounts`in e?R(e,il):R(e,rl)),ol=W({signatures:z(U()),message:W({accountKeys:z(tl),instructions:z(al),recentBlockhash:U(),addressTableLookups:H(B(z($c)))})}),sl=W({accountIndex:V(),mint:U(),owner:H(U()),programId:H(U()),uiTokenAmount:wc}),cl=W({writable:z(Bs),readonly:z(Bs)}),ll=W({err:ac,fee:V(),innerInstructions:H(B(z(W({index:V(),instructions:z(W({accounts:z(V()),data:U(),programIdIndex:V()}))})))),preBalances:z(V()),postBalances:z(V()),logMessages:H(B(z(U()))),preTokenBalances:H(B(z(sl))),postTokenBalances:H(B(z(sl))),loadedAddresses:H(cl),computeUnitsConsumed:H(V()),costUnits:H(V())}),ul=W({err:ac,fee:V(),innerInstructions:H(B(z(W({index:V(),instructions:z(al)})))),preBalances:z(V()),postBalances:z(V()),logMessages:H(B(z(U()))),preTokenBalances:H(B(z(sl))),postTokenBalances:H(B(z(sl))),loadedAddresses:H(cl),computeUnitsConsumed:H(V()),costUnits:H(V())}),dl=Ei([Si(0),Si(`legacy`)]),fl=W({pubkey:U(),lamports:V(),postBalance:B(V()),rewardType:B(U()),commission:H(B(V()))}),pl=$(B(W({blockhash:U(),previousBlockhash:U(),parentSlot:V(),transactions:z(W({transaction:el,meta:B(ll),version:H(dl)})),rewards:H(z(fl)),blockTime:B(V()),blockHeight:B(V())}))),ml=$(B(W({blockhash:U(),previousBlockhash:U(),parentSlot:V(),rewards:H(z(fl)),blockTime:B(V()),blockHeight:B(V())}))),hl=$(B(W({blockhash:U(),previousBlockhash:U(),parentSlot:V(),transactions:z(W({transaction:nl,meta:B(ll),version:H(dl)})),rewards:H(z(fl)),blockTime:B(V()),blockHeight:B(V())}))),gl=$(B(W({blockhash:U(),previousBlockhash:U(),parentSlot:V(),transactions:z(W({transaction:ol,meta:B(ul),version:H(dl)})),rewards:H(z(fl)),blockTime:B(V()),blockHeight:B(V())}))),_l=$(B(W({blockhash:U(),previousBlockhash:U(),parentSlot:V(),transactions:z(W({transaction:nl,meta:B(ul),version:H(dl)})),rewards:H(z(fl)),blockTime:B(V()),blockHeight:B(V())}))),vl=$(B(W({blockhash:U(),previousBlockhash:U(),parentSlot:V(),rewards:H(z(fl)),blockTime:B(V()),blockHeight:B(V())}))),yl=$(B(W({blockhash:U(),previousBlockhash:U(),parentSlot:V(),transactions:z(W({transaction:el,meta:B(ll)})),rewards:H(z(fl)),blockTime:B(V())}))),bl=$(B(W({blockhash:U(),previousBlockhash:U(),parentSlot:V(),signatures:z(U()),blockTime:B(V())}))),xl=$(B(W({slot:V(),meta:B(ll),blockTime:H(B(V())),transaction:el,version:H(dl)}))),Sl=$(B(W({slot:V(),transaction:ol,meta:B(ul),blockTime:H(B(V())),version:H(dl)}))),Cl=Ys(W({blockhash:U(),lastValidBlockHeight:V()})),wl=Ys(bi()),Tl=$(z(W({slot:V(),numTransactions:V(),numSlots:V(),samplePeriodSecs:V()}))),El=Ys(B(W({feeCalculator:W({lamportsPerSignature:V()})}))),Dl=$(U()),Ol=$(U()),kl=W({result:Xs(W({err:ac,logs:z(U()),signature:U()})),subscription:V()}),Al={"solana-client":`js/1.0.0-maintenance`},jl=class{constructor(e,t){this._commitment=void 0,this._confirmTransactionInitialTimeout=void 0,this._rpcEndpoint=void 0,this._rpcWsEndpoint=void 0,this._rpcClient=void 0,this._rpcRequest=void 0,this._rpcBatchRequest=void 0,this._rpcWebSocket=void 0,this._rpcWebSocketConnected=!1,this._rpcWebSocketHeartbeat=null,this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketGeneration=0,this._disableBlockhashCaching=!1,this._pollingBlockhash=!1,this._blockhashInfo={latestBlockhash:null,lastFetch:0,transactionSignatures:[],simulatedSignatures:[]},this._nextClientSubscriptionId=0,this._subscriptionDisposeFunctionsByClientSubscriptionId={},this._subscriptionHashByClientSubscriptionId={},this._subscriptionStateChangeCallbacksByHash={},this._subscriptionCallbacksByServerSubscriptionId={},this._subscriptionsByHash={},this._subscriptionsAutoDisposedByRpc=new Set,this.getBlockHeight=(()=>{let e={};return async t=>{let{commitment:n,config:r}=Gs(t),i=this._buildArgs([],n,void 0,r),a=Ds(i);return e[a]=e[a]??(async()=>{try{let e=R(await this._rpcRequest(`getBlockHeight`,i),$(V()));if(`error`in e)throw new X(e.error,`failed to get block height information`);return e.result}finally{delete e[a]}})(),await e[a]}})();let n,r,i,a,o,s;t&&typeof t==`string`?this._commitment=t:t&&(this._commitment=t.commitment,this._confirmTransactionInitialTimeout=t.confirmTransactionInitialTimeout,n=t.wsEndpoint,r=t.httpHeaders,i=t.fetch,a=t.fetchMiddleware,o=t.disableRetryOnRateLimit,s=t.httpAgent),this._rpcEndpoint=Ws(e),this._rpcWsEndpoint=n||zs(e),this._rpcClient=pc(e,r,i,a,o,s),this._rpcRequest=mc(this._rpcClient),this._rpcBatchRequest=hc(this._rpcClient),this._rpcWebSocket=new Ns(this._rpcWsEndpoint,{autoconnect:!1,max_reconnects:1/0}),this._rpcWebSocket.on(`open`,this._wsOnOpen.bind(this)),this._rpcWebSocket.on(`error`,this._wsOnError.bind(this)),this._rpcWebSocket.on(`close`,this._wsOnClose.bind(this)),this._rpcWebSocket.on(`accountNotification`,this._wsOnAccountNotification.bind(this)),this._rpcWebSocket.on(`programNotification`,this._wsOnProgramAccountNotification.bind(this)),this._rpcWebSocket.on(`slotNotification`,this._wsOnSlotNotification.bind(this)),this._rpcWebSocket.on(`slotsUpdatesNotification`,this._wsOnSlotUpdatesNotification.bind(this)),this._rpcWebSocket.on(`signatureNotification`,this._wsOnSignatureNotification.bind(this)),this._rpcWebSocket.on(`rootNotification`,this._wsOnRootNotification.bind(this)),this._rpcWebSocket.on(`logsNotification`,this._wsOnLogsNotification.bind(this))}get commitment(){return this._commitment}get rpcEndpoint(){return this._rpcEndpoint}async getBalanceAndContext(e,t){let{commitment:n,config:r}=Gs(t),i=this._buildArgs([e.toBase58()],n,void 0,r),a=R(await this._rpcRequest(`getBalance`,i),Ys(V()));if(`error`in a)throw new X(a.error,`failed to get balance for ${e.toBase58()}`);return a.result}async getBalance(e,t){return await this.getBalanceAndContext(e,t).then(e=>e.value).catch(t=>{throw Error(`failed to get balance of account `+e.toBase58()+`: `+t)})}async getBlockTime(e){let t=R(await this._rpcRequest(`getBlockTime`,[e]),$(B(V())));if(`error`in t)throw new X(t.error,`failed to get block time for slot ${e}`);return t.result}async getMinimumLedgerSlot(){let e=R(await this._rpcRequest(`minimumLedgerSlot`,[]),$(V()));if(`error`in e)throw new X(e.error,`failed to get minimum ledger slot`);return e.result}async getFirstAvailableBlock(){let e=R(await this._rpcRequest(`getFirstAvailableBlock`,[]),Sc);if(`error`in e)throw new X(e.error,`failed to get first available block`);return e.result}async getSupply(e){let t={};t=typeof e==`string`?{commitment:e}:e?{...e,commitment:e&&e.commitment||this.commitment}:{commitment:this.commitment};let n=R(await this._rpcRequest(`getSupply`,[t]),Cc);if(`error`in n)throw new X(n.error,`failed to get supply`);return n.result}async getTokenSupply(e,t){let n=this._buildArgs([e.toBase58()],t),r=R(await this._rpcRequest(`getTokenSupply`,n),Ys(wc));if(`error`in r)throw new X(r.error,`failed to get token supply`);return r.result}async getTokenAccountBalance(e,t){let n=this._buildArgs([e.toBase58()],t),r=R(await this._rpcRequest(`getTokenAccountBalance`,n),Ys(wc));if(`error`in r)throw new X(r.error,`failed to get token account balance`);return r.result}async getTokenAccountsByOwner(e,t,n){let{commitment:r,config:i}=Gs(n),a=[e.toBase58()];`mint`in t?a.push({mint:t.mint.toBase58()}):a.push({programId:t.programId.toBase58()});let o=this._buildArgs(a,r,`base64`,i),s=R(await this._rpcRequest(`getTokenAccountsByOwner`,o),Ec);if(`error`in s)throw new X(s.error,`failed to get token accounts owned by account ${e.toBase58()}`);return s.result}async getParsedTokenAccountsByOwner(e,t,n){let r=[e.toBase58()];`mint`in t?r.push({mint:t.mint.toBase58()}):r.push({programId:t.programId.toBase58()});let i=this._buildArgs(r,n,`jsonParsed`),a=R(await this._rpcRequest(`getTokenAccountsByOwner`,i),Oc);if(`error`in a)throw new X(a.error,`failed to get token accounts owned by account ${e.toBase58()}`);return a.result}async getLargestAccounts(e){let t={...e,commitment:e&&e.commitment||this.commitment},n=t.filter||t.commitment?[t]:[],r=R(await this._rpcRequest(`getLargestAccounts`,n),kc);if(`error`in r)throw new X(r.error,`failed to get largest accounts`);return r.result}async getTokenLargestAccounts(e,t){let n=this._buildArgs([e.toBase58()],t),r=R(await this._rpcRequest(`getTokenLargestAccounts`,n),Tc);if(`error`in r)throw new X(r.error,`failed to get token largest accounts`);return r.result}async getAccountInfoAndContext(e,t){let{commitment:n,config:r}=Gs(t),i=this._buildArgs([e.toBase58()],n,`base64`,r),a=R(await this._rpcRequest(`getAccountInfo`,i),Ys(B(Ac)));if(`error`in a)throw new X(a.error,`failed to get info about account ${e.toBase58()}`);return a.result}async getParsedAccountInfo(e,t){let{commitment:n,config:r}=Gs(t),i=this._buildArgs([e.toBase58()],n,`jsonParsed`,r),a=R(await this._rpcRequest(`getAccountInfo`,i),Ys(B(Nc)));if(`error`in a)throw new X(a.error,`failed to get info about account ${e.toBase58()}`);return a.result}async getAccountInfo(e,t){try{return(await this.getAccountInfoAndContext(e,t)).value}catch(t){throw Error(`failed to get info about account `+e.toBase58()+`: `+t)}}async getMultipleParsedAccounts(e,t){let{commitment:n,config:r}=Gs(t),i=e.map(e=>e.toBase58()),a=this._buildArgs([i],n,`jsonParsed`,r),o=R(await this._rpcRequest(`getMultipleAccounts`,a),Ys(z(B(Nc))));if(`error`in o)throw new X(o.error,`failed to get info for accounts ${i}`);return o.result}async getMultipleAccountsInfoAndContext(e,t){let{commitment:n,config:r}=Gs(t),i=e.map(e=>e.toBase58()),a=this._buildArgs([i],n,`base64`,r),o=R(await this._rpcRequest(`getMultipleAccounts`,a),Ys(z(B(Ac))));if(`error`in o)throw new X(o.error,`failed to get info for accounts ${i}`);return o.result}async getMultipleAccountsInfo(e,t){return(await this.getMultipleAccountsInfoAndContext(e,t)).value}async getStakeActivation(e,t,n){let{commitment:r,config:i}=Gs(t),a=this._buildArgs([e.toBase58()],r,void 0,{...i,epoch:n??i?.epoch}),o=R(await this._rpcRequest(`getStakeActivation`,a),$(Fc));if(`error`in o)throw new X(o.error,`failed to get Stake Activation ${e.toBase58()}`);return o.result}async getProgramAccounts(e,t){let{commitment:n,config:r}=Gs(t),{encoding:i,...a}=r||{},o=this._buildArgs([e.toBase58()],n,i||`base64`,{...a,...a.filters?{filters:Ks(a.filters)}:null}),s=await this._rpcRequest(`getProgramAccounts`,o),c=z(jc),l=a.withContext===!0?R(s,Ys(c)):R(s,$(c));if(`error`in l)throw new X(l.error,`failed to get accounts owned by program ${e.toBase58()}`);return l.result}async getParsedProgramAccounts(e,t){let{commitment:n,config:r}=Gs(t),i=this._buildArgs([e.toBase58()],n,`jsonParsed`,r),a=R(await this._rpcRequest(`getProgramAccounts`,i),$(z(Pc)));if(`error`in a)throw new X(a.error,`failed to get accounts owned by program ${e.toBase58()}`);return a.result}async confirmTransaction(e,t){let n;if(typeof e==`string`)n=e;else{let t=e;if(t.abortSignal?.aborted)return Promise.reject(t.abortSignal.reason);n=t.signature}let r;try{r=Ar.default.decode(n)}catch{throw Error(`signature must be base58 encoded: `+n)}return J(r.length===64,`signature has invalid length`),typeof e==`string`?await this.confirmTransactionUsingLegacyTimeoutStrategy({commitment:t||this.commitment,signature:n}):`lastValidBlockHeight`in e?await this.confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:t||this.commitment,strategy:e}):await this.confirmTransactionUsingDurableNonceStrategy({commitment:t||this.commitment,strategy:e})}getCancellationPromise(e){return new Promise((t,n)=>{e!=null&&(e.aborted?n(e.reason):e.addEventListener(`abort`,()=>{n(e.reason)}))})}getTransactionConfirmationPromise({commitment:e,signature:t}){let n,r,i=!1;return{abortConfirmation:()=>{r&&=(r(),void 0),n!=null&&(this.removeSignatureListener(n),n=void 0)},confirmationPromise:new Promise((a,o)=>{try{n=this.onSignature(t,(e,t)=>{n=void 0;let r={context:t,value:e};a({__type:Ko.PROCESSED,response:r})},e);let s=new Promise(e=>{n==null?e():r=this._onSubscriptionStateChange(n,t=>{t===`subscribed`&&e()})});(async()=>{if(await s,i)return;let n=await this.getSignatureStatus(t);if(i||n==null)return;let{context:r,value:c}=n;if(c!=null)if(c?.err)o(c.err);else{switch(e){case`confirmed`:case`single`:case`singleGossip`:if(c.confirmationStatus===`processed`)return;break;case`finalized`:case`max`:case`root`:if(c.confirmationStatus===`processed`||c.confirmationStatus===`confirmed`)return;break;case`processed`:case`recent`:}i=!0,a({__type:Ko.PROCESSED,response:{context:r,value:c}})}})()}catch(e){o(e)}})}}async confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:e,strategy:{abortSignal:t,lastValidBlockHeight:n,signature:r}}){let i=!1,a=new Promise(t=>{let r=async()=>{try{return await this.getBlockHeight(e)}catch{return-1}};(async()=>{let e=await r();if(!i){for(;e<=n;)if(await us(1e3),i||(e=await r(),i))return;t({__type:Ko.BLOCKHEIGHT_EXCEEDED})}})()}),{abortConfirmation:o,confirmationPromise:s}=this.getTransactionConfirmationPromise({commitment:e,signature:r}),c=this.getCancellationPromise(t),l;try{let e=await Promise.race([c,s,a]);if(e.__type===Ko.PROCESSED)l=e.response;else throw new Eo(r)}finally{i=!0,o()}return l}async confirmTransactionUsingDurableNonceStrategy({commitment:e,strategy:{abortSignal:t,minContextSlot:n,nonceAccountPubkey:r,nonceValue:i,signature:a}}){let o=!1,s=new Promise(t=>{let a=i,s=null,c=async()=>{try{let{context:t,value:i}=await this.getNonceAndContext(r,{commitment:e,minContextSlot:n});return s=t.slot,i?.nonce}catch{return a}};(async()=>{if(a=await c(),!o)for(;;){if(i!==a){t({__type:Ko.NONCE_INVALID,slotInWhichNonceDidAdvance:s});return}if(await us(2e3),o||(a=await c(),o))return}})()}),{abortConfirmation:c,confirmationPromise:l}=this.getTransactionConfirmationPromise({commitment:e,signature:a}),u=this.getCancellationPromise(t),d;try{let t=await Promise.race([u,l,s]);if(t.__type===Ko.PROCESSED)d=t.response;else{let r;for(;;){let e=await this.getSignatureStatus(a);if(e==null)break;if(e.context.slot<(t.slotInWhichNonceDidAdvance??n)){await us(400);continue}r=e;break}if(r?.value){let t=e||`finalized`,{confirmationStatus:n}=r.value;switch(t){case`processed`:case`recent`:if(n!==`processed`&&n!==`confirmed`&&n!==`finalized`)throw new Oo(a);break;case`confirmed`:case`single`:case`singleGossip`:if(n!==`confirmed`&&n!==`finalized`)throw new Oo(a);break;case`finalized`:case`max`:case`root`:if(n!==`finalized`)throw new Oo(a);break;default:(e=>{})(t)}d={context:r.context,value:{err:r.value.err}}}else throw new Oo(a)}}finally{o=!0,c()}return d}async confirmTransactionUsingLegacyTimeoutStrategy({commitment:e,signature:t}){let n,r=new Promise(t=>{let r=this._confirmTransactionInitialTimeout||60*1e3;switch(e){case`processed`:case`recent`:case`single`:case`confirmed`:case`singleGossip`:r=this._confirmTransactionInitialTimeout||30*1e3;break}n=setTimeout(()=>t({__type:Ko.TIMED_OUT,timeoutMs:r}),r)}),{abortConfirmation:i,confirmationPromise:a}=this.getTransactionConfirmationPromise({commitment:e,signature:t}),o;try{let e=await Promise.race([a,r]);if(e.__type===Ko.PROCESSED)o=e.response;else throw new Do(t,e.timeoutMs/1e3)}finally{clearTimeout(n),i()}return o}async getClusterNodes(){let e=R(await this._rpcRequest(`getClusterNodes`,[]),$(z(qc)));if(`error`in e)throw new X(e.error,`failed to get cluster nodes`);return e.result}async getVoteAccounts(e){let t=this._buildArgs([],e),n=R(await this._rpcRequest(`getVoteAccounts`,t),Yc);if(`error`in n)throw new X(n.error,`failed to get vote accounts`);return n.result}async getSlot(e){let{commitment:t,config:n}=Gs(e),r=this._buildArgs([],t,void 0,n),i=R(await this._rpcRequest(`getSlot`,r),$(V()));if(`error`in i)throw new X(i.error,`failed to get slot`);return i.result}async getSlotLeader(e){let{commitment:t,config:n}=Gs(e),r=this._buildArgs([],t,void 0,n),i=R(await this._rpcRequest(`getSlotLeader`,r),$(U()));if(`error`in i)throw new X(i.error,`failed to get slot leader`);return i.result}async getSlotLeaders(e,t){let n=[e,t],r=R(await this._rpcRequest(`getSlotLeaders`,n),$(z(Bs)));if(`error`in r)throw new X(r.error,`failed to get slot leaders`);return r.result}async getSignatureStatus(e,t){let{context:n,value:r}=await this.getSignatureStatuses([e],t);return J(r.length===1),{context:n,value:r[0]}}async getSignatureStatuses(e,t){let n=[e];t&&n.push(t);let r=R(await this._rpcRequest(`getSignatureStatuses`,n),Zc);if(`error`in r)throw new X(r.error,`failed to get signature status`);return r.result}async getTransactionCount(e){let{commitment:t,config:n}=Gs(e),r=this._buildArgs([],t,void 0,n),i=R(await this._rpcRequest(`getTransactionCount`,r),$(V()));if(`error`in i)throw new X(i.error,`failed to get transaction count`);return i.result}async getTotalSupply(e){return(await this.getSupply({commitment:e,excludeNonCirculatingAccountsList:!0})).value.total}async getInflationGovernor(e){let t=this._buildArgs([],e),n=R(await this._rpcRequest(`getInflationGovernor`,t),gc);if(`error`in n)throw new X(n.error,`failed to get inflation`);return n.result}async getInflationReward(e,t,n){let{commitment:r,config:i}=Gs(n),a=this._buildArgs([e.map(e=>e.toBase58())],r,void 0,{...i,epoch:t??i?.epoch}),o=R(await this._rpcRequest(`getInflationReward`,a),$s);if(`error`in o)throw new X(o.error,`failed to get inflation reward`);return o.result}async getInflationRate(){let e=R(await this._rpcRequest(`getInflationRate`,[]),_c);if(`error`in e)throw new X(e.error,`failed to get inflation rate`);return e.result}async getEpochInfo(e){let{commitment:t,config:n}=Gs(e),r=this._buildArgs([],t,void 0,n),i=R(await this._rpcRequest(`getEpochInfo`,r),yc);if(`error`in i)throw new X(i.error,`failed to get epoch info`);return i.result}async getEpochSchedule(){let e=R(await this._rpcRequest(`getEpochSchedule`,[]),bc);if(`error`in e)throw new X(e.error,`failed to get epoch schedule`);let t=e.result;return new js(t.slotsPerEpoch,t.leaderScheduleSlotOffset,t.warmup,t.firstNormalEpoch,t.firstNormalSlot)}async getLeaderSchedule(){let e=R(await this._rpcRequest(`getLeaderSchedule`,[]),xc);if(`error`in e)throw new X(e.error,`failed to get leader schedule`);return e.result}async getMinimumBalanceForRentExemption(e,t){let n=this._buildArgs([e],t),r=R(await this._rpcRequest(`getMinimumBalanceForRentExemption`,n),Qc);return`error`in r?(console.warn(`Unable to fetch minimum balance for rent exemption`),0):r.result}async getRecentBlockhashAndContext(e){let{context:t,value:{blockhash:n}}=await this.getLatestBlockhashAndContext(e);return{context:t,value:{blockhash:n,feeCalculator:{get lamportsPerSignature(){throw Error("The capability to fetch `lamportsPerSignature` using the `getRecentBlockhash` API is no longer offered by the network. Use the `getFeeForMessage` API to obtain the fee for a given message.")},toJSON(){return{}}}}}}async getRecentPerformanceSamples(e){let t=R(await this._rpcRequest(`getRecentPerformanceSamples`,e?[e]:[]),Tl);if(`error`in t)throw new X(t.error,`failed to get recent performance samples`);return t.result}async getFeeCalculatorForBlockhash(e,t){let n=this._buildArgs([e],t),r=R(await this._rpcRequest(`getFeeCalculatorForBlockhash`,n),El);if(`error`in r)throw new X(r.error,`failed to get fee calculator`);let{context:i,value:a}=r.result;return{context:i,value:a===null?null:a.feeCalculator}}async getFeeForMessage(e,t){let n=G(e.serialize()).toString(`base64`),r=this._buildArgs([n],t),i=R(await this._rpcRequest(`getFeeForMessage`,r),Ys(B(V())));if(`error`in i)throw new X(i.error,`failed to get fee for message`);if(i.result===null)throw Error(`invalid blockhash`);return i.result}async getRecentPrioritizationFees(e){let t=e?.lockedWritableAccounts?.map(e=>e.toBase58()),n=t?.length?[t]:[],r=R(await this._rpcRequest(`getRecentPrioritizationFees`,n),vc);if(`error`in r)throw new X(r.error,`failed to get recent prioritization fees`);return r.result}async getRecentBlockhash(e){try{return(await this.getRecentBlockhashAndContext(e)).value}catch(e){throw Error(`failed to get recent blockhash: `+e)}}async getLatestBlockhash(e){try{return(await this.getLatestBlockhashAndContext(e)).value}catch(e){throw Error(`failed to get recent blockhash: `+e)}}async getLatestBlockhashAndContext(e){let{commitment:t,config:n}=Gs(e),r=this._buildArgs([],t,void 0,n),i=R(await this._rpcRequest(`getLatestBlockhash`,r),Cl);if(`error`in i)throw new X(i.error,`failed to get latest blockhash`);return i.result}async isBlockhashValid(e,t){let{commitment:n,config:r}=Gs(t),i=this._buildArgs([e],n,void 0,r),a=R(await this._rpcRequest(`isBlockhashValid`,i),wl);if(`error`in a)throw new X(a.error,"failed to determine if the blockhash `"+e+"`is valid");return a.result}async getVersion(){let e=R(await this._rpcRequest(`getVersion`,[]),$(cc));if(`error`in e)throw new X(e.error,`failed to get version`);return e.result}async getGenesisHash(){let e=R(await this._rpcRequest(`getGenesisHash`,[]),$(U()));if(`error`in e)throw new X(e.error,`failed to get genesis hash`);return e.result}async getBlock(e,t){let{commitment:n,config:r}=Gs(t),i=this._buildArgsAtLeastConfirmed([e],n,void 0,r),a=await this._rpcRequest(`getBlock`,i);try{switch(r?.transactionDetails){case`accounts`:{let e=R(a,hl);if(`error`in e)throw e.error;return e.result}case`none`:{let e=R(a,ml);if(`error`in e)throw e.error;return e.result}default:{let e=R(a,pl);if(`error`in e)throw e.error;let{result:t}=e;return t?{...t,transactions:t.transactions.map(({transaction:e,meta:t,version:n})=>({meta:t,transaction:{...e,message:Zs(n,e.message)},version:n}))}:null}}}catch(e){throw new X(e,`failed to get confirmed block`)}}async getParsedBlock(e,t){let{commitment:n,config:r}=Gs(t),i=this._buildArgsAtLeastConfirmed([e],n,`jsonParsed`,r),a=await this._rpcRequest(`getBlock`,i);try{switch(r?.transactionDetails){case`accounts`:{let e=R(a,_l);if(`error`in e)throw e.error;return e.result}case`none`:{let e=R(a,vl);if(`error`in e)throw e.error;return e.result}default:{let e=R(a,gl);if(`error`in e)throw e.error;return e.result}}}catch(e){throw new X(e,`failed to get block`)}}async getBlockProduction(e){let t,n;if(typeof e==`string`)n=e;else if(e){let{commitment:r,...i}=e;n=r,t=i}let r=this._buildArgs([],n,`base64`,t),i=R(await this._rpcRequest(`getBlockProduction`,r),fc);if(`error`in i)throw new X(i.error,`failed to get block production information`);return i.result}async getTransaction(e,t){let{commitment:n,config:r}=Gs(t),i=this._buildArgsAtLeastConfirmed([e],n,void 0,r),a=R(await this._rpcRequest(`getTransaction`,i),xl);if(`error`in a)throw new X(a.error,`failed to get transaction`);let o=a.result;return o&&{...o,transaction:{...o.transaction,message:Zs(o.version,o.transaction.message)}}}async getParsedTransaction(e,t){let{commitment:n,config:r}=Gs(t),i=this._buildArgsAtLeastConfirmed([e],n,`jsonParsed`,r),a=R(await this._rpcRequest(`getTransaction`,i),Sl);if(`error`in a)throw new X(a.error,`failed to get transaction`);return a.result}async getParsedTransactions(e,t){let{commitment:n,config:r}=Gs(t),i=e.map(e=>({methodName:`getTransaction`,args:this._buildArgsAtLeastConfirmed([e],n,`jsonParsed`,r)}));return(await this._rpcBatchRequest(i)).map(e=>{let t=R(e,Sl);if(`error`in t)throw new X(t.error,`failed to get transactions`);return t.result})}async getTransactions(e,t){let{commitment:n,config:r}=Gs(t),i=e.map(e=>({methodName:`getTransaction`,args:this._buildArgsAtLeastConfirmed([e],n,void 0,r)}));return(await this._rpcBatchRequest(i)).map(e=>{let t=R(e,xl);if(`error`in t)throw new X(t.error,`failed to get transactions`);let n=t.result;return n&&{...n,transaction:{...n.transaction,message:Zs(n.version,n.transaction.message)}}})}async getConfirmedBlock(e,t){let n=this._buildArgsAtLeastConfirmed([e],t),r=R(await this._rpcRequest(`getBlock`,n),yl);if(`error`in r)throw new X(r.error,`failed to get confirmed block`);let i=r.result;if(!i)throw Error(`Confirmed block `+e+` not found`);let a={...i,transactions:i.transactions.map(({transaction:e,meta:t})=>{let n=new Uo(e.message);return{meta:t,transaction:{...e,message:n}}})};return{...a,transactions:a.transactions.map(({transaction:e,meta:t})=>({meta:t,transaction:Y.populate(e.message,e.signatures)}))}}async getBlocks(e,t,n){let r=this._buildArgsAtLeastConfirmed(t===void 0?[e]:[e,t],n),i=R(await this._rpcRequest(`getBlocks`,r),$(z(V())));if(`error`in i)throw new X(i.error,`failed to get blocks`);return i.result}async getBlockSignatures(e,t){let n=this._buildArgsAtLeastConfirmed([e],t,void 0,{transactionDetails:`signatures`,rewards:!1}),r=R(await this._rpcRequest(`getBlock`,n),bl);if(`error`in r)throw new X(r.error,`failed to get block`);let i=r.result;if(!i)throw Error(`Block `+e+` not found`);return i}async getConfirmedBlockSignatures(e,t){let n=this._buildArgsAtLeastConfirmed([e],t,void 0,{transactionDetails:`signatures`,rewards:!1}),r=R(await this._rpcRequest(`getBlock`,n),bl);if(`error`in r)throw new X(r.error,`failed to get confirmed block`);let i=r.result;if(!i)throw Error(`Confirmed block `+e+` not found`);return i}async getConfirmedTransaction(e,t){let n=this._buildArgsAtLeastConfirmed([e],t),r=R(await this._rpcRequest(`getTransaction`,n),xl);if(`error`in r)throw new X(r.error,`failed to get transaction`);let i=r.result;if(!i)return i;let a=new Uo(i.transaction.message),o=i.transaction.signatures;return{...i,transaction:Y.populate(a,o)}}async getParsedConfirmedTransaction(e,t){let n=this._buildArgsAtLeastConfirmed([e],t,`jsonParsed`),r=R(await this._rpcRequest(`getTransaction`,n),Sl);if(`error`in r)throw new X(r.error,`failed to get confirmed transaction`);return r.result}async getParsedConfirmedTransactions(e,t){let n=e.map(e=>({methodName:`getTransaction`,args:this._buildArgsAtLeastConfirmed([e],t,`jsonParsed`)}));return(await this._rpcBatchRequest(n)).map(e=>{let t=R(e,Sl);if(`error`in t)throw new X(t.error,`failed to get confirmed transactions`);return t.result})}async getConfirmedSignaturesForAddress(e,t,n){let r={},i=await this.getFirstAvailableBlock();for(;!(`until`in r)&&(t--,!(t<=0||t<i));)try{let e=await this.getConfirmedBlockSignatures(t,`finalized`);e.signatures.length>0&&(r.until=e.signatures[e.signatures.length-1].toString())}catch(e){if(e instanceof Error&&e.message.includes(`skipped`))continue;throw e}let a=await this.getSlot(`finalized`);for(;!(`before`in r)&&(n++,!(n>a));)try{let e=await this.getConfirmedBlockSignatures(n);e.signatures.length>0&&(r.before=e.signatures[e.signatures.length-1].toString())}catch(e){if(e instanceof Error&&e.message.includes(`skipped`))continue;throw e}return(await this.getConfirmedSignaturesForAddress2(e,r)).map(e=>e.signature)}async getConfirmedSignaturesForAddress2(e,t,n){let r=this._buildArgsAtLeastConfirmed([e.toBase58()],n,void 0,t),i=R(await this._rpcRequest(`getConfirmedSignaturesForAddress2`,r),Ic);if(`error`in i)throw new X(i.error,`failed to get confirmed signatures for address`);return i.result}async getSignaturesForAddress(e,t,n){let r=this._buildArgsAtLeastConfirmed([e.toBase58()],n,void 0,t),i=R(await this._rpcRequest(`getSignaturesForAddress`,r),Lc);if(`error`in i)throw new X(i.error,`failed to get signatures for address`);return i.result}async getAddressLookupTable(e,t){let{context:n,value:r}=await this.getAccountInfoAndContext(e,t),i=null;return r!==null&&(i=new Is({key:e,state:Is.deserialize(r.data)})),{context:n,value:i}}async getNonceAndContext(e,t){let{context:n,value:r}=await this.getAccountInfoAndContext(e,t),i=null;return r!==null&&(i=ms.fromAccountData(r.data)),{context:n,value:i}}async getNonce(e,t){return await this.getNonceAndContext(e,t).then(e=>e.value).catch(t=>{throw Error(`failed to get nonce for account `+e.toBase58()+`: `+t)})}async requestAirdrop(e,t){let n=R(await this._rpcRequest(`requestAirdrop`,[e.toBase58(),t]),Dl);if(`error`in n)throw new X(n.error,`airdrop to ${e.toBase58()} failed`);return n.result}async _blockhashWithExpiryBlockHeight(e){if(!e){for(;this._pollingBlockhash;)await us(100);let e=Date.now()-this._blockhashInfo.lastFetch>=Us;if(this._blockhashInfo.latestBlockhash!==null&&!e)return this._blockhashInfo.latestBlockhash}return await this._pollNewBlockhash()}async _pollNewBlockhash(){this._pollingBlockhash=!0;try{let e=Date.now(),t=this._blockhashInfo.latestBlockhash,n=t?t.blockhash:null;for(let e=0;e<50;e++){let e=await this.getLatestBlockhash(`finalized`);if(n!==e.blockhash)return this._blockhashInfo={latestBlockhash:e,lastFetch:Date.now(),transactionSignatures:[],simulatedSignatures:[]},e;await us(Zo/2)}throw Error(`Unable to obtain a new blockhash after ${Date.now()-e}ms`)}finally{this._pollingBlockhash=!1}}async getStakeMinimumDelegation(e){let{commitment:t,config:n}=Gs(e),r=this._buildArgs([],t,`base64`,n),i=R(await this._rpcRequest(`getStakeMinimumDelegation`,r),Ys(V()));if(`error`in i)throw new X(i.error,`failed to get stake minimum delegation`);return i.result}async simulateTransaction(e,t,n){if(`message`in e){let r=e.serialize(),i=I.Buffer.from(r).toString(`base64`);if(Array.isArray(t)||n!==void 0)throw Error(`Invalid arguments`);let a=t||{};a.encoding=`base64`,`commitment`in a||(a.commitment=this.commitment),t&&typeof t==`object`&&`innerInstructions`in t&&(a.innerInstructions=t.innerInstructions);let o=[i,a],s=R(await this._rpcRequest(`simulateTransaction`,o),dc);if(`error`in s)throw Error(`failed to simulate transaction: `+s.error.message);return s.result}let r;if(e instanceof Y){let t=e;r=new Y,r.feePayer=t.feePayer,r.instructions=e.instructions,r.nonceInfo=t.nonceInfo,r.signatures=t.signatures}else r=Y.populate(e),r._message=r._json=void 0;if(t!==void 0&&!Array.isArray(t))throw Error(`Invalid arguments`);let i=t;if(r.nonceInfo&&i)r.sign(...i);else{let e=this._disableBlockhashCaching;for(;;){let t=await this._blockhashWithExpiryBlockHeight(e);if(r.lastValidBlockHeight=t.lastValidBlockHeight,r.recentBlockhash=t.blockhash,!i)break;if(r.sign(...i),!r.signature)throw Error(`!signature`);let n=r.signature.toString(`base64`);if(!this._blockhashInfo.simulatedSignatures.includes(n)&&!this._blockhashInfo.transactionSignatures.includes(n)){this._blockhashInfo.simulatedSignatures.push(n);break}else e=!0}}let a=r._compile(),o=a.serialize(),s=r._serialize(o).toString(`base64`),c={encoding:`base64`,commitment:this.commitment};n&&(c.accounts={encoding:`base64`,addresses:(Array.isArray(n)?n:a.nonProgramIds()).map(e=>e.toBase58())}),i&&(c.sigVerify=!0),t&&typeof t==`object`&&`innerInstructions`in t&&(c.innerInstructions=t.innerInstructions);let l=[s,c],u=R(await this._rpcRequest(`simulateTransaction`,l),dc);if(`error`in u){let e;if(`data`in u.error&&(e=u.error.data.logs,e&&Array.isArray(e))){let t=`
|
|
2
2
|
`,n=t+e.join(t);console.error(u.error.message,n)}throw new ss({action:`simulate`,signature:``,transactionMessage:u.error.message,logs:e})}return u.result}async sendTransaction(e,t,n){if(`version`in e){if(t&&Array.isArray(t))throw Error(`Invalid arguments`);let n=e.serialize();return await this.sendRawTransaction(n,t)}if(t===void 0||!Array.isArray(t))throw Error(`Invalid arguments`);let r=t;if(e.nonceInfo)e.sign(...r);else{let t=this._disableBlockhashCaching;for(;;){let n=await this._blockhashWithExpiryBlockHeight(t);if(e.lastValidBlockHeight=n.lastValidBlockHeight,e.recentBlockhash=n.blockhash,e.sign(...r),!e.signature)throw Error(`!signature`);let i=e.signature.toString(`base64`);if(this._blockhashInfo.transactionSignatures.includes(i))t=!0;else{this._blockhashInfo.transactionSignatures.push(i);break}}}let i=e.serialize();return await this.sendRawTransaction(i,n)}async sendRawTransaction(e,t){let n=G(e).toString(`base64`);return await this.sendEncodedTransaction(n,t)}async sendEncodedTransaction(e,t){let n={encoding:`base64`},r=t&&t.skipPreflight,i=r===!0?`processed`:t&&t.preflightCommitment||this.commitment;t&&t.maxRetries!=null&&(n.maxRetries=t.maxRetries),t&&t.minContextSlot!=null&&(n.minContextSlot=t.minContextSlot),r&&(n.skipPreflight=r),i&&(n.preflightCommitment=i);let a=[e,n],o=R(await this._rpcRequest(`sendTransaction`,a),Ol);if(`error`in o){let e;throw`data`in o.error&&(e=o.error.data.logs),new ss({action:r?`send`:`simulate`,signature:``,transactionMessage:o.error.message,logs:e})}return o.result}_wsOnOpen(){this._rpcWebSocketConnected=!0,this._rpcWebSocketHeartbeat=setInterval(()=>{(async()=>{try{await this._rpcWebSocket.notify(`ping`)}catch{}})()},5e3),this._updateSubscriptions()}_wsOnError(e){this._rpcWebSocketConnected=!1,console.error(`ws error:`,e.message)}_wsOnClose(e){if(this._rpcWebSocketConnected=!1,this._rpcWebSocketGeneration=(this._rpcWebSocketGeneration+1)%(2**53-1),this._rpcWebSocketIdleTimeout&&=(clearTimeout(this._rpcWebSocketIdleTimeout),null),this._rpcWebSocketHeartbeat&&=(clearInterval(this._rpcWebSocketHeartbeat),null),e===1e3){this._updateSubscriptions();return}this._subscriptionCallbacksByServerSubscriptionId={},Object.entries(this._subscriptionsByHash).forEach(([e,t])=>{this._setSubscription(e,{...t,state:`pending`})})}_setSubscription(e,t){let n=this._subscriptionsByHash[e]?.state;if(this._subscriptionsByHash[e]=t,n!==t.state){let n=this._subscriptionStateChangeCallbacksByHash[e];n&&n.forEach(e=>{try{e(t.state)}catch{}})}}_onSubscriptionStateChange(e,t){let n=this._subscriptionHashByClientSubscriptionId[e];if(n==null)return()=>{};let r=this._subscriptionStateChangeCallbacksByHash[n]||=new Set;return r.add(t),()=>{r.delete(t),r.size===0&&delete this._subscriptionStateChangeCallbacksByHash[n]}}async _updateSubscriptions(){if(Object.keys(this._subscriptionsByHash).length===0){this._rpcWebSocketConnected&&(this._rpcWebSocketConnected=!1,this._rpcWebSocketIdleTimeout=setTimeout(()=>{this._rpcWebSocketIdleTimeout=null;try{this._rpcWebSocket.close()}catch(e){e instanceof Error&&console.log(`Error when closing socket connection: ${e.message}`)}},500));return}if(this._rpcWebSocketIdleTimeout!==null&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketConnected=!0),!this._rpcWebSocketConnected){this._rpcWebSocket.connect();return}let e=this._rpcWebSocketGeneration,t=()=>e===this._rpcWebSocketGeneration;await Promise.all(Object.keys(this._subscriptionsByHash).map(async e=>{let n=this._subscriptionsByHash[e];if(n!==void 0)switch(n.state){case`pending`:case`unsubscribed`:if(n.callbacks.size===0){delete this._subscriptionsByHash[e],n.state===`unsubscribed`&&delete this._subscriptionCallbacksByServerSubscriptionId[n.serverSubscriptionId],await this._updateSubscriptions();return}await(async()=>{let{args:r,method:i}=n;try{this._setSubscription(e,{...n,state:`subscribing`});let t=await this._rpcWebSocket.call(i,r);this._setSubscription(e,{...n,serverSubscriptionId:t,state:`subscribed`}),this._subscriptionCallbacksByServerSubscriptionId[t]=n.callbacks,await this._updateSubscriptions()}catch(a){if(console.error(`Received ${a instanceof Error?``:`JSON-RPC `}error calling \`${i}\``,{args:r,error:a}),!t())return;this._setSubscription(e,{...n,state:`pending`}),await this._updateSubscriptions()}})();break;case`subscribed`:n.callbacks.size===0&&await(async()=>{let{serverSubscriptionId:r,unsubscribeMethod:i}=n;if(this._subscriptionsAutoDisposedByRpc.has(r))this._subscriptionsAutoDisposedByRpc.delete(r);else{this._setSubscription(e,{...n,state:`unsubscribing`}),this._setSubscription(e,{...n,state:`unsubscribing`});try{await this._rpcWebSocket.call(i,[r])}catch(r){if(r instanceof Error&&console.error(`${i} error:`,r.message),!t())return;this._setSubscription(e,{...n,state:`subscribed`}),await this._updateSubscriptions();return}}this._setSubscription(e,{...n,state:`unsubscribed`}),await this._updateSubscriptions()})();break}}))}_handleServerNotification(e,t){let n=this._subscriptionCallbacksByServerSubscriptionId[e];n!==void 0&&n.forEach(e=>{try{e(...t)}catch(e){console.error(e)}})}_wsOnAccountNotification(e){let{result:t,subscription:n}=R(e,Rc);this._handleServerNotification(n,[t.value,t.context])}_makeSubscription(e,t){let n=this._nextClientSubscriptionId++,r=Ds([e.method,t]),i=this._subscriptionsByHash[r];return i===void 0?this._subscriptionsByHash[r]={...e,args:t,callbacks:new Set([e.callback]),state:`pending`}:i.callbacks.add(e.callback),this._subscriptionHashByClientSubscriptionId[n]=r,this._subscriptionDisposeFunctionsByClientSubscriptionId[n]=async()=>{delete this._subscriptionDisposeFunctionsByClientSubscriptionId[n],delete this._subscriptionHashByClientSubscriptionId[n];let t=this._subscriptionsByHash[r];J(t!==void 0,`Could not find a \`Subscription\` when tearing down client subscription #${n}`),t.callbacks.delete(e.callback),await this._updateSubscriptions()},this._updateSubscriptions(),n}onAccountChange(e,t,n){let{commitment:r,config:i}=Gs(n),a=this._buildArgs([e.toBase58()],r||this._commitment||`finalized`,`base64`,i);return this._makeSubscription({callback:t,method:`accountSubscribe`,unsubscribeMethod:`accountUnsubscribe`},a)}async removeAccountChangeListener(e){await this._unsubscribeClientSubscription(e,`account change`)}_wsOnProgramAccountNotification(e){let{result:t,subscription:n}=R(e,Bc);this._handleServerNotification(n,[{accountId:t.value.pubkey,accountInfo:t.value.account},t.context])}onProgramAccountChange(e,t,n,r){let{commitment:i,config:a}=Gs(n),o=this._buildArgs([e.toBase58()],i||this._commitment||`finalized`,`base64`,a||(r?{filters:Ks(r)}:void 0));return this._makeSubscription({callback:t,method:`programSubscribe`,unsubscribeMethod:`programUnsubscribe`},o)}async removeProgramAccountChangeListener(e){await this._unsubscribeClientSubscription(e,`program account change`)}onLogs(e,t,n){let r=this._buildArgs([typeof e==`object`?{mentions:[e.toString()]}:e],n||this._commitment||`finalized`);return this._makeSubscription({callback:t,method:`logsSubscribe`,unsubscribeMethod:`logsUnsubscribe`},r)}async removeOnLogsListener(e){await this._unsubscribeClientSubscription(e,`logs`)}_wsOnLogsNotification(e){let{result:t,subscription:n}=R(e,kl);this._handleServerNotification(n,[t.value,t.context])}_wsOnSlotNotification(e){let{result:t,subscription:n}=R(e,Hc);this._handleServerNotification(n,[t])}onSlotChange(e){return this._makeSubscription({callback:e,method:`slotSubscribe`,unsubscribeMethod:`slotUnsubscribe`},[])}async removeSlotChangeListener(e){await this._unsubscribeClientSubscription(e,`slot change`)}_wsOnSlotUpdatesNotification(e){let{result:t,subscription:n}=R(e,Wc);this._handleServerNotification(n,[t])}onSlotUpdate(e){return this._makeSubscription({callback:e,method:`slotsUpdatesSubscribe`,unsubscribeMethod:`slotsUpdatesUnsubscribe`},[])}async removeSlotUpdateListener(e){await this._unsubscribeClientSubscription(e,`slot update`)}async _unsubscribeClientSubscription(e,t){let n=this._subscriptionDisposeFunctionsByClientSubscriptionId[e];n?await n():console.warn(`Ignored unsubscribe request because an active subscription with id \`${e}\` for '${t}' events could not be found.`)}_buildArgs(e,t,n,r){let i=t||this._commitment;if(i||n||r){let t={};n&&(t.encoding=n),i&&(t.commitment=i),r&&(t=Object.assign(t,r)),e.push(t)}return e}_buildArgsAtLeastConfirmed(e,t,n,r){let i=t||this._commitment;if(i&&![`confirmed`,`finalized`].includes(i))throw Error("Using Connection with default commitment: `"+this._commitment+"`, but method requires at least `confirmed`");return this._buildArgs(e,t,n,r)}_wsOnSignatureNotification(e){let{result:t,subscription:n}=R(e,Gc);t.value!==`receivedSignature`&&this._subscriptionsAutoDisposedByRpc.add(n),this._handleServerNotification(n,t.value===`receivedSignature`?[{type:`received`},t.context]:[{type:`status`,result:t.value},t.context])}onSignature(e,t,n){let r=this._buildArgs([e],n||this._commitment||`finalized`),i=this._makeSubscription({callback:(e,n)=>{if(e.type===`status`){t(e.result,n);try{this.removeSignatureListener(i)}catch{}}},method:`signatureSubscribe`,unsubscribeMethod:`signatureUnsubscribe`},r);return i}onSignatureWithOptions(e,t,n){let{commitment:r,...i}={...n,commitment:n&&n.commitment||this._commitment||`finalized`},a=this._buildArgs([e],r,void 0,i),o=this._makeSubscription({callback:(e,n)=>{t(e,n);try{this.removeSignatureListener(o)}catch{}},method:`signatureSubscribe`,unsubscribeMethod:`signatureUnsubscribe`},a);return o}async removeSignatureListener(e){await this._unsubscribeClientSubscription(e,`signature result`)}_wsOnRootNotification(e){let{result:t,subscription:n}=R(e,Kc);this._handleServerNotification(n,[t])}onRootChange(e){return this._makeSubscription({callback:e,method:`rootSubscribe`,unsubscribeMethod:`rootUnsubscribe`},[])}async removeRootChangeListener(e){await this._unsubscribeClientSubscription(e,`root change`)}},Ml=class e{constructor(e){this._keypair=void 0,this._keypair=e??uo()}static generate(){return new e(uo())}static fromSecretKey(t,n){if(t.byteLength!==64)throw Error(`bad secret key size`);let r=t.slice(32,64);if(!n||!n.skipValidation){let e=fo(t.slice(0,32));for(let t=0;t<32;t++)if(r[t]!==e[t])throw Error(`provided secretKey is invalid`)}return new e({publicKey:r,secretKey:t})}static fromSeed(t){let n=fo(t),r=new Uint8Array(64);return r.set(t),r.set(n,32),new e({publicKey:n,secretKey:r})}get publicKey(){return new K(this._keypair.publicKey)}get secretKey(){return new Uint8Array(this._keypair.secretKey)}},Nl=Object.freeze({CreateLookupTable:{index:0,layout:L.struct([L.u32(`instruction`),hs(`recentSlot`),L.u8(`bumpSeed`)])},FreezeLookupTable:{index:1,layout:L.struct([L.u32(`instruction`)])},ExtendLookupTable:{index:2,layout:L.struct([L.u32(`instruction`),hs(),L.seq(q(),L.offset(L.u32(),-8),`addresses`)])},DeactivateLookupTable:{index:3,layout:L.struct([L.u32(`instruction`)])},CloseLookupTable:{index:4,layout:L.struct([L.u32(`instruction`)])}}),Pl=class{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);let t=L.u32(`instruction`).decode(e.data),n;for(let[e,r]of Object.entries(Nl))if(r.index==t){n=e;break}if(!n)throw Error(`Invalid Instruction. Should be a LookupTable Instruction`);return n}static decodeCreateLookupTable(e){this.checkProgramId(e.programId),this.checkKeysLength(e.keys,4);let{recentSlot:t}=Q(Nl.CreateLookupTable,e.data);return{authority:e.keys[1].pubkey,payer:e.keys[2].pubkey,recentSlot:Number(t)}}static decodeExtendLookupTable(e){if(this.checkProgramId(e.programId),e.keys.length<2)throw Error(`invalid instruction; found ${e.keys.length} keys, expected at least 2`);let{addresses:t}=Q(Nl.ExtendLookupTable,e.data);return{lookupTable:e.keys[0].pubkey,authority:e.keys[1].pubkey,payer:e.keys.length>2?e.keys[2].pubkey:void 0,addresses:t.map(e=>new K(e))}}static decodeCloseLookupTable(e){return this.checkProgramId(e.programId),this.checkKeysLength(e.keys,3),{lookupTable:e.keys[0].pubkey,authority:e.keys[1].pubkey,recipient:e.keys[2].pubkey}}static decodeFreezeLookupTable(e){return this.checkProgramId(e.programId),this.checkKeysLength(e.keys,2),{lookupTable:e.keys[0].pubkey,authority:e.keys[1].pubkey}}static decodeDeactivateLookupTable(e){return this.checkProgramId(e.programId),this.checkKeysLength(e.keys,2),{lookupTable:e.keys[0].pubkey,authority:e.keys[1].pubkey}}static checkProgramId(e){if(!e.equals(Fl.programId))throw Error(`invalid instruction; programId is not AddressLookupTable Program`)}static checkKeysLength(e,t){if(e.length<t)throw Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}},Fl=class{constructor(){}static createLookupTable(e){let[t,n]=K.findProgramAddressSync([e.authority.toBuffer(),ti().encode(e.recentSlot)],this.programId),r=Nl.CreateLookupTable,i=Z(r,{recentSlot:BigInt(e.recentSlot),bumpSeed:n}),a=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1},{pubkey:e.payer,isSigner:!0,isWritable:!0},{pubkey:vs.programId,isSigner:!1,isWritable:!1}];return[new Jo({programId:this.programId,keys:a,data:i}),t]}static freezeLookupTable(e){let t=Nl.FreezeLookupTable,n=Z(t),r=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return new Jo({programId:this.programId,keys:r,data:n})}static extendLookupTable(e){let t=Nl.ExtendLookupTable,n=Z(t,{addresses:e.addresses.map(e=>e.toBytes())}),r=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return e.payer&&r.push({pubkey:e.payer,isSigner:!0,isWritable:!0},{pubkey:vs.programId,isSigner:!1,isWritable:!1}),new Jo({programId:this.programId,keys:r,data:n})}static deactivateLookupTable(e){let t=Nl.DeactivateLookupTable,n=Z(t),r=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return new Jo({programId:this.programId,keys:r,data:n})}static closeLookupTable(e){let t=Nl.CloseLookupTable,n=Z(t),r=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1},{pubkey:e.recipient,isSigner:!1,isWritable:!0}];return new Jo({programId:this.programId,keys:r,data:n})}};Fl.programId=new K(`AddressLookupTab1e1111111111111111111111111`);var Il=class{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);let t=L.u8(`instruction`).decode(e.data),n;for(let[e,r]of Object.entries(Ll))if(r.index==t){n=e;break}if(!n)throw Error(`Instruction type incorrect; not a ComputeBudgetInstruction`);return n}static decodeRequestUnits(e){this.checkProgramId(e.programId);let{units:t,additionalFee:n}=Q(Ll.RequestUnits,e.data);return{units:t,additionalFee:n}}static decodeRequestHeapFrame(e){this.checkProgramId(e.programId);let{bytes:t}=Q(Ll.RequestHeapFrame,e.data);return{bytes:t}}static decodeSetComputeUnitLimit(e){this.checkProgramId(e.programId);let{units:t}=Q(Ll.SetComputeUnitLimit,e.data);return{units:t}}static decodeSetComputeUnitPrice(e){this.checkProgramId(e.programId);let{microLamports:t}=Q(Ll.SetComputeUnitPrice,e.data);return{microLamports:t}}static checkProgramId(e){if(!e.equals(Rl.programId))throw Error(`invalid instruction; programId is not ComputeBudgetProgram`)}},Ll=Object.freeze({RequestUnits:{index:0,layout:L.struct([L.u8(`instruction`),L.u32(`units`),L.u32(`additionalFee`)])},RequestHeapFrame:{index:1,layout:L.struct([L.u8(`instruction`),L.u32(`bytes`)])},SetComputeUnitLimit:{index:2,layout:L.struct([L.u8(`instruction`),L.u32(`units`)])},SetComputeUnitPrice:{index:3,layout:L.struct([L.u8(`instruction`),hs(`microLamports`)])}}),Rl=class{constructor(){}static requestUnits(e){let t=Ll.RequestUnits,n=Z(t,e);return new Jo({keys:[],programId:this.programId,data:n})}static requestHeapFrame(e){let t=Ll.RequestHeapFrame,n=Z(t,e);return new Jo({keys:[],programId:this.programId,data:n})}static setComputeUnitLimit(e){let t=Ll.SetComputeUnitLimit,n=Z(t,e);return new Jo({keys:[],programId:this.programId,data:n})}static setComputeUnitPrice(e){let t=Ll.SetComputeUnitPrice,n=Z(t,{microLamports:BigInt(e.microLamports)});return new Jo({keys:[],programId:this.programId,data:n})}};Rl.programId=new K(`ComputeBudget111111111111111111111111111111`);var zl=64,Bl=32,Vl=64,Hl=L.struct([L.u8(`numSignatures`),L.u8(`padding`),L.u16(`signatureOffset`),L.u16(`signatureInstructionIndex`),L.u16(`publicKeyOffset`),L.u16(`publicKeyInstructionIndex`),L.u16(`messageDataOffset`),L.u16(`messageDataSize`),L.u16(`messageInstructionIndex`)]),Ul=class e{constructor(){}static createInstructionWithPublicKey(t){let{publicKey:n,message:r,signature:i,instructionIndex:a}=t;J(n.length===Bl,`Public Key must be ${Bl} bytes but received ${n.length} bytes`),J(i.length===Vl,`Signature must be ${Vl} bytes but received ${i.length} bytes`);let o=Hl.span,s=o+n.length,c=s+i.length,l=I.Buffer.alloc(c+r.length),u=a??65535;return Hl.encode({numSignatures:1,padding:0,signatureOffset:s,signatureInstructionIndex:u,publicKeyOffset:o,publicKeyInstructionIndex:u,messageDataOffset:c,messageDataSize:r.length,messageInstructionIndex:u},l),l.fill(n,o),l.fill(i,s),l.fill(r,c),new Jo({keys:[],programId:e.programId,data:l})}static createInstructionWithPrivateKey(e){let{privateKey:t,message:n,instructionIndex:r}=e;J(t.length===zl,`Private key must be ${zl} bytes but received ${t.length} bytes`);try{let e=Ml.fromSecretKey(t),i=e.publicKey.toBytes(),a=mo(n,e.secretKey);return this.createInstructionWithPublicKey({publicKey:i,message:n,signature:a,instructionIndex:r})}catch(e){throw Error(`Error creating instruction; ${e}`)}}};Ul.programId=new K(`Ed25519SigVerify111111111111111111111111111`);var Wl=(e,t)=>{let n=so.sign(e,t);return[n.toCompactRawBytes(),n.recovery]};so.utils.isValidPrivateKey;var Gl=so.getPublicKey,Kl=32,ql=20,Jl=64,Yl=L.struct([L.u8(`numSignatures`),L.u16(`signatureOffset`),L.u8(`signatureInstructionIndex`),L.u16(`ethAddressOffset`),L.u8(`ethAddressInstructionIndex`),L.u16(`messageDataOffset`),L.u16(`messageDataSize`),L.u8(`messageInstructionIndex`),L.blob(20,`ethAddress`),L.blob(64,`signature`),L.u8(`recoveryId`)]),Xl=class e{constructor(){}static publicKeyToEthAddress(e){J(e.length===Jl,`Public key must be ${Jl} bytes but received ${e.length} bytes`);try{return I.Buffer.from(Fe(G(e))).slice(-20)}catch(e){throw Error(`Error constructing Ethereum address: ${e}`)}}static createInstructionWithPublicKey(t){let{publicKey:n,message:r,signature:i,recoveryId:a,instructionIndex:o}=t;return e.createInstructionWithEthAddress({ethAddress:e.publicKeyToEthAddress(n),message:r,signature:i,recoveryId:a,instructionIndex:o})}static createInstructionWithEthAddress(t){let{ethAddress:n,message:r,signature:i,recoveryId:a,instructionIndex:o=0}=t,s;s=typeof n==`string`?n.startsWith(`0x`)?I.Buffer.from(n.substr(2),`hex`):I.Buffer.from(n,`hex`):n,J(s.length===ql,`Address must be ${ql} bytes but received ${s.length} bytes`);let c=12+s.length,l=c+i.length+1,u=I.Buffer.alloc(Yl.span+r.length);return Yl.encode({numSignatures:1,signatureOffset:c,signatureInstructionIndex:o,ethAddressOffset:12,ethAddressInstructionIndex:o,messageDataOffset:l,messageDataSize:r.length,messageInstructionIndex:o,signature:G(i),ethAddress:G(s),recoveryId:a},u),u.fill(G(r),Yl.span),new Jo({keys:[],programId:e.programId,data:u})}static createInstructionWithPrivateKey(e){let{privateKey:t,message:n,instructionIndex:r}=e;J(t.length===Kl,`Private key must be ${Kl} bytes but received ${t.length} bytes`);try{let e=G(t),i=Gl(e,!1).slice(1),[a,o]=Wl(I.Buffer.from(Fe(G(n))),e);return this.createInstructionWithPublicKey({publicKey:i,message:n,signature:a,recoveryId:o,instructionIndex:r})}catch(e){throw Error(`Error creating instruction; ${e}`)}}};Xl.programId=new K(`KeccakSecp256k11111111111111111111111111111`);var Zl,Ql=new K(`StakeConfig11111111111111111111111111111111`),$l=class{constructor(e,t){this.staker=void 0,this.withdrawer=void 0,this.staker=e,this.withdrawer=t}},eu=class{constructor(e,t,n){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=e,this.epoch=t,this.custodian=n}};Zl=eu,eu.default=new Zl(0,0,K.default);var tu=class{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);let t=L.u32(`instruction`).decode(e.data),n;for(let[e,r]of Object.entries(nu))if(r.index==t){n=e;break}if(!n)throw Error(`Instruction type incorrect; not a StakeInstruction`);return n}static decodeInitialize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);let{authorized:t,lockup:n}=Q(nu.Initialize,e.data);return{stakePubkey:e.keys[0].pubkey,authorized:new $l(new K(t.staker),new K(t.withdrawer)),lockup:new eu(n.unixTimestamp,n.epoch,new K(n.custodian))}}static decodeDelegate(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,6),Q(nu.Delegate,e.data),{stakePubkey:e.keys[0].pubkey,votePubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[5].pubkey}}static decodeAuthorize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);let{newAuthorized:t,stakeAuthorizationType:n}=Q(nu.Authorize,e.data),r={stakePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey,newAuthorizedPubkey:new K(t),stakeAuthorizationType:{index:n}};return e.keys.length>3&&(r.custodianPubkey=e.keys[3].pubkey),r}static decodeAuthorizeWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);let{newAuthorized:t,stakeAuthorizationType:n,authoritySeed:r,authorityOwner:i}=Q(nu.AuthorizeWithSeed,e.data),a={stakePubkey:e.keys[0].pubkey,authorityBase:e.keys[1].pubkey,authoritySeed:r,authorityOwner:new K(i),newAuthorizedPubkey:new K(t),stakeAuthorizationType:{index:n}};return e.keys.length>3&&(a.custodianPubkey=e.keys[3].pubkey),a}static decodeSplit(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);let{lamports:t}=Q(nu.Split,e.data);return{stakePubkey:e.keys[0].pubkey,splitStakePubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[2].pubkey,lamports:t}}static decodeMerge(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3),Q(nu.Merge,e.data),{stakePubkey:e.keys[0].pubkey,sourceStakePubKey:e.keys[1].pubkey,authorizedPubkey:e.keys[4].pubkey}}static decodeWithdraw(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,5);let{lamports:t}=Q(nu.Withdraw,e.data),n={stakePubkey:e.keys[0].pubkey,toPubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[4].pubkey,lamports:t};return e.keys.length>5&&(n.custodianPubkey=e.keys[5].pubkey),n}static decodeDeactivate(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3),Q(nu.Deactivate,e.data),{stakePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey}}static checkProgramId(e){if(!e.equals(iu.programId))throw Error(`invalid instruction; programId is not StakeProgram`)}static checkKeyLength(e,t){if(e.length<t)throw Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}},nu=Object.freeze({Initialize:{index:0,layout:L.struct([L.u32(`instruction`),Mo(),No()])},Authorize:{index:1,layout:L.struct([L.u32(`instruction`),q(`newAuthorized`),L.u32(`stakeAuthorizationType`)])},Delegate:{index:2,layout:L.struct([L.u32(`instruction`)])},Split:{index:3,layout:L.struct([L.u32(`instruction`),L.ns64(`lamports`)])},Withdraw:{index:4,layout:L.struct([L.u32(`instruction`),L.ns64(`lamports`)])},Deactivate:{index:5,layout:L.struct([L.u32(`instruction`)])},Merge:{index:7,layout:L.struct([L.u32(`instruction`)])},AuthorizeWithSeed:{index:8,layout:L.struct([L.u32(`instruction`),q(`newAuthorized`),L.u32(`stakeAuthorizationType`),jo(`authoritySeed`),q(`authorityOwner`)])}}),ru=Object.freeze({Staker:{index:0},Withdrawer:{index:1}}),iu=class{constructor(){}static initialize(e){let{stakePubkey:t,authorized:n,lockup:r}=e,i=r||eu.default,a=nu.Initialize,o=Z(a,{authorized:{staker:G(n.staker.toBuffer()),withdrawer:G(n.withdrawer.toBuffer())},lockup:{unixTimestamp:i.unixTimestamp,epoch:i.epoch,custodian:G(i.custodian.toBuffer())}});return new Jo({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:ns,isSigner:!1,isWritable:!1}],programId:this.programId,data:o})}static createAccountWithSeed(e){let t=new Y;t.add(vs.createAccountWithSeed({fromPubkey:e.fromPubkey,newAccountPubkey:e.stakePubkey,basePubkey:e.basePubkey,seed:e.seed,lamports:e.lamports,space:this.space,programId:this.programId}));let{stakePubkey:n,authorized:r,lockup:i}=e;return t.add(this.initialize({stakePubkey:n,authorized:r,lockup:i}))}static createAccount(e){let t=new Y;t.add(vs.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.stakePubkey,lamports:e.lamports,space:this.space,programId:this.programId}));let{stakePubkey:n,authorized:r,lockup:i}=e;return t.add(this.initialize({stakePubkey:n,authorized:r,lockup:i}))}static delegate(e){let{stakePubkey:t,authorizedPubkey:n,votePubkey:r}=e,i=nu.Delegate,a=Z(i);return new Y().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!1},{pubkey:Qo,isSigner:!1,isWritable:!1},{pubkey:os,isSigner:!1,isWritable:!1},{pubkey:Ql,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:a})}static authorize(e){let{stakePubkey:t,authorizedPubkey:n,newAuthorizedPubkey:r,stakeAuthorizationType:i,custodianPubkey:a}=e,o=nu.Authorize,s=Z(o,{newAuthorized:G(r.toBuffer()),stakeAuthorizationType:i.index}),c=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:Qo,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}];return a&&c.push({pubkey:a,isSigner:!0,isWritable:!1}),new Y().add({keys:c,programId:this.programId,data:s})}static authorizeWithSeed(e){let{stakePubkey:t,authorityBase:n,authoritySeed:r,authorityOwner:i,newAuthorizedPubkey:a,stakeAuthorizationType:o,custodianPubkey:s}=e,c=nu.AuthorizeWithSeed,l=Z(c,{newAuthorized:G(a.toBuffer()),stakeAuthorizationType:o.index,authoritySeed:r,authorityOwner:G(i.toBuffer())}),u=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1},{pubkey:Qo,isSigner:!1,isWritable:!1}];return s&&u.push({pubkey:s,isSigner:!0,isWritable:!1}),new Y().add({keys:u,programId:this.programId,data:l})}static splitInstruction(e){let{stakePubkey:t,authorizedPubkey:n,splitStakePubkey:r,lamports:i}=e,a=nu.Split,o=Z(a,{lamports:i});return new Jo({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:o})}static split(e,t){let n=new Y;return n.add(vs.createAccount({fromPubkey:e.authorizedPubkey,newAccountPubkey:e.splitStakePubkey,lamports:t,space:this.space,programId:this.programId})),n.add(this.splitInstruction(e))}static splitWithSeed(e,t){let{stakePubkey:n,authorizedPubkey:r,splitStakePubkey:i,basePubkey:a,seed:o,lamports:s}=e,c=new Y;return c.add(vs.allocate({accountPubkey:i,basePubkey:a,seed:o,space:this.space,programId:this.programId})),t&&t>0&&c.add(vs.transfer({fromPubkey:e.authorizedPubkey,toPubkey:i,lamports:t})),c.add(this.splitInstruction({stakePubkey:n,authorizedPubkey:r,splitStakePubkey:i,lamports:s}))}static merge(e){let{stakePubkey:t,sourceStakePubKey:n,authorizedPubkey:r}=e,i=nu.Merge,a=Z(i);return new Y().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!0},{pubkey:Qo,isSigner:!1,isWritable:!1},{pubkey:os,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:a})}static withdraw(e){let{stakePubkey:t,authorizedPubkey:n,toPubkey:r,lamports:i,custodianPubkey:a}=e,o=nu.Withdraw,s=Z(o,{lamports:i}),c=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:Qo,isSigner:!1,isWritable:!1},{pubkey:os,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return a&&c.push({pubkey:a,isSigner:!0,isWritable:!1}),new Y().add({keys:c,programId:this.programId,data:s})}static deactivate(e){let{stakePubkey:t,authorizedPubkey:n}=e,r=nu.Deactivate,i=Z(r);return new Y().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:Qo,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:i})}};iu.programId=new K(`Stake11111111111111111111111111111111111111`),iu.space=200;var au=class{constructor(e,t,n,r){this.nodePubkey=void 0,this.authorizedVoter=void 0,this.authorizedWithdrawer=void 0,this.commission=void 0,this.nodePubkey=e,this.authorizedVoter=t,this.authorizedWithdrawer=n,this.commission=r}},ou=class{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);let t=L.u32(`instruction`).decode(e.data),n;for(let[e,r]of Object.entries(su))if(r.index==t){n=e;break}if(!n)throw Error(`Instruction type incorrect; not a VoteInstruction`);return n}static decodeInitializeAccount(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,4);let{voteInit:t}=Q(su.InitializeAccount,e.data);return{votePubkey:e.keys[0].pubkey,nodePubkey:e.keys[3].pubkey,voteInit:new au(new K(t.nodePubkey),new K(t.authorizedVoter),new K(t.authorizedWithdrawer),t.commission)}}static decodeAuthorize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);let{newAuthorized:t,voteAuthorizationType:n}=Q(su.Authorize,e.data);return{votePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey,newAuthorizedPubkey:new K(t),voteAuthorizationType:{index:n}}}static decodeAuthorizeWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);let{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:t,currentAuthorityDerivedKeySeed:n,newAuthorized:r,voteAuthorizationType:i}}=Q(su.AuthorizeWithSeed,e.data);return{currentAuthorityDerivedKeyBasePubkey:e.keys[2].pubkey,currentAuthorityDerivedKeyOwnerPubkey:new K(t),currentAuthorityDerivedKeySeed:n,newAuthorizedPubkey:new K(r),voteAuthorizationType:{index:i},votePubkey:e.keys[0].pubkey}}static decodeWithdraw(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);let{lamports:t}=Q(su.Withdraw,e.data);return{votePubkey:e.keys[0].pubkey,authorizedWithdrawerPubkey:e.keys[2].pubkey,lamports:t,toPubkey:e.keys[1].pubkey}}static checkProgramId(e){if(!e.equals(lu.programId))throw Error(`invalid instruction; programId is not VoteProgram`)}static checkKeyLength(e,t){if(e.length<t)throw Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}},su=Object.freeze({InitializeAccount:{index:0,layout:L.struct([L.u32(`instruction`),Po()])},Authorize:{index:1,layout:L.struct([L.u32(`instruction`),q(`newAuthorized`),L.u32(`voteAuthorizationType`)])},Withdraw:{index:3,layout:L.struct([L.u32(`instruction`),L.ns64(`lamports`)])},UpdateValidatorIdentity:{index:4,layout:L.struct([L.u32(`instruction`)])},AuthorizeWithSeed:{index:10,layout:L.struct([L.u32(`instruction`),Fo()])}}),cu=Object.freeze({Voter:{index:0},Withdrawer:{index:1}}),lu=class e{constructor(){}static initializeAccount(e){let{votePubkey:t,nodePubkey:n,voteInit:r}=e,i=su.InitializeAccount,a=Z(i,{voteInit:{nodePubkey:G(r.nodePubkey.toBuffer()),authorizedVoter:G(r.authorizedVoter.toBuffer()),authorizedWithdrawer:G(r.authorizedWithdrawer.toBuffer()),commission:r.commission}});return new Jo({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:ns,isSigner:!1,isWritable:!1},{pubkey:Qo,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:a})}static createAccount(e){let t=new Y;return t.add(vs.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.votePubkey,lamports:e.lamports,space:this.space,programId:this.programId})),t.add(this.initializeAccount({votePubkey:e.votePubkey,nodePubkey:e.voteInit.nodePubkey,voteInit:e.voteInit}))}static authorize(e){let{votePubkey:t,authorizedPubkey:n,newAuthorizedPubkey:r,voteAuthorizationType:i}=e,a=su.Authorize,o=Z(a,{newAuthorized:G(r.toBuffer()),voteAuthorizationType:i.index}),s=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:Qo,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return new Y().add({keys:s,programId:this.programId,data:o})}static authorizeWithSeed(e){let{currentAuthorityDerivedKeyBasePubkey:t,currentAuthorityDerivedKeyOwnerPubkey:n,currentAuthorityDerivedKeySeed:r,newAuthorizedPubkey:i,voteAuthorizationType:a,votePubkey:o}=e,s=su.AuthorizeWithSeed,c=Z(s,{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:G(n.toBuffer()),currentAuthorityDerivedKeySeed:r,newAuthorized:G(i.toBuffer()),voteAuthorizationType:a.index}}),l=[{pubkey:o,isSigner:!1,isWritable:!0},{pubkey:Qo,isSigner:!1,isWritable:!1},{pubkey:t,isSigner:!0,isWritable:!1}];return new Y().add({keys:l,programId:this.programId,data:c})}static withdraw(e){let{votePubkey:t,authorizedWithdrawerPubkey:n,lamports:r,toPubkey:i}=e,a=su.Withdraw,o=Z(a,{lamports:r}),s=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}];return new Y().add({keys:s,programId:this.programId,data:o})}static safeWithdraw(t,n,r){if(t.lamports>n-r)throw Error(`Withdraw will leave vote account with insufficient funds.`);return e.withdraw(t)}static updateValidatorIdentity(e){let{votePubkey:t,authorizedWithdrawerPubkey:n,nodePubkey:r}=e,i=su.UpdateValidatorIdentity,a=Z(i),o=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return new Y().add({keys:o,programId:this.programId,data:a})}};lu.programId=new K(`Vote111111111111111111111111111111111111111`),lu.space=3762;var uu=new K(`Va1idator1nfo111111111111111111111111111111`),du=W({name:U(),website:H(U()),details:H(U()),iconUrl:H(U()),keybaseUsername:H(U())}),fu=class e{constructor(e,t){this.key=void 0,this.info=void 0,this.key=e,this.info=t}static fromConfigData(t){let n=[...t];if(Lo(n)!==2)return null;let r=[];for(let e=0;e<2;e++){let e=new K(Ho(n,0,32)),t=Vo(n)===1;r.push({publicKey:e,isSigner:t})}if(r[0].publicKey.equals(uu)&&r[1].isSigner){let t=jo().decode(I.Buffer.from(n)),i=JSON.parse(t);return mi(i,du),new e(r[1].publicKey,i)}return null}},pu=new K(`Vote111111111111111111111111111111111111111`),mu=L.struct([q(`nodePubkey`),q(`authorizedWithdrawer`),L.u8(`commission`),L.nu64(),L.seq(L.struct([L.nu64(`slot`),L.u32(`confirmationCount`)]),L.offset(L.u32(),-8),`votes`),L.u8(`rootSlotValid`),L.nu64(`rootSlot`),L.nu64(),L.seq(L.struct([L.nu64(`epoch`),q(`authorizedVoter`)]),L.offset(L.u32(),-8),`authorizedVoters`),L.struct([L.seq(L.struct([q(`authorizedPubkey`),L.nu64(`epochOfLastAuthorizedSwitch`),L.nu64(`targetEpoch`)]),32,`buf`),L.nu64(`idx`),L.u8(`isEmpty`)],`priorVoters`),L.nu64(),L.seq(L.struct([L.nu64(`epoch`),L.nu64(`credits`),L.nu64(`prevCredits`)]),L.offset(L.u32(),-8),`epochCredits`),L.struct([L.nu64(`slot`),L.nu64(`timestamp`)],`lastTimestamp`)]),hu=class e{constructor(e){this.nodePubkey=void 0,this.authorizedWithdrawer=void 0,this.commission=void 0,this.rootSlot=void 0,this.votes=void 0,this.authorizedVoters=void 0,this.priorVoters=void 0,this.epochCredits=void 0,this.lastTimestamp=void 0,this.nodePubkey=e.nodePubkey,this.authorizedWithdrawer=e.authorizedWithdrawer,this.commission=e.commission,this.rootSlot=e.rootSlot,this.votes=e.votes,this.authorizedVoters=e.authorizedVoters,this.priorVoters=e.priorVoters,this.epochCredits=e.epochCredits,this.lastTimestamp=e.lastTimestamp}static fromAccountData(t){let n=mu.decode(G(t),4),r=n.rootSlot;return n.rootSlotValid||(r=null),new e({nodePubkey:new K(n.nodePubkey),authorizedWithdrawer:new K(n.authorizedWithdrawer),commission:n.commission,votes:n.votes,rootSlot:r,authorizedVoters:n.authorizedVoters.map(gu),priorVoters:vu(n.priorVoters),epochCredits:n.epochCredits,lastTimestamp:n.lastTimestamp})}};function gu({authorizedVoter:e,epoch:t}){return{epoch:t,authorizedVoter:new K(e)}}function _u({authorizedPubkey:e,epochOfLastAuthorizedSwitch:t,targetEpoch:n}){return{authorizedPubkey:new K(e),epochOfLastAuthorizedSwitch:t,targetEpoch:n}}function vu({buf:e,idx:t,isEmpty:n}){return n?[]:[...e.slice(t+1).map(_u),...e.slice(0,t).map(_u)]}var yu={http:{devnet:`http://api.devnet.solana.com`,testnet:`http://api.testnet.solana.com`,"mainnet-beta":`http://api.mainnet-beta.solana.com/`},https:{devnet:`https://api.devnet.solana.com`,testnet:`https://api.testnet.solana.com`,"mainnet-beta":`https://api.mainnet-beta.solana.com/`}};function bu(e,t){let n=t===!1?`http`:`https`;if(!e)return yu[n].devnet;let r=yu[n][e];if(!r)throw Error(`Unknown ${n} cluster: ${e}`);return r}async function xu(e,t,n,r){let i,a;n&&Object.prototype.hasOwnProperty.call(n,`lastValidBlockHeight`)||n&&Object.prototype.hasOwnProperty.call(n,`nonceValue`)?(i=n,a=r):a=n;let o=a&&{skipPreflight:a.skipPreflight,preflightCommitment:a.preflightCommitment||a.commitment,minContextSlot:a.minContextSlot},s=await e.sendRawTransaction(t,o),c=a&&a.commitment,l=(await(i?e.confirmTransaction(i,c):e.confirmTransaction(s,c))).value;if(l.err)throw s==null?Error(`Raw transaction ${s} failed (${JSON.stringify(l)})`):new ss({action:o?.skipPreflight?`send`:`simulate`,signature:s,transactionMessage:`Status: (${JSON.stringify(l)})`});return s}var Su=1e9;export{Xo as a,Go as i,To as n,co as o,Y as r,K as t};
|