import{h as an,E as on}from"./index-CGwqVb88.js";import{r as cn}from"./sha3--8JbGYfk.js";import{H as dn,c as me,e as $e,t as ln,o as un,w as hn,r as P,b as fn}from"./utils-CqP-FaiV.js";import{c as Q}from"./clsx.m-DHulAg21.js";class L{constructor(e,n){this.scope=e,this.module=n}storeObject(e,n){this.setItem(e,JSON.stringify(n))}loadObject(e){const n=this.getItem(e);return n?JSON.parse(n):void 0}setItem(e,n){localStorage.setItem(this.scopedKey(e),n)}getItem(e){return localStorage.getItem(this.scopedKey(e))}removeItem(e){localStorage.removeItem(this.scopedKey(e))}clear(){const e=this.scopedKey(""),n=[];for(let s=0;s<localStorage.length;s++){const r=localStorage.key(s);typeof r=="string"&&r.startsWith(e)&&n.push(r)}n.forEach(s=>localStorage.removeItem(s))}scopedKey(e){return`-${this.scope}${this.module?`:${this.module}`:""}:${e}`}static clearAll(){new L("CBWSDK").clear(),new L("walletlink").clear()}}const E={rpc:{invalidInput:-32e3,resourceNotFound:-32001,resourceUnavailable:-32002,transactionRejected:-32003,methodNotSupported:-32004,limitExceeded:-32005,parse:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internal:-32603},provider:{userRejectedRequest:4001,unauthorized:4100,unsupportedMethod:4200,disconnected:4900,chainDisconnected:4901,unsupportedChain:4902}},Ce={"-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."}},St="Unspecified error message.",pn="Unspecified server error.";function De(t,e=St){if(t&&Number.isInteger(t)){const n=t.toString();if(xe(Ce,n))return Ce[n].message;if(Ct(t))return pn}return e}function gn(t){if(!Number.isInteger(t))return!1;const e=t.toString();return!!(Ce[e]||Ct(t))}function _n(t,{shouldIncludeStack:e=!1}={}){const n={};if(t&&typeof t=="object"&&!Array.isArray(t)&&xe(t,"code")&&gn(t.code)){const s=t;n.code=s.code,s.message&&typeof s.message=="string"?(n.message=s.message,xe(s,"data")&&(n.data=s.data)):(n.message=De(n.code),n.data={originalError:Ge(t)})}else n.code=E.rpc.internal,n.message=Ye(t,"message")?t.message:St,n.data={originalError:Ge(t)};return e&&(n.stack=Ye(t,"stack")?t.stack:void 0),n}function Ct(t){return t>=-32099&&t<=-32e3}function Ge(t){return t&&typeof t=="object"&&!Array.isArray(t)?Object.assign({},t):t}function xe(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function Ye(t,e){return typeof t=="object"&&t!==null&&e in t&&typeof t[e]=="string"}const w={rpc:{parse:t=>A(E.rpc.parse,t),invalidRequest:t=>A(E.rpc.invalidRequest,t),invalidParams:t=>A(E.rpc.invalidParams,t),methodNotFound:t=>A(E.rpc.methodNotFound,t),internal:t=>A(E.rpc.internal,t),server:t=>{if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Ethereum RPC Server errors must provide single object argument.");const{code:e}=t;if(!Number.isInteger(e)||e>-32005||e<-32099)throw new Error('"code" must be an integer such that: -32099 <= code <= -32005');return A(e,t)},invalidInput:t=>A(E.rpc.invalidInput,t),resourceNotFound:t=>A(E.rpc.resourceNotFound,t),resourceUnavailable:t=>A(E.rpc.resourceUnavailable,t),transactionRejected:t=>A(E.rpc.transactionRejected,t),methodNotSupported:t=>A(E.rpc.methodNotSupported,t),limitExceeded:t=>A(E.rpc.limitExceeded,t)},provider:{userRejectedRequest:t=>z(E.provider.userRejectedRequest,t),unauthorized:t=>z(E.provider.unauthorized,t),unsupportedMethod:t=>z(E.provider.unsupportedMethod,t),disconnected:t=>z(E.provider.disconnected,t),chainDisconnected:t=>z(E.provider.chainDisconnected,t),unsupportedChain:t=>z(E.provider.unsupportedChain,t),custom:t=>{if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Ethereum Provider custom errors must provide single object argument.");const{code:e,message:n,data:s}=t;if(!n||typeof n!="string")throw new Error('"message" must be a nonempty string');return new Mt(e,n,s)}}};function A(t,e){const[n,s]=xt(e);return new At(t,n||De(t),s)}function z(t,e){const[n,s]=xt(e);return new Mt(t,n||De(t),s)}function xt(t){if(t){if(typeof t=="string")return[t];if(typeof t=="object"&&!Array.isArray(t)){const{message:e,data:n}=t;if(e&&typeof e!="string")throw new Error("Must specify string message.");return[e||void 0,n]}}return[]}class At extends Error{constructor(e,n,s){if(!Number.isInteger(e))throw new Error('"code" must be an integer.');if(!n||typeof n!="string")throw new Error('"message" must be a nonempty string.');super(n),this.code=e,s!==void 0&&(this.data=s)}}class Mt extends At{constructor(e,n,s){if(!mn(e))throw new Error('"code" must be an integer such that: 1000 <= code <= 4999');super(e,n,s)}}function mn(t){return Number.isInteger(t)&&t>=1e3&&t<=4999}function Oe(){return t=>t}const ee=Oe(),bn=Oe(),wn=Oe();function T(t){return Math.floor(t)}const Pt=/^[0-9]*$/,Rt=/^[a-f0-9]*$/;function q(t){return Ue(crypto.getRandomValues(new Uint8Array(t)))}function Ue(t){return[...t].map(e=>e.toString(16).padStart(2,"0")).join("")}function ae(t){return new Uint8Array(t.match(/.{1,2}/g).map(e=>Number.parseInt(e,16)))}function Z(t,e=!1){const n=t.toString("hex");return ee(e?`0x${n}`:n)}function be(t){return Z(Ae(t),!0)}function R(t){return wn(t.toString(10))}function B(t){return ee(`0x${BigInt(t).toString(16)}`)}function Lt(t){return t.startsWith("0x")||t.startsWith("0X")}function je(t){return Lt(t)?t.slice(2):t}function Tt(t){return Lt(t)?`0x${t.slice(2)}`:`0x${t}`}function he(t){if(typeof t!="string")return!1;const e=je(t).toLowerCase();return Rt.test(e)}function yn(t,e=!1){if(typeof t=="string"){const n=je(t).toLowerCase();if(Rt.test(n))return ee(e?`0x${n}`:n)}throw w.rpc.invalidParams(`"${String(t)}" is not a hexadecimal string`)}function We(t,e=!1){let n=yn(t,!1);return n.length%2===1&&(n=ee(`0${n}`)),e?ee(`0x${n}`):n}function U(t){if(typeof t=="string"){const e=je(t).toLowerCase();if(he(e)&&e.length===40)return bn(Tt(e))}throw w.rpc.invalidParams(`Invalid Ethereum address: ${String(t)}`)}function Ae(t){if(Buffer.isBuffer(t))return t;if(typeof t=="string"){if(he(t)){const e=We(t,!1);return Buffer.from(e,"hex")}return Buffer.from(t,"utf8")}throw w.rpc.invalidParams(`Not binary data: ${String(t)}`)}function X(t){if(typeof t=="number"&&Number.isInteger(t))return T(t);if(typeof t=="string"){if(Pt.test(t))return T(Number(t));if(he(t))return T(Number(BigInt(We(t,!0))))}throw w.rpc.invalidParams(`Not an integer: ${String(t)}`)}function J(t){if(t!==null&&(typeof t=="bigint"||vn(t)))return BigInt(t.toString(10));if(typeof t=="number")return BigInt(X(t));if(typeof t=="string"){if(Pt.test(t))return BigInt(t);if(he(t))return BigInt(We(t,!0))}throw w.rpc.invalidParams(`Not an integer: ${String(t)}`)}function kn(t){if(typeof t=="string")return JSON.parse(t);if(typeof t=="object")return t;throw w.rpc.invalidParams(`Not a JSON string or an object: ${String(t)}`)}function vn(t){if(t==null||typeof t.constructor!="function")return!1;const{constructor:e}=t;return typeof e.config=="function"&&typeof e.EUCLID=="number"}async function En(){return crypto.subtle.generateKey({name:"ECDH",namedCurve:"P-256"},!0,["deriveKey"])}async function In(t,e){return crypto.subtle.deriveKey({name:"ECDH",public:e},t,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"])}async function Sn(t,e){const n=crypto.getRandomValues(new Uint8Array(12)),s=await crypto.subtle.encrypt({name:"AES-GCM",iv:n},t,new TextEncoder().encode(e));return{iv:n,cipherText:s}}async function Cn(t,{iv:e,cipherText:n}){const s=await crypto.subtle.decrypt({name:"AES-GCM",iv:e},t,n);return new TextDecoder().decode(s)}function Nt(t){switch(t){case"public":return"spki";case"private":return"pkcs8"}}async function Dt(t,e){const n=Nt(t),s=await crypto.subtle.exportKey(n,e);return Ue(new Uint8Array(s))}async function Ot(t,e){const n=Nt(t),s=ae(e).buffer;return await crypto.subtle.importKey(n,new Uint8Array(s),{name:"ECDH",namedCurve:"P-256"},!0,t==="private"?["deriveKey"]:[])}async function xn(t,e){const n=JSON.stringify(t,(s,r)=>{if(!(r instanceof Error))return r;const i=r;return Object.assign(Object.assign({},i.code?{code:i.code}:{}),{message:i.message})});return Sn(e,n)}async function An(t,e){return JSON.parse(await Cn(e,t))}const we={storageKey:"ownPrivateKey",keyType:"private"},ye={storageKey:"ownPublicKey",keyType:"public"},ke={storageKey:"peerPublicKey",keyType:"public"};class Mn{constructor(){this.storage=new L("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(ke,e),await this.loadKeysIfNeeded()}async clear(){this.ownPrivateKey=null,this.ownPublicKey=null,this.peerPublicKey=null,this.sharedSecret=null,this.storage.removeItem(ye.storageKey),this.storage.removeItem(we.storageKey),this.storage.removeItem(ke.storageKey)}async generateKeyPair(){const e=await En();this.ownPrivateKey=e.privateKey,this.ownPublicKey=e.publicKey,await this.storeKey(we,e.privateKey),await this.storeKey(ye,e.publicKey)}async loadKeysIfNeeded(){if(this.ownPrivateKey===null&&(this.ownPrivateKey=await this.loadKey(we)),this.ownPublicKey===null&&(this.ownPublicKey=await this.loadKey(ye)),(this.ownPrivateKey===null||this.ownPublicKey===null)&&await this.generateKeyPair(),this.peerPublicKey===null&&(this.peerPublicKey=await this.loadKey(ke)),this.sharedSecret===null){if(this.ownPrivateKey===null||this.peerPublicKey===null)return;this.sharedSecret=await In(this.ownPrivateKey,this.peerPublicKey)}}async loadKey(e){const n=this.storage.getItem(e.storageKey);return n?Ot(e.keyType,n):null}async storeKey(e,n){const s=await Dt(e.keyType,n);this.storage.setItem(e.storageKey,s)}}const ne="4.3.0",Ut="@coinbase/wallet-sdk";async function Be(t,e){const n=Object.assign(Object.assign({},t),{jsonrpc:"2.0",id:crypto.randomUUID()}),s=await window.fetch(e,{method:"POST",body:JSON.stringify(n),mode:"cors",headers:{"Content-Type":"application/json","X-Cbw-Sdk-Version":ne,"X-Cbw-Sdk-Platform":Ut}}),{result:r,error:i}=await s.json();if(i)throw i;return r}function Pn(){return globalThis.coinbaseWalletExtension}function Rn(){var t,e;try{const n=globalThis;return(t=n.ethereum)!==null&&t!==void 0?t:(e=n.top)===null||e===void 0?void 0:e.ethereum}catch{return}}function Ln({metadata:t,preference:e}){var n,s;const{appName:r,appLogoUrl:i,appChainIds:a}=t;if(e.options!=="smartWalletOnly"){const l=Pn();if(l)return(n=l.setAppInfo)===null||n===void 0||n.call(l,r,i,a,e),l}const o=Rn();if(o!=null&&o.isCoinbaseBrowser)return(s=o.setAppInfo)===null||s===void 0||s.call(o,r,i,a,e),o}function Tn(t){if(!t||typeof t!="object"||Array.isArray(t))throw w.rpc.invalidParams({message:"Expected a single, non-array, object argument.",data:t});const{method:e,params:n}=t;if(typeof e!="string"||e.length===0)throw w.rpc.invalidParams({message:"'args.method' must be a non-empty string.",data:t});if(n!==void 0&&!Array.isArray(n)&&(typeof n!="object"||n===null))throw w.rpc.invalidParams({message:"'args.params' must be an object or array if provided.",data:t});switch(e){case"eth_sign":case"eth_signTypedData_v2":case"eth_subscribe":case"eth_unsubscribe":throw w.provider.unsupportedMethod()}}const Ve="accounts",Je="activeChain",Qe="availableChains",Ze="walletCapabilities";class Nn{constructor(e){var n,s,r;this.metadata=e.metadata,this.communicator=e.communicator,this.callback=e.callback,this.keyManager=new Mn,this.storage=new L("CBWSDK","SCWStateManager"),this.accounts=(n=this.storage.loadObject(Ve))!==null&&n!==void 0?n:[],this.chain=this.storage.loadObject(Je)||{id:(r=(s=e.metadata.appChainIds)===null||s===void 0?void 0:s[0])!==null&&r!==void 0?r: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 n,s,r,i;await((s=(n=this.communicator).waitForPopupLoaded)===null||s===void 0?void 0:s.call(n));const a=await this.createRequestMessage({handshake:{method:e.method,params:Object.assign({},this.metadata,(r=e.params)!==null&&r!==void 0?r:{})}}),o=await this.communicator.postRequestAndWaitForResponse(a);if("failure"in o.content)throw o.content.failure;const l=await Ot("public",o.sender);await this.keyManager.setPeerPublicKey(l);const p=(await this.decryptResponseMessage(o)).result;if("error"in p)throw p.error;switch(e.method){case"eth_requestAccounts":{const d=p.value;this.accounts=d,this.storage.storeObject(Ve,d),(i=this.callback)===null||i===void 0||i.call(this,"accountsChanged",d);break}}}async request(e){var n;if(this.accounts.length===0)switch(e.method){case"wallet_sendCalls":return this.sendRequestToPopup(e);default:throw w.provider.unauthorized()}switch(e.method){case"eth_requestAccounts":return(n=this.callback)===null||n===void 0||n.call(this,"connect",{chainId:B(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 B(this.chain.id);case"wallet_getCapabilities":return this.storage.loadObject(Ze);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 w.rpc.internal("No RPC URL set for chain");return Be(e,this.chain.rpcUrl)}}async sendRequestToPopup(e){var n,s;await((s=(n=this.communicator).waitForPopupLoaded)===null||s===void 0?void 0:s.call(n));const r=await this.sendEncryptedRequest(e),a=(await this.decryptResponseMessage(r)).result;if("error"in a)throw a.error;return a.value}async cleanup(){var e,n;this.storage.clear(),await this.keyManager.clear(),this.accounts=[],this.chain={id:(n=(e=this.metadata.appChainIds)===null||e===void 0?void 0:e[0])!==null&&n!==void 0?n:1}}async handleSwitchChainRequest(e){var n;const s=e.params;if(!s||!(!((n=s[0])===null||n===void 0)&&n.chainId))throw w.rpc.invalidParams();const r=X(s[0].chainId);if(this.updateChain(r))return null;const a=await this.sendRequestToPopup(e);return a===null&&this.updateChain(r),a}async sendEncryptedRequest(e){const n=await this.keyManager.getSharedSecret();if(!n)throw w.provider.unauthorized("No valid session found, try requestAccounts before other methods");const s=await xn({action:e,chainId:this.chain.id},n),r=await this.createRequestMessage({encrypted:s});return this.communicator.postRequestAndWaitForResponse(r)}async createRequestMessage(e){const n=await Dt("public",await this.keyManager.getOwnPublicKey());return{id:crypto.randomUUID(),sender:n,content:e,timestamp:new Date}}async decryptResponseMessage(e){var n,s;const r=e.content;if("failure"in r)throw r.failure;const i=await this.keyManager.getSharedSecret();if(!i)throw w.provider.unauthorized("Invalid session");const a=await An(r.encrypted,i),o=(n=a.data)===null||n===void 0?void 0:n.chains;if(o){const h=Object.entries(o).map(([p,d])=>({id:Number(p),rpcUrl:d}));this.storage.storeObject(Qe,h),this.updateChain(this.chain.id,h)}const l=(s=a.data)===null||s===void 0?void 0:s.capabilities;return l&&this.storage.storeObject(Ze,l),a}updateChain(e,n){var s;const r=n??this.storage.loadObject(Qe),i=r==null?void 0:r.find(a=>a.id===e);return i?(i!==this.chain&&(this.chain=i,this.storage.storeObject(Je,i),(s=this.callback)===null||s===void 0||s.call(this,"chainChanged",B(i.id))),!0):!1}}var ve,Xe;function jt(){if(Xe)return ve;Xe=1;const{keccak_256:t}=cn();function e(c){return Buffer.allocUnsafe(c).fill(0)}function n(c){return c.toString(2).length}function s(c,f){let _=c.toString(16);_.length%2!==0&&(_="0"+_);const g=_.match(/.{1,2}/g).map(m=>parseInt(m,16));for(;g.length<f;)g.unshift(0);return Buffer.from(g)}function r(c,f){const _=c<0n;let g;if(_){const m=(1n<<BigInt(f))-1n;g=(~c&m)+1n}else g=c;return g&=(1n<<BigInt(f))-1n,g}function i(c,f,_){const g=e(f);return c=o(c),_?c.length<f?(c.copy(g),g):c.slice(0,f):c.length<f?(c.copy(g,f-c.length),g):c.slice(-f)}function a(c,f){return i(c,f,!0)}function o(c){if(!Buffer.isBuffer(c))if(Array.isArray(c))c=Buffer.from(c);else if(typeof c=="string")d(c)?c=Buffer.from(p(u(c)),"hex"):c=Buffer.from(c);else if(typeof c=="number")c=intToBuffer(c);else if(c==null)c=Buffer.allocUnsafe(0);else if(typeof c=="bigint")c=s(c);else if(c.toArray)c=Buffer.from(c.toArray());else throw new Error("invalid type");return c}function l(c){return c=o(c),"0x"+c.toString("hex")}function h(c,f){if(c=o(c),f||(f=256),f!==256)throw new Error("unsupported");return Buffer.from(t(new Uint8Array(c)))}function p(c){return c.length%2?"0"+c:c}function d(c){return typeof c=="string"&&c.match(/^0x[0-9A-Fa-f]*$/)}function u(c){return typeof c=="string"&&c.startsWith("0x")?c.slice(2):c}return ve={zeros:e,setLength:i,setLengthRight:a,isHexString:d,stripHexPrefix:u,toBuffer:o,bufferToHex:l,keccak:h,bitLengthFromBigInt:n,bufferBEFromBigInt:s,twosFromBigInt:r},ve}var Ee,et;function Dn(){if(et)return Ee;et=1;const t=jt();function e(u){return u.startsWith("int[")?"int256"+u.slice(3):u==="int"?"int256":u.startsWith("uint[")?"uint256"+u.slice(4):u==="uint"?"uint256":u.startsWith("fixed[")?"fixed128x128"+u.slice(5):u==="fixed"?"fixed128x128":u.startsWith("ufixed[")?"ufixed128x128"+u.slice(6):u==="ufixed"?"ufixed128x128":u}function n(u){return Number.parseInt(/^\D+(\d+)$/.exec(u)[1],10)}function s(u){var c=/^\D+(\d+)x(\d+)$/.exec(u);return[Number.parseInt(c[1],10),Number.parseInt(c[2],10)]}function r(u){var c=u.match(/(.*)\[(.*?)\]$/);return c?c[2]===""?"dynamic":Number.parseInt(c[2],10):null}function i(u){var c=typeof u;if(c==="string"||c==="number")return BigInt(u);if(c==="bigint")return u;throw new Error("Argument is not a number")}function a(u,c){var f,_,g,m;if(u==="address")return a("uint160",i(c));if(u==="bool")return a("uint8",c?1:0);if(u==="string")return a("bytes",new Buffer(c,"utf8"));if(l(u)){if(typeof c.length>"u")throw new Error("Not an array?");if(f=r(u),f!=="dynamic"&&f!==0&&c.length>f)throw new Error("Elements exceed array size: "+f);g=[],u=u.slice(0,u.lastIndexOf("[")),typeof c=="string"&&(c=JSON.parse(c));for(m in c)g.push(a(u,c[m]));if(f==="dynamic"){var b=a("uint256",c.length);g.unshift(b)}return Buffer.concat(g)}else{if(u==="bytes")return c=new Buffer(c),g=Buffer.concat([a("uint256",c.length),c]),c.length%32!==0&&(g=Buffer.concat([g,t.zeros(32-c.length%32)])),g;if(u.startsWith("bytes")){if(f=n(u),f<1||f>32)throw new Error("Invalid bytes<N> width: "+f);return t.setLengthRight(c,32)}else if(u.startsWith("uint")){if(f=n(u),f%8||f<8||f>256)throw new Error("Invalid uint<N> width: "+f);_=i(c);const v=t.bitLengthFromBigInt(_);if(v>f)throw new Error("Supplied uint exceeds width: "+f+" vs "+v);if(_<0)throw new Error("Supplied uint is negative");return t.bufferBEFromBigInt(_,32)}else if(u.startsWith("int")){if(f=n(u),f%8||f<8||f>256)throw new Error("Invalid int<N> width: "+f);_=i(c);const v=t.bitLengthFromBigInt(_);if(v>f)throw new Error("Supplied int exceeds width: "+f+" vs "+v);const S=t.twosFromBigInt(_,256);return t.bufferBEFromBigInt(S,32)}else if(u.startsWith("ufixed")){if(f=s(u),_=i(c),_<0)throw new Error("Supplied ufixed is negative");return a("uint256",_*BigInt(2)**BigInt(f[1]))}else if(u.startsWith("fixed"))return f=s(u),a("int256",i(c)*BigInt(2)**BigInt(f[1]))}throw new Error("Unsupported or invalid type: "+u)}function o(u){return u==="string"||u==="bytes"||r(u)==="dynamic"}function l(u){return u.lastIndexOf("]")===u.length-1}function h(u,c){var f=[],_=[],g=32*u.length;for(var m in u){var b=e(u[m]),v=c[m],S=a(b,v);o(b)?(f.push(a("uint256",g)),_.push(S),g+=S.length):f.push(S)}return Buffer.concat(f.concat(_))}function p(u,c){if(u.length!==c.length)throw new Error("Number of types are not matching the values");for(var f,_,g=[],m=0;m<u.length;m++){var b=e(u[m]),v=c[m];if(b==="bytes")g.push(v);else if(b==="string")g.push(new Buffer(v,"utf8"));else if(b==="bool")g.push(new Buffer(v?"01":"00","hex"));else if(b==="address")g.push(t.setLength(v,20));else if(b.startsWith("bytes")){if(f=n(b),f<1||f>32)throw new Error("Invalid bytes<N> width: "+f);g.push(t.setLengthRight(v,f))}else if(b.startsWith("uint")){if(f=n(b),f%8||f<8||f>256)throw new Error("Invalid uint<N> width: "+f);_=i(v);const S=t.bitLengthFromBigInt(_);if(S>f)throw new Error("Supplied uint exceeds width: "+f+" vs "+S);g.push(t.bufferBEFromBigInt(_,f/8))}else if(b.startsWith("int")){if(f=n(b),f%8||f<8||f>256)throw new Error("Invalid int<N> width: "+f);_=i(v);const S=t.bitLengthFromBigInt(_);if(S>f)throw new Error("Supplied int exceeds width: "+f+" vs "+S);const H=t.twosFromBigInt(_,f);g.push(t.bufferBEFromBigInt(H,f/8))}else throw new Error("Unsupported or invalid type: "+b)}return Buffer.concat(g)}function d(u,c){return t.keccak(p(u,c))}return Ee={rawEncode:h,solidityPack:p,soliditySHA3:d},Ee}var Ie,tt;function On(){if(tt)return Ie;tt=1;const t=jt(),e=Dn(),n={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"]},s={encodeData(i,a,o,l=!0){const h=["bytes32"],p=[this.hashType(i,o)];if(l){const d=(u,c,f)=>{if(o[c]!==void 0)return["bytes32",f==null?"0x0000000000000000000000000000000000000000000000000000000000000000":t.keccak(this.encodeData(c,f,o,l))];if(f===void 0)throw new Error(`missing value for field ${u} of type ${c}`);if(c==="bytes")return["bytes32",t.keccak(f)];if(c==="string")return typeof f=="string"&&(f=Buffer.from(f,"utf8")),["bytes32",t.keccak(f)];if(c.lastIndexOf("]")===c.length-1){const _=c.slice(0,c.lastIndexOf("[")),g=f.map(m=>d(u,_,m));return["bytes32",t.keccak(e.rawEncode(g.map(([m])=>m),g.map(([,m])=>m)))]}return[c,f]};for(const u of o[i]){const[c,f]=d(u.name,u.type,a[u.name]);h.push(c),p.push(f)}}else for(const d of o[i]){let u=a[d.name];if(u!==void 0)if(d.type==="bytes")h.push("bytes32"),u=t.keccak(u),p.push(u);else if(d.type==="string")h.push("bytes32"),typeof u=="string"&&(u=Buffer.from(u,"utf8")),u=t.keccak(u),p.push(u);else if(o[d.type]!==void 0)h.push("bytes32"),u=t.keccak(this.encodeData(d.type,u,o,l)),p.push(u);else{if(d.type.lastIndexOf("]")===d.type.length-1)throw new Error("Arrays currently unimplemented in encodeData");h.push(d.type),p.push(u)}}return e.rawEncode(h,p)},encodeType(i,a){let o="",l=this.findTypeDependencies(i,a).filter(h=>h!==i);l=[i].concat(l.sort());for(const h of l){if(!a[h])throw new Error("No type definition specified: "+h);o+=h+"("+a[h].map(({name:d,type:u})=>u+" "+d).join(",")+")"}return o},findTypeDependencies(i,a,o=[]){if(i=i.match(/^\w*/)[0],o.includes(i)||a[i]===void 0)return o;o.push(i);for(const l of a[i])for(const h of this.findTypeDependencies(l.type,a,o))!o.includes(h)&&o.push(h);return o},hashStruct(i,a,o,l=!0){return t.keccak(this.encodeData(i,a,o,l))},hashType(i,a){return t.keccak(this.encodeType(i,a))},sanitizeData(i){const a={};for(const o in n.properties)i[o]&&(a[o]=i[o]);return a.types&&(a.types=Object.assign({EIP712Domain:[]},a.types)),a},hash(i,a=!0){const o=this.sanitizeData(i),l=[Buffer.from("1901","hex")];return l.push(this.hashStruct("EIP712Domain",o.domain,o.types,a)),o.primaryType!=="EIP712Domain"&&l.push(this.hashStruct(o.primaryType,o.message,o.types,a)),t.keccak(Buffer.concat(l))}};Ie={TYPED_MESSAGE_SCHEMA:n,TypedDataUtils:s,hashForSignTypedDataLegacy:function(i){return r(i.data)},hashForSignTypedData_v3:function(i){return s.hash(i.data,!1)},hashForSignTypedData_v4:function(i){return s.hash(i.data)}};function r(i){const a=new Error("Expect argument to be non-empty array");if(typeof i!="object"||!i.length)throw a;const o=i.map(function(p){return p.type==="bytes"?t.toBuffer(p.value):p.value}),l=i.map(function(p){return p.type}),h=i.map(function(p){if(!p.name)throw a;return p.type+" "+p.name});return e.soliditySHA3(["bytes32","bytes32"],[e.soliditySHA3(new Array(i.length).fill("string"),h),e.soliditySHA3(l,o)])}return Ie}var Un=On();const ie=an(Un),jn="walletUsername",Me="Addresses",Wn="AppVersion";function x(t){return t.errorMessage!==void 0}class Bn{constructor(e){this.secret=e}async encrypt(e){const n=this.secret;if(n.length!==64)throw Error("secret must be 256 bits");const s=crypto.getRandomValues(new Uint8Array(12)),r=await crypto.subtle.importKey("raw",ae(n),{name:"aes-gcm"},!1,["encrypt","decrypt"]),i=new TextEncoder,a=await window.crypto.subtle.encrypt({name:"AES-GCM",iv:s},r,i.encode(e)),o=16,l=a.slice(a.byteLength-o),h=a.slice(0,a.byteLength-o),p=new Uint8Array(l),d=new Uint8Array(h),u=new Uint8Array([...s,...p,...d]);return Ue(u)}async decrypt(e){const n=this.secret;if(n.length!==64)throw Error("secret must be 256 bits");return new Promise((s,r)=>{(async function(){const i=await crypto.subtle.importKey("raw",ae(n),{name:"aes-gcm"},!1,["encrypt","decrypt"]),a=ae(e),o=a.slice(0,12),l=a.slice(12,28),h=a.slice(28),p=new Uint8Array([...h,...l]),d={name:"AES-GCM",iv:new Uint8Array(o)};try{const u=await window.crypto.subtle.decrypt(d,i,p),c=new TextDecoder;s(c.decode(u))}catch(u){r(u)}})()})}}class qn{constructor(e,n,s){this.linkAPIUrl=e,this.sessionId=n;const r=`${n}:${s}`;this.auth=`Basic ${btoa(r)}`}async markUnseenEventsAsSeen(e){return Promise.all(e.map(n=>fetch(`${this.linkAPIUrl}/events/${n.eventId}/seen`,{method:"POST",headers:{Authorization:this.auth}}))).catch(n=>console.error("Unabled to mark event as failed:",n))}async fetchUnseenEvents(){var e;const n=await fetch(`${this.linkAPIUrl}/events?unseen=true`,{headers:{Authorization:this.auth}});if(n.ok){const{events:s,error:r}=await n.json();if(r)throw new Error(`Check unseen events failed: ${r}`);const i=(e=s==null?void 0:s.filter(a=>a.event==="Web3Response").map(a=>({type:"Event",sessionId:this.sessionId,eventId:a.id,event:a.event,data:a.data})))!==null&&e!==void 0?e:[];return this.markUnseenEventsAsSeen(i),i}throw new Error(`Check unseen events failed: ${n.status}`)}}var D;(function(t){t[t.DISCONNECTED=0]="DISCONNECTED",t[t.CONNECTING=1]="CONNECTING",t[t.CONNECTED=2]="CONNECTED"})(D||(D={}));class Kn{setConnectionStateListener(e){this.connectionStateListener=e}setIncomingDataListener(e){this.incomingDataListener=e}constructor(e,n=WebSocket){this.WebSocketClass=n,this.webSocket=null,this.pendingData=[],this.url=e.replace(/^http/,"ws")}async connect(){if(this.webSocket)throw new Error("webSocket object is not null");return new Promise((e,n)=>{var s;let r;try{this.webSocket=r=new this.WebSocketClass(this.url)}catch(i){n(i);return}(s=this.connectionStateListener)===null||s===void 0||s.call(this,D.CONNECTING),r.onclose=i=>{var a;this.clearWebSocket(),n(new Error(`websocket error ${i.code}: ${i.reason}`)),(a=this.connectionStateListener)===null||a===void 0||a.call(this,D.DISCONNECTED)},r.onopen=i=>{var a;e(),(a=this.connectionStateListener)===null||a===void 0||a.call(this,D.CONNECTED),this.pendingData.length>0&&([...this.pendingData].forEach(l=>this.sendData(l)),this.pendingData=[])},r.onmessage=i=>{var a,o;if(i.data==="h")(a=this.incomingDataListener)===null||a===void 0||a.call(this,{type:"Heartbeat"});else try{const l=JSON.parse(i.data);(o=this.incomingDataListener)===null||o===void 0||o.call(this,l)}catch{}}})}disconnect(){var e;const{webSocket:n}=this;if(n){this.clearWebSocket(),(e=this.connectionStateListener)===null||e===void 0||e.call(this,D.DISCONNECTED),this.connectionStateListener=void 0,this.incomingDataListener=void 0;try{n.close()}catch{}}}sendData(e){const{webSocket:n}=this;if(!n){this.pendingData.push(e),this.connect();return}n.send(e)}clearWebSocket(){const{webSocket:e}=this;e&&(this.webSocket=null,e.onclose=null,e.onerror=null,e.onmessage=null,e.onopen=null)}}const nt=1e4,Hn=6e4;class zn{constructor({session:e,linkAPIUrl:n,listener:s}){this.destroyed=!1,this.lastHeartbeatResponse=0,this.nextReqId=T(1),this._connected=!1,this._linked=!1,this.shouldFetchUnseenEventsOnConnect=!1,this.requestResolutions=new Map,this.handleSessionMetadataUpdated=i=>{if(!i)return;new Map([["__destroyed",this.handleDestroyed],["EthereumAddress",this.handleAccountUpdated],["WalletUsername",this.handleWalletUsernameUpdated],["AppVersion",this.handleAppVersionUpdated],["ChainId",o=>i.JsonRpcUrl&&this.handleChainUpdated(o,i.JsonRpcUrl)]]).forEach((o,l)=>{const h=i[l];h!==void 0&&o(h)})},this.handleDestroyed=i=>{var a;i==="1"&&((a=this.listener)===null||a===void 0||a.resetAndReload())},this.handleAccountUpdated=async i=>{var a;const o=await this.cipher.decrypt(i);(a=this.listener)===null||a===void 0||a.accountUpdated(o)},this.handleMetadataUpdated=async(i,a)=>{var o;const l=await this.cipher.decrypt(a);(o=this.listener)===null||o===void 0||o.metadataUpdated(i,l)},this.handleWalletUsernameUpdated=async i=>{this.handleMetadataUpdated(jn,i)},this.handleAppVersionUpdated=async i=>{this.handleMetadataUpdated(Wn,i)},this.handleChainUpdated=async(i,a)=>{var o;const l=await this.cipher.decrypt(i),h=await this.cipher.decrypt(a);(o=this.listener)===null||o===void 0||o.chainUpdated(l,h)},this.session=e,this.cipher=new Bn(e.secret),this.listener=s;const r=new Kn(`${n}/rpc`,WebSocket);r.setConnectionStateListener(async i=>{let a=!1;switch(i){case D.DISCONNECTED:if(!this.destroyed){const o=async()=>{await new Promise(l=>setTimeout(l,5e3)),this.destroyed||r.connect().catch(()=>{o()})};o()}break;case D.CONNECTED:a=await this.handleConnected(),this.updateLastHeartbeat(),setInterval(()=>{this.heartbeat()},nt),this.shouldFetchUnseenEventsOnConnect&&this.fetchUnseenEventsAPI();break;case D.CONNECTING:break}this.connected!==a&&(this.connected=a)}),r.setIncomingDataListener(i=>{var a;switch(i.type){case"Heartbeat":this.updateLastHeartbeat();return;case"IsLinkedOK":case"Linked":{const o=i.type==="IsLinkedOK"?i.linked:void 0;this.linked=o||i.onlineGuests>0;break}case"GetSessionConfigOK":case"SessionConfigUpdated":{this.handleSessionMetadataUpdated(i.metadata);break}case"Event":{this.handleIncomingEvent(i);break}}i.id!==void 0&&((a=this.requestResolutions.get(i.id))===null||a===void 0||a(i))}),this.ws=r,this.http=new qn(n,e.id,e.key)}connect(){if(this.destroyed)throw new Error("instance is destroyed");this.ws.connect()}async destroy(){this.destroyed||(await this.makeRequest({type:"SetSessionConfig",id:T(this.nextReqId++),sessionId:this.session.id,metadata:{__destroyed:"1"}},{timeout:1e3}),this.destroyed=!0,this.ws.disconnect(),this.listener=void 0)}get connected(){return this._connected}set connected(e){this._connected=e}get linked(){return this._linked}set linked(e){var n,s;this._linked=e,e&&((n=this.onceLinked)===null||n===void 0||n.call(this)),(s=this.listener)===null||s===void 0||s.linkedUpdated(e)}setOnceLinked(e){return new Promise(n=>{this.linked?e().then(n):this.onceLinked=()=>{e().then(n),this.onceLinked=void 0}})}async handleIncomingEvent(e){var n;if(e.type!=="Event"||e.event!=="Web3Response")return;const s=await this.cipher.decrypt(e.data),r=JSON.parse(s);if(r.type!=="WEB3_RESPONSE")return;const{id:i,response:a}=r;(n=this.listener)===null||n===void 0||n.handleWeb3ResponseMessage(i,a)}async checkUnseenEvents(){if(!this.connected){this.shouldFetchUnseenEventsOnConnect=!0;return}await new Promise(e=>setTimeout(e,250));try{await this.fetchUnseenEventsAPI()}catch(e){console.error("Unable to check for unseen events",e)}}async fetchUnseenEventsAPI(){this.shouldFetchUnseenEventsOnConnect=!1,(await this.http.fetchUnseenEvents()).forEach(n=>this.handleIncomingEvent(n))}async publishEvent(e,n,s=!1){const r=await this.cipher.encrypt(JSON.stringify(Object.assign(Object.assign({},n),{origin:location.origin,location:location.href,relaySource:"coinbaseWalletExtension"in window&&window.coinbaseWalletExtension?"injected_sdk":"sdk"}))),i={type:"PublishEvent",id:T(this.nextReqId++),sessionId:this.session.id,event:e,data:r,callWebhook:s};return this.setOnceLinked(async()=>{const a=await this.makeRequest(i);if(a.type==="Fail")throw new Error(a.error||"failed to publish event");return a.eventId})}sendData(e){this.ws.sendData(JSON.stringify(e))}updateLastHeartbeat(){this.lastHeartbeatResponse=Date.now()}heartbeat(){if(Date.now()-this.lastHeartbeatResponse>nt*2){this.ws.disconnect();return}try{this.ws.sendData("h")}catch{}}async makeRequest(e,n={timeout:Hn}){const s=e.id;this.sendData(e);let r;return Promise.race([new Promise((i,a)=>{r=window.setTimeout(()=>{a(new Error(`request ${s} timed out`))},n.timeout)}),new Promise(i=>{this.requestResolutions.set(s,a=>{clearTimeout(r),i(a),this.requestResolutions.delete(s)})})])}async handleConnected(){return(await this.makeRequest({type:"HostSession",id:T(this.nextReqId++),sessionId:this.session.id,sessionKey:this.session.key})).type==="Fail"?!1:(this.sendData({type:"IsLinked",id:T(this.nextReqId++),sessionId:this.session.id}),this.sendData({type:"GetSessionConfig",id:T(this.nextReqId++),sessionId:this.session.id}),!0)}}class Fn{constructor(){this._nextRequestId=0,this.callbacks=new Map}makeRequestId(){this._nextRequestId=(this._nextRequestId+1)%2147483647;const e=this._nextRequestId,n=Tt(e.toString(16));return this.callbacks.get(n)&&this.callbacks.delete(n),e}}function $n(t,e,n,s){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,n,s);const r=BigInt(32),i=BigInt(4294967295),a=Number(n>>r&i),o=Number(n&i),l=s?4:0,h=s?0:4;t.setUint32(e+l,a,s),t.setUint32(e+h,o,s)}const Gn=(t,e,n)=>t&e^~t&n,Yn=(t,e,n)=>t&e^t&n^e&n;class Vn extends dn{constructor(e,n,s,r){super(),this.blockLen=e,this.outputLen=n,this.padOffset=s,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=me(this.buffer)}update(e){$e(this);const{view:n,buffer:s,blockLen:r}=this;e=ln(e);const i=e.length;for(let a=0;a<i;){const o=Math.min(r-this.pos,i-a);if(o===r){const l=me(e);for(;r<=i-a;a+=r)this.process(l,a);continue}s.set(e.subarray(a,a+o),this.pos),this.pos+=o,a+=o,this.pos===r&&(this.process(n,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){$e(this),un(e,this),this.finished=!0;const{buffer:n,view:s,blockLen:r,isLE:i}=this;let{pos:a}=this;n[a++]=128,this.buffer.subarray(a).fill(0),this.padOffset>r-a&&(this.process(s,0),a=0);for(let d=a;d<r;d++)n[d]=0;$n(s,r-8,BigInt(this.length*8),i),this.process(s,0);const o=me(e),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const h=l/4,p=this.get();if(h>p.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<h;d++)o.setUint32(4*d,p[d],i)}digest(){const{buffer:e,outputLen:n}=this;this.digestInto(e);const s=e.slice(0,n);return this.destroy(),s}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:n,buffer:s,length:r,finished:i,destroyed:a,pos:o}=this;return e.length=r,e.pos=o,e.finished=i,e.destroyed=a,r%n&&e.buffer.set(s),e}}const Jn=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),j=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),W=new Uint32Array(64);class Qn extends Vn{constructor(){super(64,32,8,!1),this.A=j[0]|0,this.B=j[1]|0,this.C=j[2]|0,this.D=j[3]|0,this.E=j[4]|0,this.F=j[5]|0,this.G=j[6]|0,this.H=j[7]|0}get(){const{A:e,B:n,C:s,D:r,E:i,F:a,G:o,H:l}=this;return[e,n,s,r,i,a,o,l]}set(e,n,s,r,i,a,o,l){this.A=e|0,this.B=n|0,this.C=s|0,this.D=r|0,this.E=i|0,this.F=a|0,this.G=o|0,this.H=l|0}process(e,n){for(let d=0;d<16;d++,n+=4)W[d]=e.getUint32(n,!1);for(let d=16;d<64;d++){const u=W[d-15],c=W[d-2],f=P(u,7)^P(u,18)^u>>>3,_=P(c,17)^P(c,19)^c>>>10;W[d]=_+W[d-7]+f+W[d-16]|0}let{A:s,B:r,C:i,D:a,E:o,F:l,G:h,H:p}=this;for(let d=0;d<64;d++){const u=P(o,6)^P(o,11)^P(o,25),c=p+u+Gn(o,l,h)+Jn[d]+W[d]|0,_=(P(s,2)^P(s,13)^P(s,22))+Yn(s,r,i)|0;p=h,h=l,l=o,o=a+c|0,a=i,i=r,r=s,s=c+_|0}s=s+this.A|0,r=r+this.B|0,i=i+this.C|0,a=a+this.D|0,o=o+this.E|0,l=l+this.F|0,h=h+this.G|0,p=p+this.H|0,this.set(s,r,i,a,o,l,h,p)}roundClean(){W.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const Zn=hn(()=>new Qn),st="session:id",it="session:secret",rt="session:linked";class F{constructor(e,n,s,r=!1){this.storage=e,this.id=n,this.secret=s,this.key=fn(Zn(`${n}, ${s} WalletLink`)),this._linked=!!r}static create(e){const n=q(16),s=q(32);return new F(e,n,s).save()}static load(e){const n=e.getItem(st),s=e.getItem(rt),r=e.getItem(it);return n&&r?new F(e,n,r,s==="1"):null}get linked(){return this._linked}set linked(e){this._linked=e,this.persistLinked()}save(){return this.storage.setItem(st,this.id),this.storage.setItem(it,this.secret),this.persistLinked(),this}persistLinked(){this.storage.setItem(rt,this._linked?"1":"0")}}function Xn(){try{return window.frameElement!==null}catch{return!1}}function es(){try{return Xn()&&window.top?window.top.location:window.location}catch{return window.location}}function ts(){var t;return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test((t=window==null?void 0:window.navigator)===null||t===void 0?void 0:t.userAgent)}function Wt(){var t,e;return(e=(t=window==null?void 0:window.matchMedia)===null||t===void 0?void 0:t.call(window,"(prefers-color-scheme: dark)").matches)!==null&&e!==void 0?e:!1}const ns='@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}';function Bt(){const t=document.createElement("style");t.type="text/css",t.appendChild(document.createTextNode(ns)),document.documentElement.appendChild(t)}var fe,k,qt,K,at,Kt,Ht,zt,qe,Pe,Re,te={},Ft=[],ss=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,pe=Array.isArray;function O(t,e){for(var n in e)t[n]=e[n];return t}function Ke(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function y(t,e,n){var s,r,i,a={};for(i in e)i=="key"?s=e[i]:i=="ref"?r=e[i]:a[i]=e[i];if(arguments.length>2&&(a.children=arguments.length>3?fe.call(arguments,2):n),typeof t=="function"&&t.defaultProps!=null)for(i in t.defaultProps)a[i]==null&&(a[i]=t.defaultProps[i]);return oe(t,a,s,r,null)}function oe(t,e,n,s,r){var i={type:t,props:e,key:n,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:r??++qt,__i:-1,__u:0};return r==null&&k.vnode!=null&&k.vnode(i),i}function ge(t){return t.children}function ce(t,e){this.props=t,this.context=e}function $(t,e){if(e==null)return t.__?$(t.__,t.__i+1):null;for(var n;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null)return n.__e;return typeof t.type=="function"?$(t):null}function $t(t){var e,n;if((t=t.__)!=null&&t.__c!=null){for(t.__e=t.__c.base=null,e=0;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null){t.__e=t.__c.base=n.__e;break}return $t(t)}}function ot(t){(!t.__d&&(t.__d=!0)&&K.push(t)&&!le.__r++||at!=k.debounceRendering)&&((at=k.debounceRendering)||Kt)(le)}function le(){for(var t,e,n,s,r,i,a,o=1;K.length;)K.length>o&&K.sort(Ht),t=K.shift(),o=K.length,t.__d&&(n=void 0,r=(s=(e=t).__v).__e,i=[],a=[],e.__P&&((n=O({},s)).__v=s.__v+1,k.vnode&&k.vnode(n),He(e.__P,n,s,e.__n,e.__P.namespaceURI,32&s.__u?[r]:null,i,r??$(s),!!(32&s.__u),a),n.__v=s.__v,n.__.__k[n.__i]=n,Vt(i,n,a),n.__e!=r&&$t(n)));le.__r=0}function Gt(t,e,n,s,r,i,a,o,l,h,p){var d,u,c,f,_,g,m=s&&s.__k||Ft,b=e.length;for(l=is(n,e,m,l,b),d=0;d<b;d++)(c=n.__k[d])!=null&&(u=c.__i==-1?te:m[c.__i]||te,c.__i=d,g=He(t,c,u,r,i,a,o,l,h,p),f=c.__e,c.ref&&u.ref!=c.ref&&(u.ref&&ze(u.ref,null,c),p.push(c.ref,c.__c||f,c)),_==null&&f!=null&&(_=f),4&c.__u||u.__k===c.__k?l=Yt(c,l,t):typeof c.type=="function"&&g!==void 0?l=g:f&&(l=f.nextSibling),c.__u&=-7);return n.__e=_,l}function is(t,e,n,s,r){var i,a,o,l,h,p=n.length,d=p,u=0;for(t.__k=new Array(r),i=0;i<r;i++)(a=e[i])!=null&&typeof a!="boolean"&&typeof a!="function"?(l=i+u,(a=t.__k[i]=typeof a=="string"||typeof a=="number"||typeof a=="bigint"||a.constructor==String?oe(null,a,null,null,null):pe(a)?oe(ge,{children:a},null,null,null):a.constructor==null&&a.__b>0?oe(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):a).__=t,a.__b=t.__b+1,o=null,(h=a.__i=rs(a,n,l,d))!=-1&&(d--,(o=n[h])&&(o.__u|=2)),o==null||o.__v==null?(h==-1&&(r>p?u--:r<p&&u++),typeof a.type!="function"&&(a.__u|=4)):h!=l&&(h==l-1?u--:h==l+1?u++:(h>l?u--:u++,a.__u|=4))):t.__k[i]=null;if(d)for(i=0;i<p;i++)(o=n[i])!=null&&!(2&o.__u)&&(o.__e==s&&(s=$(o)),Qt(o,o));return s}function Yt(t,e,n){var s,r;if(typeof t.type=="function"){for(s=t.__k,r=0;s&&r<s.length;r++)s[r]&&(s[r].__=t,e=Yt(s[r],e,n));return e}t.__e!=e&&(e&&t.type&&!n.contains(e)&&(e=$(t)),n.insertBefore(t.__e,e||null),e=t.__e);do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function rs(t,e,n,s){var r,i,a=t.key,o=t.type,l=e[n];if(l===null&&t.key==null||l&&a==l.key&&o==l.type&&!(2&l.__u))return n;if(s>(l!=null&&!(2&l.__u)?1:0))for(r=n-1,i=n+1;r>=0||i<e.length;){if(r>=0){if((l=e[r])&&!(2&l.__u)&&a==l.key&&o==l.type)return r;r--}if(i<e.length){if((l=e[i])&&!(2&l.__u)&&a==l.key&&o==l.type)return i;i++}}return-1}function ct(t,e,n){e[0]=="-"?t.setProperty(e,n??""):t[e]=n==null?"":typeof n!="number"||ss.test(e)?n:n+"px"}function re(t,e,n,s,r){var i;e:if(e=="style")if(typeof n=="string")t.style.cssText=n;else{if(typeof s=="string"&&(t.style.cssText=s=""),s)for(e in s)n&&e in n||ct(t.style,e,"");if(n)for(e in n)s&&n[e]==s[e]||ct(t.style,e,n[e])}else if(e[0]=="o"&&e[1]=="n")i=e!=(e=e.replace(zt,"$1")),e=e.toLowerCase()in t||e=="onFocusOut"||e=="onFocusIn"?e.toLowerCase().slice(2):e.slice(2),t.l||(t.l={}),t.l[e+i]=n,n?s?n.u=s.u:(n.u=qe,t.addEventListener(e,i?Re:Pe,i)):t.removeEventListener(e,i?Re:Pe,i);else{if(r=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in t)try{t[e]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&e[4]!="-"?t.removeAttribute(e):t.setAttribute(e,e=="popover"&&n==1?"":n))}}function dt(t){return function(e){if(this.l){var n=this.l[e.type+t];if(e.t==null)e.t=qe++;else if(e.t<n.u)return;return n(k.event?k.event(e):e)}}}function He(t,e,n,s,r,i,a,o,l,h){var p,d,u,c,f,_,g,m,b,v,S,H,G,Fe,se,Y,_e,M=e.type;if(e.constructor!=null)return null;128&n.__u&&(l=!!(32&n.__u),i=[o=e.__e=n.__e]),(p=k.__b)&&p(e);e:if(typeof M=="function")try{if(m=e.props,b="prototype"in M&&M.prototype.render,v=(p=M.contextType)&&s[p.__c],S=p?v?v.props.value:p.__:s,n.__c?g=(d=e.__c=n.__c).__=d.__E:(b?e.__c=d=new M(m,S):(e.__c=d=new ce(m,S),d.constructor=M,d.render=os),v&&v.sub(d),d.props=m,d.state||(d.state={}),d.context=S,d.__n=s,u=d.__d=!0,d.__h=[],d._sb=[]),b&&d.__s==null&&(d.__s=d.state),b&&M.getDerivedStateFromProps!=null&&(d.__s==d.state&&(d.__s=O({},d.__s)),O(d.__s,M.getDerivedStateFromProps(m,d.__s))),c=d.props,f=d.state,d.__v=e,u)b&&M.getDerivedStateFromProps==null&&d.componentWillMount!=null&&d.componentWillMount(),b&&d.componentDidMount!=null&&d.__h.push(d.componentDidMount);else{if(b&&M.getDerivedStateFromProps==null&&m!==c&&d.componentWillReceiveProps!=null&&d.componentWillReceiveProps(m,S),!d.__e&&d.shouldComponentUpdate!=null&&d.shouldComponentUpdate(m,d.__s,S)===!1||e.__v==n.__v){for(e.__v!=n.__v&&(d.props=m,d.state=d.__s,d.__d=!1),e.__e=n.__e,e.__k=n.__k,e.__k.some(function(V){V&&(V.__=e)}),H=0;H<d._sb.length;H++)d.__h.push(d._sb[H]);d._sb=[],d.__h.length&&a.push(d);break e}d.componentWillUpdate!=null&&d.componentWillUpdate(m,d.__s,S),b&&d.componentDidUpdate!=null&&d.__h.push(function(){d.componentDidUpdate(c,f,_)})}if(d.context=S,d.props=m,d.__P=t,d.__e=!1,G=k.__r,Fe=0,b){for(d.state=d.__s,d.__d=!1,G&&G(e),p=d.render(d.props,d.state,d.context),se=0;se<d._sb.length;se++)d.__h.push(d._sb[se]);d._sb=[]}else do d.__d=!1,G&&G(e),p=d.render(d.props,d.state,d.context),d.state=d.__s;while(d.__d&&++Fe<25);d.state=d.__s,d.getChildContext!=null&&(s=O(O({},s),d.getChildContext())),b&&!u&&d.getSnapshotBeforeUpdate!=null&&(_=d.getSnapshotBeforeUpdate(c,f)),Y=p,p!=null&&p.type===ge&&p.key==null&&(Y=Jt(p.props.children)),o=Gt(t,pe(Y)?Y:[Y],e,n,s,r,i,a,o,l,h),d.base=e.__e,e.__u&=-161,d.__h.length&&a.push(d),g&&(d.__E=d.__=null)}catch(V){if(e.__v=null,l||i!=null)if(V.then){for(e.__u|=l?160:128;o&&o.nodeType==8&&o.nextSibling;)o=o.nextSibling;i[i.indexOf(o)]=null,e.__e=o}else for(_e=i.length;_e--;)Ke(i[_e]);else e.__e=n.__e,e.__k=n.__k;k.__e(V,e,n)}else i==null&&e.__v==n.__v?(e.__k=n.__k,e.__e=n.__e):o=e.__e=as(n.__e,e,n,s,r,i,a,l,h);return(p=k.diffed)&&p(e),128&e.__u?void 0:o}function Vt(t,e,n){for(var s=0;s<n.length;s++)ze(n[s],n[++s],n[++s]);k.__c&&k.__c(e,t),t.some(function(r){try{t=r.__h,r.__h=[],t.some(function(i){i.call(r)})}catch(i){k.__e(i,r.__v)}})}function Jt(t){return typeof t!="object"||t==null||t.__b&&t.__b>0?t:pe(t)?t.map(Jt):O({},t)}function as(t,e,n,s,r,i,a,o,l){var h,p,d,u,c,f,_,g=n.props,m=e.props,b=e.type;if(b=="svg"?r="http://www.w3.org/2000/svg":b=="math"?r="http://www.w3.org/1998/Math/MathML":r||(r="http://www.w3.org/1999/xhtml"),i!=null){for(h=0;h<i.length;h++)if((c=i[h])&&"setAttribute"in c==!!b&&(b?c.localName==b:c.nodeType==3)){t=c,i[h]=null;break}}if(t==null){if(b==null)return document.createTextNode(m);t=document.createElementNS(r,b,m.is&&m),o&&(k.__m&&k.__m(e,i),o=!1),i=null}if(b==null)g===m||o&&t.data==m||(t.data=m);else{if(i=i&&fe.call(t.childNodes),g=n.props||te,!o&&i!=null)for(g={},h=0;h<t.attributes.length;h++)g[(c=t.attributes[h]).name]=c.value;for(h in g)if(c=g[h],h!="children"){if(h=="dangerouslySetInnerHTML")d=c;else if(!(h in m)){if(h=="value"&&"defaultValue"in m||h=="checked"&&"defaultChecked"in m)continue;re(t,h,null,c,r)}}for(h in m)c=m[h],h=="children"?u=c:h=="dangerouslySetInnerHTML"?p=c:h=="value"?f=c:h=="checked"?_=c:o&&typeof c!="function"||g[h]===c||re(t,h,c,g[h],r);if(p)o||d&&(p.__html==d.__html||p.__html==t.innerHTML)||(t.innerHTML=p.__html),e.__k=[];else if(d&&(t.innerHTML=""),Gt(e.type=="template"?t.content:t,pe(u)?u:[u],e,n,s,b=="foreignObject"?"http://www.w3.org/1999/xhtml":r,i,a,i?i[0]:n.__k&&$(n,0),o,l),i!=null)for(h=i.length;h--;)Ke(i[h]);o||(h="value",b=="progress"&&f==null?t.removeAttribute("value"):f!=null&&(f!==t[h]||b=="progress"&&!f||b=="option"&&f!=g[h])&&re(t,h,f,g[h],r),h="checked",_!=null&&_!=t[h]&&re(t,h,_,g[h],r))}return t}function ze(t,e,n){try{if(typeof t=="function"){var s=typeof t.__u=="function";s&&t.__u(),s&&e==null||(t.__u=t(e))}else t.current=e}catch(r){k.__e(r,n)}}function Qt(t,e,n){var s,r;if(k.unmount&&k.unmount(t),(s=t.ref)&&(s.current&&s.current!=t.__e||ze(s,null,e)),(s=t.__c)!=null){if(s.componentWillUnmount)try{s.componentWillUnmount()}catch(i){k.__e(i,e)}s.base=s.__P=null}if(s=t.__k)for(r=0;r<s.length;r++)s[r]&&Qt(s[r],e,n||typeof t.type!="function");n||Ke(t.__e),t.__c=t.__=t.__e=void 0}function os(t,e,n){return this.constructor(t,n)}function Le(t,e,n){var s,r,i,a;e==document&&(e=document.documentElement),k.__&&k.__(t,e),r=(s=!1)?null:e.__k,i=[],a=[],He(e,t=e.__k=y(ge,null,[t]),r||te,te,e.namespaceURI,r?null:e.firstChild?fe.call(e.childNodes):null,i,r?r.__e:e.firstChild,s,a),Vt(i,t,a)}fe=Ft.slice,k={__e:function(t,e,n,s){for(var r,i,a;e=e.__;)if((r=e.__c)&&!r.__)try{if((i=r.constructor)&&i.getDerivedStateFromError!=null&&(r.setState(i.getDerivedStateFromError(t)),a=r.__d),r.componentDidCatch!=null&&(r.componentDidCatch(t,s||{}),a=r.__d),a)return r.__E=r}catch(o){t=o}throw t}},qt=0,ce.prototype.setState=function(t,e){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=O({},this.state),typeof t=="function"&&(t=t(O({},n),this.props)),t&&O(n,t),t!=null&&this.__v&&(e&&this._sb.push(e),ot(this))},ce.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),ot(this))},ce.prototype.render=ge,K=[],Kt=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Ht=function(t,e){return t.__v.__b-e.__v.__b},le.__r=0,zt=/(PointerCapture)$|Capture$/i,qe=0,Pe=dt(!1),Re=dt(!0);var ue,I,Se,lt,Te=0,Zt=[],C=k,ut=C.__b,ht=C.__r,ft=C.diffed,pt=C.__c,gt=C.unmount,_t=C.__;function Xt(t,e){C.__h&&C.__h(I,t,Te||e),Te=0;var n=I.__H||(I.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function mt(t){return Te=1,cs(en,t)}function cs(t,e,n){var s=Xt(ue++,2);if(s.t=t,!s.__c&&(s.__=[en(void 0,e),function(o){var l=s.__N?s.__N[0]:s.__[0],h=s.t(l,o);l!==h&&(s.__N=[h,s.__[1]],s.__c.setState({}))}],s.__c=I,!I.__f)){var r=function(o,l,h){if(!s.__c.__H)return!0;var p=s.__c.__H.__.filter(function(u){return!!u.__c});if(p.every(function(u){return!u.__N}))return!i||i.call(this,o,l,h);var d=s.__c.props!==o;return p.forEach(function(u){if(u.__N){var c=u.__[0];u.__=u.__N,u.__N=void 0,c!==u.__[0]&&(d=!0)}}),i&&i.call(this,o,l,h)||d};I.__f=!0;var i=I.shouldComponentUpdate,a=I.componentWillUpdate;I.componentWillUpdate=function(o,l,h){if(this.__e){var p=i;i=void 0,r(o,l,h),i=p}a&&a.call(this,o,l,h)},I.shouldComponentUpdate=r}return s.__N||s.__}function ds(t,e){var n=Xt(ue++,3);!C.__s&&hs(n.__H,e)&&(n.__=t,n.u=e,I.__H.__h.push(n))}function ls(){for(var t;t=Zt.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(de),t.__H.__h.forEach(Ne),t.__H.__h=[]}catch(e){t.__H.__h=[],C.__e(e,t.__v)}}C.__b=function(t){I=null,ut&&ut(t)},C.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),_t&&_t(t,e)},C.__r=function(t){ht&&ht(t),ue=0;var e=(I=t.__c).__H;e&&(Se===I?(e.__h=[],I.__h=[],e.__.forEach(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(e.__h.forEach(de),e.__h.forEach(Ne),e.__h=[],ue=0)),Se=I},C.diffed=function(t){ft&&ft(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(Zt.push(e)!==1&&lt===C.requestAnimationFrame||((lt=C.requestAnimationFrame)||us)(ls)),e.__H.__.forEach(function(n){n.u&&(n.__H=n.u),n.u=void 0})),Se=I=null},C.__c=function(t,e){e.some(function(n){try{n.__h.forEach(de),n.__h=n.__h.filter(function(s){return!s.__||Ne(s)})}catch(s){e.some(function(r){r.__h&&(r.__h=[])}),e=[],C.__e(s,n.__v)}}),pt&&pt(t,e)},C.unmount=function(t){gt&&gt(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.forEach(function(s){try{de(s)}catch(r){e=r}}),n.__H=void 0,e&&C.__e(e,n.__v))};var bt=typeof requestAnimationFrame=="function";function us(t){var e,n=function(){clearTimeout(s),bt&&cancelAnimationFrame(e),setTimeout(t)},s=setTimeout(n,100);bt&&(e=requestAnimationFrame(n))}function de(t){var e=I,n=t.__c;typeof n=="function"&&(t.__c=void 0,n()),I=e}function Ne(t){var e=I;t.__c=t.__(),I=e}function hs(t,e){return!t||t.length!==e.length||e.some(function(n,s){return n!==t[s]})}function en(t,e){return typeof e=="function"?e(t):e}const fs=".-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}",ps="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEuNDkyIDEwLjQxOWE4LjkzIDguOTMgMCAwMTguOTMtOC45M2gxMS4xNjNhOC45MyA4LjkzIDAgMDE4LjkzIDguOTN2MTEuMTYzYTguOTMgOC45MyAwIDAxLTguOTMgOC45M0gxMC40MjJhOC45MyA4LjkzIDAgMDEtOC45My04LjkzVjEwLjQxOXoiIGZpbGw9IiMxNjUyRjAiLz48cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTEwLjQxOSAwSDIxLjU4QzI3LjMzNSAwIDMyIDQuNjY1IDMyIDEwLjQxOVYyMS41OEMzMiAyNy4zMzUgMjcuMzM1IDMyIDIxLjU4MSAzMkgxMC40MkM0LjY2NSAzMiAwIDI3LjMzNSAwIDIxLjU4MVYxMC40MkMwIDQuNjY1IDQuNjY1IDAgMTAuNDE5IDB6bTAgMS40ODhhOC45MyA4LjkzIDAgMDAtOC45MyA4LjkzdjExLjE2M2E4LjkzIDguOTMgMCAwMDguOTMgOC45M0gyMS41OGE4LjkzIDguOTMgMCAwMDguOTMtOC45M1YxMC40MmE4LjkzIDguOTMgMCAwMC04LjkzLTguOTNIMTAuNDJ6IiBmaWxsPSIjZmZmIi8+PHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xNS45OTggMjYuMDQ5Yy01LjU0OSAwLTEwLjA0Ny00LjQ5OC0xMC4wNDctMTAuMDQ3IDAtNS41NDggNC40OTgtMTAuMDQ2IDEwLjA0Ny0xMC4wNDYgNS41NDggMCAxMC4wNDYgNC40OTggMTAuMDQ2IDEwLjA0NiAwIDUuNTQ5LTQuNDk4IDEwLjA0Ny0xMC4wNDYgMTAuMDQ3eiIgZmlsbD0iI2ZmZiIvPjxwYXRoIGQ9Ik0xMi43NjIgMTQuMjU0YzAtLjgyMi42NjctMS40ODkgMS40ODktMS40ODloMy40OTdjLjgyMiAwIDEuNDg4LjY2NiAxLjQ4OCAxLjQ4OXYzLjQ5N2MwIC44MjItLjY2NiAxLjQ4OC0xLjQ4OCAxLjQ4OGgtMy40OTdhMS40ODggMS40ODggMCAwMS0xLjQ4OS0xLjQ4OHYtMy40OTh6IiBmaWxsPSIjMTY1MkYwIi8+PC9zdmc+",gs="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIiIGhlaWdodD0iMTIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDYuNzV2LTEuNWwtMS43Mi0uNTdjLS4wOC0uMjctLjE5LS41Mi0uMzItLjc3bC44MS0xLjYyLTEuMDYtMS4wNi0xLjYyLjgxYy0uMjQtLjEzLS41LS4yNC0uNzctLjMyTDYuNzUgMGgtMS41bC0uNTcgMS43MmMtLjI3LjA4LS41My4xOS0uNzcuMzJsLTEuNjItLjgxLTEuMDYgMS4wNi44MSAxLjYyYy0uMTMuMjQtLjI0LjUtLjMyLjc3TDAgNS4yNXYxLjVsMS43Mi41N2MuMDguMjcuMTkuNTMuMzIuNzdsLS44MSAxLjYyIDEuMDYgMS4wNiAxLjYyLS44MWMuMjQuMTMuNS4yMy43Ny4zMkw1LjI1IDEyaDEuNWwuNTctMS43MmMuMjctLjA4LjUyLS4xOS43Ny0uMzJsMS42Mi44MSAxLjA2LTEuMDYtLjgxLTEuNjJjLjEzLS4yNC4yMy0uNS4zMi0uNzdMMTIgNi43NXpNNiA4LjVhMi41IDIuNSAwIDAxMC01IDIuNSAyLjUgMCAwMTAgNXoiIGZpbGw9IiMwNTBGMTkiLz48L3N2Zz4=";class _s{constructor(){this.items=new Map,this.nextItemKey=0,this.root=null,this.darkMode=Wt()}attach(e){this.root=document.createElement("div"),this.root.className="-cbwsdk-snackbar-root",e.appendChild(this.root),this.render()}presentItem(e){const n=this.nextItemKey++;return this.items.set(n,e),this.render(),()=>{this.items.delete(n),this.render()}}clear(){this.items.clear(),this.render()}render(){this.root&&Le(y("div",null,y(tn,{darkMode:this.darkMode},Array.from(this.items.entries()).map(([e,n])=>y(ms,Object.assign({},n,{key:e}))))),this.root)}}const tn=t=>y("div",{class:Q("-cbwsdk-snackbar-container")},y("style",null,fs),y("div",{class:"-cbwsdk-snackbar"},t.children)),ms=({autoExpand:t,message:e,menuItems:n})=>{const[s,r]=mt(!0),[i,a]=mt(t??!1);ds(()=>{const l=[window.setTimeout(()=>{r(!1)},1),window.setTimeout(()=>{a(!0)},1e4)];return()=>{l.forEach(window.clearTimeout)}});const o=()=>{a(!i)};return y("div",{class:Q("-cbwsdk-snackbar-instance",s&&"-cbwsdk-snackbar-instance-hidden",i&&"-cbwsdk-snackbar-instance-expanded")},y("div",{class:"-cbwsdk-snackbar-instance-header",onClick:o},y("img",{src:ps,class:"-cbwsdk-snackbar-instance-header-cblogo"})," ",y("div",{class:"-cbwsdk-snackbar-instance-header-message"},e),y("div",{class:"-gear-container"},!i&&y("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},y("circle",{cx:"12",cy:"12",r:"12",fill:"#F5F7F8"})),y("img",{src:gs,class:"-gear-icon",title:"Expand"}))),n&&n.length>0&&y("div",{class:"-cbwsdk-snackbar-instance-menu"},n.map((l,h)=>y("div",{class:Q("-cbwsdk-snackbar-instance-menu-item",l.isRed&&"-cbwsdk-snackbar-instance-menu-item-is-red"),onClick:l.onClick,key:h},y("svg",{width:l.svgWidth,height:l.svgHeight,viewBox:"0 0 10 11",fill:"none",xmlns:"http://www.w3.org/2000/svg"},y("path",{"fill-rule":l.defaultFillRule,"clip-rule":l.defaultClipRule,d:l.path,fill:"#AAAAAA"})),y("span",{class:Q("-cbwsdk-snackbar-instance-menu-item-info",l.isRed&&"-cbwsdk-snackbar-instance-menu-item-info-is-red")},l.info)))))};class bs{constructor(){this.attached=!1,this.snackbar=new _s}attach(){if(this.attached)throw new Error("Coinbase Wallet SDK UI is already attached");const e=document.documentElement,n=document.createElement("div");n.className="-cbwsdk-css-reset",e.appendChild(n),this.snackbar.attach(n),this.attached=!0,Bt()}showConnecting(e){let n;return e.isUnlinkedErrorState?n={autoExpand:!0,message:"Connection lost",menuItems:[{isRed:!1,info:"Reset connection",svgWidth:"10",svgHeight:"11",path:"M5.00008 0.96875C6.73133 0.96875 8.23758 1.94375 9.00008 3.375L10.0001 2.375V5.5H9.53133H7.96883H6.87508L7.80633 4.56875C7.41258 3.3875 6.31258 2.53125 5.00008 2.53125C3.76258 2.53125 2.70633 3.2875 2.25633 4.36875L0.812576 3.76875C1.50008 2.125 3.11258 0.96875 5.00008 0.96875ZM2.19375 6.43125C2.5875 7.6125 3.6875 8.46875 5 8.46875C6.2375 8.46875 7.29375 7.7125 7.74375 6.63125L9.1875 7.23125C8.5 8.875 6.8875 10.0312 5 10.0312C3.26875 10.0312 1.7625 9.05625 1 7.625L0 8.625V5.5H0.46875H2.03125H3.125L2.19375 6.43125Z",defaultFillRule:"evenodd",defaultClipRule:"evenodd",onClick:e.onResetConnection}]}:n={message:"Confirm on phone",menuItems:[{isRed:!0,info:"Cancel transaction",svgWidth:"11",svgHeight:"11",path:"M10.3711 1.52346L9.21775 0.370117L5.37109 4.21022L1.52444 0.370117L0.371094 1.52346L4.2112 5.37012L0.371094 9.21677L1.52444 10.3701L5.37109 6.53001L9.21775 10.3701L10.3711 9.21677L6.53099 5.37012L10.3711 1.52346Z",defaultFillRule:"inherit",defaultClipRule:"inherit",onClick:e.onCancel},{isRed:!1,info:"Reset connection",svgWidth:"10",svgHeight:"11",path:"M5.00008 0.96875C6.73133 0.96875 8.23758 1.94375 9.00008 3.375L10.0001 2.375V5.5H9.53133H7.96883H6.87508L7.80633 4.56875C7.41258 3.3875 6.31258 2.53125 5.00008 2.53125C3.76258 2.53125 2.70633 3.2875 2.25633 4.36875L0.812576 3.76875C1.50008 2.125 3.11258 0.96875 5.00008 0.96875ZM2.19375 6.43125C2.5875 7.6125 3.6875 8.46875 5 8.46875C6.2375 8.46875 7.29375 7.7125 7.74375 6.63125L9.1875 7.23125C8.5 8.875 6.8875 10.0312 5 10.0312C3.26875 10.0312 1.7625 9.05625 1 7.625L0 8.625V5.5H0.46875H2.03125H3.125L2.19375 6.43125Z",defaultFillRule:"evenodd",defaultClipRule:"evenodd",onClick:e.onResetConnection}]},this.snackbar.presentItem(n)}}const ws=".-cbwsdk-css-reset .-cbwsdk-redirect-dialog-backdrop{position:fixed;top:0;left:0;right:0;bottom:0;transition:opacity .25s;background-color:rgba(10,11,13,.5)}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-backdrop-hidden{opacity:0}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box{display:block;position:fixed;top:50%;left:50%;transform:translate(-50%, -50%);padding:20px;border-radius:8px;background-color:#fff;color:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box p{display:block;font-weight:400;font-size:14px;line-height:20px;padding-bottom:12px;color:#5b636e}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box button{appearance:none;border:none;background:none;color:#0052ff;padding:0;text-decoration:none;display:block;font-weight:600;font-size:16px;line-height:24px}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.dark{background-color:#0a0b0d;color:#fff}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.dark button{color:#0052ff}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.light{background-color:#fff;color:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.light button{color:#0052ff}";class ys{constructor(){this.root=null,this.darkMode=Wt()}attach(){const e=document.documentElement;this.root=document.createElement("div"),this.root.className="-cbwsdk-css-reset",e.appendChild(this.root),Bt()}present(e){this.render(e)}clear(){this.render(null)}render(e){this.root&&(Le(null,this.root),e&&Le(y(ks,Object.assign({},e,{onDismiss:()=>{this.clear()},darkMode:this.darkMode})),this.root))}}const ks=({title:t,buttonText:e,darkMode:n,onButtonClick:s,onDismiss:r})=>{const i=n?"dark":"light";return y(tn,{darkMode:n},y("div",{class:"-cbwsdk-redirect-dialog"},y("style",null,ws),y("div",{class:"-cbwsdk-redirect-dialog-backdrop",onClick:r}),y("div",{class:Q("-cbwsdk-redirect-dialog-box",i)},y("p",null,t),y("button",{onClick:s},e))))},vs="https://keys.coinbase.com/connect",Es="http://rpc.wallet.coinbase.com",wt="https://www.walletlink.org",Is="https://go.cb-w.com/walletlink";class yt{constructor(){this.attached=!1,this.redirectDialog=new ys}attach(){if(this.attached)throw new Error("Coinbase Wallet SDK UI is already attached");this.redirectDialog.attach(),this.attached=!0}redirectToCoinbaseWallet(e){const n=new URL(Is);n.searchParams.append("redirect_url",es().href),e&&n.searchParams.append("wl_url",e);const s=document.createElement("a");s.target="cbw-opener",s.href=n.href,s.rel="noreferrer noopener",s.click()}openCoinbaseWalletDeeplink(e){this.redirectDialog.present({title:"Redirecting to Coinbase Wallet...",buttonText:"Open",onButtonClick:()=>{this.redirectToCoinbaseWallet(e)}}),setTimeout(()=>{this.redirectToCoinbaseWallet(e)},99)}showConnecting(e){return()=>{this.redirectDialog.clear()}}}class N{constructor(e){this.chainCallbackParams={chainId:"",jsonRpcUrl:""},this.isMobileWeb=ts(),this.linkedUpdated=i=>{this.isLinked=i;const a=this.storage.getItem(Me);if(i&&(this._session.linked=i),this.isUnlinkedErrorState=!1,a){const o=a.split(" "),l=this.storage.getItem("IsStandaloneSigning")==="true";o[0]!==""&&!i&&this._session.linked&&!l&&(this.isUnlinkedErrorState=!0)}},this.metadataUpdated=(i,a)=>{this.storage.setItem(i,a)},this.chainUpdated=(i,a)=>{this.chainCallbackParams.chainId===i&&this.chainCallbackParams.jsonRpcUrl===a||(this.chainCallbackParams={chainId:i,jsonRpcUrl:a},this.chainCallback&&this.chainCallback(a,Number.parseInt(i,10)))},this.accountUpdated=i=>{this.accountsCallback&&this.accountsCallback([i]),N.accountRequestCallbackIds.size>0&&(Array.from(N.accountRequestCallbackIds.values()).forEach(a=>{this.invokeCallback(a,{method:"requestEthereumAccounts",result:[i]})}),N.accountRequestCallbackIds.clear())},this.resetAndReload=this.resetAndReload.bind(this),this.linkAPIUrl=e.linkAPIUrl,this.storage=e.storage,this.metadata=e.metadata,this.accountsCallback=e.accountsCallback,this.chainCallback=e.chainCallback;const{session:n,ui:s,connection:r}=this.subscribe();this._session=n,this.connection=r,this.relayEventManager=new Fn,this.ui=s,this.ui.attach()}subscribe(){const e=F.load(this.storage)||F.create(this.storage),{linkAPIUrl:n}=this,s=new zn({session:e,linkAPIUrl:n,listener:this}),r=this.isMobileWeb?new yt:new bs;return s.connect(),{session:e,ui:r,connection:s}}resetAndReload(){this.connection.destroy().then(()=>{const e=F.load(this.storage);(e==null?void 0:e.id)===this._session.id&&L.clearAll(),document.location.reload()}).catch(e=>{})}signEthereumTransaction(e){return this.sendRequest({method:"signEthereumTransaction",params:{fromAddress:e.fromAddress,toAddress:e.toAddress,weiValue:R(e.weiValue),data:Z(e.data,!0),nonce:e.nonce,gasPriceInWei:e.gasPriceInWei?R(e.gasPriceInWei):null,maxFeePerGas:e.gasPriceInWei?R(e.gasPriceInWei):null,maxPriorityFeePerGas:e.gasPriceInWei?R(e.gasPriceInWei):null,gasLimit:e.gasLimit?R(e.gasLimit):null,chainId:e.chainId,shouldSubmit:!1}})}signAndSubmitEthereumTransaction(e){return this.sendRequest({method:"signEthereumTransaction",params:{fromAddress:e.fromAddress,toAddress:e.toAddress,weiValue:R(e.weiValue),data:Z(e.data,!0),nonce:e.nonce,gasPriceInWei:e.gasPriceInWei?R(e.gasPriceInWei):null,maxFeePerGas:e.maxFeePerGas?R(e.maxFeePerGas):null,maxPriorityFeePerGas:e.maxPriorityFeePerGas?R(e.maxPriorityFeePerGas):null,gasLimit:e.gasLimit?R(e.gasLimit):null,chainId:e.chainId,shouldSubmit:!0}})}submitEthereumTransaction(e,n){return this.sendRequest({method:"submitEthereumTransaction",params:{signedTransaction:Z(e,!0),chainId:n}})}getWalletLinkSession(){return this._session}sendRequest(e){let n=null;const s=q(8),r=i=>{this.publishWeb3RequestCanceledEvent(s),this.handleErrorResponse(s,e.method,i),n==null||n()};return new Promise((i,a)=>{n=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:r,onResetConnection:this.resetAndReload}),this.relayEventManager.callbacks.set(s,o=>{if(n==null||n(),x(o))return a(new Error(o.errorMessage));i(o)}),this.publishWeb3RequestEvent(s,e)})}publishWeb3RequestEvent(e,n){const s={type:"WEB3_REQUEST",id:e,request:n};this.publishEvent("Web3Request",s,!0).then(r=>{}).catch(r=>{this.handleWeb3ResponseMessage(s.id,{method:n.method,errorMessage:r.message})}),this.isMobileWeb&&this.openCoinbaseWalletDeeplink(n.method)}openCoinbaseWalletDeeplink(e){if(this.ui instanceof yt)switch(e){case"requestEthereumAccounts":case"switchEthereumChain":return;default:window.addEventListener("blur",()=>{window.addEventListener("focus",()=>{this.connection.checkUnseenEvents()},{once:!0})},{once:!0}),this.ui.openCoinbaseWalletDeeplink();break}}publishWeb3RequestCanceledEvent(e){const n={type:"WEB3_REQUEST_CANCELED",id:e};this.publishEvent("Web3RequestCanceled",n,!1).then()}publishEvent(e,n,s){return this.connection.publishEvent(e,n,s)}handleWeb3ResponseMessage(e,n){if(n.method==="requestEthereumAccounts"){N.accountRequestCallbackIds.forEach(s=>this.invokeCallback(s,n)),N.accountRequestCallbackIds.clear();return}this.invokeCallback(e,n)}handleErrorResponse(e,n,s){var r;const i=(r=s==null?void 0:s.message)!==null&&r!==void 0?r:"Unspecified error message.";this.handleWeb3ResponseMessage(e,{method:n,errorMessage:i})}invokeCallback(e,n){const s=this.relayEventManager.callbacks.get(e);s&&(s(n),this.relayEventManager.callbacks.delete(e))}requestEthereumAccounts(){const{appName:e,appLogoUrl:n}=this.metadata,s={method:"requestEthereumAccounts",params:{appName:e,appLogoUrl:n}},r=q(8);return new Promise((i,a)=>{this.relayEventManager.callbacks.set(r,o=>{if(x(o))return a(new Error(o.errorMessage));i(o)}),N.accountRequestCallbackIds.add(r),this.publishWeb3RequestEvent(r,s)})}watchAsset(e,n,s,r,i,a){const o={method:"watchAsset",params:{type:e,options:{address:n,symbol:s,decimals:r,image:i},chainId:a}};let l=null;const h=q(8),p=d=>{this.publishWeb3RequestCanceledEvent(h),this.handleErrorResponse(h,o.method,d),l==null||l()};return l=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:p,onResetConnection:this.resetAndReload}),new Promise((d,u)=>{this.relayEventManager.callbacks.set(h,c=>{if(l==null||l(),x(c))return u(new Error(c.errorMessage));d(c)}),this.publishWeb3RequestEvent(h,o)})}addEthereumChain(e,n,s,r,i,a){const o={method:"addEthereumChain",params:{chainId:e,rpcUrls:n,blockExplorerUrls:r,chainName:i,iconUrls:s,nativeCurrency:a}};let l=null;const h=q(8),p=d=>{this.publishWeb3RequestCanceledEvent(h),this.handleErrorResponse(h,o.method,d),l==null||l()};return l=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:p,onResetConnection:this.resetAndReload}),new Promise((d,u)=>{this.relayEventManager.callbacks.set(h,c=>{if(l==null||l(),x(c))return u(new Error(c.errorMessage));d(c)}),this.publishWeb3RequestEvent(h,o)})}switchEthereumChain(e,n){const s={method:"switchEthereumChain",params:Object.assign({chainId:e},{address:n})};let r=null;const i=q(8),a=o=>{this.publishWeb3RequestCanceledEvent(i),this.handleErrorResponse(i,s.method,o),r==null||r()};return r=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:a,onResetConnection:this.resetAndReload}),new Promise((o,l)=>{this.relayEventManager.callbacks.set(i,h=>{if(r==null||r(),x(h)&&h.errorCode)return l(w.provider.custom({code:h.errorCode,message:"Unrecognized chain ID. Try adding the chain using addEthereumChain first."}));if(x(h))return l(new Error(h.errorMessage));o(h)}),this.publishWeb3RequestEvent(i,s)})}}N.accountRequestCallbackIds=new Set;const kt="DefaultChainId",vt="DefaultJsonRpcUrl";class nn{constructor(e){this._relay=null,this._addresses=[],this.metadata=e.metadata,this._storage=new L("walletlink",wt),this.callback=e.callback||null;const n=this._storage.getItem(Me);if(n){const s=n.split(" ");s[0]!==""&&(this._addresses=s.map(r=>U(r)))}this.initializeRelay()}getSession(){const e=this.initializeRelay(),{id:n,secret:s}=e.getWalletLinkSession();return{id:n,secret:s}}async handshake(){await this._eth_requestAccounts()}get selectedAddress(){return this._addresses[0]||void 0}get jsonRpcUrl(){var e;return(e=this._storage.getItem(vt))!==null&&e!==void 0?e:void 0}set jsonRpcUrl(e){this._storage.setItem(vt,e)}updateProviderInfo(e,n){var s;this.jsonRpcUrl=e;const r=this.getChainId();this._storage.setItem(kt,n.toString(10)),X(n)!==r&&((s=this.callback)===null||s===void 0||s.call(this,"chainChanged",B(n)))}async watchAsset(e){const n=Array.isArray(e)?e[0]:e;if(!n.type)throw w.rpc.invalidParams("Type is required");if((n==null?void 0:n.type)!=="ERC20")throw w.rpc.invalidParams(`Asset of type '${n.type}' is not supported`);if(!(n!=null&&n.options))throw w.rpc.invalidParams("Options are required");if(!(n!=null&&n.options.address))throw w.rpc.invalidParams("Address is required");const s=this.getChainId(),{address:r,symbol:i,image:a,decimals:o}=n.options,h=await this.initializeRelay().watchAsset(n.type,r,i,o,a,s==null?void 0:s.toString());return x(h)?!1:!!h.result}async addEthereumChain(e){var n,s;const r=e[0];if(((n=r.rpcUrls)===null||n===void 0?void 0:n.length)===0)throw w.rpc.invalidParams("please pass in at least 1 rpcUrl");if(!r.chainName||r.chainName.trim()==="")throw w.rpc.invalidParams("chainName is a required field");if(!r.nativeCurrency)throw w.rpc.invalidParams("nativeCurrency is a required field");const i=Number.parseInt(r.chainId,16);if(i===this.getChainId())return!1;const a=this.initializeRelay(),{rpcUrls:o=[],blockExplorerUrls:l=[],chainName:h,iconUrls:p=[],nativeCurrency:d}=r,u=await a.addEthereumChain(i.toString(),o,p,l,h,d);if(x(u))return!1;if(((s=u.result)===null||s===void 0?void 0:s.isApproved)===!0)return this.updateProviderInfo(o[0],i),null;throw w.rpc.internal("unable to add ethereum chain")}async switchEthereumChain(e){const n=e[0],s=Number.parseInt(n.chainId,16),i=await this.initializeRelay().switchEthereumChain(s.toString(10),this.selectedAddress||void 0);if(x(i))throw i;const a=i.result;return a.isApproved&&a.rpcUrl.length>0&&this.updateProviderInfo(a.rpcUrl,s),null}async cleanup(){this.callback=null,this._relay&&this._relay.resetAndReload(),this._storage.clear()}_setAddresses(e,n){var s;if(!Array.isArray(e))throw new Error("addresses is not an array");const r=e.map(i=>U(i));JSON.stringify(r)!==JSON.stringify(this._addresses)&&(this._addresses=r,(s=this.callback)===null||s===void 0||s.call(this,"accountsChanged",r),this._storage.setItem(Me,r.join(" ")))}async request(e){const n=e.params||[];switch(e.method){case"eth_accounts":return[...this._addresses];case"eth_coinbase":return this.selectedAddress||null;case"net_version":return this.getChainId().toString(10);case"eth_chainId":return B(this.getChainId());case"eth_requestAccounts":return this._eth_requestAccounts();case"eth_ecRecover":case"personal_ecRecover":return this.ecRecover(e);case"personal_sign":return this.personalSign(e);case"eth_signTransaction":return this._eth_signTransaction(n);case"eth_sendRawTransaction":return this._eth_sendRawTransaction(n);case"eth_sendTransaction":return this._eth_sendTransaction(n);case"eth_signTypedData_v1":case"eth_signTypedData_v3":case"eth_signTypedData_v4":case"eth_signTypedData":return this.signTypedData(e);case"wallet_addEthereumChain":return this.addEthereumChain(n);case"wallet_switchEthereumChain":return this.switchEthereumChain(n);case"wallet_watchAsset":return this.watchAsset(n);default:if(!this.jsonRpcUrl)throw w.rpc.internal("No RPC URL set for chain");return Be(e,this.jsonRpcUrl)}}_ensureKnownAddress(e){const n=U(e);if(!this._addresses.map(r=>U(r)).includes(n))throw new Error("Unknown Ethereum address")}_prepareTransactionParams(e){const n=e.from?U(e.from):this.selectedAddress;if(!n)throw new Error("Ethereum address is unavailable");this._ensureKnownAddress(n);const s=e.to?U(e.to):null,r=e.value!=null?J(e.value):BigInt(0),i=e.data?Ae(e.data):Buffer.alloc(0),a=e.nonce!=null?X(e.nonce):null,o=e.gasPrice!=null?J(e.gasPrice):null,l=e.maxFeePerGas!=null?J(e.maxFeePerGas):null,h=e.maxPriorityFeePerGas!=null?J(e.maxPriorityFeePerGas):null,p=e.gas!=null?J(e.gas):null,d=e.chainId?X(e.chainId):this.getChainId();return{fromAddress:n,toAddress:s,weiValue:r,data:i,nonce:a,gasPriceInWei:o,maxFeePerGas:l,maxPriorityFeePerGas:h,gasLimit:p,chainId:d}}async ecRecover(e){const{method:n,params:s}=e;if(!Array.isArray(s))throw w.rpc.invalidParams();const i=await this.initializeRelay().sendRequest({method:"ethereumAddressFromSignedMessage",params:{message:be(s[0]),signature:be(s[1]),addPrefix:n==="personal_ecRecover"}});if(x(i))throw i;return i.result}getChainId(){var e;return Number.parseInt((e=this._storage.getItem(kt))!==null&&e!==void 0?e:"1",10)}async _eth_requestAccounts(){var e,n;if(this._addresses.length>0)return(e=this.callback)===null||e===void 0||e.call(this,"connect",{chainId:B(this.getChainId())}),this._addresses;const r=await this.initializeRelay().requestEthereumAccounts();if(x(r))throw r;if(!r.result)throw new Error("accounts received is empty");return this._setAddresses(r.result),(n=this.callback)===null||n===void 0||n.call(this,"connect",{chainId:B(this.getChainId())}),this._addresses}async personalSign({params:e}){if(!Array.isArray(e))throw w.rpc.invalidParams();const n=e[1],s=e[0];this._ensureKnownAddress(n);const i=await this.initializeRelay().sendRequest({method:"signEthereumMessage",params:{address:U(n),message:be(s),addPrefix:!0,typedDataJson:null}});if(x(i))throw i;return i.result}async _eth_signTransaction(e){const n=this._prepareTransactionParams(e[0]||{}),r=await this.initializeRelay().signEthereumTransaction(n);if(x(r))throw r;return r.result}async _eth_sendRawTransaction(e){const n=Ae(e[0]),r=await this.initializeRelay().submitEthereumTransaction(n,this.getChainId());if(x(r))throw r;return r.result}async _eth_sendTransaction(e){const n=this._prepareTransactionParams(e[0]||{}),r=await this.initializeRelay().signAndSubmitEthereumTransaction(n);if(x(r))throw r;return r.result}async signTypedData(e){const{method:n,params:s}=e;if(!Array.isArray(s))throw w.rpc.invalidParams();const r=h=>{const p={eth_signTypedData_v1:ie.hashForSignTypedDataLegacy,eth_signTypedData_v3:ie.hashForSignTypedData_v3,eth_signTypedData_v4:ie.hashForSignTypedData_v4,eth_signTypedData:ie.hashForSignTypedData_v4};return Z(p[n]({data:kn(h)}),!0)},i=s[n==="eth_signTypedData_v1"?1:0],a=s[n==="eth_signTypedData_v1"?0:1];this._ensureKnownAddress(i);const l=await this.initializeRelay().sendRequest({method:"signEthereumMessage",params:{address:U(i),message:r(a),typedDataJson:JSON.stringify(a,null,2),addPrefix:!1}});if(x(l))throw l;return l.result}initializeRelay(){return this._relay||(this._relay=new N({linkAPIUrl:wt,storage:this._storage,metadata:this.metadata,accountsCallback:this._setAddresses.bind(this),chainCallback:this.updateProviderInfo.bind(this)})),this._relay}}const sn="SignerType",rn=new L("CBWSDK","SignerConfigurator");function Ss(){return rn.getItem(sn)}function Cs(t){rn.setItem(sn,t)}async function xs(t){const{communicator:e,metadata:n,handshakeRequest:s,callback:r}=t;Ms(e,n,r).catch(()=>{});const i={id:crypto.randomUUID(),event:"selectSignerType",data:Object.assign(Object.assign({},t.preference),{handshakeRequest:s})},{data:a}=await e.postRequestAndWaitForResponse(i);return a}function As(t){const{signerType:e,metadata:n,communicator:s,callback:r}=t;switch(e){case"scw":return new Nn({metadata:n,callback:r,communicator:s});case"walletlink":return new nn({metadata:n,callback:r})}}async function Ms(t,e,n){await t.onMessage(({event:r})=>r==="WalletLinkSessionRequest");const s=new nn({metadata:e,callback:n});t.postMessage({event:"WalletLinkUpdate",data:{session:s.getSession()}}),await s.handshake(),t.postMessage({event:"WalletLinkUpdate",data:{connected:!0}})}const Ps=`Coinbase Wallet SDK requires the Cross-Origin-Opener-Policy header to not be set to 'same-origin'. This is to ensure that the SDK can communicate with the Coinbase Smart Wallet app.

Please see https://www.smartwallet.dev/guides/tips/popup-tips#cross-origin-opener-policy for more information.`,Rs=()=>{let t;return{getCrossOriginOpenerPolicy:()=>t===void 0?"undefined":t,checkCrossOriginOpenerPolicy:async()=>{if(typeof window>"u"){t="non-browser-env";return}try{const e=`${window.location.origin}${window.location.pathname}`,n=await fetch(e,{method:"HEAD"});if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);const s=n.headers.get("Cross-Origin-Opener-Policy");t=s??"null",t==="same-origin"&&console.error(Ps)}catch(e){console.error("Error checking Cross-Origin-Opener-Policy:",e.message),t="error"}}}},{checkCrossOriginOpenerPolicy:Ls,getCrossOriginOpenerPolicy:Ts}=Rs(),Et=420,It=540;function Ns(t){const e=(window.innerWidth-Et)/2+window.screenX,n=(window.innerHeight-It)/2+window.screenY;Os(t);const s=`wallet_${crypto.randomUUID()}`,r=window.open(t,s,`width=${Et}, height=${It}, left=${e}, top=${n}`);if(r==null||r.focus(),!r)throw w.rpc.internal("Pop up window failed to open");return r}function Ds(t){t&&!t.closed&&t.close()}function Os(t){const e={sdkName:Ut,sdkVersion:ne,origin:window.location.origin,coop:Ts()};for(const[n,s]of Object.entries(e))t.searchParams.append(n,s.toString())}class Us{constructor({url:e=vs,metadata:n,preference:s}){this.popup=null,this.listeners=new Map,this.postMessage=async r=>{(await this.waitForPopupLoaded()).postMessage(r,this.url.origin)},this.postRequestAndWaitForResponse=async r=>{const i=this.onMessage(({requestId:a})=>a===r.id);return this.postMessage(r),await i},this.onMessage=async r=>new Promise((i,a)=>{const o=l=>{if(l.origin!==this.url.origin)return;const h=l.data;r(h)&&(i(h),window.removeEventListener("message",o),this.listeners.delete(o))};window.addEventListener("message",o),this.listeners.set(o,{reject:a})}),this.disconnect=()=>{Ds(this.popup),this.popup=null,this.listeners.forEach(({reject:r},i)=>{r(w.provider.userRejectedRequest("Request rejected")),window.removeEventListener("message",i)}),this.listeners.clear()},this.waitForPopupLoaded=async()=>this.popup&&!this.popup.closed?(this.popup.focus(),this.popup):(this.popup=Ns(this.url),this.onMessage(({event:r})=>r==="PopupUnload").then(this.disconnect).catch(()=>{}),this.onMessage(({event:r})=>r==="PopupLoaded").then(r=>{this.postMessage({requestId:r.id,data:{version:ne,metadata:this.metadata,preference:this.preference,location:window.location.toString()}})}).then(()=>{if(!this.popup)throw w.rpc.internal();return this.popup})),this.url=new URL(e),this.metadata=n,this.preference=s}}function js(t){const e=_n(Ws(t),{shouldIncludeStack:!0}),n=new URL("https://docs.cloud.coinbase.com/wallet-sdk/docs/errors");return n.searchParams.set("version",ne),n.searchParams.set("code",e.code.toString()),n.searchParams.set("message",e.message),Object.assign(Object.assign({},e),{docUrl:n.href})}function Ws(t){var e;if(typeof t=="string")return{message:t,code:E.rpc.internal};if(x(t)){const n=t.errorMessage,s=(e=t.errorCode)!==null&&e!==void 0?e:n.match(/(denied|rejected)/i)?E.provider.userRejectedRequest:void 0;return Object.assign(Object.assign({},t),{message:n,code:s,data:{method:t.method}})}return t}class Bs extends on{}var qs=function(t,e){var n={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(n[s]=t[s]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,s=Object.getOwnPropertySymbols(t);r<s.length;r++)e.indexOf(s[r])<0&&Object.prototype.propertyIsEnumerable.call(t,s[r])&&(n[s[r]]=t[s[r]]);return n};class Ks extends Bs{constructor(e){var{metadata:n}=e,s=e.preference,{keysUrl:r}=s,i=qs(s,["keysUrl"]);super(),this.signer=null,this.isCoinbaseWallet=!0,this.metadata=n,this.preference=i,this.communicator=new Us({url:r,metadata:n,preference:i});const a=Ss();a&&(this.signer=this.initSigner(a))}async request(e){try{if(Tn(e),!this.signer)switch(e.method){case"eth_requestAccounts":{const n=await this.requestSignerSelection(e),s=this.initSigner(n);await s.handshake(e),this.signer=s,Cs(n);break}case"wallet_sendCalls":{const n=this.initSigner("scw");await n.handshake({method:"handshake"});const s=await n.request(e);return await n.cleanup(),s}case"wallet_getCallsStatus":return Be(e,Es);case"net_version":return 1;case"eth_chainId":return B(1);default:throw w.provider.unauthorized("Must call 'eth_requestAccounts' before other methods")}return await this.signer.request(e)}catch(n){const{code:s}=n;return s===E.provider.unauthorized&&this.disconnect(),Promise.reject(js(n))}}async enable(){return console.warn('.enable() has been deprecated. Please use .request({ method: "eth_requestAccounts" }) instead.'),await this.request({method:"eth_requestAccounts"})}async disconnect(){var e;await((e=this.signer)===null||e===void 0?void 0:e.cleanup()),this.signer=null,L.clearAll(),this.emit("disconnect",w.provider.disconnected("User initiated disconnection"))}requestSignerSelection(e){return xs({communicator:this.communicator,preference:this.preference,metadata:this.metadata,handshakeRequest:e,callback:this.emit.bind(this)})}initSigner(e){return As({signerType:e,metadata:this.metadata,communicator:this.communicator,callback:this.emit.bind(this)})}}function Hs(t){if(t){if(!["all","smartWalletOnly","eoaOnly"].includes(t.options))throw new Error(`Invalid options: ${t.options}`);if(t.attribution&&t.attribution.auto!==void 0&&t.attribution.dataSuffix!==void 0)throw new Error("Attribution cannot contain both auto and dataSuffix properties")}}function zs(t){var e;const n={metadata:t.metadata,preference:t.preference};return(e=Ln(n))!==null&&e!==void 0?e:new Ks(n)}const Fs={options:"all"};function Js(t){var e;new L("CBWSDK").setItem("VERSION",ne),Ls();const s={metadata:{appName:t.appName||"Dapp",appLogoUrl:t.appLogoUrl||"",appChainIds:t.appChainIds||[]},preference:Object.assign(Fs,(e=t.preference)!==null&&e!==void 0?e:{})};Hs(s.preference);let r=null;return{getProvider:()=>(r||(r=zs(s)),r)}}export{Js as createCoinbaseWalletSDK};