mirror of
https://github.com/logos-messaging/OpChan.git
synced 2026-01-03 05:13:09 +00:00
9 lines
337 KiB
JavaScript
9 lines
337 KiB
JavaScript
import{B as Nn,_ as J,h as Zr,y as jo}from"./hooks.module-Dz_XB4AG.js";import{q as Ge,aT as Bn,aU as Ya,z as ce,aV as Ve,o as je,aW as vr,aP as oe,aX as Yr,aY as Qa,A as Te,l as Xa,aZ as W,a_ as Se,a$ as pn,b0 as Yt,b1 as es,B as D,b2 as Qr,b3 as ts,n as M,b4 as ns,b5 as Mo,b6 as Do,b7 as Ae,b8 as kr,b9 as rs,ba as Xr,bb as Uo,bc as Fo,p as Ke,bd as as,be as xr,bf as Je,bg as De,bh as ss,bi as $o,bj as Er,t as ct,I as Go,bk as de,bl as is,bm as Ho,r as zo,u as qo,y as Wo,bn as Vo,bo as Ko,bp as Jo,bq as gt,br as ea,bs as Zo,bt as Yo,bu as Qo,bv as Qt,bw as mn,bx as os,by as Xo,bz as cs,bA as ec,bB as tc,bC as nc,bD as rc,bE as ac,bF as Ln,bG as Sr,bH as sc,bI as us,bJ as ic,bK as oc,bL as ds,bM as ls,bN as cc,bO as he,m as fs,bP as ps,s as ut,bQ as dt,bR as Bt,bS as xt,bT as Ar,bU as ms,bV as hs,bW as ys,bX as _r,bY as gs,bZ as uc,b_ as ta,b$ as hn,c0 as yn,c1 as bs,j as Ir,c2 as dc,c3 as lc,aQ as Pr,c4 as fc,c5 as pc,c6 as Xt,c7 as mc,c8 as ws,c9 as hc,ca as yc,cb as gc,cc as bc,cd as wc,ce as vc,cf as kc,cg as xc,ch as Ec,ci as Sc,cj as vs,ck as Ac,cl as _c,cm as Ic,cn as na,h as Pc,co as Oc,cp as Cc,cq as Tc,cr as Nc,cs as Bc,ct as Lc,cu as ks,cv as Rc,ae as jc,cw as Mc,ad as nt,cx as xs,cy as Dc,cz as en,cA as ra,cB as Uc,cC as pe,cD as Fc,cE as $c,cF as Rn,cG as Gc,cH as Hc,cI as zc,cJ as qc,cK as Wc,cL as gn,cM as Mt,cN as aa,cO as sa,cP as Vc,af as Kc,cQ as Jc,cR as Zc,ai as Es,cS as Yc,cT as ia,cU as Qc,cV as Xc,cW as eu,cX as tu,cY as nu,cZ as Ss,v as ru,c_ as oa,g as ca,c$ as As,d0 as au}from"./index-Cr5N_0pd.js";import{h as Lt}from"./hashTypedData-D0Cx__mD.js";function _s(e){if(e.length!==66||e.indexOf("[")!==0||e.indexOf("]")!==65)return null;const t=`0x${e.slice(1,65)}`;return Ge(t)?t:null}function jn(e){let t=new Uint8Array(32).fill(0);if(!e)return Bn(t);const n=e.split(".");for(let r=n.length-1;r>=0;r-=1){const a=_s(n[r]),s=a?Ya(a):ce(Ve(n[r]),"bytes");t=ce(je([t,s]),"bytes")}return Bn(t)}function su(e){return`[${e.slice(2)}]`}function iu(e){const t=new Uint8Array(32).fill(0);return e?_s(e)||ce(Ve(e)):Bn(t)}function Or(e){const t=e.replace(/^\.|\.$/gm,"");if(t.length===0)return new Uint8Array(1);const n=new Uint8Array(Ve(t).byteLength+2);let r=0;const a=t.split(".");for(let s=0;s<a.length;s++){let i=Ve(a[s]);i.byteLength>255&&(i=Ve(su(iu(a[s])))),n[r]=i.length,n.set(i,r+1),r+=i.length+1}return n.byteLength!==r+1?n.slice(0,r+1):n}async function ou(e,t){const{blockNumber:n,blockTag:r,coinType:a,name:s,gatewayUrls:i,strict:o}=t,{chain:c}=e,u=(()=>{if(t.universalResolverAddress)return t.universalResolverAddress;if(!c)throw new Error("client chain not configured. universalResolverAddress is required.");return vr({blockNumber:n,chain:c,contract:"ensUniversalResolver"})})(),d=c?.ensTlds;if(d&&!d.some(p=>s.endsWith(p)))return null;const l=a!=null?[jn(s),BigInt(a)]:[jn(s)];try{const p=oe({abi:Yr,functionName:"addr",args:l}),f={address:u,abi:Qa,functionName:"resolveWithGateways",args:[Te(Or(s)),p,i??[Xa]],blockNumber:n,blockTag:r},g=await W(e,Se,"readContract")(f);if(g[0]==="0x")return null;const h=pn({abi:Yr,args:l,functionName:"addr",data:g[0]});return h==="0x"||Yt(h)==="0x00"?null:h}catch(p){if(o)throw p;if(es(p))return null;throw p}}class cu extends D{constructor({data:t}){super("Unable to extract image from metadata. The metadata may be malformed or invalid.",{metaMessages:["- Metadata must be a JSON object with at least an `image`, `image_url` or `image_data` property.","",`Provided data: ${JSON.stringify(t)}`],name:"EnsAvatarInvalidMetadataError"})}}class bt extends D{constructor({reason:t}){super(`ENS NFT avatar URI is invalid. ${t}`,{name:"EnsAvatarInvalidNftUriError"})}}class Cr extends D{constructor({uri:t}){super(`Unable to resolve ENS avatar URI "${t}". The URI may be malformed, invalid, or does not respond with a valid image.`,{name:"EnsAvatarUriResolutionError"})}}class uu extends D{constructor({namespace:t}){super(`ENS NFT avatar namespace "${t}" is not supported. Must be "erc721" or "erc1155".`,{name:"EnsAvatarUnsupportedNamespaceError"})}}const du=/(?<protocol>https?:\/\/[^/]*|ipfs:\/|ipns:\/|ar:\/)?(?<root>\/)?(?<subpath>ipfs\/|ipns\/)?(?<target>[\w\-.]+)(?<subtarget>\/.*)?/,lu=/^(Qm[1-9A-HJ-NP-Za-km-z]{44,}|b[A-Za-z2-7]{58,}|B[A-Z2-7]{58,}|z[1-9A-HJ-NP-Za-km-z]{48,}|F[0-9A-F]{50,})(\/(?<target>[\w\-.]+))?(?<subtarget>\/.*)?$/,fu=/^data:([a-zA-Z\-/+]*);base64,([^"].*)/,pu=/^data:([a-zA-Z\-/+]*)?(;[a-zA-Z0-9].*?)?(,)/;async function mu(e){try{const t=await fetch(e,{method:"HEAD"});return t.status===200?t.headers.get("content-type")?.startsWith("image/"):!1}catch(t){return typeof t=="object"&&typeof t.response<"u"||!Object.hasOwn(globalThis,"Image")?!1:new Promise(n=>{const r=new Image;r.onload=()=>{n(!0)},r.onerror=()=>{n(!1)},r.src=e})}}function ua(e,t){return e?e.endsWith("/")?e.slice(0,-1):e:t}function Is({uri:e,gatewayUrls:t}){const n=fu.test(e);if(n)return{uri:e,isOnChain:!0,isEncoded:n};const r=ua(t?.ipfs,"https://ipfs.io"),a=ua(t?.arweave,"https://arweave.net"),s=e.match(du),{protocol:i,subpath:o,target:c,subtarget:u=""}=s?.groups||{},d=i==="ipns:/"||o==="ipns/",l=i==="ipfs:/"||o==="ipfs/"||lu.test(e);if(e.startsWith("http")&&!d&&!l){let f=e;return t?.arweave&&(f=e.replace(/https:\/\/arweave.net/g,t?.arweave)),{uri:f,isOnChain:!1,isEncoded:!1}}if((d||l)&&c)return{uri:`${r}/${d?"ipns":"ipfs"}/${c}${u}`,isOnChain:!1,isEncoded:!1};if(i==="ar:/"&&c)return{uri:`${a}/${c}${u||""}`,isOnChain:!1,isEncoded:!1};let p=e.replace(pu,"");if(p.startsWith("<svg")&&(p=`data:image/svg+xml;base64,${btoa(p)}`),p.startsWith("data:")||p.startsWith("{"))return{uri:p,isOnChain:!0,isEncoded:!1};throw new Cr({uri:e})}function Ps(e){if(typeof e!="object"||!("image"in e)&&!("image_url"in e)&&!("image_data"in e))throw new cu({data:e});return e.image||e.image_url||e.image_data}async function hu({gatewayUrls:e,uri:t}){try{const n=await fetch(t).then(a=>a.json());return await Tr({gatewayUrls:e,uri:Ps(n)})}catch{throw new Cr({uri:t})}}async function Tr({gatewayUrls:e,uri:t}){const{uri:n,isOnChain:r}=Is({uri:t,gatewayUrls:e});if(r||await mu(n))return n;throw new Cr({uri:t})}function yu(e){let t=e;t.startsWith("did:nft:")&&(t=t.replace("did:nft:","").replace(/_/g,"/"));const[n,r,a]=t.split("/"),[s,i]=n.split(":"),[o,c]=r.split(":");if(!s||s.toLowerCase()!=="eip155")throw new bt({reason:"Only EIP-155 supported"});if(!i)throw new bt({reason:"Chain ID not found"});if(!c)throw new bt({reason:"Contract address not found"});if(!a)throw new bt({reason:"Token ID not found"});if(!o)throw new bt({reason:"ERC namespace not found"});return{chainID:Number.parseInt(i,10),namespace:o.toLowerCase(),contractAddress:c,tokenID:a}}async function gu(e,{nft:t}){if(t.namespace==="erc721")return Se(e,{address:t.contractAddress,abi:[{name:"tokenURI",type:"function",stateMutability:"view",inputs:[{name:"tokenId",type:"uint256"}],outputs:[{name:"",type:"string"}]}],functionName:"tokenURI",args:[BigInt(t.tokenID)]});if(t.namespace==="erc1155")return Se(e,{address:t.contractAddress,abi:[{name:"uri",type:"function",stateMutability:"view",inputs:[{name:"_id",type:"uint256"}],outputs:[{name:"",type:"string"}]}],functionName:"uri",args:[BigInt(t.tokenID)]});throw new uu({namespace:t.namespace})}async function bu(e,{gatewayUrls:t,record:n}){return/eip155:/i.test(n)?wu(e,{gatewayUrls:t,record:n}):Tr({uri:n,gatewayUrls:t})}async function wu(e,{gatewayUrls:t,record:n}){const r=yu(n),a=await gu(e,{nft:r}),{uri:s,isOnChain:i,isEncoded:o}=Is({uri:a,gatewayUrls:t});if(i&&(s.includes("data:application/json;base64,")||s.startsWith("{"))){const u=o?atob(s.replace("data:application/json;base64,","")):s,d=JSON.parse(u);return Tr({uri:Ps(d),gatewayUrls:t})}let c=r.tokenID;return r.namespace==="erc1155"&&(c=c.replace("0x","").padStart(64,"0")),hu({gatewayUrls:t,uri:s.replace(/(?:0x)?{id}/,c)})}async function Os(e,t){const{blockNumber:n,blockTag:r,key:a,name:s,gatewayUrls:i,strict:o}=t,{chain:c}=e,u=(()=>{if(t.universalResolverAddress)return t.universalResolverAddress;if(!c)throw new Error("client chain not configured. universalResolverAddress is required.");return vr({blockNumber:n,chain:c,contract:"ensUniversalResolver"})})(),d=c?.ensTlds;if(d&&!d.some(l=>s.endsWith(l)))return null;try{const l={address:u,abi:Qa,args:[Te(Or(s)),oe({abi:Qr,functionName:"text",args:[jn(s),a]}),i??[Xa]],functionName:"resolveWithGateways",blockNumber:n,blockTag:r},f=await W(e,Se,"readContract")(l);if(f[0]==="0x")return null;const y=pn({abi:Qr,functionName:"text",data:f[0]});return y===""?null:y}catch(l){if(o)throw l;if(es(l))return null;throw l}}async function vu(e,{blockNumber:t,blockTag:n,assetGatewayUrls:r,name:a,gatewayUrls:s,strict:i,universalResolverAddress:o}){const c=await W(e,Os,"getEnsText")({blockNumber:t,blockTag:n,key:"avatar",name:a,universalResolverAddress:o,gatewayUrls:s,strict:i});if(!c)return null;try{return await bu(e,{record:c,gatewayUrls:r})}catch{return null}}async function ku(e,t){const{blockNumber:n,blockTag:r,name:a}=t,{chain:s}=e,i=(()=>{if(t.universalResolverAddress)return t.universalResolverAddress;if(!s)throw new Error("client chain not configured. universalResolverAddress is required.");return vr({blockNumber:n,chain:s,contract:"ensUniversalResolver"})})(),o=s?.ensTlds;if(o&&!o.some(u=>a.endsWith(u)))throw new Error(`${a} is not a valid ENS TLD (${o?.join(", ")}) for chain "${s.name}" (id: ${s.id}).`);const[c]=await W(e,Se,"readContract")({address:i,abi:[{inputs:[{type:"bytes"}],name:"findResolver",outputs:[{type:"address"},{type:"bytes32"},{type:"uint256"}],stateMutability:"view",type:"function"}],functionName:"findResolver",args:[Te(Or(a))],blockNumber:n,blockTag:r});return c}async function Cs(e,t){const{account:n=e.account,blockNumber:r,blockTag:a="latest",blobs:s,data:i,gas:o,gasPrice:c,maxFeePerBlobGas:u,maxFeePerGas:d,maxPriorityFeePerGas:l,to:p,value:f,...y}=t,g=n?Ae(n):void 0;try{ts(t);const w=(typeof r=="bigint"?M(r):void 0)||a,E=e.chain?.formatters?.transactionRequest?.format,A=(E||ns)({...Mo(y,{format:E}),from:g?.address,blobs:s,data:i,gas:o,gasPrice:c,maxFeePerBlobGas:u,maxFeePerGas:d,maxPriorityFeePerGas:l,to:p,value:f}),I=await e.request({method:"eth_createAccessList",params:[A,w]});return{accessList:I.accessList,gasUsed:BigInt(I.gasUsed)}}catch(h){throw Do(h,{...t,account:g,chain:e.chain})}}async function xu(e){const t=kr(e,{method:"eth_newBlockFilter"}),n=await e.request({method:"eth_newBlockFilter"});return{id:n,request:t(n),type:"block"}}class Eu extends D{constructor(t){super(`Filter type "${t}" is not supported.`,{name:"FilterTypeNotSupportedError"})}}const da="/docs/contract/encodeEventTopics";function Rt(e){const{abi:t,eventName:n,args:r}=e;let a=t[0];if(n){const c=rs({abi:t,name:n});if(!c)throw new Xr(n,{docsPath:da});a=c}if(a.type!=="event")throw new Xr(void 0,{docsPath:da});const s=Uo(a),i=Fo(s);let o=[];if(r&&"inputs"in a){const c=a.inputs?.filter(d=>"indexed"in d&&d.indexed),u=Array.isArray(r)?r:Object.values(r).length>0?c?.map(d=>r[d.name])??[]:[];u.length>0&&(o=c?.map((d,l)=>Array.isArray(u[l])?u[l].map((p,f)=>la({param:d,value:u[l][f]})):typeof u[l]<"u"&&u[l]!==null?la({param:d,value:u[l]}):null)??[])}return[i,...o]}function la({param:e,value:t}){if(e.type==="string"||e.type==="bytes")return ce(Ya(t));if(e.type==="tuple"||e.type.match(/^(.*)\[(\d+)?\]$/))throw new Eu(e.type);return Ke([e],[t])}async function Ts(e,t){const{address:n,abi:r,args:a,eventName:s,fromBlock:i,strict:o,toBlock:c}=t,u=kr(e,{method:"eth_newFilter"}),d=s?Rt({abi:r,args:a,eventName:s}):void 0,l=await e.request({method:"eth_newFilter",params:[{address:n,fromBlock:typeof i=="bigint"?M(i):i,toBlock:typeof c=="bigint"?M(c):c,topics:d}]});return{abi:r,args:a,eventName:s,id:l,request:u(l),strict:!!o,type:"event"}}async function Ns(e,{address:t,args:n,event:r,events:a,fromBlock:s,strict:i,toBlock:o}={}){const c=a??(r?[r]:void 0),u=kr(e,{method:"eth_newFilter"});let d=[];c&&(d=[c.flatMap(f=>Rt({abi:[f],eventName:f.name,args:n}))],r&&(d=d[0]));const l=await e.request({method:"eth_newFilter",params:[{address:t,fromBlock:typeof s=="bigint"?M(s):s,toBlock:typeof o=="bigint"?M(o):o,...d.length?{topics:d}:{}}]});return{abi:c,args:n,eventName:r?r.name:void 0,fromBlock:s,id:l,request:u(l),strict:!!i,toBlock:o,type:"event"}}async function Su(e,t){const{abi:n,address:r,args:a,functionName:s,dataSuffix:i,...o}=t,c=oe({abi:n,args:a,functionName:s});try{return await W(e,as,"estimateGas")({data:`${c}${i?i.replace("0x",""):""}`,to:r,...o})}catch(u){const d=o.account?Ae(o.account):void 0;throw xr(u,{abi:n,address:r,args:a,docsPath:"/docs/contract/estimateContractGas",functionName:s,sender:d?.address})}}async function Au(e){const t=await e.request({method:"eth_blobBaseFee"});return BigInt(t)}async function _u(e,{blockHash:t,blockNumber:n,blockTag:r="latest"}={}){const a=n!==void 0?M(n):void 0;let s;return t?s=await e.request({method:"eth_getBlockTransactionCountByHash",params:[t]},{dedupe:!0}):s=await e.request({method:"eth_getBlockTransactionCountByNumber",params:[a||r]},{dedupe:!!a}),Je(s)}async function Nr(e,{address:t,blockHash:n,fromBlock:r,toBlock:a,event:s,events:i,args:o,strict:c}={}){const u=c??!1,d=i??(s?[s]:void 0);let l=[];d&&(l=[d.flatMap(g=>Rt({abi:[g],eventName:g.name,args:i?void 0:o}))],s&&(l=l[0]));let p;n?p=await e.request({method:"eth_getLogs",params:[{address:t,topics:l,blockHash:n}]}):p=await e.request({method:"eth_getLogs",params:[{address:t,topics:l,fromBlock:typeof r=="bigint"?M(r):r,toBlock:typeof a=="bigint"?M(a):a}]});const f=p.map(y=>De(y));return d?ss({abi:d,args:o,logs:f,strict:u}):f}async function Bs(e,t){const{abi:n,address:r,args:a,blockHash:s,eventName:i,fromBlock:o,toBlock:c,strict:u}=t,d=i?rs({abi:n,name:i}):void 0,l=d?void 0:n.filter(p=>p.type==="event");return W(e,Nr,"getLogs")({address:r,args:a,blockHash:s,event:d,events:l,fromBlock:o,toBlock:c,strict:u})}class Iu extends D{constructor({address:t}){super(`No EIP-712 domain found on contract "${t}".`,{metaMessages:["Ensure that:",`- The contract is deployed at the address "${t}".`,"- `eip712Domain()` function exists on the contract.","- `eip712Domain()` function matches signature to ERC-5267 specification."],name:"Eip712DomainNotFoundError"})}}async function Pu(e,t){const{address:n,factory:r,factoryData:a}=t;try{const[s,i,o,c,u,d,l]=await W(e,Se,"readContract")({abi:Ou,address:n,functionName:"eip712Domain",factory:r,factoryData:a});return{domain:{name:i,version:o,chainId:Number(c),verifyingContract:u,salt:d},extensions:l,fields:s}}catch(s){const i=s;throw i.name==="ContractFunctionExecutionError"&&i.cause.name==="ContractFunctionZeroDataError"?new Iu({address:n}):i}}const Ou=[{inputs:[],name:"eip712Domain",outputs:[{name:"fields",type:"bytes1"},{name:"name",type:"string"},{name:"version",type:"string"},{name:"chainId",type:"uint256"},{name:"verifyingContract",type:"address"},{name:"salt",type:"bytes32"},{name:"extensions",type:"uint256[]"}],stateMutability:"view",type:"function"}];function Cu(e){return{baseFeePerGas:e.baseFeePerGas.map(t=>BigInt(t)),gasUsedRatio:e.gasUsedRatio,oldestBlock:BigInt(e.oldestBlock),reward:e.reward?.map(t=>t.map(n=>BigInt(n)))}}async function Tu(e,{blockCount:t,blockNumber:n,blockTag:r="latest",rewardPercentiles:a}){const s=typeof n=="bigint"?M(n):void 0,i=await e.request({method:"eth_feeHistory",params:[M(t),s||r,a]},{dedupe:!!s});return Cu(i)}async function Nu(e,{filter:t}){const n=t.strict??!1,a=(await t.request({method:"eth_getFilterLogs",params:[t.id]})).map(s=>De(s));return t.abi?ss({abi:t.abi,logs:a,strict:n}):a}function Bu(e,t){if(e.length!==t.length)throw new $o({expectedLength:e.length,givenLength:t.length});const n=[];for(let r=0;r<e.length;r++){const a=e[r],s=t[r];n.push(Ls(a,s))}return Er(n)}function Ls(e,t,n=!1){if(e==="address"){const i=t;if(!ct(i))throw new Go({address:i});return de(i.toLowerCase(),{size:n?32:null})}if(e==="string")return is(t);if(e==="bytes")return t;if(e==="bool")return de(Ho(t),{size:n?32:1});const r=e.match(zo);if(r){const[i,o,c="256"]=r,u=Number.parseInt(c,10)/8;return M(t,{size:n?32:u,signed:o==="int"})}const a=e.match(qo);if(a){const[i,o]=a;if(Number.parseInt(o,10)!==(t.length-2)/2)throw new Wo({expectedSize:Number.parseInt(o,10),givenSize:(t.length-2)/2});return de(t,{dir:"right",size:n?32:null})}const s=e.match(Vo);if(s&&Array.isArray(t)){const[i,o]=s,c=[];for(let u=0;u<t.length;u++)c.push(Ls(o,t[u],!0));return c.length===0?"0x":Er(c)}throw new Ko(e)}function Lu(e){const{source:t}=e,n=new Map,r=new Jo(8192),a=new Map,s=({address:i,chainId:o})=>`${i}.${o}`;return{async consume({address:i,chainId:o,client:c}){const u=s({address:i,chainId:o}),d=this.get({address:i,chainId:o,client:c});this.increment({address:i,chainId:o});const l=await d;return await t.set({address:i,chainId:o},l),r.set(u,l),l},async increment({address:i,chainId:o}){const c=s({address:i,chainId:o}),u=n.get(c)??0;n.set(c,u+1)},async get({address:i,chainId:o,client:c}){const u=s({address:i,chainId:o});let d=a.get(u);return d||(d=(async()=>{try{const p=await t.get({address:i,chainId:o,client:c}),f=r.get(u)??0;return f>0&&p<=f?f+1:(r.delete(u),p)}finally{this.reset({address:i,chainId:o})}})(),a.set(u,d)),(n.get(u)??0)+await d},reset({address:i,chainId:o}){const c=s({address:i,chainId:o});n.delete(c),a.delete(c)}}}const Ru="0x6492649264926492649264926492649264926492649264926492649264926492";function Mn(e){return e.type==="function"?`function ${e.name}(${gt(e.inputs)})${e.stateMutability&&e.stateMutability!=="nonpayable"?` ${e.stateMutability}`:""}${e.outputs?.length?` returns (${gt(e.outputs)})`:""}`:e.type==="event"?`event ${e.name}(${gt(e.inputs)})`:e.type==="error"?`error ${e.name}(${gt(e.inputs)})`:e.type==="constructor"?`constructor(${gt(e.inputs)})${e.stateMutability==="payable"?" payable":""}`:e.type==="fallback"?`fallback() external${e.stateMutability==="payable"?" payable":""}`:"receive() external payable"}function fa(e){let t;if(typeof e=="string")t=ea(e);else{const n=Zo(e),r=e.length;for(let a=0;a<r;a++){const s=e[a];if(!Yo(s)){t=ea(s,n);break}}}if(!t)throw new Qo({signature:e});return t}function An(e){const{address:t,data:n,signature:r,to:a="hex"}=e,s=Er([Ke([{type:"address"},{type:"bytes"},{type:"bytes"}],[t,n,r]),Ru]);return a==="hex"?s:Qt(s)}function ju(e){return e.map(t=>({...t,value:BigInt(t.value)}))}function Mu(e){return{...e,balance:e.balance?BigInt(e.balance):void 0,nonce:e.nonce?Je(e.nonce):void 0,storageProof:e.storageProof?ju(e.storageProof):void 0}}async function Du(e,{address:t,blockNumber:n,blockTag:r,storageKeys:a}){const s=r??"latest",i=n!==void 0?M(n):void 0,o=await e.request({method:"eth_getProof",params:[t,a,i||s]});return Mu(o)}async function Uu(e,{address:t,blockNumber:n,blockTag:r="latest",slot:a}){const s=n!==void 0?M(n):void 0;return await e.request({method:"eth_getStorageAt",params:[t,a,s||r]})}async function Fu(e,{hash:t,transactionReceipt:n}){const[r,a]=await Promise.all([W(e,mn,"getBlockNumber")({}),t?W(e,os,"getTransaction")({hash:t}):void 0]),s=n?.blockNumber||a?.blockNumber;return s?r-s+1n:0n}async function Dn(e,t){const{blockNumber:n,blockTag:r=e.experimental_blockTag??"latest",blocks:a,returnFullTransactions:s,traceTransfers:i,validation:o}=t;try{const c=[];for(const p of a){const f=p.blockOverrides?Xo(p.blockOverrides):void 0,y=p.calls.map(h=>{const w=h,E=w.account?Ae(w.account):void 0,b=w.abi?oe(w):w.data,A={...w,data:w.dataSuffix?je([b||"0x",w.dataSuffix]):b,from:w.from??E?.address};return ts(A),ns(A)}),g=p.stateOverrides?cs(p.stateOverrides):void 0;c.push({blockOverrides:f,calls:y,stateOverrides:g})}const d=(typeof n=="bigint"?M(n):void 0)||r;return(await e.request({method:"eth_simulateV1",params:[{blockStateCalls:c,returnFullTransactions:s,traceTransfers:i,validation:o},d]})).map((p,f)=>({...ec(p),calls:p.calls.map((y,g)=>{const{abi:h,args:w,functionName:E,to:b}=a[f].calls[g],A=y.error?.data??y.returnData,I=BigInt(y.gasUsed),N=y.logs?.map(P=>De(P)),B=y.status==="0x1"?"success":"failure",j=h&&B==="success"&&A!=="0x"?pn({abi:h,data:A,functionName:E}):null,v=(()=>{if(B==="success")return;let P;if(y.error?.data==="0x"?P=new tc:y.error&&(P=new nc(y.error)),!!P)return xr(P,{abi:h??[],address:b??"0x",args:w,functionName:E??"<unknown>"})})();return{data:A,gasUsed:I,logs:N,status:B,...B==="success"?{result:j}:{error:v}}})}))}catch(c){const u=c,d=rc(u,{});throw d instanceof ac?u:d}}function Un(e){let t=!0,n="",r=0,a="",s=!1;for(let i=0;i<e.length;i++){const o=e[i];if(["(",")",","].includes(o)&&(t=!0),o==="("&&r++,o===")"&&r--,!!t){if(r===0){if(o===" "&&["event","function","error",""].includes(a))a="";else if(a+=o,o===")"){s=!0;break}continue}if(o===" "){e[i-1]!==","&&n!==","&&n!==",("&&(n="",t=!1);continue}a+=o,n+=o}}if(!s)throw new Sr("Unable to normalize signature.");return a}function Fn(e,t){const n=typeof e,r=t.type;switch(r){case"address":return Ln(e,{strict:!1});case"bool":return n==="boolean";case"function":return n==="string";case"string":return n==="string";default:return r==="tuple"&&"components"in t?Object.values(t.components).every((a,s)=>Fn(Object.values(e)[s],a)):/^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/.test(r)?n==="number"||n==="bigint":/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/.test(r)?n==="string"||e instanceof Uint8Array:/[a-z]+[1-9]{0,3}(\[[0-9]{0,}\])+$/.test(r)?Array.isArray(e)&&e.every(a=>Fn(a,{...t,type:r.replace(/(\[[0-9]{0,}\])$/,"")})):!1}}function Rs(e,t,n){for(const r in e){const a=e[r],s=t[r];if(a.type==="tuple"&&s.type==="tuple"&&"components"in a&&"components"in s)return Rs(a.components,s.components,n[r]);const i=[a.type,s.type];if(i.includes("address")&&i.includes("bytes20")?!0:i.includes("address")&&i.includes("string")?Ln(n[r],{strict:!1}):i.includes("address")&&i.includes("bytes")?Ln(n[r],{strict:!1}):!1)return i}}function js(e,t={}){const{prepare:n=!0}=t,r=Array.isArray(e)||typeof e=="string"?fa(e):e;return{...r,...n?{hash:rt(r)}:{}}}function $u(e,t,n){const{args:r=[],prepare:a=!0}=n??{},s=sc(t,{strict:!1}),i=e.filter(u=>s?u.type==="function"||u.type==="error"?Ms(u)===us(t,0,4):u.type==="event"?rt(u)===t:!1:"name"in u&&u.name===t);if(i.length===0)throw new $n({name:t});if(i.length===1)return{...i[0],...a?{hash:rt(i[0])}:{}};let o;for(const u of i){if(!("inputs"in u))continue;if(!r||r.length===0){if(!u.inputs||u.inputs.length===0)return{...u,...a?{hash:rt(u)}:{}};continue}if(!u.inputs||u.inputs.length===0||u.inputs.length!==r.length)continue;if(r.every((l,p)=>{const f="inputs"in u&&u.inputs[p];return f?Fn(l,f):!1})){if(o&&"inputs"in o&&o.inputs){const l=Rs(u.inputs,o.inputs,r);if(l)throw new Hu({abiItem:u,type:l[0]},{abiItem:o,type:l[1]})}o=u}}const c=(()=>{if(o)return o;const[u,...d]=i;return{...u,overloads:d}})();if(!c)throw new $n({name:t});return{...c,...a?{hash:rt(c)}:{}}}function Ms(e){return us(rt(e),0,4)}function Gu(e){const t=typeof e=="string"?e:Mn(e);return Un(t)}function rt(e){return typeof e!="string"&&"hash"in e&&e.hash?e.hash:ic(oc(Gu(e)))}class Hu extends Sr{constructor(t,n){super("Found ambiguous types in overloaded ABI Items.",{metaMessages:[`\`${t.type}\` in \`${Un(Mn(t.abiItem))}\`, and`,`\`${n.type}\` in \`${Un(Mn(n.abiItem))}\``,"","These types encode differently and cannot be distinguished at runtime.","Remove one of the ambiguous items in the ABI."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiItem.AmbiguityError"})}}class $n extends Sr{constructor({name:t,data:n,type:r="item"}){const a=t?` with name "${t}"`:n?` with data "${n}"`:"";super(`ABI ${r}${a} not found.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiItem.NotFoundError"})}}function zu(e,t){const{bytecode:n,args:r}=t;return ds(n,e.inputs?.length&&r?.length?ls(e.inputs,r):"0x")}function qu(e){return js(e)}function Wu(e,...t){const{overloads:n}=e,r=n?Vu([e,...n],e.name,{args:t[0]}):e,a=Ku(r),s=t.length>0?ls(r.inputs,t[0]):void 0;return s?ds(a,s):a}function Xe(e,t={}){return js(e,t)}function Vu(e,t,n){const r=$u(e,t,n);if(r.type!=="function")throw new $n({name:t,type:"function"});return r}function Ku(e){return Ms(e)}const Ju="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",we="0x0000000000000000000000000000000000000000",Zu="0x6080604052348015600e575f80fd5b5061016d8061001c5f395ff3fe608060405234801561000f575f80fd5b5060043610610029575f3560e01c8063f8b2cb4f1461002d575b5f80fd5b610047600480360381019061004291906100db565b61005d565b604051610054919061011e565b60405180910390f35b5f8173ffffffffffffffffffffffffffffffffffffffff16319050919050565b5f80fd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6100aa82610081565b9050919050565b6100ba816100a0565b81146100c4575f80fd5b50565b5f813590506100d5816100b1565b92915050565b5f602082840312156100f0576100ef61007d565b5b5f6100fd848285016100c7565b91505092915050565b5f819050919050565b61011881610106565b82525050565b5f6020820190506101315f83018461010f565b9291505056fea26469706673582212203b9fe929fe995c7cf9887f0bdba8a36dd78e8b73f149b17d2d9ad7cd09d2dc6264736f6c634300081a0033";async function Yu(e,t){const{blockNumber:n,blockTag:r,calls:a,stateOverrides:s,traceAssetChanges:i,traceTransfers:o,validation:c}=t,u=t.account?Ae(t.account):void 0;if(i&&!u)throw new D("`account` is required when `traceAssetChanges` is true");const d=u?zu(qu("constructor(bytes, bytes)"),{bytecode:cc,args:[Zu,Wu(Xe("function getBalance(address)"),[u.address])]}):void 0,l=i?await Promise.all(t.calls.map(async S=>{if(!S.data&&!S.abi)return;const{accessList:$}=await Cs(e,{account:u.address,...S,data:S.abi?oe(S):S.data});return $.map(({address:q,storageKeys:F})=>F.length>0?q:null)})).then(S=>S.flat().filter(Boolean)):[],p=await Dn(e,{blockNumber:n,blockTag:r,blocks:[...i?[{calls:[{data:d}],stateOverrides:s},{calls:l.map((S,$)=>({abi:[Xe("function balanceOf(address) returns (uint256)")],functionName:"balanceOf",args:[u.address],to:S,from:we,nonce:$})),stateOverrides:[{address:we,nonce:0}]}]:[],{calls:[...a,{}].map(S=>({...S,from:u?.address})),stateOverrides:s},...i?[{calls:[{data:d}]},{calls:l.map((S,$)=>({abi:[Xe("function balanceOf(address) returns (uint256)")],functionName:"balanceOf",args:[u.address],to:S,from:we,nonce:$})),stateOverrides:[{address:we,nonce:0}]},{calls:l.map((S,$)=>({to:S,abi:[Xe("function decimals() returns (uint256)")],functionName:"decimals",from:we,nonce:$})),stateOverrides:[{address:we,nonce:0}]},{calls:l.map((S,$)=>({to:S,abi:[Xe("function tokenURI(uint256) returns (string)")],functionName:"tokenURI",args:[0n],from:we,nonce:$})),stateOverrides:[{address:we,nonce:0}]},{calls:l.map((S,$)=>({to:S,abi:[Xe("function symbol() returns (string)")],functionName:"symbol",from:we,nonce:$})),stateOverrides:[{address:we,nonce:0}]}]:[]],traceTransfers:o,validation:c}),f=i?p[2]:p[0],[y,g,,h,w,E,b,A]=i?p:[],{calls:I,...N}=f,B=I.slice(0,-1)??[],j=y?.calls??[],v=g?.calls??[],P=[...j,...v].map(S=>S.status==="success"?he(S.data):null),x=h?.calls??[],m=w?.calls??[],k=[...x,...m].map(S=>S.status==="success"?he(S.data):null),C=(E?.calls??[]).map(S=>S.status==="success"?S.result:null),O=(A?.calls??[]).map(S=>S.status==="success"?S.result:null),L=(b?.calls??[]).map(S=>S.status==="success"?S.result:null),R=[];for(const[S,$]of k.entries()){const q=P[S];if(typeof $!="bigint"||typeof q!="bigint")continue;const F=C[S-1],ee=O[S-1],te=L[S-1],ne=S===0?{address:Ju,decimals:18,symbol:"ETH"}:{address:l[S-1],decimals:te||F?Number(F??1):void 0,symbol:ee??void 0};R.some(K=>K.token.address===ne.address)||R.push({token:ne,value:{pre:q,post:$,diff:$-q}})}return{assetChanges:R,block:N,results:B}}async function Qu(e,t){const{abi:n,address:r,args:a,dataSuffix:s,functionName:i,...o}=t,c=o.account?Ae(o.account):e.account,u=oe({abi:n,args:a,functionName:i});try{const{data:d}=await W(e,fs,"call")({batch:!1,data:`${u}${s?s.replace("0x",""):""}`,to:r,...o,account:c}),l=pn({abi:n,args:a,functionName:i,data:d||"0x"}),p=n.filter(f=>"name"in f&&f.name===t.functionName);return{result:l,request:{abi:p,address:r,args:a,dataSuffix:s,functionName:i,...o,account:c}}}catch(d){throw xr(d,{abi:n,address:r,args:a,docsPath:"/docs/contract/simulateContract",functionName:i,sender:c?.address})}}async function Xu(e,t){const{address:n,factory:r,factoryData:a,signature:s,message:i,primaryType:o,types:c,domain:u,...d}=t,l=Lt({message:i,primaryType:o,types:c,domain:u});return ps(e,{address:n,factory:r,factoryData:a,hash:l,signature:s,...d})}function ed(e,{blockTag:t=e.experimental_blockTag??"latest",emitMissed:n=!1,emitOnBegin:r=!1,onBlock:a,onError:s,includeTransactions:i,poll:o,pollingInterval:c=e.pollingInterval}){const u=typeof o<"u"?o:!(e.transport.type==="webSocket"||e.transport.type==="ipc"||e.transport.type==="fallback"&&(e.transport.transports[0].config.type==="webSocket"||e.transport.transports[0].config.type==="ipc")),d=i??!1;let l;return u?(()=>{const y=ut(["watchBlocks",e.uid,t,n,r,d,c]);return dt(y,{onBlock:a,onError:s},g=>Bt(async()=>{try{const h=await W(e,xt,"getBlock")({blockTag:t,includeTransactions:d});if(h.number!==null&&l?.number!=null){if(h.number===l.number)return;if(h.number-l.number>1&&n)for(let w=l?.number+1n;w<h.number;w++){const E=await W(e,xt,"getBlock")({blockNumber:w,includeTransactions:d});g.onBlock(E,l),l=E}}(l?.number==null||t==="pending"&&h?.number==null||h.number!==null&&h.number>l.number)&&(g.onBlock(h,l),l=h)}catch(h){g.onError?.(h)}},{emitOnBegin:r,interval:c}))})():(()=>{let y=!0,g=!0,h=()=>y=!1;return(async()=>{try{r&&W(e,xt,"getBlock")({blockTag:t,includeTransactions:d}).then(b=>{y&&g&&(a(b,void 0),g=!1)}).catch(s);const w=(()=>{if(e.transport.type==="fallback"){const b=e.transport.transports.find(A=>A.config.type==="webSocket"||A.config.type==="ipc");return b?b.value:e.transport}return e.transport})(),{unsubscribe:E}=await w.subscribe({params:["newHeads"],async onData(b){if(!y)return;const A=await W(e,xt,"getBlock")({blockNumber:b.result?.number,includeTransactions:d}).catch(()=>{});y&&(a(A,l),g=!1,l=A)},onError(b){s?.(b)}});h=E,y||h()}catch(w){s?.(w)}})(),()=>h()})()}function td(e,t){const{abi:n,address:r,args:a,batch:s=!0,eventName:i,fromBlock:o,onError:c,onLogs:u,poll:d,pollingInterval:l=e.pollingInterval,strict:p}=t;return(typeof d<"u"?d:typeof o=="bigint"?!0:!(e.transport.type==="webSocket"||e.transport.type==="ipc"||e.transport.type==="fallback"&&(e.transport.transports[0].config.type==="webSocket"||e.transport.transports[0].config.type==="ipc")))?(()=>{const h=p??!1,w=ut(["watchContractEvent",r,a,s,e.uid,i,l,h,o]);return dt(w,{onLogs:u,onError:c},E=>{let b;o!==void 0&&(b=o-1n);let A,I=!1;const N=Bt(async()=>{if(!I){try{A=await W(e,Ts,"createContractEventFilter")({abi:n,address:r,args:a,eventName:i,strict:h,fromBlock:o})}catch{}I=!0;return}try{let B;if(A)B=await W(e,_r,"getFilterChanges")({filter:A});else{const j=await W(e,mn,"getBlockNumber")({});b&&b<j?B=await W(e,Bs,"getContractEvents")({abi:n,address:r,args:a,eventName:i,fromBlock:b+1n,toBlock:j,strict:h}):B=[],b=j}if(B.length===0)return;if(s)E.onLogs(B);else for(const j of B)E.onLogs([j])}catch(B){A&&B instanceof gs&&(I=!1),E.onError?.(B)}},{emitOnBegin:!0,interval:l});return async()=>{A&&await W(e,Ar,"uninstallFilter")({filter:A}),N()}})})():(()=>{const h=p??!1,w=ut(["watchContractEvent",r,a,s,e.uid,i,l,h]);let E=!0,b=()=>E=!1;return dt(w,{onLogs:u,onError:c},A=>((async()=>{try{const I=(()=>{if(e.transport.type==="fallback"){const j=e.transport.transports.find(v=>v.config.type==="webSocket"||v.config.type==="ipc");return j?j.value:e.transport}return e.transport})(),N=i?Rt({abi:n,eventName:i,args:a}):[],{unsubscribe:B}=await I.subscribe({params:["logs",{address:r,topics:N}],onData(j){if(!E)return;const v=j.result;try{const{eventName:P,args:x}=ms({abi:n,data:v.data,topics:v.topics,strict:p}),m=De(v,{args:x,eventName:P});A.onLogs([m])}catch(P){let x,m;if(P instanceof hs||P instanceof ys){if(p)return;x=P.abiItem.name,m=P.abiItem.inputs?.some(C=>!("name"in C&&C.name))}const k=De(v,{args:m?[]:{},eventName:x});A.onLogs([k])}},onError(j){A.onError?.(j)}});b=B,E||b()}catch(I){c?.(I)}})(),()=>b()))})()}function nd(e,{address:t,args:n,batch:r=!0,event:a,events:s,fromBlock:i,onError:o,onLogs:c,poll:u,pollingInterval:d=e.pollingInterval,strict:l}){const p=typeof u<"u"?u:typeof i=="bigint"?!0:!(e.transport.type==="webSocket"||e.transport.type==="ipc"||e.transport.type==="fallback"&&(e.transport.transports[0].config.type==="webSocket"||e.transport.transports[0].config.type==="ipc")),f=l??!1;return p?(()=>{const h=ut(["watchEvent",t,n,r,e.uid,a,d,i]);return dt(h,{onLogs:c,onError:o},w=>{let E;i!==void 0&&(E=i-1n);let b,A=!1;const I=Bt(async()=>{if(!A){try{b=await W(e,Ns,"createEventFilter")({address:t,args:n,event:a,events:s,strict:f,fromBlock:i})}catch{}A=!0;return}try{let N;if(b)N=await W(e,_r,"getFilterChanges")({filter:b});else{const B=await W(e,mn,"getBlockNumber")({});E&&E!==B?N=await W(e,Nr,"getLogs")({address:t,args:n,event:a,events:s,fromBlock:E+1n,toBlock:B}):N=[],E=B}if(N.length===0)return;if(r)w.onLogs(N);else for(const B of N)w.onLogs([B])}catch(N){b&&N instanceof gs&&(A=!1),w.onError?.(N)}},{emitOnBegin:!0,interval:d});return async()=>{b&&await W(e,Ar,"uninstallFilter")({filter:b}),I()}})})():(()=>{let h=!0,w=()=>h=!1;return(async()=>{try{const E=(()=>{if(e.transport.type==="fallback"){const N=e.transport.transports.find(B=>B.config.type==="webSocket"||B.config.type==="ipc");return N?N.value:e.transport}return e.transport})(),b=s??(a?[a]:void 0);let A=[];b&&(A=[b.flatMap(B=>Rt({abi:[B],eventName:B.name,args:n}))],a&&(A=A[0]));const{unsubscribe:I}=await E.subscribe({params:["logs",{address:t,topics:A}],onData(N){if(!h)return;const B=N.result;try{const{eventName:j,args:v}=ms({abi:b??[],data:B.data,topics:B.topics,strict:f}),P=De(B,{args:v,eventName:j});c([P])}catch(j){let v,P;if(j instanceof hs||j instanceof ys){if(l)return;v=j.abiItem.name,P=j.abiItem.inputs?.some(m=>!("name"in m&&m.name))}const x=De(B,{args:P?[]:{},eventName:v});c([x])}},onError(N){o?.(N)}});w=I,h||w()}catch(E){o?.(E)}})(),()=>w()})()}const rd="0x5792579257925792579257925792579257925792579257925792579257925792",ad=M(0,{size:32});async function sd(e,t){async function n(d){if(d.endsWith(rd.slice(2))){const p=Yt(ta(d,-64,-32)),f=ta(d,0,-64).slice(2).match(/.{1,64}/g),y=await Promise.all(f.map(h=>ad.slice(2)!==h?e.request({method:"eth_getTransactionReceipt",params:[`0x${h}`]},{dedupe:!0}):void 0)),g=y.some(h=>h===null)?100:y.every(h=>h?.status==="0x1")?200:y.every(h=>h?.status==="0x0")?500:600;return{atomic:!1,chainId:Je(p),receipts:y.filter(Boolean),status:g,version:"2.0.0"}}return e.request({method:"wallet_getCallsStatus",params:[d]})}const{atomic:r=!1,chainId:a,receipts:s,version:i="2.0.0",...o}=await n(t.id),[c,u]=(()=>{const d=o.status;return d>=100&&d<200?["pending",d]:d>=200&&d<300?["success",d]:d>=300&&d<700?["failure",d]:d==="CONFIRMED"?["success",200]:d==="PENDING"?["pending",100]:[void 0,d]})();return{...o,atomic:r,chainId:a?Je(a):void 0,receipts:s?.map(d=>({...d,blockNumber:he(d.blockNumber),gasUsed:he(d.gasUsed),status:uc[d.status]}))??[],statusCode:u,status:c,version:i}}async function id(e,t){const{account:n=e.account,chainId:r,nonce:a}=t;if(!n)throw new hn({docsPath:"/docs/eip7702/prepareAuthorization"});const s=Ae(n),i=(()=>{if(t.executor)return t.executor==="self"?t.executor:Ae(t.executor)})(),o={address:t.contractAddress??t.address,chainId:r,nonce:a};return typeof o.chainId>"u"&&(o.chainId=e.chain?.id??await W(e,yn,"getChainId")({})),typeof o.nonce>"u"&&(o.nonce=await W(e,bs,"getTransactionCount")({address:s.address,blockTag:"pending"}),(i==="self"||i?.address&&Ir(i.address,s.address))&&(o.nonce+=1)),o}class od extends D{constructor(t){super(`Call bundle failed with status: ${t.statusCode}`,{name:"BundleFailedError"}),Object.defineProperty(this,"result",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.result=t}}async function Ds(e,t){const{id:n,pollingInterval:r=e.pollingInterval,status:a=({statusCode:g})=>g===200||g>=300,retryCount:s=4,retryDelay:i=({count:g})=>~~(1<<g)*200,timeout:o=6e4,throwOnFailure:c=!1}=t,u=ut(["waitForCallsStatus",e.uid,n]),{promise:d,resolve:l,reject:p}=dc();let f;const y=dt(u,{resolve:l,reject:p},g=>{const h=Bt(async()=>{const w=E=>{clearTimeout(f),h(),E(),y()};try{const E=await lc(async()=>{const b=await sd(e,{id:n});if(c&&b.status==="failure")throw new od(b);return b},{retryCount:s,delay:i});if(!a(E))return;w(()=>g.resolve(E))}catch(E){w(()=>g.reject(E))}},{interval:r,emitOnBegin:!0});return h});return f=o?setTimeout(()=>{y(),clearTimeout(f),p(new cd({id:n}))},o):void 0,await d}class cd extends D{constructor({id:t}){super(`Timed out while waiting for call bundle with id "${t}" to be confirmed.`,{name:"WaitForCallsStatusTimeoutError"})}}function ud(e){const{scheme:t,statement:n,...r}=e.match(dd)?.groups??{},{chainId:a,expirationTime:s,issuedAt:i,notBefore:o,requestId:c,...u}=e.match(ld)?.groups??{},d=e.split("Resources:")[1]?.split(`
|
|
- `).slice(1);return{...r,...u,...a?{chainId:Number(a)}:{},...s?{expirationTime:new Date(s)}:{},...i?{issuedAt:new Date(i)}:{},...o?{notBefore:new Date(o)}:{},...c?{requestId:c}:{},...d?{resources:d}:{},...t?{scheme:t}:{},...n?{statement:n}:{}}}const dd=/^(?:(?<scheme>[a-zA-Z][a-zA-Z0-9+-.]*):\/\/)?(?<domain>[a-zA-Z0-9+-.]*(?::[0-9]{1,5})?) (?:wants you to sign in with your Ethereum account:\n)(?<address>0x[a-fA-F0-9]{40})\n\n(?:(?<statement>.*)\n\n)?/,ld=/(?:URI: (?<uri>.+))\n(?:Version: (?<version>.+))\n(?:Chain ID: (?<chainId>\d+))\n(?:Nonce: (?<nonce>[a-zA-Z0-9]+))\n(?:Issued At: (?<issuedAt>.+))(?:\nExpiration Time: (?<expirationTime>.+))?(?:\nNot Before: (?<notBefore>.+))?(?:\nRequest ID: (?<requestId>.+))?/;function fd(e){const{address:t,domain:n,message:r,nonce:a,scheme:s,time:i=new Date}=e;if(n&&r.domain!==n||a&&r.nonce!==a||s&&r.scheme!==s||r.expirationTime&&i>=r.expirationTime||r.notBefore&&i<r.notBefore)return!1;try{if(!r.address||!ct(r.address,{strict:!1})||t&&!Ir(r.address,t))return!1}catch{return!1}return!0}async function pd(e,t){const{address:n,domain:r,message:a,nonce:s,scheme:i,signature:o,time:c=new Date,...u}=t,d=ud(a);if(!d.address||!fd({address:n,domain:r,message:d,nonce:s,scheme:i,time:c}))return!1;const p=Pr(a);return ps(e,{address:d.address,hash:p,signature:o,...u})}function md(e){return{call:t=>fs(e,t),createAccessList:t=>Cs(e,t),createBlockFilter:()=>xu(e),createContractEventFilter:t=>Ts(e,t),createEventFilter:t=>Ns(e,t),createPendingTransactionFilter:()=>fc(e),estimateContractGas:t=>Su(e,t),estimateGas:t=>as(e,t),getBalance:t=>pc(e,t),getBlobBaseFee:()=>Au(e),getBlock:t=>xt(e,t),getBlockNumber:t=>mn(e,t),getBlockTransactionCount:t=>_u(e,t),getBytecode:t=>Xt(e,t),getChainId:()=>yn(e),getCode:t=>Xt(e,t),getContractEvents:t=>Bs(e,t),getEip712Domain:t=>Pu(e,t),getEnsAddress:t=>ou(e,t),getEnsAvatar:t=>vu(e,t),getEnsName:t=>mc(e,t),getEnsResolver:t=>ku(e,t),getEnsText:t=>Os(e,t),getFeeHistory:t=>Tu(e,t),estimateFeesPerGas:t=>ws(e,t),getFilterChanges:t=>_r(e,t),getFilterLogs:t=>Nu(e,t),getGasPrice:()=>hc(e),getLogs:t=>Nr(e,t),getProof:t=>Du(e,t),estimateMaxPriorityFeePerGas:t=>yc(e,t),getStorageAt:t=>Uu(e,t),getTransaction:t=>os(e,t),getTransactionConfirmations:t=>Fu(e,t),getTransactionCount:t=>bs(e,t),getTransactionReceipt:t=>gc(e,t),multicall:t=>bc(e,t),prepareTransactionRequest:t=>wc(e,t),readContract:t=>Se(e,t),sendRawTransaction:t=>vc(e,t),simulate:t=>Dn(e,t),simulateBlocks:t=>Dn(e,t),simulateCalls:t=>Yu(e,t),simulateContract:t=>Qu(e,t),verifyMessage:t=>kc(e,t),verifySiweMessage:t=>pd(e,t),verifyTypedData:t=>Xu(e,t),uninstallFilter:t=>Ar(e,t),waitForTransactionReceipt:t=>xc(e,t),watchBlocks:t=>ed(e,t),watchBlockNumber:t=>Ec(e,t),watchContractEvent:t=>td(e,t),watchEvent:t=>nd(e,t),watchPendingTransactions:t=>Sc(e,t)}}function hd(e){const{key:t="public",name:n="Public Client"}=e;return vs({...e,key:t,name:n,type:"publicClient"}).extend(md)}function yd(e){const{r:t,s:n}=Ac.Signature.fromCompact(e.slice(2,130)),r=+`0x${e.slice(130)}`,[a,s]=(()=>{if(r===0||r===1)return[void 0,r];if(r===27)return[BigInt(r),0];if(r===28)return[BigInt(r),1];throw new Error("Invalid yParityOrV value")})();return typeof a<"u"?{r:M(t,{size:32}),s:M(n,{size:32}),v:a,yParity:s}:{r:M(t,{size:32}),s:M(n,{size:32}),yParity:s}}function Us(e,t){let n;try{n=e()}catch{return}return{getItem:a=>{var s;const i=c=>c===null?null:JSON.parse(c,void 0),o=(s=n.getItem(a))!=null?s:null;return o instanceof Promise?o.then(i):i(o)},setItem:(a,s)=>n.setItem(a,JSON.stringify(s,void 0)),removeItem:a=>n.removeItem(a)}}const Gn=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(r){return Gn(r)(n)},catch(r){return this}}}catch(n){return{then(r){return this},catch(r){return Gn(r)(n)}}}},gd=(e,t)=>(n,r,a)=>{let s={storage:Us(()=>localStorage),partialize:g=>g,version:0,merge:(g,h)=>({...h,...g}),...t},i=!1;const o=new Set,c=new Set;let u=s.storage;if(!u)return e((...g)=>{console.warn(`[zustand persist middleware] Unable to update item '${s.name}', the given storage is currently unavailable.`),n(...g)},r,a);const d=()=>{const g=s.partialize({...r()});return u.setItem(s.name,{state:g,version:s.version})},l=a.setState;a.setState=(g,h)=>{l(g,h),d()};const p=e((...g)=>{n(...g),d()},r,a);a.getInitialState=()=>p;let f;const y=()=>{var g,h;if(!u)return;i=!1,o.forEach(E=>{var b;return E((b=r())!=null?b:p)});const w=((h=s.onRehydrateStorage)==null?void 0:h.call(s,(g=r())!=null?g:p))||void 0;return Gn(u.getItem.bind(u))(s.name).then(E=>{if(E)if(typeof E.version=="number"&&E.version!==s.version){if(s.migrate){const b=s.migrate(E.state,E.version);return b instanceof Promise?b.then(A=>[!0,A]):[!0,b]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,E.state];return[!1,void 0]}).then(E=>{var b;const[A,I]=E;if(f=s.merge(I,(b=r())!=null?b:p),n(f,!0),A)return d()}).then(()=>{w?.(f,void 0),f=r(),i=!0,c.forEach(E=>E(f))}).catch(E=>{w?.(void 0,E)})};return a.persist={setOptions:g=>{s={...s,...g},g.storage&&(u=g.storage)},clearStorage:()=>{u?.removeItem(s.name)},getOptions:()=>s,rehydrate:()=>y(),hasHydrated:()=>i,onHydrate:g=>(o.add(g),()=>{o.delete(g)}),onFinishHydration:g=>(c.add(g),()=>{c.delete(g)})},s.skipHydration||y(),f||p},bd=gd,pa=e=>{let t;const n=new Set,r=(u,d)=>{const l=typeof u=="function"?u(t):u;if(!Object.is(l,t)){const p=t;t=d??(typeof l!="object"||l===null)?l:Object.assign({},t,l),n.forEach(f=>f(t,p))}},a=()=>t,o={setState:r,getState:a,getInitialState:()=>c,subscribe:u=>(n.add(u),()=>n.delete(u))},c=t=e(r,a,o);return o},Br=e=>e?pa(e):pa,wd=[{inputs:[{name:"preOpGas",type:"uint256"},{name:"paid",type:"uint256"},{name:"validAfter",type:"uint48"},{name:"validUntil",type:"uint48"},{name:"targetSuccess",type:"bool"},{name:"targetResult",type:"bytes"}],name:"ExecutionResult",type:"error"},{inputs:[{name:"opIndex",type:"uint256"},{name:"reason",type:"string"}],name:"FailedOp",type:"error"},{inputs:[{name:"sender",type:"address"}],name:"SenderAddressResult",type:"error"},{inputs:[{name:"aggregator",type:"address"}],name:"SignatureValidationFailed",type:"error"},{inputs:[{components:[{name:"preOpGas",type:"uint256"},{name:"prefund",type:"uint256"},{name:"sigFailed",type:"bool"},{name:"validAfter",type:"uint48"},{name:"validUntil",type:"uint48"},{name:"paymasterContext",type:"bytes"}],name:"returnInfo",type:"tuple"},{components:[{name:"stake",type:"uint256"},{name:"unstakeDelaySec",type:"uint256"}],name:"senderInfo",type:"tuple"},{components:[{name:"stake",type:"uint256"},{name:"unstakeDelaySec",type:"uint256"}],name:"factoryInfo",type:"tuple"},{components:[{name:"stake",type:"uint256"},{name:"unstakeDelaySec",type:"uint256"}],name:"paymasterInfo",type:"tuple"}],name:"ValidationResult",type:"error"},{inputs:[{components:[{name:"preOpGas",type:"uint256"},{name:"prefund",type:"uint256"},{name:"sigFailed",type:"bool"},{name:"validAfter",type:"uint48"},{name:"validUntil",type:"uint48"},{name:"paymasterContext",type:"bytes"}],name:"returnInfo",type:"tuple"},{components:[{name:"stake",type:"uint256"},{name:"unstakeDelaySec",type:"uint256"}],name:"senderInfo",type:"tuple"},{components:[{name:"stake",type:"uint256"},{name:"unstakeDelaySec",type:"uint256"}],name:"factoryInfo",type:"tuple"},{components:[{name:"stake",type:"uint256"},{name:"unstakeDelaySec",type:"uint256"}],name:"paymasterInfo",type:"tuple"},{components:[{name:"aggregator",type:"address"},{components:[{name:"stake",type:"uint256"},{name:"unstakeDelaySec",type:"uint256"}],name:"stakeInfo",type:"tuple"}],name:"aggregatorInfo",type:"tuple"}],name:"ValidationResultWithAggregation",type:"error"},{anonymous:!1,inputs:[{indexed:!0,name:"userOpHash",type:"bytes32"},{indexed:!0,name:"sender",type:"address"},{indexed:!1,name:"factory",type:"address"},{indexed:!1,name:"paymaster",type:"address"}],name:"AccountDeployed",type:"event"},{anonymous:!1,inputs:[],name:"BeforeExecution",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"account",type:"address"},{indexed:!1,name:"totalDeposit",type:"uint256"}],name:"Deposited",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"aggregator",type:"address"}],name:"SignatureAggregatorChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"account",type:"address"},{indexed:!1,name:"totalStaked",type:"uint256"},{indexed:!1,name:"unstakeDelaySec",type:"uint256"}],name:"StakeLocked",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"account",type:"address"},{indexed:!1,name:"withdrawTime",type:"uint256"}],name:"StakeUnlocked",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"account",type:"address"},{indexed:!1,name:"withdrawAddress",type:"address"},{indexed:!1,name:"amount",type:"uint256"}],name:"StakeWithdrawn",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"userOpHash",type:"bytes32"},{indexed:!0,name:"sender",type:"address"},{indexed:!0,name:"paymaster",type:"address"},{indexed:!1,name:"nonce",type:"uint256"},{indexed:!1,name:"success",type:"bool"},{indexed:!1,name:"actualGasCost",type:"uint256"},{indexed:!1,name:"actualGasUsed",type:"uint256"}],name:"UserOperationEvent",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"userOpHash",type:"bytes32"},{indexed:!0,name:"sender",type:"address"},{indexed:!1,name:"nonce",type:"uint256"},{indexed:!1,name:"revertReason",type:"bytes"}],name:"UserOperationRevertReason",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"account",type:"address"},{indexed:!1,name:"withdrawAddress",type:"address"},{indexed:!1,name:"amount",type:"uint256"}],name:"Withdrawn",type:"event"},{inputs:[],name:"SIG_VALIDATION_FAILED",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"initCode",type:"bytes"},{name:"sender",type:"address"},{name:"paymasterAndData",type:"bytes"}],name:"_validateSenderAndPaymaster",outputs:[],stateMutability:"view",type:"function"},{inputs:[{name:"unstakeDelaySec",type:"uint32"}],name:"addStake",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{name:"account",type:"address"}],name:"balanceOf",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"account",type:"address"}],name:"depositTo",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{name:"",type:"address"}],name:"deposits",outputs:[{name:"deposit",type:"uint112"},{name:"staked",type:"bool"},{name:"stake",type:"uint112"},{name:"unstakeDelaySec",type:"uint32"},{name:"withdrawTime",type:"uint48"}],stateMutability:"view",type:"function"},{inputs:[{name:"account",type:"address"}],name:"getDepositInfo",outputs:[{components:[{name:"deposit",type:"uint112"},{name:"staked",type:"bool"},{name:"stake",type:"uint112"},{name:"unstakeDelaySec",type:"uint32"},{name:"withdrawTime",type:"uint48"}],name:"info",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[{name:"sender",type:"address"},{name:"key",type:"uint192"}],name:"getNonce",outputs:[{name:"nonce",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"initCode",type:"bytes"}],name:"getSenderAddress",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"initCode",type:"bytes"},{name:"callData",type:"bytes"},{name:"callGasLimit",type:"uint256"},{name:"verificationGasLimit",type:"uint256"},{name:"preVerificationGas",type:"uint256"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"},{name:"paymasterAndData",type:"bytes"},{name:"signature",type:"bytes"}],name:"userOp",type:"tuple"}],name:"getUserOpHash",outputs:[{name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{components:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"initCode",type:"bytes"},{name:"callData",type:"bytes"},{name:"callGasLimit",type:"uint256"},{name:"verificationGasLimit",type:"uint256"},{name:"preVerificationGas",type:"uint256"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"},{name:"paymasterAndData",type:"bytes"},{name:"signature",type:"bytes"}],name:"userOps",type:"tuple[]"},{name:"aggregator",type:"address"},{name:"signature",type:"bytes"}],name:"opsPerAggregator",type:"tuple[]"},{name:"beneficiary",type:"address"}],name:"handleAggregatedOps",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"initCode",type:"bytes"},{name:"callData",type:"bytes"},{name:"callGasLimit",type:"uint256"},{name:"verificationGasLimit",type:"uint256"},{name:"preVerificationGas",type:"uint256"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"},{name:"paymasterAndData",type:"bytes"},{name:"signature",type:"bytes"}],name:"ops",type:"tuple[]"},{name:"beneficiary",type:"address"}],name:"handleOps",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"key",type:"uint192"}],name:"incrementNonce",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"callData",type:"bytes"},{components:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"callGasLimit",type:"uint256"},{name:"verificationGasLimit",type:"uint256"},{name:"preVerificationGas",type:"uint256"},{name:"paymaster",type:"address"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"}],name:"mUserOp",type:"tuple"},{name:"userOpHash",type:"bytes32"},{name:"prefund",type:"uint256"},{name:"contextOffset",type:"uint256"},{name:"preOpGas",type:"uint256"}],name:"opInfo",type:"tuple"},{name:"context",type:"bytes"}],name:"innerHandleOp",outputs:[{name:"actualGasCost",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"",type:"address"},{name:"",type:"uint192"}],name:"nonceSequenceNumber",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"initCode",type:"bytes"},{name:"callData",type:"bytes"},{name:"callGasLimit",type:"uint256"},{name:"verificationGasLimit",type:"uint256"},{name:"preVerificationGas",type:"uint256"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"},{name:"paymasterAndData",type:"bytes"},{name:"signature",type:"bytes"}],name:"op",type:"tuple"},{name:"target",type:"address"},{name:"targetCallData",type:"bytes"}],name:"simulateHandleOp",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"initCode",type:"bytes"},{name:"callData",type:"bytes"},{name:"callGasLimit",type:"uint256"},{name:"verificationGasLimit",type:"uint256"},{name:"preVerificationGas",type:"uint256"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"},{name:"paymasterAndData",type:"bytes"},{name:"signature",type:"bytes"}],name:"userOp",type:"tuple"}],name:"simulateValidation",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"unlockStake",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"withdrawAddress",type:"address"}],name:"withdrawStake",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"withdrawAddress",type:"address"},{name:"withdrawAmount",type:"uint256"}],name:"withdrawTo",outputs:[],stateMutability:"nonpayable",type:"function"},{stateMutability:"payable",type:"receive"}];function Fs(e){const{authorization:t,factory:n,factoryData:r}=e;if(n==="0x7702"||n==="0x7702000000000000000000000000000000000000"){if(!t)return"0x7702000000000000000000000000000000000000";const a=t.address;return je([a,r??"0x"])}return n?je([n,r??"0x"]):"0x"}function $s(e){const{callGasLimit:t,callData:n,maxPriorityFeePerGas:r,maxFeePerGas:a,paymaster:s,paymasterData:i,paymasterPostOpGasLimit:o,paymasterVerificationGasLimit:c,sender:u,signature:d="0x",verificationGasLimit:l}=e,p=je([de(M(l||0n),{size:16}),de(M(t||0n),{size:16})]),f=Fs(e),y=je([de(M(r||0n),{size:16}),de(M(a||0n),{size:16})]),g=e.nonce??0n,h=s?je([s,de(M(c||0n),{size:16}),de(M(o||0n),{size:16}),i||"0x"]):"0x",w=e.preVerificationGas??0n;return{accountGasLimits:p,callData:n,initCode:f,gasFees:y,nonce:g,paymasterAndData:h,preVerificationGas:w,sender:u,signature:d}}const vd={PackedUserOperation:[{type:"address",name:"sender"},{type:"uint256",name:"nonce"},{type:"bytes",name:"initCode"},{type:"bytes",name:"callData"},{type:"bytes32",name:"accountGasLimits"},{type:"uint256",name:"preVerificationGas"},{type:"bytes32",name:"gasFees"},{type:"bytes",name:"paymasterAndData"}]};function kd(e){const{chainId:t,entryPointAddress:n,userOperation:r}=e,a=$s(r);return{types:vd,primaryType:"PackedUserOperation",domain:{name:"ERC4337",version:"1",chainId:t,verifyingContract:n},message:a}}function xd(e){const{chainId:t,entryPointAddress:n,entryPointVersion:r}=e,a=e.userOperation,{authorization:s,callData:i="0x",callGasLimit:o,maxFeePerGas:c,maxPriorityFeePerGas:u,nonce:d,paymasterAndData:l="0x",preVerificationGas:p,sender:f,verificationGasLimit:y}=a;if(r==="0.8")return Lt(kd({chainId:t,entryPointAddress:n,userOperation:a}));const g=(()=>{if(r==="0.6"){const h=a.initCode?.slice(0,42),w=a.initCode?.slice(42),E=Fs({authorization:s,factory:h,factoryData:w});return Ke([{type:"address"},{type:"uint256"},{type:"bytes32"},{type:"bytes32"},{type:"uint256"},{type:"uint256"},{type:"uint256"},{type:"uint256"},{type:"uint256"},{type:"bytes32"}],[f,d,ce(E),ce(i),o,y,p,c,u,ce(l)])}if(r==="0.7"){const h=$s(a);return Ke([{type:"address"},{type:"uint256"},{type:"bytes32"},{type:"bytes32"},{type:"bytes32"},{type:"uint256"},{type:"bytes32"},{type:"bytes32"}],[h.sender,h.nonce,ce(h.initCode),ce(h.callData),h.accountGasLimits,h.preVerificationGas,h.gasFees,ce(h.paymasterAndData)])}throw new Error(`entryPointVersion "${r}" not supported.`)})();return ce(Ke([{type:"bytes32"},{type:"address"},{type:"uint256"}],[ce(g),n,BigInt(t)]))}async function Ed(e){const{extend:t,nonceKeyManager:n=Lu({source:{get(){return Date.now()},set(){}}}),...r}=e;let a=!1;const s=await e.getAddress();return{...t,...r,address:s,async getFactoryArgs(){return"isDeployed"in this&&await this.isDeployed()?{factory:void 0,factoryData:void 0}:e.getFactoryArgs()},async getNonce(i){const o=i?.key??BigInt(await n.consume({address:s,chainId:e.client.chain.id,client:e.client}));return e.getNonce?await e.getNonce({...i,key:o}):await Se(e.client,{abi:_c(["function getNonce(address, uint192) pure returns (uint256)"]),address:e.entryPoint.address,functionName:"getNonce",args:[s,o]})},async isDeployed(){return a?!0:(a=!!await W(e.client,Xt,"getCode")({address:s}),a)},...e.sign?{async sign(i){const[{factory:o,factoryData:c},u]=await Promise.all([this.getFactoryArgs(),e.sign(i)]);return o&&c?An({address:o,data:c,signature:u}):u}}:{},async signMessage(i){const[{factory:o,factoryData:c},u]=await Promise.all([this.getFactoryArgs(),e.signMessage(i)]);return o&&c&&o!=="0x7702"?An({address:o,data:c,signature:u}):u},async signTypedData(i){const[{factory:o,factoryData:c},u]=await Promise.all([this.getFactoryArgs(),e.signTypedData(i)]);return o&&c&&o!=="0x7702"?An({address:o,data:c,signature:u}):u},type:"smart"}}class Hn extends D{constructor({cause:t}){super("Smart Account is not deployed.",{cause:t,metaMessages:["This could arise when:","- No `factory`/`factoryData` or `initCode` properties are provided for Smart Account deployment.","- An incorrect `sender` address is provided."],name:"AccountNotDeployedError"})}}Object.defineProperty(Hn,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa20/});class lt extends D{constructor({cause:t,data:n,message:r}={}){const a=r?.replace("execution reverted: ","")?.replace("execution reverted","");super(`Execution reverted ${a?`with reason: ${a}`:"for an unknown reason"}.`,{cause:t,name:"ExecutionRevertedError"}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=n}}Object.defineProperty(lt,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32521});Object.defineProperty(lt,"message",{enumerable:!0,configurable:!0,writable:!0,value:/execution reverted/});class zn extends D{constructor({cause:t}){super("Failed to send funds to beneficiary.",{cause:t,name:"FailedToSendToBeneficiaryError"})}}Object.defineProperty(zn,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa91/});class qn extends D{constructor({cause:t}){super("Gas value overflowed.",{cause:t,metaMessages:["This could arise when:","- one of the gas values exceeded 2**120 (uint120)"].filter(Boolean),name:"GasValuesOverflowError"})}}Object.defineProperty(qn,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa94/});class Wn extends D{constructor({cause:t}){super("The `handleOps` function was called by the Bundler with a gas limit too low.",{cause:t,name:"HandleOpsOutOfGasError"})}}Object.defineProperty(Wn,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa95/});class Vn extends D{constructor({cause:t,factory:n,factoryData:r,initCode:a}){super("Failed to simulate deployment for Smart Account.",{cause:t,metaMessages:["This could arise when:","- Invalid `factory`/`factoryData` or `initCode` properties are present","- Smart Account deployment execution ran out of gas (low `verificationGasLimit` value)",`- Smart Account deployment execution reverted with an error
|
|
`,n&&`factory: ${n}`,r&&`factoryData: ${r}`,a&&`initCode: ${a}`].filter(Boolean),name:"InitCodeFailedError"})}}Object.defineProperty(Vn,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa13/});class Kn extends D{constructor({cause:t,factory:n,factoryData:r,initCode:a}){super("Smart Account initialization implementation did not create an account.",{cause:t,metaMessages:["This could arise when:","- `factory`/`factoryData` or `initCode` properties are invalid",`- Smart Account initialization implementation is incorrect
|
|
`,n&&`factory: ${n}`,r&&`factoryData: ${r}`,a&&`initCode: ${a}`].filter(Boolean),name:"InitCodeMustCreateSenderError"})}}Object.defineProperty(Kn,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa15/});class Jn extends D{constructor({cause:t,factory:n,factoryData:r,initCode:a,sender:s}){super("Smart Account initialization implementation does not return the expected sender.",{cause:t,metaMessages:["This could arise when:",`Smart Account initialization implementation does not return a sender address
|
|
`,n&&`factory: ${n}`,r&&`factoryData: ${r}`,a&&`initCode: ${a}`,s&&`sender: ${s}`].filter(Boolean),name:"InitCodeMustReturnSenderError"})}}Object.defineProperty(Jn,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa14/});class Zn extends D{constructor({cause:t}){super("Smart Account does not have sufficient funds to execute the User Operation.",{cause:t,metaMessages:["This could arise when:","- the Smart Account does not have sufficient funds to cover the required prefund, or","- a Paymaster was not provided"].filter(Boolean),name:"InsufficientPrefundError"})}}Object.defineProperty(Zn,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa21/});class Yn extends D{constructor({cause:t}){super("Bundler attempted to call an invalid function on the EntryPoint.",{cause:t,name:"InternalCallOnlyError"})}}Object.defineProperty(Yn,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa92/});class Qn extends D{constructor({cause:t}){super("Bundler used an invalid aggregator for handling aggregated User Operations.",{cause:t,name:"InvalidAggregatorError"})}}Object.defineProperty(Qn,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa96/});class Xn extends D{constructor({cause:t,nonce:n}){super("Invalid Smart Account nonce used for User Operation.",{cause:t,metaMessages:[n&&`nonce: ${n}`].filter(Boolean),name:"InvalidAccountNonceError"})}}Object.defineProperty(Xn,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa25/});class er extends D{constructor({cause:t}){super("Bundler has not set a beneficiary address.",{cause:t,name:"InvalidBeneficiaryError"})}}Object.defineProperty(er,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa90/});class tn extends D{constructor({cause:t}){super("Invalid fields set on User Operation.",{cause:t,name:"InvalidFieldsError"})}}Object.defineProperty(tn,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32602});class tr extends D{constructor({cause:t,paymasterAndData:n}){super("Paymaster properties provided are invalid.",{cause:t,metaMessages:["This could arise when:","- the `paymasterAndData` property is of an incorrect length\n",n&&`paymasterAndData: ${n}`].filter(Boolean),name:"InvalidPaymasterAndDataError"})}}Object.defineProperty(tr,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa93/});class We extends D{constructor({cause:t}){super("Paymaster deposit for the User Operation is too low.",{cause:t,metaMessages:["This could arise when:","- the Paymaster has deposited less than the expected amount via the `deposit` function"].filter(Boolean),name:"PaymasterDepositTooLowError"})}}Object.defineProperty(We,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32508});Object.defineProperty(We,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa31/});class nr extends D{constructor({cause:t}){super("The `validatePaymasterUserOp` function on the Paymaster reverted.",{cause:t,name:"PaymasterFunctionRevertedError"})}}Object.defineProperty(nr,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa33/});class rr extends D{constructor({cause:t}){super("The Paymaster contract has not been deployed.",{cause:t,name:"PaymasterNotDeployedError"})}}Object.defineProperty(rr,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa30/});class nn extends D{constructor({cause:t}){super("UserOperation rejected because paymaster (or signature aggregator) is throttled/banned.",{cause:t,name:"PaymasterRateLimitError"})}}Object.defineProperty(nn,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32504});class rn extends D{constructor({cause:t}){super("UserOperation rejected because paymaster (or signature aggregator) is throttled/banned.",{cause:t,name:"PaymasterStakeTooLowError"})}}Object.defineProperty(rn,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32505});class ar extends D{constructor({cause:t}){super("Paymaster `postOp` function reverted.",{cause:t,name:"PaymasterPostOpFunctionRevertedError"})}}Object.defineProperty(ar,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa50/});class sr extends D{constructor({cause:t,factory:n,factoryData:r,initCode:a}){super("Smart Account has already been deployed.",{cause:t,metaMessages:["Remove the following properties and try again:",n&&"`factory`",r&&"`factoryData`",a&&"`initCode`"].filter(Boolean),name:"SenderAlreadyConstructedError"})}}Object.defineProperty(sr,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa10/});class an extends D{constructor({cause:t}){super("UserOperation rejected because account signature check failed (or paymaster signature, if the paymaster uses its data as signature).",{cause:t,name:"SignatureCheckFailedError"})}}Object.defineProperty(an,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32507});class ir extends D{constructor({cause:t}){super("The `validateUserOp` function on the Smart Account reverted.",{cause:t,name:"SmartAccountFunctionRevertedError"})}}Object.defineProperty(ir,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa23/});class sn extends D{constructor({cause:t}){super("UserOperation rejected because account specified unsupported signature aggregator.",{cause:t,name:"UnsupportedSignatureAggregatorError"})}}Object.defineProperty(sn,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32506});class or extends D{constructor({cause:t}){super("User Operation expired.",{cause:t,metaMessages:["This could arise when:","- the `validAfter` or `validUntil` values returned from `validateUserOp` on the Smart Account are not satisfied"].filter(Boolean),name:"UserOperationExpiredError"})}}Object.defineProperty(or,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa22/});class cr extends D{constructor({cause:t}){super("Paymaster for User Operation expired.",{cause:t,metaMessages:["This could arise when:","- the `validAfter` or `validUntil` values returned from `validatePaymasterUserOp` on the Paymaster are not satisfied"].filter(Boolean),name:"UserOperationPaymasterExpiredError"})}}Object.defineProperty(cr,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa32/});class ur extends D{constructor({cause:t}){super("Signature provided for the User Operation is invalid.",{cause:t,metaMessages:["This could arise when:","- the `signature` for the User Operation is incorrectly computed, and unable to be verified by the Smart Account"].filter(Boolean),name:"UserOperationSignatureError"})}}Object.defineProperty(ur,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa24/});class dr extends D{constructor({cause:t}){super("Signature provided for the User Operation is invalid.",{cause:t,metaMessages:["This could arise when:","- the `signature` for the User Operation is incorrectly computed, and unable to be verified by the Paymaster"].filter(Boolean),name:"UserOperationPaymasterSignatureError"})}}Object.defineProperty(dr,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa34/});class on extends D{constructor({cause:t}){super("User Operation rejected by EntryPoint's `simulateValidation` during account creation or validation.",{cause:t,name:"UserOperationRejectedByEntryPointError"})}}Object.defineProperty(on,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32500});class cn extends D{constructor({cause:t}){super("User Operation rejected by Paymaster's `validatePaymasterUserOp`.",{cause:t,name:"UserOperationRejectedByPaymasterError"})}}Object.defineProperty(cn,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32501});class un extends D{constructor({cause:t}){super("User Operation rejected with op code validation error.",{cause:t,name:"UserOperationRejectedByOpCodeError"})}}Object.defineProperty(un,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32502});class dn extends D{constructor({cause:t}){super("UserOperation out of time-range: either wallet or paymaster returned a time-range, and it is already expired (or will expire soon).",{cause:t,name:"UserOperationOutOfTimeRangeError"})}}Object.defineProperty(dn,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32503});class Sd extends D{constructor({cause:t}){super(`An error occurred while executing user operation: ${t?.shortMessage}`,{cause:t,name:"UnknownBundlerError"})}}class lr extends D{constructor({cause:t}){super("User Operation verification gas limit exceeded.",{cause:t,metaMessages:["This could arise when:","- the gas used for verification exceeded the `verificationGasLimit`"].filter(Boolean),name:"VerificationGasLimitExceededError"})}}Object.defineProperty(lr,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa40/});class fr extends D{constructor({cause:t}){super("User Operation verification gas limit is too low.",{cause:t,metaMessages:["This could arise when:","- the `verificationGasLimit` is too low to verify the User Operation"].filter(Boolean),name:"VerificationGasLimitTooLowError"})}}Object.defineProperty(fr,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa41/});class Ad extends D{constructor(t,{callData:n,callGasLimit:r,docsPath:a,factory:s,factoryData:i,initCode:o,maxFeePerGas:c,maxPriorityFeePerGas:u,nonce:d,paymaster:l,paymasterAndData:p,paymasterData:f,paymasterPostOpGasLimit:y,paymasterVerificationGasLimit:g,preVerificationGas:h,sender:w,signature:E,verificationGasLimit:b}){const A=Ic({callData:n,callGasLimit:r,factory:s,factoryData:i,initCode:o,maxFeePerGas:typeof c<"u"&&`${na(c)} gwei`,maxPriorityFeePerGas:typeof u<"u"&&`${na(u)} gwei`,nonce:d,paymaster:l,paymasterAndData:p,paymasterData:f,paymasterPostOpGasLimit:y,paymasterVerificationGasLimit:g,preVerificationGas:h,sender:w,signature:E,verificationGasLimit:b});super(t.shortMessage,{cause:t,docsPath:a,metaMessages:[...t.metaMessages?[...t.metaMessages," "]:[],"Request Arguments:",A].filter(Boolean),name:"UserOperationExecutionError"}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cause=t}}class _d extends D{constructor({hash:t}){super(`User Operation receipt with hash "${t}" could not be found. The User Operation may not have been processed yet.`,{name:"UserOperationReceiptNotFoundError"})}}class Id extends D{constructor({hash:t}){super(`User Operation with hash "${t}" could not be found.`,{name:"UserOperationNotFoundError"})}}class ma extends D{constructor({hash:t}){super(`Timed out while waiting for User Operation with hash "${t}" to be confirmed.`,{name:"WaitForUserOperationReceiptTimeoutError"})}}const Pd=[lt,tn,We,nn,rn,an,sn,dn,on,cn,un];function Od(e,t){const n=(e.details||"").toLowerCase();if(Hn.message.test(n))return new Hn({cause:e});if(zn.message.test(n))return new zn({cause:e});if(qn.message.test(n))return new qn({cause:e});if(Wn.message.test(n))return new Wn({cause:e});if(Vn.message.test(n))return new Vn({cause:e,factory:t.factory,factoryData:t.factoryData,initCode:t.initCode});if(Kn.message.test(n))return new Kn({cause:e,factory:t.factory,factoryData:t.factoryData,initCode:t.initCode});if(Jn.message.test(n))return new Jn({cause:e,factory:t.factory,factoryData:t.factoryData,initCode:t.initCode,sender:t.sender});if(Zn.message.test(n))return new Zn({cause:e});if(Yn.message.test(n))return new Yn({cause:e});if(Xn.message.test(n))return new Xn({cause:e,nonce:t.nonce});if(Qn.message.test(n))return new Qn({cause:e});if(er.message.test(n))return new er({cause:e});if(tr.message.test(n))return new tr({cause:e});if(We.message.test(n))return new We({cause:e});if(nr.message.test(n))return new nr({cause:e});if(rr.message.test(n))return new rr({cause:e});if(ar.message.test(n))return new ar({cause:e});if(ir.message.test(n))return new ir({cause:e});if(sr.message.test(n))return new sr({cause:e,factory:t.factory,factoryData:t.factoryData,initCode:t.initCode});if(or.message.test(n))return new or({cause:e});if(cr.message.test(n))return new cr({cause:e});if(dr.message.test(n))return new dr({cause:e});if(ur.message.test(n))return new ur({cause:e});if(lr.message.test(n))return new lr({cause:e});if(fr.message.test(n))return new fr({cause:e});const r=e.walk(a=>Pd.some(s=>s.code===a.code));if(r){if(r.code===lt.code)return new lt({cause:e,data:r.data,message:r.details});if(r.code===tn.code)return new tn({cause:e});if(r.code===We.code)return new We({cause:e});if(r.code===nn.code)return new nn({cause:e});if(r.code===rn.code)return new rn({cause:e});if(r.code===an.code)return new an({cause:e});if(r.code===sn.code)return new sn({cause:e});if(r.code===dn.code)return new dn({cause:e});if(r.code===on.code)return new on({cause:e});if(r.code===cn.code)return new cn({cause:e});if(r.code===un.code)return new un({cause:e})}return new Sd({cause:e})}function Gs(e,{calls:t,docsPath:n,...r}){const a=(()=>{const s=Od(e,r);if(t&&s instanceof lt){const i=Cd(s),o=t?.filter(c=>c.abi);if(i&&o.length>0)return Td({calls:o,revertData:i})}return s})();return new Ad(a,{docsPath:n,...r})}function Cd(e){let t;return e.walk(n=>{const r=n;if(typeof r.data=="string"||typeof r.data?.revertData=="string"||!(r instanceof D)&&typeof r.message=="string"){const a=(r.data?.revertData||r.data||r.message).match?.(/(0x[A-Za-z0-9]*)/);if(a)return t=a[1],!0}return!1}),t}function Td(e){const{calls:t,revertData:n}=e,{abi:r,functionName:a,args:s,to:i}=(()=>{const c=t?.filter(d=>!!d.abi);if(c.length===1)return c[0];const u=c.filter(d=>{try{return!!Pc({abi:d.abi,data:n})}catch{return!1}});return u.length===1?u[0]:{abi:[],functionName:c.reduce((d,l)=>`${d?`${d} | `:""}${l.functionName}`,""),args:void 0,to:void 0}})(),o=n==="0x"?new Oc({functionName:a}):new Cc({abi:r,data:n,functionName:a});return new Tc(o,{abi:r,args:s,contractAddress:i,functionName:a})}function Nd(e){const t={};return e.callGasLimit&&(t.callGasLimit=BigInt(e.callGasLimit)),e.preVerificationGas&&(t.preVerificationGas=BigInt(e.preVerificationGas)),e.verificationGasLimit&&(t.verificationGasLimit=BigInt(e.verificationGasLimit)),e.paymasterPostOpGasLimit&&(t.paymasterPostOpGasLimit=BigInt(e.paymasterPostOpGasLimit)),e.paymasterVerificationGasLimit&&(t.paymasterVerificationGasLimit=BigInt(e.paymasterVerificationGasLimit)),t}function bn(e){const t={};return typeof e.callData<"u"&&(t.callData=e.callData),typeof e.callGasLimit<"u"&&(t.callGasLimit=M(e.callGasLimit)),typeof e.factory<"u"&&(t.factory=e.factory),typeof e.factoryData<"u"&&(t.factoryData=e.factoryData),typeof e.initCode<"u"&&(t.initCode=e.initCode),typeof e.maxFeePerGas<"u"&&(t.maxFeePerGas=M(e.maxFeePerGas)),typeof e.maxPriorityFeePerGas<"u"&&(t.maxPriorityFeePerGas=M(e.maxPriorityFeePerGas)),typeof e.nonce<"u"&&(t.nonce=M(e.nonce)),typeof e.paymaster<"u"&&(t.paymaster=e.paymaster),typeof e.paymasterAndData<"u"&&(t.paymasterAndData=e.paymasterAndData||"0x"),typeof e.paymasterData<"u"&&(t.paymasterData=e.paymasterData),typeof e.paymasterPostOpGasLimit<"u"&&(t.paymasterPostOpGasLimit=M(e.paymasterPostOpGasLimit)),typeof e.paymasterVerificationGasLimit<"u"&&(t.paymasterVerificationGasLimit=M(e.paymasterVerificationGasLimit)),typeof e.preVerificationGas<"u"&&(t.preVerificationGas=M(e.preVerificationGas)),typeof e.sender<"u"&&(t.sender=e.sender),typeof e.signature<"u"&&(t.signature=e.signature),typeof e.verificationGasLimit<"u"&&(t.verificationGasLimit=M(e.verificationGasLimit)),typeof e.authorization<"u"&&(t.eip7702Auth=Bd(e.authorization)),t}function Bd(e){return{address:e.address,chainId:M(e.chainId),nonce:M(e.nonce),r:e.r?M(BigInt(e.r),{size:32}):de("0x",{size:32}),s:e.s?M(BigInt(e.s),{size:32}):de("0x",{size:32}),yParity:e.yParity?M(e.yParity,{size:1}):de("0x",{size:32})}}async function Ld(e,t){const{chainId:n,entryPointAddress:r,context:a,...s}=t,i=bn(s),{paymasterPostOpGasLimit:o,paymasterVerificationGasLimit:c,...u}=await e.request({method:"pm_getPaymasterData",params:[{...i,callGasLimit:i.callGasLimit??"0x0",verificationGasLimit:i.verificationGasLimit??"0x0",preVerificationGas:i.preVerificationGas??"0x0"},r,M(n),a]});return{...u,...o&&{paymasterPostOpGasLimit:he(o)},...c&&{paymasterVerificationGasLimit:he(c)}}}async function Rd(e,t){const{chainId:n,entryPointAddress:r,context:a,...s}=t,i=bn(s),{paymasterPostOpGasLimit:o,paymasterVerificationGasLimit:c,...u}=await e.request({method:"pm_getPaymasterStubData",params:[{...i,callGasLimit:i.callGasLimit??"0x0",verificationGasLimit:i.verificationGasLimit??"0x0",preVerificationGas:i.preVerificationGas??"0x0"},r,M(n),a]});return{...u,...o&&{paymasterPostOpGasLimit:he(o)},...c&&{paymasterVerificationGasLimit:he(c)}}}const jd=["factory","fees","gas","paymaster","nonce","signature","authorization"];async function Lr(e,t){const n=t,{account:r=e.account,parameters:a=jd,stateOverride:s}=n;if(!r)throw new hn;const i=Ae(r),o=e,c=n.paymaster??o?.paymaster,u=typeof c=="string"?c:void 0,{getPaymasterStubData:d,getPaymasterData:l}=(()=>{if(c===!0)return{getPaymasterStubData:N=>W(o,Rd,"getPaymasterStubData")(N),getPaymasterData:N=>W(o,Ld,"getPaymasterData")(N)};if(typeof c=="object"){const{getPaymasterStubData:N,getPaymasterData:B}=c;return{getPaymasterStubData:B&&N?N:B,getPaymasterData:B&&N?B:void 0}}return{getPaymasterStubData:void 0,getPaymasterData:void 0}})(),p=n.paymasterContext?n.paymasterContext:o?.paymasterContext;let f={...n,paymaster:u,sender:i.address};const[y,g,h,w,E]=await Promise.all([(async()=>n.calls?i.encodeCalls(n.calls.map(N=>{const B=N;return B.abi?{data:oe(B),to:B.to,value:B.value}:B})):n.callData)(),(async()=>{if(!a.includes("factory"))return;if(n.initCode)return{initCode:n.initCode};if(n.factory&&n.factoryData)return{factory:n.factory,factoryData:n.factoryData};const{factory:N,factoryData:B}=await i.getFactoryArgs();return i.entryPoint.version==="0.6"?{initCode:N&&B?je([N,B]):void 0}:{factory:N,factoryData:B}})(),(async()=>{if(a.includes("fees")){if(typeof n.maxFeePerGas=="bigint"&&typeof n.maxPriorityFeePerGas=="bigint")return f;if(o?.userOperation?.estimateFeesPerGas){const N=await o.userOperation.estimateFeesPerGas({account:i,bundlerClient:o,userOperation:f});return{...f,...N}}try{const N=o.client??e,B=await W(N,ws,"estimateFeesPerGas")({chain:N.chain,type:"eip1559"});return{maxFeePerGas:typeof n.maxFeePerGas=="bigint"?n.maxFeePerGas:BigInt(2n*B.maxFeePerGas),maxPriorityFeePerGas:typeof n.maxPriorityFeePerGas=="bigint"?n.maxPriorityFeePerGas:BigInt(2n*B.maxPriorityFeePerGas)}}catch{return}}})(),(async()=>{if(a.includes("nonce"))return typeof n.nonce=="bigint"?n.nonce:i.getNonce()})(),(async()=>{if(a.includes("authorization")){if(typeof n.authorization=="object")return n.authorization;if(i.authorization&&!await i.isDeployed())return{...await id(i.client,i.authorization),r:"0xfffffffffffffffffffffffffffffff000000000000000000000000000000000",s:"0x7aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",yParity:1}}})()]);typeof y<"u"&&(f.callData=y),typeof g<"u"&&(f={...f,...g}),typeof h<"u"&&(f={...f,...h}),typeof w<"u"&&(f.nonce=w),typeof E<"u"&&(f.authorization=E),a.includes("signature")&&(typeof n.signature<"u"?f.signature=n.signature:f.signature=await i.getStubSignature(f)),i.entryPoint.version==="0.6"&&!f.initCode&&(f.initCode="0x");let b;async function A(){return b||(e.chain?e.chain.id:(b=await W(e,yn,"getChainId")({}),b))}let I=!1;if(a.includes("paymaster")&&d&&!u&&!n.paymasterAndData){const{isFinal:N=!1,sponsor:B,...j}=await d({chainId:await A(),entryPointAddress:i.entryPoint.address,context:p,...f});I=N,f={...f,...j}}if(i.entryPoint.version==="0.6"&&!f.paymasterAndData&&(f.paymasterAndData="0x"),a.includes("gas")){if(i.userOperation?.estimateGas){const N=await i.userOperation.estimateGas(f);f={...f,...N}}if(typeof f.callGasLimit>"u"||typeof f.preVerificationGas>"u"||typeof f.verificationGasLimit>"u"||f.paymaster&&typeof f.paymasterPostOpGasLimit>"u"||f.paymaster&&typeof f.paymasterVerificationGasLimit>"u"){const N=await W(o,Hs,"estimateUserOperationGas")({account:i,callGasLimit:0n,preVerificationGas:0n,verificationGasLimit:0n,stateOverride:s,...f.paymaster?{paymasterPostOpGasLimit:0n,paymasterVerificationGasLimit:0n}:{},...f});f={...f,callGasLimit:f.callGasLimit??N.callGasLimit,preVerificationGas:f.preVerificationGas??N.preVerificationGas,verificationGasLimit:f.verificationGasLimit??N.verificationGasLimit,paymasterPostOpGasLimit:f.paymasterPostOpGasLimit??N.paymasterPostOpGasLimit,paymasterVerificationGasLimit:f.paymasterVerificationGasLimit??N.paymasterVerificationGasLimit}}}if(a.includes("paymaster")&&l&&!u&&!n.paymasterAndData&&!I){const N=await l({chainId:await A(),entryPointAddress:i.entryPoint.address,context:p,...f});f={...f,...N}}return delete f.calls,delete f.parameters,delete f.paymasterContext,typeof f.paymaster!="string"&&delete f.paymaster,f}async function Hs(e,t){const{account:n=e.account,entryPointAddress:r,stateOverride:a}=t;if(!n&&!t.sender)throw new hn;const s=n?Ae(n):void 0,i=cs(a),o=s?await W(e,Lr,"prepareUserOperation")({...t,parameters:["authorization","factory","nonce","paymaster","signature"]}):t;try{const c=[bn(o),r??s?.entryPoint?.address],u=await e.request({method:"eth_estimateUserOperationGas",params:i?[...c,i]:[...c]});return Nd(u)}catch(c){const u=t.calls;throw Gs(c,{...o,...u?{calls:u}:{}})}}function Md(e){return e.request({method:"eth_supportedEntryPoints"})}function Dd(e){const t={...e};return e.callGasLimit&&(t.callGasLimit=BigInt(e.callGasLimit)),e.maxFeePerGas&&(t.maxFeePerGas=BigInt(e.maxFeePerGas)),e.maxPriorityFeePerGas&&(t.maxPriorityFeePerGas=BigInt(e.maxPriorityFeePerGas)),e.nonce&&(t.nonce=BigInt(e.nonce)),e.paymasterPostOpGasLimit&&(t.paymasterPostOpGasLimit=BigInt(e.paymasterPostOpGasLimit)),e.paymasterVerificationGasLimit&&(t.paymasterVerificationGasLimit=BigInt(e.paymasterVerificationGasLimit)),e.preVerificationGas&&(t.preVerificationGas=BigInt(e.preVerificationGas)),e.verificationGasLimit&&(t.verificationGasLimit=BigInt(e.verificationGasLimit)),t}async function Ud(e,{hash:t}){const n=await e.request({method:"eth_getUserOperationByHash",params:[t]},{dedupe:!0});if(!n)throw new Id({hash:t});const{blockHash:r,blockNumber:a,entryPoint:s,transactionHash:i,userOperation:o}=n;return{blockHash:r,blockNumber:BigInt(a),entryPoint:s,transactionHash:i,userOperation:Dd(o)}}function Fd(e){const t={...e};return e.actualGasCost&&(t.actualGasCost=BigInt(e.actualGasCost)),e.actualGasUsed&&(t.actualGasUsed=BigInt(e.actualGasUsed)),e.logs&&(t.logs=e.logs.map(n=>De(n))),e.receipt&&(t.receipt=Nc(t.receipt)),t}async function zs(e,{hash:t}){const n=await e.request({method:"eth_getUserOperationReceipt",params:[t]},{dedupe:!0});if(!n)throw new _d({hash:t});return Fd(n)}async function $d(e,t){const{account:n=e.account,entryPointAddress:r}=t;if(!n&&!t.sender)throw new hn;const a=n?Ae(n):void 0,s=a?await W(e,Lr,"prepareUserOperation")(t):t,i=t.signature||await a?.signUserOperation?.(s),o=bn({...s,signature:i});try{return await e.request({method:"eth_sendUserOperation",params:[o,r??a?.entryPoint?.address]},{retryCount:0})}catch(c){const u=t.calls;throw Gs(c,{...s,...u?{calls:u}:{},signature:i})}}function Gd(e,t){const{hash:n,pollingInterval:r=e.pollingInterval,retryCount:a,timeout:s=12e4}=t;let i=0;const o=ut(["waitForUserOperationReceipt",e.uid,n]);return new Promise((c,u)=>{const d=dt(o,{resolve:c,reject:u},l=>{const p=y=>{f(),y(),d()},f=Bt(async()=>{a&&i>=a&&p(()=>l.reject(new ma({hash:n})));try{const y=await W(e,zs,"getUserOperationReceipt")({hash:n});p(()=>l.resolve(y))}catch(y){const g=y;g.name!=="UserOperationReceiptNotFoundError"&&p(()=>l.reject(g))}i++},{emitOnBegin:!0,interval:r});return s&&setTimeout(()=>p(()=>l.reject(new ma({hash:n}))),s),f})})}function Hd(e){return{estimateUserOperationGas:t=>Hs(e,t),getChainId:()=>yn(e),getSupportedEntryPoints:()=>Md(e),getUserOperation:t=>Ud(e,t),getUserOperationReceipt:t=>zs(e,t),prepareUserOperation:t=>Lr(e,t),sendUserOperation:t=>$d(e,t),waitForUserOperationReceipt:t=>Gd(e,t)}}function zd(e){const{client:t,key:n="bundler",name:r="Bundler Client",paymaster:a,paymasterContext:s,transport:i,userOperation:o}=e;return Object.assign(vs({...e,chain:e.chain??t?.chain,key:n,name:r,transport:i,type:"bundlerClient"}),{client:t,paymaster:a,paymasterContext:s,userOperation:o}).extend(Hd)}const qd="0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",Wd="0.1.1";function Vd(){return Wd}class Y extends Error{constructor(t,n={}){const r=(()=>{if(n.cause instanceof Y){if(n.cause.details)return n.cause.details;if(n.cause.shortMessage)return n.cause.shortMessage}return n.cause?.message?n.cause.message:n.details})(),a=n.cause instanceof Y&&n.cause.docsPath||n.docsPath,i=`https://oxlib.sh${a??""}`,o=[t||"An error occurred.",...n.metaMessages?["",...n.metaMessages]:[],...r||a?["",r?`Details: ${r}`:void 0,a?`See: ${i}`:void 0]:[]].filter(c=>typeof c=="string").join(`
|
|
`);super(o,n.cause?{cause:n.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:`ox@${Vd()}`}),this.cause=n.cause,this.details=r,this.docs=i,this.docsPath=a,this.shortMessage=t}walk(t){return qs(this,t)}}function qs(e,t){return t?.(e)?e:e&&typeof e=="object"&&"cause"in e&&e.cause?qs(e.cause,t):t?null:e}const Kd="#__bigint";function wn(e,t,n){return JSON.stringify(e,(r,a)=>typeof a=="bigint"?a.toString()+Kd:a,n)}function Jd(e,t){if(pt(e)>t)throw new ll({givenSize:pt(e),maxSize:t})}function Zd(e,t){if(typeof t=="number"&&t>0&&t>pt(e)-1)throw new ei({offset:t,position:"start",size:pt(e)})}function Yd(e,t,n){if(typeof t=="number"&&typeof n=="number"&&pt(e)!==n-t)throw new ei({offset:n,position:"end",size:pt(e)})}const _e={zero:48,nine:57,A:65,F:70,a:97,f:102};function ha(e){if(e>=_e.zero&&e<=_e.nine)return e-_e.zero;if(e>=_e.A&&e<=_e.F)return e-(_e.A-10);if(e>=_e.a&&e<=_e.f)return e-(_e.a-10)}function Rr(e,t){if(Ue(e)>t)throw new ol({givenSize:Ue(e),maxSize:t})}function Qd(e,t){if(typeof t=="number"&&t>0&&t>Ue(e)-1)throw new Zs({offset:t,position:"start",size:Ue(e)})}function Xd(e,t,n){if(typeof t=="number"&&typeof n=="number"&&Ue(e)!==n-t)throw new Zs({offset:n,position:"end",size:Ue(e)})}function Ws(e,t={}){const{dir:n,size:r=32}=t;if(r===0)return e;const a=e.replace("0x","");if(a.length>r*2)throw new cl({size:Math.ceil(a.length/2),targetSize:r,type:"Hex"});return`0x${a[n==="right"?"padEnd":"padStart"](r*2,"0")}`}const el=new TextEncoder,tl=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function nl(e,t={}){const{strict:n=!1}=t;if(!e)throw new ya(e);if(typeof e!="string")throw new ya(e);if(n&&!/^0x[0-9a-fA-F]*$/.test(e))throw new ga(e);if(!e.startsWith("0x"))throw new ga(e)}function vn(...e){return`0x${e.reduce((t,n)=>t+n.replace("0x",""),"")}`}function Vs(e){return e instanceof Uint8Array?ft(e):Array.isArray(e)?ft(new Uint8Array(e)):e}function ft(e,t={}){let n="";for(let a=0;a<e.length;a++)n+=tl[e[a]];const r=`0x${n}`;return typeof t.size=="number"?(Rr(r,t.size),Js(r,t.size)):r}function Me(e,t={}){const{signed:n,size:r}=t,a=BigInt(e);let s;r?n?s=(1n<<BigInt(r)*8n-1n)-1n:s=2n**(BigInt(r)*8n)-1n:typeof e=="number"&&(s=BigInt(Number.MAX_SAFE_INTEGER));const i=typeof s=="bigint"&&n?-s-1n:0;if(s&&a>s||a<i){const u=typeof e=="bigint"?"n":"";throw new il({max:s?`${s}${u}`:void 0,min:`${i}${u}`,signed:n,size:r,value:`${e}${u}`})}const c=`0x${(n&&a<0?(1n<<BigInt(r*8))+BigInt(a):a).toString(16)}`;return r?rl(c,r):c}function Ks(e,t={}){return ft(el.encode(e),t)}function rl(e,t){return Ws(e,{dir:"left",size:t})}function Js(e,t){return Ws(e,{dir:"right",size:t})}function me(e,t,n,r={}){const{strict:a}=r;Qd(e,t);const s=`0x${e.replace("0x","").slice((t??0)*2,(n??e.length)*2)}`;return a&&Xd(s,t,n),s}function Ue(e){return Math.ceil((e.length-2)/2)}function al(e,t={}){const{signed:n}=t;t.size&&Rr(e,t.size);const r=BigInt(e);if(!n)return r;const a=(e.length-2)/2,s=(1n<<BigInt(a)*8n)-1n,i=s>>1n;return r<=i?r:r-s-1n}function sl(e,t={}){const{strict:n=!1}=t;try{return nl(e,{strict:n}),!0}catch{return!1}}class il extends Y{constructor({max:t,min:n,signed:r,size:a,value:s}){super(`Number \`${s}\` is not in safe${a?` ${a*8}-bit`:""}${r?" signed":" unsigned"} integer range ${t?`(\`${n}\` to \`${t}\`)`:`(above \`${n}\`)`}`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.IntegerOutOfRangeError"})}}class ya extends Y{constructor(t){super(`Value \`${typeof t=="object"?wn(t):t}\` of type \`${typeof t}\` is an invalid hex type.`,{metaMessages:['Hex types must be represented as `"0x${string}"`.']}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.InvalidHexTypeError"})}}class ga extends Y{constructor(t){super(`Value \`${t}\` is an invalid hex value.`,{metaMessages:['Hex values must start with `"0x"` and contain only hexadecimal characters (0-9, a-f, A-F).']}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.InvalidHexValueError"})}}let ol=class extends Y{constructor({givenSize:t,maxSize:n}){super(`Size cannot exceed \`${n}\` bytes. Given size: \`${t}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeOverflowError"})}},Zs=class extends Y{constructor({offset:t,position:n,size:r}){super(`Slice ${n==="start"?"starting":"ending"} at offset \`${t}\` is out-of-bounds (size: \`${r}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SliceOffsetOutOfBoundsError"})}};class cl extends Y{constructor({size:t,targetSize:n,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} size (\`${t}\`) exceeds padding size (\`${n}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeExceedsPaddingSizeError"})}}function ul(e){if(!(e instanceof Uint8Array)){if(!e)throw new Dt(e);if(typeof e!="object")throw new Dt(e);if(!("BYTES_PER_ELEMENT"in e))throw new Dt(e);if(e.BYTES_PER_ELEMENT!==1||e.constructor.name!=="Uint8Array")throw new Dt(e)}}function Ys(e){return e instanceof Uint8Array?e:typeof e=="string"?Xs(e):Qs(e)}function Qs(e){return e instanceof Uint8Array?e:new Uint8Array(e)}function Xs(e,t={}){const{size:n}=t;let r=e;n&&(Rr(e,n),r=Js(e,n));let a=r.slice(2);a.length%2&&(a=`0${a}`);const s=a.length/2,i=new Uint8Array(s);for(let o=0,c=0;o<s;o++){const u=ha(a.charCodeAt(c++)),d=ha(a.charCodeAt(c++));if(u===void 0||d===void 0)throw new Y(`Invalid byte sequence ("${a[c-2]}${a[c-1]}" in "${a}").`);i[o]=u*16+d}return i}function pt(e){return e.length}function ba(e,t,n,r={}){const{strict:a}=r;Zd(e,t);const s=e.slice(t,n);return a&&Yd(s,t,n),s}function wa(e,t={}){const{size:n}=t;typeof n<"u"&&Jd(e,n);const r=ft(e,t);return al(r,t)}function dl(e){try{return ul(e),!0}catch{return!1}}class Dt extends Y{constructor(t){super(`Value \`${typeof t=="object"?wn(t):t}\` of type \`${typeof t}\` is an invalid Bytes value.`,{metaMessages:["Bytes values must be of type `Bytes`."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.InvalidBytesTypeError"})}}class ll extends Y{constructor({givenSize:t,maxSize:n}){super(`Size cannot exceed \`${n}\` bytes. Given size: \`${t}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeOverflowError"})}}class ei extends Y{constructor({offset:t,position:n,size:r}){super(`Slice ${n==="start"?"starting":"ending"} at offset \`${t}\` is out-of-bounds (size: \`${r}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SliceOffsetOutOfBoundsError"})}}function ti(e,t={}){const{as:n=typeof e=="string"?"Hex":"Bytes"}=t,r=Bc(Ys(e));return n==="Bytes"?r:ft(r)}function ni(e,t={}){const{compressed:n}=t,{prefix:r,x:a,y:s}=e;if(n===!1||typeof a=="bigint"&&typeof s=="bigint"){if(r!==4)throw new va({prefix:r,cause:new yl});return}if(n===!0||typeof a=="bigint"&&typeof s>"u"){if(r!==3&&r!==2)throw new va({prefix:r,cause:new hl});return}throw new ml({publicKey:e})}function fl(e){const t=(()=>{if(sl(e))return ri(e);if(dl(e))return pl(e);const{prefix:n,x:r,y:a}=e;return typeof r=="bigint"&&typeof a=="bigint"?{prefix:n??4,x:r,y:a}:{prefix:n,x:r}})();return ni(t),t}function pl(e){return ri(ft(e))}function ri(e){if(e.length!==132&&e.length!==130&&e.length!==68)throw new gl({publicKey:e});if(e.length===130){const r=BigInt(me(e,0,32)),a=BigInt(me(e,32,64));return{prefix:4,x:r,y:a}}if(e.length===132){const r=Number(me(e,0,1)),a=BigInt(me(e,1,33)),s=BigInt(me(e,33,65));return{prefix:r,x:a,y:s}}const t=Number(me(e,0,1)),n=BigInt(me(e,1,33));return{prefix:t,x:n}}function jr(e,t={}){ni(e);const{prefix:n,x:r,y:a}=e,{includePrefix:s=!0}=t;return vn(s?Me(n,{size:1}):"0x",Me(r,{size:32}),typeof a=="bigint"?Me(a,{size:32}):"0x")}class ml extends Y{constructor({publicKey:t}){super(`Value \`${wn(t)}\` is not a valid public key.`,{metaMessages:["Public key must contain:","- an `x` and `prefix` value (compressed)","- an `x`, `y`, and `prefix` value (uncompressed)"]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidError"})}}class va extends Y{constructor({prefix:t,cause:n}){super(`Prefix "${t}" is invalid.`,{cause:n}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidPrefixError"})}}class hl extends Y{constructor(){super("Prefix must be 2 or 3 for compressed public keys."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidCompressedPrefixError"})}}class yl extends Y{constructor(){super("Prefix must be 4 for uncompressed public keys."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidUncompressedPrefixError"})}}let gl=class extends Y{constructor({publicKey:t}){super(`Value \`${t}\` is an invalid public key size.`,{metaMessages:["Expected: 33 bytes (compressed + prefix), 64 bytes (uncompressed) or 65 bytes (uncompressed + prefix).",`Received ${Ue(Vs(t))} bytes.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidSerializedSizeError"})}};const ka=2n**256n-1n;function bl(e,t={}){const{recovered:n}=t;if(typeof e.r>"u")throw new _n({signature:e});if(typeof e.s>"u")throw new _n({signature:e});if(n&&typeof e.yParity>"u")throw new _n({signature:e});if(e.r<0n||e.r>ka)throw new El({value:e.r});if(e.s<0n||e.s>ka)throw new Sl({value:e.s});if(typeof e.yParity=="number"&&e.yParity!==0&&e.yParity!==1)throw new Mr({value:e.yParity})}function ai(e){if(e.length!==130&&e.length!==132)throw new xl({signature:e});const t=BigInt(me(e,0,32)),n=BigInt(me(e,32,64)),r=(()=>{const a=+`0x${e.slice(130)}`;if(!Number.isNaN(a))try{return vl(a)}catch{throw new Mr({value:a})}})();return typeof r>"u"?{r:t,s:n}:{r:t,s:n,yParity:r}}function wl(e){bl(e);const t=e.r,n=e.s;return vn(Me(t,{size:32}),Me(n,{size:32}),typeof e.yParity=="number"?Me(kl(e.yParity),{size:1}):"0x")}function vl(e){if(e===0||e===27)return 0;if(e===1||e===28)return 1;if(e>=35)return e%2===0?1:0;throw new Al({value:e})}function kl(e){if(e===0)return 27;if(e===1)return 28;throw new Mr({value:e})}class xl extends Y{constructor({signature:t}){super(`Value \`${t}\` is an invalid signature size.`,{metaMessages:["Expected: 64 bytes or 65 bytes.",`Received ${Ue(Vs(t))} bytes.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidSerializedSizeError"})}}class _n extends Y{constructor({signature:t}){super(`Signature \`${wn(t)}\` is missing either an \`r\`, \`s\`, or \`yParity\` property.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.MissingPropertiesError"})}}class El extends Y{constructor({value:t}){super(`Value \`${t}\` is an invalid r value. r must be a positive integer less than 2^256.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidRError"})}}class Sl extends Y{constructor({value:t}){super(`Value \`${t}\` is an invalid s value. s must be a positive integer less than 2^256.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidSError"})}}class Mr extends Y{constructor({value:t}){super(`Value \`${t}\` is an invalid y-parity value. Y-parity must be 0 or 1.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidYParityError"})}}class Al extends Y{constructor({value:t}){super(`Value \`${t}\` is an invalid v value. v must be 27, 28 or >=35.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidVError"})}}const _l=new TextDecoder,Ut=Object.fromEntries(Array.from("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/").map((e,t)=>[t,e.charCodeAt(0)]));({...Object.fromEntries(Array.from("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/").map((e,t)=>[e.charCodeAt(0),t]))});function Il(e,t={}){const{pad:n=!0,url:r=!1}=t,a=new Uint8Array(Math.ceil(e.length/3)*4);for(let c=0,u=0;u<e.length;c+=4,u+=3){const d=(e[u]<<16)+(e[u+1]<<8)+(e[u+2]|0);a[c]=Ut[d>>18],a[c+1]=Ut[d>>12&63],a[c+2]=Ut[d>>6&63],a[c+3]=Ut[d&63]}const s=e.length%3,i=Math.floor(e.length/3)*4+(s&&s+1);let o=_l.decode(new Uint8Array(a.buffer,0,i));return n&&s===1&&(o+="=="),n&&s===2&&(o+="="),r&&(o=o.replaceAll("+","-").replaceAll("/","_")),o}function Pl(e,t={}){return Il(Xs(e),t)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function xa(e){e.lowS!==void 0&&en("lowS",e.lowS),e.prehash!==void 0&&en("prehash",e.prehash)}class Ol extends Error{constructor(t=""){super(t)}}const Pe={Err:Ol,_tlv:{encode:(e,t)=>{const{Err:n}=Pe;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(t.length&1)throw new n("tlv.encode: unpadded data");const r=t.length/2,a=Mt(r);if(a.length/2&128)throw new n("tlv.encode: long form length too big");const s=r>127?Mt(a.length/2|128):"";return Mt(e)+s+a+t},decode(e,t){const{Err:n}=Pe;let r=0;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(t.length<2||t[r++]!==e)throw new n("tlv.decode: wrong tlv");const a=t[r++],s=!!(a&128);let i=0;if(!s)i=a;else{const c=a&127;if(!c)throw new n("tlv.decode(long): indefinite length not supported");if(c>4)throw new n("tlv.decode(long): byte length is too big");const u=t.subarray(r,r+c);if(u.length!==c)throw new n("tlv.decode: length bytes not complete");if(u[0]===0)throw new n("tlv.decode(long): zero leftmost byte");for(const d of u)i=i<<8|d;if(r+=c,i<128)throw new n("tlv.decode(long): not minimal encoding")}const o=t.subarray(r,r+i);if(o.length!==i)throw new n("tlv.decode: wrong value length");return{v:o,l:t.subarray(r+i)}}},_int:{encode(e){const{Err:t}=Pe;if(e<St)throw new t("integer: negative integers are not allowed");let n=Mt(e);if(Number.parseInt(n[0],16)&8&&(n="00"+n),n.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return n},decode(e){const{Err:t}=Pe;if(e[0]&128)throw new t("invalid signature integer: negative");if(e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return xs(e)}},toSig(e){const{Err:t,_int:n,_tlv:r}=Pe,a=pe("signature",e),{v:s,l:i}=r.decode(48,a);if(i.length)throw new t("invalid signature: left bytes after parsing");const{v:o,l:c}=r.decode(2,s),{v:u,l:d}=r.decode(2,c);if(d.length)throw new t("invalid signature: left bytes after parsing");return{r:n.decode(o),s:n.decode(u)}},hexFromSig(e){const{_tlv:t,_int:n}=Pe,r=t.encode(2,n.encode(e.r)),a=t.encode(2,n.encode(e.s)),s=r+a;return t.encode(48,s)}},St=BigInt(0),At=BigInt(1),Cl=BigInt(2),Ft=BigInt(3),Tl=BigInt(4);function Nl(e,t,n){function r(a){const s=e.sqr(a),i=e.mul(s,a);return e.add(e.add(i,e.mul(a,t)),n)}return r}function si(e,t,n){const{BYTES:r}=e;function a(s){let i;if(typeof s=="bigint")i=s;else{let o=pe("private key",s);if(t){if(!t.includes(o.length*2))throw new Error("invalid private key");const c=new Uint8Array(r);c.set(o,c.length-o.length),o=c}try{i=e.fromBytes(o)}catch{throw new Error(`invalid private key: expected ui8a of size ${r}, got ${typeof s}`)}}if(n&&(i=e.create(i)),!e.isValidNot0(i))throw new Error("invalid private key: out of range [1..N-1]");return i}return a}function Bl(e,t={}){const{Fp:n,Fn:r}=Lc("weierstrass",e,t),{h:a,n:s}=e;ks(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});const{endo:i}=t;if(i&&(!n.is0(e.a)||typeof i.beta!="bigint"||typeof i.splitScalar!="function"))throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function');function o(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function c(j,v,P){const{x,y:m}=v.toAffine(),k=n.toBytes(x);if(en("isCompressed",P),P){o();const C=!n.isOdd(m);return nt(ii(C),k)}else return nt(Uint8Array.of(4),k,n.toBytes(m))}function u(j){ra(j);const v=n.BYTES,P=v+1,x=2*v+1,m=j.length,k=j[0],C=j.subarray(1);if(m===P&&(k===2||k===3)){const O=n.fromBytes(C);if(!n.isValid(O))throw new Error("bad point: is not on curve, wrong x");const L=p(O);let R;try{R=n.sqrt(L)}catch(q){const F=q instanceof Error?": "+q.message:"";throw new Error("bad point: is not on curve, sqrt error"+F)}o();const S=n.isOdd(R);return(k&1)===1!==S&&(R=n.neg(R)),{x:O,y:R}}else if(m===x&&k===4){const O=n.fromBytes(C.subarray(v*0,v*1)),L=n.fromBytes(C.subarray(v*1,v*2));if(!f(O,L))throw new Error("bad point: is not on curve");return{x:O,y:L}}else throw new Error(`bad point: got length ${m}, expected compressed=${P} or uncompressed=${x}`)}const d=t.toBytes||c,l=t.fromBytes||u,p=Nl(n,e.a,e.b);function f(j,v){const P=n.sqr(v),x=p(j);return n.eql(P,x)}if(!f(e.Gx,e.Gy))throw new Error("bad curve params: generator point");const y=n.mul(n.pow(e.a,Ft),Tl),g=n.mul(n.sqr(e.b),BigInt(27));if(n.is0(n.add(y,g)))throw new Error("bad curve params: a or b");function h(j,v,P=!1){if(!n.isValid(v)||P&&n.is0(v))throw new Error(`bad point coordinate ${j}`);return v}function w(j){if(!(j instanceof I))throw new Error("ProjectivePoint expected")}const E=aa((j,v)=>{const{px:P,py:x,pz:m}=j;if(n.eql(m,n.ONE))return{x:P,y:x};const k=j.is0();v==null&&(v=k?n.ONE:n.inv(m));const C=n.mul(P,v),O=n.mul(x,v),L=n.mul(m,v);if(k)return{x:n.ZERO,y:n.ZERO};if(!n.eql(L,n.ONE))throw new Error("invZ was invalid");return{x:C,y:O}}),b=aa(j=>{if(j.is0()){if(t.allowInfinityPoint&&!n.is0(j.py))return;throw new Error("bad point: ZERO")}const{x:v,y:P}=j.toAffine();if(!n.isValid(v)||!n.isValid(P))throw new Error("bad point: x or y not field elements");if(!f(v,P))throw new Error("bad point: equation left != right");if(!j.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function A(j,v,P,x,m){return P=new I(n.mul(P.px,j),P.py,P.pz),v=sa(x,v),P=sa(m,P),v.add(P)}class I{constructor(v,P,x){this.px=h("x",v),this.py=h("y",P,!0),this.pz=h("z",x),Object.freeze(this)}static fromAffine(v){const{x:P,y:x}=v||{};if(!v||!n.isValid(P)||!n.isValid(x))throw new Error("invalid affine point");if(v instanceof I)throw new Error("projective point not allowed");return n.is0(P)&&n.is0(x)?I.ZERO:new I(P,x,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(v){return Uc(I,"pz",v)}static fromBytes(v){return ra(v),I.fromHex(v)}static fromHex(v){const P=I.fromAffine(l(pe("pointHex",v)));return P.assertValidity(),P}static fromPrivateKey(v){const P=si(r,t.allowedPrivateKeyLengths,t.wrapPrivateKey);return I.BASE.multiply(P(v))}static msm(v,P){return Fc(I,r,v,P)}precompute(v=8,P=!0){return B.setWindowSize(this,v),P||this.multiply(Ft),this}_setWindowSize(v){this.precompute(v)}assertValidity(){b(this)}hasEvenY(){const{y:v}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(v)}equals(v){w(v);const{px:P,py:x,pz:m}=this,{px:k,py:C,pz:O}=v,L=n.eql(n.mul(P,O),n.mul(k,m)),R=n.eql(n.mul(x,O),n.mul(C,m));return L&&R}negate(){return new I(this.px,n.neg(this.py),this.pz)}double(){const{a:v,b:P}=e,x=n.mul(P,Ft),{px:m,py:k,pz:C}=this;let O=n.ZERO,L=n.ZERO,R=n.ZERO,S=n.mul(m,m),$=n.mul(k,k),q=n.mul(C,C),F=n.mul(m,k);return F=n.add(F,F),R=n.mul(m,C),R=n.add(R,R),O=n.mul(v,R),L=n.mul(x,q),L=n.add(O,L),O=n.sub($,L),L=n.add($,L),L=n.mul(O,L),O=n.mul(F,O),R=n.mul(x,R),q=n.mul(v,q),F=n.sub(S,q),F=n.mul(v,F),F=n.add(F,R),R=n.add(S,S),S=n.add(R,S),S=n.add(S,q),S=n.mul(S,F),L=n.add(L,S),q=n.mul(k,C),q=n.add(q,q),S=n.mul(q,F),O=n.sub(O,S),R=n.mul(q,$),R=n.add(R,R),R=n.add(R,R),new I(O,L,R)}add(v){w(v);const{px:P,py:x,pz:m}=this,{px:k,py:C,pz:O}=v;let L=n.ZERO,R=n.ZERO,S=n.ZERO;const $=e.a,q=n.mul(e.b,Ft);let F=n.mul(P,k),ee=n.mul(x,C),te=n.mul(m,O),ne=n.add(P,x),K=n.add(k,C);ne=n.mul(ne,K),K=n.add(F,ee),ne=n.sub(ne,K),K=n.add(P,m);let se=n.add(k,O);return K=n.mul(K,se),se=n.add(F,te),K=n.sub(K,se),se=n.add(x,m),L=n.add(C,O),se=n.mul(se,L),L=n.add(ee,te),se=n.sub(se,L),S=n.mul($,K),L=n.mul(q,te),S=n.add(L,S),L=n.sub(ee,S),S=n.add(ee,S),R=n.mul(L,S),ee=n.add(F,F),ee=n.add(ee,F),te=n.mul($,te),K=n.mul(q,K),ee=n.add(ee,te),te=n.sub(F,te),te=n.mul($,te),K=n.add(K,te),F=n.mul(ee,K),R=n.add(R,F),F=n.mul(se,K),L=n.mul(ne,L),L=n.sub(L,F),F=n.mul(ne,ee),S=n.mul(se,S),S=n.add(S,F),new I(L,R,S)}subtract(v){return this.add(v.negate())}is0(){return this.equals(I.ZERO)}multiply(v){const{endo:P}=t;if(!r.isValidNot0(v))throw new Error("invalid scalar: out of range");let x,m;const k=C=>B.wNAFCached(this,C,I.normalizeZ);if(P){const{k1neg:C,k1:O,k2neg:L,k2:R}=P.splitScalar(v),{p:S,f:$}=k(O),{p:q,f:F}=k(R);m=$.add(F),x=A(P.beta,S,q,C,L)}else{const{p:C,f:O}=k(v);x=C,m=O}return I.normalizeZ([x,m])[0]}multiplyUnsafe(v){const{endo:P}=t,x=this;if(!r.isValid(v))throw new Error("invalid scalar: out of range");if(v===St||x.is0())return I.ZERO;if(v===At)return x;if(B.hasPrecomputes(this))return this.multiply(v);if(P){const{k1neg:m,k1:k,k2neg:C,k2:O}=P.splitScalar(v),{p1:L,p2:R}=$c(I,x,k,O);return A(P.beta,L,R,m,C)}else return B.wNAFCachedUnsafe(x,v)}multiplyAndAddUnsafe(v,P,x){const m=this.multiplyUnsafe(P).add(v.multiplyUnsafe(x));return m.is0()?void 0:m}toAffine(v){return E(this,v)}isTorsionFree(){const{isTorsionFree:v}=t;return a===At?!0:v?v(I,this):B.wNAFCachedUnsafe(this,s).is0()}clearCofactor(){const{clearCofactor:v}=t;return a===At?this:v?v(I,this):this.multiplyUnsafe(a)}toBytes(v=!0){return en("isCompressed",v),this.assertValidity(),d(I,this,v)}toRawBytes(v=!0){return this.toBytes(v)}toHex(v=!0){return Rn(this.toBytes(v))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}I.BASE=new I(e.Gx,e.Gy,n.ONE),I.ZERO=new I(n.ZERO,n.ONE,n.ZERO),I.Fp=n,I.Fn=r;const N=r.BITS,B=Rc(I,t.endo?Math.ceil(N/2):N);return I}function ii(e){return Uint8Array.of(e?2:3)}function Ll(e,t,n={}){ks(t,{hash:"function"},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const r=t.randomBytes||jc,a=t.hmac||((x,...m)=>Mc.hmac(t.hash,x,nt(...m))),{Fp:s,Fn:i}=e,{ORDER:o,BITS:c}=i;function u(x){const m=o>>At;return x>m}function d(x){return u(x)?i.neg(x):x}function l(x,m){if(!i.isValidNot0(m))throw new Error(`invalid signature ${x}: out of range 1..CURVE.n`)}class p{constructor(m,k,C){l("r",m),l("s",k),this.r=m,this.s=k,C!=null&&(this.recovery=C),Object.freeze(this)}static fromCompact(m){const k=i.BYTES,C=pe("compactSignature",m,k*2);return new p(i.fromBytes(C.subarray(0,k)),i.fromBytes(C.subarray(k,k*2)))}static fromDER(m){const{r:k,s:C}=Pe.toSig(pe("DER",m));return new p(k,C)}assertValidity(){}addRecoveryBit(m){return new p(this.r,this.s,m)}recoverPublicKey(m){const k=s.ORDER,{r:C,s:O,recovery:L}=this;if(L==null||![0,1,2,3].includes(L))throw new Error("recovery id invalid");if(o*Cl<k&&L>1)throw new Error("recovery id is ambiguous for h>1 curve");const S=L===2||L===3?C+o:C;if(!s.isValid(S))throw new Error("recovery id 2 or 3 invalid");const $=s.toBytes(S),q=e.fromHex(nt(ii((L&1)===0),$)),F=i.inv(S),ee=b(pe("msgHash",m)),te=i.create(-ee*F),ne=i.create(O*F),K=e.BASE.multiplyUnsafe(te).add(q.multiplyUnsafe(ne));if(K.is0())throw new Error("point at infinify");return K.assertValidity(),K}hasHighS(){return u(this.s)}normalizeS(){return this.hasHighS()?new p(this.r,i.neg(this.s),this.recovery):this}toBytes(m){if(m==="compact")return nt(i.toBytes(this.r),i.toBytes(this.s));if(m==="der")return Gc(Pe.hexFromSig(this));throw new Error("invalid format")}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return Rn(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return Rn(this.toBytes("compact"))}}const f=si(i,n.allowedPrivateKeyLengths,n.wrapPrivateKey),y={isValidPrivateKey(x){try{return f(x),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{const x=o;return Hc(r(zc(x)),x)},precompute(x=8,m=e.BASE){return m.precompute(x,!1)}};function g(x,m=!0){return e.fromPrivateKey(x).toBytes(m)}function h(x){if(typeof x=="bigint")return!1;if(x instanceof e)return!0;const k=pe("key",x).length,C=s.BYTES,O=C+1,L=2*C+1;if(!(n.allowedPrivateKeyLengths||i.BYTES===O))return k===O||k===L}function w(x,m,k=!0){if(h(x)===!0)throw new Error("first arg must be private key");if(h(m)===!1)throw new Error("second arg must be public key");return e.fromHex(m).multiply(f(x)).toBytes(k)}const E=t.bits2int||function(x){if(x.length>8192)throw new Error("input is too large");const m=xs(x),k=x.length*8-c;return k>0?m>>BigInt(k):m},b=t.bits2int_modN||function(x){return i.create(E(x))},A=Dc(c);function I(x){return Vc("num < 2^"+c,x,St,A),i.toBytes(x)}function N(x,m,k=B){if(["recovered","canonical"].some(ne=>ne in k))throw new Error("sign() legacy options not supported");const{hash:C}=t;let{lowS:O,prehash:L,extraEntropy:R}=k;O==null&&(O=!0),x=pe("msgHash",x),xa(k),L&&(x=pe("prehashed msgHash",C(x)));const S=b(x),$=f(m),q=[I($),I(S)];if(R!=null&&R!==!1){const ne=R===!0?r(s.BYTES):R;q.push(pe("extraEntropy",ne))}const F=nt(...q),ee=S;function te(ne){const K=E(ne);if(!i.isValidNot0(K))return;const se=i.inv(K),yt=e.BASE.multiply(K).toAffine(),Ye=i.create(yt.x);if(Ye===St)return;const $e=i.create(se*i.create(ee+Ye*$));if($e===St)return;let Sn=(yt.x===Ye?0:2)|Number(yt.y&At),Qe=$e;return O&&u($e)&&(Qe=d($e),Sn^=1),new p(Ye,Qe,Sn)}return{seed:F,k2sig:te}}const B={lowS:t.lowS,prehash:!1},j={lowS:t.lowS,prehash:!1};function v(x,m,k=B){const{seed:C,k2sig:O}=N(x,m,k);return qc(t.hash.outputLen,i.BYTES,a)(C,O)}e.BASE.precompute(8);function P(x,m,k,C=j){const O=x;m=pe("msgHash",m),k=pe("publicKey",k),xa(C);const{lowS:L,prehash:R,format:S}=C;if("strict"in C)throw new Error("options.strict was renamed to lowS");if(S!==void 0&&!["compact","der","js"].includes(S))throw new Error('format must be "compact", "der" or "js"');const $=typeof O=="string"||Wc(O),q=!$&&!S&&typeof O=="object"&&O!==null&&typeof O.r=="bigint"&&typeof O.s=="bigint";if(!$&&!q)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let F,ee;try{if(q)if(S===void 0||S==="js")F=new p(O.r,O.s);else throw new Error("invalid format");if($){try{S!=="compact"&&(F=p.fromDER(O))}catch(Qe){if(!(Qe instanceof Pe.Err))throw Qe}!F&&S!=="der"&&(F=p.fromCompact(O))}ee=e.fromHex(k)}catch{return!1}if(!F||L&&F.hasHighS())return!1;R&&(m=t.hash(m));const{r:te,s:ne}=F,K=b(m),se=i.inv(ne),yt=i.create(K*se),Ye=i.create(te*se),$e=e.BASE.multiplyUnsafe(yt).add(ee.multiplyUnsafe(Ye));return $e.is0()?!1:i.create($e.x)===te}return Object.freeze({getPublicKey:g,getSharedSecret:w,sign:v,verify:P,utils:y,Point:e,Signature:p})}function Rl(e){const t={a:e.a,b:e.b,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},n=e.Fp,r=gn(t.n,e.nBitLength),a={Fp:n,Fn:r,allowedPrivateKeyLengths:e.allowedPrivateKeyLengths,allowInfinityPoint:e.allowInfinityPoint,endo:e.endo,wrapPrivateKey:e.wrapPrivateKey,isTorsionFree:e.isTorsionFree,clearCofactor:e.clearCofactor,fromBytes:e.fromBytes,toBytes:e.toBytes};return{CURVE:t,curveOpts:a}}function jl(e){const{CURVE:t,curveOpts:n}=Rl(e),r={hash:e.hash,hmac:e.hmac,randomBytes:e.randomBytes,lowS:e.lowS,bits2int:e.bits2int,bits2int_modN:e.bits2int_modN};return{CURVE:t,curveOpts:n,ecdsaOpts:r}}function Ml(e,t){return Object.assign({},t,{ProjectivePoint:t.Point,CURVE:e})}function Dl(e){const{CURVE:t,curveOpts:n,ecdsaOpts:r}=jl(e),a=Bl(t,n),s=Ll(a,r,n);return Ml(e,s)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Dr(e,t){const n=r=>Dl({...e,hash:r});return{...n(t),create:n}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const oi={p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")},ci={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff"),n:BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),h:BigInt(1),a:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000fffffffc"),b:BigInt("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef"),Gx:BigInt("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),Gy:BigInt("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f")},ui={p:BigInt("0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),n:BigInt("0x01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409"),h:BigInt(1),a:BigInt("0x1fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc"),b:BigInt("0x0051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00"),Gx:BigInt("0x00c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66"),Gy:BigInt("0x011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650")},Ul=gn(oi.p),Fl=gn(ci.p),$l=gn(ui.p),Gl=Dr({...oi,Fp:Ul,lowS:!1},Kc);Dr({...ci,Fp:Fl,lowS:!1},Jc);Dr({...ui,Fp:$l,lowS:!1,allowedPrivateKeyLengths:[130,131,132]},Zc);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ea=Gl;Uint8Array.from([105,171,180,181,160,222,75,198,42,42,32,31,141,37,186,233]);function Hl(e={}){const{flag:t=5,rpId:n=window.location.hostname,signCount:r=0}=e,a=ti(Ks(n)),s=Me(t,{size:1}),i=Me(r,{size:4});return vn(a,s,i)}function zl(e){const{challenge:t,crossOrigin:n=!1,extraClientData:r,origin:a=window.location.origin}=e;return JSON.stringify({type:"webauthn.get",challenge:Pl(t,{url:!0,pad:!1}),origin:a,crossOrigin:n,...r})}function ql(e){const{challenge:t,crossOrigin:n,extraClientData:r,flag:a,origin:s,rpId:i,signCount:o,userVerification:c="required"}=e,u=Hl({flag:a,rpId:i,signCount:o}),d=zl({challenge:t,crossOrigin:n,extraClientData:r,origin:s}),l=ti(Ks(d)),p=d.indexOf('"challenge"'),f=d.indexOf('"type"'),y={authenticatorData:u,clientDataJSON:d,challengeIndex:p,typeIndex:f,userVerificationRequired:c==="required"},g=vn(u,l);return{metadata:y,payload:g}}async function Wl(e={}){const{extractable:t=!1}=e,n=await globalThis.crypto.subtle.generateKey({name:"ECDSA",namedCurve:"P-256"},t,["sign","verify"]),r=await globalThis.crypto.subtle.exportKey("raw",n.publicKey),a=fl(new Uint8Array(r));return{privateKey:n.privateKey,publicKey:a}}async function Vl(e){const{payload:t,privateKey:n}=e,r=await globalThis.crypto.subtle.sign({name:"ECDSA",hash:"SHA-256"},n,Ys(t)),a=Qs(new Uint8Array(r)),s=wa(ba(a,0,32));let i=wa(ba(a,32,64));return i>Ea.CURVE.n/2n&&(i=Ea.CURVE.n-i),{r:s,s:i}}const ht="4.3.6",di="@coinbase/wallet-sdk",Kl=()=>({chains:[]}),Jl=()=>({keys:{}}),Zl=()=>({account:{}}),Yl=()=>({subAccount:void 0}),Ql=()=>({subAccountConfig:{}}),Xl=()=>({spendPermissions:[]}),ef=()=>({config:{version:ht}}),X=Br(bd((...e)=>Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},Kl(...e)),Jl(...e)),Zl(...e)),Yl(...e)),Xl(...e)),ef(...e)),Ql(...e)),{name:"cbwsdk.store",storage:Us(()=>localStorage),partialize:e=>({chains:e.chains,keys:e.keys,account:e.account,subAccount:e.subAccount,spendPermissions:e.spendPermissions,config:e.config})})),tf={get:()=>X.getState().subAccountConfig,set:e=>{X.setState(t=>({subAccountConfig:Object.assign(Object.assign({},t.subAccountConfig),e)}))},clear:()=>{X.setState({subAccountConfig:{}})}},nf={get:()=>X.getState().subAccount,set:e=>{X.setState(t=>({subAccount:t.subAccount?Object.assign(Object.assign({},t.subAccount),e):Object.assign({address:e.address},e)}))},clear:()=>{X.setState({subAccount:void 0})}},rf={get:()=>X.getState().spendPermissions,set:e=>{X.setState({spendPermissions:e})},clear:()=>{X.setState({spendPermissions:[]})}},af={get:()=>X.getState().account,set:e=>{X.setState(t=>({account:Object.assign(Object.assign({},t.account),e)}))},clear:()=>{X.setState({account:{}})}},sf={get:()=>X.getState().chains,set:e=>{X.setState({chains:e})},clear:()=>{X.setState({chains:[]})}},of={get:e=>X.getState().keys[e],set:(e,t)=>{X.setState(n=>({keys:Object.assign(Object.assign({},n.keys),{[e]:t})}))},clear:()=>{X.setState({keys:{}})}},li={get:()=>X.getState().config,set:e=>{X.setState(t=>({config:Object.assign(Object.assign({},t.config),e)}))}},cf={subAccounts:nf,subAccountsConfig:tf,spendPermissions:rf,account:af,chains:sf,keys:of,config:li},T=Object.assign(Object.assign({},X),cf),uf='!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.ClientAnalytics=t():e.ClientAnalytics=t()}(this,(function(){return(()=>{var e={792:e=>{var t={utf8:{stringToBytes:function(e){return t.bin.stringToBytes(unescape(encodeURIComponent(e)))},bytesToString:function(e){return decodeURIComponent(escape(t.bin.bytesToString(e)))}},bin:{stringToBytes:function(e){for(var t=[],n=0;n<e.length;n++)t.push(255&e.charCodeAt(n));return t},bytesToString:function(e){for(var t=[],n=0;n<e.length;n++)t.push(String.fromCharCode(e[n]));return t.join("")}}};e.exports=t},562:e=>{var t,n;t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n={rotl:function(e,t){return e<<t|e>>>32-t},rotr:function(e,t){return e<<32-t|e>>>t},endian:function(e){if(e.constructor==Number)return 16711935&n.rotl(e,8)|4278255360&n.rotl(e,24);for(var t=0;t<e.length;t++)e[t]=n.endian(e[t]);return e},randomBytes:function(e){for(var t=[];e>0;e--)t.push(Math.floor(256*Math.random()));return t},bytesToWords:function(e){for(var t=[],n=0,r=0;n<e.length;n++,r+=8)t[r>>>5]|=e[n]<<24-r%32;return t},wordsToBytes:function(e){for(var t=[],n=0;n<32*e.length;n+=8)t.push(e[n>>>5]>>>24-n%32&255);return t},bytesToHex:function(e){for(var t=[],n=0;n<e.length;n++)t.push((e[n]>>>4).toString(16)),t.push((15&e[n]).toString(16));return t.join("")},hexToBytes:function(e){for(var t=[],n=0;n<e.length;n+=2)t.push(parseInt(e.substr(n,2),16));return t},bytesToBase64:function(e){for(var n=[],r=0;r<e.length;r+=3)for(var i=e[r]<<16|e[r+1]<<8|e[r+2],a=0;a<4;a++)8*r+6*a<=8*e.length?n.push(t.charAt(i>>>6*(3-a)&63)):n.push("=");return n.join("")},base64ToBytes:function(e){e=e.replace(/[^A-Z0-9+\\/]/gi,"");for(var n=[],r=0,i=0;r<e.length;i=++r%4)0!=i&&n.push((t.indexOf(e.charAt(r-1))&Math.pow(2,-2*i+8)-1)<<2*i|t.indexOf(e.charAt(r))>>>6-2*i);return n}},e.exports=n},335:e=>{function t(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}e.exports=function(e){return null!=e&&(t(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&t(e.slice(0,0))}(e)||!!e._isBuffer)}},762:(e,t,n)=>{var r,i,a,o,s;r=n(562),i=n(792).utf8,a=n(335),o=n(792).bin,(s=function(e,t){e.constructor==String?e=t&&"binary"===t.encoding?o.stringToBytes(e):i.stringToBytes(e):a(e)?e=Array.prototype.slice.call(e,0):Array.isArray(e)||e.constructor===Uint8Array||(e=e.toString());for(var n=r.bytesToWords(e),c=8*e.length,u=1732584193,l=-271733879,d=-1732584194,p=271733878,m=0;m<n.length;m++)n[m]=16711935&(n[m]<<8|n[m]>>>24)|4278255360&(n[m]<<24|n[m]>>>8);n[c>>>5]|=128<<c%32,n[14+(c+64>>>9<<4)]=c;var f=s._ff,v=s._gg,g=s._hh,b=s._ii;for(m=0;m<n.length;m+=16){var h=u,w=l,y=d,T=p;u=f(u,l,d,p,n[m+0],7,-680876936),p=f(p,u,l,d,n[m+1],12,-389564586),d=f(d,p,u,l,n[m+2],17,606105819),l=f(l,d,p,u,n[m+3],22,-1044525330),u=f(u,l,d,p,n[m+4],7,-176418897),p=f(p,u,l,d,n[m+5],12,1200080426),d=f(d,p,u,l,n[m+6],17,-1473231341),l=f(l,d,p,u,n[m+7],22,-45705983),u=f(u,l,d,p,n[m+8],7,1770035416),p=f(p,u,l,d,n[m+9],12,-1958414417),d=f(d,p,u,l,n[m+10],17,-42063),l=f(l,d,p,u,n[m+11],22,-1990404162),u=f(u,l,d,p,n[m+12],7,1804603682),p=f(p,u,l,d,n[m+13],12,-40341101),d=f(d,p,u,l,n[m+14],17,-1502002290),u=v(u,l=f(l,d,p,u,n[m+15],22,1236535329),d,p,n[m+1],5,-165796510),p=v(p,u,l,d,n[m+6],9,-1069501632),d=v(d,p,u,l,n[m+11],14,643717713),l=v(l,d,p,u,n[m+0],20,-373897302),u=v(u,l,d,p,n[m+5],5,-701558691),p=v(p,u,l,d,n[m+10],9,38016083),d=v(d,p,u,l,n[m+15],14,-660478335),l=v(l,d,p,u,n[m+4],20,-405537848),u=v(u,l,d,p,n[m+9],5,568446438),p=v(p,u,l,d,n[m+14],9,-1019803690),d=v(d,p,u,l,n[m+3],14,-187363961),l=v(l,d,p,u,n[m+8],20,1163531501),u=v(u,l,d,p,n[m+13],5,-1444681467),p=v(p,u,l,d,n[m+2],9,-51403784),d=v(d,p,u,l,n[m+7],14,1735328473),u=g(u,l=v(l,d,p,u,n[m+12],20,-1926607734),d,p,n[m+5],4,-378558),p=g(p,u,l,d,n[m+8],11,-2022574463),d=g(d,p,u,l,n[m+11],16,1839030562),l=g(l,d,p,u,n[m+14],23,-35309556),u=g(u,l,d,p,n[m+1],4,-1530992060),p=g(p,u,l,d,n[m+4],11,1272893353),d=g(d,p,u,l,n[m+7],16,-155497632),l=g(l,d,p,u,n[m+10],23,-1094730640),u=g(u,l,d,p,n[m+13],4,681279174),p=g(p,u,l,d,n[m+0],11,-358537222),d=g(d,p,u,l,n[m+3],16,-722521979),l=g(l,d,p,u,n[m+6],23,76029189),u=g(u,l,d,p,n[m+9],4,-640364487),p=g(p,u,l,d,n[m+12],11,-421815835),d=g(d,p,u,l,n[m+15],16,530742520),u=b(u,l=g(l,d,p,u,n[m+2],23,-995338651),d,p,n[m+0],6,-198630844),p=b(p,u,l,d,n[m+7],10,1126891415),d=b(d,p,u,l,n[m+14],15,-1416354905),l=b(l,d,p,u,n[m+5],21,-57434055),u=b(u,l,d,p,n[m+12],6,1700485571),p=b(p,u,l,d,n[m+3],10,-1894986606),d=b(d,p,u,l,n[m+10],15,-1051523),l=b(l,d,p,u,n[m+1],21,-2054922799),u=b(u,l,d,p,n[m+8],6,1873313359),p=b(p,u,l,d,n[m+15],10,-30611744),d=b(d,p,u,l,n[m+6],15,-1560198380),l=b(l,d,p,u,n[m+13],21,1309151649),u=b(u,l,d,p,n[m+4],6,-145523070),p=b(p,u,l,d,n[m+11],10,-1120210379),d=b(d,p,u,l,n[m+2],15,718787259),l=b(l,d,p,u,n[m+9],21,-343485551),u=u+h>>>0,l=l+w>>>0,d=d+y>>>0,p=p+T>>>0}return r.endian([u,l,d,p])})._ff=function(e,t,n,r,i,a,o){var s=e+(t&n|~t&r)+(i>>>0)+o;return(s<<a|s>>>32-a)+t},s._gg=function(e,t,n,r,i,a,o){var s=e+(t&r|n&~r)+(i>>>0)+o;return(s<<a|s>>>32-a)+t},s._hh=function(e,t,n,r,i,a,o){var s=e+(t^n^r)+(i>>>0)+o;return(s<<a|s>>>32-a)+t},s._ii=function(e,t,n,r,i,a,o){var s=e+(n^(t|~r))+(i>>>0)+o;return(s<<a|s>>>32-a)+t},s._blocksize=16,s._digestsize=16,e.exports=function(e,t){if(null==e)throw new Error("Illegal argument "+e);var n=r.wordsToBytes(s(e,t));return t&&t.asBytes?n:t&&t.asString?o.bytesToString(n):r.bytesToHex(n)}},2:(e,t,n)=>{"use strict";n.r(t),n.d(t,{Perfume:()=>ze,incrementUjNavigation:()=>Le,markStep:()=>Re,markStepOnce:()=>qe});var r,i,a={isResourceTiming:!1,isElementTiming:!1,maxTime:3e4,reportOptions:{},enableNavigationTracking:!0},o=window,s=o.console,c=o.navigator,u=o.performance,l=function(){return c.deviceMemory},d=function(){return c.hardwareConcurrency},p="mark.",m=function(){return u&&!!u.getEntriesByType&&!!u.now&&!!u.mark},f="4g",v=!1,g={},b={value:0},h={value:{beacon:0,css:0,fetch:0,img:0,other:0,script:0,total:0,xmlhttprequest:0}},w={value:0},y={value:0},T={},k={isHidden:!1,didChange:!1},_=function(){k.isHidden=!1,document.hidden&&(k.isHidden=document.hidden,k.didChange=!0)},S=function(e,t){try{var n=new PerformanceObserver((function(e){t(e.getEntries())}));return n.observe({type:e,buffered:!0}),n}catch(e){s.warn("Perfume.js:",e)}return null},E=function(){return!!(d()&&d()<=4)||!!(l()&&l()<=4)},x=function(e,t){switch(e){case"slow-2g":case"2g":case"3g":return!0;default:return E()||t}},O=function(e){return parseFloat(e.toFixed(4))},j=function(e){return"number"!=typeof e?null:O(e/Math.pow(1024,2))},N=function(e,t,n,r,i){var s,u=function(){a.analyticsTracker&&(k.isHidden&&!["CLS","INP"].includes(e)||a.analyticsTracker({attribution:r,metricName:e,data:t,navigatorInformation:c?{deviceMemory:l()||0,hardwareConcurrency:d()||0,serviceWorkerStatus:"serviceWorker"in c?c.serviceWorker.controller?"controlled":"supported":"unsupported",isLowEndDevice:E(),isLowEndExperience:x(f,v)}:{},rating:n,navigationType:i}))};["CLS","INP"].includes(e)?u():(s=u,"requestIdleCallback"in o?o.requestIdleCallback(s,{timeout:3e3}):s())},I=function(e){e.forEach((function(e){if(!("self"!==e.name||e.startTime<b.value)){var t=e.duration-50;t>0&&(w.value+=t,y.value+=t)}}))};!function(e){e.instant="instant",e.quick="quick",e.moderate="moderate",e.slow="slow",e.unavoidable="unavoidable"}(r||(r={}));var P,M,B,C,D,A=((i={})[r.instant]={vitalsThresholds:[100,200],maxOutlierThreshold:1e4},i[r.quick]={vitalsThresholds:[200,500],maxOutlierThreshold:1e4},i[r.moderate]={vitalsThresholds:[500,1e3],maxOutlierThreshold:1e4},i[r.slow]={vitalsThresholds:[1e3,2e3],maxOutlierThreshold:1e4},i[r.unavoidable]={vitalsThresholds:[2e3,5e3],maxOutlierThreshold:2e4},i),L={RT:[100,200],TBT:[200,600],NTBT:[200,600]},U=function(e,t){return L[e]?t<=L[e][0]?"good":t<=L[e][1]?"needsImprovement":"poor":null},R=function(e,t,n){Object.keys(t).forEach((function(e){"number"==typeof t[e]&&(t[e]=O(t[e]))})),N(e,t,null,n||{})},q=function(e){var t=e.attribution,n=e.name,r=e.rating,i=e.value,o=e.navigationType;"FCP"===n&&(b.value=i),["FCP","LCP"].includes(n)&&!T[0]&&(T[0]=S("longtask",I)),"FID"===n&&setTimeout((function(){k.didChange||(q({attribution:t,name:"TBT",rating:U("TBT",w.value),value:w.value,navigationType:o}),R("dataConsumption",h.value))}),1e4);var s=O(i);s<=a.maxTime&&s>=0&&N(n,s,r,t,o)},F=function(){return window.performance&&performance.getEntriesByType&&performance.getEntriesByType("navigation")[0]},z=function(e){if("loading"===document.readyState)return"loading";var t=F();if(t){if(e<t.domInteractive)return"loading";if(0===t.domContentLoadedEventStart||e<t.domContentLoadedEventStart)return"dom-interactive";if(0===t.domComplete||e<t.domComplete)return"dom-content-loaded"}return"complete"},K=function(e){var t=e.nodeName;return 1===e.nodeType?t.toLowerCase():t.toUpperCase().replace(/^#/,"")},$=function(e,t){var n="";try{for(;e&&9!==e.nodeType;){var r=e,i=r.id?"#"+r.id:K(r)+(r.className&&r.className.length?"."+r.className.replace(/\\s+/g,"."):"");if(n.length+i.length>(t||100)-1)return n||i;if(n=n?i+">"+n:i,r.id)break;e=r.parentNode}}catch(e){}return n},Q=-1,W=function(){return Q},H=function(e){addEventListener("pageshow",(function(t){t.persisted&&(Q=t.timeStamp,e(t))}),!0)},V=function(){var e=F();return e&&e.activationStart||0},J=function(e,t){var n=F(),r="navigate";return W()>=0?r="back-forward-cache":n&&(r=document.prerendering||V()>0?"prerender":document.wasDiscarded?"restore":n.type.replace(/_/g,"-")),{name:e,value:void 0===t?-1:t,rating:"good",delta:0,entries:[],id:"v3-".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12),navigationType:r}},X=function(e,t,n){try{if(PerformanceObserver.supportedEntryTypes.includes(e)){var r=new PerformanceObserver((function(e){Promise.resolve().then((function(){t(e.getEntries())}))}));return r.observe(Object.assign({type:e,buffered:!0},n||{})),r}}catch(e){}},G=function(e,t){var n=function n(r){"pagehide"!==r.type&&"hidden"!==document.visibilityState||(e(r),t&&(removeEventListener("visibilitychange",n,!0),removeEventListener("pagehide",n,!0)))};addEventListener("visibilitychange",n,!0),addEventListener("pagehide",n,!0)},Z=function(e,t,n,r){var i,a;return function(o){t.value>=0&&(o||r)&&((a=t.value-(i||0))||void 0===i)&&(i=t.value,t.delta=a,t.rating=function(e,t){return e>t[1]?"poor":e>t[0]?"needs-improvement":"good"}(t.value,n),e(t))}},Y=function(e){requestAnimationFrame((function(){return requestAnimationFrame((function(){return e()}))}))},ee=function(e){document.prerendering?addEventListener("prerenderingchange",(function(){return e()}),!0):e()},te=-1,ne=function(){return"hidden"!==document.visibilityState||document.prerendering?1/0:0},re=function(e){"hidden"===document.visibilityState&&te>-1&&(te="visibilitychange"===e.type?e.timeStamp:0,ae())},ie=function(){addEventListener("visibilitychange",re,!0),addEventListener("prerenderingchange",re,!0)},ae=function(){removeEventListener("visibilitychange",re,!0),removeEventListener("prerenderingchange",re,!0)},oe=function(){return te<0&&(te=ne(),ie(),H((function(){setTimeout((function(){te=ne(),ie()}),0)}))),{get firstHiddenTime(){return te}}},se=function(e,t){t=t||{},ee((function(){var n,r=[1800,3e3],i=oe(),a=J("FCP"),o=X("paint",(function(e){e.forEach((function(e){"first-contentful-paint"===e.name&&(o.disconnect(),e.startTime<i.firstHiddenTime&&(a.value=Math.max(e.startTime-V(),0),a.entries.push(e),n(!0)))}))}));o&&(n=Z(e,a,r,t.reportAllChanges),H((function(i){a=J("FCP"),n=Z(e,a,r,t.reportAllChanges),Y((function(){a.value=performance.now()-i.timeStamp,n(!0)}))})))}))},ce={passive:!0,capture:!0},ue=new Date,le=function(e,t){P||(P=t,M=e,B=new Date,me(removeEventListener),de())},de=function(){if(M>=0&&M<B-ue){var e={entryType:"first-input",name:P.type,target:P.target,cancelable:P.cancelable,startTime:P.timeStamp,processingStart:P.timeStamp+M};C.forEach((function(t){t(e)})),C=[]}},pe=function(e){if(e.cancelable){var t=(e.timeStamp>1e12?new Date:performance.now())-e.timeStamp;"pointerdown"==e.type?function(e,t){var n=function(){le(e,t),i()},r=function(){i()},i=function(){removeEventListener("pointerup",n,ce),removeEventListener("pointercancel",r,ce)};addEventListener("pointerup",n,ce),addEventListener("pointercancel",r,ce)}(t,e):le(t,e)}},me=function(e){["mousedown","keydown","touchstart","pointerdown"].forEach((function(t){return e(t,pe,ce)}))},fe=0,ve=1/0,ge=0,be=function(e){e.forEach((function(e){e.interactionId&&(ve=Math.min(ve,e.interactionId),ge=Math.max(ge,e.interactionId),fe=ge?(ge-ve)/7+1:0)}))},he=function(){return D?fe:performance.interactionCount||0},we=0,ye=function(){return he()-we},Te=[],ke={},_e=function(e){var t=Te[Te.length-1],n=ke[e.interactionId];if(n||Te.length<10||e.duration>t.latency){if(n)n.entries.push(e),n.latency=Math.max(n.latency,e.duration);else{var r={id:e.interactionId,latency:e.duration,entries:[e]};ke[r.id]=r,Te.push(r)}Te.sort((function(e,t){return t.latency-e.latency})),Te.splice(10).forEach((function(e){delete ke[e.id]}))}},Se={},Ee=function e(t){document.prerendering?ee((function(){return e(t)})):"complete"!==document.readyState?addEventListener("load",(function(){return e(t)}),!0):setTimeout(t,0)},xe=function(e,t){t=t||{};var n=[800,1800],r=J("TTFB"),i=Z(e,r,n,t.reportAllChanges);Ee((function(){var a=F();if(a){var o=a.responseStart;if(o<=0||o>performance.now())return;r.value=Math.max(o-V(),0),r.entries=[a],i(!0),H((function(){r=J("TTFB",0),(i=Z(e,r,n,t.reportAllChanges))(!0)}))}}))},Oe=function(e){e.forEach((function(e){e.identifier&&q({attribution:{identifier:e.identifier},name:"ET",rating:null,value:e.startTime})}))},je=function(e){e.forEach((function(e){if(a.isResourceTiming&&R("resourceTiming",e),e.decodedBodySize&&e.initiatorType){var t=e.decodedBodySize/1e3;h.value[e.initiatorType]+=t,h.value.total+=t}}))},Ne=function(){!function(e,t){xe((function(e){!function(e){if(e.entries.length){var t=e.entries[0],n=t.activationStart||0,r=Math.max(t.domainLookupStart-n,0),i=Math.max(t.connectStart-n,0),a=Math.max(t.requestStart-n,0);e.attribution={waitingTime:r,dnsTime:i-r,connectionTime:a-i,requestTime:e.value-a,navigationEntry:t}}else e.attribution={waitingTime:0,dnsTime:0,connectionTime:0,requestTime:0}}(e),function(e){e.value>0&&q(e)}(e)}),t)}(0,a.reportOptions.ttfb),function(e,t){!function(e,t){t=t||{},ee((function(){var e,n=[.1,.25],r=J("CLS"),i=-1,a=0,o=[],s=function(e){i>-1&&function(e){!function(e){if(e.entries.length){var t=e.entries.reduce((function(e,t){return e&&e.value>t.value?e:t}));if(t&&t.sources&&t.sources.length){var n=(r=t.sources).find((function(e){return e.node&&1===e.node.nodeType}))||r[0];if(n)return void(e.attribution={largestShiftTarget:$(n.node),largestShiftTime:t.startTime,largestShiftValue:t.value,largestShiftSource:n,largestShiftEntry:t,loadState:z(t.startTime)})}}var r;e.attribution={}}(e),function(e){q(e)}(e)}(e)},c=function(t){t.forEach((function(t){if(!t.hadRecentInput){var n=o[0],i=o[o.length-1];a&&t.startTime-i.startTime<1e3&&t.startTime-n.startTime<5e3?(a+=t.value,o.push(t)):(a=t.value,o=[t]),a>r.value&&(r.value=a,r.entries=o,e())}}))},u=X("layout-shift",c);u&&(e=Z(s,r,n,t.reportAllChanges),se((function(t){i=t.value,r.value<0&&(r.value=0,e())})),G((function(){c(u.takeRecords()),e(!0)})),H((function(){a=0,i=-1,r=J("CLS",0),e=Z(s,r,n,t.reportAllChanges),Y((function(){return e()}))})))}))}(0,t)}(0,a.reportOptions.cls),function(e,t){se((function(e){!function(e){if(e.entries.length){var t=F(),n=e.entries[e.entries.length-1];if(t){var r=t.activationStart||0,i=Math.max(0,t.responseStart-r);return void(e.attribution={timeToFirstByte:i,firstByteToFCP:e.value-i,loadState:z(e.entries[0].startTime),navigationEntry:t,fcpEntry:n})}}e.attribution={timeToFirstByte:0,firstByteToFCP:e.value,loadState:z(W())}}(e),function(e){q(e)}(e)}),t)}(0,a.reportOptions.fcp),function(e,t){!function(e,t){t=t||{},ee((function(){var n,r=[100,300],i=oe(),a=J("FID"),o=function(e){e.startTime<i.firstHiddenTime&&(a.value=e.processingStart-e.startTime,a.entries.push(e),n(!0))},s=function(e){e.forEach(o)},c=X("first-input",s);n=Z(e,a,r,t.reportAllChanges),c&&G((function(){s(c.takeRecords()),c.disconnect()}),!0),c&&H((function(){var i;a=J("FID"),n=Z(e,a,r,t.reportAllChanges),C=[],M=-1,P=null,me(addEventListener),i=o,C.push(i),de()}))}))}((function(e){!function(e){var t=e.entries[0];e.attribution={eventTarget:$(t.target),eventType:t.name,eventTime:t.startTime,eventEntry:t,loadState:z(t.startTime)}}(e),function(e){q(e)}(e)}),t)}(0,a.reportOptions.fid),function(e,t){!function(e,t){t=t||{},ee((function(){var n,r=[2500,4e3],i=oe(),a=J("LCP"),o=function(e){var t=e[e.length-1];if(t){var r=Math.max(t.startTime-V(),0);r<i.firstHiddenTime&&(a.value=r,a.entries=[t],n())}},s=X("largest-contentful-paint",o);if(s){n=Z(e,a,r,t.reportAllChanges);var c=function(){Se[a.id]||(o(s.takeRecords()),s.disconnect(),Se[a.id]=!0,n(!0))};["keydown","click"].forEach((function(e){addEventListener(e,c,{once:!0,capture:!0})})),G(c,!0),H((function(i){a=J("LCP"),n=Z(e,a,r,t.reportAllChanges),Y((function(){a.value=performance.now()-i.timeStamp,Se[a.id]=!0,n(!0)}))}))}}))}((function(e){!function(e){if(e.entries.length){var t=F();if(t){var n=t.activationStart||0,r=e.entries[e.entries.length-1],i=r.url&&performance.getEntriesByType("resource").filter((function(e){return e.name===r.url}))[0],a=Math.max(0,t.responseStart-n),o=Math.max(a,i?(i.requestStart||i.startTime)-n:0),s=Math.max(o,i?i.responseEnd-n:0),c=Math.max(s,r?r.startTime-n:0),u={element:$(r.element),timeToFirstByte:a,resourceLoadDelay:o-a,resourceLoadTime:s-o,elementRenderDelay:c-s,navigationEntry:t,lcpEntry:r};return r.url&&(u.url=r.url),i&&(u.lcpResourceEntry=i),void(e.attribution=u)}}e.attribution={timeToFirstByte:0,resourceLoadDelay:0,resourceLoadTime:0,elementRenderDelay:e.value}}(e),function(e){q(e)}(e)}),t)}(0,a.reportOptions.lcp),function(e,t){!function(e,t){t=t||{},ee((function(){var n=[200,500];"interactionCount"in performance||D||(D=X("event",be,{type:"event",buffered:!0,durationThreshold:0}));var r,i=J("INP"),a=function(e){e.forEach((function(e){e.interactionId&&_e(e),"first-input"===e.entryType&&!Te.some((function(t){return t.entries.some((function(t){return e.duration===t.duration&&e.startTime===t.startTime}))}))&&_e(e)}));var t,n=(t=Math.min(Te.length-1,Math.floor(ye()/50)),Te[t]);n&&n.latency!==i.value&&(i.value=n.latency,i.entries=n.entries,r())},o=X("event",a,{durationThreshold:t.durationThreshold||40});r=Z(e,i,n,t.reportAllChanges),o&&(o.observe({type:"first-input",buffered:!0}),G((function(){a(o.takeRecords()),i.value<0&&ye()>0&&(i.value=0,i.entries=[]),r(!0)})),H((function(){Te=[],we=he(),i=J("INP"),r=Z(e,i,n,t.reportAllChanges)})))}))}((function(t){!function(e){if(e.entries.length){var t=e.entries.sort((function(e,t){return t.duration-e.duration||t.processingEnd-t.processingStart-(e.processingEnd-e.processingStart)}))[0];e.attribution={eventTarget:$(t.target),eventType:t.name,eventTime:t.startTime,eventEntry:t,loadState:z(t.startTime)}}else e.attribution={}}(t),e(t)}),t)}((function(e){return q(e)}),a.reportOptions.inp),a.isResourceTiming&&S("resource",je),a.isElementTiming&&S("element",Oe)},Ie=function(e){var t="usageDetails"in e?e.usageDetails:{};R("storageEstimate",{quota:j(e.quota),usage:j(e.usage),caches:j(t.caches),indexedDB:j(t.indexedDB),serviceWorker:j(t.serviceWorkerRegistrations)})},Pe={finalMarkToStepsMap:{},startMarkToStepsMap:{},active:{},navigationSteps:{}},Me=function(e){delete Pe.active[e]},Be=function(){return Pe.navigationSteps},Ce=function(e){var t;return null!==(t=Be()[e])&&void 0!==t?t:{}},De=function(e,t,n){var r="step."+e,i=u.getEntriesByName(p+t).length>0;if(u.getEntriesByName(p+n).length>0&&a.steps){var o=A[a.steps[e].threshold],s=o.maxOutlierThreshold,c=o.vitalsThresholds;if(i){var l=u.measure(r,p+t,p+n),d=l.duration;if(d<=s){var m=function(e,t){return e<=t[0]?"good":e<=t[1]?"needsImprovement":"poor"}(d,c);d>=0&&(N("userJourneyStep",d,m,{stepName:e},void 0),u.measure("step.".concat(e,"_vitals_").concat(m),{start:l.startTime+l.duration,end:l.startTime+l.duration,detail:{type:"stepVital",duration:d}}))}}}},Ae=function(){var e=Be(),t=Pe.startMarkToStepsMap,n=Object.keys(e).length;if(0===n)return{};var r={},i=n-1,a=Ce(i);if(Object.keys(a).forEach((function(e){var n,i=null!==(n=t[e])&&void 0!==n?n:[];Object.keys(i).forEach((function(e){r[e]=!0}))})),n>1){var o=Ce(i-1);Object.keys(o).forEach((function(e){var n,i=null!==(n=t[e])&&void 0!==n?n:[];Object.keys(i).forEach((function(e){r[e]=!0}))}))}return r},Le=function(){var e,t=Object.keys(Pe.navigationSteps).length;Pe.navigationSteps[t]={};var n=Ae();null===(e=a.onMarkStep)||void 0===e||e.call(a,"",Object.keys(n))},Ue=function(e){var t,n,r,i,o,s,c;if(Pe.finalMarkToStepsMap[e]){!function(e){var t=Pe.navigationSteps,n=Pe.finalMarkToStepsMap,r=Object.keys(t).length;if(0!==r){var i=r-1,a=Ce(i);if(a&&n[e]){var o=n[e];o&&Object.keys(o).forEach((function(e){if(a[e]){var n=Ce(i)||{};n[e]=!1,t[i]=n}if(r>1){var o=i-1,s=Ce(o);s[e]&&(s[e]=!1,t[o]=s)}}))}}}(e);var u=Pe.finalMarkToStepsMap[e];Object.keys(u).forEach((function(t){var n=u[t];n.forEach(Me),Promise.all(n.map((function(n){return function(e,t,n,r){return new(n||(n=Promise))((function(e,t){function i(e){try{o(r.next(e))}catch(e){t(e)}}function a(e){try{o(r.throw(e))}catch(e){t(e)}}function o(t){var r;t.done?e(t.value):(r=t.value,r instanceof n?r:new n((function(e){e(r)}))).then(i,a)}o((r=r.apply(undefined,[])).next())}))}(0,0,void 0,(function(){return function(e,t){var n,r,i,a,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(a){return function(s){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,r=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}}(this,(function(r){switch(r.label){case 0:return[4,De(n,t,e)];case 1:return r.sent(),[2]}}))}))}))).catch((function(){}))}))}else r=e,i=Pe.navigationSteps,o=Object.keys(i).length,(c=Ce(s=(o>0?o:1)-1)||[])[r]=!0,i[s]=c,function(e){var t,n=null!==(t=Pe.startMarkToStepsMap[e])&&void 0!==t?t:[];Object.keys(n).forEach((function(e){Pe.active[e]||(Pe.active[e]=!0)}))}(e);if(a.enableNavigationTracking){var l=Ae();null===(t=a.onMarkStep)||void 0===t||t.call(a,e,Object.keys(l))}else null===(n=a.onMarkStep)||void 0===n||n.call(a,e,Object.keys(Pe.active))},Re=function(e){u.mark(p+e),Ue(e)},qe=function(e){0===u.getEntriesByName(p+e).length&&(u.mark(p+e),Ue(e))},Fe=0,ze=function(){function e(e){if(void 0===e&&(e={}),this.v="9.0.0-rc.3",a.analyticsTracker=e.analyticsTracker,a.isResourceTiming=!!e.resourceTiming,a.isElementTiming=!!e.elementTiming,a.maxTime=e.maxMeasureTime||a.maxTime,a.reportOptions=e.reportOptions||a.reportOptions,a.steps=e.steps,a.onMarkStep=e.onMarkStep,a.enableNavigationTracking=e.enableNavigationTracking,m()){"PerformanceObserver"in o&&Ne(),void 0!==document.hidden&&document.addEventListener("visibilitychange",_);var t=function(){if(!m())return{};var e=u.getEntriesByType("navigation")[0];if(!e)return{};var t=e.responseStart,n=e.responseEnd;return{fetchTime:n-e.fetchStart,workerTime:e.workerStart>0?n-e.workerStart:0,totalTime:n-e.requestStart,downloadTime:n-t,timeToFirstByte:t-e.requestStart,headerSize:e.transferSize-e.encodedBodySize||0,dnsLookupTime:e.domainLookupEnd-e.domainLookupStart,redirectTime:e.redirectEnd-e.redirectStart}}();R("navigationTiming",t),t.redirectTime&&q({attribution:{},name:"RT",rating:U("RT",t.redirectTime),value:t.redirectTime}),R("networkInformation",function(){if("connection"in c){var e=c.connection;return"object"!=typeof e?{}:(f=e.effectiveType,v=!!e.saveData,{downlink:e.downlink,effectiveType:e.effectiveType,rtt:e.rtt,saveData:!!e.saveData})}return{}}()),c&&c.storage&&"function"==typeof c.storage.estimate&&c.storage.estimate().then(Ie),a.steps&&a.steps&&(Pe.startMarkToStepsMap={},Pe.finalMarkToStepsMap={},Pe.active={},Pe.navigationSteps={},Object.entries(a.steps).forEach((function(e){var t,n,r=e[0],i=e[1].marks,a=i[0],o=i[1],s=null!==(n=Pe.startMarkToStepsMap[a])&&void 0!==n?n:{};if(s[r]=!0,Pe.startMarkToStepsMap[a]=s,Pe.finalMarkToStepsMap[o]){var c=Pe.finalMarkToStepsMap[o][a]||[];c.push(r),Pe.finalMarkToStepsMap[o][a]=c}else Pe.finalMarkToStepsMap[o]=((t={})[a]=[r],t)})))}}return e.prototype.start=function(e){m()&&!g[e]&&(g[e]=!0,u.mark("mark_".concat(e,"_start")))},e.prototype.end=function(e,t,n){if(void 0===t&&(t={}),void 0===n&&(n=!0),m()&&g[e]){u.mark("mark_".concat(e,"_end")),delete g[e];var r=function(e){u.measure(e,"mark_".concat(e,"_start"),"mark_".concat(e,"_end"));var t=u.getEntriesByName(e).pop();return t&&"measure"===t.entryType?t.duration:-1}(e);n&&R(e,O(r),t)}},e.prototype.endPaint=function(e,t){var n=this;setTimeout((function(){n.end(e,t)}))},e.prototype.clear=function(e){delete g[e],u.clearMarks&&(u.clearMarks("mark_".concat(e,"_start")),u.clearMarks("mark_".concat(e,"_end")))},e.prototype.markNTBT=function(){var e=this;this.start("ntbt"),y.value=0,clearTimeout(Fe),Fe=setTimeout((function(){e.end("ntbt",{},!1),q({attribution:{},name:"NTBT",rating:U("NTBT",y.value),value:y.value}),y.value=0}),2e3)},e}()},426:(e,t)=>{"use strict";Symbol.for("react.element"),Symbol.for("react.portal"),Symbol.for("react.fragment"),Symbol.for("react.strict_mode"),Symbol.for("react.profiler"),Symbol.for("react.provider"),Symbol.for("react.context"),Symbol.for("react.forward_ref"),Symbol.for("react.suspense"),Symbol.for("react.memo"),Symbol.for("react.lazy"),Symbol.iterator;var n={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},r=Object.assign,i={};function a(e,t,r){this.props=e,this.context=t,this.refs=i,this.updater=r||n}function o(){}function s(e,t,r){this.props=e,this.context=t,this.refs=i,this.updater=r||n}a.prototype.isReactComponent={},a.prototype.setState=function(e,t){if("object"!=typeof e&&"function"!=typeof e&&null!=e)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")},a.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},o.prototype=a.prototype;var c=s.prototype=new o;c.constructor=s,r(c,a.prototype),c.isPureReactComponent=!0;Array.isArray,Object.prototype.hasOwnProperty;var u={current:null};t.useCallback=function(e,t){return u.current.useCallback(e,t)},t.useEffect=function(e,t){return u.current.useEffect(e,t)},t.useRef=function(e){return u.current.useRef(e)}},784:(e,t,n)=>{"use strict";e.exports=n(426)},353:function(e,t,n){var r;!function(i,a){"use strict";var o="function",s="undefined",c="object",u="string",l="major",d="model",p="name",m="type",f="vendor",v="version",g="architecture",b="console",h="mobile",w="tablet",y="smarttv",T="wearable",k="embedded",_="Amazon",S="Apple",E="ASUS",x="BlackBerry",O="Browser",j="Chrome",N="Firefox",I="Google",P="Huawei",M="LG",B="Microsoft",C="Motorola",D="Opera",A="Samsung",L="Sharp",U="Sony",R="Xiaomi",q="Zebra",F="Facebook",z="Chromium OS",K="Mac OS",$=function(e){for(var t={},n=0;n<e.length;n++)t[e[n].toUpperCase()]=e[n];return t},Q=function(e,t){return typeof e===u&&-1!==W(t).indexOf(W(e))},W=function(e){return e.toLowerCase()},H=function(e,t){if(typeof e===u)return e=e.replace(/^\\s\\s*/,""),typeof t===s?e:e.substring(0,350)},V=function(e,t){for(var n,r,i,s,u,l,d=0;d<t.length&&!u;){var p=t[d],m=t[d+1];for(n=r=0;n<p.length&&!u&&p[n];)if(u=p[n++].exec(e))for(i=0;i<m.length;i++)l=u[++r],typeof(s=m[i])===c&&s.length>0?2===s.length?typeof s[1]==o?this[s[0]]=s[1].call(this,l):this[s[0]]=s[1]:3===s.length?typeof s[1]!==o||s[1].exec&&s[1].test?this[s[0]]=l?l.replace(s[1],s[2]):a:this[s[0]]=l?s[1].call(this,l,s[2]):a:4===s.length&&(this[s[0]]=l?s[3].call(this,l.replace(s[1],s[2])):a):this[s]=l||a;d+=2}},J=function(e,t){for(var n in t)if(typeof t[n]===c&&t[n].length>0){for(var r=0;r<t[n].length;r++)if(Q(t[n][r],e))return"?"===n?a:n}else if(Q(t[n],e))return"?"===n?a:n;return e},X={ME:"4.90","NT 3.11":"NT3.51","NT 4.0":"NT4.0",2e3:"NT 5.0",XP:["NT 5.1","NT 5.2"],Vista:"NT 6.0",7:"NT 6.1",8:"NT 6.2",8.1:"NT 6.3",10:["NT 6.4","NT 10.0"],RT:"ARM"},G={browser:[[/\\b(?:crmo|crios)\\/([\\w\\.]+)/i],[v,[p,"Chrome"]],[/edg(?:e|ios|a)?\\/([\\w\\.]+)/i],[v,[p,"Edge"]],[/(opera mini)\\/([-\\w\\.]+)/i,/(opera [mobiletab]{3,6})\\b.+version\\/([-\\w\\.]+)/i,/(opera)(?:.+version\\/|[\\/ ]+)([\\w\\.]+)/i],[p,v],[/opios[\\/ ]+([\\w\\.]+)/i],[v,[p,D+" Mini"]],[/\\bopr\\/([\\w\\.]+)/i],[v,[p,D]],[/(kindle)\\/([\\w\\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer)[\\/ ]?([\\w\\.]*)/i,/(avant |iemobile|slim)(?:browser)?[\\/ ]?([\\w\\.]*)/i,/(ba?idubrowser)[\\/ ]?([\\w\\.]+)/i,/(?:ms|\\()(ie) ([\\w\\.]+)/i,/(flock|rockmelt|midori|epiphany|silk|skyfire|bolt|iron|vivaldi|iridium|phantomjs|bowser|quark|qupzilla|falkon|rekonq|puffin|brave|whale(?!.+naver)|qqbrowserlite|qq|duckduckgo)\\/([-\\w\\.]+)/i,/(heytap|ovi)browser\\/([\\d\\.]+)/i,/(weibo)__([\\d\\.]+)/i],[p,v],[/(?:\\buc? ?browser|(?:juc.+)ucweb)[\\/ ]?([\\w\\.]+)/i],[v,[p,"UC"+O]],[/microm.+\\bqbcore\\/([\\w\\.]+)/i,/\\bqbcore\\/([\\w\\.]+).+microm/i],[v,[p,"WeChat(Win) Desktop"]],[/micromessenger\\/([\\w\\.]+)/i],[v,[p,"WeChat"]],[/konqueror\\/([\\w\\.]+)/i],[v,[p,"Konqueror"]],[/trident.+rv[: ]([\\w\\.]{1,9})\\b.+like gecko/i],[v,[p,"IE"]],[/ya(?:search)?browser\\/([\\w\\.]+)/i],[v,[p,"Yandex"]],[/(avast|avg)\\/([\\w\\.]+)/i],[[p,/(.+)/,"$1 Secure "+O],v],[/\\bfocus\\/([\\w\\.]+)/i],[v,[p,N+" Focus"]],[/\\bopt\\/([\\w\\.]+)/i],[v,[p,D+" Touch"]],[/coc_coc\\w+\\/([\\w\\.]+)/i],[v,[p,"Coc Coc"]],[/dolfin\\/([\\w\\.]+)/i],[v,[p,"Dolphin"]],[/coast\\/([\\w\\.]+)/i],[v,[p,D+" Coast"]],[/miuibrowser\\/([\\w\\.]+)/i],[v,[p,"MIUI "+O]],[/fxios\\/([-\\w\\.]+)/i],[v,[p,N]],[/\\bqihu|(qi?ho?o?|360)browser/i],[[p,"360 "+O]],[/(oculus|samsung|sailfish|huawei)browser\\/([\\w\\.]+)/i],[[p,/(.+)/,"$1 "+O],v],[/(comodo_dragon)\\/([\\w\\.]+)/i],[[p,/_/g," "],v],[/(electron)\\/([\\w\\.]+) safari/i,/(tesla)(?: qtcarbrowser|\\/(20\\d\\d\\.[-\\w\\.]+))/i,/m?(qqbrowser|baiduboxapp|2345Explorer)[\\/ ]?([\\w\\.]+)/i],[p,v],[/(metasr)[\\/ ]?([\\w\\.]+)/i,/(lbbrowser)/i,/\\[(linkedin)app\\]/i],[p],[/((?:fban\\/fbios|fb_iab\\/fb4a)(?!.+fbav)|;fbav\\/([\\w\\.]+);)/i],[[p,F],v],[/(kakao(?:talk|story))[\\/ ]([\\w\\.]+)/i,/(naver)\\(.*?(\\d+\\.[\\w\\.]+).*\\)/i,/safari (line)\\/([\\w\\.]+)/i,/\\b(line)\\/([\\w\\.]+)\\/iab/i,/(chromium|instagram)[\\/ ]([-\\w\\.]+)/i],[p,v],[/\\bgsa\\/([\\w\\.]+) .*safari\\//i],[v,[p,"GSA"]],[/musical_ly(?:.+app_?version\\/|_)([\\w\\.]+)/i],[v,[p,"TikTok"]],[/headlesschrome(?:\\/([\\w\\.]+)| )/i],[v,[p,j+" Headless"]],[/ wv\\).+(chrome)\\/([\\w\\.]+)/i],[[p,j+" WebView"],v],[/droid.+ version\\/([\\w\\.]+)\\b.+(?:mobile safari|safari)/i],[v,[p,"Android "+O]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\\/v?([\\w\\.]+)/i],[p,v],[/version\\/([\\w\\.\\,]+) .*mobile\\/\\w+ (safari)/i],[v,[p,"Mobile Safari"]],[/version\\/([\\w(\\.|\\,)]+) .*(mobile ?safari|safari)/i],[v,p],[/webkit.+?(mobile ?safari|safari)(\\/[\\w\\.]+)/i],[p,[v,J,{"1.0":"/8",1.2:"/1",1.3:"/3","2.0":"/412","2.0.2":"/416","2.0.3":"/417","2.0.4":"/419","?":"/"}]],[/(webkit|khtml)\\/([\\w\\.]+)/i],[p,v],[/(navigator|netscape\\d?)\\/([-\\w\\.]+)/i],[[p,"Netscape"],v],[/mobile vr; rv:([\\w\\.]+)\\).+firefox/i],[v,[p,N+" Reality"]],[/ekiohf.+(flow)\\/([\\w\\.]+)/i,/(swiftfox)/i,/(icedragon|iceweasel|camino|chimera|fennec|maemo browser|minimo|conkeror|klar)[\\/ ]?([\\w\\.\\+]+)/i,/(seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\\/([-\\w\\.]+)$/i,/(firefox)\\/([\\w\\.]+)/i,/(mozilla)\\/([\\w\\.]+) .+rv\\:.+gecko\\/\\d+/i,/(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|sleipnir|obigo|mosaic|(?:go|ice|up)[\\. ]?browser)[-\\/ ]?v?([\\w\\.]+)/i,/(links) \\(([\\w\\.]+)/i,/panasonic;(viera)/i],[p,v],[/(cobalt)\\/([\\w\\.]+)/i],[p,[v,/master.|lts./,""]]],cpu:[[/(?:(amd|x(?:(?:86|64)[-_])?|wow|win)64)[;\\)]/i],[[g,"amd64"]],[/(ia32(?=;))/i],[[g,W]],[/((?:i[346]|x)86)[;\\)]/i],[[g,"ia32"]],[/\\b(aarch64|arm(v?8e?l?|_?64))\\b/i],[[g,"arm64"]],[/\\b(arm(?:v[67])?ht?n?[fl]p?)\\b/i],[[g,"armhf"]],[/windows (ce|mobile); ppc;/i],[[g,"arm"]],[/((?:ppc|powerpc)(?:64)?)(?: mac|;|\\))/i],[[g,/ower/,"",W]],[/(sun4\\w)[;\\)]/i],[[g,"sparc"]],[/((?:avr32|ia64(?=;))|68k(?=\\))|\\barm(?=v(?:[1-7]|[5-7]1)l?|;|eabi)|(?=atmel )avr|(?:irix|mips|sparc)(?:64)?\\b|pa-risc)/i],[[g,W]]],device:[[/\\b(sch-i[89]0\\d|shw-m380s|sm-[ptx]\\w{2,4}|gt-[pn]\\d{2,4}|sgh-t8[56]9|nexus 10)/i],[d,[f,A],[m,w]],[/\\b((?:s[cgp]h|gt|sm)-\\w+|sc[g-]?[\\d]+a?|galaxy nexus)/i,/samsung[- ]([-\\w]+)/i,/sec-(sgh\\w+)/i],[d,[f,A],[m,h]],[/(?:\\/|\\()(ip(?:hone|od)[\\w, ]*)(?:\\/|;)/i],[d,[f,S],[m,h]],[/\\((ipad);[-\\w\\),; ]+apple/i,/applecoremedia\\/[\\w\\.]+ \\((ipad)/i,/\\b(ipad)\\d\\d?,\\d\\d?[;\\]].+ios/i],[d,[f,S],[m,w]],[/(macintosh);/i],[d,[f,S]],[/\\b(sh-?[altvz]?\\d\\d[a-ekm]?)/i],[d,[f,L],[m,h]],[/\\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\\d{2})\\b(?!.+d\\/s)/i],[d,[f,P],[m,w]],[/(?:huawei|honor)([-\\w ]+)[;\\)]/i,/\\b(nexus 6p|\\w{2,4}e?-[atu]?[ln][\\dx][012359c][adn]?)\\b(?!.+d\\/s)/i],[d,[f,P],[m,h]],[/\\b(poco[\\w ]+)(?: bui|\\))/i,/\\b; (\\w+) build\\/hm\\1/i,/\\b(hm[-_ ]?note?[_ ]?(?:\\d\\w)?) bui/i,/\\b(redmi[\\-_ ]?(?:note|k)?[\\w_ ]+)(?: bui|\\))/i,/\\b(mi[-_ ]?(?:a\\d|one|one[_ ]plus|note lte|max|cc)?[_ ]?(?:\\d?\\w?)[_ ]?(?:plus|se|lite)?)(?: bui|\\))/i],[[d,/_/g," "],[f,R],[m,h]],[/\\b(mi[-_ ]?(?:pad)(?:[\\w_ ]+))(?: bui|\\))/i],[[d,/_/g," "],[f,R],[m,w]],[/; (\\w+) bui.+ oppo/i,/\\b(cph[12]\\d{3}|p(?:af|c[al]|d\\w|e[ar])[mt]\\d0|x9007|a101op)\\b/i],[d,[f,"OPPO"],[m,h]],[/vivo (\\w+)(?: bui|\\))/i,/\\b(v[12]\\d{3}\\w?[at])(?: bui|;)/i],[d,[f,"Vivo"],[m,h]],[/\\b(rmx[12]\\d{3})(?: bui|;|\\))/i],[d,[f,"Realme"],[m,h]],[/\\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\\b[\\w ]+build\\//i,/\\bmot(?:orola)?[- ](\\w*)/i,/((?:moto[\\w\\(\\) ]+|xt\\d{3,4}|nexus 6)(?= bui|\\)))/i],[d,[f,C],[m,h]],[/\\b(mz60\\d|xoom[2 ]{0,2}) build\\//i],[d,[f,C],[m,w]],[/((?=lg)?[vl]k\\-?\\d{3}) bui| 3\\.[-\\w; ]{10}lg?-([06cv9]{3,4})/i],[d,[f,M],[m,w]],[/(lm(?:-?f100[nv]?|-[\\w\\.]+)(?= bui|\\))|nexus [45])/i,/\\blg[-e;\\/ ]+((?!browser|netcast|android tv)\\w+)/i,/\\blg-?([\\d\\w]+) bui/i],[d,[f,M],[m,h]],[/(ideatab[-\\w ]+)/i,/lenovo ?(s[56]000[-\\w]+|tab(?:[\\w ]+)|yt[-\\d\\w]{6}|tb[-\\d\\w]{6})/i],[d,[f,"Lenovo"],[m,w]],[/(?:maemo|nokia).*(n900|lumia \\d+)/i,/nokia[-_ ]?([-\\w\\.]*)/i],[[d,/_/g," "],[f,"Nokia"],[m,h]],[/(pixel c)\\b/i],[d,[f,I],[m,w]],[/droid.+; (pixel[\\daxl ]{0,6})(?: bui|\\))/i],[d,[f,I],[m,h]],[/droid.+ (a?\\d[0-2]{2}so|[c-g]\\d{4}|so[-gl]\\w+|xq-a\\w[4-7][12])(?= bui|\\).+chrome\\/(?![1-6]{0,1}\\d\\.))/i],[d,[f,U],[m,h]],[/sony tablet [ps]/i,/\\b(?:sony)?sgp\\w+(?: bui|\\))/i],[[d,"Xperia Tablet"],[f,U],[m,w]],[/ (kb2005|in20[12]5|be20[12][59])\\b/i,/(?:one)?(?:plus)? (a\\d0\\d\\d)(?: b|\\))/i],[d,[f,"OnePlus"],[m,h]],[/(alexa)webm/i,/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\\))/i,/(kf[a-z]+)( bui|\\)).+silk\\//i],[d,[f,_],[m,w]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\\)).+silk\\//i],[[d,/(.+)/g,"Fire Phone $1"],[f,_],[m,h]],[/(playbook);[-\\w\\),; ]+(rim)/i],[d,f,[m,w]],[/\\b((?:bb[a-f]|st[hv])100-\\d)/i,/\\(bb10; (\\w+)/i],[d,[f,x],[m,h]],[/(?:\\b|asus_)(transfo[prime ]{4,10} \\w+|eeepc|slider \\w+|nexus 7|padfone|p00[cj])/i],[d,[f,E],[m,w]],[/ (z[bes]6[027][012][km][ls]|zenfone \\d\\w?)\\b/i],[d,[f,E],[m,h]],[/(nexus 9)/i],[d,[f,"HTC"],[m,w]],[/(htc)[-;_ ]{1,2}([\\w ]+(?=\\)| bui)|\\w+)/i,/(zte)[- ]([\\w ]+?)(?: bui|\\/|\\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\\.))|sony(?!-bra))[-_ ]?([-\\w]*)/i],[f,[d,/_/g," "],[m,h]],[/droid.+; ([ab][1-7]-?[0178a]\\d\\d?)/i],[d,[f,"Acer"],[m,w]],[/droid.+; (m[1-5] note) bui/i,/\\bmz-([-\\w]{2,})/i],[d,[f,"Meizu"],[m,h]],[/(blackberry|benq|palm(?=\\-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron)[-_ ]?([-\\w]*)/i,/(hp) ([\\w ]+\\w)/i,/(asus)-?(\\w+)/i,/(microsoft); (lumia[\\w ]+)/i,/(lenovo)[-_ ]?([-\\w]+)/i,/(jolla)/i,/(oppo) ?([\\w ]+) bui/i],[f,d,[m,h]],[/(kobo)\\s(ereader|touch)/i,/(archos) (gamepad2?)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\\/([\\w\\.]+)/i,/(nook)[\\w ]+build\\/(\\w+)/i,/(dell) (strea[kpr\\d ]*[\\dko])/i,/(le[- ]+pan)[- ]+(\\w{1,9}) bui/i,/(trinity)[- ]*(t\\d{3}) bui/i,/(gigaset)[- ]+(q\\w{1,9}) bui/i,/(vodafone) ([\\w ]+)(?:\\)| bui)/i],[f,d,[m,w]],[/(surface duo)/i],[d,[f,B],[m,w]],[/droid [\\d\\.]+; (fp\\du?)(?: b|\\))/i],[d,[f,"Fairphone"],[m,h]],[/(u304aa)/i],[d,[f,"AT&T"],[m,h]],[/\\bsie-(\\w*)/i],[d,[f,"Siemens"],[m,h]],[/\\b(rct\\w+) b/i],[d,[f,"RCA"],[m,w]],[/\\b(venue[\\d ]{2,7}) b/i],[d,[f,"Dell"],[m,w]],[/\\b(q(?:mv|ta)\\w+) b/i],[d,[f,"Verizon"],[m,w]],[/\\b(?:barnes[& ]+noble |bn[rt])([\\w\\+ ]*) b/i],[d,[f,"Barnes & Noble"],[m,w]],[/\\b(tm\\d{3}\\w+) b/i],[d,[f,"NuVision"],[m,w]],[/\\b(k88) b/i],[d,[f,"ZTE"],[m,w]],[/\\b(nx\\d{3}j) b/i],[d,[f,"ZTE"],[m,h]],[/\\b(gen\\d{3}) b.+49h/i],[d,[f,"Swiss"],[m,h]],[/\\b(zur\\d{3}) b/i],[d,[f,"Swiss"],[m,w]],[/\\b((zeki)?tb.*\\b) b/i],[d,[f,"Zeki"],[m,w]],[/\\b([yr]\\d{2}) b/i,/\\b(dragon[- ]+touch |dt)(\\w{5}) b/i],[[f,"Dragon Touch"],d,[m,w]],[/\\b(ns-?\\w{0,9}) b/i],[d,[f,"Insignia"],[m,w]],[/\\b((nxa|next)-?\\w{0,9}) b/i],[d,[f,"NextBook"],[m,w]],[/\\b(xtreme\\_)?(v(1[045]|2[015]|[3469]0|7[05])) b/i],[[f,"Voice"],d,[m,h]],[/\\b(lvtel\\-)?(v1[12]) b/i],[[f,"LvTel"],d,[m,h]],[/\\b(ph-1) /i],[d,[f,"Essential"],[m,h]],[/\\b(v(100md|700na|7011|917g).*\\b) b/i],[d,[f,"Envizen"],[m,w]],[/\\b(trio[-\\w\\. ]+) b/i],[d,[f,"MachSpeed"],[m,w]],[/\\btu_(1491) b/i],[d,[f,"Rotor"],[m,w]],[/(shield[\\w ]+) b/i],[d,[f,"Nvidia"],[m,w]],[/(sprint) (\\w+)/i],[f,d,[m,h]],[/(kin\\.[onetw]{3})/i],[[d,/\\./g," "],[f,B],[m,h]],[/droid.+; (cc6666?|et5[16]|mc[239][23]x?|vc8[03]x?)\\)/i],[d,[f,q],[m,w]],[/droid.+; (ec30|ps20|tc[2-8]\\d[kx])\\)/i],[d,[f,q],[m,h]],[/smart-tv.+(samsung)/i],[f,[m,y]],[/hbbtv.+maple;(\\d+)/i],[[d,/^/,"SmartTV"],[f,A],[m,y]],[/(nux; netcast.+smarttv|lg (netcast\\.tv-201\\d|android tv))/i],[[f,M],[m,y]],[/(apple) ?tv/i],[f,[d,S+" TV"],[m,y]],[/crkey/i],[[d,j+"cast"],[f,I],[m,y]],[/droid.+aft(\\w)( bui|\\))/i],[d,[f,_],[m,y]],[/\\(dtv[\\);].+(aquos)/i,/(aquos-tv[\\w ]+)\\)/i],[d,[f,L],[m,y]],[/(bravia[\\w ]+)( bui|\\))/i],[d,[f,U],[m,y]],[/(mitv-\\w{5}) bui/i],[d,[f,R],[m,y]],[/Hbbtv.*(technisat) (.*);/i],[f,d,[m,y]],[/\\b(roku)[\\dx]*[\\)\\/]((?:dvp-)?[\\d\\.]*)/i,/hbbtv\\/\\d+\\.\\d+\\.\\d+ +\\([\\w\\+ ]*; *([\\w\\d][^;]*);([^;]*)/i],[[f,H],[d,H],[m,y]],[/\\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\\b/i],[[m,y]],[/(ouya)/i,/(nintendo) ([wids3utch]+)/i],[f,d,[m,b]],[/droid.+; (shield) bui/i],[d,[f,"Nvidia"],[m,b]],[/(playstation [345portablevi]+)/i],[d,[f,U],[m,b]],[/\\b(xbox(?: one)?(?!; xbox))[\\); ]/i],[d,[f,B],[m,b]],[/((pebble))app/i],[f,d,[m,T]],[/(watch)(?: ?os[,\\/]|\\d,\\d\\/)[\\d\\.]+/i],[d,[f,S],[m,T]],[/droid.+; (glass) \\d/i],[d,[f,I],[m,T]],[/droid.+; (wt63?0{2,3})\\)/i],[d,[f,q],[m,T]],[/(quest( 2| pro)?)/i],[d,[f,F],[m,T]],[/(tesla)(?: qtcarbrowser|\\/[-\\w\\.]+)/i],[f,[m,k]],[/(aeobc)\\b/i],[d,[f,_],[m,k]],[/droid .+?; ([^;]+?)(?: bui|\\) applew).+? mobile safari/i],[d,[m,h]],[/droid .+?; ([^;]+?)(?: bui|\\) applew).+?(?! mobile) safari/i],[d,[m,w]],[/\\b((tablet|tab)[;\\/]|focus\\/\\d(?!.+mobile))/i],[[m,w]],[/(phone|mobile(?:[;\\/]| [ \\w\\/\\.]*safari)|pda(?=.+windows ce))/i],[[m,h]],[/(android[-\\w\\. ]{0,9});.+buil/i],[d,[f,"Generic"]]],engine:[[/windows.+ edge\\/([\\w\\.]+)/i],[v,[p,"EdgeHTML"]],[/webkit\\/537\\.36.+chrome\\/(?!27)([\\w\\.]+)/i],[v,[p,"Blink"]],[/(presto)\\/([\\w\\.]+)/i,/(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna)\\/([\\w\\.]+)/i,/ekioh(flow)\\/([\\w\\.]+)/i,/(khtml|tasman|links)[\\/ ]\\(?([\\w\\.]+)/i,/(icab)[\\/ ]([23]\\.[\\d\\.]+)/i,/\\b(libweb)/i],[p,v],[/rv\\:([\\w\\.]{1,9})\\b.+(gecko)/i],[v,p]],os:[[/microsoft (windows) (vista|xp)/i],[p,v],[/(windows) nt 6\\.2; (arm)/i,/(windows (?:phone(?: os)?|mobile))[\\/ ]?([\\d\\.\\w ]*)/i,/(windows)[\\/ ]?([ntce\\d\\. ]+\\w)(?!.+xbox)/i],[p,[v,J,X]],[/(win(?=3|9|n)|win 9x )([nt\\d\\.]+)/i],[[p,"Windows"],[v,J,X]],[/ip[honead]{2,4}\\b(?:.*os ([\\w]+) like mac|; opera)/i,/ios;fbsv\\/([\\d\\.]+)/i,/cfnetwork\\/.+darwin/i],[[v,/_/g,"."],[p,"iOS"]],[/(mac os x) ?([\\w\\. ]*)/i,/(macintosh|mac_powerpc\\b)(?!.+haiku)/i],[[p,K],[v,/_/g,"."]],[/droid ([\\w\\.]+)\\b.+(android[- ]x86|harmonyos)/i],[v,p],[/(android|webos|qnx|bada|rim tablet os|maemo|meego|sailfish)[-\\/ ]?([\\w\\.]*)/i,/(blackberry)\\w*\\/([\\w\\.]*)/i,/(tizen|kaios)[\\/ ]([\\w\\.]+)/i,/\\((series40);/i],[p,v],[/\\(bb(10);/i],[v,[p,x]],[/(?:symbian ?os|symbos|s60(?=;)|series60)[-\\/ ]?([\\w\\.]*)/i],[v,[p,"Symbian"]],[/mozilla\\/[\\d\\.]+ \\((?:mobile|tablet|tv|mobile; [\\w ]+); rv:.+ gecko\\/([\\w\\.]+)/i],[v,[p,N+" OS"]],[/web0s;.+rt(tv)/i,/\\b(?:hp)?wos(?:browser)?\\/([\\w\\.]+)/i],[v,[p,"webOS"]],[/watch(?: ?os[,\\/]|\\d,\\d\\/)([\\d\\.]+)/i],[v,[p,"watchOS"]],[/crkey\\/([\\d\\.]+)/i],[v,[p,j+"cast"]],[/(cros) [\\w]+(?:\\)| ([\\w\\.]+)\\b)/i],[[p,z],v],[/panasonic;(viera)/i,/(netrange)mmh/i,/(nettv)\\/(\\d+\\.[\\w\\.]+)/i,/(nintendo|playstation) ([wids345portablevuch]+)/i,/(xbox); +xbox ([^\\);]+)/i,/\\b(joli|palm)\\b ?(?:os)?\\/?([\\w\\.]*)/i,/(mint)[\\/\\(\\) ]?(\\w*)/i,/(mageia|vectorlinux)[; ]/i,/([kxln]?ubuntu|debian|suse|opensuse|gentoo|arch(?= linux)|slackware|fedora|mandriva|centos|pclinuxos|red ?hat|zenwalk|linpus|raspbian|plan 9|minix|risc os|contiki|deepin|manjaro|elementary os|sabayon|linspire)(?: gnu\\/linux)?(?: enterprise)?(?:[- ]linux)?(?:-gnu)?[-\\/ ]?(?!chrom|package)([-\\w\\.]*)/i,/(hurd|linux) ?([\\w\\.]*)/i,/(gnu) ?([\\w\\.]*)/i,/\\b([-frentopcghs]{0,5}bsd|dragonfly)[\\/ ]?(?!amd|[ix346]{1,2}86)([\\w\\.]*)/i,/(haiku) (\\w+)/i],[p,v],[/(sunos) ?([\\w\\.\\d]*)/i],[[p,"Solaris"],v],[/((?:open)?solaris)[-\\/ ]?([\\w\\.]*)/i,/(aix) ((\\d)(?=\\.|\\)| )[\\w\\.])*/i,/\\b(beos|os\\/2|amigaos|morphos|openvms|fuchsia|hp-ux|serenityos)/i,/(unix) ?([\\w\\.]*)/i],[p,v]]},Z=function(e,t){if(typeof e===c&&(t=e,e=a),!(this instanceof Z))return new Z(e,t).getResult();var n=typeof i!==s&&i.navigator?i.navigator:a,r=e||(n&&n.userAgent?n.userAgent:""),b=n&&n.userAgentData?n.userAgentData:a,y=t?function(e,t){var n={};for(var r in e)t[r]&&t[r].length%2==0?n[r]=t[r].concat(e[r]):n[r]=e[r];return n}(G,t):G,T=n&&n.userAgent==r;return this.getBrowser=function(){var e,t={};return t[p]=a,t[v]=a,V.call(t,r,y.browser),t[l]=typeof(e=t[v])===u?e.replace(/[^\\d\\.]/g,"").split(".")[0]:a,T&&n&&n.brave&&typeof n.brave.isBrave==o&&(t[p]="Brave"),t},this.getCPU=function(){var e={};return e[g]=a,V.call(e,r,y.cpu),e},this.getDevice=function(){var e={};return e[f]=a,e[d]=a,e[m]=a,V.call(e,r,y.device),T&&!e[m]&&b&&b.mobile&&(e[m]=h),T&&"Macintosh"==e[d]&&n&&typeof n.standalone!==s&&n.maxTouchPoints&&n.maxTouchPoints>2&&(e[d]="iPad",e[m]=w),e},this.getEngine=function(){var e={};return e[p]=a,e[v]=a,V.call(e,r,y.engine),e},this.getOS=function(){var e={};return e[p]=a,e[v]=a,V.call(e,r,y.os),T&&!e[p]&&b&&"Unknown"!=b.platform&&(e[p]=b.platform.replace(/chrome os/i,z).replace(/macos/i,K)),e},this.getResult=function(){return{ua:this.getUA(),browser:this.getBrowser(),engine:this.getEngine(),os:this.getOS(),device:this.getDevice(),cpu:this.getCPU()}},this.getUA=function(){return r},this.setUA=function(e){return r=typeof e===u&&e.length>350?H(e,350):e,this},this.setUA(r),this};Z.VERSION="1.0.35",Z.BROWSER=$([p,v,l]),Z.CPU=$([g]),Z.DEVICE=$([d,f,m,b,h,y,w,T,k]),Z.ENGINE=Z.OS=$([p,v]),typeof t!==s?(e.exports&&(t=e.exports=Z),t.UAParser=Z):n.amdO?(r=function(){return Z}.call(t,n,t,e))===a||(e.exports=r):typeof i!==s&&(i.UAParser=Z);var Y=typeof i!==s&&(i.jQuery||i.Zepto);if(Y&&!Y.ua){var ee=new Z;Y.ua=ee.getResult(),Y.ua.get=function(){return ee.getUA()},Y.ua.set=function(e){ee.setUA(e);var t=ee.getResult();for(var n in t)Y.ua[n]=t[n]}}}("object"==typeof window?window:this)}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var a=t[r]={exports:{}};return e[r].call(a.exports,a,a.exports,n),a.exports}n.amdO={},n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{"use strict";n.r(r),n.d(r,{ActionType:()=>f,AmplitudePlatformName:()=>g,AnalyticsEventImportance:()=>l,AnalyticsQueries:()=>e,AuthStatus:()=>b,ComponentType:()=>m,IThresholdTier:()=>Jt,MetricType:()=>d,PlatformName:()=>v,SessionActions:()=>h,SessionAutomatedEvents:()=>w,SessionRank:()=>y,SubjectType:()=>p,UserTypeCommerce:()=>c,UserTypeInsto:()=>i,UserTypeRetail:()=>t,UserTypeRetailBusinessBanking:()=>s,UserTypeRetailEmployeeInternal:()=>a,UserTypeRetailEmployeePersonal:()=>o,UserTypeWallet:()=>u,automatedEvents:()=>xn,automatedMappingConfig:()=>In,clearMarkEntry:()=>Vn,clearPerformanceMarkEntries:()=>Xn,config:()=>A,createEventConfig:()=>On,createNewSpan:()=>Ln,createNewTrace:()=>Un,device:()=>W,endPerfMark:()=>Jn,exposeExperiment:()=>wn,flushQueue:()=>or,generateUUID:()=>V,getAnalyticsHeaders:()=>sr,getReferrerData:()=>le,getTracingHeaders:()=>An,getTracingId:()=>Dn,getUrlHostname:()=>pe,getUrlParams:()=>me,getUrlPathname:()=>fe,getUserContext:()=>ar,identify:()=>Tn,identifyFlow:()=>xe,identity:()=>H,identityFlow:()=>Se,incrementUjNavigation:()=>an,init:()=>yn,initNextJsTrackPageview:()=>_n,initTrackPageview:()=>kn,isEventKeyFormatValid:()=>we,isSessionEnded:()=>pt,location:()=>re,logEvent:()=>$t,logMetric:()=>Ht,logPageView:()=>on,logTrace:()=>Rn,markNTBT:()=>tn,markStep:()=>nn,markStepOnce:()=>rn,onVisibilityChange:()=>ln,optIn:()=>En,optOut:()=>Sn,perfMark:()=>Wn,persistentData:()=>oe,postMessage:()=>K,recordSessionDuration:()=>pn,removeFromIdentifyFlow:()=>Ee,savePersistentData:()=>st,sendScheduledEvents:()=>Bt,setBreadcrumbs:()=>ie,setConfig:()=>U,setLocation:()=>ae,setPagePath:()=>ve,setPageview:()=>Kt,setPersistentData:()=>se,setSessionStart:()=>dt,setTime:()=>Ue,startPerfMark:()=>Hn,timeStone:()=>Le,useEventLogger:()=>Yn,useLogEventOnMount:()=>tr,usePerformanceMarks:()=>rr});let e=function(e){return e.fbclid="fbclid",e.gclid="gclid",e.msclkid="msclkid",e.ptclid="ptclid",e.ttclid="ttclid",e.utm_source="utm_source",e.utm_medium="utm_medium",e.utm_campaign="utm_campaign",e.utm_term="utm_term",e.utm_content="utm_content",e}({});const t=0,i=1,a=2,o=3,s=4,c=5,u=6;let l=function(e){return e.low="low",e.high="high",e}({}),d=function(e){return e.count="count",e.rate="rate",e.gauge="gauge",e.distribution="distribution",e.histogram="histogram",e}({}),p=function(e){return e.commerce_merchant="commerce_merchant",e.device="device",e.edp_fingerprint_id="edp_fingerprint_id",e.nft_user="nft_user",e.user="user",e.wallet_user="wallet_user",e.uuid="user_uuid",e}({}),m=function(e){return e.unknown="unknown",e.banner="banner",e.button="button",e.card="card",e.chart="chart",e.content_script="content_script",e.dropdown="dropdown",e.link="link",e.page="page",e.modal="modal",e.table="table",e.search_bar="search_bar",e.service_worker="service_worker",e.text="text",e.text_input="text_input",e.tray="tray",e.checkbox="checkbox",e.icon="icon",e}({}),f=function(e){return e.unknown="unknown",e.blur="blur",e.click="click",e.change="change",e.dismiss="dismiss",e.focus="focus",e.hover="hover",e.select="select",e.measurement="measurement",e.move="move",e.process="process",e.render="render",e.scroll="scroll",e.view="view",e.search="search",e.keyPress="keyPress",e}({}),v=function(e){return e.unknown="unknown",e.web="web",e.android="android",e.ios="ios",e.mobile_web="mobile_web",e.tablet_web="tablet_web",e.server="server",e.windows="windows",e.macos="macos",e.extension="extension",e}({}),g=function(e){return e.web="Web",e.ios="iOS",e.android="Android",e}({}),b=function(e){return e[e.notLoggedIn=0]="notLoggedIn",e[e.loggedIn=1]="loggedIn",e}({}),h=function(e){return e.ac="ac",e.af="af",e.ah="ah",e.al="al",e.am="am",e.ar="ar",e.as="as",e}({}),w=function(e){return e.pv="pv",e}({}),y=function(e){return e.xs="xs",e.s="s",e.m="m",e.l="l",e.xl="xl",e.xxl="xxl",e}({});const T="https://analytics-service-dev.cbhq.net",k=3e5,_=5e3,S="analytics-db",E="experiment-exposure-db",x="Analytics SDK:",O=Object.values(e),j="pageview",N="session_duration",I={navigationTiming:{eventName:"perf_navigation_timing"},redirectTime:{eventName:"perf_redirect_time"},RT:{eventName:"perf_redirect_time"},TTFB:{eventName:"perf_time_to_first_byte"},networkInformation:{eventName:"perf_network_information"},storageEstimate:{eventName:"perf_storage_estimate"},FCP:{eventName:"perf_first_contentful_paint"},FID:{eventName:"perf_first_input_delay"},LCP:{eventName:"perf_largest_contentful_paint"},CLS:{eventName:"perf_cumulative_layout_shift"},TBT:{eventName:"perf_total_blocking_time"},NTBT:{eventName:"perf_navigation_total_blocking_time"},INP:{eventName:"perf_interact_to_next_paint"},ET:{eventName:"perf_element_timing"},userJourneyStep:{eventName:"perf_user_journey_step"}},P="1",M="web";function B(){return B=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},B.apply(this,arguments)}const C=/^(https?:\\/\\/)/;function D(e){return{eventsEndpoint:e+"/amp",metricsEndPoint:e+"/metrics",exposureEndpoint:e+"/track-exposures",tracesEndpoint:e+"/traces"}}const A=B({authCookie:"logged_in",amplitudeApiKey:"",batchEventsPeriod:_,batchEventsThreshold:30,batchMetricsPeriod:_,batchMetricsThreshold:30,batchTracesPeriod:_,batchTracesThreshold:30,headers:{},interactionManager:null,isAlwaysAuthed:!1,isProd:!1,isInternalApplication:!1,onError:(e,t)=>{console.error(x,e,t)},platform:v.unknown,projectName:"",ricTimeoutScheduleEvent:1e3,ricTimeoutSetDevice:500,showDebugLogging:!1,trackUserId:!1,version:null,apiEndpoint:T},D(T),{steps:{}}),L=[].reduce(((e,t)=>n=>e(t(n))),(e=>{if(!e.isProd)return e.isInternalApplication?(e.apiEndpoint="https://analytics-service-internal-dev.cbhq.net",B({},e,D(e.apiEndpoint))):e;const t=(e=>e.apiEndpoint?C.test(e.apiEndpoint)?e.apiEndpoint:`https://${e.apiEndpoint}`:e.isInternalApplication?"https://analytics-service-internal.cbhq.net":"https://as.coinbase.com")(e);return B({},e,{apiEndpoint:t},D(t))})),U=e=>{const{batchEventsThreshold:t,batchMetricsThreshold:n,batchTracesThreshold:r}=e,i=[t,n,r];for(const e of i)if((e||0)>30){console.warn("You are setting the threshhold for the batch limit to be greater than 30. This may cause request overload.");break}Object.assign(A,L(e))},R=[v.web,v.mobile_web,v.tablet_web];function q(){return"android"===A.platform}function F(){return"ios"===A.platform}function z(){return R.includes(A.platform)}function K(e){if(z()&&navigator&&"serviceWorker"in navigator&&navigator.serviceWorker.controller)try{navigator.serviceWorker.controller.postMessage(e)}catch(e){e instanceof Error&&A.onError(e)}}var $=n(353),Q=n.n($);const W={amplitudeOSName:null,amplitudeOSVersion:null,amplitudeDeviceModel:null,amplitudePlatform:null,browserName:null,browserMajor:null,osName:null,userAgent:null,width:null,height:null},H={countryCode:null,deviceId:null,device_os:null,isOptOut:!1,languageCode:null,locale:null,jwt:null,session_lcc_id:null,userAgent:null,userId:null},V=e=>e?(e^16*Math.random()>>e/4).toString(16):"10000000-1000-4000-8000-100000000000".replace(/[018]/g,V),J=()=>A.isAlwaysAuthed||!!H.userId,X=()=>{const e={};return H.countryCode&&(e.country_code=H.countryCode),e},G=()=>{const{platform:e}=A;if(e===v.web)switch(!0){case window.matchMedia("(max-width: 560px)").matches:return v.mobile_web;case window.matchMedia("(max-width: 1024px, min-width: 561px)").matches:return v.tablet_web}return e},Z=()=>{var e,t,n,r,i;z()?("requestIdleCallback"in window?window.requestIdleCallback(ne,{timeout:A.ricTimeoutSetDevice}):ne(),W.amplitudePlatform=g.web,W.userAgent=(null==(e=window)||null==(e=e.navigator)?void 0:e.userAgent)||null,ee({height:null!=(t=null==(n=window)?void 0:n.innerHeight)?t:null,width:null!=(r=null==(i=window)?void 0:i.innerWidth)?r:null})):F()?(W.amplitudePlatform=g.ios,W.userAgent=H.userAgent,W.userAgent&&ne()):q()&&(W.userAgent=H.userAgent,W.amplitudePlatform=g.android,W.userAgent&&ne())},Y=e=>{Object.assign(H,e),z()&&K({identity:{isAuthed:!!H.userId,locale:H.locale||null}})},ee=e=>{W.height=e.height,W.width=e.width},te=()=>{U({platform:G()}),z()&&K({config:{platform:A.platform}})},ne=()=>{var e;performance.mark&&performance.mark("ua_parser_start");const t=new(Q())(null!=(e=W.userAgent)?e:"").getResult();W.browserName=t.browser.name||null,W.browserMajor=t.browser.major||null,W.osName=t.os.name||null,W.amplitudeOSName=W.browserName,W.amplitudeOSVersion=W.browserMajor,W.amplitudeDeviceModel=W.osName,K({device:{browserName:W.browserName,osName:W.osName}}),performance.mark&&(performance.mark("ua_parser_end"),performance.measure("ua_parser","ua_parser_start","ua_parser_end"))},re={breadcrumbs:[],initialUAAData:{},pageKey:"",pageKeyRegex:{},pagePath:"",prevPageKey:"",prevPagePath:""};function ie(e){Object.assign(re,{breadcrumbs:e})}function ae(e){Object.assign(re,e)}const oe={eventId:0,sequenceNumber:0,sessionId:0,lastEventTime:0,sessionStart:0,sessionUUID:null,userId:null,ac:0,af:0,ah:0,al:0,am:0,ar:0,as:0,pv:0};function se(e){Object.assign(oe,e)}function ce(){var e,t;return null!=(e=null==(t=document)?void 0:t.referrer)?e:""}function ue(){return ue=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},ue.apply(this,arguments)}const le=()=>{const e=ce();if(!e)return{};const t=new URL(e);return t.hostname===pe()?{}:{referrer:e,referring_domain:t.hostname}},de=()=>{const e=new URLSearchParams(me()),t={};return O.forEach((n=>{e.has(n)&&(t[n]=(e.get(n)||"").toLowerCase())})),t},pe=()=>{var e;return(null==(e=window)||null==(e=e.location)?void 0:e.hostname)||""},me=()=>{var e;return(null==(e=window)||null==(e=e.location)?void 0:e.search)||""},fe=()=>{var e;return(null==(e=window)||null==(e=e.location)?void 0:e.pathname)||""},ve=()=>{const e=A.overrideWindowLocation?re.pagePath:fe()+me();e&&e!==re.pagePath&&(e!==re.pagePath&&ge(),re.pagePath=e,re.pageKeyRegex&&Object.keys(re.pageKeyRegex).some((e=>{if(re.pageKeyRegex[e].test(re.pagePath))return re.pageKey=e,!0})))},ge=()=>{if(z()){const e=ce();if(!re.prevPagePath&&e){const t=new URL(e);if(t.hostname===pe())return void(re.prevPagePath=t.pathname)}}re.prevPagePath=re.pagePath,re.prevPageKey=re.pageKey},be=e=>{z()&&Object.assign(e,z()?(Object.keys(re.initialUAAData).length>0||(new URLSearchParams(me()),re.initialUAAData=ue({},(()=>{const e={};return O.forEach((t=>{oe[t]&&(e[t]=oe[t])})),e})(),de(),le())),re.initialUAAData):re.initialUAAData)},he=/^[a-zd]+(_[a-zd]+)*$/;function we(e){return he.test(e)}function ye(){return ye=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},ye.apply(this,arguments)}const Te=["action","component_type","component_name","context","logging_id"],ke=["num_non_hardware_accounts","ujs"],_e="ujs_",Se={};function Ee(e){e.forEach((e=>{ke.includes(e)&&delete Se[e]}))}function xe(e){var t;const n=Object.entries(e).reduce(((e,t)=>{const[n,r]=t;return!Te.includes(n)&&ke.includes(n)?we(n)?ye({},e,{[n]:r}):(A.onError(new Error("IdentityFlow property names must have snake case format"),{[n]:r}),e):e}),{});null!=(t=n.ujs)&&t.length&&(n.ujs=n.ujs.map((e=>`${_e}${e}`))),Object.assign(Se,n)}function Oe(){return A.platform!==v.unknown||(A.onError(new Error("SDK platform not initialized")),!1)}const je={eventsQueue:[],eventsScheduled:!1,metricsQueue:[],metricsScheduled:!1,tracesQueue:[],tracesScheduled:!1};function Ne(e){Object.assign(je,e)}const Ie={ac:0,af:0,ah:0,al:0,am:0,ar:0,as:0,pv:0,sqs:0},Pe={ac:20,af:5,ah:1,al:1,am:0,ar:10,as:20},Me={pv:25},Be={xs:0,s:1,m:1,l:2,xl:2,xxl:2},Ce=e=>e<15?y.xs:e<60?y.s:e<240?y.m:e<960?y.l:e<3840?y.xl:y.xxl,De=e=>{Object.assign(Ie,e)};function Ae(){return(new Date).getTime()}const Le={timeStart:Ae(),timeOnPagePath:0,timeOnPageKey:0,prevTimeOnPagePath:0,prevTimeOnPageKey:0,sessionDuration:0,sessionEnd:0,sessionStart:0,prevSessionDuration:0};function Ue(e){Object.assign(Le,e)}const Re=(e,t)=>t.some((t=>e instanceof t));let qe,Fe;const ze=new WeakMap,Ke=new WeakMap,$e=new WeakMap,Qe=new WeakMap,We=new WeakMap;let He={get(e,t,n){if(e instanceof IDBTransaction){if("done"===t)return Ke.get(e);if("objectStoreNames"===t)return e.objectStoreNames||$e.get(e);if("store"===t)return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return Je(e[t])},set:(e,t,n)=>(e[t]=n,!0),has:(e,t)=>e instanceof IDBTransaction&&("done"===t||"store"===t)||t in e};function Ve(e){return"function"==typeof e?(t=e)!==IDBDatabase.prototype.transaction||"objectStoreNames"in IDBTransaction.prototype?(Fe||(Fe=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(t)?function(...e){return t.apply(Xe(this),e),Je(ze.get(this))}:function(...e){return Je(t.apply(Xe(this),e))}:function(e,...n){const r=t.call(Xe(this),e,...n);return $e.set(r,e.sort?e.sort():[e]),Je(r)}:(e instanceof IDBTransaction&&function(e){if(Ke.has(e))return;const t=new Promise(((t,n)=>{const r=()=>{e.removeEventListener("complete",i),e.removeEventListener("error",a),e.removeEventListener("abort",a)},i=()=>{t(),r()},a=()=>{n(e.error||new DOMException("AbortError","AbortError")),r()};e.addEventListener("complete",i),e.addEventListener("error",a),e.addEventListener("abort",a)}));Ke.set(e,t)}(e),Re(e,qe||(qe=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction]))?new Proxy(e,He):e);var t}function Je(e){if(e instanceof IDBRequest)return function(e){const t=new Promise(((t,n)=>{const r=()=>{e.removeEventListener("success",i),e.removeEventListener("error",a)},i=()=>{t(Je(e.result)),r()},a=()=>{n(e.error),r()};e.addEventListener("success",i),e.addEventListener("error",a)}));return t.then((t=>{t instanceof IDBCursor&&ze.set(t,e)})).catch((()=>{})),We.set(t,e),t}(e);if(Qe.has(e))return Qe.get(e);const t=Ve(e);return t!==e&&(Qe.set(e,t),We.set(t,e)),t}const Xe=e=>We.get(e),Ge=["get","getKey","getAll","getAllKeys","count"],Ze=["put","add","delete","clear"],Ye=new Map;function et(e,t){if(!(e instanceof IDBDatabase)||t in e||"string"!=typeof t)return;if(Ye.get(t))return Ye.get(t);const n=t.replace(/FromIndex$/,""),r=t!==n,i=Ze.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!i&&!Ge.includes(n))return;const a=async function(e,...t){const a=this.transaction(e,i?"readwrite":"readonly");let o=a.store;return r&&(o=o.index(t.shift())),(await Promise.all([o[n](...t),i&&a.done]))[0]};return Ye.set(t,a),a}var tt;tt=He,He={...tt,get:(e,t,n)=>et(e,t)||tt.get(e,t,n),has:(e,t)=>!!et(e,t)||tt.has(e,t)};const nt={isReady:!1,idbKeyval:null};function rt(e){Object.assign(nt,e)}const it={},at=async e=>{if(!nt.idbKeyval)return Promise.resolve(null);try{return await nt.idbKeyval.get(e)}catch(e){return A.onError(new Error("IndexedDB:Get:InternalError")),Promise.resolve(null)}},ot=async(e,t)=>{if(nt.idbKeyval)try{await nt.idbKeyval.set(e,t)}catch(e){A.onError(new Error("IndexedDB:Set:InternalError"))}},st=()=>{"server"!==A.platform&&(se({sessionStart:Le.sessionStart,ac:Ie.ac,af:Ie.af,ah:Ie.ah,al:Ie.al,am:Ie.am,ar:Ie.ar,as:Ie.as,pv:Ie.pv}),H.userId&&se({userId:H.userId}),ot(S,oe))},ct="rgb(5,177,105)",ut=e=>{const{metricName:t,data:n}=e,r=e.importance||l.low;if(!A.showDebugLogging||!console)return;const i=`%c ${x}`,a=`color:${ct};font-size:11px;`,o=`Importance: ${r}`;console.group(i,a,t,o),n.forEach((e=>{e.event_type?console.log(e.event_type,e):console.log(e)})),console.groupEnd()},lt=e=>{const{metricName:t,data:n}=e,r=e.importance||l.low;if(!A.showDebugLogging||!console)return;const i=`color:${ct};font-size:11px;`,a=`%c ${x}`,o=`Importance: ${r}`;console.log(a,i,t,n,o)},dt=()=>{const e=Ae();oe.sessionId&&oe.lastEventTime&&oe.sessionUUID&&!pt(e)||(oe.sessionId=e,oe.sessionUUID=V(),Ue({sessionStart:e}),lt({metricName:"Started new session:",data:{persistentData:oe,timeStone:Le}})),oe.lastEventTime=e},pt=e=>e-oe.lastEventTime>18e5;function mt(){return mt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},mt.apply(this,arguments)}const ft=e=>{var t;(e=>{switch(e.action){case f.click:Ie.ac+=1;break;case f.focus:Ie.af+=1;break;case f.hover:Ie.ah+=1;break;case f.move:Ie.am+=1;break;case f.scroll:Ie.al+=1;break;case f.search:Ie.ar+=1;break;case f.select:Ie.as+=1}})(t=e),t.event_type!==j?t.event_type===N&&((e=>{if(!e.session_rank)return;const t=e.session_rank;Object.values(h).forEach((e=>{Ie.sqs+=Ie[e]*Pe[e]})),Object.values(w).forEach((e=>{Ie.sqs+=Ie[e]*Me[e]})),Ie.sqs*=Be[t]})(t),Object.assign(t,Ie),De({ac:0,af:0,ah:0,al:0,am:0,ar:0,as:0,pv:0,sqs:0})):Ie.pv+=1;const n=e.event_type;delete e.event_type;const r=e.deviceId?e.deviceId:null,i=e.timestamp;return delete e.timestamp,se({eventId:oe.eventId+1}),se({sequenceNumber:oe.sequenceNumber+1}),dt(),st(),{device_id:H.deviceId||r||null,user_id:H.userId,timestamp:i,event_id:oe.eventId,session_id:oe.sessionId||-1,event_type:n,version_name:A.version||null,platform:W.amplitudePlatform,os_name:W.amplitudeOSName,os_version:W.amplitudeOSVersion,device_model:W.amplitudeDeviceModel,language:H.languageCode,event_properties:mt({},e,{session_uuid:oe.sessionUUID,height:W.height,width:W.width}),user_properties:X(),uuid:V(),library:{name:"@cbhq/client-analytics",version:"10.6.0"},sequence_number:oe.sequenceNumber,user_agent:W.userAgent||H.userAgent}},vt=e=>e.map((e=>ft(e)));function gt(){return gt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},gt.apply(this,arguments)}const bt=e=>e.map((e=>(e=>{const t=e.tags||{},n=gt({authed:J()?"true":"false",platform:A.platform},t,{project_name:A.projectName,version_name:A.version||null});return{metric_name:e.metricName,page_path:e.pagePath||null,value:e.value,tags:n,type:e.metricType}})(e))),ht=e=>0!==je.metricsQueue.length&&(je.metricsQueue.length>=A.batchMetricsThreshold||(je.metricsScheduled||(je.metricsScheduled=!0,setTimeout((()=>{je.metricsScheduled=!1,e(bt(je.metricsQueue)),je.metricsQueue=[]}),A.batchMetricsPeriod)),!1)),wt=e=>0!==je.tracesQueue.length&&(je.tracesQueue.length>=A.batchTracesThreshold||(je.tracesScheduled||(je.tracesScheduled=!0,setTimeout((()=>{je.tracesScheduled=!1,e(je.tracesQueue),je.tracesQueue=[]}),A.batchTracesPeriod)),!1)),yt=e=>{var t;z()&&null!=(t=window)&&t.requestIdleCallback?window.requestIdleCallback(e,{timeout:A.ricTimeoutScheduleEvent}):(q()||F())&&A.interactionManager?A.interactionManager.runAfterInteractions(e):e()};function Tt(){return Tt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Tt.apply(this,arguments)}const kt="application/x-www-form-urlencoded; charset=UTF-8",_t=e=>{const{data:t,importance:n,isJSON:r,onError:i,url:a}=e,o=r?"application/json":kt,s=n||l.low,c=r?JSON.stringify(t):new URLSearchParams(t).toString();function u(){const e=new XMLHttpRequest;e.open("POST",a,!0),Object.keys(A.headers||{}).forEach((t=>{e.setRequestHeader(t,A.headers[t])})),e.setRequestHeader("Content-Type",kt),H.jwt&&e.setRequestHeader("authorization",`Bearer ${H.jwt}`),e.send(c)}if(!z()||r||!("sendBeacon"in navigator)||s!==l.low||A.headers&&0!==Object.keys(A.headers).length)if(z()&&!r)u();else{const e=Tt({},A.headers,{"Content-Type":o});H.jwt&&(e.Authorization=`Bearer ${H.jwt}`),fetch(a,{method:"POST",mode:"no-cors",headers:e,body:c}).catch((e=>{i(e,{context:"AnalyticsSDKApiError"})}))}else{const e=new Blob([c],{type:kt});try{navigator.sendBeacon.bind(navigator)(a,e)||u()}catch(e){console.error(e),u()}}};var St=n(762),Et=n.n(St);const xt=(e,t,n)=>{const r=e||"";return Et()("2"+r+t+n)};function Ot(){return Ot=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Ot.apply(this,arguments)}class jt extends Error{constructor(e){super(e),this.name="CircularJsonReference",this.message=e,"function"==typeof Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error(e).stack}}class Nt extends jt{constructor(...e){super(...e),this.name="DomReferenceInAnalyticsEvent"}}function It(){return It=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},It.apply(this,arguments)}const Pt=(e,t=l.low)=>{var n;e&&je.eventsQueue.push(e),nt.isReady&&(!A.trackUserId||H.userId?(t===l.high||(n=Mt,0!==je.eventsQueue.length&&(je.eventsQueue.length>=A.batchEventsThreshold||(je.eventsScheduled||(je.eventsScheduled=!0,setTimeout((()=>{je.eventsScheduled=!1,n(vt(je.eventsQueue)),je.eventsQueue=[]}),A.batchEventsPeriod)),0))))&&Bt():je.eventsQueue.length>10&&(A.trackUserId=!1,A.onError(new Error("userId not set in Logged-in"))))},Mt=(e,t=l.low)=>{if(H.isOptOut||0===e.length)return;let n;try{n=JSON.stringify(e)}catch(t){const r=e.map((e=>e.event_type)).join(", "),[i,a]=(e=>{try{const n=[];for(const r of e){const e=Ot({},r);r.event_properties&&(e.event_properties=Ot({},e.event_properties,{currentTarget:null,target:null,relatedTarget:null,_dispatchInstances:null,_targetInst:null,view:(t=r.event_properties.view,["string","number","boolean"].includes(typeof t)?r.event_properties.view:null)})),n.push(e)}return[!0,JSON.stringify(n)]}catch(e){return[!1,""]}var t})(e);if(!i)return void A.onError(new jt(t instanceof Error?t.message:"unknown"),{listEventType:r});n=a,A.onError(new Nt("Found DOM element reference"),{listEventType:r,stringifiedEventData:n})}const r=Ae().toString(),i=It({},{e:n,v:"2",upload_time:r},{client:A.amplitudeApiKey,checksum:xt(A.amplitudeApiKey,n,r)});_t({url:A.eventsEndpoint,data:i,importance:t,onError:A.onError}),ut({metricName:"Batch Events",data:e,importance:t})},Bt=()=>{Mt(vt(je.eventsQueue)),Ne({eventsQueue:[]})};function Ct(){return Ct=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Ct.apply(this,arguments)}const Dt=Object.values(f),At=Object.values(m),Lt=e=>Dt.includes(e)?e:f.unknown,Ut=e=>At.includes(e)?e:m.unknown,Rt=(e,t,n)=>{const r={auth:J()?b.loggedIn:b.notLoggedIn,action:Lt(e),component_type:Ut(t),logging_id:n,platform:A.platform,project_name:A.projectName};return"number"==typeof H.userTypeEnum&&(r.user_type_enum=H.userTypeEnum),r},qt=e=>{const t=Ae();if(!e)return A.onError(new Error("missing logData")),Ct({},Rt(f.unknown,m.unknown),{locale:H.locale,session_lcc_id:H.session_lcc_id,timestamp:t,time_start:Le.timeStart});const n=Ct({},e,Rt(e.action,e.componentType,e.loggingId),{locale:H.locale,session_lcc_id:H.session_lcc_id,timestamp:t,time_start:Le.timeStart});return delete n.componentType,delete n.loggingId,n},Ft={blacklistRegex:[],isEnabled:!1};function zt(){return{page_key:re.pageKey,page_path:re.pagePath,prev_page_key:re.prevPageKey,prev_page_path:re.prevPagePath}}function Kt(e){Object.assign(Ft,e)}function $t(e,t,n=l.low){if(H.isOptOut)return;if(!Oe())return;const r=qt(t);!function(e){Ft.isEnabled&&(ve(),Object.assign(e,zt()))}(r),be(r),function(e){Object.keys(Se).length>0&&Object.assign(e,Se)}(r),r.has_double_fired=!1,r.event_type=e,n===l.high?Pt(r,n):yt((()=>{Pt(r)}))}function Qt(e,t=!1){t?_t({url:A.metricsEndPoint,data:{metrics:e},isJSON:!0,onError:A.onError}):yt((()=>{_t({url:A.metricsEndPoint,data:{metrics:e},isJSON:!0,onError:A.onError})})),ut({metricName:"Batch Metrics",data:e})}function Wt(){return Wt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Wt.apply(this,arguments)}function Ht(e){if(!Oe())return;v.server!==A.platform&&!e.pagePath&&re.pagePath&&(e.pagePath=re.pagePath);const t=Object.keys(Se).length?Wt({},e.tags,Se):e.tags;t&&Object.assign(e,{tags:t}),je.metricsQueue.push(e),ht(Qt)&&(Qt(bt(je.metricsQueue)),je.metricsQueue=[])}function Vt(){return Vt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Vt.apply(this,arguments)}let Jt=function(e){return e.instant="instant",e.quick="quick",e.moderate="moderate",e.slow="slow",e.unavoidable="unavoidable",e}({});function Xt(e){return e.toLowerCase()}let Gt={};const Zt=(e,t)=>{null!=A&&A.onMarkStep&&A.onMarkStep(e,t),xe({ujs:t})};let Yt;const en={Perfume:()=>{},markStep:e=>{},markStepOnce:e=>{},incrementUjNavigation:()=>{}},tn=()=>{z()&&Yt&&Yt.markNTBT&&Yt.markNTBT()},nn=e=>{z()&&Yt&&en.markStep&&en.markStep(e)},rn=e=>{z()&&Yt&&en.markStepOnce&&en.markStepOnce(e)},an=()=>{z()&&Yt&&en.incrementUjNavigation&&en.incrementUjNavigation()};function on(e={callMarkNTBT:!0}){"unknown"!==A.platform&&(Ft.blacklistRegex.some((e=>e.test(fe())))||($t(j,{action:f.render,componentType:m.page}),e.callMarkNTBT&&tn()))}let sn=!1,cn=!1;const un=e=>{sn=!e.persisted},ln=(e,t="hidden",n=!1)=>{cn||(addEventListener("pagehide",un),addEventListener("beforeunload",(()=>{})),cn=!0),addEventListener("visibilitychange",(({timeStamp:n})=>{document.visibilityState===t&&e({timeStamp:n,isUnloading:sn})}),{capture:!0,once:n})},dn=36e3;function pn(){const e=pt(Ae());if(e&&(O.forEach((e=>{oe[e]&&delete oe[e]})),st()),!oe.lastEventTime||!Le.sessionStart||!e)return;const t=Math.round((oe.lastEventTime-Le.sessionStart)/1e3);if(t<1||t>dn)return;const n=Ce(t);$t(N,{action:f.measurement,componentType:m.page,session_duration:t,session_end:oe.lastEventTime,session_start:Le.sessionStart,session_rank:n})}function mn(){return mn=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},mn.apply(this,arguments)}const fn=[],vn=[],gn=()=>{const e=fn.shift();e&&e()},bn=()=>{const e=vn.shift();e&&e()};let hn={};function wn(e){const t=function(e){return{test_name:e.testName,group_name:e.group,subject_id:e.subjectId,exposed_at:Ae(),subject_type:e.subjectType,platform:A.platform}}(e);hn[e.testName]=hn[e.testName]||0,hn[e.testName]+k>Ae()?lt({metricName:`Event: exposeExperiment ${e.testName} not sent`,data:t}):(hn[e.testName]=Ae(),ot(E,hn),lt({metricName:`Event: exposeExperiment ${e.testName} sent`,data:t}),_t({url:A.exposureEndpoint,data:[t],onError:(t,n)=>{hn[e.testName]=0,ot(E,hn),A.onError(t,n)},isJSON:!0,importance:l.high}))}const yn=e=>{var t,r,i;U(e),z()&&(H.languageCode=(null==(t=navigator)?void 0:t.languages[0])||(null==(r=navigator)?void 0:r.language)||""),te(),(()=>{var e;if(z()&&null!=(e=window)&&e.indexedDB){const e=function(e,t,{blocked:n,upgrade:r,blocking:i,terminated:a}={}){const o=indexedDB.open(e,t),s=Je(o);return r&&o.addEventListener("upgradeneeded",(e=>{r(Je(o.result),e.oldVersion,e.newVersion,Je(o.transaction),e)})),n&&o.addEventListener("blocked",(e=>n(e.oldVersion,e.newVersion,e))),s.then((e=>{a&&e.addEventListener("close",(()=>a())),i&&e.addEventListener("versionchange",(e=>i(e.oldVersion,e.newVersion,e)))})).catch((()=>{})),s}("keyval-store",1,{upgrade(e){e.createObjectStore("keyval")}});rt({idbKeyval:{get:async t=>(await e).get("keyval",t),set:async(t,n)=>(await e).put("keyval",n,t),delete:async t=>(await e).delete("keyval",t),keys:async()=>(await e).getAllKeys("keyval")}})}else rt({idbKeyval:{get:async e=>new Promise((t=>{t(it[e])})),set:async(e,t)=>new Promise((n=>{it[e]=t,n(e)})),delete:async e=>new Promise((()=>{delete it[e]})),keys:async()=>new Promise((e=>{e(Object.keys(it))}))}})})(),lt({metricName:"Initialized Analytics:",data:{deviceId:H.deviceId}}),fn.push((()=>{Pt()})),(async()=>{const e=await at(S);rt({isReady:!0}),gn(),e&&(bn(),se({eventId:e.eventId||oe.eventId,sequenceNumber:e.sequenceNumber||oe.sequenceNumber,sessionId:e.sessionId||oe.sessionId,lastEventTime:e.lastEventTime||oe.lastEventTime,sessionUUID:e.sessionUUID||oe.sessionUUID}),function(e){se(mn({},function(e){const t={};return O.forEach((n=>{e[n]&&(t[n]=e[n])})),t}(e),de()))}(e),Ue({sessionStart:e.sessionStart||oe.sessionStart}),De({ac:e.ac||Ie.ac,af:e.af||Ie.af,ah:e.ah||Ie.ah,al:e.al||Ie.al,am:e.am||Ie.am,ar:e.ar||Ie.ar,as:e.as||Ie.as,pv:e.pv||Ie.pv}),A.trackUserId&&Y({userId:e.userId||H.userId}),pn(),lt({metricName:"Initialized Analytics IndexedDB:",data:e}))})(),async function(){at(E).then((e=>{hn=null!=e?e:{}})).catch((e=>{e instanceof Error&&A.onError(e)}))}(),Z(),z()&&(ln((()=>{se({lastEventTime:Ae()}),st(),Bt()}),"hidden"),ln((()=>{pn()}),"visible")),z()&&(i=()=>{var e,t,n,r;te(),ee({width:null!=(e=null==(t=window)?void 0:t.innerWidth)?e:null,height:null!=(n=null==(r=window)?void 0:r.innerHeight)?n:null})},addEventListener("resize",(()=>{requestAnimationFrame((()=>{i()}))}))),(()=>{if(z())try{const e=n(2);en.markStep=e.markStep,en.markStepOnce=e.markStepOnce,en.incrementUjNavigation=e.incrementUjNavigation,Yt=new e.Perfume({analyticsTracker:e=>{const{data:t,attribution:n,metricName:r,navigatorInformation:i,rating:a}=e,o=I[r],s=(null==n?void 0:n.category)||null;if(!o&&!s)return;const c=(null==i?void 0:i.deviceMemory)||0,u=(null==i?void 0:i.hardwareConcurrency)||0,l=(null==i?void 0:i.isLowEndDevice)||!1,p=(null==i?void 0:i.isLowEndExperience)||!1,v=(null==i?void 0:i.serviceWorkerStatus)||"unsupported",g=Vt({deviceMemory:c,hardwareConcurrency:u,isLowEndDevice:l,isLowEndExperience:p,serviceWorkerStatus:v},Gt),b={is_low_end_device:l,is_low_end_experience:p,page_key:re.pageKey||"",save_data:t.saveData||!1,service_worker:v,is_perf_metric:!0};if("navigationTiming"===r)t&&"number"==typeof t.redirectTime&&Ht({metricName:I.redirectTime.eventName,metricType:d.histogram,tags:b,value:t.redirectTime||0});else if("TTFB"===r)$t(o.eventName,Vt({action:f.measurement,componentType:m.page,duration:t||null,vitalsScore:a||null},g)),Ht({metricName:I.TTFB.eventName,metricType:d.histogram,tags:Vt({},b),value:t}),a&&Ht({metricName:`perf_web_vitals_ttfb_${a}`,metricType:d.count,tags:b,value:1});else if("networkInformation"===r)null!=t&&t.effectiveType&&(Gt=t,$t(o.eventName,{action:f.measurement,componentType:m.page,networkInformationDownlink:t.downlink,networkInformationEffectiveType:t.effectiveType,networkInformationRtt:t.rtt,networkInformationSaveData:t.saveData,navigatorDeviceMemory:c,navigatorHardwareConcurrency:u}));else if("storageEstimate"===r)$t(o.eventName,Vt({action:f.measurement,componentType:m.page},t,g)),Ht({metricName:"perf_storage_estimate_caches",metricType:d.histogram,tags:b,value:t.caches}),Ht({metricName:"perf_storage_estimate_indexed_db",metricType:d.histogram,tags:b,value:t.indexedDB});else if("CLS"===r)$t(o.eventName,Vt({action:f.measurement,componentType:m.page,score:100*t||null,vitalsScore:a||null},g)),a&&Ht({metricName:`perf_web_vitals_cls_${a}`,metricType:d.count,tags:b,value:1});else if("FID"===r){const e=(null==n?void 0:n.performanceEntry)||null,r=parseInt((null==e?void 0:e.processingStart)||"");$t(o.eventName,Vt({action:f.measurement,componentType:m.page,duration:t||null,processingStart:null!=e&&e.processingStart?r:null,startTime:null!=e&&e.startTime?parseInt(e.startTime):null,vitalsScore:a||null},g)),a&&Ht({metricName:`perf_web_vitals_fidVitals_${a}`,metricType:d.count,tags:b,value:1})}else"userJourneyStep"===r?($t("perf_user_journey_step",Vt({action:f.measurement,componentType:m.page,duration:t||null,rating:null!=a?a:null,step_name:(null==n?void 0:n.stepName)||""},g)),Ht({metricName:`user_journey_step.${A.projectName}.${A.platform}.${(null==n?void 0:n.stepName)||""}_vitals_${a}`,metricType:d.count,tags:b,value:1}),Ht({metricName:`user_journey_step.${A.projectName}.${A.platform}.${(null==n?void 0:n.stepName)||""}`,metricType:d.distribution,tags:b,value:t||null})):I[r]&&t&&($t(o.eventName,Vt({action:f.measurement,componentType:m.page,duration:t||null,vitalsScore:a||null},g)),a&&(Ht({metricName:`perf_web_vitals_${Xt(r)}_${a}`,metricType:d.count,tags:b,value:1}),"LCP"===r&&Ht({metricName:`perf_web_vitals_${Xt(r)}`,metricType:d.distribution,tags:b,value:t})))},maxMeasureTime:3e4,steps:A.steps,onMarkStep:Zt})}catch(e){e instanceof Error&&A.onError(e)}})()},Tn=e=>{Y(e),e.userAgent&&Z(),lt({metricName:"Identify:",data:{countryCode:H.countryCode,deviceId:H.deviceId,userId:H.userId}})},kn=({blacklistRegex:e,pageKeyRegex:t,browserHistory:n})=>{Kt({blacklistRegex:e||[],isEnabled:!0}),ae({pageKeyRegex:t}),on({callMarkNTBT:!1}),n.listen((()=>{on()}))},_n=({blacklistRegex:e,pageKeyRegex:t,nextJsRouter:n})=>{Kt({blacklistRegex:e||[],isEnabled:!0}),ae({pageKeyRegex:t}),on({callMarkNTBT:!1}),n.events.on("routeChangeComplete",(()=>{on()}))},Sn=()=>{Y({isOptOut:!0}),ot(S,{})},En=()=>{Y({isOptOut:!1})},xn={Button:{label:"cb_button",uuid:"e921a074-40e6-4371-8700-134d5cd633e6",componentType:m.button}};function On(e,t,n){return{componentName:e,actions:t,data:n}}function jn(){return jn=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},jn.apply(this,arguments)}function Nn(e,t,n){const{componentName:r,data:i}=n;$t(e.label,jn({componentType:e.componentType,action:t,loggingId:e.uuid,component_name:r},i))}const In={actionMapping:{onPress:f.click,onHover:f.hover},handlers:{Button:{[f.click]:e=>Nn(xn.Button,f.click,e),[f.hover]:e=>Nn(xn.Button,f.hover,e)}}};function Pn(e,t=!1){t?_t({url:A.tracesEndpoint,data:{traces:e},isJSON:!0,onError:A.onError}):yt((()=>{_t({url:A.tracesEndpoint,data:{traces:e},isJSON:!0,onError:A.onError})})),ut({metricName:"Batch Traces",data:e})}function Mn(){return Mn=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Mn.apply(this,arguments)}const Bn=1e6;function Cn(e){return e*Bn}function Dn(e=function(){var e;return null==(e=window)?void 0:e.crypto}()){const t=new Uint32Array(2);return null==e||e.getRandomValues(t),((BigInt(t[0])<<BigInt(32))+BigInt(t[1])).toString()}function An(e,t){return{"x-datadog-origin":"rum","x-datadog-parent-id":t,"x-datadog-sampling-priority":"1","x-datadog-trace-id":e}}function Ln(e){var t;const{name:n,traceId:r,spanId:i,start:a,duration:o,resource:s,meta:c}=e;return{duration:o?Cn(o):0,name:n,resource:s,service:A.projectName,span_id:null!=i?i:Dn(),start:a?Cn(a):0,trace_id:null!=r?r:Dn(),parent_id:P,type:M,meta:Mn({platform:A.platform},re.pageKey?{page_key:re.pageKey}:{},null!=(t=Se.ujs)&&t.length?{last_ujs:Se.ujs[Se.ujs.length-1]}:{},null!=c?c:{})}}function Un(e){return[Ln(e)]}function Rn(e,t){Oe()&&function(e){return e.length>0}(e)&&(t&&function(e,t){e.forEach((e=>function(e,t){const n=Mn({},e.meta,t.meta),r={start:t.start?Cn(t.start):e.start,duration:t.duration?Cn(t.duration):e.duration};Object.assign(e,t,Mn({meta:n},r))}(e,t)))}(e,t),je.tracesQueue.push(e),wt(Pn)&&(Pn(je.tracesQueue),je.tracesQueue=[]))}function qn(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:String(t)}function Fn(){return Fn=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Fn.apply(this,arguments)}function zn(){return void 0!==typeof window&&"performance"in window&&"mark"in performance&&"getEntriesByName"in performance}function Kn(e,t){return`perf_${e}${null!=t&&t.label?`_${t.label}`:""}`}function $n(e,t,n){return`${Kn(e,n)}__${t}`}let Qn={};function Wn(e,t,n){if(!zn())return;const r=$n(e,t,n);if(performance.mark(r),"end"===t){const t=Kn(e,n);!function(e,t,n){try{performance.measure(e,t,n)}catch(e){A.onError(e)}}(t,$n(e,"start",n),r);const i=performance.getEntriesByName(t).pop();i&&Ht(Fn({metricName:e,metricType:d.distribution,value:i.duration},null!=n&&n.tags?{tags:n.tags}:{}))}}function Hn(e,t){if(!zn())return;const n=$n(e,"start",t);Qn[n]||(Wn(e,"start",t),Qn[n]=!0)}function Vn(e,t){const n=$n(e,"start",t),r=function(e,t){if(null==e)return{};var n,r,i={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}(Qn,[n].map(qn));Qn=r}function Jn(e,t){if(!zn())return;const n=$n(e,"start",t);Qn[n]&&(Wn(e,"end",t),Vn(e,t))}function Xn(){zn()&&(performance.clearMarks(),Qn={})}var Gn=n(784);function Zn(){return Zn=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Zn.apply(this,arguments)}function Yn(e,t,n=l.low){const r=(0,Gn.useRef)(t);return(0,Gn.useEffect)((()=>{r.current=t}),[t]),(0,Gn.useCallback)((t=>{$t(e,Zn({},r.current,t),n)}),[e,n])}function er(){return er=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},er.apply(this,arguments)}function tr(e,t,n=l.low){(0,Gn.useEffect)((()=>{const r=er({},t,{action:f.render});$t(e,r,n)}),[])}function nr(){return nr=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},nr.apply(this,arguments)}const rr=function(e,t){return{markStartPerf:(0,Gn.useCallback)((()=>Hn(e,t)),[e,t]),markEndPerf:(0,Gn.useCallback)((n=>Jn(e,nr({},t,n))),[e,t])}};function ir(){return ir=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},ir.apply(this,arguments)}function ar(){return Object.entries(ir({},Se,zt(),{sessionUUID:oe.sessionUUID,userId:oe.userId})).reduce(((e,t)=>{return null!=(n=t[1])&&""!==n?ir({},e,{[t[0]]:t[1]}):e;var n}),{})}async function or(){return new Promise((e=>{Mt(vt(je.eventsQueue)),Qt(bt(je.metricsQueue),!0),Pn(je.tracesQueue,!0),Ne({eventsQueue:[],metricsQueue:[],tracesQueue:[]}),e()}))}function sr(){return{"X-CB-Device-ID":H.deviceId||"unknown","X-CB-Is-Logged-In":H.userId?"true":"false","X-CB-Pagekey":re.pageKey||"unknown","X-CB-UJS":(e=Se.ujs,void 0===e||0===e.length?"":e.join(",")),"X-CB-Platform":A.platform||"unknown","X-CB-Project-Name":A.projectName||"unknown","X-CB-Session-UUID":oe.sessionUUID||"unknown","X-CB-Version-Name":A.version?String(A.version):"unknown"};var e}})(),r})()}));',df=()=>new Promise((e,t)=>{if(window.ClientAnalytics)return e();try{const n=document.createElement("script");n.textContent=uf,n.type="text/javascript",document.head.appendChild(n),lf(),document.head.removeChild(n),e()}catch{console.error("Failed to execute inlined telemetry script"),t()}}),lf=()=>{var e,t,n;if(typeof window<"u"){const r=(n=(e=T.config.get().deviceId)!==null&&e!==void 0?e:(t=window.crypto)===null||t===void 0?void 0:t.randomUUID())!==null&&n!==void 0?n:"";if(window.ClientAnalytics){const{init:a,identify:s,PlatformName:i}=window.ClientAnalytics;a({isProd:!0,amplitudeApiKey:"c66737ad47ec354ced777935b0af822e",platform:i.web,projectName:"base_account_sdk",showDebugLogging:!1,version:"1.0.0",apiEndpoint:"https://cca-lite.coinbase.com"}),s({deviceId:r}),T.config.set({deviceId:r})}}},Q={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}},pr={"-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."}},fi="Unspecified error message.",ff="Unspecified server error.";function Ur(e,t=fi){if(e&&Number.isInteger(e)){const n=e.toString();if(mr(pr,n))return pr[n].message;if(pi(e))return ff}return t}function pf(e){if(!Number.isInteger(e))return!1;const t=e.toString();return!!(pr[t]||pi(e))}function mf(e,{shouldIncludeStack:t=!1}={}){const n={};if(e&&typeof e=="object"&&!Array.isArray(e)&&mr(e,"code")&&pf(e.code)){const r=e;n.code=r.code,r.message&&typeof r.message=="string"?(n.message=r.message,mr(r,"data")&&(n.data=r.data)):(n.message=Ur(n.code),n.data={originalError:Sa(e)})}else n.code=Q.rpc.internal,n.message=Aa(e,"message")?e.message:fi,n.data={originalError:Sa(e)};return t&&(n.stack=Aa(e,"stack")?e.stack:void 0),n}function pi(e){return e>=-32099&&e<=-32e3}function Sa(e){return e&&typeof e=="object"&&!Array.isArray(e)?Object.assign({},e):e}function mr(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Aa(e,t){return typeof e=="object"&&e!==null&&t in e&&typeof e[t]=="string"}const _={rpc:{parse:e=>fe(Q.rpc.parse,e),invalidRequest:e=>fe(Q.rpc.invalidRequest,e),invalidParams:e=>fe(Q.rpc.invalidParams,e),methodNotFound:e=>fe(Q.rpc.methodNotFound,e),internal:e=>fe(Q.rpc.internal,e),server:e=>{if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Ethereum RPC Server errors must provide single object argument.");const{code:t}=e;if(!Number.isInteger(t)||t>-32005||t<-32099)throw new Error('"code" must be an integer such that: -32099 <= code <= -32005');return fe(t,e)},invalidInput:e=>fe(Q.rpc.invalidInput,e),resourceNotFound:e=>fe(Q.rpc.resourceNotFound,e),resourceUnavailable:e=>fe(Q.rpc.resourceUnavailable,e),transactionRejected:e=>fe(Q.rpc.transactionRejected,e),methodNotSupported:e=>fe(Q.rpc.methodNotSupported,e),limitExceeded:e=>fe(Q.rpc.limitExceeded,e)},provider:{userRejectedRequest:e=>et(Q.provider.userRejectedRequest,e),unauthorized:e=>et(Q.provider.unauthorized,e),unsupportedMethod:e=>et(Q.provider.unsupportedMethod,e),disconnected:e=>et(Q.provider.disconnected,e),chainDisconnected:e=>et(Q.provider.chainDisconnected,e),unsupportedChain:e=>et(Q.provider.unsupportedChain,e),custom:e=>{if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Ethereum Provider custom errors must provide single object argument.");const{code:t,message:n,data:r}=e;if(!n||typeof n!="string")throw new Error('"message" must be a nonempty string');return new hi(t,n,r)}}};function fe(e,t){const[n,r]=mi(t);return new Fr(e,n||Ur(e),r)}function et(e,t){const[n,r]=mi(t);return new hi(e,n||Ur(e),r)}function mi(e){if(e){if(typeof e=="string")return[e];if(typeof e=="object"&&!Array.isArray(e)){const{message:t,data:n}=e;if(t&&typeof t!="string")throw new Error("Must specify string message.");return[t||void 0,n]}}return[]}class Fr extends Error{constructor(t,n,r){if(!Number.isInteger(t))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=t,r!==void 0&&(this.data=r)}}class hi extends Fr{constructor(t,n,r){if(!hf(t))throw new Error('"code" must be an integer such that: 1000 <= code <= 4999');super(t,n,r)}}function hf(e){return Number.isInteger(e)&&e>=1e3&&e<=4999}function _a(e){return typeof e=="object"&&e!==null&&"code"in e&&"data"in e&&e.code===-32090&&typeof e.data=="object"&&e.data!==null&&"type"in e.data&&e.data.type==="INSUFFICIENT_FUNDS"}function yi(e){return typeof e=="object"&&e!==null&&"details"in e}function yf(e){try{const t=JSON.parse(e.details);return new Fr(t.code,t.message,t.data)}catch{return null}}function gi(){return e=>e}const Tt=gi(),gf=gi();function Oe(e){return Math.floor(e)}const bi=/^[0-9]*$/,wi=/^[a-f0-9]*$/;function He(e){return $r(crypto.getRandomValues(new Uint8Array(e)))}function $r(e){return[...e].map(t=>t.toString(16).padStart(2,"0")).join("")}function Zt(e){return new Uint8Array(e.match(/.{1,2}/g).map(t=>Number.parseInt(t,16)))}function _t(e,t=!1){const n=e.toString("hex");return Tt(t?`0x${n}`:n)}function In(e){return _t(yr(e),!0)}function ve(e){return gf(e.toString(10))}function at(e){return Tt(`0x${BigInt(e).toString(16)}`)}function vi(e){return e.startsWith("0x")||e.startsWith("0X")}function Gr(e){return vi(e)?e.slice(2):e}function ki(e){return vi(e)?`0x${e.slice(2)}`:`0x${e}`}function kn(e){if(typeof e!="string")return!1;const t=Gr(e).toLowerCase();return wi.test(t)}function hr(e,t=!1){if(typeof e=="string"){const n=Gr(e).toLowerCase();if(wi.test(n))return Tt(t?`0x${n}`:n)}throw _.rpc.invalidParams(`"${String(e)}" is not a hexadecimal string`)}function Hr(e,t=!1){let n=hr(e,!1);return n.length%2===1&&(n=Tt(`0${n}`)),t?Tt(`0x${n}`):n}function Ne(e){if(typeof e=="string"){const t=Gr(e).toLowerCase();if(kn(t)&&t.length===40)return ki(t)}throw _.rpc.invalidParams(`Invalid Ethereum address: ${String(e)}`)}function yr(e){if(Buffer.isBuffer(e))return e;if(typeof e=="string"){if(kn(e)){const t=Hr(e,!1);return Buffer.from(t,"hex")}return Buffer.from(e,"utf8")}throw _.rpc.invalidParams(`Not binary data: ${String(e)}`)}function It(e){if(typeof e=="number"&&Number.isInteger(e))return Oe(e);if(typeof e=="string"){if(bi.test(e))return Oe(Number(e));if(kn(e))return Oe(Number(BigInt(Hr(e,!0))))}throw _.rpc.invalidParams(`Not an integer: ${String(e)}`)}function wt(e){if(e!==null&&(typeof e=="bigint"||wf(e)))return BigInt(e.toString(10));if(typeof e=="number")return BigInt(It(e));if(typeof e=="string"){if(bi.test(e))return BigInt(e);if(kn(e))return BigInt(Hr(e,!0))}throw _.rpc.invalidParams(`Not an integer: ${String(e)}`)}function bf(e){if(typeof e=="string")return JSON.parse(e);if(typeof e=="object")return e;throw _.rpc.invalidParams(`Not a JSON string or an object: ${String(e)}`)}function wf(e){if(e==null||typeof e.constructor!="function")return!1;const{constructor:t}=e;return typeof t.config=="function"&&typeof t.EUCLID=="number"}const vf=`Coinbase Wallet SDK requires the Cross-Origin-Opener-Policy header to not be set to 'same-origin'. This is to ensure that the SDK can communicate with the Coinbase Smart Wallet app.
|
|
|
|
Please see https://www.smartwallet.dev/guides/tips/popup-tips#cross-origin-opener-policy for more information.`,kf=()=>{let e;return{getCrossOriginOpenerPolicy:()=>e===void 0?"undefined":e,checkCrossOriginOpenerPolicy:async()=>{if(typeof window>"u"){e="non-browser-env";return}try{const t=`${window.location.origin}${window.location.pathname}`,n=await fetch(t,{method:"HEAD"});if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);const r=n.headers.get("Cross-Origin-Opener-Policy");e=r??"null",e==="same-origin"&&console.error(vf)}catch(t){console.error("Error checking Cross-Origin-Opener-Policy:",t.message),e="error"}}}},{checkCrossOriginOpenerPolicy:xf,getCrossOriginOpenerPolicy:Ef}=kf();async function Pt(e,t){const n=Object.assign(Object.assign({},e),{jsonrpc:"2.0",id:crypto.randomUUID()}),r=await window.fetch(t,{method:"POST",body:JSON.stringify(n),mode:"cors",headers:{"Content-Type":"application/json","X-Cbw-Sdk-Version":ht,"X-Cbw-Sdk-Platform":di}}),{result:a,error:s}=await r.json();if(s)throw s;return a}function Sf(){return globalThis.coinbaseWalletExtension}function Af(){var e,t;try{const n=globalThis;return(e=n.ethereum)!==null&&e!==void 0?e:(t=n.top)===null||t===void 0?void 0:t.ethereum}catch{return}}function _f({metadata:e,preference:t}){var n,r;const{appName:a,appLogoUrl:s,appChainIds:i}=e;if(t.options!=="smartWalletOnly"){const c=Sf();if(c)return(n=c.setAppInfo)===null||n===void 0||n.call(c,a,s,i,t),c}const o=Af();if(o?.isCoinbaseBrowser)return(r=o.setAppInfo)===null||r===void 0||r.call(o,a,s,i,t),o}function If(e){if(!e||typeof e!="object"||Array.isArray(e))throw _.rpc.invalidParams({message:"Expected a single, non-array, object argument.",data:e});const{method:t,params:n}=e;if(typeof t!="string"||t.length===0)throw _.rpc.invalidParams({message:"'args.method' must be a non-empty string.",data:e});if(n!==void 0&&!Array.isArray(n)&&(typeof n!="object"||n===null))throw _.rpc.invalidParams({message:"'args.params' must be an object or array if provided.",data:e});switch(t){case"eth_sign":case"eth_signTypedData_v2":case"eth_subscribe":case"eth_unsubscribe":throw _.provider.unsupportedMethod()}}function Pf(e){if(e){if(!["all","smartWalletOnly","eoaOnly"].includes(e.options))throw new Error(`Invalid options: ${e.options}`);if(e.attribution&&e.attribution.auto!==void 0&&e.attribution.dataSuffix!==void 0)throw new Error("Attribution cannot contain both auto and dataSuffix properties");if(e.telemetry&&typeof e.telemetry!="boolean")throw new Error("Telemetry must be a boolean")}}function Ia(e){if(typeof e!="function")throw new Error("toAccount is not a function")}const Of="https://keys.coinbase.com/connect",xi="https://rpc.wallet.coinbase.com",Pa="https://www.walletlink.org",Cf="https://go.cb-w.com/walletlink";var G;(function(e){e.unknown="unknown",e.banner="banner",e.button="button",e.card="card",e.chart="chart",e.content_script="content_script",e.dropdown="dropdown",e.link="link",e.page="page",e.modal="modal",e.table="table",e.search_bar="search_bar",e.service_worker="service_worker",e.text="text",e.text_input="text_input",e.tray="tray",e.checkbox="checkbox",e.icon="icon"})(G||(G={}));var H;(function(e){e.unknown="unknown",e.blur="blur",e.click="click",e.change="change",e.dismiss="dismiss",e.focus="focus",e.hover="hover",e.select="select",e.measurement="measurement",e.move="move",e.process="process",e.render="render",e.scroll="scroll",e.view="view",e.search="search",e.keyPress="keyPress",e.error="error"})(H||(H={}));var z;(function(e){e.low="low",e.high="high"})(z||(z={}));function V(e,t,n){var r,a,s,i;window.ClientAnalytics&&((r=window.ClientAnalytics)===null||r===void 0||r.logEvent(e,Object.assign(Object.assign({},t),{sdkVersion:ht,appName:(s=(a=T.config.get().metadata)===null||a===void 0?void 0:a.appName)!==null&&s!==void 0?s:"",appOrigin:window.location.origin,appPreferredSigner:(i=T.config.get().preference)===null||i===void 0?void 0:i.options}),n))}const Tf=()=>{V("communicator.popup_setup.started",{action:H.unknown,componentType:G.unknown},z.high)},Nf=()=>{V("communicator.popup_setup.completed",{action:H.unknown,componentType:G.unknown},z.high)},Bf=()=>{V("communicator.popup_unload.received",{action:H.unknown,componentType:G.unknown},z.high)},zr=({snackbarContext:e})=>{V(`snackbar.${e}.shown`,{action:H.render,componentType:G.modal,snackbarContext:e},z.high)},st=({snackbarContext:e,snackbarAction:t})=>{V(`snackbar.${e}.action_clicked`,{action:H.click,componentType:G.button,snackbarContext:e,snackbarAction:t},z.high)},Lf='@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 Ei(){const e=document.createElement("style");e.type="text/css",e.appendChild(document.createTextNode(Lf)),document.documentElement.appendChild(e)}function Si(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e))for(t=0;t<e.length;t++)e[t]&&(n=Si(e[t]))&&(r&&(r+=" "),r+=n);else for(t in e)e[t]&&(r&&(r+=" "),r+=t);return r}function Ot(){for(var e,t,n=0,r="";n<arguments.length;)(e=arguments[n++])&&(t=Si(e))&&(r&&(r+=" "),r+=t);return r}function Rf(){try{return window.frameElement!==null}catch{return!1}}function jf(){try{return Rf()&&window.top?window.top.location:window.location}catch{return window.location}}function Mf(){var e;return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test((e=window?.navigator)===null||e===void 0?void 0:e.userAgent)}function Ai(){var e,t;return(t=(e=window?.matchMedia)===null||e===void 0?void 0:e.call(window,"(prefers-color-scheme: dark)").matches)!==null&&t!==void 0?t:!1}const Df=".-cbwsdk-css-reset .-gear-container{margin-left:16px !important;margin-right:9px !important;display:flex;align-items:center;justify-content:center;width:24px;height:24px;transition:opacity .25s}.-cbwsdk-css-reset .-gear-container *{user-select:none}.-cbwsdk-css-reset .-gear-container svg{opacity:0;position:absolute}.-cbwsdk-css-reset .-gear-icon{height:12px;width:12px;z-index:10000}.-cbwsdk-css-reset .-cbwsdk-snackbar{align-items:flex-end;display:flex;flex-direction:column;position:fixed;right:0;top:0;z-index:2147483647}.-cbwsdk-css-reset .-cbwsdk-snackbar *{user-select:none}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance{display:flex;flex-direction:column;margin:8px 16px 0 16px;overflow:visible;text-align:left;transform:translateX(0);transition:opacity .25s,transform .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header:hover .-gear-container svg{opacity:1}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header{display:flex;align-items:center;background:#fff;overflow:hidden;border:1px solid #e7ebee;box-sizing:border-box;border-radius:8px;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header-cblogo{margin:8px 8px 8px 8px}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header *{cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header-message{color:#000;font-size:13px;line-height:1.5;user-select:none}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu{background:#fff;transition:opacity .25s ease-in-out,transform .25s linear,visibility 0s;visibility:hidden;border:1px solid #e7ebee;box-sizing:border-box;border-radius:8px;opacity:0;flex-direction:column;padding-left:8px;padding-right:8px}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:last-child{margin-bottom:8px !important}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover{background:#f5f7f8;border-radius:6px;transition:background .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover span{color:#050f19;transition:color .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover svg path{fill:#000;transition:fill .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item{visibility:inherit;height:35px;margin-top:8px;margin-bottom:0;display:flex;flex-direction:row;align-items:center;padding:8px;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item *{visibility:inherit;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover{background:rgba(223,95,103,.2);transition:background .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover *{cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover svg path{fill:#df5f67;transition:fill .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover span{color:#df5f67;transition:color .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-info{color:#aaa;font-size:13px;margin:0 8px 0 32px;position:absolute}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-hidden{opacity:0;text-align:left;transform:translateX(25%);transition:opacity .5s linear}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-expanded .-cbwsdk-snackbar-instance-menu{opacity:1;display:flex;transform:translateY(8px);visibility:visible}",Uf="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEuNDkyIDEwLjQxOWE4LjkzIDguOTMgMCAwMTguOTMtOC45M2gxMS4xNjNhOC45MyA4LjkzIDAgMDE4LjkzIDguOTN2MTEuMTYzYTguOTMgOC45MyAwIDAxLTguOTMgOC45M0gxMC40MjJhOC45MyA4LjkzIDAgMDEtOC45My04LjkzVjEwLjQxOXoiIGZpbGw9IiMxNjUyRjAiLz48cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTEwLjQxOSAwSDIxLjU4QzI3LjMzNSAwIDMyIDQuNjY1IDMyIDEwLjQxOVYyMS41OEMzMiAyNy4zMzUgMjcuMzM1IDMyIDIxLjU4MSAzMkgxMC40MkM0LjY2NSAzMiAwIDI3LjMzNSAwIDIxLjU4MVYxMC40MkMwIDQuNjY1IDQuNjY1IDAgMTAuNDE5IDB6bTAgMS40ODhhOC45MyA4LjkzIDAgMDAtOC45MyA4LjkzdjExLjE2M2E4LjkzIDguOTMgMCAwMDguOTMgOC45M0gyMS41OGE4LjkzIDguOTMgMCAwMDguOTMtOC45M1YxMC40MmE4LjkzIDguOTMgMCAwMC04LjkzLTguOTNIMTAuNDJ6IiBmaWxsPSIjZmZmIi8+PHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xNS45OTggMjYuMDQ5Yy01LjU0OSAwLTEwLjA0Ny00LjQ5OC0xMC4wNDctMTAuMDQ3IDAtNS41NDggNC40OTgtMTAuMDQ2IDEwLjA0Ny0xMC4wNDYgNS41NDggMCAxMC4wNDYgNC40OTggMTAuMDQ2IDEwLjA0NiAwIDUuNTQ5LTQuNDk4IDEwLjA0Ny0xMC4wNDYgMTAuMDQ3eiIgZmlsbD0iI2ZmZiIvPjxwYXRoIGQ9Ik0xMi43NjIgMTQuMjU0YzAtLjgyMi42NjctMS40ODkgMS40ODktMS40ODloMy40OTdjLjgyMiAwIDEuNDg4LjY2NiAxLjQ4OCAxLjQ4OXYzLjQ5N2MwIC44MjItLjY2NiAxLjQ4OC0xLjQ4OCAxLjQ4OGgtMy40OTdhMS40ODggMS40ODggMCAwMS0xLjQ4OS0xLjQ4OHYtMy40OTh6IiBmaWxsPSIjMTY1MkYwIi8+PC9zdmc+",Ff="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIiIGhlaWdodD0iMTIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDYuNzV2LTEuNWwtMS43Mi0uNTdjLS4wOC0uMjctLjE5LS41Mi0uMzItLjc3bC44MS0xLjYyLTEuMDYtMS4wNi0xLjYyLjgxYy0uMjQtLjEzLS41LS4yNC0uNzctLjMyTDYuNzUgMGgtMS41bC0uNTcgMS43MmMtLjI3LjA4LS41My4xOS0uNzcuMzJsLTEuNjItLjgxLTEuMDYgMS4wNi44MSAxLjYyYy0uMTMuMjQtLjI0LjUtLjMyLjc3TDAgNS4yNXYxLjVsMS43Mi41N2MuMDguMjcuMTkuNTMuMzIuNzdsLS44MSAxLjYyIDEuMDYgMS4wNiAxLjYyLS44MWMuMjQuMTMuNS4yMy43Ny4zMkw1LjI1IDEyaDEuNWwuNTctMS43MmMuMjctLjA4LjUyLS4xOS43Ny0uMzJsMS42Mi44MSAxLjA2LTEuMDYtLjgxLTEuNjJjLjEzLS4yNC4yMy0uNS4zMi0uNzdMMTIgNi43NXpNNiA4LjVhMi41IDIuNSAwIDAxMC01IDIuNSAyLjUgMCAwMTAgNXoiIGZpbGw9IiMwNTBGMTkiLz48L3N2Zz4=";class _i{constructor(){this.items=new Map,this.nextItemKey=0,this.root=null,this.darkMode=Ai()}attach(t){this.root=document.createElement("div"),this.root.className="-cbwsdk-snackbar-root",t.appendChild(this.root),this.render()}presentItem(t){const n=this.nextItemKey++;return this.items.set(n,t),this.render(),()=>{this.items.delete(n),this.render()}}clear(){this.items.clear(),this.render()}render(){this.root&&Nn(J("div",null,J(Ii,{darkMode:this.darkMode},Array.from(this.items.entries()).map(([t,n])=>J($f,Object.assign({},n,{key:t}))))),this.root)}}const Ii=e=>J("div",{class:Ot("-cbwsdk-snackbar-container")},J("style",null,Df),J("div",{class:"-cbwsdk-snackbar"},e.children)),$f=({autoExpand:e,message:t,menuItems:n})=>{const[r,a]=Zr(!0),[s,i]=Zr(e??!1);jo(()=>{const c=[window.setTimeout(()=>{a(!1)},1),window.setTimeout(()=>{i(!0)},1e4)];return()=>{c.forEach(window.clearTimeout)}});const o=()=>{i(!s)};return J("div",{class:Ot("-cbwsdk-snackbar-instance",r&&"-cbwsdk-snackbar-instance-hidden",s&&"-cbwsdk-snackbar-instance-expanded")},J("div",{class:"-cbwsdk-snackbar-instance-header",onClick:o},J("img",{src:Uf,class:"-cbwsdk-snackbar-instance-header-cblogo"})," ",J("div",{class:"-cbwsdk-snackbar-instance-header-message"},t),J("div",{class:"-gear-container"},!s&&J("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},J("circle",{cx:"12",cy:"12",r:"12",fill:"#F5F7F8"})),J("img",{src:Ff,class:"-gear-icon",title:"Expand"}))),n&&n.length>0&&J("div",{class:"-cbwsdk-snackbar-instance-menu"},n.map((c,u)=>J("div",{class:Ot("-cbwsdk-snackbar-instance-menu-item",c.isRed&&"-cbwsdk-snackbar-instance-menu-item-is-red"),onClick:c.onClick,key:u},J("svg",{width:c.svgWidth,height:c.svgHeight,viewBox:"0 0 10 11",fill:"none",xmlns:"http://www.w3.org/2000/svg"},J("path",{"fill-rule":c.defaultFillRule,"clip-rule":c.defaultClipRule,d:c.path,fill:"#AAAAAA"})),J("span",{class:Ot("-cbwsdk-snackbar-instance-menu-item-info",c.isRed&&"-cbwsdk-snackbar-instance-menu-item-info-is-red")},c.info)))))},Pi="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 Gf{constructor(){this.attached=!1,this.snackbar=new _i}attach(){if(this.attached)throw new Error("Coinbase Wallet SDK UI is already attached");const t=document.documentElement,n=document.createElement("div");n.className="-cbwsdk-css-reset",t.appendChild(n),this.snackbar.attach(n),this.attached=!0,Ei()}showConnecting(t){let n;return t.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:t.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:t.onCancel},{isRed:!1,info:"Reset connection",svgWidth:"10",svgHeight:"11",path:Pi,defaultFillRule:"evenodd",defaultClipRule:"evenodd",onClick:t.onResetConnection}]},this.snackbar.presentItem(n)}}const Oa=420,Ca=700,Hf={isRed:!1,info:"Retry",svgWidth:"10",svgHeight:"11",path:Pi,defaultFillRule:"evenodd",defaultClipRule:"evenodd"},zf="Popup was blocked. Try again.";let $t=null;function qf(e){const t=(window.innerWidth-Oa)/2+window.screenX,n=(window.innerHeight-Ca)/2+window.screenY;Vf(e);function r(){const s=`wallet_${crypto.randomUUID()}`,i=window.open(e,s,`width=${Oa}, height=${Ca}, left=${t}, top=${n}`);return i?.focus(),i||null}let a=r();if(!a){const s=qr();return new Promise((i,o)=>{zr({snackbarContext:"popup_blocked"}),s.presentItem({autoExpand:!0,message:zf,menuItems:[Object.assign(Object.assign({},Hf),{onClick:()=>{st({snackbarContext:"popup_blocked",snackbarAction:"confirm"}),a=r(),a?i(a):o(_.rpc.internal("Popup window was blocked")),s.clear()}})]})})}return Promise.resolve(a)}function Wf(e){e&&!e.closed&&e.close()}function Vf(e){const t={sdkName:di,sdkVersion:ht,origin:window.location.origin,coop:Ef()};for(const[n,r]of Object.entries(t))e.searchParams.has(n)||e.searchParams.append(n,r.toString())}function qr(){if(!$t){const e=document.createElement("div");e.className="-cbwsdk-css-reset",document.body.appendChild(e),$t=new _i,$t.attach(e)}return $t}class Kf{constructor({url:t=Of,metadata:n,preference:r}){this.popup=null,this.listeners=new Map,this.postMessage=async a=>{(await this.waitForPopupLoaded()).postMessage(a,this.url.origin)},this.postRequestAndWaitForResponse=async a=>{const s=this.onMessage(({requestId:i})=>i===a.id);return this.postMessage(a),await s},this.onMessage=async a=>new Promise((s,i)=>{const o=c=>{if(c.origin!==this.url.origin)return;const u=c.data;a(u)&&(s(u),window.removeEventListener("message",o),this.listeners.delete(o))};window.addEventListener("message",o),this.listeners.set(o,{reject:i})}),this.disconnect=()=>{Wf(this.popup),this.popup=null,this.listeners.forEach(({reject:a},s)=>{a(_.provider.userRejectedRequest("Request rejected")),window.removeEventListener("message",s)}),this.listeners.clear()},this.waitForPopupLoaded=async()=>this.popup&&!this.popup.closed?(this.popup.focus(),this.popup):(Tf(),this.popup=await qf(this.url),this.onMessage(({event:a})=>a==="PopupUnload").then(()=>{this.disconnect(),Bf()}).catch(()=>{}),this.onMessage(({event:a})=>a==="PopupLoaded").then(a=>{this.postMessage({requestId:a.id,data:{version:ht,metadata:this.metadata,preference:this.preference,location:window.location.toString()}})}).then(()=>{if(!this.popup)throw _.rpc.internal();return Nf(),this.popup})),this.url=new URL(t),this.metadata=n,this.preference=r}}function ae(e){return e.errorMessage!==void 0}function Jf(e){const t=mf(Zf(e),{shouldIncludeStack:!0}),n=new URL("https://docs.cloud.coinbase.com/wallet-sdk/docs/errors");return n.searchParams.set("version",ht),n.searchParams.set("code",t.code.toString()),n.searchParams.set("message",t.message),Object.assign(Object.assign({},t),{docUrl:n.href})}function Zf(e){var t;if(typeof e=="string")return{message:e,code:Q.rpc.internal};if(ae(e)){const n=e.errorMessage,r=(t=e.errorCode)!==null&&t!==void 0?t:n.match(/(denied|rejected)/i)?Q.provider.userRejectedRequest:void 0;return Object.assign(Object.assign({},e),{message:n,code:r,data:{method:e.method}})}return e}var Oi={exports:{}};(function(e){var t=Object.prototype.hasOwnProperty,n="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1));function a(c,u,d){this.fn=c,this.context=u,this.once=d||!1}function s(c,u,d,l,p){if(typeof d!="function")throw new TypeError("The listener must be a function");var f=new a(d,l||c,p),y=n?n+u:u;return c._events[y]?c._events[y].fn?c._events[y]=[c._events[y],f]:c._events[y].push(f):(c._events[y]=f,c._eventsCount++),c}function i(c,u){--c._eventsCount===0?c._events=new r:delete c._events[u]}function o(){this._events=new r,this._eventsCount=0}o.prototype.eventNames=function(){var u=[],d,l;if(this._eventsCount===0)return u;for(l in d=this._events)t.call(d,l)&&u.push(n?l.slice(1):l);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(d)):u},o.prototype.listeners=function(u){var d=n?n+u:u,l=this._events[d];if(!l)return[];if(l.fn)return[l.fn];for(var p=0,f=l.length,y=new Array(f);p<f;p++)y[p]=l[p].fn;return y},o.prototype.listenerCount=function(u){var d=n?n+u:u,l=this._events[d];return l?l.fn?1:l.length:0},o.prototype.emit=function(u,d,l,p,f,y){var g=n?n+u:u;if(!this._events[g])return!1;var h=this._events[g],w=arguments.length,E,b;if(h.fn){switch(h.once&&this.removeListener(u,h.fn,void 0,!0),w){case 1:return h.fn.call(h.context),!0;case 2:return h.fn.call(h.context,d),!0;case 3:return h.fn.call(h.context,d,l),!0;case 4:return h.fn.call(h.context,d,l,p),!0;case 5:return h.fn.call(h.context,d,l,p,f),!0;case 6:return h.fn.call(h.context,d,l,p,f,y),!0}for(b=1,E=new Array(w-1);b<w;b++)E[b-1]=arguments[b];h.fn.apply(h.context,E)}else{var A=h.length,I;for(b=0;b<A;b++)switch(h[b].once&&this.removeListener(u,h[b].fn,void 0,!0),w){case 1:h[b].fn.call(h[b].context);break;case 2:h[b].fn.call(h[b].context,d);break;case 3:h[b].fn.call(h[b].context,d,l);break;case 4:h[b].fn.call(h[b].context,d,l,p);break;default:if(!E)for(I=1,E=new Array(w-1);I<w;I++)E[I-1]=arguments[I];h[b].fn.apply(h[b].context,E)}}return!0},o.prototype.on=function(u,d,l){return s(this,u,d,l,!1)},o.prototype.once=function(u,d,l){return s(this,u,d,l,!0)},o.prototype.removeListener=function(u,d,l,p){var f=n?n+u:u;if(!this._events[f])return this;if(!d)return i(this,f),this;var y=this._events[f];if(y.fn)y.fn===d&&(!p||y.once)&&(!l||y.context===l)&&i(this,f);else{for(var g=0,h=[],w=y.length;g<w;g++)(y[g].fn!==d||p&&!y[g].once||l&&y[g].context!==l)&&h.push(y[g]);h.length?this._events[f]=h.length===1?h[0]:h:i(this,f)}return this},o.prototype.removeAllListeners=function(u){var d;return u?(d=n?n+u:u,this._events[d]&&i(this,d)):(this._events=new r,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=n,o.EventEmitter=o,e.exports=o})(Oi);var Yf=Oi.exports;const Qf=Es(Yf);class Xf extends Qf{}class Ze{constructor(t,n){this.scope=t,this.module=n}storeObject(t,n){this.setItem(t,JSON.stringify(n))}loadObject(t){const n=this.getItem(t);return n?JSON.parse(n):void 0}setItem(t,n){localStorage.setItem(this.scopedKey(t),n)}getItem(t){return localStorage.getItem(this.scopedKey(t))}removeItem(t){localStorage.removeItem(this.scopedKey(t))}clear(){const t=this.scopedKey(""),n=[];for(let r=0;r<localStorage.length;r++){const a=localStorage.key(r);typeof a=="string"&&a.startsWith(t)&&n.push(a)}n.forEach(r=>localStorage.removeItem(r))}scopedKey(t){return`-${this.scope}${this.module?`:${this.module}`:""}:${t}`}static clearAll(){new Ze("CBWSDK").clear(),new Ze("walletlink").clear()}}const ep=({signerType:e})=>{V("provider.signer.loaded_from_storage",{action:H.measurement,componentType:G.unknown,signerType:e},z.low)},tp=({method:e,correlationId:t})=>{V("provider.request.started",{action:H.unknown,componentType:G.unknown,method:e,correlationId:t},z.high)},np=({method:e,correlationId:t,signerType:n,errorMessage:r})=>{V("provider.request.error",{action:H.error,componentType:G.unknown,method:e,signerType:n,correlationId:t,errorMessage:r},z.high)},rp=({method:e,signerType:t,correlationId:n})=>{V("provider.request.responded",{action:H.unknown,componentType:G.unknown,method:e,signerType:t,correlationId:n},z.high)},ap=()=>{V("provider.enable_function.called",{action:H.measurement,componentType:G.unknown},z.high)},sp=()=>{V("signer.selection.requested",{action:H.unknown,componentType:G.unknown},z.high)},ip=e=>{V("signer.selection.responded",{action:H.unknown,componentType:G.unknown,signerType:e},z.high)},Gt=Br(()=>({correlationIds:new Map})),ge={get:e=>Gt.getState().correlationIds.get(e),set:(e,t)=>{Gt.setState(n=>{const r=new Map(n.correlationIds);return r.set(e,t),{correlationIds:r}})},delete:e=>{Gt.setState(t=>{const n=new Map(t.correlationIds);return n.delete(e),{correlationIds:n}})},clear:()=>{Gt.setState({correlationIds:new Map})}},op=({method:e,correlationId:t})=>{var n;V("scw_signer.handshake.started",{action:H.unknown,componentType:G.unknown,method:e,correlationId:t,enableAutoSubAccounts:(n=T.subAccountsConfig.get())===null||n===void 0?void 0:n.enableAutoSubAccounts},z.high)},cp=({method:e,correlationId:t,errorMessage:n})=>{var r;V("scw_signer.handshake.error",{action:H.error,componentType:G.unknown,method:e,correlationId:t,errorMessage:n,enableAutoSubAccounts:(r=T.subAccountsConfig.get())===null||r===void 0?void 0:r.enableAutoSubAccounts},z.high)},up=({method:e,correlationId:t})=>{var n;V("scw_signer.handshake.completed",{action:H.unknown,componentType:G.unknown,method:e,correlationId:t,enableAutoSubAccounts:(n=T.subAccountsConfig.get())===null||n===void 0?void 0:n.enableAutoSubAccounts},z.high)},dp=({method:e,correlationId:t})=>{var n;V("scw_signer.request.started",{action:H.unknown,componentType:G.unknown,method:e,correlationId:t,enableAutoSubAccounts:(n=T.subAccountsConfig.get())===null||n===void 0?void 0:n.enableAutoSubAccounts},z.high)},lp=({method:e,correlationId:t,errorMessage:n})=>{var r;V("scw_signer.request.error",{action:H.error,componentType:G.unknown,method:e,correlationId:t,errorMessage:n,enableAutoSubAccounts:(r=T.subAccountsConfig.get())===null||r===void 0?void 0:r.enableAutoSubAccounts},z.high)},fp=({method:e,correlationId:t})=>{var n;V("scw_signer.request.completed",{action:H.unknown,componentType:G.unknown,method:e,correlationId:t,enableAutoSubAccounts:(n=T.subAccountsConfig.get())===null||n===void 0?void 0:n.enableAutoSubAccounts},z.high)},pp=({method:e,correlationId:t})=>{var n;V("scw_sub_account.request.started",{action:H.unknown,componentType:G.unknown,method:e,correlationId:t,enableAutoSubAccounts:(n=T.subAccountsConfig.get())===null||n===void 0?void 0:n.enableAutoSubAccounts},z.high)},mp=({method:e,correlationId:t})=>{var n;V("scw_sub_account.request.completed",{action:H.unknown,componentType:G.unknown,method:e,correlationId:t,enableAutoSubAccounts:(n=T.subAccountsConfig.get())===null||n===void 0?void 0:n.enableAutoSubAccounts},z.high)},hp=({method:e,correlationId:t,errorMessage:n})=>{var r;V("scw_sub_account.request.error",{action:H.error,componentType:G.unknown,method:e,correlationId:t,errorMessage:n,enableAutoSubAccounts:(r=T.subAccountsConfig.get())===null||r===void 0?void 0:r.enableAutoSubAccounts},z.high)},yp=({method:e,correlationId:t})=>{var n;V("scw_sub_account.add_owner.started",{action:H.unknown,componentType:G.unknown,method:e,correlationId:t,enableAutoSubAccounts:(n=T.subAccountsConfig.get())===null||n===void 0?void 0:n.enableAutoSubAccounts},z.high)},gp=({method:e,correlationId:t})=>{var n;V("scw_sub_account.add_owner.completed",{action:H.unknown,componentType:G.unknown,method:e,correlationId:t,enableAutoSubAccounts:(n=T.subAccountsConfig.get())===null||n===void 0?void 0:n.enableAutoSubAccounts},z.high)},bp=({method:e,correlationId:t,errorMessage:n})=>{var r;V("scw_sub_account.add_owner.error",{action:H.error,componentType:G.unknown,method:e,correlationId:t,errorMessage:n,enableAutoSubAccounts:(r=T.subAccountsConfig.get())===null||r===void 0?void 0:r.enableAutoSubAccounts},z.high)},wp=({method:e,correlationId:t})=>{var n;V("scw_sub_account.insufficient_balance.error_handling.started",{action:H.unknown,componentType:G.unknown,method:e,correlationId:t,enableAutoSubAccounts:(n=T.subAccountsConfig.get())===null||n===void 0?void 0:n.enableAutoSubAccounts},z.high)},vp=({method:e,correlationId:t})=>{var n;V("scw_sub_account.insufficient_balance.error_handling.completed",{action:H.unknown,componentType:G.unknown,method:e,correlationId:t,enableAutoSubAccounts:(n=T.subAccountsConfig.get())===null||n===void 0?void 0:n.enableAutoSubAccounts},z.high)},kp=({method:e,correlationId:t,errorMessage:n})=>{var r;V("scw_sub_account.insufficient_balance.error_handling.error",{action:H.error,componentType:G.unknown,method:e,correlationId:t,errorMessage:n,enableAutoSubAccounts:(r=T.subAccountsConfig.get())===null||r===void 0?void 0:r.enableAutoSubAccounts},z.high)},ze=e=>"message"in e&&typeof e.message=="string"?e.message:"",Ci=Br(()=>({}));function Ta(e){e.forEach(t=>{var n,r,a,s,i,o,c,u;if(!t.rpcUrl)return;const d=Yc({id:t.id,rpcUrls:{default:{http:[t.rpcUrl]}},name:(r=(n=t.nativeCurrency)===null||n===void 0?void 0:n.name)!==null&&r!==void 0?r:"",nativeCurrency:{name:(s=(a=t.nativeCurrency)===null||a===void 0?void 0:a.name)!==null&&s!==void 0?s:"",symbol:(o=(i=t.nativeCurrency)===null||i===void 0?void 0:i.symbol)!==null&&o!==void 0?o:"",decimals:(u=(c=t.nativeCurrency)===null||c===void 0?void 0:c.decimal)!==null&&u!==void 0?u:18}}),l=hd({chain:d,transport:ia(t.rpcUrl)}),p=zd({client:l,transport:ia(t.rpcUrl)});Ci.setState({[t.id]:{client:l,bundlerClient:p}})})}function Ti(e){var t;return(t=Ci.getState()[e])===null||t===void 0?void 0:t.client}function le(e,t,n){if(e==null)throw t??_.rpc.invalidParams({message:"value must be present",data:e})}function Re(e,t){if(!Array.isArray(e))throw _.rpc.invalidParams({message:t??"value must be an array",data:e})}function Ht(e){if(typeof e!="object"||e===null)throw _.rpc.internal("sub account info is not an object");if(!("address"in e))throw _.rpc.internal("sub account is invalid");if("address"in e&&typeof e.address=="string"&&!ct(e.address))throw _.rpc.internal("sub account address is invalid");if("factory"in e&&typeof e.factory=="string"&&!ct(e.factory))throw _.rpc.internal("sub account factory address is invalid");if("factoryData"in e&&typeof e.factoryData=="string"&&!Ge(e.factoryData))throw _.rpc.internal("sub account factory data is invalid")}async function xp(){return crypto.subtle.generateKey({name:"ECDH",namedCurve:"P-256"},!0,["deriveKey"])}async function Ep(e,t){return crypto.subtle.deriveKey({name:"ECDH",public:t},e,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"])}async function Sp(e,t){const n=crypto.getRandomValues(new Uint8Array(12)),r=await crypto.subtle.encrypt({name:"AES-GCM",iv:n},e,new TextEncoder().encode(t));return{iv:n,cipherText:r}}async function Ap(e,{iv:t,cipherText:n}){const r=await crypto.subtle.decrypt({name:"AES-GCM",iv:t},e,n);return new TextDecoder().decode(r)}function Ni(e){switch(e){case"public":return"spki";case"private":return"pkcs8"}}async function Bi(e,t){const n=Ni(e),r=await crypto.subtle.exportKey(n,t);return $r(new Uint8Array(r))}async function Li(e,t){const n=Ni(e),r=Zt(t).buffer;return await crypto.subtle.importKey(n,new Uint8Array(r),{name:"ECDH",namedCurve:"P-256"},!0,e==="private"?["deriveKey"]:[])}async function _p(e,t){const n=JSON.stringify(e,(r,a)=>{if(!(a instanceof Error))return a;const s=a;return Object.assign(Object.assign({},s.code?{code:s.code}:{}),{message:s.message})});return Sp(t,n)}async function Ip(e,t){return JSON.parse(await Ap(t,e))}function Pp(e,t){const n=typeof indexedDB<"u"?Qc(e,t):void 0;return{getItem:async r=>{const a=await Xc(r,n);return a||null},removeItem:async r=>eu(r,n),setItem:async(r,a)=>tu(r,a,n)}}const Op="cbwsdk",Cp="keys",Wr="activeId",mt=Pp(Op,Cp);async function Tp(){const e=await Wl({extractable:!1}),t=me(jr(e.publicKey),1);return await mt.setItem(t,e),await mt.setItem(Wr,t),e}async function Np(){const e=await mt.getItem(Wr);if(!e)return null;const t=await mt.getItem(e);return t||null}async function Bp(){const e=await Np();if(!e){const t=await Tp(),n=me(jr(t.publicKey),1);return await mt.setItem(n,t),await mt.setItem(Wr,n),t}return e}async function Lp(){const e=await Bp(),t=me(jr(e.publicKey),1),n=async r=>{const{payload:a,metadata:s}=ql({challenge:r,origin:"https://keys.coinbase.com",userVerification:"preferred"}),i=await Vl({payload:a,privateKey:e.privateKey});return{signature:wl(i),raw:{},webauthn:s}};return{id:t,publicKey:t,async sign({hash:r}){return n(r)},async signMessage({message:r}){return n(Pr(r))},async signTypedData(r){return n(Lt(r))},type:"webAuthn"}}async function gr(){return{account:await Lp()}}const Na={storageKey:"ownPrivateKey",keyType:"private"},Ba={storageKey:"ownPublicKey",keyType:"public"},La={storageKey:"peerPublicKey",keyType:"public"};class Rp{constructor(){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(t){this.sharedSecret=null,this.peerPublicKey=t,await this.storeKey(La,t),await this.loadKeysIfNeeded()}async clear(){this.ownPrivateKey=null,this.ownPublicKey=null,this.peerPublicKey=null,this.sharedSecret=null,T.keys.clear()}async generateKeyPair(){const t=await xp();this.ownPrivateKey=t.privateKey,this.ownPublicKey=t.publicKey,await this.storeKey(Na,t.privateKey),await this.storeKey(Ba,t.publicKey)}async loadKeysIfNeeded(){if(this.ownPrivateKey===null&&(this.ownPrivateKey=await this.loadKey(Na)),this.ownPublicKey===null&&(this.ownPublicKey=await this.loadKey(Ba)),(this.ownPrivateKey===null||this.ownPublicKey===null)&&await this.generateKeyPair(),this.peerPublicKey===null&&(this.peerPublicKey=await this.loadKey(La)),this.sharedSecret===null){if(this.ownPrivateKey===null||this.peerPublicKey===null)return;this.sharedSecret=await Ep(this.ownPrivateKey,this.peerPublicKey)}}async loadKey(t){const n=T.keys.get(t.storageKey);return n?Li(t.keyType,n):null}async storeKey(t,n){const r=await Bi(t.keyType,n);T.keys.set(t.storageKey,r)}}function Et(e,t){if(!(typeof e!="object"||e===null))return t.split(/[.[\]]+/).filter(Boolean).reduce((n,r)=>{if(typeof n=="object"&&n!==null)return n[r]},e)}const Ri="0x0ba5ed0c6aa8c49038f819e587e2633c4a9f428a",ji="0xf85210B21cC50302F477BA56686d2019dC9b67Ad",be=[{inputs:[],stateMutability:"nonpayable",type:"constructor"},{inputs:[{name:"owner",type:"bytes"}],name:"AlreadyOwner",type:"error"},{inputs:[],name:"Initialized",type:"error"},{inputs:[{name:"owner",type:"bytes"}],name:"InvalidEthereumAddressOwner",type:"error"},{inputs:[{name:"key",type:"uint256"}],name:"InvalidNonceKey",type:"error"},{inputs:[{name:"owner",type:"bytes"}],name:"InvalidOwnerBytesLength",type:"error"},{inputs:[],name:"LastOwner",type:"error"},{inputs:[{name:"index",type:"uint256"}],name:"NoOwnerAtIndex",type:"error"},{inputs:[{name:"ownersRemaining",type:"uint256"}],name:"NotLastOwner",type:"error"},{inputs:[{name:"selector",type:"bytes4"}],name:"SelectorNotAllowed",type:"error"},{inputs:[],name:"Unauthorized",type:"error"},{inputs:[],name:"UnauthorizedCallContext",type:"error"},{inputs:[],name:"UpgradeFailed",type:"error"},{inputs:[{name:"index",type:"uint256"},{name:"expectedOwner",type:"bytes"},{name:"actualOwner",type:"bytes"}],name:"WrongOwnerAtIndex",type:"error"},{anonymous:!1,inputs:[{indexed:!0,name:"index",type:"uint256"},{indexed:!1,name:"owner",type:"bytes"}],name:"AddOwner",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"index",type:"uint256"},{indexed:!1,name:"owner",type:"bytes"}],name:"RemoveOwner",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"implementation",type:"address"}],name:"Upgraded",type:"event"},{stateMutability:"payable",type:"fallback"},{inputs:[],name:"REPLAYABLE_NONCE_KEY",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"owner",type:"address"}],name:"addOwnerAddress",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"x",type:"bytes32"},{name:"y",type:"bytes32"}],name:"addOwnerPublicKey",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"functionSelector",type:"bytes4"}],name:"canSkipChainIdValidation",outputs:[{name:"",type:"bool"}],stateMutability:"pure",type:"function"},{inputs:[],name:"domainSeparator",outputs:[{name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"eip712Domain",outputs:[{name:"fields",type:"bytes1"},{name:"name",type:"string"},{name:"version",type:"string"},{name:"chainId",type:"uint256"},{name:"verifyingContract",type:"address"},{name:"salt",type:"bytes32"},{name:"extensions",type:"uint256[]"}],stateMutability:"view",type:"function"},{inputs:[],name:"entryPoint",outputs:[{name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{name:"target",type:"address"},{name:"value",type:"uint256"},{name:"data",type:"bytes"}],name:"execute",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{components:[{name:"target",type:"address"},{name:"value",type:"uint256"},{name:"data",type:"bytes"}],name:"calls",type:"tuple[]"}],name:"executeBatch",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{name:"calls",type:"bytes[]"}],name:"executeWithoutChainIdValidation",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"initCode",type:"bytes"},{name:"callData",type:"bytes"},{name:"callGasLimit",type:"uint256"},{name:"verificationGasLimit",type:"uint256"},{name:"preVerificationGas",type:"uint256"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"},{name:"paymasterAndData",type:"bytes"},{name:"signature",type:"bytes"}],name:"userOp",type:"tuple"}],name:"getUserOpHashWithoutChainId",outputs:[{name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"implementation",outputs:[{name:"$",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{name:"owners",type:"bytes[]"}],name:"initialize",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{name:"account",type:"address"}],name:"isOwnerAddress",outputs:[{name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{name:"account",type:"bytes"}],name:"isOwnerBytes",outputs:[{name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{name:"x",type:"bytes32"},{name:"y",type:"bytes32"}],name:"isOwnerPublicKey",outputs:[{name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{name:"hash",type:"bytes32"},{name:"signature",type:"bytes"}],name:"isValidSignature",outputs:[{name:"result",type:"bytes4"}],stateMutability:"view",type:"function"},{inputs:[],name:"nextOwnerIndex",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"index",type:"uint256"}],name:"ownerAtIndex",outputs:[{name:"",type:"bytes"}],stateMutability:"view",type:"function"},{inputs:[],name:"ownerCount",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"proxiableUUID",outputs:[{name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{name:"index",type:"uint256"},{name:"owner",type:"bytes"}],name:"removeLastOwner",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"index",type:"uint256"},{name:"owner",type:"bytes"}],name:"removeOwnerAtIndex",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"removedOwnersCount",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"hash",type:"bytes32"}],name:"replaySafeHash",outputs:[{name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{name:"newImplementation",type:"address"},{name:"data",type:"bytes"}],name:"upgradeToAndCall",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"initCode",type:"bytes"},{name:"callData",type:"bytes"},{name:"callGasLimit",type:"uint256"},{name:"verificationGasLimit",type:"uint256"},{name:"preVerificationGas",type:"uint256"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"},{name:"paymasterAndData",type:"bytes"},{name:"signature",type:"bytes"}],name:"userOp",type:"tuple"},{name:"userOpHash",type:"bytes32"},{name:"missingAccountFunds",type:"uint256"}],name:"validateUserOp",outputs:[{name:"validationData",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{stateMutability:"payable",type:"receive"}],Mi=[{inputs:[{name:"implementation_",type:"address"}],stateMutability:"payable",type:"constructor"},{inputs:[],name:"OwnerRequired",type:"error"},{inputs:[{name:"owners",type:"bytes[]"},{name:"nonce",type:"uint256"}],name:"createAccount",outputs:[{name:"account",type:"address"}],stateMutability:"payable",type:"function"},{inputs:[{name:"owners",type:"bytes[]"},{name:"nonce",type:"uint256"}],name:"getAddress",outputs:[{name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"implementation",outputs:[{name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"initCodeHash",outputs:[{name:"",type:"bytes32"}],stateMutability:"view",type:"function"}];function Ra(e){var t;if(!Array.isArray(e.params))return null;switch(e.method){case"personal_sign":return e.params[1];case"eth_signTypedData_v4":return e.params[0];case"eth_signTransaction":case"eth_sendTransaction":case"wallet_sendCalls":return(t=e.params[0])===null||t===void 0?void 0:t.from;default:return null}}function jp(e,t){if(!Array.isArray(e.params))throw _.rpc.invalidParams();const n=[...e.params];switch(e.method){case"eth_signTransaction":case"eth_sendTransaction":case"wallet_sendCalls":n[0].from=t;break;case"eth_signTypedData_v4":n[0]=t;break;case"personal_sign":n[1]=t;break}return Object.assign(Object.assign({},e),{params:n})}function ja(e){var t;if(!e||!Array.isArray(e)||!(!((t=e[0])===null||t===void 0)&&t.chainId)||typeof e[0].chainId!="string"&&typeof e[0].chainId!="number")throw _.rpc.invalidParams()}function Mp(e){if(!e||!Array.isArray(e)||e.length!==1&&e.length!==2||typeof e[0]!="string"||!ct(e[0]))throw _.rpc.invalidParams();if(e.length===2){if(!Array.isArray(e[1]))throw _.rpc.invalidParams();for(const t of e[1])if(typeof t!="string"||!t.startsWith("0x"))throw _.rpc.invalidParams()}}function ln(e,t){const n=Object.assign({},e);if(t&&e.method.startsWith("wallet_")){let r=Et(n,"params.0.capabilities");if(typeof r>"u"&&(r={}),typeof r!="object")throw _.rpc.invalidParams();r=Object.assign(Object.assign({},t),r),n.params&&Array.isArray(n.params)&&(n.params[0]=Object.assign(Object.assign({},n.params[0]),{capabilities:r}))}return n}async function Pn(){var e;const t=(e=T.subAccountsConfig.get())!==null&&e!==void 0?e:{},n={};if(t.enableAutoSubAccounts){const{account:r}=t.toOwnerAccount?await t.toOwnerAccount():await gr();if(!r)throw _.provider.unauthorized("No owner account found");n.addSubAccount={account:{type:"create",keys:[{type:r.address?"address":"webauthn-p256",publicKey:r.address||r.publicKey}]}}}T.subAccountsConfig.set({capabilities:n})}function Dp(e){if(!(e.method==="coinbase_fetchPermissions"&&e.params===void 0)){if(e.method==="coinbase_fetchPermissions"&&Array.isArray(e.params)&&e.params.length===1&&typeof e.params[0]=="object"){if(typeof e.params[0].account!="string"||!e.params[0].chainId.startsWith("0x"))throw _.rpc.invalidParams("FetchPermissions - Invalid params: params[0].account must be a hex string");if(typeof e.params[0].chainId!="string"||!e.params[0].chainId.startsWith("0x"))throw _.rpc.invalidParams("FetchPermissions - Invalid params: params[0].chainId must be a hex string");if(typeof e.params[0].spender!="string"||!e.params[0].spender.startsWith("0x"))throw _.rpc.invalidParams("FetchPermissions - Invalid params: params[0].spender must be a hex string");return}throw _.rpc.invalidParams()}}function Up(e){var t,n,r;if(e.params!==void 0)return e;const a=(t=T.getState().account.accounts)===null||t===void 0?void 0:t[0],s=(n=T.getState().account.chain)===null||n===void 0?void 0:n.id,i=(r=T.getState().subAccount)===null||r===void 0?void 0:r.address;if(!a||!i||!s)throw _.rpc.invalidParams("FetchPermissions - one or more of account, sub account, or chain id is missing, connect to sub account via wallet_connect first");return{method:"coinbase_fetchPermissions",params:[{account:a,chainId:M(s),spender:i}]}}function Fp({spendPermission:e,chainId:t}){return{domain:{name:"Spend Permission Manager",version:"1",chainId:t,verifyingContract:ji},types:{SpendPermission:[{name:"account",type:"address"},{name:"spender",type:"address"},{name:"token",type:"address"},{name:"allowance",type:"uint160"},{name:"period",type:"uint48"},{name:"start",type:"uint48"},{name:"end",type:"uint48"},{name:"salt",type:"uint256"},{name:"extraData",type:"bytes"}]},primaryType:"SpendPermission",message:{account:e.account,spender:e.spender,token:e.token,allowance:e.allowance,period:e.period,start:e.start,end:e.end,salt:e.salt,extraData:e.extraData}}}function $p({spendPermissionBatch:e,chainId:t}){return{domain:{name:"Spend Permission Manager",version:"1",chainId:t,verifyingContract:ji},types:{SpendPermissionBatch:[{name:"account",type:"address"},{name:"period",type:"uint48"},{name:"start",type:"uint48"},{name:"end",type:"uint48"},{name:"permissions",type:"PermissionDetails[]"}],PermissionDetails:[{name:"spender",type:"address"},{name:"token",type:"address"},{name:"allowance",type:"uint160"},{name:"salt",type:"uint256"},{name:"extraData",type:"bytes"}]},primaryType:"SpendPermissionBatch",message:{account:e.account,period:e.period,start:e.start,end:e.end,permissions:e.permissions.map(n=>({spender:n.spender,token:n.token,allowance:n.allowance,salt:n.salt,extraData:n.extraData}))}}}async function Di({client:e,id:t}){var n;const r=await Ds(e,{id:t});if(r.status==="success")return(n=r.receipts)===null||n===void 0?void 0:n[0].transactionHash;throw _.rpc.internal("failed to send transaction")}function Ui({calls:e,from:t,chainId:n,capabilities:r}){const a=li.get().paymasterUrls;let s={method:"wallet_sendCalls",params:[{version:"1.0",calls:e,chainId:M(n),from:t,atomicRequired:!0,capabilities:r}]};return a?.[n]&&(s=ln(s,{paymasterService:{url:a?.[n]}})),s}async function Gp(){const e=qr();return await new Promise(n=>{zr({snackbarContext:"sub_account_insufficient_balance"}),e.presentItem({autoExpand:!0,message:"Insufficient spend permission. Choose how to proceed:",menuItems:[{isRed:!1,info:"Create new Spend Permission",svgWidth:"10",svgHeight:"11",path:"",defaultFillRule:"evenodd",defaultClipRule:"evenodd",onClick:()=>{st({snackbarContext:"sub_account_insufficient_balance",snackbarAction:"create_permission"}),e.clear(),n("update_permission")}},{isRed:!1,info:"Continue in Popup",svgWidth:"10",svgHeight:"11",path:"",defaultFillRule:"evenodd",defaultClipRule:"evenodd",onClick:()=>{st({snackbarContext:"sub_account_insufficient_balance",snackbarAction:"continue_in_popup"}),e.clear(),n("continue_popup")}},{isRed:!0,info:"Cancel",svgWidth:"10",svgHeight:"11",path:"",defaultFillRule:"evenodd",defaultClipRule:"evenodd",onClick:()=>{st({snackbarContext:"sub_account_insufficient_balance",snackbarAction:"cancel"}),e.clear(),n("cancel")}}]})})}function Hp({errorData:e,sourceAddress:t}){var n;const r=[];for(const[a,{amount:s,sources:i}]of Object.entries((n=e?.required)!==null&&n!==void 0?n:{})){if(i.filter(c=>he(c.balance)>=he(s)&&c.address.toLowerCase()===t?.toLowerCase()).length===0)throw new Error("Source address has insufficient balance for a token");r.push({token:a,requiredAmount:he(s)})}return r}function zp(e){return typeof e=="object"&&e!==null&&"calls"in e}function qp(e){return Array.isArray(e)&&e.length===1&&typeof e[0]=="object"&&e[0]!==null&&"to"in e[0]}function Wp(e){return nu(ce(Te(e)),0,16)}function Vp({attribution:e,dappOrigin:t}){if(e){if("auto"in e&&e.auto&&t)return Wp(t);if("dataSuffix"in e)return e.dataSuffix}}function Kp(e,t){var n;if(!Array.isArray(e?.params))return!1;const r=(n=e.params[0])===null||n===void 0?void 0:n.capabilities;return!r||typeof r!="object"?!1:t in r}function zt(e,t){const n=e.filter(r=>r!==t);return[t,...n]}function qt(e,t){return[...e.filter(r=>r!==t),t]}async function Jp(){const e=T.spendPermissions.get(),t=T.subAccounts.get(),n=T.account.get().accounts;return n?{accounts:n?.map(a=>({address:a,capabilities:{subAccounts:t?[t]:void 0,spendPermissions:e.length>0?{permissions:e}:void 0}}))}:null}function Zp(e){return e.replaceAll("+","-").replaceAll("/","_").replace(/=+$/,"")}function Wt(e){const t=btoa(String.fromCharCode(...new Uint8Array(e)));return Zp(t)}function Yp({webauthn:e,signature:t,id:n}){const r=ai(t);return{id:n,rawId:Wt(Ve(n)),response:{authenticatorData:Wt(Qt(e.authenticatorData)),clientDataJSON:Wt(Ve(e.clientDataJSON)),signature:Wt(Qp(r.r,r.s))},type:JSON.parse(e.clientDataJSON).type}}function Qp(e,t){const n=Qt(Yt(M(e))),r=Qt(Yt(M(t))),a=n.length,s=r.length,i=a+s+4,o=new Uint8Array(i+2);return o[0]=48,o[1]=i,o[2]=2,o[3]=a,o.set(n,4),o[a+4]=2,o[a+5]=s,o.set(r,a+6),o}var Xp=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,r=Object.getOwnPropertySymbols(e);a<r.length;a++)t.indexOf(r[a])<0&&Object.prototype.propertyIsEnumerable.call(e,r[a])&&(n[r[a]]=e[r[a]]);return n};async function em(e){const{owner:t,ownerIndex:n,address:r,client:a,factoryData:s}=e,i={abi:wd,address:qd,version:"0.6"},o={abi:Mi,address:Ri};return Ed({client:a,entryPoint:i,extend:{abi:be,factory:o},async decodeCalls(c){const u=Ss({abi:be,data:c});if(u.functionName==="execute")return[{to:u.args[0],value:u.args[1],data:u.args[2]}];if(u.functionName==="executeBatch")return u.args[0].map(d=>({to:d.target,value:d.value,data:d.data}));throw new D(`unable to decode calls for "${u.functionName}"`)},async encodeCalls(c){var u,d;return c.length===1?oe({abi:be,functionName:"execute",args:[c[0].to,(u=c[0].value)!==null&&u!==void 0?u:BigInt(0),(d=c[0].data)!==null&&d!==void 0?d:"0x"]}):oe({abi:be,functionName:"executeBatch",args:[c.map(l=>{var p,f;return{data:(p=l.data)!==null&&p!==void 0?p:"0x",target:l.to,value:(f=l.value)!==null&&f!==void 0?f:BigInt(0)}})]})},async getAddress(){return r},async getFactoryArgs(){return s?{factory:o.address,factoryData:s}:{factory:o.address,factoryData:s}},async getStubSignature(){return t.type==="webAuthn"?"0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000170000000000000000000000000000000000000000000000000000000000000001949fc7c88032b9fcb5f6efc7a7b8c63668eae9871b765e23123bb473ff57aa831a7c0d9276168ebcc29f2875a0239cffdf2a9cd1c2007c5c77c071db9264df1d000000000000000000000000000000000000000000000000000000000000002549960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97630500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008a7b2274797065223a22776562617574686e2e676574222c226368616c6c656e6765223a2273496a396e6164474850596759334b7156384f7a4a666c726275504b474f716d59576f4d57516869467773222c226f726967696e223a2268747470733a2f2f7369676e2e636f696e626173652e636f6d222c2263726f73734f726967696e223a66616c73657d00000000000000000000000000000000000000000000":vt({ownerIndex:n,signature:"0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c"})},async sign(c){const u=await this.getAddress(),d=On({address:u,chainId:a.chain.id,hash:c.hash}),l=await Vt({hash:d,owner:t});return vt({ownerIndex:n,signature:l})},async signMessage(c){const{message:u}=c,d=await this.getAddress(),l=On({address:d,chainId:a.chain.id,hash:Pr(u)}),p=await Vt({hash:l,owner:t});return vt({ownerIndex:n,signature:p})},async signTypedData(c){const{domain:u,types:d,primaryType:l,message:p}=c,f=await this.getAddress(),y=On({address:f,chainId:a.chain.id,hash:Lt({domain:u,message:p,primaryType:l,types:d})}),g=await Vt({hash:y,owner:t});return vt({ownerIndex:n,signature:g})},async signUserOperation(c){const{chainId:u=a.chain.id}=c,d=Xp(c,["chainId"]),l=await this.getAddress(),p=xd({chainId:u,entryPointAddress:i.address,entryPointVersion:i.version,userOperation:Object.assign(Object.assign({},d),{sender:l})}),f=await Vt({hash:p,owner:t});return vt({ownerIndex:n,signature:f})},userOperation:{async estimateGas(c){var u;if(t.type==="webAuthn")return{verificationGasLimit:BigInt(Math.max(Number((u=c.verificationGasLimit)!==null&&u!==void 0?u:BigInt(0)),8e5))}}}})}async function Vt({hash:e,owner:t}){if(t.type==="webAuthn"){const{signature:n,webauthn:r}=await t.sign({hash:e});return tm({signature:n,webauthn:r})}if(t.sign)return t.sign({hash:e});throw new D("`owner` does not support raw sign.")}function On({address:e,chainId:t,hash:n}){return Lt({domain:{chainId:t,name:"Coinbase Smart Wallet",verifyingContract:e,version:"1"},types:{CoinbaseSmartWalletMessage:[{name:"hash",type:"bytes32"}]},primaryType:"CoinbaseSmartWalletMessage",message:{hash:n}})}function tm({webauthn:e,signature:t}){const{r:n,s:r}=ai(t);return Ke([{components:[{name:"authenticatorData",type:"bytes"},{name:"clientDataJSON",type:"bytes"},{name:"challengeIndex",type:"uint256"},{name:"typeIndex",type:"uint256"},{name:"r",type:"uint256"},{name:"s",type:"uint256"}],type:"tuple"}],[{authenticatorData:e.authenticatorData,clientDataJSON:is(e.clientDataJSON),challengeIndex:BigInt(e.challengeIndex),typeIndex:BigInt(e.typeIndex),r:n,s:r}])}function vt(e){const{ownerIndex:t=0}=e,n=(()=>{if(ru(e.signature)!==65)return e.signature;const r=yd(e.signature);return Bu(["bytes32","bytes32","uint8"],[r.r,r.s,r.yParity===0?27:28])})();return Ke([{components:[{name:"ownerIndex",type:"uint8"},{name:"signatureData",type:"bytes"}],type:"tuple"}],[{ownerIndex:t,signatureData:n}])}async function nm({address:e,client:t,factory:n,factoryData:r,owner:a,ownerIndex:s,parentAddress:i,attribution:o}){var c;const u={address:e,factory:n,factoryData:r},d=(c=t.chain)===null||c===void 0?void 0:c.id;if(!d)throw _.rpc.internal("chainId not found");const l=await em({owner:a,ownerIndex:s??1,address:e,client:t,factoryData:r}),p=async f=>{var y,g,h,w,E,b;try{switch(f.method){case"wallet_addSubAccount":return u;case"eth_accounts":return[u.address];case"eth_coinbase":return u.address;case"net_version":return d.toString();case"eth_chainId":return M(d);case"eth_sendTransaction":{Re(f.params);const A=f.params[0];le(A.to,_.rpc.invalidParams("to is required"));const I={to:A.to,data:hr((y=A.data)!==null&&y!==void 0?y:"0x",!0),value:hr((g=A.value)!==null&&g!==void 0?g:"0x",!0),from:(h=A.from)!==null&&h!==void 0?h:u.address},N=Ui({calls:[I],chainId:d,from:I.from}),B=await p(N);return Di({client:t,id:B})}case"wallet_sendCalls":{Re(f.params);const A=Et(f.params[0],"chainId");if(!A)throw _.rpc.invalidParams("chainId is required");if(!Ge(A))throw _.rpc.invalidParams("chainId must be a hex encoded integer");if(!f.params[0])throw _.rpc.invalidParams("params are required");if(!("calls"in f.params[0]))throw _.rpc.invalidParams("calls are required");let I={method:"wallet_prepareCalls",params:[{version:"1.0",calls:f.params[0].calls,chainId:A,from:u.address,capabilities:"capabilities"in f.params[0]?f.params[0].capabilities:{}}]};i&&(I=ln(I,{funding:[{type:"spendPermission",data:{autoApply:!0,sources:[i],preference:"PREFER_DIRECT_BALANCE"}}]}));let N=await p(I);const B=await((E=(w=a).sign)===null||E===void 0?void 0:E.call(w,{hash:oa(N.signatureRequest.hash)}));let j;if(!B)throw _.rpc.internal("signature not found");return Ge(B)?j={type:"secp256k1",data:{address:a.address,signature:B}}:j={type:"webauthn",data:{signature:JSON.stringify(Yp(Object.assign({id:(b=a.id)!==null&&b!==void 0?b:"1"},B))),publicKey:a.publicKey}},(await p({method:"wallet_sendPreparedCalls",params:[{version:"1.0",type:N.type,data:N.userOp,chainId:N.chainId,signature:j}]}))[0]}case"wallet_sendPreparedCalls":{Re(f.params);const A=Et(f.params[0],"chainId");if(!A)throw _.rpc.invalidParams("chainId is required");if(!Ge(A))throw _.rpc.invalidParams("chainId must be a hex encoded integer");return await t.request({method:"wallet_sendPreparedCalls",params:f.params})}case"wallet_prepareCalls":{Re(f.params);const A=Et(f.params[0],"chainId");if(!A)throw _.rpc.invalidParams("chainId is required");if(!Ge(A))throw _.rpc.invalidParams("chainId must be a hex encoded integer");if(!f.params[0])throw _.rpc.invalidParams("params are required");if(!Et(f.params[0],"calls"))throw _.rpc.invalidParams("calls are required");const I=f.params[0];return o&&I.capabilities&&!("attribution"in I.capabilities)&&(I.capabilities.attribution=o),await t.request({method:"wallet_prepareCalls",params:[Object.assign(Object.assign({},f.params[0]),{chainId:A})]})}case"personal_sign":{if(Re(f.params),!Ge(f.params[0]))throw _.rpc.invalidParams("message must be a hex encoded string");const A=oa(f.params[0]);return l.signMessage({message:A})}case"eth_signTypedData_v4":{Re(f.params);const A=typeof f.params[1]=="string"?JSON.parse(f.params[1]):f.params[1];return l.signTypedData(A)}case"eth_signTypedData_v1":case"eth_signTypedData_v3":case"wallet_addEthereumChain":case"wallet_switchEthereumChain":default:throw _.rpc.methodNotSupported()}}catch(A){if(yi(A)){const I=yf(A);if(I)throw I}throw A}};return{request:p}}async function Fi({address:e,client:t,publicKey:n,factory:r,factoryData:a}){if(!await Xt(t,{address:e})&&r&&a){if(ca(r)!==ca(Ri))throw _.rpc.internal("unknown factory address");const o=Ss({abi:Mi,data:a});if(o.functionName!=="createAccount")throw _.rpc.internal("unknown factory function");const[c]=o.args;return c.findIndex(u=>u.toLowerCase()===Ma(n).toLowerCase())}const i=await Se(t,{address:e,abi:be,functionName:"ownerCount"});for(let o=Number(i)-1;o>=0;o--){const c=await Se(t,{address:e,abi:be,functionName:"ownerAtIndex",args:[BigInt(o)]}),u=Ma(n);if(c.toLowerCase()===u.toLowerCase())return o}return-1}function Ma(e){return ct(e)?de(e):e}async function rm(){const e=qr();return new Promise(t=>{zr({snackbarContext:"sub_account_add_owner"}),e.presentItem({autoExpand:!0,message:"App requires a signer update",menuItems:[{isRed:!1,info:"Confirm",svgWidth:"10",svgHeight:"11",path:"",defaultFillRule:"evenodd",defaultClipRule:"evenodd",onClick:()=>{st({snackbarContext:"sub_account_add_owner",snackbarAction:"confirm"}),e.clear(),t("authenticate")}},{isRed:!0,info:"Cancel",svgWidth:"10",svgHeight:"11",path:"",defaultFillRule:"evenodd",defaultClipRule:"evenodd",onClick:()=>{st({snackbarContext:"sub_account_add_owner",snackbarAction:"cancel"}),e.clear(),t("cancel")}}]})})}async function am({ownerAccount:e,globalAccountRequest:t}){var n,r;const a=T.account.get(),s=T.subAccounts.get(),i=(n=a.accounts)===null||n===void 0?void 0:n.find(y=>y.toLowerCase()!==s?.address.toLowerCase());le(i,_.provider.unauthorized("no global account")),le((r=a.chain)===null||r===void 0?void 0:r.id,_.provider.unauthorized("no chain id")),le(s?.address,_.provider.unauthorized("no sub account"));const o=[];if(e.type==="local"&&e.address&&o.push({to:s.address,data:oe({abi:be,functionName:"addOwnerAddress",args:[e.address]}),value:Te(0)}),e.publicKey){const[y,g]=As([{type:"bytes32"},{type:"bytes32"}],e.publicKey);o.push({to:s.address,data:oe({abi:be,functionName:"addOwnerPublicKey",args:[y,g]}),value:Te(0)})}const c={method:"wallet_sendCalls",params:[{version:"1",calls:o,chainId:M(84532),from:i}]};if(await rm()==="cancel")throw _.provider.unauthorized("user cancelled");const d=await t(c),l=Ti(a.chain.id);if(le(l,_.rpc.internal(`client not found for chainId ${a.chain.id}`)),(await Ds(l,{id:d})).status!=="success")throw _.rpc.internal("add owner call failed");const f=await Fi({address:s.address,publicKey:e.type==="local"&&e.address?e.address:e.publicKey,client:l});if(f===-1)throw _.rpc.internal("failed to find owner index");return f}async function sm({errorData:e,globalAccountAddress:t,subAccountAddress:n,client:r,request:a,subAccountRequest:s,globalAccountRequest:i}){var o;const c=(o=r.chain)===null||o===void 0?void 0:o.id;le(c,_.rpc.internal("invalid chainId"));const u=Hp({errorData:e,sourceAddress:t}),d=await Gp();if(d==="cancel")throw new Error("User cancelled funding");let l;const p=60*60*24,f=3;if(d==="update_permission"){if(u.length===1){const b=u[0],A=Fp({spendPermission:{token:b.token,allowance:M(b.requiredAmount*BigInt(f)),period:p,account:t,spender:n,start:0,end:0xffffffffffff,salt:M(BigInt(Math.floor(Math.random()*Number.MAX_SAFE_INTEGER))),extraData:"0x"},chainId:c});l={method:"eth_signTypedData_v4",params:[t,A]}}else{const b=$p({spendPermissionBatch:{account:t,period:p,start:0,end:0xffffffffffff,permissions:u.map(A=>({token:A.token,allowance:M(A.requiredAmount*BigInt(f)),period:p,account:t,spender:n,salt:"0x0",extraData:"0x"}))},chainId:c});l={method:"eth_signTypedData_v4",params:[t,b]}}try{await i(l)}catch(b){throw console.error(b),new Error("User denied spend permission request")}return s(a)}const y=u.map(b=>b.token.toLowerCase()==="0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE".toLowerCase()?{to:n,value:M(b.requiredAmount),data:"0x"}:{to:b.token,value:"0x0",data:oe({abi:au,functionName:"transfer",args:[n,b.requiredAmount]})});let g;if(a.method==="wallet_sendCalls"&&zp(a.params))g=a.params[0];else if(a.method==="eth_sendTransaction"&&qp(a.params))g=Ui({calls:[a.params[0]],chainId:c,from:a.params[0].from}).params[0];else throw new Error("Could not get original call");const h=oe({abi:be,functionName:"executeBatch",args:[g.calls.map(b=>{var A,I;return{target:b.to,value:he((A=b.value)!==null&&A!==void 0?A:"0x0"),data:(I=b.data)!==null&&I!==void 0?I:"0x"}})]}),w=[...y,{data:h,to:n,value:"0x0"}],E=await i({method:"wallet_sendCalls",params:[Object.assign(Object.assign({},g),{calls:w,from:t})]});return a.method==="eth_sendTransaction"?Di({client:r,id:E}):E}class $i{constructor(t){var n,r,a,s;this.communicator=t.communicator,this.callback=t.callback,this.keyManager=new Rp;const{account:i,chains:o}=T.getState();this.accounts=(n=i.accounts)!==null&&n!==void 0?n:[],this.chain=(r=i.chain)!==null&&r!==void 0?r:{id:(s=(a=t.metadata.appChainIds)===null||a===void 0?void 0:a[0])!==null&&s!==void 0?s:1},o&&Ta(o)}async handshake(t){var n,r,a;const s=ge.get(t);op({method:t.method,correlationId:s});try{await((r=(n=this.communicator).waitForPopupLoaded)===null||r===void 0?void 0:r.call(n));const i=await this.createRequestMessage({handshake:{method:t.method,params:(a=t.params)!==null&&a!==void 0?a:[]}},s),o=await this.communicator.postRequestAndWaitForResponse(i);if("failure"in o.content)throw o.content.failure;const c=await Li("public",o.sender);await this.keyManager.setPeerPublicKey(c);const u=await this.decryptResponseMessage(o);this.handleResponse(t,u),up({method:t.method,correlationId:s})}catch(i){throw cp({method:t.method,correlationId:s,errorMessage:ze(i)}),i}}async request(t){const n=ge.get(t);dp({method:t.method,correlationId:n});try{const r=await this._request(t);return fp({method:t.method,correlationId:n}),r}catch(r){throw lp({method:t.method,correlationId:n,errorMessage:ze(r)}),r}}async _request(t){var n,r,a,s,i,o,c,u,d,l,p,f,y,g;if(this.accounts.length===0)switch(t.method){case"eth_requestAccounts":return await((r=(n=this.communicator).waitForPopupLoaded)===null||r===void 0?void 0:r.call(n)),await Pn(),await this.request({method:"wallet_connect",params:[{version:"1",capabilities:Object.assign({},(s=(a=T.subAccountsConfig.get())===null||a===void 0?void 0:a.capabilities)!==null&&s!==void 0?s:{})}]}),this.accounts;case"wallet_switchEthereumChain":{ja(t.params),this.chain.id=Number(t.params[0].chainId);return}case"wallet_connect":{await((o=(i=this.communicator).waitForPopupLoaded)===null||o===void 0?void 0:o.call(i)),await Pn();let h={};Kp(t,"addSubAccount")&&(h=(u=(c=T.subAccountsConfig.get())===null||c===void 0?void 0:c.capabilities)!==null&&u!==void 0?u:{});const w=ln(t,h);return this.sendRequestToPopup(w)}case"wallet_sendCalls":case"wallet_sign":return this.sendRequestToPopup(t);default:throw _.provider.unauthorized()}if(this.shouldRequestUseSubAccountSigner(t)){const h=ge.get(t);pp({method:t.method,correlationId:h});try{const w=await this.sendRequestToSubAccountSigner(t);return mp({method:t.method,correlationId:h}),w}catch(w){throw hp({method:t.method,correlationId:h,errorMessage:ze(w)}),w}}switch(t.method){case"eth_requestAccounts":case"eth_accounts":{const h=T.subAccounts.get(),w=T.subAccountsConfig.get();return h?.address&&(this.accounts=w?.enableAutoSubAccounts?zt(this.accounts,h.address):qt(this.accounts,h.address)),(d=this.callback)===null||d===void 0||d.call(this,"connect",{chainId:M(this.chain.id)}),this.accounts}case"eth_coinbase":return this.accounts[0];case"net_version":return this.chain.id;case"eth_chainId":return M(this.chain.id);case"wallet_getCapabilities":return this.handleGetCapabilitiesRequest(t);case"wallet_switchEthereumChain":return this.handleSwitchChainRequest(t);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(t);case"wallet_connect":{const h=await Jp();if(h)return h;await((p=(l=this.communicator).waitForPopupLoaded)===null||p===void 0?void 0:p.call(l)),await Pn();const w=T.subAccountsConfig.get(),E=ln(t,(f=w?.capabilities)!==null&&f!==void 0?f:{});return(y=this.callback)===null||y===void 0||y.call(this,"connect",{chainId:M(this.chain.id)}),this.sendRequestToPopup(E)}case"wallet_getSubAccounts":{const h=T.subAccounts.get();if(h?.address)return{subAccounts:[h]};if(!this.chain.rpcUrl)throw _.rpc.internal("No RPC URL set for chain");const w=await Pt(t,this.chain.rpcUrl);if(Re(w.subAccounts,"subAccounts"),w.subAccounts.length>0){Ht(w.subAccounts[0]);const E=w.subAccounts[0];T.subAccounts.set({address:E.address,factory:E.factory,factoryData:E.factoryData})}return w}case"wallet_addSubAccount":return this.addSubAccount(t);case"coinbase_fetchPermissions":{Dp(t);const h=Up(t),w=await Pt(h,xi),E=Je((g=h.params)===null||g===void 0?void 0:g[0].chainId);return T.spendPermissions.set(w.permissions.map(b=>Object.assign(Object.assign({},b),{chainId:E}))),w}default:if(!this.chain.rpcUrl)throw _.rpc.internal("No RPC URL set for chain");return Pt(t,this.chain.rpcUrl)}}async sendRequestToPopup(t){var n,r;await((r=(n=this.communicator).waitForPopupLoaded)===null||r===void 0?void 0:r.call(n));const a=await this.sendEncryptedRequest(t),s=await this.decryptResponseMessage(a);return this.handleResponse(t,s)}async handleResponse(t,n){var r,a,s,i,o;const c=n.result;if("error"in c)throw c.error;switch(t.method){case"eth_requestAccounts":{const u=c.value;this.accounts=u,T.account.set({accounts:u,chain:this.chain}),(r=this.callback)===null||r===void 0||r.call(this,"accountsChanged",u);break}case"wallet_connect":{const u=c.value,d=u.accounts.map(w=>w.address);this.accounts=d,T.account.set({accounts:d});const l=u.accounts.at(0),p=l?.capabilities;if(p?.subAccounts){const w=p?.subAccounts;Re(w,"subAccounts"),Ht(w[0]),T.subAccounts.set({address:w[0].address,factory:w[0].factory,factoryData:w[0].factoryData})}let f=[this.accounts[0]];const y=T.subAccounts.get(),g=T.subAccountsConfig.get();y?.address&&(this.accounts=g?.enableAutoSubAccounts?zt(this.accounts,y.address):qt(this.accounts,y.address));const h=(s=(a=u?.accounts)===null||a===void 0?void 0:a[0].capabilities)===null||s===void 0?void 0:s.spendPermissions;h&&"permissions"in h&&T.spendPermissions.set(h?.permissions),(i=this.callback)===null||i===void 0||i.call(this,"accountsChanged",f);break}case"wallet_addSubAccount":{Ht(c.value);const u=c.value;T.subAccounts.set(u);const d=T.subAccountsConfig.get();this.accounts=d?.enableAutoSubAccounts?zt(this.accounts,u.address):qt(this.accounts,u.address),(o=this.callback)===null||o===void 0||o.call(this,"accountsChanged",this.accounts);break}}return c.value}async cleanup(){var t,n;const r=T.config.get().metadata;await this.keyManager.clear(),T.account.clear(),T.subAccounts.clear(),T.spendPermissions.clear(),T.chains.clear(),this.accounts=[],this.chain={id:(n=(t=r?.appChainIds)===null||t===void 0?void 0:t[0])!==null&&n!==void 0?n:1}}async handleSwitchChainRequest(t){ja(t.params);const n=It(t.params[0].chainId);if(this.updateChain(n))return null;const a=await this.sendRequestToPopup(t);return a===null&&this.updateChain(n),a}async handleGetCapabilitiesRequest(t){Mp(t.params);const n=t.params[0],r=t.params[1];if(!this.accounts.some(o=>Ir(o,n)))throw _.provider.unauthorized("no active account found when getting capabilities");const a=T.getState().account.capabilities;if(!a)return{};if(!r||r.length===0)return a;const s=new Set(r.map(o=>Je(o)));return Object.fromEntries(Object.entries(a).filter(([o])=>{try{const c=Je(o);return s.has(c)}catch{return!1}}))}async sendEncryptedRequest(t){const n=await this.keyManager.getSharedSecret();if(!n)throw _.provider.unauthorized("No shared secret found when encrypting request");const r=await _p({action:t,chainId:this.chain.id},n),a=ge.get(t),s=await this.createRequestMessage({encrypted:r},a);return this.communicator.postRequestAndWaitForResponse(s)}async createRequestMessage(t,n){const r=await Bi("public",await this.keyManager.getOwnPublicKey());return{id:crypto.randomUUID(),correlationId:n,sender:r,content:t,timestamp:new Date}}async decryptResponseMessage(t){var n,r,a;const s=t.content;if("failure"in s)throw s.failure;const i=await this.keyManager.getSharedSecret();if(!i)throw _.provider.unauthorized("Invalid session: no shared secret found when decrypting response");const o=await Ip(s.encrypted,i),c=(n=o.data)===null||n===void 0?void 0:n.chains;if(c){const d=(r=o.data)===null||r===void 0?void 0:r.nativeCurrencies,l=Object.entries(c).map(([p,f])=>{const y=d?.[Number(p)];return Object.assign({id:Number(p),rpcUrl:f},y?{nativeCurrency:y}:{})});T.chains.set(l),this.updateChain(this.chain.id,l),Ta(l)}const u=(a=o.data)===null||a===void 0?void 0:a.capabilities;return u&&T.account.set({capabilities:u}),o}updateChain(t,n){var r;const a=T.getState(),s=n??a.chains,i=s?.find(o=>o.id===t);return i?(i!==this.chain&&(this.chain=i,T.account.set({chain:i}),(r=this.callback)===null||r===void 0||r.call(this,"chainChanged",at(i.id))),!0):!1}async addSubAccount(t){var n,r,a,s;const o=T.getState().subAccount,c=T.subAccountsConfig.get();if(o?.address)return this.accounts=c?.enableAutoSubAccounts?zt(this.accounts,o.address):qt(this.accounts,o.address),(n=this.callback)===null||n===void 0||n.call(this,"accountsChanged",this.accounts),o;if(await((a=(r=this.communicator).waitForPopupLoaded)===null||a===void 0?void 0:a.call(r)),Array.isArray(t.params)&&t.params.length>0&&t.params[0].account&&t.params[0].account.type==="create"){let d;if(t.params[0].account.keys&&t.params[0].account.keys.length>0)d=t.params[0].account.keys;else{const l=(s=T.subAccountsConfig.get())!==null&&s!==void 0?s:{},{account:p}=l.toOwnerAccount?await l.toOwnerAccount():await gr();if(!p)throw _.provider.unauthorized("could not get subaccount owner account when adding sub account");d=[{type:p.address?"address":"webauthn-p256",publicKey:p.address||p.publicKey}]}t.params[0].account.keys=d}const u=await this.sendRequestToPopup(t);return Ht(u),u}shouldRequestUseSubAccountSigner(t){const n=Ra(t),r=T.subAccounts.get();return n?n.toLowerCase()===r?.address.toLowerCase():!1}async sendRequestToSubAccountSigner(t){var n;const r=T.subAccounts.get(),a=T.subAccountsConfig.get(),s=T.config.get();le(r?.address,_.provider.unauthorized("no active sub account when sending request to sub account signer"));const i=a?.toOwnerAccount?await a.toOwnerAccount():await gr();le(i?.account,_.provider.unauthorized("no active sub account owner when sending request to sub account signer")),Ra(t)===void 0&&(t=jp(t,r.address));const c=Ti(this.chain.id);le(c,_.rpc.internal(`client not found for chainId ${this.chain.id} when sending request to sub account signer`));const u=this.accounts.find(y=>y.toLowerCase()!==r.address.toLowerCase());le(u,_.provider.unauthorized("no global account found when sending request to sub account signer"));const d=Vp({attribution:(n=s.preference)===null||n===void 0?void 0:n.attribution,dappOrigin:window.location.origin}),l=i.account.type==="local"?i.account.address:i.account.publicKey;let p=await Fi({address:r.address,factory:r.factory,factoryData:r.factoryData,publicKey:l,client:c});if(p===-1){const y=ge.get(t);yp({method:t.method,correlationId:y});try{p=await am({ownerAccount:i.account,globalAccountRequest:this.sendRequestToPopup.bind(this)}),gp({method:t.method,correlationId:y})}catch(g){return bp({method:t.method,correlationId:y,errorMessage:ze(g)}),_.provider.unauthorized("failed to add sub account owner when sending request to sub account signer")}}const{request:f}=await nm({address:r.address,owner:i.account,client:c,factory:r.factory,factoryData:r.factoryData,parentAddress:u,attribution:d?{suffix:d}:void 0,ownerIndex:p});try{return await f(t)}catch(y){let g;if(yi(y))g=JSON.parse(y.details);else if(_a(y))g=y;else throw y;if(!(_a(g)&&g.data)||!g.data)throw y;const h=ge.get(t);wp({method:t.method,correlationId:h});try{const w=await sm({errorData:g.data,globalAccountAddress:u,subAccountAddress:r.address,client:c,request:t,subAccountRequest:f,globalAccountRequest:this.request.bind(this)});return vp({method:t.method,correlationId:h}),w}catch(w){throw console.error(w),kp({method:t.method,correlationId:h,errorMessage:ze(w)}),y}}}}const im=({method:e,correlationId:t})=>{V("walletlink_signer.handshake.started",{action:H.unknown,componentType:G.unknown,method:e,correlationId:t},z.high)},om=({method:e,correlationId:t,errorMessage:n})=>{V("walletlink_signer.handshake.error",{action:H.error,componentType:G.unknown,method:e,correlationId:t,errorMessage:n},z.high)},cm=({method:e,correlationId:t})=>{V("walletlink_signer.handshake.completed",{action:H.unknown,componentType:G.unknown,method:e,correlationId:t},z.high)},um=({method:e,correlationId:t})=>{V("walletlink_signer.request.started",{action:H.unknown,componentType:G.unknown,method:e,correlationId:t},z.high)},dm=({method:e,correlationId:t,errorMessage:n})=>{V("walletlink_signer.request.error",{action:H.error,componentType:G.unknown,method:e,correlationId:t,errorMessage:n},z.high)},lm=({method:e,correlationId:t})=>{V("walletlink_signer.request.completed",{action:H.unknown,componentType:G.unknown,method:e,correlationId:t},z.high)},Da=()=>{V("walletlink_signer.walletlink_connection.connection_failed",{action:H.measurement,componentType:G.unknown},z.high)},fm=()=>{V("walletlink_signer.walletlink_connection.fetch_unseen_events_failed",{action:H.measurement,componentType:G.unknown},z.high)};var Z={},re={};Object.defineProperty(re,"__esModule",{value:!0});re.output=re.exists=re.hash=re.bytes=re.bool=re.number=re.isBytes=void 0;function fn(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}re.number=fn;function Gi(e){if(typeof e!="boolean")throw new Error(`boolean expected, not ${e}`)}re.bool=Gi;function Hi(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}re.isBytes=Hi;function Vr(e,...t){if(!Hi(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}re.bytes=Vr;function zi(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");fn(e.outputLen),fn(e.blockLen)}re.hash=zi;function qi(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}re.exists=qi;function Wi(e,t){Vr(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}re.output=Wi;const pm={number:fn,bool:Gi,bytes:Vr,hash:zi,exists:qi,output:Wi};re.default=pm;var U={};Object.defineProperty(U,"__esModule",{value:!0});U.add5L=U.add5H=U.add4H=U.add4L=U.add3H=U.add3L=U.add=U.rotlBL=U.rotlBH=U.rotlSL=U.rotlSH=U.rotr32L=U.rotr32H=U.rotrBL=U.rotrBH=U.rotrSL=U.rotrSH=U.shrSL=U.shrSH=U.toBig=U.split=U.fromBig=void 0;const Kt=BigInt(2**32-1),br=BigInt(32);function Kr(e,t=!1){return t?{h:Number(e&Kt),l:Number(e>>br&Kt)}:{h:Number(e>>br&Kt)|0,l:Number(e&Kt)|0}}U.fromBig=Kr;function Vi(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let a=0;a<e.length;a++){const{h:s,l:i}=Kr(e[a],t);[n[a],r[a]]=[s,i]}return[n,r]}U.split=Vi;const Ki=(e,t)=>BigInt(e>>>0)<<br|BigInt(t>>>0);U.toBig=Ki;const Ji=(e,t,n)=>e>>>n;U.shrSH=Ji;const Zi=(e,t,n)=>e<<32-n|t>>>n;U.shrSL=Zi;const Yi=(e,t,n)=>e>>>n|t<<32-n;U.rotrSH=Yi;const Qi=(e,t,n)=>e<<32-n|t>>>n;U.rotrSL=Qi;const Xi=(e,t,n)=>e<<64-n|t>>>n-32;U.rotrBH=Xi;const eo=(e,t,n)=>e>>>n-32|t<<64-n;U.rotrBL=eo;const to=(e,t)=>t;U.rotr32H=to;const no=(e,t)=>e;U.rotr32L=no;const ro=(e,t,n)=>e<<n|t>>>32-n;U.rotlSH=ro;const ao=(e,t,n)=>t<<n|e>>>32-n;U.rotlSL=ao;const so=(e,t,n)=>t<<n-32|e>>>64-n;U.rotlBH=so;const io=(e,t,n)=>e<<n-32|t>>>64-n;U.rotlBL=io;function oo(e,t,n,r){const a=(t>>>0)+(r>>>0);return{h:e+n+(a/2**32|0)|0,l:a|0}}U.add=oo;const co=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0);U.add3L=co;const uo=(e,t,n,r)=>t+n+r+(e/2**32|0)|0;U.add3H=uo;const lo=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0);U.add4L=lo;const fo=(e,t,n,r,a)=>t+n+r+a+(e/2**32|0)|0;U.add4H=fo;const po=(e,t,n,r,a)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(a>>>0);U.add5L=po;const mo=(e,t,n,r,a,s)=>t+n+r+a+s+(e/2**32|0)|0;U.add5H=mo;const mm={fromBig:Kr,split:Vi,toBig:Ki,shrSH:Ji,shrSL:Zi,rotrSH:Yi,rotrSL:Qi,rotrBH:Xi,rotrBL:eo,rotr32H:to,rotr32L:no,rotlSH:ro,rotlSL:ao,rotlBH:so,rotlBL:io,add:oo,add3L:co,add3H:uo,add4L:lo,add4H:fo,add5H:mo,add5L:po};U.default=mm;var ho={},xn={};Object.defineProperty(xn,"__esModule",{value:!0});xn.crypto=void 0;xn.crypto=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;(function(e){/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */Object.defineProperty(e,"__esModule",{value:!0}),e.randomBytes=e.wrapXOFConstructorWithOpts=e.wrapConstructorWithOpts=e.wrapConstructor=e.checkOpts=e.Hash=e.concatBytes=e.toBytes=e.utf8ToBytes=e.asyncLoop=e.nextTick=e.hexToBytes=e.bytesToHex=e.byteSwap32=e.byteSwapIfBE=e.byteSwap=e.isLE=e.rotl=e.rotr=e.createView=e.u32=e.u8=e.isBytes=void 0;const t=xn,n=re;function r(m){return m instanceof Uint8Array||m!=null&&typeof m=="object"&&m.constructor.name==="Uint8Array"}e.isBytes=r;const a=m=>new Uint8Array(m.buffer,m.byteOffset,m.byteLength);e.u8=a;const s=m=>new Uint32Array(m.buffer,m.byteOffset,Math.floor(m.byteLength/4));e.u32=s;const i=m=>new DataView(m.buffer,m.byteOffset,m.byteLength);e.createView=i;const o=(m,k)=>m<<32-k|m>>>k;e.rotr=o;const c=(m,k)=>m<<k|m>>>32-k>>>0;e.rotl=c,e.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;const u=m=>m<<24&4278190080|m<<8&16711680|m>>>8&65280|m>>>24&255;e.byteSwap=u,e.byteSwapIfBE=e.isLE?m=>m:m=>(0,e.byteSwap)(m);function d(m){for(let k=0;k<m.length;k++)m[k]=(0,e.byteSwap)(m[k])}e.byteSwap32=d;const l=Array.from({length:256},(m,k)=>k.toString(16).padStart(2,"0"));function p(m){(0,n.bytes)(m);let k="";for(let C=0;C<m.length;C++)k+=l[m[C]];return k}e.bytesToHex=p;const f={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function y(m){if(m>=f._0&&m<=f._9)return m-f._0;if(m>=f._A&&m<=f._F)return m-(f._A-10);if(m>=f._a&&m<=f._f)return m-(f._a-10)}function g(m){if(typeof m!="string")throw new Error("hex string expected, got "+typeof m);const k=m.length,C=k/2;if(k%2)throw new Error("padded hex string expected, got unpadded hex of length "+k);const O=new Uint8Array(C);for(let L=0,R=0;L<C;L++,R+=2){const S=y(m.charCodeAt(R)),$=y(m.charCodeAt(R+1));if(S===void 0||$===void 0){const q=m[R]+m[R+1];throw new Error('hex string expected, got non-hex character "'+q+'" at index '+R)}O[L]=S*16+$}return O}e.hexToBytes=g;const h=async()=>{};e.nextTick=h;async function w(m,k,C){let O=Date.now();for(let L=0;L<m;L++){C(L);const R=Date.now()-O;R>=0&&R<k||(await(0,e.nextTick)(),O+=R)}}e.asyncLoop=w;function E(m){if(typeof m!="string")throw new Error(`utf8ToBytes expected string, got ${typeof m}`);return new Uint8Array(new TextEncoder().encode(m))}e.utf8ToBytes=E;function b(m){return typeof m=="string"&&(m=E(m)),(0,n.bytes)(m),m}e.toBytes=b;function A(...m){let k=0;for(let O=0;O<m.length;O++){const L=m[O];(0,n.bytes)(L),k+=L.length}const C=new Uint8Array(k);for(let O=0,L=0;O<m.length;O++){const R=m[O];C.set(R,L),L+=R.length}return C}e.concatBytes=A;class I{clone(){return this._cloneInto()}}e.Hash=I;const N={}.toString;function B(m,k){if(k!==void 0&&N.call(k)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(m,k)}e.checkOpts=B;function j(m){const k=O=>m().update(b(O)).digest(),C=m();return k.outputLen=C.outputLen,k.blockLen=C.blockLen,k.create=()=>m(),k}e.wrapConstructor=j;function v(m){const k=(O,L)=>m(L).update(b(O)).digest(),C=m({});return k.outputLen=C.outputLen,k.blockLen=C.blockLen,k.create=O=>m(O),k}e.wrapConstructorWithOpts=v;function P(m){const k=(O,L)=>m(L).update(b(O)).digest(),C=m({});return k.outputLen=C.outputLen,k.blockLen=C.blockLen,k.create=O=>m(O),k}e.wrapXOFConstructorWithOpts=P;function x(m=32){if(t.crypto&&typeof t.crypto.getRandomValues=="function")return t.crypto.getRandomValues(new Uint8Array(m));throw new Error("crypto.getRandomValues must be defined")}e.randomBytes=x})(ho);Object.defineProperty(Z,"__esModule",{value:!0});Z.shake256=Z.shake128=Z.keccak_512=Z.keccak_384=Z.keccak_256=Z.keccak_224=Z.sha3_512=Z.sha3_384=Z.sha3_256=Z.sha3_224=Z.Keccak=Z.keccakP=void 0;const tt=re,Nt=U,Ie=ho,yo=[],go=[],bo=[],hm=BigInt(0),kt=BigInt(1),ym=BigInt(2),gm=BigInt(7),bm=BigInt(256),wm=BigInt(113);for(let e=0,t=kt,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],yo.push(2*(5*r+n)),go.push((e+1)*(e+2)/2%64);let a=hm;for(let s=0;s<7;s++)t=(t<<kt^(t>>gm)*wm)%bm,t&ym&&(a^=kt<<(kt<<BigInt(s))-kt);bo.push(a)}const[vm,km]=(0,Nt.split)(bo,!0),Ua=(e,t,n)=>n>32?(0,Nt.rotlBH)(e,t,n):(0,Nt.rotlSH)(e,t,n),Fa=(e,t,n)=>n>32?(0,Nt.rotlBL)(e,t,n):(0,Nt.rotlSL)(e,t,n);function wo(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let i=0;i<10;i++)n[i]=e[i]^e[i+10]^e[i+20]^e[i+30]^e[i+40];for(let i=0;i<10;i+=2){const o=(i+8)%10,c=(i+2)%10,u=n[c],d=n[c+1],l=Ua(u,d,1)^n[o],p=Fa(u,d,1)^n[o+1];for(let f=0;f<50;f+=10)e[i+f]^=l,e[i+f+1]^=p}let a=e[2],s=e[3];for(let i=0;i<24;i++){const o=go[i],c=Ua(a,s,o),u=Fa(a,s,o),d=yo[i];a=e[d],s=e[d+1],e[d]=c,e[d+1]=u}for(let i=0;i<50;i+=10){for(let o=0;o<10;o++)n[o]=e[i+o];for(let o=0;o<10;o++)e[i+o]^=~n[(o+2)%10]&n[(o+4)%10]}e[0]^=vm[r],e[1]^=km[r]}n.fill(0)}Z.keccakP=wo;class jt extends Ie.Hash{constructor(t,n,r,a=!1,s=24){if(super(),this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=a,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,(0,tt.number)(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=(0,Ie.u32)(this.state)}keccak(){Ie.isLE||(0,Ie.byteSwap32)(this.state32),wo(this.state32,this.rounds),Ie.isLE||(0,Ie.byteSwap32)(this.state32),this.posOut=0,this.pos=0}update(t){(0,tt.exists)(this);const{blockLen:n,state:r}=this;t=(0,Ie.toBytes)(t);const a=t.length;for(let s=0;s<a;){const i=Math.min(n-this.pos,a-s);for(let o=0;o<i;o++)r[this.pos++]^=t[s++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:n,pos:r,blockLen:a}=this;t[r]^=n,n&128&&r===a-1&&this.keccak(),t[a-1]^=128,this.keccak()}writeInto(t){(0,tt.exists)(this,!1),(0,tt.bytes)(t),this.finish();const n=this.state,{blockLen:r}=this;for(let a=0,s=t.length;a<s;){this.posOut>=r&&this.keccak();const i=Math.min(r-this.posOut,s-a);t.set(n.subarray(this.posOut,this.posOut+i),a),this.posOut+=i,a+=i}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return(0,tt.number)(t),this.xofInto(new Uint8Array(t))}digestInto(t){if((0,tt.output)(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:n,suffix:r,outputLen:a,rounds:s,enableXOF:i}=this;return t||(t=new jt(n,r,a,i,s)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=s,t.suffix=r,t.outputLen=a,t.enableXOF=i,t.destroyed=this.destroyed,t}}Z.Keccak=jt;const Fe=(e,t,n)=>(0,Ie.wrapConstructor)(()=>new jt(t,e,n));Z.sha3_224=Fe(6,144,224/8);Z.sha3_256=Fe(6,136,256/8);Z.sha3_384=Fe(6,104,384/8);Z.sha3_512=Fe(6,72,512/8);Z.keccak_224=Fe(1,144,224/8);Z.keccak_256=Fe(1,136,256/8);Z.keccak_384=Fe(1,104,384/8);Z.keccak_512=Fe(1,72,512/8);const vo=(e,t,n)=>(0,Ie.wrapXOFConstructorWithOpts)((r={})=>new jt(t,e,r.dkLen===void 0?n:r.dkLen,!0));Z.shake128=vo(31,168,128/8);Z.shake256=vo(31,136,256/8);const{keccak_256:xm}=Z;function ko(e){return Buffer.allocUnsafe(e).fill(0)}function Em(e){return`0x${e.toString(16)}`}function Sm(e){const t=Em(e);return new Buffer(So(t.slice(2)),"hex")}function Am(e){return e.toString(2).length}function xo(e,t){let n=e.toString(16);n.length%2!==0&&(n="0"+n);const r=n.match(/.{1,2}/g).map(a=>parseInt(a,16));for(;r.length<t;)r.unshift(0);return Buffer.from(r)}function _m(e,t){const n=e<0n;let r;if(n){const a=(1n<<BigInt(t))-1n;r=(~e&a)+1n}else r=e;return r&=(1n<<BigInt(t))-1n,r}function Eo(e,t,n){const r=ko(t);return e=En(e),n?e.length<t?(e.copy(r),r):e.slice(0,t):e.length<t?(e.copy(r,t-e.length),r):e.slice(-t)}function Im(e,t){return Eo(e,t,!0)}function En(e){if(!Buffer.isBuffer(e))if(Array.isArray(e))e=Buffer.from(e);else if(typeof e=="string")Ao(e)?e=Buffer.from(So(_o(e)),"hex"):e=Buffer.from(e);else if(typeof e=="number")e=Sm(e);else if(e==null)e=Buffer.allocUnsafe(0);else if(typeof e=="bigint")e=xo(e);else if(e.toArray)e=Buffer.from(e.toArray());else throw new Error("invalid type");return e}function Pm(e){return e=En(e),"0x"+e.toString("hex")}function Om(e,t){if(e=En(e),t||(t=256),t!==256)throw new Error("unsupported");return Buffer.from(xm(new Uint8Array(e)))}function So(e){return e.length%2?"0"+e:e}function Ao(e){return typeof e=="string"&&e.match(/^0x[0-9A-Fa-f]*$/)}function _o(e){return typeof e=="string"&&e.startsWith("0x")?e.slice(2):e}var Io={zeros:ko,setLength:Eo,setLengthRight:Im,isHexString:Ao,stripHexPrefix:_o,toBuffer:En,bufferToHex:Pm,keccak:Om,bitLengthFromBigInt:Am,bufferBEFromBigInt:xo,twosFromBigInt:_m};const ie=Io;function Po(e){return e.startsWith("int[")?"int256"+e.slice(3):e==="int"?"int256":e.startsWith("uint[")?"uint256"+e.slice(4):e==="uint"?"uint256":e.startsWith("fixed[")?"fixed128x128"+e.slice(5):e==="fixed"?"fixed128x128":e.startsWith("ufixed[")?"ufixed128x128"+e.slice(6):e==="ufixed"?"ufixed128x128":e}function it(e){return Number.parseInt(/^\D+(\d+)$/.exec(e)[1],10)}function $a(e){var t=/^\D+(\d+)x(\d+)$/.exec(e);return[Number.parseInt(t[1],10),Number.parseInt(t[2],10)]}function Oo(e){var t=e.match(/(.*)\[(.*?)\]$/);return t?t[2]===""?"dynamic":Number.parseInt(t[2],10):null}function qe(e){var t=typeof e;if(t==="string"||t==="number")return BigInt(e);if(t==="bigint")return e;throw new Error("Argument is not a number")}function xe(e,t){var n,r,a,s;if(e==="address")return xe("uint160",qe(t));if(e==="bool")return xe("uint8",t?1:0);if(e==="string")return xe("bytes",new Buffer(t,"utf8"));if(Tm(e)){if(typeof t.length>"u")throw new Error("Not an array?");if(n=Oo(e),n!=="dynamic"&&n!==0&&t.length>n)throw new Error("Elements exceed array size: "+n);a=[],e=e.slice(0,e.lastIndexOf("[")),typeof t=="string"&&(t=JSON.parse(t));for(s in t)a.push(xe(e,t[s]));if(n==="dynamic"){var i=xe("uint256",t.length);a.unshift(i)}return Buffer.concat(a)}else{if(e==="bytes")return t=new Buffer(t),a=Buffer.concat([xe("uint256",t.length),t]),t.length%32!==0&&(a=Buffer.concat([a,ie.zeros(32-t.length%32)])),a;if(e.startsWith("bytes")){if(n=it(e),n<1||n>32)throw new Error("Invalid bytes<N> width: "+n);return ie.setLengthRight(t,32)}else if(e.startsWith("uint")){if(n=it(e),n%8||n<8||n>256)throw new Error("Invalid uint<N> width: "+n);r=qe(t);const o=ie.bitLengthFromBigInt(r);if(o>n)throw new Error("Supplied uint exceeds width: "+n+" vs "+o);if(r<0)throw new Error("Supplied uint is negative");return ie.bufferBEFromBigInt(r,32)}else if(e.startsWith("int")){if(n=it(e),n%8||n<8||n>256)throw new Error("Invalid int<N> width: "+n);r=qe(t);const o=ie.bitLengthFromBigInt(r);if(o>n)throw new Error("Supplied int exceeds width: "+n+" vs "+o);const c=ie.twosFromBigInt(r,256);return ie.bufferBEFromBigInt(c,32)}else if(e.startsWith("ufixed")){if(n=$a(e),r=qe(t),r<0)throw new Error("Supplied ufixed is negative");return xe("uint256",r*BigInt(2)**BigInt(n[1]))}else if(e.startsWith("fixed"))return n=$a(e),xe("int256",qe(t)*BigInt(2)**BigInt(n[1]))}throw new Error("Unsupported or invalid type: "+e)}function Cm(e){return e==="string"||e==="bytes"||Oo(e)==="dynamic"}function Tm(e){return e.lastIndexOf("]")===e.length-1}function Nm(e,t){var n=[],r=[],a=32*e.length;for(var s in e){var i=Po(e[s]),o=t[s],c=xe(i,o);Cm(i)?(n.push(xe("uint256",a)),r.push(c),a+=c.length):n.push(c)}return Buffer.concat(n.concat(r))}function Co(e,t){if(e.length!==t.length)throw new Error("Number of types are not matching the values");for(var n,r,a=[],s=0;s<e.length;s++){var i=Po(e[s]),o=t[s];if(i==="bytes")a.push(o);else if(i==="string")a.push(new Buffer(o,"utf8"));else if(i==="bool")a.push(new Buffer(o?"01":"00","hex"));else if(i==="address")a.push(ie.setLength(o,20));else if(i.startsWith("bytes")){if(n=it(i),n<1||n>32)throw new Error("Invalid bytes<N> width: "+n);a.push(ie.setLengthRight(o,n))}else if(i.startsWith("uint")){if(n=it(i),n%8||n<8||n>256)throw new Error("Invalid uint<N> width: "+n);r=qe(o);const c=ie.bitLengthFromBigInt(r);if(c>n)throw new Error("Supplied uint exceeds width: "+n+" vs "+c);a.push(ie.bufferBEFromBigInt(r,n/8))}else if(i.startsWith("int")){if(n=it(i),n%8||n<8||n>256)throw new Error("Invalid int<N> width: "+n);r=qe(o);const c=ie.bitLengthFromBigInt(r);if(c>n)throw new Error("Supplied int exceeds width: "+n+" vs "+c);const u=ie.twosFromBigInt(r,n);a.push(ie.bufferBEFromBigInt(u,n/8))}else throw new Error("Unsupported or invalid type: "+i)}return Buffer.concat(a)}function Bm(e,t){return ie.keccak(Co(e,t))}var Lm={rawEncode:Nm,solidityPack:Co,soliditySHA3:Bm};const ye=Io,Ct=Lm,To={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"]},Cn={encodeData(e,t,n,r=!0){const a=["bytes32"],s=[this.hashType(e,n)];if(r){const i=(o,c,u)=>{if(n[c]!==void 0)return["bytes32",u==null?"0x0000000000000000000000000000000000000000000000000000000000000000":ye.keccak(this.encodeData(c,u,n,r))];if(u===void 0)throw new Error(`missing value for field ${o} of type ${c}`);if(c==="bytes")return["bytes32",ye.keccak(u)];if(c==="string")return typeof u=="string"&&(u=Buffer.from(u,"utf8")),["bytes32",ye.keccak(u)];if(c.lastIndexOf("]")===c.length-1){const d=c.slice(0,c.lastIndexOf("[")),l=u.map(p=>i(o,d,p));return["bytes32",ye.keccak(Ct.rawEncode(l.map(([p])=>p),l.map(([,p])=>p)))]}return[c,u]};for(const o of n[e]){const[c,u]=i(o.name,o.type,t[o.name]);a.push(c),s.push(u)}}else for(const i of n[e]){let o=t[i.name];if(o!==void 0)if(i.type==="bytes")a.push("bytes32"),o=ye.keccak(o),s.push(o);else if(i.type==="string")a.push("bytes32"),typeof o=="string"&&(o=Buffer.from(o,"utf8")),o=ye.keccak(o),s.push(o);else if(n[i.type]!==void 0)a.push("bytes32"),o=ye.keccak(this.encodeData(i.type,o,n,r)),s.push(o);else{if(i.type.lastIndexOf("]")===i.type.length-1)throw new Error("Arrays currently unimplemented in encodeData");a.push(i.type),s.push(o)}}return Ct.rawEncode(a,s)},encodeType(e,t){let n="",r=this.findTypeDependencies(e,t).filter(a=>a!==e);r=[e].concat(r.sort());for(const a of r){if(!t[a])throw new Error("No type definition specified: "+a);n+=a+"("+t[a].map(({name:i,type:o})=>o+" "+i).join(",")+")"}return n},findTypeDependencies(e,t,n=[]){if(e=e.match(/^\w*/)[0],n.includes(e)||t[e]===void 0)return n;n.push(e);for(const r of t[e])for(const a of this.findTypeDependencies(r.type,t,n))!n.includes(a)&&n.push(a);return n},hashStruct(e,t,n,r=!0){return ye.keccak(this.encodeData(e,t,n,r))},hashType(e,t){return ye.keccak(this.encodeType(e,t))},sanitizeData(e){const t={};for(const n in To.properties)e[n]&&(t[n]=e[n]);return t.types&&(t.types=Object.assign({EIP712Domain:[]},t.types)),t},hash(e,t=!0){const n=this.sanitizeData(e),r=[Buffer.from("1901","hex")];return r.push(this.hashStruct("EIP712Domain",n.domain,n.types,t)),n.primaryType!=="EIP712Domain"&&r.push(this.hashStruct(n.primaryType,n.message,n.types,t)),ye.keccak(Buffer.concat(r))}};var Rm={TYPED_MESSAGE_SCHEMA:To,TypedDataUtils:Cn,hashForSignTypedDataLegacy:function(e){return jm(e.data)},hashForSignTypedData_v3:function(e){return Cn.hash(e.data,!1)},hashForSignTypedData_v4:function(e){return Cn.hash(e.data)}};function jm(e){const t=new Error("Expect argument to be non-empty array");if(typeof e!="object"||!e.length)throw t;const n=e.map(function(s){return s.type==="bytes"?ye.toBuffer(s.value):s.value}),r=e.map(function(s){return s.type}),a=e.map(function(s){if(!s.name)throw t;return s.type+" "+s.name});return Ct.soliditySHA3(["bytes32","bytes32"],[Ct.soliditySHA3(new Array(e.length).fill("string"),a),Ct.soliditySHA3(r,n)])}const Jt=Es(Rm),Mm="walletUsername",wr="Addresses",Dm="AppVersion";class Um{constructor(t){this.secret=t}async encrypt(t){const n=this.secret;if(n.length!==64)throw new Error("secret must be 256 bits");const r=crypto.getRandomValues(new Uint8Array(12)),a=await crypto.subtle.importKey("raw",Zt(n),{name:"aes-gcm"},!1,["encrypt","decrypt"]),s=new TextEncoder,i=await window.crypto.subtle.encrypt({name:"AES-GCM",iv:r},a,s.encode(t)),o=16,c=i.slice(i.byteLength-o),u=i.slice(0,i.byteLength-o),d=new Uint8Array(c),l=new Uint8Array(u),p=new Uint8Array([...r,...d,...l]);return $r(p)}async decrypt(t){const n=this.secret;if(n.length!==64)throw new Error("secret must be 256 bits");return new Promise((r,a)=>{(async()=>{const s=await crypto.subtle.importKey("raw",Zt(n),{name:"aes-gcm"},!1,["encrypt","decrypt"]),i=Zt(t),o=i.slice(0,12),c=i.slice(12,28),u=i.slice(28),d=new Uint8Array([...u,...c]),l={name:"AES-GCM",iv:new Uint8Array(o)};try{const p=await window.crypto.subtle.decrypt(l,s,d),f=new TextDecoder;r(f.decode(p))}catch(p){a(p)}})()})}}class Fm{constructor(t,n,r){this.linkAPIUrl=t,this.sessionId=n;const a=`${n}:${r}`;this.auth=`Basic ${btoa(a)}`}async markUnseenEventsAsSeen(t){return Promise.all(t.map(n=>fetch(`${this.linkAPIUrl}/events/${n.eventId}/seen`,{method:"POST",headers:{Authorization:this.auth}}))).catch(n=>console.error("Unable to mark events as seen:",n))}async fetchUnseenEvents(){var t;const n=await fetch(`${this.linkAPIUrl}/events?unseen=true`,{headers:{Authorization:this.auth}});if(n.ok){const{events:r,error:a}=await n.json();if(a)throw new Error(`Check unseen events failed: ${a}`);const s=(t=r?.filter(i=>i.event==="Web3Response").map(i=>({type:"Event",sessionId:this.sessionId,eventId:i.id,event:i.event,data:i.data})))!==null&&t!==void 0?t:[];return this.markUnseenEventsAsSeen(s),s}throw new Error(`Check unseen events failed: ${n.status}`)}}var Ee;(function(e){e[e.DISCONNECTED=0]="DISCONNECTED",e[e.CONNECTING=1]="CONNECTING",e[e.CONNECTED=2]="CONNECTED"})(Ee||(Ee={}));class ue{setConnectionStateListener(t){this.connectionStateListener=t}setIncomingDataListener(t){this.incomingDataListener=t}constructor(t,n=WebSocket){this.WebSocketClass=n,this.webSocket=null,this.isDisconnecting=!1,this.url=t.replace(/^http/,"ws"),this.instanceId=ue.instanceCounter++,ue.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((t,n)=>{var r;let a;try{this.webSocket=a=new this.WebSocketClass(this.url)}catch(s){n(s);return}(r=this.connectionStateListener)===null||r===void 0||r.call(this,Ee.CONNECTING),a.onclose=s=>{var i;this.clearWebSocket(),a.readyState!==WebSocket.OPEN&&n(new Error(`websocket error ${s.code}: ${s.reason}`)),(i=this.connectionStateListener)===null||i===void 0||i.call(this,Ee.DISCONNECTED)},a.onopen=s=>{var i;t(),(i=this.connectionStateListener)===null||i===void 0||i.call(this,Ee.CONNECTED),ue.pendingData.length>0&&([...ue.pendingData].forEach(c=>this.sendData(c)),ue.pendingData=[])},a.onmessage=s=>{var i,o;if(s.data==="h")(i=this.incomingDataListener)===null||i===void 0||i.call(this,{type:"Heartbeat"});else try{const c=JSON.parse(s.data);(o=this.incomingDataListener)===null||o===void 0||o.call(this,c)}catch{}}})}disconnect(){var t;const{webSocket:n}=this;if(n){this.isDisconnecting=!0,this.clearWebSocket(),(t=this.connectionStateListener)===null||t===void 0||t.call(this,Ee.DISCONNECTED),this.connectionStateListener=void 0,this.incomingDataListener=void 0;try{n.close()}catch{}}}sendData(t){const{webSocket:n}=this;if(!n){ue.pendingData.push(t),this.isDisconnecting||this.connect();return}if(n.readyState!==WebSocket.OPEN){ue.pendingData.push(t);return}n.send(t)}clearWebSocket(){const{webSocket:t}=this;t&&(this.webSocket=null,t.onclose=null,t.onerror=null,t.onmessage=null,t.onopen=null)}cleanup(){ue.activeInstances.delete(this.instanceId)}}ue.instanceCounter=0;ue.activeInstances=new Set;ue.pendingData=[];const Ga=1e4,$m=6e4;class Gm{constructor({session:t,linkAPIUrl:n,listener:r}){this.destroyed=!1,this.lastHeartbeatResponse=0,this.nextReqId=Oe(1),this.reconnectAttempts=0,this.isReconnecting=!1,this._connected=!1,this._linked=!1,this.requestResolutions=new Map,this.handleSessionMetadataUpdated=s=>{if(!s)return;new Map([["__destroyed",this.handleDestroyed],["EthereumAddress",this.handleAccountUpdated],["WalletUsername",this.handleWalletUsernameUpdated],["AppVersion",this.handleAppVersionUpdated],["ChainId",o=>s.JsonRpcUrl&&this.handleChainUpdated(o,s.JsonRpcUrl)]]).forEach((o,c)=>{const u=s[c];u!==void 0&&o(u)})},this.handleDestroyed=s=>{var i;s==="1"&&((i=this.listener)===null||i===void 0||i.resetAndReload())},this.handleAccountUpdated=async s=>{var i;try{const o=await this.cipher.decrypt(s);(i=this.listener)===null||i===void 0||i.accountUpdated(o)}catch{}},this.handleMetadataUpdated=async(s,i)=>{var o;try{const c=await this.cipher.decrypt(i);(o=this.listener)===null||o===void 0||o.metadataUpdated(s,c)}catch{}},this.handleWalletUsernameUpdated=async s=>{this.handleMetadataUpdated(Mm,s)},this.handleAppVersionUpdated=async s=>{this.handleMetadataUpdated(Dm,s)},this.handleChainUpdated=async(s,i)=>{var o;try{const c=await this.cipher.decrypt(s),u=await this.cipher.decrypt(i);(o=this.listener)===null||o===void 0||o.chainUpdated(c,u)}catch{}},this.session=t,this.cipher=new Um(t.secret),this.listener=r,this.linkAPIUrl=n,this.WebSocketClass=WebSocket;const a=this.createWebSocket();this.ws=a,this.http=new Fm(n,t.id,t.key),this.setupVisibilityChangeHandler()}createWebSocket(){const t=new ue(`${this.linkAPIUrl}/rpc`,this.WebSocketClass);return this.activeWsInstance=t,t.setConnectionStateListener(async n=>{if(t!==this.activeWsInstance)return;let r=!1;switch(n){case Ee.DISCONNECTED:this.heartbeatIntervalId&&(clearInterval(this.heartbeatIntervalId),this.heartbeatIntervalId=void 0),this.lastHeartbeatResponse=0,r=!1,this.destroyed||(async()=>{if(this.isReconnecting)return;this.isReconnecting=!0;const s=this.reconnectAttempts===0?0:3e3;await new Promise(i=>setTimeout(i,s)),!this.destroyed&&t===this.activeWsInstance?(this.reconnectAttempts++,"cleanup"in this.ws&&typeof this.ws.cleanup=="function"&&this.ws.cleanup(),this.ws=this.createWebSocket(),this.ws.connect().catch(()=>{Da()}).finally(()=>{this.isReconnecting=!1})):this.isReconnecting=!1})();break;case Ee.CONNECTED:this.reconnectAttempts=0;try{r=await this.handleConnected(),this.fetchUnseenEventsAPI().catch(()=>{})}catch{break}this.connected=r,this.updateLastHeartbeat(),this.heartbeatIntervalId&&clearInterval(this.heartbeatIntervalId),this.heartbeatIntervalId=window.setInterval(()=>{this.heartbeat()},Ga),setTimeout(()=>{this.heartbeat()},100);break;case Ee.CONNECTING:break}n!==Ee.CONNECTED&&(this.connected=r)}),t.setIncomingDataListener(n=>{var r;switch(n.type){case"Heartbeat":this.updateLastHeartbeat();return;case"IsLinkedOK":case"Linked":{const a=n.type==="IsLinkedOK"?n.linked:void 0;this.linked=a||n.onlineGuests>0;break}case"GetSessionConfigOK":case"SessionConfigUpdated":{this.handleSessionMetadataUpdated(n.metadata);break}case"Event":{this.handleIncomingEvent(n);break}}n.id!==void 0&&((r=this.requestResolutions.get(n.id))===null||r===void 0||r(n))}),t}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",t=>{t.persisted&&this.focusHandler&&this.focusHandler()})}reconnectWithFreshWebSocket(){if(this.destroyed)return;const t=this.ws;this.activeWsInstance=void 0,t.disconnect(),"cleanup"in t&&typeof t.cleanup=="function"&&t.cleanup(),this.ws=this.createWebSocket(),this.ws.connect().catch(()=>{Da()})}connect(){if(this.destroyed)throw new Error("instance is destroyed");this.ws.connect()}async destroy(){this.destroyed||(await this.makeRequest({type:"SetSessionConfig",id:Oe(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(t){this._connected=t}get linked(){return this._linked}set linked(t){var n,r;this._linked=t,t&&((n=this.onceLinked)===null||n===void 0||n.call(this)),(r=this.listener)===null||r===void 0||r.linkedUpdated(t)}setOnceLinked(t){return new Promise(n=>{this.linked?t().then(n):this.onceLinked=()=>{t().then(n),this.onceLinked=void 0}})}async handleIncomingEvent(t){var n;if(!(t.type!=="Event"||t.event!=="Web3Response"))try{const r=await this.cipher.decrypt(t.data),a=JSON.parse(r);if(a.type!=="WEB3_RESPONSE")return;(n=this.listener)===null||n===void 0||n.handleWeb3ResponseMessage(a.id,a.response)}catch{}}async checkUnseenEvents(){await new Promise(t=>setTimeout(t,250));try{await this.fetchUnseenEventsAPI()}catch(t){console.error("Unable to check for unseen events",t)}}async fetchUnseenEventsAPI(){try{(await this.http.fetchUnseenEvents()).forEach(n=>{this.handleIncomingEvent(n)})}catch{fm()}}async publishEvent(t,n,r=!1){const a=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"}))),s={type:"PublishEvent",id:Oe(this.nextReqId++),sessionId:this.session.id,event:t,data:a,callWebhook:r};return this.setOnceLinked(async()=>{const i=await this.makeRequest(s);if(i.type==="Fail")throw new Error(i.error||"failed to publish event");return i.eventId})}sendData(t){this.ws.sendData(JSON.stringify(t))}updateLastHeartbeat(){this.lastHeartbeatResponse=Date.now()}heartbeat(){if(Date.now()-this.lastHeartbeatResponse>Ga*2){this.ws.disconnect();return}if(this.connected)try{this.ws.sendData("h")}catch{}}async makeRequest(t,n={timeout:$m}){const r=t.id;this.sendData(t);let a;return Promise.race([new Promise((s,i)=>{a=window.setTimeout(()=>{i(new Error(`request ${r} timed out`))},n.timeout)}),new Promise(s=>{this.requestResolutions.set(r,i=>{clearTimeout(a),s(i),this.requestResolutions.delete(r)})})])}async handleConnected(){return(await this.makeRequest({type:"HostSession",id:Oe(this.nextReqId++),sessionId:this.session.id,sessionKey:this.session.key})).type==="Fail"?!1:(this.sendData({type:"IsLinked",id:Oe(this.nextReqId++),sessionId:this.session.id}),this.sendData({type:"GetSessionConfig",id:Oe(this.nextReqId++),sessionId:this.session.id}),!0)}}class Hm{constructor(){this._nextRequestId=0,this.callbacks=new Map}makeRequestId(){this._nextRequestId=(this._nextRequestId+1)%2147483647;const t=this._nextRequestId,n=ki(t.toString(16));return this.callbacks.get(n)&&this.callbacks.delete(n),t}}function zm(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function Jr(e,...t){if(!zm(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function Ha(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function qm(e,t){Jr(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Tn=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),ke=(e,t)=>e<<32-t|e>>>t;new Uint8Array(new Uint32Array([287454020]).buffer)[0];const Wm=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Vm(e){Jr(e);let t="";for(let n=0;n<e.length;n++)t+=Wm[e[n]];return t}function Km(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function No(e){return typeof e=="string"&&(e=Km(e)),Jr(e),e}class Jm{clone(){return this._cloneInto()}}function Zm(e){const t=r=>e().update(No(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Ym(e,t,n,r){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,n,r);const a=BigInt(32),s=BigInt(4294967295),i=Number(n>>a&s),o=Number(n&s),c=r?4:0,u=r?0:4;e.setUint32(t+c,i,r),e.setUint32(t+u,o,r)}const Qm=(e,t,n)=>e&t^~e&n,Xm=(e,t,n)=>e&t^e&n^t&n;class eh extends Jm{constructor(t,n,r,a){super(),this.blockLen=t,this.outputLen=n,this.padOffset=r,this.isLE=a,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=Tn(this.buffer)}update(t){Ha(this);const{view:n,buffer:r,blockLen:a}=this;t=No(t);const s=t.length;for(let i=0;i<s;){const o=Math.min(a-this.pos,s-i);if(o===a){const c=Tn(t);for(;a<=s-i;i+=a)this.process(c,i);continue}r.set(t.subarray(i,i+o),this.pos),this.pos+=o,i+=o,this.pos===a&&(this.process(n,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Ha(this),qm(t,this),this.finished=!0;const{buffer:n,view:r,blockLen:a,isLE:s}=this;let{pos:i}=this;n[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>a-i&&(this.process(r,0),i=0);for(let l=i;l<a;l++)n[l]=0;Ym(r,a-8,BigInt(this.length*8),s),this.process(r,0);const o=Tn(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=c/4,d=this.get();if(u>d.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<u;l++)o.setUint32(4*l,d[l],s)}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const r=t.slice(0,n);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:n,buffer:r,length:a,finished:s,destroyed:i,pos:o}=this;return t.length=a,t.pos=o,t.finished=s,t.destroyed=i,a%n&&t.buffer.set(r),t}}const th=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Be=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Le=new Uint32Array(64);class nh extends eh{constructor(){super(64,32,8,!1),this.A=Be[0]|0,this.B=Be[1]|0,this.C=Be[2]|0,this.D=Be[3]|0,this.E=Be[4]|0,this.F=Be[5]|0,this.G=Be[6]|0,this.H=Be[7]|0}get(){const{A:t,B:n,C:r,D:a,E:s,F:i,G:o,H:c}=this;return[t,n,r,a,s,i,o,c]}set(t,n,r,a,s,i,o,c){this.A=t|0,this.B=n|0,this.C=r|0,this.D=a|0,this.E=s|0,this.F=i|0,this.G=o|0,this.H=c|0}process(t,n){for(let l=0;l<16;l++,n+=4)Le[l]=t.getUint32(n,!1);for(let l=16;l<64;l++){const p=Le[l-15],f=Le[l-2],y=ke(p,7)^ke(p,18)^p>>>3,g=ke(f,17)^ke(f,19)^f>>>10;Le[l]=g+Le[l-7]+y+Le[l-16]|0}let{A:r,B:a,C:s,D:i,E:o,F:c,G:u,H:d}=this;for(let l=0;l<64;l++){const p=ke(o,6)^ke(o,11)^ke(o,25),f=d+p+Qm(o,c,u)+th[l]+Le[l]|0,g=(ke(r,2)^ke(r,13)^ke(r,22))+Xm(r,a,s)|0;d=u,u=c,c=o,o=i+f|0,i=s,s=a,a=r,r=f+g|0}r=r+this.A|0,a=a+this.B|0,s=s+this.C|0,i=i+this.D|0,o=o+this.E|0,c=c+this.F|0,u=u+this.G|0,d=d+this.H|0,this.set(r,a,s,i,o,c,u,d)}roundClean(){Le.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const rh=Zm(()=>new nh),za="session:id",qa="session:secret",Wa="session:linked";class ot{constructor(t,n,r,a=!1){this.storage=t,this.id=n,this.secret=r,this.key=Vm(rh(`${n}, ${r} WalletLink`)),this._linked=!!a}static create(t){const n=He(16),r=He(32);return new ot(t,n,r).save()}static load(t){const n=t.getItem(za),r=t.getItem(Wa),a=t.getItem(qa);return n&&a?new ot(t,n,a,r==="1"):null}get linked(){return this._linked}set linked(t){this._linked=t,this.persistLinked()}save(){return this.storage.setItem(za,this.id),this.storage.setItem(qa,this.secret),this.persistLinked(),this}persistLinked(){this.storage.setItem(Wa,this._linked?"1":"0")}}const ah=".-cbwsdk-css-reset .-cbwsdk-redirect-dialog-backdrop{position:fixed;top:0;left:0;right:0;bottom:0;transition:opacity .25s;background-color:rgba(10,11,13,.5)}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-backdrop-hidden{opacity:0}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box{display:block;position:fixed;top:50%;left:50%;transform:translate(-50%, -50%);padding:20px;border-radius:8px;background-color:#fff;color:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box p{display:block;font-weight:400;font-size:14px;line-height:20px;padding-bottom:12px;color:#5b636e}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box button{appearance:none;border:none;background:none;color:#0052ff;padding:0;text-decoration:none;display:block;font-weight:600;font-size:16px;line-height:24px}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.dark{background-color:#0a0b0d;color:#fff}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.dark button{color:#0052ff}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.light{background-color:#fff;color:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.light button{color:#0052ff}";class sh{constructor(){this.root=null,this.darkMode=Ai()}attach(){const t=document.documentElement;this.root=document.createElement("div"),this.root.className="-cbwsdk-css-reset",t.appendChild(this.root),Ei()}present(t){this.render(t)}clear(){this.render(null)}render(t){this.root&&(Nn(null,this.root),t&&Nn(J(ih,Object.assign({},t,{onDismiss:()=>{this.clear()},darkMode:this.darkMode})),this.root))}}const ih=({title:e,buttonText:t,darkMode:n,onButtonClick:r,onDismiss:a})=>{const s=n?"dark":"light";return J(Ii,{darkMode:n},J("div",{class:"-cbwsdk-redirect-dialog"},J("style",null,ah),J("div",{class:"-cbwsdk-redirect-dialog-backdrop",onClick:a}),J("div",{class:Ot("-cbwsdk-redirect-dialog-box",s)},J("p",null,e),J("button",{onClick:r},t))))};class Va{constructor(){this.attached=!1,this.redirectDialog=new sh}attach(){if(this.attached)throw new Error("Coinbase Wallet SDK UI is already attached");this.redirectDialog.attach(),this.attached=!0}redirectToCoinbaseWallet(t){const n=new URL(Cf);n.searchParams.append("redirect_url",jf().href),t&&n.searchParams.append("wl_url",t);const r=document.createElement("a");r.target="cbw-opener",r.href=n.href,r.rel="noreferrer noopener",r.click()}openCoinbaseWalletDeeplink(t){this.redirectToCoinbaseWallet(t),setTimeout(()=>{this.redirectDialog.present({title:"Redirecting to Coinbase Wallet...",buttonText:"Open",onButtonClick:()=>{this.redirectToCoinbaseWallet(t)}})},99)}showConnecting(t){return()=>{this.redirectDialog.clear()}}}class Ce{constructor(t){this.chainCallbackParams={chainId:"",jsonRpcUrl:""},this.isMobileWeb=Mf(),this.linkedUpdated=s=>{this.isLinked=s;const i=this.storage.getItem(wr);if(s&&(this._session.linked=s),this.isUnlinkedErrorState=!1,i){const o=i.split(" "),c=this.storage.getItem("IsStandaloneSigning")==="true";o[0]!==""&&!s&&this._session.linked&&!c&&(this.isUnlinkedErrorState=!0)}},this.metadataUpdated=(s,i)=>{this.storage.setItem(s,i)},this.chainUpdated=(s,i)=>{this.chainCallbackParams.chainId===s&&this.chainCallbackParams.jsonRpcUrl===i||(this.chainCallbackParams={chainId:s,jsonRpcUrl:i},this.chainCallback&&this.chainCallback(i,Number.parseInt(s,10)))},this.accountUpdated=s=>{this.accountsCallback&&this.accountsCallback([s]),Ce.accountRequestCallbackIds.size>0&&(Array.from(Ce.accountRequestCallbackIds.values()).forEach(i=>{this.invokeCallback(i,{method:"requestEthereumAccounts",result:[s]})}),Ce.accountRequestCallbackIds.clear())},this.resetAndReload=this.resetAndReload.bind(this),this.linkAPIUrl=t.linkAPIUrl,this.storage=t.storage,this.metadata=t.metadata,this.accountsCallback=t.accountsCallback,this.chainCallback=t.chainCallback;const{session:n,ui:r,connection:a}=this.subscribe();this._session=n,this.connection=a,this.relayEventManager=new Hm,this.ui=r,this.ui.attach()}subscribe(){const t=ot.load(this.storage)||ot.create(this.storage),{linkAPIUrl:n}=this,r=new Gm({session:t,linkAPIUrl:n,listener:this}),a=this.isMobileWeb?new Va:new Gf;return r.connect(),{session:t,ui:a,connection:r}}resetAndReload(){this.connection.destroy().then(()=>{const t=ot.load(this.storage);t?.id===this._session.id&&Ze.clearAll(),document.location.reload()}).catch(t=>{})}signEthereumTransaction(t){return this.sendRequest({method:"signEthereumTransaction",params:{fromAddress:t.fromAddress,toAddress:t.toAddress,weiValue:ve(t.weiValue),data:_t(t.data,!0),nonce:t.nonce,gasPriceInWei:t.gasPriceInWei?ve(t.gasPriceInWei):null,maxFeePerGas:t.gasPriceInWei?ve(t.gasPriceInWei):null,maxPriorityFeePerGas:t.gasPriceInWei?ve(t.gasPriceInWei):null,gasLimit:t.gasLimit?ve(t.gasLimit):null,chainId:t.chainId,shouldSubmit:!1}})}signAndSubmitEthereumTransaction(t){return this.sendRequest({method:"signEthereumTransaction",params:{fromAddress:t.fromAddress,toAddress:t.toAddress,weiValue:ve(t.weiValue),data:_t(t.data,!0),nonce:t.nonce,gasPriceInWei:t.gasPriceInWei?ve(t.gasPriceInWei):null,maxFeePerGas:t.maxFeePerGas?ve(t.maxFeePerGas):null,maxPriorityFeePerGas:t.maxPriorityFeePerGas?ve(t.maxPriorityFeePerGas):null,gasLimit:t.gasLimit?ve(t.gasLimit):null,chainId:t.chainId,shouldSubmit:!0}})}submitEthereumTransaction(t,n){return this.sendRequest({method:"submitEthereumTransaction",params:{signedTransaction:_t(t,!0),chainId:n}})}getWalletLinkSession(){return this._session}sendRequest(t){let n=null;const r=He(8),a=s=>{this.publishWeb3RequestCanceledEvent(r),this.handleErrorResponse(r,t.method,s),n?.()};return new Promise((s,i)=>{n=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:a,onResetConnection:this.resetAndReload}),this.relayEventManager.callbacks.set(r,o=>{if(n?.(),ae(o))return i(new Error(o.errorMessage));s(o)}),this.publishWeb3RequestEvent(r,t)})}publishWeb3RequestEvent(t,n){const r={type:"WEB3_REQUEST",id:t,request:n};this.publishEvent("Web3Request",r,!0).then(a=>{}).catch(a=>{this.handleWeb3ResponseMessage(r.id,{method:n.method,errorMessage:a.message})}),this.isMobileWeb&&this.openCoinbaseWalletDeeplink(n.method)}openCoinbaseWalletDeeplink(t){if(this.ui instanceof Va)switch(t){case"requestEthereumAccounts":case"switchEthereumChain":return;default:window.addEventListener("blur",()=>{window.addEventListener("focus",()=>{this.connection.checkUnseenEvents()},{once:!0})},{once:!0}),this.ui.openCoinbaseWalletDeeplink();break}}publishWeb3RequestCanceledEvent(t){const n={type:"WEB3_REQUEST_CANCELED",id:t};this.publishEvent("Web3RequestCanceled",n,!1).then()}publishEvent(t,n,r){return this.connection.publishEvent(t,n,r)}handleWeb3ResponseMessage(t,n){if(n.method==="requestEthereumAccounts"){Ce.accountRequestCallbackIds.forEach(r=>this.invokeCallback(r,n)),Ce.accountRequestCallbackIds.clear();return}this.invokeCallback(t,n)}handleErrorResponse(t,n,r){var a;const s=(a=r?.message)!==null&&a!==void 0?a:"Unspecified error message.";this.handleWeb3ResponseMessage(t,{method:n,errorMessage:s})}invokeCallback(t,n){const r=this.relayEventManager.callbacks.get(t);r&&(r(n),this.relayEventManager.callbacks.delete(t))}requestEthereumAccounts(){const{appName:t,appLogoUrl:n}=this.metadata,r={method:"requestEthereumAccounts",params:{appName:t,appLogoUrl:n}},a=He(8);return new Promise((s,i)=>{this.relayEventManager.callbacks.set(a,o=>{if(ae(o))return i(new Error(o.errorMessage));s(o)}),Ce.accountRequestCallbackIds.add(a),this.publishWeb3RequestEvent(a,r)})}watchAsset(t,n,r,a,s,i){const o={method:"watchAsset",params:{type:t,options:{address:n,symbol:r,decimals:a,image:s},chainId:i}};let c=null;const u=He(8),d=l=>{this.publishWeb3RequestCanceledEvent(u),this.handleErrorResponse(u,o.method,l),c?.()};return c=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:d,onResetConnection:this.resetAndReload}),new Promise((l,p)=>{this.relayEventManager.callbacks.set(u,f=>{if(c?.(),ae(f))return p(new Error(f.errorMessage));l(f)}),this.publishWeb3RequestEvent(u,o)})}addEthereumChain(t,n,r,a,s,i){const o={method:"addEthereumChain",params:{chainId:t,rpcUrls:n,blockExplorerUrls:a,chainName:s,iconUrls:r,nativeCurrency:i}};let c=null;const u=He(8),d=l=>{this.publishWeb3RequestCanceledEvent(u),this.handleErrorResponse(u,o.method,l),c?.()};return c=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:d,onResetConnection:this.resetAndReload}),new Promise((l,p)=>{this.relayEventManager.callbacks.set(u,f=>{if(c?.(),ae(f))return p(new Error(f.errorMessage));l(f)}),this.publishWeb3RequestEvent(u,o)})}switchEthereumChain(t,n){const r={method:"switchEthereumChain",params:Object.assign({chainId:t},{address:n})};let a=null;const s=He(8),i=o=>{this.publishWeb3RequestCanceledEvent(s),this.handleErrorResponse(s,r.method,o),a?.()};return a=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:i,onResetConnection:this.resetAndReload}),new Promise((o,c)=>{this.relayEventManager.callbacks.set(s,u=>{if(a?.(),ae(u)&&u.errorCode)return c(_.provider.custom({code:u.errorCode,message:"Unrecognized chain ID. Try adding the chain using addEthereumChain first."}));if(ae(u))return c(new Error(u.errorMessage));o(u)}),this.publishWeb3RequestEvent(s,r)})}}Ce.accountRequestCallbackIds=new Set;const Ka="DefaultChainId",Ja="DefaultJsonRpcUrl";class Bo{constructor(t){this._relay=null,this._addresses=[],this.metadata=t.metadata,this._storage=new Ze("walletlink",Pa),this.callback=t.callback||null;const n=this._storage.getItem(wr);if(n){const r=n.split(" ");r[0]!==""&&(this._addresses=r.map(a=>Ne(a)))}this.initializeRelay()}getSession(){const t=this.initializeRelay(),{id:n,secret:r}=t.getWalletLinkSession();return{id:n,secret:r}}async handshake(t){const n="eth_requestAccounts",r=ge.get(t);im({method:n,correlationId:r});try{await this._eth_requestAccounts(),cm({method:n,correlationId:r})}catch(a){throw om({method:n,correlationId:r,errorMessage:ze(a)}),a}}get selectedAddress(){return this._addresses[0]||void 0}get jsonRpcUrl(){var t;return(t=this._storage.getItem(Ja))!==null&&t!==void 0?t:void 0}set jsonRpcUrl(t){this._storage.setItem(Ja,t)}updateProviderInfo(t,n){var r;this.jsonRpcUrl=t;const a=this.getChainId();this._storage.setItem(Ka,n.toString(10)),It(n)!==a&&((r=this.callback)===null||r===void 0||r.call(this,"chainChanged",at(n)))}async watchAsset(t){const n=Array.isArray(t)?t[0]:t;if(!n.type)throw _.rpc.invalidParams("Type is required");if(n?.type!=="ERC20")throw _.rpc.invalidParams(`Asset of type '${n.type}' is not supported`);if(!n?.options)throw _.rpc.invalidParams("Options are required");if(!n?.options.address)throw _.rpc.invalidParams("Address is required");const r=this.getChainId(),{address:a,symbol:s,image:i,decimals:o}=n.options,u=await this.initializeRelay().watchAsset(n.type,a,s,o,i,r?.toString());return ae(u)?!1:!!u.result}async addEthereumChain(t){var n,r;const a=t[0];if(((n=a.rpcUrls)===null||n===void 0?void 0:n.length)===0)throw _.rpc.invalidParams("please pass in at least 1 rpcUrl");if(!a.chainName||a.chainName.trim()==="")throw _.rpc.invalidParams("chainName is a required field");if(!a.nativeCurrency)throw _.rpc.invalidParams("nativeCurrency is a required field");const s=Number.parseInt(a.chainId,16);if(s===this.getChainId())return!1;const i=this.initializeRelay(),{rpcUrls:o=[],blockExplorerUrls:c=[],chainName:u,iconUrls:d=[],nativeCurrency:l}=a,p=await i.addEthereumChain(s.toString(),o,d,c,u,l);if(ae(p))return!1;if(((r=p.result)===null||r===void 0?void 0:r.isApproved)===!0)return this.updateProviderInfo(o[0],s),null;throw _.rpc.internal("unable to add ethereum chain")}async switchEthereumChain(t){const n=t[0],r=Number.parseInt(n.chainId,16),s=await this.initializeRelay().switchEthereumChain(r.toString(10),this.selectedAddress||void 0);if(ae(s))throw s;const i=s.result;return i.isApproved&&i.rpcUrl.length>0&&this.updateProviderInfo(i.rpcUrl,r),null}async cleanup(){this.callback=null,this._relay&&this._relay.resetAndReload(),this._storage.clear()}_setAddresses(t,n){var r;if(!Array.isArray(t))throw new Error("addresses is not an array");const a=t.map(s=>Ne(s));JSON.stringify(a)!==JSON.stringify(this._addresses)&&(this._addresses=a,(r=this.callback)===null||r===void 0||r.call(this,"accountsChanged",a),this._storage.setItem(wr,a.join(" ")))}async request(t){const n=ge.get(t);um({method:t.method,correlationId:n});try{const r=await this._request(t);return lm({method:t.method,correlationId:n}),r}catch(r){throw dm({method:t.method,correlationId:n,errorMessage:ze(r)}),r}}async _request(t){const n=t.params||[];switch(t.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 at(this.getChainId());case"eth_requestAccounts":return this._eth_requestAccounts();case"eth_ecRecover":case"personal_ecRecover":return this.ecRecover(t);case"personal_sign":return this.personalSign(t);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(t);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 _.rpc.internal("No RPC URL set for chain");return Pt(t,this.jsonRpcUrl)}}_ensureKnownAddress(t){const n=Ne(t);if(!this._addresses.map(a=>Ne(a)).includes(n))throw new Error("Unknown Ethereum address")}_prepareTransactionParams(t){const n=t.from?Ne(t.from):this.selectedAddress;if(!n)throw new Error("Ethereum address is unavailable");this._ensureKnownAddress(n);const r=t.to?Ne(t.to):null,a=t.value!=null?wt(t.value):BigInt(0),s=t.data?yr(t.data):Buffer.alloc(0),i=t.nonce!=null?It(t.nonce):null,o=t.gasPrice!=null?wt(t.gasPrice):null,c=t.maxFeePerGas!=null?wt(t.maxFeePerGas):null,u=t.maxPriorityFeePerGas!=null?wt(t.maxPriorityFeePerGas):null,d=t.gas!=null?wt(t.gas):null,l=t.chainId?It(t.chainId):this.getChainId();return{fromAddress:n,toAddress:r,weiValue:a,data:s,nonce:i,gasPriceInWei:o,maxFeePerGas:c,maxPriorityFeePerGas:u,gasLimit:d,chainId:l}}async ecRecover(t){const{method:n,params:r}=t;if(!Array.isArray(r))throw _.rpc.invalidParams();const s=await this.initializeRelay().sendRequest({method:"ethereumAddressFromSignedMessage",params:{message:In(r[0]),signature:In(r[1]),addPrefix:n==="personal_ecRecover"}});if(ae(s))throw s;return s.result}getChainId(){var t;return Number.parseInt((t=this._storage.getItem(Ka))!==null&&t!==void 0?t:"1",10)}async _eth_requestAccounts(){var t,n;if(this._addresses.length>0)return(t=this.callback)===null||t===void 0||t.call(this,"connect",{chainId:at(this.getChainId())}),this._addresses;const a=await this.initializeRelay().requestEthereumAccounts();if(ae(a))throw a;if(!a.result)throw new Error("accounts received is empty");return this._setAddresses(a.result),(n=this.callback)===null||n===void 0||n.call(this,"connect",{chainId:at(this.getChainId())}),this._addresses}async personalSign({params:t}){if(!Array.isArray(t))throw _.rpc.invalidParams();const n=t[1],r=t[0];this._ensureKnownAddress(n);const s=await this.initializeRelay().sendRequest({method:"signEthereumMessage",params:{address:Ne(n),message:In(r),addPrefix:!0,typedDataJson:null}});if(ae(s))throw s;return s.result}async _eth_signTransaction(t){const n=this._prepareTransactionParams(t[0]||{}),a=await this.initializeRelay().signEthereumTransaction(n);if(ae(a))throw a;return a.result}async _eth_sendRawTransaction(t){const n=yr(t[0]),a=await this.initializeRelay().submitEthereumTransaction(n,this.getChainId());if(ae(a))throw a;return a.result}async _eth_sendTransaction(t){const n=this._prepareTransactionParams(t[0]||{}),a=await this.initializeRelay().signAndSubmitEthereumTransaction(n);if(ae(a))throw a;return a.result}async signTypedData(t){const{method:n,params:r}=t;if(!Array.isArray(r))throw _.rpc.invalidParams();const a=u=>{const d={eth_signTypedData_v1:Jt.hashForSignTypedDataLegacy,eth_signTypedData_v3:Jt.hashForSignTypedData_v3,eth_signTypedData_v4:Jt.hashForSignTypedData_v4,eth_signTypedData:Jt.hashForSignTypedData_v4};return _t(d[n]({data:bf(u)}),!0)},s=r[n==="eth_signTypedData_v1"?1:0],i=r[n==="eth_signTypedData_v1"?0:1];this._ensureKnownAddress(s);const c=await this.initializeRelay().sendRequest({method:"signEthereumMessage",params:{address:Ne(s),message:a(i),typedDataJson:JSON.stringify(i,null,2),addPrefix:!1}});if(ae(c))throw c;return c.result}initializeRelay(){return this._relay||(this._relay=new Ce({linkAPIUrl:Pa,storage:this._storage,metadata:this.metadata,accountsCallback:this._setAddresses.bind(this),chainCallback:this.updateProviderInfo.bind(this)})),this._relay}}const Lo="SignerType",Ro=new Ze("CBWSDK","SignerConfigurator");function oh(){return Ro.getItem(Lo)}function ch(e){Ro.setItem(Lo,e)}function Za(e){if(e)return e instanceof $i?"scw":"walletlink"}async function uh(e){const{communicator:t,metadata:n,handshakeRequest:r,callback:a}=e;lh(t,n,a,r).catch(()=>{});const s={id:crypto.randomUUID(),event:"selectSignerType",data:Object.assign(Object.assign({},e.preference),{handshakeRequest:r})},{data:i}=await t.postRequestAndWaitForResponse(s);return i}function dh(e){const{signerType:t,metadata:n,communicator:r,callback:a}=e;switch(t){case"scw":return new $i({metadata:n,callback:a,communicator:r});case"walletlink":return new Bo({metadata:n,callback:a})}}async function lh(e,t,n,r){await e.onMessage(({event:s})=>s==="WalletLinkSessionRequest");const a=new Bo({metadata:t,callback:n});e.postMessage({event:"WalletLinkUpdate",data:{session:a.getSession()}}),await a.handshake(r),e.postMessage({event:"WalletLinkUpdate",data:{connected:!0}})}var fh=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,r=Object.getOwnPropertySymbols(e);a<r.length;a++)t.indexOf(r[a])<0&&Object.prototype.propertyIsEnumerable.call(e,r[a])&&(n[r[a]]=e[r[a]]);return n};class ph extends Xf{constructor(t){var{metadata:n}=t,r=t.preference,{keysUrl:a}=r,s=fh(r,["keysUrl"]);super(),this.signer=null,this.isCoinbaseWallet=!0,this.metadata=n,this.preference=s,this.communicator=new Kf({url:a,metadata:n,preference:s});const i=oh();i&&(this.signer=this.initSigner(i),ep({signerType:i}))}async request(t){const n=crypto.randomUUID();ge.set(t,n),tp({method:t.method,correlationId:n});try{const r=await this._request(t);return rp({method:t.method,signerType:Za(this.signer),correlationId:n}),r}catch(r){throw np({method:t.method,correlationId:n,signerType:Za(this.signer),errorMessage:r instanceof Error?r.message:""}),r}finally{ge.delete(t)}}async _request(t){try{if(If(t),!this.signer)switch(t.method){case"eth_requestAccounts":{let r;const a=T.subAccountsConfig.get();a?.enableAutoSubAccounts?r="scw":r=await this.requestSignerSelection(t);const s=this.initSigner(r);r==="scw"&&a?.enableAutoSubAccounts?(await s.handshake({method:"handshake"}),await s.request(t)):await s.handshake(t),this.signer=s,ch(r);break}case"wallet_connect":{const r=this.initSigner("scw");await r.handshake({method:"handshake"});const a=await r.request(t);return this.signer=r,a}case"wallet_sendCalls":case"wallet_sign":{const r=this.initSigner("scw");await r.handshake({method:"handshake"});const a=await r.request(t);return await r.cleanup(),a}case"wallet_getCallsStatus":return await Pt(t,xi);case"net_version":return 1;case"eth_chainId":return at(1);default:throw _.provider.unauthorized("Must call 'eth_requestAccounts' before other methods")}return await this.signer.request(t)}catch(n){const{code:r}=n;return r===Q.provider.unauthorized&&this.disconnect(),Promise.reject(Jf(n))}}async enable(){return console.warn('.enable() has been deprecated. Please use .request({ method: "eth_requestAccounts" }) instead.'),ap(),await this.request({method:"eth_requestAccounts"})}async disconnect(){var t;await((t=this.signer)===null||t===void 0?void 0:t.cleanup()),this.signer=null,Ze.clearAll(),ge.clear(),this.emit("disconnect",_.provider.disconnected("User initiated disconnection"))}async requestSignerSelection(t){sp();const n=await uh({communicator:this.communicator,preference:this.preference,metadata:this.metadata,handshakeRequest:t,callback:this.emit.bind(this)});return ip(n),n}initSigner(t){return dh({signerType:t,metadata:this.metadata,communicator:this.communicator,callback:this.emit.bind(this)})}}function mh(e){var t;const n={metadata:e.metadata,preference:e.preference};return(t=_f(n))!==null&&t!==void 0?t:new ph(n)}const hh={options:"all"};function xh(e){var t,n,r,a;const s={metadata:{appName:e.appName||"Dapp",appLogoUrl:e.appLogoUrl||"",appChainIds:e.appChainIds||[]},preference:Object.assign(hh,(t=e.preference)!==null&&t!==void 0?t:{}),paymasterUrls:e.paymasterUrls};!((n=e.subAccounts)===null||n===void 0)&&n.toOwnerAccount&&Ia(e.subAccounts.toOwnerAccount),T.subAccountsConfig.set({toOwnerAccount:(r=e.subAccounts)===null||r===void 0?void 0:r.toOwnerAccount,enableAutoSubAccounts:(a=e.subAccounts)===null||a===void 0?void 0:a.enableAutoSubAccounts}),T.config.set(s),T.persist.rehydrate(),xf(),s.preference.telemetry!==!1&&df(),Pf(s.preference);let i=null;const o={getProvider(){return i||(i=mh(s)),i.sdk=o,i},subAccount:{async create(c){var u,d;const l=T.getState();return le((u=l.subAccount)===null||u===void 0?void 0:u.address,new Error("subaccount already exists")),await((d=o.getProvider())===null||d===void 0?void 0:d.request({method:"wallet_addSubAccount",params:[{version:"1",account:c}]}))},async get(){var c,u;const d=T.subAccounts.get();if(d?.address)return d;const p=(u=(await((c=o.getProvider())===null||c===void 0?void 0:c.request({method:"wallet_connect",params:[{version:"1",capabilities:{}}]}))).accounts[0].capabilities)===null||u===void 0?void 0:u.subAccounts;return Array.isArray(p)?p[0]:null},async addOwner({address:c,publicKey:u,chainId:d}){var l,p;const f=T.subAccounts.get(),y=T.account.get();le(y,new Error("account does not exist")),le(f?.address,new Error("subaccount does not exist"));const g=[];if(u){const[h,w]=As([{type:"bytes32"},{type:"bytes32"}],u);g.push({to:f.address,data:oe({abi:be,functionName:"addOwnerPublicKey",args:[h,w]}),value:Te(0)})}return c&&g.push({to:f.address,data:oe({abi:be,functionName:"addOwnerAddress",args:[c]}),value:Te(0)}),await((l=o.getProvider())===null||l===void 0?void 0:l.request({method:"wallet_sendCalls",params:[{calls:g,chainId:Te(d),from:(p=y.accounts)===null||p===void 0?void 0:p[0],version:"1"}]}))},setToOwnerAccount(c){Ia(c),T.subAccountsConfig.set({toOwnerAccount:c})}}};return o}export{xh as createCoinbaseWalletSDK,gr as getCryptoKeyAccount};
|