@clerk/clerk-js
Version:
Clerk JS library
1 lines • 105 kB
JavaScript
(globalThis.rspackChunk_clerk_clerk_js=globalThis.rspackChunk_clerk_clerk_js||[]).push([[929],{3009(e,t){"use strict";t.rotlSL=t.rotlSH=t.rotlBL=t.rotlBH=void 0,t.split=function(e,t=!1){let n=e.length,r=new Uint32Array(n),a=new Uint32Array(n);for(let o=0;o<n;o++){let{h:n,l:c}=function(e,t=!1){return t?{h:Number(e&s),l:Number(e>>i&s)}:{h:0|Number(e>>i&s),l:0|Number(e&s)}}(e[o],t);[r[o],a[o]]=[n,c]}return[r,a]};let s=BigInt(0x100000000-1),i=BigInt(32);t.rotlSH=(e,t,s)=>e<<s|t>>>32-s;t.rotlSL=(e,t,s)=>t<<s|e>>>32-s;t.rotlBH=(e,t,s)=>t<<s-32|e>>>64-s;t.rotlBL=(e,t,s)=>e<<s-32|t>>>64-s},8510(e,t){"use strict";t.crypto=void 0,t.crypto="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0},5376(e,t,s){"use strict";t.keccak_256=void 0;let i=s(3009),n=s(6770),r=BigInt(0),a=BigInt(1),o=BigInt(2),c=BigInt(7),l=BigInt(256),h=BigInt(113),d=[],u=[],f=[];for(let e=0,t=a,s=1,i=0;e<24;e++){[s,i]=[i,(2*s+3*i)%5],d.push(2*(5*i+s)),u.push((e+1)*(e+2)/2%64);let n=r;for(let e=0;e<7;e++)(t=(t<<a^(t>>c)*h)%l)&o&&(n^=a<<(a<<BigInt(e))-a);f.push(n)}let p=(0,i.split)(f,!0),g=p[0],b=p[1],m=(e,t,s)=>s>32?(0,i.rotlBH)(e,t,s):(0,i.rotlSH)(e,t,s),y=(e,t,s)=>s>32?(0,i.rotlBL)(e,t,s):(0,i.rotlSL)(e,t,s);class w extends n.Hash{constructor(e,t,s,i=!1,r=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=s,this.enableXOF=i,this.rounds=r,(0,n.anumber)(s),!(0<e&&e<200))throw Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=(0,n.u32)(this.state)}clone(){return this._cloneInto()}keccak(){(0,n.swap32IfBE)(this.state32),function(e,t=24){let s=new Uint32Array(10);for(let i=24-t;i<24;i++){for(let t=0;t<10;t++)s[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,n=(t+2)%10,r=s[n],a=s[n+1],o=m(r,a,1)^s[i],c=y(r,a,1)^s[i+1];for(let s=0;s<50;s+=10)e[t+s]^=o,e[t+s+1]^=c}let t=e[2],n=e[3];for(let s=0;s<24;s++){let i=u[s],r=m(t,n,i),a=y(t,n,i),o=d[s];t=e[o],n=e[o+1],e[o]=r,e[o+1]=a}for(let t=0;t<50;t+=10){for(let i=0;i<10;i++)s[i]=e[t+i];for(let i=0;i<10;i++)e[t+i]^=~s[(i+2)%10]&s[(i+4)%10]}e[0]^=g[i],e[1]^=b[i]}(0,n.clean)(s)}(this.state32,this.rounds),(0,n.swap32IfBE)(this.state32),this.posOut=0,this.pos=0}update(e){(0,n.aexists)(this),e=(0,n.toBytes)(e),(0,n.abytes)(e);let{blockLen:t,state:s}=this,i=e.length;for(let n=0;n<i;){let r=Math.min(t-this.pos,i-n);for(let t=0;t<r;t++)s[this.pos++]^=e[n++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:t,pos:s,blockLen:i}=this;e[s]^=t,(128&t)!=0&&s===i-1&&this.keccak(),e[i-1]^=128,this.keccak()}writeInto(e){(0,n.aexists)(this,!1),(0,n.abytes)(e),this.finish();let t=this.state,{blockLen:s}=this;for(let i=0,n=e.length;i<n;){this.posOut>=s&&this.keccak();let r=Math.min(s-this.posOut,n-i);e.set(t.subarray(this.posOut,this.posOut+r),i),this.posOut+=r,i+=r}return e}xofInto(e){if(!this.enableXOF)throw Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return(0,n.anumber)(e),this.xofInto(new Uint8Array(e))}digestInto(e){if((0,n.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,n.clean)(this.state)}_cloneInto(e){let{blockLen:t,suffix:s,outputLen:i,rounds:n,enableXOF:r}=this;return e||(e=new w(t,s,i,r,n)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=n,e.suffix=s,e.outputLen=i,e.enableXOF=r,e.destroyed=this.destroyed,e}}let x=(e,t,s)=>(0,n.createHasher)(()=>new w(t,e,s));x(6,144,28),x(6,136,32),x(6,104,48),x(6,72,64),x(1,144,28),t.keccak_256=x(1,136,32),x(1,104,48),x(1,72,64);let k=(e,t,s)=>(0,n.createXOFer)((i={})=>new w(t,e,void 0===i.dkLen?s:i.dkLen,!0));k(31,168,16),k(31,136,32)},6770(e,t,s){"use strict";t.Hash=t.dY=t.swap32IfBE=t.Y1=t.qv=void 0,t.anumber=function(e){if(!Number.isSafeInteger(e)||e<0)throw Error("positive integer expected, got "+e)},t.abytes=i,t.aexists=function(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")},t.aoutput=function(e,t){i(e);let s=t.outputLen;if(e.length<s)throw Error("digestInto() expects output buffer of length at least "+s)},t.u32=function(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))},t.clean=function(...e){for(let t=0;t<e.length;t++)e[t].fill(0)},t.toBytes=r,t.createHasher=function(e){let t=t=>e().update(r(t)).digest(),s=e();return t.outputLen=s.outputLen,t.blockLen=s.blockLen,t.create=()=>e(),t},t.createXOFer=function(e){let t=(t,s)=>e(s).update(r(t)).digest(),s=e({});return t.outputLen=s.outputLen,t.blockLen=s.blockLen,t.create=t=>e(t),t},s(8510);function i(e,...t){var s;if(!((s=e)instanceof Uint8Array||ArrayBuffer.isView(s)&&"Uint8Array"===s.constructor.name))throw Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw Error("Uint8Array expected of length "+t+", got length="+e.length)}function n(e){return e<<24&0xff000000|e<<8&0xff0000|e>>>8&65280|e>>>24&255}t.qv=68===new Uint8Array(new Uint32Array([0x11223344]).buffer)[0],t.Y1=t.qv?e=>e:e=>n(e),t.Y1,t.swap32IfBE=t.qv?e=>e:function(e){for(let t=0;t<e.length;t++)e[t]=n(e[t]);return e},"function"==typeof Uint8Array.from([]).toHex&&Uint8Array.fromHex,(e,t)=>t.toString(16).padStart(2,"0");function r(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}(e)),i(e),e}t.dY=async()=>{};t.Hash=class{}},990(e,t,s){let i=s(768);function n(e){if(e.startsWith("int["))return"int256"+e.slice(3);if("int"===e)return"int256";if(e.startsWith("uint["))return"uint256"+e.slice(4);if("uint"===e)return"uint256";if(e.startsWith("fixed["))return"fixed128x128"+e.slice(5);else if("fixed"===e)return"fixed128x128";else if(e.startsWith("ufixed["))return"ufixed128x128"+e.slice(6);else if("ufixed"===e)return"ufixed128x128";return e}function r(e){return Number.parseInt(/^\D+(\d+)$/.exec(e)[1],10)}function a(e){var t=/^\D+(\d+)x(\d+)$/.exec(e);return[Number.parseInt(t[1],10),Number.parseInt(t[2],10)]}function o(e){var t=e.match(/(.*)\[(.*?)\]$/);return t?""===t[2]?"dynamic":Number.parseInt(t[2],10):null}function c(e){var t=typeof e;if("string"===t||"number"===t)return BigInt(e);if("bigint"===t)return e;throw Error("Argument is not a number")}function l(e,t){if("address"===e)return l("uint160",c(t));if("bool"===e)return l("uint8",+!!t);if("string"===e)return l("bytes",new Buffer(t,"utf8"));if((u=e).lastIndexOf("]")===u.length-1){if(void 0===t.length)throw Error("Not an array?");if("dynamic"!==(s=o(e))&&0!==s&&t.length>s)throw Error("Elements exceed array size: "+s);for(d in h=[],e=e.slice(0,e.lastIndexOf("[")),"string"==typeof t&&(t=JSON.parse(t)),t)h.push(l(e,t[d]));if("dynamic"===s){var s,n,h,d,u,f=l("uint256",t.length);h.unshift(f)}return Buffer.concat(h)}else if("bytes"===e)return t=new Buffer(t),h=Buffer.concat([l("uint256",t.length),t]),t.length%32!=0&&(h=Buffer.concat([h,i.zeros(32-t.length%32)])),h;else if(e.startsWith("bytes")){if((s=r(e))<1||s>32)throw Error("Invalid bytes<N> width: "+s);return i.setLengthRight(t,32)}else if(e.startsWith("uint")){if((s=r(e))%8||s<8||s>256)throw Error("Invalid uint<N> width: "+s);n=c(t);let a=i.bitLengthFromBigInt(n);if(a>s)throw Error("Supplied uint exceeds width: "+s+" vs "+a);if(n<0)throw Error("Supplied uint is negative");return i.bufferBEFromBigInt(n,32)}else if(e.startsWith("int")){if((s=r(e))%8||s<8||s>256)throw Error("Invalid int<N> width: "+s);n=c(t);let a=i.bitLengthFromBigInt(n);if(a>s)throw Error("Supplied int exceeds width: "+s+" vs "+a);let o=i.twosFromBigInt(n,256);return i.bufferBEFromBigInt(o,32)}else if(e.startsWith("ufixed")){if(s=a(e),(n=c(t))<0)throw Error("Supplied ufixed is negative");return l("uint256",n*BigInt(2)**BigInt(s[1]))}else if(e.startsWith("fixed"))return s=a(e),l("int256",c(t)*BigInt(2)**BigInt(s[1]));throw Error("Unsupported or invalid type: "+e)}function h(e,t){if(e.length!==t.length)throw Error("Number of types are not matching the values");for(var s,a,o=[],l=0;l<e.length;l++){var h=n(e[l]),d=t[l];if("bytes"===h)o.push(d);else if("string"===h)o.push(new Buffer(d,"utf8"));else if("bool"===h)o.push(new Buffer(d?"01":"00","hex"));else if("address"===h)o.push(i.setLength(d,20));else if(h.startsWith("bytes")){if((s=r(h))<1||s>32)throw Error("Invalid bytes<N> width: "+s);o.push(i.setLengthRight(d,s))}else if(h.startsWith("uint")){if((s=r(h))%8||s<8||s>256)throw Error("Invalid uint<N> width: "+s);a=c(d);let e=i.bitLengthFromBigInt(a);if(e>s)throw Error("Supplied uint exceeds width: "+s+" vs "+e);o.push(i.bufferBEFromBigInt(a,s/8))}else if(h.startsWith("int")){if((s=r(h))%8||s<8||s>256)throw Error("Invalid int<N> width: "+s);a=c(d);let e=i.bitLengthFromBigInt(a);if(e>s)throw Error("Supplied int exceeds width: "+s+" vs "+e);let t=i.twosFromBigInt(a,s);o.push(i.bufferBEFromBigInt(t,s/8))}else throw Error("Unsupported or invalid type: "+h)}return Buffer.concat(o)}e.exports={rawEncode:function(e,t){var s=[],i=[],r=32*e.length;for(var a in e){var c=n(e[a]),h=l(c,t[a]);"string"===c||"bytes"===c||"dynamic"===o(c)?(s.push(l("uint256",r)),i.push(h),r+=h.length):s.push(h)}return Buffer.concat(s.concat(i))},solidityPack:h,soliditySHA3:function(e,t){return i.keccak(h(e,t))}}},5912(e,t,s){let i=s(768),n=s(990),r={type:"object",properties:{types:{type:"object",additionalProperties:{type:"array",items:{type:"object",properties:{name:{type:"string"},type:{type:"string"}},required:["name","type"]}}},primaryType:{type:"string"},domain:{type:"object"},message:{type:"object"}},required:["types","primaryType","domain","message"]},a={encodeData(e,t,s,r=!0){let a=["bytes32"],o=[this.hashType(e,s)];if(r){let c=(e,t,a)=>{if(void 0!==s[t])return["bytes32",null==a?"0x0000000000000000000000000000000000000000000000000000000000000000":i.keccak(this.encodeData(t,a,s,r))];if(void 0===a)throw Error(`missing value for field ${e} of type ${t}`);if("bytes"===t)return["bytes32",i.keccak(a)];if("string"===t)return"string"==typeof a&&(a=Buffer.from(a,"utf8")),["bytes32",i.keccak(a)];if(t.lastIndexOf("]")===t.length-1){let s=t.slice(0,t.lastIndexOf("[")),r=a.map(t=>c(e,s,t));return["bytes32",i.keccak(n.rawEncode(r.map(([e])=>e),r.map(([,e])=>e)))]}return[t,a]};for(let i of s[e]){let[e,s]=c(i.name,i.type,t[i.name]);a.push(e),o.push(s)}}else for(let n of s[e]){let e=t[n.name];if(void 0!==e)if("bytes"===n.type)a.push("bytes32"),e=i.keccak(e),o.push(e);else if("string"===n.type)a.push("bytes32"),"string"==typeof e&&(e=Buffer.from(e,"utf8")),e=i.keccak(e),o.push(e);else if(void 0!==s[n.type])a.push("bytes32"),e=i.keccak(this.encodeData(n.type,e,s,r)),o.push(e);else if(n.type.lastIndexOf("]")===n.type.length-1)throw Error("Arrays currently unimplemented in encodeData");else a.push(n.type),o.push(e)}return n.rawEncode(a,o)},encodeType(e,t){let s="",i=this.findTypeDependencies(e,t).filter(t=>t!==e);for(let n of i=[e].concat(i.sort())){if(!t[n])throw Error("No type definition specified: "+n);s+=n+"("+t[n].map(({name:e,type:t})=>t+" "+e).join(",")+")"}return s},findTypeDependencies(e,t,s=[]){if(e=e.match(/^\w*/)[0],s.includes(e)||void 0===t[e])return s;for(let i of(s.push(e),t[e]))for(let e of this.findTypeDependencies(i.type,t,s))s.includes(e)||s.push(e);return s},hashStruct(e,t,s,n=!0){return i.keccak(this.encodeData(e,t,s,n))},hashType(e,t){return i.keccak(this.encodeType(e,t))},sanitizeData(e){let t={};for(let s in r.properties)e[s]&&(t[s]=e[s]);return t.types&&(t.types=Object.assign({EIP712Domain:[]},t.types)),t},hash(e,t=!0){let s=this.sanitizeData(e),n=[Buffer.from("1901","hex")];return n.push(this.hashStruct("EIP712Domain",s.domain,s.types,t)),"EIP712Domain"!==s.primaryType&&n.push(this.hashStruct(s.primaryType,s.message,s.types,t)),i.keccak(Buffer.concat(n))}};e.exports={TYPED_MESSAGE_SCHEMA:r,TypedDataUtils:a,hashForSignTypedDataLegacy:function(e){return function(e){let t=Error("Expect argument to be non-empty array");if("object"!=typeof e||!e.length)throw t;let s=e.map(function(e){return"bytes"===e.type?i.toBuffer(e.value):e.value}),r=e.map(function(e){return e.type}),a=e.map(function(e){if(!e.name)throw t;return e.type+" "+e.name});return n.soliditySHA3(["bytes32","bytes32"],[n.soliditySHA3(Array(e.length).fill("string"),a),n.soliditySHA3(r,s)])}(e.data)},hashForSignTypedData_v3:function(e){return a.hash(e.data,!1)},hashForSignTypedData_v4:function(e){return a.hash(e.data)}}},768(e,t,s){let{keccak_256:i}=s(5376);function n(e){return Buffer.allocUnsafe(e).fill(0)}function r(e,t){let s=e.toString(16);s.length%2!=0&&(s="0"+s);let i=s.match(/.{1,2}/g).map(e=>parseInt(e,16));for(;i.length<t;)i.unshift(0);return Buffer.from(i)}function a(e,t,s){let i=n(t);return(e=o(e),s)?e.length<t?(e.copy(i),i):e.slice(0,t):e.length<t?(e.copy(i,t-e.length),i):e.slice(-t)}function o(e){if(!Buffer.isBuffer(e))if(Array.isArray(e))e=Buffer.from(e);else if("string"==typeof e){var t;e=c(e)?Buffer.from((t=l(e)).length%2?"0"+t:t,"hex"):Buffer.from(e)}else if("number"==typeof e)e=intToBuffer(e);else if(null==e)e=Buffer.allocUnsafe(0);else if("bigint"==typeof e)e=r(e);else if(e.toArray)e=Buffer.from(e.toArray());else throw Error("invalid type");return e}function c(e){return"string"==typeof e&&e.match(/^0x[0-9A-Fa-f]*$/)}function l(e){return"string"==typeof e&&e.startsWith("0x")?e.slice(2):e}e.exports={zeros:n,setLength:a,setLengthRight:function(e,t){return a(e,t,!0)},isHexString:c,stripHexPrefix:l,toBuffer:o,bufferToHex:function(e){return"0x"+(e=o(e)).toString("hex")},keccak:function(e,t){if(e=o(e),t||(t=256),256!==t)throw Error("unsupported");return Buffer.from(i(new Uint8Array(e)))},bitLengthFromBigInt:function(e){return e.toString(2).length},bufferBEFromBigInt:r,twosFromBigInt:function(e,t){return(e<0n?(~e&(1n<<BigInt(t))-1n)+1n:e)&(1n<<BigInt(t))-1n}}},2172(e,t,s){"use strict";let i;s.r(t),s.d(t,{CoinbaseWalletSDK:()=>ti,createCoinbaseWalletSDK:()=>tr,default:()=>ta});var n,r,a=s(5544),o=s(5074);class c{constructor(e,t){this.scope=e,this.module=t}storeObject(e,t){this.setItem(e,JSON.stringify(t))}loadObject(e){let t=this.getItem(e);return t?JSON.parse(t):void 0}setItem(e,t){localStorage.setItem(this.scopedKey(e),t)}getItem(e){return localStorage.getItem(this.scopedKey(e))}removeItem(e){localStorage.removeItem(this.scopedKey(e))}clear(){let e=this.scopedKey(""),t=[];for(let s=0;s<localStorage.length;s++){let i=localStorage.key(s);"string"==typeof i&&i.startsWith(e)&&t.push(i)}t.forEach(e=>localStorage.removeItem(e))}scopedKey(e){return`-${this.scope}${this.module?`:${this.module}`:""}:${e}`}static clearAll(){new c("CBWSDK").clear(),new c("walletlink").clear()}}let l=-32602,h=-32603,d=4001,u=4100,f=4200,p=4900,g={"-32700":{standard:"JSON RPC 2.0",message:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."},"-32600":{standard:"JSON RPC 2.0",message:"The JSON sent is not a valid Request object."},"-32601":{standard:"JSON RPC 2.0",message:"The method does not exist / is not available."},"-32602":{standard:"JSON RPC 2.0",message:"Invalid method parameter(s)."},"-32603":{standard:"JSON RPC 2.0",message:"Internal JSON-RPC error."},"-32000":{standard:"EIP-1474",message:"Invalid input."},"-32001":{standard:"EIP-1474",message:"Resource not found."},"-32002":{standard:"EIP-1474",message:"Resource unavailable."},"-32003":{standard:"EIP-1474",message:"Transaction rejected."},"-32004":{standard:"EIP-1474",message:"Method not supported."},"-32005":{standard:"EIP-1474",message:"Request limit exceeded."},4001:{standard:"EIP-1193",message:"User rejected the request."},4100:{standard:"EIP-1193",message:"The requested account and/or method has not been authorized by the user."},4200:{standard:"EIP-1193",message:"The requested method is not supported by this Ethereum provider."},4900:{standard:"EIP-1193",message:"The provider is disconnected from all chains."},4901:{standard:"EIP-1193",message:"The provider is disconnected from the specified chain."},4902:{standard:"EIP-3085",message:"Unrecognized chain ID."}},b="Unspecified error message.";function m(e,t=b){if(e&&Number.isInteger(e)){var s;let t=e.toString();if(w(g,t))return g[t].message;if((s=e)>=-32099&&s<=-32e3)return"Unspecified server error."}return t}function y(e){return e&&"object"==typeof e&&!Array.isArray(e)?Object.assign({},e):e}function w(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function x(e,t){return"object"==typeof e&&null!==e&&t in e&&"string"==typeof e[t]}let k=e=>M(l,e),v=e=>M(h,e),I=e=>L(d,e),C=e=>L(u,e),E=e=>L(f,e),S=e=>L(p,e),A=e=>{if(!e||"object"!=typeof e||Array.isArray(e))throw Error("Ethereum Provider custom errors must provide single object argument.");let{code:t,message:s,data:i}=e;if(!s||"string"!=typeof s)throw Error('"message" must be a nonempty string');return new N(t,s,i)};function M(e,t){let[s,i]=D(t);return new O(e,s||m(e),i)}function L(e,t){let[s,i]=D(t);return new N(e,s||m(e),i)}function D(e){if(e){if("string"==typeof e)return[e];else if("object"==typeof e&&!Array.isArray(e)){let{message:t,data:s}=e;if(t&&"string"!=typeof t)throw Error("Must specify string message.");return[t||void 0,s]}}return[]}class O extends Error{constructor(e,t,s){if(!Number.isInteger(e))throw Error('"code" must be an integer.');if(!t||"string"!=typeof t)throw Error('"message" must be a nonempty string.');super(t),this.code=e,void 0!==s&&(this.data=s)}}class N extends O{constructor(e,t,s){if(!function(e){return Number.isInteger(e)&&e>=1e3&&e<=4999}(e))throw Error('"code" must be an integer such that: 1000 <= code <= 4999');super(e,t,s)}}function R(e){return Math.floor(e)}let T=/^[0-9]*$/,_=/^[a-f0-9]*$/;function U(e){return j(crypto.getRandomValues(new Uint8Array(e)))}function j(e){return[...e].map(e=>e.toString(16).padStart(2,"0")).join("")}function P(e){return new Uint8Array(e.match(/.{1,2}/g).map(e=>Number.parseInt(e,16)))}function H(e,t=!1){let s=e.toString("hex");return t?`0x${s}`:s}function W(e){return H(G(e),!0)}function B(e){return e.toString(10)}function q(e){return`0x${BigInt(e).toString(16)}`}function V(e){return e.startsWith("0x")||e.startsWith("0X")}function Z(e){return V(e)?e.slice(2):e}function F(e){return V(e)?`0x${e.slice(2)}`:`0x${e}`}function K(e){if("string"!=typeof e)return!1;let t=Z(e).toLowerCase();return _.test(t)}function z(e,t=!1){let s=function(e,t=!1){if("string"==typeof e){let s=Z(e).toLowerCase();if(_.test(s))return t?`0x${s}`:s}throw k(`"${String(e)}" is not a hexadecimal string`)}(e,!1);return s.length%2==1&&(s=`0${s}`),t?`0x${s}`:s}function $(e){if("string"==typeof e){let t=Z(e).toLowerCase();if(K(t)&&40===t.length)return F(t)}throw k(`Invalid Ethereum address: ${String(e)}`)}function G(e){if(Buffer.isBuffer(e))return e;if("string"==typeof e){if(K(e)){let t=z(e,!1);return Buffer.from(t,"hex")}return Buffer.from(e,"utf8")}throw k(`Not binary data: ${String(e)}`)}function Q(e){if("number"==typeof e&&Number.isInteger(e))return R(e);if("string"==typeof e){if(T.test(e))return R(Number(e));if(K(e))return R(Number(BigInt(z(e,!0))))}throw k(`Not an integer: ${String(e)}`)}function J(e){if(null!==e&&("bigint"==typeof e||function(e){if(null==e||"function"!=typeof e.constructor)return!1;let{constructor:t}=e;return"function"==typeof t.config&&"number"==typeof t.EUCLID}(e)))return BigInt(e.toString(10));if("number"==typeof e)return BigInt(Q(e));if("string"==typeof e){if(T.test(e))return BigInt(e);if(K(e))return BigInt(z(e,!0))}throw k(`Not an integer: ${String(e)}`)}async function Y(){return crypto.subtle.generateKey({name:"ECDH",namedCurve:"P-256"},!0,["deriveKey"])}async function X(e,t){return crypto.subtle.deriveKey({name:"ECDH",public:t},e,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"])}async function ee(e,t){let s=crypto.getRandomValues(new Uint8Array(12)),i=await crypto.subtle.encrypt({name:"AES-GCM",iv:s},e,new TextEncoder().encode(t));return{iv:s,cipherText:i}}async function et(e,{iv:t,cipherText:s}){let i=await crypto.subtle.decrypt({name:"AES-GCM",iv:t},e,s);return new TextDecoder().decode(i)}function es(e){switch(e){case"public":return"spki";case"private":return"pkcs8"}}async function ei(e,t){let s=es(e);return j(new Uint8Array(await crypto.subtle.exportKey(s,t)))}async function en(e,t){let s=es(e),i=P(t).buffer;return await crypto.subtle.importKey(s,new Uint8Array(i),{name:"ECDH",namedCurve:"P-256"},!0,"private"===e?["deriveKey"]:[])}async function er(e,t){return ee(t,JSON.stringify(e,(e,t)=>t instanceof Error?Object.assign(Object.assign({},t.code?{code:t.code}:{}),{message:t.message}):t))}async function ea(e,t){return JSON.parse(await et(t,e))}let eo={storageKey:"ownPrivateKey",keyType:"private"},ec={storageKey:"ownPublicKey",keyType:"public"},el={storageKey:"peerPublicKey",keyType:"public"};class eh{constructor(){this.storage=new c("CBWSDK","SCWKeyManager"),this.ownPrivateKey=null,this.ownPublicKey=null,this.peerPublicKey=null,this.sharedSecret=null}async getOwnPublicKey(){return await this.loadKeysIfNeeded(),this.ownPublicKey}async getSharedSecret(){return await this.loadKeysIfNeeded(),this.sharedSecret}async setPeerPublicKey(e){this.sharedSecret=null,this.peerPublicKey=e,await this.storeKey(el,e),await this.loadKeysIfNeeded()}async clear(){this.ownPrivateKey=null,this.ownPublicKey=null,this.peerPublicKey=null,this.sharedSecret=null,this.storage.removeItem(ec.storageKey),this.storage.removeItem(eo.storageKey),this.storage.removeItem(el.storageKey)}async generateKeyPair(){let e=await Y();this.ownPrivateKey=e.privateKey,this.ownPublicKey=e.publicKey,await this.storeKey(eo,e.privateKey),await this.storeKey(ec,e.publicKey)}async loadKeysIfNeeded(){null===this.ownPrivateKey&&(this.ownPrivateKey=await this.loadKey(eo)),null===this.ownPublicKey&&(this.ownPublicKey=await this.loadKey(ec)),(null===this.ownPrivateKey||null===this.ownPublicKey)&&await this.generateKeyPair(),null===this.peerPublicKey&&(this.peerPublicKey=await this.loadKey(el)),null===this.sharedSecret&&null!==this.ownPrivateKey&&null!==this.peerPublicKey&&(this.sharedSecret=await X(this.ownPrivateKey,this.peerPublicKey))}async loadKey(e){let t=this.storage.getItem(e.storageKey);return t?en(e.keyType,t):null}async storeKey(e,t){let s=await ei(e.keyType,t);this.storage.setItem(e.storageKey,s)}}var ed=s(7138);let eu="@coinbase/wallet-sdk";async function ef(e,t){let s=Object.assign(Object.assign({},e),{jsonrpc:"2.0",id:crypto.randomUUID()}),i=await window.fetch(t,{method:"POST",body:JSON.stringify(s),mode:"cors",headers:{"Content-Type":"application/json","X-Cbw-Sdk-Version":"4.3.7","X-Cbw-Sdk-Platform":eu}}),{result:n,error:r}=await i.json();if(r)throw r;return n}function ep({metadata:e,preference:t}){var s,i;let{appName:n,appLogoUrl:r,appChainIds:a}=e;if("smartWalletOnly"!==t.options){let e=globalThis.coinbaseWalletExtension;if(e)return null==(s=e.setAppInfo)||s.call(e,n,r,a,t),e}let o=function(){var e,t;try{let s=globalThis;return null!=(t=null==(e=s.top)?void 0:e.ethereum)?t:s.ethereum}catch(e){return}}();if(null==o?void 0:o.isCoinbaseBrowser)return null==(i=o.setAppInfo)||i.call(o,n,r,a,t),o}let eg="accounts",eb="activeChain",em="availableChains",ey="walletCapabilities";class ew{constructor(e){var t,s,i;this.metadata=e.metadata,this.communicator=e.communicator,this.callback=e.callback,this.keyManager=new eh,this.storage=new c("CBWSDK","SCWStateManager"),this.accounts=null!=(t=this.storage.loadObject(eg))?t:[],this.chain=this.storage.loadObject(eb)||{id:null!=(i=null==(s=e.metadata.appChainIds)?void 0:s[0])?i:1},this.handshake=this.handshake.bind(this),this.request=this.request.bind(this),this.createRequestMessage=this.createRequestMessage.bind(this),this.decryptResponseMessage=this.decryptResponseMessage.bind(this)}async handshake(e){var t,s,i,n;await (null==(s=(t=this.communicator).waitForPopupLoaded)?void 0:s.call(t));let r=await this.createRequestMessage({handshake:{method:e.method,params:Object.assign({},this.metadata,null!=(i=e.params)?i:{})}}),a=await this.communicator.postRequestAndWaitForResponse(r);if("failure"in a.content)throw a.content.failure;let o=await en("public",a.sender);await this.keyManager.setPeerPublicKey(o);let c=(await this.decryptResponseMessage(a)).result;if("error"in c)throw c.error;if("eth_requestAccounts"===e.method){let e=c.value;this.accounts=e,this.storage.storeObject(eg,e),null==(n=this.callback)||n.call(this,"accountsChanged",e)}}async request(e){var t;if(0===this.accounts.length)if("wallet_sendCalls"===e.method)return this.sendRequestToPopup(e);else throw C();switch(e.method){case"eth_requestAccounts":return null==(t=this.callback)||t.call(this,"connect",{chainId:q(this.chain.id)}),this.accounts;case"eth_accounts":return this.accounts;case"eth_coinbase":return this.accounts[0];case"net_version":return this.chain.id;case"eth_chainId":return q(this.chain.id);case"wallet_getCapabilities":return this.handleGetCapabilitiesRequest(e);case"wallet_switchEthereumChain":return this.handleSwitchChainRequest(e);case"eth_ecRecover":case"personal_sign":case"wallet_sign":case"personal_ecRecover":case"eth_signTransaction":case"eth_sendTransaction":case"eth_signTypedData_v1":case"eth_signTypedData_v3":case"eth_signTypedData_v4":case"eth_signTypedData":case"wallet_addEthereumChain":case"wallet_watchAsset":case"wallet_sendCalls":case"wallet_showCallsStatus":case"wallet_grantPermissions":return this.sendRequestToPopup(e);default:if(!this.chain.rpcUrl)throw v("No RPC URL set for chain");return ef(e,this.chain.rpcUrl)}}async sendRequestToPopup(e){var t,s;await (null==(s=(t=this.communicator).waitForPopupLoaded)?void 0:s.call(t));let i=await this.sendEncryptedRequest(e),n=(await this.decryptResponseMessage(i)).result;if("error"in n)throw n.error;return n.value}async cleanup(){var e,t;this.storage.clear(),await this.keyManager.clear(),this.accounts=[],this.chain={id:null!=(t=null==(e=this.metadata.appChainIds)?void 0:e[0])?t:1}}async handleSwitchChainRequest(e){var t;let s=e.params;if(!s||!(null==(t=s[0])?void 0:t.chainId))throw k();let i=Q(s[0].chainId);if(this.updateChain(i))return null;let n=await this.sendRequestToPopup(e);return null===n&&this.updateChain(i),n}async handleGetCapabilitiesRequest(e){var t=e.params;if(!t||!Array.isArray(t)||1!==t.length&&2!==t.length||"string"!=typeof t[0]||!(0,ed.P)(t[0]))throw k();if(2===t.length){if(!Array.isArray(t[1]))throw k();for(let e of t[1])if("string"!=typeof e||!e.startsWith("0x"))throw k()}let s=e.params[0],i=e.params[1];if(!this.accounts.some(e=>(0,a.h)(e,s)))throw C("no active account found");let n=this.storage.loadObject(ey);if(!n)return{};if(!i||0===i.length)return n;let r=new Set(i.map(e=>(0,o.ME)(e)));return Object.fromEntries(Object.entries(n).filter(([e])=>{try{let t=(0,o.ME)(e);return r.has(t)}catch(e){return!1}}))}async sendEncryptedRequest(e){let t=await this.keyManager.getSharedSecret();if(!t)throw C("No valid session found, try requestAccounts before other methods");let s=await er({action:e,chainId:this.chain.id},t),i=await this.createRequestMessage({encrypted:s});return this.communicator.postRequestAndWaitForResponse(i)}async createRequestMessage(e){let t=await ei("public",await this.keyManager.getOwnPublicKey());return{id:crypto.randomUUID(),sender:t,content:e,timestamp:new Date}}async decryptResponseMessage(e){var t,s;let i=e.content;if("failure"in i)throw i.failure;let n=await this.keyManager.getSharedSecret();if(!n)throw C("Invalid session");let r=await ea(i.encrypted,n),a=null==(t=r.data)?void 0:t.chains;if(a){let e=Object.entries(a).map(([e,t])=>({id:Number(e),rpcUrl:t}));this.storage.storeObject(em,e),this.updateChain(this.chain.id,e)}let o=null==(s=r.data)?void 0:s.capabilities;return o&&this.storage.storeObject(ey,o),r}updateChain(e,t){var s;let i=null!=t?t:this.storage.loadObject(em),n=null==i?void 0:i.find(t=>t.id===e);return!!n&&(n!==this.chain&&(this.chain=n,this.storage.storeObject(eb,n),null==(s=this.callback)||s.call(this,"chainChanged",q(n.id))),!0)}}var ex=s(5912);let ek="Addresses";function ev(e){return void 0!==e.errorMessage}class eI{constructor(e){this.secret=e}async encrypt(e){let t=this.secret;if(64!==t.length)throw Error("secret must be 256 bits");let s=crypto.getRandomValues(new Uint8Array(12)),i=await crypto.subtle.importKey("raw",P(t),{name:"aes-gcm"},!1,["encrypt","decrypt"]),n=new TextEncoder,r=await window.crypto.subtle.encrypt({name:"AES-GCM",iv:s},i,n.encode(e)),a=r.slice(r.byteLength-16),o=r.slice(0,r.byteLength-16),c=new Uint8Array(a),l=new Uint8Array(o);return j(new Uint8Array([...s,...c,...l]))}async decrypt(e){let t=this.secret;if(64!==t.length)throw Error("secret must be 256 bits");return new Promise((s,i)=>{!async function(){let n=await crypto.subtle.importKey("raw",P(t),{name:"aes-gcm"},!1,["encrypt","decrypt"]),r=P(e),a=r.slice(0,12),o=r.slice(12,28),c=new Uint8Array([...r.slice(28),...o]),l={name:"AES-GCM",iv:new Uint8Array(a)};try{let e=await window.crypto.subtle.decrypt(l,n,c),t=new TextDecoder;s(t.decode(e))}catch(e){i(e)}}()})}}class eC{constructor(e,t,s){this.linkAPIUrl=e,this.sessionId=t;const i=`${t}:${s}`;this.auth=`Basic ${btoa(i)}`}async markUnseenEventsAsSeen(e){return Promise.all(e.map(e=>fetch(`${this.linkAPIUrl}/events/${e.eventId}/seen`,{method:"POST",headers:{Authorization:this.auth}}))).catch(e=>console.error("Unabled to mark event as failed:",e))}async fetchUnseenEvents(){var e;let t=await fetch(`${this.linkAPIUrl}/events?unseen=true`,{headers:{Authorization:this.auth}});if(t.ok){let{events:s,error:i}=await t.json();if(i)throw Error(`Check unseen events failed: ${i}`);let n=null!=(e=null==s?void 0:s.filter(e=>"Web3Response"===e.event).map(e=>({type:"Event",sessionId:this.sessionId,eventId:e.id,event:e.event,data:e.data})))?e:[];return this.markUnseenEventsAsSeen(n),n}throw Error(`Check unseen events failed: ${t.status}`)}}(n=r||(r={}))[n.DISCONNECTED=0]="DISCONNECTED",n[n.CONNECTING=1]="CONNECTING",n[n.CONNECTED=2]="CONNECTED";class eE{setConnectionStateListener(e){this.connectionStateListener=e}setIncomingDataListener(e){this.incomingDataListener=e}constructor(e,t=WebSocket){this.WebSocketClass=t,this.webSocket=null,this.isDisconnecting=!1,this.url=e.replace(/^http/,"ws"),this.instanceId=eE.instanceCounter++,eE.activeInstances.add(this.instanceId)}async connect(){if(this.webSocket)throw Error("webSocket object is not null");if(this.isDisconnecting)throw Error("WebSocket is disconnecting, cannot reconnect on same instance");return new Promise((e,t)=>{var s;let i;try{this.webSocket=i=new this.WebSocketClass(this.url)}catch(e){t(e);return}null==(s=this.connectionStateListener)||s.call(this,r.CONNECTING),i.onclose=e=>{var s;this.clearWebSocket(),i.readyState!==WebSocket.OPEN&&t(Error(`websocket error ${e.code}: ${e.reason}`)),null==(s=this.connectionStateListener)||s.call(this,r.DISCONNECTED)},i.onopen=t=>{var s;e(),null==(s=this.connectionStateListener)||s.call(this,r.CONNECTED),eE.pendingData.length>0&&([...eE.pendingData].forEach(e=>this.sendData(e)),eE.pendingData=[])},i.onmessage=e=>{var t,s;if("h"===e.data)null==(t=this.incomingDataListener)||t.call(this,{type:"Heartbeat"});else try{let t=JSON.parse(e.data);null==(s=this.incomingDataListener)||s.call(this,t)}catch(e){}}})}disconnect(){var e;let{webSocket:t}=this;if(t){this.isDisconnecting=!0,this.clearWebSocket(),null==(e=this.connectionStateListener)||e.call(this,r.DISCONNECTED),this.connectionStateListener=void 0,this.incomingDataListener=void 0;try{t.close()}catch(e){}}}sendData(e){let{webSocket:t}=this;if(!t){eE.pendingData.push(e),this.isDisconnecting||this.connect();return}t.readyState!==WebSocket.OPEN?eE.pendingData.push(e):t.send(e)}clearWebSocket(){let{webSocket:e}=this;e&&(this.webSocket=null,e.onclose=null,e.onerror=null,e.onmessage=null,e.onopen=null)}cleanup(){eE.activeInstances.delete(this.instanceId)}}eE.instanceCounter=0,eE.activeInstances=new Set,eE.pendingData=[];class eS{constructor({session:e,linkAPIUrl:t,listener:s}){this.destroyed=!1,this.lastHeartbeatResponse=0,this.nextReqId=R(1),this.reconnectAttempts=0,this.isReconnecting=!1,this._connected=!1,this._linked=!1,this.requestResolutions=new Map,this.handleSessionMetadataUpdated=e=>{e&&new Map([["__destroyed",this.handleDestroyed],["EthereumAddress",this.handleAccountUpdated],["WalletUsername",this.handleWalletUsernameUpdated],["AppVersion",this.handleAppVersionUpdated],["ChainId",t=>e.JsonRpcUrl&&this.handleChainUpdated(t,e.JsonRpcUrl)]]).forEach((t,s)=>{let i=e[s];void 0!==i&&t(i)})},this.handleDestroyed=e=>{var t;"1"===e&&(null==(t=this.listener)||t.resetAndReload())},this.handleAccountUpdated=async e=>{var t;try{let s=await this.cipher.decrypt(e);null==(t=this.listener)||t.accountUpdated(s)}catch(e){}},this.handleMetadataUpdated=async(e,t)=>{var s;try{let i=await this.cipher.decrypt(t);null==(s=this.listener)||s.metadataUpdated(e,i)}catch(e){}},this.handleWalletUsernameUpdated=async e=>{this.handleMetadataUpdated("walletUsername",e)},this.handleAppVersionUpdated=async e=>{this.handleMetadataUpdated("AppVersion",e)},this.handleChainUpdated=async(e,t)=>{var s;try{let i=await this.cipher.decrypt(e),n=await this.cipher.decrypt(t);null==(s=this.listener)||s.chainUpdated(i,n)}catch(e){}},this.session=e,this.cipher=new eI(e.secret),this.listener=s,this.linkAPIUrl=t,this.WebSocketClass=WebSocket;const i=this.createWebSocket();this.ws=i,this.http=new eC(t,e.id,e.key),this.setupVisibilityChangeHandler()}createWebSocket(){let e=new eE(`${this.linkAPIUrl}/rpc`,this.WebSocketClass);return this.activeWsInstance=e,e.setConnectionStateListener(async t=>{if(e!==this.activeWsInstance)return;let s=!1;switch(t){case r.DISCONNECTED:this.heartbeatIntervalId&&(clearInterval(this.heartbeatIntervalId),this.heartbeatIntervalId=void 0),this.lastHeartbeatResponse=0,s=!1,this.destroyed||(async()=>{if(this.isReconnecting)return;this.isReconnecting=!0;let t=3e3*(0!==this.reconnectAttempts);await new Promise(e=>setTimeout(e,t)),this.destroyed||e!==this.activeWsInstance?this.isReconnecting=!1:(this.reconnectAttempts++,"cleanup"in this.ws&&"function"==typeof this.ws.cleanup&&this.ws.cleanup(),this.ws=this.createWebSocket(),this.ws.connect().catch(()=>{}).finally(()=>{this.isReconnecting=!1}))})();break;case r.CONNECTED:this.reconnectAttempts=0;try{s=await this.handleConnected(),this.fetchUnseenEventsAPI().catch(()=>{})}catch(e){break}this.connected=s,this.updateLastHeartbeat(),this.heartbeatIntervalId&&clearInterval(this.heartbeatIntervalId),this.heartbeatIntervalId=window.setInterval(()=>{this.heartbeat()},1e4),setTimeout(()=>{this.heartbeat()},100);case r.CONNECTING:}t!==r.CONNECTED&&(this.connected=s)}),e.setIncomingDataListener(e=>{var t;switch(e.type){case"Heartbeat":this.updateLastHeartbeat();return;case"IsLinkedOK":case"Linked":{let t="IsLinkedOK"===e.type?e.linked:void 0;this.linked=t||e.onlineGuests>0;break}case"GetSessionConfigOK":case"SessionConfigUpdated":this.handleSessionMetadataUpdated(e.metadata);break;case"Event":this.handleIncomingEvent(e)}void 0!==e.id&&(null==(t=this.requestResolutions.get(e.id))||t(e))}),e}setupVisibilityChangeHandler(){this.visibilityChangeHandler=()=>{document.hidden||this.destroyed||(this.connected?this.heartbeat():this.reconnectWithFreshWebSocket())},this.focusHandler=()=>{this.destroyed||this.connected||this.reconnectWithFreshWebSocket()},document.addEventListener("visibilitychange",this.visibilityChangeHandler),window.addEventListener("focus",this.focusHandler),window.addEventListener("pageshow",e=>{e.persisted&&this.focusHandler&&this.focusHandler()})}reconnectWithFreshWebSocket(){if(this.destroyed)return;let e=this.ws;this.activeWsInstance=void 0,e.disconnect(),"cleanup"in e&&"function"==typeof e.cleanup&&e.cleanup(),this.ws=this.createWebSocket(),this.ws.connect().catch(()=>{})}connect(){if(this.destroyed)throw Error("instance is destroyed");this.ws.connect()}async destroy(){this.destroyed||(await this.makeRequest({type:"SetSessionConfig",id:R(this.nextReqId++),sessionId:this.session.id,metadata:{__destroyed:"1"}},{timeout:1e3}),this.destroyed=!0,this.activeWsInstance=void 0,this.heartbeatIntervalId&&(clearInterval(this.heartbeatIntervalId),this.heartbeatIntervalId=void 0),this.visibilityChangeHandler&&document.removeEventListener("visibilitychange",this.visibilityChangeHandler),this.focusHandler&&window.removeEventListener("focus",this.focusHandler),this.ws.disconnect(),"cleanup"in this.ws&&"function"==typeof this.ws.cleanup&&this.ws.cleanup(),this.listener=void 0)}get connected(){return this._connected}set connected(e){this._connected=e}get linked(){return this._linked}set linked(e){var t,s;this._linked=e,e&&(null==(t=this.onceLinked)||t.call(this)),null==(s=this.listener)||s.linkedUpdated(e)}setOnceLinked(e){return new Promise(t=>{this.linked?e().then(t):this.onceLinked=()=>{e().then(t),this.onceLinked=void 0}})}async handleIncomingEvent(e){var t;if("Event"===e.type&&"Web3Response"===e.event)try{let s=await this.cipher.decrypt(e.data),i=JSON.parse(s);if("WEB3_RESPONSE"!==i.type)return;null==(t=this.listener)||t.handleWeb3ResponseMessage(i.id,i.response)}catch(e){}}async checkUnseenEvents(){await new Promise(e=>setTimeout(e,250));try{await this.fetchUnseenEventsAPI()}catch(e){console.error("Unable to check for unseen events",e)}}async fetchUnseenEventsAPI(){try{(await this.http.fetchUnseenEvents()).forEach(e=>{this.handleIncomingEvent(e)})}catch(e){}}async publishEvent(e,t,s=!1){let i=await this.cipher.encrypt(JSON.stringify(Object.assign(Object.assign({},t),{origin:location.origin,location:location.href,relaySource:"coinbaseWalletExtension"in window&&window.coinbaseWalletExtension?"injected_sdk":"sdk"}))),n={type:"PublishEvent",id:R(this.nextReqId++),sessionId:this.session.id,event:e,data:i,callWebhook:s};return this.setOnceLinked(async()=>{let e=await this.makeRequest(n);if("Fail"===e.type)throw Error(e.error||"failed to publish event");return e.eventId})}sendData(e){this.ws.sendData(JSON.stringify(e))}updateLastHeartbeat(){this.lastHeartbeatResponse=Date.now()}heartbeat(){if(Date.now()-this.lastHeartbeatResponse>2e4)return void this.ws.disconnect();if(this.connected)try{this.ws.sendData("h")}catch(e){}}async makeRequest(e,t={timeout:6e4}){let s,i=e.id;return this.sendData(e),Promise.race([new Promise((e,n)=>{s=window.setTimeout(()=>{n(Error(`request ${i} timed out`))},t.timeout)}),new Promise(e=>{this.requestResolutions.set(i,t=>{clearTimeout(s),e(t),this.requestResolutions.delete(i)})})])}async handleConnected(){return"Fail"!==(await this.makeRequest({type:"HostSession",id:R(this.nextReqId++),sessionId:this.session.id,sessionKey:this.session.key})).type&&(this.sendData({type:"IsLinked",id:R(this.nextReqId++),sessionId:this.session.id}),this.sendData({type:"GetSessionConfig",id:R(this.nextReqId++),sessionId:this.session.id}),!0)}}class eA{constructor(){this._nextRequestId=0,this.callbacks=new Map}makeRequestId(){this._nextRequestId=(this._nextRequestId+1)%0x7fffffff;let e=this._nextRequestId,t=F(e.toString(16));return this.callbacks.get(t)&&this.callbacks.delete(t),e}}var eM=s(5013),eL=s(6167);let eD="session:id",eO="session:secret",eN="session:linked";class eR{constructor(e,t,s,i=!1){this.storage=e,this.id=t,this.secret=s,this.key=(0,eL.My)((0,eM.sc)(`${t}, ${s} WalletLink`)),this._linked=!!i}static create(e){return new eR(e,U(16),U(32)).save()}static load(e){let t=e.getItem(eD),s=e.getItem(eN),i=e.getItem(eO);return t&&i?new eR(e,t,i,"1"===s):null}get linked(){return this._linked}set linked(e){this._linked=e,this.persistLinked()}save(){return this.storage.setItem(eD,this.id),this.storage.setItem(eO,this.secret),this.persistLinked(),this}persistLinked(){this.storage.setItem(eN,this._linked?"1":"0")}}function eT(){var e,t;return null!=(t=null==(e=null==window?void 0:window.matchMedia)?void 0:e.call(window,"(prefers-color-scheme: dark)").matches)&&t}function e_(){let e=document.createElement("style");e.type="text/css",e.appendChild(document.createTextNode('@namespace svg "http://www.w3.org/2000/svg";.-cbwsdk-css-reset,.-cbwsdk-css-reset *{animation:none;animation-delay:0;animation-direction:normal;animation-duration:0;animation-fill-mode:none;animation-iteration-count:1;animation-name:none;animation-play-state:running;animation-timing-function:ease;backface-visibility:visible;background:0;background-attachment:scroll;background-clip:border-box;background-color:rgba(0,0,0,0);background-image:none;background-origin:padding-box;background-position:0 0;background-position-x:0;background-position-y:0;background-repeat:repeat;background-size:auto auto;border:0;border-style:none;border-width:medium;border-color:inherit;border-bottom:0;border-bottom-color:inherit;border-bottom-left-radius:0;border-bottom-right-radius:0;border-bottom-style:none;border-bottom-width:medium;border-collapse:separate;border-image:none;border-left:0;border-left-color:inherit;border-left-style:none;border-left-width:medium;border-radius:0;border-right:0;border-right-color:inherit;border-right-style:none;border-right-width:medium;border-spacing:0;border-top:0;border-top-color:inherit;border-top-left-radius:0;border-top-right-radius:0;border-top-style:none;border-top-width:medium;box-shadow:none;box-sizing:border-box;caption-side:top;clear:none;clip:auto;color:inherit;columns:auto;column-count:auto;column-fill:balance;column-gap:normal;column-rule:medium none currentColor;column-rule-color:currentColor;column-rule-style:none;column-rule-width:none;column-span:1;column-width:auto;counter-increment:none;counter-reset:none;direction:ltr;empty-cells:show;float:none;font:normal;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Helvetica Neue",Arial,sans-serif;font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;height:auto;hyphens:none;letter-spacing:normal;line-height:normal;list-style:none;list-style-image:none;list-style-position:outside;list-style-type:disc;margin:0;margin-bottom:0;margin-left:0;margin-right:0;margin-top:0;opacity:1;orphans:0;outline:0;outline-color:invert;outline-style:none;outline-width:medium;overflow:visible;overflow-x:visible;overflow-y:visible;padding:0;padding-bottom:0;padding-left:0;padding-right:0;padding-top:0;page-break-after:auto;page-break-before:auto;page-break-inside:auto;perspective:none;perspective-origin:50% 50%;pointer-events:auto;position:static;quotes:"\\201C" "\\201D" "\\2018" "\\2019";tab-size:8;table-layout:auto;text-align:inherit;text-align-last:auto;text-decoration:none;text-decoration-color:inherit;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-shadow:none;text-transform:none;transform:none;transform-style:flat;transition:none;transition-delay:0s;transition-duration:0s;transition-property:none;transition-timing-function:ease;unicode-bidi:normal;vertical-align:baseline;visibility:visible;white-space:normal;widows:0;word-spacing:normal;z-index:auto}.-cbwsdk-css-reset strong{font-weight:bold}.-cbwsdk-css-reset *{box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Helvetica Neue",Arial,sans-serif;line-height:1}.-cbwsdk-css-reset [class*=container]{margin:0;padding:0}.-cbwsdk-css-reset style{display:none}')),document.documentElement.appendChild(e)}var eU=s(4362),ej=s(2109),eP=s(7977);class eH{constructor(){this.items=new Map,this.nextItemKey=0,this.root=null,this.darkMode=eT()}attach(e){this.root=document.createElement("div"),this.root.className="-cbwsdk-snackbar-root",e.appendChild(this.root),this.render()}presentItem(e){let t=this.nextItemKey++;return this.items.set(t,e),this.render(),()=>{this.items.delete(t),this.render()}}clear(){this.items.clear(),this.render()}render(){this.root&&(0,ej.XX)((0,ej.h)("div",null,(0,ej.h)(eW,{darkMode:this.darkMode},Array.from(this.items.entries()).map(([e,t])=>(0,ej.h)(eB,Object.assign({},t,{key:e}))))),this.root)}}let eW=e=>(0,ej.h)("div",{class:(0,eU.$)("-cbwsdk-snackbar-container")},(0,ej.h)("style",null,".-cbwsdk-css-reset .-gear-container{margin-left:16px !important;margin-right:9px !important;display:flex;align-items:center;justify-content:center;width:24px;height:24px;transition:opacity .25s}.-cbwsdk-css-reset .-gear-container *{user-select:none}.-cbwsdk-css-reset .-gear-container svg{opacity:0;position:absolute}.-cbwsdk-css-reset .-gear-icon{height:12px;width:12px;z-index:10000}.-cbwsdk-css-reset .-cbwsdk-snackbar{align-items:flex-end;display:flex;flex-direction:column;position:fixed;right:0;top:0;z-index:2147483647}.-cbwsdk-css-reset .-cbwsdk-snackbar *{user-select:none}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance{display:flex;flex-direction:column;margin:8px 16px 0 16px;overflow:visible;text-align:left;transform:translateX(0);transition:opacity .25s,transform .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header:hover .-gear-container svg{opacity:1}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header{display:flex;align-items:center;background:#fff;overflow:hidden;border:1px solid #e7ebee;box-sizing:border-box;border-radius:8px;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header-cblogo{margin:8px 8px 8px 8px}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header *{cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header-message{color:#000;font-size:13px;line-height:1.5;user-select:none}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu{background:#fff;transition:opacity .25s ease-in-out,transform .25s linear,visibility 0s;visibility:hidden;border:1px solid #e7ebee;box-sizing:border-box;border-radius:8px;opacity:0;flex-direction:column;padding-left:8px;padding-right:8px}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:last-child{margin-bottom:8px !important}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover{background:#f5f7f8;border-radius:6px;transition:background .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover span{color:#050f19;transition:color .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover svg path{fill:#000;transition:fill .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item{visibility:inherit;height:35px;margin-top:8px;margin-bottom:0;display:flex;flex-direction:row;align-items:center;padding:8px;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item *{visibility:inherit;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover{background:rgba(223,95,103,.2);transition:background .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover *{cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover svg path{fill:#df5f67;transition:fill .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover span{color:#df5f67;transition:color .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-info{color:#aaa;font-size:13px;margin:0 8px 0 32px;position:absolute}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-hidden{opacity:0;text-align:left;transform:translateX(25%);transition:opacity .5s linear}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-expanded .-cbwsdk-snackbar-instance-menu{opacity:1;display:flex;transform:translateY(8px);visibility:visible}"),(0,ej.h)("div",{class:"-cbwsdk-snackbar"},e.children)),eB=({autoExpand:e,message:t,menuItems:s})=>{let[i,n]=(0,eP.J0)(!0),[r,a]=(0,eP.J0)(null!=e&&e);return(0,eP.vJ)(()=>{let e=[window.setTimeout(()=>{n(!1)},1),window.setTimeout(()=>{a(!0)},1e4)];return()=>{e.forEach(window.clearTimeout)}}),(0,ej.h)("div",{class:(0,eU.$)("-cbwsdk-snackbar-instance",i&&"-cbwsdk-snackbar-instance-hidden",r&&"-cbwsdk-snackbar-instance-expanded")},(0,ej.h)("div",{class:"-cbwsdk-snackbar-instance-header",onClick:()=>{a(!r)}},(0,ej.h)("img",{src:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEuNDkyIDEwLjQxOWE4LjkzIDguOTMgMCAwMTguOTMtOC45M2gxMS4xNjNhOC45MyA4LjkzIDAgMDE4LjkzIDguOTN2MTEuMTYzYTguOTMgOC45MyAwIDAxLTguOTMgOC45M0gxMC40MjJhOC45MyA4LjkzIDAgMDEtOC45My04LjkzVjEwLjQxOXoiIGZpbGw9IiMxNjUyRjAiLz48cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTEwLjQxOSAwSDIxLjU4QzI3LjMzNSAwIDMyIDQuNjY1IDMyIDEwLjQxOVYyMS41OEMzMiAyNy4zMzUgMjcuMzM1IDMyIDIxLjU4MSAzMkgxMC40MkM0LjY2NSAzMiAwIDI3LjMzNSAwIDIxLjU4MVYxMC40MkMwIDQuNjY1IDQuNjY1IDAgMTAuNDE5IDB6bTAgMS40ODhhOC45MyA4LjkzIDAgMDAtOC45MyA4LjkzdjExLjE2M2E4LjkzIDguOTMgMCAwMDguOTMgOC45M0gyMS41OGE4LjkzIDguOTMgMCAwMDguOTMtOC45M1YxMC40MmE4LjkzIDguOTMgMCAwMC04LjkzLTguOTNIMTAuNDJ6IiBmaWxsPSIjZmZmIi8+PHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xNS45OTggMjYuMDQ5Yy01LjU0OSAwLTEwLjA0Ny00LjQ5OC0xMC4wNDctMTAuMDQ3IDAtNS41NDggNC40OTgtMTAuMDQ2IDEwLjA0Ny0xMC4wNDYgNS41NDggMCAxMC4wNDYgNC40OTggMTAuMDQ2IDEwLjA0NiAwIDUuNTQ5LTQuNDk4IDEwLjA0Ny0xMC4wNDYgMTAuMDQ3eiIgZmlsbD0iI2ZmZiIvPjxwYXRoIGQ9Ik0xMi43NjIgMTQuMjU0YzAtLjgyMi42NjctMS40ODkgMS40ODktMS40ODloMy40OTdjLjgyMiAwIDEuNDg4LjY2NiAxLjQ4OCAxLjQ4OXYzLjQ5N2MwIC44MjItLjY2NiAxLjQ4OC0xLjQ4OCAxLjQ4OGgtMy40OTdhMS40ODggMS40ODggMCAwMS0xLjQ4OS0xLjQ4OHYtMy40OTh6IiBmaWxsPSIjMTY1MkYwIi8+PC9zdmc+",class:"-cbwsdk-snackbar-instance-header-cblogo"})," ",(0,ej.h)("div",{class:"-cbwsdk-snackbar-instance-header-message"},t),(0,ej.h)("div",{class:"-gear-container"},!r&&(0,ej.h)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,ej.h)("circle",{cx:"12",cy:"12",r:"12",fill:"#F5F7F8"})),(0,ej.h)("img",{src:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIiIGhlaWdodD0iMTIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDYuNzV2LTEuNWwtMS43Mi0uNTdjLS4wOC0uMjctLjE5LS41Mi0uMzItLjc3bC44MS0xLjYyLTEuMDYtMS4wNi0xLjYyLjgxYy0uMjQtLjEzLS41LS4yNC0uNzctLjMyTDYuNzUgMGgtMS41bC0uNTcgMS43MmMtLjI3LjA4LS41My4xOS0uNzcuMzJsLTEuNjItLjgxLTEuMDYgMS4wNi44MSAxLjYyYy0uMTMuMjQtLjI0LjUtLjMyLjc3TDAgNS4yNXYxLjVsMS43Mi41N2MuMDguMjcuMTkuNTMuMzIuNzdsLS44MSAxLjYyIDEuMDYgMS4wNiAxLjYyLS44MWMuMjQuMTMuNS4yMy43Ny4zMkw1LjI1IDEyaDEuNWwuNTctMS43MmMuMjctLjA4LjUyLS4xOS43Ny0uMzJsMS42Mi44MSAxLjA2LTEuMDYtLjgxLTEuNjJjLjEzLS4yNC4yMy0uNS4zMi0uNzdMMTIgNi43NXpNNiA4LjVhMi41IDIuN