PageSourceSearch

https://swapnil-three.vercel.app/assets/index-CtDmhhgT.js

js swapnil-three.vercel.app collected 2026-10-03 07:49:43 UTC 252,950 bytes, 4 lines download raw bytes

1import{B as _t,_ as O,h as Xt,y as $i}from"./hooks.module-Cpp96UEK.js";import{a as qn,d as zi,h as en,i as at,b as xe,n as q,s as Wi,k as qi,t as Ae,C as it,w as Fn,f as tn,j as St,l as nn,e as me,o as Kn,B as Vn,r as Gn,u as Fi,p as Ki,q as Vi,v as rn,x as Gi,F as sn,y as an,z as Ji,A as Jn,G as Yi,D as pt,E as Qi}from"./index-CLXpZXZ3.js";import{c as Zi,a as Xi,p as on,t as es,e as ts,b as ns,g as rs,d as is}from"./p256-pETEhcyX.js";import{c as ss,s as as,d as os,g as cs}from"./index-nibyPLVP.js";import{a as Mt,h as Yn}from"./hashTypedData-CivHu3kD.js";import"./verifyHash-BTW4LVAp.js";function Qn(e,t){let n;try{n=e()}catch{return}return{getItem:i=>{var s;const a=c=>c===null?null:JSON.parse(c,void 0),o=(s=n.getItem(i))!=null?s:null;return o instanceof Promise?o.then(a):a(o)},setItem:(i,s)=>n.setItem(i,JSON.stringify(s,void 0)),removeItem:i=>n.removeItem(i)}}const xt=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(r){return xt(r)(n)},catch(r){return this}}}catch(n){return{then(r){return this},catch(r){return xt(r)(n)}}}},us=(e,t)=>(n,r,i)=>{let s={storage:Qn(()=>localStorage),partialize:b=>b,version:0,merge:(b,m)=>({...m,...b}),...t},a=!1;const o=new Set,c=new Set;let u=s.storage;if(!u)return e((...b)=>{console.warn(`[zustand persist middleware] Unable to update item '${s.name}', the given storage is currently unavailable.`),n(...b)},r,i);const d=()=>{const b=s.partialize({...r()});return u.setItem(s.name,{state:b,version:s.version})},l=i.setState;i.setState=(b,m)=>{l(b,m),d()};const h=e((...b)=>{n(...b),d()},r,i);i.getInitialState=()=>h;let f;const y=()=>{var b,m;if(!u)return;a=!1,o.forEach(E=>{var k;return E((k=r())!=null?k:h)});const v=((m=s.onRehydrateStorage)==null?void 0:m.call(s,(b=r())!=null?b:h))||void 0;return xt(u.getItem.bind(u))(s.name).then(E=>{if(E)if(typeof E.version=="number"&&E.version!==s.version){if(s.migrate){const k=s.migrate(E.state,E.version);return k instanceof Promise?k.then(x=>[!0,x]):[!0,k]}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 k;const[x,P]=E;if(f=s.merge(P,(k=r())!=null?k:h),n(f,!0),x)return d()}).then(()=>{v==null||v(f,void 0),f=r(),a=!0,c.forEach(E=>E(f))}).catch(E=>{v==null||v(void 0,E)})};return i.persist={setOptions:b=>{s={...s,...b},b.storage&&(u=b.storage)},clearStorage:()=>{u==null||u.removeItem(s.name)},getOptions:()=>s,rehydrate:()=>y(),hasHydrated:()=>a,onHydrate:b=>(o.add(b),()=>{o.delete(b)}),onFinishHydration:b=>(c.add(b),()=>{c.delete(b)})},s.skipHydration||y(),f||h},ls=us,cn=e=>{let t;const n=new Set,r=(u,d)=>{const l=typeof u=="function"?u(t):u;if(!Object.is(l,t)){const h=t;t=d??(typeof l!="object"||l===null)?l:Object.assign({},t,l),n.forEach(f=>f(t,h))}},i=()=>t,o={setState:r,getState:i,getInitialState:()=>c,subscribe:u=>(n.add(u),()=>n.delete(u))},c=t=e(r,i,o);return o},Nt=e=>e?cn(e):cn,Me="4.3.6",Zn="@coinbase/wallet-sdk",ds=()=>({chains:[]}),fs=()=>({keys:{}}),hs=()=>({account:{}}),ps=()=>({subAccount:void 0}),ms=()=>({subAccountConfig:{}}),gs=()=>({spendPermissions:[]}),bs=()=>({config:{version:Me}}),D=Nt(ls((...e)=>Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},ds(...e)),fs(...e)),hs(...e)),ps(...e)),gs(...e)),bs(...e)),ms(...e)),{name:"cbwsdk.store",storage:Qn(()=>localStorage),partialize:e=>({chains:e.chains,keys:e.keys,account:e.account,subAccount:e.subAccount,spendPermissions:e.spendPermissions,config:e.config})})),ys={get:()=>D.getState().subAccountConfig,set:e=>{D.setState(t=>({subAccountConfig:Object.assign(Object.assign({},t.subAccountConfig),e)}))},clear:()=>{D.setState({subAccountConfig:{}})}},ws={get:()=>D.getState().subAccount,set:e=>{D.setState(t=>({subAccount:t.subAccount?Object.assign(Object.assign({},t.subAccount),e):Object.assign({address:e.address},e)}))},clear:()=>{D.setState({subAccount:void 0})}},vs={get:()=>D.getState().spendPermissions,set:e=>{D.setState({spendPermissions:e})},clear:()=>{D.setState({spendPermissions:[]})}},ks={get:()=>D.getState().account,set:e=>{D.setState(t=>({account:Object.assign(Object.assign({},t.account),e)}))},clear:()=>{D.setState({account:{}})}},_s={get:()=>D.getState().chains,set:e=>{D.setState({chains:e})},clear:()=>{D.setState({chains:[]})}},Ss={get:e=>D.getState().keys[e],set:(e,t)=>{D.setState(n=>
1({keys:Object.assign(Object.assign({},n.keys),{[e]:t})}))},clear:()=>{D.setState({keys:{}})}},Xn={get:()=>D.getState().config,set:e=>{D.setState(t=>({config:Object.assign(Object.assign({},t.config),e)}))}},xs={subAccounts:ws,subAccountsConfig:ys,spendPermissions:vs,account:ks,chains:_s,keys:Ss,config:Xn},w=Object.assign(Object.assign({},D),xs),Es
vendor: 83,976 bytes, line 1
1='!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})()}));',
1As=()=>new Promise((e,t)=>{if(window.ClientAnalytics)return e();try{const n=document.createElement("script");n.textContent=Es,n.type="text/javascript",document.head.appendChild(n),Is(),document.head.removeChild(n),e()}catch{console.error("Failed to execute inlined telemetry script"),t()}}),Is=()=>{var e,t,n;if(typeof window<"u"){const r=(n=(e=w.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:i,identify:s,PlatformName:a}=window.ClientAnalytics;i({isProd:!0,amplitudeApiKey:"c66737ad47ec354ced777935b0af822e",platform:a.web,projectName:"base_account_sdk",showDebugLogging:!1,version:"1.0.0",apiEndpoint:"https://cca-lite.coinbase.com"}),s({deviceId:r}),w.config.set({deviceId:r})}}},R={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}},Et={"-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."}},er="Unspecified error message.",Ts="Unspecified server error.";function Lt(e,t=er){if(e&&Number.isInteger(e)){const n=e.toString();if(At(Et,n))return Et[n].message;if(tr(e))return Ts}return t}function Cs(e){if(!Number.isInteger(e))return!1;const t=e.toString();return!!(Et[t]||tr(e))}function Ps(e,{shouldIncludeStack:t=!1}={}){const n={};if(e&&typeof e=="object"&&!Array.isArray(e)&&At(e,"code")&&Cs(e.code)){const r=e;n.code=r.code,r.message&&typeof r.message=="string"?(n.message=r.message,At(r,"data")&&(n.data=r.data)):(n.message=Lt(n.code),n.data={originalError:un(e)})}else n.code=R.rpc.internal,n.message=ln(e,"message")?e.message:er,n.data={originalError:un(e)};return t&&(n.stack=ln(e,"stack")?e.stack:void 0),n}function tr(e){return e>=-32099&&e<=-32e3}function un(e){return e&&typeof e=="object"&&!Array.isArray(e)?Object.assign({},e):e}function At(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function ln(e,t){return typeof e=="object"&&e!==null&&t in e&&typeof e[t]=="str
1ing"}const g={rpc:{parse:e=>K(R.rpc.parse,e),invalidRequest:e=>K(R.rpc.invalidRequest,e),invalidParams:e=>K(R.rpc.invalidParams,e),methodNotFound:e=>K(R.rpc.methodNotFound,e),internal:e=>K(R.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 K(t,e)},invalidInput:e=>K(R.rpc.invalidInput,e),resourceNotFound:e=>K(R.rpc.resourceNotFound,e),resourceUnavailable:e=>K(R.rpc.resourceUnavailable,e),transactionRejected:e=>K(R.rpc.transactionRejected,e),methodNotSupported:e=>K(R.rpc.methodNotSupported,e),limitExceeded:e=>K(R.rpc.limitExceeded,e)},provider:{userRejectedRequest:e=>_e(R.provider.userRejectedRequest,e),unauthorized:e=>_e(R.provider.unauthorized,e),unsupportedMethod:e=>_e(R.provider.unsupportedMethod,e),disconnected:e=>_e(R.provider.disconnected,e),chainDisconnected:e=>_e(R.provider.chainDisconnected,e),unsupportedChain:e=>_e(R.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 rr(t,n,r)}}};function K(e,t){const[n,r]=nr(t);return new Rt(e,n||Lt(e),r)}function _e(e,t){const[n,r]=nr(t);return new rr(e,n||Lt(e),r)}function nr(e){if(e){if(typeof e=="string")return[e];if(typeof e=="object"&&!Array.isArray(e)){const{message:t,data:n}=e;
1if(t&&typeof t!="string")throw new Error("Must specify string message.");return[t||void 0,n]}}return[]}class Rt 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 rr extends Rt{constructor(t,n,r){if(!Os(t))throw new Error('"code" must be an integer such that: 1000 <= code <= 4999');super(t,n,r)}}function Os(e){return Number.isInteger(e)&&e>=1e3&&e<=4999}function dn(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 ir(e){return typeof e=="object"&&e!==null&&"details"in e}function js(e){try{const t=JSON.parse(e.details);return new Rt(t.code,t.message,t.data)}catch{return null}}function sr(){return e=>e}const qe=sr(),Ms=sr();function se(e){return Math.floor(e)}const ar=/^[0-9]*$/,or=/^[a-f0-9]*$/;function ye(e){return Dt(crypto.getRandomValues(new Uint8Array(e)))}function Dt(e){return[...e].map(t=>t.toString(16).padStart(2,"0")).join("")}function st(e){return new Uint8Array(e.match(/.{1,2}/g).map(t=>Number.parseInt(t,16)))}function Ue(e,t=!1){const n=e.toString("hex");return qe(t?`0x${n}`:n)}function mt(e){return Ue(Tt(e),!0)}function Q(e){return Ms(e.toString(10))}function Ee(e){return qe(`0x${BigInt(e).toString(16)}`)}function cr(e){return e.startsWith("0x")||e.startsWith("0X")}function Bt(e){return cr(e)?e.slice(2):e}function ur(e){return cr(e)?`0x${e.slice(2)}`:`0x${e}`}function ut(e){if(typeof e!="string")return!1;const t=Bt(e).toLowerCase();return or.test(t)}
1function It(e,t=!1){if(typeof e=="string"){const n=Bt(e).toLowerCase();if(or.test(n))return qe(t?`0x${n}`:n)}throw g.rpc.invalidParams(`"${String(e)}" is not a hexadecimal string`)}function Ut(e,t=!1){let n=It(e,!1);return n.length%2===1&&(n=qe(`0${n}`)),t?qe(`0x${n}`):n}function ce(e){if(typeof e=="string"){const t=Bt(e).toLowerCase();if(ut(t)&&t.length===40)return ur(t)}throw g.rpc.invalidParams(`Invalid Ethereum address: ${String(e)}`)}function Tt(e){if(Buffer.isBuffer(e))return e;if(typeof e=="string"){if(ut(e)){const t=Ut(e,!1);return Buffer.from(t,"hex")}return Buffer.from(e,"utf8")}throw g.rpc.invalidParams(`Not binary data: ${String(e)}`)}function He(e){if(typeof e=="number"&&Number.isInteger(e))return se(e);if(typeof e=="string"){if(ar.test(e))return se(Number(e));if(ut(e))return se(Number(BigInt(Ut(e,!0))))}throw g.rpc.invalidParams(`Not an integer: ${String(e)}`)}function Le(e){if(e!==null&&(typeof e=="bigint"||Ls(e)))return BigInt(e.toString(10));if(typeof e=="number")return BigInt(He(e));if(typeof e=="string"){if(ar.test(e))return BigInt(e);if(ut(e))return BigInt(Ut(e,!0))}throw g.rpc.invalidParams(`Not an integer: ${String(e)}`)}function Ns(e){if(typeof e=="string")return JSON.parse(e);if(typeof e=="object")return e;throw g.rpc.invalidParams(`Not a JSON string or an object: ${String(e)}`)}function Ls(e){if(e==null||typeof e.constructor!="function")return!1;const{constructor:t}=e;return typeof t.config=="function"&&typeof t.EUCLID=="number"}const Rs=`Coinbase Wallet SDK requires the Cross-Origin-Opener-Policy header to not be set to 'same-origin'. This is to ensure that the SDK can communicate with the Coinbase Smart Wallet app.
2
3Please see https://www.smartwallet.dev/guides/tips/popup-tips#cross-origin-opener-policy for more information.`,Ds=()=>{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(Rs)}catch(t){console.error("Error checking Cross-Origin-Opener-Policy:",t.message),e="error"}}}},{checkCrossOriginOpenerPolicy:Bs,getCrossOriginOpenerPolicy:Us}=Ds();async function $e(e,t){const n=Object.assign(Object.assign({},e),{jsonrpc:"2.0",id:crypto.randomUUID()}
3),r=await window.fetch(t,{method:"POST",body:JSON.stringify(n),mode:"cors",headers:{"Content-Type":"application/json","X-Cbw-Sdk-Version":Me,"X-Cbw-Sdk-Platform":Zn}}),{result:i,error:s}=await r.json();if(s)throw s;return i}function Hs(){return globalThis.coinbaseWalletExtension}function $s(){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 zs({metadata:e,preference:t}){var n,r;const{appName:i,appLogoUrl:s,appChainIds:a}=e;if(t.options!=="smartWalletOnly"){const c=Hs();if(c)return(n=c.setAppInfo)===null||n===void 0||n.call(c,i,s,a,t),c}const o=$s();if(o!=null&&o.isCoinbaseBrowser)return(r=o.setAppInfo)===null||r===void 0||r.call(o,i,s,a,t),o}function Ws(e){if(!e||typeof e!="object"||Array.isArray(e))throw g.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 g.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 g.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 g.provider.unsupportedMethod()}}function qs(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 fn(e){if(typeof e!="function")throw new Error("toAccount is not a function")}const Fs="https://keys.coinbase.com/connect",lr="https://rpc.wallet.coinbase.com",hn="https://www.walletlink.org",Ks="https://go.cb-w.com/walletlink";var A;(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"})(A||(A={}));var I;(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"})(I||(I={}));var T;(function(e){e.low="low",e.high="high"})(T||(T={}));function C(e,t,n){var r,i,s,a;window.ClientAnalytics&&((r=window.ClientAnalytics)===null||r===void 0||r.logEvent(e,Object.assign(Object.assign({},t),{sdkVersion:Me,appName:(s=(i=w.config.get().metadata)===null||i===void 0?void 0:i.appName)!==null&&s!==void 0?s:"",appOrigin:window.location.origin,appPreferredSigner:(a=w.config.get().preference)===null||a===void 0?void 0:a.options}),n))}const Vs=()=>{C("communicator.popup_setup.started",{action:I.unknown,componentType:A.unknown},T.high)},Gs=()=>{C("communicator.popup_setup.completed",{action:I.unknown,componentType:A.unknown},T.high)},Js=()=>{C("communicator.popup_unload.received",{action:I.unknown,componentType:A.unknown},T.high)},Ht=({snackbarContext:e})=>{C(`snackbar.${e}.shown`,{action:I.render,componentType:A.modal,snackbarContext:e},T.high)},Ie=({snackbarContext:e,snackbarAction:t})=>{C(`snackbar.${e}.action_clicked`,{action:I.click,componentType:A.button,snackbarContext:e,snackbarAction:t},T.high)},Ys='@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 dr(){const e=document.createElement("style");e.type="text/css",e.appendChild(document.createTextNode(Ys)),document.documentElement.appendChild(e)}function fr(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=fr(e[t]))&&(r&&(r+=" "),r+=n);else for(t in e)e[t]&&(r&&(r+=" "),r+=t);return r}function ze(){for(var e,t,n=0,r="";n<arguments.length;)(e=arguments[n++])&&(t=fr(e))&&(r&&(r+=" "),r+=t);return r}function Qs(){try{return window.frameElement!==null}catch{return!1}}function Zs(){try{return Qs()&&window.top?window.top.location:window.location}catch{return window.location}}function Xs(){var e;return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test((e=window==null?void 0:window.navigator)===null||e===void 0?void 0:e.userAgent)}function hr(){var e,t;return(t=(e=window==null?void 0:window.matchMedia)===null||e===void 0?void 0:e.call(window,"(prefers-color-scheme: dark)").matches)!==null&&t!==void 0?t:!1}const ea=".-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;
3cursor: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}",ta="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEuNDkyIDEwLjQxOWE4LjkzIDguOTMgMCAwMTguOTMtOC45M2gxMS4xNjNhOC45MyA4LjkzIDAgMDE4LjkzIDguOTN2MTEuMTYzYTguOTMgOC45MyAwIDAxLTguOTMgOC45M0gxMC40MjJhOC45MyA4LjkzIDAgMDEtOC45My04LjkzVjEwLjQxOXoiIGZpbGw9IiMxNjUyRjAiLz48cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTEwLjQxOSAwSDIxLjU4QzI3LjMzNSAwIDMyIDQuNjY1IDMyIDEwLjQxOVYyMS41OEMzMiAyNy4zMzUgMjcuMzM1IDMyIDIxLjU4MSAzMkgxMC40MkM0LjY2NSAzMiAwIDI3LjMzNSAwIDIxLjU4MVYxMC40MkMwIDQuNjY1IDQuNjY1IDAgMTAuNDE5IDB6bTAgMS40ODhhOC45MyA4LjkzIDAgMDAtOC45MyA4LjkzdjExLjE2M2E4LjkzIDguOTMgMCAwMDguOTMgOC45M0gyMS41OGE4LjkzIDguOTMgMCAwMDguOTMtOC45M1YxMC40MmE4LjkzIDguOTMgMCAwMC04LjkzLTguOTNIMTAuNDJ6IiBmaWxsPSIjZmZmIi8+PHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xNS45OTggMjYuMDQ5Yy01LjU0OSAwLTEwLjA0Ny00LjQ5OC0xMC4wNDctMTAuMDQ3IDAtNS41NDggNC40OTgtMTAuMDQ2IDEwLjA0Ny0xMC4wNDYgNS41NDggMCAxMC4wNDYgNC40OTggMTAuMDQ2IDEwLjA0NiAwIDUuNTQ5LTQuNDk4IDEwLjA0Ny0xMC4wNDYgMTAuMDQ3eiIgZmlsbD0iI2ZmZiIvPjxwYXRoIGQ9Ik0xMi43NjIgMTQuMjU0YzAtLjgyMi42NjctMS40ODkgMS40ODktMS40ODloMy40OTdjLjgyMiAwIDEuNDg4LjY2NiAxLjQ4OCAxLjQ4OXYzLjQ5N2MwIC44MjItLjY2NiAxLjQ4OC0xLjQ4OCAxLjQ4OGgtMy40OTdhMS40ODggMS40ODggMCAwMS0xLjQ4OS0xLjQ4OHYtMy40OTh6IiBmaWxsPSIjMTY1MkYwIi8+PC9zdmc+",na="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIiIGhlaWdodD0iMTIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDYuNzV2LTEuNWwtMS43Mi0uNTdjLS4wOC0uMjctLjE5LS41Mi0uMzItLjc3bC44MS0xLjYyLTEuMDYtMS4wNi0xLjYyLjgxYy0uMjQtLjEzLS41LS4yNC0uNzctLjMyTDYuNzUgMGgtMS41bC0uNTcgMS43MmMtLjI3LjA4LS41My4xOS0uNzcuMzJsLTEuNjItLjgxLTEuMDYgMS4wNi44MSAxLjYyYy0uMTMuMjQtLjI0LjUtLjMyLjc3TDAgNS4yNXYxLjVsMS43Mi41N2MuMDguMjcuMTkuNTMuMzIuNzdsLS44MSAxLjYyIDEuMDYgMS4wNiAxLjYyLS44MWMuMjQuMTMuNS4yMy43Ny4zMkw1LjI1IDEyaDEuNWwuNTctMS43MmMuMjctLjA4LjUyLS4xOS43Ny0uMzJsMS42Mi44MSAxLjA2LTEuMDYtLjgxLTEuNjJjLjEzLS4yNC4yMy0uNS4zMi0uNzdMMTIgNi43NXpNNiA4LjVhMi41IDIuNSAwIDAxMC01IDIuNSAyLjUgMCAwMTAgNXoiIGZpbGw9IiMwNTBGMTkiLz48L3N2Zz4=";class pr{constructor(){this.items=new Map,this.nextItemKey=0,this.root=null,this.darkMode=hr()}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&&_t(O("div",null,O(mr,{darkMode:this.darkMode},Array.from(this.items.entries()).map(([t,n])=>O(ra,Object.assign({},n,{key:t}
3))))),this.root)}}const mr=e=>O("div",{class:ze("-cbwsdk-snackbar-container")},O("style",null,ea),O("div",{class:"-cbwsdk-snackbar"},e.children)),ra=({autoExpand:e,message:t,menuItems:n})=>{const[r,i]=Xt(!0),[s,a]=Xt(e??!1);$i(()=>{const c=[window.setTimeout(()=>{i(!1)},1),window.setTimeout(()=>{a(!0)},1e4)];return()=>{c.forEach(window.clearTimeout)}});const o=()=>{a(!s)};return O("div",{class:ze("-cbwsdk-snackbar-instance",r&&"-cbwsdk-snackbar-instance-hidden",s&&"-cbwsdk-snackbar-instance-expanded")},O("div",{class:"-cbwsdk-snackbar-instance-header",onClick:o},O("img",{src:ta,class:"-cbwsdk-snackbar-instance-header-cblogo"})," ",O("div",{class:"-cbwsdk-snackbar-instance-header-message"},t),O("div",{class:"-gear-container"},!s&&O("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},O("circle",{cx:"12",cy:"12",r:"12",fill:"#F5F7F8"})),O("img",{src:na,class:"-gear-icon",title:"Expand"}))),n&&n.length>0&&O("div",{class:"-cbwsdk-snackbar-instance-menu"},n.map((c,u)=>O("div",{class:ze("-cbwsdk-snackbar-instance-menu-item",c.isRed&&"-cbwsdk-snackbar-instance-menu-item-is-red"),onClick:c.onClick,key:u},O("svg",{width:c.svgWidth,height:c.svgHeight,viewBox:"0 0 10 11",fill:"none",xmlns:"http://www.w3.org/2000/svg"},O("path",{"fill-rule":c.defaultFillRule,"clip-rule":c.defaultClipRule,d:c.path,fill:"#AAAAAA"})),O("span",{class:ze("-cbwsdk-snackbar-instance-menu-item-info",c.isRed&&"-cbwsdk-snackbar-instance-menu-item-info-is-red")},c.info)))))},gr="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 ia{constructor(){this.attached=!1,this.snackbar=new pr}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,dr()}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:gr,defaultFillRule:"evenodd",defaultClipRule:"evenodd",onClick:t.onResetConnection}]},this.snackbar.presentItem(n)}}const pn=420,mn=700,sa={isRed:!1,info:"Retry",svgWidth:"10",svgHeight:"11",path:gr,defaultFillRule:"evenodd",defaultClipRule:"evenodd"},aa="Popup was blocked. Try again.";let Ve=null;function oa(e){const t=(window.innerWidth-pn)/2+window.screenX,n=(window.innerHeight-mn)/2+window.screenY;ua(e);function r(){const s=`wallet_${crypto.randomUUID()}`,a=window.open(e,s,`width=${pn}, height=${mn}, left=${t}, top=${n}`);return a==null||a.focus(),a||null}let i=r();if(!i){const s=$t();return new Promise((a,o)=>{Ht({snackbarContext:"popup_blocked"}),s.presentItem({autoExpand:!0,message:aa,menuItems:[Object.assign(Object.assign({},sa),{onClick:()=>{Ie({snackbarContext:"popup_blocked",snackbarAction:"confirm"}),i=r(),i?a(i):o(g.rpc.internal("Popup window was blocked")),s.clear()}})]})})}return Promise.resolve(i)}function ca(e){e&&!e.closed&&e.close()}function ua(e){const t={sdkName:Zn,sdkVersion:Me,origin:window.location.origin,coop:Us()};for(const[n,r]of Object.entries(t))e.searchParams.has(n)||e.searchParams.append(n,r.toString())}function $t(){if(!Ve){const e=document.createElement("div");e.className="-cbwsdk-css-reset",document.body.appendChild(e),Ve=new pr,Ve.attach(e)}return Ve}class la{constructor({url:t=Fs,metadata:n,preference:r}){this.popup=null,this.listeners=new Map,this.postMessage=async i=>{(await this.waitForPopupLoaded()).postMessage(i,this.url.origin)},this.postRequestAndWaitForResponse=async i=>{const s=this.onMessage(({requestId:a})=>a===i.id);return this.postMessage(i),await s},this.onMessage=async i=>new Promise((s,a)=>{const o=c=>{if(c.origin!==this.url.origin)return;const u=c.data;i(u)&&(s(u),window.removeEventListener("message",o),this.listeners.delete(o))};window.addEventListener("message",o),this.listeners.set(o,{reject:a})}),this.disconnect=()=>
3{ca(this.popup),this.popup=null,this.listeners.forEach(({reject:i},s)=>{i(g.provider.userRejectedRequest("Request rejected")),window.removeEventListener("message",s)}),this.listeners.clear()},this.waitForPopupLoaded=async()=>this.popup&&!this.popup.closed?(this.popup.focus(),this.popup):(Vs(),this.popup=await oa(this.url),this.onMessage(({event:i})=>i==="PopupUnload").then(()=>{this.disconnect(),Js()}).catch(()=>{}),this.onMessage(({event:i})=>i==="PopupLoaded").then(i=>{this.postMessage({requestId:i.id,data:{version:Me,metadata:this.metadata,preference:this.preference,location:window.location.toString()}})}).then(()=>{if(!this.popup)throw g.rpc.internal();return Gs(),this.popup})),this.url=new URL(t),this.metadata=n,this.preference=r}}function H(e){return e.errorMessage!==void 0}function da(e){const t=Ps(fa(e),{shouldIncludeStack:!0}),n=new URL("https://docs.cloud.coinbase.com/wallet-sdk/docs/errors");return n.searchParams.set("version",Me),n.searchParams.set("code",t.code.toString()),n.searchParams.set("message",t.message),Object.assign(Object.assign({},t),{docUrl:n.href})}function fa(e){var t;if(typeof e=="string")return{message:e,code:R.rpc.internal};if(H(e)){const n=e.errorMessage,r=(t=e.errorCode)!==null&&t!==void 0?t:n.match(/(denied|rejected)/i)?R.provider.userRejectedRequest:void 0;return Object.assign(Object.assign({},e),{message:n,code:r,data:{method:e.method}})}return e}var br={exports:{}};(function(e){var t=Object.prototype.hasOwnProperty,n="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1));function i(c,u,d){this.fn=c,this.context=u,this.once=d||!1}function s(c,u,d,l,h){if(typeof d!="function")throw new TypeError("The listener must be a function");var f=new i(d,l||c,h),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 a(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 h=0,f=l.length,y=new Array(f);h<f;h++)y[h]=l[h].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,h,f,y){var b=n?n+u:u;if(!this._events[b])return!1;var m=this._events[b],v=arguments.length,E,k;if(m.fn){switch(m.once&&this.removeListener(u,m.fn,void 0,!0),v){case 1:return m.fn.call(m.context),!0;case 2:return m.fn.call(m.context,d),!0;case 3:return m.fn.call(m.context,d,l),!0;case 4:return m.fn.call(m.context,d,l,h),!0;case 5:return m.fn.call(m.context,d,l,h,f),!0;case 6:return m.fn.call(m.context,d,l,h,f,y),!0}for(k=1,E=new Array(v-1);k<v;k++)E[k-1]=arguments[k];
3m.fn.apply(m.context,E)}else{var x=m.length,P;for(k=0;k<x;k++)switch(m[k].once&&this.removeListener(u,m[k].fn,void 0,!0),v){case 1:m[k].fn.call(m[k].context);break;case 2:m[k].fn.call(m[k].context,d);break;case 3:m[k].fn.call(m[k].context,d,l);break;case 4:m[k].fn.call(m[k].context,d,l,h);break;default:if(!E)for(P=1,E=new Array(v-1);P<v;P++)E[P-1]=arguments[P];m[k].fn.apply(m[k].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,h){var f=n?n+u:u;if(!this._events[f])return this;if(!d)return a(this,f),this;var y=this._events[f];if(y.fn)y.fn===d&&(!h||y.once)&&(!l||y.context===l)&&a(this,f);else{for(var b=0,m=[],v=y.length;b<v;b++)(y[b].fn!==d||h&&!y[b].once||l&&y[b].context!==l)&&m.push(y[b]);m.length?this._events[f]=m.length===1?m[0]:m:a(this,f)}return this},o.prototype.removeAllListeners=function(u){var d;return u?(d=n?n+u:u,this._events[d]&&a(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})(br);var ha=br.exports;const pa=qn(ha);class ma extends pa{}class ke{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 i=localStorage.key(r);typeof i=="string"&&i.startsWith(t)&&n.push(i)}n.forEach(r=>localStorage.removeItem(r))}scopedKey(t){return`-${this.scope}${this.module?`:${this.module}`:""}:${t}`}static clearAll(){new ke("CBWSDK").clear(),new ke("walletlink").clear()}}const ga=({signerType:e})=>{C("provider.signer.loaded_from_storage",{action:I.measurement,componentType:A.unknown,signerType:e},T.low)},ba=({method:e,correlationId:t})=>{C("provider.request.started",{action:I.unknown,componentType:A.unknown,method:e,correlationId:t},T.high)},ya=({method:e,correlationId:t,signerType:n,errorMessage:r})=>{C("provider.request.error",{action:I.error,componentType:A.unknown,method:e,signerType:n,correlationId:t,errorMessage:r},T.high)},wa=({method:e,signerType:t,correlationId:n})=>{C("provider.request.responded",{action:I.unknown,componentType:A.unknown,method:e,signerType:t,correlationId:n},T.high)},va=()=>{C("provider.enable_function.called",{action:I.measurement,componentType:A.unknown},T.high)},ka=()=>{C("signer.selection.requested",{action:I.unknown,componentType:A.unknown},T.high)},_a=e=>{C("signer.selection.responded",{action:I.unknown,componentType:A.unknown,signerType:e},T.high)},Ge=Nt(()=>({correlationIds:new Map})),J={get:e=>Ge.getState().correlationIds.get(e),set:(e,t)=>{Ge.setState(n=>{const r=new Map(n.correlationIds);return r.set(e,t),{correlationIds:r}})},delete:e=>{Ge.setState(t=>{const n=new Map(t.correlationIds);return n.delete(e),{correlationIds:n}})},clear:()=>{Ge.setState({correlationIds:new Map})}},Sa=({method:e,correlationId:t})=>{var n;C("scw_signer.handshake.started",{action:I.unknown,componentType:A.unknown,method:e,correlationId:t,enableAutoSubAccounts:(n=w.subAccountsConfig.get())===null||n===void 0?void 0:n.enableAutoSubAccounts},T.high)},xa=({method:e,correlationId:t,errorMessage:n})=>{var r;C("scw_signer.handshake.error",{action:I.error,componentType:A.unknown,method:e,correlationId:t,errorMessage:n,enableAutoSubAccounts:(r=w.subAccountsConfig.get())===null||r===void 0?void 0:r.enableAutoSubAccounts},T.high)},Ea=({method:e,correlationId:t})=>{var n;C("scw_signer.handshake.completed",{action:I.unknown,componentType:A.unknown,method:e,correlationId:t,enableAutoSubAccounts:(n=w.subAccountsConfig.get())===null||n===void 0?void 0:n.enableAutoSubAccounts},T.high)},Aa=({method:e,correlationId:t})=>{var n;C("scw_signer.request.started",{action:I.unknown,componentType:A.unknown,method:e,correlationId:t,enableAutoSubAccounts:(n=w.subAccountsConfig.get())===null||n===void 0?void 0:n.enableAutoSubAccounts},T.high)},Ia=({method:e,correlationId:t,errorMessage:n})=>{var r;C("scw_signer.request.error",{action:I.error,componentType:A.unknown,method:e,correlationId:t,errorMessage:n,enableAutoSubAccounts:(r=w.subAccountsConfig.get())===null||r===void 0?void 0:r.enableAutoSubAccounts},T.high)},Ta=({method:e,correlationId:t})=>{var n;
3C("scw_signer.request.completed",{action:I.unknown,componentType:A.unknown,method:e,correlationId:t,enableAutoSubAccounts:(n=w.subAccountsConfig.get())===null||n===void 0?void 0:n.enableAutoSubAccounts},T.high)},Ca=({method:e,correlationId:t})=>{var n;C("scw_sub_account.request.started",{action:I.unknown,componentType:A.unknown,method:e,correlationId:t,enableAutoSubAccounts:(n=w.subAccountsConfig.get())===null||n===void 0?void 0:n.enableAutoSubAccounts},T.high)},Pa=({method:e,correlationId:t})=>{var n;C("scw_sub_account.request.completed",{action:I.unknown,componentType:A.unknown,method:e,correlationId:t,enableAutoSubAccounts:(n=w.subAccountsConfig.get())===null||n===void 0?void 0:n.enableAutoSubAccounts},T.high)},Oa=({method:e,correlationId:t,errorMessage:n})=>{var r;C("scw_sub_account.request.error",{action:I.error,componentType:A.unknown,method:e,correlationId:t,errorMessage:n,enableAutoSubAccounts:(r=w.subAccountsConfig.get())===null||r===void 0?void 0:r.enableAutoSubAccounts},T.high)},ja=({method:e,correlationId:t})=>{var n;C("scw_sub_account.add_owner.started",{action:I.unknown,componentType:A.unknown,method:e,correlationId:t,enableAutoSubAccounts:(n=w.subAccountsConfig.get())===null||n===void 0?void 0:n.enableAutoSubAccounts},T.high)},Ma=({method:e,correlationId:t})=>{var n;C("scw_sub_account.add_owner.completed",{action:I.unknown,componentType:A.unknown,method:e,correlationId:t,enableAutoSubAccounts:(n=w.subAccountsConfig.get())===null||n===void 0?void 0:n.enableAutoSubAccounts},T.high)},Na=({method:e,correlationId:t,errorMessage:n})=>{var r;C("scw_sub_account.add_owner.error",{action:I.error,componentType:A.unknown,method:e,correlationId:t,errorMessage:n,enableAutoSubAccounts:(r=w.subAccountsConfig.get())===null||r===void 0?void 0:r.enableAutoSubAccounts},T.high)},La=({method:e,correlationId:t})=>{var n;C("scw_sub_account.insufficient_balance.error_handling.started",{action:I.unknown,componentType:A.unknown,method:e,correlationId:t,enableAutoSubAccounts:(n=w.subAccountsConfig.get())===null||n===void 0?void 0:n.enableAutoSubAccounts},T.high)},Ra=({method:e,correlationId:t})=>{var n;C("scw_sub_account.insufficient_balance.error_handling.completed",{action:I.unknown,componentType:A.unknown,method:e,correlationId:t,enableAutoSubAccounts:(n=w.subAccountsConfig.get())===null||n===void 0?void 0:n.enableAutoSubAccounts},T.high)},Da=({method:e,correlationId:t,errorMessage:n})=>{var r;C("scw_sub_account.insufficient_balance.error_handling.error",{action:I.error,componentType:A.unknown,method:e,correlationId:t,errorMessage:n,enableAutoSubAccounts:(r=w.subAccountsConfig.get())===null||r===void 0?void 0:r.enableAutoSubAccounts},T.high)},we=e=>"message"in e&&typeof e.message=="string"?e.message:"",yr=Nt(()=>({}));function gn(e){e.forEach(t=>{var n,r,i,s,a,o,c,u;if(!t.rpcUrl)return;const d=zi({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=(i=t.nativeCurrency)===null||i===void 0?void 0:i.name)!==null&&s!==void 0?s:"",symbol:(o=(a=t.nativeCurrency)===null||a===void 0?void 0:a.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=Zi({chain:d,transport:en(t.rpcUrl)}),h=Xi({client:l,transport:en(t.rpcUrl)});yr.setState({[t.id]:{client:l,bundlerClient:h}})})}function wr(e){var t;return(t=yr.getState()[e])===null||t===void 0?void 0:t.client}function F(e,t,n){if(e==null)throw t??g.rpc.invalidParams({message:"value must be present",data:e})}function he(e,t){if(!Array.isArray(e))throw g.rpc.invalidParams({message:t??"value must be an array",data:e})}function Je(e){if(typeof e!="object"||e===null)throw g.rpc.internal("sub account info is not an object");if(!("address"in e))throw g.rpc.internal("sub account is invalid");if("address"in e&&typeof e.address=="string"&&!at(e.address))throw g.rpc.internal("sub account address is invalid");if("factory"in e&&typeof e.factory=="string"&&!at(e.factory))throw g.rpc.internal("sub account factory address is invalid");
3if("factoryData"in e&&typeof e.factoryData=="string"&&!xe(e.factoryData))throw g.rpc.internal("sub account factory data is invalid")}async function Ba(){return crypto.subtle.generateKey({name:"ECDH",namedCurve:"P-256"},!0,["deriveKey"])}async function Ua(e,t){return crypto.subtle.deriveKey({name:"ECDH",public:t},e,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"])}async function Ha(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 $a(e,{iv:t,cipherText:n}){const r=await crypto.subtle.decrypt({name:"AES-GCM",iv:t},e,n);return new TextDecoder().decode(r)}function vr(e){switch(e){case"public":return"spki";case"private":return"pkcs8"}}async function kr(e,t){const n=vr(e),r=await crypto.subtle.exportKey(n,t);return Dt(new Uint8Array(r))}async function _r(e,t){const n=vr(e),r=st(t).buffer;return await crypto.subtle.importKey(n,new Uint8Array(r),{name:"ECDH",namedCurve:"P-256"},!0,e==="private"?["deriveKey"]:[])}async function za(e,t){const n=JSON.stringify(e,(r,i)=>{if(!(i instanceof Error))return i;const s=i;return Object.assign(Object.assign({},s.code?{code:s.code}:{}),{message:s.message})});return Ha(t,n)}async function Wa(e,t){return JSON.parse(await $a(t,e))}const qa="0.1.1";function Fa(){return qa}class M extends Error{constructor(t,n={}){const r=(()=>{var c;if(n.cause instanceof M){if(n.cause.details)return n.cause.details;if(n.cause.shortMessage)return n.cause.shortMessage}return(c=n.cause)!=null&&c.message?n.cause.message:n.details})(),i=n.cause instanceof M&&n.cause.docsPath||n.docsPath,a=`https://oxlib.sh${i??""}`,o=[t||"An error occurred.",...n.metaMessages?["",...n.metaMessages]:[],...r||i?["",r?`Details: ${r}`:void 0,i?`See: ${a}`:void 0]:[]].filter(c=>typeof c=="string").join(`
4`);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@${Fa()}`}),this.cause=n.cause,this.details=r,this.docs=a,this.docsPath=i,this.shortMessage=t}walk(t){return Sr(this,t)}}function Sr(e,t){return t!=null&&t(e)?e:e&&typeof e=="object"&&"cause"in e&&e.cause?Sr(e.cause,t):t?null:e}/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Ka(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function zt(e,...t){if(!Ka(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function bn(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 Va(e,t){zt(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function Ct(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function gt(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Z(e,t){return e<<32-t|e>>>t}function Ga(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function xr(e){return typeof e=="string"&&(e=Ga(e)),zt(e),e}let Ja=class{};function Ya(e){const t=r=>e().update(xr(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Qa(e,t,n,r){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,n,r);const i=BigInt(32),s=BigInt(4294967295),a=Number(n>>i&s),o=Number(n&s),c=r?4:0,u=r?0:4;e.setUint32(t+c,a,r),e.setUint32(t+u,o,r)}
vendor: 4,911 bytes, line 4
4function Za(e,t,n){return e&t^~e&n}function Xa(e,t,n){return e&t^e&n^t&n}let eo=class extends Ja{constructor(t,n,r,i){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=n,this.padOffset=r,this.isLE=i,this.buffer=new Uint8Array(t),this.view=gt(this.buffer)}update(t){bn(this),t=xr(t),zt(t);const{view:n,buffer:r,blockLen:i}=this,s=t.length;for(let a=0;a<s;){const o=Math.min(i-this.pos,s-a);if(o===i){const c=gt(t);for(;i<=s-a;a+=i)this.process(c,a);continue}r.set(t.subarray(a,a+o),this.pos),this.pos+=o,a+=o,this.pos===i&&(this.process(n,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){bn(this),Va(t,this),this.finished=!0;const{buffer:n,view:r,blockLen:i,isLE:s}=this;let{pos:a}=this;n[a++]=128,Ct(this.buffer.subarray(a)),this.padOffset>i-a&&(this.process(r,0),a=0);for(let l=a;l<i;l++)n[l]=0;Qa(r,i-8,BigInt(this.length*8),s),this.process(r,0);const o=gt(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:i,finished:s,destroyed:a,pos:o}=this;return t.destroyed=a,t.finished=s,t.length=i,t.pos=o,i%n&&t.buffer.set(r),t}clone(){return this._cloneInto()}};const ue=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),to=Uint32Array.from([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]),le=new Uint32Array(64);let no=class extends eo{constructor(t=32){super(64,t,8,!1),this.A=ue[0]|0,this.B=ue[1]|0,this.C=ue[2]|0,this.D=ue[3]|0,this.E=ue[4]|0,this.F=ue[5]|0,this.G=ue[6]|0,this.H=ue[7]|0}get(){const{A:t,B:n,C:r,D:i,E:s,F:a,G:o,H:c}=this;return[t,n,r,i,s,a,o,c]}set(t,n,r,i,s,a,o,c){this.A=t|0,this.B=n|0,this.C=r|0,this.D=i|0,this.E=s|0,this.F=a|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 h=le[l-15],f=le[l-2],y=Z(h,7)^Z(h,18)^h>>>3,b=Z(f,17)^Z(f,19)^f>>>10;le[l]=b+le[l-7]+y+le[l-16]|0}let{A:r,B:i,C:s,D:a,E:o,F:c,G:u,H:d}=this;for(let l=0;l<64;l++){const h=Z(o,6)^Z(o,11)^Z(o,25),f=d+h+Za(o,c,u)+to[l]+le[l]|0,b=(Z(r,2)^Z(r,13)^Z(r,22))+Xa(r,i,s)|0;d=u,u=c,c=o,o=a+f|0,a=s,s=i,i=r,r=f+b|0}r=r+this.A|0,i=i+this.B|0,s=s+this.C|0,a=a+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,i,s,a,o,c,u,d)}roundClean(){Ct(le)}destroy(){this.set(0,0,0,0,0,0,0,0),Ct(this.buffer)}};const ro=Ya(()=>new no),io=ro,so="#__bigint";function lt(e,t,n){return JSON.stringify(e,(r,i)=>typeof i=="bigint"?i.toString()+so:i,n)}function ao(e,t){if(Oe(e)>t)throw new So({givenSize:Oe(e),maxSize:t})}function oo(e,t){if(typeof t=="number"&&t>0&&t>Oe(e)-1)throw new Mr({offset:t,position:"start",size:Oe(e)})}function co(e,t,n){if(typeof t=="number"&&typeof n=="number"&&Oe(e)!==n-t)throw new Mr({offset:n,position:"end",size:Oe(e)})}const re={zero:48,nine:57,A:65,F:70,a:97,f:102};function yn(e){if(e>=re.zero&&e<=re.nine)return e-re.zero;if(e>=re.A&&e<=re.F)return e-(re.A-10);if(e>=re.a&&e<=re.f)return e-(re.a-10)}function Wt(e,t){if(ge(e)>t)throw new wo({givenSize:ge(e),maxSize:t})}function uo(e,t){if(typeof t=="number"&&t>0&&t>ge(e)-1)throw new Cr({offset:t,position:"start",size:ge(e)})}function lo(e,t,n){if(typeof t=="number"&&typeof n=="number"&&ge(e)!==n-t)throw new Cr({offset:n,position:"end",size:ge(e)})}function Er(e,t={}){const{dir:n,size:r=32}=t;if(r===0)return e;const i=e.replace("0x","");if(i.length>r*2)throw new vo({size:Math.ceil(i.length/2),targetSize:r,type:"Hex"});return`0x${i[n==="right"?"padEnd":"padStart"](r*2,"0")}`}const fo=new TextEncoder,ho=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function po(e,t={}){const{strict:n=!1}=t;if(!e)throw new wn(e);if(typeof e!="string")throw new wn(e);if(n&&!/^0x[0-9a-fA-F]*$/.test(e))throw new vn(e);if(!e.startsWith("0x"))throw new vn(e)}function dt(...e){return`0x${e.reduce((t,n)=>t+n.replace("0x",""),"")}`}function Ar(e){return e instanceof Uint8Array?Pe(e):Array.isArray(e)?Pe(new 
4Uint8Array(e)):e}function Pe(e,t={}){let n="";for(let i=0;i<e.length;i++)n+=ho[e[i]];const r=`0x${n}`;return typeof t.size=="number"?(Wt(r,t.size),Tr(r,t.size)):r}function pe(e,t={}){const{signed:n,size:r}=t,i=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 a=typeof s=="bigint"&&n?-s-1n:0;if(s&&i>s||i<a){const u=typeof e=="bigint"?"n":"";throw new yo({max:s?`${s}${u}`:void 0,min:`${a}${u}`,signed:n,size:r,value:`${e}${u}`})}const c=`0x${(n&&i<0?(1n<<BigInt(r*8))+BigInt(i):i).toString(16)}`;return r?mo(c,r):c}function Ir(e,t={}){return Pe(fo.encode(e),t)}function mo(e,t){return Er(e,{dir:"left",size:t})}function Tr(e,t){return Er(e,{dir:"right",size:t})}function V(e,t,n,r={}){const{strict:i}=r;uo(e,t);const s=`0x${e.replace("0x","").slice((t??0)*2,(n??e.length)*2)}`;return i&&lo(s,t,n),s}function ge(e){return Math.ceil((e.length-2)/2)}function go(e,t={}){const{signed:n}=t;t.size&&Wt(e,t.size);const r=BigInt(e);if(!n)return r;const i=(e.length-2)/2,s=(1n<<BigInt(i)*8n)-1n,a=s>>1n;return r<=a?r:r-s-1n}function bo(e,t={}){const{strict:n=!1}=t;try{return po(e,{strict:n}),!0}catch{return!1}}class yo extends M{constructor({max:t,min:n,signed:r,size:i,value:s}){super(`Number \`${s}\` is not in safe${i?` ${i*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 wn extends M{constructor(t){super(`Value \`${typeof t=="object"?lt(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 vn extends M{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 wo=class extends M{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"})}},Cr=class extends M{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 vo extends M{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 ko(e){if(!(e instanceof Uint8Array)){if(!e)throw new Ye(e);if(typeof e!="object")throw new Ye(e);if(!("BYTES_PER_ELEMENT"in e))throw new Ye(e);if(e.BYTES_PER_ELEMENT!==1||e.constructor.name!=="Uint8Array")throw new Ye(e)}}function Pr(e){return e instanceof Uint8Array?e:typeof e=="string"?jr(e):Or(e)}function Or(e){return e instanceof Uint8Array?e:new Uint8Array(e)}function jr(e,t={}){const{size:n}=t;let r=e;n&&(Wt(e,n),r=Tr(e,n));let i=r.slice(2);i.length%2&&(i=`0${i}`);const s=i.length/2,a=new Uint8Array(s);for(let o=0,c=0;o<s;o++){const u=yn(i.charCodeAt(c++)),d=yn(i.charCodeAt(c++));if(u===void 0||d===void 0)throw new M(`Invalid byte sequence ("${i[c-2]}${i[c-1]}" in "${i}").`);a[o]=u*16+d}return a}function Oe(e){return e.length}function kn(e,t,n,r={}){const{strict:i}=r;oo(e,t);const s=e.slice(t,n);return i&&co(s,t,n),s}function _n(e,t={}){const{size:n}=t;typeof n<"u"&&ao(e,n);const r=Pe(e,t);return go(r,t)}function _o(e){try{return ko(e),!0}catch{return!1}}class Ye extends M{constructor(t){super(`Value \`${typeof t=="object"?lt(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 So extends M{constructor({givenSize:t,maxSize:n}
4){super(`Size cannot exceed \`${n}\` bytes. Given size: \`${t}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeOverflowError"})}}class Mr extends M{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 Nr(e,t={}){const{as:n=typeof e=="string"?"Hex":"Bytes"}=t,r=io(Pr(e));return n==="Bytes"?r:Pe(r)}function Lr(e,t={}){const{compressed:n}=t,{prefix:r,x:i,y:s}=e;if(n===!1||typeof i=="bigint"&&typeof s=="bigint"){if(r!==4)throw new Sn({prefix:r,cause:new To});return}if(n===!0||typeof i=="bigint"&&typeof s>"u"){if(r!==3&&r!==2)throw new Sn({prefix:r,cause:new Io});return}throw new Ao({publicKey:e})}function xo(e){const t=(()=>{if(bo(e))return Rr(e);if(_o(e))return Eo(e);const{prefix:n,x:r,y:i}=e;return typeof r=="bigint"&&typeof i=="bigint"?{prefix:n??4,x:r,y:i}:{prefix:n,x:r}})();return Lr(t),t}function Eo(e){return Rr(Pe(e))}function Rr(e){if(e.length!==132&&e.length!==130&&e.length!==68)throw new Co({publicKey:e});if(e.length===130){const r=BigInt(V(e,0,32)),i=BigInt(V(e,32,64));return{prefix:4,x:r,y:i}}if(e.length===132){const r=Number(V(e,0,1)),i=BigInt(V(e,1,33)),s=BigInt(V(e,33,65));return{prefix:r,x:i,y:s}}const t=Number(V(e,0,1)),n=BigInt(V(e,1,33));return{prefix:t,x:n}}function qt(e,t={}){Lr(e);const{prefix:n,x:r,y:i}=e,{includePrefix:s=!0}=t;return dt(s?pe(n,{size:1}):"0x",pe(r,{size:32}),typeof i=="bigint"?pe(i,{size:32}):"0x")}class Ao extends M{constructor({publicKey:t}){super(`Value \`${lt(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 Sn extends M{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 Io extends M{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 To extends M{constructor(){super("Prefix must be 4 for uncompressed public keys."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidUncompressedPrefixError"})}}let Co=class extends M{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 ${ge(Ar(t))} bytes.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidSerializedSizeError"})}};const xn=2n**256n-1n;function Po(e,t={}){const{recovered:n}=t;if(typeof e.r>"u")throw new bt({signature:e});if(typeof e.s>"u")throw new bt({signature:e});if(n&&typeof e.yParity>"u")throw new bt({signature:e});if(e.r<0n||e.r>xn)throw new Lo({value:e.r});if(e.s<0n||e.s>xn)throw new Ro({value:e.s});if(typeof e.yParity=="number"&&e.yParity!==0&&e.yParity!==1)throw new Ft({value:e.yParity})}function Dr(e){if(e.length!==130&&e.length!==132)throw new No({signature:e});const t=BigInt(V(e,0,32)),n=BigInt(V(e,32,64)),r=(()=>{const i=+`0x${e.slice(130)}`;if(!Number.isNaN(i))try{return jo(i)}catch{throw new Ft({value:i})}})();return typeof r>"u"?{r:t,s:n}:{r:t,s:n,yParity:r}}function Oo(e){Po(e);const t=e.r,n=e.s;return dt(pe(t,{size:32}),pe(n,{size:32}),typeof e.yParity=="number"?pe(Mo(e.yParity),{size:1}):"0x")}function jo(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 Do({value:e})}function Mo(e){if(e===0)return 27;if(e===1)return 28;throw new Ft({value:e})}class No extends M{constructor({signature:t}){super(`Value \`${t}
4\` is an invalid signature size.`,{metaMessages:["Expected: 64 bytes or 65 bytes.",`Received ${ge(Ar(t))} bytes.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidSerializedSizeError"})}}class bt extends M{constructor({signature:t}){super(`Signature \`${lt(t)}\` is missing either an \`r\`, \`s\`, or \`yParity\` property.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.MissingPropertiesError"})}}class Lo extends M{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 Ro extends M{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 Ft extends M{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 Do extends M{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 Bo=new TextDecoder,Qe=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 Uo(e,t={}){const{pad:n=!0,url:r=!1}=t,i=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);i[c]=Qe[d>>18],i[c+1]=Qe[d>>12&63],i[c+2]=Qe[d>>6&63],i[c+3]=Qe[d&63]}const s=e.length%3,a=Math.floor(e.length/3)*4+(s&&s+1);let o=Bo.decode(new Uint8Array(i.buffer,0,a));return n&&s===1&&(o+="=="),n&&s===2&&(o+="="),r&&(o=o.replaceAll("+","-").replaceAll("/","_")),o}function Ho(e,t={}){return Uo(jr(e),t)}Uint8Array.from([105,171,180,181,160,222,75,198,42,42,32,31,141,37,186,233]);function $o(e={}){const{flag:t=5,rpId:n=window.location.hostname,signCount:r=0}=e,i=Nr(Ir(n)),s=pe(t,{size:1}),a=pe(r,{size:4});return dt(i,s,a)}function zo(e){const{challenge:t,crossOrigin:n=!1,extraClientData:r,origin:i=window.location.origin}=e;return JSON.stringify({type:"webauthn.get",challenge:Ho(t,{url:!0,pad:!1}),origin:i,crossOrigin:n,...r})}function Wo(e){const{challenge:t,crossOrigin:n,extraClientData:r,flag:i,origin:s,rpId:a,signCount:o,userVerification:c="required"}=e,u=$o({flag:i,rpId:a,signCount:o}),d=zo({challenge:t,crossOrigin:n,extraClientData:r,origin:s}),l=Nr(Ir(d)),h=d.indexOf('"challenge"'),f=d.indexOf('"type"'),y={authenticatorData:u,clientDataJSON:d,challengeIndex:h,typeIndex:f,userVerificationRequired:c==="required"},b=dt(u,l);return{metadata:y,payload:b}}async function qo(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),i=xo(new Uint8Array(r));return{privateKey:n.privateKey,publicKey:i}}async function Fo(e){const{payload:t,privateKey:n}=e,r=await globalThis.crypto.subtle.sign({name:"ECDSA",hash:"SHA-256"},n,Pr(t)),i=Or(new Uint8Array(r)),s=_n(kn(i,0,32));let a=_n(kn(i,32,64));return a>on.CURVE.n/2n&&(a=on.CURVE.n-a),{r:s,s:a}}function Ko(e,t){const n=typeof indexedDB<"u"?ss(e,t):void 0;return{getItem:async r=>{const i=await cs(r,n);return i||null},removeItem:async r=>os(r,n),setItem:async(r,i)=>as(r,i,n)}}const Vo="cbwsdk",Go="keys",Kt="activeId",je=Ko(Vo,Go);async function Jo(){const e=await qo({extractable:!1}),t=V(qt(e.publicKey),1);return await je.setItem(t,e),await je.setItem(Kt,t),e}async function Yo(){const e=await je.getItem(Kt);if(!e)return null;const t=await je.getItem(e);return t||null}async function Qo(){const e=await Yo();if(!e){const t=await Jo(),n=V(qt(t.publicKey),1);return await je.setItem(n,t),await je.setItem(Kt,n),t}return e}async function Zo(){const e=await Qo(),t=V(qt(e.publicKey),1),n=async r=>{const{payload:i,metadata:s}=Wo({challenge:r,origin:"https://keys.coinbase.com",userVerification:"preferred"}),a=await Fo({payload:i,privateKey:e.privateKey});return{signature:Oo(a),raw:{},webauthn:s}};return{id:t,publicKey:t,async sign({hash:r}){return n(r)},async signMessage({message:r}){return n(Yn(r))},async signTypedData(r){return n(Mt(r))},type:"webAuthn"}}async function Pt(){return{account:await Zo()}}const En={storageKey:"ownPrivateKey",keyType:"private"},An={storageKey:"ownPublicKey",keyType:"public"},In={storageKey:"peerPublicKey",keyType:"public"};class Xo{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(In,t),await this.loadKeysIfNeeded()}async clear(){this.ownPrivateKey=null,this.ownPublicKey=null,this.peerPublicKey=null,this.sharedSecret=null,w.keys.clear()}async generateKeyPair(){const t=await Ba();this.ownPrivateKey=t.privateKey,this.ownPublicKey=t.publicKey,await this.storeKey(En,t.privateKey),await this.storeKey(An,t.publicKey)}async loadKeysIfNeeded(){if(this.ownPrivateKey===null&&(this.ownPrivateKey=await this.loadKey(En)),this.ownPublicKey===null&&(this.ownPublicKey=await this.loadKey(An)),(this.ownPrivateKey===null||this.ownPublicKey===null)&&await this.generateKeyPair(),this.peerPublicKey===null&&(this.peerPublicKey=await this.loadKey(In)),this.sharedSecret===null){if(this.ownPrivateKey===null||this.peerPublicKey===null)return;this.sharedSecret=await Ua(this.ownPrivateKey,this.peerPublicKey)}}async loadKey(t){const n=w.keys.get(t.storageKey);return n?_r(t.keyType,n):null}async storeKey(t,n){const r=await kr(t.keyType,n);w.keys.set(t.storageKey,r)}}function Be(e,t){if(!(typeof e!="object"||e===null))return t.split(/[.[\]]+/).filter(
4Boolean).reduce((n,r)=>{if(typeof n=="object"&&n!==null)return n[r]},e)}const Br="0x0ba5ed0c6aa8c49038f819e587e2633c4a9f428a",Ur="0xf85210B21cC50302F477BA56686d2019dC9b67Ad",Y=[{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"}],Hr=[{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 Tn(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 ec(e,t){if(!Array.isArray(e.params))throw g.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 Cn(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 g.rpc.invalidParams()}function tc(e){if(!e||!Array.isArray(e)||e.length!==1&&e.length!==2||typeof e[0]!="str
4ing"||!at(e[0]))throw g.rpc.invalidParams();if(e.length===2){if(!Array.isArray(e[1]))throw g.rpc.invalidParams();for(const t of e[1])if(typeof t!="string"||!t.startsWith("0x"))throw g.rpc.invalidParams()}}function ot(e,t){const n=Object.assign({},e);if(t&&e.method.startsWith("wallet_")){let r=Be(n,"params.0.capabilities");if(typeof r>"u"&&(r={}),typeof r!="object")throw g.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 yt(){var e;const t=(e=w.subAccountsConfig.get())!==null&&e!==void 0?e:{},n={};if(t.enableAutoSubAccounts){const{account:r}=t.toOwnerAccount?await t.toOwnerAccount():await Pt();if(!r)throw g.provider.unauthorized("No owner account found");n.addSubAccount={account:{type:"create",keys:[{type:r.address?"address":"webauthn-p256",publicKey:r.address||r.publicKey}]}}}w.subAccountsConfig.set({capabilities:n})}function nc(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 g.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 g.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 g.rpc.invalidParams("FetchPermissions - Invalid params: params[0].spender must be a hex string");return}throw g.rpc.invalidParams()}}function rc(e){var t,n,r;if(e.params!==void 0)return e;const i=(t=w.getState().account.accounts)===null||t===void 0?void 0:t[0],s=(n=w.getState().account.chain)===null||n===void 0?void 0:n.id,a=(r=w.getState().subAccount)===null||r===void 0?void 0:r.address;if(!i||!a||!s)throw g.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:i,chainId:q(s),spender:a}]}}function ic({spendPermission:e,chainId:t}){return{domain:{name:"Spend Permission Manager",version:"1",chainId:t,verifyingContract:Ur},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 sc({spendPermissionBatch:e,chainId:t}){return{domain:{name:"Spend Permission Manager",version:"1",chainId:t,verifyingContract:Ur},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 $r({client:e,id:t}){var n;const r=await Fn(e,{id:t});if(r.status==="success")return(n=r.receipts)===null||n===void 0?void 0:n[0].transactionHash;throw g.rpc.internal("failed to send transaction")}function zr({calls:e,from:t,chainId:n,capabilities:r}){const i=Xn.get().paymasterUrls;let s={method:"wallet_sendCalls",params:[{version:"1.0",calls:e,chainId:q(n),from:t,atomicRequired:!0,capabilities:r}]};return i!=null&&i[n]&&(s=ot(s,{paymasterService:{url:i==null?void 0:i[n]}})),s}async function ac(){const e=$t();return await new Promise(n=>{Ht({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:()=>{Ie({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:()=>{Ie({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:()=>{Ie({snackbarContext:"sub_account_insufficient_balance",snackbarAction:"cancel"}),e.clear(),n("cancel")}}]})})}function oc({errorData:e,sourceAddress:t}){var n;const r=[];for(const[i,{amount:s,sources:a}]of Object.entries((n=e==null?void 0:e.required)!==null&&n!==void 0?n:{}
4)){if(a.filter(c=>it(c.balance)>=it(s)&&c.address.toLowerCase()===(t==null?void 0:t.toLowerCase())).length===0)throw new Error("Source address has insufficient balance for a token");r.push({token:i,requiredAmount:it(s)})}return r}function cc(e){return typeof e=="object"&&e!==null&&"calls"in e}function uc(e){return Array.isArray(e)&&e.length===1&&typeof e[0]=="object"&&e[0]!==null&&"to"in e[0]}function lc(e){return Wi(qi(Ae(e)),0,16)}function dc({attribution:e,dappOrigin:t}){if(e){if("auto"in e&&e.auto&&t)return lc(t);if("dataSuffix"in e)return e.dataSuffix}}function fc(e,t){var n;if(!Array.isArray(e==null?void 0: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 Ze(e,t){const n=e.filter(r=>r!==t);return[t,...n]}function Xe(e,t){return[...e.filter(r=>r!==t),t]}async function hc(){const e=w.spendPermissions.get(),t=w.subAccounts.get(),n=w.account.get().accounts;return n?{accounts:n==null?void 0:n.map(i=>({address:i,capabilities:{subAccounts:t?[t]:void 0,spendPermissions:e.length>0?{permissions:e}:void 0}}))}:null}function pc(e){return e.replaceAll("+","-").replaceAll("/","_").replace(/=+$/,"")}function et(e){const t=btoa(String.fromCharCode(...new Uint8Array(e)));return pc(t)}function mc({webauthn:e,signature:t,id:n}){const r=Dr(t);return{id:n,rawId:et(tn(n)),response:{authenticatorData:et(St(e.authenticatorData)),clientDataJSON:et(tn(e.clientDataJSON)),signature:et(gc(r.r,r.s))},type:JSON.parse(e.clientDataJSON).type}}function gc(e,t){const n=St(nn(q(e))),r=St(nn(q(t))),i=n.length,s=r.length,a=i+s+4,o=new Uint8Array(a+2);return o[0]=48,o[1]=a,o[2]=2,o[3]=i,o.set(n,4),o[i+4]=2,o[i+5]=s,o.set(r,i+6),o}var bc=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 i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n};async function yc(e){const{owner:t,ownerIndex:n,address:r,client:i,factoryData:s}=e,a={abi:ns,address:ts,version:"0.6"},o={abi:Hr,address:Br};return es({client:i,entryPoint:a,extend:{abi:Y,factory:o},async decodeCalls(c){const u=Kn({abi:Y,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 Vn(`unable to decode calls for "${u.functionName}"`)},async encodeCalls(c){var u,d;return c.length===1?me({abi:Y,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"]}):me({abi:Y,functionName:"executeBatch",args:[c.map(l=>{var h,f;return{data:(h=l.data)!==null&&h!==void 0?h:"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":Re({ownerIndex:n,signature:"0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c"})},async sign(c){const u=await this.getAddress(),d=wt({address:u,chainId:i.chain.id,hash:c.hash}),l=await tt({hash:d,owner:t});return Re({ownerIndex:n,signature:l})},async signMessage(c){const{message:u}=c,d=await this.getAddress(),l=wt({address:d,chainId:i.chain.id,hash:Yn(u)}),h=await tt({hash:l,owner:t});return Re({ownerIndex:n,signature:h})},async signTypedData(c){const{domain:u,types:d,primaryType:l,message:h}=c,f=await this.getAddress(),y=wt({address:f,chainId:i.chain.id,hash:Mt({domain:u,message:h,primaryType:l,types:d})}),b=await tt({hash:y,owner:t});return Re({ownerIndex:n,signature:b})},async signUserOperation(c){const{chainId:u=i.chain.id}=c,d=bc(c,["chainId"]),l=await this.getAddress(),h=rs({chainId:u,entryPointAddress:a.address,entryPointVersion:a.version,userOperation:Object.assign(Object.assign({},d),{sender:l})}),f=await tt({hash:h,owner:t});return Re({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 tt({hash:e,owner:t}){if(t.type==="webAuthn"){const{signature:n,webauthn:r}=await t.sign({hash:e});return wc({signature:n,webauthn:r})}if(t.sign)return t.sign({hash:e});throw new Vn("`owner` does not support raw sign.")}function wt({address:e,chainId:t,hash:n}){return Mt({domain:{chainId:t,name:"Coinbase Smart Wallet",verifyingContract:e,version:"1"},types:{CoinbaseSmartWalletMessage:[{name:"hash",type:"bytes32"}]}
4,primaryType:"CoinbaseSmartWalletMessage",message:{hash:n}})}function wc({webauthn:e,signature:t}){const{r:n,s:r}=Dr(t);return Gn([{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:Fi(e.clientDataJSON),challengeIndex:BigInt(e.challengeIndex),typeIndex:BigInt(e.typeIndex),r:n,s:r}])}function Re(e){const{ownerIndex:t=0}=e,n=(()=>{if(Ki(e.signature)!==65)return e.signature;const r=Vi(e.signature);return is(["bytes32","bytes32","uint8"],[r.r,r.s,r.yParity===0?27:28])})();return Gn([{components:[{name:"ownerIndex",type:"uint8"},{name:"signatureData",type:"bytes"}],type:"tuple"}],[{ownerIndex:t,signatureData:n}])}async function vc({address:e,client:t,factory:n,factoryData:r,owner:i,ownerIndex:s,parentAddress:a,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 g.rpc.internal("chainId not found");const l=await yc({owner:i,ownerIndex:s??1,address:e,client:t,factoryData:r}),h=async f=>{var y,b,m,v,E,k;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 q(d);case"eth_sendTransaction":{he(f.params);const x=f.params[0];F(x.to,g.rpc.invalidParams("to is required"));const P={to:x.to,data:It((y=x.data)!==null&&y!==void 0?y:"0x",!0),value:It((b=x.value)!==null&&b!==void 0?b:"0x",!0),from:(m=x.from)!==null&&m!==void 0?m:u.address},ne=zr({calls:[P],chainId:d,from:P.from}),oe=await h(ne);return $r({client:t,id:oe})}case"wallet_sendCalls":{he(f.params);const x=Be(f.params[0],"chainId");if(!x)throw g.rpc.invalidParams("chainId is required");if(!xe(x))throw g.rpc.invalidParams("chainId must be a hex encoded integer");if(!f.params[0])throw g.rpc.invalidParams("params are required");if(!("calls"in f.params[0]))throw g.rpc.invalidParams("calls are required");let P={method:"wallet_prepareCalls",params:[{version:"1.0",calls:f.params[0].calls,chainId:x,from:u.address,capabilities:"capabilities"in f.params[0]?f.params[0].capabilities:{}}]};a&&(P=ot(P,{funding:[{type:"spendPermission",data:{autoApply:!0,sources:[a],preference:"PREFER_DIRECT_BALANCE"}}]}));let ne=await h(P);const oe=await((E=(v=i).sign)===null||E===void 0?void 0:E.call(v,{hash:rn(ne.signatureRequest.hash)}));let Ne;if(!oe)throw g.rpc.internal("signature not found");return xe(oe)?Ne={type:"secp256k1",data:{address:i.address,signature:oe}}:Ne={type:"webauthn",data:{signature:JSON.stringify(mc(Object.assign({id:(k=i.id)!==null&&k!==void 0?k:"1"},oe))),publicKey:i.publicKey}},(await h({method:"wallet_sendPreparedCalls",params:[{version:"1.0",type:ne.type,data:ne.userOp,chainId:ne.chainId,signature:Ne}]}))[0]}case"wallet_sendPreparedCalls":{he(f.params);const x=Be(f.params[0],"chainId");if(!x)throw g.rpc.invalidParams("chainId is required");if(!xe(x))throw g.rpc.invalidParams("chainId must be a hex encoded integer");return await t.request({method:"wallet_sendPreparedCalls",params:f.params})}case"wallet_prepareCalls":{he(f.params);const x=Be(f.params[0],"chainId");if(!x)throw g.rpc.invalidParams("chainId is required");if(!xe(x))throw g.rpc.invalidParams("chainId must be a hex encoded integer");if(!f.params[0])throw g.rpc.invalidParams("params are required");if(!Be(f.params[0],"calls"))throw g.rpc.invalidParams("calls are required");const P=f.params[0];return o&&P.capabilities&&!("attribution"in P.capabilities)&&(P.capabilities.attribution=o),await t.request({method:"wallet_prepareCalls",params:[Object.assign(Object.assign({},f.params[0]),{chainId:x})]})}case"personal_sign":{if(he(f.params),!xe(f.params[0]))throw g.rpc.invalidParams("message must be a hex encoded string");const x=rn(f.params[0]);return l.signMessage({message:x})}case"eth_signTypedData_v4":{he(f.params);const x=typeof f.params[1]=="string"?JSON.parse(f.params[1]):f.params[1];return l.signTypedData(x)}case"eth_signTypedData_v1":case"eth_signTypedData_v3":case"wallet_addEthereumChain":case"wallet_switchEthereumChain":default:throw g.rpc.methodNotSupported()}}
4catch(x){if(ir(x)){const P=js(x);if(P)throw P}throw x}};return{request:h}}async function Wr({address:e,client:t,publicKey:n,factory:r,factoryData:i}){if(!await Gi(t,{address:e})&&r&&i){if(sn(r)!==sn(Br))throw g.rpc.internal("unknown factory address");const o=Kn({abi:Hr,data:i});if(o.functionName!=="createAccount")throw g.rpc.internal("unknown factory function");const[c]=o.args;return c.findIndex(u=>u.toLowerCase()===Pn(n).toLowerCase())}const a=await an(t,{address:e,abi:Y,functionName:"ownerCount"});for(let o=Number(a)-1;o>=0;o--){const c=await an(t,{address:e,abi:Y,functionName:"ownerAtIndex",args:[BigInt(o)]}),u=Pn(n);if(c.toLowerCase()===u.toLowerCase())return o}return-1}function Pn(e){return at(e)?Ji(e):e}async function kc(){const e=$t();return new Promise(t=>{Ht({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:()=>{Ie({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:()=>{Ie({snackbarContext:"sub_account_add_owner",snackbarAction:"cancel"}),e.clear(),t("cancel")}}]})})}async function _c({ownerAccount:e,globalAccountRequest:t}){var n,r;const i=w.account.get(),s=w.subAccounts.get(),a=(n=i.accounts)===null||n===void 0?void 0:n.find(y=>y.toLowerCase()!==(s==null?void 0:s.address.toLowerCase()));F(a,g.provider.unauthorized("no global account")),F((r=i.chain)===null||r===void 0?void 0:r.id,g.provider.unauthorized("no chain id")),F(s==null?void 0:s.address,g.provider.unauthorized("no sub account"));const o=[];if(e.type==="local"&&e.address&&o.push({to:s.address,data:me({abi:Y,functionName:"addOwnerAddress",args:[e.address]}),value:Ae(0)}),e.publicKey){const[y,b]=Jn([{type:"bytes32"},{type:"bytes32"}],e.publicKey);o.push({to:s.address,data:me({abi:Y,functionName:"addOwnerPublicKey",args:[y,b]}),value:Ae(0)})}const c={method:"wallet_sendCalls",params:[{version:"1",calls:o,chainId:q(84532),from:a}]};if(await kc()==="cancel")throw g.provider.unauthorized("user cancelled");const d=await t(c),l=wr(i.chain.id);if(F(l,g.rpc.internal(`client not found for chainId ${i.chain.id}`)),(await Fn(l,{id:d})).status!=="success")throw g.rpc.internal("add owner call failed");const f=await Wr({address:s.address,publicKey:e.type==="local"&&e.address?e.address:e.publicKey,client:l});if(f===-1)throw g.rpc.internal("failed to find owner index");return f}async function Sc({errorData:e,globalAccountAddress:t,subAccountAddress:n,client:r,request:i,subAccountRequest:s,globalAccountRequest:a}){var o;const c=(o=r.chain)===null||o===void 0?void 0:o.id;F(c,g.rpc.internal("invalid chainId"));const u=oc({errorData:e,sourceAddress:t}),d=await ac();if(d==="cancel")throw new Error("User cancelled funding");let l;const h=60*60*24,f=3;if(d==="update_permission"){if(u.length===1){const k=u[0],x=ic({spendPermission:{token:k.token,allowance:q(k.requiredAmount*BigInt(f)),period:h,account:t,spender:n,start:0,end:0xffffffffffff,salt:q(BigInt(Math.floor(Math.random()*Number.MAX_SAFE_INTEGER))),extraData:"0x"},chainId:c});l={method:"eth_signTypedData_v4",params:[t,x]}}else{const k=sc({spendPermissionBatch:{account:t,period:h,start:0,end:0xffffffffffff,permissions:u.map(x=>({token:x.token,allowance:q(x.requiredAmount*BigInt(f)),period:h,account:t,spender:n,salt:"0x0",extraData:"0x"}))},chainId:c});l={method:"eth_signTypedData_v4",params:[t,k]}}try{await a(l)}catch(k){throw console.error(k),new Error("User denied spend permission request")}return s(i)}const y=u.map(k=>k.token.toLowerCase()==="0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE".toLowerCase()?{to:n,value:q(k.requiredAmount),data:"0x"}:{to:k.token,value:"0x0",data:me({abi:Yi,functionName:"transfer",args:[n,k.requiredAmount]})});let b;if(i.method==="wallet_sendCalls"&&cc(i.params))b=i.params[0];else if(i.method==="eth_sendTransaction"&&uc(i.params))b=zr({calls:[i.params[0]],chainId:c,from:i.params[0].from}).params[0];else throw new Error("Could not get original call");const m=me({abi:Y,functionName:"executeBatch",args:[b.calls.map(k=>{var x,P;return{target:k.to,value:it((x=k.value)!==null&&x!==void 0?x:"0x0"),data:(P=k.data)!==null&&P!==void 0?P:"0x"}})]}),v=[...y,{data:m,to:n,value:"0x0"}],E=await a({method:"wallet_sendCalls",params:[Object.assign(Object.assign({},b),{calls:v,from:t})]});return i.method==="eth_sendTransaction"?$r({client:r,id:E}):E}class qr{constructor(t){var n,r,i,s;this.communicator=t.communicator,this.callback=t.callback,this.keyManager=new Xo;const{account:a,chains:o}=w.getState();this.accounts=(n=a.accounts)!==null&&n!==void 0?n:[],this.chain=(r=a.chain)!==null&&r!==void 0?r:{id:(s=(i=t.metadata.appChainIds)===null||i===void 0?void 0:i[0])!==null&&s!==void 0?s:1},o&&gn(o)}async handshake(t){var n,r,i;const s=J.get(t);Sa({method:t.method,correlationId:s});try{await((r=(n=this.communicator).waitForPopupLoaded)===null||r===void 0?void 0:r.call(n));const a=await this.createRequestMessage({handshake:{method:t.method,params:(i=t.params)!==null&&i!==void 0?i:[]}}
4,s),o=await this.communicator.postRequestAndWaitForResponse(a);if("failure"in o.content)throw o.content.failure;const c=await _r("public",o.sender);await this.keyManager.setPeerPublicKey(c);const u=await this.decryptResponseMessage(o);this.handleResponse(t,u),Ea({method:t.method,correlationId:s})}catch(a){throw xa({method:t.method,correlationId:s,errorMessage:we(a)}),a}}async request(t){const n=J.get(t);Aa({method:t.method,correlationId:n});try{const r=await this._request(t);return Ta({method:t.method,correlationId:n}),r}catch(r){throw Ia({method:t.method,correlationId:n,errorMessage:we(r)}),r}}async _request(t){var n,r,i,s,a,o,c,u,d,l,h,f,y,b;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 yt(),await this.request({method:"wallet_connect",params:[{version:"1",capabilities:Object.assign({},(s=(i=w.subAccountsConfig.get())===null||i===void 0?void 0:i.capabilities)!==null&&s!==void 0?s:{})}]}),this.accounts;case"wallet_switchEthereumChain":{Cn(t.params),this.chain.id=Number(t.params[0].chainId);return}case"wallet_connect":{await((o=(a=this.communicator).waitForPopupLoaded)===null||o===void 0?void 0:o.call(a)),await yt();let m={};fc(t,"addSubAccount")&&(m=(u=(c=w.subAccountsConfig.get())===null||c===void 0?void 0:c.capabilities)!==null&&u!==void 0?u:{});const v=ot(t,m);return this.sendRequestToPopup(v)}case"wallet_sendCalls":case"wallet_sign":return this.sendRequestToPopup(t);default:throw g.provider.unauthorized()}if(this.shouldRequestUseSubAccountSigner(t)){const m=J.get(t);Ca({method:t.method,correlationId:m});try{const v=await this.sendRequestToSubAccountSigner(t);return Pa({method:t.method,correlationId:m}),v}catch(v){throw Oa({method:t.method,correlationId:m,errorMessage:we(v)}),v}}switch(t.method){case"eth_requestAccounts":case"eth_accounts":{const m=w.subAccounts.get(),v=w.subAccountsConfig.get();return m!=null&&m.address&&(this.accounts=v!=null&&v.enableAutoSubAccounts?Ze(this.accounts,m.address):Xe(this.accounts,m.address)),(d=this.callback)===null||d===void 0||d.call(this,"connect",{chainId:q(this.chain.id)}),this.accounts}case"eth_coinbase":return this.accounts[0];case"net_version":return this.chain.id;case"eth_chainId":return q(this.chain.id);case"wallet_getCapabilities":return this.handleGetCapabilitiesRequest(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 m=await hc();if(m)return m;await((h=(l=this.communicator).waitForPopupLoaded)===null||h===void 0?void 0:h.call(l)),await yt();const v=w.subAccountsConfig.get(),E=ot(t,(f=v==null?void 0:v.capabilities)!==null&&f!==void 0?f:{});return(y=this.callback)===null||y===void 0||y.call(this,"connect",{chainId:q(this.chain.id)}),this.sendRequestToPopup(E)}case"wallet_getSubAccounts":{const m=w.subAccounts.get();if(m!=null&&m.address)return{subAccounts:[m]};if(!this.chain.rpcUrl)throw g.rpc.internal("No RPC URL set for chain");const v=await $e(t,this.chain.rpcUrl);if(he(v.subAccounts,"subAccounts"),v.subAccounts.length>0){Je(v.subAccounts[0]);const E=v.subAccounts[0];w.subAccounts.set({address:E.address,factory:E.factory,factoryData:E.factoryData})}return v}case"wallet_addSubAccount":return this.addSubAccount(t);case"coinbase_fetchPermissions":{nc(t);const m=rc(t),v=await $e(m,lr),E=pt((b=m.params)===null||b===void 0?void 0:b[0].chainId);return w.spendPermissions.set(v.permissions.map(k=>Object.assign(Object.assign({},k),{chainId:E}))),v}default:if(!this.chain.rpcUrl)throw g.rpc.internal("No RPC URL set for chain");return $e(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 i=await this.sendEncryptedRequest(t),s=await this.decryptResponseMessage(i);return this.handleResponse(t,s)}async handleResponse(t,n){var r,i,s,a,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,w.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(v=>v.address);this.accounts=d,w.account.set({accounts:d});const l=u.accounts.at(0),h=l==null?void 0:l.capabilities;if(h!=null&&h.subAccounts){const v=h==null?void 0:h.subAccounts;he(v,"subAccounts"),Je(v[0]),w.subAccounts.set({address:v[0].address,factory:v[0].factory,factoryData:v[0].factoryData})}let f=[this.accounts[0]];const y=w.subAccounts.get(),b=w.subAccountsConfig.get();y!=null&&y.address&&(this.accounts=b!=null&&b.enableAutoSubAccounts?Ze(this.accounts,y.address):Xe(this.accounts,y.address));const m=(s=(i=u==null?void 0:u.accounts)===null||i===void 0?void 0:i[0].capabilities)===null||s===void 0?void 0:s.spendPermissions;m&&"permissions"in m&&w.spendPermissions.set(m==null?void 0:m.permissions),(a=this.callback)===null||a===void 0||a.call(this,"accountsChanged",f);break}case"wallet_addSubAccount":{Je(c.value);const u=c.value;w.subAccounts.set(u);const d=w.subAccountsConfig.get();this.accounts=d!=null&&d.enableAutoSubAccounts?Ze(this.accounts,u.address):Xe(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=w.config.get().metadata;await this.keyManager.clear(),w.account.clear(),w.subAccounts.clear(),w.spendPermissions.clear(),w.chains.clear(),this.accounts=[],this.chain={id:(n=(t=r==null?void 0:r.appChainIds)===null||t===void 0?void 0:t[0])!==null&&n!==void 0?n:1}}async handleSwitchChainRequest(t){Cn(t.params);const n=He(t.params[0].chainId);if(this.updateChain(n))return null;const i=await this.sendRequestToPopup(t);return i===null&&this.updateChain(n),i}async handleGetCapabilitiesRequest(t){tc(t.params);const n=t.params[0],r=t.params[1];if(!this.accounts.some(o=>Qi(o,n)))throw g.provider.unauthorized("no active account found when getting capabilities");const i=w.getState().account.capabilities;if(!i)return{};if(!r||r.length===0)return i;const s=new Set(r.map(o=>pt(o)));return Object.fromEntries(Object.entries(i).filter(([o])=>{try{const c=pt(o);return s.has(c)}catch{return!1}}
4))}async sendEncryptedRequest(t){const n=await this.keyManager.getSharedSecret();if(!n)throw g.provider.unauthorized("No shared secret found when encrypting request");const r=await za({action:t,chainId:this.chain.id},n),i=J.get(t),s=await this.createRequestMessage({encrypted:r},i);return this.communicator.postRequestAndWaitForResponse(s)}async createRequestMessage(t,n){const r=await kr("public",await this.keyManager.getOwnPublicKey());return{id:crypto.randomUUID(),correlationId:n,sender:r,content:t,timestamp:new Date}}async decryptResponseMessage(t){var n,r,i;const s=t.content;if("failure"in s)throw s.failure;const a=await this.keyManager.getSharedSecret();if(!a)throw g.provider.unauthorized("Invalid session: no shared secret found when decrypting response");const o=await Wa(s.encrypted,a),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(([h,f])=>{const y=d==null?void 0:d[Number(h)];return Object.assign({id:Number(h),rpcUrl:f},y?{nativeCurrency:y}:{})});w.chains.set(l),this.updateChain(this.chain.id,l),gn(l)}const u=(i=o.data)===null||i===void 0?void 0:i.capabilities;return u&&w.account.set({capabilities:u}),o}updateChain(t,n){var r;const i=w.getState(),s=n??i.chains,a=s==null?void 0:s.find(o=>o.id===t);return a?(a!==this.chain&&(this.chain=a,w.account.set({chain:a}),(r=this.callback)===null||r===void 0||r.call(this,"chainChanged",Ee(a.id))),!0):!1}async addSubAccount(t){var n,r,i,s;const o=w.getState().subAccount,c=w.subAccountsConfig.get();if(o!=null&&o.address)return this.accounts=c!=null&&c.enableAutoSubAccounts?Ze(this.accounts,o.address):Xe(this.accounts,o.address),(n=this.callback)===null||n===void 0||n.call(this,"accountsChanged",this.accounts),o;if(await((i=(r=this.communicator).waitForPopupLoaded)===null||i===void 0?void 0:i.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=w.subAccountsConfig.get())!==null&&s!==void 0?s:{},{account:h}=l.toOwnerAccount?await l.toOwnerAccount():await Pt();if(!h)throw g.provider.unauthorized("could not get subaccount owner account when adding sub account");d=[{type:h.address?"address":"webauthn-p256",publicKey:h.address||h.publicKey}]}t.params[0].account.keys=d}const u=await this.sendRequestToPopup(t);return Je(u),u}shouldRequestUseSubAccountSigner(t){const n=Tn(t),r=w.subAccounts.get();return n?n.toLowerCase()===(r==null?void 0:r.address.toLowerCase()):!1}async sendRequestToSubAccountSigner(t){var n;const r=w.subAccounts.get(),i=w.subAccountsConfig.get(),s=w.config.get();F(r==null?void 0:r.address,g.provider.unauthorized("no active sub account when sending request to sub account signer"));const a=i!=null&&i.toOwnerAccount?await i.toOwnerAccount():await Pt();F(a==null?void 0:a.account,g.provider.unauthorized("no active sub account owner when sending request to sub account signer")),Tn(t)===void 0&&(t=ec(t,r.address));const c=wr(this.chain.id);F(c,g.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());F(u,g.provider.unauthorized("no global account found when sending request to sub account signer"));const d=dc({attribution:(n=s.preference)===null||n===void 0?void 0:n.attribution,dappOrigin:window.location.origin}),l=a.account.type==="local"?a.account.address:a.account.publicKey;let h=await Wr({address:r.address,factory:r.factory,factoryData:r.factoryData,publicKey:l,client:c});if(h===-1){const y=J.get(t);ja({method:t.method,correlationId:y});try{h=await _c({ownerAccount:a.account,globalAccountRequest:this.sendRequestToPopup.bind(this)}),Ma({method:t.method,correlationId:y})}catch(b){return Na({method:t.method,correlationId:y,errorMessage:we(b)}),g.provider.unauthorized("failed to add sub account owner when sending request to sub account signer")}}const{request:f}=await vc({address:r.address,owner:a.account,client:c,factory:r.factory,factoryData:r.factoryData,parentAddress:u,attribution:d?{suffix:d}:void 0,ownerIndex:h});try{return await f(t)}catch(y){let b;if(ir(y))b=JSON.parse(y.details);else if(dn(y))b=y;else throw y;if(!(dn(b)&&b.data)||!b.data)throw y;const m=J.get(t);La({method:t.method,correlationId:m});try{const v=await Sc({errorData:b.data,globalAccountAddress:u,subAccountAddress:r.address,client:c,request:t,subAccountRequest:f,globalAccountRequest:this.request.bind(this)});return Ra({method:t.method,correlationId:m}),v}catch(v){throw console.error(v),Da({method:t.method,correlationId:m,errorMessage:we(v)}),y}}}}const xc=({method:e,correlationId:t})=>{C("walletlink_signer.handshake.started",{action:I.unknown,componentType:A.unknown,method:e,correlationId:t},T.high)},Ec=({method:e,correlationId:t,errorMessage:n})=>{C("walletlink_signer.handshake.error",{action:I.error,componentType:A.unknown,method:e,correlationId:t,errorMessage:n},T.high)},Ac=({method:e,correlationId:t})=>{C("walletlink_signer.handshake.completed",{action:I.unknown,componentType:A.unknown,method:e,correlationId:t},T.high)},Ic=({method:e,correlationId:t})=>{C("walletlink_signer.request.started",{action:I.unknown,componentType:A.unknown,method:e,correlationId:t},T.high)},Tc=({method:e,correlationId:t,errorMessage:n})=>{C("walletlink_signer.request.error",{action:I.error,componentType:A.unknown,method:e,correlationId:t,errorMessage:n},T.high)},Cc=({method:e,correlationId:t})=>{C("walletlink_signer.request.completed",{action:I.unknown,componentType:A.unknown,method:e,correlationId:t},T.high)},On=()=>{C("walletlink_signer.walletlink_connection.connection_failed",{action:I.measurement,componentType:A.unknown},T.high)},Pc=()=>{C("walletlink_signer.walletlink_connection.fetch_unseen_events_failed",{action:I.measurement,componentType:A.unknown},T.high)};var j={},B={};Object.defineProperty(B,"__esModule",{value:!0});B.output=B.exists=B.hash=B.bytes=B.bool=B.number=B.isBytes=void 0;function ct(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}B.number=ct;function Fr(e){if(typeof e!="boolean")throw new Error(`boolean expected, not ${e}`)}B.bool=Fr;function Kr(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}B.isBytes=Kr;function Vt(e,...t){if(!Kr(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}`)}
4B.bytes=Vt;function Vr(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");ct(e.outputLen),ct(e.blockLen)}B.hash=Vr;function Gr(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")}B.exists=Gr;function Jr(e,t){Vt(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}B.output=Jr;const Oc={number:ct,bool:Fr,bytes:Vt,hash:Vr,exists:Gr,output:Jr};B.default=Oc;var _={};Object.defineProperty(_,"__esModule",{value:!0});_.add5L=_.add5H=_.add4H=_.add4L=_.add3H=_.add3L=_.add=_.rotlBL=_.rotlBH=_.rotlSL=_.rotlSH=_.rotr32L=_.rotr32H=_.rotrBL=_.rotrBH=_.rotrSL=_.rotrSH=_.shrSL=_.shrSH=_.toBig=_.split=_.fromBig=void 0;const nt=BigInt(2**32-1),Ot=BigInt(32);function Gt(e,t=!1){return t?{h:Number(e&nt),l:Number(e>>Ot&nt)}:{h:Number(e>>Ot&nt)|0,l:Number(e&nt)|0}}_.fromBig=Gt;function Yr(e,t=!1){let n=new Uint32Array(e.length),r=new 
4Uint32Array(e.length);for(let i=0;i<e.length;i++){const{h:s,l:a}=Gt(e[i],t);[n[i],r[i]]=[s,a]}return[n,r]}_.split=Yr;const Qr=(e,t)=>BigInt(e>>>0)<<Ot|BigInt(t>>>0);_.toBig=Qr;const Zr=(e,t,n)=>e>>>n;_.shrSH=Zr;const Xr=(e,t,n)=>e<<32-n|t>>>n;_.shrSL=Xr;const ei=(e,t,n)=>e>>>n|t<<32-n;_.rotrSH=ei;const ti=(e,t,n)=>e<<32-n|t>>>n;_.rotrSL=ti;const ni=(e,t,n)=>e<<64-n|t>>>n-32;_.rotrBH=ni;const ri=(e,t,n)=>e>>>n-32|t<<64-n;_.rotrBL=ri;const ii=(e,t)=>t;_.rotr32H=ii;const si=(e,t)=>e;_.rotr32L=si;const ai=(e,t,n)=>e<<n|t>>>32-n;_.rotlSH=ai;const oi=(e,t,n)=>t<<n|e>>>32-n;_.rotlSL=oi;const ci=(e,t,n)=>t<<n-32|e>>>64-n;_.rotlBH=ci;const ui=(e,t,n)=>e<<n-32|t>>>64-n;_.rotlBL=ui;function li(e,t,n,r){const i=(t>>>0)+(r>>>0);return{h:e+n+(i/2**32|0)|0,l:i|0}}_.add=li;const di=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0);_.add3L=di;const fi=(e,t,n,r)=>t+n+r+(e/2**32|0)|0;_.add3H=fi;const hi=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0);_.add4L=hi;const pi=(e,t,n,r,i)=>t+n+r+i+(e/2**32|0)|0;_.add4H=pi;const mi=(e,t,n,r,i)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(i>>>0);_.add5L=mi;const gi=(e,t,n,r,i,s)=>t+n+r+i+s+(e/2**32|0)|0;_.add5H=gi;const jc={fromBig:Gt,split:Yr,toBig:Qr,shrSH:Zr,shrSL:Xr,rotrSH:ei,rotrSL:ti,rotrBH:ni,rotrBL:ri,rotr32H:ii,rotr32L:si,rotlSH:ai,rotlSL:oi,rotlBH:ci,rotlBL:ui,add:li,add3L:di,add3H:fi,add4L:hi,add4H:pi,add5H:gi,add5L:mi};_.default=jc;var bi={},ft={};Object.defineProperty(ft,"__esModule",{value:!0});ft.crypto=void 0;ft.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=ft,n=B;function r(p){return p instanceof Uint8Array||p!=null&&typeof p=="object"&&p.constructor.name==="Uint8Array"}e.isBytes=r;const i=p=>new Uint8Array(p.buffer,p.byteOffset,p.byteLength);e.u8=i;const s=p=>new Uint32Array(p.buffer,p.byteOffset,Math.floor(p.byteLength/4));e.u32=s;const a=p=>new DataView(p.buffer,p.byteOffset,p.byteLength);e.createView=a;const o=(p,S)=>p<<32-S|p>>>S;e.rotr=o;const c=(p,S)=>p<<S|p>>>32-S>>>0;e.rotl=c,e.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;const u=p=>p<<24&4278190080|p<<8&16711680|p>>>8&65280|p>>>24&255;e.byteSwap=u,e.byteSwapIfBE=e.isLE?p=>p:p=>(0,e.byteSwap)(p);function d(p){for(let S=0;S<p.length;S++)p[S]=(0,e.byteSwap)(p[S])}e.byteSwap32=d;const l=Array.from({length:256},(p,S)=>S.toString(16).padStart(2,"0"));function h(p){(0,n.bytes)(p);let S="";for(let L=0;L<p.length;L++)S+=l[p[L]];return S}e.bytesToHex=h;const f={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function y(p){if(p>=f._0&&p<=f._9)return p-f._0;if(p>=f._A&&p<=f._F)return p-(f._A-10);if(p>=f._a&&p<=f._f)return p-(f._a-10)}function b(p){if(typeof p!="string")throw new Error("hex string expected, got "+typeof p);const S=p.length,L=S/2;if(S%2)throw new Error("padded hex string expected, got unpadded hex of length "+S);const N=new Uint8Array(L);for(let U=0,z=0;U<L;U++,z+=2){const Qt=y(p.charCodeAt(z)),Zt=y(p.charCodeAt(z+1));if(Qt===void 0||Zt===void 0){const Hi=p[z]+p[z+1];throw new Error('hex string expected, got non-hex character "'+Hi+'" at index '+z)}N[U]=Qt*16+Zt}return N}e.hexToBytes=b;const m=async()=>{};e.nextTick=m;async function v(p,S,L){let N=Date.now();for(let U=0;U<p;U++){L(U);const z=Date.now()-N;z>=0&&z<S||(await(0,e.nextTick)(),N+=z)}}e.asyncLoop=v;function E(p){if(typeof p!="string")throw new Error(`utf8ToBytes expected string, got ${typeof p}`);return new Uint8Array(new TextEncoder().encode(p))}e.utf8ToBytes=E;function k(p){return typeof p=="string"&&(p=E(p)),(0,n.bytes)(p),p}e.toBytes=k;function x(...p){let S=0;for(let N=0;N<p.length;N++){const U=p[N];(0,n.bytes)(U),S+=U.length}const L=new Uint8Array(S);for(let N=0,U=0;N<p.length;N++){const z=p[N];L.set(z,U),U+=z.length}return L}e.concatBytes=x;class P{clone(){return this._cloneInto()}}e.Hash=P;const ne={}.toString;function oe(p,S){if(S!==void 0&&ne.call(S)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(p,S)}e.checkOpts=oe;function Ne(p){const S=N=>p().update(k(N)).digest(),L=p();return S.outputLen=L.outputLen,S.blockLen=L.blockLen,S.create=()=>p(),S}e.wrapConstructor=Ne;function Yt(p){const S=(N,U)=>p(U).update(k(N)).digest(),L=p({});return S.outputLen=L.outputLen,S.blockLen=L.blockLen,S.create=N=>p(N),S}e.wrapConstructorWithOpts=Yt;function Bi(p){const S=(N,U)=>p(U).update(k(N)).digest(),L=p({});return S.outputLen=L.outputLen,S.blockLen=L.blockLen,S.create=N=>p(N),S}e.wrapXOFConstructorWithOpts=Bi;function Ui(p=32){if(t.crypto&&typeof t.crypto.getRandomValues=="function")return t.crypto.getRandomValues(new Uint8Array(p));throw new Error("crypto.getRandomValues must be defined")}e.randomBytes=Ui})(bi);Object.defineProperty(j,"__esModule",{value:!0});j.shake256=j.shake128=j.keccak_512=j.keccak_384=j.keccak_256=j.keccak_224=j.sha3_512=j.sha3_384=j.sha3_256=j.sha3_224=j.Keccak=j.keccakP=void 0;const Se=B,Fe=_,ie=bi,yi=[],wi=[],vi=[],Mc=BigInt(0),De=BigInt(1),Nc=BigInt(2),Lc=BigInt(7),Rc=BigInt(256),Dc=BigInt(113);for(let e=0,t=De,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],yi.push(2*(5*r+n)),wi.push((e+1)*(e+2)/2%64);let i=Mc;for(let s=0;s<7;s++)t=(t<<De^(t>>Lc)*Dc)%Rc,t&Nc&&(i^=De<<(De<<BigInt(s))-De);vi.push(i)}const[Bc,Uc]=(0,Fe.split)(vi,!0),jn=(e,t,n)=>n>
432?(0,Fe.rotlBH)(e,t,n):(0,Fe.rotlSH)(e,t,n),Mn=(e,t,n)=>n>32?(0,Fe.rotlBL)(e,t,n):(0,Fe.rotlSL)(e,t,n);function ki(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let a=0;a<10;a++)n[a]=e[a]^e[a+10]^e[a+20]^e[a+30]^e[a+40];for(let a=0;a<10;a+=2){const o=(a+8)%10,c=(a+2)%10,u=n[c],d=n[c+1],l=jn(u,d,1)^n[o],h=Mn(u,d,1)^n[o+1];for(let f=0;f<50;f+=10)e[a+f]^=l,e[a+f+1]^=h}let i=e[2],s=e[3];for(let a=0;a<24;a++){const o=wi[a],c=jn(i,s,o),u=Mn(i,s,o),d=yi[a];i=e[d],s=e[d+1],e[d]=c,e[d+1]=u}for(let a=0;a<50;a+=10){for(let o=0;o<10;o++)n[o]=e[a+o];for(let o=0;o<10;o++)e[a+o]^=~n[(o+2)%10]&n[(o+4)%10]}e[0]^=Bc[r],e[1]^=Uc[r]}n.fill(0)}j.keccakP=ki;class Ke extends ie.Hash{constructor(t,n,r,i=!1,s=24){if(super(),this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=i,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,(0,Se.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),ki(this.state32,this.rounds),ie.isLE||(0,ie.byteSwap32)(this.state32),this.posOut=0,this.pos=0}update(t){(0,Se.exists)(this);const{blockLen:n,state:r}=this;t=(0,ie.toBytes)(t);const i=t.length;for(let s=0;s<i;){const a=Math.min(n-this.pos,i-s);for(let o=0;o<a;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:i}=this;t[r]^=n,n&128&&r===i-1&&this.keccak(),t[i-1]^=128,this.keccak()}writeInto(t){(0,Se.exists)(this,!1),(0,Se.bytes)(t),this.finish();const n=this.state,{blockLen:r}=this;for(let i=0,s=t.length;i<s;){this.posOut>=r&&this.keccak();const a=Math.min(r-this.posOut,s-i);t.set(n.subarray(this.posOut,this.posOut+a),i),this.posOut+=a,i+=a}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,Se.number)(t),this.xofInto(new Uint8Array(t))}digestInto(t){if((0,Se.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:i,rounds:s,enableXOF:a}=this;return t||(t=new Ke(n,r,i,a,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=i,t.enableXOF=a,t.destroyed=this.destroyed,t}}j.Keccak=Ke;const be=(e,t,n)=>(0,ie.wrapConstructor)(()=>new Ke(t,e,n));j.sha3_224=be(6,144,224/8);j.sha3_256=be(6,136,256/8);j.sha3_384=be(6,104,384/8);j.sha3_512=be(6,72,512/8);j.keccak_224=be(1,144,224/8);j.keccak_256=be(1,136,256/8);j.keccak_384=be(1,104,384/8);j.keccak_512=be(1,72,512/8);const _i=(e,t,n)=>(0,ie.wrapXOFConstructorWithOpts)((r={})=>new Ke(t,e,r.dkLen===void 0?n:r.dkLen,!0));j.shake128=_i(31,168,128/8);j.shake256=_i(31,136,256/8);const{keccak_256:Hc}=j;function Si(e){return Buffer.allocUnsafe(e).fill(0)}function $c(e){return`0x${e.toString(16)}`}function zc(e){const t=$c(e);return new Buffer(Ai(t.slice(2)),"hex")}function Wc(e){return e.toString(2).length}function xi(e,t){let n=e.toString(16);n.length%2!==0&&(n="0"+n);const r=n.match(/.{1,2}/g).map(i=>parseInt(i,16));for(;r.length<t;)r.unshift(0);return Buffer.from(r)}function qc(e,t){const n=e<0n;let r;if(n){const i=(1n<<BigInt(t))-1n;r=(~e&i)+1n}else r=e;return r&=(1n<<BigInt(t))-1n,r}function Ei(e,t,n){const r=Si(t);return e=ht(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 Fc(e,t){return Ei(e,t,!0)}function ht(e){if(!Buffer.isBuffer(e))if(Array.isArray(e))e=Buffer.from(e);else if(typeof e=="string")Ii(e)?e=Buffer.from(Ai(Ti(e)),"hex"):e=Buffer.from(e);else if(typeof e=="number")e=zc(e);else if(e==null)e=Buffer.allocUnsafe(0);else if(typeof e=="bigint")e=xi(e);else if(e.toArray)e=Buffer.from(e.toArray());else throw new Error("invalid type");return e}function Kc(e){return e=ht(e),"0x"+e.toString("hex")}function Vc(e,t){if(e=ht(e),t||(t=256),t!==256)throw new Error("unsupported");return Buffer.from(Hc(new Uint8Array(e)))}function Ai(e){return e.length%2?"0"+e:e}function Ii(e){return typeof e=="string"&&e.match(/^0x[0-9A-Fa-f]*$/)}function Ti(e){return typeof e=="string"&&e.startsWith("0x")?e.slice(2):e}var Ci={zeros:Si,setLength:Ei,setLengthRight:Fc,isHexString:Ii,stripHexPrefix:Ti,toBuffer:ht,bufferToHex:Kc,keccak:Vc,bitLengthFromBigInt:Wc,bufferBEFromBigInt:xi,twosFromBigInt:qc};const $=Ci;function Pi(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 Te(e){return Number.parseInt(/^\D+(\d+)$/.exec(e)[1],10)}function Nn(e){var t=/^\D+(\d+)x(\d+)$/.exec(e);return[Number.parseInt(t[1],10),Number.parseInt(t[2],10)]}function Oi(e){var t=e.match(/(.*)\[(.*?)\]$/);return t?t[2]===""?"dynamic":Number.parseInt(t[2],10):null}function ve(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 ee(e,t){var n,r,i,s;if(e==="address")return ee("uint160",ve(t));if(e==="bool")return ee("uint8",t?1:0);if(e==="string")return ee("bytes",new Buffer(t,"utf8"));if(Jc(e)){if(typeof t.length>"u")throw new Error("Not an array?");if(n=Oi(e),n!=="dynamic"&&n!==0&&t.length>n)throw new Error("Elements exceed array size: "+n);i=[],e=e.slice(0,e.lastIndexOf("[")),typeof t=="string"&&(t=JSON.parse(t));for(s in t)i.push(ee(e,t[s]));if(n==="dynamic"){var a=ee("uint256",t.length);i.unshift(a)}return Buffer.concat(i)}else{if(e==="bytes")return t=new Buffer(t),i=Buffer.concat([ee("uint256",t.length),t]),t.length%32!==0&&(i=Buffer.concat([i,$.zeros(32-t.length%32)])),i;if(e.startsWith("bytes")){if(n=Te(e),n<1||n>32)throw new Error("Invalid bytes<N> width: "+n);return $.setLengthRight(t,32)}else if(e.startsWith("uint")){if(n=Te(e),n%8||n<8||n>256)throw new Error("Invalid uint<N> width: "+n);r=ve(t);const o=$.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 $.bufferBEFromBigInt(r,32)}else if(e.startsWith("int")){if(n=Te(e),n%8||n<8||n>256)throw new Error("Invalid int<N> width: "+n);r=ve(t);const o=$.bitLengthFromBigInt(r);if(o>n)throw new Error("Supplied int exceeds width: "+n+" vs "+o);const c=$.twosFromBigInt(r,256);return $.bufferBEFromBigInt(c,32)}else if(e.startsWith("ufixed")){if(n=Nn(e),r=ve(t),r<0)throw new Error("Supplied ufixed is negative");return ee("uint256",r*BigInt(2)**BigInt(n[1]))}else if(e.startsWith("fixed"))return n=Nn(e),ee("int256",ve(t)*BigInt(2)**BigInt(n[1]))}throw new Error("Unsupported or invalid type: "+e)}function Gc(e){return e==="string"||e==="bytes"||Oi(e)==="dynamic"}
4function Jc(e){return e.lastIndexOf("]")===e.length-1}function Yc(e,t){var n=[],r=[],i=32*e.length;for(var s in e){var a=Pi(e[s]),o=t[s],c=ee(a,o);Gc(a)?(n.push(ee("uint256",i)),r.push(c),i+=c.length):n.push(c)}return Buffer.concat(n.concat(r))}function ji(e,t){if(e.length!==t.length)throw new Error("Number of types are not matching the values");for(var n,r,i=[],s=0;s<e.length;s++){var a=Pi(e[s]),o=t[s];if(a==="bytes")i.push(o);else if(a==="string")i.push(new Buffer(o,"utf8"));else if(a==="bool")i.push(new Buffer(o?"01":"00","hex"));else if(a==="address")i.push($.setLength(o,20));else if(a.startsWith("bytes")){if(n=Te(a),n<1||n>32)throw new Error("Invalid bytes<N> width: "+n);i.push($.setLengthRight(o,n))}else if(a.startsWith("uint")){if(n=Te(a),n%8||n<8||n>256)throw new Error("Invalid uint<N> width: "+n);r=ve(o);const c=$.bitLengthFromBigInt(r);if(c>n)throw new Error("Supplied uint exceeds width: "+n+" vs "+c);i.push($.bufferBEFromBigInt(r,n/8))}else if(a.startsWith("int")){if(n=Te(a),n%8||n<8||n>256)throw new Error("Invalid int<N> width: "+n);r=ve(o);const c=$.bitLengthFromBigInt(r);if(c>n)throw new Error("Supplied int exceeds width: "+n+" vs "+c);const u=$.twosFromBigInt(r,n);i.push($.bufferBEFromBigInt(u,n/8))}else throw new Error("Unsupported or invalid type: "+a)}return Buffer.concat(i)}function Qc(e,t){return $.keccak(ji(e,t))}var Zc={rawEncode:Yc,solidityPack:ji,soliditySHA3:Qc};const G=Ci,We=Zc,Mi={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"]},vt={encodeData(e,t,n,r=!0){const i=["bytes32"],s=[this.hashType(e,n)];if(r){const a=(o,c,u)=>{if(n[c]!==void 0)return["bytes32",u==null?"0x0000000000000000000000000000000000000000000000000000000000000000":G.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",G.keccak(u)];if(c==="string")return typeof u=="string"&&(u=Buffer.from(u,"utf8")),["bytes32",G.keccak(u)];if(c.lastIndexOf("]")===c.length-1){const d=c.slice(0,c.lastIndexOf("[")),l=u.map(h=>a(o,d,h));return["bytes32",G.keccak(We.rawEncode(l.map(([h])=>h),l.map(([,h])=>h)))]}return[c,u]};for(const o of n[e]){const[c,u]=a(o.name,o.type,t[o.name]);i.push(c),s.push(u)}}else for(const a of n[e]){let o=t[a.name];if(o!==void 0)if(a.type==="bytes")i.push("bytes32"),o=G.keccak(o),s.push(o);
4else if(a.type==="string")i.push("bytes32"),typeof o=="string"&&(o=Buffer.from(o,"utf8")),o=G.keccak(o),s.push(o);else if(n[a.type]!==void 0)i.push("bytes32"),o=G.keccak(this.encodeData(a.type,o,n,r)),s.push(o);else{if(a.type.lastIndexOf("]")===a.type.length-1)throw new Error("Arrays currently unimplemented in encodeData");i.push(a.type),s.push(o)}}return We.rawEncode(i,s)},encodeType(e,t){let n="",r=this.findTypeDependencies(e,t).filter(i=>i!==e);r=[e].concat(r.sort());for(const i of r){if(!t[i])throw new Error("No type definition specified: "+i);n+=i+"("+t[i].map(({name:a,type:o})=>o+" "+a).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 i of this.findTypeDependencies(r.type,t,n))!n.includes(i)&&n.push(i);return n},hashStruct(e,t,n,r=!0){return G.keccak(this.encodeData(e,t,n,r))},hashType(e,t){return G.keccak(this.encodeType(e,t))},sanitizeData(e){const t={};for(const n in Mi.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)),G.keccak(Buffer.concat(r))}};var Xc={TYPED_MESSAGE_SCHEMA:Mi,TypedDataUtils:vt,hashForSignTypedDataLegacy:function(e){return eu(e.data)},hashForSignTypedData_v3:function(e){return vt.hash(e.data,!1)},hashForSignTypedData_v4:function(e){return vt.hash(e.data)}};function eu(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"?G.toBuffer(s.value):s.value}),r=e.map(function(s){return s.type}),i=e.map(function(s){if(!s.name)throw t;return s.type+" "+s.name});return We.soliditySHA3(["bytes32","bytes32"],[We.soliditySHA3(new Array(e.length).fill("string"),i),We.soliditySHA3(r,n)])}const rt=qn(Xc),tu="walletUsername",jt="Addresses",nu="AppVersion";class ru{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)),i=await crypto.subtle.importKey("raw",st(n),{name:"aes-gcm"},!1,["encrypt","decrypt"]),s=new TextEncoder,a=await window.crypto.subtle.encrypt({name:"AES-GCM",iv:r},i,s.encode(t)),o=16,c=a.slice(a.byteLength-o),u=a.slice(0,a.byteLength-o),d=new Uint8Array(c),l=new Uint8Array(u),h=new Uint8Array([...r,...d,...l]);return Dt(h)}async decrypt(t){const n=this.secret;if(n.length!==64)throw new Error("secret must be 256 bits");return new Promise((r,i)=>{(async()=>{const s=await crypto.subtle.importKey("raw",st(n),{name:"aes-gcm"},!1,["encrypt","decrypt"]),a=st(t),o=a.slice(0,12),c=a.slice(12,28),u=a.slice(28),d=new Uint8Array([...u,...c]),l={name:"AES-GCM",iv:new Uint8Array(o)};try{const h=await window.crypto.subtle.decrypt(l,s,d),f=new TextDecoder;r(f.decode(h))}catch(h){i(h)}})()})}}class iu{constructor(t,n,r){this.linkAPIUrl=t,this.sessionId=n;const i=`${n}:${r}`;this.auth=`Basic ${btoa(i)}`}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:i}=await n.json();if(i)throw new Error(`Check unseen events failed: ${i}`);const s=(t=r==null?void 0:r.filter(a=>a.event==="Web3Response").map(a=>({type:"Event",sessionId:this.sessionId,eventId:a.id,event:a.event,data:a.data})))!==null&&t!==void 0?t:[];return this.markUnseenEventsAsSeen(s),s}throw new Error(`Check unseen events failed: ${n.status}`)}}var te;(function(e){e[e.DISCONNECTED=0]="DISCONNECTED",e[e.CONNECTING=1]="CONNECTING",e[e.CONNECTED=2]="CONNECTED"})(te||(te={}));class W{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=W.instanceCounter++,W.activeInstances.add(this.instanceId)}
4async 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 i;try{this.webSocket=i=new this.WebSocketClass(this.url)}catch(s){n(s);return}(r=this.connectionStateListener)===null||r===void 0||r.call(this,te.CONNECTING),i.onclose=s=>{var a;this.clearWebSocket(),i.readyState!==WebSocket.OPEN&&n(new Error(`websocket error ${s.code}: ${s.reason}`)),(a=this.connectionStateListener)===null||a===void 0||a.call(this,te.DISCONNECTED)},i.onopen=s=>{var a;t(),(a=this.connectionStateListener)===null||a===void 0||a.call(this,te.CONNECTED),W.pendingData.length>0&&([...W.pendingData].forEach(c=>this.sendData(c)),W.pendingData=[])},i.onmessage=s=>{var a,o;if(s.data==="h")(a=this.incomingDataListener)===null||a===void 0||a.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,te.DISCONNECTED),this.connectionStateListener=void 0,this.incomingDataListener=void 0;try{n.close()}catch{}}}sendData(t){const{webSocket:n}=this;if(!n){W.pendingData.push(t),this.isDisconnecting||this.connect();return}if(n.readyState!==WebSocket.OPEN){W.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(){W.activeInstances.delete(this.instanceId)}}W.instanceCounter=0;W.activeInstances=new Set;W.pendingData=[];const Ln=1e4,su=6e4;class au{constructor({session:t,linkAPIUrl:n,listener:r}){this.destroyed=!1,this.lastHeartbeatResponse=0,this.nextReqId=se(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 a;s==="1"&&((a=this.listener)===null||a===void 0||a.resetAndReload())},this.handleAccountUpdated=async s=>{var a;try{const o=await this.cipher.decrypt(s);(a=this.listener)===null||a===void 0||a.accountUpdated(o)}catch{}},this.handleMetadataUpdated=async(s,a)=>{var o;try{const c=await this.cipher.decrypt(a);(o=this.listener)===null||o===void 0||o.metadataUpdated(s,c)}catch{}},this.handleWalletUsernameUpdated=async s=>{this.handleMetadataUpdated(tu,s)},this.handleAppVersionUpdated=async s=>{this.handleMetadataUpdated(nu,s)},this.handleChainUpdated=async(s,a)=>{var o;try{const c=await this.cipher.decrypt(s),u=await this.cipher.decrypt(a);(o=this.listener)===null||o===void 0||o.chainUpdated(c,u)}catch{}},this.session=t,this.cipher=new ru(t.secret),this.listener=r,this.linkAPIUrl=n,this.WebSocketClass=WebSocket;const i=this.createWebSocket();this.ws=i,this.http=new iu(n,t.id,t.key),this.setupVisibilityChangeHandler()}createWebSocket(){const t=new W(`${this.linkAPIUrl}/rpc`,this.WebSocketClass);return this.activeWsInstance=t,t.setConnectionStateListener(async n=>{if(t!==this.activeWsInstance)return;let r=!1;switch(n){case te.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(a=>setTimeout(a,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(()=>{On()}).finally(()=>{this.isReconnecting=!1})):this.isReconnecting=!1})();break;case te.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()},Ln),setTimeout(()=>{this.heartbeat()},100);break;case te.CONNECTING:break}n!==te.CONNECTED&&(this.connected=r)}),t.setIncomingDataListener(n=>{var r;switch(n.type){case"Heartbeat":this.updateLastHeartbeat();return;case"IsLinkedOK":case"Linked":{const i=n.type==="IsLinkedOK"?n.linked:void 0;this.linked=i||n.onlineGuests>0;break}case"GetSessionConfigOK":case"SessionConfigUpdated":{this.handleSessionMetadataUpdated(n.metadata);break}case"Event":{this.handleIncomingEvent(n);break}}n.id!==void 0&&((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(()=>{On()})}connect(){if(this.destroyed)throw new Error("instance is destroyed");this.ws.connect()}
4async destroy(){this.destroyed||(await this.makeRequest({type:"SetSessionConfig",id:se(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),i=JSON.parse(r);if(i.type!=="WEB3_RESPONSE")return;(n=this.listener)===null||n===void 0||n.handleWeb3ResponseMessage(i.id,i.response)}catch{}}async checkUnseenEvents(){await new Promise(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{Pc()}}async publishEvent(t,n,r=!1){const i=await this.cipher.encrypt(JSON.stringify(Object.assign(Object.assign({},n),{origin:location.origin,location:location.href,relaySource:"coinbaseWalletExtension"in window&&window.coinbaseWalletExtension?"injected_sdk":"sdk"}))),s={type:"PublishEvent",id:se(this.nextReqId++),sessionId:this.session.id,event:t,data:i,callWebhook:r};return this.setOnceLinked(async()=>{const a=await this.makeRequest(s);if(a.type==="Fail")throw new Error(a.error||"failed to publish event");return a.eventId})}sendData(t){this.ws.sendData(JSON.stringify(t))}updateLastHeartbeat(){this.lastHeartbeatResponse=Date.now()}heartbeat(){if(Date.now()-this.lastHeartbeatResponse>Ln*2){this.ws.disconnect();return}if(this.connected)try{this.ws.sendData("h")}catch{}}async makeRequest(t,n={timeout:su}){const r=t.id;this.sendData(t);let i;return Promise.race([new Promise((s,a)=>{i=window.setTimeout(()=>{a(new Error(`request ${r} timed out`))},n.timeout)}),new Promise(s=>{this.requestResolutions.set(r,a=>{clearTimeout(i),s(a),this.requestResolutions.delete(r)})})])}async handleConnected(){return(await this.makeRequest({type:"HostSession",id:se(this.nextReqId++),sessionId:this.session.id,sessionKey:this.session.key})).type==="Fail"?!1:(this.sendData({type:"IsLinked",id:se(this.nextReqId++),sessionId:this.session.id}),this.sendData({type:"GetSessionConfig",id:se(this.nextReqId++),sessionId:this.session.id}),!0)}}class ou{constructor(){this._nextRequestId=0,this.callbacks=new Map}makeRequestId(){this._nextRequestId=(this._nextRequestId+1)%2147483647;const t=this._nextRequestId,n=ur(t.toString(16));return this.callbacks.get(n)&&this.callbacks.delete(n),t}}function cu(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function Jt(e,...t){if(!cu(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 Rn(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 uu(e,t){Jt(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 kt=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),X=(e,t)=>e<<32-t|e>>>t;new Uint8Array(new Uint32Array([287454020]).buffer)[0];const lu=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function du(e){Jt(e);let t="";for(let n=0;n<e.length;n++)t+=lu[e[n]];return t}function fu(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function Ni(e){return typeof e=="string"&&(e=fu(e)),Jt(e),e}class hu{clone(){return this._cloneInto()}}function pu(e){const t=r=>e().update(Ni(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function mu(e,t,n,r){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,n,r);const i=BigInt(32),s=BigInt(4294967295),a=Number(n>>i&s),o=Number(n&s),c=r?4:0,u=r?0:4;e.setUint32(t+c,a,r),e.setUint32(t+u,o,r)}
4const gu=(e,t,n)=>e&t^~e&n,bu=(e,t,n)=>e&t^e&n^t&n;class yu extends hu{constructor(t,n,r,i){super(),this.blockLen=t,this.outputLen=n,this.padOffset=r,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=kt(this.buffer)}update(t){Rn(this);const{view:n,buffer:r,blockLen:i}=this;t=Ni(t);const s=t.length;for(let a=0;a<s;){const o=Math.min(i-this.pos,s-a);if(o===i){const c=kt(t);for(;i<=s-a;a+=i)this.process(c,a);continue}r.set(t.subarray(a,a+o),this.pos),this.pos+=o,a+=o,this.pos===i&&(this.process(n,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Rn(this),uu(t,this),this.finished=!0;const{buffer:n,view:r,blockLen:i,isLE:s}=this;let{pos:a}=this;n[a++]=128,this.buffer.subarray(a).fill(0),this.padOffset>i-a&&(this.process(r,0),a=0);for(let l=a;l<i;l++)n[l]=0;mu(r,i-8,BigInt(this.length*8),s),this.process(r,0);const o=kt(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:i,finished:s,destroyed:a,pos:o}=this;return t.length=i,t.pos=o,t.finished=s,t.destroyed=a,i%n&&t.buffer.set(r),t}}const wu=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]),de=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),fe=new Uint32Array(64);class vu extends yu{constructor(){super(64,32,8,!1),this.A=de[0]|0,this.B=de[1]|0,this.C=de[2]|0,this.D=de[3]|0,this.E=de[4]|0,this.F=de[5]|0,this.G=de[6]|0,this.H=de[7]|0}get(){const{A:t,B:n,C:r,D:i,E:s,F:a,G:o,H:c}=this;return[t,n,r,i,s,a,o,c]}set(t,n,r,i,s,a,o,c){this.A=t|0,this.B=n|0,this.C=r|0,this.D=i|0,this.E=s|0,this.F=a|0,this.G=o|0,this.H=c|0}process(t,n){for(let l=0;l<16;l++,n+=4)fe[l]=t.getUint32(n,!1);for(let l=16;l<64;l++){const h=fe[l-15],f=fe[l-2],y=X(h,7)^X(h,18)^h>>>3,b=X(f,17)^X(f,19)^f>>>10;fe[l]=b+fe[l-7]+y+fe[l-16]|0}let{A:r,B:i,C:s,D:a,E:o,F:c,G:u,H:d}=this;for(let l=0;l<64;l++){const h=X(o,6)^X(o,11)^X(o,25),f=d+h+gu(o,c,u)+wu[l]+fe[l]|0,b=(X(r,2)^X(r,13)^X(r,22))+bu(r,i,s)|0;d=u,u=c,c=o,o=a+f|0,a=s,s=i,i=r,r=f+b|0}r=r+this.A|0,i=i+this.B|0,s=s+this.C|0,a=a+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,i,s,a,o,c,u,d)}roundClean(){fe.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const ku=pu(()=>new vu),Dn="session:id",Bn="session:secret",Un="session:linked";class Ce{constructor(t,n,r,i=!1){this.storage=t,this.id=n,this.secret=r,this.key=du(ku(`${n}, ${r} WalletLink`)),this._linked=!!i}static create(t){const n=ye(16),r=ye(32);return new Ce(t,n,r).save()}static load(t){const n=t.getItem(Dn),r=t.getItem(Un),i=t.getItem(Bn);return n&&i?new Ce(t,n,i,r==="1"):null}get linked(){return this._linked}set linked(t){this._linked=t,this.persistLinked()}save(){return this.storage.setItem(Dn,this.id),this.storage.setItem(Bn,this.secret),this.persistLinked(),this}persistLinked(){this.storage.setItem(Un,this._linked?"1":"0")}}const _u=".-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}
4.-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 Su{constructor(){this.root=null,this.darkMode=hr()}attach(){const t=document.documentElement;this.root=document.createElement("div"),this.root.className="-cbwsdk-css-reset",t.appendChild(this.root),dr()}present(t){this.render(t)}clear(){this.render(null)}render(t){this.root&&(_t(null,this.root),t&&_t(O(xu,Object.assign({},t,{onDismiss:()=>{this.clear()},darkMode:this.darkMode})),this.root))}}const xu=({title:e,buttonText:t,darkMode:n,onButtonClick:r,onDismiss:i})=>{const s=n?"dark":"light";return O(mr,{darkMode:n},O("div",{class:"-cbwsdk-redirect-dialog"},O("style",null,_u),O("div",{class:"-cbwsdk-redirect-dialog-backdrop",onClick:i}),O("div",{class:ze("-cbwsdk-redirect-dialog-box",s)},O("p",null,e),O("button",{onClick:r},t))))};class Hn{constructor(){this.attached=!1,this.redirectDialog=new Su}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(Ks);n.searchParams.append("redirect_url",Zs().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 ae{constructor(t){this.chainCallbackParams={chainId:"",jsonRpcUrl:""},this.isMobileWeb=Xs(),this.linkedUpdated=s=>{this.isLinked=s;const a=this.storage.getItem(jt);if(s&&(this._session.linked=s),this.isUnlinkedErrorState=!1,a){const o=a.split(" "),c=this.storage.getItem("IsStandaloneSigning")==="true";o[0]!==""&&!s&&this._session.linked&&!c&&(this.isUnlinkedErrorState=!0)}},this.metadataUpdated=(s,a)=>{this.storage.setItem(s,a)},this.chainUpdated=(s,a)=>{this.chainCallbackParams.chainId===s&&this.chainCallbackParams.jsonRpcUrl===a||(this.chainCallbackParams={chainId:s,jsonRpcUrl:a},this.chainCallback&&this.chainCallback(a,Number.parseInt(s,10)))},this.accountUpdated=s=>{this.accountsCallback&&this.accountsCallback([s]),ae.accountRequestCallbackIds.size>0&&(Array.from(ae.accountRequestCallbackIds.values()).forEach(a=>{this.invokeCallback(a,{method:"requestEthereumAccounts",result:[s]})}),ae.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:i}=this.subscribe();this._session=n,this.connection=i,this.relayEventManager=new ou,this.ui=r,this.ui.attach()}subscribe(){const t=Ce.load(this.storage)||Ce.create(this.storage),{linkAPIUrl:n}=this,r=new au({session:t,linkAPIUrl:n,listener:this}),i=this.isMobileWeb?new Hn:new ia;return r.connect(),{session:t,ui:i,connection:r}}resetAndReload(){this.connection.destroy().then(()=>{const t=Ce.load(this.storage);(t==null?void 0:t.id)===this._session.id&&ke.clearAll(),document.location.reload()}).catch(t=>{})}signEthereumTransaction(t){return this.sendRequest({method:"signEthereumTransaction",params:{fromAddress:t.fromAddress,toAddress:t.toAddress,weiValue:Q(t.weiValue),data:Ue(t.data,!0),nonce:t.nonce,gasPriceInWei:t.gasPriceInWei?Q(t.gasPriceInWei):null,maxFeePerGas:t.gasPriceInWei?Q(t.gasPriceInWei):null,maxPriorityFeePerGas:t.gasPriceInWei?Q(t.gasPriceInWei):null,gasLimit:t.gasLimit?Q(t.gasLimit):null,chainId:t.chainId,shouldSubmit:!1}})}signAndSubmitEthereumTransaction(t){return this.sendRequest({method:"signEthereumTransaction",params:{fromAddress:t.fromAddress,toAddress:t.toAddress,weiValue:Q(t.weiValue),data:Ue(t.data,!0),nonce:t.nonce,gasPriceInWei:t.gasPriceInWei?Q(t.gasPriceInWei):null,maxFeePerGas:t.maxFeePerGas?Q(t.maxFeePerGas):null,maxPriorityFeePerGas:t.maxPriorityFeePerGas?Q(t.maxPriorityFeePerGas):null,gasLimit:t.gasLimit?Q(t.gasLimit):null,chainId:t.chainId,shouldSubmit:!0}})}submitEthereumTransaction(t,n){return this.sendRequest({method:"submitEthereumTransaction",params:{signedTransaction:Ue(t,!0),chainId:n}})}getWalletLinkSession(){return this._session}sendRequest(t){let n=null;const r=ye(8),i=s=>{this.publishWeb3RequestCanceledEvent(r),this.handleErrorResponse(r,t.method,s),n==null||n()};return new Promise((s,a)=>{n=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:i,onResetConnection:this.resetAndReload}),this.relayEventManager.callbacks.set(r,o=>{if(n==null||n(),H(o))return a(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(i=>{}).catch(i=>{this.handleWeb3ResponseMessage(r.id,{method:n.method,errorMessage:i.message})}),this.isMobileWeb&&this.openCoinbaseWalletDeeplink(n.method)}openCoinbaseWalletDeeplink(t){if(this.ui instanceof Hn)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"){ae.accountRequestCallbackIds.forEach(r=>this.invokeCallback(r,n)),ae.accountRequestCallbackIds.clear();return}this.invokeCallback(t,n)}handleErrorResponse(t,n,r){var i;const s=(i=r==null?void 0:r.message)!==null&&i!==void 0?i:"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}},i=ye(8);return new Promise((s,a)=>{this.relayEventManager.callbacks.set(i,o=>{if(H(o))return a(new Error(o.errorMessage));s(o)}),ae.accountRequestCallbackIds.add(i),this.publishWeb3RequestEvent(i,r)})}watchAsset(t,n,r,i,s,a){const o={method:"watchAsset",params:{type:t,options:{address:n,symbol:r,decimals:i,image:s},chainId:a}};let c=null;const u=ye(8),d=l=>{this.publishWeb3RequestCanceledEvent(u),this.handleErrorResponse(u,o.method,l),c==null||c()};return c=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:d,onResetConnection:this.resetAndReload}),new Promise((l,h)=>{this.relayEventManager.callbacks.set(u,f=>{if(c==null||c(),H(f))return h(new Error(f.errorMessage));l(f)}),this.publishWeb3RequestEvent(u,o)})}addEthereumChain(t,n,r,i,s,a){const o={method:"addEthereumChain",params:{chainId:t,rpcUrls:n,blockExplorerUrls:i,chainName:s,iconUrls:r,nativeCurrency:a}};let c=null;const u=ye(8),d=l=>{this.publishWeb3RequestCanceledEvent(u),this.handleErrorResponse(u,o.method,l),c==null||c()};return c=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:d,onResetConnection:this.resetAndReload}),new Promise((l,h)=>{this.relayEventManager.callbacks.set(u,f=>{if(c==null||c(),H(f))return h(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 i=null;const s=ye(8),a=o=>{this.publishWeb3RequestCanceledEvent(s),this.handleErrorResponse(s,r.method,o),i==null||i()};return i=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:a,onResetConnection:this.resetAndReload}),new Promise((o,c)=>{this.relayEventManager.callbacks.set(s,u=>{if(i==null||i(),H(u)&&u.errorCode)return c(g.provider.custom({code:u.errorCode,message:"Unrecognized chain ID. Try adding the chain using addEthereumChain first."}));if(H(u))return c(new Error(u.errorMessage));o(u)}),this.publishWeb3RequestEvent(s,r)})}}ae.accountRequestCallbackIds=new Set;const $n="DefaultChainId",zn="DefaultJsonRpcUrl";class Li{constructor(t){this._relay=null,this._addresses=[],this.metadata=t.metadata,this._storage=new ke("walletlink",hn),this.callback=t.callback||null;const n=this._storage.getItem(jt);if(n){const r=n.split(" ");r[0]!==""&&(this._addresses=r.map(i=>ce(i)))}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=J.get(t);xc({method:n,correlationId:r});try{await this._eth_requestAccounts(),Ac({method:n,correlationId:r})}catch(i){throw Ec({method:n,correlationId:r,errorMessage:we(i)}),i}}get selectedAddress(){return this._addresses[0]||void 0}get jsonRpcUrl(){var t;return(t=this._storage.getItem(zn))!==null&&t!==void 0?t:void 0}set jsonRpcUrl(t){this._storage.setItem(zn,t)}updateProviderInfo(t,n){var r;this.jsonRpcUrl=t;const i=this.getChainId();this._storage.setItem($n,n.toString(10)),He(n)!==i&&((r=this.callback)===null||r===void 0||r.call(this,"chainChanged",Ee(n)))}async watchAsset(t){const n=Array.isArray(t)?t[0]:t;if(!n.type)throw g.rpc.invalidParams("Type is required");if((n==null?void 0:n.type)!=="ERC20")throw g.rpc.invalidParams(`Asset of type '${n.type}' is not supported`);if(!(n!=null&&n.options))throw g.rpc.invalidParams("Options are required");if(!(n!=null&&n.options.address))throw g.rpc.invalidParams("Address is required");const r=this.getChainId(),{address:i,symbol:s,image:a,decimals:o}=n.options,u=await this.initializeRelay().watchAsset(n.type,i,s,o,a,r==null?void 0:r.toString());return H(u)?!1:!!u.result}async addEthereumChain(t){var n,r;const i=t[0];if(((n=i.rpcUrls)===null||n===void 0?void 0:n.length)===0)throw g.rpc.invalidParams("please pass in at least 1 rpcUrl");if(!i.chainName||i.chainName.trim()==="")throw g.rpc.invalidParams("chainName is a required field");if(!i.nativeCurrency)throw g.rpc.invalidParams("nativeCurrency is a required field");const s=Number.parseInt(i.chainId,16);if(s===this.getChainId())return!1;const a=this.initializeRelay(),{rpcUrls:o=[],blockExplorerUrls:c=[],chainName:u,iconUrls:d=[],nativeCurrency:l}=i,h=await a.addEthereumChain(s.toString(),o,d,c,u,l);if(H(h))return!1;if(((r=h.result)===null||r===void 0?void 0:r.isApproved)===!0)return this.updateProviderInfo(o[0],s),null;throw g.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(H(s))throw s;const a=s.result;return a.isApproved&&a.rpcUrl.length>0&&this.updateProviderInfo(a.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 i=t.map(s=>ce(s));JSON.stringify(i)!==JSON.stringify(this._addresses)&&(this._addresses=i,(r=this.callback)===null||r===void 0||r.call(this,"accountsChanged",i),this._storage.setItem(jt,i.join(" ")))}async request(t){const n=J.get(t);Ic({method:t.method,correlationId:n});try{const r=await this._request(t);return Cc({method:t.method,correlationId:n}),r}catch(r){throw Tc({method:t.method,correlationId:n,errorMessage:we(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 Ee(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 g.rpc.internal("No RPC URL set for chain");return $e(t,this.jsonRpcUrl)}}_ensureKnownAddress(t){const n=ce(t);if(!this._addresses.map(i=>ce(i)).includes(n))throw new Error("Unknown Ethereum address")}_prepareTransactionParams(t){const n=t.from?ce(t.from):this.selectedAddress;if(!n)throw new Error("Ethereum address is unavailable");this._ensureKnownAddress(n);const r=t.to?ce(t.to):null,i=t.value!=null?Le(t.value):BigInt(0),s=t.data?Tt(t.data):Buffer.alloc(0),a=t.nonce!=null?He(t.nonce):null,o=t.gasPrice!=null?Le(t.gasPrice):null,c=t.maxFeePerGas!=null?Le(t.maxFeePerGas):null,u=t.maxPriorityFeePerGas!=null?Le(t.maxPriorityFeePerGas):null,d=t.gas!=null?Le(t.gas):null,l=t.chainId?He(t.chainId):this.getChainId();return{fromAddress:n,toAddress:r,weiValue:i,data:s,nonce:a,gasPriceInWei:o,maxFeePerGas:c,maxPriorityFeePerGas:u,gasLim
4it:d,chainId:l}}async ecRecover(t){const{method:n,params:r}=t;if(!Array.isArray(r))throw g.rpc.invalidParams();const s=await this.initializeRelay().sendRequest({method:"ethereumAddressFromSignedMessage",params:{message:mt(r[0]),signature:mt(r[1]),addPrefix:n==="personal_ecRecover"}});if(H(s))throw s;return s.result}getChainId(){var t;return Number.parseInt((t=this._storage.getItem($n))!==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:Ee(this.getChainId())}),this._addresses;const i=await this.initializeRelay().requestEthereumAccounts();if(H(i))throw i;if(!i.result)throw new Error("accounts received is empty");return this._setAddresses(i.result),(n=this.callback)===null||n===void 0||n.call(this,"connect",{chainId:Ee(this.getChainId())}),this._addresses}async personalSign({params:t}){if(!Array.isArray(t))throw g.rpc.invalidParams();const n=t[1],r=t[0];this._ensureKnownAddress(n);const s=await this.initializeRelay().sendRequest({method:"signEthereumMessage",params:{address:ce(n),message:mt(r),addPrefix:!0,typedDataJson:null}});if(H(s))throw s;return s.result}async _eth_signTransaction(t){const n=this._prepareTransactionParams(t[0]||{}),i=await this.initializeRelay().signEthereumTransaction(n);if(H(i))throw i;return i.result}async _eth_sendRawTransaction(t){const n=Tt(t[0]),i=await this.initializeRelay().submitEthereumTransaction(n,this.getChainId());if(H(i))throw i;return i.result}async _eth_sendTransaction(t){const n=this._prepareTransactionParams(t[0]||{}),i=await this.initializeRelay().signAndSubmitEthereumTransaction(n);if(H(i))throw i;return i.result}async signTypedData(t){const{method:n,params:r}=t;if(!Array.isArray(r))throw g.rpc.invalidParams();const i=u=>{const d={eth_signTypedData_v1:rt.hashForSignTypedDataLegacy,eth_signTypedData_v3:rt.hashForSignTypedData_v3,eth_signTypedData_v4:rt.hashForSignTypedData_v4,eth_signTypedData:rt.hashForSignTypedData_v4};return Ue(d[n]({data:Ns(u)}),!0)},s=r[n==="eth_signTypedData_v1"?1:0],a=r[n==="eth_signTypedData_v1"?0:1];this._ensureKnownAddress(s);const c=await this.initializeRelay().sendRequest({method:"signEthereumMessage",params:{address:ce(s),message:i(a),typedDataJson:JSON.stringify(a,null,2),addPrefix:!1}});if(H(c))throw c;return c.result}initializeRelay(){return this._relay||(this._relay=new ae({linkAPIUrl:hn,storage:this._storage,metadata:this.metadata,accountsCallback:this._setAddresses.bind(this),chainCallback:this.updateProviderInfo.bind(this)})),this._relay}}const Ri="SignerType",Di=new ke("CBWSDK","SignerConfigurator");function Eu(){return Di.getItem(Ri)}function Au(e){Di.setItem(Ri,e)}function Wn(e){if(e)return e instanceof qr?"scw":"walletlink"}async function Iu(e){const{communicator:t,metadata:n,handshakeRequest:r,callback:i}=e;Cu(t,n,i,r).catch(()=>{});const s={id:crypto.randomUUID(),event:"selectSignerType",data:Object.assign(Object.assign({},e.preference),{handshakeRequest:r})},{data:a}=await t.postRequestAndWaitForResponse(s);return a}function Tu(e){const{signerType:t,metadata:n,communicator:r,callback:i}=e;switch(t){case"scw":return new qr({metadata:n,callback:i,communicator:r});case"walletlink":return new Li({metadata:n,callback:i})}}async function Cu(e,t,n,r){await e.onMessage(({event:s})=>s==="WalletLinkSessionRequest");const i=new Li({metadata:t,callback:n});e.postMessage({event:"WalletLinkUpdate",data:{session:i.getSession()}}),await i.handshake(r),e.postMessage({event:"WalletLinkUpdate",data:{connected:!0}})}var Pu=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 i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n};class Ou extends ma{constructor(t){var{metadata:n}=t,r=t.preference,{keysUrl:i}=r,s=Pu(r,["keysUrl"]);super(),this.signer=null,this.isCoinbaseWallet=!0,this.metadata=n,this.preference=s,this.communicator=new la({url:i,metadata:n,preference:s});const a=Eu();a&&(this.signer=this.initSigner(a),ga({signerType:a}))}async request(t){const n=crypto.randomUUID();J.set(t,n),ba({method:t.method,correlationId:n});try{const r=await this._request(t);return wa({method:t.method,signerType:Wn(this.signer),correlationId:n}),r}
4catch(r){throw ya({method:t.method,correlationId:n,signerType:Wn(this.signer),errorMessage:r instanceof Error?r.message:""}),r}finally{J.delete(t)}}async _request(t){try{if(Ws(t),!this.signer)switch(t.method){case"eth_requestAccounts":{let r;const i=w.subAccountsConfig.get();i!=null&&i.enableAutoSubAccounts?r="scw":r=await this.requestSignerSelection(t);const s=this.initSigner(r);r==="scw"&&(i!=null&&i.enableAutoSubAccounts)?(await s.handshake({method:"handshake"}),await s.request(t)):await s.handshake(t),this.signer=s,Au(r);break}case"wallet_connect":{const r=this.initSigner("scw");await r.handshake({method:"handshake"});const i=await r.request(t);return this.signer=r,i}case"wallet_sendCalls":case"wallet_sign":{const r=this.initSigner("scw");await r.handshake({method:"handshake"});const i=await r.request(t);return await r.cleanup(),i}case"wallet_getCallsStatus":return await $e(t,lr);case"net_version":return 1;case"eth_chainId":return Ee(1);default:throw g.provider.unauthorized("Must call 'eth_requestAccounts' before other methods")}return await this.signer.request(t)}catch(n){const{code:r}=n;return r===R.provider.unauthorized&&this.disconnect(),Promise.reject(da(n))}}async enable(){return console.warn('.enable() has been deprecated. Please use .request({ method: "eth_requestAccounts" }) instead.'),va(),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,ke.clearAll(),J.clear(),this.emit("disconnect",g.provider.disconnected("User initiated disconnection"))}async requestSignerSelection(t){ka();const n=await Iu({communicator:this.communicator,preference:this.preference,metadata:this.metadata,handshakeRequest:t,callback:this.emit.bind(this)});return _a(n),n}initSigner(t){return Tu({signerType:t,metadata:this.metadata,communicator:this.communicator,callback:this.emit.bind(this)})}}function ju(e){var t;const n={metadata:e.metadata,preference:e.preference};return(t=zs(n))!==null&&t!==void 0?t:new Ou(n)}const Mu={options:"all"};function Ku(e){var t,n,r,i;const s={metadata:{appName:e.appName||"Dapp",appLogoUrl:e.appLogoUrl||"",appChainIds:e.appChainIds||[]},preference:Object.assign(Mu,(t=e.preference)!==null&&t!==void 0?t:{}),paymasterUrls:e.paymasterUrls};!((n=e.subAccounts)===null||n===void 0)&&n.toOwnerAccount&&fn(e.subAccounts.toOwnerAccount),w.subAccountsConfig.set({toOwnerAccount:(r=e.subAccounts)===null||r===void 0?void 0:r.toOwnerAccount,enableAutoSubAccounts:(i=e.subAccounts)===null||i===void 0?void 0:i.enableAutoSubAccounts}),w.config.set(s),w.persist.rehydrate(),Bs(),s.preference.telemetry!==!1&&As(),qs(s.preference);let a=null;const o={getProvider(){return a||(a=ju(s)),a.sdk=o,a},subAccount:{async create(c){var u,d;const l=w.getState();return F((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=w.subAccounts.get();if(d!=null&&d.address)return d;const h=(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(h)?h[0]:null},async addOwner({address:c,publicKey:u,chainId:d}){var l,h;const f=w.subAccounts.get(),y=w.account.get();F(y,new Error("account does not exist")),F(f==null?void 0:f.address,new Error("subaccount does not exist"));const b=[];if(u){const[m,v]=Jn([{type:"bytes32"},{type:"bytes32"}],u);b.push({to:f.address,data:me({abi:Y,functionName:"addOwnerPublicKey",args:[m,v]}),value:Ae(0)})}return c&&b.push({to:f.address,data:me({abi:Y,functionName:"addOwnerAddress",args:[c]}),value:Ae(0)}),await((l=o.getProvider())===null||l===void 0?void 0:l.request({method:"wallet_sendCalls",params:[{calls:b,chainId:Ae(d),from:(h=y.accounts)===null||h===void 0?void 0:h[0],version:"1"}]}))},setToOwnerAccount(c){fn(c),w.subAccountsConfig.set({toOwnerAccount:c})}}};return o}export{Ku as createCoinbaseWalletSDK,Pt as getCryptoKeyAccount};

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