/**
 * Skipped minification because the original files appears to be already minified.
 * Original file: /npm/@arcana/auth@1.0.12/dist/standalone/auth.umd.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).arcana=t.arcana||{},t.arcana.auth={}))}(this,(function(t){"use strict";function e(t,e){return e.forEach((function(e){e&&"string"!=typeof e&&!Array.isArray(e)&&Object.keys(e).forEach((function(n){if("default"!==n&&!(n in t)){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}}))})),Object.freeze(t)}function n(t,e,n,r){return new(n||(n=Promise))((function(i,o){function s(t){try{c(r.next(t))}catch(t){o(t)}}function a(t){try{c(r.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function i(t){return t&&Object.prototype.hasOwnProperty.call(t,"default")&&1===Object.keys(t).length?t.default:t}var o={},s={},a=f;f.default=f,f.stable=y,f.stableStringify=y;var c="[...]",u="[Circular]",l=[],h=[];function d(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function f(t,e,n,r){var i;void 0===r&&(r=d()),g(t,"",0,[],void 0,0,r);try{i=0===h.length?JSON.stringify(t,e,n):JSON.stringify(t,w(e),n)}catch(t){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==l.length;){var o=l.pop();4===o.length?Object.defineProperty(o[0],o[1],o[3]):o[0][o[1]]=o[2]}}return i}function p(t,e,n,r){var i=Object.getOwnPropertyDescriptor(r,n);void 0!==i.get?i.configurable?(Object.defineProperty(r,n,{value:t}),l.push([r,n,e,i])):h.push([e,n,t]):(r[n]=t,l.push([r,n,e]))}function g(t,e,n,r,i,o,s){var a;if(o+=1,"object"==typeof t&&null!==t){for(a=0;a<r.length;a++)if(r[a]===t)return void p(u,t,e,i);if(void 0!==s.depthLimit&&o>s.depthLimit)return void p(c,t,e,i);if(void 0!==s.edgesLimit&&n+1>s.edgesLimit)return void p(c,t,e,i);if(r.push(t),Array.isArray(t))for(a=0;a<t.length;a++)g(t[a],a,a,r,t,o,s);else{var l=Object.keys(t);for(a=0;a<l.length;a++){var h=l[a];g(t[h],h,a,r,t,o,s)}}r.pop()}}function m(t,e){return t<e?-1:t>e?1:0}function y(t,e,n,r){void 0===r&&(r=d());var i,o=b(t,"",0,[],void 0,0,r)||t;try{i=0===h.length?JSON.stringify(o,e,n):JSON.stringify(o,w(e),n)}catch(t){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==l.length;){var s=l.pop();4===s.length?Object.defineProperty(s[0],s[1],s[3]):s[0][s[1]]=s[2]}}return i}function b(t,e,n,r,i,o,s){var a;if(o+=1,"object"==typeof t&&null!==t){for(a=0;a<r.length;a++)if(r[a]===t)return void p(u,t,e,i);try{if("function"==typeof t.toJSON)return}catch(t){return}if(void 0!==s.depthLimit&&o>s.depthLimit)return void p(c,t,e,i);if(void 0!==s.edgesLimit&&n+1>s.edgesLimit)return void p(c,t,e,i);if(r.push(t),Array.isArray(t))for(a=0;a<t.length;a++)b(t[a],a,a,r,t,o,s);else{var h={},d=Object.keys(t).sort(m);for(a=0;a<d.length;a++){var f=d[a];b(t[f],f,a,r,t,o,s),h[f]=t[f]}if(void 0===i)return h;l.push([i,e,t]),i[e]=h}r.pop()}}function w(t){return t=void 0!==t?t:function(t,e){return e},function(e,n){if(h.length>0)for(var r=0;r<h.length;r++){var i=h[r];if(i[1]===e&&i[0]===n){n=i[2],h.splice(r,1);break}}return t.call(this,e,n)}}Object.defineProperty(s,"__esModule",{value:!0}),s.EthereumProviderError=s.EthereumRpcError=void 0;const v=a;class _ extends Error{constructor(t,e,n){if(!Number.isInteger(t))throw new Error('"code" must be an integer.');if(!e||"string"!=typeof e)throw new Error('"message" must be a nonempty string.');super(e),this.code=t,void 0!==n&&(this.data=n)}serialize(){const t={code:this.code,message:this.message};return void 0!==this.data&&(t.data=this.data),this.stack&&(t.stack=this.stack),t}toString(){return v.default(this.serialize(),k,2)}}s.EthereumRpcError=_;function k(t,e){if("[Circular]"!==e)return e}s.EthereumProviderError=class extends _{constructor(t,e,n){if(!function(t){return Number.isInteger(t)&&t>=1e3&&t<=4999}(t))throw new Error('"code" must be an integer such that: 1000 <= code <= 4999');super(t,e,n)}};var S={},x={};Object.defineProperty(x,"__esModule",{value:!0}),x.errorValues=x.errorCodes=void 0,x.errorCodes={rpc:{invalidInput:-32e3,resourceNotFound:-32001,resourceUnavailable:-32002,transactionRejected:-32003,methodNotSupported:-32004,limitExceeded:-32005,parse:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internal:-32603},provider:{userRejectedRequest:4001,unauthorized:4100,unsupportedMethod:4200,disconnected:4900,chainDisconnected:4901}},x.errorValues={"-32700":{standard:"JSON RPC 2.0",message:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."},"-32600":{standard:"JSON RPC 2.0",message:"The JSON sent is not a valid Request object."},"-32601":{standard:"JSON RPC 2.0",message:"The method does not exist / is not available."},"-32602":{standard:"JSON RPC 2.0",message:"Invalid method parameter(s)."},"-32603":{standard:"JSON RPC 2.0",message:"Internal JSON-RPC error."},"-32000":{standard:"EIP-1474",message:"Invalid input."},"-32001":{standard:"EIP-1474",message:"Resource not found."},"-32002":{standard:"EIP-1474",message:"Resource unavailable."},"-32003":{standard:"EIP-1474",message:"Transaction rejected."},"-32004":{standard:"EIP-1474",message:"Method not supported."},"-32005":{standard:"EIP-1474",message:"Request limit exceeded."},4001:{standard:"EIP-1193",message:"User rejected the request."},4100:{standard:"EIP-1193",message:"The requested account and/or method has not been authorized by the user."},4200:{standard:"EIP-1193",message:"The requested method is not supported by this Ethereum provider."},4900:{standard:"EIP-1193",message:"The provider is disconnected from all chains."},4901:{standard:"EIP-1193",message:"The provider is disconnected from the specified chain."}},function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.serializeError=t.isValidCode=t.getMessageFromCode=t.JSON_RPC_SERVER_ERROR_MESSAGE=void 0;const e=x,n=s,r=e.errorCodes.rpc.internal,i="Unspecified error message. This is a bug, please report it.",o={code:r,message:a(r)};function a(n,r=i){if(Number.isInteger(n)){const r=n.toString();if(h(e.errorValues,r))return e.errorValues[r].message;if(u(n))return t.JSON_RPC_SERVER_ERROR_MESSAGE}return r}function c(t){if(!Number.isInteger(t))return!1;const n=t.toString();return!!e.errorValues[n]||!!u(t)}function u(t){return t>=-32099&&t<=-32e3}function l(t){return t&&"object"==typeof t&&!Array.isArray(t)?Object.assign({},t):t}function h(t,e){return Object.prototype.hasOwnProperty.call(t,e)}t.JSON_RPC_SERVER_ERROR_MESSAGE="Unspecified server error.",t.getMessageFromCode=a,t.isValidCode=c,t.serializeError=function(t,{fallbackError:e=o,shouldIncludeStack:r=!1}={}){var i,s;if(!e||!Number.isInteger(e.code)||"string"!=typeof e.message)throw new Error("Must provide fallback error with integer number code and string message.");if(t instanceof n.EthereumRpcError)return t.serialize();const u={};if(t&&"object"==typeof t&&!Array.isArray(t)&&h(t,"code")&&c(t.code)){const e=t;u.code=e.code,e.message&&"string"==typeof e.message?(u.message=e.message,h(e,"data")&&(u.data=e.data)):(u.message=a(u.code),u.data={originalError:l(t)})}else{u.code=e.code;const n=null===(i=t)||void 0===i?void 0:i.message;u.message=n&&"string"==typeof n?n:e.message,u.data={originalError:l(t)}}const d=null===(s=t)||void 0===s?void 0:s.stack;return r&&t&&d&&"string"==typeof d&&(u.stack=d),u}}(S);var E={};Object.defineProperty(E,"__esModule",{value:!0}),E.ethErrors=void 0;const I=s,A=S,B=x;function P(t,e){const[n,r]=M(e);return new I.EthereumRpcError(t,n||A.getMessageFromCode(t),r)}function T(t,e){const[n,r]=M(e);return new I.EthereumProviderError(t,n||A.getMessageFromCode(t),r)}function M(t){if(t){if("string"==typeof t)return[t];if("object"==typeof t&&!Array.isArray(t)){const{message:e,data:n}=t;if(e&&"string"!=typeof e)throw new Error("Must specify string message.");return[e||void 0,n]}}return[]}E.ethErrors={rpc:{parse:t=>P(B.errorCodes.rpc.parse,t),invalidRequest:t=>P(B.errorCodes.rpc.invalidRequest,t),invalidParams:t=>P(B.errorCodes.rpc.invalidParams,t),methodNotFound:t=>P(B.errorCodes.rpc.methodNotFound,t),internal:t=>P(B.errorCodes.rpc.internal,t),server:t=>{if(!t||"object"!=typeof t||Array.isArray(t))throw new Error("Ethereum RPC Server errors must provide single object argument.");const{code:e}=t;if(!Number.isInteger(e)||e>-32005||e<-32099)throw new Error('"code" must be an integer such that: -32099 <= code <= -32005');return P(e,t)},invalidInput:t=>P(B.errorCodes.rpc.invalidInput,t),resourceNotFound:t=>P(B.errorCodes.rpc.resourceNotFound,t),resourceUnavailable:t=>P(B.errorCodes.rpc.resourceUnavailable,t),transactionRejected:t=>P(B.errorCodes.rpc.transactionRejected,t),methodNotSupported:t=>P(B.errorCodes.rpc.methodNotSupported,t),limitExceeded:t=>P(B.errorCodes.rpc.limitExceeded,t)},provider:{userRejectedRequest:t=>T(B.errorCodes.provider.userRejectedRequest,t),unauthorized:t=>T(B.errorCodes.provider.unauthorized,t),unsupportedMethod:t=>T(B.errorCodes.provider.unsupportedMethod,t),disconnected:t=>T(B.errorCodes.provider.disconnected,t),chainDisconnected:t=>T(B.errorCodes.provider.chainDisconnected,t),custom:t=>{if(!t||"object"!=typeof t||Array.isArray(t))throw new Error("Ethereum Provider custom errors must provide single object argument.");const{code:e,message:n,data:r}=t;if(!n||"string"!=typeof n)throw new Error('"message" must be a nonempty string');return new I.EthereumProviderError(e,n,r)}}},function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.getMessageFromCode=t.serializeError=t.EthereumProviderError=t.EthereumRpcError=t.ethErrors=t.errorCodes=void 0;const e=s;Object.defineProperty(t,"EthereumRpcError",{enumerable:!0,get:function(){return e.EthereumRpcError}}),Object.defineProperty(t,"EthereumProviderError",{enumerable:!0,get:function(){return e.EthereumProviderError}});const n=S;Object.defineProperty(t,"serializeError",{enumerable:!0,get:function(){return n.serializeError}}),Object.defineProperty(t,"getMessageFromCode",{enumerable:!0,get:function(){return n.getMessageFromCode}});const r=E;Object.defineProperty(t,"ethErrors",{enumerable:!0,get:function(){return r.ethErrors}});const i=x;Object.defineProperty(t,"errorCodes",{enumerable:!0,get:function(){return i.errorCodes}})}(o);var C,O={},R={exports:{}},L="object"==typeof Reflect?Reflect:null,N=L&&"function"==typeof L.apply?L.apply:function(t,e,n){return Function.prototype.apply.call(t,e,n)};C=L&&"function"==typeof L.ownKeys?L.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var U=Number.isNaN||function(t){return t!=t};function z(){z.init.call(this)}R.exports=z,R.exports.once=function(t,e){return new Promise((function(n,r){function i(n){t.removeListener(e,o),r(n)}function o(){"function"==typeof t.removeListener&&t.removeListener("error",i),n([].slice.call(arguments))}G(t,e,o,{once:!0}),"error"!==e&&function(t,e,n){"function"==typeof t.on&&G(t,"error",e,n)}(t,i,{once:!0})}))},z.EventEmitter=z,z.prototype._events=void 0,z.prototype._eventsCount=0,z.prototype._maxListeners=void 0;var $=10;function W(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function F(t){return void 0===t._maxListeners?z.defaultMaxListeners:t._maxListeners}function D(t,e,n,r){var i,o,s,a;if(W(n),void 0===(o=t._events)?(o=t._events=Object.create(null),t._eventsCount=0):(void 0!==o.newListener&&(t.emit("newListener",e,n.listener?n.listener:n),o=t._events),s=o[e]),void 0===s)s=o[e]=n,++t._eventsCount;else if("function"==typeof s?s=o[e]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),(i=F(t))>0&&s.length>i&&!s.warned){s.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=t,c.type=e,c.count=s.length,a=c,console&&console.warn&&console.warn(a)}return t}function j(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function q(t,e,n){var r={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},i=j.bind(r);return i.listener=n,r.wrapFn=i,i}function K(t,e,n){var r=t._events;if(void 0===r)return[];var i=r[e];return void 0===i?[]:"function"==typeof i?n?[i.listener||i]:[i]:n?function(t){for(var e=new Array(t.length),n=0;n<e.length;++n)e[n]=t[n].listener||t[n];return e}(i):V(i,i.length)}function H(t){var e=this._events;if(void 0!==e){var n=e[t];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function V(t,e){for(var n=new Array(e),r=0;r<e;++r)n[r]=t[r];return n}function G(t,e,n,r){if("function"==typeof t.on)r.once?t.once(e,n):t.on(e,n);else{if("function"!=typeof t.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t);t.addEventListener(e,(function i(o){r.once&&t.removeEventListener(e,i),n(o)}))}}Object.defineProperty(z,"defaultMaxListeners",{enumerable:!0,get:function(){return $},set:function(t){if("number"!=typeof t||t<0||U(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");$=t}}),z.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},z.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||U(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this},z.prototype.getMaxListeners=function(){return F(this)},z.prototype.emit=function(t){for(var e=[],n=1;n<arguments.length;n++)e.push(arguments[n]);var r="error"===t,i=this._events;if(void 0!==i)r=r&&void 0===i.error;else if(!r)return!1;if(r){var o;if(e.length>0&&(o=e[0]),o instanceof Error)throw o;var s=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw s.context=o,s}var a=i[t];if(void 0===a)return!1;if("function"==typeof a)N(a,this,e);else{var c=a.length,u=V(a,c);for(n=0;n<c;++n)N(u[n],this,e)}return!0},z.prototype.addListener=function(t,e){return D(this,t,e,!1)},z.prototype.on=z.prototype.addListener,z.prototype.prependListener=function(t,e){return D(this,t,e,!0)},z.prototype.once=function(t,e){return W(e),this.on(t,q(this,t,e)),this},z.prototype.prependOnceListener=function(t,e){return W(e),this.prependListener(t,q(this,t,e)),this},z.prototype.removeListener=function(t,e){var n,r,i,o,s;if(W(e),void 0===(r=this._events))return this;if(void 0===(n=r[t]))return this;if(n===e||n.listener===e)0==--this._eventsCount?this._events=Object.create(null):(delete r[t],r.removeListener&&this.emit("removeListener",t,n.listener||e));else if("function"!=typeof n){for(i=-1,o=n.length-1;o>=0;o--)if(n[o]===e||n[o].listener===e){s=n[o].listener,i=o;break}if(i<0)return this;0===i?n.shift():function(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}(n,i),1===n.length&&(r[t]=n[0]),void 0!==r.removeListener&&this.emit("removeListener",t,s||e)}return this},z.prototype.off=z.prototype.removeListener,z.prototype.removeAllListeners=function(t){var e,n,r;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[t]&&(0==--this._eventsCount?this._events=Object.create(null):delete n[t]),this;if(0===arguments.length){var i,o=Object.keys(n);for(r=0;r<o.length;++r)"removeListener"!==(i=o[r])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(e=n[t]))this.removeListener(t,e);else if(void 0!==e)for(r=e.length-1;r>=0;r--)this.removeListener(t,e[r]);return this},z.prototype.listeners=function(t){return K(this,t,!0)},z.prototype.rawListeners=function(t){return K(this,t,!1)},z.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):H.call(t,e)},z.prototype.listenerCount=H,z.prototype.eventNames=function(){return this._eventsCount>0?C(this._events):[]},Object.defineProperty(O,"__esModule",{value:!0});const J=R.exports;function Z(t,e,n){try{Reflect.apply(t,e,n)}catch(t){setTimeout((()=>{throw t}))}}class Y extends J.EventEmitter{emit(t,...e){let n="error"===t;const r=this._events;if(void 0!==r)n=n&&void 0===r.error;else if(!n)return!1;if(n){let t;if(e.length>0&&([t]=e),t instanceof Error)throw t;const n=new Error("Unhandled error."+(t?` (${t.message})`:""));throw n.context=t,n}const i=r[t];if(void 0===i)return!1;if("function"==typeof i)Z(i,this,e);else{const t=i.length,n=function(t){const e=t.length,n=new Array(e);for(let r=0;r<e;r+=1)n[r]=t[r];return n}(i);for(let r=0;r<t;r+=1)Z(n[r],this,e)}return!0}}var X=O.default=Y;class Q extends Error{constructor(t,e){super(t),this.message=e,this.message=`[XAR_AUTH_SDK] error: [${t}] ${e}`}}const tt=new Q("user_not_logged_in","User is not logged in"),et=new Q("wallet_not_initialized","AuthProvider is not initialized. Please run `await auth.init(...)` before calling functions"),nt=new class{constructor(t,e){this.message=`[XAR_AUTH_SDK] warning: [${t}] ${e}`}log(){console.warn(this.message)}}("duplicate_iframe","Duplicate iframe detected, please keep a single instance of AuthProvider"),rt=1,it=2,ot=3,st=4,at=5,ct=t=>{ht.exceptionReporter&&ht.exceptionReporter(t)},ut=t=>{ht.logLevel=t},lt=()=>ht.logger;const ht={logger:new class{constructor(){this.prefix="[XAR_AUTH_SDK]"}info(t,e={}){this.internalLog(it,t,e)}debug(t,e={}){this.internalLog(rt,t,e)}warn(t,e={}){this.internalLog(ot,t,e)}error(t,e){if(e instanceof Error)return this.internalLog(st,t,e.message),void ct(JSON.stringify({message:t,error:e.message}));"string"==typeof e&&(this.internalLog(st,t,e),ct(JSON.stringify({message:t,error:e})))}internalLog(t,e,n){const r=`${this.prefix}\nMessage: ${e} \nParams: ${JSON.stringify(n)}`;this.consoleLog(t,r)}consoleLog(t,e){if(!(t<ht.logLevel))switch(t){case rt:console.debug(e);break;case ot:console.warn(e);break;case st:console.error(e);break;case it:console.info(e);break;default:console.log(e)}}},logLevel:at,exceptionReporter:null};class dt{constructor(t){this.url=t,this.requestHandler=()=>new Promise((t=>{let e=!1;const r=window.setInterval((()=>{var n;try{if(!e&&(null===(n=this.window)||void 0===n?void 0:n.closed))return t({id:1,jsonrpc:"2.0",error:"user_closed_popup"})}catch(t){}}),500),i=o=>n(this,void 0,void 0,(function*(){var n;if("json_rpc_response"==o.data.type)return e=!0,this.clear(i,r),null===(n=this.window)||void 0===n||n.close(),t(o.data.response)}));window.addEventListener("message",i,!1)}))}open(){const t=pt();return this.window=window.open(this.url,"_blank",t),this.getWindowResponse()}getWindowResponse(){return new Promise(((t,e)=>{let r=!1;const i=window.setInterval((()=>{var t;!r&&(null===(t=this.window)||void 0===t?void 0:t.closed)&&e("User closed the popup")}),500),o=s=>n(this,void 0,void 0,(function*(){var n,a,c;if(!(null===(n=null==s?void 0:s.data)||void 0===n?void 0:n.status))return;const u=s.data;return r=!0,this.clear(o,i),"success"===u.status?(null===(a=this.window)||void 0===a||a.close(),t("success")):"error"==u.status?(null===(c=this.window)||void 0===c||c.close(),e(u.error)):"done"===u.status?t("done"):void console.log("Unexpected event")}));window.addEventListener("message",o,!1)}))}clear(t,e){window.removeEventListener("message",t),window.clearInterval(e)}}const ft={titlebar:0,toolbar:0,status:0,menubar:0,resizable:0,height:1200,width:700,popup:1},pt=()=>{const t=[];for(const e in ft)t.push(`${e}=${ft[e]}`);return t.join(",")};class gt{constructor(t){this.url=t,this.requestCount=0,this.emitter=new X,this.ready=!1,this.cleanExit=!1,this.requestHandler=t=>new Promise((e=>{this.cleanExit=!1;const n=window.setInterval((()=>{var r;try{(null===(r=this.window)||void 0===r?void 0:r.closed)&&(this.cleanExit||this.emitter.emit(t,{id:t,jsonrpc:"2.0",error:"user_closed_popup"}),window.clearInterval(n),e("ok"))}catch(t){}}),500)})),this.handler=t=>n(this,void 0,void 0,(function*(){"json_rpc_response"==t.data.type&&(this.cleanExit=!0,this.emitter.emit(t.data.response.id,t.data.response))}))}sendRequest(t){return n(this,void 0,void 0,(function*(){if(this.window||(this.ready=!1,this.requestCount=0,this.window=window.open(this.url,"_blank",pt()),yield mt(),window.addEventListener("message",this.handler,!1)),this.window){this.requestCount++,this.window.postMessage({type:"json_rpc_request",data:t},this.url),this.window.focus(),this.requestHandler(String(t.request.id));return yield new Promise((e=>this.emitter.once(String(t.request.id),(t=>{var n;return this.requestCount--,this.requestCount<=0&&(window.removeEventListener("message",this.handler),null===(n=this.window)||void 0===n||n.close(),this.window=null),e(t)}))))}throw Error("error while opening popup")}))}}const mt=()=>new Promise((t=>{const e=n=>{"READY_TO_RECEIVE"===n.data.type&&(window.removeEventListener("message",e),t("ok"))};window.addEventListener("message",e,!1)})),yt="data:image/svg+xml,%3Csvg width='116' height='116' viewBox='0 0 116 116' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M115.341 58.0094C115.341 89.6796 89.6673 115.354 57.9967 115.354C26.3265 115.354 0.652344 89.6796 0.652344 58.0094C0.652344 26.3392 26.3265 0.665039 57.9967 0.665039C89.6673 0.665039 115.341 26.3392 115.341 58.0094Z' fill='%23B43030'/%3E%3Cpath d='M78.7969 37.2041L37.1953 78.8057' stroke='white' stroke-width='5.74' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M78.7969 78.8057L37.1953 37.2041' stroke='white' stroke-width='5.74' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E%0A",bt=t=>"string"==typeof t&&t.trim().length>0,wt=t=>40===_t(t).length,vt="0x",_t=t=>t.startsWith(vt)?t.substring(2):t,kt=(t,e=!0)=>{const n=t.toString(16);return e?(t=>t.startsWith(vt)?t:vt+t)(n):_t(n)},St=()=>window.location.origin+window.location.pathname,xt=4294967295;let Et=Math.floor(Math.random()*xt);function It(t){return String.fromCharCode(parseInt(t.slice(1),16))}function At(t){return e=JSON.stringify(t),window.btoa(encodeURIComponent(e).replace(/%[0-9A-F]{2}/g,It));var e}class Bt extends Error{constructor(t,e,n=""){super(e),this.code=t,this.message=e,this.data=n}}class Pt extends X{constructor(t){super(),this.authUrl=t,this.connected=!1,this.logger=lt(),this.onResponse=(t,e)=>{this.subscriber.emit(`result:${t}:${e.id}`,e)},this.handleEvents=(t,e)=>{switch(t){case Tt.ACCOUNTS_CHANGED:this.emit(t,[e]);break;case Tt.CHAIN_CHANGED:this.setChainId(e),this.emit(t,kt(e.chainId));break;case Tt.CONNECT:this.chainId="object"==typeof e?e.chainId:"",this.connected=!0,this.emit(t,e);break;case Tt.DISCONNECT:this.iframe.handleDisconnect(),this.connected=!1,this.emit(t,e);break;case Tt.MESSAGE:console.log({t:t,val:e}),this.emit(t,e)}},this.subscriber=new X}isArcana(){return!0}init(t,e){return n(this,void 0,void 0,(function*(){this.auth=e,this.popup=new gt(this.createRequestUrl(e.appId)),this.iframe=t;const{communication:n}=yield this.iframe.setConnectionMethods({onEvent:this.handleEvents,onMethodResponse:this.onResponse,getParentUrl:St,getAppMode:()=>this.iframe.appMode,getAppConfig:this.iframe.getAppConfig,getWalletPosition:this.iframe.getWalletPlace,getRpcConfig:()=>{},sendPendingRequestCount:this.iframe.onReceivingPendingRequestCount,triggerSocialLogin:e.loginWithSocial,triggerPasswordlessLogin:e.loginWithLink,getPopupState:()=>this.iframe.getState(),setIframeStyle:this.iframe.setIframeStyle,setSessionID:this.iframe.setSessionID,getSDKVersion:()=>"v3"});this.communication=n}))}isLoggedIn(){return n(this,void 0,void 0,(function*(){try{return(yield this.getCommunication("isLoggedIn")).isLoggedIn()}catch(t){return this.logger.error("isLoggedIn",t),!1}}))}connect(){return this.auth.connect()}isConnected(){return n(this,void 0,void 0,(function*(){return this.connected}))}isLoginAvailable(t){return n(this,void 0,void 0,(function*(){const e=yield this.getCommunication("isLoginAvailable"),n=yield e.isLoginAvailable(t);return this.logger.debug("loginAvailable",{[t]:n}),n}))}initCustomLogin(t){return n(this,void 0,void 0,(function*(){const e=yield this.getCommunication("triggerCustomLogin");return yield e.triggerCustomLogin(t)}))}requestUserInfo(){return n(this,void 0,void 0,(function*(){const t=yield this.getCommunication("getUserInfo");if(!(yield t.isLoggedIn()))throw tt;return yield t.getUserInfo()}))}getReconnectionUrl(){return n(this,void 0,void 0,(function*(){const t=yield this.getCommunication("getReconnectionUrl");return yield t.getReconnectionUrl()}))}initOTPLogin(t){return n(this,void 0,void 0,(function*(){const e=yield this.getCommunication("initOTPLogin");return yield e.initOTPLogin(t)}))}completeOTPLogin(t){return n(this,void 0,void 0,(function*(){const e=yield this.getCommunication("completeOTPLogin");yield e.completeOTPLogin(t)}))}getPublicKey(t,e){return n(this,void 0,void 0,(function*(){return(yield this.getCommunication("getPublicKey")).getPublicKey(t,e)}))}getAvailableLogins(){return n(this,void 0,void 0,(function*(){const t=yield this.getCommunication("getAvailableLogins");return yield t.getAvailableLogins()}))}logout(){return n(this,void 0,void 0,(function*(){const t=yield this.getCommunication("logout");yield t.logout()}))}initPasswordlessLogin(t){return n(this,void 0,void 0,(function*(){const e=yield this.getCommunication("initPasswordlessLogin");return yield e.initPasswordlessLogin(t)}))}initSocialLogin(t){return n(this,void 0,void 0,(function*(){const e=yield this.getCommunication("initSocialLogin");return yield e.initSocialLogin(t)}))}expandWallet(){return n(this,void 0,void 0,(function*(){const t=yield this.getCommunication("expandWallet");return yield t.expandWallet()}))}getKeySpaceConfigType(){return n(this,void 0,void 0,(function*(){const t=yield this.getCommunication("getKeySpaceConfigType");return yield t.getKeySpaceConfigType()}))}getCommunication(t="sendRequest"){return n(this,void 0,void 0,(function*(){if(this.communication){const e=yield this.communication.promise;if(!e[t])throw new Q("fn_not_available",`The requested fn ${t} is not available in this context`);return e}throw new Q("connection_not_available","The connection is not available yet")}))}request(t){return n(this,void 0,void 0,(function*(){if(!t||"object"!=typeof t||Array.isArray(t))throw o.ethErrors.rpc.invalidRequest({message:"Invalid request arguments",data:t});const{method:e,params:r}=t;if(!e)throw o.ethErrors.rpc.invalidRequest({message:"Invalid method argument",data:t});const i={method:e,params:r,jsonrpc:"2.0",id:(Et=(Et+1)%xt,Et)};return new Promise(((t,r)=>{this.getCommunication().then((o=>n(this,void 0,void 0,(function*(){this.getResponse(e,i.id).then(t,r),yield o.sendRequest(i)}))),r)}))}))}getResponse(t,e){return new Promise(((n,r)=>{this.subscriber.once(`result:${t}:${e}`,(t=>t.error?r(Mt(t.error)):n(t.result)))}))}createRequestUrl(t){return new URL(`/${t}/permission/`,this.authUrl).href}setChainId(t){t&&"object"==typeof t&&"chainId"in t&&"number"==typeof t.chainId&&(this.chainId=kt(t.chainId))}}const Tt={ACCOUNTS_CHANGED:"accountsChanged",CHAIN_CHANGED:"chainChanged",CONNECT:"connect",DISCONNECT:"disconnect",MESSAGE:"message"},Mt=t=>{switch(lt().error("getError",t),t){case"user_deny":return new Bt(4001,"User rejected the request.");case"user_closed_popup":return new Bt(4001,"User closed the popup.");case"operation_not_supported":return new Bt(4200,"The requested method is not supported by this provider.");case"all_disconnected":return new Bt(4900,"The provider is disconnected from all chains. Login is pending.");default:return"string"!=typeof t?new Bt(t.code,t.message,t.data):o.ethErrors.rpc.internal(t)}};var Ct,Ot,Rt,Lt,Nt,Ut,zt,$t;!function(t){t[t.CREATED=0]="CREATED",t[t.RUNNING=1]="RUNNING",t[t.DONE=2]="DONE"}(Ct||(Ct={})),function(t){t.evm_secp256k1="evm_secp256k1",t.solana_cv25519="solana_cv25519"}(Ot||(Ot={})),t.BearerAuthentication=void 0,(t.BearerAuthentication||(t.BearerAuthentication={})).firebase="firebase",function(t){t[t.NoUI=0]="NoUI",t[t.Widget=1]="Widget",t[t.Full=2]="Full"}(Rt||(Rt={})),function(t){t.Call="call",t.Reply="reply",t.Syn="syn",t.SynAck="synAck",t.Ack="ack"}(Lt||(Lt={})),function(t){t.Fulfilled="fulfilled",t.Rejected="rejected"}(Nt||(Nt={})),function(t){t.ConnectionDestroyed="ConnectionDestroyed",t.ConnectionTimeout="ConnectionTimeout",t.NoIframeSrc="NoIframeSrc"}(Ut||(Ut={})),function(t){t.DataCloneError="DataCloneError"}(zt||(zt={})),function(t){t.Message="message"}($t||($t={}));const Wt={"http:":"80","https:":"443"},Ft=/^(https?:)?\/\/([^/:]+)?(:(\d+))?/,Dt=["file:","data:"];const jt=({name:t,message:e,stack:n})=>({name:t,message:e,stack:n});let qt=0;var Kt=()=>++qt;const Ht=t=>t?t.split("."):[],Vt=(t,e,n)=>{const r=Ht(e);return r.reduce(((t,e,i)=>(void 0===t[e]&&(t[e]={}),i===r.length-1&&(t[e]=n),t[e])),t),t},Gt=(t,e)=>{const n={};return Object.keys(t).forEach((r=>{const i=t[r],o=((t,e)=>{const n=Ht(e||"");return n.push(t),(t=>t.join("."))(n)})(r,e);"object"==typeof i&&Object.assign(n,Gt(i,o)),"function"==typeof i&&(n[o]=i)})),n};var Jt=(t,e,n,r,i)=>{const{localName:o,local:s,remote:a,originForSending:c,originForReceiving:u}=e;let l=!1;i(`${o}: Connecting call sender`);const h=t=>(...e)=>{let n;i(`${o}: Sending ${t}() call`);try{a.closed&&(n=!0)}catch(t){n=!0}if(n&&r(),l){const e=new Error(`Unable to send ${t}() call due to destroyed connection`);throw e.code=Ut.ConnectionDestroyed,e}return new Promise(((n,r)=>{const l=Kt(),h=e=>{if(e.source!==a||e.data.penpal!==Lt.Reply||e.data.id!==l)return;if("*"!==u&&e.origin!==u)return void i(`${o} received message from origin ${e.origin} which did not match expected origin ${u}`);const c=e.data;i(`${o}: Received ${t}() reply`),s.removeEventListener($t.Message,h);let d=c.returnValue;c.returnValueIsError&&(d=(t=>{const e=new Error;return Object.keys(t).forEach((n=>e[n]=t[n])),e})(d)),(c.resolution===Nt.Fulfilled?n:r)(d)};s.addEventListener($t.Message,h);const d={penpal:Lt.Call,id:l,methodName:t,args:e};a.postMessage(d,c)}))},d=n.reduce(((t,e)=>(t[e]=h(e),t)),{});return Object.assign(t,(t=>{const e={};for(const n in t)Vt(e,n,t[n]);return e})(d)),()=>{l=!0}},Zt=(t,e,n,r,i)=>{const{destroy:o,onDestroy:s}=r;let a,c;const u={};return r=>{if("*"!==e&&r.origin!==e)return void i(`Parent: Handshake - Received ACK message from origin ${r.origin} which did not match expected origin ${e}`);i("Parent: Handshake - Received ACK");const l={localName:"Parent",local:window,remote:r.source,originForSending:n,originForReceiving:e};a&&a(),a=((t,e,n)=>{const{localName:r,local:i,remote:o,originForSending:s,originForReceiving:a}=t;let c=!1;const u=t=>{if(t.source!==o||t.data.penpal!==Lt.Call)return;if("*"!==a&&t.origin!==a)return void n(`${r} received message from origin ${t.origin} which did not match expected origin ${a}`);const i=t.data,{methodName:u,args:l,id:h}=i;n(`${r}: Received ${u}() call`);const d=t=>e=>{if(n(`${r}: Sending ${u}() reply`),c)return void n(`${r}: Unable to send ${u}() reply due to destroyed connection`);const i={penpal:Lt.Reply,id:h,resolution:t,returnValue:e};t===Nt.Rejected&&e instanceof Error&&(i.returnValue=jt(e),i.returnValueIsError=!0);try{o.postMessage(i,s)}catch(t){if(t.name===zt.DataCloneError){const e={penpal:Lt.Reply,id:h,resolution:Nt.Rejected,returnValue:jt(t),returnValueIsError:!0};o.postMessage(e,s)}throw t}};new Promise((t=>t(e[u].apply(e,l)))).then(d(Nt.Fulfilled),d(Nt.Rejected))};return i.addEventListener($t.Message,u),()=>{c=!0,i.removeEventListener($t.Message,u)}})(l,t,i),s(a),c&&c.forEach((t=>{delete u[t]})),c=r.data.methodNames;const h=Jt(u,l,c,o,i);return s(h),u}};var Yt=t=>{let{iframe:e,methods:n={},childOrigin:r,timeout:i,debug:o=!1}=t;const s=(t=>(...e)=>{t&&console.log("[Penpal]",...e)})(o),a=((t,e)=>{const n=[];let r=!1;return{destroy(i){r||(r=!0,e(`${t}: Destroying connection`),n.forEach((t=>{t(i)})))},onDestroy(t){r?t():n.push(t)}}})("Parent",s),{onDestroy:c,destroy:u}=a;r||((t=>{if(!t.src&&!t.srcdoc){const t=new Error("Iframe must have src or srcdoc property defined.");throw t.code=Ut.NoIframeSrc,t}})(e),r=(t=>{if(t&&Dt.find((e=>t.startsWith(e))))return"null";const e=document.location,n=Ft.exec(t);let r,i,o;return n?(r=n[1]?n[1]:e.protocol,i=n[2],o=n[4]):(r=e.protocol,i=e.hostname,o=e.port),`${r}//${i}${o&&o!==Wt[r]?`:${o}`:""}`})(e.src));const l="null"===r?"*":r,h=Gt(n),d=((t,e,n,r)=>i=>{if(!i.source)return;if("*"!==n&&i.origin!==n)return void t(`Parent: Handshake - Received SYN message from origin ${i.origin} which did not match expected origin ${n}`);t("Parent: Handshake - Received SYN, responding with SYN-ACK");const o={penpal:Lt.SynAck,methodNames:Object.keys(e)};i.source.postMessage(o,r)})(s,h,r,l),f=Zt(h,r,l,a,s),p=new Promise(((t,n)=>{const r=((t,e)=>{let n;return void 0!==t&&(n=window.setTimeout((()=>{const n=new Error(`Connection timed out after ${t}ms`);n.code=Ut.ConnectionTimeout,e(n)}),t)),()=>{clearTimeout(n)}})(i,u),o=n=>{if(n.source===e.contentWindow&&n.data)if(n.data.penpal!==Lt.Syn)if(n.data.penpal!==Lt.Ack);else{const e=f(n);e&&(r(),t(e))}else d(n)};window.addEventListener($t.Message,o),s("Parent: Awaiting handshake"),((t,e)=>{const{destroy:n,onDestroy:r}=e,i=setInterval((()=>{t.isConnected||(clearInterval(i),n())}),6e4);r((()=>{clearInterval(i)}))})(e,a),c((t=>{window.removeEventListener($t.Message,o),t&&n(t)}))}));return{promise:p,destroy(){u()}}};const Xt={border:"none",position:"fixed",height:0,width:0,right:0,bottom:0,zIndex:2147483648},Qt="xar-wallet";class te{constructor(t){this.params=t,this.getSessionID=()=>{const t=window.localStorage.getItem(`arcana-auth-${this.getIframeUrl()}-sessionID`);return t?JSON.parse(t):null},this.setSessionID=(t,e)=>{window.localStorage.setItem(`arcana-auth-${this.getIframeUrl()}-sessionID`,JSON.stringify({id:t,expiry:e}))},this.clearSessionID=()=>{window.localStorage.removeItem(`arcana-auth-${this.getIframeUrl()}-sessionID`)},this.setIframeStyle=t=>{var e;if(1==(null===(e=this.params.standaloneMode)||void 0===e?void 0:e.mode))this.widgetIframe.style.height=t.height?t.height:"80vh",this.widgetIframe.style.maxWidth="100%",this.widgetIframe.style.width="430px",this.widgetIframe.style.bottom="0",this.widgetIframe.style.right="0";else for(const e in t)this.widgetIframe.style[e]=t[e]},this.getWalletPlace=()=>this.params.position,this.getAppConfig=()=>this.params.appConfig,this.checkDuplicateIframe(),this.checkSecureOrigin()}setConnectionMethods(t){return n(this,void 0,void 0,(function*(){try{return this.iframeCommunication||(this.iframeCommunication=Yt({iframe:this.widgetIframe,methods:Object.assign(Object.assign({},t),{uiEvent:(t,e)=>{var n;(null===(n=this.params.standaloneMode)||void 0===n?void 0:n.handler)&&this.params.standaloneMode.handler(t,e)}}),childOrigin:this.params.iframeUrl}),yield this.iframeCommunication.promise),{iframe:this.widgetIframe,communication:this.iframeCommunication}}catch(t){throw new Error("Could not set connection methods")}}))}triggerBearerAuthentication(t,e){return n(this,void 0,void 0,(function*(){return(yield this.iframeCommunication.promise).triggerBearerLogin(t,e)}))}setWalletType(t){this.appMode=null!=t?t:Rt.Full,this.initWalletUI()}getState(){return this.state}handleDisconnect(){this.clearSessionID()}onReceivingPendingRequestCount(t){const e=document.getElementById("req-count-badge");e&&(t>0?(e.style.display="flex",e.textContent=`${t}`):e.style.display="none")}getIframeUrl(){var t,e;const n=At({standaloneMode:(null===(t=this.params.standaloneMode)||void 0===t?void 0:t.mode)?null===(e=this.params.standaloneMode)||void 0===e?void 0:e.mode:0}),r=new URL(`/${this.params.appId}/v2/login`,this.params.iframeUrl);return r.hash=n,r.toString()}createWidgetIframe(){return((t,e,...n)=>{const r=document.createElement(t);e&&(Object.assign(r,e),e.style&&Object.assign(r.style,e.style));for(const t of n)"string"!=typeof t?r.appendChild(t):r.appendChild(document.createTextNode(t));return r})("iframe",{style:Xt,src:this.getIframeUrl(),allow:"clipboard-write",className:Qt})}checkDuplicateIframe(){[].slice.call(document.querySelectorAll(`.${Qt}`)).length>0&&nt.log()}initWalletUI(){this.widgetIframe=this.createWidgetIframe(),document.body.appendChild(this.widgetIframe)}checkSecureOrigin(){const t="localhost"===location.hostname||"127.0.0.1"===location.hostname,e="https:"===location.protocol;if(!(t||e))throw new Error("Insecure origin")}}const ee={authUrl:"https://verify.dev.arcana.network",gatewayUrl:"https://gateway-dev.arcana.network",walletUrl:"https://wallet.dev.arcana.network"},ne={authUrl:"https://verify.beta.arcana.network",gatewayUrl:"https://gateway001-testnet.arcana.network",walletUrl:"https://wallet.beta.arcana.network"},re={authUrl:"https://auth.arcana.network",gatewayUrl:"https://gateway.arcana.network",walletUrl:"https://wallet.arcana.network"};function ie(t,e){return n(this,void 0,void 0,(function*(){const n=new URL(`/api/v1/get-app-theme/?id=${t}`,e);return yield(yield fetch(n.toString())).json()}))}function oe(t,e){return n(this,void 0,void 0,(function*(){const n=new URL(`/api/v1/get-app-config/?id=${t}`,e);return yield(yield fetch(n.toString())).json()}))}var se,ae,ce,ue,le,he,de,fe,pe,ge,me={},ye=[],be=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,we=Array.isArray;function ve(t,e){for(var n in e)t[n]=e[n];return t}function _e(t){var e=t.parentNode;e&&e.removeChild(t)}function ke(t,e,n,r,i){var o={type:t,props:e,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:null==i?++ce:i,__i:-1,__u:0};return null==i&&null!=ae.vnode&&ae.vnode(o),o}function Se(t){return t.children}function xe(t,e){this.props=t,this.context=e}function Ee(t,e){if(null==e)return t.__?Ee(t.__,t.__i+1):null;for(var n;e<t.__k.length;e++)if(null!=(n=t.__k[e])&&null!=n.__e)return n.__e;return"function"==typeof t.type?Ee(t):null}function Ie(t){var e,n;if(null!=(t=t.__)&&null!=t.__c){for(t.__e=t.__c.base=null,e=0;e<t.__k.length;e++)if(null!=(n=t.__k[e])&&null!=n.__e){t.__e=t.__c.base=n.__e;break}return Ie(t)}}function Ae(t){(!t.__d&&(t.__d=!0)&&ue.push(t)&&!Be.__r++||le!==ae.debounceRendering)&&((le=ae.debounceRendering)||he)(Be)}function Be(){var t,e,n,r,i,o,s,a;for(ue.sort(de);t=ue.shift();)t.__d&&(e=ue.length,r=void 0,o=(i=(n=t).__v).__e,s=[],a=[],n.__P&&((r=ve({},i)).__v=i.__v+1,ae.vnode&&ae.vnode(r),Ne(n.__P,r,i,n.__n,n.__P.namespaceURI,32&i.__u?[o]:null,s,null==o?Ee(i):o,!!(32&i.__u),a),r.__v=i.__v,r.__.__k[r.__i]=r,Ue(s,r,a),r.__e!=o&&Ie(r)),ue.length>e&&ue.sort(de));Be.__r=0}function Pe(t,e,n,r,i,o,s,a,c,u,l){var h,d,f,p,g,m=r&&r.__k||ye,y=e.length;for(n.__d=c,Te(n,e,m),c=n.__d,h=0;h<y;h++)null!=(f=n.__k[h])&&"boolean"!=typeof f&&"function"!=typeof f&&(d=-1===f.__i?me:m[f.__i]||me,f.__i=h,Ne(t,f,d,i,o,s,a,c,u,l),p=f.__e,f.ref&&d.ref!=f.ref&&(d.ref&&$e(d.ref,null,f),l.push(f.ref,f.__c||p,f)),null==g&&null!=p&&(g=p),65536&f.__u||d.__k===f.__k?(c&&"string"==typeof f.type&&!t.contains(c)&&(c=Ee(d)),c=Me(f,c,t)):"function"==typeof f.type&&void 0!==f.__d?c=f.__d:p&&(c=p.nextSibling),f.__d=void 0,f.__u&=-196609);n.__d=c,n.__e=g}function Te(t,e,n){var r,i,o,s,a,c=e.length,u=n.length,l=u,h=0;for(t.__k=[],r=0;r<c;r++)s=r+h,null!=(i=t.__k[r]=null==(i=e[r])||"boolean"==typeof i||"function"==typeof i?null:"string"==typeof i||"number"==typeof i||"bigint"==typeof i||i.constructor==String?ke(null,i,null,null,null):we(i)?ke(Se,{children:i},null,null,null):void 0===i.constructor&&i.__b>0?ke(i.type,i.props,i.key,i.ref?i.ref:null,i.__v):i)?(i.__=t,i.__b=t.__b+1,a=Ce(i,n,s,l),i.__i=a,o=null,-1!==a&&(l--,(o=n[a])&&(o.__u|=131072)),null==o||null===o.__v?(-1==a&&h--,"function"!=typeof i.type&&(i.__u|=65536)):a!==s&&(a==s-1?h=a-s:a==s+1?h++:a>s?l>c-s?h+=a-s:h--:a<s&&h++,a!==r+h&&(i.__u|=65536))):(o=n[s])&&null==o.key&&o.__e&&!(131072&o.__u)&&(o.__e==t.__d&&(t.__d=Ee(o)),We(o,o,!1),n[s]=null,l--);if(l)for(r=0;r<u;r++)null!=(o=n[r])&&!(131072&o.__u)&&(o.__e==t.__d&&(t.__d=Ee(o)),We(o,o))}function Me(t,e,n){var r,i;if("function"==typeof t.type){for(r=t.__k,i=0;r&&i<r.length;i++)r[i]&&(r[i].__=t,e=Me(r[i],e,n));return e}t.__e!=e&&(n.insertBefore(t.__e,e||null),e=t.__e);do{e=e&&e.nextSibling}while(null!=e&&8===e.nodeType);return e}function Ce(t,e,n,r){var i=t.key,o=t.type,s=n-1,a=n+1,c=e[n];if(null===c||c&&i==c.key&&o===c.type&&!(131072&c.__u))return n;if(r>(null==c||131072&c.__u?0:1))for(;s>=0||a<e.length;){if(s>=0){if((c=e[s])&&!(131072&c.__u)&&i==c.key&&o===c.type)return s;s--}if(a<e.length){if((c=e[a])&&!(131072&c.__u)&&i==c.key&&o===c.type)return a;a++}}return-1}function Oe(t,e,n){"-"===e[0]?t.setProperty(e,null==n?"":n):t[e]=null==n?"":"number"!=typeof n||be.test(e)?n:n+"px"}function Re(t,e,n,r,i){var o;t:if("style"===e)if("string"==typeof n)t.style.cssText=n;else{if("string"==typeof r&&(t.style.cssText=r=""),r)for(e in r)n&&e in n||Oe(t.style,e,"");if(n)for(e in n)r&&n[e]===r[e]||Oe(t.style,e,n[e])}else if("o"===e[0]&&"n"===e[1])o=e!==(e=e.replace(/(PointerCapture)$|Capture$/i,"$1")),e=e.toLowerCase()in t||"onFocusOut"===e||"onFocusIn"===e?e.toLowerCase().slice(2):e.slice(2),t.l||(t.l={}),t.l[e+o]=n,n?r?n.u=r.u:(n.u=fe,t.addEventListener(e,o?ge:pe,o)):t.removeEventListener(e,o?ge:pe,o);else{if("http://www.w3.org/2000/svg"==i)e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!=e&&"height"!=e&&"href"!=e&&"list"!=e&&"form"!=e&&"tabIndex"!=e&&"download"!=e&&"rowSpan"!=e&&"colSpan"!=e&&"role"!=e&&"popover"!=e&&e in t)try{t[e]=null==n?"":n;break t}catch(t){}"function"==typeof n||(null==n||!1===n&&"-"!==e[4]?t.removeAttribute(e):t.setAttribute(e,"popover"==e&&1==n?"":n))}}function Le(t){return function(e){if(this.l){var n=this.l[e.type+t];if(null==e.t)e.t=fe++;else if(e.t<n.u)return;return n(ae.event?ae.event(e):e)}}}function Ne(t,e,n,r,i,o,s,a,c,u){var l,h,d,f,p,g,m,y,b,w,v,_,k,S,x,E,I=e.type;if(void 0!==e.constructor)return null;128&n.__u&&(c=!!(32&n.__u),o=[a=e.__e=n.__e]),(l=ae.__b)&&l(e);t:if("function"==typeof I)try{if(y=e.props,b="prototype"in I&&I.prototype.render,w=(l=I.contextType)&&r[l.__c],v=l?w?w.props.value:l.__:r,n.__c?m=(h=e.__c=n.__c).__=h.__E:(b?e.__c=h=new I(y,v):(e.__c=h=new xe(y,v),h.constructor=I,h.render=Fe),w&&w.sub(h),h.props=y,h.state||(h.state={}),h.context=v,h.__n=r,d=h.__d=!0,h.__h=[],h._sb=[]),b&&null==h.__s&&(h.__s=h.state),b&&null!=I.getDerivedStateFromProps&&(h.__s==h.state&&(h.__s=ve({},h.__s)),ve(h.__s,I.getDerivedStateFromProps(y,h.__s))),f=h.props,p=h.state,h.__v=e,d)b&&null==I.getDerivedStateFromProps&&null!=h.componentWillMount&&h.componentWillMount(),b&&null!=h.componentDidMount&&h.__h.push(h.componentDidMount);else{if(b&&null==I.getDerivedStateFromProps&&y!==f&&null!=h.componentWillReceiveProps&&h.componentWillReceiveProps(y,v),!h.__e&&(null!=h.shouldComponentUpdate&&!1===h.shouldComponentUpdate(y,h.__s,v)||e.__v===n.__v)){for(e.__v!==n.__v&&(h.props=y,h.state=h.__s,h.__d=!1),e.__e=n.__e,e.__k=n.__k,e.__k.forEach((function(t){t&&(t.__=e)})),_=0;_<h._sb.length;_++)h.__h.push(h._sb[_]);h._sb=[],h.__h.length&&s.push(h);break t}null!=h.componentWillUpdate&&h.componentWillUpdate(y,h.__s,v),b&&null!=h.componentDidUpdate&&h.__h.push((function(){h.componentDidUpdate(f,p,g)}))}if(h.context=v,h.props=y,h.__P=t,h.__e=!1,k=ae.__r,S=0,b){for(h.state=h.__s,h.__d=!1,k&&k(e),l=h.render(h.props,h.state,h.context),x=0;x<h._sb.length;x++)h.__h.push(h._sb[x]);h._sb=[]}else do{h.__d=!1,k&&k(e),l=h.render(h.props,h.state,h.context),h.state=h.__s}while(h.__d&&++S<25);h.state=h.__s,null!=h.getChildContext&&(r=ve(ve({},r),h.getChildContext())),b&&!d&&null!=h.getSnapshotBeforeUpdate&&(g=h.getSnapshotBeforeUpdate(f,p)),Pe(t,we(E=null!=l&&l.type===Se&&null==l.key?l.props.children:l)?E:[E],e,n,r,i,o,s,a,c,u),h.base=e.__e,e.__u&=-161,h.__h.length&&s.push(h),m&&(h.__E=h.__=null)}catch(t){e.__v=null,c||null!=o?(e.__e=a,e.__u|=c?160:32,o[o.indexOf(a)]=null):(e.__e=n.__e,e.__k=n.__k),ae.__e(t,e,n)}else null==o&&e.__v===n.__v?(e.__k=n.__k,e.__e=n.__e):e.__e=ze(n.__e,e,n,r,i,o,s,c,u);(l=ae.diffed)&&l(e)}function Ue(t,e,n){e.__d=void 0;for(var r=0;r<n.length;r++)$e(n[r],n[++r],n[++r]);ae.__c&&ae.__c(e,t),t.some((function(e){try{t=e.__h,e.__h=[],t.some((function(t){t.call(e)}))}catch(t){ae.__e(t,e.__v)}}))}function ze(t,e,n,r,i,o,s,a,c){var u,l,h,d,f,p,g,m=n.props,y=e.props,b=e.type;if("svg"===b?i="http://www.w3.org/2000/svg":"math"===b?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),null!=o)for(u=0;u<o.length;u++)if((f=o[u])&&"setAttribute"in f==!!b&&(b?f.localName===b:3===f.nodeType)){t=f,o[u]=null;break}if(null==t){if(null===b)return document.createTextNode(y);t=document.createElementNS(i,b,y.is&&y),o=null,a=!1}if(null===b)m===y||a&&t.data===y||(t.data=y);else{if(o=o&&se.call(t.childNodes),m=n.props||me,!a&&null!=o)for(m={},u=0;u<t.attributes.length;u++)m[(f=t.attributes[u]).name]=f.value;for(u in m)if(f=m[u],"children"==u);else if("dangerouslySetInnerHTML"==u)h=f;else if("key"!==u&&!(u in y)){if("value"==u&&"defaultValue"in y||"checked"==u&&"defaultChecked"in y)continue;Re(t,u,null,f,i)}for(u in y)f=y[u],"children"==u?d=f:"dangerouslySetInnerHTML"==u?l=f:"value"==u?p=f:"checked"==u?g=f:"key"===u||a&&"function"!=typeof f||m[u]===f||Re(t,u,f,m[u],i);if(l)a||h&&(l.__html===h.__html||l.__html===t.innerHTML)||(t.innerHTML=l.__html),e.__k=[];else if(h&&(t.innerHTML=""),Pe(t,we(d)?d:[d],e,n,r,"foreignObject"===b?"http://www.w3.org/1999/xhtml":i,o,s,o?o[0]:n.__k&&Ee(n,0),a,c),null!=o)for(u=o.length;u--;)null!=o[u]&&_e(o[u]);a||(u="value",void 0!==p&&(p!==t[u]||"progress"===b&&!p||"option"===b&&p!==m[u])&&Re(t,u,p,m[u],i),u="checked",void 0!==g&&g!==t[u]&&Re(t,u,g,m[u],i))}return t}function $e(t,e,n){try{"function"==typeof t?t(e):t.current=e}catch(t){ae.__e(t,n)}}function We(t,e,n){var r,i;if(ae.unmount&&ae.unmount(t),(r=t.ref)&&(r.current&&r.current!==t.__e||$e(r,null,e)),null!=(r=t.__c)){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(t){ae.__e(t,e)}r.base=r.__P=null}if(r=t.__k)for(i=0;i<r.length;i++)r[i]&&We(r[i],e,n||"function"!=typeof t.type);n||null==t.__e||_e(t.__e),t.__c=t.__=t.__e=t.__d=void 0}function Fe(t,e,n){return this.constructor(t,n)}function De(t,e,n){var r,i,o,s;ae.__&&ae.__(t,e),i=(r="function"==typeof n)?null:n&&n.__k||e.__k,o=[],s=[],Ne(e,t=(!r&&n||e).__k=function(t,e,n){var r,i,o,s={};for(o in e)"key"==o?r=e[o]:"ref"==o?i=e[o]:s[o]=e[o];if(arguments.length>2&&(s.children=arguments.length>3?se.call(arguments,2):n),"function"==typeof t&&null!=t.defaultProps)for(o in t.defaultProps)void 0===s[o]&&(s[o]=t.defaultProps[o]);return ke(t,s,r,i,null)}(Se,null,[t]),i||me,me,e.namespaceURI,!r&&n?[n]:i?null:e.firstChild?se.call(e.childNodes):null,o,!r&&n?n:i?i.__e:e.firstChild,r,s),Ue(o,t,s)}se=ye.slice,ae={__e:function(t,e,n,r){for(var i,o,s;e=e.__;)if((i=e.__c)&&!i.__)try{if((o=i.constructor)&&null!=o.getDerivedStateFromError&&(i.setState(o.getDerivedStateFromError(t)),s=i.__d),null!=i.componentDidCatch&&(i.componentDidCatch(t,r||{}),s=i.__d),s)return i.__E=i}catch(e){t=e}throw t}},ce=0,xe.prototype.setState=function(t,e){var n;n=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=ve({},this.state),"function"==typeof t&&(t=t(ve({},n),this.props)),t&&ve(n,t),null!=t&&this.__v&&(e&&this._sb.push(e),Ae(this))},xe.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),Ae(this))},xe.prototype.render=Se,ue=[],he="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,de=function(t,e){return t.__v.__b-e.__v.__b},Be.__r=0,fe=0,pe=Le(!1),ge=Le(!0);var je=0;function qe(t,e,n,r,i,o){e||(e={});var s,a,c=e;if("ref"in c)for(a in c={},e)"ref"==a?s=e[a]:c[a]=e[a];var u={type:t,props:c,key:n,ref:s,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:--je,__i:-1,__u:0,__source:i,__self:o};if("function"==typeof t&&(s=t.defaultProps))for(a in s)void 0===c[a]&&(c[a]=s[a]);return ae.vnode&&ae.vnode(u),u}var Ke,He,Ve,Ge,Je=0,Ze=[],Ye=ae,Xe=Ye.__b,Qe=Ye.__r,tn=Ye.diffed,en=Ye.__c,nn=Ye.unmount,rn=Ye.__;function on(t,e){Ye.__h&&Ye.__h(He,t,Je||e),Je=0;var n=He.__H||(He.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function sn(t){return Je=1,an(mn,t)}function an(t,e,n){var r=on(Ke++,2);if(r.t=t,!r.__c&&(r.__=[n?n(e):mn(void 0,e),function(t){var e=r.__N?r.__N[0]:r.__[0],n=r.t(e,t);e!==n&&(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=He,!He.u)){var i=function(t,e,n){if(!r.__c.__H)return!0;var i=r.__c.__H.__.filter((function(t){return!!t.__c}));if(i.every((function(t){return!t.__N})))return!o||o.call(this,t,e,n);var s=!1;return i.forEach((function(t){if(t.__N){var e=t.__[0];t.__=t.__N,t.__N=void 0,e!==t.__[0]&&(s=!0)}})),!(!s&&r.__c.props===t)&&(!o||o.call(this,t,e,n))};He.u=!0;var o=He.shouldComponentUpdate,s=He.componentWillUpdate;He.componentWillUpdate=function(t,e,n){if(this.__e){var r=o;o=void 0,i(t,e,n),o=r}s&&s.call(this,t,e,n)},He.shouldComponentUpdate=i}return r.__N||r.__}function cn(t,e){var n=on(Ke++,3);!Ye.__s&&gn(n.__H,e)&&(n.__=t,n.i=e,He.__H.__h.push(n))}function un(t){return Je=5,function(t,e){var n=on(Ke++,7);return gn(n.__H,e)&&(n.__=t(),n.__H=e,n.__h=t),n.__}((function(){return{current:t}}),[])}function ln(){for(var t;t=Ze.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(fn),t.__H.__h.forEach(pn),t.__H.__h=[]}catch(e){t.__H.__h=[],Ye.__e(e,t.__v)}}Ye.__b=function(t){He=null,Xe&&Xe(t)},Ye.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),rn&&rn(t,e)},Ye.__r=function(t){Qe&&Qe(t),Ke=0;var e=(He=t.__c).__H;e&&(Ve===He?(e.__h=[],He.__h=[],e.__.forEach((function(t){t.__N&&(t.__=t.__N),t.i=t.__N=void 0}))):(e.__h.forEach(fn),e.__h.forEach(pn),e.__h=[],Ke=0)),Ve=He},Ye.diffed=function(t){tn&&tn(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(1!==Ze.push(e)&&Ge===Ye.requestAnimationFrame||((Ge=Ye.requestAnimationFrame)||dn)(ln)),e.__H.__.forEach((function(t){t.i&&(t.__H=t.i),t.i=void 0}))),Ve=He=null},Ye.__c=function(t,e){e.some((function(t){try{t.__h.forEach(fn),t.__h=t.__h.filter((function(t){return!t.__||pn(t)}))}catch(n){e.some((function(t){t.__h&&(t.__h=[])})),e=[],Ye.__e(n,t.__v)}})),en&&en(t,e)},Ye.unmount=function(t){nn&&nn(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.forEach((function(t){try{fn(t)}catch(t){e=t}})),n.__H=void 0,e&&Ye.__e(e,n.__v))};var hn="function"==typeof requestAnimationFrame;function dn(t){var e,n=function(){clearTimeout(r),hn&&cancelAnimationFrame(e),setTimeout(t)},r=setTimeout(n,100);hn&&(e=requestAnimationFrame(n))}function fn(t){var e=He,n=t.__c;"function"==typeof n&&(t.__c=void 0,n()),He=e}function pn(t){var e=He;t.__c=t.__(),He=e}function gn(t,e){return!t||t.length!==e.length||e.some((function(e,n){return e!==t[n]}))}function mn(t,e){return"function"==typeof e?e(t):e}const yn="https://auth-icons.s3.ap-south-1.amazonaws.com",bn={google:`${yn}/google.png`,twitter:`${yn}/twitter.png`,github:`${yn}/github-light.png`,github_light:`${yn}/github.png`,twitch:`${yn}/twitch.png`,discord:`${yn}/discord.png`,aws:`${yn}/aws.png`,aws_light:`${yn}/aws_light.png`,steam:`${yn}/steam.png`};const wn={light:`${yn}/secured-by-arcana-light.svg`,dark:`${yn}/secured-by-arcana-dark.svg`};function vn(t){return vn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},vn(t)}function _n(t){if(!("string"==typeof t||t instanceof String)){var e=vn(t);throw null===t?e="null":"object"===e&&(e=t.constructor.name),new TypeError("Expected a string but received a ".concat(e))}}function kn(t){return kn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},kn(t)}function Sn(t,e){var n,r;_n(t),"object"===kn(e)?(n=e.min||0,r=e.max):(n=arguments[1],r=arguments[2]);var i=encodeURI(t).split(/%..|./).length-1;return i>=n&&(void 0===r||i<=r)}function xn(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1?arguments[1]:void 0;for(var n in e)void 0===t[n]&&(t[n]=e[n]);return t}var En={require_tld:!0,allow_underscores:!1,allow_trailing_dot:!1,allow_numeric_tld:!1,allow_wildcard:!1,ignore_max_length:!1};var In="(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])",An="(".concat(In,"[.]){3}").concat(In),Bn=new RegExp("^".concat(An,"$")),Pn="(?:[0-9a-fA-F]{1,4})",Tn=new RegExp("^("+"(?:".concat(Pn,":){7}(?:").concat(Pn,"|:)|")+"(?:".concat(Pn,":){6}(?:").concat(An,"|:").concat(Pn,"|:)|")+"(?:".concat(Pn,":){5}(?::").concat(An,"|(:").concat(Pn,"){1,2}|:)|")+"(?:".concat(Pn,":){4}(?:(:").concat(Pn,"){0,1}:").concat(An,"|(:").concat(Pn,"){1,3}|:)|")+"(?:".concat(Pn,":){3}(?:(:").concat(Pn,"){0,2}:").concat(An,"|(:").concat(Pn,"){1,4}|:)|")+"(?:".concat(Pn,":){2}(?:(:").concat(Pn,"){0,3}:").concat(An,"|(:").concat(Pn,"){1,5}|:)|")+"(?:".concat(Pn,":){1}(?:(:").concat(Pn,"){0,4}:").concat(An,"|(:").concat(Pn,"){1,6}|:)|")+"(?::((?::".concat(Pn,"){0,5}:").concat(An,"|(?::").concat(Pn,"){1,7}|:))")+")(%[0-9a-zA-Z-.:]{1,})?$");function Mn(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return _n(t),(e=String(e))?"4"===e?Bn.test(t):"6"===e&&Tn.test(t):Mn(t,4)||Mn(t,6)}var Cn={allow_display_name:!1,allow_underscores:!1,require_display_name:!1,allow_utf8_local_part:!0,require_tld:!0,blacklisted_chars:"",ignore_max_length:!1,host_blacklist:[],host_whitelist:[]},On=/^([^\x00-\x1F\x7F-\x9F\cX]+)</i,Rn=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i,Ln=/^[a-z\d]+$/,Nn=/^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f]))*$/i,Un=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\u00A1-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$/i,zn=/^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*$/i;function $n(t,e){if(_n(t),(e=xn(e,Cn)).require_display_name||e.allow_display_name){var n=t.match(On);if(n){var r=n[1];if(t=t.replace(r,"").replace(/(^<|>$)/g,""),r.endsWith(" ")&&(r=r.slice(0,-1)),!function(t){var e=t.replace(/^"(.+)"$/,"$1");if(!e.trim())return!1;if(/[\.";<>]/.test(e)){if(e===t)return!1;if(e.split('"').length!==e.split('\\"').length)return!1}return!0}(r))return!1}else if(e.require_display_name)return!1}if(!e.ignore_max_length&&t.length>254)return!1;var i=t.split("@"),o=i.pop(),s=o.toLowerCase();if(e.host_blacklist.includes(s))return!1;if(e.host_whitelist.length>0&&!e.host_whitelist.includes(s))return!1;var a=i.join("@");if(e.domain_specific_validation&&("gmail.com"===s||"googlemail.com"===s)){var c=(a=a.toLowerCase()).split("+")[0];if(!Sn(c.replace(/\./g,""),{min:6,max:30}))return!1;for(var u=c.split("."),l=0;l<u.length;l++)if(!Ln.test(u[l]))return!1}if(!(!1!==e.ignore_max_length||Sn(a,{max:64})&&Sn(o,{max:254})))return!1;if(!function(t,e){_n(t),(e=xn(e,En)).allow_trailing_dot&&"."===t[t.length-1]&&(t=t.substring(0,t.length-1)),!0===e.allow_wildcard&&0===t.indexOf("*.")&&(t=t.substring(2));var n=t.split("."),r=n[n.length-1];if(e.require_tld){if(n.length<2)return!1;if(!e.allow_numeric_tld&&!/^([a-z\u00A1-\u00A8\u00AA-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}|xn[a-z0-9-]{2,})$/i.test(r))return!1;if(/\s/.test(r))return!1}return!(!e.allow_numeric_tld&&/^\d+$/.test(r))&&n.every((function(t){return!(t.length>63&&!e.ignore_max_length||!/^[a-z_\u00a1-\uffff0-9-]+$/i.test(t)||/[\uff01-\uff5e]/.test(t)||/^-|-$/.test(t)||!e.allow_underscores&&/_/.test(t))}))}(o,{require_tld:e.require_tld,ignore_max_length:e.ignore_max_length,allow_underscores:e.allow_underscores})){if(!e.allow_ip_domain)return!1;if(!Mn(o)){if(!o.startsWith("[")||!o.endsWith("]"))return!1;var h=o.slice(1,-1);if(0===h.length||!Mn(h))return!1}}if('"'===a[0])return a=a.slice(1,a.length-1),e.allow_utf8_local_part?zn.test(a):Nn.test(a);for(var d=e.allow_utf8_local_part?Un:Rn,f=a.split("."),p=0;p<f.length;p++)if(!d.test(f[p]))return!1;return!e.blacklisted_chars||-1===a.search(new RegExp("[".concat(e.blacklisted_chars,"]+"),"g"))}function Wn(t){const e=t.width?t.width:t.compact?60:80,{stroke:n=8,secondaryColor:r}=t;return qe("div",Object.assign({"aria-label":"oval-loading"},{children:qe("svg",Object.assign({width:e,height:e,viewBox:Fn(Number(n),20),xmlns:"http://www.w3.org/2000/svg",className:"xar-loader-circle","data-testid":"oval-svg"},{children:qe("g",Object.assign({fill:"none",fillRule:"evenodd"},{children:qe("g",Object.assign({transform:"translate(1 1)","stroke-width":n,"data-testid":"oval-secondary-group"},{children:[qe("circle",{strokeOpacity:".5",cx:"0",cy:"0",r:20,stroke:r,"stroke-width":n,opacity:.3}),qe("path",Object.assign({d:Dn(20),stroke:t.strokeColor},{children:qe("animateTransform",{attributeName:"transform",type:"rotate",from:"0 0 0",to:"360 0 0",dur:"1s",repeatCount:"indefinite"})}))]}))}))}))}))}const Fn=(t,e)=>{const n=-e-t/2+1,r=2*e+t;return[n,n,r,r].join(" ")},Dn=t=>["M"+t+" 0c0-9.94-8.06",t,t,t].join("-");!function(t,e){void 0===e&&(e={});var n=e.insertAt;if(t&&"undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css","top"===n&&r.firstChild?r.insertBefore(i,r.firstChild):r.appendChild(i),i.styleSheet?i.styleSheet.cssText=t:i.appendChild(document.createTextNode(t))}}("@import url('https://fonts.googleapis.com/css2?family=Sora:wght@100;400;600;700&display=block');\n@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;700&family=Sora:wght@400;600&display=block');\n\n.xar-light-mode {\n  --fg: #333333;\n  --bg: #eff1f3;\n  --background: #fcfcfc;\n  --inputShadow: 0 0 8px 3px rgba(126, 126, 126, 0.25);\n  --text-color: #101010;\n  --otp-bg: #eeeeee;\n  --otp-shadow: 1px 1px 2px 0px #aeaec033 inset,\n    -1px -1px 1px 0px #ffffffb2 inset;\n}\n\n.xar-dark-mode {\n  --fg: #ffffff;\n  --bg: #313131;\n  --background: #262626;\n  --inputShadow: 0 0 8px 3px rgba(0, 0, 0, 0.05);\n  --text-color: #f7f7f7;\n  --otp-bg: linear-gradient(141.48deg, #161616 -4.56%, #151515 135.63%);\n  --otp-shadow: -50px 49px 29px 22px #1c1c1cd6 inset,\n    5px 5px 10px 0px #0b0b0b80 inset;\n}\n\n.compact {\n  --modal-height: 235px;\n  --loader-font-size: 14px;\n  --loader-font-weight: 400;\n  --success-img-width: 70px;\n  --action-link-size: 12px;\n}\n\n.full {\n  --modal-height: 480px;\n  --loader-font-size: 20px;\n  --loader-font-weight: 700;\n  --success-img-width: 100px;\n  --action-link-size: 15px;\n}\n\n#xar-modal {\n  display: flex;\n  align-items: center;\n  justify-content: center;\n  position: fixed;\n  z-index: 2147483648;\n  left: 0;\n  top: 0;\n  width: 100%;\n  height: 100%;\n  overflow: auto;\n  background: rgba(10, 10, 10, 0.7);\n  backdrop-filter: blur(16px);\n  font-family: Sora, sans-serif;\n}\n\n.xar-header-logo__container {\n  width: 70px;\n  height: 70px;\n  border-radius: 50%;\n  margin: 0 auto;\n  display: flex;\n  align-items: center;\n  justify-content: center;\n  border: 2px solid var(--fg);\n}\n\n.xar-header-logo__empty-container {\n  width: 70px;\n  height: 70px;\n  border-radius: 50%;\n  margin: 0 auto;\n  display: flex;\n  align-items: center;\n  justify-content: center;\n}\n\n.xar-header-logo {\n  max-width: 60px;\n  max-height: 60px;\n  margin: 0 auto;\n  display: inline-block;\n}\n\n.xar-header-heading {\n  font-family: 'Sora', sans-serif;\n  text-align: center;\n}\n\n.xar-header-subtext {\n  font-family: 'Sora', sans-serif;\n  font-size: 12px;\n  font-weight: 400;\n  max-width: 200px;\n}\n\n.xar-email-login {\n  display: flex;\n  flex-direction: column;\n  width: 100%;\n}\n\n.xar-email-login > *:not(:first-child) {\n  margin-top: 20px;\n}\n\n.xar-email-login__label {\n  text-align: left;\n  font-size: 14px;\n  color: var(--fg);\n  font-weight: 400;\n}\n\n.xar-success__img {\n  max-width: var(--success-img-width);\n}\n\n.xar-email-login__input {\n  height: 45px;\n  padding: 0 16px;\n  font-family: 'Sora', sans-serif;\n  font-size: 14px;\n  font-weight: 400;\n  color: var(--fg);\n  background: var(--bg);\n  border: none;\n  border-radius: 5px;\n  outline: none;\n  box-shadow: var(--inputShadow);\n}\n\n.xar-social-container {\n  display: flex;\n  justify-content: center;\n  gap: 1rem;\n  flex-wrap: wrap;\n}\n\n.xar-social-icon__wrapper {\n  display: flex;\n  background: var(--fg);\n  width: 42px;\n  height: 42px;\n  border-radius: 50%;\n  align-items: center;\n}\n\n.xar-social-icon__wrapper:hover {\n  cursor: pointer;\n  transition: all 0.5s;\n  transform: scale(1.15, 1.15);\n}\n\n.xar-social-icon {\n  margin: 0 auto;\n  width: 24px;\n  max-height: 24px;\n}\n\n.xar-container {\n  padding: 30px 30px 20px;\n  width: 325px;\n  min-height: var(--modal-height);\n  background-color: var(--background);\n  color: var(--fg);\n  margin: 0 auto;\n  font-family: 'Sora', sans-serif;\n  box-shadow: 4px 5px 4px rgba(0, 0, 0, 0.25);\n  border-radius: 10px;\n  box-sizing: content-box;\n  transition: all 1s ease;\n}\n\n.xar-inner-container {\n  min-height: inherit;\n  display: flex;\n  flex-direction: column;\n  align-items: center;\n  justify-content: center;\n  text-align: center;\n}\n\n.xar-inner-container > *:not(:first-child) {\n  margin-top: 20px;\n}\n\n.xar-btn {\n  margin: 0 auto;\n  padding: 0;\n  width: 100%;\n  height: 2.75rem;\n  font-size: 14px;\n  font-weight: 600;\n  text-transform: uppercase;\n  color: var(--bg);\n  background: var(--fg);\n  border: none;\n  border-radius: 5px;\n}\n\n.xar-btn:disabled {\n  opacity: 0.7;\n}\n\n.xar-btn:hover:enabled {\n  cursor: pointer;\n  transition: all 0.5s;\n  transform: scale(1.05, 1.15);\n}\n\n.xar-btn:disabled,\n.xar-btn[disabled] {\n  cursor: not-allowed;\n}\n\n.xar-footer {\n  display: flex;\n  align-items: center;\n  justify-content: center;\n  margin-top: 1rem;\n}\n\n.xar-footer-text {\n  font-size: 12px;\n  font-weight: 400;\n}\n\n.xar-footer-img__link {\n  height: 15px;\n}\n\n.xar-footer-img {\n  display: block;\n}\n\n.xar-separator {\n  width: 100%;\n  display: flex;\n  align-items: center;\n  text-align: center;\n}\n\n.xar-separator:before,\n.xar-separator:after {\n  content: '';\n  flex: 1 1 auto;\n  border-bottom: 1px solid var(--fg);\n}\n\n.xar-separator:before {\n  margin-right: 1rem;\n}\n\n.xar-separator:after {\n  margin-left: 1rem;\n}\n\n.xar-action__link {\n  border: 0;\n  background: none;\n  text-underline-offset: 3px;\n  text-transform: uppercase;\n  text-decoration: underline;\n  color: #3e9aff;\n  font-weight: 700;\n  font-size: var(--action-link-size);\n  line-height: 19px;\n  cursor: pointer;\n}\n\n.xar-action__link:disabled {\n  color: #667b91;\n  cursor: not-allowed;\n}\n\n.xar-loader__text {\n  font-size: var(--loader-font-size);\n  font-weight: var(--loader-font-weight);\n}\n\n.xar-loader-circle {\n  stroke: var(--fg);\n}\n\n.xar-otp-box {\n  display: flex;\n  gap: 0.5em;\n}\n\n.xar-otp-input {\n  color: var(--fg);\n  font-size: 20px;\n  font-weight: 400;\n  border: none;\n  outline: none;\n  text-align: center;\n  width: 30px;\n  height: 35px;\n  border-radius: 10px;\n  background: var(--otp-bg);\n  box-shadow: var(--otp-shadow);\n}\n\n.xar-invalid-otp {\n  border: 1px solid #b43030;\n}\n\n.xar-invalid-otp-text {\n  color: #b43030;\n}\n\n.xar-otp-input:disabled {\n  opacity: 0.5;\n}\n\n.xar-otp-heading {\n  font-family: 'Montserrat', sans-serif;\n  font-size: 24px;\n  font-weight: 700;\n  text-align: center;\n  color: var(--text-color);\n}\n\n.xar-otp-sub-heading {\n  font-family: 'Montserrat', sans-serif;\n  font-size: 12px;\n  font-weight: 400;\n  text-align: center;\n  color: var(--text-color);\n}\n\n.xar-otp-error-heading {\n  color: var(--fg);\n  font-weight: 700;\n  font-size: 24px;\n  font-family: 'Montserrat', sans-serif;\n}\n.xar-otp-error-subheading {\n  color: var(--text-color);\n  font-weight: 400;\n  font-size: 12px;\n  font-family: 'Montserrat', sans-serif;\n}\n");const jn=({compact:t,logo:e})=>{const[n,r]=sn(!1);return qe(Se,{children:[n?"":qe("div",{className:"xar-header-logo__empty-container"}),qe("div",Object.assign({className:"xar-header-logo__container",style:n?{}:{display:"none"}},{children:qe("img",{className:"xar-header-logo",src:e,alt:"app-logo",onLoad:()=>{r(!1)}})})),t?"":qe("div",Object.assign({className:"xar-header-text"},{children:[qe("h1",Object.assign({className:"xar-header-heading"},{children:"Welcome"})),qe("p",Object.assign({className:"xar-header-subtext"},{children:"We’ll email you a login link for a password-free sign in."}))]}))]})},qn=({loginWithOTPStart:t,email:e,setEmail:r})=>{const[i,o]=sn(!0);return cn((()=>{o(!$n(e))}),[]),qe("form",Object.assign({className:"xar-email-login"},{children:[qe("input",{value:e,onInput:t=>{r(t.currentTarget.value),o(!$n(t.currentTarget.value))},className:"xar-email-login__input",type:"text",placeholder:"Enter your email"}),qe("button",Object.assign({disabled:i,onClick:r=>n(void 0,void 0,void 0,(function*(){if(r.preventDefault(),!e)return;o(!0);const n=yield t(e);yield n.begin(),o(!1)})),className:"xar-btn"},{children:"Get Login OTP"}))]}))},Kn=({text:t})=>qe("div",Object.assign({className:"xar-separator"},{children:t})),Hn=({loginWithSocial:t,loginList:e,mode:n})=>qe("div",Object.assign({className:"xar-social-container"},{children:e.map((e=>{return qe("div",Object.assign({className:"xar-social-icon__wrapper",onClick:()=>(e=>t(e))(e)},{children:qe("img",{src:(r=e,i=n,bn[`${r}_${i}`]?bn[`${r}_${i}`]:bn[r]),alt:`${e} logo`,className:"xar-social-icon"})}));var r,i}))})),Vn=({mode:t})=>{const e=wn[t];return qe("div",Object.assign({className:"xar-footer"},{children:qe("a",Object.assign({href:"https://arcana.network",target:"_blank",className:"xar-footer-img__link"},{children:qe("img",{className:"xar-footer-img",src:e,alt:"Secured By Arcana"})}))}))},Gn=t=>qe(Se,{children:[t.header?t.header:qe(Wn,{compact:t.compact,stroke:8,secondaryColor:"#8D8D8D"}),t.text?qe("p",Object.assign({className:"xar-loader__text"},{children:t.text})):"",t.children?qe(Se,{children:t.children}):""]}),Jn=({loginWithOtpStart:t,loginWithOtpComplete:e,setError:r,closeFunc:i,compact:o})=>{const{counter:s,resetCounter:a}=Zn(30),[c,u]=sn(3),[l,h]=sn(!1),[d,f]=sn({loading:!1,text:""}),[p,g]=sn(""),[m,y]=sn(0),b=un([]),w=()=>p?p.toString().split(""):[],v=()=>{i()};cn((()=>{6==p.length&&(h(!1),_(),f({loading:!0,text:"Processing..."}),e(p,v).then((()=>f({loading:!1,text:""}))).catch((t=>{console.log(t),u((t=>t-1)),h(!0),f({loading:!1,text:""}),g(""),k()})))}),[p]),cn((()=>{0==c&&r()}),[c]),cn((()=>{var t;null===(t=b.current[0])||void 0===t||t.focus()}),[]);const _=()=>{for(let t=0;t<6;t++){const e=b.current[t];e&&(e.disabled=!0)}},k=()=>{for(let t=0;t<6;t++){const e=b.current[t];e&&(e.disabled=!1)}},S=t=>{const e=w();e[m]=t[0],x(e)},x=t=>{const e=t.join("");g(e)},E=t=>{const e=t.target;var n;n=e.value,isNaN(Number(n))||1!==n.trim().length?(null===t.data&&"deleteContentBackward"===t.inputType&&(t.preventDefault(),S(""),A(m-1)),e.value=""):(S(e.value),A(m+1))},I=t=>{const e=w();[t.code,t.key].includes("Backspace")?(t.preventDefault(),S(""),A(m-1)):"Delete"===t.code?(t.preventDefault(),S("")):"ArrowLeft"===t.code?(t.preventDefault(),A(m-1)):"ArrowRight"===t.code||t.key===e[m]?(t.preventDefault(),A(m+1)):"Spacebar"!==t.code&&"Space"!==t.code&&"ArrowUp"!==t.code&&"ArrowDown"!==t.code||t.preventDefault()},A=t=>{var e,n;const r=Math.max(Math.min(5,t),0);b.current[r]&&(null===(e=b.current[r])||void 0===e||e.focus(),null===(n=b.current[r])||void 0===n||n.select(),y(r))},B=t=>{var e;t.preventDefault();const n=w();let r=m;if(!t.clipboardData)return;const i=t.clipboardData.getData("text/plain").slice(0,6-m).split("");if(!i.some((t=>isNaN(Number(t))))){for(let t=0;t<6;++t)t>=m&&i.length>0&&(n[t]=null!==(e=i.shift())&&void 0!==e?e:"",r++);A(r),x(n)}};return d.loading?qe(Se,{children:[qe(Wn,{stroke:8,secondaryColor:"#8D8D8D",compact:o}),qe("div",Object.assign({class:"xar-loader__text"},{children:d.text}))]}):qe(Se,{children:[qe("div",Object.assign({class:"xar-otp-heading"},{children:"Verification"})),qe("div",Object.assign({class:"xar-otp-sub-heading"},{children:["Please enter the OTP that was sent to your ",qe("br",{}),"email address"]})),qe("div",Object.assign({className:"xar-otp-box"},{children:Array(6).fill(null).map(((t,e)=>{var n;return qe("input",{value:null!==(n=w()[e])&&void 0!==n?n:"",type:"text",maxLength:1,autoComplete:"off",ref:t=>b.current[e]=t,onFocus:t=>(t=>e=>{y(e),t.target.select()})(t)(e),onInput:E,onKeyDown:I,onPaste:B,className:l?"xar-otp-input xar-invalid-otp":"xar-otp-input"},e)}))})),l?qe("div",{children:qe("p",Object.assign({class:"xar-invalid-otp-text"},{children:["Incorrect OTP. ",c," attempts left."]}))}):"",qe("div",{children:qe(Qn,{disabled:s>0,text:s>0?`Resend code in ${s} seconds`:"Resend code",method:()=>n(void 0,void 0,void 0,(function*(){f({loading:!0,text:"Sending OTP to your email address"}),yield t(),a(),f({loading:!1,text:""})}))})})]})},Zn=(t=60)=>{const[e,n]=sn(t);return cn((()=>{if(0==e)return void n(0);const t=setInterval((()=>{n(e-1)}),1e3);return()=>clearInterval(t)}),[e]),{counter:e,resetCounter:()=>n(t)}},Yn=({action:t})=>qe(Se,{children:[qe("img",{class:"xar-header-logo",src:yt,alt:"failed"}),qe("h2",Object.assign({class:"xar-otp-error-heading"},{children:"Login Failed"})),qe("p",Object.assign({class:"xar-otp-error-subheading"},{children:"Please check credentials and try again"})),qe("button",Object.assign({className:"xar-btn",onClick:t},{children:"Go Home"}))]}),Xn=({children:t,mode:e})=>qe("div",Object.assign({class:"xar-container"},{children:[qe("div",Object.assign({class:"xar-inner-container"},{children:t})),qe(Vn,{mode:e})]})),Qn=({text:t,method:e,disabled:n=!1})=>qe("div",Object.assign({class:"xar-action-container"},{children:qe("button",Object.assign({disabled:n,onClick:()=>e(),className:"xar-action__link"},{children:t}))})),tr="xar-modal",er=t=>qe("div",Object.assign({id:tr,onClick:e=>{var n;(null===(n=e.target)||void 0===n?void 0:n.id)==tr&&t.closeFunc&&t.closeFunc(new Error("User closed the connect modal"))}},{children:t.children})),nr={SOCIAL:"Please complete the login to proceed",OTP_INIT:"Sending login OTP to your email address",OTP_SENT:"",OTP_SENT_GLOBAL:"Please complete the login to proceed",OTP_ERROR:"Invalid OTP, please try again"},rr={text:"",loading:!1,type:""},ir=(t,e)=>"OTP_SENT_GLOBAL"==e||"SOCIAL"==e||"OTP_SENT"==e||"OTP_INIT"==e||"OTP_ERROR"==e?{text:nr[e],type:e,loading:"OTP_ERROR"!=e}:"RESET"==e?rr:t,or=t=>{const[e,r]=an(ir,rr),[i,o]=sn("");return e.loading?qe(er,{children:qe(Xn,Object.assign({mode:t.mode},{children:"OTP_SENT"==e.type?qe(Jn,{loginWithOtpStart:()=>t.loginWithOTPStart(i),setError:()=>r("OTP_ERROR"),closeFunc:t.closeFunc,loginWithOtpComplete:t.loginWithOTPComplete,compact:t.options.compact}):qe(Gn,{compact:t.options.compact,text:e.text,mode:t.mode})}))}):qe(er,Object.assign({closeFunc:t.closeFunc},{children:qe(Xn,Object.assign({mode:t.mode},{children:"OTP_ERROR"==e.type?qe(Yn,{action:()=>r("RESET")}):qe(Se,{children:[qe(jn,{compact:t.options.compact,logo:t.logo}),qe(qn,{email:i,setEmail:o,loginWithOTPStart:e=>n(void 0,void 0,void 0,(function*(){r("OTP_INIT");const n=yield t.loginWithOTPStart(e);return r(n.isCompleteRequired?"OTP_SENT":"OTP_SENT_GLOBAL"),n}))}),t.loginList.length>0?qe(Se,{children:[qe(Kn,{text:"or continue with"}),qe(Hn,{loginWithSocial:e=>n(void 0,void 0,void 0,(function*(){r("SOCIAL"),t.loginWithSocial(e).finally((()=>{r("RESET")}))})),loginList:t.loginList,mode:t.mode})]}):null]})}))}))};class sr{constructor(t){this.status="closed",this.close=t=>{"closed"!==this.status&&(this.onClose(t),this.status="closed",De(null,this.container))},this.params={loginList:t.loginList.filter((t=>"passwordless"!==t)),loginWithSocial:t.loginWithSocial,loginWithOTPStart:t.loginWithOTPStart,loginWithOTPComplete:t.loginWithOTPComplete,mode:t.mode,closeFunc:this.close,logo:t.logo,options:t.options},this.createContainer()}open(t){"open"!==this.status&&(this.onClose=t,this.status="open",De(qe(or,Object.assign({},this.params)),this.container))}createContainer(){const t=this.params.options.compact?"compact":"full";this.container=document.createElement("div"),this.container.setAttribute("id","xar-login-container"),this.container.classList.add(`xar-${this.params.mode}-mode`),this.container.classList.add(t),document.body.appendChild(this.container)}}class ar{static create(t){return n(this,void 0,void 0,(function*(){const[e,n]=yield Promise.all([Promise.resolve().then((function(){return Ry})),Promise.resolve().then((function(){return Uy}))]);return new ar(t,e,n)}))}constructor(t,e,n){this.p=t,this.web3Module=e,this.bs58Module=n}get isConnected(){return this.p.connected}request(t){return n(this,void 0,void 0,(function*(){const e=structuredClone(t);if("signMessage"===e.method){const t=e.params;t.message instanceof Uint8Array&&(t.message=this.bs58Module.encode(t.message))}const n=yield this.p.request(e);switch(e.method){case"signMessage":return this.parseSignatureResponse(n);case"signTransaction":return this.web3Module.VersionedTransaction.deserialize(this.bs58Module.decode(n));case"signAllTransactions":return n.map((t=>this.web3Module.VersionedTransaction.deserialize(this.bs58Module.decode(t))));default:return n}}))}parseSignatureResponse(t){return{signature:this.bs58Module.decode(t.signature),publicKey:new this.web3Module.PublicKey(t.publicKey)}}signMessage(t,e){return this.request({method:"signMessage",params:{message:this.bs58Module.encode(t),display:e}})}signTransaction(t){return this.request({method:"signTransaction",params:{message:this.bs58Module.encode(t.serialize())}})}signAndSendTransaction(t){return this.request({method:"signAndSendTransaction",params:{message:this.bs58Module.encode(t.serialize())}})}signAllTransactions(t){const e=this.request({method:"signAllTransactions",params:{message:t.map((t=>this.bs58Module.encode(t.serialize())))}});return e}}for(var cr={},ur={byteLength:function(t){var e=gr(t),n=e[0],r=e[1];return 3*(n+r)/4-r},toByteArray:function(t){var e,n,r=gr(t),i=r[0],o=r[1],s=new dr(function(t,e,n){return 3*(e+n)/4-n}(0,i,o)),a=0,c=o>0?i-4:i;for(n=0;n<c;n+=4)e=hr[t.charCodeAt(n)]<<18|hr[t.charCodeAt(n+1)]<<12|hr[t.charCodeAt(n+2)]<<6|hr[t.charCodeAt(n+3)],s[a++]=e>>16&255,s[a++]=e>>8&255,s[a++]=255&e;2===o&&(e=hr[t.charCodeAt(n)]<<2|hr[t.charCodeAt(n+1)]>>4,s[a++]=255&e);1===o&&(e=hr[t.charCodeAt(n)]<<10|hr[t.charCodeAt(n+1)]<<4|hr[t.charCodeAt(n+2)]>>2,s[a++]=e>>8&255,s[a++]=255&e);return s},fromByteArray:function(t){for(var e,n=t.length,r=n%3,i=[],o=16383,s=0,a=n-r;s<a;s+=o)i.push(mr(t,s,s+o>a?a:s+o));1===r?(e=t[n-1],i.push(lr[e>>2]+lr[e<<4&63]+"==")):2===r&&(e=(t[n-2]<<8)+t[n-1],i.push(lr[e>>10]+lr[e>>4&63]+lr[e<<2&63]+"="));return i.join("")}},lr=[],hr=[],dr="undefined"!=typeof Uint8Array?Uint8Array:Array,fr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",pr=0;pr<64;++pr)lr[pr]=fr[pr],hr[fr.charCodeAt(pr)]=pr;function gr(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}function mr(t,e,n){for(var r,i,o=[],s=e;s<n;s+=3)r=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(255&t[s+2]),o.push(lr[(i=r)>>18&63]+lr[i>>12&63]+lr[i>>6&63]+lr[63&i]);return o.join("")}hr["-".charCodeAt(0)]=62,hr["_".charCodeAt(0)]=63;var yr={/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
read:function(t,e,n,r,i){var o,s,a=8*i-r-1,c=(1<<a)-1,u=c>>1,l=-7,h=n?i-1:0,d=n?-1:1,f=t[e+h];for(h+=d,o=f&(1<<-l)-1,f>>=-l,l+=a;l>0;o=256*o+t[e+h],h+=d,l-=8);for(s=o&(1<<-l)-1,o>>=-l,l+=r;l>0;s=256*s+t[e+h],h+=d,l-=8);if(0===o)o=1-u;else{if(o===c)return s?NaN:1/0*(f?-1:1);s+=Math.pow(2,r),o-=u}return(f?-1:1)*s*Math.pow(2,o-r)},write:function(t,e,n,r,i,o){var s,a,c,u=8*o-i-1,l=(1<<u)-1,h=l>>1,d=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=r?0:o-1,p=r?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=l):(s=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-s))<1&&(s--,c*=2),(e+=s+h>=1?d/c:d*Math.pow(2,1-h))*c>=2&&(s++,c/=2),s+h>=l?(a=0,s=l):s+h>=1?(a=(e*c-1)*Math.pow(2,i),s+=h):(a=e*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;t[n+f]=255&a,f+=p,a/=256,i-=8);for(s=s<<i|a,u+=i;u>0;t[n+f]=255&s,f+=p,s/=256,u-=8);t[n+f-p]|=128*g}};
/*!
 * The buffer module from node.js, for the browser.
 *
 * @author   Feross Aboukhadijeh <https://feross.org>
 * @license  MIT
 */
!function(t){const e=ur,n=yr,r="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=s,t.SlowBuffer=function(t){+t!=t&&(t=0);return s.alloc(+t)},t.INSPECT_MAX_BYTES=50;const i=2147483647;function o(t){if(t>i)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,s.prototype),e}function s(t,e,n){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return u(t)}return a(t,e,n)}function a(t,e,n){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const n=0|f(t,e);let r=o(n);const i=r.write(t,e);i!==n&&(r=r.slice(0,i));return r}(t,e);if(ArrayBuffer.isView(t))return function(t){if(V(t,Uint8Array)){const e=new Uint8Array(t);return h(e.buffer,e.byteOffset,e.byteLength)}return l(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(V(t,ArrayBuffer)||t&&V(t.buffer,ArrayBuffer))return h(t,e,n);if("undefined"!=typeof SharedArrayBuffer&&(V(t,SharedArrayBuffer)||t&&V(t.buffer,SharedArrayBuffer)))return h(t,e,n);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const r=t.valueOf&&t.valueOf();if(null!=r&&r!==t)return s.from(r,e,n);const i=function(t){if(s.isBuffer(t)){const e=0|d(t.length),n=o(e);return 0===n.length||t.copy(n,0,0,e),n}if(void 0!==t.length)return"number"!=typeof t.length||G(t.length)?o(0):l(t);if("Buffer"===t.type&&Array.isArray(t.data))return l(t.data)}(t);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return s.from(t[Symbol.toPrimitive]("string"),e,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function c(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function u(t){return c(t),o(t<0?0:0|d(t))}function l(t){const e=t.length<0?0:0|d(t.length),n=o(e);for(let r=0;r<e;r+=1)n[r]=255&t[r];return n}function h(t,e,n){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(n||0))throw new RangeError('"length" is outside of buffer bounds');let r;return r=void 0===e&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,e):new Uint8Array(t,e,n),Object.setPrototypeOf(r,s.prototype),r}function d(t){if(t>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|t}function f(t,e){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||V(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const n=t.length,r=arguments.length>2&&!0===arguments[2];if(!r&&0===n)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return q(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return K(t).length;default:if(i)return r?-1:q(t).length;e=(""+e).toLowerCase(),i=!0}}function p(t,e,n){let r=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return B(this,e,n);case"utf8":case"utf-8":return x(this,e,n);case"ascii":return I(this,e,n);case"latin1":case"binary":return A(this,e,n);case"base64":return S(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}function g(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function m(t,e,n,r,i){if(0===t.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),G(n=+n)&&(n=i?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(i)return-1;n=t.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof e&&(e=s.from(e,r)),s.isBuffer(e))return 0===e.length?-1:y(t,e,n,r,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):y(t,[e],n,r,i);throw new TypeError("val must be string, number or Buffer")}function y(t,e,n,r,i){let o,s=1,a=t.length,c=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;s=2,a/=2,c/=2,n/=2}function u(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(i){let r=-1;for(o=n;o<a;o++)if(u(t,o)===u(e,-1===r?0:o-r)){if(-1===r&&(r=o),o-r+1===c)return r*s}else-1!==r&&(o-=o-r),r=-1}else for(n+c>a&&(n=a-c),o=n;o>=0;o--){let n=!0;for(let r=0;r<c;r++)if(u(t,o+r)!==u(e,r)){n=!1;break}if(n)return o}return-1}function b(t,e,n,r){n=Number(n)||0;const i=t.length-n;r?(r=Number(r))>i&&(r=i):r=i;const o=e.length;let s;for(r>o/2&&(r=o/2),s=0;s<r;++s){const r=parseInt(e.substr(2*s,2),16);if(G(r))return s;t[n+s]=r}return s}function w(t,e,n,r){return H(q(e,t.length-n),t,n,r)}function v(t,e,n,r){return H(function(t){const e=[];for(let n=0;n<t.length;++n)e.push(255&t.charCodeAt(n));return e}(e),t,n,r)}function _(t,e,n,r){return H(K(e),t,n,r)}function k(t,e,n,r){return H(function(t,e){let n,r,i;const o=[];for(let s=0;s<t.length&&!((e-=2)<0);++s)n=t.charCodeAt(s),r=n>>8,i=n%256,o.push(i),o.push(r);return o}(e,t.length-n),t,n,r)}function S(t,n,r){return 0===n&&r===t.length?e.fromByteArray(t):e.fromByteArray(t.slice(n,r))}function x(t,e,n){n=Math.min(t.length,n);const r=[];let i=e;for(;i<n;){const e=t[i];let o=null,s=e>239?4:e>223?3:e>191?2:1;if(i+s<=n){let n,r,a,c;switch(s){case 1:e<128&&(o=e);break;case 2:n=t[i+1],128==(192&n)&&(c=(31&e)<<6|63&n,c>127&&(o=c));break;case 3:n=t[i+1],r=t[i+2],128==(192&n)&&128==(192&r)&&(c=(15&e)<<12|(63&n)<<6|63&r,c>2047&&(c<55296||c>57343)&&(o=c));break;case 4:n=t[i+1],r=t[i+2],a=t[i+3],128==(192&n)&&128==(192&r)&&128==(192&a)&&(c=(15&e)<<18|(63&n)<<12|(63&r)<<6|63&a,c>65535&&c<1114112&&(o=c))}}null===o?(o=65533,s=1):o>65535&&(o-=65536,r.push(o>>>10&1023|55296),o=56320|1023&o),r.push(o),i+=s}return function(t){const e=t.length;if(e<=E)return String.fromCharCode.apply(String,t);let n="",r=0;for(;r<e;)n+=String.fromCharCode.apply(String,t.slice(r,r+=E));return n}(r)}t.kMaxLength=i,s.TYPED_ARRAY_SUPPORT=function(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),s.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||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."),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}}),s.poolSize=8192,s.from=function(t,e,n){return a(t,e,n)},Object.setPrototypeOf(s.prototype,Uint8Array.prototype),Object.setPrototypeOf(s,Uint8Array),s.alloc=function(t,e,n){return function(t,e,n){return c(t),t<=0?o(t):void 0!==e?"string"==typeof n?o(t).fill(e,n):o(t).fill(e):o(t)}(t,e,n)},s.allocUnsafe=function(t){return u(t)},s.allocUnsafeSlow=function(t){return u(t)},s.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==s.prototype},s.compare=function(t,e){if(V(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),V(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),!s.isBuffer(t)||!s.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let n=t.length,r=e.length;for(let i=0,o=Math.min(n,r);i<o;++i)if(t[i]!==e[i]){n=t[i],r=e[i];break}return n<r?-1:r<n?1:0},s.isEncoding=function(t){switch(String(t).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(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return s.alloc(0);let n;if(void 0===e)for(e=0,n=0;n<t.length;++n)e+=t[n].length;const r=s.allocUnsafe(e);let i=0;for(n=0;n<t.length;++n){let e=t[n];if(V(e,Uint8Array))i+e.length>r.length?(s.isBuffer(e)||(e=s.from(e)),e.copy(r,i)):Uint8Array.prototype.set.call(r,e,i);else{if(!s.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(r,i)}i+=e.length}return r},s.byteLength=f,s.prototype._isBuffer=!0,s.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)g(this,e,e+1);return this},s.prototype.swap32=function(){const t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)g(this,e,e+3),g(this,e+1,e+2);return this},s.prototype.swap64=function(){const t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)g(this,e,e+7),g(this,e+1,e+6),g(this,e+2,e+5),g(this,e+3,e+4);return this},s.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?x(this,0,t):p.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){let e="";const n=t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,n).replace(/(.{2})/g,"$1 ").trim(),this.length>n&&(e+=" ... "),"<Buffer "+e+">"},r&&(s.prototype[r]=s.prototype.inspect),s.prototype.compare=function(t,e,n,r,i){if(V(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),e<0||n>t.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&e>=n)return 0;if(r>=i)return-1;if(e>=n)return 1;if(this===t)return 0;let o=(i>>>=0)-(r>>>=0),a=(n>>>=0)-(e>>>=0);const c=Math.min(o,a),u=this.slice(r,i),l=t.slice(e,n);for(let t=0;t<c;++t)if(u[t]!==l[t]){o=u[t],a=l[t];break}return o<a?-1:a<o?1:0},s.prototype.includes=function(t,e,n){return-1!==this.indexOf(t,e,n)},s.prototype.indexOf=function(t,e,n){return m(this,t,e,n,!0)},s.prototype.lastIndexOf=function(t,e,n){return m(this,t,e,n,!1)},s.prototype.write=function(t,e,n,r){if(void 0===e)r="utf8",n=this.length,e=0;else if(void 0===n&&"string"==typeof e)r=e,n=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(n)?(n>>>=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}const i=this.length-e;if((void 0===n||n>i)&&(n=i),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");let o=!1;for(;;)switch(r){case"hex":return b(this,t,e,n);case"utf8":case"utf-8":return w(this,t,e,n);case"ascii":case"latin1":case"binary":return v(this,t,e,n);case"base64":return _(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,e,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const E=4096;function I(t,e,n){let r="";n=Math.min(t.length,n);for(let i=e;i<n;++i)r+=String.fromCharCode(127&t[i]);return r}function A(t,e,n){let r="";n=Math.min(t.length,n);for(let i=e;i<n;++i)r+=String.fromCharCode(t[i]);return r}function B(t,e,n){const r=t.length;(!e||e<0)&&(e=0),(!n||n<0||n>r)&&(n=r);let i="";for(let r=e;r<n;++r)i+=J[t[r]];return i}function P(t,e,n){const r=t.slice(e,n);let i="";for(let t=0;t<r.length-1;t+=2)i+=String.fromCharCode(r[t]+256*r[t+1]);return i}function T(t,e,n){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>n)throw new RangeError("Trying to access beyond buffer length")}function M(t,e,n,r,i,o){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(n+r>t.length)throw new RangeError("Index out of range")}function C(t,e,n,r,i){W(e,r,i,t,n,7);let o=Number(e&BigInt(4294967295));t[n++]=o,o>>=8,t[n++]=o,o>>=8,t[n++]=o,o>>=8,t[n++]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[n++]=s,s>>=8,t[n++]=s,s>>=8,t[n++]=s,s>>=8,t[n++]=s,n}function O(t,e,n,r,i){W(e,r,i,t,n,7);let o=Number(e&BigInt(4294967295));t[n+7]=o,o>>=8,t[n+6]=o,o>>=8,t[n+5]=o,o>>=8,t[n+4]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[n+3]=s,s>>=8,t[n+2]=s,s>>=8,t[n+1]=s,s>>=8,t[n]=s,n+8}function R(t,e,n,r,i,o){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function L(t,e,r,i,o){return e=+e,r>>>=0,o||R(t,0,r,4),n.write(t,e,r,i,23,4),r+4}function N(t,e,r,i,o){return e=+e,r>>>=0,o||R(t,0,r,8),n.write(t,e,r,i,52,8),r+8}s.prototype.slice=function(t,e){const n=this.length;(t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t);const r=this.subarray(t,e);return Object.setPrototypeOf(r,s.prototype),r},s.prototype.readUintLE=s.prototype.readUIntLE=function(t,e,n){t>>>=0,e>>>=0,n||T(t,e,this.length);let r=this[t],i=1,o=0;for(;++o<e&&(i*=256);)r+=this[t+o]*i;return r},s.prototype.readUintBE=s.prototype.readUIntBE=function(t,e,n){t>>>=0,e>>>=0,n||T(t,e,this.length);let r=this[t+--e],i=1;for(;e>0&&(i*=256);)r+=this[t+--e]*i;return r},s.prototype.readUint8=s.prototype.readUInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),this[t]},s.prototype.readUint16LE=s.prototype.readUInt16LE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUint16BE=s.prototype.readUInt16BE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUint32LE=s.prototype.readUInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUint32BE=s.prototype.readUInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readBigUInt64LE=Z((function(t){F(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||D(t,this.length-8);const r=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,i=this[++t]+256*this[++t]+65536*this[++t]+n*2**24;return BigInt(r)+(BigInt(i)<<BigInt(32))})),s.prototype.readBigUInt64BE=Z((function(t){F(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||D(t,this.length-8);const r=e*2**24+65536*this[++t]+256*this[++t]+this[++t],i=this[++t]*2**24+65536*this[++t]+256*this[++t]+n;return(BigInt(r)<<BigInt(32))+BigInt(i)})),s.prototype.readIntLE=function(t,e,n){t>>>=0,e>>>=0,n||T(t,e,this.length);let r=this[t],i=1,o=0;for(;++o<e&&(i*=256);)r+=this[t+o]*i;return i*=128,r>=i&&(r-=Math.pow(2,8*e)),r},s.prototype.readIntBE=function(t,e,n){t>>>=0,e>>>=0,n||T(t,e,this.length);let r=e,i=1,o=this[t+--r];for(;r>0&&(i*=256);)o+=this[t+--r]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},s.prototype.readInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){t>>>=0,e||T(t,2,this.length);const n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},s.prototype.readInt16BE=function(t,e){t>>>=0,e||T(t,2,this.length);const n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},s.prototype.readInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readBigInt64LE=Z((function(t){F(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||D(t,this.length-8);const r=this[t+4]+256*this[t+5]+65536*this[t+6]+(n<<24);return(BigInt(r)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)})),s.prototype.readBigInt64BE=Z((function(t){F(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||D(t,this.length-8);const r=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(r)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+n)})),s.prototype.readFloatLE=function(t,e){return t>>>=0,e||T(t,4,this.length),n.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return t>>>=0,e||T(t,4,this.length),n.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return t>>>=0,e||T(t,8,this.length),n.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return t>>>=0,e||T(t,8,this.length),n.read(this,t,!1,52,8)},s.prototype.writeUintLE=s.prototype.writeUIntLE=function(t,e,n,r){if(t=+t,e>>>=0,n>>>=0,!r){M(this,t,e,n,Math.pow(2,8*n)-1,0)}let i=1,o=0;for(this[e]=255&t;++o<n&&(i*=256);)this[e+o]=t/i&255;return e+n},s.prototype.writeUintBE=s.prototype.writeUIntBE=function(t,e,n,r){if(t=+t,e>>>=0,n>>>=0,!r){M(this,t,e,n,Math.pow(2,8*n)-1,0)}let i=n-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+n},s.prototype.writeUint8=s.prototype.writeUInt8=function(t,e,n){return t=+t,e>>>=0,n||M(this,t,e,1,255,0),this[e]=255&t,e+1},s.prototype.writeUint16LE=s.prototype.writeUInt16LE=function(t,e,n){return t=+t,e>>>=0,n||M(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeUint16BE=s.prototype.writeUInt16BE=function(t,e,n){return t=+t,e>>>=0,n||M(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeUint32LE=s.prototype.writeUInt32LE=function(t,e,n){return t=+t,e>>>=0,n||M(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},s.prototype.writeUint32BE=s.prototype.writeUInt32BE=function(t,e,n){return t=+t,e>>>=0,n||M(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeBigUInt64LE=Z((function(t,e=0){return C(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),s.prototype.writeBigUInt64BE=Z((function(t,e=0){return O(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),s.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e>>>=0,!r){const r=Math.pow(2,8*n-1);M(this,t,e,n,r-1,-r)}let i=0,o=1,s=0;for(this[e]=255&t;++i<n&&(o*=256);)t<0&&0===s&&0!==this[e+i-1]&&(s=1),this[e+i]=(t/o|0)-s&255;return e+n},s.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e>>>=0,!r){const r=Math.pow(2,8*n-1);M(this,t,e,n,r-1,-r)}let i=n-1,o=1,s=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/o|0)-s&255;return e+n},s.prototype.writeInt8=function(t,e,n){return t=+t,e>>>=0,n||M(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,n){return t=+t,e>>>=0,n||M(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeInt16BE=function(t,e,n){return t=+t,e>>>=0,n||M(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeInt32LE=function(t,e,n){return t=+t,e>>>=0,n||M(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},s.prototype.writeInt32BE=function(t,e,n){return t=+t,e>>>=0,n||M(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeBigInt64LE=Z((function(t,e=0){return C(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),s.prototype.writeBigInt64BE=Z((function(t,e=0){return O(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),s.prototype.writeFloatLE=function(t,e,n){return L(this,t,e,!0,n)},s.prototype.writeFloatBE=function(t,e,n){return L(this,t,e,!1,n)},s.prototype.writeDoubleLE=function(t,e,n){return N(this,t,e,!0,n)},s.prototype.writeDoubleBE=function(t,e,n){return N(this,t,e,!1,n)},s.prototype.copy=function(t,e,n,r){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e<r-n&&(r=t.length-e+n);const i=r-n;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,n,r):Uint8Array.prototype.set.call(t,this.subarray(n,r),e),i},s.prototype.fill=function(t,e,n,r){if("string"==typeof t){if("string"==typeof e?(r=e,e=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!s.isEncoding(r))throw new TypeError("Unknown encoding: "+r);if(1===t.length){const e=t.charCodeAt(0);("utf8"===r&&e<128||"latin1"===r)&&(t=e)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;let i;if(e>>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(i=e;i<n;++i)this[i]=t;else{const o=s.isBuffer(t)?t:s.from(t,r),a=o.length;if(0===a)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(i=0;i<n-e;++i)this[i+e]=o[i%a]}return this};const U={};function z(t,e,n){U[t]=class extends n{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(t){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:t,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}function $(t){let e="",n=t.length;const r="-"===t[0]?1:0;for(;n>=r+4;n-=3)e=`_${t.slice(n-3,n)}${e}`;return`${t.slice(0,n)}${e}`}function W(t,e,n,r,i,o){if(t>n||t<e){const r="bigint"==typeof e?"n":"";let i;throw i=o>3?0===e||e===BigInt(0)?`>= 0${r} and < 2${r} ** ${8*(o+1)}${r}`:`>= -(2${r} ** ${8*(o+1)-1}${r}) and < 2 ** ${8*(o+1)-1}${r}`:`>= ${e}${r} and <= ${n}${r}`,new U.ERR_OUT_OF_RANGE("value",i,t)}!function(t,e,n){F(e,"offset"),void 0!==t[e]&&void 0!==t[e+n]||D(e,t.length-(n+1))}(r,i,o)}function F(t,e){if("number"!=typeof t)throw new U.ERR_INVALID_ARG_TYPE(e,"number",t)}function D(t,e,n){if(Math.floor(t)!==t)throw F(t,n),new U.ERR_OUT_OF_RANGE(n||"offset","an integer",t);if(e<0)throw new U.ERR_BUFFER_OUT_OF_BOUNDS;throw new U.ERR_OUT_OF_RANGE(n||"offset",`>= ${n?1:0} and <= ${e}`,t)}z("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),z("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),z("ERR_OUT_OF_RANGE",(function(t,e,n){let r=`The value of "${t}" is out of range.`,i=n;return Number.isInteger(n)&&Math.abs(n)>2**32?i=$(String(n)):"bigint"==typeof n&&(i=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(i=$(i)),i+="n"),r+=` It must be ${e}. Received ${i}`,r}),RangeError);const j=/[^+/0-9A-Za-z-_]/g;function q(t,e){let n;e=e||1/0;const r=t.length;let i=null;const o=[];for(let s=0;s<r;++s){if(n=t.charCodeAt(s),n>55295&&n<57344){if(!i){if(n>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===r){(e-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(n<56320){(e-=3)>-1&&o.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((e-=1)<0)break;o.push(n)}else if(n<2048){if((e-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function K(t){return e.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(j,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function H(t,e,n,r){let i;for(i=0;i<r&&!(i+n>=e.length||i>=t.length);++i)e[i+n]=t[i];return i}function V(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function G(t){return t!=t}const J=function(){const t="0123456789abcdef",e=new Array(256);for(let n=0;n<16;++n){const r=16*n;for(let i=0;i<16;++i)e[r+i]=t[n]+t[i]}return e}();function Z(t){return"undefined"==typeof BigInt?Y:t}function Y(){throw new Error("BigInt not supported")}}(cr);const br="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;function wr(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function vr(t,...e){if(!function(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&"Uint8Array"===t.constructor.name}(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function _r(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function kr(t,e){vr(t);const n=e.outputLen;if(t.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function Sr(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function xr(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Er(t,e){return t<<32-e|t>>>e}const Ir=(()=>68===new Uint8Array(new Uint32Array([287454020]).buffer)[0])()?t=>t:function(t){for(let n=0;n<t.length;n++)t[n]=(e=t[n])<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255;var e;return t};function Ar(t){return"string"==typeof t&&(t=function(t){if("string"!=typeof t)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(t))}(t)),vr(t),t}class Br{}function Pr(t){const e=e=>t().update(Ar(e)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function Tr(t=32){if(br&&"function"==typeof br.getRandomValues)return br.getRandomValues(new Uint8Array(t));if(br&&"function"==typeof br.randomBytes)return Uint8Array.from(br.randomBytes(t));throw new Error("crypto.getRandomValues must be defined")}function Mr(t,e,n){return t&e^~t&n}function Cr(t,e,n){return t&e^t&n^e&n}class Or extends Br{constructor(t,e,n,r){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(t),this.view=xr(this.buffer)}update(t){_r(this),vr(t=Ar(t));const{view:e,buffer:n,blockLen:r}=this,i=t.length;for(let o=0;o<i;){const s=Math.min(r-this.pos,i-o);if(s!==r)n.set(t.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===r&&(this.process(e,0),this.pos=0);else{const e=xr(t);for(;r<=i-o;o+=r)this.process(e,o)}}return this.length+=t.length,this.roundClean(),this}digestInto(t){_r(this),kr(t,this),this.finished=!0;const{buffer:e,view:n,blockLen:r,isLE:i}=this;let{pos:o}=this;e[o++]=128,Sr(this.buffer.subarray(o)),this.padOffset>r-o&&(this.process(n,0),o=0);for(let t=o;t<r;t++)e[t]=0;!function(t,e,n,r){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,n,r);const i=BigInt(32),o=BigInt(4294967295),s=Number(n>>i&o),a=Number(n&o),c=r?4:0,u=r?0:4;t.setUint32(e+c,s,r),t.setUint32(e+u,a,r)}(n,r-8,BigInt(8*this.length),i),this.process(n,0);const s=xr(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=a/4,u=this.get();if(c>u.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<c;t++)s.setUint32(4*t,u[t],i)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:n,length:r,finished:i,destroyed:o,pos:s}=this;return t.destroyed=o,t.finished=i,t.length=r,t.pos=s,r%e&&t.buffer.set(n),t}clone(){return this._cloneInto()}}const Rr=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Lr=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),Nr=BigInt(2**32-1),Ur=BigInt(32);function zr(t,e=!1){return e?{h:Number(t&Nr),l:Number(t>>Ur&Nr)}:{h:0|Number(t>>Ur&Nr),l:0|Number(t&Nr)}}function $r(t,e=!1){const n=t.length;let r=new Uint32Array(n),i=new Uint32Array(n);for(let o=0;o<n;o++){const{h:n,l:s}=zr(t[o],e);[r[o],i[o]]=[n,s]}return[r,i]}const Wr=(t,e,n)=>t>>>n,Fr=(t,e,n)=>t<<32-n|e>>>n,Dr=(t,e,n)=>t>>>n|e<<32-n,jr=(t,e,n)=>t<<32-n|e>>>n,qr=(t,e,n)=>t<<64-n|e>>>n-32,Kr=(t,e,n)=>t>>>n-32|e<<64-n;function Hr(t,e,n,r){const i=(e>>>0)+(r>>>0);return{h:t+n+(i/2**32|0)|0,l:0|i}}const Vr=(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0),Gr=(t,e,n,r)=>e+n+r+(t/2**32|0)|0,Jr=(t,e,n,r)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0),Zr=(t,e,n,r,i)=>e+n+r+i+(t/2**32|0)|0,Yr=(t,e,n,r,i)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0)+(i>>>0),Xr=(t,e,n,r,i,o)=>e+n+r+i+o+(t/2**32|0)|0,Qr=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]),ti=new Uint32Array(64);class ei extends Or{constructor(t=32){super(64,t,8,!1),this.A=0|Rr[0],this.B=0|Rr[1],this.C=0|Rr[2],this.D=0|Rr[3],this.E=0|Rr[4],this.F=0|Rr[5],this.G=0|Rr[6],this.H=0|Rr[7]}get(){const{A:t,B:e,C:n,D:r,E:i,F:o,G:s,H:a}=this;return[t,e,n,r,i,o,s,a]}set(t,e,n,r,i,o,s,a){this.A=0|t,this.B=0|e,this.C=0|n,this.D=0|r,this.E=0|i,this.F=0|o,this.G=0|s,this.H=0|a}process(t,e){for(let n=0;n<16;n++,e+=4)ti[n]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=ti[t-15],n=ti[t-2],r=Er(e,7)^Er(e,18)^e>>>3,i=Er(n,17)^Er(n,19)^n>>>10;ti[t]=i+ti[t-7]+r+ti[t-16]|0}let{A:n,B:r,C:i,D:o,E:s,F:a,G:c,H:u}=this;for(let t=0;t<64;t++){const e=u+(Er(s,6)^Er(s,11)^Er(s,25))+Mr(s,a,c)+Qr[t]+ti[t]|0,l=(Er(n,2)^Er(n,13)^Er(n,22))+Cr(n,r,i)|0;u=c,c=a,a=s,s=o+e|0,o=i,i=r,r=n,n=e+l|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,o=o+this.D|0,s=s+this.E|0,a=a+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(n,r,i,o,s,a,c,u)}roundClean(){Sr(ti)}destroy(){this.set(0,0,0,0,0,0,0,0),Sr(this.buffer)}}const ni=(()=>$r(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map((t=>BigInt(t)))))(),ri=(()=>ni[0])(),ii=(()=>ni[1])(),oi=new Uint32Array(80),si=new Uint32Array(80);class ai extends Or{constructor(t=64){super(128,t,16,!1),this.Ah=0|Lr[0],this.Al=0|Lr[1],this.Bh=0|Lr[2],this.Bl=0|Lr[3],this.Ch=0|Lr[4],this.Cl=0|Lr[5],this.Dh=0|Lr[6],this.Dl=0|Lr[7],this.Eh=0|Lr[8],this.El=0|Lr[9],this.Fh=0|Lr[10],this.Fl=0|Lr[11],this.Gh=0|Lr[12],this.Gl=0|Lr[13],this.Hh=0|Lr[14],this.Hl=0|Lr[15]}get(){const{Ah:t,Al:e,Bh:n,Bl:r,Ch:i,Cl:o,Dh:s,Dl:a,Eh:c,El:u,Fh:l,Fl:h,Gh:d,Gl:f,Hh:p,Hl:g}=this;return[t,e,n,r,i,o,s,a,c,u,l,h,d,f,p,g]}set(t,e,n,r,i,o,s,a,c,u,l,h,d,f,p,g){this.Ah=0|t,this.Al=0|e,this.Bh=0|n,this.Bl=0|r,this.Ch=0|i,this.Cl=0|o,this.Dh=0|s,this.Dl=0|a,this.Eh=0|c,this.El=0|u,this.Fh=0|l,this.Fl=0|h,this.Gh=0|d,this.Gl=0|f,this.Hh=0|p,this.Hl=0|g}process(t,e){for(let n=0;n<16;n++,e+=4)oi[n]=t.getUint32(e),si[n]=t.getUint32(e+=4);for(let t=16;t<80;t++){const e=0|oi[t-15],n=0|si[t-15],r=Dr(e,n,1)^Dr(e,n,8)^Wr(e,0,7),i=jr(e,n,1)^jr(e,n,8)^Fr(e,n,7),o=0|oi[t-2],s=0|si[t-2],a=Dr(o,s,19)^qr(o,s,61)^Wr(o,0,6),c=jr(o,s,19)^Kr(o,s,61)^Fr(o,s,6),u=Jr(i,c,si[t-7],si[t-16]),l=Zr(u,r,a,oi[t-7],oi[t-16]);oi[t]=0|l,si[t]=0|u}let{Ah:n,Al:r,Bh:i,Bl:o,Ch:s,Cl:a,Dh:c,Dl:u,Eh:l,El:h,Fh:d,Fl:f,Gh:p,Gl:g,Hh:m,Hl:y}=this;for(let t=0;t<80;t++){const e=Dr(l,h,14)^Dr(l,h,18)^qr(l,h,41),b=jr(l,h,14)^jr(l,h,18)^Kr(l,h,41),w=l&d^~l&p,v=Yr(y,b,h&f^~h&g,ii[t],si[t]),_=Xr(v,m,e,w,ri[t],oi[t]),k=0|v,S=Dr(n,r,28)^qr(n,r,34)^qr(n,r,39),x=jr(n,r,28)^Kr(n,r,34)^Kr(n,r,39),E=n&i^n&s^i&s,I=r&o^r&a^o&a;m=0|p,y=0|g,p=0|d,g=0|f,d=0|l,f=0|h,({h:l,l:h}=Hr(0|c,0|u,0|_,0|k)),c=0|s,u=0|a,s=0|i,a=0|o,i=0|n,o=0|r;const A=Vr(k,x,I);n=Gr(A,_,S,E),r=0|A}({h:n,l:r}=Hr(0|this.Ah,0|this.Al,0|n,0|r)),({h:i,l:o}=Hr(0|this.Bh,0|this.Bl,0|i,0|o)),({h:s,l:a}=Hr(0|this.Ch,0|this.Cl,0|s,0|a)),({h:c,l:u}=Hr(0|this.Dh,0|this.Dl,0|c,0|u)),({h:l,l:h}=Hr(0|this.Eh,0|this.El,0|l,0|h)),({h:d,l:f}=Hr(0|this.Fh,0|this.Fl,0|d,0|f)),({h:p,l:g}=Hr(0|this.Gh,0|this.Gl,0|p,0|g)),({h:m,l:y}=Hr(0|this.Hh,0|this.Hl,0|m,0|y)),this.set(n,r,i,o,s,a,c,u,l,h,d,f,p,g,m,y)}roundClean(){Sr(oi,si)}destroy(){Sr(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const ci=Pr((()=>new ei)),ui=Pr((()=>new ai)),li=BigInt(0),hi=BigInt(1);function di(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&"Uint8Array"===t.constructor.name}function fi(t){if(!di(t))throw new Error("Uint8Array expected")}function pi(t,e){if("boolean"!=typeof e)throw new Error(t+" boolean expected, got "+e)}function gi(t){const e=t.toString(16);return 1&e.length?"0"+e:e}function mi(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);return""===t?li:BigInt("0x"+t)}const yi="function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex,bi=Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0")));function wi(t){if(fi(t),yi)return t.toHex();let e="";for(let n=0;n<t.length;n++)e+=bi[t[n]];return e}const vi={_0:48,_9:57,A:65,F:70,a:97,f:102};function _i(t){return t>=vi._0&&t<=vi._9?t-vi._0:t>=vi.A&&t<=vi.F?t-(vi.A-10):t>=vi.a&&t<=vi.f?t-(vi.a-10):void 0}function ki(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);if(yi)return Uint8Array.fromHex(t);const e=t.length,n=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(n);for(let e=0,i=0;e<n;e++,i+=2){const n=_i(t.charCodeAt(i)),o=_i(t.charCodeAt(i+1));if(void 0===n||void 0===o){const e=t[i]+t[i+1];throw new Error('hex string expected, got non-hex character "'+e+'" at index '+i)}r[e]=16*n+o}return r}function Si(t){return mi(wi(t))}function xi(t){return fi(t),mi(wi(Uint8Array.from(t).reverse()))}function Ei(t,e){return ki(t.toString(16).padStart(2*e,"0"))}function Ii(t,e){return Ei(t,e).reverse()}function Ai(t,e,n){let r;if("string"==typeof e)try{r=ki(e)}catch(e){throw new Error(t+" must be hex string or Uint8Array, cause: "+e)}else{if(!di(e))throw new Error(t+" must be hex string or Uint8Array");r=Uint8Array.from(e)}const i=r.length;if("number"==typeof n&&i!==n)throw new Error(t+" of length "+n+" expected, got "+i);return r}function Bi(...t){let e=0;for(let n=0;n<t.length;n++){const r=t[n];fi(r),e+=r.length}const n=new Uint8Array(e);for(let e=0,r=0;e<t.length;e++){const i=t[e];n.set(i,r),r+=i.length}return n}const Pi=t=>"bigint"==typeof t&&li<=t;function Ti(t,e,n){return Pi(t)&&Pi(e)&&Pi(n)&&e<=t&&t<n}function Mi(t,e,n,r){if(!Ti(e,n,r))throw new Error("expected valid "+t+": "+n+" <= n < "+r+", got "+e)}const Ci=t=>(hi<<BigInt(t))-hi,Oi=t=>new Uint8Array(t),Ri=t=>Uint8Array.from(t);const Li={bigint:t=>"bigint"==typeof t,function:t=>"function"==typeof t,boolean:t=>"boolean"==typeof t,string:t=>"string"==typeof t,stringOrUint8Array:t=>"string"==typeof t||di(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>"function"==typeof t&&Number.isSafeInteger(t.outputLen)};function Ni(t,e,n={}){const r=(e,n,r)=>{const i=Li[n];if("function"!=typeof i)throw new Error("invalid validator function");const o=t[e];if(!(r&&void 0===o||i(o,t)))throw new Error("param "+String(e)+" is invalid. Expected "+n+", got "+o)};for(const[t,n]of Object.entries(e))r(t,n,!1);for(const[t,e]of Object.entries(n))r(t,e,!0);return t}function Ui(t){const e=new WeakMap;return(n,...r)=>{const i=e.get(n);if(void 0!==i)return i;const o=t(n,...r);return e.set(n,o),o}}const zi=BigInt(0),$i=BigInt(1),Wi=BigInt(2),Fi=BigInt(3),Di=BigInt(4),ji=BigInt(5),qi=BigInt(8);function Ki(t,e){const n=t%e;return n>=zi?n:e+n}function Hi(t,e,n){let r=t;for(;e-- >zi;)r*=r,r%=n;return r}function Vi(t,e){if(t===zi)throw new Error("invert: expected non-zero number");if(e<=zi)throw new Error("invert: expected positive modulus, got "+e);let n=Ki(t,e),r=e,i=zi,o=$i;for(;n!==zi;){const t=r%n,e=i-o*(r/n);r=n,n=t,i=o,o=e}if(r!==$i)throw new Error("invert: does not exist");return Ki(i,e)}function Gi(t){return t%Di===Fi?function(e,n){const r=(t+$i)/Di,i=e.pow(n,r);if(!e.eql(e.sqr(i),n))throw new Error("Cannot find square root");return i}:t%qi===ji?function(e,n){const r=e.mul(n,Wi),i=(t-ji)/qi,o=e.pow(r,i),s=e.mul(n,o),a=e.mul(e.mul(s,Wi),o),c=e.mul(s,e.sub(a,e.ONE));if(!e.eql(e.sqr(c),n))throw new Error("Cannot find square root");return c}:function(t){let e=t-$i,n=0;for(;e%Wi===zi;)e/=Wi,n++;let r=Wi;const i=Qi(t);for(;r<t&&Yi(i,r);)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(1===n){const e=(t+$i)/Di;return function(t,n){const r=t.pow(n,e);if(!t.eql(t.sqr(r),n))throw new Error("Cannot find square root");return r}}const o=(e+$i)/Wi;return function(t,i){if(!Yi(t,i))throw new Error("Cannot find square root");let s=n,a=t.pow(t.mul(t.ONE,r),e),c=t.pow(i,o),u=t.pow(i,e);for(;!t.eql(u,t.ONE);){if(t.eql(u,t.ZERO))return t.ZERO;let e=1;for(let n=t.sqr(u);e<s&&!t.eql(n,t.ONE);e++)n=t.sqr(n);const n=t.pow(a,$i<<BigInt(s-e-1));a=t.sqr(n),c=t.mul(c,n),u=t.mul(u,a),s=e}return c}}(t)}const Ji=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Zi(t,e,n=!1){const r=new Array(e.length).fill(n?t.ZERO:void 0),i=e.reduce(((e,n,i)=>t.is0(n)?e:(r[i]=e,t.mul(e,n))),t.ONE),o=t.inv(i);return e.reduceRight(((e,n,i)=>t.is0(n)?e:(r[i]=t.mul(e,r[i]),t.mul(e,n))),o),r}function Yi(t,e){const n=function(t,e){const n=(t.ORDER-$i)/Wi,r=t.pow(e,n),i=t.eql(r,t.ONE),o=t.eql(r,t.ZERO),s=t.eql(r,t.neg(t.ONE));if(!i&&!o&&!s)throw new Error("Cannot find square root: probably non-prime P");return i?1:o?0:-1}(t,e);return 0===n||1===n}function Xi(t,e){void 0!==e&&wr(e);const n=void 0!==e?e:t.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function Qi(t,e,n=!1,r={}){if(t<=zi)throw new Error("invalid field: expected ORDER > 0, got "+t);const{nBitLength:i,nByteLength:o}=Xi(t,e);if(o>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let s;const a=Object.freeze({ORDER:t,isLE:n,BITS:i,BYTES:o,MASK:Ci(i),ZERO:zi,ONE:$i,create:e=>Ki(e,t),isValid:e=>{if("bigint"!=typeof e)throw new Error("invalid field element: expected bigint, got "+typeof e);return zi<=e&&e<t},is0:t=>t===zi,isOdd:t=>(t&$i)===$i,neg:e=>Ki(-e,t),eql:(t,e)=>t===e,sqr:e=>Ki(e*e,t),add:(e,n)=>Ki(e+n,t),sub:(e,n)=>Ki(e-n,t),mul:(e,n)=>Ki(e*n,t),pow:(t,e)=>function(t,e,n){if(n<zi)throw new Error("invalid exponent, negatives unsupported");if(n===zi)return t.ONE;if(n===$i)return e;let r=t.ONE,i=e;for(;n>zi;)n&$i&&(r=t.mul(r,i)),i=t.sqr(i),n>>=$i;return r}(a,t,e),div:(e,n)=>Ki(e*Vi(n,t),t),sqrN:t=>t*t,addN:(t,e)=>t+e,subN:(t,e)=>t-e,mulN:(t,e)=>t*e,inv:e=>Vi(e,t),sqrt:r.sqrt||(e=>(s||(s=Gi(t)),s(a,e))),toBytes:t=>n?Ii(t,o):Ei(t,o),fromBytes:t=>{if(t.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+t.length);return n?xi(t):Si(t)},invertBatch:t=>Zi(a,t),cmov:(t,e,n)=>n?e:t});return Object.freeze(a)}function to(t){if("bigint"!=typeof t)throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function eo(t){const e=to(t);return e+Math.ceil(e/2)}const no=BigInt(0),ro=BigInt(1);function io(t,e){const n=e.negate();return t?n:e}function oo(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function so(t,e){oo(t,e);const n=2**t;return{windows:Math.ceil(e/t)+1,windowSize:2**(t-1),mask:Ci(t),maxNumber:n,shiftBy:BigInt(t)}}function ao(t,e,n){const{windowSize:r,mask:i,maxNumber:o,shiftBy:s}=n;let a=Number(t&i),c=t>>s;a>r&&(a-=o,c+=ro);const u=e*r;return{nextN:c,offset:u+Math.abs(a)-1,isZero:0===a,isNeg:a<0,isNegF:e%2!=0,offsetF:u}}const co=new WeakMap,uo=new WeakMap;function lo(t){return uo.get(t)||1}function ho(t,e){return{constTimeNegate:io,hasPrecomputes:t=>1!==lo(t),unsafeLadder(e,n,r=t.ZERO){let i=e;for(;n>no;)n&ro&&(r=r.add(i)),i=i.double(),n>>=ro;return r},precomputeWindow(t,n){const{windows:r,windowSize:i}=so(n,e),o=[];let s=t,a=s;for(let t=0;t<r;t++){a=s,o.push(a);for(let t=1;t<i;t++)a=a.add(s),o.push(a);s=a.double()}return o},wNAF(n,r,i){let o=t.ZERO,s=t.BASE;const a=so(n,e);for(let t=0;t<a.windows;t++){const{nextN:e,offset:n,isZero:c,isNeg:u,isNegF:l,offsetF:h}=ao(i,t,a);i=e,c?s=s.add(io(l,r[h])):o=o.add(io(u,r[n]))}return{p:o,f:s}},wNAFUnsafe(n,r,i,o=t.ZERO){const s=so(n,e);for(let t=0;t<s.windows&&i!==no;t++){const{nextN:e,offset:n,isZero:a,isNeg:c}=ao(i,t,s);if(i=e,!a){const t=r[n];o=o.add(c?t.negate():t)}}return o},getPrecomputes(t,e,n){let r=co.get(e);return r||(r=this.precomputeWindow(e,t),1!==t&&co.set(e,n(r))),r},wNAFCached(t,e,n){const r=lo(t);return this.wNAF(r,this.getPrecomputes(r,t,n),e)},wNAFCachedUnsafe(t,e,n,r){const i=lo(t);return 1===i?this.unsafeLadder(t,e,r):this.wNAFUnsafe(i,this.getPrecomputes(i,t,n),e,r)},setWindowSize(t,n){oo(n,e),uo.set(t,n),co.delete(t)}}}function fo(t,e,n,r){if(function(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach(((t,n)=>{if(!(t instanceof e))throw new Error("invalid point at index "+n)}))}(n,t),function(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach(((t,n)=>{if(!e.isValid(t))throw new Error("invalid scalar at index "+n)}))}(r,e),n.length!==r.length)throw new Error("arrays of points and scalars must have equal length");const i=t.ZERO,o=function(t){let e;for(e=0;t>li;t>>=hi,e+=1);return e}(BigInt(n.length)),s=o>12?o-3:o>4?o-2:o?2:1,a=Ci(s),c=new Array(Number(a)+1).fill(i);let u=i;for(let t=Math.floor((e.BITS-1)/s)*s;t>=0;t-=s){c.fill(i);for(let e=0;e<r.length;e++){const i=r[e],o=Number(i>>BigInt(t)&a);c[o]=c[o].add(n[e])}let e=i;for(let t=c.length-1,n=i;t>0;t--)n=n.add(c[t]),e=e.add(n);if(u=u.add(e),0!==t)for(let t=0;t<s;t++)u=u.double()}return u}function po(t){return Ni(t.Fp,Ji.reduce(((t,e)=>(t[e]="function",t)),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"})),Ni(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Xi(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}const go=BigInt(0),mo=BigInt(1),yo=BigInt(2),bo=BigInt(8),wo={zip215:!0};function vo(t){const e=function(t){const e=po(t);return Ni(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}(t),{Fp:n,n:r,prehash:i,hash:o,randomBytes:s,nByteLength:a,h:c}=e,u=yo<<BigInt(8*a)-mo,l=n.create,h=Qi(e.n,e.nBitLength),d=e.uvRatio||((t,e)=>{try{return{isValid:!0,value:n.sqrt(t*n.inv(e))}}catch(t){return{isValid:!1,value:go}}}),f=e.adjustScalarBytes||(t=>t),p=e.domain||((t,e,n)=>{if(pi("phflag",n),e.length||n)throw new Error("Contexts/pre-hash are not supported");return t});function g(t,e,n=!1){Mi("coordinate "+t,e,n?mo:go,u)}function m(t){if(!(t instanceof w))throw new Error("ExtendedPoint expected")}const y=Ui(((t,e)=>{const{ex:r,ey:i,ez:o}=t,s=t.is0();null==e&&(e=s?bo:n.inv(o));const a=l(r*e),c=l(i*e),u=l(o*e);if(s)return{x:go,y:mo};if(u!==mo)throw new Error("invZ was invalid");return{x:a,y:c}})),b=Ui((t=>{const{a:n,d:r}=e;if(t.is0())throw new Error("bad point: ZERO");const{ex:i,ey:o,ez:s,et:a}=t,c=l(i*i),u=l(o*o),h=l(s*s),d=l(h*h),f=l(c*n);if(l(h*l(f+u))!==l(d+l(r*l(c*u))))throw new Error("bad point: equation left != right (1)");if(l(i*o)!==l(s*a))throw new Error("bad point: equation left != right (2)");return!0}));class w{constructor(t,e,n,r){g("x",t),g("y",e),g("z",n,!0),g("t",r),this.ex=t,this.ey=e,this.ez=n,this.et=r,Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(t){if(t instanceof w)throw new Error("extended point not allowed");const{x:e,y:n}=t||{};return g("x",e),g("y",n),new w(e,n,mo,l(e*n))}static normalizeZ(t){const e=Zi(n,t.map((t=>t.ez)));return t.map(((t,n)=>t.toAffine(e[n]))).map(w.fromAffine)}static msm(t,e){return fo(w,h,t,e)}_setWindowSize(t){k.setWindowSize(this,t)}assertValidity(){b(this)}equals(t){m(t);const{ex:e,ey:n,ez:r}=this,{ex:i,ey:o,ez:s}=t,a=l(e*s),c=l(i*r),u=l(n*s),h=l(o*r);return a===c&&u===h}is0(){return this.equals(w.ZERO)}negate(){return new w(l(-this.ex),this.ey,this.ez,l(-this.et))}double(){const{a:t}=e,{ex:n,ey:r,ez:i}=this,o=l(n*n),s=l(r*r),a=l(yo*l(i*i)),c=l(t*o),u=n+r,h=l(l(u*u)-o-s),d=c+s,f=d-a,p=c-s,g=l(h*f),m=l(d*p),y=l(h*p),b=l(f*d);return new w(g,m,b,y)}add(t){m(t);const{a:n,d:r}=e,{ex:i,ey:o,ez:s,et:a}=this,{ex:c,ey:u,ez:h,et:d}=t,f=l(i*c),p=l(o*u),g=l(a*r*d),y=l(s*h),b=l((i+o)*(c+u)-f-p),v=y-g,_=y+g,k=l(p-n*f),S=l(b*v),x=l(_*k),E=l(b*k),I=l(v*_);return new w(S,x,I,E)}subtract(t){return this.add(t.negate())}wNAF(t){return k.wNAFCached(this,t,w.normalizeZ)}multiply(t){const e=t;Mi("scalar",e,mo,r);const{p:n,f:i}=this.wNAF(e);return w.normalizeZ([n,i])[0]}multiplyUnsafe(t,e=w.ZERO){const n=t;return Mi("scalar",n,go,r),n===go?_:this.is0()||n===mo?this:k.wNAFCachedUnsafe(this,n,w.normalizeZ,e)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return k.unsafeLadder(this,r).is0()}toAffine(t){return y(this,t)}clearCofactor(){const{h:t}=e;return t===mo?this:this.multiplyUnsafe(t)}static fromHex(t,r=!1){const{d:i,a:o}=e,s=n.BYTES;t=Ai("pointHex",t,s),pi("zip215",r);const a=t.slice(),c=t[s-1];a[s-1]=-129&c;const h=xi(a),f=r?u:n.ORDER;Mi("pointHex.y",h,go,f);const p=l(h*h),g=l(p-mo),m=l(i*p-o);let{isValid:y,value:b}=d(g,m);if(!y)throw new Error("Point.fromHex: invalid y coordinate");const v=(b&mo)===mo,_=!!(128&c);if(!r&&b===go&&_)throw new Error("Point.fromHex: x=0 and x_0=1");return _!==v&&(b=l(-b)),w.fromAffine({x:b,y:h})}static fromPrivateKey(t){const{scalar:e}=E(t);return v.multiply(e)}toRawBytes(){const{x:t,y:e}=this.toAffine(),r=Ii(e,n.BYTES);return r[r.length-1]|=t&mo?128:0,r}toHex(){return wi(this.toRawBytes())}}w.BASE=new w(e.Gx,e.Gy,mo,l(e.Gx*e.Gy)),w.ZERO=new w(go,mo,mo,go);const{BASE:v,ZERO:_}=w,k=ho(w,8*a);function S(t){return Ki(t,r)}function x(t){return S(xi(t))}function E(t){const e=n.BYTES;t=Ai("private key",t,e);const r=Ai("hashed private key",o(t),2*e),i=f(r.slice(0,e));return{head:i,prefix:r.slice(e,2*e),scalar:x(i)}}function I(t){const{head:e,prefix:n,scalar:r}=E(t),i=v.multiply(r),o=i.toRawBytes();return{head:e,prefix:n,scalar:r,point:i,pointBytes:o}}function A(t=Uint8Array.of(),...e){const n=Bi(...e);return x(o(p(n,Ai("context",t),!!i)))}const B=wo;v._setWindowSize(8);return{CURVE:e,getPublicKey:function(t){return I(t).pointBytes},sign:function(t,e,o={}){t=Ai("message",t),i&&(t=i(t));const{prefix:s,scalar:a,pointBytes:c}=I(e),u=A(o.context,s,t),l=v.multiply(u).toRawBytes(),h=S(u+A(o.context,l,c,t)*a);return Mi("signature.s",h,go,r),Ai("result",Bi(l,Ii(h,n.BYTES)),2*n.BYTES)},verify:function(t,e,r,o=B){const{context:s,zip215:a}=o,c=n.BYTES;t=Ai("signature",t,2*c),e=Ai("message",e),r=Ai("publicKey",r,c),void 0!==a&&pi("zip215",a),i&&(e=i(e));const u=xi(t.slice(c,2*c));let l,h,d;try{l=w.fromHex(r,a),h=w.fromHex(t.slice(0,c),a),d=v.multiplyUnsafe(u)}catch(t){return!1}if(!a&&l.isSmallOrder())return!1;const f=A(s,h.toRawBytes(),l.toRawBytes(),e);return h.add(l.multiplyUnsafe(f)).subtract(d).clearCofactor().equals(w.ZERO)},ExtendedPoint:w,utils:{getExtendedPublicKey:I,randomPrivateKey:()=>s(n.BYTES),precompute:(t=8,e=w.BASE)=>(e._setWindowSize(t),e.multiply(BigInt(3)),e)}}}BigInt(0),BigInt(1);const _o=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),ko=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const So=BigInt(1),xo=BigInt(2);BigInt(3);const Eo=BigInt(5),Io=BigInt(8);function Ao(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function Bo(t,e){const n=_o,r=Ki(e*e*e,n),i=function(t){const e=BigInt(10),n=BigInt(20),r=BigInt(40),i=BigInt(80),o=_o,s=t*t%o*t%o,a=Hi(s,xo,o)*s%o,c=Hi(a,So,o)*t%o,u=Hi(c,Eo,o)*c%o,l=Hi(u,e,o)*u%o,h=Hi(l,n,o)*l%o,d=Hi(h,r,o)*h%o,f=Hi(d,i,o)*d%o,p=Hi(f,i,o)*d%o,g=Hi(p,e,o)*u%o;return{pow_p_5_8:Hi(g,xo,o)*t%o,b2:s}}(t*Ki(r*r*e,n)).pow_p_5_8;let o=Ki(t*r*i,n);const s=Ki(e*o*o,n),a=o,c=Ki(o*ko,n),u=s===t,l=s===Ki(-t,n),h=s===Ki(-t*ko,n);return u&&(o=a),(l||h)&&(o=c),(Ki(o,n)&$i)===$i&&(o=Ki(-o,n)),{isValid:u||l,value:o}}const Po=(()=>Qi(_o,void 0,!0))(),To=(()=>({a:Po.create(BigInt(-1)),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Po,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Io,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:ui,randomBytes:Tr,adjustScalarBytes:Ao,uvRatio:Bo}))(),Mo=(()=>vo(To))();var Co={exports:{}},Oo=i(Object.freeze({__proto__:null,default:{}}));!function(t){!function(t,e){function n(t,e){if(!t)throw new Error(e||"Assertion failed")}function r(t,e){t.super_=e;var n=function(){};n.prototype=e.prototype,t.prototype=new n,t.prototype.constructor=t}function i(t,e,n){if(i.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(n=e,e=10),this._init(t||0,e||10,n||"be"))}var o;"object"==typeof t?t.exports=i:e.BN=i,i.BN=i,i.wordSize=26;try{o="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:Oo.Buffer}catch(t){}function s(t,e){var r=t.charCodeAt(e);return r>=48&&r<=57?r-48:r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:void n(!1,"Invalid character in "+t)}function a(t,e,n){var r=s(t,n);return n-1>=e&&(r|=s(t,n-1)<<4),r}function c(t,e,r,i){for(var o=0,s=0,a=Math.min(t.length,r),c=e;c<a;c++){var u=t.charCodeAt(c)-48;o*=i,s=u>=49?u-49+10:u>=17?u-17+10:u,n(u>=0&&s<i,"Invalid character"),o+=s}return o}function u(t,e){t.words=e.words,t.length=e.length,t.negative=e.negative,t.red=e.red}if(i.isBN=function(t){return t instanceof i||null!==t&&"object"==typeof t&&t.constructor.wordSize===i.wordSize&&Array.isArray(t.words)},i.max=function(t,e){return t.cmp(e)>0?t:e},i.min=function(t,e){return t.cmp(e)<0?t:e},i.prototype._init=function(t,e,r){if("number"==typeof t)return this._initNumber(t,e,r);if("object"==typeof t)return this._initArray(t,e,r);"hex"===e&&(e=16),n(e===(0|e)&&e>=2&&e<=36);var i=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(i++,this.negative=1),i<t.length&&(16===e?this._parseHex(t,i,r):(this._parseBase(t,e,i),"le"===r&&this._initArray(this.toArray(),e,r)))},i.prototype._initNumber=function(t,e,r){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(n(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),e,r)},i.prototype._initArray=function(t,e,r){if(n("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var o,s,a=0;if("be"===r)for(i=t.length-1,o=0;i>=0;i-=3)s=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[o]|=s<<a&67108863,this.words[o+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===r)for(i=0,o=0;i<t.length;i+=3)s=t[i]|t[i+1]<<8|t[i+2]<<16,this.words[o]|=s<<a&67108863,this.words[o+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this._strip()},i.prototype._parseHex=function(t,e,n){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var r=0;r<this.length;r++)this.words[r]=0;var i,o=0,s=0;if("be"===n)for(r=t.length-1;r>=e;r-=2)i=a(t,e,r)<<o,this.words[s]|=67108863&i,o>=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;else for(r=(t.length-e)%2==0?e+1:e;r<t.length;r+=2)i=a(t,e,r)<<o,this.words[s]|=67108863&i,o>=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;this._strip()},i.prototype._parseBase=function(t,e,n){this.words=[0],this.length=1;for(var r=0,i=1;i<=67108863;i*=e)r++;r--,i=i/e|0;for(var o=t.length-n,s=o%r,a=Math.min(o,o-s)+n,u=0,l=n;l<a;l+=r)u=c(t,l,l+r,e),this.imuln(i),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(0!==s){var h=1;for(u=c(t,l,t.length,e),l=0;l<s;l++)h*=e;this.imuln(h),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}this._strip()},i.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red},i.prototype._move=function(t){u(t,this)},i.prototype.clone=function(){var t=new i(null);return this.copy(t),t},i.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},i.prototype._strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},i.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{i.prototype[Symbol.for("nodejs.util.inspect.custom")]=l}catch(t){i.prototype.inspect=l}else i.prototype.inspect=l;function l(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var h=["","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"],d=[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],f=[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(t,e){var r;if(e=0|e||1,16===(t=t||10)||"hex"===t){r="";for(var i=0,o=0,s=0;s<this.length;s++){var a=this.words[s],c=(16777215&(a<<i|o)).toString(16);o=a>>>24-i&16777215,(i+=2)>=26&&(i-=26,s--),r=0!==o||s!==this.length-1?h[6-c.length]+c+r:c+r}for(0!==o&&(r=o.toString(16)+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(t===(0|t)&&t>=2&&t<=36){var u=d[t],l=f[t];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var g=p.modrn(l).toString(t);r=(p=p.idivn(l)).isZero()?g+r:h[u-g.length]+g+r}for(this.isZero()&&(r="0"+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},i.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},i.prototype.toJSON=function(){return this.toString(16,2)},o&&(i.prototype.toBuffer=function(t,e){return this.toArrayLike(o,t,e)}),i.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)};function p(t,e,n){n.negative=e.negative^t.negative;var r=t.length+e.length|0;n.length=r,r=r-1|0;var i=0|t.words[0],o=0|e.words[0],s=i*o,a=67108863&s,c=s/67108864|0;n.words[0]=a;for(var u=1;u<r;u++){for(var l=c>>>26,h=67108863&c,d=Math.min(u,e.length-1),f=Math.max(0,u-t.length+1);f<=d;f++){var p=u-f|0;l+=(s=(i=0|t.words[p])*(o=0|e.words[f])+h)/67108864|0,h=67108863&s}n.words[u]=0|h,c=0|l}return 0!==c?n.words[u]=0|c:n.length--,n._strip()}i.prototype.toArrayLike=function(t,e,r){this._strip();var i=this.byteLength(),o=r||Math.max(1,i);n(i<=o,"byte array longer than desired length"),n(o>0,"Requested array length <= 0");var s=function(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,o);return this["_toArrayLike"+("le"===e?"LE":"BE")](s,i),s},i.prototype._toArrayLikeLE=function(t,e){for(var n=0,r=0,i=0,o=0;i<this.length;i++){var s=this.words[i]<<o|r;t[n++]=255&s,n<t.length&&(t[n++]=s>>8&255),n<t.length&&(t[n++]=s>>16&255),6===o?(n<t.length&&(t[n++]=s>>24&255),r=0,o=0):(r=s>>>24,o+=2)}if(n<t.length)for(t[n++]=r;n<t.length;)t[n++]=0},i.prototype._toArrayLikeBE=function(t,e){for(var n=t.length-1,r=0,i=0,o=0;i<this.length;i++){var s=this.words[i]<<o|r;t[n--]=255&s,n>=0&&(t[n--]=s>>8&255),n>=0&&(t[n--]=s>>16&255),6===o?(n>=0&&(t[n--]=s>>24&255),r=0,o=0):(r=s>>>24,o+=2)}if(n>=0)for(t[n--]=r;n>=0;)t[n--]=0},Math.clz32?i.prototype._countBits=function(t){return 32-Math.clz32(t)}:i.prototype._countBits=function(t){var e=t,n=0;return e>=4096&&(n+=13,e>>>=13),e>=64&&(n+=7,e>>>=7),e>=8&&(n+=4,e>>>=4),e>=2&&(n+=2,e>>>=2),n+e},i.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,n=0;return 8191&e||(n+=13,e>>>=13),127&e||(n+=7,e>>>=7),15&e||(n+=4,e>>>=4),3&e||(n+=2,e>>>=2),1&e||n++,n},i.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var n=this._zeroBits(this.words[e]);if(t+=n,26!==n)break}return t},i.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},i.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},i.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},i.prototype.isNeg=function(){return 0!==this.negative},i.prototype.neg=function(){return this.clone().ineg()},i.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},i.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this._strip()},i.prototype.ior=function(t){return n(!(this.negative|t.negative)),this.iuor(t)},i.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},i.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},i.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var n=0;n<e.length;n++)this.words[n]=this.words[n]&t.words[n];return this.length=e.length,this._strip()},i.prototype.iand=function(t){return n(!(this.negative|t.negative)),this.iuand(t)},i.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},i.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},i.prototype.iuxor=function(t){var e,n;this.length>t.length?(e=this,n=t):(e=t,n=this);for(var r=0;r<n.length;r++)this.words[r]=e.words[r]^n.words[r];if(this!==e)for(;r<e.length;r++)this.words[r]=e.words[r];return this.length=e.length,this._strip()},i.prototype.ixor=function(t){return n(!(this.negative|t.negative)),this.iuxor(t)},i.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},i.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},i.prototype.inotn=function(t){n("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),r=t%26;this._expand(e),r>0&&e--;for(var i=0;i<e;i++)this.words[i]=67108863&~this.words[i];return r>0&&(this.words[i]=~this.words[i]&67108863>>26-r),this._strip()},i.prototype.notn=function(t){return this.clone().inotn(t)},i.prototype.setn=function(t,e){n("number"==typeof t&&t>=0);var r=t/26|0,i=t%26;return this._expand(r+1),this.words[r]=e?this.words[r]|1<<i:this.words[r]&~(1<<i),this._strip()},i.prototype.iadd=function(t){var e,n,r;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(n=this,r=t):(n=t,r=this);for(var i=0,o=0;o<r.length;o++)e=(0|n.words[o])+(0|r.words[o])+i,this.words[o]=67108863&e,i=e>>>26;for(;0!==i&&o<n.length;o++)e=(0|n.words[o])+i,this.words[o]=67108863&e,i=e>>>26;if(this.length=n.length,0!==i)this.words[this.length]=i,this.length++;else if(n!==this)for(;o<n.length;o++)this.words[o]=n.words[o];return this},i.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},i.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var n,r,i=this.cmp(t);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(n=this,r=t):(n=t,r=this);for(var o=0,s=0;s<r.length;s++)o=(e=(0|n.words[s])-(0|r.words[s])+o)>>26,this.words[s]=67108863&e;for(;0!==o&&s<n.length;s++)o=(e=(0|n.words[s])+o)>>26,this.words[s]=67108863&e;if(0===o&&s<n.length&&n!==this)for(;s<n.length;s++)this.words[s]=n.words[s];return this.length=Math.max(this.length,s),n!==this&&(this.negative=1),this._strip()},i.prototype.sub=function(t){return this.clone().isub(t)};var g=function(t,e,n){var r,i,o,s=t.words,a=e.words,c=n.words,u=0,l=0|s[0],h=8191&l,d=l>>>13,f=0|s[1],p=8191&f,g=f>>>13,m=0|s[2],y=8191&m,b=m>>>13,w=0|s[3],v=8191&w,_=w>>>13,k=0|s[4],S=8191&k,x=k>>>13,E=0|s[5],I=8191&E,A=E>>>13,B=0|s[6],P=8191&B,T=B>>>13,M=0|s[7],C=8191&M,O=M>>>13,R=0|s[8],L=8191&R,N=R>>>13,U=0|s[9],z=8191&U,$=U>>>13,W=0|a[0],F=8191&W,D=W>>>13,j=0|a[1],q=8191&j,K=j>>>13,H=0|a[2],V=8191&H,G=H>>>13,J=0|a[3],Z=8191&J,Y=J>>>13,X=0|a[4],Q=8191&X,tt=X>>>13,et=0|a[5],nt=8191&et,rt=et>>>13,it=0|a[6],ot=8191&it,st=it>>>13,at=0|a[7],ct=8191&at,ut=at>>>13,lt=0|a[8],ht=8191&lt,dt=lt>>>13,ft=0|a[9],pt=8191&ft,gt=ft>>>13;n.negative=t.negative^e.negative,n.length=19;var mt=(u+(r=Math.imul(h,F))|0)+((8191&(i=(i=Math.imul(h,D))+Math.imul(d,F)|0))<<13)|0;u=((o=Math.imul(d,D))+(i>>>13)|0)+(mt>>>26)|0,mt&=67108863,r=Math.imul(p,F),i=(i=Math.imul(p,D))+Math.imul(g,F)|0,o=Math.imul(g,D);var yt=(u+(r=r+Math.imul(h,q)|0)|0)+((8191&(i=(i=i+Math.imul(h,K)|0)+Math.imul(d,q)|0))<<13)|0;u=((o=o+Math.imul(d,K)|0)+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,r=Math.imul(y,F),i=(i=Math.imul(y,D))+Math.imul(b,F)|0,o=Math.imul(b,D),r=r+Math.imul(p,q)|0,i=(i=i+Math.imul(p,K)|0)+Math.imul(g,q)|0,o=o+Math.imul(g,K)|0;var bt=(u+(r=r+Math.imul(h,V)|0)|0)+((8191&(i=(i=i+Math.imul(h,G)|0)+Math.imul(d,V)|0))<<13)|0;u=((o=o+Math.imul(d,G)|0)+(i>>>13)|0)+(bt>>>26)|0,bt&=67108863,r=Math.imul(v,F),i=(i=Math.imul(v,D))+Math.imul(_,F)|0,o=Math.imul(_,D),r=r+Math.imul(y,q)|0,i=(i=i+Math.imul(y,K)|0)+Math.imul(b,q)|0,o=o+Math.imul(b,K)|0,r=r+Math.imul(p,V)|0,i=(i=i+Math.imul(p,G)|0)+Math.imul(g,V)|0,o=o+Math.imul(g,G)|0;var wt=(u+(r=r+Math.imul(h,Z)|0)|0)+((8191&(i=(i=i+Math.imul(h,Y)|0)+Math.imul(d,Z)|0))<<13)|0;u=((o=o+Math.imul(d,Y)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,r=Math.imul(S,F),i=(i=Math.imul(S,D))+Math.imul(x,F)|0,o=Math.imul(x,D),r=r+Math.imul(v,q)|0,i=(i=i+Math.imul(v,K)|0)+Math.imul(_,q)|0,o=o+Math.imul(_,K)|0,r=r+Math.imul(y,V)|0,i=(i=i+Math.imul(y,G)|0)+Math.imul(b,V)|0,o=o+Math.imul(b,G)|0,r=r+Math.imul(p,Z)|0,i=(i=i+Math.imul(p,Y)|0)+Math.imul(g,Z)|0,o=o+Math.imul(g,Y)|0;var vt=(u+(r=r+Math.imul(h,Q)|0)|0)+((8191&(i=(i=i+Math.imul(h,tt)|0)+Math.imul(d,Q)|0))<<13)|0;u=((o=o+Math.imul(d,tt)|0)+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,r=Math.imul(I,F),i=(i=Math.imul(I,D))+Math.imul(A,F)|0,o=Math.imul(A,D),r=r+Math.imul(S,q)|0,i=(i=i+Math.imul(S,K)|0)+Math.imul(x,q)|0,o=o+Math.imul(x,K)|0,r=r+Math.imul(v,V)|0,i=(i=i+Math.imul(v,G)|0)+Math.imul(_,V)|0,o=o+Math.imul(_,G)|0,r=r+Math.imul(y,Z)|0,i=(i=i+Math.imul(y,Y)|0)+Math.imul(b,Z)|0,o=o+Math.imul(b,Y)|0,r=r+Math.imul(p,Q)|0,i=(i=i+Math.imul(p,tt)|0)+Math.imul(g,Q)|0,o=o+Math.imul(g,tt)|0;var _t=(u+(r=r+Math.imul(h,nt)|0)|0)+((8191&(i=(i=i+Math.imul(h,rt)|0)+Math.imul(d,nt)|0))<<13)|0;u=((o=o+Math.imul(d,rt)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,r=Math.imul(P,F),i=(i=Math.imul(P,D))+Math.imul(T,F)|0,o=Math.imul(T,D),r=r+Math.imul(I,q)|0,i=(i=i+Math.imul(I,K)|0)+Math.imul(A,q)|0,o=o+Math.imul(A,K)|0,r=r+Math.imul(S,V)|0,i=(i=i+Math.imul(S,G)|0)+Math.imul(x,V)|0,o=o+Math.imul(x,G)|0,r=r+Math.imul(v,Z)|0,i=(i=i+Math.imul(v,Y)|0)+Math.imul(_,Z)|0,o=o+Math.imul(_,Y)|0,r=r+Math.imul(y,Q)|0,i=(i=i+Math.imul(y,tt)|0)+Math.imul(b,Q)|0,o=o+Math.imul(b,tt)|0,r=r+Math.imul(p,nt)|0,i=(i=i+Math.imul(p,rt)|0)+Math.imul(g,nt)|0,o=o+Math.imul(g,rt)|0;var kt=(u+(r=r+Math.imul(h,ot)|0)|0)+((8191&(i=(i=i+Math.imul(h,st)|0)+Math.imul(d,ot)|0))<<13)|0;u=((o=o+Math.imul(d,st)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,r=Math.imul(C,F),i=(i=Math.imul(C,D))+Math.imul(O,F)|0,o=Math.imul(O,D),r=r+Math.imul(P,q)|0,i=(i=i+Math.imul(P,K)|0)+Math.imul(T,q)|0,o=o+Math.imul(T,K)|0,r=r+Math.imul(I,V)|0,i=(i=i+Math.imul(I,G)|0)+Math.imul(A,V)|0,o=o+Math.imul(A,G)|0,r=r+Math.imul(S,Z)|0,i=(i=i+Math.imul(S,Y)|0)+Math.imul(x,Z)|0,o=o+Math.imul(x,Y)|0,r=r+Math.imul(v,Q)|0,i=(i=i+Math.imul(v,tt)|0)+Math.imul(_,Q)|0,o=o+Math.imul(_,tt)|0,r=r+Math.imul(y,nt)|0,i=(i=i+Math.imul(y,rt)|0)+Math.imul(b,nt)|0,o=o+Math.imul(b,rt)|0,r=r+Math.imul(p,ot)|0,i=(i=i+Math.imul(p,st)|0)+Math.imul(g,ot)|0,o=o+Math.imul(g,st)|0;var St=(u+(r=r+Math.imul(h,ct)|0)|0)+((8191&(i=(i=i+Math.imul(h,ut)|0)+Math.imul(d,ct)|0))<<13)|0;u=((o=o+Math.imul(d,ut)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,r=Math.imul(L,F),i=(i=Math.imul(L,D))+Math.imul(N,F)|0,o=Math.imul(N,D),r=r+Math.imul(C,q)|0,i=(i=i+Math.imul(C,K)|0)+Math.imul(O,q)|0,o=o+Math.imul(O,K)|0,r=r+Math.imul(P,V)|0,i=(i=i+Math.imul(P,G)|0)+Math.imul(T,V)|0,o=o+Math.imul(T,G)|0,r=r+Math.imul(I,Z)|0,i=(i=i+Math.imul(I,Y)|0)+Math.imul(A,Z)|0,o=o+Math.imul(A,Y)|0,r=r+Math.imul(S,Q)|0,i=(i=i+Math.imul(S,tt)|0)+Math.imul(x,Q)|0,o=o+Math.imul(x,tt)|0,r=r+Math.imul(v,nt)|0,i=(i=i+Math.imul(v,rt)|0)+Math.imul(_,nt)|0,o=o+Math.imul(_,rt)|0,r=r+Math.imul(y,ot)|0,i=(i=i+Math.imul(y,st)|0)+Math.imul(b,ot)|0,o=o+Math.imul(b,st)|0,r=r+Math.imul(p,ct)|0,i=(i=i+Math.imul(p,ut)|0)+Math.imul(g,ct)|0,o=o+Math.imul(g,ut)|0;var xt=(u+(r=r+Math.imul(h,ht)|0)|0)+((8191&(i=(i=i+Math.imul(h,dt)|0)+Math.imul(d,ht)|0))<<13)|0;u=((o=o+Math.imul(d,dt)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,r=Math.imul(z,F),i=(i=Math.imul(z,D))+Math.imul($,F)|0,o=Math.imul($,D),r=r+Math.imul(L,q)|0,i=(i=i+Math.imul(L,K)|0)+Math.imul(N,q)|0,o=o+Math.imul(N,K)|0,r=r+Math.imul(C,V)|0,i=(i=i+Math.imul(C,G)|0)+Math.imul(O,V)|0,o=o+Math.imul(O,G)|0,r=r+Math.imul(P,Z)|0,i=(i=i+Math.imul(P,Y)|0)+Math.imul(T,Z)|0,o=o+Math.imul(T,Y)|0,r=r+Math.imul(I,Q)|0,i=(i=i+Math.imul(I,tt)|0)+Math.imul(A,Q)|0,o=o+Math.imul(A,tt)|0,r=r+Math.imul(S,nt)|0,i=(i=i+Math.imul(S,rt)|0)+Math.imul(x,nt)|0,o=o+Math.imul(x,rt)|0,r=r+Math.imul(v,ot)|0,i=(i=i+Math.imul(v,st)|0)+Math.imul(_,ot)|0,o=o+Math.imul(_,st)|0,r=r+Math.imul(y,ct)|0,i=(i=i+Math.imul(y,ut)|0)+Math.imul(b,ct)|0,o=o+Math.imul(b,ut)|0,r=r+Math.imul(p,ht)|0,i=(i=i+Math.imul(p,dt)|0)+Math.imul(g,ht)|0,o=o+Math.imul(g,dt)|0;var Et=(u+(r=r+Math.imul(h,pt)|0)|0)+((8191&(i=(i=i+Math.imul(h,gt)|0)+Math.imul(d,pt)|0))<<13)|0;u=((o=o+Math.imul(d,gt)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,r=Math.imul(z,q),i=(i=Math.imul(z,K))+Math.imul($,q)|0,o=Math.imul($,K),r=r+Math.imul(L,V)|0,i=(i=i+Math.imul(L,G)|0)+Math.imul(N,V)|0,o=o+Math.imul(N,G)|0,r=r+Math.imul(C,Z)|0,i=(i=i+Math.imul(C,Y)|0)+Math.imul(O,Z)|0,o=o+Math.imul(O,Y)|0,r=r+Math.imul(P,Q)|0,i=(i=i+Math.imul(P,tt)|0)+Math.imul(T,Q)|0,o=o+Math.imul(T,tt)|0,r=r+Math.imul(I,nt)|0,i=(i=i+Math.imul(I,rt)|0)+Math.imul(A,nt)|0,o=o+Math.imul(A,rt)|0,r=r+Math.imul(S,ot)|0,i=(i=i+Math.imul(S,st)|0)+Math.imul(x,ot)|0,o=o+Math.imul(x,st)|0,r=r+Math.imul(v,ct)|0,i=(i=i+Math.imul(v,ut)|0)+Math.imul(_,ct)|0,o=o+Math.imul(_,ut)|0,r=r+Math.imul(y,ht)|0,i=(i=i+Math.imul(y,dt)|0)+Math.imul(b,ht)|0,o=o+Math.imul(b,dt)|0;var It=(u+(r=r+Math.imul(p,pt)|0)|0)+((8191&(i=(i=i+Math.imul(p,gt)|0)+Math.imul(g,pt)|0))<<13)|0;u=((o=o+Math.imul(g,gt)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863,r=Math.imul(z,V),i=(i=Math.imul(z,G))+Math.imul($,V)|0,o=Math.imul($,G),r=r+Math.imul(L,Z)|0,i=(i=i+Math.imul(L,Y)|0)+Math.imul(N,Z)|0,o=o+Math.imul(N,Y)|0,r=r+Math.imul(C,Q)|0,i=(i=i+Math.imul(C,tt)|0)+Math.imul(O,Q)|0,o=o+Math.imul(O,tt)|0,r=r+Math.imul(P,nt)|0,i=(i=i+Math.imul(P,rt)|0)+Math.imul(T,nt)|0,o=o+Math.imul(T,rt)|0,r=r+Math.imul(I,ot)|0,i=(i=i+Math.imul(I,st)|0)+Math.imul(A,ot)|0,o=o+Math.imul(A,st)|0,r=r+Math.imul(S,ct)|0,i=(i=i+Math.imul(S,ut)|0)+Math.imul(x,ct)|0,o=o+Math.imul(x,ut)|0,r=r+Math.imul(v,ht)|0,i=(i=i+Math.imul(v,dt)|0)+Math.imul(_,ht)|0,o=o+Math.imul(_,dt)|0;var At=(u+(r=r+Math.imul(y,pt)|0)|0)+((8191&(i=(i=i+Math.imul(y,gt)|0)+Math.imul(b,pt)|0))<<13)|0;u=((o=o+Math.imul(b,gt)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,r=Math.imul(z,Z),i=(i=Math.imul(z,Y))+Math.imul($,Z)|0,o=Math.imul($,Y),r=r+Math.imul(L,Q)|0,i=(i=i+Math.imul(L,tt)|0)+Math.imul(N,Q)|0,o=o+Math.imul(N,tt)|0,r=r+Math.imul(C,nt)|0,i=(i=i+Math.imul(C,rt)|0)+Math.imul(O,nt)|0,o=o+Math.imul(O,rt)|0,r=r+Math.imul(P,ot)|0,i=(i=i+Math.imul(P,st)|0)+Math.imul(T,ot)|0,o=o+Math.imul(T,st)|0,r=r+Math.imul(I,ct)|0,i=(i=i+Math.imul(I,ut)|0)+Math.imul(A,ct)|0,o=o+Math.imul(A,ut)|0,r=r+Math.imul(S,ht)|0,i=(i=i+Math.imul(S,dt)|0)+Math.imul(x,ht)|0,o=o+Math.imul(x,dt)|0;var Bt=(u+(r=r+Math.imul(v,pt)|0)|0)+((8191&(i=(i=i+Math.imul(v,gt)|0)+Math.imul(_,pt)|0))<<13)|0;u=((o=o+Math.imul(_,gt)|0)+(i>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,r=Math.imul(z,Q),i=(i=Math.imul(z,tt))+Math.imul($,Q)|0,o=Math.imul($,tt),r=r+Math.imul(L,nt)|0,i=(i=i+Math.imul(L,rt)|0)+Math.imul(N,nt)|0,o=o+Math.imul(N,rt)|0,r=r+Math.imul(C,ot)|0,i=(i=i+Math.imul(C,st)|0)+Math.imul(O,ot)|0,o=o+Math.imul(O,st)|0,r=r+Math.imul(P,ct)|0,i=(i=i+Math.imul(P,ut)|0)+Math.imul(T,ct)|0,o=o+Math.imul(T,ut)|0,r=r+Math.imul(I,ht)|0,i=(i=i+Math.imul(I,dt)|0)+Math.imul(A,ht)|0,o=o+Math.imul(A,dt)|0;var Pt=(u+(r=r+Math.imul(S,pt)|0)|0)+((8191&(i=(i=i+Math.imul(S,gt)|0)+Math.imul(x,pt)|0))<<13)|0;u=((o=o+Math.imul(x,gt)|0)+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,r=Math.imul(z,nt),i=(i=Math.imul(z,rt))+Math.imul($,nt)|0,o=Math.imul($,rt),r=r+Math.imul(L,ot)|0,i=(i=i+Math.imul(L,st)|0)+Math.imul(N,ot)|0,o=o+Math.imul(N,st)|0,r=r+Math.imul(C,ct)|0,i=(i=i+Math.imul(C,ut)|0)+Math.imul(O,ct)|0,o=o+Math.imul(O,ut)|0,r=r+Math.imul(P,ht)|0,i=(i=i+Math.imul(P,dt)|0)+Math.imul(T,ht)|0,o=o+Math.imul(T,dt)|0;var Tt=(u+(r=r+Math.imul(I,pt)|0)|0)+((8191&(i=(i=i+Math.imul(I,gt)|0)+Math.imul(A,pt)|0))<<13)|0;u=((o=o+Math.imul(A,gt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,r=Math.imul(z,ot),i=(i=Math.imul(z,st))+Math.imul($,ot)|0,o=Math.imul($,st),r=r+Math.imul(L,ct)|0,i=(i=i+Math.imul(L,ut)|0)+Math.imul(N,ct)|0,o=o+Math.imul(N,ut)|0,r=r+Math.imul(C,ht)|0,i=(i=i+Math.imul(C,dt)|0)+Math.imul(O,ht)|0,o=o+Math.imul(O,dt)|0;var Mt=(u+(r=r+Math.imul(P,pt)|0)|0)+((8191&(i=(i=i+Math.imul(P,gt)|0)+Math.imul(T,pt)|0))<<13)|0;u=((o=o+Math.imul(T,gt)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,r=Math.imul(z,ct),i=(i=Math.imul(z,ut))+Math.imul($,ct)|0,o=Math.imul($,ut),r=r+Math.imul(L,ht)|0,i=(i=i+Math.imul(L,dt)|0)+Math.imul(N,ht)|0,o=o+Math.imul(N,dt)|0;var Ct=(u+(r=r+Math.imul(C,pt)|0)|0)+((8191&(i=(i=i+Math.imul(C,gt)|0)+Math.imul(O,pt)|0))<<13)|0;u=((o=o+Math.imul(O,gt)|0)+(i>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,r=Math.imul(z,ht),i=(i=Math.imul(z,dt))+Math.imul($,ht)|0,o=Math.imul($,dt);var Ot=(u+(r=r+Math.imul(L,pt)|0)|0)+((8191&(i=(i=i+Math.imul(L,gt)|0)+Math.imul(N,pt)|0))<<13)|0;u=((o=o+Math.imul(N,gt)|0)+(i>>>13)|0)+(Ot>>>26)|0,Ot&=67108863;var Rt=(u+(r=Math.imul(z,pt))|0)+((8191&(i=(i=Math.imul(z,gt))+Math.imul($,pt)|0))<<13)|0;return u=((o=Math.imul($,gt))+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,c[0]=mt,c[1]=yt,c[2]=bt,c[3]=wt,c[4]=vt,c[5]=_t,c[6]=kt,c[7]=St,c[8]=xt,c[9]=Et,c[10]=It,c[11]=At,c[12]=Bt,c[13]=Pt,c[14]=Tt,c[15]=Mt,c[16]=Ct,c[17]=Ot,c[18]=Rt,0!==u&&(c[19]=u,n.length++),n};function m(t,e,n){n.negative=e.negative^t.negative,n.length=t.length+e.length;for(var r=0,i=0,o=0;o<n.length-1;o++){var s=i;i=0;for(var a=67108863&r,c=Math.min(o,e.length-1),u=Math.max(0,o-t.length+1);u<=c;u++){var l=o-u,h=(0|t.words[l])*(0|e.words[u]),d=67108863&h;a=67108863&(d=d+a|0),i+=(s=(s=s+(h/67108864|0)|0)+(d>>>26)|0)>>>26,s&=67108863}n.words[o]=a,r=s,s=i}return 0!==r?n.words[o]=r:n.length--,n._strip()}function y(t,e,n){return m(t,e,n)}Math.imul||(g=p),i.prototype.mulTo=function(t,e){var n=this.length+t.length;return 10===this.length&&10===t.length?g(this,t,e):n<63?p(this,t,e):n<1024?m(this,t,e):y(this,t,e)},i.prototype.mul=function(t){var e=new i(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},i.prototype.mulf=function(t){var e=new i(null);return e.words=new Array(this.length+t.length),y(this,t,e)},i.prototype.imul=function(t){return this.clone().mulTo(t,this)},i.prototype.imuln=function(t){var e=t<0;e&&(t=-t),n("number"==typeof t),n(t<67108864);for(var r=0,i=0;i<this.length;i++){var o=(0|this.words[i])*t,s=(67108863&o)+(67108863&r);r>>=26,r+=o/67108864|0,r+=s>>>26,this.words[i]=67108863&s}return 0!==r&&(this.words[i]=r,this.length++),e?this.ineg():this},i.prototype.muln=function(t){return this.clone().imuln(t)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),n=0;n<e.length;n++){var r=n/26|0,i=n%26;e[n]=t.words[r]>>>i&1}return e}(t);if(0===e.length)return new i(1);for(var n=this,r=0;r<e.length&&0===e[r];r++,n=n.sqr());if(++r<e.length)for(var o=n.sqr();r<e.length;r++,o=o.sqr())0!==e[r]&&(n=n.mul(o));return n},i.prototype.iushln=function(t){n("number"==typeof t&&t>=0);var e,r=t%26,i=(t-r)/26,o=67108863>>>26-r<<26-r;if(0!==r){var s=0;for(e=0;e<this.length;e++){var a=this.words[e]&o,c=(0|this.words[e])-a<<r;this.words[e]=c|s,s=a>>>26-r}s&&(this.words[e]=s,this.length++)}if(0!==i){for(e=this.length-1;e>=0;e--)this.words[e+i]=this.words[e];for(e=0;e<i;e++)this.words[e]=0;this.length+=i}return this._strip()},i.prototype.ishln=function(t){return n(0===this.negative),this.iushln(t)},i.prototype.iushrn=function(t,e,r){var i;n("number"==typeof t&&t>=0),i=e?(e-e%26)/26:0;var o=t%26,s=Math.min((t-o)/26,this.length),a=67108863^67108863>>>o<<o,c=r;if(i-=s,i=Math.max(0,i),c){for(var u=0;u<s;u++)c.words[u]=this.words[u];c.length=s}if(0===s);else if(this.length>s)for(this.length-=s,u=0;u<this.length;u++)this.words[u]=this.words[u+s];else this.words[0]=0,this.length=1;var l=0;for(u=this.length-1;u>=0&&(0!==l||u>=i);u--){var h=0|this.words[u];this.words[u]=l<<26-o|h>>>o,l=h&a}return c&&0!==l&&(c.words[c.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},i.prototype.ishrn=function(t,e,r){return n(0===this.negative),this.iushrn(t,e,r)},i.prototype.shln=function(t){return this.clone().ishln(t)},i.prototype.ushln=function(t){return this.clone().iushln(t)},i.prototype.shrn=function(t){return this.clone().ishrn(t)},i.prototype.ushrn=function(t){return this.clone().iushrn(t)},i.prototype.testn=function(t){n("number"==typeof t&&t>=0);var e=t%26,r=(t-e)/26,i=1<<e;return!(this.length<=r)&&!!(this.words[r]&i)},i.prototype.imaskn=function(t){n("number"==typeof t&&t>=0);var e=t%26,r=(t-e)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==e&&r++,this.length=Math.min(r,this.length),0!==e){var i=67108863^67108863>>>e<<e;this.words[this.length-1]&=i}return this._strip()},i.prototype.maskn=function(t){return this.clone().imaskn(t)},i.prototype.iaddn=function(t){return n("number"==typeof t),n(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<=t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},i.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},i.prototype.isubn=function(t){if(n("number"==typeof t),n(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this._strip()},i.prototype.addn=function(t){return this.clone().iaddn(t)},i.prototype.subn=function(t){return this.clone().isubn(t)},i.prototype.iabs=function(){return this.negative=0,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(t,e,r){var i,o,s=t.length+r;this._expand(s);var a=0;for(i=0;i<t.length;i++){o=(0|this.words[i+r])+a;var c=(0|t.words[i])*e;a=((o-=67108863&c)>>26)-(c/67108864|0),this.words[i+r]=67108863&o}for(;i<this.length-r;i++)a=(o=(0|this.words[i+r])+a)>>26,this.words[i+r]=67108863&o;if(0===a)return this._strip();for(n(-1===a),a=0,i=0;i<this.length;i++)a=(o=-(0|this.words[i])+a)>>26,this.words[i]=67108863&o;return this.negative=1,this._strip()},i.prototype._wordDiv=function(t,e){var n=(this.length,t.length),r=this.clone(),o=t,s=0|o.words[o.length-1];0!==(n=26-this._countBits(s))&&(o=o.ushln(n),r.iushln(n),s=0|o.words[o.length-1]);var a,c=r.length-o.length;if("mod"!==e){(a=new i(null)).length=c+1,a.words=new Array(a.length);for(var u=0;u<a.length;u++)a.words[u]=0}var l=r.clone()._ishlnsubmul(o,1,c);0===l.negative&&(r=l,a&&(a.words[c]=1));for(var h=c-1;h>=0;h--){var d=67108864*(0|r.words[o.length+h])+(0|r.words[o.length+h-1]);for(d=Math.min(d/s|0,67108863),r._ishlnsubmul(o,d,h);0!==r.negative;)d--,r.negative=0,r._ishlnsubmul(o,1,h),r.isZero()||(r.negative^=1);a&&(a.words[h]=d)}return a&&a._strip(),r._strip(),"div"!==e&&0!==n&&r.iushrn(n),{div:a||null,mod:r}},i.prototype.divmod=function(t,e,r){return n(!t.isZero()),this.isZero()?{div:new i(0),mod:new i(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),"mod"!==e&&(o=a.div.neg()),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.iadd(t)),{div:o,mod:s}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(o=a.div.neg()),{div:o,mod:a.mod}):this.negative&t.negative?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.isub(t)),{div:a.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new i(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new i(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new i(this.modrn(t.words[0]))}:this._wordDiv(t,e);var o,s,a},i.prototype.div=function(t){return this.divmod(t,"div",!1).div},i.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},i.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},i.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var n=0!==e.div.negative?e.mod.isub(t):e.mod,r=t.ushrn(1),i=t.andln(1),o=n.cmp(r);return o<0||1===i&&0===o?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},i.prototype.modrn=function(t){var e=t<0;e&&(t=-t),n(t<=67108863);for(var r=(1<<26)%t,i=0,o=this.length-1;o>=0;o--)i=(r*i+(0|this.words[o]))%t;return e?-i:i},i.prototype.modn=function(t){return this.modrn(t)},i.prototype.idivn=function(t){var e=t<0;e&&(t=-t),n(t<=67108863);for(var r=0,i=this.length-1;i>=0;i--){var o=(0|this.words[i])+67108864*r;this.words[i]=o/t|0,r=o%t}return this._strip(),e?this.ineg():this},i.prototype.divn=function(t){return this.clone().idivn(t)},i.prototype.egcd=function(t){n(0===t.negative),n(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o=new i(1),s=new i(0),a=new i(0),c=new i(1),u=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++u;for(var l=r.clone(),h=e.clone();!e.isZero();){for(var d=0,f=1;!(e.words[0]&f)&&d<26;++d,f<<=1);if(d>0)for(e.iushrn(d);d-- >0;)(o.isOdd()||s.isOdd())&&(o.iadd(l),s.isub(h)),o.iushrn(1),s.iushrn(1);for(var p=0,g=1;!(r.words[0]&g)&&p<26;++p,g<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(a.isOdd()||c.isOdd())&&(a.iadd(l),c.isub(h)),a.iushrn(1),c.iushrn(1);e.cmp(r)>=0?(e.isub(r),o.isub(a),s.isub(c)):(r.isub(e),a.isub(o),c.isub(s))}return{a:a,b:c,gcd:r.iushln(u)}},i.prototype._invmp=function(t){n(0===t.negative),n(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o,s=new i(1),a=new i(0),c=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var u=0,l=1;!(e.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(e.iushrn(u);u-- >0;)s.isOdd()&&s.iadd(c),s.iushrn(1);for(var h=0,d=1;!(r.words[0]&d)&&h<26;++h,d<<=1);if(h>0)for(r.iushrn(h);h-- >0;)a.isOdd()&&a.iadd(c),a.iushrn(1);e.cmp(r)>=0?(e.isub(r),s.isub(a)):(r.isub(e),a.isub(s))}return(o=0===e.cmpn(1)?s:a).cmpn(0)<0&&o.iadd(t),o},i.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),n=t.clone();e.negative=0,n.negative=0;for(var r=0;e.isEven()&&n.isEven();r++)e.iushrn(1),n.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;n.isEven();)n.iushrn(1);var i=e.cmp(n);if(i<0){var o=e;e=n,n=o}else if(0===i||0===n.cmpn(1))break;e.isub(n)}return n.iushln(r)},i.prototype.invm=function(t){return this.egcd(t).a.umod(t)},i.prototype.isEven=function(){return!(1&this.words[0])},i.prototype.isOdd=function(){return!(1&~this.words[0])},i.prototype.andln=function(t){return this.words[0]&t},i.prototype.bincn=function(t){n("number"==typeof t);var e=t%26,r=(t-e)/26,i=1<<e;if(this.length<=r)return this._expand(r+1),this.words[r]|=i,this;for(var o=i,s=r;0!==o&&s<this.length;s++){var a=0|this.words[s];o=(a+=o)>>>26,a&=67108863,this.words[s]=a}return 0!==o&&(this.words[s]=o,this.length++),this},i.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},i.prototype.cmpn=function(t){var e,r=t<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this._strip(),this.length>1)e=1;else{r&&(t=-t),n(t<=67108863,"Number is too big");var i=0|this.words[0];e=i===t?0:i<t?-1:1}return 0!==this.negative?0|-e:e},i.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},i.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,n=this.length-1;n>=0;n--){var r=0|this.words[n],i=0|t.words[n];if(r!==i){r<i?e=-1:r>i&&(e=1);break}}return e},i.prototype.gtn=function(t){return 1===this.cmpn(t)},i.prototype.gt=function(t){return 1===this.cmp(t)},i.prototype.gten=function(t){return this.cmpn(t)>=0},i.prototype.gte=function(t){return this.cmp(t)>=0},i.prototype.ltn=function(t){return-1===this.cmpn(t)},i.prototype.lt=function(t){return-1===this.cmp(t)},i.prototype.lten=function(t){return this.cmpn(t)<=0},i.prototype.lte=function(t){return this.cmp(t)<=0},i.prototype.eqn=function(t){return 0===this.cmpn(t)},i.prototype.eq=function(t){return 0===this.cmp(t)},i.red=function(t){return new x(t)},i.prototype.toRed=function(t){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},i.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(t){return this.red=t,this},i.prototype.forceRed=function(t){return n(!this.red,"Already a number in reduction context"),this._forceRed(t)},i.prototype.redAdd=function(t){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},i.prototype.redIAdd=function(t){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},i.prototype.redSub=function(t){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},i.prototype.redISub=function(t){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},i.prototype.redShl=function(t){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},i.prototype.redMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},i.prototype.redIMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},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(t){return n(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var b={k256:null,p224:null,p192:null,p25519:null};function w(t,e){this.name=t,this.p=new i(e,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){w.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function _(){w.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function k(){w.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function S(){w.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function x(t){if("string"==typeof t){var e=i._prime(t);this.m=e.p,this.prime=e}else n(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function E(t){x.call(this,t),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)}w.prototype._tmp=function(){var t=new i(null);return t.words=new Array(Math.ceil(this.n/13)),t},w.prototype.ireduce=function(t){var e,n=t;do{this.split(n,this.tmp),e=(n=(n=this.imulK(n)).iadd(this.tmp)).bitLength()}while(e>this.n);var r=e<this.n?-1:n.ucmp(this.p);return 0===r?(n.words[0]=0,n.length=1):r>0?n.isub(this.p):void 0!==n.strip?n.strip():n._strip(),n},w.prototype.split=function(t,e){t.iushrn(this.n,0,e)},w.prototype.imulK=function(t){return t.imul(this.k)},r(v,w),v.prototype.split=function(t,e){for(var n=4194303,r=Math.min(t.length,9),i=0;i<r;i++)e.words[i]=t.words[i];if(e.length=r,t.length<=9)return t.words[0]=0,void(t.length=1);var o=t.words[9];for(e.words[e.length++]=o&n,i=10;i<t.length;i++){var s=0|t.words[i];t.words[i-10]=(s&n)<<4|o>>>22,o=s}o>>>=22,t.words[i-10]=o,0===o&&t.length>10?t.length-=10:t.length-=9},v.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,n=0;n<t.length;n++){var r=0|t.words[n];e+=977*r,t.words[n]=67108863&e,e=64*r+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},r(_,w),r(k,w),r(S,w),S.prototype.imulK=function(t){for(var e=0,n=0;n<t.length;n++){var r=19*(0|t.words[n])+e,i=67108863&r;r>>>=26,t.words[n]=i,e=r}return 0!==e&&(t.words[t.length++]=e),t},i._prime=function(t){if(b[t])return b[t];var e;if("k256"===t)e=new v;else if("p224"===t)e=new _;else if("p192"===t)e=new k;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new S}return b[t]=e,e},x.prototype._verify1=function(t){n(0===t.negative,"red works only with positives"),n(t.red,"red works only with red numbers")},x.prototype._verify2=function(t,e){n(!(t.negative|e.negative),"red works only with positives"),n(t.red&&t.red===e.red,"red works only with red numbers")},x.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(u(t,t.umod(this.m)._forceRed(this)),t)},x.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},x.prototype.add=function(t,e){this._verify2(t,e);var n=t.add(e);return n.cmp(this.m)>=0&&n.isub(this.m),n._forceRed(this)},x.prototype.iadd=function(t,e){this._verify2(t,e);var n=t.iadd(e);return n.cmp(this.m)>=0&&n.isub(this.m),n},x.prototype.sub=function(t,e){this._verify2(t,e);var n=t.sub(e);return n.cmpn(0)<0&&n.iadd(this.m),n._forceRed(this)},x.prototype.isub=function(t,e){this._verify2(t,e);var n=t.isub(e);return n.cmpn(0)<0&&n.iadd(this.m),n},x.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},x.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},x.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},x.prototype.isqr=function(t){return this.imul(t,t.clone())},x.prototype.sqr=function(t){return this.mul(t,t)},x.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(n(e%2==1),3===e){var r=this.m.add(new i(1)).iushrn(2);return this.pow(t,r)}for(var o=this.m.subn(1),s=0;!o.isZero()&&0===o.andln(1);)s++,o.iushrn(1);n(!o.isZero());var a=new i(1).toRed(this),c=a.redNeg(),u=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new i(2*l*l).toRed(this);0!==this.pow(l,u).cmp(c);)l.redIAdd(c);for(var h=this.pow(l,o),d=this.pow(t,o.addn(1).iushrn(1)),f=this.pow(t,o),p=s;0!==f.cmp(a);){for(var g=f,m=0;0!==g.cmp(a);m++)g=g.redSqr();n(m<p);var y=this.pow(h,new i(1).iushln(p-m-1));d=d.redMul(y),h=y.redSqr(),f=f.redMul(h),p=m}return d},x.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},x.prototype.pow=function(t,e){if(e.isZero())return new i(1).toRed(this);if(0===e.cmpn(1))return t.clone();var n=new Array(16);n[0]=new i(1).toRed(this),n[1]=t;for(var r=2;r<n.length;r++)n[r]=this.mul(n[r-1],t);var o=n[0],s=0,a=0,c=e.bitLength()%26;for(0===c&&(c=26),r=e.length-1;r>=0;r--){for(var u=e.words[r],l=c-1;l>=0;l--){var h=u>>l&1;o!==n[0]&&(o=this.sqr(o)),0!==h||0!==s?(s<<=1,s|=h,(4===++a||0===r&&0===l)&&(o=this.mul(o,n[s]),a=0,s=0)):a=0}c=26}return o},x.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},x.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},i.mont=function(t){return new E(t)},r(E,x),E.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},E.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},E.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var n=t.imul(e),r=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=n.isub(r).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},E.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new i(0)._forceRed(this);var n=t.mul(e),r=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=n.isub(r).iushrn(this.shift),s=o;return o.cmp(this.m)>=0?s=o.isub(this.m):o.cmpn(0)<0&&(s=o.iadd(this.m)),s._forceRed(this)},E.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t,r)}(Co);var Ro=Co.exports,Lo={exports:{}};/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
!function(t,e){var n=cr,r=n.Buffer;function i(t,e){for(var n in t)e[n]=t[n]}function o(t,e,n){return r(t,e,n)}r.from&&r.alloc&&r.allocUnsafe&&r.allocUnsafeSlow?t.exports=n:(i(n,e),e.Buffer=o),o.prototype=Object.create(r.prototype),i(r,o),o.from=function(t,e,n){if("number"==typeof t)throw new TypeError("Argument must not be a number");return r(t,e,n)},o.alloc=function(t,e,n){if("number"!=typeof t)throw new TypeError("Argument must be a number");var i=r(t);return void 0!==e?"string"==typeof n?i.fill(e,n):i.fill(e):i.fill(0),i},o.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return r(t)},o.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return n.SlowBuffer(t)}}(Lo,Lo.exports);var No=Lo.exports.Buffer;var Uo=function(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var r=0;r<t.length;r++){var i=t.charAt(r),o=i.charCodeAt(0);if(255!==e[o])throw new TypeError(i+" is ambiguous");e[o]=r}var s=t.length,a=t.charAt(0),c=Math.log(s)/Math.log(256),u=Math.log(256)/Math.log(s);function l(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return No.alloc(0);for(var n=0,r=0,i=0;t[n]===a;)r++,n++;for(var o=(t.length-n)*c+1>>>0,u=new Uint8Array(o);t[n];){var l=e[t.charCodeAt(n)];if(255===l)return;for(var h=0,d=o-1;(0!==l||h<i)&&-1!==d;d--,h++)l+=s*u[d]>>>0,u[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,n++}for(var f=o-i;f!==o&&0===u[f];)f++;var p=No.allocUnsafe(r+(o-f));p.fill(0,0,r);for(var g=r;f!==o;)p[g++]=u[f++];return p}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=No.from(e)),!No.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var n=0,r=0,i=0,o=e.length;i!==o&&0===e[i];)i++,n++;for(var c=(o-i)*u+1>>>0,l=new Uint8Array(c);i!==o;){for(var h=e[i],d=0,f=c-1;(0!==h||d<r)&&-1!==f;f--,d++)h+=256*l[f]>>>0,l[f]=h%s>>>0,h=h/s>>>0;if(0!==h)throw new Error("Non-zero carry");r=d,i++}for(var p=c-r;p!==c&&0===l[p];)p++;for(var g=a.repeat(n);p<c;++p)g+=t.charAt(l[p]);return g},decodeUnsafe:l,decode:function(t){var e=l(t);if(e)return e;throw new Error("Non-base"+s+" character")}}},zo=Uo("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");const $o=ci;var Wo={},Fo=Lo.exports.Buffer;var Do=function(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var r=0;r<t.length;r++){var i=t.charAt(r),o=i.charCodeAt(0);if(255!==e[o])throw new TypeError(i+" is ambiguous");e[o]=r}var s=t.length,a=t.charAt(0),c=Math.log(s)/Math.log(256),u=Math.log(256)/Math.log(s);function l(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return Fo.alloc(0);for(var n=0,r=0,i=0;t[n]===a;)r++,n++;for(var o=(t.length-n)*c+1>>>0,u=new Uint8Array(o);t[n];){var l=e[t.charCodeAt(n)];if(255===l)return;for(var h=0,d=o-1;(0!==l||h<i)&&-1!==d;d--,h++)l+=s*u[d]>>>0,u[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,n++}for(var f=o-i;f!==o&&0===u[f];)f++;var p=Fo.allocUnsafe(r+(o-f));p.fill(0,0,r);for(var g=r;f!==o;)p[g++]=u[f++];return p}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=Fo.from(e)),!Fo.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var n=0,r=0,i=0,o=e.length;i!==o&&0===e[i];)i++,n++;for(var c=(o-i)*u+1>>>0,l=new Uint8Array(c);i!==o;){for(var h=e[i],d=0,f=c-1;(0!==h||d<r)&&-1!==f;f--,d++)h+=256*l[f]>>>0,l[f]=h%s>>>0,h=h/s>>>0;if(0!==h)throw new Error("Non-zero carry");r=d,i++}for(var p=c-r;p!==c&&0===l[p];)p++;for(var g=a.repeat(n);p<c;++p)g+=t.charAt(l[p]);return g},decodeUnsafe:l,decode:function(t){var e=l(t);if(e)return e;throw new Error("Non-base"+s+" character")}}},jo=Do("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");function qo(t,e,n){return e<=t&&t<=n}function Ko(t){if(void 0===t)return{};if(t===Object(t))return t;throw TypeError("Could not convert argument to dictionary")}function Ho(t){this.tokens=[].slice.call(t)}Ho.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():-1},prepend:function(t){if(Array.isArray(t))for(var e=t;e.length;)this.tokens.unshift(e.pop());else this.tokens.unshift(t)},push:function(t){if(Array.isArray(t))for(var e=t;e.length;)this.tokens.push(e.shift());else this.tokens.push(t)}};var Vo=-1;function Go(t,e){if(t)throw TypeError("Decoder error");return e||65533}var Jo="utf-8";function Zo(t,e){if(!(this instanceof Zo))return new Zo(t,e);if((t=void 0!==t?String(t).toLowerCase():Jo)!==Jo)throw new Error("Encoding not supported. Only utf-8 is supported");e=Ko(e),this._streaming=!1,this._BOMseen=!1,this._decoder=null,this._fatal=Boolean(e.fatal),this._ignoreBOM=Boolean(e.ignoreBOM),Object.defineProperty(this,"encoding",{value:"utf-8"}),Object.defineProperty(this,"fatal",{value:this._fatal}),Object.defineProperty(this,"ignoreBOM",{value:this._ignoreBOM})}function Yo(t,e){if(!(this instanceof Yo))return new Yo(t,e);if((t=void 0!==t?String(t).toLowerCase():Jo)!==Jo)throw new Error("Encoding not supported. Only utf-8 is supported");e=Ko(e),this._streaming=!1,this._encoder=null,this._options={fatal:Boolean(e.fatal)},Object.defineProperty(this,"encoding",{value:"utf-8"})}function Xo(t){var e=t.fatal,n=0,r=0,i=0,o=128,s=191;this.handler=function(t,a){if(-1===a&&0!==i)return i=0,Go(e);if(-1===a)return Vo;if(0===i){if(qo(a,0,127))return a;if(qo(a,194,223))i=1,n=a-192;else if(qo(a,224,239))224===a&&(o=160),237===a&&(s=159),i=2,n=a-224;else{if(!qo(a,240,244))return Go(e);240===a&&(o=144),244===a&&(s=143),i=3,n=a-240}return n<<=6*i,null}if(!qo(a,o,s))return n=i=r=0,o=128,s=191,t.prepend(a),Go(e);if(o=128,s=191,n+=a-128<<6*(i-(r+=1)),r!==i)return null;var c=n;return n=i=r=0,c}}function Qo(t){t.fatal,this.handler=function(t,e){if(-1===e)return Vo;if(qo(e,0,127))return e;var n,r;qo(e,128,2047)?(n=1,r=192):qo(e,2048,65535)?(n=2,r=224):qo(e,65536,1114111)&&(n=3,r=240);for(var i=[(e>>6*n)+r];n>0;){var o=e>>6*(n-1);i.push(128|63&o),n-=1}return i}}Zo.prototype={decode:function(t,e){var n;n="object"==typeof t&&t instanceof ArrayBuffer?new Uint8Array(t):"object"==typeof t&&"buffer"in t&&t.buffer instanceof ArrayBuffer?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):new Uint8Array(0),e=Ko(e),this._streaming||(this._decoder=new Xo({fatal:this._fatal}),this._BOMseen=!1),this._streaming=Boolean(e.stream);for(var r,i=new Ho(n),o=[];!i.endOfStream()&&(r=this._decoder.handler(i,i.read()))!==Vo;)null!==r&&(Array.isArray(r)?o.push.apply(o,r):o.push(r));if(!this._streaming){do{if((r=this._decoder.handler(i,i.read()))===Vo)break;null!==r&&(Array.isArray(r)?o.push.apply(o,r):o.push(r))}while(!i.endOfStream());this._decoder=null}return o.length&&(-1===["utf-8"].indexOf(this.encoding)||this._ignoreBOM||this._BOMseen||(65279===o[0]?(this._BOMseen=!0,o.shift()):this._BOMseen=!0)),function(t){for(var e="",n=0;n<t.length;++n){var r=t[n];r<=65535?e+=String.fromCharCode(r):(r-=65536,e+=String.fromCharCode(55296+(r>>10),56320+(1023&r)))}return e}(o)}},Yo.prototype={encode:function(t,e){t=t?String(t):"",e=Ko(e),this._streaming||(this._encoder=new Qo(this._options)),this._streaming=Boolean(e.stream);for(var n,r=[],i=new Ho(function(t){for(var e=String(t),n=e.length,r=0,i=[];r<n;){var o=e.charCodeAt(r);if(o<55296||o>57343)i.push(o);else if(56320<=o&&o<=57343)i.push(65533);else if(55296<=o&&o<=56319)if(r===n-1)i.push(65533);else{var s=t.charCodeAt(r+1);if(56320<=s&&s<=57343){var a=1023&o,c=1023&s;i.push(65536+(a<<10)+c),r+=1}else i.push(65533)}r+=1}return i}(t));!i.endOfStream()&&(n=this._encoder.handler(i,i.read()))!==Vo;)Array.isArray(n)?r.push.apply(r,n):r.push(n);if(!this._streaming){for(;(n=this._encoder.handler(i,i.read()))!==Vo;)Array.isArray(n)?r.push.apply(r,n):r.push(n);this._encoder=null}return new Uint8Array(r)}};var ts=i(Object.freeze({__proto__:null,TextEncoder:Yo,TextDecoder:Zo})),es=r&&r.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n),Object.defineProperty(t,r,{enumerable:!0,get:function(){return e[n]}})}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),ns=r&&r.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),rs=r&&r.__decorate||function(t,e,n,r){var i,o=arguments.length,s=o<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(o<3?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},is=r&&r.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.hasOwnProperty.call(t,n)&&es(e,t,n);return ns(e,t),e},os=r&&r.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Wo,"__esModule",{value:!0});var ss=Wo.deserializeUnchecked=ks=Wo.deserialize=ws=Wo.serialize=Wo.BinaryReader=Wo.BinaryWriter=Wo.BorshError=Wo.baseDecode=Wo.baseEncode=void 0;const as=os(Co.exports),cs=os(jo),us=is(ts),ls=new("function"!=typeof TextDecoder?us.TextDecoder:TextDecoder)("utf-8",{fatal:!0});Wo.baseEncode=function(t){return"string"==typeof t&&(t=Buffer.from(t,"utf8")),cs.default.encode(Buffer.from(t))},Wo.baseDecode=function(t){return Buffer.from(cs.default.decode(t))};const hs=1024;class ds extends Error{constructor(t){super(t),this.fieldPath=[],this.originalMessage=t}addToFieldPath(t){this.fieldPath.splice(0,0,t),this.message=this.originalMessage+": "+this.fieldPath.join(".")}}Wo.BorshError=ds;class fs{constructor(){this.buf=Buffer.alloc(hs),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Buffer.concat([this.buf,Buffer.alloc(hs)]))}writeU8(t){this.maybeResize(),this.buf.writeUInt8(t,this.length),this.length+=1}writeU16(t){this.maybeResize(),this.buf.writeUInt16LE(t,this.length),this.length+=2}writeU32(t){this.maybeResize(),this.buf.writeUInt32LE(t,this.length),this.length+=4}writeU64(t){this.maybeResize(),this.writeBuffer(Buffer.from(new as.default(t).toArray("le",8)))}writeU128(t){this.maybeResize(),this.writeBuffer(Buffer.from(new as.default(t).toArray("le",16)))}writeU256(t){this.maybeResize(),this.writeBuffer(Buffer.from(new as.default(t).toArray("le",32)))}writeU512(t){this.maybeResize(),this.writeBuffer(Buffer.from(new as.default(t).toArray("le",64)))}writeBuffer(t){this.buf=Buffer.concat([Buffer.from(this.buf.subarray(0,this.length)),t,Buffer.alloc(hs)]),this.length+=t.length}writeString(t){this.maybeResize();const e=Buffer.from(t,"utf8");this.writeU32(e.length),this.writeBuffer(e)}writeFixedArray(t){this.writeBuffer(Buffer.from(t))}writeArray(t,e){this.maybeResize(),this.writeU32(t.length);for(const n of t)this.maybeResize(),e(n)}toArray(){return this.buf.subarray(0,this.length)}}function ps(t,e,n){const r=n.value;n.value=function(...t){try{return r.apply(this,t)}catch(t){if(t instanceof RangeError){const e=t.code;if(["ERR_BUFFER_OUT_OF_BOUNDS","ERR_OUT_OF_RANGE"].indexOf(e)>=0)throw new ds("Reached the end of buffer when deserializing")}throw t}}}Wo.BinaryWriter=fs;class gs{constructor(t){this.buf=t,this.offset=0}readU8(){const t=this.buf.readUInt8(this.offset);return this.offset+=1,t}readU16(){const t=this.buf.readUInt16LE(this.offset);return this.offset+=2,t}readU32(){const t=this.buf.readUInt32LE(this.offset);return this.offset+=4,t}readU64(){const t=this.readBuffer(8);return new as.default(t,"le")}readU128(){const t=this.readBuffer(16);return new as.default(t,"le")}readU256(){const t=this.readBuffer(32);return new as.default(t,"le")}readU512(){const t=this.readBuffer(64);return new as.default(t,"le")}readBuffer(t){if(this.offset+t>this.buf.length)throw new ds(`Expected buffer length ${t} isn't within bounds`);const e=this.buf.slice(this.offset,this.offset+t);return this.offset+=t,e}readString(){const t=this.readU32(),e=this.readBuffer(t);try{return ls.decode(e)}catch(t){throw new ds(`Error decoding UTF-8 string: ${t}`)}}readFixedArray(t){return new Uint8Array(this.readBuffer(t))}readArray(t){const e=this.readU32(),n=Array();for(let r=0;r<e;++r)n.push(t());return n}}function ms(t){return t.charAt(0).toUpperCase()+t.slice(1)}function ys(t,e,n,r,i){try{if("string"==typeof r)i[`write${ms(r)}`](n);else if(r instanceof Array)if("number"==typeof r[0]){if(n.length!==r[0])throw new ds(`Expecting byte array of length ${r[0]}, but got ${n.length} bytes`);i.writeFixedArray(n)}else if(2===r.length&&"number"==typeof r[1]){if(n.length!==r[1])throw new ds(`Expecting byte array of length ${r[1]}, but got ${n.length} bytes`);for(let e=0;e<r[1];e++)ys(t,null,n[e],r[0],i)}else i.writeArray(n,(n=>{ys(t,e,n,r[0],i)}));else if(void 0!==r.kind)switch(r.kind){case"option":null==n?i.writeU8(0):(i.writeU8(1),ys(t,e,n,r.type,i));break;case"map":i.writeU32(n.size),n.forEach(((n,o)=>{ys(t,e,o,r.key,i),ys(t,e,n,r.value,i)}));break;default:throw new ds(`FieldType ${r} unrecognized`)}else bs(t,n,i)}catch(t){throw t instanceof ds&&t.addToFieldPath(e),t}}function bs(t,e,n){if("function"==typeof e.borshSerialize)return void e.borshSerialize(n);const r=t.get(e.constructor);if(!r)throw new ds(`Class ${e.constructor.name} is missing in schema`);if("struct"===r.kind)r.fields.map((([r,i])=>{ys(t,r,e[r],i,n)}));else{if("enum"!==r.kind)throw new ds(`Unexpected schema kind: ${r.kind} for ${e.constructor.name}`);{const i=e[r.field];for(let o=0;o<r.values.length;++o){const[s,a]=r.values[o];if(s===i){n.writeU8(o),ys(t,s,e[s],a,n);break}}}}}rs([ps],gs.prototype,"readU8",null),rs([ps],gs.prototype,"readU16",null),rs([ps],gs.prototype,"readU32",null),rs([ps],gs.prototype,"readU64",null),rs([ps],gs.prototype,"readU128",null),rs([ps],gs.prototype,"readU256",null),rs([ps],gs.prototype,"readU512",null),rs([ps],gs.prototype,"readString",null),rs([ps],gs.prototype,"readFixedArray",null),rs([ps],gs.prototype,"readArray",null),Wo.BinaryReader=gs;var ws=Wo.serialize=function(t,e,n=fs){const r=new n;return bs(t,e,r),r.toArray()};function vs(t,e,n,r){try{if("string"==typeof n)return r[`read${ms(n)}`]();if(n instanceof Array){if("number"==typeof n[0])return r.readFixedArray(n[0]);if("number"==typeof n[1]){const e=[];for(let i=0;i<n[1];i++)e.push(vs(t,null,n[0],r));return e}return r.readArray((()=>vs(t,e,n[0],r)))}if("option"===n.kind){return r.readU8()?vs(t,e,n.type,r):void 0}if("map"===n.kind){let i=new Map;const o=r.readU32();for(let s=0;s<o;s++){const o=vs(t,e,n.key,r),s=vs(t,e,n.value,r);i.set(o,s)}return i}return _s(t,n,r)}catch(t){throw t instanceof ds&&t.addToFieldPath(e),t}}function _s(t,e,n){if("function"==typeof e.borshDeserialize)return e.borshDeserialize(n);const r=t.get(e);if(!r)throw new ds(`Class ${e.name} is missing in schema`);if("struct"===r.kind){const r={};for(const[i,o]of t.get(e).fields)r[i]=vs(t,i,o,n);return new e(r)}if("enum"===r.kind){const i=n.readU8();if(i>=r.values.length)throw new ds(`Enum index: ${i} is out of range`);const[o,s]=r.values[i],a=vs(t,o,s,n);return new e({[o]:a})}throw new ds(`Unexpected schema kind: ${r.kind} for ${e.constructor.name}`)}var ks=Wo.deserialize=function(t,e,n,r=gs){const i=new r(n),o=_s(t,e,i);if(i.offset<n.length)throw new ds(`Unexpected ${n.length-i.offset} bytes after deserialized data`);return o};ss=Wo.deserializeUnchecked=function(t,e,n,r=gs){return _s(t,e,new r(n))};var Ss={};Object.defineProperty(Ss,"__esModule",{value:!0}),Ss.s16=Ss.s8=Ss.nu64be=Ss.u48be=Ss.u40be=Ss.u32be=Ss.u24be=Ss.u16be=ha=Ss.nu64=Ss.u48=Ss.u40=la=Ss.u32=Ss.u24=ua=Ss.u16=ca=Ss.u8=aa=Ss.offset=Ss.greedy=Ss.Constant=Ss.UTF8=Ss.CString=Ss.Blob=Ss.Boolean=Ss.BitField=Ss.BitStructure=Ss.VariantLayout=Ss.Union=Ss.UnionLayoutDiscriminator=Ss.UnionDiscriminator=Ss.Structure=Ss.Sequence=Ss.DoubleBE=Ss.Double=Ss.FloatBE=Ss.Float=Ss.NearInt64BE=Ss.NearInt64=Ss.NearUInt64BE=Ss.NearUInt64=Ss.IntBE=Ss.Int=Ss.UIntBE=Ss.UInt=Ss.OffsetLayout=Ss.GreedyCount=Ss.ExternalLayout=Ss.bindConstructorLayout=Ss.nameWithProperty=Ss.Layout=Ss.uint8ArrayToBuffer=Ss.checkUint8Array=void 0,Ss.constant=Ss.utf8=Ss.cstr=ga=Ss.blob=Ss.unionLayoutDiscriminator=Ss.union=pa=Ss.seq=Ss.bits=fa=Ss.struct=Ss.f64be=Ss.f64=Ss.f32be=Ss.f32=Ss.ns64be=Ss.s48be=Ss.s40be=Ss.s32be=Ss.s24be=Ss.s16be=da=Ss.ns64=Ss.s48=Ss.s40=Ss.s32=Ss.s24=void 0;const xs=cr;function Es(t){if(!(t instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}function Is(t){return Es(t),xs.Buffer.from(t.buffer,t.byteOffset,t.length)}Ss.checkUint8Array=Es,Ss.uint8ArrayToBuffer=Is;class As{constructor(t,e){if(!Number.isInteger(t))throw new TypeError("span must be an integer");this.span=t,this.property=e}makeDestinationObject(){return{}}getSpan(t,e){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(t){const e=Object.create(this.constructor.prototype);return Object.assign(e,this),e.property=t,e}fromArray(t){}}function Bs(t,e){return e.property?t+"["+e.property+"]":t}Ss.Layout=As,Ss.nameWithProperty=Bs,Ss.bindConstructorLayout=function(t,e){if("function"!=typeof t)throw new TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(t,"layout_"))throw new Error("Class is already bound to a layout");if(!(e&&e instanceof As))throw new TypeError("layout must be a Layout");if(Object.prototype.hasOwnProperty.call(e,"boundConstructor_"))throw new Error("layout is already bound to a constructor");t.layout_=e,e.boundConstructor_=t,e.makeDestinationObject=()=>new t,Object.defineProperty(t.prototype,"encode",{value(t,n){return e.encode(this,t,n)},writable:!0}),Object.defineProperty(t,"decode",{value:(t,n)=>e.decode(t,n),writable:!0})};class Ps extends As{isCount(){throw new Error("ExternalLayout is abstract")}}Ss.ExternalLayout=Ps;class Ts extends Ps{constructor(t=1,e){if(!Number.isInteger(t)||0>=t)throw new TypeError("elementSpan must be a (positive) integer");super(-1,e),this.elementSpan=t}isCount(){return!0}decode(t,e=0){Es(t);const n=t.length-e;return Math.floor(n/this.elementSpan)}encode(t,e,n){return 0}}Ss.GreedyCount=Ts;class Ms extends Ps{constructor(t,e=0,n){if(!(t instanceof As))throw new TypeError("layout must be a Layout");if(!Number.isInteger(e))throw new TypeError("offset must be integer or undefined");super(t.span,n||t.property),this.layout=t,this.offset=e}isCount(){return this.layout instanceof Cs||this.layout instanceof Os}decode(t,e=0){return this.layout.decode(t,e+this.offset)}encode(t,e,n=0){return this.layout.encode(t,e,n+this.offset)}}Ss.OffsetLayout=Ms;class Cs extends As{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return Is(t).readUIntLE(e,this.span)}encode(t,e,n=0){return Is(e).writeUIntLE(t,n,this.span),this.span}}Ss.UInt=Cs;class Os extends As{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return Is(t).readUIntBE(e,this.span)}encode(t,e,n=0){return Is(e).writeUIntBE(t,n,this.span),this.span}}Ss.UIntBE=Os;class Rs extends As{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return Is(t).readIntLE(e,this.span)}encode(t,e,n=0){return Is(e).writeIntLE(t,n,this.span),this.span}}Ss.Int=Rs;class Ls extends As{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return Is(t).readIntBE(e,this.span)}encode(t,e,n=0){return Is(e).writeIntBE(t,n,this.span),this.span}}Ss.IntBE=Ls;const Ns=Math.pow(2,32);function Us(t){const e=Math.floor(t/Ns);return{hi32:e,lo32:t-e*Ns}}function zs(t,e){return t*Ns+e}class $s extends As{constructor(t){super(8,t)}decode(t,e=0){const n=Is(t),r=n.readUInt32LE(e);return zs(n.readUInt32LE(e+4),r)}encode(t,e,n=0){const r=Us(t),i=Is(e);return i.writeUInt32LE(r.lo32,n),i.writeUInt32LE(r.hi32,n+4),8}}Ss.NearUInt64=$s;class Ws extends As{constructor(t){super(8,t)}decode(t,e=0){const n=Is(t);return zs(n.readUInt32BE(e),n.readUInt32BE(e+4))}encode(t,e,n=0){const r=Us(t),i=Is(e);return i.writeUInt32BE(r.hi32,n),i.writeUInt32BE(r.lo32,n+4),8}}Ss.NearUInt64BE=Ws;class Fs extends As{constructor(t){super(8,t)}decode(t,e=0){const n=Is(t),r=n.readUInt32LE(e);return zs(n.readInt32LE(e+4),r)}encode(t,e,n=0){const r=Us(t),i=Is(e);return i.writeUInt32LE(r.lo32,n),i.writeInt32LE(r.hi32,n+4),8}}Ss.NearInt64=Fs;class Ds extends As{constructor(t){super(8,t)}decode(t,e=0){const n=Is(t);return zs(n.readInt32BE(e),n.readUInt32BE(e+4))}encode(t,e,n=0){const r=Us(t),i=Is(e);return i.writeInt32BE(r.hi32,n),i.writeUInt32BE(r.lo32,n+4),8}}Ss.NearInt64BE=Ds;class js extends As{constructor(t){super(4,t)}decode(t,e=0){return Is(t).readFloatLE(e)}encode(t,e,n=0){return Is(e).writeFloatLE(t,n),4}}Ss.Float=js;class qs extends As{constructor(t){super(4,t)}decode(t,e=0){return Is(t).readFloatBE(e)}encode(t,e,n=0){return Is(e).writeFloatBE(t,n),4}}Ss.FloatBE=qs;class Ks extends As{constructor(t){super(8,t)}decode(t,e=0){return Is(t).readDoubleLE(e)}encode(t,e,n=0){return Is(e).writeDoubleLE(t,n),8}}Ss.Double=Ks;class Hs extends As{constructor(t){super(8,t)}decode(t,e=0){return Is(t).readDoubleBE(e)}encode(t,e,n=0){return Is(e).writeDoubleBE(t,n),8}}Ss.DoubleBE=Hs;class Vs extends As{constructor(t,e,n){if(!(t instanceof As))throw new TypeError("elementLayout must be a Layout");if(!(e instanceof Ps&&e.isCount()||Number.isInteger(e)&&0<=e))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let r=-1;!(e instanceof Ps)&&0<t.span&&(r=e*t.span),super(r,n),this.elementLayout=t,this.count=e}getSpan(t,e=0){if(0<=this.span)return this.span;let n=0,r=this.count;if(r instanceof Ps&&(r=r.decode(t,e)),0<this.elementLayout.span)n=r*this.elementLayout.span;else{let i=0;for(;i<r;)n+=this.elementLayout.getSpan(t,e+n),++i}return n}decode(t,e=0){const n=[];let r=0,i=this.count;for(i instanceof Ps&&(i=i.decode(t,e));r<i;)n.push(this.elementLayout.decode(t,e)),e+=this.elementLayout.getSpan(t,e),r+=1;return n}encode(t,e,n=0){const r=this.elementLayout,i=t.reduce(((t,i)=>t+r.encode(i,e,n+t)),0);return this.count instanceof Ps&&this.count.encode(t.length,e,n),i}}Ss.Sequence=Vs;class Gs extends As{constructor(t,e,n){if(!Array.isArray(t)||!t.reduce(((t,e)=>t&&e instanceof As),!0))throw new TypeError("fields must be array of Layout instances");"boolean"==typeof e&&void 0===n&&(n=e,e=void 0);for(const e of t)if(0>e.span&&void 0===e.property)throw new Error("fields cannot contain unnamed variable-length layout");let r=-1;try{r=t.reduce(((t,e)=>t+e.getSpan()),0)}catch(t){}super(r,e),this.fields=t,this.decodePrefixes=!!n}getSpan(t,e=0){if(0<=this.span)return this.span;let n=0;try{n=this.fields.reduce(((n,r)=>{const i=r.getSpan(t,e);return e+=i,n+i}),0)}catch(t){throw new RangeError("indeterminate span")}return n}decode(t,e=0){Es(t);const n=this.makeDestinationObject();for(const r of this.fields)if(void 0!==r.property&&(n[r.property]=r.decode(t,e)),e+=r.getSpan(t,e),this.decodePrefixes&&t.length===e)break;return n}encode(t,e,n=0){const r=n;let i=0,o=0;for(const r of this.fields){let s=r.span;if(o=0<s?s:0,void 0!==r.property){const i=t[r.property];void 0!==i&&(o=r.encode(i,e,n),0>s&&(s=r.getSpan(e,n)))}i=n,n+=s}return i+o-r}fromArray(t){const e=this.makeDestinationObject();for(const n of this.fields)void 0!==n.property&&0<t.length&&(e[n.property]=t.shift());return e}layoutFor(t){if("string"!=typeof t)throw new TypeError("property must be string");for(const e of this.fields)if(e.property===t)return e}offsetOf(t){if("string"!=typeof t)throw new TypeError("property must be string");let e=0;for(const n of this.fields){if(n.property===t)return e;0>n.span?e=-1:0<=e&&(e+=n.span)}}}Ss.Structure=Gs;class Js{constructor(t){this.property=t}decode(t,e){throw new Error("UnionDiscriminator is abstract")}encode(t,e,n){throw new Error("UnionDiscriminator is abstract")}}Ss.UnionDiscriminator=Js;class Zs extends Js{constructor(t,e){if(!(t instanceof Ps&&t.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(e||t.property||"variant"),this.layout=t}decode(t,e){return this.layout.decode(t,e)}encode(t,e,n){return this.layout.encode(t,e,n)}}Ss.UnionLayoutDiscriminator=Zs;class Ys extends As{constructor(t,e,n){let r;if(t instanceof Cs||t instanceof Os)r=new Zs(new Ms(t));else if(t instanceof Ps&&t.isCount())r=new Zs(t);else{if(!(t instanceof Js))throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");r=t}if(void 0===e&&(e=null),!(null===e||e instanceof As))throw new TypeError("defaultLayout must be null or a Layout");if(null!==e){if(0>e.span)throw new Error("defaultLayout must have constant span");void 0===e.property&&(e=e.replicate("content"))}let i=-1;e&&(i=e.span,0<=i&&(t instanceof Cs||t instanceof Os)&&(i+=r.layout.span)),super(i,n),this.discriminator=r,this.usesPrefixDiscriminator=t instanceof Cs||t instanceof Os,this.defaultLayout=e,this.registry={};let o=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(t){return o(t)},this.configGetSourceVariant=function(t){o=t.bind(this)}}getSpan(t,e=0){if(0<=this.span)return this.span;const n=this.getVariant(t,e);if(!n)throw new Error("unable to determine span for unrecognized variant");return n.getSpan(t,e)}defaultGetSourceVariant(t){if(Object.prototype.hasOwnProperty.call(t,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(t,this.defaultLayout.property))return;const e=this.registry[t[this.discriminator.property]];if(e&&(!e.layout||e.property&&Object.prototype.hasOwnProperty.call(t,e.property)))return e}else for(const e in this.registry){const n=this.registry[e];if(n.property&&Object.prototype.hasOwnProperty.call(t,n.property))return n}throw new Error("unable to infer src variant")}decode(t,e=0){let n;const r=this.discriminator,i=r.decode(t,e),o=this.registry[i];if(void 0===o){const o=this.defaultLayout;let s=0;this.usesPrefixDiscriminator&&(s=r.layout.span),n=this.makeDestinationObject(),n[r.property]=i,n[o.property]=o.decode(t,e+s)}else n=o.decode(t,e);return n}encode(t,e,n=0){const r=this.getSourceVariant(t);if(void 0===r){const r=this.discriminator,i=this.defaultLayout;let o=0;return this.usesPrefixDiscriminator&&(o=r.layout.span),r.encode(t[r.property],e,n),o+i.encode(t[i.property],e,n+o)}return r.encode(t,e,n)}addVariant(t,e,n){const r=new Xs(this,t,e,n);return this.registry[t]=r,r}getVariant(t,e=0){let n;return n=t instanceof Uint8Array?this.discriminator.decode(t,e):t,this.registry[n]}}Ss.Union=Ys;class Xs extends As{constructor(t,e,n,r){if(!(t instanceof Ys))throw new TypeError("union must be a Union");if(!Number.isInteger(e)||0>e)throw new TypeError("variant must be a (non-negative) integer");if("string"==typeof n&&void 0===r&&(r=n,n=null),n){if(!(n instanceof As))throw new TypeError("layout must be a Layout");if(null!==t.defaultLayout&&0<=n.span&&n.span>t.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if("string"!=typeof r)throw new TypeError("variant must have a String property")}let i=t.span;0>t.span&&(i=n?n.span:0,0<=i&&t.usesPrefixDiscriminator&&(i+=t.discriminator.layout.span)),super(i,r),this.union=t,this.variant=e,this.layout=n||null}getSpan(t,e=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(t,e+n)),n+r}decode(t,e=0){const n=this.makeDestinationObject();if(this!==this.union.getVariant(t,e))throw new Error("variant mismatch");let r=0;return this.union.usesPrefixDiscriminator&&(r=this.union.discriminator.layout.span),this.layout?n[this.property]=this.layout.decode(t,e+r):this.property?n[this.property]=!0:this.union.usesPrefixDiscriminator&&(n[this.union.discriminator.property]=this.variant),n}encode(t,e,n=0){let r=0;if(this.union.usesPrefixDiscriminator&&(r=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(t,this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,e,n);let i=r;if(this.layout&&(this.layout.encode(t[this.property],e,n+r),i+=this.layout.getSpan(e,n+r),0<=this.union.span&&i>this.union.span))throw new Error("encoded variant overruns containing union");return i}fromArray(t){if(this.layout)return this.layout.fromArray(t)}}function Qs(t){return 0>t&&(t+=4294967296),t}Ss.VariantLayout=Xs;class ta extends As{constructor(t,e,n){if(!(t instanceof Cs||t instanceof Os))throw new TypeError("word must be a UInt or UIntBE layout");if("string"==typeof e&&void 0===n&&(n=e,e=!1),4<t.span)throw new RangeError("word cannot exceed 32 bits");super(t.span,n),this.word=t,this.msb=!!e,this.fields=[];let r=0;this._packedSetValue=function(t){return r=Qs(t),this},this._packedGetValue=function(){return r}}decode(t,e=0){const n=this.makeDestinationObject(),r=this.word.decode(t,e);this._packedSetValue(r);for(const e of this.fields)void 0!==e.property&&(n[e.property]=e.decode(t));return n}encode(t,e,n=0){const r=this.word.decode(e,n);this._packedSetValue(r);for(const e of this.fields)if(void 0!==e.property){const n=t[e.property];void 0!==n&&e.encode(n)}return this.word.encode(this._packedGetValue(),e,n)}addField(t,e){const n=new ea(this,t,e);return this.fields.push(n),n}addBoolean(t){const e=new na(this,t);return this.fields.push(e),e}fieldFor(t){if("string"!=typeof t)throw new TypeError("property must be string");for(const e of this.fields)if(e.property===t)return e}}Ss.BitStructure=ta;class ea{constructor(t,e,n){if(!(t instanceof ta))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(e)||0>=e)throw new TypeError("bits must be positive integer");const r=8*t.span,i=t.fields.reduce(((t,e)=>t+e.bits),0);if(e+i>r)throw new Error("bits too long for span remainder ("+(r-i)+" of "+r+" remain)");this.container=t,this.bits=e,this.valueMask=(1<<e)-1,32===e&&(this.valueMask=4294967295),this.start=i,this.container.msb&&(this.start=r-i-e),this.wordMask=Qs(this.valueMask<<this.start),this.property=n}decode(t,e){return Qs(this.container._packedGetValue()&this.wordMask)>>>this.start}encode(t){if("number"!=typeof t||!Number.isInteger(t)||t!==Qs(t&this.valueMask))throw new TypeError(Bs("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const e=this.container._packedGetValue(),n=Qs(t<<this.start);this.container._packedSetValue(Qs(e&~this.wordMask)|n)}}Ss.BitField=ea;class na extends ea{constructor(t,e){super(t,1,e)}decode(t,e){return!!super.decode(t,e)}encode(t){"boolean"==typeof t&&(t=+t),super.encode(t)}}Ss.Boolean=na;class ra extends As{constructor(t,e){if(!(t instanceof Ps&&t.isCount()||Number.isInteger(t)&&0<=t))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let n=-1;t instanceof Ps||(n=t),super(n,e),this.length=t}getSpan(t,e){let n=this.span;return 0>n&&(n=this.length.decode(t,e)),n}decode(t,e=0){let n=this.span;return 0>n&&(n=this.length.decode(t,e)),Is(t).slice(e,e+n)}encode(t,e,n){let r=this.length;if(this.length instanceof Ps&&(r=t.length),!(t instanceof Uint8Array&&r===t.length))throw new TypeError(Bs("Blob.encode",this)+" requires (length "+r+") Uint8Array as src");if(n+r>e.length)throw new RangeError("encoding overruns Uint8Array");const i=Is(t);return Is(e).write(i.toString("hex"),n,r,"hex"),this.length instanceof Ps&&this.length.encode(r,e,n),r}}Ss.Blob=ra;class ia extends As{constructor(t){super(-1,t)}getSpan(t,e=0){Es(t);let n=e;for(;n<t.length&&0!==t[n];)n+=1;return 1+n-e}decode(t,e=0){const n=this.getSpan(t,e);return Is(t).slice(e,e+n-1).toString("utf-8")}encode(t,e,n=0){"string"!=typeof t&&(t=String(t));const r=xs.Buffer.from(t,"utf8"),i=r.length;if(n+i>e.length)throw new RangeError("encoding overruns Buffer");const o=Is(e);return r.copy(o,n),o[n+i]=0,i+1}}Ss.CString=ia;class oa extends As{constructor(t,e){if("string"==typeof t&&void 0===e&&(e=t,t=void 0),void 0===t)t=-1;else if(!Number.isInteger(t))throw new TypeError("maxSpan must be an integer");super(-1,e),this.maxSpan=t}getSpan(t,e=0){return Es(t),t.length-e}decode(t,e=0){const n=this.getSpan(t,e);if(0<=this.maxSpan&&this.maxSpan<n)throw new RangeError("text length exceeds maxSpan");return Is(t).slice(e,e+n).toString("utf-8")}encode(t,e,n=0){"string"!=typeof t&&(t=String(t));const r=xs.Buffer.from(t,"utf8"),i=r.length;if(0<=this.maxSpan&&this.maxSpan<i)throw new RangeError("text length exceeds maxSpan");if(n+i>e.length)throw new RangeError("encoding overruns Buffer");return r.copy(Is(e),n),i}}Ss.UTF8=oa;class sa extends As{constructor(t,e){super(0,e),this.value=t}decode(t,e){return this.value}encode(t,e,n){return 0}}Ss.Constant=sa,Ss.greedy=(t,e)=>new Ts(t,e);var aa=Ss.offset=(t,e,n)=>new Ms(t,e,n),ca=Ss.u8=t=>new Cs(1,t),ua=Ss.u16=t=>new Cs(2,t);Ss.u24=t=>new Cs(3,t);var la=Ss.u32=t=>new Cs(4,t);Ss.u40=t=>new Cs(5,t),Ss.u48=t=>new Cs(6,t);var ha=Ss.nu64=t=>new $s(t);Ss.u16be=t=>new Os(2,t),Ss.u24be=t=>new Os(3,t),Ss.u32be=t=>new Os(4,t),Ss.u40be=t=>new Os(5,t),Ss.u48be=t=>new Os(6,t),Ss.nu64be=t=>new Ws(t),Ss.s8=t=>new Rs(1,t),Ss.s16=t=>new Rs(2,t),Ss.s24=t=>new Rs(3,t),Ss.s32=t=>new Rs(4,t),Ss.s40=t=>new Rs(5,t),Ss.s48=t=>new Rs(6,t);var da=Ss.ns64=t=>new Fs(t);Ss.s16be=t=>new Ls(2,t),Ss.s24be=t=>new Ls(3,t),Ss.s32be=t=>new Ls(4,t),Ss.s40be=t=>new Ls(5,t),Ss.s48be=t=>new Ls(6,t),Ss.ns64be=t=>new Ds(t),Ss.f32=t=>new js(t),Ss.f32be=t=>new qs(t),Ss.f64=t=>new Ks(t),Ss.f64be=t=>new Hs(t);var fa=Ss.struct=(t,e,n)=>new Gs(t,e,n);Ss.bits=(t,e,n)=>new ta(t,e,n);var pa=Ss.seq=(t,e,n)=>new Vs(t,e,n);Ss.union=(t,e,n)=>new Ys(t,e,n),Ss.unionLayoutDiscriminator=(t,e)=>new Zs(t,e);var ga=Ss.blob=(t,e)=>new ra(t,e);Ss.cstr=t=>new ia(t),Ss.utf8=(t,e)=>new oa(t,e),Ss.constant=(t,e)=>new sa(t,e);var ma,ya,ba={exports:{}},wa=ba.exports={};function va(){throw new Error("setTimeout has not been defined")}function _a(){throw new Error("clearTimeout has not been defined")}function ka(t){if(ma===setTimeout)return setTimeout(t,0);if((ma===va||!ma)&&setTimeout)return ma=setTimeout,setTimeout(t,0);try{return ma(t,0)}catch(e){try{return ma.call(null,t,0)}catch(e){return ma.call(this,t,0)}}}!function(){try{ma="function"==typeof setTimeout?setTimeout:va}catch(t){ma=va}try{ya="function"==typeof clearTimeout?clearTimeout:_a}catch(t){ya=_a}}();var Sa,xa=[],Ea=!1,Ia=-1;function Aa(){Ea&&Sa&&(Ea=!1,Sa.length?xa=Sa.concat(xa):Ia=-1,xa.length&&Ba())}function Ba(){if(!Ea){var t=ka(Aa);Ea=!0;for(var e=xa.length;e;){for(Sa=xa,xa=[];++Ia<e;)Sa&&Sa[Ia].run();Ia=-1,e=xa.length}Sa=null,Ea=!1,function(t){if(ya===clearTimeout)return clearTimeout(t);if((ya===_a||!ya)&&clearTimeout)return ya=clearTimeout,clearTimeout(t);try{return ya(t)}catch(e){try{return ya.call(null,t)}catch(e){return ya.call(this,t)}}}(t)}}function Pa(t,e){this.fun=t,this.array=e}function Ta(){}wa.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];xa.push(new Pa(t,e)),1!==xa.length||Ea||ka(Ba)},Pa.prototype.run=function(){this.fun.apply(null,this.array)},wa.title="browser",wa.browser=!0,wa.env={},wa.argv=[],wa.version="",wa.versions={},wa.on=Ta,wa.addListener=Ta,wa.once=Ta,wa.off=Ta,wa.removeListener=Ta,wa.removeAllListeners=Ta,wa.emit=Ta,wa.prependListener=Ta,wa.prependOnceListener=Ta,wa.listeners=function(t){return[]},wa.binding=function(t){throw new Error("process.binding is not supported")},wa.cwd=function(){return"/"},wa.chdir=function(t){throw new Error("process.chdir is not supported")},wa.umask=function(){return 0};var Ma=1,Ca=2,Oa=3,Ra=4,La=5,Na=6,Ua=7,za=8,$a=9,Wa=10,Fa=-32700,Da=-32603,ja=-32602,qa=-32601,Ka=-32600,Ha=-32016,Va=-32015,Ga=-32014,Ja=-32013,Za=-32012,Ya=-32011,Xa=-32010,Qa=-32009,tc=-32008,ec=-32007,nc=-32006,rc=-32005,ic=-32004,oc=-32003,sc=-32002,ac=-32001,cc=28e5,uc=2800001,lc=2800002,hc=2800003,dc=2800004,fc=2800005,pc=2800006,gc=2800007,mc=2800008,yc=2800009,bc=2800010,wc=323e4,vc=32300001,_c=3230002,kc=3230003,Sc=3230004,xc=361e4,Ec=3610001,Ic=3610002,Ac=3610003,Bc=3610004,Pc=3610005,Tc=3610006,Mc=3610007,Cc=3611e3,Oc=3704e3,Rc=3704001,Lc=3704002,Nc=3704003,Uc=3704004,zc=4128e3,$c=4128001,Wc=4128002,Fc=4615e3,Dc=4615001,jc=4615002,qc=4615003,Kc=4615004,Hc=4615005,Vc=4615006,Gc=4615007,Jc=4615008,Zc=4615009,Yc=4615010,Xc=4615011,Qc=4615012,tu=4615013,eu=4615014,nu=4615015,ru=4615016,iu=4615017,ou=4615018,su=4615019,au=4615020,cu=4615021,uu=4615022,lu=4615023,hu=4615024,du=4615025,fu=4615026,pu=4615027,gu=4615028,mu=4615029,yu=4615030,bu=4615031,wu=4615032,vu=4615033,_u=4615034,ku=4615035,Su=4615036,xu=4615037,Eu=4615038,Iu=4615039,Au=4615040,Bu=4615041,Pu=4615042,Tu=4615043,Mu=4615044,Cu=4615045,Ou=4615046,Ru=4615047,Lu=4615048,Nu=4615049,Uu=4615050,zu=4615051,$u=4615052,Wu=4615053,Fu=4615054,Du=5508e3,ju=5508001,qu=5508002,Ku=5508003,Hu=5508004,Vu=5508005,Gu=5508006,Ju=5508007,Zu=5508008,Yu=5508009,Xu=5508010,Qu=5508011,tl=5663e3,el=5663001,nl=5663002,rl=5663003,il=5663004,ol=5663005,sl=5663006,al=5663007,cl=5663008,ul=5663009,ll=5663010,hl=5663011,dl=5663012,fl=5663013,pl=5663014,gl=5663015,ml=5663016,yl=5663017,bl=5663018,wl=5663019,vl=705e4,_l=7050001,kl=7050002,Sl=7050003,xl=7050004,El=7050005,Il=7050006,Al=7050007,Bl=7050008,Pl=7050009,Tl=7050010,Ml=7050011,Cl=7050012,Ol=7050013,Rl=7050014,Ll=7050015,Nl=7050016,Ul=7050017,zl=7050018,$l=7050019,Wl=7050020,Fl=7050021,Dl=7050022,jl=7050023,ql=7050024,Kl=7050025,Hl=7050026,Vl=7050027,Gl=7050028,Jl=7050029,Zl=7050030,Yl=7050031,Xl=7050032,Ql=7050033,th=7050034,eh=7050035,nh=7050036,rh=8078e3,ih=8078001,oh=8078002,sh=8078003,ah=8078004,ch=8078005,uh=8078006,lh=8078007,hh=8078008,dh=8078009,fh=8078010,ph=8078011,gh=8078012,mh=8078013,yh=8078014,bh=8078015,wh=8078016,vh=8078017,_h=8078018,kh=8078019,Sh=8078020,xh=8078021,Eh=8078022,Ih=81e5,Ah=8100001,Bh=8100002,Ph=8100003,Th=819e4,Mh=8190001,Ch=8190002,Oh=8190003,Rh=8190004,Lh=99e5,Nh=9900001,Uh=9900002,zh=9900003,$h=9900004;function Wh(t){if(Array.isArray(t)){return"%5B"+t.map(Wh).join("%2C%20")+"%5D"}return"bigint"==typeof t?`${t}n`:encodeURIComponent(String(null!=t&&null===Object.getPrototypeOf(t)?{...t}:t))}function Fh([t,e]){return`${t}=${Wh(e)}`}var Dh={[wc]:"Account not found at address: $address",[Sc]:"Not all accounts were decoded. Encoded accounts found at addresses: $addresses.",[kc]:"Expected decoded account at address: $address",[_c]:"Failed to decode account data at address: $address",[vc]:"Accounts not found at addresses: $addresses",[yc]:"Unable to find a viable program address bump seed.",[lc]:"$putativeAddress is not a base58-encoded address.",[cc]:"Expected base58 encoded address to decode to a byte array of length 32. Actual length: $actualLength.",[hc]:"The `CryptoKey` must be an `Ed25519` public key.",[mc]:"Invalid seeds; point must fall off the Ed25519 curve.",[dc]:"Expected given program derived address to have the following format: [Address, ProgramDerivedAddressBump].",[pc]:"A maximum of $maxSeeds seeds, including the bump seed, may be supplied when creating an address. Received: $actual.",[gc]:"The seed at index $index with length $actual exceeds the maximum length of $maxSeedLength bytes.",[fc]:"Expected program derived address bump to be in the range [0, 255], got: $bump.",[bc]:"Program address cannot end with PDA marker.",[uc]:"Expected base58-encoded address string of length in the range [32, 44]. Actual length: $actualLength.",[Ra]:"Expected base58-encoded blockash string of length in the range [32, 44]. Actual length: $actualLength.",[Ma]:"The network has progressed past the last block for which this transaction could have been committed.",[rh]:"Codec [$codecDescription] cannot decode empty byte arrays.",[Eh]:"Enum codec cannot use lexical values [$stringValues] as discriminators. Either remove all lexical values or set `useValuesAsDiscriminators` to `false`.",[Sh]:"Sentinel [$hexSentinel] must not be present in encoded bytes [$hexEncodedBytes].",[ch]:"Encoder and decoder must have the same fixed size, got [$encoderFixedSize] and [$decoderFixedSize].",[uh]:"Encoder and decoder must have the same max size, got [$encoderMaxSize] and [$decoderMaxSize].",[ah]:"Encoder and decoder must either both be fixed-size or variable-size.",[hh]:"Enum discriminator out of range. Expected a number in [$formattedValidDiscriminators], got $discriminator.",[oh]:"Expected a fixed-size codec, got a variable-size one.",[mh]:"Codec [$codecDescription] expected a positive byte length, got $bytesLength.",[sh]:"Expected a variable-size codec, got a fixed-size one.",[kh]:"Codec [$codecDescription] expected zero-value [$hexZeroValue] to have the same size as the provided fixed-size item [$expectedSize bytes].",[ih]:"Codec [$codecDescription] expected $expected bytes, got $bytesLength.",[_h]:"Expected byte array constant [$hexConstant] to be present in data [$hexData] at offset [$offset].",[dh]:"Invalid discriminated union variant. Expected one of [$variants], got $value.",[fh]:"Invalid enum variant. Expected one of [$stringValues] or a number in [$formattedNumericalValues], got $variant.",[bh]:"Invalid literal union variant. Expected one of [$variants], got $value.",[lh]:"Expected [$codecDescription] to have $expected items, got $actual.",[gh]:"Invalid value $value for base $base with alphabet $alphabet.",[wh]:"Literal union discriminator out of range. Expected a number between $minRange and $maxRange, got $discriminator.",[ph]:"Codec [$codecDescription] expected number to be in the range [$min, $max], got $value.",[yh]:"Codec [$codecDescription] expected offset to be in the range [0, $bytesLength], got $offset.",[xh]:"Expected sentinel [$hexSentinel] to be present in decoded bytes [$hexDecodedBytes].",[vh]:"Union variant out of range. Expected an index between $minRange and $maxRange, got $variant.",[Cc]:"No random values implementation could be found.",[Zc]:"instruction requires an uninitialized account",[lu]:"instruction tries to borrow reference for an account which is already borrowed",[hu]:"instruction left account with an outstanding borrowed reference",[cu]:"program other than the account's owner changed the size of the account data",[Hc]:"account data too small for instruction",[uu]:"instruction expected an executable account",[Ou]:"An account does not have enough lamports to be rent-exempt",[Lu]:"Program arithmetic overflowed",[Cu]:"Failed to serialize or deserialize account data: $encodedData",[Fu]:"Builtin programs must consume compute units",[wu]:"Cross-program invocation call depth too deep",[Eu]:"Computational budget exceeded",[fu]:"custom program error: #$code",[iu]:"instruction contains duplicate accounts",[du]:"instruction modifications of multiply-passed account differ",[yu]:"executable accounts must be rent exempt",[gu]:"instruction changed executable accounts data",[mu]:"instruction changed the balance of an executable account",[ou]:"instruction changed executable bit of an account",[eu]:"instruction modified data of an account it does not own",[tu]:"instruction spent from the balance of an account it does not own",[Dc]:"generic instruction error",[Uu]:"Provided owner is not allowed",[Tu]:"Account is immutable",[Mu]:"Incorrect authority provided",[Gc]:"incorrect program id for instruction",[Vc]:"insufficient funds for instruction",[Kc]:"invalid account data for instruction",[Ru]:"Invalid account owner",[jc]:"invalid program argument",[pu]:"program returned invalid error code",[qc]:"invalid instruction data",[xu]:"Failed to reallocate account data",[Su]:"Provided seeds do not result in a valid address",[zu]:"Accounts data allocations exceeded the maximum allowed per transaction",[$u]:"Max accounts exceeded",[Wu]:"Max instruction trace length exceeded",[ku]:"Length of the seed is too long for address generation",[vu]:"An account required by the instruction is missing",[Jc]:"missing required signature for instruction",[Qc]:"instruction illegally modified the program id of an account",[au]:"insufficient account keys for instruction",[Iu]:"Cross-program invocation with unauthorized signer or writable account",[Au]:"Failed to create program execution environment",[Pu]:"Program failed to compile",[Bu]:"Program failed to complete",[ru]:"instruction modified data of a read-only account",[nu]:"instruction changed the balance of a read-only account",[_u]:"Cross-program invocation reentrancy not allowed for this instruction",[su]:"instruction modified rent epoch of an account",[Xc]:"sum of account balances before and after instruction do not match",[Yc]:"instruction requires an initialized account",[Fc]:"",[bu]:"Unsupported program id",[Nu]:"Unsupported sysvar",[zc]:"The instruction does not have any accounts.",[$c]:"The instruction does not have any data.",[Wc]:"Expected instruction to have progress address $expectedProgramAddress, got $actualProgramAddress.",[La]:"Expected base58 encoded blockhash to decode to a byte array of length 32. Actual length: $actualLength.",[Ca]:"The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",[Uh]:"Invariant violation: Found no abortable iterable cache entry for key `$cacheKey`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[$h]:"Invariant violation: This data publisher does not publish to the channel named `$channelName`. Supported channels include $supportedChannelNames.",[Nh]:"Invariant violation: WebSocket message iterator state is corrupt; iterated without first resolving existing message promise. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[Lh]:"Invariant violation: WebSocket message iterator is missing state storage. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[zh]:"Invariant violation: Switch statement non-exhaustive. Received unexpected value `$unexpectedValue`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[Da]:"JSON-RPC error: Internal JSON-RPC error ($__serverMessage)",[ja]:"JSON-RPC error: Invalid method parameter(s) ($__serverMessage)",[Ka]:"JSON-RPC error: The JSON sent is not a valid `Request` object ($__serverMessage)",[qa]:"JSON-RPC error: The method does not exist / is not available ($__serverMessage)",[Fa]:"JSON-RPC error: An error occurred on the server while parsing the JSON text ($__serverMessage)",[Za]:"$__serverMessage",[ac]:"$__serverMessage",[ic]:"$__serverMessage",[Ga]:"$__serverMessage",[Xa]:"$__serverMessage",[Qa]:"$__serverMessage",[Ha]:"Minimum context slot has not been reached",[rc]:"Node is unhealthy; behind by $numSlotsBehind slots",[tc]:"No snapshot",[sc]:"Transaction simulation failed",[ec]:"$__serverMessage",[Ya]:"Transaction history is not available from this node",[nc]:"$__serverMessage",[Ja]:"Transaction signature length mismatch",[oc]:"Transaction signature verification failure",[Va]:"$__serverMessage",[Oc]:"Key pair bytes must be of length 64, got $byteLength.",[Rc]:"Expected private key bytes with length 32. Actual length: $actualLength.",[Lc]:"Expected base58-encoded signature to decode to a byte array of length 64. Actual length: $actualLength.",[Uc]:"The provided private key does not match the provided public key.",[Nc]:"Expected base58-encoded signature string of length in the range [64, 88]. Actual length: $actualLength.",[Na]:"Lamports value must be in the range [0, 2e64-1]",[Ua]:"`$value` cannot be parsed as a `BigInt`",[Wa]:"$message",[za]:"`$value` cannot be parsed as a `Number`",[Oa]:"No nonce account could be found at address `$nonceAccountAddress`",[Th]:"The notification name must end in 'Notifications' and the API must supply a subscription plan creator function for the notification '$notificationName'.",[Ch]:"WebSocket was closed before payload could be added to the send buffer",[Oh]:"WebSocket connection closed",[Rh]:"WebSocket failed to connect",[Mh]:"Failed to obtain a subscription id from the server",[Ph]:"Could not find an API plan for RPC method: `$method`",[Ih]:"The $argumentLabel argument to the `$methodName` RPC method$optionalPathLabel was `$value`. This number is unsafe for use with the Solana JSON-RPC because it exceeds `Number.MAX_SAFE_INTEGER`.",[Bh]:"HTTP error ($statusCode): $message",[Ah]:"HTTP header(s) forbidden: $headers. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.",[Du]:"Multiple distinct signers were identified for address `$address`. Please ensure that you are using the same signer instance for each address.",[ju]:"The provided value does not implement the `KeyPairSigner` interface",[Ku]:"The provided value does not implement the `MessageModifyingSigner` interface",[Hu]:"The provided value does not implement the `MessagePartialSigner` interface",[qu]:"The provided value does not implement any of the `MessageSigner` interfaces",[Gu]:"The provided value does not implement the `TransactionModifyingSigner` interface",[Ju]:"The provided value does not implement the `TransactionPartialSigner` interface",[Zu]:"The provided value does not implement the `TransactionSendingSigner` interface",[Vu]:"The provided value does not implement any of the `TransactionSigner` interfaces",[Yu]:"More than one `TransactionSendingSigner` was identified.",[Xu]:"No `TransactionSendingSigner` was identified. Please provide a valid `ITransactionWithSingleSendingSigner` transaction.",[Qu]:"Wallet account signers do not support signing multiple messages/transactions in a single operation",[Mc]:"Cannot export a non-extractable key.",[Ec]:"No digest implementation could be found.",[xc]:"Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts.",[Ic]:"This runtime does not support the generation of Ed25519 key pairs.\n\nInstall @solana/webcrypto-ed25519-polyfill and call its `install` function before generating keys in environments that do not support Ed25519.\n\nFor a list of runtimes that currently support Ed25519 operations, visit https://github.com/WICG/webcrypto-secure-curves/issues/20.",[Ac]:"No signature verification implementation could be found.",[Bc]:"No key generation implementation could be found.",[Pc]:"No signing implementation could be found.",[Tc]:"No key export implementation could be found.",[$a]:"Timestamp value must be in the range [-(2n ** 63n), (2n ** 63n) - 1]. `$value` given",[Nl]:"Transaction processing left an account with an outstanding borrowed reference",[_l]:"Account in use",[kl]:"Account loaded twice",[Sl]:"Attempt to debit an account but found no record of a prior credit.",[jl]:"Transaction loads an address table account that doesn't exist",[Al]:"This transaction has already been processed",[Bl]:"Blockhash not found",[Pl]:"Loader call chain is too deep",[Ll]:"Transactions are currently disabled due to cluster maintenance",[Zl]:"Transaction contains a duplicate instruction ($index) that is not allowed",[El]:"Insufficient funds for fee",[Yl]:"Transaction results in an account ($accountIndex) with insufficient funds for rent",[Il]:"This account may not be used to pay transaction fees",[Ml]:"Transaction contains an invalid account reference",[Kl]:"Transaction loads an address table account with invalid data",[Hl]:"Transaction address table lookup uses an invalid index",[ql]:"Transaction loads an address table account with an invalid owner",[Ql]:"LoadedAccountsDataSizeLimit set for transaction must be greater than 0.",[Ol]:"This program may not be used for executing instructions",[Vl]:"Transaction leaves an account with a lower balance than rent-exempt minimum",[$l]:"Transaction loads a writable account that cannot be written",[Xl]:"Transaction exceeded max loaded accounts data size cap",[Tl]:"Transaction requires a fee but has no signature present",[xl]:"Attempt to load a program that does not exist",[eh]:"Execution of the program referenced by account at index $accountIndex is temporarily restricted.",[th]:"ResanitizationNeeded",[Rl]:"Transaction failed to sanitize accounts offsets correctly",[Cl]:"Transaction did not pass signature verification",[Dl]:"Transaction locked too many accounts",[nh]:"Sum of account balances before and after transaction do not match",[vl]:"The transaction failed with the error `$errorName`",[zl]:"Transaction version is unsupported",[Fl]:"Transaction would exceed account data limit within the block",[Jl]:"Transaction would exceed total account data limit",[Wl]:"Transaction would exceed max account limit within the block",[Ul]:"Transaction would exceed max Block Cost Limit",[Gl]:"Transaction would exceed max Vote Cost Limit",[gl]:"Attempted to sign a transaction with an address that is not a signer for it",[ll]:"Transaction is missing an address at index: $index.",[ml]:"Transaction has no expected signers therefore it cannot be encoded",[nl]:"Transaction does not have a blockhash lifetime",[rl]:"Transaction is not a durable nonce transaction",[ol]:"Contents of these address lookup tables unknown: $lookupTableAddresses",[sl]:"Lookup of address at index $highestRequestedIndex failed for lookup table `$lookupTableAddress`. Highest known index is $highestKnownIndex. The lookup table may have been extended since its contents were retrieved",[cl]:"No fee payer set in CompiledTransaction",[al]:"Could not find program address at index $index",[bl]:"Failed to estimate the compute unit consumption for this transaction message. This is likely because simulating the transaction failed. Inspect the `cause` property of this error to learn more",[wl]:"Transaction failed when it was simulated in order to estimate the compute unit consumption. The compute unit estimate provided is for a transaction that failed when simulated and may not be representative of the compute units this transaction would consume if successful. Inspect the `cause` property of this error to learn more",[hl]:"Transaction is missing a fee payer.",[dl]:"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer.",[pl]:"Transaction first instruction is not advance nonce account instruction.",[fl]:"Transaction with no instructions cannot be durable nonce transaction.",[tl]:"This transaction includes an address (`$programAddress`) which is both invoked and set as the fee payer. Program addresses may not pay fees",[el]:"This transaction includes an address (`$programAddress`) which is both invoked and marked writable. Program addresses may not be writable",[yl]:"The transaction message expected the transaction to have $signerAddressesLength signatures, got $signaturesLength.",[ul]:"Transaction is missing signatures for addresses: $addresses.",[il]:"Transaction version must be in the range [0, 127]. `$actualVersion` given"},jh="i",qh="t";function Kh(t,e={}){if("production"!==ba.exports.env.NODE_ENV)return function(t,e={}){const n=Dh[t];if(0===n.length)return"";let r;function i(t){if(2===r[qh]){const i=n.slice(r[jh]+1,t);o.push(i in e?`${e[i]}`:`$${i}`)}else 1===r[qh]&&o.push(n.slice(r[jh],t))}const o=[];return n.split("").forEach(((t,e)=>{if(0===e)return void(r={[jh]:0,[qh]:"\\"===n[0]?0:"$"===n[0]?2:1});let o;switch(r[qh]){case 0:o={[jh]:e,[qh]:1};break;case 1:"\\"===t?o={[jh]:e,[qh]:0}:"$"===t&&(o={[jh]:e,[qh]:2});break;case 2:"\\"===t?o={[jh]:e,[qh]:0}:"$"===t?o={[jh]:e,[qh]:2}:t.match(/\w/)||(o={[jh]:e,[qh]:1})}o&&(r!==o&&i(e),r=o)})),i(),o.join("")}(t,e);{let n=`Solana error #${t}; Decode this error by running \`npx @solana/errors decode -- ${t}`;return Object.keys(e).length&&(n+=` '${function(t){const e=Object.entries(t).map(Fh).join("&");return btoa(e)}(e)}'`),`${n}\``}}var Hh=class extends Error{cause=this.cause;context;constructor(...[t,e]){let n,r;if(e){const{cause:t,...i}=e;t&&(r={cause:t}),Object.keys(i).length>0&&(n=i)}super(Kh(t,n),r),this.context={__code:t,...n},this.name="SolanaError"}};function Vh(t){return"fixedSize"in t&&"number"==typeof t.fixedSize}function Gh(t){return 1!==t?.endian}function Jh(t){return e={fixedSize:t.size,write(e,n,r){t.range&&function(t,e,n,r){if(r<e||r>n)throw new Hh(ph,{codecDescription:t,max:n,min:e,value:r})}(t.name,t.range[0],t.range[1],e);const i=new ArrayBuffer(t.size);return t.set(new DataView(i),e,Gh(t.config)),n.set(new Uint8Array(i),r),r+t.size}},Object.freeze({...e,encode:t=>{const n=new Uint8Array(function(t,e){return"fixedSize"in e?e.fixedSize:e.getSizeFromValue(t)}(t,e));return e.write(t,n,0),n}});var e}function Zh(t){return e={fixedSize:t.size,read(e,n=0){!function(t,e,n=0){if(e.length-n<=0)throw new Hh(rh,{codecDescription:t})}(t.name,e,n),function(t,e,n,r=0){const i=n.length-r;if(i<e)throw new Hh(ih,{bytesLength:i,codecDescription:t,expected:e})}(t.name,t.size,e,n);const r=new DataView(function(t,e,n){const r=t.byteOffset+(e??0),i=n??t.byteLength;return t.buffer.slice(r,r+i)}(e,n,t.size));return[t.get(r,Gh(t.config)),n+t.size]}},Object.freeze({...e,decode:(t,n=0)=>e.read(t,n)[0]});var e}var Yh,Xh=(t={})=>Jh({config:t,name:"u64",range:[0n,BigInt("0xffffffffffffffff")],set:(t,e,n)=>t.setBigUint64(0,BigInt(e),n),size:8}),Qh=(t={})=>function(t,e){if(Vh(t)!==Vh(e))throw new Hh(ah);if(Vh(t)&&Vh(e)&&t.fixedSize!==e.fixedSize)throw new Hh(ch,{decoderFixedSize:e.fixedSize,encoderFixedSize:t.fixedSize});if(!Vh(t)&&!Vh(e)&&t.maxSize!==e.maxSize)throw new Hh(uh,{decoderMaxSize:e.maxSize,encoderMaxSize:t.maxSize});return{...e,...t,decode:e.decode,encode:t.encode,read:e.read,write:t.write}}(Xh(t),((t={})=>Zh({config:t,get:(t,e)=>t.getBigUint64(0,e),name:"u64",size:8}))(t));class td extends TypeError{constructor(t,e){let n;const{message:r,explanation:i,...o}=t,{path:s}=t,a=0===s.length?r:`At path: ${s.join(".")} -- ${r}`;super(i??a),null!=i&&(this.cause=a),Object.assign(this,o),this.name=this.constructor.name,this.failures=()=>n??(n=[t,...e()])}}function ed(t){return"object"==typeof t&&null!=t}function nd(t){return ed(t)&&!Array.isArray(t)}function rd(t){return"symbol"==typeof t?t.toString():"string"==typeof t?JSON.stringify(t):`${t}`}function id(t,e,n,r){if(!0===t)return;!1===t?t={}:"string"==typeof t&&(t={message:t});const{path:i,branch:o}=e,{type:s}=n,{refinement:a,message:c=`Expected a value of type \`${s}\`${a?` with refinement \`${a}\``:""}, but received: \`${rd(r)}\``}=t;return{value:r,type:s,refinement:a,key:i[i.length-1],path:i,branch:o,...t,message:c}}function*od(t,e,n,r){(function(t){return ed(t)&&"function"==typeof t[Symbol.iterator]})(t)||(t=[t]);for(const i of t){const t=id(i,e,n,r);t&&(yield t)}}function*sd(t,e,n={}){const{path:r=[],branch:i=[t],coerce:o=!1,mask:s=!1}=n,a={path:r,branch:i,mask:s};o&&(t=e.coercer(t,a));let c="valid";for(const r of e.validator(t,a))r.explanation=n.message,c="not_valid",yield[r,void 0];for(let[u,l,h]of e.entries(t,a)){const e=sd(l,h,{path:void 0===u?r:[...r,u],branch:void 0===u?i:[...i,l],coerce:o,mask:s,message:n.message});for(const n of e)n[0]?(c=null!=n[0].refinement?"not_refined":"not_valid",yield[n[0],void 0]):o&&(l=n[1],void 0===u?t=l:t instanceof Map?t.set(u,l):t instanceof Set?t.add(l):ed(t)&&(void 0!==l||u in t)&&(t[u]=l))}if("not_valid"!==c)for(const r of e.refiner(t,a))r.explanation=n.message,c="not_refined",yield[r,void 0];"valid"===c&&(yield[void 0,t])}class ad{constructor(t){const{type:e,schema:n,validator:r,refiner:i,coercer:o=(t=>t),entries:s=function*(){}}=t;this.type=e,this.schema=n,this.entries=s,this.coercer=o,this.validator=r?(t,e)=>od(r(t,e),e,this,t):()=>[],this.refiner=i?(t,e)=>od(i(t,e),e,this,t):()=>[]}assert(t,e){return cd(t,this,e)}create(t,e){return ud(t,this,e)}is(t){return ld(t,this)}mask(t,e){return function(t,e,n){const r=hd(t,e,{coerce:!0,mask:!0,message:n});if(r[0])throw r[0];return r[1]}(t,this,e)}validate(t,e={}){return hd(t,this,e)}}function cd(t,e,n){const r=hd(t,e,{message:n});if(r[0])throw r[0]}function ud(t,e,n){const r=hd(t,e,{coerce:!0,message:n});if(r[0])throw r[0];return r[1]}function ld(t,e){return!hd(t,e)[0]}function hd(t,e,n={}){const r=sd(t,e,n),i=function(t){const{done:e,value:n}=t.next();return e?void 0:n}(r);if(i[0]){const t=new td(i[0],(function*(){for(const t of r)t[0]&&(yield t[0])}));return[t,void 0]}return[void 0,i[1]]}function dd(t,e){return new ad({type:t,schema:null,validator:e})}function fd(t){return new ad({type:"array",schema:t,*entries(e){if(t&&Array.isArray(e))for(const[n,r]of e.entries())yield[n,r,t]},coercer:t=>Array.isArray(t)?t.slice():t,validator:t=>Array.isArray(t)||`Expected an array value, but received: ${rd(t)}`})}function pd(){return dd("boolean",(t=>"boolean"==typeof t))}function gd(t){return dd("instance",(e=>e instanceof t||`Expected a \`${t.name}\` instance, but received: ${rd(e)}`))}function md(t){const e=rd(t),n=typeof t;return new ad({type:"literal",schema:"string"===n||"number"===n||"boolean"===n?t:null,validator:n=>n===t||`Expected the literal \`${e}\`, but received: ${rd(n)}`})}function yd(t){return new ad({...t,validator:(e,n)=>null===e||t.validator(e,n),refiner:(e,n)=>null===e||t.refiner(e,n)})}function bd(){return dd("number",(t=>"number"==typeof t&&!isNaN(t)||`Expected a number, but received: ${rd(t)}`))}function wd(t){return new ad({...t,validator:(e,n)=>void 0===e||t.validator(e,n),refiner:(e,n)=>void 0===e||t.refiner(e,n)})}function vd(t,e){return new ad({type:"record",schema:null,*entries(n){if(ed(n))for(const r in n){const i=n[r];yield[r,r,t],yield[r,i,e]}},validator:t=>nd(t)||`Expected an object, but received: ${rd(t)}`,coercer:t=>nd(t)?{...t}:t})}function _d(){return dd("string",(t=>"string"==typeof t||`Expected a string, but received: ${rd(t)}`))}function kd(t){const e=dd("never",(()=>!1));return new ad({type:"tuple",schema:null,*entries(n){if(Array.isArray(n)){const r=Math.max(t.length,n.length);for(let i=0;i<r;i++)yield[i,n[i],t[i]||e]}},validator:t=>Array.isArray(t)||`Expected an array, but received: ${rd(t)}`,coercer:t=>Array.isArray(t)?t.slice():t})}function Sd(t){const e=Object.keys(t);return new ad({type:"type",schema:t,*entries(n){if(ed(n))for(const r of e)yield[r,n[r],t[r]]},validator:t=>nd(t)||`Expected an object, but received: ${rd(t)}`,coercer:t=>nd(t)?{...t}:t})}function xd(t){const e=t.map((t=>t.type)).join(" | ");return new ad({type:"union",schema:null,coercer(e,n){for(const r of t){const[t,i]=r.validate(e,{coerce:!0,mask:n.mask});if(!t)return i}return e},validator(n,r){const i=[];for(const e of t){const[...t]=sd(n,e,r),[o]=t;if(!o[0])return[];for(const[e]of t)e&&i.push(e)}return[`Expected the value to satisfy a union of \`${e}\`, but received: ${rd(n)}`,...i]}})}function Ed(){return dd("unknown",(()=>!0))}function Id(t,e,n){return new ad({...t,coercer:(r,i)=>ld(r,e)?t.coercer(n(r,i),i):t.coercer(r,i)})}var Ad=new Uint8Array(16);function Bd(){if(!Yh&&!(Yh="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Yh(Ad)}var Pd=/^(?:[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 Td(t){return"string"==typeof t&&Pd.test(t)}for(var Md,Cd,Od=[],Rd=0;Rd<256;++Rd)Od.push((Rd+256).toString(16).substr(1));function Ld(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(Od[t[e+0]]+Od[t[e+1]]+Od[t[e+2]]+Od[t[e+3]]+"-"+Od[t[e+4]]+Od[t[e+5]]+"-"+Od[t[e+6]]+Od[t[e+7]]+"-"+Od[t[e+8]]+Od[t[e+9]]+"-"+Od[t[e+10]]+Od[t[e+11]]+Od[t[e+12]]+Od[t[e+13]]+Od[t[e+14]]+Od[t[e+15]]).toLowerCase();if(!Td(n))throw TypeError("Stringified UUID is invalid");return n}var Nd=0,Ud=0;function zd(t){if(!Td(t))throw TypeError("Invalid UUID");var e,n=new Uint8Array(16);return n[0]=(e=parseInt(t.slice(0,8),16))>>>24,n[1]=e>>>16&255,n[2]=e>>>8&255,n[3]=255&e,n[4]=(e=parseInt(t.slice(9,13),16))>>>8,n[5]=255&e,n[6]=(e=parseInt(t.slice(14,18),16))>>>8,n[7]=255&e,n[8]=(e=parseInt(t.slice(19,23),16))>>>8,n[9]=255&e,n[10]=(e=parseInt(t.slice(24,36),16))/1099511627776&255,n[11]=e/4294967296&255,n[12]=e>>>24&255,n[13]=e>>>16&255,n[14]=e>>>8&255,n[15]=255&e,n}function $d(t,e,n){function r(t,r,i,o){if("string"==typeof t&&(t=function(t){t=unescape(encodeURIComponent(t));for(var e=[],n=0;n<t.length;++n)e.push(t.charCodeAt(n));return e}(t)),"string"==typeof r&&(r=zd(r)),16!==r.length)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var s=new Uint8Array(16+t.length);if(s.set(r),s.set(t,r.length),(s=n(s))[6]=15&s[6]|e,s[8]=63&s[8]|128,i){o=o||0;for(var a=0;a<16;++a)i[o+a]=s[a];return i}return Ld(s)}try{r.name=t}catch(t){}return r.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",r.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8",r}function Wd(t){return 14+(t+64>>>9<<4)+1}function Fd(t,e){var n=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(n>>16)<<16|65535&n}function Dd(t,e,n,r,i,o){return Fd((s=Fd(Fd(e,t),Fd(r,o)))<<(a=i)|s>>>32-a,n);var s,a}function jd(t,e,n,r,i,o,s){return Dd(e&n|~e&r,t,e,i,o,s)}function qd(t,e,n,r,i,o,s){return Dd(e&r|n&~r,t,e,i,o,s)}function Kd(t,e,n,r,i,o,s){return Dd(e^n^r,t,e,i,o,s)}function Hd(t,e,n,r,i,o,s){return Dd(n^(e|~r),t,e,i,o,s)}var Vd=$d("v3",48,(function(t){if("string"==typeof t){var e=unescape(encodeURIComponent(t));t=new Uint8Array(e.length);for(var n=0;n<e.length;++n)t[n]=e.charCodeAt(n)}return function(t){for(var e=[],n=32*t.length,r="0123456789abcdef",i=0;i<n;i+=8){var o=t[i>>5]>>>i%32&255,s=parseInt(r.charAt(o>>>4&15)+r.charAt(15&o),16);e.push(s)}return e}(function(t,e){t[e>>5]|=128<<e%32,t[Wd(e)-1]=e;for(var n=1732584193,r=-271733879,i=-1732584194,o=271733878,s=0;s<t.length;s+=16){var a=n,c=r,u=i,l=o;n=jd(n,r,i,o,t[s],7,-680876936),o=jd(o,n,r,i,t[s+1],12,-389564586),i=jd(i,o,n,r,t[s+2],17,606105819),r=jd(r,i,o,n,t[s+3],22,-1044525330),n=jd(n,r,i,o,t[s+4],7,-176418897),o=jd(o,n,r,i,t[s+5],12,1200080426),i=jd(i,o,n,r,t[s+6],17,-1473231341),r=jd(r,i,o,n,t[s+7],22,-45705983),n=jd(n,r,i,o,t[s+8],7,1770035416),o=jd(o,n,r,i,t[s+9],12,-1958414417),i=jd(i,o,n,r,t[s+10],17,-42063),r=jd(r,i,o,n,t[s+11],22,-1990404162),n=jd(n,r,i,o,t[s+12],7,1804603682),o=jd(o,n,r,i,t[s+13],12,-40341101),i=jd(i,o,n,r,t[s+14],17,-1502002290),n=qd(n,r=jd(r,i,o,n,t[s+15],22,1236535329),i,o,t[s+1],5,-165796510),o=qd(o,n,r,i,t[s+6],9,-1069501632),i=qd(i,o,n,r,t[s+11],14,643717713),r=qd(r,i,o,n,t[s],20,-373897302),n=qd(n,r,i,o,t[s+5],5,-701558691),o=qd(o,n,r,i,t[s+10],9,38016083),i=qd(i,o,n,r,t[s+15],14,-660478335),r=qd(r,i,o,n,t[s+4],20,-405537848),n=qd(n,r,i,o,t[s+9],5,568446438),o=qd(o,n,r,i,t[s+14],9,-1019803690),i=qd(i,o,n,r,t[s+3],14,-187363961),r=qd(r,i,o,n,t[s+8],20,1163531501),n=qd(n,r,i,o,t[s+13],5,-1444681467),o=qd(o,n,r,i,t[s+2],9,-51403784),i=qd(i,o,n,r,t[s+7],14,1735328473),n=Kd(n,r=qd(r,i,o,n,t[s+12],20,-1926607734),i,o,t[s+5],4,-378558),o=Kd(o,n,r,i,t[s+8],11,-2022574463),i=Kd(i,o,n,r,t[s+11],16,1839030562),r=Kd(r,i,o,n,t[s+14],23,-35309556),n=Kd(n,r,i,o,t[s+1],4,-1530992060),o=Kd(o,n,r,i,t[s+4],11,1272893353),i=Kd(i,o,n,r,t[s+7],16,-155497632),r=Kd(r,i,o,n,t[s+10],23,-1094730640),n=Kd(n,r,i,o,t[s+13],4,681279174),o=Kd(o,n,r,i,t[s],11,-358537222),i=Kd(i,o,n,r,t[s+3],16,-722521979),r=Kd(r,i,o,n,t[s+6],23,76029189),n=Kd(n,r,i,o,t[s+9],4,-640364487),o=Kd(o,n,r,i,t[s+12],11,-421815835),i=Kd(i,o,n,r,t[s+15],16,530742520),n=Hd(n,r=Kd(r,i,o,n,t[s+2],23,-995338651),i,o,t[s],6,-198630844),o=Hd(o,n,r,i,t[s+7],10,1126891415),i=Hd(i,o,n,r,t[s+14],15,-1416354905),r=Hd(r,i,o,n,t[s+5],21,-57434055),n=Hd(n,r,i,o,t[s+12],6,1700485571),o=Hd(o,n,r,i,t[s+3],10,-1894986606),i=Hd(i,o,n,r,t[s+10],15,-1051523),r=Hd(r,i,o,n,t[s+1],21,-2054922799),n=Hd(n,r,i,o,t[s+8],6,1873313359),o=Hd(o,n,r,i,t[s+15],10,-30611744),i=Hd(i,o,n,r,t[s+6],15,-1560198380),r=Hd(r,i,o,n,t[s+13],21,1309151649),n=Hd(n,r,i,o,t[s+4],6,-145523070),o=Hd(o,n,r,i,t[s+11],10,-1120210379),i=Hd(i,o,n,r,t[s+2],15,718787259),r=Hd(r,i,o,n,t[s+9],21,-343485551),n=Fd(n,a),r=Fd(r,c),i=Fd(i,u),o=Fd(o,l)}return[n,r,i,o]}(function(t){if(0===t.length)return[];for(var e=8*t.length,n=new Uint32Array(Wd(e)),r=0;r<e;r+=8)n[r>>5]|=(255&t[r/8])<<r%32;return n}(t),8*t.length))})),Gd=Vd;function Jd(t,e,n,r){switch(t){case 0:return e&n^~e&r;case 1:case 3:return e^n^r;case 2:return e&n^e&r^n&r}}function Zd(t,e){return t<<e|t>>>32-e}var Yd=$d("v5",80,(function(t){var e=[1518500249,1859775393,2400959708,3395469782],n=[1732584193,4023233417,2562383102,271733878,3285377520];if("string"==typeof t){var r=unescape(encodeURIComponent(t));t=[];for(var i=0;i<r.length;++i)t.push(r.charCodeAt(i))}else Array.isArray(t)||(t=Array.prototype.slice.call(t));t.push(128);for(var o=t.length/4+2,s=Math.ceil(o/16),a=new Array(s),c=0;c<s;++c){for(var u=new Uint32Array(16),l=0;l<16;++l)u[l]=t[64*c+4*l]<<24|t[64*c+4*l+1]<<16|t[64*c+4*l+2]<<8|t[64*c+4*l+3];a[c]=u}a[s-1][14]=8*(t.length-1)/Math.pow(2,32),a[s-1][14]=Math.floor(a[s-1][14]),a[s-1][15]=8*(t.length-1)&4294967295;for(var h=0;h<s;++h){for(var d=new Uint32Array(80),f=0;f<16;++f)d[f]=a[h][f];for(var p=16;p<80;++p)d[p]=Zd(d[p-3]^d[p-8]^d[p-14]^d[p-16],1);for(var g=n[0],m=n[1],y=n[2],b=n[3],w=n[4],v=0;v<80;++v){var _=Math.floor(v/20),k=Zd(g,5)+Jd(_,m,y,b)+w+e[_]+d[v]>>>0;w=b,b=y,y=Zd(m,30)>>>0,m=g,g=k}n[0]=n[0]+g>>>0,n[1]=n[1]+m>>>0,n[2]=n[2]+y>>>0,n[3]=n[3]+b>>>0,n[4]=n[4]+w>>>0}return[n[0]>>24&255,n[0]>>16&255,n[0]>>8&255,255&n[0],n[1]>>24&255,n[1]>>16&255,n[1]>>8&255,255&n[1],n[2]>>24&255,n[2]>>16&255,n[2]>>8&255,255&n[2],n[3]>>24&255,n[3]>>16&255,n[3]>>8&255,255&n[3],n[4]>>24&255,n[4]>>16&255,n[4]>>8&255,255&n[4]]})),Xd=Yd;var Qd=Object.freeze({__proto__:null,v1:function(t,e,n){var r=e&&n||0,i=e||new Array(16),o=(t=t||{}).node||Md,s=void 0!==t.clockseq?t.clockseq:Cd;if(null==o||null==s){var a=t.random||(t.rng||Bd)();null==o&&(o=Md=[1|a[0],a[1],a[2],a[3],a[4],a[5]]),null==s&&(s=Cd=16383&(a[6]<<8|a[7]))}var c=void 0!==t.msecs?t.msecs:Date.now(),u=void 0!==t.nsecs?t.nsecs:Ud+1,l=c-Nd+(u-Ud)/1e4;if(l<0&&void 0===t.clockseq&&(s=s+1&16383),(l<0||c>Nd)&&void 0===t.nsecs&&(u=0),u>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Nd=c,Ud=u,Cd=s;var h=(1e4*(268435455&(c+=122192928e5))+u)%4294967296;i[r++]=h>>>24&255,i[r++]=h>>>16&255,i[r++]=h>>>8&255,i[r++]=255&h;var d=c/4294967296*1e4&268435455;i[r++]=d>>>8&255,i[r++]=255&d,i[r++]=d>>>24&15|16,i[r++]=d>>>16&255,i[r++]=s>>>8|128,i[r++]=255&s;for(var f=0;f<6;++f)i[r+f]=o[f];return e||Ld(i)},v3:Gd,v4:function(t,e,n){var r=(t=t||{}).random||(t.rng||Bd)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,e){n=n||0;for(var i=0;i<16;++i)e[n+i]=r[i];return e}return Ld(r)},v5:Xd,NIL:"00000000-0000-0000-0000-000000000000",version:function(t){if(!Td(t))throw TypeError("Invalid UUID");return parseInt(t.substr(14,1),16)},validate:Td,stringify:Ld,parse:zd});const tf=Qd.v4;var ef=function(t,e,n,r){if("string"!=typeof t)throw new TypeError(t+" must be a string");const i="number"==typeof(r=r||{}).version?r.version:2;if(1!==i&&2!==i)throw new TypeError(i+" must be 1 or 2");const o={method:t};if(2===i&&(o.jsonrpc="2.0"),e){if("object"!=typeof e&&!Array.isArray(e))throw new TypeError(e+" must be an object, array or omitted");o.params=e}if(void 0===n){const t="function"==typeof r.generator?r.generator:function(){return tf()};o.id=t(o,r)}else 2===i&&null===n?r.notificationIdNull&&(o.id=null):o.id=n;return o};const nf=Qd.v4,rf=ef,of=function(t,e){if(!(this instanceof of))return new of(t,e);e||(e={}),this.options={reviver:void 0!==e.reviver?e.reviver:null,replacer:void 0!==e.replacer?e.replacer:null,generator:void 0!==e.generator?e.generator:function(){return nf()},version:void 0!==e.version?e.version:2,notificationIdNull:"boolean"==typeof e.notificationIdNull&&e.notificationIdNull},this.callServer=t};var sf=of;of.prototype.request=function(t,e,n,r){const i=this;let o=null;const s=Array.isArray(t)&&"function"==typeof e;if(1===this.options.version&&s)throw new TypeError("JSON-RPC 1.0 does not support batching");if(s||!s&&t&&"object"==typeof t&&"function"==typeof e)r=e,o=t;else{"function"==typeof n&&(r=n,n=void 0);const i="function"==typeof r;try{o=rf(t,e,n,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(t){if(i)return r(t);throw t}if(!i)return o}let a;try{a=JSON.stringify(o,this.options.replacer)}catch(t){return r(t)}return this.callServer(a,(function(t,e){i._parseResponse(t,e,r)})),o},of.prototype._parseResponse=function(t,e,n){if(t)return void n(t);if(!e)return n();let r;try{r=JSON.parse(e,this.options.reviver)}catch(t){return n(t)}if(3===n.length){if(Array.isArray(r)){const t=function(t){return void 0!==t.error},e=function(e){return!t(e)};return n(null,r.filter(t),r.filter(e))}return n(null,r.error,r.result)}n(null,r)};var af={exports:{}};!function(t){var e=Object.prototype.hasOwnProperty,n="~";function r(){}function i(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function o(t,e,r,o,s){if("function"!=typeof r)throw new TypeError("The listener must be a function");var a=new i(r,o||t,s),c=n?n+e:e;return t._events[c]?t._events[c].fn?t._events[c]=[t._events[c],a]:t._events[c].push(a):(t._events[c]=a,t._eventsCount++),t}function s(t,e){0==--t._eventsCount?t._events=new r:delete t._events[e]}function a(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),a.prototype.eventNames=function(){var t,r,i=[];if(0===this._eventsCount)return i;for(r in t=this._events)e.call(t,r)&&i.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(t)):i},a.prototype.listeners=function(t){var e=n?n+t:t,r=this._events[e];if(!r)return[];if(r.fn)return[r.fn];for(var i=0,o=r.length,s=new Array(o);i<o;i++)s[i]=r[i].fn;return s},a.prototype.listenerCount=function(t){var e=n?n+t:t,r=this._events[e];return r?r.fn?1:r.length:0},a.prototype.emit=function(t,e,r,i,o,s){var a=n?n+t:t;if(!this._events[a])return!1;var c,u,l=this._events[a],h=arguments.length;if(l.fn){switch(l.once&&this.removeListener(t,l.fn,void 0,!0),h){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,e),!0;case 3:return l.fn.call(l.context,e,r),!0;case 4:return l.fn.call(l.context,e,r,i),!0;case 5:return l.fn.call(l.context,e,r,i,o),!0;case 6:return l.fn.call(l.context,e,r,i,o,s),!0}for(u=1,c=new Array(h-1);u<h;u++)c[u-1]=arguments[u];l.fn.apply(l.context,c)}else{var d,f=l.length;for(u=0;u<f;u++)switch(l[u].once&&this.removeListener(t,l[u].fn,void 0,!0),h){case 1:l[u].fn.call(l[u].context);break;case 2:l[u].fn.call(l[u].context,e);break;case 3:l[u].fn.call(l[u].context,e,r);break;case 4:l[u].fn.call(l[u].context,e,r,i);break;default:if(!c)for(d=1,c=new Array(h-1);d<h;d++)c[d-1]=arguments[d];l[u].fn.apply(l[u].context,c)}}return!0},a.prototype.on=function(t,e,n){return o(this,t,e,n,!1)},a.prototype.once=function(t,e,n){return o(this,t,e,n,!0)},a.prototype.removeListener=function(t,e,r,i){var o=n?n+t:t;if(!this._events[o])return this;if(!e)return s(this,o),this;var a=this._events[o];if(a.fn)a.fn!==e||i&&!a.once||r&&a.context!==r||s(this,o);else{for(var c=0,u=[],l=a.length;c<l;c++)(a[c].fn!==e||i&&!a[c].once||r&&a[c].context!==r)&&u.push(a[c]);u.length?this._events[o]=1===u.length?u[0]:u:s(this,o)}return this},a.prototype.removeAllListeners=function(t){var e;return t?(e=n?n+t:t,this._events[e]&&s(this,e)):(this._events=new r,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=n,a.EventEmitter=a,t.exports=a}(af);var cf=af.exports,uf=class extends cf{socket;constructor(t,e,n){super(),this.socket=new window.WebSocket(t,n),this.socket.onopen=()=>this.emit("open"),this.socket.onmessage=t=>this.emit("message",t.data),this.socket.onerror=t=>this.emit("error",t),this.socket.onclose=t=>{this.emit("close",t.code,t.reason)}}send(t,e,n){const r=n||e;try{this.socket.send(t),r()}catch(t){r(t)}}close(t,e){this.socket.close(t,e)}addEventListener(t,e,n){this.socket.addEventListener(t,e,n)}};var lf=class{encode(t){return JSON.stringify(t)}decode(t){return JSON.parse(t)}},hf=class extends cf{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(t,e="ws://localhost:8080",{autoconnect:n=!0,reconnect:r=!0,reconnect_interval:i=1e3,max_reconnects:o=5,...s}={},a,c){super(),this.webSocketFactory=t,this.queue={},this.rpc_id=0,this.address=e,this.autoconnect=n,this.ready=!1,this.reconnect=r,this.reconnect_timer_id=void 0,this.reconnect_interval=i,this.max_reconnects=o,this.rest_options=s,this.current_reconnects=0,this.generate_request_id=a||(()=>++this.rpc_id),this.dataPack=c||new lf,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(t,e,n,r){return r||"object"!=typeof n||(r=n,n=null),new Promise(((i,o)=>{if(!this.ready)return o(new Error("socket not ready"));const s=this.generate_request_id(t,e),a={jsonrpc:"2.0",method:t,params:e||void 0,id:s};this.socket.send(this.dataPack.encode(a),r,(t=>{if(t)return o(t);this.queue[s]={promise:[i,o]},n&&(this.queue[s].timeout=setTimeout((()=>{delete this.queue[s],o(new Error("reply timeout"))}),n))}))}))}async login(t){const e=await this.call("rpc.login",t);if(!e)throw new Error("authentication failed");return e}async listMethods(){return await this.call("__listMethods")}notify(t,e){return new Promise(((n,r)=>{if(!this.ready)return r(new Error("socket not ready"));const i={jsonrpc:"2.0",method:t,params:e};this.socket.send(this.dataPack.encode(i),(t=>{if(t)return r(t);n()}))}))}async subscribe(t){"string"==typeof t&&(t=[t]);const e=await this.call("rpc.on",t);if("string"==typeof t&&"ok"!==e[t])throw new Error("Failed subscribing to an event '"+t+"' with: "+e[t]);return e}async unsubscribe(t){"string"==typeof t&&(t=[t]);const e=await this.call("rpc.off",t);if("string"==typeof t&&"ok"!==e[t])throw new Error("Failed unsubscribing from an event with: "+e);return e}close(t,e){this.socket.close(t||1e3,e)}setAutoReconnect(t){this.reconnect=t}setReconnectInterval(t){this.reconnect_interval=t}setMaxReconnects(t){this.max_reconnects=t}_connect(t,e){clearTimeout(this.reconnect_timer_id),this.socket=this.webSocketFactory(t,e),this.socket.addEventListener("open",(()=>{this.ready=!0,this.emit("open"),this.current_reconnects=0})),this.socket.addEventListener("message",(({data:t})=>{t instanceof ArrayBuffer&&(t=cr.Buffer.from(t).toString());try{t=this.dataPack.decode(t)}catch(t){return}if(t.notification&&this.listeners(t.notification).length){if(!Object.keys(t.params).length)return this.emit(t.notification);const e=[t.notification];if(t.params.constructor===Object)e.push(t.params);else for(let n=0;n<t.params.length;n++)e.push(t.params[n]);return Promise.resolve().then((()=>{this.emit.apply(this,e)}))}if(!this.queue[t.id])return t.method?Promise.resolve().then((()=>{this.emit(t.method,t?.params)})):void 0;"error"in t=="result"in t&&this.queue[t.id].promise[1](new Error('Server response malformed. Response must include either "result" or "error", but not both.')),this.queue[t.id].timeout&&clearTimeout(this.queue[t.id].timeout),t.error?this.queue[t.id].promise[1](t.error):this.queue[t.id].promise[0](t.result),delete this.queue[t.id]})),this.socket.addEventListener("error",(t=>this.emit("error",t))),this.socket.addEventListener("close",(({code:n,reason:r})=>{this.ready&&setTimeout((()=>this.emit("close",n,r)),0),this.ready=!1,this.socket=void 0,1e3!==n&&(this.current_reconnects++,this.reconnect&&(this.max_reconnects>this.current_reconnects||0===this.max_reconnects)&&(this.reconnect_timer_id=setTimeout((()=>this._connect(t,e)),this.reconnect_interval)))}))}};const df=BigInt(0),ff=BigInt(1),pf=BigInt(2),gf=BigInt(7),mf=BigInt(256),yf=BigInt(113),bf=[],wf=[],vf=[];for(let t=0,e=ff,n=1,r=0;t<24;t++){[n,r]=[r,(2*n+3*r)%5],bf.push(2*(5*r+n)),wf.push((t+1)*(t+2)/2%64);let i=df;for(let t=0;t<7;t++)e=(e<<ff^(e>>gf)*yf)%mf,e&pf&&(i^=ff<<(ff<<BigInt(t))-ff);vf.push(i)}const _f=$r(vf,!0),kf=_f[0],Sf=_f[1],xf=(t,e,n)=>n>32?((t,e,n)=>e<<n-32|t>>>64-n)(t,e,n):((t,e,n)=>t<<n|e>>>32-n)(t,e,n),Ef=(t,e,n)=>n>32?((t,e,n)=>t<<n-32|e>>>64-n)(t,e,n):((t,e,n)=>e<<n|t>>>32-n)(t,e,n);class If extends Br{constructor(t,e,n,r=!1,i=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=t,this.suffix=e,this.outputLen=n,this.enableXOF=r,this.rounds=i,wr(n),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=function(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}(this.state)}clone(){return this._cloneInto()}keccak(){Ir(this.state32),function(t,e=24){const n=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let e=0;e<10;e++)n[e]=t[e]^t[e+10]^t[e+20]^t[e+30]^t[e+40];for(let e=0;e<10;e+=2){const r=(e+8)%10,i=(e+2)%10,o=n[i],s=n[i+1],a=xf(o,s,1)^n[r],c=Ef(o,s,1)^n[r+1];for(let n=0;n<50;n+=10)t[e+n]^=a,t[e+n+1]^=c}let e=t[2],i=t[3];for(let n=0;n<24;n++){const r=wf[n],o=xf(e,i,r),s=Ef(e,i,r),a=bf[n];e=t[a],i=t[a+1],t[a]=o,t[a+1]=s}for(let e=0;e<50;e+=10){for(let r=0;r<10;r++)n[r]=t[e+r];for(let r=0;r<10;r++)t[e+r]^=~n[(r+2)%10]&n[(r+4)%10]}t[0]^=kf[r],t[1]^=Sf[r]}Sr(n)}(this.state32,this.rounds),Ir(this.state32),this.posOut=0,this.pos=0}update(t){_r(this),vr(t=Ar(t));const{blockLen:e,state:n}=this,r=t.length;for(let i=0;i<r;){const o=Math.min(e-this.pos,r-i);for(let e=0;e<o;e++)n[this.pos++]^=t[i++];this.pos===e&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:e,pos:n,blockLen:r}=this;t[n]^=e,128&e&&n===r-1&&this.keccak(),t[r-1]^=128,this.keccak()}writeInto(t){_r(this,!1),vr(t),this.finish();const e=this.state,{blockLen:n}=this;for(let r=0,i=t.length;r<i;){this.posOut>=n&&this.keccak();const o=Math.min(n-this.posOut,i-r);t.set(e.subarray(this.posOut,this.posOut+o),r),this.posOut+=o,r+=o}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return wr(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(kr(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,Sr(this.state)}_cloneInto(t){const{blockLen:e,suffix:n,outputLen:r,rounds:i,enableXOF:o}=this;return t||(t=new If(e,n,r,o,i)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=i,t.suffix=n,t.outputLen=r,t.enableXOF=o,t.destroyed=this.destroyed,t}}const Af=(()=>{return t=1,e=136,n=32,Pr((()=>new If(e,t,n)));var t,e,n})();class Bf extends Br{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,function(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.createHasher");wr(t.outputLen),wr(t.blockLen)}(t);const n=Ar(e);if(this.iHash=t.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,i=new Uint8Array(r);i.set(n.length>r?t.create().update(n).digest():n);for(let t=0;t<i.length;t++)i[t]^=54;this.iHash.update(i),this.oHash=t.create();for(let t=0;t<i.length;t++)i[t]^=106;this.oHash.update(i),Sr(i)}update(t){return _r(this),this.iHash.update(t),this}digestInto(t){_r(this),vr(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:e,iHash:n,finished:r,destroyed:i,blockLen:o,outputLen:s}=this;return t.finished=r,t.destroyed=i,t.blockLen=o,t.outputLen=s,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Pf=(t,e,n)=>new Bf(t,e).update(n).digest();function Tf(t){void 0!==t.lowS&&pi("lowS",t.lowS),void 0!==t.prehash&&pi("prehash",t.prehash)}Pf.create=(t,e)=>new Bf(t,e);class Mf extends Error{constructor(t=""){super(t)}}const Cf={Err:Mf,_tlv:{encode:(t,e)=>{const{Err:n}=Cf;if(t<0||t>256)throw new n("tlv.encode: wrong tag");if(1&e.length)throw new n("tlv.encode: unpadded data");const r=e.length/2,i=gi(r);if(i.length/2&128)throw new n("tlv.encode: long form length too big");const o=r>127?gi(i.length/2|128):"";return gi(t)+o+i+e},decode(t,e){const{Err:n}=Cf;let r=0;if(t<0||t>256)throw new n("tlv.encode: wrong tag");if(e.length<2||e[r++]!==t)throw new n("tlv.decode: wrong tlv");const i=e[r++];let o=0;if(!!(128&i)){const t=127&i;if(!t)throw new n("tlv.decode(long): indefinite length not supported");if(t>4)throw new n("tlv.decode(long): byte length is too big");const s=e.subarray(r,r+t);if(s.length!==t)throw new n("tlv.decode: length bytes not complete");if(0===s[0])throw new n("tlv.decode(long): zero leftmost byte");for(const t of s)o=o<<8|t;if(r+=t,o<128)throw new n("tlv.decode(long): not minimal encoding")}else o=i;const s=e.subarray(r,r+o);if(s.length!==o)throw new n("tlv.decode: wrong value length");return{v:s,l:e.subarray(r+o)}}},_int:{encode(t){const{Err:e}=Cf;if(t<Of)throw new e("integer: negative integers are not allowed");let n=gi(t);if(8&Number.parseInt(n[0],16)&&(n="00"+n),1&n.length)throw new e("unexpected DER parsing assertion: unpadded hex");return n},decode(t){const{Err:e}=Cf;if(128&t[0])throw new e("invalid signature integer: negative");if(0===t[0]&&!(128&t[1]))throw new e("invalid signature integer: unnecessary leading zero");return Si(t)}},toSig(t){const{Err:e,_int:n,_tlv:r}=Cf,i=Ai("signature",t),{v:o,l:s}=r.decode(48,i);if(s.length)throw new e("invalid signature: left bytes after parsing");const{v:a,l:c}=r.decode(2,o),{v:u,l:l}=r.decode(2,c);if(l.length)throw new e("invalid signature: left bytes after parsing");return{r:n.decode(a),s:n.decode(u)}},hexFromSig(t){const{_tlv:e,_int:n}=Cf,r=e.encode(2,n.encode(t.r))+e.encode(2,n.encode(t.s));return e.encode(48,r)}},Of=BigInt(0),Rf=BigInt(1);BigInt(2);const Lf=BigInt(3);function Nf(t){const e=function(t){const e=po(t);Ni(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:n,Fp:r,a:i}=e;if(n){if(!r.eql(i,r.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if("object"!=typeof n||"bigint"!=typeof n.beta||"function"!=typeof n.splitScalar)throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...e})}(t),{Fp:n}=e,r=Qi(e.n,e.nBitLength),i=e.toBytes||((t,e,r)=>{const i=e.toAffine();return Bi(Uint8Array.from([4]),n.toBytes(i.x),n.toBytes(i.y))}),o=e.fromBytes||(t=>{const e=t.subarray(1);return{x:n.fromBytes(e.subarray(0,n.BYTES)),y:n.fromBytes(e.subarray(n.BYTES,2*n.BYTES))}});function s(t){const{a:r,b:i}=e,o=n.sqr(t),s=n.mul(o,t);return n.add(n.add(s,n.mul(t,r)),i)}if(!n.eql(n.sqr(e.Gy),s(e.Gx)))throw new Error("bad generator point: equation left != right");function a(t){const{allowedPrivateKeyLengths:n,nByteLength:r,wrapPrivateKey:i,n:o}=e;if(n&&"bigint"!=typeof t){if(di(t)&&(t=wi(t)),"string"!=typeof t||!n.includes(t.length))throw new Error("invalid private key");t=t.padStart(2*r,"0")}let s;try{s="bigint"==typeof t?t:Si(Ai("private key",t,r))}catch(e){throw new Error("invalid private key, expected hex or "+r+" bytes, got "+typeof t)}return i&&(s=Ki(s,o)),Mi("private key",s,Rf,o),s}function c(t){if(!(t instanceof h))throw new Error("ProjectivePoint expected")}const u=Ui(((t,e)=>{const{px:r,py:i,pz:o}=t;if(n.eql(o,n.ONE))return{x:r,y:i};const s=t.is0();null==e&&(e=s?n.ONE:n.inv(o));const a=n.mul(r,e),c=n.mul(i,e),u=n.mul(o,e);if(s)return{x:n.ZERO,y:n.ZERO};if(!n.eql(u,n.ONE))throw new Error("invZ was invalid");return{x:a,y:c}})),l=Ui((t=>{if(t.is0()){if(e.allowInfinityPoint&&!n.is0(t.py))return;throw new Error("bad point: ZERO")}const{x:r,y:i}=t.toAffine();if(!n.isValid(r)||!n.isValid(i))throw new Error("bad point: x or y not FE");const o=n.sqr(i),a=s(r);if(!n.eql(o,a))throw new Error("bad point: equation left != right");if(!t.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0}));class h{constructor(t,e,r){if(null==t||!n.isValid(t))throw new Error("x required");if(null==e||!n.isValid(e)||n.is0(e))throw new Error("y required");if(null==r||!n.isValid(r))throw new Error("z required");this.px=t,this.py=e,this.pz=r,Object.freeze(this)}static fromAffine(t){const{x:e,y:r}=t||{};if(!t||!n.isValid(e)||!n.isValid(r))throw new Error("invalid affine point");if(t instanceof h)throw new Error("projective point not allowed");const i=t=>n.eql(t,n.ZERO);return i(e)&&i(r)?h.ZERO:new h(e,r,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(t){const e=Zi(n,t.map((t=>t.pz)));return t.map(((t,n)=>t.toAffine(e[n]))).map(h.fromAffine)}static fromHex(t){const e=h.fromAffine(o(Ai("pointHex",t)));return e.assertValidity(),e}static fromPrivateKey(t){return h.BASE.multiply(a(t))}static msm(t,e){return fo(h,r,t,e)}_setWindowSize(t){f.setWindowSize(this,t)}assertValidity(){l(this)}hasEvenY(){const{y:t}=this.toAffine();if(n.isOdd)return!n.isOdd(t);throw new Error("Field doesn't support isOdd")}equals(t){c(t);const{px:e,py:r,pz:i}=this,{px:o,py:s,pz:a}=t,u=n.eql(n.mul(e,a),n.mul(o,i)),l=n.eql(n.mul(r,a),n.mul(s,i));return u&&l}negate(){return new h(this.px,n.neg(this.py),this.pz)}double(){const{a:t,b:r}=e,i=n.mul(r,Lf),{px:o,py:s,pz:a}=this;let c=n.ZERO,u=n.ZERO,l=n.ZERO,d=n.mul(o,o),f=n.mul(s,s),p=n.mul(a,a),g=n.mul(o,s);return g=n.add(g,g),l=n.mul(o,a),l=n.add(l,l),c=n.mul(t,l),u=n.mul(i,p),u=n.add(c,u),c=n.sub(f,u),u=n.add(f,u),u=n.mul(c,u),c=n.mul(g,c),l=n.mul(i,l),p=n.mul(t,p),g=n.sub(d,p),g=n.mul(t,g),g=n.add(g,l),l=n.add(d,d),d=n.add(l,d),d=n.add(d,p),d=n.mul(d,g),u=n.add(u,d),p=n.mul(s,a),p=n.add(p,p),d=n.mul(p,g),c=n.sub(c,d),l=n.mul(p,f),l=n.add(l,l),l=n.add(l,l),new h(c,u,l)}add(t){c(t);const{px:r,py:i,pz:o}=this,{px:s,py:a,pz:u}=t;let l=n.ZERO,d=n.ZERO,f=n.ZERO;const p=e.a,g=n.mul(e.b,Lf);let m=n.mul(r,s),y=n.mul(i,a),b=n.mul(o,u),w=n.add(r,i),v=n.add(s,a);w=n.mul(w,v),v=n.add(m,y),w=n.sub(w,v),v=n.add(r,o);let _=n.add(s,u);return v=n.mul(v,_),_=n.add(m,b),v=n.sub(v,_),_=n.add(i,o),l=n.add(a,u),_=n.mul(_,l),l=n.add(y,b),_=n.sub(_,l),f=n.mul(p,v),l=n.mul(g,b),f=n.add(l,f),l=n.sub(y,f),f=n.add(y,f),d=n.mul(l,f),y=n.add(m,m),y=n.add(y,m),b=n.mul(p,b),v=n.mul(g,v),y=n.add(y,b),b=n.sub(m,b),b=n.mul(p,b),v=n.add(v,b),m=n.mul(y,v),d=n.add(d,m),m=n.mul(_,v),l=n.mul(w,l),l=n.sub(l,m),m=n.mul(w,y),f=n.mul(_,f),f=n.add(f,m),new h(l,d,f)}subtract(t){return this.add(t.negate())}is0(){return this.equals(h.ZERO)}wNAF(t){return f.wNAFCached(this,t,h.normalizeZ)}multiplyUnsafe(t){const{endo:r,n:i}=e;Mi("scalar",t,Of,i);const o=h.ZERO;if(t===Of)return o;if(this.is0()||t===Rf)return this;if(!r||f.hasPrecomputes(this))return f.wNAFCachedUnsafe(this,t,h.normalizeZ);let{k1neg:s,k1:a,k2neg:c,k2:u}=r.splitScalar(t),l=o,d=o,p=this;for(;a>Of||u>Of;)a&Rf&&(l=l.add(p)),u&Rf&&(d=d.add(p)),p=p.double(),a>>=Rf,u>>=Rf;return s&&(l=l.negate()),c&&(d=d.negate()),d=new h(n.mul(d.px,r.beta),d.py,d.pz),l.add(d)}multiply(t){const{endo:r,n:i}=e;let o,s;if(Mi("scalar",t,Rf,i),r){const{k1neg:e,k1:i,k2neg:a,k2:c}=r.splitScalar(t);let{p:u,f:l}=this.wNAF(i),{p:d,f:p}=this.wNAF(c);u=f.constTimeNegate(e,u),d=f.constTimeNegate(a,d),d=new h(n.mul(d.px,r.beta),d.py,d.pz),o=u.add(d),s=l.add(p)}else{const{p:e,f:n}=this.wNAF(t);o=e,s=n}return h.normalizeZ([o,s])[0]}multiplyAndAddUnsafe(t,e,n){const r=h.BASE,i=(t,e)=>e!==Of&&e!==Rf&&t.equals(r)?t.multiply(e):t.multiplyUnsafe(e),o=i(this,e).add(i(t,n));return o.is0()?void 0:o}toAffine(t){return u(this,t)}isTorsionFree(){const{h:t,isTorsionFree:n}=e;if(t===Rf)return!0;if(n)return n(h,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:t,clearCofactor:n}=e;return t===Rf?this:n?n(h,this):this.multiplyUnsafe(e.h)}toRawBytes(t=!0){return pi("isCompressed",t),this.assertValidity(),i(h,this,t)}toHex(t=!0){return pi("isCompressed",t),wi(this.toRawBytes(t))}}h.BASE=new h(e.Gx,e.Gy,n.ONE),h.ZERO=new h(n.ZERO,n.ONE,n.ZERO);const d=e.nBitLength,f=ho(h,e.endo?Math.ceil(d/2):d);return{CURVE:e,ProjectivePoint:h,normPrivateKeyToScalar:a,weierstrassEquation:s,isWithinCurveOrder:function(t){return Ti(t,Rf,e.n)}}}function Uf(t){const e=function(t){const e=po(t);return Ni(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}(t),{Fp:n,n:r}=e,i=n.BYTES+1,o=2*n.BYTES+1;function s(t){return Ki(t,r)}function a(t){return Vi(t,r)}const{ProjectivePoint:c,normPrivateKeyToScalar:u,weierstrassEquation:l,isWithinCurveOrder:h}=Nf({...e,toBytes(t,e,r){const i=e.toAffine(),o=n.toBytes(i.x),s=Bi;return pi("isCompressed",r),r?s(Uint8Array.from([e.hasEvenY()?2:3]),o):s(Uint8Array.from([4]),o,n.toBytes(i.y))},fromBytes(t){const e=t.length,r=t[0],s=t.subarray(1);if(e!==i||2!==r&&3!==r){if(e===o&&4===r){return{x:n.fromBytes(s.subarray(0,n.BYTES)),y:n.fromBytes(s.subarray(n.BYTES,2*n.BYTES))}}throw new Error("invalid Point, expected length of "+i+", or uncompressed "+o+", got "+e)}{const t=Si(s);if(!Ti(t,Rf,n.ORDER))throw new Error("Point is not on curve");const e=l(t);let i;try{i=n.sqrt(e)}catch(t){const e=t instanceof Error?": "+t.message:"";throw new Error("Point is not on curve"+e)}return!(1&~r)!==((i&Rf)===Rf)&&(i=n.neg(i)),{x:t,y:i}}}}),d=t=>wi(Ei(t,e.nByteLength));function f(t){return t>r>>Rf}const p=(t,e,n)=>Si(t.slice(e,n));class g{constructor(t,e,n){Mi("r",t,Rf,r),Mi("s",e,Rf,r),this.r=t,this.s=e,null!=n&&(this.recovery=n),Object.freeze(this)}static fromCompact(t){const n=e.nByteLength;return t=Ai("compactSignature",t,2*n),new g(p(t,0,n),p(t,n,2*n))}static fromDER(t){const{r:e,s:n}=Cf.toSig(Ai("DER",t));return new g(e,n)}assertValidity(){}addRecoveryBit(t){return new g(this.r,this.s,t)}recoverPublicKey(t){const{r:r,s:i,recovery:o}=this,u=w(Ai("msgHash",t));if(null==o||![0,1,2,3].includes(o))throw new Error("recovery id invalid");const l=2===o||3===o?r+e.n:r;if(l>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const h=1&o?"03":"02",f=c.fromHex(h+d(l)),p=a(l),g=s(-u*p),m=s(i*p),y=c.BASE.multiplyAndAddUnsafe(f,g,m);if(!y)throw new Error("point at infinify");return y.assertValidity(),y}hasHighS(){return f(this.s)}normalizeS(){return this.hasHighS()?new g(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return ki(this.toDERHex())}toDERHex(){return Cf.hexFromSig(this)}toCompactRawBytes(){return ki(this.toCompactHex())}toCompactHex(){return d(this.r)+d(this.s)}}const m={isValidPrivateKey(t){try{return u(t),!0}catch(t){return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{const t=eo(e.n);return function(t,e,n=!1){const r=t.length,i=to(e),o=eo(e);if(r<16||r<o||r>1024)throw new Error("expected "+o+"-1024 bytes of input, got "+r);const s=Ki(n?xi(t):Si(t),e-$i)+$i;return n?Ii(s,i):Ei(s,i)}(e.randomBytes(t),e.n)},precompute:(t=8,e=c.BASE)=>(e._setWindowSize(t),e.multiply(BigInt(3)),e)};function y(t){const e=di(t),n="string"==typeof t,r=(e||n)&&t.length;return e?r===i||r===o:n?r===2*i||r===2*o:t instanceof c}const b=e.bits2int||function(t){if(t.length>8192)throw new Error("input is too large");const n=Si(t),r=8*t.length-e.nBitLength;return r>0?n>>BigInt(r):n},w=e.bits2int_modN||function(t){return s(b(t))},v=Ci(e.nBitLength);function _(t){return Mi("num < 2^"+e.nBitLength,t,Of,v),Ei(t,e.nByteLength)}function k(t,r,i=S){if(["recovered","canonical"].some((t=>t in i)))throw new Error("sign() legacy options not supported");const{hash:o,randomBytes:l}=e;let{lowS:d,prehash:p,extraEntropy:m}=i;null==d&&(d=!0),t=Ai("msgHash",t),Tf(i),p&&(t=Ai("prehashed msgHash",o(t)));const y=w(t),v=u(r),k=[_(v),_(y)];if(null!=m&&!1!==m){const t=!0===m?l(n.BYTES):m;k.push(Ai("extraEntropy",t))}const x=Bi(...k),E=y;return{seed:x,k2sig:function(t){const e=b(t);if(!h(e))return;const n=a(e),r=c.BASE.multiply(e).toAffine(),i=s(r.x);if(i===Of)return;const o=s(n*s(E+i*v));if(o===Of)return;let u=(r.x===i?0:2)|Number(r.y&Rf),l=o;return d&&f(o)&&(l=function(t){return f(t)?s(-t):t}(o),u^=1),new g(i,l,u)}}}const S={lowS:e.lowS,prehash:!1},x={lowS:e.lowS,prehash:!1};return c.BASE._setWindowSize(8),{CURVE:e,getPublicKey:function(t,e=!0){return c.fromPrivateKey(t).toRawBytes(e)},getSharedSecret:function(t,e,n=!0){if(y(t))throw new Error("first arg must be private key");if(!y(e))throw new Error("second arg must be public key");return c.fromHex(e).multiply(u(t)).toRawBytes(n)},sign:function(t,n,r=S){const{seed:i,k2sig:o}=k(t,n,r),s=e,a=function(t,e,n){if("number"!=typeof t||t<2)throw new Error("hashLen must be a number");if("number"!=typeof e||e<2)throw new Error("qByteLen must be a number");if("function"!=typeof n)throw new Error("hmacFn must be a function");let r=Oi(t),i=Oi(t),o=0;const s=()=>{r.fill(1),i.fill(0),o=0},a=(...t)=>n(i,r,...t),c=(t=Oi(0))=>{i=a(Ri([0]),t),r=a(),0!==t.length&&(i=a(Ri([1]),t),r=a())},u=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let t=0;const n=[];for(;t<e;){r=a();const e=r.slice();n.push(e),t+=r.length}return Bi(...n)};return(t,e)=>{let n;for(s(),c(t);!(n=e(u()));)c();return s(),n}}(s.hash.outputLen,s.nByteLength,s.hmac);return a(i,o)},verify:function(t,n,r,i=x){const o=t;n=Ai("msgHash",n),r=Ai("publicKey",r);const{lowS:u,prehash:l,format:h}=i;if(Tf(i),"strict"in i)throw new Error("options.strict was renamed to lowS");if(void 0!==h&&"compact"!==h&&"der"!==h)throw new Error("format must be compact or der");const d="string"==typeof o||di(o),f=!d&&!h&&"object"==typeof o&&null!==o&&"bigint"==typeof o.r&&"bigint"==typeof o.s;if(!d&&!f)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let p,m;try{if(f&&(p=new g(o.r,o.s)),d){try{"compact"!==h&&(p=g.fromDER(o))}catch(t){if(!(t instanceof Cf.Err))throw t}p||"der"===h||(p=g.fromCompact(o))}m=c.fromHex(r)}catch(t){return!1}if(!p)return!1;if(u&&p.hasHighS())return!1;l&&(n=e.hash(n));const{r:y,s:b}=p,v=w(n),_=a(b),k=s(v*_),S=s(y*_),E=c.BASE.multiplyAndAddUnsafe(m,k,S)?.toAffine();return!!E&&s(E.x)===y},ProjectivePoint:c,Signature:g,utils:m}}function zf(t){return{hash:t,hmac:(e,...n)=>Pf(t,e,function(...t){let e=0;for(let n=0;n<t.length;n++){const r=t[n];vr(r),e+=r.length}const n=new Uint8Array(e);for(let e=0,r=0;e<t.length;e++){const i=t[e];n.set(i,r),r+=i.length}return n}(...n)),randomBytes:Tr}}BigInt(4);const $f=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Wf=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Ff=BigInt(1),Df=BigInt(2),jf=(t,e)=>(t+e/Df)/e;const qf=Qi($f,void 0,void 0,{sqrt:function(t){const e=$f,n=BigInt(3),r=BigInt(6),i=BigInt(11),o=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),u=t*t*t%e,l=u*u*t%e,h=Hi(l,n,e)*l%e,d=Hi(h,n,e)*l%e,f=Hi(d,Df,e)*u%e,p=Hi(f,i,e)*f%e,g=Hi(p,o,e)*p%e,m=Hi(g,a,e)*g%e,y=Hi(m,c,e)*m%e,b=Hi(y,a,e)*g%e,w=Hi(b,n,e)*l%e,v=Hi(w,s,e)*p%e,_=Hi(v,r,e)*u%e,k=Hi(_,Df,e);if(!qf.eql(qf.sqr(k),t))throw new Error("Cannot find square root");return k}}),Kf=function(t,e){const n=e=>Uf({...t,...zf(e)});return{...n(e),create:n}}({a:BigInt(0),b:BigInt(7),Fp:qf,n:Wf,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=Wf,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-Ff*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=n,s=BigInt("0x100000000000000000000000000000000"),a=jf(o*t,e),c=jf(-r*t,e);let u=Ki(t-a*n-c*i,e),l=Ki(-a*r-c*o,e);const h=u>s,d=l>s;if(h&&(u=e-u),d&&(l=e-l),u>s||l>s)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:h,k1:u,k2neg:d,k2:l}}}},ci);BigInt(0),Kf.ProjectivePoint;const Hf=Mo.utils.randomPrivateKey,Vf=()=>{const t=Mo.utils.randomPrivateKey(),e=Gf(t),n=new Uint8Array(64);return n.set(t),n.set(e,32),{publicKey:e,secretKey:n}},Gf=Mo.getPublicKey;function Jf(t){try{return Mo.ExtendedPoint.fromHex(t),!0}catch{return!1}}const Zf=(t,e)=>Mo.sign(t,e.slice(0,32)),Yf=Mo.verify,Xf=t=>cr.Buffer.isBuffer(t)?t:t instanceof Uint8Array?cr.Buffer.from(t.buffer,t.byteOffset,t.byteLength):cr.Buffer.from(t);class Qf{constructor(t){Object.assign(this,t)}encode(){return cr.Buffer.from(ws(tp,this))}static decode(t){return ks(tp,this,t)}static decodeUnchecked(t){return ss(tp,this,t)}}const tp=new Map;var ep;const np=32;let rp=1;class ip extends Qf{constructor(t){if(super({}),this._bn=void 0,function(t){return void 0!==t._bn}(t))this._bn=t._bn;else{if("string"==typeof t){const e=zo.decode(t);if(e.length!=np)throw new Error("Invalid public key input");this._bn=new Ro(e)}else this._bn=new Ro(t);if(this._bn.byteLength()>np)throw new Error("Invalid public key input")}}static unique(){const t=new ip(rp);return rp+=1,new ip(t.toBuffer())}equals(t){return this._bn.eq(t._bn)}toBase58(){return zo.encode(this.toBytes())}toJSON(){return this.toBase58()}toBytes(){const t=this.toBuffer();return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}toBuffer(){const t=this._bn.toArrayLike(cr.Buffer);if(t.length===np)return t;const e=cr.Buffer.alloc(32);return t.copy(e,32-t.length),e}get[Symbol.toStringTag](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(t,e,n){const r=cr.Buffer.concat([t.toBuffer(),cr.Buffer.from(e),n.toBuffer()]),i=$o(r);return new ip(i)}static createProgramAddressSync(t,e){let n=cr.Buffer.alloc(0);t.forEach((function(t){if(t.length>32)throw new TypeError("Max seed length exceeded");n=cr.Buffer.concat([n,Xf(t)])})),n=cr.Buffer.concat([n,e.toBuffer(),cr.Buffer.from("ProgramDerivedAddress")]);const r=$o(n);if(Jf(r))throw new Error("Invalid seeds, address must fall off the curve");return new ip(r)}static async createProgramAddress(t,e){return this.createProgramAddressSync(t,e)}static findProgramAddressSync(t,e){let n,r=255;for(;0!=r;){try{const i=t.concat(cr.Buffer.from([r]));n=this.createProgramAddressSync(i,e)}catch(t){if(t instanceof TypeError)throw t;r--;continue}return[n,r]}throw new Error("Unable to find a viable program address nonce")}static async findProgramAddress(t,e){return this.findProgramAddressSync(t,e)}static isOnCurve(t){return Jf(new ip(t).toBytes())}}ep=ip,ip.default=new ep("11111111111111111111111111111111"),tp.set(ip,{kind:"struct",fields:[["_bn","u256"]]});const op=new ip("BPFLoader1111111111111111111111111111111111"),sp=1232,ap=127;class cp extends Error{constructor(t){super(`Signature ${t} has expired: block height exceeded.`),this.signature=void 0,this.signature=t}}Object.defineProperty(cp.prototype,"name",{value:"TransactionExpiredBlockheightExceededError"});class up extends Error{constructor(t,e){super(`Transaction was not confirmed in ${e.toFixed(2)} seconds. It is unknown if it succeeded or failed. Check signature ${t} using the Solana Explorer or CLI tools.`),this.signature=void 0,this.signature=t}}Object.defineProperty(up.prototype,"name",{value:"TransactionExpiredTimeoutError"});class lp extends Error{constructor(t){super(`Signature ${t} has expired: the nonce is no longer valid.`),this.signature=void 0,this.signature=t}}Object.defineProperty(lp.prototype,"name",{value:"TransactionExpiredNonceInvalidError"});class hp{constructor(t,e){this.staticAccountKeys=void 0,this.accountKeysFromLookups=void 0,this.staticAccountKeys=t,this.accountKeysFromLookups=e}keySegments(){const t=[this.staticAccountKeys];return this.accountKeysFromLookups&&(t.push(this.accountKeysFromLookups.writable),t.push(this.accountKeysFromLookups.readonly)),t}get(t){for(const e of this.keySegments()){if(t<e.length)return e[t];t-=e.length}}get length(){return this.keySegments().flat().length}compileInstructions(t){if(this.length>256)throw new Error("Account index overflow encountered during compilation");const e=new Map;this.keySegments().flat().forEach(((t,n)=>{e.set(t.toBase58(),n)}));const n=t=>{const n=e.get(t.toBase58());if(void 0===n)throw new Error("Encountered an unknown instruction account key during compilation");return n};return t.map((t=>({programIdIndex:n(t.programId),accountKeyIndexes:t.keys.map((t=>n(t.pubkey))),data:t.data})))}}const dp=(t="publicKey")=>ga(32,t),fp=(t="signature")=>ga(64,t),pp=(t="string")=>{const e=fa([la("length"),la("lengthPadding"),ga(aa(la(),-8),"chars")],t),n=e.decode.bind(e),r=e.encode.bind(e),i=e;return i.decode=(t,e)=>n(t,e).chars.toString(),i.encode=(t,e,n)=>{const i={chars:cr.Buffer.from(t,"utf8")};return r(i,e,n)},i.alloc=t=>la().span+la().span+cr.Buffer.from(t,"utf8").length,i};function gp(t,e){const n=t=>{if(t.span>=0)return t.span;if("function"==typeof t.alloc)return t.alloc(e[t.property]);if("count"in t&&"elementLayout"in t){const r=e[t.property];if(Array.isArray(r))return r.length*n(t.elementLayout)}else if("fields"in t)return gp({layout:t},e[t.property]);return 0};let r=0;return t.layout.fields.forEach((t=>{r+=n(t)})),r}function mp(t){let e=0,n=0;for(;;){let r=t.shift();if(e|=(127&r)<<7*n,n+=1,!(128&r))break}return e}function yp(t,e){let n=e;for(;;){let e=127&n;if(n>>=7,0==n){t.push(e);break}e|=128,t.push(e)}}function bp(t,e){if(!t)throw new Error(e||"Assertion failed")}class wp{constructor(t,e){this.payer=void 0,this.keyMetaMap=void 0,this.payer=t,this.keyMetaMap=e}static compile(t,e){const n=new Map,r=t=>{const e=t.toBase58();let r=n.get(e);return void 0===r&&(r={isSigner:!1,isWritable:!1,isInvoked:!1},n.set(e,r)),r},i=r(e);i.isSigner=!0,i.isWritable=!0;for(const e of t){r(e.programId).isInvoked=!0;for(const t of e.keys){const e=r(t.pubkey);e.isSigner||=t.isSigner,e.isWritable||=t.isWritable}}return new wp(e,n)}getMessageComponents(){const t=[...this.keyMetaMap.entries()];bp(t.length<=256,"Max static account keys length exceeded");const e=t.filter((([,t])=>t.isSigner&&t.isWritable)),n=t.filter((([,t])=>t.isSigner&&!t.isWritable)),r=t.filter((([,t])=>!t.isSigner&&t.isWritable)),i=t.filter((([,t])=>!t.isSigner&&!t.isWritable)),o={numRequiredSignatures:e.length+n.length,numReadonlySignedAccounts:n.length,numReadonlyUnsignedAccounts:i.length};{bp(e.length>0,"Expected at least one writable signer key");const[t]=e[0];bp(t===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}return[o,[...e.map((([t])=>new ip(t))),...n.map((([t])=>new ip(t))),...r.map((([t])=>new ip(t))),...i.map((([t])=>new ip(t)))]]}extractTableLookup(t){const[e,n]=this.drainKeysFoundInLookupTable(t.state.addresses,(t=>!t.isSigner&&!t.isInvoked&&t.isWritable)),[r,i]=this.drainKeysFoundInLookupTable(t.state.addresses,(t=>!t.isSigner&&!t.isInvoked&&!t.isWritable));if(0!==e.length||0!==r.length)return[{accountKey:t.key,writableIndexes:e,readonlyIndexes:r},{writable:n,readonly:i}]}drainKeysFoundInLookupTable(t,e){const n=new Array,r=new Array;for(const[i,o]of this.keyMetaMap.entries())if(e(o)){const e=new ip(i),o=t.findIndex((t=>t.equals(e)));o>=0&&(bp(o<256,"Max lookup table index exceeded"),n.push(o),r.push(e),this.keyMetaMap.delete(i))}return[n,r]}}const vp="Reached end of buffer unexpectedly";function _p(t){if(0===t.length)throw new Error(vp);return t.shift()}function kp(t,...e){const[n]=e;if(2===e.length?n+(e[1]??0)>t.length:n>=t.length)throw new Error(vp);return t.splice(...e)}class Sp{constructor(t){this.header=void 0,this.accountKeys=void 0,this.recentBlockhash=void 0,this.instructions=void 0,this.indexToProgramIds=new Map,this.header=t.header,this.accountKeys=t.accountKeys.map((t=>new ip(t))),this.recentBlockhash=t.recentBlockhash,this.instructions=t.instructions,this.instructions.forEach((t=>this.indexToProgramIds.set(t.programIdIndex,this.accountKeys[t.programIdIndex])))}get version(){return"legacy"}get staticAccountKeys(){return this.accountKeys}get compiledInstructions(){return this.instructions.map((t=>({programIdIndex:t.programIdIndex,accountKeyIndexes:t.accounts,data:zo.decode(t.data)})))}get addressTableLookups(){return[]}getAccountKeys(){return new hp(this.staticAccountKeys)}static compile(t){const e=wp.compile(t.instructions,t.payerKey),[n,r]=e.getMessageComponents(),i=new hp(r).compileInstructions(t.instructions).map((t=>({programIdIndex:t.programIdIndex,accounts:t.accountKeyIndexes,data:zo.encode(t.data)})));return new Sp({header:n,accountKeys:r,recentBlockhash:t.recentBlockhash,instructions:i})}isAccountSigner(t){return t<this.header.numRequiredSignatures}isAccountWritable(t){const e=this.header.numRequiredSignatures;if(t>=this.header.numRequiredSignatures){return t-e<this.accountKeys.length-e-this.header.numReadonlyUnsignedAccounts}return t<e-this.header.numReadonlySignedAccounts}isProgramId(t){return this.indexToProgramIds.has(t)}programIds(){return[...this.indexToProgramIds.values()]}nonProgramIds(){return this.accountKeys.filter(((t,e)=>!this.isProgramId(e)))}serialize(){const t=this.accountKeys.length;let e=[];yp(e,t);const n=this.instructions.map((t=>{const{accounts:e,programIdIndex:n}=t,r=Array.from(zo.decode(t.data));let i=[];yp(i,e.length);let o=[];return yp(o,r.length),{programIdIndex:n,keyIndicesCount:cr.Buffer.from(i),keyIndices:e,dataLength:cr.Buffer.from(o),data:r}}));let r=[];yp(r,n.length);let i=cr.Buffer.alloc(sp);cr.Buffer.from(r).copy(i);let o=r.length;n.forEach((t=>{const e=fa([ca("programIdIndex"),ga(t.keyIndicesCount.length,"keyIndicesCount"),pa(ca("keyIndex"),t.keyIndices.length,"keyIndices"),ga(t.dataLength.length,"dataLength"),pa(ca("userdatum"),t.data.length,"data")]).encode(t,i,o);o+=e})),i=i.slice(0,o);const s=fa([ga(1,"numRequiredSignatures"),ga(1,"numReadonlySignedAccounts"),ga(1,"numReadonlyUnsignedAccounts"),ga(e.length,"keyCount"),pa(dp("key"),t,"keys"),dp("recentBlockhash")]),a={numRequiredSignatures:cr.Buffer.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:cr.Buffer.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:cr.Buffer.from([this.header.numReadonlyUnsignedAccounts]),keyCount:cr.Buffer.from(e),keys:this.accountKeys.map((t=>Xf(t.toBytes()))),recentBlockhash:zo.decode(this.recentBlockhash)};let c=cr.Buffer.alloc(2048);const u=s.encode(a,c);return i.copy(c,u),c.slice(0,u+i.length)}static from(t){let e=[...t];const n=_p(e);if(n!==(n&ap))throw new Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");const r=_p(e),i=_p(e),o=mp(e);let s=[];for(let t=0;t<o;t++){const t=kp(e,0,np);s.push(new ip(cr.Buffer.from(t)))}const a=kp(e,0,np),c=mp(e);let u=[];for(let t=0;t<c;t++){const t=_p(e),n=kp(e,0,mp(e)),r=kp(e,0,mp(e)),i=zo.encode(cr.Buffer.from(r));u.push({programIdIndex:t,accounts:n,data:i})}const l={header:{numRequiredSignatures:n,numReadonlySignedAccounts:r,numReadonlyUnsignedAccounts:i},recentBlockhash:zo.encode(cr.Buffer.from(a)),accountKeys:s,instructions:u};return new Sp(l)}}class xp{constructor(t){this.header=void 0,this.staticAccountKeys=void 0,this.recentBlockhash=void 0,this.compiledInstructions=void 0,this.addressTableLookups=void 0,this.header=t.header,this.staticAccountKeys=t.staticAccountKeys,this.recentBlockhash=t.recentBlockhash,this.compiledInstructions=t.compiledInstructions,this.addressTableLookups=t.addressTableLookups}get version(){return 0}get numAccountKeysFromLookups(){let t=0;for(const e of this.addressTableLookups)t+=e.readonlyIndexes.length+e.writableIndexes.length;return t}getAccountKeys(t){let e;if(t&&"accountKeysFromLookups"in t&&t.accountKeysFromLookups){if(this.numAccountKeysFromLookups!=t.accountKeysFromLookups.writable.length+t.accountKeysFromLookups.readonly.length)throw new Error("Failed to get account keys because of a mismatch in the number of account keys from lookups");e=t.accountKeysFromLookups}else if(t&&"addressLookupTableAccounts"in t&&t.addressLookupTableAccounts)e=this.resolveAddressTableLookups(t.addressLookupTableAccounts);else if(this.addressTableLookups.length>0)throw new Error("Failed to get account keys because address table lookups were not resolved");return new hp(this.staticAccountKeys,e)}isAccountSigner(t){return t<this.header.numRequiredSignatures}isAccountWritable(t){const e=this.header.numRequiredSignatures,n=this.staticAccountKeys.length;if(t>=n){const e=t-n,r=this.addressTableLookups.reduce(((t,e)=>t+e.writableIndexes.length),0);return e<r}if(t>=this.header.numRequiredSignatures){return t-e<n-e-this.header.numReadonlyUnsignedAccounts}return t<e-this.header.numReadonlySignedAccounts}resolveAddressTableLookups(t){const e={writable:[],readonly:[]};for(const n of this.addressTableLookups){const r=t.find((t=>t.key.equals(n.accountKey)));if(!r)throw new Error(`Failed to find address lookup table account for table key ${n.accountKey.toBase58()}`);for(const t of n.writableIndexes){if(!(t<r.state.addresses.length))throw new Error(`Failed to find address for index ${t} in address lookup table ${n.accountKey.toBase58()}`);e.writable.push(r.state.addresses[t])}for(const t of n.readonlyIndexes){if(!(t<r.state.addresses.length))throw new Error(`Failed to find address for index ${t} in address lookup table ${n.accountKey.toBase58()}`);e.readonly.push(r.state.addresses[t])}}return e}static compile(t){const e=wp.compile(t.instructions,t.payerKey),n=new Array,r={writable:new Array,readonly:new Array},i=t.addressLookupTableAccounts||[];for(const t of i){const i=e.extractTableLookup(t);if(void 0!==i){const[t,{writable:e,readonly:o}]=i;n.push(t),r.writable.push(...e),r.readonly.push(...o)}}const[o,s]=e.getMessageComponents(),a=new hp(s,r).compileInstructions(t.instructions);return new xp({header:o,staticAccountKeys:s,recentBlockhash:t.recentBlockhash,compiledInstructions:a,addressTableLookups:n})}serialize(){const t=Array();yp(t,this.staticAccountKeys.length);const e=this.serializeInstructions(),n=Array();yp(n,this.compiledInstructions.length);const r=this.serializeAddressTableLookups(),i=Array();yp(i,this.addressTableLookups.length);const o=fa([ca("prefix"),fa([ca("numRequiredSignatures"),ca("numReadonlySignedAccounts"),ca("numReadonlyUnsignedAccounts")],"header"),ga(t.length,"staticAccountKeysLength"),pa(dp(),this.staticAccountKeys.length,"staticAccountKeys"),dp("recentBlockhash"),ga(n.length,"instructionsLength"),ga(e.length,"serializedInstructions"),ga(i.length,"addressTableLookupsLength"),ga(r.length,"serializedAddressTableLookups")]),s=new Uint8Array(sp),a=o.encode({prefix:128,header:this.header,staticAccountKeysLength:new Uint8Array(t),staticAccountKeys:this.staticAccountKeys.map((t=>t.toBytes())),recentBlockhash:zo.decode(this.recentBlockhash),instructionsLength:new Uint8Array(n),serializedInstructions:e,addressTableLookupsLength:new Uint8Array(i),serializedAddressTableLookups:r},s);return s.slice(0,a)}serializeInstructions(){let t=0;const e=new Uint8Array(sp);for(const n of this.compiledInstructions){const r=Array();yp(r,n.accountKeyIndexes.length);const i=Array();yp(i,n.data.length);t+=fa([ca("programIdIndex"),ga(r.length,"encodedAccountKeyIndexesLength"),pa(ca(),n.accountKeyIndexes.length,"accountKeyIndexes"),ga(i.length,"encodedDataLength"),ga(n.data.length,"data")]).encode({programIdIndex:n.programIdIndex,encodedAccountKeyIndexesLength:new Uint8Array(r),accountKeyIndexes:n.accountKeyIndexes,encodedDataLength:new Uint8Array(i),data:n.data},e,t)}return e.slice(0,t)}serializeAddressTableLookups(){let t=0;const e=new Uint8Array(sp);for(const n of this.addressTableLookups){const r=Array();yp(r,n.writableIndexes.length);const i=Array();yp(i,n.readonlyIndexes.length);t+=fa([dp("accountKey"),ga(r.length,"encodedWritableIndexesLength"),pa(ca(),n.writableIndexes.length,"writableIndexes"),ga(i.length,"encodedReadonlyIndexesLength"),pa(ca(),n.readonlyIndexes.length,"readonlyIndexes")]).encode({accountKey:n.accountKey.toBytes(),encodedWritableIndexesLength:new Uint8Array(r),writableIndexes:n.writableIndexes,encodedReadonlyIndexesLength:new Uint8Array(i),readonlyIndexes:n.readonlyIndexes},e,t)}return e.slice(0,t)}static deserialize(t){let e=[...t];const n=_p(e),r=n&ap;bp(n!==r,"Expected versioned message but received legacy message");bp(0===r,`Expected versioned message with version 0 but found version ${r}`);const i={numRequiredSignatures:_p(e),numReadonlySignedAccounts:_p(e),numReadonlyUnsignedAccounts:_p(e)},o=[],s=mp(e);for(let t=0;t<s;t++)o.push(new ip(kp(e,0,np)));const a=zo.encode(kp(e,0,np)),c=mp(e),u=[];for(let t=0;t<c;t++){const t=_p(e),n=kp(e,0,mp(e)),r=mp(e),i=new Uint8Array(kp(e,0,r));u.push({programIdIndex:t,accountKeyIndexes:n,data:i})}const l=mp(e),h=[];for(let t=0;t<l;t++){const t=new ip(kp(e,0,np)),n=kp(e,0,mp(e)),r=kp(e,0,mp(e));h.push({accountKey:t,writableIndexes:n,readonlyIndexes:r})}return new xp({header:i,staticAccountKeys:o,recentBlockhash:a,compiledInstructions:u,addressTableLookups:h})}}const Ep={deserializeMessageVersion(t){const e=t[0],n=e&ap;return n===e?"legacy":n},deserialize:t=>{const e=Ep.deserializeMessageVersion(t);if("legacy"===e)return Sp.from(t);if(0===e)return xp.deserialize(t);throw new Error(`Transaction message version ${e} deserialization is not supported`)}};let Ip=function(t){return t[t.BLOCKHEIGHT_EXCEEDED=0]="BLOCKHEIGHT_EXCEEDED",t[t.PROCESSED=1]="PROCESSED",t[t.TIMED_OUT=2]="TIMED_OUT",t[t.NONCE_INVALID=3]="NONCE_INVALID",t}({});const Ap=cr.Buffer.alloc(64).fill(0);class Bp{constructor(t){this.keys=void 0,this.programId=void 0,this.data=cr.Buffer.alloc(0),this.programId=t.programId,this.keys=t.keys,t.data&&(this.data=t.data)}toJSON(){return{keys:this.keys.map((({pubkey:t,isSigner:e,isWritable:n})=>({pubkey:t.toJSON(),isSigner:e,isWritable:n}))),programId:this.programId.toJSON(),data:[...this.data]}}}class Pp{get signature(){return this.signatures.length>0?this.signatures[0].signature:null}constructor(t){if(this.signatures=[],this.feePayer=void 0,this.instructions=[],this.recentBlockhash=void 0,this.lastValidBlockHeight=void 0,this.nonceInfo=void 0,this.minNonceContextSlot=void 0,this._message=void 0,this._json=void 0,t)if(t.feePayer&&(this.feePayer=t.feePayer),t.signatures&&(this.signatures=t.signatures),Object.prototype.hasOwnProperty.call(t,"nonceInfo")){const{minContextSlot:e,nonceInfo:n}=t;this.minNonceContextSlot=e,this.nonceInfo=n}else if(Object.prototype.hasOwnProperty.call(t,"lastValidBlockHeight")){const{blockhash:e,lastValidBlockHeight:n}=t;this.recentBlockhash=e,this.lastValidBlockHeight=n}else{const{recentBlockhash:e,nonceInfo:n}=t;n&&(this.nonceInfo=n),this.recentBlockhash=e}}toJSON(){return{recentBlockhash:this.recentBlockhash||null,feePayer:this.feePayer?this.feePayer.toJSON():null,nonceInfo:this.nonceInfo?{nonce:this.nonceInfo.nonce,nonceInstruction:this.nonceInfo.nonceInstruction.toJSON()}:null,instructions:this.instructions.map((t=>t.toJSON())),signers:this.signatures.map((({publicKey:t})=>t.toJSON()))}}add(...t){if(0===t.length)throw new Error("No instructions");return t.forEach((t=>{"instructions"in t?this.instructions=this.instructions.concat(t.instructions):"data"in t&&"programId"in t&&"keys"in t?this.instructions.push(t):this.instructions.push(new Bp(t))})),this}compileMessage(){if(this._message&&JSON.stringify(this.toJSON())===JSON.stringify(this._json))return this._message;let t,e,n;if(this.nonceInfo?(t=this.nonceInfo.nonce,e=this.instructions[0]!=this.nonceInfo.nonceInstruction?[this.nonceInfo.nonceInstruction,...this.instructions]:this.instructions):(t=this.recentBlockhash,e=this.instructions),!t)throw new Error("Transaction recentBlockhash required");if(e.length<1&&console.warn("No instructions provided"),this.feePayer)n=this.feePayer;else{if(!(this.signatures.length>0&&this.signatures[0].publicKey))throw new Error("Transaction fee payer required");n=this.signatures[0].publicKey}for(let t=0;t<e.length;t++)if(void 0===e[t].programId)throw new Error(`Transaction instruction index ${t} has undefined program id`);const r=[],i=[];e.forEach((t=>{t.keys.forEach((t=>{i.push({...t})}));const e=t.programId.toString();r.includes(e)||r.push(e)})),r.forEach((t=>{i.push({pubkey:new ip(t),isSigner:!1,isWritable:!1})}));const o=[];i.forEach((t=>{const e=t.pubkey.toString(),n=o.findIndex((t=>t.pubkey.toString()===e));n>-1?(o[n].isWritable=o[n].isWritable||t.isWritable,o[n].isSigner=o[n].isSigner||t.isSigner):o.push(t)})),o.sort((function(t,e){if(t.isSigner!==e.isSigner)return t.isSigner?-1:1;if(t.isWritable!==e.isWritable)return t.isWritable?-1:1;return t.pubkey.toBase58().localeCompare(e.pubkey.toBase58(),"en",{localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"})}));const s=o.findIndex((t=>t.pubkey.equals(n)));if(s>-1){const[t]=o.splice(s,1);t.isSigner=!0,t.isWritable=!0,o.unshift(t)}else o.unshift({pubkey:n,isSigner:!0,isWritable:!0});for(const t of this.signatures){const e=o.findIndex((e=>e.pubkey.equals(t.publicKey)));if(!(e>-1))throw new Error(`unknown signer: ${t.publicKey.toString()}`);o[e].isSigner||(o[e].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."))}let a=0,c=0,u=0;const l=[],h=[];o.forEach((({pubkey:t,isSigner:e,isWritable:n})=>{e?(l.push(t.toString()),a+=1,n||(c+=1)):(h.push(t.toString()),n||(u+=1))}));const d=l.concat(h),f=e.map((t=>{const{data:e,programId:n}=t;return{programIdIndex:d.indexOf(n.toString()),accounts:t.keys.map((t=>d.indexOf(t.pubkey.toString()))),data:zo.encode(e)}}));return f.forEach((t=>{bp(t.programIdIndex>=0),t.accounts.forEach((t=>bp(t>=0)))})),new Sp({header:{numRequiredSignatures:a,numReadonlySignedAccounts:c,numReadonlyUnsignedAccounts:u},accountKeys:d,recentBlockhash:t,instructions:f})}_compile(){const t=this.compileMessage(),e=t.accountKeys.slice(0,t.header.numRequiredSignatures);if(this.signatures.length===e.length){const n=this.signatures.every(((t,n)=>e[n].equals(t.publicKey)));if(n)return t}return this.signatures=e.map((t=>({signature:null,publicKey:t}))),t}serializeMessage(){return this._compile().serialize()}async getEstimatedFee(t){return(await t.getFeeForMessage(this.compileMessage())).value}setSigners(...t){if(0===t.length)throw new Error("No signers");const e=new Set;this.signatures=t.filter((t=>{const n=t.toString();return!e.has(n)&&(e.add(n),!0)})).map((t=>({signature:null,publicKey:t})))}sign(...t){if(0===t.length)throw new Error("No signers");const e=new Set,n=[];for(const r of t){const t=r.publicKey.toString();e.has(t)||(e.add(t),n.push(r))}this.signatures=n.map((t=>({signature:null,publicKey:t.publicKey})));const r=this._compile();this._partialSign(r,...n)}partialSign(...t){if(0===t.length)throw new Error("No signers");const e=new Set,n=[];for(const r of t){const t=r.publicKey.toString();e.has(t)||(e.add(t),n.push(r))}const r=this._compile();this._partialSign(r,...n)}_partialSign(t,...e){const n=t.serialize();e.forEach((t=>{const e=Zf(n,t.secretKey);this._addSignature(t.publicKey,Xf(e))}))}addSignature(t,e){this._compile(),this._addSignature(t,e)}_addSignature(t,e){bp(64===e.length);const n=this.signatures.findIndex((e=>t.equals(e.publicKey)));if(n<0)throw new Error(`unknown signer: ${t.toString()}`);this.signatures[n].signature=cr.Buffer.from(e)}verifySignatures(t=!0){return!this._getMessageSignednessErrors(this.serializeMessage(),t)}_getMessageSignednessErrors(t,e){const n={};for(const{signature:r,publicKey:i}of this.signatures)null===r?e&&(n.missing||=[]).push(i):Yf(r,t,i.toBytes())||(n.invalid||=[]).push(i);return n.invalid||n.missing?n:void 0}serialize(t){const{requireAllSignatures:e,verifySignatures:n}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},t),r=this.serializeMessage();if(n){const t=this._getMessageSignednessErrors(r,e);if(t){let e="Signature verification failed.";throw t.invalid&&(e+=`\nInvalid signature for public key${1===t.invalid.length?"":"(s)"} [\`${t.invalid.map((t=>t.toBase58())).join("`, `")}\`].`),t.missing&&(e+=`\nMissing signature for public key${1===t.missing.length?"":"(s)"} [\`${t.missing.map((t=>t.toBase58())).join("`, `")}\`].`),new Error(e)}}return this._serialize(r)}_serialize(t){const{signatures:e}=this,n=[];yp(n,e.length);const r=n.length+64*e.length+t.length,i=cr.Buffer.alloc(r);return bp(e.length<256),cr.Buffer.from(n).copy(i,0),e.forEach((({signature:t},e)=>{null!==t&&(bp(64===t.length,"signature has invalid length"),cr.Buffer.from(t).copy(i,n.length+64*e))})),t.copy(i,n.length+64*e.length),bp(i.length<=sp,`Transaction too large: ${i.length} > 1232`),i}get keys(){return bp(1===this.instructions.length),this.instructions[0].keys.map((t=>t.pubkey))}get programId(){return bp(1===this.instructions.length),this.instructions[0].programId}get data(){return bp(1===this.instructions.length),this.instructions[0].data}static from(t){let e=[...t];const n=mp(e);let r=[];for(let t=0;t<n;t++){const t=kp(e,0,64);r.push(zo.encode(cr.Buffer.from(t)))}return Pp.populate(Sp.from(e),r)}static populate(t,e=[]){const n=new Pp;return n.recentBlockhash=t.recentBlockhash,t.header.numRequiredSignatures>0&&(n.feePayer=t.accountKeys[0]),e.forEach(((e,r)=>{const i={signature:e==zo.encode(Ap)?null:zo.decode(e),publicKey:t.accountKeys[r]};n.signatures.push(i)})),t.instructions.forEach((e=>{const r=e.accounts.map((e=>{const r=t.accountKeys[e];return{pubkey:r,isSigner:n.signatures.some((t=>t.publicKey.toString()===r.toString()))||t.isAccountSigner(e),isWritable:t.isAccountWritable(e)}}));n.instructions.push(new Bp({keys:r,programId:t.accountKeys[e.programIdIndex],data:zo.decode(e.data)}))})),n._message=t,n._json=n.toJSON(),n}}class Tp{constructor(t){this.payerKey=void 0,this.instructions=void 0,this.recentBlockhash=void 0,this.payerKey=t.payerKey,this.instructions=t.instructions,this.recentBlockhash=t.recentBlockhash}static decompile(t,e){const{header:n,compiledInstructions:r,recentBlockhash:i}=t,{numRequiredSignatures:o,numReadonlySignedAccounts:s,numReadonlyUnsignedAccounts:a}=n,c=o-s;bp(c>0,"Message header is invalid");const u=t.staticAccountKeys.length-o-a;bp(u>=0,"Message header is invalid");const l=t.getAccountKeys(e),h=l.get(0);if(void 0===h)throw new Error("Failed to decompile message because no account keys were found");const d=[];for(const t of r){const e=[];for(const r of t.accountKeyIndexes){const t=l.get(r);if(void 0===t)throw new Error(`Failed to find key for account key index ${r}`);let i;i=r<o?r<c:r<l.staticAccountKeys.length?r-o<u:r-l.staticAccountKeys.length<l.accountKeysFromLookups.writable.length,e.push({pubkey:t,isSigner:r<n.numRequiredSignatures,isWritable:i})}const r=l.get(t.programIdIndex);if(void 0===r)throw new Error(`Failed to find program id for program id index ${t.programIdIndex}`);d.push(new Bp({programId:r,data:Xf(t.data),keys:e}))}return new Tp({payerKey:h,instructions:d,recentBlockhash:i})}compileToLegacyMessage(){return Sp.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions})}compileToV0Message(t){return xp.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions,addressLookupTableAccounts:t})}}class Mp{get version(){return this.message.version}constructor(t,e){if(this.signatures=void 0,this.message=void 0,void 0!==e)bp(e.length===t.header.numRequiredSignatures,"Expected signatures length to be equal to the number of required signatures"),this.signatures=e;else{const e=[];for(let n=0;n<t.header.numRequiredSignatures;n++)e.push(new Uint8Array(64));this.signatures=e}this.message=t}serialize(){const t=this.message.serialize(),e=Array();yp(e,this.signatures.length);const n=fa([ga(e.length,"encodedSignaturesLength"),pa(fp(),this.signatures.length,"signatures"),ga(t.length,"serializedMessage")]),r=new Uint8Array(2048),i=n.encode({encodedSignaturesLength:new Uint8Array(e),signatures:this.signatures,serializedMessage:t},r);return r.slice(0,i)}static deserialize(t){let e=[...t];const n=[],r=mp(e);for(let t=0;t<r;t++)n.push(new Uint8Array(kp(e,0,64)));const i=Ep.deserialize(new Uint8Array(e));return new Mp(i,n)}sign(t){const e=this.message.serialize(),n=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures);for(const r of t){const t=n.findIndex((t=>t.equals(r.publicKey)));bp(t>=0,`Cannot sign with non signer key ${r.publicKey.toBase58()}`),this.signatures[t]=Zf(e,r.secretKey)}}addSignature(t,e){bp(64===e.byteLength,"Signature must be 64 bytes long");const n=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures).findIndex((e=>e.equals(t)));bp(n>=0,`Can not add signature; \`${t.toBase58()}\` is not required to sign this transaction`),this.signatures[n]=e}}const Cp=new ip("SysvarC1ock11111111111111111111111111111111"),Op=new ip("SysvarEpochSchedu1e111111111111111111111111"),Rp=new ip("Sysvar1nstructions1111111111111111111111111"),Lp=new ip("SysvarRecentB1ockHashes11111111111111111111"),Np=new ip("SysvarRent111111111111111111111111111111111"),Up=new ip("SysvarRewards111111111111111111111111111111"),zp=new ip("SysvarS1otHashes111111111111111111111111111"),$p=new ip("SysvarS1otHistory11111111111111111111111111"),Wp=new ip("SysvarStakeHistory1111111111111111111111111");class Fp extends Error{constructor({action:t,signature:e,transactionMessage:n,logs:r}){const i=r?`Logs: \n${JSON.stringify(r.slice(-10),null,2)}. `:"",o="\nCatch the `SendTransactionError` and call `getLogs()` on it for full details.";let s;switch(t){case"send":s=`Transaction ${e} resulted in an error. \n${n}. `+i+o;break;case"simulate":s=`Simulation failed. \nMessage: ${n}. \n`+i+o;break;default:s=`Unknown action '${t}'`}super(s),this.signature=void 0,this.transactionMessage=void 0,this.transactionLogs=void 0,this.signature=e,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(){const t=this.transactionLogs;if(null==t||"object"!=typeof t||!("then"in t))return t}async getLogs(t){return Array.isArray(this.transactionLogs)||(this.transactionLogs=new Promise(((e,n)=>{t.getTransaction(this.signature).then((t=>{if(t&&t.meta&&t.meta.logMessages){const n=t.meta.logMessages;this.transactionLogs=n,e(n)}else n(new Error("Log messages not found"))})).catch(n)}))),await this.transactionLogs}}class Dp extends Error{constructor({code:t,message:e,data:n},r){super(null!=r?`${r}: ${e}`:e),this.code=void 0,this.data=void 0,this.code=t,this.data=n,this.name="SolanaJSONRPCError"}}async function jp(t,e,n,r){const i=r&&{skipPreflight:r.skipPreflight,preflightCommitment:r.preflightCommitment||r.commitment,maxRetries:r.maxRetries,minContextSlot:r.minContextSlot},o=await t.sendTransaction(e,n,i);let s;if(null!=e.recentBlockhash&&null!=e.lastValidBlockHeight)s=(await t.confirmTransaction({abortSignal:r?.abortSignal,signature:o,blockhash:e.recentBlockhash,lastValidBlockHeight:e.lastValidBlockHeight},r&&r.commitment)).value;else if(null!=e.minNonceContextSlot&&null!=e.nonceInfo){const{nonceInstruction:n}=e.nonceInfo,i=n.keys[0].pubkey;s=(await t.confirmTransaction({abortSignal:r?.abortSignal,minContextSlot:e.minNonceContextSlot,nonceAccountPubkey:i,nonceValue:e.nonceInfo.nonce,signature:o},r&&r.commitment)).value}else null!=r?.abortSignal&&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."),s=(await t.confirmTransaction(o,r&&r.commitment)).value;if(s.err){if(null!=o)throw new Fp({action:"send",signature:o,transactionMessage:`Status: (${JSON.stringify(s)})`});throw new Error(`Transaction ${o} failed (${JSON.stringify(s)})`)}return o}function qp(t){return new Promise((e=>setTimeout(e,t)))}function Kp(t,e){const n=t.layout.span>=0?t.layout.span:gp(t,e),r=cr.Buffer.alloc(n),i=Object.assign({instruction:t.index},e);return t.layout.encode(i,r),r}function Hp(t,e){let n;try{n=t.layout.decode(e)}catch(t){throw new Error("invalid instruction; "+t)}if(n.instruction!==t.index)throw new Error(`invalid instruction; instruction index mismatch ${n.instruction} != ${t.index}`);return n}const Vp=ha("lamportsPerSignature"),Gp=fa([la("version"),la("state"),dp("authorizedPubkey"),dp("nonce"),fa([Vp],"feeCalculator")]),Jp=Gp.span;class Zp{constructor(t){this.authorizedPubkey=void 0,this.nonce=void 0,this.feeCalculator=void 0,this.authorizedPubkey=t.authorizedPubkey,this.nonce=t.nonce,this.feeCalculator=t.feeCalculator}static fromAccountData(t){const e=Gp.decode(Xf(t),0);return new Zp({authorizedPubkey:new ip(e.authorizedPubkey),nonce:new ip(e.nonce).toString(),feeCalculator:e.feeCalculator})}}function Yp(t){const e=ga(8,t),n=e.decode.bind(e),r=e.encode.bind(e),i=e,o=Qh();return i.decode=(t,e)=>{const r=n(t,e);return o.decode(r)},i.encode=(t,e,n)=>{const i=o.encode(t);return r(i,e,n)},i}const Xp=Object.freeze({Create:{index:0,layout:fa([la("instruction"),da("lamports"),da("space"),dp("programId")])},Assign:{index:1,layout:fa([la("instruction"),dp("programId")])},Transfer:{index:2,layout:fa([la("instruction"),Yp("lamports")])},CreateWithSeed:{index:3,layout:fa([la("instruction"),dp("base"),pp("seed"),da("lamports"),da("space"),dp("programId")])},AdvanceNonceAccount:{index:4,layout:fa([la("instruction")])},WithdrawNonceAccount:{index:5,layout:fa([la("instruction"),da("lamports")])},InitializeNonceAccount:{index:6,layout:fa([la("instruction"),dp("authorized")])},AuthorizeNonceAccount:{index:7,layout:fa([la("instruction"),dp("authorized")])},Allocate:{index:8,layout:fa([la("instruction"),da("space")])},AllocateWithSeed:{index:9,layout:fa([la("instruction"),dp("base"),pp("seed"),da("space"),dp("programId")])},AssignWithSeed:{index:10,layout:fa([la("instruction"),dp("base"),pp("seed"),dp("programId")])},TransferWithSeed:{index:11,layout:fa([la("instruction"),Yp("lamports"),pp("seed"),dp("programId")])},UpgradeNonceAccount:{index:12,layout:fa([la("instruction")])}});class Qp{constructor(){}static createAccount(t){const e=Kp(Xp.Create,{lamports:t.lamports,space:t.space,programId:Xf(t.programId.toBuffer())});return new Bp({keys:[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.newAccountPubkey,isSigner:!0,isWritable:!0}],programId:this.programId,data:e})}static transfer(t){let e,n;if("basePubkey"in t){e=Kp(Xp.TransferWithSeed,{lamports:BigInt(t.lamports),seed:t.seed,programId:Xf(t.programId.toBuffer())}),n=[{pubkey:t.fromPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0}]}else{e=Kp(Xp.Transfer,{lamports:BigInt(t.lamports)}),n=[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0}]}return new Bp({keys:n,programId:this.programId,data:e})}static assign(t){let e,n;if("basePubkey"in t){e=Kp(Xp.AssignWithSeed,{base:Xf(t.basePubkey.toBuffer()),seed:t.seed,programId:Xf(t.programId.toBuffer())}),n=[{pubkey:t.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1}]}else{e=Kp(Xp.Assign,{programId:Xf(t.programId.toBuffer())}),n=[{pubkey:t.accountPubkey,isSigner:!0,isWritable:!0}]}return new Bp({keys:n,programId:this.programId,data:e})}static createAccountWithSeed(t){const e=Kp(Xp.CreateWithSeed,{base:Xf(t.basePubkey.toBuffer()),seed:t.seed,lamports:t.lamports,space:t.space,programId:Xf(t.programId.toBuffer())});let n=[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.newAccountPubkey,isSigner:!1,isWritable:!0}];return t.basePubkey.equals(t.fromPubkey)||n.push({pubkey:t.basePubkey,isSigner:!0,isWritable:!1}),new Bp({keys:n,programId:this.programId,data:e})}static createNonceAccount(t){const e=new Pp;"basePubkey"in t&&"seed"in t?e.add(Qp.createAccountWithSeed({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,basePubkey:t.basePubkey,seed:t.seed,lamports:t.lamports,space:Jp,programId:this.programId})):e.add(Qp.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,lamports:t.lamports,space:Jp,programId:this.programId}));const n={noncePubkey:t.noncePubkey,authorizedPubkey:t.authorizedPubkey};return e.add(this.nonceInitialize(n)),e}static nonceInitialize(t){const e=Kp(Xp.InitializeNonceAccount,{authorized:Xf(t.authorizedPubkey.toBuffer())}),n={keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:Lp,isSigner:!1,isWritable:!1},{pubkey:Np,isSigner:!1,isWritable:!1}],programId:this.programId,data:e};return new Bp(n)}static nonceAdvance(t){const e=Kp(Xp.AdvanceNonceAccount),n={keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:Lp,isSigner:!1,isWritable:!1},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:e};return new Bp(n)}static nonceWithdraw(t){const e=Kp(Xp.WithdrawNonceAccount,{lamports:t.lamports});return new Bp({keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0},{pubkey:Lp,isSigner:!1,isWritable:!1},{pubkey:Np,isSigner:!1,isWritable:!1},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:e})}static nonceAuthorize(t){const e=Kp(Xp.AuthorizeNonceAccount,{authorized:Xf(t.newAuthorizedPubkey.toBuffer())});return new Bp({keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:e})}static allocate(t){let e,n;if("basePubkey"in t){e=Kp(Xp.AllocateWithSeed,{base:Xf(t.basePubkey.toBuffer()),seed:t.seed,space:t.space,programId:Xf(t.programId.toBuffer())}),n=[{pubkey:t.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1}]}else{e=Kp(Xp.Allocate,{space:t.space}),n=[{pubkey:t.accountPubkey,isSigner:!0,isWritable:!0}]}return new Bp({keys:n,programId:this.programId,data:e})}}Qp.programId=new ip("11111111111111111111111111111111");class tg{constructor(){}static getMinNumSignatures(t){return 2*(Math.ceil(t/tg.chunkSize)+1+1)}static async load(t,e,n,r,i){{const o=await t.getMinimumBalanceForRentExemption(i.length),s=await t.getAccountInfo(n.publicKey,"confirmed");let a=null;if(null!==s){if(s.executable)return console.error("Program load failed, account is already executable"),!1;s.data.length!==i.length&&(a=a||new Pp,a.add(Qp.allocate({accountPubkey:n.publicKey,space:i.length}))),s.owner.equals(r)||(a=a||new Pp,a.add(Qp.assign({accountPubkey:n.publicKey,programId:r}))),s.lamports<o&&(a=a||new Pp,a.add(Qp.transfer({fromPubkey:e.publicKey,toPubkey:n.publicKey,lamports:o-s.lamports})))}else a=(new Pp).add(Qp.createAccount({fromPubkey:e.publicKey,newAccountPubkey:n.publicKey,lamports:o>0?o:1,space:i.length,programId:r}));null!==a&&await jp(t,a,[e,n],{commitment:"confirmed"})}const o=fa([la("instruction"),la("offset"),la("bytesLength"),la("bytesLengthPadding"),pa(ca("byte"),aa(la(),-8),"bytes")]),s=tg.chunkSize;let a=0,c=i,u=[];for(;c.length>0;){const i=c.slice(0,s),l=cr.Buffer.alloc(s+16);o.encode({instruction:0,offset:a,bytes:i,bytesLength:0,bytesLengthPadding:0},l);const h=(new Pp).add({keys:[{pubkey:n.publicKey,isSigner:!0,isWritable:!0}],programId:r,data:l});if(u.push(jp(t,h,[e,n],{commitment:"confirmed"})),t._rpcEndpoint.includes("solana.com")){const t=4;await qp(1e3/t)}a+=s,c=c.slice(s)}await Promise.all(u);{const i=fa([la("instruction")]),o=cr.Buffer.alloc(i.span);i.encode({instruction:1},o);const s=(new Pp).add({keys:[{pubkey:n.publicKey,isSigner:!0,isWritable:!0},{pubkey:Np,isSigner:!1,isWritable:!1}],programId:r,data:o}),a="processed",c=await t.sendTransaction(s,[e,n],{preflightCommitment:a}),{context:u,value:l}=await t.confirmTransaction({signature:c,lastValidBlockHeight:s.lastValidBlockHeight,blockhash:s.recentBlockhash},a);if(l.err)throw new Error(`Transaction ${c} failed (${JSON.stringify(l)})`);for(;;){try{if(await t.getSlot({commitment:a})>u.slot)break}catch{}await new Promise((t=>setTimeout(t,Math.round(200))))}}return!0}}tg.chunkSize=932;const eg=new ip("BPFLoader2111111111111111111111111111111111");function ng(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var rg,ig;function og(){if(ig)return rg;ig=1;var t=Object.prototype.toString,e=Object.keys||function(t){var e=[];for(var n in t)e.push(n);return e};function n(r,i){var o,s,a,c,u,l,h;if(!0===r)return"true";if(!1===r)return"false";switch(typeof r){case"object":if(null===r)return null;if(r.toJSON&&"function"==typeof r.toJSON)return n(r.toJSON(),i);if("[object Array]"===(h=t.call(r))){for(a="[",s=r.length-1,o=0;o<s;o++)a+=n(r[o],!0)+",";return s>-1&&(a+=n(r[o],!0)),a+"]"}if("[object Object]"===h){for(s=(c=e(r).sort()).length,a="",o=0;o<s;)void 0!==(l=n(r[u=c[o]],!1))&&(a&&(a+=","),a+=JSON.stringify(u)+":"+l),o++;return"{"+a+"}"}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 rg=function(t){var e=n(t,!1);if(void 0!==e)return""+e}}var sg=ng(og());function ag(t){let e=0;for(;t>1;)t/=2,e++;return e}class cg{constructor(t,e,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=t,this.leaderScheduleSlotOffset=e,this.warmup=n,this.firstNormalEpoch=r,this.firstNormalSlot=i}getEpoch(t){return this.getEpochAndSlotIndex(t)[0]}getEpochAndSlotIndex(t){if(t<this.firstNormalSlot){const e=ag(function(t){return 0===t?1:(t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,1+(t|=t>>32))}(t+32+1))-ag(32)-1;return[e,t-(this.getSlotsInEpoch(e)-32)]}{const e=t-this.firstNormalSlot,n=Math.floor(e/this.slotsPerEpoch);return[this.firstNormalEpoch+n,e%this.slotsPerEpoch]}}getFirstSlotInEpoch(t){return t<=this.firstNormalEpoch?32*(Math.pow(2,t)-1):(t-this.firstNormalEpoch)*this.slotsPerEpoch+this.firstNormalSlot}getLastSlotInEpoch(t){return this.getFirstSlotInEpoch(t)+this.getSlotsInEpoch(t)-1}getSlotsInEpoch(t){return t<this.firstNormalEpoch?Math.pow(2,t+ag(32)):this.slotsPerEpoch}}var ug=globalThis.fetch;class lg extends hf{constructor(t,e,n){super((t=>{const n=function(t,e){return new uf(t,e)}(t,{autoconnect:!0,max_reconnects:5,reconnect:!0,reconnect_interval:1e3,...e});return this.underlyingSocket="socket"in n?n.socket:n,n}),t,e,n),this.underlyingSocket=void 0}call(...t){const e=this.underlyingSocket?.readyState;return 1===e?super.call(...t):Promise.reject(new Error("Tried to call a JSON-RPC method `"+t[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+e+")"))}notify(...t){const e=this.underlyingSocket?.readyState;return 1===e?super.notify(...t):Promise.reject(new Error("Tried to send a JSON-RPC notification `"+t[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+e+")"))}}class hg{constructor(t){this.key=void 0,this.state=void 0,this.key=t.key,this.state=t.state}isActive(){const t=BigInt("0xffffffffffffffff");return this.state.deactivationSlot===t}static deserialize(t){const e=function(t,e){let n;try{n=t.layout.decode(e)}catch(t){throw new Error("invalid instruction; "+t)}if(n.typeIndex!==t.index)throw new Error(`invalid account data; account type mismatch ${n.typeIndex} != ${t.index}`);return n}(dg,t),n=t.length-56;bp(n>=0,"lookup table is invalid"),bp(n%32==0,"lookup table is invalid");const r=n/32,{addresses:i}=fa([pa(dp(),r,"addresses")]).decode(t.slice(56));return{deactivationSlot:e.deactivationSlot,lastExtendedSlot:e.lastExtendedSlot,lastExtendedSlotStartIndex:e.lastExtendedStartIndex,authority:0!==e.authority.length?new ip(e.authority[0]):void 0,addresses:i.map((t=>new ip(t)))}}}const dg={index:1,layout:fa([la("typeIndex"),Yp("deactivationSlot"),ha("lastExtendedSlot"),ca("lastExtendedStartIndex"),ca(),pa(dp(),aa(ca(),-1),"authority")])},fg=/^[^:]+:\/\/([^:[]+|\[[^\]]+\])(:\d+)?(.*)/i;const pg=Id(gd(ip),_d(),(t=>new ip(t))),gg=kd([_d(),md("base64")]),mg=Id(gd(cr.Buffer),gg,(t=>cr.Buffer.from(t[0],"base64")));function yg(t){let e,n;if("string"==typeof t)e=t;else if(t){const{commitment:r,...i}=t;e=r,n=i}return{commitment:e,config:n}}function bg(t){return t.map((t=>"memcmp"in t?{...t,memcmp:{...t.memcmp,encoding:t.memcmp.encoding??"base58"}}:t))}function wg(t){return xd([Sd({jsonrpc:md("2.0"),id:_d(),result:t}),Sd({jsonrpc:md("2.0"),id:_d(),error:Sd({code:Ed(),message:_d(),data:wd(dd("any",(()=>!0)))})})])}const vg=wg(Ed());function _g(t){return Id(wg(t),vg,(e=>"error"in e?e:{...e,result:ud(e.result,t)}))}function kg(t){return _g(Sd({context:Sd({slot:bd()}),value:t}))}function Sg(t){return Sd({context:Sd({slot:bd()}),value:t})}function xg(t,e){return 0===t?new xp({header:e.header,staticAccountKeys:e.accountKeys.map((t=>new ip(t))),recentBlockhash:e.recentBlockhash,compiledInstructions:e.instructions.map((t=>({programIdIndex:t.programIdIndex,accountKeyIndexes:t.accounts,data:zo.decode(t.data)}))),addressTableLookups:e.addressTableLookups}):new Sp(e)}const Eg=Sd({foundation:bd(),foundationTerm:bd(),initial:bd(),taper:bd(),terminal:bd()}),Ig=_g(fd(yd(Sd({epoch:bd(),effectiveSlot:bd(),amount:bd(),postBalance:bd(),commission:wd(yd(bd()))})))),Ag=fd(Sd({slot:bd(),prioritizationFee:bd()})),Bg=Sd({total:bd(),validator:bd(),foundation:bd(),epoch:bd()}),Pg=Sd({epoch:bd(),slotIndex:bd(),slotsInEpoch:bd(),absoluteSlot:bd(),blockHeight:wd(bd()),transactionCount:wd(bd())}),Tg=Sd({slotsPerEpoch:bd(),leaderScheduleSlotOffset:bd(),warmup:pd(),firstNormalEpoch:bd(),firstNormalSlot:bd()}),Mg=vd(_d(),fd(bd())),Cg=yd(xd([Sd({}),_d()])),Og=Sd({err:Cg}),Rg=md("receivedSignature"),Lg=Sd({"solana-core":_d(),"feature-set":wd(bd())}),Ng=Sd({program:_d(),programId:pg,parsed:Ed()}),Ug=Sd({programId:pg,accounts:fd(pg),data:_d()}),zg=kg(Sd({err:yd(xd([Sd({}),_d()])),logs:yd(fd(_d())),accounts:wd(yd(fd(yd(Sd({executable:pd(),owner:_d(),lamports:bd(),data:fd(_d()),rentEpoch:wd(bd())}))))),unitsConsumed:wd(bd()),returnData:wd(yd(Sd({programId:_d(),data:kd([_d(),md("base64")])}))),innerInstructions:wd(yd(fd(Sd({index:bd(),instructions:fd(xd([Ng,Ug]))}))))})),$g=kg(Sd({byIdentity:vd(_d(),fd(bd())),range:Sd({firstSlot:bd(),lastSlot:bd()})}));const Wg=_g(Eg),Fg=_g(Bg),Dg=_g(Ag),jg=_g(Pg),qg=_g(Tg),Kg=_g(Mg),Hg=_g(bd()),Vg=kg(Sd({total:bd(),circulating:bd(),nonCirculating:bd(),nonCirculatingAccounts:fd(pg)})),Gg=Sd({amount:_d(),uiAmount:yd(bd()),decimals:bd(),uiAmountString:wd(_d())}),Jg=kg(fd(Sd({address:pg,amount:_d(),uiAmount:yd(bd()),decimals:bd(),uiAmountString:wd(_d())}))),Zg=kg(fd(Sd({pubkey:pg,account:Sd({executable:pd(),owner:pg,lamports:bd(),data:mg,rentEpoch:bd()})}))),Yg=Sd({program:_d(),parsed:Ed(),space:bd()}),Xg=kg(fd(Sd({pubkey:pg,account:Sd({executable:pd(),owner:pg,lamports:bd(),data:Yg,rentEpoch:bd()})}))),Qg=kg(fd(Sd({lamports:bd(),address:pg}))),tm=Sd({executable:pd(),owner:pg,lamports:bd(),data:mg,rentEpoch:bd()}),em=Sd({pubkey:pg,account:tm}),nm=Id(xd([gd(cr.Buffer),Yg]),xd([gg,Yg]),(t=>Array.isArray(t)?ud(t,mg):t)),rm=Sd({executable:pd(),owner:pg,lamports:bd(),data:nm,rentEpoch:bd()}),im=Sd({pubkey:pg,account:rm}),om=Sd({state:xd([md("active"),md("inactive"),md("activating"),md("deactivating")]),active:bd(),inactive:bd()}),sm=_g(fd(Sd({signature:_d(),slot:bd(),err:Cg,memo:yd(_d()),blockTime:wd(yd(bd()))}))),am=_g(fd(Sd({signature:_d(),slot:bd(),err:Cg,memo:yd(_d()),blockTime:wd(yd(bd()))}))),cm=Sd({subscription:bd(),result:Sg(tm)}),um=Sd({pubkey:pg,account:tm}),lm=Sd({subscription:bd(),result:Sg(um)}),hm=Sd({parent:bd(),slot:bd(),root:bd()}),dm=Sd({subscription:bd(),result:hm}),fm=xd([Sd({type:xd([md("firstShredReceived"),md("completed"),md("optimisticConfirmation"),md("root")]),slot:bd(),timestamp:bd()}),Sd({type:md("createdBank"),parent:bd(),slot:bd(),timestamp:bd()}),Sd({type:md("frozen"),slot:bd(),timestamp:bd(),stats:Sd({numTransactionEntries:bd(),numSuccessfulTransactions:bd(),numFailedTransactions:bd(),maxTransactionsPerEntry:bd()})}),Sd({type:md("dead"),slot:bd(),timestamp:bd(),err:_d()})]),pm=Sd({subscription:bd(),result:fm}),gm=Sd({subscription:bd(),result:Sg(xd([Og,Rg]))}),mm=Sd({subscription:bd(),result:bd()}),ym=Sd({pubkey:_d(),gossip:yd(_d()),tpu:yd(_d()),rpc:yd(_d()),version:yd(_d())}),bm=Sd({votePubkey:_d(),nodePubkey:_d(),activatedStake:bd(),epochVoteAccount:pd(),epochCredits:fd(kd([bd(),bd(),bd()])),commission:bd(),lastVote:bd(),rootSlot:yd(bd())}),wm=_g(Sd({current:fd(bm),delinquent:fd(bm)})),vm=xd([md("processed"),md("confirmed"),md("finalized")]),_m=Sd({slot:bd(),confirmations:yd(bd()),err:Cg,confirmationStatus:wd(vm)}),km=kg(fd(yd(_m))),Sm=_g(bd()),xm=Sd({accountKey:pg,writableIndexes:fd(bd()),readonlyIndexes:fd(bd())}),Em=Sd({signatures:fd(_d()),message:Sd({accountKeys:fd(_d()),header:Sd({numRequiredSignatures:bd(),numReadonlySignedAccounts:bd(),numReadonlyUnsignedAccounts:bd()}),instructions:fd(Sd({accounts:fd(bd()),data:_d(),programIdIndex:bd()})),recentBlockhash:_d(),addressTableLookups:wd(fd(xm))})}),Im=Sd({pubkey:pg,signer:pd(),writable:pd(),source:wd(xd([md("transaction"),md("lookupTable")]))}),Am=Sd({accountKeys:fd(Im),signatures:fd(_d())}),Bm=Sd({parsed:Ed(),program:_d(),programId:pg}),Pm=Sd({accounts:fd(pg),data:_d(),programId:pg}),Tm=Id(xd([Pm,Bm]),xd([Sd({parsed:Ed(),program:_d(),programId:_d()}),Sd({accounts:fd(_d()),data:_d(),programId:_d()})]),(t=>ud(t,"accounts"in t?Pm:Bm))),Mm=Sd({signatures:fd(_d()),message:Sd({accountKeys:fd(Im),instructions:fd(Tm),recentBlockhash:_d(),addressTableLookups:wd(yd(fd(xm)))})}),Cm=Sd({accountIndex:bd(),mint:_d(),owner:wd(_d()),programId:wd(_d()),uiTokenAmount:Gg}),Om=Sd({writable:fd(pg),readonly:fd(pg)}),Rm=Sd({err:Cg,fee:bd(),innerInstructions:wd(yd(fd(Sd({index:bd(),instructions:fd(Sd({accounts:fd(bd()),data:_d(),programIdIndex:bd()}))})))),preBalances:fd(bd()),postBalances:fd(bd()),logMessages:wd(yd(fd(_d()))),preTokenBalances:wd(yd(fd(Cm))),postTokenBalances:wd(yd(fd(Cm))),loadedAddresses:wd(Om),computeUnitsConsumed:wd(bd())}),Lm=Sd({err:Cg,fee:bd(),innerInstructions:wd(yd(fd(Sd({index:bd(),instructions:fd(Tm)})))),preBalances:fd(bd()),postBalances:fd(bd()),logMessages:wd(yd(fd(_d()))),preTokenBalances:wd(yd(fd(Cm))),postTokenBalances:wd(yd(fd(Cm))),loadedAddresses:wd(Om),computeUnitsConsumed:wd(bd())}),Nm=xd([md(0),md("legacy")]),Um=Sd({pubkey:_d(),lamports:bd(),postBalance:yd(bd()),rewardType:yd(_d()),commission:wd(yd(bd()))}),zm=_g(yd(Sd({blockhash:_d(),previousBlockhash:_d(),parentSlot:bd(),transactions:fd(Sd({transaction:Em,meta:yd(Rm),version:wd(Nm)})),rewards:wd(fd(Um)),blockTime:yd(bd()),blockHeight:yd(bd())}))),$m=_g(yd(Sd({blockhash:_d(),previousBlockhash:_d(),parentSlot:bd(),rewards:wd(fd(Um)),blockTime:yd(bd()),blockHeight:yd(bd())}))),Wm=_g(yd(Sd({blockhash:_d(),previousBlockhash:_d(),parentSlot:bd(),transactions:fd(Sd({transaction:Am,meta:yd(Rm),version:wd(Nm)})),rewards:wd(fd(Um)),blockTime:yd(bd()),blockHeight:yd(bd())}))),Fm=_g(yd(Sd({blockhash:_d(),previousBlockhash:_d(),parentSlot:bd(),transactions:fd(Sd({transaction:Mm,meta:yd(Lm),version:wd(Nm)})),rewards:wd(fd(Um)),blockTime:yd(bd()),blockHeight:yd(bd())}))),Dm=_g(yd(Sd({blockhash:_d(),previousBlockhash:_d(),parentSlot:bd(),transactions:fd(Sd({transaction:Am,meta:yd(Lm),version:wd(Nm)})),rewards:wd(fd(Um)),blockTime:yd(bd()),blockHeight:yd(bd())}))),jm=_g(yd(Sd({blockhash:_d(),previousBlockhash:_d(),parentSlot:bd(),rewards:wd(fd(Um)),blockTime:yd(bd()),blockHeight:yd(bd())}))),qm=_g(yd(Sd({blockhash:_d(),previousBlockhash:_d(),parentSlot:bd(),transactions:fd(Sd({transaction:Em,meta:yd(Rm)})),rewards:wd(fd(Um)),blockTime:yd(bd())}))),Km=_g(yd(Sd({blockhash:_d(),previousBlockhash:_d(),parentSlot:bd(),signatures:fd(_d()),blockTime:yd(bd())}))),Hm=_g(yd(Sd({slot:bd(),meta:yd(Rm),blockTime:wd(yd(bd())),transaction:Em,version:wd(Nm)}))),Vm=_g(yd(Sd({slot:bd(),transaction:Mm,meta:yd(Lm),blockTime:wd(yd(bd())),version:wd(Nm)}))),Gm=kg(Sd({blockhash:_d(),lastValidBlockHeight:bd()})),Jm=kg(pd()),Zm=_g(fd(Sd({slot:bd(),numTransactions:bd(),numSlots:bd(),samplePeriodSecs:bd()}))),Ym=kg(yd(Sd({feeCalculator:Sd({lamportsPerSignature:bd()})}))),Xm=_g(_d()),Qm=_g(_d()),ty=Sd({err:Cg,logs:fd(_d()),signature:_d()}),ey=Sd({result:Sg(ty),subscription:bd()}),ny={"solana-client":"js/1.0.0-maintenance"};class ry{constructor(t){this._keypair=void 0,this._keypair=t??Vf()}static generate(){return new ry(Vf())}static fromSecretKey(t,e){if(64!==t.byteLength)throw new Error("bad secret key size");const n=t.slice(32,64);if(!e||!e.skipValidation){const e=t.slice(0,32),r=Gf(e);for(let t=0;t<32;t++)if(n[t]!==r[t])throw new Error("provided secretKey is invalid")}return new ry({publicKey:n,secretKey:t})}static fromSeed(t){const e=Gf(t),n=new Uint8Array(64);return n.set(t),n.set(e,32),new ry({publicKey:e,secretKey:n})}get publicKey(){return new ip(this._keypair.publicKey)}get secretKey(){return new Uint8Array(this._keypair.secretKey)}}const iy=Object.freeze({CreateLookupTable:{index:0,layout:fa([la("instruction"),Yp("recentSlot"),ca("bumpSeed")])},FreezeLookupTable:{index:1,layout:fa([la("instruction")])},ExtendLookupTable:{index:2,layout:fa([la("instruction"),Yp(),pa(dp(),aa(la(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:fa([la("instruction")])},CloseLookupTable:{index:4,layout:fa([la("instruction")])}});class oy{constructor(){}static createLookupTable(t){const[e,n]=ip.findProgramAddressSync([t.authority.toBuffer(),Xh().encode(t.recentSlot)],this.programId),r=Kp(iy.CreateLookupTable,{recentSlot:BigInt(t.recentSlot),bumpSeed:n}),i=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1},{pubkey:t.payer,isSigner:!0,isWritable:!0},{pubkey:Qp.programId,isSigner:!1,isWritable:!1}];return[new Bp({programId:this.programId,keys:i,data:r}),e]}static freezeLookupTable(t){const e=Kp(iy.FreezeLookupTable),n=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1}];return new Bp({programId:this.programId,keys:n,data:e})}static extendLookupTable(t){const e=Kp(iy.ExtendLookupTable,{addresses:t.addresses.map((t=>t.toBytes()))}),n=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1}];return t.payer&&n.push({pubkey:t.payer,isSigner:!0,isWritable:!0},{pubkey:Qp.programId,isSigner:!1,isWritable:!1}),new Bp({programId:this.programId,keys:n,data:e})}static deactivateLookupTable(t){const e=Kp(iy.DeactivateLookupTable),n=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1}];return new Bp({programId:this.programId,keys:n,data:e})}static closeLookupTable(t){const e=Kp(iy.CloseLookupTable),n=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1},{pubkey:t.recipient,isSigner:!1,isWritable:!0}];return new Bp({programId:this.programId,keys:n,data:e})}}oy.programId=new ip("AddressLookupTab1e1111111111111111111111111");const sy=Object.freeze({RequestUnits:{index:0,layout:fa([ca("instruction"),la("units"),la("additionalFee")])},RequestHeapFrame:{index:1,layout:fa([ca("instruction"),la("bytes")])},SetComputeUnitLimit:{index:2,layout:fa([ca("instruction"),la("units")])},SetComputeUnitPrice:{index:3,layout:fa([ca("instruction"),Yp("microLamports")])}});class ay{constructor(){}static requestUnits(t){const e=Kp(sy.RequestUnits,t);return new Bp({keys:[],programId:this.programId,data:e})}static requestHeapFrame(t){const e=Kp(sy.RequestHeapFrame,t);return new Bp({keys:[],programId:this.programId,data:e})}static setComputeUnitLimit(t){const e=Kp(sy.SetComputeUnitLimit,t);return new Bp({keys:[],programId:this.programId,data:e})}static setComputeUnitPrice(t){const e=Kp(sy.SetComputeUnitPrice,{microLamports:BigInt(t.microLamports)});return new Bp({keys:[],programId:this.programId,data:e})}}ay.programId=new ip("ComputeBudget111111111111111111111111111111");const cy=fa([ca("numSignatures"),ca("padding"),ua("signatureOffset"),ua("signatureInstructionIndex"),ua("publicKeyOffset"),ua("publicKeyInstructionIndex"),ua("messageDataOffset"),ua("messageDataSize"),ua("messageInstructionIndex")]);class uy{constructor(){}static createInstructionWithPublicKey(t){const{publicKey:e,message:n,signature:r,instructionIndex:i}=t;bp(32===e.length,`Public Key must be 32 bytes but received ${e.length} bytes`),bp(64===r.length,`Signature must be 64 bytes but received ${r.length} bytes`);const o=cy.span,s=o+e.length,a=s+r.length,c=cr.Buffer.alloc(a+n.length),u=null==i?65535:i;return cy.encode({numSignatures:1,padding:0,signatureOffset:s,signatureInstructionIndex:u,publicKeyOffset:o,publicKeyInstructionIndex:u,messageDataOffset:a,messageDataSize:n.length,messageInstructionIndex:u},c),c.fill(e,o),c.fill(r,s),c.fill(n,a),new Bp({keys:[],programId:uy.programId,data:c})}static createInstructionWithPrivateKey(t){const{privateKey:e,message:n,instructionIndex:r}=t;bp(64===e.length,`Private key must be 64 bytes but received ${e.length} bytes`);try{const t=ry.fromSecretKey(e),i=t.publicKey.toBytes(),o=Zf(n,t.secretKey);return this.createInstructionWithPublicKey({publicKey:i,message:n,signature:o,instructionIndex:r})}catch(t){throw new Error(`Error creating instruction; ${t}`)}}}uy.programId=new ip("Ed25519SigVerify111111111111111111111111111");Kf.utils.isValidPrivateKey;const ly=Kf.getPublicKey,hy=fa([ca("numSignatures"),ua("signatureOffset"),ca("signatureInstructionIndex"),ua("ethAddressOffset"),ca("ethAddressInstructionIndex"),ua("messageDataOffset"),ua("messageDataSize"),ca("messageInstructionIndex"),ga(20,"ethAddress"),ga(64,"signature"),ca("recoveryId")]);class dy{constructor(){}static publicKeyToEthAddress(t){bp(64===t.length,`Public key must be 64 bytes but received ${t.length} bytes`);try{return cr.Buffer.from(Af(Xf(t))).slice(-20)}catch(t){throw new Error(`Error constructing Ethereum address: ${t}`)}}static createInstructionWithPublicKey(t){const{publicKey:e,message:n,signature:r,recoveryId:i,instructionIndex:o}=t;return dy.createInstructionWithEthAddress({ethAddress:dy.publicKeyToEthAddress(e),message:n,signature:r,recoveryId:i,instructionIndex:o})}static createInstructionWithEthAddress(t){const{ethAddress:e,message:n,signature:r,recoveryId:i,instructionIndex:o=0}=t;let s;s="string"==typeof e?e.startsWith("0x")?cr.Buffer.from(e.substr(2),"hex"):cr.Buffer.from(e,"hex"):e,bp(20===s.length,`Address must be 20 bytes but received ${s.length} bytes`);const a=12+s.length,c=a+r.length+1,u=cr.Buffer.alloc(hy.span+n.length);return hy.encode({numSignatures:1,signatureOffset:a,signatureInstructionIndex:o,ethAddressOffset:12,ethAddressInstructionIndex:o,messageDataOffset:c,messageDataSize:n.length,messageInstructionIndex:o,signature:Xf(r),ethAddress:Xf(s),recoveryId:i},u),u.fill(Xf(n),hy.span),new Bp({keys:[],programId:dy.programId,data:u})}static createInstructionWithPrivateKey(t){const{privateKey:e,message:n,instructionIndex:r}=t;bp(32===e.length,`Private key must be 32 bytes but received ${e.length} bytes`);try{const t=Xf(e),i=ly(t,!1).slice(1),o=cr.Buffer.from(Af(Xf(n))),[s,a]=((t,e)=>{const n=Kf.sign(t,e);return[n.toCompactRawBytes(),n.recovery]})(o,t);return this.createInstructionWithPublicKey({publicKey:i,message:n,signature:s,recoveryId:a,instructionIndex:r})}catch(t){throw new Error(`Error creating instruction; ${t}`)}}}var fy;dy.programId=new ip("KeccakSecp256k11111111111111111111111111111");const py=new ip("StakeConfig11111111111111111111111111111111");class gy{constructor(t,e){this.staker=void 0,this.withdrawer=void 0,this.staker=t,this.withdrawer=e}}class my{constructor(t,e,n){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=t,this.epoch=e,this.custodian=n}}fy=my,my.default=new fy(0,0,ip.default);const yy=Object.freeze({Initialize:{index:0,layout:fa([la("instruction"),((t="authorized")=>fa([dp("staker"),dp("withdrawer")],t))(),((t="lockup")=>fa([da("unixTimestamp"),da("epoch"),dp("custodian")],t))()])},Authorize:{index:1,layout:fa([la("instruction"),dp("newAuthorized"),la("stakeAuthorizationType")])},Delegate:{index:2,layout:fa([la("instruction")])},Split:{index:3,layout:fa([la("instruction"),da("lamports")])},Withdraw:{index:4,layout:fa([la("instruction"),da("lamports")])},Deactivate:{index:5,layout:fa([la("instruction")])},Merge:{index:7,layout:fa([la("instruction")])},AuthorizeWithSeed:{index:8,layout:fa([la("instruction"),dp("newAuthorized"),la("stakeAuthorizationType"),pp("authoritySeed"),dp("authorityOwner")])}}),by=Object.freeze({Staker:{index:0},Withdrawer:{index:1}});class wy{constructor(){}static initialize(t){const{stakePubkey:e,authorized:n,lockup:r}=t,i=r||my.default,o=Kp(yy.Initialize,{authorized:{staker:Xf(n.staker.toBuffer()),withdrawer:Xf(n.withdrawer.toBuffer())},lockup:{unixTimestamp:i.unixTimestamp,epoch:i.epoch,custodian:Xf(i.custodian.toBuffer())}}),s={keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:Np,isSigner:!1,isWritable:!1}],programId:this.programId,data:o};return new Bp(s)}static createAccountWithSeed(t){const e=new Pp;e.add(Qp.createAccountWithSeed({fromPubkey:t.fromPubkey,newAccountPubkey:t.stakePubkey,basePubkey:t.basePubkey,seed:t.seed,lamports:t.lamports,space:this.space,programId:this.programId}));const{stakePubkey:n,authorized:r,lockup:i}=t;return e.add(this.initialize({stakePubkey:n,authorized:r,lockup:i}))}static createAccount(t){const e=new Pp;e.add(Qp.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.stakePubkey,lamports:t.lamports,space:this.space,programId:this.programId}));const{stakePubkey:n,authorized:r,lockup:i}=t;return e.add(this.initialize({stakePubkey:n,authorized:r,lockup:i}))}static delegate(t){const{stakePubkey:e,authorizedPubkey:n,votePubkey:r}=t,i=Kp(yy.Delegate);return(new Pp).add({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!1},{pubkey:Cp,isSigner:!1,isWritable:!1},{pubkey:Wp,isSigner:!1,isWritable:!1},{pubkey:py,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:i})}static authorize(t){const{stakePubkey:e,authorizedPubkey:n,newAuthorizedPubkey:r,stakeAuthorizationType:i,custodianPubkey:o}=t,s=Kp(yy.Authorize,{newAuthorized:Xf(r.toBuffer()),stakeAuthorizationType:i.index}),a=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:Cp,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}];return o&&a.push({pubkey:o,isSigner:!0,isWritable:!1}),(new Pp).add({keys:a,programId:this.programId,data:s})}static authorizeWithSeed(t){const{stakePubkey:e,authorityBase:n,authoritySeed:r,authorityOwner:i,newAuthorizedPubkey:o,stakeAuthorizationType:s,custodianPubkey:a}=t,c=Kp(yy.AuthorizeWithSeed,{newAuthorized:Xf(o.toBuffer()),stakeAuthorizationType:s.index,authoritySeed:r,authorityOwner:Xf(i.toBuffer())}),u=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1},{pubkey:Cp,isSigner:!1,isWritable:!1}];return a&&u.push({pubkey:a,isSigner:!0,isWritable:!1}),(new Pp).add({keys:u,programId:this.programId,data:c})}static splitInstruction(t){const{stakePubkey:e,authorizedPubkey:n,splitStakePubkey:r,lamports:i}=t,o=Kp(yy.Split,{lamports:i});return new Bp({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:o})}static split(t,e){const n=new Pp;return n.add(Qp.createAccount({fromPubkey:t.authorizedPubkey,newAccountPubkey:t.splitStakePubkey,lamports:e,space:this.space,programId:this.programId})),n.add(this.splitInstruction(t))}static splitWithSeed(t,e){const{stakePubkey:n,authorizedPubkey:r,splitStakePubkey:i,basePubkey:o,seed:s,lamports:a}=t,c=new Pp;return c.add(Qp.allocate({accountPubkey:i,basePubkey:o,seed:s,space:this.space,programId:this.programId})),e&&e>0&&c.add(Qp.transfer({fromPubkey:t.authorizedPubkey,toPubkey:i,lamports:e})),c.add(this.splitInstruction({stakePubkey:n,authorizedPubkey:r,splitStakePubkey:i,lamports:a}))}static merge(t){const{stakePubkey:e,sourceStakePubKey:n,authorizedPubkey:r}=t,i=Kp(yy.Merge);return(new Pp).add({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!0},{pubkey:Cp,isSigner:!1,isWritable:!1},{pubkey:Wp,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:i})}static withdraw(t){const{stakePubkey:e,authorizedPubkey:n,toPubkey:r,lamports:i,custodianPubkey:o}=t,s=Kp(yy.Withdraw,{lamports:i}),a=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:Cp,isSigner:!1,isWritable:!1},{pubkey:Wp,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return o&&a.push({pubkey:o,isSigner:!0,isWritable:!1}),(new Pp).add({keys:a,programId:this.programId,data:s})}static deactivate(t){const{stakePubkey:e,authorizedPubkey:n}=t,r=Kp(yy.Deactivate);return(new Pp).add({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:Cp,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:r})}}wy.programId=new ip("Stake11111111111111111111111111111111111111"),wy.space=200;class vy{constructor(t,e,n,r){this.nodePubkey=void 0,this.authorizedVoter=void 0,this.authorizedWithdrawer=void 0,this.commission=void 0,this.nodePubkey=t,this.authorizedVoter=e,this.authorizedWithdrawer=n,this.commission=r}}const _y=Object.freeze({InitializeAccount:{index:0,layout:fa([la("instruction"),((t="voteInit")=>fa([dp("nodePubkey"),dp("authorizedVoter"),dp("authorizedWithdrawer"),ca("commission")],t))()])},Authorize:{index:1,layout:fa([la("instruction"),dp("newAuthorized"),la("voteAuthorizationType")])},Withdraw:{index:3,layout:fa([la("instruction"),da("lamports")])},UpdateValidatorIdentity:{index:4,layout:fa([la("instruction")])},AuthorizeWithSeed:{index:10,layout:fa([la("instruction"),((t="voteAuthorizeWithSeedArgs")=>fa([la("voteAuthorizationType"),dp("currentAuthorityDerivedKeyOwnerPubkey"),pp("currentAuthorityDerivedKeySeed"),dp("newAuthorized")],t))()])}}),ky=Object.freeze({Voter:{index:0},Withdrawer:{index:1}});class Sy{constructor(){}static initializeAccount(t){const{votePubkey:e,nodePubkey:n,voteInit:r}=t,i=Kp(_y.InitializeAccount,{voteInit:{nodePubkey:Xf(r.nodePubkey.toBuffer()),authorizedVoter:Xf(r.authorizedVoter.toBuffer()),authorizedWithdrawer:Xf(r.authorizedWithdrawer.toBuffer()),commission:r.commission}}),o={keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:Np,isSigner:!1,isWritable:!1},{pubkey:Cp,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:i};return new Bp(o)}static createAccount(t){const e=new Pp;return e.add(Qp.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.votePubkey,lamports:t.lamports,space:this.space,programId:this.programId})),e.add(this.initializeAccount({votePubkey:t.votePubkey,nodePubkey:t.voteInit.nodePubkey,voteInit:t.voteInit}))}static authorize(t){const{votePubkey:e,authorizedPubkey:n,newAuthorizedPubkey:r,voteAuthorizationType:i}=t,o=Kp(_y.Authorize,{newAuthorized:Xf(r.toBuffer()),voteAuthorizationType:i.index}),s=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:Cp,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return(new Pp).add({keys:s,programId:this.programId,data:o})}static authorizeWithSeed(t){const{currentAuthorityDerivedKeyBasePubkey:e,currentAuthorityDerivedKeyOwnerPubkey:n,currentAuthorityDerivedKeySeed:r,newAuthorizedPubkey:i,voteAuthorizationType:o,votePubkey:s}=t,a=Kp(_y.AuthorizeWithSeed,{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:Xf(n.toBuffer()),currentAuthorityDerivedKeySeed:r,newAuthorized:Xf(i.toBuffer()),voteAuthorizationType:o.index}}),c=[{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:Cp,isSigner:!1,isWritable:!1},{pubkey:e,isSigner:!0,isWritable:!1}];return(new Pp).add({keys:c,programId:this.programId,data:a})}static withdraw(t){const{votePubkey:e,authorizedWithdrawerPubkey:n,lamports:r,toPubkey:i}=t,o=Kp(_y.Withdraw,{lamports:r}),s=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}];return(new Pp).add({keys:s,programId:this.programId,data:o})}static safeWithdraw(t,e,n){if(t.lamports>e-n)throw new Error("Withdraw will leave vote account with insufficient funds.");return Sy.withdraw(t)}static updateValidatorIdentity(t){const{votePubkey:e,authorizedWithdrawerPubkey:n,nodePubkey:r}=t,i=Kp(_y.UpdateValidatorIdentity),o=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return(new Pp).add({keys:o,programId:this.programId,data:i})}}Sy.programId=new ip("Vote111111111111111111111111111111111111111"),Sy.space=3762;const xy=new ip("Va1idator1nfo111111111111111111111111111111"),Ey=Sd({name:_d(),website:wd(_d()),details:wd(_d()),iconUrl:wd(_d()),keybaseUsername:wd(_d())});class Iy{constructor(t,e){this.key=void 0,this.info=void 0,this.key=t,this.info=e}static fromConfigData(t){let e=[...t];if(2!==mp(e))return null;const n=[];for(let t=0;t<2;t++){const t=new ip(kp(e,0,np)),r=1===_p(e);n.push({publicKey:t,isSigner:r})}if(n[0].publicKey.equals(xy)&&n[1].isSigner){const t=pp().decode(cr.Buffer.from(e)),r=JSON.parse(t);return cd(r,Ey),new Iy(n[1].publicKey,r)}return null}}const Ay=new ip("Vote111111111111111111111111111111111111111"),By=fa([dp("nodePubkey"),dp("authorizedWithdrawer"),ca("commission"),ha(),pa(fa([ha("slot"),la("confirmationCount")]),aa(la(),-8),"votes"),ca("rootSlotValid"),ha("rootSlot"),ha(),pa(fa([ha("epoch"),dp("authorizedVoter")]),aa(la(),-8),"authorizedVoters"),fa([pa(fa([dp("authorizedPubkey"),ha("epochOfLastAuthorizedSwitch"),ha("targetEpoch")]),32,"buf"),ha("idx"),ca("isEmpty")],"priorVoters"),ha(),pa(fa([ha("epoch"),ha("credits"),ha("prevCredits")]),aa(la(),-8),"epochCredits"),fa([ha("slot"),ha("timestamp")],"lastTimestamp")]);class Py{constructor(t){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=t.nodePubkey,this.authorizedWithdrawer=t.authorizedWithdrawer,this.commission=t.commission,this.rootSlot=t.rootSlot,this.votes=t.votes,this.authorizedVoters=t.authorizedVoters,this.priorVoters=t.priorVoters,this.epochCredits=t.epochCredits,this.lastTimestamp=t.lastTimestamp}static fromAccountData(t){const e=By.decode(Xf(t),4);let n=e.rootSlot;return e.rootSlotValid||(n=null),new Py({nodePubkey:new ip(e.nodePubkey),authorizedWithdrawer:new ip(e.authorizedWithdrawer),commission:e.commission,votes:e.votes,rootSlot:n,authorizedVoters:e.authorizedVoters.map(Ty),priorVoters:Cy(e.priorVoters),epochCredits:e.epochCredits,lastTimestamp:e.lastTimestamp})}}function Ty({authorizedVoter:t,epoch:e}){return{epoch:e,authorizedVoter:new ip(t)}}function My({authorizedPubkey:t,epochOfLastAuthorizedSwitch:e,targetEpoch:n}){return{authorizedPubkey:new ip(t),epochOfLastAuthorizedSwitch:e,targetEpoch:n}}function Cy({buf:t,idx:e,isEmpty:n}){return n?[]:[...t.slice(e+1).map(My),...t.slice(0,e).map(My)]}const Oy={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/"}};var Ry=Object.freeze({__proto__:null,Account:class{constructor(t){if(this._publicKey=void 0,this._secretKey=void 0,t){const e=Xf(t);if(64!==t.length)throw new Error("bad secret key size");this._publicKey=e.slice(32,64),this._secretKey=e.slice(0,32)}else this._secretKey=Xf(Hf()),this._publicKey=Xf(Gf(this._secretKey))}get publicKey(){return new ip(this._publicKey)}get secretKey(){return cr.Buffer.concat([this._secretKey,this._publicKey],64)}},AddressLookupTableAccount:hg,AddressLookupTableInstruction:class{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const e=la("instruction").decode(t.data);let n;for(const[t,r]of Object.entries(iy))if(r.index==e){n=t;break}if(!n)throw new Error("Invalid Instruction. Should be a LookupTable Instruction");return n}static decodeCreateLookupTable(t){this.checkProgramId(t.programId),this.checkKeysLength(t.keys,4);const{recentSlot:e}=Hp(iy.CreateLookupTable,t.data);return{authority:t.keys[1].pubkey,payer:t.keys[2].pubkey,recentSlot:Number(e)}}static decodeExtendLookupTable(t){if(this.checkProgramId(t.programId),t.keys.length<2)throw new Error(`invalid instruction; found ${t.keys.length} keys, expected at least 2`);const{addresses:e}=Hp(iy.ExtendLookupTable,t.data);return{lookupTable:t.keys[0].pubkey,authority:t.keys[1].pubkey,payer:t.keys.length>2?t.keys[2].pubkey:void 0,addresses:e.map((t=>new ip(t)))}}static decodeCloseLookupTable(t){return this.checkProgramId(t.programId),this.checkKeysLength(t.keys,3),{lookupTable:t.keys[0].pubkey,authority:t.keys[1].pubkey,recipient:t.keys[2].pubkey}}static decodeFreezeLookupTable(t){return this.checkProgramId(t.programId),this.checkKeysLength(t.keys,2),{lookupTable:t.keys[0].pubkey,authority:t.keys[1].pubkey}}static decodeDeactivateLookupTable(t){return this.checkProgramId(t.programId),this.checkKeysLength(t.keys,2),{lookupTable:t.keys[0].pubkey,authority:t.keys[1].pubkey}}static checkProgramId(t){if(!t.equals(oy.programId))throw new Error("invalid instruction; programId is not AddressLookupTable Program")}static checkKeysLength(t,e){if(t.length<e)throw new Error(`invalid instruction; found ${t.length} keys, expected at least ${e}`)}},AddressLookupTableProgram:oy,Authorized:gy,BLOCKHASH_CACHE_TIMEOUT_MS:3e4,BPF_LOADER_DEPRECATED_PROGRAM_ID:op,BPF_LOADER_PROGRAM_ID:eg,BpfLoader:class{static getMinNumSignatures(t){return tg.getMinNumSignatures(t)}static load(t,e,n,r,i){return tg.load(t,e,n,i,r)}},COMPUTE_BUDGET_INSTRUCTION_LAYOUTS:sy,ComputeBudgetInstruction:class{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const e=ca("instruction").decode(t.data);let n;for(const[t,r]of Object.entries(sy))if(r.index==e){n=t;break}if(!n)throw new Error("Instruction type incorrect; not a ComputeBudgetInstruction");return n}static decodeRequestUnits(t){this.checkProgramId(t.programId);const{units:e,additionalFee:n}=Hp(sy.RequestUnits,t.data);return{units:e,additionalFee:n}}static decodeRequestHeapFrame(t){this.checkProgramId(t.programId);const{bytes:e}=Hp(sy.RequestHeapFrame,t.data);return{bytes:e}}static decodeSetComputeUnitLimit(t){this.checkProgramId(t.programId);const{units:e}=Hp(sy.SetComputeUnitLimit,t.data);return{units:e}}static decodeSetComputeUnitPrice(t){this.checkProgramId(t.programId);const{microLamports:e}=Hp(sy.SetComputeUnitPrice,t.data);return{microLamports:e}}static checkProgramId(t){if(!t.equals(ay.programId))throw new Error("invalid instruction; programId is not ComputeBudgetProgram")}},ComputeBudgetProgram:ay,Connection:class{constructor(t,e){let n,r,i,o,s,a;var c;this._commitment=void 0,this._confirmTransactionInitialTimeout=void 0,this._rpcEndpoint=void 0,this._rpcWsEndpoint=void 0,this._rpcClient=void 0,this._rpcRequest=void 0,this._rpcBatchRequest=void 0,this._rpcWebSocket=void 0,this._rpcWebSocketConnected=!1,this._rpcWebSocketHeartbeat=null,this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketGeneration=0,this._disableBlockhashCaching=!1,this._pollingBlockhash=!1,this._blockhashInfo={latestBlockhash:null,lastFetch:0,transactionSignatures:[],simulatedSignatures:[]},this._nextClientSubscriptionId=0,this._subscriptionDisposeFunctionsByClientSubscriptionId={},this._subscriptionHashByClientSubscriptionId={},this._subscriptionStateChangeCallbacksByHash={},this._subscriptionCallbacksByServerSubscriptionId={},this._subscriptionsByHash={},this._subscriptionsAutoDisposedByRpc=new Set,this.getBlockHeight=(()=>{const t={};return async e=>{const{commitment:n,config:r}=yg(e),i=this._buildArgs([],n,void 0,r),o=sg(i);return t[o]=t[o]??(async()=>{try{const t=ud(await this._rpcRequest("getBlockHeight",i),_g(bd()));if("error"in t)throw new Dp(t.error,"failed to get block height information");return t.result}finally{delete t[o]}})(),await t[o]}})(),e&&"string"==typeof e?this._commitment=e:e&&(this._commitment=e.commitment,this._confirmTransactionInitialTimeout=e.confirmTransactionInitialTimeout,n=e.wsEndpoint,r=e.httpHeaders,i=e.fetch,o=e.fetchMiddleware,s=e.disableRetryOnRateLimit,a=e.httpAgent),this._rpcEndpoint=function(t){if(!1===/^https?:/.test(t))throw new TypeError("Endpoint URL must start with `http:` or `https:`.");return t}(t),this._rpcWsEndpoint=n||function(t){const e=t.match(fg);if(null==e)throw TypeError(`Failed to validate endpoint URL \`${t}\``);const[n,r,i,o]=e,s=t.startsWith("https:")?"wss:":"ws:",a=null==i?null:parseInt(i.slice(1),10);return`${s}//${r}${null==a?"":`:${a+1}`}${o}`}(t),this._rpcClient=function(t,e,n,r,i,o){const s=n||ug;let a;return null!=o&&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."),r&&(a=async(t,e)=>{const n=await new Promise(((n,i)=>{try{r(t,e,((t,e)=>n([t,e])))}catch(t){i(t)}}));return await s(...n)}),new sf((async(n,r)=>{const o={method:"POST",body:n,agent:void 0,headers:Object.assign({"Content-Type":"application/json"},e||{},ny)};try{let e,n=5,c=500;for(;e=a?await a(t,o):await s(t,o),429===e.status&&!0!==i&&(n-=1,0!==n);)console.error(`Server responded with ${e.status} ${e.statusText}.  Retrying after ${c}ms delay...`),await qp(c),c*=2;const u=await e.text();e.ok?r(null,u):r(new Error(`${e.status} ${e.statusText}: ${u}`))}catch(t){t instanceof Error&&r(t)}}),{})}(t,r,i,o,s,a),this._rpcRequest=(c=this._rpcClient,(t,e)=>new Promise(((n,r)=>{c.request(t,e,((t,e)=>{t?r(t):n(e)}))}))),this._rpcBatchRequest=function(t){return e=>new Promise(((n,r)=>{0===e.length&&n([]);const i=e.map((e=>t.request(e.methodName,e.args)));t.request(i,((t,e)=>{t?r(t):n(e)}))}))}(this._rpcClient),this._rpcWebSocket=new lg(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(t,e){const{commitment:n,config:r}=yg(e),i=this._buildArgs([t.toBase58()],n,void 0,r),o=ud(await this._rpcRequest("getBalance",i),kg(bd()));if("error"in o)throw new Dp(o.error,`failed to get balance for ${t.toBase58()}`);return o.result}async getBalance(t,e){return await this.getBalanceAndContext(t,e).then((t=>t.value)).catch((e=>{throw new Error("failed to get balance of account "+t.toBase58()+": "+e)}))}async getBlockTime(t){const e=ud(await this._rpcRequest("getBlockTime",[t]),_g(yd(bd())));if("error"in e)throw new Dp(e.error,`failed to get block time for slot ${t}`);return e.result}async getMinimumLedgerSlot(){const t=ud(await this._rpcRequest("minimumLedgerSlot",[]),_g(bd()));if("error"in t)throw new Dp(t.error,"failed to get minimum ledger slot");return t.result}async getFirstAvailableBlock(){const t=ud(await this._rpcRequest("getFirstAvailableBlock",[]),Hg);if("error"in t)throw new Dp(t.error,"failed to get first available block");return t.result}async getSupply(t){let e={};e="string"==typeof t?{commitment:t}:t?{...t,commitment:t&&t.commitment||this.commitment}:{commitment:this.commitment};const n=ud(await this._rpcRequest("getSupply",[e]),Vg);if("error"in n)throw new Dp(n.error,"failed to get supply");return n.result}async getTokenSupply(t,e){const n=this._buildArgs([t.toBase58()],e),r=ud(await this._rpcRequest("getTokenSupply",n),kg(Gg));if("error"in r)throw new Dp(r.error,"failed to get token supply");return r.result}async getTokenAccountBalance(t,e){const n=this._buildArgs([t.toBase58()],e),r=ud(await this._rpcRequest("getTokenAccountBalance",n),kg(Gg));if("error"in r)throw new Dp(r.error,"failed to get token account balance");return r.result}async getTokenAccountsByOwner(t,e,n){const{commitment:r,config:i}=yg(n);let o=[t.toBase58()];"mint"in e?o.push({mint:e.mint.toBase58()}):o.push({programId:e.programId.toBase58()});const s=this._buildArgs(o,r,"base64",i),a=ud(await this._rpcRequest("getTokenAccountsByOwner",s),Zg);if("error"in a)throw new Dp(a.error,`failed to get token accounts owned by account ${t.toBase58()}`);return a.result}async getParsedTokenAccountsByOwner(t,e,n){let r=[t.toBase58()];"mint"in e?r.push({mint:e.mint.toBase58()}):r.push({programId:e.programId.toBase58()});const i=this._buildArgs(r,n,"jsonParsed"),o=ud(await this._rpcRequest("getTokenAccountsByOwner",i),Xg);if("error"in o)throw new Dp(o.error,`failed to get token accounts owned by account ${t.toBase58()}`);return o.result}async getLargestAccounts(t){const e={...t,commitment:t&&t.commitment||this.commitment},n=e.filter||e.commitment?[e]:[],r=ud(await this._rpcRequest("getLargestAccounts",n),Qg);if("error"in r)throw new Dp(r.error,"failed to get largest accounts");return r.result}async getTokenLargestAccounts(t,e){const n=this._buildArgs([t.toBase58()],e),r=ud(await this._rpcRequest("getTokenLargestAccounts",n),Jg);if("error"in r)throw new Dp(r.error,"failed to get token largest accounts");return r.result}async getAccountInfoAndContext(t,e){const{commitment:n,config:r}=yg(e),i=this._buildArgs([t.toBase58()],n,"base64",r),o=ud(await this._rpcRequest("getAccountInfo",i),kg(yd(tm)));if("error"in o)throw new Dp(o.error,`failed to get info about account ${t.toBase58()}`);return o.result}async getParsedAccountInfo(t,e){const{commitment:n,config:r}=yg(e),i=this._buildArgs([t.toBase58()],n,"jsonParsed",r),o=ud(await this._rpcRequest("getAccountInfo",i),kg(yd(rm)));if("error"in o)throw new Dp(o.error,`failed to get info about account ${t.toBase58()}`);return o.result}async getAccountInfo(t,e){try{return(await this.getAccountInfoAndContext(t,e)).value}catch(e){throw new Error("failed to get info about account "+t.toBase58()+": "+e)}}async getMultipleParsedAccounts(t,e){const{commitment:n,config:r}=yg(e),i=t.map((t=>t.toBase58())),o=this._buildArgs([i],n,"jsonParsed",r),s=ud(await this._rpcRequest("getMultipleAccounts",o),kg(fd(yd(rm))));if("error"in s)throw new Dp(s.error,`failed to get info for accounts ${i}`);return s.result}async getMultipleAccountsInfoAndContext(t,e){const{commitment:n,config:r}=yg(e),i=t.map((t=>t.toBase58())),o=this._buildArgs([i],n,"base64",r),s=ud(await this._rpcRequest("getMultipleAccounts",o),kg(fd(yd(tm))));if("error"in s)throw new Dp(s.error,`failed to get info for accounts ${i}`);return s.result}async getMultipleAccountsInfo(t,e){return(await this.getMultipleAccountsInfoAndContext(t,e)).value}async getStakeActivation(t,e,n){const{commitment:r,config:i}=yg(e),o=this._buildArgs([t.toBase58()],r,void 0,{...i,epoch:null!=n?n:i?.epoch}),s=ud(await this._rpcRequest("getStakeActivation",o),_g(om));if("error"in s)throw new Dp(s.error,`failed to get Stake Activation ${t.toBase58()}`);return s.result}async getProgramAccounts(t,e){const{commitment:n,config:r}=yg(e),{encoding:i,...o}=r||{},s=this._buildArgs([t.toBase58()],n,i||"base64",{...o,...o.filters?{filters:bg(o.filters)}:null}),a=await this._rpcRequest("getProgramAccounts",s),c=fd(em),u=!0===o.withContext?ud(a,kg(c)):ud(a,_g(c));if("error"in u)throw new Dp(u.error,`failed to get accounts owned by program ${t.toBase58()}`);return u.result}async getParsedProgramAccounts(t,e){const{commitment:n,config:r}=yg(e),i=this._buildArgs([t.toBase58()],n,"jsonParsed",r),o=ud(await this._rpcRequest("getProgramAccounts",i),_g(fd(im)));if("error"in o)throw new Dp(o.error,`failed to get accounts owned by program ${t.toBase58()}`);return o.result}async confirmTransaction(t,e){let n,r;if("string"==typeof t)n=t;else{const e=t;if(e.abortSignal?.aborted)return Promise.reject(e.abortSignal.reason);n=e.signature}try{r=zo.decode(n)}catch(t){throw new Error("signature must be base58 encoded: "+n)}return bp(64===r.length,"signature has invalid length"),"string"==typeof t?await this.confirmTransactionUsingLegacyTimeoutStrategy({commitment:e||this.commitment,signature:n}):"lastValidBlockHeight"in t?await this.confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:e||this.commitment,strategy:t}):await this.confirmTransactionUsingDurableNonceStrategy({commitment:e||this.commitment,strategy:t})}getCancellationPromise(t){return new Promise(((e,n)=>{null!=t&&(t.aborted?n(t.reason):t.addEventListener("abort",(()=>{n(t.reason)})))}))}getTransactionConfirmationPromise({commitment:t,signature:e}){let n,r,i=!1;return{abortConfirmation:()=>{r&&(r(),r=void 0),null!=n&&(this.removeSignatureListener(n),n=void 0)},confirmationPromise:new Promise(((o,s)=>{try{n=this.onSignature(e,((t,e)=>{n=void 0;const r={context:e,value:t};o({__type:Ip.PROCESSED,response:r})}),t);const a=new Promise((t=>{null==n?t():r=this._onSubscriptionStateChange(n,(e=>{"subscribed"===e&&t()}))}));(async()=>{if(await a,i)return;const n=await this.getSignatureStatus(e);if(i)return;if(null==n)return;const{context:r,value:c}=n;if(null!=c)if(c?.err)s(c.err);else{switch(t){case"confirmed":case"single":case"singleGossip":if("processed"===c.confirmationStatus)return;break;case"finalized":case"max":case"root":if("processed"===c.confirmationStatus||"confirmed"===c.confirmationStatus)return}i=!0,o({__type:Ip.PROCESSED,response:{context:r,value:c}})}})()}catch(t){s(t)}}))}}async confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:t,strategy:{abortSignal:e,lastValidBlockHeight:n,signature:r}}){let i=!1;const o=new Promise((e=>{const r=async()=>{try{return await this.getBlockHeight(t)}catch(t){return-1}};(async()=>{let t=await r();if(!i){for(;t<=n;){if(await qp(1e3),i)return;if(t=await r(),i)return}e({__type:Ip.BLOCKHEIGHT_EXCEEDED})}})()})),{abortConfirmation:s,confirmationPromise:a}=this.getTransactionConfirmationPromise({commitment:t,signature:r}),c=this.getCancellationPromise(e);let u;try{const t=await Promise.race([c,a,o]);if(t.__type!==Ip.PROCESSED)throw new cp(r);u=t.response}finally{i=!0,s()}return u}async confirmTransactionUsingDurableNonceStrategy({commitment:t,strategy:{abortSignal:e,minContextSlot:n,nonceAccountPubkey:r,nonceValue:i,signature:o}}){let s=!1;const a=new Promise((e=>{let o=i,a=null;const c=async()=>{try{const{context:e,value:i}=await this.getNonceAndContext(r,{commitment:t,minContextSlot:n});return a=e.slot,i?.nonce}catch(t){return o}};(async()=>{if(o=await c(),!s)for(;;){if(i!==o)return void e({__type:Ip.NONCE_INVALID,slotInWhichNonceDidAdvance:a});if(await qp(2e3),s)return;if(o=await c(),s)return}})()})),{abortConfirmation:c,confirmationPromise:u}=this.getTransactionConfirmationPromise({commitment:t,signature:o}),l=this.getCancellationPromise(e);let h;try{const e=await Promise.race([l,u,a]);if(e.__type===Ip.PROCESSED)h=e.response;else{let r;for(;;){const t=await this.getSignatureStatus(o);if(null==t)break;if(!(t.context.slot<(e.slotInWhichNonceDidAdvance??n))){r=t;break}await qp(400)}if(!r?.value)throw new lp(o);{const e=t||"finalized",{confirmationStatus:n}=r.value;switch(e){case"processed":case"recent":if("processed"!==n&&"confirmed"!==n&&"finalized"!==n)throw new lp(o);break;case"confirmed":case"single":case"singleGossip":if("confirmed"!==n&&"finalized"!==n)throw new lp(o);break;case"finalized":case"max":case"root":if("finalized"!==n)throw new lp(o)}h={context:r.context,value:{err:r.value.err}}}}}finally{s=!0,c()}return h}async confirmTransactionUsingLegacyTimeoutStrategy({commitment:t,signature:e}){let n;const r=new Promise((e=>{let r=this._confirmTransactionInitialTimeout||6e4;switch(t){case"processed":case"recent":case"single":case"confirmed":case"singleGossip":r=this._confirmTransactionInitialTimeout||3e4}n=setTimeout((()=>e({__type:Ip.TIMED_OUT,timeoutMs:r})),r)})),{abortConfirmation:i,confirmationPromise:o}=this.getTransactionConfirmationPromise({commitment:t,signature:e});let s;try{const t=await Promise.race([o,r]);if(t.__type!==Ip.PROCESSED)throw new up(e,t.timeoutMs/1e3);s=t.response}finally{clearTimeout(n),i()}return s}async getClusterNodes(){const t=ud(await this._rpcRequest("getClusterNodes",[]),_g(fd(ym)));if("error"in t)throw new Dp(t.error,"failed to get cluster nodes");return t.result}async getVoteAccounts(t){const e=this._buildArgs([],t),n=ud(await this._rpcRequest("getVoteAccounts",e),wm);if("error"in n)throw new Dp(n.error,"failed to get vote accounts");return n.result}async getSlot(t){const{commitment:e,config:n}=yg(t),r=this._buildArgs([],e,void 0,n),i=ud(await this._rpcRequest("getSlot",r),_g(bd()));if("error"in i)throw new Dp(i.error,"failed to get slot");return i.result}async getSlotLeader(t){const{commitment:e,config:n}=yg(t),r=this._buildArgs([],e,void 0,n),i=ud(await this._rpcRequest("getSlotLeader",r),_g(_d()));if("error"in i)throw new Dp(i.error,"failed to get slot leader");return i.result}async getSlotLeaders(t,e){const n=[t,e],r=ud(await this._rpcRequest("getSlotLeaders",n),_g(fd(pg)));if("error"in r)throw new Dp(r.error,"failed to get slot leaders");return r.result}async getSignatureStatus(t,e){const{context:n,value:r}=await this.getSignatureStatuses([t],e);bp(1===r.length);return{context:n,value:r[0]}}async getSignatureStatuses(t,e){const n=[t];e&&n.push(e);const r=ud(await this._rpcRequest("getSignatureStatuses",n),km);if("error"in r)throw new Dp(r.error,"failed to get signature status");return r.result}async getTransactionCount(t){const{commitment:e,config:n}=yg(t),r=this._buildArgs([],e,void 0,n),i=ud(await this._rpcRequest("getTransactionCount",r),_g(bd()));if("error"in i)throw new Dp(i.error,"failed to get transaction count");return i.result}async getTotalSupply(t){return(await this.getSupply({commitment:t,excludeNonCirculatingAccountsList:!0})).value.total}async getInflationGovernor(t){const e=this._buildArgs([],t),n=ud(await this._rpcRequest("getInflationGovernor",e),Wg);if("error"in n)throw new Dp(n.error,"failed to get inflation");return n.result}async getInflationReward(t,e,n){const{commitment:r,config:i}=yg(n),o=this._buildArgs([t.map((t=>t.toBase58()))],r,void 0,{...i,epoch:null!=e?e:i?.epoch}),s=ud(await this._rpcRequest("getInflationReward",o),Ig);if("error"in s)throw new Dp(s.error,"failed to get inflation reward");return s.result}async getInflationRate(){const t=ud(await this._rpcRequest("getInflationRate",[]),Fg);if("error"in t)throw new Dp(t.error,"failed to get inflation rate");return t.result}async getEpochInfo(t){const{commitment:e,config:n}=yg(t),r=this._buildArgs([],e,void 0,n),i=ud(await this._rpcRequest("getEpochInfo",r),jg);if("error"in i)throw new Dp(i.error,"failed to get epoch info");return i.result}async getEpochSchedule(){const t=ud(await this._rpcRequest("getEpochSchedule",[]),qg);if("error"in t)throw new Dp(t.error,"failed to get epoch schedule");const e=t.result;return new cg(e.slotsPerEpoch,e.leaderScheduleSlotOffset,e.warmup,e.firstNormalEpoch,e.firstNormalSlot)}async getLeaderSchedule(){const t=ud(await this._rpcRequest("getLeaderSchedule",[]),Kg);if("error"in t)throw new Dp(t.error,"failed to get leader schedule");return t.result}async getMinimumBalanceForRentExemption(t,e){const n=this._buildArgs([t],e),r=ud(await this._rpcRequest("getMinimumBalanceForRentExemption",n),Sm);return"error"in r?(console.warn("Unable to fetch minimum balance for rent exemption"),0):r.result}async getRecentBlockhashAndContext(t){const{context:e,value:{blockhash:n}}=await this.getLatestBlockhashAndContext(t);return{context:e,value:{blockhash:n,feeCalculator:{get lamportsPerSignature(){throw new Error("The capability to fetch `lamportsPerSignature` using the `getRecentBlockhash` API is no longer offered by the network. Use the `getFeeForMessage` API to obtain the fee for a given message.")},toJSON:()=>({})}}}}async getRecentPerformanceSamples(t){const e=ud(await this._rpcRequest("getRecentPerformanceSamples",t?[t]:[]),Zm);if("error"in e)throw new Dp(e.error,"failed to get recent performance samples");return e.result}async getFeeCalculatorForBlockhash(t,e){const n=this._buildArgs([t],e),r=ud(await this._rpcRequest("getFeeCalculatorForBlockhash",n),Ym);if("error"in r)throw new Dp(r.error,"failed to get fee calculator");const{context:i,value:o}=r.result;return{context:i,value:null!==o?o.feeCalculator:null}}async getFeeForMessage(t,e){const n=Xf(t.serialize()).toString("base64"),r=this._buildArgs([n],e),i=ud(await this._rpcRequest("getFeeForMessage",r),kg(yd(bd())));if("error"in i)throw new Dp(i.error,"failed to get fee for message");if(null===i.result)throw new Error("invalid blockhash");return i.result}async getRecentPrioritizationFees(t){const e=t?.lockedWritableAccounts?.map((t=>t.toBase58())),n=e?.length?[e]:[],r=ud(await this._rpcRequest("getRecentPrioritizationFees",n),Dg);if("error"in r)throw new Dp(r.error,"failed to get recent prioritization fees");return r.result}async getRecentBlockhash(t){try{return(await this.getRecentBlockhashAndContext(t)).value}catch(t){throw new Error("failed to get recent blockhash: "+t)}}async getLatestBlockhash(t){try{return(await this.getLatestBlockhashAndContext(t)).value}catch(t){throw new Error("failed to get recent blockhash: "+t)}}async getLatestBlockhashAndContext(t){const{commitment:e,config:n}=yg(t),r=this._buildArgs([],e,void 0,n),i=ud(await this._rpcRequest("getLatestBlockhash",r),Gm);if("error"in i)throw new Dp(i.error,"failed to get latest blockhash");return i.result}async isBlockhashValid(t,e){const{commitment:n,config:r}=yg(e),i=this._buildArgs([t],n,void 0,r),o=ud(await this._rpcRequest("isBlockhashValid",i),Jm);if("error"in o)throw new Dp(o.error,"failed to determine if the blockhash `"+t+"`is valid");return o.result}async getVersion(){const t=ud(await this._rpcRequest("getVersion",[]),_g(Lg));if("error"in t)throw new Dp(t.error,"failed to get version");return t.result}async getGenesisHash(){const t=ud(await this._rpcRequest("getGenesisHash",[]),_g(_d()));if("error"in t)throw new Dp(t.error,"failed to get genesis hash");return t.result}async getBlock(t,e){const{commitment:n,config:r}=yg(e),i=this._buildArgsAtLeastConfirmed([t],n,void 0,r),o=await this._rpcRequest("getBlock",i);try{switch(r?.transactionDetails){case"accounts":{const t=ud(o,Wm);if("error"in t)throw t.error;return t.result}case"none":{const t=ud(o,$m);if("error"in t)throw t.error;return t.result}default:{const t=ud(o,zm);if("error"in t)throw t.error;const{result:e}=t;return e?{...e,transactions:e.transactions.map((({transaction:t,meta:e,version:n})=>({meta:e,transaction:{...t,message:xg(n,t.message)},version:n})))}:null}}}catch(t){throw new Dp(t,"failed to get confirmed block")}}async getParsedBlock(t,e){const{commitment:n,config:r}=yg(e),i=this._buildArgsAtLeastConfirmed([t],n,"jsonParsed",r),o=await this._rpcRequest("getBlock",i);try{switch(r?.transactionDetails){case"accounts":{const t=ud(o,Dm);if("error"in t)throw t.error;return t.result}case"none":{const t=ud(o,jm);if("error"in t)throw t.error;return t.result}default:{const t=ud(o,Fm);if("error"in t)throw t.error;return t.result}}}catch(t){throw new Dp(t,"failed to get block")}}async getBlockProduction(t){let e,n;if("string"==typeof t)n=t;else if(t){const{commitment:r,...i}=t;n=r,e=i}const r=this._buildArgs([],n,"base64",e),i=ud(await this._rpcRequest("getBlockProduction",r),$g);if("error"in i)throw new Dp(i.error,"failed to get block production information");return i.result}async getTransaction(t,e){const{commitment:n,config:r}=yg(e),i=this._buildArgsAtLeastConfirmed([t],n,void 0,r),o=ud(await this._rpcRequest("getTransaction",i),Hm);if("error"in o)throw new Dp(o.error,"failed to get transaction");const s=o.result;return s?{...s,transaction:{...s.transaction,message:xg(s.version,s.transaction.message)}}:s}async getParsedTransaction(t,e){const{commitment:n,config:r}=yg(e),i=this._buildArgsAtLeastConfirmed([t],n,"jsonParsed",r),o=ud(await this._rpcRequest("getTransaction",i),Vm);if("error"in o)throw new Dp(o.error,"failed to get transaction");return o.result}async getParsedTransactions(t,e){const{commitment:n,config:r}=yg(e),i=t.map((t=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([t],n,"jsonParsed",r)})));return(await this._rpcBatchRequest(i)).map((t=>{const e=ud(t,Vm);if("error"in e)throw new Dp(e.error,"failed to get transactions");return e.result}))}async getTransactions(t,e){const{commitment:n,config:r}=yg(e),i=t.map((t=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([t],n,void 0,r)})));return(await this._rpcBatchRequest(i)).map((t=>{const e=ud(t,Hm);if("error"in e)throw new Dp(e.error,"failed to get transactions");const n=e.result;return n?{...n,transaction:{...n.transaction,message:xg(n.version,n.transaction.message)}}:n}))}async getConfirmedBlock(t,e){const n=this._buildArgsAtLeastConfirmed([t],e),r=ud(await this._rpcRequest("getBlock",n),qm);if("error"in r)throw new Dp(r.error,"failed to get confirmed block");const i=r.result;if(!i)throw new Error("Confirmed block "+t+" not found");const o={...i,transactions:i.transactions.map((({transaction:t,meta:e})=>{const n=new Sp(t.message);return{meta:e,transaction:{...t,message:n}}}))};return{...o,transactions:o.transactions.map((({transaction:t,meta:e})=>({meta:e,transaction:Pp.populate(t.message,t.signatures)})))}}async getBlocks(t,e,n){const r=this._buildArgsAtLeastConfirmed(void 0!==e?[t,e]:[t],n),i=ud(await this._rpcRequest("getBlocks",r),_g(fd(bd())));if("error"in i)throw new Dp(i.error,"failed to get blocks");return i.result}async getBlockSignatures(t,e){const n=this._buildArgsAtLeastConfirmed([t],e,void 0,{transactionDetails:"signatures",rewards:!1}),r=ud(await this._rpcRequest("getBlock",n),Km);if("error"in r)throw new Dp(r.error,"failed to get block");const i=r.result;if(!i)throw new Error("Block "+t+" not found");return i}async getConfirmedBlockSignatures(t,e){const n=this._buildArgsAtLeastConfirmed([t],e,void 0,{transactionDetails:"signatures",rewards:!1}),r=ud(await this._rpcRequest("getBlock",n),Km);if("error"in r)throw new Dp(r.error,"failed to get confirmed block");const i=r.result;if(!i)throw new Error("Confirmed block "+t+" not found");return i}async getConfirmedTransaction(t,e){const n=this._buildArgsAtLeastConfirmed([t],e),r=ud(await this._rpcRequest("getTransaction",n),Hm);if("error"in r)throw new Dp(r.error,"failed to get transaction");const i=r.result;if(!i)return i;const o=new Sp(i.transaction.message),s=i.transaction.signatures;return{...i,transaction:Pp.populate(o,s)}}async getParsedConfirmedTransaction(t,e){const n=this._buildArgsAtLeastConfirmed([t],e,"jsonParsed"),r=ud(await this._rpcRequest("getTransaction",n),Vm);if("error"in r)throw new Dp(r.error,"failed to get confirmed transaction");return r.result}async getParsedConfirmedTransactions(t,e){const n=t.map((t=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([t],e,"jsonParsed")})));return(await this._rpcBatchRequest(n)).map((t=>{const e=ud(t,Vm);if("error"in e)throw new Dp(e.error,"failed to get confirmed transactions");return e.result}))}async getConfirmedSignaturesForAddress(t,e,n){let r={},i=await this.getFirstAvailableBlock();for(;!("until"in r)&&!(--e<=0||e<i);)try{const t=await this.getConfirmedBlockSignatures(e,"finalized");t.signatures.length>0&&(r.until=t.signatures[t.signatures.length-1].toString())}catch(t){if(t instanceof Error&&t.message.includes("skipped"))continue;throw t}let o=await this.getSlot("finalized");for(;!("before"in r||++n>o);)try{const t=await this.getConfirmedBlockSignatures(n);t.signatures.length>0&&(r.before=t.signatures[t.signatures.length-1].toString())}catch(t){if(t instanceof Error&&t.message.includes("skipped"))continue;throw t}return(await this.getConfirmedSignaturesForAddress2(t,r)).map((t=>t.signature))}async getConfirmedSignaturesForAddress2(t,e,n){const r=this._buildArgsAtLeastConfirmed([t.toBase58()],n,void 0,e),i=ud(await this._rpcRequest("getConfirmedSignaturesForAddress2",r),sm);if("error"in i)throw new Dp(i.error,"failed to get confirmed signatures for address");return i.result}async getSignaturesForAddress(t,e,n){const r=this._buildArgsAtLeastConfirmed([t.toBase58()],n,void 0,e),i=ud(await this._rpcRequest("getSignaturesForAddress",r),am);if("error"in i)throw new Dp(i.error,"failed to get signatures for address");return i.result}async getAddressLookupTable(t,e){const{context:n,value:r}=await this.getAccountInfoAndContext(t,e);let i=null;return null!==r&&(i=new hg({key:t,state:hg.deserialize(r.data)})),{context:n,value:i}}async getNonceAndContext(t,e){const{context:n,value:r}=await this.getAccountInfoAndContext(t,e);let i=null;return null!==r&&(i=Zp.fromAccountData(r.data)),{context:n,value:i}}async getNonce(t,e){return await this.getNonceAndContext(t,e).then((t=>t.value)).catch((e=>{throw new Error("failed to get nonce for account "+t.toBase58()+": "+e)}))}async requestAirdrop(t,e){const n=ud(await this._rpcRequest("requestAirdrop",[t.toBase58(),e]),Xm);if("error"in n)throw new Dp(n.error,`airdrop to ${t.toBase58()} failed`);return n.result}async _blockhashWithExpiryBlockHeight(t){if(!t){for(;this._pollingBlockhash;)await qp(100);const t=Date.now()-this._blockhashInfo.lastFetch>=3e4;if(null!==this._blockhashInfo.latestBlockhash&&!t)return this._blockhashInfo.latestBlockhash}return await this._pollNewBlockhash()}async _pollNewBlockhash(){this._pollingBlockhash=!0;try{const t=Date.now(),e=this._blockhashInfo.latestBlockhash,n=e?e.blockhash:null;for(let t=0;t<50;t++){const t=await this.getLatestBlockhash("finalized");if(n!==t.blockhash)return this._blockhashInfo={latestBlockhash:t,lastFetch:Date.now(),transactionSignatures:[],simulatedSignatures:[]},t;await qp(200)}throw new Error(`Unable to obtain a new blockhash after ${Date.now()-t}ms`)}finally{this._pollingBlockhash=!1}}async getStakeMinimumDelegation(t){const{commitment:e,config:n}=yg(t),r=this._buildArgs([],e,"base64",n),i=ud(await this._rpcRequest("getStakeMinimumDelegation",r),kg(bd()));if("error"in i)throw new Dp(i.error,"failed to get stake minimum delegation");return i.result}async simulateTransaction(t,e,n){if("message"in t){const r=t.serialize(),i=cr.Buffer.from(r).toString("base64");if(Array.isArray(e)||void 0!==n)throw new Error("Invalid arguments");const o=e||{};o.encoding="base64","commitment"in o||(o.commitment=this.commitment),e&&"object"==typeof e&&"innerInstructions"in e&&(o.innerInstructions=e.innerInstructions);const s=[i,o],a=ud(await this._rpcRequest("simulateTransaction",s),zg);if("error"in a)throw new Error("failed to simulate transaction: "+a.error.message);return a.result}let r;if(t instanceof Pp){let e=t;r=new Pp,r.feePayer=e.feePayer,r.instructions=t.instructions,r.nonceInfo=e.nonceInfo,r.signatures=e.signatures}else r=Pp.populate(t),r._message=r._json=void 0;if(void 0!==e&&!Array.isArray(e))throw new Error("Invalid arguments");const i=e;if(r.nonceInfo&&i)r.sign(...i);else{let t=this._disableBlockhashCaching;for(;;){const e=await this._blockhashWithExpiryBlockHeight(t);if(r.lastValidBlockHeight=e.lastValidBlockHeight,r.recentBlockhash=e.blockhash,!i)break;if(r.sign(...i),!r.signature)throw new Error("!signature");const n=r.signature.toString("base64");if(!this._blockhashInfo.simulatedSignatures.includes(n)&&!this._blockhashInfo.transactionSignatures.includes(n)){this._blockhashInfo.simulatedSignatures.push(n);break}t=!0}}const o=r._compile(),s=o.serialize(),a=r._serialize(s).toString("base64"),c={encoding:"base64",commitment:this.commitment};if(n){const t=(Array.isArray(n)?n:o.nonProgramIds()).map((t=>t.toBase58()));c.accounts={encoding:"base64",addresses:t}}i&&(c.sigVerify=!0),e&&"object"==typeof e&&"innerInstructions"in e&&(c.innerInstructions=e.innerInstructions);const u=[a,c],l=ud(await this._rpcRequest("simulateTransaction",u),zg);if("error"in l){let t;if("data"in l.error&&(t=l.error.data.logs,t&&Array.isArray(t))){const e="\n    ",n=e+t.join(e);console.error(l.error.message,n)}throw new Fp({action:"simulate",signature:"",transactionMessage:l.error.message,logs:t})}return l.result}async sendTransaction(t,e,n){if("version"in t){if(e&&Array.isArray(e))throw new Error("Invalid arguments");const n=t.serialize();return await this.sendRawTransaction(n,e)}if(void 0===e||!Array.isArray(e))throw new Error("Invalid arguments");const r=e;if(t.nonceInfo)t.sign(...r);else{let e=this._disableBlockhashCaching;for(;;){const n=await this._blockhashWithExpiryBlockHeight(e);if(t.lastValidBlockHeight=n.lastValidBlockHeight,t.recentBlockhash=n.blockhash,t.sign(...r),!t.signature)throw new Error("!signature");const i=t.signature.toString("base64");if(!this._blockhashInfo.transactionSignatures.includes(i)){this._blockhashInfo.transactionSignatures.push(i);break}e=!0}}const i=t.serialize();return await this.sendRawTransaction(i,n)}async sendRawTransaction(t,e){const n=Xf(t).toString("base64");return await this.sendEncodedTransaction(n,e)}async sendEncodedTransaction(t,e){const n={encoding:"base64"},r=e&&e.skipPreflight,i=!0===r?"processed":e&&e.preflightCommitment||this.commitment;e&&null!=e.maxRetries&&(n.maxRetries=e.maxRetries),e&&null!=e.minContextSlot&&(n.minContextSlot=e.minContextSlot),r&&(n.skipPreflight=r),i&&(n.preflightCommitment=i);const o=[t,n],s=ud(await this._rpcRequest("sendTransaction",o),Qm);if("error"in s){let t;throw"data"in s.error&&(t=s.error.data.logs),new Fp({action:r?"send":"simulate",signature:"",transactionMessage:s.error.message,logs:t})}return s.result}_wsOnOpen(){this._rpcWebSocketConnected=!0,this._rpcWebSocketHeartbeat=setInterval((()=>{(async()=>{try{await this._rpcWebSocket.notify("ping")}catch{}})()}),5e3),this._updateSubscriptions()}_wsOnError(t){this._rpcWebSocketConnected=!1,console.error("ws error:",t.message)}_wsOnClose(t){this._rpcWebSocketConnected=!1,this._rpcWebSocketGeneration=(this._rpcWebSocketGeneration+1)%Number.MAX_SAFE_INTEGER,this._rpcWebSocketIdleTimeout&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null),this._rpcWebSocketHeartbeat&&(clearInterval(this._rpcWebSocketHeartbeat),this._rpcWebSocketHeartbeat=null),1e3!==t?(this._subscriptionCallbacksByServerSubscriptionId={},Object.entries(this._subscriptionsByHash).forEach((([t,e])=>{this._setSubscription(t,{...e,state:"pending"})}))):this._updateSubscriptions()}_setSubscription(t,e){const n=this._subscriptionsByHash[t]?.state;if(this._subscriptionsByHash[t]=e,n!==e.state){const n=this._subscriptionStateChangeCallbacksByHash[t];n&&n.forEach((t=>{try{t(e.state)}catch{}}))}}_onSubscriptionStateChange(t,e){const n=this._subscriptionHashByClientSubscriptionId[t];if(null==n)return()=>{};const r=this._subscriptionStateChangeCallbacksByHash[n]||=new Set;return r.add(e),()=>{r.delete(e),0===r.size&&delete this._subscriptionStateChangeCallbacksByHash[n]}}async _updateSubscriptions(){if(0===Object.keys(this._subscriptionsByHash).length)return void(this._rpcWebSocketConnected&&(this._rpcWebSocketConnected=!1,this._rpcWebSocketIdleTimeout=setTimeout((()=>{this._rpcWebSocketIdleTimeout=null;try{this._rpcWebSocket.close()}catch(t){t instanceof Error&&console.log(`Error when closing socket connection: ${t.message}`)}}),500)));if(null!==this._rpcWebSocketIdleTimeout&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketConnected=!0),!this._rpcWebSocketConnected)return void this._rpcWebSocket.connect();const t=this._rpcWebSocketGeneration,e=()=>t===this._rpcWebSocketGeneration;await Promise.all(Object.keys(this._subscriptionsByHash).map((async t=>{const n=this._subscriptionsByHash[t];if(void 0!==n)switch(n.state){case"pending":case"unsubscribed":if(0===n.callbacks.size)return delete this._subscriptionsByHash[t],"unsubscribed"===n.state&&delete this._subscriptionCallbacksByServerSubscriptionId[n.serverSubscriptionId],void await this._updateSubscriptions();await(async()=>{const{args:r,method:i}=n;try{this._setSubscription(t,{...n,state:"subscribing"});const e=await this._rpcWebSocket.call(i,r);this._setSubscription(t,{...n,serverSubscriptionId:e,state:"subscribed"}),this._subscriptionCallbacksByServerSubscriptionId[e]=n.callbacks,await this._updateSubscriptions()}catch(o){if(console.error(`Received ${o instanceof Error?"":"JSON-RPC "}error calling \`${i}\``,{args:r,error:o}),!e())return;this._setSubscription(t,{...n,state:"pending"}),await this._updateSubscriptions()}})();break;case"subscribed":0===n.callbacks.size&&await(async()=>{const{serverSubscriptionId:r,unsubscribeMethod:i}=n;if(this._subscriptionsAutoDisposedByRpc.has(r))this._subscriptionsAutoDisposedByRpc.delete(r);else{this._setSubscription(t,{...n,state:"unsubscribing"}),this._setSubscription(t,{...n,state:"unsubscribing"});try{await this._rpcWebSocket.call(i,[r])}catch(r){if(r instanceof Error&&console.error(`${i} error:`,r.message),!e())return;return this._setSubscription(t,{...n,state:"subscribed"}),void await this._updateSubscriptions()}}this._setSubscription(t,{...n,state:"unsubscribed"}),await this._updateSubscriptions()})()}})))}_handleServerNotification(t,e){const n=this._subscriptionCallbacksByServerSubscriptionId[t];void 0!==n&&n.forEach((t=>{try{t(...e)}catch(t){console.error(t)}}))}_wsOnAccountNotification(t){const{result:e,subscription:n}=ud(t,cm);this._handleServerNotification(n,[e.value,e.context])}_makeSubscription(t,e){const n=this._nextClientSubscriptionId++,r=sg([t.method,e]),i=this._subscriptionsByHash[r];return void 0===i?this._subscriptionsByHash[r]={...t,args:e,callbacks:new Set([t.callback]),state:"pending"}:i.callbacks.add(t.callback),this._subscriptionHashByClientSubscriptionId[n]=r,this._subscriptionDisposeFunctionsByClientSubscriptionId[n]=async()=>{delete this._subscriptionDisposeFunctionsByClientSubscriptionId[n],delete this._subscriptionHashByClientSubscriptionId[n];const e=this._subscriptionsByHash[r];bp(void 0!==e,`Could not find a \`Subscription\` when tearing down client subscription #${n}`),e.callbacks.delete(t.callback),await this._updateSubscriptions()},this._updateSubscriptions(),n}onAccountChange(t,e,n){const{commitment:r,config:i}=yg(n),o=this._buildArgs([t.toBase58()],r||this._commitment||"finalized","base64",i);return this._makeSubscription({callback:e,method:"accountSubscribe",unsubscribeMethod:"accountUnsubscribe"},o)}async removeAccountChangeListener(t){await this._unsubscribeClientSubscription(t,"account change")}_wsOnProgramAccountNotification(t){const{result:e,subscription:n}=ud(t,lm);this._handleServerNotification(n,[{accountId:e.value.pubkey,accountInfo:e.value.account},e.context])}onProgramAccountChange(t,e,n,r){const{commitment:i,config:o}=yg(n),s=this._buildArgs([t.toBase58()],i||this._commitment||"finalized","base64",o||(r?{filters:bg(r)}:void 0));return this._makeSubscription({callback:e,method:"programSubscribe",unsubscribeMethod:"programUnsubscribe"},s)}async removeProgramAccountChangeListener(t){await this._unsubscribeClientSubscription(t,"program account change")}onLogs(t,e,n){const r=this._buildArgs(["object"==typeof t?{mentions:[t.toString()]}:t],n||this._commitment||"finalized");return this._makeSubscription({callback:e,method:"logsSubscribe",unsubscribeMethod:"logsUnsubscribe"},r)}async removeOnLogsListener(t){await this._unsubscribeClientSubscription(t,"logs")}_wsOnLogsNotification(t){const{result:e,subscription:n}=ud(t,ey);this._handleServerNotification(n,[e.value,e.context])}_wsOnSlotNotification(t){const{result:e,subscription:n}=ud(t,dm);this._handleServerNotification(n,[e])}onSlotChange(t){return this._makeSubscription({callback:t,method:"slotSubscribe",unsubscribeMethod:"slotUnsubscribe"},[])}async removeSlotChangeListener(t){await this._unsubscribeClientSubscription(t,"slot change")}_wsOnSlotUpdatesNotification(t){const{result:e,subscription:n}=ud(t,pm);this._handleServerNotification(n,[e])}onSlotUpdate(t){return this._makeSubscription({callback:t,method:"slotsUpdatesSubscribe",unsubscribeMethod:"slotsUpdatesUnsubscribe"},[])}async removeSlotUpdateListener(t){await this._unsubscribeClientSubscription(t,"slot update")}async _unsubscribeClientSubscription(t,e){const n=this._subscriptionDisposeFunctionsByClientSubscriptionId[t];n?await n():console.warn(`Ignored unsubscribe request because an active subscription with id \`${t}\` for '${e}' events could not be found.`)}_buildArgs(t,e,n,r){const i=e||this._commitment;if(i||n||r){let e={};n&&(e.encoding=n),i&&(e.commitment=i),r&&(e=Object.assign(e,r)),t.push(e)}return t}_buildArgsAtLeastConfirmed(t,e,n,r){const i=e||this._commitment;if(i&&!["confirmed","finalized"].includes(i))throw new Error("Using Connection with default commitment: `"+this._commitment+"`, but method requires at least `confirmed`");return this._buildArgs(t,e,n,r)}_wsOnSignatureNotification(t){const{result:e,subscription:n}=ud(t,gm);"receivedSignature"!==e.value&&this._subscriptionsAutoDisposedByRpc.add(n),this._handleServerNotification(n,"receivedSignature"===e.value?[{type:"received"},e.context]:[{type:"status",result:e.value},e.context])}onSignature(t,e,n){const r=this._buildArgs([t],n||this._commitment||"finalized"),i=this._makeSubscription({callback:(t,n)=>{if("status"===t.type){e(t.result,n);try{this.removeSignatureListener(i)}catch(t){}}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},r);return i}onSignatureWithOptions(t,e,n){const{commitment:r,...i}={...n,commitment:n&&n.commitment||this._commitment||"finalized"},o=this._buildArgs([t],r,void 0,i),s=this._makeSubscription({callback:(t,n)=>{e(t,n);try{this.removeSignatureListener(s)}catch(t){}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},o);return s}async removeSignatureListener(t){await this._unsubscribeClientSubscription(t,"signature result")}_wsOnRootNotification(t){const{result:e,subscription:n}=ud(t,mm);this._handleServerNotification(n,[e])}onRootChange(t){return this._makeSubscription({callback:t,method:"rootSubscribe",unsubscribeMethod:"rootUnsubscribe"},[])}async removeRootChangeListener(t){await this._unsubscribeClientSubscription(t,"root change")}},Ed25519Program:uy,Enum:class extends Qf{constructor(t){if(super(t),this.enum="",1!==Object.keys(t).length)throw new Error("Enum can only take single value");Object.keys(t).map((t=>{this.enum=t}))}},EpochSchedule:cg,FeeCalculatorLayout:Vp,Keypair:ry,LAMPORTS_PER_SOL:1e9,LOOKUP_TABLE_INSTRUCTION_LAYOUTS:iy,Loader:tg,Lockup:my,MAX_SEED_LENGTH:32,Message:Sp,MessageAccountKeys:hp,MessageV0:xp,NONCE_ACCOUNT_LENGTH:Jp,NonceAccount:Zp,PACKET_DATA_SIZE:sp,PUBLIC_KEY_LENGTH:np,PublicKey:ip,SIGNATURE_LENGTH_IN_BYTES:64,SOLANA_SCHEMA:tp,STAKE_CONFIG_ID:py,STAKE_INSTRUCTION_LAYOUTS:yy,SYSTEM_INSTRUCTION_LAYOUTS:Xp,SYSVAR_CLOCK_PUBKEY:Cp,SYSVAR_EPOCH_SCHEDULE_PUBKEY:Op,SYSVAR_INSTRUCTIONS_PUBKEY:Rp,SYSVAR_RECENT_BLOCKHASHES_PUBKEY:Lp,SYSVAR_RENT_PUBKEY:Np,SYSVAR_REWARDS_PUBKEY:Up,SYSVAR_SLOT_HASHES_PUBKEY:zp,SYSVAR_SLOT_HISTORY_PUBKEY:$p,SYSVAR_STAKE_HISTORY_PUBKEY:Wp,Secp256k1Program:dy,SendTransactionError:Fp,SolanaJSONRPCError:Dp,SolanaJSONRPCErrorCode:{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},StakeAuthorizationLayout:by,StakeInstruction:class{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const e=la("instruction").decode(t.data);let n;for(const[t,r]of Object.entries(yy))if(r.index==e){n=t;break}if(!n)throw new Error("Instruction type incorrect; not a StakeInstruction");return n}static decodeInitialize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{authorized:e,lockup:n}=Hp(yy.Initialize,t.data);return{stakePubkey:t.keys[0].pubkey,authorized:new gy(new ip(e.staker),new ip(e.withdrawer)),lockup:new my(n.unixTimestamp,n.epoch,new ip(n.custodian))}}static decodeDelegate(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,6),Hp(yy.Delegate,t.data),{stakePubkey:t.keys[0].pubkey,votePubkey:t.keys[1].pubkey,authorizedPubkey:t.keys[5].pubkey}}static decodeAuthorize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{newAuthorized:e,stakeAuthorizationType:n}=Hp(yy.Authorize,t.data),r={stakePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey,newAuthorizedPubkey:new ip(e),stakeAuthorizationType:{index:n}};return t.keys.length>3&&(r.custodianPubkey=t.keys[3].pubkey),r}static decodeAuthorizeWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{newAuthorized:e,stakeAuthorizationType:n,authoritySeed:r,authorityOwner:i}=Hp(yy.AuthorizeWithSeed,t.data),o={stakePubkey:t.keys[0].pubkey,authorityBase:t.keys[1].pubkey,authoritySeed:r,authorityOwner:new ip(i),newAuthorizedPubkey:new ip(e),stakeAuthorizationType:{index:n}};return t.keys.length>3&&(o.custodianPubkey=t.keys[3].pubkey),o}static decodeSplit(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{lamports:e}=Hp(yy.Split,t.data);return{stakePubkey:t.keys[0].pubkey,splitStakePubkey:t.keys[1].pubkey,authorizedPubkey:t.keys[2].pubkey,lamports:e}}static decodeMerge(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3),Hp(yy.Merge,t.data),{stakePubkey:t.keys[0].pubkey,sourceStakePubKey:t.keys[1].pubkey,authorizedPubkey:t.keys[4].pubkey}}static decodeWithdraw(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,5);const{lamports:e}=Hp(yy.Withdraw,t.data),n={stakePubkey:t.keys[0].pubkey,toPubkey:t.keys[1].pubkey,authorizedPubkey:t.keys[4].pubkey,lamports:e};return t.keys.length>5&&(n.custodianPubkey=t.keys[5].pubkey),n}static decodeDeactivate(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3),Hp(yy.Deactivate,t.data),{stakePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey}}static checkProgramId(t){if(!t.equals(wy.programId))throw new Error("invalid instruction; programId is not StakeProgram")}static checkKeyLength(t,e){if(t.length<e)throw new Error(`invalid instruction; found ${t.length} keys, expected at least ${e}`)}},StakeProgram:wy,Struct:Qf,SystemInstruction:class{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const e=la("instruction").decode(t.data);let n;for(const[t,r]of Object.entries(Xp))if(r.index==e){n=t;break}if(!n)throw new Error("Instruction type incorrect; not a SystemInstruction");return n}static decodeCreateAccount(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{lamports:e,space:n,programId:r}=Hp(Xp.Create,t.data);return{fromPubkey:t.keys[0].pubkey,newAccountPubkey:t.keys[1].pubkey,lamports:e,space:n,programId:new ip(r)}}static decodeTransfer(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{lamports:e}=Hp(Xp.Transfer,t.data);return{fromPubkey:t.keys[0].pubkey,toPubkey:t.keys[1].pubkey,lamports:e}}static decodeTransferWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{lamports:e,seed:n,programId:r}=Hp(Xp.TransferWithSeed,t.data);return{fromPubkey:t.keys[0].pubkey,basePubkey:t.keys[1].pubkey,toPubkey:t.keys[2].pubkey,lamports:e,seed:n,programId:new ip(r)}}static decodeAllocate(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,1);const{space:e}=Hp(Xp.Allocate,t.data);return{accountPubkey:t.keys[0].pubkey,space:e}}static decodeAllocateWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,1);const{base:e,seed:n,space:r,programId:i}=Hp(Xp.AllocateWithSeed,t.data);return{accountPubkey:t.keys[0].pubkey,basePubkey:new ip(e),seed:n,space:r,programId:new ip(i)}}static decodeAssign(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,1);const{programId:e}=Hp(Xp.Assign,t.data);return{accountPubkey:t.keys[0].pubkey,programId:new ip(e)}}static decodeAssignWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,1);const{base:e,seed:n,programId:r}=Hp(Xp.AssignWithSeed,t.data);return{accountPubkey:t.keys[0].pubkey,basePubkey:new ip(e),seed:n,programId:new ip(r)}}static decodeCreateWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{base:e,seed:n,lamports:r,space:i,programId:o}=Hp(Xp.CreateWithSeed,t.data);return{fromPubkey:t.keys[0].pubkey,newAccountPubkey:t.keys[1].pubkey,basePubkey:new ip(e),seed:n,lamports:r,space:i,programId:new ip(o)}}static decodeNonceInitialize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{authorized:e}=Hp(Xp.InitializeNonceAccount,t.data);return{noncePubkey:t.keys[0].pubkey,authorizedPubkey:new ip(e)}}static decodeNonceAdvance(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3),Hp(Xp.AdvanceNonceAccount,t.data),{noncePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey}}static decodeNonceWithdraw(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,5);const{lamports:e}=Hp(Xp.WithdrawNonceAccount,t.data);return{noncePubkey:t.keys[0].pubkey,toPubkey:t.keys[1].pubkey,authorizedPubkey:t.keys[4].pubkey,lamports:e}}static decodeNonceAuthorize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{authorized:e}=Hp(Xp.AuthorizeNonceAccount,t.data);return{noncePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[1].pubkey,newAuthorizedPubkey:new ip(e)}}static checkProgramId(t){if(!t.equals(Qp.programId))throw new Error("invalid instruction; programId is not SystemProgram")}static checkKeyLength(t,e){if(t.length<e)throw new Error(`invalid instruction; found ${t.length} keys, expected at least ${e}`)}},SystemProgram:Qp,Transaction:Pp,TransactionExpiredBlockheightExceededError:cp,TransactionExpiredNonceInvalidError:lp,TransactionExpiredTimeoutError:up,TransactionInstruction:Bp,TransactionMessage:Tp,TransactionStatus:Ip,VALIDATOR_INFO_KEY:xy,VERSION_PREFIX_MASK:ap,VOTE_PROGRAM_ID:Ay,ValidatorInfo:Iy,VersionedMessage:Ep,VersionedTransaction:Mp,VoteAccount:Py,VoteAuthorizationLayout:ky,VoteInit:vy,VoteInstruction:class{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const e=la("instruction").decode(t.data);let n;for(const[t,r]of Object.entries(_y))if(r.index==e){n=t;break}if(!n)throw new Error("Instruction type incorrect; not a VoteInstruction");return n}static decodeInitializeAccount(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,4);const{voteInit:e}=Hp(_y.InitializeAccount,t.data);return{votePubkey:t.keys[0].pubkey,nodePubkey:t.keys[3].pubkey,voteInit:new vy(new ip(e.nodePubkey),new ip(e.authorizedVoter),new ip(e.authorizedWithdrawer),e.commission)}}static decodeAuthorize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{newAuthorized:e,voteAuthorizationType:n}=Hp(_y.Authorize,t.data);return{votePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey,newAuthorizedPubkey:new ip(e),voteAuthorizationType:{index:n}}}static decodeAuthorizeWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:e,currentAuthorityDerivedKeySeed:n,newAuthorized:r,voteAuthorizationType:i}}=Hp(_y.AuthorizeWithSeed,t.data);return{currentAuthorityDerivedKeyBasePubkey:t.keys[2].pubkey,currentAuthorityDerivedKeyOwnerPubkey:new ip(e),currentAuthorityDerivedKeySeed:n,newAuthorizedPubkey:new ip(r),voteAuthorizationType:{index:i},votePubkey:t.keys[0].pubkey}}static decodeWithdraw(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{lamports:e}=Hp(_y.Withdraw,t.data);return{votePubkey:t.keys[0].pubkey,authorizedWithdrawerPubkey:t.keys[2].pubkey,lamports:e,toPubkey:t.keys[1].pubkey}}static checkProgramId(t){if(!t.equals(Sy.programId))throw new Error("invalid instruction; programId is not VoteProgram")}static checkKeyLength(t,e){if(t.length<e)throw new Error(`invalid instruction; found ${t.length} keys, expected at least ${e}`)}},VoteProgram:Sy,clusterApiUrl:function(t,e){const n=!1===e?"http":"https";if(!t)return Oy[n].devnet;const r=Oy[n][t];if(!r)throw new Error(`Unknown ${n} cluster: ${t}`);return r},sendAndConfirmRawTransaction:async function(t,e,n,r){let i,o;n&&Object.prototype.hasOwnProperty.call(n,"lastValidBlockHeight")||n&&Object.prototype.hasOwnProperty.call(n,"nonceValue")?(i=n,o=r):o=n;const s=o&&{skipPreflight:o.skipPreflight,preflightCommitment:o.preflightCommitment||o.commitment,minContextSlot:o.minContextSlot},a=await t.sendRawTransaction(e,s),c=o&&o.commitment,u=i?t.confirmTransaction(i,c):t.confirmTransaction(a,c),l=(await u).value;if(l.err){if(null!=a)throw new Fp({action:s?.skipPreflight?"send":"simulate",signature:a,transactionMessage:`Status: (${JSON.stringify(l)})`});throw new Error(`Raw transaction ${a} failed (${JSON.stringify(l)})`)}return a},sendAndConfirmTransaction:jp});var Ly=function(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var r=0;r<t.length;r++){var i=t.charAt(r),o=i.charCodeAt(0);if(255!==e[o])throw new TypeError(i+" is ambiguous");e[o]=r}var s=t.length,a=t.charAt(0),c=Math.log(s)/Math.log(256),u=Math.log(256)/Math.log(s);function l(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return new Uint8Array;for(var n=0,r=0,i=0;t[n]===a;)r++,n++;for(var o=(t.length-n)*c+1>>>0,u=new Uint8Array(o);t[n];){var l=e[t.charCodeAt(n)];if(255===l)return;for(var h=0,d=o-1;(0!==l||h<i)&&-1!==d;d--,h++)l+=s*u[d]>>>0,u[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,n++}for(var f=o-i;f!==o&&0===u[f];)f++;for(var p=new Uint8Array(r+(o-f)),g=r;f!==o;)p[g++]=u[f++];return p}return{encode:function(e){if(e instanceof Uint8Array||(ArrayBuffer.isView(e)?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):Array.isArray(e)&&(e=Uint8Array.from(e))),!(e instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===e.length)return"";for(var n=0,r=0,i=0,o=e.length;i!==o&&0===e[i];)i++,n++;for(var c=(o-i)*u+1>>>0,l=new Uint8Array(c);i!==o;){for(var h=e[i],d=0,f=c-1;(0!==h||d<r)&&-1!==f;f--,d++)h+=256*l[f]>>>0,l[f]=h%s>>>0,h=h/s>>>0;if(0!==h)throw new Error("Non-zero carry");r=d,i++}for(var p=c-r;p!==c&&0===l[p];)p++;for(var g=a.repeat(n);p<c;++p)g+=t.charAt(l[p]);return g},decodeUnsafe:l,decode:function(t){var e=l(t);if(e)return e;throw new Error("Non-base"+s+" character")}}};var Ny=Ly("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),Uy=e({__proto__:null,default:Ny},[Ny]);t.AuthProvider=class{constructor(t,e){this.initStatus=Ct.CREATED,this.initPromises=[],this.loginWithOTPStart=t=>n(this,void 0,void 0,(function*(){return yield this.init(),{begin:()=>this._loginWithOTPStart(t),isCompleteRequired:!("global"===(yield this._provider.getKeySpaceConfigType()))}})),this.loginWithCustomProvider=t=>n(this,void 0,void 0,(function*(){return yield this.init(),(yield this.isLoggedIn())?this._provider:(yield this._provider.initCustomLogin(t),yield this.waitForConnect())})),this.loginWithOTPComplete=(t,e)=>n(this,void 0,void 0,(function*(){if("global"===(yield this._provider.getKeySpaceConfigType()))throw new Error("complete is not required for global login");yield this._loginWithOTPComplete(t,e)})),this.loginWithSocial=t=>n(this,void 0,void 0,(function*(){if(yield this.init(),yield this.isLoggedIn())return this._provider;if(!(yield this._provider.isLoginAvailable(t)))throw new Error(`${t} login is not available`);const e=yield this._provider.initSocialLogin(t);return this.beginLogin(e)})),this.loginWithLink=(t,e)=>n(this,void 0,void 0,(function*(){if(yield this.init(),yield this.isLoggedIn())return this._provider;if(!$n(t))throw new Error("Invalid email");const n=yield this._provider.initPasswordlessLogin(t);return n&&"string"==typeof n?this.beginLogin(n):(e&&e(),yield this.waitForConnect())})),this._loginWithOTPStart=t=>n(this,void 0,void 0,(function*(){if(yield this.init(),yield this.isLoggedIn())return;if(!$n(t))throw new Error("Invalid email");const e=yield this._provider.initOTPLogin(t);e&&"string"==typeof e&&(yield this.beginLogin(e))})),this._loginWithOTPComplete=(t,e)=>n(this,void 0,void 0,(function*(){return yield this.init(),(yield this.isLoggedIn())?this._provider:(this._provider.once("message",(t=>{"mfa_flow"===t&&e&&e()})),yield this._provider.completeOTPLogin(t),yield this.waitForConnect())})),this.loginWithBearer=(t,e)=>n(this,void 0,void 0,(function*(){return yield this.init(),yield this.iframeWrapper.triggerBearerAuthentication(t,e)}));let r=null==e?void 0:e.network,i=t;if((t=>{if(!bt(t))throw new Q("invalid_client_id","Invalid Client ID");return 3==t.split("_").length})(t)){const e=(t=>{const e=t.split("_"),[,n,r]=e;if(!wt(r))throw new Error("Invalid ClientId");if("live"==n)return{network:"mainnet",address:r};if("test"==n)return{network:"testnet",address:r};if("dev"==n)return{network:"dev",address:r};throw new Error("Invalid ClientId")})(t);r=e.network,i=e.address}var o;(t=>{if(!(t=>null!=t)(t))throw new Error("appAddress is required");if(!bt(t))throw new Error("appAddress is required to be a non-empty string");if(!wt(t))throw new Error("appAddress is required to be an ethereum address")})(i),this.appId=_t(i),this.params=(t=>{var e;const n={network:"testnet",debug:!1,position:"right",theme:"dark",alwaysVisible:!0,setWindowProvider:!1,useEIP6963:!1,connectOptions:{compact:!1}};return(null==t?void 0:t.network)&&(n.network=t.network),void 0!==(null==t?void 0:t.debug)&&(n.debug=t.debug),(null==t?void 0:t.theme)&&(n.theme=t.theme),(null==t?void 0:t.position)&&(n.position=t.position),void 0!==(null==t?void 0:t.alwaysVisible)&&(n.alwaysVisible=t.alwaysVisible),void 0!==(null===(e=null==t?void 0:t.connectOptions)||void 0===e?void 0:e.compact)&&(n.connectOptions.compact=t.connectOptions.compact),void 0!==(null==t?void 0:t.useEIP6963)&&(n.useEIP6963=t.useEIP6963),"testnet"!=n.network&&"dev"!=n.network||console.log(`%c[XAR_AUTH_SDK] You are currently on ${n.network} network.`,"color: red"),n})(Object.assign(Object.assign({},e),{network:r})),this.networkConfig=(t=>{if("string"==typeof t&&"testnet"==t)return ne;if("string"==typeof t&&"dev"==t)return ee;if("string"==typeof t&&"mainnet"==t)return re;if(function(t){return"string"!=typeof t&&(!("object"!=typeof t||!t.gatewayUrl)&&(!("object"!=typeof t||!t.walletUrl)&&!("object"!=typeof t||!t.authUrl)))}(t))return t;throw new Error("Invalid network config passed")})(this.params.network),function(t,e){try{if("undefined"==typeof document)return;const n=document.createElement("link");n.href=`${t}/${e}/v2/login`,n.type="text/html",n.rel="prefetch",document.head.appendChild(n)}catch(t){console.warn(t)}}(this.networkConfig.walletUrl,this.appId),this._provider=new Pt(this.networkConfig.authUrl),this.params.debug?(ut(rt),o=t=>{console.error(t)},ht.exceptionReporter=o):ut(at)}init(){var t;return n(this,void 0,void 0,(function*(){if(this.initStatus===Ct.CREATED){if(this.initStatus=Ct.RUNNING,this.iframeWrapper)return this;if(yield this.setAppConfig(),this.iframeWrapper=new te({appId:this.appId,iframeUrl:this.networkConfig.walletUrl,appConfig:this.appConfig,position:this.params.position,standaloneMode:this._standaloneMode}),this.iframeWrapper.setWalletType(null!==(t=this.params.appMode)&&void 0!==t?t:this.params.alwaysVisible?Rt.Full:Rt.Widget),yield this._provider.init(this.iframeWrapper,this),this.setProviders(),this.appConfig.chainType===Ot.solana_cv25519)this._solanaAPI=yield ar.create(this._provider);return this.initStatus=Ct.DONE,this.resolveInitPromises(),this}return this.initStatus===Ct.RUNNING?yield this.waitForInit():this}))}connect(){return n(this,void 0,void 0,(function*(){if(this.initStatus!==Ct.DONE&&(yield this.init()),yield this.isLoggedIn())return this._provider;const t=yield this.getLogins();return this.connectCtrl||(this.connectCtrl=new sr({loginWithOTPStart:this.loginWithOTPStart,loginWithOTPComplete:this.loginWithOTPComplete,loginWithSocial:this.loginWithSocial,loginList:t,mode:this.theme,logo:this.logo.vertical,options:this.params.connectOptions})),new Promise(((t,e)=>{this.connectCtrl.open((t=>{if(t)return e(t)})),this.waitForConnect().then((e=>{this.connectCtrl.close(),t(e)})).catch(e)}))}))}showWallet(){if(!this.connected)throw new Error("no connection yet, cannot show wallet");this._provider.expandWallet()}get connected(){return this._provider.connected}getUser(){if(this.initStatus===Ct.DONE)return this._provider.requestUserInfo();throw et}isLoggedIn(){return n(this,void 0,void 0,(function*(){if(this.initStatus===Ct.DONE){return yield this._provider.isLoggedIn()}throw et}))}logout(){if(this.initStatus===Ct.DONE)return this._provider.logout();throw et}getPublicKey(t,e="google"){return n(this,void 0,void 0,(function*(){if(this.initStatus===Ct.DONE){if(!t||""===t)throw new Q("email_required",`Email is required in getPublicKey, got ${t}`);return yield this._provider.getPublicKey(t,e)}throw et}))}getLogins(){return n(this,void 0,void 0,(function*(){if(this.initStatus===Ct.DONE)return yield this._provider.getAvailableLogins();throw et}))}getProvider(){if(this.initStatus===Ct.DONE)return this._provider;throw et}canReconnect(){return n(this,void 0,void 0,(function*(){if(yield this.init(),yield this.isLoggedIn())return!1;const t=this.iframeWrapper.getSessionID();return!!t&&!(t.expiry<Date.now())}))}reconnect(){return n(this,void 0,void 0,(function*(){if(yield this.init(),yield this.isLoggedIn())return void(yield this.waitForConnect());const t=this.iframeWrapper.getSessionID();if(t){if(t.expiry<Date.now())throw new Error("cannot reconnect, session expired");const e=new URL(yield this._provider.getReconnectionUrl());e.searchParams.set("sessionID",t.id);const n=new dt(e.toString());return yield n.open(),void(yield this.waitForConnect())}throw new Error("cannot reconnect, no session found")}))}get chainId(){return this._provider.chainId}beginLogin(t){return n(this,void 0,void 0,(function*(){const e=new dt(t);return yield e.open(),yield this.waitForConnect()}))}waitForConnect(){return new Promise((t=>{if(this.connected)return t(this._provider);this._provider.once("connect",(()=>t(this._provider)))}))}setAppConfig(){return n(this,void 0,void 0,(function*(){const[t,e]=yield Promise.all([ie(this.appId,this.networkConfig.gatewayUrl),oe(this.appId,this.networkConfig.gatewayUrl)]),n=function(t,e,n){const r=new URL(`/api/v2/app/${t}/logo?type=${e}`,n);return{horizontal:`${r.toString()}&orientation=horizontal`,vertical:`${r.toString()}&orientation=vertical`}}(this.appId,this.params.theme,this.networkConfig.gatewayUrl),r=t.logo.dark_horizontal||t.logo.light_horizontal,i=t.logo.dark_vertical||t.logo.light_vertical;this.appConfig={name:e.name,chainType:"evm"===e.chain_type.toLowerCase()?Ot.evm_secp256k1:Ot.solana_cv25519,themeConfig:{assets:{logo:{horizontal:r?n.horizontal:"",vertical:i?n.vertical:""}},theme:this.params.theme}}}))}waitForInit(){return n(this,void 0,void 0,(function*(){const t=new Promise((t=>{this.initPromises.push(t)}));return yield t}))}resolveInitPromises(){const t=this.initPromises;this.initPromises=[];for(const e of t)e(this)}get provider(){if(this._provider)return this._provider;throw et}get solana(){if(this._solanaAPI)return this._solanaAPI;throw et}get logo(){if(this.initStatus===Ct.DONE)return this.appConfig.themeConfig.assets.logo;throw et}get theme(){if(this.initStatus===Ct.DONE)return this.appConfig.themeConfig.theme;throw et}setProviders(){var t;void 0!==typeof window&&(this.providerInfo={uuid:window.crypto.randomUUID(),name:"Arcana Wallet",icon:"data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'/>",rdns:"network.arcana.wallet"},t=()=>{var t,e,n;const r=window;try{r.arcana=null!==(t=r.arcana)&&void 0!==t?t:{},r.arcana.provider=this._provider}catch(t){}if(this.params.setWindowProvider)try{r.ethereum=null!==(e=r.ethereum)&&void 0!==e?e:this._provider,r.ethereum.providers=null!==(n=r.ethereum.providers)&&void 0!==n?n:[],r.ethereum.providers.push(this._provider)}catch(t){console.error(t)}this.params.useEIP6963&&(this.announceProvider(),window.addEventListener("eip6963:requestProvider",(()=>{this.announceProvider()})))},"complete"===document.readyState?t():window.addEventListener("load",t))}announceProvider(){window.dispatchEvent(new CustomEvent("eip6963:announceProvider",{detail:Object.freeze({info:this.providerInfo,provider:this._provider})}))}standaloneMode(t,e){this._standaloneMode={mode:t,handler:e}}},Object.defineProperty(t,"__esModule",{value:!0})}));