1import{H as En,nz as Cn,nA as Ye,g as In,b as Sn,J as Mn,nB as ee,kB as xn}from"./index-23810fa3.js";import{s as An}from"./sha3-5db38fdd.js";import"./utils-d9c93a5f.js";const Pn=(t,e)=>{let n;switch(t){case"standard":return n=e,`data:image/svg+xml,%3Csvg width='${e}' height='${n}' viewBox='0 0 1024 1024' fill='none' xmlns='http://www.w3.org/2000/svg'%3E %3Crect width='1024' height='1024' fill='%230052FF'/%3E %3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z' fill='white'/%3E %3C/svg%3E `;case"circle":return n=e,`data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='${e}' height='${n}' viewBox='0 0 999.81 999.81'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052fe;%7D.cls-2%7Bfill:%23fefefe;%7D.cls-3%7Bfill:%230152fe;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M655-115.9h56c.83,1.59,2.36.88,3.56,1a478,478,0,0,1,75.06,10.42C891.4-81.76,978.33-32.58,1049.19,44q116.7,126,131.94,297.61c.38,4.14-.34,8.53,1.78,12.45v59c-1.58.84-.91,2.35-1,3.56a482.05,482.05,0,0,1-10.38,74.05c-24,106.72-76.64,196.76-158.83,268.93s-178.18,112.82-287.2,122.6c-4.83.43-9.86-.25-14.51,1.77H654c-1-1.68-2.69-.91-4.06-1a496.89,496.89,0,0,1-105.9-18.59c-93.54-27.42-172.78-77.59-236.91-150.94Q199.34,590.1,184.87,426.58c-.47-5.19.25-10.56-1.77-15.59V355c1.68-1,.91-2.7,1-4.06a498.12,498.12,0,0,1,18.58-105.9c26-88.75,72.64-164.9,140.6-227.57q126-116.27,297.21-131.61C645.32-114.57,650.35-113.88,655-115.9Zm377.92,500c0-192.44-156.31-349.49-347.56-350.15-194.13-.68-350.94,155.13-352.29,347.42-1.37,194.55,155.51,352.1,348.56,352.47C876.15,734.23,1032.93,577.84,1032.93,384.11Z' transform='translate(-183.1 115.9)'/%3E%3Cpath class='cls-2' d='M1032.93,384.11c0,193.73-156.78,350.12-351.29,349.74-193-.37-349.93-157.92-348.56-352.47C334.43,189.09,491.24,33.28,685.37,34,876.62,34.62,1032.94,191.67,1032.93,384.11ZM683,496.81q43.74,0,87.48,0c15.55,0,25.32-9.72,25.33-25.21q0-87.48,0-175c0-15.83-9.68-25.46-25.59-25.46H595.77c-15.88,0-25.57,9.64-25.58,25.46q0,87.23,0,174.45c0,16.18,9.59,25.7,25.84,25.71Z' transform='translate(-183.1 115.9)'/%3E%3Cpath class='cls-3' d='M683,496.81H596c-16.25,0-25.84-9.53-25.84-25.71q0-87.23,0-174.45c0-15.82,9.7-25.46,25.58-25.46H770.22c15.91,0,25.59,9.63,25.59,25.46q0,87.47,0,175c0,15.49-9.78,25.2-25.33,25.21Q726.74,496.84,683,496.81Z' transform='translate(-183.1 115.9)'/%3E%3C/svg%3E`;case"text":return n=(.1*e).toFixed(2),`data:image/svg+xml,%3Csvg width='${e}' height='${n}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 528.15 53.64'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052ff;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3ECoinbase_Wordmark_SubBrands_ALL%3C/title%3E%3Cpath class='cls-1' d='M164.45,15a15,15,0,0,0-11.74,5.4V0h-8.64V52.92h8.5V48a15,15,0,0,0,11.88,5.62c10.37,0,18.21-8.21,18.21-19.3S174.67,15,164.45,15Zm-1.3,30.67c-6.19,0-10.73-4.83-10.73-11.31S157,23,163.22,23s10.66,4.82,10.66,11.37S169.34,45.65,163.15,45.65Zm83.31-14.91-6.34-.93c-3-.43-5.18-1.44-5.18-3.82,0-2.59,2.8-3.89,6.62-3.89,4.18,0,6.84,1.8,7.42,4.76h8.35c-.94-7.49-6.7-11.88-15.55-11.88-9.15,0-15.2,4.68-15.2,11.3,0,6.34,4,10,12,11.16l6.33.94c3.1.43,4.83,1.65,4.83,4,0,2.95-3,4.17-7.2,4.17-5.12,0-8-2.09-8.43-5.25h-8.49c.79,7.27,6.48,12.38,16.84,12.38,9.44,0,15.7-4.32,15.7-11.74C258.12,35.28,253.58,31.82,246.46,30.74Zm-27.65-2.3c0-8.06-4.9-13.46-15.27-13.46-9.79,0-15.26,5-16.34,12.6h8.57c.43-3,2.73-5.4,7.63-5.4,4.39,0,6.55,1.94,6.55,4.32,0,3.09-4,3.88-8.85,4.39-6.63.72-14.84,3-14.84,11.66,0,6.7,5,11,12.89,11,6.19,0,10.08-2.59,12-6.7.28,3.67,3,6.05,6.84,6.05h5v-7.7h-4.25Zm-8.5,9.36c0,5-4.32,8.64-9.57,8.64-3.24,0-6-1.37-6-4.25,0-3.67,4.39-4.68,8.42-5.11s6-1.22,7.13-2.88ZM281.09,15c-11.09,0-19.23,8.35-19.23,19.36,0,11.6,8.72,19.3,19.37,19.3,9,0,16.06-5.33,17.86-12.89h-9c-1.3,3.31-4.47,5.19-8.71,5.19-5.55,0-9.72-3.46-10.66-9.51H299.3V33.12C299.3,22.46,291.53,15,281.09,15Zm-9.87,15.26c1.37-5.18,5.26-7.7,9.72-7.7,4.9,0,8.64,2.8,9.51,7.7ZM19.3,23a9.84,9.84,0,0,1,9.5,7h9.14c-1.65-8.93-9-15-18.57-15A19,19,0,0,0,0,34.34c0,11.09,8.28,19.3,19.37,19.3,9.36,0,16.85-6,18.5-15H28.8a9.75,9.75,0,0,1-9.43,7.06c-6.27,0-10.66-4.83-10.66-11.31S13,23,19.3,23Zm41.11-8A19,19,0,0,0,41,34.34c0,11.09,8.28,19.3,19.37,19.3A19,19,0,0,0,79.92,34.27C79.92,23.33,71.64,15,60.41,15Zm.07,30.67c-6.19,0-10.73-4.83-10.73-11.31S54.22,23,60.41,23s10.8,4.89,10.8,11.37S66.67,45.65,60.48,45.65ZM123.41,15c-5.62,0-9.29,2.3-11.45,5.54V15.7h-8.57V52.92H112V32.69C112,27,115.63,23,121,23c5,0,8.06,3.53,8.06,8.64V52.92h8.64V31C137.66,21.6,132.84,15,123.41,15ZM92,.36a5.36,5.36,0,0,0-5.55,5.47,5.55,5.55,0,0,0,11.09,0A5.35,5.35,0,0,0,92,.36Zm-9.72,23h5.4V52.92h8.64V15.7
1h-14Zm298.17-7.7L366.2,52.92H372L375.29,44H392l3.33,8.88h6L386.87,15.7ZM377,39.23l6.45-17.56h.1l6.56,17.56ZM362.66,15.7l-7.88,29h-.11l-8.14-29H341l-8,28.93h-.1l-8-28.87H319L329.82,53h5.45l8.19-29.24h.11L352,53h5.66L368.1,15.7Zm135.25,0v4.86h12.32V52.92h5.6V20.56h12.32V15.7ZM467.82,52.92h25.54V48.06H473.43v-12h18.35V31.35H473.43V20.56h19.93V15.7H467.82ZM443,15.7h-5.6V52.92h24.32V48.06H443Zm-30.45,0h-5.61V52.92h24.32V48.06H412.52Z'/%3E%3C/svg%3E`;case"textWithLogo":return n=(.25*e).toFixed(2),`data:image/svg+xml,%3Csvg width='${e}' height='${n}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 308.44 77.61'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052ff;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M142.94,20.2l-7.88,29H135l-8.15-29h-5.55l-8,28.93h-.11l-8-28.87H99.27l10.84,37.27h5.44l8.2-29.24h.1l8.41,29.24h5.66L148.39,20.2Zm17.82,0L146.48,57.42h5.82l3.28-8.88h16.65l3.34,8.88h6L167.16,20.2Zm-3.44,23.52,6.45-17.55h.11l6.56,17.55ZM278.2,20.2v4.86h12.32V57.42h5.6V25.06h12.32V20.2ZM248.11,57.42h25.54V52.55H253.71V40.61h18.35V35.85H253.71V25.06h19.94V20.2H248.11ZM223.26,20.2h-5.61V57.42H242V52.55H223.26Zm-30.46,0h-5.6V57.42h24.32V52.55H192.8Zm-154,38A19.41,19.41,0,1,1,57.92,35.57H77.47a38.81,38.81,0,1,0,0,6.47H57.92A19.39,19.39,0,0,1,38.81,58.21Z'/%3E%3C/svg%3E`;case"textLight":return n=(.1*e).toFixed(2),`data:image/svg+xml,%3Csvg width='${e}' height='${n}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 528.15 53.64'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23fefefe;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3ECoinbase_Wordmark_SubBrands_ALL%3C/title%3E%3Cpath class='cls-1' d='M164.45,15a15,15,0,0,0-11.74,5.4V0h-8.64V52.92h8.5V48a15,15,0,0,0,11.88,5.62c10.37,0,18.21-8.21,18.21-19.3S174.67,15,164.45,15Zm-1.3,30.67c-6.19,0-10.73-4.83-10.73-11.31S157,23,163.22,23s10.66,4.82,10.66,11.37S169.34,45.65,163.15,45.65Zm83.31-14.91-6.34-.93c-3-.43-5.18-1.44-5.18-3.82,0-2.59,2.8-3.89,6.62-3.89,4.18,0,6.84,1.8,7.42,4.76h8.35c-.94-7.49-6.7-11.88-15.55-11.88-9.15,0-15.2,4.68-15.2,11.3,0,6.34,4,10,12,11.16l6.33.94c3.1.43,4.83,1.65,4.83,4,0,2.95-3,4.17-7.2,4.17-5.12,0-8-2.09-8.43-5.25h-8.49c.79,7.27,6.48,12.38,16.84,12.38,9.44,0,15.7-4.32,15.7-11.74C258.12,35.28,253.58,31.82,246.46,30.74Zm-27.65-2.3c0-8.06-4.9-13.46-15.27-13.46-9.79,0-15.26,5-16.34,12.6h8.57c.43-3,2.73-5.4,7.63-5.4,4.39,0,6.55,1.94,6.55,4.32,0,3.09-4,3.88-8.85,4.39-6.63.72-14.84,3-14.84,11.66,0,6.7,5,11,12.89,11,6.19,0,10.08-2.59,12-6.7.28,3.67,3,6.05,6.84,6.05h5v-7.7h-4.25Zm-8.5,9.36c0,5-4.32,8.64-9.57,8.64-3.24,0-6-1.37-6-4.25,0-3.67,4.39-4.68,8.42-5.11s6-1.22,7.13-2.88ZM281.09,15c-11.09,0-19.23,8.35-19.23,19.36,0,11.6,8.72,19.3,19.37,19.3,9,0,16.06-5.33,17.86-12.89h-9c-1.3,3.31-4.47,5.19-8.71,5.19-5.55,0-9.72-3.46-10.66-9.51H299.3V33.12C299.3,22.46,291.53,15,281.09,15Zm-9.87,15.26c1.37-5.18,5.26-7.7,9.72-7.7,4.9,0,8.64,2.8,9.51,7.7ZM19.3,23a9.84,9.84,0,0,1,9.5,7h9.14c-1.65-8.93-9-15-18.57-15A19,19,0,0,0,0,34.34c0,11.09,8.28,19.3,19.37,19.3,9.36,0,16.85-6,18.5-15H28.8a9.75,9.75,0,0,1-9.43,7.06c-6.27,0-10.66-4.83-10.66-11.31S13,23,19.3,23Zm41.11-8A19,19,0,0,0,41,34.34c0,11.09,8.28,19.3,19.37,19.3A19,19,0,0,0,79.92,34.27C79.92,23.33,71.64,15,60.41,15Zm.07,30.67c-6.19,0-10.73-4.83-10.73-11.31S54.22,23,60.41,23s10.8,4.89,10.8,11.37S66.67,45.65,60.48,45.65ZM123.41,15c-5.62,0-9.29,2.3-11.45,5.54V15.7h-8.57V52.92H112V32.69C112,27,115.63,23,121,23c5,0,8.06,3.53,8.06,8.64V52.92h8.64V31C137.66,21.6,132.84,15,123.41,15ZM92,.36a5.36,5.36,0,0,0-5.55,5.47,5.55,5.55,0,0,0,11.09,0A5.35,5.35,0,0,0,92,.36Zm-9.72,23h5.4V52.92h8.64V15.7h-14Zm298.17-7.7L366.2,52.92H372L375.29,44H392l3.33,8.88h6L386.87,15.7ZM377,39.23l6.45-17.56h.1l6.56,17.56ZM362.66,15.7l-7.88,29h-.11l-8.14-29H341l-8,28.93h-.1l-8-28.87H319L329.82,53h5.45l8.19-29.24h.11L352,53h5.66L368.1,15.7Zm135.25,0v4.86h12.32V52.92h5.6V20.56h12.32V15.7ZM467.82,52.92h25.54V48.06H473.43v-12h18.35V31.35H473.43V20.56h19.93V15.7H467.82ZM443,15.7h-5.6V52.92h24.32V48.06H443Zm-30.45,0h-5.61V52.92h24.32V48.06H412.52Z'/%3E%3C/svg%3E`;case"textWithLogoLight":return n=(.25*e).toFixed(2),`data:image/svg+xml,%3Csvg width='${e}' height='${n}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 308.44 77.61'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23fefefe;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M142.94,20.2l-7.88,29H135l-8.15-29h-5.55l-8,28.93h-.11l-8-28.87H99.27l10.84,37.27h5.44l8.2-29.24h.1l8.41,29.24h5.66L148.39,20.2Zm17.82,0L146.48,57.42h5.82l3.28-8.88h16.65l3.34,8.88h6L167.16,20.2Zm-3.44,23.52,6.45-17.55h.11l6.56,17.55ZM278.2,20.2v4.86h12.32V57.42h5.6V25.06h12.32V20.2ZM248.11,57.42h25.54V52.55H253.71V40.61h18.35V35.85H253.71V25.06h19.94V20.2H248.11ZM223.26,20.2h-5.61V57.42H242V52.55H223.26Zm-30.46,0h-5.6V57.42h24.32V52.55H192.8Zm-154,38A19.41,19.41,0,1,1,57.92,35.57H77.47a38.81,38.8
11,0,1,0,0,6.47H57.92A19.39,19.39,0,0,1,38.81,58.21Z'/%3E%3C/svg%3E`;default:return n=e,`data:image/svg+xml,%3Csvg width='${e}' height='${n}' viewBox='0 0 1024 1024' fill='none' xmlns='http://www.w3.org/2000/svg'%3E %3Crect width='1024' height='1024' fill='%230052FF'/%3E %3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z' fill='white'/%3E %3C/svg%3E `}};class P{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 i=localStorage.key(s);typeof i=="string"&&i.startsWith(e)&&n.push(i)}n.forEach(s=>localStorage.removeItem(s))}scopedKey(e){return`-${this.scope}${this.module?`:${this.module}`:""}:${e}`}static clearAll(){new P("CBWSDK").clear(),new P("walletlink").clear()}}const w={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}},Ae={"-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."}},Mt="Unspecified error message.",Ln="Unspecified server error.";function He(t,e=Mt){if(t&&Number.isInteger(t)){const n=t.toString();if(Pe(Ae,n))return Ae[n].message;if(xt(t))return Ln}return e}function Rn(t){if(!Number.isInteger(t))return!1;const e=t.toString();return!!(Ae[e]||xt(t))}function Nn(t,{shouldIncludeStack:e=!1}={}){const n={};if(t&&typeof t=="object"&&!Array.isArray(t)&&Pe(t,"code")&&Rn(t.code)){const s=t;n.code=s.code,s.message&&typeof s.message=="string"?(n.message=s.message,Pe(s,"data")&&(n.data=s.data)):(n.message=He(n.code),n.data={originalError:Je(t)})}else n.code=w.rpc.internal,n.message=Qe(t,"message")?t.message:Mt,n.data={originalError:Je(t)};return e&&(n.stack=Qe(t,"stack")?t.stack:void 0),n}function xt(t){return t>=-32099&&t<=-32e3}function Je(t){return t&&typeof t=="object"&&!Array.isArray(t)?Object.assign({},t):t}function Pe(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function Qe(t,e){return typeof t=="object"&&t!==null&&e in t&&typeof t[e]=="string"}const p={rpc:{parse:t=>M(w.rpc.parse,t),invalidRequest:t=>M(w.rpc.invalidRequest,t),invalidParams:t=>M(w.rpc.invalidParams,t),methodNotFound:t=>M(w.rpc.methodNotFound,t),internal:t=>M(w.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
1<= -32005');return M(e,t)},invalidInput:t=>M(w.rpc.invalidInput,t),resourceNotFound:t=>M(w.rpc.resourceNotFound,t),resourceUnavailable:t=>M(w.rpc.resourceUnavailable,t),transactionRejected:t=>M(w.rpc.transactionRejected,t),methodNotSupported:t=>M(w.rpc.methodNotSupported,t),limitExceeded:t=>M(w.rpc.limitExceeded,t)},provider:{userRejectedRequest:t=>F(w.provider.userRejectedRequest,t),unauthorized:t=>F(w.provider.unauthorized,t),unsupportedMethod:t=>F(w.provider.unsupportedMethod,t),disconnected:t=>F(w.provider.disconnected,t),chainDisconnected:t=>F(w.provider.chainDisconnected,t),unsupportedChain:t=>F(w.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 Lt(e,n,s)}}};function M(t,e){const[n,s]=At(e);return new Pt(t,n||He(t),s)}function F(t,e){const[n,s]=At(e);return new Lt(t,n||He(t),s)}function At(t){if(t){if(typeof t=="string")return[t];if(typeof t=="object"&&!Array.isArray(t)){const{message:e,data:n}=t;
1if(e&&typeof e!="string")throw new Error("Must specify string message.");return[e||void 0,n]}}return[]}class Pt 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 Lt extends Pt{constructor(e,n,s){if(!Tn(e))throw new Error('"code" must be an integer such that: 1000 <= code <= 4999');super(e,n,s)}}function Tn(t){return Number.isInteger(t)&&t>=1e3&&t<=4999}function We(){return t=>t}const ie=We(),Dn=We(),On=We();function D(t){return Math.floor(t)}const Rt=/^[0-9]*$/,Nt=/^[a-f0-9]*$/;function q(t){return Be(crypto.getRandomValues(new Uint8Array(t)))}function Be(t){return[...t].map(e=>e.toString(16).padStart(2,"0")).join("")}function he(t){return new Uint8Array(t.match(/.{1,2}/g).map(e=>Number.parseInt(e,16)))}function te(t,e=!1){const n=t.toString("hex");return ie(e?`0x${n}`:n)}function Ee(t){return te(Le(t),!0)}function R(t){return On(t.toString(10))}function B(t){return ie(`0x${BigInt(t).toString(16)}`)}function Tt(t){return t.startsWith("0x")||t.startsWith("0X")}function qe(t){return Tt(t)?t.slice(2):t}function Dt(t){return Tt(t)?`0x${t.slice(2)}`:`0x${t}`}function _e(t){if(typeof t!="string")return!1;const e=qe(t).toLowerCase();return Nt.test(e)}function jn(t,e=!1){if(typeof t=="string"){const n=qe(t).toLowerCase();if(Nt.test(n))return ie(e?`0x${n}`:n)}throw p.rpc.invalidParams(`"${String(t)}" is not a hexadecimal string`)}function Ke(t,e=!1){let n=jn(t,!1);return n.length%2===1&&(n=ie(`0${n}`)),e?ie(`0x${n}`):n}function W(t){if(typeof t=="string"){const e=qe(t).toLowerCase();if(_e(e)&&e.length===40)return Dn(Dt(e))}throw p.rpc.invalidParams(`Invalid Ethereum address: ${String(t)}`)}function Le(t){if(Buffer.isBuffer(t))return t;if(typeof t=="string"){if(_e(t)){const e=Ke(t,!1);return Buffer.from(e,"hex")}return Buffer.from(t,"utf8")}throw p.rpc.invalidParams(`Not binary data: ${String(t)}`)}function ne(t){if(typeof t=="number"&&Number.isInteger(t))return D(t);if(typeof t=="string"){if(Rt.test(t))return D(Number(t));if(_e(t))return D(Number(BigInt(Ke(t,!0))))}throw p.rpc.invalidParams(`Not an integer: ${String(t)}`)}function X(t){if(t!==null&&(typeof t=="bigint"||Hn(t)))return BigInt(t.toString(10));if(typeof t=="number")return BigInt(ne(t));if(typeof t=="string"){if(Rt.test(t))return BigInt(t);if(_e(t))return BigInt(Ke(t,!0))}throw p.rpc.invalidParams(`Not an integer: ${String(t)}`)}function Un(t){if(typeof t=="string")return JSON.parse(t);if(typeof t=="object")return t;throw p.rpc.invalidParams(`Not a JSON string or an object: ${String(t)}`)}function Hn(t){if(t==null||typeof t.constructor!="function")return!1;const{constructor:e}=t;return typeof e.config=="function"&&typeof e.EUCLID=="number"}function Wn(){const t=document.querySelector('link[sizes="192x192"]')||document.querySelector('link[sizes="180x180"]')||document.querySelector('link[rel="icon"]')||document.querySelector('link[rel="shortcut icon"]'),{protocol:e,host:n}=document.location,s=t?t.getAttribute("href"):null;return!s||s.startsWith("javascript:")||s.startsWith("vbscript:")?`${e}//${n}/favicon.ico`:s.startsWith("http://")||s.startsWith("https://")||s.startsWith("data:")?s:s.startsWith("//")?e+s:`${e}//${n}${s}`}async function Bn(){return crypto.subtle.generateKey({name:"ECDH",namedCurve:"P-256"},!0,["deriveKey"])}async function qn(t,e){return crypto.subtle.deriveKey({name:"ECDH",public:e},t,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"])}async function Kn(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 Vn(t,{iv:e,cipherText:n}){const s=await crypto.subtle.decrypt({name:"AES-GCM",iv:e},t,n);return new TextDecoder().decode(s)}function Ot(t){switch(t){case"public":return"spki";case"private":return"pkcs8"}}async function jt(t,e){const n=Ot(t),s=await crypto.subtle.exportKey(n,e);return Be(new Uint8Array(s))}async function Ut(t,e){const n=Ot(t),s=he(e).buffer;return await crypto.subtle.importKey(n,new Uint8Array(s),{name:"ECDH",namedCurve:"P-256"},!0,t==="private"?["deriveKey"]:[])}async function zn(t,e){const n=JSON.stringify(t,(s,i)=>{if(!(i instanceof Error))return i;const r=i;return Object.assign(Object.assign({},r.code?{code:r.code}:{}),{message:r.message})});return Kn(e,n)}async function Fn(t,e){return JSON.parse(await Vn(e,t))}const Ce={storageKey:"ownPrivateKey",keyType:"private"},Ie={storageKey:"ownPublicKey",keyType:"public"},Se={storageKey:"peerPublicKey",keyType:"public"};
1class $n{constructor(){this.storage=new P("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(Se,e),await this.loadKeysIfNeeded()}async clear(){this.ownPrivateKey=null,this.ownPublicKey=null,this.peerPublicKey=null,this.sharedSecret=null,this.storage.removeItem(Ie.storageKey),this.storage.removeItem(Ce.storageKey),this.storage.removeItem(Se.storageKey)}async generateKeyPair(){const e=await Bn();this.ownPrivateKey=e.privateKey,this.ownPublicKey=e.publicKey,await this.storeKey(Ce,e.privateKey),await this.storeKey(Ie,e.publicKey)}async loadKeysIfNeeded(){if(this.ownPrivateKey===null&&(this.ownPrivateKey=await this.loadKey(Ce)),this.ownPublicKey===null&&(this.ownPublicKey=await this.loadKey(Ie)),(this.ownPrivateKey===null||this.ownPublicKey===null)&&await this.generateKeyPair(),this.peerPublicKey===null&&(this.peerPublicKey=await this.loadKey(Se)),this.sharedSecret===null){if(this.ownPrivateKey===null||this.peerPublicKey===null)return;this.sharedSecret=await qn(this.ownPrivateKey,this.peerPublicKey)}}async loadKey(e){const n=this.storage.getItem(e.storageKey);return n?Ut(e.keyType,n):null}async storeKey(e,n){const s=await jt(e.keyType,n);this.storage.setItem(e.storageKey,s)}}function Zn(t){if(!t||!Array.isArray(t)||t.length!==1&&t.length!==2||typeof t[0]!="string"||!En(t[0]))throw p.rpc.invalidParams();if(t.length===2){if(!Array.isArray(t[1]))throw p.rpc.invalidParams();for(const e of t[1])if(typeof e!="string"||!e.startsWith("0x"))throw p.rpc.invalidParams()}}const Y="4.3.7",Ht="@coinbase/wallet-sdk";async function Ve(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":Y,"X-Cbw-Sdk-Platform":Ht}}),{result:i,error:r}=await s.json();if(r)throw r;return i}function Gn(){return globalThis.coinbaseWalletExtension}function Yn(){var t,e;try{const n=globalThis;return(e=(t=n.top)===null||t===void 0?void 0:t.ethereum)!==null&&e!==void 0?e:n.ethereum}catch{return}}function Wt({metadata:t,preference:e}){var n,s;const{appName:i,appLogoUrl:r,appChainIds:a}=t;if(e.options!=="smartWalletOnly"){const c=Gn();if(c)return(n=c.setAppInfo)===null||n===void 0||n.call(c,i,r,a,e),c}const o=Yn();if(o!=null&&o.isCoinbaseBrowser)return(s=o.setAppInfo)===null||s===void 0||s.call(o,i,r,a,e),o}function Jn(t){if(!t||typeof t!="object"||Array.isArray(t))throw p.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 p.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 p.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 p.provider.unsupportedMethod()}}const Xe="accounts",et="activeChain",tt="availableChains",nt="walletCapabilities";class Qn{constructor(e){var n,s,i;this.metadata=e.metadata,this.communicator=e.communicator,this.callback=e.callback,this.keyManager=new $n,this.storage=new P("CBWSDK","SCWStateManager"),this.accounts=(n=this.storage.loadObject(Xe))!==null&&n!==void 0?n:[],this.chain=this.storage.loadObject(et)||{id:(i=(s=e.metadata.appChainIds)===null||s===void 0?void 0:s[0])!==null&&i!==void 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 n,s,i,r;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,(i=e.params)!==null&&i!==void 0?i:{})}}
1),o=await this.communicator.postRequestAndWaitForResponse(a);if("failure"in o.content)throw o.content.failure;const c=await Ut("public",o.sender);await this.keyManager.setPeerPublicKey(c);const h=(await this.decryptResponseMessage(o)).result;if("error"in h)throw h.error;switch(e.method){case"eth_requestAccounts":{const l=h.value;this.accounts=l,this.storage.storeObject(Xe,l),(r=this.callback)===null||r===void 0||r.call(this,"accountsChanged",l);break}}}async request(e){var n;if(this.accounts.length===0)switch(e.method){case"wallet_sendCalls":return this.sendRequestToPopup(e);default:throw p.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.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 p.rpc.internal("No RPC URL set for chain");return Ve(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 i=await this.sendEncryptedRequest(e),a=(await this.decryptResponseMessage(i)).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 p.rpc.invalidParams();const i=ne(s[0].chainId);if(this.updateChain(i))return null;const a=await this.sendRequestToPopup(e);return a===null&&this.updateChain(i),a}async handleGetCapabilitiesRequest(e){Zn(e.params);const n=e.params[0],s=e.params[1];if(!this.accounts.some(o=>Cn(o,n)))throw p.provider.unauthorized("no active account found");const i=this.storage.loadObject(nt);if(!i)return{};if(!s||s.length===0)return i;const r=new Set(s.map(o=>Ye(o)));return Object.fromEntries(Object.entries(i).filter(([o])=>{try{const c=Ye(o);return r.has(c)}catch{return!1}}))}async sendEncryptedRequest(e){const n=await this.keyManager.getSharedSecret();if(!n)throw p.provider.unauthorized("No valid session found, try requestAccounts before other methods");const s=await zn({action:e,chainId:this.chain.id},n),i=await this.createRequestMessage({encrypted:s});return this.communicator.postRequestAndWaitForResponse(i)}async createRequestMessage(e){const n=await jt("public",await this.keyManager.getOwnPublicKey());return{id:crypto.randomUUID(),sender:n,content:e,timestamp:new Date}}async decryptResponseMessage(e){var n,s;const i=e.content;if("failure"in i)throw i.failure;const r=await this.keyManager.getSharedSecret();if(!r)throw p.provider.unauthorized("Invalid session");const a=await Fn(i.encrypted,r),o=(n=a.data)===null||n===void 0?void 0:n.chains;if(o){const d=Object.entries(o).map(([h,l])=>({id:Number(h),rpcUrl:l}));this.storage.storeObject(tt,d),this.updateChain(this.chain.id,d)}const c=(s=a.data)===null||s===void 0?void 0:s.capabilities;return c&&this.storage.storeObject(nt,c),a}updateChain(e,n){var s;const i=n??this.storage.loadObject(tt),r=i==null?void 0:i.find(a=>a.id===e);return r?(r!==this.chain&&(this.chain=r,this.storage.storeObject(et,r),(s=this.callback)===null||s===void 0||s.call(this,"chainChanged",B(r.id))),!0):!1}}const{keccak_256:Xn}=An;function Bt(t){return Buffer.allocUnsafe(t).fill(0)}function es(t){return t.toString(2).length}function qt(t,e){let n=t.toString(16);n.length%2!==0&&(n="0"+n);const s=n.match(/.{1,2}/g).map(i=>parseInt(i,16));for(;s.length<e;)s.unshift(0);return Buffer.from(s)}function ts(t,e){const n=t<0n;let s;if(n){const i=(1n<<BigInt(e))-1n;s=(~t&i)+1n}else s=t;return s&=(1n<<BigInt(e))-1n,s}
1function Kt(t,e,n){const s=Bt(e);return t=be(t),n?t.length<e?(t.copy(s),s):t.slice(0,e):t.length<e?(t.copy(s,e-t.length),s):t.slice(-e)}function ns(t,e){return Kt(t,e,!0)}function be(t){if(!Buffer.isBuffer(t))if(Array.isArray(t))t=Buffer.from(t);else if(typeof t=="string")Vt(t)?t=Buffer.from(rs(zt(t)),"hex"):t=Buffer.from(t);else if(typeof t=="number")t=intToBuffer(t);else if(t==null)t=Buffer.allocUnsafe(0);else if(typeof t=="bigint")t=qt(t);else if(t.toArray)t=Buffer.from(t.toArray());else throw new Error("invalid type");return t}function ss(t){return t=be(t),"0x"+t.toString("hex")}function is(t,e){if(t=be(t),e||(e=256),e!==256)throw new Error("unsupported");return Buffer.from(Xn(new Uint8Array(t)))}function rs(t){return t.length%2?"0"+t:t}function Vt(t){return typeof t=="string"&&t.match(/^0x[0-9A-Fa-f]*$/)}function zt(t){return typeof t=="string"&&t.startsWith("0x")?t.slice(2):t}var Ft={zeros:Bt,setLength:Kt,setLengthRight:ns,isHexString:Vt,stripHexPrefix:zt,toBuffer:be,bufferToHex:ss,keccak:is,bitLengthFromBigInt:es,bufferBEFromBigInt:qt,twosFromBigInt:ts};const I=Ft;function $t(t){return t.startsWith("int[")?"int256"+t.slice(3):t==="int"?"int256":t.startsWith("uint[")?"uint256"+t.slice(4):t==="uint"?"uint256":t.startsWith("fixed[")?"fixed128x128"+t.slice(5):t==="fixed"?"fixed128x128":t.startsWith("ufixed[")?"ufixed128x128"+t.slice(6):t==="ufixed"?"ufixed128x128":t}function $(t){return Number.parseInt(/^\D+(\d+)$/.exec(t)[1],10)}function st(t){var e=/^\D+(\d+)x(\d+)$/.exec(t);return[Number.parseInt(e[1],10),Number.parseInt(e[2],10)]}function Zt(t){var e=t.match(/(.*)\[(.*?)\]$/);return e?e[2]===""?"dynamic":Number.parseInt(e[2],10):null}function K(t){var e=typeof t;if(e==="string"||e==="number")return BigInt(t);if(e==="bigint")return t;throw new Error("Argument is not a number")}function N(t,e){var n,s,i,r;if(t==="address")return N("uint160",K(e));if(t==="bool")return N("uint8",e?1:0);if(t==="string")return N("bytes",new Buffer(e,"utf8"));if(os(t)){if(typeof e.length>"u")throw new Error("Not an array?");if(n=Zt(t),n!=="dynamic"&&n!==0&&e.length>n)throw new Error("Elements exceed array size: "+n);i=[],t=t.slice(0,t.lastIndexOf("[")),typeof e=="string"&&(e=JSON.parse(e));for(r in e)i.push(N(t,e[r]));if(n==="dynamic"){var a=N("uint256",e.length);i.unshift(a)}return Buffer.concat(i)}else{if(t==="bytes")return e=new Buffer(e),i=Buffer.concat([N("uint256",e.length),e]),e.length%32!==0&&(i=Buffer.concat([i,I.zeros(32-e.length%32)])),i;if(t.startsWith("bytes")){if(n=$(t),n<1||n>32)throw new Error("Invalid bytes<N> width: "+n);return I.setLengthRight(e,32)}else if(t.startsWith("uint")){if(n=$(t),n%8||n<8||n>256)throw new Error("Invalid uint<N> width: "+n);s=K(e);const o=I.bitLengthFromBigInt(s);if(o>n)throw new Error("Supplied uint exceeds width: "+n+" vs "+o);if(s<0)throw new Error("Supplied uint is negative");return I.bufferBEFromBigInt(s,32)}else if(t.startsWith("int")){if(n=$(t),n%8||n<8||n>256)throw new Error("Invalid int<N> width: "+n);s=K(e);const o=I.bitLengthFromBigInt(s);if(o>n)throw new Error("Supplied int exceeds width: "+n+" vs "+o);const c=I.twosFromBigInt(s,256);return I.bufferBEFromBigInt(c,32)}else if(t.startsWith("ufixed")){if(n=st(t),s=K(e),s<0)throw new Error("Supplied ufixed is negative");return N("uint256",s*BigInt(2)**BigInt(n[1]))}else if(t.startsWith("fixed"))return n=st(t),N("int256",K(e)*BigInt(2)**BigInt(n[1]))}throw new Error("Unsupported or invalid type: "+t)}function as(t){return t==="string"||t==="bytes"||Zt(t)==="dynamic"}function os(t){return t.lastIndexOf("]")===t.length-1}function cs(t,e){var n=[],s=[],i=32*t.length;for(var r in t){var a=$t(t[r]),o=e[r],c=N(a,o);as(a)?(n.push(N("uint256",i)),s.push(c),i+=c.length):n.push(c)}return Buffer.concat(n.concat(s))}function Gt(t,e){if(t.length!==e.length)throw new Error("Number of types are not matching the values");for(var n,s,i=[],r=0;r<t.length;r++){var a=$t(t[r]),o=e[r];if(a==="bytes")i.push(o);else if(a==="string")i.push(new Buffer(o,"utf8"));else if(a==="bool")i.push(new Buffer(o?"01":"00","hex"));else if(a==="address")i.push(I.setLength(o,20));else if(a.startsWith("bytes")){if(n=$(a),n<1||n>32)throw new Error("Invalid bytes<N> width: "+n);i.push(I.setLengthRight(o,n))}else if(a.startsWith("uint")){if(n=$(a),n%8||n<8||n>256)throw new Error("Invalid uint<N> width: "+n);s=K(o);const c=I.bitLengthFromBigInt(s);if(c>n)throw new Error("Supplied uint exceeds width: "+n+" vs "+c);i.push(I.bufferBEFromBigInt(s,n/8))}else if(a.startsWith("int")){if(n=$(a),n%8||n<8||n>256)throw new Error("Invalid int<N> width: "+n);s=K(o);const c=I.bitLengthFromBigInt(s);if(c>n)throw new Error("Supplied int exceeds width: "+n+" vs "+c);const d=I.twosFromBigInt(s,n);i.push(I.bufferBEFromBigInt(d,n/8))}else throw new Error("Unsupported or invalid type: "+a)}return Buffer.concat(i)}function ls(t,e){return I.keccak(Gt(t,e))}var ds={rawEncode:cs,solidityPack:Gt,soliditySHA3:ls};const A=Ft,se=ds,Yt={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"]},Me={encodeData(t,e,n,s=!0){const i=["bytes32"],r=[this.hashType(t,n)];if(s){const a=(o,c,d)=>
1{if(n[c]!==void 0)return["bytes32",d==null?"0x0000000000000000000000000000000000000000000000000000000000000000":A.keccak(this.encodeData(c,d,n,s))];if(d===void 0)throw new Error(`missing value for field ${o} of type ${c}`);if(c==="bytes")return["bytes32",A.keccak(d)];if(c==="string")return typeof d=="string"&&(d=Buffer.from(d,"utf8")),["bytes32",A.keccak(d)];if(c.lastIndexOf("]")===c.length-1){const h=c.slice(0,c.lastIndexOf("[")),l=d.map(u=>a(o,h,u));return["bytes32",A.keccak(se.rawEncode(l.map(([u])=>u),l.map(([,u])=>u)))]}return[c,d]};for(const o of n[t]){const[c,d]=a(o.name,o.type,e[o.name]);i.push(c),r.push(d)}}else for(const a of n[t]){let o=e[a.name];if(o!==void 0)if(a.type==="bytes")i.push("bytes32"),o=A.keccak(o),r.push(o);else if(a.type==="string")i.push("bytes32"),typeof o=="string"&&(o=Buffer.from(o,"utf8")),o=A.keccak(o),r.push(o);else if(n[a.type]!==void 0)i.push("bytes32"),o=A.keccak(this.encodeData(a.type,o,n,s)),r.push(o);else{if(a.type.lastIndexOf("]")===a.type.length-1)throw new Error("Arrays currently unimplemented in encodeData");i.push(a.type),r.push(o)}}return se.rawEncode(i,r)},encodeType(t,e){let n="",s=this.findTypeDependencies(t,e).filter(i=>i!==t);s=[t].concat(s.sort());for(const i of s){if(!e[i])throw new Error("No type definition specified: "+i);n+=i+"("+e[i].map(({name:a,type:o})=>o+" "+a).join(",")+")"}return n},findTypeDependencies(t,e,n=[]){if(t=t.match(/^\w*/)[0],n.includes(t)||e[t]===void 0)return n;n.push(t);for(const s of e[t])for(const i of this.findTypeDependencies(s.t
1ype,e,n))!n.includes(i)&&n.push(i);return n},hashStruct(t,e,n,s=!0){return A.keccak(this.encodeData(t,e,n,s))},hashType(t,e){return A.keccak(this.encodeType(t,e))},sanitizeData(t){const e={};for(const n in Yt.properties)t[n]&&(e[n]=t[n]);return e.types&&(e.types=Object.assign({EIP712Domain:[]},e.types)),e},hash(t,e=!0){const n=this.sanitizeData(t),s=[Buffer.from("1901","hex")];return s.push(this.hashStruct("EIP712Domain",n.domain,n.types,e)),n.primaryType!=="EIP712Domain"&&s.push(this.hashStruct(n.primaryType,n.message,n.types,e)),A.keccak(Buffer.concat(s))}};var hs={TYPED_MESSAGE_SCHEMA:Yt,TypedDataUtils:Me,hashForSignTypedDataLegacy:function(t){return us(t.data)},hashForSignTypedData_v3:function(t){return Me.hash(t.data,!1)},hashForSignTypedData_v4:function(t){return Me.hash(t.data)}};function us(t){const e=new Error("Expect argument to be non-empty array");if(typeof t!="object"||!t.length)throw e;const n=t.map(function(r){return r.type==="bytes"?A.toBuffer(r.value):r.value}),s=t.map(function(r){return r.type}),i=t.map(function(r){if(!r.name)throw e;return r.type+" "+r.name});return se.soliditySHA3(["bytes32","bytes32"],[se.soliditySHA3(new Array(t.length).fill("string"),i),se.soliditySHA3(s,n)])}const ce=In(hs),fs="walletUsername",Re="Addresses",ps="AppVersion";function C(t){return t.errorMessage!==void 0}class gs{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)),i=await crypto.subtle.importKey("raw",he(n),{name:"aes-gcm"},!1,["encrypt","decrypt"]),r=new TextEncoder,a=await window.crypto.subtle.encrypt({name:"AES-GCM",iv:s},i,r.encode(e)),o=16,c=a.slice(a.byteLength-o),d=a.slice(0,a.byteLength-o),h=new Uint8Array(c),l=new Uint8Array(d),u=new Uint8Array([...s,...h,...l]);return Be(u)}async decrypt(e){const n=this.secret;if(n.length!==64)throw Error("secret must be 256 bits");return new Promise((s,i)=>{(async function(){const r=await crypto.subtle.importKey("raw",he(n),{name:"aes-gcm"},!1,["encrypt","decrypt"]),a=he(e),o=a.slice(0,12),c=a.slice(12,28),d=a.slice(28),h=new Uint8Array([...d,...c]),l={name:"AES-GCM",iv:new Uint8Array(o)};try{const u=await window.crypto.subtle.decrypt(l,r,h),f=new TextDecoder;s(f.decode(u))}catch(u){i(u)}})()})}}class ms{constructor(e,n,s){this.linkAPIUrl=e,this.sessionId=n;const i=`${n}:${s}`;this.auth=`Basic ${btoa(i)}`}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:i}=await n.json();if(i)throw new Error(`Check unseen events failed: ${i}`);const r=(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(r),r}throw new Error(`Check unseen events failed: ${n.status}`)}}var T;(function(t){t[t.DISCONNECTED=0]="DISCONNECTED",t[t.CONNECTING=1]="CONNECTING",t[t.CONNECTED=2]="CONNECTED"})(T||(T={}));class S{setConnectionStateListener(e){this.connectionStateListener=e}setIncomingDataListener(e){this.incomingDataListener=e}constructor(e,n=WebSocket){this.WebSocketClass=n,this.webSocket=null,this.isDisconnecting=!1,this.url=e.replace(/^http/,"ws"),this.instanceId=S.instanceCounter++,S.activeInstances.add(this.instanceId)}async connect(){if(this.webSocket)throw new Error("webSocket object is not null");if(this.isDisconnecting)throw new Error("WebSocket is disconnecting, cannot reconnect on same instance");return new Promise((e,n)=>{var s;let i;try{this.webSocket=i=new this.WebSocketClass(this.url)}catch(r){n(r);return}(s=this.connectionStateListener)===null||s===void 0||s.call(this,T.CONNECTING),i.onclose=r=>{var a;this.clearWebSocket(),i.readyState!==WebSocket.OPEN&&n(new Error(`websocket error ${r.code}: ${r.reason}`)),(a=this.connectionStateListener)===null||a===void 0||a.call(this,T.DISCONNECTED)},i.onopen=r=>{var a;
1e(),(a=this.connectionStateListener)===null||a===void 0||a.call(this,T.CONNECTED),S.pendingData.length>0&&([...S.pendingData].forEach(c=>this.sendData(c)),S.pendingData=[])},i.onmessage=r=>{var a,o;if(r.data==="h")(a=this.incomingDataListener)===null||a===void 0||a.call(this,{type:"Heartbeat"});else try{const c=JSON.parse(r.data);(o=this.incomingDataListener)===null||o===void 0||o.call(this,c)}catch{}}})}disconnect(){var e;const{webSocket:n}=this;if(n){this.isDisconnecting=!0,this.clearWebSocket(),(e=this.connectionStateListener)===null||e===void 0||e.call(this,T.DISCONNECTED),this.connectionStateListener=void 0,this.incomingDataListener=void 0;try{n.close()}catch{}}}sendData(e){const{webSocket:n}=this;if(!n){S.pendingData.push(e),this.isDisconnecting||this.connect();return}if(n.readyState!==WebSocket.OPEN){S.pendingData.push(e);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)}cleanup(){S.activeInstances.delete(this.instanceId)}}S.instanceCounter=0;S.activeInstances=new Set;S.pendingData=[];const it=1e4,_s=6e4;class bs{constructor({session:e,linkAPIUrl:n,listener:s}){this.destroyed=!1,this.lastHeartbeatResponse=0,this.nextReqId=D(1),this.reconnectAttempts=0,this.isReconnecting=!1,this._connected=!1,this._linked=!1,this.requestResolutions=new Map,this.handleSessionMetadataUpdated=r=>{if(!r)return;new Map([["__destroyed",this.handleDestroyed],["EthereumAddress",this.handleAccountUpdated],["WalletUsername",this.handleWalletUsernameUpdated],["AppVersion",this.handleAppVersionUpdated],["ChainId",o=>r.JsonRpcUrl&&this.handleChainUpdated(o,r.JsonRpcUrl)]]).forEach((o,c)=>{const d=r[c];d!==void 0&&o(d)})},this.handleDestroyed=r=>{var a;r==="1"&&((a=this.listener)===null||a===void 0||a.resetAndReload())},this.handleAccountUpdated=async r=>{var a;try{const o=await this.cipher.decrypt(r);(a=this.listener)===null||a===void 0||a.accountUpdated(o)}catch{}},this.handleMetadataUpdated=async(r,a)=>{var o;try{const c=await this.cipher.decrypt(a);(o=this.listener)===null||o===void 0||o.metadataUpdated(r,c)}catch{}},this.handleWalletUsernameUpdated=async r=>{this.handleMetadataUpdated(fs,r)},this.handleAppVersionUpdated=async r=>{this.handleMetadataUpdated(ps,r)},this.handleChainUpdated=async(r,a)=>{var o;try{const c=await this.cipher.decrypt(r),d=await this.cipher.decrypt(a);(o=this.listener)===null||o===void 0||o.chainUpdated(c,d)}catch{}},this.session=e,this.cipher=new gs(e.secret),this.listener=s,this.linkAPIUrl=n,this.WebSocketClass=WebSocket;const i=this.createWebSocket();this.ws=i,this.http=new ms(n,e.id,e.key),this.setupVisibilityChangeHandler()}createWebSocket(){const e=new S(`${this.linkAPIUrl}/rpc`,this.WebSocketClass);return this.activeWsInstance=e,e.setConnectionStateListener(async n=>{if(e!==this.activeWsInstance)return;let s=!1;switch(n){case T.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;const r=this.reconnectAttempts===0?0:3e3;await new Promise(a=>setTimeout(a,r)),!this.destroyed&&e===this.activeWsInstance?(this.reconnectAttempts++,"cleanup"in this.ws&&typeof this.ws.cleanup=="function"&&this.ws.cleanup(),this.ws=this.createWebSocket(),this.ws.connect().catch(()=>{}).finally(()=>{this.isReconnecting=!1})):this.isReconnecting=!1})();break;case T.CONNECTED:this.reconnectAttempts=0;try{s=await this.handleConnected(),this.fetchUnseenEventsAPI().catch(()=>{})}catch{break}this.connected=s,this.updateLastHeartbeat(),this.heartbeatIntervalId&&clearInterval(this.heartbeatIntervalId),this.heartbeatIntervalId=window.setInterval(()=>{this.heartbeat()},it),setTimeout(()=>{this.heartbeat()},100);break;case T.CONNECTING:break}n!==T.CONNECTED&&(this.connected=s)}),e.setIncomingDataListener(n=>{var s;switch(n.type){case"Heartbeat":this.updateLastHeartbeat();return;case"IsLinkedOK":case"Linked":{const i=n.type==="IsLinkedOK"?n.linked:void 0;this.linked=i||n.onlineGuests>0;break}case"GetSessionConfigOK":case"SessionConfigUpdated":{this.handleSessionMetadataUpdated(n.metadata);break}case"Event":{this.handleIncomingEvent(n);break}}n.id!==void 0&&((s=this.requestResolutions.get(n.id))===null||s===void 0||s(n))}),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;const e=this.ws;this.activeWsInstance=void 0,e.disconnect(),"cleanup"in e&&typeof e.cleanup=="function"&&e.cleanup(),this.ws=this.createWebSocket(),this.ws.connect().catch(()=>{})}connect(){if(this.destroyed)throw new Error("instance is destroyed");this.ws.connect()}
1async destroy(){this.destroyed||(await this.makeRequest({type:"SetSessionConfig",id:D(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&&typeof this.ws.cleanup=="function"&&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 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"))try{const s=await this.cipher.decrypt(e.data),i=JSON.parse(s);if(i.type!=="WEB3_RESPONSE")return;(n=this.listener)===null||n===void 0||n.handleWeb3ResponseMessage(i.id,i.response)}catch{}}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(n=>{this.handleIncomingEvent(n)})}catch{}}async publishEvent(e,n,s=!1){const i=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"}))),r={type:"PublishEvent",id:D(this.nextReqId++),sessionId:this.session.id,event:e,data:i,callWebhook:s};return this.setOnceLinked(async()=>{const a=await this.makeRequest(r);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>it*2){this.ws.disconnect();return}if(this.connected)try{this.ws.sendData("h")}catch{}}async makeRequest(e,n={timeout:_s}){const s=e.id;this.sendData(e);let i;return Promise.race([new Promise((r,a)=>{i=window.setTimeout(()=>{a(new Error(`request ${s} timed out`))},n.timeout)}),new Promise(r=>{this.requestResolutions.set(s,a=>{clearTimeout(i),r(a),this.requestResolutions.delete(s)})})])}async handleConnected(){return(await this.makeRequest({type:"HostSession",id:D(this.nextReqId++),sessionId:this.session.id,sessionKey:this.session.key})).type==="Fail"?!1:(this.sendData({type:"IsLinked",id:D(this.nextReqId++),sessionId:this.session.id}),this.sendData({type:"GetSessionConfig",id:D(this.nextReqId++),sessionId:this.session.id}),!0)}}class ws{constructor(){this._nextRequestId=0,this.callbacks=new Map}makeRequestId(){this._nextRequestId=(this._nextRequestId+1)%2147483647;const e=this._nextRequestId,n=Dt(e.toString(16));return this.callbacks.get(n)&&this.callbacks.delete(n),e}}const rt="session:id",at="session:secret",ot="session:linked";class Z{constructor(e,n,s,i=!1){this.storage=e,this.id=n,this.secret=s,this.key=Sn(Mn(`${n}, ${s} WalletLink`)),this._linked=!!i}static create(e){const n=q(16),s=q(32);return new Z(e,n,s).save()}static load(e){const n=e.getItem(rt),s=e.getItem(ot),i=e.getItem(at);return n&&i?new Z(e,n,i,s==="1"):null}get linked(){return this._linked}set linked(e){this._linked=e,this.persistLinked()}save(){return this.storage.setItem(rt,this.id),this.storage.setItem(at,this.secret),this.persistLinked(),this}persistLinked(){this.storage.setItem(ot,this._linked?"1":"0")}}function ys(){try{return window.frameElement!==null}catch{return!1}}function vs(){try{return ys()&&window.top?window.top.location:window.location}catch{return window.location}}function ks(){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 Jt(){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 Es=(()=>'@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 Qt(){const t=document.createElement("style");t.type="text/css",t.appendChild(document.createTextNode(Es)),document.documentElement.appendChild(t)}var we,b,Xt,V,ct,en,tn,nn,ze,Ne,Te,re={},sn=[],Cs=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,ye=Array.isArray;function j(t,e){for(var n in e)t[n]=e[n];return t}function Fe(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function g(t,e,n){var s,i,r,a={};for(r in e)r=="key"?s=e[r]:r=="ref"?i=e[r]:a[r]=e[r];if(arguments.length>2&&(a.children=arguments.length>3?we.call(arguments,2):n),typeof t=="function"&&t.defaultProps!=null)for(r in t.defaultProps)a[r]===void 0&&(a[r]=t.defaultProps[r]);return ue(t,a,s,i,null)}function ue(t,e,n,s,i){var r={type:t,props:e,key:n,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++Xt,__i:-1,__u:0};return i==null&&b.vnode!=null&&b.vnode(r),r}function ve(t){return t.children}function fe(t,e){this.props=t,this.context=e}function G(t,e){if(e==null)return t.__?G(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"?G(t):null}function rn(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 rn(t)}}function lt(t){(!t.__d&&(t.__d=!0)&&V.push(t)&&!ge.__r++||ct!=b.debounceRendering)&&((ct=b.debounceRendering)||en)(ge)}function ge(){for(var t,e,n,s,i,r,a,o=1;V.length;)V.length>o&&V.sort(tn),t=V.shift(),o=V.length,t.__d&&(n=void 0,s=void 0,i=(s=(e=t).__v).__e,r=[],a=[],e.__P&&((n=j({},s)).__v=s.__v+1,b.vnode&&b.vnode(n),$e(e.__P,n,s,e.__n,e.__P.namespaceURI,32&s.__u?[i]:null,r,i??G(s),!!(32&s.__u),a),n.__v=s.__v,n.__.__k[n.__i]=n,cn(r,n,a),s.__e=s.__=null,n.__e!=i&&rn(n)));ge.__r=0}function an(t,e,n,s,i,r,a,o,c,d,h){var l,u,f,k,x,E,m,_=s&&s.__k||sn,U=e.length;for(c=Is(n,e,_,c,U),l=0;l<U;l++)(f=n.__k[l])!=null&&(u=f.__i==-1?re:_[f.__i]||re,f.__i=l,E=$e(t,f,u,i,r,a,o,c,d,h),k=f.__e,f.ref&&u.ref!=f.ref&&(u.ref&&Ze(u.ref,null,f),h.push(f.ref,f.__c||k,f)),x==null&&k!=null&&(x=k),(m=!!(4&f.__u))||u.__k===f.__k?c=on(f,c,t,m):typeof f.type=="function"&&E!==void 0?c=E:k&&(c=k.nextSibling),f.__u&=-7);return n.__e=x,c}function Is(t,e,n,s,i){var r,a,o,c,d,h=n.length,l=h,u=0;for(t.__k=new Array(i),r=0;r<i;r++)(a=e[r])!=null&&typeof a!="boolean"&&typeof a!="function"?(c=r+u,(a=t.__k[r]=typeof a=="str
1ing"||typeof a=="number"||typeof a=="bigint"||a.constructor==String?ue(null,a,null,null,null):ye(a)?ue(ve,{children:a},null,null,null):a.constructor==null&&a.__b>0?ue(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):a).__=t,a.__b=t.__b+1,o=null,(d=a.__i=Ss(a,n,c,l))!=-1&&(l--,(o=n[d])&&(o.__u|=2)),o==null||o.__v==null?(d==-1&&(i>h?u--:i<h&&u++),typeof a.type!="function"&&(a.__u|=4)):d!=c&&(d==c-1?u--:d==c+1?u++:(d>c?u--:u++,a.__u|=4))):t.__k[r]=null;if(l)for(r=0;r<h;r++)(o=n[r])!=null&&!(2&o.__u)&&(o.__e==s&&(s=G(o)),dn(o,o));return s}function on(t,e,n,s){var i,r;if(typeof t.type=="function"){for(i=t.__k,r=0;i&&r<i.length;r++)i[r]&&(i[r].__=t,e=on(i[r],e,n,s));return e}t.__e!=e&&(s&&(e&&t.type&&!e.parentNode&&(e=G(t)),n.insertBefore(t.__e,e||null)),e=t.__e);do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function Ss(t,e,n,s){var i,r,a,o=t.key,c=t.type,d=e[n],h=d!=null&&(2&d.__u)==0;if(d===null&&t.key==null||h&&o==d.key&&c==d.type)return n;if(s>(h?1:0)){for(i=n-1,r=n+1;i>=0||r<e.length;)if((d=e[a=i>=0?i--:r++])!=null&&!(2&d.__u)&&o==d.key&&c==d.type)return a}return-1}function dt(t,e,n){e[0]=="-"?t.setProperty(e,n??""):t[e]=n==null?"":typeof n!="number"||Cs.test(e)?n:n+"px"}function le(t,e,n,s,i){var r,a;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||dt(t.style,e,"");if(n)for(e in n)s&&n[e]==s[e]||dt(t.style,e,n[e])}else if(e[0]=="o"&&e[1]=="n")r=e!=(e=e.replace(nn,"$1")),a=e.toLowerCase(),e=a in t||e=="onFocusOut"||e=="onFocusIn"?a.slice(2):e.slice(2),t.l||(t.l={}),t.l[e+r]=n,n?s?n.u=s.u:(n.u=ze,t.addEventListener(e,r?Te:Ne,r)):t.removeEventListener(e,r?Te:Ne,r);else{if(i=="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 ht(t){return function(e){if(this.l){var n=this.l[e.type+t];if(e.t==null)e.t=ze++;else if(e.t<n.u)return;return n(b.event?b.event(e):e)}}}function $e(t,e,n,s,i,r,a,o,c,d){var h,l,u,f,k,x,E,m,_,U,H,ae,J,Ge,oe,Q,ke,L=e.type;if(e.constructor!=null)return null;128&n.__u&&(c=!!(32&n.__u),r=[o=e.__e=n.__e]),(h=b.__b)&&h(e);e:if(typeof L=="function")try{if(m=e.props,_="prototype"in L&&L.prototype.render,U=(h=L.contextType)&&s[h.__c],H=h?U?U.props.value:h.__:s,n.__c?E=(l=e.__c=n.__c).__=l.__E:(_?e.__c=l=new L(m,H):(e.__c=l=new fe(m,H),l.constructor=L,l.render=xs),U&&U.sub(l),l.props=m,l.state||(l.state={}),l.context=H,l.__n=s,u=l.__d=!0,l.__h=[],l._sb=[]),_&&l.__s==null&&(l.__s=l.state),_&&L.getDerivedStateFromProps!=null&&(l.__s==l.state&&(l.__s=j({},l.__s)),j(l.__s,L.getDerivedStateFromProps(m,l.__s))),f=l.props,k=l.state,l.__v=e,u)_&&L.getDerivedStateFromProps==null&&l.componentWillMount!=null&&l.componentWillMount(),_&&l.componentDidMount!=null&&l.__h.push(l.componentDidMount);else{if(_&&L.getDerivedStateFromProps==null&&m!==f&&l.componentWillReceiveProps!=null&&l.componentWillReceiveProps(m,H),!l.__e&&l.shouldComponentUpdate!=null&&l.shouldComponentUpdate(m,l.__s,H)===!1||e.__v==n.__v){for(e.__v!=n.__v&&(l.props=m,l.state=l.__s,l.__d=!1),e.__e=n.__e,e.__k=n.__k,e.__k.some(function(z){z&&(z.__=e)}),ae=0;ae<l._sb.length;ae++)l.__h.push(l._sb[ae]);l._sb=[],l.__h.length&&a.push(l);break e}l.componentWillUpdate!=null&&l.componentWillUpdate(m,l.__s,H),_&&l.componentDidUpdate!=null&&l.__h.push(function(){l.componentDidUpdate(f,k,x)})}if(l.context=H,l.props=m,l.__P=t,l.__e=!1,J=b.__r,Ge=0,_){for(l.state=l.__s,l.__d=!1,J&&J(e),h=l.render(l.props,l.state,l.context),oe=0;oe<l._sb.length;oe++)l.__h.push(l._sb[oe]);l._sb=[]}else do l.__d=!1,J&&J(e),h=l.render(l.props,l.state,l.context),l.state=l.__s;while(l.__d&&++Ge<25);l.state=l.__s,l.getChildContext!=null&&(s=j(j({},s),l.getChildContext())),_&&!u&&l.getSnapshotBeforeUpdate!=null&&(x=l.getSnapshotBeforeUpdate(f,k)),Q=h,h!=null&&h.type===ve&&h.key==null&&(Q=ln(h.props.children)),o=an(t,ye(Q)?Q:[Q],e,n,s,i,r,a,o,c,d),l.base=e.__e,e.__u&=-161,l.__h.length&&a.push(l),E&&(l.__E=l.__=null)}catch(z){if(e.__v=null,c||r!=null)if(z.then){for(e.__u|=c?160:128;o&&o.nodeType==8&&o.nextSibling;)o=o.nextSibling;r[r.indexOf(o)]=null,e.__e=o}else{for(ke=r.length;ke--;)Fe(r[ke]);De(e)}else e.__e=n.__e,e.__k=n.__k,z.then||De(e);b.__e(z,e,n)}else r==null&&e.__v==n.__v?(e.__k=n.__k,e.__e=n.__e):o=e.__e=Ms(n.__e,e,n,s,i,r,a,c,d);
vendor: 3,417 bytes, line 1
1return(h=b.diffed)&&h(e),128&e.__u?void 0:o}function De(t){t&&t.__c&&(t.__c.__e=!0),t&&t.__k&&t.__k.forEach(De)}function cn(t,e,n){for(var s=0;s<n.length;s++)Ze(n[s],n[++s],n[++s]);b.__c&&b.__c(e,t),t.some(function(i){try{t=i.__h,i.__h=[],t.some(function(r){r.call(i)})}catch(r){b.__e(r,i.__v)}})}function ln(t){return typeof t!="object"||t==null||t.__b&&t.__b>0?t:ye(t)?t.map(ln):j({},t)}function Ms(t,e,n,s,i,r,a,o,c){var d,h,l,u,f,k,x,E=n.props,m=e.props,_=e.type;if(_=="svg"?i="http://www.w3.org/2000/svg":_=="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),r!=null){for(d=0;d<r.length;d++)if((f=r[d])&&"setAttribute"in f==!!_&&(_?f.localName==_:f.nodeType==3)){t=f,r[d]=null;break}}if(t==null){if(_==null)return document.createTextNode(m);t=document.createElementNS(i,_,m.is&&m),o&&(b.__m&&b.__m(e,r),o=!1),r=null}if(_==null)E===m||o&&t.data==m||(t.data=m);else{if(r=r&&we.call(t.childNodes),E=n.props||re,!o&&r!=null)for(E={},d=0;d<t.attributes.length;d++)E[(f=t.attributes[d]).name]=f.value;for(d in E)if(f=E[d],d!="children"){if(d=="dangerouslySetInnerHTML")l=f;else if(!(d in m)){if(d=="value"&&"defaultValue"in m||d=="checked"&&"defaultChecked"in m)continue;le(t,d,null,f,i)}}for(d in m)f=m[d],d=="children"?u=f:d=="dangerouslySetInnerHTML"?h=f:d=="value"?k=f:d=="checked"?x=f:o&&typeof f!="function"||E[d]===f||le(t,d,f,E[d],i);if(h)o||l&&(h.__html==l.__html||h.__html==t.innerHTML)||(t.innerHTML=h.__html),e.__k=[];else if(l&&(t.innerHTML=""),an(e.type=="template"?t.content:t,ye(u)?u:[u],e,n,s,_=="foreignObject"?"http://www.w3.org/1999/xhtml":i,r,a,r?r[0]:n.__k&&G(n,0),o,c),r!=null)for(d=r.length;d--;)Fe(r[d]);o||(d="value",_=="progress"&&k==null?t.removeAttribute("value"):k!=null&&(k!==t[d]||_=="progress"&&!k||_=="option"&&k!=E[d])&&le(t,d,k,E[d],i),d="checked",x!=null&&x!=t[d]&&le(t,d,x,E[d],i))}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(i){b.__e(i,n)}}function dn(t,e,n){var s,i;if(b.unmount&&b.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(r){b.__e(r,e)}s.base=s.__P=null}if(s=t.__k)for(i=0;i<s.length;i++)s[i]&&dn(s[i],e,n||typeof t.type!="function");n||Fe(t.__e),t.__c=t.__=t.__e=void 0}function xs(t,e,n){return this.constructor(t,n)}function Oe(t,e,n){var s,i,r,a;e==document&&(e=document.documentElement),b.__&&b.__(t,e),i=(s=typeof n=="function")?null:n&&n.__k||e.__k,r=[],a=[],$e(e,t=(!s&&n||e).__k=g(ve,null,[t]),i||re,re,e.namespaceURI,!s&&n?[n]:i?null:e.firstChild?we.call(e.childNodes):null,r,!s&&n?n:i?i.__e:e.firstChild,s,a),cn(r,t,a)}we=sn.slice,b={__e:function(t,e,n,s){for(var i,r,a;e=e.__;)if((i=e.__c)&&!i.__)try{if((r=i.constructor)&&r.getDerivedStateFromError!=null&&(i.setState(r.getDerivedStateFromError(t)),a=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(t,s||{}),a=i.__d),a)return i.__E=i}catch(o){t=o}throw t}},Xt=0,fe.prototype.setState=function(t,e){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=j({},this.state),typeof t=="function"&&(t=t(j({},n),this.props)),t&&j(n,t),t!=null&&this.__v&&(e&&this._sb.push(e),lt(this))},fe.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),lt(this))},fe.prototype.render=ve,V=[],en=typeof Promise=="function"?Promise.prototype.then.bind(Prom
vendor: 4,335 bytes, line 1
1ise.resolve()):setTimeout,tn=function(t,e){return t.__v.__b-e.__v.__b},ge.__r=0,nn=/(PointerCapture)$|Capture$/i,ze=0,Ne=ht(!1),Te=ht(!0);var me,y,xe,ut,je=0,hn=[],v=b,ft=v.__b,pt=v.__r,gt=v.diffed,mt=v.__c,_t=v.unmount,bt=v.__;function un(t,e){v.__h&&v.__h(y,t,je||e),je=0;var n=y.__H||(y.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function wt(t){return je=1,As(fn,t)}function As(t,e,n){var s=un(me++,2);if(s.t=t,!s.__c&&(s.__=[n?n(e):fn(void 0,e),function(o){var c=s.__N?s.__N[0]:s.__[0],d=s.t(c,o);c!==d&&(s.__N=[d,s.__[1]],s.__c.setState({}))}],s.__c=y,!y.__f)){var i=function(o,c,d){if(!s.__c.__H)return!0;var h=s.__c.__H.__.filter(function(u){return!!u.__c});if(h.every(function(u){return!u.__N}))return!r||r.call(this,o,c,d);var l=s.__c.props!==o;return h.forEach(function(u){if(u.__N){var f=u.__[0];u.__=u.__N,u.__N=void 0,f!==u.__[0]&&(l=!0)}}),r&&r.call(this,o,c,d)||l};y.__f=!0;var r=y.shouldComponentUpdate,a=y.componentWillUpdate;y.componentWillUpdate=function(o,c,d){if(this.__e){var h=r;r=void 0,i(o,c,d),r=h}a&&a.call(this,o,c,d)},y.shouldComponentUpdate=i}return s.__N||s.__}function Ps(t,e){var n=un(me++,3);!v.__s&&Ns(n.__H,e)&&(n.__=t,n.u=e,y.__H.__h.push(n))}function Ls(){for(var t;t=hn.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(pe),t.__H.__h.forEach(Ue),t.__H.__h=[]}catch(e){t.__H.__h=[],v.__e(e,t.__v)}}v.__b=function(t){y=null,ft&&ft(t)},v.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),bt&&bt(t,e)},v.__r=function(t){pt&&pt(t),me=0;var e=(y=t.__c).__H;e&&(xe===y?(e.__h=[],y.__h=[],e.__.forEach(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(e.__h.forEach(pe),e.__h.forEach(Ue),e.__h=[],me=0)),xe=y},v.diffed=function(t){gt&>(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(hn.push(e)!==1&&ut===v.requestAnimationFrame||((ut=v.requestAnimationFrame)||Rs)(Ls)),e.__H.__.forEach(function(n){n.u&&(n.__H=n.u),n.u=void 0})),xe=y=null},v.__c=function(t,e){e.some(function(n){try{n.__h.forEach(pe),n.__h=n.__h.filter(function(s){return!s.__||Ue(s)})}catch(s){e.some(function(i){i.__h&&(i.__h=[])}),e=[],v.__e(s,n.__v)}}),mt&&mt(t,e)},v.unmount=function(t){_t&&_t(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.forEach(function(s){try{pe(s)}catch(i){e=i}}),n.__H=void 0,e&&v.__e(e,n.__v))};var yt=typeof requestAnimationFrame=="function";function Rs(t){var e,n=function(){clearTimeout(s),yt&&cancelAnimationFrame(e),setTimeout(t)},s=setTimeout(n,35);yt&&(e=requestAnimationFrame(n))}function pe(t){var e=y,n=t.__c;typeof n=="function"&&(t.__c=void 0,n()),y=e}function Ue(t){var e=y;t.__c=t.__(),y=e}function Ns(t,e){return!t||t.length!==e.length||e.some(function(n,s){return n!==t[s]})}function fn(t,e){return typeof e=="function"?e(t):e}const Ts=(()=>".-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}
1.-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}")(),Ds="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEuNDkyIDEwLjQxOWE4LjkzIDguOTMgMCAwMTguOTMtOC45M2gxMS4xNjNhOC45MyA4LjkzIDAgMDE4LjkzIDguOTN2MTEuMTYzYTguOTMgOC45MyAwIDAxLTguOTMgOC45M0gxMC40MjJhOC45MyA4LjkzIDAgMDEtOC45My04LjkzVjEwLjQxOXoiIGZpbGw9IiMxNjUyRjAiLz48cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTEwLjQxOSAwSDIxLjU4QzI3LjMzNSAwIDMyIDQuNjY1IDMyIDEwLjQxOVYyMS41OEMzMiAyNy4zMzUgMjcuMzM1IDMyIDIxLjU4MSAzMkgxMC40MkM0LjY2NSAzMiAwIDI3LjMzNSAwIDIxLjU4MVYxMC40MkMwIDQuNjY1IDQuNjY1IDAgMTAuNDE5IDB6bTAgMS40ODhhOC45MyA4LjkzIDAgMDAtOC45MyA4LjkzdjExLjE2M2E4LjkzIDguOTMgMCAwMDguOTMgOC45M0gyMS41OGE4LjkzIDguOTMgMCAwMDguOTMtOC45M1YxMC40MmE4LjkzIDguOTMgMCAwMC04LjkzLTguOTNIMTAuNDJ6IiBmaWxsPSIjZmZmIi8+PHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xNS45OTggMjYuMDQ5Yy01LjU0OSAwLTEwLjA0Ny00LjQ5OC0xMC4wNDctMTAuMDQ3IDAtNS41NDggNC40OTgtMTAuMDQ2IDEwLjA0Ny0xMC4wNDYgNS41NDggMCAxMC4wNDYgNC40OTggMTAuMDQ2IDEwLjA0NiAwIDUuNTQ5LTQuNDk4IDEwLjA0Ny0xMC4wNDYgMTAuMDQ3eiIgZmlsbD0iI2ZmZiIvPjxwYXRoIGQ9Ik0xMi43NjIgMTQuMjU0YzAtLjgyMi42NjctMS40ODkgMS40ODktMS40ODloMy40OTdjLjgyMiAwIDEuNDg4LjY2NiAxLjQ4OCAxLjQ4OXYzLjQ5N2MwIC44MjItLjY2NiAxLjQ4OC0xLjQ4OCAxLjQ4OGgtMy40OTdhMS40ODggMS40ODggMCAwMS0xLjQ4OS0xLjQ4OHYtMy40OTh6IiBmaWxsPSIjMTY1MkYwIi8+PC9zdmc+",Os="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIiIGhlaWdodD0iMTIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDYuNzV2LTEuNWwtMS43Mi0uNTdjLS4wOC0uMjctLjE5LS41Mi0uMzItLjc3bC44MS0xLjYyLTEuMDYtMS4wNi0xLjYyLjgxYy0uMjQtLjEzLS41LS4yNC0uNzctLjMyTDYuNzUgMGgtMS41bC0uNTcgMS43MmMtLjI3LjA4LS41My4xOS0uNzcuMzJsLTEuNjItLjgxLTEuMDYgMS4wNi44MSAxLjYyYy0uMTMuMjQtLjI0LjUtLjMyLjc3TDAgNS4yNXYxLjVsMS43Mi41N2MuMDguMjcuMTkuNTMuMzIuNzdsLS44MSAxLjYyIDEuMDYgMS4wNiAxLjYyLS44MWMuMjQuMTMuNS4yMy43Ny4zMkw1LjI1IDEyaDEuNWwuNTctMS43MmMuMjctLjA4LjUyLS4xOS43Ny0uMzJsMS42Mi44MSAxLjA2LTEuMDYtLjgxLTEuNjJjLjEzLS4yNC4yMy0uNS4zMi0uNzdMMTIgNi43NXpNNiA4LjVhMi41IDIuNSAwIDAxMC01IDIuNSAyLjUgMCAwMTAgNXoiIGZpbGw9IiMwNTBGMTkiLz48L3N2Zz4=";class pn{constructor(){this.items=new Map,this.nextItemKey=0,this.root=null,this.darkMode=Jt()}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&&Oe(g("div",null,g(gn,{darkMode:this.darkMode},Array.from(this.items.entries()).map(([e,n])=>g(js,Object.assign({},n,{key:e}))))),this.root)}}const gn=t=>g("div",{class:ee("-cbwsdk-snackbar-container")},g("style",null,Ts),g("div",{class:"-cbwsdk-snackbar"},t.children)),js=({autoExpand:t,message:e,menuItems:n})=>{const[s,i]=wt(!0),[r,a]=wt(t??!1);Ps(()=>{const c=[window.setTimeout(()=>{i(!1)},1),window.setTimeout(()=>{a(!0)},1e4)];return()=>
1{c.forEach(window.clearTimeout)}});const o=()=>{a(!r)};return g("div",{class:ee("-cbwsdk-snackbar-instance",s&&"-cbwsdk-snackbar-instance-hidden",r&&"-cbwsdk-snackbar-instance-expanded")},g("div",{class:"-cbwsdk-snackbar-instance-header",onClick:o},g("img",{src:Ds,class:"-cbwsdk-snackbar-instance-header-cblogo"})," ",g("div",{class:"-cbwsdk-snackbar-instance-header-message"},e),g("div",{class:"-gear-container"},!r&&g("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},g("circle",{cx:"12",cy:"12",r:"12",fill:"#F5F7F8"})),g("img",{src:Os,class:"-gear-icon",title:"Expand"}))),n&&n.length>0&&g("div",{class:"-cbwsdk-snackbar-instance-menu"},n.map((c,d)=>g("div",{class:ee("-cbwsdk-snackbar-instance-menu-item",c.isRed&&"-cbwsdk-snackbar-instance-menu-item-is-red"),onClick:c.onClick,key:d},g("svg",{width:c.svgWidth,height:c.svgHeight,viewBox:"0 0 10 11",fill:"none",xmlns:"http://www.w3.org/2000/svg"},g("path",{"fill-rule":c.defaultFillRule,"clip-rule":c.defaultClipRule,d:c.path,fill:"#AAAAAA"})),g("span",{class:ee("-cbwsdk-snackbar-instance-menu-item-info",c.isRed&&"-cbwsdk-snackbar-instance-menu-item-info-is-red")},c.info)))))},mn="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";class Us{constructor(){this.attached=!1,this.snackbar=new pn}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,Qt()}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:mn,defaultFillRule:"evenodd",defaultClipRule:"evenodd",onClick:e.onResetConnection}]},this.snackbar.presentItem(n)}}const Hs=(()=>".-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}
1.-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 Ws{constructor(){this.root=null,this.darkMode=Jt()}attach(){const e=document.documentElement;this.root=document.createElement("div"),this.root.className="-cbwsdk-css-reset",e.appendChild(this.root),Qt()}present(e){this.render(e)}clear(){this.render(null)}render(e){this.root&&(Oe(null,this.root),e&&Oe(g(Bs,Object.assign({},e,{onDismiss:()=>{this.clear()},darkMode:this.darkMode})),this.root))}}const Bs=({title:t,buttonText:e,darkMode:n,onButtonClick:s,onDismiss:i})=>{const r=n?"dark":"light";return g(gn,{darkMode:n},g("div",{class:"-cbwsdk-redirect-dialog"},g("style",null,Hs),g("div",{class:"-cbwsdk-redirect-dialog-backdrop",onClick:i}),g("div",{class:ee("-cbwsdk-redirect-dialog-box",r)},g("p",null,t),g("button",{onClick:s},e))))},qs="https://keys.coinbase.com/connect",Ks="https://rpc.wallet.coinbase.com",vt="https://www.walletlink.org",Vs="https://go.cb-w.com/walletlink";class kt{constructor(){this.attached=!1,this.redirectDialog=new Ws}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(Vs);n.searchParams.append("redirect_url",vs().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.redirectToCoinbaseWallet(e),setTimeout(()=>{this.redirectDialog.present({title:"Redirecting to Coinbase Wallet...",buttonText:"Open",onButtonClick:()=>{this.redirectToCoinbaseWallet(e)}})},99)}showConnecting(e){return()=>{this.redirectDialog.clear()}}}class O{constructor(e){this.chainCallbackParams={chainId:"",jsonRpcUrl:""},this.isMobileWeb=ks(),this.linkedUpdated=r=>{this.isLinked=r;const a=this.storage.getItem(Re);if(r&&(this._session.linked=r),this.isUnlinkedErrorState=!1,a){const o=a.split(" "),c=this.storage.getItem("IsStandaloneSigning")==="true";o[0]!==""&&!r&&this._session.linked&&!c&&(this.isUnlinkedErrorState=!0)}},this.metadataUpdated=(r,a)=>{this.storage.setItem(r,a)},this.chainUpdated=(r,a)=>{this.chainCallbackParams.chainId===r&&this.chainCallbackParams.jsonRpcUrl===a||(this.chainCallbackParams={chainId:r,jsonRpcUrl:a},this.chainCallback&&this.chainCallback(a,Number.parseInt(r,10)))},this.accountUpdated=r=>{this.accountsCallback&&this.accountsCallback([r]),O.accountRequestCallbackIds.size>0&&(Array.from(O.accountRequestCallbackIds.values()).forEach(a=>{this.invokeCallback(a,{method:"requestEthereumAccounts",result:[r]}
1)}),O.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:i}=this.subscribe();this._session=n,this.connection=i,this.relayEventManager=new ws,this.ui=s,this.ui.attach()}subscribe(){const e=Z.load(this.storage)||Z.create(this.storage),{linkAPIUrl:n}=this,s=new bs({session:e,linkAPIUrl:n,listener:this}),i=this.isMobileWeb?new kt:new Us;return s.connect(),{session:e,ui:i,connection:s}}resetAndReload(){this.connection.destroy().then(()=>{const e=Z.load(this.storage);(e==null?void 0:e.id)===this._session.id&&P.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:te(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:te(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:te(e,!0),chainId:n}})}getWalletLinkSession(){return this._session}sendRequest(e){let n=null;const s=q(8),i=r=>{this.publishWeb3RequestCanceledEvent(s),this.handleErrorResponse(s,e.method,r),n==null||n()};return new Promise((r,a)=>{n=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:i,onResetConnection:this.resetAndReload}),this.relayEventManager.callbacks.set(s,o=>{if(n==null||n(),C(o))return a(new Error(o.errorMessage));r(o)}),this.publishWeb3RequestEvent(s,e)})}publishWeb3RequestEvent(e,n){const s={type:"WEB3_REQUEST",id:e,request:n};this.publishEvent("Web3Request",s,!0).then(i=>{}).catch(i=>{this.handleWeb3ResponseMessage(s.id,{method:n.method,errorMessage:i.message})}),this.isMobileWeb&&this.openCoinbaseWalletDeeplink(n.method)}openCoinbaseWalletDeeplink(e){if(this.ui instanceof kt)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"){O.accountRequestCallbackIds.forEach(s=>this.invokeCallback(s,n)),O.accountRequestCallbackIds.clear();return}this.invokeCallback(e,n)}handleErrorResponse(e,n,s){var i;const r=(i=s==null?void 0:s.message)!==null&&i!==void 0?i:"Unspecified error message.";this.handleWeb3ResponseMessage(e,{method:n,errorMessage:r})}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}},i=q(8);return new Promise((r,a)=>{this.relayEventManager.callbacks.set(i,o=>{if(C(o))return a(new Error(o.errorMessage));r(o)}),O.accountRequestCallbackIds.add(i),this.publishWeb3RequestEvent(i,s)})}watchAsset(e,n,s,i,r,a){const o={method:"watchAsset",params:{type:e,options:{address:n,symbol:s,decimals:i,image:r},chainId:a}};let c=null;const d=q(8),h=l=>{this.publishWeb3RequestCanceledEvent(d),this.handleErrorResponse(d,o.method,l),c==null||c()};return c=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:h,onResetConnection:this.resetAndReload}),new Promise((l,u)=>{this.relayEventManager.callbacks.set(d,f=>{if(c==null||c(),C(f))return u(new Error(f.errorMessage));l(f)}),this.publishWeb3RequestEvent(d,o)})}addEthereumChain(e,n,s,i,r,a){const o={method:"addEthereumChain",params:{chainId:e,rpcUrls:n,blockExplorerUrls:i,chainName:r,iconUrls:s,nativeCurrency:a}};let c=null;const d=q(8),h=l=>{this.publishWeb3RequestCanceledEvent(d),this.handleErrorResponse(d,o.method,l),c==null||c()};return c=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:h,onResetConnection:this.resetAndReload}),new Promise((l,u)=>{this.relayEventManager.callbacks.set(d,f=>{if(c==null||c(),C(f))return u(new Error(f.errorMessage));l(f)}),this.publishWeb3RequestEvent(d,o)})}switchEthereumChain(e,n){const s={method:"switchEthereumChain",params:Object.assign({chainId:e},{address:n})};let i=null;const r=q(8),a=o=>{this.publishWeb3RequestCanceledEvent(r),this.handleErrorResponse(r,s.method,o),i==null||i()};return i=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:a,onResetConnection:this.resetAndReload}),new Promise((o,c)=>{this.relayEventManager.callbacks.set(r,d=>{if(i==null||i(),C(d)&&d.errorCode)return c(p.provider.custom({code:d.errorCode,message:"Unrecognized chain ID. Try adding the chain using addEthereumChain first."}));if(C(d))return c(new Error(d.errorMessage));o(d)}),this.publishWeb3RequestEvent(r,s)})}}O.accountRequestCallbackIds=new Set;const Et="DefaultChainId",Ct="DefaultJsonRpcUrl";class _n{constructor(e){this._relay=null,this._addresses=[],this.metadata=e.metadata,this._storage=new P("walletlink",vt),this.callback=e.callback||null;const n=this._storage.getItem(Re);
1if(n){const s=n.split(" ");s[0]!==""&&(this._addresses=s.map(i=>W(i)))}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(Ct))!==null&&e!==void 0?e:void 0}set jsonRpcUrl(e){this._storage.setItem(Ct,e)}updateProviderInfo(e,n){var s;this.jsonRpcUrl=e;const i=this.getChainId();this._storage.setItem(Et,n.toString(10)),ne(n)!==i&&((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 p.rpc.invalidParams("Type is required");if((n==null?void 0:n.type)!=="ERC20")throw p.rpc.invalidParams(`Asset of type '${n.type}' is not supported`);if(!(n!=null&&n.options))throw p.rpc.invalidParams("Options are required");if(!(n!=null&&n.options.address))throw p.rpc.invalidParams("Address is required");const s=this.getChainId(),{address:i,symbol:r,image:a,decimals:o}=n.options,d=await this.initializeRelay().watchAsset(n.type,i,r,o,a,s==null?void 0:s.toString());return C(d)?!1:!!d.result}async addEthereumChain(e){var n,s;const i=e[0];if(((n=i.rpcUrls)===null||n===void 0?void 0:n.length)===0)throw p.rpc.invalidParams("please pass in at least 1 rpcUrl");if(!i.chainName||i.chainName.trim()==="")throw p.rpc.invalidParams("chainName is a required field");if(!i.nativeCurrency)throw p.rpc.invalidParams("nativeCurrency is a required field");const r=Number.parseInt(i.chainId,16);if(r===this.getChainId())return!1;const a=this.initializeRelay(),{rpcUrls:o=[],blockExplorerUrls:c=[],chainName:d,iconUrls:h=[],nativeCurrency:l}=i,u=await a.addEthereumChain(r.toString(),o,h,c,d,l);if(C(u))return!1;if(((s=u.result)===null||s===void 0?void 0:s.isApproved)===!0)return this.updateProviderInfo(o[0],r),null;throw p.rpc.internal("unable to add ethereum chain")}async switchEthereumChain(e){const n=e[0],s=Number.parseInt(n.chainId,16),r=await this.initializeRelay().switchEthereumChain(s.toString(10),this.selectedAddress||void 0);if(C(r))throw r;const a=r.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 i=e.map(r=>W(r));JSON.stringify(i)!==JSON.stringify(this._addresses)&&(this._addresses=i,(s=this.callback)===null||s===void 0||s.call(this,"accountsChanged",i),this._storage.setItem(Re,i.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 p.rpc.internal("No RPC URL set for chain");return Ve(e,this.jsonRpcUrl)}}_ensureKnownAddress(e){const n=W(e);if(!this._addresses.map(i=>W(i)).includes(n))throw new Error("Unknown Ethereum address")}_prepareTransactionParams(e){const n=e.from?W(e.from):this.selectedAddress;if(!n)throw new Error("Ethereum address is unavailable");this._ensureKnownAddress(n);const s=e.to?W(e.to):null,i=e.value!=null?X(e.value):BigInt(0),r=e.data?Le(e.data):Buffer.alloc(0),a=e.nonce!=null?ne(e.nonce):null,o=e.gasPrice!=null?X(e.gasPrice):null,c=e.maxFeePerGas!=null?X(e.maxFeePerGas):null,d=e.maxPriorityFeePerGas!=null?X(e.maxPriorityFeePerGas):null,h=e.gas!=null?X(e.gas):null,l=e.chainId?ne(e.chainId):this.getChainId();return{fromAddress:n,toAddress:s,weiValue:i,data:r,nonce:a,gasPriceInWei:o,maxFeePerGas:c,maxPriorityFeePerGas:d,gasLimit:h,chainId:l}}async ecRecover(e){const{method:n,params:s}=e;if(!Array.isArray(s))throw p.rpc.invalidParams();const r=await this.initializeRelay().sendRequest({method:"ethereumAddressFromSignedMessage",params:{message:Ee(s[0]),signature:Ee(s[1]),addPrefix:n==="personal_ecRecover"}});if(C(r))throw r;return r.result}getChainId(){var e;return Number.parseInt((e=this._storage.getItem(Et))!==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 i=await this.initializeRelay().requestEthereumAccounts();if(C(i))throw i;if(!i.result)throw new Error("accounts received is empty");return this._setAddresses(i.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 p.rpc.invalidParams();const n=e[1],s=e[0];this._ensureKnownAddress(n);const r=await this.initializeRelay().sendRequest({method:"signEthereumMessage",params:{address:W(n),message:Ee(s),addPrefix:!0,typedDataJson:null}});if(C(r))throw r;return r.result}async _eth_signTransaction(e){const n=this._prepareTransactionParams(e[0]||{}),i=await this.initializeRelay().signEthereumTransaction(n);if(C(i))throw i;return i.result}async _eth_sendRawTransaction(e){const n=Le(e[0]),i=await this.initializeRelay().submitEthereumTransaction(n,this.getChainId());if(C(i))throw i;return i.result}async _eth_sendTransaction(e){const n=this._prepareTransactionParams(e[0]||{}),i=await this.initializeRelay().signAndSubmitEthereumTransaction(n);if(C(i))throw i;return i.result}async signTypedData(e){const{method:n,params:s}=e;if(!Array.isArray(s))throw p.rpc.invalidParams();const i=d=>{const h={eth_signTypedData_v1:ce.hashForSignTypedDataLegacy,eth_signTypedData_v3:ce.hashForSignTypedData_v3,eth_signTypedData_v4:ce.hashForSignTypedData_v4,eth_signTypedData:ce.hashForSignTypedData_v4};return te(h[n]({data:Un(d)}),!0)},r=s[n==="eth_signTypedData_v1"?1:0],a=s[n==="eth_signTypedData_v1"?0:1];this._ensureKnownAddress(r);const c=await this.initializeRelay().sendRequest({method:"signEthereumMessage",params:{address:W(r),message:i(a),typedDataJson:JSON.stringify(a,null,2),addPrefix:!1}});if(C(c))throw c;return c.result}initializeRelay(){return this._relay||(this._relay=new O({linkAPIUrl:vt,storage:this._storage,metadata:this.metadata,accountsCallback:this._setAddresses.bind(this),chainCallback:this.updateProviderInfo.bind(this)})),this._relay}}const bn="SignerType",wn=new P("CBWSDK","SignerConfigurator");function zs(){return wn.getItem(bn)}function Fs(t){wn.setItem(bn,t)}async function $s(t){const{communicator:e,metadata:n,handshakeRequest:s,callback:i}=t;Gs(e,n,i).catch(()=>{});const r={id:crypto.randomUUID(),event:"selectSignerType",data:Object.assign(Object.assign({},t.preference),{handshakeRequest:s})},{data:a}=await e.postRequestAndWaitForResponse(r);return a}function Zs(t){const{signerType:e,metadata:n,communicator:s,callback:i}=t;switch(e){case"scw":return new Qn({metadata:n,callback:i,communicator:s});case"walletlink":return new _n({metadata:n,callback:i})}}async function Gs(t,e,n){await t.onMessage(({event:i})=>i==="WalletLinkSessionRequest");const s=new _n({metadata:e,callback:n});
1t.postMessage({event:"WalletLinkUpdate",data:{session:s.getSession()}}),await s.handshake(),t.postMessage({event:"WalletLinkUpdate",data:{connected:!0}})}const Ys=`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. 2 3Please see https://www.smartwallet.dev/guides/tips/popup-tips#cross-origin-opener-policy for more information.`,Js=()=>{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(Ys)}catch(e){console.error("Error checking Cross-Origin-Opener-Policy:",e.message),t="error"}}}},{checkCrossOriginOpenerPolicy:yn,getCrossOriginOpenerPolicy:Qs}=Js(),It=420,St=540,Xs={isRed:!1,info:"Retry",svgWidth:"10",svgHeight:"11",path:mn,defaultFillRule:"evenodd",defaultClipRule:"evenodd"},ei="Popup was blocked. Try again.";let de=null;function ti(t){const e=(window.innerWidth-It)/2+window.screenX,n=(window.innerHeight-St)/2+window.screenY;si(t);function s(){const r=`wallet_${crypto.randomUUID()}`,a=window.open(t,r,`width=${It}, height=${St}, left=${e}, top=${n}`);return a==null||a.focus(),a||null}let i=s();if(!i){const r=ii();return new Promise((a,o)=>{r.presentItem({autoExpand:!0,message:ei,menuItems:[Object.assign(Object.assign({},Xs),{onClick:()=>{i=s(),i?a(i):o(p.rpc.internal("Popup window was blocked")),r.clear()}})]})})}return Promise.resolve(i)}function ni(t){t&&!t.closed&&t.close()}function si(t){const e={sdkName:Ht,sdkVersion:Y,origin:window.location.origin,coop:Qs()};for(const[n,s]of Object.entries(e))t.searchParams.append(n,s.toString())}function ii(){if(!de){const t=document.createElement("div");t.className="-cbwsdk-css-reset",document.body.appendChild(t),de=new pn,de.attach(t)}return de}class ri{constructor({url:e=qs,metadata:n,preference:s}){this.popup=null,this.listeners=new Map,this.postMessage=async i=>{(await this.waitForPopupLoaded()).postMessage(i,this.url.origin)},this.postRequestAndWaitForResponse=async i=>{const r=this.onMessage(({requestId:a})=>a===i.id);return this.postMessage(i),await r},this.onMessage=async i=>new Promise((r,a)=>{const o=c=>{if(c.origin!==this.url.origin)return;const d=c.data;i(d)&&(r(d),window.removeEventListener("message",o),this.listeners.delete(o))};window.addEventListener("message",o),this.listeners.set(o,{reject:a})}),this.disconnect=()=>{ni(this.popup),this.popup=null,this.listeners.forEach(({reject:i},r)=>{i(p.provider.userRejectedRequest("Request rejected")),window.removeEventListener("message",r)}),this.listeners.clear()},this.waitForPopupLoaded=async()=>this.popup&&!this.popup.closed?(this.popup.focus(),this.popup):(this.popup=await ti(this.url),this.onMessage(({event:i})=>i==="PopupUnload").then(this.disconnect).catch(()=>{}),this.onMessage(({event:i})=>i==="PopupLoaded").then(i=>{this.postMessage({requestId:i.id,data:{version:Y,metadata:this.metadata,preference:this.preference,location:window.location.toString()}})}).then(()=>{if(!this.popup)throw p.rpc.internal();return this.popup})),this.url=new URL(e),this.metadata=n,this.preference=s}}function ai(t){const e=Nn(oi(t),{shouldIncludeStack:!0}),n=new URL("https://docs.cloud.coinbase.com/wallet-sdk/docs/errors");return n.searchParams.set("version",Y),n.searchParams.set("code",e.code.toString()),n.searchParams.set("message",e.message),Object.assign(Object.assign({},e),{docUrl:n.href})}function oi(t){var e;if(typeof t=="string")return{message:t,code:w.rpc.internal};if(C(t)){const n=t.errorMessage,s=(e=t.errorCode)!==null&&e!==void 0?e:n.match(/(denied|rejected)/i)?w.provider.userRejectedRequest:void 0;return Object.assign(Object.assign({},t),{message:n,code:s,data:{method:t.method}})}return t}class ci extends xn{}var li=globalThis&&globalThis.__rest||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 i=0,s=Object.getOwnPropertySymbols(t);i<s.length;i++)e.indexOf(s[i])<0&&Object.prototype.propertyIsEnumerable.call(t,s[i])&&(n[s[i]]=t[s[i]]);return n};class vn extends ci{constructor(e){var{metadata:n}=e,s=e.preference,{keysUrl:i}=s,r=li(s,["keysUrl"]);super(),this.signer=null,this.isCoinbaseWallet=!0,this.metadata=n,this.preference=r,this.communicator=new ri({url:i,metadata:n,preference:r});const a=zs();a&&(this.signer=this.initSigner(a))}async request(e){try{if(Jn(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,Fs(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 Ve(e,Ks);case"net_version":return 1;case"eth_chainId":return B(1);default:throw p.provider.unauthorized("Must call 'eth_requestAccounts' before other methods")}return await this.signer.request(e)}catch(n){const{code:s}=n;return s===w.provider.unauthorized&&this.disconnect(),Promise.reject(ai(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,P.clearAll(),this.emit
3("disconnect",p.provider.disconnected("User initiated disconnection"))}requestSignerSelection(e){return $s({communicator:this.communicator,preference:this.preference,metadata:this.metadata,handshakeRequest:e,callback:this.emit.bind(this)})}initSigner(e){return Zs({signerType:e,metadata:this.metadata,communicator:this.communicator,callback:this.emit.bind(this)})}}function kn(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")}}class gi{constructor(e){this.metadata={appName:e.appName||"Dapp",appLogoUrl:e.appLogoUrl||Wn(),appChainIds:e.appChainIds||[]},this.storeLatestVersion(),yn()}makeWeb3Provider(e={options:"all"}){var n;kn(e);const s={metadata:this.metadata,preference:e};return(n=Wt(s))!==null&&n!==void 0?n:new vn(s)}getCoinbaseWalletLogo(e,n=240){return Pn(e,n)}storeLatestVersion(){new P("CBWSDK").setItem("VERSION",Y)}}function di(t){var e;const n={metadata:t.metadata,preference:t.preference};return(e=Wt(n))!==null&&e!==void 0?e:new vn(n)}const hi={options:"all"};function mi(t){var e;new P("CBWSDK").setItem("VERSION",Y),yn();const s={metadata:{appName:t.appName||"Dapp",appLogoUrl:t.appLogoUrl||"",appChainIds:t.appChainIds||[]},preference:Object.assign(hi,(e=t.preference)!==null&&e!==void 0?e:{})};kn(s.preference);let i=null;return{getProvider:()=>(i||(i=di(s)),i)}}export{gi as CoinbaseWalletSDK,mi as createCoinbaseWalletSDK,gi as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.