diff --git a/assets/index-7992f12d.js b/assets/index-32d7b86e.js similarity index 98% rename from assets/index-7992f12d.js rename to assets/index-32d7b86e.js index 42d446d..5db6a3b 100644 --- a/assets/index-7992f12d.js +++ b/assets/index-32d7b86e.js @@ -1 +1 @@ -import{_ as pe}from"./index-eca98261.js";const fe=Symbol(),Z=Object.getPrototypeOf,F=new WeakMap,me=e=>e&&(F.has(e)?F.get(e):Z(e)===Object.prototype||Z(e)===Array.prototype),ge=e=>me(e)&&e[fe]||null,ee=(e,t=!0)=>{F.set(e,t)},J=e=>typeof e=="object"&&e!==null,C=new WeakMap,x=new WeakSet,he=(e=Object.is,t=(n,h)=>new Proxy(n,h),s=n=>J(n)&&!x.has(n)&&(Array.isArray(n)||!(Symbol.iterator in n))&&!(n instanceof WeakMap)&&!(n instanceof WeakSet)&&!(n instanceof Error)&&!(n instanceof Number)&&!(n instanceof Date)&&!(n instanceof String)&&!(n instanceof RegExp)&&!(n instanceof ArrayBuffer),r=n=>{switch(n.status){case"fulfilled":return n.value;case"rejected":throw n.reason;default:throw n}},l=new WeakMap,c=(n,h,I=r)=>{const b=l.get(n);if((b==null?void 0:b[0])===h)return b[1];const y=Array.isArray(n)?[]:Object.create(Object.getPrototypeOf(n));return ee(y,!0),l.set(n,[h,y]),Reflect.ownKeys(n).forEach(P=>{if(Object.getOwnPropertyDescriptor(y,P))return;const L=Reflect.get(n,P),D={value:L,enumerable:!0,configurable:!0};if(x.has(L))ee(L,!1);else if(L instanceof Promise)delete D.value,D.get=()=>I(L);else if(C.has(L)){const[v,H]=C.get(L);D.value=c(v,H(),I)}Object.defineProperty(y,P,D)}),Object.preventExtensions(y)},m=new WeakMap,f=[1,1],W=n=>{if(!J(n))throw new Error("object required");const h=m.get(n);if(h)return h;let I=f[0];const b=new Set,y=(i,a=++f[0])=>{I!==a&&(I=a,b.forEach(o=>o(i,a)))};let P=f[1];const L=(i=++f[1])=>(P!==i&&!b.size&&(P=i,v.forEach(([a])=>{const o=a[1](i);o>I&&(I=o)})),I),D=i=>(a,o)=>{const g=[...a];g[1]=[i,...g[1]],y(g,o)},v=new Map,H=(i,a)=>{if(b.size){const o=a[3](D(i));v.set(i,[a,o])}else v.set(i,[a])},Y=i=>{var a;const o=v.get(i);o&&(v.delete(i),(a=o[1])==null||a.call(o))},de=i=>(b.add(i),b.size===1&&v.forEach(([o,g],R)=>{const N=o[3](D(R));v.set(R,[o,N])}),()=>{b.delete(i),b.size===0&&v.forEach(([o,g],R)=>{g&&(g(),v.set(R,[o]))})}),z=Array.isArray(n)?[]:Object.create(Object.getPrototypeOf(n)),V=t(z,{deleteProperty(i,a){const o=Reflect.get(i,a);Y(a);const g=Reflect.deleteProperty(i,a);return g&&y(["delete",[a],o]),g},set(i,a,o,g){const R=Reflect.has(i,a),N=Reflect.get(i,a,g);if(R&&(e(N,o)||m.has(o)&&e(N,m.get(o))))return!0;Y(a),J(o)&&(o=ge(o)||o);let $=o;if(o instanceof Promise)o.then(A=>{o.status="fulfilled",o.value=A,y(["resolve",[a],A])}).catch(A=>{o.status="rejected",o.reason=A,y(["reject",[a],A])});else{!C.has(o)&&s(o)&&($=W(o));const A=!x.has($)&&C.get($);A&&H(a,A)}return Reflect.set(i,a,$,g),y(["set",[a],o,N]),!0}});m.set(n,V);const ue=[z,L,c,de];return C.set(V,ue),Reflect.ownKeys(n).forEach(i=>{const a=Object.getOwnPropertyDescriptor(n,i);"value"in a&&(V[i]=n[i],delete a.value,delete a.writable),Object.defineProperty(z,i,a)}),V})=>[W,C,x,e,t,s,r,l,c,m,f],[be]=he();function S(e={}){return be(e)}function U(e,t,s){const r=C.get(e);let l;const c=[],m=r[3];let f=!1;const n=m(h=>{if(c.push(h),s){t(c.splice(0));return}l||(l=Promise.resolve().then(()=>{l=void 0,f&&t(c.splice(0))}))});return f=!0,()=>{f=!1,n()}}function ye(e,t){const s=C.get(e),[r,l,c]=s;return c(r,l(),t)}const d=S({history:["ConnectWallet"],view:"ConnectWallet",data:void 0}),ce={state:d,subscribe(e){return U(d,()=>e(d))},push(e,t){e!==d.view&&(d.view=e,t&&(d.data=t),d.history.push(e))},reset(e){d.view=e,d.history=[e]},replace(e){d.history.length>1&&(d.history[d.history.length-1]=e,d.view=e)},goBack(){if(d.history.length>1){d.history.pop();const[e]=d.history.slice(-1);d.view=e}},setData(e){d.data=e}},p={WALLETCONNECT_DEEPLINK_CHOICE:"WALLETCONNECT_DEEPLINK_CHOICE",WCM_VERSION:"WCM_VERSION",RECOMMENDED_WALLET_AMOUNT:9,isMobile(){return typeof window<"u"?!!(window.matchMedia("(pointer:coarse)").matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1},isAndroid(){return p.isMobile()&&navigator.userAgent.toLowerCase().includes("android")},isIos(){const e=navigator.userAgent.toLowerCase();return p.isMobile()&&(e.includes("iphone")||e.includes("ipad"))},isHttpUrl(e){return e.startsWith("http://")||e.startsWith("https://")},isArray(e){return Array.isArray(e)&&e.length>0},formatNativeUrl(e,t,s){if(p.isHttpUrl(e))return this.formatUniversalUrl(e,t,s);let r=e;r.includes("://")||(r=e.replaceAll("/","").replaceAll(":",""),r=`${r}://`),r.endsWith("/")||(r=`${r}/`),this.setWalletConnectDeepLink(r,s);const l=encodeURIComponent(t);return`${r}wc?uri=${l}`},formatUniversalUrl(e,t,s){if(!p.isHttpUrl(e))return this.formatNativeUrl(e,t,s);let r=e;r.endsWith("/")||(r=`${r}/`),this.setWalletConnectDeepLink(r,s);const l=encodeURIComponent(t);return`${r}wc?uri=${l}`},async wait(e){return new Promise(t=>{setTimeout(t,e)})},openHref(e,t){window.open(e,t,"noreferrer noopener")},setWalletConnectDeepLink(e,t){try{localStorage.setItem(p.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:e,name:t}))}catch{console.info("Unable to set WalletConnect deep link")}},setWalletConnectAndroidDeepLink(e){try{const[t]=e.split("?");localStorage.setItem(p.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:t,name:"Android"}))}catch{console.info("Unable to set WalletConnect android deep link")}},removeWalletConnectDeepLink(){try{localStorage.removeItem(p.WALLETCONNECT_DEEPLINK_CHOICE)}catch{console.info("Unable to remove WalletConnect deep link")}},setModalVersionInStorage(){try{typeof localStorage<"u"&&localStorage.setItem(p.WCM_VERSION,"2.6.2")}catch{console.info("Unable to set Web3Modal version in storage")}},getWalletRouterData(){var e;const t=(e=ce.state.data)==null?void 0:e.Wallet;if(!t)throw new Error('Missing "Wallet" view data');return t}},ve=typeof location<"u"&&(location.hostname.includes("localhost")||location.protocol.includes("https")),u=S({enabled:ve,userSessionId:"",events:[],connectedWalletId:void 0}),we={state:u,subscribe(e){return U(u.events,()=>e(ye(u.events[u.events.length-1])))},initialize(){u.enabled&&typeof(crypto==null?void 0:crypto.randomUUID)<"u"&&(u.userSessionId=crypto.randomUUID())},setConnectedWalletId(e){u.connectedWalletId=e},click(e){if(u.enabled){const t={type:"CLICK",name:e.name,userSessionId:u.userSessionId,timestamp:Date.now(),data:e};u.events.push(t)}},track(e){if(u.enabled){const t={type:"TRACK",name:e.name,userSessionId:u.userSessionId,timestamp:Date.now(),data:e};u.events.push(t)}},view(e){if(u.enabled){const t={type:"VIEW",name:e.name,userSessionId:u.userSessionId,timestamp:Date.now(),data:e};u.events.push(t)}}},E=S({chains:void 0,walletConnectUri:void 0,isAuth:!1,isCustomDesktop:!1,isCustomMobile:!1,isDataLoaded:!1,isUiLoaded:!1}),w={state:E,subscribe(e){return U(E,()=>e(E))},setChains(e){E.chains=e},setWalletConnectUri(e){E.walletConnectUri=e},setIsCustomDesktop(e){E.isCustomDesktop=e},setIsCustomMobile(e){E.isCustomMobile=e},setIsDataLoaded(e){E.isDataLoaded=e},setIsUiLoaded(e){E.isUiLoaded=e},setIsAuth(e){E.isAuth=e}},B=S({projectId:"",mobileWallets:void 0,desktopWallets:void 0,walletImages:void 0,chains:void 0,enableAuthMode:!1,enableExplorer:!0,explorerExcludedWalletIds:void 0,explorerRecommendedWalletIds:void 0,termsOfServiceUrl:void 0,privacyPolicyUrl:void 0}),k={state:B,subscribe(e){return U(B,()=>e(B))},setConfig(e){var t,s;we.initialize(),w.setChains(e.chains),w.setIsAuth(!!e.enableAuthMode),w.setIsCustomMobile(!!((t=e.mobileWallets)!=null&&t.length)),w.setIsCustomDesktop(!!((s=e.desktopWallets)!=null&&s.length)),p.setModalVersionInStorage(),Object.assign(B,e)}};var Ie=Object.defineProperty,te=Object.getOwnPropertySymbols,Ee=Object.prototype.hasOwnProperty,Oe=Object.prototype.propertyIsEnumerable,se=(e,t,s)=>t in e?Ie(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Le=(e,t)=>{for(var s in t||(t={}))Ee.call(t,s)&&se(e,s,t[s]);if(te)for(var s of te(t))Oe.call(t,s)&&se(e,s,t[s]);return e};const G="https://explorer-api.walletconnect.com",Q="wcm",X="js-2.6.2";async function K(e,t){const s=Le({sdkType:Q,sdkVersion:X},t),r=new URL(e,G);return r.searchParams.append("projectId",k.state.projectId),Object.entries(s).forEach(([l,c])=>{c&&r.searchParams.append(l,String(c))}),(await fetch(r)).json()}const j={async getDesktopListings(e){return K("/w3m/v1/getDesktopListings",e)},async getMobileListings(e){return K("/w3m/v1/getMobileListings",e)},async getInjectedListings(e){return K("/w3m/v1/getInjectedListings",e)},async getAllListings(e){return K("/w3m/v1/getAllListings",e)},getWalletImageUrl(e){return`${G}/w3m/v1/getWalletImage/${e}?projectId=${k.state.projectId}&sdkType=${Q}&sdkVersion=${X}`},getAssetImageUrl(e){return`${G}/w3m/v1/getAssetImage/${e}?projectId=${k.state.projectId}&sdkType=${Q}&sdkVersion=${X}`}};var We=Object.defineProperty,ne=Object.getOwnPropertySymbols,Ae=Object.prototype.hasOwnProperty,Ce=Object.prototype.propertyIsEnumerable,oe=(e,t,s)=>t in e?We(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Se=(e,t)=>{for(var s in t||(t={}))Ae.call(t,s)&&oe(e,s,t[s]);if(ne)for(var s of ne(t))Ce.call(t,s)&&oe(e,s,t[s]);return e};const re=p.isMobile(),O=S({wallets:{listings:[],total:0,page:1},search:{listings:[],total:0,page:1},recomendedWallets:[]}),Ne={state:O,async getRecomendedWallets(){const{explorerRecommendedWalletIds:e,explorerExcludedWalletIds:t}=k.state;if(e==="NONE"||t==="ALL"&&!e)return O.recomendedWallets;if(p.isArray(e)){const s={recommendedIds:e.join(",")},{listings:r}=await j.getAllListings(s),l=Object.values(r);l.sort((c,m)=>{const f=e.indexOf(c.id),W=e.indexOf(m.id);return f-W}),O.recomendedWallets=l}else{const{chains:s,isAuth:r}=w.state,l=s==null?void 0:s.join(","),c=p.isArray(t),m={page:1,sdks:r?"auth_v1":void 0,entries:p.RECOMMENDED_WALLET_AMOUNT,chains:l,version:2,excludedIds:c?t.join(","):void 0},{listings:f}=re?await j.getMobileListings(m):await j.getDesktopListings(m);O.recomendedWallets=Object.values(f)}return O.recomendedWallets},async getWallets(e){const t=Se({},e),{explorerRecommendedWalletIds:s,explorerExcludedWalletIds:r}=k.state,{recomendedWallets:l}=O;if(r==="ALL")return O.wallets;l.length?t.excludedIds=l.map(I=>I.id).join(","):p.isArray(s)&&(t.excludedIds=s.join(",")),p.isArray(r)&&(t.excludedIds=[t.excludedIds,r].filter(Boolean).join(",")),w.state.isAuth&&(t.sdks="auth_v1");const{page:c,search:m}=e,{listings:f,total:W}=re?await j.getMobileListings(t):await j.getDesktopListings(t),n=Object.values(f),h=m?"search":"wallets";return O[h]={listings:[...O[h].listings,...n],total:W,page:c??1},{listings:n,total:W}},getWalletImageUrl(e){return j.getWalletImageUrl(e)},getAssetImageUrl(e){return j.getAssetImageUrl(e)},resetSearch(){O.search={listings:[],total:0,page:1}}},_=S({open:!1}),q={state:_,subscribe(e){return U(_,()=>e(_))},async open(e){return new Promise(t=>{const{isUiLoaded:s,isDataLoaded:r}=w.state;if(p.removeWalletConnectDeepLink(),w.setWalletConnectUri(e==null?void 0:e.uri),w.setChains(e==null?void 0:e.chains),ce.reset("ConnectWallet"),s&&r)_.open=!0,t();else{const l=setInterval(()=>{const c=w.state;c.isUiLoaded&&c.isDataLoaded&&(clearInterval(l),_.open=!0,t())},200)}})},close(){_.open=!1}};var De=Object.defineProperty,ae=Object.getOwnPropertySymbols,je=Object.prototype.hasOwnProperty,Me=Object.prototype.propertyIsEnumerable,ie=(e,t,s)=>t in e?De(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Ue=(e,t)=>{for(var s in t||(t={}))je.call(t,s)&&ie(e,s,t[s]);if(ae)for(var s of ae(t))Me.call(t,s)&&ie(e,s,t[s]);return e};function Pe(){return typeof matchMedia<"u"&&matchMedia("(prefers-color-scheme: dark)").matches}const T=S({themeMode:Pe()?"dark":"light"}),le={state:T,subscribe(e){return U(T,()=>e(T))},setThemeConfig(e){const{themeMode:t,themeVariables:s}=e;t&&(T.themeMode=t),s&&(T.themeVariables=Ue({},s))}},M=S({open:!1,message:"",variant:"success"}),Te={state:M,subscribe(e){return U(M,()=>e(M))},openToast(e,t){M.open=!0,M.message=e,M.variant=t},closeToast(){M.open=!1}};class Re{constructor(t){this.openModal=q.open,this.closeModal=q.close,this.subscribeModal=q.subscribe,this.setTheme=le.setThemeConfig,le.setThemeConfig(t),k.setConfig(t),this.initUi()}async initUi(){if(typeof window<"u"){await pe(()=>import("./index-4941fbd1.js"),["assets/index-4941fbd1.js","assets/index-eca98261.js","assets/index-a1650bee.css"]);const t=document.createElement("wcm-modal");document.body.insertAdjacentElement("beforeend",t),w.setIsUiLoaded(!0)}}}const Ve=Object.freeze(Object.defineProperty({__proto__:null,WalletConnectModal:Re},Symbol.toStringTag,{value:"Module"}));export{we as R,ce as T,p as a,Ve as i,le as n,Te as o,w as p,q as s,Ne as t,k as y}; +import{_ as pe}from"./index-47efff01.js";const fe=Symbol(),Z=Object.getPrototypeOf,F=new WeakMap,me=e=>e&&(F.has(e)?F.get(e):Z(e)===Object.prototype||Z(e)===Array.prototype),ge=e=>me(e)&&e[fe]||null,ee=(e,t=!0)=>{F.set(e,t)},J=e=>typeof e=="object"&&e!==null,C=new WeakMap,x=new WeakSet,he=(e=Object.is,t=(n,h)=>new Proxy(n,h),s=n=>J(n)&&!x.has(n)&&(Array.isArray(n)||!(Symbol.iterator in n))&&!(n instanceof WeakMap)&&!(n instanceof WeakSet)&&!(n instanceof Error)&&!(n instanceof Number)&&!(n instanceof Date)&&!(n instanceof String)&&!(n instanceof RegExp)&&!(n instanceof ArrayBuffer),r=n=>{switch(n.status){case"fulfilled":return n.value;case"rejected":throw n.reason;default:throw n}},l=new WeakMap,c=(n,h,I=r)=>{const b=l.get(n);if((b==null?void 0:b[0])===h)return b[1];const y=Array.isArray(n)?[]:Object.create(Object.getPrototypeOf(n));return ee(y,!0),l.set(n,[h,y]),Reflect.ownKeys(n).forEach(P=>{if(Object.getOwnPropertyDescriptor(y,P))return;const L=Reflect.get(n,P),D={value:L,enumerable:!0,configurable:!0};if(x.has(L))ee(L,!1);else if(L instanceof Promise)delete D.value,D.get=()=>I(L);else if(C.has(L)){const[v,H]=C.get(L);D.value=c(v,H(),I)}Object.defineProperty(y,P,D)}),Object.preventExtensions(y)},m=new WeakMap,f=[1,1],W=n=>{if(!J(n))throw new Error("object required");const h=m.get(n);if(h)return h;let I=f[0];const b=new Set,y=(i,a=++f[0])=>{I!==a&&(I=a,b.forEach(o=>o(i,a)))};let P=f[1];const L=(i=++f[1])=>(P!==i&&!b.size&&(P=i,v.forEach(([a])=>{const o=a[1](i);o>I&&(I=o)})),I),D=i=>(a,o)=>{const g=[...a];g[1]=[i,...g[1]],y(g,o)},v=new Map,H=(i,a)=>{if(b.size){const o=a[3](D(i));v.set(i,[a,o])}else v.set(i,[a])},Y=i=>{var a;const o=v.get(i);o&&(v.delete(i),(a=o[1])==null||a.call(o))},de=i=>(b.add(i),b.size===1&&v.forEach(([o,g],R)=>{const N=o[3](D(R));v.set(R,[o,N])}),()=>{b.delete(i),b.size===0&&v.forEach(([o,g],R)=>{g&&(g(),v.set(R,[o]))})}),z=Array.isArray(n)?[]:Object.create(Object.getPrototypeOf(n)),V=t(z,{deleteProperty(i,a){const o=Reflect.get(i,a);Y(a);const g=Reflect.deleteProperty(i,a);return g&&y(["delete",[a],o]),g},set(i,a,o,g){const R=Reflect.has(i,a),N=Reflect.get(i,a,g);if(R&&(e(N,o)||m.has(o)&&e(N,m.get(o))))return!0;Y(a),J(o)&&(o=ge(o)||o);let $=o;if(o instanceof Promise)o.then(A=>{o.status="fulfilled",o.value=A,y(["resolve",[a],A])}).catch(A=>{o.status="rejected",o.reason=A,y(["reject",[a],A])});else{!C.has(o)&&s(o)&&($=W(o));const A=!x.has($)&&C.get($);A&&H(a,A)}return Reflect.set(i,a,$,g),y(["set",[a],o,N]),!0}});m.set(n,V);const ue=[z,L,c,de];return C.set(V,ue),Reflect.ownKeys(n).forEach(i=>{const a=Object.getOwnPropertyDescriptor(n,i);"value"in a&&(V[i]=n[i],delete a.value,delete a.writable),Object.defineProperty(z,i,a)}),V})=>[W,C,x,e,t,s,r,l,c,m,f],[be]=he();function S(e={}){return be(e)}function U(e,t,s){const r=C.get(e);let l;const c=[],m=r[3];let f=!1;const n=m(h=>{if(c.push(h),s){t(c.splice(0));return}l||(l=Promise.resolve().then(()=>{l=void 0,f&&t(c.splice(0))}))});return f=!0,()=>{f=!1,n()}}function ye(e,t){const s=C.get(e),[r,l,c]=s;return c(r,l(),t)}const d=S({history:["ConnectWallet"],view:"ConnectWallet",data:void 0}),ce={state:d,subscribe(e){return U(d,()=>e(d))},push(e,t){e!==d.view&&(d.view=e,t&&(d.data=t),d.history.push(e))},reset(e){d.view=e,d.history=[e]},replace(e){d.history.length>1&&(d.history[d.history.length-1]=e,d.view=e)},goBack(){if(d.history.length>1){d.history.pop();const[e]=d.history.slice(-1);d.view=e}},setData(e){d.data=e}},p={WALLETCONNECT_DEEPLINK_CHOICE:"WALLETCONNECT_DEEPLINK_CHOICE",WCM_VERSION:"WCM_VERSION",RECOMMENDED_WALLET_AMOUNT:9,isMobile(){return typeof window<"u"?!!(window.matchMedia("(pointer:coarse)").matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1},isAndroid(){return p.isMobile()&&navigator.userAgent.toLowerCase().includes("android")},isIos(){const e=navigator.userAgent.toLowerCase();return p.isMobile()&&(e.includes("iphone")||e.includes("ipad"))},isHttpUrl(e){return e.startsWith("http://")||e.startsWith("https://")},isArray(e){return Array.isArray(e)&&e.length>0},formatNativeUrl(e,t,s){if(p.isHttpUrl(e))return this.formatUniversalUrl(e,t,s);let r=e;r.includes("://")||(r=e.replaceAll("/","").replaceAll(":",""),r=`${r}://`),r.endsWith("/")||(r=`${r}/`),this.setWalletConnectDeepLink(r,s);const l=encodeURIComponent(t);return`${r}wc?uri=${l}`},formatUniversalUrl(e,t,s){if(!p.isHttpUrl(e))return this.formatNativeUrl(e,t,s);let r=e;r.endsWith("/")||(r=`${r}/`),this.setWalletConnectDeepLink(r,s);const l=encodeURIComponent(t);return`${r}wc?uri=${l}`},async wait(e){return new Promise(t=>{setTimeout(t,e)})},openHref(e,t){window.open(e,t,"noreferrer noopener")},setWalletConnectDeepLink(e,t){try{localStorage.setItem(p.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:e,name:t}))}catch{console.info("Unable to set WalletConnect deep link")}},setWalletConnectAndroidDeepLink(e){try{const[t]=e.split("?");localStorage.setItem(p.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:t,name:"Android"}))}catch{console.info("Unable to set WalletConnect android deep link")}},removeWalletConnectDeepLink(){try{localStorage.removeItem(p.WALLETCONNECT_DEEPLINK_CHOICE)}catch{console.info("Unable to remove WalletConnect deep link")}},setModalVersionInStorage(){try{typeof localStorage<"u"&&localStorage.setItem(p.WCM_VERSION,"2.6.2")}catch{console.info("Unable to set Web3Modal version in storage")}},getWalletRouterData(){var e;const t=(e=ce.state.data)==null?void 0:e.Wallet;if(!t)throw new Error('Missing "Wallet" view data');return t}},ve=typeof location<"u"&&(location.hostname.includes("localhost")||location.protocol.includes("https")),u=S({enabled:ve,userSessionId:"",events:[],connectedWalletId:void 0}),we={state:u,subscribe(e){return U(u.events,()=>e(ye(u.events[u.events.length-1])))},initialize(){u.enabled&&typeof(crypto==null?void 0:crypto.randomUUID)<"u"&&(u.userSessionId=crypto.randomUUID())},setConnectedWalletId(e){u.connectedWalletId=e},click(e){if(u.enabled){const t={type:"CLICK",name:e.name,userSessionId:u.userSessionId,timestamp:Date.now(),data:e};u.events.push(t)}},track(e){if(u.enabled){const t={type:"TRACK",name:e.name,userSessionId:u.userSessionId,timestamp:Date.now(),data:e};u.events.push(t)}},view(e){if(u.enabled){const t={type:"VIEW",name:e.name,userSessionId:u.userSessionId,timestamp:Date.now(),data:e};u.events.push(t)}}},E=S({chains:void 0,walletConnectUri:void 0,isAuth:!1,isCustomDesktop:!1,isCustomMobile:!1,isDataLoaded:!1,isUiLoaded:!1}),w={state:E,subscribe(e){return U(E,()=>e(E))},setChains(e){E.chains=e},setWalletConnectUri(e){E.walletConnectUri=e},setIsCustomDesktop(e){E.isCustomDesktop=e},setIsCustomMobile(e){E.isCustomMobile=e},setIsDataLoaded(e){E.isDataLoaded=e},setIsUiLoaded(e){E.isUiLoaded=e},setIsAuth(e){E.isAuth=e}},B=S({projectId:"",mobileWallets:void 0,desktopWallets:void 0,walletImages:void 0,chains:void 0,enableAuthMode:!1,enableExplorer:!0,explorerExcludedWalletIds:void 0,explorerRecommendedWalletIds:void 0,termsOfServiceUrl:void 0,privacyPolicyUrl:void 0}),k={state:B,subscribe(e){return U(B,()=>e(B))},setConfig(e){var t,s;we.initialize(),w.setChains(e.chains),w.setIsAuth(!!e.enableAuthMode),w.setIsCustomMobile(!!((t=e.mobileWallets)!=null&&t.length)),w.setIsCustomDesktop(!!((s=e.desktopWallets)!=null&&s.length)),p.setModalVersionInStorage(),Object.assign(B,e)}};var Ie=Object.defineProperty,te=Object.getOwnPropertySymbols,Ee=Object.prototype.hasOwnProperty,Oe=Object.prototype.propertyIsEnumerable,se=(e,t,s)=>t in e?Ie(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Le=(e,t)=>{for(var s in t||(t={}))Ee.call(t,s)&&se(e,s,t[s]);if(te)for(var s of te(t))Oe.call(t,s)&&se(e,s,t[s]);return e};const G="https://explorer-api.walletconnect.com",Q="wcm",X="js-2.6.2";async function K(e,t){const s=Le({sdkType:Q,sdkVersion:X},t),r=new URL(e,G);return r.searchParams.append("projectId",k.state.projectId),Object.entries(s).forEach(([l,c])=>{c&&r.searchParams.append(l,String(c))}),(await fetch(r)).json()}const j={async getDesktopListings(e){return K("/w3m/v1/getDesktopListings",e)},async getMobileListings(e){return K("/w3m/v1/getMobileListings",e)},async getInjectedListings(e){return K("/w3m/v1/getInjectedListings",e)},async getAllListings(e){return K("/w3m/v1/getAllListings",e)},getWalletImageUrl(e){return`${G}/w3m/v1/getWalletImage/${e}?projectId=${k.state.projectId}&sdkType=${Q}&sdkVersion=${X}`},getAssetImageUrl(e){return`${G}/w3m/v1/getAssetImage/${e}?projectId=${k.state.projectId}&sdkType=${Q}&sdkVersion=${X}`}};var We=Object.defineProperty,ne=Object.getOwnPropertySymbols,Ae=Object.prototype.hasOwnProperty,Ce=Object.prototype.propertyIsEnumerable,oe=(e,t,s)=>t in e?We(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Se=(e,t)=>{for(var s in t||(t={}))Ae.call(t,s)&&oe(e,s,t[s]);if(ne)for(var s of ne(t))Ce.call(t,s)&&oe(e,s,t[s]);return e};const re=p.isMobile(),O=S({wallets:{listings:[],total:0,page:1},search:{listings:[],total:0,page:1},recomendedWallets:[]}),Ne={state:O,async getRecomendedWallets(){const{explorerRecommendedWalletIds:e,explorerExcludedWalletIds:t}=k.state;if(e==="NONE"||t==="ALL"&&!e)return O.recomendedWallets;if(p.isArray(e)){const s={recommendedIds:e.join(",")},{listings:r}=await j.getAllListings(s),l=Object.values(r);l.sort((c,m)=>{const f=e.indexOf(c.id),W=e.indexOf(m.id);return f-W}),O.recomendedWallets=l}else{const{chains:s,isAuth:r}=w.state,l=s==null?void 0:s.join(","),c=p.isArray(t),m={page:1,sdks:r?"auth_v1":void 0,entries:p.RECOMMENDED_WALLET_AMOUNT,chains:l,version:2,excludedIds:c?t.join(","):void 0},{listings:f}=re?await j.getMobileListings(m):await j.getDesktopListings(m);O.recomendedWallets=Object.values(f)}return O.recomendedWallets},async getWallets(e){const t=Se({},e),{explorerRecommendedWalletIds:s,explorerExcludedWalletIds:r}=k.state,{recomendedWallets:l}=O;if(r==="ALL")return O.wallets;l.length?t.excludedIds=l.map(I=>I.id).join(","):p.isArray(s)&&(t.excludedIds=s.join(",")),p.isArray(r)&&(t.excludedIds=[t.excludedIds,r].filter(Boolean).join(",")),w.state.isAuth&&(t.sdks="auth_v1");const{page:c,search:m}=e,{listings:f,total:W}=re?await j.getMobileListings(t):await j.getDesktopListings(t),n=Object.values(f),h=m?"search":"wallets";return O[h]={listings:[...O[h].listings,...n],total:W,page:c??1},{listings:n,total:W}},getWalletImageUrl(e){return j.getWalletImageUrl(e)},getAssetImageUrl(e){return j.getAssetImageUrl(e)},resetSearch(){O.search={listings:[],total:0,page:1}}},_=S({open:!1}),q={state:_,subscribe(e){return U(_,()=>e(_))},async open(e){return new Promise(t=>{const{isUiLoaded:s,isDataLoaded:r}=w.state;if(p.removeWalletConnectDeepLink(),w.setWalletConnectUri(e==null?void 0:e.uri),w.setChains(e==null?void 0:e.chains),ce.reset("ConnectWallet"),s&&r)_.open=!0,t();else{const l=setInterval(()=>{const c=w.state;c.isUiLoaded&&c.isDataLoaded&&(clearInterval(l),_.open=!0,t())},200)}})},close(){_.open=!1}};var De=Object.defineProperty,ae=Object.getOwnPropertySymbols,je=Object.prototype.hasOwnProperty,Me=Object.prototype.propertyIsEnumerable,ie=(e,t,s)=>t in e?De(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Ue=(e,t)=>{for(var s in t||(t={}))je.call(t,s)&&ie(e,s,t[s]);if(ae)for(var s of ae(t))Me.call(t,s)&&ie(e,s,t[s]);return e};function Pe(){return typeof matchMedia<"u"&&matchMedia("(prefers-color-scheme: dark)").matches}const T=S({themeMode:Pe()?"dark":"light"}),le={state:T,subscribe(e){return U(T,()=>e(T))},setThemeConfig(e){const{themeMode:t,themeVariables:s}=e;t&&(T.themeMode=t),s&&(T.themeVariables=Ue({},s))}},M=S({open:!1,message:"",variant:"success"}),Te={state:M,subscribe(e){return U(M,()=>e(M))},openToast(e,t){M.open=!0,M.message=e,M.variant=t},closeToast(){M.open=!1}};class Re{constructor(t){this.openModal=q.open,this.closeModal=q.close,this.subscribeModal=q.subscribe,this.setTheme=le.setThemeConfig,le.setThemeConfig(t),k.setConfig(t),this.initUi()}async initUi(){if(typeof window<"u"){await pe(()=>import("./index-510a7f22.js"),["assets/index-510a7f22.js","assets/index-47efff01.js","assets/index-a1650bee.css"]);const t=document.createElement("wcm-modal");document.body.insertAdjacentElement("beforeend",t),w.setIsUiLoaded(!0)}}}const Ve=Object.freeze(Object.defineProperty({__proto__:null,WalletConnectModal:Re},Symbol.toStringTag,{value:"Module"}));export{we as R,ce as T,p as a,Ve as i,le as n,Te as o,w as p,q as s,Ne as t,k as y}; diff --git a/assets/index-eca98261.js b/assets/index-47efff01.js similarity index 99% rename from assets/index-eca98261.js rename to assets/index-47efff01.js index 80b2321..e59e383 100644 --- a/assets/index-eca98261.js +++ b/assets/index-47efff01.js @@ -125,7 +125,7 @@ __p += '`),x0&&(tp+=`' + function print() { __p += __j.call(arguments, '') } `:`; `)+tp+`return __p -}`;var v0=I3(function(){return k0(iu,t0+"return "+tp).apply(jr,bu)});if(v0.source=tp,$_(v0))throw v0;return v0}function SS(Sn){return I0(Sn).toLowerCase()}function CS(Sn){return I0(Sn).toUpperCase()}function AS(Sn,An,ao){if(Sn=I0(Sn),Sn&&(ao||An===jr))return F_(Sn);if(!Sn||!(An=tm(An)))return Sn;var Mo=jm(Sn),zl=jm(An),iu=B_(Mo,zl),bu=U_(Mo,zl)+1;return Zy(Mo,iu,bu).join("")}function RS(Sn,An,ao){if(Sn=I0(Sn),Sn&&(ao||An===jr))return Sn.slice(0,z_(Sn)+1);if(!Sn||!(An=tm(An)))return Sn;var Mo=jm(Sn),zl=U_(Mo,jm(An))+1;return Zy(Mo,0,zl).join("")}function kS(Sn,An,ao){if(Sn=I0(Sn),Sn&&(ao||An===jr))return Sn.replace(Op,"");if(!Sn||!(An=tm(An)))return Sn;var Mo=jm(Sn),zl=B_(Mo,jm(An));return Zy(Mo,zl).join("")}function IS(Sn,An){var ao=au,Mo=wu;if(B0(An)){var zl="separator"in An?An.separator:zl;ao="length"in An?y0(An.length):ao,Mo="omission"in An?tm(An.omission):Mo}Sn=I0(Sn);var iu=Sn.length;if(Gv(Sn)){var bu=jm(Sn);iu=bu.length}if(ao>=iu)return Sn;var Su=ao-Kv(Mo);if(Su<1)return Mo;var zu=bu?Zy(bu,0,Su).join(""):Sn.slice(0,Su);if(zl===jr)return zu+Mo;if(bu&&(Su+=zu.length-Su),E_(zl)){if(Sn.slice(Su).search(zl)){var Yu,Xu=zu;for(zl.global||(zl=Fw(zl.source,I0(m0.exec(zl))+"g")),zl.lastIndex=0;Yu=zl.exec(Xu);)var tp=Yu.index;zu=zu.slice(0,tp===jr?Su:tp)}}else if(Sn.indexOf(tm(zl),Su)!=Su){var wp=zu.lastIndexOf(zl);wp>-1&&(zu=zu.slice(0,wp))}return zu+Mo}function TS(Sn){return Sn=I0(Sn),Sn&&Ep.test(Sn)?Sn.replace(op,iE):Sn}var NS=e2(function(Sn,An,ao){return Sn+(ao?" ":"")+An.toUpperCase()}),C_=T$("toUpperCase");function k3(Sn,An,ao){return Sn=I0(Sn),An=ao?jr:An,An===jr?Z3(Sn)?aE(Sn):z3(Sn):Sn.match(An)||[]}var I3=b0(function(Sn,An){try{return Y0(Sn,jr,An)}catch(ao){return $_(ao)?ao:new f0(ao)}}),PS=wy(function(Sn,An){return dm(An,function(ao){ao=ty(ao),vy(Sn,ao,w_(Sn[ao],Sn))}),Sn});function OS(Sn){var An=Sn==null?0:Sn.length,ao=l0();return Sn=An?F0(Sn,function(Mo){if(typeof Mo[1]!="function")throw new fm(Hr);return[ao(Mo[0]),Mo[1]]}):[],b0(function(Mo){for(var zl=-1;++zlVo)return[];var ao=Lo,Mo=p1(Sn,Lo);An=l0(An),Sn-=Lo;for(var zl=Mw(Mo,An);++ao0||An<0)?new $0(ao):(Sn<0?ao=ao.takeRight(-Sn):Sn&&(ao=ao.drop(Sn)),An!==jr&&(An=y0(An),ao=An<0?ao.dropRight(-An):ao.take(An-Sn)),ao)},$0.prototype.takeRightWhile=function(Sn){return this.reverse().takeWhile(Sn).reverse()},$0.prototype.toArray=function(){return this.take(Lo)},Zm($0.prototype,function(Sn,An){var ao=/^(?:filter|find|map|reject)|While$/.test(An),Mo=/^(?:head|last)$/.test(An),zl=Zl[Mo?"take"+(An=="last"?"Right":""):An],iu=Mo||/^find/.test(An);zl&&(Zl.prototype[An]=function(){var bu=this.__wrapped__,Su=Mo?[1]:arguments,zu=bu instanceof $0,Yu=Su[0],Xu=zu||p0(bu),tp=function(_0){var x0=zl.apply(Zl,Hy([_0],Su));return Mo&&wp?x0[0]:x0};Xu&&ao&&typeof Yu=="function"&&Yu.length!=1&&(zu=Xu=!1);var wp=this.__chain__,t0=!!this.__actions__.length,u0=iu&&!wp,v0=zu&&!t0;if(!iu&&Xu){bu=v0?bu:new $0(this);var d0=Sn.apply(bu,Su);return d0.__actions__.push({func:mw,args:[tp],thisArg:jr}),new pm(d0,wp)}return u0&&v0?Sn.apply(this,Su):(d0=this.thru(tp),u0?Mo?d0.value()[0]:d0.value():d0)})}),dm(["pop","push","shift","sort","splice","unshift"],function(Sn){var An=W2[Sn],ao=/^(?:push|sort|unshift)$/.test(Sn)?"tap":"thru",Mo=/^(?:pop|shift)$/.test(Sn);Zl.prototype[Sn]=function(){var zl=arguments;if(Mo&&!this.__chain__){var iu=this.value();return An.apply(p0(iu)?iu:[],zl)}return this[ao](function(bu){return An.apply(p0(bu)?bu:[],zl)})}}),Zm($0.prototype,function(Sn,An){var ao=Zl[An];if(ao){var Mo=ao.name+"";T0.call(Xv,Mo)||(Xv[Mo]=[]),Xv[Mo].push({name:An,func:ao})}}),Xv[cw(jr,so).name]=[{name:"wrapper",func:jr}],$0.prototype.clone=kE,$0.prototype.reverse=IE,$0.prototype.value=TE,Zl.prototype.at=l5,Zl.prototype.chain=c5,Zl.prototype.commit=u5,Zl.prototype.next=d5,Zl.prototype.plant=h5,Zl.prototype.reverse=p5,Zl.prototype.toJSON=Zl.prototype.valueOf=Zl.prototype.value=g5,Zl.prototype.first=Zl.prototype.head,c2&&(Zl.prototype[c2]=f5),Zl},Jv=lE();z0?((z0.exports=Jv)._=Jv,j0._=Jv):E0._=Jv}).call(ge$1)})(Ui$1,Ui$1.exports);var qg$1=Object.defineProperty,Bg$1=Object.defineProperties,Gg$1=Object.getOwnPropertyDescriptors,Ea=Object.getOwnPropertySymbols,zg$1=Object.prototype.hasOwnProperty,Kg$1=Object.prototype.propertyIsEnumerable,ya=(Nr,$r,jr)=>$r in Nr?qg$1(Nr,$r,{enumerable:!0,configurable:!0,writable:!0,value:jr}):Nr[$r]=jr,cr=(Nr,$r)=>{for(var jr in $r||($r={}))zg$1.call($r,jr)&&ya(Nr,jr,$r[jr]);if(Ea)for(var jr of Ea($r))Kg$1.call($r,jr)&&ya(Nr,jr,$r[jr]);return Nr},Yg$1=(Nr,$r)=>Bg$1(Nr,Gg$1($r));function ft(Nr,$r,jr){var Lr;const Ur=ve$1(Nr);return((Lr=$r.rpcMap)==null?void 0:Lr[Ur.reference])||`${Mg}?chainId=${Ur.namespace}:${Ur.reference}&projectId=${jr}`}function Ct(Nr){return Nr.includes(":")?Nr.split(":")[1]:Nr}function Sa$1(Nr){return Nr.map($r=>`${$r.split(":")[0]}:${$r.split(":")[1]}`)}function Zg$1(Nr,$r){const jr=Object.keys($r.namespaces).filter(Ur=>Ur.includes(Nr));if(!jr.length)return[];const Lr=[];return jr.forEach(Ur=>{const Wr=$r.namespaces[Ur].accounts;Lr.push(...Wr)}),Lr}function Jg(Nr={},$r={}){const jr=Oa(Nr),Lr=Oa($r);return Ui$1.exports.merge(jr,Lr)}function Oa(Nr){var $r,jr,Lr,Ur;const Wr={};if(!B$3(Nr))return Wr;for(const[Hr,qr]of Object.entries(Nr)){const Vr=oe$3(Hr)?[Hr]:qr.chains,Gr=qr.methods||[],Cn=qr.events||[],In=qr.rpcMap||{},Gn=Xe$1(Hr);Wr[Gn]=Yg$1(cr(cr({},Wr[Gn]),qr),{chains:S$4(Vr,($r=Wr[Gn])==null?void 0:$r.chains),methods:S$4(Gr,(jr=Wr[Gn])==null?void 0:jr.methods),events:S$4(Cn,(Lr=Wr[Gn])==null?void 0:Lr.events),rpcMap:cr(cr({},In),(Ur=Wr[Gn])==null?void 0:Ur.rpcMap)})}return Wr}function Xg$1(Nr){return Nr.includes(":")?Nr.split(":")[2]:Nr}function Qg$1(Nr){const $r={};for(const[jr,Lr]of Object.entries(Nr)){const Ur=Lr.methods||[],Wr=Lr.events||[],Hr=Lr.accounts||[],qr=oe$3(jr)?[jr]:Lr.chains?Lr.chains:Sa$1(Lr.accounts);$r[jr]={chains:qr,methods:Ur,events:Wr,accounts:Hr}}return $r}function Wi$1(Nr){return typeof Nr=="number"?Nr:Nr.includes("0x")?parseInt(Nr,16):Nr.includes(":")?Number(Nr.split(":")[1]):Number(Nr)}const Ra={},z$5=Nr=>Ra[Nr],Fi$1=(Nr,$r)=>{Ra[Nr]=$r};class Vg{constructor($r){this.name="polkadot",this.namespace=$r.namespace,this.events=z$5("events"),this.client=z$5("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace($r){this.namespace=Object.assign(this.namespace,$r)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const $r=this.namespace.chains[0];if(!$r)throw new Error("ChainId not found");return $r.split(":")[1]}request($r){return this.namespace.methods.includes($r.request.method)?this.client.request($r):this.getHttpProvider().request($r.request)}setDefaultChain($r,jr){this.httpProviders[$r]||this.setHttpProvider($r,jr),this.chainId=$r,this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${$r}`)}getAccounts(){const $r=this.namespace.accounts;return $r?$r.filter(jr=>jr.split(":")[1]===this.chainId.toString()).map(jr=>jr.split(":")[2])||[]:[]}createHttpProviders(){const $r={};return this.namespace.chains.forEach(jr=>{var Lr;const Ur=Ct(jr);$r[Ur]=this.createHttpProvider(Ur,(Lr=this.namespace.rpcMap)==null?void 0:Lr[jr])}),$r}getHttpProvider(){const $r=`${this.name}:${this.chainId}`,jr=this.httpProviders[$r];if(typeof jr>"u")throw new Error(`JSON-RPC provider for ${$r} not found`);return jr}setHttpProvider($r,jr){const Lr=this.createHttpProvider($r,jr);Lr&&(this.httpProviders[$r]=Lr)}createHttpProvider($r,jr){const Lr=jr||ft($r,this.namespace,this.client.core.projectId);if(!Lr)throw new Error(`No RPC url provided for chainId: ${$r}`);return new JsonRpcProvider(new HttpConnection(Lr,z$5("disableProviderPing")))}}let kg$1=class{constructor($r){this.name="eip155",this.namespace=$r.namespace,this.events=z$5("events"),this.client=z$5("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request($r){switch($r.request.method){case"eth_requestAccounts":return this.getAccounts();case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain($r);case"eth_chainId":return parseInt(this.getDefaultChain())}return this.namespace.methods.includes($r.request.method)?await this.client.request($r):this.getHttpProvider().request($r.request)}updateNamespace($r){this.namespace=Object.assign(this.namespace,$r)}setDefaultChain($r,jr){this.httpProviders[$r]||this.setHttpProvider(parseInt($r),jr),this.chainId=parseInt($r),this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${$r}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const $r=this.namespace.chains[0];if(!$r)throw new Error("ChainId not found");return $r.split(":")[1]}createHttpProvider($r,jr){const Lr=jr||ft(`${this.name}:${$r}`,this.namespace,this.client.core.projectId);if(!Lr)throw new Error(`No RPC url provided for chainId: ${$r}`);return new JsonRpcProvider(new HttpConnection(Lr,z$5("disableProviderPing")))}setHttpProvider($r,jr){const Lr=this.createHttpProvider($r,jr);Lr&&(this.httpProviders[$r]=Lr)}createHttpProviders(){const $r={};return this.namespace.chains.forEach(jr=>{var Lr;const Ur=parseInt(Ct(jr));$r[Ur]=this.createHttpProvider(Ur,(Lr=this.namespace.rpcMap)==null?void 0:Lr[jr])}),$r}getAccounts(){const $r=this.namespace.accounts;return $r?[...new Set($r.filter(jr=>jr.split(":")[1]===this.chainId.toString()).map(jr=>jr.split(":")[2]))]:[]}getHttpProvider(){const $r=this.chainId,jr=this.httpProviders[$r];if(typeof jr>"u")throw new Error(`JSON-RPC provider for ${$r} not found`);return jr}async handleSwitchChain($r){var jr,Lr;let Ur=$r.request.params?(jr=$r.request.params[0])==null?void 0:jr.chainId:"0x0";Ur=Ur.startsWith("0x")?Ur:`0x${Ur}`;const Wr=parseInt(Ur,16);if(this.isChainApproved(Wr))this.setDefaultChain(`${Wr}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:$r.topic,request:{method:$r.request.method,params:[{chainId:Ur}]},chainId:(Lr=this.namespace.chains)==null?void 0:Lr[0]}),this.setDefaultChain(`${Wr}`);else throw new Error(`Failed to switch to chain 'eip155:${Wr}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved($r){return this.namespace.chains.includes(`${this.name}:${$r}`)}};class jg{constructor($r){this.name="solana",this.namespace=$r.namespace,this.events=z$5("events"),this.client=z$5("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace($r){this.namespace=Object.assign(this.namespace,$r)}requestAccounts(){return this.getAccounts()}request($r){return this.namespace.methods.includes($r.request.method)?this.client.request($r):this.getHttpProvider().request($r.request)}setDefaultChain($r,jr){this.httpProviders[$r]||this.setHttpProvider($r,jr),this.chainId=$r,this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${$r}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const $r=this.namespace.chains[0];if(!$r)throw new Error("ChainId not found");return $r.split(":")[1]}getAccounts(){const $r=this.namespace.accounts;return $r?[...new Set($r.filter(jr=>jr.split(":")[1]===this.chainId.toString()).map(jr=>jr.split(":")[2]))]:[]}createHttpProviders(){const $r={};return this.namespace.chains.forEach(jr=>{var Lr;const Ur=Ct(jr);$r[Ur]=this.createHttpProvider(Ur,(Lr=this.namespace.rpcMap)==null?void 0:Lr[jr])}),$r}getHttpProvider(){const $r=`${this.name}:${this.chainId}`,jr=this.httpProviders[$r];if(typeof jr>"u")throw new Error(`JSON-RPC provider for ${$r} not found`);return jr}setHttpProvider($r,jr){const Lr=this.createHttpProvider($r,jr);Lr&&(this.httpProviders[$r]=Lr)}createHttpProvider($r,jr){const Lr=jr||ft($r,this.namespace,this.client.core.projectId);if(!Lr)throw new Error(`No RPC url provided for chainId: ${$r}`);return new JsonRpcProvider(new HttpConnection(Lr,z$5("disableProviderPing")))}}let nv$1=class{constructor($r){this.name="cosmos",this.namespace=$r.namespace,this.events=z$5("events"),this.client=z$5("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace($r){this.namespace=Object.assign(this.namespace,$r)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const $r=this.namespace.chains[0];if(!$r)throw new Error("ChainId not found");return $r.split(":")[1]}request($r){return this.namespace.methods.includes($r.request.method)?this.client.request($r):this.getHttpProvider().request($r.request)}setDefaultChain($r,jr){this.httpProviders[$r]||this.setHttpProvider($r,jr),this.chainId=$r,this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const $r=this.namespace.accounts;return $r?[...new Set($r.filter(jr=>jr.split(":")[1]===this.chainId.toString()).map(jr=>jr.split(":")[2]))]:[]}createHttpProviders(){const $r={};return this.namespace.chains.forEach(jr=>{var Lr;const Ur=Ct(jr);$r[Ur]=this.createHttpProvider(Ur,(Lr=this.namespace.rpcMap)==null?void 0:Lr[jr])}),$r}getHttpProvider(){const $r=`${this.name}:${this.chainId}`,jr=this.httpProviders[$r];if(typeof jr>"u")throw new Error(`JSON-RPC provider for ${$r} not found`);return jr}setHttpProvider($r,jr){const Lr=this.createHttpProvider($r,jr);Lr&&(this.httpProviders[$r]=Lr)}createHttpProvider($r,jr){const Lr=jr||ft($r,this.namespace,this.client.core.projectId);if(!Lr)throw new Error(`No RPC url provided for chainId: ${$r}`);return new JsonRpcProvider(new HttpConnection(Lr,z$5("disableProviderPing")))}},tv$1=class{constructor($r){this.name="cip34",this.namespace=$r.namespace,this.events=z$5("events"),this.client=z$5("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace($r){this.namespace=Object.assign(this.namespace,$r)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const $r=this.namespace.chains[0];if(!$r)throw new Error("ChainId not found");return $r.split(":")[1]}request($r){return this.namespace.methods.includes($r.request.method)?this.client.request($r):this.getHttpProvider().request($r.request)}setDefaultChain($r,jr){this.httpProviders[$r]||this.setHttpProvider($r,jr),this.chainId=$r,this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const $r=this.namespace.accounts;return $r?[...new Set($r.filter(jr=>jr.split(":")[1]===this.chainId.toString()).map(jr=>jr.split(":")[2]))]:[]}createHttpProviders(){const $r={};return this.namespace.chains.forEach(jr=>{const Lr=this.getCardanoRPCUrl(jr),Ur=Ct(jr);$r[Ur]=this.createHttpProvider(Ur,Lr)}),$r}getHttpProvider(){const $r=`${this.name}:${this.chainId}`,jr=this.httpProviders[$r];if(typeof jr>"u")throw new Error(`JSON-RPC provider for ${$r} not found`);return jr}getCardanoRPCUrl($r){const jr=this.namespace.rpcMap;if(jr)return jr[$r]}setHttpProvider($r,jr){const Lr=this.createHttpProvider($r,jr);Lr&&(this.httpProviders[$r]=Lr)}createHttpProvider($r,jr){const Lr=jr||this.getCardanoRPCUrl($r);if(!Lr)throw new Error(`No RPC url provided for chainId: ${$r}`);return new JsonRpcProvider(new HttpConnection(Lr,z$5("disableProviderPing")))}},ev$1=class{constructor($r){this.name="elrond",this.namespace=$r.namespace,this.events=z$5("events"),this.client=z$5("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace($r){this.namespace=Object.assign(this.namespace,$r)}requestAccounts(){return this.getAccounts()}request($r){return this.namespace.methods.includes($r.request.method)?this.client.request($r):this.getHttpProvider().request($r.request)}setDefaultChain($r,jr){this.httpProviders[$r]||this.setHttpProvider($r,jr),this.chainId=$r,this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${$r}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const $r=this.namespace.chains[0];if(!$r)throw new Error("ChainId not found");return $r.split(":")[1]}getAccounts(){const $r=this.namespace.accounts;return $r?[...new Set($r.filter(jr=>jr.split(":")[1]===this.chainId.toString()).map(jr=>jr.split(":")[2]))]:[]}createHttpProviders(){const $r={};return this.namespace.chains.forEach(jr=>{var Lr;const Ur=Ct(jr);$r[Ur]=this.createHttpProvider(Ur,(Lr=this.namespace.rpcMap)==null?void 0:Lr[jr])}),$r}getHttpProvider(){const $r=`${this.name}:${this.chainId}`,jr=this.httpProviders[$r];if(typeof jr>"u")throw new Error(`JSON-RPC provider for ${$r} not found`);return jr}setHttpProvider($r,jr){const Lr=this.createHttpProvider($r,jr);Lr&&(this.httpProviders[$r]=Lr)}createHttpProvider($r,jr){const Lr=jr||ft($r,this.namespace,this.client.core.projectId);if(!Lr)throw new Error(`No RPC url provided for chainId: ${$r}`);return new JsonRpcProvider(new HttpConnection(Lr,z$5("disableProviderPing")))}},rv$1=class{constructor($r){this.name="multiversx",this.namespace=$r.namespace,this.events=z$5("events"),this.client=z$5("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace($r){this.namespace=Object.assign(this.namespace,$r)}requestAccounts(){return this.getAccounts()}request($r){return this.namespace.methods.includes($r.request.method)?this.client.request($r):this.getHttpProvider().request($r.request)}setDefaultChain($r,jr){this.httpProviders[$r]||this.setHttpProvider($r,jr),this.chainId=$r,this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${$r}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const $r=this.namespace.chains[0];if(!$r)throw new Error("ChainId not found");return $r.split(":")[1]}getAccounts(){const $r=this.namespace.accounts;return $r?[...new Set($r.filter(jr=>jr.split(":")[1]===this.chainId.toString()).map(jr=>jr.split(":")[2]))]:[]}createHttpProviders(){const $r={};return this.namespace.chains.forEach(jr=>{var Lr;const Ur=Ct(jr);$r[Ur]=this.createHttpProvider(Ur,(Lr=this.namespace.rpcMap)==null?void 0:Lr[jr])}),$r}getHttpProvider(){const $r=`${this.name}:${this.chainId}`,jr=this.httpProviders[$r];if(typeof jr>"u")throw new Error(`JSON-RPC provider for ${$r} not found`);return jr}setHttpProvider($r,jr){const Lr=this.createHttpProvider($r,jr);Lr&&(this.httpProviders[$r]=Lr)}createHttpProvider($r,jr){const Lr=jr||ft($r,this.namespace,this.client.core.projectId);if(!Lr)throw new Error(`No RPC url provided for chainId: ${$r}`);return new JsonRpcProvider(new HttpConnection(Lr,z$5("disableProviderPing")))}};class iv{constructor($r){this.name="near",this.namespace=$r.namespace,this.events=z$5("events"),this.client=z$5("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace($r){this.namespace=Object.assign(this.namespace,$r)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const $r=this.namespace.chains[0];if(!$r)throw new Error("ChainId not found");return $r.split(":")[1]}request($r){return this.namespace.methods.includes($r.request.method)?this.client.request($r):this.getHttpProvider().request($r.request)}setDefaultChain($r,jr){if(this.chainId=$r,!this.httpProviders[$r]){const Lr=jr||ft(`${this.name}:${$r}`,this.namespace);if(!Lr)throw new Error(`No RPC url provided for chainId: ${$r}`);this.setHttpProvider($r,Lr)}this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const $r=this.namespace.accounts;return $r?$r.filter(jr=>jr.split(":")[1]===this.chainId.toString()).map(jr=>jr.split(":")[2])||[]:[]}createHttpProviders(){const $r={};return this.namespace.chains.forEach(jr=>{var Lr;$r[jr]=this.createHttpProvider(jr,(Lr=this.namespace.rpcMap)==null?void 0:Lr[jr])}),$r}getHttpProvider(){const $r=`${this.name}:${this.chainId}`,jr=this.httpProviders[$r];if(typeof jr>"u")throw new Error(`JSON-RPC provider for ${$r} not found`);return jr}setHttpProvider($r,jr){const Lr=this.createHttpProvider($r,jr);Lr&&(this.httpProviders[$r]=Lr)}createHttpProvider($r,jr){const Lr=jr||ft($r,this.namespace);return typeof Lr>"u"?void 0:new JsonRpcProvider(new HttpConnection(Lr,z$5("disableProviderPing")))}}var sv$1=Object.defineProperty,uv$1=Object.defineProperties,av=Object.getOwnPropertyDescriptors,ba$1=Object.getOwnPropertySymbols,ov$1=Object.prototype.hasOwnProperty,fv=Object.prototype.propertyIsEnumerable,Ta$1=(Nr,$r,jr)=>$r in Nr?sv$1(Nr,$r,{enumerable:!0,configurable:!0,writable:!0,value:jr}):Nr[$r]=jr,hr=(Nr,$r)=>{for(var jr in $r||($r={}))ov$1.call($r,jr)&&Ta$1(Nr,jr,$r[jr]);if(ba$1)for(var jr of ba$1($r))fv.call($r,jr)&&Ta$1(Nr,jr,$r[jr]);return Nr},Mi$1=(Nr,$r)=>uv$1(Nr,av($r));class lr{constructor($r){this.events=new $g,this.rpcProviders={},this.shouldAbortPairingAttempt=!1,this.maxPairingAttempts=10,this.disableProviderPing=!1,this.providerOpts=$r,this.logger=typeof($r==null?void 0:$r.logger)<"u"&&typeof($r==null?void 0:$r.logger)!="string"?$r.logger:cjs$4.pino(cjs$4.getDefaultLoggerOptions({level:($r==null?void 0:$r.logger)||Ia})),this.disableProviderPing=($r==null?void 0:$r.disableProviderPing)||!1}static async init($r){const jr=new lr($r);return await jr.initialize(),jr}async request($r,jr){const[Lr,Ur]=this.validateChain(jr);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(Lr).request({request:hr({},$r),chainId:`${Lr}:${Ur}`,topic:this.session.topic})}sendAsync($r,jr,Lr){this.request($r,Lr).then(Ur=>jr(null,Ur)).catch(Ur=>jr(Ur,void 0))}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties}),await this.requestAccounts()}async disconnect(){var $r;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:($r=this.session)==null?void 0:$r.topic,reason:U$4("USER_DISCONNECTED")}),await this.cleanup()}async connect($r){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces($r),await this.cleanupPendingPairings(),!$r.skipPairing)return await this.pair($r.pairingTopic)}on($r,jr){this.events.on($r,jr)}once($r,jr){this.events.once($r,jr)}removeListener($r,jr){this.events.removeListener($r,jr)}off($r,jr){this.events.off($r,jr)}get isWalletConnect(){return!0}async pair($r){this.shouldAbortPairingAttempt=!1;let jr=0;do{if(this.shouldAbortPairingAttempt)throw new Error("Pairing aborted");if(jr>=this.maxPairingAttempts)throw new Error("Max auto pairing attempts reached");const{uri:Lr,approval:Ur}=await this.client.connect({pairingTopic:$r,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties});Lr&&(this.uri=Lr,this.events.emit("display_uri",Lr)),await Ur().then(Wr=>{this.session=Wr,this.namespaces||(this.namespaces=Qg$1(Wr.namespaces),this.persist("namespaces",this.namespaces))}).catch(Wr=>{if(Wr.message!==oe$1)throw Wr;jr++})}while(!this.session);return this.onConnect(),this.session}setDefaultChain($r,jr){try{if(!this.session)return;const[Lr,Ur]=this.validateChain($r);this.getProvider(Lr).setDefaultChain(Ur,jr)}catch(Lr){if(!/Please call connect/.test(Lr.message))throw Lr}}async cleanupPendingPairings($r={}){this.logger.info("Cleaning up inactive pairings...");const jr=this.client.pairing.getAll();if(D$5(jr)){for(const Lr of jr)$r.deletePairings?this.client.core.expirer.set(Lr.topic,0):await this.client.core.relayer.subscriber.unsubscribe(Lr.topic);this.logger.info(`Inactive pairings cleared: ${jr.length}`)}}abortPairingAttempt(){this.shouldAbortPairingAttempt=!0}async checkStorage(){if(this.namespaces=await this.getFromStore("namespaces"),this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.client.session.length){const $r=this.client.session.keys.length-1;this.session=this.client.session.get(this.client.session.keys[$r]),this.createProviders()}}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){this.client=this.providerOpts.client||await Q$3.init({logger:this.providerOpts.logger||Ia,relayUrl:this.providerOpts.relayUrl||Ug$1,projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name}),this.logger.trace("SignClient Initialized")}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const $r=[...new Set(Object.keys(this.session.namespaces).map(jr=>Xe$1(jr)))];Fi$1("client",this.client),Fi$1("events",this.events),Fi$1("disableProviderPing",this.disableProviderPing),$r.forEach(jr=>{if(!this.session)return;const Lr=Zg$1(jr,this.session),Ur=Sa$1(Lr),Wr=Jg(this.namespaces,this.optionalNamespaces),Hr=Mi$1(hr({},Wr[jr]),{accounts:Lr,chains:Ur});switch(jr){case"eip155":this.rpcProviders[jr]=new kg$1({namespace:Hr});break;case"solana":this.rpcProviders[jr]=new jg({namespace:Hr});break;case"cosmos":this.rpcProviders[jr]=new nv$1({namespace:Hr});break;case"polkadot":this.rpcProviders[jr]=new Vg({namespace:Hr});break;case"cip34":this.rpcProviders[jr]=new tv$1({namespace:Hr});break;case"elrond":this.rpcProviders[jr]=new ev$1({namespace:Hr});break;case"multiversx":this.rpcProviders[jr]=new rv$1({namespace:Hr});break;case"near":this.rpcProviders[jr]=new iv({namespace:Hr});break}})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",$r=>{this.events.emit("session_ping",$r)}),this.client.on("session_event",$r=>{const{params:jr}=$r,{event:Lr}=jr;if(Lr.name==="accountsChanged"){const Ur=Lr.data;Ur&&D$5(Ur)&&this.events.emit("accountsChanged",Ur.map(Xg$1))}else if(Lr.name==="chainChanged"){const Ur=jr.chainId,Wr=jr.event.data,Hr=Xe$1(Ur),qr=Wi$1(Ur)!==Wi$1(Wr)?`${Hr}:${Wi$1(Wr)}`:Ur;this.onChainChanged(qr)}else this.events.emit(Lr.name,Lr.data);this.events.emit("session_event",$r)}),this.client.on("session_update",({topic:$r,params:jr})=>{var Lr;const{namespaces:Ur}=jr,Wr=(Lr=this.client)==null?void 0:Lr.session.get($r);this.session=Mi$1(hr({},Wr),{namespaces:Ur}),this.onSessionUpdate(),this.events.emit("session_update",{topic:$r,params:jr})}),this.client.on("session_delete",async $r=>{await this.cleanup(),this.events.emit("session_delete",$r),this.events.emit("disconnect",Mi$1(hr({},U$4("USER_DISCONNECTED")),{data:$r.topic}))}),this.on(Vn.DEFAULT_CHAIN_CHANGED,$r=>{this.onChainChanged($r,!0)})}getProvider($r){if(!this.rpcProviders[$r])throw new Error(`Provider not found: ${$r}`);return this.rpcProviders[$r]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach($r=>{var jr;this.getProvider($r).updateNamespace((jr=this.session)==null?void 0:jr.namespaces[$r])})}setNamespaces($r){const{namespaces:jr,optionalNamespaces:Lr,sessionProperties:Ur}=$r;jr&&Object.keys(jr).length&&(this.namespaces=jr),Lr&&Object.keys(Lr).length&&(this.optionalNamespaces=Lr),this.sessionProperties=Ur,this.persist("namespaces",jr),this.persist("optionalNamespaces",Lr)}validateChain($r){const[jr,Lr]=($r==null?void 0:$r.split(":"))||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[jr,Lr];if(jr&&!Object.keys(this.namespaces||{}).map(Hr=>Xe$1(Hr)).includes(jr))throw new Error(`Namespace '${jr}' is not configured. Please call connect() first with namespace config.`);if(jr&&Lr)return[jr,Lr];const Ur=Xe$1(Object.keys(this.namespaces)[0]),Wr=this.rpcProviders[Ur].getDefaultChain();return[Ur,Wr]}async requestAccounts(){const[$r]=this.validateChain();return await this.getProvider($r).requestAccounts()}onChainChanged($r,jr=!1){var Lr;if(!this.namespaces)return;const[Ur,Wr]=this.validateChain($r);jr||this.getProvider(Ur).setDefaultChain(Wr),((Lr=this.namespaces[Ur])!=null?Lr:this.namespaces[`${Ur}:${Wr}`]).defaultChain=Wr,this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",Wr)}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.session=void 0,this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,this.persist("namespaces",void 0),this.persist("optionalNamespaces",void 0),this.persist("sessionProperties",void 0),await this.cleanupPendingPairings({deletePairings:!0})}persist($r,jr){this.client.core.storage.setItem(`${xa$1}/${$r}`,jr)}async getFromStore($r){return await this.client.core.storage.getItem(`${xa$1}/${$r}`)}}const cv=lr,P$4="wc",S$2="ethereum_provider",$$4=`${P$4}@2:${S$2}:`,j$3="https://rpc.walletconnect.com/v1/",u$3=["eth_sendTransaction","personal_sign"],E$4=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode"],m$5=["chainChanged","accountsChanged"],_$5=["chainChanged","accountsChanged","message","disconnect","connect"];var N$3=Object.defineProperty,q$5=Object.defineProperties,D$3=Object.getOwnPropertyDescriptors,y$4=Object.getOwnPropertySymbols,U$2=Object.prototype.hasOwnProperty,Q$2=Object.prototype.propertyIsEnumerable,O$2=(Nr,$r,jr)=>$r in Nr?N$3(Nr,$r,{enumerable:!0,configurable:!0,writable:!0,value:jr}):Nr[$r]=jr,p$4=(Nr,$r)=>{for(var jr in $r||($r={}))U$2.call($r,jr)&&O$2(Nr,jr,$r[jr]);if(y$4)for(var jr of y$4($r))Q$2.call($r,jr)&&O$2(Nr,jr,$r[jr]);return Nr},M$3=(Nr,$r)=>q$5(Nr,D$3($r));function g$5(Nr){return Number(Nr[0].split(":")[1])}function f$4(Nr){return`0x${Nr.toString(16)}`}function L$3(Nr){const{chains:$r,optionalChains:jr,methods:Lr,optionalMethods:Ur,events:Wr,optionalEvents:Hr,rpcMap:qr}=Nr;if(!D$5($r))throw new Error("Invalid chains");const Vr={chains:$r,methods:Lr||u$3,events:Wr||m$5,rpcMap:p$4({},$r.length?{[g$5($r)]:qr[g$5($r)]}:{})},Gr=Wr==null?void 0:Wr.filter(Zn=>!m$5.includes(Zn)),Cn=Lr==null?void 0:Lr.filter(Zn=>!u$3.includes(Zn));if(!jr&&!Hr&&!Ur&&!(Gr!=null&&Gr.length)&&!(Cn!=null&&Cn.length))return{required:$r.length?Vr:void 0};const In=(Gr==null?void 0:Gr.length)&&(Cn==null?void 0:Cn.length)||!jr,Gn={chains:[...new Set(In?Vr.chains.concat(jr||[]):jr)],methods:[...new Set(Vr.methods.concat(Ur!=null&&Ur.length?Ur:E$4))],events:[...new Set(Vr.events.concat(Hr!=null&&Hr.length?Hr:_$5))],rpcMap:qr};return{required:$r.length?Vr:void 0,optional:jr.length?Gn:void 0}}let v$6=class L3{constructor(){this.events=new eventsExports.EventEmitter,this.namespace="eip155",this.accounts=[],this.chainId=1,this.STORAGE_KEY=$$4,this.on=($r,jr)=>(this.events.on($r,jr),this),this.once=($r,jr)=>(this.events.once($r,jr),this),this.removeListener=($r,jr)=>(this.events.removeListener($r,jr),this),this.off=($r,jr)=>(this.events.off($r,jr),this),this.parseAccount=$r=>this.isCompatibleChainId($r)?this.parseAccountId($r).address:$r,this.signer={},this.rpc={}}static async init($r){const jr=new L3;return await jr.initialize($r),jr}async request($r){return await this.signer.request($r,this.formatChainId(this.chainId))}sendAsync($r,jr){this.signer.sendAsync($r,jr,this.formatChainId(this.chainId))}get connected(){return this.signer.client?this.signer.client.core.relayer.connected:!1}get connecting(){return this.signer.client?this.signer.client.core.relayer.connecting:!1}async enable(){return this.session||await this.connect(),await this.request({method:"eth_requestAccounts"})}async connect($r){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts($r);const{required:jr,optional:Lr}=L$3(this.rpc);try{const Ur=await new Promise(async(Hr,qr)=>{var Vr;this.rpc.showQrModal&&((Vr=this.modal)==null||Vr.subscribeModal(Gr=>{!Gr.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),qr(new Error("Connection request reset. Please try again.")))})),await this.signer.connect(M$3(p$4({namespaces:p$4({},jr&&{[this.namespace]:jr})},Lr&&{optionalNamespaces:{[this.namespace]:Lr}}),{pairingTopic:$r==null?void 0:$r.pairingTopic})).then(Gr=>{Hr(Gr)}).catch(Gr=>{qr(new Error(Gr.message))})});if(!Ur)return;const Wr=Rn$1(Ur.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:Wr),this.setAccounts(Wr),this.events.emit("connect",{chainId:f$4(this.chainId)})}catch(Ur){throw this.signer.logger.error(Ur),Ur}finally{this.modal&&this.modal.closeModal()}}async disconnect(){this.session&&await this.signer.disconnect(),this.reset()}get isWalletConnect(){return!0}get session(){return this.signer.session}registerEventListeners(){this.signer.on("session_event",$r=>{const{params:jr}=$r,{event:Lr}=jr;Lr.name==="accountsChanged"?(this.accounts=this.parseAccounts(Lr.data),this.events.emit("accountsChanged",this.accounts)):Lr.name==="chainChanged"?this.setChainId(this.formatChainId(Lr.data)):this.events.emit(Lr.name,Lr.data),this.events.emit("session_event",$r)}),this.signer.on("chainChanged",$r=>{const jr=parseInt($r);this.chainId=jr,this.events.emit("chainChanged",f$4(this.chainId)),this.persist()}),this.signer.on("session_update",$r=>{this.events.emit("session_update",$r)}),this.signer.on("session_delete",$r=>{this.reset(),this.events.emit("session_delete",$r),this.events.emit("disconnect",M$3(p$4({},U$4("USER_DISCONNECTED")),{data:$r.topic,name:"USER_DISCONNECTED"}))}),this.signer.on("display_uri",$r=>{var jr,Lr;this.rpc.showQrModal&&((jr=this.modal)==null||jr.closeModal(),(Lr=this.modal)==null||Lr.openModal({uri:$r})),this.events.emit("display_uri",$r)})}switchEthereumChain($r){this.request({method:"wallet_switchEthereumChain",params:[{chainId:$r.toString(16)}]})}isCompatibleChainId($r){return typeof $r=="string"?$r.startsWith(`${this.namespace}:`):!1}formatChainId($r){return`${this.namespace}:${$r}`}parseChainId($r){return Number($r.split(":")[1])}setChainIds($r){const jr=$r.filter(Lr=>this.isCompatibleChainId(Lr)).map(Lr=>this.parseChainId(Lr));jr.length&&(this.chainId=jr[0],this.events.emit("chainChanged",f$4(this.chainId)),this.persist())}setChainId($r){if(this.isCompatibleChainId($r)){const jr=this.parseChainId($r);this.chainId=jr,this.switchEthereumChain(jr)}}parseAccountId($r){const[jr,Lr,Ur]=$r.split(":");return{chainId:`${jr}:${Lr}`,address:Ur}}setAccounts($r){this.accounts=$r.filter(jr=>this.parseChainId(this.parseAccountId(jr).chainId)===this.chainId).map(jr=>this.parseAccountId(jr).address),this.events.emit("accountsChanged",this.accounts)}getRpcConfig($r){var jr,Lr;const Ur=(jr=$r==null?void 0:$r.chains)!=null?jr:[],Wr=(Lr=$r==null?void 0:$r.optionalChains)!=null?Lr:[],Hr=Ur.concat(Wr);if(!Hr.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const qr=Ur.length?($r==null?void 0:$r.methods)||u$3:[],Vr=Ur.length?($r==null?void 0:$r.events)||m$5:[],Gr=($r==null?void 0:$r.optionalMethods)||[],Cn=($r==null?void 0:$r.optionalEvents)||[],In=($r==null?void 0:$r.rpcMap)||this.buildRpcMap(Hr,$r.projectId),Gn=($r==null?void 0:$r.qrModalOptions)||void 0;return{chains:Ur==null?void 0:Ur.map(Zn=>this.formatChainId(Zn)),optionalChains:Wr.map(Zn=>this.formatChainId(Zn)),methods:qr,events:Vr,optionalMethods:Gr,optionalEvents:Cn,rpcMap:In,showQrModal:!!($r!=null&&$r.showQrModal),qrModalOptions:Gn,projectId:$r.projectId,metadata:$r.metadata}}buildRpcMap($r,jr){const Lr={};return $r.forEach(Ur=>{Lr[Ur]=this.getRpcUrl(Ur,jr)}),Lr}async initialize($r){if(this.rpc=this.getRpcConfig($r),this.chainId=this.rpc.chains.length?g$5(this.rpc.chains):g$5(this.rpc.optionalChains),this.signer=await cv.init({projectId:this.rpc.projectId,metadata:this.rpc.metadata,disableProviderPing:$r.disableProviderPing,relayUrl:$r.relayUrl,storageOptions:$r.storageOptions}),this.registerEventListeners(),await this.loadPersistedSession(),this.rpc.showQrModal){let jr;try{const{WalletConnectModal:Lr}=await __vitePreload(()=>import("./index-7992f12d.js").then(Ur=>Ur.i),[]);jr=Lr}catch{throw new Error("To use QR modal, please install @walletconnect/modal package")}if(jr)try{this.modal=new jr(p$4({walletConnectVersion:2,projectId:this.rpc.projectId,standaloneChains:this.rpc.chains},this.rpc.qrModalOptions))}catch(Lr){throw this.signer.logger.error(Lr),new Error("Could not generate WalletConnectModal Instance")}}}loadConnectOpts($r){if(!$r)return;const{chains:jr,optionalChains:Lr,rpcMap:Ur}=$r;jr&&D$5(jr)&&(this.rpc.chains=jr.map(Wr=>this.formatChainId(Wr)),jr.forEach(Wr=>{this.rpc.rpcMap[Wr]=(Ur==null?void 0:Ur[Wr])||this.getRpcUrl(Wr)})),Lr&&D$5(Lr)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=Lr==null?void 0:Lr.map(Wr=>this.formatChainId(Wr)),Lr.forEach(Wr=>{this.rpc.rpcMap[Wr]=(Ur==null?void 0:Ur[Wr])||this.getRpcUrl(Wr)}))}getRpcUrl($r,jr){var Lr;return((Lr=this.rpc.rpcMap)==null?void 0:Lr[$r])||`${j$3}?chainId=eip155:${$r}&projectId=${jr||this.rpc.projectId}`}async loadPersistedSession(){if(!this.session)return;const $r=await this.signer.client.core.storage.getItem(`${this.STORAGE_KEY}/chainId`),jr=this.session.namespaces[`${this.namespace}:${$r}`]?this.session.namespaces[`${this.namespace}:${$r}`]:this.session.namespaces[this.namespace];this.setChainIds($r?[this.formatChainId($r)]:jr==null?void 0:jr.accounts),this.setAccounts(jr==null?void 0:jr.accounts)}reset(){this.chainId=1,this.accounts=[]}persist(){this.session&&this.signer.client.core.storage.setItem(`${this.STORAGE_KEY}/chainId`,this.chainId)}parseAccounts($r){return typeof $r=="string"||$r instanceof String?[this.parseAccount($r)]:$r.map(jr=>this.parseAccount(jr))}};const G$2=v$6;var cjs$2={},cjs$1={};Object.defineProperty(cjs$1,"__esModule",{value:!0});var getLocalStorage_1=cjs$1.getLocalStorage=getLocalStorageOrThrow_1=cjs$1.getLocalStorageOrThrow=getCrypto_1=cjs$1.getCrypto=getCryptoOrThrow_1=cjs$1.getCryptoOrThrow=getLocation_1=cjs$1.getLocation=getLocationOrThrow_1=cjs$1.getLocationOrThrow=getNavigator_1=cjs$1.getNavigator=getNavigatorOrThrow_1=cjs$1.getNavigatorOrThrow=getDocument_1=cjs$1.getDocument=getDocumentOrThrow_1=cjs$1.getDocumentOrThrow=getFromWindowOrThrow_1=cjs$1.getFromWindowOrThrow=getFromWindow_1=cjs$1.getFromWindow=void 0;function getFromWindow$1(Nr){let $r;return typeof window<"u"&&typeof window[Nr]<"u"&&($r=window[Nr]),$r}var getFromWindow_1=cjs$1.getFromWindow=getFromWindow$1;function getFromWindowOrThrow$1(Nr){const $r=getFromWindow$1(Nr);if(!$r)throw new Error(`${Nr} is not defined in Window`);return $r}var getFromWindowOrThrow_1=cjs$1.getFromWindowOrThrow=getFromWindowOrThrow$1;function getDocumentOrThrow$1(){return getFromWindowOrThrow$1("document")}var getDocumentOrThrow_1=cjs$1.getDocumentOrThrow=getDocumentOrThrow$1;function getDocument$1(){return getFromWindow$1("document")}var getDocument_1=cjs$1.getDocument=getDocument$1;function getNavigatorOrThrow$1(){return getFromWindowOrThrow$1("navigator")}var getNavigatorOrThrow_1=cjs$1.getNavigatorOrThrow=getNavigatorOrThrow$1;function getNavigator$1(){return getFromWindow$1("navigator")}var getNavigator_1=cjs$1.getNavigator=getNavigator$1;function getLocationOrThrow$1(){return getFromWindowOrThrow$1("location")}var getLocationOrThrow_1=cjs$1.getLocationOrThrow=getLocationOrThrow$1;function getLocation$1(){return getFromWindow$1("location")}var getLocation_1=cjs$1.getLocation=getLocation$1;function getCryptoOrThrow$1(){return getFromWindowOrThrow$1("crypto")}var getCryptoOrThrow_1=cjs$1.getCryptoOrThrow=getCryptoOrThrow$1;function getCrypto$1(){return getFromWindow$1("crypto")}var getCrypto_1=cjs$1.getCrypto=getCrypto$1;function getLocalStorageOrThrow$1(){return getFromWindowOrThrow$1("localStorage")}var getLocalStorageOrThrow_1=cjs$1.getLocalStorageOrThrow=getLocalStorageOrThrow$1;function getLocalStorage$1(){return getFromWindow$1("localStorage")}getLocalStorage_1=cjs$1.getLocalStorage=getLocalStorage$1;Object.defineProperty(cjs$2,"__esModule",{value:!0});var getWindowMetadata_1=cjs$2.getWindowMetadata=void 0;const window_getters_1=cjs$1;function getWindowMetadata(){let Nr,$r;try{Nr=window_getters_1.getDocumentOrThrow(),$r=window_getters_1.getLocationOrThrow()}catch{return null}function jr(){const In=Nr.getElementsByTagName("link"),Gn=[];for(let Zn=0;Zn-1){const xo=no.getAttribute("href");if(xo)if(xo.toLowerCase().indexOf("https:")===-1&&xo.toLowerCase().indexOf("http:")===-1&&xo.indexOf("//")!==0){let so=$r.protocol+"//"+$r.host;if(xo.indexOf("/")===0)so+=xo;else{const io=$r.pathname.split("/");io.pop();const lo=io.join("/");so+=lo+"/"+xo}Gn.push(so)}else if(xo.indexOf("//")===0){const so=$r.protocol+xo;Gn.push(so)}else Gn.push(xo)}}return Gn}function Lr(...In){const Gn=Nr.getElementsByTagName("meta");for(let Zn=0;Znno.getAttribute(xo)).filter(xo=>xo?In.includes(xo):!1);if(ho.length&&ho){const xo=no.getAttribute("content");if(xo)return xo}}return""}function Ur(){let In=Lr("name","og:site_name","og:title","twitter:title");return In||(In=Nr.title),In}function Wr(){return Lr("description","og:description","twitter:description","keywords")}const Hr=Ur(),qr=Wr(),Vr=$r.origin,Gr=jr();return{description:qr,url:Vr,icons:Gr,name:Hr}}getWindowMetadata_1=cjs$2.getWindowMetadata=getWindowMetadata;var __spreadArrays=globalThis&&globalThis.__spreadArrays||function(){for(var Nr=0,$r=0,jr=arguments.length;$r"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new ReactNativeInfo:typeof navigator<"u"?parseUserAgent(navigator.userAgent):getNodeVersion()}function matchUserAgent(Nr){return Nr!==""&&userAgentRules.reduce(function($r,jr){var Lr=jr[0],Ur=jr[1];if($r)return $r;var Wr=Ur.exec(Nr);return!!Wr&&[Lr,Wr]},!1)}function parseUserAgent(Nr){var $r=matchUserAgent(Nr);if(!$r)return null;var jr=$r[0],Lr=$r[1];if(jr==="searchbot")return new BotInfo;var Ur=Lr[1]&&Lr[1].split(/[._]/).slice(0,3);Ur?Ur.length1:!1}function isMobile(){return detectOS()?isAndroid()||isIOS():!1}function isNode$1(){const Nr=detectEnv();return Nr&&Nr.name?Nr.name.toLowerCase()==="node":!1}function isBrowser(){return!isNode$1()&&!!getNavigator()}const getFromWindow=getFromWindow_1,getFromWindowOrThrow=getFromWindowOrThrow_1,getDocumentOrThrow=getDocumentOrThrow_1,getDocument=getDocument_1,getNavigatorOrThrow=getNavigatorOrThrow_1,getNavigator=getNavigator_1,getLocationOrThrow=getLocationOrThrow_1,getLocation=getLocation_1,getCryptoOrThrow=getCryptoOrThrow_1,getCrypto=getCrypto_1,getLocalStorageOrThrow=getLocalStorageOrThrow_1,getLocalStorage=getLocalStorage_1;function getClientMeta(){return getWindowMetadata_1()}function safeJsonParse$1(Nr){if(typeof Nr!="string")throw new Error(`Cannot safe json parse value of type ${typeof Nr}`);try{return JSON.parse(Nr)}catch{return Nr}}function safeJsonStringify$1(Nr){return typeof Nr=="string"?Nr:JSON.stringify(Nr)}const safeJsonParse=safeJsonParse$1,safeJsonStringify=safeJsonStringify$1;function setLocal(Nr,$r){const jr=safeJsonStringify($r),Lr=getLocalStorage();Lr&&Lr.setItem(Nr,jr)}function getLocal(Nr){let $r=null,jr=null;const Lr=getLocalStorage();return Lr&&(jr=Lr.getItem(Nr)),$r=jr&&safeJsonParse(jr),$r}function removeLocal(Nr){const $r=getLocalStorage();$r&&$r.removeItem(Nr)}const mobileLinkChoiceKey="WALLETCONNECT_DEEPLINK_CHOICE";function formatIOSMobile(Nr,$r){const jr=encodeURIComponent(Nr);return $r.universalLink?`${$r.universalLink}/wc?uri=${jr}`:$r.deepLink?`${$r.deepLink}${$r.deepLink.endsWith(":")?"//":"/"}wc?uri=${jr}`:""}function saveMobileLinkInfo(Nr){const $r=Nr.href.split("?")[0];setLocal(mobileLinkChoiceKey,Object.assign(Object.assign({},Nr),{href:$r}))}function getMobileRegistryEntry(Nr,$r){return Nr.filter(jr=>jr.name.toLowerCase().includes($r.toLowerCase()))[0]}function getMobileLinkRegistry(Nr,$r){let jr=Nr;return $r&&(jr=$r.map(Lr=>getMobileRegistryEntry(Nr,Lr)).filter(Boolean)),jr}const API_URL="https://registry.walletconnect.com";function getWalletRegistryUrl(){return API_URL+"/api/v2/wallets"}function getDappRegistryUrl(){return API_URL+"/api/v2/dapps"}function formatMobileRegistryEntry(Nr,$r="mobile"){var jr;return{name:Nr.name||"",shortName:Nr.metadata.shortName||"",color:Nr.metadata.colors.primary||"",logo:(jr=Nr.image_url.sm)!==null&&jr!==void 0?jr:"",universalLink:Nr[$r].universal||"",deepLink:Nr[$r].native||""}}function formatMobileRegistry(Nr,$r="mobile"){return Object.values(Nr).filter(jr=>!!jr[$r].universal||!!jr[$r].native).map(jr=>formatMobileRegistryEntry(jr,$r))}const esm=Object.freeze(Object.defineProperty({__proto__:null,detectEnv,detectOS,formatIOSMobile,formatMobileRegistry,formatMobileRegistryEntry,getClientMeta,getCrypto,getCryptoOrThrow,getDappRegistryUrl,getDocument,getDocumentOrThrow,getFromWindow,getFromWindowOrThrow,getLocal,getLocalStorage,getLocalStorageOrThrow,getLocation,getLocationOrThrow,getMobileLinkRegistry,getMobileRegistryEntry,getNavigator,getNavigatorOrThrow,getWalletRegistryUrl,isAndroid,isBrowser,isIOS,isMobile,isNode:isNode$1,mobileLinkChoiceKey,removeLocal,safeJsonParse,safeJsonStringify,saveMobileLinkInfo,setLocal},Symbol.toStringTag,{value:"Module"})),require$$0=getAugmentedNamespace(esm);var browser$1={},canPromise$3=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then},qrcode$1={},typedarrayBuffer={},toString={}.toString,isarray=Array.isArray||function(Nr){return toString.call(Nr)=="[object Array]"},isArray$1=isarray;function typedArraySupport(){try{var Nr=new Uint8Array(1);return Nr.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},Nr.foo()===42}catch{return!1}}Buffer$2.TYPED_ARRAY_SUPPORT=typedArraySupport();var K_MAX_LENGTH=Buffer$2.TYPED_ARRAY_SUPPORT?2147483647:1073741823;function Buffer$2(Nr,$r,jr){return!Buffer$2.TYPED_ARRAY_SUPPORT&&!(this instanceof Buffer$2)?new Buffer$2(Nr,$r,jr):typeof Nr=="number"?allocUnsafe(this,Nr):from(this,Nr,$r,jr)}Buffer$2.TYPED_ARRAY_SUPPORT&&(Buffer$2.prototype.__proto__=Uint8Array.prototype,Buffer$2.__proto__=Uint8Array,typeof Symbol<"u"&&Symbol.species&&Buffer$2[Symbol.species]===Buffer$2&&Object.defineProperty(Buffer$2,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}));function checked(Nr){if(Nr>=K_MAX_LENGTH)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+K_MAX_LENGTH.toString(16)+" bytes");return Nr|0}function isnan(Nr){return Nr!==Nr}function createBuffer(Nr,$r){var jr;return Buffer$2.TYPED_ARRAY_SUPPORT?(jr=new Uint8Array($r),jr.__proto__=Buffer$2.prototype):(jr=Nr,jr===null&&(jr=new Buffer$2($r)),jr.length=$r),jr}function allocUnsafe(Nr,$r){var jr=createBuffer(Nr,$r<0?0:checked($r)|0);if(!Buffer$2.TYPED_ARRAY_SUPPORT)for(var Lr=0;Lr<$r;++Lr)jr[Lr]=0;return jr}function fromString(Nr,$r){var jr=byteLength($r)|0,Lr=createBuffer(Nr,jr),Ur=Lr.write($r);return Ur!==jr&&(Lr=Lr.slice(0,Ur)),Lr}function fromArrayLike(Nr,$r){for(var jr=$r.length<0?0:checked($r.length)|0,Lr=createBuffer(Nr,jr),Ur=0;Ur55295&&jr<57344){if(!Ur){if(jr>56319){($r-=3)>-1&&Wr.push(239,191,189);continue}else if(Hr+1===Lr){($r-=3)>-1&&Wr.push(239,191,189);continue}Ur=jr;continue}if(jr<56320){($r-=3)>-1&&Wr.push(239,191,189),Ur=jr;continue}jr=(Ur-55296<<10|jr-56320)+65536}else Ur&&($r-=3)>-1&&Wr.push(239,191,189);if(Ur=null,jr<128){if(($r-=1)<0)break;Wr.push(jr)}else if(jr<2048){if(($r-=2)<0)break;Wr.push(jr>>6|192,jr&63|128)}else if(jr<65536){if(($r-=3)<0)break;Wr.push(jr>>12|224,jr>>6&63|128,jr&63|128)}else if(jr<1114112){if(($r-=4)<0)break;Wr.push(jr>>18|240,jr>>12&63|128,jr>>6&63|128,jr&63|128)}else throw new Error("Invalid code point")}return Wr}function byteLength(Nr){if(Buffer$2.isBuffer(Nr))return Nr.length;if(typeof ArrayBuffer<"u"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(Nr)||Nr instanceof ArrayBuffer))return Nr.byteLength;typeof Nr!="string"&&(Nr=""+Nr);var $r=Nr.length;return $r===0?0:utf8ToBytes(Nr).length}function blitBuffer(Nr,$r,jr,Lr){for(var Ur=0;Ur=$r.length||Ur>=Nr.length);++Ur)$r[Ur+jr]=Nr[Ur];return Ur}function utf8Write(Nr,$r,jr,Lr){return blitBuffer(utf8ToBytes($r,Nr.length-jr),Nr,jr,Lr)}function from(Nr,$r,jr,Lr){if(typeof $r=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer<"u"&&$r instanceof ArrayBuffer?fromArrayBuffer(Nr,$r,jr,Lr):typeof $r=="string"?fromString(Nr,$r):fromObject(Nr,$r)}Buffer$2.prototype.write=function($r,jr,Lr){jr===void 0?(Lr=this.length,jr=0):Lr===void 0&&typeof jr=="string"?(Lr=this.length,jr=0):isFinite(jr)&&(jr=jr|0,isFinite(Lr)?Lr=Lr|0:Lr=void 0);var Ur=this.length-jr;if((Lr===void 0||Lr>Ur)&&(Lr=Ur),$r.length>0&&(Lr<0||jr<0)||jr>this.length)throw new RangeError("Attempt to write outside buffer bounds");return utf8Write(this,$r,jr,Lr)};Buffer$2.prototype.slice=function($r,jr){var Lr=this.length;$r=~~$r,jr=jr===void 0?Lr:~~jr,$r<0?($r+=Lr,$r<0&&($r=0)):$r>Lr&&($r=Lr),jr<0?(jr+=Lr,jr<0&&(jr=0)):jr>Lr&&(jr=Lr),jr<$r&&(jr=$r);var Ur;if(Buffer$2.TYPED_ARRAY_SUPPORT)Ur=this.subarray($r,jr),Ur.__proto__=Buffer$2.prototype;else{var Wr=jr-$r;Ur=new Buffer$2(Wr,void 0);for(var Hr=0;Hr=$r.length&&(jr=$r.length),jr||(jr=0),Ur>0&&Ur=this.length)throw new RangeError("sourceStart out of bounds");if(Ur<0)throw new RangeError("sourceEnd out of bounds");Ur>this.length&&(Ur=this.length),$r.length-jr=0;--Hr)$r[Hr+jr]=this[Hr+Lr];else if(Wr<1e3||!Buffer$2.TYPED_ARRAY_SUPPORT)for(Hr=0;Hr>>0,Lr=Lr===void 0?this.length:Lr>>>0,$r||($r=0);var Wr;if(typeof $r=="number")for(Wr=jr;Wr40)throw new Error('"version" should be in range from 1 to 40');return $r*4+17};utils$3.getSymbolTotalCodewords=function($r){return CODEWORDS_COUNT$1[$r]};utils$3.getBCHDigit=function(Nr){for(var $r=0;Nr!==0;)$r++,Nr>>>=1;return $r};utils$3.setToSJISFunction=function($r){if(typeof $r!="function")throw new Error('"toSJISFunc" is not a valid function.');toSJISFunction$1=$r};utils$3.isKanjiModeEnabled=function(){return typeof toSJISFunction$1<"u"};utils$3.toSJIS=function($r){return toSJISFunction$1($r)};var errorCorrectionLevel$1={};(function(Nr){Nr.L={bit:1},Nr.M={bit:0},Nr.Q={bit:3},Nr.H={bit:2};function $r(jr){if(typeof jr!="string")throw new Error("Param is not a string");var Lr=jr.toLowerCase();switch(Lr){case"l":case"low":return Nr.L;case"m":case"medium":return Nr.M;case"q":case"quartile":return Nr.Q;case"h":case"high":return Nr.H;default:throw new Error("Unknown EC Level: "+jr)}}Nr.isValid=function(Lr){return Lr&&typeof Lr.bit<"u"&&Lr.bit>=0&&Lr.bit<4},Nr.from=function(Lr,Ur){if(Nr.isValid(Lr))return Lr;try{return $r(Lr)}catch{return Ur}}})(errorCorrectionLevel$1);function BitBuffer$3(){this.buffer=[],this.length=0}BitBuffer$3.prototype={get:function(Nr){var $r=Math.floor(Nr/8);return(this.buffer[$r]>>>7-Nr%8&1)===1},put:function(Nr,$r){for(var jr=0;jr<$r;jr++)this.putBit((Nr>>>$r-jr-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(Nr){var $r=Math.floor(this.length/8);this.buffer.length<=$r&&this.buffer.push(0),Nr&&(this.buffer[$r]|=128>>>this.length%8),this.length++}};var bitBuffer$1=BitBuffer$3,BufferUtil$4=typedarrayBuffer;function BitMatrix$3(Nr){if(!Nr||Nr<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=Nr,this.data=BufferUtil$4.alloc(Nr*Nr),this.reservedBit=BufferUtil$4.alloc(Nr*Nr)}BitMatrix$3.prototype.set=function(Nr,$r,jr,Lr){var Ur=Nr*this.size+$r;this.data[Ur]=jr,Lr&&(this.reservedBit[Ur]=!0)};BitMatrix$3.prototype.get=function(Nr,$r){return this.data[Nr*this.size+$r]};BitMatrix$3.prototype.xor=function(Nr,$r,jr){this.data[Nr*this.size+$r]^=jr};BitMatrix$3.prototype.isReserved=function(Nr,$r){return this.reservedBit[Nr*this.size+$r]};var bitMatrix$1=BitMatrix$3,alignmentPattern$1={};(function(Nr){var $r=utils$3.getSymbolSize;Nr.getRowColCoords=function(Lr){if(Lr===1)return[];for(var Ur=Math.floor(Lr/7)+2,Wr=$r(Lr),Hr=Wr===145?26:Math.ceil((Wr-13)/(2*Ur-2))*2,qr=[Wr-7],Vr=1;Vr=0&&Ur<=7},Nr.from=function(Ur){return Nr.isValid(Ur)?parseInt(Ur,10):void 0},Nr.getPenaltyN1=function(Ur){for(var Wr=Ur.size,Hr=0,qr=0,Vr=0,Gr=null,Cn=null,In=0;In=5&&(Hr+=$r.N1+(qr-5)),Gr=Zn,qr=1),Zn=Ur.get(Gn,In),Zn===Cn?Vr++:(Vr>=5&&(Hr+=$r.N1+(Vr-5)),Cn=Zn,Vr=1)}qr>=5&&(Hr+=$r.N1+(qr-5)),Vr>=5&&(Hr+=$r.N1+(Vr-5))}return Hr},Nr.getPenaltyN2=function(Ur){for(var Wr=Ur.size,Hr=0,qr=0;qr=10&&(qr===1488||qr===93)&&Hr++,Vr=Vr<<1&2047|Ur.get(Cn,Gr),Cn>=10&&(Vr===1488||Vr===93)&&Hr++}return Hr*$r.N3},Nr.getPenaltyN4=function(Ur){for(var Wr=0,Hr=Ur.data.length,qr=0;qr=0;){for(var qr=Hr[0],Vr=0;Vr=iu)return Sn;var Su=ao-Kv(Mo);if(Su<1)return Mo;var zu=bu?Zy(bu,0,Su).join(""):Sn.slice(0,Su);if(zl===jr)return zu+Mo;if(bu&&(Su+=zu.length-Su),E_(zl)){if(Sn.slice(Su).search(zl)){var Yu,Xu=zu;for(zl.global||(zl=Fw(zl.source,I0(m0.exec(zl))+"g")),zl.lastIndex=0;Yu=zl.exec(Xu);)var tp=Yu.index;zu=zu.slice(0,tp===jr?Su:tp)}}else if(Sn.indexOf(tm(zl),Su)!=Su){var wp=zu.lastIndexOf(zl);wp>-1&&(zu=zu.slice(0,wp))}return zu+Mo}function TS(Sn){return Sn=I0(Sn),Sn&&Ep.test(Sn)?Sn.replace(op,iE):Sn}var NS=e2(function(Sn,An,ao){return Sn+(ao?" ":"")+An.toUpperCase()}),C_=T$("toUpperCase");function k3(Sn,An,ao){return Sn=I0(Sn),An=ao?jr:An,An===jr?Z3(Sn)?aE(Sn):z3(Sn):Sn.match(An)||[]}var I3=b0(function(Sn,An){try{return Y0(Sn,jr,An)}catch(ao){return $_(ao)?ao:new f0(ao)}}),PS=wy(function(Sn,An){return dm(An,function(ao){ao=ty(ao),vy(Sn,ao,w_(Sn[ao],Sn))}),Sn});function OS(Sn){var An=Sn==null?0:Sn.length,ao=l0();return Sn=An?F0(Sn,function(Mo){if(typeof Mo[1]!="function")throw new fm(Hr);return[ao(Mo[0]),Mo[1]]}):[],b0(function(Mo){for(var zl=-1;++zlVo)return[];var ao=Lo,Mo=p1(Sn,Lo);An=l0(An),Sn-=Lo;for(var zl=Mw(Mo,An);++ao0||An<0)?new $0(ao):(Sn<0?ao=ao.takeRight(-Sn):Sn&&(ao=ao.drop(Sn)),An!==jr&&(An=y0(An),ao=An<0?ao.dropRight(-An):ao.take(An-Sn)),ao)},$0.prototype.takeRightWhile=function(Sn){return this.reverse().takeWhile(Sn).reverse()},$0.prototype.toArray=function(){return this.take(Lo)},Zm($0.prototype,function(Sn,An){var ao=/^(?:filter|find|map|reject)|While$/.test(An),Mo=/^(?:head|last)$/.test(An),zl=Zl[Mo?"take"+(An=="last"?"Right":""):An],iu=Mo||/^find/.test(An);zl&&(Zl.prototype[An]=function(){var bu=this.__wrapped__,Su=Mo?[1]:arguments,zu=bu instanceof $0,Yu=Su[0],Xu=zu||p0(bu),tp=function(_0){var x0=zl.apply(Zl,Hy([_0],Su));return Mo&&wp?x0[0]:x0};Xu&&ao&&typeof Yu=="function"&&Yu.length!=1&&(zu=Xu=!1);var wp=this.__chain__,t0=!!this.__actions__.length,u0=iu&&!wp,v0=zu&&!t0;if(!iu&&Xu){bu=v0?bu:new $0(this);var d0=Sn.apply(bu,Su);return d0.__actions__.push({func:mw,args:[tp],thisArg:jr}),new pm(d0,wp)}return u0&&v0?Sn.apply(this,Su):(d0=this.thru(tp),u0?Mo?d0.value()[0]:d0.value():d0)})}),dm(["pop","push","shift","sort","splice","unshift"],function(Sn){var An=W2[Sn],ao=/^(?:push|sort|unshift)$/.test(Sn)?"tap":"thru",Mo=/^(?:pop|shift)$/.test(Sn);Zl.prototype[Sn]=function(){var zl=arguments;if(Mo&&!this.__chain__){var iu=this.value();return An.apply(p0(iu)?iu:[],zl)}return this[ao](function(bu){return An.apply(p0(bu)?bu:[],zl)})}}),Zm($0.prototype,function(Sn,An){var ao=Zl[An];if(ao){var Mo=ao.name+"";T0.call(Xv,Mo)||(Xv[Mo]=[]),Xv[Mo].push({name:An,func:ao})}}),Xv[cw(jr,so).name]=[{name:"wrapper",func:jr}],$0.prototype.clone=kE,$0.prototype.reverse=IE,$0.prototype.value=TE,Zl.prototype.at=l5,Zl.prototype.chain=c5,Zl.prototype.commit=u5,Zl.prototype.next=d5,Zl.prototype.plant=h5,Zl.prototype.reverse=p5,Zl.prototype.toJSON=Zl.prototype.valueOf=Zl.prototype.value=g5,Zl.prototype.first=Zl.prototype.head,c2&&(Zl.prototype[c2]=f5),Zl},Jv=lE();z0?((z0.exports=Jv)._=Jv,j0._=Jv):E0._=Jv}).call(ge$1)})(Ui$1,Ui$1.exports);var qg$1=Object.defineProperty,Bg$1=Object.defineProperties,Gg$1=Object.getOwnPropertyDescriptors,Ea=Object.getOwnPropertySymbols,zg$1=Object.prototype.hasOwnProperty,Kg$1=Object.prototype.propertyIsEnumerable,ya=(Nr,$r,jr)=>$r in Nr?qg$1(Nr,$r,{enumerable:!0,configurable:!0,writable:!0,value:jr}):Nr[$r]=jr,cr=(Nr,$r)=>{for(var jr in $r||($r={}))zg$1.call($r,jr)&&ya(Nr,jr,$r[jr]);if(Ea)for(var jr of Ea($r))Kg$1.call($r,jr)&&ya(Nr,jr,$r[jr]);return Nr},Yg$1=(Nr,$r)=>Bg$1(Nr,Gg$1($r));function ft(Nr,$r,jr){var Lr;const Ur=ve$1(Nr);return((Lr=$r.rpcMap)==null?void 0:Lr[Ur.reference])||`${Mg}?chainId=${Ur.namespace}:${Ur.reference}&projectId=${jr}`}function Ct(Nr){return Nr.includes(":")?Nr.split(":")[1]:Nr}function Sa$1(Nr){return Nr.map($r=>`${$r.split(":")[0]}:${$r.split(":")[1]}`)}function Zg$1(Nr,$r){const jr=Object.keys($r.namespaces).filter(Ur=>Ur.includes(Nr));if(!jr.length)return[];const Lr=[];return jr.forEach(Ur=>{const Wr=$r.namespaces[Ur].accounts;Lr.push(...Wr)}),Lr}function Jg(Nr={},$r={}){const jr=Oa(Nr),Lr=Oa($r);return Ui$1.exports.merge(jr,Lr)}function Oa(Nr){var $r,jr,Lr,Ur;const Wr={};if(!B$3(Nr))return Wr;for(const[Hr,qr]of Object.entries(Nr)){const Vr=oe$3(Hr)?[Hr]:qr.chains,Gr=qr.methods||[],Cn=qr.events||[],In=qr.rpcMap||{},Gn=Xe$1(Hr);Wr[Gn]=Yg$1(cr(cr({},Wr[Gn]),qr),{chains:S$4(Vr,($r=Wr[Gn])==null?void 0:$r.chains),methods:S$4(Gr,(jr=Wr[Gn])==null?void 0:jr.methods),events:S$4(Cn,(Lr=Wr[Gn])==null?void 0:Lr.events),rpcMap:cr(cr({},In),(Ur=Wr[Gn])==null?void 0:Ur.rpcMap)})}return Wr}function Xg$1(Nr){return Nr.includes(":")?Nr.split(":")[2]:Nr}function Qg$1(Nr){const $r={};for(const[jr,Lr]of Object.entries(Nr)){const Ur=Lr.methods||[],Wr=Lr.events||[],Hr=Lr.accounts||[],qr=oe$3(jr)?[jr]:Lr.chains?Lr.chains:Sa$1(Lr.accounts);$r[jr]={chains:qr,methods:Ur,events:Wr,accounts:Hr}}return $r}function Wi$1(Nr){return typeof Nr=="number"?Nr:Nr.includes("0x")?parseInt(Nr,16):Nr.includes(":")?Number(Nr.split(":")[1]):Number(Nr)}const Ra={},z$5=Nr=>Ra[Nr],Fi$1=(Nr,$r)=>{Ra[Nr]=$r};class Vg{constructor($r){this.name="polkadot",this.namespace=$r.namespace,this.events=z$5("events"),this.client=z$5("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace($r){this.namespace=Object.assign(this.namespace,$r)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const $r=this.namespace.chains[0];if(!$r)throw new Error("ChainId not found");return $r.split(":")[1]}request($r){return this.namespace.methods.includes($r.request.method)?this.client.request($r):this.getHttpProvider().request($r.request)}setDefaultChain($r,jr){this.httpProviders[$r]||this.setHttpProvider($r,jr),this.chainId=$r,this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${$r}`)}getAccounts(){const $r=this.namespace.accounts;return $r?$r.filter(jr=>jr.split(":")[1]===this.chainId.toString()).map(jr=>jr.split(":")[2])||[]:[]}createHttpProviders(){const $r={};return this.namespace.chains.forEach(jr=>{var Lr;const Ur=Ct(jr);$r[Ur]=this.createHttpProvider(Ur,(Lr=this.namespace.rpcMap)==null?void 0:Lr[jr])}),$r}getHttpProvider(){const $r=`${this.name}:${this.chainId}`,jr=this.httpProviders[$r];if(typeof jr>"u")throw new Error(`JSON-RPC provider for ${$r} not found`);return jr}setHttpProvider($r,jr){const Lr=this.createHttpProvider($r,jr);Lr&&(this.httpProviders[$r]=Lr)}createHttpProvider($r,jr){const Lr=jr||ft($r,this.namespace,this.client.core.projectId);if(!Lr)throw new Error(`No RPC url provided for chainId: ${$r}`);return new JsonRpcProvider(new HttpConnection(Lr,z$5("disableProviderPing")))}}let kg$1=class{constructor($r){this.name="eip155",this.namespace=$r.namespace,this.events=z$5("events"),this.client=z$5("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request($r){switch($r.request.method){case"eth_requestAccounts":return this.getAccounts();case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain($r);case"eth_chainId":return parseInt(this.getDefaultChain())}return this.namespace.methods.includes($r.request.method)?await this.client.request($r):this.getHttpProvider().request($r.request)}updateNamespace($r){this.namespace=Object.assign(this.namespace,$r)}setDefaultChain($r,jr){this.httpProviders[$r]||this.setHttpProvider(parseInt($r),jr),this.chainId=parseInt($r),this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${$r}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const $r=this.namespace.chains[0];if(!$r)throw new Error("ChainId not found");return $r.split(":")[1]}createHttpProvider($r,jr){const Lr=jr||ft(`${this.name}:${$r}`,this.namespace,this.client.core.projectId);if(!Lr)throw new Error(`No RPC url provided for chainId: ${$r}`);return new JsonRpcProvider(new HttpConnection(Lr,z$5("disableProviderPing")))}setHttpProvider($r,jr){const Lr=this.createHttpProvider($r,jr);Lr&&(this.httpProviders[$r]=Lr)}createHttpProviders(){const $r={};return this.namespace.chains.forEach(jr=>{var Lr;const Ur=parseInt(Ct(jr));$r[Ur]=this.createHttpProvider(Ur,(Lr=this.namespace.rpcMap)==null?void 0:Lr[jr])}),$r}getAccounts(){const $r=this.namespace.accounts;return $r?[...new Set($r.filter(jr=>jr.split(":")[1]===this.chainId.toString()).map(jr=>jr.split(":")[2]))]:[]}getHttpProvider(){const $r=this.chainId,jr=this.httpProviders[$r];if(typeof jr>"u")throw new Error(`JSON-RPC provider for ${$r} not found`);return jr}async handleSwitchChain($r){var jr,Lr;let Ur=$r.request.params?(jr=$r.request.params[0])==null?void 0:jr.chainId:"0x0";Ur=Ur.startsWith("0x")?Ur:`0x${Ur}`;const Wr=parseInt(Ur,16);if(this.isChainApproved(Wr))this.setDefaultChain(`${Wr}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:$r.topic,request:{method:$r.request.method,params:[{chainId:Ur}]},chainId:(Lr=this.namespace.chains)==null?void 0:Lr[0]}),this.setDefaultChain(`${Wr}`);else throw new Error(`Failed to switch to chain 'eip155:${Wr}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved($r){return this.namespace.chains.includes(`${this.name}:${$r}`)}};class jg{constructor($r){this.name="solana",this.namespace=$r.namespace,this.events=z$5("events"),this.client=z$5("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace($r){this.namespace=Object.assign(this.namespace,$r)}requestAccounts(){return this.getAccounts()}request($r){return this.namespace.methods.includes($r.request.method)?this.client.request($r):this.getHttpProvider().request($r.request)}setDefaultChain($r,jr){this.httpProviders[$r]||this.setHttpProvider($r,jr),this.chainId=$r,this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${$r}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const $r=this.namespace.chains[0];if(!$r)throw new Error("ChainId not found");return $r.split(":")[1]}getAccounts(){const $r=this.namespace.accounts;return $r?[...new Set($r.filter(jr=>jr.split(":")[1]===this.chainId.toString()).map(jr=>jr.split(":")[2]))]:[]}createHttpProviders(){const $r={};return this.namespace.chains.forEach(jr=>{var Lr;const Ur=Ct(jr);$r[Ur]=this.createHttpProvider(Ur,(Lr=this.namespace.rpcMap)==null?void 0:Lr[jr])}),$r}getHttpProvider(){const $r=`${this.name}:${this.chainId}`,jr=this.httpProviders[$r];if(typeof jr>"u")throw new Error(`JSON-RPC provider for ${$r} not found`);return jr}setHttpProvider($r,jr){const Lr=this.createHttpProvider($r,jr);Lr&&(this.httpProviders[$r]=Lr)}createHttpProvider($r,jr){const Lr=jr||ft($r,this.namespace,this.client.core.projectId);if(!Lr)throw new Error(`No RPC url provided for chainId: ${$r}`);return new JsonRpcProvider(new HttpConnection(Lr,z$5("disableProviderPing")))}}let nv$1=class{constructor($r){this.name="cosmos",this.namespace=$r.namespace,this.events=z$5("events"),this.client=z$5("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace($r){this.namespace=Object.assign(this.namespace,$r)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const $r=this.namespace.chains[0];if(!$r)throw new Error("ChainId not found");return $r.split(":")[1]}request($r){return this.namespace.methods.includes($r.request.method)?this.client.request($r):this.getHttpProvider().request($r.request)}setDefaultChain($r,jr){this.httpProviders[$r]||this.setHttpProvider($r,jr),this.chainId=$r,this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const $r=this.namespace.accounts;return $r?[...new Set($r.filter(jr=>jr.split(":")[1]===this.chainId.toString()).map(jr=>jr.split(":")[2]))]:[]}createHttpProviders(){const $r={};return this.namespace.chains.forEach(jr=>{var Lr;const Ur=Ct(jr);$r[Ur]=this.createHttpProvider(Ur,(Lr=this.namespace.rpcMap)==null?void 0:Lr[jr])}),$r}getHttpProvider(){const $r=`${this.name}:${this.chainId}`,jr=this.httpProviders[$r];if(typeof jr>"u")throw new Error(`JSON-RPC provider for ${$r} not found`);return jr}setHttpProvider($r,jr){const Lr=this.createHttpProvider($r,jr);Lr&&(this.httpProviders[$r]=Lr)}createHttpProvider($r,jr){const Lr=jr||ft($r,this.namespace,this.client.core.projectId);if(!Lr)throw new Error(`No RPC url provided for chainId: ${$r}`);return new JsonRpcProvider(new HttpConnection(Lr,z$5("disableProviderPing")))}},tv$1=class{constructor($r){this.name="cip34",this.namespace=$r.namespace,this.events=z$5("events"),this.client=z$5("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace($r){this.namespace=Object.assign(this.namespace,$r)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const $r=this.namespace.chains[0];if(!$r)throw new Error("ChainId not found");return $r.split(":")[1]}request($r){return this.namespace.methods.includes($r.request.method)?this.client.request($r):this.getHttpProvider().request($r.request)}setDefaultChain($r,jr){this.httpProviders[$r]||this.setHttpProvider($r,jr),this.chainId=$r,this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const $r=this.namespace.accounts;return $r?[...new Set($r.filter(jr=>jr.split(":")[1]===this.chainId.toString()).map(jr=>jr.split(":")[2]))]:[]}createHttpProviders(){const $r={};return this.namespace.chains.forEach(jr=>{const Lr=this.getCardanoRPCUrl(jr),Ur=Ct(jr);$r[Ur]=this.createHttpProvider(Ur,Lr)}),$r}getHttpProvider(){const $r=`${this.name}:${this.chainId}`,jr=this.httpProviders[$r];if(typeof jr>"u")throw new Error(`JSON-RPC provider for ${$r} not found`);return jr}getCardanoRPCUrl($r){const jr=this.namespace.rpcMap;if(jr)return jr[$r]}setHttpProvider($r,jr){const Lr=this.createHttpProvider($r,jr);Lr&&(this.httpProviders[$r]=Lr)}createHttpProvider($r,jr){const Lr=jr||this.getCardanoRPCUrl($r);if(!Lr)throw new Error(`No RPC url provided for chainId: ${$r}`);return new JsonRpcProvider(new HttpConnection(Lr,z$5("disableProviderPing")))}},ev$1=class{constructor($r){this.name="elrond",this.namespace=$r.namespace,this.events=z$5("events"),this.client=z$5("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace($r){this.namespace=Object.assign(this.namespace,$r)}requestAccounts(){return this.getAccounts()}request($r){return this.namespace.methods.includes($r.request.method)?this.client.request($r):this.getHttpProvider().request($r.request)}setDefaultChain($r,jr){this.httpProviders[$r]||this.setHttpProvider($r,jr),this.chainId=$r,this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${$r}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const $r=this.namespace.chains[0];if(!$r)throw new Error("ChainId not found");return $r.split(":")[1]}getAccounts(){const $r=this.namespace.accounts;return $r?[...new Set($r.filter(jr=>jr.split(":")[1]===this.chainId.toString()).map(jr=>jr.split(":")[2]))]:[]}createHttpProviders(){const $r={};return this.namespace.chains.forEach(jr=>{var Lr;const Ur=Ct(jr);$r[Ur]=this.createHttpProvider(Ur,(Lr=this.namespace.rpcMap)==null?void 0:Lr[jr])}),$r}getHttpProvider(){const $r=`${this.name}:${this.chainId}`,jr=this.httpProviders[$r];if(typeof jr>"u")throw new Error(`JSON-RPC provider for ${$r} not found`);return jr}setHttpProvider($r,jr){const Lr=this.createHttpProvider($r,jr);Lr&&(this.httpProviders[$r]=Lr)}createHttpProvider($r,jr){const Lr=jr||ft($r,this.namespace,this.client.core.projectId);if(!Lr)throw new Error(`No RPC url provided for chainId: ${$r}`);return new JsonRpcProvider(new HttpConnection(Lr,z$5("disableProviderPing")))}},rv$1=class{constructor($r){this.name="multiversx",this.namespace=$r.namespace,this.events=z$5("events"),this.client=z$5("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace($r){this.namespace=Object.assign(this.namespace,$r)}requestAccounts(){return this.getAccounts()}request($r){return this.namespace.methods.includes($r.request.method)?this.client.request($r):this.getHttpProvider().request($r.request)}setDefaultChain($r,jr){this.httpProviders[$r]||this.setHttpProvider($r,jr),this.chainId=$r,this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${$r}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const $r=this.namespace.chains[0];if(!$r)throw new Error("ChainId not found");return $r.split(":")[1]}getAccounts(){const $r=this.namespace.accounts;return $r?[...new Set($r.filter(jr=>jr.split(":")[1]===this.chainId.toString()).map(jr=>jr.split(":")[2]))]:[]}createHttpProviders(){const $r={};return this.namespace.chains.forEach(jr=>{var Lr;const Ur=Ct(jr);$r[Ur]=this.createHttpProvider(Ur,(Lr=this.namespace.rpcMap)==null?void 0:Lr[jr])}),$r}getHttpProvider(){const $r=`${this.name}:${this.chainId}`,jr=this.httpProviders[$r];if(typeof jr>"u")throw new Error(`JSON-RPC provider for ${$r} not found`);return jr}setHttpProvider($r,jr){const Lr=this.createHttpProvider($r,jr);Lr&&(this.httpProviders[$r]=Lr)}createHttpProvider($r,jr){const Lr=jr||ft($r,this.namespace,this.client.core.projectId);if(!Lr)throw new Error(`No RPC url provided for chainId: ${$r}`);return new JsonRpcProvider(new HttpConnection(Lr,z$5("disableProviderPing")))}};class iv{constructor($r){this.name="near",this.namespace=$r.namespace,this.events=z$5("events"),this.client=z$5("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace($r){this.namespace=Object.assign(this.namespace,$r)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const $r=this.namespace.chains[0];if(!$r)throw new Error("ChainId not found");return $r.split(":")[1]}request($r){return this.namespace.methods.includes($r.request.method)?this.client.request($r):this.getHttpProvider().request($r.request)}setDefaultChain($r,jr){if(this.chainId=$r,!this.httpProviders[$r]){const Lr=jr||ft(`${this.name}:${$r}`,this.namespace);if(!Lr)throw new Error(`No RPC url provided for chainId: ${$r}`);this.setHttpProvider($r,Lr)}this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const $r=this.namespace.accounts;return $r?$r.filter(jr=>jr.split(":")[1]===this.chainId.toString()).map(jr=>jr.split(":")[2])||[]:[]}createHttpProviders(){const $r={};return this.namespace.chains.forEach(jr=>{var Lr;$r[jr]=this.createHttpProvider(jr,(Lr=this.namespace.rpcMap)==null?void 0:Lr[jr])}),$r}getHttpProvider(){const $r=`${this.name}:${this.chainId}`,jr=this.httpProviders[$r];if(typeof jr>"u")throw new Error(`JSON-RPC provider for ${$r} not found`);return jr}setHttpProvider($r,jr){const Lr=this.createHttpProvider($r,jr);Lr&&(this.httpProviders[$r]=Lr)}createHttpProvider($r,jr){const Lr=jr||ft($r,this.namespace);return typeof Lr>"u"?void 0:new JsonRpcProvider(new HttpConnection(Lr,z$5("disableProviderPing")))}}var sv$1=Object.defineProperty,uv$1=Object.defineProperties,av=Object.getOwnPropertyDescriptors,ba$1=Object.getOwnPropertySymbols,ov$1=Object.prototype.hasOwnProperty,fv=Object.prototype.propertyIsEnumerable,Ta$1=(Nr,$r,jr)=>$r in Nr?sv$1(Nr,$r,{enumerable:!0,configurable:!0,writable:!0,value:jr}):Nr[$r]=jr,hr=(Nr,$r)=>{for(var jr in $r||($r={}))ov$1.call($r,jr)&&Ta$1(Nr,jr,$r[jr]);if(ba$1)for(var jr of ba$1($r))fv.call($r,jr)&&Ta$1(Nr,jr,$r[jr]);return Nr},Mi$1=(Nr,$r)=>uv$1(Nr,av($r));class lr{constructor($r){this.events=new $g,this.rpcProviders={},this.shouldAbortPairingAttempt=!1,this.maxPairingAttempts=10,this.disableProviderPing=!1,this.providerOpts=$r,this.logger=typeof($r==null?void 0:$r.logger)<"u"&&typeof($r==null?void 0:$r.logger)!="string"?$r.logger:cjs$4.pino(cjs$4.getDefaultLoggerOptions({level:($r==null?void 0:$r.logger)||Ia})),this.disableProviderPing=($r==null?void 0:$r.disableProviderPing)||!1}static async init($r){const jr=new lr($r);return await jr.initialize(),jr}async request($r,jr){const[Lr,Ur]=this.validateChain(jr);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(Lr).request({request:hr({},$r),chainId:`${Lr}:${Ur}`,topic:this.session.topic})}sendAsync($r,jr,Lr){this.request($r,Lr).then(Ur=>jr(null,Ur)).catch(Ur=>jr(Ur,void 0))}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties}),await this.requestAccounts()}async disconnect(){var $r;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:($r=this.session)==null?void 0:$r.topic,reason:U$4("USER_DISCONNECTED")}),await this.cleanup()}async connect($r){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces($r),await this.cleanupPendingPairings(),!$r.skipPairing)return await this.pair($r.pairingTopic)}on($r,jr){this.events.on($r,jr)}once($r,jr){this.events.once($r,jr)}removeListener($r,jr){this.events.removeListener($r,jr)}off($r,jr){this.events.off($r,jr)}get isWalletConnect(){return!0}async pair($r){this.shouldAbortPairingAttempt=!1;let jr=0;do{if(this.shouldAbortPairingAttempt)throw new Error("Pairing aborted");if(jr>=this.maxPairingAttempts)throw new Error("Max auto pairing attempts reached");const{uri:Lr,approval:Ur}=await this.client.connect({pairingTopic:$r,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties});Lr&&(this.uri=Lr,this.events.emit("display_uri",Lr)),await Ur().then(Wr=>{this.session=Wr,this.namespaces||(this.namespaces=Qg$1(Wr.namespaces),this.persist("namespaces",this.namespaces))}).catch(Wr=>{if(Wr.message!==oe$1)throw Wr;jr++})}while(!this.session);return this.onConnect(),this.session}setDefaultChain($r,jr){try{if(!this.session)return;const[Lr,Ur]=this.validateChain($r);this.getProvider(Lr).setDefaultChain(Ur,jr)}catch(Lr){if(!/Please call connect/.test(Lr.message))throw Lr}}async cleanupPendingPairings($r={}){this.logger.info("Cleaning up inactive pairings...");const jr=this.client.pairing.getAll();if(D$5(jr)){for(const Lr of jr)$r.deletePairings?this.client.core.expirer.set(Lr.topic,0):await this.client.core.relayer.subscriber.unsubscribe(Lr.topic);this.logger.info(`Inactive pairings cleared: ${jr.length}`)}}abortPairingAttempt(){this.shouldAbortPairingAttempt=!0}async checkStorage(){if(this.namespaces=await this.getFromStore("namespaces"),this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.client.session.length){const $r=this.client.session.keys.length-1;this.session=this.client.session.get(this.client.session.keys[$r]),this.createProviders()}}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){this.client=this.providerOpts.client||await Q$3.init({logger:this.providerOpts.logger||Ia,relayUrl:this.providerOpts.relayUrl||Ug$1,projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name}),this.logger.trace("SignClient Initialized")}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const $r=[...new Set(Object.keys(this.session.namespaces).map(jr=>Xe$1(jr)))];Fi$1("client",this.client),Fi$1("events",this.events),Fi$1("disableProviderPing",this.disableProviderPing),$r.forEach(jr=>{if(!this.session)return;const Lr=Zg$1(jr,this.session),Ur=Sa$1(Lr),Wr=Jg(this.namespaces,this.optionalNamespaces),Hr=Mi$1(hr({},Wr[jr]),{accounts:Lr,chains:Ur});switch(jr){case"eip155":this.rpcProviders[jr]=new kg$1({namespace:Hr});break;case"solana":this.rpcProviders[jr]=new jg({namespace:Hr});break;case"cosmos":this.rpcProviders[jr]=new nv$1({namespace:Hr});break;case"polkadot":this.rpcProviders[jr]=new Vg({namespace:Hr});break;case"cip34":this.rpcProviders[jr]=new tv$1({namespace:Hr});break;case"elrond":this.rpcProviders[jr]=new ev$1({namespace:Hr});break;case"multiversx":this.rpcProviders[jr]=new rv$1({namespace:Hr});break;case"near":this.rpcProviders[jr]=new iv({namespace:Hr});break}})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",$r=>{this.events.emit("session_ping",$r)}),this.client.on("session_event",$r=>{const{params:jr}=$r,{event:Lr}=jr;if(Lr.name==="accountsChanged"){const Ur=Lr.data;Ur&&D$5(Ur)&&this.events.emit("accountsChanged",Ur.map(Xg$1))}else if(Lr.name==="chainChanged"){const Ur=jr.chainId,Wr=jr.event.data,Hr=Xe$1(Ur),qr=Wi$1(Ur)!==Wi$1(Wr)?`${Hr}:${Wi$1(Wr)}`:Ur;this.onChainChanged(qr)}else this.events.emit(Lr.name,Lr.data);this.events.emit("session_event",$r)}),this.client.on("session_update",({topic:$r,params:jr})=>{var Lr;const{namespaces:Ur}=jr,Wr=(Lr=this.client)==null?void 0:Lr.session.get($r);this.session=Mi$1(hr({},Wr),{namespaces:Ur}),this.onSessionUpdate(),this.events.emit("session_update",{topic:$r,params:jr})}),this.client.on("session_delete",async $r=>{await this.cleanup(),this.events.emit("session_delete",$r),this.events.emit("disconnect",Mi$1(hr({},U$4("USER_DISCONNECTED")),{data:$r.topic}))}),this.on(Vn.DEFAULT_CHAIN_CHANGED,$r=>{this.onChainChanged($r,!0)})}getProvider($r){if(!this.rpcProviders[$r])throw new Error(`Provider not found: ${$r}`);return this.rpcProviders[$r]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach($r=>{var jr;this.getProvider($r).updateNamespace((jr=this.session)==null?void 0:jr.namespaces[$r])})}setNamespaces($r){const{namespaces:jr,optionalNamespaces:Lr,sessionProperties:Ur}=$r;jr&&Object.keys(jr).length&&(this.namespaces=jr),Lr&&Object.keys(Lr).length&&(this.optionalNamespaces=Lr),this.sessionProperties=Ur,this.persist("namespaces",jr),this.persist("optionalNamespaces",Lr)}validateChain($r){const[jr,Lr]=($r==null?void 0:$r.split(":"))||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[jr,Lr];if(jr&&!Object.keys(this.namespaces||{}).map(Hr=>Xe$1(Hr)).includes(jr))throw new Error(`Namespace '${jr}' is not configured. Please call connect() first with namespace config.`);if(jr&&Lr)return[jr,Lr];const Ur=Xe$1(Object.keys(this.namespaces)[0]),Wr=this.rpcProviders[Ur].getDefaultChain();return[Ur,Wr]}async requestAccounts(){const[$r]=this.validateChain();return await this.getProvider($r).requestAccounts()}onChainChanged($r,jr=!1){var Lr;if(!this.namespaces)return;const[Ur,Wr]=this.validateChain($r);jr||this.getProvider(Ur).setDefaultChain(Wr),((Lr=this.namespaces[Ur])!=null?Lr:this.namespaces[`${Ur}:${Wr}`]).defaultChain=Wr,this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",Wr)}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.session=void 0,this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,this.persist("namespaces",void 0),this.persist("optionalNamespaces",void 0),this.persist("sessionProperties",void 0),await this.cleanupPendingPairings({deletePairings:!0})}persist($r,jr){this.client.core.storage.setItem(`${xa$1}/${$r}`,jr)}async getFromStore($r){return await this.client.core.storage.getItem(`${xa$1}/${$r}`)}}const cv=lr,P$4="wc",S$2="ethereum_provider",$$4=`${P$4}@2:${S$2}:`,j$3="https://rpc.walletconnect.com/v1/",u$3=["eth_sendTransaction","personal_sign"],E$4=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode"],m$5=["chainChanged","accountsChanged"],_$5=["chainChanged","accountsChanged","message","disconnect","connect"];var N$3=Object.defineProperty,q$5=Object.defineProperties,D$3=Object.getOwnPropertyDescriptors,y$4=Object.getOwnPropertySymbols,U$2=Object.prototype.hasOwnProperty,Q$2=Object.prototype.propertyIsEnumerable,O$2=(Nr,$r,jr)=>$r in Nr?N$3(Nr,$r,{enumerable:!0,configurable:!0,writable:!0,value:jr}):Nr[$r]=jr,p$4=(Nr,$r)=>{for(var jr in $r||($r={}))U$2.call($r,jr)&&O$2(Nr,jr,$r[jr]);if(y$4)for(var jr of y$4($r))Q$2.call($r,jr)&&O$2(Nr,jr,$r[jr]);return Nr},M$3=(Nr,$r)=>q$5(Nr,D$3($r));function g$5(Nr){return Number(Nr[0].split(":")[1])}function f$4(Nr){return`0x${Nr.toString(16)}`}function L$3(Nr){const{chains:$r,optionalChains:jr,methods:Lr,optionalMethods:Ur,events:Wr,optionalEvents:Hr,rpcMap:qr}=Nr;if(!D$5($r))throw new Error("Invalid chains");const Vr={chains:$r,methods:Lr||u$3,events:Wr||m$5,rpcMap:p$4({},$r.length?{[g$5($r)]:qr[g$5($r)]}:{})},Gr=Wr==null?void 0:Wr.filter(Zn=>!m$5.includes(Zn)),Cn=Lr==null?void 0:Lr.filter(Zn=>!u$3.includes(Zn));if(!jr&&!Hr&&!Ur&&!(Gr!=null&&Gr.length)&&!(Cn!=null&&Cn.length))return{required:$r.length?Vr:void 0};const In=(Gr==null?void 0:Gr.length)&&(Cn==null?void 0:Cn.length)||!jr,Gn={chains:[...new Set(In?Vr.chains.concat(jr||[]):jr)],methods:[...new Set(Vr.methods.concat(Ur!=null&&Ur.length?Ur:E$4))],events:[...new Set(Vr.events.concat(Hr!=null&&Hr.length?Hr:_$5))],rpcMap:qr};return{required:$r.length?Vr:void 0,optional:jr.length?Gn:void 0}}let v$6=class L3{constructor(){this.events=new eventsExports.EventEmitter,this.namespace="eip155",this.accounts=[],this.chainId=1,this.STORAGE_KEY=$$4,this.on=($r,jr)=>(this.events.on($r,jr),this),this.once=($r,jr)=>(this.events.once($r,jr),this),this.removeListener=($r,jr)=>(this.events.removeListener($r,jr),this),this.off=($r,jr)=>(this.events.off($r,jr),this),this.parseAccount=$r=>this.isCompatibleChainId($r)?this.parseAccountId($r).address:$r,this.signer={},this.rpc={}}static async init($r){const jr=new L3;return await jr.initialize($r),jr}async request($r){return await this.signer.request($r,this.formatChainId(this.chainId))}sendAsync($r,jr){this.signer.sendAsync($r,jr,this.formatChainId(this.chainId))}get connected(){return this.signer.client?this.signer.client.core.relayer.connected:!1}get connecting(){return this.signer.client?this.signer.client.core.relayer.connecting:!1}async enable(){return this.session||await this.connect(),await this.request({method:"eth_requestAccounts"})}async connect($r){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts($r);const{required:jr,optional:Lr}=L$3(this.rpc);try{const Ur=await new Promise(async(Hr,qr)=>{var Vr;this.rpc.showQrModal&&((Vr=this.modal)==null||Vr.subscribeModal(Gr=>{!Gr.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),qr(new Error("Connection request reset. Please try again.")))})),await this.signer.connect(M$3(p$4({namespaces:p$4({},jr&&{[this.namespace]:jr})},Lr&&{optionalNamespaces:{[this.namespace]:Lr}}),{pairingTopic:$r==null?void 0:$r.pairingTopic})).then(Gr=>{Hr(Gr)}).catch(Gr=>{qr(new Error(Gr.message))})});if(!Ur)return;const Wr=Rn$1(Ur.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:Wr),this.setAccounts(Wr),this.events.emit("connect",{chainId:f$4(this.chainId)})}catch(Ur){throw this.signer.logger.error(Ur),Ur}finally{this.modal&&this.modal.closeModal()}}async disconnect(){this.session&&await this.signer.disconnect(),this.reset()}get isWalletConnect(){return!0}get session(){return this.signer.session}registerEventListeners(){this.signer.on("session_event",$r=>{const{params:jr}=$r,{event:Lr}=jr;Lr.name==="accountsChanged"?(this.accounts=this.parseAccounts(Lr.data),this.events.emit("accountsChanged",this.accounts)):Lr.name==="chainChanged"?this.setChainId(this.formatChainId(Lr.data)):this.events.emit(Lr.name,Lr.data),this.events.emit("session_event",$r)}),this.signer.on("chainChanged",$r=>{const jr=parseInt($r);this.chainId=jr,this.events.emit("chainChanged",f$4(this.chainId)),this.persist()}),this.signer.on("session_update",$r=>{this.events.emit("session_update",$r)}),this.signer.on("session_delete",$r=>{this.reset(),this.events.emit("session_delete",$r),this.events.emit("disconnect",M$3(p$4({},U$4("USER_DISCONNECTED")),{data:$r.topic,name:"USER_DISCONNECTED"}))}),this.signer.on("display_uri",$r=>{var jr,Lr;this.rpc.showQrModal&&((jr=this.modal)==null||jr.closeModal(),(Lr=this.modal)==null||Lr.openModal({uri:$r})),this.events.emit("display_uri",$r)})}switchEthereumChain($r){this.request({method:"wallet_switchEthereumChain",params:[{chainId:$r.toString(16)}]})}isCompatibleChainId($r){return typeof $r=="string"?$r.startsWith(`${this.namespace}:`):!1}formatChainId($r){return`${this.namespace}:${$r}`}parseChainId($r){return Number($r.split(":")[1])}setChainIds($r){const jr=$r.filter(Lr=>this.isCompatibleChainId(Lr)).map(Lr=>this.parseChainId(Lr));jr.length&&(this.chainId=jr[0],this.events.emit("chainChanged",f$4(this.chainId)),this.persist())}setChainId($r){if(this.isCompatibleChainId($r)){const jr=this.parseChainId($r);this.chainId=jr,this.switchEthereumChain(jr)}}parseAccountId($r){const[jr,Lr,Ur]=$r.split(":");return{chainId:`${jr}:${Lr}`,address:Ur}}setAccounts($r){this.accounts=$r.filter(jr=>this.parseChainId(this.parseAccountId(jr).chainId)===this.chainId).map(jr=>this.parseAccountId(jr).address),this.events.emit("accountsChanged",this.accounts)}getRpcConfig($r){var jr,Lr;const Ur=(jr=$r==null?void 0:$r.chains)!=null?jr:[],Wr=(Lr=$r==null?void 0:$r.optionalChains)!=null?Lr:[],Hr=Ur.concat(Wr);if(!Hr.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const qr=Ur.length?($r==null?void 0:$r.methods)||u$3:[],Vr=Ur.length?($r==null?void 0:$r.events)||m$5:[],Gr=($r==null?void 0:$r.optionalMethods)||[],Cn=($r==null?void 0:$r.optionalEvents)||[],In=($r==null?void 0:$r.rpcMap)||this.buildRpcMap(Hr,$r.projectId),Gn=($r==null?void 0:$r.qrModalOptions)||void 0;return{chains:Ur==null?void 0:Ur.map(Zn=>this.formatChainId(Zn)),optionalChains:Wr.map(Zn=>this.formatChainId(Zn)),methods:qr,events:Vr,optionalMethods:Gr,optionalEvents:Cn,rpcMap:In,showQrModal:!!($r!=null&&$r.showQrModal),qrModalOptions:Gn,projectId:$r.projectId,metadata:$r.metadata}}buildRpcMap($r,jr){const Lr={};return $r.forEach(Ur=>{Lr[Ur]=this.getRpcUrl(Ur,jr)}),Lr}async initialize($r){if(this.rpc=this.getRpcConfig($r),this.chainId=this.rpc.chains.length?g$5(this.rpc.chains):g$5(this.rpc.optionalChains),this.signer=await cv.init({projectId:this.rpc.projectId,metadata:this.rpc.metadata,disableProviderPing:$r.disableProviderPing,relayUrl:$r.relayUrl,storageOptions:$r.storageOptions}),this.registerEventListeners(),await this.loadPersistedSession(),this.rpc.showQrModal){let jr;try{const{WalletConnectModal:Lr}=await __vitePreload(()=>import("./index-32d7b86e.js").then(Ur=>Ur.i),[]);jr=Lr}catch{throw new Error("To use QR modal, please install @walletconnect/modal package")}if(jr)try{this.modal=new jr(p$4({walletConnectVersion:2,projectId:this.rpc.projectId,standaloneChains:this.rpc.chains},this.rpc.qrModalOptions))}catch(Lr){throw this.signer.logger.error(Lr),new Error("Could not generate WalletConnectModal Instance")}}}loadConnectOpts($r){if(!$r)return;const{chains:jr,optionalChains:Lr,rpcMap:Ur}=$r;jr&&D$5(jr)&&(this.rpc.chains=jr.map(Wr=>this.formatChainId(Wr)),jr.forEach(Wr=>{this.rpc.rpcMap[Wr]=(Ur==null?void 0:Ur[Wr])||this.getRpcUrl(Wr)})),Lr&&D$5(Lr)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=Lr==null?void 0:Lr.map(Wr=>this.formatChainId(Wr)),Lr.forEach(Wr=>{this.rpc.rpcMap[Wr]=(Ur==null?void 0:Ur[Wr])||this.getRpcUrl(Wr)}))}getRpcUrl($r,jr){var Lr;return((Lr=this.rpc.rpcMap)==null?void 0:Lr[$r])||`${j$3}?chainId=eip155:${$r}&projectId=${jr||this.rpc.projectId}`}async loadPersistedSession(){if(!this.session)return;const $r=await this.signer.client.core.storage.getItem(`${this.STORAGE_KEY}/chainId`),jr=this.session.namespaces[`${this.namespace}:${$r}`]?this.session.namespaces[`${this.namespace}:${$r}`]:this.session.namespaces[this.namespace];this.setChainIds($r?[this.formatChainId($r)]:jr==null?void 0:jr.accounts),this.setAccounts(jr==null?void 0:jr.accounts)}reset(){this.chainId=1,this.accounts=[]}persist(){this.session&&this.signer.client.core.storage.setItem(`${this.STORAGE_KEY}/chainId`,this.chainId)}parseAccounts($r){return typeof $r=="string"||$r instanceof String?[this.parseAccount($r)]:$r.map(jr=>this.parseAccount(jr))}};const G$2=v$6;var cjs$2={},cjs$1={};Object.defineProperty(cjs$1,"__esModule",{value:!0});var getLocalStorage_1=cjs$1.getLocalStorage=getLocalStorageOrThrow_1=cjs$1.getLocalStorageOrThrow=getCrypto_1=cjs$1.getCrypto=getCryptoOrThrow_1=cjs$1.getCryptoOrThrow=getLocation_1=cjs$1.getLocation=getLocationOrThrow_1=cjs$1.getLocationOrThrow=getNavigator_1=cjs$1.getNavigator=getNavigatorOrThrow_1=cjs$1.getNavigatorOrThrow=getDocument_1=cjs$1.getDocument=getDocumentOrThrow_1=cjs$1.getDocumentOrThrow=getFromWindowOrThrow_1=cjs$1.getFromWindowOrThrow=getFromWindow_1=cjs$1.getFromWindow=void 0;function getFromWindow$1(Nr){let $r;return typeof window<"u"&&typeof window[Nr]<"u"&&($r=window[Nr]),$r}var getFromWindow_1=cjs$1.getFromWindow=getFromWindow$1;function getFromWindowOrThrow$1(Nr){const $r=getFromWindow$1(Nr);if(!$r)throw new Error(`${Nr} is not defined in Window`);return $r}var getFromWindowOrThrow_1=cjs$1.getFromWindowOrThrow=getFromWindowOrThrow$1;function getDocumentOrThrow$1(){return getFromWindowOrThrow$1("document")}var getDocumentOrThrow_1=cjs$1.getDocumentOrThrow=getDocumentOrThrow$1;function getDocument$1(){return getFromWindow$1("document")}var getDocument_1=cjs$1.getDocument=getDocument$1;function getNavigatorOrThrow$1(){return getFromWindowOrThrow$1("navigator")}var getNavigatorOrThrow_1=cjs$1.getNavigatorOrThrow=getNavigatorOrThrow$1;function getNavigator$1(){return getFromWindow$1("navigator")}var getNavigator_1=cjs$1.getNavigator=getNavigator$1;function getLocationOrThrow$1(){return getFromWindowOrThrow$1("location")}var getLocationOrThrow_1=cjs$1.getLocationOrThrow=getLocationOrThrow$1;function getLocation$1(){return getFromWindow$1("location")}var getLocation_1=cjs$1.getLocation=getLocation$1;function getCryptoOrThrow$1(){return getFromWindowOrThrow$1("crypto")}var getCryptoOrThrow_1=cjs$1.getCryptoOrThrow=getCryptoOrThrow$1;function getCrypto$1(){return getFromWindow$1("crypto")}var getCrypto_1=cjs$1.getCrypto=getCrypto$1;function getLocalStorageOrThrow$1(){return getFromWindowOrThrow$1("localStorage")}var getLocalStorageOrThrow_1=cjs$1.getLocalStorageOrThrow=getLocalStorageOrThrow$1;function getLocalStorage$1(){return getFromWindow$1("localStorage")}getLocalStorage_1=cjs$1.getLocalStorage=getLocalStorage$1;Object.defineProperty(cjs$2,"__esModule",{value:!0});var getWindowMetadata_1=cjs$2.getWindowMetadata=void 0;const window_getters_1=cjs$1;function getWindowMetadata(){let Nr,$r;try{Nr=window_getters_1.getDocumentOrThrow(),$r=window_getters_1.getLocationOrThrow()}catch{return null}function jr(){const In=Nr.getElementsByTagName("link"),Gn=[];for(let Zn=0;Zn-1){const xo=no.getAttribute("href");if(xo)if(xo.toLowerCase().indexOf("https:")===-1&&xo.toLowerCase().indexOf("http:")===-1&&xo.indexOf("//")!==0){let so=$r.protocol+"//"+$r.host;if(xo.indexOf("/")===0)so+=xo;else{const io=$r.pathname.split("/");io.pop();const lo=io.join("/");so+=lo+"/"+xo}Gn.push(so)}else if(xo.indexOf("//")===0){const so=$r.protocol+xo;Gn.push(so)}else Gn.push(xo)}}return Gn}function Lr(...In){const Gn=Nr.getElementsByTagName("meta");for(let Zn=0;Znno.getAttribute(xo)).filter(xo=>xo?In.includes(xo):!1);if(ho.length&&ho){const xo=no.getAttribute("content");if(xo)return xo}}return""}function Ur(){let In=Lr("name","og:site_name","og:title","twitter:title");return In||(In=Nr.title),In}function Wr(){return Lr("description","og:description","twitter:description","keywords")}const Hr=Ur(),qr=Wr(),Vr=$r.origin,Gr=jr();return{description:qr,url:Vr,icons:Gr,name:Hr}}getWindowMetadata_1=cjs$2.getWindowMetadata=getWindowMetadata;var __spreadArrays=globalThis&&globalThis.__spreadArrays||function(){for(var Nr=0,$r=0,jr=arguments.length;$r"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new ReactNativeInfo:typeof navigator<"u"?parseUserAgent(navigator.userAgent):getNodeVersion()}function matchUserAgent(Nr){return Nr!==""&&userAgentRules.reduce(function($r,jr){var Lr=jr[0],Ur=jr[1];if($r)return $r;var Wr=Ur.exec(Nr);return!!Wr&&[Lr,Wr]},!1)}function parseUserAgent(Nr){var $r=matchUserAgent(Nr);if(!$r)return null;var jr=$r[0],Lr=$r[1];if(jr==="searchbot")return new BotInfo;var Ur=Lr[1]&&Lr[1].split(/[._]/).slice(0,3);Ur?Ur.length1:!1}function isMobile(){return detectOS()?isAndroid()||isIOS():!1}function isNode$1(){const Nr=detectEnv();return Nr&&Nr.name?Nr.name.toLowerCase()==="node":!1}function isBrowser(){return!isNode$1()&&!!getNavigator()}const getFromWindow=getFromWindow_1,getFromWindowOrThrow=getFromWindowOrThrow_1,getDocumentOrThrow=getDocumentOrThrow_1,getDocument=getDocument_1,getNavigatorOrThrow=getNavigatorOrThrow_1,getNavigator=getNavigator_1,getLocationOrThrow=getLocationOrThrow_1,getLocation=getLocation_1,getCryptoOrThrow=getCryptoOrThrow_1,getCrypto=getCrypto_1,getLocalStorageOrThrow=getLocalStorageOrThrow_1,getLocalStorage=getLocalStorage_1;function getClientMeta(){return getWindowMetadata_1()}function safeJsonParse$1(Nr){if(typeof Nr!="string")throw new Error(`Cannot safe json parse value of type ${typeof Nr}`);try{return JSON.parse(Nr)}catch{return Nr}}function safeJsonStringify$1(Nr){return typeof Nr=="string"?Nr:JSON.stringify(Nr)}const safeJsonParse=safeJsonParse$1,safeJsonStringify=safeJsonStringify$1;function setLocal(Nr,$r){const jr=safeJsonStringify($r),Lr=getLocalStorage();Lr&&Lr.setItem(Nr,jr)}function getLocal(Nr){let $r=null,jr=null;const Lr=getLocalStorage();return Lr&&(jr=Lr.getItem(Nr)),$r=jr&&safeJsonParse(jr),$r}function removeLocal(Nr){const $r=getLocalStorage();$r&&$r.removeItem(Nr)}const mobileLinkChoiceKey="WALLETCONNECT_DEEPLINK_CHOICE";function formatIOSMobile(Nr,$r){const jr=encodeURIComponent(Nr);return $r.universalLink?`${$r.universalLink}/wc?uri=${jr}`:$r.deepLink?`${$r.deepLink}${$r.deepLink.endsWith(":")?"//":"/"}wc?uri=${jr}`:""}function saveMobileLinkInfo(Nr){const $r=Nr.href.split("?")[0];setLocal(mobileLinkChoiceKey,Object.assign(Object.assign({},Nr),{href:$r}))}function getMobileRegistryEntry(Nr,$r){return Nr.filter(jr=>jr.name.toLowerCase().includes($r.toLowerCase()))[0]}function getMobileLinkRegistry(Nr,$r){let jr=Nr;return $r&&(jr=$r.map(Lr=>getMobileRegistryEntry(Nr,Lr)).filter(Boolean)),jr}const API_URL="https://registry.walletconnect.com";function getWalletRegistryUrl(){return API_URL+"/api/v2/wallets"}function getDappRegistryUrl(){return API_URL+"/api/v2/dapps"}function formatMobileRegistryEntry(Nr,$r="mobile"){var jr;return{name:Nr.name||"",shortName:Nr.metadata.shortName||"",color:Nr.metadata.colors.primary||"",logo:(jr=Nr.image_url.sm)!==null&&jr!==void 0?jr:"",universalLink:Nr[$r].universal||"",deepLink:Nr[$r].native||""}}function formatMobileRegistry(Nr,$r="mobile"){return Object.values(Nr).filter(jr=>!!jr[$r].universal||!!jr[$r].native).map(jr=>formatMobileRegistryEntry(jr,$r))}const esm=Object.freeze(Object.defineProperty({__proto__:null,detectEnv,detectOS,formatIOSMobile,formatMobileRegistry,formatMobileRegistryEntry,getClientMeta,getCrypto,getCryptoOrThrow,getDappRegistryUrl,getDocument,getDocumentOrThrow,getFromWindow,getFromWindowOrThrow,getLocal,getLocalStorage,getLocalStorageOrThrow,getLocation,getLocationOrThrow,getMobileLinkRegistry,getMobileRegistryEntry,getNavigator,getNavigatorOrThrow,getWalletRegistryUrl,isAndroid,isBrowser,isIOS,isMobile,isNode:isNode$1,mobileLinkChoiceKey,removeLocal,safeJsonParse,safeJsonStringify,saveMobileLinkInfo,setLocal},Symbol.toStringTag,{value:"Module"})),require$$0=getAugmentedNamespace(esm);var browser$1={},canPromise$3=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then},qrcode$1={},typedarrayBuffer={},toString={}.toString,isarray=Array.isArray||function(Nr){return toString.call(Nr)=="[object Array]"},isArray$1=isarray;function typedArraySupport(){try{var Nr=new Uint8Array(1);return Nr.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},Nr.foo()===42}catch{return!1}}Buffer$2.TYPED_ARRAY_SUPPORT=typedArraySupport();var K_MAX_LENGTH=Buffer$2.TYPED_ARRAY_SUPPORT?2147483647:1073741823;function Buffer$2(Nr,$r,jr){return!Buffer$2.TYPED_ARRAY_SUPPORT&&!(this instanceof Buffer$2)?new Buffer$2(Nr,$r,jr):typeof Nr=="number"?allocUnsafe(this,Nr):from(this,Nr,$r,jr)}Buffer$2.TYPED_ARRAY_SUPPORT&&(Buffer$2.prototype.__proto__=Uint8Array.prototype,Buffer$2.__proto__=Uint8Array,typeof Symbol<"u"&&Symbol.species&&Buffer$2[Symbol.species]===Buffer$2&&Object.defineProperty(Buffer$2,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}));function checked(Nr){if(Nr>=K_MAX_LENGTH)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+K_MAX_LENGTH.toString(16)+" bytes");return Nr|0}function isnan(Nr){return Nr!==Nr}function createBuffer(Nr,$r){var jr;return Buffer$2.TYPED_ARRAY_SUPPORT?(jr=new Uint8Array($r),jr.__proto__=Buffer$2.prototype):(jr=Nr,jr===null&&(jr=new Buffer$2($r)),jr.length=$r),jr}function allocUnsafe(Nr,$r){var jr=createBuffer(Nr,$r<0?0:checked($r)|0);if(!Buffer$2.TYPED_ARRAY_SUPPORT)for(var Lr=0;Lr<$r;++Lr)jr[Lr]=0;return jr}function fromString(Nr,$r){var jr=byteLength($r)|0,Lr=createBuffer(Nr,jr),Ur=Lr.write($r);return Ur!==jr&&(Lr=Lr.slice(0,Ur)),Lr}function fromArrayLike(Nr,$r){for(var jr=$r.length<0?0:checked($r.length)|0,Lr=createBuffer(Nr,jr),Ur=0;Ur55295&&jr<57344){if(!Ur){if(jr>56319){($r-=3)>-1&&Wr.push(239,191,189);continue}else if(Hr+1===Lr){($r-=3)>-1&&Wr.push(239,191,189);continue}Ur=jr;continue}if(jr<56320){($r-=3)>-1&&Wr.push(239,191,189),Ur=jr;continue}jr=(Ur-55296<<10|jr-56320)+65536}else Ur&&($r-=3)>-1&&Wr.push(239,191,189);if(Ur=null,jr<128){if(($r-=1)<0)break;Wr.push(jr)}else if(jr<2048){if(($r-=2)<0)break;Wr.push(jr>>6|192,jr&63|128)}else if(jr<65536){if(($r-=3)<0)break;Wr.push(jr>>12|224,jr>>6&63|128,jr&63|128)}else if(jr<1114112){if(($r-=4)<0)break;Wr.push(jr>>18|240,jr>>12&63|128,jr>>6&63|128,jr&63|128)}else throw new Error("Invalid code point")}return Wr}function byteLength(Nr){if(Buffer$2.isBuffer(Nr))return Nr.length;if(typeof ArrayBuffer<"u"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(Nr)||Nr instanceof ArrayBuffer))return Nr.byteLength;typeof Nr!="string"&&(Nr=""+Nr);var $r=Nr.length;return $r===0?0:utf8ToBytes(Nr).length}function blitBuffer(Nr,$r,jr,Lr){for(var Ur=0;Ur=$r.length||Ur>=Nr.length);++Ur)$r[Ur+jr]=Nr[Ur];return Ur}function utf8Write(Nr,$r,jr,Lr){return blitBuffer(utf8ToBytes($r,Nr.length-jr),Nr,jr,Lr)}function from(Nr,$r,jr,Lr){if(typeof $r=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer<"u"&&$r instanceof ArrayBuffer?fromArrayBuffer(Nr,$r,jr,Lr):typeof $r=="string"?fromString(Nr,$r):fromObject(Nr,$r)}Buffer$2.prototype.write=function($r,jr,Lr){jr===void 0?(Lr=this.length,jr=0):Lr===void 0&&typeof jr=="string"?(Lr=this.length,jr=0):isFinite(jr)&&(jr=jr|0,isFinite(Lr)?Lr=Lr|0:Lr=void 0);var Ur=this.length-jr;if((Lr===void 0||Lr>Ur)&&(Lr=Ur),$r.length>0&&(Lr<0||jr<0)||jr>this.length)throw new RangeError("Attempt to write outside buffer bounds");return utf8Write(this,$r,jr,Lr)};Buffer$2.prototype.slice=function($r,jr){var Lr=this.length;$r=~~$r,jr=jr===void 0?Lr:~~jr,$r<0?($r+=Lr,$r<0&&($r=0)):$r>Lr&&($r=Lr),jr<0?(jr+=Lr,jr<0&&(jr=0)):jr>Lr&&(jr=Lr),jr<$r&&(jr=$r);var Ur;if(Buffer$2.TYPED_ARRAY_SUPPORT)Ur=this.subarray($r,jr),Ur.__proto__=Buffer$2.prototype;else{var Wr=jr-$r;Ur=new Buffer$2(Wr,void 0);for(var Hr=0;Hr=$r.length&&(jr=$r.length),jr||(jr=0),Ur>0&&Ur=this.length)throw new RangeError("sourceStart out of bounds");if(Ur<0)throw new RangeError("sourceEnd out of bounds");Ur>this.length&&(Ur=this.length),$r.length-jr=0;--Hr)$r[Hr+jr]=this[Hr+Lr];else if(Wr<1e3||!Buffer$2.TYPED_ARRAY_SUPPORT)for(Hr=0;Hr>>0,Lr=Lr===void 0?this.length:Lr>>>0,$r||($r=0);var Wr;if(typeof $r=="number")for(Wr=jr;Wr40)throw new Error('"version" should be in range from 1 to 40');return $r*4+17};utils$3.getSymbolTotalCodewords=function($r){return CODEWORDS_COUNT$1[$r]};utils$3.getBCHDigit=function(Nr){for(var $r=0;Nr!==0;)$r++,Nr>>>=1;return $r};utils$3.setToSJISFunction=function($r){if(typeof $r!="function")throw new Error('"toSJISFunc" is not a valid function.');toSJISFunction$1=$r};utils$3.isKanjiModeEnabled=function(){return typeof toSJISFunction$1<"u"};utils$3.toSJIS=function($r){return toSJISFunction$1($r)};var errorCorrectionLevel$1={};(function(Nr){Nr.L={bit:1},Nr.M={bit:0},Nr.Q={bit:3},Nr.H={bit:2};function $r(jr){if(typeof jr!="string")throw new Error("Param is not a string");var Lr=jr.toLowerCase();switch(Lr){case"l":case"low":return Nr.L;case"m":case"medium":return Nr.M;case"q":case"quartile":return Nr.Q;case"h":case"high":return Nr.H;default:throw new Error("Unknown EC Level: "+jr)}}Nr.isValid=function(Lr){return Lr&&typeof Lr.bit<"u"&&Lr.bit>=0&&Lr.bit<4},Nr.from=function(Lr,Ur){if(Nr.isValid(Lr))return Lr;try{return $r(Lr)}catch{return Ur}}})(errorCorrectionLevel$1);function BitBuffer$3(){this.buffer=[],this.length=0}BitBuffer$3.prototype={get:function(Nr){var $r=Math.floor(Nr/8);return(this.buffer[$r]>>>7-Nr%8&1)===1},put:function(Nr,$r){for(var jr=0;jr<$r;jr++)this.putBit((Nr>>>$r-jr-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(Nr){var $r=Math.floor(this.length/8);this.buffer.length<=$r&&this.buffer.push(0),Nr&&(this.buffer[$r]|=128>>>this.length%8),this.length++}};var bitBuffer$1=BitBuffer$3,BufferUtil$4=typedarrayBuffer;function BitMatrix$3(Nr){if(!Nr||Nr<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=Nr,this.data=BufferUtil$4.alloc(Nr*Nr),this.reservedBit=BufferUtil$4.alloc(Nr*Nr)}BitMatrix$3.prototype.set=function(Nr,$r,jr,Lr){var Ur=Nr*this.size+$r;this.data[Ur]=jr,Lr&&(this.reservedBit[Ur]=!0)};BitMatrix$3.prototype.get=function(Nr,$r){return this.data[Nr*this.size+$r]};BitMatrix$3.prototype.xor=function(Nr,$r,jr){this.data[Nr*this.size+$r]^=jr};BitMatrix$3.prototype.isReserved=function(Nr,$r){return this.reservedBit[Nr*this.size+$r]};var bitMatrix$1=BitMatrix$3,alignmentPattern$1={};(function(Nr){var $r=utils$3.getSymbolSize;Nr.getRowColCoords=function(Lr){if(Lr===1)return[];for(var Ur=Math.floor(Lr/7)+2,Wr=$r(Lr),Hr=Wr===145?26:Math.ceil((Wr-13)/(2*Ur-2))*2,qr=[Wr-7],Vr=1;Vr=0&&Ur<=7},Nr.from=function(Ur){return Nr.isValid(Ur)?parseInt(Ur,10):void 0},Nr.getPenaltyN1=function(Ur){for(var Wr=Ur.size,Hr=0,qr=0,Vr=0,Gr=null,Cn=null,In=0;In=5&&(Hr+=$r.N1+(qr-5)),Gr=Zn,qr=1),Zn=Ur.get(Gn,In),Zn===Cn?Vr++:(Vr>=5&&(Hr+=$r.N1+(Vr-5)),Cn=Zn,Vr=1)}qr>=5&&(Hr+=$r.N1+(qr-5)),Vr>=5&&(Hr+=$r.N1+(Vr-5))}return Hr},Nr.getPenaltyN2=function(Ur){for(var Wr=Ur.size,Hr=0,qr=0;qr=10&&(qr===1488||qr===93)&&Hr++,Vr=Vr<<1&2047|Ur.get(Cn,Gr),Cn>=10&&(Vr===1488||Vr===93)&&Hr++}return Hr*$r.N3},Nr.getPenaltyN4=function(Ur){for(var Wr=0,Hr=Ur.data.length,qr=0;qr=0;){for(var qr=Hr[0],Vr=0;Vr @@ -2940,10 +2940,10 @@ You will need this password to access your ${Nr} wallet on a new device. Please align-items: center; justify-content: center; height: 100%; -`,sv=({onLoad:Nr})=>{let $r=window;return reactExports.useEffect(()=>{if(document.getElementById("cf-script")!==null||$r.turnstile)return;$r.onloadTurnstileCallback=Nr;let jr=document.createElement("script");jr.setAttribute("src","https://challenges.cloudflare.com/turnstile/v0/api.js?onload=onloadTurnstileCallback&render=explicit"),jr.setAttribute("id","cf-script"),jr.setAttribute("async","true"),document.body.appendChild(jr)},[]),jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{})},Dp=sv,Up={id:42161,name:"Arbitrum One",network:"arbitrum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{alchemy:{http:["https://arb-mainnet.g.alchemy.com/v2"],webSocket:["wss://arb-mainnet.g.alchemy.com/v2"]},infura:{http:["https://arbitrum-mainnet.infura.io/v3"],webSocket:["wss://arbitrum-mainnet.infura.io/ws/v3"]},default:{http:["https://arb1.arbitrum.io/rpc"]},public:{http:["https://arb1.arbitrum.io/rpc"]}},blockExplorers:{etherscan:{name:"Arbiscan",url:"https://arbiscan.io"},default:{name:"Arbiscan",url:"https://arbiscan.io"}}},Fp={id:421613,name:"Arbitrum Goerli",network:"arbitrum-goerli",nativeCurrency:{name:"Goerli Ether",symbol:"AGOR",decimals:18},rpcUrls:{alchemy:{http:["https://arb-goerli.g.alchemy.com/v2"],webSocket:["wss://arb-goerli.g.alchemy.com/v2"]},infura:{http:["https://arbitrum-goerli.infura.io/v3"],webSocket:["wss://arbitrum-goerli.infura.io/ws/v3"]},default:{http:["https://goerli-rollup.arbitrum.io/rpc"]},public:{http:["https://goerli-rollup.arbitrum.io/rpc"]}},blockExplorers:{etherscan:{name:"Arbiscan",url:"https://goerli.arbiscan.io/"},default:{name:"Arbiscan",url:"https://goerli.arbiscan.io/"}},testnet:!0},Bp={id:43114,name:"Avalanche",network:"avalanche",nativeCurrency:{decimals:18,name:"Avalanche",symbol:"AVAX"},rpcUrls:{default:{http:["https://api.avax.network/ext/bc/C/rpc"]},public:{http:["https://api.avax.network/ext/bc/C/rpc"]}},blockExplorers:{etherscan:{name:"SnowTrace",url:"https://snowtrace.io"},default:{name:"SnowTrace",url:"https://snowtrace.io"}}},Hp={id:43113,name:"Avalanche Fuji",network:"avalanche-fuji",nativeCurrency:{decimals:18,name:"Avalanche Fuji",symbol:"AVAX"},rpcUrls:{default:{http:["https://api.avax-test.network/ext/bc/C/rpc"]},public:{http:["https://api.avax-test.network/ext/bc/C/rpc"]}},blockExplorers:{etherscan:{name:"SnowTrace",url:"https://testnet.snowtrace.io"},default:{name:"SnowTrace",url:"https://testnet.snowtrace.io"}},testnet:!0},Gp={id:8453,network:"base",name:"Base",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{blast:{http:["https://base-mainnet.blastapi.io"],webSocket:["wss://base-mainnet.blastapi.io"]},default:{http:["https://mainnet.base.org"]},public:{http:["https://mainnet.base.org"]}},blockExplorers:{etherscan:{name:"Basescan",url:"https://basescan.org"},default:{name:"Basescan",url:"https://basescan.org"}},testnet:!0},zp={id:84531,network:"base-goerli",name:"Base Goerli Testnet",nativeCurrency:{name:"Goerli Ether",symbol:"ETH",decimals:18},rpcUrls:{blast:{http:["https://base-goerli.blastapi.io"],webSocket:["wss://base-goerli.blastapi.io"]},default:{http:["https://goerli.base.org"]},public:{http:["https://goerli.base.org"]}},blockExplorers:{etherscan:{name:"Basescan",url:"https://goerli.basescan.org"},default:{name:"Basescan",url:"https://goerli.basescan.org"}},testnet:!0},$p={id:42220,name:"Celo Mainnet",network:"celo",nativeCurrency:{decimals:18,name:"CELO",symbol:"CELO"},rpcUrls:{default:{http:["https://forno.celo.org"]},infura:{http:["https://celo-mainnet.infura.io/v3"]},public:{http:["https://forno.celo.org"]}},blockExplorers:{default:{name:"Celo Explorer",url:"https://explorer.celo.org/mainnet"},etherscan:{name:"CeloScan",url:"https://celoscan.io"}},testnet:!1},Vp={id:44787,name:"Celo Alfajores Testnet",network:"celo-alfajores",nativeCurrency:{decimals:18,name:"CELO",symbol:"CELO"},rpcUrls:{default:{http:["https://alfajores-forno.celo-testnet.org"]},infura:{http:["https://celo-alfajores.infura.io/v3"]},public:{http:["https://alfajores-forno.celo-testnet.org"]}},blockExplorers:{default:{name:"Celo Explorer",url:"https://explorer.celo.org/alfajores"},etherscan:{name:"CeloScan",url:"https://alfajores.celoscan.io/"}},testnet:!0},qp={id:314,name:"Filecoin - Mainnet",network:"filecoin-mainnet",nativeCurrency:{decimals:18,name:"filecoin",symbol:"FIL"},rpcUrls:{default:{http:["https://api.node.glif.io/rpc/v1"]},public:{http:["https://api.node.glif.io/rpc/v1"]}},blockExplorers:{default:{name:"Filfox",url:"https://filfox.info/en"},filscan:{name:"Filscan",url:"https://filscan.io"},filscout:{name:"Filscout",url:"https://filscout.io/en"},glif:{name:"Glif",url:"https://explorer.glif.io"}}},jp={id:314159,name:"Filecoin - Calibration testnet",network:"filecoin-calibration",nativeCurrency:{decimals:18,name:"testnet filecoin",symbol:"tFIL"},rpcUrls:{default:{http:["https://api.calibration.node.glif.io/rpc/v1"]},public:{http:["https://api.calibration.node.glif.io/rpc/v1"]}},blockExplorers:{default:{name:"Filscan",url:"https://calibration.filscan.io"}}},Kp={id:5,network:"goerli",name:"Goerli",nativeCurrency:{name:"Goerli Ether",symbol:"ETH",decimals:18},rpcUrls:{alchemy:{http:["https://eth-goerli.g.alchemy.com/v2"],webSocket:["wss://eth-goerli.g.alchemy.com/v2"]},infura:{http:["https://goerli.infura.io/v3"],webSocket:["wss://goerli.infura.io/ws/v3"]},default:{http:["https://rpc.ankr.com/eth_goerli"]},public:{http:["https://rpc.ankr.com/eth_goerli"]}},blockExplorers:{etherscan:{name:"Etherscan",url:"https://goerli.etherscan.io"},default:{name:"Etherscan",url:"https://goerli.etherscan.io"}},testnet:!0},Yp={id:59144,network:"linea-mainnet",name:"Linea Mainnet",nativeCurrency:{name:"Linea Ether",symbol:"ETH",decimals:18},rpcUrls:{infura:{http:["https://linea-mainnet.infura.io/v3"],webSocket:["wss://linea-mainnet.infura.io/ws/v3"]},default:{http:["https://rpc.linea.build"],webSocket:["wss://rpc.linea.build"]},public:{http:["https://rpc.linea.build"],webSocket:["wss://rpc.linea.build"]}},blockExplorers:{default:{name:"Etherscan",url:"https://lineascan.build"},etherscan:{name:"Etherscan",url:"https://lineascan.build"}},testnet:!1},Jp={id:59140,network:"linea-testnet",name:"Linea Goerli Testnet",nativeCurrency:{name:"Linea Ether",symbol:"ETH",decimals:18},rpcUrls:{infura:{http:["https://linea-goerli.infura.io/v3"],webSocket:["wss://linea-goerli.infura.io/ws/v3"]},default:{http:["https://rpc.goerli.linea.build"],webSocket:["wss://rpc.goerli.linea.build"]},public:{http:["https://rpc.goerli.linea.build"],webSocket:["wss://rpc.goerli.linea.build"]}},blockExplorers:{default:{name:"Etherscan",url:"https://goerli.lineascan.build"},etherscan:{name:"Etherscan",url:"https://goerli.lineascan.build"}},testnet:!0},yi={id:1,network:"homestead",name:"Ethereum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{alchemy:{http:["https://eth-mainnet.g.alchemy.com/v2"],webSocket:["wss://eth-mainnet.g.alchemy.com/v2"]},infura:{http:["https://mainnet.infura.io/v3"],webSocket:["wss://mainnet.infura.io/ws/v3"]},default:{http:["https://cloudflare-eth.com"]},public:{http:["https://cloudflare-eth.com"]}},blockExplorers:{etherscan:{name:"Etherscan",url:"https://etherscan.io"},default:{name:"Etherscan",url:"https://etherscan.io"}}},Qp={id:10,name:"OP Mainnet",network:"optimism",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{alchemy:{http:["https://opt-mainnet.g.alchemy.com/v2"],webSocket:["wss://opt-mainnet.g.alchemy.com/v2"]},infura:{http:["https://optimism-mainnet.infura.io/v3"],webSocket:["wss://optimism-mainnet.infura.io/ws/v3"]},default:{http:["https://mainnet.optimism.io"]},public:{http:["https://mainnet.optimism.io"]}},blockExplorers:{etherscan:{name:"Etherscan",url:"https://optimistic.etherscan.io"},default:{name:"Optimism Explorer",url:"https://explorer.optimism.io"}}},Zp={id:420,name:"Optimism Goerli Testnet",network:"optimism-goerli",nativeCurrency:{name:"Goerli Ether",symbol:"ETH",decimals:18},rpcUrls:{alchemy:{http:["https://opt-goerli.g.alchemy.com/v2"],webSocket:["wss://opt-goerli.g.alchemy.com/v2"]},infura:{http:["https://optimism-goerli.infura.io/v3"],webSocket:["wss://optimism-goerli.infura.io/ws/v3"]},default:{http:["https://goerli.optimism.io"]},public:{http:["https://goerli.optimism.io"]}},blockExplorers:{etherscan:{name:"Etherscan",url:"https://goerli-optimism.etherscan.io"},default:{name:"Etherscan",url:"https://goerli-optimism.etherscan.io"}},testnet:!0},Xp={id:11155111,network:"sepolia",name:"Sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"SEP",decimals:18},rpcUrls:{alchemy:{http:["https://eth-sepolia.g.alchemy.com/v2"],webSocket:["wss://eth-sepolia.g.alchemy.com/v2"]},infura:{http:["https://sepolia.infura.io/v3"],webSocket:["wss://sepolia.infura.io/ws/v3"]},default:{http:["https://rpc.sepolia.org"]},public:{http:["https://rpc.sepolia.org"]}},blockExplorers:{etherscan:{name:"Etherscan",url:"https://sepolia.etherscan.io"},default:{name:"Etherscan",url:"https://sepolia.etherscan.io"}},testnet:!0},gi=[Up,Fp,Kp,Xp,yi,Qp,Zp,Fr,Br,$p,Vp,qp,jp,Gp,zp,Yp,Jp,Bp,Hp];new Set(gi.map(Nr=>Nr.id));var eu="#FFFFFF",dv="#000000",pv=eu,uv="#1E1E1D";function mv(Nr){return Nr<.8&&Nr>.2&&console.warn("Background color is not light or dark enough, which could lead to accessibility issues."),Nr>.5?"light":"dark"}function po(Nr,$r){let jr=Math.max(0,Math.min(1,Nr.toHsl().l+$r));return tinycolor({...Nr.toHsl(),l:jr})}function tu({backgroundTheme:Nr,accentHex:$r,successHex:jr="#51BA81",warnHex:Lr="#FFB74D",errorHex:Ur="#EC6351",whiteHex:Wr=eu,blackHex:Hr=dv}){let qr;switch(Nr){case"light":qr=pv;break;case"dark":qr=uv;break;default:qr=Nr;break}let Vr=tinycolor(qr),Gr=tinycolor($r),Cn=tinycolor(jr),In=tinycolor(Lr),Gn=tinycolor(Ur),Zn=mv(Vr.getLuminance()),no=po(Vr,Zn==="light"?-.04:.11),ho=po(Vr,Zn==="light"?-.88:.87),xo=po(Vr,Zn==="light"?-.77:.75),so=po(Vr,Zn==="light"?-.43:.45).desaturate(Zn==="light"?60:20),io=po(Vr,Zn==="light"?-.08:.25).desaturate(Zn==="light"?60:20),lo=po(Gr,.15),co=po(Gr,-.06),_o=tinycolor(Gr.getLuminance()>.5?Hr:Wr),Ro=po(Cn,-.16);return{colorScheme:Zn,background:Vr.toHslString(),background2:no.toHslString(),foreground:ho.toHslString(),foreground2:xo.toHslString(),foreground3:so.toHslString(),foreground4:io.toHslString(),accent:Gr.toHslString(),accentLight:lo.toHslString(),accentDark:co.toHslString(),foregroundAccent:_o.toHslString(),success:Cn.toHslString(),successDark:Ro.toHslString(),error:Gn.toHslString(),warn:In.toHslString()}}var uo={appearance:{theme:"light",accentColor:"#676FFF"},walletConnectCloudProjectId:Os,rpcConfig:{rpcUrls:{}},captchaEnabled:!1,_render:{inDialog:!0,inParentNodeId:null},fiatOnRamp:{useSandbox:!1}};function vi(Nr,$r){var io,lo,co,_o,Ro,fo,jo,Kl,au,wu,Au,na;let jr=["google","twitter","discord","tiktok","linkedin","github","apple"],Lr=(io=$r==null?void 0:$r.loginMethods)==null?void 0:io.filter(eo=>jr.includes(eo)),Ur=Lr==null?void 0:Lr.slice(0,5),Wr,Hr,qr,Vr,Gr,Cn,In,Gn,Zn,no;if($r!=null&&$r.loginMethods?(Wr=$r.loginMethods.includes("email"),Hr=$r.loginMethods.includes("sms"),qr=$r.loginMethods.includes("wallet"),Vr=Ur==null?void 0:Ur.includes("google"),Gr=Ur==null?void 0:Ur.includes("twitter"),Cn=Ur==null?void 0:Ur.includes("discord"),In=Ur==null?void 0:Ur.includes("tiktok"),Zn=Ur==null?void 0:Ur.includes("github"),Gn=Ur==null?void 0:Ur.includes("linkedin"),no=Ur==null?void 0:Ur.includes("apple")):(Wr=Nr.emailAuth,Hr=Nr.smsAuth,qr=Nr.walletAuth,Vr=Nr.googleOAuth,Gr=Nr.twitterOAuth,Cn=Nr.discordOAuth,Zn=Nr.githubOAuth,In=Nr.tiktokOAuth,Gn=Nr.linkedinOAuth,no=Nr.appleOAuth),Wr&&Hr&&(console.warn("Enabling both email and SMS passwordless is not currently supported. Disabling SMS."),Hr=!1),!Wr&&!Hr&&[Vr,Gr,Cn,Zn,In,Gn,no].some(eo=>eo))throw new Error("To enable social logins you must also enable either SMS or Email login");if(![Wr,Hr,qr,Vr,Gr,Cn,Zn,In,Gn,no].some(eo=>eo))throw new Error("You must enable at least one login method");let{chains:ho,defaultChain:xo}=hv($r==null?void 0:$r.additionalChains,$r==null?void 0:$r.supportedChains,$r==null?void 0:$r.defaultChain);Lr&&Lr.length>5&&console.warn("Max number of social logins allowed is 5. Any more have been removed.");let so=((lo=$r==null?void 0:$r.customAuth)==null?void 0:lo.getCustomAccessToken)&&((co=$r==null?void 0:$r.customAuth)==null?void 0:co.enabled)!==!1;return{id:Nr.id,name:Nr.name,allowlistConfig:Nr.allowlistConfig,appearance:{logo:((_o=$r==null?void 0:$r.appearance)==null?void 0:_o.logo)??Nr.logoUrl,palette:tu({backgroundTheme:((Ro=$r==null?void 0:$r.appearance)==null?void 0:Ro.theme)??uo.appearance.theme,accentHex:((fo=$r==null?void 0:$r.appearance)==null?void 0:fo.accentColor)??Nr.accentColor??uo.appearance.accentColor}),showWalletLoginFirst:((jo=$r==null?void 0:$r.appearance)==null?void 0:jo.showWalletLoginFirst)??Nr.showWalletLoginFirst},loginMethods:{wallet:qr,email:Wr,sms:Hr,google:Vr,twitter:Gr,discord:Cn,github:Zn,tiktok:In,linkedin:Gn,apple:no},legal:{termsAndConditionsUrl:((Kl=$r==null?void 0:$r.legal)==null?void 0:Kl.termsAndConditionsUrl)??Nr.termsAndConditionsUrl,privacyPolicyUrl:((au=$r==null?void 0:$r.legal)==null?void 0:au.privacyPolicyUrl)??Nr.privacyPolicyUrl},walletConnectCloudProjectId:($r==null?void 0:$r.walletConnectCloudProjectId)??Nr.walletConnectCloudProjectId??uo.walletConnectCloudProjectId,rpcConfig:($r==null?void 0:$r.rpcConfig)??uo.rpcConfig,chains:ho,defaultChain:xo,captchaEnabled:Nr.captchaEnabled??uo.captchaEnabled,embeddedWallets:{...Nr.embeddedWalletConfig,...so?{createOnLogin:"all-users",requireUserPasswordOnCreate:!1,noPromptOnSignature:!0}:{},...$r==null?void 0:$r.embeddedWallets},customAuth:so?{enabled:!0,...$r.customAuth}:void 0,fiatOnRamp:{enabled:Nr.fiatOnRampEnabled,useSandbox:((wu=$r==null?void 0:$r.fiatOnRamp)==null?void 0:wu.useSandbox)??uo.fiatOnRamp.useSandbox},loginConfig:{twitterOAuthOnMobileEnabled:Nr.twitterOAuthOnMobileEnabled??!1},render:{inDialog:((Au=$r==null?void 0:$r._render)==null?void 0:Au.inDialog)??uo._render.inDialog,inParentNodeId:((na=$r==null?void 0:$r._render)==null?void 0:na.inParentNodeId)??uo._render.inParentNodeId}}}function ou(Nr,$r){var jr;return(jr=Nr==null?void 0:Nr.appearance)!=null&&jr.logo&&typeof Nr.appearance.logo=="object"&&(Nr.appearance.logo="component"),{...Nr,legacyCreateEmbeddedWalletFlag:$r}}function hv(Nr,$r,jr){let Lr;if(Nr&&$r&&console.warn("You should only specify one of `additionalChains` or `supportedChains`. Using `supportedChains`."),$r){if($r.length===0)throw new Error("`supportedChains` must contain at least one chain");Lr=$r}else Lr=gi.concat(Nr??[]);let Ur=$r?Lr[0]:yi,Wr=jr??Ur;if(!Lr.find(Hr=>Hr.id===Wr.id))throw new Error("`defaultChain` must be included in `supportedChains`");return{chains:Lr,defaultChain:Wr}}var wi=class{constructor(){this.callbacks={}}enqueue(Nr,$r){this.callbacks[Nr]=$r}dequeue(Nr,$r){let jr=this.callbacks[$r];if(!jr)throw new Error(`cannot dequeue ${Nr} event: no event found for id ${$r}`);switch(delete this.callbacks[$r],Nr){case"privy:iframe:ready":return jr;case"privy:wallet:create":return jr;case"privy:wallet:connect":return jr;case"privy:wallet:recover":return jr;case"privy:wallet:rpc":return jr;case"privy:wallet:set-recovery-password":return jr;default:throw new Error(`invalid wallet event type ${Nr}`)}}},gv=function(Nr){return()=>`id-${Nr++}`}(0);function vv(Nr){return typeof Nr.event=="string"&&/^privy:.+/.test(Nr.event)}function dr(Nr){return Nr.error!==void 0}var Oo=new wi,ts=new Map,wv=(Nr,$r)=>typeof $r=="bigint"?$r.toString():$r,Cv=(Nr,$r)=>`${Nr}${JSON.stringify($r,wv)}`;function pr(Nr,$r,jr){let Lr=jr.contentWindow;if(!Lr)throw new Error("iframe not initialized");let Ur=Cv(Nr,$r);if(Nr==="privy:wallet:create"){let Hr=ts.get(Ur);if(Hr)return Hr}let Wr=new Promise((Hr,qr)=>{let Vr=gv();Oo.enqueue(Vr,{resolve:Hr,reject:qr}),Lr.postMessage({id:Vr,event:Nr,data:$r},"*")}).finally(()=>{ts.delete(Ur)});return ts.set(Ur,Wr),Wr}function bv(Nr){switch(Nr.event){case"privy:iframe:ready":let $r=Oo.dequeue(Nr.event,Nr.id);return dr(Nr)?$r.reject(new Wt(Nr.error.type,Nr.error.message)):$r.resolve(Nr.data);case"privy:wallet:create":let jr=Oo.dequeue(Nr.event,Nr.id);return dr(Nr)?jr.reject(new Wt(Nr.error.type,Nr.error.message)):jr.resolve(Nr.data);case"privy:wallet:connect":let Lr=Oo.dequeue(Nr.event,Nr.id);return dr(Nr)?Lr.reject(new Wt(Nr.error.type,Nr.error.message)):Lr.resolve(Nr.data);case"privy:wallet:recover":let Ur=Oo.dequeue(Nr.event,Nr.id);return dr(Nr)?Ur.reject(new Wt(Nr.error.type,Nr.error.message)):Ur.resolve(Nr.data);case"privy:wallet:rpc":let Wr=Oo.dequeue(Nr.event,Nr.id);return dr(Nr)?Wr.reject(new Wt(Nr.error.type,Nr.error.message)):Wr.resolve(Nr.data);case"privy:wallet:set-recovery-password":let Hr=Oo.dequeue(Nr.event,Nr.id);return dr(Nr)?Hr.reject(new Wt(Nr.error.type,Nr.error.message)):Hr.resolve(Nr.data);default:console.warn("Unsupported wallet proxy method:",Nr)}}function ru(Nr){let $r=reactExports.useRef(null);return reactExports.useEffect(()=>{let jr=$r.current;if(!jr)return;function Lr(Vr){Vr&&Vr.origin===Nr.origin&&vv(Vr.data)&&bv(Vr.data)}let Ur={create(Vr){return pr("privy:wallet:create",Vr,jr)},connect(Vr){return pr("privy:wallet:connect",Vr,jr)},recover(Vr){return pr("privy:wallet:recover",Vr,jr)},rpc(Vr){return pr("privy:wallet:rpc",Vr,jr)},setRecoveryPassword(Vr){return pr("privy:wallet:set-recovery-password",Vr,jr)}};window.addEventListener("message",Lr);let Wr=()=>Nr.onLoad(Ur),Hr=(...Vr)=>{console.warn("Privy iframe failed to load: ",...Vr),Nr.onLoadFailed()},qr=new AbortController;return js(()=>pr("privy:iframe:ready",{},jr),{abortSignal:qr.signal}).then(Wr,Hr),()=>{window.removeEventListener("message",Lr),qr.abort()}},[$r.current]),jsxRuntimeExports.jsx("iframe",{ref:$r,width:"0",height:"0",style:{display:"none",height:"0px",width:"0px"},src:an(Nr.origin,`/apps/${Nr.appId}/embedded-wallets`)})}var nu={login:{onComplete:[],onError:[]},logout:{onSuccess:[]},connectWallet:{onSuccess:[],onError:[]},createWallet:{onSuccess:[],onError:[]}},os=reactExports.createContext(void 0);function se(Nr,$r,jr,...Lr){for(let Ur of Nr.current[$r][jr])Ur(...Lr)}function kv(Nr){return typeof Nr=="string"&&Nr.length===25}var zr;function At(){if(!zr){let Nr=z.get(Ho);return Promise.resolve(Nr||null)}return zr.getAccessToken()}var su,Xs=(Nr,$r)=>su(Nr,$r),lu,el=(Nr,$r)=>lu(Nr,$r),cu,tl=()=>cu(),Rv=()=>{let Nr=new URLSearchParams(window.location.search).get("privy_token");if(!Nr)return;z.put(yr,Nr);let $r=new URL(window.location.href);$r.searchParams.delete("privy_token"),window.history.pushState({},"",$r)},Wv=({config:Nr,...$r})=>{var Lr,Ur;if(!kv($r.appId))throw new C("Cannot initialize the Privy provider with an invalid Privy app ID");zr||(zr=new Pr({appId:$r.appId,apiUrl:$r.apiUrl||Xr}));let jr=Object.assign({},Nr);return $r.createPrivyWalletOnLogin!==void 0&&((Lr=jr.embeddedWallets)==null?void 0:Lr.createOnLogin)===void 0&&(jr.embeddedWallets||(jr.embeddedWallets={}),jr.embeddedWallets.createOnLogin=$r.createPrivyWalletOnLogin?"users-without-wallets":"off"),$r.createPrivyWalletOnLogin!==void 0&&((Ur=Nr==null?void 0:Nr.embeddedWallets)!=null&&Ur.createOnLogin)&&console.warn("Both `createPrivyWalletOnLogin` and `config.embeddedWallets.createOnLogin` are set. `createPrivyWalletOnLogin` is deprecated and should be removed."),jsxRuntimeExports.jsx(Iv,{...$r,config:jr,client:zr})},Iv=Nr=>{var Pu,dp,fu;let $r=Nr.client,[jr,Lr]=reactExports.useState(!1),[Ur,Wr]=reactExports.useState(!1),[Hr,qr]=reactExports.useState(!1),[Vr,Gr]=reactExports.useState(null),[Cn,In]=reactExports.useState(!1),[Gn,Zn]=reactExports.useState([]),no=reactExports.useRef(Gn),[ho,xo]=reactExports.useState(!1),[so,io]=reactExports.useState(null),[lo,co]=reactExports.useState(!1),[_o,Ro]=reactExports.useState({status:"disconnected",connectError:null,connector:null,connectRetry:x}),[fo,jo]=reactExports.useState(null),[Kl,au]=reactExports.useState(null),[wu,Au]=reactExports.useState({showWalletLoginFirst:!0,allowlistConfig:{errorTitle:null,errorDetail:null,errorCtaText:null,errorCtaLink:null},walletAuth:!0,emailAuth:!0,smsAuth:!1,googleOAuth:!1,twitterOAuth:!1,discordOAuth:!1,githubOAuth:!1,linkedinOAuth:!1,appleOAuth:!1,termsAndConditionsUrl:null,privacyPolicyUrl:null,embeddedWalletConfig:{createOnLogin:"off",requireUserPasswordOnCreate:!1},fiatOnRampEnabled:!1,captchaEnabled:!1}),[na,eo]=reactExports.useState(()=>{let Hl=ou(Nr.config,Nr.createPrivyWalletOnLogin);return $r.createAnalyticsEvent("sdk_initialize",Hl),vi(wu,Nr.config)}),[mo,Qo]=reactExports.useState(!0),[Ml,Vo]=reactExports.useState({}),[Do,Sl]=reactExports.useState(null),[Lo,Eo]=reactExports.useState(null),[ga,vu]=reactExports.useState(!1),[Bo,Xo]=reactExports.useState(),[Al,Ol]=reactExports.useState(),[Gl,So]=reactExports.useState(),[Po,Wl]=reactExports.useState(!1),hu=reactExports.useRef(nu),$u=Hl=>{Hl&&io(Hl),Lr(!0),$r.createAnalyticsEvent("modal_open",{initialScreen:Hl})},Vu=Hl=>{na.embeddedWallets.createOnLogin!=="off"&&Qo(!0),$u(Hl)};reactExports.useEffect(()=>{var Ql,gu;if(!Kl||!Vr){(Ql=$r.connectors)==null||Ql.removeEmbeddedWalletConnector();return}let Hl=Vr==null?void 0:Vr.linkedAccounts.filter(ju=>ju.type==="wallet"&&ju.walletClient==="privy");if(Hl&&Hl.length>0){let ju=Hl[0].address;(gu=$r.connectors)==null||gu.addEmbeddedWalletConnector(Kl,ju,na.defaultChain)}},[Kl,Vr]),reactExports.useEffect(()=>{Kl&&(Lo==null||Lo(Kl))},[Kl]),reactExports.useEffect(()=>{(async()=>{var gu;if(!((gu=na.customAuth)!=null&&gu.enabled))return;Qo(!0);let{getCustomAccessToken:Hl,isLoading:Ql}=na.customAuth;if(!(!Ur||Ql))try{let ju=await Hl();if(!ju){await Jl.logout();return}if(Hr)return;$r.startAuthFlow(new Fo(ju));let{user:cp,isNewUser:op}=await $r.authenticate();cp||await Jl.logout(),Gr(cp||null),xo(op||!1),qr(!0),Wl(!0)}catch(ju){console.warn(ju),Hr&&await Jl.logout()}})()},[(Pu=na.customAuth)==null?void 0:Pu.enabled,(dp=na.customAuth)==null?void 0:dp.getCustomAccessToken,(fu=na.customAuth)==null?void 0:fu.isLoading,Ur,Hr]),reactExports.useEffect(()=>{var Hl,Ql;Po&&Kl&&Vr&&zt(Vr,(Ql=(Hl=Nr.config)==null?void 0:Hl.embeddedWallets)==null?void 0:Ql.createOnLogin)&&(Wl(!1),Co(Vr,3e4).catch(console.error))},[Po&&Kl&&Vr]),reactExports.useEffect(()=>{async function Hl(){var op,Pp,Ep;let Ql=await $r.getServerConfig();Au(Ql);let gu=vi(Ql,Nr.config);eo(gu),Ql.customApiUrl&&$r.updateApiUrl(Ql.customApiUrl),$r.initializeConnectorManager(gu.walletConnectCloudProjectId,gu.rpcConfig,gu.chains,gu.defaultChain),(op=$r.connectors)==null||op.initialize();let ju=Vl();Rv();let cp=await $r.getAuthenticatedUser();(Ep=(Pp=Nr.config)==null?void 0:Pp.customAuth)!=null&&Ep.enabled||(qr(!!cp),cp&&se(hu,"login","onComplete",cp,!1,!0),Gr(cp)),ju||(Wr(!0),Do==null||Do()),ju&&cp&&In(!0),mu()}Ur||Hl()},[$r,Do,Ur]),reactExports.useEffect(()=>{let Hl=vi(wu,Nr.config);eo(Hl)},[Nr.config]);let Vl=()=>{let Hl=new URLSearchParams(window.location.search),Ql=Hl.get("privy_oauth_code"),gu=Hl.get("privy_oauth_state"),ju=Hl.get("privy_oauth_provider");return Ql&&gu&&ju?($r.startAuthFlow(new Gt(ju,Ql,gu)),Vu("AWAITING_OAUTH_SCREEN"),Vo({finishOauthFlow:{onComplete:()=>{Wr(!0),Do==null||Do()}}}),!0):!1},Io=async(Hl,Ql,gu)=>{var cp;let ju=await((cp=$r.connectors)==null?void 0:cp.createWalletConnector(Hl,Ql))||null;Ko(ju,gu)};async function Ko(Hl,Ql){if(!Hl)return Ro({status:"disconnected",connectError:new F("Unable to connect to wallet."),connector:null,connectRetry:x}),Ql==null?void 0:Ql(null);Ro({connector:Hl,status:"connecting",connectError:null,connectRetry:()=>Ko(Hl,Ql)});try{let gu=await Hl.connect({showPrompt:!0});if(!na.chains.find(ju=>ju.id===Number(gu==null?void 0:gu.chainId))){Ro(ju=>({...ju,connector:Hl,status:"switching_to_supported_chain",connectError:null,connectRetry:x}));try{await(gu==null?void 0:gu.switchChain(na.defaultChain.id))}catch{console.warn(`Unable to switch to default chain: ${na.defaultChain.id}`)}}return Ro(ju=>({...ju,status:"connected",connectError:null,connectRetry:x})),gu&&!lo&&se(hu,"connectWallet","onSuccess",gu),Ql==null?void 0:Ql(gu)}catch(gu){return gu instanceof et?(console.warn(gu.cause?gu.cause:gu.message),lo||se(hu,"connectWallet","onError",gu.privyErrorCode||"generic_connect_wallet_error")):(console.warn(gu),lo||se(hu,"connectWallet","onError","unknown_connect_wallet_error")),Ro(ju=>({...ju,status:"disconnected",connectError:gu})),Ql==null?void 0:Ql(null)}}let uu=Hl=>{Hl!==null&&$r.startAuthFlow(new go(Hl))},mu=()=>{let Hl=new URLSearchParams(window.location.search),Ql=Hl.get("privy_connector"),gu=Hl.get("privy_wallet_client");if(!Ql||!gu)return;if(gu==="phantom"&&!je()&&Vu("LOGIN_FAILED_SCREEN"),!$r.connectors)throw new C("Connector not initialized");$u("AWAITING_CONNECTION");let ju=new URL(window.location.href);ju.searchParams.delete("privy_connector"),ju.searchParams.delete("privy_wallet_client"),window.history.pushState({},"",ju),Io(Ql,gu,uu)};reactExports.useEffect(()=>{Ur&&Hr&&Vr===null&&$r.getAuthenticatedUser().then(Gr)},[Ur,Hr,Vr,$r]);let Ru=()=>{In(!0),$u("LINK_WALLET_SCREEN")},Bu=Hl=>{if(!Hr||!Vr)return!1;for(let Ql of Vr.linkedAccounts)if(Ql.type==="wallet"&&Ql.address===Hl.address)return!0;return!1},Ku=async Hl=>{if(!$r.connectors)throw new C("Connector not initialized");let Ql=$r.connectors.findWalletConnector(Hl.connectorType,Hl.walletClientType)||null;Ro(gu=>({...gu,connector:Ql,status:"connected",connectError:null,connectRetry:x})),uu(Hl),Vu("AWAITING_CONNECTION")},qu=async(Hl,Ql)=>{if(!$r.connectors)throw new C("Connector not initialized");await Io(Hl,Ql,uu)},Hu=async(Hl,Ql)=>{if(!na.fiatOnRamp.enabled)throw new C("Fiat on-ramp is not enabled");if(!Ql||!Ql.provider||Ql.provider==="moonpay"){let{signedUrl:gu,externalTransactionId:ju}=await qc($r,Hl,(Ql==null?void 0:Ql.config)??{},na.appearance.palette,na.fiatOnRamp.useSandbox);return{signedUrl:gu,externalTransactionId:ju}}else throw new C("Unsupported fund provider. Currently supported option is `moonpay`.")},Ju=()=>{Zn(Hl=>{var gu;let Ql=((gu=$r.connectors)==null?void 0:gu.wallets.map(ju=>({...ju,linked:Bu(ju),loginOrLink:async()=>{if(!await ju.isConnected())throw new C("Wallet is not connected");if(ju.connectorType==="embedded"&&ju.walletClientType==="privy")throw new C("Cannot link or login with embedded wallet");Ku(ju)},fund:async cp=>{let{signedUrl:op,externalTransactionId:Pp}=await Hu(ju.address,cp);Vo({fiatOnRampPrompt:{signedUrl:op},fiatOnRampStatus:{externalTransactionId:Pp}}),$u("FIAT_ON_RAMP_PROMPT_SCREEN")},unlink:async()=>{if(!Hr)throw new C("User is not authenticated.");if(ju.connectorType==="embedded"&&ju.walletClientType==="privy")throw new C("Cannot unlink an embedded wallet");let cp=await $r.unlinkWallet(ju.address);Gr(cp)}})))||[];return cn(Hl,Ql)?Hl:Ql})};reactExports.useEffect(()=>{Ju()},[Vr==null?void 0:Vr.linkedAccounts,Hr,Ur]),reactExports.useEffect(()=>{if(Ur){if(!$r.connectors)throw new C("Connector not initialized");Ju(),$r.connectors.on("walletsUpdated",Ju)}},[Ur]);let Rl=()=>{$u(Hr?"CONNECT_ONLY_AUTHENTICATED_SCREEN":"CONNECT_ONLY_LANDING_SCREEN")};reactExports.useEffect(()=>{if(!Gn[0])return;let Hl=Gn[0],Ql=no.current.find(ju=>ju.address===Hl.address),gu=Vr==null?void 0:Vr.linkedAccounts.find(ju=>ju.type==="wallet"&&ju.address===Hl.address);if(!Ql&&gu){let ju=Object.assign({},Vr);ju.wallet=gu&&{address:gu.address,chainType:gu.chainType,chainId:gu.chainId,walletClient:gu.walletClient,walletClientType:gu.walletClientType,connectorType:gu.connectorType},Gr(ju)}no.current=Gn},[Gn]);let Co=async(Hl,Ql)=>{var cp,op,Pp,Ep;if(Z(Hl))throw se(hu,"createWallet","onError","embedded_wallet_already_exists"),new Error("Only one Privy wallet per user is currently allowed");let[gu,ju]=await Promise.all([du.initializeWalletProxy(Ql),At()]);if(!gu&&((op=(cp=Nr.config)==null?void 0:cp.customAuth)!=null&&op.enabled))throw se(hu,"createWallet","onError","unknown_embedded_wallet_error"),new Error("Failed to connect to wallet proxy");if(!gu||!ju||(Ep=(Pp=Nr.config)==null?void 0:Pp.embeddedWallets)!=null&&Ep.requireUserPasswordOnCreate)return new Promise((fp,vp)=>{Qo(!0),Vo({createWallet:{onSuccess:a0=>{se(hu,"createWallet","onSuccess",a0),fp(a0)},onFailure:a0=>{se(hu,"createWallet","onError","unknown_embedded_wallet_error"),vp(a0)},callAuthOnSuccessOnClose:!1}}),$u("EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN")});{await gu.create({accessToken:ju});let fp=await du.refreshUser(),vp=Z(fp);if(!vp)throw se(hu,"createWallet","onError","unknown_embedded_wallet_error"),new Error("Failed to create wallet");return se(hu,"createWallet","onSuccess",vp),vp}},No=Hl=>{if(!na.chains.map(Ql=>Ql.id).includes(Hl))throw new F(`Chain ID ${Hl} is not supported. It must be added to the config.supportedChains property of the PrivyProvider.`,"unsupported_chain_id")},Jl={ready:Ur,authenticated:Hr,user:Vr,walletConnectors:$r.connectors||null,connectWallet:Rl,linkWallet:Ru,linkEmail:()=>{if(Vr!=null&&Vr.email)throw new C("User already has an email linked to their account.");In(!0),$u("LINK_EMAIL_SCREEN")},linkPhone:()=>{if(Vr!=null&&Vr.phone)throw new C("User already has a phone number linked to their account.");In(!0),$u("LINK_PHONE_SCREEN")},linkGoogle:async()=>{if(Vr!=null&&Vr.google)throw new C("User already has a Google account linked to their account.");await du.initLoginWithOAuth("google")},linkTwitter:async()=>{if(Vr!=null&&Vr.twitter)throw new C("User already has a Twitter account linked to their account.");await du.initLoginWithOAuth("twitter")},linkDiscord:async()=>{if(Vr!=null&&Vr.discord)throw new C("User already has a Discord account linked to their account.");await du.initLoginWithOAuth("discord")},linkGithub:async()=>{if(Vr!=null&&Vr.github)throw new C("User already has a Github account linked to their account.");await du.initLoginWithOAuth("github")},linkTiktok:async()=>{if(Vr!=null&&Vr.tiktok)throw new C("User already has a Tiktok account linked to their account.");await du.initLoginWithOAuth("tiktok")},linkLinkedIn:async()=>{if(Vr!=null&&Vr.linkedin)throw new C("User already has a LinkedIn account linked to their account.");await du.initLoginWithOAuth("linkedin")},linkApple:async()=>{await du.initLoginWithOAuth("apple")},login:async()=>{if(Ur||(await new Promise(Hl=>{Sl(()=>Hl)}),Sl(null)),Hr){console.warn("Attempted to log in, but user is already logged in. Use a `link` helper instead.");return}co(!0),Vu()},logout:async()=>{await $r.logout(),Gr(null),qr(!1),io(null),se(hu,"logout","onSuccess"),In(!1),Lr(!1),z.del(gr)},getAccessToken:()=>$r.getAccessToken(),getEthereumProvider:()=>{var gu;if(!Vr||!Vr.wallet)return new X;let Hl=Gn.find(ju=>Vr.wallet&&ju.address===Vr.wallet.address),Ql=(gu=$r.connectors)==null?void 0:gu.walletConnectors.find(ju=>ju.wallets.find(cp=>cp.address===(Hl==null?void 0:Hl.address)));return!Hl||!Ql?new X:Ql.proxyProvider},getEthersProvider:()=>{var gu;if(!Vr||!Vr.wallet)return new Web3Provider(new ht(new X));let Hl=Gn.find(ju=>Vr.wallet&&ju.address===Vr.wallet.address),Ql=(gu=$r.connectors)==null?void 0:gu.walletConnectors.find(ju=>ju.wallets.find(cp=>cp.address===(Hl==null?void 0:Hl.address)));return!Hl||!Ql?new Web3Provider(new ht(new X)):new Web3Provider(new ht(Ql.proxyProvider))},getWeb3jsProvider:()=>{var gu;if(!Vr||!Vr.wallet)return new qt(new X);let Hl=Gn.find(ju=>Vr.wallet&&ju.address===Vr.wallet.address),Ql=(gu=$r.connectors)==null?void 0:gu.walletConnectors.find(ju=>ju.wallets.find(cp=>cp.address===(Hl==null?void 0:Hl.address)));return!Hl||!Ql?new qt(new X):new qt(Ql.proxyProvider)},unlinkWallet:async Hl=>{let Ql=await $r.unlinkWallet(Hl);return Gr(Ql),Ql},unlinkEmail:async Hl=>{let Ql=await $r.unlinkEmail(Hl);return Gr(Ql),Ql},unlinkPhone:async Hl=>{let Ql=await $r.unlinkPhone(Hl);return Gr(Ql),Ql},unlinkGoogle:async Hl=>{let Ql=await $r.unlinkOAuth("google",Hl);return Gr(Ql),Ql},unlinkTwitter:async Hl=>{let Ql=await $r.unlinkOAuth("twitter",Hl);return Gr(Ql),Ql},unlinkDiscord:async Hl=>{let Ql=await $r.unlinkOAuth("discord",Hl);return Gr(Ql),Ql},unlinkGithub:async Hl=>{let Ql=await $r.unlinkOAuth("github",Hl);return Gr(Ql),Ql},unlinkTiktok:async Hl=>{let Ql=await $r.unlinkOAuth("tiktok",Hl);return Gr(Ql),Ql},unlinkLinkedIn:async Hl=>{let Ql=await $r.unlinkOAuth("linkedin",Hl);return Gr(Ql),Ql},unlinkApple:async Hl=>{let Ql=await $r.unlinkOAuth("apple",Hl);return Gr(Ql),Ql},setActiveWallet:async Hl=>{let Ql=Gn.find(ju=>getAddress(ju.address)===getAddress(Hl)),gu=Vr==null?void 0:Vr.linkedAccounts.find(ju=>ju.type==="wallet"&&getAddress(ju.address)===getAddress(Hl));if(!Ql||!await Ql.isConnected())jo(Hl),Ru();else if(!Ql.linked)Ql.loginOrLink();else{let ju=Object.assign({},Vr);ju.wallet=gu&&{address:gu.address,chainType:gu.chainType,chainId:gu.chainId,walletClient:gu.walletClient,walletClientType:gu.walletClientType,connectorType:gu.connectorType},Gr(ju)}},forkSession:()=>$r.forkSession(),createWallet:async()=>{if(!Hr||!Vr)throw se(hu,"createWallet","onError","must_be_authenticated"),new Error("User must be authenticated before creating a Privy wallet");return Co(Vr,15e3)},setWalletPassword:()=>new Promise((Hl,Ql)=>{if(!Hr||!Vr){Ql(new Error("User must be authenticated before adding password to Privy wallet"));return}let gu=Z(Vr);if(!gu||!Kl){Ql(new Error("Must have a Privy wallet to add a password"));return}if(gu.recoveryMethod==="user-passcode"){Ql(new Error("Cannot set password. Embedded wallet already has a password."));return}Qo(!0),Vo({setWalletPassword:{onSuccess:Hl,onFailure:Ql,callAuthOnSuccessOnClose:!1},connectWallet:{onCompleteNavigateTo:"EMBEDDED_WALLET_PASSWORD_UPDATE_SPLASH_SCREEN",onFailure:Ql}}),$u("EMBEDDED_WALLET_CONNECTING_SCREEN")}),signMessage:(Hl,Ql)=>new Promise(async(gu,ju)=>{if(!Hr||!Vr){ju(new Error("User must be authenticated before signing with a Privy wallet"));return}let cp=Z(Vr);if(!cp){ju(new Error("Must have a Privy wallet before signing"));return}if(typeof Hl!="string"||Hl.length<1){ju(new Error("Message must be a non-empty string"));return}Qo(!0);let op=async()=>{if(!Hr)return ju(new Error("User must be authenticated before signing with a Privy wallet")),null;let Pp=await At();if(Kl&&Pp)try{if(!await du.recoverEmbeddedWallet())return ju(new Error("Unable to connect to wallet")),null;$r.createAnalyticsEvent("embedded_wallet_sign_message_started",{walletAddress:cp.address});let{response:Ep}=await Kl.rpc({accessToken:Pp,address:cp.address,request:{method:"personal_sign",params:[Hl,cp.address]}}),fp=Ep.data;return $r.createAnalyticsEvent("embedded_wallet_sign_message_completed",{walletAddress:cp.address}),fp}catch(Ep){return ju(Ep),null}else return null};if(na.embeddedWallets.noPromptOnSignature){Ql&&console.warn("uiOptions defined with `noPromptOnSignature` set to true in app config");let Pp=await op();Pp?gu(Pp):ju(new Ee("Unable to sign message"))}else Vo({signMessage:{message:Hl,confirmAndSignMessage:op,onSuccess:fp=>{gu(fp)},onFailure:fp=>{ju(fp)},uiOptions:Ql||{}},connectWallet:{onCompleteNavigateTo:"EMBEDDED_WALLET_SIGN_REQUEST_SCREEN",onFailure:ju}}),$u("EMBEDDED_WALLET_CONNECTING_SCREEN")}),sendTransaction:(Hl,Ql,gu)=>new Promise(async(ju,cp)=>{var a0,r0;if(!Hr||!Vr){cp(new Error("User must be authenticated before signing with a Privy wallet"));return}let op=Z(Vr);if(!op){cp(new Error("Must have a Privy wallet before signing"));return}Qo(!0);let Pp=(r0=(a0=$r.connectors)==null?void 0:a0.findWalletConnector("embedded","privy"))==null?void 0:r0.proxyProvider,Ep=Hl.chainId||Pp.chainId;No(Ep);let fp=Object.assign({},Hl,{chainId:Ep}),vp=async()=>{let e0=await At();if(!e0||!Kl){cp(new Error("Must have valid access token and Privy wallet to send transaction"));return}try{if(!await du.recoverEmbeddedWallet()){cp(new Error("Unable to connect to wallet"));return}let g0=new StaticJsonRpcProvider(tt(fp.chainId,na.chains,na.rpcConfig)),o0=await di(op.address,fp,g0),n0=await pi(e0,op.address,Kl,o0,g0);ju(n0)}catch(g0){cp(g0)}};na.embeddedWallets.noPromptOnSignature?(Ql&&console.warn("uiOptions defined with `noPromptOnSignature` set to true in app config"),vp()):(Vo({connectWallet:{onCompleteNavigateTo:"EMBEDDED_WALLET_SEND_TRANSACTION_SCREEN",onFailure:cp},sendTransaction:{transactionRequest:fp,onSuccess:ju,onFailure:cp,uiOptions:Ql||{},fundWalletConfig:gu}}),$u("EMBEDDED_WALLET_CONNECTING_SCREEN"))}),exportWallet:()=>new Promise((Hl,Ql)=>{if(!Hr||!Vr){Ql(new Error("User must be authenticated before exporting their Privy wallet"));return}if(!Z(Vr)){Ql(new Error("Must have a Privy wallet before exporting"));return}Qo(!0);let gu={onCompleteNavigateTo:"EMBEDDED_WALLET_KEY_EXPORT_SCREEN",onFailure:Ql},ju={appId:Nr.appId,origin:$r.apiUrl,onSuccess:Hl,onFailure:Ql};Vo({keyExport:ju,connectWallet:gu}),$u("EMBEDDED_WALLET_CONNECTING_SCREEN")})};su=Jl.signMessage,lu=Jl.sendTransaction;let du=(()=>({isNewUserThisSession:ho,isLinking:Cn,linkingHint:fo,walletConnectionStatus:_o,rpcConfig:na.rpcConfig,chains:na.chains,nativeTokenSymbolForChainId:Hl=>{var Ql;return(Ql=na.chains.find(gu=>gu.id===Number(Hl)))==null?void 0:Ql.nativeCurrency.symbol},captchaData:{ready:ga,enabled:na.captchaEnabled,execute:()=>{let Hl=window.turnstile;if(!Hl)return;let Ql=Hl.render("#cf-turnstile",{sitekey:Ms,action:na.id,callback:Xo,"error-callback":Ol,"expired-callback":()=>{try{Hl.reset(Gl),Ol(void 0),Xo(void 0)}catch{Ol("expired_and_failed_reset")}},"unsupported-callback":()=>{console.warn("Browser does not support Turnstile.")}});Ql||console.warn("Failed to render challenge."),So(Ql)},remove:()=>{let Hl=window.turnstile;!(Hl!=null&&Hl.remove)||!Gl||(Hl.remove(Gl),So(void 0),Ol(void 0),Xo(void 0))},token:Bo,error:Al},initializeWalletProxy:async Hl=>{if(Kl)return Kl;let Ql=new Promise(cp=>{Eo(()=>op=>cp(op))}),gu=new Promise(cp=>setTimeout(()=>cp(null),Hl)),ju=await Promise.race([Ql,gu]);return Eo(null),ju},getAuthFlow:()=>$r.authFlow,getAuthMeta:()=>{var Hl;return(Hl=$r.authFlow)==null?void 0:Hl.meta},closePrivyModal:(Hl={shouldCallAuthOnSuccess:!0})=>{var gu;let Ql=Ur&&Hr&&Vr;Hl.shouldCallAuthOnSuccess&&Ql?(se(hu,"login","onComplete",Vr,ho,!1),(gu=Nr.onSuccess)==null||gu.call(Nr,Vr,ho)):lo&&se(hu,"login","onError","exited_auth_flow"),$r.authFlow=void 0,jo(null),io(null),co(!1),In(!1),xo(!1),Lr(!1),$r.createAnalyticsEvent("modal_closed")},connectWallet:Io,initLoginWithWallet:qu,loginWithWallet:async()=>{if(!Ur)throw new fr;if(!($r.authFlow instanceof go))throw new C("Must initialize SIWE flow first.");let Hl,Ql;if(Hr)Hl=await $r.link();else try{({user:Hl,isNewUser:Ql}=await $r.authenticate())}catch(gu){throw se(hu,"login","onError",gu.privyErrorCode||"generic_connect_wallet_error"),gu}Gr(Hl||Vr||null),xo(Ql||!1),qr(!0)},initLoginWithOAuth:async Hl=>{$r.startAuthFlow(new Gt(Hl));let Ql=await $r.authFlow.getAuthorizationUrl();Ql&&Ql.url&&window.location.assign(Ql.url)},loginWithOAuth:async()=>{if(!($r.authFlow instanceof Gt))throw new C("Must initialize OAuth flow before calling loginWithOAuth");let Hl,Ql;if(Hr)Hl=await $r.link();else try{({user:Hl,isNewUser:Ql}=await $r.authenticate())}catch(gu){throw se(hu,"login","onError",gu.privyErrorCode||"unknown_auth_error"),gu}Gr(Hl),xo(Ql||!1),qr(!0)},initLoginWithEmail:async(Hl,Ql)=>{let gu=new yo(Hl,Ql);$r.startAuthFlow(gu);try{await gu.sendCodeEmail()}catch(ju){throw se(hu,"login","onError",ju.privyErrorCode||"unknown_auth_error"),ju}},initLoginWithSms:async(Hl,Ql)=>{let gu=new vo(Hl,Ql);$r.startAuthFlow(gu);try{await gu.sendSmsCode()}catch(ju){throw se(hu,"login","onError",ju.privyErrorCode||"unknown_auth_error"),ju}},resendEmailCode:async()=>{var Hl;await((Hl=$r.authFlow)==null?void 0:Hl.sendCodeEmail())},resendSmsCode:async()=>{var Hl;await((Hl=$r.authFlow)==null?void 0:Hl.sendSmsCode())},loginWithCode:async Hl=>{if(!Ur)throw new fr;if($r.authFlow instanceof yo)$r.authFlow.meta.emailCode=Hl.trim();else if($r.authFlow instanceof vo)$r.authFlow.meta.smsCode=Hl.trim();else throw new C("Must initialize a passwordless code flow first");let Ql,gu;Hr?Ql=await $r.link():{user:Ql,isNewUser:gu}=await $r.authenticate(),Gr(Ql||Vr||null),xo(gu||!1),qr(!0)},refreshUser:async()=>{let Hl=await $r.getAuthenticatedUser();return Gr(Hl),Hl},walletProxy:Kl,createAnalyticsEvent:(Hl,Ql,gu)=>$r.createAnalyticsEvent(Hl,Ql,gu),getUsdTokenPrice:Hl=>$r.getUsdTokenPrice(Hl),recoverEmbeddedWallet:async()=>new Promise(async(Hl,Ql)=>{let gu=Vr==null?void 0:Vr.linkedAccounts.find(cp=>cp.type==="wallet"&&cp.walletClientType==="privy"),ju=await At();if(!ju||!Kl||!gu){Ql(new Error("Must have valid access token and Privy wallet to recover wallet"));return}Qo(!0);try{await Kl.connect({accessToken:ju,address:gu.address}),Hl(!0)}catch(cp){Jo(cp)&&gu.recoveryMethod==="privy"?($r.createAnalyticsEvent("embedded_wallet_pinless_recovery_started",{walletAddress:gu.address}),(await Kl.recover({address:gu.address,accessToken:ju})).address||Ql(new Error("Unable to recover wallet")),$r.createAnalyticsEvent("embedded_wallet_recovery_completed",{walletAddress:gu.address}),Hl(!0)):Jo(cp)?(Vo({recoverWallet:{privyWallet:gu,onFailure:Ql,onSuccess:()=>Hl(!0)}}),$u("EMBEDDED_WALLET_RECOVERY_SCREEN")):Ql(cp)}}),getFiatOnRampConfig:Hu,updateWallets:()=>Ju()}))();cu=du.recoverEmbeddedWallet;let yu=reactExports.useMemo(()=>({wallets:Gn}),[Gn]);return jsxRuntimeExports.jsx(rt.Provider,{value:Jl,children:jsxRuntimeExports.jsx(os.Provider,{value:hu,children:jsxRuntimeExports.jsxs(Ya.Provider,{value:yu,children:[Nr.children,jsxRuntimeExports.jsxs(Bi.Provider,{value:du,children:[jsxRuntimeExports.jsx(Ip,{theme:{...na.appearance.palette||{}}}),jsxRuntimeExports.jsx(ll,{appConfig:na,data:Ml,setModalData:Vo,setInitialScreen:io,initialScreen:so,visible:jr,authenticated:Hr,children:jr?jsxRuntimeExports.jsx(Mp,{}):null}),mo&&wu.id?jsxRuntimeExports.jsx(ru,{appId:Nr.appId,origin:$r.apiUrl,onLoad:au,onLoadFailed:()=>null}):null]}),na.captchaEnabled&&jsxRuntimeExports.jsx(Dp,{onLoad:()=>vu(!0)})]})})})},dist={};Object.defineProperty(dist,"__esModule",{value:!0});var truncateRegex=/^(0x[a-zA-Z0-9]{4})[a-zA-Z0-9]+([a-zA-Z0-9]{4})$/,truncateEthAddress=function(Nr){var $r=Nr.match(truncateRegex);return $r?$r[1]+"…"+$r[2]:Nr},_default=dist.default=truncateEthAddress;const WalletIcon="/IncoHangman/assets/wallet_icon-5495f594.svg";function noop(){}function run(Nr){return Nr()}function blank_object(){return Object.create(null)}function run_all(Nr){Nr.forEach(run)}function is_function(Nr){return typeof Nr=="function"}function safe_not_equal(Nr,$r){return Nr!=Nr?$r==$r:Nr!==$r||Nr&&typeof Nr=="object"||typeof Nr=="function"}let src_url_equal_anchor;function src_url_equal(Nr,$r){return Nr===$r?!0:(src_url_equal_anchor||(src_url_equal_anchor=document.createElement("a")),src_url_equal_anchor.href=$r,Nr===src_url_equal_anchor.href)}function is_empty(Nr){return Object.keys(Nr).length===0}function append(Nr,$r){Nr.appendChild($r)}function insert(Nr,$r,jr){Nr.insertBefore($r,jr||null)}function detach(Nr){Nr.parentNode&&Nr.parentNode.removeChild(Nr)}function destroy_each(Nr,$r){for(let jr=0;jrNr.indexOf(Lr)===-1?$r.push(Lr):jr.push(Lr)),jr.forEach(Lr=>Lr()),render_callbacks=$r}const outroing=new Set;let outros;function group_outros(){outros={r:0,c:[],p:outros}}function check_outros(){outros.r||run_all(outros.c),outros=outros.p}function transition_in(Nr,$r){Nr&&Nr.i&&(outroing.delete(Nr),Nr.i($r))}function transition_out(Nr,$r,jr,Lr){if(Nr&&Nr.o){if(outroing.has(Nr))return;outroing.add(Nr),outros.c.push(()=>{outroing.delete(Nr),Lr&&(jr&&Nr.d(1),Lr())}),Nr.o($r)}else Lr&&Lr()}function ensure_array_like(Nr){return(Nr==null?void 0:Nr.length)!==void 0?Nr:Array.from(Nr)}function create_component(Nr){Nr&&Nr.c()}function mount_component(Nr,$r,jr){const{fragment:Lr,after_update:Ur}=Nr.$$;Lr&&Lr.m($r,jr),add_render_callback(()=>{const Wr=Nr.$$.on_mount.map(run).filter(is_function);Nr.$$.on_destroy?Nr.$$.on_destroy.push(...Wr):run_all(Wr),Nr.$$.on_mount=[]}),Ur.forEach(add_render_callback)}function destroy_component(Nr,$r){const jr=Nr.$$;jr.fragment!==null&&(flush_render_callbacks(jr.after_update),run_all(jr.on_destroy),jr.fragment&&jr.fragment.d($r),jr.on_destroy=jr.fragment=null,jr.ctx=[])}function make_dirty(Nr,$r){Nr.$$.dirty[0]===-1&&(dirty_components.push(Nr),schedule_update(),Nr.$$.dirty.fill(0)),Nr.$$.dirty[$r/31|0]|=1<<$r%31}function init(Nr,$r,jr,Lr,Ur,Wr,Hr=null,qr=[-1]){const Vr=current_component;set_current_component(Nr);const Gr=Nr.$$={fragment:null,ctx:[],props:Wr,update:noop,not_equal:Ur,bound:blank_object(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map($r.context||(Vr?Vr.$$.context:[])),callbacks:blank_object(),dirty:qr,skip_bound:!1,root:$r.target||Vr.$$.root};Hr&&Hr(Gr.root);let Cn=!1;if(Gr.ctx=jr?jr(Nr,$r.props||{},(In,Gn,...Zn)=>{const no=Zn.length?Zn[0]:Gn;return Gr.ctx&&Ur(Gr.ctx[In],Gr.ctx[In]=no)&&(!Gr.skip_bound&&Gr.bound[In]&&Gr.bound[In](no),Cn&&make_dirty(Nr,In)),Gn}):[],Gr.update(),Cn=!0,run_all(Gr.before_update),Gr.fragment=Lr?Lr(Gr.ctx):!1,$r.target){if($r.hydrate){const In=children($r.target);Gr.fragment&&Gr.fragment.l(In),In.forEach(detach)}else Gr.fragment&&Gr.fragment.c();$r.intro&&transition_in(Nr.$$.fragment),mount_component(Nr,$r.target,$r.anchor),flush()}set_current_component(Vr)}class SvelteComponent{constructor(){P_(this,"$$");P_(this,"$$set")}$destroy(){destroy_component(this,1),this.$destroy=noop}$on($r,jr){if(!is_function(jr))return noop;const Lr=this.$$.callbacks[$r]||(this.$$.callbacks[$r]=[]);return Lr.push(jr),()=>{const Ur=Lr.indexOf(jr);Ur!==-1&&Lr.splice(Ur,1)}}$set($r){this.$$set&&!is_empty($r)&&(this.$$.skip_bound=!0,this.$$set($r),this.$$.skip_bound=!1)}}const PUBLIC_VERSION="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(PUBLIC_VERSION);const Confetti_svelte_svelte_type_style_lang="";function get_each_context$1(Nr,$r,jr){const Lr=Nr.slice();return Lr[18]=$r[jr],Lr}function create_if_block$1(Nr){let $r,jr=ensure_array_like({length:Nr[6]}),Lr=[];for(let Ur=0;Ur{!io||qr||Gn=="infinite"||setTimeout(()=>jr(13,lo=!0),(Hr+Vr[1])*Gn)});function co(){return Cn.length?Cn[Math.round(Math.random()*(Cn.length-1))]:`hsl(${Math.round(randomBetween(Gr[0],Gr[1]))}, 75%, 50%`}return Nr.$$set=_o=>{"size"in _o&&jr(0,Lr=_o.size),"x"in _o&&jr(1,Ur=_o.x),"y"in _o&&jr(2,Wr=_o.y),"duration"in _o&&jr(3,Hr=_o.duration),"infinite"in _o&&jr(4,qr=_o.infinite),"delay"in _o&&jr(5,Vr=_o.delay),"colorRange"in _o&&jr(15,Gr=_o.colorRange),"colorArray"in _o&&jr(16,Cn=_o.colorArray),"amount"in _o&&jr(6,In=_o.amount),"iterationCount"in _o&&jr(7,Gn=_o.iterationCount),"fallDistance"in _o&&jr(8,Zn=_o.fallDistance),"rounded"in _o&&jr(9,no=_o.rounded),"cone"in _o&&jr(10,ho=_o.cone),"noGravity"in _o&&jr(11,xo=_o.noGravity),"xSpread"in _o&&jr(12,so=_o.xSpread),"destroyOnComplete"in _o&&jr(17,io=_o.destroyOnComplete)},[Lr,Ur,Wr,Hr,qr,Vr,In,Gn,Zn,no,ho,xo,so,lo,co,Gr,Cn,io]}class Confetti extends SvelteComponent{constructor($r){super(),init(this,$r,instance$1,create_fragment$1,safe_not_equal,{size:0,x:1,y:2,duration:3,infinite:4,delay:5,colorRange:15,colorArray:16,amount:6,iterationCount:7,fallDistance:8,rounded:9,cone:10,noGravity:11,xSpread:12,destroyOnComplete:17})}}const hangman_0="/IncoHangman/assets/hangman_0-b2cad2aa.png",hangman_1="/IncoHangman/assets/hangman_1-803f1fe5.png",hangman_2="/IncoHangman/assets/hangman_2-4f35571c.png",hangman_3="/IncoHangman/assets/hangman_3-6717656a.png",hangman_4="/IncoHangman/assets/hangman_4-9fcf1839.png",hangman_5="/IncoHangman/assets/hangman_5-e4dd913a.png",hangman_6="/IncoHangman/assets/hangman_6-04a66a6f.png",hangman_7="/IncoHangman/assets/hangman_7-2b2aef72.png",hangman_8="/IncoHangman/assets/hangman_8-67a59ea2.png",hangman_9="/IncoHangman/assets/hangman_9-15ebbed8.png",hangman_10="/IncoHangman/assets/hangman_10-eeb33293.png",hangman_11="/IncoHangman/assets/hangman_11-a9e9b187.png",Game_svelte_svelte_type_style_lang="";function get_each_context(Nr,$r,jr){const Lr=Nr.slice();return Lr[9]=$r[jr],Lr}function get_each_context_1(Nr,$r,jr){const Lr=Nr.slice();return Lr[9]=$r[jr],Lr}function create_each_block_1(Nr){let $r,jr=Nr[9]+"",Lr;return{c(){$r=element("span"),Lr=text(jr),attr($r,"class","Letter svelte-vcspso")},m(Ur,Wr){insert(Ur,$r,Wr),append($r,Lr)},p(Ur,Wr){Wr&2&&jr!==(jr=Ur[9]+"")&&set_data(Lr,jr)},d(Ur){Ur&&detach($r)}}}function create_each_block(Nr){let $r,jr,Lr=Nr[9]+"",Ur,Wr;return{c(){$r=element("div"),jr=element("p"),Ur=text(Lr),Wr=space(),attr($r,"class","Underscore svelte-vcspso")},m(Hr,qr){insert(Hr,$r,qr),append($r,jr),append(jr,Ur),append($r,Wr)},p(Hr,qr){qr&8&&Lr!==(Lr=Hr[9]+"")&&set_data(Ur,Lr)},d(Hr){Hr&&detach($r)}}}function create_if_block(Nr){let $r,jr,Lr;return jr=new Confetti({props:{size:"30",x:[-5,5],y:[0,.1],delay:[200,3500],duration:"5000",amount:"500",fallDistance:"100vh"}}),{c(){$r=element("div"),create_component(jr.$$.fragment),attr($r,"class","Confetti svelte-vcspso")},m(Ur,Wr){insert(Ur,$r,Wr),mount_component(jr,$r,null),Lr=!0},i(Ur){Lr||(transition_in(jr.$$.fragment,Ur),Lr=!0)},o(Ur){transition_out(jr.$$.fragment,Ur),Lr=!1},d(Ur){Ur&&detach($r),destroy_component(jr)}}}function create_fragment(Nr){let $r,jr,Lr,Ur,Wr,Hr,qr,Vr,Gr,Cn,In,Gn=ensure_array_like(Nr[1]),Zn=[];for(let so=0;so{xo=null}),check_outros())},i(so){In||(transition_in(xo),In=!0)},o(so){transition_out(xo),In=!1},d(so){so&&detach($r),destroy_each(Zn,so),destroy_each(ho,so),xo&&xo.d()}}}function instance($$self,$$props,$$invalidate){let wrongWords,drawingId,splitWord;const drawings=[hangman_0,hangman_1,hangman_2,hangman_3,hangman_4,hangman_5,hangman_6,hangman_7,hangman_8,hangman_9,hangman_10,hangman_11];let{wrongGuesses=[]}=$$props,{lives=11}=$$props,{hasWon=!1}=$$props,{currentWord="____"}=$$props;var rpGlobal=typeof window<"u"?window:global;return rpGlobal.rpDsp=rpGlobal.rpDsp||function(){},rpGlobal.rpDsp("SvelteReactiveEnable",{version:"0.8.3"}),$$self.$$set=Nr=>{"wrongGuesses"in Nr&&$$invalidate(5,wrongGuesses=Nr.wrongGuesses),"lives"in Nr&&$$invalidate(6,lives=Nr.lives),"hasWon"in Nr&&$$invalidate(0,hasWon=Nr.hasWon),"currentWord"in Nr&&$$invalidate(7,currentWord=Nr.currentWord)},$$self.$$.update=()=>{if($$self.$$.dirty&384){let svrp_start=Date.now(),svrp_exec=Math.random(),start_state=eval("{}");rpGlobal.rpDsp("SvelteReactiveStart",{statement:"splitWord = currentWord.split('');",filename:"/home/runner/work/IncoHangman/IncoHangman/src/Game.svelte",line:38,id:"vxra"},svrp_start,svrp_exec,start_state),$$invalidate(3,splitWord=currentWord.split("")),rpGlobal.rpDsp("SvelteReactiveEnd",{statement:"splitWord = currentWord.split('');",filename:"/home/runner/work/IncoHangman/IncoHangman/src/Game.svelte",line:38,id:"vxra"},svrp_start,svrp_exec,start_state,eval("{}"))}if($$self.$$.dirty&288){let svrp_start=Date.now(),svrp_exec=Math.random(),start_state=eval("{}");rpGlobal.rpDsp("SvelteReactiveStart",{statement:"drawingId = wrongGuesses.length;",filename:"/home/runner/work/IncoHangman/IncoHangman/src/Game.svelte",line:40,id:"9zEj"},svrp_start,svrp_exec,start_state),$$invalidate(2,drawingId=wrongGuesses.length),rpGlobal.rpDsp("SvelteReactiveEnd",{statement:"drawingId = wrongGuesses.length;",filename:"/home/runner/work/IncoHangman/IncoHangman/src/Game.svelte",line:40,id:"9zEj"},svrp_start,svrp_exec,start_state,eval("{}"))}if($$self.$$.dirty&288){let svrp_start=Date.now(),svrp_exec=Math.random(),start_state=eval("{}");rpGlobal.rpDsp("SvelteReactiveStart",{statement:`wrongWords = wrongGuesses.flatMap( +`,sv=({onLoad:Nr})=>{let $r=window;return reactExports.useEffect(()=>{if(document.getElementById("cf-script")!==null||$r.turnstile)return;$r.onloadTurnstileCallback=Nr;let jr=document.createElement("script");jr.setAttribute("src","https://challenges.cloudflare.com/turnstile/v0/api.js?onload=onloadTurnstileCallback&render=explicit"),jr.setAttribute("id","cf-script"),jr.setAttribute("async","true"),document.body.appendChild(jr)},[]),jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{})},Dp=sv,Up={id:42161,name:"Arbitrum One",network:"arbitrum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{alchemy:{http:["https://arb-mainnet.g.alchemy.com/v2"],webSocket:["wss://arb-mainnet.g.alchemy.com/v2"]},infura:{http:["https://arbitrum-mainnet.infura.io/v3"],webSocket:["wss://arbitrum-mainnet.infura.io/ws/v3"]},default:{http:["https://arb1.arbitrum.io/rpc"]},public:{http:["https://arb1.arbitrum.io/rpc"]}},blockExplorers:{etherscan:{name:"Arbiscan",url:"https://arbiscan.io"},default:{name:"Arbiscan",url:"https://arbiscan.io"}}},Fp={id:421613,name:"Arbitrum Goerli",network:"arbitrum-goerli",nativeCurrency:{name:"Goerli Ether",symbol:"AGOR",decimals:18},rpcUrls:{alchemy:{http:["https://arb-goerli.g.alchemy.com/v2"],webSocket:["wss://arb-goerli.g.alchemy.com/v2"]},infura:{http:["https://arbitrum-goerli.infura.io/v3"],webSocket:["wss://arbitrum-goerli.infura.io/ws/v3"]},default:{http:["https://goerli-rollup.arbitrum.io/rpc"]},public:{http:["https://goerli-rollup.arbitrum.io/rpc"]}},blockExplorers:{etherscan:{name:"Arbiscan",url:"https://goerli.arbiscan.io/"},default:{name:"Arbiscan",url:"https://goerli.arbiscan.io/"}},testnet:!0},Bp={id:43114,name:"Avalanche",network:"avalanche",nativeCurrency:{decimals:18,name:"Avalanche",symbol:"AVAX"},rpcUrls:{default:{http:["https://api.avax.network/ext/bc/C/rpc"]},public:{http:["https://api.avax.network/ext/bc/C/rpc"]}},blockExplorers:{etherscan:{name:"SnowTrace",url:"https://snowtrace.io"},default:{name:"SnowTrace",url:"https://snowtrace.io"}}},Hp={id:43113,name:"Avalanche Fuji",network:"avalanche-fuji",nativeCurrency:{decimals:18,name:"Avalanche Fuji",symbol:"AVAX"},rpcUrls:{default:{http:["https://api.avax-test.network/ext/bc/C/rpc"]},public:{http:["https://api.avax-test.network/ext/bc/C/rpc"]}},blockExplorers:{etherscan:{name:"SnowTrace",url:"https://testnet.snowtrace.io"},default:{name:"SnowTrace",url:"https://testnet.snowtrace.io"}},testnet:!0},Gp={id:8453,network:"base",name:"Base",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{blast:{http:["https://base-mainnet.blastapi.io"],webSocket:["wss://base-mainnet.blastapi.io"]},default:{http:["https://mainnet.base.org"]},public:{http:["https://mainnet.base.org"]}},blockExplorers:{etherscan:{name:"Basescan",url:"https://basescan.org"},default:{name:"Basescan",url:"https://basescan.org"}},testnet:!0},zp={id:84531,network:"base-goerli",name:"Base Goerli Testnet",nativeCurrency:{name:"Goerli Ether",symbol:"ETH",decimals:18},rpcUrls:{blast:{http:["https://base-goerli.blastapi.io"],webSocket:["wss://base-goerli.blastapi.io"]},default:{http:["https://goerli.base.org"]},public:{http:["https://goerli.base.org"]}},blockExplorers:{etherscan:{name:"Basescan",url:"https://goerli.basescan.org"},default:{name:"Basescan",url:"https://goerli.basescan.org"}},testnet:!0},$p={id:42220,name:"Celo Mainnet",network:"celo",nativeCurrency:{decimals:18,name:"CELO",symbol:"CELO"},rpcUrls:{default:{http:["https://forno.celo.org"]},infura:{http:["https://celo-mainnet.infura.io/v3"]},public:{http:["https://forno.celo.org"]}},blockExplorers:{default:{name:"Celo Explorer",url:"https://explorer.celo.org/mainnet"},etherscan:{name:"CeloScan",url:"https://celoscan.io"}},testnet:!1},Vp={id:44787,name:"Celo Alfajores Testnet",network:"celo-alfajores",nativeCurrency:{decimals:18,name:"CELO",symbol:"CELO"},rpcUrls:{default:{http:["https://alfajores-forno.celo-testnet.org"]},infura:{http:["https://celo-alfajores.infura.io/v3"]},public:{http:["https://alfajores-forno.celo-testnet.org"]}},blockExplorers:{default:{name:"Celo Explorer",url:"https://explorer.celo.org/alfajores"},etherscan:{name:"CeloScan",url:"https://alfajores.celoscan.io/"}},testnet:!0},qp={id:314,name:"Filecoin - Mainnet",network:"filecoin-mainnet",nativeCurrency:{decimals:18,name:"filecoin",symbol:"FIL"},rpcUrls:{default:{http:["https://api.node.glif.io/rpc/v1"]},public:{http:["https://api.node.glif.io/rpc/v1"]}},blockExplorers:{default:{name:"Filfox",url:"https://filfox.info/en"},filscan:{name:"Filscan",url:"https://filscan.io"},filscout:{name:"Filscout",url:"https://filscout.io/en"},glif:{name:"Glif",url:"https://explorer.glif.io"}}},jp={id:314159,name:"Filecoin - Calibration testnet",network:"filecoin-calibration",nativeCurrency:{decimals:18,name:"testnet filecoin",symbol:"tFIL"},rpcUrls:{default:{http:["https://api.calibration.node.glif.io/rpc/v1"]},public:{http:["https://api.calibration.node.glif.io/rpc/v1"]}},blockExplorers:{default:{name:"Filscan",url:"https://calibration.filscan.io"}}},Kp={id:5,network:"goerli",name:"Goerli",nativeCurrency:{name:"Goerli Ether",symbol:"ETH",decimals:18},rpcUrls:{alchemy:{http:["https://eth-goerli.g.alchemy.com/v2"],webSocket:["wss://eth-goerli.g.alchemy.com/v2"]},infura:{http:["https://goerli.infura.io/v3"],webSocket:["wss://goerli.infura.io/ws/v3"]},default:{http:["https://rpc.ankr.com/eth_goerli"]},public:{http:["https://rpc.ankr.com/eth_goerli"]}},blockExplorers:{etherscan:{name:"Etherscan",url:"https://goerli.etherscan.io"},default:{name:"Etherscan",url:"https://goerli.etherscan.io"}},testnet:!0},Yp={id:59144,network:"linea-mainnet",name:"Linea Mainnet",nativeCurrency:{name:"Linea Ether",symbol:"ETH",decimals:18},rpcUrls:{infura:{http:["https://linea-mainnet.infura.io/v3"],webSocket:["wss://linea-mainnet.infura.io/ws/v3"]},default:{http:["https://rpc.linea.build"],webSocket:["wss://rpc.linea.build"]},public:{http:["https://rpc.linea.build"],webSocket:["wss://rpc.linea.build"]}},blockExplorers:{default:{name:"Etherscan",url:"https://lineascan.build"},etherscan:{name:"Etherscan",url:"https://lineascan.build"}},testnet:!1},Jp={id:59140,network:"linea-testnet",name:"Linea Goerli Testnet",nativeCurrency:{name:"Linea Ether",symbol:"ETH",decimals:18},rpcUrls:{infura:{http:["https://linea-goerli.infura.io/v3"],webSocket:["wss://linea-goerli.infura.io/ws/v3"]},default:{http:["https://rpc.goerli.linea.build"],webSocket:["wss://rpc.goerli.linea.build"]},public:{http:["https://rpc.goerli.linea.build"],webSocket:["wss://rpc.goerli.linea.build"]}},blockExplorers:{default:{name:"Etherscan",url:"https://goerli.lineascan.build"},etherscan:{name:"Etherscan",url:"https://goerli.lineascan.build"}},testnet:!0},yi={id:1,network:"homestead",name:"Ethereum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{alchemy:{http:["https://eth-mainnet.g.alchemy.com/v2"],webSocket:["wss://eth-mainnet.g.alchemy.com/v2"]},infura:{http:["https://mainnet.infura.io/v3"],webSocket:["wss://mainnet.infura.io/ws/v3"]},default:{http:["https://cloudflare-eth.com"]},public:{http:["https://cloudflare-eth.com"]}},blockExplorers:{etherscan:{name:"Etherscan",url:"https://etherscan.io"},default:{name:"Etherscan",url:"https://etherscan.io"}}},Qp={id:10,name:"OP Mainnet",network:"optimism",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{alchemy:{http:["https://opt-mainnet.g.alchemy.com/v2"],webSocket:["wss://opt-mainnet.g.alchemy.com/v2"]},infura:{http:["https://optimism-mainnet.infura.io/v3"],webSocket:["wss://optimism-mainnet.infura.io/ws/v3"]},default:{http:["https://mainnet.optimism.io"]},public:{http:["https://mainnet.optimism.io"]}},blockExplorers:{etherscan:{name:"Etherscan",url:"https://optimistic.etherscan.io"},default:{name:"Optimism Explorer",url:"https://explorer.optimism.io"}}},Zp={id:420,name:"Optimism Goerli Testnet",network:"optimism-goerli",nativeCurrency:{name:"Goerli Ether",symbol:"ETH",decimals:18},rpcUrls:{alchemy:{http:["https://opt-goerli.g.alchemy.com/v2"],webSocket:["wss://opt-goerli.g.alchemy.com/v2"]},infura:{http:["https://optimism-goerli.infura.io/v3"],webSocket:["wss://optimism-goerli.infura.io/ws/v3"]},default:{http:["https://goerli.optimism.io"]},public:{http:["https://goerli.optimism.io"]}},blockExplorers:{etherscan:{name:"Etherscan",url:"https://goerli-optimism.etherscan.io"},default:{name:"Etherscan",url:"https://goerli-optimism.etherscan.io"}},testnet:!0},Xp={id:11155111,network:"sepolia",name:"Sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"SEP",decimals:18},rpcUrls:{alchemy:{http:["https://eth-sepolia.g.alchemy.com/v2"],webSocket:["wss://eth-sepolia.g.alchemy.com/v2"]},infura:{http:["https://sepolia.infura.io/v3"],webSocket:["wss://sepolia.infura.io/ws/v3"]},default:{http:["https://rpc.sepolia.org"]},public:{http:["https://rpc.sepolia.org"]}},blockExplorers:{etherscan:{name:"Etherscan",url:"https://sepolia.etherscan.io"},default:{name:"Etherscan",url:"https://sepolia.etherscan.io"}},testnet:!0},gi=[Up,Fp,Kp,Xp,yi,Qp,Zp,Fr,Br,$p,Vp,qp,jp,Gp,zp,Yp,Jp,Bp,Hp];new Set(gi.map(Nr=>Nr.id));var eu="#FFFFFF",dv="#000000",pv=eu,uv="#1E1E1D";function mv(Nr){return Nr<.8&&Nr>.2&&console.warn("Background color is not light or dark enough, which could lead to accessibility issues."),Nr>.5?"light":"dark"}function po(Nr,$r){let jr=Math.max(0,Math.min(1,Nr.toHsl().l+$r));return tinycolor({...Nr.toHsl(),l:jr})}function tu({backgroundTheme:Nr,accentHex:$r,successHex:jr="#51BA81",warnHex:Lr="#FFB74D",errorHex:Ur="#EC6351",whiteHex:Wr=eu,blackHex:Hr=dv}){let qr;switch(Nr){case"light":qr=pv;break;case"dark":qr=uv;break;default:qr=Nr;break}let Vr=tinycolor(qr),Gr=tinycolor($r),Cn=tinycolor(jr),In=tinycolor(Lr),Gn=tinycolor(Ur),Zn=mv(Vr.getLuminance()),no=po(Vr,Zn==="light"?-.04:.11),ho=po(Vr,Zn==="light"?-.88:.87),xo=po(Vr,Zn==="light"?-.77:.75),so=po(Vr,Zn==="light"?-.43:.45).desaturate(Zn==="light"?60:20),io=po(Vr,Zn==="light"?-.08:.25).desaturate(Zn==="light"?60:20),lo=po(Gr,.15),co=po(Gr,-.06),_o=tinycolor(Gr.getLuminance()>.5?Hr:Wr),Ro=po(Cn,-.16);return{colorScheme:Zn,background:Vr.toHslString(),background2:no.toHslString(),foreground:ho.toHslString(),foreground2:xo.toHslString(),foreground3:so.toHslString(),foreground4:io.toHslString(),accent:Gr.toHslString(),accentLight:lo.toHslString(),accentDark:co.toHslString(),foregroundAccent:_o.toHslString(),success:Cn.toHslString(),successDark:Ro.toHslString(),error:Gn.toHslString(),warn:In.toHslString()}}var uo={appearance:{theme:"light",accentColor:"#676FFF"},walletConnectCloudProjectId:Os,rpcConfig:{rpcUrls:{}},captchaEnabled:!1,_render:{inDialog:!0,inParentNodeId:null},fiatOnRamp:{useSandbox:!1}};function vi(Nr,$r){var io,lo,co,_o,Ro,fo,jo,Kl,au,wu,Au,na;let jr=["google","twitter","discord","tiktok","linkedin","github","apple"],Lr=(io=$r==null?void 0:$r.loginMethods)==null?void 0:io.filter(eo=>jr.includes(eo)),Ur=Lr==null?void 0:Lr.slice(0,5),Wr,Hr,qr,Vr,Gr,Cn,In,Gn,Zn,no;if($r!=null&&$r.loginMethods?(Wr=$r.loginMethods.includes("email"),Hr=$r.loginMethods.includes("sms"),qr=$r.loginMethods.includes("wallet"),Vr=Ur==null?void 0:Ur.includes("google"),Gr=Ur==null?void 0:Ur.includes("twitter"),Cn=Ur==null?void 0:Ur.includes("discord"),In=Ur==null?void 0:Ur.includes("tiktok"),Zn=Ur==null?void 0:Ur.includes("github"),Gn=Ur==null?void 0:Ur.includes("linkedin"),no=Ur==null?void 0:Ur.includes("apple")):(Wr=Nr.emailAuth,Hr=Nr.smsAuth,qr=Nr.walletAuth,Vr=Nr.googleOAuth,Gr=Nr.twitterOAuth,Cn=Nr.discordOAuth,Zn=Nr.githubOAuth,In=Nr.tiktokOAuth,Gn=Nr.linkedinOAuth,no=Nr.appleOAuth),Wr&&Hr&&(console.warn("Enabling both email and SMS passwordless is not currently supported. Disabling SMS."),Hr=!1),!Wr&&!Hr&&[Vr,Gr,Cn,Zn,In,Gn,no].some(eo=>eo))throw new Error("To enable social logins you must also enable either SMS or Email login");if(![Wr,Hr,qr,Vr,Gr,Cn,Zn,In,Gn,no].some(eo=>eo))throw new Error("You must enable at least one login method");let{chains:ho,defaultChain:xo}=hv($r==null?void 0:$r.additionalChains,$r==null?void 0:$r.supportedChains,$r==null?void 0:$r.defaultChain);Lr&&Lr.length>5&&console.warn("Max number of social logins allowed is 5. Any more have been removed.");let so=((lo=$r==null?void 0:$r.customAuth)==null?void 0:lo.getCustomAccessToken)&&((co=$r==null?void 0:$r.customAuth)==null?void 0:co.enabled)!==!1;return{id:Nr.id,name:Nr.name,allowlistConfig:Nr.allowlistConfig,appearance:{logo:((_o=$r==null?void 0:$r.appearance)==null?void 0:_o.logo)??Nr.logoUrl,palette:tu({backgroundTheme:((Ro=$r==null?void 0:$r.appearance)==null?void 0:Ro.theme)??uo.appearance.theme,accentHex:((fo=$r==null?void 0:$r.appearance)==null?void 0:fo.accentColor)??Nr.accentColor??uo.appearance.accentColor}),showWalletLoginFirst:((jo=$r==null?void 0:$r.appearance)==null?void 0:jo.showWalletLoginFirst)??Nr.showWalletLoginFirst},loginMethods:{wallet:qr,email:Wr,sms:Hr,google:Vr,twitter:Gr,discord:Cn,github:Zn,tiktok:In,linkedin:Gn,apple:no},legal:{termsAndConditionsUrl:((Kl=$r==null?void 0:$r.legal)==null?void 0:Kl.termsAndConditionsUrl)??Nr.termsAndConditionsUrl,privacyPolicyUrl:((au=$r==null?void 0:$r.legal)==null?void 0:au.privacyPolicyUrl)??Nr.privacyPolicyUrl},walletConnectCloudProjectId:($r==null?void 0:$r.walletConnectCloudProjectId)??Nr.walletConnectCloudProjectId??uo.walletConnectCloudProjectId,rpcConfig:($r==null?void 0:$r.rpcConfig)??uo.rpcConfig,chains:ho,defaultChain:xo,captchaEnabled:Nr.captchaEnabled??uo.captchaEnabled,embeddedWallets:{...Nr.embeddedWalletConfig,...so?{createOnLogin:"all-users",requireUserPasswordOnCreate:!1,noPromptOnSignature:!0}:{},...$r==null?void 0:$r.embeddedWallets},customAuth:so?{enabled:!0,...$r.customAuth}:void 0,fiatOnRamp:{enabled:Nr.fiatOnRampEnabled,useSandbox:((wu=$r==null?void 0:$r.fiatOnRamp)==null?void 0:wu.useSandbox)??uo.fiatOnRamp.useSandbox},loginConfig:{twitterOAuthOnMobileEnabled:Nr.twitterOAuthOnMobileEnabled??!1},render:{inDialog:((Au=$r==null?void 0:$r._render)==null?void 0:Au.inDialog)??uo._render.inDialog,inParentNodeId:((na=$r==null?void 0:$r._render)==null?void 0:na.inParentNodeId)??uo._render.inParentNodeId}}}function ou(Nr,$r){var jr;return(jr=Nr==null?void 0:Nr.appearance)!=null&&jr.logo&&typeof Nr.appearance.logo=="object"&&(Nr.appearance.logo="component"),{...Nr,legacyCreateEmbeddedWalletFlag:$r}}function hv(Nr,$r,jr){let Lr;if(Nr&&$r&&console.warn("You should only specify one of `additionalChains` or `supportedChains`. Using `supportedChains`."),$r){if($r.length===0)throw new Error("`supportedChains` must contain at least one chain");Lr=$r}else Lr=gi.concat(Nr??[]);let Ur=$r?Lr[0]:yi,Wr=jr??Ur;if(!Lr.find(Hr=>Hr.id===Wr.id))throw new Error("`defaultChain` must be included in `supportedChains`");return{chains:Lr,defaultChain:Wr}}var wi=class{constructor(){this.callbacks={}}enqueue(Nr,$r){this.callbacks[Nr]=$r}dequeue(Nr,$r){let jr=this.callbacks[$r];if(!jr)throw new Error(`cannot dequeue ${Nr} event: no event found for id ${$r}`);switch(delete this.callbacks[$r],Nr){case"privy:iframe:ready":return jr;case"privy:wallet:create":return jr;case"privy:wallet:connect":return jr;case"privy:wallet:recover":return jr;case"privy:wallet:rpc":return jr;case"privy:wallet:set-recovery-password":return jr;default:throw new Error(`invalid wallet event type ${Nr}`)}}},gv=function(Nr){return()=>`id-${Nr++}`}(0);function vv(Nr){return typeof Nr.event=="string"&&/^privy:.+/.test(Nr.event)}function dr(Nr){return Nr.error!==void 0}var Oo=new wi,ts=new Map,wv=(Nr,$r)=>typeof $r=="bigint"?$r.toString():$r,Cv=(Nr,$r)=>`${Nr}${JSON.stringify($r,wv)}`;function pr(Nr,$r,jr){let Lr=jr.contentWindow;if(!Lr)throw new Error("iframe not initialized");let Ur=Cv(Nr,$r);if(Nr==="privy:wallet:create"){let Hr=ts.get(Ur);if(Hr)return Hr}let Wr=new Promise((Hr,qr)=>{let Vr=gv();Oo.enqueue(Vr,{resolve:Hr,reject:qr}),Lr.postMessage({id:Vr,event:Nr,data:$r},"*")}).finally(()=>{ts.delete(Ur)});return ts.set(Ur,Wr),Wr}function bv(Nr){switch(Nr.event){case"privy:iframe:ready":let $r=Oo.dequeue(Nr.event,Nr.id);return dr(Nr)?$r.reject(new Wt(Nr.error.type,Nr.error.message)):$r.resolve(Nr.data);case"privy:wallet:create":let jr=Oo.dequeue(Nr.event,Nr.id);return dr(Nr)?jr.reject(new Wt(Nr.error.type,Nr.error.message)):jr.resolve(Nr.data);case"privy:wallet:connect":let Lr=Oo.dequeue(Nr.event,Nr.id);return dr(Nr)?Lr.reject(new Wt(Nr.error.type,Nr.error.message)):Lr.resolve(Nr.data);case"privy:wallet:recover":let Ur=Oo.dequeue(Nr.event,Nr.id);return dr(Nr)?Ur.reject(new Wt(Nr.error.type,Nr.error.message)):Ur.resolve(Nr.data);case"privy:wallet:rpc":let Wr=Oo.dequeue(Nr.event,Nr.id);return dr(Nr)?Wr.reject(new Wt(Nr.error.type,Nr.error.message)):Wr.resolve(Nr.data);case"privy:wallet:set-recovery-password":let Hr=Oo.dequeue(Nr.event,Nr.id);return dr(Nr)?Hr.reject(new Wt(Nr.error.type,Nr.error.message)):Hr.resolve(Nr.data);default:console.warn("Unsupported wallet proxy method:",Nr)}}function ru(Nr){let $r=reactExports.useRef(null);return reactExports.useEffect(()=>{let jr=$r.current;if(!jr)return;function Lr(Vr){Vr&&Vr.origin===Nr.origin&&vv(Vr.data)&&bv(Vr.data)}let Ur={create(Vr){return pr("privy:wallet:create",Vr,jr)},connect(Vr){return pr("privy:wallet:connect",Vr,jr)},recover(Vr){return pr("privy:wallet:recover",Vr,jr)},rpc(Vr){return pr("privy:wallet:rpc",Vr,jr)},setRecoveryPassword(Vr){return pr("privy:wallet:set-recovery-password",Vr,jr)}};window.addEventListener("message",Lr);let Wr=()=>Nr.onLoad(Ur),Hr=(...Vr)=>{console.warn("Privy iframe failed to load: ",...Vr),Nr.onLoadFailed()},qr=new AbortController;return js(()=>pr("privy:iframe:ready",{},jr),{abortSignal:qr.signal}).then(Wr,Hr),()=>{window.removeEventListener("message",Lr),qr.abort()}},[$r.current]),jsxRuntimeExports.jsx("iframe",{ref:$r,width:"0",height:"0",style:{display:"none",height:"0px",width:"0px"},src:an(Nr.origin,`/apps/${Nr.appId}/embedded-wallets`)})}var nu={login:{onComplete:[],onError:[]},logout:{onSuccess:[]},connectWallet:{onSuccess:[],onError:[]},createWallet:{onSuccess:[],onError:[]}},os=reactExports.createContext(void 0);function se(Nr,$r,jr,...Lr){for(let Ur of Nr.current[$r][jr])Ur(...Lr)}function kv(Nr){return typeof Nr=="string"&&Nr.length===25}var zr;function At(){if(!zr){let Nr=z.get(Ho);return Promise.resolve(Nr||null)}return zr.getAccessToken()}var su,Xs=(Nr,$r)=>su(Nr,$r),lu,el=(Nr,$r)=>lu(Nr,$r),cu,tl=()=>cu(),Rv=()=>{let Nr=new URLSearchParams(window.location.search).get("privy_token");if(!Nr)return;z.put(yr,Nr);let $r=new URL(window.location.href);$r.searchParams.delete("privy_token"),window.history.pushState({},"",$r)},Wv=({config:Nr,...$r})=>{var Lr,Ur;if(!kv($r.appId))throw new C("Cannot initialize the Privy provider with an invalid Privy app ID");zr||(zr=new Pr({appId:$r.appId,apiUrl:$r.apiUrl||Xr}));let jr=Object.assign({},Nr);return $r.createPrivyWalletOnLogin!==void 0&&((Lr=jr.embeddedWallets)==null?void 0:Lr.createOnLogin)===void 0&&(jr.embeddedWallets||(jr.embeddedWallets={}),jr.embeddedWallets.createOnLogin=$r.createPrivyWalletOnLogin?"users-without-wallets":"off"),$r.createPrivyWalletOnLogin!==void 0&&((Ur=Nr==null?void 0:Nr.embeddedWallets)!=null&&Ur.createOnLogin)&&console.warn("Both `createPrivyWalletOnLogin` and `config.embeddedWallets.createOnLogin` are set. `createPrivyWalletOnLogin` is deprecated and should be removed."),jsxRuntimeExports.jsx(Iv,{...$r,config:jr,client:zr})},Iv=Nr=>{var Pu,dp,fu;let $r=Nr.client,[jr,Lr]=reactExports.useState(!1),[Ur,Wr]=reactExports.useState(!1),[Hr,qr]=reactExports.useState(!1),[Vr,Gr]=reactExports.useState(null),[Cn,In]=reactExports.useState(!1),[Gn,Zn]=reactExports.useState([]),no=reactExports.useRef(Gn),[ho,xo]=reactExports.useState(!1),[so,io]=reactExports.useState(null),[lo,co]=reactExports.useState(!1),[_o,Ro]=reactExports.useState({status:"disconnected",connectError:null,connector:null,connectRetry:x}),[fo,jo]=reactExports.useState(null),[Kl,au]=reactExports.useState(null),[wu,Au]=reactExports.useState({showWalletLoginFirst:!0,allowlistConfig:{errorTitle:null,errorDetail:null,errorCtaText:null,errorCtaLink:null},walletAuth:!0,emailAuth:!0,smsAuth:!1,googleOAuth:!1,twitterOAuth:!1,discordOAuth:!1,githubOAuth:!1,linkedinOAuth:!1,appleOAuth:!1,termsAndConditionsUrl:null,privacyPolicyUrl:null,embeddedWalletConfig:{createOnLogin:"off",requireUserPasswordOnCreate:!1},fiatOnRampEnabled:!1,captchaEnabled:!1}),[na,eo]=reactExports.useState(()=>{let Hl=ou(Nr.config,Nr.createPrivyWalletOnLogin);return $r.createAnalyticsEvent("sdk_initialize",Hl),vi(wu,Nr.config)}),[mo,Qo]=reactExports.useState(!0),[Ml,Vo]=reactExports.useState({}),[Do,Sl]=reactExports.useState(null),[Lo,Eo]=reactExports.useState(null),[ga,vu]=reactExports.useState(!1),[Bo,Xo]=reactExports.useState(),[Al,Ol]=reactExports.useState(),[Gl,So]=reactExports.useState(),[Po,Wl]=reactExports.useState(!1),hu=reactExports.useRef(nu),$u=Hl=>{Hl&&io(Hl),Lr(!0),$r.createAnalyticsEvent("modal_open",{initialScreen:Hl})},Vu=Hl=>{na.embeddedWallets.createOnLogin!=="off"&&Qo(!0),$u(Hl)};reactExports.useEffect(()=>{var Ql,gu;if(!Kl||!Vr){(Ql=$r.connectors)==null||Ql.removeEmbeddedWalletConnector();return}let Hl=Vr==null?void 0:Vr.linkedAccounts.filter(ju=>ju.type==="wallet"&&ju.walletClient==="privy");if(Hl&&Hl.length>0){let ju=Hl[0].address;(gu=$r.connectors)==null||gu.addEmbeddedWalletConnector(Kl,ju,na.defaultChain)}},[Kl,Vr]),reactExports.useEffect(()=>{Kl&&(Lo==null||Lo(Kl))},[Kl]),reactExports.useEffect(()=>{(async()=>{var gu;if(!((gu=na.customAuth)!=null&&gu.enabled))return;Qo(!0);let{getCustomAccessToken:Hl,isLoading:Ql}=na.customAuth;if(!(!Ur||Ql))try{let ju=await Hl();if(!ju){await Jl.logout();return}if(Hr)return;$r.startAuthFlow(new Fo(ju));let{user:cp,isNewUser:op}=await $r.authenticate();cp||await Jl.logout(),Gr(cp||null),xo(op||!1),qr(!0),Wl(!0)}catch(ju){console.warn(ju),Hr&&await Jl.logout()}})()},[(Pu=na.customAuth)==null?void 0:Pu.enabled,(dp=na.customAuth)==null?void 0:dp.getCustomAccessToken,(fu=na.customAuth)==null?void 0:fu.isLoading,Ur,Hr]),reactExports.useEffect(()=>{var Hl,Ql;Po&&Kl&&Vr&&zt(Vr,(Ql=(Hl=Nr.config)==null?void 0:Hl.embeddedWallets)==null?void 0:Ql.createOnLogin)&&(Wl(!1),Co(Vr,3e4).catch(console.error))},[Po&&Kl&&Vr]),reactExports.useEffect(()=>{async function Hl(){var op,Pp,Ep;let Ql=await $r.getServerConfig();Au(Ql);let gu=vi(Ql,Nr.config);eo(gu),Ql.customApiUrl&&$r.updateApiUrl(Ql.customApiUrl),$r.initializeConnectorManager(gu.walletConnectCloudProjectId,gu.rpcConfig,gu.chains,gu.defaultChain),(op=$r.connectors)==null||op.initialize();let ju=Vl();Rv();let cp=await $r.getAuthenticatedUser();(Ep=(Pp=Nr.config)==null?void 0:Pp.customAuth)!=null&&Ep.enabled||(qr(!!cp),cp&&se(hu,"login","onComplete",cp,!1,!0),Gr(cp)),ju||(Wr(!0),Do==null||Do()),ju&&cp&&In(!0),mu()}Ur||Hl()},[$r,Do,Ur]),reactExports.useEffect(()=>{let Hl=vi(wu,Nr.config);eo(Hl)},[Nr.config]);let Vl=()=>{let Hl=new URLSearchParams(window.location.search),Ql=Hl.get("privy_oauth_code"),gu=Hl.get("privy_oauth_state"),ju=Hl.get("privy_oauth_provider");return Ql&&gu&&ju?($r.startAuthFlow(new Gt(ju,Ql,gu)),Vu("AWAITING_OAUTH_SCREEN"),Vo({finishOauthFlow:{onComplete:()=>{Wr(!0),Do==null||Do()}}}),!0):!1},Io=async(Hl,Ql,gu)=>{var cp;let ju=await((cp=$r.connectors)==null?void 0:cp.createWalletConnector(Hl,Ql))||null;Ko(ju,gu)};async function Ko(Hl,Ql){if(!Hl)return Ro({status:"disconnected",connectError:new F("Unable to connect to wallet."),connector:null,connectRetry:x}),Ql==null?void 0:Ql(null);Ro({connector:Hl,status:"connecting",connectError:null,connectRetry:()=>Ko(Hl,Ql)});try{let gu=await Hl.connect({showPrompt:!0});if(!na.chains.find(ju=>ju.id===Number(gu==null?void 0:gu.chainId))){Ro(ju=>({...ju,connector:Hl,status:"switching_to_supported_chain",connectError:null,connectRetry:x}));try{await(gu==null?void 0:gu.switchChain(na.defaultChain.id))}catch{console.warn(`Unable to switch to default chain: ${na.defaultChain.id}`)}}return Ro(ju=>({...ju,status:"connected",connectError:null,connectRetry:x})),gu&&!lo&&se(hu,"connectWallet","onSuccess",gu),Ql==null?void 0:Ql(gu)}catch(gu){return gu instanceof et?(console.warn(gu.cause?gu.cause:gu.message),lo||se(hu,"connectWallet","onError",gu.privyErrorCode||"generic_connect_wallet_error")):(console.warn(gu),lo||se(hu,"connectWallet","onError","unknown_connect_wallet_error")),Ro(ju=>({...ju,status:"disconnected",connectError:gu})),Ql==null?void 0:Ql(null)}}let uu=Hl=>{Hl!==null&&$r.startAuthFlow(new go(Hl))},mu=()=>{let Hl=new URLSearchParams(window.location.search),Ql=Hl.get("privy_connector"),gu=Hl.get("privy_wallet_client");if(!Ql||!gu)return;if(gu==="phantom"&&!je()&&Vu("LOGIN_FAILED_SCREEN"),!$r.connectors)throw new C("Connector not initialized");$u("AWAITING_CONNECTION");let ju=new URL(window.location.href);ju.searchParams.delete("privy_connector"),ju.searchParams.delete("privy_wallet_client"),window.history.pushState({},"",ju),Io(Ql,gu,uu)};reactExports.useEffect(()=>{Ur&&Hr&&Vr===null&&$r.getAuthenticatedUser().then(Gr)},[Ur,Hr,Vr,$r]);let Ru=()=>{In(!0),$u("LINK_WALLET_SCREEN")},Bu=Hl=>{if(!Hr||!Vr)return!1;for(let Ql of Vr.linkedAccounts)if(Ql.type==="wallet"&&Ql.address===Hl.address)return!0;return!1},Ku=async Hl=>{if(!$r.connectors)throw new C("Connector not initialized");let Ql=$r.connectors.findWalletConnector(Hl.connectorType,Hl.walletClientType)||null;Ro(gu=>({...gu,connector:Ql,status:"connected",connectError:null,connectRetry:x})),uu(Hl),Vu("AWAITING_CONNECTION")},qu=async(Hl,Ql)=>{if(!$r.connectors)throw new C("Connector not initialized");await Io(Hl,Ql,uu)},Hu=async(Hl,Ql)=>{if(!na.fiatOnRamp.enabled)throw new C("Fiat on-ramp is not enabled");if(!Ql||!Ql.provider||Ql.provider==="moonpay"){let{signedUrl:gu,externalTransactionId:ju}=await qc($r,Hl,(Ql==null?void 0:Ql.config)??{},na.appearance.palette,na.fiatOnRamp.useSandbox);return{signedUrl:gu,externalTransactionId:ju}}else throw new C("Unsupported fund provider. Currently supported option is `moonpay`.")},Ju=()=>{Zn(Hl=>{var gu;let Ql=((gu=$r.connectors)==null?void 0:gu.wallets.map(ju=>({...ju,linked:Bu(ju),loginOrLink:async()=>{if(!await ju.isConnected())throw new C("Wallet is not connected");if(ju.connectorType==="embedded"&&ju.walletClientType==="privy")throw new C("Cannot link or login with embedded wallet");Ku(ju)},fund:async cp=>{let{signedUrl:op,externalTransactionId:Pp}=await Hu(ju.address,cp);Vo({fiatOnRampPrompt:{signedUrl:op},fiatOnRampStatus:{externalTransactionId:Pp}}),$u("FIAT_ON_RAMP_PROMPT_SCREEN")},unlink:async()=>{if(!Hr)throw new C("User is not authenticated.");if(ju.connectorType==="embedded"&&ju.walletClientType==="privy")throw new C("Cannot unlink an embedded wallet");let cp=await $r.unlinkWallet(ju.address);Gr(cp)}})))||[];return cn(Hl,Ql)?Hl:Ql})};reactExports.useEffect(()=>{Ju()},[Vr==null?void 0:Vr.linkedAccounts,Hr,Ur]),reactExports.useEffect(()=>{if(Ur){if(!$r.connectors)throw new C("Connector not initialized");Ju(),$r.connectors.on("walletsUpdated",Ju)}},[Ur]);let Rl=()=>{$u(Hr?"CONNECT_ONLY_AUTHENTICATED_SCREEN":"CONNECT_ONLY_LANDING_SCREEN")};reactExports.useEffect(()=>{if(!Gn[0])return;let Hl=Gn[0],Ql=no.current.find(ju=>ju.address===Hl.address),gu=Vr==null?void 0:Vr.linkedAccounts.find(ju=>ju.type==="wallet"&&ju.address===Hl.address);if(!Ql&&gu){let ju=Object.assign({},Vr);ju.wallet=gu&&{address:gu.address,chainType:gu.chainType,chainId:gu.chainId,walletClient:gu.walletClient,walletClientType:gu.walletClientType,connectorType:gu.connectorType},Gr(ju)}no.current=Gn},[Gn]);let Co=async(Hl,Ql)=>{var cp,op,Pp,Ep;if(Z(Hl))throw se(hu,"createWallet","onError","embedded_wallet_already_exists"),new Error("Only one Privy wallet per user is currently allowed");let[gu,ju]=await Promise.all([du.initializeWalletProxy(Ql),At()]);if(!gu&&((op=(cp=Nr.config)==null?void 0:cp.customAuth)!=null&&op.enabled))throw se(hu,"createWallet","onError","unknown_embedded_wallet_error"),new Error("Failed to connect to wallet proxy");if(!gu||!ju||(Ep=(Pp=Nr.config)==null?void 0:Pp.embeddedWallets)!=null&&Ep.requireUserPasswordOnCreate)return new Promise((fp,vp)=>{Qo(!0),Vo({createWallet:{onSuccess:a0=>{se(hu,"createWallet","onSuccess",a0),fp(a0)},onFailure:a0=>{se(hu,"createWallet","onError","unknown_embedded_wallet_error"),vp(a0)},callAuthOnSuccessOnClose:!1}}),$u("EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN")});{await gu.create({accessToken:ju});let fp=await du.refreshUser(),vp=Z(fp);if(!vp)throw se(hu,"createWallet","onError","unknown_embedded_wallet_error"),new Error("Failed to create wallet");return se(hu,"createWallet","onSuccess",vp),vp}},No=Hl=>{if(!na.chains.map(Ql=>Ql.id).includes(Hl))throw new F(`Chain ID ${Hl} is not supported. It must be added to the config.supportedChains property of the PrivyProvider.`,"unsupported_chain_id")},Jl={ready:Ur,authenticated:Hr,user:Vr,walletConnectors:$r.connectors||null,connectWallet:Rl,linkWallet:Ru,linkEmail:()=>{if(Vr!=null&&Vr.email)throw new C("User already has an email linked to their account.");In(!0),$u("LINK_EMAIL_SCREEN")},linkPhone:()=>{if(Vr!=null&&Vr.phone)throw new C("User already has a phone number linked to their account.");In(!0),$u("LINK_PHONE_SCREEN")},linkGoogle:async()=>{if(Vr!=null&&Vr.google)throw new C("User already has a Google account linked to their account.");await du.initLoginWithOAuth("google")},linkTwitter:async()=>{if(Vr!=null&&Vr.twitter)throw new C("User already has a Twitter account linked to their account.");await du.initLoginWithOAuth("twitter")},linkDiscord:async()=>{if(Vr!=null&&Vr.discord)throw new C("User already has a Discord account linked to their account.");await du.initLoginWithOAuth("discord")},linkGithub:async()=>{if(Vr!=null&&Vr.github)throw new C("User already has a Github account linked to their account.");await du.initLoginWithOAuth("github")},linkTiktok:async()=>{if(Vr!=null&&Vr.tiktok)throw new C("User already has a Tiktok account linked to their account.");await du.initLoginWithOAuth("tiktok")},linkLinkedIn:async()=>{if(Vr!=null&&Vr.linkedin)throw new C("User already has a LinkedIn account linked to their account.");await du.initLoginWithOAuth("linkedin")},linkApple:async()=>{await du.initLoginWithOAuth("apple")},login:async()=>{if(Ur||(await new Promise(Hl=>{Sl(()=>Hl)}),Sl(null)),Hr){console.warn("Attempted to log in, but user is already logged in. Use a `link` helper instead.");return}co(!0),Vu()},logout:async()=>{await $r.logout(),Gr(null),qr(!1),io(null),se(hu,"logout","onSuccess"),In(!1),Lr(!1),z.del(gr)},getAccessToken:()=>$r.getAccessToken(),getEthereumProvider:()=>{var gu;if(!Vr||!Vr.wallet)return new X;let Hl=Gn.find(ju=>Vr.wallet&&ju.address===Vr.wallet.address),Ql=(gu=$r.connectors)==null?void 0:gu.walletConnectors.find(ju=>ju.wallets.find(cp=>cp.address===(Hl==null?void 0:Hl.address)));return!Hl||!Ql?new X:Ql.proxyProvider},getEthersProvider:()=>{var gu;if(!Vr||!Vr.wallet)return new Web3Provider(new ht(new X));let Hl=Gn.find(ju=>Vr.wallet&&ju.address===Vr.wallet.address),Ql=(gu=$r.connectors)==null?void 0:gu.walletConnectors.find(ju=>ju.wallets.find(cp=>cp.address===(Hl==null?void 0:Hl.address)));return!Hl||!Ql?new Web3Provider(new ht(new X)):new Web3Provider(new ht(Ql.proxyProvider))},getWeb3jsProvider:()=>{var gu;if(!Vr||!Vr.wallet)return new qt(new X);let Hl=Gn.find(ju=>Vr.wallet&&ju.address===Vr.wallet.address),Ql=(gu=$r.connectors)==null?void 0:gu.walletConnectors.find(ju=>ju.wallets.find(cp=>cp.address===(Hl==null?void 0:Hl.address)));return!Hl||!Ql?new qt(new X):new qt(Ql.proxyProvider)},unlinkWallet:async Hl=>{let Ql=await $r.unlinkWallet(Hl);return Gr(Ql),Ql},unlinkEmail:async Hl=>{let Ql=await $r.unlinkEmail(Hl);return Gr(Ql),Ql},unlinkPhone:async Hl=>{let Ql=await $r.unlinkPhone(Hl);return Gr(Ql),Ql},unlinkGoogle:async Hl=>{let Ql=await $r.unlinkOAuth("google",Hl);return Gr(Ql),Ql},unlinkTwitter:async Hl=>{let Ql=await $r.unlinkOAuth("twitter",Hl);return Gr(Ql),Ql},unlinkDiscord:async Hl=>{let Ql=await $r.unlinkOAuth("discord",Hl);return Gr(Ql),Ql},unlinkGithub:async Hl=>{let Ql=await $r.unlinkOAuth("github",Hl);return Gr(Ql),Ql},unlinkTiktok:async Hl=>{let Ql=await $r.unlinkOAuth("tiktok",Hl);return Gr(Ql),Ql},unlinkLinkedIn:async Hl=>{let Ql=await $r.unlinkOAuth("linkedin",Hl);return Gr(Ql),Ql},unlinkApple:async Hl=>{let Ql=await $r.unlinkOAuth("apple",Hl);return Gr(Ql),Ql},setActiveWallet:async Hl=>{let Ql=Gn.find(ju=>getAddress(ju.address)===getAddress(Hl)),gu=Vr==null?void 0:Vr.linkedAccounts.find(ju=>ju.type==="wallet"&&getAddress(ju.address)===getAddress(Hl));if(!Ql||!await Ql.isConnected())jo(Hl),Ru();else if(!Ql.linked)Ql.loginOrLink();else{let ju=Object.assign({},Vr);ju.wallet=gu&&{address:gu.address,chainType:gu.chainType,chainId:gu.chainId,walletClient:gu.walletClient,walletClientType:gu.walletClientType,connectorType:gu.connectorType},Gr(ju)}},forkSession:()=>$r.forkSession(),createWallet:async()=>{if(!Hr||!Vr)throw se(hu,"createWallet","onError","must_be_authenticated"),new Error("User must be authenticated before creating a Privy wallet");return Co(Vr,15e3)},setWalletPassword:()=>new Promise((Hl,Ql)=>{if(!Hr||!Vr){Ql(new Error("User must be authenticated before adding password to Privy wallet"));return}let gu=Z(Vr);if(!gu||!Kl){Ql(new Error("Must have a Privy wallet to add a password"));return}if(gu.recoveryMethod==="user-passcode"){Ql(new Error("Cannot set password. Embedded wallet already has a password."));return}Qo(!0),Vo({setWalletPassword:{onSuccess:Hl,onFailure:Ql,callAuthOnSuccessOnClose:!1},connectWallet:{onCompleteNavigateTo:"EMBEDDED_WALLET_PASSWORD_UPDATE_SPLASH_SCREEN",onFailure:Ql}}),$u("EMBEDDED_WALLET_CONNECTING_SCREEN")}),signMessage:(Hl,Ql)=>new Promise(async(gu,ju)=>{if(!Hr||!Vr){ju(new Error("User must be authenticated before signing with a Privy wallet"));return}let cp=Z(Vr);if(!cp){ju(new Error("Must have a Privy wallet before signing"));return}if(typeof Hl!="string"||Hl.length<1){ju(new Error("Message must be a non-empty string"));return}Qo(!0);let op=async()=>{if(!Hr)return ju(new Error("User must be authenticated before signing with a Privy wallet")),null;let Pp=await At();if(Kl&&Pp)try{if(!await du.recoverEmbeddedWallet())return ju(new Error("Unable to connect to wallet")),null;$r.createAnalyticsEvent("embedded_wallet_sign_message_started",{walletAddress:cp.address});let{response:Ep}=await Kl.rpc({accessToken:Pp,address:cp.address,request:{method:"personal_sign",params:[Hl,cp.address]}}),fp=Ep.data;return $r.createAnalyticsEvent("embedded_wallet_sign_message_completed",{walletAddress:cp.address}),fp}catch(Ep){return ju(Ep),null}else return null};if(na.embeddedWallets.noPromptOnSignature){Ql&&console.warn("uiOptions defined with `noPromptOnSignature` set to true in app config");let Pp=await op();Pp?gu(Pp):ju(new Ee("Unable to sign message"))}else Vo({signMessage:{message:Hl,confirmAndSignMessage:op,onSuccess:fp=>{gu(fp)},onFailure:fp=>{ju(fp)},uiOptions:Ql||{}},connectWallet:{onCompleteNavigateTo:"EMBEDDED_WALLET_SIGN_REQUEST_SCREEN",onFailure:ju}}),$u("EMBEDDED_WALLET_CONNECTING_SCREEN")}),sendTransaction:(Hl,Ql,gu)=>new Promise(async(ju,cp)=>{var a0,r0;if(!Hr||!Vr){cp(new Error("User must be authenticated before signing with a Privy wallet"));return}let op=Z(Vr);if(!op){cp(new Error("Must have a Privy wallet before signing"));return}Qo(!0);let Pp=(r0=(a0=$r.connectors)==null?void 0:a0.findWalletConnector("embedded","privy"))==null?void 0:r0.proxyProvider,Ep=Hl.chainId||Pp.chainId;No(Ep);let fp=Object.assign({},Hl,{chainId:Ep}),vp=async()=>{let e0=await At();if(!e0||!Kl){cp(new Error("Must have valid access token and Privy wallet to send transaction"));return}try{if(!await du.recoverEmbeddedWallet()){cp(new Error("Unable to connect to wallet"));return}let g0=new StaticJsonRpcProvider(tt(fp.chainId,na.chains,na.rpcConfig)),o0=await di(op.address,fp,g0),n0=await pi(e0,op.address,Kl,o0,g0);ju(n0)}catch(g0){cp(g0)}};na.embeddedWallets.noPromptOnSignature?(Ql&&console.warn("uiOptions defined with `noPromptOnSignature` set to true in app config"),vp()):(Vo({connectWallet:{onCompleteNavigateTo:"EMBEDDED_WALLET_SEND_TRANSACTION_SCREEN",onFailure:cp},sendTransaction:{transactionRequest:fp,onSuccess:ju,onFailure:cp,uiOptions:Ql||{},fundWalletConfig:gu}}),$u("EMBEDDED_WALLET_CONNECTING_SCREEN"))}),exportWallet:()=>new Promise((Hl,Ql)=>{if(!Hr||!Vr){Ql(new Error("User must be authenticated before exporting their Privy wallet"));return}if(!Z(Vr)){Ql(new Error("Must have a Privy wallet before exporting"));return}Qo(!0);let gu={onCompleteNavigateTo:"EMBEDDED_WALLET_KEY_EXPORT_SCREEN",onFailure:Ql},ju={appId:Nr.appId,origin:$r.apiUrl,onSuccess:Hl,onFailure:Ql};Vo({keyExport:ju,connectWallet:gu}),$u("EMBEDDED_WALLET_CONNECTING_SCREEN")})};su=Jl.signMessage,lu=Jl.sendTransaction;let du=(()=>({isNewUserThisSession:ho,isLinking:Cn,linkingHint:fo,walletConnectionStatus:_o,rpcConfig:na.rpcConfig,chains:na.chains,nativeTokenSymbolForChainId:Hl=>{var Ql;return(Ql=na.chains.find(gu=>gu.id===Number(Hl)))==null?void 0:Ql.nativeCurrency.symbol},captchaData:{ready:ga,enabled:na.captchaEnabled,execute:()=>{let Hl=window.turnstile;if(!Hl)return;let Ql=Hl.render("#cf-turnstile",{sitekey:Ms,action:na.id,callback:Xo,"error-callback":Ol,"expired-callback":()=>{try{Hl.reset(Gl),Ol(void 0),Xo(void 0)}catch{Ol("expired_and_failed_reset")}},"unsupported-callback":()=>{console.warn("Browser does not support Turnstile.")}});Ql||console.warn("Failed to render challenge."),So(Ql)},remove:()=>{let Hl=window.turnstile;!(Hl!=null&&Hl.remove)||!Gl||(Hl.remove(Gl),So(void 0),Ol(void 0),Xo(void 0))},token:Bo,error:Al},initializeWalletProxy:async Hl=>{if(Kl)return Kl;let Ql=new Promise(cp=>{Eo(()=>op=>cp(op))}),gu=new Promise(cp=>setTimeout(()=>cp(null),Hl)),ju=await Promise.race([Ql,gu]);return Eo(null),ju},getAuthFlow:()=>$r.authFlow,getAuthMeta:()=>{var Hl;return(Hl=$r.authFlow)==null?void 0:Hl.meta},closePrivyModal:(Hl={shouldCallAuthOnSuccess:!0})=>{var gu;let Ql=Ur&&Hr&&Vr;Hl.shouldCallAuthOnSuccess&&Ql?(se(hu,"login","onComplete",Vr,ho,!1),(gu=Nr.onSuccess)==null||gu.call(Nr,Vr,ho)):lo&&se(hu,"login","onError","exited_auth_flow"),$r.authFlow=void 0,jo(null),io(null),co(!1),In(!1),xo(!1),Lr(!1),$r.createAnalyticsEvent("modal_closed")},connectWallet:Io,initLoginWithWallet:qu,loginWithWallet:async()=>{if(!Ur)throw new fr;if(!($r.authFlow instanceof go))throw new C("Must initialize SIWE flow first.");let Hl,Ql;if(Hr)Hl=await $r.link();else try{({user:Hl,isNewUser:Ql}=await $r.authenticate())}catch(gu){throw se(hu,"login","onError",gu.privyErrorCode||"generic_connect_wallet_error"),gu}Gr(Hl||Vr||null),xo(Ql||!1),qr(!0)},initLoginWithOAuth:async Hl=>{$r.startAuthFlow(new Gt(Hl));let Ql=await $r.authFlow.getAuthorizationUrl();Ql&&Ql.url&&window.location.assign(Ql.url)},loginWithOAuth:async()=>{if(!($r.authFlow instanceof Gt))throw new C("Must initialize OAuth flow before calling loginWithOAuth");let Hl,Ql;if(Hr)Hl=await $r.link();else try{({user:Hl,isNewUser:Ql}=await $r.authenticate())}catch(gu){throw se(hu,"login","onError",gu.privyErrorCode||"unknown_auth_error"),gu}Gr(Hl),xo(Ql||!1),qr(!0)},initLoginWithEmail:async(Hl,Ql)=>{let gu=new yo(Hl,Ql);$r.startAuthFlow(gu);try{await gu.sendCodeEmail()}catch(ju){throw se(hu,"login","onError",ju.privyErrorCode||"unknown_auth_error"),ju}},initLoginWithSms:async(Hl,Ql)=>{let gu=new vo(Hl,Ql);$r.startAuthFlow(gu);try{await gu.sendSmsCode()}catch(ju){throw se(hu,"login","onError",ju.privyErrorCode||"unknown_auth_error"),ju}},resendEmailCode:async()=>{var Hl;await((Hl=$r.authFlow)==null?void 0:Hl.sendCodeEmail())},resendSmsCode:async()=>{var Hl;await((Hl=$r.authFlow)==null?void 0:Hl.sendSmsCode())},loginWithCode:async Hl=>{if(!Ur)throw new fr;if($r.authFlow instanceof yo)$r.authFlow.meta.emailCode=Hl.trim();else if($r.authFlow instanceof vo)$r.authFlow.meta.smsCode=Hl.trim();else throw new C("Must initialize a passwordless code flow first");let Ql,gu;Hr?Ql=await $r.link():{user:Ql,isNewUser:gu}=await $r.authenticate(),Gr(Ql||Vr||null),xo(gu||!1),qr(!0)},refreshUser:async()=>{let Hl=await $r.getAuthenticatedUser();return Gr(Hl),Hl},walletProxy:Kl,createAnalyticsEvent:(Hl,Ql,gu)=>$r.createAnalyticsEvent(Hl,Ql,gu),getUsdTokenPrice:Hl=>$r.getUsdTokenPrice(Hl),recoverEmbeddedWallet:async()=>new Promise(async(Hl,Ql)=>{let gu=Vr==null?void 0:Vr.linkedAccounts.find(cp=>cp.type==="wallet"&&cp.walletClientType==="privy"),ju=await At();if(!ju||!Kl||!gu){Ql(new Error("Must have valid access token and Privy wallet to recover wallet"));return}Qo(!0);try{await Kl.connect({accessToken:ju,address:gu.address}),Hl(!0)}catch(cp){Jo(cp)&&gu.recoveryMethod==="privy"?($r.createAnalyticsEvent("embedded_wallet_pinless_recovery_started",{walletAddress:gu.address}),(await Kl.recover({address:gu.address,accessToken:ju})).address||Ql(new Error("Unable to recover wallet")),$r.createAnalyticsEvent("embedded_wallet_recovery_completed",{walletAddress:gu.address}),Hl(!0)):Jo(cp)?(Vo({recoverWallet:{privyWallet:gu,onFailure:Ql,onSuccess:()=>Hl(!0)}}),$u("EMBEDDED_WALLET_RECOVERY_SCREEN")):Ql(cp)}}),getFiatOnRampConfig:Hu,updateWallets:()=>Ju()}))();cu=du.recoverEmbeddedWallet;let yu=reactExports.useMemo(()=>({wallets:Gn}),[Gn]);return jsxRuntimeExports.jsx(rt.Provider,{value:Jl,children:jsxRuntimeExports.jsx(os.Provider,{value:hu,children:jsxRuntimeExports.jsxs(Ya.Provider,{value:yu,children:[Nr.children,jsxRuntimeExports.jsxs(Bi.Provider,{value:du,children:[jsxRuntimeExports.jsx(Ip,{theme:{...na.appearance.palette||{}}}),jsxRuntimeExports.jsx(ll,{appConfig:na,data:Ml,setModalData:Vo,setInitialScreen:io,initialScreen:so,visible:jr,authenticated:Hr,children:jr?jsxRuntimeExports.jsx(Mp,{}):null}),mo&&wu.id?jsxRuntimeExports.jsx(ru,{appId:Nr.appId,origin:$r.apiUrl,onLoad:au,onLoadFailed:()=>null}):null]}),na.captchaEnabled&&jsxRuntimeExports.jsx(Dp,{onLoad:()=>vu(!0)})]})})})},dist={};Object.defineProperty(dist,"__esModule",{value:!0});var truncateRegex=/^(0x[a-zA-Z0-9]{4})[a-zA-Z0-9]+([a-zA-Z0-9]{4})$/,truncateEthAddress=function(Nr){var $r=Nr.match(truncateRegex);return $r?$r[1]+"…"+$r[2]:Nr},_default=dist.default=truncateEthAddress;const WalletIcon="/IncoHangman/assets/wallet_icon-5495f594.svg";function noop(){}function run(Nr){return Nr()}function blank_object(){return Object.create(null)}function run_all(Nr){Nr.forEach(run)}function is_function(Nr){return typeof Nr=="function"}function safe_not_equal(Nr,$r){return Nr!=Nr?$r==$r:Nr!==$r||Nr&&typeof Nr=="object"||typeof Nr=="function"}let src_url_equal_anchor;function src_url_equal(Nr,$r){return Nr===$r?!0:(src_url_equal_anchor||(src_url_equal_anchor=document.createElement("a")),src_url_equal_anchor.href=$r,Nr===src_url_equal_anchor.href)}function is_empty(Nr){return Object.keys(Nr).length===0}function append(Nr,$r){Nr.appendChild($r)}function insert(Nr,$r,jr){Nr.insertBefore($r,jr||null)}function detach(Nr){Nr.parentNode&&Nr.parentNode.removeChild(Nr)}function destroy_each(Nr,$r){for(let jr=0;jrNr.indexOf(Lr)===-1?$r.push(Lr):jr.push(Lr)),jr.forEach(Lr=>Lr()),render_callbacks=$r}const outroing=new Set;let outros;function group_outros(){outros={r:0,c:[],p:outros}}function check_outros(){outros.r||run_all(outros.c),outros=outros.p}function transition_in(Nr,$r){Nr&&Nr.i&&(outroing.delete(Nr),Nr.i($r))}function transition_out(Nr,$r,jr,Lr){if(Nr&&Nr.o){if(outroing.has(Nr))return;outroing.add(Nr),outros.c.push(()=>{outroing.delete(Nr),Lr&&(jr&&Nr.d(1),Lr())}),Nr.o($r)}else Lr&&Lr()}function ensure_array_like(Nr){return(Nr==null?void 0:Nr.length)!==void 0?Nr:Array.from(Nr)}function create_component(Nr){Nr&&Nr.c()}function mount_component(Nr,$r,jr){const{fragment:Lr,after_update:Ur}=Nr.$$;Lr&&Lr.m($r,jr),add_render_callback(()=>{const Wr=Nr.$$.on_mount.map(run).filter(is_function);Nr.$$.on_destroy?Nr.$$.on_destroy.push(...Wr):run_all(Wr),Nr.$$.on_mount=[]}),Ur.forEach(add_render_callback)}function destroy_component(Nr,$r){const jr=Nr.$$;jr.fragment!==null&&(flush_render_callbacks(jr.after_update),run_all(jr.on_destroy),jr.fragment&&jr.fragment.d($r),jr.on_destroy=jr.fragment=null,jr.ctx=[])}function make_dirty(Nr,$r){Nr.$$.dirty[0]===-1&&(dirty_components.push(Nr),schedule_update(),Nr.$$.dirty.fill(0)),Nr.$$.dirty[$r/31|0]|=1<<$r%31}function init(Nr,$r,jr,Lr,Ur,Wr,Hr=null,qr=[-1]){const Vr=current_component;set_current_component(Nr);const Gr=Nr.$$={fragment:null,ctx:[],props:Wr,update:noop,not_equal:Ur,bound:blank_object(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map($r.context||(Vr?Vr.$$.context:[])),callbacks:blank_object(),dirty:qr,skip_bound:!1,root:$r.target||Vr.$$.root};Hr&&Hr(Gr.root);let Cn=!1;if(Gr.ctx=jr?jr(Nr,$r.props||{},(In,Gn,...Zn)=>{const no=Zn.length?Zn[0]:Gn;return Gr.ctx&&Ur(Gr.ctx[In],Gr.ctx[In]=no)&&(!Gr.skip_bound&&Gr.bound[In]&&Gr.bound[In](no),Cn&&make_dirty(Nr,In)),Gn}):[],Gr.update(),Cn=!0,run_all(Gr.before_update),Gr.fragment=Lr?Lr(Gr.ctx):!1,$r.target){if($r.hydrate){const In=children($r.target);Gr.fragment&&Gr.fragment.l(In),In.forEach(detach)}else Gr.fragment&&Gr.fragment.c();$r.intro&&transition_in(Nr.$$.fragment),mount_component(Nr,$r.target,$r.anchor),flush()}set_current_component(Vr)}class SvelteComponent{constructor(){P_(this,"$$");P_(this,"$$set")}$destroy(){destroy_component(this,1),this.$destroy=noop}$on($r,jr){if(!is_function(jr))return noop;const Lr=this.$$.callbacks[$r]||(this.$$.callbacks[$r]=[]);return Lr.push(jr),()=>{const Ur=Lr.indexOf(jr);Ur!==-1&&Lr.splice(Ur,1)}}$set($r){this.$$set&&!is_empty($r)&&(this.$$.skip_bound=!0,this.$$set($r),this.$$.skip_bound=!1)}}const PUBLIC_VERSION="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(PUBLIC_VERSION);const Confetti_svelte_svelte_type_style_lang="";function get_each_context$1(Nr,$r,jr){const Lr=Nr.slice();return Lr[18]=$r[jr],Lr}function create_if_block$1(Nr){let $r,jr=ensure_array_like({length:Nr[6]}),Lr=[];for(let Ur=0;Ur{!io||qr||Gn=="infinite"||setTimeout(()=>jr(13,lo=!0),(Hr+Vr[1])*Gn)});function co(){return Cn.length?Cn[Math.round(Math.random()*(Cn.length-1))]:`hsl(${Math.round(randomBetween(Gr[0],Gr[1]))}, 75%, 50%`}return Nr.$$set=_o=>{"size"in _o&&jr(0,Lr=_o.size),"x"in _o&&jr(1,Ur=_o.x),"y"in _o&&jr(2,Wr=_o.y),"duration"in _o&&jr(3,Hr=_o.duration),"infinite"in _o&&jr(4,qr=_o.infinite),"delay"in _o&&jr(5,Vr=_o.delay),"colorRange"in _o&&jr(15,Gr=_o.colorRange),"colorArray"in _o&&jr(16,Cn=_o.colorArray),"amount"in _o&&jr(6,In=_o.amount),"iterationCount"in _o&&jr(7,Gn=_o.iterationCount),"fallDistance"in _o&&jr(8,Zn=_o.fallDistance),"rounded"in _o&&jr(9,no=_o.rounded),"cone"in _o&&jr(10,ho=_o.cone),"noGravity"in _o&&jr(11,xo=_o.noGravity),"xSpread"in _o&&jr(12,so=_o.xSpread),"destroyOnComplete"in _o&&jr(17,io=_o.destroyOnComplete)},[Lr,Ur,Wr,Hr,qr,Vr,In,Gn,Zn,no,ho,xo,so,lo,co,Gr,Cn,io]}class Confetti extends SvelteComponent{constructor($r){super(),init(this,$r,instance$1,create_fragment$1,safe_not_equal,{size:0,x:1,y:2,duration:3,infinite:4,delay:5,colorRange:15,colorArray:16,amount:6,iterationCount:7,fallDistance:8,rounded:9,cone:10,noGravity:11,xSpread:12,destroyOnComplete:17})}}const hangman_0="/IncoHangman/assets/hangman_0-b2cad2aa.png",hangman_1="/IncoHangman/assets/hangman_1-803f1fe5.png",hangman_2="/IncoHangman/assets/hangman_2-4f35571c.png",hangman_3="/IncoHangman/assets/hangman_3-6717656a.png",hangman_4="/IncoHangman/assets/hangman_4-9fcf1839.png",hangman_5="/IncoHangman/assets/hangman_5-e4dd913a.png",hangman_6="/IncoHangman/assets/hangman_6-04a66a6f.png",hangman_7="/IncoHangman/assets/hangman_7-2b2aef72.png",hangman_8="/IncoHangman/assets/hangman_8-67a59ea2.png",hangman_9="/IncoHangman/assets/hangman_9-15ebbed8.png",hangman_10="/IncoHangman/assets/hangman_10-eeb33293.png",hangman_11="/IncoHangman/assets/hangman_11-a9e9b187.png",Game_svelte_svelte_type_style_lang="";function get_each_context(Nr,$r,jr){const Lr=Nr.slice();return Lr[9]=$r[jr],Lr}function get_each_context_1(Nr,$r,jr){const Lr=Nr.slice();return Lr[9]=$r[jr],Lr}function create_each_block_1(Nr){let $r,jr=Nr[9]+"",Lr;return{c(){$r=element("span"),Lr=text(jr),attr($r,"class","Letter svelte-vcspso")},m(Ur,Wr){insert(Ur,$r,Wr),append($r,Lr)},p(Ur,Wr){Wr&2&&jr!==(jr=Ur[9]+"")&&set_data(Lr,jr)},d(Ur){Ur&&detach($r)}}}function create_each_block(Nr){let $r,jr,Lr=Nr[9]+"",Ur,Wr;return{c(){$r=element("div"),jr=element("p"),Ur=text(Lr),Wr=space(),attr($r,"class","Underscore svelte-vcspso")},m(Hr,qr){insert(Hr,$r,qr),append($r,jr),append(jr,Ur),append($r,Wr)},p(Hr,qr){qr&8&&Lr!==(Lr=Hr[9]+"")&&set_data(Ur,Lr)},d(Hr){Hr&&detach($r)}}}function create_if_block(Nr){let $r,jr,Lr;return jr=new Confetti({props:{size:"30",x:[-5,5],y:[0,.1],delay:[200,3500],duration:"5000",amount:"500",fallDistance:"100vh"}}),{c(){$r=element("div"),create_component(jr.$$.fragment),attr($r,"class","Confetti svelte-vcspso")},m(Ur,Wr){insert(Ur,$r,Wr),mount_component(jr,$r,null),Lr=!0},i(Ur){Lr||(transition_in(jr.$$.fragment,Ur),Lr=!0)},o(Ur){transition_out(jr.$$.fragment,Ur),Lr=!1},d(Ur){Ur&&detach($r),destroy_component(jr)}}}function create_fragment(Nr){let $r,jr,Lr,Ur,Wr,Hr,qr,Vr,Gr,Cn,In,Gn=ensure_array_like(Nr[1]),Zn=[];for(let so=0;so{xo=null}),check_outros())},i(so){In||(transition_in(xo),In=!0)},o(so){transition_out(xo),In=!1},d(so){so&&detach($r),destroy_each(Zn,so),destroy_each(ho,so),xo&&xo.d()}}}function instance($$self,$$props,$$invalidate){let wrongWords,drawingId,splitWord;const drawings=[hangman_0,hangman_1,hangman_2,hangman_3,hangman_4,hangman_5,hangman_6,hangman_7,hangman_8,hangman_9,hangman_10,hangman_11];let{wrongGuesses=[]}=$$props,{lives=11}=$$props,{hasWon=!1}=$$props,{currentWord="____"}=$$props;var rpGlobal=typeof window<"u"?window:global;return rpGlobal.rpDsp=rpGlobal.rpDsp||function(){},rpGlobal.rpDsp("SvelteReactiveEnable",{version:"0.8.3"}),$$self.$$set=Nr=>{"wrongGuesses"in Nr&&$$invalidate(5,wrongGuesses=Nr.wrongGuesses),"lives"in Nr&&$$invalidate(6,lives=Nr.lives),"hasWon"in Nr&&$$invalidate(0,hasWon=Nr.hasWon),"currentWord"in Nr&&$$invalidate(7,currentWord=Nr.currentWord)},$$self.$$.update=()=>{if($$self.$$.dirty&384){let svrp_start=Date.now(),svrp_exec=Math.random(),start_state=eval("{}");rpGlobal.rpDsp("SvelteReactiveStart",{statement:"splitWord = currentWord.split('');",filename:"/home/runner/work/IncoHangman/IncoHangman/src/Game.svelte",line:38,id:"iH21"},svrp_start,svrp_exec,start_state),$$invalidate(3,splitWord=currentWord.split("")),rpGlobal.rpDsp("SvelteReactiveEnd",{statement:"splitWord = currentWord.split('');",filename:"/home/runner/work/IncoHangman/IncoHangman/src/Game.svelte",line:38,id:"iH21"},svrp_start,svrp_exec,start_state,eval("{}"))}if($$self.$$.dirty&288){let svrp_start=Date.now(),svrp_exec=Math.random(),start_state=eval("{}");rpGlobal.rpDsp("SvelteReactiveStart",{statement:"drawingId = wrongGuesses.length;",filename:"/home/runner/work/IncoHangman/IncoHangman/src/Game.svelte",line:40,id:"trB8"},svrp_start,svrp_exec,start_state),$$invalidate(2,drawingId=wrongGuesses.length),rpGlobal.rpDsp("SvelteReactiveEnd",{statement:"drawingId = wrongGuesses.length;",filename:"/home/runner/work/IncoHangman/IncoHangman/src/Game.svelte",line:40,id:"trB8"},svrp_start,svrp_exec,start_state,eval("{}"))}if($$self.$$.dirty&288){let svrp_start=Date.now(),svrp_exec=Math.random(),start_state=eval("{}");rpGlobal.rpDsp("SvelteReactiveStart",{statement:`wrongWords = wrongGuesses.flatMap( (v, i, array) => array.length - 1 !== i ? [v, ","] : v - );`,filename:"/home/runner/work/IncoHangman/IncoHangman/src/Game.svelte",line:42,id:"KH8K"},svrp_start,svrp_exec,start_state),$$invalidate(1,wrongWords=wrongGuesses.flatMap((Nr,$r,jr)=>jr.length-1!==$r?[Nr,","]:Nr)),rpGlobal.rpDsp("SvelteReactiveEnd",{statement:`wrongWords = wrongGuesses.flatMap( + );`,filename:"/home/runner/work/IncoHangman/IncoHangman/src/Game.svelte",line:42,id:"F7OU"},svrp_start,svrp_exec,start_state),$$invalidate(1,wrongWords=wrongGuesses.flatMap((Nr,$r,jr)=>jr.length-1!==$r?[Nr,","]:Nr)),rpGlobal.rpDsp("SvelteReactiveEnd",{statement:`wrongWords = wrongGuesses.flatMap( (v, i, array) => array.length - 1 !== i ? [v, ","] : v - );`,filename:"/home/runner/work/IncoHangman/IncoHangman/src/Game.svelte",line:42,id:"KH8K"},svrp_start,svrp_exec,start_state,eval("{}"))}},[hasWon,wrongWords,drawingId,splitWord,drawings,wrongGuesses,lives,currentWord,rpGlobal]}class Game extends SvelteComponent{constructor($r){super(),init(this,$r,instance,create_fragment,safe_not_equal,{wrongGuesses:5,lives:6,hasWon:0,currentWord:7})}}(function(){var Nr={},$r="";try{$r=location.hash.toString()}catch{}var jr=Vr($r),Lr=so("initParams");if(Lr)for(var Ur in Lr)typeof jr[Ur]>"u"&&(jr[Ur]=Lr[Ur]);xo("initParams",jr);var Wr=!1,Hr;try{if(Wr=window.parent!=null&&window!=window.parent,Wr){window.addEventListener("message",function(io){if(io.source===window.parent){try{var lo=JSON.parse(io.data)}catch{return}!lo||!lo.eventType||(lo.eventType=="set_custom_style"?Hr.innerHTML=lo.eventData:Gn(lo.eventType,lo.eventData))}}),Hr=document.createElement("style"),document.head.appendChild(Hr);try{window.parent.postMessage(JSON.stringify({eventType:"iframe_ready"}),"*")}catch{}}}catch{}function qr(io){try{return io=io.replace(/\+/g,"%20"),decodeURIComponent(io)}catch{return io}}function Vr(io){io=io.replace(/^#/,"");var lo={};if(!io.length)return lo;if(io.indexOf("=")<0&&io.indexOf("?")<0)return lo._path=qr(io),lo;var co=io.indexOf("?");if(co>=0){var _o=io.substr(0,co);lo._path=qr(_o),io=io.substr(co+1)}var Ro=Gr(io);for(var fo in Ro)lo[fo]=Ro[fo];return lo}function Gr(io){var lo={};if(!io.length)return lo;var co=io.split("&"),_o,Ro,fo,jo;for(_o=0;_o=0?io+"&"+lo:_o.length>0?io+"?"+lo:io+lo}function In(io,lo,co){if(lo||(lo=function(){}),co===void 0&&(co=""),console.log("[Telegram.WebView] > postEvent",io,co),window.TelegramWebviewProxy!==void 0)TelegramWebviewProxy.postEvent(io,JSON.stringify(co)),lo();else if(window.external&&"notify"in window.external)window.external.notify(JSON.stringify({eventType:io,eventData:co})),lo();else if(Wr)try{var _o="https://web.telegram.org";_o="*",window.parent.postMessage(JSON.stringify({eventType:io,eventData:co}),_o),lo()}catch(Ro){lo(Ro)}else lo({notAvailable:!0})}function Gn(io,lo){console.log("[Telegram.WebView] < receiveEvent",io,lo),Zn(io,function(co){co(io,lo)})}function Zn(io,lo){var co=Nr[io];if(!(co===void 0||!co.length))for(var _o=0;_ocp?1:-1;return 0}function hu(fu){return Wl(Gr,fu)>=0}function $u(fu){if(window.Blob)try{return new Blob([fu]).size}catch{}for(var Hl=fu.length,Ql=fu.length-1;Ql>=0;Ql--){var gu=fu.charCodeAt(Ql);gu>127&&gu<=2047?Hl++:gu>2047&&gu<=65535&&(Hl+=2),gu>=56320&&gu<=57343&&Ql--}return Hl}var Vu=function(){var fu=!1,Hl={};Object.defineProperty(Hl,"isVisible",{set:function(fp){Ep({is_visible:fp})},get:function(){return fu},enumerable:!0});var Ql=null;$r.onEvent("back_button_pressed",gu);function gu(){_o("backButtonClicked")}function ju(){return{is_visible:fu}}function cp(fp){return typeof fp>"u"&&(fp=ju()),JSON.stringify(fp)}function op(){return hu("6.1")?!0:(console.warn("[Telegram.WebApp] BackButton is not supported in version "+Gr),!1)}function Pp(){var fp=ju(),vp=cp(fp);Ql!==vp&&(Ql=vp,$r.postEvent("web_app_setup_back_button",!1,fp))}function Ep(fp){return op()&&(typeof fp.is_visible<"u"&&(fu=!!fp.is_visible),Pp()),Hl}return Hl.onClick=function(fp){return op()&&Ro("backButtonClicked",fp),Hl},Hl.offClick=function(fp){return op()&&fo("backButtonClicked",fp),Hl},Hl.show=function(){return Ep({is_visible:!0})},Hl.hide=function(){return Ep({is_visible:!1})},Hl}(),Vl=0,Io=function(){var fu=!1,Hl=!0,Ql=!1,gu="CONTINUE",ju=!1,cp=!1,op={};Object.defineProperty(op,"text",{set:function(gp){op.setParams({text:gp})},get:function(){return gu},enumerable:!0}),Object.defineProperty(op,"color",{set:function(gp){op.setParams({color:gp})},get:function(){return ju||qr.button_color||"#2481cc"},enumerable:!0}),Object.defineProperty(op,"textColor",{set:function(gp){op.setParams({text_color:gp})},get:function(){return cp||qr.button_text_color||"#ffffff"},enumerable:!0}),Object.defineProperty(op,"isVisible",{set:function(gp){op.setParams({is_visible:gp})},get:function(){return fu},enumerable:!0}),Object.defineProperty(op,"isProgressVisible",{get:function(){return Ql},enumerable:!0}),Object.defineProperty(op,"isActive",{set:function(gp){op.setParams({is_active:gp})},get:function(){return Hl},enumerable:!0});var Pp=null;$r.onEvent("main_button_pressed",a0);var Ep=null,fp={};if(jr.tgWebAppDebug){Ep=document.createElement("tg-main-button"),fp={font:"600 14px/18px sans-serif",display:"none",width:"100%",height:"48px",borderRadius:"0",background:"no-repeat right center",position:"fixed",left:"0",right:"0",bottom:"0",margin:"0",padding:"15px 20px",textAlign:"center",boxSizing:"border-box",zIndex:"10000"};for(var vp in fp)Ep.style[vp]=fp[vp];document.addEventListener("DOMContentLoaded",function gp(Op){document.removeEventListener("DOMContentLoaded",gp),document.body.appendChild(Ep),Ep.addEventListener("click",a0,!1)})}function a0(){Hl&&_o("mainButtonClicked")}function r0(){var gp=op.color,Op=op.textColor;return fu?{is_visible:!0,is_active:Hl,is_progress_visible:Ql,text:gu,color:gp,text_color:Op}:{is_visible:!1}}function e0(gp){return typeof gp>"u"&&(gp=r0()),JSON.stringify(gp)}function g0(){var gp=r0(),Op=e0(gp);Pp!==Op&&(Pp=Op,$r.postEvent("web_app_setup_main_button",!1,gp),jr.tgWebAppDebug&&o0(gp))}function o0(gp){gp.is_visible?(Ep.style.display="block",Vl=48,Ep.style.opacity=gp.is_active?"1":"0.8",Ep.style.cursor=gp.is_active?"pointer":"auto",Ep.disabled=!gp.is_active,Ep.innerText=gp.text,Ep.style.backgroundImage=gp.is_progress_visible?"url('data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20xmlns%3Axlink%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink%22%20viewport%3D%220%200%2048%2048%22%20width%3D%2248px%22%20height%3D%2248px%22%3E%3Ccircle%20cx%3D%2250%25%22%20cy%3D%2250%25%22%20stroke%3D%22%23fff%22%20stroke-width%3D%222.25%22%20stroke-linecap%3D%22round%22%20fill%3D%22none%22%20stroke-dashoffset%3D%22106%22%20r%3D%229%22%20stroke-dasharray%3D%2256.52%22%20rotate%3D%22-90%22%3E%3Canimate%20attributeName%3D%22stroke-dashoffset%22%20attributeType%3D%22XML%22%20dur%3D%22360s%22%20from%3D%220%22%20to%3D%2212500%22%20repeatCount%3D%22indefinite%22%3E%3C%2Fanimate%3E%3CanimateTransform%20attributeName%3D%22transform%22%20attributeType%3D%22XML%22%20type%3D%22rotate%22%20dur%3D%221s%22%20from%3D%22-90%2024%2024%22%20to%3D%22630%2024%2024%22%20repeatCount%3D%22indefinite%22%3E%3C%2FanimateTransform%3E%3C%2Fcircle%3E%3C%2Fsvg%3E')":"none",Ep.style.backgroundColor=gp.color,Ep.style.color=gp.text_color):(Ep.style.display="none",Vl=0),document.documentElement&&(document.documentElement.style.boxSizing="border-box",document.documentElement.style.paddingBottom=Vl+"px"),mo()}function n0(gp){if(typeof gp.text<"u"){var Op=co(gp.text);if(!Op.length)throw console.error("[Telegram.WebApp] Main button text is required",gp.text),Error("WebAppMainButtonParamInvalid");if(Op.length>64)throw console.error("[Telegram.WebApp] Main button text is too long",Op),Error("WebAppMainButtonParamInvalid");gu=Op}if(typeof gp.color<"u")if(gp.color===!1||gp.color===null)ju=!1;else{var s0=So(gp.color);if(!s0)throw console.error("[Telegram.WebApp] Main button color format is invalid",gp.color),Error("WebAppMainButtonParamInvalid");ju=s0}if(typeof gp.text_color<"u")if(gp.text_color===!1||gp.text_color===null)cp=!1;else{var w0=So(gp.text_color);if(!w0)throw console.error("[Telegram.WebApp] Main button text color format is invalid",gp.text_color),Error("WebAppMainButtonParamInvalid");cp=w0}if(typeof gp.is_visible<"u"){if(gp.is_visible&&!op.text.length)throw console.error("[Telegram.WebApp] Main button text is required"),Error("WebAppMainButtonParamInvalid");fu=!!gp.is_visible}return typeof gp.is_active<"u"&&(Hl=!!gp.is_active),g0(),op}return op.setText=function(gp){return op.setParams({text:gp})},op.onClick=function(gp){return Ro("mainButtonClicked",gp),op},op.offClick=function(gp){return fo("mainButtonClicked",gp),op},op.show=function(){return op.setParams({is_visible:!0})},op.hide=function(){return op.setParams({is_visible:!1})},op.enable=function(){return op.setParams({is_active:!0})},op.disable=function(){return op.setParams({is_active:!1})},op.showProgress=function(gp){return Hl=!!gp,Ql=!0,g0(),op},op.hideProgress=function(){return op.isActive||(Hl=!0),Ql=!1,g0(),op},op.setParams=n0,op}();function Ko(){_o("settingsButtonClicked")}$r.onEvent("settings_button_pressed",Ko);var uu=function(){var fu={};function Hl(Ql){if(!hu("6.1"))return console.warn("[Telegram.WebApp] HapticFeedback is not supported in version "+Gr),fu;if(Ql.type=="impact"){if(Ql.impact_style!="light"&&Ql.impact_style!="medium"&&Ql.impact_style!="heavy"&&Ql.impact_style!="rigid"&&Ql.impact_style!="soft")throw console.error("[Telegram.WebApp] Haptic impact style is invalid",Ql.impact_style),Error("WebAppHapticImpactStyleInvalid")}else if(Ql.type=="notification"){if(Ql.notification_type!="error"&&Ql.notification_type!="success"&&Ql.notification_type!="warning")throw console.error("[Telegram.WebApp] Haptic notification type is invalid",Ql.notification_type),Error("WebAppHapticNotificationTypeInvalid")}else if(Ql.type!="selection_change")throw console.error("[Telegram.WebApp] Haptic feedback type is invalid",Ql.type),Error("WebAppHapticFeedbackTypeInvalid");return $r.postEvent("web_app_trigger_haptic_feedback",!1,Ql),fu}return fu.impactOccurred=function(Ql){return Hl({type:"impact",impact_style:Ql})},fu.notificationOccurred=function(Ql){return Hl({type:"notification",notification_type:Ql})},fu.selectionChanged=function(){return Hl({type:"selection_change"})},fu}(),mu=function(){var fu={};function Hl(Ql,gu,ju){if(!hu("6.9"))throw console.error("[Telegram.WebApp] CloudStorage is not supported in version "+Gr),Error("WebAppMethodUnsupported");return dp(Ql,gu,ju),fu}return fu.setItem=function(Ql,gu,ju){return Hl("saveStorageValue",{key:Ql,value:gu},ju)},fu.getItem=function(Ql,gu){return fu.getItems([Ql],gu?function(ju,cp){ju?gu(ju):gu(null,cp[Ql])}:null)},fu.getItems=function(Ql,gu){return Hl("getStorageValues",{keys:Ql},gu)},fu.removeItem=function(Ql,gu){return fu.removeItems([Ql],gu)},fu.removeItems=function(Ql,gu){return Hl("deleteStorageValues",{keys:Ql},gu)},fu.getKeys=function(Ql){return Hl("getStorageKeys",{},Ql)},fu}(),Ru={};function Bu(fu,Hl){if(Hl.slug&&Ru[Hl.slug]){var Ql=Ru[Hl.slug];delete Ru[Hl.slug],Ql.callback&&Ql.callback(Hl.status),_o("invoiceClosed",{url:Ql.url,status:Hl.status})}}var Ku=!1;function qu(fu,Hl){if(Ku){var Ql=Ku;Ku=!1;var gu=null;typeof Hl.button_id<"u"&&(gu=Hl.button_id),Ql.callback&&Ql.callback(gu),_o("popupClosed",{button_id:gu})}}var Hu=!1;function Ju(fu,Hl){if(Hu){var Ql=Hu,gu=null;typeof Hl.data<"u"&&(gu=Hl.data),Ql.callback&&Ql.callback(gu)&&(Hu=!1,$r.postEvent("web_app_close_scan_qr_popup",!1)),_o("qrTextReceived",{data:gu})}}function Rl(fu,Hl){Hu=!1}function Co(fu,Hl){if(Hl.req_id&&au[Hl.req_id]){var Ql=au[Hl.req_id];delete au[Hl.req_id];var gu=null;typeof Hl.data<"u"&&(gu=Hl.data),Ql.callback&&Ql.callback(gu),_o("clipboardTextReceived",{data:gu})}}var No=!1;function Jl(fu,Hl){if(No){var Ql=No;No=!1,Ql.callback&&Ql.callback(Hl.status=="allowed"),_o("writeAccessRequested",{status:Hl.status})}}var du=!1;function yu(fu,Hl){if(du){var Ql=du;du=!1,Ql.callback&&Ql.callback(Hl.status=="sent"),_o("contactRequested",{status:Hl.status})}}function Pu(fu,Hl){if(Hl.req_id&&au[Hl.req_id]){var Ql=au[Hl.req_id];delete au[Hl.req_id];var gu=null,ju=null;typeof Hl.result<"u"&&(gu=Hl.result),typeof Hl.error<"u"&&(ju=Hl.error),Ql.callback&&Ql.callback(ju,gu)}}function dp(fu,Hl,Ql){if(!hu("6.9"))throw console.error("[Telegram.WebApp] Method invokeCustomMethod is not supported in version "+Gr),Error("WebAppMethodUnsupported");var gu=wu(16),ju={req_id:gu,method:fu,params:Hl||{}};au[gu]={callback:Ql},$r.postEvent("web_app_invoke_custom_method",!1,ju)}window.Telegram||(window.Telegram={}),Object.defineProperty(Ur,"initData",{get:function(){return Wr},enumerable:!0}),Object.defineProperty(Ur,"initDataUnsafe",{get:function(){return Hr},enumerable:!0}),Object.defineProperty(Ur,"version",{get:function(){return Gr},enumerable:!0}),Object.defineProperty(Ur,"platform",{get:function(){return Cn},enumerable:!0}),Object.defineProperty(Ur,"colorScheme",{get:function(){return Vr},enumerable:!0}),Object.defineProperty(Ur,"themeParams",{get:function(){return qr},enumerable:!0}),Object.defineProperty(Ur,"isExpanded",{get:function(){return eo},enumerable:!0}),Object.defineProperty(Ur,"viewportHeight",{get:function(){return(Au===!1?window.innerHeight:Au)-Vl},enumerable:!0}),Object.defineProperty(Ur,"viewportStableHeight",{get:function(){return(na===!1?window.innerHeight:na)-Vl},enumerable:!0}),Object.defineProperty(Ur,"isClosingConfirmationEnabled",{set:function(fu){Ml(fu)},get:function(){return Qo},enumerable:!0}),Object.defineProperty(Ur,"headerColor",{set:function(fu){Lo(fu)},get:function(){return Sl()},enumerable:!0}),Object.defineProperty(Ur,"backgroundColor",{set:function(fu){Al(fu)},get:function(){return Xo()},enumerable:!0}),Object.defineProperty(Ur,"BackButton",{value:Vu,enumerable:!0}),Object.defineProperty(Ur,"MainButton",{value:Io,enumerable:!0}),Object.defineProperty(Ur,"HapticFeedback",{value:uu,enumerable:!0}),Object.defineProperty(Ur,"CloudStorage",{value:mu,enumerable:!0}),Ur.setHeaderColor=function(fu){Ur.headerColor=fu},Ur.setBackgroundColor=function(fu){Ur.backgroundColor=fu},Ur.enableClosingConfirmation=function(){Ur.isClosingConfirmationEnabled=!0},Ur.disableClosingConfirmation=function(){Ur.isClosingConfirmationEnabled=!1},Ur.isVersionAtLeast=function(fu){return hu(fu)},Ur.onEvent=function(fu,Hl){Ro(fu,Hl)},Ur.offEvent=function(fu,Hl){fo(fu,Hl)},Ur.sendData=function(fu){if(!fu||!fu.length)throw console.error("[Telegram.WebApp] Data is required",fu),Error("WebAppDataInvalid");if($u(fu)>4096)throw console.error("[Telegram.WebApp] Data is too long",fu),Error("WebAppDataInvalid");$r.postEvent("web_app_data_send",!1,{data:fu})},Ur.switchInlineQuery=function(fu,Hl){if(!hu("6.6"))throw console.error("[Telegram.WebApp] Method switchInlineQuery is not supported in version "+Gr),Error("WebAppMethodUnsupported");if(!jr.tgWebAppBotInline)throw console.error("[Telegram.WebApp] Inline mode is disabled for this bot. Read more about inline mode: https://core.telegram.org/bots/inline"),Error("WebAppInlineModeDisabled");if(fu=fu||"",fu.length>256)throw console.error("[Telegram.WebApp] Inline query is too long",fu),Error("WebAppInlineQueryInvalid");var Ql=[];if(Hl){if(!Array.isArray(Hl))throw console.error("[Telegram.WebApp] Choose chat types should be an array",Hl),Error("WebAppInlineChooseChatTypesInvalid");for(var gu={users:1,bots:1,groups:1,channels:1},ju=0;ju64)throw console.error("[Telegram.WebApp] Popup title is too long",Ql),Error("WebAppPopupParamInvalid");Ql.length>0&&(cp.title=Ql)}if(typeof fu.message<"u"&&(gu=co(fu.message)),!gu.length)throw console.error("[Telegram.WebApp] Popup message is required",fu.message),Error("WebAppPopupParamInvalid");if(gu.length>256)throw console.error("[Telegram.WebApp] Popup message is too long",gu),Error("WebAppPopupParamInvalid");if(cp.message=gu,typeof fu.buttons<"u"){if(!Array.isArray(fu.buttons))throw console.error("[Telegram.WebApp] Popup buttons should be an array",fu.buttons),Error("WebAppPopupParamInvalid");for(var op=0;op64))throw console.error("[Telegram.WebApp] Popup button id is too long",fp),Error("WebAppPopupParamInvalid");Ep.id=fp;var vp=Pp.type;if(typeof vp>"u"&&(vp="default"),Ep.type=vp,!(vp=="ok"||vp=="close"||vp=="cancel"))if(vp=="default"||vp=="destructive"){var a0="";if(typeof Pp.text<"u"&&(a0=co(Pp.text)),!a0.length)throw console.error("[Telegram.WebApp] Popup button text is required for type "+vp,Pp.text),Error("WebAppPopupParamInvalid");if(a0.length>64)throw console.error("[Telegram.WebApp] Popup button text is too long",a0),Error("WebAppPopupParamInvalid");Ep.text=a0}else throw console.error("[Telegram.WebApp] Popup button type is invalid",vp),Error("WebAppPopupParamInvalid");ju.push(Ep)}}else ju.push({id:"",type:"close"});if(ju.length<1)throw console.error("[Telegram.WebApp] Popup should have at least one button"),Error("WebAppPopupParamInvalid");if(ju.length>3)throw console.error("[Telegram.WebApp] Popup should not have more than 3 buttons"),Error("WebAppPopupParamInvalid");cp.buttons=ju,Ku={callback:Hl},$r.postEvent("web_app_open_popup",!1,cp)},Ur.showAlert=function(fu,Hl){Ur.showPopup({message:fu},Hl?function(){Hl()}:null)},Ur.showConfirm=function(fu,Hl){Ur.showPopup({message:fu,buttons:[{type:"ok",id:"ok"},{type:"cancel"}]},Hl?function(Ql){Hl(Ql=="ok")}:null)},Ur.showScanQrPopup=function(fu,Hl){if(!hu("6.4"))throw console.error("[Telegram.WebApp] Method showScanQrPopup is not supported in version "+Gr),Error("WebAppMethodUnsupported");if(Hu)throw console.error("[Telegram.WebApp] Popup is already opened"),Error("WebAppScanQrPopupOpened");var Ql="",gu={};if(typeof fu.text<"u"){if(Ql=co(fu.text),Ql.length>64)throw console.error("[Telegram.WebApp] Scan QR popup text is too long",Ql),Error("WebAppScanQrPopupParamInvalid");Ql.length>0&&(gu.text=Ql)}Hu={callback:Hl},$r.postEvent("web_app_open_scan_qr_popup",!1,gu)},Ur.closeScanQrPopup=function(){if(!hu("6.4"))throw console.error("[Telegram.WebApp] Method closeScanQrPopup is not supported in version "+Gr),Error("WebAppMethodUnsupported");Hu=!1,$r.postEvent("web_app_close_scan_qr_popup",!1)},Ur.readTextFromClipboard=function(fu){if(!hu("6.4"))throw console.error("[Telegram.WebApp] Method readTextFromClipboard is not supported in version "+Gr),Error("WebAppMethodUnsupported");var Hl=wu(16),Ql={req_id:Hl};au[Hl]={callback:fu},$r.postEvent("web_app_read_text_from_clipboard",!1,Ql)},Ur.requestWriteAccess=function(fu){if(!hu("6.9"))throw console.error("[Telegram.WebApp] Method requestWriteAccess is not supported in version "+Gr),Error("WebAppMethodUnsupported");if(No)throw console.error("[Telegram.WebApp] Write access is already requested"),Error("WebAppWriteAccessRequested");No={callback:fu},$r.postEvent("web_app_request_write_access")},Ur.requestContact=function(fu){if(!hu("6.9"))throw console.error("[Telegram.WebApp] Method requestContact is not supported in version "+Gr),Error("WebAppMethodUnsupported");if(du)throw console.error("[Telegram.WebApp] Contact is already requested"),Error("WebAppContactRequested");du={callback:fu},$r.postEvent("web_app_request_phone")},Ur.invokeCustomMethod=function(fu,Hl,Ql){dp(fu,Hl,Ql)},Ur.ready=function(){$r.postEvent("web_app_ready")},Ur.expand=function(){$r.postEvent("web_app_expand")},Ur.close=function(){$r.postEvent("web_app_close")},window.Telegram.WebApp=Ur,vu(),Gl(),mo(),window.addEventListener("resize",io),Lr&&document.addEventListener("click",lo),$r.onEvent("theme_changed",ho),$r.onEvent("viewport_changed",so),$r.onEvent("invoice_closed",Bu),$r.onEvent("popup_closed",qu),$r.onEvent("qr_text_received",Ju),$r.onEvent("scan_qr_popup_closed",Rl),$r.onEvent("clipboard_text_received",Co),$r.onEvent("write_access_requested",Jl),$r.onEvent("phone_requested",yu),$r.onEvent("custom_method_invoked",Pu),$r.postEvent("web_app_request_theme"),$r.postEvent("web_app_request_viewport")})();var telegramWindow=window,WebApp=telegramWindow.Telegram.WebApp,runtime={exports:{}};(function(Nr){var $r=function(jr){var Lr=Object.prototype,Ur=Lr.hasOwnProperty,Wr=Object.defineProperty||function(Do,Sl,Lo){Do[Sl]=Lo.value},Hr,qr=typeof Symbol=="function"?Symbol:{},Vr=qr.iterator||"@@iterator",Gr=qr.asyncIterator||"@@asyncIterator",Cn=qr.toStringTag||"@@toStringTag";function In(Do,Sl,Lo){return Object.defineProperty(Do,Sl,{value:Lo,enumerable:!0,configurable:!0,writable:!0}),Do[Sl]}try{In({},"")}catch{In=function(Sl,Lo,Eo){return Sl[Lo]=Eo}}function Gn(Do,Sl,Lo,Eo){var ga=Sl&&Sl.prototype instanceof lo?Sl:lo,vu=Object.create(ga.prototype),Bo=new Qo(Eo||[]);return Wr(vu,"_invoke",{value:Au(Do,Lo,Bo)}),vu}jr.wrap=Gn;function Zn(Do,Sl,Lo){try{return{type:"normal",arg:Do.call(Sl,Lo)}}catch(Eo){return{type:"throw",arg:Eo}}}var no="suspendedStart",ho="suspendedYield",xo="executing",so="completed",io={};function lo(){}function co(){}function _o(){}var Ro={};In(Ro,Vr,function(){return this});var fo=Object.getPrototypeOf,jo=fo&&fo(fo(Ml([])));jo&&jo!==Lr&&Ur.call(jo,Vr)&&(Ro=jo);var Kl=_o.prototype=lo.prototype=Object.create(Ro);co.prototype=_o,Wr(Kl,"constructor",{value:_o,configurable:!0}),Wr(_o,"constructor",{value:co,configurable:!0}),co.displayName=In(_o,Cn,"GeneratorFunction");function au(Do){["next","throw","return"].forEach(function(Sl){In(Do,Sl,function(Lo){return this._invoke(Sl,Lo)})})}jr.isGeneratorFunction=function(Do){var Sl=typeof Do=="function"&&Do.constructor;return Sl?Sl===co||(Sl.displayName||Sl.name)==="GeneratorFunction":!1},jr.mark=function(Do){return Object.setPrototypeOf?Object.setPrototypeOf(Do,_o):(Do.__proto__=_o,In(Do,Cn,"GeneratorFunction")),Do.prototype=Object.create(Kl),Do},jr.awrap=function(Do){return{__await:Do}};function wu(Do,Sl){function Lo(vu,Bo,Xo,Al){var Ol=Zn(Do[vu],Do,Bo);if(Ol.type==="throw")Al(Ol.arg);else{var Gl=Ol.arg,So=Gl.value;return So&&typeof So=="object"&&Ur.call(So,"__await")?Sl.resolve(So.__await).then(function(Po){Lo("next",Po,Xo,Al)},function(Po){Lo("throw",Po,Xo,Al)}):Sl.resolve(So).then(function(Po){Gl.value=Po,Xo(Gl)},function(Po){return Lo("throw",Po,Xo,Al)})}}var Eo;function ga(vu,Bo){function Xo(){return new Sl(function(Al,Ol){Lo(vu,Bo,Al,Ol)})}return Eo=Eo?Eo.then(Xo,Xo):Xo()}Wr(this,"_invoke",{value:ga})}au(wu.prototype),In(wu.prototype,Gr,function(){return this}),jr.AsyncIterator=wu,jr.async=function(Do,Sl,Lo,Eo,ga){ga===void 0&&(ga=Promise);var vu=new wu(Gn(Do,Sl,Lo,Eo),ga);return jr.isGeneratorFunction(Sl)?vu:vu.next().then(function(Bo){return Bo.done?Bo.value:vu.next()})};function Au(Do,Sl,Lo){var Eo=no;return function(vu,Bo){if(Eo===xo)throw new Error("Generator is already running");if(Eo===so){if(vu==="throw")throw Bo;return Vo()}for(Lo.method=vu,Lo.arg=Bo;;){var Xo=Lo.delegate;if(Xo){var Al=na(Xo,Lo);if(Al){if(Al===io)continue;return Al}}if(Lo.method==="next")Lo.sent=Lo._sent=Lo.arg;else if(Lo.method==="throw"){if(Eo===no)throw Eo=so,Lo.arg;Lo.dispatchException(Lo.arg)}else Lo.method==="return"&&Lo.abrupt("return",Lo.arg);Eo=xo;var Ol=Zn(Do,Sl,Lo);if(Ol.type==="normal"){if(Eo=Lo.done?so:ho,Ol.arg===io)continue;return{value:Ol.arg,done:Lo.done}}else Ol.type==="throw"&&(Eo=so,Lo.method="throw",Lo.arg=Ol.arg)}}}function na(Do,Sl){var Lo=Sl.method,Eo=Do.iterator[Lo];if(Eo===Hr)return Sl.delegate=null,Lo==="throw"&&Do.iterator.return&&(Sl.method="return",Sl.arg=Hr,na(Do,Sl),Sl.method==="throw")||Lo!=="return"&&(Sl.method="throw",Sl.arg=new TypeError("The iterator does not provide a '"+Lo+"' method")),io;var ga=Zn(Eo,Do.iterator,Sl.arg);if(ga.type==="throw")return Sl.method="throw",Sl.arg=ga.arg,Sl.delegate=null,io;var vu=ga.arg;if(!vu)return Sl.method="throw",Sl.arg=new TypeError("iterator result is not an object"),Sl.delegate=null,io;if(vu.done)Sl[Do.resultName]=vu.value,Sl.next=Do.nextLoc,Sl.method!=="return"&&(Sl.method="next",Sl.arg=Hr);else return vu;return Sl.delegate=null,io}au(Kl),In(Kl,Cn,"Generator"),In(Kl,Vr,function(){return this}),In(Kl,"toString",function(){return"[object Generator]"});function eo(Do){var Sl={tryLoc:Do[0]};1 in Do&&(Sl.catchLoc=Do[1]),2 in Do&&(Sl.finallyLoc=Do[2],Sl.afterLoc=Do[3]),this.tryEntries.push(Sl)}function mo(Do){var Sl=Do.completion||{};Sl.type="normal",delete Sl.arg,Do.completion=Sl}function Qo(Do){this.tryEntries=[{tryLoc:"root"}],Do.forEach(eo,this),this.reset(!0)}jr.keys=function(Do){var Sl=Object(Do),Lo=[];for(var Eo in Sl)Lo.push(Eo);return Lo.reverse(),function ga(){for(;Lo.length;){var vu=Lo.pop();if(vu in Sl)return ga.value=vu,ga.done=!1,ga}return ga.done=!0,ga}};function Ml(Do){if(Do||Do===""){var Sl=Do[Vr];if(Sl)return Sl.call(Do);if(typeof Do.next=="function")return Do;if(!isNaN(Do.length)){var Lo=-1,Eo=function ga(){for(;++Lo=0;--Eo){var ga=this.tryEntries[Eo],vu=ga.completion;if(ga.tryLoc==="root")return Lo("end");if(ga.tryLoc<=this.prev){var Bo=Ur.call(ga,"catchLoc"),Xo=Ur.call(ga,"finallyLoc");if(Bo&&Xo){if(this.prev=0;--Lo){var Eo=this.tryEntries[Lo];if(Eo.tryLoc<=this.prev&&Ur.call(Eo,"finallyLoc")&&this.prev=0;--Sl){var Lo=this.tryEntries[Sl];if(Lo.finallyLoc===Do)return this.complete(Lo.completion,Lo.afterLoc),mo(Lo),io}},catch:function(Do){for(var Sl=this.tryEntries.length-1;Sl>=0;--Sl){var Lo=this.tryEntries[Sl];if(Lo.tryLoc===Do){var Eo=Lo.completion;if(Eo.type==="throw"){var ga=Eo.arg;mo(Lo)}return ga}}throw new Error("illegal catch attempt")},delegateYield:function(Do,Sl,Lo){return this.delegate={iterator:Ml(Do),resultName:Sl,nextLoc:Lo},this.method==="next"&&(this.arg=Hr),io}},jr}(Nr.exports);try{regeneratorRuntime=$r}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=$r:Function("r","regeneratorRuntime = r")($r)}})(runtime);const GAME_FACTORY_ADDR="0x746eD964A6B0ECF7Ab765Dfd831Bf4a715Ac33af";async function fundWallet(Nr){return(await fetch("https://faucet.testnet.inco.org/api/get-faucet",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({address:Nr})})).ok}function App(){var Vo;const{ready:Nr,user:$r,login:jr,logout:Lr,authenticated:Ur}=$(),[Wr,Hr]=reactExports.useState(!1),[qr,Vr]=reactExports.useState(!1),[Gr,Cn]=reactExports.useState(""),[In,Gn]=reactExports.useState(""),[Zn,no]=reactExports.useState("____"),[ho,xo]=reactExports.useState(11),[so,io]=reactExports.useState(!1),[lo,co]=reactExports.useState([]),_o=Do=>{(Do.target.value.length==1||Do.target.value.length==4)&&Cn(Do.target.value)},Ro=Do=>{Do.keyCode===8&&Cn("")},{wallets:fo}=Ja(),jo=fo[0];reactExports.useEffect(()=>{jo==null||jo.getEthersProvider().then(async Do=>{(await Do.getNetwork()).chainId!=9090&&await wu(),await jo.switchChain(9090),jo==null||jo.getEthersProvider().then(async Lo=>{const Eo=await au(Lo);!Wr&&(Eo!=null&&Eo.lte(1e14))?await fundWallet(jo.address)?Hr(!0):WebApp.showPopup({title:"Error",message:"Could not fund wallet"}):Hr(!0)})})},[jo]);const Kl=_default(((Vo=$r==null?void 0:$r.wallet)==null?void 0:Vo.address)||"");async function au(Do){(await Do.getNetwork()).chainId!=9090&&await wu(),await jo.switchChain(9090);const Lo=await(Do==null?void 0:Do.getSigner());return await(Lo==null?void 0:Lo.getBalance())}async function wu(){console.info("Adding network");const Do=await(jo==null?void 0:jo.getEthersProvider());await(Do==null?void 0:Do.send("wallet_addEthereumChain",[{chainId:"0x2382",chainName:"Inco Gentry",nativeCurrency:{name:"IncoToken",symbol:"INCO",decimals:18},rpcUrls:["https://testnet.inco.org/"],blockExplorerUrls:["https://explorer.inco.org/"]}]))}const Au=async()=>{console.info("Creating Game");const Do=await eo(()=>Vr(!0));Gn(Do),Vr(!0),Cn(""),no("____"),xo(11),io(!1),co([]),console.info("Game created"),console.info(Do)},na=async()=>{console.info("Making a guess");const Do=await mo(Gr,()=>{Cn("")});if(console.info("Guessed correctly?:"),console.info(Do),Do){const Sl=await Qo();console.info("Word:"),console.info(Sl),no(Sl),Sl.indexOf("_")===-1&&io(!0)}else console.info("Updating wrong guess list:"),co(lo.concat([Gr])),console.info(lo)},eo=async Do=>{const Sl=await(jo==null?void 0:jo.getEthersProvider());(await Sl.getNetwork()).chainId!=9090&&wu();const Eo=await(Sl==null?void 0:Sl.getSigner()),ga=await(Eo==null?void 0:Eo.getAddress()),Bo=await new Contract(GAME_FACTORY_ADDR,factoryABI,Eo).CreateGame(ga);Do();const Al=(await Bo.wait()).events.find(So=>So.event==="GameCreated"),[Ol,Gl]=Al.args;return console.info("playerAddr:",Ol),Gl},mo=async(Do,Sl)=>{const Lo=await(jo==null?void 0:jo.getEthersProvider());(await Lo.getNetwork()).chainId!=9090&&wu();const ga=await(Lo==null?void 0:Lo.getSigner()),vu=new Contract(In,gameABI,ga);console.info("Before estimate gas");const Bo=await vu.guessLetter(Do);Sl();const Al=(await Bo.wait()).events.find(Ol=>Ol.event==="GuessedCorrectly");if(Al){console.info("Guessed correctly!!");const[Ol]=Al.args;return console.info("correctLetter:"),console.info(Ol),!0}else return ho>0&&xo(ho-1),!1},Qo=async()=>{const Do=await(jo==null?void 0:jo.getEthersProvider());return(await Do.getNetwork()).chainId!=9090&&wu(),await new Contract(In,gameABI,Do).showWord()},Ml=reactExports.useRef();return reactExports.useLayoutEffect(()=>{for(;Ml.current.firstChild;)Ml.current.removeChild(Ml.current.firstChild);new Game({target:Ml.current,props:{wrongGuesses:[...lo],lives:ho,currentWord:Zn,hasWon:so}})},[ho,Zn,lo,so]),jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"Fill"}),jsxRuntimeExports.jsxs("div",{className:"Game",children:[jsxRuntimeExports.jsx("div",{className:"Profile",children:Ur?jsxRuntimeExports.jsxs("div",{className:"Wallet",children:[jsxRuntimeExports.jsx("img",{className:"WalletIcon",src:WalletIcon,alt:"Wallet Icon"}),jsxRuntimeExports.jsx("p",{children:Kl}),jsxRuntimeExports.jsx("button",{className:"LogoutButton",onClick:Lr,children:"Logout"})]}):jsxRuntimeExports.jsx("div",{className:"Wallet",children:jsxRuntimeExports.jsx("p",{children:"No wallet connected"})})}),jsxRuntimeExports.jsx("div",{ref:Ml}),jsxRuntimeExports.jsx("br",{}),jsxRuntimeExports.jsx("br",{}),jsxRuntimeExports.jsx("div",{className:"ActionButtons",children:Nr?Ur?jsxRuntimeExports.jsxs("div",{children:[" ",qr&&ho>0&&!so?jsxRuntimeExports.jsxs("div",{className:"LetterInputForm",children:[jsxRuntimeExports.jsx("input",{className:"LetterInput",type:"text",maxLength:4,placeholder:"A - Z",value:Gr,onChange:_o,onKeyDown:Ro}),jsxRuntimeExports.jsxs("button",{className:"LoginButton",onClick:na,children:["Guess ",ho]})]}):jsxRuntimeExports.jsx("button",{className:"CreateButton",onClick:Au,children:"New Game"})]}):jsxRuntimeExports.jsx("button",{className:"LoginButton",onClick:jr,children:"Login to Play"}):void 0})]})]})}const index="",incoChain={id:9090,network:"Inco Network",name:"Inco",nativeCurrency:{name:"IncoEther",symbol:"INCO",decimals:18},rpcUrls:{default:{http:["https://testnet.inco.org/"]},public:{http:["https://testnet.inco.org/"]}},blockExplorers:{default:{name:"Explorer",url:"https://explorer.inco.org/"}}},handleLogin=Nr=>{console.log(`User ${Nr.id} logged in!`)};WebApp.ready();let loginMethods=["sms","email","discord"];(WebApp.platform==="weba"||WebApp.platform==="webk")&&(loginMethods=["google",...loginMethods]);WebApp.platform!=="android"&&WebApp.platform!=="ios"&&(loginMethods=["wallet",...loginMethods]);client.createRoot(document.getElementById("root")).render(jsxRuntimeExports.jsx(Wv,{appId:"clpyhx1kt00zhky0g7hyv24g1",onSuccess:handleLogin,config:{loginMethods,appearance:{theme:"light",accentColor:"#676FFF",logo:"https://your-logo-url"},supportedChains:[incoChain]},children:jsxRuntimeExports.jsx(React$2.StrictMode,{children:jsxRuntimeExports.jsx(App,{})})}));export{__vitePreload as _,browser as b}; + );`,filename:"/home/runner/work/IncoHangman/IncoHangman/src/Game.svelte",line:42,id:"F7OU"},svrp_start,svrp_exec,start_state,eval("{}"))}},[hasWon,wrongWords,drawingId,splitWord,drawings,wrongGuesses,lives,currentWord,rpGlobal]}class Game extends SvelteComponent{constructor($r){super(),init(this,$r,instance,create_fragment,safe_not_equal,{wrongGuesses:5,lives:6,hasWon:0,currentWord:7})}}(function(){var Nr={},$r="";try{$r=location.hash.toString()}catch{}var jr=Vr($r),Lr=so("initParams");if(Lr)for(var Ur in Lr)typeof jr[Ur]>"u"&&(jr[Ur]=Lr[Ur]);xo("initParams",jr);var Wr=!1,Hr;try{if(Wr=window.parent!=null&&window!=window.parent,Wr){window.addEventListener("message",function(io){if(io.source===window.parent){try{var lo=JSON.parse(io.data)}catch{return}!lo||!lo.eventType||(lo.eventType=="set_custom_style"?Hr.innerHTML=lo.eventData:Gn(lo.eventType,lo.eventData))}}),Hr=document.createElement("style"),document.head.appendChild(Hr);try{window.parent.postMessage(JSON.stringify({eventType:"iframe_ready"}),"*")}catch{}}}catch{}function qr(io){try{return io=io.replace(/\+/g,"%20"),decodeURIComponent(io)}catch{return io}}function Vr(io){io=io.replace(/^#/,"");var lo={};if(!io.length)return lo;if(io.indexOf("=")<0&&io.indexOf("?")<0)return lo._path=qr(io),lo;var co=io.indexOf("?");if(co>=0){var _o=io.substr(0,co);lo._path=qr(_o),io=io.substr(co+1)}var Ro=Gr(io);for(var fo in Ro)lo[fo]=Ro[fo];return lo}function Gr(io){var lo={};if(!io.length)return lo;var co=io.split("&"),_o,Ro,fo,jo;for(_o=0;_o=0?io+"&"+lo:_o.length>0?io+"?"+lo:io+lo}function In(io,lo,co){if(lo||(lo=function(){}),co===void 0&&(co=""),console.log("[Telegram.WebView] > postEvent",io,co),window.TelegramWebviewProxy!==void 0)TelegramWebviewProxy.postEvent(io,JSON.stringify(co)),lo();else if(window.external&&"notify"in window.external)window.external.notify(JSON.stringify({eventType:io,eventData:co})),lo();else if(Wr)try{var _o="https://web.telegram.org";_o="*",window.parent.postMessage(JSON.stringify({eventType:io,eventData:co}),_o),lo()}catch(Ro){lo(Ro)}else lo({notAvailable:!0})}function Gn(io,lo){console.log("[Telegram.WebView] < receiveEvent",io,lo),Zn(io,function(co){co(io,lo)})}function Zn(io,lo){var co=Nr[io];if(!(co===void 0||!co.length))for(var _o=0;_ocp?1:-1;return 0}function hu(fu){return Wl(Gr,fu)>=0}function $u(fu){if(window.Blob)try{return new Blob([fu]).size}catch{}for(var Hl=fu.length,Ql=fu.length-1;Ql>=0;Ql--){var gu=fu.charCodeAt(Ql);gu>127&&gu<=2047?Hl++:gu>2047&&gu<=65535&&(Hl+=2),gu>=56320&&gu<=57343&&Ql--}return Hl}var Vu=function(){var fu=!1,Hl={};Object.defineProperty(Hl,"isVisible",{set:function(fp){Ep({is_visible:fp})},get:function(){return fu},enumerable:!0});var Ql=null;$r.onEvent("back_button_pressed",gu);function gu(){_o("backButtonClicked")}function ju(){return{is_visible:fu}}function cp(fp){return typeof fp>"u"&&(fp=ju()),JSON.stringify(fp)}function op(){return hu("6.1")?!0:(console.warn("[Telegram.WebApp] BackButton is not supported in version "+Gr),!1)}function Pp(){var fp=ju(),vp=cp(fp);Ql!==vp&&(Ql=vp,$r.postEvent("web_app_setup_back_button",!1,fp))}function Ep(fp){return op()&&(typeof fp.is_visible<"u"&&(fu=!!fp.is_visible),Pp()),Hl}return Hl.onClick=function(fp){return op()&&Ro("backButtonClicked",fp),Hl},Hl.offClick=function(fp){return op()&&fo("backButtonClicked",fp),Hl},Hl.show=function(){return Ep({is_visible:!0})},Hl.hide=function(){return Ep({is_visible:!1})},Hl}(),Vl=0,Io=function(){var fu=!1,Hl=!0,Ql=!1,gu="CONTINUE",ju=!1,cp=!1,op={};Object.defineProperty(op,"text",{set:function(gp){op.setParams({text:gp})},get:function(){return gu},enumerable:!0}),Object.defineProperty(op,"color",{set:function(gp){op.setParams({color:gp})},get:function(){return ju||qr.button_color||"#2481cc"},enumerable:!0}),Object.defineProperty(op,"textColor",{set:function(gp){op.setParams({text_color:gp})},get:function(){return cp||qr.button_text_color||"#ffffff"},enumerable:!0}),Object.defineProperty(op,"isVisible",{set:function(gp){op.setParams({is_visible:gp})},get:function(){return fu},enumerable:!0}),Object.defineProperty(op,"isProgressVisible",{get:function(){return Ql},enumerable:!0}),Object.defineProperty(op,"isActive",{set:function(gp){op.setParams({is_active:gp})},get:function(){return Hl},enumerable:!0});var Pp=null;$r.onEvent("main_button_pressed",a0);var Ep=null,fp={};if(jr.tgWebAppDebug){Ep=document.createElement("tg-main-button"),fp={font:"600 14px/18px sans-serif",display:"none",width:"100%",height:"48px",borderRadius:"0",background:"no-repeat right center",position:"fixed",left:"0",right:"0",bottom:"0",margin:"0",padding:"15px 20px",textAlign:"center",boxSizing:"border-box",zIndex:"10000"};for(var vp in fp)Ep.style[vp]=fp[vp];document.addEventListener("DOMContentLoaded",function gp(Op){document.removeEventListener("DOMContentLoaded",gp),document.body.appendChild(Ep),Ep.addEventListener("click",a0,!1)})}function a0(){Hl&&_o("mainButtonClicked")}function r0(){var gp=op.color,Op=op.textColor;return fu?{is_visible:!0,is_active:Hl,is_progress_visible:Ql,text:gu,color:gp,text_color:Op}:{is_visible:!1}}function e0(gp){return typeof gp>"u"&&(gp=r0()),JSON.stringify(gp)}function g0(){var gp=r0(),Op=e0(gp);Pp!==Op&&(Pp=Op,$r.postEvent("web_app_setup_main_button",!1,gp),jr.tgWebAppDebug&&o0(gp))}function o0(gp){gp.is_visible?(Ep.style.display="block",Vl=48,Ep.style.opacity=gp.is_active?"1":"0.8",Ep.style.cursor=gp.is_active?"pointer":"auto",Ep.disabled=!gp.is_active,Ep.innerText=gp.text,Ep.style.backgroundImage=gp.is_progress_visible?"url('data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20xmlns%3Axlink%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink%22%20viewport%3D%220%200%2048%2048%22%20width%3D%2248px%22%20height%3D%2248px%22%3E%3Ccircle%20cx%3D%2250%25%22%20cy%3D%2250%25%22%20stroke%3D%22%23fff%22%20stroke-width%3D%222.25%22%20stroke-linecap%3D%22round%22%20fill%3D%22none%22%20stroke-dashoffset%3D%22106%22%20r%3D%229%22%20stroke-dasharray%3D%2256.52%22%20rotate%3D%22-90%22%3E%3Canimate%20attributeName%3D%22stroke-dashoffset%22%20attributeType%3D%22XML%22%20dur%3D%22360s%22%20from%3D%220%22%20to%3D%2212500%22%20repeatCount%3D%22indefinite%22%3E%3C%2Fanimate%3E%3CanimateTransform%20attributeName%3D%22transform%22%20attributeType%3D%22XML%22%20type%3D%22rotate%22%20dur%3D%221s%22%20from%3D%22-90%2024%2024%22%20to%3D%22630%2024%2024%22%20repeatCount%3D%22indefinite%22%3E%3C%2FanimateTransform%3E%3C%2Fcircle%3E%3C%2Fsvg%3E')":"none",Ep.style.backgroundColor=gp.color,Ep.style.color=gp.text_color):(Ep.style.display="none",Vl=0),document.documentElement&&(document.documentElement.style.boxSizing="border-box",document.documentElement.style.paddingBottom=Vl+"px"),mo()}function n0(gp){if(typeof gp.text<"u"){var Op=co(gp.text);if(!Op.length)throw console.error("[Telegram.WebApp] Main button text is required",gp.text),Error("WebAppMainButtonParamInvalid");if(Op.length>64)throw console.error("[Telegram.WebApp] Main button text is too long",Op),Error("WebAppMainButtonParamInvalid");gu=Op}if(typeof gp.color<"u")if(gp.color===!1||gp.color===null)ju=!1;else{var s0=So(gp.color);if(!s0)throw console.error("[Telegram.WebApp] Main button color format is invalid",gp.color),Error("WebAppMainButtonParamInvalid");ju=s0}if(typeof gp.text_color<"u")if(gp.text_color===!1||gp.text_color===null)cp=!1;else{var w0=So(gp.text_color);if(!w0)throw console.error("[Telegram.WebApp] Main button text color format is invalid",gp.text_color),Error("WebAppMainButtonParamInvalid");cp=w0}if(typeof gp.is_visible<"u"){if(gp.is_visible&&!op.text.length)throw console.error("[Telegram.WebApp] Main button text is required"),Error("WebAppMainButtonParamInvalid");fu=!!gp.is_visible}return typeof gp.is_active<"u"&&(Hl=!!gp.is_active),g0(),op}return op.setText=function(gp){return op.setParams({text:gp})},op.onClick=function(gp){return Ro("mainButtonClicked",gp),op},op.offClick=function(gp){return fo("mainButtonClicked",gp),op},op.show=function(){return op.setParams({is_visible:!0})},op.hide=function(){return op.setParams({is_visible:!1})},op.enable=function(){return op.setParams({is_active:!0})},op.disable=function(){return op.setParams({is_active:!1})},op.showProgress=function(gp){return Hl=!!gp,Ql=!0,g0(),op},op.hideProgress=function(){return op.isActive||(Hl=!0),Ql=!1,g0(),op},op.setParams=n0,op}();function Ko(){_o("settingsButtonClicked")}$r.onEvent("settings_button_pressed",Ko);var uu=function(){var fu={};function Hl(Ql){if(!hu("6.1"))return console.warn("[Telegram.WebApp] HapticFeedback is not supported in version "+Gr),fu;if(Ql.type=="impact"){if(Ql.impact_style!="light"&&Ql.impact_style!="medium"&&Ql.impact_style!="heavy"&&Ql.impact_style!="rigid"&&Ql.impact_style!="soft")throw console.error("[Telegram.WebApp] Haptic impact style is invalid",Ql.impact_style),Error("WebAppHapticImpactStyleInvalid")}else if(Ql.type=="notification"){if(Ql.notification_type!="error"&&Ql.notification_type!="success"&&Ql.notification_type!="warning")throw console.error("[Telegram.WebApp] Haptic notification type is invalid",Ql.notification_type),Error("WebAppHapticNotificationTypeInvalid")}else if(Ql.type!="selection_change")throw console.error("[Telegram.WebApp] Haptic feedback type is invalid",Ql.type),Error("WebAppHapticFeedbackTypeInvalid");return $r.postEvent("web_app_trigger_haptic_feedback",!1,Ql),fu}return fu.impactOccurred=function(Ql){return Hl({type:"impact",impact_style:Ql})},fu.notificationOccurred=function(Ql){return Hl({type:"notification",notification_type:Ql})},fu.selectionChanged=function(){return Hl({type:"selection_change"})},fu}(),mu=function(){var fu={};function Hl(Ql,gu,ju){if(!hu("6.9"))throw console.error("[Telegram.WebApp] CloudStorage is not supported in version "+Gr),Error("WebAppMethodUnsupported");return dp(Ql,gu,ju),fu}return fu.setItem=function(Ql,gu,ju){return Hl("saveStorageValue",{key:Ql,value:gu},ju)},fu.getItem=function(Ql,gu){return fu.getItems([Ql],gu?function(ju,cp){ju?gu(ju):gu(null,cp[Ql])}:null)},fu.getItems=function(Ql,gu){return Hl("getStorageValues",{keys:Ql},gu)},fu.removeItem=function(Ql,gu){return fu.removeItems([Ql],gu)},fu.removeItems=function(Ql,gu){return Hl("deleteStorageValues",{keys:Ql},gu)},fu.getKeys=function(Ql){return Hl("getStorageKeys",{},Ql)},fu}(),Ru={};function Bu(fu,Hl){if(Hl.slug&&Ru[Hl.slug]){var Ql=Ru[Hl.slug];delete Ru[Hl.slug],Ql.callback&&Ql.callback(Hl.status),_o("invoiceClosed",{url:Ql.url,status:Hl.status})}}var Ku=!1;function qu(fu,Hl){if(Ku){var Ql=Ku;Ku=!1;var gu=null;typeof Hl.button_id<"u"&&(gu=Hl.button_id),Ql.callback&&Ql.callback(gu),_o("popupClosed",{button_id:gu})}}var Hu=!1;function Ju(fu,Hl){if(Hu){var Ql=Hu,gu=null;typeof Hl.data<"u"&&(gu=Hl.data),Ql.callback&&Ql.callback(gu)&&(Hu=!1,$r.postEvent("web_app_close_scan_qr_popup",!1)),_o("qrTextReceived",{data:gu})}}function Rl(fu,Hl){Hu=!1}function Co(fu,Hl){if(Hl.req_id&&au[Hl.req_id]){var Ql=au[Hl.req_id];delete au[Hl.req_id];var gu=null;typeof Hl.data<"u"&&(gu=Hl.data),Ql.callback&&Ql.callback(gu),_o("clipboardTextReceived",{data:gu})}}var No=!1;function Jl(fu,Hl){if(No){var Ql=No;No=!1,Ql.callback&&Ql.callback(Hl.status=="allowed"),_o("writeAccessRequested",{status:Hl.status})}}var du=!1;function yu(fu,Hl){if(du){var Ql=du;du=!1,Ql.callback&&Ql.callback(Hl.status=="sent"),_o("contactRequested",{status:Hl.status})}}function Pu(fu,Hl){if(Hl.req_id&&au[Hl.req_id]){var Ql=au[Hl.req_id];delete au[Hl.req_id];var gu=null,ju=null;typeof Hl.result<"u"&&(gu=Hl.result),typeof Hl.error<"u"&&(ju=Hl.error),Ql.callback&&Ql.callback(ju,gu)}}function dp(fu,Hl,Ql){if(!hu("6.9"))throw console.error("[Telegram.WebApp] Method invokeCustomMethod is not supported in version "+Gr),Error("WebAppMethodUnsupported");var gu=wu(16),ju={req_id:gu,method:fu,params:Hl||{}};au[gu]={callback:Ql},$r.postEvent("web_app_invoke_custom_method",!1,ju)}window.Telegram||(window.Telegram={}),Object.defineProperty(Ur,"initData",{get:function(){return Wr},enumerable:!0}),Object.defineProperty(Ur,"initDataUnsafe",{get:function(){return Hr},enumerable:!0}),Object.defineProperty(Ur,"version",{get:function(){return Gr},enumerable:!0}),Object.defineProperty(Ur,"platform",{get:function(){return Cn},enumerable:!0}),Object.defineProperty(Ur,"colorScheme",{get:function(){return Vr},enumerable:!0}),Object.defineProperty(Ur,"themeParams",{get:function(){return qr},enumerable:!0}),Object.defineProperty(Ur,"isExpanded",{get:function(){return eo},enumerable:!0}),Object.defineProperty(Ur,"viewportHeight",{get:function(){return(Au===!1?window.innerHeight:Au)-Vl},enumerable:!0}),Object.defineProperty(Ur,"viewportStableHeight",{get:function(){return(na===!1?window.innerHeight:na)-Vl},enumerable:!0}),Object.defineProperty(Ur,"isClosingConfirmationEnabled",{set:function(fu){Ml(fu)},get:function(){return Qo},enumerable:!0}),Object.defineProperty(Ur,"headerColor",{set:function(fu){Lo(fu)},get:function(){return Sl()},enumerable:!0}),Object.defineProperty(Ur,"backgroundColor",{set:function(fu){Al(fu)},get:function(){return Xo()},enumerable:!0}),Object.defineProperty(Ur,"BackButton",{value:Vu,enumerable:!0}),Object.defineProperty(Ur,"MainButton",{value:Io,enumerable:!0}),Object.defineProperty(Ur,"HapticFeedback",{value:uu,enumerable:!0}),Object.defineProperty(Ur,"CloudStorage",{value:mu,enumerable:!0}),Ur.setHeaderColor=function(fu){Ur.headerColor=fu},Ur.setBackgroundColor=function(fu){Ur.backgroundColor=fu},Ur.enableClosingConfirmation=function(){Ur.isClosingConfirmationEnabled=!0},Ur.disableClosingConfirmation=function(){Ur.isClosingConfirmationEnabled=!1},Ur.isVersionAtLeast=function(fu){return hu(fu)},Ur.onEvent=function(fu,Hl){Ro(fu,Hl)},Ur.offEvent=function(fu,Hl){fo(fu,Hl)},Ur.sendData=function(fu){if(!fu||!fu.length)throw console.error("[Telegram.WebApp] Data is required",fu),Error("WebAppDataInvalid");if($u(fu)>4096)throw console.error("[Telegram.WebApp] Data is too long",fu),Error("WebAppDataInvalid");$r.postEvent("web_app_data_send",!1,{data:fu})},Ur.switchInlineQuery=function(fu,Hl){if(!hu("6.6"))throw console.error("[Telegram.WebApp] Method switchInlineQuery is not supported in version "+Gr),Error("WebAppMethodUnsupported");if(!jr.tgWebAppBotInline)throw console.error("[Telegram.WebApp] Inline mode is disabled for this bot. Read more about inline mode: https://core.telegram.org/bots/inline"),Error("WebAppInlineModeDisabled");if(fu=fu||"",fu.length>256)throw console.error("[Telegram.WebApp] Inline query is too long",fu),Error("WebAppInlineQueryInvalid");var Ql=[];if(Hl){if(!Array.isArray(Hl))throw console.error("[Telegram.WebApp] Choose chat types should be an array",Hl),Error("WebAppInlineChooseChatTypesInvalid");for(var gu={users:1,bots:1,groups:1,channels:1},ju=0;ju64)throw console.error("[Telegram.WebApp] Popup title is too long",Ql),Error("WebAppPopupParamInvalid");Ql.length>0&&(cp.title=Ql)}if(typeof fu.message<"u"&&(gu=co(fu.message)),!gu.length)throw console.error("[Telegram.WebApp] Popup message is required",fu.message),Error("WebAppPopupParamInvalid");if(gu.length>256)throw console.error("[Telegram.WebApp] Popup message is too long",gu),Error("WebAppPopupParamInvalid");if(cp.message=gu,typeof fu.buttons<"u"){if(!Array.isArray(fu.buttons))throw console.error("[Telegram.WebApp] Popup buttons should be an array",fu.buttons),Error("WebAppPopupParamInvalid");for(var op=0;op64))throw console.error("[Telegram.WebApp] Popup button id is too long",fp),Error("WebAppPopupParamInvalid");Ep.id=fp;var vp=Pp.type;if(typeof vp>"u"&&(vp="default"),Ep.type=vp,!(vp=="ok"||vp=="close"||vp=="cancel"))if(vp=="default"||vp=="destructive"){var a0="";if(typeof Pp.text<"u"&&(a0=co(Pp.text)),!a0.length)throw console.error("[Telegram.WebApp] Popup button text is required for type "+vp,Pp.text),Error("WebAppPopupParamInvalid");if(a0.length>64)throw console.error("[Telegram.WebApp] Popup button text is too long",a0),Error("WebAppPopupParamInvalid");Ep.text=a0}else throw console.error("[Telegram.WebApp] Popup button type is invalid",vp),Error("WebAppPopupParamInvalid");ju.push(Ep)}}else ju.push({id:"",type:"close"});if(ju.length<1)throw console.error("[Telegram.WebApp] Popup should have at least one button"),Error("WebAppPopupParamInvalid");if(ju.length>3)throw console.error("[Telegram.WebApp] Popup should not have more than 3 buttons"),Error("WebAppPopupParamInvalid");cp.buttons=ju,Ku={callback:Hl},$r.postEvent("web_app_open_popup",!1,cp)},Ur.showAlert=function(fu,Hl){Ur.showPopup({message:fu},Hl?function(){Hl()}:null)},Ur.showConfirm=function(fu,Hl){Ur.showPopup({message:fu,buttons:[{type:"ok",id:"ok"},{type:"cancel"}]},Hl?function(Ql){Hl(Ql=="ok")}:null)},Ur.showScanQrPopup=function(fu,Hl){if(!hu("6.4"))throw console.error("[Telegram.WebApp] Method showScanQrPopup is not supported in version "+Gr),Error("WebAppMethodUnsupported");if(Hu)throw console.error("[Telegram.WebApp] Popup is already opened"),Error("WebAppScanQrPopupOpened");var Ql="",gu={};if(typeof fu.text<"u"){if(Ql=co(fu.text),Ql.length>64)throw console.error("[Telegram.WebApp] Scan QR popup text is too long",Ql),Error("WebAppScanQrPopupParamInvalid");Ql.length>0&&(gu.text=Ql)}Hu={callback:Hl},$r.postEvent("web_app_open_scan_qr_popup",!1,gu)},Ur.closeScanQrPopup=function(){if(!hu("6.4"))throw console.error("[Telegram.WebApp] Method closeScanQrPopup is not supported in version "+Gr),Error("WebAppMethodUnsupported");Hu=!1,$r.postEvent("web_app_close_scan_qr_popup",!1)},Ur.readTextFromClipboard=function(fu){if(!hu("6.4"))throw console.error("[Telegram.WebApp] Method readTextFromClipboard is not supported in version "+Gr),Error("WebAppMethodUnsupported");var Hl=wu(16),Ql={req_id:Hl};au[Hl]={callback:fu},$r.postEvent("web_app_read_text_from_clipboard",!1,Ql)},Ur.requestWriteAccess=function(fu){if(!hu("6.9"))throw console.error("[Telegram.WebApp] Method requestWriteAccess is not supported in version "+Gr),Error("WebAppMethodUnsupported");if(No)throw console.error("[Telegram.WebApp] Write access is already requested"),Error("WebAppWriteAccessRequested");No={callback:fu},$r.postEvent("web_app_request_write_access")},Ur.requestContact=function(fu){if(!hu("6.9"))throw console.error("[Telegram.WebApp] Method requestContact is not supported in version "+Gr),Error("WebAppMethodUnsupported");if(du)throw console.error("[Telegram.WebApp] Contact is already requested"),Error("WebAppContactRequested");du={callback:fu},$r.postEvent("web_app_request_phone")},Ur.invokeCustomMethod=function(fu,Hl,Ql){dp(fu,Hl,Ql)},Ur.ready=function(){$r.postEvent("web_app_ready")},Ur.expand=function(){$r.postEvent("web_app_expand")},Ur.close=function(){$r.postEvent("web_app_close")},window.Telegram.WebApp=Ur,vu(),Gl(),mo(),window.addEventListener("resize",io),Lr&&document.addEventListener("click",lo),$r.onEvent("theme_changed",ho),$r.onEvent("viewport_changed",so),$r.onEvent("invoice_closed",Bu),$r.onEvent("popup_closed",qu),$r.onEvent("qr_text_received",Ju),$r.onEvent("scan_qr_popup_closed",Rl),$r.onEvent("clipboard_text_received",Co),$r.onEvent("write_access_requested",Jl),$r.onEvent("phone_requested",yu),$r.onEvent("custom_method_invoked",Pu),$r.postEvent("web_app_request_theme"),$r.postEvent("web_app_request_viewport")})();var telegramWindow=window,WebApp=telegramWindow.Telegram.WebApp,runtime={exports:{}};(function(Nr){var $r=function(jr){var Lr=Object.prototype,Ur=Lr.hasOwnProperty,Wr=Object.defineProperty||function(Do,Sl,Lo){Do[Sl]=Lo.value},Hr,qr=typeof Symbol=="function"?Symbol:{},Vr=qr.iterator||"@@iterator",Gr=qr.asyncIterator||"@@asyncIterator",Cn=qr.toStringTag||"@@toStringTag";function In(Do,Sl,Lo){return Object.defineProperty(Do,Sl,{value:Lo,enumerable:!0,configurable:!0,writable:!0}),Do[Sl]}try{In({},"")}catch{In=function(Sl,Lo,Eo){return Sl[Lo]=Eo}}function Gn(Do,Sl,Lo,Eo){var ga=Sl&&Sl.prototype instanceof lo?Sl:lo,vu=Object.create(ga.prototype),Bo=new Qo(Eo||[]);return Wr(vu,"_invoke",{value:Au(Do,Lo,Bo)}),vu}jr.wrap=Gn;function Zn(Do,Sl,Lo){try{return{type:"normal",arg:Do.call(Sl,Lo)}}catch(Eo){return{type:"throw",arg:Eo}}}var no="suspendedStart",ho="suspendedYield",xo="executing",so="completed",io={};function lo(){}function co(){}function _o(){}var Ro={};In(Ro,Vr,function(){return this});var fo=Object.getPrototypeOf,jo=fo&&fo(fo(Ml([])));jo&&jo!==Lr&&Ur.call(jo,Vr)&&(Ro=jo);var Kl=_o.prototype=lo.prototype=Object.create(Ro);co.prototype=_o,Wr(Kl,"constructor",{value:_o,configurable:!0}),Wr(_o,"constructor",{value:co,configurable:!0}),co.displayName=In(_o,Cn,"GeneratorFunction");function au(Do){["next","throw","return"].forEach(function(Sl){In(Do,Sl,function(Lo){return this._invoke(Sl,Lo)})})}jr.isGeneratorFunction=function(Do){var Sl=typeof Do=="function"&&Do.constructor;return Sl?Sl===co||(Sl.displayName||Sl.name)==="GeneratorFunction":!1},jr.mark=function(Do){return Object.setPrototypeOf?Object.setPrototypeOf(Do,_o):(Do.__proto__=_o,In(Do,Cn,"GeneratorFunction")),Do.prototype=Object.create(Kl),Do},jr.awrap=function(Do){return{__await:Do}};function wu(Do,Sl){function Lo(vu,Bo,Xo,Al){var Ol=Zn(Do[vu],Do,Bo);if(Ol.type==="throw")Al(Ol.arg);else{var Gl=Ol.arg,So=Gl.value;return So&&typeof So=="object"&&Ur.call(So,"__await")?Sl.resolve(So.__await).then(function(Po){Lo("next",Po,Xo,Al)},function(Po){Lo("throw",Po,Xo,Al)}):Sl.resolve(So).then(function(Po){Gl.value=Po,Xo(Gl)},function(Po){return Lo("throw",Po,Xo,Al)})}}var Eo;function ga(vu,Bo){function Xo(){return new Sl(function(Al,Ol){Lo(vu,Bo,Al,Ol)})}return Eo=Eo?Eo.then(Xo,Xo):Xo()}Wr(this,"_invoke",{value:ga})}au(wu.prototype),In(wu.prototype,Gr,function(){return this}),jr.AsyncIterator=wu,jr.async=function(Do,Sl,Lo,Eo,ga){ga===void 0&&(ga=Promise);var vu=new wu(Gn(Do,Sl,Lo,Eo),ga);return jr.isGeneratorFunction(Sl)?vu:vu.next().then(function(Bo){return Bo.done?Bo.value:vu.next()})};function Au(Do,Sl,Lo){var Eo=no;return function(vu,Bo){if(Eo===xo)throw new Error("Generator is already running");if(Eo===so){if(vu==="throw")throw Bo;return Vo()}for(Lo.method=vu,Lo.arg=Bo;;){var Xo=Lo.delegate;if(Xo){var Al=na(Xo,Lo);if(Al){if(Al===io)continue;return Al}}if(Lo.method==="next")Lo.sent=Lo._sent=Lo.arg;else if(Lo.method==="throw"){if(Eo===no)throw Eo=so,Lo.arg;Lo.dispatchException(Lo.arg)}else Lo.method==="return"&&Lo.abrupt("return",Lo.arg);Eo=xo;var Ol=Zn(Do,Sl,Lo);if(Ol.type==="normal"){if(Eo=Lo.done?so:ho,Ol.arg===io)continue;return{value:Ol.arg,done:Lo.done}}else Ol.type==="throw"&&(Eo=so,Lo.method="throw",Lo.arg=Ol.arg)}}}function na(Do,Sl){var Lo=Sl.method,Eo=Do.iterator[Lo];if(Eo===Hr)return Sl.delegate=null,Lo==="throw"&&Do.iterator.return&&(Sl.method="return",Sl.arg=Hr,na(Do,Sl),Sl.method==="throw")||Lo!=="return"&&(Sl.method="throw",Sl.arg=new TypeError("The iterator does not provide a '"+Lo+"' method")),io;var ga=Zn(Eo,Do.iterator,Sl.arg);if(ga.type==="throw")return Sl.method="throw",Sl.arg=ga.arg,Sl.delegate=null,io;var vu=ga.arg;if(!vu)return Sl.method="throw",Sl.arg=new TypeError("iterator result is not an object"),Sl.delegate=null,io;if(vu.done)Sl[Do.resultName]=vu.value,Sl.next=Do.nextLoc,Sl.method!=="return"&&(Sl.method="next",Sl.arg=Hr);else return vu;return Sl.delegate=null,io}au(Kl),In(Kl,Cn,"Generator"),In(Kl,Vr,function(){return this}),In(Kl,"toString",function(){return"[object Generator]"});function eo(Do){var Sl={tryLoc:Do[0]};1 in Do&&(Sl.catchLoc=Do[1]),2 in Do&&(Sl.finallyLoc=Do[2],Sl.afterLoc=Do[3]),this.tryEntries.push(Sl)}function mo(Do){var Sl=Do.completion||{};Sl.type="normal",delete Sl.arg,Do.completion=Sl}function Qo(Do){this.tryEntries=[{tryLoc:"root"}],Do.forEach(eo,this),this.reset(!0)}jr.keys=function(Do){var Sl=Object(Do),Lo=[];for(var Eo in Sl)Lo.push(Eo);return Lo.reverse(),function ga(){for(;Lo.length;){var vu=Lo.pop();if(vu in Sl)return ga.value=vu,ga.done=!1,ga}return ga.done=!0,ga}};function Ml(Do){if(Do||Do===""){var Sl=Do[Vr];if(Sl)return Sl.call(Do);if(typeof Do.next=="function")return Do;if(!isNaN(Do.length)){var Lo=-1,Eo=function ga(){for(;++Lo=0;--Eo){var ga=this.tryEntries[Eo],vu=ga.completion;if(ga.tryLoc==="root")return Lo("end");if(ga.tryLoc<=this.prev){var Bo=Ur.call(ga,"catchLoc"),Xo=Ur.call(ga,"finallyLoc");if(Bo&&Xo){if(this.prev=0;--Lo){var Eo=this.tryEntries[Lo];if(Eo.tryLoc<=this.prev&&Ur.call(Eo,"finallyLoc")&&this.prev=0;--Sl){var Lo=this.tryEntries[Sl];if(Lo.finallyLoc===Do)return this.complete(Lo.completion,Lo.afterLoc),mo(Lo),io}},catch:function(Do){for(var Sl=this.tryEntries.length-1;Sl>=0;--Sl){var Lo=this.tryEntries[Sl];if(Lo.tryLoc===Do){var Eo=Lo.completion;if(Eo.type==="throw"){var ga=Eo.arg;mo(Lo)}return ga}}throw new Error("illegal catch attempt")},delegateYield:function(Do,Sl,Lo){return this.delegate={iterator:Ml(Do),resultName:Sl,nextLoc:Lo},this.method==="next"&&(this.arg=Hr),io}},jr}(Nr.exports);try{regeneratorRuntime=$r}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=$r:Function("r","regeneratorRuntime = r")($r)}})(runtime);const GAME_FACTORY_ADDR="0x746eD964A6B0ECF7Ab765Dfd831Bf4a715Ac33af";async function fundWallet(Nr){return console.info("Funding wallet"),(await fetch("https://faucet.testnet.inco.org/api/get-faucet",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({address:Nr})})).ok}function App(){var Vo;const{ready:Nr,user:$r,login:jr,logout:Lr,authenticated:Ur}=$(),[Wr,Hr]=reactExports.useState(!1),[qr,Vr]=reactExports.useState(!1),[Gr,Cn]=reactExports.useState(""),[In,Gn]=reactExports.useState(""),[Zn,no]=reactExports.useState("____"),[ho,xo]=reactExports.useState(11),[so,io]=reactExports.useState(!1),[lo,co]=reactExports.useState([]),_o=Do=>{(Do.target.value.length==1||Do.target.value.length==4)&&Cn(Do.target.value)},Ro=Do=>{Do.keyCode===8&&Cn("")},{wallets:fo}=Ja(),jo=fo[0];reactExports.useEffect(()=>{jo==null||jo.getEthersProvider().then(async Do=>{(await Do.getNetwork()).chainId!=9090&&await wu(),await jo.switchChain(9090),jo==null||jo.getEthersProvider().then(async Lo=>{const Eo=await au(Lo);!Wr&&(Eo!=null&&Eo.lte(1e14))?await fundWallet(jo.address)?Hr(!0):WebApp.showPopup({title:"Error",message:"Could not fund wallet"}):Hr(!0)})})},[jo,Ur]);const Kl=_default(((Vo=$r==null?void 0:$r.wallet)==null?void 0:Vo.address)||"");async function au(Do){(await Do.getNetwork()).chainId!=9090&&await wu(),await jo.switchChain(9090);const Lo=await(Do==null?void 0:Do.getSigner());return await(Lo==null?void 0:Lo.getBalance())}async function wu(){console.info("Adding network");const Do=await(jo==null?void 0:jo.getEthersProvider());await(Do==null?void 0:Do.send("wallet_addEthereumChain",[{chainId:"0x2382",chainName:"Inco Gentry",nativeCurrency:{name:"IncoToken",symbol:"INCO",decimals:18},rpcUrls:["https://testnet.inco.org/"],blockExplorerUrls:["https://explorer.inco.org/"]}]))}const Au=async()=>{console.info("Creating Game");const Do=await eo(()=>Vr(!0));Gn(Do),Vr(!0),Cn(""),no("____"),xo(11),io(!1),co([]),console.info("Game created"),console.info(Do)},na=async()=>{console.info("Making a guess");const Do=await mo(Gr,()=>{Cn("")});if(console.info("Guessed correctly?:"),console.info(Do),Do){const Sl=await Qo();console.info("Word:"),console.info(Sl),no(Sl),Sl.indexOf("_")===-1&&io(!0)}else console.info("Updating wrong guess list:"),co(lo.concat([Gr])),console.info(lo)},eo=async Do=>{const Sl=await(jo==null?void 0:jo.getEthersProvider());(await Sl.getNetwork()).chainId!=9090&&wu();const Eo=await(Sl==null?void 0:Sl.getSigner()),ga=await(Eo==null?void 0:Eo.getAddress()),Bo=await new Contract(GAME_FACTORY_ADDR,factoryABI,Eo).CreateGame(ga);Do();const Al=(await Bo.wait()).events.find(So=>So.event==="GameCreated"),[Ol,Gl]=Al.args;return console.info("playerAddr:",Ol),Gl},mo=async(Do,Sl)=>{const Lo=await(jo==null?void 0:jo.getEthersProvider());(await Lo.getNetwork()).chainId!=9090&&wu();const ga=await(Lo==null?void 0:Lo.getSigner()),vu=new Contract(In,gameABI,ga);console.info("Before estimate gas");const Bo=await vu.guessLetter(Do);Sl();const Al=(await Bo.wait()).events.find(Ol=>Ol.event==="GuessedCorrectly");if(Al){console.info("Guessed correctly!!");const[Ol]=Al.args;return console.info("correctLetter:"),console.info(Ol),!0}else return ho>0&&xo(ho-1),!1},Qo=async()=>{const Do=await(jo==null?void 0:jo.getEthersProvider());return(await Do.getNetwork()).chainId!=9090&&wu(),await new Contract(In,gameABI,Do).showWord()},Ml=reactExports.useRef();return reactExports.useLayoutEffect(()=>{for(;Ml.current.firstChild;)Ml.current.removeChild(Ml.current.firstChild);new Game({target:Ml.current,props:{wrongGuesses:[...lo],lives:ho,currentWord:Zn,hasWon:so}})},[ho,Zn,lo,so]),jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"Fill"}),jsxRuntimeExports.jsxs("div",{className:"Game",children:[jsxRuntimeExports.jsx("div",{className:"Profile",children:Ur?jsxRuntimeExports.jsxs("div",{className:"Wallet",children:[jsxRuntimeExports.jsx("img",{className:"WalletIcon",src:WalletIcon,alt:"Wallet Icon"}),jsxRuntimeExports.jsx("p",{children:Kl}),jsxRuntimeExports.jsx("button",{className:"LogoutButton",onClick:Lr,children:"Logout"})]}):jsxRuntimeExports.jsx("div",{className:"Wallet",children:jsxRuntimeExports.jsx("p",{children:"No wallet connected"})})}),jsxRuntimeExports.jsx("div",{ref:Ml}),jsxRuntimeExports.jsx("br",{}),jsxRuntimeExports.jsx("br",{}),jsxRuntimeExports.jsx("div",{className:"ActionButtons",children:Nr?Ur?jsxRuntimeExports.jsxs("div",{children:[" ",qr&&ho>0&&!so?jsxRuntimeExports.jsxs("div",{className:"LetterInputForm",children:[jsxRuntimeExports.jsx("input",{className:"LetterInput",type:"text",maxLength:4,placeholder:"A - Z",value:Gr,onChange:_o,onKeyDown:Ro}),jsxRuntimeExports.jsxs("button",{className:"LoginButton",onClick:na,children:["Guess ",ho]})]}):jsxRuntimeExports.jsx("button",{className:"CreateButton",onClick:Au,children:"New Game"})]}):jsxRuntimeExports.jsx("button",{className:"LoginButton",onClick:jr,children:"Login to Play"}):void 0})]})]})}const index="",incoChain={id:9090,network:"Inco Network",name:"Inco",nativeCurrency:{name:"IncoEther",symbol:"INCO",decimals:18},rpcUrls:{default:{http:["https://testnet.inco.org/"]},public:{http:["https://testnet.inco.org/"]}},blockExplorers:{default:{name:"Explorer",url:"https://explorer.inco.org/"}}},handleLogin=Nr=>{console.log(`User ${Nr.id} logged in!`)};WebApp.ready();let loginMethods=["sms","email","discord"];(WebApp.platform==="weba"||WebApp.platform==="webk")&&(loginMethods=["google",...loginMethods]);WebApp.platform!=="android"&&WebApp.platform!=="ios"&&(loginMethods=["wallet",...loginMethods]);client.createRoot(document.getElementById("root")).render(jsxRuntimeExports.jsx(Wv,{appId:"clpyhx1kt00zhky0g7hyv24g1",onSuccess:handleLogin,config:{loginMethods,appearance:{theme:"light",accentColor:"#676FFF",logo:"https://your-logo-url"},supportedChains:[incoChain]},children:jsxRuntimeExports.jsx(React$2.StrictMode,{children:jsxRuntimeExports.jsx(App,{})})}));export{__vitePreload as _,browser as b}; diff --git a/assets/index-4941fbd1.js b/assets/index-510a7f22.js similarity index 99% rename from assets/index-4941fbd1.js rename to assets/index-510a7f22.js index 4779f75..ba6ed6c 100644 --- a/assets/index-4941fbd1.js +++ b/assets/index-510a7f22.js @@ -1,4 +1,4 @@ -import{n as ve,s as qe,T as k,t as W,a as u,o as Q,R as jr,p as U,y as ne}from"./index-7992f12d.js";import{b as Nr}from"./index-eca98261.js";/** +import{n as ve,s as qe,T as k,t as W,a as u,o as Q,R as jr,p as U,y as ne}from"./index-32d7b86e.js";import{b as Nr}from"./index-47efff01.js";/** * @license * Copyright 2019 Google LLC * SPDX-License-Identifier: BSD-3-Clause diff --git a/index.html b/index.html index 93ab29d..dee5443 100644 --- a/index.html +++ b/index.html @@ -16,7 +16,7 @@ } Vite + React + TS - +