PageSourceSearch

https://starsarena.com/_next/static/chunks/0xy47.lnfcgd4.js

js starsarena.com collected 2026-10-05 19:23:32 UTC 772,390 bytes, 22 lines download raw bytes

1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,408927,e=>{"use strict";e.s(["trimEnd",0,(e,t="")=>{let r=e.length-1;for(;r>=0&&e[r]===t;)r--;return e.slice(0,r+1)}])},628873,e=>{"use strict";var t=e.i(407906),r=e.i(408927);e.s(["formatNumberText",0,(e,{precision:i=0}={})=>{if(!i)return e;let s=parseFloat(e),[n,o]=(0,t.ceil)(s,i).toFixed(i).split("."),a=(0,r.trimEnd)(o,"0");return`${n}.${a||"0"}`}])},22439,e=>{"use strict";var t=e.i(284684);class r extends t.CustomError{constructor(e){super(`${e} requires its in-app browser to sign. Open this site inside the ${e} app's browser and try again.`,"wallet_requires_in_app_browser")}}e.s(["WalletRequiresInAppBrowserError",0,r])},951664,e=>{"use strict";e.s(["getProvidersFromWindow",0,e=>{let t=e.split("."),r=window,i=[];for(let[e,s]of Object.entries(t)){if("object"!=typeof(r=r[s])||null===r)return[];Number(e)===t.length-1&&(Array.isArray(r)?r.forEach(e=>i.push(e)):r.providers?r.providers.forEach(e=>i.push(e)):i.push(r))}return i}])},232961,e=>{"use strict";e.s(["ProviderLookup",0,(e,t)=>{if(0!==t.length)return e.find(e=>!0===t.every(t=>((null==e?void 0:e[t.flag])||!1)===t.value))}])},776267,e=>{"use strict";var t=e.i(735400),r=e.i(364697),i=e.i(893554),s=e.i(933795),n=e.i(870948),o=e.i(5746),a=e.i(526539);let l={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},c={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},u=BigInt(0),d=BigInt(2),h=(0,n.Field)(l.p,void 0,void 0,{sqrt:function(e){let t=l.p,r=BigInt(3),i=BigInt(6),s=BigInt(11),o=BigInt(22),a=BigInt(23),c=BigInt(44),u=BigInt(88),f=e*e*e%t,p=f*f*e%t,g=(0,n.pow2)(p,r,t)*p%t,y=(0,n.pow2)(g,r,t)*p%t,m=(0,n.pow2)(y,d,t)*f%t,b=(0,n.pow2)(m,s,t)*m%t,v=(0,n.pow2)(b,o,t)*b%t,w=(0,n.pow2)(v,c,t)*v%t,_=(0,n.pow2)(w,u,t)*w%t,S=(0,n.pow2)(_,c,t)*v%t,E=(0,n.pow2)(S,r,t)*p%t,I=(0,n.pow2)(E,a,t)*b%t,A=(0,n.pow2)(I,i,t)*f%t,T=(0,n.pow2)(A,d,t);if(!h.eql(h.sqr(T),e))throw Error("Cannot find square root");return T}}),f=(0,i.createCurve)({...l,Fp:h,lowS:!0,endo:c},t.sha256);f.Point;a.bytesToNumberBE;let p=(0,s.isogenyMap)(h,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b","0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14","0x0000000000000000000000000000000000000000000000000000000000000001"],["0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c","0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3","0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931","0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"],["0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b","0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573","0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f","0x0000000000000000000000000000000000000000000000000000000000000001"]].map(e=>e.map(e=>BigInt(e)))),g=(0,o.mapToCurveSimpleSWU)(h,{A:BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),B:BigInt("1771"),Z:h.create(BigInt("-11"))});(0,s.createHasher)(f.Point,e=>{let{x:t,y:r}=g(h.create(e[0]));return p(t,r)},{DST:"secp256k1_XMD:SHA-256_SSWU_RO_",encodeDST:"secp256k1_XMD:SHA-256_SSWU_NU_",p:h.ORDER,m:1,k:128,expand:"xmd",hash:t.sha256}),e.s(["secp256k1",0,f])},632677,e=>{"use strict";e.s(["version",0,"4.93.0"])},353766,e=>{"use strict";
1"function"==typeof SuppressedError&&SuppressedError,e.s(["__awaiter",0,function(e,t,r,i){return new(r||(r=Promise))(function(s,n){function o(e){try{l(i.next(e))}catch(e){n(e)}}function a(e){try{l(i.throw(e))}catch(e){n(e)}}function l(e){var t;e.done?s(e.value):((t=e.value)instanceof r?t:new r(function(e){e(t)})).then(o,a)}l((i=i.apply(e,t||[])).next())})},"__classPrivateFieldGet",0,function(e,t,r,i){if("a"===r&&!i)throw TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},"__classPrivateFieldSet",0,function(e,t,r,i,s){if("m"===i)throw TypeError("Private method is not writable");if("a"===i&&!s)throw TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?s.call(e,r):s?s.value=r:t.set(e,r),r}])},818972,e=>{"use strict";var t=e.i(247167),r=e.i(110831);let i="u">typeof window&&void 0!==window.document&&"u">typeof crypto&&void 0!==crypto.subtle,s=void 0!==t.default&&null!=t.default.versions&&null!=t.default.versions.node,n=async(t,r)=>{let n=r??(i?"browser":s?"node":"purejs");switch(n){case"browser":return(await e.A(664017)).signWithApiKey(t);case"node":return(await e.A(830932)).signWithApiKey(t);case"purejs":return(await e.A(311485)).signWithApiKey(t);default:throw Error(`Unsupported runtime: ${n}`)}};e.s(["ApiKeyStamper",0,class{constructor(e){this.apiPublicKey=e.apiPublicKey,this.apiPrivateKey=e.apiPrivateKey,this.runtimeOverride=e.runtimeOverride}async stamp(e){let t=await n({publicKey:this.apiPublicKey,privateKey:this.apiPrivateKey,content:e},this.runtimeOverride),i={publicKey:this.apiPublicKey,scheme:"SIGNATURE_SCHEME_TK_API_P256",signature:t};return{stampHeaderName:"X-Stamp",stampHeaderValue:(0,r.stringToBase64urlString)(JSON.stringify(i))}}},"signWithApiKey",0,n])},147342,(e,t,r)=>{var i="u">typeof globalThis&&globalThis||"u">typeof self&&self||e.g,s=function(){function e(){this.fetch=!1,this.DOMException=i.DOMException}return e.prototype=i,new e}();(function(t){var r=void 0!==s&&s||"u">typeof self&&self||e.g||{},i={searchParams:"URLSearchParams"in r,iterable:"Symbol"in r&&"iterator"in Symbol,blob:"FileReader"in r&&"Blob"in r&&function(){try{return new Blob,!0}catch(e){return!1}}(),formData:"FormData"in r,arrayBuffer:"ArrayBuffer"in r};if(i.arrayBuffer)var n=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],o=ArrayBuffer.isView||function(e){return e&&n.indexOf(Object.prototype.toString.call(e))>-1};function a(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e)||""===e)throw TypeError('Invalid character in header field name: "'+e+'"');return e.toLowerCase()}function l(e){return"string"!=typeof e&&(e=String(e)),e}function c(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return i.iterable&&(t[Symbol.iterator]=function(){return t}),t}function u(e){this.map={},e instanceof u?e.forEach(function(e,t){this.append(t,e)},this):Array.isArray(e)?e.forEach(function(e){if(2!=e.length)throw TypeError("Headers constructor: expected name/value pair to be length 2, found"+e.length);this.append(e[0],e[1])},this):e&&Object.getOwnPropertyNames(e).forEach(function(t){this.append(t,e[t])},this)}function d(e){if(!e._noBody){if(e.bodyUsed)return Promise.reject(TypeError("Already read"));e.bodyUsed=!0}}function h(e){return new Promise(function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}})}function f(e){var t=new FileReader,r=h(t);return t.readAsArrayBuffer(e),r}function p(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function g(){return this.bodyUsed=!1,this._initBody=function(e){if(this.bodyUsed=this.bodyUsed,this._bodyInit=e,e)if("string"==typeof e)this._bodyText=e;else if(i.blob&&Blob.prototype.isPrototypeOf(e))this._bodyBlob=e;else if(i.formData&&FormData.prototype.isPrototypeOf(e))this._bodyFormData=e;else if(i.searchParams&&URLSearchParams.prototype.isPrototypeOf(e))this._bodyText=e.toString();else{var t;i.arrayBuffer&&i.blob&&(t=e)&&DataView.prototype.isPrototypeOf(t)?(this._bodyArrayBuffer=p(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):i.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(e)||o(e))?this._bodyArrayBuffer=p(e):this._bodyText=e=Object.prototype.toString.call(e)}else this._noBody=!0,this._bodyText="";!this.headers.get("content-type")&&("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):i.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},i.blob&&(this.blob=function(){var e=d(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(!this._bodyFormData)return Promise.resolve(new Blob([this._bodyText]));throw Error("could not read FormData body as blob")}),this.arrayBuffer=function(){if(this._bodyArrayBuffer){var e=d(this);return e||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}if(i.blob)return this.blob().then(f);throw Error("could not read as ArrayBuffer")},this.text=function(){var e,t,r,i,s,n=d(this);if(n)return n;if(this._bodyBlob)return e=this._bodyBlob,r=h(t=new FileReader),s=(i=/charset=([A-Za-z0-9_-]+)/.exec(e.type))?i[1]:"utf-8",t.readAsText(e,s),r;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),r=Array(t.length),i=0;i<t.length;i++)r[i]=String.fromCharCode(t[i]);return r.join("")}(this._bodyArrayBuffer));if(!this._bodyFormData)return Promise.resolve(this._bodyText);throw Error("could not read FormData body as text")},i.formData&&(this.formData=function(){return this.text().then(b)}),this.json=function(){return this.text().then(JSON.parse)},this}u.prototype.append=function(e,t){e=a(e),t=l(t);var r=this.map[e];this.map[e]=r?r+", "+t:t},u.prototype.delete=function(e){delete this.map[a(e)]},u.prototype.get=function(e){return e=a(e),this.has(e)?this.map[e]:null},u.prototype.has=function(e){return this.map.hasOwnProperty(a(e))},u.prototype.set=function(e,t){this.map[a(e)]=l(t)},u.prototype.forEach=function(e,t){for(var r in this.map)this.map.hasOwnProperty(r)&&e.call(t,this.map[r],r,this)},u.prototype.keys=function(){var e=[];return this.forEach(function(t,r){e.push(r)}),c(e)},u.prototype.values=function(){var e=[];return this.forEach(function(t){e.push(t)}),c(e)},u.prototype.entries=function(){var e=[];return this.forEach(function(t,r){e.push([r,t])}),c(e)},i.iterable&&(u.prototype[Symbol.iterator]=u.prototype.entries);var y=["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"];function m(e,t){if(!(this instanceof m))throw TypeError('Please use the "new" operator, this DOM object c
1onstructor cannot be called as a function.');var i,s,n=(t=t||{}).body;if(e instanceof m){if(e.bodyUsed)throw TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new u(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,n||null==e._bodyInit||(n=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"same-origin",(t.headers||!this.headers)&&(this.headers=new u(t.headers)),this.method=(s=(i=t.method||this.method||"GET").toUpperCase(),y.indexOf(s)>-1?s:i),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal||function(){if("AbortController"in r)return new AbortController().signal}(),this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&n)throw TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(n),("GET"===this.method||"HEAD"===this.method)&&("no-store"===t.cache||"no-cache"===t.cache)){var o=/([?&])_=[^&]*/;o.test(this.url)?this.url=this.url.replace(o,"$1_="+new Date().getTime()):this.url+=(/\?/.test(this.url)?"&":"?")+"_="+new Date().getTime()}}function b(e){var t=new FormData;return e.trim().split("&").forEach(function(e){if(e){var r=e.split("="),i=r.shift().replace(/\+/g," "),s=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(i),decodeURIComponent(s))}}),t}function v(e,t){if(!(this instanceof v))throw TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.status<200||this.status>599)throw RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=void 0===t.statusText?"":""+t.statusText,this.headers=new u(t.headers),this.url=t.url||"",this._initBody(e)}m.prototype.clone=function(){return new m(this,{body:this._bodyInit})},g.call(m.prototype),g.call(v.prototype),v.prototype.clone=function(){return new v(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new u(this.headers),url:this.url})},v.error=function(){var e=new v(null,{status:200,statusText:""});return e.ok=!1,e.status=0,e.type="error",e};var w=[301,302,303,307,308];v.redirect=function(e,t){if(-1===w.indexOf(t))throw RangeError("Invalid status code");return new v(null,{status:t,headers:{location:e}})},t.DOMException=r.DOMException;try{new t.DOMException}catch(e){t.DOMException=function(e,t){this.message=e,this.name=t;var r=Error(e);this.stack=r.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function _(e,s){return new Promise(function(n,o){var c=new m(e,s);if(c.signal&&c.signal.aborted)return o(new t.DOMException("Aborted","AbortError"));var d=new XMLHttpRequest;function h(){d.abort()}if(d.onload=function(){var e,t,r={statusText:d.statusText,headers:(e=d.getAllResponseHeaders()||"",t=new u,e.replace(/\r?\n[\t ]+/g," ").split("\r").map(function(e){return 0===e.indexOf("\n")?e.substr(1,e.length):e}).forEach(function(e){var r=e.split(":"),i=r.shift().trim();if(i){var s=r.join(":").trim();try{t.append(i,s)}catch(e){console.warn("Response "+e.message)}}}),t)};0===c.url.indexOf("file://")&&(d.status<200||d.status>599)?r.status=200:r.status=d.status,r.url="responseURL"in d?d.responseURL:r.headers.get("X-Request-URL");var i="response"in d?d.response:d.responseText;setTimeout(function(){n(new v(i,r))},0)},d.onerror=function(){setTimeout(function(){o(TypeError("Network request failed"))},0)},d.ontimeout=function(){setTimeout(function(){o(TypeError("Network request timed out"))},0)},d.onabort=function(){setTimeout(function(){o(new t.DOMException("Aborted","AbortError"))},0)},d.open(c.method,function(e){try{return""===e&&r.location.href?r.location.href:e}catch(t){return e}}(c.url),!0),"include"===c.credentials?d.withCredentials=!0:"omit"===c.credentials&&(d.withCredentials=!1),"responseType"in d&&(i.blob?d.responseType="blob":i.arrayBuffer&&(d.responseType="arraybuffer")),s&&"object"==typeof s.headers&&!(s.headers instanceof u||r.Headers&&s.headers instanceof r.Headers)){var f=[];
1Object.getOwnPropertyNames(s.headers).forEach(function(e){f.push(a(e)),d.setRequestHeader(e,l(s.headers[e]))}),c.headers.forEach(function(e,t){-1===f.indexOf(t)&&d.setRequestHeader(t,e)})}else c.headers.forEach(function(e,t){d.setRequestHeader(t,e)});c.signal&&(c.signal.addEventListener("abort",h),d.onreadystatechange=function(){4===d.readyState&&c.signal.removeEventListener("abort",h)}),d.send(void 0===c._bodyInit?null:c._bodyInit)})}_.polyfill=!0,r.fetch||(r.fetch=_,r.Headers=u,r.Request=m,r.Response=v),t.Headers=u,t.Request=m,t.Response=v,t.fetch=_,Object.defineProperty(t,"__esModule",{value:!0})})({}),s.fetch.ponyfill=!0,delete s.fetch.polyfill;var n=i.fetch?i:s;(r=n.fetch).default=n.fetch,r.fetch=n.fetch,r.Headers=n.Headers,r.Request=n.Request,r.Response=n.Response,t.exports=r},211834,e=>{"use strict";let t=e.i(147342).fetch;e.s(["fetch",0,t])},417566,e=>{"use strict";function t(e,t){if("string"!=typeof e||!e)throw Error(`"${t}" must be a non-empty string`);return e}e.s(["getBrowserConfig",0,function(){return{baseUrl:t(null,"baseUrl")}},"getConfig",0,function(){return{apiPublicKey:t(null,"apiPublicKey"),apiPrivateKey:t(null,"apiPrivateKey"),baseUrl:t(null,"baseUrl")}}])},861558,e=>{"use strict";e.s(["bufferToBase64url",0,function(e){let t=new Uint8Array(e),r="";for(let e of t)r+=String.fromCharCode(e);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}])},70266,e=>{"use strict";let t="copy",r="convert";e.s(["convert",0,function e(i,s,n){if(s===t)return n;if(s===r)return i(n);if(s instanceof Array)return n.map(t=>e(i,s[0],t));if(s instanceof Object){let t={};for(let[r,o]of Object.entries(s)){if(o.derive){let e=o.derive(n);void 0!==e&&(n[r]=e)}if(!(r in n)){if(o.required)throw Error(`Missing key: ${r}`);continue}if(null==n[r]){t[r]=null;continue}t[r]=e(i,o.schema,n[r])}return t}},"convertValue",0,r,"copyValue",0,t,"derived",0,function(e,t){return{required:!0,schema:e,derive:t}},"optional",0,function(e){return{required:!1,schema:e}},"required",0,function(e){return{required:!0,schema:e}}])},650357,e=>{"use strict";var t=e.i(70266);let r={appid:(0,t.optional)(t.copyValue),appidExclude:(0,t.optional)(t.copyValue),credProps:(0,t.optional)(t.copyValue)},i={type:(0,t.required)(t.copyValue),id:(0,t.required)(t.copyValue),rawId:(0,t.required)(t.convertValue),authenticatorAttachment:(0,t.optional)(t.copyValue),response:(0,t.required)({clientDataJSON:(0,t.required)(t.convertValue),attestationObject:(0,t.required)(t.convertValue),transports:(0,t.derived)(t.copyValue,e=>e.getTransports?.()||[])}),clientExtensionResults:(0,t.derived)(r,e=>e.getClientExtensionResults())},s={type:(0,t.required)(t.copyValue),id:(0,t.required)(t.copyValue),rawId:(0,t.required)(t.convertValue),authenticatorAttachment:(0,t.optional)(t.copyValue),response:(0,t.required)({clientDataJSON:(0,t.required)(t.convertValue),authenticatorData:(0,t.required)(t.convertValue),signature:(0,t.required)(t.convertValue),userHandle:(0,t.required)(t.convertValue)}),clientExtensionResults:(0,t.derived)(r,e=>e.getClientExtensionResults())};e.s(["publicKeyCredentialWithAssertion",0,s,"publicKeyCredentialWithAttestation",0,i])},391673,e=>{"use strict";var t=e.i(861558),r=e.i(70266),i=e.i(650357);e.s(["createResponseToJSON",0,function(e){return(0,r.convert)(t.bufferToBase64url,i.publicKeyCredentialWithAttestation,e)},"getResponseToJSON",0,function(e){return(0,r.convert)(t.bufferToBase64url,i.publicKeyCredentialWithAssertion,e)}])},133176,e=>{"use strict";var t=e.i(391673);async function r(e){let r=await navigator.credentials.create(e);return r.toJSON=()=>(0,t.createResponseToJSON)(r),r}async function i(e){let r=await navigator.credentials.get(e);return r.toJSON=()=>(0,t.getResponseToJSON)(r),r}e.s(["create",0,r,"get",0,i])},167920,e=>{"use strict";var t=e.i(467034),r=e.i(133176);let i={publicKey:{timeout:3e5,userVerification:"preferred"}};async function s(e,t=i){let r=await n(e);return{...t,publicKey:{...i.publicKey,...t.publicKey,challenge:r}}}async function n(e){let r=new TextEncoder().encode(e),i=await crypto.subtle.digest("SHA-256",r),s=t.Buffer.from(i).toString("hex");return new Uint8Array(t.Buffer.from(s,"utf8"))}async function o(e,t){if(!window.PublicKeyCredential)throw Error("webauthn is not supported by this browser");let i=await s(e,t),n=(await (0,r.get)(i)).toJSON();return JSON.stringify({authenticatorData:n.response.authenticatorData,clientDataJson:n.response.clientDataJSON,credentialId:n.id,signature:n.response.signature})}
1e.s(["getWebAuthnAssertion",0,o])},285942,e=>{"use strict";var t=e.i(818972),r=e.i(211834),i=e.i(417566),s=e.i(110831),n=e.i(167920);let o={},a={redirect:"follow"};async function l(e){let{uri:t,query:r={},substitution:i={},body:s={}}=e,o=u({uri:t,query:r,substitution:i}),a=JSON.stringify(s),l=await (0,n.getWebAuthnAssertion)(a,e.options);return{url:o.toString(),body:a,stamp:l}}async function c(e){let{uri:t,method:i,headers:s={},query:n={},substitution:l={},body:c={}}=e,d=u({uri:t,query:n,substitution:l}),{sealedBody:h,xStamp:g}=await f({body:c}),y=await (0,r.fetch)(d.toString(),{...a,method:i,headers:{...o,...s,"X-Stamp":g},body:h});if(!y.ok){let e;try{e=await y.json()}catch(e){throw Error(`${y.status} ${y.statusText}`)}throw new p(e)}return await y.json()}function u(e){let{uri:t,query:r,substitution:s}=e,n=function(){try{let{baseUrl:e}=(0,i.getConfig)();return e}catch(t){let{baseUrl:e}=(0,i.getBrowserConfig)();return e}}(),o=new URL(function(e,t){let r=e;for(let i of Object.keys(t)){let s=r.replaceAll(`{${i}}`,t[i]);d(s!==r,`Substitution error: cannot find "${i}" in URI "${e}". \`substitutionMap\`: ${JSON.stringify(t)}`),r=s}return d(!/\{.*\}/.test(r),`Substitution error: found unsubstituted components in "${r}"`),r}(t,s),n);for(let e in r){let t=r[e];if(Array.isArray(t))for(let r of t)o.searchParams.append(e,r);else o.searchParams.append(e,t??"")}return o}function d(e,t){if(!e)throw Error(t)}function h(e){return JSON.stringify(e)}async function f(e){let{body:r}=e,{apiPublicKey:n,apiPrivateKey:o}=e;n||(n=(0,i.getConfig)().apiPublicKey),o||(o=(0,i.getConfig)().apiPrivateKey);let a=h(r),l=await (0,t.signWithApiKey)({content:a,privateKey:o,publicKey:n}),c=h({publicKey:n,scheme:"SIGNATURE_SCHEME_TK_API_P256",signature:l});return{sealedBody:a,xStamp:(0,s.stringToBase64urlString)(c)}}
1class p extends Error{constructor(e){let t=`Turnkey error ${e.code}: ${e.message}`;null!=e.details&&(t+=` (Details: ${JSON.stringify(e.details)})`),super(t),this.name="TurnkeyRequestError",this.details=e.details??null,this.code=e.code}}e.s(["TurnkeyRequestError",0,p,"isHttpClient",0,function(e){return e?.name==="TurnkeyClient"},"request",0,c,"signedRequest",0,l])},537897,e=>{"use strict";var t=e.i(285942);e.s(["approveActivity",0,e=>(0,t.request)({uri:"/public/v1/submit/approve_activity",method:"POST",body:e.body}),"createApiKeys",0,e=>(0,t.request)({uri:"/public/v1/submit/create_api_keys",method:"POST",body:e.body}),"createApiOnlyUsers",0,e=>(0,t.request)({uri:"/public/v1/submit/create_api_only_users",method:"POST",body:e.body}),"createAuthenticators",0,e=>(0,t.request)({uri:"/public/v1/submit/create_authenticators",method:"POST",body:e.body}),"createInvitations",0,e=>(0,t.request)({uri:"/public/v1/submit/create_invitations",method:"POST",body:e.body}),"createOauthProviders",0,e=>(0,t.request)({uri:"/public/v1/submit/create_oauth_providers",method:"POST",body:e.body}),"createPolicies",0,e=>(0,t.request)({uri:"/public/v1/submit/create_policies",method:"POST",body:e.body}),"createPolicy",0,e=>(0,t.request)({uri:"/public/v1/submit/create_policy",method:"POST",body:e.body}),"createPrivateKeyTag",0,e=>(0,t.request)({uri:"/public/v1/submit/create_private_key_tag",method:"POST",body:e.body}),"createPrivateKeys",0,e=>(0,t.request)({uri:"/public/v1/submit/create_private_keys",method:"POST",body:e.body}),"createReadOnlySession",0,e=>(0,t.request)({uri:"/public/v1/submit/create_read_only_session",method:"POST",body:e.body}),"createReadWriteSession",0,e=>(0,t.request)({uri:"/public/v1/submit/create_read_write_session",method:"POST",body:e.body}),"createSmartContractInterface",0,e=>(0,t.request)({uri:"/public/v1/submit/create_smart_contract_interface",method:"POST",body:e.body}),"createSubOrganization",0,e=>(0,t.request)({uri:"/public/v1/submit/create_sub_organization",method:"POST",body:e.body}),"createUserTag",0,e=>(0,t.request)({uri:"/public/v1/submit/create_user_tag",method:"POST",body:e.body}),"createUsers",0,e=>(0,t.request)({uri:"/public/v1/submit/create_users",method:"POST",body:e.body}),"createWallet",0,e=>(0,t.request)({uri:"/public/v1/submit/create_wallet",method:"POST",body:e.body}),"createWalletAccounts",0,e=>(0,t.request)({uri:"/public/v1/submit/create_wallet_accounts",method:"POST",body:e.body}),"deleteApiKeys",0,e=>(0,t.request)({uri:"/public/v1/submit/delete_api_keys",method:"POST",body:e.body}),"deleteAuthenticators",0,e=>(0,t.request)({uri:"/public/v1/submit/delete_authenticators",method:"POST",body:e.body}),"deleteInvitation",0,e=>(0,t.request)({uri:"/public/v1/submit/delete_invitation",method:"POST",body:e.body}),"deleteOauthProviders",0,e=>(0,t.request)({uri:"/public/v1/submit/delete_oauth_providers",method:"POST",body:e.body}),"deletePolicy",0,e=>(0,t.request)({uri:"/public/v1/submit/delete_policy",method:"POST",body:e.body}),"deletePrivateKeyTags",0,e=>(0,t.request)({uri:"/public/v1/submit/delete_private_key_tags",method:"POST",body:e.body}),"deletePrivateKeys",0,e=>(0,t.request)({uri:"/public/v1/submit/delete_private_keys",method:"POST",body:e.body}),"deleteSmartContractInterface",0,e=>(0,t.request)({uri:"/public/v1/submit/delete_smart_contract_interface",method:"POST",body:e.body}),"deleteSubOrganization",0,e=>(0,t.request)({uri:"/public/v1/submit/delete_sub_organization",method:"POST",body:e.body}),"deleteUserTags",0,e=>(0,t.request)({uri:"/public/v1/submit/delete_user_tags",method:"POST",body:e.body}),"deleteUsers",0,e=>(0,t.request)({uri:"/public/v1/submit/delete_users",method:"POST",body:e.body}),"deleteWallets",0,e=>(0,t.request)({uri:"/public/v1/submit/delete_wallets",method:"POST",body:e.body}),"emailAuth",0,e=>(0,t.request)({uri:"/public/v1/submit/email_auth",method:"POST",body:e.body}),"exportPrivateKey",0,e=>(0,t.request)({uri:"/public/v1/submit/export_private_key",method:"POST",body:e.body}),"exportWallet",0,e=>(0,t.request)({uri:"/public/v1/submit/export_wallet",method:"POST",body:e.body}),"exportWalletAccount",0,e=>(0,t.request)({uri:"/public/v1/submit/export_wallet_account",method:"POST",body:e.body}),"getActivities",0,e=>(0,t.request)({uri:"/public/v1/query/list_activities",method:"POST",body:e.body}),"getActivity",0,e=>(0,t.request)({uri:"/public/v1/query/get_activity",method:"POST",body:e.body}),"getApiKey",0,e=>(0,t.request)({uri:"/public/v1/query/get_api_key",method:"POST",body:e.body}),"getApiKeys",0,e=>(0,t.request)({uri:"/public/v1/query/get_api_keys",method:"POST",body:e.body}),"getAttestationDocument",0,e=>(0,t.request)({uri:"/public/v1/query/get_attestation",method:"POST",body:e.body}),"getAuthenticator",0,e=>(0,t.request)({uri:"/public/v1/query/get_authenticator",method:"POST",body:e.body}),"getAuthenticators",0,e=>(0,t.request)({uri:"/public/v1/query/get_authenticators",method:"POST",body:e.body}),"getOauthProviders",0,e=>(0,t.request)({uri:"/public/v1/query/get_oauth_providers",method:"POST",body:e.body}),"getOrganization",0,e=>(0,t.request)({uri:"/public/v1/query/get_organization",method:"POST",body:e.body}),"getOrganizationConfigs",0,e=>(0,t.request)({uri:"/public/v1/query/get_organization_configs",method:"POST",body:e.body}),"getPolicies",0,e=>(0,t.request)({uri:"/public/v1/query/list_policies",method:"POST",body:e.body}),"getPolicy",0,e=>(0,t.request)({uri:"/public/v1/query/get_policy",method:"POST",body:e.body}),"getPolicyEvaluations",0,e=>(0,t.request)({uri:"/public/v1/query/get_policy_evaluations",method:"POST",body:e.body}),"getPrivateKey",0,e=>(0,t.request)({uri:"/public/v1/query/get_private_key",method:"POST",body:e.body}),"getPrivateKeys",0,e=>(0,t.request)({uri:"/public/v1/query/list_private_keys",method:"POST",body:e.body}),"getSmartContractInterface",0,e=>(0,t.request)({uri:"/public/v1/query/get_smart_contract_interface",method:"POST",body:e.body}),"getSmartContractInterfaces",0,e=>(0,t.request)({uri:"/public/v1/query/list_smart_contract_interfaces",method:"POST",body:e.body}),"getSubOrgIds",0,e=>(0,t.request)({uri:"/public/v1/query/list_suborgs",method:"POST",body:e.body}),"getUser",0,e=>(0,t.request)({uri:"/public/v1/query/get_user",method:"POST",body:e.body}),"getUsers",0,e=>(0,t.request)({uri:"/public/v1/query/list_users",method:"POST",body:e.body}),"getVerifiedSubOrgIds",0,e=>(0,t.request)({uri:"/public/v1/query/list_verified_suborgs",method:"POST",body:e.body}),"getWallet",0,e=>(0,t.request)({uri:"/public/v1/query/get_wallet",method:"POST",body:e.body}),"getWalletAccount",0,e=>(0,t.request)({uri:"/public/v1/query/get_wallet_account",method:"POST",body:e.body}),"getWalletAccounts",0,e=>(0,t.request)({uri:"/public/v1/query/list_wallet_accounts",method:"POST",body:e.body}),"getWallets",0,e=>(0,t.request)({uri:"/public/v1/query/list_wallets",method:"POST",body:e.body}),"getWhoami",0,e=>(0,t.request)({uri:"/public/v1/query/whoami",method:"POST",body:e.body}),"importPrivateKey",0,e=>(0,t.request)({uri:"/public/v1/submit/import_private_key",method:"POST",body:e.body}),"importWallet",0,e=>(0,t.request)({uri:"/public/v1/submit/import_wallet",method:"POST",body:e.body}),"initFiatOnRamp",0,e=>(0,t.request)({uri:"/public/v1/submit/init_fiat_on_ramp",method:"POST",body:e.body}),"initImportPrivateKey",0,e=>(0,t.request)({uri:"/public/v1/submit/init_import_private_key",method:"POST",body:e.body}),"initImportWallet",0,e=>(0,t.request)({uri:"/public/v1/submit/init_import_wallet",method:"POST",body:e.body}),"initOtp",0,e=>(0,t.request)({uri:"/public/v1/submit/init_otp",method:"POST",body:e.body}),"initOtpAuth",0,e=>(0,t.request)({uri:"/public/v1/submit/init_otp_auth",method:"POST",body:e.body}),"initUserEmailRecovery",0,e=>(0,t.request)({uri:"/public/v1/submit/init_user_email_recovery",method:"POST",body:e.body}),"listPrivateKeyTags",0,e=>(0,t.request)({uri:"/public/v1/query/list_private_key_tags",method:"POST",body:e.body}),"listUserTags",0,e=>(0,t.request)({uri:"/public/v1/query/list_user_tags",method:"POST",body:e.body}),"nOOPCodegenAnchor",0,()=>(0,t.request)({uri:"/tkhq/api/v1/noop-codegen-anchor",method:"POST"}),"oauth",0,e=>(0,t.request)({uri:"/public/v1/submit/oauth",method:"POST",body:e.body}),"oauthLogin",0,e=>(0,t.request)({uri:"/public/v1/submit/oauth_login",method:"POST",body:e.body}),"otpAuth",0,e=>(0,t.request)({uri:"/public/v1/submit/otp_auth",method:"POST",body:e.body}),"otpLogin",0,e=>(0,t.request)({uri:"/public/v1/submit/otp_login",method:"POST",body:e.body}),"recoverUser",0,e=>(0,t.request)({uri:"/public/v1/submit/recover_user",method:"POST",body:e.body}),"rejectActivity",0,e=>(0,t.request)({uri:"/public/v1/submit/reject_activity",method:"POST",body:e.body}),"removeOrganizationFeature",0,e=>(0,t.request)({uri:"/public/v1/submit/remove_organization_feature",method:"POST",body:e.body}),"setOrganizationFeature",0,e=>(0,t.request)({uri:"/public/v1/submit/set_organization_feature",method:"POST",body:e.body}),"signApproveActivity",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/approve_activity",body:e.body,options:r}),"signCreateApiKeys",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/create_api_keys",body:e.body,options:r}),"signCreateApiOnlyUsers",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/create_api_only_users",body:e.body,options:r}),"signCreateAuthenticators",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/create_authenticators",body:e.body,options:r}),"signCreateInvitations",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/create_invitations",body:e.body,options:r}),"signCreateOauthProviders",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/create_oauth_providers",body:e.body,options:r}),"signCreatePolicies",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/create_policies",body:e.body,options:r}),"signCreatePolicy",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/create_policy",body:e.body,options:r}),"signCreatePrivateKeyTag",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/create_private_key_tag",body:e.body,options:r}),"signCreatePrivateKeys",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/create_private_keys",body:e.body,options:r}),"signCreateReadOnlySession",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/create_read_only_session",body:e.body,options:r}),"signCreateReadWriteSession",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/create_read_write_session",body:e.body,options:r}),"signCreateSmartContractInterface",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/create_smart_contract_interface",body:e.body,options:r}),"signCreateSubOrganization",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/create_sub_organization",body:e.body,options:r}),"signCreateUserTag",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/create_user_tag",body:e.body,options:r}),"signCreateUsers",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/create_users",body:e.body,options:r}),"signCreateWallet",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/create_wallet",body:e.body,options:r}),"signCreateWalletAccounts",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/create_wallet_accounts",body:e.body,options:r}),"signDeleteApiKeys",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/delete_api_keys",body:e.body,options:r}),"signDeleteAuthenticators",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/delete_authenticators",body:e.body,options:r}),"signDeleteInvitation",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/delete_invitation",body:e.body,options:r}),"signDeleteOauthProviders",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/delete_oauth_providers",body:e.body,options:r}),"signDeletePolicy",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/delete_policy",body:e.body,options:r}),"signDeletePrivateKeyTags",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/delete_private_key_tags",body:e.body,options:r}),"signDeletePrivateKeys",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/delete_private_keys",body:e.body,options:r}),"signDeleteSmartContractInterface",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/delete_smart_contract_interface",body:e.body,options:r}),"signDeleteSubOrganization",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/delete_sub_organization",body:e.body,options:r}),"signDeleteUserTags",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/delete_user_tags",body:e.body,options:r}),"signDeleteUsers",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/delete_users",body:e.body,options:r}),"signDeleteWallets",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/delete_wallets",body:e.body,options:r}),"signEmailAuth",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/email_auth",body:e.body,options:r}),"signExportPrivateKey",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/export_private_key",body:e.body,options:r}),"signExportWallet",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/export_wallet",body:e.body,options:r}),"signExportWalletAccount",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/export_wallet_account",body:e.body,options:r}),"signGetActivities",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/query/list_activities",body:e.body,options:r}),"signGetActivity",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/query/get_activity",body:e.body,options:r}),"signGetApiKey",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/query/get_api_key",body:e.body,options:r}),"signGetApiKeys",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/query/get_api_keys",body:e.body,options:r}),"signGetAttestationDocument",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/query/get_attestation",body:e.body,options:r}),"signGetAuthenticator",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/query/get_authenticator",body:e.body,options:r}),"signGetAuthenticators",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/query/get_authenticators",body:e.body,options:r}),"signGetOauthProviders",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/query/get_oauth_providers",body:e.body,options:r}),"signGetOrganization",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/query/get_organization",body:e.body,options:r}),"signGetOrganizationConfigs",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/query/get_organization_configs",body:e.body,options:r}),"signGetPolicies",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/query/list_policies",body:e.body,options:r}),"signGetPolicy",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/query/get_policy",body:e.body,options:r}),"signGetPolicyEvaluations",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/query/get_policy_evaluations",body:e.body,options:r}),"signGetPrivateKey",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/query/get_private_key",body:e.body,options:r}),"signGetPrivateKeys",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/query/list_private_keys",body:e.body,options:r}),"signGetSmartContractInterface",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/query/get_smart_contract_interface",body:e.body,options:r}),"signGetSmartContractInterfaces",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/query/list_smart_contract_interfaces",body:e.body,options:r}),"signGetSubOrgIds",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/query/list_suborgs",body:e.body,options:r}),"signGetUser",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/query/get_user",body:e.body,options:r}),"signGetUsers",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/query/list_users",body:e.body,options:r}),"signGetVerifiedSubOrgIds",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/query/list_verified_suborgs",body:e.body,options:r}),"signGetWallet",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/query/get_wallet",body:e.body,options:r}),"signGetWalletAccount",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/query/get_wallet_account",body:e.body,options:r}),"signGetWalletAccounts",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/query/list_wallet_accounts",body:e.body,options:r}),"signGetWallets",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/query/list_wallets",body:e.body,options:r}),"signGetWhoami",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/query/whoami",body:e.body,options:r}),"signImportPrivateKey",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/import_private_key",body:e.body,options:r}),"signImportWallet",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/import_wallet",body:e.body,options:r}),"signInitFiatOnRamp",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/init_fiat_
1on_ramp",body:e.body,options:r}),"signInitImportPrivateKey",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/init_import_private_key",body:e.body,options:r}),"signInitImportWallet",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/init_import_wallet",body:e.body,options:r}),"signInitOtp",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/init_otp",body:e.body,options:r}),"signInitOtpAuth",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/init_otp_auth",body:e.body,options:r}),"signInitUserEmailRecovery",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/init_user_email_recovery",body:e.body,options:r}),"signListPrivateKeyTags",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/query/list_private_key_tags",body:e.body,options:r}),"signListUserTags",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/query/list_user_tags",body:e.body,options:r}),"signNOOPCodegenAnchor",0,()=>(0,t.signedRequest)({uri:"/tkhq/api/v1/noop-codegen-anchor"}),"signOauth",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/oauth",body:e.body,options:r}),"signOauthLogin",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/oauth_login",body:e.body,options:r}),"signOtpAuth",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/otp_auth",body:e.body,options:r}),"signOtpLogin",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/otp_login",body:e.body,options:r}),"signRawPayload",0,e=>(0,t.request)({uri:"/public/v1/submit/sign_raw_payload",method:"POST",body:e.body}),"signRawPayloads",0,e=>(0,t.request)({uri:"/public/v1/submit/sign_raw_payloads",method:"POST",body:e.body}),"signRecoverUser",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/recover_user",body:e.body,options:r}),"signRejectActivity",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/reject_activity",body:e.body,options:r}),"signRemoveOrganizationFeature",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/remove_organization_feature",body:e.body,options:r}),"signSetOrganizationFeature",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/set_organization_feature",body:e.body,options:r}),"signSignRawPayload",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/sign_raw_payload",body:e.body,options:r}),"signSignRawPayloads",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/sign_raw_payloads",body:e.body,options:r}),"signSignTransaction",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/sign_transaction",body:e.body,options:r}),"signStampLogin",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/stamp_login",body:e.body,options:r}),"signTestRateLimits",0,(e,r)=>(0,t.signedRequest)({uri:"/tkhq/api/v1/test_rate_limits",body:e.body,options:r}),"signTransaction",0,e=>(0,t.request)({uri:"/public/v1/submit/sign_transaction",method:"POST",body:e.body}),"signUpdatePolicy",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/update_policy",body:e.body,options:r}),"signUpdatePrivateKeyTag",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/update_private_key_tag",body:e.body,options:r}),"signUpdateRootQuorum",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/update_root_quorum",body:e.body,options:r}),"signUpdateUser",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/update_user",body:e.body,options:r}),"signUpdateUserEmail",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/update_user_email",body:e.body,options:r}),"signUpdateUserName",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/update_user_name",body:e.body,options:r}),"signUpdateUserPhoneNumber",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/update_user_phone_number",body:e.body,options:r}),"signUpdateUserTag",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/update_user_tag",body:e.body,options:r}),"signUpdateWallet",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/update_wallet",body:e.body,options:r}),"signVerifyOtp",0,(e,r)=>(0,t.signedRequest)({uri:"/public/v1/submit/verify_otp",body:e.body,options:r}),"stampLogin",0,e=>(0,t.request)({uri:"/public/v1/submit/stamp_login",method:"POST",body:e.body}),"testRateLimits",0,e=>(0,t.request)({uri:"/tkhq/api/v1/test_rate_limits",method:"POST",body:e.body}),"updatePolicy",0,e=>(0,t.request)({uri:"/public/v1/submit/update_policy",method:"POST",body:e.body}),"updatePrivateKeyTag",0,e=>(0,t.request)({uri:"/public/v1/submit/update_private_key_tag",method:"POST",body:e.body}),"updateRootQuorum",0,e=>(0,t.request)({uri:"/public/v1/submit/update_root_quorum",method:"POST",body:e.body}),"updateUser",0,e=>(0,t.request)({uri:"/public/v1/submit/update_user",method:"POST",body:e.body}),"updateUserEmail",0,e=>(0,t.request)({uri:"/public/v1/submit/update_user_email",method:"POST",body:e.body}),"updateUserName",0,e=>(0,t.request)({uri:"/public/v1/submit/update_user_name",method:"POST",body:e.body}),"updateUserPhoneNumber",0,e=>(0,t.request)({uri:"/public/v1/submit/update_user_phone_number",method:"POST",body:e.body}),"updateUserTag",0,e=>(0,t.request)({uri:"/public/v1/submit/update_user_tag",method:"POST",body:e.body}),"updateWallet",0,e=>(0,t.request)({uri:"/public/v1/submit/update_wallet",method:"POST",body:e.body}),"verifyOtp",0,e=>(0,t.request)({uri:"/public/v1/submit/verify_otp",method:"POST",body:e.body})])},688039,e=>{"use strict";e.s(["VERSION",0,"@turnkey/[email protected]"])},850430,e=>{"use strict";var t=e.i(285942),r=e.i(688039),i=e.i(211834);e.s(["TurnkeyClient",0,class{constructor(e,t){if(this.name="TurnkeyClient",this.getActivity=async e=>this.request("/public/v1/query/get_activity",e),this.stampGetActivity=async e=>{let t=this.config.baseUrl+"/public/v1/query/get_activity",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.getApiKey=async e=>this.request("/public/v1/query/get_api_key",e),this.stampGetApiKey=async e=>{let t=this.config.baseUrl+"/public/v1/query/get_api_key",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.getApiKeys=async e=>this.request("/public/v1/query/get_api_keys",e),this.stampGetApiKeys=async e=>{let t=this.config.baseUrl+"/public/v1/query/get_api_keys",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.getAttestationDocument=async e=>this.request("/public/v1/query/get_attestation",e),this.stampGetAttestationDocument=async e=>{let t=this.config.baseUrl+"/public/v1/query/get_attestation",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.getAuthenticator=async e=>this.request("/public/v1/query/get_authenticator",e),this.stampGetAuthenticator=async e=>{let t=this.config.baseUrl+"/public/v1/query/get_authenticator",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.getAuthenticators=async e=>this.request("/public/v1/query/get_authenticators",e),this.stampGetAuthenticators=async e=>{let t=this.config.baseUrl+"/public/v1/query/get_authenticators",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.getOauthProviders=async e=>this.request("/public/v1/query/get_oauth_providers",e),this.stampGetOauthProviders=async e=>{let t=this.config.baseUrl+"/public/v1/query/get_oauth_providers",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.getOrganization=async e=>this.request("/public/v1/query/get_organization",e),this.stampGetOrganization=async e=>{let t=this.config.baseUrl+"/public/v1/query/get_organization",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.getOrganizationConfigs=async e=>this.request("/public/v1/query/get_organization_configs",e),this.stampGetOrganizationConfigs=async e=>{let t=this.config.baseUrl+"/public/v1/query/get_organization_configs",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.getPolicy=async e=>this.request("/public/v1/query/get_policy",e),this.stampGetPolicy=async e=>{let t=this.config.baseUrl+"/public/v1/query/get_policy",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.getPolicyEvaluations=async e=>this.request("/public/v1/query/get_policy_evaluations",e),this.stampGetPolicyEvaluations=async e=>{let t=this.config.baseUrl+"/public/v1/query/get_policy_evaluations",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.getPrivateKey=async e=>this.request("/public/v1/query/get_private_key",e),this.stampGetPrivateKey=async e=>{let t=this.config.baseUrl+"/public/v1/query/get_private_key",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}}
1,this.getSmartContractInterface=async e=>this.request("/public/v1/query/get_smart_contract_interface",e),this.stampGetSmartContractInterface=async e=>{let t=this.config.baseUrl+"/public/v1/query/get_smart_contract_interface",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.getUser=async e=>this.request("/public/v1/query/get_user",e),this.stampGetUser=async e=>{let t=this.config.baseUrl+"/public/v1/query/get_user",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.getWallet=async e=>this.request("/public/v1/query/get_wallet",e),this.stampGetWallet=async e=>{let t=this.config.baseUrl+"/public/v1/query/get_wallet",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.getWalletAccount=async e=>this.request("/public/v1/query/get_wallet_account",e),this.stampGetWalletAccount=async e=>{let t=this.config.baseUrl+"/public/v1/query/get_wallet_account",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.getActivities=async e=>this.request("/public/v1/query/list_activities",e),this.stampGetActivities=async e=>{let t=this.config.baseUrl+"/public/v1/query/list_activities",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.getPolicies=async e=>this.request("/public/v1/query/list_policies",e),this.stampGetPolicies=async e=>{let t=this.config.baseUrl+"/public/v1/query/list_policies",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.listPrivateKeyTags=async e=>this.request("/public/v1/query/list_private_key_tags",e),this.stampListPrivateKeyTags=async e=>{let t=this.config.baseUrl+"/public/v1/query/list_private_key_tags",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.getPrivateKeys=async e=>this.request("/public/v1/query/list_private_keys",e),this.stampGetPrivateKeys=async e=>{let t=this.config.baseUrl+"/public/v1/query/list_private_keys",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.getSmartContractInterfaces=async e=>this.request("/public/v1/query/list_smart_contract_interfaces",e),this.stampGetSmartContractInterfaces=async e=>{let t=this.config.baseUrl+"/public/v1/query/list_smart_contract_interfaces",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.getSubOrgIds=async e=>this.request("/public/v1/query/list_suborgs",e),this.stampGetSubOrgIds=async e=>{let t=this.config.baseUrl+"/public/v1/query/list_suborgs",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.listUserTags=async e=>this.request("/public/v1/query/list_user_tags",e),this.stampListUserTags=async e=>{let t=this.config.baseUrl+"/public/v1/query/list_user_tags",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.getUsers=async e=>this.request("/public/v1/query/list_users",e),this.stampGetUsers=async e=>{let t=this.config.baseUrl+"/public/v1/query/list_users",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.getVerifiedSubOrgIds=async e=>this.request("/public/v1/query/list_verified_suborgs",e),this.stampGetVerifiedSubOrgIds=async e=>{let t=this.config.baseUrl+"/public/v1/query/list_verified_suborgs",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.getWalletAccounts=async e=>this.request("/public/v1/query/list_wallet_accounts",e),this.stampGetWalletAccounts=async e=>{let t=this.config.baseUrl+"/public/v1/query/list_wallet_accounts",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.getWallets=async e=>this.request("/public/v1/query/list_wallets",e),this.stampGetWallets=async e=>{let t=this.config.baseUrl+"/public/v1/query/list_wallets",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.getWhoami=async e=>this.request("/public/v1/query/whoami",e),this.stampGetWhoami=async e=>{let t=this.config.baseUrl+"/public/v1/query/whoami",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.approveActivity=async e=>this.request("/public/v1/submit/approve_activity",e),this.stampApproveActivity=async e=>{let t=this.config.baseUrl+"/public/v1/submit/approve_activity",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.createApiKeys=async e=>this.request("/public/v1/submit/create_api_keys",e),this.stampCreateApiKeys=async e=>{let t=this.config.baseUrl+"/public/v1/submit/create_api_keys",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.createApiOnlyUsers=async e=>this.request("/public/v1/submit/create_api_only_users",e),this.stampCreateApiOnlyUsers=async e=>{let t=this.config.baseUrl+"/public/v1/submit/create_api_only_users",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.createAuthenticators=async e=>this.request("/public/v1/submit/create_authenticators",e),this.stampCreateAuthenticators=async e=>{let t=this.config.baseUrl+"/public/v1/submit/create_authenticators",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.createInvitations=async e=>this.request("/public/v1/submit/create_invitations",e),this.stampCreateInvitations=async e=>{let t=this.config.baseUrl+"/public/v1/submit/create_invitations",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.createOauthProviders=async e=>this.request("/public/v1/submit/create_oauth_providers",e),this.stampCreateOauthProviders=async e=>{let t=this.config.baseUrl+"/public/v1/submit/create_oauth_providers",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.createPolicies=async e=>this.request("/public/v1/submit/create_policies",e),this.stampCreatePolicies=async e=>{let t=this.config.baseUrl+"/public/v1/submit/create_policies",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.createPolicy=async e=>this.request("/public/v1/submit/create_policy",e),this.stampCreatePolicy=async e=>{let t=this.config.baseUrl+"/public/v1/submit/create_policy",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.createPrivateKeyTag=async e=>this.request("/public/v1/submit/create_private_key_tag",e),this.stampCreatePrivateKeyTag=async e=>{let t=this.config.baseUrl+"/public/v1/submit/create_private_key_tag",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.createPrivateKeys=async e=>this.request("/public/v1/submit/create_private_keys",e),this.stampCreatePrivateKeys=async e=>{let t=this.config.baseUrl+"/public/v1/submit/create_private_keys",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.createReadOnlySession=async e=>this.request("/public/v1/submit/create_read_only_session",e),this.stampCreateReadOnlySession=async e=>{let t=this.config.baseUrl+"/public/v1/submit/create_read_only_session",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.createReadWriteSession=async e=>this.request("/public/v1/submit/create_read_write_session",e),this.stampCreateReadWriteSession=async e=>{let t=this.config.baseUrl+"/public/v1/submit/create_read_write_session",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.createSmartContractInterface=async e=>this.request("/public/v1/submit/create_smart_contract_interface",e),this.stampCreateSmartContractInterface=async e=>{let t=this.config.baseUrl+"/public/v1/submit/create_smart_contract_interface",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.createSubOrganization=async e=>this.request("/public/v1/submit/create_sub_organization",e),this.stampCreateSubOrganization=async e=>{let t=this.config.baseUrl+"/public/v1/submit/create_sub_organization",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.createUserTag=async e=>this.request("/public/v1/submit/create_user_tag",e),this.stampCreateUserTag=async e=>{let t=this.config.baseUrl+"/public/v1/submit/create_user_tag",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.createUsers=async e=>this.request("/public/v1/submit/create_users",e),this.stampCreateUsers=async e=>{let t=this.config.baseUrl+"/public/v1/submit/create_users",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}}
1,this.createWallet=async e=>this.request("/public/v1/submit/create_wallet",e),this.stampCreateWallet=async e=>{let t=this.config.baseUrl+"/public/v1/submit/create_wallet",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.createWalletAccounts=async e=>this.request("/public/v1/submit/create_wallet_accounts",e),this.stampCreateWalletAccounts=async e=>{let t=this.config.baseUrl+"/public/v1/submit/create_wallet_accounts",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.deleteApiKeys=async e=>this.request("/public/v1/submit/delete_api_keys",e),this.stampDeleteApiKeys=async e=>{let t=this.config.baseUrl+"/public/v1/submit/delete_api_keys",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.deleteAuthenticators=async e=>this.request("/public/v1/submit/delete_authenticators",e),this.stampDeleteAuthenticators=async e=>{let t=this.config.baseUrl+"/public/v1/submit/delete_authenticators",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.deleteInvitation=async e=>this.request("/public/v1/submit/delete_invitation",e),this.stampDeleteInvitation=async e=>{let t=this.config.baseUrl+"/public/v1/submit/delete_invitation",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.deleteOauthProviders=async e=>this.request("/public/v1/submit/delete_oauth_providers",e),this.stampDeleteOauthProviders=async e=>{let t=this.config.baseUrl+"/public/v1/submit/delete_oauth_providers",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.deletePolicy=async e=>this.request("/public/v1/submit/delete_policy",e),this.stampDeletePolicy=async e=>{let t=this.config.baseUrl+"/public/v1/submit/delete_policy",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.deletePrivateKeyTags=async e=>this.request("/public/v1/submit/delete_private_key_tags",e),this.stampDeletePrivateKeyTags=async e=>{let t=this.config.baseUrl+"/public/v1/submit/delete_private_key_tags",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.deletePrivateKeys=async e=>this.request("/public/v1/submit/delete_private_keys",e),this.stampDeletePrivateKeys=async e=>{let t=this.config.baseUrl+"/public/v1/submit/delete_private_keys",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.deleteSmartContractInterface=async e=>this.request("/public/v1/submit/delete_smart_contract_interface",e),this.stampDeleteSmartContractInterface=async e=>{let t=this.config.baseUrl+"/public/v1/submit/delete_smart_contract_interface",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.deleteSubOrganization=async e=>this.request("/public/v1/submit/delete_sub_organization",e),this.stampDeleteSubOrganization=async e=>{let t=this.config.baseUrl+"/public/v1/submit/delete_sub_organization",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.deleteUserTags=async e=>this.request("/public/v1/submit/delete_user_tags",e),this.stampDeleteUserTags=async e=>{let t=this.config.baseUrl+"/public/v1/submit/delete_user_tags",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.deleteUsers=async e=>this.request("/public/v1/submit/delete_users",e),this.stampDeleteUsers=async e=>{let t=this.config.baseUrl+"/public/v1/submit/delete_users",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.deleteWallets=async e=>this.request("/public/v1/submit/delete_wallets",e),this.stampDeleteWallets=async e=>{let t=this.config.baseUrl+"/public/v1/submit/delete_wallets",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.emailAuth=async e=>this.request("/public/v1/submit/email_auth",e),this.stampEmailAuth=async e=>{let t=this.config.baseUrl+"/public/v1/submit/email_auth",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.exportPrivateKey=async e=>this.request("/public/v1/submit/export_private_key",e),this.stampExportPrivateKey=async e=>{let t=this.config.baseUrl+"/public/v1/submit/export_private_key",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.exportWallet=async e=>this.request("/public/v1/submit/export_wallet",e),this.stampExportWallet=async e=>{let t=this.config.baseUrl+"/public/v1/submit/export_wallet",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.exportWalletAccount=async e=>this.request("/public/v1/submit/export_wallet_account",e),this.stampExportWalletAccount=async e=>{let t=this.config.baseUrl+"/public/v1/submit/export_wallet_account",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.importPrivateKey=async e=>this.request("/public/v1/submit/import_private_key",e),this.stampImportPrivateKey=async e=>{let t=this.config.baseUrl+"/public/v1/submit/import_private_key",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.importWallet=async e=>this.request("/public/v1/submit/import_wallet",e),this.stampImportWallet=async e=>{let t=this.config.baseUrl+"/public/v1/submit/import_wallet",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.initFiatOnRamp=async e=>this.request("/public/v1/submit/init_fiat_on_ramp",e),this.stampInitFiatOnRamp=async e=>{let t=this.config.baseUrl+"/public/v1/submit/init_fiat_on_ramp",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.initImportPrivateKey=async e=>this.request("/public/v1/submit/init_import_private_key",e),this.stampInitImportPrivateKey=async e=>{let t=this.config.baseUrl+"/public/v1/submit/init_import_private_key",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.initImportWallet=async e=>this.request("/public/v1/submit/init_import_wallet",e),this.stampInitImportWallet=async e=>{let t=this.config.baseUrl+"/public/v1/submit/init_import_wallet",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.initOtp=async e=>this.request("/public/v1/submit/init_otp",e),this.stampInitOtp=async e=>{let t=this.config.baseUrl+"/public/v1/submit/init_otp",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.initOtpAuth=async e=>this.request("/public/v1/submit/init_otp_auth",e),this.stampInitOtpAuth=async e=>{let t=this.config.baseUrl+"/public/v1/submit/init_otp_auth",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.initUserEmailRecovery=async e=>this.request("/public/v1/submit/init_user_email_recovery",e),this.stampInitUserEmailRecovery=async e=>{let t=this.config.baseUrl+"/public/v1/submit/init_user_email_recovery",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.oauth=async e=>this.request("/public/v1/submit/oauth",e),this.stampOauth=async e=>{let t=this.config.baseUrl+"/public/v1/submit/oauth",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.oauthLogin=async e=>this.request("/public/v1/submit/oauth_login",e),this.stampOauthLogin=async e=>{let t=this.config.baseUrl+"/public/v1/submit/oauth_login",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.otpAuth=async e=>this.request("/public/v1/submit/otp_auth",e),this.stampOtpAuth=async e=>{let t=this.config.baseUrl+"/public/v1/submit/otp_auth",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.otpLogin=async e=>this.request("/public/v1/submit/otp_login",e),this.stampOtpLogin=async e=>{let t=this.config.baseUrl+"/public/v1/submit/otp_login",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.recoverUser=async e=>this.request("/public/v1/submit/recover_user",e),this.stampRecoverUser=async e=>{let t=this.config.baseUrl+"/public/v1/submit/recover_user",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.rejectActivity=async e=>this.request("/public/v1/submit/reject_activity",e),this.stampRejectActivity=async e=>{let t=this.config.baseUrl+"/public/v1/submit/reject_activity",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.removeOrganizationFeature=async e=>this.request("/public/v1/submit/remove_organization_feature",e),this.stampRemoveOrganizationFeature=async e=>{let t=this.config.baseUrl+"/public/v1/submit/remove_organization_feature",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.setOrganizationFeature=async e=>this.request("/public/v1/submit/set_organization_feature",e),this.stampSetOrganizationFeature=async e=>{let t=this.config.baseUrl+"/public/v1/submit/set_organization_feature",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.signRawPayload=async e=>this.request("/public/v1/submit/sign_raw_payload",e),this.stampSignRawPayload=async e=>{let t=this.config.baseUrl+"/public/v1/submit/sign_raw_payload",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.signRawPayloads=async e=>this.request("/public/v1/submit/sign_raw_payloads",e),this.stampSignRawPayloads=async e=>{let t=this.config.baseUrl+"/public/v1/submit/sign_raw_payloads",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.signTransaction=async e=>this.request("/public/v1/submit/sign_transaction",e),this.stampSignTransaction=async e=>{let t=this.config.baseUrl+"/public/v1/submit/sign_transaction",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.stampLogin=async e=>this.request("/public/v1/submit/stamp_login",e),this.stampStampLogin=async e=>{let t=this.config.baseUrl+"/public/v1/submit/stamp_login",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.updatePolicy=async e=>this.request("/public/v1/submit/update_policy",e),this.stampUpdatePolicy=async e=>{let t=this.config.baseUrl+"/public/v1/submit/update_policy",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.updatePrivateKeyTag=async e=>this.request("/public/v1/submit/update_private_key_tag",e),this.stampUpdatePrivateKeyTag=async e=>{let t=this.config.baseUrl+"/public/v1/submit/update_private_key_tag",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.updateRootQuorum=async e=>this.request("/public/v1/submit/update_root_quorum",e),this.stampUpdateRootQuorum=async e=>{let t=this.config.baseUrl+"/public/v1/submit/update_root_quorum",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.updateUser=async e=>this.request("/public/v1/submit/update_user",e),this.stampUpdateUser=async e=>{let t=this.config.baseUrl+"/public/v1/submit/update_user",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.updateUserEmail=async e=>this.request("/public/v1/submit/update_user_email",e),this.stampUpdateUserEmail=async e=>{let t=this.config.baseUrl+"/public/v1/submit/update_user_email",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.updateUserName=async e=>this.request("/public/v1/submit/update_user_name",e),this.stampUpdateUserName=async e=>{let t=this.config.baseUrl+"/public/v1/submit/update_user_name",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.updateUserPhoneNumber=async e=>this.request("/public/v1/submit/update_user_phone_number",e),this.stampUpdateUserPhoneNumber=async e=>{let t=this.config.baseUrl+"/public/v1/submit/update_user_phone_number",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.updateUserTag=async e=>this.request("/public/v1/submit/update_user_tag",e),this.stampUpdateUserTag=async e=>{let t=this.config.baseUrl+"/public/v1/submit/update_user_tag",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}}
1,this.updateWallet=async e=>this.request("/public/v1/submit/update_wallet",e),this.stampUpdateWallet=async e=>{let t=this.config.baseUrl+"/public/v1/submit/update_wallet",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.verifyOtp=async e=>this.request("/public/v1/submit/verify_otp",e),this.stampVerifyOtp=async e=>{let t=this.config.baseUrl+"/public/v1/submit/verify_otp",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},this.testRateLimits=async e=>this.request("/tkhq/api/v1/test_rate_limits",e),this.stampTestRateLimits=async e=>{let t=this.config.baseUrl+"/tkhq/api/v1/test_rate_limits",r=JSON.stringify(e),i=await this.stamper.stamp(r);return{body:r,stamp:i,url:t}},!e.baseUrl)throw Error("Missing base URL. Please verify env vars.");this.config=e,this.stamper=t}async request(e,s){let n=this.config.baseUrl+e,o=JSON.stringify(s),a=await this.stamper.stamp(o),l=await (0,i.fetch)(n,{method:"POST",headers:{[a.stampHeaderName]:a.stampHeaderValue,"X-Client-Version":r.VERSION},body:o,redirect:"follow"});if(!l.ok){let e;try{e=await l.json()}catch(e){throw Error(`${l.status} ${l.statusText}`)}throw new t.TurnkeyRequestError(e)}return await l.json()}}])},346653,e=>{"use strict";class t extends Error{constructor(e){const{message:t,cause:r,activityId:i,activityStatus:s,activityType:n}=e;super(t),this.name="TurnkeyActivityError",this.activityId=i??void 0,this.activityStatus=s??void 0,this.activityType=n??void 0,this.cause=r??void 0}}class r extends Error{constructor(e){const{message:t,cause:r,activityId:i,activityStatus:s,activityType:n}=e;super(t),this.name="TurnkeyActivityConsensusNeededError",this.activityId=i??void 0,this.activityStatus=s??void 0,this.activityType=n??void 0,this.cause=r??void 0}}e.s(["TurnkeyActivityConsensusNeededError",0,r,"TurnkeyActivityError",0,t,"assertActivityCompleted",0,function(e){let{id:i,status:s}=e;if("ACTIVITY_STATUS_CONSENSUS_NEEDED"===s)throw new r({message:"Activity requires consensus",activityId:i,activityStatus:s});if("ACTIVITY_STATUS_COMPLETED"!==s)throw new t({message:`Expected COMPLETED status, got ${s}`,activityId:i,activityStatus:s});return!0},"assertNonNull",0,function(e){if(null==e)throw Error(`Got unexpected ${JSON.stringify(e)}`);return e}])},29036,e=>{"use strict";e.i(537897),e.i(346653),e.s([])},94007,e=>{"use strict";e.i(537897),e.i(850430),e.i(285942),e.i(167920),e.i(29036),e.s([])},854972,e=>{"use strict";var t,r,i,s;(i=t||(t={})).PublicKeyReady="PUBLIC_KEY_READY",i.InjectCredentialBundle="INJECT_CREDENTIAL_BUNDLE",i.InjectKeyExportBundle="INJECT_KEY_EXPORT_BUNDLE",i.InjectWalletExportBundle="INJECT_WALLET_EXPORT_BUNDLE",i.InjectImportBundle="INJECT_IMPORT_BUNDLE",i.ExtractWalletEncryptedBundle="EXTRACT_WALLET_ENCRYPTED_BUNDLE",i.ExtractKeyEncryptedBundle="EXTRACT_KEY_ENCRYPTED_BUNDLE",i.ApplySettings="APPLY_SETTINGS",i.BundleInjected="BUNDLE_INJECTED",i.EncryptedBundleExtracted="ENCRYPTED_BUNDLE_EXTRACTED",i.SettingsApplied="SETTINGS_APPLIED",i.StampRequest="STAMP_REQUEST",i.Stamp="STAMP",i.TurnkeyInitMessageChannel="TURNKEY_INIT_MESSAGE_CHANNEL",i.GetEmbeddedPublicKey="GET_EMBEDDED_PUBLIC_KEY",i.ClearEmbeddedKey="RESET_EMBEDDED_KEY",i.InitEmbeddedKey="INIT_EMBEDDED_KEY",i.Error="ERROR",(s=r||(r={})).Hexadecimal="HEXADECIMAL",s.Solana="SOLANA",e.s(["IframeStamper",0,class{constructor(e){if("u"<typeof window)throw Error("Cannot initialize iframe in non-browser environment");if("u"<typeof MessageChannel)throw Error("Cannot initialize iframe without MessageChannel support");if(!e.iframeContainer)throw Error("Iframe container cannot be found");if(this.container=e.iframeContainer,this.container.querySelector(`#${e.iframeElementId}`))throw Error(`Iframe element with ID ${e.iframeElementId} already exists`);let t=window.document.createElement("iframe");t.setAttribute("sandbox","allow-scripts allow-same-origin"),t.id=e.iframeElementId,t.src=e.iframeUrl,this.iframe=t;const r=new URL(e.iframeUrl);this.iframeOrigin=r.origin,this.iframePublicKey=null,this.messageChannel=new MessageChannel,this.pendingRequests=new Map}onMessageHandler(e){let{type:r,value:i,requestId:s}=e.data||{};if(!s){r===t.PublicKeyReady&&(this.iframePublicKey=i);return}let n=this.pendingRequests.get(s);n?(this.pendingRequests.delete(s),r===t.Error)?n.reject(Error(i)):r===t.Stamp?n.resolve({stampHeaderName:"X-Stamp",
1stampHeaderValue:i}):n.resolve(i):console.warn(`Received response for unknown request: ${s}`)}async init(e){return new Promise((r,i)=>{this.container.appendChild(this.iframe),this.iframe.addEventListener("load",()=>{this.iframe.contentWindow?.postMessage?this.iframe.contentWindow.postMessage({type:t.TurnkeyInitMessageChannel,dangerouslyOverrideIframeKeyTtl:e},this.iframeOrigin,[this.messageChannel.port2]):i(Error("contentWindow or contentWindow.postMessage does not exist"))}),this.messageChannel.port1.onmessage=e=>{e.data?.type===t.PublicKeyReady&&(this.iframePublicKey=e.data.value,r(e.data.value)),this.onMessageHandler(e)}})}clear(){this.messageChannel?.port1?.close(),this.messageChannel?.port2?.close(),this.iframe.remove(),this.pendingRequests.clear()}publicKey(){return this.iframePublicKey}async getEmbeddedPublicKey(){let e=await this.createRequest(t.GetEmbeddedPublicKey);return this.iframePublicKey=e,e}async clearEmbeddedKey(){return await this.createRequest(t.ClearEmbeddedKey),this.iframePublicKey="",null}async initEmbeddedKey(){let e=await this.createRequest(t.InitEmbeddedKey);return this.iframePublicKey=e,e}createRequest(e,t={}){return new Promise((r,i)=>{let s=crypto.randomUUID();this.pendingRequests.set(s,{resolve:r,reject:i,requestId:s}),this.messageChannel.port1.postMessage({type:e,requestId:s,...t})})}async injectCredentialBundle(e){return this.createRequest(t.InjectCredentialBundle,{value:e})}async injectKeyExportBundle(e,r,i){return this.createRequest(t.InjectKeyExportBundle,{value:e,keyFormat:i,organizationId:r})}async injectWalletExportBundle(e,r){return this.createRequest(t.InjectWalletExportBundle,{value:e,organizationId:r})}async injectImportBundle(e,r,i){return this.createRequest(t.InjectImportBundle,{value:e,organizationId:r,userId:i})}async extractWalletEncryptedBundle(){return this.createRequest(t.ExtractWalletEncryptedBundle)}async extractKeyEncryptedBundle(e){return this.createRequest(t.ExtractKeyEncryptedBundle,{keyFormat:e})}async applySettings(e){return this.createRequest(t.ApplySettings,{value:JSON.stringify(e)})}async stamp(e){if(null===this.iframePublicKey)throw Error("null iframe public key. Have you called/awaited .init()?");return this.createRequest(t.StampRequest,{value:e})}},"KeyFormat",0,r])},855726,e=>{"use strict";e.s(["BaseTurnkeyHandler",0,class{get client(){return this.__turnkeyClient}get publicKey(){return this.__publicKey}clear(){var e;null==(e=this.__iframeStamper)||e.clear(),this.__iframeStamper=void 0,this.__publicKey=void 0,this.__turnkeyClient=void 0}}])},1641,e=>{"use strict";e.s(["TURNKEY_API_BASE_URL",0,"https://api.turnkey.com","TURNKEY_SDK_BENIGN_ERRORS",0,["The operation either timed out or was not allowed","The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.","Turnkey error 5: webauthn authenticator not found in organization or parent organization","The user cancelled the request"],"TURNKEY_SDK_SESSION_KEY_RETRYABLE_ERRORS",0,["Turnkey error 16: expired api key","Turnkey error 16: could not find public key"]])},618811,e=>{"use strict";e.i(534505);var t=e.i(584643);let r={AUTHENTICATOR_TRANSPORT_BLE:t.AuthenticatorTransportProtocol.Ble,AUTHENTICATOR_TRANSPORT_HYBRID:t.AuthenticatorTransportProtocol.Hybrid,AUTHENTICATOR_TRANSPORT_INTERNAL:t.AuthenticatorTransportProtocol.Internal,AUTHENTICATOR_TRANSPORT_NFC:t.AuthenticatorTransportProtocol.Nfc,AUTHENTICATOR_TRANSPORT_USB:t.AuthenticatorTransportProtocol.Usb};e.s(["convertAttestationTransports",0,e=>e.map(e=>r[e])])},599364,e=>{"use strict";var t=e.i(538990),r=e.i(457382),i=e.i(1641);class s extends t.Logger{constructor(e,t){super(e,t)}error(e,...t){let[s]=t;(null==s?void 0:s.message)&&i.TURNKEY_SDK_BENIGN_ERRORS.some(e=>s.message.includes(e))?this.warn(e,...t):this.log(r.LogLevel.ERROR,e,...t)}}let n=new s("Dynamic embedded wallets",r.LogLevel.INFO);e.s(["logger",0,n])},778906,e=>{"use strict";e.s(["bufferToBase64url",0,function(e){let t=new Uint8Array(e),r="";for(let e of t)r+=String.fromCharCode(e);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}])},981895,e=>{"use strict";let t="copy",r="convert";e.s(["convert",0,function e(i,s,n){if(s===t)return n;if(s===r)return i(n);if(s instanceof Array)return n.map(t=>e(i,s[0],t));if(s instanceof Object){let t={};for(let[r,o]of Object.entries(s)){if(o.derive){let e=o.derive(n);void 0!==e&&(n[r]=e)}if(!(r in n)){if(o.required)throw Error(`Missing key: ${r}`);continue}if(null==n[r]){t[r]=null;continue}t[r]=e(i,o.schema,n[r])}return t}},"convertValue",0,r,"copyValue",0,t,"derived",0,function(e,t){return{required:!0,schema:e,derive:t}},"optional",0,function(e){return{required:!1,schema:e}},"required",0,function(e){return{required:!0,schema:e}}])},277563,e=>{"use strict";var t=e.i(981895);let r={appid:(0,t.optional)(t.copyValue),appidExclude:(0,t.optional)(t.copyValue),credProps:(0,t.optional)(t.copyValue)},i={type:(0,t.required)(t.copyValue),id:(0,t.required)(t.copyValue),rawId:(0,t.required)(t.convertValue),authenticatorAttachment:(0,t.optional)(t.copyValue),response:(0,t.required)({clientDataJSON:(0,t.required)(t.convertValue),authenticatorData:(0,t.required)(t.convertValue),signature:(0,t.required)(t.convertValue),userHandle:(0,t.required)(t.convertValue)}),clientExtensionResults:(0,t.derived)(r,e=>e.getClientExtensionResults())};e.s(["publicKeyCredentialWithAssertion",0,i])},954712,e=>{"use strict";var t=e.i(778906),r=e.i(981895),i=e.i(277563);e.s(["getResponseToJSON",0,function(e){return(0,r.convert)(t.bufferToBase64url,i.publicKeyCredentialWithAssertion,e)}])},810443,e=>{"use strict";var t=e.i(954712);async function r(e){let r=await navigator.credentials.get(e);return r.toJSON=()=>(0,t.getResponseToJSON)(r),r}e.s(["get",0,r])},721461,e=>{"use strict";var t=e.i(810443),r=e.i(229419);e.s(["WebauthnStamper",0,class{constructor(e){this.rpId=e.rpId,this.timeout=e.timeout||3e5,this.userVerification=e.userVerification||"preferred",this.allowCredentials=e.allowCredentials||[]}async stamp(e){var i;let s,n=(i=e,s=(0,r.createHash)().update(i).digest("hex"),new TextEncoder().encode(s)),o={publicKey:{rpId:this.rpId,challenge:n,allowCredentials:this.allowCredentials,timeout:this.timeout,userVerification:this.userVerification}},a=(await (0,t.get)(o)).toJSON();return{stampHeaderName:"X-Stamp-Webauthn",stampHeaderValue:JSON.stringify({authenticatorData:a.response.authenticatorData,clientDataJson:a.response.clientDataJSON,credentialId:a.id,signature:a.response.signature})}}}])},805337,e=>{"use strict";e.s(["version",0,"4.93.0"])},956027,e=>{"use strict";
1"function"==typeof SuppressedError&&SuppressedError,e.s(["__awaiter",0,function(e,t,r,i){return new(r||(r=Promise))(function(s,n){function o(e){try{l(i.next(e))}catch(e){n(e)}}function a(e){try{l(i.throw(e))}catch(e){n(e)}}function l(e){var t;e.done?s(e.value):((t=e.value)instanceof r?t:new r(function(e){e(t)})).then(o,a)}l((i=i.apply(e,t||[])).next())})}])},239045,e=>{"use strict";e.s(["WebauthnNotSupportedError",0,class extends Error{constructor(){super("Webauthn is not supported on this device")}}])},511606,e=>{"use strict";let t=new(e.i(538990)).Logger("Webauthn");e.s(["logger",0,t])},666713,e=>{"use strict";var t=e.i(956027);e.i(671232);var r=e.i(244516),i=e.i(313422),s=e.i(239045),n=e.i(511606);e.s(["createWebauthnCredential",0,e=>(0,t.__awaiter)(void 0,void 0,void 0,function*(){let t;if(!(0,r.browserSupportsWebAuthn)())throw new s.WebauthnNotSupportedError;try{t=yield(0,i.startRegistration)({optionsJSON:e})}catch(e){throw n.logger.debug("Failed to create webauthn credential",e),e}return t})])},710831,e=>{"use strict";e.i(956027),e.i(671232),e.i(244516),e.i(896729),e.i(239045),e.i(511606),e.s([])},259088,e=>{"use strict";e.s(["convertTransportEnumToTurnkeyEnum",0,e=>{switch(e){case"internal":return"AUTHENTICATOR_TRANSPORT_INTERNAL";case"usb":return"AUTHENTICATOR_TRANSPORT_USB";case"nfc":return"AUTHENTICATOR_TRANSPORT_NFC";case"ble":return"AUTHENTICATOR_TRANSPORT_BLE";case"hybrid":return"AUTHENTICATOR_TRANSPORT_HYBRID";default:throw Error("unsupported transport format "+e)}}])},187082,e=>{"use strict";var t=e.i(956027);e.i(671232);var r=e.i(270084),i=e.i(666713),s=e.i(259088);let n=e=>{if(e instanceof ArrayBuffer)return(0,r.bufferToBase64URLString)(e);{let t=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);return(0,r.bufferToBase64URLString)(t)}};e.s(["getWebAuthnAttestationTurnkeyAdapter",0,e=>(0,t.__awaiter)(void 0,void 0,void 0,function*(){var t,r,o,a;if(!e.publicKey)throw Error("Invalid options. Public key attribute must be defined");return{attestationObject:(o=yield(0,i.createWebauthnCredential)(Object.assign(Object.assign({},t=e.publicKey),{challenge:n(t.challenge),excludeCredentials:null==(r=t.excludeCredentials)?void 0:r.map(e=>Object.assign(Object.assign({},e),{id:n(e.id)})),user:Object.assign(Object.assign({},t.user),{id:n(t.user.id)})}))).response.attestationObject,clientDataJson:o.response.clientDataJSON,credentialId:o.rawId,transports:(null==(a=o.response.transports)?void 0:a.map(s.convertTransportEnumToTurnkeyEnum))||[]}})])},729089,e=>{"use strict";e.i(957121);var t=e.i(303690),r=e.i(805337);e.i(666713),e.i(710831),e.i(187082),(0,t.assertPackageVersion)("@dynamic-labs/webauthn",r.version),e.s([])},943560,e=>{"use strict";var t=e.i(721461);e.i(729089);var r=e.i(187082);e.s(["createTurnkeyPasskeyService",0,()=>({createWebauthnStamper:e=>new t.WebauthnStamper(e),getWebAuthnAttestation:r.getWebAuthnAttestationTurnkeyAdapter})])},223395,e=>{"use strict";var t,r,i=e.i(353766),s=e.i(943560);class n{static get implementation(){return(0,i.__classPrivateFieldGet)(t,t,"f",r)?(0,i.__classPrivateFieldGet)(t,t,"f",r):(0,s.createTurnkeyPasskeyService)()}static set implementation(e){(0,i.__classPrivateFieldSet)(t,t,e,"f",r)}static get getWebAuthnAttestation(){return t.implementation.getWebAuthnAttestation}static get createWebauthnStamper(){return t.implementation.createWebauthnStamper}}t=n,r={value:void 0},e.s(["TurnkeyPasskeyService",0,n])},629903,e=>{"use strict";var t=e.i(353766);e.i(94007);var r=e.i(850430),i=e.i(854972);e.i(973402);var s=e.i(624211),n=e.i(791977),o=e.i(415565),a=e.i(855726),l=e.i(1641);e.i(618811);var c=e.i(599364),u=e.i(223395);class d extends a.BaseTurnkeyHandler{constructor(){super(...arguments),this.isSessionActive=()=>!!this.__createdAt&&"email"===this.__recoveryType&&(!this.isExpired(this.__createdAt,this.__sessionExpiration||1800)||(this.clear(),!1)),this.isValidCode=e=>(0,t.__awaiter)(this,void 0,void 0,function*(){var t,r,i,n;if(!e||!this.__turnkeyRecoveryUserId)throw new s.DynamicError("Cannot proceed with your request","proceed_with_your_request");let o=yield null==(t=this.__turnkeyClient)?void 0:t.getUser({organizationId:e,userId:this.__turnkeyRecoveryUserId}),a={email:"CREDENTIAL_TYPE_API_KEY_P256",passkey:"CREDENTIAL_TYPE_RECOVER_USER_KEY_P256"},l=null==(n=null==(i=null==(r=null==o?void 0:o.user)?void 0:r.apiKeys)?void 0:i.filter(e=>e.credential.type===a[this.__recoveryType]))?void 0:n.pop();return!(!l||this.isExpired(parseInt(l.createdAt.seconds,10),900))&&(this.__createdAt=parseInt(l.createdAt.seconds,10),!0)}),this.isExpired=(e,t)=>{let r=new Date(1e3*(e+t));return new Date>=r}}get recoveryType(){return this.__recoveryType}get recoveryUserId(){return this.__turnkeyRecoveryUserId||""}set recoveryUserId(e){this.__turnkeyRecoveryUserId=e}clear(){super.clear(),this.__recoveryType=void 0,this.__turnkeyRecoveryUserId=void 0,this.__createdAt=void 0}initRecovery(e,r,s,n){return(0,t.__awaiter)(this,void 0,void 0,function*(){return this.__recoveryType&&this.clear(),this.__sessionExpiration=n,this.__recoveryType=e,this.__iframeStamper=new i.IframeStamper({iframeContainer:r,iframeElementId:s,iframeUrl:"passkey"===e?"https://recovery.turnkey.com":"https://auth.turnkey.com"}),yield this.__iframeStamper.init(),this.__publicKey=this.__iframeStamper.publicKey(),this.__publicKey})}verifyRecoveryCode(e,i){return(0,t.__awaiter)(this,void 0,void 0,function*(){if(!this.__iframeStamper)throw new s.DynamicError("Cannot proceed with your request","proceed_with_your_request");try{if(yield this.__iframeStamper.injectCredentialBundle(e),this.__turnkeyClient=new r.TurnkeyClient({baseUrl:l.TURNKEY_API_BASE_URL},this.__iframeStamper),!i||!this.__turnkeyRecoveryUserId)throw new s.DynamicError("Cannot proceed with your request","proceed_with_your_request");
1if(!(yield this.isValidCode(i)))throw new s.DynamicError("The code is invalid or expired.","the_code_is_invalid_or_expired")}catch(e){if(c.logger.error("Error while verifying recovery code",e),e instanceof s.DynamicError)throw e;throw new s.DynamicError("The code is invalid or expired.","the_code_is_invalid_or_expired")}})}completeRecovery(e){return(0,t.__awaiter)(this,arguments,void 0,function*({attestation:e,challenge:t,turnkeySubOrganizationId:r}){if(!this.__turnkeyClient||!this.__turnkeyRecoveryUserId)throw new s.DynamicError("Cannot proceed with your request","proceed_with_your_request");try{return this.__turnkeyClient.recoverUser({organizationId:r,parameters:{authenticator:{attestation:e,authenticatorName:"Passkey",challenge:t},userId:this.__turnkeyRecoveryUserId},timestampMs:String(Date.now()),type:"ACTIVITY_TYPE_RECOVER_USER"})}catch(e){throw c.logger.error("[TK] Error while completing recovery process",e),e}})}addPasskeyAuthenticator(e){return(0,t.__awaiter)(this,arguments,void 0,function*({attestation:e,challenge:t,turnkeySubOrganizationId:r}){if(!this.__turnkeyClient||!this.__turnkeyRecoveryUserId)throw new s.DynamicError("Cannot proceed with your request","proceed_with_your_request");try{return this.__turnkeyClient.createAuthenticators({organizationId:r,parameters:{authenticators:[{attestation:e,authenticatorName:"Passkey",challenge:t}],userId:this.__turnkeyRecoveryUserId},timestampMs:String(Date.now()),type:"ACTIVITY_TYPE_CREATE_AUTHENTICATORS_V2"})}catch(e){throw c.logger.error("[TK] Error while creating new authenticator",e),e}})}addEmailRecovery(e){return(0,t.__awaiter)(this,arguments,void 0,function*({organizationId:e,email:t,turnkeyUserId:i}){let s=(0,n.getTLD)();s||(s=o.PlatformService.getHostname());let a=u.TurnkeyPasskeyService.createWebauthnStamper({rpId:s}),d=new r.TurnkeyClient({baseUrl:l.TURNKEY_API_BASE_URL},a);try{return{signedRequest:yield d.stampUpdateUser({organizationId:e,parameters:{userEmail:t,userId:i,userTagIds:[]},timestampMs:String(Date.now()),type:"ACTIVITY_TYPE_UPDATE_USER"}),userId:i}}catch(e){throw c.logger.error("Error while adding email recovery",e),e}})}}let h=new d;e.s(["turnkeyAuthenticatorRecoveryHandler",0,h])},791028,e=>{"use strict";var t=e.i(353766);e.i(94007);var r=e.i(850430),i=e.i(854972);e.i(973402);var s=e.i(791977),n=e.i(415565),o=e.i(624211),a=e.i(629903),l=e.i(855726),c=e.i(1641);e.i(618811);var u=e.i(599364),d=e.i(223395);class h extends l.BaseTurnkeyHandler{initExport(e,o){return(0,t.__awaiter)(this,void 0,void 0,function*(){if(this.__iframeStamper=new i.IframeStamper({iframeContainer:e,iframeElementId:o,iframeUrl:"https://export.turnkey.com"}),yield this.__iframeStamper.init(),this.__publicKey=this.__iframeStamper.publicKey(),a.turnkeyAuthenticatorRecoveryHandler.isSessionActive())this.__turnkeyClient=a.turnkeyAuthenticatorRecoveryHandler.client;else{let e=(0,s.getTLD)();e||(e=n.PlatformService.getHostname());let t=d.TurnkeyPasskeyService.createWebauthnStamper({rpId:e}),i=null==h?void 0:h.apiKeyStamper;this.__turnkeyClient=new r.TurnkeyClient({baseUrl:c.TURNKEY_API_BASE_URL},null!=i?i:t)}return this.__publicKey})}verifyExportWallet(e){return(0,t.__awaiter)(this,arguments,void 0,function*({exportBundle:e,organizationId:t}){if(!this.__iframeStamper)throw new o.DynamicError("Cannot proceed with your request","proceed_with_your_request");try{return yield this.__iframeStamper.injectWalletExportBundle(e,t)}catch(e){throw u.logger.error("Error while verifying export wallet",e),e}})}verifyExportPrivateKey(e){return(0,t.__awaiter)(this,arguments,void 0,function*({exportBundle:e,organizationId:t,chain:r}){if(!this.__iframeStamper)throw new o.DynamicError("Cannot proceed with your request","proceed_with_your_request");let s="solana"===r||"SOL"===r?i.KeyFormat.Solana:i.KeyFormat.Hexadecimal;try{return yield this.__iframeStamper.injectKeyExportBundle(e,t,s)}catch(e){throw u.logger.error("Error while verifying export private key",e),e}})}exportPrivateKey(e){return(0,t.__awaiter)(this,arguments,void 0,function*({privateKeyId:e,organizationId:t}){let i=null==h?void 0:h.apiKeyStamper;if(i&&(this.__turnkeyClient=new r.TurnkeyClient({baseUrl:c.TURNKEY_API_BASE_URL},i)),!this.__iframeStamper||!this.__publicKey||!this.__turnkeyClient||!e)throw new o.DynamicError("Cannot proceed with your request","proceed_with_your_request");try{return(yield this.__turnkeyClient.exportPrivateKey({organizationId:t,parameters:{privateKeyId:e,targetPublicKey:this.__publicKey},timestampMs:String(Date.now()),type:"ACTIVITY_TYPE_EXPORT_PRIVATE_KEY"})).activity}catch(e){throw u.logger.error("[TK] Error while completing export private key process",e),e}})}exportWallet(e){return(0,t.__awaiter)(this,arguments,void 0,function*({walletId:e,organizationId:t,address:i}){let s=null==h?void 0:h.apiKeyStamper;if(s&&(this.__turnkeyClient=new r.TurnkeyClient({baseUrl:c.TURNKEY_API_BASE_URL},s)),!this.__iframeStamper||!this.__publicKey||!this.__turnkeyClient||!e)throw new o.DynamicError("Cannot proceed with your request","proceed_with_your_request");try{if(i)return(yield this.__turnkeyClient.exportWalletAccount({organizationId:t,parameters:{address:i,targetPublicKey:this.__publicKey},timestampMs:String(Date.now()),type:"ACTIVITY_TYPE_EXPORT_WALLET_ACCOUNT"})).activity;return(yield this.__turnkeyClient.exportWallet({organizationId:t,parameters:{targetPublicKey:this.__publicKey,walletId:e},timestampMs:String(Date.now()),type:"ACTIVITY_TYPE_EXPORT_WALLET"})).activity}catch(e){throw u.logger.error("[TK] Error while completing export wallet process",e),e}})}}e.s(["TurnkeyExportHandler",0,h])},555324,e=>{"use strict";var t=e.i(467034);e.s(["base64UrlEncode",0,e=>t.Buffer.from(e).toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")])},702828,e=>{"use strict";e.s(["generateRandomBuffer",0,()=>{let e=new Uint8Array(32);return crypto.getRandomValues(e),e.buffer}])},871186,e=>{"use strict";var t=e.i(353766),r=e.i(818972);e.i(94007);var i=e.i(850430);e.i(973402);var s=e.i(791977),n=e.i(415565),o=e.i(624211),a=e.i(643541);e.i(303778);var l=e.i(721021),c=e.i(629903),u=e.i(1641),d=e.i(791028),h=e.i(555324),f=e.i(702828),p=e.i(618811),g=e.i(599364),y=e.i(223395);class m extends l.WalletConnectorBase{constructor(e,r){if(super(r),this.requiresNonDynamicEmailOtp=!1,this.isEmbeddedWallet=!0,this.removeSessionKeys=()=>(0,t.__awaiter)(this,void 0,void 0,function*(){m.sessionKeys=void 0,m.apiKeyStamper=void 0,d.TurnkeyExportHandler.apiKeyStamper=void 0}),this.stampCreateWalletAccountRequest=e=>(0,t.__awaiter)(this,[e],void 0,function*({request:e}){return yield this.createOrRestoreSession(),(yield this.getTurnkeyClient()).stampCreateWalletAccounts(e)}),this.stampDeleteSubOrganizationRequest=e=>(0,t.__awaiter)(this,[e],void 0,function*({request:e}){return yield this.createOrRestoreSession(),(yield this.getTurnkeyClient()).stampDeleteSubOrganization(e)}),!r.appName)throw Error("appName not set");this.name=e.name,this.overrideKey=e.key,this.appName=r.appName,this.__authenticatorMethodHandler=c.turnkeyAuthenticatorRecoveryHandler}getWebAuthnAttestation(){return(0,t.__awaiter)(this,void 0,void 0,function*(){let e,t=(0,f.generateRandomBuffer)(),r=(0,f.generateRandomBuffer)(),{email:i,passkeyIdentifier:o}=this;if(!i&&!o)throw Error("Email or passkeyIdentifier must be set to register a webauthn credential.");let a=i||`${this.appName} - ${o}`,l={publicKey:{authenticatorSelection:{authenticatorAttachment:void 0,requireResidentKey:!1,residentKey:"preferred",userVerification:"discouraged"},challenge:t,pubKeyCredParams:[{alg:-7,type:"public-key"}],rp:{id:(0,s.getTLD)(),name:this.appName},user:{displayName:a,id:r,name:i||`${this.appName} - ${o}`}}};try{e=yield y.TurnkeyPasskeyService.getWebAuthnAttestation(l)}catch(t){g.logger.warn(`Unable to register webauthn credential on the current page's TLD ${(0,s.getTLD)()}. Falling back to using hostname. ${n.PlatformService.getHostname()}`,t),l.publicKey.rp.id=n.PlatformService.getHostname(),e=yield y.TurnkeyPasskeyService.getWebAuthnAttestation(l)}return{attestation:{attestationObject:e.attestationObject,clientDataJson:e.clientDataJson,credentialId:e.credentialId,transports:(0,p.convertAttestationTransports)(e.transports)},challenge:(0,h.base64UrlEncode)(t),displayName:a}})}getAuthenticatorHandler(){return this.__authenticatorMethodHandler}getExportHandler(){return m.__exportHandler||(m.__exportHandler=new d.TurnkeyExportHandler),m.__exportHandler}get email(){return this._email}setEmail(e){this._email=e}get phone(){return this._phone}setPhone(e){this._phone=e}get passkeyIdentifier(){return this._passkeyIdentifier}setPasskeyIdentifier(e){this._passkeyIdentifier=e}clearEmail(){this._email=null}getAddress(){return(0,t.__awaiter)(this,void 0,void 0,function*(){var e;return null==(e=this.verifiedCredential)?void 0:e.address})}getConnectedAccounts(){return(0,t.__awaiter)(this,void 0,void 0,function*(){return(this.verifiedCredentials||[]).map(e=>null==e?void 0:e.address).filter(e=>"string"==typeof e)})}get turnkeyAddress(){var e;let{address:t}=null!=(e=this.verifiedCredential)?e:{};return t}get walletProperties(){let{walletProperties:e}=this.verifiedCredential||{};return e}set verifiedCredentials(e){this._verifiedCredentials=e}get verifiedCredentials(){return this._verifiedCredentials}set verifiedCredential(e){this._verifiedCredential=e}get verifiedCredential(){return this._verifiedCredential}setSessionKeyFetcher(e){this.createOrRestoreSessionFetcherFunction=e}setSessionKeyRemoveFunction(e){this.removeSessionKeysFunction=e}createOrRestoreSession(){return(0,t.__awaiter)(this,arguments,void 0,function*({ignoreRestore:e}={}){var t,i,s;if(!this.isSessionKeyCompatible()||m.isLoadingSession)return;if(!this.createOrRestoreSessionFetcherFunction)throw new o.DynamicError("Cannot register session key to init provider","register_session_key_to_init_provider");let{sessionKeys:n}=m;if((null==n?void 0:n.publicKey)&&!(new Date>=new Date(n.expirationDate)))return n.publicKey;try{if(m.isLoadingSession=!0,this.isLoadingSessionDeferredPromise=new a.DeferredPromise,!(null==(t=this.verifiedCredential)?void 0:t.id))throw new o.DynamicError("No wallet ID found","no_wallet_id_found");let s=yield this.createOrRestoreSessionFetcherFunction({ignoreRestore:e,w
1alletId:null==(i=this.verifiedCredential)?void 0:i.id});return m.sessionKeys=s,m.apiKeyStamper=new r.ApiKeyStamper({apiPrivateKey:s.privateKey,apiPublicKey:s.publicKey}),d.TurnkeyExportHandler.apiKeyStamper=m.apiKeyStamper,g.logger.metaData.set("sessionApiPublicKey",s.publicKey),s.publicKey}catch(e){throw g.logger.error(e),new o.DynamicError("Failed to create or restore session","create_or_restore_session")}finally{m.isLoadingSession=!1,null==(s=this.isLoadingSessionDeferredPromise)||s.resolve()}})}isSessionKeyCompatible(){var e;let t=null==(e=this.verifiedCredential)?void 0:e.walletProperties;return!!(null==t?void 0:t.isSessionKeyCompatible)}isSessionActive(){return(0,t.__awaiter)(this,void 0,void 0,function*(){return!!((yield this.getAddress())&&m.sessionKeys&&m.apiKeyStamper)})}get sessionKeys(){return m.sessionKeys}getTurnkeyClient(){return(0,t.__awaiter)(this,void 0,void 0,function*(){var e,t;m.isLoadingSession&&(yield null==(e=this.isLoadingSessionDeferredPromise)?void 0:e.promise);let r=(0,s.getTLD)();r||(r=n.PlatformService.getHostname());let o=y.TurnkeyPasskeyService.createWebauthnStamper({rpId:r}),a=null==m?void 0:m.apiKeyStamper;return this.__turnkeyClient=null!=(t=this.getAuthenticatorHandler().client)?t:new i.TurnkeyClient({baseUrl:u.TURNKEY_API_BASE_URL},null!=a?a:o),this.__turnkeyClient})}setLoggerMetadata(){var e,t,r;g.logger.metaData.set("turnkeySubOrganizationId",null==(t=null==(e=this._verifiedCredential)?void 0:e.walletProperties)?void 0:t.turnkeySubOrganizationId),g.logger.metaData.set("walletId",null==(r=this._verifiedCredential)?void 0:r.id);let i="Unknown";this.isSessionKeyCompatible()?i="SessionKeys":"passkey"===this.__authenticatorMethodHandler.recoveryType?i="Passkey":"email"===this.__authenticatorMethodHandler.recoveryType&&(i="EmailAuth"),g.logger.metaData.set("authMethod",i)}}m.isLoadingSession=!1,e.s(["TurnkeyWalletConnectorBase",0,m])},311317,e=>{"use strict";e.i(957121);var t=e.i(303690),r=e.i(632677);e.i(629903),e.i(791028),e.i(871186),e.i(618811),e.i(599364),e.i(223395),(0,t.assertPackageVersion)("@dynamic-labs/embedded-wallet",r.version),e.s([])},513329,e=>{"use strict";e.s(["TurnkeyWalletConnectorInfo",0,{Turnkey:{key:"turnkey",name:"Turnkey"},TurnkeyHD:{key:"turnkeyhd",name:"Turnkey HD"}}])},798622,e=>{"use strict";e.s(["findTurnkeyVerifiedCredentials",0,(e,t)=>null==e?void 0:e.filter(({walletName:e,chain:r})=>(null==e?void 0:e.startsWith("turnkey"))&&t===r),"findTurnkeyVerifiedCredentialsWithSmartWalletRef",0,(e,t)=>null==e?void 0:e.reduce((r,i)=>{var s;if((null==(s=i.walletName)?void 0:s.startsWith("turnkey"))&&t===i.chain){let t=e.find(e=>e.signerRefId===i.id),s=null==t?void 0:t.id,n=null==t?void 0:t.address;r.push(Object.assign(Object.assign({},i),{smartWalletRefAddress:n,smartWalletRefId:s}))}return r},[])])},136724,e=>{"use strict";e.s(["version",0,"4.93.0"])},379433,e=>{"use strict";"function"==typeof SuppressedError&&SuppressedError,e.s(["__awaiter",0,function(e,t,r,i){return new(r||(r=Promise))(function(s,n){function o(e){try{l(i.next(e))}catch(e){n(e)}}function a(e){try{l(i.throw(e))}catch(e){n(e)}}function l(e){var t;e.done?s(e.value):((t=e.value)instanceof r?t:new r(function(e){e(t)})).then(o,a)}l((i=i.apply(e,t||[])).next())})}])},598927,e=>{"use strict";e.s(["DEFAULT_BASE_API_URL",0,"https://app.dynamicauth.com","DEFAULT_BASE_MPC_RELAY_API_URL",0,"https://relay.dynamicauth.com"])},535369,e=>{"use strict";var t=e.i(379433);e.i(973402);var r=e.i(159491);e.s(["createWaasClientSecureStorage",0,()=>({getClientKeyShare:e=>(0,t.__awaiter)(void 0,void 0,void 0,function*(){let t=r.StorageService.getItem(`waas_client_key_share_${e}`,{priority:["secureStorage"]});return t?JSON.parse(t):[]}),removeClientKeyShare:e=>(0,t.__awaiter)(void 0,void 0,void 0,function*(){r.StorageService.removeItem(`waas_client_key_share_${e}`,{priority:["secureStorage"]})}),setClientKeyShare:(e,i)=>(0,t.__awaiter)(void 0,void 0,void 0,function*(){return r.StorageService.setItem(`waas_client_key_share_${e}`,JSON.stringify(i),{priority:["secureStorage"]})})})])},694121,e=>{"use strict";e.s(["InstrumentationTimer",0,class{constructor(e){this.startTime=e||Date.now(),this.stepStartTime=this.startTime}getElapsed(){return Date.now()-this.startTime}startStep(){this.stepStartTime=Date.now()}getStepElapsed(){return Date.now()-this.stepStartTime}resetStep(){this.startStep()}setStartTime(e){this.startTime=e}setStepStartTime(e){this.stepStartTime=e}}])},947569,e=>{"use strict";e.i(534505);var t=e.i(522546);let r=[t.JwtScope.RequiresAdditionalAuth,t.JwtScope.UserDataForm,t.JwtScope.Deviceregister];e.s(["tokenHasPendingAuthScope",0,e=>{var t,i;return(null!=(i=null==(t=(e=>{let t=null==e?void 0:e.split(".")[1];if(t)try{return JSON.parse(atob(t)).scope}catch(e){return}})(e))?void 0:t.split(" "))?i:[]).some(e=>r.includes(e))}])},858899,e=>{"use strict";var t=e.i(379433),r=e.i(522898);e.i(534505);var i=e.i(229557),s=e.i(877774);e.i(973402);var n=e.i(624211),o=e.i(382531),a=e.i(415565),l=e.i(318989),c=e.i(136724),u=e.i(598927),d=e.i(535369),h=e.i(694121),f=e.i(947569);let p="unknown";class g{constructor(){this.iframeStamper=null}setIframeStamper(e){this.iframeStamper=e}clear(){this.iframeStamper&&(this.iframeStamper.remove(),this.iframeStamper=null)}}e.s(["WaasExportHandler",0,g,"withDynamicWaas",0,e=>class extends e{setGetAuthTokenFunction(e){this.getAuthToken=e}setOnUnauthorizedFunction(e){this.onUnauthorized=e}setWaasAuthMode(e){this.authMode=e}setGetMfaTokenFunction(e){this.getMfaToken=e}setGetElevatedAccessTokenFunction(e){this.getElevatedAccessToken=e}setGetWalletPasswordFunction(e){this.getWalletPassword=e}getPasswordIfNeeded(e){return(0,t.__awaiter)(this,arguments,void 0,function*({accountAddress:e}){let t=yield this.getWalletRecoveryState({accountAddress:e});if("ready"===t.walletReadyState||!t.isPasswordEncrypted)return;if(!this.getWalletPassword)throw new n.DynamicError("Wallet is locked but no password provider is configured","wallet_is_locked_but_no_password");let r=yield this.getWalletPassword({accountAddress:e,chainName:this.chainName});if(!r)throw new o.UserRejectedRequestError;return r})}getPassword(e){return(0,t.__awaiter)(this,arguments,void 0,function*({accountAddress:e}){if(this.getWalletPassword&&(yield this.getWalletRecoveryState({accountAddress:e})).isPasswordEncrypted)return this.getWalletPassword({accountAddress:e,chainName:this.chainName})})}setEnvironmentId(e){this.environmentId=e}setBaseApiUrl(e){this.baseApiUrl=e}setBaseClientKeysharesRelayApiUrl(e){this.baseClientKeysharesRelayApiUrl=e}setRelayUrl(e){this.relayUrl=e}
1setGetSignedSessionIdFunction(e){this.getSignedSessionId=e}setGetSessionPublicKeyFunction(e){this.getSessionPublicKey=e}delegateKeyShares(e){return(0,t.__awaiter)(this,arguments,void 0,function*({accountAddress:e,password:t}){var r,i,s;if(!e)throw Error("Account address is required");let n=null!=t?t:yield this.getPasswordIfNeeded({accountAddress:e}),o=yield this.getWaasWalletClient(),a=yield null==(r=this.getSignedSessionId)?void 0:r.call(this);if(!a)throw Error("Signed session ID is required");let l=null==(i=this.getAuthToken)?void 0:i.call(this);if(!l)throw Error("Auth token is required");return o.delegateKeyShares({accountAddress:e,authToken:l,password:n,sessionPublicKey:yield null==(s=this.getSessionPublicKey)?void 0:s.call(this),signedSessionId:a})})}constructor(...e){super(...e),this.name="Dynamic Waas",this.overrideKey="dynamicwaas",this.isEmbeddedWallet=!0,this.authMode="header",this.__exportHandler=new g;const{connectedChain:t}=this,r={ALEO:"ALEO",BTC:"BTC",EVM:"EVM",MIDNIGHT:"MIDNIGHT",SOL:"SVM",STELLAR:"STELLAR",SUI:"SUI",TEMPO:"TEMPO",TON:"TON"}[t];if(!r)throw new n.DynamicError(`Unsupported chain: ${t}`,"unsupported_chain");this.chainName=r}createRevocableSignedSessionCallback(){if(!this.getSignedSessionId)throw Error("[DynamicWaasMixin] getSignedSessionId must be set before creating a revocable callback");let e=this.getSignedSessionId,r=!1;return this.revokeSignedSession=()=>{r=!0},{getSignedSessionId:()=>(0,t.__awaiter)(this,void 0,void 0,function*(){if(r)throw Error("[DynamicWaasMixin] WaaS client replaced — signed session callback revoked");return e()})}}createDynamicWaasClient(e){return(0,t.__awaiter)(this,void 0,void 0,function*(){var i;let s=null==(i=this.getAuthToken)?void 0:i.call(this);if(!s&&"header"===this.authMode)throw new n.DynamicError("Auth token is required in non-cookie auth mode","auth_token_is_required_in_noncookie");if(!this.environmentId)throw new n.DynamicError("Environment ID is required","environment_id_is_required");let o=new r.DynamicWalletClient({authMode:this.authMode||"header",authToken:s||"",baseApiUrl:this.baseApiUrl||u.DEFAULT_BASE_API_URL,baseClientKeysharesRelayApiUrl:this.baseClientKeysharesRelayApiUrl,baseMPCRelayApiUrl:this.relayUrl||u.DEFAULT_BASE_MPC_RELAY_API_URL,chainName:this.chainName,eagerlyRecoverKeyShares:!0,environmentId:this.environmentId,sdkVersion:c.version},Object.assign(Object.assign(Object.assign(Object.assign({},a.PlatformService.isWaasSecureStorageSupported?{secureStorage:(0,d.createWaasClientSecureStorage)()}:{}
1),this.getSignedSessionId?this.createRevocableSignedSessionCallback():{}),this.getSessionPublicKey?{getSessionPublicKey:this.getSessionPublicKey}:{}),this.onUnauthorized?{onUnauthorized:this.onUnauthorized}:{}));return this.instrumentAsync({context:e,fn:()=>(0,t.__awaiter)(this,void 0,void 0,function*(){return o.initialize()}),operation:"createDynamicWaasClient",resource:"initialize"}),o})}getWaasWalletClient(e){return(0,t.__awaiter)(this,arguments,void 0,function*(e,{forceRebuild:t=!1}={}){var r,i;if(t&&(null==(r=this.revokeSignedSession)||r.call(this),this.revokeSignedSession=void 0,this.dynamicWaasClient=void 0),!this.dynamicWaasClient){if((0,f.tokenHasPendingAuthScope)(null==(i=this.getAuthToken)?void 0:i.call(this)))throw new l.WaasAuthScopePendingError;this.dynamicWaasClient=yield this.createDynamicWaasClient(e)}return this.dynamicWaasClient})}createWalletAccount(){return(0,t.__awaiter)(this,arguments,void 0,function*({thresholdSignatureScheme:e="TWO_OF_TWO",password:t,bitcoinConfig:r,businessAccountId:i}={}){var s,o;let a=yield this.getWaasWalletClient(),l=yield null==(s=this.getSignedSessionId)?void 0:s.call(this);if(!l)throw new n.DynamicError("Signed session ID is required","signed_session_id_is_required");return yield a.createWalletAccount(Object.assign({authToken:null==(o=this.getAuthToken)?void 0:o.call(this),bitcoinConfig:r,password:t,signedSessionId:l,thresholdSignatureScheme:e},i&&{workspaceAccountId:i}))})}addSignerViaReshare(e){return(0,t.__awaiter)(this,arguments,void 0,function*({accountAddress:e,walletId:t,businessAccountId:r,targetSignerIdentity:i,signerType:s,password:o}){var a,l,c;let u=yield this.getWaasWalletClient(),d=yield null==(a=this.getSignedSessionId)?void 0:a.call(this);if(!d)throw new n.DynamicError("Signed session ID is required","signed_session_id_is_required");return null==(l=this.logger)||l.debug("[BusinessAccountAddSigner] addSignerViaReshare",{accountAddress:e,businessAccountId:r,identifierType:i.identifierType,identityMode:i.userId?"userId":"identifier",signerType:s,walletId:t}),u.reshareToNewSignerShareSet({accountAddress:e,authToken:null==(c=this.getAuthToken)?void 0:c.call(this),password:o,signedSessionId:d,signerType:s,targetSignerIdentity:i,walletId:t,workspaceAccountId:r})})}importPrivateKey(e){return(0,t.__awaiter)(this,arguments,void 0,function*({privateKey:e,thresholdSignatureScheme:t="TWO_OF_TWO",publicAddressCheck:r,addressType:i,legacyWalletId:s,password:o}){var a,l;
1let c=yield this.getWaasWalletClient(),u=yield null==(a=this.getSignedSessionId)?void 0:a.call(this);if(!u)throw new n.DynamicError("Signed session ID is required","signed_session_id_is_required");yield c.importPrivateKey({addressType:i,authToken:null==(l=this.getAuthToken)?void 0:l.call(this),legacyWalletId:s,password:o,privateKey:e,publicAddressCheck:r,signedSessionId:u,thresholdSignatureScheme:t})})}migrateFromFireblocks(e){return(0,t.__awaiter)(this,arguments,void 0,function*({deviceId:e,jwt:t,walletPassword:r,ncwStorage:i,expectedAddresses:s,coinTypes:o,password:a}){var l,c;let u=yield this.getWaasWalletClient(),d=yield null==(l=this.getSignedSessionId)?void 0:l.call(this);if(!d)throw new n.DynamicError("Signed session ID is required","signed_session_id_is_required");return u.migrateFromFireblocks({authToken:null==(c=this.getAuthToken)?void 0:c.call(this),fireblocks:Object.assign({deviceId:e,expectedAddresses:s,jwt:t,ncwStorage:i,walletPassword:r},o?{coinTypes:o}:{}),password:a,signedSessionId:d})})}exportPrivateKey(){return(0,t.__awaiter)(this,arguments,void 0,function*({accountAddress:e,displayContainer:t,password:r}={}){var o,a,l,c;let u=yield this.getWaasWalletClient(),d=e||(yield this.getActiveAccountAddress());if(!d)throw new n.DynamicError("Account address is required","account_address_is_required");if(!t)throw new n.DynamicError("Missing display container for export private key","missing_display_container_for_export_private");let h=null!=r?r:yield this.getPasswordIfNeeded({accountAddress:d}),f=yield null==(o=this.getSignedSessionId)?void 0:o.call(this);if(!f)throw new n.DynamicError("Signed session ID is required","signed_session_id_is_required");this.__exportHandler.setIframeStamper(t);let p=yield null==(a=this.getMfaToken)?void 0:a.call(this,{mfaAction:i.MFAAction.WalletWaasExport}),g=yield null==(l=this.getElevatedAccessToken)?void 0:l.call(this,{scope:s.TokenScope.Walletexport});yield u.exportPrivateKey({accountAddress:d,authToken:null==(c=this.getAuthToken)?void 0:c.call(this),displayContainer:t,elevatedAccessToken:g,mfaToken:p,password:h,signedSessionId:f})})}getExportHandler(){return this.__exportHandler}exportClientKeyshares(e){return(0,t.__awaiter)(this,arguments,void 0,function*({accountAddress:e,password:t}){var r,i;if(!e)throw new n.DynamicError("Account address is required","account_address_is_required");let s=null!=t?t:yield this.getPasswordIfNeeded({accountAddress:e}),o=yield null==(r=this.getSignedSessionId)?void 0:r.call(this);if(!o)throw new n.DynamicError("Signed session ID is required","signed_session_id_is_required");let a=yield this.getWaasWalletClient();yield a.exportClientKeyshares({accountAddress:e,authToken:null==(i=this.getAuthToken)?void 0:i.call(this),password:s,signedSessionId:o})})}backupKeySharesToGoogleDrive(e){return(0,t.__awaiter)(this,arguments,void 0,function*({accountAddress:e,password:t,googleDriveAccessToken:r}){var i,s,o;if(!e)throw new n.DynamicError("Account address is required","account_address_is_required");let a=null!=t?t:yield this.getPassword({accountAddress:e}),l=yield this.getWaasWalletClient(),c=yield null==(i=this.getSignedSessionId)?void 0:i.call(this);if(!c)throw new n.DynamicError("Signed session ID is required","signed_session_id_is_required");return l.backupKeySharesToGoogleDrive({accountAddress:e,authToken:null==(s=this.getAuthToken)?void 0:s.call(this),googleDriveAccessToken:r,password:a,sessionPublicKey:yield null==(o=this.getSessionPublicKey)?void 0:o.call(this),signedSessionId:c})})}exportClientKeysharesFromGoogleDrive(e){return(0,t.__awaiter)(this,arguments,void 0,function*({accountAddress:e,password:t}){var r,i;if(!e)throw new n.DynamicError("Account address is required","account_address_is_required");let s=null!=t?t:yield this.getPassword({accountAddress:e}),o=yield this.getWaasWalletClient(),a=yield null==(r=this.getSignedSessionId)?void 0:r.call(this);if(!a)throw new n.DynamicError("Signed session ID is required","signed_session_id_is_required");return o.exportClientKeysharesFromGoogleDrive({accountAddress:e,authToken:null==(i=this.getAuthToken)?void 0:i.call(this),password:s,signedSessionId:a})})}backupKeySharesToICloud(e){return(0,t.__awaiter)(this,arguments,void 0,function*({accountAddress:e,password:t}){var r,i,s;if(!e)throw new n.DynamicError("Account address is required","account_address_is_required");let o=null!=t?t:yield this.getPassword({accountAddress:e}),a=yield this.getWaasWalletClient(),l=yield null==(r=this.getSignedSessionId)?void 0:r.call(this);if(!l)throw new n.DynamicError("Signed session ID is required","signed_session_id_is_required");return a.backupKeySharesToICloud({accountAddress:e,authToken:null==(i=this.getAuthToken)?void 0:i.call(this),password:o,sessionPublicKey:yield null==(s=this.getSessionPublicKey)?void 0:s.call(this),signedSessionId:l})})}displayICloudSignIn(e){return(0,t.__awaiter)(this,arguments,void 0,function*({displayContainer:e}){return(yield this.getWaasWalletClient()).displayICloudSignIn({displayContainer:e})})}hideICloudSignIn(){return(0,t.__awaiter)(this,void 0,void 0,function*(){return(yield this.getWaasWalletClient()).hideICloudSignIn()})}isICloudAuthenticated(){return(0,t.__awaiter)(this,void 0,void 0,function*(){return(yield this.getWaasWalletClient()).isICloudAuthenticated()})}refreshWalletAccountShares(e){return(0,t.__awaiter)(this,arguments,void 0,function*({accountAddress:e,password:t}){var r,o,a,l,c,u,d;if(!e)throw new n.DynamicError("Account address is required","account_address_is_required");let h=null!=t?t:yield this.getPasswordIfNeeded({accountAddress:e}),f=yield this.getWaasWalletClient(),p=yield null==(r=this.getSignedSessionId)?void 0:r.call(this),g=yield null==(o=this.getSignedSessionId)?void 0:o.call(this);if(!p||!g)throw new n.DynamicError("Signed session ID is required","signed_session_id_is_required");yield f.getWallet({accountAddress:e,authToken:null==(a=this.getAuthToken)?void 0:a.call(this),signedSessionId:p});let y=yield null==(l=this.getMfaToken)?void 0:l.call(this,{mfaAction:i.MFAAction.WalletWaasRefresh}),m=yield null==(c=this.getElevatedAccessToken)?void 0:c.call(this,{scope:s.TokenScope.Walletdelegate});return f.refreshWalletAccountShares({accountAddress:e,authToken:null==(u=this.getAuthToken)?void 0:u.call(this),elevatedAccessToken:m,mfaToken:y,password:h,sessionPublicKey:yield null==(d=this.getSessionPublicKey)?void 0:d.call(this),signedSessionId:g})})}reshareWalletAccountShares(e){return(0,t.__awaiter)(this,arguments,void 0,function*({accountAddress:e,thresholdSignatureScheme:t,password:r}){var o,a,l,c,u;if(!e)throw new n.DynamicError("Account address is required","account_address_is_required");let d=null!=r?r:yield this.getPasswordIfNeeded({accountAddress:e}),h=yield this.getWaasWalletClient(),f=yield null==(o=this.getSignedSessionId)?void 0:o.call(this);if(!f)throw new n.DynamicError("Signed session ID is required","signed_session_id_is_required");let p=(yield h.getWallets()).find(t=>t.accountAddress===e);if(!p)throw new n.DynamicError("Wallet not found","wallet_not_found");let g=p.thresholdSignatureScheme,y=yield null==(a=this.getMfaToken)?void 0:a.call(this,{mfaAction:i.MFAAction.WalletWaasReshare}),m=yield null==(l=this.getElevatedAccessToken)?void 0:l.call(this,{scope:s.TokenScope.Walletdelegate});return h.reshare({accountAddress:e,authToken:null==(c=this.getAuthToken)?void 0:c.call(this),elevatedAccessToken:m,mfaToken:y,newThresholdSignatureScheme:t,oldThresholdSignatureScheme:g,password:d,sessionPublicKey:yield null==(u=this.getSessionPublicKey)?void 0:u.call(this),signedSessionId:f})})}revokeDelegation(e){return(0,t.__awaiter)(this,arguments,void 0,function*({accountAddress:e,password:t}){var r,i,s;if(!e)throw new n.DynamicError("Account address is required","account_address_is_required");let o=null!=t?t:yield this.getPasswordIfNeeded({accountAddress:e}),a=yield this.getWaasWalletClient(),l=yield null==(r=this.getSignedSessionId)?void 0:r.call(this);if(!l)throw new n.DynamicError("Signed session ID is required","signed_session_id_is_required");return a.revokeDelegation({accountAddress:e,authToken:null==(i=this.getAuthToken)?void 0:i.call(this),password:o,sessionPublicKey:yield null==(s=this.getSessionPublicKey)?void 0:s.call(this),signedSessionId:l})})}updatePassword(e){return(0,t.__awaiter)(this,arguments,void 0,function*({accountAddress:e,existingPassword:r,newPassword:i}){if(!e)throw new n.DynamicError("Account address is required","account_address_is_required");let s=null!=r?r:yield this.getPasswordIfNeeded({accountAddress:e});if(!s)throw new n.DynamicError("Existing password is required to update password","existing_password_is_required_to_update");let o=yield this.getWaasWalletClient();if(!this.getSignedSessionId)throw new n.DynamicError("Signed session ID is required","signed_session_id_is_required");let a=(yield o.getAllWallets()).filter(e=>{var t;return null==(t=e.clientKeySharesBackupInfo)?void 0:t.passwordEncrypted}),l=crypto.randomUUID();yield Promise.all(a.map(e=>(0,t.__awaiter)(this,void 0,void 0,function*(){var t,r;
1let n=yield this.getSignedSessionId();yield o.updatePassword({accountAddress:e.accountAddress,authToken:null==(t=this.getAuthToken)?void 0:t.call(this),existingPassword:s,newPassword:i,passwordUpdateBatchId:l,sessionPublicKey:yield null==(r=this.getSessionPublicKey)?void 0:r.call(this),signedSessionId:n})})))})}setPassword(e){return(0,t.__awaiter)(this,arguments,void 0,function*({accountAddress:e,newPassword:r}){if(!e)throw new n.DynamicError("Account address is required","account_address_is_required");let i=yield this.getWaasWalletClient();if(!this.getSignedSessionId)throw new n.DynamicError("Signed session ID is required","signed_session_id_is_required");let s=yield i.getAllWallets(),o=crypto.randomUUID();yield Promise.all(s.map(e=>(0,t.__awaiter)(this,void 0,void 0,function*(){var t,s;let n=yield this.getSignedSessionId();yield i.setPassword({accountAddress:e.accountAddress,authToken:null==(t=this.getAuthToken)?void 0:t.call(this),newPassword:r,passwordUpdateBatchId:o,sessionPublicKey:yield null==(s=this.getSessionPublicKey)?void 0:s.call(this),signedSessionId:n})})))})}signRawMessage(e){return(0,t.__awaiter)(this,arguments,void 0,function*({accountAddress:e,context:t,message:r,password:o}){var a,l,c,u;if(!e)throw new n.DynamicError("Account address is required","account_address_is_required");if(64!==r.length)throw new n.DynamicError("Message must be 64 characters long","message_must_be_64_characters_long");let d=null!=o?o:yield this.getPasswordIfNeeded({accountAddress:e}),h=yield this.getWaasWalletClient(),f=yield null==(a=this.getSignedSessionId)?void 0:a.call(this);if(!f)throw new n.DynamicError("Signed session ID is required","signed_session_id_is_required");let p=yield null==(l=this.getMfaToken)?void 0:l.call(this,{mfaAction:i.MFAAction.WalletWaasSign}),g=yield null==(c=this.getElevatedAccessToken)?void 0:c.call(this,{scope:s.TokenScope.Walletsign});return h.signRawMessage({accountAddress:e,authToken:null==(u=this.getAuthToken)?void 0:u.call(this),context:t,elevatedAccessToken:g,message:r,mfaToken:p,password:d,signedSessionId:f})})}unlockWallet(e){return(0,t.__awaiter)(this,arguments,void 0,function*({accountAddress:e,password:t}){var r,i;let s=null!=t?t:yield this.getPasswordIfNeeded({accountAddress:e});if(!s)throw new n.DynamicError("Password is required to unlock this wallet","password_is_required_to_unlock_this");let o=yield this.getWaasWalletClient(),a=yield null==(r=this.getSignedSessionId)?void 0:r.call(this);if(!a)throw new n.DynamicError("Signed session ID is required","signed_session_id_is_required");return o.unlockWallet({accountAddress:e,authToken:null==(i=this.getAuthToken)?void 0:i.call(this),password:s,signedSessionId:a})})}getWalletRecoveryState(e){return(0,t.__awaiter)(this,arguments,void 0,function*({accountAddress:e}){var t,r;let i=yield this.getWaasWalletClient(),s=yield null==(t=this.getSignedSessionId)?void 0:t.call(this);if(!s)throw new n.DynamicError("Signed session ID is required","signed_session_id_is_required");return i.getWalletRecoveryState({accountAddress:e,authToken:null==(r=this.getAuthToken)?void 0:r.call(this),signedSessionId:s})})}endSession(e){return(0,t.__awaiter)(this,void 0,void 0,function*(){var t;let r;try{r=yield this.getWaasWalletClient()}catch(e){this.instrument("[endSession] getWaasWalletClient failed; proceeding",Object.assign({key:"endSession-getClient-failed",time:0},this.buildErrorInstrumentContext(e)))}if("token-expired"!==e){let e=yield this.getActiveAccountAddress();if(e)try{yield(0,d.createWaasClientSecureStorage)().removeClientKeyShare(e)}catch(e){this.instrument("[endSession] direct key share removal failed",Object.assign({key:"endSession-removeClientKeyShare-failed",time:0},this.buildErrorInstrumentContext(e)))}r&&Promise.resolve(r.cleanup()).catch(e=>{this.instrument("[endSession] background iframe cleanup failed",Object.assign({key:"endSession-cleanup-failed",time:0},this.buildErrorInstrumentContext(e)))})}null==(t=this.revokeSignedSession)||t.call(this),this.revokeSignedSession=void 0,this.dynamicWaasClient=void 0})}getConnectedAccounts(){return(0,t.__awaiter)(this,void 0,void 0,function*(){try{let e=yield this.getWaasWalletClient();return(yield e.getWallets()).map(e=>null==e?void 0:e.accountAddress).filter(e=>"string"==typeof e)}catch(e){return this.logger.debug("[getConnectedAccounts] Failed to fetch wallets from Waas client",{error:e}),[]}})}generateTraceId(){let e=new Uint8Array(16);return crypto.getRandomValues(e),Array.from(e).map(e=>e.toString(16).padStart(2,"0")).join("")}buildErrorInstrumentContext(e){var t,r;try{return{errorCode:null!=(t=null==e?void 0:e.code)?t:p,errorMessage:e instanceof Error?e.message:String(e),errorType:null==(r=null==e?void 0:e.constructor)?void 0:r.name}}catch(e){return{errorCode:p}}}instrument(e,t){let r={accountAddress:t.accountAddress||this.activeAccountAddress,environmentId:t.environmentId||this.environmentId,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,traceId:t.traceId||this.generateTraceId()};this.logger.debug(e,Object.assign(Object.assign({},r),t)),this.logger.instrument(e,Object.assign(Object.assign({},r),t))}instrumentAsync(e){return(0,t.__awaiter)(this,arguments,void 0,function*({operation:e,resource:t,fn:r,context:i}){let s=new h.InstrumentationTimer(null==i?void 0:i.startTime);(null==i?void 0:i.stepStartTime)?s.setStepStartTime(i.stepStartTime):s.startStep(),this.instrument(`[${e}] ${t} - start`,Object.assign({key:`${t}-start`,operation:e,stepTime:s.getStepElapsed(),time:s.getElapsed()},i));try{let n=yield r(s);return this.instrument(`[${e}] ${t} - completed`,Object.assign({key:`${t}-completed`,operation:e,stepTime:s.getStepElapsed(),time:s.getElapsed()},i)),n}catch(a){let r=a instanceof o.UserRejectedRequestError||(null==a?void 0:a.code)==="user_rejected_request",n=this.buildErrorInstrumentContext(a);throw r?this.logger.debug(`[${e}] ${t} - cancelled`,Object.assign(Object.assign({key:`${t}-cancelled`,operation:e,stepTime:s.getStepElapsed(),time:s.getElapsed()},i),n)):this.instrument(`[${e}] ${t} - failed`,Object.assign(Object.assign({key:`${t}-failed`,operation:e,stepTime:s.getStepElapsed(),time:s.getElapsed()},i),n)),a}})}getPrivateBalance(){return(0,t.__awaiter)(this,void 0,void 0,function*(){throw new n.DynamicError(`getPrivateBalance is not supported for ${this.chainName} wallets`,"getprivatebalance_is_not_supported_for_wallets")})}}])},738110,e=>{"use strict";e.i(957121);var t=e.i(303690),r=e.i(136724);e.i(858899),(0,t.assertPackageVersion)("@dynamic-labs/waas",r.version),e.s([])},940893,e=>{"use strict";var t=e.i(974891),r=e.i(470525);class i extends r.Hash{constructor(e,t,i,s){super(),this.blockLen=e,this.outputLen=t,this.padOffset=i,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=(0,r.createView)(this.buffer)}update(e){(0,t.exists)(this);let{view:i,buffer:s,blockLen:n}=this,o=(e=(0,r.toBytes)(e)).length;for(let t=0;t<o;){let a=Math.min(n-this.pos,o-t);if(a===n){let i=(0,r.createView)(e);for(;n<=o-t;t+=n)this.process(i,t);continue}s.set(e.subarray(t,t+a),this.pos),this.pos+=a,t+=a,this.pos===n&&(this.process(i,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){(0,t.exists)(this),(0,t.output)(e,this),this.finished=!0;let{buffer:i,view:s,blockLen:n,isLE:o}=this,{pos:a}=this;i[a++]=128,this.buffer.subarray(a).fill(0),this.padOffset>n-a&&(this.process(s,0),a=0);for(let e=a;
1e<n;e++)i[e]=0;!function(e,t,r,i){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,r,i);let s=BigInt(32),n=BigInt(0xffffffff),o=Number(r>>s&n),a=Number(r&n),l=4*!!i,c=4*!i;e.setUint32(t+l,o,i),e.setUint32(t+c,a,i)}(s,n-8,BigInt(8*this.length),o),this.process(s,0);let l=(0,r.createView)(e),c=this.outputLen;if(c%4)throw Error("_sha2: outputLen should be aligned to 32bit");let u=c/4,d=this.get();if(u>d.length)throw Error("_sha2: outputLen bigger than state");for(let e=0;e<u;e++)l.setUint32(4*e,d[e],o)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:t,buffer:r,length:i,finished:s,destroyed:n,pos:o}=this;return e.length=i,e.pos=o,e.finished=s,e.destroyed=n,i%t&&e.buffer.set(r),e}}e.s(["Chi",0,(e,t,r)=>e&t^~e&r,"HashMD",0,i,"Maj",0,(e,t,r)=>e&t^e&r^t&r])},280355,e=>{"use strict";var t=e.i(940893),r=e.i(470525);let i=new Uint32Array([0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5,0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5,0xd807aa98,0x12835b01,0x243185be,0x550c7dc3,0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174,0xe49b69c1,0xefbe4786,0xfc19dc6,0x240ca1cc,0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da,0x983e5152,0xa831c66d,0xb00327c8,0xbf597fc7,0xc6e00bf3,0xd5a79147,0x6ca6351,0x14292967,0x27b70a85,0x2e1b2138,0x4d2c6dfc,0x53380d13,0x650a7354,0x766a0abb,0x81c2c92e,0x92722c85,0xa2bfe8a1,0xa81a664b,0xc24b8b70,0xc76c51a3,0xd192e819,0xd6990624,0xf40e3585,0x106aa070,0x19a4c116,0x1e376c08,0x2748774c,0x34b0bcb5,0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3,0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208,0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2]),s=new Uint32Array([0x6a09e66
17,0xbb67ae85,0x3c6ef372,0xa54ff53a,0x510e527f,0x9b05688c,0x1f83d9ab,0x5be0cd19]),n=new Uint32Array(64);class o extends t.HashMD{constructor(){super(64,32,8,!1),this.A=0|s[0],this.B=0|s[1],this.C=0|s[2],this.D=0|s[3],this.E=0|s[4],this.F=0|s[5],this.G=0|s[6],this.H=0|s[7]}get(){let{A:e,B:t,C:r,D:i,E:s,F:n,G:o,H:a}=this;return[e,t,r,i,s,n,o,a]}set(e,t,r,i,s,n,o,a){this.A=0|e,this.B=0|t,this.C=0|r,this.D=0|i,this.E=0|s,this.F=0|n,this.G=0|o,this.H=0|a}process(e,s){for(let t=0;t<16;t++,s+=4)n[t]=e.getUint32(s,!1);for(let e=16;e<64;e++){let t=n[e-15],i=n[e-2],s=(0,r.rotr)(t,7)^(0,r.rotr)(t,18)^t>>>3,o=(0,r.rotr)(i,17)^(0,r.rotr)(i,19)^i>>>10;n[e]=o+n[e-7]+s+n[e-16]|0}let{A:o,B:a,C:l,D:c,E:u,F:d,G:h,H:f}=this;for(let e=0;e<64;e++){let s=f+((0,r.rotr)(u,6)^(0,r.rotr)(u,11)^(0,r.rotr)(u,25))+(0,t.Chi)(u,d,h)+i[e]+n[e]|0,p=((0,r.rotr)(o,2)^(0,r.rotr)(o,13)^(0,r.rotr)(o,22))+(0,t.Maj)(o,a,l)|0;f=h,h=d,d=u,u=c+s|0,c=l,l=a,a=o,o=s+p|0}o=o+this.A|0,a=a+this.B|0,l=l+this.C|0,c=c+this.D|0,u=u+this.E|0,d=d+this.F|0,h=h+this.G|0,f=f+this.H|0,this.set(o,a,l,c,u,d,h,f)}roundClean(){n.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}let a=(0,r.wrapConstructor)(()=>new o);e.s(["sha256",0,a])},751694,e=>{"use strict";e.s(["version",0,"4.93.0"])},677007,e=>{"use strict";e.s(["version",0,"4.93.0"])},59726,e=>{"use strict";"function"==typeof SuppressedError&&SuppressedError,e.s(["__awaiter",0,function(e,t,r,i){return new(r||(r=Promise))(function(s,n){function o(e){try{l(i.next(e))}catch(e){n(e)}}function a(e){try{l(i.throw(e))}catch(e){n(e)}}function l(e){var t;e.done?s(e.value):((t=e.value)instanceof r?t:new r(function(e){e(t)})).then(o,a)}l((i=i.apply(e,t||[])).next())})}])},714502,e=>{"use strict";var t=e.i(526539),r=e.i(364697),i=e.i(810588),s=e.i(870948);let n=BigInt(0),o=BigInt(1),a=BigInt(2),l=BigInt(8);e.s(["PrimeEdwardsPoint",0,class{constructor(e){this.ep=e}static fromBytes(e){throw Error("fromBytes must be implemented by subclass")}static fromHex(e){throw Error("fromHex must be implemented by subclass")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}clearCofactor(){return this}assertValidity(){this.ep.assertValidity()}toAffine(e){return this.ep.toAffine(e)}toRawBytes(){return this.toBytes()}toHex(){return(0,r.bytesToHex)(this.toBytes())}toString(){return this.toHex()}isTorsionFree(){return!0}isSmallOrder(){return!1}add(e){return this.assertSame(e),this.init(this.ep.add(e.ep))}subtract(e){return this.assertSame(e),this.init(this.ep.subtract(e.ep))}multiply(e){return this.init(this.ep.multiply(e))}multiplyUnsafe(e){return this.init(this.ep.multiplyUnsafe(e))}double(){return this.init(this.ep.double())}negate(){return this.init(this.ep.negate())}precompute(e,t){return this.init(this.ep.precompute(e,t))}},"twistedEdwards",0,function(e){let c,u,d,{CURVE:h,curveOpts:f,hash:p,eddsaOpts:g}=(c={a:e.a,d:e.d,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},u={Fp:e.Fp,Fn:(0,s.Field)(c.n,e.nBitLength,!0),uvRatio:e.uvRatio},d={randomBytes:e.randomBytes,adjustScalarBytes:e.adjustScalarBytes,domain:e.domain,prehash:e.prehash,mapToCurve:e.mapToCurve},{CURVE:c,curveOpts:u,hash:e.hash,eddsaOpts:d}),y=function(e,i,s){if("function"!=typeof i)throw Error('"hash" function param is required');(0,t._validateObject)(s,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});let{prehash:a}=s,{BASE:l,Fp:c,Fn:u}=e,d=u.ORDER,h=s.randomBytes||r.randomBytes,f=s.adjustScalarBytes||(e=>e),p=s.domain||((e,r,i)=>{if((0,t.abool)("phflag",i),r.length||i)throw Error("Contexts/pre-hash are not supported");return e});function g(e){var r;return r=(0,t.bytesToNumberLE)(e),u.create(r)}function y(e){var r;let s,n,o,a,u,{head:d,prefix:h,scalar:p}=(r=e,s=c.BYTES,r=(0,t.ensureBytes)("private key",r,s),o=f((n=(0,t.ensureBytes)("hashed private key",i(r),2*s)).slice(0,s)),a=n.slice(s,2*s),u=g(o),{head:o,prefix:a,scalar:u}),y=l.multiply(p),m=y.toBytes();return{head:d,prefix:h,scalar:p,point:y,pointBytes:m}}function m(e){return y(e).pointBytes}function b(e=Uint8Array.of(),...s){return g(i(p((0,r.concatBytes)(...s),(0,t.ensureBytes)("context",e),!!a)))}let v={zip215:!0};l.precompute(8);let w=c.BYTES,_={secret:w,public:w,signature:2*w,seed:w};function S(e=h(_.seed)){return e}let E={getExtendedPublicKey:y,randomSecretKey:S,isValidSecretKey:function(e){try{return!!u.fromBytes(e,!1)}catch(e){return!1}},isValidPublicKey:function(t,r){try{return!!e.fromBytes(t,r)}catch(e){return!1}},randomPrivateKey:S,toMontgomery(t){let{y:r}=e.fromBytes(t),i=32===w;if(!i&&57!==w)throw Error("only defined for 25519 and 448");let s=i?c.div(o+r,o-r):c.div(r-o,r+o);return c.toBytes(s)},toMontgomeryPriv:e=>((0,r.abytes)(e,w),f(i(e.subarray(0,w))).subarray(0,w)),precompute:(t=8,r=e.BASE)=>r.precompute(t,!1)};return Object.freeze({keygen:function(e){let t=E.randomSecretKey(e);return{secretKey:t,publicKey:m(t)}},getPublicKey:m,sign:function(e,i,s={}){var o;e=(0,t.ensureBytes)("message",e),a&&(e=a(e));let{prefix:h,scalar:f,pointBytes:p}=y(i),g=b(s.context,h,e),m=l.multiply(g).toBytes(),v=(o=g+b(s.context,m,p,e)*f,u.create(o));(0,t.aInRange)("signature.s",v,n,d);let w=c.BYTES,_=(0,r.concatBytes)(m,(0,t.numberToBytesLE)(v,w));return(0,t.ensureBytes)("result",_,2*w)},verify:function(r,i,s,n=v){let o,u,d,{context:h,zip215:f}=n,p=c.BYTES;r=(0,t.ensureBytes)("signature",r,2*p),i=(0,t.ensureBytes)("message",i),s=(0,t.ensureBytes)("publicKey",s,p),void 0!==f&&(0,t.abool)("zip215",f),a&&(i=a(i));let g=(0,t.bytesToNumberLE)(r.slice(p,2*p));try{o=e.fromHex(s,f),u=e.fromHex(r.slice(0,p),f),d=l.multiplyUnsafe(g)}catch(e){return!1}if(!f&&o.isSmallOrder())return!1;let y=b(h,u.toBytes(),o.toBytes(),i);return u.add(o.multiplyUnsafe(y)).subtract(d).clearCofactor().is0()},utils:E,Point:e,info:{type:"edwards",lengths:_}})}(function(e,s={}){var c,u;let d,h,f,p,g,{Fp:y,Fn:m}=(0,i._createCurveFields)("edwards",e,s),{h:b,n:v}=e;(0,t._validateObject)(s,{},{uvRatio:"function"});let w=a<<BigInt(8*m.BYTES)-o,_=s.uvRatio||((e,t)=>{try{return{isValid:!0,value:y.sqrt(y.div(e,t))}}catch(e){return{isValid:!1,value:n}}});if(c=e.Gx,u=e.Gy,d=y.sqr(c),h=y.sqr(u),f=y.add(y.mul(e.a,d),h),p=y.add(y.ONE,y.mul(e.d,y.mul(d,h))),!y.eql(f,p))throw Error("bad curve params: generator point");function S(e,r,i=!1){let s=i?o:n;return(0,t.aInRange)("coordinate "+e,r,s,w),r}function E(e){if(!(e instanceof T))throw Error("ExtendedPoint expected")}let I=(0,t.memoized)((e,t)=>{let r,i,{X:s,Y:a,Z:c}=e,u=e.is0();null==t&&(t=u?l:y.inv(c));let d=(r=s*t,y.create(r)),h=(i=a*t,y.create(i)),f=y.mul(c,t);if(u)return{x:n,y:o};
1if(f!==o)throw Error("invZ was invalid");return{x:d,y:h}}),A=(0,t.memoized)(t=>{let r,i,s,n,o,a,l,c,u,d,h,f,{a:p,d:g}=e;if(t.is0())throw Error("bad point: ZERO");let{X:m,Y:b,Z:v,T:w}=t,_=(r=m*m,y.create(r)),S=(i=b*b,y.create(i)),E=(s=v*v,y.create(s)),I=(n=E*E,y.create(n));if(l=E*(o=_*p,a=y.create(o)+S,y.create(a)),y.create(l)!==(d=I+(u=g*(c=_*S,y.create(c)),y.create(u)),y.create(d)))throw Error("bad point: equation left != right (1)");if(h=m*b,y.create(h)!==(f=v*w,y.create(f)))throw Error("bad point: equation left != right (2)");return!0});class T{constructor(e,t,r,i){this.X=S("x",e),this.Y=S("y",t),this.Z=S("z",r,!0),this.T=S("t",i),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}get ex(){return this.X}get ey(){return this.Y}get ez(){return this.Z}get et(){return this.T}static normalizeZ(e){return(0,i.normalizeZ)(T,e)}static msm(e,t){return(0,i.pippenger)(T,m,e,t)}_setWindowSize(e){this.precompute(e)}static fromAffine(e){let t;if(e instanceof T)throw Error("extended point not allowed");let{x:r,y:i}=e||{};return S("x",r),S("y",i),new T(r,i,o,(t=r*i,y.create(t)))}precompute(e=8,t=!0){return x.createCache(this,e),t||this.multiply(a),this}assertValidity(){A(this)}equals(e){let t,r,i,s;E(e);let{X:n,Y:o,Z:a}=this,{X:l,Y:c,Z:u}=e,d=(t=n*u,y.create(t)),h=(r=l*a,y.create(r)),f=(i=o*u,y.create(i)),p=(s=c*a,y.create(s));return d===h&&f===p}is0(){return this.equals(T.ZERO)}negate(){let e,t;return new T((e=-this.X,y.create(e)),this.Y,this.Z,(t=-this.T,y.create(t)))}double(){let t,r,i,s,n,o,l,c,u,d,h,{a:f}=e,{X:p,Y:g,Z:m}=this,b=(t=p*p,y.create(t)),v=(r=g*g,y.create(r)),w=(s=a*(i=m*m,y.create(i)),y.create(s)),_=(n=f*b,y.create(n)),S=p+g,E=(o=S*S,l=y.create(o)-b-v,y.create(l)),I=_+v,A=I-w,x=_-v,k=(c=E*A,y.create(c)),P=(u=I*x,y.create(u)),O=(d=E*x,y.create(d));return new T(k,P,(h=A*I,y.create(h)),O)}add(t){let r,i,s,n,o,a,l,c,u,d;E(t);let{a:h,d:f}=e,{X:p,Y:g,Z:m,T:b}=this,{X:v,Y:w,Z:_,T:S}=t,I=(r=p*v,y.create(r)),A=(i=g*w,y.create(i)),x=(s=b*f*S,y.create(s)),k=(n=m*_,y.create(n)),P=(o=(p+g)*(v+w)-I-A,y.create(o)),O=k-x,R=k+x,C=(a=A-h*I,y.create(a)),N=(l=P*O,y.create(l)),B=(c=R*C,y.create(c)),U=(u=P*C,y.create(u));return new T(N,B,(d=O*R,y.create(d)),U)}subtract(e){return this.add(e.negate())}multiply(e){(0,t.aInRange)("scalar",e,o,v);let{p:r,f:s}=x.cached(this,e,e=>(0,i.normalizeZ)(T,e));return(0,i.normalizeZ)(T,[r,s])[0]}multiplyUnsafe(e,r=T.ZERO){return((0,t.aInRange)("scalar",e,n,v),e===n)?T.ZERO:this.is0()||e===o?this:x.unsafe(this,e,e=>(0,i.normalizeZ)(T,e),r)}isSmallOrder(){return this.multiplyUnsafe(b).is0()}isTorsionFree(){return x.unsafe(this,v).is0()}toAffine(e){return I(this,e)}clearCofactor(){return b===o?this:this.multiplyUnsafe(b)}static fromBytes(e,t=!1){return(0,r.abytes)(e),T.fromHex(e,t)}static fromHex(r,i=!1){let s,a,l,c,{d:u,a:d}=e,h=y.BYTES;r=(0,t.ensureBytes)("pointHex",r,h),(0,t.abool)("zip215",i);let f=r.slice(),p=r[h-1];f[h-1]=-129&p;let g=(0,t.bytesToNumberLE)(f),m=i?w:y.ORDER;(0,t.aInRange)("pointHex.y",g,n,m);let b=(s=g*g,y.create(s)),{isValid:v,value:S}=_((a=b-o,y.create(a)),(l=u*b-d,y.create(l)));if(!v)throw Error("Point.fromHex: invalid y coordinate");let E=(S&o)===o,I=(128&p)!=0;if(!i&&S===n&&I)throw Error("Point.fromHex: x=0 and x_0=1");return I!==E&&(c=-S,S=y.create(c)),T.fromAffine({x:S,y:g})}toBytes(){let{x:e,y:r}=this.toAffine(),i=(0,t.numberToBytesLE)(r,y.BYTES);return i[i.length-1]|=e&o?128:0,i}toRawBytes(){return this.toBytes()}toHex(){return(0,r.bytesToHex)(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}T.BASE=new T(e.Gx,e.Gy,o,(g=e.Gx*e.Gy,y.create(g))),T.ZERO=new T(n,o,o,n),T.Fp=y,T.Fn=m;let x=new i.wNAF(T,8*m.BYTES);return T}(h,f),p,g);return Object.assign({},y,{ExtendedPoint:y.Point,CURVE:e})}])},124643,e=>{"use strict";var t=e.i(526539),r=e.i(364697),i=e.i(870948);let s=BigInt(0),n=BigInt(1),o=BigInt(2);e.s(["montgomery",0,function(e){let{P:a,type:l,adjustScalarBytes:c,powPminus2:u,randomBytes:d}=((0,t._validateObject)(e,{adjustScalarBytes:"function",powPminus2:"function"}),Object.freeze({...e})),h="x25519"===l;if(!h&&"x448"!==l)throw Error("invalid type");let f=d||r.randomBytes,p=h?255:448,g=h?32:56,y=h?BigInt(9):BigInt(5),m=h?BigInt(121665):BigInt(39081),b=h?o**BigInt(254):o**BigInt(447),v=b+(h?BigInt(8)*o**BigInt(251)-n:BigInt(4)*o**BigInt(445)-n)+n,w=e=>(0,i.mod)(e,a),_=S(y);function S(e){return(0,t.numberToBytesLE)(w(e),g)}function E(e,r){let i,o=function(e,r){(0,t.aInRange)("u",e,s,a),(0,t.aInRange)("scalar",r,b,v);let i=n,o=s,l=e,c=n,d=s;for(let t=BigInt(p-1);t>=s;t--){let s=r>>t&n;d^=s,({x_2:i,x_3:l}=A(d,i,l)),({x_2:o,x_3:c}=A(d,o,c)),d=s;let a=i+o,u=w(a*a),h=i-o,f=w(h*h),p=u-f,g=l+c,y=w((l-c)*a),b=w(g*h),v=y+b,_=y-b;l=w(v*v),c=w(e*w(_*_)),i=w(u*f),o=w(p*(u+w(m*p)))}return{x_2:i,x_3:l}=A(d,i,l),{x_2:o,x_3:c}=A(d,o,c),w(i*u(o))}((i=(0,t.ensureBytes)("u coordinate",r,g),h&&(i[31]&=127),w((0,t.bytesToNumberLE)(i))),(0,t.bytesToNumberLE)(c((0,t.ensureBytes)("scalar",e,g))));if(o===s)throw Error("invalid private or public key received");return S(o)}function I(e){return E(e,_)}function A(e,t,r){let i=w(e*(t-r));return{x_2:t=w(t-i),x_3:r=w(r+i)}}let T=(e=f(g))=>e,x={randomSecretKey:T,randomPrivateKey:T};return{keygen:function(e){let t=x.randomSecretKey(e);return{secretKey:t,publicKey:I(t)}},getSharedSecret:(e,t)=>E(e,t),getPublicKey:e=>I(e),scalarMult:E,scalarMultBase:I,utils:x,GuBytes:_.slice(),info:{type:"montgomery",lengths:{secret:g,public:g,seed:g}}}}])},214303,e=>{"use strict";var t=e.i(735400),r=e.i(364697),i=e.i(810588),s=e.i(714502),n=e.i(933795),o=e.i(870948);e.i(124643);var a=e.i(526539);let l=BigInt(0),c=BigInt(1),u=BigInt(2),d=BigInt(3),h=BigInt(5),f=BigInt(8),p={p:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:f,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")},g=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function y(e,t){var r;let i,s,n,a,l,d,f,y,m,b,v,w,_,S,E,I=p.p,A=(0,o.mod)(t*t*t,I),T=(r=e*(0,o.mod)(A*A*t,I),i=BigInt(10),s=BigInt(20),n=BigInt(40),a=BigInt(80),d=r*r%(l=p.p)*r%l,f=(0,o.pow2)(d,u,l)*d%l,y=(0,o.pow2)(f,c,l)*r%l,m=(0,o.pow2)(y,h,l)*y%l,b=(0,o.pow2)(m,i,l)*m%l,v=(0,o.pow2)(b,
1s,l)*b%l,w=(0,o.pow2)(v,n,l)*v%l,_=(0,o.pow2)(w,a,l)*w%l,S=(0,o.pow2)(_,a,l)*w%l,E=(0,o.pow2)(S,i,l)*m%l,{pow_p_5_8:(0,o.pow2)(E,u,l)*r%l,b2:d}).pow_p_5_8,x=(0,o.mod)(e*A*T,I),k=(0,o.mod)(t*x*x,I),P=x,O=(0,o.mod)(x*g,I),R=k===e,C=k===(0,o.mod)(-e,I),N=k===(0,o.mod)(-e*g,I);return R&&(x=P),(C||N)&&(x=O),(0,o.isNegativeLE)(x,I)&&(x=(0,o.mod)(-x,I)),{isValid:R||C,value:x}}let m=(0,o.Field)(p.p,{isLE:!0}),b=(0,o.Field)(p.n,{isLE:!0}),v={...p,Fp:m,hash:t.sha512,adjustScalarBytes:function(e){return e[0]&=248,e[31]&=127,e[31]|=64,e},uvRatio:y},w=(0,s.twistedEdwards)(v),_=(m.ORDER+d)/f,S=m.pow(u,_),E=m.sqrt(m.neg(m.ONE)),I=(0,o.FpSqrtEven)(m,m.neg(BigInt(486664)));(0,n.createHasher)(w.Point,e=>(function(e){let t,r,i,s,n,a,l,d,p,g,y,b,v,w,_,A,T,x,k,P,O,R,C,{xMn:N,xMd:B,yMn:U,yMd:q}=(t=(m.ORDER-h)/f,r=BigInt(486662),i=m.sqr(e),i=m.mul(i,u),s=m.add(i,m.ONE),n=m.neg(r),a=m.sqr(s),l=m.mul(a,s),d=m.mul(i,r),d=m.mul(d,n),d=m.add(d,a),d=m.mul(d,n),p=m.sqr(l),a=m.sqr(p),p=m.mul(p,l),p=m.mul(p,d),a=m.mul(a,p),g=m.pow(a,t),g=m.mul(g,p),y=m.mul(g,E),a=m.sqr(g),a=m.mul(a,l),b=m.eql(a,d),v=m.cmov(y,g,b),w=m.mul(n,i),_=m.mul(g,e),_=m.mul(_,S),A=m.mul(_,E),T=m.mul(d,i),a=m.sqr(_),a=m.mul(a,l),x=m.eql(a,T),k=m.cmov(A,_,x),a=m.sqr(v),a=m.mul(a,l),P=m.eql(a,d),O=m.cmov(w,n,P),R=m.cmov(k,v,P),C=m.isOdd(R),{xMn:O,xMd:s,yMn:R=m.cmov(R,m.neg(R),P!==C),yMd:c}),L=m.mul(N,q);L=m.mul(L,I);let D=m.mul(B,U),M=m.sub(N,B),K=m.add(N,B),W=m.mul(D,K),z=m.eql(W,m.ZERO);L=m.cmov(L,m.ZERO,z),D=m.cmov(D,m.ONE,z),M=m.cmov(M,m.ONE,z),K=m.cmov(K,m.ONE,z);let[j,V]=(0,o.FpInvertBatch)(m,[D,K],!0);return{x:m.mul(L,j),y:m.mul(M,V)}})(e[0]),{DST:"edwards25519_XMD:SHA-512_ELL2_RO_",encodeDST:"edwards25519_XMD:SHA-512_ELL2_NU_",p:m.ORDER,m:1,k:128,expand:"xmd",hash:t.sha512});let A=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),T=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),x=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),k=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),P=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),O=e=>w.CURVE.Fp.create((0,a.bytesToNumberLE)(e)&P);function R(e){let{d:t}=w.CURVE,r=w.CURVE.Fp.ORDER,i=w.CURVE.Fp.create,s=i(g*e*e),n=i((s+c)*x),a=BigInt(-1),l=i((a-t*s)*i(s+t)),{isValid:u,value:d}=y(n,l),h=i(d*e);(0,o.isNegativeLE)(h,r)||(h=i(-h)),u||(d=h),u||(a=s);let f=i(a*(s-c)*k-l),p=d*d,m=i((d+d)*l),b=i(f*A),v=i(c-p),_=i(c+p);return new w.Point(i(m*_),i(v*b),i(b*_),i(m*v))}class C extends s.PrimeEdwardsPoint{constructor(e){super(e)}static fromAffine(e){return new C(w.Point.fromAffine(e))}assertSame(e){if(!(e instanceof C))throw Error("RistrettoPoint expected")}init(e){return new C(e)}static hashToCurve(e){var t;let i,s;return t=(0,a.ensureBytes)("ristrettoHash",e,64),(0,r.abytes)(t,64),i=R(O(t.subarray(0,32))),s=R(O(t.subarray(32,64))),new C(i.add(s))}static fromBytes(e){(0,r.abytes)(e,32);let{a:t,d:i}=w.CURVE,s=m.ORDER,n=m.create,u=O(e);if(!(0,a.equalBytes)((0,a.numberToBytesLE)(u,32),e)||(0,o.isNegativeLE)(u,s))throw Error("invalid ristretto255 encoding 1");let d=n(u*u),h=n(c+t*d),f=n(c-t*d),p=n(h*h),g=n(f*f),b=n(t*i*p-g),{isValid:v,value:_}=y(c,n(b*g)),S=n(_*f),E=n(_*S*b),I=n((u+u)*S);(0,o.isNegativeLE)(I,s)&&(I=n(-I));let A=n(h*E),T=n(I*A);if(!v||(0,o.isNegativeLE)(T,s)||A===l)throw Error("invalid ristretto255 encoding 2");return new C(new w.Point(I,A,c,T))}static fromHex(e){return C.fromBytes((0,a.ensureBytes)("ristrettoHex",e,32))}static msm(e,t){return(0,i.pippenger)(C,w.Point.Fn,e,t)}toBytes(){let e,{X:t,Y:r,Z:i,T:s}=this.ep,n=m.ORDER,l=m.create,u=l(l(i+r)*l(i-r)),d=l(t*r),h=l(d*d),{value:f}=y(c,l(u*h)),p=l(f*u),b=l(f*d),v=l(p*b*s);if((0,o.isNegativeLE)(s*v,n)){let i=l(r*g),s=l(t*g);t=i,r=s,e=l(p*T)}else e=b;(0,o.isNegativeLE)(t*v,n)&&(r=l(-r));let w=l((i-r)*e);return(0,o.isNegativeLE)(w,n)&&(w=l(-w)),(0,a.numberToBytesLE)(w,32)}equals(e){this.assertSame(e);let{X:t,Y:r}=this.ep,{X:i,Y:s}=e.ep,n=m.create,o=n(t*s)===n(r*i),a=n(r*s)===n(t*i);return o||a}is0(){return this.equals(C.ZERO)}}C.BASE=new C(w.Point.BASE),C.ZERO=new C(w.Point.ZERO),C.Fp=m,C.Fn=b,e.s(["ed25519",0,w])},313227,(e,t,r)=>{"use strict";var i=e.r(242524).Buffer;t.exports=function(e){if(e.length>=255)throw TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r<t.length;r++)t[r]=255;for(var s=0;s<e.length;s++){var n=e.charAt(s),o=n.charCodeAt(0);if(255!==t[o])throw TypeError(n+" is ambiguous");t[o]=s}
vendor: 4,134 bytes, line 1
1var a=e.length,l=e.charAt(0),c=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function d(e){if("string"!=typeof e)throw TypeError("Expected String");if(0===e.length)return i.alloc(0);for(var r=0,s=0,n=0;e[r]===l;)s++,r++;for(var o=(e.length-r)*c+1>>>0,u=new Uint8Array(o);r<e.length;){var d=e.charCodeAt(r);if(d>255)return;var h=t[d];if(255===h)return;for(var f=0,p=o-1;(0!==h||f<n)&&-1!==p;p--,f++)h+=a*u[p]>>>0,u[p]=h%256>>>0,h=h/256>>>0;if(0!==h)throw Error("Non-zero carry");n=f,r++}for(var g=o-n;g!==o&&0===u[g];)g++;var y=i.allocUnsafe(s+(o-g));y.fill(0,0,s);for(var m=s;g!==o;)y[m++]=u[g++];return y}return{encode:function(t){if((Array.isArray(t)||t instanceof Uint8Array)&&(t=i.from(t)),!i.isBuffer(t))throw TypeError("Expected Buffer");if(0===t.length)return"";for(var r=0,s=0,n=0,o=t.length;n!==o&&0===t[n];)n++,r++;for(var c=(o-n)*u+1>>>0,d=new Uint8Array(c);n!==o;){for(var h=t[n],f=0,p=c-1;(0!==h||f<s)&&-1!==p;p--,f++)h+=256*d[p]>>>0,d[p]=h%a>>>0,h=h/a>>>0;if(0!==h)throw Error("Non-zero carry");s=f,n++}for(var g=c-s;g!==c&&0===d[g];)g++;for(var y=l.repeat(r);g<c;++g)y+=e.charAt(d[g]);return y},decodeUnsafe:d,decode:function(e){var t=d(e);if(t)return t;throw Error("Non-base"+a+" character")}}}},635030,(e,t,r)=>{t.exports=e.r(313227)("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},217944,(e,t,r)=>{"use strict";var i=e.r(242524).Buffer;t.exports=function(e){if(e.length>=255)throw TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r<t.length;r++)t[r]=255;for(var s=0;s<e.length;s++){var n=e.charAt(s),o=n.charCodeAt(0);if(255!==t[o])throw TypeError(n+" is ambiguous");t[o]=s}var a=e.length,l=e.charAt(0),c=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function d(e){if("string"!=typeof e)throw TypeError("Expected String");if(0===e.length)return i.alloc(0);for(var r=0,s=0,n=0;e[r]===l;)s++,r++;for(var o=(e.length-r)*c+1>>>0,u=new Uint8Array(o);r<e.length;){var d=e.charCodeAt(r);if(d>255)return;var h=t[d];if(255===h)return;for(var f=0,p=o-1;(0!==h||f<n)&&-1!==p;p--,f++)h+=a*u[p]>>>0,u[p]=h%256>>>0,h=h/256>>>0;if(0!==h)throw Error("Non-zero carry");n=f,r++}for(var g=o-n;g!==o&&0===u[g];)g++;var y=i.allocUnsafe(s+(o-g));y.fill(0,0,s);for(var m=s;g!==o;)y[m++]=u[g++];return y}return{encode:function(t){if((Array.isArray(t)||t instanceof Uint8Array)&&(t=i.from(t)),!i.isBuffer(t))throw TypeError("Expected Buffer");if(0===t.length)return"";for(var r=0,s=0,n=0,o=t.length;n!==o&&0===t[n];)n++,r++;for(var c=(o-n)*u+1>>>0,d=new Uint8Array(c);n!==o;){for(var h=t[n],f=0,p=c-1;(0!==h||f<s)&&-1!==p;p--,f++)h+=256*d[p]>>>0,d[p]=h%a>>>0,h=h/a>>>0;if(0!==h)throw Error("Non-zero carry");s=f,n++}for(var g=c-s;g!==c&&0===d[g];)g++;for(var y=l.repeat(r);g<c;++g)y+=e.charAt(d[g]);return y},decodeUnsafe:d,decode:function(e){var t=d(e);if(t)return t;throw Error("Non-base"+a+" character")}}}},701262,(e,t,r)=>{t.exports=e.r(217944)("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},572766,(e,t,r)=>{"use strict";function i(e,t,r){return t<=e&&e<=r}function s(e){if(void 0===e)return{};if(e===Object(e))return e;throw TypeError("Could not convert argument to dictionary")}function n(e){this.tokens=[].slice.call(e)}function o(e,t){if(e)throw TypeError("Decoder error");return t||65533}n.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():-1},prepend:function(e){if(Array.isArray(e))for(;e.length;)this.tokens.unshift(e.pop());else this.tokens.unshift(e)},push:function(e){if(Array.isArray(e))for(;e.length;)this.tokens.push(e.shift());else this.tokens.push(e)}};var a="utf-8";function l(e,t){if(!(this instanceof l))return new l(e,t);if((e=void 0!==e?String(e).toLowerCase():a)!==a)throw Error("Encoding not supported. Only utf-8 is supported");t=s(t),this._streaming=!1,this._BOMseen=!1,this._decoder=null,this._fatal=!!t.fatal,this._ignoreBOM=!!t.ignoreBOM,Object.defineProperty(this,"encoding",{value:"utf-8"}),Object.defineProperty(this,"fatal",{value:this._fatal}),Object.defineProperty(this,"ignoreBOM",{value:this._ignoreBOM})}function c(e,t){if(!(this instanceof c))return new c(e,t);
1if((e=void 0!==e?String(e).toLowerCase():a)!==a)throw Error("Encoding not supported. Only utf-8 is supported");t=s(t),this._streaming=!1,this._encoder=null,this._options={fatal:!!t.fatal},Object.defineProperty(this,"encoding",{value:"utf-8"})}function u(e){var t=e.fatal,r=0,s=0,n=0,a=128,l=191;this.handler=function(e,c){if(-1===c&&0!==n)return n=0,o(t);if(-1===c)return -1;if(0===n){if(i(c,0,127))return c;if(i(c,194,223))n=1,r=c-192;else if(i(c,224,239))224===c&&(a=160),237===c&&(l=159),n=2,r=c-224;else{if(!i(c,240,244))return o(t);240===c&&(a=144),244===c&&(l=143),n=3,r=c-240}return r<<=6*n,null}if(!i(c,a,l))return r=n=s=0,a=128,l=191,e.prepend(c),o(t);if(a=128,l=191,s+=1,r+=c-128<<6*(n-s),s!==n)return null;var u=r;return r=n=s=0,u}}function d(e){e.fatal,this.handler=function(e,t){if(-1===t)return -1;if(i(t,0,127))return t;i(t,128,2047)?(r=1,s=192):i(t,2048,65535)?(r=2,s=224):i(t,65536,1114111)&&(r=3,s=240);for(var r,s,n=[(t>>6*r)+s];r>0;){var o=t>>6*(r-1);n.push(128|63&o),r-=1}return n}}l.prototype={decode:function(e,t){r="object"==typeof e&&e instanceof ArrayBuffer?new Uint8Array(e):"object"==typeof e&&"buffer"in e&&e.buffer instanceof ArrayBuffer?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(0),t=s(t),this._streaming||(this._decoder=new u({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!t.stream;for(var r,i,o=new n(r),a=[];!o.endOfStream()&&-1!==(i=this._decoder.handler(o,o.read()));)null!==i&&(Array.isArray(i)?a.push.apply(a,i):a.push(i));if(!this._streaming){do{if(-1===(i=this._decoder.handler(o,o.read())))break;if(null===i)continue;Array.isArray(i)?a.push.apply(a,i):a.push(i)}while(!o.endOfStream())this._decoder=null}!a.length||-1===["utf-8"].indexOf(this.encoding)||this._ignoreBOM||this._BOMseen||(65279===a[0]?(this._BOMseen=!0,a.shift()):this._BOMseen=!0);for(var l="",c=0;c<a.length;++c){var d=a[c];d<=65535?l+=String.fromCharCode(d):(d-=65536,l+=String.fromCharCode((d>>10)+55296,(1023&d)+56320))}return l}},c.prototype={encode:function(e,t){e=e?String(e):"",t=s(t),this._streaming||(this._encoder=new d(this._options)),this._streaming=!!t.stream;for(var r,i=[],o=new n(function(e){for(var t=String(e),r=t.length,i=0,s=[];i<r;){var n=t.charCodeAt(i);if(n<55296||n>57343)s.push(n);else if(56320<=n&&n<=57343)s.push(65533);else if(55296<=n&&n<=56319)if(i===r-1)s.push(65533);else{var o=e.charCodeAt(i+1);if(56320<=o&&o<=57343){var a=1023&n,l=1023&o;s.push(65536+(a<<10)+l),i+=1}else s.push(65533)}i+=1}return s}(e));!o.endOfStream()&&-1!==(r=this._encoder.handler(o,o.read()));)Array.isArray(r)?i.push.apply(i,r):i.push(r);if(!this._streaming){for(;-1!==(r=this._encoder.handler(o,o.read()));)Array.isArray(r)?i.push.apply(i,r):i.push(r);this._encoder=null}return new Uint8Array(i)}},r.TextEncoder=c,r.TextDecoder=l},154119,(e,t,r)=>{"use strict";var i=e.i(467034),s=e.e&&e.e.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r),Object.defineProperty(e,i,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=e.e&&e.e.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=e.e&&e.e.__decorate||function(e,t,r,i){var s,n=arguments.length,o=n<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(s=e[a])&&(o=(n<3?s(o):n>3?s(t,r,o):s(t,r))||o);return n>3&&o&&Object.defineProperty(t,r,o),o},a=e.e&&e.e.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.hasOwnProperty.call(e,r)&&s(t,e,r);return n(t,e),t},l=e.e&&e.e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.deserializeUnchecked=r.deserialize=r.serialize=r.BinaryReader=r.BinaryWriter=r.BorshError=r.baseDecode=r.baseEncode=void 0;let c=l(e.r(659341)),u=l(e.r(701262)),d=a(e.r(572766)),h=new("function"!=typeof TextDecoder?d.TextDecoder:TextDecoder)("utf-8",{fatal:!0});r.baseEncode=function(e){return"string"==typeof e&&(e=i.Buffer.from(e,"utf8")),u.default.encode(i.Buffer.from(e))},r.baseDecode=function(e){return i.Buffer.from(u.default.decode(e))};
vendor: 5,816 bytes, line 1
1class f extends Error{constructor(e){super(e),this.fieldPath=[],this.originalMessage=e}addToFieldPath(e){this.fieldPath.splice(0,0,e),this.message=this.originalMessage+": "+this.fieldPath.join(".")}}r.BorshError=f;class p{constructor(){this.buf=i.Buffer.alloc(1024),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=i.Buffer.concat([this.buf,i.Buffer.alloc(1024)]))}writeU8(e){this.maybeResize(),this.buf.writeUInt8(e,this.length),this.length+=1}writeU16(e){this.maybeResize(),this.buf.writeUInt16LE(e,this.length),this.length+=2}writeU32(e){this.maybeResize(),this.buf.writeUInt32LE(e,this.length),this.length+=4}writeU64(e){this.maybeResize(),this.writeBuffer(i.Buffer.from(new c.default(e).toArray("le",8)))}writeU128(e){this.maybeResize(),this.writeBuffer(i.Buffer.from(new c.default(e).toArray("le",16)))}writeU256(e){this.maybeResize(),this.writeBuffer(i.Buffer.from(new c.default(e).toArray("le",32)))}writeU512(e){this.maybeResize(),this.writeBuffer(i.Buffer.from(new c.default(e).toArray("le",64)))}writeBuffer(e){this.buf=i.Buffer.concat([i.Buffer.from(this.buf.subarray(0,this.length)),e,i.Buffer.alloc(1024)]),this.length+=e.length}writeString(e){this.maybeResize();let t=i.Buffer.from(e,"utf8");this.writeU32(t.length),this.writeBuffer(t)}writeFixedArray(e){this.writeBuffer(i.Buffer.from(e))}writeArray(e,t){for(let r of(this.maybeResize(),this.writeU32(e.length),e))this.maybeResize(),t(r)}toArray(){return this.buf.subarray(0,this.length)}}function g(e,t,r){let i=r.value;r.value=function(...e){try{return i.apply(this,e)}catch(e){if(e instanceof RangeError&&["ERR_BUFFER_OUT_OF_BOUNDS","ERR_OUT_OF_RANGE"].indexOf(e.code)>=0)throw new f("Reached the end of buffer when deserializing");throw e}}}r.BinaryWriter=p;class y{constructor(e){this.buf=e,this.offset=0}readU8(){let e=this.buf.readUInt8(this.offset);return this.offset+=1,e}readU16(){let e=this.buf.readUInt16LE(this.offset);return this.offset+=2,e}readU32(){let e=this.buf.readUInt32LE(this.offset);return this.offset+=4,e}readU64(){let e=this.readBuffer(8);return new c.default(e,"le")}readU128(){let e=this.readBuffer(16);return new c.default(e,"le")}readU256(){let e=this.readBuffer(32);return new c.default(e,"le")}readU512(){let e=this.readBuffer(64);return new c.default(e,"le")}readBuffer(e){if(this.offset+e>this.buf.length)throw new f(`Expected buffer length ${e} isn't within bounds`);let t=this.buf.slice(this.offset,this.offset+e);return this.offset+=e,t}readString(){let e=this.readU32(),t=this.readBuffer(e);try{return h.decode(t)}catch(e){throw new f(`Error decoding UTF-8 string: ${e}`)}}readFixedArray(e){return new Uint8Array(this.readBuffer(e))}readArray(e){let t=this.readU32(),r=[];for(let i=0;i<t;++i)r.push(e());return r}}function m(e){return e.charAt(0).toUpperCase()+e.slice(1)}function b(e,t,r,i,s){try{if("string"==typeof i)s[`write${m(i)}`](r);else if(i instanceof Array)if("number"==typeof i[0]){if(r.length!==i[0])throw new f(`Expecting byte array of length ${i[0]}, but got ${r.length} bytes`);s.writeFixedArray(r)}else if(2===i.length&&"number"==typeof i[1]){if(r.length!==i[1])throw new f(`Expecting byte array of length ${i[1]}, but got ${r.length} bytes`);for(let t=0;t<i[1];t++)b(e,null,r[t],i[0],s)}else s.writeArray(r,r=>{b(e,t,r,i[0],s)});else if(void 0!==i.kind)switch(i.kind){case"option":null==r?s.writeU8(0):(s.writeU8(1),b(e,t,r,i.type,s));break;case"map":s.writeU32(r.size),r.forEach((r,n)=>{b(e,t,n,i.key,s),b(e,t,r,i.value,s)});break;default:throw new f(`FieldType ${i} unrecognized`)}else v(e,r,s)}catch(e){throw e instanceof f&&e.addToFieldPath(t),e}}function v(e,t,r){if("function"==typeof t.borshSerialize)return void t.borshSerialize(r);let i=e.get(t.constructor);if(!i)throw new f(`Class ${t.constructor.name} is missing in schema`);if("struct"===i.kind)i.fields.map(([i,s])=>{b(e,i,t[i],s,r)});else if("enum"===i.kind){let s=t[i.field];for(let n=0;n<i.values.length;++n){let[o,a]=i.values[n];if(o===s){r.writeU8(n),b(e,o,t[o],a,r);break}}}else throw new f(`Unexpected schema kind: ${i.kind} for ${t.constructor.name}`)}function w(e,t,r,i){try{if("string"==typeof r)return i[`read${m(r)}`]();if(r instanceof Array)if("number"==typeof r[0])return i.readFixedArray(r[0]);else{if("number"!=typeof r[1])return i.readArray(()=>w(e,t,r[0],i));let s=[];for(let t=0;t<r[1];t++)s.push(w(e,null,r[0],i));return s}if("option"===r.kind){if(i.readU8())return w(e,t,r.type,i);return}if("map"===r.kind){let s=new Map,n=i.readU32();for(let o=0;o<n;o++){let n=w(e,t,r.key,i),o=w(e,t,r.value,i);s.set(n,o)}return s}return _(e,r,i)}catch(e){throw e instanceof f&&e.addToFieldPath(t),e}}function _(e,t,r){if("function"==typeof t.borshDeserialize)return t.borshDeserialize(r);let i=e.get(t);if(!i)throw new f(`Class ${t.name} is missing in schema`);if("struct"===i.kind){let i={};for(let[s,n]of e.get(t).fields)i[s]=w(e,s,n,r);return new t(i)}if("enum"===i.kind){let s=r.readU8();if(s>=i.values.length)throw new f(`Enum index: ${s} is out of range`);let[n,o]=i.values[s],a=w(e,n,o,r);return new t({[n]:a})}throw new f(`Unexpected schema kind: ${i.kind} for ${t.constructor.name}`)}o([g],y.prototype,"readU8",null),o([g],y.prototype,"readU16",null),o([g],y.prototype,"readU32",null),o([g],y.prototype,"readU64",null),o([g],y.prototype,"readU128",null),o([g],y.prototype,"readU256",null),o([g],y.prototype,"readU512",null),o([g],y.prototype,"readString",null),o([g],y.prototype,"readFixedArray",null),o([g],y.prototype,"readArray",null),r.BinaryReader=y,r.serialize=function(e,t,r=p){let i=new r;return v(e,t,i),i.toArray()},r.deserialize=function(e,t,r,i=y){let s=new i(r),n=_(e,t,s);if(s.offset<r.length)throw new f(`Unexpected ${r.length-s.offset} bytes after deserialized data`);return n},r.deserializeUnchecked=function(e,t,r,i=y){return _(e,t,new i(r))}},444610,(e,t,r)=>{"use strict";
1Object.defineProperty(r,"__esModule",{value:!0}),r.s16=r.s8=r.nu64be=r.u48be=r.u40be=r.u32be=r.u24be=r.u16be=r.nu64=r.u48=r.u40=r.u32=r.u24=r.u16=r.u8=r.offset=r.greedy=r.Constant=r.UTF8=r.CString=r.Blob=r.Boolean=r.BitField=r.BitStructure=r.VariantLayout=r.Union=r.UnionLayoutDiscriminator=r.UnionDiscriminator=r.Structure=r.Sequence=r.DoubleBE=r.Double=r.FloatBE=r.Float=r.NearInt64BE=r.NearInt64=r.NearUInt64BE=r.NearUInt64=r.IntBE=r.Int=r.UIntBE=r.UInt=r.OffsetLayout=r.GreedyCount=r.ExternalLayout=r.bindConstructorLayout=r.nameWithProperty=r.Layout=r.uint8ArrayToBuffer=r.checkUint8Array=void 0,r.constant=r.utf8=r.cstr=r.blob=r.unionLayoutDiscriminator=r.union=r.seq=r.bits=r.struct=r.f64be=r.f64=r.f32be=r.f32=r.ns64be=r.s48be=r.s40be=r.s32be=r.s24be=r.s16be=r.ns64=r.s48=r.s40=r.s32=r.s24=void 0;let i=e.r(843943);function s(e){if(!(e instanceof Uint8Array))throw TypeError("b must be a Uint8Array")}function n(e){return s(e),i.Buffer.from(e.buffer,e.byteOffset,e.length)}r.checkUint8Array=s,r.uint8ArrayToBuffer=n;class o{constructor(e,t){if(!Number.isInteger(e))throw TypeError("span must be an integer");this.span=e,this.property=t}makeDestinationObject(){return{}}getSpan(e,t){if(0>this.span)throw RangeError("indeterminate span");return this.span}replicate(e){let t=Object.create(this.constructor.prototype);return Object.assign(t,this),t.property=e,t}fromArray(e){}}function a(e,t){return t.property?e+"["+t.property+"]":e}r.Layout=o,r.nameWithProperty=a,r.bindConstructorLayout=function(e,t){if("function"!=typeof e)throw TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(e,"layout_"))throw Error("Class is already bound to a layout");if(!(t&&t instanceof o))throw TypeError("layout must be a Layout");if(Object.prototype.hasOwnProperty.call(t,"boundConstructor_"))throw Error("layout is already bound to a constructor");e.layout_=t,t.boundConstructor_=e,t.makeDestinationObject=()=>new e,Object.defineProperty(e.prototype,"encode",{value(e,r){return t.encode(this,e,r)},writable:!0}),Object.defineProperty(e,"decode",{value:(e,r)=>t.decode(e,r),writable:!0})};class l extends o{isCount(){throw Error("ExternalLayout is abstract")}}r.ExternalLayout=l;class c extends l{constructor(e=1,t){if(!Number.isInteger(e)||0>=e)throw TypeError("elementSpan must be a (positive) integer");super(-1,t),this.elementSpan=e}isCount(){return!0}decode(e,t=0){return s(e),Math.floor((e.length-t)/this.elementSpan)}encode(e,t,r){return 0}}r.GreedyCount=c;class u extends l{constructor(e,t=0,r){if(!(e instanceof o))throw TypeError("layout must be a Layout");if(!Number.isInteger(t))throw TypeError("offset must be integer or undefined");super(e.span,r||e.property),this.layout=e,this.offset=t}isCount(){return this.layout instanceof d||this.layout instanceof h}decode(e,t=0){return this.layout.decode(e,t+this.offset)}encode(e,t,r=0){return this.layout.encode(e,t,r+this.offset)}}r.OffsetLayout=u;class d extends o{constructor(e,t){if(super(e,t),6<this.span)throw RangeError("span must not exceed 6 bytes")}decode(e,t=0){return n(e).readUIntLE(t,this.span)}encode(e,t,r=0){return n(t).writeUIntLE(e,r,this.span),this.span}}r.UInt=d;class h extends o{constructor(e,t){if(super(e,t),6<this.span)throw RangeError("span must not exceed 6 bytes")}decode(e,t=0){return n(e).readUIntBE(t,this.span)}encode(e,t,r=0){return n(t).writeUIntBE(e,r,this.span),this.span}}r.UIntBE=h;class f extends o{constructor(e,t){if(super(e,t),6<this.span)throw RangeError("span must not exceed 6 bytes")}decode(e,t=0){return n(e).readIntLE(t,this.span)}encode(e,t,r=0){return n(t).writeIntLE(e,r,this.span),this.span}}r.Int=f;class p extends o{constructor(e,t){if(super(e,t),6<this.span)throw RangeError("span must not exceed 6 bytes")}decode(e,t=0){return n(e).readIntBE(t,this.span)}encode(e,t,r=0){return n(t).writeIntBE(e,r,this.span),this.span}}function g(e){let t=Math.floor(e/0x100000000);return{hi32:t,lo32:e-0x100000000*t}}function y(e,t){return 0x100000000*e+t}r.IntBE=p;class m extends o{constructor(e){super(8,e)}decode(e,t=0){let r=n(e),i=r.readUInt32LE(t);return y(r.readUInt32LE(t+4),i)}encode(e,t,r=0){let i=g(e),s=n(t);return s.writeUInt32LE(i.lo32,r),s.writeUInt32LE(i.hi32,r+4),8}}r.NearUInt64=m;class b extends o{constructor(e){super(8,e)}decode(e,t=0){let r=n(e);return y(r.readUInt32BE(t),r.readUInt32BE(t+4))}encode(e,t,r=0){let i=g(e),s=n(t);return s.writeUInt32BE(i.hi32,r),s.writeUInt32BE(i.lo32,r+4),8}}r.NearUInt64BE=b;class v extends o{constructor(e){super(8,e)}decode(e,t=0){let r=n(e),i=r.readUInt32LE(t);return y(r.readInt32LE(t+4),i)}encode(e,t,r=0){let i=g(e),s=n(t);return s.writeUInt32LE(i.lo32,r),s.writeInt32LE(i.hi32,r+4),8}}r.NearInt64=v;class w extends o{constructor(e){super(8,e)}decode(e,t=0){let r=n(e);return y(r.readInt32BE(t),r.readUInt32BE(t+4))}encode(e,t,r=0){let i=g(e),s=n(t);return s.writeInt32BE(i.hi32,r),s.writeUInt32BE(i.lo32,r+4),8}}r.NearInt64BE=w;class _ extends o{constructor(e){super(4,e)}decode(e,t=0){return n(e).readFloatLE(t)}encode(e,t,r=0){return n(t).writeFloatLE(e,r),4}}r.Float=_;class S extends o{constructor(e){super(4,e)}decode(e,t=0){return n(e).readFloatBE(t)}encode(e,t,r=0){return n(t).writeFloatBE(e,r),4}}r.FloatBE=S;class E extends o{constructor(e){super(8,e)}decode(e,t=0){return n(e).readDoubleLE(t)}encode(e,t,r=0){return n(t).writeDoubleLE(e,r),8}}r.Double=E;class I extends o{constructor(e){super(8,e)}decode(e,t=0){return n(e).readDoubleBE(t)}encode(e,t,r=0){return n(t).writeDoubleBE(e,r),8}}r.DoubleBE=I;class A extends o{constructor(e,t,r){if(!(e instanceof o))throw TypeError("elementLayout must be a Layout");if(!(t instanceof l&&t.isCount()||Number.isInteger(t)&&0<=t))throw TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let i=-1;t instanceof l||!(0<e.span)||(i=t*e.span),super(i,r),this.elementLayout=e,this.count=t}getSpan(e,t=0){if(0<=this.span)return this.span;let r=0,i=this.count;if(i instanceof l&&(i=i.decode(e,t)),0<this.elementLayout.span)r=i*this.elementLayout.span;else{let s=0;for(;s<i;)r+=this.elementLayout.getSpan(e,t+r),++s}return r}decode(e,t=0){let r=[],i=0,s=this.count;for(s instanceof l&&(s=s.decode(e,t));i<s;)r.push(this.elementLayout.decode(e,t)),t+=this.elementLayout.getSpan(e,t),i+=1;return r}encode(e,t,r=0){let i=this.elementLayout,s=e.reduce((e,s)=>e+i.encode(s,t,r+e),0);return this.count instanceof l&&this.count.encode(e.length,t,r),s}}r.Sequence=A;class T extends o{constructor(e,t,r){if(!(Array.isArray(e)&&e.reduce((e,t)=>
1e&&t instanceof o,!0)))throw TypeError("fields must be array of Layout instances");for(const i of("boolean"==typeof t&&void 0===r&&(r=t,t=void 0),e))if(0>i.span&&void 0===i.property)throw Error("fields cannot contain unnamed variable-length layout");let i=-1;try{i=e.reduce((e,t)=>e+t.getSpan(),0)}catch(e){}super(i,t),this.fields=e,this.decodePrefixes=!!r}getSpan(e,t=0){if(0<=this.span)return this.span;let r=0;try{r=this.fields.reduce((r,i)=>{let s=i.getSpan(e,t);return t+=s,r+s},0)}catch(e){throw RangeError("indeterminate span")}return r}decode(e,t=0){s(e);let r=this.makeDestinationObject();for(let i of this.fields)if(void 0!==i.property&&(r[i.property]=i.decode(e,t)),t+=i.getSpan(e,t),this.decodePrefixes&&e.length===t)break;return r}encode(e,t,r=0){let i=r,s=0,n=0;for(let i of this.fields){let o=i.span;if(n=0<o?o:0,void 0!==i.property){let s=e[i.property];void 0!==s&&(n=i.encode(s,t,r),0>o&&(o=i.getSpan(t,r)))}s=r,r+=o}return s+n-i}fromArray(e){let t=this.makeDestinationObject();for(let r of this.fields)void 0!==r.property&&0<e.length&&(t[r.property]=e.shift());return t}layoutFor(e){if("string"!=typeof e)throw TypeError("property must be string");for(let t of this.fields)if(t.property===e)return t}offsetOf(e){if("string"!=typeof e)throw TypeError("property must be string");let t=0;for(let r of this.fields){if(r.property===e)return t;0>r.span?t=-1:0<=t&&(t+=r.span)}}}r.Structure=T;class x{constructor(e){this.property=e}decode(e,t){throw Error("UnionDiscriminator is abstract")}encode(e,t,r){throw Error("UnionDiscriminator is abstract")}}r.UnionDiscriminator=x;class k extends x{constructor(e,t){if(!(e instanceof l&&e.isCount()))throw TypeError("layout must be an unsigned integer ExternalLayout");super(t||e.property||"variant"),this.layout=e}decode(e,t){return this.layout.decode(e,t)}encode(e,t,r){return this.layout.encode(e,t,r)}}r.UnionLayoutDiscriminator=k;class P extends o{constructor(e,t,r){let i;if(e instanceof d||e instanceof h)i=new k(new u(e));else if(e instanceof l&&e.isCount())i=new k(e);else if(e instanceof x)i=e;else throw TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(void 0===t&&(t=null),!(null===t||t instanceof o))throw TypeError("defaultLayout must be null or a Layout");if(null!==t){if(0>t.span)throw Error("defaultLayout must have constant span");void 0===t.property&&(t=t.replicate("content"))}let s=-1;t&&0<=(s=t.span)&&(e instanceof d||e instanceof h)&&(s+=i.layout.span),super(s,r),this.discriminator=i,this.usesPrefixDiscriminator=e instanceof d||e instanceof h,this.defaultLayout=t,this.registry={};let n=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(e){return n(e)},this.configGetSourceVariant=function(e){n=e.bind(this)}}getSpan(e,t=0){if(0<=this.span)return this.span;let r=this.getVariant(e,t);if(!r)throw Error("unable to determine span for unrecognized variant");return r.getSpan(e,t)}defaultGetSourceVariant(e){if(Object.prototype.hasOwnProperty.call(e,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(e,this.defaultLayout.property))return;let t=this.registry[e[this.discriminator.property]];if(t&&(!t.layout||t.property&&Object.prototype.hasOwnProperty.call(e,t.property)))return t}else for(let t in this.registry){let r=this.registry[t];if(r.property&&Object.prototype.hasOwnProperty.call(e,r.property))return r}throw Error("unable to infer src variant")}decode(e,t=0){let r,i=this.discriminator,s=i.decode(e,t),n=this.registry[s];if(void 0===n){let n=this.defaultLayout,o=0;this.usesPrefixDiscriminator&&(o=i.layout.span),(r=this.makeDestinationObject())[i.property]=s,r[n.property]=n.decode(e,t+o)}else r=n.decode(e,t);return r}encode(e,t,r=0){let i=this.getSourceVariant(e);if(void 0===i){let i=this.discriminator,s=this.defaultLayout,n=0;return this.usesPrefixDiscriminator&&(n=i.layout.span),i.encode(e[i.property],t,r),n+s.encode(e[s.property],t,r+n)}return i.encode(e,t,r)}addVariant(e,t,r){let i=new O(this,e,t,r);return this.registry[e]=i,i}getVariant(e,t=0){let r;return r=e instanceof Uint8Array?this.discriminator.decode(e,t):e,this.registry[r]}}r.Union=P;
1class O extends o{constructor(e,t,r,i){if(!(e instanceof P))throw TypeError("union must be a Union");if(!Number.isInteger(t)||0>t)throw TypeError("variant must be a (non-negative) integer");if("string"==typeof r&&void 0===i&&(i=r,r=null),r){if(!(r instanceof o))throw TypeError("layout must be a Layout");if(null!==e.defaultLayout&&0<=r.span&&r.span>e.defaultLayout.span)throw Error("variant span exceeds span of containing union");if("string"!=typeof i)throw TypeError("variant must have a String property")}let s=e.span;0>e.span&&0<=(s=r?r.span:0)&&e.usesPrefixDiscriminator&&(s+=e.discriminator.layout.span),super(s,i),this.union=e,this.variant=t,this.layout=r||null}getSpan(e,t=0){if(0<=this.span)return this.span;let r=0;this.union.usesPrefixDiscriminator&&(r=this.union.discriminator.layout.span);let i=0;return this.layout&&(i=this.layout.getSpan(e,t+r)),r+i}decode(e,t=0){let r=this.makeDestinationObject();if(this!==this.union.getVariant(e,t))throw Error("variant mismatch");let i=0;return this.union.usesPrefixDiscriminator&&(i=this.union.discriminator.layout.span),this.layout?r[this.property]=this.layout.decode(e,t+i):this.property?r[this.property]=!0:this.union.usesPrefixDiscriminator&&(r[this.union.discriminator.property]=this.variant),r}encode(e,t,r=0){let i=0;if(this.union.usesPrefixDiscriminator&&(i=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(e,this.property))throw TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,t,r);let s=i;if(this.layout&&(this.layout.encode(e[this.property],t,r+i),s+=this.layout.getSpan(t,r+i),0<=this.union.span&&s>this.union.span))throw Error("encoded variant overruns containing union");return s}fromArray(e){if(this.layout)return this.layout.fromArray(e)}}function R(e){return 0>e&&(e+=0x100000000),e}r.VariantLayout=O;class C extends o{constructor(e,t,r){if(!(e instanceof d||e instanceof h))throw TypeError("word must be a UInt or UIntBE layout");if("string"==typeof t&&void 0===r&&(r=t,t=!1),4<e.span)throw RangeError("word cannot exceed 32 bits");super(e.span,r),this.word=e,this.msb=!!t,this.fields=[];let i=0;this._packedSetValue=function(e){return i=R(e),this},this._packedGetValue=function(){return i}}decode(e,t=0){let r=this.makeDestinationObject(),i=this.word.decode(e,t);for(let t of(this._packedSetValue(i),this.fields))void 0!==t.property&&(r[t.property]=t.decode(e));return r}encode(e,t,r=0){let i=this.word.decode(t,r);for(let t of(this._packedSetValue(i),this.fields))if(void 0!==t.property){let r=e[t.property];void 0!==r&&t.encode(r)}return this.word.encode(this._packedGetValue(),t,r)}addField(e,t){let r=new N(this,e,t);return this.fields.push(r),r}addBoolean(e){let t=new B(this,e);return this.fields.push(t),t}fieldFor(e){if("string"!=typeof e)throw TypeError("property must be string");for(let t of this.fields)if(t.property===e)return t}}r.BitStructure=C;class N{constructor(e,t,r){if(!(e instanceof C))throw TypeError("container must be a BitStructure");if(!Number.isInteger(t)||0>=t)throw TypeError("bits must be positive integer");const i=8*e.span,s=e.fields.reduce((e,t)=>e+t.bits,0);if(t+s>i)throw Error("bits too long for span remainder ("+(i-s)+" of "+i+" remain)");this.container=e,this.bits=t,this.valueMask=(1<<t)-1,32===t&&(this.valueMask=0xffffffff),this.start=s,this.container.msb&&(this.start=i-s-t),this.wordMask=R(this.valueMask<<this.start),this.property=r}decode(e,t){return R(this.container._packedGetValue()&this.wordMask)>>>this.start}encode(e){if("number"!=typeof e||!Number.isInteger(e)||e!==R(e&this.valueMask))throw TypeError(a("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);let t=this.container._packedGetValue(),r=R(e<<this.start);this.container._packedSetValue(R(t&~this.wordMask)|r)}}r.BitField=N;class B extends N{constructor(e,t){super(e,1,t)}decode(e,t){return!!super.decode(e,t)}encode(e){"boolean"==typeof e&&(e*=1),super.encode(e)}}r.Boolean=B;class U extends o{constructor(e,t){if(!(e instanceof l&&e.isCount()||Number.isInteger(e)&&0<=e))throw TypeError("length must be positive integer or an unsigned integer ExternalLayout");let r=-1;e instanceof l||(r=e),super(r,t),this.length=e}getSpan(e,t){let r=this.span;return 0>r&&(r=this.length.decode(e,t)),r}decode(e,t=0){let r=this.span;return 0>r&&(r=this.length.decode(e,t)),n(e).slice(t,t+r)}encode(e,t,r){let i=this.length;if(this.length instanceof l&&(i=e.length),!(e instanceof Uint8Array&&i===e.length))throw TypeError(a("Blob.encode",this)+" requires (length "+i+") Uint8Array as src");if(r+i>t.length)throw RangeError("encoding overruns Uint8Array");let s=n(e);return n(t).write(s.toString("hex"),r,i,"hex"),this.length instanceof l&&this.length.encode(i,t,r),i}}r.Blob=U;class q extends o{constructor(e){super(-1,e)}getSpan(e,t=0){s(e);let r=t;for(;r<e.length&&0!==e[r];)r+=1;return 1+r-t}decode(e,t=0){let r=this.getSpan(e,t);return n(e).slice(t,t+r-1).toString("utf-8")}encode(e,t,r=0){"string"!=typeof e&&(e=String(e));let s=i.Buffer.from(e,"utf8"),o=s.length;if(r+o>t.length)throw RangeError("encoding overruns Buffer");let a=n(t);return s.copy(a,r),a[r+o]=0,o+1}}r.CString=q;class L extends o{constructor(e,t){if("string"==typeof e&&void 0===t&&(t=e,e=void 0),void 0===e)e=-1;else if(!Number.isInteger(e))throw TypeError("maxSpan must be an integer");super(-1,t),this.maxSpan=e}getSpan(e,t=0){return s(e),e.length-t}decode(e,t=0){let r=this.getSpan(e,t);if(0<=this.maxSpan&&this.maxSpan<r)throw RangeError("text length exceeds maxSpan");return n(e).slice(t,t+r).toString("utf-8")}encode(e,t,r=0){"string"!=typeof e&&(e=String(e));let s=i.Buffer.from(e,"utf8"),o=s.length;if(0<=this.maxSpan&&this.maxSpan<o)throw RangeError("text length exceeds maxSpan");if(r+o>t.length)throw RangeError("encoding overruns Buffer");return s.copy(n(t),r),o}}r.UTF8=L;class D extends o{constructor(e,t){super(0,t),this.value=e}decode(e,t){return this.value}encode(e,t,r){return 0}}r.Constant=D,r.greedy=(e,t)=>new c(e,t),r.offset=(e,t,r)=>new u(e,t,r),r.u8=e=>
1new d(1,e),r.u16=e=>new d(2,e),r.u24=e=>new d(3,e),r.u32=e=>new d(4,e),r.u40=e=>new d(5,e),r.u48=e=>new d(6,e),r.nu64=e=>new m(e),r.u16be=e=>new h(2,e),r.u24be=e=>new h(3,e),r.u32be=e=>new h(4,e),r.u40be=e=>new h(5,e),r.u48be=e=>new h(6,e),r.nu64be=e=>new b(e),r.s8=e=>new f(1,e),r.s16=e=>new f(2,e),r.s24=e=>new f(3,e),r.s32=e=>new f(4,e),r.s40=e=>new f(5,e),r.s48=e=>new f(6,e),r.ns64=e=>new v(e),r.s16be=e=>new p(2,e),r.s24be=e=>new p(3,e),r.s32be=e=>new p(4,e),r.s40be=e=>new p(5,e),r.s48be=e=>new p(6,e),r.ns64be=e=>new w(e),r.f32=e=>new _(e),r.f32be=e=>new S(e),r.f64=e=>new E(e),r.f64be=e=>new I(e),r.struct=(e,t,r)=>new T(e,t,r),r.bits=(e,t,r)=>new C(e,t,r),r.seq=(e,t,r)=>new A(e,t,r),r.union=(e,t,r)=>new P(e,t,r),r.unionLayoutDiscriminator=(e,t)=>new k(e,t),r.blob=(e,t)=>new U(e,t),r.cstr=e=>new q(e),r.utf8=(e,t)=>new L(e,t),r.constant=(e,t)=>new D(e,t)},642044,e=>{"use strict";function t([e,r]){return`${e}=${function e(t){return Array.isArray(t)?"%5B"+t.map(e).join("%2C%20")+"%5D":"bigint"==typeof t?`${t}n`:encodeURIComponent(String(null!=t&&null===Object.getPrototypeOf(t)?{...t}:t))}(r)}`}var r=class extends Error{cause=this.cause;context;constructor(...[e,r]){let i,s;if(r){const{cause:e,...t}=r;e&&(s={cause:e}),Object.keys(t).length>0&&(i=t)}super(function(e,r={}){{let i=`Solana error #${e}; Decode this error by running \`npx @solana/errors decode -- ${e}`;return Object.keys(r).length&&(i+=` '${btoa(Object.entries(r).map(t).join("&"))}'`),`${i}\``}}(e,i),s),this.context={__code:e,...i},this.name="SolanaError"}};e.s(["SOLANA_ERROR__CODECS__CANNOT_DECODE_EMPTY_BYTE_ARRAY",0,8078e3,"SOLANA_ERROR__CODECS__ENCODED_BYTES_MUST_NOT_INCLUDE_SENTINEL",0,8078020,"SOLANA_ERROR__CODECS__ENCODER_DECODER_FIXED_SIZE_MISMATCH",0,8078005,"SOLANA_ERROR__CODECS__ENCODER_DECODER_MAX_SIZE_MISMATCH",0,8078006,"SOLANA_ERROR__CODECS__ENCODER_DECODER_SIZE_COMPATIBILITY_MISMATCH",0,8078004,"SOLANA_ERROR__CODECS__EXPECTED_FIXED_LENGTH",0,8078002,"SOLANA_ERROR__CODECS__EXPECTED_POSITIVE_BYTE_LENGTH",0,8078013,"SOLANA_ERROR__CODECS__EXPECTED_VARIABLE_LENGTH",0,8078003,"SOLANA_ERROR__CODECS__INVALID_BYTE_LENGTH",0,8078001,"SOLANA_ERROR__CODECS__NUMBER_OUT_OF_RANGE",0,8078011,"SOLANA_ERROR__CODECS__OFFSET_OUT_OF_RANGE",0,8078014,"SOLANA_ERROR__CODECS__SENTINEL_MISSING_IN_DECODED_BYTES",0,8078021,"SolanaError",0,r])},284257,e=>{"use strict";var t=e.i(642044);function r(e){return"fixedSize"in e&&"number"==typeof e.fixedSize}e.s(["assertByteArrayHasEnoughBytesForCodec",0,function(e,r,i,s=0){let n=i.length-s;if(n<r)throw new t.SolanaError(t.SOLANA_ERROR__CODECS__INVALID_BYTE_LENGTH,{bytesLength:n,codecDescription:e,expected:r})},"assertByteArrayIsNotEmptyForCodec",0,function(e,r,i=0){if(r.length-i<=0)throw new t.SolanaError(t.SOLANA_ERROR__CODECS__CANNOT_DECODE_EMPTY_BYTE_ARRAY,{codecDescription:e})},"combineCodec",0,function(e,i){if(r(e)!==r(i))throw new t.SolanaError(t.SOLANA_ERROR__CODECS__ENCODER_DECODER_SIZE_COMPATIBILITY_MISMATCH);if(r(e)&&r(i)&&e.fixedSize!==i.fixedSize)throw new t.SolanaError(t.SOLANA_ERROR__CODECS__ENCODER_DECODER_FIXED_SIZE_MISMATCH,{decoderFixedSize:i.fixedSize,encoderFixedSize:e.fixedSize});if(!r(e)&&!r(i)&&e.maxSize!==i.maxSize)throw new t.SolanaError(t.SOLANA_ERROR__CODECS__ENCODER_DECODER_MAX_SIZE_MISMATCH,{decoderMaxSize:i.maxSize,encoderMaxSize:e.maxSize});return{...i,...e,decode:i.decode,encode:e.encode,read:i.read,write:e.write}},"createDecoder",0,function(e){return Object.freeze({...e,decode:(t,r=0)=>e.read(t,r)[0]})},"createEncoder",0,function(e){return Object.freeze({...e,encode:t=>{let r=new Uint8Array("fixedSize"in e?e.fixedSize:e.getSizeFromValue(t));return e.write(t,r,0),r}})}])},640512,e=>{"use strict";var t,r=e.i(642044),i=e.i(284257),s=((t=s||{})[t.Little=0]="Little",t[t.Big=1]="Big",t);function n(e){return e?.endian!==1}var o=(e={})=>{var t;return t={config:e,name:"u64",range:[0n,BigInt("0xffffffffffffffff")],set:(e,t,r)=>e.setBigUint64(0,BigInt(t),r),size:8},(0,i.createEncoder)({fixedSize:t.size,write(e,i,s){t.range&&function(e,t,i,s){if(s<t||s>i)throw new r.SolanaError(r.SOLANA_ERROR__CODECS__NUMBER_OUT_OF_RANGE,{codecDescription:e,max:i,min:t,value:s})}(t.name,t.range[0],t.range[1],e);let o=new ArrayBuffer(t.size);return t.set(new DataView(o),e,n(t.config)),i.set(new Uint8Array(o),s),s+t.size}})};e.s(["getU64Codec",0,(e={})=>(0,i.combineCodec)(o(e),((e={})=>{var t;return t={config:e,get:(e,t)=>e.getBigUint64(0,t),name:"u64",size:8},(0,i.createDecoder)({fixedSize:t.size,read(e,r=0){var s,o,a;let l,c;
1(0,i.assertByteArrayIsNotEmptyForCodec)(t.name,e,r),(0,i.assertByteArrayHasEnoughBytesForCodec)(t.name,t.size,e,r);let u=new DataView((s=e,o=r,a=t.size,l=s.byteOffset+(o??0),c=a??s.byteLength,s.buffer.slice(l,l+c)));return[t.get(u,n(t.config)),r+t.size]}})})(e)),"getU64Encoder",0,o])},685098,e=>{"use strict";class t extends TypeError{constructor(e,t){let r;const{message:i,explanation:s,...n}=e,{path:o}=e,a=0===o.length?i:`At path: ${o.join(".")} -- ${i}`;super(s??a),null!=s&&(this.cause=a),Object.assign(this,n),this.name=this.constructor.name,this.failures=()=>r??(r=[e,...t()])}}function r(e){return"object"==typeof e&&null!=e}function i(e){return r(e)&&!Array.isArray(e)}function s(e){return"symbol"==typeof e?e.toString():"string"==typeof e?JSON.stringify(e):`${e}`}function*n(e,t,i,n){var o;for(let a of(r(o=e)&&"function"==typeof o[Symbol.iterator]||(e=[e]),e)){let e=function(e,t,r,i){if(!0===e)return;!1===e?e={}:"string"==typeof e&&(e={message:e});let{path:n,branch:o}=t,{type:a}=r,{refinement:l,message:c=`Expected a value of type \`${a}\`${l?` with refinement \`${l}\``:""}, but received: \`${s(i)}\``}=e;return{value:i,type:a,refinement:l,key:n[n.length-1],path:n,branch:o,...e,message:c}}(a,t,i,n);e&&(yield e)}}function*o(e,t,i={}){let{path:s=[],branch:n=[e],coerce:a=!1,mask:l=!1}=i,c={path:s,branch:n,mask:l};a&&(e=t.coercer(e,c));let u="valid";for(let r of t.validator(e,c))r.explanation=i.message,u="not_valid",yield[r,void 0];for(let[d,h,f]of t.entries(e,c))for(let t of o(h,f,{path:void 0===d?s:[...s,d],branch:void 0===d?n:[...n,h],coerce:a,mask:l,message:i.message}))t[0]?(u=null!=t[0].refinement?"not_refined":"not_valid",yield[t[0],void 0]):a&&(h=t[1],void 0===d?e=h:e instanceof Map?e.set(d,h):e instanceof Set?e.add(h):r(e)&&(void 0!==h||d in e)&&(e[d]=h));if("not_valid"!==u)for(let r of t.refiner(e,c))r.explanation=i.message,u="not_refined",yield[r,void 0];"valid"===u&&(yield[void 0,e])}class a{constructor(e){const{type:t,schema:r,validator:i,refiner:s,coercer:o=e=>e,entries:a=function*(){}}=e;this.type=t,this.schema=r,this.entries=a,this.coercer=o,i?this.validator=(e,t)=>n(i(e,t),t,this,e):this.validator=()=>[],s?this.refiner=(e,t)=>n(s(e,t),t,this,e):this.refiner=()=>[]}assert(e,t){return l(e,this,t)}create(e,t){return c(e,this,t)}is(e){var t,r;return t=e,r=this,!u(t,r)[0]}mask(e,t){var r=e,i=this,s=t;let n=u(r,i,{coerce:!0,mask:!0,message:s});if(!n[0])return n[1];throw n[0]}validate(e,t={}){return u(e,this,t)}}function l(e,t,r){let i=u(e,t,{message:r});if(i[0])throw i[0]}function c(e,t,r){let i=u(e,t,{coerce:!0,message:r});if(!i[0])return i[1];throw i[0]}function u(e,r,i={}){let s=o(e,r,i),n=function(e){let{done:t,value:r}=e.next();return t?void 0:r}(s);return n[0]?[new t(n[0],function*(){for(let e of s)e[0]&&(yield e[0])}),void 0]:[void 0,n[1]]}function d(e,t){return new a({type:e,schema:null,validator:t})}e.s(["any",0,function(){return d("any",()=>!0)},"array",0,function(e){return new a({type:"array",schema:e,*entries(t){if(e&&Array.isArray(t))for(let[r,i]of t.entries())yield[r,i,e]},coercer:e=>Array.isArray(e)?e.slice():e,validator:e=>Array.isArray(e)||`Expected an array value, but received: ${s(e)}`})},"assert",0,l,"boolean",0,function(){return d("boolean",e=>"boolean"==typeof e)},"coerce",0,function(e,t,r){return new a({...e,coercer:(i,s)=>u(i,t)[0]?e.coercer(i,s):e.coercer(r(i,s),s)})},"create",0,c,"instance",0,function(e){return d("instance",t=>t instanceof e||`Expected a \`${e.name}\` instance, but received: ${s(t)}`)},"literal",0,function(e){let t=s(e),r=typeof e;return new a({type:"literal",schema:"string"===r||"number"===r||"boolean"===r?e:null,validator:r=>r===e||`Expected the literal \`${t}\`, but received: ${s(r)}`})},"nullable",0,function(e){return new a({...e,validator:(t,r)=>null===t||e.validator(t,r),refiner:(t,r)=>null===t||e.refiner(t,r)})},"number",0,function(){return d("number",e=>"number"==typeof e&&!isNaN(e)||`Expected a number, but received: ${s(e)}`)},"optional",0,function(e){return new a({...e,validator:(t,r)=>void 0===t||e.validator(t,r),refiner:(t,r)=>void 0===t||e.refiner(t,r)})},"record",0,function(e,t){return new a({type:"record",schema:null,*entries(i){if(r(i))for(let r in i){let s=i[r];yield[r,r,e],yield[r,s,t]}},validator:e=>i(e)||`Expected an object, but received: ${s(e)}`,coercer:e=>i(e)?{...e}:e})},"string",0,function(){return d("string",e=>"string"==typeof e||`Expected a string, but received: ${s(e)}`)},"tuple",0,function(e){let t=d("never",()=>!1);return new a({type:"tuple",schema:null,*entries(r){if(Array.isArray(r)){let i=Math.max(e.length,r.length);for(let s=0;s<i;s++)yield[s,r[s],e[s]||t]}},validator:e=>Array.isArray(e)||`Expected an array, but received: ${s(e)}`,coercer:e=>Array.isArray(e)?e.slice():e})},"type",0,function(e){let t=Object.keys(e);return new a({type:"type",schema:e,*entries(i){if(r(i))for(let r of t)yield[r,i[r],e[r]]},validator:e=>i(e)||`Expected an object, but received: ${s(e)}`,coercer:e=>i(e)?{...e}:e})},"union",0,function(e){let t=e.map(e=>e.type).join(" | ");return new a({type:"union",schema:null,coercer(t,r){for(let i of e){let[e,s]=i.validate(t,{coerce:!0,mask:r.mask});if(!e)return s}return t},validator(r,i){let n=[];for(let t of e){let[...e]=o(r,t,i),[s]=e;if(!s[0])return[];for(let[t]of e)t&&n.push(t)}return[`Expected the value to satisfy a union of \`${t}\`, but received: ${s(r)}`,...n]}})},"unknown",0,function(){return d("unknown",()=>!0)}])},448675,e=>{"use strict";e.s([])},2884,e=>{"use strict";var t,r=new Uint8Array(16);e.s(["default",0,function(){if(!t&&!(t="u">typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"u">typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return t(r)}])},941676,e=>{"use strict";e.s(["default",0,/^(?:[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])},926040,e=>{"use strict";var t=e.i(941676);e.s(["default",0,function(e){return"string"==typeof e&&t.default.test(e)}])},748721,e=>{"use strict";for(var t=e.i(926040),r=[],i=0;i<256;++i)r.push((i+256).toString(16).substr(1));e.s(["default",0,function(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,s=(r[e[i+0]]+r[e[i+1]]+r[e[i+2]]+r[e[i+3]]+"-"+r[e[i+4]]+r[e[i+5]]+"-"+r[e[i+6]]+r[e[i+7]]+"-"+r[e[i+8]]+r[e[i+9]]+"-"+r[e[i+10]]+r[e[i+11]]+r[e[i+12]]+r[e[i+13]]+r[e[i+14]]+r[e[i+15]]).toLowerCase();if(!(0,t.default)(s))throw TypeError("Stringified UUID is invali
1d");return s}])},405002,e=>{"use strict";var t,r,i=e.i(2884),s=e.i(748721),n=0,o=0;e.s(["default",0,function(e,a,l){var c=a&&l||0,u=a||Array(16),d=(e=e||{}).node||t,h=void 0!==e.clockseq?e.clockseq:r;if(null==d||null==h){var f=e.random||(e.rng||i.default)();null==d&&(d=t=[1|f[0],f[1],f[2],f[3],f[4],f[5]]),null==h&&(h=r=(f[6]<<8|f[7])&16383)}var p=void 0!==e.msecs?e.msecs:Date.now(),g=void 0!==e.nsecs?e.nsecs:o+1,y=p-n+(g-o)/1e4;if(y<0&&void 0===e.clockseq&&(h=h+1&16383),(y<0||p>n)&&void 0===e.nsecs&&(g=0),g>=1e4)throw Error("uuid.v1(): Can't create more than 10M uuids/sec");n=p,o=g,r=h;var m=((0xfffffff&(p+=122192928e5))*1e4+g)%0x100000000;u[c++]=m>>>24&255,u[c++]=m>>>16&255,u[c++]=m>>>8&255,u[c++]=255&m;var b=p/0x100000000*1e4&0xfffffff;u[c++]=b>>>8&255,u[c++]=255&b,u[c++]=b>>>24&15|16,u[c++]=b>>>16&255,u[c++]=h>>>8|128,u[c++]=255&h;for(var v=0;v<6;++v)u[c+v]=d[v];return a||(0,s.default)(u)}])},85360,e=>{"use strict";var t=e.i(926040);e.s(["default",0,function(e){if(!(0,t.default)(e))throw TypeError("Invalid UUID");var r,i=new Uint8Array(16);return i[0]=(r=parseInt(e.slice(0,8),16))>>>24,i[1]=r>>>16&255,i[2]=r>>>8&255,i[3]=255&r,i[4]=(r=parseInt(e.slice(9,13),16))>>>8,i[5]=255&r,i[6]=(r=parseInt(e.slice(14,18),16))>>>8,i[7]=255&r,i[8]=(r=parseInt(e.slice(19,23),16))>>>8,i[9]=255&r,i[10]=(r=parseInt(e.slice(24,36),16))/0x10000000000&255,i[11]=r/0x100000000&255,i[12]=r>>>24&255,i[13]=r>>>16&255,i[14]=r>>>8&255,i[15]=255&r,i}])},541733,e=>{"use strict";var t=e.i(748721),r=e.i(85360);e.s(["default",0,function(e,i,s){function n(e,n,o,a){if("string"==typeof e&&(e=function(e){e=unescape(encodeURIComponent(e));for(var t=[],r=0;r<e.length;++r)t.push(e.charCodeAt(r));return t}(e)),"string"==typeof n&&(n=(0,r.default)(n)),16!==n.length)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var l=new Uint8Array(16+e.length);if(l.set(n),l.set(e,n.length),(l=s(l))[6]=15&l[6]|i,l[8]=63&l[8]|128,o){a=a||0;for(var c=0;c<16;++c)o[a+c]=l[c];return o}return(0,t.default)(l)}try{n.name=e}catch(e){}return n.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",n.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8",n}])},367263,e=>{"use strict";function t(e){return(e+64>>>9<<4)+14+1}function r(e,t){var r=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(r>>16)<<16|65535&r}function i(e,t,i,s,n,o){var a;return r((a=r(r(t,e),r(s,o)))<<n|a>>>32-n,i)}function s(e,t,r,s,n,o,a){return i(t&r|~t&s,e,t,n,o,a)}function n(e,t,r,s,n,o,a){return i(t&s|r&~s,e,t,n,o,a)}function o(e,t,r,s,n,o,a){return i(t^r^s,e,t,n,o,a)}function a(e,t,r,s,n,o,a){return i(r^(t|~s),e,t,n,o,a)}e.s(["default",0,function(e){if("string"==typeof e){var i=unescape(encodeURIComponent(e));e=new Uint8Array(i.length);for(var l=0;l<i.length;++l)e[l]=i.charCodeAt(l)}return function(e){for(var t=[],r=32*e.length,i="0123456789abcdef",s=0;s<r;s+=8){var n=e[s>>5]>>>s%32&255,o=parseInt(i.charAt(n>>>4&15)+i.charAt(15&n),16);t.push(o)}return t}(function(e,i){e[i>>5]|=128<<i%32,e[t(i)-1]=i;for(var l=0x67452301,c=-0x10325477,u=-0x67452302,d=0x10325476,h=0;h<e.length;h+=16){var f=l,p=c,g=u,y=d;l=s(l,c,u,d,e[h],7,-0x28955b88),d=s(d,l,c,u,e[h+1],12,-0x173848aa),u=s(u,d,l,c,e[h+2],17,0x242070db),c=s(c,u,d,l,e[h+3],22,-0x3e423112),l=s(l,c,u,d,e[h+4],7,-0xa83f051),d=s(d,l,c,u,e[h+5],12,0x4787c62a),u=s(u,d,l,c,e[h+6],17,-0x57cfb9ed),c=s(c,u,d,l,e[h+7],22,-0x2b96aff),l=s(l,c,u,d,e[h+8],7,0x698098d8),d=s(d,l,c,u,e[h+9],12,-0x74bb0851),u=s(u,d,l,c,e[h+10],17,-42063),c=s(c,u,d,l,e[h+11],22,-0x76a32842),l=s(l,c,u,d,e[h+12],7,0x6b901122),d=s(d,l,c,u,e[h+13],12,-0x2678e6d),u=s(u,d,l,c,e[h+14],17,-0x5986bc72),c=s(c,u,d,l,e[h+15],22,0x49b40821),l=n(l,c,u,d,e[h+1],5,-0x9e1da9e),d=n(d,l,c,u,e[h+6],9,-0x3fbf4cc0),u=n(u,d,l,c,e[h+11],14,0x265e5a51),c=n(c,u,d,l,e[h],20,-0x16493856),l=n(l,c,u,d,e[h+5],5,-0x29d0efa3),d=n(d,l,c,u,e[h+10],9,0x2441453),u=n(u,d,l,c,e[h+15],14,-0x275e197f),c=n(c,u,d,l,e[h+4],20,-0x182c0438),l=n(l,c,u,d,e[h+9],5,0x21e1cde6),d=n(d,l,c,u,e[h+14],9,-0x3cc8f82a),u=n(u,d,l,c,e[h+3],14,-0xb2af279),c=n(c,u,d,l,e[h+8],20,0x455a14ed),l=n(l,c,u,d,e[h+13],5,-0x561c16fb),d=n(d,l,c,u,e[h+2],9,-0x3105c08),u=n(u,d,l,c,e[h+7],14,0x676f02d9),c=n(c,u,d,l,e[h+12],20,-0x72d5b376),l=o(l,c,u,d,e[h+5],4,-378558),d=o(d,l,c,u,e[h+8],11,-0x788e097f),u=o(u,d,l,c,e[h+11],16,0x6d9d6122),c=o(c,u,d,l,e[h+14],23,-0x21ac7f4),l=o(l,c,u,d,e[h+1],4,-0x5b4115bc),d=o(d,l,c,u,e[h+4],11,0x4bdecfa9),u=o(u,d,l,c,e[h+7],16,-0x944b4a0),c=o(c,u,d,l,e[h+10],23,-0x41404390),l=o(l,c,u,d,e[h+13],4,0x289b7ec6),d=o(d,l,c,u,e[h],11,-0x155ed806),u=o(u,d,l,c,e[h+3],16,-0x2b10cf7b),c=o(c,u,d,l,e[h+6],23,0x4881d05
1),l=o(l,c,u,d,e[h+9],4,-0x262b2fc7),d=o(d,l,c,u,e[h+12],11,-0x1924661b),u=o(u,d,l,c,e[h+15],16,0x1fa27cf8),c=o(c,u,d,l,e[h+2],23,-0x3b53a99b),l=a(l,c,u,d,e[h],6,-0xbd6ddbc),d=a(d,l,c,u,e[h+7],10,0x432aff97),u=a(u,d,l,c,e[h+14],15,-0x546bdc59),c=a(c,u,d,l,e[h+5],21,-0x36c5fc7),l=a(l,c,u,d,e[h+12],6,0x655b59c3),d=a(d,l,c,u,e[h+3],10,-0x70f3336e),u=a(u,d,l,c,e[h+10],15,-1051523),c=a(c,u,d,l,e[h+1],21,-0x7a7ba22f),l=a(l,c,u,d,e[h+8],6,0x6fa87e4f),d=a(d,l,c,u,e[h+15],10,-0x1d31920),u=a(u,d,l,c,e[h+6],15,-0x5cfebcec),c=a(c,u,d,l,e[h+13],21,0x4e0811a1),l=a(l,c,u,d,e[h+4],6,-0x8ac817e),d=a(d,l,c,u,e[h+11],10,-0x42c50dcb),u=a(u,d,l,c,e[h+2],15,0x2ad7d2bb),c=a(c,u,d,l,e[h+9],21,-0x14792c6f),l=r(l,f),c=r(c,p),u=r(u,g),d=r(d,y)}return[l,c,u,d]}(function(e){if(0===e.length)return[];for(var r=8*e.length,i=new Uint32Array(t(r)),s=0;s<r;s+=8)i[s>>5]|=(255&e[s/8])<<s%32;return i}(e),8*e.length))}])},64409,e=>{"use strict";var t=e.i(541733),r=e.i(367263),i=(0,t.default)("v3",48,r.default);e.s(["default",0,i])},535612,e=>{"use strict";var t=e.i(2884),r=e.i(748721);e.s(["default",0,function(e,i,s){var n=(e=e||{}).random||(e.rng||t.default)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,i){s=s||0;for(var o=0;o<16;++o)i[s+o]=n[o];return i}return(0,r.default)(n)}])},609140,e=>{"use strict";function t(e,t){return e<<t|e>>>32-t}e.s(["default",0,function(e){var r=[0x5a827999,0x6ed9eba1,0x8f1bbcdc,0xca62c1d6],i=[0x67452301,0xefcdab89,0x98badcfe,0x10325476,0xc3d2e1f0];if("string"==typeof e){var s=unescape(encodeURIComponent(e));e=[];for(var n=0;n<s.length;++n)e.push(s.charCodeAt(n))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);for(var o=Math.ceil((e.length/4+2)/16),a=Array(o),l=0;l<o;++l){for(var c=new Uint32Array(16),u=0;u<16;++u)c[u]=e[64*l+4*u]<<24|e[64*l+4*u+1]<<16|e[64*l+4*u+2]<<8|e[64*l+4*u+3];a[l]=c}a[o-1][14]=(e.length-1)*8/0x100000000,a[o-1][14]=Math.floor(a[o-1][14]),a[o-1][15]=(e.length-1)*8|0;for(var d=0;d<o;++d){for(var h=new Uint32Array(80),f=0;f<16;++f)h[f]=a[d][f];for(var p=16;p<80;++p)h[p]=t(h[p-3]^h[p-8]^h[p-14]^h[p-16],1);for(var g=i[0],y=i[1],m=i[2],b=i[3],v=i[4],w=0;w<80;++w){var _=Math.floor(w/20),S=t(g,5)+function(e,t,r,i){switch(e){case 0:return t&r^~t&i;case 1:case 3:return t^r^i;case 2:return t&r^t&i^r&i}}(_,y,m,b)+v+r[_]+h[w]>>>0;v=b,b=m,m=t(y,30)>>>0,y=g,g=S}i[0]=i[0]+g>>>0,i[1]=i[1]+y>>>0,i[2]=i[2]+m>>>0,i[3]=i[3]+b>>>0,i[4]=i[4]+v>>>0}return[i[0]>>24&255,i[0]>>16&255,i[0]>>8&255,255&i[0],i[1]>>24&255,i[1]>>16&255,i[1]>>8&255,255&i[1],i[2]>>24&255,i[2]>>16&255,i[2]>>8&255,255&i[2],i[3]>>24&255,i[3]>>16&255,i[3]>>8&255,255&i[3],i[4]>>24&255,i[4]>>16&255,i[4]>>8&255,255&i[4]]}])},761134,e=>{"use strict";var t=e.i(541733),r=e.i(609140),i=(0,t.default)("v5",80,r.default);e.s(["default",0,i])},312280,e=>{"use strict";e.s(["default",0,"00000000-0000-0000-0000-000000000000"])},597675,e=>{"use strict";var t=e.i(926040);e.s(["default",0,function(e){if(!(0,t.default)(e))throw TypeError("Invalid UUID");return parseInt(e.substr(14,1),16)}])},719679,e=>{"use strict";e.i(448675);var t=e.i(405002),r=e.i(64409),i=e.i(535612),s=e.i(761134),n=e.i(312280),o=e.i(597675),a=e.i(926040),l=e.i(748721),c=e.i(85360);e.s(["NIL",()=>n.default,"parse",()=>c.default,"stringify",()=>l.default,"v1",()=>t.default,"v3",()=>r.default,"v4",()=>i.default,"v5",()=>s.default,"validate",()=>a.default,"version",()=>o.default])},943173,(e,t,r)=>{"use strict";let i=e.r(719679).v4;t.exports=function(e,t,r,s){if("string"!=typeof e)throw TypeError(e+" must be a string");let n="number"==typeof(s=s||{}).version?s.version:2;if(1!==n&&2!==n)throw TypeError(n+" must be 1 or 2");let o={method:e};if(2===n&&(o.jsonrpc="2.0"),t){if("object"!=typeof t&&!Array.isArray(t))throw TypeError(t+" must be an object, array or omitted");o.params=t}return void 0===r?o.id=("function"==typeof s.generator?s.generator:function(){return i()})(o,s):2===n&&null===r?s.notificationIdNull&&(o.id=null):o.id=r,o}},92113,(e,t,r)=>{"use strict";let i=e.r(719679).v4,s=e.r(943173),n=function(e,t){if(!(this instanceof n))return new n(e,t);t||(t={}),this.options={reviver:void 0!==t.reviver?t.reviver:null,replacer:void 0!==t.replacer?t.replacer:null,generator:void 0!==t.generator?t.generator:function(){return i()},version:void 0!==t.version?t.version:2,notificationIdNull:"boolean"==typeof t.notificationIdNull&&t.notificationIdNull},this.callServer=e};t.exports=n,n.prototype.request=function(e,t,r,i){let n,o=this,a=null,l=Array.isArray(e)&&"function"==typeof t;if(1===this.options.version&&l)throw TypeError("JSON-RPC 1.0 does not support batching");let c=!l&&e&&"object"==typeof e&&"function"==typeof t;if(l||c)i=t,a=e;else{"function"==typeof r&&(i=r,r=void 0);let n="function"==typeof i;try{a=s(e,t,r,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(e){if(n)return i(e);throw e}if(!n)return a}try{n=JSON.stringify(a,this.options.replacer)}catch(e){return i(e)}return this.callServer(n,function(e,t){o._parseResponse(e,t,i)}),a},n.prototype._parseResponse=function(e,t,r){let i;if(e)return void r(e);if(!t)return r();try{i=JSON.parse(t,this.options.reviver)}catch(e){return r(e)}
1if(3===r.length)if(!Array.isArray(i))return r(null,i.error,i.result);else{let e=function(e){return void 0!==e.error};return r(null,i.filter(e),i.filter(function(t){return!e(t)}))}r(null,i)}},12920,e=>{"use strict";var t=e.i(843943);e.i(595932);var r=e.i(87246),i=class extends r.EventEmitter{socket;constructor(e,t,r){super(),this.socket=new window.WebSocket(e,r),this.socket.onopen=()=>this.emit("open"),this.socket.onmessage=e=>this.emit("message",e.data),this.socket.onerror=e=>this.emit("error",e),this.socket.onclose=e=>{this.emit("close",e.code,e.reason)}}send(e,t,r){let i=r||t;try{this.socket.send(e),i()}catch(e){i(e)}}close(e,t){this.socket.close(e,t)}addEventListener(e,t,r){this.socket.addEventListener(e,t,r)}},s=class{encode(e){return JSON.stringify(e)}decode(e){return JSON.parse(e)}},n=class extends r.EventEmitter{address;rpc_id;queue;options;autoconnect;ready;reconnect;reconnect_timer_id;reconnect_interval;max_reconnects;rest_options;current_reconnects;generate_request_id;socket;webSocketFactory;dataPack;constructor(e,t="ws://localhost:8080",{autoconnect:r=!0,reconnect:i=!0,reconnect_interval:n=1e3,max_reconnects:o=5,...a}={},l,c){super(),this.webSocketFactory=e,this.queue={},this.rpc_id=0,this.address=t,this.autoconnect=r,this.ready=!1,this.reconnect=i,this.reconnect_timer_id=void 0,this.reconnect_interval=n,this.max_reconnects=o,this.rest_options=a,this.current_reconnects=0,this.generate_request_id=l||(()=>"number"==typeof this.rpc_id?++this.rpc_id:Number(this.rpc_id)+1),c?this.dataPack=c:this.dataPack=new s,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})}
vendor: 2,550 bytes, line 1
1call(e,t,r,i){return i||"object"!=typeof r||(i=r,r=null),new Promise((s,n)=>{if(!this.ready)return n(Error("socket not ready"));let o=this.generate_request_id(e,t);this.socket.send(this.dataPack.encode({jsonrpc:"2.0",method:e,params:t||void 0,id:o}),i,e=>{if(e)return n(e);this.queue[o]={promise:[s,n]},r&&(this.queue[o].timeout=setTimeout(()=>{delete this.queue[o],n(Error("reply timeout"))},r))})})}async login(e){let t=await this.call("rpc.login",e);if(!t)throw Error("authentication failed");return t}async listMethods(){return await this.call("__listMethods")}notify(e,t){return new Promise((r,i)=>{if(!this.ready)return i(Error("socket not ready"));this.socket.send(this.dataPack.encode({jsonrpc:"2.0",method:e,params:t}),e=>{if(e)return i(e);r()})})}async subscribe(e){"string"==typeof e&&(e=[e]);let t=await this.call("rpc.on",e);if("string"==typeof e&&"ok"!==t[e])throw Error("Failed subscribing to an event '"+e+"' with: "+t[e]);return t}async unsubscribe(e){"string"==typeof e&&(e=[e]);let t=await this.call("rpc.off",e);if("string"==typeof e&&"ok"!==t[e])throw Error("Failed unsubscribing from an event with: "+t);return t}close(e,t){this.socket.close(e||1e3,t)}setAutoReconnect(e){this.reconnect=e}setReconnectInterval(e){this.reconnect_interval=e}setMaxReconnects(e){this.max_reconnects=e}_connect(e,r){clearTimeout(this.reconnect_timer_id),this.socket=this.webSocketFactory(e,r),this.socket.addEventListener("open",()=>{this.ready=!0,this.emit("open"),this.current_reconnects=0}),this.socket.addEventListener("message",({data:e})=>{e instanceof ArrayBuffer&&(e=t.Buffer.from(e).toString());try{e=this.dataPack.decode(e)}catch(e){return}if(e.notification&&this.listeners(e.notification).length){if(!Object.keys(e.params).length)return this.emit(e.notification);let t=[e.notification];if(e.params.constructor===Object)t.push(e.params);else for(let r=0;r<e.params.length;r++)t.push(e.params[r]);return Promise.resolve().then(()=>{this.emit.apply(this,t)})}if(!this.queue[e.id])return e.method?Promise.resolve().then(()=>{this.emit(e.method,e?.params)}):void 0;"error"in e=="result"in e&&this.queue[e.id].promise[1](Error('Server response malformed. Response must include either "result" or "error", but not both.')),this.queue[e.id].timeout&&clearTimeout(this.queue[e.id].timeout),e.error?this.queue[e.id].promise[1](e.error):this.queue[e.id].promise[0](e.result),delete this.queue[e.id]}),this.socket.addEventListener("error",e=>this.emit("error",e)),this.socket.addEventListener("close",({code:t,reason:i})=>{this.ready&&setTimeout(()=>
1this.emit("close",t,i),0),this.ready=!1,this.socket=void 0,1e3!==t&&(this.current_reconnects++,this.reconnect&&(this.max_reconnects>this.current_reconnects||0===this.max_reconnects)&&(this.reconnect_timer_id=setTimeout(()=>this._connect(e,r),this.reconnect_interval)))})}};e.s(["CommonClient",0,n,"WebSocket",0,function(e,t){return new i(e,t)}])},127261,e=>{"use strict";var t,r,i,s,n=e.i(843943),o=e.i(214303),a=e.i(659341),l=e.i(635030),c=e.i(280355),u=e.i(154119),d=e.i(444610),h=e.i(640512),f=e.i(685098),p=e.i(92113),g=e.i(12920),y=e.i(145535),m=e.i(776267);o.ed25519.utils.randomPrivateKey;let b=()=>{let e=o.ed25519.utils.randomPrivateKey(),t=v(e),r=new Uint8Array(64);return r.set(e),r.set(t,32),{publicKey:t,secretKey:r}},v=o.ed25519.getPublicKey;function w(e){try{return o.ed25519.ExtendedPoint.fromHex(e),!0}catch{return!1}}let _=(e,t)=>o.ed25519.sign(e,t.slice(0,32)),S=o.ed25519.verify,E=e=>n.Buffer.isBuffer(e)?e:e instanceof Uint8Array?n.Buffer.from(e.buffer,e.byteOffset,e.byteLength):n.Buffer.from(e);class I{constructor(e){Object.assign(this,e)}encode(){return n.Buffer.from((0,u.serialize)(A,this))}static decode(e){return(0,u.deserialize)(A,this,e)}static decodeUnchecked(e){return(0,u.deserializeUnchecked)(A,this,e)}}let A=new Map,T=1;class x extends I{constructor(e){if(super({}),this._bn=void 0,function(e){return void 0!==e._bn}(e))this._bn=e._bn;else{if("string"==typeof e){const t=l.default.decode(e);if(32!=t.length)throw Error("Invalid public key input");this._bn=new a.default(t)}else this._bn=new a.default(e);if(this._bn.byteLength()>32)throw Error("Invalid public key input")}}static unique(){let e=new x(T);return T+=1,new x(e.toBuffer())}equals(e){return this._bn.eq(e._bn)}toBase58(){return l.default.encode(this.toBytes())}toJSON(){return this.toBase58()}toBytes(){let e=this.toBuffer();return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}toBuffer(){let e=this._bn.toArrayLike(n.Buffer);if(32===e.length)return e;let t=n.Buffer.alloc(32);return e.copy(t,32-e.length),t}get[Symbol.toStringTag](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(e,t,r){let i=n.Buffer.concat([e.toBuffer(),n.Buffer.from(t),r.toBuffer()]);return new x((0,c.sha256)(i))}static createProgramAddressSync(e,t){let r=n.Buffer.alloc(0);e.forEach(function(e){if(e.length>32)throw TypeError("Max seed length exceeded");r=n.Buffer.concat([r,E(e)])}),r=n.Buffer.concat([r,t.toBuffer(),n.Buffer.from("ProgramDerivedAddress")]);let i=(0,c.sha256)(r);if(w(i))throw Error("Invalid seeds, address must fall off the curve");return new x(i)}static async createProgramAddress(e,t){return this.createProgramAddressSync(e,t)}static findProgramAddressSync(e,t){let r,i=255;for(;0!=i;){try{let s=e.concat(n.Buffer.from([i]));r=this.createProgramAddressSync(s,t)}catch(e){if(e instanceof TypeError)throw e;i--;continue}return[r,i]}throw Error("Unable to find a viable program address nonce")}static async findProgramAddress(e,t){return this.findProgramAddressSync(e,t)}static isOnCurve(e){return w(new x(e).toBytes())}}x.default=new x("11111111111111111111111111111111"),A.set(x,{kind:"struct",fields:[["_bn","u256"]]}),new x("BPFLoader1111111111111111111111111111111111");class k extends Error{constructor(e){super(`Signature ${e} has expired: block height exceeded.`),this.signature=void 0,this.signature=e}}Object.defineProperty(k.prototype,"name",{value:"TransactionExpiredBlockheightExceededError"});class P extends Error{constructor(e,t){super(`Transaction was not confirmed in ${t.toFixed(2)} seconds. It is unknown if it succeeded or failed. Check signature ${e} using the Solana Explorer or CLI tools.`),this.signature=void 0,this.signature=e}}Object.defineProperty(P.prototype,"name",{value:"TransactionExpiredTimeoutError"});class O extends Error{constructor(e){super(`Signature ${e} has expired: the nonce is no longer valid.`),this.signature=void 0,this.signature=e}}Object.defineProperty(O.prototype,"name",{value:"TransactionExpiredNonceInvalidError"});class R{constructor(e,t){this.staticAccountKeys=void 0,this.accountKeysFromLookups=void 0,this.staticAccountKeys=e,this.accountKeysFromLookups=t}keySegments(){let e=[this.staticAccountKeys];return this.accountKeysFromLookups&&(e.push(this.accountKeysFromLookups.writable),e.push(this.accountKeysFromLookups.readonly)),e}get(e){for(let t of this.keySegments())if(e<t.length)return t[e];else e-=t.length}get length(){return this.keySegments().flat().length}compileInstructions(e){if(this.length>256)throw Error("Account index overflow encountered during compilation");let t=new Map;
vendor: 18,066 bytes, line 1
1this.keySegments().flat().forEach((e,r)=>{t.set(e.toBase58(),r)});let r=e=>{let r=t.get(e.toBase58());if(void 0===r)throw Error("Encountered an unknown instruction account key during compilation");return r};return e.map(e=>({programIdIndex:r(e.programId),accountKeyIndexes:e.keys.map(e=>r(e.pubkey)),data:e.data}))}}let C=(e="publicKey")=>d.blob(32,e),N=(e="string")=>{let t=d.struct([d.u32("length"),d.u32("lengthPadding"),d.blob(d.offset(d.u32(),-8),"chars")],e),r=t.decode.bind(t),i=t.encode.bind(t);return t.decode=(e,t)=>r(e,t).chars.toString(),t.encode=(e,t,r)=>i({chars:n.Buffer.from(e,"utf8")},t,r),t.alloc=e=>d.u32().span+d.u32().span+n.Buffer.from(e,"utf8").length,t};function B(e){let t=0,r=0;for(;;){let i=e.shift();if(t|=(127&i)<<7*r,r+=1,(128&i)==0)break}return t}function U(e,t){let r=t;for(;;){let t=127&r;if(0==(r>>=7)){e.push(t);break}t|=128,e.push(t)}}function q(e,t){if(!e)throw Error(t||"Assertion failed")}class L{constructor(e,t){this.payer=void 0,this.keyMetaMap=void 0,this.payer=e,this.keyMetaMap=t}static compile(e,t){let r=new Map,i=e=>{let t=e.toBase58(),i=r.get(t);return void 0===i&&(i={isSigner:!1,isWritable:!1,isInvoked:!1},r.set(t,i)),i},s=i(t);for(let t of(s.isSigner=!0,s.isWritable=!0,e))for(let e of(i(t.programId).isInvoked=!0,t.keys)){let t=i(e.pubkey);t.isSigner||=e.isSigner,t.isWritable||=e.isWritable}return new L(t,r)}getMessageComponents(){let e=[...this.keyMetaMap.entries()];q(e.length<=256,"Max static account keys length exceeded");let t=e.filter(([,e])=>e.isSigner&&e.isWritable),r=e.filter(([,e])=>e.isSigner&&!e.isWritable),i=e.filter(([,e])=>!e.isSigner&&e.isWritable),s=e.filter(([,e])=>!e.isSigner&&!e.isWritable),n={numRequiredSignatures:t.length+r.length,numReadonlySignedAccounts:r.length,numReadonlyUnsignedAccounts:s.length};{q(t.length>0,"Expected at least one writable signer key");let[e]=t[0];q(e===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}return[n,[...t.map(([e])=>new x(e)),...r.map(([e])=>new x(e)),...i.map(([e])=>new x(e)),...s.map(([e])=>new x(e))]]}extractTableLookup(e){let[t,r]=this.drainKeysFoundInLookupTable(e.state.addresses,e=>!e.isSigner&&!e.isInvoked&&e.isWritable),[i,s]=this.drainKeysFoundInLookupTable(e.state.addresses,e=>!e.isSigner&&!e.isInvoked&&!e.isWritable);if(0!==t.length||0!==i.length)return[{accountKey:e.key,writableIndexes:t,readonlyIndexes:i},{writable:r,readonly:s}]}drainKeysFoundInLookupTable(e,t){let r=[],i=[];for(let[s,n]of this.keyMetaMap.entries())if(t(n)){let t=new x(s),n=e.findIndex(e=>e.equals(t));n>=0&&(q(n<256,"Max lookup table index exceeded"),r.push(n),i.push(t),this.keyMetaMap.delete(s))}return[r,i]}}let D="Reached end of buffer unexpectedly";function M(e){if(0===e.length)throw Error(D);return e.shift()}function K(e,...t){let[r]=t;if(2===t.length?r+(t[1]??0)>e.length:r>=e.length)throw Error(D);return e.splice(...t)}class W{constructor(e){this.header=void 0,this.accountKeys=void 0,this.recentBlockhash=void 0,this.instructions=void 0,this.indexToProgramIds=new Map,this.header=e.header,this.accountKeys=e.accountKeys.map(e=>new x(e)),this.recentBlockhash=e.recentBlockhash,this.instructions=e.instructions,this.instructions.forEach(e=>this.indexToProgramIds.set(e.programIdIndex,this.accountKeys[e.programIdIndex]))}get version(){return"legacy"}get staticAccountKeys(){return this.accountKeys}get compiledInstructions(){return this.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:l.default.decode(e.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new R(this.staticAccountKeys)}static compile(e){let[t,r]=L.compile(e.instructions,e.payerKey).getMessageComponents(),i=new R(r).compileInstructions(e.instructions).map(e=>({programIdIndex:e.programIdIndex,accounts:e.accountKeyIndexes,data:l.default.encode(e.data)}));return new W({header:t,accountKeys:r,recentBlockhash:e.recentBlockhash,instructions:i})}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){let t=this.header.numRequiredSignatures;if(!(e>=this.header.numRequiredSignatures))return e<t-this.header.numReadonlySignedAccounts;{let r=this.accountKeys.length-t-this.header.numReadonlyUnsignedAccounts;return e-t<r}}isProgramId(e){return this.indexToProgramIds.has(e)}programIds(){return[...this.indexToProgramIds.values()]}nonProgramIds(){return this.accountKeys.filter((e,t)=>!this.isProgramId(t))}serialize(){let e=this.accountKeys.length,t=[];U(t,e);let r=this.instructions.map(e=>{let{accounts:t,programIdIndex:r}=e,i=Array.from(l.default.decode(e.data)),s=[];U(s,t.length);let o=[];return U(o,i.length),{programIdIndex:r,keyIndicesCount:n.Buffer.from(s),keyIndices:t,dataLength:n.Buffer.from(o),data:i}}),i=[];U(i,r.length);let s=n.Buffer.alloc(1232);n.Buffer.from(i).copy(s);let o=i.length;r.forEach(e=>{let t=d.struct([d.u8("programIdIndex"),d.blob(e.keyIndicesCount.length,"keyIndicesCount"),d.seq(d.u8("keyIndex"),e.keyIndices.length,"keyIndices"),d.blob(e.dataLength.length,"dataLength"),d.seq(d.u8("userdatum"),e.data.length,"data")]).encode(e,s,o);o+=t}),s=s.slice(0,o);let a=d.struct([d.blob(1,"numRequiredSignatures"),d.blob(1,"numReadonlySignedAccounts"),d.blob(1,"numReadonlyUnsignedAccounts"),d.blob(t.length,"keyCount"),d.seq(C("key"),e,"keys"),C("recentBlockhash")]),c={numRequiredSignatures:n.Buffer.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:n.Buffer.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:n.Buffer.from([this.header.numReadonlyUnsignedAccounts]),keyCount:n.Buffer.from(t),keys:this.accountKeys.map(e=>E(e.toBytes())),recentBlockhash:l.default.decode(this.recentBlockhash)},u=n.Buffer.alloc(2048),h=a.encode(c,u);return s.copy(u,h),u.slice(0,h+s.length)}static from(e){let t=[...e],r=M(t);if(r!==(127&r))throw Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");let i=M(t),s=M(t),o=B(t),a=[];for(let e=0;e<o;e++){let e=K(t,0,32);a.push(new x(n.Buffer.from(e)))}let c=K(t,0,32),u=B(t),d=[];for(let e=0;e<u;e++){let e=M(t),r=B(t),i=K(t,0,r),s=B(t),o=K(t,0,s),a=l.default.encode(n.Buffer.from(o));d.push({programIdIndex:e,accounts:i,data:a})}return new W({header:{numRequiredSignatures:r,numReadonlySignedAccounts:i,numReadonlyUnsignedAccounts:s},recentBlockhash:l.default.encode(n.Buffer.from(c)),accountKeys:a,instructions:d})}}class z{constructor(e){this.header=void 0,this.staticAccountKeys=void 0,this.recentBlockhash=void 0,this.compiledInstructions=void 0,this.addressTableLookups=void 0,this.header=e.header,this.staticAccountKeys=e.staticAccountKeys,this.recentBlockhash=e.recentBlockhash,this.compiledInstructions=e.compiledInstructions,this.addressTableLookups=e.addressTableLookups}get version(){return 0}get numAccountKeysFromLookups(){let e=0;for(let t of this.addressTableLookups)e+=t.readonlyIndexes.length+t.writableIndexes.length;return e}getAccountKeys(e){let t;if(e&&"accountKeysFromLookups"in e&&e.accountKeysFromLookups){if(this.numAccountKeysFromLookups!=e.accountKeysFromLookups.writable.length+e.accountKeysFromLookups.readonly.length)throw Error("Failed to get account keys because of a mismatch in the number of account keys from lookups");t=e.accountKeysFromLookups}else if(e&&"addressLookupTableAccounts"in e&&e.addressLookupTableAccounts)t=this.resolveAddressTableLookups(e.addressLookupTableAccounts);else if(this.addressTableLookups.length>0)throw Error("Failed to get account keys because address table lookups were not resolved");return new R(this.staticAccountKeys,t)}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){let t=this.header.numRequiredSignatures,r=this.staticAccountKeys.length;if(e>=r)return e-r<this.addressTableLookups.reduce((e,t)=>e+t.writableIndexes.length,0);if(!(e>=this.header.numRequiredSignatures))return e<t-this.header.numReadonlySignedAccounts;{let i=r-t-this.header.numReadonlyUnsignedAccounts;return e-t<i}}resolveAddressTableLookups(e){let t={writable:[],readonly:[]};for(let r of this.addressTableLookups){let i=e.find(e=>e.key.equals(r.accountKey));if(!i)throw Error(`Failed to find address lookup table account for table key ${r.accountKey.toBase58()}`);for(let e of r.writableIndexes)if(e<i.state.addresses.length)t.writable.push(i.state.addresses[e]);else throw Error(`Failed to find address for index ${e} in address lookup table ${r.accountKey.toBase58()}`);for(let e of r.readonlyIndexes)if(e<i.state.addresses.length)t.readonly.push(i.state.addresses[e]);else throw Error(`Failed to find address for index ${e} in address lookup table ${r.accountKey.toBase58()}`)}return t}static compile(e){let t=L.compile(e.instructions,e.payerKey),r=[],i={writable:[],readonly:[]};for(let s of e.addressLookupTableAccounts||[]){let e=t.extractTableLookup(s);if(void 0!==e){let[t,{writable:s,readonly:n}]=e;r.push(t),i.writable.push(...s),i.readonly.push(...n)}}let[s,n]=t.getMessageComponents(),o=new R(n,i).compileInstructions(e.instructions);return new z({header:s,staticAccountKeys:n,recentBlockhash:e.recentBlockhash,compiledInstructions:o,addressTableLookups:r})}serialize(){let e=[];U(e,this.staticAccountKeys.length);let t=this.serializeInstructions(),r=[];U(r,this.compiledInstructions.length);let i=this.serializeAddressTableLookups(),s=[];U(s,this.addressTableLookups.length);let n=d.struct([d.u8("prefix"),d.struct([d.u8("numRequiredSignatures"),d.u8("numReadonlySignedAccounts"),d.u8("numReadonlyUnsignedAccounts")],"header"),d.blob(e.length,"staticAccountKeysLength"),d.seq(C(),this.staticAccountKeys.length,"staticAccountKeys"),C("recentBlockhash"),d.blob(r.length,"instructionsLength"),d.blob(t.length,"serializedInstructions"),d.blob(s.length,"addressTableLookupsLength"),d.blob(i.length,"serializedAddressTableLookups")]),o=new Uint8Array(1232),a=n.encode({prefix:128,header:this.header,staticAccountKeysLength:new Uint8Array(e),staticAccountKeys:this.staticAccountKeys.map(e=>e.toBytes()),recentBlockhash:l.default.decode(this.recentBlockhash),instructionsLength:new Uint8Array(r),serializedInstructions:t,addressTableLookupsLength:new Uint8Array(s),serializedAddressTableLookups:i},o);return o.slice(0,a)}serializeInstructions(){let e=0,t=new Uint8Array(1232);for(let r of this.compiledInstructions){let i=[];U(i,r.accountKeyIndexes.length);let s=[];U(s,r.data.length);let n=d.struct([d.u8("programIdIndex"),d.blob(i.length,"encodedAccountKeyIndexesLength"),d.seq(d.u8(),r.accountKeyIndexes.length,"accountKeyIndexes"),d.blob(s.length,"encodedDataLength"),d.blob(r.data.length,"data")]);e+=n.encode({programIdIndex:r.programIdIndex,encodedAccountKeyIndexesLength:new Uint8Array(i),accountKeyIndexes:r.accountKeyIndexes,encodedDataLength:new Uint8Array(s),data:r.data},t,e)}return t.slice(0,e)}serializeAddressTableLookups(){let e=0,t=new Uint8Array(1232);for(let r of this.addressTableLookups){let i=[];U(i,r.writableIndexes.length);let s=[];U(s,r.readonlyIndexes.length);let n=d.struct([C("accountKey"),d.blob(i.length,"encodedWritableIndexesLength"),d.seq(d.u8(),r.writableIndexes.length,"writableIndexes"),d.blob(s.length,"encodedReadonlyIndexesLength"),d.seq(d.u8(),r.readonlyIndexes.length,"readonlyIndexes")]);e+=n.encode({accountKey:r.accountKey.toBytes(),encodedWritableIndexesLength:new Uint8Array(i),writableIndexes:r.writableIndexes,encodedReadonlyIndexesLength:new Uint8Array(s),readonlyIndexes:r.readonlyIndexes},t,e)}return t.slice(0,e)}static deserialize(e){let t=[...e],r=M(t),i=127&r;q(r!==i,"Expected versioned message but received legacy message"),q(0===i,`Expected versioned message with version 0 but found version ${i}`);let s={numRequiredSignatures:M(t),numReadonlySignedAccounts:M(t),numReadonlyUnsignedAccounts:M(t)},n=[],o=B(t);for(let e=0;e<o;e++)n.push(new x(K(t,0,32)));let a=l.default.encode(K(t,0,32)),c=B(t),u=[];for(let e=0;e<c;e++){let e=M(t),r=B(t),i=K(t,0,r),s=B(t),n=new Uint8Array(K(t,0,s));u.push({programIdIndex:e,accountKeyIndexes:i,data:n})}let d=B(t),h=[];for(let e=0;e<d;e++){let e=new x(K(t,0,32)),r=B(t),i=K(t,0,r),s=B(t),n=K(t,0,s);h.push({accountKey:e,writableIndexes:i,readonlyIndexes:n})}return new z({header:s,staticAccountKeys:n,recentBlockhash:a,compiledInstructions:u,addressTableLookups:h})}}let j={deserializeMessageVersion(e){let t=e[0],r=127&t;return r===t?"legacy":r},deserialize:e=>{let t=j.deserializeMessageVersion(e);if("legacy"===t)return W.from(e);if(0===t)return z.deserialize(e);throw Error(`Transaction message version ${t} deserialization is not supported`)}},V=((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),$=n.Buffer.alloc(64).fill(0);class F{constructor(e){this.keys=void 0,this.programId=void 0,this.data=n.Buffer.alloc(0),this.programId=e.programId,this.keys=e.keys,e.data&&(this.data=e.data)}toJSON(){return{keys:this.keys.map(({pubkey:e,isSigner:t,isWritable:r})=>({pubkey:e.toJSON(),isSigner:t,isWritable:r})),programId:this.programId.toJSON(),data:[...this.data]}}}class H{get signature(){return this.signatures.length>0?this.signatures[0].signature:null}constructor(e){if(this.signatures=[],this.feePayer=void 0,this.instructions=[],this.recentBlockhash=void 0,this.lastValidBlockHeight=void 0,this.nonceInfo=void 0,this.minNonceContextSlot=void 0,this._message=void 0,this._json=void 0,!e)return;if(e.feePayer&&(this.feePayer=e.feePayer),e.signatures&&(this.signatures=e.signatures),Object.prototype.hasOwnProperty.call(e,"nonceInfo")){const{minContextSlot:t,nonceInfo:r}=e;this.minNonceContextSlot=t,this.nonceInfo=r}else if(Object.prototype.hasOwnProperty.call(e,"lastValidBlockHeight")){const{blockhash:t,lastValidBlockHeight:r}=e;this.recentBlockhash=t,this.lastValidBlockHeight=r}else{const{recentBlockhash:t,nonceInfo:r}=e;r&&(this.nonceInfo=r),this.recentBlockhash=t}}toJSON(){return{recentBlockhash:this.recentBlockhash||null,feePayer:this.feePayer?this.feePayer.toJSON():null,nonceInfo:this.nonceInfo?{nonce:this.nonceInfo.nonce,nonceInstruction:this.nonceInfo.nonceInstruction.toJSON()}:null,instructions:this.instructions.map(e=>e.toJSON()),signers:this.signatures.map(({publicKey:e})=>e.toJSON())}}add(...e){if(0===e.length)throw Error("No instructions");return e.forEach(e=>{"instructions"in e?this.instructions=this.instructions.concat(e.instructions):"data"in e&&"programId"in e&&"keys"in e?this.instructions.push(e):this.instructions.push(new F(e))}),this}compileMessage(){let e,t,r;if(this._message&&JSON.stringify(this.toJSON())===JSON.stringify(this._json))return this._message;if(this.nonceInfo?(e=this.nonceInfo.nonce,t=this.instructions[0]!=this.nonceInfo.nonceInstruction?[this.nonceInfo.nonceInstruction,...this.instructions]:this.instructions):(e=this.recentBlockhash,t=this.instructions),!e)throw Error("Transaction recentBlockhash required");if(t.length<1&&console.warn("No instructions provided"),this.feePayer)r=this.feePayer;else if(this.signatures.length>0&&this.signatures[0].publicKey)r=this.signatures[0].publicKey;else throw Error("Transaction fee payer required");for(let e=0;e<t.length;e++)if(void 0===t[e].programId)throw Error(`Transaction instruction index ${e} has undefined program id`);let i=[],s=[];t.forEach(e=>{e.keys.forEach(e=>{s.push({...e})});let t=e.programId.toString();i.includes(t)||i.push(t)}),i.forEach(e=>{s.push({pubkey:new x(e),isSigner:!1,isWritable:!1})});let n=[];s.forEach(e=>{let t=e.pubkey.toString(),r=n.findIndex(e=>e.pubkey.toString()===t);r>-1?(n[r].isWritable=n[r].isWritable||e.isWritable,n[r].isSigner=n[r].isSigner||e.isSigner):n.push(e)}),n.sort(function(e,t){return e.isSigner!==t.isSigner?e.isSigner?-1:1:e.isWritable!==t.isWritable?e.isWritable?-1:1:e.pubkey.toBase58().localeCompare(t.pubkey.toBase58(),"en",{localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"})});let o=n.findIndex(e=>e.pubkey.equals(r));if(o>-1){let[e]=n.splice(o,1);e.isSigner=!0,e.isWritable=!0,n.unshift(e)}else n.unshift({pubkey:r,isSigner:!0,isWritable:!0});for(let e of this.signatures){let t=n.findIndex(t=>t.pubkey.equals(e.publicKey));if(t>-1)n[t].isSigner||(n[t].isSigner=!0,console.warn("Transaction references a signature that is unnecessary, only the fee payer and instruction signer accounts should sign a transaction. This behavior is deprecated and will throw an error in the next major version release."));else throw Error(`unknown signer: ${e.publicKey.toString()}`)}let a=0,c=0,u=0,d=[],h=[];n.forEach(({pubkey:e,isSigner:t,isWritable:r})=>{t?(d.push(e.toString()),a+=1,r||(c+=1)):(h.push(e.toString()),r||(u+=1))});let f=d.concat(h),p=t.map(e=>{let{data:t,programId:r}=e;return{programIdIndex:f.indexOf(r.toString()),accounts:e.keys.map(e=>f.indexOf(e.pubkey.toString())),data:l.default.encode(t)}});return p.forEach(e=>{q(e.programIdIndex>=0),e.accounts.forEach(e=>q(e>=0))}),new W({header:{numRequiredSignatures:a,numReadonlySignedAccounts:c,numReadonlyUnsignedAccounts:u},accountKeys:f,recentBlockhash:e,instructions:p})}_compile(){let e=this.compileMessage(),t=e.accountKeys.slice(0,e.header.numRequiredSignatures);return this.signatures.length===t.length&&this.signatures.every((e,r)=>t[r].equals(e.publicKey))?e:(this.signatures=t.map(e=>({signature:null,publicKey:e})),e)}serializeMessage(){return this._compile().serialize()}async getEstimatedFee(e){return(await e.getFeeForMessage(this.compileMessage())).value}setSigners(...e){if(0===e.length)throw Error("No signers");let t=new Set;this.signatures=e.filter(e=>{let r=e.toString();return!t.has(r)&&(t.add(r),!0)}).map(e=>({signature:null,publicKey:e}))}sign(...e){if(0===e.length)throw Error("No signers");let t=new Set,r=[];for(let i of e){let e=i.publicKey.toString();t.has(e)||(t.add(e),r.push(i))}this.signatures=r.map(e=>({signature:null,publicKey:e.publicKey}));let i=this._compile();this._partialSign(i,...r)}partialSign(...e){if(0===e.length)throw Error("No signers");let t=new Set,r=[];for(let i of e){let e=i.publicKey.toString();t.has(e)||(t.add(e),r.push(i))}let i=this._compile();this._partialSign(i,...r)}_partialSign(e,...t){let r=e.serialize();
1t.forEach(e=>{let t=_(r,e.secretKey);this._addSignature(e.publicKey,E(t))})}addSignature(e,t){this._compile(),this._addSignature(e,t)}_addSignature(e,t){q(64===t.length);let r=this.signatures.findIndex(t=>e.equals(t.publicKey));if(r<0)throw Error(`unknown signer: ${e.toString()}`);this.signatures[r].signature=n.Buffer.from(t)}verifySignatures(e=!0){return!this._getMessageSignednessErrors(this.serializeMessage(),e)}_getMessageSignednessErrors(e,t){let r={};for(let{signature:i,publicKey:s}of this.signatures)null===i?t&&(r.missing||=[]).push(s):S(i,e,s.toBytes())||(r.invalid||=[]).push(s);return r.invalid||r.missing?r:void 0}serialize(e){let{requireAllSignatures:t,verifySignatures:r}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},e),i=this.serializeMessage();if(r){let e=this._getMessageSignednessErrors(i,t);if(e){let t="Signature verification failed.";throw e.invalid&&(t+=`
2Invalid signature for public key${1===e.invalid.length?"":"(s)"} [\`${e.invalid.map(e=>e.toBase58()).join("`, `")}\`].`),e.missing&&(t+=`
3Missing signature for public key${1===e.missing.length?"":"(s)"} [\`${e.missing.map(e=>e.toBase58()).join("`, `")}\`].`),Error(t)}}return this._serialize(i)}_serialize(e){let{signatures:t}=this,r=[];U(r,t.length);let i=r.length+64*t.length+e.length,s=n.Buffer.alloc(i);return q(t.length<256),n.Buffer.from(r).copy(s,0),t.forEach(({signature:e},t)=>{null!==e&&(q(64===e.length,"signature has invalid length"),n.Buffer.from(e).copy(s,r.length+64*t))}),e.copy(s,r.length+64*t.length),q(s.length<=1232,`Transaction too large: ${s.length} > 1232`),s}get keys(){return q(1===this.instructions.length),this.instructions[0].keys.map(e=>e.pubkey)}get programId(){return q(1===this.instructions.length),this.instructions[0].programId}get data(){return q(1===this.instructions.length),this.instructions[0].data}static from(e){let t=[...e],r=B(t),i=[];for(let e=0;e<r;e++){let e=K(t,0,64);i.push(l.default.encode(n.Buffer.from(e)))}return H.populate(W.from(t),i)}static populate(e,t=[]){let r=new H;return r.recentBlockhash=e.recentBlockhash,e.header.numRequiredSignatures>0&&(r.feePayer=e.accountKeys[0]),t.forEach((t,i)=>{let s={signature:t==l.default.encode($)?null:l.default.decode(t),publicKey:e.accountKeys[i]};r.signatures.push(s)}),e.instructions.forEach(t=>{let i=t.accounts.map(t=>{let i=e.accountKeys[t];return{pubkey:i,isSigner:r.signatures.some(e=>e.publicKey.toString()===i.toString())||e.isAccountSigner(t),isWritable:e.isAccountWritable(t)}});r.instructions.push(new F({keys:i,programId:e.accountKeys[t.programIdIndex],data:l.default.decode(t.data)}))}),r._message=e,r._json=r.toJSON(),r}}class G{constructor(e){this.payerKey=void 0,this.instructions=void 0,this.recentBlockhash=void 0,this.payerKey=e.payerKey,this.instructions=e.instructions,this.recentBlockhash=e.recentBlockhash}static decompile(e,t){let{header:r,compiledInstructions:i,recentBlockhash:s}=e,{numRequiredSignatures:n,numReadonlySignedAccounts:o,numReadonlyUnsignedAccounts:a}=r,l=n-o;q(l>0,"Message header is invalid");let c=e.staticAccountKeys.length-n-a;q(c>=0,"Message header is invalid");let u=e.getAccountKeys(t),d=u.get(0);if(void 0===d)throw Error("Failed to decompile message because no account keys were found");let h=[];for(let e of i){let t=[];for(let i of e.accountKeyIndexes){let e,s=u.get(i);if(void 0===s)throw Error(`Failed to find key for account key index ${i}`);e=i<n?i<l:i<u.staticAccountKeys.length?i-n<c:i-u.staticAccountKeys.length<u.accountKeysFromLookups.writable.length,t.push({pubkey:s,isSigner:i<r.numRequiredSignatures,isWritable:e})}let i=u.get(e.programIdIndex);if(void 0===i)throw Error(`Failed to find program id for program id index ${e.programIdIndex}`);h.push(new F({programId:i,data:E(e.data),keys:t}))}return new G({payerKey:d,instructions:h,recentBlockhash:s})}compileToLegacyMessage(){return W.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions})}compileToV0Message(e){return z.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions,addressLookupTableAccounts:e})}}class J{get version(){return this.message.version}constructor(e,t){if(this.signatures=void 0,this.message=void 0,void 0!==t)q(t.length===e.header.numRequiredSignatures,"Expected signatures length to be equal to the number of required signatures"),this.signatures=t;else{const t=[];for(let r=0;r<e.header.numRequiredSignatures;r++)t.push(new Uint8Array(64));this.signatures=t}this.message=e}serialize(){let e=this.message.serialize(),t=[];U(t,this.signatures.length);let r=d.struct([d.blob(t.length,"encodedSignaturesLength"),d.seq(((e="signature")=>d.blob(64,e))(),this.signatures.length,"signatures"),d.blob(e.length,"serializedMessage")]),i=new Uint8Array(2048),s=r.encode({encodedSignaturesLength:new Uint8Array(t),signatures:this.signatures,serializedMessage:e},i);return i.slice(0,s)}static deserialize(e){let t=[...e],r=[],i=B(t);for(let e=0;e<i;e++)r.push(new Uint8Array(K(t,0,64)));
vendor: 16,019 bytes, lines 3-7
3return new J(j.deserialize(new Uint8Array(t)),r)}sign(e){let t=this.message.serialize(),r=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures);for(let i of e){let e=r.findIndex(e=>e.equals(i.publicKey));q(e>=0,`Cannot sign with non signer key ${i.publicKey.toBase58()}`),this.signatures[e]=_(t,i.secretKey)}}addSignature(e,t){q(64===t.byteLength,"Signature must be 64 bytes long");let r=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures).findIndex(t=>t.equals(e));q(r>=0,`Can not add signature; \`${e.toBase58()}\` is not required to sign this transaction`),this.signatures[r]=t}}let Y=new x("SysvarC1ock11111111111111111111111111111111");new x("SysvarEpochSchedu1e111111111111111111111111"),new x("Sysvar1nstructions1111111111111111111111111");let Z=new x("SysvarRecentB1ockHashes11111111111111111111"),X=new x("SysvarRent111111111111111111111111111111111");new x("SysvarRewards111111111111111111111111111111"),new x("SysvarS1otHashes111111111111111111111111111"),new x("SysvarS1otHistory11111111111111111111111111");let Q=new x("SysvarStakeHistory1111111111111111111111111");class ee extends Error{constructor({action:e,signature:t,transactionMessage:r,logs:i}){let s;const n=i?`Logs: 
4${JSON.stringify(i.slice(-10),null,2)}. `:"",o="\nCatch the `SendTransactionError` and call `getLogs()` on it for full details.";switch(e){case"send":s=`Transaction ${t} resulted in an error. 
5${r}. `+n+o;break;case"simulate":s=`Simulation failed. 
6Message: ${r}. 
7`+n+o;break;default:s=`Unknown action '${(e=>e)(e)}'`}super(s),this.signature=void 0,this.transactionMessage=void 0,this.transactionLogs=void 0,this.signature=t,this.transactionMessage=r,this.transactionLogs=i||void 0}get transactionError(){return{message:this.transactionMessage,logs:Array.isArray(this.transactionLogs)?this.transactionLogs:void 0}}get logs(){let e=this.transactionLogs;if(null==e||"object"!=typeof e||!("then"in e))return e}async getLogs(e){return Array.isArray(this.transactionLogs)||(this.transactionLogs=new Promise((t,r)=>{e.getTransaction(this.signature).then(e=>{if(e&&e.meta&&e.meta.logMessages){let r=e.meta.logMessages;this.transactionLogs=r,t(r)}else r(Error("Log messages not found"))}).catch(r)})),await this.transactionLogs}}class et extends Error{constructor({code:e,message:t,data:r},i){super(null!=i?`${i}: ${t}`:t),this.code=void 0,this.data=void 0,this.code=e,this.data=r,this.name="SolanaJSONRPCError"}}async function er(e,t,r,i){let s,n=i&&{skipPreflight:i.skipPreflight,preflightCommitment:i.preflightCommitment||i.commitment,maxRetries:i.maxRetries,minContextSlot:i.minContextSlot},o=await e.sendTransaction(t,r,n);if(null!=t.recentBlockhash&&null!=t.lastValidBlockHeight)s=(await e.confirmTransaction({abortSignal:i?.abortSignal,signature:o,blockhash:t.recentBlockhash,lastValidBlockHeight:t.lastValidBlockHeight},i&&i.commitment)).value;else if(null!=t.minNonceContextSlot&&null!=t.nonceInfo){let{nonceInstruction:r}=t.nonceInfo,n=r.keys[0].pubkey;s=(await e.confirmTransaction({abortSignal:i?.abortSignal,minContextSlot:t.minNonceContextSlot,nonceAccountPubkey:n,nonceValue:t.nonceInfo.nonce,signature:o},i&&i.commitment)).value}else i?.abortSignal!=null&&console.warn("sendAndConfirmTransaction(): A transaction with a deprecated confirmation strategy was supplied along with an `abortSignal`. Only transactions having `lastValidBlockHeight` or a combination of `nonceInfo` and `minNonceContextSlot` are abortable."),s=(await e.confirmTransaction(o,i&&i.commitment)).value;if(s.err){if(null!=o)throw new ee({action:"send",signature:o,transactionMessage:`Status: (${JSON.stringify(s)})`});throw Error(`Transaction ${o} failed (${JSON.stringify(s)})`)}return o}function ei(e){return new Promise(t=>setTimeout(t,e))}function es(e,t){let r=e.layout.span>=0?e.layout.span:function e(t,r){let i=t=>{if(t.span>=0)return t.span;if("function"==typeof t.alloc)return t.alloc(r[t.property]);if("count"in t&&"elementLayout"in t){let e=r[t.property];if(Array.isArray(e))return e.length*i(t.elementLayout)}else if("fields"in t)return e({layout:t},r[t.property]);return 0},s=0;return t.layout.fields.forEach(e=>{s+=i(e)}),s}(e,t),i=n.Buffer.alloc(r),s=Object.assign({instruction:e.index},t);return e.layout.encode(s,i),i}let en=d.nu64("lamportsPerSignature"),eo=d.struct([d.u32("version"),d.u32("state"),C("authorizedPubkey"),C("nonce"),d.struct([en],"feeCalculator")]),ea=eo.span;class el{constructor(e){this.authorizedPubkey=void 0,this.nonce=void 0,this.feeCalculator=void 0,this.authorizedPubkey=e.authorizedPubkey,this.nonce=e.nonce,this.feeCalculator=e.feeCalculator}static fromAccountData(e){let t=eo.decode(E(e),0);return new el({authorizedPubkey:new x(t.authorizedPubkey),nonce:new x(t.nonce).toString(),feeCalculator:t.feeCalculator})}}function ec(e){let t=(0,d.blob)(8,e),r=t.decode.bind(t),i=t.encode.bind(t),s=(0,h.getU64Codec)();return t.decode=(e,t)=>{let i=r(e,t);return s.decode(i)},t.encode=(e,t,r)=>i(s.encode(e),t,r),t}let eu=Object.freeze({Create:{index:0,layout:d.struct([d.u32("instruction"),d.ns64("lamports"),d.ns64("space"),C("programId")])},Assign:{index:1,layout:d.struct([d.u32("instruction"),C("programId")])},Transfer:{index:2,layout:d.struct([d.u32("instruction"),ec("lamports")])},CreateWithSeed:{index:3,layout:d.struct([d.u32("instruction"),C("base"),N("seed"),d.ns64("lamports"),d.ns64("space"),C("programId")])},AdvanceNonceAccount:{index:4,layout:d.struct([d.u32("instruction")])},WithdrawNonceAccount:{index:5,layout:d.struct([d.u32("instruction"),d.ns64("lamports")])},InitializeNonceAccount:{index:6,layout:d.struct([d.u32("instruction"),C("authorized")])},AuthorizeNonceAccount:{index:7,layout:d.struct([d.u32("instruction"),C("authorized")])},Allocate:{index:8,layout:d.struct([d.u32("instruction"),d.ns64("space")])},AllocateWithSeed:{index:9,layout:d.struct([d.u32("instruction"),C("base"),N("seed"),d.ns64("space"),C("programId")])},AssignWithSeed:{index:10,layout:d.struct([d.u32("instruction"),C("base"),N("seed"),C("programId")])},TransferWithSeed:{index:11,layout:d.struct([d.u32("instruction"),ec("lamports"),N("seed"),C("programId")])},UpgradeNonceAccount:{index:12,layout:d.struct([d.u32("instruction")])}});class ed{static createAccount(e){let t=es(eu.Create,{lamports:e.lamports,space:e.space,programId:E(e.programId.toBuffer())});return new F({keys:[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.newAccountPubkey,isSigner:!0,isWritable:!0}],programId:this.programId,data:t})}static transfer(e){let t,r;return"basePubkey"in e?(t=es(eu.TransferWithSeed,{lamports:BigInt(e.lamports),seed:e.seed,programId:E(e.programId.toBuffer())}),r=[{pubkey:e.fromPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0}]):(t=es(eu.Transfer,{lamports:BigInt(e.lamports)}),r=[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0}]),new F({keys:r,programId:this.programId,data:t})}static assign(e){let t,r;return"basePubkey"in e?(t=es(eu.AssignWithSeed,{base:E(e.basePubkey.toBuffer()),seed:e.seed,programId:E(e.programId.toBuffer())}),r=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]):(t=es(eu.Assign,{programId:E(e.programId.toBuffer())}),r=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]),new F({keys:r,programId:this.programId,data:t})}static createAccountWithSeed(e){let t=es(eu.CreateWithSeed,{base:E(e.basePubkey.toBuffer()),seed:e.seed,lamports:e.lamports,space:e.space,programId:E(e.programId.toBuffer())}),r=[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.newAccountPubkey,isSigner:!1,isWritable:!0}];return e.basePubkey.equals(e.fromPubkey)||r.push({pubkey:e.basePubkey,isSigner:!0,isWritable:!1}),new F({keys:r,programId:this.programId,data:t})}static createNonceAccount(e){let t=new H;"basePubkey"in e&&"seed"in e?t.add(ed.createAccountWithSeed({fromPubkey:e.fromPubkey,newAccountPubkey:e.noncePubkey,basePubkey:e.basePubkey,seed:e.seed,lamports:e.lamports,space:ea,programId:this.programId})):t.add(ed.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.noncePubkey,lamports:e.lamports,space:ea,programId:this.programId}));let r={noncePubkey:e.noncePubkey,authorizedPubkey:e.authorizedPubkey};return t.add(this.nonceInitialize(r)),t}static nonceInitialize(e){let t=es(eu.InitializeNonceAccount,{authorized:E(e.authorizedPubkey.toBuffer())});return new F({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:Z,isSigner:!1,isWritable:!1},{pubkey:X,isSigner:!1,isWritable:!1}],programId:this.programId,data:t})}static nonceAdvance(e){let t=es(eu.AdvanceNonceAccount);return new F({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:Z,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:t})}static nonceWithdraw(e){let t=es(eu.WithdrawNonceAccount,{lamports:e.lamports});return new F({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0},{pubkey:Z,isSigner:!1,isWritable:!1},{pubkey:X,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:t})}static nonceAuthorize(e){let t=es(eu.AuthorizeNonceAccount,{authorized:E(e.newAuthorizedPubkey.toBuffer())});return new F({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:t})}static allocate(e){let t,r;return"basePubkey"in e?(t=es(eu.AllocateWithSeed,{base:E(e.basePubkey.toBuffer()),seed:e.seed,space:e.space,programId:E(e.programId.toBuffer())}),r=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]):(t=es(eu.Allocate,{space:e.space}),r=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]),new F({keys:r,programId:this.programId,data:t})}}ed.programId=new x("11111111111111111111111111111111");class eh{static getMinNumSignatures(e){return 2*(Math.ceil(e/eh.chunkSize)+1+1)}static async load(e,t,r,i,s){{let n=await e.getMinimumBalanceForRentExemption(s.length),o=await e.getAccountInfo(r.publicKey,"confirmed"),a=null;if(null!==o){if(o.executable)return console.error("Program load failed, account is already executable"),!1;o.data.length!==s.length&&(a=a||new H).add(ed.allocate({accountPubkey:r.publicKey,space:s.length})),o.owner.equals(i)||(a=a||new H).add(ed.assign({accountPubkey:r.publicKey,programId:i})),o.lamports<n&&(a=a||new H).add(ed.transfer({fromPubkey:t.publicKey,toPubkey:r.publicKey,lamports:n-o.lamports}))}else a=new H().add(ed.createAccount({fromPubkey:t.publicKey,newAccountPubkey:r.publicKey,lamports:n>0?n:1,space:s.length,programId:i}));null!==a&&await er(e,a,[t,r],{commitment:"confirmed"})}let o=d.struct([d.u32("instruction"),d.u32("offset"),d.u32("bytesLength"),d.u32("bytesLengthPadding"),d.seq(d.u8("byte"),d.offset(d.u32(),-8),"bytes")]),a=eh.chunkSize,l=0,c=s,u=[];for(;c.length>0;){let s=c.slice(0,a),d=n.Buffer.alloc(a+16);o.encode({instruction:0,offset:l,bytes:s,bytesLength:0,bytesLengthPadding:0},d);let h=new H().add({keys:[{pubkey:r.publicKey,isSigner:!0,isWritable:!0}],programId:i,data:d});u.push(er(e,h,[t,r],{commitment:"confirmed"})),e._rpcEndpoint.includes("solana.com")&&await ei(250),l+=a,c=c.slice(a)}await Promise.all(u);{let s=d.struct([d.u32("instruction")]),o=n.Buffer.alloc(s.span);s.encode({instruction:1},o);let a=new H().add({keys:[{pubkey:r.publicKey,isSigner:!0,isWritable:!0},{pubkey:X,isSigner:!1,isWritable:!1}],programId:i,data:o}),l="processed",c=await e.sendTransaction(a,[t,r],{preflightCommitment:l}),{context:u,value:h}=await e.confirmTransaction({signature:c,lastValidBlockHeight:a.lastValidBlockHeight,blockhash:a.recentBlockhash},l);if(h.err)throw Error(`Transaction ${c} failed (${JSON.stringify(h)})`);for(;;){try{if(await e.getSlot({commitment:l})>u.slot)break}catch{}await new Promise(e=>setTimeout(e,Math.round(200)))}}return!0}}eh.chunkSize=932,new x("BPFLoader2111111111111111111111111111111111");var ef=(r=function(){if(s)return i;s=1;var e=Object.prototype.toString,t=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};return i=function(r){var i=function r(i,s){var n,o,a,l,c,u,d;if(!0===i)return"true";if(!1===i)return"false";switch(typeof i){case"object":if(null===i)return null;if(i.toJSON&&"function"==typeof i.toJSON)return r(i.toJSON(),s);if("[object Array]"===(d=e.call(i))){for(n=0,a="[",o=i.length-1;n<o;n++)a+=r(i[n],!0)+",";return o>-1&&(a+=r(i[n],!0)),a+"]"}if("[object Object]"!==d)return JSON.stringify(i);for(o=(l=t(i).sort()).length,a="",n=0;n<o;)void 0!==(u=r(i[c=l[n]],!1))&&(a&&(a+=","),a+=JSON.stringify(c)+":"+u),n++;return"{"+a+"}";case"function":case"undefined":return s?null:void 0;case"string":return JSON.stringify(i);default:return isFinite(i)?i:null}}(r,!1);if(void 0!==i)return""+i}}())&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r;function ep(e){let t=0;for(;e>1;)e/=2,t++;return t}class eg{constructor(e,t,r,i,s){this.slotsPerEpoch=void 0,this.leaderScheduleSlotOffset=void 0,this.warmup=void 0,this.firstNormalEpoch=void 0,this.firstNormalSlot=void 0,this.slotsPerEpoch=e,this.leaderScheduleSlotOffset=t,this.warmup=r,this.firstNormalEpoch=i,this.firstNormalSlot=s}getEpoch(e){return this.getEpochAndSlotIndex(e)[0]}getEpochAndSlotIndex(e){if(e<this.firstNormalSlot){var t;let r=ep(0===(t=e+32+1)?1:(t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,(t|=t>>32)+1))-ep(32)-1,i=this.getSlotsInEpoch(r);return[r,e-(i-32)]}{let t=e-this.firstNormalSlot,r=Math.floor(t/this.slotsPerEpoch);return[this.firstNormalEpoch+r,t%this.slotsPerEpoch]}}getFirstSlotInEpoch(e){return e<=this.firstNormalEpoch?(Math.pow(2,e)-1)*32:(e-this.firstNormalEpoch)*this.slotsPerEpoch+this.firstNormalSlot}getLastSlotInEpoch(e){return this.getFirstSlotInEpoch(e)+this.getSlotsInEpoch(e)-1}getSlotsInEpoch(e){return e<this.firstNormalEpoch?Math.pow(2,e+ep(32)):this.slotsPerEpoch}}var ey=globalThis.fetch;class em extends g.CommonClient{constructor(e,t,r){super(e=>{let r=(0,g.WebSocket)(e,{autoconnect:!0,max_reconnects:5,reconnect:!0,reconnect_interval:1e3,...t});return"socket"in r?this.underlyingSocket=r.socket:this.underlyingSocket=r,r},e,t,r),this.underlyingSocket=void 0}call(...e){let t=this.underlyingSocket?.readyState;return 1===t?super.call(...e):Promise.reject(Error("Tried to call a JSON-RPC method `"+e[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+t+")"))}notify(...e){let t=this.underlyingSocket?.readyState;return 1===t?super.notify(...e):Promise.reject(Error("Tried to send a JSON-RPC notification `"+e[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+t+")"))}}class eb{constructor(e){this.key=void 0,this.state=void 0,this.key=e.key,this.state=e.state}isActive(){let e=BigInt("0xffffffffffffffff");return this.state.deactivationSlot===e}static deserialize(e){let t=function(e,t){let r;try{r=e.layout.decode(t)}catch(e){throw Error("invalid instruction; "+e)}if(r.typeIndex!==e.index)throw Error(`invalid account data; account type mismatch ${r.typeIndex} != ${e.index}`);return r}(ev,e),r=e.length-56;q(r>=0,"lookup table is invalid"),q(r%32==0,"lookup table is invalid");let{addresses:i}=d.struct([d.seq(C(),r/32,"addresses")]).decode(e.slice(56));return{deactivationSlot:t.deactivationSlot,lastExtendedSlot:t.lastExtendedSlot,lastExtendedSlotStartIndex:t.lastExtendedStartIndex,authority:0!==t.authority.length?new x(t.authority[0]):void 0,addresses:i.map(e=>new x(e))}}}let ev={index:1,layout:d.struct([d.u32("typeIndex"),ec("deactivationSlot"),d.nu64("lastExtendedSlot"),d.u8("lastExtendedStartIndex"),d.u8(),d.seq(C(),d.offset(d.u8(),-1),"authority")])},ew=/^[^:]+:\/\/([^:[]+|\[[^\]]+\])(:\d+)?(.*)/i,e_=(0,f.coerce)((0,f.instance)(x),(0,f.string)(),e=>new x(e)),eS=(0,f.tuple)([(0,f.string)(),(0,f.literal)("base64")]),eE=(0,f.coerce)((0,f.instance)(n.Buffer),eS,e=>n.Buffer.from(e[0],"base64"));function eI(e){let t,r;if("string"==typeof e)t=e;
7else if(e){let{commitment:i,...s}=e;t=i,r=s}return{commitment:t,config:r}}function eA(e){return e.map(e=>"memcmp"in e?{...e,memcmp:{...e.memcmp,encoding:e.memcmp.encoding??"base58"}}:e)}function eT(e){return(0,f.union)([(0,f.type)({jsonrpc:(0,f.literal)("2.0"),id:(0,f.string)(),result:e}),(0,f.type)({jsonrpc:(0,f.literal)("2.0"),id:(0,f.string)(),error:(0,f.type)({code:(0,f.unknown)(),message:(0,f.string)(),data:(0,f.optional)((0,f.any)())})})])}let ex=eT((0,f.unknown)());function ek(e){return(0,f.coerce)(eT(e),ex,t=>"error"in t?t:{...t,result:(0,f.create)(t.result,e)})}function eP(e){return ek((0,f.type)({context:(0,f.type)({slot:(0,f.number)()}),value:e}))}function eO(e){return(0,f.type)({context:(0,f.type)({slot:(0,f.number)()}),value:e})}function eR(e,t){return 0===e?new z({header:t.header,staticAccountKeys:t.accountKeys.map(e=>new x(e)),recentBlockhash:t.recentBlockhash,compiledInstructions:t.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:l.default.decode(e.data)})),addressTableLookups:t.addressTableLookups}):new W(t)}let eC=(0,f.type)({foundation:(0,f.number)(),foundationTerm:(0,f.number)(),initial:(0,f.number)(),taper:(0,f.number)(),terminal:(0,f.number)()}),eN=ek((0,f.array)((0,f.nullable)((0,f.type)({epoch:(0,f.number)(),effectiveSlot:(0,f.number)(),amount:(0,f.number)(),postBalance:(0,f.number)(),commission:(0,f.optional)((0,f.nullable)((0,f.number)()))})))),eB=(0,f.array)((0,f.type)({slot:(0,f.number)(),prioritizationFee:(0,f.number)()})),eU=(0,f.type)({total:(0,f.number)(),validator:(0,f.number)(),foundation:(0,f.number)(),epoch:(0,f.number)()}),eq=(0,f.type)({epoch:(0,f.number)(),slotIndex:(0,f.number)(),slotsInEpoch:(0,f.number)(),absoluteSlot:(0,f.number)(),blockHeight:(0,f.optional)((0,f.number)()),transactionCount:(0,f.optional)((0,f.number)())}),eL=(0,f.type)({slotsPerEpoch:(0,f.number)(),leaderScheduleSlotOffset:(0,f.number)(),warmup:(0,f.boolean)(),firstNormalEpoch:(0,f.number)(),firstNormalSlot:(0,f.number)()}),eD=(0,f.record)((0,f.string)(),(0,f.array)((0,f.number)())),eM=(0,f.nullable)((0,f.union)([(0,f.type)({}),(0,f.string)()])),eK=(0,f.type)({err:eM}),eW=(0,f.literal)("receivedSignature"),ez=(0,f.type)({"solana-core":(0,f.string)(),"feature-set":(0,f.optional)((0,f.number)())}),ej=(0,f.type)({program:(0,f.string)(),programId:e_,parsed:(0,f.unknown)()}),eV=(0,f.type)({programId:e_,accounts:(0,f.array)(e_),data:(0,f.string)()}),e$=eP((0,f.type)({err:(0,f.nullable)((0,f.union)([(0,f.type)({}),(0,f.string)()])),logs:(0,f.nullable)((0,f.array)((0,f.string)())),accounts:(0,f.optional)((0,f.nullable)((0,f.array)((0,f.nullable)((0,f.type)({executable:(0,f.boolean)(),owner:(0,f.string)(),lamports:(0,f.number)(),data:(0,f.array)((0,f.string)()),rentEpoch:(0,f.optional)((0,f.number)())}))))),unitsConsumed:(0,f.optional)((0,f.number)()),returnData:(0,f.optional)((0,f.nullable)((0,f.type)({programId:(0,f.string)(),data:(0,f.tuple)([(0,f.string)(),(0,f.literal)("base64")])}))),innerInstructions:(0,f.optional)((0,f.nullable)((0,f.array)((0,f.type)({index:(0,f.number)(),instructions:(0,f.array)((0,f.union)([ej,eV]))}))))})),eF=eP((0,f.type)({byIdentity:(0,f.record)((0,f.string)(),(0,f.array)((0,f.number)())),range:(0,f.type)({firstSlot:(0,f.number)(),lastSlot:(0,f.number)()})})),eH=ek(eC),eG=ek(eU),eJ=ek(eB),eY=ek(eq),eZ=ek(eL),eX=ek(eD),eQ=ek((0,f.number)()),e0=eP((0,f.type)({total:(0,f.number)(),circulating:(0,f.number)(),nonCirculating:(0,f.number)(),nonCirculatingAccounts:(0,f.array)(e_)})),e1=(0,f.type)({amount:(0,f.string)(),uiAmount:(0,f.nullable)((0,f.number)()),decimals:(0,f.number)(),uiAmountString:(0,f.optional)((0,f.string)())}),e2=eP((0,f.array)((0,f.type)({address:e_,amount:(0,f.string)(),uiAmount:(0,f.nullable)((0,f.number)()),decimals:(0,f.number)(),uiAmountString:(0,f.optional)((0,f.string)())}))),e5=eP((0,f.array)((0,f.type)({pubkey:e_,account:(0,f.type)({executable:(0,f.boolean)(),owner:e_,lamports:(0,f.number)(),data:eE,rentEpoch:(0,f.number)()})}))),e6=(0,f.type)({program:(0,f.string)(),parsed:(0,f.unknown)(),space:(0,f.number)()}),e3=eP((0,f.array)((0,f.type)({pubkey:e_,account:(0,f.type)({executable:(0,f.boolean)(),owner:e_,lamports:(0,f.number)(),data:e6,rentEpoch:(0,f.number)()})}))),e8=eP((0,f.array)((0,f.type)({lamports:(0,f.number)(),address:e_}))),e4=(0,f.type)({executable:(0,f.boolean)(),owner:e_,lamports:(0,f.number)(),data:eE,rentEpoch:(0,f.number)()}),e7=(0,f.type)({pubkey:e_,account:e4}),e9=(0,f.coerce)((0,f.union)([(0,f.instance)(n.Buffer),e6]),(0,f.union)([eS,e6]),e=>Array.isArray(e)?(0,f.create)(e,eE):e),te=(0,f.type)({executable:(0,f.boolean)(),owner:e_,lamports:(0,f.number)(),data:e9,rentEpoch:(0,f.number)()}),tt=(0,f.type)({pubkey:e_,account:te}),tr=(0,f.type)({state:(0,f.union)([(0,f.literal)("active"),(0,f.literal)("inactive"),(0,f.literal)("activating"),(0,f.literal)("deactivating")]),active:(0,f.number)(),inactive:(0,f.number)()}),ti=ek((0,f.array)((0,f.type)({signature:(0,f.string)(),slot:(0,f.number)(),err:eM,memo:(0,f.nullable)((0,f.string)()),blockTime:(0,f.optional)((0,f.nullable)((0,f.number)()))}))),ts=ek((0,f.array)((0,f.type)({signature:(0,f.string)(),slot:(0,f.number)(),err:eM,memo:(0,f.nullable)((0,f.string)()),blockTime:(0,f.optional)((0,f.nullable)((0,f.number)()))}))),tn=(0,f.type)({subscription:(0,f.number)(),result:eO(e4)}),to=(0,f.type)({pubkey:e_,account:e4}),ta=(0,f.type)({subscription:(0,f.number)(),result:eO(to)}),tl=(0,f.type)({parent:(0,f.number)(),slot:(0,f.number)(),root:(0,f.number)()}),tc=(0,f.type)({subscription:(0,f.number)(),result:tl}),tu=(0,f.union)([(0,f.type)({type:(0,f.union)([(0,f.literal)("firstShredReceived"),(0,f.literal)("completed"),(0,f.literal)("optimisticConfirmation"),(0,f.literal)("root")
7]),slot:(0,f.number)(),timestamp:(0,f.number)()}),(0,f.type)({type:(0,f.literal)("createdBank"),parent:(0,f.number)(),slot:(0,f.number)(),timestamp:(0,f.number)()}),(0,f.type)({type:(0,f.literal)("frozen"),slot:(0,f.number)(),timestamp:(0,f.number)(),stats:(0,f.type)({numTransactionEntries:(0,f.number)(),numSuccessfulTransactions:(0,f.number)(),numFailedTransactions:(0,f.number)(),maxTransactionsPerEntry:(0,f.number)()})}),(0,f.type)({type:(0,f.literal)("dead"),slot:(0,f.number)(),timestamp:(0,f.number)(),err:(0,f.string)()})]),td=(0,f.type)({subscription:(0,f.number)(),result:tu}),th=(0,f.type)({subscription:(0,f.number)(),result:eO((0,f.union)([eK,eW]))}),tf=(0,f.type)({subscription:(0,f.number)(),result:(0,f.number)()}),tp=(0,f.type)({pubkey:(0,f.string)(),gossip:(0,f.nullable)((0,f.string)()),tpu:(0,f.nullable)((0,f.string)()),rpc:(0,f.nullable)((0,f.string)()),version:(0,f.nullable)((0,f.string)())}),tg=(0,f.type)({votePubkey:(0,f.string)(),nodePubkey:(0,f.string)(),activatedStake:(0,f.number)(),epochVoteAccount:(0,f.boolean)(),epochCredits:(0,f.array)((0,f.tuple)([(0,f.number)(),(0,f.number)(),(0,f.number)()])),commission:(0,f.number)(),lastVote:(0,f.number)(),rootSlot:(0,f.nullable)((0,f.number)())}),ty=ek((0,f.type)({current:(0,f.array)(tg),delinquent:(0,f.array)(tg)})),tm=(0,f.union)([(0,f.literal)("processed"),(0,f.literal)("confirmed"),(0,f.literal)("finalized")]),tb=(0,f.type)({slot:(0,f.number)(),confirmations:(0,f.nullable)((0,f.number)()),err:eM,confirmationStatus:(0,f.optional)(tm)}),tv=eP((0,f.array)((0,f.nullable)(tb))),tw=ek((0,f.number)()),t_=(0,f.type)({accountKey:e_,writableIndexes:(0,f.array)((0,f.number)()),readonlyIndexes:(0,f.array)((0,f.number)())}),tS=(0,f.type)({signatures:(0,f.array)((0,f.string)()),message:(0,f.type)({accountKeys:(0,f.array)((0,f.string)()),header:(0,f.type)({numRequiredSignatures:(0,f.number)(),numReadonlySignedAccounts:(0,f.number)(),numReadonlyUnsignedAccounts:(0,f.number)()}),instructions:(0,f.array)((0,f.type)({accounts:(0,f.array)((0,f.number)()),data:(0,f.string)(),programIdIndex:(0,f.number)()})),recentBlockhash:(0,f.string)(),addressTableLookups:(0,f.optional)((0,f.array)(t_))})}),tE=(0,f.type)({pubkey:e_,signer:(0,f.boolean)(),writable:(0,f.boolean)(),source:(0,f.optional)((0,f.union)([(0,f.literal)("transaction"),(0,f.literal)("lookupTable")]))}),tI=(0,f.type)({accountKeys:(0,f.array)(tE),signatures:(0,f.array)((0,f.string)())}),tA=(0,f.type)({parsed:(0,f.unknown)(),program:(0,f.string)(),programId:e_}),tT=(0,f.type)({accounts:(0,f.array)(e_),data:(0,f.string)(),programId:e_}),tx=(0,f.union)([tT,tA]),tk=(0,f.union)([(0,f.type)({parsed:(0,f.unknown)(),program:(0,f.string)(),programId:(0,f.string)()}),(0,f.type)({accounts:(0,f.array)((0,f.string)()),data:(0,f.string)(),programId:(0,f.string)()})]),tP=(0,f.coerce)(tx,tk,e=>"accounts"in e?(0,f.create)(e,tT):(0,f.create)(e,tA)),tO=(0,f.type)({signatures:(0,f.array)((0,f.string)()),message:(0,f.type)({accountKeys:(0,f.array)(tE),instructions:(0,f.array)(tP),recentBlockhash:(0,f.string)(),addressTableLookups:(0,f.optional)((0,f.nullable)((0,f.array)(t_)))})}),tR=(0,f.type)({accountIndex:(0,f.number)(),mint:(0,f.string)(),owner:(0,f.optional)((0,f.string)()),programId:(0,f.optional)((0,f.string)()),uiTokenAmount:e1}),tC=(0,f.type)({writable:(0,f.array)(e_),readonly:(0,f.array)(e_)}),tN=(0,f.type)({err:eM,fee:(0,f.number)(),innerInstructions:(0,f.optional)((0,f.nullable)((0,f.array)((0,f.type)({index:(0,f.number)(),instructions:(0,f.array)((0,f.type)({accounts:(0,f.array)((0,f.number)()),data:(0,f.string)(),programIdIndex:(0,f.number)()}))})))),preBalances:(0,f.array)((0,f.number)()),postBalances:(0,f.array)((0,f.number)()),logMessages:(0,f.optional)((0,f.nullable)((0,f.array)((0,f.string)()))),preTokenBalances:(0,f.optional)((0,f.nullable)((0,f.array)(tR))),postTokenBalances:(0,f.optional)((0,f.nullable)((0,f.array)(tR))),loadedAddresses:(0,f.optional)(tC),computeUnitsConsumed:(0,f.optional)((0,f.number)())}),tB=(0,f.type)({err:eM,fee:(0,f.number)(),innerInstructions:(0,f.optional)((0,f.nullable)((0,f.array)((0,f.type)({index:(0,f.number)(),instructions:(0,f.array)(tP)})))),preBalances:(0,f.array)((0,f.number)()),postBalances:(0,f.array)((0,f.number)()),logMessages:(0,f.optional)((0,f.nullable)((0,f.array)((0,f.string)()))),preTokenBalances:(0,f.optional)((0,f.nullable)((0,f.array)(tR))),postTokenBalances:(0,f.optional)((0,f.nullable)((0,f.array)(tR))),loadedAddresses:(0,f.optional)(tC),computeUnitsConsumed:(0,f.optional)((0,f.number)())}),tU=(0,f.union)([(0,f.literal)(0),(0,f.literal)("legacy")]),tq=(0,f.type)({pubkey:(0,f.string)(),lamports:(0,f.number)(),postBalance:(0,f.nullable)((0,f.number)()),rewardType:(0,f.nullable)((0,f.string)()),commission:(0,f.optional)((0,f.nullable)((0,f.number)()))}),tL=ek((0,f.nullable)((0,f.type)({blockhash:(0,f.string)(),previousBlockhash:(0,f.string)(),parentSlot:(0,f.number)(),transactions:(0,f.array)((0,f.type)({transaction:tS,meta:(0,f.nullable)(tN),version:(0,f.optional)(tU)})),rewards:(0,f.optional)((0,f.array)(tq)),blockTime:(0,f.nullable)((0,f.number)()),blockHeight:(0,f.nullable)((0,f.number)())}))),tD=ek((0,f.nullable)((0,f.type)({blockhash:(0,f.string)(),previousBlockhash:(0,f.string)(),parentSlot:(0,f.number)(),rewards:(0,f.optional)((0,f.array)(tq)),blockTime:(0,f.nullable)((0,f.number)()),blockHeight:(0,f.nullable)((0,f.number)())}))),tM=ek((0,f.nullable)((0,f.type)({blockhash:(0,f.string)(),previousBlockhash:(0,f.string)(),parentSlot:(0,f.number)(),transactions:(0,f.array)((0,f.type)({transaction:tI,meta:(0,f.nullable)(tN),version:(0,f.optional)(tU)})),rewards:(0,f.optional)((0,f.array)(tq)),blockTime:(0,f.nullable)((0,f.number)()),blockHeight:(0,f.nullable)((0,f.number)())}))),tK=ek((0,f.nullable)((0,f.type)({blockhash:(0,f.string)(),previousBlockhash:(0,f.string)(),parentSlot:(0,f.number)(),transactions:(0,f.array)((0,f.type)({transaction:tO,meta:(0,f.nullable)(tB),version:(0,f.optional)(tU)})),rewards:(0,f.optional)((0,f.array)(tq)),blockTime:(0,f.nullable)((0,f.number)()),blockHeight:(0,f.nullable)((0,f.number)())}))),tW=ek((0,f.nullable)((0,f.type)({blockhash:(0,f.string)(),previousBlockhash:(0,f.string)(),parentSlot:(0,f.number)(),transactions:(0,f.array)((0,f.type)({transaction:tI,meta:(0,f.nullable)(tB),version:(0,f.optional)(tU)})),rewards:(0,f.optional)((0,f.array)(tq)),blockTime:(0,f.nullable)((0,f.number)()),blockHeight:(0,f.nullable)((0,f.number)())}))),tz=ek((0,f.nullable)((0,f.type)({blockhash:(0,f.string)(),previousBlockhash:(0,f.string)(),parentSlot:(0,f.number)(),rewards:(0,f.optional)((0,f.array)(tq)),blockTime:(0,f.nullable)((0,f.number)()),blockHeight:(0,f.nullable)((0,f.number)())}))),tj=ek((0,f.nullable)((0,f.type)({blockhash:(0,f.string)(),previousBlockhash:(0,f.string)(),parentSlot:(0,f.number)(),transactions:(0,f.array)((0,f.type)({transaction:tS,meta:(0,f.nullable)(tN)})),rewards:(0,f.optional)((0,f.array)(tq)),blockTime:(0,f.nullable)((0,f.number)())}))),tV=ek((0,f.nullable)((0,f.type)({blockhash:(0,f.string)(),previousBlockhash:(0,f.string)(),parentSlot:(0,f.number)(),signatures:(0,f.array)((0,f.string)()),blockTime:(0,f.nullable)((0,f.number)())}))),t$=ek((0,f.nullable)((0,f.type)({slot:(0,f.number)(),meta:(0,f.nullable)(tN),blockTime:(0,f.optional)((0,f.nullable)((0,f.number)())),transaction:tS,version:(0,f.optional)(tU)}))),tF=ek((0,f.nullable)((0,f.type)({slot:(0,f.number)(),transaction:tO,meta:(0,f.nullable)(tB),blockTime:(0,f.optional)((0,f.nullable)((0,f.number)())),version:(0,f.optional)(tU)}
vendor: 14,436 bytes, line 7
7))),tH=eP((0,f.type)({blockhash:(0,f.string)(),lastValidBlockHeight:(0,f.number)()})),tG=eP((0,f.boolean)()),tJ=(0,f.type)({slot:(0,f.number)(),numTransactions:(0,f.number)(),numSlots:(0,f.number)(),samplePeriodSecs:(0,f.number)()}),tY=ek((0,f.array)(tJ)),tZ=eP((0,f.nullable)((0,f.type)({feeCalculator:(0,f.type)({lamportsPerSignature:(0,f.number)()})}))),tX=ek((0,f.string)()),tQ=ek((0,f.string)()),t0=(0,f.type)({err:eM,logs:(0,f.array)((0,f.string)()),signature:(0,f.string)()}),t1=(0,f.type)({result:eO(t0),subscription:(0,f.number)()}),t2={"solana-client":"js/1.0.0-maintenance"};class t5{constructor(e){this._keypair=void 0,this._keypair=e??b()}static generate(){return new t5(b())}static fromSecretKey(e,t){if(64!==e.byteLength)throw Error("bad secret key size");let r=e.slice(32,64);if(!t||!t.skipValidation){let t=v(e.slice(0,32));for(let e=0;e<32;e++)if(r[e]!==t[e])throw Error("provided secretKey is invalid")}return new t5({publicKey:r,secretKey:e})}static fromSeed(e){let t=v(e),r=new Uint8Array(64);return r.set(e),r.set(t,32),new t5({publicKey:t,secretKey:r})}get publicKey(){return new x(this._keypair.publicKey)}get secretKey(){return new Uint8Array(this._keypair.secretKey)}}Object.freeze({CreateLookupTable:{index:0,layout:d.struct([d.u32("instruction"),ec("recentSlot"),d.u8("bumpSeed")])},FreezeLookupTable:{index:1,layout:d.struct([d.u32("instruction")])},ExtendLookupTable:{index:2,layout:d.struct([d.u32("instruction"),ec(),d.seq(C(),d.offset(d.u32(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:d.struct([d.u32("instruction")])},CloseLookupTable:{index:4,layout:d.struct([d.u32("instruction")])}}),new x("AddressLookupTab1e1111111111111111111111111"),Object.freeze({RequestUnits:{index:0,layout:d.struct([d.u8("instruction"),d.u32("units"),d.u32("additionalFee")])},RequestHeapFrame:{index:1,layout:d.struct([d.u8("instruction"),d.u32("bytes")])},SetComputeUnitLimit:{index:2,layout:d.struct([d.u8("instruction"),d.u32("units")])},SetComputeUnitPrice:{index:3,layout:d.struct([d.u8("instruction"),ec("microLamports")])}}),new x("ComputeBudget111111111111111111111111111111");let t6=d.struct([d.u8("numSignatures"),d.u8("padding"),d.u16("signatureOffset"),d.u16("signatureInstructionIndex"),d.u16("publicKeyOffset"),d.u16("publicKeyInstructionIndex"),d.u16("messageDataOffset"),d.u16("messageDataSize"),d.u16("messageInstructionIndex")]);class t3{static createInstructionWithPublicKey(e){let{publicKey:t,message:r,signature:i,instructionIndex:s}=e;q(32===t.length,`Public Key must be 32 bytes but received ${t.length} bytes`),q(64===i.length,`Signature must be 64 bytes but received ${i.length} bytes`);let o=t6.span,a=o+t.length,l=a+i.length,c=n.Buffer.alloc(l+r.length),u=null==s?65535:s;return t6.encode({numSignatures:1,padding:0,signatureOffset:a,signatureInstructionIndex:u,publicKeyOffset:o,publicKeyInstructionIndex:u,messageDataOffset:l,messageDataSize:r.length,messageInstructionIndex:u},c),c.fill(t,o),c.fill(i,a),c.fill(r,l),new F({keys:[],programId:t3.programId,data:c})}static createInstructionWithPrivateKey(e){let{privateKey:t,message:r,instructionIndex:i}=e;q(64===t.length,`Private key must be 64 bytes but received ${t.length} bytes`);try{let e=t5.fromSecretKey(t),s=e.publicKey.toBytes(),n=_(r,e.secretKey);return this.createInstructionWithPublicKey({publicKey:s,message:r,signature:n,instructionIndex:i})}catch(e){throw Error(`Error creating instruction; ${e}`)}}}t3.programId=new x("Ed25519SigVerify111111111111111111111111111"),m.secp256k1.utils.isValidPrivateKey;let t8=m.secp256k1.getPublicKey,t4=d.struct([d.u8("numSignatures"),d.u16("signatureOffset"),d.u8("signatureInstructionIndex"),d.u16("ethAddressOffset"),d.u8("ethAddressInstructionIndex"),d.u16("messageDataOffset"),d.u16("messageDataSize"),d.u8("messageInstructionIndex"),d.blob(20,"ethAddress"),d.blob(64,"signature"),d.u8("recoveryId")]);class t7{static publicKeyToEthAddress(e){q(64===e.length,`Public key must be 64 bytes but received ${e.length} bytes`);try{return n.Buffer.from((0,y.keccak_256)(E(e))).slice(-20)}catch(e){throw Error(`Error constructing Ethereum address: ${e}`)}}static createInstructionWithPublicKey(e){let{publicKey:t,message:r,signature:i,recoveryId:s,instructionIndex:n}=e;return t7.createInstructionWithEthAddress({ethAddress:t7.publicKeyToEthAddress(t),message:r,signature:i,recoveryId:s,instructionIndex:n})}static createInstructionWithEthAddress(e){let t,{ethAddress:r,message:i,signature:s,recoveryId:o,instructionIndex:a=0}=e;q(20===(t="string"==typeof r?r.startsWith("0x")?n.Buffer.from(r.substr(2),"hex"):n.Buffer.from(r,"hex"):r).length,`Address must be 20 bytes but received ${t.length} bytes`);let l=12+t.length,c=l+s.length+1,u=n.Buffer.alloc(t4.span+i.length);return t4.encode({numSignatures:1,signatureOffset:l,signatureInstructionIndex:a,ethAddressOffset:12,ethAddressInstructionIndex:a,messageDataOffset:c,messageDataSize:i.length,messageInstructionIndex:a,signature:E(s),ethAddress:E(t),recoveryId:o},u),u.fill(E(i),t4.span),new F({keys:[],programId:t7.programId,data:u})}static createInstructionWithPrivateKey(e){let{privateKey:t,message:r,instructionIndex:i}=e;q(32===t.length,`Private key must be 32 bytes but received ${t.length} bytes`);try{var s;let e,o=E(t),a=t8(o,!1).slice(1),[l,c]=(s=n.Buffer.from((0,y.keccak_256)(E(r))),[(e=m.secp256k1.sign(s,o)).toCompactRawBytes(),e.recovery]);return this.createInstructionWithPublicKey({publicKey:a,message:r,signature:l,recoveryId:c,instructionIndex:i})}catch(e){throw Error(`Error creating instruction; ${e}`)}}}t7.programId=new x("KeccakSecp256k11111111111111111111111111111");let t9=new x("StakeConfig11111111111111111111111111111111");class re{constructor(e,t,r){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=e,this.epoch=t,this.custodian=r}}re.default=new re(0,0,x.default);let rt=Object.freeze({Initialize:{index:0,layout:d.struct([d.u32("instruction"),((e="authorized")=>d.struct([C("staker"),C("withdrawer")],e))(),((e="lockup")=>d.struct([d.ns64("unixTimestamp"),d.ns64("epoch"),C("custodian")],e))()])},Authorize:{index:1,layout:d.struct([d.u32("instruction"),C("newAuthorized"),d.u32("stakeAuthorizationType")])},Delegate:{index:2,layout:d.struct([d.u32("instruction")])},Split:{index:3,layout:d.struct([d.u32("instruction"),d.ns64("lamports")])},Withdraw:{index:4,layout:d.struct([d.u32("instruction"),d.ns64("lamports")])},Deactivate:{index:5,layout:d.struct([d.u32("instruction")])},Merge:{index:7,layout:d.struct([d.u32("instruction")])},AuthorizeWithSeed:{index:8,layout:d.struct([d.u32("instruction"),C("newAuthorized"),d.u32("stakeAuthorizationType"),N("authoritySeed"),C("authorityOwner")])}});Object.freeze({Staker:{index:0},Withdrawer:{index:1}});class rr{static initialize(e){let{stakePubkey:t,authorized:r,lockup:i}=e,s=i||re.default,n=es(rt.Initialize,{authorized:{staker:E(r.staker.toBuffer()),withdrawer:E(r.withdrawer.toBuffer())},lockup:{unixTimestamp:s.unixTimestamp,epoch:s.epoch,custodian:E(s.custodian.toBuffer())}});return new F({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:X,isSigner:!1,isWritable:!1}],programId:this.programId,data:n})}static createAccountWithSeed(e){let t=new H;t.add(ed.createAccountWithSeed({fromPubkey:e.fromPubkey,newAccountPubkey:e.stakePubkey,basePubkey:e.basePubkey,seed:e.seed,lamports:e.lamports,space:this.space,programId:this.programId}));let{stakePubkey:r,authorized:i,lockup:s}=e;return t.add(this.initialize({stakePubkey:r,authorized:i,lockup:s}))}static createAccount(e){let t=new H;t.add(ed.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.stakePubkey,lamports:e.lamports,space:this.space,programId:this.programId}));let{stakePubkey:r,authorized:i,lockup:s}=e;return t.add(this.initialize({stakePubkey:r,authorized:i,lockup:s}))}static delegate(e){let{stakePubkey:t,authorizedPubkey:r,votePubkey:i}=e,s=es(rt.Delegate);return new H().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!1},{pubkey:Y,isSigner:!1,isWritable:!1},{pubkey:Q,isSigner:!1,isWritable:!1},{pubkey:t9,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:s})}static authorize(e){let{stakePubkey:t,authorizedPubkey:r,newAuthorizedPubkey:i,stakeAuthorizationType:s,custodianPubkey:n}=e,o=es(rt.Authorize,{newAuthorized:E(i.toBuffer()),stakeAuthorizationType:s.index}),a=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:Y,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}];return n&&a.push({pubkey:n,isSigner:!0,isWritable:!1}),new H().add({keys:a,programId:this.programId,data:o})}static authorizeWithSeed(e){let{stakePubkey:t,authorityBase:r,authoritySeed:i,authorityOwner:s,newAuthorizedPubkey:n,stakeAuthorizationType:o,custodianPubkey:a}=e,l=es(rt.AuthorizeWithSeed,{newAuthorized:E(n.toBuffer()),stakeAuthorizationType:o.index,authoritySeed:i,authorityOwner:E(s.toBuffer())}),c=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1},{pubkey:Y,isSigner:!1,isWritable:!1}];return a&&c.push({pubkey:a,isSigner:!0,isWritable:!1}),new H().add({keys:c,programId:this.programId,data:l})}static splitInstruction(e){let{stakePubkey:t,authorizedPubkey:r,splitStakePubkey:i,lamports:s}=e,n=es(rt.Split,{lamports:s});return new F({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static split(e,t){let r=new H;return r.add(ed.createAccount({fromPubkey:e.authorizedPubkey,newAccountPubkey:e.splitStakePubkey,lamports:t,space:this.space,programId:this.programId})),r.add(this.splitInstruction(e))}static splitWithSeed(e,t){let{stakePubkey:r,authorizedPubkey:i,splitStakePubkey:s,basePubkey:n,seed:o,lamports:a}=e,l=new H;return l.add(ed.allocate({accountPubkey:s,basePubkey:n,seed:o,space:this.space,programId:this.programId})),t&&t>0&&l.add(ed.transfer({fromPubkey:e.authorizedPubkey,toPubkey:s,lamports:t})),l.add(this.splitInstruction({stakePubkey:r,authorizedPubkey:i,splitStakePubkey:s,lamports:a}))}static merge(e){let{stakePubkey:t,sourceStakePubKey:r,authorizedPubkey:i}=e,s=es(rt.Merge);return new H().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:Y,isSigner:!1,isWritable:!1},{pubkey:Q,isSigner:!1,isWritable:!1},{pubkey:i,isSigner:!0,isWritable:!1}],programId:this.programId,data:s})}static withdraw(e){let{stakePubkey:t,authorizedPubkey:r,toPubkey:i,lamports:s,custodianPubkey:n}=e,o=es(rt.Withdraw,{lamports:s}),a=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:Y,isSigner:!1,isWritable:!1},{pubkey:Q,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}];return n&&a.push({pubkey:n,isSigner:!0,isWritable:!1}),new H().add({keys:a,programId:this.programId,data:o})}static deactivate(e){let{stakePubkey:t,authorizedPubkey:r}=e,i=es(rt.Deactivate);return new H().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:Y,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:i})}}rr.programId=new x("Stake11111111111111111111111111111111111111"),rr.space=200;let ri=Object.freeze({InitializeAccount:{index:0,layout:d.struct([d.u32("instruction"),((e="voteInit")=>d.struct([C("nodePubkey"),C("authorizedVoter"),C("authorizedWithdrawer"),d.u8("commission")],e))()])},Authorize:{index:1,layout:d.struct([d.u32("instruction"),C("newAuthorized"),d.u32("voteAuthorizationType")])},Withdraw:{index:3,layout:d.struct([d.u32("instruction"),d.ns64("lamports")])},UpdateValidatorIdentity:{index:4,layout:d.struct([d.u32("instruction")])},AuthorizeWithSeed:{index:10,layout:d.struct([d.u32("instruction"),((e="voteAuthorizeWithSeedArgs")=>d.struct([d.u32("voteAuthorizationType"),C("currentAuthorityDerivedKeyOwnerPubkey"),N("currentAuthorityDerivedKeySeed"),C("newAuthorized")],e))()])}});Object.freeze({Voter:{index:0},Withdrawer:{index:1}});class rs{static initializeAccount(e){let{votePubkey:t,nodePubkey:r,voteInit:i}=e,s=es(ri.InitializeAccount,{voteInit:{nodePubkey:E(i.nodePubkey.toBuffer()),authorizedVoter:E(i.authorizedVoter.toBuffer()),authorizedWithdrawer:E(i.authorizedWithdrawer.toBuffer()),commission:i.commission}});return new F({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:X,isSigner:!1,isWritable:!1},{pubkey:Y,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:s})}static createAccount(e){let t=new H;return t.add(ed.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.votePubkey,lamports:e.lamports,space:this.space,programId:this.programId})),t.add(this.initializeAccount({votePubkey:e.votePubkey,nodePubkey:e.voteInit.nodePubkey,voteInit:e.voteInit}))}static authorize(e){let{votePubkey:t,authorizedPubkey:r,newAuthorizedPubkey:i,voteAuthorizationType:s}=e,n=es(ri.Authorize,{newAuthorized:E(i.toBuffer()),voteAuthorizationType:s.index});return new H().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:Y,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static authorizeWithSeed(e){let{currentAuthorityDerivedKeyBasePubkey:t,currentAuthorityDerivedKeyOwnerPubkey:r,currentAuthorityDerivedKeySeed:i,newAuthorizedPubkey:s,voteAuthorizationType:n,votePubkey:o}=e,a=es(ri.AuthorizeWithSeed,{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:E(r.toBuffer()),currentAuthorityDerivedKeySeed:i,newAuthorized:E(s.toBuffer()),voteAuthorizationType:n.index}});return new H().add({keys:[{pubkey:o,isSigner:!1,isWritable:!0},{pubkey:Y,isSigner:!1,isWritable:!1},{pubkey:t,isSigner:!0,isWritable:!1}],programId:this.programId,data:a})}static withdraw(e){let{votePubkey:t,authorizedWithdrawerPubkey:r,lamports:i,toPubkey:s}=e,n=es(ri.Withdraw,{lamports:i});return new H().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static safeWithdraw(e,t,r){if(e.lamports>t-r)throw Error("Withdraw will leave vote account with insufficient funds.");return rs.withdraw(e)}static updateValidatorIdentity(e){let{votePubkey:t,authorizedWithdrawerPubkey:r,nodePubkey:i}=e,s=es(ri.UpdateValidatorIdentity);return new H().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!0,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:s})}}rs.programId=new x("Vote111111111111111111111111111111111111111"),rs.space=3762,new x("V
7a1idator1nfo111111111111111111111111111111"),(0,f.type)({name:(0,f.string)(),website:(0,f.optional)((0,f.string)()),details:(0,f.optional)((0,f.string)()),iconUrl:(0,f.optional)((0,f.string)()),keybaseUsername:(0,f.optional)((0,f.string)())}),new x("Vote111111111111111111111111111111111111111"),d.struct([C("nodePubkey"),C("authorizedWithdrawer"),d.u8("commission"),d.nu64(),d.seq(d.struct([d.nu64("slot"),d.u32("confirmationCount")]),d.offset(d.u32(),-8),"votes"),d.u8("rootSlotValid"),d.nu64("rootSlot"),d.nu64(),d.seq(d.struct([d.nu64("epoch"),C("authorizedVoter")]),d.offset(d.u32(),-8),"authorizedVoters"),d.struct([d.seq(d.struct([C("authorizedPubkey"),d.nu64("epochOfLastAuthorizedSwitch"),d.nu64("targetEpoch")]),32,"buf"),d.nu64("idx"),d.u8("isEmpty")],"priorVoters"),d.nu64(),d.seq(d.struct([d.nu64("epoch"),d.nu64("credits"),d.nu64("prevCredits")]),d.offset(d.u32(),-8),"epochCredits"),d.struct([d.nu64("slot"),d.nu64("timestamp")],"lastTimestamp")]),e.s(["Connection",0,class{constructor(e,t){let r,i,s,n,o,a;this._commitment=void 0,this._confirmTransactionInitialTimeout=void 0,this._rpcEndpoint=void 0,this._rpcWsEndpoint=void 0,this._rpcClient=void 0,this._rpcRequest=void 0,this._rpcBatchRequest=void 0,this._rpcWebSocket=void 0,this._rpcWebSocketConnected=!1,this._rpcWebSocketHeartbeat=null,this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketGeneration=0,this._disableBlockhashCaching=!1,this._pollingBlockhash=!1,this._blockhashInfo={latestBlockhash:null,lastFetch:0,transactionSignatures:[],simulatedSignatures:[]},this._nextClientSubscriptionId=0,this._subscriptionDisposeFunctionsByClientSubscriptionId={},this._subscriptionHashByClientSubscriptionId={},this._subscriptionStateChangeCallbacksByHash={},this._subscriptionCallbacksByServerSubscriptionId={},this._subscriptionsByHash={},this._subscriptionsAutoDisposedByRpc=new Set,this.getBlockHeight=(()=>{let e={};return async t=>{let{commitment:r,config:i}=eI(t),s=this._buildArgs([],r,void 0,i),n=ef(s);return e[n]=e[n]??(async()=>{try{let e=await this._rpcRequest("getBlockHeight",s),t=(0,f.create)(e,ek((0,f.number)()));if("error"in t)throw new et(t.error,"failed to get block height information");return t.result}finally{delete e[n]}})(),await e[n]}})(),t&&"string"==typeof t?this._commitment=t:t&&(this._commitment=t.commitment,this._confirmTransactionInitialTimeout=t.confirmTransactionInitialTimeout,r=t.wsEndpoint,i=t.httpHeaders,s=t.fetch,n=t.fetchMiddleware,o=t.disableRetryOnRateLimit,a=t.httpAgent),this._rpcEndpoint=function(e){if(!1===/^https?:/.test(e))throw TypeError("Endpoint URL must start with `http:` or `https:`.");return e}(e),this._rpcWsEndpoint=r||function(e){let t=e.match(ew);if(null==t)throw TypeError(`Failed to validate endpoint URL \`${e}\``);let[r,i,s,n]=t,o=e.startsWith("https:")?"wss:":"ws:",a=null==s?null:parseInt(s.slice(1),10),l=null==a?"":`:${a+1}`;return`${o}//${i}${l}${n}`}(e),this._rpcClient=function(e,t,r,i,s,n){let o,a,l=r||ey;return null!=n&&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."),i&&(a=async(e,t)=>{let r=await new Promise((r,s)=>{try{i(e,t,(e,t)=>r([e,t]))}catch(e){s(e)}});return await l(...r)}),new p.default(async(r,i)=>{let n={method:"POST",body:r,agent:o,headers:Object.assign({"Content-Type":"application/json"},t||{},t2)};try{let t,r=5,o=500;for(;(t=a?await a(e,n):await l(e,n),429===t.status&&!0!==s)&&(r-=1,0!==r);){;console.error(`Server responded with ${t.status} ${t.statusText}.  Retrying after ${o}ms delay...`),await ei(o),o*=2}let c=await t.text();t.ok?i(null,c):i(Error(`${t.status} ${t.statusText}: ${c}`))}catch(e){e instanceof Error&&i(e)}},{})}(e,i,s,n,o,a),this._rpcRequest=function(e){return(t,r)=>new Promise((i,s)=>{e.request(t,r,(e,t)=>{e?s(e):i(t)})})}(this._rpcClient),this._rpcBatchRequest=function(e){return t=>new Promise((r,i)=>{0===t.length&&r([]);let s=t.map(t=>e.request(t.methodName,t.args));e.request(s,(e,t)=>{e?i(e):r(t)})})}(this._rpcClient),this._rpcWebSocket=new em(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}
7async getBalanceAndContext(e,t){let{commitment:r,config:i}=eI(t),s=this._buildArgs([e.toBase58()],r,void 0,i),n=await this._rpcRequest("getBalance",s),o=(0,f.create)(n,eP((0,f.number)()));if("error"in o)throw new et(o.error,`failed to get balance for ${e.toBase58()}`);return o.result}async getBalance(e,t){return await this.getBalanceAndContext(e,t).then(e=>e.value).catch(t=>{throw Error("failed to get balance of account "+e.toBase58()+": "+t)})}async getBlockTime(e){let t=await this._rpcRequest("getBlockTime",[e]),r=(0,f.create)(t,ek((0,f.nullable)((0,f.number)())));if("error"in r)throw new et(r.error,`failed to get block time for slot ${e}`);return r.result}async getMinimumLedgerSlot(){let e=await this._rpcRequest("minimumLedgerSlot",[]),t=(0,f.create)(e,ek((0,f.number)()));if("error"in t)throw new et(t.error,"failed to get minimum ledger slot");return t.result}async getFirstAvailableBlock(){let e=await this._rpcRequest("getFirstAvailableBlock",[]),t=(0,f.create)(e,eQ);if("error"in t)throw new et(t.error,"failed to get first available block");return t.result}async getSupply(e){let t={};t="string"==typeof e?{commitment:e}:e?{...e,commitment:e&&e.commitment||this.commitment}:{commitment:this.commitment};let r=await this._rpcRequest("getSupply",[t]),i=(0,f.create)(r,e0);if("error"in i)throw new et(i.error,"failed to get supply");return i.result}async getTokenSupply(e,t){let r=this._buildArgs([e.toBase58()],t),i=await this._rpcRequest("getTokenSupply",r),s=(0,f.create)(i,eP(e1));if("error"in s)throw new et(s.error,"failed to get token supply");return s.result}async getTokenAccountBalance(e,t){let r=this._buildArgs([e.toBase58()],t),i=await this._rpcRequest("getTokenAccountBalance",r),s=(0,f.create)(i,eP(e1));if("error"in s)throw new et(s.error,"failed to get token account balance");return s.result}async getTokenAccountsByOwner(e,t,r){let{commitment:i,config:s}=eI(r),n=[e.toBase58()];"mint"in t?n.push({mint:t.mint.toBase58()}):n.push({programId:t.programId.toBase58()});let o=this._buildArgs(n,i,"base64",s),a=await this._rpcRequest("getTokenAccountsByOwner",o),l=(0,f.create)(a,e5);if("error"in l)throw new et(l.error,`failed to get token accounts owned by account ${e.toBase58()}`);return l.result}async getParsedTokenAccountsByOwner(e,t,r){let i=[e.toBase58()];"mint"in t?i.push({mint:t.mint.toBase58()}):i.push({programId:t.programId.toBase58()});let s=this._buildArgs(i,r,"jsonParsed"),n=await this._rpcRequest("getTokenAccountsByOwner",s),o=(0,f.create)(n,e3);if("error"in o)throw new et(o.error,`failed to get token accounts owned by account ${e.toBase58()}`);return o.result}async getLargestAccounts(e){let t={...e,commitment:e&&e.commitment||this.commitment},r=t.filter||t.commitment?[t]:[],i=await this._rpcRequest("getLargestAccounts",r),s=(0,f.create)(i,e8);if("error"in s)throw new et(s.error,"failed to get largest accounts");return s.result}async getTokenLargestAccounts(e,t){let r=this._buildArgs([e.toBase58()],t),i=await this._rpcRequest("getTokenLargestAccounts",r),s=(0,f.create)(i,e2);if("error"in s)throw new et(s.error,"failed to get token largest accounts");return s.result}async getAccountInfoAndContext(e,t){let{commitment:r,config:i}=eI(t),s=this._buildArgs([e.toBase58()],r,"base64",i),n=await this._rpcRequest("getAccountInfo",s),o=(0,f.create)(n,eP((0,f.nullable)(e4)));if("error"in o)throw new et(o.error,`failed to get info about account ${e.toBase58()}`);return o.result}async getParsedAccountInfo(e,t){let{commitment:r,config:i}=eI(t),s=this._buildArgs([e.toBase58()],r,"jsonParsed",i),n=await this._rpcRequest("getAccountInfo",s),o=(0,f.create)(n,eP((0,f.nullable)(te)));if("error"in o)throw new et(o.error,`failed to get info about account ${e.toBase58()}`);return o.result}async getAccountInfo(e,t){try{return(await this.getAccountInfoAndContext(e,t)).value}catch(t){throw Error("failed to get info about account "+e.toBase58()+": "+t)}}async getMultipleParsedAccounts(e,t){let{commitment:r,config:i}=eI(t),s=e.map(e=>e.toBase58()),n=this._buildArgs([s],r,"jsonParsed",i),o=await this._rpcRequest("getMultipleAccounts",n),a=(0,f.create)(o,eP((0,f.array)((0,f.nullable)(te))));if("error"in a)throw new et(a.error,`failed to get info for accounts ${s}`);return a.result}
7async getMultipleAccountsInfoAndContext(e,t){let{commitment:r,config:i}=eI(t),s=e.map(e=>e.toBase58()),n=this._buildArgs([s],r,"base64",i),o=await this._rpcRequest("getMultipleAccounts",n),a=(0,f.create)(o,eP((0,f.array)((0,f.nullable)(e4))));if("error"in a)throw new et(a.error,`failed to get info for accounts ${s}`);return a.result}async getMultipleAccountsInfo(e,t){return(await this.getMultipleAccountsInfoAndContext(e,t)).value}async getStakeActivation(e,t,r){let{commitment:i,config:s}=eI(t),n=this._buildArgs([e.toBase58()],i,void 0,{...s,epoch:null!=r?r:s?.epoch}),o=await this._rpcRequest("getStakeActivation",n),a=(0,f.create)(o,ek(tr));if("error"in a)throw new et(a.error,`failed to get Stake Activation ${e.toBase58()}`);return a.result}async getProgramAccounts(e,t){let{commitment:r,config:i}=eI(t),{encoding:s,...n}=i||{},o=this._buildArgs([e.toBase58()],r,s||"base64",{...n,...n.filters?{filters:eA(n.filters)}:null}),a=await this._rpcRequest("getProgramAccounts",o),l=(0,f.array)(e7),c=!0===n.withContext?(0,f.create)(a,eP(l)):(0,f.create)(a,ek(l));if("error"in c)throw new et(c.error,`failed to get accounts owned by program ${e.toBase58()}`);return c.result}async getParsedProgramAccounts(e,t){let{commitment:r,config:i}=eI(t),s=this._buildArgs([e.toBase58()],r,"jsonParsed",i),n=await this._rpcRequest("getProgramAccounts",s),o=(0,f.create)(n,ek((0,f.array)(tt)));if("error"in o)throw new et(o.error,`failed to get accounts owned by program ${e.toBase58()}`);return o.result}async confirmTransaction(e,t){let r,i;if("string"==typeof e)r=e;else{if(e.abortSignal?.aborted)return Promise.reject(e.abortSignal.reason);r=e.signature}try{i=l.default.decode(r)}catch(e){throw Error("signature must be base58 encoded: "+r)}return(q(64===i.length,"signature has invalid length"),"string"==typeof e)?await this.confirmTransactionUsingLegacyTimeoutStrategy({commitment:t||this.commitment,signature:r}):"lastValidBlockHeight"in e?await this.confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:t||this.commitment,strategy:e}):await this.confirmTransactionUsingDurableNonceStrategy({commitment:t||this.commitment,strategy:e})}getCancellationPromise(e){return new Promise((t,r)=>{null!=e&&(e.aborted?r(e.reason):e.addEventListener("abort",()=>{r(e.reason)}))})}getTransactionConfirmationPromise({commitment:e,signature:t}){let r,i,s=!1;return{abortConfirmation:()=>{i&&(i(),i=void 0),null!=r&&(this.removeSignatureListener(r),r=void 0)},confirmationPromise:new Promise((n,o)=>{try{r=this.onSignature(t,(e,t)=>{r=void 0,n({__type:V.PROCESSED,response:{context:t,value:e}})},e);let a=new Promise(e=>{null==r?e():i=this._onSubscriptionStateChange(r,t=>{"subscribed"===t&&e()})});(async()=>{if(await a,s)return;
vendor: 1,816 bytes, line 7
7let r=await this.getSignatureStatus(t);if(s||null==r)return;let{context:i,value:l}=r;if(null!=l)if(l?.err)o(l.err);else{switch(e){case"confirmed":case"single":case"singleGossip":if("processed"===l.confirmationStatus)return;break;case"finalized":case"max":case"root":if("processed"===l.confirmationStatus||"confirmed"===l.confirmationStatus)return}s=!0,n({__type:V.PROCESSED,response:{context:i,value:l}})}})()}catch(e){o(e)}})}}async confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:e,strategy:{abortSignal:t,lastValidBlockHeight:r,signature:i}}){let s,n=!1,o=new Promise(t=>{let i=async()=>{try{return await this.getBlockHeight(e)}catch(e){return -1}};(async()=>{let e=await i();if(!n){for(;e<=r;)if(await ei(1e3),n||(e=await i(),n))return;t({__type:V.BLOCKHEIGHT_EXCEEDED})}})()}),{abortConfirmation:a,confirmationPromise:l}=this.getTransactionConfirmationPromise({commitment:e,signature:i}),c=this.getCancellationPromise(t);try{let e=await Promise.race([c,l,o]);if(e.__type===V.PROCESSED)s=e.response;else throw new k(i)}finally{n=!0,a()}return s}async confirmTransactionUsingDurableNonceStrategy({commitment:e,strategy:{abortSignal:t,minContextSlot:r,nonceAccountPubkey:i,nonceValue:s,signature:n}}){let o,a=!1,l=new Promise(t=>{let n=s,o=null,l=async()=>{try{let{context:t,value:s}=await this.getNonceAndContext(i,{commitment:e,minContextSlot:r});return o=t.slot,s?.nonce}catch(e){return n}};(async()=>{if(n=await l(),!a)for(;;){if(s!==n)return void t({__type:V.NONCE_INVALID,slotInWhichNonceDidAdvance:o});if(await ei(2e3),a||(n=await l(),a))return}})()}),{abortConfirmation:c,confirmationPromise:u}=this.getTransactionConfirmationPromise({commitment:e,signature:n}),d=this.getCancellationPromise(t);try{let t=await Promise.race([d,u,l]);if(t.__type===V.PROCESSED)o=t.response;else{let i;for(;;
7){let e=await this.getSignatureStatus(n);if(null==e)break;if(e.context.slot<(t.slotInWhichNonceDidAdvance??r)){await ei(400);continue}i=e;break}if(i?.value){let t=e||"finalized",{confirmationStatus:r}=i.value;switch(t){case"processed":case"recent":if("processed"!==r&&"confirmed"!==r&&"finalized"!==r)throw new O(n);break;case"confirmed":case"single":case"singleGossip":if("confirmed"!==r&&"finalized"!==r)throw new O(n);break;case"finalized":case"max":case"root":if("finalized"!==r)throw new O(n)}o={context:i.context,value:{err:i.value.err}}}else throw new O(n)}}finally{a=!0,c()}return o}async confirmTransactionUsingLegacyTimeoutStrategy({commitment:e,signature:t}){let r,i,s=new Promise(t=>{let i=this._confirmTransactionInitialTimeout||6e4;switch(e){case"processed":case"recent":case"single":case"confirmed":case"singleGossip":i=this._confirmTransactionInitialTimeout||3e4}r=setTimeout(()=>t({__type:V.TIMED_OUT,timeoutMs:i}),i)}),{abortConfirmation:n,confirmationPromise:o}=this.getTransactionConfirmationPromise({commitment:e,signature:t});try{let e=await Promise.race([o,s]);if(e.__type===V.PROCESSED)i=e.response;else throw new P(t,e.timeoutMs/1e3)}finally{clearTimeout(r),n()}return i}async getClusterNodes(){let e=await this._rpcRequest("getClusterNodes",[]),t=(0,f.create)(e,ek((0,f.array)(tp)));if("error"in t)throw new et(t.error,"failed to get cluster nodes");return t.result}async getVoteAccounts(e){let t=this._buildArgs([],e),r=await this._rpcRequest("getVoteAccounts",t),i=(0,f.create)(r,ty);if("error"in i)throw new et(i.error,"failed to get vote accounts");return i.result}async getSlot(e){let{commitment:t,config:r}=eI(e),i=this._buildArgs([],t,void 0,r),s=await this._rpcRequest("getSlot",i),n=(0,f.create)(s,ek((0,f.number)()));if("error"in n)throw new et(n.error,"failed to get slot");return n.result}async getSlotLeader(e){let{commitment:t,config:r}=eI(e),i=this._buildArgs([],t,void 0,r),s=await this._rpcRequest("getSlotLeader",i),n=(0,f.create)(s,ek((0,f.string)()));if("error"in n)throw new et(n.error,"failed to get slot leader");return n.result}async getSlotLeaders(e,t){let r=await this._rpcRequest("getSlotLeaders",[e,t]),i=(0,f.create)(r,ek((0,f.array)(e_)));if("error"in i)throw new et(i.error,"failed to get slot leaders");return i.result}async getSignatureStatus(e,t){let{context:r,value:i}
7=await this.getSignatureStatuses([e],t);return q(1===i.length),{context:r,value:i[0]}}async getSignatureStatuses(e,t){let r=[e];t&&r.push(t);let i=await this._rpcRequest("getSignatureStatuses",r),s=(0,f.create)(i,tv);if("error"in s)throw new et(s.error,"failed to get signature status");return s.result}async getTransactionCount(e){let{commitment:t,config:r}=eI(e),i=this._buildArgs([],t,void 0,r),s=await this._rpcRequest("getTransactionCount",i),n=(0,f.create)(s,ek((0,f.number)()));if("error"in n)throw new et(n.error,"failed to get transaction count");return n.result}async getTotalSupply(e){return(await this.getSupply({commitment:e,excludeNonCirculatingAccountsList:!0})).value.total}async getInflationGovernor(e){let t=this._buildArgs([],e),r=await this._rpcRequest("getInflationGovernor",t),i=(0,f.create)(r,eH);if("error"in i)throw new et(i.error,"failed to get inflation");return i.result}async getInflationReward(e,t,r){let{commitment:i,config:s}=eI(r),n=this._buildArgs([e.map(e=>e.toBase58())],i,void 0,{...s,epoch:null!=t?t:s?.epoch}),o=await this._rpcRequest("getInflationReward",n),a=(0,f.create)(o,eN);if("error"in a)throw new et(a.error,"failed to get inflation reward");return a.result}async getInflationRate(){let e=await this._rpcRequest("getInflationRate",[]),t=(0,f.create)(e,eG);if("error"in t)throw new et(t.error,"failed to get inflation rate");return t.result}async getEpochInfo(e){let{commitment:t,config:r}=eI(e),i=this._buildArgs([],t,void 0,r),s=await this._rpcRequest("getEpochInfo",i),n=(0,f.create)(s,eY);if("error"in n)throw new et(n.error,"failed to get epoch info");return n.result}async getEpochSchedule(){let e=await this._rpcRequest("getEpochSchedule",[]),t=(0,f.create)(e,eZ);if("error"in t)throw new et(t.error,"failed to get epoch schedule");let r=t.result;return new eg(r.slotsPerEpoch,r.leaderScheduleSlotOffset,r.warmup,r.firstNormalEpoch,r.firstNormalSlot)}async getLeaderSchedule(){let e=await this._rpcRequest("getLeaderSchedule",[]),t=(0,f.create)(e,eX);if("error"in t)throw new et(t.error,"failed to get leader schedule");return t.result}async getMinimumBalanceForRentExemption(e,t){let r=this._buildArgs([e],t),i=await this._rpcRequest("getMinimumBalanceForRentExemption",r),s=(0,f.create)(i,tw);return"error"in s?(console.warn("Unable to fetch minimum balance for rent exemption"),0):s.result}async getRecentBlockhashAndContext(e){let{context:t,value:{blockhash:r}}=await this.getLatestBlockhashAndContext(e);return{context:t,value:{blockhash:r,feeCalculator:{get lamportsPerSignature(){throw Error("The capability to fetch `lamportsPerSignature` using the `getRecentBlockhash` API is no longer offered by the network. Use the `getFeeForMessage` API to obtain the fee for a given message.")},toJSON:()=>({})}}}}async getRecentPerformanceSamples(e){let t=await this._rpcRequest("getRecentPerformanceSamples",e?[e]:[]),r=(0,f.create)(t,tY);if("error"in r)throw new et(r.error,"failed to get recent performance samples");return r.result}async getFeeCalculatorForBlockhash(e,t){let r=this._buildArgs([e],t),i=await this._rpcRequest("getFeeCalculatorForBlockhash",r),s=(0,f.create)(i,tZ);if("error"in s)throw new et(s.error,"failed to get fee calculator");let{context:n,value:o}=s.result;return{context:n,value:null!==o?o.feeCalculator:null}}async getFeeForMessage(e,t){let r=E(e.serialize()).toString("base64"),i=this._buildArgs([r],t),s=await this._rpcRequest("getFeeForMessage",i),n=(0,f.create)(s,eP((0,f.nullable)((0,f.number)())));if("error"in n)throw new et(n.error,"failed to get fee for message");if(null===n.result)throw Error("invalid blockhash");return n.result}async getRecentPrioritizationFees(e){let t=e?.lockedWritableAccounts?.map(e=>e.toBase58()),r=t?.length?[t]:[],i=await this._rpcRequest("getRecentPrioritizationFees",r),s=(0,f.create)(i,eJ);if("error"in s)throw new et(s.error,"failed to get recent prioritization fees");return s.result}async getRecentBlockhash(e){try{return(await this.getRecentBlockhashAndContext(e)).value}catch(e){throw Error("failed to get recent blockhash: "+e)}}async getLatestBlockhash(e){try{return(await this.getLatestBlockhashAndContext(e)).value}catch(e){throw Error("failed to get recent blockhash: "+e)}}
7async getLatestBlockhashAndContext(e){let{commitment:t,config:r}=eI(e),i=this._buildArgs([],t,void 0,r),s=await this._rpcRequest("getLatestBlockhash",i),n=(0,f.create)(s,tH);if("error"in n)throw new et(n.error,"failed to get latest blockhash");return n.result}async isBlockhashValid(e,t){let{commitment:r,config:i}=eI(t),s=this._buildArgs([e],r,void 0,i),n=await this._rpcRequest("isBlockhashValid",s),o=(0,f.create)(n,tG);if("error"in o)throw new et(o.error,"failed to determine if the blockhash `"+e+"`is valid");return o.result}async getVersion(){let e=await this._rpcRequest("getVersion",[]),t=(0,f.create)(e,ek(ez));if("error"in t)throw new et(t.error,"failed to get version");return t.result}async getGenesisHash(){let e=await this._rpcRequest("getGenesisHash",[]),t=(0,f.create)(e,ek((0,f.string)()));if("error"in t)throw new et(t.error,"failed to get genesis hash");return t.result}async getBlock(e,t){let{commitment:r,config:i}=eI(t),s=this._buildArgsAtLeastConfirmed([e],r,void 0,i),n=await this._rpcRequest("getBlock",s);try{switch(i?.transactionDetails){case"accounts":{let e=(0,f.create)(n,tM);if("error"in e)throw e.error;return e.result}case"none":{let e=(0,f.create)(n,tD);if("error"in e)throw e.error;return e.result}default:{let e=(0,f.create)(n,tL);if("error"in e)throw e.error;let{result:t}=e;return t?{...t,transactions:t.transactions.map(({transaction:e,meta:t,version:r})=>({meta:t,transaction:{...e,message:eR(r,e.message)},version:r}))}:null}}}catch(e){throw new et(e,"failed to get confirmed block")}}async getParsedBlock(e,t){let{commitment:r,config:i}=eI(t),s=this._buildArgsAtLeastConfirmed([e],r,"jsonParsed",i),n=await this._rpcRequest("getBlock",s);try{switch(i?.transactionDetails){case"accounts":{let e=(0,f.create)(n,tW);if("error"in e)throw e.error;return e.result}case"none":{let e=(0,f.create)(n,tz);if("error"in e)throw e.error;return e.result}default:{let e=(0,f.create)(n,tK);if("error"in e)throw e.error;return e.result}}}catch(e){throw new et(e,"failed to get block")}}async getBlockProduction(e){let t,r;if("string"==typeof e)r=e;
7else if(e){let{commitment:i,...s}=e;r=i,t=s}let i=this._buildArgs([],r,"base64",t),s=await this._rpcRequest("getBlockProduction",i),n=(0,f.create)(s,eF);if("error"in n)throw new et(n.error,"failed to get block production information");return n.result}async getTransaction(e,t){let{commitment:r,config:i}=eI(t),s=this._buildArgsAtLeastConfirmed([e],r,void 0,i),n=await this._rpcRequest("getTransaction",s),o=(0,f.create)(n,t$);if("error"in o)throw new et(o.error,"failed to get transaction");let a=o.result;return a?{...a,transaction:{...a.transaction,message:eR(a.version,a.transaction.message)}}:a}async getParsedTransaction(e,t){let{commitment:r,config:i}=eI(t),s=this._buildArgsAtLeastConfirmed([e],r,"jsonParsed",i),n=await this._rpcRequest("getTransaction",s),o=(0,f.create)(n,tF);if("error"in o)throw new et(o.error,"failed to get transaction");return o.result}async getParsedTransactions(e,t){let{commitment:r,config:i}=eI(t),s=e.map(e=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([e],r,"jsonParsed",i)}));return(await this._rpcBatchRequest(s)).map(e=>{let t=(0,f.create)(e,tF);if("error"in t)throw new et(t.error,"failed to get transactions");return t.result})}async getTransactions(e,t){let{commitment:r,config:i}=eI(t),s=e.map(e=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([e],r,void 0,i)}));return(await this._rpcBatchRequest(s)).map(e=>{let t=(0,f.create)(e,t$);if("error"in t)throw new et(t.error,"failed to get transactions");let r=t.result;return r?{...r,transaction:{...r.transaction,message:eR(r.version,r.transaction.message)}}:r})}async getConfirmedBlock(e,t){let r=this._buildArgsAtLeastConfirmed([e],t),i=await this._rpcRequest("getBlock",r),s=(0,f.create)(i,tj);if("error"in s)throw new et(s.error,"failed to get confirmed block");let n=s.result;if(!n)throw Error("Confirmed block "+e+" not found");let o={...n,transactions:n.transactions.map(({transaction:e,meta:t})=>{let r=new W(e.message);return{meta:t,transaction:{...e,message:r}}})};return{...o,transactions:o.transactions.map(({transaction:e,meta:t})=>({meta:t,transaction:H.populate(e.message,e.signatures)}))}}async getBlocks(e,t,r){let i=this._buildArgsAtLeastConfirmed(void 0!==t?[e,t]:[e],r),s=await this._rpcRequest("getBlocks",i),n=(0,f.create)(s,ek((0,f.array)((0,f.number)())));if("error"in n)throw new et(n.error,"failed to get blocks");return n.result}async getBlockSignatures(e,t){let r=this._buildArgsAtLeastConfirmed([e],t,void 0,{transactionDetails:"signatures",rewards:!1}),i=await this._rpcRequest("getBlock",r),s=(0,f.create)(i,tV);if("error"in s)throw new et(s.error,"failed to get block");let n=s.result;if(!n)throw Error("Block "+e+" not found");return n}async getConfirmedBlockSignatures(e,t){let r=this._buildArgsAtLeastConfirmed([e],t,void 0,{transactionDetails:"signatures",rewards:!1}),i=await this._rpcRequest("getBlock",r),s=(0,f.create)(i,tV);if("error"in s)throw new et(s.error,"failed to get confirmed block");let n=s.result;if(!n)throw Error("Confirmed block "+e+" not found");return n}async getConfirmedTransaction(e,t){let r=this._buildArgsAtLeastConfirmed([e],t),i=await this._rpcRequest("getTransaction",r),s=(0,f.create)(i,t$);if("error"in s)throw new et(s.error,"failed to get transaction");let n=s.result;if(!n)return n;let o=new W(n.transaction.message),a=n.transaction.signatures;return{...n,transaction:H.populate(o,a)}}async getParsedConfirmedTransaction(e,t){let r=this._buildArgsAtLeastConfirmed([e],t,"jsonParsed"),i=await this._rpcRequest("getTransaction",r),s=(0,f.create)(i,tF);if("error"in s)throw new et(s.error,"failed to get confirmed transaction");return s.result}async getParsedConfirmedTransactions(e,t){let r=e.map(e=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([e],t,"jsonParsed")}));return(await this._rpcBatchRequest(r)).map(e=>{let t=(0,f.create)(e,tF);if("error"in t)throw new et(t.error,"failed to get confirmed transactions");return t.result})}async getConfirmedSignaturesForAddress(e,t,r){let i={},s=await this.getFirstAvailableBlock();for(;!("until"in i)&&!(--t<=0)&&!(t<s);)try{let e=await this.getConfirmedBlockSignatures(t,"finalized");
vendor: 13,917 bytes, line 7
7e.signatures.length>0&&(i.until=e.signatures[e.signatures.length-1].toString())}catch(e){if(e instanceof Error&&e.message.includes("skipped"))continue;throw e}let n=await this.getSlot("finalized");for(;!("before"in i)&&!(++r>n);)try{let e=await this.getConfirmedBlockSignatures(r);e.signatures.length>0&&(i.before=e.signatures[e.signatures.length-1].toString())}catch(e){if(e instanceof Error&&e.message.includes("skipped"))continue;throw e}return(await this.getConfirmedSignaturesForAddress2(e,i)).map(e=>e.signature)}async getConfirmedSignaturesForAddress2(e,t,r){let i=this._buildArgsAtLeastConfirmed([e.toBase58()],r,void 0,t),s=await this._rpcRequest("getConfirmedSignaturesForAddress2",i),n=(0,f.create)(s,ti);if("error"in n)throw new et(n.error,"failed to get confirmed signatures for address");return n.result}async getSignaturesForAddress(e,t,r){let i=this._buildArgsAtLeastConfirmed([e.toBase58()],r,void 0,t),s=await this._rpcRequest("getSignaturesForAddress",i),n=(0,f.create)(s,ts);if("error"in n)throw new et(n.error,"failed to get signatures for address");return n.result}async getAddressLookupTable(e,t){let{context:r,value:i}=await this.getAccountInfoAndContext(e,t),s=null;return null!==i&&(s=new eb({key:e,state:eb.deserialize(i.data)})),{context:r,value:s}}async getNonceAndContext(e,t){let{context:r,value:i}=await this.getAccountInfoAndContext(e,t),s=null;return null!==i&&(s=el.fromAccountData(i.data)),{context:r,value:s}}async getNonce(e,t){return await this.getNonceAndContext(e,t).then(e=>e.value).catch(t=>{throw Error("failed to get nonce for account "+e.toBase58()+": "+t)})}async requestAirdrop(e,t){let r=await this._rpcRequest("requestAirdrop",[e.toBase58(),t]),i=(0,f.create)(r,tX);if("error"in i)throw new et(i.error,`airdrop to ${e.toBase58()} failed`);return i.result}async _blockhashWithExpiryBlockHeight(e){if(!e){for(;this._pollingBlockhash;)await ei(100);let e=Date.now()-this._blockhashInfo.lastFetch;if(null!==this._blockhashInfo.latestBlockhash&&!(e>=3e4))return this._blockhashInfo.latestBlockhash}return await this._pollNewBlockhash()}async _pollNewBlockhash(){this._pollingBlockhash=!0;try{let e=Date.now(),t=this._blockhashInfo.latestBlockhash,r=t?t.blockhash:null;for(let e=0;e<50;e++){let e=await this.getLatestBlockhash("finalized");if(r!==e.blockhash)return this._blockhashInfo={latestBlockhash:e,lastFetch:Date.now(),transactionSignatures:[],simulatedSignatures:[]},e;await ei(200)}throw Error(`Unable to obtain a new blockhash after ${Date.now()-e}ms`)}finally{this._pollingBlockhash=!1}}async getStakeMinimumDelegation(e){let{commitment:t,config:r}=eI(e),i=this._buildArgs([],t,"base64",r),s=await this._rpcRequest("getStakeMinimumDelegation",i),n=(0,f.create)(s,eP((0,f.number)()));if("error"in n)throw new et(n.error,"failed to get stake minimum delegation");return n.result}async simulateTransaction(e,t,r){let i;if("message"in e){let i=e.serialize(),s=n.Buffer.from(i).toString("base64");if(Array.isArray(t)||void 0!==r)throw Error("Invalid arguments");let o=t||{};o.encoding="base64","commitment"in o||(o.commitment=this.commitment),t&&"object"==typeof t&&"innerInstructions"in t&&(o.innerInstructions=t.innerInstructions);let a=[s,o],l=await this._rpcRequest("simulateTransaction",a),c=(0,f.create)(l,e$);if("error"in c)throw Error("failed to simulate transaction: "+c.error.message);return c.result}if(e instanceof H?((i=new H).feePayer=e.feePayer,i.instructions=e.instructions,i.nonceInfo=e.nonceInfo,i.signatures=e.signatures):(i=H.populate(e))._message=i._json=void 0,void 0!==t&&!Array.isArray(t))throw Error("Invalid arguments");if(i.nonceInfo&&t)i.sign(...t);else{let e=this._disableBlockhashCaching;for(;;){let r=await this._blockhashWithExpiryBlockHeight(e);if(i.lastValidBlockHeight=r.lastValidBlockHeight,i.recentBlockhash=r.blockhash,!t)break;if(i.sign(...t),!i.signature)throw Error("!signature");let s=i.signature.toString("base64");if(this._blockhashInfo.simulatedSignatures.includes(s)||this._blockhashInfo.transactionSignatures.includes(s))e=!0;else{this._blockhashInfo.simulatedSignatures.push(s);break}}}let s=i._compile(),o=s.serialize(),a=i._serialize(o).toString("base64"),l={encoding:"base64",commitment:this.commitment};r&&(l.accounts={encoding:"base64",addresses:(Array.isArray(r)?r:s.nonProgramIds()).map(e=>e.toBase58())}),t&&(l.sigVerify=!0),t&&"object"==typeof t&&"innerInstructions"in t&&(l.innerInstructions=t.innerInstructions);let c=[a,l],u=await this._rpcRequest("simulateTransaction",c),d=(0,f.create)(u,e$);if("error"in d){let e;if("data"in d.error&&(e=d.error.data.logs)&&Array.isArray(e)){let t="\n    ",r=t+e.join(t);console.error(d.error.message,r)}throw new ee({action:"simulate",signature:"",transactionMessage:d.error.message,logs:e})}return d.result}async sendTransaction(e,t,r){if("version"in e){if(t&&Array.isArray(t))throw Error("Invalid arguments");let r=e.serialize();return await this.sendRawTransaction(r,t)}if(void 0===t||!Array.isArray(t))throw Error("Invalid arguments");if(e.nonceInfo)e.sign(...t);else{let r=this._disableBlockhashCaching;for(;;){let i=await this._blockhashWithExpiryBlockHeight(r);if(e.lastValidBlockHeight=i.lastValidBlockHeight,e.recentBlockhash=i.blockhash,e.sign(...t),!e.signature)throw Error("!signature");let s=e.signature.toString("base64");if(this._blockhashInfo.transactionSignatures.includes(s))r=!0;else{this._blockhashInfo.transactionSignatures.push(s);break}}}let i=e.serialize();return await this.sendRawTransaction(i,r)}async sendRawTransaction(e,t){let r=E(e).toString("base64");return await this.sendEncodedTransaction(r,t)}async sendEncodedTransaction(e,t){let r={encoding:"base64"},i=t&&t.skipPreflight,s=!0===i?"processed":t&&t.preflightCommitment||this.commitment;t&&null!=t.maxRetries&&(r.maxRetries=t.maxRetries),t&&null!=t.minContextSlot&&(r.minContextSlot=t.minContextSlot),i&&(r.skipPreflight=i),s&&(r.preflightCommitment=s);let n=[e,r],o=await this._rpcRequest("sendTransaction",n),a=(0,f.create)(o,tQ);if("error"in a){let e;throw"data"in a.error&&(e=a.error.data.logs),new ee({action:i?"send":"simulate",signature:"",transactionMessage:a.error.message,logs:e})}return a.result}_wsOnOpen(){this._rpcWebSocketConnected=!0,this._rpcWebSocketHeartbeat=setInterval(()=>{(async()=>{try{await this._rpcWebSocket.notify("ping")}catch{}})()},5e3),this._updateSubscriptions()}_wsOnError(e){this._rpcWebSocketConnected=!1,console.error("ws error:",e.message)}_wsOnClose(e){(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===e)?this._updateSubscriptions():(this._subscriptionCallbacksByServerSubscriptionId={},Object.entries(this._subscriptionsByHash).forEach(([e,t])=>{this._setSubscription(e,{...t,state:"pending"})}))}_setSubscription(e,t){let r=this._subscriptionsByHash[e]?.state;if(this._subscriptionsByHash[e]=t,r!==t.state){let r=this._subscriptionStateChangeCallbacksByHash[e];r&&r.forEach(e=>{try{e(t.state)}catch{}})}}_onSubscriptionStateChange(e,t){let r=this._subscriptionHashByClientSubscriptionId[e];if(null==r)return()=>{};let i=this._subscriptionStateChangeCallbacksByHash[r]||=new Set;return i.add(t),()=>{i.delete(t),0===i.size&&delete this._subscriptionStateChangeCallbacksByHash[r]}}async _updateSubscriptions(){if(0===Object.keys(this._subscriptionsByHash).length){this._rpcWebSocketConnected&&(this._rpcWebSocketConnected=!1,this._rpcWebSocketIdleTimeout=setTimeout(()=>{this._rpcWebSocketIdleTimeout=null;try{this._rpcWebSocket.close()}catch(e){e instanceof Error&&console.log(`Error when closing socket connection: ${e.message}`)}},500));return}if(null!==this._rpcWebSocketIdleTimeout&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketConnected=!0),!this._rpcWebSocketConnected)return void this._rpcWebSocket.connect();let e=this._rpcWebSocketGeneration,t=()=>e===this._rpcWebSocketGeneration;await Promise.all(Object.keys(this._subscriptionsByHash).map(async e=>{let r=this._subscriptionsByHash[e];if(void 0!==r)switch(r.state){case"pending":case"unsubscribed":if(0===r.callbacks.size){delete this._subscriptionsByHash[e],"unsubscribed"===r.state&&delete this._subscriptionCallbacksByServerSubscriptionId[r.serverSubscriptionId],await this._updateSubscriptions();return}await (async()=>{let{args:i,method:s}=r;try{this._setSubscription(e,{...r,state:"subscribing"});let t=await this._rpcWebSocket.call(s,i);this._setSubscription(e,{...r,serverSubscriptionId:t,state:"subscribed"}),this._subscriptionCallbacksByServerSubscriptionId[t]=r.callbacks,await this._updateSubscriptions()}catch(n){if(console.error(`Received ${n instanceof Error?"":"JSON-RPC "}error calling \`${s}\``,{args:i,error:n}),!t())return;this._setSubscription(e,{...r,state:"pending"}),await this._updateSubscriptions()}})();break;case"subscribed":0===r.callbacks.size&&await (async()=>{let{serverSubscriptionId:i,unsubscribeMethod:s}=r;if(this._subscriptionsAutoDisposedByRpc.has(i))this._subscriptionsAutoDisposedByRpc.delete(i);else{this._setSubscription(e,{...r,state:"unsubscribing"}),this._setSubscription(e,{...r,state:"unsubscribing"});try{await this._rpcWebSocket.call(s,[i])}catch(i){if(i instanceof Error&&console.error(`${s} error:`,i.message),!t())return;this._setSubscription(e,{...r,state:"subscribed"}),await this._updateSubscriptions();return}}this._setSubscription(e,{...r,state:"unsubscribed"}),await this._updateSubscriptions()})()}}))}_handleServerNotification(e,t){let r=this._subscriptionCallbacksByServerSubscriptionId[e];void 0!==r&&r.forEach(e=>{try{e(...t)}catch(e){console.error(e)}})}_wsOnAccountNotification(e){let{result:t,subscription:r}=(0,f.create)(e,tn);this._handleServerNotification(r,[t.value,t.context])}_makeSubscription(e,t){let r=this._nextClientSubscriptionId++,i=ef([e.method,t]),s=this._subscriptionsByHash[i];return void 0===s?this._subscriptionsByHash[i]={...e,args:t,callbacks:new Set([e.callback]),state:"pending"}:s.callbacks.add(e.callback),this._subscriptionHashByClientSubscriptionId[r]=i,this._subscriptionDisposeFunctionsByClientSubscriptionId[r]=async()=>{delete this._subscriptionDisposeFunctionsByClientSubscriptionId[r],delete this._subscriptionHashByClientSubscriptionId[r];let t=this._subscriptionsByHash[i];q(void 0!==t,`Could not find a \`Subscription\` when tearing down client subscription #${r}`),t.callbacks.delete(e.callback),await this._updateSubscriptions()},this._updateSubscriptions(),r}onAccountChange(e,t,r){let{commitment:i,config:s}=eI(r),n=this._buildArgs([e.toBase58()],i||this._commitment||"finalized","base64",s);return this._makeSubscription({callback:t,method:"accountSubscribe",unsubscribeMethod:"accountUnsubscribe"},n)}async removeAccountChangeListener(e){await this._unsubscribeClientSubscription(e,"account change")}_wsOnProgramAccountNotification(e){let{result:t,subscription:r}=(0,f.create)(e,ta);this._handleServerNotification(r,[{accountId:t.value.pubkey,accountInfo:t.value.account},t.context])}onProgramAccountChange(e,t,r,i){let{commitment:s,config:n}=eI(r),o=this._buildArgs([e.toBase58()],s||this._commitment||"finalized","base64",n||(i?{filters:eA(i)}:void 0));return this._makeSubscription({callback:t,method:"programSubscribe",unsubscribeMethod:"programUnsubscribe"},o)}async removeProgramAccountChangeListener(e){await this._unsubscribeClientSubscription(e,"program account change")}onLogs(e,t,r){let i=this._buildArgs(["object"==typeof e?{mentions:[e.toString()]}:e],r||this._commitment||"finalized");return this._makeSubscription({callback:t,method:"logsSubscribe",unsubscribeMethod:"logsUnsubscribe"},i)}async removeOnLogsListener(e){await this._unsubscribeClientSubscription(e,"logs")}_wsOnLogsNotification(e){let{result:t,subscription:r}=(0,f.create)(e,t1);this._handleServerNotification(r,[t.value,t.context])}_wsOnSlotNotification(e){let{result:t,subscription:r}=(0,f.create)(e,tc);this._handleServerNotification(r,[t])}onSlotChange(e){return this._makeSubscription({callback:e,method:"slotSubscribe",unsubscribeMethod:"slotUnsubscribe"},[])}async removeSlotChangeListener(e){await this._unsubscribeClientSubscription(e,"slot change")}_wsOnSlotUpdatesNotification(e){let{result:t,subscription:r}=(0,f.create)(e,td);this._handleServerNotification(r,[t])}onSlotUpdate(e){return this._makeSubscription({callback:e,method:"slotsUpdatesSubscribe",unsubscribeMethod:"slotsUpdatesUnsubscribe"},[])}async removeSlotUpdateListener(e){await this._unsubscribeClientSubscription(e,"slot update")}async _unsubscribeClientSubscription(e,t){let r=this._subscriptionDisposeFunctionsByClientSubscriptionId[e];r?await r():console.warn(`Ignored unsubscribe request because an active subscription with id \`${e}\` for '${t}' events could not be found.`)}_buildArgs(e,t,r,i){let s=t||this._commitment;if(s||r||i){let t={};r&&(t.encoding=r),s&&(t.commitment=s),i&&(t=Object.assign(t,i)),e.push(t)}return e}_buildArgsAtLeastConfirmed(e,t,r,i){let s=t||this._commitment;if(s&&!["confirmed","finalized"].includes(s))throw Error("Using Connection with default commitment: `"+this._commitment+"`, but method requires at least `confirmed`");return this._buildArgs(e,t,r,i)}_wsOnSignatureNotification(e){let{result:t,subscription:r}=(0,f.create)(e,th);"receivedSignature"!==t.value&&this._subscriptionsAutoDisposedByRpc.add(r),this._handleServerNotification(r,"receivedSignature"===t.value?[{type:"received"},t.context]:[{type:"status",result:t.value},t.context])}onSignature(e,t,r){let i=this._buildArgs([e],r||this._commitment||"finalized"),s=this._makeSubscription({callback:(e,r)=>{if("status"===e.type){t(e.result,r);try{this.removeSignatureListener(s)}catch(e){}}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},i);return s}
7onSignatureWithOptions(e,t,r){let{commitment:i,...s}={...r,commitment:r&&r.commitment||this._commitment||"finalized"},n=this._buildArgs([e],i,void 0,s),o=this._makeSubscription({callback:(e,r)=>{t(e,r);try{this.removeSignatureListener(o)}catch(e){}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},n);return o}async removeSignatureListener(e){await this._unsubscribeClientSubscription(e,"signature result")}_wsOnRootNotification(e){let{result:t,subscription:r}=(0,f.create)(e,tf);this._handleServerNotification(r,[t])}onRootChange(e){return this._makeSubscription({callback:e,method:"rootSubscribe",unsubscribeMethod:"rootUnsubscribe"},[])}async removeRootChangeListener(e){await this._unsubscribeClientSubscription(e,"root change")}},"LAMPORTS_PER_SOL",0,1e9,"PublicKey",0,x,"SystemProgram",0,ed,"Transaction",0,H,"TransactionInstruction",0,F,"TransactionMessage",0,G,"VersionedTransaction",0,J])},678105,e=>{"use strict";e.s(["isLedgerAddressViaVerifiedCredentials",0,(e,t)=>t.filter(e=>{var t;return(null==(t=e.walletProperties)?void 0:t.hardwareWallet)==="ledger"}).map(e=>e.address).includes(e)])},83950,e=>{"use strict";var t=e.i(624211);class r extends t.DynamicError{constructor(e="Not supported",t="not_supported"){super(e,t)}}e.s(["NotSupportedError",0,r])},787458,e=>{"use strict";e.s(["cloneObjectWithOverrides",0,(e,t={})=>{var r,i;let s=Object.getOwnPropertyDescriptors(e),n=Object.create(Object.getPrototypeOf(e));for(let[e,o]of Object.entries(t))Object.defineProperty(n,e,{configurable:!0,enumerable:null==(i=null==(r=s[e])?void 0:r.enumerable)||i,value:o,writable:!0});let o=Object.keys(t);for(let[e,t]of Object.entries(s))o.includes(e)||Object.defineProperty(n,e,t);return n}])},422876,e=>{"use strict";var t=e.i(127261);let r=new t.PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"),i=new t.PublicKey("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"),s=new t.PublicKey("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL");new t.PublicKey("So11111111111111111111111111111111111111112"),new t.PublicKey("9pan9bMn5HatX4EJdBwg9VgCa7Uz5HL8N1m5D3NdXejP"),e.s(["ASSOCIATED_TOKEN_PROGRAM_ID",0,s,"TOKEN_2022_PROGRAM_ID",0,i,"TOKEN_PROGRAM_ID",0,r])},201238,(e,t,r)=>{"use strict";var i=e.i(467034);Object.defineProperty(r,"__esModule",{value:!0}),r.toBigIntLE=function(e){{let t=i.Buffer.from(e);t.reverse();let r=t.toString("hex");return 0===r.length?BigInt(0):BigInt(`0x${r}`)}},r.toBigIntBE=function(e){{let t=e.toString("hex");return 0===t.length?BigInt(0):BigInt(`0x${t}`)}},r.toBufferLE=function(e,t){{let r=e.toString(16),s=i.Buffer.from(r.padStart(2*t,"0").slice(0,2*t),"hex");return s.reverse(),s}},r.toBufferBE=function(e,t){{let r=e.toString(16);return i.Buffer.from(r.padStart(2*t,"0").slice(0,2*t),"hex")}}},829877,e=>{"use strict";e.s(["encodeDecode",0,e=>({decode:e.decode.bind(e),encode:e.encode.bind(e)})])},107522,e=>{"use strict";var t=e.i(467034),r=e.i(444610),i=e.i(201238),s=e.i(829877);let n=e=>n=>{let o=(0,r.blob)(e,n),{encode:a,decode:l}=(0,s.encodeDecode)(o);return o.decode=(e,r)=>{let s=l(e,r);return(0,i.toBigIntLE)(t.Buffer.from(s))},o.encode=(t,r,s)=>a((0,i.toBufferLE)(t,e),r,s),o},o=e=>n=>{let o=(0,r.blob)(e,n),{encode:a,decode:l}=(0,s.encodeDecode)(o);return o.decode=(e,r)=>{let s=l(e,r);return(0,i.toBigIntBE)(t.Buffer.from(s))},o.encode=(t,r,s)=>a((0,i.toBufferBE)(t,e),r,s),o},a=n(8);o(8);let l=n(16);o(16),n(24),o(24),n(32),o(32),e.s(["u128",0,l,"u64",0,a])},828073,e=>{"use strict";var t=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,r=Math.ceil,i=Math.floor,s="[BigNumber Error] ",n=s+"Number primitive has more than 15 significant digits: ",o=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13];function a(e){var t=0|e;return e>0||e===t?t:t-1}function l(e){for(var t,r,i=1,s=e.length,n=e[0]+"";i<s;){for(r=14-(t=e[i++]+"").length;r--;t="0"+t);n+=t}for(s=n.length;48===n.charCodeAt(--s););return n.slice(0,s+1||1)}function c(e,t){var r,i,s=e.c,n=t.c,o=e.s,a=t.s,l=e.e,c=t.e;if(!o||!a)return null;if(r=s&&!s[0],i=n&&!n[0],r||i)return r?i?0:-a:o;if(o!=a)return o;if(r=o<0,i=l==c,!s||!n)return i?0:!s^r?1:-1;if(!i)return l>c^r?1:-1;for(o=0,a=(l=s.length)<(c=n.length)?l:c;o<a;o++)if(s[o]!=n[o])return s[o]>n[o]^r?1:-1;return l==c?0:l>c^r?1:-1}function u(e,t,r,n){if(e<t||e>r||e!==i(e))throw Error(s+(n||"Argument")+("number"==typeof e?e<t||e>r?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function d(e){var t=e.c.length-1;return a(e.e/14)==t&&e.c[t]%2!=0}function h(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function f(e,t,r){var i,s;if(t<0){for(s=r+".";++t;s+=r);e=s+e}else if(i=e.length,++t>i){for(s=r,t-=i;--t;s+=r);e+=s}else t<i&&(e=e.slice(0,t)+"."+e.slice(t));return e}var p=function e(p){var g,y,m,b,v,w,_,S,E,I=D.prototype={constructor:D,toString:null,valueOf:null},A=new D(1),T=20,x=4,k=-7,P=21,O=-1e7,R=1e7,C=!1,N=1,B=0,U={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},q="0123456789abcdefghijklmnopqrstuvwxyz",L=!0;function D(e,r){var s,o,a,l,c,d,h,f,p=this;if(!(p instanceof D))return new D(e,r);if(null==r){if(e&&!0===e._isBigNumber){p.s=e.s,!e.c||e.e>R?p.c=p.e=null:e.e<O?p.c=[p.e=0]:(p.e=e.e,p.c=e.c.slice());return}if((d="number"==typeof e)&&0*e==0){if(p.s=1/e<0?(e=-e,-1):1,e===~~e){for(l=0,c=e;c>=10;c/=10,l++);l>R?p.c=p.e=null:(p.e=l,p.c=[e]);return}f=String(e)}else{if(!t.test(f=String(e)))return E(p,f,d);p.s=45==f.charCodeAt(0)?(f=f.slice(1),-1):1}(l=f.indexOf("."))>-1&&(f=f.replace(".","")),(c=f.search(/e/i))>0?(l<0&&(l=c),l+=+f.slice(c+1),f=f.substring(0,c)):l<0&&(l=f.length)}else{if(u(r,2,q.length,"Base"),10==r&&L)return z(p=new D(e),T+p.e+1,x);if(f=String(e),d="number"==typeof e){if(0*e!=0)return E(p,f,d,r);if(p.s=1/e<0?(f=f.slice(1),-1):1,D.DEBUG&&f.replace(/^0\.0*|\./,"").length>15)throw Error(n+e)}else p.s=45===f.charCodeAt(0)?(f=f.slice(1),-1):1;for(s=q.slice(0,r),l=c=0,h=f.length;c<h;c++)if(0>
7s.indexOf(o=f.charAt(c))){if("."==o){if(c>l){l=h;continue}}else if(!a&&(f==f.toUpperCase()&&(f=f.toLowerCase())||f==f.toLowerCase()&&(f=f.toUpperCase()))){a=!0,c=-1,l=0;continue}return E(p,String(e),d,r)}d=!1,(l=(f=S(f,r,10,p.s)).indexOf("."))>-1?f=f.replace(".",""):l=f.length}for(c=0;48===f.charCodeAt(c);c++);for(h=f.length;48===f.charCodeAt(--h););if(f=f.slice(c,++h)){if(h-=c,d&&D.DEBUG&&h>15&&(e>0x1fffffffffffff||e!==i(e)))throw Error(n+p.s*e);if((l=l-c-1)>R)p.c=p.e=null;else if(l<O)p.c=[p.e=0];else{if(p.e=l,p.c=[],c=(l+1)%14,l<0&&(c+=14),c<h){for(c&&p.c.push(+f.slice(0,c)),h-=14;c<h;)p.c.push(+f.slice(c,c+=14));c=14-(f=f.slice(c)).length}else c-=h;for(;c--;f+="0");p.c.push(+f)}}else p.c=[p.e=0]}function M(e,t,r,i){var s,n,o,a,c;if(null==r?r=x:u(r,0,8),!e.c)return e.toString();if(s=e.c[0],o=e.e,null==t)c=l(e.c),c=1==i||2==i&&(o<=k||o>=P)?h(c,o):f(c,o,"0");else if(n=(e=z(new D(e),t,r)).e,a=(c=l(e.c)).length,1==i||2==i&&(t<=n||n<=k)){for(;a<t;c+="0",a++);c=h(c,n)}else if(t-=o+(2===i&&n>o),c=f(c,n,"0"),n+1>a){if(--t>0)for(c+=".";t--;c+="0");}else if((t+=n-a)>0)for(n+1==a&&(c+=".");t--;c+="0");return e.s<0&&s?"-"+c:c}function K(e,t){for(var r,i,s=1,n=new D(e[0]);s<e.length;s++)(i=new D(e[s])).s&&(r=c(n,i))!==t&&(0!==r||n.s!==t)||(n=i);return n}function W(e,t,r){for(var i=1,s=t.length;!t[--s];t.pop());for(s=t[0];s>=10;s/=10,i++);return(r=i+14*r-1)>R?e.c=e.e=null:r<O?e.c=[e.e=0]:(e.e=r,e.c=t),e}function z(e,t,s,n){var a,l,c,u,d,h,f,p=e.c;if(p){e:{for(a=1,u=p[0];u>=10;u/=10,a++);if((l=t-a)<0)l+=14,c=t,f=i((d=p[h=0])/o[a-c-1]%10);else if((h=r((l+1)/14))>=p.length)if(n){for(;p.length<=h;p.push(0));d=f=0,a=1,l%=14,c=l-14+1}else break e;else{for(a=1,d=u=p[h];u>=10;u/=10,a++);l%=14,f=(c=l-14+a)<0?0:i(d/o[a-c-1]%10)}if(n=n||t<0||null!=p[h+1]||(c<0?d:d%o[a-c-1]),n=s<4?(f||n)&&(0==s||s==(e.s<0?3:2)):f>5||5==f&&(4==s||n||6==s&&(l>0?c>0?d/o[a-c]:0:p[h-1])%10&1||s==(e.s<0?8:7)),t<1||!p[0])return p.length=0,n?(t-=e.e+1,p[0]=o[(14-t%14)%14],e.e=-t||0):p[0]=e.e=0,e;if(0==l?(p.length=h,u=1,h--):(p.length=h+1,u=o[14-l],p[h]=c>0?i(d/o[a-c]%o[c])*u:0),n)for(;;)if(0==h){for(l=1,c=p[0];c>=10;c/=10,l++);for(c=p[0]+=u,u=1;c>=10;c/=10,u++);l!=u&&(e.e++,1e14==p[0]&&(p[0]=1));break}else{if(p[h]+=u,1e14!=p[h])break;p[h--]=0,u=1}for(l=p.length;0===p[--l];p.pop());}e.e>R?e.c=e.e=null:e.e<O&&(e.c=[e.e=0])}return e}function j(e){var t,r=e.e;return null===r?e.toString():(t=l(e.c),t=r<=k||r>=P?h(t,r):f(t,r,"0"),e.s<0?"-"+t:t)}return D.clone=e,D.ROUND_UP=0,D.ROUND_DOWN=1,D.ROUND_CEIL=2,D.ROUND_FLOOR=3,D.ROUND_HALF_UP=4,D.ROUND_HALF_DOWN=5,D.ROUND_HALF_EVEN=6,D.ROUND_HALF_CEIL=7,D.ROUND_HALF_FLOOR=8,D.EUCLID=9,D.config=D.set=function(e){var t,r;if(null!=e)if("object"==typeof e){if(e.hasOwnProperty(t="DECIMAL_PLACES")&&(u(r=e[t],0,1e9,t),T=r),e.hasOwnProperty(t="ROUNDING_MODE")&&(u(r=e[t],0,8,t),x=r),e.hasOwnProperty(t="EXPONENTIAL_AT")&&((r=e[t])&&r.pop?(u(r[0],-1e9,0,t),u(r[1],0,1e9,t),k=r[0],P=r[1]):(u(r,-1e9,1e9,t),k=-(P=r<0?-r:r))),e.hasOwnProperty(t="RANGE"))if((r=e[t])&&r.pop)u(r[0],-1e9,-1,t),u(r[1],1,1e9,t),O=r[0],R=r[1];else if(u(r,-1e9,1e9,t),r)O=-(R=r<0?-r:r);else throw Error(s+t+" cannot be zero: "+r);if(e.hasOwnProperty(t="CRYPTO"))if(!!(r=e[t])===r)if(r)if("u">typeof crypto&&crypto&&(crypto.getRandomValues||crypto.randomBytes))C=r;else throw C=!r,Error(s+"crypto unavailable");else C=r;else throw Error(s+t+" not true or false: "+r);if(e.hasOwnProperty(t="MODULO_MODE")&&(u(r=e[t],0,9,t),N=r),e.hasOwnProperty(t="POW_PRECISION")&&(u(r=e[t],0,1e9,t),B=r),e.hasOwnProperty(t="FORMAT"))if("object"==typeof(r=e[t]))U=r;else throw Error(s+t+" not an object: "+r);if(e.hasOwnProperty(t="ALPHABET")){if("string"!=typeof(r=e[t])||/^.?$|[+\-.\s]|(.).*\1/.test(r))throw Error(s+t+" invalid: "+r);L="0123456789"==r.slice(0,10),q=r}}else throw Error(s+"Object expected: "+e);return{DECIMAL_PLACES:T,ROUNDING_MODE:x,EXPONENTIAL_AT:[k,P],RANGE:[O,R],CRYPTO:C,MODULO_MODE:N,POW_PRECISION:B,FORMAT:U,ALPHABET:q}},D.isBigNumber=function(e){if(!e||!0!==e._isBigNumber)return!1;if(!D.DEBUG)return!0;var t,r,n=e.c,o=e.e,a=e.s;e:if("[object Array]"==({}
7).toString.call(n)){if((1===a||-1===a)&&o>=-1e9&&o<=1e9&&o===i(o)){if(0===n[0]){if(0===o&&1===n.length)return!0;break e}if((t=(o+1)%14)<1&&(t+=14),String(n[0]).length==t){for(t=0;t<n.length;t++)if((r=n[t])<0||r>=1e14||r!==i(r))break e;if(0!==r)return!0}}}else if(null===n&&null===o&&(null===a||1===a||-1===a))return!0;throw Error(s+"Invalid BigNumber: "+e)},D.maximum=D.max=function(){return K(arguments,-1)},D.minimum=D.min=function(){return K(arguments,1)},g=0x20000000000000*Math.random()&2097151?function(){return i(0x20000000000000*Math.random())}:function(){return(0x40000000*Math.random()|0)*8388608+(8388608*Math.random()|0)},D.random=function(e){var t,n,a,l,c,d=0,h=[],f=new D(A);if(null==e?e=T:u(e,0,1e9),l=r(e/14),C)if(crypto.getRandomValues){for(t=crypto.getRandomValues(new Uint32Array(l*=2));d<l;)(c=131072*t[d]+(t[d+1]>>>11))>=9e15?(n=crypto.getRandomValues(new Uint32Array(2)),t[d]=n[0],t[d+1]=n[1]):(h.push(c%1e14),d+=2);d=l/2}else if(crypto.randomBytes){for(t=crypto.randomBytes(l*=7);d<l;)(c=(31&t[d])*0x1000000000000+0x10000000000*t[d+1]+0x100000000*t[d+2]+0x1000000*t[d+3]+(t[d+4]<<16)+(t[d+5]<<8)+t[d+6])>=9e15?crypto.randomBytes(7).copy(t,d):(h.push(c%1e14),d+=7);d=l/7}else throw C=!1,Error(s+"crypto unavailable");if(!C)for(;d<l;)(c=g())<9e15&&(h[d++]=c%1e14);for(l=h[--d],e%=14,l&&e&&(c=o[14-e],h[d]=i(l/c)*c);0===h[d];h.pop(),d--);if(d<0)h=[a=0];else{for(a=-1;0===h[0];h.splice(0,1),a-=14);for(d=1,c=h[0];c>=10;c/=10,d++);d<14&&(a-=14-d)}return f.e=a,f.c=h,f},D.sum=function(){for(var e=1,t=arguments,r=new D(t[0]);e<t.length;)r=r.plus(t[e++]);return r},S=function(){var e="0123456789";function t(e,t,r,i){for(var s,n,o=[0],a=0,l=e.length;a<l;){for(n=o.length;n--;o[n]*=t);for(o[0]+=i.indexOf(e.charAt(a++)),s=0;s<o.length;s++)o[s]>r-1&&(null==o[s+1]&&(o[s+1]=0),o[s+1]+=o[s]/r|0,o[s]%=r)}return o.reverse()}return function(r,i,s,n,o){var a,c,u,d,h,p,g,y,m=r.indexOf("."),b=T,v=x;for(m>=0&&(d=B,B=0,r=r.replace(".",""),p=(y=new D(i)).pow(r.length-m),B=d,y.c=t(f(l(p.c),p.e,"0"),10,s,e),y.e=y.c.length),u=d=(g=t(r,i,s,o?(a=q,e):(a=e,q))).length;0==g[--d];g.pop());if(!g[0])return a.charAt(0);if(m<0?--u:(p.c=g,p.e=u,p.s=n,g=(p=_(p,y,b,v,s)).c,h=p.r,u=p.e),m=g[c=u+b+1],d=s/2,h=h||c<0||null!=g[c+1],h=v<4?(null!=m||h)&&(0==v||v==(p.s<0?3:2)):m>d||m==d&&(4==v||h||6==v&&1&g[c-1]||v==(p.s<0?8:7)),c<1||!g[0])r=h?f(a.charAt(1),-b,a.charAt(0)):a.charAt(0);else{if(g.length=c,h)for(--s;++g[--c]>s;)g[c]=0,c||(++u,g=[1].concat(g));for(d=g.length;!g[--d];);for(m=0,r="";m<=d;r+=a.charAt(g[m++]));r=f(r,u,a.charAt(0))}return r}}(),_=function(){function e(e,t,r){var i,s,n,o,a=0,l=e.length,c=t%1e7,u=t/1e7|0;for(e=e.slice();l--;)i=u*(n=e[l]%1e7)+(o=e[l]/1e7|0)*c,a=((s=c*n+i%1e7*1e7+a)/r|0)+(i/1e7|0)+u*o,e[l]=s%r;return a&&(e=[a].concat(e)),e}function t(e,t,r,i){var s,n;if(r!=i)n=r>i?1:-1;else for(s=n=0;s<r;s++)if(e[s]!=t[s]){n=e[s]>t[s]?1:-1;break}return n}function r(e,t,r,i){for(var s=0;r--;)e[r]-=s,s=+(e[r]<t[r]),e[r]=s*i+e[r]-t[r];for(;!e[0]&&e.length>1;e.splice(0,1));}return function(s,n,o,l,c){var u,d,h,f,p,g,y,m,b,v,w,_,S,E,I,A,T,x=s.s==n.s?1:-1,k=s.c,P=n.c;if(!k||!k[0]||!P||!P[0])return new D(!s.s||!n.s||(k?P&&k[0]==P[0]:!P)?NaN:k&&0==k[0]||!P?0*x:x/0);for(b=(m=new D(x)).c=[],x=o+(d=s.e-n.e)+1,c||(c=1e14,d=a(s.e/14)-a(n.e/14),x=x/14|0),h=0;P[h]==(k[h]||0);h++);if(P[h]>(k[h]||0)&&d--,x<0)b.push(1),f=!0;else{for(E=k.length,A=P.length,h=0,x+=2,(p=i(c/(P[0]+1)))>1&&(P=e(P,p,c),k=e(k,p,c),A=P.length,E=k.length),S=A,w=(v=k.slice(0,A)).length;w<A;v[w++]=0);T=[0].concat(T=P.slice()),I=P[0],P[1]>=c/2&&I++;do{if(p=0,(u=t(P,v,A,w))<0){if(_=v[0],A!=w&&(_=_*c+(v[1]||0)),(p=i(_/I))>1)for(p>=c&&(p=c-1),y=(g=e(P,p,c)).length,w=v.length;1==t(g,v,y,w);)p--,r(g,A<y?T:P,y,c),y=g.length,u=1;else 0==p&&(u=p=1),y=(g=P.slice()).length;if(y<w&&(g=[0].concat(g)),r(v,g,w,c),w=v.length,-1==u)for(;1>t(P,v,A,w);)p++,r(v,A<w?T:P,w,c),w=v.length}else 0===u&&(p++,v=[0]);b[h++]=p,v[0]?v[w++]=k[S]||0:(v=[k[S]],w=1)}while((S++<E||null!=v[0])&&x--)f=null!=v[0],b[0]||b.splice(0,1)}if(1e14==c){for(h=1,x=b[0];x>=10;x/=10,h++);z(m,o+(m.e=h+14*d-1)+1,l,f)}else m.e=d,m.r=+f;return m}}(),y=/^(-?)0([xbo])(?=\w[\w.]*$)/i,m=/^([^.]+)\.$/,b=/^\.([^.]+)$/,v=/^-?(Infinity|NaN)$/,w=/^\s*\+(?=[\w.])|^\s+|\s+$/g,E=function(e,t,r,i){var n,o=r?t:t.replace(w,"");if(v.test(o))e.s=isNaN(o)?null:o<0?-1:1;else{if(!r&&(o=o.replace(y,function(e,t,r){return n="x"==(r=r.toLowerCase())?16:"b"==r?2:8,i&&i!=n?e:t}),i&&(n=i,o=o.replace(m,"$1").replace(b,"0.$1")),t!=o))return new D(o,n);if(D.DEBUG)throw Error(s+"Not a"+(i?" base "+i:"")+" number: "+t);e.s=null}e.c=e.e=null},I.absoluteValue=I.abs=function(){var e=new D(this);return e.s<0&&(e.s=1),e},I.comparedTo=function(e,t){return c(this,new D(e,t))},I.decimalPlaces=I.dp=function(e,t){var r,i,s;
7if(null!=e)return u(e,0,1e9),null==t?t=x:u(t,0,8),z(new D(this),e+this.e+1,t);if(!(r=this.c))return null;if(i=((s=r.length-1)-a(this.e/14))*14,s=r[s])for(;s%10==0;s/=10,i--);return i<0&&(i=0),i},I.dividedBy=I.div=function(e,t){return _(this,new D(e,t),T,x)},I.dividedToIntegerBy=I.idiv=function(e,t){return _(this,new D(e,t),0,1)},I.exponentiatedBy=I.pow=function(e,t){var n,o,a,l,c,u,h,f,p,g=this;if((e=new D(e)).c&&!e.isInteger())throw Error(s+"Exponent not an integer: "+j(e));if(null!=t&&(t=new D(t)),u=e.e>14,!g.c||!g.c[0]||1==g.c[0]&&!g.e&&1==g.c.length||!e.c||!e.c[0])return p=new D(Math.pow(+j(g),u?e.s*(2-d(e)):+j(e))),t?p.mod(t):p;if(h=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new D(NaN);(o=!h&&g.isInteger()&&t.isInteger())&&(g=g.mod(t))}else{if(e.e>9&&(g.e>0||g.e<-1||(0==g.e?g.c[0]>1||u&&g.c[1]>=24e7:g.c[0]<8e13||u&&g.c[0]<=9999975e7)))return l=g.s<0&&d(e)?-0:0,g.e>-1&&(l=1/l),new D(h?1/l:l);B&&(l=r(B/14+2))}for(u?(n=new D(.5),h&&(e.s=1),f=d(e)):f=(a=Math.abs(+j(e)))%2,p=new D(A);;){if(f){if(!(p=p.times(g)).c)break;l?p.c.length>l&&(p.c.length=l):o&&(p=p.mod(t))}if(a){if(0===(a=i(a/2)))break;f=a%2}else if(z(e=e.times(n),e.e+1,1),e.e>14)f=d(e);else{if(0==(a=+j(e)))break;f=a%2}g=g.times(g),l?g.c&&g.c.length>l&&(g.c.length=l):o&&(g=g.mod(t))}return o?p:(h&&(p=A.div(p)),t?p.mod(t):l?z(p,B,x,c):p)},I.integerValue=function(e){var t=new D(this);return null==e?e=x:u(e,0,8),z(t,t.e+1,e)},I.isEqualTo=I.eq=function(e,t){return 0===c(this,new D(e,t))},I.isFinite=function(){return!!this.c},I.isGreaterThan=I.gt=function(e,t){return c(this,new D(e,t))>0},I.isGreaterThanOrEqualTo=I.gte=function(e,t){return 1===(t=c(this,new D(e,t)))||0===t},I.isInteger=function(){return!!this.c&&a(this.e/14)>this.c.length-2},I.isLessThan=I.lt=function(e,t){return 0>c(this,new D(e,t))},I.isLessThanOrEqualTo=I.lte=function(e,t){return -1===(t=c(this,new D(e,t)))||0===t},I.isNaN=function(){return!this.s},I.isNegative=function(){return this.s<0},I.isPositive=function(){return this.s>0},I.isZero=function(){return!!this.c&&0==this.c[0]},I.minus=function(e,t){var r,i,s,n,o=this.s;if(t=(e=new D(e,t)).s,!o||!t)return new D(NaN);if(o!=t)return e.s=-t,this.plus(e);var l=this.e/14,c=e.e/14,u=this.c,d=e.c;if(!l||!c){if(!u||!d)return u?(e.s=-t,e):new D(d?this:NaN);if(!u[0]||!d[0])return d[0]?(e.s=-t,e):new D(u[0]?this:3==x?-0:0)}if(l=a(l),c=a(c),u=u.slice(),o=l-c){for((n=o<0)?(o=-o,s=u):(c=l,s=d),s.reverse(),t=o;t--;s.push(0));s.reverse()}else for(i=(n=(o=u.length)<(t=d.length))?o:t,o=t=0;t<i;t++)if(u[t]!=d[t]){n=u[t]<d[t];break}if(n&&(s=u,u=d,d=s,e.s=-e.s),(t=(i=d.length)-(r=u.length))>0)for(;t--;u[r++]=0);for(t=1e14-1;i>o;){if(u[--i]<d[i]){for(r=i;r&&!u[--r];u[r]=t);--u[r],u[i]+=1e14}u[i]-=d[i]}for(;0==u[0];u.splice(0,1),--c);return u[0]?W(e,u,c):(e.s=3==x?-1:1,e.c=[e.e=0],e)},I.modulo=I.mod=function(e,t){var r,i;return(e=new D(e,t),this.c&&e.s&&(!e.c||e.c[0]))?e.c&&(!this.c||this.c[0])?(9==N?(i=e.s,e.s=1,r=_(this,e,0,3),e.s=i,r.s*=i):r=_(this,e,0,N),(e=this.minus(r.times(e))).c[0]||1!=N||(e.s=this.s),e):new D(this):new D(NaN)},I.multipliedBy=I.times=function(e,t){var r,i,s,n,o,l,c,u,d,h,f,p,g,y=this.c,m=(e=new D(e,t)).c;if(!y||!m||!y[0]||!m[0])return this.s&&e.s&&(!y||y[0]||m)&&(!m||m[0]||y)?(e.s*=this.s,y&&m?(e.c=[0],e.e=0):e.c=e.e=null):e.c=e.e=e.s=null,e;for(i=a(this.e/14)+a(e.e/14),e.s*=this.s,(c=y.length)<(h=m.length)&&(g=y,y=m,m=g,s=c,c=h,h=s),s=c+h,g=[];s--;g.push(0));for(s=h;--s>=0;){for(r=0,f=m[s]%1e7,p=m[s]/1e7|0,n=s+(o=c);n>s;)l=p*(u=y[--o]%1e7)+(d=y[o]/1e7|0)*f,r=((u=f*u+l%1e7*1e7+g[n]+r)/1e14|0)+(l/1e7|0)+p*d,g[n--]=u%1e14;g[n]=r}return r?++i:g.splice(0,1),W(e,g,i)},I.negated=function(){var e=new D(this);return e.s=-e.s||null,e},I.plus=function(e,t){var r,i=this.s;if(t=(e=new D(e,t)).s,!i||!t)return new D(NaN);if(i!=t)return e.s=-t,this.minus(e);var s=this.e/14,n=e.e/14,o=this.c,l=e.c;if(!s||!n){if(!o||!l)return new D(i/0);if(!o[0]||!l[0])return l[0]?e:new D(o[0]?this:0*i)}if(s=a(s),n=a(n),o=o.slice(),i=s-n){for(i>0?(n=s,r=l):(i=-i,r=o),r.reverse();i--;r.push(0));r.reverse()}for((i=o.length)-(t=l.length)<0&&(r=l,l=o,o=r,t=i),i=0;t;)i=(o[--t]=o[t]+l[t]+i)/1e14|0,o[t]=1e14===o[t]?0:o[t]%1e14;return i&&(o=[i].concat(o),++n),W(e,o,n)},I.precision=I.sd=function(e,t){var r,i,s;
7if(null!=e&&!!e!==e)return u(e,1,1e9),null==t?t=x:u(t,0,8),z(new D(this),e,t);if(!(r=this.c))return null;if(i=14*(s=r.length-1)+1,s=r[s]){for(;s%10==0;s/=10,i--);for(s=r[0];s>=10;s/=10,i++);}return e&&this.e+1>i&&(i=this.e+1),i},I.shiftedBy=function(e){return u(e,-0x1fffffffffffff,0x1fffffffffffff),this.times("1e"+e)},I.squareRoot=I.sqrt=function(){var e,t,r,i,s,n=this.c,o=this.s,c=this.e,u=T+4,d=new D("0.5");if(1!==o||!n||!n[0])return new D(!o||o<0&&(!n||n[0])?NaN:n?this:1/0);if(0==(o=Math.sqrt(+j(this)))||o==1/0?(((t=l(n)).length+c)%2==0&&(t+="0"),o=Math.sqrt(+t),c=a((c+1)/2)-(c<0||c%2),r=new D(t=o==1/0?"5e"+c:(t=o.toExponential()).slice(0,t.indexOf("e")+1)+c)):r=new D(o+""),r.c[0]){for((o=(c=r.e)+u)<3&&(o=0);;)if(s=r,r=d.times(s.plus(_(this,s,u,1))),l(s.c).slice(0,o)===(t=l(r.c)).slice(0,o)){if(r.e<c&&--o,"9999"!=(t=t.slice(o-3,o+1))&&(i||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(z(r,r.e+T+2,1),e=!r.times(r).eq(this));break}if(!i&&(z(s,s.e+T+2,0),s.times(s).eq(this))){r=s;break}u+=4,o+=4,i=1}}return z(r,r.e+T+1,x,e)},I.toExponential=function(e,t){return null!=e&&(u(e,0,1e9),e++),M(this,e,t,1)},I.toFixed=function(e,t){return null!=e&&(u(e,0,1e9),e=e+this.e+1),M(this,e,t)},I.toFormat=function(e,t,r){var i;if(null==r)null!=e&&t&&"object"==typeof t?(r=t,t=null):e&&"object"==typeof e?(r=e,e=t=null):r=U;else if("object"!=typeof r)throw Error(s+"Argument not an object: "+r);if(i=this.toFixed(e,t),this.c){var n,o=i.split("."),a=+r.groupSize,l=+r.secondaryGroupSize,c=r.groupSeparator||"",u=o[0],d=o[1],h=this.s<0,f=h?u.slice(1):u,p=f.length;if(l&&(n=a,a=l,l=n,p-=n),a>0&&p>0){for(n=p%a||a,u=f.substr(0,n);n<p;n+=a)u+=c+f.substr(n,a);l>0&&(u+=c+f.slice(n)),h&&(u="-"+u)}i=d?u+(r.decimalSeparator||"")+((l=+r.fractionGroupSize)?d.replace(RegExp("\\d{"+l+"}\\B","g"),"$&"+(r.fractionGroupSeparator||"")):d):u}return(r.prefix||"")+i+(r.suffix||"")},I.toFraction=function(e){var t,r,i,n,a,c,u,d,h,f,p,g,y=this.c;if(null!=e&&(!(u=new D(e)).isInteger()&&(u.c||1!==u.s)||u.lt(A)))throw Error(s+"Argument "+(u.isInteger()?"out of range: ":"not an integer: ")+j(u));if(!y)return new D(this);for(t=new D(A),h=r=new D(A),i=d=new D(A),g=l(y),a=t.e=g.length-this.e-1,t.c[0]=o[(c=a%14)<0?14+c:c],e=!e||u.comparedTo(t)>0?a>0?t:h:u,c=R,R=1/0,u=new D(g),d.c[0]=0;f=_(u,t,0,1),1!=(n=r.plus(f.times(i))).comparedTo(e);)r=i,i=n,h=d.plus(f.times(n=h)),d=n,t=u.minus(f.times(n=t)),u=n;return n=_(e.minus(r),i,0,1),d=d.plus(n.times(h)),r=r.plus(n.times(i)),d.s=h.s=this.s,a*=2,p=1>_(h,i,a,x).minus(this).abs().comparedTo(_(d,r,a,x).minus(this).abs())?[h,i]:[d,r],R=c,p},I.toNumber=function(){return+j(this)},I.toPrecision=function(e,t){return null!=e&&u(e,1,1e9),M(this,e,t,2)},I.toString=function(e){var t,r=this,i=r.s,s=r.e;return null===s?i?(t="Infinity",i<0&&(t="-"+t)):t="NaN":(null==e?t=s<=k||s>=P?h(l(r.c),s):f(l(r.c),s,"0"):10===e&&L?t=f(l((r=z(new D(r),T+s+1,x)).c),r.e,"0"):(u(e,2,q.length,"Base"),t=S(f(l(r.c),s,"0"),10,e,i,!0)),i<0&&r.c[0]&&(t="-"+t)),t},I.valueOf=I.toJSON=function(){return j(this)},I._isBigNumber=!0,I[Symbol.toStringTag]="BigNumber",I[Symbol.for("nodejs.util.inspect.custom")]=I.valueOf,null!=p&&D.set(p),D}();e.s(["default",0,p])},46747,e=>{"use strict";var t=e.i(828073);e.i(829877),e.i(107522),new t.default("1e+18"),e.s([])},147618,e=>{"use strict";var t=e.i(444610),r=e.i(829877);e.s(["bool",0,e=>{let i=(0,t.u8)(e),{encode:s,decode:n}=(0,r.encodeDecode)(i);return i.decode=(e,t)=>!!n(e,t),i.encode=(e,t,r)=>s(Number(e),t,r),i}])},80070,e=>{"use strict";var t=e.i(444610),r=e.i(127261),i=e.i(829877);e.s(["publicKey",0,e=>{let s=(0,t.blob)(32,e),{encode:n,decode:o}=(0,i.encodeDecode)(s);return s.decode=(e,t)=>{let i=o(e,t);return new r.PublicKey(i)},s.encode=(e,t,r)=>n(e.toBuffer(),t,r),s}])},559136,e=>{"use strict";e.i(107522),e.i(46747),e.i(147618),e.i(80070),e.s([])},896198,e=>{"use strict";class t extends Error{constructor(e){super(e)}}e.s(["TokenOwnerOffCurveError",0,class extends t{constructor(){super(...arguments),this.name="TokenOwnerOffCurveError"}}])},946865,e=>{"use strict";var t=e.i(444610);e.i(559136);var r=e.i(147618),i=e.i(80070),s=e.i(107522),n=e.i(127261),o=e.i(422876),a=e.i(896198);async function l(e,t,r=!1,i=o.TOKEN_PROGRAM_ID,s=o.ASSOCIATED_TOKEN_PROGRAM_ID){if(!r&&!n.PublicKey.isOnCurve(t.toBuffer()))throw new a.TokenOwnerOffCurveError;let[c]=await n.PublicKey.findProgramAddress([t.toBuffer(),i.toBuffer(),e.toBuffer()],s);return c}(0,t.struct)([(0,t.u32)("mintAuthorityOption"),(0,i.publicKey)("mintAuthority"),(0,s.u64)("supply"),(0,t.u8)("decimals"),(0,r.bool)("isInitialized"),(0,t.u32)("freezeAuthorityOption"),(0,i.publicKey)("freezeAuthority")]).span,e.s(["getAssociatedTokenAddress",0,l])},123424,e=>{"use strict";var t=e.i(467034),r=e.i(127261),i=e.i(422876);e.s(["createAssociatedTokenAccountInstruction",0,function(e,s,n,o,a=i.TOKEN_PROGRAM_ID,l=i.ASSOCIATED_TOKEN_PROGRAM_ID){return function(e,t,s,n,o,a=i.TOKEN_PROGRAM_ID,l=i.ASSOCIATED_TOKEN_PROGRAM_ID){let c=[{pubkey:e,isSigner:!0,isWritable:!0},{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!1,isWritable:!1},{pubkey:r.SystemProgram.programId,isSigner:!1,isWritable:!1},{pubkey:a,isSigner:!1,isWritable:!1}];return new r.TransactionInstruction({keys:c,programId:l,data:o})}(e,s,n,o,t.Buffer.alloc(0),a,l)}])},717725,e=>{"use strict";var t=e.i(127261);e.s(["addSigners",0,function(e,r,i){if(i.length)for(let s of(e.push({pubkey:r,isSigner:!1,isWritable:!1}),i))e.push({pubkey:s instanceof t.PublicKey?s:s.publicKey,isSigner:!0,isWritable:!1});else e.push({pubkey:r,isSigner:!0,isWritable:!1});return e}])},858010,e=>{"use strict";var t,r;(r=t||(t={}))[r.InitializeMint=0]="InitializeMint",r[r.InitializeAccount=1]="InitializeAccount",r[r.InitializeMultisig=2]="InitializeMultisig",r[r.Transfer=3]="Transfer",r[r.Approve=4]="Approve",r[r.Revoke=5]="Revoke",r[r.SetAuthority=6]="SetAuthority",r[r.MintTo=7]="MintTo",r[r.Burn=8]="Burn",r[r.CloseAccount=9]="CloseAccount",r[r.FreezeAccount=10]="FreezeAccount",r[r.ThawAccount=11]="ThawAccount",r[r.TransferChecked=12]="TransferChecked",r[r.ApproveChecked=13]="ApproveChecked",r[r.MintToChecked=14]="MintToChecked",r[r.BurnChecked=15]="BurnChecked",r[r.InitializeAccount2=16]="InitializeAccount2",r[r.SyncNative=17]="SyncNative",r[r.InitializeAccount3=18]="InitializeAccount3",r[r.InitializeMultisig2=19]="InitializeMultisig2",r[r.InitializeMint2=20]="InitializeMint2",r[r.GetAccountDataSize=21]="GetAccountDataSize",r[r.InitializeImmutableOwner=22]="InitializeImmutableOwner",r[r.AmountToUiAmount=23]="Amou
7ntToUiAmount",r[r.UiAmountToAmount=24]="UiAmountToAmount",r[r.InitializeMintCloseAuthority=25]="InitializeMintCloseAuthority",r[r.TransferFeeExtension=26]="TransferFeeExtension",r[r.ConfidentialTransferExtension=27]="ConfidentialTransferExtension",r[r.DefaultAccountStateExtension=28]="DefaultAccountStateExtension",r[r.Reallocate=29]="Reallocate",r[r.MemoTransferExtension=30]="MemoTransferExtension",r[r.CreateNativeMint=31]="CreateNativeMint",r[r.InitializeNonTransferableMint=32]="InitializeNonTransferableMint",r[r.InterestBearingMintExtension=33]="InterestBearingMintExtension",r[r.CpiGuardExtension=34]="CpiGuardExtension",r[r.InitializePermanentDelegate=35]="InitializePermanentDelegate",r[r.TransferHookExtension=36]="TransferHookExtension",r[r.MetadataPointerExtension=39]="MetadataPointerExtension",r[r.GroupPointerExtension=40]="GroupPointerExtension",r[r.GroupMemberPointerExtension=41]="GroupMemberPointerExtension",r[r.ScaledUiAmountExtension=43]="ScaledUiAmountExtension",r[r.PausableExtension=44]="PausableExtension",e.s(["TokenInstruction",0,t])},5934,e=>{"use strict";var t=e.i(467034),r=e.i(444610);e.i(559136);var i=e.i(107522),s=e.i(127261),n=e.i(422876),o=e.i(717725),a=e.i(858010);let l=(0,r.struct)([(0,r.u8)("instruction"),(0,i.u64)("amount"),(0,r.u8)("decimals")]);e.s(["createTransferCheckedInstruction",0,function(e,r,i,c,u,d,h=[],f=n.TOKEN_PROGRAM_ID){let p=(0,o.addSigners)([{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!1},{pubkey:i,isSigner:!1,isWritable:!0}],c,h),g=t.Buffer.alloc(l.span);return l.encode({instruction:a.TokenInstruction.TransferChecked,amount:BigInt(u),decimals:d},g),new s.TransactionInstruction({keys:p,programId:f,data:g})}])},526035,e=>{"use strict";e.s(["parseAmountToSmallestUnit",0,({amount:e,decimals:t})=>{let[r,i=""]=e.split(".");return BigInt((r||"0")+i.padEnd(t,"0").slice(0,t))}])},161006,e=>{"use strict";var t=e.i(59726),r=e.i(422876),i=e.i(946865),s=e.i(123424),n=e.i(5934),o=e.i(127261);e.i(973402);var a=e.i(526035);e.s(["createNonNativeTokenTransfer",0,e=>(0,t.__awaiter)(void 0,[e],void 0,function*({connection:e,fromAddress:t,toAddress:l,tokenAddress:c,amount:u,decimals:d,blockhash:h,lastValidBlockHeight:f}){var p,g;let y,m=new o.PublicKey(t),b=new o.PublicKey(l),v=new o.PublicKey(c),w=yield e.getAccountInfo(v),_=w&&w.owner.equals(r.TOKEN_2022_PROGRAM_ID)?r.TOKEN_2022_PROGRAM_ID:r.TOKEN_PROGRAM_ID,S=null==(g=null==(p=yield e.getTokenAccountsByOwner(m,{mint:v}))?void 0:p.value[0])?void 0:g.pubkey;if(!S)throw Error("Source token account not found");let E=[];try{y=yield(0,i.getAssociatedTokenAddress)(v,b,!1,_),yield e.getTokenAccountBalance(y)}catch(e){y=yield(0,i.getAssociatedTokenAddress)(v,b,!1,_),E.push((0,s.createAssociatedTokenAccountInstruction)(m,y,b,v,_))}let I=d||0;E.push((0,n.createTransferCheckedInstruction)(S,v,y,m,(0,a.parseAmountToSmallestUnit)({amount:u,decimals:I}),I,[],_));let A=new o.Transaction().add(...E);return A.recentBlockhash=h,A.lastValidBlockHeight=f,A.feePayer=m,A})])},208684,e=>{"use strict";e.s(["solToLamports",0,e=>1e9*e])},675871,e=>{"use strict";var t=e.i(59726),r=e.i(127261);e.i(973402);var i=e.i(208684);e.s(["createSolTransfer",0,e=>(0,t.__awaiter)(void 0,[e],void 0,function*({fromAddress:e,toAddress:t,amount:s,blockhash:n}){let o=new r.TransactionMessage({instructions:[r.SystemProgram.transfer({fromPubkey:new r.PublicKey(e),lamports:Math.round((0,i.solToLamports)(s)),toPubkey:new r.PublicKey(t)})],payerKey:new r.PublicKey(e),recentBlockhash:n}).compileToV0Message();return new r.VersionedTransaction(o)})])},521162,e=>{"use strict";var t=e.i(59726);e.i(303778);var r=e.i(776177),i=e.i(890357);e.i(973402);var s=e.i(787458);e.i(127261);var n=e.i(161006),o=e.i(675871);class a extends r.Wallet{sendBalance(e){return(0,t.__awaiter)(this,arguments,void 0,function*({amount:e,toAddress:t,token:r}){let i,s=yield this.getConnection(),a=yield this.getSigner(),{blockhash:l,lastValidBlockHeight:c}=yield s.getLatestBlockhash("finalized");i=(null==r?void 0:r.address)?yield(0,n.createNonNativeTokenTransfer)({amount:e,blockhash:l,connection:s,decimals:r.decimals,fromAddress:this.address,lastValidBlockHeight:c,toAddress:t,tokenAddress:r.address}):yield(0,o.createSolTransfer)({amount:Number(e),blockhash:l,fromAddress:this.address,toAddress:t});let{signature:u}=yield a.signAndSendTransaction(i);return u})}getConnection(){return(0,t.__awaiter)(this,void 0,void 0,function*(){return this._connector.getWalletClient()})}getSigner(){return(0,t.__awaiter)(this,void 0,void 0,function*(){let e=yield this._connector.getSigner();if(!e)throw Error("unable to retrieve Solana signer");try{return(0,s.cloneObjectWithOverrides)(e,{signAllTransactions:r=>(0,t.__awaiter)(this,void 0,void 0,function*(){return yield this.sync(),e.signAllTransactions(r)}),signAndSendTransaction:(r,...i)=>(0,t.__awaiter)(this,void 0,void 0,function*(){return yield this.sync(),e.signAndSendTransaction(r,...i)}),signMessage:(r,...i)=>(0,t.__awaiter)(this,void 0,void 0,function*(){return yield this.sync(),e.signMessage(r,...i)}),signTransaction:r=>(0,t.__awaiter)(this,void 0,void 0,function*(){return yield this.sync(),e.signTransaction(r)})})}catch(t){return i.logger.warn(`Failed to add logic to auto-sync the wallet. Signer might be out of sync for wallet: ${this._connector.name} (${this.address})`,t),e}})}}e.s(["SolanaWallet",0,a])},894058,e=>{"use strict";e.s(["extractNonce",0,e=>{let t=e.match(/Nonce: (.*)/);if(t&&2===t.length)return t[1]}])},59081,e=>{"use strict";e.s(["getOverrideRpcUrlForNetwork",0,(e,t)=>{var r,i,s,n,o;let a,l=t.name.toLowerCase().includes("solana"),c=t.name.toLowerCase().includes("eclipse");return l&&(a=null==(i=null==(r=null==e?void 0:e.customRpcUrls)?void 0:r.solana)?void 0:i[0]),c&&(a=null==(n=null==(s=null==e?void 0:e.customRpcUrls)?void 0:s.eclipse)?void 0:n[0]),a||(null==(o=t.privateCustomerRpcUrls)?void 0:o[0])||t.rpcUrls[0]}])},58352,e=>{"use strict";
7e.s(["DYNAMIC_SVM_NETWORK_ID_LS_KEY",0,"dynamic_svm_network_id"])},204173,e=>{"use strict";var t=e.i(59081);let r={blockExplorerUrls:["https://explorer.solana.com"],chainId:"101",cluster:"mainnet",genesisHash:"5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",iconUrls:["https://app.dynamic.xyz/assets/networks/solana.svg"],isTestnet:!1,key:"solana",name:"Solana Mainnet",nativeCurrency:{decimals:9,iconUrl:"https://app.dynamic.xyz/assets/networks/solana.svg",name:"Solana",pricingProviderTokenId:"solana",symbol:"SOL"},networkId:"101",rpcUrls:["https://api.mainnet-beta.solana.com"],vanityName:"Solana"},i={blockExplorerUrls:["https://explorer.solana.com/?cluster=testnet"],chainId:"102",cluster:"testnet",genesisHash:"4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z",iconUrls:["https://app.dynamic.xyz/assets/networks/solana.svg"],isTestnet:!0,key:"solana",name:"Solana Testnet",nativeCurrency:{decimals:9,iconUrl:"https://app.dynamic.xyz/assets/networks/solana.svg",name:"Solana",pricingProviderTokenId:"solana",symbol:"SOL"},networkId:"102",rpcUrls:["https://api.testnet.solana.com"]},s={blockExplorerUrls:["https://explorer.solana.com/?cluster=devnet"],chainId:"103",cluster:"devnet",genesisHash:"EtWTRABZaYq6iMfeYKouRu166VU2xqa1",iconUrls:["https://app.dynamic.xyz/assets/networks/solana.svg"],isTestnet:!0,key:"solana",name:"Solana Devnet",nativeCurrency:{decimals:9,iconUrl:"https://app.dynamic.xyz/assets/networks/solana.svg",name:"Solana",pricingProviderTokenId:"solana",symbol:"SOL"},networkId:"103",rpcUrls:["https://api.devnet.solana.com"]};e.s(["getBackwardsCompatibleSolNetworks",0,(e,n)=>{if(!(null==e?void 0:e.length))return[];if(e.length>1||"101"!==e[0].chainId)return e;let o=(0,t.getOverrideRpcUrlForNetwork)(n,e[0]);return o.includes("testnet")?[Object.assign(Object.assign({},i),{privateCustomerRpcUrls:[o]})]:o.includes("devnet")?[Object.assign(Object.assign({},s),{privateCustomerRpcUrls:[o]})]:o.includes("mainnet")?[Object.assign(Object.assign({},r),{privateCustomerRpcUrls:[o]})]:e}])},510137,e=>{"use strict";var t=e.i(467034),r=e.i(59726),i=e.i(127261);e.i(303778);var s=e.i(721021);e.i(973402);var n=e.i(624211),o=e.i(678105),a=e.i(83950),l=e.i(521162),c=e.i(894058),u=e.i(59081),d=e.i(58352),h=e.i(204173);let f=new i.PublicKey("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr");class p extends s.WalletConnectorBase{constructor(e){var t;super(e),this.isHardwareWalletEnabled=!1,this.verifiedCredentials=[],this.ChainWallet=l.SolanaWallet,this.supportedChains=["SOL"],this.connectedChain="SOL",this.solNetworks=(0,h.getBackwardsCompatibleSolNetworks)(e.solNetworks,e.connectionConfig),this.chainRpcProviders=e.chainRpcProviders,this.connectionConfig=e.connectionConfig,null==(t=this.chainRpcProviders)||t.registerSolanaProviders(this.connectionConfig)}getNetworkId(){var e;let t=null==(e=this.solNetworks[0])?void 0:e.networkId.toString(),r=localStorage.getItem(d.DYNAMIC_SVM_NETWORK_ID_LS_KEY);return null!=r?r:t}setNetworkId(e){e?localStorage.setItem(d.DYNAMIC_SVM_NETWORK_ID_LS_KEY,e):localStorage.removeItem(d.DYNAMIC_SVM_NETWORK_ID_LS_KEY)}getSelectedNetwork(){return this.solNetworks.find(e=>e.networkId.toString()===this.getNetworkId())}getNetwork(){return(0,r.__awaiter)(this,arguments,void 0,function*(e=!1){let t=this.getSelectedNetwork();if(!t)return"";let{networkId:r,genesisHash:i}=t;return e?r.toString():"5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"===i?"mainnet":"4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z"===i?"testnet":"EtWTRABZaYq6iMfeYKouRu166VU2xqa1"===i?"devnet":r.toString()})}switchNetwork(e){return(0,r.__awaiter)(this,arguments,void 0,function*({networkChainId:e}){if(!e)return;let t=e.toString();this.solNetworks.some(e=>e.networkId.toString()===t)&&(this.setNetworkId(t),this.emit("chainChange",{chain:t}))})}endSession(){return(0,r.__awaiter)(this,void 0,void 0,function*(){this.setNetworkId(null);let e=yield this.getSigner();e&&(yield e.disconnect())})}getWalletClient(){var e;let t=this.getSelectedNetwork();if(!t)throw new n.DynamicError("No enabled networks","no_enabled_networks");let r=(0,u.getOverrideRpcUrlForNetwork)(this.connectionConfig,t);return new i.Connection(r,null!=(e=this.connectionConfig)?e:"confirmed")}getPublicClient(){return(0,r.__awaiter)(this,void 0,void 0,function*(){var e;let t=this.getSelectedNetwork();if(!t)return;let r=t.networkId.toString(),i={cosmos:[],evm:void 0,solana:this.sol
7Networks,starknet:void 0};if(!this.chainRpcProviders)return;let s=this.chainRpcProviders.getProviders(i);return null==(e=this.chainRpcProviders.getSolanaProviderByChainId(s,r))?void 0:e.provider})}getBalance(e){return(0,r.__awaiter)(this,void 0,void 0,function*(){let t=new i.PublicKey(e);return this.lamportsToSol((yield this.getWalletClient().getBalance(t))).toString()})}lamportsToSol(e){return e/1e9}canConnectWithHardwareWallet(){var e;return!!(null==(e=this.metadata.supportedHardwareWallets)?void 0:e.includes("ledger"))}signMessage(e){let t=Object.create(null,{signMessage:{get:()=>super.signMessage}});return(0,r.__awaiter)(this,void 0,void 0,function*(){if(this.isHardwareWalletEnabled)throw new a.NotSupportedError(`Message signing is currently not supported on ${this.name} hardware wallet.
8          You can use signMessageViaTransaction instead to achieve similar functionality
9          by signing a transaction with a memo instruction.
10          You can read more about it here https://github.com/solana-labs/solana/issues/21366`);return t.signMessage.call(this,e)})}proveOwnership(e,t){let i=Object.create(null,{proveOwnership:{get:()=>super.proveOwnership}});return(0,r.__awaiter)(this,void 0,void 0,function*(){if(yield this.validateActiveWallet(e),this.isHardwareWalletEnabled){let e=(0,c.extractNonce)(t);if(!e)throw new n.DynamicError("Nonce missing","nonce_missing");return this.signMessageViaTransaction(e)}return i.proveOwnership.call(this,e,t)})}signMessageViaTransaction(e){return(0,r.__awaiter)(this,void 0,void 0,function*(){let t=yield this.getAddress();if(!t)throw new n.DynamicError("Address missing","address_missing");let r=this.buildAuthTx(e);r.feePayer=new i.PublicKey(t),r.recentBlockhash=(yield this.getWalletClient().getLatestBlockhash()).blockhash;let s=yield this.getSigner();if(!s)throw new n.DynamicError("Signer not found","signer_not_found");return JSON.stringify({signedTransaction:{data:Array.from((yield s.signTransaction(r)).serialize()),type:"Buffer"}})})}buildAuthTx(e){let r=new i.Transaction;return r.add(new i.TransactionInstruction({data:t.Buffer.from(e,"utf8"),keys:[],programId:f})),r}setVerifiedCredentials(e){this.verifiedCredentials=e}isLedgerAddress(e){return(0,o.isLedgerAddressViaVerifiedCredentials)(e,this.verifiedCredentials)}getBlockExplorerUrlsForCurrentNetwork(){return(0,r.__awaiter)(this,void 0,void 0,function*(){let e=this.getSelectedNetwork();return e?e.blockExplorerUrls:[]})}getEnabledNetworks(){return this.solNetworks}supportsNetworkSwitching(){return!0}}e.s(["SolanaWalletConnector",0,p])},819277,e=>{"use strict";var t=e.i(127261);e.i(93474);var r=e.i(114579),i=e.i(577709);e.i(973402);var s=e.i(59081);r.ChainRpcProviders.getSolanaProviderByChainId=(e,t)=>{var r;return null==(r=e.solana)?void 0:r.find(e=>e.chainId===t)},r.ChainRpcProviders.registerSolanaProviders=e=>{r.ChainRpcProviders.registerChainProviders(i.ProviderChain.SOLANA,r=>{let i={};return(null==r?void 0:r.solana)&&(i.solana=r.solana.map(r=>{let i=(0,s.getOverrideRpcUrlForNetwork)(e,r),n=new t.Connection(i,e);return{chainId:r.chainId.toString(),chainName:r.name,provider:n}})),i.solana})},e.s([])},344014,e=>{"use strict";e.i(93474),e.i(114579),e.s([])},319050,e=>{"use strict";var t=e.i(59726),r=e.i(127261),i=e.i(422876),s=e.i(946865),n=e.i(123424),o=e.i(5934);e.i(973402);var a=e.i(628873);e.s(["SolanaUiTransaction",0,class{constructor({onSubmit:e,from:t,connection:r,multipleTransactions:i}){this.chain="SOL",this.data=void 0,this.fee={gas:void 0},this.formatNonNativeToken=(e,t)=>(Number(e)/Number(Math.pow(10,t))).toString(),this.from=t,this.onSubmit=e,this.connection=r,this.multipleTransactions=i}fetchFee(){return(0,t.__awaiter)(this,void 0,void 0,function*(){if(this.fee.gas)return;let e=this.multipleTransactions;if(!e){let t=yield this.createTransactionSafe();if(!t)return;e=t instanceof Array?t:[t]}let r=yield Promise.all(e.map(e=>(0,t.__awaiter)(this,void 0,void 0,function*(){return"version"in e?e.message:e.compileMessage()})));if(r.some(e=>!e))throw Error("Invalid transaction");let i=e=>(0,t.__awaiter)(this,void 0,void 0,function*(){let t=yield this.connection.getFeeForMessage(e,"confirmed"),r=0;for(;null===t.value&&r<5;)t=yield this.connection.getFeeForMessage(e,"confirmed"),r++;return t.value?BigInt(t.value):BigInt(0)}),s=yield Promise.all(r.map(e=>i(e)));this.fee.gas=s.reduce((e,t)=>
10e+t,BigInt(0)),this.fee.gas===BigInt(0)&&(this.fee.gas=void 0)})}isGasSponsored(){var e;return!!(null==(e=this.multipleTransactions)?void 0:e.length)&&this.multipleTransactions.every(e=>{var t;return"version"in e?this.from!==e.message.staticAccountKeys[0].toBase58():"feePayer"in e&&this.from!==(null==(t=e.feePayer)?void 0:t.toBase58())})}parse(e){return BigInt(Math.round(1e9*parseFloat(e)))}parseNonNativeToken(e,t){return BigInt(Math.floor(Number(e)*Math.pow(10,t)))}format(e,{precision:t}={}){let r=(Number(e)/1e9).toLocaleString("fullwide",{maximumFractionDigits:20,minimumFractionDigits:0,useGrouping:!1});return(0,a.formatNumberText)(r,{precision:t})}submit(){return(0,t.__awaiter)(this,void 0,void 0,function*(){if(this.multipleTransactions)return this.onSubmit();let e=yield this.createTransaction();return this.onSubmit(e)})}getBalance(){return(0,t.__awaiter)(this,void 0,void 0,function*(){let e=new r.PublicKey(this.from);return BigInt((yield this.connection.getBalance(e)))})}validateAddressFormat(e){return"dyn_send_transaction.multiple_recipients"===e||/^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(e)}createTransaction(){return(0,t.__awaiter)(this,void 0,void 0,function*(){var e;let{value:t,to:a,nonNativeAddress:l,nonNativeValue:c}=this;if(!a)throw Error("Destination is required");if(this.multipleTransactions)return this.multipleTransactions;let u=new r.Transaction,d=new r.PublicKey(this.from),h=new r.PublicKey(a);if(l&&c){let t,a=new r.PublicKey(l),f=yield this.connection.getAccountInfo(a),p=(null==f?void 0:f.owner.equals(i.TOKEN_2022_PROGRAM_ID))?i.TOKEN_2022_PROGRAM_ID:i.TOKEN_PROGRAM_ID,g=null==(e=(yield this.connection.getTokenAccountsByOwner(d,{mint:a})).value[0])?void 0:e.pubkey;if(!g)throw Error("Source token account not found");try{t=yield(0,s.getAssociatedTokenAddress)(a,h,!1,p),yield this.connection.getTokenAccountBalance(t)}catch(e){t=yield(0,s.getAssociatedTokenAddress)(a,h,!1,p),u.add((0,n.createAssociatedTokenAccountInstruction)(d,t,h,a,p))}let y=this.nonNativeDecimal||0;u.add((0,o.createTransferCheckedInstruction)(g,a,t,d,c,y,[],p))}else{let e=null!=t?t:BigInt(0);u.add(r.SystemProgram.transfer({fromPubkey:d,lamports:e,toPubkey:h}))}let{blockhash:f}=yield this.connection.getLatestBlockhash();return u.feePayer=new r.PublicKey(this.from),u.recentBlockhash=f,u})}createTransactionSafe(){return(0,t.__awaiter)(this,void 0,void 0,function*(){try{return yield this.createTransaction()}catch(e){return}})}}])},898742,e=>{"use strict";e.i(127261),e.s([])},733149,e=>{"use strict";e.s(["isVersionedTransaction",0,e=>"version"in e])},588593,e=>{"use strict";e.i(733149),e.s([])},785863,e=>{"use strict";e.s(["isSolanaWallet",0,e=>["SOL"].includes(e.chain)])},482927,e=>{"use strict";e.i(303778),e.i(938523),e.i(785863),e.s([])},484200,e=>{"use strict";e.i(957121);var t=e.i(303690),r=e.i(677007);e.i(510137),e.i(819277),e.i(93474),e.i(344014),e.i(319050),e.i(898742),e.i(588593),e.i(161006),e.i(675871),e.i(521162),e.i(482927),(0,t.assertPackageVersion)("@dynamic-labs/solana-core",r.version),e.s([])},115349,e=>{"use strict";"function"==typeof SuppressedError&&SuppressedError,e.s(["__awaiter",0,function(e,t,r,i){return new(r||(r=Promise))(function(s,n){function o(e){try{l(i.next(e))}catch(e){n(e)}}function a(e){try{l(i.throw(e))}catch(e){n(e)}}function l(e){var t;e.done?s(e.value):((t=e.value)instanceof r?t:new r(function(e){e(t)})).then(o,a)}l((i=i.apply(e,t||[])).next())})}])},302414,e=>{"use strict";e.s(["promiseWithTimeout",0,(e,t,{timeoutMessage:r="Operation timed out"}={})=>{let i,s=new Promise((e,s)=>{i=setTimeout(()=>{s(Error(r))},t)});return Promise.race([e.finally(()=>{clearTimeout(i)}),s])}])},565696,e=>{"use strict";let t;var r,i=function(e,t,r,i,s){if("m"===i)throw TypeError("Private method is not writable");if("a"===i&&!s)throw TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?s.call(e,r):s?s.value=r:t.set(e,r),r},s=function(e,t,r,i){if("a"===r&&!i)throw TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};let n=new Set,o={};function a(...e){return(e=e.filter(e=>
10!n.has(e))).length?(e.forEach(e=>n.add(e)),o.register?.forEach(t=>u(()=>t(...e))),function(){e.forEach(e=>n.delete(e)),o.unregister?.forEach(t=>u(()=>t(...e)))}):()=>{}}function l(){return[...n]}function c(e,t){return o[e]?.push(t)||(o[e]=[t]),function(){o[e]=o[e]?.filter(e=>t!==e)}}function u(e){try{e()}catch(e){console.error(e)}}class d extends Event{constructor(e){super("wallet-standard:app-ready",{bubbles:!1,cancelable:!1,composed:!1}),r.set(this,void 0),i(this,r,e,"f")}get detail(){return s(this,r,"f")}get type(){return"wallet-standard:app-ready"}preventDefault(){throw Error("preventDefault cannot be called")}stopImmediatePropagation(){throw Error("stopImmediatePropagation cannot be called")}stopPropagation(){throw Error("stopPropagation cannot be called")}}r=new WeakMap,e.s(["getWallets",0,function(){if(t||(t=Object.freeze({register:a,get:l,on:c}),"u"<typeof window))return t;let e=Object.freeze({register:a});try{window.addEventListener("wallet-standard:register-wallet",({detail:t})=>t(e))}catch(e){console.error("wallet-standard:register-wallet event listener could not be added\n",e)}try{window.dispatchEvent(new d(e))}catch(e){console.error("wallet-standard:app-ready event could not be dispatched\n",e)}return t}])},14954,e=>{"use strict";e.s(["get",0,(e,t)=>{try{return(t.match(/[^.[\]"']+/g)||[]).reduce((e,t)=>e[t],e)}catch(e){return}}])},864199,e=>{"use strict";var t=e.i(565696);e.i(973402);var r=e.i(14954);e.s(["findWalletProviderFromWalletStandard",0,e=>{let{walletStandardLocators:i}=e;if(!i||0===i.length)return;let s=(0,t.getWallets)().get();return i.reduce((e,t)=>{if(e)return e;let i=s.find(e=>e.name===t.name);if(i)return(0,r.get)(i,t.locator)},void 0)}])},515730,e=>{"use strict";e.s(["isSignedMessage",0,e=>!!e&&void 0!==e.signature])},61176,e=>{"use strict";var t=e.i(115349);e.i(973402);var r=e.i(951664),i=e.i(123785),s=e.i(302414);e.i(900373);var n=e.i(103388);e.i(303778);var o=e.i(232961),a=e.i(890357),l=e.i(864199),c=e.i(515730);e.s(["SolProviderHelper",0,class{constructor(e){this.walletBookWallet=(0,n.findWalletBookWallet)(e.walletBook,e.key),this.connector=e}getInjectedConfig(){var e;let t=null==(e=this.walletBookWallet)?void 0:e.injectedConfig;return null==t?void 0:t.find(e=>e.chain===this.connector.connectedChain.toLowerCase())}getInstalledProvider(){let e=this.getInjectedConfig();if(e&&e.extensionLocators)return this.installedProviderLookup(e.extensionLocators)}installedProviders(){var e,t;let i=this.getInjectedConfig();if(!i)return[];let s=[];if((null!=(t=null==(e=i.walletStandardLocators)?void 0:e.length)?t:0)>0){let e=(0,l.findWalletProviderFromWalletStandard)(i);e&&s.push(e)}if(i.windowLocations)for(let e of i.windowLocations){let t=(0,r.getProvidersFromWindow)(e);t&&t.length&&s.push(...t)}return 0!==i.extensionLocators.length&&window.solana&&(window.solana.providers?window.solana.providers.forEach(e=>s.push(e)):s.push(window.solana)),s}installedProviderLookup(e){let t=this.installedProviders();return 0===e.length?t[0]:(0,o.ProviderLookup)(t,e)}findProvider(){return this.connector.findProvider()}isInstalledHelper(){return void 0!==this.findProvider()}getAddress(){return(0,t.__awaiter)(this,void 0,void 0,function*(){var e;let t=this.findProvider();if(t)return yield t.connect(),null==(e=t.publicKey)?void 0:e.toString()})}connect(){return(0,t.__awaiter)(this,void 0,void 0,function*(){let e=this.findProvider();if(!e)return void a.logger.error("No Solanaprovider found to connect",{connector:this.connector.name});try{return e.isConnected||(yield e.connect()),e}catch(e){a.logger.error("Error connecting to Solanaprovider",{connector:this.connector.name,error:e});return}})}signMessage(e){return(0,t.__awaiter)(this,void 0,void 0,function*(){if(!(yield this.getAddress()))return;let t=this.findProvider();if(!t)return;let r=new TextEncoder().encode(e),s=yield t.signMessage(r,"utf8");if(s)return(0,i.bufferToBase64)((0,c.isSignedMessage)(s)?s.signature:s)})}handleAccountChange(e,r,i){return(0,t.__awaiter)(this,void 0,void 0,function*(){var t;if(!i){yield null==r?void 0:r.connect(),(null==(t=null==r?void 0:r.publicKey)?void 0:t.toString())&&e.emit("accountChange",{accounts:[r.publicKey.toString()]});return}i.toString()&&e.emit("accountChange",{accounts:[i.toString()]})})}_setupEventListeners(){let e=this.findProvider();e?e.on?(e.on("accountChanged",t=>this.handleAccountChange(this.connector,e,t)),e.on("disconnect",()=>this.connector.emit("disconnect"))):a.logger.warn("Provider does not support event listeners",{connector:this.connector,provider:e}):a.logger.warn("Provider not found",{connector:this.connector})}_teardownEventListeners(){let e=this.findProvider();e&&e.removeAllListeners()}getConnectedAccounts(){return(0,t.__awaiter)(this,void 0,void 0,function*(){var e,t;let r,i=this.findProvider();if(!i)return[];try{i.isConnected||(r=yield(0,s.promiseWithTimeout)(Promise.resolve(i.connect({onlyIfTrusted:!0})),3e3))}catch(e){return[]}let n=null==r?void 0:r.address;if(n)return[n];try{let s=null!=(e=null==r?void 0:r.publicKey)?e:null==(t=i.publicKey)?void 0:t.toString();if(s)return[null==s?void 0:s.toString()]}catch(e){a.logger.debug("Error getting public key",{connector:this.connector,error:e})}return[]})}}])},14129,e=>{"use strict";e.i(973402);var t=e.i(83950);class r extends t.NotSupportedError{constructor(e){super(`Message signing is currently not supported on ${e} hardware wallet.
11    You can use signMessageViaTransaction instead to achieve similar functionality
12    by signing a transaction with a memo instruction.
13    You can read more about it here https://github.com/solana-labs/solana/issues/21366`)}}e.s(["SignMessageNotSupportedError",0,r])},779772,e=>{"use strict";let t=new(e.i(538990)).Logger("solana");e.s(["logger",0,t])},510853,e=>{"use strict";e.s(["version",0,"2.31.0"])},192749,e=>{"use strict";var t=e.i(510853);let r={getDocsUrl:({docsBaseUrl:e,docsPath:t="",docsSlug:r})=>t?`${e??"https://viem.sh"}${t}${r?`#${r}`:""}`:void 0,version:`viem@${t.version}`};
13class i extends Error{constructor(e,s={}){const n=s.cause instanceof i?s.cause.details:s.cause?.message?s.cause.message:s.details,o=s.cause instanceof i&&s.cause.docsPath||s.docsPath,a=r.getDocsUrl?.({...s,docsPath:o});super([e||"An error occurred.","",...s.metaMessages?[...s.metaMessages,""]:[],...a?[`Docs: ${a}`]:[],...n?[`Details: ${n}`]:[],...r.version?[`Version: ${r.version}`]:[]].join("\n"),s.cause?{cause:s.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=n,this.docsPath=o,this.metaMessages=s.metaMessages,this.name=s.name??this.name,this.shortMessage=e,this.version=t.version}walk(e){return function e(t,r){return r?.(t)?t:t&&"object"==typeof t&&"cause"in t&&void 0!==t.cause?e(t.cause,r):r?null:t}(this,e)}}e.s(["BaseError",0,i])},611745,e=>{"use strict";e.s(["isHex",0,function(e,{strict:t=!0}={}){return!!e&&"string"==typeof e&&(t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x"))}])},615541,e=>{"use strict";var t=e.i(192749);t.BaseError;class r extends t.BaseError{constructor({size:e,targetSize:t,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} size (${e}) exceeds padding size (${t}).`,{name:"SizeExceedsPaddingSizeError"})}}t.BaseError,e.s(["SizeExceedsPaddingSizeError",0,r])},829987,e=>{"use strict";var t=e.i(615541);e.s(["pad",0,function(e,{dir:r,size:i=32}={}){return"string"==typeof e?function(e,{dir:r,size:i=32}={}){if(null===i)return e;let s=e.replace("0x","");if(s.length>2*i)throw new t.SizeExceedsPaddingSizeError({size:Math.ceil(s.length/2),targetSize:i,type:"hex"});return`0x${s["right"===r?"padEnd":"padStart"](2*i,"0")}`}(e,{dir:r,size:i}):function(e,{dir:r,size:i=32}={}){if(null===i)return e;if(e.length>i)throw new t.SizeExceedsPaddingSizeError({size:e.length,targetSize:i,type:"bytes"});let s=new Uint8Array(i);for(let t=0;t<i;t++){let n="right"===r;s[n?t:i-t-1]=e[n?t:e.length-t-1]}return s}(e,{dir:r,size:i})}])},544779,e=>{"use strict";var t=e.i(192749);class r extends t.BaseError{constructor({max:e,min:t,signed:r,size:i,value:s}){super(`Number "${s}" is not in safe ${i?`${8*i}-bit ${r?"signed":"unsigned"} `:""}integer range ${e?`(${t} to ${e})`:`(above ${t})`}`,{name:"IntegerOutOfRangeError"})}}t.BaseError,t.BaseError,t.BaseError;class i extends t.BaseError{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed ${t} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}e.s(["IntegerOutOfRangeError",0,r,"SizeOverflowError",0,i])},664e3,e=>{"use strict";var t=e.i(611745);e.s(["size",0,function(e){return(0,t.isHex)(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}])},331044,e=>{"use strict";var t=e.i(544779),r=e.i(664e3);function i(e,{size:s}){if((0,r.size)(e)>s)throw new t.SizeOverflowError({givenSize:(0,r.size)(e),maxSize:s})}function s(e,t={}){let{signed:r}=t;t.size&&i(e,{size:t.size});let n=BigInt(e);if(!r)return n;let o=(e.length-2)/2;return n<=(1n<<8n*BigInt(o)-1n)-1n?n:n-BigInt(`0x${"f".padStart(2*o,"f")}`)-1n}e.s(["assertSize",0,i,"hexToBigInt",0,s,"hexToNumber",0,function(e,t={}){return Number(s(e,t))}])},639075,e=>{"use strict";var t=e.i(544779),r=e.i(829987),i=e.i(331044);let s=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function n(e,t={}){let o="";for(let t=0;t<e.length;t++)o+=s[e[t]];let a=`0x${o}`;return"number"==typeof t.size?((0,i.assertSize)(a,{size:t.size}),(0,r.pad)(a,{dir:"right",size:t.size})):a}function o(e,i={}){let s,{signed:n,size:a}=i,l=BigInt(e);a?s=n?(1n<<8n*BigInt(a)-1n)-1n:2n**(8n*BigInt(a))-1n:"number"==typeof e&&(s=BigInt(Number.MAX_SAFE_INTEGER));let c="bigint"==typeof s&&n?-s-1n:0;if(s&&l>s||l<c){let r="bigint"==typeof e?"n":"";throw new t.IntegerOutOfRangeError({max:s?`${s}${r}`:void 0,min:`${c}${r}`,signed:n,size:a,value:`${e}${r}`})}let u=`0x${(n&&l<0?(1n<<BigInt(8*a))+BigInt(l):l).toString(16)}`;return a?(0,r.pad)(u,{size:a}):u}let a=new TextEncoder;e.s(["numberToHex",0,o,"toHex",0,function(e,t={}){return"number"==typeof e||"bigint"==typeof e?o(e,t):"string"==typeof e?function(e,t={}){return n(a.encode(e),t)}(e,t):"boolean"==typeof e?function(e,t={}){let s=`0x${Number(e)}`;return"number"==typeof t.size?((0,i.assertSize)(s,{size:t.size}),(0,r.pad)(s,{size:t.size})):s}(e,t):n(e,t)}])},135978,e=>{"use strict";var t=e.i(192749),r=e.i(611745),i=e.i(829987),s=e.i(331044),n=e.i(639075);let o=new TextEncoder;function a(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:void 0}function l(e,r={}){let n=e;r.size&&((0,s.assertSize)(n,{size:r.size}),n=(0,i.pad)(n,{dir:"right",size:r.size}));let o=n.slice(2);o.length%2&&(o=`0${o}`);let c=o.length/2,u=new Uint8Array(c);for(let e=0,r=0;e<c;
vendor: 5,242 bytes, line 13
13e++){let i=a(o.charCodeAt(r++)),s=a(o.charCodeAt(r++));if(void 0===i||void 0===s)throw new t.BaseError(`Invalid byte sequence ("${o[r-2]}${o[r-1]}" in "${o}").`);u[e]=16*i+s}return u}function c(e,t={}){let r=o.encode(e);return"number"==typeof t.size?((0,s.assertSize)(r,{size:t.size}),(0,i.pad)(r,{dir:"right",size:t.size})):r}e.s(["stringToBytes",0,c,"toBytes",0,function(e,t={}){var o,a;return"number"==typeof e||"bigint"==typeof e?(o=e,a=t,l((0,n.numberToHex)(o,a))):"boolean"==typeof e?function(e,t={}){let r=new Uint8Array(1);return(r[0]=Number(e),"number"==typeof t.size)?((0,s.assertSize)(r,{size:t.size}),(0,i.pad)(r,{size:t.size})):r}(e,t):(0,r.isHex)(e)?l(e,t):c(e,t)}])},867239,e=>{"use strict";var t=e.i(322866),r=e.i(713301);let i=BigInt(0),s=BigInt(1),n=BigInt(2),o=BigInt(7),a=BigInt(256),l=BigInt(113),c=[],u=[],d=[];for(let e=0,t=s,r=1,h=0;e<24;e++){[r,h]=[h,(2*r+3*h)%5],c.push(2*(5*h+r)),u.push((e+1)*(e+2)/2%64);let f=i;for(let e=0;e<7;e++)(t=(t<<s^(t>>o)*l)%a)&n&&(f^=s<<(s<<BigInt(e))-s);d.push(f)}let h=(0,t.split)(d,!0),f=h[0],p=h[1],g=(e,r,i)=>i>32?(0,t.rotlBH)(e,r,i):(0,t.rotlSH)(e,r,i),y=(e,r,i)=>i>32?(0,t.rotlBL)(e,r,i):(0,t.rotlSL)(e,r,i);class m extends r.Hash{constructor(e,t,i,s=!1,n=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=e,this.suffix=t,this.outputLen=i,this.enableXOF=s,this.rounds=n,(0,r.anumber)(i),!(0<e&&e<200))throw Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=(0,r.u32)(this.state)}clone(){return this._cloneInto()}keccak(){(0,r.swap32IfBE)(this.state32),function(e,t=24){let i=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let t=0;t<10;t++)i[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){let r=(t+8)%10,s=(t+2)%10,n=i[s],o=i[s+1],a=g(n,o,1)^i[r],l=y(n,o,1)^i[r+1];for(let r=0;r<50;r+=10)e[t+r]^=a,e[t+r+1]^=l}let t=e[2],s=e[3];for(let r=0;r<24;r++){let i=u[r],n=g(t,s,i),o=y(t,s,i),a=c[r];t=e[a],s=e[a+1],e[a]=n,e[a+1]=o}for(let t=0;t<50;t+=10){for(let r=0;r<10;r++)i[r]=e[t+r];for(let r=0;r<10;r++)e[t+r]^=~i[(r+2)%10]&i[(r+4)%10]}e[0]^=f[r],e[1]^=p[r]}(0,r.clean)(i)}(this.state32,this.rounds),(0,r.swap32IfBE)(this.state32),this.posOut=0,this.pos=0}update(e){(0,r.aexists)(this),e=(0,r.toBytes)(e),(0,r.abytes)(e);let{blockLen:t,state:i}=this,s=e.length;for(let r=0;r<s;){let n=Math.min(t-this.pos,s-r);for(let t=0;t<n;t++)i[this.pos++]^=e[r++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:t,pos:r,blockLen:i}=this;e[r]^=t,(128&t)!=0&&r===i-1&&this.keccak(),e[i-1]^=128,this.keccak()}writeInto(e){(0,r.aexists)(this,!1),(0,r.abytes)(e),this.finish();let t=this.state,{blockLen:i}=this;for(let r=0,s=e.length;r<s;){this.posOut>=i&&this.keccak();let n=Math.min(i-this.posOut,s-r);e.set(t.subarray(this.posOut,this.posOut+n),r),this.posOut+=n,r+=n}return e}xofInto(e){if(!this.enableXOF)throw Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return(0,r.anumber)(e),this.xofInto(new Uint8Array(e))}digestInto(e){if((0,r.aoutput)(e,this),this.finished)throw Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,(0,r.clean)(this.state)}_cloneInto(e){let{blockLen:t,suffix:r,outputLen:i,rounds:s,enableXOF:n}=this;return e||(e=new m(t,r,i,n,s)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=s,e.suffix=r,e.outputLen=i,e.enableXOF=n,e.destroyed=this.destroyed,e}}let b=(0,r.createHasher)(()=>new m(136,1,32));e.s(["keccak_256",0,b])},139864,e=>{"use strict";var t=e.i(867239),r=e.i(611745),i=e.i(135978),s=e.i(639075);e.s(["keccak256",0,function(e,n){let o=(0,t.keccak_256)((0,r.isHex)(e,{strict:!1})?(0,i.toBytes)(e):e);return"bytes"===(n||"hex")?o:(0,s.toHex)(o)}])},402058,e=>{"use strict";class t extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){let t=super.get(e);return super.has(e)&&void 0!==t&&(this.delete(e),super.set(e,t)),t}set(e,t){if(super.set(e,t),this.maxSize&&this.size>this.maxSize){let e=this.keys().next().value;e&&this.delete(e)}return this}}e.s(["LruMap",0,t])},944306,e=>{"use strict";var t=e.i(135978),r=e.i(139864);let i=new(e.i(402058)).LruMap(8192);e.s(["checksumAddress",0,function(e,s){if(i.has(`${e}.${s}`))return i.get(`${e}.${s}`);let n=s?`${s}${e.toLowerCase()}`:e.substring(2).toLowerCase(),o=(0,r.keccak256)((0,t.stringToBytes)(n),"bytes"),a=(s?n.substring(`${s}0x`.length):n).split("");for(let e=0;e<40;e+=2)o[e>>1]>>4>=8&&a[e]&&(a[e]=a[e].toUpperCase()),(15&o[e>>1])>=8&&a[e+1]&&(a[e+1]=a[e+1].toUpperCase());let l=`0x${a.join("")}`;return i.set(`${e}.${s}`,l),l}])},194377,e=>{"use strict";var t=e.i(944306),r=e.i(139864);e.s(["publicKeyToAddress",0,function(e){let i=(0,r.keccak256)(`0x${e.substring(4)}`).substring(26);return(0,t.checksumAddress)(`0x${i}`)}])},946881,e=>{"use strict";var t=e.i(611745),r=e.i(664e3),i=e.i(331044),s=e.i(639075);async function n({hash:a,signature:l}){let c=(0,t.isHex)(a)?a:(0,s.toHex)(a),{secp256k1:u}=await e.A(958766),d=(()=>
13{if("object"==typeof l&&"r"in l&&"s"in l){let{r:e,s:t,v:r,yParity:s}=l,n=o(Number(s??r));return new u.Signature((0,i.hexToBigInt)(e),(0,i.hexToBigInt)(t)).addRecoveryBit(n)}let e=(0,t.isHex)(l)?l:(0,s.toHex)(l);if(65!==(0,r.size)(e))throw Error("invalid signature length");let n=o((0,i.hexToNumber)(`0x${e.slice(130)}`));return u.Signature.fromCompact(e.substring(2,130)).addRecoveryBit(n)})().recoverPublicKey(c.substring(2)).toHex(!1);return`0x${d}`}function o(e){if(0===e||1===e)return e;if(27===e)return 0;if(28===e)return 1;throw Error("Invalid yParityOrV value")}e.s(["recoverPublicKey",0,n])},473398,e=>{"use strict";var t=e.i(194377),r=e.i(946881);async function i({hash:e,signature:s}){return(0,t.publicKeyToAddress)(await (0,r.recoverPublicKey)({hash:e,signature:s}))}e.s(["recoverAddress",0,i])},534439,e=>{"use strict";e.s(["default",0,function(e){if(e.length>=255)throw TypeError("Alphabet too long");let t=new Uint8Array(256);for(let e=0;e<t.length;e++)t[e]=255;for(let r=0;r<e.length;r++){let i=e.charAt(r),s=i.charCodeAt(0);if(255!==t[s])throw TypeError(i+" is ambiguous");t[s]=r}let r=e.length,i=e.charAt(0),s=Math.log(r)/Math.log(256),n=Math.log(256)/Math.log(r);function o(e){if("string"!=typeof e)throw TypeError("Expected String");if(0===e.length)return new Uint8Array;let n=0,o=0,a=0;for(;e[n]===i;)o++,n++;let l=(e.length-n)*s+1>>>0,c=new Uint8Array(l);for(;n<e.length;){let i=e.charCodeAt(n);if(i>255)return;let s=t[i];if(255===s)return;let o=0;for(let e=l-1;(0!==s||o<a)&&-1!==e;e--,o++)s+=r*c[e]>>>0,c[e]=s%256>>>0,s=s/256>>>0;if(0!==s)throw Error("Non-zero carry");a=o,n++}let u=l-a;for(;u!==l&&0===c[u];)u++;let d=new Uint8Array(o+(l-u)),h=o;for(;u!==l;)d[h++]=c[u++];return d}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw TypeError("Expected Uint8Array");if(0===t.length)return"";let s=0,o=0,a=0,l=t.length;for(;a!==l&&0===t[a];)a++,s++;let c=(l-a)*n+1>>>0,u=new Uint8Array(c);for(;a!==l;){let e=t[a],i=0;for(let t=c-1;(0!==e||i<o)&&-1!==t;t--,i++)e+=256*u[t]>>>0,u[t]=e%r>>>0,e=e/r>>>0;if(0!==e)throw Error("Non-zero carry");o=i,a++}let d=c-o;for(;d!==c&&0===u[d];)d++;let h=i.repeat(s);for(;d<c;++d)h+=e.charAt(u[d]);return h},decodeUnsafe:o,decode:function(e){let t=o(e);if(t)return t;throw Error("Non-base"+r+" character")}}}])},763830,e=>{"use strict";let t=(0,e.i(534439).default)("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");e.s(["default",0,t])},682708,e=>{"use strict";e.s(["compare",0,function(e,t){for(let r=0;r<e.byteLength;r++){if(e[r]<t[r])return -1;if(e[r]>t[r])return 1}return e.byteLength>t.byteLength?1:e.byteLength<t.byteLength?-1:0}])},71686,e=>{"use strict";e.s(["asUint8Array",0,function(e){return null!=globalThis.Buffer?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e}])},725236,e=>{"use strict";var t=e.i(71686);e.s(["allocUnsafe",0,function(e=0){return null!=globalThis.Buffer&&null!=globalThis.Buffer.allocUnsafe?(0,t.asUint8Array)(globalThis.Buffer.allocUnsafe(e)):new Uint8Array(e)}])},369227,e=>{"use strict";var t=e.i(725236),r=e.i(71686);e.s(["concat",0,function(e,i){i||(i=e.reduce((e,t)=>e+t.length,0));let s=(0,t.allocUnsafe)(i),n=0;for(let t of e)s.set(t,n),n+=t.length;return(0,r.asUint8Array)(s)}])},195368,e=>{"use strict";e.s(["equals",0,function(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}])},116625,e=>{"use strict";var t=e.i(18531),r=e.i(725236);function i(e,t,r,i){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:i}}}let s=i("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),n=i("ascii","a",e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t},e=>{e=e.substring(1);let t=(0,r.allocUnsafe)(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),o={utf8:s,"utf-8":s,hex:t.bases.base16,latin1:n,ascii:n,binary:n,...t.bases};e.s(["default",0,o])},103892,e=>{"use strict";var t=e.i(116625),r=e.i(71686);e.s(["fromString",0,function(e,i="utf8"){let s=t.default[i];if(!s)throw Error(`Unsupported encoding "${i}"`);return("utf8"===i||"utf-8"===i)&&null!=globalThis.Buffer&&null!=globalThis.Buffer.from?(0,r.asUint8Array)(globalThis.Buffer.from(e,"utf-8")):s.decoder.decode(`${s.prefix}${e}`)}])},492400,e=>{"use strict";var t=e.i(116625);e.s(["toString",0,function(e,r="utf8"){let i=t.default[r];if(!i)throw Error(`Unsupported encoding "${r}"`);return("utf8"===r||"utf-8"===r)&&null!=globalThis.Buffer&&null!=globalThis.Buffer.from?globalThis.Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString("utf8"):i.encoder.encode(e).substring(1)}])},956628,e=>{"use strict";var t=e.i(725236),r=e.i(71686);e.s(["xor",0,function(e,i){if(e.length!==i.length)throw Error("Inputs should have the same length");let s=(0,t.allocUnsafe)(e.length);for(let t=0;t<e.length;t++)s[t]=e[t]^i[t];return(0,r.asUint8Array)(s)}])},164546,e=>{"use strict";e.i(682708),e.i(369227),e.i(195368),e.i(103892),e.i(492400),e.i(956628),e.s([])},741483,e=>{"use strict";let t,r,i,s,n;var o,a,l=e.i(247167),c=e.i(467034),u=e.i(277945),d=e.i(648512),h=e.i(36610),f=e.i(275221),p=e.i(473398),g=e.i(763830),y=e.i(626335),m=e.i(425748),b=e.i(166953),v=e.i(121609);e.i(164546);var w=e.i(492400),_=e.i(103892),S=e.i(369227),E=e.i(281223),I=e.i(5625);function A(e){let[t,r]=e.split(":");return{namespace:t,reference:r}}function T(e,t){return e.includes(":")?[e]:t.chains||[]}var x=Object.defineProperty,k=Object.defineProperties,P=Object.getOwnPropertyDescriptors,O=Object.getOwnPropertySymbols,R=Object.prototype.hasOwnProperty,C=Object.prototype.propertyIsEnumerable,N=(e,t,r)=>t in e?x(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,B=(e,t)=>{for(var r in t||(t={}))R.call(t,r)&&N(e,r,t[r]);if(O)for(var r of O(t))C.call(t,r)&&N(e,r,t[r]);return e},U=(e,t,r)=>N(e,"symbol"!=typeof t?t+"":t,r);let q="react-native",L="node",D="browser";function M(){return"u">typeof l.default&&"u">typeof l.default.versions&&"u">typeof l.default.versions.node}
13function K(){return!(0,h.getDocument)()&&!!(0,h.getNavigator)()&&"ReactNative"===navigator.product}function W(){return!M()&&!!(0,h.getNavigator)()&&!!(0,h.getDocument)()}function z(){return K()?q:M()?L:W()?D:"unknown"}function j(){return(0,f.getWindowMetadata)()||{name:"",description:"",url:"",icons:[""]}}function V(t,r,i){var s;let n,o=function(){if(z()===q&&"u">typeof(null==e.g?void 0:e.g.Platform)){let{OS:t,Version:r}=e.g.Platform;return[t,r].join("-")}let t=(0,u.detect)();if(null===t)return"unknown";let r=t.os?t.os.replace(" ","").toLowerCase():"unknown";return"browser"===t.type?[r,t.name,t.version].join("-"):[r,t.version].join("-")}(),a=(n=z())===D?[n,(null==(s=(0,h.getLocation)())?void 0:s.host)||"unknown"].join(":"):n;return[[t,r].join("-"),["js",i].join("-"),o,a].join("/")}function $(e,t){return e.filter(e=>t.includes(e)).length===e.length}function F(e,t){if("string"==typeof t&&t.startsWith(`${e}:`))return t;if("topic"===e.toLowerCase()){if("string"!=typeof t)throw Error('Value must be "string" for expirer target type: topic');return`topic:${t}`}if("id"===e.toLowerCase()){if("number"!=typeof t)throw Error('Value must be "number" for expirer target type: id');return`id:${t}`}throw Error(`Unknown expirer target type: ${e}`)}function H(e=[],t=[]){return[...new Set([...e,...t])]}async function G({id:t,topic:r,wcDeepLink:i}){var s,n;try{if(!i)return;let o="string"==typeof i?JSON.parse(i):i,a=o?.href;if("string"!=typeof a)return;let l=function(e,t,r){let i=`requestId=${t}&sessionTopic=${r}`;e.endsWith("/")&&(e=e.slice(0,-1));let s=`${e}`;if(e.startsWith("https://t.me")){let t=e.includes("?")?"&startapp=":"?startapp=";s=`${s}${t}${function(e,t=!1){let r=c.Buffer.from(e).toString("base64");return t?r.replace(/[=]/g,""):r}(i,!0)}`}else s=`${s}/wc?${i}`;return s}(a,t,r),u=z();if(u===D){let e;if(!(null!=(s=(0,h.getDocument)())&&s.hasFocus()))return void console.warn("Document does not have focus, skipping deeplink.");n=l,e="_self",!function(){try{return window.self!==window.top}catch{return!1}}()?("u">typeof window&&(window.TelegramWebviewProxy||window.Telegram||window.TelegramWebviewProxyProto)||n.startsWith("https://")||n.startsWith("http://"))&&(e="_blank"):e="_top",window.open(n,e,"noreferrer noopener")}else u===q&&"u">typeof(null==e.g?void 0:e.g.Linking)&&await e.g.Linking.openURL(l)}catch(e){console.error(e)}}async function J(e,t){let r="";try{if(W()&&(r=localStorage.getItem(t)))return r;r=await e.getItem(t)}catch(e){console.error(e)}return r}function Y(e){return c.Buffer.from(e,"base64").toString("utf-8")}let Z=BigInt(0x100000000-1),X=BigInt(32);function Q(e,t=!1){return t?{h:Number(e&Z),l:Number(e>>X&Z)}:{h:0|Number(e>>X&Z),l:0|Number(e&Z)}}function ee(e,t=!1){let r=e.length,i=new Uint32Array(r),s=new Uint32Array(r);for(let n=0;n<r;n++){let{h:r,l:o}=Q(e[n],t);[i[n],s[n]]=[r,o]}return[i,s]}let et=(e,t,r)=>e>>>r,er=(e,t,r)=>e<<32-r|t>>>r,ei=(e,t,r)=>e>>>r|t<<32-r,es=(e,t,r)=>e<<32-r|t>>>r,en=(e,t,r)=>e<<64-r|t>>>r-32,eo=(e,t,r)=>e>>>r-32|t<<64-r;function ea(e,t,r,i){let s=(t>>>0)+(i>>>0);return{h:e+r+(s/0x100000000|0)|0,l:0|s}}let el=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),ec=(e,t,r,i)=>t+r+i+(e/0x100000000|0)|0,eu=(e,t,r,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(i>>>0),ed=(e,t,r,i,s)=>t+r+i+s+(e/0x100000000|0)|0,eh=(e,t,r,i,s)=>(e>>>0)+(t>>>0)+(r>>>0)+(i>>>0)+(s>>>0),ef=(e,t,r,i,s,n)=>t+r+i+s+n+(e/0x100000000|0)|0,ep="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;function eg(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function ey(e){if(!Number.isSafeInteger(e)||e<0)throw Error("positive integer expected, got "+e)}function em(e,...t){if(!eg(e))throw Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw Error("Uint8Array expected of length "+t+", got length="+e.length)}function eb(e){if("function"!=typeof e||"function"!=typeof e.create)throw Error("Hash should be wrapped by utils.createHasher");ey(e.outputLen),ey(e.blockLen)}function ev(e,t=!0){if(e.destroyed)throw Error("Hash instance has been destroyed");if(t&&e.finished)throw Error("Hash#digest() has already been called")}function ew(e,t){em(e);let r=t.outputLen;if(e.length<r)throw Error("digestInto() expects output buffer of length at least "+r)}function e_(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function eS(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function eE(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function eI(e,t){return e<<32-t|e>>>t}let eA=68===new Uint8Array(new Uint32Array([0x11223344]).buffer)[0];function eT(e){return e<<24&0xff000000|e<<8&0xff0000|e>>>8&65280|e>>>24&255}let ex=eA?e=>e:e=>eT(e),ek=eA?e=>e:function(e){for(let t=0;t<e.length;t++)e[t]=eT(e[t]);return e},eP="function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex,eO=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function eR(e){if(em(e),eP)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=eO[e[r]];return t}function eC(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:void 0}function eN(e){if("string"!=typeof e)throw Error("hex string expected, got "+typeof e);if(eP)return Uint8Array.fromHex(e);let t=e.length,r=t/2;if(t%2)throw Error("hex string expected, got unpadded hex of length "+t);let i=new Uint8Array(r);for(let t=0,s=0;t<r;t++,s+=2){let r=eC(e.charCodeAt(s)),n=eC(e.charCodeAt(s+1));if(void 0===r||void 0===n)throw Error('hex string expected, got non-hex character "'+(e[s]+e[s+1])+'" at index '+s);i[t]=16*r+n}return i}function eB(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}(e)),em(e),e}function eU(...e){let t=0;for(let r=0;r<e.length;r++){let i=e[r];em(i),t+=i.length}let r=new Uint8Array(t);for(let t=0,i=0;t<e.length;t++){let s=e[t];r.set(s,i),i+=s.length}return r}class eq{}function eL(e){let t=t=>e().update(eB(t)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function eD(e=32){if(ep&&"function"==typeof ep.getRandomValues)return ep.getRandomValues(new Uint8Array(e));if(ep&&"function"==typeof ep.randomBytes)return Uint8Array.from(ep.randomBytes(e));throw Error("crypto.getRandomValues must be defined")}let eM=BigInt(0),eK=BigInt(1),eW=BigInt(2),ez=BigInt(7),ej=BigInt(256),eV=BigInt(113),e$=[],eF=[],eH=[];for(let e=0,t=eK,r=1,i=0;e<24;e++){[r,i]=[i,(2*r+3*i)%5],e$.push(2*(5*i+r)),eF.push((e+1)*(e+2)/2%64);let s=eM;for(let e=0;e<7;e++)(t=(t<<eK^(t>>ez)*eV)%ej)&eW&&(s^=eK<<(eK<<BigInt(e))-eK);eH.push(s)}let eG=ee(eH,!0),eJ=eG[0],eY=eG[1],eZ=(e,t,r)=>r>32?t<<r-32|e>>>64-r:e<<r|t>>>32-r,eX=(e,t,r)=>r>32?e<<r-32|t>>>64-r:t<<r|e>>>32-r;class eQ extends eq{constructor(e,t,r,i=!1,s=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=e,this.suffix=t,this.outputLen=r,this.enableXOF=i,this.rounds=s,ey(r),!(0<e&&e<200))throw Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=e_(this.state)}clone(){return this._cloneInto()}keccak(){ek(this.state32),function(e,t=24){let r=new Uint32Array(10);for(let i=24-t;i<24;i++){for(let t=0;t<10;t++)r[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){let i=(t+8)%10,s=(t+2)%10,n=r[s],o=r[s+1],a=eZ(n,o,1)^r[i],l=eX(n,o,1)^r[i+1];for(let r=0;r<50;r+=10)e[t+r]^=a,e[t+r+1]^=l}let t=e[2],s=e[3];for(let r=0;r<24;r++){let i=eF[r],n=eZ(t,s,i),o=eX(t,s,i),a=e$[r];t=e[a],s=e[a+1],e[a]=n,e[a+1]=o}for(let t=0;t<50;t+=10){for(let i=0;i<10;i++)r[i]=e[t+i];for(let i=0;i<10;i++)e[t+i]^=~r[(i+2)%10]&r[(i+4)%10]}e[0]^=eJ[i],e[1]^=eY[i]}eS(r)}(this.state32,this.rounds),ek(this.state32),this.posOut=0,this.pos=0}update(e){ev(this),em(e=eB(e));let{blockLen:t,state:r}=this,i=e.length;for(let s=0;s<i;){let n=Math.min(t-this.pos,i-s);for(let t=0;t<n;t++)r[this.pos++]^=e[s++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:t,pos:r,blockLen:i}=this;e[r]^=t,(128&t)!=0&&r===i-1&&this.keccak(),e[i-1]^=128,this.keccak()}writeInto(e){ev(this,!1),em(e),this.finish();let t=this.state,{blockLen:r}=this;for(let i=0,s=e.length;i<s;){this.posOut>=r&&this.keccak();let n=Math.min(r-this.posOut,s-i);e.set(t.subarray(this.posOut,this.posOut+n),i),this.posOut+=n,i+=n}return e}xofInto(e){if(!this.enableXOF)throw Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return ey(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(ew(e,this),this.finished)throw Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,eS(this.state)}_cloneInto(e){let{blockLen:t,suffix:r,outputLen:i,rounds:s,enableXOF:n}=this;return e||(e=new eQ(t,r,i,n,s)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=s,e.suffix=r,e.outputLen=i,e.enableXOF=n,e.destroyed=this.destroyed,e}}let e0=eL(()=>new eQ(136,1,32));
13class e1 extends eq{constructor(e,t,r,i){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=i,this.buffer=new Uint8Array(e),this.view=eE(this.buffer)}update(e){ev(this),em(e=eB(e));let{view:t,buffer:r,blockLen:i}=this,s=e.length;for(let n=0;n<s;){let o=Math.min(i-this.pos,s-n);if(o===i){let t=eE(e);for(;i<=s-n;n+=i)this.process(t,n);continue}r.set(e.subarray(n,n+o),this.pos),this.pos+=o,n+=o,this.pos===i&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){ev(this),ew(e,this),this.finished=!0;let{buffer:t,view:r,blockLen:i,isLE:s}=this,{pos:n}=this;t[n++]=128,eS(this.buffer.subarray(n)),this.padOffset>i-n&&(this.process(r,0),n=0);for(let e=n;e<i;e++)t[e]=0;(function(e,t,r,i){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,r,i);let s=BigInt(32),n=BigInt(0xffffffff),o=Number(r>>s&n),a=Number(r&n),l=4*!!i,c=4*!i;e.setUint32(t+l,o,i),e.setUint32(t+c,a,i)})(r,i-8,BigInt(8*this.length),s),this.process(r,0);let o=eE(e),a=this.outputLen;if(a%4)throw Error("_sha2: outputLen should be aligned to 32bit");let l=a/4,c=this.get();if(l>c.length)throw Error("_sha2: outputLen bigger than state");for(let e=0;e<l;e++)o.setUint32(4*e,c[e],s)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:t,buffer:r,length:i,finished:s,destroyed:n,pos:o}=this;return e.destroyed=n,e.finished=s,e.length=i,e.pos=o,i%t&&e.buffer.set(r),e}clone(){return this._cloneInto()}}let e2=Uint32Array.from([0x6a09e667,0xbb67ae85,0x3c6ef372,0xa54ff53a,0x510e527f,0x9b05688c,0x1f83d9ab,0x5be0cd19]),e5=Uint32Array.from([0xcbbb9d5d,0xc1059ed8,0x629a292a,0x367cd507,0x9159015a,0x3070dd17,0x152fecd8,0xf70e5939,0x67332667,0xffc00b31,0x8eb44a87,0x68581511,0xdb0c2e0d,0x64f98fa7,0x47b5481d,0xbefa4fa4]),e6=Uint32Array.from([0x6a09e667,0xf3bcc908,0xbb67ae85,0x84caa73b,0x3c6ef372,0xfe94f82b,0xa54ff53a,0x5f1d36f1,0x510e527f,0xade682d1,0x9b05688c,0x2b3e6c1f,0x1f83d9ab,0xfb41bd6b,0x5be0cd19,0x137e2179]),e3=Uint32Array.from([0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5,0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5,0xd807aa98,0x12835b01,0x243185be,0x550c7dc3,0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174,0xe49b69c1,0xefbe4786,0xfc19dc6,0x240ca1cc,0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da,0x983e5152,0xa831c66d,0xb00327c8,0xbf597fc7,0xc6e00bf3,0xd5a79147,0x6ca6351,0x14292967,0x27b70a85,0x2e1b2138,0x4d2c6dfc,0x53380d13,0x650a7354,0x766a0abb,0x81c2c92e,0x92722c85,0xa2bfe8a1,0xa81a664b,0xc24b8b70,0xc76c51a3,0xd192e819,0xd6990624,0xf40e3585,0x106aa070,0x19a4c116,0x1e376c08,0x2748774c,0x34b0bcb5,0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3,0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208,0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2]),e8=new Uint32Array(64);class e4 extends e1{constructor(e=32){super(64,e,8,!1),this.A=0|e2[0],this.B=0|e2[1],this.C=0|e2[2],this.D=0|e2[3],this.E=0|e2[4],this.F=0|e2[5],this.G=0|e2[6],this.H=0|e2[7]}get(){let{A:e,B:t,C:r,D:i,E:s,F:n,G:o,H:a}=this;return[e,t,r,i,s,n,o,a]}set(e,t,r,i,s,n,o,a){this.A=0|e,this.B=0|t,this.C=0|r,this.D=0|i,this.E=0|s,this.F=0|n,this.G=0|o,this.H=0|a}process(e,t){for(let r=0;r<16;r++,t+=4)e8[r]=e.getUint32(t,!1);for(let e=16;e<64;e++){let t=e8[e-15],r=e8[e-2],i=eI(t,7)^eI(t,18)^t>>>3,s=eI(r,17)^eI(r,19)^r>>>10;e8[e]=s+e8[e-7]+i+e8[e-16]|0}let{A:r,B:i,C:s,D:n,E:o,F:a,G:l,H:c}=this;for(let e=0;e<64;e++){var u,d,h,f;let t=c+(eI(o,6)^eI(o,11)^eI(o,25))+((u=o)&a^~u&l)+e3[e]+e8[e]|0,p=(eI(r,2)^eI(r,13)^eI(r,22))+((d=r)&(h=i)^d&(f=s)^h&f)|0;c=l,l=a,a=o,o=n+t|0,n=s,s=i,i=r,r=t+p|0}r=r+this.A|0,i=i+this.B|0,s=s+this.C|0,n=n+this.D|0,o=o+this.E|0,a=a+this.F|0,l=l+this.G|0,c=c+this.H|0,this.set(r,i,s,n,o,a,l,c)}roundClean(){eS(e8)}destroy(){this.set(0,0,0,0,0,0,0,0),eS(this.buffer)}}let e7=ee(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b89
136f","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(e=>BigInt(e))),e9=e7[0],te=e7[1],tt=new Uint32Array(80),tr=new Uint32Array(80);class ti extends e1{constructor(e=64){super(128,e,16,!1),this.Ah=0|e6[0],this.Al=0|e6[1],this.Bh=0|e6[2],this.Bl=0|e6[3],this.Ch=0|e6[4],this.Cl=0|e6[5],this.Dh=0|e6[6],this.Dl=0|e6[7],this.Eh=0|e6[8],this.El=0|e6[9],this.Fh=0|e6[10],this.Fl=0|e6[11],this.Gh=0|e6[12],this.Gl=0|e6[13],this.Hh=0|e6[14],this.Hl=0|e6[15]}get(){let{Ah:e,Al:t,Bh:r,Bl:i,Ch:s,Cl:n,Dh:o,Dl:a,Eh:l,El:c,Fh:u,Fl:d,Gh:h,Gl:f,Hh:p,Hl:g}=this;return[e,t,r,i,s,n,o,a,l,c,u,d,h,f,p,g]}set(e,t,r,i,s,n,o,a,l,c,u,d,h,f,p,g){this.Ah=0|e,this.Al=0|t,this.Bh=0|r,this.Bl=0|i,this.Ch=0|s,this.Cl=0|n,this.Dh=0|o,this.Dl=0|a,this.Eh=0|l,this.El=0|c,this.Fh=0|u,this.Fl=0|d,this.Gh=0|h,this.Gl=0|f,this.Hh=0|p,this.Hl=0|g}process(e,t){for(let r=0;r<16;r++,t+=4)tt[r]=e.getUint32(t),tr[r]=e.getUint32(t+=4);for(let e=16;e<80;e++){let t=0|tt[e-15],r=0|tr[e-15],i=ei(t,r,1)^ei(t,r,8)^et(t,r,7),s=es(t,r,1)^es(t,r,8)^er(t,r,7),n=0|tt[e-2],o=0|tr[e-2],a=ei(n,o,19)^en(n,o,61)^et(n,o,6),l=eu(s,es(n,o,19)^eo(n,o,61)^er(n,o,6),tr[e-7],tr[e-16]),c=ed(l,i,a,tt[e-7],tt[e-16]);tt[e]=0|c,tr[e]=0|l}let{Ah:r,Al:i,Bh:s,Bl:n,Ch:o,Cl:a,Dh:l,Dl:c,Eh:u,El:d,Fh:h,Fl:f,Gh:p,Gl:g,Hh:y,Hl:m}=this;for(let e=0;e<80;e++){let t=ei(u,d,14)^ei(u,d,18)^en(u,d,41),b=es(u,d,14)^es(u,d,18)^eo(u,d,41),v=u&h^~u&p,w=eh(m,b,d&f^~d&g,te[e],tr[e]),_=ef(w,y,t,v,e9[e],tt[e]),S=0|w,E=ei(r,i,28)^en(r,i,34)^en(r,i,39),I=es(r,i,28)^eo(r,i,34)^eo(r,i,39),A=r&s^r&o^s&o,T=i&n^i&a^n&a;y=0|p,m=0|g,p=0|h,g=0|f,h=0|u,f=0|d,({h:u,l:d}=ea(0|l,0|c,0|_,0|S)),l=0|o,c=0|a,o=0|s,a=0|n,s=0|r,n=0|i;let x=el(S,I,T);r=ec(x,_,E,A),i=0|x}({h:r,l:i}=ea(0|this.Ah,0|this.Al,0|r,0|i)),({h:s,l:n}=ea(0|this.Bh,0|this.Bl,0|s,0|n)),({h:o,l:a}=ea(0|this.Ch,0|this.Cl,0|o,0|a)),({h:l,l:c}=ea(0|this.Dh,0|this.Dl,0|l,0|c)),({h:u,l:d}=ea(0|this.Eh,0|this.El,0|u,0|d)),({h:h,l:f}=ea(0|this.Fh,0|this.Fl,0|h,0|f)),({h:p,l:g}=ea(0|this.Gh,0|this.Gl,0|p,0|g)),({h:y,l:m}=ea(0|this.Hh,0|this.Hl,0|y,0|m)),this.set(r,i,s,n,o,a,l,c,u,d,h,f,p,g,y,m)}roundClean(){eS(tt,tr)}destroy(){eS(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class ts extends ti{constructor(){super(48),this.Ah=0|e5[0],this.Al=0|e5[1],this.Bh=0|e5[2],this.Bl=0|e5[3],this.Ch=0|e5[4],this.Cl=0|e5[5],this.Dh=0|e5[6],this.Dl=0|e5[7],this.Eh=0|e5[8],this.El=0|e5[9],this.Fh=0|e5[10],this.Fl=0|e5[11],this.Gh=0|e5[12],this.Gl=0|e5[13],this.Hh=0|e5[14],this.Hl=0|e5[15]}}let tn=Uint32Array.from([0x22312194,0xfc2bf72c,0x9f555fa3,0xc84c64c2,0x2393b86b,0x6f53b151,0x96387719,0x5940eabd,0x96283ee2,0xa88effe3,0xbe5e1e25,0x53863992,0x2b0199fc,0x2c85b8aa,0xeb72ddc,0x81c52ca2]);class to extends ti{constructor(){super(32),this.Ah=0|tn[0],this.Al=0|tn[1],this.Bh=0|tn[2],this.Bl=0|tn[3],this.Ch=0|tn[4],this.Cl=0|tn[5],this.Dh=0|tn[6],this.Dl=0|tn[7
13],this.Eh=0|tn[8],this.El=0|tn[9],this.Fh=0|tn[10],this.Fl=0|tn[11],this.Gh=0|tn[12],this.Gl=0|tn[13],this.Hh=0|tn[14],this.Hl=0|tn[15]}}let ta=eL(()=>new e4),tl=eL(()=>new ti),tc=eL(()=>new ts),tu=eL(()=>new to),td=Uint8Array.from([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9]),th=Uint32Array.from([0xf3bcc908,0x6a09e667,0x84caa73b,0xbb67ae85,0xfe94f82b,0x3c6ef372,0x5f1d36f1,0xa54ff53a,0xade682d1,0x510e527f,0x2b3e6c1f,0x9b05688c,0xfb41bd6b,0x1f83d9ab,0x137e2179,0x5be0cd19]),tf=new Uint32Array(32);function tp(e,t,r,i,s,n){let o=s[n],a=s[n+1],l=tf[2*e],c=tf[2*e+1],u=tf[2*t],d=tf[2*t+1],h=tf[2*r],f=tf[2*r+1],p=tf[2*i],g=tf[2*i+1],y=el(l,u,o);c=ec(y,c,d,a),l=0|y,({Dh:g,Dl:p}={Dh:g^c,Dl:p^l}),({Dh:g,Dl:p}={Dh:p,Dl:g}),({h:f,l:h}=ea(f,h,g,p)),({Bh:d,Bl:u}={Bh:d^f,Bl:u^h}),({Bh:d,Bl:u}={Bh:ei(d,u,24),Bl:es(d,u,24)}),tf[2*e]=l,tf[2*e+1]=c,tf[2*t]=u,tf[2*t+1]=d,tf[2*r]=h,tf[2*r+1]=f,tf[2*i]=p,tf[2*i+1]=g}function tg(e,t,r,i,s,n){let o=s[n],a=s[n+1],l=tf[2*e],c=tf[2*e+1],u=tf[2*t],d=tf[2*t+1],h=tf[2*r],f=tf[2*r+1],p=tf[2*i],g=tf[2*i+1],y=el(l,u,o);c=ec(y,c,d,a),l=0|y,({Dh:g,Dl:p}={Dh:g^c,Dl:p^l}),({Dh:g,Dl:p}={Dh:ei(g,p,16),Dl:es(g,p,16)}),({h:f,l:h}=ea(f,h,g,p)),({Bh:d,Bl:u}={Bh:d^f,Bl:u^h}),({Bh:d,Bl:u}={Bh:en(d,u,63),Bl:eo(d,u,63)}),tf[2*e]=l,tf[2*e+1]=c,tf[2*t]=u,tf[2*t+1]=d,tf[2*r]=h,tf[2*r+1]=f,tf[2*i]=p,tf[2*i+1]=g}class ty extends eq{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,this.length=0,this.pos=0,ey(e),ey(t),this.blockLen=e,this.outputLen=t,this.buffer=new Uint8Array(e),this.buffer32=e_(this.buffer)}update(e){ev(this),em(e=eB(e));let{blockLen:t,buffer:r,buffer32:i}=this,s=e.length,n=e.byteOffset,o=e.buffer;for(let a=0;a<s;){this.pos===t&&(ek(i),this.compress(i,0,!1),ek(i),this.pos=0);let l=Math.min(t-this.pos,s-a),c=n+a;if(l===t&&!(c%4)&&a+l<s){let e=new Uint32Array(o,c,Math.floor((s-a)/4));ek(e);for(let r=0;a+t<s;r+=i.length,a+=t)this.length+=t,this.compress(e,r,!1);ek(e);continue}r.set(e.subarray(a,a+l),this.pos),this.pos+=l,this.length+=l,a+=l}return this}digestInto(e){ev(this),ew(e,this);let{pos:t,buffer32:r}=this;this.finished=!0,eS(this.buffer.subarray(t)),ek(r),this.compress(r,0,!0),ek(r);let i=e_(e);this.get().forEach((e,t)=>i[t]=ex(e))}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){let{buffer:t,length:r,finished:i,destroyed:s,outputLen:n,pos:o}=this;return e||(e=new this.constructor({dkLen:n})),e.set(...this.get()),e.buffer.set(t),e.destroyed=s,e.finished=i,e.length=r,e.pos=o,e.outputLen=n,e}clone(){return this._cloneInto()}}class tm extends ty{constructor(e={}){const t=void 0===e.dkLen?64:e.dkLen;super(128,t),this.v0l=0|th[0],this.v0h=0|th[1],this.v1l=0|th[2],this.v1h=0|th[3],this.v2l=0|th[4],this.v2h=0|th[5],this.v3l=0|th[6],this.v3h=0|th[7],this.v4l=0|th[8],this.v4h=0|th[9],this.v5l=0|th[10],this.v5h=0|th[11],this.v6l=0|th[12],this.v6h=0|th[13],this.v7l=0|th[14],this.v7h=0|th[15],function(e,t={}){if(ey(64),e<0||e>64)throw Error("outputLen bigger than keyLen");let{key:r,salt:i,personalization:s}=t;if(void 0!==r&&(r.length<1||r.length>64))throw Error("key length must be undefined or 1..64");if(void 0!==i&&16!==i.length)throw Error("salt must be undefined or 16");if(void 0!==s&&16!==s.length)throw Error("personalization must be undefined or 16")}(t,e);let{key:r,personalization:i,salt:s}=e,n=0;if(void 0!==r&&(n=(r=eB(r)).length),this.v0l^=this.outputLen|n<<8|0x1010000,void 0!==s){const e=e_(s=eB(s));this.v4l^=ex(e[0]),this.v4h^=ex(e[1]),this.v5l^=ex(e[2]),this.v5h^=ex(e[3])}if(void 0!==i){const e=e_(i=eB(i));this.v6l^=ex(e[0]),this.v6h^=ex(e[1]),this.v7l^=ex(e[2]),this.v7h^=ex(e[3])}if(void 0!==r){const e=new Uint8Array(this.blockLen);e.set(r),this.update(e)}}
13get(){let{v0l:e,v0h:t,v1l:r,v1h:i,v2l:s,v2h:n,v3l:o,v3h:a,v4l:l,v4h:c,v5l:u,v5h:d,v6l:h,v6h:f,v7l:p,v7h:g}=this;return[e,t,r,i,s,n,o,a,l,c,u,d,h,f,p,g]}set(e,t,r,i,s,n,o,a,l,c,u,d,h,f,p,g){this.v0l=0|e,this.v0h=0|t,this.v1l=0|r,this.v1h=0|i,this.v2l=0|s,this.v2h=0|n,this.v3l=0|o,this.v3h=0|a,this.v4l=0|l,this.v4h=0|c,this.v5l=0|u,this.v5h=0|d,this.v6l=0|h,this.v6h=0|f,this.v7l=0|p,this.v7h=0|g}compress(e,t,r){this.get().forEach((e,t)=>tf[t]=e),tf.set(th,16);let{h:i,l:s}=Q(BigInt(this.length));tf[24]=th[8]^s,tf[25]=th[9]^i,r&&(tf[28]=~tf[28],tf[29]=~tf[29]);let n=0;for(let r=0;r<12;r++)tp(0,4,8,12,e,t+2*td[n++]),tg(0,4,8,12,e,t+2*td[n++]),tp(1,5,9,13,e,t+2*td[n++]),tg(1,5,9,13,e,t+2*td[n++]),tp(2,6,10,14,e,t+2*td[n++]),tg(2,6,10,14,e,t+2*td[n++]),tp(3,7,11,15,e,t+2*td[n++]),tg(3,7,11,15,e,t+2*td[n++]),tp(0,5,10,15,e,t+2*td[n++]),tg(0,5,10,15,e,t+2*td[n++]),tp(1,6,11,12,e,t+2*td[n++]),tg(1,6,11,12,e,t+2*td[n++]),tp(2,7,8,13,e,t+2*td[n++]),tg(2,7,8,13,e,t+2*td[n++]),tp(3,4,9,14,e,t+2*td[n++]),tg(3,4,9,14,e,t+2*td[n++]);this.v0l^=tf[0]^tf[16],this.v0h^=tf[1]^tf[17],this.v1l^=tf[2]^tf[18],this.v1h^=tf[3]^tf[19],this.v2l^=tf[4]^tf[20],this.v2h^=tf[5]^tf[21],this.v3l^=tf[6]^tf[22],this.v3h^=tf[7]^tf[23],this.v4l^=tf[8]^tf[24],this.v4h^=tf[9]^tf[25],this.v5l^=tf[10]^tf[26],this.v5h^=tf[11]^tf[27],this.v6l^=tf[12]^tf[28],this.v6h^=tf[13]^tf[29],this.v7l^=tf[14]^tf[30],this.v7h^=tf[15]^tf[31],eS(tf)}destroy(){this.destroyed=!0,eS(this.buffer32),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}let tb=(o=e=>new tm(e),(t=(e,t)=>o(t).update(eB(e)).digest()).outputLen=(r=o({})).outputLen,t.blockLen=r.blockLen,t.create=e=>o(e),t);function tv(e){let t=`�Ethereum Signed Message:
14${e.length}`,r=new TextEncoder().encode(t+e);return"0x"+c.Buffer.from(e0(r)).toString("hex")}async function tw(e,t,r,i,s,n){switch(r.t){case"eip191":return await t_(e,t,r.s);case"eip1271":return await tS(e,t,r.s,i,s,n);default:throw Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${r.t}`)}}async function t_(e,t,r){return(await (0,p.recoverAddress)({hash:tv(t),signature:r})).toLowerCase()===e.toLowerCase()}async function tS(e,t,r,i,s,n){let o=A(i);if(!o.namespace||!o.reference)throw Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${i}`);try{let o="0x1626ba7e",a=r.substring(2),l=(a.length/2).toString(16).padStart(64,"0"),c=(t.startsWith("0x")?t:tv(t)).substring(2),u=o+c+"0000000000000000000000000000000000000000000000000000000000000040"+l+a,d=await fetch(`${n||"https://rpc.walletconnect.org/v1"}/?chainId=${i}&projectId=${s}`,{headers:{"Content-Type":"application/json"},method:"POST",body:JSON.stringify({id:Date.now()+Math.floor(1e3*Math.random()),jsonrpc:"2.0",method:"eth_call",params:[{to:e,data:u},"latest"]})}),{result:h}=await d.json();return!!h&&h.slice(0,o.length).toLowerCase()===o.toLowerCase()}catch(e){return console.error("isValidEip1271Signature: ",e),!1}}function tE(e){let t=[],r=BigInt(e);for(;r>=BigInt(128);)t.push(Number(r&BigInt(127)|BigInt(128))),r>>=BigInt(7);return t.push(Number(r)),c.Buffer.from(t)}var tI=Object.defineProperty,tA=Object.defineProperties,tT=Object.getOwnPropertyDescriptors,tx=Object.getOwnPropertySymbols,tk=Object.prototype.hasOwnProperty,tP=Object.prototype.propertyIsEnumerable,tO=(e,t,r)=>t in e?tI(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;let tR=e=>e?.split(":"),tC=e=>{let t=e&&tR(e);if(t)return t[2]+":"+t[3]},tN=e=>{let t=e&&tR(e);if(t)return t.pop()};async function tB(e){let{cacao:t,projectId:r}=e,{s:i,p:s}=t,n=tU(s,s.iss),o=tN(s.iss);return await tw(o,n,i,tC(s.iss),r)}let tU=(e,t)=>{let r=`${e.domain} wants you to sign in with your Ethereum account:`,i=tN(t);if(!e.aud&&!e.uri)throw Error("Either `aud` or `uri` is required to construct the message");let s=e.statement||void 0,n=`URI: ${e.aud||e.uri}`,o=`Version: ${e.version}`,a=`Chain ID: ${(e=>{let t=e&&tR(e);if(t)return e.includes("did:pkh:")?t[3]:t[1]})(t)}`,l=`Nonce: ${e.nonce}`,c=`Issued At: ${e.iat}`,u=e.exp?`Expiration Time: ${e.exp}`:void 0,d=e.nbf?`Not Before: ${e.nbf}`:void 0,h=e.requestId?`Request ID: ${e.requestId}`:void 0,f=e.resources?`Resources:${e.resources.map(e=>`
15- ${e}`).join("")}`:void 0,p=tM(e.resources);return p&&(s=function(e="",t){tq(t);let r="I further authorize the stated URI to perform the following actions on my behalf: ";if(e.includes(r))return e;let i=[],s=0;
15Object.keys(t.att).forEach(e=>{let r=Object.keys(t.att[e]).map(e=>({ability:e.split("/")[0],action:e.split("/")[1]}));r.sort((e,t)=>e.action.localeCompare(t.action));let n={};r.forEach(e=>{n[e.ability]||(n[e.ability]=[]),n[e.ability].push(e.action)});let o=Object.keys(n).map(t=>(s++,`(${s}) '${t}': '${n[t].join("', '")}' for '${e}'.`));i.push(o.join(", ").replace(".,","."))});let n=i.join(" "),o=`${r}${n}`;return`${e?e+" ":""}${o}`}(s,tD(p))),[r,i,"",s,"",n,o,a,l,c,u,d,h,f].filter(e=>null!=e).join(`
16`)};function tq(e){if(!e)throw Error("No recap provided, value is undefined");if(!e.att)throw Error("No `att` property found");let t=Object.keys(e.att);if(!(null!=t&&t.length))throw Error("No resources found in `att` property");t.forEach(t=>{let r=e.att[t];if(Array.isArray(r)||"object"!=typeof r)throw Error(`Resource must be an object: ${t}`);if(!Object.keys(r).length)throw Error(`Resource object is empty: ${t}`);Object.keys(r).forEach(e=>{let t=r[e];if(!Array.isArray(t))throw Error(`Ability limits ${e} must be an array of objects, found: ${t}`);if(!t.length)throw Error(`Value of ${e} is empty array, must be an array with objects`);t.forEach(t=>{if("object"!=typeof t)throw Error(`Ability limits (${e}) must be an array of objects, found: ${t}`)})})})}function tL(e){return tq(e),`urn:recap:${c.Buffer.from(JSON.stringify(e)).toString("base64").replace(/=/g,"")}`}function tD(e){var t;let r=(t=e.replace("urn:recap:",""),JSON.parse(c.Buffer.from(t,"base64").toString("utf-8")));return tq(r),r}function tM(e){if(!e)return;let t=e?.[e.length-1];return t&&t.includes("urn:recap:")?t:void 0}function tK(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function tW(e){if("boolean"!=typeof e)throw Error(`boolean expected, not ${e}`)}function tz(e){if(!Number.isSafeInteger(e)||e<0)throw Error("positive integer expected, got "+e)}function tj(e,...t){if(!tK(e))throw Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw Error("Uint8Array expected of length "+t+", got length="+e.length)}function tV(e,t=!0){if(e.destroyed)throw Error("Hash instance has been destroyed");if(t&&e.finished)throw Error("Hash#digest() has already been called")}function t$(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function tF(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}let tH=68===new Uint8Array(new Uint32Array([0x11223344]).buffer)[0];function tG(e){if("string"==typeof e)e=function(e){if("string"!=typeof e)throw Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}(e);else if(tK(e))e=tZ(e);else throw Error("Uint8Array expected, got "+typeof e);return e}function tJ(e,t,r=!0){if(void 0===t)return new Uint8Array(e);if(t.length!==e)throw Error("invalid output length, expected "+e+", got: "+t.length);if(r&&t.byteOffset%4!=0)throw Error("invalid output, must be aligned");return t}function tY(e,t,r,i){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,r,i);let s=BigInt(32),n=BigInt(0xffffffff),o=Number(r>>s&n),a=Number(r&n),l=4*!!i,c=4*!i;e.setUint32(t+l,o,i),e.setUint32(t+c,a,i)}function tZ(e){return Uint8Array.from(e)}let tX=e=>Uint8Array.from(e.split("").map(e=>e.charCodeAt(0))),tQ=tX("expand 16-byte k"),t0=tX("expand 32-byte k"),t1=t$(tQ),t2=t$(t0);function t5(e,t){return e<<t|e>>>32-t}function t6(e){return e.byteOffset%4==0}let t3=0x100000000-1,t8=new Uint32Array,t4=(e,t)=>255&e[t++]|(255&e[t++])<<8;class t7{constructor(e){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,tj(e=tG(e),32);const t=t4(e,0),r=t4(e,2),i=t4(e,4),s=t4(e,6),n=t4(e,8),o=t4(e,10),a=t4(e,12),l=t4(e,14);this.r[0]=8191&t,this.r[1]=(t>>>13|r<<3)&8191,this.r[2]=(r>>>10|i<<6)&7939,this.r[3]=(i>>>7|s<<9)&8191,this.r[4]=(s>>>4|n<<12)&255,this.r[5]=n>>>1&8190,this.r[6]=(n>>>14|o<<2)&8191,this.r[7]=(o>>>11|a<<5)&8065,this.r[8]=(a>>>8|l<<8)&8191,this.r[9]=l>>>5&127;for(let t=0;t<8;t++)this.pad[t]=t4(e,16+2*t)}process(e,t,r=!1){let{h:i,r:s}=this,n=s[0],o=s[1],a=s[2],l=s[3],c=s[4],u=s[5],d=s[6],h=s[7],f=s[8],p=s[9],g=t4(e,t+0),y=t4(e,t+2),m=t4(e,t+4),b=t4(e,t+6),v=t4(e,t+8),w=t4(e,t+10),_=t4(e,t+12),S=t4(e,t+14),E=i[0]+(8191&g),I=i[1]+((g>>>13|y<<3)&8191),A=i[2]+((y>>>10|m<<6)&8191),T=i[3]+((m>>>7|b<<9)&8191),x=i[4]+((b>>>4|v<<12)&8191),k=i[5]+(v>>>1&8191),P=i[6]+((v>>>14|w<<2)&8191),O=i[7]+((w>>>11|_<<5)&8191),R=i[8]+((_>>>
168|S<<8)&8191),C=i[9]+(S>>>5|2048*!r),N=0,B=0+E*n+5*p*I+5*f*A+5*h*T+5*d*x;N=B>>>13,B&=8191,B+=5*u*k+5*c*P+5*l*O+5*a*R+5*o*C,N+=B>>>13,B&=8191;let U=N+E*o+I*n+5*p*A+5*f*T+5*h*x;N=U>>>13,U&=8191,U+=5*d*k+5*u*P+5*c*O+5*l*R+5*a*C,N+=U>>>13,U&=8191;let q=N+E*a+I*o+A*n+5*p*T+5*f*x;N=q>>>13,q&=8191,q+=5*h*k+5*d*P+5*u*O+5*c*R+5*l*C,N+=q>>>13,q&=8191;let L=N+E*l+I*a+A*o+T*n+5*p*x;N=L>>>13,L&=8191,L+=5*f*k+5*h*P+5*d*O+5*u*R+5*c*C,N+=L>>>13,L&=8191;let D=N+E*c+I*l+A*a+T*o+x*n;N=D>>>13,D&=8191,D+=5*p*k+5*f*P+5*h*O+5*d*R+5*u*C,N+=D>>>13,D&=8191;let M=N+E*u+I*c+A*l+T*a+x*o;N=M>>>13,M&=8191,M+=k*n+5*p*P+5*f*O+5*h*R+5*d*C,N+=M>>>13,M&=8191;let K=N+E*d+I*u+A*c+T*l+x*a;N=K>>>13,K&=8191,K+=k*o+P*n+5*p*O+5*f*R+5*h*C,N+=K>>>13,K&=8191;let W=N+E*h+I*d+A*u+T*c+x*l;N=W>>>13,W&=8191,W+=k*a+P*o+O*n+5*p*R+5*f*C,N+=W>>>13,W&=8191;let z=N+E*f+I*h+A*d+T*u+x*c;N=z>>>13,z&=8191,z+=k*l+P*a+O*o+R*n+5*p*C,N+=z>>>13,z&=8191;let j=N+E*p+I*f+A*h+T*d+x*u;N=j>>>13,j&=8191,j+=k*c+P*l+O*a+R*o+C*n,N+=j>>>13,j&=8191,B=8191&(N=(N=(N<<2)+N|0)+B|0),N>>>=13,U+=N,i[0]=B,i[1]=U,i[2]=q,i[3]=L,i[4]=D,i[5]=M,i[6]=K,i[7]=W,i[8]=z,i[9]=j}finalize(){let{h:e,pad:t}=this,r=new Uint16Array(10),i=e[1]>>>13;e[1]&=8191;for(let t=2;t<10;t++)e[t]+=i,i=e[t]>>>13,e[t]&=8191;e[0]+=5*i,i=e[0]>>>13,e[0]&=8191,e[1]+=i,i=e[1]>>>13,e[1]&=8191,e[2]+=i,r[0]=e[0]+5,i=r[0]>>>13,r[0]&=8191;for(let t=1;t<10;t++)r[t]=e[t]+i,i=r[t]>>>13,r[t]&=8191;r[9]-=8192;let s=(1^i)-1;for(let e=0;e<10;e++)r[e]&=s;s=~s;for(let t=0;t<10;t++)e[t]=e[t]&s|r[t];e[0]=(e[0]|e[1]<<13)&65535,e[1]=(e[1]>>>3|e[2]<<10)&65535,e[2]=(e[2]>>>6|e[3]<<7)&65535,e[3]=(e[3]>>>9|e[4]<<4)&65535,e[4]=(e[4]>>>12|e[5]<<1|e[6]<<14)&65535,e[5]=(e[6]>>>2|e[7]<<11)&65535,e[6]=(e[7]>>>5|e[8]<<8)&65535,e[7]=(e[8]>>>8|e[9]<<5)&65535;let n=e[0]+t[0];e[0]=65535&n;for(let r=1;r<8;r++)n=(e[r]+t[r]|0)+(n>>>16)|0,e[r]=65535&n;tF(r)}update(e){tV(this),tj(e=tG(e));let{buffer:t,blockLen:r}=this,i=e.length;for(let s=0;s<i;){let n=Math.min(r-this.pos,i-s);if(n===r){for(;r<=i-s;s+=r)this.process(e,s);continue}t.set(e.subarray(s,s+n),this.pos),this.pos+=n,s+=n,this.pos===r&&(this.process(t,0,!1),this.pos=0)}return this}destroy(){tF(this.h,this.r,this.buffer,this.pad)}digestInto(e){tV(this),function(e,t){tj(e);let r=t.outputLen;if(e.length<r)throw Error("digestInto() expects output buffer of length at least "+r)}(e,this),this.finished=!0;let{buffer:t,h:r}=this,{pos:i}=this;if(i){for(t[i++]=1;i<16;i++)t[i]=0;this.process(t,0,!0)}this.finalize();let s=0;for(let t=0;t<8;t++)e[s++]=r[t]>>>0,e[s++]=r[t]>>>8;return e}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let r=e.slice(0,t);return this.destroy(),r}}let t9=(a=e=>new t7(e),(i=(e,t)=>a(t).update(tG(e)).digest()).outputLen=(s=a(new Uint8Array(32))).outputLen,i.blockLen=s.blockLen,i.create=e=>a(e),i),re=function(e,t){let{allowShortKeys:r,extendNonceFn:i,counterLength:s,counterRight:n,rounds:o}=function(e,t){if(null==t||"object"!=typeof t)throw Error("options must be defined");return Object.assign(e,t)}({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t);if("function"!=typeof e)throw Error("core must be a function");return tz(s),tz(o),tW(n),tW(r),(t,a,l,c,u=0)=>{tj(t),tj(a),tj(l);let d=l.length;if(void 0===c&&(c=new Uint8Array(d)),tj(c),tz(u),u<0||u>=t3)throw Error("arx: counter overflow");if(c.length<d)throw Error(`arx: output (${c.length}) is shorter than data (${d})`);let h=[],f=t.length,p,g;if(32===f)h.push(p=tZ(t)),g=t2;else if(16===f&&r)(p=new Uint8Array(32)).set(t),p.set(t,16),g=t1,h.push(p);else throw Error(`arx: invalid 32-byte key, got length=${f}`);t6(a)||h.push(a=tZ(a));let y=t$(p);if(i){if(24!==a.length)throw Error("arx: extended nonce must be 24 bytes");i(g,y,t$(a.subarray(0,16)),y),a=a.subarray(16)}let m=16-s;if(m!==a.length)throw Error(`arx: nonce must be ${m} or 16 bytes`);if(12!==m){let e=new Uint8Array(12);e.set(a,n?0:12-a.length),a=e,h.push(a)}return function(e,t,r,i,s,n,o,a){let l=s.length,c=new Uint8Array(64),u=t$(c),d=t6(s)&&t6(n),h=d?t$(s):t8,f=d?t$(n):t8;for(let p=0;p<l;o++){if(e(t,r,i,u,o,a),o>=t3)throw Error("arx: counter overflow");let g=Math.min(64,l-p);if(d&&64===g){let e=p/4;
16if(p%4!=0)throw Error("arx: invalid block position");for(let t=0,r;t<16;t++)f[r=e+t]=h[r]^u[t];p+=64;continue}for(let e=0,t;e<g;e++)n[t=p+e]=s[t]^c[e];p+=g}}(e,g,y,t$(a),l,c,u,o),tF(...h),c}}(function(e,t,r,i,s,n=20){let o=e[0],a=e[1],l=e[2],c=e[3],u=t[0],d=t[1],h=t[2],f=t[3],p=t[4],g=t[5],y=t[6],m=t[7],b=r[0],v=r[1],w=r[2],_=o,S=a,E=l,I=c,A=u,T=d,x=h,k=f,P=p,O=g,R=y,C=m,N=s,B=b,U=v,q=w;for(let e=0;e<n;e+=2)P=P+(N=t5(N^(_=_+A|0),16))|0,_=_+(A=t5(A^P,12))|0,P=P+(N=t5(N^_,8))|0,A=t5(A^P,7),O=O+(B=t5(B^(S=S+T|0),16))|0,S=S+(T=t5(T^O,12))|0,O=O+(B=t5(B^S,8))|0,T=t5(T^O,7),R=R+(U=t5(U^(E=E+x|0),16))|0,E=E+(x=t5(x^R,12))|0,R=R+(U=t5(U^E,8))|0,x=t5(x^R,7),C=C+(q=t5(q^(I=I+k|0),16))|0,I=I+(k=t5(k^C,12))|0,C=C+(q=t5(q^I,8))|0,k=t5(k^C,7),R=R+(q=t5(q^(_=_+T|0),16))|0,_=_+(T=t5(T^R,12))|0,R=R+(q=t5(q^_,8))|0,T=t5(T^R,7),C=C+(N=t5(N^(S=S+x|0),16))|0,S=S+(x=t5(x^C,12))|0,C=C+(N=t5(N^S,8))|0,x=t5(x^C,7),P=P+(B=t5(B^(E=E+k|0),16))|0,E=E+(k=t5(k^P,12))|0,P=P+(B=t5(B^E,8))|0,k=t5(k^P,7),O=O+(U=t5(U^(I=I+A|0),16))|0,I=I+(A=t5(A^O,12))|0,O=O+(U=t5(U^I,8))|0,A=t5(A^O,7);let L=0;i[L++]=o+_|0,i[L++]=a+S|0,i[L++]=l+E|0,i[L++]=c+I|0,i[L++]=u+A|0,i[L++]=d+T|0,i[L++]=h+x|0,i[L++]=f+k|0,i[L++]=p+P|0,i[L++]=g+O|0,i[L++]=y+R|0,i[L++]=m+C|0,i[L++]=s+N|0,i[L++]=b+B|0,i[L++]=v+U|0,i[L++]=w+q|0},{counterRight:!1,counterLength:4,allowShortKeys:!1}),rt=new Uint8Array(16),rr=(e,t)=>{e.update(t);let r=t.length%16;r&&e.update(rt.subarray(r))},ri=new Uint8Array(32);function rs(e,t,r,i,s){var n,o;let a,l,c=e(t,r,ri),u=t9.create(c);s&&rr(u,s),rr(u,i);let d=(n=i.length,o=s?s.length:0,tW(!0),tY(l=new DataView((a=new Uint8Array(16)).buffer,a.byteOffset,a.byteLength),0,BigInt(o),!0),tY(l,8,BigInt(n),!0),a);u.update(d);let h=u.digest();return tF(c,d),h}let rn=((e,t)=>{function r(i,...s){if(tj(i),!tH)throw Error("Non little-endian hardware is not yet supported");if(void 0!==e.nonceLength){let t=s[0];if(!t)throw Error("nonce / iv required");e.varSizeNonce?tj(t):tj(t,e.nonceLength)}let n=e.tagLength;n&&void 0!==s[1]&&tj(s[1]);let o=t(i,...s),a=(e,t)=>{if(void 0!==t){if(2!==e)throw Error("cipher output not supported");tj(t)}},l=!1;return{encrypt(e,t){if(l)throw Error("cannot encrypt() twice with same key + nonce");return l=!0,tj(e),a(o.encrypt.length,t),o.encrypt(e,t)},decrypt(e,t){if(tj(e),n&&e.length<n)throw Error("invalid ciphertext length: smaller than tagLength="+n);return a(o.decrypt.length,t),o.decrypt(e,t)}}}return Object.assign(r,e),r})({blockSize:64,nonceLength:12,tagLength:16},(e,t,r)=>({encrypt(i,s){let n=i.length;(s=tJ(n+16,s,!1)).set(i);let o=s.subarray(0,-16);re(e,t,o,o,1);let a=rs(re,e,t,o,r);return s.set(a,n),tF(a),s},decrypt(i,s){s=tJ(i.length-16,s,!1);let n=i.subarray(0,-16),o=i.subarray(-16),a=rs(re,e,t,n,r);if(!function(e,t){if(e.length!==t.length)return!1;let r=0;for(let i=0;i<e.length;i++)r|=e[i]^t[i];return 0===r}(o,a))throw Error("invalid tag");return s.set(i.subarray(0,-16)),re(e,t,s,s,1),tF(a),s}}));class ro extends eq{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,eb(e);const r=eB(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const i=this.blockLen,s=new Uint8Array(i);s.set(r.length>i?e.create().update(r).digest():r);for(let e=0;e<s.length;e++)s[e]^=54;this.iHash.update(s),this.oHash=e.create();for(let e=0;e<s.length;e++)s[e]^=106;this.oHash.update(s),eS(s)}update(e){return ev(this),this.iHash.update(e),this}digestInto(e){ev(this),em(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));let{oHash:t,iHash:r,finished:i,destroyed:s,blockLen:n,outputLen:o}=this;return e.finished=i,e.destroyed=s,e.blockLen=n,e.outputLen=o,e.oHash=t._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}let ra=(e,t,r)=>new ro(e,t).update(r).digest();ra.create=(e,t)=>
vendor: 6,012 bytes, line 16
16new ro(e,t);let rl=Uint8Array.from([0]),rc=Uint8Array.of(),ru=BigInt(0),rd=BigInt(1);function rh(e,t){if("boolean"!=typeof t)throw Error(e+" boolean expected, got "+t)}function rf(e){let t=e.toString(16);return 1&t.length?"0"+t:t}function rp(e){if("string"!=typeof e)throw Error("hex string expected, got "+typeof e);return""===e?ru:BigInt("0x"+e)}function rg(e){return em(e),rp(eR(Uint8Array.from(e).reverse()))}function ry(e,t){return eN(e.toString(16).padStart(2*t,"0"))}function rm(e,t){return ry(e,t).reverse()}function rb(e,t,r){let i;if("string"==typeof t)try{i=eN(t)}catch(t){throw Error(e+" must be hex string or Uint8Array, cause: "+t)}else if(eg(t))i=Uint8Array.from(t);else throw Error(e+" must be hex string or Uint8Array");let s=i.length;if("number"==typeof r&&s!==r)throw Error(e+" of length "+r+" expected, got "+s);return i}let rv=e=>"bigint"==typeof e&&ru<=e;function rw(e,t,r,i){if(!(rv(t)&&rv(r)&&rv(i))||!(r<=t)||!(t<i))throw Error("expected valid "+e+": "+r+" <= n < "+i+", got "+t)}let r_=e=>(rd<<BigInt(e))-rd;function rS(e,t,r={}){if(!e||"object"!=typeof e)throw Error("expected valid options object");function i(t,r,i){let s=e[t];if(i&&void 0===s)return;let n=typeof s;if(n!==r||null===s)throw Error(`param "${t}" is invalid: expected ${r}, got ${n}`)}Object.entries(t).forEach(([e,t])=>i(e,t,!1)),Object.entries(r).forEach(([e,t])=>i(e,t,!0))}function rE(e){let t=new WeakMap;return(r,...i)=>{let s=t.get(r);if(void 0!==s)return s;let n=e(r,...i);return t.set(r,n),n}}let rI=BigInt(0),rA=BigInt(1),rT=BigInt(2),rx=BigInt(3),rk=BigInt(4),rP=BigInt(5),rO=BigInt(8);function rR(e,t){let r=e%t;return r>=rI?r:t+r}function rC(e,t,r){let i=e;for(;t-- >rI;)i*=i,i%=r;return i}function rN(e,t){if(e===rI)throw Error("invert: expected non-zero number");if(t<=rI)throw Error("invert: expected positive modulus, got "+t);let r=rR(e,t),i=t,s=rI,n=rA;for(;r!==rI;){let e=i/r,t=i%r,o=s-n*e;i=r,r=t,s=n,n=o}if(i!==rA)throw Error("invert: does not exist");return rR(s,t)}function rB(e,t){let r=(e.ORDER+rA)/rk,i=e.pow(t,r);if(!e.eql(e.sqr(i),t))throw Error("Cannot find square root");return i}function rU(e,t){let r=(e.ORDER-rP)/rO,i=e.mul(t,rT),s=e.pow(i,r),n=e.mul(t,s),o=e.mul(e.mul(n,rT),s),a=e.mul(n,e.sub(o,e.ONE));if(!e.eql(e.sqr(a),t))throw Error("Cannot find square root");return a}let rq=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function rL(e,t,r=!1){let i=Array(t.length).fill(r?e.ZERO:void 0),s=t.reduce((t,r,s)=>e.is0(r)?t:(i[s]=t,e.mul(t,r)),e.ONE),n=e.inv(s);return t.reduceRight((t,r,s)=>e.is0(r)?t:(i[s]=e.mul(t,i[s]),e.mul(t,r)),n),i}function rD(e,t){let r=(e.ORDER-rA)/rT,i=e.pow(t,r),s=e.eql(i,e.ONE),n=e.eql(i,e.ZERO),o=e.eql(i,e.neg(e.ONE));if(!s&&!n&&!o)throw Error("invalid Legendre symbol result");return s?1:n?0:-1}function rM(e,t,r=!1,i={}){var s;let n,o,a,l,c;if(e<=rI)throw Error("invalid field: expected ORDER > 0, got "+e);if("object"==typeof t&&null!=t){if(i.sqrt||r)throw Error("cannot specify opts in two arguments");t.BITS&&(n=t.BITS),t.sqrt&&(o=t.sqrt),"boolean"==typeof t.isLE&&(r=t.isLE)}else"number"==typeof t&&(n=t),i.sqrt&&(o=i.sqrt);let{nBitLength:u,nByteLength:d}=(void 0!==(s=n)&&ey(s),c=Math.ceil((l=void 0!==s?s:e.toString(2).length)/8),{nBitLength:l,nByteLength:c});if(d>2048)throw Error("invalid field: expected ORDER of <= 2048 bytes");let h=Object.freeze({ORDER:e,isLE:r,BITS:u,BYTES:d,MASK:r_(u),ZERO:rI,ONE:rA,create:t=>rR(t,e),isValid:t=>{if("bigint"!=typeof t)throw Error("invalid field element: expected bigint, got "+typeof t);return rI<=t&&t<e},is0:e=>e===rI,isValidNot0:e=>!h.is0(e)&&h.isValid(e),isOdd:e=>(e&rA)===rA,neg:t=>rR(-t,e),eql:(e,t)=>e===t,sqr:t=>rR(t*t,e),add:(t,r)=>rR(t+r,e),sub:(t,r)=>rR(t-r,e),mul:(t,r)=>rR(t*r,e),pow:(e,t)=>(function(e,t,r){if(r<rI)throw Error("invalid exponent, negatives unsupported");if(r===rI)return e.ONE;if(r===rA)return t;let i=e.ONE,s=t;for(;r>rI;)r&rA&&(i=e.mul(i,s)),s=e.sqr(s),r>>=rA;return i})(h,e,t),div:(t,r)=>rR(t*rN(r,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>rN(t,e),sqrt:o||(t=>(a||(a=e%rk===rx?rB:e%rO===rP?rU:function(e){if(e<BigInt(3))throw Error("sqrt is not defined for small field");let t=e-rA,r=0;for(;t%rT===rI;)t/=rT,r++;let i=rT,s=rM(e);for(;1===rD(s,i);)if(i++>1e3)throw Error("Cannot find square root: probably non-prime P");if(1===r)return rB;let n=s.pow(i,t),o=(t+rA)/rT;return function(e,i){if(e.is0(i))return i;if(1!==rD(e,i))throw Error("Cannot find square root");let s=r,a=e.mul(e.ONE,n),l=e.pow(i,t),c=e.pow(i,o);for(;!e.eql(l,e.ONE);){if(e.is0(l))return e.ZERO;let t=1,r=e.sqr(l);for(;!e.eql(r,e.ONE);)if(t++,r=e.sqr(r),t===s)throw Error("Cannot find square root");let i=rA<<BigInt(s-t-1),n=e.pow(a,i);s=t,a=e.sqr(n),l=e.mul(l,a),c=e.mul(c,n)}return c}}(e)),a(h,t))),toBytes:e=>r?rm(e,d):ry(e,d),fromBytes:e=>{if(e.length!==d)throw Error("Field.fromBytes: expected "+d+" bytes, got "+e.length);return r?rg(e):rp(eR(e))},invertBatch:e=>rL(h,e),cmov:(e,t,r)=>r?t:e});return Object.freeze(h)}function rK(e){if("bigint"!=typeof e)throw Error("field order must be bigint");return Math.ceil(e.toString(2).length/8)}function rW(e){let t=rK(e);return t+Math.ceil(t/2)}let rz=BigInt(0),rj=BigInt(1);function rV(e,t){let r=t.negate();return e?r:t}function r$(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw Error("invalid window size, expected [1.."+t+"], got W="+e)}function rF(e,t){r$(e,t);let r=Math.ceil(t/e)+1,i=2**(e-1),s=2**e;return{windows:r,windowSize:i,mask:r_(e),maxNumber:s,shiftBy:BigInt(e)}}function rH(e,t,r){let{windowSize:i,mask:s,maxNumber:n,shiftBy:o}=r,a=Number(e&s),l=e>>o;a>i&&(a-=n,l+=rj);let c=t*i;return{nextN:l,offset:c+Math.abs(a)-1,isZero:0===a,isNeg:a<0,isNegF:t%2!=0,offsetF:c}}let rG=new WeakMap,rJ=new WeakMap;function rY(e){return rJ.get(e)||1}function rZ(e){if(e!==rz)throw Error("invalid wNAF")}function rX(e,t){if(!t)return rM(e);if(t.ORDER!==e)throw Error("Field.ORDER must match order: Fp == p, Fn == n");return rS(t,rq.reduce((e,t)=>
16(e[t]="function",e),{ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"})),t}BigInt(0),BigInt(1),BigInt(2),BigInt(8);let rQ=BigInt(0),r0=BigInt(1),r1=BigInt(2);BigInt(0);let r2=BigInt(1),r5=BigInt(2),r6=BigInt(3),r3=BigInt(5),r8=BigInt(8),r4={p:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:r8,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")},r7=function(e){let{P:t,type:r,adjustScalarBytes:i,powPminus2:s,randomBytes:n}=(rS(e,{adjustScalarBytes:"function",powPminus2:"function"}),Object.freeze({...e})),o="x25519"===r;if(!o&&"x448"!==r)throw Error("invalid type");let a=n||eD,l=o?255:448,c=o?32:56,u=BigInt(o?9:5),d=BigInt(o?121665:39081),h=o?r1**BigInt(254):r1**BigInt(447),f=h+(o?BigInt(8)*r1**BigInt(251)-r0:BigInt(4)*r1**BigInt(445)-r0)+r0,p=e=>rR(e,t),g=rm(p(u),c);function y(e,r){let n,a=function(e,r){rw("u",e,rQ,t),rw("scalar",r,h,f);let i=r0,n=rQ,o=e,a=r0,c=rQ;for(let t=BigInt(l-1);t>=rQ;t--){let s=r>>t&r0;c^=s,({x_2:i,x_3:o}=b(c,i,o)),({x_2:n,x_3:a}=b(c,n,a)),c=s;let l=i+n,u=p(l*l),h=i-n,f=p(h*h),g=u-f,y=o+a,m=p((o-a)*l),v=p(y*h),w=m+v,_=m-v;o=p(w*w),a=p(e*p(_*_)),i=p(u*f),n=p(g*(u+p(d*g)))}return{x_2:i,x_3:o}=b(c,i,o),{x_2:n,x_3:a}=b(c,n,a),p(i*s(n))}((n=rb("u coordinate",r,c),o&&(n[31]&=127),p(rg(n))),rg(i(rb("scalar",e,c))));if(a===rQ)throw Error("invalid private or public key received");return rm(p(a),c)}function m(e){return y(e,g)}function b(e,t,r){let i=p(e*(t-r));return{x_2:t=p(t-i),x_3:r=p(r+i)}}return{scalarMult:y,scalarMultBase:m,getSharedSecret:(e,t)=>y(e,t),getPublicKey:e=>m(e),utils:{randomPrivateKey:()=>a(c)},GuBytes:g.slice()}}({P:n=r4.p,type:"x25519",powPminus2:e=>{let t,r,i,s,o,a,l,c,u,d,h,f,p,g,y,{pow_p_5_8:m,b2:b}=(t=BigInt(10),r=BigInt(20),i=BigInt(40),s=BigInt(80),l=rC(a=e*e%(o=r4.p)*e%o,r5,o)*a%o,c=rC(l,r2,o)*e%o,u=rC(c,r3,o)*c%o,d=rC(u,t,o)*u%o,h=rC(d,r,o)*d%o,f=rC(h,i,o)*h%o,p=rC(f,s,o)*f%o,g=rC(p,s,o)*f%o,y=rC(g,t,o)*u%o,{pow_p_5_8:rC(y,r5,o)*e%o,b2:a});return rR(rC(m,r6,n)*b,n)},adjustScalarBytes:function(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}});function r9(e){void 0!==e.lowS&&rh("lowS",e.lowS),void 0!==e.prehash&&rh("prehash",e.prehash)}let ie={Err:class extends Error{constructor(e=""){super(e)}},_tlv:{encode:(e,t)=>{let{Err:r}=ie;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(1&t.length)throw new r("tlv.encode: unpadded data");let i=t.length/2,s=rf(i);if(s.length/2&128)throw new r("tlv.encode: long form length too big");let n=i>127?rf(s.length/2|128):"";return rf(e)+n+s+t},decode(e,t){let{Err:r}=ie,i=0;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length<2||t[i++]!==e)throw new r("tlv.decode: wrong tlv");let s=t[i++],n=0;if(128&s){let e=127&s;if(!e)throw new r("tlv.decode(long): indefinite length not supported");if(e>4)throw new r("tlv.decode(long): byte length is too big");let o=t.subarray(i,i+e);if(o.length!==e)throw new r("tlv.decode: length bytes not complete");if(0===o[0])throw new r("tlv.decode(long): zero leftmost byte");for(let e of o)n=n<<8|e;if(i+=e,n<128)throw new r("tlv.decode(long): not minimal encoding")}else n=s;let o=t.subarray(i,i+n);if(o.length!==n)throw new r("tlv.decode: wrong value length");return{v:o,l:t.subarray(i+n)}}},_int:{encode(e){let{Err:t}=ie;if(e<it)throw new t("integer: negative integers are not allowed");let r=rf(e);if(8&Number.parseInt(r[0],16)&&(r="00"+r),1&r.length)throw new t("unexpected DER parsing assertion: unpadded hex");return r},decode(e){let{Err:t}=ie;if(128&e[0])throw new t("invalid signature integer: negative");if(0===e[0]&&!(128&e[1]))throw new t("invalid signature integer: unnecessary leading zero");return rp(eR(e))}},toSig(e){let{Err:t,_int:r,_tlv:i}=ie,s=rb("signature",e),{v:n,l:o}=i.decode(48,s);if(o.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:l}=i.decode(2,n),{v:c,l:u}=i.decode(2,l);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(c)}},hexFromSig(e){let{_tlv:t,_int:r}=ie,i=t.encode(2,r.encode(e.r)),s=t.encode(2,r.encode(e.s));return t.encode(48,i+s)}},it=BigInt(0),ir=BigInt(1),ii=BigInt(2),is=BigInt(3),io=BigInt(4);function ia(e,t,r){let{BYTES:i}=e;return function(s){let n;if("bigint"==typeof s)n=s;else{let r=rb("private key",s);if(t){if(!t.includes(2*r.length))throw Error("invalid private key");let e=new Uint8Array(i);e.set(r,e.length-r.length),r=e}try{n=e.fromBytes(r)}catch{throw Error(`invalid private key: expected ui8a of size ${i}, got ${typeof s}`)}}if(r&&(n=e.create(n)),!e.isValidNot0(n))throw Error("invalid private key: out of range [1..N-1]");return n}}function il(e){return Uint8Array.of(e?2:3)}function ic(e,t){let r=t=>(function(e){let{CURVE:t,curveOpts:r,ecdsaOpts:i}=function(e){let t,r,{CURVE:i,curveOpts:s}=(t={a:e.a,b:e.b,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},r={Fp:e.Fp,Fn:rM(t.n,e.nBitLength),allowedPrivateKeyLengths:e.allowedPrivateKeyLengths,allowInfinityPoint:e.allowInfinityPoint,endo:e.endo,wrapPrivateKey:e.wrapPrivateKey,isTorsionFree:e.isTorsionFree,clearCofactor:e.clearCofactor,fromBytes:e.fromBytes,toBytes:e.toBytes},{CURVE:t,curveOpts:r});return{CURVE:i,curveOpts:s,ecdsaOpts:{hash:e.hash,hmac:e.hmac,randomBytes:e.randomBytes,lowS:e.lowS,bits2int:e.bits2int,bits2int_modN:e.bits2int_modN}}}(e),s=function(e,t,r={}){rS(t,{hash:"function"},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});let i=t.randomBytes||eD,s=t.hmac||((e,...r)=>ra(t.hash,e,eU(...r))),{Fp:n,Fn:o}=e,{ORDER:a,BITS:l}=o;function c(e,t){if(!o.isValidNot0(t))throw Error(`invalid signature ${e}: out of range 1..CURVE.n`)}class u{constructor(e,t,r){c("r",e),c("s",t),this.r=e,this.s=t,null!=r&&(this.recovery=r),Object.freeze(this)}static fromCompact(e){let t=o.BYTES,r=rb("compactSignature",e,2*t);return new u(o.fromBytes(r.subarray(0,t)),o.fromBytes(r.subarray(t,2*t)))}static fromDER(e){let{r:t,s:r}=ie.toSig(rb("DER",e));return new u(t,r)}
16assertValidity(){}addRecoveryBit(e){return new u(this.r,this.s,e)}recoverPublicKey(t){let r=n.ORDER,{r:i,s:s,recovery:l}=this;if(null==l||![0,1,2,3].includes(l))throw Error("recovery id invalid");if(a*ii<r&&l>1)throw Error("recovery id is ambiguous for h>1 curve");let c=2===l||3===l?i+a:i;if(!n.isValid(c))throw Error("recovery id 2 or 3 invalid");let u=n.toBytes(c),d=e.fromHex(eU(il((1&l)==0),u)),h=o.inv(c),f=p(rb("msgHash",t)),g=o.create(-f*h),y=o.create(s*h),m=e.BASE.multiplyUnsafe(g).add(d.multiplyUnsafe(y));if(m.is0())throw Error("point at infinify");return m.assertValidity(),m}hasHighS(){return this.s>a>>ir}normalizeS(){return this.hasHighS()?new u(this.r,o.neg(this.s),this.recovery):this}toBytes(e){if("compact"===e)return eU(o.toBytes(this.r),o.toBytes(this.s));if("der"===e)return eN(ie.hexFromSig(this));throw Error("invalid format")}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return eR(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return eR(this.toBytes("compact"))}}let d=ia(o,r.allowedPrivateKeyLengths,r.wrapPrivateKey);function h(t){if("bigint"==typeof t)return!1;if(t instanceof e)return!0;let i=rb("key",t).length,s=n.BYTES,a=s+1;if(!(r.allowedPrivateKeyLengths||o.BYTES===a))return i===a||i===2*s+1}let f=t.bits2int||function(e){if(e.length>8192)throw Error("input is too large");let t=rp(eR(e)),r=8*e.length-l;return r>0?t>>BigInt(r):t},p=t.bits2int_modN||function(e){return o.create(f(e))},g=r_(l);function y(e){return rw("num < 2^"+l,e,it,g),o.toBytes(e)}let m={lowS:t.lowS,prehash:!1},b={lowS:t.lowS,prehash:!1};return e.BASE.precompute(8),Object.freeze({getPublicKey:function(t,r=!0){return e.fromPrivateKey(t).toBytes(r)},getSharedSecret:function(t,r,i=!0){if(!0===h(t))throw Error("first arg must be private key");if(!1===h(r))throw Error("second arg must be public key");return e.fromHex(r).multiply(d(t)).toBytes(i)},sign:function(r,l,c=m){let{seed:h,k2sig:g}=function(r,s,l=m){if(["recovered","canonical"].some(e=>e in l))throw Error("sign() legacy options not supported");let{hash:c}=t,{lowS:h,prehash:g,extraEntropy:b}=l;null==h&&(h=!0),r=rb("msgHash",r),r9(l),g&&(r=rb("prehashed msgHash",c(r)));let v=p(r),w=d(s),_=[y(w),y(v)];if(null!=b&&!1!==b){let e=!0===b?i(n.BYTES):b;_.push(rb("extraEntropy",e))}return{seed:eU(..._),k2sig:function(t){var r;let i=f(t);if(!o.isValidNot0(i))return;let s=o.inv(i),n=e.BASE.multiply(i).toAffine(),l=o.create(n.x);if(l===it)return;let c=o.create(s*o.create(v+l*w));if(c===it)return;let d=2*(n.x!==l)|Number(n.y&ir),p=c;return h&&c>a>>ir&&(p=(r=c)>a>>ir?o.neg(r):r,d^=1),new u(l,p,d)}}}(r,l,c);return(function(e,t,r){if("number"!=typeof e||e<2)throw Error("hashLen must be a number");if("number"!=typeof t||t<2)throw Error("qByteLen must be a number");if("function"!=typeof r)throw Error("hmacFn must be a function");let i=e=>new Uint8Array(e),s=i(e),n=i(e),o=0,a=()=>{s.fill(1),n.fill(0),o=0},l=(...e)=>r(n,s,...e),c=(e=i(0))=>{n=l(Uint8Array.of(0),e),s=l(),0!==e.length&&(n=l(Uint8Array.of(1),e),s=l())},u=()=>{if(o++>=1e3)throw Error("drbg: tried 1000 values");let e=0,r=[];for(;e<t;){let t=(s=l()).slice();r.push(t),e+=s.length}return eU(...r)};return(e,t)=>{let r;for(a(),c(e);!(r=t(u()));)c();return a(),r}})(t.hash.outputLen,o.BYTES,s)(h,g)},verify:function(r,i,s,n=b){let a,l;i=rb("msgHash",i),s=rb("publicKey",s),r9(n);let{lowS:c,prehash:d,format:h}=n;if("strict"in n)throw Error("options.strict was renamed to lowS");if(void 0!==h&&!["compact","der","js"].includes(h))throw Error('format must be "compact", "der" or "js"');let f="string"==typeof r||eg(r),g=!f&&!h&&"object"==typeof r&&null!==r&&"bigint"==typeof r.r&&"bigint"==typeof r.s;if(!f&&!g)throw Error("invalid signature, expected Uint8Array, hex string or Signature instance");try{if(g)if(void 0===h||"js"===h)a=new u(r.r,r.s);else throw Error("invalid format");if(f){try{"compact"!==h&&(a=u.fromDER(r))}catch(e){if(!(e instanceof ie.Err))throw e}a||"der"===h||(a=u.fromCompact(r))}l=e.fromHex(s)}catch{return!1}if(!a||c&&a.hasHighS())return!1;d&&(i=t.hash(i));let{r:y,s:m}=a,v=p(i),w=o.inv(m),_=o.create(v*w),S=o.create(y*w),E=e.BASE.multiplyUnsafe(_).add(l.multiplyUnsafe(S));return!E.is0()&&o.create(E.x)===y},utils:{isValidPrivateKey(e){try{return d(e),!0}catch{return!1}},normPrivateKeyToScalar:d,randomPrivateKey:()=>(function(e,t,r=!1){let i=e.length,s=rK(t),n=rW(t);if(i<16||i<n||i>1024)throw Error("expected "+n+"-1024 bytes of input, got "+i);let o=rR(r?rg(e):rp(eR(e)),t-rA)+rA;return r?rm(o,s):ry(o,s)})(i(rW(a)),a),precompute:(t=8,r=e.BASE)=>r.precompute(t,!1)},Point:e,Signature:u})}(function(e,t={}){var r,i,s;let{Fp:n,Fn:o}=function(e,t,r={}){if(!t||"object"!=typeof t)throw Error(`expected valid ${e} CURVE object`);for(let e of["p","n","h"]){let r=t[e];if(!("bigint"==typeof r&&r>rz))throw Error(`CURVE.${e} must be positive bigint`)}let i=rX(t.p,r.Fp),s=rX(t.n,r.Fn);for(let r of["Gx","Gy","a","weierstrass"===e?"b":"d"])if(!i.isValid(t[r]))throw Error(`CURVE.${r} must be valid field element of CURVE.Fp`);return{Fp:i,Fn:s}}("weierstrass",e,t),{h:a,n:l}=e;rS(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});let{endo:c}=t;if(c&&(!n.is0(e.a)||"bigint"!=typeof c.beta||"function"!=typeof c.splitScalar))throw Error('invalid endo: expected "beta": bigint and "splitScalar": function');function u(){if(!n.isOdd)throw Error("compression is not supported: Field does not have .isOdd()")}let d=t.toBytes||function(e,t,r){let{x:i,y:s}=t.toAffine(),o=n.toBytes(i);return(rh("isCompressed",r),r)?(u(),eU(il(!n.isOdd(s)),o)):eU(Uint8Array.of(4),o,n.toBytes(s))},h=t.fromBytes||function(e){em(e);let t=n.BYTES,r=t+1,i=2*t+1,s=e.length,o=e[0],a=e.subarray(1);if(s===r&&(2===o||3===o)){let e,t=n.fromBytes(a);if(!n.isValid(t))throw Error("bad point: is not on curve, wrong x");let r=f(t);try{e=n.sqrt(r)}catch(e){throw Error("bad point: is not on curve, sqrt error"+(e instanceof Error?": "+e.message:""))}return u(),(1&o)==1!==n.isOdd(e)&&(e=n.neg(e)),{x:t,y:e}}if(s===i&&4===o){let e=n.fromBytes(a.subarray(0*t,+t)),r=n.fromBytes(a.subarray(+t,2*t));if(!p(e,r))throw Error("bad point: is not on curve");return{x:e,y:r}}throw Error(`bad point: got length ${s}, expected compressed=${r} or uncompressed=${i}`)},f=(r=e.a,i=e.b,function(e){let t=n.sqr(e),s=n.mul(t,e);return n.add(n.add(s,n.mul(e,r)),i)});function p(e,t){let r=n.sqr(t),i=f(e);return n.eql(r,i)}if(!p(e.Gx,e.Gy))throw Error("bad curve params: generator point");let g=n.mul(n.pow(e.a,is),io),y=n.mul(n.sqr(e.b),BigInt(27));
16if(n.is0(n.add(g,y)))throw Error("bad curve params: a or b");function m(e,t,r=!1){if(!n.isValid(t)||r&&n.is0(t))throw Error(`bad point coordinate ${e}`);return t}function b(e){if(!(e instanceof S))throw Error("ProjectivePoint expected")}let v=rE((e,t)=>{let{px:r,py:i,pz:s}=e;if(n.eql(s,n.ONE))return{x:r,y:i};let o=e.is0();null==t&&(t=o?n.ONE:n.inv(s));let a=n.mul(r,t),l=n.mul(i,t),c=n.mul(s,t);if(o)return{x:n.ZERO,y:n.ZERO};if(!n.eql(c,n.ONE))throw Error("invZ was invalid");return{x:a,y:l}}),w=rE(e=>{if(e.is0()){if(t.allowInfinityPoint&&!n.is0(e.py))return;throw Error("bad point: ZERO")}let{x:r,y:i}=e.toAffine();if(!n.isValid(r)||!n.isValid(i))throw Error("bad point: x or y not field elements");if(!p(r,i))throw Error("bad point: equation left != right");if(!e.isTorsionFree())throw Error("bad point: not in prime-order subgroup");return!0});function _(e,t,r,i,s){return r=new S(n.mul(r.px,e),r.py,r.pz),t=rV(i,t),r=rV(s,r),t.add(r)}class S{constructor(e,t,r){this.px=m("x",e),this.py=m("y",t,!0),this.pz=m("z",r),Object.freeze(this)}static fromAffine(e){let{x:t,y:r}=e||{};if(!e||!n.isValid(t)||!n.isValid(r))throw Error("invalid affine point");if(e instanceof S)throw Error("projective point not allowed");return n.is0(t)&&n.is0(r)?S.ZERO:new S(t,r,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(e){let t,r;return t=e=>e.pz,r=rL(S.Fp,e.map(t)),e.map((e,t)=>e.toAffine(r[t])).map(S.fromAffine)}static fromBytes(e){return em(e),S.fromHex(e)}static fromHex(e){let t=S.fromAffine(h(rb("pointHex",e)));return t.assertValidity(),t}static fromPrivateKey(e){let r=ia(o,t.allowedPrivateKeyLengths,t.wrapPrivateKey);return S.BASE.multiply(r(e))}static msm(e,t){return function(e,t,r,i){(function(e,t){if(!Array.isArray(e))throw Error("array expected");e.forEach((e,r)=>{if(!(e instanceof t))throw Error("invalid point at index "+r)})})(r,e),function(e,t){if(!Array.isArray(e))throw Error("array of scalars expected");e.forEach((e,r)=>{if(!t.isValid(e))throw Error("invalid scalar at index "+r)})}(i,t);let s=r.length,n=i.length;if(s!==n)throw Error("arrays of points and scalars must have equal length");let o=e.ZERO,a=function(e){let t;for(t=0;e>ru;e>>=rd,t+=1);return t}(BigInt(s)),l=1;a>12?l=a-3:a>4?l=a-2:a>0&&(l=2);let c=r_(l),u=Array(Number(c)+1).fill(o),d=Math.floor((t.BITS-1)/l)*l,h=o;for(let e=d;e>=0;e-=l){u.fill(o);for(let t=0;t<n;t++){let s=Number(i[t]>>BigInt(e)&c);u[s]=u[s].add(r[t])}let t=o;for(let e=u.length-1,r=o;e>0;e--)r=r.add(u[e]),t=t.add(r);if(h=h.add(t),0!==e)for(let e=0;e<l;e++)h=h.double()}return h}(S,o,e,t)}precompute(e=8,t=!0){return I.setWindowSize(this,e),t||this.multiply(is),this}_setWindowSize(e){this.precompute(e)}assertValidity(){w(this)}hasEvenY(){let{y:e}=this.toAffine();if(!n.isOdd)throw Error("Field doesn't support isOdd");return!n.isOdd(e)}equals(e){b(e);let{px:t,py:r,pz:i}=this,{px:s,py:o,pz:a}=e,l=n.eql(n.mul(t,a),n.mul(s,i)),c=n.eql(n.mul(r,a),n.mul(o,i));return l&&c}negate(){return new S(this.px,n.neg(this.py),this.pz)}double(){let{a:t,b:r}=e,i=n.mul(r,is),{px:s,py:o,pz:a}=this,l=n.ZERO,c=n.ZERO,u=n.ZERO,d=n.mul(s,s),h=n.mul(o,o),f=n.mul(a,a),p=n.mul(s,o);return p=n.add(p,p),u=n.mul(s,a),u=n.add(u,u),l=n.mul(t,u),c=n.mul(i,f),c=n.add(l,c),l=n.sub(h,c),c=n.add(h,c),c=n.mul(l,c),l=n.mul(p,l),u=n.mul(i,u),f=n.mul(t,f),p=n.sub(d,f),p=n.mul(t,p),p=n.add(p,u),u=n.add(d,d),d=n.add(u,d),d=n.add(d,f),d=n.mul(d,p),c=n.add(c,d),f=n.mul(o,a),f=n.add(f,f),d=n.mul(f,p),l=n.sub(l,d),u=n.mul(f,h),u=n.add(u,u),new S(l,c,u=n.add(u,u))}add(t){b(t);let{px:r,py:i,pz:s}=this,{px:o,py:a,pz:l}=t,c=n.ZERO,u=n.ZERO,d=n.ZERO,h=e.a,f=n.mul(e.b,is),p=n.mul(r,o),g=n.mul(i,a),y=n.mul(s,l),m=n.add(r,i),v=n.add(o,a);m=n.mul(m,v),v=n.add(p,g),m=n.sub(m,v),v=n.add(r,s);let w=n.add(o,l);return v=n.mul(v,w),w=n.add(p,y),v=n.sub(v,w),w=n.add(i,s),c=n.add(a,l),w=n.mul(w,c),c=n.add(g,y),w=n.sub(w,c),d=n.mul(h,v),c=n.mul(f,y),d=n.add(c,d),c=n.sub(g,d),d=n.add(g,d),u=n.mul(c,d),g=n.add(p,p),g=n.add(g,p),y=n.mul(h,y),v=n.mul(f,v),g=n.add(g,y),y=n.sub(p,y),y=n.mul(h,y),v=n.add(v,y),p=n.mul(g,v),u=n.add(u,p),p=n.mul(w,v),c=n.mul(m,c),c=n.sub(c,p),p=n.mul(m,g),d=n.mul(w,d),new S(c,u,d=n.add(d,p))}subtract(e){return this.add(e.negate())}is0(){return this.equals(S.ZERO)}multiply(e){let r,i,{endo:s}=t;if(!o.isValidNot0(e))throw Error("invalid scalar: out of range");let n=e=>I.wNAFCached(this,e,S.normalizeZ);
16if(s){let{k1neg:t,k1:o,k2neg:a,k2:l}=s.splitScalar(e),{p:c,f:u}=n(o),{p:d,f:h}=n(l);i=u.add(h),r=_(s.beta,c,d,t,a)}else{let{p:t,f:s}=n(e);r=t,i=s}return S.normalizeZ([r,i])[0]}multiplyUnsafe(e){let{endo:r}=t;if(!o.isValid(e))throw Error("invalid scalar: out of range");if(e===it||this.is0())return S.ZERO;if(e===ir)return this;if(I.hasPrecomputes(this))return this.multiply(e);if(!r)return I.wNAFCachedUnsafe(this,e);{let{k1neg:t,k1:i,k2neg:s,k2:n}=r.splitScalar(e),{p1:o,p2:a}=function(e,t,r,i){let s=t,n=e.ZERO,o=e.ZERO;for(;r>rz||i>rz;)r&rj&&(n=n.add(s)),i&rj&&(o=o.add(s)),s=s.double(),r>>=rj,i>>=rj;return{p1:n,p2:o}}(S,this,i,n);return _(r.beta,o,a,t,s)}}multiplyAndAddUnsafe(e,t,r){let i=this.multiplyUnsafe(t).add(e.multiplyUnsafe(r));return i.is0()?void 0:i}toAffine(e){return v(this,e)}isTorsionFree(){let{isTorsionFree:e}=t;return a===ir||(e?e(S,this):I.wNAFCachedUnsafe(this,l).is0())}clearCofactor(){let{clearCofactor:e}=t;return a===ir?this:e?e(S,this):this.multiplyUnsafe(a)}toBytes(e=!0){return rh("isCompressed",e),this.assertValidity(),d(S,this,e)}toRawBytes(e=!0){return this.toBytes(e)}toHex(e=!0){return eR(this.toBytes(e))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}S.BASE=new S(e.Gx,e.Gy,n.ONE),S.ZERO=new S(n.ZERO,n.ONE,n.ZERO),S.Fp=n,S.Fn=o;let E=o.BITS,I=(s=t.endo?Math.ceil(E/2):E,{constTimeNegate:rV,hasPrecomputes:e=>1!==rY(e),unsafeLadder(e,t,r=S.ZERO){let i=e;for(;t>rz;)t&rj&&(r=r.add(i)),i=i.double(),t>>=rj;return r},precomputeWindow(e,t){let{windows:r,windowSize:i}=rF(t,s),n=[],o=e,a=o;for(let e=0;e<r;e++){a=o,n.push(a);for(let e=1;e<i;e++)a=a.add(o),n.push(a);o=a.double()}return n},wNAF(e,t,r){let i=S.ZERO,n=S.BASE,o=rF(e,s);for(let e=0;e<o.windows;e++){let{nextN:s,offset:a,isZero:l,isNeg:c,isNegF:u,offsetF:d}=rH(r,e,o);r=s,l?n=n.add(rV(u,t[d])):i=i.add(rV(c,t[a]))}return rZ(r),{p:i,f:n}},wNAFUnsafe(e,t,r,i=S.ZERO){let n=rF(e,s);for(let e=0;e<n.windows&&r!==rz;e++){let{nextN:s,offset:o,isZero:a,isNeg:l}=rH(r,e,n);if(r=s,!a){let e=t[o];i=i.add(l?e.negate():e)}}return rZ(r),i},getPrecomputes(e,t,r){let i=rG.get(t);return i||(i=this.precomputeWindow(t,e),1!==e&&("function"==typeof r&&(i=r(i)),rG.set(t,i))),i},wNAFCached(e,t,r){let i=rY(e);return this.wNAF(i,this.getPrecomputes(i,e,r),t)},wNAFCachedUnsafe(e,t,r,i){let s=rY(e);return 1===s?this.unsafeLadder(e,t,i):this.wNAFUnsafe(s,this.getPrecomputes(s,e,r),t,i)},setWindowSize(e,t){r$(t,s),rJ.set(e,t),rG.delete(e)}});return S}(t,r),i,r);return Object.assign({},s,{ProjectivePoint:s.Point,CURVE:e})})({...e,hash:t});return{...r(t),create:r}}let iu={p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")},id={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff"),n:BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),h:BigInt(1),a:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000fffffffc"),b:BigInt("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef"),Gx:BigInt("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),Gy:BigInt("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f")},ih={p:BigInt("0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),n:BigInt("0x01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409"),h:BigInt(1),a:BigInt("0x1fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc"),b:BigInt("0x0051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00"),Gx:BigInt("0x00c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66"),Gy:BigInt("0x011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650")},ip=rM(iu.p),ig=rM(id.p),iy=rM(ih.p),im=ic({...iu,Fp:ip,lowS:!1},ta);ic({...id,Fp:ig,lowS:!1},tc),ic({...ih,Fp:iy,lowS:!1,allowedPrivateKeyLengths:[130,131,132]},tl);let ib="base10",iv="base16",iw="base64pad",i_="base64url",iS="utf8";function iE(e){return(0,_.fromString)(`${e}`,ib)}function iI(e){return Number((0,w.toString)(e,ib))}function iA(e){return e.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function iT(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r=(4-t.length%4)%4;return t+"=".repeat(r)}function ix(e){if(2===iI(e.type))return(0,w.toString)((0,S.concat)([e.type,e.sealed]),iw);if(1===iI(e.type)){if(typeof e.senderPublicKey>"u")throw Error("Missing sender public key for type 1 envelope");
16return(0,w.toString)((0,S.concat)([e.type,e.senderPublicKey,e.iv,e.sealed]),iw)}return(0,w.toString)((0,S.concat)([e.type,e.iv,e.sealed]),iw)}function ik(e){let t=(e.encoding||iw)===i_?iT(e.encoded):e.encoded,r=(0,_.fromString)(t,iw),i=r.slice(0,1);if(1===iI(i)){let e=r.slice(1,33),t=r.slice(33,45);return{type:i,sealed:r.slice(45),iv:t,senderPublicKey:e}}if(2===iI(i))return{type:i,sealed:r.slice(1),iv:eD(12)};let s=r.slice(1,13);return{type:i,sealed:r.slice(13),iv:s}}function iP(e){let t=e?.type||0;if(1===t){if(typeof e?.senderPublicKey>"u")throw Error("missing sender public key");if(typeof e?.receiverPublicKey>"u")throw Error("missing receiver public key")}return{type:t,senderPublicKey:e?.senderPublicKey,receiverPublicKey:e?.receiverPublicKey}}var iO=Object.defineProperty,iR=Object.defineProperties,iC=Object.getOwnPropertyDescriptors,iN=Object.getOwnPropertySymbols,iB=Object.prototype.hasOwnProperty,iU=Object.prototype.propertyIsEnumerable,iq=(e,t,r)=>t in e?iO(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,iL=(e,t)=>{for(var r in t||(t={}))iB.call(t,r)&&iq(e,r,t[r]);if(iN)for(var r of iN(t))iU.call(t,r)&&iq(e,r,t[r]);return e},iD=(e,t)=>iR(e,iC(t));function iM(e){let t=[];return e.forEach(e=>{let[r,i]=e.split(":");t.push(`${r}:${i}`)}),t}function iK(e){return e.includes(":")}function iW(e){var t,r,i;let s={};if(!iH(e))return s;for(let[n,o]of Object.entries(e)){let e=iK(n)?[n]:o.chains,a=o.methods||[],l=o.events||[],c=iK(n)?n.split(":")[0]:n;s[c]=iD(iL({},s[c]),{chains:H(e,null==(t=s[c])?void 0:t.chains),methods:H(a,null==(r=s[c])?void 0:r.methods),events:H(l,null==(i=s[c])?void 0:i.events)})}return s}let iz={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}},ij={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};function iV(e,t){let{message:r,code:i}=ij[e];return{message:t?`${r} ${t}`:r,code:i}}function i$(e,t){let{message:r,code:i}=iz[e];return{message:t?`${r} ${t}`:r,code:i}}function iF(e,t){return!!Array.isArray(e)&&(!("u">typeof t)||!e.length||e.every(t))}function iH(e){return Object.getPrototypeOf(e)===Object.prototype&&Object.keys(e).length}function iG(e){return typeof e>"u"}function iJ(e,t){return!!(t&&iG(e))||"string"==typeof e&&!!e.trim().length}function iY(e,t){return!!(t&&iG(e))||"number"==typeof e&&!isNaN(e)}function iZ(e){return!!(iJ(e,!1)&&e.includes(":"))&&2===e.split(":").length}function iX(e){let t=!0;return iF(e)?e.length&&(t=e.every(e=>
16iJ(e,!1))):t=!1,t}function iQ(e,t){let r=null;return Object.values(e).forEach(e=>{var i;let s;if(r)return;let n=(i=`${t}, namespace`,s=null,iX(e?.methods)?iX(e?.events)||(s=i$("UNSUPPORTED_EVENTS",`${i}, events should be an array of strings or empty array for no events`)):s=i$("UNSUPPORTED_METHODS",`${i}, methods should be an array of strings or empty array for no methods`),s);n&&(r=n)}),r}function i0(e){return iJ(e.protocol,!0)}function i1(e,t,r){var i,s;let n,o,a=null,l=(n={},Object.keys(i=e).forEach(e=>{var t;e.includes(":")?n[e]=i[e]:null==(t=i[e].chains)||t.forEach(t=>{n[t]={methods:i[e].methods,events:i[e].events}})}),n),c=(o={},Object.keys(s=t).forEach(e=>{if(e.includes(":"))o[e]=s[e];else{let t=iM(s[e].accounts);t?.forEach(t=>{o[t]={accounts:s[e].accounts.filter(e=>e.includes(`${t}:`)),methods:s[e].methods,events:s[e].events}})}}),o),u=Object.keys(l),d=Object.keys(c),h=i2(Object.keys(e)),f=i2(Object.keys(t)),p=h.filter(e=>!f.includes(e));return p.length&&(a=iV("NON_CONFORMING_NAMESPACES",`${r} namespaces keys don't satisfy requiredNamespaces.
17      Required: ${p.toString()}
18      Received: ${Object.keys(t).toString()}`)),$(u,d)||(a=iV("NON_CONFORMING_NAMESPACES",`${r} namespaces chains don't satisfy required namespaces.
19      Required: ${u.toString()}
20      Approved: ${d.toString()}`)),Object.keys(t).forEach(e=>{if(!e.includes(":")||a)return;let i=iM(t[e].accounts);i.includes(e)||(a=iV("NON_CONFORMING_NAMESPACES",`${r} namespaces accounts don't satisfy namespace accounts for ${e}
21        Required: ${e}
22        Approved: ${i.toString()}`))}),u.forEach(e=>{a||($(l[e].methods,c[e].methods)?$(l[e].events,c[e].events)||(a=iV("NON_CONFORMING_NAMESPACES",`${r} namespaces events don't satisfy namespace events for ${e}`)):a=iV("NON_CONFORMING_NAMESPACES",`${r} namespaces methods don't satisfy namespace methods for ${e}`))}),a}function i2(e){return[...new Set(e.map(e=>e.includes(":")?e.split(":")[0]:e))]}async function i5(){if(K()&&null!=e.g&&e.g.NetInfo){let t=await (null==e.g?void 0:e.g.NetInfo.fetch());return t?.isConnected}return!0}let i6={};function i3(e){return new Uint8Array(e.replace(/^0x/,"").match(/.{1,2}/g).map(e=>parseInt(e,16)))}e.s(["BASE16",0,iv,"BASE64",0,iw,"BASE64URL",0,i_,"LimitedSet",0,class{constructor({limit:e}){U(this,"limit"),U(this,"set"),this.limit=e,this.set=new Set}
22add(e){if(!this.set.has(e)){if(this.set.size>=this.limit){let e=this.set.values().next().value;e&&this.set.delete(e)}this.set.add(e)}}has(e){return this.set.has(e)}},"MemoryStore",0,class{static get(e){return i6[e]}static set(e,t){i6[e]=t}static delete(e){delete i6[e]}},"SDK_ERRORS",0,iz,"TYPE_1",0,1,"TYPE_2",0,2,"buildApprovedNamespaces",0,function(e){var t;let{proposal:{requiredNamespaces:r,optionalNamespaces:i={}},supportedNamespaces:s}=e,n=iW(r),o=iW(i),a={};Object.keys(s).forEach(e=>{let t=s[e].chains,r=s[e].methods,i=s[e].events,n=s[e].accounts;t.forEach(t=>{if(!n.some(e=>e.includes(t)))throw Error(`No accounts provided for chain ${t} in namespace ${e}`)}),a[e]={chains:t,methods:r,events:i,accounts:n}});let l=i1(r,a,"approve()");if(l)throw Error(l.message);let c={};if(!Object.keys(r).length&&!Object.keys(i).length)return a;for(let[e,r]of(Object.keys(n).forEach(e=>{let t=s[e].chains.filter(t=>{var r,i;return null==(i=null==(r=n[e])?void 0:r.chains)?void 0:i.includes(t)}),r=s[e].methods.filter(t=>{var r,i;return null==(i=null==(r=n[e])?void 0:r.methods)?void 0:i.includes(t)}),i=s[e].events.filter(t=>{var r,i;return null==(i=null==(r=n[e])?void 0:r.events)?void 0:i.includes(t)}),o=t.map(t=>s[e].accounts.filter(e=>e.includes(`${t}:`))).flat();c[e]={chains:t,methods:r,events:i,accounts:o}}),Object.keys(o).forEach(e=>{var t,r,i,n,a,l;if(!s[e])return;let u=null==(r=null==(t=o[e])?void 0:t.chains)?void 0:r.filter(t=>s[e].chains.includes(t)),d=s[e].methods.filter(t=>{var r,i;return null==(i=null==(r=o[e])?void 0:r.methods)?void 0:i.includes(t)}),h=s[e].events.filter(t=>{var r,i;return null==(i=null==(r=o[e])?void 0:r.events)?void 0:i.includes(t)}),f=u?.map(t=>s[e].accounts.filter(e=>e.includes(`${t}:`))).flat();c[e]={chains:H(null==(i=c[e])?void 0:i.chains,u),methods:H(null==(n=c[e])?void 0:n.methods,d),events:H(null==(a=c[e])?void 0:a.events,h),accounts:H(null==(l=c[e])?void 0:l.accounts,f)}}),Object.entries(c)))(0===r.accounts.length||(null==(t=r?.chains)?void 0:t.length)===0)&&delete c[e];return c},"buildNamespacesFromAuth",0,function(e,t){var r;let i,s=(r=t=t.map(e=>e.replace("did:pkh:","")),i={},r?.forEach(e=>{var t;let[r,s]=e.split(":");i[r]||(i[r]={accounts:[],chains:[],events:[],methods:[]}),i[r].accounts.push(e),null==(t=i[r].chains)||t.push(`${r}:${s}`)}),i);for(let[t,r]of Object.entries(s))r.methods?r.methods=H(r.methods,e):r.methods=e,r.events=["chainChanged","accountsChanged"];return s},"buildSignedExtrinsicHash",0,function(e){let t,r,i=Uint8Array.from(c.Buffer.from(e.signature,"hex")),s=function({publicKey:e,signature:t,payload:r}){var i,s,n;let o,a=i3(r.method),l=128|parseInt((null==(i=r.version)?void 0:i.toString())||"4"),c=(s=r.address,42===(o=g.default.decode(s)[0])?0:60===o?2:1),u="00"===r.era?new Uint8Array([0]):i3(r.era);if(1!==u.length&&2!==u.length)throw Error("Invalid era length");let d=parseInt(r.nonce,16),h=new Uint8Array([255&d,d>>8&255]),f=new Uint8Array([0,...e,c,...t,...u,...h,...function(e){if(e<BigInt(1)<<BigInt(6))return new Uint8Array([Number(e<<BigInt(2))]);if(e<BigInt(1)<<BigInt(14)){let t=e<<BigInt(2)|BigInt(1);return new Uint8Array([Number(t&BigInt(255)),Number(t>>BigInt(8)&BigInt(255))])}if(e<BigInt(1)<<BigInt(30)){let t=e<<BigInt(2)|BigInt(2);return new Uint8Array([Number(t&BigInt(255)),Number(t>>BigInt(8)&BigInt(255)),Number(t>>BigInt(16)&BigInt(255)),Number(t>>BigInt(24)&BigInt(255))])}throw Error("BigInt compact encoding not supported > 2^30")}(BigInt(`0x${(n=r.tip).startsWith("0x")?n.slice(2):n}`)),...a]);return new Uint8Array([...function(e){if(e<64)return new Uint8Array([e<<2]);if(e<16384){let t=e<<2|1;return new Uint8Array([255&t,t>>8&255])}if(e<0x40000000){let t=e<<2|2;return new Uint8Array([255&t,t>>8&255,t>>16&255,t>>24&255])}throw Error("Compact encoding > 2^30 not supported")}(f.length+1),l,...f])}({publicKey:function(e){let t=g.default.decode(e);if(t.length<33)throw Error("Too short to contain a public key");return t.slice(1,33)}(e.transaction.address),signature:i,payload:e.transaction});return t=i3(c.Buffer.from(s).toString("hex")),r=(0,I.blake2b)(t,void 0,32),"0x"+c.Buffer.from(r).toString("hex")},"calcExpiry",0,function(e,t){return(0,d.fromMiliseconds)((t||Date.now())+(0,d.toMiliseconds)(e))},"createDelayedPromise",0,function(e=d.FIVE_MINUTES,t){let r,i,s,n,o=(0,d.toMiliseconds)(e||d.FIVE_MINUTES);return{resolve:e=>{s&&r&&(clearTimeout(s),r(e),n=Promise.resolve(e))},reject:e=>{s&&i&&(clearTimeout(s),i(e))},done:()=>new Promise((e,a)=>{if(n)return e(n);s=setTimeout(()=>{let e=Error(t);n=Promise.reject(e),a(e)},o),r=e,i=a})}},"createEncodedRecap",0,function(e,t,r){return tL(function(e,t,r,i={}){return r?.sort((e,t)=>
22e.localeCompare(t)),{att:{[e]:function(e,t,r={}){return Object.assign({},...(t=t?.sort((e,t)=>e.localeCompare(t))).map(t=>({[`${e}/${t}`]:[r]})))}(t,r,i)}}}(e,t,r))},"createExpiringPromise",0,function(e,t,r){return new Promise(async(i,s)=>{let n=setTimeout(()=>s(Error(r)),t);try{let t=await e;i(t)}catch(e){s(e)}clearTimeout(n)})},"decodeTypeByte",0,iI,"decodeTypeTwoEnvelope",0,function(e,t){let{sealed:r}=ik({encoded:e,encoding:t});return(0,w.toString)(r,iS)},"decrypt",0,function(e){let t=(0,_.fromString)(e.symKey,iv),{sealed:r,iv:i}=ik({encoded:e.encoded,encoding:e.encoding}),s=rn(t,i).decrypt(r);if(null===s)throw Error("Failed to decrypt");return(0,w.toString)(s,iS)},"deriveSymKey",0,function(e,t){var r,i;let s=r7.getSharedSecret((0,_.fromString)(e,iv),(0,_.fromString)(t,iv)),n=(r=void 0,function(e,t,r,i=32){eb(e),ey(i);let s=e.outputLen;if(i>255*s)throw Error("Length should be <= 255*HashLen");let n=Math.ceil(i/s);void 0===r&&(r=rc);let o=new Uint8Array(n*s),a=ra.create(e,t),l=a._cloneInto(),c=new Uint8Array(a.outputLen);for(let e=0;e<n;e++)rl[0]=e+1,l.update(0===e?rc:c).update(r).update(rl).digestInto(c),o.set(c,s*e),a._cloneInto(l);return a.destroy(),l.destroy(),eS(c,rl),o.slice(0,i)}(ta,(i=void 0,eb(ta),void 0===i&&(i=new Uint8Array(ta.outputLen)),ra(ta,eB(i),eB(s))),r,32));return(0,w.toString)(n,iv)},"deserialize",0,ik,"encodeTypeTwoEnvelope",0,function(e,t){let r=iE(2),i=eD(12),s=ix({type:r,sealed:(0,_.fromString)(e,iS),iv:i});return t===i_?iA(s):s},"encrypt",0,function(e){let t=iE("u">typeof e.type?e.type:0);if(1===iI(t)&&typeof e.senderPublicKey>"u")throw Error("Missing sender public key for type 1 envelope");let r="u">typeof e.senderPublicKey?(0,_.fromString)(e.senderPublicKey,iv):void 0,i="u">typeof e.iv?(0,_.fromString)(e.iv,iv):eD(12),s=ix({type:t,sealed:rn((0,_.fromString)(e.symKey,iv),i).encrypt((0,_.fromString)(e.message,iS)),iv:i,senderPublicKey:r});return e.encoding===i_?iA(s):s},"engineEvent",0,function(e,t){return`${e}${t?`:${t}`:""}`},"extractSolanaTransactionId",0,function(e){let t=atob(e),r=new Uint8Array(t.length);for(let e=0;e<t.length;e++)r[e]=t.charCodeAt(e);let i=r[0];if(0===i)throw Error("No signatures found");if(r.length<1+64*i)throw Error("Transaction data too short for claimed signature count");if(r.length<100)throw Error("Transaction too short");let s=c.Buffer.from(e,"base64").slice(1,65);return g.default.encode(s)},"formatIdTarget",0,function(e){return F("id",e)},"formatMessage",0,tU,"formatRelayRpcUrl",0,function({protocol:e,version:t,relayUrl:r,sdkVersion:i,auth:s,projectId:n,useOnCloseEvent:o,bundleId:a,packageName:l}){let c=r.split("?"),u=V(e,t,i),d=function(e,t){let r=new URLSearchParams(e);for(let e of Object.keys(t).sort())if(t.hasOwnProperty(e)){let i=t[e];void 0!==i&&r.set(e,i)}return r.toString()}(c[1]||"",{auth:s,ua:u,projectId:n,useOnCloseEvent:o||void 0,packageName:l||void 0,bundleId:a||void 0});return c[0]+"?"+d},"formatTopicTarget",0,function(e){return F("topic",e)},"formatUA",0,V,"formatUri",0,function(e){let t=new URLSearchParams,r=function(e,t="-"){let r={};return Object.keys(e).forEach(i=>{e[i]&&(r["relay"+t+i]=e[i])}),r}(e.relay);Object.keys(r).sort().forEach(e=>{t.set(e,r[e])}),t.set("symKey",e.symKey),e.expiryTimestamp&&t.set("expiryTimestamp",e.expiryTimestamp.toString()),e.methods&&t.set("methods",e.methods.join(","));let i=t.toString();return`${e.protocol}:${e.topic}@${e.version}?${i}`},"generateKeyPair",0,function(){let e=r7.utils.randomPrivateKey(),t=r7.getPublicKey(e);return{privateKey:(0,w.toString)(e,iv),publicKey:(0,w.toString)(t,iv)}},"generateRandomBytes32",0,function(){let e=eD(32);return(0,w.toString)(e,iv)},"getAlgorandTransactionId",0,function(e){let t=c.Buffer.from(e,"base64"),r=(0,y.decode)(t).txn;if(!r)throw Error("Invalid signed transaction: missing 'txn' field");let i=(0,m.encode)(r),s=c.Buffer.from("TX"),n=tu(c.Buffer.concat([s,c.Buffer.from(i)]));return b.base32.encode(n).replace(/=+$/,"")},"getAppId",0,function(){var t;try{return K()&&"u">typeof(null==e.g?void 0:e.g.Application)?null==(t=e.g.Application)?void 0:t.applicationId:void 0}catch{return}},"getAppMetadata",0,j,"getChainsFromRecap",0,function(e){let t=tD(e);tq(t);let r=[];
22return Object.values(t.att).forEach(e=>{Object.values(e).forEach(e=>{var t;null!=(t=e?.[0])&&t.chains&&r.push(e[0].chains)})}),[...new Set(r.flat())]},"getDeepLink",0,J,"getDidAddress",0,tN,"getInternalError",0,iV,"getLinkModeURL",0,function(e,t,r){return`${e}?wc_ev=${r}&topic=${t}`},"getMethodsFromRecap",0,function(e){var t;let r=tD(e);tq(r);let i=null==(t=r.att)?void 0:t.eip155;return i?Object.keys(i).map(e=>e.split("/")[1]):[]},"getNamespacedDidChainId",0,tC,"getNearTransactionIdFromSignedTransaction",0,function(e){let t=new Uint8Array(ta(function(e){if(e instanceof Uint8Array)return e;if(Array.isArray(e))return new Uint8Array(e);if("object"==typeof e&&null!=e&&e.data)return new Uint8Array(Object.values(e.data));if("object"==typeof e&&e)return new Uint8Array(Object.values(e));throw Error("getNearUint8ArrayFromBytes: Unexpected result type from bytes array")}(e)));return g.default.encode(t)},"getRecapFromResources",0,tM,"getRelayProtocolApi",0,function(e){let t=E.RELAY_JSONRPC[e];if(typeof t>"u")throw Error(`Relay Protocol not supported: ${e}`);return t},"getRelayProtocolName",0,function(e){return e?.relay||{protocol:"irn"}},"getSdkError",0,i$,"getSearchParamFromURL",0,function(e,t){if(!e.includes(t))return null;let r=e.split(/([&,?,=])/),i=r.indexOf(t);return r[i+2]},"getSignDirectHash",0,function(e){let t=c.Buffer.from(e.signed.bodyBytes,"base64"),r=c.Buffer.from(e.signed.authInfoBytes,"base64"),i=c.Buffer.from(e.signature.signature,"base64"),s=[];s.push(c.Buffer.from([10])),s.push(tE(t.length)),s.push(t),s.push(c.Buffer.from([18])),s.push(tE(r.length)),s.push(r),s.push(c.Buffer.from([26])),s.push(tE(i.length)),s.push(i);let n=ta(c.Buffer.concat(s));return c.Buffer.from(n).toString("hex").toUpperCase()},"getSuiDigest",0,function(e){let t=new Uint8Array(c.Buffer.from(e,"base64")),r=Array.from("TransactionData::").map(e=>e.charCodeAt(0)),i=new Uint8Array(r.length+t.length);i.set(r),i.set(t,r.length);let s=tb(i,{dkLen:32});return g.default.encode(s)},"handleDeeplinkRedirect",0,G,"hashKey",0,function(e){let t=ta((0,_.fromString)(e,iv));return(0,w.toString)(t,iv)},"hashMessage",0,function(e){let t=ta((0,_.fromString)(e,iS));return(0,w.toString)(t,iv)},"isAndroid",0,function(){return K()&&"u">typeof(null==e.g?void 0:e.g.Platform)&&(null==e.g?void 0:e.g.Platform.OS)==="android"},"isAppVisible",0,function(){var e;return!(W()&&(0,h.getDocument)())||(null==(e=(0,h.getDocument)())?void 0:e.visibilityState)==="visible"},"isBrowser",0,W,"isConformingNamespaces",0,i1,"isExpired",0,function(e){return Date.now()>=(0,d.toMiliseconds)(e)},"isIos",0,function(){return K()&&"u">typeof(null==e.g?void 0:e.g.Platform)&&(null==e.g?void 0:e.g.Platform.OS)==="ios"},"isNode",0,M,"isOnline",0,function(){let e=z();return new Promise(t=>{switch(e){case D:t(W()&&navigator?.onLine);break;case q:t(i5());break;default:t(!0)}})},"isProposalStruct",0,function(e){var t;return null==(t=e?.proposer)?void 0:t.publicKey},"isReactNative",0,K,"isSessionCompatible",0,function(e,t){let{requiredNamespaces:r}=t,i=Object.keys(e.namespaces),s=Object.keys(r),n=!0;return!!$(s,i)&&(i.forEach(t=>{let{accounts:i,methods:s,events:o}=e.namespaces[t],a=iM(i),l=r[t];$(T(t,l),a)&&$(l.methods,s)&&$(l.events,o)||(n=!1)}),n)},"isSessionStruct",0,function(e){return e?.topic},"isTestRun",0,function(){return"u">typeof l.default&&"true"===l.default.env.IS_VITEST},"isTypeOneEnvelope",0,function(e){return 1===e.type&&"string"==typeof e.senderPublicKey&&"string"==typeof e.receiverPublicKey},"isTypeTwoEnvelope",0,function(e){return 2===e.type},"isUndefined",0,iG,"isValidArray",0,iF,"isValidController",0,function(e,t){let r=null;return iJ(e?.publicKey,!1)||(r=iV("MISSING_OR_INVALID",`${t} controller public key should be a string`)),r},"isValidErrorReason",0,function(e){return!(!e||"object"!=typeof e||!e.code||!iY(e.code,!1)||!e.message||!iJ(e.message,!1))},"isValidEvent",0,function(e){return!(iG(e)||!iJ(e.name,!1))},"isValidId",0,function(e){return"number"==typeof e},"isValidNamespaces",0,function(e,t){let r=null;if(e&&iH(e)){let i,s=iQ(e,t);s&&(r=s);
22let n=(i=null,Object.values(e).forEach(e=>{var r,s;let n;if(i)return;let o=(r=e?.accounts,s=`${t} namespace`,n=null,iF(r)?r.forEach(e=>{n||function(e){if(iJ(e,!1)&&e.includes(":")){let t=e.split(":");if(3===t.length){let e=t[0]+":"+t[1];return!!t[2]&&iZ(e)}}return!1}(e)||(n=i$("UNSUPPORTED_ACCOUNTS",`${s}, account ${e} should be a string and conform to "namespace:chainId:address" format`))}):n=i$("UNSUPPORTED_ACCOUNTS",`${s}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),n);o&&(i=o)}),i);n&&(r=n)}else r=iV("MISSING_OR_INVALID",`${t}, namespaces should be an object with data`);return r},"isValidNamespacesChainId",0,function(e,t){let r;return!(!iZ(t)||!(r=[],Object.values(e).forEach(e=>{r.push(...iM(e.accounts))}),r).includes(t))},"isValidNamespacesEvent",0,function(e,t,r){let i;return!!iJ(r,!1)&&(i=[],Object.values(e).forEach(e=>{iM(e.accounts).includes(t)&&i.push(...e.events)}),i).includes(r)},"isValidNamespacesRequest",0,function(e,t,r){let i;return!!iJ(r,!1)&&(i=[],Object.values(e).forEach(e=>{iM(e.accounts).includes(t)&&i.push(...e.methods)}),i).includes(r)},"isValidObject",0,iH,"isValidParams",0,function(e){return"u">typeof e},"isValidRelay",0,i0,"isValidRelays",0,function(e,t){let r=!1;return t&&!e?r=!0:e&&iF(e)&&e.length&&e.forEach(e=>{r=i0(e)}),r},"isValidRequest",0,function(e){return!(iG(e)||!iJ(e.method,!1))},"isValidRequestExpiry",0,function(e,t){return iY(e,!1)&&e<=t.max&&e>=t.min},"isValidRequiredNamespaces",0,function(e,t,r){let i=null;if(e&&iH(e)){let s,n=iQ(e,t);n&&(i=n);let o=(s=null,Object.entries(e).forEach(([e,i])=>{var n,o;let a;if(s)return;let l=(n=T(e,i),o=`${t} ${r}`,a=null,iF(n)&&n.length?n.forEach(e=>{a||iZ(e)||(a=i$("UNSUPPORTED_CHAINS",`${o}, chain ${e} should be a string and conform to "namespace:chainId" format`))}):iZ(e)||(a=i$("UNSUPPORTED_CHAINS",`${o}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }`)),a);l&&(s=l)}),s);o&&(i=o)}else i=iV("MISSING_OR_INVALID",`${t}, ${r} should be an object with data`);return i},"isValidResponse",0,function(e){return!(iG(e)||iG(e.result)&&iG(e.error)||!iY(e.id,!1)||!iJ(e.jsonrpc,!1))},"isValidString",0,iJ,"isValidUrl",0,function(e){function t(e){try{return"u">typeof new URL(e)}catch{return!1}}try{if(iJ(e,!1)){if(t(e))return!0;let r=Y(e);return t(r)}}catch{}return!1},"mapToObj",0,function(e){return Object.fromEntries(e.entries())},"mergeEncodedRecaps",0,function(e,t){var r,i;let s,n;return tL((r=tD(e),i=tD(t),tq(r),tq(i),s=Object.keys(r.att).concat(Object.keys(i.att)).sort((e,t)=>e.localeCompare(t)),n={att:{}},s.forEach(e=>{var t,s;Object.keys((null==(t=r.att)?void 0:t[e])||{}).concat(Object.keys((null==(s=i.att)?void 0:s[e])||{})).sort((e,t)=>e.localeCompare(t)).forEach(t=>{var s,o;n.att[e]=tA(((e,t)=>{for(var r in t||(t={}))tk.call(t,r)&&tO(e,r,t[r]);if(tx)for(var r of tx(t))tP.call(t,r)&&tO(e,r,t[r]);return e})({},n.att[e]),tT({[t]:(null==(s=r.att[e])?void 0:s[t])||(null==(o=i.att[e])?void 0:o[t])}))})}),n))},"mergeRequiredAndOptionalNamespaces",0,function(e,t){var r,i,s,n,o,a;let l=iW(e),c=iW(t),u={};for(let e of Object.keys(l).concat(Object.keys(c)))u[e]={chains:H(null==(r=l[e])?void 0:r.chains,null==(i=c[e])?void 0:i.chains),methods:H(null==(s=l[e])?void 0:s.methods,null==(n=c[e])?void 0:n.methods),events:H(null==(o=l[e])?void 0:o.events,null==(a=c[e])?void 0:a.events)};return u},"objToMap",0,function(e){return new Map(Object.entries(e))},"parseChainId",0,A,"parseExpirerTarget",0,function(e){let[t,r]=e.split(":"),i={id:void 0,topic:void 0};if("topic"===t&&"string"==typeof r)i.topic=r;else if("id"===t&&Number.isInteger(Number(r)))i.id=Number(r);else throw Error(`Invalid target, expected id:number or topic:string, got ${t}:${r}`);return i},"parseUri",0,function(e){var t;if(!e.includes("wc:")){let t=Y(e);null!=t&&t.includes("wc:")&&(e=t)}let r=(e=(e=e.includes("wc://")?e.replace("wc://",""):e).includes("wc:")?e.replace("wc:",""):e).indexOf(":"),i=-1!==e.indexOf("?")?e.indexOf("?"):void 0,s=e.substring(0,r),n=e.substring(r+1,i).split("@"),o=new URLSearchParams("u">typeof i?e.substring(i):""),a={};o.forEach((e,t)=>{a[t]=e});let l="string"==typeof a.methods?a.methods.split(","):void 0;return{protocol:s,topic:(t=n[0]).startsWith("//")?t.substring(2):t,version:parseInt(n[1],10),symKey:a.symKey,relay:function(e,t="-"){let r={},i="relay"+t;return Object.keys(e).forEach(t=>{if(t.startsWith(i)){let s=t.replace(i,""),n=e[t];r[s]=n}}),r}(a),methods:l,expiryTimestamp:a.expiryTimestamp?parseInt(a.expiryTimestamp,10):void 0}},"populateAppMetadata",0,function(e){var t,r;let i=j();try{let s,n;return null!=e&&e.url&&i.url&&new URL(e.url).host!==new URL(i.url).host&&(console.warn(`The configured WalletConnect 'metadata.url':${e.url} differs from the actual page url:${i.url}. This is probably unintended and can lead to issues.`),e.url=i.url),null!=(t=e?.icons)&&t.length&&e.icons.length>0&&(e.icons=e.icons.filter(e=>""!==e)),s=B(B({},i),e),n={url:e?.url||i.url,name:e?.name||i.name,description:e?.description||i.description,icons:null!=(r=e?.icons)&&r.length&&e.icons.length>0?e.icons:i.icons},k(s,P(n))}catch(t){return console.warn("Error populating app metadata",t),e||i}},"sleep",0,function(e){return new Promise(t=>setTimeout(t,e))},"subscribeToNetworkChange",0,function(t){var r,i;switch(z()){case D:r=t,!K()&&W()&&(window.addEventListener("online",()=>r(!0)),window.addEventListener("offline",()=>r(!1)));break;case q:i=t,K()&&null!=e.g&&e.g.NetInfo&&e.g?.NetInfo.addEventListener(e=>i(e?.isConnected))}},"uuidv4",0,function(){return"u">typeof crypto&&null!=crypto&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,e=>{let t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})},"validateDecoding",0,function(e,t){let r=ik({encoded:e,encoding:t?.encoding});return iP({type:iI(r.type),senderPublicKey:"u">typeof r.senderPublicKey?(0,w.toString)(r.senderPublicKey,iv):void 0,receiverPublicKey:t?.receiverPublicKey})},"validateEncoding",0,iP,"validateSignedCacao",0,tB,"verifyP256Jwt",0,function(e,t){let r,i,[s,n,o]=e.split("."),a=c.Buffer.from(iT(o),"base64");if(64!==a.length)throw Error("Invalid signature length");let l=a.slice(0,32),u=a.slice(32,64),d=ta(`${s}.${n}`),h=(r=c.Buffer.from(t.x,"base64"),i=c.Buffer.from(t.y,"base64"),(0,S.concat)([new Uint8Array([4]),r,i]));if(!im.verify((0,S.concat)([l,u]),d,h))throw Error("Invalid signature");return(0,v.decodeJWT)(e).payload}])},4502,e=>{"use strict";e.s(["isTxAlreadySigned",0,e=>"version"in e?e.signatures.some(e=>!e.every(e=>0===e)):e.signatures.some(e=>e.signature)])},267028,e=>{"use strict";
22e.s(["filterDuplicates",0,e=>Array.from(new Set(e))])},995978,e=>{"use strict";e.s(["version",0,"4.93.0"])},633227,e=>{"use strict";"function"==typeof SuppressedError&&SuppressedError,e.s(["__awaiter",0,function(e,t,r,i){return new(r||(r=Promise))(function(s,n){function o(e){try{l(i.next(e))}catch(e){n(e)}}function a(e){try{l(i.throw(e))}catch(e){n(e)}}function l(e){var t;e.done?s(e.value):((t=e.value)instanceof r?t:new r(function(e){e(t)})).then(o,a)}l((i=i.apply(e,t||[])).next())})}])},102232,(e,t,r)=>{"use strict";let i=e.r(71187);t.exports=n;let s=function(){function e(e){return void 0!==e&&e}try{if("u">typeof globalThis)return globalThis;return Object.defineProperty(Object.prototype,"globalThis",{get:function(){return delete Object.prototype.globalThis,this.globalThis=this},configurable:!0}),globalThis}catch(t){return e(self)||e(window)||e(this)||{}}}().console||{};function n(e){var t,r;(e=e||{}).browser=e.browser||{};let i=e.browser.transmit;if(i&&"function"!=typeof i.send)throw Error("pino: transmit option must have a send function");let u=e.browser.write||s;e.browser.write&&(e.browser.asObject=!0);let d=e.serializers||{},g=(t=e.browser.serialize,Array.isArray(t)?t.filter(function(e){return"!stdSerializers.err"!==e}):!0===t&&Object.keys(d)),y=e.browser.serialize;Array.isArray(e.browser.serialize)&&e.browser.serialize.indexOf("!stdSerializers.err")>-1&&(y=!1),"function"==typeof u&&(u.error=u.fatal=u.warn=u.info=u.debug=u.trace=u),!1===e.enabled&&(e.level="silent");let m=e.level||"info",b=Object.create(u);b.log||(b.log=h),Object.defineProperty(b,"levelVal",{get:function(){return"silent"===this.level?1/0:this.levels.values[this.level]}}),Object.defineProperty(b,"level",{get:function(){return this._level},set:function(e){if("silent"!==e&&!this.levels.values[e])throw Error("unknown level "+e);this._level=e,o(v,b,"error","log"),o(v,b,"fatal","error"),o(v,b,"warn","error"),o(v,b,"info","log"),o(v,b,"debug","log"),o(v,b,"trace","log")}});let v={transmit:i,serialize:g,asObject:e.browser.asObject,levels:["error","fatal","warn","info","debug","trace"],timestamp:"function"==typeof(r=e).timestamp?r.timestamp:!1===r.timestamp?f:p};return b.levels=n.levels,b.level=m,b.setMaxListeners=b.getMaxListeners=b.emit=b.addListener=b.on=b.prependListener=b.once=b.prependOnceListener=b.removeListener=b.removeAllListeners=b.listeners=b.listenerCount=b.eventNames=b.write=b.flush=h,b.serializers=d,b._serialize=g,b._stdErrSerialize=y,b.child=function(t,r){if(!t)throw Error("missing bindings for child Pino");r=r||{},g&&t.serializers&&(r.serializers=t.serializers);let s=r.serializers;if(g&&s){var n=Object.assign({},d,s),o=!0===e.browser.serialize?Object.keys(n):g;delete t.serializers,a([t],o,n,this._stdErrSerialize)}function u(e){this._childLevel=(0|e._childLevel)+1,this.error=l(e,t,"error"),this.fatal=l(e,t,"fatal"),this.warn=l(e,t,"warn"),this.info=l(e,t,"info"),this.debug=l(e,t,"debug"),this.trace=l(e,t,"trace"),n&&(this.serializers=n,this._serialize=o),i&&(this._logEvent=c([].concat(e._logEvent.bindings,t)))}return u.prototype=this,new u(this)},i&&(b._logEvent=c()),b}function o(e,t,r,o){let l=Object.getPrototypeOf(t);t[r]=t.levelVal>t.levels.values[r]?h:l[r]?l[r]:s[r]||s[o]||h,function(e,t,r){if(e.transmit||t[r]!==h){var o;t[r]=(o=t[r],function(){let l=e.timestamp(),u=Array(arguments.length),d=Object.getPrototypeOf&&Object.getPrototypeOf(this)===s?s:this;for(var h,f,p,g=0;g<u.length;g++)u[g]=arguments[g];if(e.serialize&&!e.asObject&&a(u,this._serialize,this.serializers,this._stdErrSerialize),e.asObject?o.call(d,function(e,t,r,s){e._serialize&&a(r,e._serialize,e.serializers,e._stdErrSerialize);let o=r.slice(),l=o[0],c={};s&&(c.time=s),c.level=n.levels.values[t];let u=(0|e._childLevel)+1;if(u<1&&(u=1),null!==l&&"object"==typeof l){for(;u--&&"object"==typeof o[0];)Object.assign(c,o.shift());l=o.length?i(o.shift(),o):void 0}else"string"==typeof l&&(l=i(o.shift(),o));return void 0!==l&&(c.msg=l),c}(this,r,u,l)):o.apply(d,u),e.transmit){let i,s,o,d,g,y,m=e.transmit.level||t.level,b=n.levels.values[m],v=n.levels.values[r];if(v<b)return;h=this,f={ts:l,methodLevel:r,methodValue:v,transmitLevel:m,transmitValue:n.levels.values[e.transmit.level||t.level],send:e.transmit.send,val:t.levelVal},p=u,i=f.send,s=f.ts,o=f.methodLevel,d=f.methodValue,g=f.val,y=h._logEvent.bindings,a(p,h._serialize||Object.keys(h.serializers),h.serializers,void 0===h._stdErrSerialize||h._stdErrSerialize),h._logEvent.ts=s,h._logEvent.messages=p.filter(function(e){return -1===y.indexOf(e)}),h._logEvent.level.label=o,h._logEvent.level.value=d,i(o,h._logEvent,g),h._logEvent=c(y)}})}}(e,t,r)}function a(e,t,r,i){for(let s in e)if(i&&e[s]instanceof Error)e[s]=n.stdSerializers.err(e[s]);else if("object"==typeof e[s]&&!Array.isArray(e[s]))for(let i in e[s])t&&t.indexOf(i)>-1&&i in r&&(e[s][i]=r[i](e[s][i]))}function l(e,t,r){return function(){let i=Array(1+arguments.length);i[0]=t;for(var s=1;s<i.length;s++)i[s]=arguments[s-1];return e[r].apply(this,i)}}function c(e){return{ts:0,messages:[],bindings:e||[],level:{label:"",value:0}}}function u(){return{}}function d(e){return e}function h(){}function f(){return!1}function p(){return Date.now()}n.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}},n.stdSerializers={mapHttpRequest:u,mapHttpResponse:u,wrapRequestSerializer:d,wrapResponseSerializer:d,wrapErrorSerializer:d,req:u,res:u,err:function(e){let t={type:e.constructor.name,msg:e.message,stack:e.stack};for(let r in e)void 0===t[r]&&(t[r]=e[r]);return t}},n.stdTimeFunctions=Object.assign({},{nullTime:f,epochTime:p,unixTime:function(){return Math.round(Date.now()/1e3)},isoTime:function(){return new Date(Date.now()).toISOString()}})},278662,e=>{"use strict";var t=e.i(102232),r=e.i(31794);let i="custom_context";class s{constructor(e){this.nodeValue=e,this.sizeInBytes=new TextEncoder().encode(this.nodeValue).length,this.next=null}get value(){return this.nodeValue}get size(){return this.sizeInBytes}}class n{constructor(e){this.head=null,this.tail=null,this.lengthInNodes=0,this.maxSizeInBytes=e,this.sizeInBytes=0}append(e){let t=new s(e);if(t.size>this.maxSizeInBytes)throw Error(`[LinkedList] Value too big to insert into list: ${e} with size ${t.size}`);for(;this.size+t.size>this.maxSizeInBytes;)this.shift();this.head?this.tail&&(this.tail.next=t):this.head=t,this.tail=t,this.lengthInNodes++,this.sizeInBytes+=t.size}shift(){if(!this.head)return;let e=this.head;this.head=this.head.next,this.head||(this.tail=null),this.lengthInNodes--,this.sizeInBytes-=e.size}toArray(){let e=[],t=this.head;for(;null!==t;)e.push(t.value),t=t.next;return e}get length(){return this.lengthInNodes}get size(){return this.sizeInBytes}toOrderedArray(){return Array.from(this)}[Symbol.iterator](){let e=this.head;return{next:()=>{if(!e)return{done:!0,value:null};let t=e.value;return e=e.next,{done:!1,value:t}}}}}class o{constructor(e,r=1024e3){this.level=e??"error",this.levelValue=t.levels.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=r,this.logs=new n(this.MAX_LOG_SIZE_IN_BYTES)}forwardToConsole(e,r){r===t.levels.values.error?console.error(e):r===t.levels.values.warn?console.warn(e):r===t.levels.values.debug?console.debug(e):r===t.levels.values.trace?console.trace(e):console.log(e)}appendToLogs(e){this.logs.append((0,r.safeJsonStringify)({timestamp:new Date().toISOString(),log:e}));let t="string"==typeof e?JSON.parse(e).level:e.level;t>=this.levelValue&&this.forwardToConsole(e,t)}getLogs(){return this.logs}clearLogs(){this.logs=new n(this.MAX_LOG_SIZE_IN_BYTES)}getLogArray(){return Array.from(this.logs)}logsToBlob(e){let t=this.getLogArray();return t.push((0,r.safeJsonStringify)({extraMetadata:e})),new Blob(t,{type:"application/json"})}}class a{constructor(e,t=1024e3){this.baseChunkLogger=new o(e,t)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}downloadLogsBlobInBrowser(e){let t=URL.createObjectURL(this.logsToBlob(e)),r=document.createElement("a");r.href=t,r.download=`walletconnect-logs-${new Date().toISOString()}.txt`,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(t)}}class l{constructor(e,t=1024e3){this.baseChunkLogger=new o(e,t)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}}var c=Object.defineProperty,u=Object.defineProperties,d=Object.getOwnPropertyDescriptors,h=Object.getOwnPropertySymbols,f=Object.prototype.hasOwnProperty,p=Object.prototype.propertyIsEnumerable,g=(e,t,r)=>t in e?c(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,y=(e,t)=>{for(var r in t||(t={}))f.call(t,r)&&g(e,r,t[r]);if(h)for(var r of h(t))p.call(t,r)&&g(e,r,t[r]);return e};function m(e,t=i){return typeof e.bindings>"u"?function(e,t=i){return e[t]||""}(e,t):e.bindings().context||""}e.s(["generateChildLogger",0,function(e,t,r=i){let s=function(e,t,r=i){let s=m(e,r);return s.trim()?`${s}/${t}`:t}(e,t,r);return function(e,t,r=i){return e[r]=t,e}(e.child({context:s}),s,r)},"generatePlatformLogger",0,function(e){var r,i,s,n;let o,c,h,f;return"u">typeof e.loggerOverride&&"string"!=typeof e.loggerOverride?{logger:e.loggerOverride,chunkLoggerController:null}:"u">typeof window?(f=new a(null==(s=(i=e).opts)?void 0:s.level,i.maxSizeInBytes),{logger:(0,t.default)((c=y({},i.opts),h={level:"trace",browser:u(y({},null==(n=i.opts)?void 0:n.browser),d({write:e=>f.write(e)}))},u(c,d(h)))),chunkLoggerController:f}):(o=new l(null==(r=e.opts)?void 0:r.level,e.maxSizeInBytes),{logger:(0,t.default)(u(y({},e.opts),d({level:"trace"})),o),chunkLoggerController:o})},"getDefaultLoggerOptions",0,function(e){return u(y({},e),d({level:e?.level||"info"}))},"getLoggerContext",0,m])},241370,e=>{"use strict";var t=e.i(102232);e.s(["pino",()=>t.default])},826472,e=>{"use strict";var t=e.i(81775),r=e.i(219298),i=Object.defineProperty,s=(e,t,r)=>{let s;return(s="symbol"!=typeof t?t+"":t)in e?i(e,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[s]=r};class n extends t.IEvents{constructor(e){super(),this.opts=e,s(this,"protocol","wc"),s(this,"version",2)}}var o=Object.defineProperty;class a extends t.IEvents{constructor(e,t){super(),this.core=e,this.logger=t,((e,t,r)=>{let i;return(i="symbol"!=typeof t?t+"":t)in e?o(e,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[i]=r})(this,"records",new Map)}}class l extends t.IEvents{constructor(e,t){super(),this.relayer=e,this.logger=t}}class c extends t.IEvents{constructor(e){super()}}class u extends t.IEvents{constructor(e,t){super(),this.relayer=e,this.logger=t}}class d extends t.IEvents{constructor(e,t){super(),this.core=e,this.logger=t}}r.default,r.EventEmitter,e.s(["ICore",0,n,"IEchoClient",0,class{constructor(e,t){this.projectId=e,this.logger=t}},"IEventClient",0,class{constructor(e,t,r){this.core=e,this.logger=t,this.telemetryEnabled=r}},"IExpirer",0,d,"IJsonRpcHistory",0,a,"IMessageTracker",0,class{constructor(e,t){this.logger=e,this.core=t}},"IPublisher",0,l,"IRelayer",0,c,"IStore",0,class{constructor(e,t,r,i
22){this.core=e,this.logger=t,this.name=r}},"ISubscriber",0,u,"IVerify",0,class{constructor(e,t,r){this.core=e,this.logger=t,this.store=r}}])},318178,e=>{"use strict";e.s(["compare",0,function(e,t){for(let r=0;r<e.byteLength;r++){if(e[r]<t[r])return -1;if(e[r]>t[r])return 1}return e.byteLength>t.byteLength?1:e.byteLength<t.byteLength?-1:0}])},863134,e=>{"use strict";e.s(["asUint8Array",0,function(e){return null!=globalThis.Buffer?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e}])},953530,e=>{"use strict";var t=e.i(863134);e.s(["allocUnsafe",0,function(e=0){return null!=globalThis.Buffer&&null!=globalThis.Buffer.allocUnsafe?(0,t.asUint8Array)(globalThis.Buffer.allocUnsafe(e)):new Uint8Array(e)}])},698453,e=>{"use strict";var t=e.i(953530),r=e.i(863134);e.s(["concat",0,function(e,i){i||(i=e.reduce((e,t)=>e+t.length,0));let s=(0,t.allocUnsafe)(i),n=0;for(let t of e)s.set(t,n),n+=t.length;return(0,r.asUint8Array)(s)}])},395028,e=>{"use strict";e.s(["equals",0,function(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}])},500561,e=>{"use strict";var t=e.i(18531),r=e.i(953530);function i(e,t,r,i){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:i}}}let s=i("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),n=i("ascii","a",e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t},e=>{e=e.substring(1);let t=(0,r.allocUnsafe)(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),o={utf8:s,"utf-8":s,hex:t.bases.base16,latin1:n,ascii:n,binary:n,...t.bases};e.s(["default",0,o])},670129,e=>{"use strict";var t=e.i(500561),r=e.i(863134);e.s(["fromString",0,function(e,i="utf8"){let s=t.default[i];if(!s)throw Error(`Unsupported encoding "${i}"`);return("utf8"===i||"utf-8"===i)&&null!=globalThis.Buffer&&null!=globalThis.Buffer.from?(0,r.asUint8Array)(globalThis.Buffer.from(e,"utf-8")):s.decoder.decode(`${s.prefix}${e}`)}])},82192,e=>{"use strict";var t=e.i(500561);e.s(["toString",0,function(e,r="utf8"){let i=t.default[r];if(!i)throw Error(`Unsupported encoding "${r}"`);return("utf8"===r||"utf-8"===r)&&null!=globalThis.Buffer&&null!=globalThis.Buffer.from?globalThis.Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString("utf8"):i.encoder.encode(e).substring(1)}])},132138,e=>{"use strict";var t=e.i(953530),r=e.i(863134);e.s(["xor",0,function(e,i){if(e.length!==i.length)throw Error("Inputs should have the same length");let s=(0,t.allocUnsafe)(e.length);for(let t=0;t<e.length;t++)s[t]=e[t]^i[t];return(0,r.asUint8Array)(s)}])},791888,e=>{"use strict";e.i(318178),e.i(698453),e.i(395028),e.i(670129),e.i(82192),e.i(132138),e.s([])},274283,e=>{"use strict";var t=e.i(247167),r=e.i(467034),i=e.i(219298),s=e.i(180476),n=e.i(499276),o=e.i(278662),a=e.i(241370),l=e.i(826472),c=e.i(648512),u=e.i(31794),d=e.i(121609),h=e.i(741483);e.i(791888);var f=e.i(82192),p=e.i(501365);e.i(424047);var g=e.i(329193),y=e.i(850967),m=e.i(112324),b=e.i(36610);let v="core",w=`wc@2:${v}:`,_={database:":memory:"},S="client_ed25519_seed",E=c.ONE_DAY,I=c.SIX_HOURS,A="wss://relay.walletconnect.org",T={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",transport_closed:"relayer_transport_closed",publish:"relayer_publish"},x="payload",k="connect",P="disconnect",O="error",R="2.21.5",C={link_mode:"link_mode",relay:"relay"},N="inbound",B="WALLETCONNECT_LINK_MODE_APPS",U="subscription_created",q="subscription_deleted",L=(c.THIRTY_DAYS,c.FIVE_SECONDS,c.THIRTY_DAYS,{wc_pairingDelete:{req:{ttl:c.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:c.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:c.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:c.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:c.ONE_DAY,prompt:!1,tag:0},res:{ttl:c.ONE_DAY,prompt:!1,tag:0}}}),D={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},M="history_created",K="history_updated",W="history_deleted",z={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},j=(c.ONE_DAY,"https://verify.walletconnect.org"),V=`${j}/v3`,$=["https://verify.walletconnect.com",j],F={pairing_started:"pairing_started",pairing_uri_validation_success:"pairing_uri_validation_success",pairing_uri_not_expired:"pairing_uri_not_expired",store_new_pairing:"store_new_pairing",subscribing_pairing_topic:"subscribing_pairing_topic",subscribe_pairing_topic_success:"subscribe_pairing_topic_success",existing_pairing:"existing_pairing",pairing_not_expired:"pairing_not_expired",emit_inactive_pairing:"emit_inactive_pairing",emit_session_proposal:"emit_session_proposal",subscribing_to_pairing_topic:"subscribing_to_pairing_topic"},H={no_wss_connection:"no_wss_connection",no_internet_connection:"no_internet_connection",malformed_pairing_uri:"malformed_pairing_uri",active_pairing_already_exists:"active_pairing_already_exists",subscribe_pairing_topic_failure:"subscribe_pairing_topic_failure",pairing_expired:"pairing_expired",proposal_expired:"proposal_expired",proposal_listener_not_found:"proposal_listener_not_found"};var G=function(e,t){if(e.length>=255)throw TypeError("Alphabet too long");
22for(var r=new Uint8Array(256),i=0;i<r.length;i++)r[i]=255;for(var s=0;s<e.length;s++){var n=e.charAt(s),o=n.charCodeAt(0);if(255!==r[o])throw TypeError(n+" is ambiguous");r[o]=s}var a=e.length,l=e.charAt(0),c=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function d(e){if("string"!=typeof e)throw TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[0]){for(var i=0,s=0;e[t]===l;)i++,t++;for(var n=(e.length-t)*c+1>>>0,o=new Uint8Array(n);e[t];){var u=r[e.charCodeAt(t)];if(255===u)return;for(var d=0,h=n-1;(0!==u||d<s)&&-1!==h;h--,d++)u+=a*o[h]>>>0,o[h]=u%256>>>0,u=u/256>>>0;if(0!==u)throw Error("Non-zero carry");s=d,t++}if(" "!==e[t]){for(var f=n-s;f!==n&&0===o[f];)f++;for(var p=new Uint8Array(i+(n-f)),g=i;f!==n;)p[g++]=o[f++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,i=0,s=0,n=t.length;s!==n&&0===t[s];)s++,r++;for(var o=(n-s)*u+1>>>0,c=new Uint8Array(o);s!==n;){for(var d=t[s],h=0,f=o-1;(0!==d||h<i)&&-1!==f;f--,h++)d+=256*c[f]>>>0,c[f]=d%a>>>0,d=d/a>>>0;if(0!==d)throw Error("Non-zero carry");i=h,s++}for(var p=o-i;p!==o&&0===c[p];)p++;for(var g=l.repeat(r);p<o;++p)g+=e.charAt(c[p]);return g},decodeUnsafe:d,decode:function(e){var r=d(e);if(r)return r;throw Error(`Non-${t} character`)}}};let J=e=>{if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw Error("Unknown type, must be binary type")};class Y{constructor(e,t,r){this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class Z{constructor(e,t,r){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"==typeof e){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}throw Error("Can only multibase decode strings")}or(e){return Q(this,e)}}class X{constructor(e){this.decoders=e}or(e){return Q(this,e)}decode(e){let t=e[0],r=this.decoders[t];if(r)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}let Q=(e,t)=>new X({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});
22class ee{constructor(e,t,r,i){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=i,this.encoder=new Y(e,t,r),this.decoder=new Z(e,t,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}let et=({name:e,prefix:t,encode:r,decode:i})=>new ee(e,t,r,i),er=({prefix:e,name:t,alphabet:r})=>{let{encode:i,decode:s}=G(r,t);return et({prefix:e,name:t,encode:i,decode:e=>J(s(e))})},ei=({name:e,prefix:t,bitsPerChar:r,alphabet:i})=>et({prefix:t,name:e,encode:e=>((e,t,r)=>{let i="="===t[t.length-1],s=(1<<r)-1,n="",o=0,a=0;for(let i=0;i<e.length;++i)for(a=a<<8|e[i],o+=8;o>r;)o-=r,n+=t[s&a>>o];if(o&&(n+=t[s&a<<r-o]),i)for(;n.length*r&7;)n+="=";return n})(e,i,r),decode:t=>((e,t,r,i)=>{let s={};for(let e=0;e<t.length;++e)s[t[e]]=e;let n=e.length;for(;"="===e[n-1];)--n;let o=new Uint8Array(n*r/8|0),a=0,l=0,c=0;for(let t=0;t<n;++t){let n=s[e[t]];if(void 0===n)throw SyntaxError(`Non-${i} character`);l=l<<r|n,(a+=r)>=8&&(a-=8,o[c++]=255&l>>a)}if(a>=r||255&l<<8-a)throw SyntaxError("Unexpected end of data");return o})(t,i,r,e)});var es=Object.freeze({__proto__:null,identity:et({prefix:"\0",name:"identity",encode:e=>new TextDecoder().decode(e),decode:e=>new TextEncoder().encode(e)})}),en=Object.freeze({__proto__:null,base2:ei({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1})}),eo=Object.freeze({__proto__:null,base8:ei({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3})}),ea=Object.freeze({__proto__:null,base10:er({prefix:"9",name:"base10",alphabet:"0123456789"})}),el=Object.freeze({__proto__:null,base16:ei({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),base16upper:ei({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4})}),ec=Object.freeze({__proto__:null,base32:ei({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),base32upper:ei({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),base32pad:ei({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),base32padupper:ei({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),base32hex:ei({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),base32hexupper:ei({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),base32hexpad:ei({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),base32hexpadupper:ei({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),base32z:ei({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5})}),eu=Object.freeze({__proto__:null,base36:er({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),base36upper:er({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"})}),ed=Object.freeze({__proto__:null,base58btc:er({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),base58flickr:er({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"})}),eh=Object.freeze({__proto__:null,base64:ei({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),base64pad:ei({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),base64url:ei({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),base64urlpad:ei({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6})});let ef=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈ðŸ‘
22‡ðŸŽ¶ðŸ˜’🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),ep=ef.reduce((e,t,r)=>(e[r]=t,e),[]),eg=ef.reduce((e,t,r)=>(e[t.codePointAt(0)]=r,e),[]);var ey=Object.freeze({__proto__:null,base256emoji:et({prefix:"🚀",name:"base256emoji",encode:function(e){return e.reduce((e,t)=>e+=ep[t],"")},decode:function(e){let t=[];for(let r of e){let e=eg[r.codePointAt(0)];if(void 0===e)throw Error(`Non-base256emoji character: ${r}`);t.push(e)}return new Uint8Array(t)}})});function em(e,t,r){t=t||[],r=r||0;for(var i=r;e>=0x80000000;)t[r++]=255&e|128,e/=128;for(;-128&e;)t[r++]=255&e|128,e>>>=7;return t[r]=0|e,em.bytes=r-i+1,t}var eb=function(e){return e<128?1:e<16384?2:e<2097152?3:e<0x10000000?4:e<0x800000000?5:e<0x40000000000?6:e<0x2000000000000?7:e<0x100000000000000?8:e<0x8000000000000000?9:10};let ev=(e,t,r=0)=>(em(e,t,r),t),ew=(e,t)=>{let r=t.byteLength,i=eb(e),s=i+eb(r),n=new Uint8Array(s+r);return ev(e,n,0),ev(r,n,i),n.set(t,s),new e_(e,r,t,n)};
22class e_{constructor(e,t,r,i){this.code=e,this.size=t,this.digest=r,this.bytes=i}}let eS=({name:e,code:t,encode:r})=>new eE(e,t,r);class eE{constructor(e,t,r){this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?ew(this.code,t):t.then(e=>ew(this.code,e))}throw Error("Unknown type, must be binary type")}}let eI=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t));var eA=Object.freeze({__proto__:null,sha256:eS({name:"sha2-256",code:18,encode:eI("SHA-256")}),sha512:eS({name:"sha2-512",code:19,encode:eI("SHA-512")})}),eT=Object.freeze({__proto__:null,identity:{code:0,name:"identity",encode:J,digest:e=>ew(0,J(e))}});new TextEncoder,new TextDecoder;let ex={...es,...en,...eo,...ea,...el,...ec,...eu,...ed,...eh,...ey};function ek(e){return null!=globalThis.Buffer?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e}function eP(e,t,r,i){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:i}}}({...eA,...eT});let eO=eP("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),eR=eP("ascii","a",e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t},e=>{let t=function(e=0){return null!=globalThis.Buffer&&null!=globalThis.Buffer.allocUnsafe?ek(globalThis.Buffer.allocUnsafe(e)):new Uint8Array(e)}((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),eC={utf8:eO,"utf-8":eO,hex:ex.base16,latin1:eR,ascii:eR,binary:eR,...ex};var eN=Object.defineProperty,eB=(e,t,r)=>{let i;return(i="symbol"!=typeof t?t+"":t)in e?eN(e,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[i]=r};class eU{constructor(e,t){this.core=e,this.logger=t,eB(this,"keychain",new Map),eB(this,"name","keychain"),eB(this,"version","0.3"),eB(this,"initialized",!1),eB(this,"storagePrefix",w),eB(this,"init",async()=>{if(!this.initialized){let e=await this.getKeyChain();"u">typeof e&&(this.keychain=e),this.initialized=!0}}),eB(this,"has",e=>(this.isInitialized(),this.keychain.has(e))),eB(this,"set",async(e,t)=>{this.isInitialized(),this.keychain.set(e,t),await this.persist()}),eB(this,"get",e=>{this.isInitialized();let t=this.keychain.get(e);if(typeof t>"u"){let{message:t}=(0,h.getInternalError)("NO_MATCHING_KEY",`${this.name}: ${e}`);throw Error(t)}return t}),eB(this,"del",async e=>{this.isInitialized(),this.keychain.delete(e),await this.persist()}),this.core=e,this.logger=(0,o.generateChildLogger)(t,this.name)}get context(){return(0,o.getLoggerContext)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,(0,h.mapToObj)(e))}async getKeyChain(){let e=await this.core.storage.getItem(this.storageKey);return"u">typeof e?(0,h.objToMap)(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){let{message:e}=(0,h.getInternalError)("NOT_INITIALIZED",this.name);throw Error(e)}}}var eq=Object.defineProperty,eL=(e,t,r)=>{let i;return(i="symbol"!=typeof t?t+"":t)in e?eq(e,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[i]=r};class eD{constructor(e,t,r){this.core=e,this.logger=t,eL(this,"name","crypto"),eL(this,"keychain"),eL(this,"randomSessionIdentifier",(0,h.generateRandomBytes32)()),eL(this,"initialized",!1),eL(this,"init",async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)}),eL(this,"hasKeys",e=>(this.isInitialized(),this.keychain.has(e))),eL(this,"getClientId",async()=>{this.isInitialized();let e=await this.getClientSeed(),t=d.generateKeyPair(e);return d.encodeIss(t.publicKey)}),eL(this,"generateKeyPair",()=>{this.isInitialized();let e=(0,h.generateKeyPair)();return this.setPrivateKey(e.publicKey,e.privateKey)}),eL(this,"signJWT",async e=>{this.isInitialized();let t=await this.getClientSeed(),r=d.generateKeyPair(t),i=this.randomSessionIdentifier;return await d.signJWT(i,e,E,r)}),eL(this,"generateSharedKey",(e,t,r)=>{this.isInitialized();let i=this.getPrivateKey(e),s=(0,h.deriveSymKey)(i,t);return this.setSymKey(s,r)}),eL(this,"setSymKey",async(e,t)=>{this.isInitialized();let r=t||(0,h.hashKey)(e);return await this.keychain.set(r,e),r}),eL(this,"deleteKeyPair",async e=>{this.isInitialized(),await this.keychain.del(e)}),eL(this,"deleteSymKey",async e=>{this.isInitialized(),await this.keychain.del(e)}),eL(this,"encode",async(e,t,r)=>{this.isInitialized();let i=(0,h.validateEncoding)(r),s=(0,u.safeJsonStringify)(t);if((0,h.isTypeTwoEnvelope)(i))return(0,h.encodeTypeTwoEnvelope)(s,r?.encoding);
22if((0,h.isTypeOneEnvelope)(i)){let t=i.senderPublicKey,r=i.receiverPublicKey;e=await this.generateSharedKey(t,r)}let n=this.getSymKey(e),{type:o,senderPublicKey:a}=i;return(0,h.encrypt)({type:o,symKey:n,message:s,senderPublicKey:a,encoding:r?.encoding})}),eL(this,"decode",async(e,t,r)=>{this.isInitialized();let i=(0,h.validateDecoding)(t,r);if((0,h.isTypeTwoEnvelope)(i)){let e=(0,h.decodeTypeTwoEnvelope)(t,r?.encoding);return(0,u.safeJsonParse)(e)}if((0,h.isTypeOneEnvelope)(i)){let t=i.receiverPublicKey,r=i.senderPublicKey;e=await this.generateSharedKey(t,r)}try{let i=this.getSymKey(e),s=(0,h.decrypt)({symKey:i,encoded:t,encoding:r?.encoding});return(0,u.safeJsonParse)(s)}catch(t){this.logger.error(`Failed to decode message from topic: '${e}', clientId: '${await this.getClientId()}'`),this.logger.error(t)}}),eL(this,"getPayloadType",(e,t=h.BASE64)=>{let r=(0,h.deserialize)({encoded:e,encoding:t});return(0,h.decodeTypeByte)(r.type)}),eL(this,"getPayloadSenderPublicKey",(e,t=h.BASE64)=>{let r=(0,h.deserialize)({encoded:e,encoding:t});return r.senderPublicKey?(0,f.toString)(r.senderPublicKey,h.BASE16):void 0}),this.core=e,this.logger=(0,o.generateChildLogger)(t,this.name),this.keychain=r||new eU(this.core,this.logger)}get context(){return(0,o.getLoggerContext)(this.logger)}async setPrivateKey(e,t){return await this.keychain.set(e,t),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(S)}catch{e=(0,h.generateRandomBytes32)(),await this.keychain.set(S,e)}return function(e,t="utf8"){let r=eC[t];if(!r)throw Error(`Unsupported encoding "${t}"`);return("utf8"===t||"utf-8"===t)&&null!=globalThis.Buffer&&null!=globalThis.Buffer.from?ek(globalThis.Buffer.from(e,"utf-8")):r.decoder.decode(`${r.prefix}${e}`)}(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){let{message:e}=(0,h.getInternalError)("NOT_INITIALIZED",this.name);throw Error(e)}}}var eM=Object.defineProperty,eK=Object.defineProperties,eW=Object.getOwnPropertyDescriptors,ez=Object.getOwnPropertySymbols,ej=Object.prototype.hasOwnProperty,eV=Object.prototype.propertyIsEnumerable,e$=(e,t,r)=>t in e?eM(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,eF=(e,t,r)=>e$(e,"symbol"!=typeof t?t+"":t,r);class eH extends l.IMessageTracker{constructor(e,t){super(e,t),this.logger=e,this.core=t,eF(this,"messages",new Map),eF(this,"messagesWithoutClientAck",new Map),eF(this,"name","messages"),eF(this,"version","0.3"),eF(this,"initialized",!1),eF(this,"storagePrefix",w),eF(this,"init",async()=>{if(!this.initialized){this.logger.trace("Initialized");try{let e=await this.getRelayerMessages();"u">typeof e&&(this.messages=e);let t=await this.getRelayerMessagesWithoutClientAck();"u">typeof t&&(this.messagesWithoutClientAck=t),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}finally{this.initialized=!0}}}),eF(this,"set",async(e,t,r)=>{this.isInitialized();let i=(0,h.hashMessage)(t),s=this.messages.get(e);if(typeof s>"u"&&(s={}),"u">typeof s[i])return i;if(s[i]=t,this.messages.set(e,s),r===N){let r=this.messagesWithoutClientAck.get(e)||{};this.messagesWithoutClientAck.set(e,eK(((e,t)=>{for(var r in t||(t={}))ej.call(t,r)&&e$(e,r,t[r]);if(ez)for(var r of ez(t))eV.call(t,r)&&e$(e,r,t[r]);return e})({},r),eW({[i]:t})))}return await this.persist(),i}),eF(this,"get",e=>{this.isInitialized();let t=this.messages.get(e);return typeof t>"u"&&(t={}),t}),eF(this,"getWithoutAck",e=>{this.isInitialized();let t={};for(let r of e){let e=this.messagesWithoutClientAck.get(r)||{};t[r]=Object.values(e)}return t}),eF(this,"has",(e,t)=>(this.isInitialized(),"u">typeof this.get(e)[(0,h.hashMessage)(t)])),eF(this,"ack",async(e,t)=>{this.isInitialized();let r=this.messagesWithoutClientAck.get(e);if(typeof r>"u")return;let i=(0,h.hashMessage)(t);delete r[i],0===Object.keys(r).length?this.messagesWithoutClientAck.delete(e):this.messagesWithoutClientAck.set(e,r),await this.persist()}),eF(this,"del",async e=>{this.isInitialized(),this.messages.delete(e),this.messagesWithoutClientAck.delete(e),await this.persist()}),this.logger=(0,o.generateChildLogger)(e,this.name),this.core=t}
22get context(){return(0,o.getLoggerContext)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get storageKeyWithoutClientAck(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name+"_withoutClientAck"}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,(0,h.mapToObj)(e))}async setRelayerMessagesWithoutClientAck(e){await this.core.storage.setItem(this.storageKeyWithoutClientAck,(0,h.mapToObj)(e))}async getRelayerMessages(){let e=await this.core.storage.getItem(this.storageKey);return"u">typeof e?(0,h.objToMap)(e):void 0}async getRelayerMessagesWithoutClientAck(){let e=await this.core.storage.getItem(this.storageKeyWithoutClientAck);return"u">typeof e?(0,h.objToMap)(e):void 0}async persist(){await this.setRelayerMessages(this.messages),await this.setRelayerMessagesWithoutClientAck(this.messagesWithoutClientAck)}isInitialized(){if(!this.initialized){let{message:e}=(0,h.getInternalError)("NOT_INITIALIZED",this.name);throw Error(e)}}}var eG=Object.defineProperty,eJ=Object.defineProperties,eY=Object.getOwnPropertyDescriptors,eZ=Object.getOwnPropertySymbols,eX=Object.prototype.hasOwnProperty,eQ=Object.prototype.propertyIsEnumerable,e0=(e,t,r)=>t in e?eG(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,e1=(e,t)=>{for(var r in t||(t={}))eX.call(t,r)&&e0(e,r,t[r]);if(eZ)for(var r of eZ(t))eQ.call(t,r)&&e0(e,r,t[r]);return e},e2=(e,t,r)=>e0(e,"symbol"!=typeof t?t+"":t,r);class e5 extends l.IPublisher{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,e2(this,"events",new i.EventEmitter),e2(this,"name","publisher"),e2(this,"queue",new Map),e2(this,"publishTimeout",(0,c.toMiliseconds)(c.ONE_MINUTE)),e2(this,"initialPublishTimeout",(0,c.toMiliseconds)(15*c.ONE_SECOND)),e2(this,"needsTransportRestart",!1),e2(this,"publish",async(e,t,r)=>{var i;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:e,message:t,opts:r}});let s=r?.ttl||I,n=(0,h.getRelayProtocolName)(r),o=r?.prompt||!1,a=r?.tag||0,l=r?.id||(0,g.getBigIntRpcId)().toString(),c={topic:e,message:t,opts:{ttl:s,relay:n,prompt:o,tag:a,id:l,attestation:r?.attestation,tvf:r?.tvf}},u=`Failed to publish payload, please try again. id:${l} tag:${a}`;try{let i=new Promise(async i=>{let n=({id:e})=>{c.opts.id===e&&(this.removeRequestFromQueue(e),this.relayer.events.removeListener(T.publish,n),i(c))};this.relayer.events.on(T.publish,n);let u=(0,h.createExpiringPromise)(new Promise((i,n)=>{this.rpcPublish({topic:e,message:t,ttl:s,prompt:o,tag:a,id:l,attestation:r?.attestation,tvf:r?.tvf}).then(i).catch(e=>{this.logger.warn(e,e?.message),n(e)})}),this.initialPublishTimeout,`Failed initial publish, retrying.... id:${l} tag:${a}`);try{await u,this.events.removeListener(T.publish,n)}catch(r){let e,t;this.queue.set(l,(e=e1({},c),t={attempt:1},eJ(e,eY(t)))),this.logger.warn(r,r?.message)}});this.logger.trace({type:"method",method:"publish",params:{id:l,topic:e,message:t,opts:r}}),await (0,h.createExpiringPromise)(i,this.publishTimeout,u)}catch(e){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(e),null!=(i=r?.internal)&&i.throwOnFailedPublish)throw e}finally{this.queue.delete(l)}}),e2(this,"on",(e,t)=>{this.events.on(e,t)}),e2(this,"once",(e,t)=>{this.events.once(e,t)}),e2(this,"off",(e,t)=>{this.events.off(e,t)}),e2(this,"removeListener",(e,t)=>{this.events.removeListener(e,t)}),this.relayer=e,this.logger=(0,o.generateChildLogger)(t,this.name),this.registerEventListeners()}get context(){return(0,o.getLoggerContext)(this.logger)}async rpcPublish(e){var t,r,i,s;let{topic:n,message:o,ttl:a=I,prompt:l,tag:c,id:u,attestation:d,tvf:f}=e,p={method:(0,h.getRelayProtocolApi)((0,h.getRelayProtocolName)().protocol).publish,params:e1({topic:n,message:o,ttl:a,prompt:l,tag:c,attestation:d},f),id:u};(0,h.isUndefined)(null==(t=p.params)?void 0:t.prompt)&&(null==(r=p.params)||delete r.prompt),(0,h.isUndefined)(null==(i=p.params)?void 0:i.tag)&&(null==(s=p.params)||delete s.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:p});let g=await this.relayer.request(p);return this.relayer.events.emit(T.publish,e),this.logger.debug("Successfully Published Payload"),g}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async(e,t)=>{let r=e.attempt+1;this.queue.set(t,eJ(e1({},e),eY({attempt:r}
22)));let{topic:i,message:s,opts:n,attestation:o}=e;this.logger.warn({},`Publisher: queue->publishing: ${e.opts.id}, tag: ${e.opts.tag}, attempt: ${r}`),await this.rpcPublish(eJ(e1({},e),eY({topic:i,message:s,ttl:n.ttl,prompt:n.prompt,tag:n.tag,id:n.id,attestation:o,tvf:n.tvf}))),this.logger.warn({},`Publisher: queue->published: ${e.opts.id}`)})}registerEventListeners(){this.relayer.core.heartbeat.on(s.HEARTBEAT_EVENTS.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(T.connection_stalled);return}this.checkQueue()}),this.relayer.on(T.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}}var e6=Object.defineProperty,e3=(e,t,r)=>{let i;return(i="symbol"!=typeof t?t+"":t)in e?e6(e,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[i]=r};class e8{constructor(){e3(this,"map",new Map),e3(this,"set",(e,t)=>{let r=this.get(e);this.exists(e,t)||this.map.set(e,[...r,t])}),e3(this,"get",e=>this.map.get(e)||[]),e3(this,"exists",(e,t)=>this.get(e).includes(t)),e3(this,"delete",(e,t)=>{if(typeof t>"u")return void this.map.delete(e);if(!this.map.has(e))return;let r=this.get(e);if(!this.exists(e,t))return;let i=r.filter(e=>e!==t);i.length?this.map.set(e,i):this.map.delete(e)}),e3(this,"clear",()=>{this.map.clear()})}get topics(){return Array.from(this.map.keys())}}var e4=Object.defineProperty,e7=Object.defineProperties,e9=Object.getOwnPropertyDescriptors,te=Object.getOwnPropertySymbols,tt=Object.prototype.hasOwnProperty,tr=Object.prototype.propertyIsEnumerable,ti=(e,t,r)=>t in e?e4(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ts=(e,t)=>{for(var r in t||(t={}))tt.call(t,r)&&ti(e,r,t[r]);if(te)for(var r of te(t))tr.call(t,r)&&ti(e,r,t[r]);return e},tn=(e,t,r)=>ti(e,"symbol"!=typeof t?t+"":t,r);class to extends l.ISubscriber{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,tn(this,"subscriptions",new Map),tn(this,"topicMap",new e8),tn(this,"events",new i.EventEmitter),tn(this,"name","subscription"),tn(this,"version","0.3"),tn(this,"pending",new Map),tn(this,"cached",[]),tn(this,"initialized",!1),tn(this,"storagePrefix",w),tn(this,"subscribeTimeout",(0,c.toMiliseconds)(c.ONE_MINUTE)),tn(this,"initialSubscribeTimeout",(0,c.toMiliseconds)(15*c.ONE_SECOND)),tn(this,"clientId"),tn(this,"batchSubscribeTopicsLimit",500),tn(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),await this.restore()),this.initialized=!0}),tn(this,"subscribe",async(e,t)=>{this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:e,opts:t}});try{let r=(0,h.getRelayProtocolName)(t),i={topic:e,relay:r,transportType:t?.transportType};this.pending.set(e,i);let s=await this.rpcSubscribe(e,r,t);return"string"==typeof s&&(this.onSubscribe(s,i),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:e,opts:t}})),s}catch(e){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(e),e}}),tn(this,"unsubscribe",async(e,t)=>{this.isInitialized(),"u">typeof t?.id?await this.unsubscribeById(e,t.id,t):await this.unsubscribeByTopic(e,t)}),tn(this,"isSubscribed",e=>new Promise(t=>{t(this.topicMap.topics.includes(e))})),tn(this,"isKnownTopic",e=>new Promise(t=>{t(this.topicMap.topics.includes(e)||this.pending.has(e)||this.cached.some(t=>t.topic===e))})),tn(this,"on",(e,t)=>{this.events.on(e,t)}),tn(this,"once",(e,t)=>{this.events.once(e,t)}),tn(this,"off",(e,t)=>{this.events.off(e,t)}),tn(this,"removeListener",(e,t)=>{this.events.removeListener(e,t)}),tn(this,"start",async()=>{await this.onConnect()}),tn(this,"stop",async()=>{await this.onDisconnect()}),tn(this,"restart",async()=>{await this.restore(),await this.onRestart()}),tn(this,"checkPending",async()=>{if(0===this.pending.size&&(!this.initialized||!this.relayer.connected))return;let e=[];this.pending.forEach(t=>{e.push(t)}),await this.batchSubscribe(e)}),tn(this,"registerEventListeners",()=>{this.relayer.core.heartbeat.on(s.HEARTBEAT_EVENTS.pulse,async()=>{await this.checkPending()}),this.events.on(U,async e=>{this.logger.info(`Emitting ${U}`),this.logger.debug({type:"event",event:U,data:e}),await this.persist()}),this.events.on(q,async e=>{this.logger.info(`Emitting ${q}`),this.logger.debug({type:"event",event:q,data:e}),await this.persist()})}),this.relayer=e,this.logger=(0,o.generateChildLogger)(t,this.name),this.clientId=""}
22get context(){return(0,o.getLoggerContext)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}get hasAnyTopics(){return this.topicMap.topics.length>0||this.pending.size>0||this.cached.length>0||this.subscriptions.size>0}hasSubscription(e,t){let r=!1;try{r=this.getSubscription(e).topic===t}catch{}return r}reset(){this.cached=[],this.initialized=!0}onDisable(){this.values.length>0&&(this.cached=this.values),this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,t){let r=this.topicMap.get(e);await Promise.all(r.map(async r=>await this.unsubscribeById(e,r,t)))}async unsubscribeById(e,t,r){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:r}});try{let i=(0,h.getRelayProtocolName)(r);await this.restartToComplete({topic:e,id:t,relay:i}),await this.rpcUnsubscribe(e,t,i);let s=(0,h.getSdkError)("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,t,s),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:r}})}catch(e){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(e),e}}async rpcSubscribe(e,t,r){var i;r&&r?.transportType!==C.relay||await this.restartToComplete({topic:e,id:e,relay:t});let s={method:(0,h.getRelayProtocolApi)(t.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s});let n=null==(i=r?.internal)?void 0:i.throwOnFailedPublish;
22try{let t=await this.getSubscriptionId(e);if(r?.transportType===C.link_mode)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(s).catch(e=>this.logger.warn(e))},(0,c.toMiliseconds)(c.ONE_SECOND)),t;let i=new Promise(async t=>{let r=i=>{i.topic===e&&(this.events.removeListener(U,r),t(i.id))};this.events.on(U,r);try{let i=await (0,h.createExpiringPromise)(new Promise((e,t)=>{this.relayer.request(s).catch(e=>{this.logger.warn(e,e?.message),t(e)}).then(e)}),this.initialSubscribeTimeout,`Subscribing to ${e} failed, please try again`);this.events.removeListener(U,r),t(i)}catch{}}),o=await (0,h.createExpiringPromise)(i,this.subscribeTimeout,`Subscribing to ${e} failed, please try again`);if(!o&&n)throw Error(`Subscribing to ${e} failed, please try again`);return o?t:null}catch(e){if(this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(T.connection_stalled),n)throw e}return null}async rpcBatchSubscribe(e){if(!e.length)return;let t=e[0].relay,r={method:(0,h.getRelayProtocolApi)(t.protocol).batchSubscribe,params:{topics:e.map(e=>e.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:r});try{await await (0,h.createExpiringPromise)(new Promise(e=>{this.relayer.request(r).catch(e=>this.logger.warn(e)).then(e)}),this.subscribeTimeout,"rpcBatchSubscribe failed, please try again")}catch{this.relayer.events.emit(T.connection_stalled)}}async rpcBatchFetchMessages(e){let t;if(!e.length)return;let r=e[0].relay,i={method:(0,h.getRelayProtocolApi)(r.protocol).batchFetchMessages,params:{topics:e.map(e=>e.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});try{t=await await (0,h.createExpiringPromise)(new Promise((e,t)=>{this.relayer.request(i).catch(e=>{this.logger.warn(e),t(e)}).then(e)}),this.subscribeTimeout,"rpcBatchFetchMessages failed, please try again")}catch{this.relayer.events.emit(T.connection_stalled)}return t}rpcUnsubscribe(e,t,r){let i={method:(0,h.getRelayProtocolApi)(r.protocol).unsubscribe,params:{topic:e,id:t}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i}),this.relayer.request(i)}onSubscribe(e,t){this.setSubscription(e,e7(ts({},t),e9({id:e}))),this.pending.delete(t.topic)}onBatchSubscribe(e){e.length&&e.forEach(e=>{this.setSubscription(e.id,ts({},e)),this.pending.delete(e.topic)})}async onUnsubscribe(e,t,r){this.events.removeAllListeners(t),this.hasSubscription(t,e)&&this.deleteSubscription(t,r),await this.relayer.messages.del(e)}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,t){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:t}),this.addSubscription(e,t)}addSubscription(e,t){this.subscriptions.set(e,ts({},t)),this.topicMap.set(t.topic,e),this.events.emit(U,t)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});let t=this.subscriptions.get(e);if(!t){let{message:t}=(0,h.getInternalError)("NO_MATCHING_KEY",`${this.name}: ${e}`);throw Error(t)}return t}deleteSubscription(e,t){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:t});let r=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(r.topic,e),this.events.emit(q,e7(ts({},r),e9({reason:t})))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit("subscription_sync")}async onRestart(){if(this.cached.length){let e=[...this.cached],t=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let r=0;r<t;r++){let t=e.splice(0,this.batchSubscribeTopicsLimit);await this.batchSubscribe(t)}}this.events.emit("subscription_resubscribed")}async restore(){try{let e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){let{message:e}=(0,h.getInternalError)("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),Error(e)}this.cached=e,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(e){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(e)}}async batchSubscribe(e){e.length&&(await this.rpcBatchSubscribe(e),this.onBatchSubscribe(await Promise.all(e.map(async e=>e7(ts({}
22,e),e9({id:await this.getSubscriptionId(e.topic)}))))))}async batchFetchMessages(e){if(!e.length)return;this.logger.trace(`Fetching batch messages for ${e.length} subscriptions`);let t=await this.rpcBatchFetchMessages(e);t&&t.messages&&(await (0,h.sleep)((0,c.toMiliseconds)(c.ONE_SECOND)),await this.relayer.handleBatchMessageEvents(t.messages))}async onConnect(){await this.restart(),this.reset()}onDisconnect(){this.onDisable()}isInitialized(){if(!this.initialized){let{message:e}=(0,h.getInternalError)("NOT_INITIALIZED",this.name);throw Error(e)}}async restartToComplete(e){this.relayer.connected||this.relayer.connecting||(this.cached.push(e),await this.relayer.transportOpen())}async getClientId(){return this.clientId||(this.clientId=await this.relayer.core.crypto.getClientId()),this.clientId}async getSubscriptionId(e){return(0,h.hashMessage)(e+await this.getClientId())}}var ta=Object.defineProperty,tl=Object.getOwnPropertySymbols,tc=Object.prototype.hasOwnProperty,tu=Object.prototype.propertyIsEnumerable,td=(e,t,r)=>t in e?ta(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,th=(e,t)=>{for(var r in t||(t={}))tc.call(t,r)&&td(e,r,t[r]);if(tl)for(var r of tl(t))tu.call(t,r)&&td(e,r,t[r]);return e},tf=(e,t,r)=>td(e,"symbol"!=typeof t?t+"":t,r);class tp extends l.IRelayer{constructor(e){super(e),tf(this,"protocol","wc"),tf(this,"version",2),tf(this,"core"),tf(this,"logger"),tf(this,"events",new i.EventEmitter),tf(this,"provider"),tf(this,"messages"),tf(this,"subscriber"),tf(this,"publisher"),tf(this,"name","relayer"),tf(this,"transportExplicitlyClosed",!1),tf(this,"initialized",!1),tf(this,"connectionAttemptInProgress",!1),tf(this,"relayUrl"),tf(this,"projectId"),tf(this,"packageName"),tf(this,"bundleId"),tf(this,"hasExperiencedNetworkDisruption",!1),tf(this,"pingTimeout"),tf(this,"heartBeatTimeout",(0,c.toMiliseconds)(c.THIRTY_SECONDS+c.FIVE_SECONDS)),tf(this,"reconnectTimeout"),tf(this,"connectPromise"),tf(this,"reconnectInProgress",!1),tf(this,"requestsInFlight",[]),tf(this,"connectTimeout",(0,c.toMiliseconds)(15*c.ONE_SECOND)),tf(this,"request",async e=>{var t,r;this.logger.debug("Publishing Request Payload");let i=e.id||(0,g.getBigIntRpcId)().toString();await this.toEstablishConnection();try{this.logger.trace({id:i,method:e.method,topic:null==(t=e.params)?void 0:t.topic},"relayer.request - publishing...");let s=`${i}:${(null==(r=e.params)?void 0:r.tag)||""}`;this.requestsInFlight.push(s);let n=await this.provider.request(e);return this.requestsInFlight=this.requestsInFlight.filter(e=>e!==s),n}catch(e){throw this.logger.debug(`Failed to Publish Request: ${i}`),e}}),tf(this,"resetPingTimeout",()=>{(0,h.isNode)()&&(clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var e,t,r,i;try{this.logger.debug({},"pingTimeout: Connection stalled, terminating..."),null==(i=null==(r=null==(t=null==(e=this.provider)?void 0:e.connection)?void 0:t.socket)?void 0:r.terminate)||i.call(r)}catch(e){this.logger.warn(e,e?.message)}},this.heartBeatTimeout))}),tf(this,"onPayloadHandler",e=>{this.onProviderPayload(e),this.resetPingTimeout()}),tf(this,"onConnectHandler",()=>{this.logger.warn({},"Relayer connected 🛜"),this.startPingTimeout(),this.events.emit(T.connect)}),tf(this,"onDisconnectHandler",()=>{this.logger.warn({},"Relayer disconnected 🛑"),this.requestsInFlight=[],this.onProviderDisconnect()}),tf(this,"onProviderErrorHandler",e=>{this.logger.fatal(`Fatal socket error: ${e.message}`),this.events.emit(T.error,e),this.logger.fatal("Fatal socket error received, closing transport"),this.transportClose()}),tf(this,"registerProviderListeners",()=>{this.provider.on(x,this.onPayloadHandler),this.provider.on(k,this.onConnectHandler),this.provider.on(P,this.onDisconnectHandler),this.provider.on(O,this.onProviderErrorHandler)}),this.core=e.core,this.logger="u">typeof e.logger&&"string"!=typeof e.logger?(0,o.generateChildLogger)(e.logger,this.name):(0,a.pino)((0,o.getDefaultLoggerOptions)({level:e.logger||"error"})),this.messages=new eH(this.logger,e.core),this.subscriber=new to(this,this.logger),this.publisher=new e5(this,this.logger),this.relayUrl=e?.relayUrl||A,this.projectId=e.projectId,(0,h.isAndroid)()?this.packageName=(0,h.getAppId)():(0,h.isIos)()&&(this.bundleId=(0,h.getAppId)()),this.provider={}}
22async init(){this.logger.trace("Initialized"),this.registerEventListeners(),await Promise.all([this.messages.init(),this.subscriber.init()]),this.initialized=!0,this.transportOpen().catch(e=>this.logger.warn(e,e?.message))}get context(){return(0,o.getLoggerContext)(this.logger)}get connected(){var e,t,r;return(null==(r=null==(t=null==(e=this.provider)?void 0:e.connection)?void 0:t.socket)?void 0:r.readyState)===1}get connecting(){var e,t,r;return(null==(r=null==(t=null==(e=this.provider)?void 0:e.connection)?void 0:t.socket)?void 0:r.readyState)===0||void 0!==this.connectPromise}async publish(e,t,r){this.isInitialized(),await this.publisher.publish(e,t,r),await this.recordMessageEvent({topic:e,message:t,publishedAt:Date.now(),transportType:C.relay},"outbound")}async subscribe(e,t){var r,i,s;this.isInitialized(),null!=t&&t.transportType&&t?.transportType!=="relay"||await this.toEstablishConnection();let n=typeof(null==(r=t?.internal)?void 0:r.throwOnFailedPublish)>"u"||(null==(i=t?.internal)?void 0:i.throwOnFailedPublish),o=(null==(s=this.subscriber.topicMap.get(e))?void 0:s[0])||"",a,l=t=>{t.topic===e&&(this.subscriber.off(U,l),a())};return await Promise.all([new Promise(e=>{a=e,this.subscriber.on(U,l)}),new Promise(async(r,i)=>{o=await this.subscriber.subscribe(e,th({internal:{throwOnFailedPublish:n}},t)).catch(e=>{n&&i(e)})||o,r()})]),o}async unsubscribe(e,t){this.isInitialized(),await this.subscriber.unsubscribe(e,t)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async transportDisconnect(){this.provider.disconnect&&(this.hasExperiencedNetworkDisruption||this.connected)?await (0,h.createExpiringPromise)(this.provider.disconnect(),2e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.onProviderDisconnect()}async transportClose(){this.transportExplicitlyClosed=!0,await this.transportDisconnect()}async transportOpen(e){if(!this.subscriber.hasAnyTopics)return void this.logger.info("Starting WS connection skipped because the client has no topics to work with.");if(this.connectPromise?(this.logger.debug({},"Waiting for existing connection attempt to resolve..."),await this.connectPromise,this.logger.debug({},"Existing connection attempt resolved")):(this.connectPromise=new Promise(async(t,r)=>{await this.connect(e).then(t).catch(r).finally(()=>{this.connectPromise=void 0})}),await this.connectPromise),!this.connected)throw Error(`Couldn't establish socket connection to the relay server: ${this.relayUrl}`)}async restartTransport(e){this.logger.debug({},"Restarting transport..."),this.connectionAttemptInProgress||(this.relayUrl=e||this.relayUrl,await this.confirmOnlineStateOrThrow(),await this.transportClose(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await (0,h.isOnline)())throw Error("No internet connection detected. Please restart your network and try again.")}async handleBatchMessageEvents(e){if(e?.length===0)return void this.logger.trace("Batch message events is empty. Ignoring...");let t=e.sort((e,t)=>e.publishedAt-t.publishedAt);for(let e of(this.logger.debug(`Batch of ${t.length} message events sorted`),t))try{await this.onMessageEvent(e)}catch(e){this.logger.warn(e,"Error while processing batch message event: "+e?.message)}this.logger.trace(`Batch of ${t.length} message events processed`)}async onLinkMessageEvent(e,t){let{topic:r}=e;if(!t.sessionExists){let e=(0,h.calcExpiry)(c.FIVE_MINUTES);await this.core.pairing.pairings.set(r,{topic:r,expiry:e,relay:{protocol:"irn"},active:!1})}this.events.emit(T.message,e),await this.recordMessageEvent(e,N)}async connect(e){await this.confirmOnlineStateOrThrow(),e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportDisconnect()),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;let t=1;for(;t<6;){try{if(this.transportExplicitlyClosed)break;this.logger.debug({},`Connecting to ${this.relayUrl}, attempt: ${t}...`),await this.createProvider(),await new Promise(async(e,t)=>{let r=()=>{t(Error("Connection interrupted while trying to connect"))};this.provider.once(P,r),await (0,h.createExpiringPromise)(new Promise((e,t)=>
22{this.provider.connect().then(e).catch(t)}),this.connectTimeout,`Socket stalled when trying to connect to ${this.relayUrl}`).catch(e=>{t(e)}).finally(()=>{this.provider.off(P,r),clearTimeout(this.reconnectTimeout)}),await new Promise(async(e,r)=>{let i=()=>{t(Error("Connection interrupted while trying to subscribe"))};this.provider.once(P,i),await this.subscriber.start().then(e).catch(r).finally(()=>{this.provider.off(P,i)})}),this.hasExperiencedNetworkDisruption=!1,e()})}catch(e){await this.subscriber.stop(),this.logger.warn({},e.message),this.hasExperiencedNetworkDisruption=!0}finally{this.connectionAttemptInProgress=!1}if(this.connected){this.logger.debug({},`Connected to ${this.relayUrl} successfully on attempt: ${t}`);break}await new Promise(e=>setTimeout(e,(0,c.toMiliseconds)(+t))),t++}}startPingTimeout(){var e,t,r,i,s;if((0,h.isNode)())try{null!=(t=null==(e=this.provider)?void 0:e.connection)&&t.socket&&(null==(s=null==(i=null==(r=this.provider)?void 0:r.connection)?void 0:i.socket)||s.on("ping",()=>{this.resetPingTimeout()})),this.resetPingTimeout()}catch(e){this.logger.warn(e,e?.message)}}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();let e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new p.JsonRpcProvider(new m.default((0,h.formatRelayRpcUrl)({sdkVersion:R,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0,bundleId:this.bundleId,packageName:this.packageName}))),this.registerProviderListeners()}async recordMessageEvent(e,t){let{topic:r,message:i}=e;await this.messages.set(r,i,t)}async shouldIgnoreMessageEvent(e){let{topic:t,message:r}=e;if(!r||0===r.length)return this.logger.warn(`Ignoring invalid/empty message: ${r}`),!0;if(!await this.subscriber.isKnownTopic(t))return this.logger.warn(`Ignoring message for unknown topic ${t}`),!0;let i=this.messages.has(t,r);return i&&this.logger.warn(`Ignoring duplicate message: ${r}`),i}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),(0,y.isJsonRpcRequest)(e)){if(!e.method.endsWith("_subscription"))return;let t=e.params,{topic:r,message:i,publishedAt:s,attestation:n}=t.data,o={topic:r,message:i,publishedAt:s,transportType:C.relay,attestation:n};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(th({type:"event",event:t.id},o)),this.events.emit(t.id,o),await this.acknowledgePayload(e),await this.onMessageEvent(o)}else(0,y.isJsonRpcResponse)(e)&&this.events.emit(T.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(await this.recordMessageEvent(e,N),this.events.emit(T.message,e))}async acknowledgePayload(e){let t=(0,g.formatJsonRpcResult)(e.id,!0);await this.provider.connection.send(t)}unregisterProviderListeners(){this.provider.off(x,this.onPayloadHandler),this.provider.off(k,this.onConnectHandler),this.provider.off(P,this.onDisconnectHandler),this.provider.off(O,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await (0,h.isOnline)();(0,h.subscribeToNetworkChange)(async t=>{e!==t&&(e=t,t?await this.transportOpen().catch(e=>this.logger.error(e,e?.message)):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))}),this.core.heartbeat.on(s.HEARTBEAT_EVENTS.pulse,async()=>{if(!this.transportExplicitlyClosed&&!this.connected&&(0,h.isAppVisible)())try{await this.confirmOnlineStateOrThrow(),await this.transportOpen()}catch(e){this.logger.warn(e,e?.message)}})}async onProviderDisconnect(){clearTimeout(this.pingTimeout),this.events.emit(T.disconnect),this.connectionAttemptInProgress=!1,!this.reconnectInProgress&&(this.reconnectInProgress=!0,await this.subscriber.stop(),this.subscriber.hasAnyTopics&&(this.transportExplicitlyClosed||(this.reconnectTimeout=setTimeout(async()=>{await this.transportOpen().catch(e=>this.logger.error(e,e?.message)),this.reconnectTimeout=void 0,this.reconnectInProgress=!1},(0,c.toMiliseconds)(.1)))))}isInitialized(){if(!this.initialized){let{message:e}=(0,h.getInternalError)("NOT_INITIALIZED",this.name);throw Error(e)}}async toEstablishConnection(){if(await this.confirmOnlineStateOrThrow(),!this.connected){if(this.connectPromise)return void await this.connectPromise;await this.connect()}}}function tg(e){return Object.getOwnPropertySymbols(e).filter(t=>Object.prototype.propertyIsEnumerable.call(e,t))}
22function ty(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}let tm="[object Arguments]",tb="[object Object]";function tv(){}function tw(e){if(!e||"object"!=typeof e)return!1;let t=Object.getPrototypeOf(e);return(null===t||t===Object.prototype||null===Object.getPrototypeOf(t))&&"[object Object]"===Object.prototype.toString.call(e)}var t_=Object.defineProperty,tS=Object.getOwnPropertySymbols,tE=Object.prototype.hasOwnProperty,tI=Object.prototype.propertyIsEnumerable,tA=(e,t,r)=>t in e?t_(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,tT=(e,t)=>{for(var r in t||(t={}))tE.call(t,r)&&tA(e,r,t[r]);if(tS)for(var r of tS(t))tI.call(t,r)&&tA(e,r,t[r]);return e},tx=(e,t,r)=>tA(e,"symbol"!=typeof t?t+"":t,r);class tk extends l.IStore{constructor(e,t,i,s=w,n){super(e,t,i,s),this.core=e,this.logger=t,this.name=i,tx(this,"map",new Map),tx(this,"version","0.3"),tx(this,"cached",[]),tx(this,"initialized",!1),tx(this,"getKey"),tx(this,"storagePrefix",w),tx(this,"recentlyDeleted",[]),tx(this,"recentlyDeletedLimit",200),tx(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(e=>{this.getKey&&null!==e&&!(0,h.isUndefined)(e)?this.map.set(this.getKey(e),e):(0,h.isProposalStruct)(e)?this.map.set(e.id,e):(0,h.isSessionStruct)(e)&&this.map.set(e.topic,e)}),this.cached=[],this.initialized=!0)}),tx(this,"set",async(e,t)=>{this.isInitialized(),this.map.has(e)?await this.update(e,t):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:e,value:t}),this.map.set(e,t),await this.persist())}),tx(this,"get",e=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:e}),this.getData(e))),tx(this,"getAll",e=>(this.isInitialized(),e?this.values.filter(t=>Object.keys(e).every(i=>{var s;return s=t[i],function e(t,i,s,n,o,a,l){let c=l(t,i,s,n,o,a);if(void 0!==c)return c;if(typeof t==typeof i)switch(typeof t){case"bigint":case"string":case"boolean":case"symbol":case"undefined":case"function":return t===i;case"number":return t===i||Object.is(t,i)}return function t(i,s,n,o){if(Object.is(i,s))return!0;let a=ty(i),l=ty(s);if(a===tm&&(a=tb),l===tm&&(l=tb),a!==l)return!1;switch(a){case"[object String]":return i.toString()===s.toString();case"[object Number]":{let e=i.valueOf(),t=s.valueOf();return e===t||Number.isNaN(e)&&Number.isNaN(t)}case"[object Boolean]":case"[object Date]":case"[object Symbol]":return Object.is(i.valueOf(),s.valueOf());case"[object RegExp]":return i.source===s.source&&i.flags===s.flags;case"[object Function]":return i===s}let c=(n=n??new Map).get(i),u=n.get(s);if(null!=c&&null!=u)return c===s;n.set(i,s),n.set(s,i);try{switch(a){case"[object Map]":if(i.size!==s.size)return!1;for(let[t,r]of i.entries())if(!s.has(t)||!e(r,s.get(t),t,i,s,n,o))return!1;return!0;case"[object Set]":{if(i.size!==s.size)return!1;let t=Array.from(i.values()),r=Array.from(s.values());for(let a=0;a<t.length;a++){let l=t[a],c=r.findIndex(t=>e(l,t,void 0,i,s,n,o));if(-1===c)return!1;r.splice(c,1)}return!0}case"[object Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":case"[object BigUint64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object BigInt64Array]":case"[object Float32Array]":case"[object Float64Array]":if("u">typeof r.Buffer&&r.Buffer.isBuffer(i)!==r.Buffer.isBuffer(s)||i.length!==s.length)return!1;for(let t=0;t<i.length;t++)if(!e(i[t],s[t],t,i,s,n,o))return!1;return!0;case"[object ArrayBuffer]":return i.byteLength===s.byteLength&&t(new Uint8Array(i),new Uint8Array(s),n,o);case"[object DataView]":return i.byteLength===s.byteLength&&i.byteOffset===s.byteOffset&&t(new Uint8Array(i),new Uint8Array(s),n,o);case"[object Error]":return i.name===s.name&&i.message===s.message;case tb:{if(!(t(i.constructor,s.constructor,n,o)||tw(i)&&tw(s)))return!1;let r=[...Object.keys(i),...tg(i)],a=[...Object.keys(s),...tg(s)];if(r.length!==a.length)return!1;for(let t=0;t<r.length;t++){let a=r[t],l=i[a];if(!Object.hasOwn(s,a))return!1;let c=s[a];if(!e(l,c,a,i,s,n,o))return!1}return!0}default:return!1}}finally{n.delete(i),n.delete(s)}}(t,i,a,l)}(s,e[i],void 0,void 0,void 0,void 0,tv)})):this.values)),tx(this,"update",async(e,t)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:e,update:t});let r=tT(tT({},this.getData(e)),t);this.map.set(e,r),await this.persist()}),tx(this,"delete",async(e,t)=>{this.isInitialized(),this.map.has(e)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",ke
22y:e,reason:t}),this.map.delete(e),this.addToRecentlyDeleted(e),await this.persist())}),this.logger=(0,o.generateChildLogger)(t,this.name),this.storagePrefix=s,this.getKey=n}get context(){return(0,o.getLoggerContext)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}addToRecentlyDeleted(e){this.recentlyDeleted.push(e),this.recentlyDeleted.length>=this.recentlyDeletedLimit&&this.recentlyDeleted.splice(0,this.recentlyDeletedLimit/2)}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){let t=this.map.get(e);if(!t){if(this.recentlyDeleted.includes(e)){let{message:t}=(0,h.getInternalError)("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(t),Error(t)}let{message:t}=(0,h.getInternalError)("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(t),Error(t)}return t}async persist(){await this.setDataStore(this.values)}async restore(){try{let e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){let{message:e}=(0,h.getInternalError)("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),Error(e)}this.cached=e,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(e){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(e)}}isInitialized(){if(!this.initialized){let{message:e}=(0,h.getInternalError)("NOT_INITIALIZED",this.name);throw Error(e)}}}var tP=Object.defineProperty,tO=(e,t,r)=>{let i;return(i="symbol"!=typeof t?t+"":t)in e?tP(e,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[i]=r};class tR{constructor(e,t){this.core=e,this.logger=t,tO(this,"name","pairing"),tO(this,"version","0.3"),tO(this,"events",new i.default),tO(this,"pairings"),tO(this,"initialized",!1),tO(this,"storagePrefix",w),tO(this,"ignoredPayloadTypes",[h.TYPE_1]),tO(this,"registeredMethods",[]),tO(this,"init",async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))}),tO(this,"register",({methods:e})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...e])]}),tO(this,"create",async e=>{this.isInitialized();let t=(0,h.generateRandomBytes32)(),r=await this.core.crypto.setSymKey(t),i=(0,h.calcExpiry)(c.FIVE_MINUTES),s={protocol:"irn"},n={topic:r,expiry:i,relay:s,active:!1,methods:e?.methods},o=(0,h.formatUri)({protocol:this.core.protocol,version:this.core.version,topic:r,symKey:t,relay:s,expiryTimestamp:i,methods:e?.methods});return this.events.emit(D.create,n),this.core.expirer.set(r,i),await this.pairings.set(r,n),await this.core.relayer.subscribe(r,{transportType:e?.transportType}),{topic:r,uri:o}}),tO(this,"pair",async e=>{let t;this.isInitialized();let r=this.core.eventClient.createEvent({properties:{topic:e?.uri,trace:[F.pairing_started]}});this.isValidPair(e,r);let{topic:i,symKey:s,relay:n,expiryTimestamp:o,methods:a}=(0,h.parseUri)(e.uri);if(r.props.properties.topic=i,r.addTrace(F.pairing_uri_validation_success),r.addTrace(F.pairing_uri_not_expired),this.pairings.keys.includes(i)){if(t=this.pairings.get(i),r.addTrace(F.existing_pairing),t.active)throw r.setError(H.active_pairing_already_exists),Error(`Pairing already exists: ${i}. Please try again with a new connection URI.`);r.addTrace(F.pairing_not_expired)}let l=o||(0,h.calcExpiry)(c.FIVE_MINUTES),u={topic:i,relay:n,expiry:l,active:!1,methods:a};this.core.expirer.set(i,l),await this.pairings.set(i,u),r.addTrace(F.store_new_pairing),e.activatePairing&&await this.activate({topic:i}),this.events.emit(D.create,u),r.addTrace(F.emit_inactive_pairing),this.core.crypto.keychain.has(i)||await this.core.crypto.setSymKey(s,i),r.addTrace(F.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{r.setError(H.no_internet_connection)}try{await this.core.relayer.subscribe(i,{relay:n})}catch(e){throw r.setError(H.subscribe_pairing_topic_failure),e}return r.addTrace(F.subscribe_pairing_topic_success),u}),tO(this,"activate",async({topic:e})=>{this.isInitialized();let t=(0,h.calcExpiry)(c.FIVE_MINUTES);this.core.expirer.set(e,t),await this.pairings.update(e,{active:!0,expiry:t})}),tO(this,"ping",async e=>{this.isInitialized(),await this.isValidPing(e),this.logger.warn("ping() is deprecated and will be removed in the next major release.");let{topic:t}=e;if(this.pairings.keys.includes(t)){let e=await this.sendRequest(t,"wc_pairingPing",{}),{done:r,resolve:i,reject:s}=(0,h.createDelayedPromise)();this.events.once((0,h.engineEvent)("pairing_ping",e),({error:e})=>{e?s(e):i()}),await r()}}),tO(this,"updateExpiry",async({topic:e,expiry:t})=>{this.isInitialized(),await this.pairings.update(e,{expiry:t})}),tO(this,"updateMetadata",async({topic:e,metadata:t})=>{this.isInitialized(),await this.pairings.update(e,{peerMetadata:t})}),tO(this,"getPairings",()=>(this.isInitialized(),this.pairings.values)),tO(this,"disconnect",async e=>{this.isInitialized(),await this.isValidDisconnect(e);let{topic:t}=e;this.pairings.keys.includes(t)&&(await this.sendRequest(t,"wc_pairingDelete",(0,h.getSdkError)("USER_DISCONNECTED")),await this.deletePairing(t))}),tO(this,"formatUriFromPairing",e=>{this.isInitialized();let{topic:t,relay:r,expiry:i,methods:s}=e,n=this.core.crypto.keychain.get(t);return(0,h.formatUri)({protocol:this.core.protocol,version:this.core.version,topic:t,symKey:n,relay:r,expiryTimestamp:i,methods:s})}),tO(this,"sendRequest",async(e,t,r)=>{let i=(0,g.formatJsonRpcRequest)(t,r),s=await this.core.crypto.encode(e,i),n=L[t].req;return this.core.history.set(e,i),this.core.relayer.publish(e,s,n),i.id}),tO(this,"sendResult",async(e,t,r)=>{let i=(0,g.formatJsonRpcResult)(e,r),s=await this.core.crypto.encode(t,i),n=L[(await this.core.history.get(t,e)).request.method].res;await this.core.relayer.publish(t,s,n),await this.core.history.resolve(i)}),tO(this,"sendError",async(e,t,r)=>{let i=(0,g.formatJsonRpcError)(e,r),s=await this.core.crypto.encode(t,i),n=(await this.core.history.get(t,e)).request.method,o=L[n]?L[n].res:L.unregistered_method.res;await this.core.relayer.publish(t,s,o),await this.core.history.resolve(i)}),tO(this,"deletePairing",async(e,t)=>{await this.core.relayer.unsubscribe(e),await Promise.all([this.pairings.delete(e,(0,h.getSdkError)("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(e),t?Promise.resolve():this.core.expirer.del(e)])}),tO(this,"cleanup",async()=>{let e=this.pairings.getAll().filter(e=>(0,h.isExpired)(e.expiry));await Promise.all(e.map(e=>this.deletePairing(e.topic)))}),tO(this,"onRelayEventRequest",async e=>{let{topic:t,payload:r}=e;switch(r.method){case"wc_pairingPing":return await this.onPairingPingRequest(t,r);case"wc_pairingDelete":return await this.onPairingDeleteRequest(t,r);default:return await this.onUnknownRpcMethodRequest(t,r)}}),tO(this,"onRelayEventResponse",async e=>{let{topic:t,payload:r}=e,i=(await this.core.history.get(t,r.id)).request.method;return"wc_pairingPing"===i?this.onPairingPingResponse(t,r):this.onUnknownRpcMethodResponse(i)}),tO(this,"onPairingPingRequest",async(e,t)=>{let{id:r}=t;try{this.isValidPing({topic:e}),await this.sendResult(r,e,!0),this.events.emit(D.ping,{id:r,topic:e})}catch(t){await this.sendError(r,e,t),this.logger.error(t)}}),tO(this,"onPairingPingResponse",(e,t)=>{let{id:r}=t;setTimeout(()=>{(0,y.isJsonRpcResult)(t)?this.events.emit((0,h.engineEvent)("pairing_ping",r),{}):(0,y.isJsonRpcError)(t)&&this.events.emit((0,h.engineEvent)("pairing_ping",r),{error:t.error})},500)}),tO(this,"onPairingDeleteRequest",async(e,t)=>{let{id:r}=t;try{this.isValidDisconnect({topic:e}),await this.deletePairing(e),this.events.emit(D.delete,{id:r,topic:e})}catch(t){await this.sendError(r,e,t),this.logger.error(t)}}),tO(this,"onUnknownRpcMethodRequest",async(e,t)=>{let{id:r,method:i}=t;try{if(this.registeredMethods.includes(i))return;let t=(0,h.getSdkError)("WC_METHOD_UNSUPPORTED",i);await this.sendError(r,e,t),this.logger.error(t)}catch(t){await this.sendError(r,e,t),this.logger.error(t)}}),tO(this,"onUnknownRpcMethodResponse",e=>{this.registeredMethods.includes(e)||this.logger.error((0,h.getSdkError)("WC_METHOD_UNSUPPORTED",e))}),tO(this,"isValidPair",(e,t)=>{var r;if(!(0,h.isValidParams)(e)){let{message:r}=(0,h.getInternalError)("MISSING_OR_INVALID",`pair() params: ${e}`);throw t.setError(H.malformed_pairing_uri),Error(r)}if(!(0,h.isValidUrl)(e.uri)){let{message:r}=(0,h.getInternalError)("MISSING_OR_INVALID",`pair() uri: ${e.uri}`);throw t.setError(H.malformed_pairing_uri),Error(r)}let i=(0,h.parseUri)(e?.uri);if(!(null!=(r=i?.relay)&&r.protocol)){let{message:e}=(0,h.getInternalError)("MISSING_OR_INVALID","pair() uri#relay-protocol");throw t.setError(H.malformed_pairing_uri),Error(e)}if(!(null!=i&&i.symKey)){let{message:e}=(0,h.getInternalError)("MISSING_OR_INVALID","pair() uri#symKey");throw t.setError(H.malformed_pairing_uri),Error(e)}if(null!=i&&i.expiryTimestamp&&(0,c.toMiliseconds)(i?.expiryTimestamp)<Date.now()){t.setError(H.pairing_expired);let{message:e}=(0,h.getInternalError)("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw Error(e)}}),tO(this,"isValidPing",async e=>{if(!(0,h.isValidParams)(e)){let{message:t}=(0,h.getInternalError)("MISSING_OR_INVALID",`ping() params: ${e}`);throw Error(t)}let{topic:t}=e;await this.isValidPairingTopic(t)}),tO(this,"isValidDisconnect",async e=>{if(!(0,h.isValidParams)(e)){let{message:t}=(0,h.getInternalError)("MISSING_OR_INVALID",`disconnect() params: ${e}`);throw Error(t)}let{topic:t}=e;await this.isValidPairingTopic(t)}),tO(this,"isValidPairingTopic",async e=>{if(!(0,h.isValidString)(e,!1)){let{message:t}=(0,h.getInternalError)("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw Error(t)}if(!this.pairings.keys.includes(e)){let{message:t}=(0,h.getInternalError)("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw Error(t)}if((0,h.isExpired)(this.pairings.get(e).expiry)){await this.deletePairing(e);let{message:t}=(0,h.getInternalError)("EXPIRED",`pairing topic: ${e}`);throw Error(t)}}),this.core=e,this.logger=(0,o.generateChildLogger)(t,this.name),this.pairings=new tk(this.core,this.logger,this.name,this.storagePrefix)}
22get context(){return(0,o.getLoggerContext)(this.logger)}isInitialized(){if(!this.initialized){let{message:e}=(0,h.getInternalError)("NOT_INITIALIZED",this.name);throw Error(e)}}registerRelayerEvents(){this.core.relayer.on(T.message,async e=>{let{topic:t,message:r,transportType:i}=e;if(this.pairings.keys.includes(t)&&i!==C.link_mode&&!this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(r)))try{let e=await this.core.crypto.decode(t,r);(0,y.isJsonRpcRequest)(e)?(this.core.history.set(t,e),await this.onRelayEventRequest({topic:t,payload:e})):(0,y.isJsonRpcResponse)(e)&&(await this.core.history.resolve(e),await this.onRelayEventResponse({topic:t,payload:e}),this.core.history.delete(t,e.id)),await this.core.relayer.messages.ack(t,r)}catch(e){this.logger.error(e)}})}registerExpirerEvents(){this.core.expirer.on(z.expired,async e=>{let{topic:t}=(0,h.parseExpirerTarget)(e.target);t&&this.pairings.keys.includes(t)&&(await this.deletePairing(t,!0),this.events.emit(D.expire,{topic:t}))})}}var tC=Object.defineProperty,tN=(e,t,r)=>{let i;return(i="symbol"!=typeof t?t+"":t)in e?tC(e,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[i]=r};class tB extends l.IJsonRpcHistory{constructor(e,t){super(e,t),this.core=e,this.logger=t,tN(this,"records",new Map),tN(this,"events",new i.EventEmitter),tN(this,"name","history"),tN(this,"version","0.3"),tN(this,"cached",[]),tN(this,"initialized",!1),tN(this,"storagePrefix",w),tN(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(e=>this.records.set(e.id,e)),this.cached=[],this.registerEventListeners(),this.initialized=!0)}),tN(this,"set",(e,t,r)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:e,request:t,chainId:r}),this.records.has(t.id))return;let i={id:t.id,topic:e,request:{method:t.method,params:t.params||null},chainId:r,expiry:(0,h.calcExpiry)(c.THIRTY_DAYS)};this.records.set(i.id,i),this.persist(),this.events.emit(M,i)}),tN(this,"resolve",async e=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:e}),!this.records.has(e.id))return;let t=await this.getRecord(e.id);typeof t.response>"u"&&(t.response=(0,y.isJsonRpcError)(e)?{error:e.error}:{result:e.result},this.records.set(t.id,t),this.persist(),this.events.emit(K,t))}),tN(this,"get",async(e,t)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:e,id:t}),await this.getRecord(t))),tN(this,"delete",(e,t)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:t}),this.values.forEach(r=>{r.topic===e&&("u">typeof t&&r.id!==t||(this.records.delete(r.id),this.events.emit(W,r)))}),this.persist()}),tN(this,"exists",async(e,t)=>(this.isInitialized(),!!this.records.has(t)&&(await this.getRecord(t)).topic===e)),tN(this,"on",(e,t)=>{this.events.on(e,t)}),tN(this,"once",(e,t)=>{this.events.once(e,t)}),tN(this,"off",(e,t)=>{this.events.off(e,t)}),tN(this,"removeListener",(e,t)=>{this.events.removeListener(e,t)}),this.logger=(0,o.generateChildLogger)(t,this.name)}get context(){return(0,o.getLoggerContext)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){let e=[];return this.values.forEach(t=>{if("u">typeof t.response)return;let r={topic:t.topic,request:(0,g.formatJsonRpcRequest)(t.request.method,t.request.params,t.id),chainId:t.chainId};return e.push(r)}),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();let t=this.records.get(e);if(!t){let{message:t}=(0,h.getInternalError)("NO_MATCHING_KEY",`${this.name}: ${e}`);throw Error(t)}return t}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit("history_sync")}
22async restore(){try{let e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){let{message:e}=(0,h.getInternalError)("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),Error(e)}this.cached=e,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}}registerEventListeners(){this.events.on(M,e=>{this.logger.info(`Emitting ${M}`),this.logger.debug({type:"event",event:M,record:e})}),this.events.on(K,e=>{this.logger.info(`Emitting ${K}`),this.logger.debug({type:"event",event:K,record:e})}),this.events.on(W,e=>{this.logger.info(`Emitting ${W}`),this.logger.debug({type:"event",event:W,record:e})}),this.core.heartbeat.on(s.HEARTBEAT_EVENTS.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(t=>{(0,c.toMiliseconds)(t.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${t.id}`),this.records.delete(t.id),this.events.emit(W,t,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){let{message:e}=(0,h.getInternalError)("NOT_INITIALIZED",this.name);throw Error(e)}}}var tU=Object.defineProperty,tq=(e,t,r)=>{let i;return(i="symbol"!=typeof t?t+"":t)in e?tU(e,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[i]=r};class tL extends l.IExpirer{constructor(e,t){super(e,t),this.core=e,this.logger=t,tq(this,"expirations",new Map),tq(this,"events",new i.EventEmitter),tq(this,"name","expirer"),tq(this,"version","0.3"),tq(this,"cached",[]),tq(this,"initialized",!1),tq(this,"storagePrefix",w),tq(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(e=>this.expirations.set(e.target,e)),this.cached=[],this.registerEventListeners(),this.initialized=!0)}),tq(this,"has",e=>{try{let t=this.formatTarget(e);return"u">typeof this.getExpiration(t)}catch{return!1}}),tq(this,"set",(e,t)=>{this.isInitialized();let r=this.formatTarget(e),i={target:r,expiry:t};this.expirations.set(r,i),this.checkExpiry(r,i),this.events.emit(z.created,{target:r,expiration:i})}),tq(this,"get",e=>{this.isInitialized();let t=this.formatTarget(e);return this.getExpiration(t)}),tq(this,"del",e=>{if(this.isInitialized(),this.has(e)){let t=this.formatTarget(e),r=this.getExpiration(t);this.expirations.delete(t),this.events.emit(z.deleted,{target:t,expiration:r})}}),tq(this,"on",(e,t)=>{this.events.on(e,t)}),tq(this,"once",(e,t)=>{this.events.once(e,t)}),tq(this,"off",(e,t)=>{this.events.off(e,t)}),tq(this,"removeListener",(e,t)=>{this.events.removeListener(e,t)}),this.logger=(0,o.generateChildLogger)(t,this.name)}get context(){return(0,o.getLoggerContext)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if("string"==typeof e)return(0,h.formatTopicTarget)(e);if("number"==typeof e)return(0,h.formatIdTarget)(e);let{message:t}=(0,h.getInternalError)("UNKNOWN_TYPE",`Target type: ${typeof e}`);throw Error(t)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(z.sync)}async restore(){try{let e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){let{message:e}=(0,h.getInternalError)("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),Error(e)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e)}}getExpiration(e){let t=this.expirations.get(e);if(!t){let{message:t}=(0,h.getInternalError)("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(t),Error(t)}return t}checkExpiry(e,t){let{expiry:r}=t;(0,c.toMiliseconds)(r)-Date.now()<=0&&this.expire(e,t)}expire(e,t){this.expirations.delete(e),this.events.emit(z.expired,{target:e,expiration:t})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,t)=>this.checkExpiry(t,e))}registerEventListeners(){this.core.heartbeat.on(s.HEARTBEAT_EVENTS.pulse,()=>this.checkExpirations()),this.events.on(z.created,e=>{let t=z.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(z.expired,e=>{let t=z.expired;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(z.deleted,e=>{let t=z.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()})}isInitialized(){if(!this.initialized){let{message:e}=(0,h.getInternalError)("NOT_INITIALIZED",this.name);throw Error(e)}}}var tD=Object.defineProperty,tM=(e,t,r)=>{let i;return(i="symbol"!=typeof t?t+"":t)in e?tD(e,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[i]=r};class tK extends l.IVerify{constructor(e,t,r){super(e,t,r),this.core=e,this.logger=t,this.store=r,tM(this,"name","verify-api"),tM(this,"abortController"),tM(this,"isDevEnv"),tM(this,"verifyUrlV3",V),tM(this,"storagePrefix",w),tM(this,"version",2),tM(this,"publicKey"),tM(this,"fetchPromise"),tM(this,"init",async()=>{var e;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&(0,c.toMiliseconds)(null==(e=this.publicKey)?void 0:e.expiresAt)<Date.now()&&(this.logger.debug("verify v2 public key expired"),await this.removePublicKey()))}),tM(this,"register",async e=>{if(!(0,h.isBrowser)()||this.isDevEnv)return;let t=window.location.origin,{id:r,decryptedId:i}=e,s=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${t}&id=${r}&decryptedId=${i}`;try{let e=(0,b.getDocument)(),t=this.startAbortTimer(5*c.ONE_SECOND),i=await new Promise((i,n)=>{let o=()=>{window.removeEventListener("message",l),e.body.removeChild(a),n("attestation aborted")};this.abortController.signal.addEventListener("abort",o);let a=e.createElement("iframe");a.src=s,a.style.display="none",a.addEventListener("error",o,{signal:this.abortController.signal});let l=s=>{if(s.data&&"string"==typeof s.data)try{let n=JSON.parse(s.data);if("verify_attestation"===n.type){if((0,d.decodeJWT)(n.attestation).payload.id!==r)return;clearInterval(t),e.body.removeChild(a),this.abortController.signal.removeEventListener("abort",o),window.removeEventListener("message",l),i(null===n.attestation?"":n.attestation)}}catch(e){this.logger.warn(e)}};e.body.appendChild(a),window.addEventListener("message",l,{signal:this.abortController.signal})});return this.logger.debug("jwt attestation",i),i}catch(e){this.logger.warn(e)}return""}),tM(this,"resolve",async e=>{if(this.isDevEnv)return"";let{attestationId:t,hash:r,encryptedId:i}=e;if(""===t)return void this.logger.debug("resolve: attestationId is empty, skipping");if(t){if((0,d.decodeJWT)(t).payload.id!==i)return;let e=await this.isValidJwtAttestation(t);
22if(e)return e.isVerified?e:void this.logger.warn("resolve: jwt attestation: origin url not verified")}if(!r)return;let s=this.getVerifyUrl(e?.verifyUrl);return this.fetchAttestation(r,s)}),tM(this,"fetchAttestation",async(e,t)=>{this.logger.debug(`resolving attestation: ${e} from url: ${t}`);let r=this.startAbortTimer(5*c.ONE_SECOND),i=await fetch(`${t}/attestation/${e}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(r),200===i.status?await i.json():void 0}),tM(this,"getVerifyUrl",e=>{let t=e||j;return $.includes(t)||(this.logger.info(`verify url: ${t}, not included in trusted list, assigning default: ${j}`),t=j),t}),tM(this,"fetchPublicKey",async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);let e=this.startAbortTimer(c.FIVE_SECONDS),t=await fetch(`${this.verifyUrlV3}/public-key`,{signal:this.abortController.signal});return clearTimeout(e),await t.json()}catch(e){this.logger.warn(e)}}),tM(this,"persistPublicKey",async e=>{this.logger.debug("persisting public key to local storage",e),await this.store.setItem(this.storeKey,e),this.publicKey=e}),tM(this,"removePublicKey",async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0}),tM(this,"isValidJwtAttestation",async e=>{let t=await this.getPublicKey();try{if(t)return this.validateAttestation(e,t)}catch(e){this.logger.error(e),this.logger.warn("error validating attestation")}let r=await this.fetchAndPersistPublicKey();try{if(r)return this.validateAttestation(e,r)}catch(e){this.logger.error(e),this.logger.warn("error validating attestation")}}),tM(this,"getPublicKey",async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey()),tM(this,"fetchAndPersistPublicKey",async()=>{if(this.fetchPromise)return await this.fetchPromise,this.publicKey;this.fetchPromise=new Promise(async e=>{let t=await this.fetchPublicKey();t&&(await this.persistPublicKey(t),e(t))});let e=await this.fetchPromise;return this.fetchPromise=void 0,e}),tM(this,"validateAttestation",(e,t)=>{let r=(0,h.verifyP256Jwt)(e,t.publicKey),i={hasExpired:(0,c.toMiliseconds)(r.exp)<Date.now(),payload:r};if(i.hasExpired)throw this.logger.warn("resolve: jwt attestation expired"),Error("JWT attestation expired");return{origin:i.payload.origin,isScam:i.payload.isScam,isVerified:i.payload.isVerified}}),this.logger=(0,o.generateChildLogger)(t,this.name),this.abortController=new AbortController,this.isDevEnv=(0,h.isTestRun)(),this.init()}get storeKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//verify:public:key"}get context(){return(0,o.getLoggerContext)(this.logger)}startAbortTimer(e){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),(0,c.toMiliseconds)(e))}}var tW=Object.defineProperty,tz=(e,t,r)=>{let i;return(i="symbol"!=typeof t?t+"":t)in e?tW(e,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[i]=r};class tj extends l.IEchoClient{constructor(e,t){super(e,t),this.projectId=e,this.logger=t,tz(this,"context","echo"),tz(this,"registerDeviceToken",async e=>{let{clientId:t,token:r,notificationType:i,enableEncrypted:s=!1}=e,n=`https://echo.walletconnect.com/${this.projectId}/clients`;await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:t,type:i,token:r,always_raw:s})})}),this.logger=(0,o.generateChildLogger)(t,this.context)}}var tV=Object.defineProperty,t$=Object.getOwnPropertySymbols,tF=Object.prototype.hasOwnProperty,tH=Object.prototype.propertyIsEnumerable,tG=(e,t,r)=>t in e?tV(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,tJ=(e,t)=>{for(var r in t||(t={}))tF.call(t,r)&&tG(e,r,t[r]);if(t$)for(var r of t$(t))tH.call(t,r)&&tG(e,r,t[r]);return e},tY=(e,t,r)=>tG(e,"symbol"!=typeof t?t+"":t,r);class tZ extends l.IEventClient{constructor(e,t,r=!0){super(e,t,r),this.core=e,this.logger=t,tY(this,"context","event-client"),tY(this,"storagePrefix",w),tY(this,"storageVersion",.1),tY(this,"events",new Map),tY(this,"shouldPersist",!1),tY(this,"init",async()=>
22{if(!(0,h.isTestRun)())try{let e={eventId:(0,h.uuidv4)(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:(0,h.formatUA)(this.core.relayer.protocol,this.core.relayer.version,R)}}};await this.sendEvent([e])}catch(e){this.logger.warn(e)}}),tY(this,"createEvent",e=>{let{event:t="ERROR",type:r="",properties:{topic:i,trace:s}}=e,n=(0,h.uuidv4)(),o=this.core.projectId||"",a=tJ({eventId:n,timestamp:Date.now(),props:{event:t,type:r,properties:{topic:i,trace:s}},bundleId:o,domain:this.getAppDomain()},this.setMethods(n));return this.telemetryEnabled&&(this.events.set(n,a),this.shouldPersist=!0),a}),tY(this,"getEvent",e=>{let{eventId:t,topic:r}=e;if(t)return this.events.get(t);let i=Array.from(this.events.values()).find(e=>e.props.properties.topic===r);if(i)return tJ(tJ({},i),this.setMethods(i.eventId))}),tY(this,"deleteEvent",e=>{let{eventId:t}=e;this.events.delete(t),this.shouldPersist=!0}),tY(this,"setEventListeners",()=>{this.core.heartbeat.on(s.HEARTBEAT_EVENTS.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(e=>{(0,c.fromMiliseconds)(Date.now())-(0,c.fromMiliseconds)(e.timestamp)>86400&&(this.events.delete(e.eventId),this.shouldPersist=!0)})})}),tY(this,"setMethods",e=>({addTrace:t=>this.addTrace(e,t),setError:t=>this.setError(e,t)})),tY(this,"addTrace",(e,t)=>{let r=this.events.get(e);r&&(r.props.properties.trace.push(t),this.events.set(e,r),this.shouldPersist=!0)}),tY(this,"setError",(e,t)=>{let r=this.events.get(e);r&&(r.props.type=t,r.timestamp=Date.now(),this.events.set(e,r),this.shouldPersist=!0)}),tY(this,"persist",async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1}),tY(this,"restore",async()=>{try{let e=await this.core.storage.getItem(this.storageKey)||[];if(!e.length)return;e.forEach(e=>{this.events.set(e.eventId,tJ(tJ({},e),this.setMethods(e.eventId)))})}catch(e){this.logger.warn(e)}}),tY(this,"submit",async()=>{if(!this.telemetryEnabled||0===this.events.size)return;let e=[];for(let[t,r]of this.events)r.props.type&&e.push(r);if(0!==e.length)try{if((await this.sendEvent(e)).ok)for(let t of e)this.events.delete(t.eventId),this.shouldPersist=!0}catch(e){this.logger.warn(e)}}),tY(this,"sendEvent",async e=>{let t=this.getAppDomain()?"":"&sp=desktop";return await fetch(`https://pulse.walletconnect.org/batch?projectId=${this.core.projectId}&st=events_sdk&sv=js-${R}${t}`,{method:"POST",body:JSON.stringify(e)})}),tY(this,"getAppDomain",()=>(0,h.getAppMetadata)().url),this.logger=(0,o.generateChildLogger)(t,this.context),this.telemetryEnabled=r,r?this.restore().then(async()=>{await this.submit(),this.setEventListeners()}):this.persist()}get storageKey(){return this.storagePrefix+this.storageVersion+this.core.customStoragePrefix+"//"+this.context}}var tX=Object.defineProperty,tQ=Object.getOwnPropertySymbols,t0=Object.prototype.hasOwnProperty,t1=Object.prototype.propertyIsEnumerable,t2=(e,t,r)=>t in e?tX(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,t5=(e,t)=>{for(var r in t||(t={}))t0.call(t,r)&&t2(e,r,t[r]);if(tQ)for(var r of tQ(t))t1.call(t,r)&&t2(e,r,t[r]);return e},t6=(e,t,r)=>t2(e,"symbol"!=typeof t?t+"":t,r);class t3 extends l.ICore{constructor(e){var t;super(e),t6(this,"protocol","wc"),t6(this,"version",2),t6(this,"name",v),t6(this,"relayUrl"),t6(this,"projectId"),t6(this,"customStoragePrefix"),t6(this,"events",new i.EventEmitter),t6(this,"logger"),t6(this,"heartbeat"),t6(this,"relayer"),t6(this,"crypto"),t6(this,"storage"),t6(this,"history"),t6(this,"expirer"),t6(this,"pairing"),t6(this,"verify"),t6(this,"echoClient"),t6(this,"linkModeSupportedApps"),t6(this,"eventClient"),t6(this,"initialized",!1),t6(this,"logChunkController"),t6(this,"on",(e,t)=>this.events.on(e,t)),t6(this,"once",(e,t)=>this.events.once(e,t)),t6(this,"off",(e,t)=>this.events.off(e,t)),t6(this,"removeListener",(e,t)=>this.events.removeListener(e,t)),t6(this,"dispatchEnvelope",({topic:e,message:t,sessionExists:r})=>{if(!e||!t)return;let i={topic:e,message:t,publishedAt:Date.now(),transportType:C.link_mode};this.relayer.onLinkMessageEvent(i,{sessionExists:r})});const r=this.getGlobalCore(e?.customStoragePrefix);if(r)try{return this.customStoragePrefix=r.customStoragePrefix,this.logger=r.logger,this.heartbeat=r.heartbeat,this.crypto=r.crypto,this.history=r.history,this.expirer=r.expirer,this.storage=r.storage,this.relayer=r.relayer,this.pairing=r.pairing,this.verify=r.verify,this.echoClient=r.echoClient,this.linkModeSupportedApps=r.linkModeSupportedApps,this.eventClient=r.eventClient,this.initialized=r.initialized,this.logChunkController=r.logChunkController,r}catch(e){console.warn("Failed to copy global core",e)}this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||A,this.customStoragePrefix=null!=e&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";const a=(0,o.getDefaultLoggerOptions)({level:"string"==typeof e?.logger&&e.logger?e.logger:"error",name:v}),{logger:l,chunkLoggerController:c}=(0,o.generatePlatformLogger)({opts:a,maxSizeInBytes:e?.maxLogBlobSizeInBytes,loggerOverride:e?.logger});this.logChunkController=c,null!=(t=this.logChunkController)&&t.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var e,t;null!=(e=this.logChunkController)&&e.downloadLogsBlobInBrowser&&(null==(t=this.logChunkController)||t.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=(0,o.generateChildLogger)(l,this.name),this.heartbeat=new s.HeartBeat,this.crypto=new eD(this,this.logger,e?.keychain),this.history=new tB(this,this.logger),this.expirer=new tL(this,this.logger),this.storage=null!=e&&e.storage?e.storage:new n.default(t5(t5({},_),e?.storageOptions)),this.relayer=new tp({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new tR(this,this.logger),this.verify=new tK(this,this.logger,this.storage),this.echoClient=new tj(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new tZ(this,this.logger,e?.telemetryEnabled),this.setGlobalCore(this)}static async init(e){let t=new t3(e);await t.initialize();let r=await t.crypto.getClientId();return await t.storage.setItem("WALLETCONNECT_CLIENT_ID",r),t}
22get context(){return(0,o.getLoggerContext)(this.logger)}async start(){this.initialized||await this.initialize()}async getLogsBlob(){var e;return null==(e=this.logChunkController)?void 0:e.logsToBlob({clientId:await this.crypto.getClientId()})}async addLinkModeSupportedApp(e){this.linkModeSupportedApps.includes(e)||(this.linkModeSupportedApps.push(e),await this.storage.setItem(B,this.linkModeSupportedApps))}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.linkModeSupportedApps=await this.storage.getItem(B)||[],this.initialized=!0,this.logger.info("Core Initialization Success")}catch(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}getGlobalCore(e=""){try{if(this.isGlobalCoreDisabled())return;let t=`_walletConnectCore_${e}`,r=`${t}_count`;return globalThis[r]=(globalThis[r]||0)+1,globalThis[r]>1&&console.warn(`WalletConnect Core is already initialized. This is probably a mistake and can lead to unexpected behavior. Init() was called ${globalThis[r]} times.`),globalThis[t]}catch(e){console.warn("Failed to get global WalletConnect core",e);return}}setGlobalCore(e){var t;try{if(this.isGlobalCoreDisabled())return;let r=`_walletConnectCore_${(null==(t=e.opts)?void 0:t.customStoragePrefix)||""}`;globalThis[r]=e}catch(e){console.warn("Failed to set global WalletConnect core",e)}}isGlobalCoreDisabled(){try{return"u">typeof t.default&&"true"===t.default.env.DISABLE_GLOBAL_CORE}catch{return!0}}}e.s(["Core",0,t3,"EVENT_CLIENT_AUTHENTICATE_ERRORS",0,{no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",missing_session_authenticate_request:"missing_session_authenticate_request",session_authenticate_request_expired:"session_authenticate_request_expired",chains_caip2_compliant_failure:"chains_caip2_compliant_failure",chains_evm_compliant_failure:"chains_evm_compliant_failure",invalid_cacao:"invalid_cacao",subscribe_authenticated_session_topic_failure:"subscribe_authenticated_session_topic_failure",authenticated_session_approve_publish_failure:"authenticated_session_approve_publish_failure",authenticated_session_pending_request_not_found:"authenticated_session_pending_request_not_found"},"EVENT_CLIENT_AUTHENTICATE_TRACES",0,{authenticated_session_approve_started:"authenticated_session_approve_started",authenticated_session_not_expired:"authenticated_session_not_expired",chains_caip2_compliant:"chains_caip2_compliant",chains_evm_compliant:"chains_evm_compliant",create_authenticated_session_topic:"create_authenticated_session_topic",cacaos_verified:"cacaos_verified",store_authenticated_session:"store_authenticated_session",subscribing_authenticated_session_topic:"subscribing_authenticated_session_topic",subscribe_authenticated_session_topic_success:"subscribe_authenticated_session_topic_success",publishing_authenticated_session_approve:"publishing_authenticated_session_approve",authenticated_session_approve_publish_success:"authenticated_session_approve_publish_success"},"EVENT_CLIENT_PAIRING_ERRORS",0,H,"EVENT_CLIENT_PAIRING_TRACES",0,F,"EVENT_CLIENT_SESSION_ERRORS",0,{no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",proposal_expired:"proposal_expired",subscribe_session_topic_failure:"subscribe_session_topic_failure",session_approve_publish_failure:"session_approve_publish_failure",session_settle_publish_failure:"session_settle_publish_failure",session_approve_namespace_validation_failure:"session_approve_namespace_validation_failure",proposal_not_found:"proposal_not_found"},"EVENT_CLIENT_SESSION_TRACES",0,{session_approve_started:"session_approve_started",proposal_not_expired:"proposal_not_expired",session_namespaces_validation_success:"session_namespaces_validation_success",create_session_topic:"create_session_topic",subscribing_session_topic:"subscribing_session_topic",subscribe_session_topic_success:"subscribe_session_topic_success",publishing_session_approve:"publishing_session_approve",session_approve_publish_success:"session_approve_publish_success",store_session:"store_session",publishing_session_settle:"publishing_session_settle",session_settle_publish_success:"session_settle_publish_success"},"EXPIRER_EVENTS",0,z,"PAIRING_EVENTS",0,D,"RELAYER_DEFAULT_PROTOCOL",0,"irn","RELAYER_EVENTS",0,T,"Store",0,tk,"TRANSPORT_TYPES",0,C,"VERIFY_SERVER",0,j])},381154,e=>{"use strict";var t=e.i(81775),r=e.i(219298),i=Object.defineProperty;t.IEvents;t.IEvents,t.IEvents,t.IEvents,t.IEvents,t.IEvents;var s=Object.defineProperty,n=(e,t,r)=>{let i;return(i="symbol"!=typeof t?t+"":t)in e?s(e,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[i]=r};r.default,r.EventEmitter,e.s(["IEngine",0,class{constructor(e){this.client=e}},"ISignClient",0,class{constructor(e){this.opts=e,n(this,"protocol","wc"),n(this,"version",2)}}])},484130,e=>{"use strict";var t=e.i(274283),r=e.i(278662),i=e.i(241370),s=e.i(381154),n=e.i(741483),o=e.i(219298),a=e.i(648512);e.i(424047);var l=e.i(850967),c=e.i(329193);let u="client",d=`wc@2:${u}:`,h="WALLETCONNECT_DEEPLINK_CHOICE",f=(a.THIRTY_DAYS,"Proposal expired"),p=a.SEVEN_DAYS,g={wc_sessionPropose:{req:{ttl:a.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:a.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:a.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:a.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:a.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:a.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:a.ONE_DAY,prompt:!1,tag:1104},res:{ttl:a.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:a.ONE_DAY,prompt:!1,tag:1106},res:{ttl:a.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:a.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:a.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:a.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:a.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:a.ONE_DAY,prompt:!1,tag:1112},res:{ttl:a.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:a.ONE_DAY,prompt:!1,tag:1114},res:{ttl:a.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:a.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:a.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:a.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:a.FIVE_MINUTES,prompt:!1,tag:1119}}},y={min:a.FIVE_MINUTES,max:a.SEVEN_DAYS},m="IDLE",b="ACTIVE",v={eth_sendTransaction:{key:""},eth_sendRawTransaction:{key:""},wallet_sendCalls:{key:""},solana_signTransaction:{key:"signature"},solana_signAllTransactions:{key:"transactions"},solana_signAndSendTransaction:{key:"signature"},sui_signAndExecuteTransaction:{key:"digest"},sui_signTransaction:{key:""},hedera_signAndExecuteTransaction:{key:"transactionId"},hedera_executeTransaction:{key:"transactionId"},near_signTransaction:{key:""},near_signTransactions:{key:""},tron_signTransaction:{key:"txID"},xrpl_signTransaction:{key:""},xrpl_signTransactionFor:{key:""},algo_signTxn:{key:""},sendTransfer:{key:"txid"},stacks_stxTransfer:{key:"txId"},polkadot_signTransaction:{key:""}
22,cosmos_signDirect:{key:""}},w=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],_="[email protected]:auth:",S=`${_}:PUB_KEY`;var E=Object.defineProperty,I=Object.defineProperties,A=Object.getOwnPropertyDescriptors,T=Object.getOwnPropertySymbols,x=Object.prototype.hasOwnProperty,k=Object.prototype.propertyIsEnumerable,P=(e,t,r)=>t in e?E(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,O=(e,t)=>{for(var r in t||(t={}))x.call(t,r)&&P(e,r,t[r]);if(T)for(var r of T(t))k.call(t,r)&&P(e,r,t[r]);return e},R=(e,t,r)=>P(e,"symbol"!=typeof t?t+"":t,r);class C extends s.IEngine{constructor(r){super(r),R(this,"name","engine"),R(this,"events",new o.default),R(this,"initialized",!1),R(this,"requestQueue",{state:m,queue:[]}),R(this,"sessionRequestQueue",{state:m,queue:[]}),R(this,"emittedSessionRequests",new n.LimitedSet({limit:500})),R(this,"requestQueueDelay",a.ONE_SECOND),R(this,"expectedPairingMethodMap",new Map),R(this,"recentlyDeletedMap",new Map),R(this,"recentlyDeletedLimit",200),R(this,"relayMessageCache",[]),R(this,"pendingSessions",new Map),R(this,"init",async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),await this.registerLinkModeListeners(),this.client.core.pairing.register({methods:Object.keys(g)}),this.initialized=!0,setTimeout(async()=>{await this.processPendingMessageEvents(),this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},(0,a.toMiliseconds)(this.requestQueueDelay)))}),R(this,"connect",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();let r=I(O({},e),A({requiredNamespaces:e.requiredNamespaces||{},optionalNamespaces:e.optionalNamespaces||{}}));await this.isValidConnect(r),r.optionalNamespaces=(0,n.mergeRequiredAndOptionalNamespaces)(r.requiredNamespaces,r.optionalNamespaces),r.requiredNamespaces={};let{pairingTopic:i,requiredNamespaces:s,optionalNamespaces:o,sessionProperties:l,scopedProperties:u,relays:d}=r,h=i,p,y=!1;try{if(h){let e=this.client.core.pairing.pairings.get(h);this.client.logger.warn("connect() with existing pairing topic is deprecated and will be removed in the next major release."),y=e.active}}catch(e){throw this.client.logger.error(`connect() -> pairing.get(${h}) failed`),e}if(!h||!y){let{topic:e,uri:t}=await this.client.core.pairing.create();h=e,p=t}if(!h){let{message:e}=(0,n.getInternalError)("NO_MATCHING_KEY",`connect() pairing topic: ${h}`);throw Error(e)}let m=await this.client.core.crypto.generateKeyPair(),b=g.wc_sessionPropose.req.ttl||a.FIVE_MINUTES,v=(0,n.calcExpiry)(b),w=I(O(O({requiredNamespaces:s,optionalNamespaces:o,relays:d??[{protocol:t.RELAYER_DEFAULT_PROTOCOL}],proposer:{publicKey:m,metadata:this.client.metadata},expiryTimestamp:v,pairingTopic:h},l&&{sessionProperties:l}),u&&{scopedProperties:u}),A({id:(0,c.payloadId)()})),_=(0,n.engineEvent)("session_connect",w.id),{reject:S,resolve:E,done:T}=(0,n.createDelayedPromise)(b,f),x=({id:e})=>{e===w.id&&(this.client.events.off("proposal_expire",x),this.pendingSessions.delete(w.id),this.events.emit(_,{error:{message:f,code:0}}))};return this.client.events.on("proposal_expire",x),this.events.once(_,({error:e,session:t})=>{this.client.events.off("proposal_expire",x),e?S(e):t&&E(t)}),await this.sendRequest({topic:h,method:"wc_sessionPropose",params:w,throwOnFailedPublish:!0,clientRpcId:w.id}),await this.setProposal(w.id,w),{uri:p,approval:T}}),R(this,"pair",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{return await this.client.core.pairing.pair(e)}catch(e){throw this.client.logger.error("pair() failed"),e}}),R(this,"approve",async e=>{var r,i,s;let o=this.client.core.eventClient.createEvent({properties:{topic:null==(r=e?.id)?void 0:r.toString(),trace:[t.EVENT_CLIENT_SESSION_TRACES.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(e){throw o.setError(t.EVENT_CLIENT_SESSION_ERRORS.no_internet_connection),e}try{await this.isValidProposalId(e?.id)}catch(r){throw this.client.logger.error(`approve() -> proposal.get(${e?.id}) failed`),o.setError(t.EVENT_CLIENT_SESSION_ERRORS.proposal_not_found),r}try{await this.isValidApprove(e)}catch(e){throw this.client.logger.error("approve() -> isValidApprove() failed"),o.setError(t.EVENT_CLIENT_SESSION_ERRORS.session_approve_namespace_validation_failure),e}let{id:a,relayProtocol:l,namespaces:c,sessionProperties:u,scopedProperties:d,sessionConfig:h}=e,f=this.client.proposal.get(a);this.client.core.eventClient.deleteEvent({eventId:o.eventId});let{pairingTopic:g,proposer:y,requiredNamespaces:m,optionalNamespaces:b}=f,v=null==(i=this.client.core.eventClient)?void 0:i.getEvent({topic:g});v||(v=null==(s=this.client.core.eventClient)?void 0:s.createEvent({type:t.EVENT_CLIENT_SESSION_TRACES.session_approve_started,properties:{topic:g,trace:[t.EVENT_CLIENT_SESSION_TRACES.session_approve_started,t.EVENT_CLIENT_SESSION_TRACES.session_namespaces_validation_success]}}));let w=await this.client.core.crypto.generateKeyPair(),_=y.publicKey,S=await this.client.core.crypto.generateSharedKey(w,_),E=O(O(O({relay:{protocol:l??"irn"},namespaces:c,controller:{publicKey:w,metadata:this.client.metadata},expiry:(0,n.calcExpiry)(p)},u&&{sessionProperties:u}),d&&{scopedProperties:d}),h&&{sessionConfig:h}),T=t.TRANSPORT_TYPES.relay;v.addTrace(t.EVENT_CLIENT_SESSION_TRACES.subscribing_session_topic);try{await this.client.core.relayer.subscribe(S,{transportType:T})}catch(e){throw v.setError(t.EVENT_CLIENT_SESSION_ERRORS.subscribe_session_topic_failure),e}v.addTrace(t.EVENT_CLIENT_SESSION_TRACES.subscribe_session_topic_success);let x=I(O({},E),A({topic:S,requiredNamespaces:m,optionalNamespaces:b,pairingTopic:g,acknowledged:!1,self:E.controller,peer:{publicKey:y.publicKey,metadata:y.metadata},controller:w,transportType:t.TRANSPORT_TYPES.relay}));await this.client.session.set(S,x),v.addTrace(t.EVENT_CLIENT_SESSION_TRACES.store_session);try{v.addTrace(t.EVENT_CLIENT_SESSION_TRACES.publishing_session_settle),await this.sendRequest({topic:S,method:"wc_sessionSettle",params:E,throwOnFailedPublish:!0}).catch(e=>{throw v?.setError(t.EVENT_CLIENT_SESSION_ERRORS.session_settle_publish_failure),e}),v.addTrace(t.EVENT_CLIENT_SESSION_TRACES.session_settle_publish_success),v.addTrace(t.EVENT_CLIENT_SESSION_TRACES.publishing_session_approve),await this.sendResult({id:a,topic:g,result:{relay:{protocol:l??"irn"},responderPublicKey:w},throwOnFailedPublish:!0}).catch(e=>{throw v?.setError(t.EVENT_CLIENT_SESSION_ERRORS.session_approve_publish_failure),e}),v.addTrace(t.EVENT_CLIENT_SESSION_TRACES.session_approve_publish_success)}catch(e){throw this.client.logger.error(e),this.client.session.delete(S,(0,n.getSdkError)("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(S),e}return this.client.core.eventClient.deleteEvent({eventId:v.eventId}),await this.client.core.pairing.updateMetadata({topic:g,metadata:y.metadata}),await this.deleteProposal(a),await this.client.core.pairing.activate({topic:g}),await this.setExpiry(S,(0,n.calcExpiry)(p)),{topic:S,acknowledged:()=>Promise.resolve(this.client.session.get(S))}}),R(this,"reject",async e=>{let t;this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidReject(e)}catch(e){throw this.client.logger.error("reject() -> isValidReject() failed"),e}let{id:r,reason:i}=e;try{t=this.client.proposal.get(r).pairingTopic}catch(e){throw this.client.logger.error(`reject() -> proposal.get(${r}) failed`),e}
22t&&await this.sendError({id:r,topic:t,error:i,rpcOpts:g.wc_sessionPropose.reject}),await this.deleteProposal(r)}),R(this,"update",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(e)}catch(e){throw this.client.logger.error("update() -> isValidUpdate() failed"),e}let{topic:t,namespaces:r}=e,{done:i,resolve:s,reject:o}=(0,n.createDelayedPromise)(),a=(0,c.payloadId)(),l=(0,c.getBigIntRpcId)().toString(),u=this.client.session.get(t).namespaces;return this.events.once((0,n.engineEvent)("session_update",a),({error:e})=>{e?o(e):s()}),await this.client.session.update(t,{namespaces:r}),await this.sendRequest({topic:t,method:"wc_sessionUpdate",params:{namespaces:r},throwOnFailedPublish:!0,clientRpcId:a,relayRpcId:l}).catch(e=>{this.client.logger.error(e),this.client.session.update(t,{namespaces:u}),o(e)}),{acknowledged:i}}),R(this,"extend",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(e)}catch(e){throw this.client.logger.error("extend() -> isValidExtend() failed"),e}let{topic:t}=e,r=(0,c.payloadId)(),{done:i,resolve:s,reject:o}=(0,n.createDelayedPromise)();return this.events.once((0,n.engineEvent)("session_extend",r),({error:e})=>{e?o(e):s()}),await this.setExpiry(t,(0,n.calcExpiry)(p)),this.sendRequest({topic:t,method:"wc_sessionExtend",params:{},clientRpcId:r,throwOnFailedPublish:!0}).catch(e=>{o(e)}),{acknowledged:i}}),R(this,"request",async e=>{this.isInitialized();try{await this.isValidRequest(e)}catch(e){throw this.client.logger.error("request() -> isValidRequest() failed"),e}let{chainId:r,request:i,topic:s,expiry:o=g.wc_sessionRequest.req.ttl}=e,a=this.client.session.get(s);a?.transportType===t.TRANSPORT_TYPES.relay&&await this.confirmOnlineStateOrThrow();let l=(0,c.payloadId)(),u=(0,c.getBigIntRpcId)().toString(),{done:d,resolve:f,reject:p}=(0,n.createDelayedPromise)(o,"Request expired. Please try again.");this.events.once((0,n.engineEvent)("session_request",l),({error:e,result:t})=>{e?p(e):f(t)});let y="wc_sessionRequest",m=this.getAppLinkIfEnabled(a.peer.metadata,a.transportType);if(m)return await this.sendRequest({clientRpcId:l,relayRpcId:u,topic:s,method:y,params:{request:I(O({},i),A({expiryTimestamp:(0,n.calcExpiry)(o)})),chainId:r},expiry:o,throwOnFailedPublish:!0,appLink:m}).catch(e=>p(e)),this.client.events.emit("session_request_sent",{topic:s,request:i,chainId:r,id:l}),await d();let b={request:I(O({},i),A({expiryTimestamp:(0,n.calcExpiry)(o)})),chainId:r};return await Promise.all([new Promise(async e=>{await this.sendRequest({clientRpcId:l,relayRpcId:u,topic:s,method:y,params:b,expiry:o,throwOnFailedPublish:!0,tvf:this.getTVFParams(l,b)}).catch(e=>p(e)),this.client.events.emit("session_request_sent",{topic:s,request:i,chainId:r,id:l}),e()}),new Promise(async e=>{var t;if(!(null!=(t=a.sessionConfig)&&t.disableDeepLink)){let e=await (0,n.getDeepLink)(this.client.core.storage,h);await (0,n.handleDeeplinkRedirect)({id:l,topic:s,wcDeepLink:e})}e()}),d()]).then(e=>e[2])}),R(this,"respond",async e=>{this.isInitialized(),await this.isValidRespond(e);let{topic:r,response:i}=e,{id:s}=i,n=this.client.session.get(r);n.transportType===t.TRANSPORT_TYPES.relay&&await this.confirmOnlineStateOrThrow();let o=this.getAppLinkIfEnabled(n.peer.metadata,n.transportType);(0,l.isJsonRpcResult)(i)?await this.sendResult({id:s,topic:r,result:i.result,throwOnFailedPublish:!0,appLink:o}):(0,l.isJsonRpcError)(i)&&await this.sendError({id:s,topic:r,error:i.error,appLink:o}),this.cleanupAfterResponse(e)}),R(this,"ping",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(e)}catch(e){throw this.client.logger.error("ping() -> isValidPing() failed"),e}let{topic:t}=e;if(this.client.session.keys.includes(t)){let e=(0,c.payloadId)(),r=(0,c.getBigIntRpcId)().toString(),{done:i,resolve:s,reject:o}=(0,n.createDelayedPromise)();this.events.once((0,n.engineEvent)("session_ping",e),({error:e})=>{e?o(e):s()}),await Promise.all([this.sendRequest({topic:t,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:e,relayRpcId:r}),i()])}else this.client.core.pairing.pairings.keys.includes(t)&&(this.client.logger.warn("ping() on pairing topic is deprecated and will be removed in the next major release."),await this.client.core.pairing.ping({topic:t}))}),R(this,"emit",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(e);let{topic:t,event:r,chainId:i}=e,s=(0,c.getBigIntRpcId)().toString(),n=(0,c.payloadId)();await this.sendRequest({topic:t,method:"wc_sessionEvent",params:{event:r,chainId:i},throwOnFailedPublish:!0,relayRpcId:s,clientRpcId:n})}),R(this,"disconnect",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidDisconnect(e);let{topic:t}=e;if(this.client.session.keys.includes(t))await this.sendRequest({topic:t,method:"wc_sessionDelete",params:(0,n.getSdkError)("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:t,emitEvent:!1});else if(this.client.core.pairing.pairings.keys.includes(t))await this.client.core.pairing.disconnect({topic:t});else{let{message:e}=(0,n.getInternalError)("MISMATCHED_TOPIC",`Session or pairing topic not found: ${t}`);throw Error(e)}}),R(this,"find",e=>(this.isInitialized(),this.client.session.getAll().filter(t=>(0,n.isSessionCompatible)(t,e)))),R(this,"getPendingSessionRequests",()=>
22this.client.pendingRequest.getAll()),R(this,"authenticate",async(e,r)=>{var i;let s;this.isInitialized(),this.isValidAuthenticate(e);let o=r&&this.client.core.linkModeSupportedApps.includes(r)&&(null==(i=this.client.metadata.redirect)?void 0:i.linkMode),a=o?t.TRANSPORT_TYPES.link_mode:t.TRANSPORT_TYPES.relay;a===t.TRANSPORT_TYPES.relay&&await this.confirmOnlineStateOrThrow();let{chains:l,statement:u="",uri:d,domain:h,nonce:f,type:y,exp:m,nbf:b,methods:v=[],expiry:w}=e,_=[...e.resources||[]],{topic:E,uri:T}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:a});this.client.logger.info({message:"Generated new pairing",pairing:{topic:E,uri:T}});let x=await this.client.core.crypto.generateKeyPair(),k=(0,n.hashKey)(x);if(await Promise.all([this.client.auth.authKeys.set(S,{responseTopic:k,publicKey:x}),this.client.auth.pairingTopics.set(k,{topic:k,pairingTopic:E})]),await this.client.core.relayer.subscribe(k,{transportType:a}),this.client.logger.info(`sending request to new pairing topic: ${E}`),v.length>0){let{namespace:e}=(0,n.parseChainId)(l[0]),t=(0,n.createEncodedRecap)(e,"request",v);(0,n.getRecapFromResources)(_)&&(t=(0,n.mergeEncodedRecaps)(t,_.pop())),_.push(t)}let P=w&&w>g.wc_sessionAuthenticate.req.ttl?w:g.wc_sessionAuthenticate.req.ttl,R={authPayload:{type:y??"caip122",chains:l,statement:u,aud:d,domain:h,version:"1",nonce:f,iat:new Date().toISOString(),exp:m,nbf:b,resources:_},requester:{publicKey:x,metadata:this.client.metadata},expiryTimestamp:(0,n.calcExpiry)(P)},C={requiredNamespaces:{},optionalNamespaces:{eip155:{chains:l,methods:[...new Set(["personal_sign",...v])],events:["chainChanged","accountsChanged"]}},relays:[{protocol:"irn"}],pairingTopic:E,proposer:{publicKey:x,metadata:this.client.metadata},expiryTimestamp:(0,n.calcExpiry)(g.wc_sessionPropose.req.ttl),id:(0,c.payloadId)()},{done:N,resolve:B,reject:U}=(0,n.createDelayedPromise)(P,"Request expired"),q=(0,c.payloadId)(),L=(0,n.engineEvent)("session_connect",C.id),D=(0,n.engineEvent)("session_request",q),M=async({error:e,session:t})=>{this.events.off(D,K),e?U(e):t&&B({session:t})},K=async e=>{var i,s,o;let l;if(await this.deletePendingAuthRequest(q,{message:"fulfilled",code:0}),e.error){let t=(0,n.getSdkError)("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return e.error.code===t.code?void 0:(this.events.off(L,M),U(e.error.message))}
22await this.deleteProposal(C.id),this.events.off(L,M);let{cacaos:c,responder:u}=e.result,d=[],h=[];for(let e of c){await (0,n.validateSignedCacao)({cacao:e,projectId:this.client.core.projectId})||(this.client.logger.error(e,"Signature verification failed"),U((0,n.getSdkError)("SESSION_SETTLEMENT_FAILED","Signature verification failed")));let{p:t}=e,r=(0,n.getRecapFromResources)(t.resources),i=[(0,n.getNamespacedDidChainId)(t.iss)],s=(0,n.getDidAddress)(t.iss);if(r){let e=(0,n.getMethodsFromRecap)(r),t=(0,n.getChainsFromRecap)(r);d.push(...e),i.push(...t)}for(let e of i)h.push(`${e}:${s}`)}let f=await this.client.core.crypto.generateSharedKey(x,u.publicKey);d.length>0&&(l={topic:f,acknowledged:!0,self:{publicKey:x,metadata:this.client.metadata},peer:u,controller:u.publicKey,expiry:(0,n.calcExpiry)(p),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:E,namespaces:(0,n.buildNamespacesFromAuth)([...new Set(d)],[...new Set(h)]),transportType:a},await this.client.core.relayer.subscribe(f,{transportType:a}),await this.client.session.set(f,l),E&&await this.client.core.pairing.updateMetadata({topic:E,metadata:u.metadata}),l=this.client.session.get(f)),null!=(i=this.client.metadata.redirect)&&i.linkMode&&null!=(s=u.metadata.redirect)&&s.linkMode&&null!=(o=u.metadata.redirect)&&o.universal&&r&&(this.client.core.addLinkModeSupportedApp(u.metadata.redirect.universal),this.client.session.update(f,{transportType:t.TRANSPORT_TYPES.link_mode})),B({auths:c,session:l})};this.events.once(L,M),this.events.once(D,K);try{if(o){let e=(0,c.formatJsonRpcRequest)("wc_sessionAuthenticate",R,q);this.client.core.history.set(E,e);let t=await this.client.core.crypto.encode("",e,{type:n.TYPE_2,encoding:n.BASE64URL});s=(0,n.getLinkModeURL)(r,E,t)}else await Promise.all([this.sendRequest({topic:E,method:"wc_sessionAuthenticate",params:R,expiry:e.expiry,throwOnFailedPublish:!0,clientRpcId:q}),this.sendRequest({topic:E,method:"wc_sessionPropose",params:C,expiry:g.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:C.id})])}catch(e){throw this.events.off(L,M),this.events.off(D,K),e}return await this.setProposal(C.id,C),await this.setAuthRequest(q,{request:I(O({},R),A({verifyContext:{}})),pairingTopic:E,transportType:a}),{uri:s??T,response:N}}),R(this,"approveSessionAuthenticate",async e=>{let r,{id:i,auths:s}=e,o=this.client.core.eventClient.createEvent({properties:{topic:i.toString(),trace:[t.EVENT_CLIENT_AUTHENTICATE_TRACES.authenticated_session_approve_started]}});try{this.isInitialized()}catch(e){throw o.setError(t.EVENT_CLIENT_AUTHENTICATE_ERRORS.no_internet_connection),e}let a=this.getPendingAuthRequest(i);if(!a)throw o.setError(t.EVENT_CLIENT_AUTHENTICATE_ERRORS.authenticated_session_pending_request_not_found),Error(`Could not find pending auth request with id ${i}`);let l=a.transportType||t.TRANSPORT_TYPES.relay;l===t.TRANSPORT_TYPES.relay&&await this.confirmOnlineStateOrThrow();let c=a.requester.publicKey,u=await this.client.core.crypto.generateKeyPair(),d=(0,n.hashKey)(c),h={type:n.TYPE_1,receiverPublicKey:c,senderPublicKey:u},f=[],g=[];for(let e of s){if(!await (0,n.validateSignedCacao)({cacao:e,projectId:this.client.core.projectId})){o.setError(t.EVENT_CLIENT_AUTHENTICATE_ERRORS.invalid_cacao);let e=(0,n.getSdkError)("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:i,topic:d,error:e,encodeOpts:h}),Error(e.message)}o.addTrace(t.EVENT_CLIENT_AUTHENTICATE_TRACES.cacaos_verified);let{p:r}=e,s=(0,n.getRecapFromResources)(r.resources),a=[(0,n.getNamespacedDidChainId)(r.iss)],l=(0,n.getDidAddress)(r.iss);if(s){let e=(0,n.getMethodsFromRecap)(s),t=(0,n.getChainsFromRecap)(s);f.push(...e),a.push(...t)}for(let e of a)g.push(`${e}:${l}`)}let y=await this.client.core.crypto.generateSharedKey(u,c);if(o.addTrace(t.EVENT_CLIENT_AUTHENTICATE_TRACES.create_authenticated_session_topic),f?.length>0){r={topic:y,acknowledged:!0,self:{publicKey:u,metadata:this.client.metadata},peer:{publicKey:c,metadata:a.requester.metadata},controller:c,expiry:(0,n.calcExpiry)(p),authentication:s,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:a.pairingTopic,namespaces:(0,n.buildNamespacesFromAuth)([...new Set(f)],[...new Set(g)]),transportType:l},o.addTrace(t.EVENT_CLIENT_AUTHENTICATE_TRACES.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(y,{transportType:l})}catch(e){throw o.setError(t.EVENT_CLIENT_AUTHENTICATE_ERRORS.subscribe_authenticated_session_topic_failure),e}o.addTrace(t.EVENT_CLIENT_AUTHENTICATE_TRACES.subscribe_authenticated_session_topic_success),await this.client.session.set(y,r),o.addTrace(t.EVENT_CLIENT_AUTHENTICATE_TRACES.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:a.pairingTopic,metadata:a.requester.metadata})}o.addTrace(t.EVENT_CLIENT_AUTHENTICATE_TRACES.publishing_authenticated_session_approve);
22try{await this.sendResult({topic:d,id:i,result:{cacaos:s,responder:{publicKey:u,metadata:this.client.metadata}},encodeOpts:h,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(a.requester.metadata,l)})}catch(e){throw o.setError(t.EVENT_CLIENT_AUTHENTICATE_ERRORS.authenticated_session_approve_publish_failure),e}return await this.client.auth.requests.delete(i,{message:"fulfilled",code:0}),await this.client.core.pairing.activate({topic:a.pairingTopic}),this.client.core.eventClient.deleteEvent({eventId:o.eventId}),{session:r}}),R(this,"rejectSessionAuthenticate",async e=>{this.isInitialized();let{id:r,reason:i}=e,s=this.getPendingAuthRequest(r);if(!s)throw Error(`Could not find pending auth request with id ${r}`);s.transportType===t.TRANSPORT_TYPES.relay&&await this.confirmOnlineStateOrThrow();let o=s.requester.publicKey,a=await this.client.core.crypto.generateKeyPair(),l=(0,n.hashKey)(o),c={type:n.TYPE_1,receiverPublicKey:o,senderPublicKey:a};await this.sendError({id:r,topic:l,error:i,encodeOpts:c,rpcOpts:g.wc_sessionAuthenticate.reject,appLink:this.getAppLinkIfEnabled(s.requester.metadata,s.transportType)}),await this.client.auth.requests.delete(r,{message:"rejected",code:0}),await this.deleteProposal(r)}),R(this,"formatAuthMessage",e=>{this.isInitialized();let{request:t,iss:r}=e;return(0,n.formatMessage)(t,r)}),R(this,"processRelayMessageCache",()=>{setTimeout(async()=>{if(0!==this.relayMessageCache.length)for(;this.relayMessageCache.length>0;)try{let e=this.relayMessageCache.shift();e&&await this.onRelayMessage(e)}catch(e){this.client.logger.error(e)}},50)}),R(this,"cleanupDuplicatePairings",async e=>{if(e.pairingTopic)try{let t=this.client.core.pairing.pairings.get(e.pairingTopic),r=this.client.core.pairing.pairings.getAll().filter(r=>{var i,s;return(null==(i=r.peerMetadata)?void 0:i.url)&&(null==(s=r.peerMetadata)?void 0:s.url)===e.peer.metadata.url&&r.topic&&r.topic!==t.topic});if(0===r.length)return;this.client.logger.info(`Cleaning up ${r.length} duplicate pairing(s)`),await Promise.all(r.map(e=>this.client.core.pairing.disconnect({topic:e.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(e){this.client.logger.error(e)}}),R(this,"deleteSession",async e=>{var t;let{topic:r,expirerHasDeleted:i=!1,emitEvent:s=!0,id:o=0}=e,{self:a}=this.client.session.get(r);await this.client.core.relayer.unsubscribe(r),await this.client.session.delete(r,(0,n.getSdkError)("USER_DISCONNECTED")),this.addToRecentlyDeleted(r,"session"),this.client.core.crypto.keychain.has(a.publicKey)&&await this.client.core.crypto.deleteKeyPair(a.publicKey),this.client.core.crypto.keychain.has(r)&&await this.client.core.crypto.deleteSymKey(r),i||this.client.core.expirer.del(r),this.client.core.storage.removeItem(h).catch(e=>this.client.logger.warn(e)),this.getPendingSessionRequests().forEach(e=>{e.topic===r&&this.deletePendingSessionRequest(e.id,(0,n.getSdkError)("USER_DISCONNECTED"))}),r===(null==(t=this.sessionRequestQueue.queue[0])?void 0:t.topic)&&(this.sessionRequestQueue.state=m),s&&this.client.events.emit("session_delete",{id:o,topic:r})}),R(this,"deleteProposal",async(e,r)=>{if(r)try{let r=this.client.proposal.get(e),i=this.client.core.eventClient.getEvent({topic:r.pairingTopic});i?.setError(t.EVENT_CLIENT_SESSION_ERRORS.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(e,(0,n.getSdkError)("USER_DISCONNECTED")),r?Promise.resolve():this.client.core.expirer.del(e)]),this.addToRecentlyDeleted(e,"proposal")}),R(this,"deletePendingSessionRequest",async(e,t,r=!1)=>{await Promise.all([this.client.pendingRequest.delete(e,t),r?Promise.resolve():this.client.core.expirer.del(e)]),this.addToRecentlyDeleted(e,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(t=>t.id!==e),r&&(this.sessionRequestQueue.state=m,this.client.events.emit("session_request_expire",{id:e}))}),R(this,"deletePendingAuthRequest",async(e,t,r=!1)=>{await Promise.all([this.client.auth.requests.delete(e,t),r?Promise.resolve():this.client.core.expirer.del(e)])}),R(this,"setExpiry",async(e,t)=>{this.client.session.keys.includes(e)&&(this.client.core.expirer.set(e,t),await this.client.session.update(e,{expiry:t}))}),R(this,"setProposal",async(e,t)=>{this.client.core.expirer.set(e,(0,n.calcExpiry)(g.wc_sessionPropose.req.ttl)),await this.client.proposal.set(e,t)}),R(this,"setAuthRequest",async(e,r)=>{let{request:i,pairingTopic:s,transportType:n=t.TRANSPORT_TYPES.relay}=r;this.client.core.expirer.set(e,i.expiryTimestamp),await this.client.auth.requests.set(e,{authPayload:i.authPayload,requester:i.requester,expiryTimestamp:i.expiryTimestamp,id:e,pairingTopic:s,verifyContext:i.verifyContext,transportType:n})}),R(this,"setPendingSessionRequest",async e=>{let{id:t,topic:r,params:i,verifyContext:s}=e,o=i.request.expiryTimestamp||(0,n.calcExpiry)(g.wc_sessionRequest.req.ttl);
22this.client.core.expirer.set(t,o),await this.client.pendingRequest.set(t,{id:t,topic:r,params:i,verifyContext:s})}),R(this,"sendRequest",async t=>{let r,i,{topic:s,method:o,params:a,expiry:l,relayRpcId:u,clientRpcId:d,throwOnFailedPublish:h,appLink:f,tvf:p}=t,y=(0,c.formatJsonRpcRequest)(o,a,d),m=!!f;try{let e=m?n.BASE64URL:n.BASE64;r=await this.client.core.crypto.encode(s,y,{encoding:e})}catch(e){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${s} failed`),e}if(w.includes(o)){let e=(0,n.hashMessage)(JSON.stringify(y)),t=(0,n.hashMessage)(r);i=await this.client.core.verify.register({id:t,decryptedId:e})}let b=g[o].req;if(b.attestation=i,l&&(b.ttl=l),u&&(b.id=u),this.client.core.history.set(s,y),m){let t=(0,n.getLinkModeURL)(f,s,r);await e.g.Linking.openURL(t,this.client.name)}else{let e,t=g[o].req;l&&(t.ttl=l),u&&(t.id=u),t.tvf=I(O({},p),A({correlationId:y.id})),h?(e=O({},t.internal),t.internal=I(e,A({throwOnFailedPublish:!0})),await this.client.core.relayer.publish(s,r,t)):this.client.core.relayer.publish(s,r,t).catch(e=>this.client.logger.error(e))}return y.id}),R(this,"sendResult",async t=>{let r,i,s,{id:o,topic:a,result:l,throwOnFailedPublish:u,encodeOpts:d,appLink:h}=t,f=(0,c.formatJsonRpcResult)(o,l),p=h&&"u">typeof(null==e.g?void 0:e.g.Linking);try{let e,t,i=p?n.BASE64URL:n.BASE64;r=await this.client.core.crypto.encode(a,f,(e=O({},d||{}),t={encoding:i},I(e,A(t))))}catch(e){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${a} failed`),e}try{let e=(i=await this.client.core.history.get(a,o)).request;try{s=this.getTVFParams(o,e.params,l)}catch(e){this.client.logger.warn(`sendResult() -> getTVFParams() failed: ${e?.message}`)}}catch(e){throw this.client.logger.error(`sendResult() -> history.get(${a}, ${o}) failed`),e}if(p){let t=(0,n.getLinkModeURL)(h,a,r);await e.g.Linking.openURL(t,this.client.name)}else{let e,t=g[i.request.method].res;t.tvf=I(O({},s),A({correlationId:o})),u?(e=O({},t.internal),t.internal=I(e,A({throwOnFailedPublish:!0})),await this.client.core.relayer.publish(a,r,t)):this.client.core.relayer.publish(a,r,t).catch(e=>this.client.logger.error(e))}await this.client.core.history.resolve(f)}),R(this,"sendError",async t=>{let r,i,{id:s,topic:o,error:a,encodeOpts:l,rpcOpts:u,appLink:d}=t,h=(0,c.formatJsonRpcError)(s,a),f=d&&"u">typeof(null==e.g?void 0:e.g.Linking);try{let e,t,i=f?n.BASE64URL:n.BASE64;r=await this.client.core.crypto.encode(o,h,(e=O({},l||{}),t={encoding:i},I(e,A(t))))}catch(e){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${o} failed`),e}try{i=await this.client.core.history.get(o,s)}catch(e){throw this.client.logger.error(`sendError() -> history.get(${o}, ${s}) failed`),e}if(f){let t=(0,n.getLinkModeURL)(d,o,r);await e.g.Linking.openURL(t,this.client.name)}else{let e=i.request.method,t=u||g[e].res;this.client.core.relayer.publish(o,r,t)}await this.client.core.history.resolve(h)}),R(this,"cleanup",async()=>{let e=[],t=[];this.client.session.getAll().forEach(t=>{let r=!1;(0,n.isExpired)(t.expiry)&&(r=!0),this.client.core.crypto.keychain.has(t.topic)||(r=!0),r&&e.push(t.topic)}),this.client.proposal.getAll().forEach(e=>{(0,n.isExpired)(e.expiryTimestamp)&&t.push(e.id)}),await Promise.all([...e.map(e=>this.deleteSession({topic:e})),...t.map(e=>this.deleteProposal(e))])}),R(this,"onProviderMessageEvent",async e=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(e):await this.onRelayMessage(e)}),R(this,"onRelayEventRequest",async e=>{this.requestQueue.queue.push(e),await this.processRequestsQueue()}),R(this,"processRequestsQueue",async()=>{if(this.requestQueue.state===b)return void this.client.logger.info("Request queue already active, skipping...");for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=b;let e=this.requestQueue.queue.shift();if(e)try{await this.processRequest(e)}catch(e){this.client.logger.warn(e)}}this.requestQueue.state=m}),R(this,"processRequest",async e=>{let{topic:t,payload:r,attestation:i,transportType:s,encryptedId:n}=e,o=r.method;if(!this.shouldIgnorePairingRequest({topic:t,requestMethod:o}))switch(o){case"wc_sessionPropose":return await this.onSessionProposeRequest
22({topic:t,payload:r,attestation:i,encryptedId:n});case"wc_sessionSettle":return await this.onSessionSettleRequest(t,r);case"wc_sessionUpdate":return await this.onSessionUpdateRequest(t,r);case"wc_sessionExtend":return await this.onSessionExtendRequest(t,r);case"wc_sessionPing":return await this.onSessionPingRequest(t,r);case"wc_sessionDelete":return await this.onSessionDeleteRequest(t,r);case"wc_sessionRequest":return await this.onSessionRequest({topic:t,payload:r,attestation:i,encryptedId:n,transportType:s});case"wc_sessionEvent":return await this.onSessionEventRequest(t,r);case"wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:t,payload:r,attestation:i,encryptedId:n,transportType:s});default:return this.client.logger.info(`Unsupported request method ${o}`)}}),R(this,"onRelayEventResponse",async e=>{let{topic:t,payload:r,transportType:i}=e,s=(await this.client.core.history.get(t,r.id)).request.method;switch(s){case"wc_sessionPropose":return this.onSessionProposeResponse(t,r,i);case"wc_sessionSettle":return this.onSessionSettleResponse(t,r);case"wc_sessionUpdate":return this.onSessionUpdateResponse(t,r);case"wc_sessionExtend":return this.onSessionExtendResponse(t,r);case"wc_sessionPing":return this.onSessionPingResponse(t,r);case"wc_sessionRequest":return this.onSessionRequestResponse(t,r);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(t,r);default:return this.client.logger.info(`Unsupported response method ${s}`)}}),R(this,"onRelayEventUnknownPayload",e=>{let{topic:t}=e,{message:r}=(0,n.getInternalError)("MISSING_OR_INVALID",`Decoded payload on topic ${t} is not identifiable as a JSON-RPC request or a response.`);throw Error(r)}),R(this,"shouldIgnorePairingRequest",e=>{let{topic:t,requestMethod:r}=e,i=this.expectedPairingMethodMap.get(t);return!(!i||i.includes(r))&&!!(i.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0)}),R(this,"onSessionProposeRequest",async e=>{let{topic:r,payload:i,attestation:s,encryptedId:o}=e,{params:a,id:l}=i;try{let e=this.client.core.eventClient.getEvent({topic:r});0===this.client.events.listenerCount("session_proposal")&&(console.warn("No listener for session_proposal event"),e?.setError(t.EVENT_CLIENT_PAIRING_ERRORS.proposal_listener_not_found)),this.isValidConnect(O({},i.params));let c=a.expiryTimestamp||(0,n.calcExpiry)(g.wc_sessionPropose.req.ttl),u=O({id:l,pairingTopic:r,expiryTimestamp:c,attestation:s,encryptedId:o},a);await this.setProposal(l,u);let d=await this.getVerifyContext({attestationId:s,hash:(0,n.hashMessage)(JSON.stringify(i)),encryptedId:o,metadata:u.proposer.metadata});e?.addTrace(t.EVENT_CLIENT_PAIRING_TRACES.emit_session_proposal),this.client.events.emit("session_proposal",{id:l,params:u,verifyContext:d})}catch(e){await this.sendError({id:l,topic:r,error:e,rpcOpts:g.wc_sessionPropose.autoReject}),this.client.logger.error(e)}}),R(this,"onSessionProposeResponse",async(e,t,r)=>{let{id:i}=t;if((0,l.isJsonRpcResult)(t)){let{result:s}=t;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:s});let n=this.client.proposal.get(i);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:n});let o=n.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:o});let a=s.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:a});let l=await this.client.core.crypto.generateSharedKey(o,a);this.pendingSessions.set(i,{sessionTopic:l,pairingTopic:e,proposalId:i,publicKey:o});let c=await this.client.core.relayer.subscribe(l,{transportType:r});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:c}),await this.client.core.pairing.activate({topic:e})}else if((0,l.isJsonRpcError)(t)){await this.deleteProposal(i);let e=(0,n.engineEvent)("session_connect",i);if(0===this.events.listenerCount(e))throw Error(`emitting ${e} without any listeners, 954`);this.events.emit(e,{error:t.error})}}),R(this,"onSessionSettleRequest",async(e,r)=>{let{id:i,params:s}=r;try{let i,o;this.isValidSessionSettleRequest(s);let{relay:a,controller:l,expiry:c,namespaces:u,sessionProperties:d,scopedProperties:h,sessionConfig:f}=r.params,p=[...this.pendingSessions.values()].find(t=>t.sessionTopic===e);if(!p)return this.client.logger.error(`Pending session not found for topic ${e}`);let g=this.client.proposal.get(p.proposalId),y=(i=O(O(O({topic:e,relay:a,expiry:c,namespaces:u,acknowledged:!0,pairingTopic:p.pairingTopic,requiredNamespaces:g.requiredNamespaces,optionalNamespaces:g.optionalNamespaces,controller:l.publicKey,self:{publicKey:p.publicKey,metadata:this.client.metadata},peer:{publicKey:l.publicKey,metadata:l.metadata}},d&&{sessionProperties:d}),h&&{scopedProperties:h}),f&&{sessionConfig:f}),o={transportType:t.TRANSPORT_TYPES.relay},I(i,A(o)));await this.client.session.set(y.topic,y),await this.setExpiry(y.topic,y.expiry),await this.client.core.pairing.updateMetadata({topic:p.pairingTopic,metadata:y.peer.metadata}),this.client.events.emit("session_connect",{session:y}),this.events.emit((0,n.engineEvent)("session_connect",p.proposalId),{session:y}),this.pendingSessions.delete(p.proposalId),this.deleteProposal(p.proposalId,!1),this.cleanupDupl
22icatePairings(y),await this.sendResult({id:r.id,topic:e,result:!0})}catch(t){await this.sendError({id:i,topic:e,error:t}),this.client.logger.error(t)}}),R(this,"onSessionSettleResponse",async(e,t)=>{let{id:r}=t;(0,l.isJsonRpcResult)(t)?(await this.client.session.update(e,{acknowledged:!0}),this.events.emit((0,n.engineEvent)("session_approve",r),{})):(0,l.isJsonRpcError)(t)&&(await this.client.session.delete(e,(0,n.getSdkError)("USER_DISCONNECTED")),this.events.emit((0,n.engineEvent)("session_approve",r),{error:t.error}))}),R(this,"onSessionUpdateRequest",async(e,t)=>{let{params:r,id:i}=t;try{let t=`${e}_session_update`,s=n.MemoryStore.get(t);if(s&&this.isRequestOutOfSync(s,i)){this.client.logger.warn(`Discarding out of sync request - ${i}`),this.sendError({id:i,topic:e,error:(0,n.getSdkError)("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(O({topic:e},r));try{n.MemoryStore.set(t,i),await this.client.session.update(e,{namespaces:r.namespaces}),await this.sendResult({id:i,topic:e,result:!0})}catch(e){throw n.MemoryStore.delete(t),e}this.client.events.emit("session_update",{id:i,topic:e,params:r})}catch(t){await this.sendError({id:i,topic:e,error:t}),this.client.logger.error(t)}}),R(this,"isRequestOutOfSync",(e,t)=>t.toString().slice(0,-3)<e.toString().slice(0,-3)),R(this,"onSessionUpdateResponse",(e,t)=>{let{id:r}=t,i=(0,n.engineEvent)("session_update",r);if(0===this.events.listenerCount(i))throw Error(`emitting ${i} without any listeners`);(0,l.isJsonRpcResult)(t)?this.events.emit((0,n.engineEvent)("session_update",r),{}):(0,l.isJsonRpcError)(t)&&this.events.emit((0,n.engineEvent)("session_update",r),{error:t.error})}),R(this,"onSessionExtendRequest",async(e,t)=>{let{id:r}=t;try{this.isValidExtend({topic:e}),await this.setExpiry(e,(0,n.calcExpiry)(p)),await this.sendResult({id:r,topic:e,result:!0}),this.client.events.emit("session_extend",{id:r,topic:e})}catch(t){await this.sendError({id:r,topic:e,error:t}),this.client.logger.error(t)}}),R(this,"onSessionExtendResponse",(e,t)=>{let{id:r}=t,i=(0,n.engineEvent)("session_extend",r);if(0===this.events.listenerCount(i))throw Error(`emitting ${i} without any listeners`);(0,l.isJsonRpcResult)(t)?this.events.emit((0,n.engineEvent)("session_extend",r),{}):(0,l.isJsonRpcError)(t)&&this.events.emit((0,n.engineEvent)("session_extend",r),{error:t.error})}),R(this,"onSessionPingRequest",async(e,t)=>{let{id:r}=t;try{this.isValidPing({topic:e}),await this.sendResult({id:r,topic:e,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:r,topic:e})}catch(t){await this.sendError({id:r,topic:e,error:t}),this.client.logger.error(t)}}),R(this,"onSessionPingResponse",(e,t)=>{let{id:r}=t,i=(0,n.engineEvent)("session_ping",r);setTimeout(()=>{if(0===this.events.listenerCount(i))throw Error(`emitting ${i} without any listeners 2176`);(0,l.isJsonRpcResult)(t)?this.events.emit((0,n.engineEvent)("session_ping",r),{}):(0,l.isJsonRpcError)(t)&&this.events.emit((0,n.engineEvent)("session_ping",r),{error:t.error})},500)}),R(this,"onSessionDeleteRequest",async(e,r)=>{let{id:i}=r;try{this.isValidDisconnect({topic:e,reason:r.params}),Promise.all([new Promise(r=>{this.client.core.relayer.once(t.RELAYER_EVENTS.publish,async()=>{r(await this.deleteSession({topic:e,id:i}))})}),this.sendResult({id:i,topic:e,result:!0}),this.cleanupPendingSentRequestsForTopic({topic:e,error:(0,n.getSdkError)("USER_DISCONNECTED")})]).catch(e=>this.client.logger.error(e))}catch(e){this.client.logger.error(e)}}),R(this,"onSessionRequest",async e=>{var r,i,s;let{topic:o,payload:a,attestation:l,encryptedId:u,transportType:d}=e,{id:h,params:f}=a;try{await this.isValidRequest(O({topic:o},f));let e=this.client.session.get(o),a=await this.getVerifyContext({attestationId:l,hash:(0,n.hashMessage)(JSON.stringify((0,c.formatJsonRpcRequest)("wc_sessionRequest",f,h))),encryptedId:u,metadata:e.peer.metadata,transportType:d}),p={id:h,topic:o,params:f,verifyContext:a};await this.setPendingSessionRequest(p),d===t.TRANSPORT_TYPES.link_mode&&null!=(r=e.peer.metadata.redirect)&&r.universal&&this.client.core.addLinkModeSupportedApp(null==(i=e.peer.metadata.redirect)?void 0:i.universal),null!=(s=this.client.signConfig)&&s.disableRequestQueue?this.emitSessionRequest(p):(this.addSessionRequestToSessionRequestQueue(p),this.processSessionRequestQueue())}
22catch(e){await this.sendError({id:h,topic:o,error:e}),this.client.logger.error(e)}}),R(this,"onSessionRequestResponse",(e,t)=>{let{id:r}=t,i=(0,n.engineEvent)("session_request",r);if(0===this.events.listenerCount(i))throw Error(`emitting ${i} without any listeners`);(0,l.isJsonRpcResult)(t)?this.events.emit((0,n.engineEvent)("session_request",r),{result:t.result}):(0,l.isJsonRpcError)(t)&&this.events.emit((0,n.engineEvent)("session_request",r),{error:t.error})}),R(this,"onSessionEventRequest",async(e,t)=>{let{id:r,params:i}=t;try{let t=`${e}_session_event_${i.event.name}`,s=n.MemoryStore.get(t);if(s&&this.isRequestOutOfSync(s,r))return void this.client.logger.info(`Discarding out of sync request - ${r}`);this.isValidEmit(O({topic:e},i)),this.client.events.emit("session_event",{id:r,topic:e,params:i}),n.MemoryStore.set(t,r)}catch(t){await this.sendError({id:r,topic:e,error:t}),this.client.logger.error(t)}}),R(this,"onSessionAuthenticateResponse",(e,t)=>{let{id:r}=t;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:e,payload:t}),(0,l.isJsonRpcResult)(t)?this.events.emit((0,n.engineEvent)("session_request",r),{result:t.result}):(0,l.isJsonRpcError)(t)&&this.events.emit((0,n.engineEvent)("session_request",r),{error:t.error})}),R(this,"onSessionAuthenticateRequest",async e=>{var r;let{topic:i,payload:s,attestation:o,encryptedId:a,transportType:l}=e;try{let{requester:e,authPayload:c,expiryTimestamp:u}=s.params,d=await this.getVerifyContext({attestationId:o,hash:(0,n.hashMessage)(JSON.stringify(s)),encryptedId:a,metadata:e.metadata,transportType:l}),h={requester:e,pairingTopic:i,id:s.id,authPayload:c,verifyContext:d,expiryTimestamp:u};await this.setAuthRequest(s.id,{request:h,pairingTopic:i,transportType:l}),l===t.TRANSPORT_TYPES.link_mode&&null!=(r=e.metadata.redirect)&&r.universal&&this.client.core.addLinkModeSupportedApp(e.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:i,params:s.params,id:s.id,verifyContext:d})}catch(a){this.client.logger.error(a);let e=s.params.requester.publicKey,t=await this.client.core.crypto.generateKeyPair(),r=this.getAppLinkIfEnabled(s.params.requester.metadata,l),o={type:n.TYPE_1,receiverPublicKey:e,senderPublicKey:t};await this.sendError({id:s.id,topic:i,error:a,encodeOpts:o,rpcOpts:g.wc_sessionAuthenticate.autoReject,appLink:r})}}),R(this,"addSessionRequestToSessionRequestQueue",e=>{this.sessionRequestQueue.queue.push(e)}),R(this,"cleanupAfterResponse",e=>{this.deletePendingSessionRequest(e.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=m,this.processSessionRequestQueue()},(0,a.toMiliseconds)(this.requestQueueDelay))}),R(this,"cleanupPendingSentRequestsForTopic",({topic:e,error:t})=>{let r=this.client.core.history.pending;r.length>0&&r.filter(t=>t.topic===e&&"wc_sessionRequest"===t.request.method).forEach(e=>{let r=e.request.id,i=(0,n.engineEvent)("session_request",r);if(0===this.events.listenerCount(i))throw Error(`emitting ${i} without any listeners`);this.events.emit((0,n.engineEvent)("session_request",e.request.id),{error:t})})}),R(this,"processSessionRequestQueue",()=>{if(this.sessionRequestQueue.state===b)return void this.client.logger.info("session request queue is already active.");let e=this.sessionRequestQueue.queue[0];if(!e)return void this.client.logger.info("session request queue is empty.");try{this.emitSessionRequest(e)}catch(e){this.client.logger.error(e)}}),R(this,"emitSessionRequest",e=>{this.emittedSessionRequests.has(e.id)?this.client.logger.warn({id:e.id},`Skipping emitting \`session_request\` event for duplicate request. id: ${e.id}`):(this.sessionRequestQueue.state=b,this.emittedSessionRequests.add(e.id),this.client.events.emit("session_request",e))}),R(this,"onPairingCreated",e=>{if(e.methods&&this.expectedPairingMethodMap.set(e.topic,e.methods),e.active)return;let t=this.client.proposal.getAll().find(t=>t.pairingTopic===e.topic);
22t&&this.onSessionProposeRequest({topic:e.topic,payload:(0,c.formatJsonRpcRequest)("wc_sessionPropose",I(O({},t),A({requiredNamespaces:t.requiredNamespaces,optionalNamespaces:t.optionalNamespaces,relays:t.relays,proposer:t.proposer,sessionProperties:t.sessionProperties,scopedProperties:t.scopedProperties})),t.id),attestation:t.attestation,encryptedId:t.encryptedId})}),R(this,"isValidConnect",async e=>{if(!(0,n.isValidParams)(e)){let{message:t}=(0,n.getInternalError)("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(e)}`);throw Error(t)}let{pairingTopic:t,requiredNamespaces:r,optionalNamespaces:i,sessionProperties:s,scopedProperties:o,relays:a}=e;if((0,n.isUndefined)(t)||await this.isValidPairingTopic(t),!(0,n.isValidRelays)(a,!0)){let{message:e}=(0,n.getInternalError)("MISSING_OR_INVALID",`connect() relays: ${a}`);throw Error(e)}if(!(0,n.isUndefined)(r)&&0!==(0,n.isValidObject)(r)){let e="requiredNamespaces are deprecated and are automatically assigned to optionalNamespaces";["fatal","error","silent"].includes(this.client.logger.level)?console.warn(e):this.client.logger.warn(e),this.validateNamespaces(r,"requiredNamespaces")}if((0,n.isUndefined)(i)||0===(0,n.isValidObject)(i)||this.validateNamespaces(i,"optionalNamespaces"),(0,n.isUndefined)(s)||this.validateSessionProps(s,"sessionProperties"),!(0,n.isUndefined)(o)){this.validateSessionProps(o,"scopedProperties");let e=Object.keys(r||{}).concat(Object.keys(i||{}));if(!Object.keys(o).every(t=>e.includes(t.split(":")[0])))throw Error(`Scoped properties must be a subset of required/optional namespaces, received: ${JSON.stringify(o)}, required/optional namespaces: ${JSON.stringify(e)}`)}}),R(this,"validateNamespaces",(e,t)=>{let r=(0,n.isValidRequiredNamespaces)(e,"connect()",t);if(r)throw Error(r.message)}),R(this,"isValidApprove",async e=>{if(!(0,n.isValidParams)(e))throw Error((0,n.getInternalError)("MISSING_OR_INVALID",`approve() params: ${e}`).message);let{id:t,namespaces:r,relayProtocol:i,sessionProperties:s,scopedProperties:o}=e;this.checkRecentlyDeleted(t),await this.isValidProposalId(t);let a=this.client.proposal.get(t),l=(0,n.isValidNamespaces)(r,"approve()");if(l)throw Error(l.message);let c=(0,n.isConformingNamespaces)(a.requiredNamespaces,r,"approve()");if(c)throw Error(c.message);if(!(0,n.isValidString)(i,!0)){let{message:e}=(0,n.getInternalError)("MISSING_OR_INVALID",`approve() relayProtocol: ${i}`);throw Error(e)}if((0,n.isUndefined)(s)||this.validateSessionProps(s,"sessionProperties"),!(0,n.isUndefined)(o)){this.validateSessionProps(o,"scopedProperties");let e=new Set(Object.keys(r));if(!Object.keys(o).every(t=>e.has(t.split(":")[0])))throw Error(`Scoped properties must be a subset of approved namespaces, received: ${JSON.stringify(o)}, approved namespaces: ${Array.from(e).join(", ")}`)}}),R(this,"isValidReject",async e=>{if(!(0,n.isValidParams)(e)){let{message:t}=(0,n.getInternalError)("MISSING_OR_INVALID",`reject() params: ${e}`);throw Error(t)}let{id:t,reason:r}=e;if(this.checkRecentlyDeleted(t),await this.isValidProposalId(t),!(0,n.isValidErrorReason)(r)){let{message:e}=(0,n.getInternalError)("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(r)}`);throw Error(e)}}),R(this,"isValidSessionSettleRequest",e=>{if(!(0,n.isValidParams)(e)){let{message:t}=(0,n.getInternalError)("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${e}`);throw Error(t)}
22let{relay:t,controller:r,namespaces:i,expiry:s}=e;if(!(0,n.isValidRelay)(t)){let{message:e}=(0,n.getInternalError)("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw Error(e)}let o=(0,n.isValidController)(r,"onSessionSettleRequest()");if(o)throw Error(o.message);let a=(0,n.isValidNamespaces)(i,"onSessionSettleRequest()");if(a)throw Error(a.message);if((0,n.isExpired)(s)){let{message:e}=(0,n.getInternalError)("EXPIRED","onSessionSettleRequest()");throw Error(e)}}),R(this,"isValidUpdate",async e=>{if(!(0,n.isValidParams)(e)){let{message:t}=(0,n.getInternalError)("MISSING_OR_INVALID",`update() params: ${e}`);throw Error(t)}let{topic:t,namespaces:r}=e;this.checkRecentlyDeleted(t),await this.isValidSessionTopic(t);let i=this.client.session.get(t),s=(0,n.isValidNamespaces)(r,"update()");if(s)throw Error(s.message);let o=(0,n.isConformingNamespaces)(i.requiredNamespaces,r,"update()");if(o)throw Error(o.message)}),R(this,"isValidExtend",async e=>{if(!(0,n.isValidParams)(e)){let{message:t}=(0,n.getInternalError)("MISSING_OR_INVALID",`extend() params: ${e}`);throw Error(t)}let{topic:t}=e;this.checkRecentlyDeleted(t),await this.isValidSessionTopic(t)}),R(this,"isValidRequest",async e=>{if(!(0,n.isValidParams)(e)){let{message:t}=(0,n.getInternalError)("MISSING_OR_INVALID",`request() params: ${e}`);throw Error(t)}let{topic:t,request:r,chainId:i,expiry:s}=e;this.checkRecentlyDeleted(t),await this.isValidSessionTopic(t);let{namespaces:o}=this.client.session.get(t);if(!(0,n.isValidNamespacesChainId)(o,i)){let{message:e}=(0,n.getInternalError)("MISSING_OR_INVALID",`request() chainId: ${i}`);throw Error(e)}if(!(0,n.isValidRequest)(r)){let{message:e}=(0,n.getInternalError)("MISSING_OR_INVALID",`request() ${JSON.stringify(r)}`);throw Error(e)}if(!(0,n.isValidNamespacesRequest)(o,i,r.method)){let{message:e}=(0,n.getInternalError)("MISSING_OR_INVALID",`request() method: ${r.method}`);throw Error(e)}if(s&&!(0,n.isValidRequestExpiry)(s,y)){let{message:e}=(0,n.getInternalError)("MISSING_OR_INVALID",`request() expiry: ${s}. Expiry must be a number (in seconds) between ${y.min} and ${y.max}`);throw Error(e)}}),R(this,"isValidRespond",async e=>{var t;if(!(0,n.isValidParams)(e)){let{message:t}=(0,n.getInternalError)("MISSING_OR_INVALID",`respond() params: ${e}`);throw Error(t)}let{topic:r,response:i}=e;try{await this.isValidSessionTopic(r)}catch(r){throw null!=(t=e?.response)&&t.id&&this.cleanupAfterResponse(e),r}if(!(0,n.isValidResponse)(i)){let{message:e}=(0,n.getInternalError)("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(i)}`);throw Error(e)}}),R(this,"isValidPing",async e=>{if(!(0,n.isValidParams)(e)){let{message:t}=(0,n.getInternalError)("MISSING_OR_INVALID",`ping() params: ${e}`);throw Error(t)}let{topic:t}=e;await this.isValidSessionOrPairingTopic(t)}),R(this,"isValidEmit",async e=>{if(!(0,n.isValidParams)(e)){let{message:t}=(0,n.getInternalError)("MISSING_OR_INVALID",`emit() params: ${e}`);throw Error(t)}let{topic:t,event:r,chainId:i}=e;await this.isValidSessionTopic(t);let{namespaces:s}=this.client.session.get(t);if(!(0,n.isValidNamespacesChainId)(s,i)){let{message:e}=(0,n.getInternalError)("MISSING_OR_INVALID",`emit() chainId: ${i}`);throw Error(e)}if(!(0,n.isValidEvent)(r)||!(0,n.isValidNamespacesEvent)(s,i,r.name)){let{message:e}=(0,n.getInternalError)("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(r)}`);throw Error(e)}}),R(this,"isValidDisconnect",async e=>{if(!(0,n.isValidParams)(e)){let{message:t}=(0,n.getInternalError)("MISSING_OR_INVALID",`disconnect() params: ${e}`);throw Error(t)}let{topic:t}=e;await this.isValidSessionOrPairingTopic(t)}),R(this,"isValidAuthenticate",e=>{let{chains:t,uri:r,domain:i,nonce:s}=e;if(!Array.isArray(t)||0===t.length)throw Error("chains is required and must be a non-empty array");if(!(0,n.isValidString)(r,!1))throw Error("uri is required parameter");if(!(0,n.isValidString)(i,!1))throw Error("domain is required parameter");if(!(0,n.isValidString)(s,!1))throw Error("nonce is required parameter");if([...new Set(t.map(e=>(0,n.parseChainId)(e).namespace))].length>1)throw Error("Multi-namespace requests are not supported. Please request single namespace only.");let{namespace:o}=(0,n.parseChainId)(t[0]);if("eip155"!==o)throw Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")}),R(this,"getVerifyContext",async e=>{let{attestationId:r,hash:i,encryptedId:s,metadata:n,transportType:o}=e,a={verified:{verifyUrl:n.verifyUrl||t.VERIFY_SERVER,validation:"UNKNOWN",origin:n.url||""}};try{if(o===t.TRANSPORT_TYPES.link_mode){let e=this.getAppLinkIfEnabled(n,o);return a.verified.validation=e&&new URL(e).origin===new URL(n.url).origin?"VALID":"INVALID",a}let e=await this.client.core.verify.resolve({attestationId:r,hash:i,encryptedId:s,verifyUrl:n.verifyUrl});e&&(a.verified.origin=e.origin,a.verified.isScam=e.isScam,a.verified.validation=e.origin===new URL(n.url).origin?"VALID":"INVALID")}catch(e){this.client.logger.warn(e)}return this.client.logger.debug(`Verify context: ${JSON.stringify(a)}`),a}),R(this,"validateSessionProps",(e,t)=>{Object.values(e).forEach((r,i)=>{if(null==r){let{message:s}=(0,n.getInternalError)("MISSING_OR_INVALID",`${t} must contain an existing value for each key. Received: ${r} for key ${Object.keys(e)[i]}`);throw Error(s)}})}),R(this,"getPendingAuthRequest",e=>{let t=this.client.auth.requests.get(e);return"object"==typeof t?t:void 0}),R(this,"addToRecentlyDeleted",(e,t)=>{if(this.recentlyDeletedMap.set(e,t),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let e=0,t=this.recentlyDeletedLimit/2;
22for(let r of this.recentlyDeletedMap.keys()){if(e++>=t)break;this.recentlyDeletedMap.delete(r)}}}),R(this,"checkRecentlyDeleted",e=>{let t=this.recentlyDeletedMap.get(e);if(t){let{message:r}=(0,n.getInternalError)("MISSING_OR_INVALID",`Record was recently deleted - ${t}: ${e}`);throw Error(r)}}),R(this,"isLinkModeEnabled",(r,i)=>{var s,n,o,a,l,c,u,d,h;return!!r&&i===t.TRANSPORT_TYPES.link_mode&&(null==(n=null==(s=this.client.metadata)?void 0:s.redirect)?void 0:n.linkMode)===!0&&(null==(a=null==(o=this.client.metadata)?void 0:o.redirect)?void 0:a.universal)!==void 0&&(null==(c=null==(l=this.client.metadata)?void 0:l.redirect)?void 0:c.universal)!==""&&(null==(u=r?.redirect)?void 0:u.universal)!==void 0&&(null==(d=r?.redirect)?void 0:d.universal)!==""&&(null==(h=r?.redirect)?void 0:h.linkMode)===!0&&this.client.core.linkModeSupportedApps.includes(r.redirect.universal)&&"u">typeof(null==e.g?void 0:e.g.Linking)}),R(this,"getAppLinkIfEnabled",(e,t)=>{var r;return this.isLinkModeEnabled(e,t)?null==(r=e?.redirect)?void 0:r.universal:void 0}),R(this,"handleLinkModeMessage",({url:e})=>{if(!e||!e.includes("wc_ev")||!e.includes("topic"))return;let r=(0,n.getSearchParamFromURL)(e,"topic")||"",i=decodeURIComponent((0,n.getSearchParamFromURL)(e,"wc_ev")||""),s=this.client.session.keys.includes(r);s&&this.client.session.update(r,{transportType:t.TRANSPORT_TYPES.link_mode}),this.client.core.dispatchEnvelope({topic:r,message:i,sessionExists:s})}),R(this,"registerLinkModeListeners",async()=>{var t;if((0,n.isTestRun)()||(0,n.isReactNative)()&&null!=(t=this.client.metadata.redirect)&&t.linkMode){let t=null==e.g?void 0:e.g.Linking;if("u">typeof t){t.addEventListener("url",this.handleLinkModeMessage,this.client.name);let e=await t.getInitialURL();e&&setTimeout(()=>{this.handleLinkModeMessage({url:e})},50)}}}),R(this,"getTVFParams",(e,t,r)=>{var i,s,n;if(!(null!=(i=t.request)&&i.method))return{};let o={correlationId:e,rpcMethods:[t.request.method],chainId:t.chainId};try{o.txHashes=this.extractTxHashesFromResult(t.request,r),o.contractAddresses=this.isValidContractData(t.request.params)?[null==(n=null==(s=t.request.params)?void 0:s[0])?void 0:n.to]:[]}catch(e){this.client.logger.warn("Error getting TVF params",e)}return o}),R(this,"isValidContractData",e=>{var t;if(!e)return!1;try{let r=e?.data||(null==(t=e?.[0])?void 0:t.data);if(!r.startsWith("0x"))return!1;let i=r.slice(2);return!!/^[0-9a-fA-F]*$/.test(i)&&i.length%2==0}catch{}return!1}),R(this,"extractTxHashesFromResult",(e,t)=>{var r;try{if(!t)return[];let i=e.method,s=v[i];if("sui_signTransaction"===i)return[(0,n.getSuiDigest)(t.transactionBytes)];if("near_signTransaction"===i)return[(0,n.getNearTransactionIdFromSignedTransaction)(t)];if("near_signTransactions"===i)return t.map(e=>(0,n.getNearTransactionIdFromSignedTransaction)(e));if("xrpl_signTransactionFor"===i||"xrpl_signTransaction"===i)return[null==(r=t.tx_json)?void 0:r.hash];if("polkadot_signTransaction"===i)return[(0,n.buildSignedExtrinsicHash)({transaction:e.params.transactionPayload,signature:t.signature})];if("algo_signTxn"===i)return(0,n.isValidArray)(t)?t.map(e=>(0,n.getAlgorandTransactionId)(e)):[(0,n.getAlgorandTransactionId)(t)];if("cosmos_signDirect"===i)return[(0,n.getSignDirectHash)(t)];if("string"==typeof t)return[t];let o=t[s.key];if((0,n.isValidArray)(o))return"solana_signAllTransactions"===i?o.map(e=>(0,n.extractSolanaTransactionId)(e)):o;if("string"==typeof o)return[o]}catch(e){this.client.logger.warn("Error extracting tx hashes from result",e)}return[]})}async processPendingMessageEvents(){try{let e=this.client.session.keys,t=this.client.core.relayer.messages.getWithoutAck(e);for(let[e,r]of Object.entries(t))for(let t of r)try{await this.onProviderMessageEvent({topic:e,message:t,publishedAt:Date.now()})}catch{this.client.logger.warn(`Error processing pending message event for topic: ${e}, message: ${t}`)}}catch(e){this.client.logger.warn("processPendingMessageEvents failed",e)}}isInitialized(){if(!this.initialized){let{message:e}=(0,n.getInternalError)("NOT_INITIALIZED",this.name);throw Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(t.RELAYER_EVENTS.message,e=>{this.onProviderMessageEvent(e)})}async onRelayMessage(e){let{topic:r,message:i,attestation:s,transportType:o}=e,{publicKey:a}=this.client.auth.authKeys.keys.includes(S)?this.client.auth.authKeys.get(S):{responseTopic:void 0,publicKey:void 0};try{let e=await this.client.core.crypto.decode(r,i,{receiverPublicKey:a,encoding:o===t.TRANSPORT_TYPES.link_mode?n.BASE64URL:n.BASE64});(0,l.isJsonRpcRequest)(e)?(this.client.core.history.set(r,e),await this.onRelayEventRequest({topic:r,payload:e,attestation:s,transportType:o,encryptedId:(0,n.hashMessage)(i)})):(0,l.isJsonRpcResponse)(e)?(await this.client.core.history.resolve(e),await this.onRelayEventResponse({topic:r,payload:e,transportType:o}
22),this.client.core.history.delete(r,e.id)):await this.onRelayEventUnknownPayload({topic:r,payload:e,transportType:o}),await this.client.core.relayer.messages.ack(r,i)}catch(e){this.client.logger.error(e)}}registerExpirerEvents(){this.client.core.expirer.on(t.EXPIRER_EVENTS.expired,async e=>{let{topic:t,id:r}=(0,n.parseExpirerTarget)(e.target);return r&&this.client.pendingRequest.keys.includes(r)?await this.deletePendingSessionRequest(r,(0,n.getInternalError)("EXPIRED"),!0):r&&this.client.auth.requests.keys.includes(r)?await this.deletePendingAuthRequest(r,(0,n.getInternalError)("EXPIRED"),!0):void(t?this.client.session.keys.includes(t)&&(await this.deleteSession({topic:t,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:t})):r&&(await this.deleteProposal(r,!0),this.client.events.emit("proposal_expire",{id:r})))})}registerPairingEvents(){this.client.core.pairing.events.on(t.PAIRING_EVENTS.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(t.PAIRING_EVENTS.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!(0,n.isValidString)(e,!1)){let{message:t}=(0,n.getInternalError)("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw Error(t)}if(!this.client.core.pairing.pairings.keys.includes(e)){let{message:t}=(0,n.getInternalError)("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw Error(t)}if((0,n.isExpired)(this.client.core.pairing.pairings.get(e).expiry)){let{message:t}=(0,n.getInternalError)("EXPIRED",`pairing topic: ${e}`);throw Error(t)}}async isValidSessionTopic(e){if(!(0,n.isValidString)(e,!1)){let{message:t}=(0,n.getInternalError)("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw Error(t)}if(this.checkRecentlyDeleted(e),!this.client.session.keys.includes(e)){let{message:t}=(0,n.getInternalError)("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw Error(t)}if((0,n.isExpired)(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});let{message:t}=(0,n.getInternalError)("EXPIRED",`session topic: ${e}`);throw Error(t)}if(!this.client.core.crypto.keychain.has(e)){let{message:t}=(0,n.getInternalError)("MISSING_OR_INVALID",`session topic does not exist in keychain: ${e}`);throw await this.deleteSession({topic:e}),Error(t)}}async isValidSessionOrPairingTopic(e){if(this.checkRecentlyDeleted(e),this.client.session.keys.includes(e))await this.isValidSessionTopic(e);else if(this.client.core.pairing.pairings.keys.includes(e))this.isValidPairingTopic(e);else if((0,n.isValidString)(e,!1)){let{message:t}=(0,n.getInternalError)("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw Error(t)}else{let{message:t}=(0,n.getInternalError)("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw Error(t)}}async isValidProposalId(e){if(!(0,n.isValidId)(e)){let{message:t}=(0,n.getInternalError)("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw Error(t)}if(!this.client.proposal.keys.includes(e)){let{message:t}=(0,n.getInternalError)("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw Error(t)}if((0,n.isExpired)(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);let{message:t}=(0,n.getInternalError)("EXPIRED",`proposal id: ${e}`);throw Error(t)}}}class N extends t.Store{constructor(e,t){super(e,t,"proposal",d),this.core=e,this.logger=t}}class B extends t.Store{constructor(e,t){super(e,t,"session",d),this.core=e,this.logger=t}}class U extends t.Store{constructor(e,t){super(e,t,"request",d,e=>e.id),this.core=e,this.logger=t}}class q extends t.Store{constructor(e,t){super(e,t,"authKeys",_,()=>S),this.core=e,this.logger=t}}class L extends t.Store{constructor(e,t){super(e,t,"pairingTopics",_),this.core=e,this.logger=t}}class D extends t.Store{constructor(e,t){super(e,t,"requests",_,e=>e.id),this.core=e,this.logger=t}}var M=Object.defineProperty,K=(e,t,r)=>{let i;return(i="symbol"!=typeof t?t+"":t)in e?M(e,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[i]=r};class W{constructor(e,t){this.core=e,this.logger=t,K(this,"authKeys"),K(this,"pairingTopics"),K(this,"requests"),this.authKeys=new q(this.core,this.logger),this.pairingTopics=new L(this.core,this.logger),this.requests=new D(this.core,this.logger)}
22async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}}var z=Object.defineProperty,j=(e,t,r)=>{let i;return(i="symbol"!=typeof t?t+"":t)in e?z(e,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[i]=r};class V extends s.ISignClient{constructor(e){super(e),j(this,"protocol","wc"),j(this,"version",2),j(this,"name",u),j(this,"metadata"),j(this,"core"),j(this,"logger"),j(this,"events",new o.EventEmitter),j(this,"engine"),j(this,"session"),j(this,"proposal"),j(this,"pendingRequest"),j(this,"auth"),j(this,"signConfig"),j(this,"on",(e,t)=>this.events.on(e,t)),j(this,"once",(e,t)=>this.events.once(e,t)),j(this,"off",(e,t)=>this.events.off(e,t)),j(this,"removeListener",(e,t)=>this.events.removeListener(e,t)),j(this,"removeAllListeners",e=>this.events.removeAllListeners(e)),j(this,"connect",async e=>{try{return await this.engine.connect(e)}catch(e){throw this.logger.error(e.message),e}}),j(this,"pair",async e=>{try{return await this.engine.pair(e)}catch(e){throw this.logger.error(e.message),e}}),j(this,"approve",async e=>{try{return await this.engine.approve(e)}catch(e){throw this.logger.error(e.message),e}}),j(this,"reject",async e=>{try{return await this.engine.reject(e)}catch(e){throw this.logger.error(e.message),e}}),j(this,"update",async e=>{try{return await this.engine.update(e)}catch(e){throw this.logger.error(e.message),e}}),j(this,"extend",async e=>{try{return await this.engine.extend(e)}catch(e){throw this.logger.error(e.message),e}}),j(this,"request",async e=>{try{return await this.engine.request(e)}catch(e){throw this.logger.error(e.message),e}}),j(this,"respond",async e=>{try{return await this.engine.respond(e)}catch(e){throw this.logger.error(e.message),e}}),j(this,"ping",async e=>{try{return await this.engine.ping(e)}catch(e){throw this.logger.error(e.message),e}}),j(this,"emit",async e=>{try{return await this.engine.emit(e)}catch(e){throw this.logger.error(e.message),e}}),j(this,"disconnect",async e=>{try{return await this.engine.disconnect(e)}catch(e){throw this.logger.error(e.message),e}}),j(this,"find",e=>{try{return this.engine.find(e)}catch(e){throw this.logger.error(e.message),e}}),j(this,"getPendingSessionRequests",()=>{try{return this.engine.getPendingSessionRequests()}catch(e){throw this.logger.error(e.message),e}}),j(this,"authenticate",async(e,t)=>{try{return await this.engine.authenticate(e,t)}catch(e){throw this.logger.error(e.message),e}}),j(this,"formatAuthMessage",e=>{try{return this.engine.formatAuthMessage(e)}catch(e){throw this.logger.error(e.message),e}}),j(this,"approveSessionAuthenticate",async e=>{try{return await this.engine.approveSessionAuthenticate(e)}catch(e){throw this.logger.error(e.message),e}}),j(this,"rejectSessionAuthenticate",async e=>{try{return await this.engine.rejectSessionAuthenticate(e)}catch(e){throw this.logger.error(e.message),e}}),this.name=e?.name||u,this.metadata=(0,n.populateAppMetadata)(e?.metadata),this.signConfig=e?.signConfig;const s="u">typeof e?.logger&&"string"!=typeof e?.logger?e.logger:(0,i.pino)((0,r.getDefaultLoggerOptions)({level:e?.logger||"error"}));this.core=e?.core||new t.Core(e),this.logger=(0,r.generateChildLogger)(s,this.name),this.session=new B(this.core,this.logger),this.proposal=new N(this.core,this.logger),this.pendingRequest=new U(this.core,this.logger),this.engine=new C(this),this.auth=new W(this.core,this.logger)}static async init(e){let t=new V(e);return await t.initialize(),t}get context(){return(0,r.getLoggerContext)(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.auth.init(),await this.engine.init(),this.logger.info("SignClient Initialization Success")}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}}e.s(["default",0,V])},812229,e=>{"use strict";let t=new(e.i(538990)).Logger("wallet-connect");e.s(["logger",0,t])},479281,e=>{"use strict";var t=e.i(633227),r=e.i(812229);e.s(["reconcileOrphanedPairings",0,e=>(0,t.__awaiter)(void 0,void 0,void 0,function*(){let i;try{i=e.core.pairing.getPairings()}catch(e){r.logger.warn("[reconcileOrphanedPairings] failed to read pairings",{errorMessage:e instanceof Error?e.message:String(e)});return}0!==i.length&&(yield Promise.all(i.map(i=>(0,t.__awaiter)(void 0,void 0,void 0,function*(){if(!e.session.getAll().some(e=>e.pairingTopic===i.topic))try{yield e.core.pairing.disconnect({topic:i.topic})}catch(e){r.logger.warn("[reconcileOrphanedPairings] failed to disconnect pairing",{errorMessage:e instanceof Error?e.message:String(e),topic:i.topic})}}))))})])},822769,e=>{"use strict";let t;var r=e.i(633227),i=e.i(484130),s=e.i(479281);e.s(["getSignClientSingleton",0,e=>(0,r.__awaiter)(void 0,[e],void 0,function*({projectId:e,appIcon:r,appName:n,redirectUrl:o}){return t||(t=yield i.default.init({customStoragePrefix:`dynamicauth_${e}_walletconnect`,metadata:{description:"",icons:[r],name:n,redirect:o?{native:o}:void 0,url:""},projectId:e}),(0,s.reconcileOrphanedPairings)(t)),t})])},709451,e=>{"use strict";e.i(957121);var t=e.i(303690),r=e.i(995978);e.i(822769),(0,t.assertPackageVersion)("@dynamic-labs/wallet-connect",r.version),e.s([])},959083,e=>{"use strict";e.s(["parsePairingTopicFromUri",0,e=>{if(!e)return;let t=/^wc:([^@?]+)@/.exec(e);return null==t?void 0:t[1]}])},60967,e=>{"use strict";var t=e.i(115349),r=e.i(127261);e.i(973402);var i=e.i(267028),s=e.i(779772);e.s(["createSolanaSignerForWalletConnect",0,({walletConnector:e})=>{let n={addListener:()=>{throw Error("addListener - Not implemented")},connect:()=>(0,t.__awaiter)(void 0,void 0,void 0,function*(){let t=e.getActiveAddress();if(t)return{address:t,publicKey:new r.PublicKey(t)}}),disconnect:()=>(0,t.__awaiter)(void 0,void 0,void 0,function*(){yield e.endSession()}),emit:()=>{throw Error("emit - Not implemented")},eventNames:()=>(s.logger.error("eventNames - Not implemented"),[]),isBackpack:!1,isBraveWallet:!1,get isConnected(){return!!e.getActiveAddress()},isExodus:!1,isGlow:!1,isMagicEden:!1,isPhantom:!1,isSolflare:!1,listenerCount:()=>(s.logger.error("listenerCount - Not implemented"),0),listeners:()=>(s.logger.error("listeners - Not implemented"),[]),off:()=>{throw Error("off - Not implemented")},on:(t,r)=>("connect"===t?s.logger.debug("on - Not implemented for event: connect"):"activeWalletDidChange"===t?e.listenToActiveAccountChange(r):e.signClient.on("session_event",s=>{if(e.session&&s.topic===e.session.topic){if("accountsChanged"===s.params.event.name&&"accountChanged"===t){let e=s.params.event.data;r((0,i.filterDuplicates)(e.map(e=>e.startsWith("solana:")?e.split(":")[2]:e))[0]);return}if("disconnected"===s.params.event.name&&"disconnect"===t)return void r("")}}),n),once:()=>{throw Error("once - Not implemented")},providers:[],get publicKey(){let t=e.getActiveAddress();return t?new r.PublicKey(t):void 0},removeAllListeners:()=>{throw Error("removeAllListeners - Not implemented")},removeListener:()=>{throw Error("removeListener - Not implemented")},signAllTransactions:r=>(0,t.__awaiter)(void 0,void 0,void 0,function*(){return e.signAllTransactions(r)}),signAndSendTransaction:(r,i)=>(0,t.__awaiter)(void 0,void 0,void 0,function*(){return{signature:yield e.signAndSendTransaction(r,i)}}),signMessage:r=>(0,t.__awaiter)(void 0,void 0,void 0,function*(){return{signature:yield e.signEncodedMessage(r)}}),signTransaction:r=>(0,t.__awaiter)(void 0,void 0,void 0,function*(){return e.signTransaction(r)})};return n}])},926497,e=>{"use strict";var t=e.i(467034),r=e.i(115349),i=e.i(127261),s=e.i(741483),n=e.i(6
2254611),o=e.i(595932);e.i(484200);var a=e.i(510137),l=e.i(319050),c=e.i(733149),u=e.i(4502);e.i(973402);var d=e.i(159491),h=e.i(624211),f=e.i(267028),p=e.i(55130),g=e.i(415565),y=e.i(44630),m=e.i(123785);e.i(709451);var b=e.i(822769);e.i(303778);var v=e.i(264542),w=e.i(241898),_=e.i(13855),S=e.i(779772),E=e.i(959083),I=e.i(60967);class A extends a.SolanaWalletConnector{constructor(e){super(e),this.activeAccountEmitter=new o.default,this.isInitialized=!1,this.canConnectViaQrCode=!0,this.isWalletConnect=!0,this.canHandleMultipleConnections=!1,this.mergeWalletBookChains=!1,this.name=e.walletName;const t=d.StorageService.getItem("dynamic-wc2-solana-current-chain");if(t&&this.setNetworkId(t),e.overrideKey&&(this.overrideKey=e.overrideKey),!e.projectId)throw new h.DynamicError("WalletConnect project ID is required","walletconnect_project_id_is_required")}get deepLinkPreference(){var e;return null!=(e=this.constructorProps.deepLinkPreference)?e:"native"}get signClient(){if(!A.signClientReference)throw new h.DynamicError("Failed to access sign client for Wallet Connect Solana: Sign client not initialized","access_sign_client_for_wallet_connect");return A.signClientReference}getAvailableMethods(){var e,t;return this.session&&null!=(t=null==(e=this.session.namespaces.solana)?void 0:e.methods)?t:[]}getSupportedNetworks(){return(0,r.__awaiter)(this,void 0,void 0,function*(){var e,t;if(!this.session)return this.solNetworks.map(e=>e.chainId.toString());let r=null!=(t=null==(e=this.session.namespaces.solana)?void 0:e.chains)?t:[];return this.solNetworks.filter(e=>r.includes(`solana:${e.genesisHash}`)).map(e=>e.chainId.toString())})}getActiveAddress(){var e,t;return this.session?(S.logger.logVerboseTroubleshootingMessage("[SolanaWalletConnect] getActiveAddress - session",this.session),null==(t=null==(e=this.session.namespaces.solana)?void 0:e.accounts)?void 0:t[0].split(":")[2]):void S.logger.logVerboseTroubleshootingMessage("[SolanaWalletConnect] getActiveAddress - no session, returning undefined")}listenToActiveAccountChange(e){return this.activeAccountEmitter.on("activeAccountDidChange",e),()=>{this.activeAccountEmitter.off("activeAccountDidChange",e)}}isSendBalanceUnsupported(){if(!this.session)return!1;let e=this.getAvailableMethods();return!e.includes("solana_signAndSendTransaction")&&!e.includes("solana_signTransaction")}createUiTransaction(e){return(0,r.__awaiter)(this,void 0,void 0,function*(){if(yield this.validateActiveWallet(e),this.isSendBalanceUnsupported())throw new h.DynamicError("Wallet does not support signing transactions. Please connect to a wallet that supports signing transactions.","wallet_does_not_support_signing_transactions");return new l.SolanaUiTransaction({connection:this.getWalletClient(),from:e,onSubmit:t=>(0,r.__awaiter)(this,void 0,void 0,function*(){var r;if(!t)return;let s=yield this.getWalletClient().getLatestBlockhash();return"version"in t?t.message.recentBlockhash=s.blockhash:(t.recentBlockhash=s.blockhash,t.feePayer=null!=(r=t.feePayer)?r:new i.PublicKey(e)),yield this.signAndSendTransaction(t)})})})}getSigner(){return(0,r.__awaiter)(this,void 0,void 0,function*(){return(0,I.createSolanaSignerForWalletConnect)({walletConnector:this})})}connect(){return(0,r.__awaiter)(this,void 0,void 0,function*(){throw Error("Connect method not implemented.")})}static globalInit(e){return(0,r.__awaiter)(this,void 0,void 0,function*(){var t,r;A.signClientPromise=(0,b.getSignClientSingleton)({appIcon:null!=(t=e.appLogoUrl)?t:"",appName:null!=(r=e.appName)?r:"",projectId:e.projectId,redirectUrl:e.redirectUrl}),A.signClientReference=yield A.signClientPromise,A.signClientReference.on("session_event",e=>{A.sessionEventListeners.forEach(t=>{t(e)})})})}static testOnly__reset(){A.signClientPromise=void 0,A.signClientReference=void 0,A.sessionEventListeners=[]}init(){return(0,r.__awaiter)(this,void 0,void 0,function*(){var e,t,r,i;if(!this.isInitialized){if(S.logger.logVerboseTroubleshootingMessage("[SolanaWalletConnect] init called"),this.isInitialized=!0,!(null!=(i=null==(r=null==(t=null==(e=this.constructorProps.settings)?void 0:e.sdk)?void 0:t.walletConnect)?void 0:r.v2Enabled)&&i))return void S.logger.logVerboseTroubleshootingMessage("[SolanaWalletConnect] skipping init - WalletConnect is not enabled in project settings");if(A.signClientPromise){yield A.signClientPromise,this.setupWCEventListeners();return}yield A.globalInit(this.constructorProps),this.setupWCEventListeners()}})}handleSessionEvent({params:{event:e},topic:t}){var r,i;if(this.session&&t===this.session.topic){if("chainChanged"===e.name){let t=e.data,s=t;if("string"==typeof t&&t.startsWith("solana:")){let e=t.split(":")[1];
22s=null!=(i=null==(r=this.solNetworks.find(t=>t.genesisHash===e))?void 0:r.networkId.toString())?i:t}return(S.logger.debug("[SolanaWalletConnect] onChainChange",{chainId:s}),s===this.getNetworkId())?void S.logger.debug(`[SolanaWalletConnect] onChainChange - ignoring chainChanged event with same chain id as current chain id: ${s}`):void this.switchNetwork({networkChainId:parseInt(String(s))})}if("accountsChanged"===e.name){let t=e.data,r=(0,f.filterDuplicates)(t.map(e=>e.startsWith("solana:")?e.split(":")[2]:e));S.logger.debug("[SolanaWalletConnect] onAccountChanged",{accounts:r}),this.emit("accountChange",{accounts:r});return}if("disconnected"===e.name){S.logger.debug("[SolanaWalletConnect] onDisconnect"),this.emit("disconnect"),this.endSession();return}}}setupWCEventListeners(){A.sessionEventListeners.push(e=>this.handleSessionEvent(e))}endSession(){return(0,r.__awaiter)(this,void 0,void 0,function*(){(S.logger.debug("[SolanaWalletConnect] endSession"),this.connectionUri=void 0,this.session)?(yield this.signClient.disconnect({reason:s.SDK_ERRORS.USER_DISCONNECTED,topic:this.session.topic}),this.session=void 0,this.pendingPairingTopic=void 0):yield this.disconnectPendingPairing()})}disconnectPendingPairing(){return(0,r.__awaiter)(this,void 0,void 0,function*(){let e=this.pendingPairingTopic;if(e){this.pendingPairingTopic=void 0;try{yield this.signClient.core.pairing.disconnect({topic:e})}catch(t){S.logger.warn("[SolanaWalletConnect] Failed to disconnect pending pairing",{errorMessage:t instanceof Error?t.message:String(t),topic:e})}}})}displayUri(e){return(0,r.__awaiter)(this,void 0,void 0,function*(){this.connectionUri&&(S.logger.debug("[SolanaWalletConnect] handleDisplayURI",this.connectionUri),yield(0,w.performPlatformSpecificConnectionMethod)(this.connectionUri,this.metadata.deepLinks,{onDesktopUri:null==e?void 0:e.onDesktopUri,onDisplayUri:null==e?void 0:e.onDisplayUri},this.deepLinkPreference,this.constructorProps.redirectUrl))})}getAddress(e){return(0,r.__awaiter)(this,void 0,void 0,function*(){var t;if(S.logger.debug("[SolanaWalletConnect] getAddress",e),this.session)return this.getActiveAddress();if(this.connectionUri){S.logger.debug("[SolanaWalletConnect] getAddress - connecting to WalletConnect with existing connection URI"),yield this.displayUri(e);return}if(S.logger.logVerboseTroubleshootingMessage("[WalletConnectConnector] getAddress",{inAppBrowserUrl:null==(t=this.metadata)?void 0:t.inAppBrowserUrl,isMobile:(0,p.isMobile)(),mobileExperience:this.mobileExperience}),this.openInAppBrowserIfRequired())return;S.logger.debug("[SolanaWalletConnect] getAddress - connecting to WalletConnect");let r=this.solNetworks.map(e=>`solana:${e.genesisHash}`),i=yield A.signClientPromise;if(!i)throw new h.DynamicError("Failed to access sign client for Wallet Connect Solana: Sign client not initialized","access_sign_client_for_wallet_connect");try{let{approval:t,uri:s}=yield i.connect({optionalNamespaces:{solana:{chains:r,events:["chainChanged","accountsChanged","disconnected"],methods:["solana_signMessage","solana_signTransaction","solana_requestAccounts","solana_getAccounts","solana_signAllTransactions","solana_signAndSendTransaction"]}}});S.logger.debug("[SolanaWalletConnect] getAddress - connection URI",s),this.connectionUri=s,this.pendingPairingTopic=(0,E.parsePairingTopicFromUri)(s),yield this.displayUri(e),this.session=yield t(),this.pendingPairingTopic=void 0;let n=this.getActiveAddress();return this.activeAccountEmitter.emit("activeAccountDidChange",n),n}finally{this.connectionUri=void 0}})}signClientRequest(e){return(0,r.__awaiter)(this,arguments,void 0,function*({method:e,params:t}){var r,i;if(!this.session)throw new h.DynamicError("Session not initialized. Please connect to a wallet first.","session_not_initialized_please_connect_to");let s=null!=(i=null==(r=this.getSelectedNetwork())?void 0:r.genesisHash)?i:this.solNetworks[0].genesisHash,n=`solana:${s}`;try{let r=this.signClient.request({chainId:n,request:{method:e,params:t},topic:this.session.topic});return this.deepLinkIfApplicable({method:e}),yield r}catch(e){if("An error has occured. Please, try again."===e.message)throw yield this.endSession(),new h.DynamicError("Wallet connection lost. Please, try again.","wallet_connection_lost_please_try_again");throw e}})}
22deepLinkIfApplicable(e){let t=this.getDeepLink();if((0,p.isMobile)()&&t&&["solana_signMessage","solana_signTransaction","solana_signAllTransactions","solana_signAndSendTransaction"].includes(e.method)){let e=g.PlatformService.getUrl();y.walletReturnRoute.set(e.pathname),g.PlatformService.openURL(t)}}signMessage(e,t){return(0,r.__awaiter)(this,void 0,void 0,function*(){S.logger.logVerboseTroubleshootingMessage("[SolanaWalletConnect] signMessage",e,t);let r=new TextEncoder().encode(e),i=yield this.signEncodedMessage(r,t);return(0,m.bufferToBase64)(i)})}signEncodedMessage(e,t){return(0,r.__awaiter)(this,void 0,void 0,function*(){S.logger.logVerboseTroubleshootingMessage("[SolanaWalletConnect] signEncodedMessage",e,t),(null==t?void 0:t.address)&&(yield this.validateActiveWallet(t.address));let r=this.getActiveAddress();if(!r)throw new h.DynamicError("No active address found","no_active_address_found");let{signature:s}=yield this.signClientRequest({method:"solana_signMessage",params:{message:n.default.encode(e),pubkey:new i.PublicKey(r).toBase58()}});return n.default.decode(s)})}serializeTransaction(e){let r=e.serialize({requireAllSignatures:!1,verifySignatures:!1});return t.Buffer.from(new Uint8Array(r)).toString("base64")}signTransaction(e){return(0,r.__awaiter)(this,void 0,void 0,function*(){let t=this.getActiveAddress();if(!t)throw new h.DynamicError("Active account address is required","active_account_address_is_required");S.logger.debug("[SolanaWalletConnect] Signing transaction",{activeAddress:t,isVersioned:"version"in e,transaction:e});let r=this.serializeTransaction(e);S.logger.debug("[SolanaWalletConnect] Sending to wallet for signing",{serializedLength:r.length});let{signature:s}=yield this.signClientRequest({method:"solana_signTransaction",params:{transaction:r}});S.logger.debug("[SolanaWalletConnect] Received transaction signature from wallet",{signature:s});let o=n.default.decode(s);return e.addSignature(new i.PublicKey(t),o),e})}signAllTransactions(e){return(0,r.__awaiter)(this,void 0,void 0,function*(){let r=e.map(this.serializeTransaction),{transactions:s}=yield this.signClientRequest({method:"solana_signAllTransactions",params:{transactions:r}});return s.map((r,s)=>{let n=e[s],o=new Uint8Array(t.Buffer.from(r,"base64"));return(0,c.isVersionedTransaction)(n)?i.VersionedTransaction.deserialize(o):i.Transaction.from(o)})})}signAndSendTransaction(e,t){return(0,r.__awaiter)(this,void 0,void 0,function*(){let r=this.getAvailableMethods();if(r.includes("solana_signAndSendTransaction")){let r=this.serializeTransaction(e),{signature:i}=yield this.signClientRequest({method:"solana_signAndSendTransaction",params:{sendOptions:t,transaction:r}});return i}if(r.includes("solana_signTransaction")){S.logger.debug("[SolanaWalletConnect] Using fallback: signTransaction + sendRawTransaction");let r=yield this.signTransaction(e),i=(0,u.isTxAlreadySigned)(r);if(S.logger.debug("[SolanaWalletConnect] Transaction signed, checking signatures",{hasSignatures:"signatures"in r&&r.signatures.length>0,isSigned:i,signaturesLength:"signatures"in r?r.signatures.length:"N/A"}),!i)throw new h.DynamicError("Transaction returned from wallet was not properly signed. The wallet may have rejected the signing request.","transaction_returned_from_wallet_was_not");let s=r.serialize();S.logger.debug("[SolanaWalletConnect] Transaction serialized",{serializedLength:s.length});let n=yield this.getWalletClient().sendRawTransaction(s,t);return S.logger.debug("[SolanaWalletConnect] Transaction sent successfully",{signature:n}),n}throw new h.DynamicError("Wallet does not support signing and sending transactions. Please connect to a wallet that supports at least solana_signTransaction.","wallet_does_not_support_signing_and")})}getDeepLink(){let e=(0,v.getDeepLink)({deepLinks:this.metadata.deepLinks,mode:"regular",preference:this.deepLinkPreference});if(S.logger.logVerboseTroubleshootingMessage("[SolanaWalletConnect] getDeepLink - deepLink",e),e)return this.session?`${e}?sessionTopic=${this.session.topic}`:e}getConnectedAccounts(){return(0,r.__awaiter)(this,void 0,void 0,function*(){let e=this.getActiveAddress();return e?(S.logger.logVerboseTroubleshootingMessage("[SolanaWalletConnect] getConnectedAccounts - activeAccounts",[e]),[e]):(S.logger.logVerboseTroubleshootingMessage("[SolanaWalletConnect] getConnectedAccounts - no activeAccounts, returning empty array"),[])})}getConnectionUri(){return this.connectionUri}validateActiveWallet(e){return(0,r.__awaiter)(this,void 0,void 0,function*(){S.logger.debug("[SolanaWalletConnect] validateActiveWallet - validating wallet",e);let[t]=yield this.getConnectedAccounts();return(0,_.isSameAddress)(t,e,this.connectedChain)?void S.logger.debug("[SolanaWalletConnect] validateActiveWallet - wallet is active"):this.handleWalletNotActive({activeAddress:t,expectedAddress:e})})}}A.sessionEventListeners=[],e.s(["SolanaWalletConnectConnector",0,A])},581825,e=>{"use strict";var t=e.i(115349),r=e.i(127261);e.i(484200);var i=e.i(510137),s=e.i(319050);e.i(973402);var n=e.i(55130),o=e.i(22439);e.i(303778);var a=e.i(114800),l=e.i(61176),c=e.i(14129),u=e.i(779772),d=e.i(926497);class h extends i.SolanaWalletConnector{constructor(){super(...arguments),this.walletConnectWalletBookEntry=void 0}getMobileOrInstalledWallet(){let e=this.walletConnectWalletBookEntry&&this.constructorProps.projectId;if(u.logger.logVerboseTroubleshootingMessage("[SOL InjectedWalletBase] getMobileOrInstalledWallet",{canUseWalletConnect:e,isInstalledOnBrowser:this.isInstalledOnBrowser(),projectId:this.constructorProps.projectId,walletConnectWalletBookEntry:this.walletConnectWalletBookEntry}),this.isInstalledOnBrowser()||!e)return this;let t=new d.SolanaWalletConnectConnector(Object.assign(Object.assign({},this.constructorProps),{metadata:(0,a.getWalletMetadataFromWalletBook)(Object.assign(Object.assign({},this.metadata),{walletBook:this.walletBook,walletBookWallet:this.walletConnectWalletBookEntry,walletKey:this.key})),overrideKey:this.key,walletName:this.name}));return t.init(),t}get solProviderHelper(){return this._solProviderHelper||(this._solProviderHelper=new l.SolProviderHelper(this)),this._solProviderHelper}findProvider(){var e;return null==(e=this.solProviderHelper)?void 0:e.getInstalledProvider()}setupEventListeners(){var e;null==(e=this.solProviderHelper)||e._setupEventListeners()}teardownEventListeners(){var e;null==(e=this.solProviderHelper)||e._teardownEventListeners()}connect(){return(0,t.__awaiter)(this,void 0,void 0,function*(){var e;yield null==(e=this.solProviderHelper)?void 0:e.connect()})}getSigner(){return(0,t.__awaiter)(this,void 0,void 0,function*(){var e;let t=yield null==(e=this.solProviderHelper)?void 0:e.connect();if(t)return t;if((0,n.isMobile)()&&!this.isInstalledOnBrowser()&&!this.openInAppBrowserIfRequired())throw new o.WalletRequiresInAppBrowserError(this.name)})}createUiTransaction(e){return(0,t.__awaiter)(this,void 0,void 0,function*(){return yield this.validateActiveWallet(e),new s.SolanaUiTransaction({connection:this.getWalletClient(),from:e,onSubmit:e=>(0,t.__awaiter)(this,void 0,void 0,function*(){var t;if(!e)return;
22let i=yield this.getSigner();if(!i)throw Error("Signer not found");let s=yield this.getWalletClient().getLatestBlockhash();if("version"in e)e.message.recentBlockhash=s.blockhash;else{let i=yield this.getAddress();if(!i)throw Error("User address not found");e.recentBlockhash=s.blockhash,e.feePayer=null!=(t=e.feePayer)?t:new r.PublicKey(i)}return(yield i.signAndSendTransaction(e)).signature})})})}isInstalledOnBrowser(){var e;return!!(null==(e=this.solProviderHelper)?void 0:e.isInstalledHelper())}getAddress(){return(0,t.__awaiter)(this,void 0,void 0,function*(){var e;if(!this.openInAppBrowserIfRequired())return null==(e=this.solProviderHelper)?void 0:e.getAddress()})}signMessage(e){return(0,t.__awaiter)(this,void 0,void 0,function*(){var t;let r=yield this.getAddress();if(r){if(this.isLedgerAddress(r))throw new c.SignMessageNotSupportedError(this.name);return null==(t=this.solProviderHelper)?void 0:t.signMessage(e)}})}getConnectedAccounts(){return(0,t.__awaiter)(this,void 0,void 0,function*(){var e,t;return null!=(t=null==(e=this.solProviderHelper)?void 0:e.getConnectedAccounts())?t:[]})}}e.s(["InjectedWalletBase",0,h])},883170,e=>{"use strict";var t=e.i(467034),r=e.i(115349);e.i(973402);var i=e.i(951664),s=e.i(123785);e.i(900373);var n=e.i(103388),o=e.i(581825);class a extends o.InjectedWalletBase{constructor(e){super(e),this.name="Backpack",this.overrideKey="backpacksol",this.walletConnectWalletBookEntry=(0,n.findWalletBookWallet)(e.walletBook,this.key)}getSigner(){let e=Object.create(null,{getSigner:{get:()=>super.getSigner}});return(0,r.__awaiter)(this,void 0,void 0,function*(){return e.getSigner.call(this)})}findProvider(){let[e]=(0,i.getProvidersFromWindow)("backpack.solana");return(null==e?void 0:e.isBackpack)?e:super.findProvider()}getConnectedAccounts(){return(0,r.__awaiter)(this,void 0,void 0,function*(){var e;let t=this.findProvider();if(!(null==t?void 0:t.isConnected))return[];let r=null==(e=t.publicKey)?void 0:e.toString();return r?[r]:[]})}signMessage(e){return(0,r.__awaiter)(this,void 0,void 0,function*(){if(!(yield this.getAddress()))return;let r=yield this.getSigner();if(!r)return;let i=yield r.signMessage(t.Buffer.from(e,"utf8"));if(i)return"object"==typeof i&&"signature"in i?(0,s.bufferToBase64)(i.signature):(0,s.bufferToBase64)(i)})}}Object.defineProperty(a,"key",{value:"backpacksol",writable:!1}),e.s(["BackpackSol",0,a])},429985,e=>{"use strict";e.i(303778);var t=e.i(890357);e.i(973402);var r=e.i(415565);let i=e=>{let t=/^https?:\/\//i.test(e);r.PlatformService.openURL(e,t?"blank":"self")};class s{constructor(){throw Error("MetaMaskSolanaSdkClient is not instantiable")}}s.client=null,s.wallet=null,s.multichainCore=null,s.initPromise=null,s.connectUri=null,s.isInitialized=!1,s.init=async e=>{if(!s.isInitialized){if(s.initPromise)return s.initPromise;s.initPromise=s.doInit(e);try{await s.initPromise}finally{s.initPromise=null}}},s.doInit=async n=>{try{var o,a;let{createSolanaClient:l}=await e.A(684780),c=await l({dapp:{name:null!=(o=n.dappName)?o:"Dynamic",url:null!=(a=n.dappUrl)?a:r.PlatformService.getOrigin()},analytics:{integrationType:"dynamic"},skipAutoRegister:!1}),u=c.getWallet();s.client=c,s.wallet=u,s.multichainCore=c.core,s.isInitialized=!0,c.core.mergeOptions({ui:{headless:!0},mobile:{preferredOpenLink:i,useDeeplink:!0}}),c.core.on("display_uri",e=>{e.includes("://connect")&&(s.connectUri=e)}),t.logger.debug("[MetaMaskSolanaSdkClient] init complete")}catch(r){let e=r instanceof Error?r.message:String(r);throw t.logger.error("[MetaMaskSolanaSdkClient] Failed to initialize:",e),r}},s.getWallet=()=>s.wallet,s.getCore=()=>s.multichainCore,s.onDisplayUri=e=>{let t=s.multichainCore;return t?(t.on("display_uri",e),()=>t.off("display_uri",e)):()=>{}},s.getConnectUri=()=>{var e;return null!=(e=s.connectUri)?e:void 0},s.retryDeepLink=()=>{let e=s.connectUri;e&&i(e)},s.getAccounts=()=>{var e,t;return null!=(t=null==(e=s.wallet)?void 0:e.accounts.map(e=>e.address))?t:[]},s.getSelectedAccount=()=>{var e,t;return null==(t=s.wallet)||null==(e=t.accounts[0])?void 0:e.address},s.connect=async()=>{var e;let t=s.wallet;if(!t)throw Error("[MetaMaskSolanaSdkClient] Not initialized. Call init() first.");let r=t.accounts[0];if(r)return r.address;let i=null==(e=t.features["standard:connect"])?void 0:e.connect;if(!i)throw Error("[MetaMaskSolanaSdkClient] Wallet does not support standard:connect");let n=(await i({silent:!1})).accounts[0];return null==n?void 0:n.address},s.disconnect=async()=>{let e=s.client;if(e)try{await e.disconnect()}catch(e){}},s.reset=()=>{s.client=null,s.wallet=null,s.multichainCore=null,s.isInitialized=!1,s.initPromise=null,s.connectUri=null},e.s(["MetaMaskSolanaSdkClient",0,s])},203058,e=>{"use strict";e.s(["default",0,function(e){if(e.length>=255)throw TypeError("Alphabet too long");let t=new Uint8Array(256);for(let e=0;e<t.length;e++)t[e]=255;for(let r=0;r<e.length;r++){let i=e.charAt(r),s=i.charCodeAt(0);if(255!==t[s])throw TypeError(i+" is ambiguous");t[s]=r}let r=e.length,i=e.charAt(0),s=Math.log(r)/Math.log(256),n=Math.log(256)/Math.log(r);function o(e){if("string"!=typeof e)throw TypeError("Expected String");if(0===e.length)return new Uint8Array;let n=0,o=0,a=0;for(;e[n]===i;)o++,n++;let l=(e.length-n)*s+1>>>0,c=new Uint8Array(l);for(;n<e.length;){let i=e.charCodeAt(n);if(i>255)return;let s=t[i];if(255===s)return;let o=0;for(let e=l-1;(0!==s||o<a)&&-1!==e;e--,o++)s+=r*c[e]>>>0,c[e]=s%256>>>0,s=s/256>>>0;if(0!==s)throw Error("Non-zero carry");a=o,n++}let u=l-a;for(;u!==l&&0===c[u];)u++;let d=new Uint8Array(o+(l-u)),h=o;for(;u!==l;)d[h++]=c[u++];return d}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw TypeError("Expected Uint8Array");if(0===t.length)return"";let s=0,o=0,a=0,l=t.length;for(;
22a!==l&&0===t[a];)a++,s++;let c=(l-a)*n+1>>>0,u=new Uint8Array(c);for(;a!==l;){let e=t[a],i=0;for(let t=c-1;(0!==e||i<o)&&-1!==t;t--,i++)e+=256*u[t]>>>0,u[t]=e%r>>>0,e=e/r>>>0;if(0!==e)throw Error("Non-zero carry");o=i,a++}let d=c-o;for(;d!==c&&0===u[d];)d++;let h=i.repeat(s);for(;d<c;++d)h+=e.charAt(u[d]);return h},decodeUnsafe:o,decode:function(e){let t=o(e);if(t)return t;throw Error("Non-base"+r+" character")}}}])},305393,e=>{"use strict";let t=(0,e.i(203058).default)("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");e.s(["default",0,t])},274771,e=>{"use strict";var t=e.i(127261),r=e.i(305393);e.s(["createWalletStandardAdapter",0,function(e,i){let s=e.features,n=()=>{let t=e.accounts[0];if(!t)throw Error("[WalletStandardAdapter] No connected account");return t},o=()=>{let e=i();return`solana:${e}`},a=async e=>{var r;let i=null==(r=s["solana:signTransaction"])?void 0:r.signTransaction;if(!i)throw Error("[WalletStandardAdapter] solana:signTransaction not supported");let a=n(),l=o(),c=e.map(e=>({account:a,chain:l,transaction:Uint8Array.from(e.serialize({requireAllSignatures:!1}))})),u=await i(...c);return e.map((e,r)=>{var i;let s=null==(i=u[r])?void 0:i.signedTransaction;if(!s)throw Error("[WalletStandardAdapter] No signed transaction returned");return"instructions"in e?t.Transaction.from(s):t.VersionedTransaction.deserialize(s)})},l=async e=>{let[t]=await a([e]);if(!t)throw Error("[WalletStandardAdapter] No signed transaction returned");return t},c=async e=>{var t,i;let a=null==(t=s["solana:signAndSendTransaction"])?void 0:t.signAndSendTransaction;if(!a)throw Error("[WalletStandardAdapter] solana:signAndSendTransaction not supported");let l=n(),c=e.serialize({requireAllSignatures:!1}),u=null==(i=(await a({account:l,chain:o(),transaction:Uint8Array.from(c)}))[0])?void 0:i.signature;if(!u)throw Error("[WalletStandardAdapter] No signature returned");return{signature:r.default.encode(u)}},u=async e=>{var t,r;let i=null==(t=s["solana:signMessage"])?void 0:t.signMessage;if(!i)throw Error("[WalletStandardAdapter] solana:signMessage not supported");let o=n(),a=null==(r=(await i({account:o,message:e}))[0])?void 0:r.signature;if(!a)throw Error("[WalletStandardAdapter] No signature returned");return{signature:a}},d=()=>{};return{addListener:d,connect:async()=>{var t;let r=e.accounts[0];if(r)return{address:r.address,publicKey:r.publicKey};let i=null==(t=s["standard:connect"])?void 0:t.connect;if(!i)throw Error("[WalletStandardAdapter] standard:connect not supported");let n=await i({silent:!1});if(n.accounts[0])return{address:n.accounts[0].address,publicKey:n.accounts[0].publicKey}},disconnect:async()=>{var e;let t=null==(e=s["standard:disconnect"])?void 0:e.disconnect;t&&await t()},emit:d,eventNames:()=>[],isBackpack:!1,isBraveWallet:!1,isConnected:e.accounts.length>0,isExodus:!1,isGlow:!1,isMagicEden:!1,isPhantom:!1,isSolflare:!1,listenerCount:()=>0,listeners:()=>[],off:d,on:(e,t)=>{var r;let i=null==(r=s["standard:events"])?void 0:r.on;if(i&&"accountChanged"===e)return i("change",e=>{var r,i;let s=null==(i=e.accounts)||null==(r=i[0])?void 0:r.publicKey;s&&t(new TextDecoder().decode(s))})},once:d,providers:[],get publicKey(){let r=e.accounts[0];if(!(null==r?void 0:r.publicKey))return;return new t.PublicKey(r.publicKey)},removeAllListeners:d,removeListener:d,signAllTransactions:a,signAndSendTransaction:c,signMessage:u,signTransaction:l}}])},411915,e=>{"use strict";e.i(303778);var t=e.i(580718),r=e.i(890357);e.i(484200);var i=e.i(510137),s=e.i(429985),n=e.i(274771);function o(){return(o=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e}).apply(this,arguments)}class a extends i.SolanaWalletConnector{isInstalledOnBrowser(){if("u"<typeof window)return!1;let e=window.ethereum;return!!(null==e?void 0:e.isMetaMask)}
22async init(){this.walletConnectorEventsEmitter.emit("connectorInitStarted",this.overrideKey);try{await s.MetaMaskSolanaSdkClient.init({dappName:"Dynamic"})}catch(e){r.logger.error("[MetaMaskSolanaWalletConnector] SDK init failed:",e)}this.walletConnectorEventsEmitter.emit("connectorInitCompleted",this.overrideKey)}setupEventListeners(){var e;let r=s.MetaMaskSolanaSdkClient.getWallet();if(!r)return;let i=null==(e=r.features["standard:events"])?void 0:e.on;if(!i)return;let{handleAccountChange:n}=(0,t.eventListenerHandlers)(this),o=i("change",e=>{e.accounts&&n(e.accounts.map(e=>e.address))});this.teardownEventListeners=()=>{o()}}async connect(){s.MetaMaskSolanaSdkClient.isInitialized||await this.init(),await s.MetaMaskSolanaSdkClient.connect(),this.signer=this.buildSigner()}async getSigner(){return this.signer||(this.signer=this.buildSigner()),this.signer}async signMessage(e){let t=await this.getSigner();if(!t)return;let r=new TextEncoder().encode(e),i=await t.signMessage(r),s=null==i?void 0:i.signature;if(s){let e="";for(let t of s)e+=String.fromCharCode(t);return btoa(e)}}async getAddress(e){let t=s.MetaMaskSolanaSdkClient.getSelectedAccount();if(t)return t;s.MetaMaskSolanaSdkClient.isInitialized||await this.init();let r=(null==e?void 0:e.onDisplayUri)?s.MetaMaskSolanaSdkClient.onDisplayUri(e.onDisplayUri):void 0;try{return await s.MetaMaskSolanaSdkClient.connect()}finally{null==r||r()}}async getConnectedAccounts(){if(!s.MetaMaskSolanaSdkClient.isInitialized)try{await this.init()}catch(e){}let e=s.MetaMaskSolanaSdkClient.getAccounts();if(e.length)return e;let t=s.MetaMaskSolanaSdkClient.getWallet();if(t)try{var r;let e=null==(r=t.features["standard:connect"])?void 0:r.connect;if(e){let t=await e({silent:!0});if(t.accounts.length)return t.accounts.map(e=>e.address)}}catch(e){}return[]}async endSession(){null==this.teardownEventListeners||this.teardownEventListeners.call(this),this.signer=void 0,await s.MetaMaskSolanaSdkClient.disconnect()}retryDeeplinkConnection(){s.MetaMaskSolanaSdkClient.retryDeepLink()}buildSigner(){let e=s.MetaMaskSolanaSdkClient.getWallet();if(r.logger.logVerboseTroubleshootingMessage("[MetaMaskSolanaWalletConnector] buildSigner",{wallet:e}),e)return(0,n.createWalletStandardAdapter)(e,()=>{var e;let t=this.getSelectedNetwork();return null!=(e=null==t?void 0:t.cluster)?e:"mainnet"})}constructor(e){super(o({},e,{metadata:{id:"metamasksol",name:"MetaMask",icon:"https://iconic.dynamic-static-assets.com/icons/sprite.svg#metamask",groupKey:"metamask"}})),this.name="MetaMask",this.overrideKey="metamasksol",this.canConnectViaQrCode=!0,this.canHandleMultipleConnections=!1}}e.s(["MetaMaskSolanaWalletConnector",0,a])},535315,e=>{"use strict";var t=e.i(411915);e.s(["MetaMaskSolanaWalletConnectors",0,e=>[t.MetaMaskSolanaWalletConnector]])},726138,e=>{"use strict";e.s(["version",0,"4.93.0"])},572505,e=>{"use strict";"function"==typeof SuppressedError&&SuppressedError,e.s(["__awaiter",0,function(e,t,r,i){return new(r||(r=Promise))(function(s,n){function o(e){try{l(i.next(e))}catch(e){n(e)}}function a(e){try{l(i.throw(e))}catch(e){n(e)}}function l(e){var t;e.done?s(e.value):((t=e.value)instanceof r?t:new r(function(e){e(t)})).then(o,a)}l((i=i.apply(e,t||[])).next())})},"__rest",0,function(e,t){var r={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&0>t.indexOf(i)&&(r[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var s=0,i=Object.getOwnPropertySymbols(e);s<i.length;s++)0>t.indexOf(i[s])&&Object.prototype.propertyIsEnumerable.call(e,i[s])&&(r[i[s]]=e[i[s]]);return r}])},846610,e=>{"use strict";var t=e.i(467034),r=e.i(127261);e.i(94007);var i=e.i(285942),s=e.i(346653);e.s(["TurnkeySigner",0,class{constructor(e){this.organizationId=e.organizationId,this.client=e.client}async signAllTransactions(e,i,s){let n=new r.PublicKey(i),o=e.map(e=>this.getMessageToSign(e).toString("hex")),a=await this.signRawPayloads(o,i,s),l=a?.signatures?.map(e=>`${e?.r}${e?.s}`);for(let r in e)e[r]?.addSignature(n,t.Buffer.from(l[r],"hex"));return e}async addSignature(e,i,s){let n=new r.PublicKey(i),o=this.getMessageToSign(e),a=await this.signRawPayload(o.toString("hex"),i,s??this.organizationId),l=`${a?.r}${a?.s}`;e.addSignature(n,t.Buffer.from(l,"hex"))}async signMessage(e,r,i){let s=await this.signRawPayload(t.Buffer.from(e).toString("hex"),r,i);return t.Buffer.from(`${s?.r}${s?.s}`,"hex")}async signTransaction(e,i,s){let n=t.Buffer.from(e.serialize({requireAllSignatures:!1,verifySignatures:!1})).toString("hex"),o=await this.signTransactionImpl(n,i,s),a=t.Buffer.from(o,"hex");return"version"in e?r.VersionedTransaction.deserialize(a):r.Transaction.from(a)}
22async signTransactionImpl(e,t,r){if((0,i.isHttpClient)(this.client)){let{activity:i}=await this.client.signTransaction({type:"ACTIVITY_TYPE_SIGN_TRANSACTION_V2",organizationId:r??this.organizationId,timestampMs:String(Date.now()),parameters:{signWith:t,unsignedTransaction:e,type:"TRANSACTION_TYPE_SOLANA"}});return(0,s.assertActivityCompleted)(i),(0,s.assertNonNull)(i?.result?.signTransactionResult?.signedTransaction)}{let{activity:i,signedTransaction:n}=await this.client.signTransaction({...void 0!==r&&{organizationId:r},signWith:t,unsignedTransaction:e,type:"TRANSACTION_TYPE_SOLANA"});return(0,s.assertActivityCompleted)(i),(0,s.assertNonNull)(n)}}async signRawPayload(e,t,r){if((0,i.isHttpClient)(this.client)){let{activity:i}=await this.client.signRawPayload({type:"ACTIVITY_TYPE_SIGN_RAW_PAYLOAD_V2",organizationId:r??this.organizationId,timestampMs:String(Date.now()),parameters:{signWith:t,payload:e,encoding:"PAYLOAD_ENCODING_HEXADECIMAL",hashFunction:"HASH_FUNCTION_NOT_APPLICABLE"}});return(0,s.assertActivityCompleted)(i),(0,s.assertNonNull)(i?.result?.signRawPayloadResult)}{let{activity:i,r:n,s:o,v:a}=await this.client.signRawPayload({...void 0!==r&&{organizationId:r},signWith:t,payload:e,encoding:"PAYLOAD_ENCODING_HEXADECIMAL",hashFunction:"HASH_FUNCTION_NOT_APPLICABLE"});return(0,s.assertActivityCompleted)(i),(0,s.assertNonNull)({r:n,s:o,v:a})}}async signRawPayloads(e,t,r){if((0,i.isHttpClient)(this.client)){let{activity:i}=await this.client.signRawPayloads({type:"ACTIVITY_TYPE_SIGN_RAW_PAYLOADS",organizationId:r??this.organizationId,timestampMs:String(Date.now()),parameters:{signWith:t,payloads:e,encoding:"PAYLOAD_ENCODING_HEXADECIMAL",hashFunction:"HASH_FUNCTION_NOT_APPLICABLE"}});return(0,s.assertActivityCompleted)(i),(0,s.assertNonNull)(i?.result?.signRawPayloadsResult)}{let{activity:i,signatures:n}=await this.client.signRawPayloads({...void 0!==r&&{organizationId:r},signWith:t,payloads:e,encoding:"PAYLOAD_ENCODING_HEXADECIMAL",hashFunction:"HASH_FUNCTION_NOT_APPLICABLE"});return(0,s.assertActivityCompleted)(i),(0,s.assertNonNull)({signatures:n})}}getMessageToSign(e){return"function"==typeof e.serializeMessage?e.serializeMessage():t.Buffer.from(e.message.serialize())}}])},528577,e=>{"use strict";var t=e.i(624211);class r extends t.DynamicError{constructor(e){super(`Transaction failed: ${JSON.stringify(e)}`,"transaction_failed"),this.chainError=e}}e.s(["TransactionFailedError",0,r])},21439,e=>{"use strict";var t=e.i(127261);e.s(["createSolanaConnection",0,(e,r)=>{if(!e)throw Error("rpcUrl is required");return new t.Connection(e,r)}])},717231,e=>{"use strict";var t=e.i(467034),r=e.i(572505),i=e.i(127261);e.i(484622);var s=e.i(289339),n=e.i(598036),o=e.i(856109);e.i(973402);var a=e.i(751384);let l=e=>e instanceof i.VersionedTransaction?t.Buffer.from(new Uint8Array(e.serialize())).toString("base64"):t.Buffer.from(new Uint8Array(e.serialize({verifySignatures:!1}))).toString("base64"),c=e=>{let r=t.Buffer.from(e,"base64");return i.VersionedTransaction.deserialize(new Uint8Array(r))};e.s(["optimizeSolanaTransaction",0,(e,t,i)=>(0,r.__awaiter)(void 0,void 0,void 0,function*(){let r=l(t);return c((yield(0,o.createApiClient)({},(0,s.getDefaultClient)()).optimizeTransaction({environmentId:e,solanaTransactionOptimizationRequest:{address:i,transaction:r}})).transaction)}),"sponsorSolanaTransaction",0,(e,t)=>(0,r.__awaiter)(void 0,void 0,void 0,function*(){let r=l(t),i=(0,s.getDefaultClient)(),o=(0,n.getCore)(i),{legacyToken:u}=o.state.get(),d=`${o.apiBaseUrl}/sdk/${e}/solana/sponsorTransaction`;if(!u)throw Error("No auth token available for sponsoring transaction");let h=yield a.FetchService.fetch(d,{body:JSON.stringify({transaction:r}),credentials:"include",headers:{Authorization:`Bearer ${u}`,"Content-Type":"application/json"},method:"POST"});if(!h.ok)throw Error((yield h.json().catch(()=>({}))).error||`Failed to sponsor transaction: ${h.status}`);let f=yield h.json();if(!f.transaction)throw Error("Invalid API response: missing transaction field");return c(f.transaction)})])},209362,e=>{"use strict";var t=e.i(572505),r=e.i(127261);e.s(["TurnkeySolanaSigner",0,class{constructor({walletConnector:e}){this.isConnected=!0,this.providers=[this],this.walletConnector=e,this.turnkeyAddress=this.walletConnector.turnkeyAddress,this.publicKey=this.turnkeyAddress?new r.PublicKey(this.turnkeyAddress):void 0}signMessage(e){return(0,t.__awaiter)(this,void 0,void 0,function*(){return{signature:yield this.walletConnector.signUint8ArrayMessage(e)}})}signTransaction(e){return(0,t.__awaiter)(this,void 0,void 0,function*(){return this.walletConnector.signTransaction(e)})}signAllTransactions(e){return(0,t.__awaiter)(this,void 0,void 0,function*(){return this.walletConnector.signAllTransactions(e)})}signAndSendTransaction(e,r){return(0,t.__awaiter)(this,void 0,void 0,function*(){return{signature:yield this.walletConnector.signAndSendTransaction(e,r)}})}connect(e){return(0,t.__awaiter)(this,void 0,void 0,function*(){return{address:this.turnkeyAddress,publicKey:this.publicKey}})}disconnect(){return(0,t.__awaiter)(this,void 0,void 0,function*(){})}}])},113841,e=>{"use strict";var t=e.i(467034),r=e.i(572505),i=e.i(127261),s=e.i(854972),n=e.i(846610),o=e.i(721461);e.i(311317);var a=e.i(871186),l=e.i(798622),c=e.i(599364),u=e.i(1641);e.i(484200);var d=e.i(521162),h=e.i(204173),f=e.i(59081),p=e.i(58352),g=e.i(577709),y=e.i(319050),m=e.i(4502);e.i(973402);var b=e.i(624211),v=e.i(123785),w=e.i(528577),_=e.i(165948);e.i(303778);var S=e.i(13855),E=e.i(21439),I=e.i(717231),A=e.i(209362);class T extends a.TurnkeyWalletConnectorBase{constructor(e,t){var r;super(e,t),this.ChainWallet=d.SolanaWallet,this.connectedChain="SOL",this.supportedChains=["SOL"],this.verifiedCredentialChain="solana",this.getEnvId=()=>{let e=localStorage.getItem("dynamic_nonce");if(e){let t=JSON.parse(e);if(t&&t.environmentId)return t.environmentId}let t=localStorage.getItem("dynamic_nonce_demo");if(t){let e=JSON.parse(t);if(e&&e.environmentId)return e.environmentId}throw Error("Failed to get environment id")},this.solNetworks=(0,h.getBackwardsCompatibleSolNetworks)(t.solNetworks,t.connectionConfig),this.walletUiUtils=t.walletUiUtils,this._turnkeyAccount=void 0,this.connectionConfig=t.connectionConfig,this.chainRpcProviders=t.chainRpcProviders,null==(r=this.chainRpcProviders)||r.registerSolanaProvi
22ders(this.connectionConfig),this.getTurnkeyClient().then(e=>{this.__turnkeyClient=e})}getRpcUrl(){let e=this.getSelectedNetwork();if(!e)throw new b.DynamicError("No enabled networks","no_enabled_networks");return(0,f.getOverrideRpcUrlForNetwork)(this.connectionConfig,e)}getConnection(e){let t=this.getRpcUrl();if(!t)throw new b.DynamicError("No rpcUrl","no_rpc_url");let r="string"==typeof e?Object.assign(Object.assign({},this.connectionConfig),{commitment:e}):Object.assign(Object.assign({},this.connectionConfig),e);return(0,E.createSolanaConnection)(t,r)}getWalletClient(){return this.getConnection()}getNetworkId(){var e;let t=null==(e=this.solNetworks[0])?void 0:e.networkId.toString(),r=localStorage.getItem(p.DYNAMIC_SVM_NETWORK_ID_LS_KEY);return null!=r?r:t}setNetworkId(e){e?localStorage.setItem(p.DYNAMIC_SVM_NETWORK_ID_LS_KEY,e):localStorage.removeItem(p.DYNAMIC_SVM_NETWORK_ID_LS_KEY)}getSelectedNetwork(){return this.solNetworks.find(e=>e.networkId.toString()===this.getNetworkId())}getNetwork(){return(0,r.__awaiter)(this,arguments,void 0,function*(e=!1){let t=this.getSelectedNetwork();if(!t)return"";let{networkId:r,genesisHash:i}=t;return e?r.toString():"5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"===i?"mainnet":"4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z"===i?"testnet":"EtWTRABZaYq6iMfeYKouRu166VU2xqa1"===i?"devnet":r.toString()})}switchNetwork(e){return(0,r.__awaiter)(this,arguments,void 0,function*({networkChainId:e}){if(!e)return;let t=e.toString();this.solNetworks.some(e=>e.networkId.toString()===t)&&(this.setNetworkId(t),this.emit("chainChange",{chain:t}))})}getPublicClient(){return(0,r.__awaiter)(this,void 0,void 0,function*(){var e;let t=this.getSelectedNetwork();if(!t)return;let r=t.networkId.toString(),i={cosmos:[],evm:void 0,solana:this.solNetworks,starknet:void 0};if(!this.chainRpcProviders)return;let s=this.chainRpcProviders.getProviders(i);return null==(e=this.chainRpcProviders.getSolanaProviderByChainId(s,r))?void 0:e.provider})}supportsNetworkSwitching(){return!0}setVerifiedCredentials(e){let t=(0,l.findTurnkeyVerifiedCredentials)(e,g.ProviderChain.SOLANA),[r]=t;JSON.stringify(this.verifiedCredentials)!==JSON.stringify(t)&&(this.verifiedCredential=r,this.verifiedCredentials=t,this.refreshTurnkeyAccount())}validateActiveWallet(e){return(0,r.__awaiter)(this,void 0,void 0,function*(){var t,r;let i=(null==(t=this.verifiedCredential)?void 0:t.address)||"";if(!(0,S.isSameAddress)(i,e,this.connectedChain)){let t=null==(r=this.verifiedCredentials)?void 0:r.find(t=>(null==t?void 0:t.address)===e);if(!t)throw new b.DynamicError("Account not found","account_not_found");this.verifiedCredential=t,this.refreshTurnkeyAccount()}})}getAccount(){return this.turnkeyAddress}endSession(){return(0,r.__awaiter)(this,void 0,void 0,function*(){this.setNetworkId(null)})}refreshTurnkeyAccount(){return(0,r.__awaiter)(this,void 0,void 0,function*(){return this._turnkeyAccount=void 0,this.getTurnkeyAccount()})}createTurnkeyAccount(e){return(0,r.__awaiter)(this,arguments,void 0,function*({organizationId:e}){let t=yield this.getTurnkeyClient();return new n.TurnkeySigner({client:t,organizationId:e})})}getTurnkeyAccount(){return(0,r.__awaiter)(this,void 0,void 0,function*(){var e,t,r,i;if(this._turnkeyAccount&&("passkey"===this.getAuthenticatorHandler().recoveryType&&(null==(e=this.__turnkeyClient)?void 0:e.stamper)instanceof o.WebauthnStamper||"email"===this.getAuthenticatorHandler().recoveryType&&(null==(t=this.__turnkeyClient)?void 0:t.stamper)instanceof s.IframeStamper)&&this.__turnkeyClient===this.getAuthenticatorHandler().client)return this._turnkeyAccount;let{turnkeySubOrganizationId:n}=null!=(r=this.walletProperties)?r:{},{address:a}=null!=(i=this.verifiedCredential)?i:{};if(n&&a)return this._turnkeyAccount=yield this.createTurnkeyAccount({organizationId:n}),this.setLoggerMetadata(),this._turnkeyAccount})}getSigner(){return(0,r.__awaiter)(this,void 0,void 0,function*(){return new A.TurnkeySolanaSigner({walletConnector:this})})}getBalance(e){return(0,r.__awaiter)(this,void 0,void 0,function*(){let t=this.getConnection(),r=new i.PublicKey(e),s=yield t.getBalance(r);return this.lamportsToSol(s).toString()})}signUint8ArrayMessage(e){return(0,r.__awaiter)(this,void 0,void 0,function*(){let i;if(!this.turnkeyAddress)throw new b.DynamicError("No turnkey account","no_turnkey_account");let s=this.turnkeyAddress;if(yield this.createOrRestoreSession(),yield this.walletUiUtils.signMessage({handler:()=>(0,r.__awaiter)(this,void 0,void 0,function*(){var r;let n=yield this.getTurnkeyAccount();try{i=yield null==n?void 0:n.signMessage(e,s)}catch(t){yield this.removeSessionKeys(),yield this.createOrRestoreSession({ignoreRestore:!0}),n=yield this.getTurnkeyAccount(),i=yield null==n?void 0:n.signMessage(e,s),c.logger.error("[TK - removeSessionKeys] failed to perform signUint8ArrayMessage activity",{address:s,err:t,turnkeySubOrganizationId:null==(r=this.walletProperties)?void 0:r.turnkeySubOrganizationId})}return(0,v.bufferToBase64)(i||t.Buffer.from([]))}),message:new TextDecoder().decode(e)}),!i)throw Error("Failed to sign message");return i})}signMessage(e){return(0,r.__awaiter)(this,void 0,void 0,function*(){let t=new TextEncoder().encode(e),r=yield this.signUint8ArrayMessage(t);return(0,v.bufferToBase64)(r)})}internalSignTransaction(e){return(0,r.__awaiter)(this,void 0,void 0,function*(){var t;yield this.createOrRestoreSession();let r=yield this.getTurnkeyAccount(),i=this.turnkeyAddress;if(!r||!i)throw Error("No turnkey account");try{yield r.addSignature(e,i)}catch(s){if(u.TURNKEY_SDK_SESSION_KEY_RETRYABLE_ERRORS.some(e=>s.message.toLowerCase().includes(e.toLowerCase())))yield this.removeSessionKeys(),yield this.createOrRestoreSession({ignoreRestore:!0}),r=yield this.getTurnkeyAccount(),yield r.addSignature(e,i),c.logger.error("[TK - removeSessionKeys] failed to perform SignTransaction activity",{address:i,err:s,turnkeySubOrganizationId:null==(t=this.walletProperties)?void 0:t.turnkeySubOrganizationId});else throw c.logger.error("[TK] failed to perform SignTransaction activity",s),s}try{e.serialize({requireAllSignatures:!1})}catch(e){c.logger.error("[SignTransaction] likely invalid signature, failed to serialize",e)}return e})}signTransaction(e){return(0,r.__awaiter)(this,void 0,void 0,function*(){if(!this.turnkeyAddress)throw new b.DynamicError("No turnkey account","no_turnkey_account");let t=new y.SolanaUiTransaction({connection:this.getConnection("confirmed"),from:this.turnkeyAddress,multipleTransactions:[e],onSubmit:()=>(0,r.__awaiter)(this,void 0,void 0,function*(){return this.internalSignTransaction(e)})});return this.walletUiUtils.signTransaction(this,t)})}createUiTransaction(e){return(0,r.__awaiter)(this,void 0,void 0,function*(){return yield this.validateActiveWallet(e),new y.SolanaUiTransaction({connection:this.getConnection("confirmed"),from:e,onSubmit:e=>(0,r.__awaiter)(this,void 0,void 0,function*(){if(e)return this.internalSignAndSendTransaction(e)})})})}internalSignAllTransactions(e){return(0,r.__awaiter)(this,void 0,void 0,function*(){var t;let r;yield this.createOrRestoreSession();let i=yield this.getTurnkeyAccount(),s=this.turnkeyAddress;if(!i||!s)throw Error("No turnkey account");try{r=yield i.signAllTransactions(e,s)}catch(n){if(u.TURNKEY_SDK_SESSION_KEY_RETRYABLE_ERRORS.some(e=>n.message.toLowerCase().includes(e.toLowerCase())))yield this.removeSessionKeys(),yield this.createOrRestoreSession({ignoreRestore:!0}),i=yield this.getTurnkeyAccount(),r=yield i.signAllTransactions(e,s),c.logger.error("[TK - removeSessionKeys] failed to perform SignAllTransactions activity",{address:s,err:n,turnkeySubOrganizationId:null==(t=this.walletProperties)?void 0:t.turnkeySubOrganizationId});else throw c.logger.error("[TK] failed to perform SignAllTransactions activity",n),n}
22try{r.forEach(e=>{e.serialize({requireAllSignatures:!1})})}catch(e){c.logger.error("[SignAllTransactions] likely invalid signature, failed to serialize",e)}return r})}signAllTransactions(e){return(0,r.__awaiter)(this,void 0,void 0,function*(){if(!this.turnkeyAddress)throw new b.DynamicError("No turnkey account","no_turnkey_account");let t=new y.SolanaUiTransaction({connection:this.getConnection("confirmed"),from:this.turnkeyAddress,multipleTransactions:e,onSubmit:()=>(0,r.__awaiter)(this,void 0,void 0,function*(){return this.internalSignAllTransactions(e)})});return this.walletUiUtils.signTransaction(this,t)})}internalSignAndSendTransaction(e,t){return(0,r.__awaiter)(this,void 0,void 0,function*(){var r,i;if(!this.turnkeyAddress)throw new b.DynamicError("Solana wallet not found","solana_wallet_not_found");let s=this.getConnection(null!=(i=null==(r=this.connectionConfig)?void 0:r.commitment)?i:"confirmed"),{blockhash:n,lastValidBlockHeight:o}=yield s.getLatestBlockhash("finalized");"version"in e?e.message.recentBlockhash=n:(e.recentBlockhash=n,e.lastValidBlockHeight=o);let a=yield this.internalSignTransaction(e),l=yield s.sendRawTransaction(a.serialize(),t);try{let e=yield s.confirmTransaction({blockhash:n,lastValidBlockHeight:o,signature:l},"confirmed");if(e.value.err)throw new w.TransactionFailedError(e.value.err)}catch(e){if(e instanceof w.TransactionFailedError)throw e;throw c.logger.warn("[internalSignAndSendTransaction] Confirmation timed out, including signature for on-chain verification",{error:e,signature:l}),new _.TransactionConfirmationTimeoutError(l)}return l})}signAndSendTransaction(e,t){return(0,r.__awaiter)(this,void 0,void 0,function*(){if(!this.turnkeyAddress)throw new b.DynamicError("Solana wallet not found","solana_wallet_not_found");let i=yield this.optimizeTransaction(e),s=new y.SolanaUiTransaction({connection:this.getConnection("confirmed"),from:this.turnkeyAddress,multipleTransactions:[i],onSubmit:()=>(0,r.__awaiter)(this,void 0,void 0,function*(){return this.internalSignAndSendTransaction(i,t)})});return this.walletUiUtils.sendTransaction(this,s)})}sendTransaction(e,t){return(0,r.__awaiter)(this,arguments,void 0,function*(e,t,s={}){var n;if(!this.turnkeyAddress)throw new b.DynamicError("Solana wallet not found","solana_wallet_not_found");if(!e||!t)throw new b.DynamicError("Transaction and connection are required","transaction_and_connection_are_required");let{signers:o}=s,a=(0,r.__rest)(s,["signers"]),l=yield t.getLatestBlockhash({commitment:s.preflightCommitment,minContextSlot:s.minContextSlot});"version"in e?(null==o?void 0:o.length)&&e.sign(o):(e.feePayer=e.feePayer||new i.PublicKey(this.turnkeyAddress),e.recentBlockhash=e.recentBlockhash||l.blockhash,(null==o?void 0:o.length)&&e.partialSign(...o)),a.preflightCommitment=a.preflightCommitment||t.commitment;let c=yield t.sendRawTransaction(e.serialize(),s),u={blockhash:l.blockhash,lastValidBlockHeight:l.lastValidBlockHeight,signature:c},d=yield null==t?void 0:t.confirmTransaction(u);return(null==(n=null==d?void 0:d.value)?void 0:n.err)?JSON.stringify(d.value.err):c})}lamportsToSol(e){return e/i.LAMPORTS_PER_SOL}optimizeTransaction(e){return(0,r.__awaiter)(this,void 0,void 0,function*(){var t;let r=e;try{(yield this.getNetwork(!0))!=="101"||(0,m.isTxAlreadySigned)(e)||(r=yield(0,I.optimizeSolanaTransaction)(this.getEnvId(),e,null!=(t=this.turnkeyAddress)?t:""))}catch(e){c.logger.warn("Failed to optimize transaction",e)}return r})}getBlockExplorerUrlsForCurrentNetwork(){return(0,r.__awaiter)(this,void 0,void 0,function*(){let e=this.getSelectedNetwork();return e?e.blockExplorerUrls:[]})}getEnabledNetworks(){return this.solNetworks}}e.s(["TurnkeySolanaWalletConnector",0,T])},490713,e=>{"use strict";e.i(311317);var t=e.i(513329),r=e.i(113841);e.s(["TurnkeySolanaWalletConnectors",0,e=>{var i;if(null==(i=e.apiProviders)?void 0:i.turnkey){let i=class extends r.TurnkeySolanaWalletConnector{constructor(r){super(t.TurnkeyWalletConnectorInfo.TurnkeyHD,Object.assign(Object.assign({},e),r))}};return Object.defineProperty(i,"key",{value:"turnkeyhd",writable:!1}),[i]}return[]}])},214260,e=>{"use strict";e.i(957121);var t=e.i(303690),r=e.i(726138);e.i(490713),e.i(717231),(0,t.assertPackageVersion)("@dynamic-labs/embedded-wallet-solana",r.version),e.s([])},875622,e=>{"use strict";e.s(["version",0,"4.93.0"])},918244,e=>{"use strict";
22"function"==typeof SuppressedError&&SuppressedError,e.s(["__awaiter",0,function(e,t,r,i){return new(r||(r=Promise))(function(s,n){function o(e){try{l(i.next(e))}catch(e){n(e)}}function a(e){try{l(i.throw(e))}catch(e){n(e)}}function l(e){var t;e.done?s(e.value):((t=e.value)instanceof r?t:new r(function(e){e(t)})).then(o,a)}l((i=i.apply(e,t||[])).next())})}])},376260,e=>{"use strict";let t=new(e.i(538990)).Logger("@dynamic-labs/waas-svm");e.s(["logger",0,t])},981134,e=>{"use strict";var t=e.i(467034),r=e.i(918244),i=e.i(654611),s=e.i(127261),n=e.i(595932);class o extends n.default{constructor({walletConnector:e}){super(),this.isConnected=!0,this.providers=[this],this.isBraveWallet=!1,this.isGlow=!1,this.isPhantom=!1,this.isSolflare=!1,this.isExodus=!1,this.isBackpack=!1,this.isMagicEden=!1,this.walletConnector=e,this.accountAddress=this.walletConnector.activeAccountAddress,this.publicKey=this.accountAddress?new s.PublicKey(this.accountAddress):void 0}signMessage(e){return(0,r.__awaiter)(this,void 0,void 0,function*(){let r=t.Buffer.from(e).toString(),s=yield this.walletConnector.signMessage(r);return{signature:i.default.decode(s)}})}signTransaction(e){return(0,r.__awaiter)(this,void 0,void 0,function*(){return this.walletConnector.signTransaction(e)})}signAllTransactions(e){return(0,r.__awaiter)(this,void 0,void 0,function*(){return this.walletConnector.signAllTransactions(e)})}signAndSendTransaction(e,t){return(0,r.__awaiter)(this,void 0,void 0,function*(){return{signature:yield this.walletConnector.signAndSendTransaction(e,t)}})}connect(e){return(0,r.__awaiter)(this,void 0,void 0,function*(){return{address:this.accountAddress,publicKey:this.publicKey}})}disconnect(){return(0,r.__awaiter)(this,void 0,void 0,function*(){})}}e.s(["DynamicWaasSVMSigner",0,o])},284719,e=>{"use strict";var t=e.i(467034),r=e.i(918244),i=e.i(127261);e.i(214260);var s=e.i(717231);e.i(534505);var n=e.i(229557),o=e.i(877774);e.i(484200);var a=e.i(510137),l=e.i(733149),c=e.i(319050);e.i(973402);var u=e.i(624211),d=e.i(528577),h=e.i(165948);e.i(738110);var f=e.i(858899);e.i(303778);var p=e.i(13855),g=e.i(376260),y=e.i(981134),m=e.i(538990);class b extends(0,f.withDynamicWaas)(a.SolanaWalletConnector){connect(){throw Error("Method not implemented.")}constructor(e){super(e),this.name="Dynamic Waas",this.overrideKey="dynamicwaas",this.isEmbeddedWallet=!0,this.getSvmGasSponsorshipEnabled=()=>!1,this.logger=g.logger,this.walletUiUtils=e.walletUiUtils}setSvmGasSponsorshipEnabled(e){this.getSvmGasSponsorshipEnabled=e}isTxAlreadySigned(e){return"version"in e?e.signatures.some(e=>!e.every(e=>0===e)):e.signatures.some(e=>e.signature&&!e.signature.every(e=>0===e))}maybeSponsorTransaction(e){return(0,r.__awaiter)(this,void 0,void 0,function*(){if(!this.getSvmGasSponsorshipEnabled())return e;if(this.isTxAlreadySigned(e))return g.logger.debug("[maybeSponsorTransaction] Skipping sponsorship - transaction already signed"),e;if(!this.environmentId)return g.logger.warn("[maybeSponsorTransaction] Missing environmentId, skipping sponsorship"),e;try{let t=yield(0,s.sponsorSolanaTransaction)(this.environmentId,e);return g.logger.info("[maybeSponsorTransaction] Transaction sponsored successfully"),t}catch(t){return g.logger.warn("[maybeSponsorTransaction] Failed to sponsor transaction, using original",{error:t}),e}})}setEnvironmentId(e){super.setEnvironmentId(e),m.Logger.setEnvironmentId(e)}setActiveAccountAddress(e){this.activeAccountAddress=e}getActiveAccountAddress(){return(0,r.__awaiter)(this,void 0,void 0,function*(){return this.activeAccountAddress})}validateActiveWallet(e){return(0,r.__awaiter)(this,void 0,void 0,function*(){var t;let r=yield this.getWaasWalletClient(),i=yield r.getWallet({accountAddress:e,authToken:null==(t=this.getAuthToken)?void 0:t.call(this),signedSessionId:""});if(!i)throw new u.DynamicError("Account not found","account_not_found");(0,p.isSameAddress)(i.accountAddress,this.activeAccountAddress||"",this.connectedChain)||(this.activeAccountAddress=i.accountAddress)})}internalSignMessage(e){return(0,r.__awaiter)(this,arguments,void 0,function*(e,{parentTraceId:t,startTime:i}={}){var s,a,l,c;let d=t||this.generateTraceId(),h=i||Date.now(),f=yield this.instrumentAsync({context:{chainName:"SVM",startTime:h,traceId:d},fn:()=>(0,r.__awaiter)(this,void 0,void 0,function*(){return this.getWaasWalletClient()}),operation:"internalSignMessage",resource:"getWaasWalletClient"});if(!this.activeAccountAddress)throw Error("Active account address is required");let p=yield null==(s=this.getSignedSessionId)?void 0:s.call(this);if(!p)throw new u.DynamicError("Signed session ID is required","signed_session_id_is_required");let g=yield null==(a=this.getMfaToken)?void 0:a.call(this,{mfaAction:n.MFAAction.WalletWaasSign}),y=yield null==(l=this.getElevatedAccessToken)?void 0:l.call(this,{scope:o.TokenScope.Walletsign}),m=yield this.getPasswordIfNeeded({accountAddress:this.activeAccountAddress}),b=this.activeAccountAddress,v=null==(c=this.getAuthToken)?void 0:c.call(this);return yield this.instrumentAsync({context:{chainName:"SVM",startTime:h,traceId:d},fn:()=>(0,r.__awaiter)(this,void 0,void 0,function*(){return f.signMessage({accountAddress:b,authToken:v,elevatedAccessToken:y,message:e,mfaToken:g,password:m,signedSessionId:p,traceContext:{startTime:h,traceId:d}})}),operation:"internalSignMessage",resource:"walletClient.signMessage"})})}signMessage(e){return(0,r.__awaiter)(this,void 0,void 0,function*(){if(!this.activeAccountAddress)throw Error("Active account address is required");let t=this.generateTraceId(),i=Date.now();this.instrument("[signMessage] start",{key:"signMessage-start",startTime:i,time:0,traceId:t});let s=yield this.walletUiUtils.signMessage({handler:()=>(0,r.__awaiter)(this,void 0,void 0,function*(){return this.internalSignMessage(e,{parentTraceId:t,startTime:i})}
22),message:e,walletConnector:this});return this.instrument("[signMessage] completed",{key:"signMessage-completed",startTime:i,time:Date.now()-i,traceId:t}),s})}internalSignTransaction(e){return(0,r.__awaiter)(this,arguments,void 0,function*(e,{parentTraceId:s,startTime:a,overrideBlockhash:c}={}){var d,h,f;let p=s||this.generateTraceId(),y=a||Date.now(),m=yield this.maybeSponsorTransaction(e);c&&((0,l.isVersionedTransaction)(m)?m.message.recentBlockhash=c.blockhash:(m.recentBlockhash=c.blockhash,m.lastValidBlockHeight=c.lastValidBlockHeight));let b=yield this.instrumentAsync({context:{chainName:"SVM",startTime:y,traceId:p},fn:()=>(0,r.__awaiter)(this,void 0,void 0,function*(){return this.getWaasWalletClient()}),operation:"internalSignTransaction",resource:"getWaasWalletClient"}),v=yield null==(d=this.getSignedSessionId)?void 0:d.call(this);if(!v)throw new u.DynamicError("Signed session ID is required","signed_session_id_is_required");if(!this.activeAccountAddress)throw Error("Active account address is required");let w=yield null==(h=this.getMfaToken)?void 0:h.call(this,{mfaAction:n.MFAAction.WalletWaasSign}),_=yield null==(f=this.getElevatedAccessToken)?void 0:f.call(this,{scope:o.TokenScope.Walletsign}),S=yield this.getPasswordIfNeeded({accountAddress:this.activeAccountAddress}),E=(0,l.isVersionedTransaction)(m),I=E?m.message.serialize():m.serializeMessage(),A=t.Buffer.from(I).toString("hex"),T=yield this.getNetwork(!0),x=this.activeAccountAddress,k=yield this.instrumentAsync({context:{chainName:"SVM",startTime:y,traceId:p},fn:()=>(0,r.__awaiter)(this,void 0,void 0,function*(){var e;return b.signTransaction({authToken:null==(e=this.getAuthToken)?void 0:e.call(this),chainId:T,elevatedAccessToken:_,mfaToken:w,password:S,senderAddress:x,signedSessionId:v,traceContext:{startTime:y,traceId:p},transaction:A})}),operation:"internalSignTransaction",resource:"signTransaction"});if(m.addSignature(new i.PublicKey(this.activeAccountAddress),t.Buffer.from(k,"hex")),!E)try{m.serialize({requireAllSignatures:!1,verifySignatures:!0})}catch(e){g.logger.warn("[internalSignTransaction] Signature verification failed for legacy Transaction",e)}return m})}signTransaction(e){return(0,r.__awaiter)(this,void 0,void 0,function*(){if(!this.activeAccountAddress)throw Error("Active account address is required");let t=this.generateTraceId(),i=Date.now();this.instrument("[signTransaction] start",{key:"signTransaction-start",startTime:i,time:0,traceId:t});let s=new c.SolanaUiTransaction({connection:this.getWalletClient(),from:this.activeAccountAddress,multipleTransactions:[e],onSubmit:()=>(0,r.__awaiter)(this,void 0,void 0,function*(){return this.internalSignTransaction(e,{parentTraceId:t,startTime:i})})}),n=yield this.walletUiUtils.signTransaction(this,s);return this.instrument("[signTransaction] completed",{key:"signTransaction-completed",startTime:i,time:Date.now()-i,traceId:t}),n})}internalSignAllTransactions(e){return(0,r.__awaiter)(this,void 0,void 0,function*(){if(!this.activeAccountAddress)throw Error("Active account address is required");let t=[];for(let r of e){let e=yield this.internalSignTransaction(r);t.push(e)}return t})}signAllTransactions(e){return(0,r.__awaiter)(this,void 0,void 0,function*(){if(!this.activeAccountAddress)throw Error("Active account address is required");let t=this.generateTraceId(),i=Date.now();this.instrument("[signAllTransactions] start",{key:"signAllTransactions-start",startTime:i,time:0,traceId:t});let s=new c.SolanaUiTransaction({connection:this.getWalletClient(),from:this.activeAccountAddress,multipleTransactions:e,onSubmit:()=>(0,r.__awaiter)(this,void 0,void 0,function*(){return this.internalSignAllTransactions(e)})}),n=yield this.walletUiUtils.signTransaction(this,s);return this.instrument("[signAllTransactions] completed",{key:"signAllTransactions-completed",startTime:i,time:Date.now()-i,traceId:t}),n})}internalSignAndSendTransaction(e,t){return(0,r.__awaiter)(this,arguments,void 0,function*(e,t,{parentTraceId:i,startTime:s}={}){var n;let o=i||this.generateTraceId(),a=s||Date.now();if(!this.activeAccountAddress)throw Error("Active account address is required");let c=this.getWalletClient(),{blockhash:u,lastValidBlockHeight:f}=yield c.getLatestBlockhash("finalized"),p=yield this.instrumentAsync({context:{chainName:"SVM",startTime:a,traceId:o},fn:()=>(0,r.__awaiter)(this,void 0,void 0,function*(){return this.internalSignTransaction(e,{overrideBlockhash:{blockhash:u,lastValidBlockHeight:f},parentTraceId:o,startTime:a})}),operation:"internalSignAndSendTransaction",resource:"internalSignTransaction"}),y=(0,l.isVersionedTransaction)(p)?p.serialize():p.serialize({requireAllSignatures:!1,verifySignatures:!0}),m=yield this.instrumentAsync({context:{chainName:"SVM",rpcUrl:c.rpcEndpoint,startTime:a,traceId:o},fn:()=>(0,r.__awaiter)(this,void 0,void 0,function*(){return c.sendRawTransaction(y,t)}),operation:"internalSignAndSendTransaction",resource:"sendRawTransaction"}),b=Date.now();try{let e=yield c.confirmTransaction({blockhash:u,lastValidBlockHeight:f,signature:m}
22,null!=(n=null==t?void 0:t.preflightCommitment)?n:"confirmed"),r=Date.now(),i=r-b,s=r-a;if(e.value.err)throw g.logger.error(`[internalSignAndSendTransaction] Transaction failed - total: ${s}ms, step: ${i}ms`,{accountAddress:this.activeAccountAddress,error:e.value.err,key:"internalSignAndSendTransaction-transactionFailed",rpcUrl:c.rpcEndpoint,stepTime:i,time:s,traceId:o}),new d.TransactionFailedError(e.value.err);this.instrument(`[internalSignAndSendTransaction] Transaction confirmed - total: ${s}ms, step: ${i}ms`,{key:"internalSignAndSendTransaction-transactionSuccess",rpcUrl:c.rpcEndpoint,stepTime:i,time:s,traceId:o})}catch(t){if(t instanceof d.TransactionFailedError)throw t;let e=Date.now()-b;throw g.logger.error(`[internalSignAndSendTransaction] Confirmation timed out - total: ${e}ms`,{accountAddress:this.activeAccountAddress,error:t,key:"internalSignAndSendTransaction-confirmationTimedOut",rpcUrl:c.rpcEndpoint,signature:m,time:e,traceId:o}),new h.TransactionConfirmationTimeoutError(m)}return m})}signAndSendTransaction(e,t){return(0,r.__awaiter)(this,void 0,void 0,function*(){if(!this.activeAccountAddress)throw Error("Active account address is required");let i=this.generateTraceId(),s=Date.now();this.instrument("[signAndSendTransaction] start",{key:"signAndSendTransaction-start",options:t,startTime:s,time:0,traceId:i});let n=new c.SolanaUiTransaction({connection:this.getWalletClient(),from:this.activeAccountAddress,multipleTransactions:[e],onSubmit:()=>(0,r.__awaiter)(this,void 0,void 0,function*(){return this.internalSignAndSendTransaction(e,t,{parentTraceId:i,startTime:s})})}),o=yield this.walletUiUtils.sendTransaction(this,n);return this.instrument("[signAndSendTransaction] completed",{key:"signAndSendTransaction-completed",startTime:s,time:Date.now()-s,traceId:i}),o})}getSigner(){return(0,r.__awaiter)(this,void 0,void 0,function*(){return new y.DynamicWaasSVMSigner({walletConnector:this})})}getWalletClientByAddress({accountAddress:e}){return this.setActiveAccountAddress(e),this.getWalletClient()}exportClientKeyshares(e){let t=Object.create(null,{exportClientKeyshares:{get:()=>super.exportClientKeyshares}});return(0,r.__awaiter)(this,arguments,void 0,function*({accountAddress:e,password:r}){let i=e||this.activeAccountAddress;if(!i)throw Error("Account address is required");let s=this.generateTraceId(),n=Date.now();this.instrument("[exportClientKeyshares] start",{key:"exportClientKeyshares-start",startTime:n,time:0,traceId:s});let o=yield t.exportClientKeyshares.call(this,{accountAddress:i,password:r});return this.instrument("[exportClientKeyshares] completed",{key:"exportClientKeyshares-completed",startTime:n,time:Date.now()-n,traceId:s}),o})}createUiTransaction(e){return(0,r.__awaiter)(this,void 0,void 0,function*(){return yield this.validateActiveWallet(e),new c.SolanaUiTransaction({connection:this.getWalletClient(),from:e,onSubmit:e=>(0,r.__awaiter)(this,void 0,void 0,function*(){if(e)return this.internalSignAndSendTransaction(e)})})})}signMessageWithContext(){return(0,r.__awaiter)(this,void 0,void 0,function*(){throw Error("Not implemented")})}}Object.defineProperty(b,"key",{value:"dynamicwaas",writable:!1}),e.s(["DynamicWaasSVMConnector",0,b])},690822,e=>{"use strict";var t=e.i(284719);e.s(["DynamicWaasSVMConnectors",0,()=>[t.DynamicWaasSVMConnector]])},326132,e=>{"use strict";e.i(957121);var t=e.i(303690),r=e.i(875622);e.i(284719),e.i(690822),(0,t.assertPackageVersion)("@dynamic-labs/waas-svm",r.version),e.s([])},550028,e=>{"use strict";e.i(973402);var t=e.i(55130),r=e.i(507301),i=e.i(581825);class s extends i.InjectedWalletBase{constructor(){super(...arguments),this.name="Phantom",this.overrideKey="phantom"}openInAppBrowserIfRequired(){return!(!(0,t.isMobile)()||this.isInstalledOnBrowser())&&((0,r.handleMobileWalletRedirect)({nativeLink:"phantom://browse",universalLink:"https://phantom.app/ul/browse"}),!0)}canGetChainAddress(){var e,t;return(null==(t=null==(e=this.solProviderHelper)?void 0:e.findProvider())?void 0:t.publicKey)!==null}}e.s(["PhantomInjected",0,s])},596510,(e,t,r)=>{!function(e){"use strict";var t,r=function(e){var t,r=new Float64Array(16);if(e)for(t=0;t<e.length;t++)r[t]=e[t];return r},i=function(){throw Error("no PRNG")},s=new Uint8Array(16),n=new Uint8Array(32);n[0]=9;var o=r(),a=r([1]),l=r([56129,1]),c=r([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),u=r([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),d=r([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),h=r([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),f=r([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function p(e,t,r,i){e[t]=r>>24&255,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=255&r,e[t+4]=i>>24&255,e[t+5]=i>>16&255,e[t+6]=i>>8&255,e[t+7]=255&i}function g(e,t,r,i,s){var n,o=0;for(n=0;n<s;n++)o|=e[t+n]^r[i+n];return(1&o-1>>>8)-1}function y(e,t,r,i){return g(e,t,r,i,16)}
22function m(e,t,r,i){return g(e,t,r,i,32)}function b(e,t,r,i){!function(e,t,r,i){for(var s,n=255&i[0]|(255&i[1])<<8|(255&i[2])<<16|(255&i[3])<<24,o=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,a=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,l=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,c=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,u=255&i[4]|(255&i[5])<<8|(255&i[6])<<16|(255&i[7])<<24,d=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,h=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,f=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,p=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,g=255&i[8]|(255&i[9])<<8|(255&i[10])<<16|(255&i[11])<<24,y=255&r[16]|(255&r[17])<<8|(255&r[18])<<16|(255&r[19])<<24,m=255&r[20]|(255&r[21])<<8|(255&r[22])<<16|(255&r[23])<<24,b=255&r[24]|(255&r[25])<<8|(255&r[26])<<16|(255&r[27])<<24,v=255&r[28]|(255&r[29])<<8|(255&r[30])<<16|(255&r[31])<<24,w=255&i[12]|(255&i[13])<<8|(255&i[14])<<16|(255&i[15])<<24,_=n,S=o,E=a,I=l,A=c,T=u,x=d,k=h,P=f,O=p,R=g,C=y,N=m,B=b,U=v,q=w,L=0;L<20;L+=2)A^=(s=_+N|0)<<7|s>>>25,P^=(s=A+_|0)<<9|s>>>23,N^=(s=P+A|0)<<13|s>>>19,_^=(s=N+P|0)<<18|s>>>14,O^=(s=T+S|0)<<7|s>>>25,B^=(s=O+T|0)<<9|s>>>23,S^=(s=B+O|0)<<13|s>>>19,T^=(s=S+B|0)<<18|s>>>14,U^=(s=R+x|0)<<7|s>>>25,E^=(s=U+R|0)<<9|s>>>23,x^=(s=E+U|0)<<13|s>>>19,R^=(s=x+E|0)<<18|s>>>14,I^=(s=q+C|0)<<7|s>>>25,k^=(s=I+q|0)<<9|s>>>23,C^=(s=k+I|0)<<13|s>>>19,q^=(s=C+k|0)<<18|s>>>14,S^=(s=_+I|0)<<7|s>>>25,E^=(s=S+_|0)<<9|s>>>23,I^=(s=E+S|0)<<13|s>>>19,_^=(s=I+E|0)<<18|s>>>14,x^=(s=T+A|0)<<7|s>>>25,k^=(s=x+T|0)<<9|s>>>23,A^=(s=k+x|0)<<13|s>>>19,T^=(s=A+k|0)<<18|s>>>
2214,C^=(s=R+O|0)<<7|s>>>25,P^=(s=C+R|0)<<9|s>>>23,O^=(s=P+C|0)<<13|s>>>19,R^=(s=O+P|0)<<18|s>>>14,N^=(s=q+U|0)<<7|s>>>25,B^=(s=N+q|0)<<9|s>>>23,U^=(s=B+N|0)<<13|s>>>19,q^=(s=U+B|0)<<18|s>>>14;_=_+n|0,S=S+o|0,E=E+a|0,I=I+l|0,A=A+c|0,T=T+u|0,x=x+d|0,k=k+h|0,P=P+f|0,O=O+p|0,R=R+g|0,C=C+y|0,N=N+m|0,B=B+b|0,U=U+v|0,q=q+w|0,e[0]=_>>>0&255,e[1]=_>>>8&255,e[2]=_>>>16&255,e[3]=_>>>24&255,e[4]=S>>>0&255,e[5]=S>>>8&255,e[6]=S>>>16&255,e[7]=S>>>24&255,e[8]=E>>>0&255,e[9]=E>>>8&255,e[10]=E>>>16&255,e[11]=E>>>24&255,e[12]=I>>>0&255,e[13]=I>>>8&255,e[14]=I>>>16&255,e[15]=I>>>24&255,e[16]=A>>>0&255,e[17]=A>>>8&255,e[18]=A>>>16&255,e[19]=A>>>24&255,e[20]=T>>>0&255,e[21]=T>>>8&255,e[22]=T>>>16&255,e[23]=T>>>24&255,e[24]=x>>>0&255,e[25]=x>>>8&255,e[26]=x>>>16&255,e[27]=x>>>24&255,e[28]=k>>>0&255,e[29]=k>>>8&255,e[30]=k>>>16&255,e[31]=k>>>24&255,e[32]=P>>>0&255,e[33]=P>>>8&255,e[34]=P>>>16&255,e[35]=P>>>24&255,e[36]=O>>>0&255,e[37]=O>>>8&255,e[38]=O>>>16&255,e[39]=O>>>24&255,e[40]=R>>>0&255,e[41]=R>>>8&255,e[42]=R>>>16&255,e[43]=R>>>24&255,e[44]=C>>>0&255,e[45]=C>>>8&255,e[46]=C>>>16&255,e[47]=C>>>24&255,e[48]=N>>>0&255,e[49]=N>>>8&255,e[50]=N>>>16&255,e[51]=N>>>24&255,e[52]=B>>>0&255,e[53]=B>>>8&255,e[54]=B>>>16&255,e[55]=B>>>24&255,e[56]=U>>>0&255,e[57]=U>>>8&255,e[58]=U>>>16&255,e[59]=U>>>24&255,e[60]=q>>>0&255,e[61]=q>>>8&255,e[62]=q>>>16&255,e[63]=q>>>24&255}(e,t,r,i)}function v(e,t,r,i){!function(e,t,r,i){for(var s,n=255&i[0]|(255&i[1])<<8|(255&i[2])<<16|(255&i[3])<<24,o=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,a=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,l=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,c=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,u=255&i[4]|(255&i[5])<<8|(255&i[6])<<16|(255&i[7])<<24,d=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,h=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,f=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,p=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,g=255&i[8]|(255&i[9])<<8|(255&i[10])<<16|(255&i[11])<<24,y=255&r[16]|(255&r[17])<<8|(255&r[18])<<16|(255&r[19])<<24,m=255&r[20]|(255&r[21])<<8|(255&r[22])<<16|(255&r[23])<<24,b=255&r[24]|(255&r[25])<<8|(255&r[26])<<16|(255&r[27])<<24,v=255&r[28]|(255&r[29])<<8|(255&r[30])<<16|(255&r[31])<<24,w=255&i[12]|(255&i[13])<<8|(255&i[14])<<16|(255&i[15])<<24,_=n,S=o,E=a,I=l,A=c,T=u,x=d,k=h,P=f,O=p,R=g,C=y,N=m,B=b,U=v,q=w,L=0;L<20;L+=2)A^=(s=_+N|0)<<7|s>>>25,P^=(s=A+_|0)<<9|s>>>23,N^=(s=P+A|0)<<13|s>>>19,_^=(s=N+P|0)<<18|s>>>14,O^=(s=T+S|0)<<7|s>>>25,B^=(s=O+T|0)<<9|s>>>23,S^=(s=B+O|0)<<13|s>>>19,T^=(s=S+B|0)<<18|s>>>14,U^=(s=R+x|0)<<7|s>>>25,E^=(s=U+R|0)<<9|s>>>23,x^=(s=E+U|0)<<13|s>>>19,R^=(s=x+E|0)<<18|s>>>14,I^=(s=q+C|0)<<7|s>>>25,k^=(s=I+q|0)<<9|s>>>23,C^=(s=k+I|0)<<13|s>>>19,q^=(s=C+k|0)<<18|s>>>14,S^=(s=_+I|0)<<7|s>>>25,E^=(s=S+_|0)<<9|s>>>23,I^=(s=E+S|0)<<13|s>>>19,_^=(s=I+E|0)<<18|s>>>14,x^=(s=T+A|0)<<7|s>>>25,k^=(s=x+T|0)<<9|s>>>23,A^=(s=k+x|0)<<13|s>>>19,T^=(s=A+k|0)<<18|s>>>
2214,C^=(s=R+O|0)<<7|s>>>25,P^=(s=C+R|0)<<9|s>>>23,O^=(s=P+C|0)<<13|s>>>19,R^=(s=O+P|0)<<18|s>>>14,N^=(s=q+U|0)<<7|s>>>25,B^=(s=N+q|0)<<9|s>>>23,U^=(s=B+N|0)<<13|s>>>19,q^=(s=U+B|0)<<18|s>>>14;e[0]=_>>>0&255,e[1]=_>>>8&255,e[2]=_>>>16&255,e[3]=_>>>24&255,e[4]=T>>>0&255,e[5]=T>>>8&255,e[6]=T>>>16&255,e[7]=T>>>24&255,e[8]=R>>>0&255,e[9]=R>>>8&255,e[10]=R>>>16&255,e[11]=R>>>24&255,e[12]=q>>>0&255,e[13]=q>>>8&255,e[14]=q>>>16&255,e[15]=q>>>24&255,e[16]=x>>>0&255,e[17]=x>>>8&255,e[18]=x>>>16&255,e[19]=x>>>24&255,e[20]=k>>>0&255,e[21]=k>>>8&255,e[22]=k>>>16&255,e[23]=k>>>24&255,e[24]=P>>>0&255,e[25]=P>>>8&255,e[26]=P>>>16&255,e[27]=P>>>24&255,e[28]=O>>>0&255,e[29]=O>>>8&255,e[30]=O>>>16&255,e[31]=O>>>24&255}(e,t,r,i)}var w=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function _(e,t,r,i,s,n,o){var a,l,c=new Uint8Array(16),u=new Uint8Array(64);for(l=0;l<16;l++)c[l]=0;for(l=0;l<8;l++)c[l]=n[l];for(;s>=64;){for(b(u,c,o,w),l=0;l<64;l++)e[t+l]=r[i+l]^u[l];for(l=8,a=1;l<16;l++)a=a+(255&c[l])|0,c[l]=255&a,a>>>=8;s-=64,t+=64,i+=64}if(s>0)for(b(u,c,o,w),l=0;l<s;l++)e[t+l]=r[i+l]^u[l];return 0}function S(e,t,r,i,s){var n,o,a=new Uint8Array(16),l=new Uint8Array(64);for(o=0;o<16;o++)a[o]=0;for(o=0;o<8;o++)a[o]=i[o];for(;r>=64;){for(b(l,a,s,w),o=0;o<64;o++)e[t+o]=l[o];for(o=8,n=1;o<16;o++)n=n+(255&a[o])|0,a[o]=255&n,n>>>=8;r-=64,t+=64}if(r>0)for(b(l,a,s,w),o=0;o<r;o++)e[t+o]=l[o];return 0}function E(e,t,r,i,s){var n=new Uint8Array(32);v(n,i,s,w);for(var o=new Uint8Array(8),a=0;a<8;a++)o[a]=i[a+16];return S(e,t,r,o,n)}function I(e,t,r,i,s,n,o){var a=new Uint8Array(32);v(a,n,o,w);for(var l=new Uint8Array(8),c=0;c<8;c++)l[c]=n[c+16];return _(e,t,r,i,s,l,a)}var A=function(e){var t,r,i,s,n,o,a,l;this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,this.fin=0,t=255&e[0]|(255&e[1])<<8,this.r[0]=8191&t,r=255&e[2]|(255&e[3])<<8,this.r[1]=(t>>>13|r<<3)&8191,i=255&e[4]|(255&e[5])<<8,this.r[2]=(r>>>10|i<<6)&7939,s=255&e[6]|(255&e[7])<<8,this.r[3]=(i>>>7|s<<9)&8191,n=255&e[8]|(255&e[9])<<8,this.r[4]=(s>>>4|n<<12)&255,this.r[5]=n>>>1&8190,o=255&e[10]|(255&e[11])<<8,this.r[6]=(n>>>14|o<<2)&8191,a=255&e[12]|(255&e[13])<<8,this.r[7]=(o>>>11|a<<5)&8065,l=255&e[14]|(255&e[15])<<8,this.r[8]=(a>>>8|l<<8)&8191,this.r[9]=l>>>5&127,this.pad[0]=255&e[16]|(255&e[17])<<8,this.pad[1]=255&e[18]|(255&e[19])<<8,this.pad[2]=255&e[20]|(255&e[21])<<8,this.pad[3]=255&e[22]|(255&e[23])<<8,this.pad[4]=255&e[24]|(255&e[25])<<8,this.pad[5]=255&e[26]|(255&e[27])<<8,this.pad[6]=255&e[28]|(255&e[29])<<8,this.pad[7]=255&e[30]|(255&e[31])<<8};function T(e,t,r,i,s,n){var o=new A(n);return o.update(r,i,s),o.finish(e,t),0}function x(e,t,r,i,s,n){var o=new Uint8Array(16);return T(o,0,r,i,s,n),y(e,t,o,0)}function k(e,t,r,i,s){var n;if(r<32)return -1;for(I(e,0,t,0,r,i,s),T(e,16,e,32,r-32,e),n=0;n<16;n++)e[n]=0;return 0}function P(e,t,r,i,s){var n,o=new Uint8Array(32);if(r<32||(E(o,0,32,i,s),0!==x(t,16,t,32,r-32,o)))return -1;for(I(e,0,t,0,r,i,s),n=0;n<32;n++)e[n]=0;return 0}function O(e,t){var r;for(r=0;r<16;r++)e[r]=0|t[r]}function R(e){var t,r,i=1;for(t=0;t<16;t++)i=Math.floor((r=e[t]+i+65535)/65536),e[t]=r-65536*i;e[0]+=i-1+37*(i-1)}function C(e,t,r){for(var i,s=~(r-1),n=0;n<16;n++)i=s&(e[n]^t[n]),e[n]^=i,t[n]^=i}function N(e,t){var i,s,n,o=r(),a=r();for(i=0;i<16;i++)a[i]=t[i];for(R(a),R(a),R(a),s=0;s<2;s++){for(i=1,o[0]=a[0]-65517;i<15;i++)o[i]=a[i]-65535-(o[i-1]>>16&1),o[i-1]&=65535;o[15]=a[15]-32767-(o[14]>>16&1),n=o[15]>>16&1,o[14]&=65535,C(a,o,1-n)}for(i=0;i<16;i++)e[2*i]=255&a[i],e[2*i+1]=a[i]>>8}function B(e,t){var r=new Uint8Array(32),i=new Uint8Array(32);return N(r,e),N(i,t),m(r,0,i,0)}function U(e){var t=new Uint8Array(32);return N(t,e),1&t[0]}function q(e,t){var r;for(r=0;r<16;r++)e[r]=t[2*r]+(t[2*r+1]<<8);e[15]&=32767}function L(e,t,r){for(var i=0;i<16;i++)e[i]=t[i]+r[i]}function D(e,t,r){for(var i=0;i<16;i++)e[i]=t[i]-r[i]}function M(e,t,r){var i,s,n=0,o=0,a=0,l=0,c=0,u=0,d=0,h=0,f=0,p=0,g=0,y=0,m=0,b=0,v=0,w=0,_=0,S=0,E=0,I=0,A=0,T=0,x=0,k=0,P=0,O=0,R=0,C=0,N=0,B=0,U=0,q=r[0],L=r[1],D=r[2],M=r[3],K=r[4],W=r[5],z=r[6],j=r[7],V=r[8],$=r[9],F=r[10],H=r[11],G=r[12],J=r[13],Y=r[14],Z=r[15];n+=(i=t[0])*q,o+=i*L,a+=i*D,l+=i*M,c+=i*K,u+=i*W,d+=i*z,h+=i*j,f+=i*V,p+=i*$,g+=i*F,y+=i*H,m+=i*G,b+=i*J,v+=i*Y,w+=i*Z,o+=(i=t[1])*q,a+=i*L,l+=i*D,c+=i*M,u+=i*K,d+=i*W,h+=i*z,f+=i*j,p+=i*V,g+=i*$,y+=i*F,m+=i*H,b+=i*G,v+=i*J,w+=i*Y,_+=i*Z,a+=(i=t[2])*q,l+=i*L,c+=i*D,u+=i*M,d+=i*K,h+=i*W,f+=i*z,p+=i*j,g+=i*V,y+=i*$,m+=i*F,b+=i*H,v+=i*G,w+=i*J,_+=i*Y,S+=i*Z,l+=(i=t[3])*q,c+=i*L,u+=i*D,d+=i*M,h+=i*K,f+=i*W,p+=i*z,g+=i*j,y+=i*V,m+=i*$,b+=i*F,v+=i*H,w+=i*G,_+=i*J,S+=i*Y,E+=i*Z,c+=(i=t[4])*q,u+=i*L,d+=i*D,h+=i*M,f+=i*K,p+=i*W,g+=i*z,y+=i*j,m+=i*V,b+=i*$,v+=i*F,w+=i*H,_+=i*G,S+=i*J,E+=i*Y,I+=i*Z,u+=(i=t[5])*q,d+=i*L,h+=i*D,f+=i*M,p+=i*K,g+=i*W,y+=i*z,m+=i*j,b+=i*V,v+=i*$,w+=i*F,_+=i*H,S+=i*G,E+=i*J,I+=i*Y,A+=i*Z,d+=(i=t[6])*q,h+=i*L,f+=i*D,p+=i*M,g+=i*K,y+=i*W,m+=i*z,b+=i*j,v+=i*V,w+=i*$,_+=i*F,S+=i*H,E+=i*G,I+=i*J,A+=i*Y,T+=i*Z,h+=(i=t[7])*q,f+=i*L,p+=i*D,g+=i*M,y+=i*K,m+=i*W,b+=i*z,v+=i*j,w+=i*V,_+=i*$,S+=i*F,E+=i*H,I+=i*G,A+=i*J,T+=i*Y,x+=i*Z,f+=(i=t[8])*q,p+=i*L,g+=i*D,y+=i*M,m+=i*K,b+=i*W,v+=i*z,w+=i*j,_+=i*V,S+=i*$,E+=i*F,I+=i*H,A+=i*G,T+=i*J,x+=i*Y,k+=i*Z,p+=(i=t[9])*q,g+=i*L,y+=i*D,m+=i*M,b+=i*K,v+=i*W,w+=i*z,_+=i*j,S+=i*V,E+=i*$,I+=i*F,A+=i*H,T+=i*G,x+=i*J,k+=i*Y,P+=i*Z,g+=(i=t[10])*q,y+=i*L,m+=i*D,b+=i*M,v+=i*K,w+=i*W,_+=i*z,S+=i*j,E+=i*V,I+=i*$,A+=i*F,T+=i*H,x+=i*G,k+=i*J,P+=i*Y,O+=i*Z,y+=(i=t[11])*q,m+=i*L,b+=i*D,v+=i*M,w+=i*K,_+=i*W,S+=i*z,E+=i*j,I+=i*V,A+=i*$,T+=i*F,x+=i*H,k+=i*G,P+=i*J,O+=i*Y,R+=i*Z,m+=(i=t[12])*q,b+=i*L,v+=i*D,w+=i*M,_+=i*K,S+=i*W,E+=i*z,I+=i*j,A+=i*V,T+=i*$,x+=i*F,k+=i*H,P+=i*G,O+=i*J,R+=i*Y,C+=i*Z,b+=(i=t[13])*q,v+=i*L,w+=i*D,_+=i*M,S+=i*K,E+=i*W,I+=i*z,A+=i*j,T+=i*V,x+=i*$,k+=i*F,P+=i*H,O+=i*G,R+=i*J,C+=i*Y,N+=i*Z,v+=(i=t[14])*q,w+=i*L,_+=i*D,S+=i*M,E+=i*K,I+=i*W,A+=i*z,T+=i*j,x+=i*V,k+=i*$,P+=i*F,O+=i*H,R+=i*G,C+=i*J,N+=i*Y,B+=i*Z,w+=(i=t[15])*q,_+=i*L,S+=i*D,E+=i*M,I+=i*K,A+=i*W,T+=i*z,x+=i*j,k+=i*V,P+=i*$,O+=i*F,R+=i*H,C+=i*G,N+=i*J,B+=i*Y,U+=i*Z,n+=38*_,o+=38*S,a+=38*E,l+=38*I,c+=38*A,u+=38*T,d+=38*x,h+=38*k,f+=38*P,p+=38*O,g+=38*R,y+=38*C,m+=38*N,b+=38*B,v+=38*U,s=Math.floor((i=n+(s=1)+6
225535)/65536),n=i-65536*s,s=Math.floor((i=o+s+65535)/65536),o=i-65536*s,s=Math.floor((i=a+s+65535)/65536),a=i-65536*s,s=Math.floor((i=l+s+65535)/65536),l=i-65536*s,s=Math.floor((i=c+s+65535)/65536),c=i-65536*s,s=Math.floor((i=u+s+65535)/65536),u=i-65536*s,s=Math.floor((i=d+s+65535)/65536),d=i-65536*s,s=Math.floor((i=h+s+65535)/65536),h=i-65536*s,s=Math.floor((i=f+s+65535)/65536),f=i-65536*s,s=Math.floor((i=p+s+65535)/65536),p=i-65536*s,s=Math.floor((i=g+s+65535)/65536),g=i-65536*s,s=Math.floor((i=y+s+65535)/65536),y=i-65536*s,s=Math.floor((i=m+s+65535)/65536),m=i-65536*s,s=Math.floor((i=b+s+65535)/65536),b=i-65536*s,s=Math.floor((i=v+s+65535)/65536),v=i-65536*s,s=Math.floor((i=w+s+65535)/65536),w=i-65536*s,n+=s-1+37*(s-1),s=Math.floor((i=n+(s=1)+65535)/65536),n=i-65536*s,s=Math.floor((i=o+s+65535)/65536),o=i-65536*s,s=Math.floor((i=a+s+65535)/65536),a=i-65536*s,s=Math.floor((i=l+s+65535)/65536),l=i-65536*s,s=Math.floor((i=c+s+65535)/65536),c=i-65536*s,s=Math.floor((i=u+s+65535)/65536),u=i-65536*s,s=Math.floor((i=d+s+65535)/65536),d=i-65536*s,s=Math.floor((i=h+s+65535)/65536),h=i-65536*s,s=Math.floor((i=f+s+65535)/65536),f=i-65536*s,s=Math.floor((i=p+s+65535)/65536),p=i-65536*s,s=Math.floor((i=g+s+65535)/65536),g=i-65536*s,s=Math.floor((i=y+s+65535)/65536),y=i-65536*s,s=Math.floor((i=m+s+65535)/65536),m=i-65536*s,s=Math.floor((i=b+s+65535)/65536),b=i-65536*s,s=Math.floor((i=v+s+65535)/65536),v=i-65536*s,s=Math.floor((i=w+s+65535)/65536),w=i-65536*s,n+=s-1+37*(s-1),e[0]=n,e[1]=o,e[2]=a,e[3]=l,e[4]=c,e[5]=u,e[6]=d,e[7]=h,e[8]=f,e[9]=p,e[10]=g,e[11]=y,e[12]=m,e[13]=b,e[14]=v,e[15]=w}function K(e,t){M(e,t,t)}function W(e,t){var i,s=r();for(i=0;i<16;i++)s[i]=t[i];for(i=253;i>=0;i--)K(s,s),2!==i&&4!==i&&M(s,s,t);for(i=0;i<16;i++)e[i]=s[i]}function z(e,t){var i,s=r();for(i=0;i<16;i++)s[i]=t[i];for(i=250;i>=0;i--)K(s,s),1!==i&&M(s,s,t);for(i=0;i<16;i++)e[i]=s[i]}function j(e,t,i){var s,n,o=new Uint8Array(32),a=new Float64Array(80),c=r(),u=r(),d=r(),h=r(),f=r(),p=r();for(n=0;n<31;n++)o[n]=t[n];for(o[31]=127&t[31]|64,o[0]&=248,q(a,i),n=0;n<16;n++)u[n]=a[n],h[n]=c[n]=d[n]=0;for(n=254,c[0]=h[0]=1;n>=0;--n)C(c,u,s=o[n>>>3]>>>(7&n)&1),C(d,h,s),L(f,c,d),D(c,c,d),L(d,u,h),D(u,u,h),K(h,f),K(p,c),M(c,d,c),M(d,u,f),L(f,c,d),D(c,c,d),K(u,c),D(d,h,p),M(c,d,l),L(c,c,h),M(d,d,c),M(c,h,p),M(h,u,a),K(u,f),C(c,u,s),C(d,h,s);for(n=0;n<16;n++)a[n+16]=c[n],a[n+32]=d[n],a[n+48]=u[n],a[n+64]=h[n];var g=a.subarray(32),y=a.subarray(16);return W(g,g),M(y,y,g),N(e,y),0}function V(e,t){return j(e,t,n)}function $(e,t){return i(t,32),V(e,t)}function F(e,t,r){var i=new Uint8Array(32);return j(i,r,t),v(e,s,i,w)}A.prototype.blocks=function(e,t,r){for(var i,s,n,o,a,l,c,u,d,h,f,p,g,y,m,b,v,w,_,S=2048*!this.fin,E=this.h[0],I=this.h[1],A=this.h[2],T=this.h[3],x=this.h[4],k=this.h[5],P=this.h[6],O=this.h[7],R=this.h[8],C=this.h[9],N=this.r[0],B=this.r[1],U=this.r[2],q=this.r[3],L=this.r[4],D=this.r[5],M=this.r[6],K=this.r[7],W=this.r[8],z=this.r[9];r>=16;)E+=8191&(i=255&e[t+0]|(255&e[t+1])<<8),I+=(i>>>13|(s=255&e[t+2]|(255&e[t+3])<<8)<<3)&8191,A+=(s>>>10|(n=255&e[t+4]|(255&e[t+5])<<8)<<6)&8191,T+=(n>>>7|(o=255&e[t+6]|(255&e[t+7])<<8)<<9)&8191,x+=(o>>>4|(a=255&e[t+8]|(255&e[t+9])<<8)<<12)&8191,k+=a>>>1&8191,P+=(a>>>14|(l=255&e[t+10]|(255&e[t+11])<<8)<<2)&8191,O+=(l>>>11|(c=255&e[t+12]|(255&e[t+13])<<8)<<5)&8191,R+=(c>>>8|(u=255&e[t+14]|(255&e[t+15])<<8)<<8)&8191,C+=u>>>5|S,d=(h=(d=0)+E*N+5*z*I+5*W*A+5*K*T+5*M*x)>>>13,h&=8191,h+=5*D*k,h+=5*L*P,h+=5*q*O,h+=5*U*R,h+=5*B*C,d+=h>>>13,h&=8191,d=(f=d+E*B+I*N+5*z*A+5*W*T+5*K*x)>>>13,f&=8191,f+=5*M*k,f+=5*D*P,f+=5*L*O,f+=5*q*R,f+=5*U*C,d+=f>>>13,f&=8191,d=(p=d+E*U+I*B+A*N+5*z*T+5*W*x)>>>13,p&=8191,p+=5*K*k,p+=5*M*P,p+=5*D*O,p+=5*L*R,p+=5*q*C,d+=p>>>13,p&=8191,d=(g=d+E*q+I*U+A*B+T*N+5*z*x)>>>13,g&=8191,g+=5*W*k,g+=5*K*P,g+=5*M*O,g+=5*D*R,g+=5*L*C,d+=g>>>13,g&=8191,d=(y=d+E*L+I*q+A*U+T*B+x*N)>>>13,y&=8191,y+=5*z*k,y+=5*W*P,y+=5*K*O,y+=5*M*R,y+=5*D*C,d+=y>>>13,y&=8191,d=(m=d+E*D+I*L+A*q+T*U+x*B)>>>13,m&=8191,m+=k*N,m+=5*z*P,m+=5*W*O,m+=5*K*R,m+=5*M*C,d+=m>>>13,m&=8191,d=(b=d+E*M+I*D+A*L+T*q+x*U)>>>
2213,b&=8191,b+=k*B,b+=P*N,b+=5*z*O,b+=5*W*R,b+=5*K*C,d+=b>>>13,b&=8191,d=(v=d+E*K+I*M+A*D+T*L+x*q)>>>13,v&=8191,v+=k*U,v+=P*B,v+=O*N,v+=5*z*R,v+=5*W*C,d+=v>>>13,v&=8191,d=(w=d+E*W+I*K+A*M+T*D+x*L)>>>13,w&=8191,w+=k*q,w+=P*U,w+=O*B,w+=R*N,w+=5*z*C,d+=w>>>13,w&=8191,d=(_=d+E*z+I*W+A*K+T*M+x*D)>>>13,_&=8191,_+=k*L,_+=P*q,_+=O*U,_+=R*B,_+=C*N,d+=_>>>13,_&=8191,h=8191&(d=(d=(d<<2)+d|0)+h|0),d>>>=13,f+=d,E=h,I=f,A=p,T=g,x=y,k=m,P=b,O=v,R=w,C=_,t+=16,r-=16;this.h[0]=E,this.h[1]=I,this.h[2]=A,this.h[3]=T,this.h[4]=x,this.h[5]=k,this.h[6]=P,this.h[7]=O,this.h[8]=R,this.h[9]=C},A.prototype.finish=function(e,t){var r,i,s,n,o=new Uint16Array(10);if(this.leftover){for(n=this.leftover,this.buffer[n++]=1;n<16;n++)this.buffer[n]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(r=this.h[1]>>>13,this.h[1]&=8191,n=2;n<10;n++)this.h[n]+=r,r=this.h[n]>>>13,this.h[n]&=8191;for(this.h[0]+=5*r,r=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=r,r=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=r,o[0]=this.h[0]+5,r=o[0]>>>13,o[0]&=8191,n=1;n<10;n++)o[n]=this.h[n]+r,r=o[n]>>>13,o[n]&=8191;for(o[9]-=8192,i=(1^r)-1,n=0;n<10;n++)o[n]&=i;for(n=0,i=~i;n<10;n++)this.h[n]=this.h[n]&i|o[n];for(n=1,this.h[0]=(this.h[0]|this.h[1]<<13)&65535,this.h[1]=(this.h[1]>>>3|this.h[2]<<10)&65535,this.h[2]=(this.h[2]>>>6|this.h[3]<<7)&65535,this.h[3]=(this.h[3]>>>9|this.h[4]<<4)&65535,this.h[4]=(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14)&65535,this.h[5]=(this.h[6]>>>2|this.h[7]<<11)&65535,this.h[6]=(this.h[7]>>>5|this.h[8]<<8)&65535,this.h[7]=(this.h[8]>
22>>8|this.h[9]<<5)&65535,s=this.h[0]+this.pad[0],this.h[0]=65535&s;n<8;n++)s=(this.h[n]+this.pad[n]|0)+(s>>>16)|0,this.h[n]=65535&s;e[t+0]=this.h[0]>>>0&255,e[t+1]=this.h[0]>>>8&255,e[t+2]=this.h[1]>>>0&255,e[t+3]=this.h[1]>>>8&255,e[t+4]=this.h[2]>>>0&255,e[t+5]=this.h[2]>>>8&255,e[t+6]=this.h[3]>>>0&255,e[t+7]=this.h[3]>>>8&255,e[t+8]=this.h[4]>>>0&255,e[t+9]=this.h[4]>>>8&255,e[t+10]=this.h[5]>>>0&255,e[t+11]=this.h[5]>>>8&255,e[t+12]=this.h[6]>>>0&255,e[t+13]=this.h[6]>>>8&255,e[t+14]=this.h[7]>>>0&255,e[t+15]=this.h[7]>>>8&255},A.prototype.update=function(e,t,r){var i,s;if(this.leftover){for((s=16-this.leftover)>r&&(s=r),i=0;i<s;i++)this.buffer[this.leftover+i]=e[t+i];if(r-=s,t+=s,this.leftover+=s,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(r>=16&&(s=r-r%16,this.blocks(e,t,s),t+=s,r-=s),r){for(i=0;i<r;i++)this.buffer[this.leftover+i]=e[t+i];this.leftover+=r}};var H=[0x428a2f98,0xd728ae22,0x71374491,0x23ef65cd,0xb5c0fbcf,0xec4d3b2f,0xe9b5dba5,0x8189dbbc,0x3956c25b,0xf348b538,0x59f111f1,0xb605d019,0x923f82a4,0xaf194f9b,0xab1c5ed5,0xda6d8118,0xd807aa98,0xa3030242,0x12835b01,0x45706fbe,0x243185be,0x4ee4b28c,0x550c7dc3,0xd5ffb4e2,0x72be5d74,0xf27b896f,0x80deb1fe,0x3b1696b1,0x9bdc06a7,0x25c71235,0xc19bf174,0xcf692694,0xe49b69c1,0x9ef14ad2,0xefbe4786,0x384f25e3,0xfc19dc6,0x8b8cd5b5,0x240ca1cc,0x77ac9c65,0x2de92c6f,0x592b0275,0x4a7484aa,0x6ea6e483,0x5cb0a9dc,0xbd41fbd4,0x76f988da,0x831153b5,0x983e5152,0xee66dfab,0xa831c66d,0x2db43210,0xb00327c8,0x98fb213f,0xbf597fc7,0xbeef0ee4,0xc6e00bf3,0x3da88fc2,0xd5a79147,0x930aa725,0x6ca6351,0xe003826f,0x14292967,0xa0e6e70,0x27b70a85,0x46d22ffc,0x2e1b2138,0x5c26c926,0x4d2c6dfc,0x5ac42aed,0x53380d13,0x9d95b3df,0x650a7354,0x8baf63de,0x766a0abb,0x3c77b2a8,0x81c2c92e,0x47edaee6,0x92722c85,0x1482353b,0xa2bfe8a1,0x4cf10364,0xa81a664b,0xbc423001,0xc24b8b70,0xd0f89791,0xc76c51a3,0x654be30,0xd192e819,0xd6ef5218,0xd6990624,0x5565a910,0xf40e3585,0x5771202a,0x106aa070,0x32bbd1b8,0x19a4c116,0xb8d2d0c8,0x1e376c08,0x5141ab53,0x2748774c,0xdf8eeb99,0x34b0bcb5,0xe19b48a8,0x391c0cb3,0xc5c95a63,0x4ed8aa4a,0xe3418acb,0x5b9cca4f,0x7763e373,0x682e6ff3,0xd6b2b8a3,0x748f82ee,0x5defb2fc,0x78a5636f,0x43172f60,0x84c87814,0xa1f0ab72,0x8cc70208,0x1a6439ec,0x90befffa,0x23631e28,0xa4506ceb,0xde82bde9,0xbef9a3f7,0xb2c67915,0xc67178f2,0xe372532b,0xca273ece,0xea26619c,0xd186b8c7,0x21c0c207,0xeada7dd6,0xcde0eb1e,0xf57d4f7f,0xee6ed178,0x6f067aa,0x72176fba,0xa637dc5,0xa2c898a6,0x113f9804,0xbef90dae,0x1b710b35,0x131c471b,0x28db77f5,0x23047d84,0x32caab7b,0x40c72493,0x3c9ebe0a,0x15c9bebc,0x431d67c4,0x9c100d4c,0x4cc5d4be,0xcb3e42b6,0x597f299c,0xfc657e2a,0x5fcb6fab,0x3ad6faec,0x6c44198c,0x4a475817];function G(e,t,r,i){for(var s,n,o,a,l,c,u,d,h,f,p,g,y,m,b,v,w,_,S,E,I,A,T,x,k,P,O=new Int32Array(16),R=new Int32Array(16),C=e[0],N=e[1],B=e[2],U=e[3],q=e[4],L=e[5],D=e[6],M=e[7],K=t[0],W=t[1],z=t[2],j=t[3],V=t[4],$=t[5],F=t[6],G=t[7],J=0;i>=128;){for(S=0;S<16;S++)E=8*S+J,O[S]=r[E+0]<<24|r[E+1]<<16|r[E+2]<<8|r[E+3],R[S]=r[E+4]<<24|r[E+5]<<16|r[E+6]<<8|r[E+7];for(S=0;S<80;S++)if(s=C,n=N,o=B,a=U,l=q,c=L,u=D,d=M,h=K,f=W,p=z,g=j,y=V,m=$,b=F,v=G,I=M,T=65535&(A=G),x=A>>>16,k=65535&I,P=I>>>16,I=(q>>>14|V<<18)^(q>>>18|V<<14)^(V>>>9|q<<23),T+=65535&(A=(V>>>14|q<<18)^(V>>>18|q<<14)^(q>>>9|V<<23)),x+=A>>>16,k+=65535&I,P+=I>>>16,I=q&L^~q&D,T+=65535&(A=V&$^~V&F),x+=A>>>16,k+=65535&I,P+=I>>>16,I=H[2*S],T+=65535&(A=H[2*S+1]),x+=A>>>16,k+=65535&I,P+=I>>>16,I=O[S%16],T+=65535&(A=R[S%16]),x+=A>>>16,k+=65535&I,P+=I>>>16,x+=T>>>16,k+=x>>>16,P+=k>>>16,w=65535&k|P<<16,_=65535&T|x<<16,I=w,T=65535&(A=_),x=A>>>16,k=65535&I,P=I>>>16,I=(C>>>28|K<<4)^(K>>>2|C<<30)^(K>>>7|C<<25),T+=65535&(A=(K>>>28|C<<4)^(C>>>2|K<<30)^(C>>>7|K<<25)),x+=A>>>16,k+=65535&I,P+=I>>>16,I=C&N^C&B^N&B,T+=65535&(A=K&W^K&z^W&z),x+=A>>>16,k+=65535&I,P+=I>>>16,x+=T>>>16,k+=x>>>16,P+=k>>>16,d=65535&k|P<<16,v=65535&T|x<<16,I=a,T=65535&(A=g),x=A>>>16,k=65535&I,P=I>>>16,I=w,T+=65535&(A=_),x+=A>>>16,k+=65535&I,P+=I>>>16,x+=T>>>16,k+=x>>>16,P+=k>>>16,a=65535&k|P<<16,g=65535&T|x<<16,N=s,B=n,U=o,q=a,L=l,D=c,M=u,C=d,W=h,z=f,j=p,V=g,$=y,F=m,G=b,K=v,S%16==15)for(E=0;E<16;E++)I=O[E],T=65535&(A=R[E]),x=A>>>16,k=65535&I,P=I>>>16,I=O[(E+9)%16],T+=65535&(A=R[(E+9)%16]),x+=A>>>16,k+=65535&I,P+=I>>>16,I=((w=O[(E+1)%16])>>>1|(_=R[(E+1)%16])<<31)^(w>>>8|_<<24)^w>>>7,T+=65535&(A=(_>>>1|w<<31)^(_>>>8|w<<24)^(_>>>7|w<<25)),x+=A>>>16,k+=65535&I,P+=I>>>16,I=((w=O[(E+14)%16])>>>19|(_=R[(E+14)%16])<<13)^(_>>>29|w<<3)^w>>>6,T+=65535&(A=(_>>>19|w<<13)^(w>>>29|_<<3)^(_>>>6|w<<26)),x+=A>>>16,k+=65535&I,P+=I>>>16,x+=T>>>16,k+=x>>>16,P+=k>>>16,O[E]=65535&k|P<<16,R[E]=65535&T|x<<16;I=C,T=65535&(A=K),x=A>>>16,k=65535&I,P=I>>>16,I=e[0],T+=65535&(A=t[0]),x+=A>>>16,k+=65535&I,P+=I>>>16,x+=T>>>16,k+=x>>>16,P+=k>>>16,e[0]=C=65535&k|P<<16,t[0]=K=65535&T|x<<16,I=N,T=65535&(A=W),x=A>>>16,k=65535&I,P=I>>>16,I=e[1],T+=65535&(A=t[1]),x+=A>>>16,k+=65535&I,P+=I>>>16,x+=T>>>16,k+=x>>>16,P+=k>>>16,e[1]=N=65535&k|P<<16,t[1]=W=65535&T|x<<16,I=B,T=65535&(A=z),x=A>>>16,k=65535&I,P=I>>>16,I=e[2],T+=65535&(A=t[2]),x+=A>>>16,k+=65535&I,P+=I>>>16,x+=T>>>16,k+=x>>>16,P+=k>>>16,e[2]=B=65535&k|P<<16,t[2]=z=65535&T|x<<16,I=U,T=65535&(A=j),x=A>>>16,k=65535&I,P=I>>>16,I=e[3],T+=65535&(A=t[3]),x+=A>>>16,k+=65535&I,P+=I>>>16,x+=T>>>16,k+=x>>>16,P+=k>>>16,e[3]=U=65535&k|P<<16,t[3]=j=65535&T|x<<16,I=q,T=65535&(A=V),x=A>>>16,k=65535&I,P=I>>>16,I=e[4],T+=65535&(A=t[4]),x+=A>>>16,k+=65535&I,P+=I>>>16,x+=T>>>16,k+=x>>>16,P+=k>>>16,e[4]=q=65535&k|P<<16,t[4]=V=65535&T|x<<16,I=L,T=65535&(A=$),x=A>>>16,k=65535&I,P=I>>>16,I=e[5],T+=65535&(A=t[5]),x+=A>>>16,k+=65535&I,P+=I>>>16,x+=T>>>16,k+=x>>>16,P+=k>>>
2216,e[5]=L=65535&k|P<<16,t[5]=$=65535&T|x<<16,I=D,T=65535&(A=F),x=A>>>16,k=65535&I,P=I>>>16,I=e[6],T+=65535&(A=t[6]),x+=A>>>16,k+=65535&I,P+=I>>>16,x+=T>>>16,k+=x>>>16,P+=k>>>16,e[6]=D=65535&k|P<<16,t[6]=F=65535&T|x<<16,I=M,T=65535&(A=G),x=A>>>16,k=65535&I,P=I>>>16,I=e[7],T+=65535&(A=t[7]),x+=A>>>16,k+=65535&I,P+=I>>>16,x+=T>>>16,k+=x>>>16,P+=k>>>16,e[7]=M=65535&k|P<<16,t[7]=G=65535&T|x<<16,J+=128,i-=128}return i}function J(e,t,r){var i,s=new Int32Array(8),n=new Int32Array(8),o=new Uint8Array(256),a=r;for(s[0]=0x6a09e667,s[1]=0xbb67ae85,s[2]=0x3c6ef372,s[3]=0xa54ff53a,s[4]=0x510e527f,s[5]=0x9b05688c,s[6]=0x1f83d9ab,s[7]=0x5be0cd19,n[0]=0xf3bcc908,n[1]=0x84caa73b,n[2]=0xfe94f82b,n[3]=0x5f1d36f1,n[4]=0xade682d1,n[5]=0x2b3e6c1f,n[6]=0xfb41bd6b,n[7]=0x137e2179,G(s,n,t,r),r%=128,i=0;i<r;i++)o[i]=t[a-r+i];for(o[r]=128,o[(r=256-(r<112)*128)-9]=0,p(o,r-8,a/0x20000000|0,a<<3),G(s,n,o,r),i=0;i<8;i++)p(e,8*i,s[i],n[i]);return 0}function Y(e,t){var i=r(),s=r(),n=r(),o=r(),a=r(),l=r(),c=r(),d=r(),h=r();D(i,e[1],e[0]),D(h,t[1],t[0]),M(i,i,h),L(s,e[0],e[1]),L(h,t[0],t[1]),M(s,s,h),M(n,e[3],t[3]),M(n,n,u),M(o,e[2],t[2]),L(o,o,o),D(a,s,i),D(l,o,n),L(c,o,n),L(d,s,i),M(e[0],a,l),M(e[1],d,c),M(e[2],c,l),M(e[3],a,d)}function Z(e,t,r){var i;for(i=0;i<4;i++)C(e[i],t[i],r)}function X(e,t){var i=r(),s=r(),n=r();W(n,t[2]),M(i,t[0],n),M(s,t[1],n),N(e,s),e[31]^=U(i)<<7}function Q(e,t,r){var i,s;for(O(e[0],o),O(e[1],a),O(e[2],a),O(e[3],o),s=255;s>=0;--s)Z(e,t,i=r[s/8|0]>>(7&s)&1),Y(t,e),Y(e,e),Z(e,t,i)}function ee(e,t){var i=[r(),r(),r(),r()];O(i[0],d),O(i[1],h),O(i[2],a),M(i[3],d,h),Q(e,i,t)}function et(e,t,s){var n,o=new Uint8Array(64),a=[r(),r(),r(),r()];for(s||i(t,32),J(o,t,32),o[0]&=248,o[31]&=127,o[31]|=64,ee(a,o),X(e,a),n=0;n<32;n++)t[n+32]=e[n];return 0}var er=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function ei(e,t){var r,i,s,n;for(i=63;i>=32;--i){for(r=0,s=i-32,n=i-12;s<n;++s)t[s]+=r-16*t[i]*er[s-(i-32)],r=Math.floor((t[s]+128)/256),t[s]-=256*r;t[s]+=r,t[i]=0}for(s=0,r=0;s<32;s++)t[s]+=r-(t[31]>>4)*er[s],r=t[s]>>8,t[s]&=255;for(s=0;s<32;s++)t[s]-=r*er[s];for(i=0;i<32;i++)t[i+1]+=t[i]>>8,e[i]=255&t[i]}function es(e){var t,r=new Float64Array(64);for(t=0;t<64;t++)r[t]=e[t];for(t=0;t<64;t++)e[t]=0;ei(e,r)}function en(e,t,i,s){var n,o,a=new Uint8Array(64),l=new Uint8Array(64),c=new Uint8Array(64),u=new Float64Array(64),d=[r(),r(),r(),r()];for(J(a,s,32),a[0]&=248,a[31]&=127,a[31]|=64,n=0;n<i;n++)e[64+n]=t[n];for(n=0;n<32;n++)e[32+n]=a[32+n];for(J(c,e.subarray(32),i+32),es(c),ee(d,c),X(e,d),n=32;n<64;n++)e[n]=s[n];for(J(l,e,i+64),es(l),n=0;n<64;n++)u[n]=0;for(n=0;n<32;n++)u[n]=c[n];for(n=0;n<32;n++)for(o=0;o<32;o++)u[n+o]+=l[n]*a[o];return ei(e.subarray(32),u),i+64}function eo(e,t,i,s){var n,l,u,d,h,p,g,y,b=new Uint8Array(32),v=new Uint8Array(64),w=[r(),r(),r(),r()],_=[r(),r(),r(),r()];if(i<64||(n=r(),l=r(),u=r(),d=r(),h=r(),p=r(),g=r(),(O(_[2],a),q(_[1],s),K(u,_[1]),M(d,u,c),D(u,u,_[2]),L(d,_[2],d),K(h,d),K(p,h),M(g,p,h),M(n,g,u),M(n,n,d),z(n,n),M(n,n,u),M(n,n,d),M(n,n,d),M(_[0],n,d),K(l,_[0]),M(l,l,d),B(l,u)&&M(_[0],_[0],f),K(l,_[0]),M(l,l,d),B(l,u))?-1:(U(_[0])===s[31]>>7&&D(_[0],o,_[0]),M(_[3],_[0],_[1]),0)))return -1;for(y=0;y<i;y++)e[y]=t[y];for(y=0;y<32;y++)e[y+32]=s[y];if(J(v,e,i),es(v),Q(w,_,v),ee(_,t.subarray(32)),Y(w,_),X(b,w),i-=64,m(t,0,b,0)){for(y=0;y<i;y++)e[y]=0;return -1}for(y=0;y<i;y++)e[y]=t[y+64];return i}function ea(e,t){if(32!==e.length)throw Error("bad key size");if(24!==t.length)throw Error("bad nonce size")}function el(){for(var e=0;e<arguments.length;e++)if(!(arguments[e]instanceof Uint8Array))throw TypeError("unexpected type, use Uint8Array")}function ec(e){for(var t=0;t<e.length;t++)e[t]=0}e.lowlevel={crypto_core_hsalsa20:v,crypto_stream_xor:I,crypto_stream:E,crypto_stream_salsa20_xor:_,crypto_stream_salsa20:S,crypto_onetimeauth:T,crypto_onetimeauth_verify:x,crypto_verify_16:y,crypto_verify_32:m,crypto_secretbox:k,crypto_secretbox_open:P,crypto_scalarmult:j,crypto_scalarmult_base:V,crypto_box_beforenm:F,crypto_box_afternm:k,crypto_box:function(e,t,r,i,s,n){var o=new Uint8Array(32);return F(o,s,n),k(e,t,r,i,o)},crypto_box_open:function(e,t,r,i,s,n){var o=new Uint8Array(32);return F(o,s,n),P(e,t,r,i,o)},crypto_box_keypair:$,crypto_hash:J,crypto_sign:en,crypto_sign_keypair:et,crypto_sign_open:eo,crypto_secretbox_KEYBYTES:32,crypto_secretbox_NONCEBYTES:24,crypto_secretbox_ZEROBYTES:32,crypto_secretbox_BOXZEROBYTES:16,crypto_scalarmult_BYTES:32,crypto_scalarmult_SCALARBYTES:32,crypto_box_PUBLICKEYBYTES:32,crypto_box_SECRETKEYBYTES:32,crypto_box_BEFORENMBYTES:32,crypto_box_NONCEBYTES:24,crypto_box_ZEROBYTES:32,crypto_box_BOXZEROBYTES:16,crypto_sign_BYTES:64,crypto_sign_PUBLICKEYBYTES:32,crypto_sign_SECRETKEYBYTES:64,crypto_sign_SEEDBYTES:32,crypto_hash_BYTES:64,gf:r,D:c,L:er,pack25519:N,unpack25519:q,M:M,A:L,S:K,Z:D,pow2523:z,add:Y,set25519:O,modL:ei,scalarmult:Q,scalarbase:ee},e.randomBytes=function(e){var t=new Uint8Array(e);return i(t,e),t},e.secretbox=function(e,t,r){el(e,t,r),ea(r,t);for(var i=new Uint8Array(32+e.length),s=new Uint8Array(i.length),n=0;n<e.length;n++)i[n+32]=e[n];return k(s,i,i.length,t,r),s.subarray(16)},e.secretbox.open=function(e,t,r){el(e,t,r),ea(r,t);for(var i=new Uint8Array(16+e.length),s=new Uint8Array(i.length),n=0;n<e.length;n++)i[n+16]=e[n];return i.length<32||0!==P(s,i,i.length,t,r)?null:s.subarray(32)},e.secretbox.keyLength=32,e.secretbox.nonceLength=24,e.secretbox.overheadLength=16,e.scalarMult=function(e,t){if(el(e,t),32!==e.length)throw Error("bad n size");if(32!==t.length)throw Error("bad p size");
22var r=new Uint8Array(32);return j(r,e,t),r},e.scalarMult.base=function(e){if(el(e),32!==e.length)throw Error("bad n size");var t=new Uint8Array(32);return V(t,e),t},e.scalarMult.scalarLength=32,e.scalarMult.groupElementLength=32,e.box=function(t,r,i,s){var n=e.box.before(i,s);return e.secretbox(t,r,n)},e.box.before=function(e,t){el(e,t);if(32!==e.length)throw Error("bad public key size");if(32!==t.length)throw Error("bad secret key size");var r=new Uint8Array(32);return F(r,e,t),r},e.box.after=e.secretbox,e.box.open=function(t,r,i,s){var n=e.box.before(i,s);return e.secretbox.open(t,r,n)},e.box.open.after=e.secretbox.open,e.box.keyPair=function(){var e=new Uint8Array(32),t=new Uint8Array(32);return $(e,t),{publicKey:e,secretKey:t}},e.box.keyPair.fromSecretKey=function(e){if(el(e),32!==e.length)throw Error("bad secret key size");var t=new Uint8Array(32);return V(t,e),{publicKey:t,secretKey:new Uint8Array(e)}},e.box.publicKeyLength=32,e.box.secretKeyLength=32,e.box.sharedKeyLength=32,e.box.nonceLength=24,e.box.overheadLength=e.secretbox.overheadLength,e.sign=function(e,t){if(el(e,t),64!==t.length)throw Error("bad secret key size");var r=new Uint8Array(64+e.length);return en(r,e,e.length,t),r},e.sign.open=function(e,t){if(el(e,t),32!==t.length)throw Error("bad public key size");var r=new Uint8Array(e.length),i=eo(r,e,e.length,t);if(i<0)return null;for(var s=new Uint8Array(i),n=0;n<s.length;n++)s[n]=r[n];return s},e.sign.detached=function(t,r){for(var i=e.sign(t,r),s=new Uint8Array(64),n=0;n<s.length;n++)s[n]=i[n];return s},e.sign.detached.verify=function(e,t,r){if(el(e,t,r),64!==t.length)throw Error("bad signature size");if(32!==r.length)throw Error("bad public key size");var i,s=new Uint8Array(64+e.length),n=new Uint8Array(64+e.length);for(i=0;i<64;i++)s[i]=t[i];for(i=0;i<e.length;i++)s[i+64]=e[i];return eo(n,s,s.length,r)>=0},e.sign.keyPair=function(){var e=new Uint8Array(32),t=new Uint8Array(64);return et(e,t),{publicKey:e,secretKey:t}},e.sign.keyPair.fromSecretKey=function(e){if(el(e),64!==e.length)throw Error("bad secret key size");for(var t=new Uint8Array(32),r=0;r<t.length;r++)t[r]=e[32+r];return{publicKey:t,secretKey:new Uint8Array(e)}},e.sign.keyPair.fromSeed=function(e){if(el(e),32!==e.length)throw Error("bad seed size");for(var t=new Uint8Array(32),r=new Uint8Array(64),i=0;i<32;i++)r[i]=e[i];return et(t,r,!0),{publicKey:t,secretKey:r}},e.sign.publicKeyLength=32,e.sign.secretKeyLength=64,e.sign.seedLength=32,e.sign.signatureLength=64,e.hash=function(e){el(e);var t=new Uint8Array(64);return J(t,e,e.length),t},e.hash.hashLength=64,e.verify=function(e,t){return el(e,t),0!==e.length&&0!==t.length&&e.length===t.length&&0===g(e,0,t,0,e.length)},e.setPRNG=function(e){i=e},(t="u">typeof self?self.crypto||self.msCrypto:null)&&t.getRandomValues?e.setPRNG(function(e,r){var i,s=new Uint8Array(r);for(i=0;i<r;i+=65536)t.getRandomValues(s.subarray(i,i+Math.min(r-i,65536)));for(i=0;i<r;i++)e[i]=s[i];ec(s)}):(t={}).randomBytes&&e.setPRNG(function(e,r){var i,s=t.randomBytes(r);for(i=0;i<r;i++)e[i]=s[i];ec(s)})}(t.exports?t.exports:self.nacl=self.nacl||{})},940658,e=>{"use strict";e.s(["buildUrl",0,(e,t)=>`https://phantom.app/ul/v1/${e}?${t.toString()}`])},91826,e=>{"use strict";e.s(["clearRedirectUrlForPhantom",0,e=>(["data","nonce","phantom_encryption_public_key","errorCode","errorMessage","data"].forEach(t=>{e.searchParams.delete(t)}),e.toString())])},194997,e=>{"use strict";var t=e.i(467034),r=e.i(654611),i=e.i(596510),s=e.i(779772);let n=(e,t)=>{let r=`Failed to decrypt phantom redirect payload: ${e} was invalid (${t})`;throw s.logger.error(r),Error(r)};e.s(["decryptPayload",0,(e,s,o)=>{e||n("data",e),s||n("nonce",s),o||n("sharedSecret",o);let a=i.default.box.open.after(r.default.decode(e),r.default.decode(s),o);if(!a)throw Error("Unable to decrypt data");return JSON.parse(t.Buffer.from(a).toString("utf8"))}])},114139,e=>{"use strict";var t=e.i(467034),r=e.i(596510);e.s(["encryptPayload",0,(e,i)=>{let s=r.default.randomBytes(24),n=r.default.box.after(t.Buffer.from(JSON.stringify(e)),s,i);return[s,n]}])},441988,e=>{"use strict";var t=e.i(779772);let r={address:{get:()=>{var e;let r=null!=(e=localStorage.getItem("dynamic_phantom_wallet_address"))?e:void 0;return t.logger.logVerboseTroubleshootingMessage("[PhantomStorage] address.get",{value:r}),r},remove:()=>{t.logger.logVerboseTroubleshootingMessage("[PhantomStorage] address.remove"),localStorage.removeItem("dynamic_phantom_wallet_address")},set:e=>{t.logger.logVerboseTroubleshootingMessage("[PhantomStorage] address.set",{address:e.toString()}),localStorage.setItem("dynamic_phantom_wallet_address",e.toString())}},encryptionPublicKey:{get:()=>{let e=localStorage.getItem("dynamic_phantom_public_key");if(e)return new Uint8Array(JSON.parse(e))},remove:()=>{localStorage.removeItem("dynamic_phantom_public_key")},set:e=>{localStorage.setItem("dynamic_phantom_public_key",JSON.stringify([...e]))}},encryptionSecretKey:{get:()=>{let e=localStorage.getItem("dynamic_phantom_secret_key");if(e)return new Uint8Array(JSON.parse(e))},remove:()=>{localStorage.removeItem("dynamic_phantom_secret_key")},set:e=>{localStorage.setItem("dynamic_phantom_secret_key",JSON.stringify([...e]))}},message:{get:()=>{var e;let r=null!=(e=localStorage.getItem("dynamic_phantom_message_to_sign"))?e:void 0;return t.logger.logVerboseTroubleshootingMessage("[PhantomStorage] message.get",{hasMessage:!!r,messageLength:null==r?void 0:r.length,messagePreview:null==r?void 0:r.substring(0,100)}),r},remove:()=>{t.logger.logVerboseTroubleshootingMessage("[PhantomStorage] message.remove"),localStorage.removeItem("dynamic_phantom_message_to_sign")},set:e=>{t.logger.logVerboseTroubleshootingMessage("[PhantomStorage] message.set",{messageLength:e.length,messagePreview:e.substring(0,100)}),localStorage.setItem("dynamic_phantom_message_to_sign",e)}},method:{get:()=>{var e;let r=null!=(e=localStorage.getItem("dynamic_phantom_method"))?e:void 0;return t.logger.logVerboseTroubleshootingMessage("[PhantomStorage] method.get",{value:r}),r},remove:()=>{t.logger.logVerboseTroubleshootingMessage("[PhantomStorage] method.remove"),localStorage.removeItem("dynamic_phantom_method")},set:e=>{t.logger.logVerboseTroubleshootingMessage("[PhantomStorage] method.set",{method:e}),localStorage.setItem("dynamic_phantom_method",e)}},requestId:{get:()=>{var e;return null!=(e=localStorage.getItem("dynamic_phantom_request_id"))?e:void 0},remove:()=>{localStorage.removeItem("dynamic_phantom_request_id")},set:e=>{localStorage.setItem("dynamic_phantom_request_id",e)}},sendOptions:{get:()=>{var e;return null!=(e=localStorage.getItem("dynamic_phantom_send_options"))?e:void 0},remove:()=>{localStorage.removeItem("dynamic_phantom_send_options")},set:e=>{localStorage.setItem("dynamic_phantom_send_options",e)}},session:{get:()=>{var e;let r=null!=(e=localStorage.getItem("dynamic_phantom_session"))?e:void 0;return t.logger.logVerboseTroubleshootingMessage("[PhantomStorage] 
22session.get",{hasSession:!!r}),r},remove:()=>{t.logger.logVerboseTroubleshootingMessage("[PhantomStorage] session.remove"),localStorage.removeItem("dynamic_phantom_session")},set:e=>{t.logger.logVerboseTroubleshootingMessage("[PhantomStorage] session.set",{session:e}),localStorage.setItem("dynamic_phantom_session",e)}},sharedSecret:{get:()=>{let e=localStorage.getItem("dynamic_phantom_shared_secret");if(t.logger.logVerboseTroubleshootingMessage("[PhantomStorage] sharedSecret.get",{hasSharedSecret:!!e}),e)return new Uint8Array(JSON.parse(e))},remove:()=>{t.logger.logVerboseTroubleshootingMessage("[PhantomStorage] sharedSecret.remove"),localStorage.removeItem("dynamic_phantom_shared_secret")},set:e=>{t.logger.logVerboseTroubleshootingMessage("[PhantomStorage] sharedSecret.set",{sharedSecretLength:e.length}),localStorage.setItem("dynamic_phantom_shared_secret",JSON.stringify([...e]))}}};e.s(["clearStorage",0,()=>{for(let e in t.logger.logVerboseTroubleshootingMessage("[PhantomStorage] clearStorage called"),r)r[e].remove()},"storage",0,r])},177658,e=>{"use strict";var t=e.i(467034),r=e.i(115349),i=e.i(127261),s=e.i(654611),n=e.i(596510);e.i(484200);var o=e.i(510137);e.i(973402);var a=e.i(415565),l=e.i(159491),c=e.i(634943),u=e.i(940658),d=e.i(91826),h=e.i(194997),f=e.i(114139),p=e.i(441988),g=e.i(779772);class y extends o.SolanaWalletConnector{constructor(e){super(Object.assign({},e)),this.name="Phantom",this.overrideKey="phantom"}getMethod(){throw Error("Method not implemented.")}setupNativeMobileListener({eventName:e,methodName:t,getResult:r,shouldIgnoreEvent:i}){if(!a.PlatformService.isNativeMobile)return;let s=`${Date.now()}-${Math.random().toString(36).slice(2)}`;return p.storage.requestId.set(s),g.logger.logVerboseTroubleshootingMessage(`[PhantomRedirect] ${t} - setting up listener`,{requestId:s}),new Promise((n,o)=>{let a=l=>{l.requestId!==s||(null==i?void 0:i(l,s))?g.logger.logVerboseTroubleshootingMessage(`[PhantomRedirect] ${t} - ignoring event (requestId mismatch)`,{expectedRequestId:s,receivedRequestId:l.requestId}):(g.logger.logVerboseTroubleshootingMessage(`[PhantomRedirect] ${t} - listener received matching event`,{errorCode:l.errorCode,requestId:s}),this.off(e,a),l.errorCode?o(Error(l.errorMessage||l.errorCode)):n(r(l)))};this.on(e,a)})}openPhantomUrl({payload:e,sharedSecret:t,encryptionPublicKey:r,phantomEndpoint:i,methodToStore:n}){let[o,l]=(0,f.encryptPayload)(e,t),c=new URLSearchParams({dapp_encryption_public_key:s.default.encode(r),nonce:s.default.encode(o),payload:s.default.encode(l),redirect_link:(0,d.clearRedirectUrlForPhantom)(a.PlatformService.getUrl())}),h=(0,u.buildUrl)(i,c);p.storage.method.set(n),g.logger.debug(`[PhantomRedirect] ${n} - opening Phantom`,{isNativeMobile:a.PlatformService.isNativeMobile}),a.PlatformService.openURL(h)}getAddress(){return(0,r.__awaiter)(this,void 0,void 0,function*(){let e=p.storage.address.get();if(e)return e;yield this.connect()})}connect(){return(0,r.__awaiter)(this,void 0,void 0,function*(){var e;let t=l.StorageService.getItem(c.PHANTOM_REDIRECT_CONNECTION_TYPE_KEY);t&&(t.connectorConsumed?l.StorageService.setItem(c.PHANTOM_REDIRECT_CONNECTION_TYPE_KEY,void 0):(t.connectorConsumed=!0,l.StorageService.setItem(c.PHANTOM_REDIRECT_CONNECTION_TYPE_KEY,t)));let r=n.default.box.keyPair();p.storage.encryptionPublicKey.set(r.publicKey),p.storage.encryptionSecretKey.set(r.secretKey);let{href:i}=a.PlatformService.getUrl(),o=i.includes("localhost")||i.includes("0.0.0.0")||i.includes("127.0.0.1"),h=this.getSelectedNetwork(),f=null!=(e=null==h?void 0:h.cluster)?e:"mainnet-beta";"mainnet"===f&&(f="mainnet-beta");let g=new URLSearchParams({app_url:o?"https://demo.dynamic.xyz":i,cluster:f,dapp_encryption_public_key:s.default.encode(r.publicKey),redirect_link:(0,d.clearRedirectUrlForPhantom)(a.PlatformService.getUrl())}),y=(0,u.buildUrl)("connect",g);a.PlatformService.openURL(y)})}getSession(){return(0,r.__awaiter)(this,void 0,void 0,function*(){let{data:e,nonce:t,phantom_encryption_public_key:r,encryptionSecretKey:o}=this.getInputsOrThrow("getSession",["data","nonce","phantom_encryption_public_key"],["encryptionSecretKey"]),a=n.default.box.before(s.default.decode(r),o);p.storage.sharedSecret.set(a);let l=(0,h.decryptPayload)(e,t,a);return p.storage.session.set(l.session),p.storage.address.set(new i.PublicKey(l.public_key)),l.public_key})}signMessage(e){return(0,r.__awaiter)(this,void 0,void 0,function*(){g.logger.debug("[PhantomRedirect] signMessage called",{messageLength:e.length,messagePreview:e.substring(0,200)});let{session:r,sharedSecret:i,encryptionPublicKey:n}=this.getInputsOrThrow("signMessage",[],["session","sharedSecret","encryptionPublicKey"]);p.storage.message.set(e);let o={message:s.default.encode(t.Buffer.from(e)),session:r};this.openPhantomUrl({encryptionPublicKey:n,methodToStore:"signMessage",payload:o,phantomEndpoint:"signMessage",sharedSecret:i}
22);let a=this.setupNativeMobileListener({eventName:"signMessage",getResult:e=>e.signature,methodName:"signMessage",shouldIgnoreEvent:t=>t.message!==e});if(a)return a;throw g.logger.debug("[PhantomRedirect] signMessage - mobile web, throwing ignore error"),Error("ignore")})}extractSignature(){var e;g.logger.debug("[PhantomRedirect] extractSignature called");let{data:t,nonce:r,sharedSecret:i,message:s}=this.getInputsOrThrow("extractSignature",["data","nonce"],["sharedSecret","message"]);g.logger.debug("[PhantomRedirect] extractSignature - retrieved from storage",{dataPresent:!!t,message:s,messageLength:null==s?void 0:s.length,noncePresent:!!r,sharedSecretPresent:!!i});let n=(0,h.decryptPayload)(t,r,i);return g.logger.debug("[PhantomRedirect] extractSignature - decrypted payload",{signature:n.signature,signatureLength:null==(e=n.signature)?void 0:e.length}),{message:s,signature:n.signature}}extractTransactions(){let{data:e,nonce:t,sharedSecret:r}=this.getInputsOrThrow("extractTransactions",["data","nonce"],["sharedSecret"]);return(0,h.decryptPayload)(e,t,r).transactions.map(e=>i.Transaction.from(s.default.decode(e)))}extractTransaction(){let{data:e,nonce:t,sharedSecret:r}=this.getInputsOrThrow("extractTransaction",["data","nonce"],["sharedSecret"]),n=(0,h.decryptPayload)(e,t,r),o=s.default.decode(n.transaction);try{return i.VersionedTransaction.deserialize(o)}catch(e){return i.Transaction.from(o)}}extractAndSendTransaction(){return(0,r.__awaiter)(this,void 0,void 0,function*(){g.logger.debug("[PhantomRedirect] extractAndSendTransaction called");let e=this.extractTransaction(),t=p.storage.sendOptions.get();p.storage.sendOptions.remove();let r=t?JSON.parse(t):void 0;g.logger.debug("[PhantomRedirect] Sending transaction to network",{hasSendOptions:!!r,isVersioned:e instanceof i.VersionedTransaction});let s=e.serialize(),n=yield this.getWalletClient().sendRawTransaction(s,r);return g.logger.debug("[PhantomRedirect] Transaction sent successfully",{signature:n}),n})}consumeMethod(){let e=p.storage.method.get();return p.storage.method.remove(),e}consumeRequestId(){let e=p.storage.requestId.get();return p.storage.requestId.remove(),e}getSigner(){return(0,r.__awaiter)(this,void 0,void 0,function*(){let e=p.storage.address.get();if(e)return{addListener:()=>{throw Error("Not implemented")},connect:()=>{throw Error("Not implemented")},disconnect:()=>{throw Error("Not implemented")},emit:()=>{throw Error("Not implemented")},eventNames:()=>{throw Error("Not implemented")},isBackpack:!1,isBraveWallet:!1,isConnected:!0,isExodus:!1,isGlow:!1,isMagicEden:!1,isPhantom:!0,isSolflare:!1,listenerCount:()=>{throw Error("Not implemented")},listeners:()=>{throw Error("Not implemented")},off:()=>{throw Error("Not implemented")},on:()=>{throw Error("Not implemented")},once:()=>{throw Error("Not implemented")},providers:[],publicKey:new i.PublicKey(e),removeAllListeners:()=>{throw Error("Not implemented")},removeListener:()=>{throw Error("Not implemented")},signAllTransactions:e=>(0,r.__awaiter)(this,void 0,void 0,function*(){let t=e.map(e=>s.default.encode(e.serialize({requireAllSignatures:!1}))),{session:r,sharedSecret:i,encryptionPublicKey:n}=this.getInputsOrThrow("signAllTransactions",[],["session","sharedSecret","encryptionPublicKey"]);this.openPhantomUrl({encryptionPublicKey:n,methodToStore:"signAllTransactions",payload:{session:r,transactions:t},phantomEndpoint:"signAllTransactions",sharedSecret:i});let o=this.setupNativeMobileListener({eventName:"signAllTransactions",getResult:e=>e.transactions||[],methodName:"signAllTransactions"});return o||[]}),signAndSendTransaction:(e,t)=>(0,r.__awaiter)(this,void 0,void 0,function*(){let r=s.default.encode(e.serialize({requireAllSignatures:!1})),{session:i,sharedSecret:n,encryptionPublicKey:o}=this.getInputsOrThrow("signAndSendTransaction",[],["session","sharedSecret","encryptionPublicKey"]);t&&p.storage.sendOptions.set(JSON.stringify(t)),this.openPhantomUrl({encryptionPublicKey:o,methodToStore:"signAndSendTransaction",payload:{session:i,transaction:r},phantomEndpoint:"signTransaction",sharedSecret:n});let a=this.setupNativeMobileListener({eventName:"signAndSendTransaction",getResult:e=>({signature:e.signature||""}),methodName:"signAndSendTransaction"});return a||{signature:""}}),signMessage:e=>(0,r.__awaiter)(this,void 0,void 0,function*(){let t=new TextDecoder().decode(e),r=yield this.signMessage(t);return{signature:r?s.default.decode(r):new Uint8Array(0)}}),signTransaction:e=>(0,r.__awaiter)(this,void 0,void 0,function*(){let t=s.default.encode(e.serialize({requireAllSignatures:!1})),{session:r,sharedSecret:i,encryptionPublicKey:n}=this.getInputsOrThrow("signTransaction",[],["session","sharedSecret","encryptionPublicKey"]);this.openPhantomUrl({encryptionPublicKey:n,methodToStore:"signTransaction",payload:{session:r,transaction:t},phantomEndpoint:"signTransaction",sharedSecret:i}
22);let o=this.setupNativeMobileListener({eventName:"signTransaction",getResult:e=>e.transaction,methodName:"signTransaction"});return o||e})}})}getConnectedAccounts(){return(0,r.__awaiter)(this,void 0,void 0,function*(){let e=p.storage.address.get();return e?[e]:[]})}endSession(){return(0,r.__awaiter)(this,void 0,void 0,function*(){let e=p.storage.address.get(),t=p.storage.session.get(),r=p.storage.sharedSecret.get(),i=p.storage.encryptionPublicKey.get();if((0,p.clearStorage)(),!e||!t||!i||!r)return;let[n,o]=(0,f.encryptPayload)({session:t},r),l=new URLSearchParams({dapp_encryption_public_key:s.default.encode(i),nonce:s.default.encode(n),payload:s.default.encode(o),redirect_link:(0,d.clearRedirectUrlForPhantom)(a.PlatformService.getUrl())}),c=(0,u.buildUrl)("disconnect",l);a.PlatformService.openURL(c)})}getInputsOrThrow(e,t,r){let i={},s=a.PlatformService.getUrl().searchParams;return t.forEach(t=>{let r=s.get(t);if(!r)throw Error(`[PhantomRedirect] ${e} called, but required input '${t}' not found in query params`);i[t]=r}),r.forEach(t=>{let r=p.storage[t].get();if(!r)throw Error(`[PhantomRedirect] ${e} called, but required input '${t}' not found in local storage`);i[t]=r}),i}}e.s(["PhantomRedirect",0,y])},402671,e=>{"use strict";var t=e.i(115349);e.i(484200);var r=e.i(510137);e.i(973402);var i=e.i(55130),s=e.i(550028),n=e.i(177658);class o extends r.SolanaWalletConnector{constructor(){super(...arguments),this.name="Phantom",this.overrideKey="phantom"}connect(){return(0,t.__awaiter)(this,void 0,void 0,function*(){yield this.getMobileOrInstalledWallet().connect()})}getSigner(){return(0,t.__awaiter)(this,void 0,void 0,function*(){return this.getMobileOrInstalledWallet().getSigner()})}getMobileOrInstalledWallet(){let e=new s.PhantomInjected(this.constructorProps);return(0,i.isMobile)()&&!e.isInstalledOnBrowser()&&"redirect"===this.mobileExperience?new n.PhantomRedirect(this.constructorProps):e}}Object.defineProperty(o,"key",{value:"phantom",writable:!1}),e.s(["Phantom",0,o])},3374,e=>{"use strict";e.s(["findWalletBookWalletByNameAndChain",0,(e,t,r)=>{var i;return Object.values(null!=(i=null==e?void 0:e.wallets)?i:{}).find(e=>{var i,s;return e.name===t&&(null==(s=null==(i=e.injectedConfig)?void 0:i[0])?void 0:s.chain)===r})}])},637746,e=>{"use strict";var t=e.i(115349);e.i(973402);var r=e.i(123785),i=e.i(581825),s=e.i(515730);class n extends i.InjectedWalletBase{constructor(){super(...arguments),this.name="Coinbase",this.overrideKey="coinbasesolana"}getSigner(){let e=Object.create(null,{getSigner:{get:()=>super.getSigner}});return(0,t.__awaiter)(this,void 0,void 0,function*(){return e.getSigner.call(this)})}signMessage(e){return(0,t.__awaiter)(this,void 0,void 0,function*(){let t=yield this.getAddress();if(!t)return;let i=yield this.getSigner();if(!i)return;let n=new TextEncoder().encode(e),o=yield i.signMessage(n,t);if(o)return(0,r.bufferToBase64)((0,s.isSignedMessage)(o)?o.signature:o)})}}Object.defineProperty(n,"key",{value:"coinbasesolana",writable:!1}),e.s(["CoinbaseSolana",0,n])},645394,e=>{"use strict";var t=e.i(115349);e.i(973402);var r=e.i(55130),i=e.i(507301),s=e.i(123785);e.i(900373);var n=e.i(103388),o=e.i(581825);class a extends o.InjectedWalletBase{constructor(e){super(e),this.name="Solflare",this.overrideKey="solflare",this.walletConnectWalletBookEntry=(0,n.findWalletBookWallet)(e.walletBook,this.key)}getMobileOrInstalledWallet(){return this}openInAppBrowserIfRequired(){var e;if((0,r.isMobile)()&&!this.isInstalledOnBrowser()){let t=null==(e=this.metadata.deepLinks)?void 0:e.mobile;return(0,i.handleMobileWalletRedirect)({nativeLink:(null==t?void 0:t.native)||"solflare://ul/v1/browse",universalLink:(null==t?void 0:t.universal)||"https://solflare.com/ul/v1/browse"}),!0}return!1}signMessage(e){return(0,t.__awaiter)(this,void 0,void 0,function*(){if(!(yield this.getAddress()))return;let t=yield this.getSigner();if(!t)return;let r=new TextEncoder().encode(e);yield t.connect(),yield new Promise(e=>{setTimeout(e,100)});let i=yield t.signMessage(r,"utf8");return void 0!==i.signature?(0,s.bufferToBase64)(i.signature):void 0})}}
22Object.defineProperty(a,"key",{value:"solflare",writable:!1}),e.s(["Solflare",0,a])},924688,e=>{"use strict";var t=e.i(581825);e.s(["getConnectorConstructorInjectedWallet",0,({key:e,wallet:r,walletBook:i})=>{let s,{shortName:n}=r,o=n||r.name;r.group&&(s=Object.values(i.wallets).find(e=>{var t;return e.walletConnect&&e.group===r.group&&(null==(t=e.chains)?void 0:t.some(e=>e.includes("solana:")))}));let a=class extends t.InjectedWalletBase{constructor(){super(...arguments),this.walletName=o,this.name=o,this.walletConnectWalletBookEntry=s,this.overrideKey=e}};return Object.defineProperty(a,"key",{value:e,writable:!1}),a}])},206546,e=>{"use strict";var t=e.i(115349),r=e.i(127261),i=e.i(654611),s=e.i(779772);e.s(["createSolanaSignerFromWalletStandard",0,({wallet:e,walletConnector:n})=>{let o=e.features,a=()=>{var t,r,i;return!!((null==(t=e.accounts)?void 0:t.length)>0&&(null==(r=e.accounts[0])?void 0:r.publicKey)&&(null==(i=e.accounts[0])?void 0:i.address))},l=()=>(0,t.__awaiter)(void 0,void 0,void 0,function*(){let t=yield n.getAddress(),r=e.accounts.find(e=>e.address===t);if(!r)throw Error("Account not found");return r}),c=()=>{var e;let t=n.getSelectedNetwork();if(!t)throw Error("Network not found");let r=null!=(e=t.cluster)?e:"mainnet";return`solana:${r}`},u=e=>(0,t.__awaiter)(void 0,void 0,void 0,function*(){let t=o["solana:signTransaction"].signTransaction,i=yield l(),s=c(),n=e.map(e=>({account:i,chain:s,transaction:e.serialize({requireAllSignatures:!1})}));return(yield t(...n)).map(({signedTransaction:t},i)=>"instructions"in e[i]?r.Transaction.from(t):r.VersionedTransaction.deserialize(t))});return{addListener:()=>{throw Error("addListener - Not implemented")},connect:r=>(0,t.__awaiter)(void 0,void 0,void 0,function*(){var t;let r=e.accounts;if(s.logger.logVerboseTroubleshootingMessage("[SolanaWalletStandardConnector] - connect",{autoConnectedAccounts:r}),a())return{address:r[0].address,publicKey:r[0].publicKey};let i=null==(t=o["standard:connect"])?void 0:t.connect;if(!i)return void s.logger.error("connect - Not implemented");let n=yield i({silent:!1});if(n.accounts[0])return{address:n.accounts[0].address,publicKey:n.accounts[0].publicKey}}),disconnect:()=>(0,t.__awaiter)(void 0,void 0,void 0,function*(){var e;let t=null==(e=o["standard:disconnect"])?void 0:e.disconnect;t?yield t():s.logger.debug("disconnect - Not implemented")}),emit:()=>{throw Error("emit - Not implemented")},eventNames:()=>(s.logger.error("eventNames - Not implemented"),[]),isBackpack:!1,isBraveWallet:!1,isConnected:a(),isExodus:!1,isGlow:!1,isMagicEden:!1,isPhantom:!1,isSolflare:!1,listenerCount:()=>(s.logger.error("listenerCount - Not implemented"),0),listeners:()=>(s.logger.error("listeners - Not implemented"),[]),off:()=>{throw Error("off - Not implemented")},on:(e,t)=>{var r;let i=null==(r=o["standard:events"])?void 0:r.on;return i?(s.logger.debug(`[SolanaWalletStandardConnector] - on: ${e}`),"accountChanged"!==e)?void s.logger.debug(`on - Not implemented for event: ${e}`):i("change",e=>{var r,i;let s=null==(i=null==(r=e.accounts)?void 0:r[0])?void 0:i.publicKey;s&&t(new TextDecoder().decode(s))}):void s.logger.error("on - Not implemented")},once:()=>{throw Error("once - Not implemented")},providers:[],get publicKey(){var d,h;if(!(null==(h=null==(d=e.accounts)?void 0:d[0])?void 0:h.publicKey))return;return new r.PublicKey(e.accounts[0].publicKey)},removeAllListeners:()=>{throw Error("removeAllListeners - Not implemented")},removeListener:()=>{throw Error("removeListener - Not implemented")},send:()=>{throw Error("send - Not implemented")},signAllTransactions:u,signAndSendTransaction:e=>(0,t.__awaiter)(void 0,void 0,void 0,function*(){var t;let r=null==(t=o["solana:signAndSendTransaction"])?void 0:t.signAndSendTransaction;if(!r)throw s.logger.error("signAndSendTransaction - Not implemented"),Error("signAndSendTransaction - Not implemented by wallet");let n=yield l(),[{signature:a}]=yield r({account:n,chain:c(),transaction:e.serialize({requireAllSignatures:!1})});return{signature:i.default.encode(a)}}),signMessage:e=>(0,t.__awaiter)(void 0,void 0,void 0,function*(){var t;let r=null==(t=o["solana:signMessage"])?void 0:t.signMessage;if(!r)throw s.logger.error("signMessage - Not implemented"),Error("signMessage - Not implemented by wallet");let i=yield l();return{signature:(yield r({account:i,message:e}))[0].signature}}),signTransaction:e=>(0,t.__awaiter)(void 0,void 0,void 0,function*(){return(yield u([e]))[0]})}}])},83526,e=>{"use strict";e.i(973402);var t=e.i(643398),r=e.i(581825),i=e.i(206546);e.s(["getConnectorConstructorForWalletStandardWallet",0,(e,s={},n)=>{let o=(0,t.sanitizeName)(e.name),a=class extends r.InjectedWalletBase{constructor(t){super(Object.assign(Object.assign({},t),{metadata:Object.assign(Object.assign({},s),{groupKey:o,icon:e.icon,id:o,name:e.name})})),this.name=e.name,this.overrideKey=`${o}sol`,this._provider=(0,i.createSolanaSignerFromWalletStandard)({wallet:e,walletConnector:this})}findProvider(){return this._provider}};
22return Object.defineProperty(a,"key",{value:null!=n?n:o,writable:!1}),a}])},992399,e=>{"use strict";var t=e.i(565696);e.s(["getWalletStandardWallets",0,()=>{let{get:e,on:r}=(0,t.getWallets)();return{on:r,wallets:e()}}])},445128,e=>{"use strict";e.s(["hasAllWalletStandardRequiredFeatures",0,(e,t="connect-and-sign")=>{var r,i,s,n;let o=!!((null==(r=e.features)?void 0:r["standard:events"])&&(null==(i=e.features)?void 0:i["standard:connect"])&&(null==(s=e.features)?void 0:s["solana:signTransaction"])),a="connect-and-sign"!==t||!!(null==(n=e.features)?void 0:n["solana:signMessage"]);return o&&a}])},769691,e=>{"use strict";e.i(900373);var t=e.i(3374);e.i(303778);var r=e.i(114800),i=e.i(201565);e.i(973402);var s=e.i(643398),n=e.i(637746),o=e.i(402671),a=e.i(645394),l=e.i(779772),c=e.i(924688),u=e.i(883170),d=e.i(83526),h=e.i(992399),f=e.i(445128);let p=null,g=[n.CoinbaseSolana,u.BackpackSol,a.Solflare],y=["coinbasesolana","phantom","phantomledger","backpacksol","solflare","metamasksol"],m={Backpack:u.BackpackSol,"Coinbase Wallet":n.CoinbaseSolana,Phantom:o.Phantom,Solflare:a.Solflare},b=(e,t,r)=>{var i;let{name:n}=e,o=`${(0,s.sanitizeName)(n)}sol`;l.logger.logVerboseTroubleshootingMessage("[SOL shouldAddWalletStandardConnector]",n,"sol",o,e.features);let a=Object.entries(null!=(i=null==t?void 0:t.wallets)?i:{}).find(([e,t])=>{var r,i,s,a,l,c;let u=e===o,d=y.includes(o),h=t.name===n&&(null==(i=null==(r=t.injectedConfig)?void 0:r[0])?void 0:i.chain)==="sol",f=!(null==(c=null==(l=null==(a=null==(s=t.injectedConfig)?void 0:s[0])?void 0:a.walletStandard)?void 0:l.features)?void 0:c.length);return(u||d||h)&&f}),c=(0,f.hasAllWalletStandardRequiredFeatures)(e,r);return l.logger.logVerboseTroubleshootingMessage("[SOL shouldAddWalletStandardConnector]",{hasAllFeatures:c,shouldAdd:!a&&c,shouldHandleFromWalletBook:a}),!a&&c};e.s(["fetchInjectedWalletConnectors",0,({walletBook:e,authMode:n})=>{var o;((e,n)=>{if("u"<typeof window)return;null==p||p();let o=new Set,a=a=>{if(o.has(a.name))return;let c=m[a.name];if(c){o.add(a.name),l.logger.logVerboseTroubleshootingMessage("[SOL fetchInjectedWalletConnectors] Emitting providerInjected for late-registered custom connector wallet",a.name),i.walletConnectorEvents.emit("providerInjected",{injectedConnectorConstructor:c});return}if(b(a,e,n)){var u,h;let n,c,f,p;o.add(a.name),l.logger.logVerboseTroubleshootingMessage("[SOL fetchInjectedWalletConnectors] Emitting providerInjected for wallet-standard wallet",a.name),c=(n=(0,t.findWalletBookWalletByNameAndChain)(e,a.name,"sol"))?null==(h=Object.entries(null!=(u=null==e?void 0:e.wallets)?u:{}).find(([,e])=>e===n))?void 0:h[0]:void 0,f=n&&(0,r.getWalletMetadataFromWalletBook)({walletBook:e,walletBookWallet:n,walletKey:null!=c?c:`${(0,s.sanitizeName)(a.name)}sol`}),p=(0,d.getConnectorConstructorForWalletStandardWallet)(a,f,c),i.walletConnectorEvents.emit("providerInjected",{injectedConnectorConstructor:p})}},{on:c,wallets:u}=(0,h.getWalletStandardWallets)();u.forEach(t=>{(m[t.name]||b(t,e,n))&&o.add(t.name)});let f=c("register",a),g=setInterval(()=>{(0,h.getWalletStandardWallets)().wallets.forEach(a)},300),y=setTimeout(()=>{clearInterval(g)},5e3);p=()=>{null==f||f(),clearInterval(g),clearTimeout(y)}})(e,n);let a=Object.entries(null!=(o=null==e?void 0:e.wallets)?o:{}).filter(([e,t])=>{var r,i,s;let n=null==(r=t.injectedConfig)?void 0:r.find(e=>"sol"===e.chain),o=!!n,a=y.includes(e)||(null==(s=null==(i=null==n?void 0:n.walletStandard)?void 0:i.features)?void 0:s.length);return o&&!a}).map(([t,r])=>(0,c.getConnectorConstructorInjectedWallet)({key:t,wallet:r,walletBook:e})),{wallets:u}=(0,h.getWalletStandardWallets)(),f=u.filter(t=>b(t,e,n)).map(t=>{var i,n;let[o,a]=null!=(n=Object.entries(null!=(i=null==e?void 0:e.wallets)?i:{}).find(([,e])=>{var r,i;return e.name===t.name&&(null==(i=null==(r=e.injectedConfig)?void 0:r[0])?void 0:i.chain)==="sol"}))?n:[],l=a&&(0,r.getWalletMetadataFromWalletBook)({walletBook:e,walletBookWallet:a,walletKey:null!=o?o:`${(0,s.sanitizeName)(t.name)}sol`});return(0,d.getConnectorConstructorForWalletStandardWallet)(t,l,o)});return l.logger.logVerboseTroubleshootingMessage("[SOL fetchInjectedWalletConnectors] walletStandardConnectors",f.map(e=>e.name)),[...a,...f]},"injectedWalletOverrides",0,g])},853479,e=>{"use strict";var t=e.i(581825);class r extends t.InjectedWalletBase{constructor(){super(...arguments),this.name="Fallback Connector",this.overrideKey="fallbackconnector",this.isAvailable=!1}isInstalledOnBrowser(){return!1}}Object.defineProperty(r,"key",{value:"fallbackconnector",writable:!1}),e.s(["FallbackSolanaConnector",0,r])},529896,e=>{"use strict";var t=e.i(926497);e.s(["getSolanaWalletConnectConnector",0,()=>{let e=class extends t.SolanaWalletConnectConnector{constructor(e){super(Object.assign(Object.assign({},e),{metadata:{groupKey:"walletconnect",name:"WalletConnect"},walletName:"WalletConnect Sol"}))}};return Object.defineProperty(e,"key",{value:"walletconnectsol",writable:!1}),e}])},837064,e=>{"use strict";e.i(303778);var t=e.i(114800),r=e.i(926497);e.s(["addSolanaWalletConnectConnectors",0,({walletBook:e,connectors:i})=>{var s;let n=Object.entries(null!=(s=null==e?void 0:e.wallets)?s:{}),o=n.filter(([,e])=>{var t;return e.walletConnect&&(null==(t=e.chains)?void 0:t.some(e=>e.includes("solana:")))}).map(([i,s])=>{let{shortName:o}=s,a=o||s.name,l=class extends r.SolanaWalletConnectConnector{constructor(r){super(Object.assign(Object.assign({},r),{metadata:(0,t.getWalletMetadataFromWalletBook)({walletBook:e,walletBookWallet:s,walletKey:i}),overrideKey:i,walletName:a})),this.overrideKey=i}},c=n.filter(([,{group:e}])=>e&&e===s.group).map(([e])=>e);return Object.defineProperty(l,"key",{value:i,writable:!1}),Object.defineProperty(l,"groupedKeys",{value:c,writable:!1}),l}),a=o;return i.length>0&&(a=o.filter(e=>i.every(t=>
22t.key!==e.key&&!e.groupedKeys.includes(t.key)))),[...i,...a]}])},632680,e=>{"use strict";var t=e.i(535315);e.i(214260);var r=e.i(490713);e.i(326132);var i=e.i(690822),s=e.i(402671),n=e.i(769691),o=e.i(853479);e.i(127261),e.i(654611),e.i(779772);var a=e.i(529896),l=e.i(837064);e.s(["SolanaWalletConnectors",0,e=>{let c=(e.solNetworks||[]).length>0,u=[...n.injectedWalletOverrides,...(0,n.fetchInjectedWalletConnectors)(e),...(0,r.TurnkeySolanaWalletConnectors)(e),...(0,i.DynamicWaasSVMConnectors)(),...(0,t.MetaMaskSolanaWalletConnectors)(e),s.Phantom,o.FallbackSolanaConnector,...c?[(0,a.getSolanaWalletConnectConnector)()]:[]];return c?(0,l.addSolanaWalletConnectConnectors)({connectors:u,walletBook:e.walletBook}):u}])},53177,e=>{"use strict";e.i(837064),e.s([])},274072,e=>{"use strict";e.i(632680),e.s([])},397231,e=>{"use strict";e.i(957121);var t=e.i(303690),r=e.i(751694);e.i(484200),e.i(883170),e.i(581825),e.i(632680),e.i(53177),e.i(274072),e.i(900373),e.i(303778),e.i(973402),e.i(637746),e.i(402671),e.i(645394),e.i(779772),e.i(206546),e.i(853479),e.i(177658),(0,t.assertPackageVersion)("@dynamic-labs/solana",r.version),e.s([])},143653,e=>{"use strict";var t=e.i(849266);e.s(["useUserWallets",()=>t.useUserWalletsExternal])}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.