@vechain/vechain-kit 2.0.3 → 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -110,13 +110,13 @@ import{A as e,B as t,C as n,E as r,H as i,J as a,O as o,Q as s,S as c,U as l,V a
110
110
  opacity: 0.5 !important;
111
111
  }
112
112
  `),d.length>0&&(u.textContent=d.join(`
113
- `))}let Ga=null;function Ka(){return Ga||=new Fn({defaultOptions:{queries:{queryKeyHashFn:Bn,retry:0,staleTime:3e4,refetchOnWindowFocus:!0,refetchOnMount:!0,refetchOnReconnect:!0,refetchInterval:!1,refetchIntervalInBackground:!1}}}),Ga}const qa=({children:e})=>{try{if(V.useContext(In))return q(K,{children:e})}catch(e){console.log(e)}return q(Ln,{client:Ka(),children:e})},Ja=({onClick:e,...t})=>q(lt,{"aria-label":`Back`,icon:q(N,{as:nr,fontSize:`20px`}),size:`sm`,variant:`ghost`,position:`absolute`,borderRadius:`50%`,left:`10px`,top:`10px`,onClick:e,...t}),Ya=({wallet:e,label:t,style:n,showHumanAddress:r=!0})=>{let[i,a]=G(!1),[o,s]=G(!1),c=B(`colors`,`vechain-kit-text-primary`),u=B(`colors`,`vechain-kit-text-secondary`),d=async(e,t)=>{await ie(e)&&(t(!0),setTimeout(()=>{t(!1)},2e3))};return q(z,{w:`full`,justifyContent:`center`,...n,children:J(z,{w:`full`,spacing:4,children:[t&&q(R,{fontSize:`sm`,color:u,children:t}),e?.domain?J(z,{spacing:2,w:`full`,children:[J(ft,{children:[q(pt,{children:q(N,{as:Fr,color:u})}),q(dt,{cursor:`pointer`,value:e.domain,readOnly:!0,fontSize:`sm`,fontWeight:`700`,color:c,onClick:()=>d(e.domain||``,s)}),q(mt,{children:q(N,{color:u,onClick:()=>d(e.domain||``,s),cursor:`pointer`,as:o?er:lr})})]}),J(ft,{children:[q(pt,{children:q(N,{as:Br,color:u})}),q(dt,{cursor:`pointer`,value:r?l(e.address??``,8,7):e.address,readOnly:!0,fontSize:`sm`,fontWeight:`700`,color:c,onClick:()=>d(e.address??``,a)}),q(mt,{children:q(N,{color:u,cursor:`pointer`,onClick:()=>d(e.address??``,a),as:i?er:lr})})]})]}):J(ft,{children:[q(pt,{children:q(N,{as:Br,color:u})}),q(dt,{cursor:`pointer`,value:r?l(e?.address??``,6,4):e?.address,readOnly:!0,fontSize:`sm`,fontWeight:`700`,color:c,onClick:()=>d(e?.address??``,a)}),q(mt,{children:q(N,{color:u,onClick:()=>d(e?.address??``,a),cursor:`pointer`,as:i?er:lr})})]})]})})};var Xa=`2.0.3`;const Za=({...e})=>{let{darkMode:t}=$();return J(M,{w:`full`,justifyContent:`center`,alignItems:`center`,spacing:0,...e,children:[q(fe,{isDark:t,w:`70px`,h:`auto`,opacity:.4,mr:1,ml:`-16px`}),J(ht,{fontSize:`11px`,fontWeight:`500`,opacity:.4,textAlign:`left`,href:`https://github.com/vechain/vechain-kit/releases/tag/${Xa}`,isExternal:!0,pt:`1px`,children:[`v`,Xa]})]})},Z=({children:e})=>{let[t,n]=G(!1),r=Zt(null),{tokens:i}=td(),a=i?.effects?.backdropFilter?.stickyHeader??`blur(12px)`,o=B(`colors`,`vechain-kit-sticky-header`);return U(()=>{let e=new IntersectionObserver(([e])=>{n(!e.isIntersecting)},{threshold:0});return r.current&&e.observe(r.current),()=>e.disconnect()},[]),J(K,{children:[q(A,{position:`sticky`,top:`0`,left:`0`,w:`full`,borderRadius:`24px 24px 0px 0px`,bg:t?o:`transparent`,backdropFilter:t?a:`none`,style:{WebkitBackdropFilter:t?a:`none`},zIndex:1e3,boxShadow:t?`0px 2px 4px 1px rgb(0 0 0 / 10%)`:`none`,transition:`box-shadow 0.2s ease-in-out`,children:e}),q(`div`,{ref:r,style:{position:`absolute`,top:`25px`}})]})},Qa=({children:e})=>q(A,{position:`sticky`,bottom:`0`,left:`0`,right:`0`,bg:B(`colors`,`vechain-kit-modal`),zIndex:`1000`,p:4,boxShadow:`0px -1px 6px -3px rgb(0 0 0 / 56%)`,transition:`box-shadow 0.2s ease-in-out`,children:e}),$a=({isOpen:e,onClose:t,children:n,size:r=`sm`,isCentered:i=!0,motionPreset:a=`slideInBottom`,closeOnOverlayClick:o=!0,blockScrollOnMount:s=!1,allowExternalFocus:c=!1,backdropFilter:l,isCloseable:u=!0})=>{let[d]=Kt(`(min-width: 768px)`),{portalRootRef:f}=td(),p=B(`colors`,`vechain-kit-modal`),m=B(`colors`,`vechain-kit-overlay`),{tokens:h}=td(),g=h?.effects?.backdropFilter?.overlay,_=h?.effects?.backdropFilter?.modal,v=l??g??`blur(3px)`,y=d?{}:{position:`fixed`,bottom:`0`,mb:`0`,maxW:`2xl`,borderRadius:`24px 24px 0px 0px !important`,overflowY:`auto`,overflowX:`hidden`,scrollBehavior:`smooth`};return J(vt,{motionPreset:a,isOpen:e,onClose:t,isCentered:i,size:r,returnFocusOnClose:!1,blockScrollOnMount:s,closeOnOverlayClick:o&&u,preserveScrollBarGap:!0,portalProps:{containerRef:f},trapFocus:!c,autoFocus:!c,children:[q(bt,{bg:m,backdropFilter:v}),q(yt,{role:`dialog`,"aria-modal":!c,bg:p,variant:`vechainKitBase`,sx:{backdropFilter:_,WebkitBackdropFilter:_},...y,children:n})]})},eo=(e,t,n)=>{switch(t){case`eur`:return e/n.eurUsdPrice;case`gbp`:return e/n.gbpUsdPrice;default:return e}},to=(e,t=`en`,n)=>{let r={style:`currency`,minimumFractionDigits:2,maximumFractionDigits:2,currency:n?.currency??`usd`,...n};return new Intl.NumberFormat(xa[t],r).format(e)},no=(e,t)=>to(e,Ca.resolvedLanguage,{notation:`compact`,compactDisplay:`short`,currency:t?.currency??`usd`,...t}),ro=({symbol:e,amount:t,currencyValue:n,currentCurrency:r,isDisabled:i,onClick:a,...o})=>{let c=B(`colors`,`vechain-kit-text-primary`),l=B(`colors`,`vechain-kit-text-secondary`);return J(j,{height:`72px`,variant:`ghost`,justifyContent:`space-between`,isDisabled:i,p:4,w:`100%`,_disabled:{cursor:`not-allowed`,opacity:.5},onClick:a,"data-testid":`asset-${e}`,...o,children:[J(M,{children:[s[e]?V.cloneElement(s[e],{boxSize:`24px`,borderRadius:`full`}):q(ut,{src:p[e],alt:`${e} logo`,boxSize:`24px`,borderRadius:`full`,fallback:q(A,{boxSize:`24px`,borderRadius:`full`,bg:`whiteAlpha.200`,display:`flex`,alignItems:`center`,justifyContent:`center`,children:q(R,{fontSize:`10px`,fontWeight:`bold`,color:c,children:e.slice(0,3)})})}),q(R,{color:c,children:e})]}),J(z,{align:`flex-end`,spacing:0,children:[J(R,{color:c,children:[t.toLocaleString(void 0,{maximumFractionDigits:2}),` `]}),q(R,{fontSize:`sm`,color:l,"data-testid":`${e}-balance`,children:no(n,{currency:r})})]})]})},io=async e=>{let t=await fetch(`https://auth.privy.io/api/v1/apps/${e}`,{headers:{"privy-app-id":e}});if(!t.ok)throw Error(`Failed to fetch Privy app info`);return t.json()},ao=e=>[`VECHAIN_KIT_PRIVY_APP_INFO`,...Array.isArray(e)?e:[e]],oo=e=>{let t=Array.isArray(e)?e:[e];return X({queryKey:ao(e),queryFn:async()=>{let e=await Promise.all(t.map(e=>io(e)));return Object.fromEntries(e.map((e,n)=>{let r=t[n],i=a.find(e=>e.id===r);return[r,{...e,website:i?.website}]}))},enabled:t.length>0,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`))return!1}return e<2},gcTime:1e3*60*5,staleTime:1e3*60})},so=async()=>{try{let e=await fetch(`https://status.privy.io/summary.json`);if(!e.ok)throw Error(`Failed to fetch Privy status`);return(await e.json()).page.status??`No data`}catch(e){return console.error(`Error fetching data:`,e),`Error fetching data`}},co=()=>X({queryKey:[`PRIVY_STATUS`],queryFn:so,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`))return!1}return e<2},gcTime:1e3*60*5,staleTime:1e3*60}),lo=e=>[`VECHAIN_KIT_DOMAIN`,e],uo=t=>{let{network:n}=$();return X({queryKey:lo(t),queryFn:async()=>{if(!t)throw Error(`Address or domain is required`);let r=await Zr(t,{networkUrl:n.nodeUrl}),i=e(t);if(!r&&!i)throw Error(`Input must be a valid domain or address`);let a=null,o=null,s=!1;return r?(a=await Gr(t,{networkUrl:n.nodeUrl}),o=t,a&&(s=await Xr(t,a,{networkUrl:n.nodeUrl}))):(o=await Hr(t,{networkUrl:n.nodeUrl}),a=t,o&&(s=await Xr(o,t,{networkUrl:n.nodeUrl}))),{address:a||void 0,domain:o||void 0,isValidAddressOrDomain:r||i,isPrimaryDomain:s}},enabled:!!t&&!!n.type,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`)||e===`address or domain is required`||e===`input must be a valid domain or address`)return!1}return e<2},gcTime:1e3*60*5,staleTime:1e3*60})},fo=async(e,t,n)=>{let r=vi(fi([`0x571e15b4bbf879cf28e5075190137be8e18500e3d38543bf0cbcdb54e00b02cc`,vi(Si(n))])),i=await e.contracts.load(k(t).vetDomainsContractAddress,oi.abi).read.recordExists(r);if(!i)throw Error(`Failed to get ENS record exists for ${n}`);return i[0]},po=e=>[`VECHAIN_KIT_ENS_RECORD_VE_WORLD_EXISTS`,e],mo=e=>{let t=jn(),{network:n}=$();return X({queryKey:po(e),queryFn:()=>fo(t,n.type,e),enabled:!!e,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`))return!1}return e<2},gcTime:1e3*60*5,staleTime:1e3*60})},ho=(e,t)=>{let n=zn(),{network:r}=$();return{refresh:async()=>{await Promise.all([n.invalidateQueries({queryKey:Po(e??``,r.type)}),n.invalidateQueries({queryKey:Ro(e,r.type)}),n.invalidateQueries({queryKey:Go(t)})])}}},go=async(e,t,n,r,i,a)=>{await Promise.all([e.invalidateQueries({queryKey:lo(t)}),e.invalidateQueries({queryKey:lo(n)}),e.invalidateQueries({queryKey:po(r)}),e.invalidateQueries({queryKey:Mo(t,`.vet`)}),e.invalidateQueries({queryKey:Mo(t,`.veworld.vet`)}),e.invalidateQueries({queryKey:Ro(n)})]),await Promise.all([e.refetchQueries({queryKey:lo(t)}),e.refetchQueries({queryKey:lo(n)}),e.refetchQueries({queryKey:Mo(t,`.vet`)}),e.refetchQueries({queryKey:Mo(t,`.veworld.vet`)}),e.refetchQueries({queryKey:Po(r+`.`+i,a)}),e.refetchQueries({queryKey:Ro(n)}),e.refetchQueries({queryKey:po(r)}),e.refetchQueries({queryKey:Go(t)})])},_o=ci.createInterface(),vo=si.createInterface(),yo=(e,t,n,r,i)=>{let a=[];if(!e)throw Error(`Invalid subdomain`);let o=`${e}.${t}`;if(a.push({to:k(i.type).vetDomainsReverseRegistrarAddress,value:`0x0`,data:vo.encodeFunctionData(`setName`,[``]),comment:`Unsetting your current VeChain nickname of the account ${l(r?.address??``,4,4)}`,abi:vo.getFunction(`setName`)}),n){a.push({to:k(i.type).vetDomainsReverseRegistrarAddress,value:`0x0`,data:vo.encodeFunctionData(`setName`,[o]),comment:`Setting your VeChain nickname to ${o}`,abi:vo.getFunction(`setName`)});let e=new en.Interface([`function setAddr(bytes32 node, address addr)`]),t=en.namehash(o);a.push({to:k(i.type).vetDomainsPublicResolverAddress,value:`0x0`,data:e.encodeFunctionData(`setAddr`,[t,r?.address||``]),comment:`Setting the address for ${o} to ${l(r?.address??``,4,4)}`,abi:e.getFunction(`setAddr`)})}else if(xo(t))a.push({to:k(i.type).veWorldSubdomainClaimerContractAddress,value:`0x0`,data:_o.encodeFunctionData(`claim`,[e,k(i.type).vetDomainsPublicResolverAddress]),comment:`Claim VeChain subdomain: ${e}.${t}`,abi:_o.getFunction(`claim`)}),a.push({to:k(i.type).vetDomainsReverseRegistrarAddress,value:`0x0`,data:vo.encodeFunctionData(`setName`,[e+`.`+t]),comment:`Set ${e}.${t} as the VeChain nickname of the account ${l(r?.address??``,4,4)}`,abi:vo.getFunction(`setName`)});else throw Error(`This hook only supports .veworld.vet subdomains`);return a},bo=({subdomain:e,domain:t,onSuccess:n,onError:r,alreadyOwned:i=!1})=>{let a=zn(),{account:o}=Q(),{network:s}=$(),{refresh:c}=ho(e+`.`+t,o?.address??``),l=H(()=>yo(e,t,i,o,s),[e,t,i,o,s]),u=H(async()=>{let r=`${e}.${t}`;await go(a,o?.address??``,r,e,t,s.type),c(),n?.()},[n,e,t,a,o,s.type,c]),d=lc({signerAccountAddress:o?.address??``,privyUIOptions:{title:`Sign to claim your VeChain nickname`,description:`Claim ${e}.${t} as your VeChain nickname`,buttonText:`Sign to continue`},onTxConfirmed:u,onTxFailedOrCancelled:()=>{r?.()}});return{...d,clauses:l,sendTransaction:async()=>d.sendTransaction(l())}},xo=e=>e.endsWith(`veworld.vet`),So=si.createInterface(),Co=(e,t,n,r)=>{let i=[];if(!e)throw Error(`Invalid domain`);if(t){i.push({to:k(r.type).vetDomainsReverseRegistrarAddress,value:`0x0`,data:So.encodeFunctionData(`setName`,[e]),comment:`Setting your VeChain nickname to ${e}`,abi:So.getFunction(`setName`)});let t=new en.Interface([`function setAddr(bytes32 node, address addr)`]),a=en.namehash(e);i.push({to:k(r.type).vetDomainsPublicResolverAddress,value:`0x0`,data:t.encodeFunctionData(`setAddr`,[a,n?.address||``]),comment:`Setting the address for ${e} to ${l(n?.address??``,4,4)}`,abi:t.getFunction(`setAddr`)})}else throw Error(`Primary .vet domains are not supported yet`);return i},wo=({domain:e,onSuccess:t,onError:n,alreadyOwned:r=!1})=>{let{network:i}=$(),a=zn(),{account:o}=Q(),{refresh:s}=ho(e,o?.address??``),c=H(()=>Co(e,r,o,i),[e,r,o,i]),l=H(async()=>{await go(a,o?.address??``,e,``,e.endsWith(`.vet`)?e:`${e}.vet`,i.type),s(),t?.()},[t,e,a,o,i.type,s]),u=lc({signerAccountAddress:o?.address??``,privyUIOptions:{title:`Sign to claim your VeChain nickname`,description:`Claim ${e} as your VeChain nickname`,buttonText:`Sign to continue`},onTxConfirmed:l,onTxFailedOrCancelled:n});return{...u,clauses:c,sendTransaction:async()=>u.sendTransaction(c())}},To=e=>[`VECHAIN_KIT_DOMAIN`,e,`IS_DOMAIN_PROTECTED`],Eo=sn.ofAbi(ci.abi),Do=async(e,t,n)=>{let r=k(t).veWorldSubdomainClaimerContractAddress;return(await e.contracts.load(r,Eo.abi).read.isDomainProtected(n))[0]},Oo=(e,t=!0)=>{let n=jn(),{network:r}=$();return X({queryKey:To(e),queryFn:()=>Do(n,r.type,e),enabled:!!e&&t&&!!r.type,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`))return!1}return e<2},gcTime:1e3*60*5,staleTime:1e3*60})},ko=wi.object({name:wi.string()}),Ao=wi.object({domains:wi.array(ko)}),jo=async(e,t,n)=>{if(!t)throw Error(`Address is required`);let r=k(e).graphQlIndexerUrl,i=`query Registrations {
113
+ `))}let Ga=null;function Ka(){return Ga||=new Fn({defaultOptions:{queries:{queryKeyHashFn:Bn,retry:0,staleTime:3e4,refetchOnWindowFocus:!0,refetchOnMount:!0,refetchOnReconnect:!0,refetchInterval:!1,refetchIntervalInBackground:!1}}}),Ga}const qa=({children:e})=>{try{if(V.useContext(In))return q(K,{children:e})}catch(e){console.log(e)}return q(Ln,{client:Ka(),children:e})},Ja=({onClick:e,...t})=>q(lt,{"aria-label":`Back`,icon:q(N,{as:nr,fontSize:`20px`}),size:`sm`,variant:`ghost`,position:`absolute`,borderRadius:`50%`,left:`10px`,top:`10px`,onClick:e,...t}),Ya=({wallet:e,label:t,style:n,showHumanAddress:r=!0})=>{let[i,a]=G(!1),[o,s]=G(!1),c=B(`colors`,`vechain-kit-text-primary`),u=B(`colors`,`vechain-kit-text-secondary`),d=async(e,t)=>{await ie(e)&&(t(!0),setTimeout(()=>{t(!1)},2e3))};return q(z,{w:`full`,justifyContent:`center`,...n,children:J(z,{w:`full`,spacing:4,children:[t&&q(R,{fontSize:`sm`,color:u,children:t}),e?.domain?J(z,{spacing:2,w:`full`,children:[J(ft,{children:[q(pt,{children:q(N,{as:Fr,color:u})}),q(dt,{cursor:`pointer`,value:e.domain,readOnly:!0,fontSize:`sm`,fontWeight:`700`,color:c,onClick:()=>d(e.domain||``,s)}),q(mt,{children:q(N,{color:u,onClick:()=>d(e.domain||``,s),cursor:`pointer`,as:o?er:lr})})]}),J(ft,{children:[q(pt,{children:q(N,{as:Br,color:u})}),q(dt,{cursor:`pointer`,value:r?l(e.address??``,8,7):e.address,readOnly:!0,fontSize:`sm`,fontWeight:`700`,color:c,onClick:()=>d(e.address??``,a)}),q(mt,{children:q(N,{color:u,cursor:`pointer`,onClick:()=>d(e.address??``,a),as:i?er:lr})})]})]}):J(ft,{children:[q(pt,{children:q(N,{as:Br,color:u})}),q(dt,{cursor:`pointer`,value:r?l(e?.address??``,6,4):e?.address,readOnly:!0,fontSize:`sm`,fontWeight:`700`,color:c,onClick:()=>d(e?.address??``,a)}),q(mt,{children:q(N,{color:u,onClick:()=>d(e?.address??``,a),cursor:`pointer`,as:i?er:lr})})]})]})})};var Xa=`2.0.4`;const Za=({...e})=>{let{darkMode:t}=$();return J(M,{w:`full`,justifyContent:`center`,alignItems:`center`,spacing:0,...e,children:[q(fe,{isDark:t,w:`70px`,h:`auto`,opacity:.4,mr:1,ml:`-16px`}),J(ht,{fontSize:`11px`,fontWeight:`500`,opacity:.4,textAlign:`left`,href:`https://github.com/vechain/vechain-kit/releases/tag/${Xa}`,isExternal:!0,pt:`1px`,children:[`v`,Xa]})]})},Z=({children:e})=>{let[t,n]=G(!1),r=Zt(null),{tokens:i}=$u(),a=i?.effects?.backdropFilter?.stickyHeader??`blur(12px)`,o=B(`colors`,`vechain-kit-sticky-header`);return U(()=>{let e=new IntersectionObserver(([e])=>{n(!e.isIntersecting)},{threshold:0});return r.current&&e.observe(r.current),()=>e.disconnect()},[]),J(K,{children:[q(A,{position:`sticky`,top:`0`,left:`0`,w:`full`,borderRadius:`24px 24px 0px 0px`,bg:t?o:`transparent`,backdropFilter:t?a:`none`,style:{WebkitBackdropFilter:t?a:`none`},zIndex:1e3,boxShadow:t?`0px 2px 4px 1px rgb(0 0 0 / 10%)`:`none`,transition:`box-shadow 0.2s ease-in-out`,children:e}),q(`div`,{ref:r,style:{position:`absolute`,top:`25px`}})]})},Qa=({children:e})=>q(A,{position:`sticky`,bottom:`0`,left:`0`,right:`0`,bg:B(`colors`,`vechain-kit-modal`),zIndex:`1000`,p:4,boxShadow:`0px -1px 6px -3px rgb(0 0 0 / 56%)`,transition:`box-shadow 0.2s ease-in-out`,children:e}),$a=({isOpen:e,onClose:t,children:n,size:r=`sm`,isCentered:i=!0,motionPreset:a=`slideInBottom`,closeOnOverlayClick:o=!0,blockScrollOnMount:s=!1,allowExternalFocus:c=!1,backdropFilter:l,isCloseable:u=!0})=>{let[d]=Kt(`(min-width: 768px)`),{portalRootRef:f}=$u(),p=B(`colors`,`vechain-kit-modal`),m=B(`colors`,`vechain-kit-overlay`),{tokens:h}=$u(),g=h?.effects?.backdropFilter?.overlay,_=h?.effects?.backdropFilter?.modal,v=l??g??`blur(3px)`,y=d?{}:{position:`fixed`,bottom:`0`,mb:`0`,maxW:`2xl`,borderRadius:`24px 24px 0px 0px !important`,overflowY:`auto`,overflowX:`hidden`,scrollBehavior:`smooth`};return J(vt,{motionPreset:a,isOpen:e,onClose:t,isCentered:i,size:r,returnFocusOnClose:!1,blockScrollOnMount:s,closeOnOverlayClick:o&&u,preserveScrollBarGap:!0,portalProps:{containerRef:f},trapFocus:!c,autoFocus:!c,children:[q(bt,{bg:m,backdropFilter:v}),q(yt,{role:`dialog`,"aria-modal":!c,bg:p,variant:`vechainKitBase`,sx:{backdropFilter:_,WebkitBackdropFilter:_},...y,children:n})]})},eo=(e,t,n)=>{switch(t){case`eur`:return e/n.eurUsdPrice;case`gbp`:return e/n.gbpUsdPrice;default:return e}},to=(e,t=`en`,n)=>{let r={style:`currency`,minimumFractionDigits:2,maximumFractionDigits:2,currency:n?.currency??`usd`,...n};return new Intl.NumberFormat(xa[t],r).format(e)},no=(e,t)=>to(e,Ca.resolvedLanguage,{notation:`compact`,compactDisplay:`short`,currency:t?.currency??`usd`,...t}),ro=({symbol:e,amount:t,currencyValue:n,currentCurrency:r,isDisabled:i,onClick:a,...o})=>{let c=B(`colors`,`vechain-kit-text-primary`),l=B(`colors`,`vechain-kit-text-secondary`);return J(j,{height:`72px`,variant:`ghost`,justifyContent:`space-between`,isDisabled:i,p:4,w:`100%`,_disabled:{cursor:`not-allowed`,opacity:.5},onClick:a,"data-testid":`asset-${e}`,...o,children:[J(M,{children:[s[e]?V.cloneElement(s[e],{boxSize:`24px`,borderRadius:`full`}):q(ut,{src:p[e],alt:`${e} logo`,boxSize:`24px`,borderRadius:`full`,fallback:q(A,{boxSize:`24px`,borderRadius:`full`,bg:`whiteAlpha.200`,display:`flex`,alignItems:`center`,justifyContent:`center`,children:q(R,{fontSize:`10px`,fontWeight:`bold`,color:c,children:e.slice(0,3)})})}),q(R,{color:c,children:e})]}),J(z,{align:`flex-end`,spacing:0,children:[J(R,{color:c,children:[t.toLocaleString(void 0,{maximumFractionDigits:2}),` `]}),q(R,{fontSize:`sm`,color:l,"data-testid":`${e}-balance`,children:no(n,{currency:r})})]})]})},io=async e=>{let t=await fetch(`https://auth.privy.io/api/v1/apps/${e}`,{headers:{"privy-app-id":e}});if(!t.ok)throw Error(`Failed to fetch Privy app info`);return t.json()},ao=e=>[`VECHAIN_KIT_PRIVY_APP_INFO`,...Array.isArray(e)?e:[e]],oo=e=>{let t=Array.isArray(e)?e:[e];return X({queryKey:ao(e),queryFn:async()=>{let e=await Promise.all(t.map(e=>io(e)));return Object.fromEntries(e.map((e,n)=>{let r=t[n],i=a.find(e=>e.id===r);return[r,{...e,website:i?.website}]}))},enabled:t.length>0,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`))return!1}return e<2},gcTime:1e3*60*5,staleTime:1e3*60})},so=async()=>{try{let e=await fetch(`https://status.privy.io/summary.json`);if(!e.ok)throw Error(`Failed to fetch Privy status`);return(await e.json()).page.status??`No data`}catch(e){return console.error(`Error fetching data:`,e),`Error fetching data`}},co=()=>X({queryKey:[`PRIVY_STATUS`],queryFn:so,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`))return!1}return e<2},gcTime:1e3*60*5,staleTime:1e3*60}),lo=e=>[`VECHAIN_KIT_DOMAIN`,e],uo=t=>{let{network:n}=$();return X({queryKey:lo(t),queryFn:async()=>{if(!t)throw Error(`Address or domain is required`);let r=await Zr(t,{networkUrl:n.nodeUrl}),i=e(t);if(!r&&!i)throw Error(`Input must be a valid domain or address`);let a=null,o=null,s=!1;return r?(a=await Gr(t,{networkUrl:n.nodeUrl}),o=t,a&&(s=await Xr(t,a,{networkUrl:n.nodeUrl}))):(o=await Hr(t,{networkUrl:n.nodeUrl}),a=t,o&&(s=await Xr(o,t,{networkUrl:n.nodeUrl}))),{address:a||void 0,domain:o||void 0,isValidAddressOrDomain:r||i,isPrimaryDomain:s}},enabled:!!t&&!!n.type,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`)||e===`address or domain is required`||e===`input must be a valid domain or address`)return!1}return e<2},gcTime:1e3*60*5,staleTime:1e3*60})},fo=async(e,t,n)=>{let r=vi(fi([`0x571e15b4bbf879cf28e5075190137be8e18500e3d38543bf0cbcdb54e00b02cc`,vi(Si(n))])),i=await e.contracts.load(k(t).vetDomainsContractAddress,oi.abi).read.recordExists(r);if(!i)throw Error(`Failed to get ENS record exists for ${n}`);return i[0]},po=e=>[`VECHAIN_KIT_ENS_RECORD_VE_WORLD_EXISTS`,e],mo=e=>{let t=jn(),{network:n}=$();return X({queryKey:po(e),queryFn:()=>fo(t,n.type,e),enabled:!!e,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`))return!1}return e<2},gcTime:1e3*60*5,staleTime:1e3*60})},ho=(e,t)=>{let n=zn(),{network:r}=$();return{refresh:async()=>{await Promise.all([n.invalidateQueries({queryKey:Po(e??``,r.type)}),n.invalidateQueries({queryKey:Ro(e,r.type)}),n.invalidateQueries({queryKey:Go(t)})])}}},go=async(e,t,n,r,i,a)=>{await Promise.all([e.invalidateQueries({queryKey:lo(t)}),e.invalidateQueries({queryKey:lo(n)}),e.invalidateQueries({queryKey:po(r)}),e.invalidateQueries({queryKey:Mo(t,`.vet`)}),e.invalidateQueries({queryKey:Mo(t,`.veworld.vet`)}),e.invalidateQueries({queryKey:Ro(n)})]),await Promise.all([e.refetchQueries({queryKey:lo(t)}),e.refetchQueries({queryKey:lo(n)}),e.refetchQueries({queryKey:Mo(t,`.vet`)}),e.refetchQueries({queryKey:Mo(t,`.veworld.vet`)}),e.refetchQueries({queryKey:Po(r+`.`+i,a)}),e.refetchQueries({queryKey:Ro(n)}),e.refetchQueries({queryKey:po(r)}),e.refetchQueries({queryKey:Go(t)})])},_o=ci.createInterface(),vo=si.createInterface(),yo=(e,t,n,r,i)=>{let a=[];if(!e)throw Error(`Invalid subdomain`);let o=`${e}.${t}`;if(a.push({to:k(i.type).vetDomainsReverseRegistrarAddress,value:`0x0`,data:vo.encodeFunctionData(`setName`,[``]),comment:`Unsetting your current VeChain nickname of the account ${l(r?.address??``,4,4)}`,abi:vo.getFunction(`setName`)}),n){a.push({to:k(i.type).vetDomainsReverseRegistrarAddress,value:`0x0`,data:vo.encodeFunctionData(`setName`,[o]),comment:`Setting your VeChain nickname to ${o}`,abi:vo.getFunction(`setName`)});let e=new en.Interface([`function setAddr(bytes32 node, address addr)`]),t=en.namehash(o);a.push({to:k(i.type).vetDomainsPublicResolverAddress,value:`0x0`,data:e.encodeFunctionData(`setAddr`,[t,r?.address||``]),comment:`Setting the address for ${o} to ${l(r?.address??``,4,4)}`,abi:e.getFunction(`setAddr`)})}else if(xo(t))a.push({to:k(i.type).veWorldSubdomainClaimerContractAddress,value:`0x0`,data:_o.encodeFunctionData(`claim`,[e,k(i.type).vetDomainsPublicResolverAddress]),comment:`Claim VeChain subdomain: ${e}.${t}`,abi:_o.getFunction(`claim`)}),a.push({to:k(i.type).vetDomainsReverseRegistrarAddress,value:`0x0`,data:vo.encodeFunctionData(`setName`,[e+`.`+t]),comment:`Set ${e}.${t} as the VeChain nickname of the account ${l(r?.address??``,4,4)}`,abi:vo.getFunction(`setName`)});else throw Error(`This hook only supports .veworld.vet subdomains`);return a},bo=({subdomain:e,domain:t,onSuccess:n,onError:r,alreadyOwned:i=!1})=>{let a=zn(),{account:o}=Q(),{network:s}=$(),{refresh:c}=ho(e+`.`+t,o?.address??``),l=H(()=>yo(e,t,i,o,s),[e,t,i,o,s]),u=H(async()=>{let r=`${e}.${t}`;await go(a,o?.address??``,r,e,t,s.type),c(),n?.()},[n,e,t,a,o,s.type,c]),d=lc({signerAccountAddress:o?.address??``,privyUIOptions:{title:`Sign to claim your VeChain nickname`,description:`Claim ${e}.${t} as your VeChain nickname`,buttonText:`Sign to continue`},onTxConfirmed:u,onTxFailedOrCancelled:()=>{r?.()}});return{...d,clauses:l,sendTransaction:async()=>d.sendTransaction(l())}},xo=e=>e.endsWith(`veworld.vet`),So=si.createInterface(),Co=(e,t,n,r)=>{let i=[];if(!e)throw Error(`Invalid domain`);if(t){i.push({to:k(r.type).vetDomainsReverseRegistrarAddress,value:`0x0`,data:So.encodeFunctionData(`setName`,[e]),comment:`Setting your VeChain nickname to ${e}`,abi:So.getFunction(`setName`)});let t=new en.Interface([`function setAddr(bytes32 node, address addr)`]),a=en.namehash(e);i.push({to:k(r.type).vetDomainsPublicResolverAddress,value:`0x0`,data:t.encodeFunctionData(`setAddr`,[a,n?.address||``]),comment:`Setting the address for ${e} to ${l(n?.address??``,4,4)}`,abi:t.getFunction(`setAddr`)})}else throw Error(`Primary .vet domains are not supported yet`);return i},wo=({domain:e,onSuccess:t,onError:n,alreadyOwned:r=!1})=>{let{network:i}=$(),a=zn(),{account:o}=Q(),{refresh:s}=ho(e,o?.address??``),c=H(()=>Co(e,r,o,i),[e,r,o,i]),l=H(async()=>{await go(a,o?.address??``,e,``,e.endsWith(`.vet`)?e:`${e}.vet`,i.type),s(),t?.()},[t,e,a,o,i.type,s]),u=lc({signerAccountAddress:o?.address??``,privyUIOptions:{title:`Sign to claim your VeChain nickname`,description:`Claim ${e} as your VeChain nickname`,buttonText:`Sign to continue`},onTxConfirmed:l,onTxFailedOrCancelled:n});return{...u,clauses:c,sendTransaction:async()=>u.sendTransaction(c())}},To=e=>[`VECHAIN_KIT_DOMAIN`,e,`IS_DOMAIN_PROTECTED`],Eo=sn.ofAbi(ci.abi),Do=async(e,t,n)=>{let r=k(t).veWorldSubdomainClaimerContractAddress;return(await e.contracts.load(r,Eo.abi).read.isDomainProtected(n))[0]},Oo=(e,t=!0)=>{let n=jn(),{network:r}=$();return X({queryKey:To(e),queryFn:()=>Do(n,r.type,e),enabled:!!e&&t&&!!r.type,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`))return!1}return e<2},gcTime:1e3*60*5,staleTime:1e3*60})},ko=wi.object({name:wi.string()}),Ao=wi.object({domains:wi.array(ko)}),jo=async(e,t,n)=>{if(!t)throw Error(`Address is required`);let r=k(e).graphQlIndexerUrl,i=`query Registrations {
114
114
  domains(
115
115
  where: ${n?`{owner: "${t.toLowerCase()}", parent_: {name: "${n}"}}`:`{owner: "${t.toLowerCase()}"}`}
116
116
  ) {
117
117
  name
118
118
  }
119
- }`,a=await fetch(r,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({operationName:`Registrations`,query:i,extensions:{}})});if(!a.ok)throw Error(`Failed to fetch domains`);let o=await a.json();return o.data&&o.data.domains&&(o.data.domains=o.data.domains.filter(e=>!e.name.endsWith(`addr.reverse`))),Ao.parse(o.data)},Mo=(e,t)=>[`VECHAIN_KIT`,`VET_DOMAINS`,e,t],No=(e,t)=>{let{network:n}=$();return X({queryKey:Mo(e,t),queryFn:()=>jo(n.type,e,t),enabled:!!e&&!!n.type,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`)||e===`address is required`)return!1}return e<2},gcTime:1e3*60*5,staleTime:1e3*60})},Po=(e,t)=>[`VECHAIN_KIT`,`VET_DOMAINS`,`AVATAR`,e,t],Fo=e=>{let{network:t}=$();return X({queryKey:Po(e??``,t.type),queryFn:async()=>e?Ur(e,{networkUrl:t.nodeUrl}):null,enabled:!!e&&!!t.type,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`))return!1}return e<2},gcTime:1e3*60*5,staleTime:1e3*60})},Io=new $t([`function resolver(bytes32 node) returns (address resolverAddress)`,`function text(bytes32 node, string key) view returns (string)`]),Lo=async(e,t,n)=>{if(!n)return{};let r=tn(n);try{let[{data:n,reverted:i}]=await(await fetch(`${e}/accounts/*`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({clauses:[{to:k(t).vetDomainsContractAddress,data:Io.encodeFunctionData(`resolver`,[r])}]})})).json();if(i)return{};let{resolverAddress:a}=Io.decodeFunctionResult(`resolver`,n);return(await(await fetch(`${e}/accounts/*`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({clauses:le.map(e=>({to:a,data:Io.encodeFunctionData(`text`,[r,e])}))})})).json()).reduce((e,{data:t,reverted:n},r)=>{if(!n&&t&&t!==`0x`)try{let n=Io.decodeFunctionResult(`text`,t)[0];n&&(e[le[r]]=n)}catch(e){console.error(`Failed to decode text record for ${le[r]}:`,e)}return e},{})}catch(e){throw console.error(`Error fetching text records:`,e),e}},Ro=(e,t)=>[`VECHAIN_KIT_TEXT_RECORDS`,e,t],zo=e=>{let{network:t}=$(),n=t.nodeUrl??k(t.type).nodeUrl;return X({queryKey:Ro(e,t.type),queryFn:()=>Lo(n,t.type,e),enabled:!!e&&!!t.type,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`))return!1}return e<2},gcTime:1e3*60*5,staleTime:1e3*60})},Bo=new $t([`function resolver(bytes32 node) returns (address resolverAddress)`,`function setText(bytes32 node, string key, string value) external`]),Vo=(e,t)=>{let n=[];for(let{domain:r,key:i,value:a}of t){if(!r)throw Error(`Domain is required`);if(!e)throw Error(`Resolver address is required`);let t=tn(r);n.push({to:e,data:Bo.encodeFunctionData(`setText`,[t,i,a]),value:`0`,comment:`Update ${i} record`})}return n},Ho=({onSuccess:e,onError:t,signerAccountAddress:n,resolverAddress:r}={})=>{let i=H(e=>{if(!r)throw Error(`Resolver address is required`);return Vo(r,e)},[r]),a=lc({signerAccountAddress:n,onTxConfirmed:async()=>{await e?.()},onTxFailedOrCancelled:async()=>{await t?.()},privyUIOptions:{title:`Update Profile Information`,description:`Update the profile information associated with your domain`,buttonText:`Sign to continue`}});return{...a,clauses:i,sendTransaction:async e=>a.sendTransaction(i(e))}},Uo=e=>[`VECHAIN_KIT`,`RESOLVER_ADDRESS`,e],Wo=e=>{let{network:t}=$();return tf({address:k(t.type).vetDomainsContractAddress,abi:ai.abi,method:`resolver`,args:[e?yi(e):`0x`],queryOptions:{select:e=>e[0],enabled:!!e}})},Go=e=>[`VECHAIN_KIT`,`VET_DOMAINS`,`AVATAR_OF_ADDRESS`,e],Ko=e=>{let{network:t}=$();return X({queryKey:Go(e),queryFn:async()=>{if(!e||!t.nodeUrl)return i(e??``);let n=await Hr(e,{networkUrl:t.nodeUrl});return n&&await Ur(n,{networkUrl:t.nodeUrl})||i(e??``)},enabled:!!e&&!!t.nodeUrl,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`))return!1}return e<2},gcTime:1e3*60*5,staleTime:1e3*60})},qo=new $t([`function resolver(bytes32 node) returns (address resolverAddress)`,`function text(bytes32 node, string key) returns (string avatar)`]),Jo=new $t([`function tokenURI(uint256 tokenId) view returns (string)`,`function uri(uint256 id) view returns (string)`]),Yo=async(e,t,n)=>{if(!n)throw Error(`Name is required`);let r=tn(n);try{let[{data:n,reverted:i}]=await(await fetch(`${t}/accounts/*`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({clauses:[{to:k(e).vetDomainsContractAddress,data:qo.encodeFunctionData(`resolver`,[r])}]})})).json();if(i)return null;let{resolverAddress:a}=qo.decodeFunctionResult(`resolver`,n),[{data:o,reverted:s}]=await(await fetch(`${t}/accounts/*`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({clauses:[{to:a,data:qo.encodeFunctionData(`text`,[r,`avatar`])}]})})).json();if(s||o===`0x`)return null;try{let{avatar:n}=qo.decodeFunctionResult(`text`,o),r=n===``?null:n;return r?Zo(r,e,t):null}catch(e){return console.error(`Failed to decode avatar data:`,e),null}}catch(e){throw console.error(`Error fetching avatar using legacy API:`,e),e}},Xo=(e,t)=>[`VECHAIN_KIT`,`VET_DOMAINS`,`AVATAR`,`LEGACY`,e,t];async function Zo(e,t,n){try{if(e.startsWith(`http`)||e.startsWith(`ipfs://`)||e.startsWith(`ar://`))return x(e,t)||null;let r=e.match(/eip155:(\d+)\/(?:erc721|erc1155):([^/]+)\/(\d+)/);if(r){let[,i,a,o]=r,s=e.includes(`erc1155`);if(!i||!a||o===void 0)return null;let c=[{to:a,data:Jo.encodeFunctionData(s?`uri`:`tokenURI`,[BigInt(o||0)])}],[{data:l,reverted:u}]=await fetch(`${n}/accounts/*`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({clauses:c})}).then(e=>e.json());if(u)return console.error(`Failed to fetch tokenURI`),null;let d=``;try{d=Jo.decodeFunctionResult(s?`uri`:`tokenURI`,l)[0]}catch(e){console.error(`Failed to decode avatar data:`,e),d=an(l)}d=x(d,t)||d,s&&(d=d.replace(`{id}`,on(rn(BigInt(o||0)),32).slice(2)));let f=await fetch(d);if(!f.ok)return console.error(`Failed to fetch metadata`),null;let p=await f.json(),m=p.image||p.image_url||p.image_data;return m?x(m,t)||m:(console.error(`No image URL in metadata`),null)}return null}catch(e){return console.error(`Error parsing avatar record:`,e),null}}const Qo=e=>{let{network:t}=$(),n=t.nodeUrl??k(t.type).nodeUrl;return X({queryKey:Xo(e??``,t.type),queryFn:async()=>e?Yo(t.type,n,e):null,enabled:!!e&&!!n&&!!t.type})},$o=si.createInterface(),es=(e,t)=>{let n=[];return n.push({to:k(t.type).vetDomainsReverseRegistrarAddress,value:`0x0`,data:$o.encodeFunctionData(`setName`,[``]),comment:`Unsetting your current VeChain nickname of the account ${l(e?.address??``,4,4)}`,abi:$o.getFunction(`setName`)}),n},ts=({onSuccess:e,onError:t})=>{let n=zn(),{account:r}=Q(),{network:i}=$(),a=H(()=>es(r,i),[r,i]),o=H(async()=>{await go(n,r?.address??``,``,``,``,i.type),e?.()},[e,n,r,i.type]),s=lc({signerAccountAddress:r?.address??``,privyUIOptions:{title:`Sign to unset your VeChain nickname`,description:`Unset your current VeChain nickname`,buttonText:`Sign to continue`},onTxConfirmed:o,onTxFailedOrCancelled:t});return{...s,clauses:a,sendTransaction:async()=>s.sendTransaction(a())}},ns=e=>{let{network:t}=$(),n=k(t.type),{data:r,isLoading:i}=lf(e),{data:a,isLoading:o}=Ss(e),{data:s,isLoading:c}=Os(e),{data:l,isLoading:u}=Es(n.veDelegateTokenContractAddress,e),{data:d,isLoading:f}=Es(n.gloDollarContractAddress,e),p=ws(e),m=p.map(e=>e.data).filter(Boolean),h=p.some(e=>e.isLoading);return{balances:W(()=>{if(!e)return[];let t={vet:`0x`,vtho:n.vthoContractAddress,b3tr:n.b3trContractAddress,vot3:n.vot3ContractAddress,veDelegate:n.veDelegate,USDGLO:n.gloDollarContractAddress},i=[{address:t.vet,symbol:`VET`,balance:r?.balance||`0`},{address:t.vtho,symbol:`VTHO`,balance:r?.energy||`0`},{address:t.b3tr,symbol:`B3TR`,balance:a?.scaled??`0`},{address:t.vot3,symbol:`VOT3`,balance:s?.scaled??`0`},{address:t.veDelegate,symbol:`veDelegate`,balance:l?.scaled??`0`},{address:t.USDGLO,symbol:`USDGLO`,balance:d?.scaled??`0`}],o=m.map(e=>({address:e?.address||``,symbol:e?.symbol||``,balance:e?.scaled||`0`}));return[...i,...o]},[e,r,a,s,l,d,m,t.type]),isLoading:i||o||c||u||f||h}},rs={B3TR:`0x623374722d757364000000000000000000000000000000000000000000000000`,VET:`0x7665742d75736400000000000000000000000000000000000000000000000000`,VTHO:`0x7674686f2d757364000000000000000000000000000000000000000000000000`,GBP:`0x6762702d75736400000000000000000000000000000000000000000000000000`,EUR:`0x657572742d757364000000000000000000000000000000000000000000000000`},is=async(e,t,n)=>{let r=await e.contracts.load(k(n).oracleContractAddress,$r.abi).read.getLatestValue(rs[t]);if(!r)throw Error(`Failed to get price of ${t}`);return new Qt(r[0].toString()).div(0xe8d4a51000).toNumber()},as=e=>[`VECHAIN_KIT_PRICE`,e],os=e=>{let t=jn(),{network:n}=$();return X({queryKey:as(e),queryFn:async()=>is(t,e,n.type),enabled:!!t&&!!n.type,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`))return!1}return e<2},gcTime:1e3*60*5,staleTime:1e3*60})},ss=()=>{let{network:e}=$(),t=k(e.type),{data:n,isLoading:r}=os(`VET`),{data:i,isLoading:a}=os(`VTHO`),{data:o,isLoading:s}=os(`B3TR`),{data:c,isLoading:l}=os(`EUR`),{data:u,isLoading:d}=os(`GBP`);return{prices:W(()=>{let e={vet:`0x`,vtho:t.vthoContractAddress,b3tr:t.b3trContractAddress,vot3:t.vot3ContractAddress,veDelegate:t.veDelegate,USDGLO:t.gloDollarContractAddress};return{[e.vet]:n||0,[e.vtho]:i||0,[e.b3tr]:o||0,[e.vot3]:o||0,[e.veDelegate]:o||0,[e.USDGLO]:1}},[n,i,o,t.vthoContractAddress,t.b3trContractAddress,t.vot3ContractAddress,t.veDelegate,t.gloDollarContractAddress]),exchangeRates:W(()=>({eurUsdPrice:c||1,gbpUsdPrice:u||1}),[c,u]),isLoading:r||a||s||l||d}},cs=`vechain_kit_currency`,ls=[`usd`,`eur`,`gbp`],us=()=>{let{defaultCurrency:e=`usd`}=$(),[t,n]=G(()=>{try{return w(cs)||e}catch(t){return console.error(t),e}});return U(()=>{h(cs,t)},[t]),{currentCurrency:t,allCurrencies:ls,changeCurrency:e=>{if(!ls.includes(e)){console.error(`Invalid currency: ${e}`);return}n(e)}}},ds=({address:e=``})=>{let{balances:t,isLoading:n}=ns(e),{prices:r,exchangeRates:i,isLoading:a}=ss(),{currentCurrency:o}=us(),s=W(()=>t.map(e=>{let t=r[e.address]||0,n=Number(e.balance)*t,a=eo(n,o,i);return{...e,priceUsd:t,valueUsd:n,valueInCurrency:a}}),[t,r,o,i]),c=W(()=>[...s].sort((e,t)=>t.valueInCurrency-e.valueInCurrency),[s]);return{tokens:s,sortedTokens:c,tokensWithBalance:W(()=>c.filter(e=>Number(e.balance)>0),[c]),isLoading:n||a}},fs=({address:e=``})=>{let{tokensWithBalance:t,isLoading:n}=ds({address:e}),{currentCurrency:r}=us(),i=W(()=>t.reduce((e,t)=>e+t.valueInCurrency,0),[t]);return{totalBalanceInCurrency:i,totalBalanceUsd:W(()=>t.reduce((e,t)=>e+t.valueUsd,0),[t]),formattedBalance:W(()=>no(i,{currency:r}),[i,r]),isLoading:n,hasAnyBalance:t.length>0}},ps=di.abi,ms=`currentRoundId`,hs=e=>$d({abi:ps,address:e,method:ms}),gs=()=>{let{network:e}=$(),t=k(e.type).xAllocationVotingContractAddress;return tf({abi:ps,address:t,method:ms,args:[],queryOptions:{select:e=>e[0].toString()}})},_s=async(e,t)=>Jr(e,{networkUrl:t}),vs=e=>[`VECHAIN_KIT_CUSTOM_TOKEN_INFO`,e],ys=e=>{let{network:t}=$();return X({queryKey:vs(e),queryFn:async()=>{if(!e)throw Error(`Token address is required`);if(!t.nodeUrl)throw Error(`Network node URL is required`);return _s(e,t.nodeUrl)},enabled:!!t.type&&!!e,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`)||e===`token address is required`||e===`network node url is required`)return!1}return e<2},gcTime:1e3*60*5,staleTime:1e3*60})},bs=()=>{let[e,t]=mp(pp.CUSTOM_TOKENS,[]),{network:n}=$(),r=async r=>{if(!a(r)&&!s(r)){if(!n.nodeUrl)throw Error(`Network node URL is required`);let i={...await _s(r,n.nodeUrl),address:r};t([...e,i])}},i=n=>{t(e.filter(e=>e.address!==n))},a=t=>e.some(e=>o(e.address,t)),s=e=>{let t={vet:`0x`,vtho:k(n.type).vthoContractAddress,b3tr:k(n.type).b3trContractAddress,vot3:k(n.type).vot3ContractAddress,veDelegate:k(n.type).veDelegate};return Object.values(t).includes(e)};return{customTokens:e,addToken:r,removeToken:i,isTokenIncluded:a,isDefaultToken:s}},xs=e=>[`VEBETTERDAO_BALANCE`,e,`B3TR`],Ss=e=>{let{network:t}=$();return X({queryKey:xs(e),queryFn:async()=>{if(!e)throw Error(`Address is required`);let n=await Wr(e,{networkUrl:t.nodeUrl});if(!n)throw Error(`Failed to get b3tr balance`);let r=n[0];return u(r)},enabled:!!e&&!!t.type})},Cs=(e,t)=>[`VECHAIN_KIT_BALANCE`,t,`CUSTOM_TOKEN`,e],ws=e=>{let{network:t}=$(),{customTokens:n}=bs();return Rn({queries:n.map(n=>({queryKey:Cs(n.address,e),queryFn:async()=>{if(!n.address)throw Error(`Token address is required`);if(!e)throw Error(`Address is required`);if(!t.nodeUrl)throw Error(`Network node URL is required`);let r=await Kr(n.address,e,{networkUrl:t.nodeUrl});if(!r)throw Error(`Failed to get token balance`);let i=u(r[0]);return{...n,...i}}}))})},Ts=(e,t)=>[`VECHAIN_KIT`,`BALANCE`,`ERC20`,e,t],Es=(e,t)=>{let{network:n}=$();return X({queryKey:Ts(e,t),queryFn:async()=>{if(!t)throw Error(`Address is required`);let r=await Kr(e,t,{networkUrl:n.nodeUrl});if(!r)throw Error(`Failed to get vot3 balance`);let i=r[0];return u(i)},enabled:!!t&&!!n.type})},Ds=e=>[`VEBETTERDAO_BALANCE`,e,`VOT3`],Os=e=>{let{network:t}=$();return X({queryKey:Ds(e),queryFn:async()=>{if(!e)throw Error(`Address is required`);let n=await Yr(e,{networkUrl:t.nodeUrl});if(!n)throw Error(`Failed to get vot3 balance`);let r=n[0];return u(r)},enabled:!!e&&!!t.type})},ks=(e,t)=>[`VECHAIN_KIT`,`IS_PERSON`,e,t],As=e=>{let{network:t}=$();return X({queryKey:ks(e??``,t.type),queryFn:async()=>{if(!e)throw Error(`User address is required`);return qr(e,{networkUrl:t.nodeUrl})},enabled:!!e&&!!t.type,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`)||e===`user address is required`)return!1}return e<2},gcTime:1e3*60*5,staleTime:1e3*60})},js=di.abi,Ms=`getAppsOfRound`,Ns=(e,t)=>ef({abi:js,address:k(t).xAllocationVotingContractAddress,method:Ms,args:[BigInt(e??0)]}),Ps=e=>{let{network:t}=$(),n=k(t.type).xAllocationVotingContractAddress;return tf({abi:js,address:n,method:Ms,args:[BigInt(e??0)],queryOptions:{enabled:!!e,select:e=>e[0].map(e=>({id:e.id.toString(),teamWalletAddress:e.teamWalletAddress,name:e.name,metadataURI:e.metadataURI,createdAtTimestamp:e.createdAtTimestamp.toString()}))}})},Fs=ui.abi,Is=e=>[`VECHAIN_KIT`,`XApps`,`Shares`,e],Ls=(e,t)=>{let n=jn(),{network:r}=$(),i=k(r.type).xAllocationPoolContractAddress;return X({queryKey:Is(t),queryFn:async()=>(await re({thor:n,calls:e.map(e=>({abi:Fs,functionName:`getAppShares`,address:i,args:[t,e]}))})).map((t,n)=>({app:e[n],share:Number(t[0]||0)/100,unallocatedShare:Number(t[1]||0)/100})),enabled:!!t&&!!e.length})},Rs=e=>{let{data:t}=Ps(e),n=Ls(t?.map(e=>e.id)??[],e);return{data:W(()=>n.data?.map(e=>({percentage:e.share+e.unallocatedShare,id:t?.find(t=>t.id===e.app)?.id??``,app:t?.find(t=>t.id===e.app)??{}})).sort((e,t)=>Number(t.percentage)-Number(e.percentage))??[],[n.data,t]),isLoading:n.isLoading}},zs=({error:e,mobileBrowserPopupMessage:t=`Mobile browser blocked the window. Please try again.`,rejectedMessage:n=`Request was cancelled.`,defaultMessage:r=`Operation failed`})=>{let i=e?.message;return Pi&&i&&!g(i)?Error(t):i&&g(i)?Error(n):e instanceof Error?e:Error(r)},Bs=mi({id:`1176455790972829965191905223412607679856028701100105089447013101863`,name:`Vechain`,nativeCurrency:{name:`VeChain`,symbol:`VET`,decimals:18},rpcUrls:{default:{http:[`https://mainnet.vechain.org`]}},blockExplorers:{default:{name:`Vechain Explorer`,url:`https://explore.vechain.org`},vechainStats:{name:`Vechain Stats`,url:`https://vechainstats.com`}}}),Vs=()=>Ni({id:O,name:`VeChain`,iconUrl:`https://imagedelivery.net/oHBRUd2clqykxgDWmeAyLg/661dd77c-2f9d-40e7-baa1-f4e24fd7bf00/icon`,smartWalletMode:!1}),Hs=({privyEcosystemAppIDS:e,children:t})=>q(Ti,{config:Zt(Ei({chains:[Bs],ssr:!0,connectors:[Vs(),...e.map(e=>Ni({id:e,name:``,iconUrl:``}))],transports:{[Bs.id]:Di()},multiInjectedProviderDiscovery:!1})).current,children:t}),Us=()=>{let{connectAsync:e,connectors:t}=ki(),{signTypedDataAsync:n}=Mi(),{signMessageAsync:r}=ji(),{disconnectAsync:i}=Ai(),{isConnected:a}=Oi(),[o,s]=G(!1),[c,l]=G(null),u=H(async()=>{try{a&&(await i(),y()&&window.dispatchEvent(new Event(`wallet_disconnected`)))}catch(e){throw console.error(`Error during logout:`,e),e}},[i,a]);return{login:H(async n=>{try{s(!0),l(null);let r=t.find(e=>e.id===(n||O));if(!r)throw Error(`Connector not found`);return await e({connector:r})}catch(e){throw l(e),e}finally{s(!1)}},[e,t]),logout:u,signMessage:H(async e=>{try{return await r({message:e})}catch(e){throw zs({error:e,mobileBrowserPopupMessage:`Your mobile browser blocked the signing window. Please click 'Try again' to open the signing window or change your browser settings.`,rejectedMessage:`Signing request was cancelled.`,defaultMessage:`An unexpected issue occurred while signing a message. Please try again or contact support.`})}},[r]),signTypedData:H(async e=>{try{return await n(e)}catch(e){throw zs({error:e,mobileBrowserPopupMessage:`Your mobile browser blocked the signing window. Please click 'Try again' to open the signing window or change your browser settings.`,rejectedMessage:`Signing request was cancelled.`,defaultMessage:`An unexpected issue occurred while signing typed data. Please try again or contact support.`})}},[n]),isConnecting:o,connectionError:c}},Ws=(e,t)=>{let{data:n,isLoading:r}=uo(e??``),{data:i,isLoading:a}=Ko(e??``),{data:o,isLoading:s}=zo(n?.domain??``),c=o?.header?x(o.header,t):null;return{domain:n?.domain,image:i,records:{...o,header:c},isLoading:r||a||s}},Q=()=>{let{address:e,isConnected:t,isConnecting:n,isReconnecting:r}=Oi(),{logout:i}=Us(),{loading:a}=xn({}),{feeDelegation:s,network:c,privy:l}=$(),{user:u,authenticated:d,logout:f,ready:p}=Tn(),{data:m}=qf(),{account:h,disconnect:g}=Mn(),{getConnectionCache:_,clearConnectionCache:v}=Gd(),b=_(),x=rf(),S=!!h,C=d&&!!u,w=C||t,ee=C&&l?.appId===O||t&&b?.ecosystemApp?.appId===O,T=n||r||a||!p,[E,D]=G(!1),te=t?{type:`privy-cross-app`,displayName:`Ecosystem`}:S?{type:`wallet`,displayName:`Wallet`}:{type:`privy`,displayName:`Social Login`};U(()=>{let e=S||C||t;E!==e&&(D(e),e||(v(),y()&&window.dispatchEvent(new Event(`wallet_disconnected`))))},[S,C,t,v,E]);let ne=u?.linkedAccounts?.find(e=>e.type===`wallet`&&e.connectorType===`embedded`)?.address,re=S?h:t?e:ne,{data:ie}=Nf(re),ae=S?h:ie?.address,oe=Ws(ae??``,c.type),se=Ws(re??``,c.type),k=Ws(ie?.address??``,c.type),ce=ae?{address:ae,domain:oe.domain,image:oe.image,isLoadingMetadata:oe.isLoading,metadata:oe.records}:null,le=re?{address:re,domain:se.domain,image:se.image,isLoadingMetadata:se.isLoading,metadata:se.records}:null,{data:ue}=xf(ie?.address??``,le?.address??``),de=!!ie?.address&&!!ce?.address&&o(ie?.address,ce?.address),fe=H(async()=>{try{D(!1),S?g():C?await f():t&&await i(),v(),y()&&window.dispatchEvent(new Event(`wallet_disconnected`))}catch(e){console.error(`Error during disconnect:`,e)}},[S,g,C,f,t,i,v]);return{account:ce,smartAccount:{address:ie?.address??``,domain:k.domain,image:k.image,isDeployed:ie?.isDeployed??!1,isActive:de,version:ue?.version??null,isLoadingMetadata:k.isLoading,metadata:k.records},connectedWallet:le,privyUser:u,connection:{isLoading:T,isConnected:E,isConnectedWithSocialLogin:C,isConnectedWithDappKit:S,isConnectedWithCrossApp:t,isConnectedWithPrivy:w,isConnectedWithVeChain:ee,source:te,isInAppBrowser:(y()&&window.vechain&&window.vechain.isInAppBrowser)??!1,nodeUrl:x,delegatorUrl:s?.delegatorUrl,chainId:m,network:c.type},disconnect:fe}},Gs=()=>{let e=zn(),{account:t}=Q();return{refresh:async()=>{let n=t?.address??``;await Promise.all([e.invalidateQueries({queryKey:[`VECHAIN_KIT_BALANCE`,n]}),e.invalidateQueries({queryKey:[`VECHAIN_KIT_PRICE`]})])}}},Ks=async(e,t)=>{let n=x(e,t)||``,r=await fetch(n,{signal:AbortSignal.timeout(2e4)});if(!r.ok)throw Error(`HTTP error! status: ${r.status}`);return await r.json()},qs=li.abi,Js=e=>{let t=jn(),{network:n}=$();return X({queryKey:[`xAppMetaData`,e],queryFn:async()=>{let r=k(n.type).x2EarnAppsContractAddress,i=t.contracts.load(r,qs),[a]=await i.read.app(e),o=a.metadataURI||``,[s]=await i.read.baseURI();return await Ks(`${s}${o}`,n.type)}})},Ys=async(e,t,n=!1)=>{if(!t)throw Error(`No URI provided`);let r=x(t,e);if(!r)throw Error(`Invalid URI`);let i=await(await fetch(r,{headers:{"X-Project-Id":`vechain-kit`}})).text();return n?JSON.parse(i):i},Xs=(e,t)=>[`VECHAIN_KIT`,`IPFS_METADATA`,e,t],Zs=(e,t=!1)=>{let{network:n}=$();return X({queryKey:Xs(n.type,e),queryFn:()=>Ys(n.type,e,t),enabled:!!e&&!!n.type,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`)||e===`no uri provided`||e===`invalid uri`)return!1}return e<2},staleTime:1/0})},Qs=1024*1024*10,$s=async(e,t)=>{if(!t)throw Error(`IPFS URI is required`);let n=await fetch(x(t,e)??``,{headers:{"X-Project-Id":`vechain-kit`}});if(!n.ok)throw Error(`HTTP error! status: ${n.status}`);let r=await n.blob();if(![`image/jpeg`,`image/jpg`,`image/png`,`image/gif`,`image/bmp`,`image/tiff`,`image/webp`,`image/svg+xml`].includes(r.type))throw Error(`Unsupported MIME type: ${r.type}`);if(r.size>Qs)throw Error(`Image size exceeds maximum allowed size`);return new Promise((e,t)=>{let n=new FileReader;n.readAsDataURL(r),n.onloadend=()=>{e({image:n.result,mime:r.type,mediaType:b(r.type)})},n.onerror=()=>{t(Error(`Error occurred while reading blob.`))}})},ec=(e,t)=>[`VECHAIN_KIT`,`IPFS_IMAGE`,e,t],tc=e=>{let{network:t}=$();return X({queryKey:ec(t.type,e),queryFn:()=>$s(t.type,e),enabled:!!e&&!!t.type,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`)||e===`ipfs uri is required`)return!1}return e<2},staleTime:1/0})},nc=e=>{let{network:t}=$();return Rn({queries:e.map(e=>({queryKey:ec(t.type,e),queryFn:()=>$s(t.type,e),enabled:!!e&&!!t.type,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`)||e===`ipfs uri is required`)return!1}return e<2},staleTime:1/0}))})},rc=(e,t=!1)=>{let{network:n}=$();return Rn({queries:e.map(e=>({queryKey:Xs(n.type,e),queryFn:async()=>Ys(n.type,e,t),enabled:!!e&&!!n.type,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`)||e===`no uri provided`||e===`invalid uri`)return!1}return e<2},staleTime:1/0}))})},ic={maxSizeMB:.4,maxWidthOrHeight:1920,useWebWorker:!0},ac=async e=>{let t=[];try{for(let n of e){let e=await Fi(n.file,ic);t.push(e)}return t}catch(e){throw console.error(`compress error`,e),e}},oc=({compressImages:e,defaultImages:t})=>{let[n,r]=G(t??[]);U(()=>{t&&r(t)},[t]);let[i,a]=G([]),o=H(e=>r(t=>t.filter((t,n)=>n!==e)),[]);return{uploadedImages:n,setUploadedImages:r,onUpload:H(async(t,n=!0)=>{a([]);let i=[];for(let n of t){let t=n;e&&(t=await Fi(n,ic));let r={file:t,image:URL.createObjectURL(n)};i.push(r)}r(e=>[...i,...n?e.filter(e=>!i.some(t=>t.file.name===e.file.name)):[]])},[e]),onRemove:o,invalidDateError:i}},sc=({compressImage:e,defaultImage:t})=>{let[n,r]=G(t);U(()=>{t&&r(t)},[t]);let i=H(()=>r(void 0),[]);return{uploadedImage:n,setUploadedImage:r,onUpload:H(async t=>{let n=t;e&&(n=await Fi(n,ic));let i={file:n,image:URL.createObjectURL(n)};return r(i),i},[e]),onRemove:i}},cc=async(e,t,n,r)=>{let i=await e.transactions.estimateGas(t,n,r);if(i.reverted)throw Error(`Failed to estimate gas`);let a=i?.totalGas??0;return(!a||Number.isNaN(a))&&(a=0),Math.ceil(a)},lc=({signerAccountAddress:e,clauses:t,onTxConfirmed:n,onTxFailedOrCancelled:r,suggestedMaxGas:i,privyUIOptions:a,gasPadding:o})=>{let s=jn(),{signer:c}=Nn(),{connection:l}=Q(),{feeDelegation:u}=$(),d=rf(),f=Xp(),p=H(async(t,n)=>{let r=typeof t==`function`?await t():t??[];if(l.isConnectedWithPrivy)return await f.sendTransaction({txClauses:r,...a,...n});if(!e)throw Error(`signerAccountAddress is required`);let d=0;try{d=await cc(s,[...r],e,{revision:dn.NEXT,...o?{gasPadding:o}:{}})}catch(e){console.error(`Gas estimation failed`,e)}let p=await s.transactions.buildTransactionBody(r,i??d,{isDelegated:u?.delegateAllTransactions}),m=Bi.transactionBodyToTransactionRequestInput(p,e);return c.sendTransaction({...m,maxPriorityFeePerGas:m.maxPriorityFeePerGas?.toString(),maxFeePerGas:m.maxFeePerGas?.toString()})},[e,i,d,f,a]),[m,h]=G(null),[g,_]=G(!1),[v,y]=G(null),b=H(async e=>{if(!e&&!t)throw Error(`clauses are required`);try{h(null),_(!0),y(null),T(void 0),h(await p(e??[],{...a}))}catch(e){y(e&&typeof e==`object`&&`message`in e?e.message:String(e)),r?.(e instanceof Error?e:Error(String(e)))}finally{_(!1)}},[p,t,a]),{data:x,isLoading:S,error:C}=ap(m??``),w=H(async e=>{if(!(!e.reverted||!e.meta.txID))return await s.transactions.getRevertReason(e.meta.txID)},[s]),[ee,T]=G(),E=W(()=>{if(g)return`pending`;if(v)return`error`;if(m){if(S)return`waitingConfirmation`;if(C)return`error`;if(x)return x.reverted?`error`:`success`}return`ready`},[S,v,g,m,x,C]);U(()=>{if(E===`success`||E===`error`){if(v&&!ee){T({type:`UserRejectedError`,reason:v});return}if(x?.reverted&&!ee?.type){(async()=>{let e=await w(x);T({type:`RevertReasonError`,reason:e?`Transaction reverted with: `+e:`Transaction reverted`})})();return}x&&!x.reverted&&n?.()}},[E,x,n,w,v]);let D=H(()=>{h(null),_(!1),y(null),T(void 0)},[]);return{sendTransaction:b,isTransactionPending:W(()=>g||S||E===`pending`||E===`waitingConfirmation`,[g,S,E]),isWaitingForWalletConfirmation:W(()=>E===`pending`,[g,E]),txReceipt:x??null,status:E,resetStatus:D,error:ee}},uc=(e,t)=>{let{account:n}=Q(),{t:r}=Y(),{sendTransaction:i,isTransactionPending:a,isWaitingForWalletConfirmation:o,txReceipt:s,status:c,resetStatus:l,error:u}=lc({signerAccountAddress:n?.address??``,privyUIOptions:{title:r(`ConfirmSwapTitle`,{defaultValue:`Confirm Swap`}),description:r(`ConfirmSwapDescription`,{defaultValue:`Please confirm the swap transaction in your wallet`}),buttonText:r(`Confirm`,{defaultValue:`Confirm`})}});return{executeSwap:H(async()=>{if(!e||!t)throw Error(`Missing swap parameters or quote`);if(!t.aggregator)throw Error(`Aggregator not found for quote from ${t.aggregatorName}`);let n=await t.aggregator.buildSwapTransaction(e,t);if(n.length===0)throw Error(`Failed to build swap transaction`);await i(n)},[e,t,i]),isTransactionPending:a,isWaitingForWalletConfirmation:o,txReceipt:s,status:c,resetStatus:l,error:u}},dc=e=>e===`0x`||e===`0x0000000000000000000000000000000000000000`,fc=()=>BigInt(Math.floor(Date.now()/1e3)+1200),pc=e=>{let t={name:e.name,getIcon:e.getIcon,async getQuote(n,r){let i=[dc(n.fromTokenAddress)?e.wrappedVET:n.fromTokenAddress,dc(n.toTokenAddress)?e.wrappedVET:n.toTokenAddress],a=BigInt(n.amountIn);try{let[o]=await r.contracts.load(e.routerAddress,ii.abi).read.getAmountsOut(a,i),s=Array.isArray(o)?o:[o],c=s[s.length-1];if(!c||c===0n)throw Error(`Output amount is zero or invalid`);if(typeof c!=`bigint`)throw Error(`Output amount is not a valid bigint`);let l=n.slippageTolerance||1,u=c*BigInt(1e4-l*100)/BigInt(1e4);return{aggregatorName:e.name,aggregator:t,outputAmount:c,priceImpact:0,minimumOutputAmount:u,data:{path:i,routerAddress:e.routerAddress}}}catch(n){return console.error(`${e.name} getQuote failed:`,n),{aggregatorName:e.name,aggregator:t,outputAmount:0n,priceImpact:0,minimumOutputAmount:0n,data:{path:i,routerAddress:e.routerAddress}}}},async simulateSwap(e,t,n){try{let r=await this.buildSwapTransaction(e,t);if(r.length===0)return{gasCostVTHO:0,success:!1,error:`Failed to build transaction clauses`};let i=await n.transactions.simulateTransaction(r,{caller:e.userAddress}),a=!1,o,s=2e5;for(let e=0;e<i.length;e++){let t=i[e];if(t.reverted){a=!0,o=t.vmError||`Transaction reverted`;break}s+=t.gasUsed}let c=s/1e5;return a?{gasCostVTHO:0,success:!1,error:o||`Transaction reverted`}:{gasCostVTHO:c,success:!0}}catch(e){return{gasCostVTHO:0,success:!1,error:e instanceof Error?e.message:`Simulation failed`}}},async buildSwapTransaction(t,n){if(!n.data||typeof n.data!=`object`||!(`path`in n.data))throw Error(`Invalid quote data`);let r=fc();if(!n.minimumOutputAmount||n.minimumOutputAmount===0n)throw Error(`Invalid quote: minimumOutputAmount is missing or zero`);let i=n.minimumOutputAmount,a=BigInt(t.amountIn);if(i===0n)throw Error(`Invalid quote: minimumOutputAmount is zero`);let o=dc(t.fromTokenAddress),s=dc(t.toTokenAddress),c=sn.ofAbi(ii.abi),l=[];if(o)l.push(ln.callFunction(cn.of(e.routerAddress),c.getFunction(`swapExactETHForTokens`),[i.toString(),n.data.path,t.userAddress,r.toString()],mn.of(a,pn.wei),{comment:`Swap on ${n.aggregatorName}`}));else{let o=sn.ofAbi(Qr.abi),u=cn.of(t.fromTokenAddress),d=cn.of(e.routerAddress);l.push(ln.callFunction(u,o.getFunction(`approve`),[d.toString(),a.toString()],mn.of(0n,pn.wei),{comment:`Swap on ${n.aggregatorName}`})),s?l.push(ln.callFunction(d,c.getFunction(`swapExactTokensForETH`),[a.toString(),i.toString(),n.data.path,t.userAddress,r.toString()],mn.of(0n,pn.wei),{comment:`Swap on ${n.aggregatorName}`})):l.push(ln.callFunction(d,c.getFunction(`swapExactTokensForTokens`),[a.toString(),i.toString(),n.data.path,t.userAddress,r.toString()],mn.of(0n,pn.wei),{comment:`Swap on ${n.aggregatorName}`}))}return l}};return t},mc={main:{routerAddress:`0xf21Dd7108D93af56FaB07423EfB90F4a3604DA89`,wrappedVET:`0xf9b02b47694fd635A413F16dC7B38aF06Cc16fe5`},test:{routerAddress:Ci,wrappedVET:Ci},solo:{routerAddress:Ci,wrappedVET:Ci}},hc=e=>{let t=mc[e]??mc.main;return pc({name:`BetterSwap.io`,routerAddress:t.routerAddress,wrappedVET:t.wrappedVET,getIcon:(e=`20px`)=>V.createElement(Te,{boxSize:e})})},gc=e=>e.startsWith(`0x`)?BigInt(e).toString():e,_c=e=>({to:e.to,value:gc(e.value),data:e.data,comment:e.comment||`Swap on aggregator`}),vc=e=>{let t={name:e.name,getIcon:e.getIcon,async getQuote(n,r){try{let r=new URLSearchParams({fromAddress:n.fromTokenAddress,toAddress:n.toTokenAddress,amountIn:n.amountIn,recipient:n.userAddress,slippageBps:String((n.slippageTolerance||1)*100),network:e.network}),i=await fetch(`${e.apiBaseUrl}/quote?${r.toString()}`);if(!i.ok)throw Error(`API request failed: ${i.status} ${i.statusText}`);let a=await i.json(),o=a.clauses.map(_c),s=BigInt(a.amountOut),c=BigInt(a.amountOutMin);return{aggregatorName:e.name,aggregator:t,outputAmount:s,minimumOutputAmount:c,priceImpact:0,data:{clauses:o,path:a.path}}}catch(n){return console.error(`${e.name} getQuote failed:`,n),{aggregatorName:e.name,aggregator:t,outputAmount:0n,priceImpact:0,minimumOutputAmount:0n,data:{clauses:[],path:[]}}}},async simulateSwap(e,t,n){try{if(!t.data||typeof t.data!=`object`||!(`clauses`in t.data))return{gasCostVTHO:0,success:!1,error:`Invalid quote data: clauses not found`};let r=t.data.clauses;if(r.length===0)return{gasCostVTHO:0,success:!1,error:`No clauses found in quote`};let i=await n.transactions.simulateTransaction(r,{caller:e.userAddress}),a=!1,o,s=2e5;for(let e=0;e<i.length;e++){let t=i[e];if(t.reverted){a=!0,o=t.vmError||`Transaction reverted`;break}s+=t.gasUsed}let c=s/1e5;return a?{gasCostVTHO:0,success:!1,error:o||`Transaction reverted`}:{gasCostVTHO:c,success:!0}}catch(e){return{gasCostVTHO:0,success:!1,error:e instanceof Error?e.message:`Simulation failed`}}},async buildSwapTransaction(e,t){if(!t.data||typeof t.data!=`object`||!(`clauses`in t.data))throw Error(`Invalid quote data: clauses not found`);let n=t.data.clauses;if(n.length===0)throw Error(`No clauses found in quote`);if(!t.minimumOutputAmount||t.minimumOutputAmount===0n)throw Error(`Invalid quote: minimumOutputAmount is missing or zero`);return n}};return t},yc=e=>vc({name:`VeTrade.vet`,apiBaseUrl:`https://vetrade.vet/api`,network:e,getIcon:(e=`20px`)=>V.createElement(Ae,{boxSize:e})}),bc=e=>[hc(e),yc(e)],xc=(e,t,n,r,i=1,a=!0)=>{let o=jn(),{connection:s}=Q(),c=e?.address??null,l=t?.address??null,{data:u}=ys(c===`0x`||c===Ci||!c?``:c),{data:d}=ys(l===`0x`||l===Ci||!l?``:l),f=W(()=>!c||c===`0x`||c===Ci||!u?18:Number(u?.decimals??18),[c,u?.decimals]),p=W(()=>!l||l===`0x`||l===Ci||!d?18:Number(d?.decimals??18),[l,d?.decimals]),m=W(()=>{if(!c||!l||!n||!r)return null;let e;try{e=xi(n,f)}catch(e){return console.error(`Failed to parse amount:`,n,e),null}return e<=0n?null:{fromTokenAddress:c,toTokenAddress:l,amountIn:e.toString(),userAddress:r,slippageTolerance:i}},[c,l,n,r,i,f]),{data:h,isLoading:g,error:_}=X({queryKey:[`unified-swap-quotes`,m,s.network],queryFn:async()=>{if(!m||!o||!s.network)return{quotes:[],best:null};let e=bc(s.network).map(async e=>{try{let t=await e.getQuote(m,o);try{let n=await e.simulateSwap(m,t,o);return{...t,aggregator:e,reverted:!n.success,revertReason:n.error,gasCostVTHO:n.gasCostVTHO}}catch(n){return console.error(`Failed to simulate swap for ${e.name}:`,n),{...t,aggregator:e,reverted:!0,revertReason:n instanceof Error?n.message:`Simulation failed`,gasCostVTHO:0}}}catch(t){return console.error(`Failed to get quote from ${e.name}:`,t),null}}),t=(await Promise.all(e)).filter(e=>e!==null&&e.outputAmount!==0n),n=null;if(t.length>0){let e=t.filter(e=>!(e.reverted??!1));n=(e.length>0?e:t).reduce((e,t)=>{let n=BigInt(e.outputAmount||`0`);return BigInt(t.outputAmount||`0`)>n?t:e})}return{quotes:t,best:n}},enabled:a&&m!==null&&o!=null,refetchInterval:1e4});return{bestQuote:h?.best??null,quotes:h?.quotes??[],isLoading:g,error:_,from:e?{...e,address:c??``,decimals:f}:null,to:t?{...t,address:l??``,decimals:p}:null}},Sc=({email:e,onResend:t,isLoading:n,isOpen:r,onClose:i})=>{let{t:a}=Y(),{darkMode:o}=$(),s=B(`colors`,`vechain-kit-text-secondary`),[c,l]=G(``),[u,d]=G(null),{createWallet:f}=yn(),{loginWithCode:p}=bn({onComplete:async({isNewUser:e})=>{e&&await f()}});return U(()=>{c.length===6&&p({code:c}).then(()=>{i()}).catch(e=>{d(e.message)})},[c]),J($a,{isOpen:r,onClose:i,trapFocus:!1,children:[J(Z,{children:[q(L,{alignItems:`center`,display:`flex`,gap:2,children:a(`Enter confirmation code`)}),q(F,{})]}),J(tt,{maxW:`container.lg`,children:[q(P,{children:J(z,{spacing:2,children:[q(N,{as:Sr,w:`48px`,h:`48px`,color:s}),q(R,{fontSize:`xs`,color:s,textAlign:`center`,children:a(`Please check {{email}} for an email from privy.io and enter your code below.`,{email:e})}),q(M,{spacing:2,justify:`center`,mt:4,children:J(xt,{value:c,onChange:l,otp:!0,size:`lg`,isInvalid:!!u,errorBorderColor:`#ef4444`,children:[q(St,{borderRadius:`12px`,border:`1px solid ${o?`#ffffff29`:`#ebebeb`}`,_hover:{border:`1px solid ${o?`#ffffff40`:`#e0e0e0`}`},_focus:{border:`1px solid ${o?`#ffffff60`:`#d0d0d0`}`,boxShadow:`none`},backgroundColor:o?`transparent`:`#ffffff`}),q(St,{borderRadius:`12px`,border:`1px solid ${o?`#ffffff29`:`#ebebeb`}`,_hover:{border:`1px solid ${o?`#ffffff40`:`#e0e0e0`}`},_focus:{border:`1px solid ${o?`#ffffff60`:`#d0d0d0`}`,boxShadow:`none`},backgroundColor:o?`transparent`:`#ffffff`}),q(St,{borderRadius:`12px`,border:`1px solid ${o?`#ffffff29`:`#ebebeb`}`,_hover:{border:`1px solid ${o?`#ffffff40`:`#e0e0e0`}`},_focus:{border:`1px solid ${o?`#ffffff60`:`#d0d0d0`}`,boxShadow:`none`},backgroundColor:o?`transparent`:`#ffffff`}),q(St,{borderRadius:`12px`,border:`1px solid ${o?`#ffffff29`:`#ebebeb`}`,_hover:{border:`1px solid ${o?`#ffffff40`:`#e0e0e0`}`},_focus:{border:`1px solid ${o?`#ffffff60`:`#d0d0d0`}`,boxShadow:`none`},backgroundColor:o?`transparent`:`#ffffff`}),q(St,{borderRadius:`12px`,border:`1px solid ${o?`#ffffff29`:`#ebebeb`}`,_hover:{border:`1px solid ${o?`#ffffff40`:`#e0e0e0`}`},_focus:{border:`1px solid ${o?`#ffffff60`:`#d0d0d0`}`,boxShadow:`none`},backgroundColor:o?`transparent`:`#ffffff`}),q(St,{borderRadius:`12px`,border:`1px solid ${o?`#ffffff29`:`#ebebeb`}`,_hover:{border:`1px solid ${o?`#ffffff40`:`#e0e0e0`}`},_focus:{border:`1px solid ${o?`#ffffff60`:`#d0d0d0`}`,boxShadow:`none`},backgroundColor:o?`transparent`:`#ffffff`})]})}),u&&q(R,{color:`#ef4444`,fontSize:`xs`,children:u})]})}),q(I,{children:J(R,{w:`100%`,textAlign:`center`,fontSize:`14px`,color:o?`whiteAlpha.700`:`gray.600`,children:[a(`Didn't get an email?`),` `,q(j,{variant:`link`,color:`blue.500`,fontSize:`14px`,onClick:t,isLoading:n,children:a(`Resend code`)})]})})]})]})},Cc=()=>{let{t:e}=Y(),{darkMode:t}=$(),[n,r]=G(``),{sendCode:i,state:a}=bn({}),o=Gt(),s=async()=>{await i({email:n}),o.onOpen()};return J(K,{children:[q(st,{colSpan:4,w:`full`,children:q(z,{spacing:3,w:`full`,children:J(ft,{size:`lg`,w:`full`,children:[q(pt,{pointerEvents:`none`,height:`100%`,pl:4,children:q(N,{as:Sr,color:t?`whiteAlpha.600`:`blackAlpha.700`,w:`20px`,h:`20px`})}),q(dt,{placeholder:e(`your@email.com`),value:n,onChange:e=>r(e.target.value),fontSize:`16px`,fontWeight:`400`,backgroundColor:t?`transparent`:`#ffffff`,border:`1px solid ${t?`#ffffff0a`:`#ebebeb`}`,p:6,borderRadius:16,w:`full`,pl:12}),q(j,{"aria-label":`Send code`,position:`absolute`,right:2,top:`50%`,transform:`translateY(-50%)`,zIndex:2,variant:`ghost`,size:`sm`,px:6,borderRadius:`full`,isLoading:a.status===`sending-code`,onClick:s,children:e(`Submit`)})]})})}),q(Sc,{isOpen:o.isOpen,onClose:o.onClose,onResend:()=>i({email:n}),email:n,isLoading:a.status===`sending-code`})]})},wc=({isDark:e,gridColumn:t})=>{let{t:n}=Y(),{initOAuth:r}=Wd();return q(st,{colSpan:t??4,w:`full`,children:q(gu,{isDark:e,onClick:async()=>{await r({provider:`google`})},icon:Vi,text:n(`Continue with Google`)})})},Tc=({isDark:e,gridColumn:t})=>{let{t:n}=Y(),{initOAuth:r}=Wd();return q(st,{colSpan:t??4,w:`full`,children:q(gu,{isDark:e,onClick:async()=>{await r({provider:`github`})},icon:gr,text:n(`Continue with Github`)})})},Ec=({isDark:e,gridColumn:t})=>{let{t:n}=Y(),{login:r}=wn();return q(st,{colSpan:t||4,w:`full`,children:q(gu,{isDark:e,onClick:r,icon:e?ge:Pe,text:n(`Use social login with VeChain`),variant:`loginWithVechain`,rightIcon:q(xu,{})})})},Dc=({isDark:e,gridColumn:t})=>{let{t:n}=Y(),{login:r}=Kd(),[i,a]=G(),o=Gt(),s=async()=>{o.onOpen();try{a(void 0),await r(),o.onClose()}catch(e){console.error(n(`Login failed:`),e),a(e instanceof Error?e.message:n(`Failed to connect with VeChain`))}};return J(K,{children:[q(st,{colSpan:t||4,w:`full`,children:q(gu,{isDark:e,onClick:s,icon:e?ge:Pe,text:n(`Use social login with VeChain`),variant:`loginWithVechain`,rightIcon:q(xu,{})})}),q(wu,{isOpen:o.isOpen,onClose:()=>{o.onClose()},onTryAgain:()=>{s()},error:i,title:n(`Connecting to VeChain`),loadingText:n(`Please approve the request in the connection request window...`)})]})},Oc=({isDark:e,gridColumn:t})=>{let{t:n}=Y(),{loginWithPasskey:r}=Hd(),[i,a]=G(),o=Gt(),s=async()=>{o.onOpen();try{a(void 0),await r(),o.onClose()}catch(e){(e instanceof Error?e.message.toLowerCase():``).includes(`not found`)&&(console.error(e),a(e instanceof Error?e.message:n(`Failed to connect with Passkey`)))}};return J(K,{children:[q(st,{colSpan:t,w:`full`,children:q(gu,{isDark:e,onClick:s,icon:pr,text:t&&t>=2?n(`Passkey`):void 0})}),q(wu,{isOpen:o.isOpen,onClose:()=>{o.onClose()},error:i,title:n(`Connecting with Passkey`),loadingText:n(`Please complete the passkey authentication...`),onTryAgain:()=>{s()}})]})},kc=({isDark:e,gridColumn:t=2})=>{let{t:n}=Y(),{open:r,onConnectionStatusChange:i}=Pn(),{dappKit:a}=$(),{source:o}=Nn(),s=a?.allowedWallets?.includes(`sync2`)?n(`Connect wallet`):n(`Connect with VeWorld wallet`);return U(()=>{i((e,t)=>{if(!e)return t?.message&&console.error(t?.message),{...o&&{source:o}}})},[i]),q(st,{colSpan:t||2,w:`full`,children:q(gu,{isDark:e,onClick:()=>{r()},icon:a?.allowedWallets?.includes(`sync2`)?Br:e?Ee:he,iconWidth:`27px`,text:t>=2?s:void 0,rightIcon:a?.allowedWallets?.includes(`sync2`)&&q(N,{as:qn})||void 0})})},Ac=({isDark:e,onViewMoreLogin:t,gridColumn:n})=>{let{t:r}=Y();return q(st,{colSpan:n,w:`full`,children:q(gu,{isDark:e,onClick:t,icon:dr,text:n&&n>=2?r(`More`):void 0,rightIcon:q(N,{as:qn})})})},jc=()=>{let{loginMethods:e,darkMode:t}=$(),{login:n}=wn(),{showGoogleLogin:r,showEmailLogin:i,showPasskey:a,showVeChainLogin:o,showDappKit:s,showMoreLogin:c,showGithubLogin:l,isOfficialVeChainApp:u}=Fd();return q(jt,{spacing:4,w:`full`,align:`center`,children:q(ot,{templateColumns:`repeat(4, 1fr)`,gap:2,w:`full`,children:e?.map(({method:e,gridColumn:d})=>{switch(e){case`email`:return i&&q(Cc,{},`email`);case`google`:return r&&q(wc,{isDark:t,gridColumn:d},`google`);case`github`:return l&&q(Tc,{isDark:t,gridColumn:d},`github`);case`vechain`:return o&&q(u?Ec:Dc,{isDark:t,gridColumn:d},`vechain`);case`passkey`:return a&&q(Oc,{isDark:t,gridColumn:d},`passkey`);case`dappkit`:return s&&q(kc,{isDark:t,gridColumn:d},`dappkit`);case`more`:return c&&q(Ac,{isDark:t,onViewMoreLogin:n,gridColumn:d},`more`);default:return null}})})})},Mc=({appsInfo:e,isLoading:t})=>{let{t:n}=Y(),r=Gt();return J(K,{children:[q(j,{fontSize:`sm`,variant:`link`,onClick:()=>{r.onOpen()},children:n(`Already have an x2earn app wallet?`)}),q(Ou,{isOpen:r.isOpen,onClose:r.onClose,appsInfo:e,isLoading:t})]})},Nc=({setCurrentContent:e,onClose:t})=>{let{t:n}=Y(),{connection:r}=Q(),{loginModalUI:i,darkMode:a}=$(),{loginMethods:o,privyEcosystemAppIDS:s}=$(),{data:c,isLoading:l}=oo(s),u=B(`colors`,`vechain-kit-text-secondary`),d=()=>{e(`faq`)};U(()=>{r.isConnected&&t()},[r.isConnected,t]);let f=o?.some(({method:e})=>e===`ecosystem`);return J(K,{children:[J(Z,{children:[q(kp,{onClick:d}),q(L,{children:n(`Log in or sign up`)}),q(F,{})]}),i?.logo&&q(M,{justify:`center`,children:q(ut,{src:i.logo||`/images/favicon.png`,maxW:`180px`,maxH:`90px`,m:8,alt:`logo`})}),J(P,{children:[i?.description&&q(M,{spacing:4,w:`full`,justify:`center`,mb:`24px`,px:4,children:q(R,{color:u,fontSize:`sm`,textAlign:`center`,children:i?.description})}),q(jc,{})]}),f?q(I,{children:q(M,{justify:`center`,w:`full`,children:q(Mc,{isDark:a,appsInfo:Object.values(c||{}),isLoading:l})})}):q(I,{pt:0,pb:`5px`})]})},Pc=({onClick:e,...t})=>{let{smartAccount:n,connectedWallet:r,connection:i}=Q(),[a,o]=G(!1);U(()=>{o(!localStorage.getItem(`app-first-visit`))},[]);let{data:s}=If(n?.address??``,r?.address??``,3),c=i.isConnectedWithPrivy&&s,l=()=>{a&&(localStorage.setItem(`app-first-visit`,`true`),o(!1)),e()};return q(lt,{"aria-label":`Notifications`,size:`sm`,variant:`ghost`,position:`absolute`,borderRadius:`50%`,left:`10px`,top:`10px`,onClick:l,icon:J(A,{position:`relative`,children:[q(N,{as:jr,fontSize:`18px`}),c&&q(A,{position:`absolute`,top:`-1px`,right:`-1px`,minWidth:`8px`,height:`8px`,bg:`red.500`,borderRadius:`full`})]}),...t})},Fc=({setCurrentContent:e,wallet:t,onClose:n})=>{let{t:r}=Y(),{network:i}=$();return J(Ap,{children:[J(Z,{children:[q(Pc,{onClick:()=>{e(`settings`)},"data-testid":`settings-button`}),J(L,{children:[r(`Wallet`),i?.type!==`main`&&q(Nt,{size:`xs`,colorScheme:`orange`,fontSize:`2xs`,p:1,ml:1,textTransform:`uppercase`,children:`${i?.type}`})]}),q(F,{})]}),q(P,{w:`full`,children:J(z,{w:`full`,overflow:`hidden`,justifyContent:`flex-start`,spacing:6,children:[q(Rc,{style:{justifyContent:`flex-start`},onClick:()=>{e(`profile`)},setCurrentContent:e,onClose:n,wallet:t}),q(Bc,{onAssetsClick:()=>{e(`assets`)}}),q(Uc,{setCurrentContent:e})]})}),q(I,{pt:0})]})},Ic=({leftIcon:e,rightIcon:t,title:n,wallet:r,onClick:i,leftImage:a,isActive:o=!1})=>{let{t:s}=Y(),{darkMode:c}=$();return q(j,{w:`full`,minH:`70px`,h:`fit-content`,py:4,onClick:i,backgroundColor:`transparent`,border:`1px solid ${c?`#ffffff29`:`#ebebeb`}`,children:J(M,{w:`full`,justify:`space-between`,children:[q(A,{minW:`40px`,justifyContent:`center`,children:a?q(ut,{justifySelf:`center`,src:a,w:`28px`,alt:`left-image`}):q(N,{as:e,fontSize:`28px`})}),J(z,{textAlign:`left`,w:`full`,flex:1,children:[q(M,{w:`full`,spacing:2,justifyContent:`flex-start`,children:q(R,{fontSize:`sm`,fontWeight:`400`,children:n})}),q(R,{fontSize:`sm`,fontWeight:`500`,opacity:.5,overflowWrap:`break-word`,wordBreak:`break-word`,whiteSpace:`normal`,w:`full`,children:r?.domain?d(r?.domain??``,18,0):l(r?.address??``,6,4)})]}),q(z,{minW:`40px`,justifyContent:`flex-end`,children:J(M,{justifyContent:`flex-end`,minW:`40px`,children:[o&&q(Nt,{size:`sm`,colorScheme:`green`,children:s(`Active`)}),q(N,{as:t,fontSize:`20px`,opacity:.5})]})})]})})},Lc=({leftIcon:e,rightIcon:t,title:n,onClick:r,leftImage:i,hide:a=!1,showComingSoon:o=!1,backgroundColor:s,_hover:c,isDisabled:l=!1,stacked:u=!1,isLoading:d,loadingText:f,style:p,extraContent:m,dataTestId:h,variant:g=`actionButton`})=>{let{t:_}=Y();return q(j,{variant:g===`actionButton`?`vechainKitSecondary`:g,py:u?0:2,minHeight:`50px`,height:`fit-content`,p:0,onClick:r,display:a?`none`:`flex`,isDisabled:o||l,isLoading:d,loadingText:f,bgColor:s,_hover:c,"data-testid":h,...p,children:J(M,{w:`full`,justify:`space-between`,alignItems:`center`,children:[q(A,{minW:`40px`,h:`20px`,children:i?q(ut,{src:i,w:`30px`,h:`30px`,borderRadius:`full`,alt:`left-image`,alignSelf:`end`,objectFit:`cover`}):q(N,{as:e,fontSize:`20px`,h:`full`,alignContent:`center`})}),q(z,{textAlign:`left`,w:`full`,flex:1,justifyContent:`flex-start`,alignItems:`flex-start`,children:J(M,{justify:`flex-start`,alignItems:`baseline`,children:[q(R,{fontSize:`sm`,fontWeight:`400`,children:n}),o&&q(Nt,{size:`sm`,colorScheme:`red`,children:_(`Coming Soon!`)}),m]})}),t&&q(z,{minW:`40px`,justifyContent:`flex-end`,children:q(N,{as:t,fontSize:`20px`,opacity:.5})})]})})},Rc=({wallet:e,setCurrentContent:t,size:n=`md`,onClick:r,onClose:i,mt:a,style:o})=>{let[s,c]=G(!1),{disconnect:u}=Q(),f=async()=>{await ie(e?.domain??e?.address??``)&&(c(!0),setTimeout(()=>{c(!1)},2e3))},p=()=>{u(),i()};return J(M,{mt:a,w:`full`,...o,justifyContent:`flex-start`,alignItems:`center`,children:[q(j,{w:`full`,h:12,"aria-label":`Wallet`,onClick:r,variant:`vechainKitSecondary`,p:3,"data-testid":`profile-button`,children:J(M,{spacing:2,align:`center`,justifyContent:`space-between`,w:`full`,children:[J(M,{spacing:2,justifyContent:`flex-start`,children:[q(jp,{wallet:e,props:{width:7,height:7}}),q(R,{fontSize:n,fontWeight:`500`,children:d(e?.domain??``,22,0)||l(e?.address??``,6,4)})]}),q(N,{boxSize:5,as:rr,cursor:`pointer`,opacity:.5})]})}),q(lt,{"aria-label":`Copy address`,icon:q(N,{as:s?er:lr}),onClick:f,variant:`ghost`,size:`sm`,opacity:.5,_hover:{opacity:.8}}),q(lt,{"aria-label":`Logout`,icon:q(N,{as:xr}),onClick:()=>t({type:`disconnect-confirm`,props:{onDisconnect:p,onBack:()=>t(`main`)}}),variant:`ghost`,size:`sm`,opacity:.5,_hover:{opacity:.8},colorScheme:`red`})]})},zc=({address:e,maxIcons:t=3,iconSize:n=20,ml:r=0,style:i,iconsGap:a=0,rightIcon:o,showNoAssetsWarning:c=!1,onClick:l})=>{let{t:u}=Y(),{tokensWithBalance:d}=ds({address:e}),{darkMode:f}=$(),m=B(`colors`,`vechain-kit-text-secondary`),h=a<1?`-${n/2}px`:`${a}px`,g=d.slice(0,t),_=d.length-t;return!e||d.length===0&&!c?null:J(M,{spacing:0,ml:r,...i,onClick:l,children:[J(M,{spacing:0,children:[g.map((e,t)=>q(Qe,{ml:t>0?h:`0`,zIndex:t,size:`${n}px`,borderRadius:`full`,bg:f?`gray.100`:`gray.600`,border:`2px solid #00000024`,alignItems:`center`,justifyContent:`center`,children:s[e.symbol]?V.cloneElement(s[e.symbol],{width:`${n*.8}px`,height:`${n*.8}px`,rounded:`full`}):p[e.symbol]?q(ut,{src:p[e.symbol],alt:`${e.symbol} logo`,width:`${n*.8}px`,height:`${n*.8}px`,rounded:`full`}):q(R,{fontSize:`${n*.4}px`,fontWeight:`bold`,color:f?`black`:`white`,children:e.symbol.slice(0,3)})},e.symbol)),_>0&&q(Qe,{ml:h,zIndex:g.length,size:`${n}px`,borderRadius:`full`,bg:f?`gray.100`:`gray.700`,display:`flex`,alignItems:`center`,justifyContent:`center`,border:`2px solid`,children:J(R,{fontSize:`${n*.4}px`,fontWeight:`bold`,color:f?`black`:`white`,children:[`+`,_]})}),d.length===0&&c&&q(R,{fontSize:`sm`,color:m,fontWeight:`700`,children:u(`No assets`)})]}),o]})},Bc=({mb:e,mt:t,onAssetsClick:n})=>{let{t:r}=Y(),{account:i}=Q(),{formattedBalance:a,isLoading:o}=fs({address:i?.address??``}),{refresh:s}=Gs(),[c,l]=G(!1),u=B(`colors`,`vechain-kit-text-secondary`),d=async()=>{l(!0),await s(),setTimeout(()=>{l(!1)},1500)};return J(z,{w:`full`,justifyContent:`start`,spacing:1,mt:t,mb:e,children:[J(M,{w:`full`,justifyContent:`flex-start`,alignItems:`center`,spacing:2,role:`group`,children:[q(ct,{size:`xs`,fontWeight:`500`,color:u,children:r(`Assets`)}),q(A,{display:`flex`,alignItems:`center`,justifyContent:`center`,w:`32px`,h:`32px`,children:q(lt,{"aria-label":`Refresh balances`,variant:`ghost`,size:`sm`,opacity:.5,_hover:{opacity:.8},onClick:d,icon:q(N,{as:Dr,boxSize:4}),isLoading:o||c,sx:{"& > span.chakra-button__spinner":{width:`16px`,height:`16px`,position:`absolute`}}})})]}),q(j,{onClick:n,h:`fit-content`,variant:`vechainKitSecondary`,children:J(z,{spacing:2,w:`full`,justifyContent:`flex-start`,alignItems:`flex-start`,mt:4,mb:4,children:[q(ct,{size:`2xl`,fontWeight:`700`,children:a}),q(M,{w:`full`,justifyContent:`flex-start`,"data-testid":`all-assets-button`,mt:2,children:q(zc,{style:{width:`100%`,justifyContent:`space-between`},maxIcons:10,iconSize:26,iconsGap:3,address:i?.address??``,showNoAssetsWarning:!0,rightIcon:q(N,{as:rr,boxSize:5,opacity:.5,marginLeft:2})})})]})})]})},Vc=[{icon:Yn,label:`Send`,onClick:e=>e({type:`send-token`,props:{setCurrentContent:e}}),isDisabled:e=>!e},{icon:Kn,label:`Swap`,onClick:e=>{e(`swap-token`)},isDisabled:e=>!e},{icon:Wn,label:`Receive`,onClick:e=>{e(`receive-token`)}}],Hc=({icon:e,label:t,onClick:n,isDisabled:r,showRedDot:i})=>{let{t:a}=Y();return q(lt,{variant:`vechainKitSecondary`,h:`80px`,w:`full`,"aria-label":t,isDisabled:r,p:3,icon:J(z,{spacing:4,children:[q(N,{as:e,boxSize:5,opacity:.9}),J(M,{p:0,alignItems:`baseline`,spacing:1,children:[q(R,{fontSize:`sm`,fontWeight:`600`,"data-testid":`${t.toLowerCase()}-button-label`,children:a(t,t)}),i&&q(A,{minWidth:`8px`,height:`8px`,bg:`red.500`,borderRadius:`full`,display:`flex`,alignItems:`center`,justifyContent:`center`})]})]}),onClick:n})},Uc=({mt:e,setCurrentContent:t})=>{let{account:n,smartAccount:r,connectedWallet:i,connection:a}=Q(),{hasAnyBalance:o}=fs({address:n?.address??``}),{data:s}=If(r?.address??``,i?.address??``,3),c=a.isConnectedWithPrivy&&s;return q(ot,{templateColumns:`repeat(3, 1fr)`,gap:2,w:`full`,mt:e,children:Vc.map(e=>q(Hc,{icon:e.icon,label:e.label,onClick:()=>e.onClick(t),isDisabled:e.isDisabled?.(o),showRedDot:c&&e.label===`Settings`},e.label))})},Wc=()=>{let[e,t]=G(!0),n=`vechain_kit_feature_announcement_closed`;return U(()=>{w(n)&&t(!1)},[]),{isVisible:e,closeAnnouncement:()=>{h(n,`true`),t(!1)}}},Gc=({setCurrentContent:e})=>{let{t}=Y(),{isVisible:n,closeAnnouncement:r}=Wc(),i=B(`colors`,`vechain-kit-text-primary`),a=B(`colors`,`vechain-kit-text-secondary`);return n?q(Ge,{w:`full`,variant:`featureAnnouncement`,overflow:`hidden`,onClick:()=>{e({type:`choose-name`,props:{setCurrentContent:e,onBack:()=>e(`main`),initialContentSource:`main`}}),r()},cursor:`pointer`,_hover:{opacity:.8},children:q(Ke,{p:4,children:J(M,{justify:`space-between`,align:`flex-start`,spacing:3,children:[J(z,{align:`flex-start`,spacing:1,children:[J(M,{spacing:2,children:[q(R,{fontSize:`sm`,fontWeight:`400`,color:i,children:t(`Claim your vet domain!`)}),q(Nt,{size:`sm`,colorScheme:`red`,children:t(`New`)})]}),q(R,{fontSize:`xs`,color:a,children:t(`Say goodbye to 0x addresses, claim your .veworld.vet subdomain now for free!`)})]}),q(lt,{size:`sm`,variant:`ghost`,colorScheme:`gray`,icon:q(cr,{}),onClick:e=>{e.stopPropagation(),r()},"aria-label":t(`Close announcement`)})]})})}):null},Kc=()=>{let{t:e}=Y();return q(Be,{status:`warning`,fontSize:`xs`,borderRadius:`xl`,p:2,children:q(z,{spacing:1,align:`stretch`,w:`full`,children:J(M,{spacing:2,align:`flex-start`,children:[q(He,{boxSize:4,mt:`10px`}),q(R,{w:`full`,children:e(`Sending to OceanX or other exchanges may result in loss of funds.`)})]})})})},qc=()=>{let{t:e}=Y();return q(Be,{status:`warning`,fontSize:`xs`,borderRadius:`xl`,p:2,children:q(z,{spacing:1,align:`stretch`,w:`full`,children:J(M,{spacing:2,align:`flex-start`,children:[q(He,{boxSize:4,mt:`10px`}),q(R,{w:`full`,children:e(`A .vet domain is required to customize your profile. Choose an account name to get started.`)})]})})})},Jc=()=>{let{t:e}=Y(),{getConnectionCache:t}=Gd(),n=t();return J(Ge,{variant:`vechainKitBase`,w:`full`,children:[J(Je,{p:4,pl:6,borderBottomWidth:`1px`,children:[q(R,{fontWeight:`medium`,opacity:.8,children:e(`Security preferences`)}),q(R,{fontSize:`xs`,mt:1,opacity:.7,children:e(`For security reasons, you can manage your embedded wallet settings only on the {{appName}} platform.`,{appName:n?.ecosystemApp.name??`origin app`})})]}),q(Ke,{borderRadius:`none`,children:J(z,{spacing:3,align:`stretch`,children:[J(M,{spacing:3,align:`center`,children:[q(Ye,{w:`fit-content`,h:`fit-content`,p:2,borderRadius:`full`,bg:`blackAlpha.100`,flexShrink:0,children:q(N,{as:zr})}),J(A,{flex:1,children:[q(R,{fontSize:`sm`,fontWeight:`medium`,lineHeight:`shorter`,children:e(`Login methods`)}),q(R,{fontSize:`xs`,opacity:.7,lineHeight:`shorter`,children:e(`Manage your login methods and passkeys`)})]})]}),J(M,{spacing:3,align:`center`,children:[q(Ye,{w:`fit-content`,h:`fit-content`,p:2,borderRadius:`full`,bg:`blackAlpha.100`,flexShrink:0,children:q(N,{as:Nr})}),J(A,{flex:1,children:[q(R,{fontSize:`sm`,fontWeight:`medium`,lineHeight:`shorter`,children:e(`Security settings`)}),q(R,{fontSize:`xs`,opacity:.7,lineHeight:`shorter`,children:e(`Backup your wallet, configure MFA and set recovery options`)})]})]})]})}),q(qe,{children:J(j,{variant:`vechainKitSecondary`,w:`full`,onClick:()=>{window.open(n?.ecosystemApp.website??`https://governance.vebetterdao.org/`,`_blank`)},children:[e(`Manage on {{appName}}`,{appName:n?.ecosystemApp.name??`origin app`}),q(N,{as:fr,ml:2})]})})]})},Yc=({setCurrentContent:e})=>{let{t}=Y(),{exportWallet:n}=wn(),{showMfaEnrollmentModal:r}=Cn(),{setWalletRecovery:i}=En(),{connection:a,smartAccount:o,connectedWallet:s}=Q(),c=B(`colors`,`vechain-kit-text-secondary`),{data:l}=If(o?.address??``,s?.address??``,3);return J(Ap,{children:[J(Z,{children:[q(L,{children:t(`Access and security`)}),q(Ja,{onClick:()=>e(`settings`)}),q(F,{})]}),q(P,{w:`full`,children:J(z,{justify:`center`,spacing:3,align:`flex-start`,w:`full`,children:[q(z,{w:`full`,justifyContent:`center`,spacing:3,mb:3,children:q(R,{fontSize:`sm`,color:c,textAlign:`center`,children:t(`Manage your embedded wallet security settings: handle your login methods, add a passkey or back up your wallet to never lose access to your assets.`)})}),l&&q(Lc,{title:t(`Upgrade Smart Account to V3`),description:t(`A new version is available for your account`),onClick:()=>{e({type:`upgrade-smart-account`,props:{setCurrentContent:e,initialContent:`access-and-security`}})},leftIcon:jr,extraContent:q(A,{minWidth:`8px`,height:`8px`,bg:`red.500`,borderRadius:`full`,display:`flex`,alignItems:`center`,justifyContent:`center`,ml:2})}),q(Lc,{title:t(`Your embedded wallet`),onClick:()=>{e(`embedded-wallet`)},leftIcon:Br,rightIcon:rr}),a.isConnectedWithSocialLogin?J(z,{w:`full`,justifyContent:`center`,spacing:0,children:[q(Lc,{title:t(`Login methods and Passkeys`),style:{borderBottomRadius:`0px`},onClick:()=>{e(`privy-linked-accounts`)},leftIcon:zr,rightIcon:rr}),q(Lc,{title:t(`Backup your wallet`),style:{borderTopRadius:`0px`,borderBottomRadius:`0px`},onClick:()=>{n()},leftIcon:yr}),q(Lc,{title:t(`Manage MFA`),style:{borderTopRadius:`0px`,borderBottomRadius:`0px`},onClick:()=>{r()},leftIcon:Nr}),q(Lc,{title:t(`Manage Recovery`),style:{borderTopRadius:`0px`},onClick:()=>{i()},leftIcon:Or})]}):q(Jc,{})]})}),q(I,{pt:0})]})},Xc=()=>{let{isolatedView:e,closeAccountModal:t}=ad();return{isolatedView:e,closeAccountModal:t}},Zc=({setCurrentContent:e,onLogoutSuccess:t})=>{let n=Zt(null),{t:r}=Y(),{isolatedView:i}=Xc(),{connection:a,disconnect:o,smartAccount:s,connectedWallet:c,account:l}=Q(),{data:u}=If(s?.address??``,c?.address??``,3);U(()=>{n.current&&(n.current.scrollTop=0)},[]);let d=()=>{e({type:`account-customization`,props:{setCurrentContent:e,initialContentSource:`settings`}})},f=()=>{l?.domain?e({type:`choose-name-search`,props:{name:``,setCurrentContent:e,initialContentSource:`settings`}}):e({type:`choose-name`,props:{setCurrentContent:e,initialContentSource:`settings`,onBack:()=>e(`settings`)}})},p=()=>{e(`access-and-security`)},m=()=>{e(`connection-details`)},h=()=>{e(`general-settings`)},g=()=>{o(),t()};return J(A,{children:[J(Z,{children:[q(L,{children:r(`Settings`)}),!i&&q(Ja,{onClick:()=>e(`main`)}),q(F,{})]}),q(P,{w:`full`,children:J(z,{w:`full`,spacing:4,children:[J(z,{w:`full`,spacing:0,children:[q(Lc,{style:{marginTop:`10px`,borderBottomRadius:`0px`},title:r(`Customize profile`),onClick:d,leftIcon:Rr,rightIcon:rr}),q(Lc,{style:{borderTopRadius:`0px`},title:r(`Choose account name`),description:r(`Choose a name for your account.`),onClick:f,leftIcon:Fr,rightIcon:rr})]}),J(z,{w:`full`,spacing:0,children:[a.isConnectedWithPrivy&&q(Lc,{style:{borderBottomRadius:`0px`},title:r(`Access and security`),onClick:p,leftIcon:Mr,rightIcon:rr,extraContent:u&&q(A,{minWidth:`8px`,height:`8px`,bg:`red.500`,borderRadius:`full`,display:`flex`,alignItems:`center`,justifyContent:`center`})}),q(Lc,{style:a.isConnectedWithPrivy?{borderTopRadius:`0px`,borderBottomRadius:`0px`}:{borderTopRadius:`12px`,borderBottomRadius:`0px`},title:r(`General`),onClick:h,leftIcon:Ar,rightIcon:rr}),q(Lc,{title:r(`Help`),onClick:()=>e({type:`faq`,props:{onGoBack:()=>e(`settings`),showLanguageSelector:!1}}),leftIcon:sr,rightIcon:rr,style:{borderTopRadius:`0px`}})]}),J(z,{w:`full`,spacing:0,children:[q(Lc,{style:{borderBottomRadius:`0px`},title:r(`Connection details`),onClick:m,leftIcon:Lr,rightIcon:rr}),q(Lc,{style:{borderTopRadius:`0px`},title:r(`Logout`),onClick:()=>e({type:`disconnect-confirm`,props:{onDisconnect:g,onBack:()=>e(`settings`)}}),leftIcon:xr})]})]})}),q(I,{pt:0})]})},Qc=()=>{let{t:e}=Y(),{network:t}=$(),{connection:n,smartAccount:r,connectedWallet:i}=Q(),{data:a,isLoading:o}=co(),{data:s,isLoading:c}=xf(r.address??``,i?.address??``),l=B(`colors`,`vechain-kit-text-primary`),u=B(`colors`,`vechain-kit-text-secondary`),d=({label:e,value:t,isLoading:n=!1,href:r})=>J(M,{w:`full`,justifyContent:`space-between`,children:[J(R,{fontSize:`sm`,color:l,children:[e,`:`]}),q(R,{fontSize:`sm`,as:r?`a`:void 0,href:r,target:`_blank`,rel:`noopener noreferrer`,style:{textDecoration:r?`underline`:`none`},color:u,children:n?`Loading...`:t})]});return J(K,{children:[q(d,{label:e(`Connection Type`),value:n.source.type,isLoading:n.isLoading}),q(d,{label:e(`Network`),value:t.type}),q(d,{label:e(`Node URL`),value:t.nodeUrl||k(t.type).nodeUrl}),n.isConnectedWithPrivy?J(K,{children:[q(d,{label:e(`Smart Account`),value:`v${s?.version??``} ${s?.isDeployed?``:`(not deployed)`}`,isLoading:c}),q(d,{label:e(`Privy Status`),value:a||``,isLoading:o})]}):r.isDeployed&&q(d,{label:e(`Smart Account`),value:`v${s?.version??``}`,isLoading:c}),q(d,{label:e(`VeChain Kit`),value:Xa,href:`https://github.com/vechain/vechain-kit/releases/tag/${Xa}`})]})},$c=({connectionCache:e})=>{let{t}=Y(),n=B(`colors`,`vechain-kit-card`),r=B(`colors`,`vechain-kit-text-secondary`),i=B(`colors`,`vechain-kit-text-primary`);return q(K,{children:e.ecosystemApp&&J(z,{p:4,bg:n,borderRadius:`xl`,spacing:4,w:`full`,children:[J(M,{w:`full`,justifyContent:`space-between`,children:[J(R,{fontSize:`sm`,color:i,children:[t(`Logged in with`),`:`]}),q(R,{fontSize:`sm`,color:r,children:e.ecosystemApp.name})]}),J(M,{w:`full`,justifyContent:`space-between`,children:[J(R,{fontSize:`sm`,color:i,children:[t(`At`),`:`]}),q(R,{fontSize:`sm`,color:r,children:new Date(e.timestamp).toLocaleString()})]}),q(Qc,{})]})})},el=()=>{let{t:e}=Y(),{source:t}=Nn(),n=B(`colors`,`vechain-kit-card`),r=B(`colors`,`vechain-kit-text-secondary`),i=B(`colors`,`vechain-kit-text-primary`);return q(K,{children:t&&J(z,{p:4,bg:n,borderRadius:`xl`,spacing:4,w:`full`,justifyContent:`space-between`,children:[J(M,{w:`full`,justifyContent:`space-between`,children:[J(R,{fontSize:`sm`,color:i,children:[e(`Logged in with`),`:`]}),q(R,{fontSize:`sm`,color:r,children:t})]}),q(Qc,{})]})})},tl=()=>{let{t:e}=Y(),{privy:t}=$(),{data:n,isLoading:r}=oo(t?.appId??``),i=B(`colors`,`vechain-kit-card`),a=B(`colors`,`vechain-kit-text-primary`),o=B(`colors`,`vechain-kit-text-secondary`);return r?q(z,{w:`full`,h:`full`,justify:`center`,align:`center`,children:q(At,{})}):q(K,{children:n&&J(z,{p:4,bg:i,borderRadius:`xl`,spacing:4,w:`full`,justifyContent:`space-between`,children:[J(M,{w:`full`,justifyContent:`space-between`,children:[J(R,{fontSize:`sm`,color:a,children:[e(`Logged in with`),`:`]}),q(R,{fontSize:`sm`,color:o,children:Object.values(n)[0].name})]}),q(Qc,{})]})})},nl=()=>{let{connection:e}=Q(),{t}=Y(),{privy:n,darkMode:r}=$(),{getConnectionCache:i}=Gd(),a=i();return J(z,{w:`full`,align:`stretch`,textAlign:`center`,mt:5,p:3,borderRadius:`lg`,bg:B(`colors`,`vechain-kit-card`),shadow:`sm`,children:[q(R,{fontSize:`xs`,fontWeight:`800`,children:t(`Wallet secured by`)}),J(M,{justify:`center`,children:[q(Se,{isDark:r,w:`50px`}),q(N,{as:Cr,ml:3}),e.isConnectedWithVeChain?q(fe,{isDark:r,w:`80px`,h:`auto`,mb:`3px`}):e.isConnectedWithCrossApp&&a&&q(ut,{src:a.ecosystemApp.logoUrl,alt:a.ecosystemApp.name,maxW:`40px`,borderRadius:`md`}),e.isConnectedWithSocialLogin&&!e.isConnectedWithVeChain&&q(ut,{src:n?.appearance.logo,alt:n?.appearance.logo,maxW:`40px`,borderRadius:`md`})]})]})},rl=({setCurrentContent:e})=>{let{t}=Y(),{connectedWallet:n,connection:r}=Q(),a=i(n?.address??``),{getConnectionCache:o}=Gd(),s=o(),c=B(`colors`,`vechain-kit-text-secondary`);return J(Ap,{children:[J(Z,{children:[q(L,{children:t(`Embedded wallet`)}),q(Ja,{onClick:()=>e(`access-and-security`)}),q(F,{})]}),q(P,{w:`full`,children:J(z,{justify:`center`,spacing:3,align:`flex-start`,w:`full`,children:[J(z,{justify:`center`,align:`center`,w:`full`,children:[q(ut,{src:a,maxW:`100px`,borderRadius:`50%`}),q(Ya,{wallet:n,style:{mt:2},showHumanAddress:!1})]}),r.isConnectedWithCrossApp&&J(K,{children:[q(R,{fontSize:`sm`,color:c,children:t(`This is your main wallet, created by {{element}} and secured by Privy.`,{element:s?.ecosystemApp?.name})}),q(R,{fontSize:`sm`,color:c,children:t(`This wallet is the owner of your smart account, which is used as your identity and as a gateway for your blockchain interactions.`)}),q(R,{fontSize:`sm`,color:c,children:t(`Please be sure to keep this wallet safe and backed up.`)})]}),r.isConnectedWithSocialLogin&&J(K,{children:[q(R,{fontSize:`sm`,color:c,children:t(`You are using an Embedded Wallet secured by your social login method, ensuring a seamless VeChain experience.`)}),q(R,{fontSize:`sm`,color:c,children:t(`This wallet is the owner of your smart account, which is used as your identity and as a gateway for your blockchain interactions.`)}),J(R,{fontSize:`sm`,color:c,children:[t(`We highly recommend exporting your private key to back up your wallet. This ensures you can restore it if needed or transfer it to self-custody using`),J(ht,{href:`https://www.veworld.net/`,isExternal:!0,color:c,fontSize:`14px`,textDecoration:`underline`,children:[` `,t(`VeWorld Wallet`),q(N,{ml:1,as:fr})]}),`.`]}),J(R,{fontSize:`sm`,color:c,children:[t(`Click`),` `,q(ht,{href:`https://docs.vechainkit.vechain.org/vechain-kit/embedded-wallets`,isExternal:!0,color:c,fontSize:`14px`,textDecoration:`underline`,children:t(`here`)}),` `,t(`to learn more about embedded wallets.`)]})]})]})}),q(I,{w:`full`,children:J(z,{w:`full`,children:[q(nt,{}),r.isConnectedWithPrivy&&q(nl,{})]})})]})},il=({onDisconnect:e,onBack:t,onClose:n,showCloseButton:r=!0,text:i})=>{let{t:a}=Y(),o=B(`colors`,`vechain-kit-text-primary`),s=i??a(`Are you sure you want to disconnect your wallet?`);return J(Ap,{children:[J(Z,{children:[q(L,{children:a(`Logout`)}),q(Ja,{onClick:t}),r?q(F,{onClick:n}):null]}),q(P,{children:q(z,{spacing:6,align:`stretch`,children:q(R,{fontSize:`md`,textAlign:`center`,color:o,children:s})})}),q(I,{w:`full`,children:J(z,{spacing:3,w:`full`,children:[q(j,{height:`60px`,colorScheme:`red`,w:`full`,onClick:e,"data-testid":`disconnect-button`,children:a(`Confirm`)}),q(j,{variant:`vechainKitSecondary`,onClick:t,"data-testid":`cancel-logout-button`,children:a(`Cancel`)})]})})]})},al=({onSelectToken:e,onBack:t,showAllTokens:n=!1})=>{let{t:r}=Y(),{darkMode:i}=$(),{currentCurrency:a}=us(),o=B(`colors`,`vechain-kit-text-primary`),s=B(`colors`,`vechain-kit-text-secondary`),c=B(`colors`,`vechain-kit-text-tertiary`),{account:l}=Q(),{tokensWithBalance:u,sortedTokens:d}=ds({address:l?.address??``}),[f,p]=G(``),m=W(()=>{if(n){let e=d.filter(e=>Number(e.balance)>0),t=[...d.filter(e=>Number(e.balance)===0)].sort((e,t)=>e.symbol.localeCompare(t.symbol));return[...e,...t]}return u},[n,d,u]).filter(({symbol:e})=>e.toLowerCase().includes(f.toLowerCase()));return J(K,{children:[J(Z,{children:[q(L,{children:r(`Select Token`)}),q(Ja,{onClick:t}),q(F,{})]}),q(tt,{h:[`540px`,`auto`],p:0,children:q(P,{children:J(z,{spacing:4,align:`stretch`,children:[J(ft,{size:`lg`,children:[q(dt,{placeholder:`Search token`,bg:i?`vechain-kit-overlay`:`vechain-kit-card`,borderRadius:`xl`,height:`56px`,pl:12,value:f,onChange:e=>p(e.target.value),"data-testid":`search-token-input`}),q(pt,{h:`56px`,w:`56px`,pl:4,children:q(kr,{color:c})})]}),q(R,{fontSize:`lg`,fontWeight:`semibold`,color:o,mt:4,children:r(n?`All tokens`:`Your tokens`)}),m.length===0?J(z,{spacing:2,py:8,children:[q(N,{as:Pr,boxSize:12,color:c}),q(R,{fontSize:`lg`,color:o,children:r(`No tokens found`)}),q(R,{fontSize:`md`,color:s,children:r(`Try searching with a different term`)})]}):q(z,{spacing:2,align:`stretch`,children:m.map(t=>q(ro,{symbol:t.symbol,amount:Number(t.balance),currencyValue:t.valueInCurrency,currentCurrency:a,onClick:()=>e(t)},t.address))})]})})}),q(I,{pt:0})]})},ol=({setCurrentContent:e,preselectedToken:t,initialAmount:n=``,initialToAddressOrDomain:r=``,onBack:i=()=>e(`main`)})=>{let{t:a}=Y(),{darkMode:o,feeDelegation:c}=$(),{currentCurrency:l}=us(),u=B(`colors`,`vechain-kit-text-primary`),d=B(`colors`,`vechain-kit-text-secondary`),f=B(`colors`,`vechain-kit-text-tertiary`),m=B(`colors`,`vechain-kit-error`),h=B(`colors`,`vechain-kit-card`),{exchangeRates:g}=ss(),{account:_}=Q(),{isolatedView:v}=Xc(),{tokensWithBalance:y}=ds({address:_?.address??``}),[b,x]=G(t??y[0]??null),[S,C]=G(!1);U(()=>{!t&&!b&&y.length>0&&x(y[0])},[y,t,b]);let{register:w,watch:ee,setValue:T,setError:E,formState:{errors:D,isValid:te},handleSubmit:ne}=Hi({defaultValues:{amount:n,toAddressOrDomain:r},mode:`onChange`}),{toAddressOrDomain:re,amount:O}=ee(),ie=Zt(b);U(()=>{ie.current&&b&&ie.current.address!==b.address&&T(`amount`,``),ie.current=b},[b,T]);let ae=W(()=>b?no(eo(Number(O)*b.priceUsd,l,g),{currency:l}):``,[O,b,l,g]),{data:oe,isLoading:se}=uo(re),k=()=>{b&&T(`amount`,b.balance)},ce=()=>{i()},le=async t=>{if(b){if(!(oe?.isValidAddressOrDomain&&(!oe?.domain||oe?.domain&&oe?.isPrimaryDomain))){E(`toAddressOrDomain`,{type:`manual`,message:a(`Invalid address or domain`)});return}if(b){let e=nn(t.amount),n=c?.b3trTransfers?.minAmountInEther;if(b.symbol===`B3TR`&&typeof n==`number`&&n>0)try{if(e<nn(String(n))){E(`amount`,{type:`manual`,message:a(`Minimum {{symbol}} transfer is {{min}}`,{symbol:b.symbol,min:n})});return}}catch{}if(e>nn(b.balance)){E(`amount`,{type:`manual`,message:a(`Insufficient {{symbol}} balance`,{symbol:b.symbol})});return}}e({type:`send-token-summary`,props:{toAddressOrDomain:t.toAddressOrDomain,resolvedDomain:oe?.domain,resolvedAddress:oe?.address,amount:t.amount,selectedToken:b,formattedTotalAmount:ae,setCurrentContent:e}})}};return S?q(al,{setCurrentContent:e,onSelectToken:e=>{x(e),C(!1)},onBack:()=>{C(!1)}}):J(K,{children:[J(Z,{children:[q(L,{children:a(`Send`)}),!v&&q(Ja,{onClick:ce}),q(F,{})]}),q(P,{children:J(z,{spacing:1,align:`stretch`,position:`relative`,children:[J(A,{p:6,borderRadius:`xl`,bg:h,children:[q(R,{fontSize:`sm`,fontWeight:`medium`,color:u,mb:2,children:a(`Amount`)}),q(z,{align:`stretch`,spacing:2,children:J(it,{isInvalid:!!D.amount,children:[J(M,{justify:`space-between`,children:[q(dt,{...w(`amount`,{required:a(`Amount is required`),pattern:{value:/^\d*\.?\d*$/,message:a(`Please enter a valid number`)},validate:e=>{if(!e)return!0;let t=parseFloat(e);if(isNaN(t))return a(`Please enter a valid number`);let n=c?.b3trTransfers?.minAmountInEther;return b?.symbol===`B3TR`&&typeof n==`number`&&n>0&&t<n?a(`Minimum {{symbol}} transfer is {{min}}`,{symbol:b.symbol,min:n}):!0}}),onChange:e=>{let t=e.target.value.trim();e.target.value=t,T(`amount`,t,{shouldValidate:!0})},placeholder:`0`,variant:`unstyled`,fontSize:`4xl`,fontWeight:`bold`,"data-testid":`tx-amount-input`,type:`number`,inputMode:`decimal`,color:u}),b?J(j,{variant:`outline`,size:`sm`,borderRadius:`full`,px:6,color:d,borderColor:d,_hover:{bg:o?`whiteAlpha.300`:`blackAlpha.300`},onClick:()=>C(!0),leftIcon:s[b.symbol]?V.cloneElement(s[b.symbol],{boxSize:`20px`,borderRadius:`full`}):q(ut,{src:p[b.symbol],alt:`${b.symbol} logo`,boxSize:`20px`,borderRadius:`full`,fallback:q(A,{boxSize:`20px`,borderRadius:`full`,bg:`whiteAlpha.200`,display:`flex`,alignItems:`center`,justifyContent:`center`,children:q(R,{fontSize:`8px`,fontWeight:`bold`,color:u,children:b.symbol.slice(0,3)})})}),children:[b.symbol,q(N,{as:tr,boxSize:5,color:d})]}):J(j,{variant:`outline`,size:`sm`,borderRadius:`full`,px:6,color:d,borderColor:d,_hover:{bg:o?`whiteAlpha.300`:`blackAlpha.300`,color:f},onClick:()=>C(!0),children:[a(`Select token`),q(N,{as:tr,boxSize:5,color:d})]})]}),b&&J(M,{spacing:1,fontSize:`sm`,justifyContent:`space-between`,color:d,children:[J(R,{color:d,children:[`≈ `,ae]}),q(R,{cursor:`pointer`,_hover:{color:d,textDecoration:`underline`},onClick:k,noOfLines:1,overflow:`hidden`,textOverflow:`ellipsis`,children:a(`Send all`)})]}),D.amount&&q(R,{color:`#ef4444`,fontSize:`sm`,mt:1,"data-testid":`amount-error-msg`,children:D.amount.message})]})})]}),J(A,{borderRadius:`xl`,bg:h,children:[q(R,{fontSize:`sm`,fontWeight:`medium`,color:u,mb:2,px:6,pt:6,children:a(`To`)}),q(z,{align:`stretch`,spacing:2,p:6,pt:2,width:`100%`,children:J(it,{isInvalid:!!D.toAddressOrDomain,children:[q(dt,{...w(`toAddressOrDomain`,{required:a(`Address is required`)}),onChange:e=>{let t=e.target.value.trim(),n=t.includes(`.`)?Ui(t):t;e.target.value=n,T(`toAddressOrDomain`,n,{shouldValidate:!0})},placeholder:a(`Type the receiver address or domain`),_placeholder:{fontSize:`md`,fontWeight:`normal`},fontSize:`lg`,fontWeight:`bold`,color:u,variant:`unstyled`,"data-testid":`tx-address-input`}),D.toAddressOrDomain&&q(R,{color:m,fontSize:`sm`,"data-testid":`address-error-msg`,children:D.toAddressOrDomain.message})]})})]})]})}),q(I,{children:q(j,{variant:`vechainKitPrimary`,isDisabled:!b||!te,isLoading:se,onClick:ne(le),"data-testid":`send-button`,children:a(b?`Send`:`Select Token`)})})]})},sl=({setCurrentContent:e,toAddressOrDomain:t,resolvedDomain:n,resolvedAddress:r,amount:a,selectedToken:o,formattedTotalAmount:s})=>{let{t:c}=Y(),{account:l,connection:u,connectedWallet:d}=Q(),{data:f}=Ko(r??``),{network:p,feeDelegation:m}=$(),{preferences:h}=Tp(),{isolatedView:g,closeAccountModal:_}=Xc(),v=B(`colors`,`vechain-kit-text-primary`),y=B(`colors`,`vechain-kit-text-secondary`),{data:b}=If(l?.address??``,d?.address??``,3),{open:x}=Id(),S=W(()=>f||i(r||t),[f,p.type,r,t]),C=async()=>{if(b){x();return}try{o.symbol===`VET`?await re():await ee()}catch(e){console.error(c(`Transaction failed:`),e)}},w=t=>{e({type:`successful-operation`,props:{setCurrentContent:e,txId:t,title:c(`Transaction successful`),onDone:()=>{g?_():e(`main`)},showSocialButtons:!0}})},{sendTransaction:ee,txReceipt:T,error:E,isWaitingForWalletConfirmation:D,isTransactionPending:te,clauses:ne}=$f({fromAddress:l?.address??``,receiverAddress:r||t,amount:a,tokenAddress:o.address,tokenName:o.symbol,onSuccess:()=>{w(T?.meta.txID??``)},onError:e=>{de(e??``)}}),{sendTransaction:re,txReceipt:O,error:ie,isWaitingForWalletConfirmation:ae,isTransactionPending:oe,clauses:se}=tp({fromAddress:l?.address??``,receiverAddress:r||t,amount:a,onSuccess:()=>{w(O?.meta.txID??``)},onError:e=>{de(e??``)}}),k=()=>o.symbol===`VET`?O:T,ce=D||ae,le=ce||te||oe,ue=()=>{e({type:`send-token`,props:{setCurrentContent:e,preselectedToken:o,initialAmount:a,initialToAddressOrDomain:t}})},de=e=>{console.error(`Transaction failed:`,e)},[fe,pe]=V.useState(null),[me,he]=V.useState(null),ge=h.availableGasTokens.length>0&&(u.isConnectedWithPrivy||u.isConnectedWithVeChain)&&!m?.delegatorUrl,{data:_e,isLoading:ve,error:ye,refetch:be}=Ep({clauses:o.symbol===`VET`?se:ne,tokens:fe?[fe]:h.availableGasTokens,sendingAmount:a,sendingTokenSymbol:o.symbol,enabled:ge&&!!m?.genericDelegatorUrl}),xe=_e?.usedToken,Se=(ve||!_e)&&u.isConnectedWithPrivy&&!m?.delegatorUrl,Ce=V.useCallback(e=>{pe(e),he(e),setTimeout(()=>be(),100)},[be]),we=!!xe&&!ye;return V.useEffect(()=>{ye&&fe&&pe(null)},[ye,fe]),J(K,{children:[J(Z,{children:[q(L,{children:`Send`}),q(Ja,{isDisabled:le,onClick:ue}),q(F,{isDisabled:le})]}),q(P,{children:q(z,{spacing:6,align:`stretch`,w:`full`,children:J(z,{spacing:4,w:`full`,children:[q(Op,{label:c(`From`),address:l?.address??``,domain:l?.domain,imageSrc:l?.image??``,imageAlt:`From account`,balance:Number(o.balance),tokenAddress:o.address}),q(Op,{label:c(`To`),address:r||t,domain:n,imageSrc:S??``,imageAlt:`To account`,tokenAddress:o.address}),u.isConnectedWithPrivy&&q(Fp,{estimation:_e,isLoading:ve,isLoadingTransaction:le,onTokenChange:Ce,clauses:o.symbol===`VET`?se:ne,userSelectedToken:me}),J(z,{spacing:0,w:`full`,justifyContent:`flex-start`,children:[q(R,{fontSize:`sm`,fontWeight:`light`,textAlign:`left`,w:`full`,color:y,children:c(`Amount`)}),J(M,{justifyContent:`flex-start`,w:`full`,children:[J(R,{fontSize:`xl`,fontWeight:`semibold`,textAlign:`left`,"data-testid":`send-summary-amount`,color:v,children:[Number(a).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2}),` `,o.symbol]}),J(R,{color:y,children:[`≈ `,s]})]})]})]})})}),q(I,{children:q(Mp,{transactionError:o.symbol===`VET`?ie:E,isSubmitting:le,isTxWaitingConfirmation:ce,onConfirm:C,transactionPendingText:c(`Sending...`),txReceipt:k(),buttonText:c(`Confirm`),isDisabled:le||Se,gasEstimationError:ye,hasEnoughGasBalance:we,isLoadingGasEstimation:ve,showGasEstimationError:!m?.delegatorUrl&&u.isConnectedWithPrivy,context:`send`})})]})},cl=({setCurrentContent:e})=>{let{t}=Y(),{account:n}=Q(),{isolatedView:r}=Xc(),i=B(`colors`,`vechain-kit-text-primary`),a=B(`colors`,`vechain-kit-text-secondary`);return J(K,{children:[J(Z,{children:[q(L,{children:t(`Receive`)}),!r&&q(Ja,{onClick:()=>e(`main`)}),q(F,{})]}),J(tt,{maxW:`container.lg`,children:[q(P,{children:J(z,{spacing:4,align:`center`,w:`full`,children:[q(Wi,{value:n?.address??``,size:200,removeQrCodeBehindLogo:!0,eyeRadius:4,logoPaddingStyle:`circle`,style:{borderRadius:`16px`}}),q(Ya,{wallet:n,style:{w:`85%`}}),q(R,{fontSize:`sm`,textAlign:`center`,color:i,children:t(`Copy your address or scan this QR code`)}),q(R,{fontSize:`xs`,textAlign:`center`,color:a,children:t(`This address only supports VeChain assets.`)})]})}),q(I,{pt:0})]})]})},ll=({quotes:e,selectedQuote:t,toTokenAddress:n,onSelectQuote:r,onBack:i})=>{let{t:a}=Y(),{darkMode:c}=$(),{currentCurrency:l}=us(),{account:u}=Q(),{exchangeRates:d,prices:f}=ss(),{tokens:m}=ds({address:u?.address??``}),[h,g]=G(!1),_=W(()=>n&&m.find(e=>o(e.address,n))||null,[n,m]),v=e.filter(e=>!e.reverted),y=e.filter(e=>e.reverted),b=W(()=>v.length===0?null:v.reduce((e,t)=>{let n=BigInt(e.outputAmount||`0`);return BigInt(t.outputAmount||`0`)>n?t:e}),[v]),x=W(()=>{let e=n&&f[n]||0;return v.map(t=>{let n=gi(BigInt(t.outputAmount||`0`)),r=Number(n)*e,i=eo(r,l,d),a=b&&t.aggregatorName===b.aggregatorName,o=0;if(b&&!a){let e=BigInt(b.outputAmount||`0`),n=BigInt(t.outputAmount||`0`);o=Number(n-e)/Number(e)*100}return{...t,outputAmountFormatted:n,valueUsd:r,valueInCurrency:i,isBest:a,percentageDiff:o}}).sort((e,t)=>{let n=BigInt(e.outputAmount||`0`),r=BigInt(t.outputAmount||`0`);return Number(r-n)})},[v,n,f,l,d,b]);return J(K,{children:[J(Z,{children:[q(L,{children:a(`Found following rates`)}),q(Ja,{onClick:i}),q(F,{})]}),q(tt,{h:[`540px`,`auto`],p:0,children:q(P,{children:J(z,{spacing:6,align:`stretch`,children:[x.length>0&&q(z,{spacing:2,align:`stretch`,children:x.map(e=>{let n=t?.aggregatorName===e.aggregatorName;return J(A,{p:2.5,borderRadius:`xl`,bg:c?`#00000038`:`gray.50`,borderWidth:1,borderColor:n?`blue.500`:c?`whiteAlpha.200`:`gray.200`,cursor:`pointer`,onClick:()=>r(e),_hover:{borderColor:n?`blue.500`:c?`whiteAlpha.400`:`gray.300`},position:`relative`,children:[(e.isBest||!e.isBest&&e.percentageDiff<0)&&q(A,{position:`absolute`,top:-1,left:0,zIndex:1,children:e.isBest?q(We,{colorScheme:`purple`,borderRadius:`sm`,fontSize:`2xs`,px:1.5,py:.5,borderTopLeftRadius:`xl`,borderBottomRightRadius:`md`,children:a(`Best`)}):J(We,{colorScheme:`red`,borderRadius:`xs`,fontSize:`2xs`,px:1.5,py:.5,borderTopLeftRadius:`xl`,borderBottomRightRadius:`md`,children:[e.percentageDiff.toFixed(2),`%`]})}),J(z,{align:`stretch`,spacing:1.5,marginTop:4,children:[J(M,{justify:`space-between`,align:`center`,children:[J(M,{spacing:1.5,align:`center`,children:[e.aggregator.getIcon(`20px`),q(R,{fontSize:`md`,fontWeight:`bold`,children:e.aggregatorName})]}),q(M,{align:`center`,spacing:1.5,children:_&&J(K,{children:[s[_.symbol]?V.cloneElement(s[_.symbol],{boxSize:`24px`,borderRadius:`full`}):p[_.symbol]?q(ut,{src:p[_.symbol],alt:`${_.symbol} logo`,boxSize:`24px`,borderRadius:`full`}):null,q(Ft,{label:Number(e.outputAmountFormatted).toLocaleString(void 0,{maximumFractionDigits:18}),hasArrow:!0,placement:`top`,children:J(R,{fontSize:`md`,fontWeight:`bold`,textAlign:`right`,whiteSpace:`nowrap`,children:[Number(e.outputAmountFormatted).toLocaleString(void 0,{minimumFractionDigits:4}),` `,_.symbol]})})]})})]}),J(M,{justify:`space-between`,align:`center`,children:[q(R,{fontSize:`xs`,color:c?`whiteAlpha.500`:`blackAlpha.500`,children:e.gasCostVTHO&&e.gasCostVTHO>0?`Gas: ${e.gasCostVTHO.toLocaleString(void 0,{maximumFractionDigits:2})} VTHO`:``}),e.valueUsd>0&&J(R,{fontSize:`xs`,color:c?`whiteAlpha.600`:`blackAlpha.600`,textAlign:`right`,whiteSpace:`nowrap`,children:[`≈ `,no(e.valueInCurrency,{currency:l})]})]})]})]},e.aggregatorName)})}),y.length>0&&J(A,{children:[J(M,{justify:`space-between`,cursor:`pointer`,onClick:()=>g(!h),py:2,children:[J(R,{fontSize:`sm`,color:c?`whiteAlpha.600`:`blackAlpha.600`,children:[y.length,` `,a(`rate`),y.length===1?``:`s`,` `,a(`unavailable`)]}),q(N,{as:h?ir:tr,boxSize:4,color:c?`whiteAlpha.600`:`blackAlpha.600`})]}),q($e,{in:h,animateOpacity:!0,children:q(z,{spacing:2,align:`stretch`,pt:2,children:y.map(e=>q(A,{p:2,borderRadius:`xl`,bg:c?`#00000038`:`gray.50`,opacity:.6,children:J(M,{justify:`space-between`,children:[J(M,{spacing:2,align:`center`,children:[e.aggregator.getIcon(`20px`),q(R,{fontSize:`md`,fontWeight:`medium`,children:e.aggregatorName})]}),q(R,{fontSize:`xs`,color:c?`whiteAlpha.500`:`blackAlpha.500`,children:a(`Unable to fetch the price`)})]})},e.aggregatorName))})})]}),x.length===0&&y.length===0&&q(z,{spacing:2,py:8,color:c?`whiteAlpha.600`:`blackAlpha.600`,children:q(R,{fontSize:`lg`,children:a(`No quotes available`)})})]})})}),q(I,{})]})},ul=e=>e===`0x`||e===Ci||!e,dl=(e,t,n,r)=>{if(!e||!t||!n||!r)return null;let i=t.toLowerCase(),a=n.toLowerCase(),o=r.toLowerCase(),s=ul(n),c=ul(r),l=[],u=[];if(e.outputs&&Array.isArray(e.outputs))for(let t of e.outputs)t.events&&Array.isArray(t.events)&&l.push(...t.events),t.transfers&&Array.isArray(t.transfers)&&u.push(...t.transfers);let d=Qr.createInterface().getEvent(`Transfer`),f=d.topicHash.toLowerCase(),p=l.filter(e=>e.topics&&e.topics.length>0&&e.topics[0]?.toString().toLowerCase()===f),m=null,h=null;if(s){for(let e of u)if(e.sender?.toLowerCase()===i&&e.amount&&e.amount!==`0x0`&&e.amount!==`0x`){let t=BigInt(e.amount);if(t>0n){m=t;break}}}if(c){for(let e of u)if(e.recipient?.toLowerCase()===i&&e.amount&&e.amount!==`0x0`&&e.amount!==`0x`){let t=BigInt(e.amount);if(t>0n){h=t;break}}}if(p.length>0)for(let e of p)try{let t=pi({abi:[d],data:e.data.toString(),topics:e.topics.map(e=>e.toString())});if(!t.args||!(`from`in t.args)||!(`to`in t.args)||!(`value`in t.args))continue;let n=t.args.from?.toString().toLowerCase(),r=t.args.to?.toString().toLowerCase(),l=t.args.value,u=e.address.toLowerCase();!s&&n===i&&u&&u===a&&l>0n&&m===null&&(m=l),!c&&r===i&&u&&u===o&&l>0n&&h===null&&(h=l)}catch(e){console.warn(`Failed to decode transfer event:`,e);continue}return{fromAmount:m??0n,toAmount:h??0n}},fl=({setCurrentContent:e,fromTokenAddress:t,toTokenAddress:n})=>{let{t:r}=Y(),{account:i,connection:a}=Q(),{currentCurrency:c}=us(),{network:l,feeDelegation:u}=$(),{isolatedView:d,closeAccountModal:f}=Xc(),m=B(`colors`,`vechain-kit-card`),h=B(`colors`,`vechain-kit-card-hover`),g=B(`colors`,`vechain-kit-border`),_=B(`colors`,`vechain-kit-text-primary`),v=B(`colors`,`vechain-kit-text-secondary`),y=B(`colors`,`vechain-kit-text-tertiary`),{preferences:b}=Tp(),{sortedTokens:x}=ds({address:i?.address??``}),[S,C]=G(`main`),[w,ee]=G(null),[T,E]=G(null),[D,te]=G(``),[ne,re]=G(!1),[O,ie]=G(1),[ae,oe]=G(!1),[se,ce]=G(`1`),[le,ue]=G(null),[de,fe]=V.useState(null),[pe,me]=V.useState(null),[he,ge]=V.useState([]),{prices:_e,exchangeRates:ve}=ss(),ye=O===1;V.useEffect(()=>{ce(O===1?`1`:O===.5?`0.5`:O===3?`3`:O.toString())},[O]),V.useEffect(()=>{if(x.length!==0){if((t||n)&&(!w||!T)){if(t&&!w){let e=x.find(e=>o(e.address,t));e&&ee(e)}if(n&&!T){let e=x.find(e=>o(e.address,n));e&&E(e)}return}if(!w&&!T){let e=x.find(e=>e.symbol===`VET`);e&&ee(e);let t=x.find(e=>e.symbol===`B3TR`);if(!t)try{let e=k(l.type).b3trContractAddress;e&&(t=x.find(t=>o(t.address,e)))}catch(e){console.warn(`Failed to get B3TR address from config:`,e)}t&&E(t)}}},[x,w,T,t,n,l.type]);let be=H(()=>{if(w&&T){let e=w;ee(T),E(e),te(``)}},[w,T]);V.useEffect(()=>{ue(null)},[w?.address,T?.address,D]);let{bestQuote:xe,quotes:Se,isLoading:Ce,from:we,to:Te}=xc(w,T,D,i?.address??``,O,!!w&&!!T&&Number(D)>0),Ee=W(()=>{if(!D||Number(D)<=0||!we)return 0n;try{return xi(D,we.decimals)}catch{return 0n}},[D,we?.decimals]),De=le||xe,Oe=W(()=>{if(!De?.outputAmount||!Te)return`0`;try{return _i(De.outputAmount,Te.decimals)}catch{return`0`}},[De,Te?.decimals]),ke=W(()=>{if(!w||!D)return 0;let e=_e[w.address]||0;return eo(Number(D)*e,c,ve)},[w?.address,D,_e,c,ve]),Ae=W(()=>{if(!T||!Oe)return 0;let e=_e[T.address]||0;return eo(Number(Oe)*e,c,ve)},[T?.address,Oe,_e,c,ve]),je=W(()=>!w||!T||!i?.address||Ee===0n?null:{fromTokenAddress:w.address,toTokenAddress:T.address,amountIn:Ee.toString(),userAddress:i.address,slippageTolerance:O},[w,T,i?.address,Ee,O]),Me=De?.gasCostVTHO??0;V.useEffect(()=>{(async()=>{if(!De||!je||!De.aggregator){ge([]);return}try{ge(await De.aggregator.buildSwapTransaction(je,De))}catch(e){console.error(`Failed to build swap clauses for gas estimation:`,e),ge([])}})()},[De,je]);let Ne=b.availableGasTokens.length>0&&(a.isConnectedWithPrivy||a.isConnectedWithVeChain)&&!u?.delegatorUrl,{data:Pe,isLoading:Fe,error:Ie,refetch:Le}=Ep({clauses:he,tokens:de?[de]:b.availableGasTokens,sendingAmount:D,sendingTokenSymbol:w?.symbol??``,enabled:Ne&&!!u?.genericDelegatorUrl&&he.length>0}),Re=Pe?.usedToken,ze=(Fe||!Pe)&&a.isConnectedWithPrivy&&!u?.delegatorUrl,Be=V.useCallback(e=>{fe(e),me(e),setTimeout(()=>Le(),100)},[Le]),Ve=!!Re&&!Ie;V.useEffect(()=>{Ie&&de&&fe(null)},[Ie,de]);let{executeSwap:He,isTransactionPending:Ue,isWaitingForWalletConfirmation:We,txReceipt:Ge,status:Ke,error:qe}=uc(je,De),Je=H(()=>{let t=Ge?.meta.txID??``,n=r(`Swap successful`,{defaultValue:`Swap successful`}),a;if(Ge&&w&&T&&i?.address){let e=dl(Ge,i.address,w.address,T.address);if(e&&we&&Te)try{let t=we.decimals,n=Te.decimals,i=_i(e.fromAmount,t),o=_i(e.toAmount,n),s=e=>{let t=Number(e);return t>=1e3?t.toLocaleString(void 0,{maximumFractionDigits:2}):t.toLocaleString(void 0,{maximumFractionDigits:6,minimumFractionDigits:0})};a=r(`You successfully swapped {fromAmount} {fromSymbol} for {toAmount} {toSymbol}`,{fromAmount:s(i),fromSymbol:w.symbol,toAmount:s(o),toSymbol:T.symbol,defaultValue:`You successfully swapped ${s(i)} ${w.symbol} for ${s(o)} ${T.symbol}`})}catch(e){console.warn(`Failed to format swap amounts:`,e)}}!a&&w&&T&&(a=r(`You successfully swapped {fromToken} for {toToken}`,{fromToken:w.symbol,toToken:T.symbol,defaultValue:`You successfully swapped ${w.symbol} for ${T.symbol}`})),e({type:`successful-operation`,props:{setCurrentContent:e,txId:t,title:n,description:a,onDone:()=>{d?f():e(`main`)},showSocialButtons:!0}})},[w,T,D,De,Ge,i?.address,e,r,d,f]),Xe=H(e=>{let t=typeof e==`string`?e:e.message;console.error(`Swap failed:`,t)},[w,T,D]),[Ze,Qe]=V.useState(!1);V.useEffect(()=>{if(Ke===`ready`){Qe(!1);return}Ze||(Ke===`success`&&Ge&&!Ge.reverted?(Qe(!0),Je()):Ke===`error`&&qe?Xe(qe?.reason||qe?.message||String(qe)):Ge?.reverted&&Xe(`Transaction reverted`))},[Ke,Ge,qe,Je,Xe,Ze]);let et=H(e=>{if(ee(e),e.symbol===`VET`&&!T){let e=x.find(e=>e.symbol===`B3TR`);if(!e)try{let t=k(l.type).b3trContractAddress;t&&(e=x.find(e=>o(e.address,t)))}catch(e){console.warn(`Failed to get B3TR address from config:`,e)}e&&E(e)}C(`main`)},[T,x,l.type]),nt=H(e=>{E(e),C(`main`)},[]),rt=H(e=>{(/^\d*\.?\d*$/.test(e)||e===``)&&te(e)},[]),it=H(()=>{w&&te(w.balance)},[w]),at=e=>{if(!e)return null;let t=s[e.symbol],n=p[e.symbol];return{symbol:e.symbol,logoComponent:t,logoUrl:n,balance:e.balance,value:e.valueInCurrency}},ot=at(w),st=at(T);return S===`select-from-token`?q(al,{setCurrentContent:e,onSelectToken:et,onBack:()=>C(`main`),showAllTokens:!1}):S===`select-quote`?q(ll,{quotes:Se,selectedQuote:De,toTokenAddress:T?.address??null,onSelectQuote:e=>{ue(e),C(`main`)},onBack:()=>C(`main`)}):S===`select-to-token`?q(al,{setCurrentContent:e,onSelectToken:nt,onBack:()=>C(`main`),showAllTokens:!0}):J(K,{children:[J(Z,{children:[q(L,{children:r(`Swap`)}),!d&&q(Ja,{onClick:()=>e(`main`)}),q(F,{})]}),q(tt,{maxW:`container.lg`,p:0,children:q(P,{children:J(z,{spacing:2,align:`stretch`,w:`full`,children:[J(A,{px:6,py:a.isConnectedWithPrivy?2:6,borderRadius:`xl`,bg:m,children:[q(R,{fontSize:`sm`,fontWeight:`medium`,color:v,mb:2,children:r(`From`)}),J(z,{align:`stretch`,spacing:2,children:[J(M,{justify:`space-between`,children:[q(dt,{placeholder:`0`,value:D,onChange:e=>rt(e.target.value),fontSize:`4xl`,fontWeight:`bold`,variant:`unstyled`,"data-testid":`swap-amount-input`,type:`number`,inputMode:`decimal`,color:ot&&D&&Number(D)>Number(ot.balance)?`red.500`:_}),ot?J(j,{onClick:()=>C(`select-from-token`),variant:`outline`,size:`sm`,borderRadius:`full`,px:6,color:v,borderColor:g,_hover:{bg:h,borderColor:g},leftIcon:ot.logoComponent?V.cloneElement(ot.logoComponent,{boxSize:`20px`,borderRadius:`full`}):ot.logoUrl?q(ut,{src:ot.logoUrl,alt:`${ot.symbol} logo`,boxSize:`20px`,borderRadius:`full`,fallback:q(A,{boxSize:`20px`,borderRadius:`full`,bg:`whiteAlpha.200`,display:`flex`,alignItems:`center`,justifyContent:`center`,children:q(R,{fontSize:`8px`,fontWeight:`bold`,color:_,children:ot.symbol.slice(0,3)})})}):void 0,children:[ot.symbol,q(N,{as:tr,boxSize:5,color:v})]}):J(j,{onClick:()=>C(`select-from-token`),variant:`outline`,size:`sm`,borderRadius:`full`,px:6,color:v,borderColor:g,_hover:{bg:h,borderColor:g,color:v},children:[r(`Select token`),q(N,{as:tr,boxSize:5,color:v})]})]}),ot&&J(M,{spacing:1,fontSize:`sm`,justifyContent:`space-between`,color:v,children:[q(M,{spacing:2,alignItems:`center`,children:ke>0&&J(R,{color:v,children:[`≈`,` `,no(ke,{currency:c})]})}),q(R,{cursor:`pointer`,_hover:{color:v,textDecoration:`underline`},onClick:it,noOfLines:1,overflow:`hidden`,textOverflow:`ellipsis`,children:r(`Swap all`,{defaultValue:`Swap all`})})]})]})]}),q(Ye,{position:`relative`,marginTop:`-20px`,marginBottom:`-20px`,marginX:`auto`,bg:m,borderRadius:`xl`,w:`40px`,h:`40px`,zIndex:2,cursor:!w||!T||Ce?`not-allowed`:`pointer`,onClick:!w||!T||Ce?void 0:be,opacity:!w||!T||Ce?.5:1,children:Ce?q(At,{size:`sm`}):q(N,{as:Gn,boxSize:5,color:v})}),J(A,{px:6,py:a.isConnectedWithPrivy?2:6,borderRadius:`xl`,bg:m,children:[q(R,{fontSize:`sm`,fontWeight:`medium`,color:v,mb:2,children:r(`To`)}),J(z,{align:`stretch`,spacing:2,children:[J(M,{justify:`space-between`,alignItems:`center`,children:[q(dt,{value:Number(Oe).toLocaleString(void 0,{maximumFractionDigits:Number(Oe)>1e4?0:2}),readOnly:!0,variant:`unstyled`,fontSize:`4xl`,fontWeight:`bold`,"data-testid":`swap-output-amount`,color:_}),st?J(j,{onClick:()=>C(`select-to-token`),variant:`outline`,size:`sm`,borderRadius:`full`,px:6,color:v,borderColor:g,_hover:{bg:h,borderColor:g},leftIcon:st.logoComponent?V.cloneElement(st.logoComponent,{boxSize:`20px`,borderRadius:`full`}):st.logoUrl?q(ut,{src:st.logoUrl,alt:`${st.symbol} logo`,boxSize:`20px`,borderRadius:`full`,fallback:q(A,{boxSize:`20px`,borderRadius:`full`,bg:`whiteAlpha.200`,display:`flex`,alignItems:`center`,justifyContent:`center`,children:q(R,{fontSize:`8px`,fontWeight:`bold`,color:_,children:st.symbol.slice(0,3)})})}):void 0,children:[st.symbol,q(N,{as:tr,boxSize:5,color:v})]}):J(j,{onClick:()=>C(`select-to-token`),variant:`outline`,size:`sm`,borderRadius:`full`,px:6,color:v,borderColor:g,_hover:{bg:h,borderColor:g,color:v},children:[r(`Select token`),q(N,{as:tr,boxSize:5,color:v})]})]}),st&&J(M,{spacing:1,fontSize:`sm`,justifyContent:`space-between`,color:v,children:[q(M,{spacing:2,alignItems:`center`,children:Ae>0&&J(R,{color:v,children:[`≈`,` `,no(Ae,{currency:c})]})}),q(A,{})]})]})]}),q($e,{in:ne&&!!De,animateOpacity:!0,children:J(z,{spacing:1,align:`stretch`,p:4,borderRadius:`xl`,bg:m,children:[De&&J(M,{justify:`space-between`,children:[J(R,{fontSize:`xs`,color:v,children:[r(`Source`),`:`]}),J(M,{spacing:1.5,cursor:`pointer`,onClick:()=>C(`select-quote`),_hover:{opacity:.8},alignItems:`center`,children:[De.aggregator?.getIcon(`12px`),q(R,{fontSize:`xs`,color:_,children:De.aggregatorName})]})]}),J(z,{align:`stretch`,spacing:2,children:[J(M,{justify:`space-between`,cursor:`pointer`,onClick:()=>oe(!ae),children:[J(R,{fontSize:`xs`,color:v,children:[r(`Slippage tolerance`),`:`]}),J(R,{fontSize:`xs`,fontWeight:`medium`,color:_,children:[O,`%`]})]}),q($e,{in:ae,animateOpacity:!0,children:q(z,{spacing:3,align:`stretch`,pt:2,children:J(M,{spacing:2,children:[q(j,{size:`sm`,variant:ye?`solid`:`outline`,colorScheme:ye?`blue`:`gray`,onClick:()=>{ie(1)},flex:`0 0 auto`,minW:`60px`,borderRadius:`md`,fontSize:`xs`,color:_,children:`Auto`}),q(j,{size:`sm`,variant:O===.5?`solid`:`outline`,colorScheme:O===.5?`blue`:`gray`,onClick:()=>{ie(.5)},flex:`0 0 auto`,minW:`60px`,borderRadius:`md`,fontSize:`xs`,color:_,children:`0.5%`}),q(j,{size:`sm`,variant:O===3?`solid`:`outline`,colorScheme:O===3?`blue`:`gray`,onClick:()=>{ie(3)},flex:`0 0 auto`,minW:`60px`,borderRadius:`md`,fontSize:`xs`,color:_,children:`3%`}),J(ft,{size:`sm`,flex:1,children:[q(dt,{value:se,onChange:e=>{let t=e.target.value;if((/^\d*\.?\d*$/.test(t)||t===``)&&(ce(t),t!==``)){let e=parseFloat(t);!isNaN(e)&&e>=0&&e<=100&&ie(e)}},placeholder:`1`,borderRadius:`md`,textAlign:`right`,pr:8,fontSize:`xs`,color:_}),q(mt,{width:`2rem`,pointerEvents:`none`,children:q(R,{fontSize:`2xs`,color:v,children:`%`})})]})]})})})]}),J(M,{justify:`space-between`,children:[J(R,{fontSize:`xs`,color:v,children:[r(`Gas fee`),`:`]}),q(R,{fontSize:`xs`,fontWeight:`medium`,color:_,children:Me>0?`${Me.toLocaleString(void 0,{maximumFractionDigits:2})} VTHO`:`-`})]})]})}),q(A,{minH:`24px`,display:`flex`,alignItems:`center`,justifyContent:`center`,children:De&&q(j,{variant:`ghost`,size:`xs`,onClick:()=>re(!ne),rightIcon:q(N,{color:y,_hover:{color:v},as:ne?Jn:Un}),fontSize:`xs`,fontWeight:`light`,color:y,_hover:{color:v},children:r(ne?`Show Less`:`Show More`)})}),he.length>0&&a.isConnectedWithPrivy&&q(Fp,{estimation:Pe,isLoading:Fe,isLoadingTransaction:Ue,onTokenChange:Be,clauses:he,userSelectedToken:pe})]})})}),q(I,{children:q(Mp,{buttonText:r(`Swap`),onConfirm:He,isSubmitting:Ue,isTxWaitingConfirmation:We,transactionPendingText:r(`Swapping...`),txReceipt:Ge,transactionError:qe,onError:e=>{Xe(e)},isDisabled:!w||!T||!D||Number(D)<=0||Ce||!De||De?.reverted===!0||!!(ot&&D&&Number(D)>Number(ot.balance))||ze,gasEstimationError:Ie,hasEnoughGasBalance:Ve,isLoadingGasEstimation:Fe,showGasEstimationError:!u?.delegatorUrl&&a.isConnectedWithPrivy,context:`transaction`})})]})},pl=({setCurrentContent:e,onBack:t=()=>e(`settings`),initialContentSource:n=`settings`})=>{let{t:r}=Y(),{isolatedView:i}=Xc(),a=B(`colors`,`vechain-kit-text-primary`),o=B(`colors`,`vechain-kit-text-secondary`),s=()=>{t()};return J(K,{children:[J(Z,{children:[q(L,{"data-testid":`modal-title`,children:r(`Choose your account name`)}),!i&&q(Ja,{onClick:s}),q(F,{})]}),q(P,{children:J(z,{spacing:6,align:`center`,py:8,children:[q(N,{as:Fr,boxSize:16,color:o}),J(z,{spacing:2,children:[q(R,{fontSize:`lg`,fontWeight:`500`,textAlign:`center`,color:a,children:r(`Finally say goodbye to 0x addresses`)}),q(R,{fontSize:`md`,color:o,textAlign:`center`,px:4,children:r(`Name your account to make it easier to exchange assets`)})]})]})}),q(I,{children:q(j,{variant:`vechainKitPrimary`,onClick:()=>e({type:`choose-name-search`,props:{name:``,setCurrentContent:e,initialContentSource:n}}),"data-testid":`choose-name-button`,children:r(`Choose name`)})})]})},ml=({domain:e,isCurrentDomain:t,onSelect:n})=>{let{connection:r}=Q(),{t:a}=Y(),o=Ws(e.name,r.network),s=B(`colors`,`vechain-kit-card`),c=B(`colors`,`vechain-kit-card-hover`),l=B(`colors`,`vechain-kit-border`),u=B(`colors`,`vechain-kit-text-primary`),f=B(`colors`,`vechain-kit-text-secondary`),p=B(`colors`,`vechain-kit-card`);return q(_t,{p:4,bg:s,borderRadius:`xl`,cursor:t?`default`:`pointer`,opacity:t?.7:1,border:`1px solid ${l}`,_hover:{bg:t?c:s,borderColor:l},onClick:()=>!t&&n(e.name),transition:`all 0.2s`,children:J(M,{spacing:3,align:`center`,children:[q(jp,{props:{width:`40px`,height:`40px`,src:o.image??i(e.name),alt:e.name}}),J(z,{align:`start`,spacing:0,flex:1,children:[q(R,{color:u,fontSize:`md`,fontWeight:`500`,children:d(e.name,24,0)}),t&&q(R,{fontSize:`sm`,color:f,children:a(`Current domain`)})]}),t&&q(Nt,{size:`sm`,bg:p,color:u,px:3,py:1,borderRadius:`full`,children:a(`Current`)})]})},e.name)},hl=({onUnset:e})=>{let t=B(`colors`,`vechain-kit-card`),n=B(`colors`,`vechain-kit-card-hover`),r=B(`colors`,`vechain-kit-border`),i=B(`colors`,`vechain-kit-text-primary`),a=B(`colors`,`vechain-kit-text-secondary`),o=B(`colors`,`vechain-kit-error`),{t:s}=Y();return q(_t,{p:4,bg:t,borderRadius:`xl`,cursor:`pointer`,opacity:1,border:`1px solid ${r}`,_hover:{bg:n,borderColor:r,color:`red.400`},onClick:e,transition:`all 0.2s`,role:`button`,"aria-label":s(`Unset current domain`),children:J(M,{spacing:3,align:`center`,children:[q(A,{width:`40px`,height:`40px`,borderRadius:`full`,display:`flex`,alignItems:`center`,justifyContent:`center`,bg:t,children:q(N,{as:Ir,fontSize:`18px`,color:o})}),J(z,{align:`start`,spacing:0,flex:1,children:[q(R,{color:i,fontSize:`md`,fontWeight:`500`,children:s(`Unset current domain`)}),q(R,{fontSize:`sm`,color:a,children:s(`Remove your current domain name`)})]})]})},`unset-domain-list-item`)},gl=({domains:e,onDomainSelect:t,onUnsetDomain:n,isLoading:r})=>{let{t:i}=Y(),{account:a}=Q(),o=B(`colors`,`vechain-kit-card`),s=B(`colors`,`vechain-kit-card-hover`),c=B(`colors`,`vechain-kit-text-primary`),l=B(`colors`,`vechain-kit-text-secondary`);return e.length===0||r?null:q(Ie,{allowToggle:!0,children:q(Re,{border:`none`,children:({isExpanded:u})=>J(K,{children:[J(Le,{bg:o,borderRadius:`xl`,_hover:{bg:s},opacity:r?.7:1,transition:`all 0.2s`,disabled:r,children:[q(A,{flex:`1`,textAlign:`left`,py:2,children:q(R,{fontWeight:`500`,color:c,children:r?i(`Loading your domains...`):`${i(`Your existing domains`)} (${e.length})`})}),q(N,{as:u?ir:tr,fontSize:`20px`,color:l})]}),q(ze,{pb:4,pt:2,children:J(gt,{spacing:2,children:[e.map(e=>q(ml,{domain:e,isCurrentDomain:e.name===a?.domain,onSelect:t},e.name)),a?.domain&&q(hl,{onUnset:n})]})})]})})})},_l=({name:e,setCurrentContent:t,initialContentSource:n=`settings`})=>{let{t:r}=Y(),{account:i}=Q(),{darkMode:a}=$(),{isolatedView:o}=Xc(),[s,c]=G(Ui(e)),[l,u]=G(null),[d,f]=G(!1),[p,m]=G(!1),[h,g]=G(!1),_=B(`colors`,`vechain-kit-error`),v=B(`colors`,`vechain-kit-success`),y=B(`colors`,`vechain-kit-text-secondary`),{data:b,isLoading:x}=mo(s),{data:S,isLoading:C}=uo(`${s}.veworld.vet`),{data:w,isLoading:ee}=Oo(s),{data:T,isLoading:E}=No(i?.address,``),D=x||C||ee;U(()=>{if(!h)return;let e=/[^a-zA-Z0-9-]|\s/.test(s);s.length<3?(u(r(`Name must be at least 3 characters long`)),m(!1),f(!1)):e?(u(r(`Only letters, numbers, and hyphens are allowed`)),m(!1),f(!1)):w?(u(r(`This domain is protected`)),m(!1),f(!1)):b?S?.address?.toLowerCase()===i?.address?.toLowerCase()?(u(null),m(!0),f(!0)):(u(r(`This domain is already taken`)),m(!1),f(!1)):x||(u(null),m(!0),f(!1))},[s,h,b,x,S,i?.address,w,p,D]);let te=()=>{p&&!l&&t({type:`choose-name-summary`,props:{fullDomain:s+`.veworld.vet`,isOwnDomain:d,setCurrentContent:t,initialContentSource:n}})},ne=e=>{let r=e.split(`.`);t({type:`choose-name-summary`,props:{fullDomain:e,domainType:r.length>2?`${r[1]}.${r[2]}`:`vet`,isOwnDomain:!0,setCurrentContent:t,initialContentSource:n}})},re=()=>{t({type:`choose-name-summary`,props:{fullDomain:``,domainType:``,isOwnDomain:!1,isUnsetting:!0,setCurrentContent:t,initialContentSource:n}})},O=()=>{t(n)};return J(K,{children:[J(Z,{children:[q(L,{"data-testid":`modal-title`,children:r(`Choose Name`)}),!o&&q(Ja,{onClick:O}),q(F,{})]}),q(P,{children:J(z,{spacing:4,align:`stretch`,children:[q(gl,{domains:T?.domains||[],onDomainSelect:ne,onUnsetDomain:re,isLoading:E}),J(ft,{size:`lg`,children:[q(dt,{placeholder:r(`Enter your name`),value:s,onChange:e=>{c(Ui(e.target.value)),h||g(!0)},paddingRight:`120px`,fontSize:`lg`,height:`60px`,bg:a?`#00000038`:`white`,border:`1px solid ${a?`#ffffff29`:`#ebebeb`}`,_hover:{border:`1px solid ${a?`#ffffff40`:`#e0e0e0`}`},_focus:{border:`1px solid ${a?`#ffffff60`:`#d0d0d0`}`,boxShadow:`none`},isInvalid:!!l,"data-testid":`domain-input`}),q(mt,{width:`auto`,paddingRight:`12px`,h:`full`,children:q(A,{mr:4,fontSize:`sm`,color:y,children:`.veworld.vet`})})]}),l&&h&&q(R,{color:_,fontSize:`sm`,"data-testid":`domain-availability-status`,children:l}),!l&&h&&s.length>=3&&q(R,{fontSize:`sm`,color:p?v:_,fontWeight:`500`,"data-testid":`domain-availability-status`,children:r(d?`YOU OWN THIS`:p?`AVAILABLE`:`UNAVAILABLE`)})]})}),q(I,{children:q(j,{variant:`vechainKitPrimary`,isDisabled:!p||!!l||w||D,onClick:te,"data-testid":`continue-button`,children:r(`Continue`)})})]})},vl=({setCurrentContent:e,fullDomain:t,domainType:n=`veworld.vet`,isOwnDomain:r,isUnsetting:i=!1,initialContentSource:a=`settings`})=>{let{t:o}=Y(),s=B(`colors`,`vechain-kit-text-primary`),{isolatedView:c,closeAccountModal:l}=Xc(),{account:u,connectedWallet:d,connection:f}=Q(),{data:p}=If(u?.address??``,d?.address??``,3),{open:m}=Id(),{preferences:h}=Tp(),{feeDelegation:g}=$(),_=e=>{console.error(`Transaction failed:`,e)},v=ts({onSuccess:()=>D()}),y=n.endsWith(`veworld.vet`),b=bo({subdomain:t.split(`.veworld.vet`)[0],domain:n,alreadyOwned:r,onSuccess:()=>D()}),x=wo({domain:!i&&!y?t:``,alreadyOwned:r,onSuccess:()=>D()}),{sendTransaction:S,txReceipt:C,error:w,isWaitingForWalletConfirmation:ee,isTransactionPending:T,clauses:E}=i?v:y?b:x,D=()=>{e({type:`successful-operation`,props:{setCurrentContent:e,txId:C?.meta.txID,title:o(i?`Domain unset`:`Domain set`),description:i?o(`Your domain has been unset successfully.`):o(`Your address has been successfully set to {{name}}`,{name:t}),onDone:()=>{c?l():e(a)}}})},te=async()=>{if(p){m();return}try{await S()}catch(e){console.error(`Transaction failed:`,e)}},ne=()=>{te()},re=()=>{e({type:`choose-name-search`,props:{setCurrentContent:e,name:t,initialContentSource:a}})},[O,ie]=V.useState(null),[ae,oe]=V.useState(null),se=h.availableGasTokens.length>0&&(f.isConnectedWithPrivy||f.isConnectedWithVeChain)&&!g?.delegatorUrl,{data:k,isLoading:ce,error:le,refetch:ue}=Ep({clauses:E(),tokens:O?[O]:h.availableGasTokens,enabled:se&&!!g?.genericDelegatorUrl}),de=k?.usedToken,fe=(ce||!k)&&f.isConnectedWithPrivy&&!g?.delegatorUrl,pe=V.useCallback(e=>{ie(e),oe(e),setTimeout(()=>ue(),100)},[ue]),me=!!de&&!le;return V.useEffect(()=>{le&&O&&ie(null)},[le,O]),J(K,{children:[J(Z,{children:[q(L,{"data-testid":`confirm-domain`,children:o(i?`Confirm Unset Domain`:`Confirm Name`)}),q(Ja,{onClick:re,isDisabled:T}),q(F,{isDisabled:T})]}),J(P,{children:[J(z,{spacing:4,w:`full`,textAlign:`center`,children:[q(R,{fontSize:`lg`,color:s,children:o(i?`Are you sure you want to unset your current domain?`:`Are you sure you want to set your domain name to`)}),!i&&q(R,{fontSize:`xl`,fontWeight:`bold`,color:s,"data-testid":`preconfirm-domain-val`,children:`${t}`})]}),f.isConnectedWithPrivy&&q(Fp,{estimation:k,isLoading:ce,isLoadingTransaction:T,onTokenChange:pe,clauses:E(),userSelectedToken:ae})]}),q(I,{gap:4,w:`full`,children:q(Mp,{transactionError:w,isSubmitting:T,isTxWaitingConfirmation:ee,onConfirm:te,onRetry:ne,transactionPendingText:o(i?`Unsetting current domain...`:`Claiming name...`),txReceipt:C,buttonText:o(`Confirm`),isDisabled:T||fe,onError:_,gasEstimationError:le,hasEnoughGasBalance:me,isLoadingGasEstimation:ce,showGasEstimationError:!g?.delegatorUrl&&f.isConnectedWithPrivy,context:`domain`})})]})},yl=()=>{let{t:e}=Y(),[t,n]=G(``),r=B(`colors`,`vechain-kit-card`),i=B(`colors`,`vechain-kit-text-secondary`),a=B(`colors`,`vechain-kit-text-tertiary`),o=B(`colors`,`vechain-kit-card`),s=B(`colors`,`vechain-kit-card-elevated`),c=[{question:e(`What is VeChain?`),answer:e(`VeChain, headquartered in San Marino, Europe, is a pioneering blockchain ecosystem and creator of VeChainThor, a world-class smart contract platform driving real-world blockchain adoption. Founded in 2015 by Sunny Lu, VeChain has consistently worked to deliver a transparent, efficient, scalable, and adaptable blockchain solution.`)},{question:e(`What is a wallet?`),answer:e(`A wallet is your gateway to the VeChain blockchain. It stores your private keys and allows you to securely manage your digital assets, send and receive tokens, and interact with decentralized applications. Think of it as your digital bank account for blockchain transactions.`)},{question:e(`What is a Smart Account?`),answer:e(`A Smart Account is a smart contract wallet that provides enhanced security and functionality. It allows for features like social recovery, transaction batching, and more.`)},{question:e(`How is my wallet secured?`),answer:e(`Your wallet security depends on how you access it. With self-custody options like the VeWorld extension, mobile app, or hardware wallet, you have complete control over your private keys. This extension itself has no access to your private keys. When logging in with social accounts or VeChain, your wallet is created and secured by Privy and managed by VeChain, providing an easier onboarding experience while maintaining security.`)},{question:e(`How do I backup my wallet?`),answer:e(`Backing up your wallet is crucial as you are the only one with access to your private keys. If something goes wrong, having your private key is the only way to recover your assets. How to backup depends on how you access your wallet: If using VeWorld, the backup option is available within the app. For social login users, you can find backup options in the Wallet section. If you're connected through VeChain or another ecosystem app, you'll need to visit the original website, log in, and access the Wallet section from there.`)},{question:e(`What is a network?`),answer:e(`A network in blockchain refers to the environment where transactions take place. VeChain has two main networks: Mainnet (the live network where real transactions occur) and Testnet (a testing environment for developers). The network you're connected to is displayed at the top of this modal.`)},{question:e(`What is a domain name?`),answer:e(`A domain name is a sort of nickname for your wallet address. It allows you to easily identify your wallet and interact with dApps using a human-readable name. For example, if your wallet address is 0x1234567890, your nickname could be "alice.vechain".`)},{question:e(`What is Privy?`),answer:e(`Privy builds user onboarding and embedded wallet infrastructure to enable better products built on crypto rails. This means embedding asset control within applications themselves to enable users, businesses or machines to use digital assets through seamless product experiences.`)},{question:e(`What is VeBetterDAO?`),answer:e(`VeBetterDAO is a decentralized organization on VeChain blockchain focused on sustainability. Members participate in the governance of the DAO using B3TR tokens for rewards and VOT3 for voting in proposals and weekly token allocation rounds.`)},{question:e(`What is an x2earn application?`),answer:e(`An X2Earn application in VeBetterDAO is a sustainable app that rewards users with B3TR tokens for eco-friendly actions. These apps must distribute B3TR, link user wallets, and provide proof of sustainable actions. They join VeBetterDAO through endorsement and participate in weekly token allocation rounds.`)},{question:e(`What is B3TR?`),answer:e(`B3TR is the incentive token of VeBetterDAO, built on VechainThor blockchain. It has a capped supply of 1 billion tokens, emitted weekly over 12 years. B3TR is used for rewards, governance, and backing VOT3 tokens 1:1. It supports sustainability applications and DAO treasury management.`)},{question:e(`What is VET?`),answer:e(`VET is the primary cryptocurrency of the VeChain network. It represents value and ownership in the VeChain ecosystem, similar to how stocks represent ownership in a company. Holding VET automatically generates VTHO, which is needed to pay for transactions on the network.`)},{question:e(`What is VTHO?`),answer:e(`VTHO (VeThor) is the energy or 'gas' token of the VeChain network. It's used to pay for transaction fees when interacting with the blockchain. VTHO is automatically generated by holding VET tokens, creating a two-token system that helps maintain network stability and manage transaction costs.`)},{question:e(`How do I send tokens?`),answer:e(`You can send tokens by clicking the send icon in the Quick Actions section. Enter the recipient's address or VeChain domain name, select the token, and specify the amount you want to send.`)},{question:e(`What is fee delegation?`),answer:e(`Fee delegation is a unique feature of VeChain that allows someone else (a delegator) to pay for your transaction fees. While many dApps and service providers act as delegators to make it easier for new users to get started, some transactions may still require you to pay fees using your own VTHO. Fees are necessary to prevent network spam and compensate the nodes that process and validate transactions on the blockchain. When paying fees yourself, you'll be able to select VTHO from your assets to cover the transaction cost.`)}].filter(e=>e.question.toLowerCase().includes(t.toLowerCase())||typeof e.answer==`string`&&e.answer.toLowerCase().includes(t.toLowerCase()));return J(z,{spacing:4,align:`stretch`,children:[J(ft,{size:`lg`,children:[q(dt,{placeholder:e(`Search FAQ`),bg:r,borderRadius:`xl`,height:`56px`,pl:12,value:t,onChange:e=>n(e.target.value)}),q(pt,{h:`56px`,w:`56px`,pl:4,children:q(kr,{color:a})})]}),c.length===0?J(z,{spacing:2,py:8,color:i,children:[q(N,{as:Pr,boxSize:12,opacity:.5}),q(R,{fontSize:`lg`,children:e(`No questions found`)}),q(R,{fontSize:`md`,children:e(`Try searching with a different term`)})]}):q(Ie,{allowMultiple:!0,children:c.map((e,t)=>q(Re,{border:`none`,mb:2,children:({isExpanded:t})=>J(K,{children:[J(Le,{bg:o,borderRadius:`xl`,color:i,_hover:{bg:s},children:[q(A,{flex:`1`,textAlign:`left`,py:2,children:q(R,{fontWeight:`500`,color:i,children:e.question})}),q(N,{as:t?ir:tr,fontSize:`20px`,opacity:.5})]}),q(ze,{pb:4,children:q(R,{fontSize:`sm`,color:i,opacity:.8,children:e.answer})})]})},t))})]})},bl=({onGoBack:e,showLanguageSelector:t=!0})=>{let{i18n:n,t:r}=Y(),{isolatedView:i}=Xc(),a=B(`colors`,`vechain-kit-card`),o=B(`colors`,`vechain-kit-border`),s=B(`colors`,`vechain-kit-border-hover`);return J(Ap,{children:[J(Z,{children:[q(L,{children:r(`Help`)}),!i&&q(Ja,{onClick:e}),q(F,{})]}),q(P,{w:`full`,children:J(z,{spacing:6,align:`stretch`,children:[t&&q(Ot,{borderRadius:`md`,size:`sm`,width:`auto`,value:n.language,onChange:e=>{n.changeLanguage(e.target.value)},bg:a,borderColor:o,_hover:{borderColor:s},children:va.map(e=>q(`option`,{value:e,children:ba[e]},e))}),q(j,{as:ht,href:`https://docs.vechainkit.vechain.org/`,isExternal:!0,variant:`vechainKitSecondary`,rightIcon:q(N,{as:fr}),children:r(`For developers`)}),q(yl,{})]})}),q(I,{pt:0})]})},xl=({setCurrentContent:e,initialContentSource:t=`profile`})=>{let{t:n}=Y(),{network:i}=$(),{account:a}=Q(),o=B(`colors`,`vechain-kit-text-primary`),s=B(`colors`,`vechain-kit-error`),c=B(`colors`,`vechain-kit-card`),l=Zt(null),u=Zt(null),[d,f]=G(!1),{onUpload:p}=sc({compressImage:!0}),[m,h]=G(null),[g,_]=G(null),v=!!a?.domain,[y,b]=G(null),[x,S]=G(``),[C,w]=G(``),{register:ee,watch:T,formState:{errors:E,isValid:D}}=Hi({defaultValues:{displayName:a?.metadata?.display||``,description:a?.metadata?.description||``},mode:`onChange`});U(()=>{if(a?.metadata){let e=a.metadata;S(e.display||``),w(e.description||``),b(a.image?a.image.replace(`ipfs://`,``):null),h(e=>e??a.image??null)}},[a,i.type]);let te=T(),ne=async e=>{let t=e.target.files?.[0];if(t)try{f(!0),m&&URL.revokeObjectURL(m),h(URL.createObjectURL(t));let e=await p(t);if(!e)throw Error(`Failed to compress image`);_(await r(e.file,t.name,i.type))}catch(e){console.error(`Error uploading image:`,e),h(null)}finally{f(!1)}};U(()=>()=>{m&&URL.revokeObjectURL(m)},[m]);let re=()=>{let e={};return g!==y&&g&&(e.avatarIpfsHash=g),te.displayName!==x&&(e.displayName=te.displayName),te.description!==C&&(e.description=te.description),e},O=W(()=>{let e=re();return Object.keys(e).length>0},[re]),ie=()=>{e({type:`account-customization-summary`,props:{setCurrentContent:e,changes:re(),onDoneRedirectContent:t}})},ae=()=>{e(t)};return J(A,{children:[J(Z,{children:[q(L,{"data-testid":`modal-title`,children:n(`Customization`)}),q(Ja,{onClick:ae}),q(F,{})]}),J(P,{children:[J(Ge,{variant:`vechainKitBase`,position:`relative`,overflow:`visible`,justifyContent:`center`,alignItems:`center`,children:[J(A,{cursor:v?`pointer`:`default`,pt:2,onClick:()=>v&&l.current?.click(),children:[q(jp,{wallet:a,props:{width:`100px`,height:`100px`,boxShadow:`0px 0px 3px 2px #00000024`,src:m??void 0}}),v&&q(N,{as:$n,position:`absolute`,top:`80px`,left:`60%`,bg:c,color:o,p:`1`,borderRadius:`full`,boxSize:`6`}),d&&q(A,{display:`flex`,alignItems:`center`,justifyContent:`center`,backgroundColor:`rgba(0, 0, 0, 0.5)`,borderRadius:`full`,children:q(R,{fontSize:`xs`,color:`white`,children:d?`Uploading...`:`Processing...`})})]}),q(Ke,{w:`full`,backgroundColor:`none`,border:`none`,children:J(z,{spacing:6,children:[!v&&q(qc,{}),q(Lc,{title:a?.domain??n(`Choose account name`),description:n(`Choose a unique .vet domain name for your account.`),onClick:()=>{a?.domain?e({type:`choose-name-search`,props:{name:``,setCurrentContent:e,initialContentSource:{type:`account-customization`,props:{setCurrentContent:e}}}}):e({type:`choose-name`,props:{setCurrentContent:e,initialContentSource:{type:`account-customization`,props:{setCurrentContent:e}},onBack:()=>e({type:`account-customization`,props:{setCurrentContent:e}})}})},leftIcon:Fr,rightIcon:rr,dataTestId:`set-domain-name-button`}),J(it,{isDisabled:!v,isInvalid:!!E.displayName,children:[q(at,{fontSize:`sm`,fontWeight:`medium`,color:o,children:n(`Display Name`)}),q(dt,{...ee(`displayName`,{maxLength:{value:25,message:n(`Display name must be less than 25 characters`)}}),placeholder:n(v?`Enter your display name`:`Set a domain first`),fontWeight:`medium`,color:o,"data-testid":`display-name-input`}),E.displayName&&q(R,{color:s,fontSize:`sm`,mt:1,fontWeight:`medium`,children:E.displayName.message})]}),J(it,{isDisabled:!v,isInvalid:!!E.description,children:[q(at,{fontSize:`sm`,fontWeight:`medium`,color:o,children:n(`Description`)}),q(Pt,{...ee(`description`,{maxLength:{value:100,message:n(`Description must be less than 100 characters`)}}),placeholder:n(`Eg: DevRel @ ENS Labs`),fontWeight:`medium`,color:o,"data-testid":`description-input`,minH:`50px`}),E.description&&q(R,{color:s,mt:1,fontSize:`sm`,fontWeight:`medium`,children:E.description.message})]})]})})]}),q(`input`,{type:`file`,ref:l,hidden:!0,accept:`image/*`,onChange:async e=>await ne(e)}),q(`input`,{type:`file`,ref:u,hidden:!0,accept:`image/*`,onChange:async e=>{e.preventDefault()}})]}),q(I,{w:`full`,children:q(j,{variant:`vechainKitPrimary`,onClick:ie,isDisabled:!v||!O||!D,isLoading:d,loadingText:n(`Preparing changes...`),"data-testid":`save-changes-button`,children:n(`Save Changes`)})})]})},Sl=({setCurrentContent:e,changes:t,onDoneRedirectContent:n})=>{let{t:r}=Y(),{darkMode:i,network:a,feeDelegation:o}=$(),{account:s,connectedWallet:c,connection:l}=Q(),{preferences:u}=Tp(),{data:d}=If(s?.address??``,c?.address??``,3),{open:f}=Id(),{handleSubmit:p}=Hi({defaultValues:{...t,avatarIpfsHash:t.avatarIpfsHash??void 0}}),m=s?.domain??``,{data:h}=Wo(m),g=zn(),{sendTransaction:_,txReceipt:v,error:y,isWaitingForWalletConfirmation:b,isTransactionPending:S,clauses:C}=Ho({resolverAddress:h,signerAccountAddress:s?.address??``,onSuccess:async()=>{e({type:`successful-operation`,props:{setCurrentContent:e,txId:v?.meta.txID,title:r(`Profile Updated`),description:r(`Your changes have been saved successfully.`),onDone:()=>{e(n)}}});try{await pe()}catch(e){console.error(`Error refreshing data:`,e)}},onError:e=>{console.error(`Error updating text record:`,e)}}),w=W(()=>{let e=s?.domain??``,n={displayName:`display`,description:`description`,twitter:`com.x`,website:`url`,email:`email`,avatarIpfsHash:`avatar`};return Object.entries(t).filter(e=>e[1]!==void 0&&e[1]!==null).map(([t,r])=>({domain:e,key:n[t],value:t===`avatarIpfsHash`?`ipfs://${r}`:r}))},[t,s?.domain]),ee=W(()=>{try{return!h||w.length===0||!C?[]:C(w)}catch(e){return console.error(`Error building clauses:`,e),[]}},[w,C,h]),[T,E]=V.useState(null),[D,te]=V.useState(null),ne=u.availableGasTokens.length>0&&(l.isConnectedWithPrivy||l.isConnectedWithVeChain)&&!o?.delegatorUrl,{data:re,isLoading:O,error:ie,refetch:ae}=Ep({clauses:ee,tokens:T?[T]:u.availableGasTokens,enabled:ne&&!!o?.genericDelegatorUrl}),oe=re?.usedToken,se=(O||!re)&&l.isConnectedWithPrivy&&!o?.delegatorUrl,k=V.useCallback(e=>{E(e),te(e),setTimeout(()=>ae(),100)},[ae]),ce=!!oe&&!ie;V.useEffect(()=>{ie&&T&&E(null)},[ie,T]);let le=async()=>{if(d){f();return}try{w.length>0&&await _(w)}catch(e){console.error(`Error saving changes:`,e)}},ue=(e,t)=>t?.trim()?J(z,{align:`flex-start`,w:`full`,spacing:1,children:[q(R,{fontSize:`sm`,color:i?`whiteAlpha.600`:`blackAlpha.600`,children:e}),q(R,{fontSize:`md`,children:t})]}):null,de=()=>{p(le)()},fe=()=>{e({type:`account-customization`,props:{setCurrentContent:e}})},pe=async()=>{t.avatarIpfsHash&&(g.setQueryData(Po(m,a.type),x(`ipfs://`+t.avatarIpfsHash,a.type)),g.setQueryData(Go(s?.address??``),x(`ipfs://`+t.avatarIpfsHash,a.type))),await g.invalidateQueries({queryKey:Ro(m,a.type)}),await g.refetchQueries({queryKey:Ro(m,a.type)})};return J(A,{as:`form`,onSubmit:p(le),children:[J(Z,{children:[q(L,{children:r(`Confirm Changes`)}),q(Ja,{isDisabled:S,onClick:fe}),q(F,{isDisabled:S})]}),J(P,{children:[J(z,{spacing:4,align:`stretch`,children:[t.avatarIpfsHash&&J(z,{align:`flex-start`,w:`full`,spacing:1,children:[q(R,{fontSize:`sm`,color:i?`whiteAlpha.600`:`blackAlpha.600`,children:r(`Profile Image`)}),q(R,{fontSize:`md`,children:r(`New image selected`)})]}),t.displayName&&ue(r(`Display Name`),t.displayName),t.description&&ue(r(`Description`),t.description),t.twitter&&ue(r(`Twitter`),t.twitter),t.website&&ue(r(`Website`),t.website),t.email&&ue(r(`Email`),t.email)]}),l.isConnectedWithPrivy&&q(Fp,{estimation:re,isLoading:O,isLoadingTransaction:S,onTokenChange:k,clauses:ee,userSelectedToken:D})]}),q(I,{gap:4,w:`full`,children:q(Mp,{transactionError:y,isSubmitting:S,isTxWaitingConfirmation:b,onConfirm:p(le),onRetry:de,transactionPendingText:r(`Saving changes...`),txReceipt:v,buttonText:r(`Confirm`),isDisabled:S||se,gasEstimationError:ie,hasEnoughGasBalance:ce,isLoadingGasEstimation:O,showGasEstimationError:!o?.delegatorUrl&&l.isConnectedWithPrivy,context:`customization`})})]})},Cl=({onEditClick:e,address:t,showHeader:n=!0,onLogout:r,showLinks:a=!0,showDescription:o=!0,showDisplayName:s=!0,showEdit:c=!0,style:l})=>{let{t:u}=Y(),{account:d,disconnect:f}=Q(),{network:p}=$(),{openAccountModal:m,closeAccountModal:h}=ad(),g=B(`colors`,`vechain-kit-text-primary`),_=B(`colors`,`vechain-kit-text-secondary`),v=Ws(t,p.type),y=i(t),b=t===d?.address,x=v?.records?.url||v?.records?.[`com.x`]||v?.records?.email;return J(Ge,{variant:`vechainKitBase`,...l?.card,children:[q(A,{p:0,backgroundSize:`100% !important`,backgroundPosition:`center`,position:`relative`,h:`80px`,background:n?`no-repeat url('${y}')`:`none`,w:`100%`,borderRadius:`14px 14px 0 0`}),q(A,{position:`absolute`,top:`30px`,left:`50%`,transform:`translateX(-50%)`,children:q(jp,{wallet:{address:t,domain:v?.domain,image:v?.image,isLoadingMetadata:v?.isLoading,metadata:v?.records},props:{width:`120px`,height:`120px`}})}),q(Ke,{mt:`60px`,backgroundColor:`none`,border:`none`,...l?.body,children:J(z,{w:`full`,spacing:2,children:[s&&v?.records?.display&&q(R,{fontSize:`xl`,color:g,fontWeight:`bold`,w:`full`,textAlign:`center`,mt:2,"data-testid":`display-name-val`,children:v?.records?.display}),o&&v?.records?.description&&q(R,{fontSize:`sm`,color:_,w:`full`,textAlign:`center`,"data-testid":`description-val`,children:v?.records?.description}),a&&x&&J(M,{w:`full`,justify:`center`,spacing:5,mt:4,children:[v?.records?.email&&q(ht,{href:`mailto:${v?.records?.email}`,target:`_blank`,"data-testid":`mail-link`,children:q(N,{as:Sr,color:g})}),v?.records?.url&&q(ht,{href:v?.records?.url,target:`_blank`,"data-testid":`website-link`,children:q(N,{as:_r,color:g})}),v?.records?.[`com.x`]&&q(ht,{href:`https://x.com/${v?.records?.[`com.x`]}`,target:`_blank`,"data-testid":`twitter-link`,children:q(N,{as:Ki,color:g})})]}),q(Ya,{wallet:{address:t,domain:v?.domain,image:v?.image,isLoadingMetadata:v?.isLoading,metadata:v?.records},style:{mt:4}})]})}),b&&c&&q(qe,{justify:`space-between`,...l?.footer,children:J(z,{w:`full`,justify:`space-between`,spacing:4,children:[q(nt,{}),J(M,{w:`full`,justify:`space-between`,children:[q(j,{size:`md`,width:`full`,height:`40px`,variant:`ghost`,leftIcon:q(N,{as:wr}),onClick:e??(()=>{m({type:`account-customization`,props:{setCurrentContent:()=>h()}})}),"data-testid":`customize-button`,children:u(`Customize`)}),q(j,{size:`md`,width:`full`,height:`40px`,variant:`ghost`,leftIcon:q(N,{as:xr}),colorScheme:`red`,onClick:r??(()=>{m({type:`disconnect-confirm`,props:{onDisconnect:()=>{f(),h()},onBack:()=>h()}})}),"data-testid":`logout-button`,children:u(`Logout`)})]})]})})]})},wl=({setCurrentContent:e,onLogoutSuccess:t})=>{let{t:n}=Y(),{isolatedView:r}=Xc(),{account:i,disconnect:a}=Q();return J(A,{children:[J(Z,{children:[q(L,{"data-testid":`modal-title`,children:n(`Profile`)}),!r&&q(Ja,{onClick:()=>e(`main`)}),q(F,{})]}),q(P,{w:`full`,children:J(z,{w:`full`,spacing:2,children:[!i?.domain&&q(Gc,{setCurrentContent:e}),q(Cl,{onEditClick:()=>{e({type:`account-customization`,props:{setCurrentContent:e,initialContentSource:`profile`}})},address:i?.address??``,showHeader:!1,style:{card:{bg:`transparent`,px:0},footer:{px:0}},onLogout:()=>{e?.({type:`disconnect-confirm`,props:{onDisconnect:()=>{a(),t?.()},onBack:()=>e?.(`profile`)}})}})]})}),q(I,{pt:0})]})},Tl=({setCurrentContent:e,handleClose:t,initialContent:n=`access-and-security`})=>{let{t:r}=Y(),{smartAccount:i,connectedWallet:a}=Q(),{data:o}=If(i?.address??``,a?.address??``,3),{sendTransaction:s,isTransactionPending:c,isWaitingForWalletConfirmation:l,error:u,txReceipt:d}=Vf({smartAccountAddress:i?.address??``,targetVersion:3,onSuccess:()=>{e({type:`successful-operation`,props:{setCurrentContent:e,txId:d?.meta.txID,title:r(`Upgrade Successful!`),description:r(`Your account has been successfully upgraded to the latest version. You can now enjoy a better user experience, lower gas costs, and enhanced security.`),onDone:()=>{t?t():e(n)},showSocialButtons:!1}})},onError:()=>{console.error(`Error upgrading Smart Account`)}});return J(K,{children:[J(Z,{children:[q(L,{children:r(`Account upgrade required`)}),q(Ja,{onClick:()=>{e(n)}}),q(F,{})]}),q(P,{children:J(z,{spacing:10,align:`stretch`,children:[q(R,{fontSize:`sm`,textAlign:`center`,children:r(o?`Your smart account needs to be upgraded to the latest version (v3).`:`Your smart account is already upgraded to this version.`)}),J(M,{align:`center`,justifyContent:`space-evenly`,rounded:`md`,children:[J(A,{position:`relative`,display:`inline-block`,children:[q(Qe,{size:`60px`,bg:`gray.200`,children:q(ut,{borderRadius:`full`,src:i?.image,alt:r(`Profile Picture`),w:`100%`,h:`100%`,objectFit:`cover`})}),q(ct,{position:`absolute`,top:`-5`,right:`-5`,color:`#D23F63`,fontSize:`28px`,children:`v1`})]}),q(N,{as:qn,color:`#3DBA67`}),J(A,{position:`relative`,display:`inline-block`,children:[q(Qe,{size:`60px`,bg:`gray.200`,children:q(ut,{borderRadius:`full`,src:i?.image,alt:r(`Profile Picture`),w:`100%`,h:`100%`,objectFit:`cover`})}),q(ct,{position:`absolute`,top:`-5`,right:`-5`,color:`#3DBA67`,fontSize:`28px`,children:`v3`})]})]}),J(Be,{status:`info`,borderRadius:`md`,children:[q(He,{}),J(A,{children:[q(Ue,{fontSize:`sm`,children:r(`Benefits of this upgrade:`)}),q(Ve,{fontSize:`xs`,children:J(z,{align:`start`,spacing:0,mt:1,children:[J(R,{fontSize:`xs`,lineHeight:`1.2`,children:[`• `,r(`Improved security features`)]}),J(R,{fontSize:`xs`,children:[`• `,r(`Better transaction handling`)]}),J(R,{fontSize:`xs`,children:[`•`,` `,r(`Enhanced compatibility with dApps`)]}),J(R,{fontSize:`xs`,children:[`•`,` `,r(`Reduced gas costs for operations`)]})]})})]})]})]})}),q(I,{justifyContent:`center`,children:J(z,{spacing:3,w:`full`,children:[q(Mp,{buttonText:r(o?`Upgrade account`:`Account already upgraded`),onConfirm:async()=>{try{await s()}catch(e){console.error(`Failed to upgrade Smart Account:`,e)}},isTxWaitingConfirmation:l,isSubmitting:c,transactionPendingText:r(`Upgrading...`),txReceipt:d,transactionError:u,isDisabled:!o}),q(j,{mt:2,variant:`link`,onClick:()=>{t?t():e(n)},isDisabled:c,children:r(o?`Close and do this later`:`Close`)})]})})]})},El=({setCurrentContent:e})=>{let{account:t}=Q(),{sortedTokens:n}=ds({address:t?.address}),{allowCustomTokens:r,darkMode:i}=$(),{currentCurrency:a}=us(),o=B(`colors`,`vechain-kit-text-tertiary`),{t:s}=Y(),{isolatedView:c}=Xc(),[l,u]=G(``),d=t=>{e({type:`send-token`,props:{setCurrentContent:e,preselectedToken:t,onBack:()=>e(`assets`)}})},f=n.filter(({symbol:e})=>e.toLowerCase().includes(l.toLowerCase()));return J(K,{children:[J(Z,{children:[q(L,{children:s(`Assets`)}),!c&&q(Ja,{onClick:()=>e(`main`)}),q(F,{})]}),J(tt,{h:[`540px`,`auto`],p:0,children:[J(P,{children:[J(ft,{size:`lg`,children:[q(dt,{placeholder:`Search token`,bg:i?`#00000038`:`gray.50`,borderRadius:`xl`,height:`56px`,pl:12,value:l,onChange:e=>u(e.target.value),"data-testid":`search-token-input`}),q(pt,{h:`56px`,w:`56px`,pl:4,children:q(kr,{color:o})})]}),q(z,{spacing:2,align:`stretch`,mt:2,children:f.map(e=>{let t=Number(e.balance)>0;return q(ro,{symbol:e.symbol,amount:Number(e.balance),currencyValue:e.valueInCurrency,currentCurrency:a,onClick:()=>d(e),isDisabled:!t},e.address)})})]}),q(I,{children:r&&q(j,{variant:`vechainKitSecondary`,leftIcon:q(N,{as:wr,boxSize:4}),onClick:()=>e(`add-custom-token`),children:s(`Manage Custom Tokens`)})})]})]})},Dl=({setCurrentContent:e})=>{let{t}=Y(),n=B(`colors`,`vechain-kit-text-primary`),r=B(`colors`,`vechain-kit-text-secondary`),i=B(`colors`,`vechain-kit-card`),a=B(`colors`,`vechain-kit-overlay`),{addToken:o,removeToken:s,isTokenIncluded:c,isDefaultToken:u,customTokens:d}=bs(),{register:f,setError:m,setValue:h,formState:{errors:g,isValid:_},handleSubmit:v}=Hi({defaultValues:{newTokenAddress:``},mode:`onChange`}),y=async e=>{if(e.newTokenAddress){if(c(e.newTokenAddress)||u(e.newTokenAddress))return m(`newTokenAddress`,{type:`manual`,message:t(`Token already added`)});try{await o(e.newTokenAddress),h(`newTokenAddress`,``)}catch(e){console.error(`Error adding token 2:`,e),m(`newTokenAddress`,{type:`manual`,message:t(`Invalid token address`)})}}};return J(K,{children:[J(Z,{children:[q(L,{children:t(`Manage Custom Tokens`)}),q(Ja,{onClick:()=>e(`assets`)}),q(F,{})]}),q(P,{children:J(z,{spacing:4,align:`stretch`,position:`relative`,children:[q(A,{p:6,borderRadius:`xl`,bg:i,children:q(z,{align:`stretch`,spacing:2,children:J(it,{isInvalid:!!g.newTokenAddress,children:[q(at,{fontSize:`sm`,fontWeight:`medium`,color:n,children:t(`Token Contract Address`)}),q(dt,{...f(`newTokenAddress`,{required:t(`Address is required`),pattern:{value:/^0x[a-fA-F0-9]{40}$/,message:t(`Please enter a valid contract address`)},validate:e=>/^0x[a-fA-F0-9]{40}$/.test(e)||t(`Invalid contract address`)}),onChange:e=>{let t=e.target.value.trim();e.target.value=t,h(`newTokenAddress`,t,{shouldValidate:!0})},placeholder:`0x...`,variant:`outline`,fontSize:`md`,fontWeight:`medium`}),g.newTokenAddress&&q(R,{color:`#ef4444`,fontSize:`sm`,children:g.newTokenAddress.message})]})})}),d.length>0&&J(A,{p:4,borderRadius:`xl`,bg:a,children:[q(R,{fontSize:`sm`,fontWeight:`medium`,mb:2,children:t(`Existing Custom Tokens`)}),q(z,{align:`stretch`,spacing:2,children:d.map(e=>J(M,{justify:`space-between`,fontSize:`sm`,p:2,borderRadius:`md`,bg:i,children:[J(M,{children:[q(ut,{src:p[e?.symbol],alt:`${e.symbol} logo`,boxSize:`20px`,borderRadius:`full`,fallback:q(A,{boxSize:`20px`,borderRadius:`full`,bg:`whiteAlpha.200`,display:`flex`,alignItems:`center`,justifyContent:`center`,children:q(R,{fontSize:`8px`,fontWeight:`bold`,color:n,children:e.symbol?.slice(0,3)})})}),q(R,{fontWeight:`medium`,color:n,children:e.symbol??`Unknown`})]}),q(R,{color:r,children:l(e.address??``,4,4)}),q(j,{size:`sm`,variant:`ghost`,color:n,borderRadius:`md`,p:2,onClick:()=>s(e.address),children:q(Ir,{size:16,color:n})})]},e.address))})]})]})}),q(I,{children:q(j,{variant:`vechainKitPrimary`,isDisabled:!_,onClick:v(y),children:t(`Add Token`)})})]})},Ol=({setCurrentContent:e})=>{let{t}=Y(),{darkMode:n}=$(),{isolatedView:r}=Xc();return J(K,{children:[J(Z,{children:[q(L,{children:t(`Bridge`)}),!r&&q(Ja,{onClick:()=>e(`main`)}),q(F,{})]}),q(tt,{maxW:`container.lg`,children:q(P,{children:J(z,{spacing:6,align:`center`,w:`full`,children:[q(Oe,{isDark:n,borderRadius:`xl`}),q(R,{fontSize:`sm`,textAlign:`center`,children:t(`Exchange your digital assets between VeChain and other blockchain networks easily and securely. Swaps are executed through partners that leverage both decentralized and centralized exchanges to convert tokens.`)})]})})}),q(I,{children:J(j,{variant:`vechainKitSecondary`,onClick:()=>{window.open(`https://swap.vechain.energy/`,`_blank`)},children:[t(`Launch vechain.energy`),q(N,{as:fr,ml:2})]})})]})},kl=({setCurrentContent:e})=>{let{t}=Y(),{currentCurrency:n,changeCurrency:r,allCurrencies:i}=us();U(()=>{h(`settings-currency-visited`,`true`)},[]);let a=e=>J(j,{w:`full`,variant:`ghost`,justifyContent:`space-between`,onClick:()=>r(e),py:6,px:4,children:[J(M,{spacing:3,children:[q(R,{fontSize:`xl`,children:c[e]}),q(R,{children:e.toUpperCase()})]}),n===e&&q(N,{as:er,boxSize:5,color:`blue.500`})]},e);return J(Ap,{children:[J(Z,{children:[q(L,{children:t(`Select currency`)}),q(Ja,{onClick:()=>e(`general-settings`)}),q(F,{})]}),q(P,{w:`full`,children:q(z,{justify:`center`,spacing:3,align:`flex-start`,w:`full`,children:i.map(e=>a(e))})}),q(I,{pt:0})]})},Al=({setCurrentContent:e})=>{let{connection:t}=Q(),{t:n}=Y(),{feeDelegation:r}=$(),i=B(`colors`,`vechain-kit-text-secondary`);return J(Ap,{children:[J(Z,{children:[q(L,{children:n(`General`)}),q(Ja,{onClick:()=>e(`settings`)}),q(F,{})]}),q(P,{w:`full`,children:J(z,{justify:`center`,spacing:3,align:`flex-start`,w:`full`,children:[q(z,{w:`full`,justifyContent:`center`,spacing:3,mb:3,children:q(R,{fontSize:`sm`,color:i,textAlign:`center`,children:n(`Manage your preferences for currency, language, and appearance.`)})}),J(z,{w:`full`,justifyContent:`center`,spacing:0,children:[q(Lc,{title:n(`Currency`),style:{borderBottomRadius:`0px`},onClick:()=>{e(`change-currency`)},leftIcon:ur,rightIcon:rr}),q(Lc,{title:n(`Language`),style:{borderTopRadius:`0px`,...t.isConnectedWithPrivy?{borderBottomRadius:`0px`}:{}},onClick:()=>{e(`change-language`)},leftIcon:br,rightIcon:rr}),t.isConnectedWithPrivy&&!r?.delegatorUrl&&q(Lc,{title:n(`Gas Token Preferences`),style:{borderTopRadius:`0px`},onClick:()=>{e(`gas-token-settings`)},leftIcon:mr,rightIcon:rr})]}),q(Lc,{title:n(`Terms and Policies`),onClick:()=>{e({type:`terms-and-privacy`,props:{onGoBack:()=>e(`settings`)}})},leftIcon:Mr,rightIcon:rr})]})}),q(I,{pt:0})]})},jl=({setCurrentContent:e})=>{let{t,i18n:n}=Y(),r=e=>{n.changeLanguage(e)},i=e=>J(j,{w:`full`,variant:`ghost`,justifyContent:`space-between`,onClick:()=>r(e),py:6,px:4,children:[q(R,{children:ba[e]}),n.language===e&&q(N,{as:er,boxSize:5,color:`blue.500`})]},e);return J(Ap,{children:[J(Z,{children:[q(L,{children:t(`Select language`)}),q(Ja,{onClick:()=>e(`general-settings`)}),q(F,{})]}),q(P,{w:`full`,children:q(z,{justify:`center`,spacing:3,align:`flex-start`,w:`full`,children:va.map(e=>i(e))})}),q(I,{pt:0})]})},Ml=({setCurrentContent:e})=>{let{t}=Y();return J(Ap,{children:[J(Z,{children:[q(L,{children:t(`General`)}),q(Ja,{onClick:()=>e(`general-settings`)}),q(F,{})]}),q(P,{w:`full`,children:J(z,{justify:`center`,spacing:3,align:`flex-start`,w:`full`,children:[q(z,{w:`full`,justifyContent:`center`,spacing:3,mb:3,children:q(R,{fontSize:`sm`,opacity:.5,textAlign:`center`,children:t(`Customize the appearance of your wallet.`)})}),q(z,{w:`full`,justifyContent:`center`,spacing:0})]})}),q(I,{pt:0})]})},Nl=({token:e,index:t,isExcluded:n,onToggleExclusion:r,onDragStart:i,onDragOver:a,onDrop:o,onTouchStart:s,onTouchMove:c,onTouchEnd:l,isDragging:u,isDraggedOver:d})=>{let p=f[e],{darkMode:m}=$(),h=B(`colors`,`vechain-kit-text-primary`),g=B(`colors`,`vechain-kit-text-secondary`),_=B(`colors`,`vechain-kit-card`);return q(A,{bg:m?`#ffffff0a`:`blackAlpha.50`,borderRadius:`md`,border:`1px`,borderColor:u?m?`blue.500`:`blue.300`:d?m?`blue.400`:`blue.200`:_,p:3,mb:2,opacity:u||n?.5:1,cursor:`move`,transition:`background-color 0.2s ease, border-color 0.2s ease`,draggable:!0,onDragStart:()=>i(t),onDragOver:e=>{e.preventDefault(),a(t)},onDrop:()=>o(t),onTouchStart:e=>s(t,e),onTouchMove:c,onTouchEnd:l,_hover:{backgroundColor:m?`#ffffff12`:`blackAlpha.200`},children:J(M,{justify:`space-between`,children:[J(M,{opacity:n?.5:1,children:[q(A,{cursor:`grab`,_active:{cursor:`grabbing`},pointerEvents:`none`,children:q(N,{as:vr,color:g})}),J(z,{align:`start`,spacing:0,children:[q(R,{fontWeight:`medium`,color:h,children:p.name}),q(R,{fontSize:`sm`,color:g,children:p.description})]})]}),q(Mt,{isChecked:!n,onChange:()=>r(e),colorScheme:`blue`,size:`sm`})]})})},Pl=({tokens:e,excludedTokens:t,onReorder:n,onToggleExclusion:r})=>{let[i,a]=G(null),[o,s]=G(null),c=Zt([]),l=Zt(0),u=e=>{a(e)},d=e=>{s(e)},f=t=>{if(i===null||i===t){a(null),s(null);return}let r=[...e],o=r[i];r.splice(i,1),r.splice(t,0,o),n(r),a(null),s(null)},p=(e,t)=>{l.current=t.touches[0].clientY,a(e)},m=e=>{if(i===null)return;let t=e.touches[0].clientY;for(let e=0;e<c.current.length;e++){let n=c.current[e];if(!n)continue;let r=n.getBoundingClientRect();if(t>=r.top&&t<=r.bottom){s(e);break}}},h=()=>{if(i!==null&&o!==null&&i!==o){let t=[...e],r=t[i];t.splice(i,1),t.splice(o,0,r),n(t)}a(null),s(null),l.current=0};return q(A,{w:`full`,children:e.map((e,n)=>q(A,{ref:e=>{c.current[n]=e},children:q(Nl,{token:e,index:n,isExcluded:t.includes(e),onToggleExclusion:r,onDragStart:u,onDragOver:d,onDrop:f,onTouchStart:p,onTouchMove:m,onTouchEnd:h,isDragging:i===n,isDraggedOver:o===n})},e))})},Fl=({setCurrentContent:e})=>{let{t}=Y(),{preferences:n,reorderTokenPriority:r,toggleTokenExclusion:i}=Tp(),a=B(`colors`,`vechain-kit-text-primary`),o=B(`colors`,`vechain-kit-text-secondary`),s=H(e=>{r(e)},[r]);return J(Ap,{children:[J(Z,{children:[q(L,{children:t(`Gas Token Preferences`)}),q(Ja,{onClick:()=>e(`general-settings`)}),q(F,{})]}),q(P,{w:`full`,children:J(z,{justify:`center`,spacing:6,align:`flex-start`,w:`full`,children:[q(z,{w:`full`,justifyContent:`center`,spacing:3,mb:3,children:q(R,{fontSize:`sm`,color:o,textAlign:`center`,children:t(`Choose which tokens to use for transaction fees when the app is not covering them.`)})}),n.availableGasTokens.length===0&&J(Be,{status:`warning`,borderRadius:`md`,children:[q(He,{}),q(Ve,{fontSize:`sm`,color:o,children:t(`You must enable at least one token to perform transactions. Without any enabled tokens, you will not be able to pay for gas fees.`)})]}),J(z,{w:`full`,align:`start`,spacing:3,children:[q(R,{fontSize:`md`,fontWeight:`semibold`,color:a,children:t(`Token Priority Order`)}),q(R,{fontSize:`sm`,color:o,children:t(`Drag to reorder. The system will automatically use the highest priority token with sufficient balance.`)}),q(Pl,{tokens:n.tokenPriority,excludedTokens:n.excludedTokens,onReorder:s,onToggleExclusion:i})]})]})})]})},Il=({title:e,description:t,icon:n})=>{let r=B(`colors`,`vechain-kit-text-secondary`),i=B(`colors`,`vechain-kit-text-primary`);return J(z,{spacing:6,align:`center`,py:8,children:[q(N,{as:n,boxSize:16,color:r}),J(z,{spacing:2,children:[q(R,{fontSize:`lg`,fontWeight:`500`,textAlign:`center`,color:i,children:e}),q(R,{fontSize:`md`,color:r,textAlign:`center`,px:4,children:t})]})]})},Ll=(e,t=`en-US`)=>new Intl.DateTimeFormat(t,{month:`short`,day:`numeric`}).format(new Date(e)),Rl=({document:e})=>{let{t}=Y(),n=B(`colors`,`vechain-kit-text-secondary`),r=e.documentSource===m.VECHAIN_KIT&&e.documentType===se.TERMS;return J(M,{children:[J(Nt,{size:`sm`,borderRadius:`full`,color:n,children:[`v`,e.version]}),q(R,{fontSize:`xs`,cursor:`pointer`,color:n,onClick:()=>{window.open(e.url,`_blank`)},_hover:{textDecoration:`underline`},children:r?t(`'{{policyName}}' on connect`,{policyName:e.displayName??t(`Vechain Kit Policy`)}):t(`'{{policyName}}' on {{date}}`,{policyName:e.displayName??t(`Policy`),date:Ll(e.timestamp)})})]})},zl=({title:e,description:t,documents:n,bg:r,hoverBg:i,currentPolicy:a})=>{let{t:o}=Y(),s=B(`colors`,`vechain-kit-text-primary`),c=B(`colors`,`vechain-kit-text-secondary`),l=n?.length>0,u=n?.find(e=>e.id===a?.id);return l?q(Re,{border:`none`,mb:3,children:({isExpanded:l})=>J(K,{children:[J(Le,{bg:r,borderRadius:`xl`,_hover:{bg:i},children:[J(z,{w:`full`,align:`flex-start`,textAlign:`left`,children:[q(R,{fontWeight:`700`,color:s,children:e}),q(R,{fontSize:`xs`,color:c,children:t})]}),q(N,{as:l?ir:tr,fontSize:`20px`,color:c})]}),q(ze,{pb:4,pt:3,children:J(z,{align:`stretch`,spacing:4,children:[u?.id?J(M,{w:`full`,children:[q(N,{as:er,color:s}),q(R,{fontSize:`xs`,color:c,children:o(`You accepted current policy on {{date}}`,{date:Ll(u.timestamp)})})]}):null,q(M,{w:`full`,textAlign:`left`,children:q(R,{fontSize:`xs`,fontWeight:`bold`,color:c,children:o(`All policies you have accepted`)})}),q(M,{w:`full`,gap:2,children:q(z,{align:`stretch`,spacing:2,children:n.map(e=>q(Rl,{document:e},e.id))})}),a&&q(j,{variant:`outline`,size:`xs`,alignSelf:`flex-end`,onClick:()=>{window.open(a.url,`_blank`)},children:o(`View Current Policy`)})]})})]})}):null},Bl=()=>{let{account:e}=Q(),{t}=Y(),{darkMode:n}=$(),{agreements:r,documents:i}=Kp(),a=W(()=>{let t=r?.filter(t=>o(t.walletAddress,e?.address));return[{id:`vechain-kit-terms`,...E,documentType:se.TERMS,documentSource:m.VECHAIN_KIT,walletAddress:e?.address??``,timestamp:new Date().getTime()},...t]?.reduce((e,t)=>(e[t.documentType]=[...e[t.documentType]||[],t],e),{})},[r,e?.address]),s=W(()=>i.reduce((e,t)=>{let n=t.documentType;return(!e[n]||t.version>e[n].version)&&(e[n]=t),e},{}),[i]),c=W(()=>Object.values(a).some(e=>e.length>0),[a]),l=n?`whiteAlpha.50`:`blackAlpha.50`,u=n?`whiteAlpha.100`:`blackAlpha.100`;return c?q(z,{spacing:4,align:`stretch`,children:J(Ie,{allowMultiple:!0,children:[q(zl,{title:t(`Terms and Conditions`),description:t(`Legal agreement between you, Vechain Kit and the current app, outlining the rules for using wallet services.`),documents:a[se.TERMS],bg:l,hoverBg:u,currentPolicy:s[se.TERMS]}),q(zl,{title:t(`Privacy Policy`),description:t(`Privacy policy outlining the data collection and processing practices.`),documents:a[se.PRIVACY],bg:l,hoverBg:u,currentPolicy:s[se.PRIVACY]}),q(zl,{title:t(`Cookie Policy`),description:t(`Cookie policy outlining the use of cookies and tracking technologies.`),documents:a[se.COOKIES],bg:l,hoverBg:u,currentPolicy:s[se.COOKIES]})]})}):q(Il,{title:t(`No policies accepted`),description:t(`When you have accepted a policy, it will appear here`),icon:hr})},Vl=({onGoBack:e})=>{let{t}=Y();return J(Ap,{children:[J(Z,{children:[q(L,{children:t(`Terms and Policies`)}),q(Ja,{onClick:e}),q(F,{})]}),q(P,{w:`full`,children:q(z,{spacing:6,align:`stretch`,children:q(Bl,{})})}),q(I,{pt:0})]})},Hl=({onGoBack:e})=>{let{t}=Y(),{getConnectionCache:n}=Gd(),{connection:r}=Q(),i=n();return J(Ap,{children:[J(Z,{children:[q(L,{children:t(`Connection Details`)}),q(Ja,{onClick:()=>{e()}}),q(F,{})]}),J(P,{w:`full`,children:[r.isConnectedWithCrossApp&&i&&q($c,{connectionCache:i}),r.isConnectedWithSocialLogin&&q(tl,{}),r.isConnectedWithDappKit&&q(el,{})]}),q(I,{pt:0})]})},Ul=({accountType:e,accountDescription:t,isLoading:n,onConfirm:r,onCancel:i})=>{let{t:a}=Y();return J(z,{spacing:6,align:`stretch`,children:[q(R,{fontSize:`md`,textAlign:`center`,color:B(`colors`,`vechain-kit-text-primary`),children:a(`Are you sure you want to unlink {{accountType}} as a login method linked to {{accountDescription}}?`,{accountType:e,accountDescription:t})}),J(z,{spacing:3,w:`full`,children:[q(j,{height:`60px`,colorScheme:`red`,w:`full`,onClick:r,isLoading:n,children:a(`Remove Login Method`)}),q(j,{isLoading:n,height:`60px`,w:`full`,onClick:i,children:a(`Cancel`)})]})]})},Wl=({onBack:e})=>{let{t}=Y(),{privy:n,dappKit:r}=$(),[i,a]=G(null),[o,s]=G(!1),[c,u]=G(!1),[d,f]=G(!1),p=B(`colors`,`vechain-kit-text-primary`),m=B(`colors`,`vechain-kit-text-secondary`),{user:h,linkEmail:g,linkGoogle:_,linkTwitter:v,linkPhone:y,linkSpotify:b,linkApple:x,linkInstagram:S,linkTiktok:C,linkGithub:w,linkLinkedIn:ee,linkTelegram:T,linkFarcaster:E,linkPasskey:D,linkDiscord:te,unlinkEmail:ne,unlinkGoogle:re,unlinkApple:O,unlinkSpotify:ie,unlinkInstagram:ae,unlinkTiktok:oe,unlinkGithub:se,unlinkLinkedIn:k,unlinkTelegram:ce,unlinkFarcaster:le,unlinkPhone:ue,unlinkPasskey:de,unlinkDiscord:fe,linkWallet:pe}=Tn(),me=W(()=>{let e=n?.loginMethods?.filter(e=>[`rabby_wallet`,`coinbase_wallet`,`rainbow`,`phantom`,`metamask`].includes(e))??[],t=r?.allowedWallets??[];return e.length>0||t.length>0},[n?.loginMethods,r?.allowedWallets]),he=e=>{switch(e){case`google_oauth`:return Vi;case`email`:return Sr;case`passkey`:return pr;case`wallet`:return Br;case`twitter_oauth`:return Ki;case`phone`:return Tr;case`spotify_oauth`:return Qi;case`apple_oauth`:return Ji;case`instagram_oauth`:return Xi;case`tiktok_oauth`:return ta;case`github_oauth`:return gr;case`linkedin_oauth`:return Zi;case`telegram`:return $i;case`farcaster`:return qi;case`discord_oauth`:return Yi;default:return}},ge=()=>{let e=h?.linkedAccounts?.filter(e=>e.type!==`wallet`||e.type===`wallet`&&e.connectorType!==`embedded`);return e&&e?.length>1},_e=async e=>{if(ge()){f(!0);try{switch(e.type){case`google_oauth`:await re(e.subject);break;case`email`:await ne(e.address);break;case`passkey`:await de(e.subject);break;case`phone`:await ue(e.number);break;case`spotify_oauth`:await ie(e.subject);break;case`apple_oauth`:await O(e.subject);break;case`instagram_oauth`:await ae(e.subject);break;case`tiktok_oauth`:await oe(e.subject);break;case`github_oauth`:await se(e.subject);break;case`linkedin_oauth`:await k(e.subject);break;case`telegram`:await ce(e.subject);break;case`farcaster`:await le(e.subject);break;case`discord_oauth`:await fe(e.subject);break;default:break}}catch(e){console.error(e)}finally{f(!1),a(null)}}},ve=e=>{switch(e.type){case`google_oauth`:return e.email;case`email`:return e.address;case`passkey`:return`${e.authenticatorName} - ${e.createdWithBrowser}`;case`phone`:return e.number;case`wallet`:return`${l(e.address)} - ${e.walletClientType}`;default:return``}},ye=h?.linkedAccounts?.map(e=>e.type)||[],be=n?.loginMethods||[],xe=!ye.includes(`google_oauth`)&&be.includes(`google`),Se=!ye.includes(`email`)&&be.includes(`email`),Ce=!ye.includes(`twitter_oauth`)&&be.includes(`twitter`),we=!ye.includes(`phone`)&&be.includes(`sms`),Te=!ye.includes(`spotify_oauth`)&&be.includes(`spotify`),Ee=!ye.includes(`apple_oauth`)&&be.includes(`apple`),De=!ye.includes(`instagram_oauth`)&&be.includes(`instagram`),Oe=!ye.includes(`tiktok_oauth`)&&be.includes(`tiktok`),ke=!ye.includes(`github_oauth`)&&be.includes(`github`),Ae=!ye.includes(`linkedin_oauth`)&&be.includes(`linkedin`),je=!ye.includes(`telegram`)&&be.includes(`telegram`),Me=!ye.includes(`farcaster`)&&be.includes(`farcaster`),Ne=!ye.includes(`discord_oauth`)&&be.includes(`discord`);return o?J(Ap,{children:[J(Z,{children:[q(L,{children:t(`Select Additional Login Method`)}),q(Ja,{onClick:()=>s(!1)}),q(F,{})]}),q(P,{w:`full`,children:J(z,{spacing:3,align:`stretch`,w:`full`,children:[q(Lc,{title:t(`Set up Passkey`),description:t(`Set up a passkey for easier access`),onClick:()=>D(),leftIcon:pr}),xe&&q(Lc,{title:t(`Link Google Account`),description:t(`Connect your Google account for easier access`),onClick:()=>_(),leftIcon:Vi}),Se&&q(Lc,{title:t(`Link Email Account`),description:t(`Connect your email for easier access`),onClick:()=>g(),leftIcon:Sr,stacked:!0}),Ce&&q(Lc,{title:t(`Link Twitter Account`),description:t(`Connect your Twitter account for easier access`),onClick:()=>v(),leftIcon:Ki}),we&&q(Lc,{title:t(`Link Phone Number`),description:t(`Connect your phone number for easier access`),onClick:()=>y(),leftIcon:Tr}),Te&&q(Lc,{title:t(`Link Spotify Account`),description:t(`Connect your Spotify account for easier access`),onClick:()=>b(),leftIcon:Qi}),Ee&&q(Lc,{title:t(`Link Apple Account`),description:t(`Connect your Apple account for easier access`),onClick:()=>x(),leftIcon:Ji}),De&&q(Lc,{title:t(`Link Instagram Account`),description:t(`Connect your Instagram account for easier access`),onClick:()=>S(),leftIcon:Xi}),Oe&&q(Lc,{title:t(`Link Tiktok Account`),description:t(`Connect your Tiktok account for easier access`),onClick:()=>C(),leftIcon:ta}),ke&&q(Lc,{title:t(`Link Github Account`),description:t(`Connect your Github account for easier access`),onClick:()=>w(),leftIcon:gr}),Ae&&q(Lc,{title:t(`Link LinkedIn Account`),description:t(`Connect your LinkedIn account for easier access`),onClick:()=>ee(),leftIcon:Zi}),je&&q(Lc,{title:t(`Link Telegram Account`),description:t(`Connect your Telegram account for easier access`),onClick:()=>T(),leftIcon:$i}),Me&&q(Lc,{title:t(`Link Farcaster Account`),description:t(`Connect your Farcaster account for easier access`),onClick:()=>E(),leftIcon:qi}),Ne&&q(Lc,{title:t(`Link Discord Account`),description:t(`Connect your Discord account for easier access`),onClick:()=>te(),leftIcon:Yi}),me&&q(Lc,{title:t(`Link External Wallet`),description:t(`Connect an external wallet for easier access`),onClick:()=>pe(),leftIcon:Br}),!xe&&!Se&&!Ce&&!we&&!Te&&!Ee&&!De&&!Oe&&!ke&&!Ae&&!je&&!Me&&!Ne&&q(R,{fontSize:`sm`,textAlign:`center`,opacity:.7,children:t(`No additional accounts available to link`)})]})}),q(I,{pt:0})]}):i?J(Ap,{children:[J(Z,{children:[q(L,{children:t(`Remove Login Method`)}),q(Ja,{onClick:()=>a(null)}),q(F,{})]}),q(P,{children:q(Ul,{accountType:i.type,accountDescription:ve(i),isLoading:d,onConfirm:()=>_e(i),onCancel:()=>a(null)})}),q(I,{pt:0})]}):J(Ap,{children:[J(Z,{children:[q(L,{children:t(`Login methods`)}),q(Ja,{onClick:e}),q(F,{})]}),q(P,{w:`full`,children:J(z,{spacing:3,align:`center`,w:`full`,justify:`center`,children:[J(z,{spacing:1,justify:`flex-start`,alignItems:`flex-start`,mb:5,textAlign:`left`,w:`full`,children:[q(R,{fontSize:`sm`,color:m,children:t(`These accounts are linked to your embedded wallet and can be used to login to your wallet and access your private key.`)}),c&&q(R,{fontSize:`sm`,color:m,children:t(`Adding more linked accounts increases security against loss of access, but also introduces additional potential attack vectors. For enhanced security, we recommend enabling MFA.`)}),q(j,{variant:`link`,mt:0,size:`sm`,onClick:()=>u(!c),color:p,children:t(c?`Show Less`:`Read More`)})]}),h?.linkedAccounts?.filter(e=>e.type!==`wallet`||e.type===`wallet`&&e.connectorType!==`embedded`).map(e=>J(rt,{p:4,borderWidth:`1px`,borderRadius:`md`,align:`center`,justify:`space-between`,w:`full`,children:[J(rt,{align:`center`,gap:3,children:[q(N,{as:he(e.type),color:p}),J(z,{align:`start`,spacing:0,children:[q(R,{fontWeight:`500`,color:p,children:e.type===`google_oauth`?t(`Google`):e.type===`email`?t(`Email`):e.type===`passkey`?t(`Passkey`):e.type===`twitter_oauth`?t(`Twitter`):e.type===`phone`?t(`Phone Number`):e.type===`spotify_oauth`?t(`Spotify`):e.type===`apple_oauth`?t(`Apple`):e.type===`instagram_oauth`?t(`Instagram`):e.type===`tiktok_oauth`?t(`Tiktok`):e.type===`github_oauth`?t(`Github`):e.type===`linkedin_oauth`?t(`LinkedIn`):e.type===`telegram`?t(`Telegram`):e.type===`farcaster`?t(`Farcaster`):e.type===`discord_oauth`?t(`Discord`):t(`Wallet`)}),q(R,{fontSize:`sm`,color:m,children:ve(e)})]})]}),q(j,{size:`sm`,variant:`ghost`,colorScheme:`red`,isDisabled:!ge(),onClick:()=>{e.type===`passkey`?D():a(e)},children:t(`Remove`)})]},e.type))]})}),q(I,{w:`full`,children:q(j,{w:`full`,variant:`vechainKitPrimary`,onClick:()=>s(!0),leftIcon:q(N,{as:Er}),isDisabled:!xe&&!Se&&!Ce&&!we&&!Te&&!Ee&&!De&&!Oe&&!ke&&!Ae&&!je&&!Me&&!Ne,children:t(`Add Login Method`)})})]})},Gl=[{id:`welcome`,title:`Welcome to the VeChain`,description:`Welcome! Here you can manage your wallet, send tokens, and interact with the VeChain blockchain and its applications.`,timestamp:Date.now(),status:`success`,isRead:!1}],Kl=()=>{let{t:e}=Y(),{account:t,connection:n,smartAccount:r}=Q(),{addNotification:i,getNotifications:a}=ql(),{data:o}=zf(r?.address??``,3);U(()=>{if(!n.isConnectedWithPrivy||!t?.address)return;let r=a(),s=`smart_account_upgrade_${t.address.toLowerCase()}`;!r.some(e=>e.id===s)&&o&&i({id:s,title:e(`Account Upgrade Required`),description:e(`A new upgrade is available for your smart account. Please head over to the 'Access and Security' section to upgrade it.`),status:`warning`})},[n.isConnectedWithPrivy,t?.address,o]),U(()=>{!n.isConnectedWithPrivy||!t?.address||a().some(e=>e.id===`smart_account_${t.address.toLowerCase()}`)||i({id:`smart_account_${t.address.toLowerCase()}`,title:e(`Smart Account detected`),description:e(`You have an active smart account associated to this wallet. It has been set as your main identity.`),status:`info`})},[n.isConnectedWithPrivy,t?.address]),U(()=>{if(!n.isConnectedWithPrivy||!t?.address)return;let r=a(),o=r.some(e=>e.id===`multiclause_warning_${t.address.toLowerCase()}`),s=r.some(e=>e.id===`multiclause_support_${t.address.toLowerCase()}`);o&&!s&&i({id:`multiclause_support_${t.address.toLowerCase()}`,title:e(`Multiclause Transactions Are Now Supported`),description:e(`Good news! Multiclause transactions are now fully supported for smart accounts. You can now enjoy a better user experience, lower gas costs, and enchanced security.`),status:`info`})},[n.isConnectedWithPrivy,t?.address])},ql=()=>{let{account:e}=Q(),t=H(e=>{let t=e?.toLowerCase();return{notifications:`vechain_kit_notifications_${t}`,archived:`vechain_kit_archived_notifications_${t}`,initialized:`vechain_kit_notifications_initialized_${t}`}},[]),n=H(()=>{if(!e?.address||!y())return;let n=t(e.address);w(n.initialized)||(h(n.notifications,JSON.stringify(Gl)),h(n.initialized,`true`))},[e?.address,t]);U(()=>{n()},[n]);let r=H(()=>{if(!e?.address||!y())return[];let n=w(t(e.address).notifications);return n?JSON.parse(n):[]},[e?.address,t]),i=H(()=>{if(!e?.address||!y())return[];let n=w(t(e.address).archived);return n?JSON.parse(n):[]},[e?.address,t]),a=H(n=>{if(!e?.address||!y())return;let i=t(e.address),a=r(),o=w(i.archived),s=o?JSON.parse(o):[];if([...a,...s].some(e=>e.title===n.title))return;let c={...n,id:n.id||Math.random().toString(36).substring(7),timestamp:Date.now(),isRead:!1};h(i.notifications,JSON.stringify([c,...a]))},[e?.address,r,t]),o=H(n=>{if(!e?.address||!y())return;let i=t(e.address),a=r().filter(e=>e.id!==n);h(i.notifications,JSON.stringify(a))},[e?.address,r,t]);return{getNotifications:r,getArchivedNotifications:i,addNotification:a,clearAllNotifications:H(()=>{if(!e?.address||!y())return;let n=t(e.address),a=r();h(n.archived,JSON.stringify([...i(),...a])),h(n.notifications,JSON.stringify([]))},[e?.address,r,i,t]),markAsRead:H(n=>{if(!e?.address||!y())return;let a=t(e.address),o=r(),s=i(),c=o.find(e=>e.id===n),l=o.filter(e=>e.id!==n);if(c){let e=[{...c,isRead:!0},...s];h(a.notifications,JSON.stringify(l)),h(a.archived,JSON.stringify(e))}},[e?.address,r,i,t]),deleteNotification:o}},Jl=({showArchived:e})=>{let{t}=Y();return q(Il,{title:t(e?`No archived notifications`:`No notifications`),description:t(e?`Cleared notifications will appear here`:`When you have notifications, they will appear here`),icon:e?Hn:Xn})},Yl=({notification:e,isArchiveView:t,onMarkAsRead:n})=>{let{t:r}=Y(),i=()=>{n(e.id)};return e.isRead&&!t?null:J(Be,{status:e.status,variant:`subtle`,borderRadius:`lg`,pr:8,position:`relative`,opacity:e.isRead?.7:1,cursor:`pointer`,_hover:{opacity:.8},"data-testid":`notification-item`,children:[q(He,{boxSize:`16px`}),J(A,{children:[q(Ue,{fontSize:`sm`,"data-testid":`notification-title`,children:r(e.title)}),q(Ve,{fontSize:`xs`,lineHeight:`1.2`,"data-testid":`notification-text`,children:r(e.description)})]}),!t&&!e.isRead&&q(lt,{position:`absolute`,right:1,top:1,size:`sm`,variant:`ghost`,icon:q(cr,{}),onClick:e=>{e.stopPropagation(),i()},"aria-label":`Mark as read and archive`,"data-testid":`remove-notification-button`})]},e.id)},Xl=({setCurrentContent:e})=>{let{t}=Y(),{isolatedView:n}=Xc(),{getNotifications:r,getArchivedNotifications:i,clearAllNotifications:a,markAsRead:o}=ql(),[s,c]=G(!1),[l,u]=G(r()),[d,f]=G(i()),p=()=>{a(),f([...d,...l]),u([])},m=e=>{o(e);let t=l.find(t=>t.id===e);u(l.filter(t=>t.id!==e)),t&&f([{...t,isRead:!0},...d])},h=()=>{c(!s)},g=s?d:l,_=[...g].sort((e,t)=>e.id===`welcome`?-1:t.id===`welcome`?1:e.id===`smart-account`?-1:t.id===`smart-account`?1:e.id===`multiclause`?-1:t.id===`multiclause`?1:t.timestamp-e.timestamp);return J(Ap,{children:[J(Z,{children:[!n&&q(Ja,{onClick:()=>e(`main`)}),q(L,{"data-testid":`modal-title`,children:t(s?`Archived Notifications`:`Notifications`)}),q(F,{})]}),J(tt,{h:[`540px`,`auto`],p:0,children:[q(P,{children:J(z,{spacing:4,align:`stretch`,w:`full`,children:[J(M,{justify:`space-between`,children:[q(j,{variant:`ghost`,leftIcon:q(N,{as:s?Xn:Hn}),size:`sm`,onClick:h,"data-testid":`toggle-view-button`,children:t(s?`Current`:`Archived`)}),!s&&l.length>0&&q(j,{variant:`ghost`,size:`sm`,onClick:p,"data-testid":`clear-all-button`,children:t(`Clear all`)})]}),g.length===0?q(Jl,{showArchived:s}):q(z,{spacing:3,children:_.map(e=>q(Yl,{notification:e,isArchiveView:s,onMarkAsRead:m},e.id))})]})}),q(I,{pt:0})]})]})},Zl=e=>{switch(e){case`defi`:return`blue`;case`games`:return`green`;case`collectibles`:return`purple`;case`marketplaces`:return`orange`;case`utilities`:return`cyan`;default:return`gray`}},Ql=({category:e,...t})=>{let{t:n}=Y(),r=e.toLowerCase();return q(Nt,{size:`sm`,colorScheme:Zl(r),borderRadius:`full`,px:2,...t,children:n(r)})},$l=({name:e,imageUrl:t,logoComponent:n,category:r,onClick:i,size:a=`md`})=>J(Ge,{variant:`vechainKitAppCard`,_hover:{opacity:.8},cursor:`pointer`,onClick:i,position:`relative`,children:[r&&q(A,{position:`absolute`,top:`2`,right:`2`,zIndex:`1`,children:q(Ql,{category:r})}),q(Ke,{p:a===`sm`?2:4,alignItems:`center`,children:J(z,{spacing:2,h:`100%`,justifyContent:`space-between`,children:[n||t&&q(ut,{src:t,fallbackSrc:te,alt:e,height:`90px`,objectFit:`contain`,rounded:`full`}),e&&q(R,{fontWeight:`medium`,wordBreak:`break-word`,noOfLines:1,textAlign:`center`,w:`full`,children:e})]})})]}),eu=({xApp:e,setCurrentContent:t,selectedCategory:n})=>{let{data:r,isLoading:i}=Js(e.id),{data:a,isLoading:o}=tc(r?.logo);return q(kt,{isLoaded:!i&&!o,borderRadius:`md`,height:`100%`,children:q($l,{name:r?.name??``,imageUrl:a?.image??``,linkUrl:r?.external_url??``,category:`vebetter`,onClick:()=>{r?.name&&t({type:`app-overview`,props:{name:r.name,image:a?.image??``,url:r?.external_url??``,description:r?.description??``,category:`vebetter`,selectedCategory:n,setCurrentContent:t}})}})})},tu=({name:e,image:t,url:n,description:r,category:i,logoComponent:a,selectedCategory:o,setCurrentContent:s})=>q($l,{name:e,imageUrl:t,linkUrl:n,category:i,onClick:()=>{s({type:`app-overview`,props:{name:e,image:t,url:n,description:r,category:i,logoComponent:a,selectedCategory:o,setCurrentContent:s}})},...a&&{logoComponent:a}}),nu=({})=>{let{t:e}=Y(),{shortcuts:t}=_p();return t.length===0?null:J(z,{w:`full`,align:`flex-start`,spacing:2,children:[q(R,{fontSize:`sm`,fontWeight:`500`,children:e(`Shortcuts`)}),q(ot,{templateColumns:`repeat(4, 1fr)`,gap:2,w:`full`,children:t.map(e=>q(st,{children:q(Ge,{_hover:{opacity:.8},cursor:`pointer`,onClick:()=>window.open(e.url,`_blank`),children:q(Ke,{p:2,alignItems:`center`,children:q(ut,{src:e.image,fallbackSrc:te,alt:e.name,objectFit:`contain`,rounded:`full`})})})},e.url))})]})},ru=({selectedCategory:e,onCategoryChange:t,categories:n,darkMode:r})=>{let{t:i}=Y();return J(A,{width:`full`,mb:4,children:[q(R,{fontSize:`sm`,fontWeight:`500`,mb:2,children:i(`Filter by category`)}),J(It,{spacing:2,children:[q(Lt,{children:q(Nt,{size:`md`,borderRadius:`full`,variant:e===null?`solid`:`outline`,colorScheme:r?`gray`:`blackAlpha`,cursor:`pointer`,onClick:()=>t(null),children:i(`All`)})}),n.map(n=>q(Lt,{children:q(Ql,{category:n,size:`md`,variant:e===n?`solid`:`outline`,cursor:`pointer`,onClick:()=>t(n)})},n))]})]})},iu=[{name:`VeBetterDAO`,description:`Engage, earn and prosper by doing sustainable actions.`,external_url:`https://governance.vebetterdao.org/`,logo:`https://i.ibb.co/cgJBj83/vbd.png`,banner:`https://i.ibb.co/cgJBj83/vbd.png`,screenshots:[],social_urls:[],app_urls:[],tweets:[],ve_world:{banner:`https://i.ibb.co/cgJBj83/vbd.png`},categories:[]},{name:`vet.domains`,description:`.vet.domains provides a unique and unchangeable identity for Vechain users by linking information to their wallet addresses. It becomes easier for people to use the blockchain by replacing complicated wallet addresses with easy-to-remember names.`,external_url:`https://vet.domains`,logo:`https://vet.domains/assets/walletconnect.png`,banner:`https://vet.domains/assets/walletconnect.png`,screenshots:[],social_urls:[],app_urls:[],tweets:[],ve_world:{banner:`https://vet.domains/assets/walletconnect.png`},categories:[]}],au=({setCurrentContent:e,selectedCategory:t})=>{let{t:n}=Y(),{darkMode:r,network:i}=$(),{isolatedView:a}=Xc(),o=B(`colors`,`vechain-kit-text-tertiary`),[s,c]=G(``),[l,u]=G(t||null);U(()=>{t!==void 0&&u(t)},[t]);let{data:d}=gs(),{data:f}=Rs(d?(parseInt(d)-1).toString():`1`),{data:p,isLoading:m,error:h}=Qd(),g=W(()=>{let e=new Set;return i.type===`main`&&f&&f.length>0&&e.add(`vebetter`),p&&p.forEach(t=>{t.category&&e.add(t.category)}),Array.from(e).sort()},[p,f,i.type]),_=i.type===`main`?f.filter(e=>e.app.name.toLowerCase().includes(s.toLowerCase())):[],v=iu.filter(e=>e.name.toLowerCase().includes(s.toLowerCase())),y=p?.filter(e=>(e.name.toLowerCase().includes(s.toLowerCase())||e.description.toLowerCase().includes(s.toLowerCase())||e.tags.some(e=>e.toLowerCase().includes(s.toLowerCase())))&&(l===null||e.category===l))||[],b=l===null,x=l===null||l===`vebetter`,{shortcuts:S}=_p();return J(A,{children:[J(Z,{children:[q(L,{children:n(`Ecosystem`)}),!a&&q(Ja,{onClick:()=>e(`main`)}),q(F,{})]}),q(P,{overflowY:`auto`,minH:`300px`,children:J(z,{spacing:6,w:`full`,children:[q(nu,{setCurrentContent:e}),S.length>0&&q(R,{fontSize:`sm`,fontWeight:`500`,w:`full`,textAlign:`left`,children:n(`All apps`)}),J(ft,{size:`lg`,children:[q(dt,{placeholder:n(`Search Apps`),value:s,onChange:e=>{c(e.target.value)},bg:r?`#00000038`:`gray.50`,borderRadius:`xl`,height:`56px`,pl:12}),q(pt,{h:`56px`,w:`56px`,pl:4,children:q(kr,{color:o})})]}),g.length>0&&q(ru,{selectedCategory:l,onCategoryChange:e=>{u(e)},categories:g,darkMode:r}),J(ot,{templateColumns:`repeat(2, 1fr)`,gap:4,w:`full`,children:[b&&v.length>0&&q(K,{children:v.map(t=>q(st,{children:q(tu,{name:t.name,image:t.logo,url:t.external_url,setCurrentContent:e,description:t.description,selectedCategory:l})},t.name))}),x&&_.length>0&&q(K,{children:_.map(t=>q(st,{children:q(eu,{xApp:t.app,setCurrentContent:e,selectedCategory:l})},t.id))}),m?q(st,{colSpan:2,children:q(Ye,{py:4,children:q(At,{})})}):h?q(st,{colSpan:2,children:q(R,{color:`red.500`,textAlign:`center`,children:n(`Failed to load App Hub apps`)})}):y.length>0?y.map(t=>q(st,{children:q(tu,{name:t.name,image:t.logo,url:t.url,setCurrentContent:e,description:t.description,category:t.category,selectedCategory:l})},t.id)):l&&!x&&q(st,{colSpan:2,children:q(Ye,{py:4,children:q(R,{children:n(`No apps found in this category`)})})})]})]})}),q(I,{pt:0})]})},ou=({name:e,image:t,url:n,description:r})=>{let{t:i}=Y(),{isShortcut:a,addShortcut:o,removeShortcut:s}=_p(),c=a(n);return q(j,{px:4,width:`full`,height:`45px`,variant:`vechainKitSecondary`,borderRadius:`xl`,onClick:()=>{c?s(n):o({name:e,image:t,url:n,description:r})},leftIcon:q(N,{as:c?Qn:Zn}),children:i(c?`Remove from shortcuts`:`Add to shortcuts`)})},su=({setCurrentContent:e,name:t,image:n,url:r,description:i,category:a,selectedCategory:o,logoComponent:s})=>{let{t:c}=Y();return J(A,{children:[J(Z,{children:[q(L,{children:t}),q(Ja,{onClick:()=>{e(o?{type:`ecosystem-with-category`,props:{selectedCategory:o,setCurrentContent:e}}:`ecosystem`)}}),q(F,{})]}),q(P,{children:J(z,{spacing:6,align:`center`,w:`full`,children:[J(rt,{direction:`column`,align:`center`,children:[s||q(ut,{src:n,alt:t,w:`200px`,h:`200px`,objectFit:`contain`,borderRadius:`xl`}),a&&q(M,{mt:2,children:q(Ql,{category:a})})]}),q(R,{fontSize:`sm`,textAlign:`center`,children:i}),q(R,{fontSize:`sm`,textAlign:`center`,children:c(`Click below to access {{ name }} and explore its features.`,{name:t})})]})}),q(I,{children:J(z,{w:`full`,spacing:4,children:[J(j,{variant:`vechainKitSecondary`,onClick:()=>{window.open(r,`_blank`)},children:[c(`Launch {{name}}`,{name:t}),q(N,{as:fr,ml:2})]}),q(ou,{name:t,image:n,url:r,description:i})]})})]})},cu=({children:e})=>q(Vn.div,{whileHover:{scale:1.1},transition:{duration:.5,ease:`easeInOut`,repeat:1/0,repeatDelay:crypto.getRandomValues(new Uint32Array(1))[0]/2**32*5},animate:{y:[0,-2,0],rotate:[0,10,-10,0]},children:e}),lu=({descriptionEncoded:e})=>{let{darkMode:t}=$();return J(M,{gap:2,children:[q(cu,{children:q(ht,{href:`https://twitter.com/intent/tweet?text=${e}`,isExternal:!0,children:q(A,{bg:t?`blackAlpha.700`:`lightgrey`,p:2,borderRadius:`full`,children:q(Ki,{size:22})})})}),q(cu,{children:q(ht,{href:`https://telegram.me/share/url?url=${e}`,isExternal:!0,children:q(A,{bg:`#30abec`,p:2,borderRadius:`full`,children:q(ea,{color:`white`,size:22})})})}),q(cu,{children:q(ht,{href:`https://wa.me/?text=${e}`,isExternal:!0,children:q(A,{bg:`#01cb37`,p:2,borderRadius:`full`,children:q(na,{size:22,color:`white`})})})})]})},uu=({status:e,uiConfig:t,onTryAgain:n,txReceipt:r,txError:i,onClose:a})=>{let{t:o}=Y(),{network:s}=$(),c=B(`colors`,`vechain-kit-error`),l=B(`colors`,`vechain-kit-success`),u=B(`colors`,`vechain-kit-text-primary`),d=B(`colors`,`vechain-kit-text-secondary`),f=W(()=>i?i.reason||o(`Something went wrong. Please try again.`):null,[i,o]),p=(()=>{let n=e===`waitingConfirmation`;switch(n&&(e=`pending`),e){case`pending`:return{title:t?.title??o(n?`Sending Transaction...`:`Waiting for confirmation`),icon:t?.loadingIcon??q(At,{size:`xl`,"data-testid":`pending-spinner-modal`}),description:n?o(`Transaction is being processed, it can take up to 15 seconds.`):t?.description??o(`Please confirm the transaction in your wallet.`)};case`error`:return{title:o(`Something went wrong`),icon:t?.errorIcon??q(N,{as:ar,color:c,fontSize:`100px`,"data-testid":`error-icon-modal`}),description:f??o(`An unexpected error occurred.`)};case`success`:return{title:o(`Transaction successful!`),icon:t?.successIcon??q(N,{as:or,color:l,fontSize:`100px`,"data-testid":`success-icon-modal`}),description:``};case`ready`:return{title:t?.title??o(`Confirm transaction`),icon:null,description:t?.description??o(`Confirm the transaction in your wallet to complete it.`)};default:return{title:``,icon:null,description:``}}})(),m=`${k(s.type).explorerUrl}/${r?.meta.txID}`;return J(A,{children:[J(Z,{children:[q(L,{children:p.title}),q(F,{isDisabled:e===`pending`&&!t?.isClosable})]}),q(P,{children:J(z,{align:`center`,p:6,spacing:3,children:[p.icon,e===`success`&&t?.showShareOnSocials&&J(z,{mt:2,spacing:3,children:[q(R,{fontSize:`sm`,fontWeight:`bold`,color:d,children:o(`Share on`)}),q(lu,{descriptionEncoded:m})]}),p.description&&q(R,{fontSize:e===`ready`?`md`:`sm`,textAlign:`center`,color:e===`error`?c:u,mt:5,style:{lineBreak:`anywhere`},children:p.description})]})}),q(I,{justifyContent:`center`,children:J(z,{width:`full`,spacing:4,children:[e===`error`&&!!n&&J(j,{variant:`vechainKitPrimary`,onClick:n,width:`full`,children:[q(N,{mr:2,as:Dr}),o(`Try again`)]}),e===`ready`&&q(j,{onClick:n,variant:`vechainKitPrimary`,width:`full`,children:o(`Confirm`)}),(e===`success`||e===`error`||e===`ready`)&&q(j,{onClick:a,variant:`vechainKitSecondary`,width:`full`,children:o(`Close`)}),t?.showExplorerButton&&r?.meta.txID&&q(ht,{href:`${k(s.type).explorerUrl}/${r?.meta.txID}`,isExternal:!0,opacity:.5,fontSize:`14px`,textDecoration:`underline`,children:J(M,{spacing:1,alignItems:`center`,w:`full`,justifyContent:`center`,children:[q(R,{color:d,children:o(`View transaction on the explorer`)}),q(N,{size:`sm`,as:fr,color:d})]})})]})})]})},du=({isOpen:e,onClose:t,status:n,uiConfig:r,txReceipt:i,txError:a,onTryAgain:o})=>q($a,{isOpen:e,onClose:t,allowExternalFocus:!0,blockScrollOnMount:!0,closeOnOverlayClick:n!==`pending`&&r?.isClosable,children:q(uu,{status:n,onTryAgain:o,uiConfig:r,txReceipt:i,onClose:t,txError:a})}),fu=({txId:e,title:t,description:n,onDone:r,showSocialButtons:i=!1})=>{let{t:a}=Y(),{network:o}=$(),s=k(o.type).explorerUrl,c=`${s}/${e}`,l=B(`colors`,`vechain-kit-success`),u=B(`colors`,`vechain-kit-text-primary`),d=B(`colors`,`vechain-kit-text-secondary`);return J(A,{children:[J(Z,{children:[q(L,{children:t}),q(F,{})]}),q(P,{children:J(z,{align:`center`,p:6,spacing:3,children:[q(N,{as:or,fontSize:`100px`,color:l,"data-testid":`success-icon`}),n&&q(R,{fontSize:`sm`,textAlign:`center`,color:u,children:n}),i&&e&&J(z,{mt:2,spacing:3,children:[q(R,{fontSize:`sm`,fontWeight:`bold`,color:d,children:a(`Share on`)}),q(lu,{descriptionEncoded:c})]})]})}),q(I,{justifyContent:`center`,children:J(z,{width:`full`,spacing:4,children:[q(j,{onClick:r,variant:`vechainKitSecondary`,width:`full`,children:a(`Done`)}),e&&q(ht,{href:`${s}/${e}`,isExternal:!0,opacity:.5,fontSize:`14px`,textDecoration:`underline`,children:J(M,{spacing:1,alignItems:`center`,w:`full`,justifyContent:`center`,children:[q(R,{color:d,children:a(`View transaction on the explorer`)}),q(N,{size:16,as:fr})]})})]})})]})},pu=({txId:e,title:t,description:n,onDone:r})=>{let{t:i}=Y(),{network:a,darkMode:o}=$(),s=k(a.type).explorerUrl;return J(A,{children:[J(Z,{children:[q(L,{children:t}),q(F,{})]}),q(P,{children:J(z,{align:`center`,p:6,spacing:3,children:[q(N,{as:ar,fontSize:`100px`,color:o?`red.400`:`red.500`,"data-testid":`error-icon`}),n&&q(R,{fontSize:`sm`,textAlign:`center`,children:n})]})}),q(I,{justifyContent:`center`,children:J(z,{width:`full`,spacing:4,children:[q(j,{onClick:r,variant:`vechainKitSecondary`,width:`full`,children:i(`Done`)}),e&&q(ht,{href:`${s}/${e}`,isExternal:!0,opacity:.5,fontSize:`14px`,textDecoration:`underline`,children:J(M,{spacing:1,alignItems:`center`,w:`full`,justifyContent:`center`,children:[q(R,{children:i(`View transaction on the explorer`)}),q(N,{size:16,as:fr})]})})]})})]})},mu=({isOpen:e,onClose:t,initialContent:n=`main`})=>{Kl();let{account:r}=Q(),{accountModalContent:i,setAccountModalContent:a}=ad();return U(()=>{e&&n&&a(n)},[e,n,a]),q($a,{isOpen:e,onClose:t,allowExternalFocus:!0,blockScrollOnMount:!0,children:(()=>{if(typeof i==`object`)switch(i.type){case`send-token`:return q(ol,{...i.props});case`send-token-summary`:return q(sl,{...i.props});case`swap-token`:return q(fl,{...i.props});case`choose-name`:return q(pl,{...i.props});case`choose-name-search`:return q(_l,{...i.props});case`choose-name-summary`:return q(vl,{...i.props});case`app-overview`:return q(su,{...i.props,setCurrentContent:a});case`disconnect-confirm`:return q(il,{...i.props});case`account-customization`:return q(xl,{...i.props});case`account-customization-summary`:return q(Sl,{...i.props});case`successful-operation`:return q(fu,{...i.props});case`failed-operation`:return q(pu,{...i.props});case`upgrade-smart-account`:return q(Tl,{...i.props});case`faq`:return q(bl,{...i.props});case`terms-and-privacy`:return q(Vl,{...i.props});case`ecosystem-with-category`:return q(au,{setCurrentContent:a,selectedCategory:i.props.selectedCategory})}switch(i){case`main`:return q(Fc,{setCurrentContent:a,onClose:t,wallet:r});case`settings`:return q(Zc,{setCurrentContent:a,onLogoutSuccess:()=>{t()}});case`profile`:return q(wl,{setCurrentContent:a,onLogoutSuccess:()=>{t()}});case`assets`:return q(El,{setCurrentContent:a});case`bridge`:return q(Ol,{setCurrentContent:a});case`notifications`:return q(Xl,{setCurrentContent:a});case`access-and-security`:return q(Yc,{setCurrentContent:a});case`receive-token`:return q(cl,{setCurrentContent:a});case`swap-token`:return q(fl,{setCurrentContent:a});case`connection-details`:return q(Hl,{onGoBack:()=>a(`settings`)});case`privy-linked-accounts`:return q(Wl,{onBack:()=>a(`access-and-security`)});case`ecosystem`:return q(au,{setCurrentContent:a});case`embedded-wallet`:return q(rl,{setCurrentContent:a});case`add-custom-token`:return q(Dl,{setCurrentContent:a});case`change-currency`:return q(kl,{setCurrentContent:a});case`general-settings`:return q(Al,{setCurrentContent:a});case`change-language`:return q(jl,{setCurrentContent:a});case`appearance-settings`:return q(Ml,{setCurrentContent:a});case`gas-token-settings`:return q(Fl,{setCurrentContent:a});default:return null}})()})},hu=({isOpen:e,onClose:t})=>{let[n,r]=G(`main`);return U(()=>{e&&r(`main`)},[e]),q($a,{isOpen:e,onClose:t,allowExternalFocus:!0,blockScrollOnMount:!0,children:(()=>{switch(n){case`main`:return q(Nc,{setCurrentContent:r,onClose:t});case`faq`:return q(bl,{onGoBack:()=>r(`main`)})}})()})},gu=({onClick:e,text:t,icon:n,customIcon:r,rightIcon:i,style:a,variant:o=`loginIn`,iconWidth:s=`25px`})=>t?t?J(j,{...a,variant:o,w:`full`,onClick:e,children:[J(M,{w:`full`,justify:`flex-start`,gap:2,children:[r||q(N,{as:n,w:s,h:s}),q(R,{opacity:.9,children:t})]}),i]}):null:q(j,{...a,variant:o,w:`full`,onClick:e,children:r||q(N,{as:n,w:`20px`,h:`20px`})}),_u=({isLoading:e,buttonStyle:t})=>{let{t:n}=Y(),{loginMethods:r,darkMode:i,privyEcosystemAppIDS:a}=$(),o=r?.some(({method:e})=>e===`ecosystem`),{data:s,isLoading:c}=oo(a);return q(Ct,{placement:`bottom-start`,size:`xl`,closeOnBlur:!1,variant:`vechainKitBase`,children:({isOpen:r})=>J(K,{children:[q(Dt,{children:J(j,{isLoading:e,...t,isActive:r,children:[n(`Login`),q(N,{ml:2,as:tr,transform:r?`rotate(180deg)`:`rotate(0deg)`,transition:`transform 0.2s`})]})}),J(Tt,{children:[q(wt,{children:q(jc,{})}),q(Et,{borderTop:`none`,pb:`15px`,children:o&&q(M,{justify:`center`,w:`full`,children:q(Mc,{isDark:i,appsInfo:Object.values(s||{}),isLoading:c})})})]})]})})},vu=({variant:e})=>{let{account:t}=Q();return t?e===`icon`?null:e===`iconAndDomain`?t.domain?q(R,{fontSize:`sm`,children:d(t?.domain??``,16,0)}):q(R,{fontSize:`sm`,children:l(t.address??``,6,4)}):e===`iconDomainAndAssets`?J(M,{spacing:4,children:[J(z,{spacing:0,alignItems:`flex-start`,children:[t.domain&&q(R,{fontSize:`sm`,fontWeight:`bold`,children:d(t?.domain??``,16,0)}),q(R,{fontSize:t.domain?`xs`:`sm`,opacity:t.domain?.5:1,"data-testid":`trimmed-address`,children:l(t.address??``,4,4)})]}),q(zc,{address:t.address??``,maxIcons:3})]}):J(z,{spacing:0,alignItems:`flex-start`,children:[t.domain&&q(R,{fontSize:`sm`,fontWeight:`bold`,children:d(t?.domain??``,16,0)}),q(R,{fontSize:t.domain?`xs`:`sm`,opacity:t.domain?.5:1,children:l(t.address??``,4,4)})]}):q(At,{})},yu=({mobileVariant:e=`iconAndDomain`,desktopVariant:t=`iconAndDomain`,onOpen:n,buttonStyle:r={}})=>{let{account:i}=Q(),[a]=Kt(`(min-width: 768px)`);return q(j,{...r,onClick:n,w:`full`,minH:`45px`,maxW:`fit-content`,"data-testid":`wallet-button`,children:J(M,{w:`full`,minW:`fit-content`,children:[q(jp,{wallet:i,props:{width:30,height:30,minWidth:30,minHeight:30}}),q(vu,{variant:a?t:e})]})})},bu=({mobileVariant:e=`iconAndDomain`,desktopVariant:t=`iconDomainAndAddress`,buttonStyle:n,connectionVariant:r=`modal`})=>{let{t:i}=Y(),{darkMode:a,loginMethods:o}=$(),s=o?.length===1&&o[0].method===`dappkit`,{connection:c,account:l}=Q(),{setSource:u,connectV2:d}=Mn(),[f]=Kt(`(max-width: 768px)`),p=Gt(),m=Gt(),{open:h}=Pn();return J(rd,{darkMode:a,children:[c.isConnected&&l?q(yu,{mobileVariant:e,desktopVariant:t,onOpen:m.onOpen,buttonStyle:n}):r===`popover`&&!f?q(_u,{isLoading:c.isLoading,buttonStyle:n}):q(j,{isLoading:c.isLoading,onClick:()=>{c.isInAppBrowser?(u(`veworld`),d(null)):s?h():p.onOpen()},...n,children:i(`Login`)}),q(hu,{isOpen:p.isOpen,onClose:p.onClose}),q(mu,{isOpen:m.isOpen,onClose:m.onClose})]})},xu=()=>{let{darkMode:e}=$(),t=25/2,[n]=Kt(`(max-width: 280px)`),[r]=Kt(`(max-width: 380px)`);return J(M,{spacing:0,ml:0,children:[q(Qe,{size:`25px`,borderRadius:`full`,bg:`#F8F8F8`,p:2,alignItems:`center`,justifyContent:`center`,zIndex:3,children:q(N,{as:Vi,fontSize:`20px`})}),!n&&q(Qe,{ml:`-${t}px`,size:`25px`,borderRadius:`full`,bg:`black`,p:2,alignItems:`center`,justifyContent:`center`,zIndex:2,children:q(N,{as:Ki,color:`white`,fontSize:`20px`})}),!n&&!r&&q(Qe,{ml:`-${t}px`,zIndex:1,size:`25px`,borderRadius:`full`,bg:`#5865F2`,p:2,alignItems:`center`,justifyContent:`center`,children:q(N,{as:Gi,color:`white`,fontSize:`20px`})}),q(N,{zIndex:1,as:Er,color:e?`black`:`white`,fontSize:`15px`})]})},Su=({status:e,txReceipt:t,txError:n,onTryAgain:r,description:i,onClose:a})=>{let{t:o}=Y(),{network:s}=$(),c=k(s.type).explorerUrl,l=W(()=>n?n.reason||o(`Something went wrong. Please try again.`):null,[n,o]),u=(()=>{let t=e===`waitingConfirmation`;switch(t&&(e=`pending`),e){case`pending`:return{icon:q(At,{size:`md`,"data-testid":`pending-spinner-toast`}),title:o(t?`Processing transaction...`:`Waiting for confirmation...`),closeDisabled:!0,description:t?o(`Transaction is being processed, it can take up to 15 seconds.`):i??o(`Please confirm the transaction in your wallet.`)};case`error`:return{icon:q(N,{as:ar,color:`red.500`,fontSize:`40px`,"data-testid":`error-icon-toast`}),title:o(`Transaction failed`),closeDisabled:!1,description:l};case`success`:return{icon:q(N,{as:or,color:`green.500`,fontSize:`40px`,"data-testid":`success-icon-toast`}),title:o(`Transaction successful!`),closeDisabled:!1,description:void 0};case`ready`:return{icon:null,title:o(`Confirm transaction`),closeDisabled:!1,description:i??o(`Confirm the transaction in your wallet to complete it.`)};default:return{icon:null,title:``,closeDisabled:!1,description:``}}})();return u?J(M,{justify:`space-between`,alignItems:`flex-start`,w:`full`,children:[q(z,{spacing:4,children:J(M,{spacing:4,w:`full`,justifyContent:`flex-start`,alignItems:`flex-start`,children:[u.icon,J(z,{w:`full`,align:`flex-start`,spacing:2,children:[J(z,{spacing:1,w:`full`,children:[q(ct,{w:`full`,size:`xs`,children:u.title}),u.description&&q(R,{fontSize:`xs`,children:u.description})]}),(e===`error`||e===`ready`)&&q(j,{size:`xs`,onClick:r,children:o(e===`error`?`Try again`:`Confirm`)}),t&&e!==`pending`&&J(ht,{fontSize:`xs`,isExternal:!0,href:`${c}/${t.meta.txID}`,children:[o(`View on explorer`),` `,q(N,{as:fr})]})]})]})}),!u.closeDisabled&&q(lt,{onClick:a,variant:`ghost`,size:`sm`,borderRadius:`full`,"aria-label":`Close`,icon:q(N,{as:Vr,boxSize:4})})]}):null},Cu=({isOpen:e,onClose:t,status:n,txReceipt:r,txError:i,onTryAgain:a,description:o})=>{let{darkMode:s}=$();return e?q(A,{position:`fixed`,bottom:`5`,left:`5`,zIndex:`11111`,bg:s?`#1f1f1e`:`white`,borderRadius:`md`,p:5,boxShadow:`lg`,maxW:`sm`,minW:`300px`,children:q(Su,{status:n,txReceipt:r,txError:i,onTryAgain:a,description:o,onClose:t})}):null},wu=({isOpen:e,onClose:t,error:n,title:r,loadingText:i,onTryAgain:a=()=>{}})=>q($a,{isOpen:e,onClose:t,trapFocus:!1,autoFocus:!1,backdropFilter:`blur(3px)`,children:n?q(Eu,{error:n,onClose:t,onTryAgain:a}):q(Tu,{loadingText:i,title:r,onTryAgain:a})}),Tu=({loadingText:e,title:t,onTryAgain:n})=>{let{t:r}=Y(),[i,a]=V.useState(!1);return V.useEffect(()=>{let e=setTimeout(()=>{a(!0)},7e3);return()=>clearTimeout(e)},[Pi]),J(K,{children:[q(Z,{children:q(L,{children:t??r(`Connecting...`)})}),J(P,{children:[q(z,{align:`center`,p:6,gap:0,w:`full`,justifyContent:`center`,minH:`150px`,children:q(At,{size:`xl`})}),e&&!i&&q(R,{size:`sm`,textAlign:`center`,children:e}),i&&J(z,{mt:4,spacing:2,children:[q(R,{color:`orange.300`,size:`sm`,textAlign:`center`,children:r(`This is taking longer than expected.`)}),q(R,{size:`sm`,textAlign:`center`,children:r(`You may want to try establishing the connection again.`)})]})]}),q(I,{justifyContent:`center`,children:i&&J(j,{variant:`vechainKitPrimary`,onClick:n,children:[q(N,{mr:2,as:Dr}),r(`Try again`)]})})]})},Eu=({error:e,onClose:t,onTryAgain:n})=>{let{t:r}=Y();return J(K,{children:[J(Z,{children:[q(L,{children:r(`Connection Failed`)}),q(F,{onClick:()=>{t()}})]}),q(P,{children:J(z,{align:`center`,p:6,w:`full`,justifyContent:`center`,minH:`100px`,gap:4,children:[q(Vn.div,{transition:{duration:4,ease:`easeInOut`,repeat:1/0},animate:{scale:[1,1.1,1]},children:q(N,{as:ar,color:`#ef4444`,fontSize:`60px`,opacity:.5})}),q(R,{w:`full`,size:`sm`,textAlign:`center`,children:e})]})}),q(I,{justifyContent:`center`,children:J(j,{variant:`vechainKitPrimary`,onClick:n,children:[q(N,{mr:2,as:Dr}),r(`Try again`)]})})]})},Du=({onClose:e,appsInfo:t,isLoading:n})=>{let{t:r}=Y(),i=B(`colors`,`vechain-kit-text-primary`),[a,o]=G(),[s,c]=G(),l=Gt(),{setConnectionCache:u}=Gd(),{login:d}=Us(),f=async(n,i)=>{l.onOpen();try{o(void 0),c(i);try{await d(n),l.onClose(),u({name:i,logoUrl:t.find(e=>e.id===n)?.logo_url,appId:n,website:t.find(e=>e.id===n)?.website}),e()}catch(e){let t=e?.message;if(t&&g(t))return Error(`Login request was cancelled.`);o((e instanceof Error?e:Error(`'An unexpected issue occurred while logging in with this app. Please try again or contact support.',`)).message)}}catch(e){console.error(r(`Login failed:`),e),o(e instanceof Error?e.message:r(`Failed to connect with ecosystem app`))}};return J(A,{children:[J(K,{children:[q(Z,{children:J(L,{children:[r(`Already have an x2earn app wallet?`),q(F,{onClick:()=>{e()}})]})}),J(P,{children:[n&&q(z,{minH:`200px`,w:`full`,justifyContent:`center`,children:q(At,{})}),!n&&t&&q(z,{spacing:4,w:`full`,pb:6,children:t.map(e=>J(j,{variant:`loginIn`,fontSize:`14px`,fontWeight:`400`,p:6,borderRadius:16,w:`full`,onClick:()=>{f(e.id,e.name)},justifyContent:`flex-start`,children:[q(ut,{src:e.logo_url,alt:e.name,w:`30px`}),q(R,{ml:5,children:e.name})]},e.id))}),!n&&!t&&q(R,{textAlign:`center`,color:i,children:r(`No application from VeChain ecosystem is available to login.`)})]}),q(I,{pt:0})]}),q(wu,{isOpen:l.isOpen,onClose:()=>{l.onClose()},error:a,title:`${r(`Connecting with`)} ${s}`,loadingText:r(`Please approve the request in the connection request window...`),onTryAgain:()=>{if(s){let e=t.find(e=>e.name===s);e&&f(e.id,e.name)}}})]})},Ou=({isOpen:e,onClose:t,appsInfo:n,isLoading:r})=>q($a,{isOpen:e,onClose:t,backdropFilter:`blur(3px)`,children:q(Du,{onClose:t,appsInfo:n,isLoading:r})}),ku=({txId:e,title:t,description:n,onDone:r,showSocialButtons:i=!1})=>{let{t:a}=Y(),{network:o}=$(),s=k(o.type).explorerUrl,c=`${s}/${e}`,l=B(`colors`,`vechain-kit-success`);return J(A,{children:[J(Z,{children:[q(L,{children:t}),q(F,{})]}),q(P,{children:J(z,{align:`center`,p:6,spacing:3,children:[q(Vn.div,{transition:{duration:4,ease:`easeInOut`,repeat:1/0},animate:{scale:[1,1.1,1]},children:q(N,{as:or,fontSize:`100px`,color:l})}),n&&q(R,{fontSize:`sm`,textAlign:`center`,children:n}),i&&e&&J(z,{mt:2,children:[q(R,{fontSize:`xs`,children:a(`Share on`)}),q(lu,{descriptionEncoded:c})]})]})}),q(I,{justifyContent:`center`,children:J(z,{width:`full`,spacing:4,children:[q(j,{onClick:r,variant:`vechainKitSecondary`,width:`full`,children:a(`Done`)}),e&&q(ht,{href:`${s}/${e}`,isExternal:!0,opacity:.5,fontSize:`14px`,textDecoration:`underline`,children:J(M,{spacing:1,alignItems:`center`,w:`full`,justifyContent:`center`,children:[q(R,{children:a(`View transaction on the explorer`)}),q(N,{size:16,as:fr})]})})]})})]})},Au=({setCurrentContent:e,handleClose:t,style:n})=>{let{t:r}=Y(),{smartAccount:i,connectedWallet:a}=Q(),{data:o}=If(i?.address??``,a?.address??``,3),{sendTransaction:s,isTransactionPending:c,isWaitingForWalletConfirmation:l,error:u,txReceipt:d}=Vf({smartAccountAddress:i?.address??``,targetVersion:3,onSuccess:()=>{e({type:`successful-operation`,props:{setCurrentContent:e,txId:d?.meta.txID,title:r(`Upgrade Successful!`),description:r(`Your account has been successfully upgraded to the latest version. You can now enjoy a better user experience, lower gas costs, and enhanced security.`),onDone:()=>{t()},showSocialButtons:!1}})},onError:()=>{console.error(`Error upgrading Smart Account`)}});return J(K,{children:[J(Z,{children:[q(L,{children:r(`Account upgrade required`)}),q(F,{})]}),q(P,{children:J(z,{spacing:10,align:`stretch`,justifyContent:`center`,children:[q(R,{fontSize:`sm`,textAlign:`center`,children:r(`To continue interacting with VeChain blockchain and complete your operation, your smart account needs to be upgraded to the latest version (v3).`)}),J(M,{align:`center`,justifyContent:`space-evenly`,rounded:`md`,children:[J(A,{position:`relative`,display:`inline-block`,children:[q(Qe,{size:`60px`,bg:`gray.200`,children:q(ut,{src:i?.image,alt:r(`Profile Picture`),w:`100%`,h:`100%`,borderRadius:`full`,objectFit:`cover`})}),q(ct,{position:`absolute`,top:`-5`,right:`-5`,color:`#D23F63`,fontSize:`28px`,children:`v1`})]}),q(N,{as:qn,color:`#3DBA67`}),J(A,{position:`relative`,display:`inline-block`,children:[q(Qe,{size:`60px`,bg:`gray.200`,children:q(ut,{src:i?.image,alt:r(`Profile Picture`),w:`100%`,h:`100%`,borderRadius:`full`,objectFit:`cover`})}),q(ct,{position:`absolute`,top:`-5`,right:`-5`,color:`#3DBA67`,fontSize:`28px`,children:`v3`})]})]}),J(Be,{status:`info`,borderRadius:`md`,children:[q(He,{}),J(A,{children:[q(Ue,{fontSize:`sm`,children:r(`Benefits of this upgrade:`)}),q(Ve,{fontSize:`xs`,children:J(z,{align:`start`,spacing:0,mt:1,children:[J(R,{fontSize:`xs`,lineHeight:`1.2`,children:[`• `,r(`Improved security features`)]}),J(R,{fontSize:`xs`,children:[`• `,r(`Better transaction handling`)]}),J(R,{fontSize:`xs`,children:[`•`,` `,r(`Enhanced compatibility with dApps`)]}),J(R,{fontSize:`xs`,children:[`•`,` `,r(`Reduced gas costs for operations`)]})]})})]})]})]})}),q(I,{justifyContent:`center`,children:q(z,{spacing:3,w:`full`,children:q(Mp,{style:n,buttonText:r(o?`Upgrade account`:`Account already upgraded`),onConfirm:async()=>{try{await s()}catch(e){console.error(`Failed to upgrade Smart Account:`,e)}},isTxWaitingConfirmation:l,isSubmitting:c,transactionPendingText:r(`Upgrading...`),txReceipt:d,transactionError:u,isDisabled:!o})})})]})},ju=({isOpen:e,onClose:t,style:n})=>{let[r,i]=G(`upgrade-smart-account`);return U(()=>{e&&i(`upgrade-smart-account`)},[e]),q($a,{isOpen:e,onClose:t,allowExternalFocus:!0,blockScrollOnMount:!0,size:n?.modalSize,children:(()=>{if(typeof r==`object`)switch(r.type){case`successful-operation`:return q(ku,{...r.props})}else if(r===`upgrade-smart-account`)return q(Au,{setCurrentContent:i,handleClose:t,style:n})})()})},{definePartsStyle:Mu,defineMultiStyleConfig:Nu}=Rt(ca.keys),Pu=e=>({vechainKitBase:Mu({dialog:{scrollbarWidth:`none`,overflow:`scroll`,overflowX:`hidden`,maxHeight:`550px`,borderRadius:e.borders.radius.xl,backgroundColor:e.colors.background.modal,backdropFilter:e.effects.backdropFilter.modal,border:e.colors.border.modal},overlay:{backgroundColor:e.colors.background.overlay,backdropFilter:e.effects.backdropFilter.overlay},closeButton:{borderRadius:e.borders.radius.full,color:e.colors.text.primary,_hover:{bg:e.buttons.button.bg},_active:{bg:e.buttons.button.bg,opacity:.8}},header:{w:`full`,color:e.colors.text.primary,fontSize:e.fonts.sizes.medium,fontWeight:e.fonts.weights.bold,textAlign:`center`}})}),Fu=e=>Nu({variants:Pu(e),defaultProps:{variant:`vechainKitBase`}}),{definePartsStyle:Iu,defineMultiStyleConfig:Lu}=Rt(sa.keys),Ru=e=>({vechainKitBase:Iu({container:{backgroundColor:e.colors.background.card,borderRadius:e.borders.radius.medium,width:`full`,border:`none`},body:{p:5,width:`full`},header:{p:5,width:`full`,borderRadius:`${e.borders.radius.medium} ${e.borders.radius.medium} 0 0`},footer:{width:`full`,borderRadius:`0 0 ${e.borders.radius.medium} ${e.borders.radius.medium}`}}),featureAnnouncement:Iu({body:{backgroundColor:e.buttons.button.bg,borderRadius:e.borders.radius.medium,color:e.colors.text.secondary},container:{borderRadius:e.borders.radius.medium,backgroundColor:`transparent`}}),vechainKitAppCard:Iu({body:{height:`full`,borderRadius:e.borders.radius.medium,backgroundColor:e.colors.background.cardElevated,border:`1px solid ${e.colors.border.default}`},container:{height:`150px`,borderRadius:e.borders.radius.medium,backgroundColor:`transparent`}})}),zu=e=>Lu({variants:Ru(e),defaultProps:{variant:`vechainKitBase`}}),Bu=Bt({borderRadius:`12px`}),Vu=e=>({loginIn:Bt(()=>({bg:e.buttons.loginButton.bg,color:e.buttons.loginButton.color,border:e.buttons.loginButton.border,fontSize:e.fonts.sizes.medium,fontWeight:e.fonts.weights.normal,py:6,px:3,borderRadius:e.borders.radius.large,_hover:{opacity:.5,_disabled:{opacity:.5,bg:e.buttons.loginButton.bg}},_disabled:{opacity:.5,cursor:`not-allowed`,bg:e.buttons.loginButton.bg},transition:`all 0.2s`})),loginWithVechain:Bt(()=>({color:`white`,bg:`#1a1a1a`,fontSize:e.fonts.sizes.medium,fontWeight:e.fonts.weights.normal,py:6,px:3,borderRadius:e.borders.radius.large,border:`1px solid ${e.colors.border.button}`,_hover:{opacity:.5,_disabled:{opacity:.5,bg:`#1a1a1a`}},_disabled:{opacity:.5,cursor:`not-allowed`,bg:`#1a1a1a`},_dark:{color:`#1a1a1a`,bg:`white`,_hover:{_disabled:{bg:`white`}},_disabled:{bg:`white`}},transition:`all 0.2s`})),vechainKitPrimary:Bt(()=>({fontSize:e.fonts.sizes.medium,px:4,width:`full`,height:`60px`,borderRadius:e.borders.radius.large,bg:e.buttons.primaryButton.bg,color:e.buttons.primaryButton.color,border:e.buttons.primaryButton.border,_hover:{...e.buttons.primaryButton.hoverBg?{bg:e.buttons.primaryButton.hoverBg}:{opacity:.8},_disabled:{opacity:.5,bg:e.buttons.primaryButton.bg}},_disabled:{opacity:.5,cursor:`not-allowed`,bg:e.buttons.primaryButton.bg},transition:`all 0.2s`})),vechainKitSecondary:Bt(()=>({fontSize:e.fonts.sizes.medium,px:4,width:`full`,height:`60px`,borderRadius:e.borders.radius.large,bg:e.buttons.button.bg,color:e.buttons.button.color,border:e.buttons.button.border===`none`?`none`:e.buttons.button.border,_hover:{...e.buttons.button.hoverBg?{bg:e.buttons.button.hoverBg}:{opacity:.8},_disabled:{opacity:.5,bg:e.buttons.button.bg}},_disabled:{opacity:.5,cursor:`not-allowed`,bg:e.buttons.button.bg},transition:`all 0.2s`})),vechainKitTertiary:Bt(()=>({fontSize:e.fonts.sizes.medium,px:4,width:`full`,height:`60px`,borderRadius:e.borders.radius.large,bg:e.buttons.tertiaryButton.bg,color:e.buttons.tertiaryButton.color,border:e.buttons.tertiaryButton.border===`none`?`none`:e.buttons.tertiaryButton.border,_hover:{opacity:.8,_disabled:{opacity:.5,bg:e.buttons.tertiaryButton.bg}},_disabled:{opacity:.5,cursor:`not-allowed`,bg:e.buttons.tertiaryButton.bg},transition:`all 0.2s`})),vechainKitLogout:Bt(()=>({width:`full`,minHeight:`50px`,height:`fit-content`,borderRadius:e.borders.radius.xl,p:0,bg:e.colors.error+`1f`,_hover:{bg:e.colors.error+`5e`,color:e.colors.error},transition:`all 0.2s`,color:e.colors.error})),actionButton:Bt(()=>({width:`full`,minHeight:`50px`,height:`fit-content`,bg:e.buttons.button.bg,borderRadius:e.borders.radius.xl,p:0,color:e.buttons.button.color,border:e.buttons.button.border===`none`?`1px solid ${e.colors.border.button}`:e.buttons.button.border,_hover:{opacity:.8,_disabled:{opacity:.5,bg:e.buttons.button.bg}},_disabled:{opacity:.5,cursor:`not-allowed`,bg:e.buttons.button.bg},transition:`all 0.2s`})),ghost:Bt(()=>({bg:`transparent`,color:e.colors.text.primary,border:`none`,_hover:{bg:e.buttons.button.bg},_active:{bg:e.buttons.button.bg,opacity:.8},transition:`all 0.2s`})),link:Bt(()=>({color:e.colors.text.primary,_hover:{color:e.colors.text.secondary,textDecoration:`underline`},_active:{color:e.colors.text.primary},transition:`all 0.2s`}))}),Hu=e=>Vt({baseStyle:Bu,variants:Vu(e)}),{definePartsStyle:Uu,defineMultiStyleConfig:Wu}=Rt(la.keys),Gu=e=>({vechainKitBase:Uu({popper:{zIndex:1e3},content:{borderRadius:e.borders.radius.xl,border:`none`,backgroundColor:e.colors.background.modal,boxShadow:`0px 4px 16px rgba(0, 0, 0, 0.12)`,minWidth:`380px`},body:{padding:`16px`}})}),Ku=e=>Wu({variants:Gu(e),defaultProps:{variant:`vechainKitBase`}}),qu=(e,t)=>({useSystemColorMode:!1,disableTransitionOnChange:!1,components:{Modal:Fu(t),Card:zu(t),Button:Hu(t),Popover:Ku(t)},styles:{global:()=>({})},semanticTokens:{colors:{"chakra-placeholder-color":t.colors.text.tertiary,"vechain-kit-modal":t.colors.background.modal,"vechain-kit-overlay":t.colors.background.overlay,"vechain-kit-card":e?`rgba(0, 0, 0, 0.3)`:`rgba(0, 0, 0, 0.05)`,"vechain-kit-card-elevated":e?`rgba(0, 0, 0, 0.4)`:`rgba(0, 0, 0, 0.08)`,"vechain-kit-sticky-header":t.colors.background.stickyHeader,"vechain-kit-text-primary":t.colors.text.primary,"vechain-kit-text-secondary":t.colors.text.secondary,"vechain-kit-text-tertiary":t.colors.text.tertiary,"vechain-kit-border":t.colors.border.default,"vechain-kit-border-hover":t.colors.border.hover,"vechain-kit-border-focus":t.colors.border.focus,"vechain-kit-success":t.colors.success,"vechain-kit-error":t.colors.error,"vechain-kit-warning":t.colors.warning},effects:{"vechain-kit-backdrop-filter-modal":t.effects.backdropFilter.modal,"vechain-kit-backdrop-filter-overlay":t.effects.backdropFilter.overlay,"vechain-kit-backdrop-filter-sticky-header":t.effects.backdropFilter.stickyHeader},config:{cssVarPrefix:`vechain-kit`}},fonts:Ut.fonts,fontSizes:{...Ut.fontSizes,sm:t.fonts.sizes.small,md:t.fonts.sizes.medium,lg:t.fonts.sizes.large},fontWeights:{...Ut.fontWeights,normal:t.fonts.weights.normal,medium:t.fonts.weights.medium,bold:t.fonts.weights.bold},colors:Ut.colors,space:Ut.space}),Ju=(e,t)=>{let n=Ht(qu(e,Ra(La(e),za(t,e))));return n.styles.global=()=>({}),n.__cssVars&&(n.__cssVars.global=()=>({})),n},{ToastContainer:Yu}=zt(),Xu=()=>oa({key:`vechain-kit`,prepend:!0}),Zu=({bodyFont:e,headingFont:t})=>q(ia,{styles:aa`
119
+ }`,a=await fetch(r,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({operationName:`Registrations`,query:i,extensions:{}})});if(!a.ok)throw Error(`Failed to fetch domains`);let o=await a.json();return o.data&&o.data.domains&&(o.data.domains=o.data.domains.filter(e=>!e.name.endsWith(`addr.reverse`))),Ao.parse(o.data)},Mo=(e,t)=>[`VECHAIN_KIT`,`VET_DOMAINS`,e,t],No=(e,t)=>{let{network:n}=$();return X({queryKey:Mo(e,t),queryFn:()=>jo(n.type,e,t),enabled:!!e&&!!n.type,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`)||e===`address is required`)return!1}return e<2},gcTime:1e3*60*5,staleTime:1e3*60})},Po=(e,t)=>[`VECHAIN_KIT`,`VET_DOMAINS`,`AVATAR`,e,t],Fo=e=>{let{network:t}=$();return X({queryKey:Po(e??``,t.type),queryFn:async()=>e?Ur(e,{networkUrl:t.nodeUrl}):null,enabled:!!e&&!!t.type,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`))return!1}return e<2},gcTime:1e3*60*5,staleTime:1e3*60})},Io=new $t([`function resolver(bytes32 node) returns (address resolverAddress)`,`function text(bytes32 node, string key) view returns (string)`]),Lo=async(e,t,n)=>{if(!n)return{};let r=tn(n);try{let[{data:n,reverted:i}]=await(await fetch(`${e}/accounts/*`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({clauses:[{to:k(t).vetDomainsContractAddress,data:Io.encodeFunctionData(`resolver`,[r])}]})})).json();if(i)return{};let{resolverAddress:a}=Io.decodeFunctionResult(`resolver`,n);return(await(await fetch(`${e}/accounts/*`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({clauses:le.map(e=>({to:a,data:Io.encodeFunctionData(`text`,[r,e])}))})})).json()).reduce((e,{data:t,reverted:n},r)=>{if(!n&&t&&t!==`0x`)try{let n=Io.decodeFunctionResult(`text`,t)[0];n&&(e[le[r]]=n)}catch(e){console.error(`Failed to decode text record for ${le[r]}:`,e)}return e},{})}catch(e){throw console.error(`Error fetching text records:`,e),e}},Ro=(e,t)=>[`VECHAIN_KIT_TEXT_RECORDS`,e,t],zo=e=>{let{network:t}=$(),n=t.nodeUrl??k(t.type).nodeUrl;return X({queryKey:Ro(e,t.type),queryFn:()=>Lo(n,t.type,e),enabled:!!e&&!!t.type,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`))return!1}return e<2},gcTime:1e3*60*5,staleTime:1e3*60})},Bo=new $t([`function resolver(bytes32 node) returns (address resolverAddress)`,`function setText(bytes32 node, string key, string value) external`]),Vo=(e,t)=>{let n=[];for(let{domain:r,key:i,value:a}of t){if(!r)throw Error(`Domain is required`);if(!e)throw Error(`Resolver address is required`);let t=tn(r);n.push({to:e,data:Bo.encodeFunctionData(`setText`,[t,i,a]),value:`0`,comment:`Update ${i} record`})}return n},Ho=({onSuccess:e,onError:t,signerAccountAddress:n,resolverAddress:r}={})=>{let i=H(e=>{if(!r)throw Error(`Resolver address is required`);return Vo(r,e)},[r]),a=lc({signerAccountAddress:n,onTxConfirmed:async()=>{await e?.()},onTxFailedOrCancelled:async()=>{await t?.()},privyUIOptions:{title:`Update Profile Information`,description:`Update the profile information associated with your domain`,buttonText:`Sign to continue`}});return{...a,clauses:i,sendTransaction:async e=>a.sendTransaction(i(e))}},Uo=e=>[`VECHAIN_KIT`,`RESOLVER_ADDRESS`,e],Wo=e=>{let{network:t}=$();return $d({address:k(t.type).vetDomainsContractAddress,abi:ai.abi,method:`resolver`,args:[e?yi(e):`0x`],queryOptions:{select:e=>e[0],enabled:!!e}})},Go=e=>[`VECHAIN_KIT`,`VET_DOMAINS`,`AVATAR_OF_ADDRESS`,e],Ko=e=>{let{network:t}=$();return X({queryKey:Go(e),queryFn:async()=>{if(!e||!t.nodeUrl)return i(e??``);let n=await Hr(e,{networkUrl:t.nodeUrl});return n&&await Ur(n,{networkUrl:t.nodeUrl})||i(e??``)},enabled:!!e&&!!t.nodeUrl,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`))return!1}return e<2},gcTime:1e3*60*5,staleTime:1e3*60})},qo=new $t([`function resolver(bytes32 node) returns (address resolverAddress)`,`function text(bytes32 node, string key) returns (string avatar)`]),Jo=new $t([`function tokenURI(uint256 tokenId) view returns (string)`,`function uri(uint256 id) view returns (string)`]),Yo=async(e,t,n)=>{if(!n)throw Error(`Name is required`);let r=tn(n);try{let[{data:n,reverted:i}]=await(await fetch(`${t}/accounts/*`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({clauses:[{to:k(e).vetDomainsContractAddress,data:qo.encodeFunctionData(`resolver`,[r])}]})})).json();if(i)return null;let{resolverAddress:a}=qo.decodeFunctionResult(`resolver`,n),[{data:o,reverted:s}]=await(await fetch(`${t}/accounts/*`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({clauses:[{to:a,data:qo.encodeFunctionData(`text`,[r,`avatar`])}]})})).json();if(s||o===`0x`)return null;try{let{avatar:n}=qo.decodeFunctionResult(`text`,o),r=n===``?null:n;return r?Zo(r,e,t):null}catch(e){return console.error(`Failed to decode avatar data:`,e),null}}catch(e){throw console.error(`Error fetching avatar using legacy API:`,e),e}},Xo=(e,t)=>[`VECHAIN_KIT`,`VET_DOMAINS`,`AVATAR`,`LEGACY`,e,t];async function Zo(e,t,n){try{if(e.startsWith(`http`)||e.startsWith(`ipfs://`)||e.startsWith(`ar://`))return x(e,t)||null;let r=e.match(/eip155:(\d+)\/(?:erc721|erc1155):([^/]+)\/(\d+)/);if(r){let[,i,a,o]=r,s=e.includes(`erc1155`);if(!i||!a||o===void 0)return null;let c=[{to:a,data:Jo.encodeFunctionData(s?`uri`:`tokenURI`,[BigInt(o||0)])}],[{data:l,reverted:u}]=await fetch(`${n}/accounts/*`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({clauses:c})}).then(e=>e.json());if(u)return console.error(`Failed to fetch tokenURI`),null;let d=``;try{d=Jo.decodeFunctionResult(s?`uri`:`tokenURI`,l)[0]}catch(e){console.error(`Failed to decode avatar data:`,e),d=an(l)}d=x(d,t)||d,s&&(d=d.replace(`{id}`,on(rn(BigInt(o||0)),32).slice(2)));let f=await fetch(d);if(!f.ok)return console.error(`Failed to fetch metadata`),null;let p=await f.json(),m=p.image||p.image_url||p.image_data;return m?x(m,t)||m:(console.error(`No image URL in metadata`),null)}return null}catch(e){return console.error(`Error parsing avatar record:`,e),null}}const Qo=e=>{let{network:t}=$(),n=t.nodeUrl??k(t.type).nodeUrl;return X({queryKey:Xo(e??``,t.type),queryFn:async()=>e?Yo(t.type,n,e):null,enabled:!!e&&!!n&&!!t.type})},$o=si.createInterface(),es=(e,t)=>{let n=[];return n.push({to:k(t.type).vetDomainsReverseRegistrarAddress,value:`0x0`,data:$o.encodeFunctionData(`setName`,[``]),comment:`Unsetting your current VeChain nickname of the account ${l(e?.address??``,4,4)}`,abi:$o.getFunction(`setName`)}),n},ts=({onSuccess:e,onError:t})=>{let n=zn(),{account:r}=Q(),{network:i}=$(),a=H(()=>es(r,i),[r,i]),o=H(async()=>{await go(n,r?.address??``,``,``,``,i.type),e?.()},[e,n,r,i.type]),s=lc({signerAccountAddress:r?.address??``,privyUIOptions:{title:`Sign to unset your VeChain nickname`,description:`Unset your current VeChain nickname`,buttonText:`Sign to continue`},onTxConfirmed:o,onTxFailedOrCancelled:t});return{...s,clauses:a,sendTransaction:async()=>s.sendTransaction(a())}},ns=e=>{let{network:t}=$(),n=k(t.type),{data:r,isLoading:i}=sf(e),{data:a,isLoading:o}=Ss(e),{data:s,isLoading:c}=Os(e),{data:l,isLoading:u}=Es(n.veDelegateTokenContractAddress,e),{data:d,isLoading:f}=Es(n.gloDollarContractAddress,e),p=ws(e),m=p.map(e=>e.data).filter(Boolean),h=p.some(e=>e.isLoading);return{balances:W(()=>{if(!e)return[];let t={vet:`0x`,vtho:n.vthoContractAddress,b3tr:n.b3trContractAddress,vot3:n.vot3ContractAddress,veDelegate:n.veDelegate,USDGLO:n.gloDollarContractAddress},i=[{address:t.vet,symbol:`VET`,balance:r?.balance||`0`},{address:t.vtho,symbol:`VTHO`,balance:r?.energy||`0`},{address:t.b3tr,symbol:`B3TR`,balance:a?.scaled??`0`},{address:t.vot3,symbol:`VOT3`,balance:s?.scaled??`0`},{address:t.veDelegate,symbol:`veDelegate`,balance:l?.scaled??`0`},{address:t.USDGLO,symbol:`USDGLO`,balance:d?.scaled??`0`}],o=m.map(e=>({address:e?.address||``,symbol:e?.symbol||``,balance:e?.scaled||`0`}));return[...i,...o]},[e,r,a,s,l,d,m,t.type]),isLoading:i||o||c||u||f||h}},rs={B3TR:`0x623374722d757364000000000000000000000000000000000000000000000000`,VET:`0x7665742d75736400000000000000000000000000000000000000000000000000`,VTHO:`0x7674686f2d757364000000000000000000000000000000000000000000000000`,GBP:`0x6762702d75736400000000000000000000000000000000000000000000000000`,EUR:`0x657572742d757364000000000000000000000000000000000000000000000000`},is=async(e,t,n)=>{let r=await e.contracts.load(k(n).oracleContractAddress,$r.abi).read.getLatestValue(rs[t]);if(!r)throw Error(`Failed to get price of ${t}`);return new Qt(r[0].toString()).div(0xe8d4a51000).toNumber()},as=e=>[`VECHAIN_KIT_PRICE`,e],os=e=>{let t=jn(),{network:n}=$();return X({queryKey:as(e),queryFn:async()=>is(t,e,n.type),enabled:!!t&&!!n.type,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`))return!1}return e<2},gcTime:1e3*60*5,staleTime:1e3*60})},ss=()=>{let{network:e}=$(),t=k(e.type),{data:n,isLoading:r}=os(`VET`),{data:i,isLoading:a}=os(`VTHO`),{data:o,isLoading:s}=os(`B3TR`),{data:c,isLoading:l}=os(`EUR`),{data:u,isLoading:d}=os(`GBP`);return{prices:W(()=>{let e={vet:`0x`,vtho:t.vthoContractAddress,b3tr:t.b3trContractAddress,vot3:t.vot3ContractAddress,veDelegate:t.veDelegate,USDGLO:t.gloDollarContractAddress};return{[e.vet]:n||0,[e.vtho]:i||0,[e.b3tr]:o||0,[e.vot3]:o||0,[e.veDelegate]:o||0,[e.USDGLO]:1}},[n,i,o,t.vthoContractAddress,t.b3trContractAddress,t.vot3ContractAddress,t.veDelegate,t.gloDollarContractAddress]),exchangeRates:W(()=>({eurUsdPrice:c||1,gbpUsdPrice:u||1}),[c,u]),isLoading:r||a||s||l||d}},cs=`vechain_kit_currency`,ls=[`usd`,`eur`,`gbp`],us=()=>{let{defaultCurrency:e=`usd`}=$(),[t,n]=G(()=>{try{return w(cs)||e}catch(t){return console.error(t),e}});return U(()=>{h(cs,t)},[t]),{currentCurrency:t,allCurrencies:ls,changeCurrency:e=>{if(!ls.includes(e)){console.error(`Invalid currency: ${e}`);return}n(e)}}},ds=({address:e=``})=>{let{balances:t,isLoading:n}=ns(e),{prices:r,exchangeRates:i,isLoading:a}=ss(),{currentCurrency:o}=us(),s=W(()=>t.map(e=>{let t=r[e.address]||0,n=Number(e.balance)*t,a=eo(n,o,i);return{...e,priceUsd:t,valueUsd:n,valueInCurrency:a}}),[t,r,o,i]),c=W(()=>[...s].sort((e,t)=>t.valueInCurrency-e.valueInCurrency),[s]);return{tokens:s,sortedTokens:c,tokensWithBalance:W(()=>c.filter(e=>Number(e.balance)>0),[c]),isLoading:n||a}},fs=({address:e=``})=>{let{tokensWithBalance:t,isLoading:n}=ds({address:e}),{currentCurrency:r}=us(),i=W(()=>t.reduce((e,t)=>e+t.valueInCurrency,0),[t]);return{totalBalanceInCurrency:i,totalBalanceUsd:W(()=>t.reduce((e,t)=>e+t.valueUsd,0),[t]),formattedBalance:W(()=>no(i,{currency:r}),[i,r]),isLoading:n,hasAnyBalance:t.length>0}},ps=di.abi,ms=`currentRoundId`,hs=e=>Zd({abi:ps,address:e,method:ms}),gs=()=>{let{network:e}=$(),t=k(e.type).xAllocationVotingContractAddress;return $d({abi:ps,address:t,method:ms,args:[],queryOptions:{select:e=>e[0].toString()}})},_s=async(e,t)=>Jr(e,{networkUrl:t}),vs=e=>[`VECHAIN_KIT_CUSTOM_TOKEN_INFO`,e],ys=e=>{let{network:t}=$();return X({queryKey:vs(e),queryFn:async()=>{if(!e)throw Error(`Token address is required`);if(!t.nodeUrl)throw Error(`Network node URL is required`);return _s(e,t.nodeUrl)},enabled:!!t.type&&!!e,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`)||e===`token address is required`||e===`network node url is required`)return!1}return e<2},gcTime:1e3*60*5,staleTime:1e3*60})},bs=()=>{let[e,t]=fp(dp.CUSTOM_TOKENS,[]),{network:n}=$(),r=async r=>{if(!a(r)&&!s(r)){if(!n.nodeUrl)throw Error(`Network node URL is required`);let i={...await _s(r,n.nodeUrl),address:r};t([...e,i])}},i=n=>{t(e.filter(e=>e.address!==n))},a=t=>e.some(e=>o(e.address,t)),s=e=>{let t={vet:`0x`,vtho:k(n.type).vthoContractAddress,b3tr:k(n.type).b3trContractAddress,vot3:k(n.type).vot3ContractAddress,veDelegate:k(n.type).veDelegate};return Object.values(t).includes(e)};return{customTokens:e,addToken:r,removeToken:i,isTokenIncluded:a,isDefaultToken:s}},xs=e=>[`VEBETTERDAO_BALANCE`,e,`B3TR`],Ss=e=>{let{network:t}=$();return X({queryKey:xs(e),queryFn:async()=>{if(!e)throw Error(`Address is required`);let n=await Wr(e,{networkUrl:t.nodeUrl});if(!n)throw Error(`Failed to get b3tr balance`);let r=n[0];return u(r)},enabled:!!e&&!!t.type})},Cs=(e,t)=>[`VECHAIN_KIT_BALANCE`,t,`CUSTOM_TOKEN`,e],ws=e=>{let{network:t}=$(),{customTokens:n}=bs();return Rn({queries:n.map(n=>({queryKey:Cs(n.address,e),queryFn:async()=>{if(!n.address)throw Error(`Token address is required`);if(!e)throw Error(`Address is required`);if(!t.nodeUrl)throw Error(`Network node URL is required`);let r=await Kr(n.address,e,{networkUrl:t.nodeUrl});if(!r)throw Error(`Failed to get token balance`);let i=u(r[0]);return{...n,...i}}}))})},Ts=(e,t)=>[`VECHAIN_KIT`,`BALANCE`,`ERC20`,e,t],Es=(e,t)=>{let{network:n}=$();return X({queryKey:Ts(e,t),queryFn:async()=>{if(!t)throw Error(`Address is required`);let r=await Kr(e,t,{networkUrl:n.nodeUrl});if(!r)throw Error(`Failed to get vot3 balance`);let i=r[0];return u(i)},enabled:!!t&&!!n.type})},Ds=e=>[`VEBETTERDAO_BALANCE`,e,`VOT3`],Os=e=>{let{network:t}=$();return X({queryKey:Ds(e),queryFn:async()=>{if(!e)throw Error(`Address is required`);let n=await Yr(e,{networkUrl:t.nodeUrl});if(!n)throw Error(`Failed to get vot3 balance`);let r=n[0];return u(r)},enabled:!!e&&!!t.type})},ks=(e,t)=>[`VECHAIN_KIT`,`IS_PERSON`,e,t],As=e=>{let{network:t}=$();return X({queryKey:ks(e??``,t.type),queryFn:async()=>{if(!e)throw Error(`User address is required`);return qr(e,{networkUrl:t.nodeUrl})},enabled:!!e&&!!t.type,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`)||e===`user address is required`)return!1}return e<2},gcTime:1e3*60*5,staleTime:1e3*60})},js=di.abi,Ms=`getAppsOfRound`,Ns=(e,t)=>Qd({abi:js,address:k(t).xAllocationVotingContractAddress,method:Ms,args:[BigInt(e??0)]}),Ps=e=>{let{network:t}=$(),n=k(t.type).xAllocationVotingContractAddress;return $d({abi:js,address:n,method:Ms,args:[BigInt(e??0)],queryOptions:{enabled:!!e,select:e=>e[0].map(e=>({id:e.id.toString(),teamWalletAddress:e.teamWalletAddress,name:e.name,metadataURI:e.metadataURI,createdAtTimestamp:e.createdAtTimestamp.toString()}))}})},Fs=ui.abi,Is=e=>[`VECHAIN_KIT`,`XApps`,`Shares`,e],Ls=(e,t)=>{let n=jn(),{network:r}=$(),i=k(r.type).xAllocationPoolContractAddress;return X({queryKey:Is(t),queryFn:async()=>(await re({thor:n,calls:e.map(e=>({abi:Fs,functionName:`getAppShares`,address:i,args:[t,e]}))})).map((t,n)=>({app:e[n],share:Number(t[0]||0)/100,unallocatedShare:Number(t[1]||0)/100})),enabled:!!t&&!!e.length})},Rs=e=>{let{data:t}=Ps(e),n=Ls(t?.map(e=>e.id)??[],e);return{data:W(()=>n.data?.map(e=>({percentage:e.share+e.unallocatedShare,id:t?.find(t=>t.id===e.app)?.id??``,app:t?.find(t=>t.id===e.app)??{}})).sort((e,t)=>Number(t.percentage)-Number(e.percentage))??[],[n.data,t]),isLoading:n.isLoading}},zs=({error:e,mobileBrowserPopupMessage:t=`Mobile browser blocked the window. Please try again.`,rejectedMessage:n=`Request was cancelled.`,defaultMessage:r=`Operation failed`})=>{let i=e?.message;return Pi&&i&&!g(i)?Error(t):i&&g(i)?Error(n):e instanceof Error?e:Error(r)},Bs=mi({id:`1176455790972829965191905223412607679856028701100105089447013101863`,name:`Vechain`,nativeCurrency:{name:`VeChain`,symbol:`VET`,decimals:18},rpcUrls:{default:{http:[`https://mainnet.vechain.org`]}},blockExplorers:{default:{name:`Vechain Explorer`,url:`https://explore.vechain.org`},vechainStats:{name:`Vechain Stats`,url:`https://vechainstats.com`}}}),Vs=()=>Ni({id:O,name:`VeChain`,iconUrl:`https://imagedelivery.net/oHBRUd2clqykxgDWmeAyLg/661dd77c-2f9d-40e7-baa1-f4e24fd7bf00/icon`,smartWalletMode:!1}),Hs=({privyEcosystemAppIDS:e,children:t})=>q(Ti,{config:Zt(Ei({chains:[Bs],ssr:!0,connectors:[Vs(),...e.map(e=>Ni({id:e,name:``,iconUrl:``}))],transports:{[Bs.id]:Di()},multiInjectedProviderDiscovery:!1})).current,children:t}),Us=()=>{let{connectAsync:e,connectors:t}=ki(),{signTypedDataAsync:n}=Mi(),{signMessageAsync:r}=ji(),{disconnectAsync:i}=Ai(),{isConnected:a}=Oi(),[o,s]=G(!1),[c,l]=G(null),u=H(async()=>{try{a&&(await i(),y()&&window.dispatchEvent(new Event(`wallet_disconnected`)))}catch(e){throw console.error(`Error during logout:`,e),e}},[i,a]);return{login:H(async n=>{try{s(!0),l(null);let r=t.find(e=>e.id===(n||O));if(!r)throw Error(`Connector not found`);return await e({connector:r})}catch(e){throw l(e),e}finally{s(!1)}},[e,t]),logout:u,signMessage:H(async e=>{try{return await r({message:e})}catch(e){throw zs({error:e,mobileBrowserPopupMessage:`Your mobile browser blocked the signing window. Please click 'Try again' to open the signing window or change your browser settings.`,rejectedMessage:`Signing request was cancelled.`,defaultMessage:`An unexpected issue occurred while signing a message. Please try again or contact support.`})}},[r]),signTypedData:H(async e=>{try{return await n(e)}catch(e){throw zs({error:e,mobileBrowserPopupMessage:`Your mobile browser blocked the signing window. Please click 'Try again' to open the signing window or change your browser settings.`,rejectedMessage:`Signing request was cancelled.`,defaultMessage:`An unexpected issue occurred while signing typed data. Please try again or contact support.`})}},[n]),isConnecting:o,connectionError:c}},Ws=(e,t)=>{let{data:n,isLoading:r}=uo(e??``),{data:i,isLoading:a}=Ko(e??``),{data:o,isLoading:s}=zo(n?.domain??``),c=o?.header?x(o.header,t):null;return{domain:n?.domain,image:i,records:{...o,header:c},isLoading:r||a||s}},Q=()=>{let{address:e,isConnected:t,isConnecting:n,isReconnecting:r}=Oi(),{logout:i}=Us(),{loading:a}=xn({}),{feeDelegation:s,network:c,privy:l}=$(),{user:u,authenticated:d,logout:f,ready:p}=Tn(),{data:m}=Gf(),{account:h,disconnect:g}=Mn(),{getConnectionCache:_,clearConnectionCache:v}=Ud(),b=_(),x=tf(),S=!!h,C=d&&!!u,w=C||t,ee=C&&l?.appId===O||t&&b?.ecosystemApp?.appId===O,T=n||r||a||!p,[E,D]=G(!1),te=t?{type:`privy-cross-app`,displayName:`Ecosystem`}:S?{type:`wallet`,displayName:`Wallet`}:{type:`privy`,displayName:`Social Login`};U(()=>{let e=S||C||t;E!==e&&(D(e),e||(v(),y()&&window.dispatchEvent(new Event(`wallet_disconnected`))))},[S,C,t,v,E]);let ne=u?.linkedAccounts?.find(e=>e.type===`wallet`&&e.connectorType===`embedded`)?.address,re=S?h:t?e:ne,{data:ie}=jf(re),ae=S?h:ie?.address,oe=Ws(ae??``,c.type),se=Ws(re??``,c.type),k=Ws(ie?.address??``,c.type),ce=ae?{address:ae,domain:oe.domain,image:oe.image,isLoadingMetadata:oe.isLoading,metadata:oe.records}:null,le=re?{address:re,domain:se.domain,image:se.image,isLoadingMetadata:se.isLoading,metadata:se.records}:null,{data:ue}=yf(ie?.address??``,le?.address??``),de=!!ie?.address&&!!ce?.address&&o(ie?.address,ce?.address),fe=H(async()=>{try{D(!1),S?g():C?await f():t&&await i(),v(),y()&&window.dispatchEvent(new Event(`wallet_disconnected`))}catch(e){console.error(`Error during disconnect:`,e)}},[S,g,C,f,t,i,v]);return{account:ce,smartAccount:{address:ie?.address??``,domain:k.domain,image:k.image,isDeployed:ie?.isDeployed??!1,isActive:de,version:ue?.version??null,isLoadingMetadata:k.isLoading,metadata:k.records},connectedWallet:le,privyUser:u,connection:{isLoading:T,isConnected:E,isConnectedWithSocialLogin:C,isConnectedWithDappKit:S,isConnectedWithCrossApp:t,isConnectedWithPrivy:w,isConnectedWithVeChain:ee,source:te,isInAppBrowser:(y()&&window.vechain&&window.vechain.isInAppBrowser)??!1,nodeUrl:x,delegatorUrl:s?.delegatorUrl,chainId:m,network:c.type},disconnect:fe}},Gs=()=>{let e=zn(),{account:t}=Q();return{refresh:async()=>{let n=t?.address??``;await Promise.all([e.invalidateQueries({queryKey:[`VECHAIN_KIT_BALANCE`,n]}),e.invalidateQueries({queryKey:[`VECHAIN_KIT_PRICE`]})])}}},Ks=async(e,t)=>{let n=x(e,t)||``,r=await fetch(n,{signal:AbortSignal.timeout(2e4)});if(!r.ok)throw Error(`HTTP error! status: ${r.status}`);return await r.json()},qs=li.abi,Js=e=>{let t=jn(),{network:n}=$();return X({queryKey:[`xAppMetaData`,e],queryFn:async()=>{let r=k(n.type).x2EarnAppsContractAddress,i=t.contracts.load(r,qs),[a]=await i.read.app(e),o=a.metadataURI||``,[s]=await i.read.baseURI();return await Ks(`${s}${o}`,n.type)}})},Ys=async(e,t,n=!1)=>{if(!t)throw Error(`No URI provided`);let r=x(t,e);if(!r)throw Error(`Invalid URI`);let i=await(await fetch(r,{headers:{"X-Project-Id":`vechain-kit`}})).text();return n?JSON.parse(i):i},Xs=(e,t)=>[`VECHAIN_KIT`,`IPFS_METADATA`,e,t],Zs=(e,t=!1)=>{let{network:n}=$();return X({queryKey:Xs(n.type,e),queryFn:()=>Ys(n.type,e,t),enabled:!!e&&!!n.type,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`)||e===`no uri provided`||e===`invalid uri`)return!1}return e<2},staleTime:1/0})},Qs=1024*1024*10,$s=async(e,t)=>{if(!t)throw Error(`IPFS URI is required`);let n=await fetch(x(t,e)??``,{headers:{"X-Project-Id":`vechain-kit`}});if(!n.ok)throw Error(`HTTP error! status: ${n.status}`);let r=await n.blob();if(![`image/jpeg`,`image/jpg`,`image/png`,`image/gif`,`image/bmp`,`image/tiff`,`image/webp`,`image/svg+xml`].includes(r.type))throw Error(`Unsupported MIME type: ${r.type}`);if(r.size>Qs)throw Error(`Image size exceeds maximum allowed size`);return new Promise((e,t)=>{let n=new FileReader;n.readAsDataURL(r),n.onloadend=()=>{e({image:n.result,mime:r.type,mediaType:b(r.type)})},n.onerror=()=>{t(Error(`Error occurred while reading blob.`))}})},ec=(e,t)=>[`VECHAIN_KIT`,`IPFS_IMAGE`,e,t],tc=e=>{let{network:t}=$();return X({queryKey:ec(t.type,e),queryFn:()=>$s(t.type,e),enabled:!!e&&!!t.type,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`)||e===`ipfs uri is required`)return!1}return e<2},staleTime:1/0})},nc=e=>{let{network:t}=$();return Rn({queries:e.map(e=>({queryKey:ec(t.type,e),queryFn:()=>$s(t.type,e),enabled:!!e&&!!t.type,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`)||e===`ipfs uri is required`)return!1}return e<2},staleTime:1/0}))})},rc=(e,t=!1)=>{let{network:n}=$();return Rn({queries:e.map(e=>({queryKey:Xs(n.type,e),queryFn:async()=>Ys(n.type,e,t),enabled:!!e&&!!n.type,retry:(e,t)=>{if(t instanceof Error){let e=t.message.toLowerCase();if(e.includes(`cancel`)||e.includes(`abort`)||e===`no uri provided`||e===`invalid uri`)return!1}return e<2},staleTime:1/0}))})},ic={maxSizeMB:.4,maxWidthOrHeight:1920,useWebWorker:!0},ac=async e=>{let t=[];try{for(let n of e){let e=await Fi(n.file,ic);t.push(e)}return t}catch(e){throw console.error(`compress error`,e),e}},oc=({compressImages:e,defaultImages:t})=>{let[n,r]=G(t??[]);U(()=>{t&&r(t)},[t]);let[i,a]=G([]),o=H(e=>r(t=>t.filter((t,n)=>n!==e)),[]);return{uploadedImages:n,setUploadedImages:r,onUpload:H(async(t,n=!0)=>{a([]);let i=[];for(let n of t){let t=n;e&&(t=await Fi(n,ic));let r={file:t,image:URL.createObjectURL(n)};i.push(r)}r(e=>[...i,...n?e.filter(e=>!i.some(t=>t.file.name===e.file.name)):[]])},[e]),onRemove:o,invalidDateError:i}},sc=({compressImage:e,defaultImage:t})=>{let[n,r]=G(t);U(()=>{t&&r(t)},[t]);let i=H(()=>r(void 0),[]);return{uploadedImage:n,setUploadedImage:r,onUpload:H(async t=>{let n=t;e&&(n=await Fi(n,ic));let i={file:n,image:URL.createObjectURL(n)};return r(i),i},[e]),onRemove:i}},cc=async(e,t,n,r)=>{let i=await e.transactions.estimateGas(t,n,r);if(i.reverted)throw Error(`Failed to estimate gas`);let a=i?.totalGas??0;return(!a||Number.isNaN(a))&&(a=0),Math.ceil(a)},lc=({signerAccountAddress:e,clauses:t,onTxConfirmed:n,onTxFailedOrCancelled:r,suggestedMaxGas:i,privyUIOptions:a,gasPadding:o})=>{let s=jn(),{signer:c}=Nn(),{connection:l}=Q(),{feeDelegation:u}=$(),d=tf(),f=Jp(),p=H(async(t,n)=>{let r=typeof t==`function`?await t():t??[];if(l.isConnectedWithPrivy)return await f.sendTransaction({txClauses:r,...a,...n});if(!e)throw Error(`signerAccountAddress is required`);let d=0;try{d=await cc(s,[...r],e,{revision:dn.NEXT,...o?{gasPadding:o}:{}})}catch(e){console.error(`Gas estimation failed`,e)}let p=await s.transactions.buildTransactionBody(r,i??d,{isDelegated:u?.delegateAllTransactions}),m=Bi.transactionBodyToTransactionRequestInput(p,e);return c.sendTransaction({...m,maxPriorityFeePerGas:m.maxPriorityFeePerGas?.toString(),maxFeePerGas:m.maxFeePerGas?.toString()})},[e,i,d,f,a]),[m,h]=G(null),[g,_]=G(!1),[v,y]=G(null),b=H(async e=>{if(!e&&!t)throw Error(`clauses are required`);try{h(null),_(!0),y(null),T(void 0),h(await p(e??[],{...a}))}catch(e){y(e&&typeof e==`object`&&`message`in e?e.message:String(e)),r?.(e instanceof Error?e:Error(String(e)))}finally{_(!1)}},[p,t,a]),{data:x,isLoading:S,error:C}=rp(m??``),w=H(async e=>{if(!(!e.reverted||!e.meta.txID))return await s.transactions.getRevertReason(e.meta.txID)},[s]),[ee,T]=G(),E=W(()=>{if(g)return`pending`;if(v)return`error`;if(m){if(S)return`waitingConfirmation`;if(C)return`error`;if(x)return x.reverted?`error`:`success`}return`ready`},[S,v,g,m,x,C]);U(()=>{if(E===`success`||E===`error`){if(v&&!ee){T({type:`UserRejectedError`,reason:v});return}if(x?.reverted&&!ee?.type){(async()=>{let e=await w(x);T({type:`RevertReasonError`,reason:e?`Transaction reverted with: `+e:`Transaction reverted`})})();return}x&&!x.reverted&&n?.()}},[E,x,n,w,v]);let D=H(()=>{h(null),_(!1),y(null),T(void 0)},[]);return{sendTransaction:b,isTransactionPending:W(()=>g||S||E===`pending`||E===`waitingConfirmation`,[g,S,E]),isWaitingForWalletConfirmation:W(()=>E===`pending`,[g,E]),txReceipt:x??null,status:E,resetStatus:D,error:ee}},uc=(e,t)=>{let{account:n}=Q(),{t:r}=Y(),{sendTransaction:i,isTransactionPending:a,isWaitingForWalletConfirmation:o,txReceipt:s,status:c,resetStatus:l,error:u}=lc({signerAccountAddress:n?.address??``,privyUIOptions:{title:r(`ConfirmSwapTitle`,{defaultValue:`Confirm Swap`}),description:r(`ConfirmSwapDescription`,{defaultValue:`Please confirm the swap transaction in your wallet`}),buttonText:r(`Confirm`,{defaultValue:`Confirm`})}});return{executeSwap:H(async()=>{if(!e||!t)throw Error(`Missing swap parameters or quote`);if(!t.aggregator)throw Error(`Aggregator not found for quote from ${t.aggregatorName}`);let n=await t.aggregator.buildSwapTransaction(e,t);if(n.length===0)throw Error(`Failed to build swap transaction`);await i(n)},[e,t,i]),isTransactionPending:a,isWaitingForWalletConfirmation:o,txReceipt:s,status:c,resetStatus:l,error:u}},dc=e=>e===`0x`||e===`0x0000000000000000000000000000000000000000`,fc=()=>BigInt(Math.floor(Date.now()/1e3)+1200),pc=e=>{let t={name:e.name,getIcon:e.getIcon,async getQuote(n,r){let i=[dc(n.fromTokenAddress)?e.wrappedVET:n.fromTokenAddress,dc(n.toTokenAddress)?e.wrappedVET:n.toTokenAddress],a=BigInt(n.amountIn);try{let[o]=await r.contracts.load(e.routerAddress,ii.abi).read.getAmountsOut(a,i),s=Array.isArray(o)?o:[o],c=s[s.length-1];if(!c||c===0n)throw Error(`Output amount is zero or invalid`);if(typeof c!=`bigint`)throw Error(`Output amount is not a valid bigint`);let l=n.slippageTolerance||1,u=c*BigInt(1e4-l*100)/BigInt(1e4);return{aggregatorName:e.name,aggregator:t,outputAmount:c,priceImpact:0,minimumOutputAmount:u,data:{path:i,routerAddress:e.routerAddress}}}catch(n){return console.error(`${e.name} getQuote failed:`,n),{aggregatorName:e.name,aggregator:t,outputAmount:0n,priceImpact:0,minimumOutputAmount:0n,data:{path:i,routerAddress:e.routerAddress}}}},async simulateSwap(e,t,n){try{let r=await this.buildSwapTransaction(e,t);if(r.length===0)return{gasCostVTHO:0,success:!1,error:`Failed to build transaction clauses`};let i=await n.transactions.simulateTransaction(r,{caller:e.userAddress}),a=!1,o,s=2e5;for(let e=0;e<i.length;e++){let t=i[e];if(t.reverted){a=!0,o=t.vmError||`Transaction reverted`;break}s+=t.gasUsed}let c=s/1e5;return a?{gasCostVTHO:0,success:!1,error:o||`Transaction reverted`}:{gasCostVTHO:c,success:!0}}catch(e){return{gasCostVTHO:0,success:!1,error:e instanceof Error?e.message:`Simulation failed`}}},async buildSwapTransaction(t,n){if(!n.data||typeof n.data!=`object`||!(`path`in n.data))throw Error(`Invalid quote data`);let r=fc();if(!n.minimumOutputAmount||n.minimumOutputAmount===0n)throw Error(`Invalid quote: minimumOutputAmount is missing or zero`);let i=n.minimumOutputAmount,a=BigInt(t.amountIn);if(i===0n)throw Error(`Invalid quote: minimumOutputAmount is zero`);let o=dc(t.fromTokenAddress),s=dc(t.toTokenAddress),c=sn.ofAbi(ii.abi),l=[];if(o)l.push(ln.callFunction(cn.of(e.routerAddress),c.getFunction(`swapExactETHForTokens`),[i.toString(),n.data.path,t.userAddress,r.toString()],mn.of(a,pn.wei),{comment:`Swap on ${n.aggregatorName}`}));else{let o=sn.ofAbi(Qr.abi),u=cn.of(t.fromTokenAddress),d=cn.of(e.routerAddress);l.push(ln.callFunction(u,o.getFunction(`approve`),[d.toString(),a.toString()],mn.of(0n,pn.wei),{comment:`Swap on ${n.aggregatorName}`})),s?l.push(ln.callFunction(d,c.getFunction(`swapExactTokensForETH`),[a.toString(),i.toString(),n.data.path,t.userAddress,r.toString()],mn.of(0n,pn.wei),{comment:`Swap on ${n.aggregatorName}`})):l.push(ln.callFunction(d,c.getFunction(`swapExactTokensForTokens`),[a.toString(),i.toString(),n.data.path,t.userAddress,r.toString()],mn.of(0n,pn.wei),{comment:`Swap on ${n.aggregatorName}`}))}return l}};return t},mc={main:{routerAddress:`0xf21Dd7108D93af56FaB07423EfB90F4a3604DA89`,wrappedVET:`0xf9b02b47694fd635A413F16dC7B38aF06Cc16fe5`},test:{routerAddress:Ci,wrappedVET:Ci},solo:{routerAddress:Ci,wrappedVET:Ci}},hc=e=>{let t=mc[e]??mc.main;return pc({name:`BetterSwap.io`,routerAddress:t.routerAddress,wrappedVET:t.wrappedVET,getIcon:(e=`20px`)=>V.createElement(Te,{boxSize:e})})},gc={main:{routerAddress:`0xE5fA980a6EfE5B79C2150a529da06AeF455963b6`,wrappedVET:Ci},test:{routerAddress:Ci,wrappedVET:Ci},solo:{routerAddress:Ci,wrappedVET:Ci}},_c=e=>{let t=gc[e]??gc.main;return pc({name:`VeTrade.vet`,routerAddress:t.routerAddress,wrappedVET:t.wrappedVET,getIcon:(e=`20px`)=>V.createElement(Ae,{boxSize:e})})},vc=e=>[hc(e),_c(e)],yc=(e,t,n,r,i=1,a=!0)=>{let o=jn(),{connection:s}=Q(),c=e?.address??null,l=t?.address??null,{data:u}=ys(c===`0x`||c===Ci||!c?``:c),{data:d}=ys(l===`0x`||l===Ci||!l?``:l),f=W(()=>!c||c===`0x`||c===Ci||!u?18:Number(u?.decimals??18),[c,u?.decimals]),p=W(()=>!l||l===`0x`||l===Ci||!d?18:Number(d?.decimals??18),[l,d?.decimals]),m=W(()=>{if(!c||!l||!n||!r)return null;let e;try{e=xi(n,f)}catch(e){return console.error(`Failed to parse amount:`,n,e),null}return e<=0n?null:{fromTokenAddress:c,toTokenAddress:l,amountIn:e.toString(),userAddress:r,slippageTolerance:i}},[c,l,n,r,i,f]),{data:h,isLoading:g,error:_}=X({queryKey:[`unified-swap-quotes`,m,s.network],queryFn:async()=>{if(!m||!o||!s.network)return{quotes:[],best:null};let e=vc(s.network).map(async e=>{try{let t=await e.getQuote(m,o);try{let n=await e.simulateSwap(m,t,o);return{...t,aggregator:e,reverted:!n.success,revertReason:n.error,gasCostVTHO:n.gasCostVTHO}}catch(n){return console.error(`Failed to simulate swap for ${e.name}:`,n),{...t,aggregator:e,reverted:!0,revertReason:n instanceof Error?n.message:`Simulation failed`,gasCostVTHO:0}}}catch(t){return console.error(`Failed to get quote from ${e.name}:`,t),null}}),t=(await Promise.all(e)).filter(e=>e!==null&&e.outputAmount!==0n),n=null;if(t.length>0){let e=t.filter(e=>!(e.reverted??!1));n=(e.length>0?e:t).reduce((e,t)=>{let n=BigInt(e.outputAmount||`0`);return BigInt(t.outputAmount||`0`)>n?t:e})}return{quotes:t,best:n}},enabled:a&&m!==null&&o!=null,refetchInterval:1e4});return{bestQuote:h?.best??null,quotes:h?.quotes??[],isLoading:g,error:_,from:e?{...e,address:c??``,decimals:f}:null,to:t?{...t,address:l??``,decimals:p}:null}},bc=({email:e,onResend:t,isLoading:n,isOpen:r,onClose:i})=>{let{t:a}=Y(),{darkMode:o}=$(),s=B(`colors`,`vechain-kit-text-secondary`),[c,l]=G(``),[u,d]=G(null),{createWallet:f}=yn(),{loginWithCode:p}=bn({onComplete:async({isNewUser:e})=>{e&&await f()}});return U(()=>{c.length===6&&p({code:c}).then(()=>{i()}).catch(e=>{d(e.message)})},[c]),J($a,{isOpen:r,onClose:i,trapFocus:!1,children:[J(Z,{children:[q(L,{alignItems:`center`,display:`flex`,gap:2,children:a(`Enter confirmation code`)}),q(F,{})]}),J(tt,{maxW:`container.lg`,children:[q(P,{children:J(z,{spacing:2,children:[q(N,{as:Sr,w:`48px`,h:`48px`,color:s}),q(R,{fontSize:`xs`,color:s,textAlign:`center`,children:a(`Please check {{email}} for an email from privy.io and enter your code below.`,{email:e})}),q(M,{spacing:2,justify:`center`,mt:4,children:J(xt,{value:c,onChange:l,otp:!0,size:`lg`,isInvalid:!!u,errorBorderColor:`#ef4444`,children:[q(St,{borderRadius:`12px`,border:`1px solid ${o?`#ffffff29`:`#ebebeb`}`,_hover:{border:`1px solid ${o?`#ffffff40`:`#e0e0e0`}`},_focus:{border:`1px solid ${o?`#ffffff60`:`#d0d0d0`}`,boxShadow:`none`},backgroundColor:o?`transparent`:`#ffffff`}),q(St,{borderRadius:`12px`,border:`1px solid ${o?`#ffffff29`:`#ebebeb`}`,_hover:{border:`1px solid ${o?`#ffffff40`:`#e0e0e0`}`},_focus:{border:`1px solid ${o?`#ffffff60`:`#d0d0d0`}`,boxShadow:`none`},backgroundColor:o?`transparent`:`#ffffff`}),q(St,{borderRadius:`12px`,border:`1px solid ${o?`#ffffff29`:`#ebebeb`}`,_hover:{border:`1px solid ${o?`#ffffff40`:`#e0e0e0`}`},_focus:{border:`1px solid ${o?`#ffffff60`:`#d0d0d0`}`,boxShadow:`none`},backgroundColor:o?`transparent`:`#ffffff`}),q(St,{borderRadius:`12px`,border:`1px solid ${o?`#ffffff29`:`#ebebeb`}`,_hover:{border:`1px solid ${o?`#ffffff40`:`#e0e0e0`}`},_focus:{border:`1px solid ${o?`#ffffff60`:`#d0d0d0`}`,boxShadow:`none`},backgroundColor:o?`transparent`:`#ffffff`}),q(St,{borderRadius:`12px`,border:`1px solid ${o?`#ffffff29`:`#ebebeb`}`,_hover:{border:`1px solid ${o?`#ffffff40`:`#e0e0e0`}`},_focus:{border:`1px solid ${o?`#ffffff60`:`#d0d0d0`}`,boxShadow:`none`},backgroundColor:o?`transparent`:`#ffffff`}),q(St,{borderRadius:`12px`,border:`1px solid ${o?`#ffffff29`:`#ebebeb`}`,_hover:{border:`1px solid ${o?`#ffffff40`:`#e0e0e0`}`},_focus:{border:`1px solid ${o?`#ffffff60`:`#d0d0d0`}`,boxShadow:`none`},backgroundColor:o?`transparent`:`#ffffff`})]})}),u&&q(R,{color:`#ef4444`,fontSize:`xs`,children:u})]})}),q(I,{children:J(R,{w:`100%`,textAlign:`center`,fontSize:`14px`,color:o?`whiteAlpha.700`:`gray.600`,children:[a(`Didn't get an email?`),` `,q(j,{variant:`link`,color:`blue.500`,fontSize:`14px`,onClick:t,isLoading:n,children:a(`Resend code`)})]})})]})]})},xc=()=>{let{t:e}=Y(),{darkMode:t}=$(),[n,r]=G(``),{sendCode:i,state:a}=bn({}),o=Gt(),s=async()=>{await i({email:n}),o.onOpen()};return J(K,{children:[q(st,{colSpan:4,w:`full`,children:q(z,{spacing:3,w:`full`,children:J(ft,{size:`lg`,w:`full`,children:[q(pt,{pointerEvents:`none`,height:`100%`,pl:4,children:q(N,{as:Sr,color:t?`whiteAlpha.600`:`blackAlpha.700`,w:`20px`,h:`20px`})}),q(dt,{placeholder:e(`your@email.com`),value:n,onChange:e=>r(e.target.value),fontSize:`16px`,fontWeight:`400`,backgroundColor:t?`transparent`:`#ffffff`,border:`1px solid ${t?`#ffffff0a`:`#ebebeb`}`,p:6,borderRadius:16,w:`full`,pl:12}),q(j,{"aria-label":`Send code`,position:`absolute`,right:2,top:`50%`,transform:`translateY(-50%)`,zIndex:2,variant:`ghost`,size:`sm`,px:6,borderRadius:`full`,isLoading:a.status===`sending-code`,onClick:s,children:e(`Submit`)})]})})}),q(bc,{isOpen:o.isOpen,onClose:o.onClose,onResend:()=>i({email:n}),email:n,isLoading:a.status===`sending-code`})]})},Sc=({isDark:e,gridColumn:t})=>{let{t:n}=Y(),{initOAuth:r}=Hd();return q(st,{colSpan:t??4,w:`full`,children:q(mu,{isDark:e,onClick:async()=>{await r({provider:`google`})},icon:Vi,text:n(`Continue with Google`)})})},Cc=({isDark:e,gridColumn:t})=>{let{t:n}=Y(),{initOAuth:r}=Hd();return q(st,{colSpan:t??4,w:`full`,children:q(mu,{isDark:e,onClick:async()=>{await r({provider:`github`})},icon:gr,text:n(`Continue with Github`)})})},wc=({isDark:e,gridColumn:t})=>{let{t:n}=Y(),{login:r}=wn();return q(st,{colSpan:t||4,w:`full`,children:q(mu,{isDark:e,onClick:r,icon:e?ge:Pe,text:n(`Use social login with VeChain`),variant:`loginWithVechain`,rightIcon:q(yu,{})})})},Tc=({isDark:e,gridColumn:t})=>{let{t:n}=Y(),{login:r}=Wd(),[i,a]=G(),o=Gt(),s=async()=>{o.onOpen();try{a(void 0),await r(),o.onClose()}catch(e){console.error(n(`Login failed:`),e),a(e instanceof Error?e.message:n(`Failed to connect with VeChain`))}};return J(K,{children:[q(st,{colSpan:t||4,w:`full`,children:q(mu,{isDark:e,onClick:s,icon:e?ge:Pe,text:n(`Use social login with VeChain`),variant:`loginWithVechain`,rightIcon:q(yu,{})})}),q(Su,{isOpen:o.isOpen,onClose:()=>{o.onClose()},onTryAgain:()=>{s()},error:i,title:n(`Connecting to VeChain`),loadingText:n(`Please approve the request in the connection request window...`)})]})},Ec=({isDark:e,gridColumn:t})=>{let{t:n}=Y(),{loginWithPasskey:r}=Bd(),[i,a]=G(),o=Gt(),s=async()=>{o.onOpen();try{a(void 0),await r(),o.onClose()}catch(e){(e instanceof Error?e.message.toLowerCase():``).includes(`not found`)&&(console.error(e),a(e instanceof Error?e.message:n(`Failed to connect with Passkey`)))}};return J(K,{children:[q(st,{colSpan:t,w:`full`,children:q(mu,{isDark:e,onClick:s,icon:pr,text:t&&t>=2?n(`Passkey`):void 0})}),q(Su,{isOpen:o.isOpen,onClose:()=>{o.onClose()},error:i,title:n(`Connecting with Passkey`),loadingText:n(`Please complete the passkey authentication...`),onTryAgain:()=>{s()}})]})},Dc=({isDark:e,gridColumn:t=2})=>{let{t:n}=Y(),{open:r,onConnectionStatusChange:i}=Pn(),{dappKit:a}=$(),{source:o}=Nn(),s=a?.allowedWallets?.includes(`sync2`)?n(`Connect wallet`):n(`Connect with VeWorld wallet`);return U(()=>{i((e,t)=>{if(!e)return t?.message&&console.error(t?.message),{...o&&{source:o}}})},[i]),q(st,{colSpan:t||2,w:`full`,children:q(mu,{isDark:e,onClick:()=>{r()},icon:a?.allowedWallets?.includes(`sync2`)?Br:e?Ee:he,iconWidth:`27px`,text:t>=2?s:void 0,rightIcon:a?.allowedWallets?.includes(`sync2`)&&q(N,{as:qn})||void 0})})},Oc=({isDark:e,onViewMoreLogin:t,gridColumn:n})=>{let{t:r}=Y();return q(st,{colSpan:n,w:`full`,children:q(mu,{isDark:e,onClick:t,icon:dr,text:n&&n>=2?r(`More`):void 0,rightIcon:q(N,{as:qn})})})},kc=()=>{let{loginMethods:e,darkMode:t}=$(),{login:n}=wn(),{showGoogleLogin:r,showEmailLogin:i,showPasskey:a,showVeChainLogin:o,showDappKit:s,showMoreLogin:c,showGithubLogin:l,isOfficialVeChainApp:u}=Nd();return q(jt,{spacing:4,w:`full`,align:`center`,children:q(ot,{templateColumns:`repeat(4, 1fr)`,gap:2,w:`full`,children:e?.map(({method:e,gridColumn:d})=>{switch(e){case`email`:return i&&q(xc,{},`email`);case`google`:return r&&q(Sc,{isDark:t,gridColumn:d},`google`);case`github`:return l&&q(Cc,{isDark:t,gridColumn:d},`github`);case`vechain`:return o&&q(u?wc:Tc,{isDark:t,gridColumn:d},`vechain`);case`passkey`:return a&&q(Ec,{isDark:t,gridColumn:d},`passkey`);case`dappkit`:return s&&q(Dc,{isDark:t,gridColumn:d},`dappkit`);case`more`:return c&&q(Oc,{isDark:t,onViewMoreLogin:n,gridColumn:d},`more`);default:return null}})})})},Ac=({appsInfo:e,isLoading:t})=>{let{t:n}=Y(),r=Gt();return J(K,{children:[q(j,{fontSize:`sm`,variant:`link`,onClick:()=>{r.onOpen()},children:n(`Already have an x2earn app wallet?`)}),q(Eu,{isOpen:r.isOpen,onClose:r.onClose,appsInfo:e,isLoading:t})]})},jc=({setCurrentContent:e,onClose:t})=>{let{t:n}=Y(),{connection:r}=Q(),{loginModalUI:i,darkMode:a}=$(),{loginMethods:o,privyEcosystemAppIDS:s}=$(),{data:c,isLoading:l}=oo(s),u=B(`colors`,`vechain-kit-text-secondary`),d=()=>{e(`faq`)};U(()=>{r.isConnected&&t()},[r.isConnected,t]);let f=o?.some(({method:e})=>e===`ecosystem`);return J(K,{children:[J(Z,{children:[q(Dp,{onClick:d}),q(L,{children:n(`Log in or sign up`)}),q(F,{})]}),i?.logo&&q(M,{justify:`center`,children:q(ut,{src:i.logo||`/images/favicon.png`,maxW:`180px`,maxH:`90px`,m:8,alt:`logo`})}),J(P,{children:[i?.description&&q(M,{spacing:4,w:`full`,justify:`center`,mb:`24px`,px:4,children:q(R,{color:u,fontSize:`sm`,textAlign:`center`,children:i?.description})}),q(kc,{})]}),f?q(I,{children:q(M,{justify:`center`,w:`full`,children:q(Ac,{isDark:a,appsInfo:Object.values(c||{}),isLoading:l})})}):q(I,{pt:0,pb:`5px`})]})},Mc=({onClick:e,...t})=>{let{smartAccount:n,connectedWallet:r,connection:i}=Q(),[a,o]=G(!1);U(()=>{o(!localStorage.getItem(`app-first-visit`))},[]);let{data:s}=Pf(n?.address??``,r?.address??``,3),c=i.isConnectedWithPrivy&&s,l=()=>{a&&(localStorage.setItem(`app-first-visit`,`true`),o(!1)),e()};return q(lt,{"aria-label":`Notifications`,size:`sm`,variant:`ghost`,position:`absolute`,borderRadius:`50%`,left:`10px`,top:`10px`,onClick:l,icon:J(A,{position:`relative`,children:[q(N,{as:jr,fontSize:`18px`}),c&&q(A,{position:`absolute`,top:`-1px`,right:`-1px`,minWidth:`8px`,height:`8px`,bg:`red.500`,borderRadius:`full`})]}),...t})},Nc=({setCurrentContent:e,wallet:t,onClose:n})=>{let{t:r}=Y(),{network:i}=$();return J(Op,{children:[J(Z,{children:[q(Mc,{onClick:()=>{e(`settings`)},"data-testid":`settings-button`}),J(L,{children:[r(`Wallet`),i?.type!==`main`&&q(Nt,{size:`xs`,colorScheme:`orange`,fontSize:`2xs`,p:1,ml:1,textTransform:`uppercase`,children:`${i?.type}`})]}),q(F,{})]}),q(P,{w:`full`,children:J(z,{w:`full`,overflow:`hidden`,justifyContent:`flex-start`,spacing:6,children:[q(Ic,{style:{justifyContent:`flex-start`},onClick:()=>{e(`profile`)},setCurrentContent:e,onClose:n,wallet:t}),q(Rc,{onAssetsClick:()=>{e(`assets`)}}),q(Vc,{setCurrentContent:e})]})}),q(I,{pt:0})]})},Pc=({leftIcon:e,rightIcon:t,title:n,wallet:r,onClick:i,leftImage:a,isActive:o=!1})=>{let{t:s}=Y(),{darkMode:c}=$();return q(j,{w:`full`,minH:`70px`,h:`fit-content`,py:4,onClick:i,backgroundColor:`transparent`,border:`1px solid ${c?`#ffffff29`:`#ebebeb`}`,children:J(M,{w:`full`,justify:`space-between`,children:[q(A,{minW:`40px`,justifyContent:`center`,children:a?q(ut,{justifySelf:`center`,src:a,w:`28px`,alt:`left-image`}):q(N,{as:e,fontSize:`28px`})}),J(z,{textAlign:`left`,w:`full`,flex:1,children:[q(M,{w:`full`,spacing:2,justifyContent:`flex-start`,children:q(R,{fontSize:`sm`,fontWeight:`400`,children:n})}),q(R,{fontSize:`sm`,fontWeight:`500`,opacity:.5,overflowWrap:`break-word`,wordBreak:`break-word`,whiteSpace:`normal`,w:`full`,children:r?.domain?d(r?.domain??``,18,0):l(r?.address??``,6,4)})]}),q(z,{minW:`40px`,justifyContent:`flex-end`,children:J(M,{justifyContent:`flex-end`,minW:`40px`,children:[o&&q(Nt,{size:`sm`,colorScheme:`green`,children:s(`Active`)}),q(N,{as:t,fontSize:`20px`,opacity:.5})]})})]})})},Fc=({leftIcon:e,rightIcon:t,title:n,onClick:r,leftImage:i,hide:a=!1,showComingSoon:o=!1,backgroundColor:s,_hover:c,isDisabled:l=!1,stacked:u=!1,isLoading:d,loadingText:f,style:p,extraContent:m,dataTestId:h,variant:g=`actionButton`})=>{let{t:_}=Y();return q(j,{variant:g===`actionButton`?`vechainKitSecondary`:g,py:u?0:2,minHeight:`50px`,height:`fit-content`,p:0,onClick:r,display:a?`none`:`flex`,isDisabled:o||l,isLoading:d,loadingText:f,bgColor:s,_hover:c,"data-testid":h,...p,children:J(M,{w:`full`,justify:`space-between`,alignItems:`center`,children:[q(A,{minW:`40px`,h:`20px`,children:i?q(ut,{src:i,w:`30px`,h:`30px`,borderRadius:`full`,alt:`left-image`,alignSelf:`end`,objectFit:`cover`}):q(N,{as:e,fontSize:`20px`,h:`full`,alignContent:`center`})}),q(z,{textAlign:`left`,w:`full`,flex:1,justifyContent:`flex-start`,alignItems:`flex-start`,children:J(M,{justify:`flex-start`,alignItems:`baseline`,children:[q(R,{fontSize:`sm`,fontWeight:`400`,children:n}),o&&q(Nt,{size:`sm`,colorScheme:`red`,children:_(`Coming Soon!`)}),m]})}),t&&q(z,{minW:`40px`,justifyContent:`flex-end`,children:q(N,{as:t,fontSize:`20px`,opacity:.5})})]})})},Ic=({wallet:e,setCurrentContent:t,size:n=`md`,onClick:r,onClose:i,mt:a,style:o})=>{let[s,c]=G(!1),{disconnect:u}=Q(),f=async()=>{await ie(e?.domain??e?.address??``)&&(c(!0),setTimeout(()=>{c(!1)},2e3))},p=()=>{u(),i()};return J(M,{mt:a,w:`full`,...o,justifyContent:`flex-start`,alignItems:`center`,children:[q(j,{w:`full`,h:12,"aria-label":`Wallet`,onClick:r,variant:`vechainKitSecondary`,p:3,"data-testid":`profile-button`,children:J(M,{spacing:2,align:`center`,justifyContent:`space-between`,w:`full`,children:[J(M,{spacing:2,justifyContent:`flex-start`,children:[q(kp,{wallet:e,props:{width:7,height:7}}),q(R,{fontSize:n,fontWeight:`500`,children:d(e?.domain??``,22,0)||l(e?.address??``,6,4)})]}),q(N,{boxSize:5,as:rr,cursor:`pointer`,opacity:.5})]})}),q(lt,{"aria-label":`Copy address`,icon:q(N,{as:s?er:lr}),onClick:f,variant:`ghost`,size:`sm`,opacity:.5,_hover:{opacity:.8}}),q(lt,{"aria-label":`Logout`,icon:q(N,{as:xr}),onClick:()=>t({type:`disconnect-confirm`,props:{onDisconnect:p,onBack:()=>t(`main`)}}),variant:`ghost`,size:`sm`,opacity:.5,_hover:{opacity:.8},colorScheme:`red`})]})},Lc=({address:e,maxIcons:t=3,iconSize:n=20,ml:r=0,style:i,iconsGap:a=0,rightIcon:o,showNoAssetsWarning:c=!1,onClick:l})=>{let{t:u}=Y(),{tokensWithBalance:d}=ds({address:e}),{darkMode:f}=$(),m=B(`colors`,`vechain-kit-text-secondary`),h=a<1?`-${n/2}px`:`${a}px`,g=d.slice(0,t),_=d.length-t;return!e||d.length===0&&!c?null:J(M,{spacing:0,ml:r,...i,onClick:l,children:[J(M,{spacing:0,children:[g.map((e,t)=>q(Qe,{ml:t>0?h:`0`,zIndex:t,size:`${n}px`,borderRadius:`full`,bg:f?`gray.100`:`gray.600`,border:`2px solid #00000024`,alignItems:`center`,justifyContent:`center`,children:s[e.symbol]?V.cloneElement(s[e.symbol],{width:`${n*.8}px`,height:`${n*.8}px`,rounded:`full`}):p[e.symbol]?q(ut,{src:p[e.symbol],alt:`${e.symbol} logo`,width:`${n*.8}px`,height:`${n*.8}px`,rounded:`full`}):q(R,{fontSize:`${n*.4}px`,fontWeight:`bold`,color:f?`black`:`white`,children:e.symbol.slice(0,3)})},e.symbol)),_>0&&q(Qe,{ml:h,zIndex:g.length,size:`${n}px`,borderRadius:`full`,bg:f?`gray.100`:`gray.700`,display:`flex`,alignItems:`center`,justifyContent:`center`,border:`2px solid`,children:J(R,{fontSize:`${n*.4}px`,fontWeight:`bold`,color:f?`black`:`white`,children:[`+`,_]})}),d.length===0&&c&&q(R,{fontSize:`sm`,color:m,fontWeight:`700`,children:u(`No assets`)})]}),o]})},Rc=({mb:e,mt:t,onAssetsClick:n})=>{let{t:r}=Y(),{account:i}=Q(),{formattedBalance:a,isLoading:o}=fs({address:i?.address??``}),{refresh:s}=Gs(),[c,l]=G(!1),u=B(`colors`,`vechain-kit-text-secondary`),d=async()=>{l(!0),await s(),setTimeout(()=>{l(!1)},1500)};return J(z,{w:`full`,justifyContent:`start`,spacing:1,mt:t,mb:e,children:[J(M,{w:`full`,justifyContent:`flex-start`,alignItems:`center`,spacing:2,role:`group`,children:[q(ct,{size:`xs`,fontWeight:`500`,color:u,children:r(`Assets`)}),q(A,{display:`flex`,alignItems:`center`,justifyContent:`center`,w:`32px`,h:`32px`,children:q(lt,{"aria-label":`Refresh balances`,variant:`ghost`,size:`sm`,opacity:.5,_hover:{opacity:.8},onClick:d,icon:q(N,{as:Dr,boxSize:4}),isLoading:o||c,sx:{"& > span.chakra-button__spinner":{width:`16px`,height:`16px`,position:`absolute`}}})})]}),q(j,{onClick:n,h:`fit-content`,variant:`vechainKitSecondary`,children:J(z,{spacing:2,w:`full`,justifyContent:`flex-start`,alignItems:`flex-start`,mt:4,mb:4,children:[q(ct,{size:`2xl`,fontWeight:`700`,children:a}),q(M,{w:`full`,justifyContent:`flex-start`,"data-testid":`all-assets-button`,mt:2,children:q(Lc,{style:{width:`100%`,justifyContent:`space-between`},maxIcons:10,iconSize:26,iconsGap:3,address:i?.address??``,showNoAssetsWarning:!0,rightIcon:q(N,{as:rr,boxSize:5,opacity:.5,marginLeft:2})})})]})})]})},zc=[{icon:Yn,label:`Send`,onClick:e=>e({type:`send-token`,props:{setCurrentContent:e}}),isDisabled:e=>!e},{icon:Kn,label:`Swap`,onClick:e=>{e(`swap-token`)},isDisabled:e=>!e},{icon:Wn,label:`Receive`,onClick:e=>{e(`receive-token`)}}],Bc=({icon:e,label:t,onClick:n,isDisabled:r,showRedDot:i})=>{let{t:a}=Y();return q(lt,{variant:`vechainKitSecondary`,h:`80px`,w:`full`,"aria-label":t,isDisabled:r,p:3,icon:J(z,{spacing:4,children:[q(N,{as:e,boxSize:5,opacity:.9}),J(M,{p:0,alignItems:`baseline`,spacing:1,children:[q(R,{fontSize:`sm`,fontWeight:`600`,"data-testid":`${t.toLowerCase()}-button-label`,children:a(t,t)}),i&&q(A,{minWidth:`8px`,height:`8px`,bg:`red.500`,borderRadius:`full`,display:`flex`,alignItems:`center`,justifyContent:`center`})]})]}),onClick:n})},Vc=({mt:e,setCurrentContent:t})=>{let{account:n,smartAccount:r,connectedWallet:i,connection:a}=Q(),{hasAnyBalance:o}=fs({address:n?.address??``}),{data:s}=Pf(r?.address??``,i?.address??``,3),c=a.isConnectedWithPrivy&&s;return q(ot,{templateColumns:`repeat(3, 1fr)`,gap:2,w:`full`,mt:e,children:zc.map(e=>q(Bc,{icon:e.icon,label:e.label,onClick:()=>e.onClick(t),isDisabled:e.isDisabled?.(o),showRedDot:c&&e.label===`Settings`},e.label))})},Hc=()=>{let[e,t]=G(!0),n=`vechain_kit_feature_announcement_closed`;return U(()=>{w(n)&&t(!1)},[]),{isVisible:e,closeAnnouncement:()=>{h(n,`true`),t(!1)}}},Uc=({setCurrentContent:e})=>{let{t}=Y(),{isVisible:n,closeAnnouncement:r}=Hc(),i=B(`colors`,`vechain-kit-text-primary`),a=B(`colors`,`vechain-kit-text-secondary`);return n?q(Ge,{w:`full`,variant:`featureAnnouncement`,overflow:`hidden`,onClick:()=>{e({type:`choose-name`,props:{setCurrentContent:e,onBack:()=>e(`main`),initialContentSource:`main`}}),r()},cursor:`pointer`,_hover:{opacity:.8},children:q(Ke,{p:4,children:J(M,{justify:`space-between`,align:`flex-start`,spacing:3,children:[J(z,{align:`flex-start`,spacing:1,children:[J(M,{spacing:2,children:[q(R,{fontSize:`sm`,fontWeight:`400`,color:i,children:t(`Claim your vet domain!`)}),q(Nt,{size:`sm`,colorScheme:`red`,children:t(`New`)})]}),q(R,{fontSize:`xs`,color:a,children:t(`Say goodbye to 0x addresses, claim your .veworld.vet subdomain now for free!`)})]}),q(lt,{size:`sm`,variant:`ghost`,colorScheme:`gray`,icon:q(cr,{}),onClick:e=>{e.stopPropagation(),r()},"aria-label":t(`Close announcement`)})]})})}):null},Wc=()=>{let{t:e}=Y();return q(Be,{status:`warning`,fontSize:`xs`,borderRadius:`xl`,p:2,children:q(z,{spacing:1,align:`stretch`,w:`full`,children:J(M,{spacing:2,align:`flex-start`,children:[q(He,{boxSize:4,mt:`10px`}),q(R,{w:`full`,children:e(`Sending to OceanX or other exchanges may result in loss of funds.`)})]})})})},Gc=()=>{let{t:e}=Y();return q(Be,{status:`warning`,fontSize:`xs`,borderRadius:`xl`,p:2,children:q(z,{spacing:1,align:`stretch`,w:`full`,children:J(M,{spacing:2,align:`flex-start`,children:[q(He,{boxSize:4,mt:`10px`}),q(R,{w:`full`,children:e(`A .vet domain is required to customize your profile. Choose an account name to get started.`)})]})})})},Kc=()=>{let{t:e}=Y(),{getConnectionCache:t}=Ud(),n=t();return J(Ge,{variant:`vechainKitBase`,w:`full`,children:[J(Je,{p:4,pl:6,borderBottomWidth:`1px`,children:[q(R,{fontWeight:`medium`,opacity:.8,children:e(`Security preferences`)}),q(R,{fontSize:`xs`,mt:1,opacity:.7,children:e(`For security reasons, you can manage your embedded wallet settings only on the {{appName}} platform.`,{appName:n?.ecosystemApp.name??`origin app`})})]}),q(Ke,{borderRadius:`none`,children:J(z,{spacing:3,align:`stretch`,children:[J(M,{spacing:3,align:`center`,children:[q(Ye,{w:`fit-content`,h:`fit-content`,p:2,borderRadius:`full`,bg:`blackAlpha.100`,flexShrink:0,children:q(N,{as:zr})}),J(A,{flex:1,children:[q(R,{fontSize:`sm`,fontWeight:`medium`,lineHeight:`shorter`,children:e(`Login methods`)}),q(R,{fontSize:`xs`,opacity:.7,lineHeight:`shorter`,children:e(`Manage your login methods and passkeys`)})]})]}),J(M,{spacing:3,align:`center`,children:[q(Ye,{w:`fit-content`,h:`fit-content`,p:2,borderRadius:`full`,bg:`blackAlpha.100`,flexShrink:0,children:q(N,{as:Nr})}),J(A,{flex:1,children:[q(R,{fontSize:`sm`,fontWeight:`medium`,lineHeight:`shorter`,children:e(`Security settings`)}),q(R,{fontSize:`xs`,opacity:.7,lineHeight:`shorter`,children:e(`Backup your wallet, configure MFA and set recovery options`)})]})]})]})}),q(qe,{children:J(j,{variant:`vechainKitSecondary`,w:`full`,onClick:()=>{window.open(n?.ecosystemApp.website??`https://governance.vebetterdao.org/`,`_blank`)},children:[e(`Manage on {{appName}}`,{appName:n?.ecosystemApp.name??`origin app`}),q(N,{as:fr,ml:2})]})})]})},qc=({setCurrentContent:e})=>{let{t}=Y(),{exportWallet:n}=wn(),{showMfaEnrollmentModal:r}=Cn(),{setWalletRecovery:i}=En(),{connection:a,smartAccount:o,connectedWallet:s}=Q(),c=B(`colors`,`vechain-kit-text-secondary`),{data:l}=Pf(o?.address??``,s?.address??``,3);return J(Op,{children:[J(Z,{children:[q(L,{children:t(`Access and security`)}),q(Ja,{onClick:()=>e(`settings`)}),q(F,{})]}),q(P,{w:`full`,children:J(z,{justify:`center`,spacing:3,align:`flex-start`,w:`full`,children:[q(z,{w:`full`,justifyContent:`center`,spacing:3,mb:3,children:q(R,{fontSize:`sm`,color:c,textAlign:`center`,children:t(`Manage your embedded wallet security settings: handle your login methods, add a passkey or back up your wallet to never lose access to your assets.`)})}),l&&q(Fc,{title:t(`Upgrade Smart Account to V3`),description:t(`A new version is available for your account`),onClick:()=>{e({type:`upgrade-smart-account`,props:{setCurrentContent:e,initialContent:`access-and-security`}})},leftIcon:jr,extraContent:q(A,{minWidth:`8px`,height:`8px`,bg:`red.500`,borderRadius:`full`,display:`flex`,alignItems:`center`,justifyContent:`center`,ml:2})}),q(Fc,{title:t(`Your embedded wallet`),onClick:()=>{e(`embedded-wallet`)},leftIcon:Br,rightIcon:rr}),a.isConnectedWithSocialLogin?J(z,{w:`full`,justifyContent:`center`,spacing:0,children:[q(Fc,{title:t(`Login methods and Passkeys`),style:{borderBottomRadius:`0px`},onClick:()=>{e(`privy-linked-accounts`)},leftIcon:zr,rightIcon:rr}),q(Fc,{title:t(`Backup your wallet`),style:{borderTopRadius:`0px`,borderBottomRadius:`0px`},onClick:()=>{n()},leftIcon:yr}),q(Fc,{title:t(`Manage MFA`),style:{borderTopRadius:`0px`,borderBottomRadius:`0px`},onClick:()=>{r()},leftIcon:Nr}),q(Fc,{title:t(`Manage Recovery`),style:{borderTopRadius:`0px`},onClick:()=>{i()},leftIcon:Or})]}):q(Kc,{})]})}),q(I,{pt:0})]})},Jc=()=>{let{isolatedView:e,closeAccountModal:t}=rd();return{isolatedView:e,closeAccountModal:t}},Yc=({setCurrentContent:e,onLogoutSuccess:t})=>{let n=Zt(null),{t:r}=Y(),{isolatedView:i}=Jc(),{connection:a,disconnect:o,smartAccount:s,connectedWallet:c,account:l}=Q(),{data:u}=Pf(s?.address??``,c?.address??``,3);U(()=>{n.current&&(n.current.scrollTop=0)},[]);let d=()=>{e({type:`account-customization`,props:{setCurrentContent:e,initialContentSource:`settings`}})},f=()=>{l?.domain?e({type:`choose-name-search`,props:{name:``,setCurrentContent:e,initialContentSource:`settings`}}):e({type:`choose-name`,props:{setCurrentContent:e,initialContentSource:`settings`,onBack:()=>e(`settings`)}})},p=()=>{e(`access-and-security`)},m=()=>{e(`connection-details`)},h=()=>{e(`general-settings`)},g=()=>{o(),t()};return J(A,{children:[J(Z,{children:[q(L,{children:r(`Settings`)}),!i&&q(Ja,{onClick:()=>e(`main`)}),q(F,{})]}),q(P,{w:`full`,children:J(z,{w:`full`,spacing:4,children:[J(z,{w:`full`,spacing:0,children:[q(Fc,{style:{marginTop:`10px`,borderBottomRadius:`0px`},title:r(`Customize profile`),onClick:d,leftIcon:Rr,rightIcon:rr}),q(Fc,{style:{borderTopRadius:`0px`},title:r(`Choose account name`),description:r(`Choose a name for your account.`),onClick:f,leftIcon:Fr,rightIcon:rr})]}),J(z,{w:`full`,spacing:0,children:[a.isConnectedWithPrivy&&q(Fc,{style:{borderBottomRadius:`0px`},title:r(`Access and security`),onClick:p,leftIcon:Mr,rightIcon:rr,extraContent:u&&q(A,{minWidth:`8px`,height:`8px`,bg:`red.500`,borderRadius:`full`,display:`flex`,alignItems:`center`,justifyContent:`center`})}),q(Fc,{style:a.isConnectedWithPrivy?{borderTopRadius:`0px`,borderBottomRadius:`0px`}:{borderTopRadius:`12px`,borderBottomRadius:`0px`},title:r(`General`),onClick:h,leftIcon:Ar,rightIcon:rr}),q(Fc,{title:r(`Help`),onClick:()=>e({type:`faq`,props:{onGoBack:()=>e(`settings`),showLanguageSelector:!1}}),leftIcon:sr,rightIcon:rr,style:{borderTopRadius:`0px`}})]}),J(z,{w:`full`,spacing:0,children:[q(Fc,{style:{borderBottomRadius:`0px`},title:r(`Connection details`),onClick:m,leftIcon:Lr,rightIcon:rr}),q(Fc,{style:{borderTopRadius:`0px`},title:r(`Logout`),onClick:()=>e({type:`disconnect-confirm`,props:{onDisconnect:g,onBack:()=>e(`settings`)}}),leftIcon:xr})]})]})}),q(I,{pt:0})]})},Xc=()=>{let{t:e}=Y(),{network:t}=$(),{connection:n,smartAccount:r,connectedWallet:i}=Q(),{data:a,isLoading:o}=co(),{data:s,isLoading:c}=yf(r.address??``,i?.address??``),l=B(`colors`,`vechain-kit-text-primary`),u=B(`colors`,`vechain-kit-text-secondary`),d=({label:e,value:t,isLoading:n=!1,href:r})=>J(M,{w:`full`,justifyContent:`space-between`,children:[J(R,{fontSize:`sm`,color:l,children:[e,`:`]}),q(R,{fontSize:`sm`,as:r?`a`:void 0,href:r,target:`_blank`,rel:`noopener noreferrer`,style:{textDecoration:r?`underline`:`none`},color:u,children:n?`Loading...`:t})]});return J(K,{children:[q(d,{label:e(`Connection Type`),value:n.source.type,isLoading:n.isLoading}),q(d,{label:e(`Network`),value:t.type}),q(d,{label:e(`Node URL`),value:t.nodeUrl||k(t.type).nodeUrl}),n.isConnectedWithPrivy?J(K,{children:[q(d,{label:e(`Smart Account`),value:`v${s?.version??``} ${s?.isDeployed?``:`(not deployed)`}`,isLoading:c}),q(d,{label:e(`Privy Status`),value:a||``,isLoading:o})]}):r.isDeployed&&q(d,{label:e(`Smart Account`),value:`v${s?.version??``}`,isLoading:c}),q(d,{label:e(`VeChain Kit`),value:Xa,href:`https://github.com/vechain/vechain-kit/releases/tag/${Xa}`})]})},Zc=({connectionCache:e})=>{let{t}=Y(),n=B(`colors`,`vechain-kit-card`),r=B(`colors`,`vechain-kit-text-secondary`),i=B(`colors`,`vechain-kit-text-primary`);return q(K,{children:e.ecosystemApp&&J(z,{p:4,bg:n,borderRadius:`xl`,spacing:4,w:`full`,children:[J(M,{w:`full`,justifyContent:`space-between`,children:[J(R,{fontSize:`sm`,color:i,children:[t(`Logged in with`),`:`]}),q(R,{fontSize:`sm`,color:r,children:e.ecosystemApp.name})]}),J(M,{w:`full`,justifyContent:`space-between`,children:[J(R,{fontSize:`sm`,color:i,children:[t(`At`),`:`]}),q(R,{fontSize:`sm`,color:r,children:new Date(e.timestamp).toLocaleString()})]}),q(Xc,{})]})})},Qc=()=>{let{t:e}=Y(),{source:t}=Nn(),n=B(`colors`,`vechain-kit-card`),r=B(`colors`,`vechain-kit-text-secondary`),i=B(`colors`,`vechain-kit-text-primary`);return q(K,{children:t&&J(z,{p:4,bg:n,borderRadius:`xl`,spacing:4,w:`full`,justifyContent:`space-between`,children:[J(M,{w:`full`,justifyContent:`space-between`,children:[J(R,{fontSize:`sm`,color:i,children:[e(`Logged in with`),`:`]}),q(R,{fontSize:`sm`,color:r,children:t})]}),q(Xc,{})]})})},$c=()=>{let{t:e}=Y(),{privy:t}=$(),{data:n,isLoading:r}=oo(t?.appId??``),i=B(`colors`,`vechain-kit-card`),a=B(`colors`,`vechain-kit-text-primary`),o=B(`colors`,`vechain-kit-text-secondary`);return r?q(z,{w:`full`,h:`full`,justify:`center`,align:`center`,children:q(At,{})}):q(K,{children:n&&J(z,{p:4,bg:i,borderRadius:`xl`,spacing:4,w:`full`,justifyContent:`space-between`,children:[J(M,{w:`full`,justifyContent:`space-between`,children:[J(R,{fontSize:`sm`,color:a,children:[e(`Logged in with`),`:`]}),q(R,{fontSize:`sm`,color:o,children:Object.values(n)[0].name})]}),q(Xc,{})]})})},el=()=>{let{connection:e}=Q(),{t}=Y(),{privy:n,darkMode:r}=$(),{getConnectionCache:i}=Ud(),a=i();return J(z,{w:`full`,align:`stretch`,textAlign:`center`,mt:5,p:3,borderRadius:`lg`,bg:B(`colors`,`vechain-kit-card`),shadow:`sm`,children:[q(R,{fontSize:`xs`,fontWeight:`800`,children:t(`Wallet secured by`)}),J(M,{justify:`center`,children:[q(Se,{isDark:r,w:`50px`}),q(N,{as:Cr,ml:3}),e.isConnectedWithVeChain?q(fe,{isDark:r,w:`80px`,h:`auto`,mb:`3px`}):e.isConnectedWithCrossApp&&a&&q(ut,{src:a.ecosystemApp.logoUrl,alt:a.ecosystemApp.name,maxW:`40px`,borderRadius:`md`}),e.isConnectedWithSocialLogin&&!e.isConnectedWithVeChain&&q(ut,{src:n?.appearance.logo,alt:n?.appearance.logo,maxW:`40px`,borderRadius:`md`})]})]})},tl=({setCurrentContent:e})=>{let{t}=Y(),{connectedWallet:n,connection:r}=Q(),a=i(n?.address??``),{getConnectionCache:o}=Ud(),s=o(),c=B(`colors`,`vechain-kit-text-secondary`);return J(Op,{children:[J(Z,{children:[q(L,{children:t(`Embedded wallet`)}),q(Ja,{onClick:()=>e(`access-and-security`)}),q(F,{})]}),q(P,{w:`full`,children:J(z,{justify:`center`,spacing:3,align:`flex-start`,w:`full`,children:[J(z,{justify:`center`,align:`center`,w:`full`,children:[q(ut,{src:a,maxW:`100px`,borderRadius:`50%`}),q(Ya,{wallet:n,style:{mt:2},showHumanAddress:!1})]}),r.isConnectedWithCrossApp&&J(K,{children:[q(R,{fontSize:`sm`,color:c,children:t(`This is your main wallet, created by {{element}} and secured by Privy.`,{element:s?.ecosystemApp?.name})}),q(R,{fontSize:`sm`,color:c,children:t(`This wallet is the owner of your smart account, which is used as your identity and as a gateway for your blockchain interactions.`)}),q(R,{fontSize:`sm`,color:c,children:t(`Please be sure to keep this wallet safe and backed up.`)})]}),r.isConnectedWithSocialLogin&&J(K,{children:[q(R,{fontSize:`sm`,color:c,children:t(`You are using an Embedded Wallet secured by your social login method, ensuring a seamless VeChain experience.`)}),q(R,{fontSize:`sm`,color:c,children:t(`This wallet is the owner of your smart account, which is used as your identity and as a gateway for your blockchain interactions.`)}),J(R,{fontSize:`sm`,color:c,children:[t(`We highly recommend exporting your private key to back up your wallet. This ensures you can restore it if needed or transfer it to self-custody using`),J(ht,{href:`https://www.veworld.net/`,isExternal:!0,color:c,fontSize:`14px`,textDecoration:`underline`,children:[` `,t(`VeWorld Wallet`),q(N,{ml:1,as:fr})]}),`.`]}),J(R,{fontSize:`sm`,color:c,children:[t(`Click`),` `,q(ht,{href:`https://docs.vechainkit.vechain.org/vechain-kit/embedded-wallets`,isExternal:!0,color:c,fontSize:`14px`,textDecoration:`underline`,children:t(`here`)}),` `,t(`to learn more about embedded wallets.`)]})]})]})}),q(I,{w:`full`,children:J(z,{w:`full`,children:[q(nt,{}),r.isConnectedWithPrivy&&q(el,{})]})})]})},nl=({onDisconnect:e,onBack:t,onClose:n,showCloseButton:r=!0,text:i})=>{let{t:a}=Y(),o=B(`colors`,`vechain-kit-text-primary`),s=i??a(`Are you sure you want to disconnect your wallet?`);return J(Op,{children:[J(Z,{children:[q(L,{children:a(`Logout`)}),q(Ja,{onClick:t}),r?q(F,{onClick:n}):null]}),q(P,{children:q(z,{spacing:6,align:`stretch`,children:q(R,{fontSize:`md`,textAlign:`center`,color:o,children:s})})}),q(I,{w:`full`,children:J(z,{spacing:3,w:`full`,children:[q(j,{height:`60px`,colorScheme:`red`,w:`full`,onClick:e,"data-testid":`disconnect-button`,children:a(`Confirm`)}),q(j,{variant:`vechainKitSecondary`,onClick:t,"data-testid":`cancel-logout-button`,children:a(`Cancel`)})]})})]})},rl=({onSelectToken:e,onBack:t,showAllTokens:n=!1})=>{let{t:r}=Y(),{darkMode:i}=$(),{currentCurrency:a}=us(),o=B(`colors`,`vechain-kit-text-primary`),s=B(`colors`,`vechain-kit-text-secondary`),c=B(`colors`,`vechain-kit-text-tertiary`),{account:l}=Q(),{tokensWithBalance:u,sortedTokens:d}=ds({address:l?.address??``}),[f,p]=G(``),m=W(()=>{if(n){let e=d.filter(e=>Number(e.balance)>0),t=[...d.filter(e=>Number(e.balance)===0)].sort((e,t)=>e.symbol.localeCompare(t.symbol));return[...e,...t]}return u},[n,d,u]).filter(({symbol:e})=>e.toLowerCase().includes(f.toLowerCase()));return J(K,{children:[J(Z,{children:[q(L,{children:r(`Select Token`)}),q(Ja,{onClick:t}),q(F,{})]}),q(tt,{h:[`540px`,`auto`],p:0,children:q(P,{children:J(z,{spacing:4,align:`stretch`,children:[J(ft,{size:`lg`,children:[q(dt,{placeholder:`Search token`,bg:i?`vechain-kit-overlay`:`vechain-kit-card`,borderRadius:`xl`,height:`56px`,pl:12,value:f,onChange:e=>p(e.target.value),"data-testid":`search-token-input`}),q(pt,{h:`56px`,w:`56px`,pl:4,children:q(kr,{color:c})})]}),q(R,{fontSize:`lg`,fontWeight:`semibold`,color:o,mt:4,children:r(n?`All tokens`:`Your tokens`)}),m.length===0?J(z,{spacing:2,py:8,children:[q(N,{as:Pr,boxSize:12,color:c}),q(R,{fontSize:`lg`,color:o,children:r(`No tokens found`)}),q(R,{fontSize:`md`,color:s,children:r(`Try searching with a different term`)})]}):q(z,{spacing:2,align:`stretch`,children:m.map(t=>q(ro,{symbol:t.symbol,amount:Number(t.balance),currencyValue:t.valueInCurrency,currentCurrency:a,onClick:()=>e(t)},t.address))})]})})}),q(I,{pt:0})]})},il=({setCurrentContent:e,preselectedToken:t,initialAmount:n=``,initialToAddressOrDomain:r=``,onBack:i=()=>e(`main`)})=>{let{t:a}=Y(),{darkMode:o,feeDelegation:c}=$(),{currentCurrency:l}=us(),u=B(`colors`,`vechain-kit-text-primary`),d=B(`colors`,`vechain-kit-text-secondary`),f=B(`colors`,`vechain-kit-text-tertiary`),m=B(`colors`,`vechain-kit-error`),h=B(`colors`,`vechain-kit-card`),{exchangeRates:g}=ss(),{account:_}=Q(),{isolatedView:v}=Jc(),{tokensWithBalance:y}=ds({address:_?.address??``}),[b,x]=G(t??y[0]??null),[S,C]=G(!1);U(()=>{!t&&!b&&y.length>0&&x(y[0])},[y,t,b]);let{register:w,watch:ee,setValue:T,setError:E,formState:{errors:D,isValid:te},handleSubmit:ne}=Hi({defaultValues:{amount:n,toAddressOrDomain:r},mode:`onChange`}),{toAddressOrDomain:re,amount:O}=ee(),ie=Zt(b);U(()=>{ie.current&&b&&ie.current.address!==b.address&&T(`amount`,``),ie.current=b},[b,T]);let ae=W(()=>b?no(eo(Number(O)*b.priceUsd,l,g),{currency:l}):``,[O,b,l,g]),{data:oe,isLoading:se}=uo(re),k=()=>{b&&T(`amount`,b.balance)},ce=()=>{i()},le=async t=>{if(b){if(!(oe?.isValidAddressOrDomain&&(!oe?.domain||oe?.domain&&oe?.isPrimaryDomain))){E(`toAddressOrDomain`,{type:`manual`,message:a(`Invalid address or domain`)});return}if(b){let e=nn(t.amount),n=c?.b3trTransfers?.minAmountInEther;if(b.symbol===`B3TR`&&typeof n==`number`&&n>0)try{if(e<nn(String(n))){E(`amount`,{type:`manual`,message:a(`Minimum {{symbol}} transfer is {{min}}`,{symbol:b.symbol,min:n})});return}}catch{}if(e>nn(b.balance)){E(`amount`,{type:`manual`,message:a(`Insufficient {{symbol}} balance`,{symbol:b.symbol})});return}}e({type:`send-token-summary`,props:{toAddressOrDomain:t.toAddressOrDomain,resolvedDomain:oe?.domain,resolvedAddress:oe?.address,amount:t.amount,selectedToken:b,formattedTotalAmount:ae,setCurrentContent:e}})}};return S?q(rl,{setCurrentContent:e,onSelectToken:e=>{x(e),C(!1)},onBack:()=>{C(!1)}}):J(K,{children:[J(Z,{children:[q(L,{children:a(`Send`)}),!v&&q(Ja,{onClick:ce}),q(F,{})]}),q(P,{children:J(z,{spacing:1,align:`stretch`,position:`relative`,children:[J(A,{p:6,borderRadius:`xl`,bg:h,children:[q(R,{fontSize:`sm`,fontWeight:`medium`,color:u,mb:2,children:a(`Amount`)}),q(z,{align:`stretch`,spacing:2,children:J(it,{isInvalid:!!D.amount,children:[J(M,{justify:`space-between`,children:[q(dt,{...w(`amount`,{required:a(`Amount is required`),pattern:{value:/^\d*\.?\d*$/,message:a(`Please enter a valid number`)},validate:e=>{if(!e)return!0;let t=parseFloat(e);if(isNaN(t))return a(`Please enter a valid number`);let n=c?.b3trTransfers?.minAmountInEther;return b?.symbol===`B3TR`&&typeof n==`number`&&n>0&&t<n?a(`Minimum {{symbol}} transfer is {{min}}`,{symbol:b.symbol,min:n}):!0}}),onChange:e=>{let t=e.target.value.trim();e.target.value=t,T(`amount`,t,{shouldValidate:!0})},placeholder:`0`,variant:`unstyled`,fontSize:`4xl`,fontWeight:`bold`,"data-testid":`tx-amount-input`,type:`number`,inputMode:`decimal`,color:u}),b?J(j,{variant:`outline`,size:`sm`,borderRadius:`full`,px:6,color:d,borderColor:d,_hover:{bg:o?`whiteAlpha.300`:`blackAlpha.300`},onClick:()=>C(!0),leftIcon:s[b.symbol]?V.cloneElement(s[b.symbol],{boxSize:`20px`,borderRadius:`full`}):q(ut,{src:p[b.symbol],alt:`${b.symbol} logo`,boxSize:`20px`,borderRadius:`full`,fallback:q(A,{boxSize:`20px`,borderRadius:`full`,bg:`whiteAlpha.200`,display:`flex`,alignItems:`center`,justifyContent:`center`,children:q(R,{fontSize:`8px`,fontWeight:`bold`,color:u,children:b.symbol.slice(0,3)})})}),children:[b.symbol,q(N,{as:tr,boxSize:5,color:d})]}):J(j,{variant:`outline`,size:`sm`,borderRadius:`full`,px:6,color:d,borderColor:d,_hover:{bg:o?`whiteAlpha.300`:`blackAlpha.300`,color:f},onClick:()=>C(!0),children:[a(`Select token`),q(N,{as:tr,boxSize:5,color:d})]})]}),b&&J(M,{spacing:1,fontSize:`sm`,justifyContent:`space-between`,color:d,children:[J(R,{color:d,children:[`≈ `,ae]}),q(R,{cursor:`pointer`,_hover:{color:d,textDecoration:`underline`},onClick:k,noOfLines:1,overflow:`hidden`,textOverflow:`ellipsis`,children:a(`Send all`)})]}),D.amount&&q(R,{color:`#ef4444`,fontSize:`sm`,mt:1,"data-testid":`amount-error-msg`,children:D.amount.message})]})})]}),J(A,{borderRadius:`xl`,bg:h,children:[q(R,{fontSize:`sm`,fontWeight:`medium`,color:u,mb:2,px:6,pt:6,children:a(`To`)}),q(z,{align:`stretch`,spacing:2,p:6,pt:2,width:`100%`,children:J(it,{isInvalid:!!D.toAddressOrDomain,children:[q(dt,{...w(`toAddressOrDomain`,{required:a(`Address is required`)}),onChange:e=>{let t=e.target.value.trim(),n=t.includes(`.`)?Ui(t):t;e.target.value=n,T(`toAddressOrDomain`,n,{shouldValidate:!0})},placeholder:a(`Type the receiver address or domain`),_placeholder:{fontSize:`md`,fontWeight:`normal`},fontSize:`lg`,fontWeight:`bold`,color:u,variant:`unstyled`,"data-testid":`tx-address-input`}),D.toAddressOrDomain&&q(R,{color:m,fontSize:`sm`,"data-testid":`address-error-msg`,children:D.toAddressOrDomain.message})]})})]})]})}),q(I,{children:q(j,{variant:`vechainKitPrimary`,isDisabled:!b||!te,isLoading:se,onClick:ne(le),"data-testid":`send-button`,children:a(b?`Send`:`Select Token`)})})]})},al=({setCurrentContent:e,toAddressOrDomain:t,resolvedDomain:n,resolvedAddress:r,amount:a,selectedToken:o,formattedTotalAmount:s})=>{let{t:c}=Y(),{account:l,connection:u,connectedWallet:d}=Q(),{data:f}=Ko(r??``),{network:p,feeDelegation:m}=$(),{preferences:h}=Cp(),{isolatedView:g,closeAccountModal:_}=Jc(),v=B(`colors`,`vechain-kit-text-primary`),y=B(`colors`,`vechain-kit-text-secondary`),{data:b}=Pf(l?.address??``,d?.address??``,3),{open:x}=Pd(),S=W(()=>f||i(r||t),[f,p.type,r,t]),C=async()=>{if(b){x();return}try{o.symbol===`VET`?await re():await ee()}catch(e){console.error(c(`Transaction failed:`),e)}},w=t=>{e({type:`successful-operation`,props:{setCurrentContent:e,txId:t,title:c(`Transaction successful`),onDone:()=>{g?_():e(`main`)},showSocialButtons:!0}})},{sendTransaction:ee,txReceipt:T,error:E,isWaitingForWalletConfirmation:D,isTransactionPending:te,clauses:ne}=Zf({fromAddress:l?.address??``,receiverAddress:r||t,amount:a,tokenAddress:o.address,tokenName:o.symbol,onSuccess:()=>{w(T?.meta.txID??``)},onError:e=>{de(e??``)}}),{sendTransaction:re,txReceipt:O,error:ie,isWaitingForWalletConfirmation:ae,isTransactionPending:oe,clauses:se}=$f({fromAddress:l?.address??``,receiverAddress:r||t,amount:a,onSuccess:()=>{w(O?.meta.txID??``)},onError:e=>{de(e??``)}}),k=()=>o.symbol===`VET`?O:T,ce=D||ae,le=ce||te||oe,ue=()=>{e({type:`send-token`,props:{setCurrentContent:e,preselectedToken:o,initialAmount:a,initialToAddressOrDomain:t}})},de=e=>{console.error(`Transaction failed:`,e)},[fe,pe]=V.useState(null),[me,he]=V.useState(null),ge=h.availableGasTokens.length>0&&(u.isConnectedWithPrivy||u.isConnectedWithVeChain)&&!m?.delegatorUrl,{data:_e,isLoading:ve,error:ye,refetch:be}=wp({clauses:o.symbol===`VET`?se:ne,tokens:fe?[fe]:h.availableGasTokens,sendingAmount:a,sendingTokenSymbol:o.symbol,enabled:ge&&!!m?.genericDelegatorUrl}),xe=_e?.usedToken,Se=(ve||!_e)&&u.isConnectedWithPrivy&&!m?.delegatorUrl,Ce=V.useCallback(e=>{pe(e),he(e),setTimeout(()=>be(),100)},[be]),we=!!xe&&!ye;return V.useEffect(()=>{ye&&fe&&pe(null)},[ye,fe]),J(K,{children:[J(Z,{children:[q(L,{children:`Send`}),q(Ja,{isDisabled:le,onClick:ue}),q(F,{isDisabled:le})]}),q(P,{children:q(z,{spacing:6,align:`stretch`,w:`full`,children:J(z,{spacing:4,w:`full`,children:[q(Ep,{label:c(`From`),address:l?.address??``,domain:l?.domain,imageSrc:l?.image??``,imageAlt:`From account`,balance:Number(o.balance),tokenAddress:o.address}),q(Ep,{label:c(`To`),address:r||t,domain:n,imageSrc:S??``,imageAlt:`To account`,tokenAddress:o.address}),u.isConnectedWithPrivy&&q(Np,{estimation:_e,isLoading:ve,isLoadingTransaction:le,onTokenChange:Ce,clauses:o.symbol===`VET`?se:ne,userSelectedToken:me}),J(z,{spacing:0,w:`full`,justifyContent:`flex-start`,children:[q(R,{fontSize:`sm`,fontWeight:`light`,textAlign:`left`,w:`full`,color:y,children:c(`Amount`)}),J(M,{justifyContent:`flex-start`,w:`full`,children:[J(R,{fontSize:`xl`,fontWeight:`semibold`,textAlign:`left`,"data-testid":`send-summary-amount`,color:v,children:[Number(a).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2}),` `,o.symbol]}),J(R,{color:y,children:[`≈ `,s]})]})]})]})})}),q(I,{children:q(Ap,{transactionError:o.symbol===`VET`?ie:E,isSubmitting:le,isTxWaitingConfirmation:ce,onConfirm:C,transactionPendingText:c(`Sending...`),txReceipt:k(),buttonText:c(`Confirm`),isDisabled:le||Se,gasEstimationError:ye,hasEnoughGasBalance:we,isLoadingGasEstimation:ve,showGasEstimationError:!m?.delegatorUrl&&u.isConnectedWithPrivy,context:`send`})})]})},ol=({setCurrentContent:e})=>{let{t}=Y(),{account:n}=Q(),{isolatedView:r}=Jc(),i=B(`colors`,`vechain-kit-text-primary`),a=B(`colors`,`vechain-kit-text-secondary`);return J(K,{children:[J(Z,{children:[q(L,{children:t(`Receive`)}),!r&&q(Ja,{onClick:()=>e(`main`)}),q(F,{})]}),J(tt,{maxW:`container.lg`,children:[q(P,{children:J(z,{spacing:4,align:`center`,w:`full`,children:[q(Wi,{value:n?.address??``,size:200,removeQrCodeBehindLogo:!0,eyeRadius:4,logoPaddingStyle:`circle`,style:{borderRadius:`16px`}}),q(Ya,{wallet:n,style:{w:`85%`}}),q(R,{fontSize:`sm`,textAlign:`center`,color:i,children:t(`Copy your address or scan this QR code`)}),q(R,{fontSize:`xs`,textAlign:`center`,color:a,children:t(`This address only supports VeChain assets.`)})]})}),q(I,{pt:0})]})]})},sl=({quotes:e,selectedQuote:t,toTokenAddress:n,onSelectQuote:r,onBack:i})=>{let{t:a}=Y(),{darkMode:c}=$(),{currentCurrency:l}=us(),{account:u}=Q(),{exchangeRates:d,prices:f}=ss(),{tokens:m}=ds({address:u?.address??``}),[h,g]=G(!1),_=W(()=>n&&m.find(e=>o(e.address,n))||null,[n,m]),v=e.filter(e=>!e.reverted),y=e.filter(e=>e.reverted),b=W(()=>v.length===0?null:v.reduce((e,t)=>{let n=BigInt(e.outputAmount||`0`);return BigInt(t.outputAmount||`0`)>n?t:e}),[v]),x=W(()=>{let e=n&&f[n]||0;return v.map(t=>{let n=gi(BigInt(t.outputAmount||`0`)),r=Number(n)*e,i=eo(r,l,d),a=b&&t.aggregatorName===b.aggregatorName,o=0;if(b&&!a){let e=BigInt(b.outputAmount||`0`),n=BigInt(t.outputAmount||`0`);o=Number(n-e)/Number(e)*100}return{...t,outputAmountFormatted:n,valueUsd:r,valueInCurrency:i,isBest:a,percentageDiff:o}}).sort((e,t)=>{let n=BigInt(e.outputAmount||`0`),r=BigInt(t.outputAmount||`0`);return Number(r-n)})},[v,n,f,l,d,b]);return J(K,{children:[J(Z,{children:[q(L,{children:a(`Found following rates`)}),q(Ja,{onClick:i}),q(F,{})]}),q(tt,{h:[`540px`,`auto`],p:0,children:q(P,{children:J(z,{spacing:6,align:`stretch`,children:[x.length>0&&q(z,{spacing:2,align:`stretch`,children:x.map(e=>{let n=t?.aggregatorName===e.aggregatorName;return J(A,{p:2.5,borderRadius:`xl`,bg:c?`#00000038`:`gray.50`,borderWidth:1,borderColor:n?`blue.500`:c?`whiteAlpha.200`:`gray.200`,cursor:`pointer`,onClick:()=>r(e),_hover:{borderColor:n?`blue.500`:c?`whiteAlpha.400`:`gray.300`},position:`relative`,children:[(e.isBest||!e.isBest&&e.percentageDiff<0)&&q(A,{position:`absolute`,top:-1,left:0,zIndex:1,children:e.isBest?q(We,{colorScheme:`purple`,borderRadius:`sm`,fontSize:`2xs`,px:1.5,py:.5,borderTopLeftRadius:`xl`,borderBottomRightRadius:`md`,children:a(`Best`)}):J(We,{colorScheme:`red`,borderRadius:`xs`,fontSize:`2xs`,px:1.5,py:.5,borderTopLeftRadius:`xl`,borderBottomRightRadius:`md`,children:[e.percentageDiff.toFixed(2),`%`]})}),J(z,{align:`stretch`,spacing:1.5,marginTop:4,children:[J(M,{justify:`space-between`,align:`center`,children:[J(M,{spacing:1.5,align:`center`,children:[e.aggregator.getIcon(`20px`),q(R,{fontSize:`md`,fontWeight:`bold`,children:e.aggregatorName})]}),q(M,{align:`center`,spacing:1.5,children:_&&J(K,{children:[s[_.symbol]?V.cloneElement(s[_.symbol],{boxSize:`24px`,borderRadius:`full`}):p[_.symbol]?q(ut,{src:p[_.symbol],alt:`${_.symbol} logo`,boxSize:`24px`,borderRadius:`full`}):null,q(Ft,{label:Number(e.outputAmountFormatted).toLocaleString(void 0,{maximumFractionDigits:18}),hasArrow:!0,placement:`top`,children:J(R,{fontSize:`md`,fontWeight:`bold`,textAlign:`right`,whiteSpace:`nowrap`,children:[Number(e.outputAmountFormatted).toLocaleString(void 0,{minimumFractionDigits:4}),` `,_.symbol]})})]})})]}),J(M,{justify:`space-between`,align:`center`,children:[q(R,{fontSize:`xs`,color:c?`whiteAlpha.500`:`blackAlpha.500`,children:e.gasCostVTHO&&e.gasCostVTHO>0?`Gas: ${e.gasCostVTHO.toLocaleString(void 0,{maximumFractionDigits:2})} VTHO`:``}),e.valueUsd>0&&J(R,{fontSize:`xs`,color:c?`whiteAlpha.600`:`blackAlpha.600`,textAlign:`right`,whiteSpace:`nowrap`,children:[`≈ `,no(e.valueInCurrency,{currency:l})]})]})]})]},e.aggregatorName)})}),y.length>0&&J(A,{children:[J(M,{justify:`space-between`,cursor:`pointer`,onClick:()=>g(!h),py:2,children:[J(R,{fontSize:`sm`,color:c?`whiteAlpha.600`:`blackAlpha.600`,children:[y.length,` `,a(`rate`),y.length===1?``:`s`,` `,a(`unavailable`)]}),q(N,{as:h?ir:tr,boxSize:4,color:c?`whiteAlpha.600`:`blackAlpha.600`})]}),q($e,{in:h,animateOpacity:!0,children:q(z,{spacing:2,align:`stretch`,pt:2,children:y.map(e=>q(A,{p:2,borderRadius:`xl`,bg:c?`#00000038`:`gray.50`,opacity:.6,children:J(M,{justify:`space-between`,children:[J(M,{spacing:2,align:`center`,children:[e.aggregator.getIcon(`20px`),q(R,{fontSize:`md`,fontWeight:`medium`,children:e.aggregatorName})]}),q(R,{fontSize:`xs`,color:c?`whiteAlpha.500`:`blackAlpha.500`,children:a(`Unable to fetch the price`)})]})},e.aggregatorName))})})]}),x.length===0&&y.length===0&&q(z,{spacing:2,py:8,color:c?`whiteAlpha.600`:`blackAlpha.600`,children:q(R,{fontSize:`lg`,children:a(`No quotes available`)})})]})})}),q(I,{})]})},cl=e=>e===`0x`||e===Ci||!e,ll=(e,t,n,r)=>{if(!e||!t||!n||!r)return null;let i=t.toLowerCase(),a=n.toLowerCase(),o=r.toLowerCase(),s=cl(n),c=cl(r),l=[],u=[];if(e.outputs&&Array.isArray(e.outputs))for(let t of e.outputs)t.events&&Array.isArray(t.events)&&l.push(...t.events),t.transfers&&Array.isArray(t.transfers)&&u.push(...t.transfers);let d=Qr.createInterface().getEvent(`Transfer`),f=d.topicHash.toLowerCase(),p=l.filter(e=>e.topics&&e.topics.length>0&&e.topics[0]?.toString().toLowerCase()===f),m=null,h=null;if(s){for(let e of u)if(e.sender?.toLowerCase()===i&&e.amount&&e.amount!==`0x0`&&e.amount!==`0x`){let t=BigInt(e.amount);if(t>0n){m=t;break}}}if(c){for(let e of u)if(e.recipient?.toLowerCase()===i&&e.amount&&e.amount!==`0x0`&&e.amount!==`0x`){let t=BigInt(e.amount);if(t>0n){h=t;break}}}if(p.length>0)for(let e of p)try{let t=pi({abi:[d],data:e.data.toString(),topics:e.topics.map(e=>e.toString())});if(!t.args||!(`from`in t.args)||!(`to`in t.args)||!(`value`in t.args))continue;let n=t.args.from?.toString().toLowerCase(),r=t.args.to?.toString().toLowerCase(),l=t.args.value,u=e.address.toLowerCase();!s&&n===i&&u&&u===a&&l>0n&&m===null&&(m=l),!c&&r===i&&u&&u===o&&l>0n&&h===null&&(h=l)}catch(e){console.warn(`Failed to decode transfer event:`,e);continue}return{fromAmount:m??0n,toAmount:h??0n}},ul=({setCurrentContent:e,fromTokenAddress:t,toTokenAddress:n})=>{let{t:r}=Y(),{account:i,connection:a}=Q(),{currentCurrency:c}=us(),{network:l,feeDelegation:u}=$(),{isolatedView:d,closeAccountModal:f}=Jc(),m=B(`colors`,`vechain-kit-card`),h=B(`colors`,`vechain-kit-card-hover`),g=B(`colors`,`vechain-kit-border`),_=B(`colors`,`vechain-kit-text-primary`),v=B(`colors`,`vechain-kit-text-secondary`),y=B(`colors`,`vechain-kit-text-tertiary`),{preferences:b}=Cp(),{sortedTokens:x}=ds({address:i?.address??``}),[S,C]=G(`main`),[w,ee]=G(null),[T,E]=G(null),[D,te]=G(``),[ne,re]=G(!1),[O,ie]=G(1),[ae,oe]=G(!1),[se,ce]=G(`1`),[le,ue]=G(null),[de,fe]=V.useState(null),[pe,me]=V.useState(null),[he,ge]=V.useState([]),{prices:_e,exchangeRates:ve}=ss(),ye=O===1;V.useEffect(()=>{ce(O===1?`1`:O===.5?`0.5`:O===3?`3`:O.toString())},[O]),V.useEffect(()=>{if(x.length!==0){if((t||n)&&(!w||!T)){if(t&&!w){let e=x.find(e=>o(e.address,t));e&&ee(e)}if(n&&!T){let e=x.find(e=>o(e.address,n));e&&E(e)}return}if(!w&&!T){let e=x.find(e=>e.symbol===`VET`);e&&ee(e);let t=x.find(e=>e.symbol===`B3TR`);if(!t)try{let e=k(l.type).b3trContractAddress;e&&(t=x.find(t=>o(t.address,e)))}catch(e){console.warn(`Failed to get B3TR address from config:`,e)}t&&E(t)}}},[x,w,T,t,n,l.type]);let be=H(()=>{if(w&&T){let e=w;ee(T),E(e),te(``)}},[w,T]);V.useEffect(()=>{ue(null)},[w?.address,T?.address,D]);let{bestQuote:xe,quotes:Se,isLoading:Ce,from:we,to:Te}=yc(w,T,D,i?.address??``,O,!!w&&!!T&&Number(D)>0),Ee=W(()=>{if(!D||Number(D)<=0||!we)return 0n;try{return xi(D,we.decimals)}catch{return 0n}},[D,we?.decimals]),De=le||xe,Oe=W(()=>{if(!De?.outputAmount||!Te)return`0`;try{return _i(De.outputAmount,Te.decimals)}catch{return`0`}},[De,Te?.decimals]),ke=W(()=>{if(!w||!D)return 0;let e=_e[w.address]||0;return eo(Number(D)*e,c,ve)},[w?.address,D,_e,c,ve]),Ae=W(()=>{if(!T||!Oe)return 0;let e=_e[T.address]||0;return eo(Number(Oe)*e,c,ve)},[T?.address,Oe,_e,c,ve]),je=W(()=>!w||!T||!i?.address||Ee===0n?null:{fromTokenAddress:w.address,toTokenAddress:T.address,amountIn:Ee.toString(),userAddress:i.address,slippageTolerance:O},[w,T,i?.address,Ee,O]),Me=De?.gasCostVTHO??0;V.useEffect(()=>{(async()=>{if(!De||!je||!De.aggregator){ge([]);return}try{ge(await De.aggregator.buildSwapTransaction(je,De))}catch(e){console.error(`Failed to build swap clauses for gas estimation:`,e),ge([])}})()},[De,je]);let Ne=b.availableGasTokens.length>0&&(a.isConnectedWithPrivy||a.isConnectedWithVeChain)&&!u?.delegatorUrl,{data:Pe,isLoading:Fe,error:Ie,refetch:Le}=wp({clauses:he,tokens:de?[de]:b.availableGasTokens,sendingAmount:D,sendingTokenSymbol:w?.symbol??``,enabled:Ne&&!!u?.genericDelegatorUrl&&he.length>0}),Re=Pe?.usedToken,ze=(Fe||!Pe)&&a.isConnectedWithPrivy&&!u?.delegatorUrl,Be=V.useCallback(e=>{fe(e),me(e),setTimeout(()=>Le(),100)},[Le]),Ve=!!Re&&!Ie;V.useEffect(()=>{Ie&&de&&fe(null)},[Ie,de]);let{executeSwap:He,isTransactionPending:Ue,isWaitingForWalletConfirmation:We,txReceipt:Ge,status:Ke,error:qe}=uc(je,De),Je=H(()=>{let t=Ge?.meta.txID??``,n=r(`Swap successful`,{defaultValue:`Swap successful`}),a;if(Ge&&w&&T&&i?.address){let e=ll(Ge,i.address,w.address,T.address);if(e&&we&&Te)try{let t=we.decimals,n=Te.decimals,i=_i(e.fromAmount,t),o=_i(e.toAmount,n),s=e=>{let t=Number(e);return t>=1e3?t.toLocaleString(void 0,{maximumFractionDigits:2}):t.toLocaleString(void 0,{maximumFractionDigits:6,minimumFractionDigits:0})};a=r(`You successfully swapped {fromAmount} {fromSymbol} for {toAmount} {toSymbol}`,{fromAmount:s(i),fromSymbol:w.symbol,toAmount:s(o),toSymbol:T.symbol,defaultValue:`You successfully swapped ${s(i)} ${w.symbol} for ${s(o)} ${T.symbol}`})}catch(e){console.warn(`Failed to format swap amounts:`,e)}}!a&&w&&T&&(a=r(`You successfully swapped {fromToken} for {toToken}`,{fromToken:w.symbol,toToken:T.symbol,defaultValue:`You successfully swapped ${w.symbol} for ${T.symbol}`})),e({type:`successful-operation`,props:{setCurrentContent:e,txId:t,title:n,description:a,onDone:()=>{d?f():e(`main`)},showSocialButtons:!0}})},[w,T,D,De,Ge,i?.address,e,r,d,f]),Xe=H(e=>{let t=typeof e==`string`?e:e.message;console.error(`Swap failed:`,t)},[w,T,D]),[Ze,Qe]=V.useState(!1);V.useEffect(()=>{if(Ke===`ready`){Qe(!1);return}Ze||(Ke===`success`&&Ge&&!Ge.reverted?(Qe(!0),Je()):Ke===`error`&&qe?Xe(qe?.reason||qe?.message||String(qe)):Ge?.reverted&&Xe(`Transaction reverted`))},[Ke,Ge,qe,Je,Xe,Ze]);let et=H(e=>{if(ee(e),e.symbol===`VET`&&!T){let e=x.find(e=>e.symbol===`B3TR`);if(!e)try{let t=k(l.type).b3trContractAddress;t&&(e=x.find(e=>o(e.address,t)))}catch(e){console.warn(`Failed to get B3TR address from config:`,e)}e&&E(e)}C(`main`)},[T,x,l.type]),nt=H(e=>{E(e),C(`main`)},[]),rt=H(e=>{(/^\d*\.?\d*$/.test(e)||e===``)&&te(e)},[]),it=H(()=>{w&&te(w.balance)},[w]),at=e=>{if(!e)return null;let t=s[e.symbol],n=p[e.symbol];return{symbol:e.symbol,logoComponent:t,logoUrl:n,balance:e.balance,value:e.valueInCurrency}},ot=at(w),st=at(T);return S===`select-from-token`?q(rl,{setCurrentContent:e,onSelectToken:et,onBack:()=>C(`main`),showAllTokens:!1}):S===`select-quote`?q(sl,{quotes:Se,selectedQuote:De,toTokenAddress:T?.address??null,onSelectQuote:e=>{ue(e),C(`main`)},onBack:()=>C(`main`)}):S===`select-to-token`?q(rl,{setCurrentContent:e,onSelectToken:nt,onBack:()=>C(`main`),showAllTokens:!0}):J(K,{children:[J(Z,{children:[q(L,{children:r(`Swap`)}),!d&&q(Ja,{onClick:()=>e(`main`)}),q(F,{})]}),q(tt,{maxW:`container.lg`,p:0,children:q(P,{children:J(z,{spacing:2,align:`stretch`,w:`full`,children:[J(A,{px:6,py:a.isConnectedWithPrivy?2:6,borderRadius:`xl`,bg:m,children:[q(R,{fontSize:`sm`,fontWeight:`medium`,color:v,mb:2,children:r(`From`)}),J(z,{align:`stretch`,spacing:2,children:[J(M,{justify:`space-between`,children:[q(dt,{placeholder:`0`,value:D,onChange:e=>rt(e.target.value),fontSize:`4xl`,fontWeight:`bold`,variant:`unstyled`,"data-testid":`swap-amount-input`,type:`number`,inputMode:`decimal`,color:ot&&D&&Number(D)>Number(ot.balance)?`red.500`:_}),ot?J(j,{onClick:()=>C(`select-from-token`),variant:`outline`,size:`sm`,borderRadius:`full`,px:6,color:v,borderColor:g,_hover:{bg:h,borderColor:g},leftIcon:ot.logoComponent?V.cloneElement(ot.logoComponent,{boxSize:`20px`,borderRadius:`full`}):ot.logoUrl?q(ut,{src:ot.logoUrl,alt:`${ot.symbol} logo`,boxSize:`20px`,borderRadius:`full`,fallback:q(A,{boxSize:`20px`,borderRadius:`full`,bg:`whiteAlpha.200`,display:`flex`,alignItems:`center`,justifyContent:`center`,children:q(R,{fontSize:`8px`,fontWeight:`bold`,color:_,children:ot.symbol.slice(0,3)})})}):void 0,children:[ot.symbol,q(N,{as:tr,boxSize:5,color:v})]}):J(j,{onClick:()=>C(`select-from-token`),variant:`outline`,size:`sm`,borderRadius:`full`,px:6,color:v,borderColor:g,_hover:{bg:h,borderColor:g,color:v},children:[r(`Select token`),q(N,{as:tr,boxSize:5,color:v})]})]}),ot&&J(M,{spacing:1,fontSize:`sm`,justifyContent:`space-between`,color:v,children:[q(M,{spacing:2,alignItems:`center`,children:ke>0&&J(R,{color:v,children:[`≈`,` `,no(ke,{currency:c})]})}),q(R,{cursor:`pointer`,_hover:{color:v,textDecoration:`underline`},onClick:it,noOfLines:1,overflow:`hidden`,textOverflow:`ellipsis`,children:r(`Swap all`,{defaultValue:`Swap all`})})]})]})]}),q(Ye,{position:`relative`,marginTop:`-20px`,marginBottom:`-20px`,marginX:`auto`,bg:m,borderRadius:`xl`,w:`40px`,h:`40px`,zIndex:2,cursor:!w||!T||Ce?`not-allowed`:`pointer`,onClick:!w||!T||Ce?void 0:be,opacity:!w||!T||Ce?.5:1,children:Ce?q(At,{size:`sm`}):q(N,{as:Gn,boxSize:5,color:v})}),J(A,{px:6,py:a.isConnectedWithPrivy?2:6,borderRadius:`xl`,bg:m,children:[q(R,{fontSize:`sm`,fontWeight:`medium`,color:v,mb:2,children:r(`To`)}),J(z,{align:`stretch`,spacing:2,children:[J(M,{justify:`space-between`,alignItems:`center`,children:[q(dt,{value:Number(Oe).toLocaleString(void 0,{maximumFractionDigits:Number(Oe)>1e4?0:2}),readOnly:!0,variant:`unstyled`,fontSize:`4xl`,fontWeight:`bold`,"data-testid":`swap-output-amount`,color:_}),st?J(j,{onClick:()=>C(`select-to-token`),variant:`outline`,size:`sm`,borderRadius:`full`,px:6,color:v,borderColor:g,_hover:{bg:h,borderColor:g},leftIcon:st.logoComponent?V.cloneElement(st.logoComponent,{boxSize:`20px`,borderRadius:`full`}):st.logoUrl?q(ut,{src:st.logoUrl,alt:`${st.symbol} logo`,boxSize:`20px`,borderRadius:`full`,fallback:q(A,{boxSize:`20px`,borderRadius:`full`,bg:`whiteAlpha.200`,display:`flex`,alignItems:`center`,justifyContent:`center`,children:q(R,{fontSize:`8px`,fontWeight:`bold`,color:_,children:st.symbol.slice(0,3)})})}):void 0,children:[st.symbol,q(N,{as:tr,boxSize:5,color:v})]}):J(j,{onClick:()=>C(`select-to-token`),variant:`outline`,size:`sm`,borderRadius:`full`,px:6,color:v,borderColor:g,_hover:{bg:h,borderColor:g,color:v},children:[r(`Select token`),q(N,{as:tr,boxSize:5,color:v})]})]}),st&&J(M,{spacing:1,fontSize:`sm`,justifyContent:`space-between`,color:v,children:[q(M,{spacing:2,alignItems:`center`,children:Ae>0&&J(R,{color:v,children:[`≈`,` `,no(Ae,{currency:c})]})}),q(A,{})]})]})]}),q($e,{in:ne&&!!De,animateOpacity:!0,children:J(z,{spacing:1,align:`stretch`,p:4,borderRadius:`xl`,bg:m,children:[De&&J(M,{justify:`space-between`,children:[J(R,{fontSize:`xs`,color:v,children:[r(`Source`),`:`]}),J(M,{spacing:1.5,cursor:`pointer`,onClick:()=>C(`select-quote`),_hover:{opacity:.8},alignItems:`center`,children:[De.aggregator?.getIcon(`12px`),q(R,{fontSize:`xs`,color:_,children:De.aggregatorName})]})]}),J(z,{align:`stretch`,spacing:2,children:[J(M,{justify:`space-between`,cursor:`pointer`,onClick:()=>oe(!ae),children:[J(R,{fontSize:`xs`,color:v,children:[r(`Slippage tolerance`),`:`]}),J(R,{fontSize:`xs`,fontWeight:`medium`,color:_,children:[O,`%`]})]}),q($e,{in:ae,animateOpacity:!0,children:q(z,{spacing:3,align:`stretch`,pt:2,children:J(M,{spacing:2,children:[q(j,{size:`sm`,variant:ye?`solid`:`outline`,colorScheme:ye?`blue`:`gray`,onClick:()=>{ie(1)},flex:`0 0 auto`,minW:`60px`,borderRadius:`md`,fontSize:`xs`,color:_,children:`Auto`}),q(j,{size:`sm`,variant:O===.5?`solid`:`outline`,colorScheme:O===.5?`blue`:`gray`,onClick:()=>{ie(.5)},flex:`0 0 auto`,minW:`60px`,borderRadius:`md`,fontSize:`xs`,color:_,children:`0.5%`}),q(j,{size:`sm`,variant:O===3?`solid`:`outline`,colorScheme:O===3?`blue`:`gray`,onClick:()=>{ie(3)},flex:`0 0 auto`,minW:`60px`,borderRadius:`md`,fontSize:`xs`,color:_,children:`3%`}),J(ft,{size:`sm`,flex:1,children:[q(dt,{value:se,onChange:e=>{let t=e.target.value;if((/^\d*\.?\d*$/.test(t)||t===``)&&(ce(t),t!==``)){let e=parseFloat(t);!isNaN(e)&&e>=0&&e<=100&&ie(e)}},placeholder:`1`,borderRadius:`md`,textAlign:`right`,pr:8,fontSize:`xs`,color:_}),q(mt,{width:`2rem`,pointerEvents:`none`,children:q(R,{fontSize:`2xs`,color:v,children:`%`})})]})]})})})]}),J(M,{justify:`space-between`,children:[J(R,{fontSize:`xs`,color:v,children:[r(`Gas fee`),`:`]}),q(R,{fontSize:`xs`,fontWeight:`medium`,color:_,children:Me>0?`${Me.toLocaleString(void 0,{maximumFractionDigits:2})} VTHO`:`-`})]})]})}),q(A,{minH:`24px`,display:`flex`,alignItems:`center`,justifyContent:`center`,children:De&&q(j,{variant:`ghost`,size:`xs`,onClick:()=>re(!ne),rightIcon:q(N,{color:y,_hover:{color:v},as:ne?Jn:Un}),fontSize:`xs`,fontWeight:`light`,color:y,_hover:{color:v},children:r(ne?`Show Less`:`Show More`)})}),he.length>0&&a.isConnectedWithPrivy&&q(Np,{estimation:Pe,isLoading:Fe,isLoadingTransaction:Ue,onTokenChange:Be,clauses:he,userSelectedToken:pe})]})})}),q(I,{children:q(Ap,{buttonText:r(`Swap`),onConfirm:He,isSubmitting:Ue,isTxWaitingConfirmation:We,transactionPendingText:r(`Swapping...`),txReceipt:Ge,transactionError:qe,onError:e=>{Xe(e)},isDisabled:!w||!T||!D||Number(D)<=0||Ce||!De||De?.reverted===!0||!!(ot&&D&&Number(D)>Number(ot.balance))||ze,gasEstimationError:Ie,hasEnoughGasBalance:Ve,isLoadingGasEstimation:Fe,showGasEstimationError:!u?.delegatorUrl&&a.isConnectedWithPrivy,context:`transaction`})})]})},dl=({setCurrentContent:e,onBack:t=()=>e(`settings`),initialContentSource:n=`settings`})=>{let{t:r}=Y(),{isolatedView:i}=Jc(),a=B(`colors`,`vechain-kit-text-primary`),o=B(`colors`,`vechain-kit-text-secondary`),s=()=>{t()};return J(K,{children:[J(Z,{children:[q(L,{"data-testid":`modal-title`,children:r(`Choose your account name`)}),!i&&q(Ja,{onClick:s}),q(F,{})]}),q(P,{children:J(z,{spacing:6,align:`center`,py:8,children:[q(N,{as:Fr,boxSize:16,color:o}),J(z,{spacing:2,children:[q(R,{fontSize:`lg`,fontWeight:`500`,textAlign:`center`,color:a,children:r(`Finally say goodbye to 0x addresses`)}),q(R,{fontSize:`md`,color:o,textAlign:`center`,px:4,children:r(`Name your account to make it easier to exchange assets`)})]})]})}),q(I,{children:q(j,{variant:`vechainKitPrimary`,onClick:()=>e({type:`choose-name-search`,props:{name:``,setCurrentContent:e,initialContentSource:n}}),"data-testid":`choose-name-button`,children:r(`Choose name`)})})]})},fl=({domain:e,isCurrentDomain:t,onSelect:n})=>{let{connection:r}=Q(),{t:a}=Y(),o=Ws(e.name,r.network),s=B(`colors`,`vechain-kit-card`),c=B(`colors`,`vechain-kit-card-hover`),l=B(`colors`,`vechain-kit-border`),u=B(`colors`,`vechain-kit-text-primary`),f=B(`colors`,`vechain-kit-text-secondary`),p=B(`colors`,`vechain-kit-card`);return q(_t,{p:4,bg:s,borderRadius:`xl`,cursor:t?`default`:`pointer`,opacity:t?.7:1,border:`1px solid ${l}`,_hover:{bg:t?c:s,borderColor:l},onClick:()=>!t&&n(e.name),transition:`all 0.2s`,children:J(M,{spacing:3,align:`center`,children:[q(kp,{props:{width:`40px`,height:`40px`,src:o.image??i(e.name),alt:e.name}}),J(z,{align:`start`,spacing:0,flex:1,children:[q(R,{color:u,fontSize:`md`,fontWeight:`500`,children:d(e.name,24,0)}),t&&q(R,{fontSize:`sm`,color:f,children:a(`Current domain`)})]}),t&&q(Nt,{size:`sm`,bg:p,color:u,px:3,py:1,borderRadius:`full`,children:a(`Current`)})]})},e.name)},pl=({onUnset:e})=>{let t=B(`colors`,`vechain-kit-card`),n=B(`colors`,`vechain-kit-card-hover`),r=B(`colors`,`vechain-kit-border`),i=B(`colors`,`vechain-kit-text-primary`),a=B(`colors`,`vechain-kit-text-secondary`),o=B(`colors`,`vechain-kit-error`),{t:s}=Y();return q(_t,{p:4,bg:t,borderRadius:`xl`,cursor:`pointer`,opacity:1,border:`1px solid ${r}`,_hover:{bg:n,borderColor:r,color:`red.400`},onClick:e,transition:`all 0.2s`,role:`button`,"aria-label":s(`Unset current domain`),children:J(M,{spacing:3,align:`center`,children:[q(A,{width:`40px`,height:`40px`,borderRadius:`full`,display:`flex`,alignItems:`center`,justifyContent:`center`,bg:t,children:q(N,{as:Ir,fontSize:`18px`,color:o})}),J(z,{align:`start`,spacing:0,flex:1,children:[q(R,{color:i,fontSize:`md`,fontWeight:`500`,children:s(`Unset current domain`)}),q(R,{fontSize:`sm`,color:a,children:s(`Remove your current domain name`)})]})]})},`unset-domain-list-item`)},ml=({domains:e,onDomainSelect:t,onUnsetDomain:n,isLoading:r})=>{let{t:i}=Y(),{account:a}=Q(),o=B(`colors`,`vechain-kit-card`),s=B(`colors`,`vechain-kit-card-hover`),c=B(`colors`,`vechain-kit-text-primary`),l=B(`colors`,`vechain-kit-text-secondary`);return e.length===0||r?null:q(Ie,{allowToggle:!0,children:q(Re,{border:`none`,children:({isExpanded:u})=>J(K,{children:[J(Le,{bg:o,borderRadius:`xl`,_hover:{bg:s},opacity:r?.7:1,transition:`all 0.2s`,disabled:r,children:[q(A,{flex:`1`,textAlign:`left`,py:2,children:q(R,{fontWeight:`500`,color:c,children:r?i(`Loading your domains...`):`${i(`Your existing domains`)} (${e.length})`})}),q(N,{as:u?ir:tr,fontSize:`20px`,color:l})]}),q(ze,{pb:4,pt:2,children:J(gt,{spacing:2,children:[e.map(e=>q(fl,{domain:e,isCurrentDomain:e.name===a?.domain,onSelect:t},e.name)),a?.domain&&q(pl,{onUnset:n})]})})]})})})},hl=({name:e,setCurrentContent:t,initialContentSource:n=`settings`})=>{let{t:r}=Y(),{account:i}=Q(),{darkMode:a}=$(),{isolatedView:o}=Jc(),[s,c]=G(Ui(e)),[l,u]=G(null),[d,f]=G(!1),[p,m]=G(!1),[h,g]=G(!1),_=B(`colors`,`vechain-kit-error`),v=B(`colors`,`vechain-kit-success`),y=B(`colors`,`vechain-kit-text-secondary`),{data:b,isLoading:x}=mo(s),{data:S,isLoading:C}=uo(`${s}.veworld.vet`),{data:w,isLoading:ee}=Oo(s),{data:T,isLoading:E}=No(i?.address,``),D=x||C||ee;U(()=>{if(!h)return;let e=/[^a-zA-Z0-9-]|\s/.test(s);s.length<3?(u(r(`Name must be at least 3 characters long`)),m(!1),f(!1)):e?(u(r(`Only letters, numbers, and hyphens are allowed`)),m(!1),f(!1)):w?(u(r(`This domain is protected`)),m(!1),f(!1)):b?S?.address?.toLowerCase()===i?.address?.toLowerCase()?(u(null),m(!0),f(!0)):(u(r(`This domain is already taken`)),m(!1),f(!1)):x||(u(null),m(!0),f(!1))},[s,h,b,x,S,i?.address,w,p,D]);let te=()=>{p&&!l&&t({type:`choose-name-summary`,props:{fullDomain:s+`.veworld.vet`,isOwnDomain:d,setCurrentContent:t,initialContentSource:n}})},ne=e=>{let r=e.split(`.`);t({type:`choose-name-summary`,props:{fullDomain:e,domainType:r.length>2?`${r[1]}.${r[2]}`:`vet`,isOwnDomain:!0,setCurrentContent:t,initialContentSource:n}})},re=()=>{t({type:`choose-name-summary`,props:{fullDomain:``,domainType:``,isOwnDomain:!1,isUnsetting:!0,setCurrentContent:t,initialContentSource:n}})},O=()=>{t(n)};return J(K,{children:[J(Z,{children:[q(L,{"data-testid":`modal-title`,children:r(`Choose Name`)}),!o&&q(Ja,{onClick:O}),q(F,{})]}),q(P,{children:J(z,{spacing:4,align:`stretch`,children:[q(ml,{domains:T?.domains||[],onDomainSelect:ne,onUnsetDomain:re,isLoading:E}),J(ft,{size:`lg`,children:[q(dt,{placeholder:r(`Enter your name`),value:s,onChange:e=>{c(Ui(e.target.value)),h||g(!0)},paddingRight:`120px`,fontSize:`lg`,height:`60px`,bg:a?`#00000038`:`white`,border:`1px solid ${a?`#ffffff29`:`#ebebeb`}`,_hover:{border:`1px solid ${a?`#ffffff40`:`#e0e0e0`}`},_focus:{border:`1px solid ${a?`#ffffff60`:`#d0d0d0`}`,boxShadow:`none`},isInvalid:!!l,"data-testid":`domain-input`}),q(mt,{width:`auto`,paddingRight:`12px`,h:`full`,children:q(A,{mr:4,fontSize:`sm`,color:y,children:`.veworld.vet`})})]}),l&&h&&q(R,{color:_,fontSize:`sm`,"data-testid":`domain-availability-status`,children:l}),!l&&h&&s.length>=3&&q(R,{fontSize:`sm`,color:p?v:_,fontWeight:`500`,"data-testid":`domain-availability-status`,children:r(d?`YOU OWN THIS`:p?`AVAILABLE`:`UNAVAILABLE`)})]})}),q(I,{children:q(j,{variant:`vechainKitPrimary`,isDisabled:!p||!!l||w||D,onClick:te,"data-testid":`continue-button`,children:r(`Continue`)})})]})},gl=({setCurrentContent:e,fullDomain:t,domainType:n=`veworld.vet`,isOwnDomain:r,isUnsetting:i=!1,initialContentSource:a=`settings`})=>{let{t:o}=Y(),s=B(`colors`,`vechain-kit-text-primary`),{isolatedView:c,closeAccountModal:l}=Jc(),{account:u,connectedWallet:d,connection:f}=Q(),{data:p}=Pf(u?.address??``,d?.address??``,3),{open:m}=Pd(),{preferences:h}=Cp(),{feeDelegation:g}=$(),_=e=>{console.error(`Transaction failed:`,e)},v=ts({onSuccess:()=>D()}),y=n.endsWith(`veworld.vet`),b=bo({subdomain:t.split(`.veworld.vet`)[0],domain:n,alreadyOwned:r,onSuccess:()=>D()}),x=wo({domain:!i&&!y?t:``,alreadyOwned:r,onSuccess:()=>D()}),{sendTransaction:S,txReceipt:C,error:w,isWaitingForWalletConfirmation:ee,isTransactionPending:T,clauses:E}=i?v:y?b:x,D=()=>{e({type:`successful-operation`,props:{setCurrentContent:e,txId:C?.meta.txID,title:o(i?`Domain unset`:`Domain set`),description:i?o(`Your domain has been unset successfully.`):o(`Your address has been successfully set to {{name}}`,{name:t}),onDone:()=>{c?l():e(a)}}})},te=async()=>{if(p){m();return}try{await S()}catch(e){console.error(`Transaction failed:`,e)}},ne=()=>{te()},re=()=>{e({type:`choose-name-search`,props:{setCurrentContent:e,name:t,initialContentSource:a}})},[O,ie]=V.useState(null),[ae,oe]=V.useState(null),se=h.availableGasTokens.length>0&&(f.isConnectedWithPrivy||f.isConnectedWithVeChain)&&!g?.delegatorUrl,{data:k,isLoading:ce,error:le,refetch:ue}=wp({clauses:E(),tokens:O?[O]:h.availableGasTokens,enabled:se&&!!g?.genericDelegatorUrl}),de=k?.usedToken,fe=(ce||!k)&&f.isConnectedWithPrivy&&!g?.delegatorUrl,pe=V.useCallback(e=>{ie(e),oe(e),setTimeout(()=>ue(),100)},[ue]),me=!!de&&!le;return V.useEffect(()=>{le&&O&&ie(null)},[le,O]),J(K,{children:[J(Z,{children:[q(L,{"data-testid":`confirm-domain`,children:o(i?`Confirm Unset Domain`:`Confirm Name`)}),q(Ja,{onClick:re,isDisabled:T}),q(F,{isDisabled:T})]}),J(P,{children:[J(z,{spacing:4,w:`full`,textAlign:`center`,children:[q(R,{fontSize:`lg`,color:s,children:o(i?`Are you sure you want to unset your current domain?`:`Are you sure you want to set your domain name to`)}),!i&&q(R,{fontSize:`xl`,fontWeight:`bold`,color:s,"data-testid":`preconfirm-domain-val`,children:`${t}`})]}),f.isConnectedWithPrivy&&q(Np,{estimation:k,isLoading:ce,isLoadingTransaction:T,onTokenChange:pe,clauses:E(),userSelectedToken:ae})]}),q(I,{gap:4,w:`full`,children:q(Ap,{transactionError:w,isSubmitting:T,isTxWaitingConfirmation:ee,onConfirm:te,onRetry:ne,transactionPendingText:o(i?`Unsetting current domain...`:`Claiming name...`),txReceipt:C,buttonText:o(`Confirm`),isDisabled:T||fe,onError:_,gasEstimationError:le,hasEnoughGasBalance:me,isLoadingGasEstimation:ce,showGasEstimationError:!g?.delegatorUrl&&f.isConnectedWithPrivy,context:`domain`})})]})},_l=()=>{let{t:e}=Y(),[t,n]=G(``),r=B(`colors`,`vechain-kit-card`),i=B(`colors`,`vechain-kit-text-secondary`),a=B(`colors`,`vechain-kit-text-tertiary`),o=B(`colors`,`vechain-kit-card`),s=B(`colors`,`vechain-kit-card-elevated`),c=[{question:e(`What is VeChain?`),answer:e(`VeChain, headquartered in San Marino, Europe, is a pioneering blockchain ecosystem and creator of VeChainThor, a world-class smart contract platform driving real-world blockchain adoption. Founded in 2015 by Sunny Lu, VeChain has consistently worked to deliver a transparent, efficient, scalable, and adaptable blockchain solution.`)},{question:e(`What is a wallet?`),answer:e(`A wallet is your gateway to the VeChain blockchain. It stores your private keys and allows you to securely manage your digital assets, send and receive tokens, and interact with decentralized applications. Think of it as your digital bank account for blockchain transactions.`)},{question:e(`What is a Smart Account?`),answer:e(`A Smart Account is a smart contract wallet that provides enhanced security and functionality. It allows for features like social recovery, transaction batching, and more.`)},{question:e(`How is my wallet secured?`),answer:e(`Your wallet security depends on how you access it. With self-custody options like the VeWorld extension, mobile app, or hardware wallet, you have complete control over your private keys. This extension itself has no access to your private keys. When logging in with social accounts or VeChain, your wallet is created and secured by Privy and managed by VeChain, providing an easier onboarding experience while maintaining security.`)},{question:e(`How do I backup my wallet?`),answer:e(`Backing up your wallet is crucial as you are the only one with access to your private keys. If something goes wrong, having your private key is the only way to recover your assets. How to backup depends on how you access your wallet: If using VeWorld, the backup option is available within the app. For social login users, you can find backup options in the Wallet section. If you're connected through VeChain or another ecosystem app, you'll need to visit the original website, log in, and access the Wallet section from there.`)},{question:e(`What is a network?`),answer:e(`A network in blockchain refers to the environment where transactions take place. VeChain has two main networks: Mainnet (the live network where real transactions occur) and Testnet (a testing environment for developers). The network you're connected to is displayed at the top of this modal.`)},{question:e(`What is a domain name?`),answer:e(`A domain name is a sort of nickname for your wallet address. It allows you to easily identify your wallet and interact with dApps using a human-readable name. For example, if your wallet address is 0x1234567890, your nickname could be "alice.vechain".`)},{question:e(`What is Privy?`),answer:e(`Privy builds user onboarding and embedded wallet infrastructure to enable better products built on crypto rails. This means embedding asset control within applications themselves to enable users, businesses or machines to use digital assets through seamless product experiences.`)},{question:e(`What is VeBetterDAO?`),answer:e(`VeBetterDAO is a decentralized organization on VeChain blockchain focused on sustainability. Members participate in the governance of the DAO using B3TR tokens for rewards and VOT3 for voting in proposals and weekly token allocation rounds.`)},{question:e(`What is an x2earn application?`),answer:e(`An X2Earn application in VeBetterDAO is a sustainable app that rewards users with B3TR tokens for eco-friendly actions. These apps must distribute B3TR, link user wallets, and provide proof of sustainable actions. They join VeBetterDAO through endorsement and participate in weekly token allocation rounds.`)},{question:e(`What is B3TR?`),answer:e(`B3TR is the incentive token of VeBetterDAO, built on VechainThor blockchain. It has a capped supply of 1 billion tokens, emitted weekly over 12 years. B3TR is used for rewards, governance, and backing VOT3 tokens 1:1. It supports sustainability applications and DAO treasury management.`)},{question:e(`What is VET?`),answer:e(`VET is the primary cryptocurrency of the VeChain network. It represents value and ownership in the VeChain ecosystem, similar to how stocks represent ownership in a company. Holding VET automatically generates VTHO, which is needed to pay for transactions on the network.`)},{question:e(`What is VTHO?`),answer:e(`VTHO (VeThor) is the energy or 'gas' token of the VeChain network. It's used to pay for transaction fees when interacting with the blockchain. VTHO is automatically generated by holding VET tokens, creating a two-token system that helps maintain network stability and manage transaction costs.`)},{question:e(`How do I send tokens?`),answer:e(`You can send tokens by clicking the send icon in the Quick Actions section. Enter the recipient's address or VeChain domain name, select the token, and specify the amount you want to send.`)},{question:e(`What is fee delegation?`),answer:e(`Fee delegation is a unique feature of VeChain that allows someone else (a delegator) to pay for your transaction fees. While many dApps and service providers act as delegators to make it easier for new users to get started, some transactions may still require you to pay fees using your own VTHO. Fees are necessary to prevent network spam and compensate the nodes that process and validate transactions on the blockchain. When paying fees yourself, you'll be able to select VTHO from your assets to cover the transaction cost.`)}].filter(e=>e.question.toLowerCase().includes(t.toLowerCase())||typeof e.answer==`string`&&e.answer.toLowerCase().includes(t.toLowerCase()));return J(z,{spacing:4,align:`stretch`,children:[J(ft,{size:`lg`,children:[q(dt,{placeholder:e(`Search FAQ`),bg:r,borderRadius:`xl`,height:`56px`,pl:12,value:t,onChange:e=>n(e.target.value)}),q(pt,{h:`56px`,w:`56px`,pl:4,children:q(kr,{color:a})})]}),c.length===0?J(z,{spacing:2,py:8,color:i,children:[q(N,{as:Pr,boxSize:12,opacity:.5}),q(R,{fontSize:`lg`,children:e(`No questions found`)}),q(R,{fontSize:`md`,children:e(`Try searching with a different term`)})]}):q(Ie,{allowMultiple:!0,children:c.map((e,t)=>q(Re,{border:`none`,mb:2,children:({isExpanded:t})=>J(K,{children:[J(Le,{bg:o,borderRadius:`xl`,color:i,_hover:{bg:s},children:[q(A,{flex:`1`,textAlign:`left`,py:2,children:q(R,{fontWeight:`500`,color:i,children:e.question})}),q(N,{as:t?ir:tr,fontSize:`20px`,opacity:.5})]}),q(ze,{pb:4,children:q(R,{fontSize:`sm`,color:i,opacity:.8,children:e.answer})})]})},t))})]})},vl=({onGoBack:e,showLanguageSelector:t=!0})=>{let{i18n:n,t:r}=Y(),{isolatedView:i}=Jc(),a=B(`colors`,`vechain-kit-card`),o=B(`colors`,`vechain-kit-border`),s=B(`colors`,`vechain-kit-border-hover`);return J(Op,{children:[J(Z,{children:[q(L,{children:r(`Help`)}),!i&&q(Ja,{onClick:e}),q(F,{})]}),q(P,{w:`full`,children:J(z,{spacing:6,align:`stretch`,children:[t&&q(Ot,{borderRadius:`md`,size:`sm`,width:`auto`,value:n.language,onChange:e=>{n.changeLanguage(e.target.value)},bg:a,borderColor:o,_hover:{borderColor:s},children:va.map(e=>q(`option`,{value:e,children:ba[e]},e))}),q(j,{as:ht,href:`https://docs.vechainkit.vechain.org/`,isExternal:!0,variant:`vechainKitSecondary`,rightIcon:q(N,{as:fr}),children:r(`For developers`)}),q(_l,{})]})}),q(I,{pt:0})]})},yl=({setCurrentContent:e,initialContentSource:t=`profile`})=>{let{t:n}=Y(),{network:i}=$(),{account:a}=Q(),o=B(`colors`,`vechain-kit-text-primary`),s=B(`colors`,`vechain-kit-error`),c=B(`colors`,`vechain-kit-card`),l=Zt(null),u=Zt(null),[d,f]=G(!1),{onUpload:p}=sc({compressImage:!0}),[m,h]=G(null),[g,_]=G(null),v=!!a?.domain,[y,b]=G(null),[x,S]=G(``),[C,w]=G(``),{register:ee,watch:T,formState:{errors:E,isValid:D}}=Hi({defaultValues:{displayName:a?.metadata?.display||``,description:a?.metadata?.description||``},mode:`onChange`});U(()=>{if(a?.metadata){let e=a.metadata;S(e.display||``),w(e.description||``),b(a.image?a.image.replace(`ipfs://`,``):null),h(e=>e??a.image??null)}},[a,i.type]);let te=T(),ne=async e=>{let t=e.target.files?.[0];if(t)try{f(!0),m&&URL.revokeObjectURL(m),h(URL.createObjectURL(t));let e=await p(t);if(!e)throw Error(`Failed to compress image`);_(await r(e.file,t.name,i.type))}catch(e){console.error(`Error uploading image:`,e),h(null)}finally{f(!1)}};U(()=>()=>{m&&URL.revokeObjectURL(m)},[m]);let re=()=>{let e={};return g!==y&&g&&(e.avatarIpfsHash=g),te.displayName!==x&&(e.displayName=te.displayName),te.description!==C&&(e.description=te.description),e},O=W(()=>{let e=re();return Object.keys(e).length>0},[re]),ie=()=>{e({type:`account-customization-summary`,props:{setCurrentContent:e,changes:re(),onDoneRedirectContent:t}})},ae=()=>{e(t)};return J(A,{children:[J(Z,{children:[q(L,{"data-testid":`modal-title`,children:n(`Customization`)}),q(Ja,{onClick:ae}),q(F,{})]}),J(P,{children:[J(Ge,{variant:`vechainKitBase`,position:`relative`,overflow:`visible`,justifyContent:`center`,alignItems:`center`,children:[J(A,{cursor:v?`pointer`:`default`,pt:2,onClick:()=>v&&l.current?.click(),children:[q(kp,{wallet:a,props:{width:`100px`,height:`100px`,boxShadow:`0px 0px 3px 2px #00000024`,src:m??void 0}}),v&&q(N,{as:$n,position:`absolute`,top:`80px`,left:`60%`,bg:c,color:o,p:`1`,borderRadius:`full`,boxSize:`6`}),d&&q(A,{display:`flex`,alignItems:`center`,justifyContent:`center`,backgroundColor:`rgba(0, 0, 0, 0.5)`,borderRadius:`full`,children:q(R,{fontSize:`xs`,color:`white`,children:d?`Uploading...`:`Processing...`})})]}),q(Ke,{w:`full`,backgroundColor:`none`,border:`none`,children:J(z,{spacing:6,children:[!v&&q(Gc,{}),q(Fc,{title:a?.domain??n(`Choose account name`),description:n(`Choose a unique .vet domain name for your account.`),onClick:()=>{a?.domain?e({type:`choose-name-search`,props:{name:``,setCurrentContent:e,initialContentSource:{type:`account-customization`,props:{setCurrentContent:e}}}}):e({type:`choose-name`,props:{setCurrentContent:e,initialContentSource:{type:`account-customization`,props:{setCurrentContent:e}},onBack:()=>e({type:`account-customization`,props:{setCurrentContent:e}})}})},leftIcon:Fr,rightIcon:rr,dataTestId:`set-domain-name-button`}),J(it,{isDisabled:!v,isInvalid:!!E.displayName,children:[q(at,{fontSize:`sm`,fontWeight:`medium`,color:o,children:n(`Display Name`)}),q(dt,{...ee(`displayName`,{maxLength:{value:25,message:n(`Display name must be less than 25 characters`)}}),placeholder:n(v?`Enter your display name`:`Set a domain first`),fontWeight:`medium`,color:o,"data-testid":`display-name-input`}),E.displayName&&q(R,{color:s,fontSize:`sm`,mt:1,fontWeight:`medium`,children:E.displayName.message})]}),J(it,{isDisabled:!v,isInvalid:!!E.description,children:[q(at,{fontSize:`sm`,fontWeight:`medium`,color:o,children:n(`Description`)}),q(Pt,{...ee(`description`,{maxLength:{value:100,message:n(`Description must be less than 100 characters`)}}),placeholder:n(`Eg: DevRel @ ENS Labs`),fontWeight:`medium`,color:o,"data-testid":`description-input`,minH:`50px`}),E.description&&q(R,{color:s,mt:1,fontSize:`sm`,fontWeight:`medium`,children:E.description.message})]})]})})]}),q(`input`,{type:`file`,ref:l,hidden:!0,accept:`image/*`,onChange:async e=>await ne(e)}),q(`input`,{type:`file`,ref:u,hidden:!0,accept:`image/*`,onChange:async e=>{e.preventDefault()}})]}),q(I,{w:`full`,children:q(j,{variant:`vechainKitPrimary`,onClick:ie,isDisabled:!v||!O||!D,isLoading:d,loadingText:n(`Preparing changes...`),"data-testid":`save-changes-button`,children:n(`Save Changes`)})})]})},bl=({setCurrentContent:e,changes:t,onDoneRedirectContent:n})=>{let{t:r}=Y(),{darkMode:i,network:a,feeDelegation:o}=$(),{account:s,connectedWallet:c,connection:l}=Q(),{preferences:u}=Cp(),{data:d}=Pf(s?.address??``,c?.address??``,3),{open:f}=Pd(),{handleSubmit:p}=Hi({defaultValues:{...t,avatarIpfsHash:t.avatarIpfsHash??void 0}}),m=s?.domain??``,{data:h}=Wo(m),g=zn(),{sendTransaction:_,txReceipt:v,error:y,isWaitingForWalletConfirmation:b,isTransactionPending:S,clauses:C}=Ho({resolverAddress:h,signerAccountAddress:s?.address??``,onSuccess:async()=>{e({type:`successful-operation`,props:{setCurrentContent:e,txId:v?.meta.txID,title:r(`Profile Updated`),description:r(`Your changes have been saved successfully.`),onDone:()=>{e(n)}}});try{await pe()}catch(e){console.error(`Error refreshing data:`,e)}},onError:e=>{console.error(`Error updating text record:`,e)}}),w=W(()=>{let e=s?.domain??``,n={displayName:`display`,description:`description`,twitter:`com.x`,website:`url`,email:`email`,avatarIpfsHash:`avatar`};return Object.entries(t).filter(e=>e[1]!==void 0&&e[1]!==null).map(([t,r])=>({domain:e,key:n[t],value:t===`avatarIpfsHash`?`ipfs://${r}`:r}))},[t,s?.domain]),ee=W(()=>{try{return!h||w.length===0||!C?[]:C(w)}catch(e){return console.error(`Error building clauses:`,e),[]}},[w,C,h]),[T,E]=V.useState(null),[D,te]=V.useState(null),ne=u.availableGasTokens.length>0&&(l.isConnectedWithPrivy||l.isConnectedWithVeChain)&&!o?.delegatorUrl,{data:re,isLoading:O,error:ie,refetch:ae}=wp({clauses:ee,tokens:T?[T]:u.availableGasTokens,enabled:ne&&!!o?.genericDelegatorUrl}),oe=re?.usedToken,se=(O||!re)&&l.isConnectedWithPrivy&&!o?.delegatorUrl,k=V.useCallback(e=>{E(e),te(e),setTimeout(()=>ae(),100)},[ae]),ce=!!oe&&!ie;V.useEffect(()=>{ie&&T&&E(null)},[ie,T]);let le=async()=>{if(d){f();return}try{w.length>0&&await _(w)}catch(e){console.error(`Error saving changes:`,e)}},ue=(e,t)=>t?.trim()?J(z,{align:`flex-start`,w:`full`,spacing:1,children:[q(R,{fontSize:`sm`,color:i?`whiteAlpha.600`:`blackAlpha.600`,children:e}),q(R,{fontSize:`md`,children:t})]}):null,de=()=>{p(le)()},fe=()=>{e({type:`account-customization`,props:{setCurrentContent:e}})},pe=async()=>{t.avatarIpfsHash&&(g.setQueryData(Po(m,a.type),x(`ipfs://`+t.avatarIpfsHash,a.type)),g.setQueryData(Go(s?.address??``),x(`ipfs://`+t.avatarIpfsHash,a.type))),await g.invalidateQueries({queryKey:Ro(m,a.type)}),await g.refetchQueries({queryKey:Ro(m,a.type)})};return J(A,{as:`form`,onSubmit:p(le),children:[J(Z,{children:[q(L,{children:r(`Confirm Changes`)}),q(Ja,{isDisabled:S,onClick:fe}),q(F,{isDisabled:S})]}),J(P,{children:[J(z,{spacing:4,align:`stretch`,children:[t.avatarIpfsHash&&J(z,{align:`flex-start`,w:`full`,spacing:1,children:[q(R,{fontSize:`sm`,color:i?`whiteAlpha.600`:`blackAlpha.600`,children:r(`Profile Image`)}),q(R,{fontSize:`md`,children:r(`New image selected`)})]}),t.displayName&&ue(r(`Display Name`),t.displayName),t.description&&ue(r(`Description`),t.description),t.twitter&&ue(r(`Twitter`),t.twitter),t.website&&ue(r(`Website`),t.website),t.email&&ue(r(`Email`),t.email)]}),l.isConnectedWithPrivy&&q(Np,{estimation:re,isLoading:O,isLoadingTransaction:S,onTokenChange:k,clauses:ee,userSelectedToken:D})]}),q(I,{gap:4,w:`full`,children:q(Ap,{transactionError:y,isSubmitting:S,isTxWaitingConfirmation:b,onConfirm:p(le),onRetry:de,transactionPendingText:r(`Saving changes...`),txReceipt:v,buttonText:r(`Confirm`),isDisabled:S||se,gasEstimationError:ie,hasEnoughGasBalance:ce,isLoadingGasEstimation:O,showGasEstimationError:!o?.delegatorUrl&&l.isConnectedWithPrivy,context:`customization`})})]})},xl=({onEditClick:e,address:t,showHeader:n=!0,onLogout:r,showLinks:a=!0,showDescription:o=!0,showDisplayName:s=!0,showEdit:c=!0,style:l})=>{let{t:u}=Y(),{account:d,disconnect:f}=Q(),{network:p}=$(),{openAccountModal:m,closeAccountModal:h}=rd(),g=B(`colors`,`vechain-kit-text-primary`),_=B(`colors`,`vechain-kit-text-secondary`),v=Ws(t,p.type),y=i(t),b=t===d?.address,x=v?.records?.url||v?.records?.[`com.x`]||v?.records?.email;return J(Ge,{variant:`vechainKitBase`,...l?.card,children:[q(A,{p:0,backgroundSize:`100% !important`,backgroundPosition:`center`,position:`relative`,h:`80px`,background:n?`no-repeat url('${y}')`:`none`,w:`100%`,borderRadius:`14px 14px 0 0`}),q(A,{position:`absolute`,top:`30px`,left:`50%`,transform:`translateX(-50%)`,children:q(kp,{wallet:{address:t,domain:v?.domain,image:v?.image,isLoadingMetadata:v?.isLoading,metadata:v?.records},props:{width:`120px`,height:`120px`}})}),q(Ke,{mt:`60px`,backgroundColor:`none`,border:`none`,...l?.body,children:J(z,{w:`full`,spacing:2,children:[s&&v?.records?.display&&q(R,{fontSize:`xl`,color:g,fontWeight:`bold`,w:`full`,textAlign:`center`,mt:2,"data-testid":`display-name-val`,children:v?.records?.display}),o&&v?.records?.description&&q(R,{fontSize:`sm`,color:_,w:`full`,textAlign:`center`,"data-testid":`description-val`,children:v?.records?.description}),a&&x&&J(M,{w:`full`,justify:`center`,spacing:5,mt:4,children:[v?.records?.email&&q(ht,{href:`mailto:${v?.records?.email}`,target:`_blank`,"data-testid":`mail-link`,children:q(N,{as:Sr,color:g})}),v?.records?.url&&q(ht,{href:v?.records?.url,target:`_blank`,"data-testid":`website-link`,children:q(N,{as:_r,color:g})}),v?.records?.[`com.x`]&&q(ht,{href:`https://x.com/${v?.records?.[`com.x`]}`,target:`_blank`,"data-testid":`twitter-link`,children:q(N,{as:Ki,color:g})})]}),q(Ya,{wallet:{address:t,domain:v?.domain,image:v?.image,isLoadingMetadata:v?.isLoading,metadata:v?.records},style:{mt:4}})]})}),b&&c&&q(qe,{justify:`space-between`,...l?.footer,children:J(z,{w:`full`,justify:`space-between`,spacing:4,children:[q(nt,{}),J(M,{w:`full`,justify:`space-between`,children:[q(j,{size:`md`,width:`full`,height:`40px`,variant:`ghost`,leftIcon:q(N,{as:wr}),onClick:e??(()=>{m({type:`account-customization`,props:{setCurrentContent:()=>h()}})}),"data-testid":`customize-button`,children:u(`Customize`)}),q(j,{size:`md`,width:`full`,height:`40px`,variant:`ghost`,leftIcon:q(N,{as:xr}),colorScheme:`red`,onClick:r??(()=>{m({type:`disconnect-confirm`,props:{onDisconnect:()=>{f(),h()},onBack:()=>h()}})}),"data-testid":`logout-button`,children:u(`Logout`)})]})]})})]})},Sl=({setCurrentContent:e,onLogoutSuccess:t})=>{let{t:n}=Y(),{isolatedView:r}=Jc(),{account:i,disconnect:a}=Q();return J(A,{children:[J(Z,{children:[q(L,{"data-testid":`modal-title`,children:n(`Profile`)}),!r&&q(Ja,{onClick:()=>e(`main`)}),q(F,{})]}),q(P,{w:`full`,children:J(z,{w:`full`,spacing:2,children:[!i?.domain&&q(Uc,{setCurrentContent:e}),q(xl,{onEditClick:()=>{e({type:`account-customization`,props:{setCurrentContent:e,initialContentSource:`profile`}})},address:i?.address??``,showHeader:!1,style:{card:{bg:`transparent`,px:0},footer:{px:0}},onLogout:()=>{e?.({type:`disconnect-confirm`,props:{onDisconnect:()=>{a(),t?.()},onBack:()=>e?.(`profile`)}})}})]})}),q(I,{pt:0})]})},Cl=({setCurrentContent:e,handleClose:t,initialContent:n=`access-and-security`})=>{let{t:r}=Y(),{smartAccount:i,connectedWallet:a}=Q(),{data:o}=Pf(i?.address??``,a?.address??``,3),{sendTransaction:s,isTransactionPending:c,isWaitingForWalletConfirmation:l,error:u,txReceipt:d}=zf({smartAccountAddress:i?.address??``,targetVersion:3,onSuccess:()=>{e({type:`successful-operation`,props:{setCurrentContent:e,txId:d?.meta.txID,title:r(`Upgrade Successful!`),description:r(`Your account has been successfully upgraded to the latest version. You can now enjoy a better user experience, lower gas costs, and enhanced security.`),onDone:()=>{t?t():e(n)},showSocialButtons:!1}})},onError:()=>{console.error(`Error upgrading Smart Account`)}});return J(K,{children:[J(Z,{children:[q(L,{children:r(`Account upgrade required`)}),q(Ja,{onClick:()=>{e(n)}}),q(F,{})]}),q(P,{children:J(z,{spacing:10,align:`stretch`,children:[q(R,{fontSize:`sm`,textAlign:`center`,children:r(o?`Your smart account needs to be upgraded to the latest version (v3).`:`Your smart account is already upgraded to this version.`)}),J(M,{align:`center`,justifyContent:`space-evenly`,rounded:`md`,children:[J(A,{position:`relative`,display:`inline-block`,children:[q(Qe,{size:`60px`,bg:`gray.200`,children:q(ut,{borderRadius:`full`,src:i?.image,alt:r(`Profile Picture`),w:`100%`,h:`100%`,objectFit:`cover`})}),q(ct,{position:`absolute`,top:`-5`,right:`-5`,color:`#D23F63`,fontSize:`28px`,children:`v1`})]}),q(N,{as:qn,color:`#3DBA67`}),J(A,{position:`relative`,display:`inline-block`,children:[q(Qe,{size:`60px`,bg:`gray.200`,children:q(ut,{borderRadius:`full`,src:i?.image,alt:r(`Profile Picture`),w:`100%`,h:`100%`,objectFit:`cover`})}),q(ct,{position:`absolute`,top:`-5`,right:`-5`,color:`#3DBA67`,fontSize:`28px`,children:`v3`})]})]}),J(Be,{status:`info`,borderRadius:`md`,children:[q(He,{}),J(A,{children:[q(Ue,{fontSize:`sm`,children:r(`Benefits of this upgrade:`)}),q(Ve,{fontSize:`xs`,children:J(z,{align:`start`,spacing:0,mt:1,children:[J(R,{fontSize:`xs`,lineHeight:`1.2`,children:[`• `,r(`Improved security features`)]}),J(R,{fontSize:`xs`,children:[`• `,r(`Better transaction handling`)]}),J(R,{fontSize:`xs`,children:[`•`,` `,r(`Enhanced compatibility with dApps`)]}),J(R,{fontSize:`xs`,children:[`•`,` `,r(`Reduced gas costs for operations`)]})]})})]})]})]})}),q(I,{justifyContent:`center`,children:J(z,{spacing:3,w:`full`,children:[q(Ap,{buttonText:r(o?`Upgrade account`:`Account already upgraded`),onConfirm:async()=>{try{await s()}catch(e){console.error(`Failed to upgrade Smart Account:`,e)}},isTxWaitingConfirmation:l,isSubmitting:c,transactionPendingText:r(`Upgrading...`),txReceipt:d,transactionError:u,isDisabled:!o}),q(j,{mt:2,variant:`link`,onClick:()=>{t?t():e(n)},isDisabled:c,children:r(o?`Close and do this later`:`Close`)})]})})]})},wl=({setCurrentContent:e})=>{let{account:t}=Q(),{sortedTokens:n}=ds({address:t?.address}),{allowCustomTokens:r,darkMode:i}=$(),{currentCurrency:a}=us(),o=B(`colors`,`vechain-kit-text-tertiary`),{t:s}=Y(),{isolatedView:c}=Jc(),[l,u]=G(``),d=t=>{e({type:`send-token`,props:{setCurrentContent:e,preselectedToken:t,onBack:()=>e(`assets`)}})},f=n.filter(({symbol:e})=>e.toLowerCase().includes(l.toLowerCase()));return J(K,{children:[J(Z,{children:[q(L,{children:s(`Assets`)}),!c&&q(Ja,{onClick:()=>e(`main`)}),q(F,{})]}),J(tt,{h:[`540px`,`auto`],p:0,children:[J(P,{children:[J(ft,{size:`lg`,children:[q(dt,{placeholder:`Search token`,bg:i?`#00000038`:`gray.50`,borderRadius:`xl`,height:`56px`,pl:12,value:l,onChange:e=>u(e.target.value),"data-testid":`search-token-input`}),q(pt,{h:`56px`,w:`56px`,pl:4,children:q(kr,{color:o})})]}),q(z,{spacing:2,align:`stretch`,mt:2,children:f.map(e=>{let t=Number(e.balance)>0;return q(ro,{symbol:e.symbol,amount:Number(e.balance),currencyValue:e.valueInCurrency,currentCurrency:a,onClick:()=>d(e),isDisabled:!t},e.address)})})]}),q(I,{children:r&&q(j,{variant:`vechainKitSecondary`,leftIcon:q(N,{as:wr,boxSize:4}),onClick:()=>e(`add-custom-token`),children:s(`Manage Custom Tokens`)})})]})]})},Tl=({setCurrentContent:e})=>{let{t}=Y(),n=B(`colors`,`vechain-kit-text-primary`),r=B(`colors`,`vechain-kit-text-secondary`),i=B(`colors`,`vechain-kit-card`),a=B(`colors`,`vechain-kit-overlay`),{addToken:o,removeToken:s,isTokenIncluded:c,isDefaultToken:u,customTokens:d}=bs(),{register:f,setError:m,setValue:h,formState:{errors:g,isValid:_},handleSubmit:v}=Hi({defaultValues:{newTokenAddress:``},mode:`onChange`}),y=async e=>{if(e.newTokenAddress){if(c(e.newTokenAddress)||u(e.newTokenAddress))return m(`newTokenAddress`,{type:`manual`,message:t(`Token already added`)});try{await o(e.newTokenAddress),h(`newTokenAddress`,``)}catch(e){console.error(`Error adding token 2:`,e),m(`newTokenAddress`,{type:`manual`,message:t(`Invalid token address`)})}}};return J(K,{children:[J(Z,{children:[q(L,{children:t(`Manage Custom Tokens`)}),q(Ja,{onClick:()=>e(`assets`)}),q(F,{})]}),q(P,{children:J(z,{spacing:4,align:`stretch`,position:`relative`,children:[q(A,{p:6,borderRadius:`xl`,bg:i,children:q(z,{align:`stretch`,spacing:2,children:J(it,{isInvalid:!!g.newTokenAddress,children:[q(at,{fontSize:`sm`,fontWeight:`medium`,color:n,children:t(`Token Contract Address`)}),q(dt,{...f(`newTokenAddress`,{required:t(`Address is required`),pattern:{value:/^0x[a-fA-F0-9]{40}$/,message:t(`Please enter a valid contract address`)},validate:e=>/^0x[a-fA-F0-9]{40}$/.test(e)||t(`Invalid contract address`)}),onChange:e=>{let t=e.target.value.trim();e.target.value=t,h(`newTokenAddress`,t,{shouldValidate:!0})},placeholder:`0x...`,variant:`outline`,fontSize:`md`,fontWeight:`medium`}),g.newTokenAddress&&q(R,{color:`#ef4444`,fontSize:`sm`,children:g.newTokenAddress.message})]})})}),d.length>0&&J(A,{p:4,borderRadius:`xl`,bg:a,children:[q(R,{fontSize:`sm`,fontWeight:`medium`,mb:2,children:t(`Existing Custom Tokens`)}),q(z,{align:`stretch`,spacing:2,children:d.map(e=>J(M,{justify:`space-between`,fontSize:`sm`,p:2,borderRadius:`md`,bg:i,children:[J(M,{children:[q(ut,{src:p[e?.symbol],alt:`${e.symbol} logo`,boxSize:`20px`,borderRadius:`full`,fallback:q(A,{boxSize:`20px`,borderRadius:`full`,bg:`whiteAlpha.200`,display:`flex`,alignItems:`center`,justifyContent:`center`,children:q(R,{fontSize:`8px`,fontWeight:`bold`,color:n,children:e.symbol?.slice(0,3)})})}),q(R,{fontWeight:`medium`,color:n,children:e.symbol??`Unknown`})]}),q(R,{color:r,children:l(e.address??``,4,4)}),q(j,{size:`sm`,variant:`ghost`,color:n,borderRadius:`md`,p:2,onClick:()=>s(e.address),children:q(Ir,{size:16,color:n})})]},e.address))})]})]})}),q(I,{children:q(j,{variant:`vechainKitPrimary`,isDisabled:!_,onClick:v(y),children:t(`Add Token`)})})]})},El=({setCurrentContent:e})=>{let{t}=Y(),{darkMode:n}=$(),{isolatedView:r}=Jc();return J(K,{children:[J(Z,{children:[q(L,{children:t(`Bridge`)}),!r&&q(Ja,{onClick:()=>e(`main`)}),q(F,{})]}),q(tt,{maxW:`container.lg`,children:q(P,{children:J(z,{spacing:6,align:`center`,w:`full`,children:[q(Oe,{isDark:n,borderRadius:`xl`}),q(R,{fontSize:`sm`,textAlign:`center`,children:t(`Exchange your digital assets between VeChain and other blockchain networks easily and securely. Swaps are executed through partners that leverage both decentralized and centralized exchanges to convert tokens.`)})]})})}),q(I,{children:J(j,{variant:`vechainKitSecondary`,onClick:()=>{window.open(`https://swap.vechain.energy/`,`_blank`)},children:[t(`Launch vechain.energy`),q(N,{as:fr,ml:2})]})})]})},Dl=({setCurrentContent:e})=>{let{t}=Y(),{currentCurrency:n,changeCurrency:r,allCurrencies:i}=us();U(()=>{h(`settings-currency-visited`,`true`)},[]);let a=e=>J(j,{w:`full`,variant:`ghost`,justifyContent:`space-between`,onClick:()=>r(e),py:6,px:4,children:[J(M,{spacing:3,children:[q(R,{fontSize:`xl`,children:c[e]}),q(R,{children:e.toUpperCase()})]}),n===e&&q(N,{as:er,boxSize:5,color:`blue.500`})]},e);return J(Op,{children:[J(Z,{children:[q(L,{children:t(`Select currency`)}),q(Ja,{onClick:()=>e(`general-settings`)}),q(F,{})]}),q(P,{w:`full`,children:q(z,{justify:`center`,spacing:3,align:`flex-start`,w:`full`,children:i.map(e=>a(e))})}),q(I,{pt:0})]})},Ol=({setCurrentContent:e})=>{let{connection:t}=Q(),{t:n}=Y(),{feeDelegation:r}=$(),i=B(`colors`,`vechain-kit-text-secondary`);return J(Op,{children:[J(Z,{children:[q(L,{children:n(`General`)}),q(Ja,{onClick:()=>e(`settings`)}),q(F,{})]}),q(P,{w:`full`,children:J(z,{justify:`center`,spacing:3,align:`flex-start`,w:`full`,children:[q(z,{w:`full`,justifyContent:`center`,spacing:3,mb:3,children:q(R,{fontSize:`sm`,color:i,textAlign:`center`,children:n(`Manage your preferences for currency, language, and appearance.`)})}),J(z,{w:`full`,justifyContent:`center`,spacing:0,children:[q(Fc,{title:n(`Currency`),style:{borderBottomRadius:`0px`},onClick:()=>{e(`change-currency`)},leftIcon:ur,rightIcon:rr}),q(Fc,{title:n(`Language`),style:{borderTopRadius:`0px`,...t.isConnectedWithPrivy?{borderBottomRadius:`0px`}:{}},onClick:()=>{e(`change-language`)},leftIcon:br,rightIcon:rr}),t.isConnectedWithPrivy&&!r?.delegatorUrl&&q(Fc,{title:n(`Gas Token Preferences`),style:{borderTopRadius:`0px`},onClick:()=>{e(`gas-token-settings`)},leftIcon:mr,rightIcon:rr})]}),q(Fc,{title:n(`Terms and Policies`),onClick:()=>{e({type:`terms-and-privacy`,props:{onGoBack:()=>e(`settings`)}})},leftIcon:Mr,rightIcon:rr})]})}),q(I,{pt:0})]})},kl=({setCurrentContent:e})=>{let{t,i18n:n}=Y(),r=e=>{n.changeLanguage(e)},i=e=>J(j,{w:`full`,variant:`ghost`,justifyContent:`space-between`,onClick:()=>r(e),py:6,px:4,children:[q(R,{children:ba[e]}),n.language===e&&q(N,{as:er,boxSize:5,color:`blue.500`})]},e);return J(Op,{children:[J(Z,{children:[q(L,{children:t(`Select language`)}),q(Ja,{onClick:()=>e(`general-settings`)}),q(F,{})]}),q(P,{w:`full`,children:q(z,{justify:`center`,spacing:3,align:`flex-start`,w:`full`,children:va.map(e=>i(e))})}),q(I,{pt:0})]})},Al=({setCurrentContent:e})=>{let{t}=Y();return J(Op,{children:[J(Z,{children:[q(L,{children:t(`General`)}),q(Ja,{onClick:()=>e(`general-settings`)}),q(F,{})]}),q(P,{w:`full`,children:J(z,{justify:`center`,spacing:3,align:`flex-start`,w:`full`,children:[q(z,{w:`full`,justifyContent:`center`,spacing:3,mb:3,children:q(R,{fontSize:`sm`,opacity:.5,textAlign:`center`,children:t(`Customize the appearance of your wallet.`)})}),q(z,{w:`full`,justifyContent:`center`,spacing:0})]})}),q(I,{pt:0})]})},jl=({token:e,index:t,isExcluded:n,onToggleExclusion:r,onDragStart:i,onDragOver:a,onDrop:o,onTouchStart:s,onTouchMove:c,onTouchEnd:l,isDragging:u,isDraggedOver:d})=>{let p=f[e],{darkMode:m}=$(),h=B(`colors`,`vechain-kit-text-primary`),g=B(`colors`,`vechain-kit-text-secondary`),_=B(`colors`,`vechain-kit-card`);return q(A,{bg:m?`#ffffff0a`:`blackAlpha.50`,borderRadius:`md`,border:`1px`,borderColor:u?m?`blue.500`:`blue.300`:d?m?`blue.400`:`blue.200`:_,p:3,mb:2,opacity:u||n?.5:1,cursor:`move`,transition:`background-color 0.2s ease, border-color 0.2s ease`,draggable:!0,onDragStart:()=>i(t),onDragOver:e=>{e.preventDefault(),a(t)},onDrop:()=>o(t),onTouchStart:e=>s(t,e),onTouchMove:c,onTouchEnd:l,_hover:{backgroundColor:m?`#ffffff12`:`blackAlpha.200`},children:J(M,{justify:`space-between`,children:[J(M,{opacity:n?.5:1,children:[q(A,{cursor:`grab`,_active:{cursor:`grabbing`},pointerEvents:`none`,children:q(N,{as:vr,color:g})}),J(z,{align:`start`,spacing:0,children:[q(R,{fontWeight:`medium`,color:h,children:p.name}),q(R,{fontSize:`sm`,color:g,children:p.description})]})]}),q(Mt,{isChecked:!n,onChange:()=>r(e),colorScheme:`blue`,size:`sm`})]})})},Ml=({tokens:e,excludedTokens:t,onReorder:n,onToggleExclusion:r})=>{let[i,a]=G(null),[o,s]=G(null),c=Zt([]),l=Zt(0),u=e=>{a(e)},d=e=>{s(e)},f=t=>{if(i===null||i===t){a(null),s(null);return}let r=[...e],o=r[i];r.splice(i,1),r.splice(t,0,o),n(r),a(null),s(null)},p=(e,t)=>{l.current=t.touches[0].clientY,a(e)},m=e=>{if(i===null)return;let t=e.touches[0].clientY;for(let e=0;e<c.current.length;e++){let n=c.current[e];if(!n)continue;let r=n.getBoundingClientRect();if(t>=r.top&&t<=r.bottom){s(e);break}}},h=()=>{if(i!==null&&o!==null&&i!==o){let t=[...e],r=t[i];t.splice(i,1),t.splice(o,0,r),n(t)}a(null),s(null),l.current=0};return q(A,{w:`full`,children:e.map((e,n)=>q(A,{ref:e=>{c.current[n]=e},children:q(jl,{token:e,index:n,isExcluded:t.includes(e),onToggleExclusion:r,onDragStart:u,onDragOver:d,onDrop:f,onTouchStart:p,onTouchMove:m,onTouchEnd:h,isDragging:i===n,isDraggedOver:o===n})},e))})},Nl=({setCurrentContent:e})=>{let{t}=Y(),{preferences:n,reorderTokenPriority:r,toggleTokenExclusion:i}=Cp(),a=B(`colors`,`vechain-kit-text-primary`),o=B(`colors`,`vechain-kit-text-secondary`),s=H(e=>{r(e)},[r]);return J(Op,{children:[J(Z,{children:[q(L,{children:t(`Gas Token Preferences`)}),q(Ja,{onClick:()=>e(`general-settings`)}),q(F,{})]}),q(P,{w:`full`,children:J(z,{justify:`center`,spacing:6,align:`flex-start`,w:`full`,children:[q(z,{w:`full`,justifyContent:`center`,spacing:3,mb:3,children:q(R,{fontSize:`sm`,color:o,textAlign:`center`,children:t(`Choose which tokens to use for transaction fees when the app is not covering them.`)})}),n.availableGasTokens.length===0&&J(Be,{status:`warning`,borderRadius:`md`,children:[q(He,{}),q(Ve,{fontSize:`sm`,color:o,children:t(`You must enable at least one token to perform transactions. Without any enabled tokens, you will not be able to pay for gas fees.`)})]}),J(z,{w:`full`,align:`start`,spacing:3,children:[q(R,{fontSize:`md`,fontWeight:`semibold`,color:a,children:t(`Token Priority Order`)}),q(R,{fontSize:`sm`,color:o,children:t(`Drag to reorder. The system will automatically use the highest priority token with sufficient balance.`)}),q(Ml,{tokens:n.tokenPriority,excludedTokens:n.excludedTokens,onReorder:s,onToggleExclusion:i})]})]})})]})},Pl=({title:e,description:t,icon:n})=>{let r=B(`colors`,`vechain-kit-text-secondary`),i=B(`colors`,`vechain-kit-text-primary`);return J(z,{spacing:6,align:`center`,py:8,children:[q(N,{as:n,boxSize:16,color:r}),J(z,{spacing:2,children:[q(R,{fontSize:`lg`,fontWeight:`500`,textAlign:`center`,color:i,children:e}),q(R,{fontSize:`md`,color:r,textAlign:`center`,px:4,children:t})]})]})},Fl=(e,t=`en-US`)=>new Intl.DateTimeFormat(t,{month:`short`,day:`numeric`}).format(new Date(e)),Il=({document:e})=>{let{t}=Y(),n=B(`colors`,`vechain-kit-text-secondary`),r=e.documentSource===m.VECHAIN_KIT&&e.documentType===se.TERMS;return J(M,{children:[J(Nt,{size:`sm`,borderRadius:`full`,color:n,children:[`v`,e.version]}),q(R,{fontSize:`xs`,cursor:`pointer`,color:n,onClick:()=>{window.open(e.url,`_blank`)},_hover:{textDecoration:`underline`},children:r?t(`'{{policyName}}' on connect`,{policyName:e.displayName??t(`Vechain Kit Policy`)}):t(`'{{policyName}}' on {{date}}`,{policyName:e.displayName??t(`Policy`),date:Fl(e.timestamp)})})]})},Ll=({title:e,description:t,documents:n,bg:r,hoverBg:i,currentPolicy:a})=>{let{t:o}=Y(),s=B(`colors`,`vechain-kit-text-primary`),c=B(`colors`,`vechain-kit-text-secondary`),l=n?.length>0,u=n?.find(e=>e.id===a?.id);return l?q(Re,{border:`none`,mb:3,children:({isExpanded:l})=>J(K,{children:[J(Le,{bg:r,borderRadius:`xl`,_hover:{bg:i},children:[J(z,{w:`full`,align:`flex-start`,textAlign:`left`,children:[q(R,{fontWeight:`700`,color:s,children:e}),q(R,{fontSize:`xs`,color:c,children:t})]}),q(N,{as:l?ir:tr,fontSize:`20px`,color:c})]}),q(ze,{pb:4,pt:3,children:J(z,{align:`stretch`,spacing:4,children:[u?.id?J(M,{w:`full`,children:[q(N,{as:er,color:s}),q(R,{fontSize:`xs`,color:c,children:o(`You accepted current policy on {{date}}`,{date:Fl(u.timestamp)})})]}):null,q(M,{w:`full`,textAlign:`left`,children:q(R,{fontSize:`xs`,fontWeight:`bold`,color:c,children:o(`All policies you have accepted`)})}),q(M,{w:`full`,gap:2,children:q(z,{align:`stretch`,spacing:2,children:n.map(e=>q(Il,{document:e},e.id))})}),a&&q(j,{variant:`outline`,size:`xs`,alignSelf:`flex-end`,onClick:()=>{window.open(a.url,`_blank`)},children:o(`View Current Policy`)})]})})]})}):null},Rl=()=>{let{account:e}=Q(),{t}=Y(),{darkMode:n}=$(),{agreements:r,documents:i}=Wp(),a=W(()=>{let t=r?.filter(t=>o(t.walletAddress,e?.address));return[{id:`vechain-kit-terms`,...E,documentType:se.TERMS,documentSource:m.VECHAIN_KIT,walletAddress:e?.address??``,timestamp:new Date().getTime()},...t]?.reduce((e,t)=>(e[t.documentType]=[...e[t.documentType]||[],t],e),{})},[r,e?.address]),s=W(()=>i.reduce((e,t)=>{let n=t.documentType;return(!e[n]||t.version>e[n].version)&&(e[n]=t),e},{}),[i]),c=W(()=>Object.values(a).some(e=>e.length>0),[a]),l=n?`whiteAlpha.50`:`blackAlpha.50`,u=n?`whiteAlpha.100`:`blackAlpha.100`;return c?q(z,{spacing:4,align:`stretch`,children:J(Ie,{allowMultiple:!0,children:[q(Ll,{title:t(`Terms and Conditions`),description:t(`Legal agreement between you, Vechain Kit and the current app, outlining the rules for using wallet services.`),documents:a[se.TERMS],bg:l,hoverBg:u,currentPolicy:s[se.TERMS]}),q(Ll,{title:t(`Privacy Policy`),description:t(`Privacy policy outlining the data collection and processing practices.`),documents:a[se.PRIVACY],bg:l,hoverBg:u,currentPolicy:s[se.PRIVACY]}),q(Ll,{title:t(`Cookie Policy`),description:t(`Cookie policy outlining the use of cookies and tracking technologies.`),documents:a[se.COOKIES],bg:l,hoverBg:u,currentPolicy:s[se.COOKIES]})]})}):q(Pl,{title:t(`No policies accepted`),description:t(`When you have accepted a policy, it will appear here`),icon:hr})},zl=({onGoBack:e})=>{let{t}=Y();return J(Op,{children:[J(Z,{children:[q(L,{children:t(`Terms and Policies`)}),q(Ja,{onClick:e}),q(F,{})]}),q(P,{w:`full`,children:q(z,{spacing:6,align:`stretch`,children:q(Rl,{})})}),q(I,{pt:0})]})},Bl=({onGoBack:e})=>{let{t}=Y(),{getConnectionCache:n}=Ud(),{connection:r}=Q(),i=n();return J(Op,{children:[J(Z,{children:[q(L,{children:t(`Connection Details`)}),q(Ja,{onClick:()=>{e()}}),q(F,{})]}),J(P,{w:`full`,children:[r.isConnectedWithCrossApp&&i&&q(Zc,{connectionCache:i}),r.isConnectedWithSocialLogin&&q($c,{}),r.isConnectedWithDappKit&&q(Qc,{})]}),q(I,{pt:0})]})},Vl=({accountType:e,accountDescription:t,isLoading:n,onConfirm:r,onCancel:i})=>{let{t:a}=Y();return J(z,{spacing:6,align:`stretch`,children:[q(R,{fontSize:`md`,textAlign:`center`,color:B(`colors`,`vechain-kit-text-primary`),children:a(`Are you sure you want to unlink {{accountType}} as a login method linked to {{accountDescription}}?`,{accountType:e,accountDescription:t})}),J(z,{spacing:3,w:`full`,children:[q(j,{height:`60px`,colorScheme:`red`,w:`full`,onClick:r,isLoading:n,children:a(`Remove Login Method`)}),q(j,{isLoading:n,height:`60px`,w:`full`,onClick:i,children:a(`Cancel`)})]})]})},Hl=({onBack:e})=>{let{t}=Y(),{privy:n,dappKit:r}=$(),[i,a]=G(null),[o,s]=G(!1),[c,u]=G(!1),[d,f]=G(!1),p=B(`colors`,`vechain-kit-text-primary`),m=B(`colors`,`vechain-kit-text-secondary`),{user:h,linkEmail:g,linkGoogle:_,linkTwitter:v,linkPhone:y,linkSpotify:b,linkApple:x,linkInstagram:S,linkTiktok:C,linkGithub:w,linkLinkedIn:ee,linkTelegram:T,linkFarcaster:E,linkPasskey:D,linkDiscord:te,unlinkEmail:ne,unlinkGoogle:re,unlinkApple:O,unlinkSpotify:ie,unlinkInstagram:ae,unlinkTiktok:oe,unlinkGithub:se,unlinkLinkedIn:k,unlinkTelegram:ce,unlinkFarcaster:le,unlinkPhone:ue,unlinkPasskey:de,unlinkDiscord:fe,linkWallet:pe}=Tn(),me=W(()=>{let e=n?.loginMethods?.filter(e=>[`rabby_wallet`,`coinbase_wallet`,`rainbow`,`phantom`,`metamask`].includes(e))??[],t=r?.allowedWallets??[];return e.length>0||t.length>0},[n?.loginMethods,r?.allowedWallets]),he=e=>{switch(e){case`google_oauth`:return Vi;case`email`:return Sr;case`passkey`:return pr;case`wallet`:return Br;case`twitter_oauth`:return Ki;case`phone`:return Tr;case`spotify_oauth`:return Qi;case`apple_oauth`:return Ji;case`instagram_oauth`:return Xi;case`tiktok_oauth`:return ta;case`github_oauth`:return gr;case`linkedin_oauth`:return Zi;case`telegram`:return $i;case`farcaster`:return qi;case`discord_oauth`:return Yi;default:return}},ge=()=>{let e=h?.linkedAccounts?.filter(e=>e.type!==`wallet`||e.type===`wallet`&&e.connectorType!==`embedded`);return e&&e?.length>1},_e=async e=>{if(ge()){f(!0);try{switch(e.type){case`google_oauth`:await re(e.subject);break;case`email`:await ne(e.address);break;case`passkey`:await de(e.subject);break;case`phone`:await ue(e.number);break;case`spotify_oauth`:await ie(e.subject);break;case`apple_oauth`:await O(e.subject);break;case`instagram_oauth`:await ae(e.subject);break;case`tiktok_oauth`:await oe(e.subject);break;case`github_oauth`:await se(e.subject);break;case`linkedin_oauth`:await k(e.subject);break;case`telegram`:await ce(e.subject);break;case`farcaster`:await le(e.subject);break;case`discord_oauth`:await fe(e.subject);break;default:break}}catch(e){console.error(e)}finally{f(!1),a(null)}}},ve=e=>{switch(e.type){case`google_oauth`:return e.email;case`email`:return e.address;case`passkey`:return`${e.authenticatorName} - ${e.createdWithBrowser}`;case`phone`:return e.number;case`wallet`:return`${l(e.address)} - ${e.walletClientType}`;default:return``}},ye=h?.linkedAccounts?.map(e=>e.type)||[],be=n?.loginMethods||[],xe=!ye.includes(`google_oauth`)&&be.includes(`google`),Se=!ye.includes(`email`)&&be.includes(`email`),Ce=!ye.includes(`twitter_oauth`)&&be.includes(`twitter`),we=!ye.includes(`phone`)&&be.includes(`sms`),Te=!ye.includes(`spotify_oauth`)&&be.includes(`spotify`),Ee=!ye.includes(`apple_oauth`)&&be.includes(`apple`),De=!ye.includes(`instagram_oauth`)&&be.includes(`instagram`),Oe=!ye.includes(`tiktok_oauth`)&&be.includes(`tiktok`),ke=!ye.includes(`github_oauth`)&&be.includes(`github`),Ae=!ye.includes(`linkedin_oauth`)&&be.includes(`linkedin`),je=!ye.includes(`telegram`)&&be.includes(`telegram`),Me=!ye.includes(`farcaster`)&&be.includes(`farcaster`),Ne=!ye.includes(`discord_oauth`)&&be.includes(`discord`);return o?J(Op,{children:[J(Z,{children:[q(L,{children:t(`Select Additional Login Method`)}),q(Ja,{onClick:()=>s(!1)}),q(F,{})]}),q(P,{w:`full`,children:J(z,{spacing:3,align:`stretch`,w:`full`,children:[q(Fc,{title:t(`Set up Passkey`),description:t(`Set up a passkey for easier access`),onClick:()=>D(),leftIcon:pr}),xe&&q(Fc,{title:t(`Link Google Account`),description:t(`Connect your Google account for easier access`),onClick:()=>_(),leftIcon:Vi}),Se&&q(Fc,{title:t(`Link Email Account`),description:t(`Connect your email for easier access`),onClick:()=>g(),leftIcon:Sr,stacked:!0}),Ce&&q(Fc,{title:t(`Link Twitter Account`),description:t(`Connect your Twitter account for easier access`),onClick:()=>v(),leftIcon:Ki}),we&&q(Fc,{title:t(`Link Phone Number`),description:t(`Connect your phone number for easier access`),onClick:()=>y(),leftIcon:Tr}),Te&&q(Fc,{title:t(`Link Spotify Account`),description:t(`Connect your Spotify account for easier access`),onClick:()=>b(),leftIcon:Qi}),Ee&&q(Fc,{title:t(`Link Apple Account`),description:t(`Connect your Apple account for easier access`),onClick:()=>x(),leftIcon:Ji}),De&&q(Fc,{title:t(`Link Instagram Account`),description:t(`Connect your Instagram account for easier access`),onClick:()=>S(),leftIcon:Xi}),Oe&&q(Fc,{title:t(`Link Tiktok Account`),description:t(`Connect your Tiktok account for easier access`),onClick:()=>C(),leftIcon:ta}),ke&&q(Fc,{title:t(`Link Github Account`),description:t(`Connect your Github account for easier access`),onClick:()=>w(),leftIcon:gr}),Ae&&q(Fc,{title:t(`Link LinkedIn Account`),description:t(`Connect your LinkedIn account for easier access`),onClick:()=>ee(),leftIcon:Zi}),je&&q(Fc,{title:t(`Link Telegram Account`),description:t(`Connect your Telegram account for easier access`),onClick:()=>T(),leftIcon:$i}),Me&&q(Fc,{title:t(`Link Farcaster Account`),description:t(`Connect your Farcaster account for easier access`),onClick:()=>E(),leftIcon:qi}),Ne&&q(Fc,{title:t(`Link Discord Account`),description:t(`Connect your Discord account for easier access`),onClick:()=>te(),leftIcon:Yi}),me&&q(Fc,{title:t(`Link External Wallet`),description:t(`Connect an external wallet for easier access`),onClick:()=>pe(),leftIcon:Br}),!xe&&!Se&&!Ce&&!we&&!Te&&!Ee&&!De&&!Oe&&!ke&&!Ae&&!je&&!Me&&!Ne&&q(R,{fontSize:`sm`,textAlign:`center`,opacity:.7,children:t(`No additional accounts available to link`)})]})}),q(I,{pt:0})]}):i?J(Op,{children:[J(Z,{children:[q(L,{children:t(`Remove Login Method`)}),q(Ja,{onClick:()=>a(null)}),q(F,{})]}),q(P,{children:q(Vl,{accountType:i.type,accountDescription:ve(i),isLoading:d,onConfirm:()=>_e(i),onCancel:()=>a(null)})}),q(I,{pt:0})]}):J(Op,{children:[J(Z,{children:[q(L,{children:t(`Login methods`)}),q(Ja,{onClick:e}),q(F,{})]}),q(P,{w:`full`,children:J(z,{spacing:3,align:`center`,w:`full`,justify:`center`,children:[J(z,{spacing:1,justify:`flex-start`,alignItems:`flex-start`,mb:5,textAlign:`left`,w:`full`,children:[q(R,{fontSize:`sm`,color:m,children:t(`These accounts are linked to your embedded wallet and can be used to login to your wallet and access your private key.`)}),c&&q(R,{fontSize:`sm`,color:m,children:t(`Adding more linked accounts increases security against loss of access, but also introduces additional potential attack vectors. For enhanced security, we recommend enabling MFA.`)}),q(j,{variant:`link`,mt:0,size:`sm`,onClick:()=>u(!c),color:p,children:t(c?`Show Less`:`Read More`)})]}),h?.linkedAccounts?.filter(e=>e.type!==`wallet`||e.type===`wallet`&&e.connectorType!==`embedded`).map(e=>J(rt,{p:4,borderWidth:`1px`,borderRadius:`md`,align:`center`,justify:`space-between`,w:`full`,children:[J(rt,{align:`center`,gap:3,children:[q(N,{as:he(e.type),color:p}),J(z,{align:`start`,spacing:0,children:[q(R,{fontWeight:`500`,color:p,children:e.type===`google_oauth`?t(`Google`):e.type===`email`?t(`Email`):e.type===`passkey`?t(`Passkey`):e.type===`twitter_oauth`?t(`Twitter`):e.type===`phone`?t(`Phone Number`):e.type===`spotify_oauth`?t(`Spotify`):e.type===`apple_oauth`?t(`Apple`):e.type===`instagram_oauth`?t(`Instagram`):e.type===`tiktok_oauth`?t(`Tiktok`):e.type===`github_oauth`?t(`Github`):e.type===`linkedin_oauth`?t(`LinkedIn`):e.type===`telegram`?t(`Telegram`):e.type===`farcaster`?t(`Farcaster`):e.type===`discord_oauth`?t(`Discord`):t(`Wallet`)}),q(R,{fontSize:`sm`,color:m,children:ve(e)})]})]}),q(j,{size:`sm`,variant:`ghost`,colorScheme:`red`,isDisabled:!ge(),onClick:()=>{e.type===`passkey`?D():a(e)},children:t(`Remove`)})]},e.type))]})}),q(I,{w:`full`,children:q(j,{w:`full`,variant:`vechainKitPrimary`,onClick:()=>s(!0),leftIcon:q(N,{as:Er}),isDisabled:!xe&&!Se&&!Ce&&!we&&!Te&&!Ee&&!De&&!Oe&&!ke&&!Ae&&!je&&!Me&&!Ne,children:t(`Add Login Method`)})})]})},Ul=[{id:`welcome`,title:`Welcome to the VeChain`,description:`Welcome! Here you can manage your wallet, send tokens, and interact with the VeChain blockchain and its applications.`,timestamp:Date.now(),status:`success`,isRead:!1}],Wl=()=>{let{t:e}=Y(),{account:t,connection:n,smartAccount:r}=Q(),{addNotification:i,getNotifications:a}=Gl(),{data:o}=Lf(r?.address??``,3);U(()=>{if(!n.isConnectedWithPrivy||!t?.address)return;let r=a(),s=`smart_account_upgrade_${t.address.toLowerCase()}`;!r.some(e=>e.id===s)&&o&&i({id:s,title:e(`Account Upgrade Required`),description:e(`A new upgrade is available for your smart account. Please head over to the 'Access and Security' section to upgrade it.`),status:`warning`})},[n.isConnectedWithPrivy,t?.address,o]),U(()=>{!n.isConnectedWithPrivy||!t?.address||a().some(e=>e.id===`smart_account_${t.address.toLowerCase()}`)||i({id:`smart_account_${t.address.toLowerCase()}`,title:e(`Smart Account detected`),description:e(`You have an active smart account associated to this wallet. It has been set as your main identity.`),status:`info`})},[n.isConnectedWithPrivy,t?.address]),U(()=>{if(!n.isConnectedWithPrivy||!t?.address)return;let r=a(),o=r.some(e=>e.id===`multiclause_warning_${t.address.toLowerCase()}`),s=r.some(e=>e.id===`multiclause_support_${t.address.toLowerCase()}`);o&&!s&&i({id:`multiclause_support_${t.address.toLowerCase()}`,title:e(`Multiclause Transactions Are Now Supported`),description:e(`Good news! Multiclause transactions are now fully supported for smart accounts. You can now enjoy a better user experience, lower gas costs, and enchanced security.`),status:`info`})},[n.isConnectedWithPrivy,t?.address])},Gl=()=>{let{account:e}=Q(),t=H(e=>{let t=e?.toLowerCase();return{notifications:`vechain_kit_notifications_${t}`,archived:`vechain_kit_archived_notifications_${t}`,initialized:`vechain_kit_notifications_initialized_${t}`}},[]),n=H(()=>{if(!e?.address||!y())return;let n=t(e.address);w(n.initialized)||(h(n.notifications,JSON.stringify(Ul)),h(n.initialized,`true`))},[e?.address,t]);U(()=>{n()},[n]);let r=H(()=>{if(!e?.address||!y())return[];let n=w(t(e.address).notifications);return n?JSON.parse(n):[]},[e?.address,t]),i=H(()=>{if(!e?.address||!y())return[];let n=w(t(e.address).archived);return n?JSON.parse(n):[]},[e?.address,t]),a=H(n=>{if(!e?.address||!y())return;let i=t(e.address),a=r(),o=w(i.archived),s=o?JSON.parse(o):[];if([...a,...s].some(e=>e.title===n.title))return;let c={...n,id:n.id||Math.random().toString(36).substring(7),timestamp:Date.now(),isRead:!1};h(i.notifications,JSON.stringify([c,...a]))},[e?.address,r,t]),o=H(n=>{if(!e?.address||!y())return;let i=t(e.address),a=r().filter(e=>e.id!==n);h(i.notifications,JSON.stringify(a))},[e?.address,r,t]);return{getNotifications:r,getArchivedNotifications:i,addNotification:a,clearAllNotifications:H(()=>{if(!e?.address||!y())return;let n=t(e.address),a=r();h(n.archived,JSON.stringify([...i(),...a])),h(n.notifications,JSON.stringify([]))},[e?.address,r,i,t]),markAsRead:H(n=>{if(!e?.address||!y())return;let a=t(e.address),o=r(),s=i(),c=o.find(e=>e.id===n),l=o.filter(e=>e.id!==n);if(c){let e=[{...c,isRead:!0},...s];h(a.notifications,JSON.stringify(l)),h(a.archived,JSON.stringify(e))}},[e?.address,r,i,t]),deleteNotification:o}},Kl=({showArchived:e})=>{let{t}=Y();return q(Pl,{title:t(e?`No archived notifications`:`No notifications`),description:t(e?`Cleared notifications will appear here`:`When you have notifications, they will appear here`),icon:e?Hn:Xn})},ql=({notification:e,isArchiveView:t,onMarkAsRead:n})=>{let{t:r}=Y(),i=()=>{n(e.id)};return e.isRead&&!t?null:J(Be,{status:e.status,variant:`subtle`,borderRadius:`lg`,pr:8,position:`relative`,opacity:e.isRead?.7:1,cursor:`pointer`,_hover:{opacity:.8},"data-testid":`notification-item`,children:[q(He,{boxSize:`16px`}),J(A,{children:[q(Ue,{fontSize:`sm`,"data-testid":`notification-title`,children:r(e.title)}),q(Ve,{fontSize:`xs`,lineHeight:`1.2`,"data-testid":`notification-text`,children:r(e.description)})]}),!t&&!e.isRead&&q(lt,{position:`absolute`,right:1,top:1,size:`sm`,variant:`ghost`,icon:q(cr,{}),onClick:e=>{e.stopPropagation(),i()},"aria-label":`Mark as read and archive`,"data-testid":`remove-notification-button`})]},e.id)},Jl=({setCurrentContent:e})=>{let{t}=Y(),{isolatedView:n}=Jc(),{getNotifications:r,getArchivedNotifications:i,clearAllNotifications:a,markAsRead:o}=Gl(),[s,c]=G(!1),[l,u]=G(r()),[d,f]=G(i()),p=()=>{a(),f([...d,...l]),u([])},m=e=>{o(e);let t=l.find(t=>t.id===e);u(l.filter(t=>t.id!==e)),t&&f([{...t,isRead:!0},...d])},h=()=>{c(!s)},g=s?d:l,_=[...g].sort((e,t)=>e.id===`welcome`?-1:t.id===`welcome`?1:e.id===`smart-account`?-1:t.id===`smart-account`?1:e.id===`multiclause`?-1:t.id===`multiclause`?1:t.timestamp-e.timestamp);return J(Op,{children:[J(Z,{children:[!n&&q(Ja,{onClick:()=>e(`main`)}),q(L,{"data-testid":`modal-title`,children:t(s?`Archived Notifications`:`Notifications`)}),q(F,{})]}),J(tt,{h:[`540px`,`auto`],p:0,children:[q(P,{children:J(z,{spacing:4,align:`stretch`,w:`full`,children:[J(M,{justify:`space-between`,children:[q(j,{variant:`ghost`,leftIcon:q(N,{as:s?Xn:Hn}),size:`sm`,onClick:h,"data-testid":`toggle-view-button`,children:t(s?`Current`:`Archived`)}),!s&&l.length>0&&q(j,{variant:`ghost`,size:`sm`,onClick:p,"data-testid":`clear-all-button`,children:t(`Clear all`)})]}),g.length===0?q(Kl,{showArchived:s}):q(z,{spacing:3,children:_.map(e=>q(ql,{notification:e,isArchiveView:s,onMarkAsRead:m},e.id))})]})}),q(I,{pt:0})]})]})},Yl=e=>{switch(e){case`defi`:return`blue`;case`games`:return`green`;case`collectibles`:return`purple`;case`marketplaces`:return`orange`;case`utilities`:return`cyan`;default:return`gray`}},Xl=({category:e,...t})=>{let{t:n}=Y(),r=e.toLowerCase();return q(Nt,{size:`sm`,colorScheme:Yl(r),borderRadius:`full`,px:2,...t,children:n(r)})},Zl=({name:e,imageUrl:t,logoComponent:n,category:r,onClick:i,size:a=`md`})=>J(Ge,{variant:`vechainKitAppCard`,_hover:{opacity:.8},cursor:`pointer`,onClick:i,position:`relative`,children:[r&&q(A,{position:`absolute`,top:`2`,right:`2`,zIndex:`1`,children:q(Xl,{category:r})}),q(Ke,{p:a===`sm`?2:4,alignItems:`center`,children:J(z,{spacing:2,h:`100%`,justifyContent:`space-between`,children:[n||t&&q(ut,{src:t,fallbackSrc:te,alt:e,height:`90px`,objectFit:`contain`,rounded:`full`}),e&&q(R,{fontWeight:`medium`,wordBreak:`break-word`,noOfLines:1,textAlign:`center`,w:`full`,children:e})]})})]}),Ql=({xApp:e,setCurrentContent:t,selectedCategory:n})=>{let{data:r,isLoading:i}=Js(e.id),{data:a,isLoading:o}=tc(r?.logo);return q(kt,{isLoaded:!i&&!o,borderRadius:`md`,height:`100%`,children:q(Zl,{name:r?.name??``,imageUrl:a?.image??``,linkUrl:r?.external_url??``,category:`vebetter`,onClick:()=>{r?.name&&t({type:`app-overview`,props:{name:r.name,image:a?.image??``,url:r?.external_url??``,description:r?.description??``,category:`vebetter`,selectedCategory:n,setCurrentContent:t}})}})})},$l=({name:e,image:t,url:n,description:r,category:i,logoComponent:a,selectedCategory:o,setCurrentContent:s})=>q(Zl,{name:e,imageUrl:t,linkUrl:n,category:i,onClick:()=>{s({type:`app-overview`,props:{name:e,image:t,url:n,description:r,category:i,logoComponent:a,selectedCategory:o,setCurrentContent:s}})},...a&&{logoComponent:a}}),eu=({})=>{let{t:e}=Y(),{shortcuts:t}=hp();return t.length===0?null:J(z,{w:`full`,align:`flex-start`,spacing:2,children:[q(R,{fontSize:`sm`,fontWeight:`500`,children:e(`Shortcuts`)}),q(ot,{templateColumns:`repeat(4, 1fr)`,gap:2,w:`full`,children:t.map(e=>q(st,{children:q(Ge,{_hover:{opacity:.8},cursor:`pointer`,onClick:()=>window.open(e.url,`_blank`),children:q(Ke,{p:2,alignItems:`center`,children:q(ut,{src:e.image,fallbackSrc:te,alt:e.name,objectFit:`contain`,rounded:`full`})})})},e.url))})]})},tu=({selectedCategory:e,onCategoryChange:t,categories:n,darkMode:r})=>{let{t:i}=Y();return J(A,{width:`full`,mb:4,children:[q(R,{fontSize:`sm`,fontWeight:`500`,mb:2,children:i(`Filter by category`)}),J(It,{spacing:2,children:[q(Lt,{children:q(Nt,{size:`md`,borderRadius:`full`,variant:e===null?`solid`:`outline`,colorScheme:r?`gray`:`blackAlpha`,cursor:`pointer`,onClick:()=>t(null),children:i(`All`)})}),n.map(n=>q(Lt,{children:q(Xl,{category:n,size:`md`,variant:e===n?`solid`:`outline`,cursor:`pointer`,onClick:()=>t(n)})},n))]})]})},nu=[{name:`VeBetterDAO`,description:`Engage, earn and prosper by doing sustainable actions.`,external_url:`https://governance.vebetterdao.org/`,logo:`https://i.ibb.co/cgJBj83/vbd.png`,banner:`https://i.ibb.co/cgJBj83/vbd.png`,screenshots:[],social_urls:[],app_urls:[],tweets:[],ve_world:{banner:`https://i.ibb.co/cgJBj83/vbd.png`},categories:[]},{name:`vet.domains`,description:`.vet.domains provides a unique and unchangeable identity for Vechain users by linking information to their wallet addresses. It becomes easier for people to use the blockchain by replacing complicated wallet addresses with easy-to-remember names.`,external_url:`https://vet.domains`,logo:`https://vet.domains/assets/walletconnect.png`,banner:`https://vet.domains/assets/walletconnect.png`,screenshots:[],social_urls:[],app_urls:[],tweets:[],ve_world:{banner:`https://vet.domains/assets/walletconnect.png`},categories:[]}],ru=({setCurrentContent:e,selectedCategory:t})=>{let{t:n}=Y(),{darkMode:r,network:i}=$(),{isolatedView:a}=Jc(),o=B(`colors`,`vechain-kit-text-tertiary`),[s,c]=G(``),[l,u]=G(t||null);U(()=>{t!==void 0&&u(t)},[t]);let{data:d}=gs(),{data:f}=Rs(d?(parseInt(d)-1).toString():`1`),{data:p,isLoading:m,error:h}=Xd(),g=W(()=>{let e=new Set;return i.type===`main`&&f&&f.length>0&&e.add(`vebetter`),p&&p.forEach(t=>{t.category&&e.add(t.category)}),Array.from(e).sort()},[p,f,i.type]),_=i.type===`main`?f.filter(e=>e.app.name.toLowerCase().includes(s.toLowerCase())):[],v=nu.filter(e=>e.name.toLowerCase().includes(s.toLowerCase())),y=p?.filter(e=>(e.name.toLowerCase().includes(s.toLowerCase())||e.description.toLowerCase().includes(s.toLowerCase())||e.tags.some(e=>e.toLowerCase().includes(s.toLowerCase())))&&(l===null||e.category===l))||[],b=l===null,x=l===null||l===`vebetter`,{shortcuts:S}=hp();return J(A,{children:[J(Z,{children:[q(L,{children:n(`Ecosystem`)}),!a&&q(Ja,{onClick:()=>e(`main`)}),q(F,{})]}),q(P,{overflowY:`auto`,minH:`300px`,children:J(z,{spacing:6,w:`full`,children:[q(eu,{setCurrentContent:e}),S.length>0&&q(R,{fontSize:`sm`,fontWeight:`500`,w:`full`,textAlign:`left`,children:n(`All apps`)}),J(ft,{size:`lg`,children:[q(dt,{placeholder:n(`Search Apps`),value:s,onChange:e=>{c(e.target.value)},bg:r?`#00000038`:`gray.50`,borderRadius:`xl`,height:`56px`,pl:12}),q(pt,{h:`56px`,w:`56px`,pl:4,children:q(kr,{color:o})})]}),g.length>0&&q(tu,{selectedCategory:l,onCategoryChange:e=>{u(e)},categories:g,darkMode:r}),J(ot,{templateColumns:`repeat(2, 1fr)`,gap:4,w:`full`,children:[b&&v.length>0&&q(K,{children:v.map(t=>q(st,{children:q($l,{name:t.name,image:t.logo,url:t.external_url,setCurrentContent:e,description:t.description,selectedCategory:l})},t.name))}),x&&_.length>0&&q(K,{children:_.map(t=>q(st,{children:q(Ql,{xApp:t.app,setCurrentContent:e,selectedCategory:l})},t.id))}),m?q(st,{colSpan:2,children:q(Ye,{py:4,children:q(At,{})})}):h?q(st,{colSpan:2,children:q(R,{color:`red.500`,textAlign:`center`,children:n(`Failed to load App Hub apps`)})}):y.length>0?y.map(t=>q(st,{children:q($l,{name:t.name,image:t.logo,url:t.url,setCurrentContent:e,description:t.description,category:t.category,selectedCategory:l})},t.id)):l&&!x&&q(st,{colSpan:2,children:q(Ye,{py:4,children:q(R,{children:n(`No apps found in this category`)})})})]})]})}),q(I,{pt:0})]})},iu=({name:e,image:t,url:n,description:r})=>{let{t:i}=Y(),{isShortcut:a,addShortcut:o,removeShortcut:s}=hp(),c=a(n);return q(j,{px:4,width:`full`,height:`45px`,variant:`vechainKitSecondary`,borderRadius:`xl`,onClick:()=>{c?s(n):o({name:e,image:t,url:n,description:r})},leftIcon:q(N,{as:c?Qn:Zn}),children:i(c?`Remove from shortcuts`:`Add to shortcuts`)})},au=({setCurrentContent:e,name:t,image:n,url:r,description:i,category:a,selectedCategory:o,logoComponent:s})=>{let{t:c}=Y();return J(A,{children:[J(Z,{children:[q(L,{children:t}),q(Ja,{onClick:()=>{e(o?{type:`ecosystem-with-category`,props:{selectedCategory:o,setCurrentContent:e}}:`ecosystem`)}}),q(F,{})]}),q(P,{children:J(z,{spacing:6,align:`center`,w:`full`,children:[J(rt,{direction:`column`,align:`center`,children:[s||q(ut,{src:n,alt:t,w:`200px`,h:`200px`,objectFit:`contain`,borderRadius:`xl`}),a&&q(M,{mt:2,children:q(Xl,{category:a})})]}),q(R,{fontSize:`sm`,textAlign:`center`,children:i}),q(R,{fontSize:`sm`,textAlign:`center`,children:c(`Click below to access {{ name }} and explore its features.`,{name:t})})]})}),q(I,{children:J(z,{w:`full`,spacing:4,children:[J(j,{variant:`vechainKitSecondary`,onClick:()=>{window.open(r,`_blank`)},children:[c(`Launch {{name}}`,{name:t}),q(N,{as:fr,ml:2})]}),q(iu,{name:t,image:n,url:r,description:i})]})})]})},ou=({children:e})=>q(Vn.div,{whileHover:{scale:1.1},transition:{duration:.5,ease:`easeInOut`,repeat:1/0,repeatDelay:crypto.getRandomValues(new Uint32Array(1))[0]/2**32*5},animate:{y:[0,-2,0],rotate:[0,10,-10,0]},children:e}),su=({descriptionEncoded:e})=>{let{darkMode:t}=$();return J(M,{gap:2,children:[q(ou,{children:q(ht,{href:`https://twitter.com/intent/tweet?text=${e}`,isExternal:!0,children:q(A,{bg:t?`blackAlpha.700`:`lightgrey`,p:2,borderRadius:`full`,children:q(Ki,{size:22})})})}),q(ou,{children:q(ht,{href:`https://telegram.me/share/url?url=${e}`,isExternal:!0,children:q(A,{bg:`#30abec`,p:2,borderRadius:`full`,children:q(ea,{color:`white`,size:22})})})}),q(ou,{children:q(ht,{href:`https://wa.me/?text=${e}`,isExternal:!0,children:q(A,{bg:`#01cb37`,p:2,borderRadius:`full`,children:q(na,{size:22,color:`white`})})})})]})},cu=({status:e,uiConfig:t,onTryAgain:n,txReceipt:r,txError:i,onClose:a})=>{let{t:o}=Y(),{network:s}=$(),c=B(`colors`,`vechain-kit-error`),l=B(`colors`,`vechain-kit-success`),u=B(`colors`,`vechain-kit-text-primary`),d=B(`colors`,`vechain-kit-text-secondary`),f=W(()=>i?i.reason||o(`Something went wrong. Please try again.`):null,[i,o]),p=(()=>{let n=e===`waitingConfirmation`;switch(n&&(e=`pending`),e){case`pending`:return{title:t?.title??o(n?`Sending Transaction...`:`Waiting for confirmation`),icon:t?.loadingIcon??q(At,{size:`xl`,"data-testid":`pending-spinner-modal`}),description:n?o(`Transaction is being processed, it can take up to 15 seconds.`):t?.description??o(`Please confirm the transaction in your wallet.`)};case`error`:return{title:o(`Something went wrong`),icon:t?.errorIcon??q(N,{as:ar,color:c,fontSize:`100px`,"data-testid":`error-icon-modal`}),description:f??o(`An unexpected error occurred.`)};case`success`:return{title:o(`Transaction successful!`),icon:t?.successIcon??q(N,{as:or,color:l,fontSize:`100px`,"data-testid":`success-icon-modal`}),description:``};case`ready`:return{title:t?.title??o(`Confirm transaction`),icon:null,description:t?.description??o(`Confirm the transaction in your wallet to complete it.`)};default:return{title:``,icon:null,description:``}}})(),m=`${k(s.type).explorerUrl}/${r?.meta.txID}`;return J(A,{children:[J(Z,{children:[q(L,{children:p.title}),q(F,{isDisabled:e===`pending`&&!t?.isClosable})]}),q(P,{children:J(z,{align:`center`,p:6,spacing:3,children:[p.icon,e===`success`&&t?.showShareOnSocials&&J(z,{mt:2,spacing:3,children:[q(R,{fontSize:`sm`,fontWeight:`bold`,color:d,children:o(`Share on`)}),q(su,{descriptionEncoded:m})]}),p.description&&q(R,{fontSize:e===`ready`?`md`:`sm`,textAlign:`center`,color:e===`error`?c:u,mt:5,style:{lineBreak:`anywhere`},children:p.description})]})}),q(I,{justifyContent:`center`,children:J(z,{width:`full`,spacing:4,children:[e===`error`&&!!n&&J(j,{variant:`vechainKitPrimary`,onClick:n,width:`full`,children:[q(N,{mr:2,as:Dr}),o(`Try again`)]}),e===`ready`&&q(j,{onClick:n,variant:`vechainKitPrimary`,width:`full`,children:o(`Confirm`)}),(e===`success`||e===`error`||e===`ready`)&&q(j,{onClick:a,variant:`vechainKitSecondary`,width:`full`,children:o(`Close`)}),t?.showExplorerButton&&r?.meta.txID&&q(ht,{href:`${k(s.type).explorerUrl}/${r?.meta.txID}`,isExternal:!0,opacity:.5,fontSize:`14px`,textDecoration:`underline`,children:J(M,{spacing:1,alignItems:`center`,w:`full`,justifyContent:`center`,children:[q(R,{color:d,children:o(`View transaction on the explorer`)}),q(N,{size:`sm`,as:fr,color:d})]})})]})})]})},lu=({isOpen:e,onClose:t,status:n,uiConfig:r,txReceipt:i,txError:a,onTryAgain:o})=>q($a,{isOpen:e,onClose:t,allowExternalFocus:!0,blockScrollOnMount:!0,closeOnOverlayClick:n!==`pending`&&r?.isClosable,children:q(cu,{status:n,onTryAgain:o,uiConfig:r,txReceipt:i,onClose:t,txError:a})}),uu=({txId:e,title:t,description:n,onDone:r,showSocialButtons:i=!1})=>{let{t:a}=Y(),{network:o}=$(),s=k(o.type).explorerUrl,c=`${s}/${e}`,l=B(`colors`,`vechain-kit-success`),u=B(`colors`,`vechain-kit-text-primary`),d=B(`colors`,`vechain-kit-text-secondary`);return J(A,{children:[J(Z,{children:[q(L,{children:t}),q(F,{})]}),q(P,{children:J(z,{align:`center`,p:6,spacing:3,children:[q(N,{as:or,fontSize:`100px`,color:l,"data-testid":`success-icon`}),n&&q(R,{fontSize:`sm`,textAlign:`center`,color:u,children:n}),i&&e&&J(z,{mt:2,spacing:3,children:[q(R,{fontSize:`sm`,fontWeight:`bold`,color:d,children:a(`Share on`)}),q(su,{descriptionEncoded:c})]})]})}),q(I,{justifyContent:`center`,children:J(z,{width:`full`,spacing:4,children:[q(j,{onClick:r,variant:`vechainKitSecondary`,width:`full`,children:a(`Done`)}),e&&q(ht,{href:`${s}/${e}`,isExternal:!0,opacity:.5,fontSize:`14px`,textDecoration:`underline`,children:J(M,{spacing:1,alignItems:`center`,w:`full`,justifyContent:`center`,children:[q(R,{color:d,children:a(`View transaction on the explorer`)}),q(N,{size:16,as:fr})]})})]})})]})},du=({txId:e,title:t,description:n,onDone:r})=>{let{t:i}=Y(),{network:a,darkMode:o}=$(),s=k(a.type).explorerUrl;return J(A,{children:[J(Z,{children:[q(L,{children:t}),q(F,{})]}),q(P,{children:J(z,{align:`center`,p:6,spacing:3,children:[q(N,{as:ar,fontSize:`100px`,color:o?`red.400`:`red.500`,"data-testid":`error-icon`}),n&&q(R,{fontSize:`sm`,textAlign:`center`,children:n})]})}),q(I,{justifyContent:`center`,children:J(z,{width:`full`,spacing:4,children:[q(j,{onClick:r,variant:`vechainKitSecondary`,width:`full`,children:i(`Done`)}),e&&q(ht,{href:`${s}/${e}`,isExternal:!0,opacity:.5,fontSize:`14px`,textDecoration:`underline`,children:J(M,{spacing:1,alignItems:`center`,w:`full`,justifyContent:`center`,children:[q(R,{children:i(`View transaction on the explorer`)}),q(N,{size:16,as:fr})]})})]})})]})},fu=({isOpen:e,onClose:t,initialContent:n=`main`})=>{Wl();let{account:r}=Q(),{accountModalContent:i,setAccountModalContent:a}=rd();return U(()=>{e&&n&&a(n)},[e,n,a]),q($a,{isOpen:e,onClose:t,allowExternalFocus:!0,blockScrollOnMount:!0,children:(()=>{if(typeof i==`object`)switch(i.type){case`send-token`:return q(il,{...i.props});case`send-token-summary`:return q(al,{...i.props});case`swap-token`:return q(ul,{...i.props});case`choose-name`:return q(dl,{...i.props});case`choose-name-search`:return q(hl,{...i.props});case`choose-name-summary`:return q(gl,{...i.props});case`app-overview`:return q(au,{...i.props,setCurrentContent:a});case`disconnect-confirm`:return q(nl,{...i.props});case`account-customization`:return q(yl,{...i.props});case`account-customization-summary`:return q(bl,{...i.props});case`successful-operation`:return q(uu,{...i.props});case`failed-operation`:return q(du,{...i.props});case`upgrade-smart-account`:return q(Cl,{...i.props});case`faq`:return q(vl,{...i.props});case`terms-and-privacy`:return q(zl,{...i.props});case`ecosystem-with-category`:return q(ru,{setCurrentContent:a,selectedCategory:i.props.selectedCategory})}switch(i){case`main`:return q(Nc,{setCurrentContent:a,onClose:t,wallet:r});case`settings`:return q(Yc,{setCurrentContent:a,onLogoutSuccess:()=>{t()}});case`profile`:return q(Sl,{setCurrentContent:a,onLogoutSuccess:()=>{t()}});case`assets`:return q(wl,{setCurrentContent:a});case`bridge`:return q(El,{setCurrentContent:a});case`notifications`:return q(Jl,{setCurrentContent:a});case`access-and-security`:return q(qc,{setCurrentContent:a});case`receive-token`:return q(ol,{setCurrentContent:a});case`swap-token`:return q(ul,{setCurrentContent:a});case`connection-details`:return q(Bl,{onGoBack:()=>a(`settings`)});case`privy-linked-accounts`:return q(Hl,{onBack:()=>a(`access-and-security`)});case`ecosystem`:return q(ru,{setCurrentContent:a});case`embedded-wallet`:return q(tl,{setCurrentContent:a});case`add-custom-token`:return q(Tl,{setCurrentContent:a});case`change-currency`:return q(Dl,{setCurrentContent:a});case`general-settings`:return q(Ol,{setCurrentContent:a});case`change-language`:return q(kl,{setCurrentContent:a});case`appearance-settings`:return q(Al,{setCurrentContent:a});case`gas-token-settings`:return q(Nl,{setCurrentContent:a});default:return null}})()})},pu=({isOpen:e,onClose:t})=>{let[n,r]=G(`main`);return U(()=>{e&&r(`main`)},[e]),q($a,{isOpen:e,onClose:t,allowExternalFocus:!0,blockScrollOnMount:!0,children:(()=>{switch(n){case`main`:return q(jc,{setCurrentContent:r,onClose:t});case`faq`:return q(vl,{onGoBack:()=>r(`main`)})}})()})},mu=({onClick:e,text:t,icon:n,customIcon:r,rightIcon:i,style:a,variant:o=`loginIn`,iconWidth:s=`25px`})=>t?t?J(j,{...a,variant:o,w:`full`,onClick:e,children:[J(M,{w:`full`,justify:`flex-start`,gap:2,children:[r||q(N,{as:n,w:s,h:s}),q(R,{opacity:.9,children:t})]}),i]}):null:q(j,{...a,variant:o,w:`full`,onClick:e,children:r||q(N,{as:n,w:`20px`,h:`20px`})}),hu=({isLoading:e,buttonStyle:t})=>{let{t:n}=Y(),{loginMethods:r,darkMode:i,privyEcosystemAppIDS:a}=$(),o=r?.some(({method:e})=>e===`ecosystem`),{data:s,isLoading:c}=oo(a);return q(Ct,{placement:`bottom-start`,size:`xl`,closeOnBlur:!1,variant:`vechainKitBase`,children:({isOpen:r})=>J(K,{children:[q(Dt,{children:J(j,{isLoading:e,...t,isActive:r,children:[n(`Login`),q(N,{ml:2,as:tr,transform:r?`rotate(180deg)`:`rotate(0deg)`,transition:`transform 0.2s`})]})}),J(Tt,{children:[q(wt,{children:q(kc,{})}),q(Et,{borderTop:`none`,pb:`15px`,children:o&&q(M,{justify:`center`,w:`full`,children:q(Ac,{isDark:i,appsInfo:Object.values(s||{}),isLoading:c})})})]})]})})},gu=({variant:e})=>{let{account:t}=Q();return t?e===`icon`?null:e===`iconAndDomain`?t.domain?q(R,{fontSize:`sm`,children:d(t?.domain??``,16,0)}):q(R,{fontSize:`sm`,children:l(t.address??``,6,4)}):e===`iconDomainAndAssets`?J(M,{spacing:4,children:[J(z,{spacing:0,alignItems:`flex-start`,children:[t.domain&&q(R,{fontSize:`sm`,fontWeight:`bold`,children:d(t?.domain??``,16,0)}),q(R,{fontSize:t.domain?`xs`:`sm`,opacity:t.domain?.5:1,"data-testid":`trimmed-address`,children:l(t.address??``,4,4)})]}),q(Lc,{address:t.address??``,maxIcons:3})]}):J(z,{spacing:0,alignItems:`flex-start`,children:[t.domain&&q(R,{fontSize:`sm`,fontWeight:`bold`,children:d(t?.domain??``,16,0)}),q(R,{fontSize:t.domain?`xs`:`sm`,opacity:t.domain?.5:1,children:l(t.address??``,4,4)})]}):q(At,{})},_u=({mobileVariant:e=`iconAndDomain`,desktopVariant:t=`iconAndDomain`,onOpen:n,buttonStyle:r={}})=>{let{account:i}=Q(),[a]=Kt(`(min-width: 768px)`);return q(j,{...r,onClick:n,w:`full`,minH:`45px`,maxW:`fit-content`,"data-testid":`wallet-button`,children:J(M,{w:`full`,minW:`fit-content`,children:[q(kp,{wallet:i,props:{width:30,height:30,minWidth:30,minHeight:30}}),q(gu,{variant:a?t:e})]})})},vu=({mobileVariant:e=`iconAndDomain`,desktopVariant:t=`iconDomainAndAddress`,buttonStyle:n,connectionVariant:r=`modal`})=>{let{t:i}=Y(),{darkMode:a,loginMethods:o}=$(),s=o?.length===1&&o[0].method===`dappkit`,{connection:c,account:l}=Q(),{setSource:u,connectV2:d}=Mn(),[f]=Kt(`(max-width: 768px)`),p=Gt(),m=Gt(),{open:h}=Pn();return J(td,{darkMode:a,children:[c.isConnected&&l?q(_u,{mobileVariant:e,desktopVariant:t,onOpen:m.onOpen,buttonStyle:n}):r===`popover`&&!f?q(hu,{isLoading:c.isLoading,buttonStyle:n}):q(j,{isLoading:c.isLoading,onClick:()=>{c.isInAppBrowser?(u(`veworld`),d(null)):s?h():p.onOpen()},...n,children:i(`Login`)}),q(pu,{isOpen:p.isOpen,onClose:p.onClose}),q(fu,{isOpen:m.isOpen,onClose:m.onClose})]})},yu=()=>{let{darkMode:e}=$(),t=25/2,[n]=Kt(`(max-width: 280px)`),[r]=Kt(`(max-width: 380px)`);return J(M,{spacing:0,ml:0,children:[q(Qe,{size:`25px`,borderRadius:`full`,bg:`#F8F8F8`,p:2,alignItems:`center`,justifyContent:`center`,zIndex:3,children:q(N,{as:Vi,fontSize:`20px`})}),!n&&q(Qe,{ml:`-${t}px`,size:`25px`,borderRadius:`full`,bg:`black`,p:2,alignItems:`center`,justifyContent:`center`,zIndex:2,children:q(N,{as:Ki,color:`white`,fontSize:`20px`})}),!n&&!r&&q(Qe,{ml:`-${t}px`,zIndex:1,size:`25px`,borderRadius:`full`,bg:`#5865F2`,p:2,alignItems:`center`,justifyContent:`center`,children:q(N,{as:Gi,color:`white`,fontSize:`20px`})}),q(N,{zIndex:1,as:Er,color:e?`black`:`white`,fontSize:`15px`})]})},bu=({status:e,txReceipt:t,txError:n,onTryAgain:r,description:i,onClose:a})=>{let{t:o}=Y(),{network:s}=$(),c=k(s.type).explorerUrl,l=W(()=>n?n.reason||o(`Something went wrong. Please try again.`):null,[n,o]),u=(()=>{let t=e===`waitingConfirmation`;switch(t&&(e=`pending`),e){case`pending`:return{icon:q(At,{size:`md`,"data-testid":`pending-spinner-toast`}),title:o(t?`Processing transaction...`:`Waiting for confirmation...`),closeDisabled:!0,description:t?o(`Transaction is being processed, it can take up to 15 seconds.`):i??o(`Please confirm the transaction in your wallet.`)};case`error`:return{icon:q(N,{as:ar,color:`red.500`,fontSize:`40px`,"data-testid":`error-icon-toast`}),title:o(`Transaction failed`),closeDisabled:!1,description:l};case`success`:return{icon:q(N,{as:or,color:`green.500`,fontSize:`40px`,"data-testid":`success-icon-toast`}),title:o(`Transaction successful!`),closeDisabled:!1,description:void 0};case`ready`:return{icon:null,title:o(`Confirm transaction`),closeDisabled:!1,description:i??o(`Confirm the transaction in your wallet to complete it.`)};default:return{icon:null,title:``,closeDisabled:!1,description:``}}})();return u?J(M,{justify:`space-between`,alignItems:`flex-start`,w:`full`,children:[q(z,{spacing:4,children:J(M,{spacing:4,w:`full`,justifyContent:`flex-start`,alignItems:`flex-start`,children:[u.icon,J(z,{w:`full`,align:`flex-start`,spacing:2,children:[J(z,{spacing:1,w:`full`,children:[q(ct,{w:`full`,size:`xs`,children:u.title}),u.description&&q(R,{fontSize:`xs`,children:u.description})]}),(e===`error`||e===`ready`)&&q(j,{size:`xs`,onClick:r,children:o(e===`error`?`Try again`:`Confirm`)}),t&&e!==`pending`&&J(ht,{fontSize:`xs`,isExternal:!0,href:`${c}/${t.meta.txID}`,children:[o(`View on explorer`),` `,q(N,{as:fr})]})]})]})}),!u.closeDisabled&&q(lt,{onClick:a,variant:`ghost`,size:`sm`,borderRadius:`full`,"aria-label":`Close`,icon:q(N,{as:Vr,boxSize:4})})]}):null},xu=({isOpen:e,onClose:t,status:n,txReceipt:r,txError:i,onTryAgain:a,description:o})=>{let{darkMode:s}=$();return e?q(A,{position:`fixed`,bottom:`5`,left:`5`,zIndex:`11111`,bg:s?`#1f1f1e`:`white`,borderRadius:`md`,p:5,boxShadow:`lg`,maxW:`sm`,minW:`300px`,children:q(bu,{status:n,txReceipt:r,txError:i,onTryAgain:a,description:o,onClose:t})}):null},Su=({isOpen:e,onClose:t,error:n,title:r,loadingText:i,onTryAgain:a=()=>{}})=>q($a,{isOpen:e,onClose:t,trapFocus:!1,autoFocus:!1,backdropFilter:`blur(3px)`,children:n?q(wu,{error:n,onClose:t,onTryAgain:a}):q(Cu,{loadingText:i,title:r,onTryAgain:a})}),Cu=({loadingText:e,title:t,onTryAgain:n})=>{let{t:r}=Y(),[i,a]=V.useState(!1);return V.useEffect(()=>{let e=setTimeout(()=>{a(!0)},7e3);return()=>clearTimeout(e)},[Pi]),J(K,{children:[q(Z,{children:q(L,{children:t??r(`Connecting...`)})}),J(P,{children:[q(z,{align:`center`,p:6,gap:0,w:`full`,justifyContent:`center`,minH:`150px`,children:q(At,{size:`xl`})}),e&&!i&&q(R,{size:`sm`,textAlign:`center`,children:e}),i&&J(z,{mt:4,spacing:2,children:[q(R,{color:`orange.300`,size:`sm`,textAlign:`center`,children:r(`This is taking longer than expected.`)}),q(R,{size:`sm`,textAlign:`center`,children:r(`You may want to try establishing the connection again.`)})]})]}),q(I,{justifyContent:`center`,children:i&&J(j,{variant:`vechainKitPrimary`,onClick:n,children:[q(N,{mr:2,as:Dr}),r(`Try again`)]})})]})},wu=({error:e,onClose:t,onTryAgain:n})=>{let{t:r}=Y();return J(K,{children:[J(Z,{children:[q(L,{children:r(`Connection Failed`)}),q(F,{onClick:()=>{t()}})]}),q(P,{children:J(z,{align:`center`,p:6,w:`full`,justifyContent:`center`,minH:`100px`,gap:4,children:[q(Vn.div,{transition:{duration:4,ease:`easeInOut`,repeat:1/0},animate:{scale:[1,1.1,1]},children:q(N,{as:ar,color:`#ef4444`,fontSize:`60px`,opacity:.5})}),q(R,{w:`full`,size:`sm`,textAlign:`center`,children:e})]})}),q(I,{justifyContent:`center`,children:J(j,{variant:`vechainKitPrimary`,onClick:n,children:[q(N,{mr:2,as:Dr}),r(`Try again`)]})})]})},Tu=({onClose:e,appsInfo:t,isLoading:n})=>{let{t:r}=Y(),i=B(`colors`,`vechain-kit-text-primary`),[a,o]=G(),[s,c]=G(),l=Gt(),{setConnectionCache:u}=Ud(),{login:d}=Us(),f=async(n,i)=>{l.onOpen();try{o(void 0),c(i);try{await d(n),l.onClose(),u({name:i,logoUrl:t.find(e=>e.id===n)?.logo_url,appId:n,website:t.find(e=>e.id===n)?.website}),e()}catch(e){let t=e?.message;if(t&&g(t))return Error(`Login request was cancelled.`);o((e instanceof Error?e:Error(`'An unexpected issue occurred while logging in with this app. Please try again or contact support.',`)).message)}}catch(e){console.error(r(`Login failed:`),e),o(e instanceof Error?e.message:r(`Failed to connect with ecosystem app`))}};return J(A,{children:[J(K,{children:[q(Z,{children:J(L,{children:[r(`Already have an x2earn app wallet?`),q(F,{onClick:()=>{e()}})]})}),J(P,{children:[n&&q(z,{minH:`200px`,w:`full`,justifyContent:`center`,children:q(At,{})}),!n&&t&&q(z,{spacing:4,w:`full`,pb:6,children:t.map(e=>J(j,{variant:`loginIn`,fontSize:`14px`,fontWeight:`400`,p:6,borderRadius:16,w:`full`,onClick:()=>{f(e.id,e.name)},justifyContent:`flex-start`,children:[q(ut,{src:e.logo_url,alt:e.name,w:`30px`}),q(R,{ml:5,children:e.name})]},e.id))}),!n&&!t&&q(R,{textAlign:`center`,color:i,children:r(`No application from VeChain ecosystem is available to login.`)})]}),q(I,{pt:0})]}),q(Su,{isOpen:l.isOpen,onClose:()=>{l.onClose()},error:a,title:`${r(`Connecting with`)} ${s}`,loadingText:r(`Please approve the request in the connection request window...`),onTryAgain:()=>{if(s){let e=t.find(e=>e.name===s);e&&f(e.id,e.name)}}})]})},Eu=({isOpen:e,onClose:t,appsInfo:n,isLoading:r})=>q($a,{isOpen:e,onClose:t,backdropFilter:`blur(3px)`,children:q(Tu,{onClose:t,appsInfo:n,isLoading:r})}),Du=({txId:e,title:t,description:n,onDone:r,showSocialButtons:i=!1})=>{let{t:a}=Y(),{network:o}=$(),s=k(o.type).explorerUrl,c=`${s}/${e}`,l=B(`colors`,`vechain-kit-success`);return J(A,{children:[J(Z,{children:[q(L,{children:t}),q(F,{})]}),q(P,{children:J(z,{align:`center`,p:6,spacing:3,children:[q(Vn.div,{transition:{duration:4,ease:`easeInOut`,repeat:1/0},animate:{scale:[1,1.1,1]},children:q(N,{as:or,fontSize:`100px`,color:l})}),n&&q(R,{fontSize:`sm`,textAlign:`center`,children:n}),i&&e&&J(z,{mt:2,children:[q(R,{fontSize:`xs`,children:a(`Share on`)}),q(su,{descriptionEncoded:c})]})]})}),q(I,{justifyContent:`center`,children:J(z,{width:`full`,spacing:4,children:[q(j,{onClick:r,variant:`vechainKitSecondary`,width:`full`,children:a(`Done`)}),e&&q(ht,{href:`${s}/${e}`,isExternal:!0,opacity:.5,fontSize:`14px`,textDecoration:`underline`,children:J(M,{spacing:1,alignItems:`center`,w:`full`,justifyContent:`center`,children:[q(R,{children:a(`View transaction on the explorer`)}),q(N,{size:16,as:fr})]})})]})})]})},Ou=({setCurrentContent:e,handleClose:t,style:n})=>{let{t:r}=Y(),{smartAccount:i,connectedWallet:a}=Q(),{data:o}=Pf(i?.address??``,a?.address??``,3),{sendTransaction:s,isTransactionPending:c,isWaitingForWalletConfirmation:l,error:u,txReceipt:d}=zf({smartAccountAddress:i?.address??``,targetVersion:3,onSuccess:()=>{e({type:`successful-operation`,props:{setCurrentContent:e,txId:d?.meta.txID,title:r(`Upgrade Successful!`),description:r(`Your account has been successfully upgraded to the latest version. You can now enjoy a better user experience, lower gas costs, and enhanced security.`),onDone:()=>{t()},showSocialButtons:!1}})},onError:()=>{console.error(`Error upgrading Smart Account`)}});return J(K,{children:[J(Z,{children:[q(L,{children:r(`Account upgrade required`)}),q(F,{})]}),q(P,{children:J(z,{spacing:10,align:`stretch`,justifyContent:`center`,children:[q(R,{fontSize:`sm`,textAlign:`center`,children:r(`To continue interacting with VeChain blockchain and complete your operation, your smart account needs to be upgraded to the latest version (v3).`)}),J(M,{align:`center`,justifyContent:`space-evenly`,rounded:`md`,children:[J(A,{position:`relative`,display:`inline-block`,children:[q(Qe,{size:`60px`,bg:`gray.200`,children:q(ut,{src:i?.image,alt:r(`Profile Picture`),w:`100%`,h:`100%`,borderRadius:`full`,objectFit:`cover`})}),q(ct,{position:`absolute`,top:`-5`,right:`-5`,color:`#D23F63`,fontSize:`28px`,children:`v1`})]}),q(N,{as:qn,color:`#3DBA67`}),J(A,{position:`relative`,display:`inline-block`,children:[q(Qe,{size:`60px`,bg:`gray.200`,children:q(ut,{src:i?.image,alt:r(`Profile Picture`),w:`100%`,h:`100%`,borderRadius:`full`,objectFit:`cover`})}),q(ct,{position:`absolute`,top:`-5`,right:`-5`,color:`#3DBA67`,fontSize:`28px`,children:`v3`})]})]}),J(Be,{status:`info`,borderRadius:`md`,children:[q(He,{}),J(A,{children:[q(Ue,{fontSize:`sm`,children:r(`Benefits of this upgrade:`)}),q(Ve,{fontSize:`xs`,children:J(z,{align:`start`,spacing:0,mt:1,children:[J(R,{fontSize:`xs`,lineHeight:`1.2`,children:[`• `,r(`Improved security features`)]}),J(R,{fontSize:`xs`,children:[`• `,r(`Better transaction handling`)]}),J(R,{fontSize:`xs`,children:[`•`,` `,r(`Enhanced compatibility with dApps`)]}),J(R,{fontSize:`xs`,children:[`•`,` `,r(`Reduced gas costs for operations`)]})]})})]})]})]})}),q(I,{justifyContent:`center`,children:q(z,{spacing:3,w:`full`,children:q(Ap,{style:n,buttonText:r(o?`Upgrade account`:`Account already upgraded`),onConfirm:async()=>{try{await s()}catch(e){console.error(`Failed to upgrade Smart Account:`,e)}},isTxWaitingConfirmation:l,isSubmitting:c,transactionPendingText:r(`Upgrading...`),txReceipt:d,transactionError:u,isDisabled:!o})})})]})},ku=({isOpen:e,onClose:t,style:n})=>{let[r,i]=G(`upgrade-smart-account`);return U(()=>{e&&i(`upgrade-smart-account`)},[e]),q($a,{isOpen:e,onClose:t,allowExternalFocus:!0,blockScrollOnMount:!0,size:n?.modalSize,children:(()=>{if(typeof r==`object`)switch(r.type){case`successful-operation`:return q(Du,{...r.props})}else if(r===`upgrade-smart-account`)return q(Ou,{setCurrentContent:i,handleClose:t,style:n})})()})},{definePartsStyle:Au,defineMultiStyleConfig:ju}=Rt(ca.keys),Mu=e=>({vechainKitBase:Au({dialog:{scrollbarWidth:`none`,overflow:`scroll`,overflowX:`hidden`,maxHeight:`550px`,borderRadius:e.borders.radius.xl,backgroundColor:e.colors.background.modal,backdropFilter:e.effects.backdropFilter.modal,border:e.colors.border.modal},overlay:{backgroundColor:e.colors.background.overlay,backdropFilter:e.effects.backdropFilter.overlay},closeButton:{borderRadius:e.borders.radius.full,color:e.colors.text.primary,_hover:{bg:e.buttons.button.bg},_active:{bg:e.buttons.button.bg,opacity:.8}},header:{w:`full`,color:e.colors.text.primary,fontSize:e.fonts.sizes.medium,fontWeight:e.fonts.weights.bold,textAlign:`center`}})}),Nu=e=>ju({variants:Mu(e),defaultProps:{variant:`vechainKitBase`}}),{definePartsStyle:Pu,defineMultiStyleConfig:Fu}=Rt(sa.keys),Iu=e=>({vechainKitBase:Pu({container:{backgroundColor:e.colors.background.card,borderRadius:e.borders.radius.medium,width:`full`,border:`none`},body:{p:5,width:`full`},header:{p:5,width:`full`,borderRadius:`${e.borders.radius.medium} ${e.borders.radius.medium} 0 0`},footer:{width:`full`,borderRadius:`0 0 ${e.borders.radius.medium} ${e.borders.radius.medium}`}}),featureAnnouncement:Pu({body:{backgroundColor:e.buttons.button.bg,borderRadius:e.borders.radius.medium,color:e.colors.text.secondary},container:{borderRadius:e.borders.radius.medium,backgroundColor:`transparent`}}),vechainKitAppCard:Pu({body:{height:`full`,borderRadius:e.borders.radius.medium,backgroundColor:e.colors.background.cardElevated,border:`1px solid ${e.colors.border.default}`},container:{height:`150px`,borderRadius:e.borders.radius.medium,backgroundColor:`transparent`}})}),Lu=e=>Fu({variants:Iu(e),defaultProps:{variant:`vechainKitBase`}}),Ru=Bt({borderRadius:`12px`}),zu=e=>({loginIn:Bt(()=>({bg:e.buttons.loginButton.bg,color:e.buttons.loginButton.color,border:e.buttons.loginButton.border,fontSize:e.fonts.sizes.medium,fontWeight:e.fonts.weights.normal,py:6,px:3,borderRadius:e.borders.radius.large,_hover:{opacity:.5,_disabled:{opacity:.5,bg:e.buttons.loginButton.bg}},_disabled:{opacity:.5,cursor:`not-allowed`,bg:e.buttons.loginButton.bg},transition:`all 0.2s`})),loginWithVechain:Bt(()=>({color:`white`,bg:`#1a1a1a`,fontSize:e.fonts.sizes.medium,fontWeight:e.fonts.weights.normal,py:6,px:3,borderRadius:e.borders.radius.large,border:`1px solid ${e.colors.border.button}`,_hover:{opacity:.5,_disabled:{opacity:.5,bg:`#1a1a1a`}},_disabled:{opacity:.5,cursor:`not-allowed`,bg:`#1a1a1a`},_dark:{color:`#1a1a1a`,bg:`white`,_hover:{_disabled:{bg:`white`}},_disabled:{bg:`white`}},transition:`all 0.2s`})),vechainKitPrimary:Bt(()=>({fontSize:e.fonts.sizes.medium,px:4,width:`full`,height:`60px`,borderRadius:e.borders.radius.large,bg:e.buttons.primaryButton.bg,color:e.buttons.primaryButton.color,border:e.buttons.primaryButton.border,_hover:{...e.buttons.primaryButton.hoverBg?{bg:e.buttons.primaryButton.hoverBg}:{opacity:.8},_disabled:{opacity:.5,bg:e.buttons.primaryButton.bg}},_disabled:{opacity:.5,cursor:`not-allowed`,bg:e.buttons.primaryButton.bg},transition:`all 0.2s`})),vechainKitSecondary:Bt(()=>({fontSize:e.fonts.sizes.medium,px:4,width:`full`,height:`60px`,borderRadius:e.borders.radius.large,bg:e.buttons.button.bg,color:e.buttons.button.color,border:e.buttons.button.border===`none`?`none`:e.buttons.button.border,_hover:{...e.buttons.button.hoverBg?{bg:e.buttons.button.hoverBg}:{opacity:.8},_disabled:{opacity:.5,bg:e.buttons.button.bg}},_disabled:{opacity:.5,cursor:`not-allowed`,bg:e.buttons.button.bg},transition:`all 0.2s`})),vechainKitTertiary:Bt(()=>({fontSize:e.fonts.sizes.medium,px:4,width:`full`,height:`60px`,borderRadius:e.borders.radius.large,bg:e.buttons.tertiaryButton.bg,color:e.buttons.tertiaryButton.color,border:e.buttons.tertiaryButton.border===`none`?`none`:e.buttons.tertiaryButton.border,_hover:{opacity:.8,_disabled:{opacity:.5,bg:e.buttons.tertiaryButton.bg}},_disabled:{opacity:.5,cursor:`not-allowed`,bg:e.buttons.tertiaryButton.bg},transition:`all 0.2s`})),vechainKitLogout:Bt(()=>({width:`full`,minHeight:`50px`,height:`fit-content`,borderRadius:e.borders.radius.xl,p:0,bg:e.colors.error+`1f`,_hover:{bg:e.colors.error+`5e`,color:e.colors.error},transition:`all 0.2s`,color:e.colors.error})),actionButton:Bt(()=>({width:`full`,minHeight:`50px`,height:`fit-content`,bg:e.buttons.button.bg,borderRadius:e.borders.radius.xl,p:0,color:e.buttons.button.color,border:e.buttons.button.border===`none`?`1px solid ${e.colors.border.button}`:e.buttons.button.border,_hover:{opacity:.8,_disabled:{opacity:.5,bg:e.buttons.button.bg}},_disabled:{opacity:.5,cursor:`not-allowed`,bg:e.buttons.button.bg},transition:`all 0.2s`})),ghost:Bt(()=>({bg:`transparent`,color:e.colors.text.primary,border:`none`,_hover:{bg:e.buttons.button.bg},_active:{bg:e.buttons.button.bg,opacity:.8},transition:`all 0.2s`})),link:Bt(()=>({color:e.colors.text.primary,_hover:{color:e.colors.text.secondary,textDecoration:`underline`},_active:{color:e.colors.text.primary},transition:`all 0.2s`}))}),Bu=e=>Vt({baseStyle:Ru,variants:zu(e)}),{definePartsStyle:Vu,defineMultiStyleConfig:Hu}=Rt(la.keys),Uu=e=>({vechainKitBase:Vu({popper:{zIndex:1e3},content:{borderRadius:e.borders.radius.xl,border:`none`,backgroundColor:e.colors.background.modal,boxShadow:`0px 4px 16px rgba(0, 0, 0, 0.12)`,minWidth:`380px`},body:{padding:`16px`}})}),Wu=e=>Hu({variants:Uu(e),defaultProps:{variant:`vechainKitBase`}}),Gu=(e,t)=>({useSystemColorMode:!1,disableTransitionOnChange:!1,components:{Modal:Nu(t),Card:Lu(t),Button:Bu(t),Popover:Wu(t)},styles:{global:()=>({})},semanticTokens:{colors:{"chakra-placeholder-color":t.colors.text.tertiary,"vechain-kit-modal":t.colors.background.modal,"vechain-kit-overlay":t.colors.background.overlay,"vechain-kit-card":e?`rgba(0, 0, 0, 0.3)`:`rgba(0, 0, 0, 0.05)`,"vechain-kit-card-elevated":e?`rgba(0, 0, 0, 0.4)`:`rgba(0, 0, 0, 0.08)`,"vechain-kit-sticky-header":t.colors.background.stickyHeader,"vechain-kit-text-primary":t.colors.text.primary,"vechain-kit-text-secondary":t.colors.text.secondary,"vechain-kit-text-tertiary":t.colors.text.tertiary,"vechain-kit-border":t.colors.border.default,"vechain-kit-border-hover":t.colors.border.hover,"vechain-kit-border-focus":t.colors.border.focus,"vechain-kit-success":t.colors.success,"vechain-kit-error":t.colors.error,"vechain-kit-warning":t.colors.warning},effects:{"vechain-kit-backdrop-filter-modal":t.effects.backdropFilter.modal,"vechain-kit-backdrop-filter-overlay":t.effects.backdropFilter.overlay,"vechain-kit-backdrop-filter-sticky-header":t.effects.backdropFilter.stickyHeader},config:{cssVarPrefix:`vechain-kit`}},fonts:Ut.fonts,fontSizes:{...Ut.fontSizes,sm:t.fonts.sizes.small,md:t.fonts.sizes.medium,lg:t.fonts.sizes.large},fontWeights:{...Ut.fontWeights,normal:t.fonts.weights.normal,medium:t.fonts.weights.medium,bold:t.fonts.weights.bold},colors:Ut.colors,space:Ut.space}),Ku=(e,t)=>{let n=Ht(Gu(e,Ra(La(e),za(t,e))));return n.styles.global=()=>({}),n.__cssVars&&(n.__cssVars.global=()=>({})),n},{ToastContainer:qu}=zt(),Ju=()=>oa({key:`vechain-kit`,prepend:!0}),Yu=({bodyFont:e,headingFont:t})=>q(ia,{styles:aa`
120
120
  /* define CSS layers with proper priority order */
121
121
  @layer vechain-kit, host-app;
122
122
 
@@ -189,7 +189,7 @@ import{A as e,B as t,C as n,E as r,H as i,J as a,O as o,Q as s,S as c,U as l,V a
189
189
  font-family: ${t} !important;
190
190
  }
191
191
  }
192
- `}),Qu=({children:e,theme:t,bodyFont:n,headingFont:r})=>J(ra,{value:W(()=>Xu(),[]),children:[q(Zu,{bodyFont:n,headingFont:r}),q(Xe,{theme:t,resetCSS:!1,portalZIndex:void 0,children:e})]}),$u=({darkMode:e})=>{try{if(S(`[data-chakra-color-mode]`))return null}catch(e){console.error(e)}return q(et,{initialColorMode:e?`dark`:`light`})},ed=Yt({portalRootRef:void 0,tokens:void 0}),td=()=>{let e=Xt(ed);if(!e)throw Error(`useVechainKitTheme must be used within a VechainKitThemeProvider`);return e},nd=({darkMode:e=!1})=>{let{setColorMode:t,colorMode:n}=Wt();return U(()=>{let r=e?`dark`:`light`;n!==r&&t(r)},[e]),q(K,{})},rd=({children:e,darkMode:t=!1,theme:n})=>{let r=Zt(null),i=Xt(Zp),a=i?i.theme:void 0,o=n??a,s=W(()=>Ra(La(t),za(o,t)),[t,o]),c=W(()=>({...Ju(t,o),config:{...Ju(t,o).config,initialColorMode:t?`dark`:`light`}}),[t,o]);return J(ed.Provider,{value:{portalRootRef:r,tokens:s},children:[q($u,{darkMode:t}),J(Qu,{theme:c,bodyFont:s.fonts.body,headingFont:s.fonts.heading,children:[q(nd,{darkMode:t}),q(A,{id:`vechain-kit-root`,ref:r,bg:`transparent`,borderRadius:`12px`,children:e})]}),q(Yu,{})]})},id=Yt(null),ad=()=>{let e=Xt(id);if(!e)throw Error(`useModal must be used within ModalProvider`);return e},od=({children:e})=>{let{darkMode:t,theme:n}=$(),[r,i]=G(!1),{setSource:a,connectV2:o}=Mn(),s=H(()=>{y()&&window.vechain&&window.vechain.isInAppBrowser?(a(`veworld`),o(null)):i(!0)},[]),c=H(()=>i(!1),[]),[l,u]=G(!1),[d,f]=G(!1),p=H((e,t)=>{re(e??`main`),f(t?.isolatedView??!1),u(!0)},[]),m=H(()=>{u(!1),setTimeout(()=>{f(!1)},300)},[]),[h,g]=G(!1),_=H(()=>g(!0),[]),v=H(()=>g(!1),[]),[b,x]=G(!1),S=H(()=>x(!0),[]),C=H(()=>x(!1),[]),[w,ee]=G(!1),[T,E]=G(void 0),D=H(e=>{E(e),ee(!0)},[]),te=H(()=>ee(!1),[]),[ne,re]=G(`main`);return J(id.Provider,{value:{openConnectModal:s,closeConnectModal:c,isConnectModalOpen:r,openAccountModal:p,closeAccountModal:m,isAccountModalOpen:l,setAccountModalContent:re,accountModalContent:ne,isolatedView:d,openTransactionModal:_,closeTransactionModal:v,isTransactionModalOpen:h,openTransactionToast:S,closeTransactionToast:C,isTransactionToastOpen:b,openUpgradeSmartAccountModal:D,closeUpgradeSmartAccountModal:te,isUpgradeSmartAccountModalOpen:w},children:[e,J(rd,{darkMode:t,theme:n,children:[q(hu,{isOpen:r,onClose:c}),q(mu,{isOpen:l,onClose:m,initialContent:ne}),q(ju,{isOpen:w,onClose:te,style:T})]})]})},sd=()=>{let{loginMethods:e}=$(),t=e?.length===1&&e[0].method===`dappkit`,{openConnectModal:n,closeConnectModal:r,isConnectModalOpen:i}=ad(),{open:a,close:o}=Pn();return{open:t?a:n,close:t?o:r,isOpen:t?!1:i}},cd=({children:e})=>q(K,{children:e}),ld=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=ad();return{open:()=>e(),close:t,isOpen:n}},ud=({children:e})=>q(K,{children:e}),dd=()=>{let{openTransactionModal:e,closeTransactionModal:t,isTransactionModalOpen:n}=ad();return{open:e,close:t,isOpen:n}},fd=({children:e})=>q(K,{children:e}),pd=()=>{let{openTransactionToast:e,closeTransactionToast:t,isTransactionToastOpen:n}=ad();return{open:e,close:t,isOpen:n}},md=({children:e})=>q(K,{children:e}),hd=()=>{let{connection:e}=Q(),{openConnectModal:t,closeConnectModal:n,isConnectModalOpen:r,openAccountModal:i,closeAccountModal:a,isAccountModalOpen:o}=ad();return{open:()=>{e.isConnected?i():t()},close:()=>{o&&a(),r&&n()},isOpen:r||o}},gd=({children:e})=>q(K,{children:e}),_d=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n,setAccountModalContent:r}=ad();return{open:t=>{e({type:`choose-name`,props:{setCurrentContent:r,onBack:()=>r(`main`),initialContentSource:`main`}},t)},close:()=>{t()},isOpen:n}},vd=({children:e})=>q(K,{children:e}),yd=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n,setAccountModalContent:r}=ad();return{open:t=>{e({type:`send-token`,props:{setCurrentContent:r}},t)},close:()=>{t()},isOpen:n}},bd=({children:e})=>q(K,{children:e}),xd=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n,setAccountModalContent:r}=ad();return{open:t=>{e({type:`swap-token`,props:{setCurrentContent:r,fromTokenAddress:t?.fromTokenAddress,toTokenAddress:t?.toTokenAddress}},{isolatedView:t?.isolatedView})},close:()=>{t()},isOpen:n}},Sd=({children:e})=>q(K,{children:e}),Cd=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=ad();return{open:t=>{e(`access-and-security`,t)},close:()=>{t()},isOpen:n}},wd=({children:e})=>q(K,{children:e}),Td=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=ad();return{open:t=>{e(`ecosystem`,t)},close:()=>{t()},isOpen:n}},Ed=({children:e})=>q(K,{children:e}),Dd=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=ad();return{open:t=>{e(`notifications`,t)},close:()=>{t()},isOpen:n}},Od=({children:e})=>q(K,{children:e}),kd=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n,setAccountModalContent:r}=ad();return{open:t=>{e({type:`faq`,props:{onGoBack:()=>r(`main`),showLanguageSelector:!1}},t)},close:()=>{t()},isOpen:n}},Ad=({children:e})=>q(K,{children:e}),jd=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n,setAccountModalContent:r}=ad();return{open:()=>{e({type:`account-customization`,props:{setCurrentContent:r}})},close:()=>{t()},isOpen:n}},Md=({children:e})=>q(K,{children:e}),Nd=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=ad();return{open:t=>{e(`receive-token`,t)},close:()=>{t()},isOpen:n}},Pd=({children:e})=>q(K,{children:e}),Fd=()=>{let{privy:e,loginMethods:t}=$(),n=e?.appId===O,r=e=>t?Array.isArray(e)?e.some(e=>t.some(t=>t.method===e)):t.some(t=>t.method===e):!0,i=W(()=>t?t.length===0||r(`ecosystem`):!0,[t]),a=W(()=>r(`vechain`),[t]),o=W(()=>r(`dappkit`),[t]),s=W(()=>r(`passkey`),[t]),c=W(()=>r(`email`),[t]),l={showGoogleLogin:W(()=>r(`google`),[t]),showEmailLogin:c,showPasskey:s,showVeChainLogin:a,showDappKit:o,showEcosystem:i,showMoreLogin:W(()=>r(`more`),[t]),showGithubLogin:W(()=>r(`github`),[t]),isOfficialVeChainApp:!1};return e?n?{...l,isOfficialVeChainApp:!0}:{...l}:{...l,showGoogleLogin:!1,showEmailLogin:!1,showPasskey:!1,showMoreLogin:!1}},Id=e=>{let{openUpgradeSmartAccountModal:t,closeUpgradeSmartAccountModal:n,isUpgradeSmartAccountModalOpen:r}=ad();return{open:()=>t(e),close:n,isOpen:r}},Ld=({children:e})=>q(K,{children:e}),Rd=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=ad();return{open:t=>{e(`profile`,t)},close:()=>{t()},isOpen:n}},zd=({children:e})=>q(K,{children:e}),Bd=()=>{let[e,t]=G(!1),[n,r]=G(null),[i,a]=G(null),{connection:o,account:s}=Q(),{requestCertificate:c}=Nn(),l=Xp();return{signMessage:H(async e=>{if(!s)throw Error(`Account not found`);t(!0),a(null),r(null);try{let t=null;return t=o.isConnectedWithDappKit?(await c({purpose:`agreement`,payload:{type:`text`,content:e}},{signer:s.address})).signature:await l.signMessage(e),r(t),t}catch(e){let t=e instanceof Error?e:Error(String(e));throw a(t),t}finally{t(!1)}},[o,l]),isSigningPending:e,signature:n,error:i,reset:H(()=>{t(!1),r(null),a(null)},[])}},Vd=()=>{let[e,t]=G(!1),[n,r]=G(null),[i,a]=G(null),{signer:o}=Mn(),{connection:s}=Q(),c=Xp();return{signTypedData:H(async(e,n)=>{t(!0),a(null),r(null);try{let t;if(s.isConnectedWithDappKit){let r={...e.domain,salt:e.domain?.salt?Buffer.from(e.domain.salt).toString(`hex`):void 0};t=await o.signTypedData(r,e.types,e.message,void 0,n)}else t=await c.signTypedData(e);return r(t),t}catch(e){if(e&&typeof e==`object`&&`statusCode`in e&&e.statusCode===4001){let e=Error(`User denied signature request`);throw a(e),e}let t=e instanceof Error?e:Error(typeof e==`object`?JSON.stringify(e):String(e));throw console.error(t),a(t),t}finally{t(!1)}},[s,c]),isSigningPending:e,signature:n,error:i,reset:H(()=>{t(!1),r(null),a(null)},[])}},Hd=()=>{let{loginWithPasskey:e}=Sn();return{loginWithPasskey:async()=>{try{await e()}catch(e){throw e}}}};let Ud=!1;const Wd=()=>{let{createWallet:e}=yn(),{initOAuth:t}=xn({onComplete:H(async({isNewUser:t})=>{if(t&&!Ud){Ud=!0;try{await e()}catch(e){throw Ud=!1,console.error(`Failed to create wallet:`,e),e}}},[e])});return{initOAuth:async({provider:e})=>{try{await t({provider:e})}catch(e){throw e}}}},Gd=()=>{let e=`vechain_kit_cross_app_connection`;return{setConnectionCache:H(t=>{let n={timestamp:Date.now(),ecosystemApp:t};h(e,JSON.stringify(n))},[]),getConnectionCache:H(()=>{let t=w(e);return t?JSON.parse(t):null},[]),clearConnectionCache:H(()=>{ee(e)},[])}},Kd=()=>{let{login:e}=Us(),{setConnectionCache:t}=Gd(),{data:n}=oo([O]);return{login:async()=>{try{await e(O),t({name:`VeChain`,logoUrl:n?.[O]?.logo_url,appId:O,website:`https://governance.vebetterdao.org`})}catch(e){throw zs({error:e,mobileBrowserPopupMessage:`Your mobile browser blocked the login window. Please click 'Try again' to open the login window or change your browser settings.`,rejectedMessage:`Login request was cancelled.`,defaultMessage:`There was an unexpected issue logging in with VeChain. Please try again or contact support.`})}}}},qd=`vechain-kit-app-hub-apps`,Jd=`vechain-kit-app-hub-apps-expiry`,Yd=`https://raw.githubusercontent.com/vechain/app-hub/master`,Xd=()=>[`VECHAIN_KIT`,`appHub`,`apps`],Zd=async()=>{if(typeof window<`u`)try{let e=w(qd),t=w(Jd);if(e&&t){let n=parseInt(t,10);if(Date.now()<n)return JSON.parse(e)}}catch{console.warn(`Invalid app-hub cache, fetching fresh data`)}let e=await fetch(`https://api.github.com/repos/vechain/app-hub/contents/apps`);if(!e.ok)throw Error(`Failed to fetch app directories`);let t=(await e.json()).map(async e=>{if(e.type!==`dir`)return null;let t=`${Yd}/apps/${e.name}/manifest.json`,n=await fetch(t);if(!n.ok)return console.warn(`Failed to fetch manifest for ${e.name}`),null;try{let t=await n.json();return{id:e.name,name:t.name,description:t.desc,url:t.href,logo:`${Yd}/apps/${e.name}/logo.png`,category:t.category,tags:t.tags||[],isVeWorldSupported:t.isVeWorldSupported||!1,repo:t.repo,contracts:t.contracts,veBetterDaoId:t.veBetterDaoId}}catch(t){return console.warn(`Error parsing manifest for ${e.name}:`,t),null}}),n=(await Promise.all(t)).filter(e=>e!==null);if(typeof window<`u`)try{h(qd,JSON.stringify(n)),h(Jd,(Date.now()+864e5).toString())}catch(e){console.warn(`Failed to cache app-hub data:`,e)}return n},Qd=()=>X({queryKey:Xd(),queryFn:async()=>{try{return await Zd()}catch(e){let t=localStorage.getItem(qd);if(t)return JSON.parse(t);throw e}},staleTime:1e3*60*60,retry:2}),$d=({abi:e,address:t,method:n})=>[`callClause`,t,n],ef=({abi:e,address:t,method:n,args:r})=>[`callClause`,t,n,...r?.length?[r]:[]],tf=({address:e,abi:t,method:n,args:r,queryOptions:i})=>{let a=jn();return X({queryKey:ef({abi:t,address:e,method:n,args:r}),queryFn:async()=>T({thor:a,contractAddress:e,abi:t,method:n,args:r}),...i})},nf=({thor:e,calls:t,queryKey:n,enabled:r=!0})=>X({queryKey:n,queryFn:()=>re({thor:e,calls:t}),enabled:r}),rf=()=>{let{network:e}=$();return e.nodeUrl??k(e.type).nodeUrl},af=()=>{let[e,t]=G(!0);return U(()=>{if(!y()){t(!1);return}let e=()=>{t(window.matchMedia(`(display-mode: standalone)`).matches||window.standalone||document.referrer.includes(`android-app://`))};return e(),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`resize`,e)}},[]),e},of=()=>{U(()=>{let e=document.querySelector(`.chakra-modal__content`);e&&(e.scrollTop=0)},[])},sf=async(e,t)=>{if(!t)throw Error(`Address is required`);let n=await e.accounts.getAccount(cn.of(t));return{balance:gi(BigInt(n.balance)).toString(),energy:gi(BigInt(n.energy)).toString()}},cf=e=>[`VECHAIN_KIT_BALANCE`,e],lf=e=>{let t=jn();return X({queryKey:cf(e),queryFn:()=>sf(t,e),enabled:!!e&&cn.isValid(e),refetchInterval:1e4})},uf=async(e,t,n)=>{if(!n)throw Error(`Network type is required`);if(!t)throw Error(`Version is required`);let r=e.contracts.load(k(n).accountFactoryAddress,ti.abi),i;switch(t){case 1:case 2:i=r.read.accountImplementationV1();break;case 3:i=r.read.accountImplementationV3();break;default:throw Error(`Invalid version, must be between 1 and 3`)}let a=await i;if(!a)throw Error(`Failed to get account implementation address`);return a[0].toString()},df=(e,t)=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`FACTORY`,`IMPLEMENTATION_ADDRESS`,e,t],ff=e=>{let t=jn(),{network:n}=$();return X({queryKey:df(e,n.type),queryFn:async()=>uf(t,e,n.type),enabled:!!t&&!!e&&!!n})},pf=async(e,t)=>{if(!t)throw Error(`Network type is required`);let n=await e.contracts.load(k(t).accountFactoryAddress,ti.abi).read.currentAccountImplementationVersion();if(!n)throw Error(`Failed to get current account implementation version`);return parseInt(n[0].toString())},mf=e=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`FACTORY`,`CURRENT_ACCOUNT_IMPLEMENTATION_VERSION`,e],hf=()=>{let e=jn(),{network:t}=$();return X({queryKey:mf(t.type),queryFn:async()=>pf(e,t.type),enabled:!!e&&!!t})},gf=async(e,t,n)=>{if(!t)throw Error(`Owner address is required`);if(!n)throw Error(`Network type is required`);let r=await e.contracts.load(k(n).accountFactoryAddress,ti.abi).read.getAccountAddress(t);if(!r)throw Error(`Failed to get account address of ${t}`);return r[0].toString()},_f=(e,t)=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`FACTORY`,`ADDRESS`,e,t],vf=e=>{let t=jn(),{network:n}=$();return X({queryKey:_f(e,n.type),queryFn:async()=>gf(t,e,n.type),enabled:!!t&&!!e&&!!n})},yf=ti.abi,bf=(e,t,n)=>ef({abi:yf,address:k(n).accountFactoryAddress,method:`getAccountVersion`,args:[e,t]}),xf=(e,t)=>{let{network:n}=$();return tf({address:k(n.type).accountFactoryAddress,abi:yf,method:`getAccountVersion`,args:[e,t],queryOptions:{select:e=>({version:parseInt(e[0].toString()),isDeployed:e[1]})}})},Sf=ti.abi,Cf=async(e,t,n)=>{if(!t)throw Error(`Owner address is required`);if(!n)throw Error(`Network type is required`);let[r]=await T({thor:e,abi:Sf,contractAddress:k(n).accountFactoryAddress,method:`hasLegacyAccount`,args:[t]});return r},wf=(e,t)=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`HAS_V1_SMART_ACCOUNT`,e,t],Tf=e=>{let t=jn(),{network:n}=$();return X({queryKey:wf(e,n.type),queryFn:async()=>Cf(t,e,n.type),enabled:!!t&&!!e&&!!n})},Ef=async(e,t)=>{if(!t)throw Error(`Account address is required`);let n=await e.accounts.getAccount(cn.of(String(t)));if(!n)throw Error(`Account not found`);return n.hasCode},Df=e=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`IS_DEPLOYED`,e],Of=e=>{let t=rf(),n=Ri.at(t);return X({queryKey:Df(e),queryFn:async()=>Ef(n,e),enabled:!!n&&!!e})},kf=()=>{let e=zn(),{connectedWallet:t,smartAccount:n}=Q(),{network:r}=$();return{refresh:async()=>{let i=t?.address??``,a=n?.address??``;await Promise.all([e.cancelQueries({queryKey:_f(i,r.type)}),e.cancelQueries({queryKey:bf(a,i,r.type)}),e.cancelQueries({queryKey:wf(i,r.type)}),e.cancelQueries({queryKey:mf(r.type)}),e.cancelQueries({queryKey:Ff(a,i,3,r.type)}),e.cancelQueries({queryKey:Rf(a,3,r.type)}),e.cancelQueries({queryKey:df(3,r.type)})]),await Promise.all([e.refetchQueries({queryKey:_f(i,r.type)}),e.refetchQueries({queryKey:bf(a,i,r.type)}),e.refetchQueries({queryKey:wf(i,r.type)}),e.refetchQueries({queryKey:mf(r.type)}),e.refetchQueries({queryKey:Ff(a,i,3,r.type)}),e.refetchQueries({queryKey:Rf(a,3,r.type)}),e.refetchQueries({queryKey:df(3,r.type)})])}}},Af=()=>{let e=zn(),{smartAccount:t}=Q();return{refresh:async()=>{let n=t?.address??``;await Promise.all([e.cancelQueries({queryKey:Mf(n)}),e.cancelQueries({queryKey:Df(n)})]),await Promise.all([e.refetchQueries({queryKey:Mf(n)}),e.refetchQueries({queryKey:Df(n)})])}}},jf=async(e,t,n)=>{if(!n)return{address:void 0};let r=await e.contracts.load(k(t).accountFactoryAddress,ti.abi).read.getAccountAddress(n);if(!r)throw Error(`Failed to get account address of ${n}`);let i=cn.of(r[0].toString()),a=await e.accounts.getAccount(i);if(!a)throw Error(`Failed to get account detail of ${i}`);return{address:i.toString(),isDeployed:a.hasCode}},Mf=e=>[`VECHAIN_KIT_SMART_ACCOUNT`,e],Nf=e=>{let{network:t}=$(),n=jn();return X({queryKey:Mf(e),queryFn:()=>jf(n,t.type,e),enabled:!!e&&!!t.type&&!!n})},Pf=async(e,t,n,r,i)=>{let a=await e.contracts.load(k(i).accountFactoryAddress,ti.abi).read.upgradeRequired(t,n,BigInt(r));if(!a)throw Error(`Failed to get upgrade required of contract address ${k(i).accountFactoryAddress}`);return a[0]},Ff=(e,t,n,r)=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`FACTORY`,`UPGRADE_REQUIRED`,e,t,n,r],If=(e,t,n)=>{let r=jn(),{network:i}=$();return X({queryKey:Ff(e,t,n,i.type),queryFn:async()=>Pf(r,e,t,n,i.type),enabled:!!r&&!!e&&!!t&&!!i.type})},Lf=async(e,t,n,r)=>{let i=await e.contracts.load(k(r).accountFactoryAddress,ti.abi).read.upgradeRequiredForAccount(t,BigInt(n));if(!i)throw Error(`Failed to get upgrade required for contract address ${t}`);return i[0]},Rf=(e,t,n)=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`FACTORY`,`NEEDS_UPGRADE_FOR_ACCOUNT`,e,t,n],zf=(e,t)=>{let n=jn(),{network:r}=$();return X({queryKey:Rf(e,t,r.type),queryFn:async()=>Lf(n,e,t,r.type),enabled:!!n&&!!r&&!!e&&!!t&&e!==``})},Bf=ri.createInterface(),Vf=({smartAccountAddress:t,targetVersion:n,onSuccess:r,onError:i})=>{let{refresh:a}=kf(),{refresh:o}=Af(),{data:s}=ff(n),c=H(async()=>{if(!t||!e(t))throw Error(`Invalid smart account address`);if(!s)throw Error(`Unable to fetch implementation address for version ${n}`);return[{to:t,value:`0x0`,data:Bf.encodeFunctionData(`upgradeToAndCall`,[s,`0x`]),comment:`Upgrade account to version ${n}`,abi:Bf.getFunction(`upgradeToAndCall`).format(`json`)}]},[t,s,n]),u=lc({privyUIOptions:{title:`Upgrade Smart Account`,description:`Upgrading your account at ${l(t)} to version ${n}`,buttonText:`Sign to continue`},onTxConfirmed:async()=>{await Promise.all([a(),o()]),r?.()},onTxFailedOrCancelled:async()=>{i?.()}});return{...u,sendTransaction:async()=>u.sendTransaction(await c())}},Hf=()=>[`VECHAIN_KIT`,`CURRENT_BLOCK`],Uf=10*D.SECOND,Wf=()=>{let e=jn();return X({queryKey:Hf(),queryFn:async()=>{let t=await e.blocks.getBestBlockExpanded();if(!t)throw Error(`Failed to fetch current block`);return t},staleTime:1e3*60,refetchInterval:Uf})},Gf=async e=>{let t=await e.blocks.getGenesisBlock();if(!t)throw Error(`Genesis block not found`);return t.id},Kf=()=>[`VECHAIN_KIT_CHAIN_ID`],qf=()=>{let e=jn();return X({queryKey:Kf(),queryFn:()=>Gf(e),enabled:!!e})},Jf=1e3,Yf=async({thor:e,order:t=`asc`,offset:n=0,limit:r=Jf,from:i=0,to:a=e.blocks.getHeadBlock()?.number,filterCriteria:o})=>{let s=await e.logs.filterEventLogs({range:{from:i,to:a,unit:`block`},options:{offset:n,limit:r},order:t,criteriaSet:o});if(!s)throw Error(`Failed to fetch events`);return s},Xf=async({nodeUrl:e,thor:t,order:n=`asc`,from:r=0,to:i,filterCriteria:a})=>{let o=[],s=0;for(;;){let c=await Yf({nodeUrl:e,thor:t,filterCriteria:a,from:r,to:i??2**53-1,limit:Jf,order:n,offset:s});if(o.push(...c),c.length<Jf)return o;s+=Jf}},Zf=Qr.createInterface(),Qf=(t,n,r,i)=>{if(!t||!n||!e(t))throw Error(`Invalid receiver address or amount`);let a=[];return a.push({to:r,value:`0x0`,data:Zf.encodeFunctionData(`transfer`,[t,bi(n)]),comment:`Transfer ${n} ${i} to ${t}`,abi:Zf.getFunction(`transfer`)}),a},$f=({fromAddress:e,receiverAddress:t,amount:n,tokenAddress:r,tokenName:i,onSuccess:a,onError:o})=>{let{refresh:s}=Gs(),c=W(()=>Qf(t,n,r,i),[t,n,r,i]),u=lc({signerAccountAddress:e,privyUIOptions:{title:`Confirm Transfer`,description:`Transfer ${n} ${i} to ${l(t)}`,buttonText:`Sign to continue`},onTxConfirmed:async()=>{s(),a?.()},onTxFailedOrCancelled:async e=>{o?.(e instanceof Error?e.message:String(e))}});return{...u,clauses:c,sendTransaction:async()=>u.sendTransaction(c)}},ep=(t,n)=>{if(!t||!n||!e(t))throw Error(`Invalid receiver address or amount`);if(isNaN(Number(n)))throw Error(`Invalid amount`);let r=[];try{r.push({to:t,value:bi(n).toString(),data:`0x`,comment:`Transfer ${n} VET to ${t}`})}catch(e){throw console.error(`Error building clauses:`,e),Error(`Invalid amount format`)}return r},tp=({fromAddress:e,receiverAddress:t,amount:n,onSuccess:r,onError:i})=>{let{refresh:a}=Gs(),o=W(()=>ep(t,n),[t,n]),s=lc({signerAccountAddress:e,privyUIOptions:{title:`Confirm Transfer`,description:`Transfer ${n} VET to ${l(t)}`,buttonText:`Sign to continue`},onTxConfirmed:async()=>{a(),r?.()},onTxFailedOrCancelled:async e=>{i?.(e instanceof Error?e.message:String(e))}});return{...s,clauses:o,sendTransaction:async()=>s.sendTransaction(o)}},np=({clauseBuilder:e,refetchQueryKeys:t,invalidateCache:n=!0,onSuccess:r,onFailure:i,suggestedMaxGas:a,gasPadding:o})=>{let{account:s}=Q(),c=zn(),l=H(async()=>{n&&t?.forEach(async e=>{await c.cancelQueries({queryKey:e}),await c.refetchQueries({queryKey:e})}),r?.()},[n,r,c,t]),u=lc({signerAccountAddress:s?.address,onTxConfirmed:l,suggestedMaxGas:a,onTxFailedOrCancelled:i,gasPadding:o}),d=H(async t=>{u.sendTransaction(e(t))},[e,u]);return{...u,sendTransaction:d}},rp=10*D.SECOND,ip=e=>[`VECHAIN_KIT`,`TX_RECEIPT`,e],ap=(e,t=5)=>{let n=jn();return X({queryKey:ip(e),queryFn:async()=>{let r=await n.transactions.waitForTransaction(e,{timeoutMs:t*rp,intervalMs:3e3});if(!r)throw Error(`Transaction receipt not found`);return r},enabled:!!e})},op=(e,t)=>{let n=pi({abi:t,data:e.data.toString(),topics:e.topics.map(e=>e.toString())});return{meta:e.meta,decodedData:n}},sp=({eventName:e,filterParams:t})=>[e,t?JSON.stringify(t):`all`],cp=({abi:e,contractAddress:t,eventName:n,filterParams:r,mapResponse:i,nodeUrl:a})=>{let o=jn();return X({queryFn:H(async()=>{if(!o)return[];let s=o.contracts.load(t,e).getEventAbi(n),c=s.encodeFilterTopicsNoNull(r??{}),l=(await Xf({thor:o,nodeUrl:a,filterCriteria:[{criteria:{address:t,topic0:c[0]??void 0,topic1:c[1]??void 0,topic2:c[2]??void 0,topic3:c[3]??void 0,topic4:c[4]??void 0},eventAbi:s}]})).map(t=>op(t,e));if(l.some(({decodedData:e})=>e.eventName!==n))throw Error(`Unknown event`);return l.map(e=>i({meta:e.meta,decodedData:e.decodedData}))},[o,t,e,n,r,i,a]),queryKey:W(()=>sp({eventName:n,filterParams:r}),[n,r]),enabled:!!o})};function lp({clauses:e,chainId:t,verifyingContract:n}){let r=[],i=[],a=[];return e.forEach(e=>{r.push(e.to??``),i.push(String(e.value)),typeof e.data==`object`&&`abi`in e.data?a.push(hi(e.data)):a.push(e.data||`0x`)}),{domain:{name:`Wallet`,version:`1`,chainId:t,verifyingContract:n},types:{ExecuteBatchWithAuthorization:[{name:`to`,type:`address[]`},{name:`value`,type:`uint256[]`},{name:`data`,type:`bytes[]`},{name:`validAfter`,type:`uint256`},{name:`validBefore`,type:`uint256`},{name:`nonce`,type:`bytes32`}],EIP712Domain:[{name:`name`,type:`string`},{name:`version`,type:`string`},{name:`chainId`,type:`uint256`},{name:`verifyingContract`,type:`address`}]},primaryType:`ExecuteBatchWithAuthorization`,message:{to:r,value:i,data:a,validAfter:0,validBefore:Math.floor(Date.now()/1e3)+300,nonce:en.hexlify(en.randomBytes(32))}}}function up({clause:e,chainId:t,smartAccount:n}){return{domain:{name:`Wallet`,version:`1`,chainId:t,verifyingContract:n.address??``},types:{ExecuteWithAuthorization:[{name:`to`,type:`address`},{name:`value`,type:`uint256`},{name:`data`,type:`bytes`},{name:`validAfter`,type:`uint256`},{name:`validBefore`,type:`uint256`}],EIP712Domain:[{name:`name`,type:`string`},{name:`version`,type:`string`},{name:`chainId`,type:`uint256`},{name:`verifyingContract`,type:`address`}]},primaryType:`ExecuteWithAuthorization`,message:{validAfter:0,validBefore:Math.floor(Date.now()/1e3)+60,to:e.to,value:String(e.value),data:(typeof e.data==`object`&&`abi`in e.data?hi(e.data):e.data)||`0x`}}}function dp(){let{connection:e,connectedWallet:t}=Q(),{signTypedData:n}=Us(),{signTypedData:r}=Tn(),{network:i}=$(),{data:a}=qf();return{connection:e,connectedWallet:t,signTypedDataWithCrossApp:n,signTypedDataPrivy:r,network:i,chainId:a}}const fp=()=>{let{connection:e,connectedWallet:t,signTypedDataWithCrossApp:n,signTypedDataPrivy:r,network:i,chainId:a}=dp(),o=async e=>{let{version:t}=e;return t&&t<3?await s(e):await c(e)};async function s(o){let{clauses:s,smartAccount:c,title:l=`Sign Transaction`,description:u,buttonText:d=`Sign`}=o,f=[],p=s.map(e=>up({clause:e,chainId:a,smartAccount:c})),m=[];for(let i=0;i<p.length;i++){let a=p[i],o=s[i];if(!o)throw Error(`Transaction clause at index ${i} is undefined`);if(e.isConnectedWithCrossApp){let e=await n({...a,address:t?.address,types:Object.fromEntries(Object.entries(a.types).map(([e,t])=>[e,[...t]]))});m.push(e);continue}let c=o.data,f=(await r(a,{uiOptions:{title:l,description:u??(s[i].comment||(typeof c==`object`&&c&&`functionName`in c?c.functionName:` `)),buttonText:d}})).signature;m.push(f)}return c.isDeployed||f.push(ln.callFunction(cn.of(k(i.type).accountFactoryAddress),sn.ofAbi(ei.abi).getFunction(`createAccount`),[t?.address??``])),p.forEach((e,t)=>{f.push(ln.callFunction(cn.of(c.address??``),sn.ofAbi(ni.abi).getFunction(`executeWithAuthorization`),[e.message.to,BigInt(e.message.value),e.message.data,BigInt(e.message.validAfter),BigInt(e.message.validBefore),m[t]]))}),f}async function c(o){let{clauses:s,smartAccount:c,title:l,description:u,buttonText:d=`Sign`}=o,f=[],p=lp({clauses:s,chainId:a,verifyingContract:c.address??``}),m;return m=e.isConnectedWithCrossApp?await n({...p,address:t?.address}):(await r(p,{uiOptions:{title:l,description:u,buttonText:d}})).signature,c.isDeployed||f.push(ln.callFunction(cn.of(k(i.type).accountFactoryAddress),sn.ofAbi(ei.abi).getFunction(`createAccount`),[t?.address??``])),f.push(ln.callFunction(cn.of(c.address??``),sn.ofAbi(ni.abi).getFunction(`executeBatchWithAuthorization`),[p.message.to,p.message.value?.map(e=>BigInt(e))??0,p.message.data,BigInt(p.message.validAfter),BigInt(p.message.validBefore),p.message.nonce,m])),f}return{buildClausesWithAuth:o}};let pp=function(e){return e.CUSTOM_TOKENS=`vechain_kit_custom_tokens`,e.ECOSYSTEM_SHORTCUTS=`vechain-kit-ecosystem-shortcuts`,e.CURRENCY=`vechain_kit_currency`,e.NODE_URL=`vechain_kit_node_url`,e.NETWORK=`vechain_kit_network`,e.GAS_TOKEN_PREFERENCES=`vechain_kit_gas_token_preferences`,e}({});const mp=(e,t)=>{let[n,r]=G(()=>{try{let n=w(e);return n?JSON.parse(n):t}catch(e){return console.error(e),t}});return U(()=>{h(e,JSON.stringify(n))},[e,n]),[n,r]},hp=`vechain-kit-storage-change`,gp=(e,t)=>{let[n,r]=G(()=>{if(typeof window>`u`)return t;try{let n=window.localStorage.getItem(e);return n?JSON.parse(n):t}catch(e){return console.error(`Error loading from localStorage:`,e),t}}),i=Zt(!1);return U(()=>{if(!(typeof window>`u`)){if(i.current){i.current=!1;return}try{window.localStorage.setItem(e,JSON.stringify(n)),window.dispatchEvent(new CustomEvent(hp,{detail:{key:e,value:n}}))}catch(e){console.error(`Error writing to localStorage:`,e)}}},[e,n]),U(()=>{if(typeof window>`u`)return;let t=t=>{if(t.key===e&&t.newValue)try{let e=JSON.parse(t.newValue);JSON.stringify(e)!==JSON.stringify(n)&&(i.current=!0,r(e))}catch(e){console.error(`Error parsing storage value:`,e)}},a=(t=>{if(t.detail.key===e)try{let t=window.localStorage.getItem(e);if(t){let e=JSON.parse(t);JSON.stringify(e)!==JSON.stringify(n)&&(i.current=!0,r(e))}}catch(e){console.error(`Error parsing storage value:`,e)}});return window.addEventListener(`storage`,t),window.addEventListener(hp,a),()=>{window.removeEventListener(`storage`,t),window.removeEventListener(hp,a)}},[e,n]),[n,r,H(()=>{if(!(typeof window>`u`))try{let i=window.localStorage.getItem(e),a=i?JSON.parse(i):t;JSON.stringify(a)!==JSON.stringify(n)&&r(a)}catch(e){console.error(`Error syncing localStorage:`,e)}},[e,t,n]),H(()=>{if(typeof window>`u`)return t;let n=window.localStorage.getItem(e);return n?JSON.parse(n):t},[e,t])]},_p=()=>{let[e,t]=mp(pp.ECOSYSTEM_SHORTCUTS,[]);return{shortcuts:e,addShortcut:n=>{e.some(e=>e.url===n.url)||t([...e,n])},removeShortcut:n=>{t(e.filter(e=>e.url!==n))},isShortcut:t=>e.some(e=>e.url===t)}},vp=async(e,t,n,r,i)=>await(await fetch(t+`estimate/clauses/`+r.toLowerCase()+`?type=smartaccount&speed=`+i,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({clauses:n,signer:e})})).json(),yp=async e=>await(await fetch(e+`deposit/account`,{method:`GET`,headers:{"Content-Type":`application/json`}})).json(),bp=async(e,t,n,r)=>await(await fetch(r+`sign/transaction/authorized/`+n.toLowerCase(),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({raw:e,origin:t,token:n.toLowerCase()})})).json(),xp=async(e,t,n,r)=>{let i=await t.gas.estimateGas(e,n?.address??``),a=Math.max(i.totalGas,0);return r?await t.transactions.buildTransactionBody(e,a,{isDelegated:r}):await t.transactions.buildTransactionBody(e,a)};function Sp(e,t){return fn.of(e.body,ua.concatBytes(e.signature??new Uint8Array,un.of(t.slice(2)).bytes))}function Cp(e,t){return fn.decode(un.of(e.slice(2)).bytes,t)}const wp=()=>{let{connectedWallet:e}=Q(),{data:n}=Nf(e?.address??``),{data:r}=xf(n?.address??``,e?.address??``),{preferences:i}=Tp(),a=Qr.createInterface(),{network:o}=$(),{buildClausesWithAuth:s}=fp(),c=Ri.at(k(o.type).nodeUrl);return{sendTransactionUsingGenericDelegator:H(async({clauses:e,genericDelegatorUrl:o})=>{try{let l=i.gasTokenToUse,u=await vp(n?.address??``,o,e,l,`medium`),d=await yp(o),p={to:l===`VET`?d.depositAccount:f[l].address,value:l===`VET`?bi(u.transactionCost?.toString()??`0`).toString():`0x0`,data:l===`VET`?`0x`:a.encodeFunctionData(`transfer`,[d.depositAccount,bi(u.transactionCost?.toString()??`0`)]),comment:`Transfer ${u.transactionCost} ${l} to ${d.depositAccount}`,abi:l===`VET`?void 0:a.getFunction(`transfer`)},m=await s({clauses:[...e,p],smartAccount:n,version:r?.version??0}),h=await xp(m,c,t,!0),g=await fn.of(h).signAsSender(un.of(t.privateKey).bytes),_=await bp(un.of(g.encoded).toString(),t.address,l,o),v=Sp(g,_.signature),y={clauses:m,simulateTransactionOptions:{caller:t.address??``,gasPayer:_.address}},b=await c.transactions.simulateTransaction(y.clauses,{...y.simulateTransactionOptions});for(let e=0;e<b.length;e++)if(b[e].reverted)throw Error(b[e].vmError);return(await c.transactions.sendTransaction(v)).id}catch(e){console.error(`Error sending transaction using generic delegator`,e)}throw Error(`Failed to send transaction using generic delegator, no gas tokens have sufficient balance or are enabled in Gas Token Preferences`)},[i,n,r,s,c,t])}},Tp=()=>{let[e,t]=gp(pp.GAS_TOKEN_PREFERENCES,ne);return{preferences:e,supportedTokens:f,updatePreferences:H(e=>{t(t=>({...t,...e}))},[t]),reorderTokenPriority:H(e=>{t(t=>{let n=e.filter(e=>t.availableGasTokens.includes(e)&&!t.excludedTokens.includes(e));return{...t,tokenPriority:e,availableGasTokens:n,gasTokenToUse:n[0]??t.gasTokenToUse}})},[t]),toggleTokenExclusion:H(e=>{t(t=>{let n=t.excludedTokens.includes(e),r=n?t.excludedTokens.filter(t=>t!==e):[...t.excludedTokens,e],i=t.tokenPriority.indexOf(e),a=n?[...t.availableGasTokens.slice(0,i),e,...t.availableGasTokens.slice(i)]:t.availableGasTokens.filter(t=>t!==e);return{...t,excludedTokens:r,availableGasTokens:a,gasTokenToUse:a[0]??t.gasTokenToUse}})},[t])}},Ep=({clauses:e,enabled:t=!0,tokens:n,sendingAmount:r,sendingTokenSymbol:i})=>{let{connectedWallet:a,account:o}=Q(),{data:s}=Nf(a?.address??``),{feeDelegation:c}=$(),{balances:l}=ns(o?.address??``),{updatePreferences:u}=Tp();return X({queryKey:[`gas-estimation`,JSON.stringify(e),JSON.stringify(n),r,i],queryFn:async()=>{let t=null;for(let a of n)try{let n=await vp(s?.address??``,c?.genericDelegatorUrl??``,e,a,`medium`),o=n.transactionCost,d=Number(l.find(e=>e.symbol===a)?.balance||0),f=o+(r&&i&&a===i?Number(r):0);if(d>=f)return u({gasTokenToUse:a}),{...n,usedToken:a};t=Error(`Insufficient ${a} balance: has ${d}, needs ${f}`)}catch(e){t=e}throw t||Error(`All gas tokens failed estimation or have insufficient balance`)},enabled:t&&e.length>0&&!!s?.address&&!!c?.genericDelegatorUrl&&n.length>0&&l.length>0,staleTime:30*1e3,gcTime:300*1e3,refetchOnWindowFocus:!1,refetchOnReconnect:!1,refetchOnMount:!1,retry:!1,retryDelay:1e3})},Dp=({clauses:e,tokens:t,enabled:n=!0})=>{let{connectedWallet:r}=Q(),{data:i}=Nf(r?.address??``),{feeDelegation:a}=$();return X({queryKey:[`gas-estimation-all-tokens`,JSON.stringify(e),JSON.stringify(t)],queryFn:async()=>{let n={};return await Promise.all(t.map(async t=>{try{n[t]={cost:(await vp(i?.address??``,a?.genericDelegatorUrl??``,e,t,`medium`)).transactionCost||0,loading:!1}}catch(e){n[t]={cost:0,loading:!1,error:e instanceof Error?e.message:`Unknown error`}}})),n},enabled:n&&e.length>0&&!!i?.address&&!!a?.genericDelegatorUrl&&t.length>0,staleTime:30*1e3,gcTime:300*1e3,refetchOnWindowFocus:!1,refetchOnReconnect:!1,refetchOnMount:!1})},Op=({label:e,address:t,domain:n,imageSrc:r,imageAlt:i=`Account`,hideAddress:a=!1,balance:o,tokenAddress:s})=>{let{t:c}=Y(),u=B(`colors`,`vechain-kit-text-primary`),d=B(`colors`,`vechain-kit-text-secondary`),f=B(`colors`,`vechain-kit-card`),{isLoading:p}=fs({address:t}),{tokens:m,isLoading:h}=ds({address:t}),g=W(()=>s?m.find(e=>e.address===s):null,[m,s]),_=W(()=>o===void 0?g?Number(g.balance):0:o,[o,g]),v=g?.symbol||``;return p||h?J(A,{w:`full`,p:2,borderRadius:`lg`,bg:f,children:[q(R,{fontSize:`sm`,fontWeight:`bold`,mb:2,color:u,children:e}),J(M,{minH:`50px`,justify:`space-between`,children:[J(M,{children:[q(kt,{boxSize:`40px`,borderRadius:`xl`}),J(z,{align:`start`,spacing:0,children:[q(kt,{height:`16px`,width:`120px`,borderRadius:`md`}),!a&&q(kt,{mt:2,height:`12px`,width:`100px`,borderRadius:`md`})]})]}),J(z,{justify:`flex-start`,align:`flex-end`,spacing:0,mr:2,children:[q(R,{fontSize:`sm`,fontWeight:`medium`,color:u,children:c(`Balance`)}),q(kt,{height:`12px`,width:`80px`,borderRadius:`md`})]})]})]}):J(A,{w:`full`,p:2,borderRadius:`lg`,bg:f,wordBreak:`break-word`,children:[q(R,{fontSize:`sm`,fontWeight:`bold`,mb:2,color:u,children:e}),J(M,{minH:`50px`,justify:`space-between`,children:[J(M,{children:[q(ut,{src:r,alt:i,boxSize:`40px`,borderRadius:`xl`,objectFit:`cover`}),q(z,{align:`start`,spacing:0,children:n?J(K,{children:[q(R,{fontWeight:`medium`,fontSize:`sm`,color:u,"data-testid":`${e.toLowerCase()}-domain`,children:n}),!a&&q(R,{fontSize:`xs`,color:d,"data-testid":`${e.toLowerCase()}-address`,children:l(t,6,4)})]}):q(R,{fontWeight:`medium`,fontSize:`sm`,color:u,"data-testid":`${e.toLowerCase()}-address`,children:l(t,6,4)})})]}),J(z,{justify:`flex-start`,align:`flex-end`,spacing:0,mr:2,children:[q(R,{fontSize:`sm`,fontWeight:`medium`,color:u,children:c(`Balance`)}),J(R,{fontSize:`xs`,color:d,children:[_.toLocaleString(void 0,{maximumFractionDigits:2}),v&&` ${v}`]})]})]})]})},kp=({onClick:e,...t})=>q(lt,{"aria-label":`FAQ`,icon:q(N,{as:sr,fontSize:`17px`}),size:`sm`,variant:`ghost`,position:`absolute`,borderRadius:`50%`,left:`10px`,top:`10px`,onClick:e,...t}),Ap=({children:e,...t})=>(of(),q(z,{...t,children:e})),jp=({wallet:e,props:t})=>{let n=Zt(e?.image);return U(()=>{e?.image&&!e.isLoadingMetadata&&(n.current=e.image)},[e?.image,e?.isLoadingMetadata]),!t?.src&&!e?.image&&!n.current||e?.isLoadingMetadata?q(kt,{rounded:`full`,width:t?.width,height:t?.height}):q(ut,{src:t?.src||e?.image||n.current,alt:t?.alt||e?.domain,objectFit:`cover`,rounded:`full`,...t})},Mp=({transactionError:e,isSubmitting:t,isTxWaitingConfirmation:n,onConfirm:r,onRetry:i,transactionPendingText:a,txReceipt:o,isSubmitForm:s=!1,buttonText:c,isDisabled:l=!1,style:u,onError:d,gasEstimationError:f,hasEnoughGasBalance:p=!0,isLoadingGasEstimation:m=!1,showGasEstimationError:h=!1,context:g=`transaction`})=>{let{t:_}=Y(),{darkMode:v}=$(),{network:y}=$(),b=W(()=>e?e.reason||_(`Something went wrong. Please try again.`):null,[e,_]);U(()=>{b&&d?.(b)},[b,d]);let x=W(()=>{if(u?.accentColor)return`${u.accentColor} !important`},[u?.accentColor]),S=W(()=>{if(!h||m||!(f||p))return null;if(!p&&!f)return{message:_(`You don't have any gas tokens enabled. Please enable at least one gas token in Gas Token Preferences.`)};if(f){let e=``;switch(g){case`send`:e=_(`Insufficient balance to complete this transfer and cover gas fees.`);break;case`customization`:e=_(`Insufficient balance to update your profile and cover gas fees.`);break;case`domain`:e=_(`Insufficient balance to claim this domain and cover gas fees.`);break;default:e=_(`Insufficient balance to complete this transaction and cover gas fees.`)}return{message:e}}return null},[f,p,m,h,g,_]);return J(z,{width:`full`,spacing:4,children:[b&&q(A,{p:3,borderRadius:`md`,bg:v?`rgba(218, 90, 90, 0.1)`:`rgba(218, 90, 90, 0.05)`,borderWidth:`1px`,borderColor:v?`rgba(218, 90, 90, 0.3)`:`rgba(218, 90, 90, 0.2)`,w:`full`,children:q(R,{color:`#da5a5a`,fontSize:`sm`,fontWeight:`medium`,"data-testid":`tx-send-error-msg`,children:b})}),S&&!b&&q(A,{p:3,borderRadius:`md`,bg:v?`rgba(218, 90, 90, 0.1)`:`rgba(218, 90, 90, 0.05)`,borderWidth:`1px`,borderColor:v?`rgba(218, 90, 90, 0.3)`:`rgba(218, 90, 90, 0.2)`,w:`full`,children:q(R,{color:`#da5a5a`,fontSize:`sm`,fontWeight:`medium`,"data-testid":`gas-estimation-error`,children:S.message})}),q(j,{px:4,variant:b?`vechainKitSecondary`:`vechainKitPrimary`,bg:x,onClick:()=>b&&i?i():r(),type:s?`submit`:`button`,isLoading:t,isDisabled:l,loadingText:n?_(`Waiting wallet confirmation...`):a,"data-testid":`confirm-button`,children:b?_(`Retry`):c||_(`Confirm`)}),b&&o?.meta.txID&&q(ht,{isExternal:!0,fontSize:`sm`,color:v?`whiteAlpha.600`:`blackAlpha.600`,textAlign:`center`,width:`full`,href:`${k(y.type).explorerUrl}/${o?.meta.txID}`,target:`_blank`,rel:`noopener noreferrer`,children:_(`View transaction on the explorer`)})]})},Np=({onClick:e,hasUnreadNotifications:t,...n})=>q(lt,{"aria-label":`Notifications`,size:`sm`,variant:`ghost`,position:`absolute`,borderRadius:`50%`,left:`10px`,top:`10px`,onClick:e,icon:J(A,{position:`relative`,children:[q(Xn,{fontSize:`20px`}),t&&q(A,{position:`absolute`,top:`-1px`,right:`-1px`,minWidth:`8px`,height:`8px`,bg:`red.500`,borderRadius:`full`})]}),...n}),Pp=({isOpen:e,onClose:t,selectedToken:n,onTokenSelect:r,availableTokens:i,tokenEstimations:a,walletAddress:o})=>{let{t:c}=Y(),{balances:l}=ns(o),[u,d]=V.useState(n),[p,m]=V.useState(!1),h=B(`colors`,`vechain-kit-text-primary`),g=B(`colors`,`vechain-kit-text-secondary`),_=B(`colors`,`vechain-kit-text-tertiary`),y=B(`colors`,`vechain-kit-error`),b=e=>e?_:`transparent`,x=e=>e?h:`transparent`;V.useEffect(()=>{e&&(d(n),m(!1))},[e,n]);let S=()=>{r(u,p),t()},C=e=>{let t=l.find(t=>t.symbol===e);return t?Number(t.balance).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2}):`0.00`},w=e=>{let t=l.find(t=>t.symbol===e),n=a[e];return!t||!n?!1:Number(t.balance)<n.cost};return J($a,{isOpen:e,onClose:t,size:`sm`,children:[J(L,{children:[q(R,{fontSize:`lg`,fontWeight:`semibold`,color:h,children:c(`Fee token`)}),q(R,{fontSize:`sm`,fontWeight:`normal`,color:g,mt:1,children:c(`Select the token to pay the fee with`)})]}),q(P,{children:J(z,{spacing:2,align:`stretch`,children:[i.map(e=>{let t=f[e],n=u===e,r=a[e]||{cost:0,loading:!0},i=w(e);return q(A,{cursor:i?`not-allowed`:`pointer`,bg:b(n),border:`1px`,borderColor:x(n),borderRadius:`md`,p:3,transition:`all 0.2s ease`,_hover:{backgroundColor:i?b(n):g&&`#ffffff12`,borderColor:i?x(n):g},opacity:i?.5:1,onClick:()=>!i&&d(e),children:J(M,{spacing:3,justify:`space-between`,children:[J(M,{spacing:3,flex:1,children:[V.cloneElement(s[e],{boxSize:`36px`,borderRadius:`full`}),J(z,{align:`start`,spacing:0,children:[q(R,{fontWeight:`medium`,color:h,children:t.symbol}),J(R,{fontSize:`xs`,color:g,children:[c(`Balance`),`:`,` `,C(e)]}),i&&q(R,{fontSize:`xs`,color:y,children:c(`Insufficient balance`)})]})]}),q(z,{align:`end`,spacing:0,children:r.loading?q(kt,{height:`16px`,width:`60px`}):J(K,{children:[q(R,{fontSize:`sm`,fontWeight:`semibold`,color:h,children:v(r.cost,2)}),q(R,{fontSize:`xs`,color:g,children:t.symbol})]})})]})},e)}),u!==n&&J(it,{display:`flex`,alignItems:`center`,justifyContent:`space-between`,children:[q(at,{htmlFor:`remember-choice`,mb:`0`,fontSize:`sm`,color:h,children:c(`Use this token for future transactions`)}),q(Mt,{id:`remember-choice`,isChecked:p,onChange:e=>m(e.target.checked),color:h})]})]})}),q(I,{children:J(z,{spacing:3,w:`full`,children:[q(j,{variant:`vechainKitPrimary`,onClick:S,isDisabled:w(u),children:c(`Apply`)}),q(j,{variant:`ghost`,width:`full`,onClick:t,children:c(`Cancel`)})]})})]})},Fp=({estimation:e,isLoading:t,isLoadingTransaction:n,onTokenChange:r,clauses:i=[],userSelectedToken:a})=>{let{t:o}=Y(),{feeDelegation:c}=$(),{connection:l,account:u}=Q(),{preferences:d,reorderTokenPriority:p}=Tp(),{isOpen:m,onOpen:h,onClose:g}=Gt(),_=B(`colors`,`vechain-kit-text-primary`),y=B(`colors`,`vechain-kit-text-secondary`),[b,x]=G(()=>{let e={};return d.availableGasTokens.forEach(t=>{e[t]={cost:0,loading:!0}}),e}),{data:S,isLoading:C}=Dp({clauses:i,tokens:d.availableGasTokens,enabled:i.length>0});U(()=>{!C&&S&&x(S)},[S,C]),U(()=>{e&&x(t=>({...t,[e.usedToken]:{cost:e.transactionCost||0,loading:!1}}))},[e]),U(()=>{C&&x(d.availableGasTokens.reduce((e,t)=>(e[t]={cost:0,loading:!0},e),{}))},[C,d.availableGasTokens]);let w=H((t,n)=>{n&&p([t,...d.tokenPriority.filter(e=>e!==t)]),r&&t!==e?.usedToken&&r(t)},[e,r,p,d.tokenPriority]);if(c?.delegatorUrl||l.isConnectedWithDappKit||d.availableGasTokens.length===0)return null;let{balances:ee}=ns(u?.address??``),T=e=>{let t=ee.find(t=>t.symbol===e),n=b[e];return!t||!n||n.loading?!0:Number(t.balance)<n.cost},E=e?.usedToken,D=d.availableGasTokens,te;E?te=E:a&&D.includes(a)?te=a:(te=D.find(e=>b[e]&&!b[e].loading&&!T(e)),te||=D.find(e=>b[e]&&!b[e].loading),te||=D[0]);let ne=te?b[te]:void 0,re=E&&e?.transactionCost?e.transactionCost:ne?.cost||0,O=te?f[te]:void 0;return J(K,{children:[q(nt,{mt:3}),J(M,{mt:3,w:`full`,justifyContent:`start`,alignItems:`center`,children:[J(z,{align:`start`,spacing:0,w:`full`,children:[q(R,{fontSize:`sm`,fontWeight:`light`,textAlign:`left`,w:`full`,color:y,children:o(`Fee`)}),q(M,{align:`start`,justifyContent:`space-between`,spacing:0,w:`full`,children:q(M,{justifyContent:`flex-start`,w:`full`,children:t||!E&&(!ne||ne.loading)||!O?J(K,{children:[q(kt,{height:`16px`,width:`120px`,borderRadius:`md`}),q(kt,{height:`16px`,width:`60px`,borderRadius:`md`})]}):J(K,{children:[J(R,{color:_,fontSize:`sm`,fontWeight:`semibold`,children:[v(re,2),` `,O.symbol]}),J(R,{color:y,fontSize:`xs`,children:[`≈`,` $`,(re*.01).toFixed(2)]})]})})})]}),J(j,{onClick:h,variant:`outline`,size:`sm`,borderRadius:`full`,px:6,disabled:n,color:y,borderColor:y,_hover:{bg:y},leftIcon:V.cloneElement(s[te||d.availableGasTokens[0]],{boxSize:`20px`,borderRadius:`full`}),children:[q(R,{fontSize:`sm`,fontWeight:`semibold`,children:te||d.availableGasTokens[0]}),q(N,{as:tr,boxSize:5,color:y})]})]}),q(Pp,{isOpen:m,onClose:g,selectedToken:te||d.availableGasTokens[0],onTokenSelect:w,availableTokens:d.availableGasTokens,tokenEstimations:b,walletAddress:u?.address??``})]})},Ip=({isOpen:e,onClose:t,steps:n,activeStep:r,goToPrevious:i,setActiveStep:a,disableBackButton:o,disableCloseButton:s,closeOnOverlayClick:c=!0,isCloseable:l=!0})=>{let u=()=>{a(0),t()},[d]=Kt(`(min-width: 1060px)`),f=n[r],p=r===0,m=!p&&!o||f?.title||d&&!s;return f?q($a,{closeOnOverlayClick:c,isOpen:e,onClose:u,isCloseable:l,blockScrollOnMount:!0,children:q(Ge,{p:0,bg:`none`,children:J(Ke,{p:0,children:[m?J(Z,{children:[f?.title?q(L,{children:f.title}):null,!p&&!o?q(Ja,{onClick:i}):null,d&&!s?q(F,{onClick:t}):null]}):null,f?.description?q(R,{fontSize:{base:14,md:16},fontWeight:400,px:4,children:f?.description}):null,q(Vn.div,{initial:`hidden`,animate:`visible`,style:{width:`100%`},children:f.content},f.key)]})})}):null},Lp=({document:e,register:t,isText:n=!1})=>{let{t:r}=Y(),{darkMode:i}=$(),a=e.displayName??r(`Policy`),o=i?`whiteAlpha.400`:`blackAlpha.400`,s=i?`blue.300`:`blue.500`,c=i?`blue.200`:`blue.700`,l=(()=>{if(!e.documentType)return a;switch(e.documentType){case`terms`:return e.displayName||`Terms of Service`;case`privacy`:return e.displayName||`Privacy Policy`;case`cookies`:return e.displayName||`Cookie Policy`;default:return e.displayName||`Legal Document`}})();return n?J(ht,{href:e.url,isExternal:!0,color:`blue.500`,textDecoration:`underline`,_hover:{color:`blue.300`,textDecoration:`underline`},fontWeight:`medium`,display:`contents`,alignItems:`center`,children:[q(dt,{...t(e.id,{required:e.required}),type:`checkbox`,hidden:!0}),l,q(N,{as:fr,ml:1,boxSize:3})]},e.id):q(M,{width:`full`,borderRadius:`md`,transition:`all 0.2s`,children:J(M,{align:`flex-start`,spacing:3,width:`full`,children:[q(Ze,{mt:`2px`,size:`md`,colorScheme:`blue`,borderColor:o,...t(e.id,{required:e.required}),"data-testid":`tnc-checkbox`}),J(R,{fontSize:`xs`,children:[r(`I have read and agree to `),J(ht,{href:e.url,isExternal:!0,color:s,textDecoration:`underline`,_hover:{color:c,textDecoration:`underline`},fontWeight:`medium`,display:`contents`,alignItems:`center`,children:[l,q(N,{as:fr,ml:1})]}),e.required&&q(R,{as:`span`,color:`red.500`,fontWeight:`bold`,children:`*`})]})]})},e.id)},Rp=({onAgree:e,onReject:t,onlyOptionalDocuments:n=!1})=>{let{t:r}=Y(),{darkMode:i}=$(),{documentsNotAgreed:a}=Kp(),{requiredDocuments:o,optionalDocuments:s}=W(()=>a.reduce((e,t)=>(t.required?e.requiredDocuments.push(t):e.optionalDocuments.push(t),e),{requiredDocuments:[],optionalDocuments:[]}),[a]),{handleSubmit:c,register:l,formState:{isValid:u},watch:d}=Hi({defaultValues:W(()=>a.reduce((e,t)=>(e[t.id]=t.required,e),{}),[a])}),f=d(),p=W(()=>a.filter(e=>f[e.id]),[a,f]),m=a?.length===p.length,h=H(t=>{let n=new Set(Object.entries(t).filter(([e,t])=>t).map(([e])=>e));return e(a.filter(e=>n.has(e.id)))},[a,e]),g=i?`#3a3a3a`:`#eaeaea`,_=i?`#2a2a2a`:`#f5f5f5`,v=i?`gray.300`:`gray.600`,y=i?`0 2px 8px rgba(0, 0, 0, 0.2)`:`0 2px 8px rgba(0, 0, 0, 0.05)`,b=o.length>0,x=s.length>0,S=W(()=>{let e=s.filter(e=>f[e.id]).length;return r(m?`Accept all`:n&&e===0?`Ignore and continue`:b&&!x||b&&e===0?`Accept`:`Accept selected`)},[n,m,s,f]),C=e=>e===o.length-2&&o.length>1?r(` and `):`, `;return q(jt,{width:`full`,children:J(`form`,{onSubmit:c(h),children:[q(Z,{children:q(L,{children:r(`Terms and Policies`)})}),q(P,{children:J(z,{align:`stretch`,spacing:5,width:`full`,children:[b&&J(R,{as:`span`,fontSize:`sm`,children:[r(`By continuing, you agree to`),` `,o.map((e,t)=>J(Jt,{children:[q(Lp,{document:e,register:l,isText:!0},e.id),t<o.length-1?C(t):null]},e.id)),`.`,` `,r(`Please take a moment to review all the policies, with acceptance being mandatory to continue.`)]}),n&&q(R,{fontSize:`sm`,color:v,mb:3,children:q(gn,{i18nKey:`<bold>Your privacy matters.</bold> You’re in control, accept to enable optional features like cookies that help us enhance your experience.`,components:{bold:q(R,{as:`span`,fontWeight:`semibold`,color:v})}})}),x&&J(jt,{p:4,borderRadius:`xl`,bg:_,borderWidth:`1px`,borderColor:g,boxShadow:y,spacing:5,children:[q(R,{fontSize:`md`,fontWeight:`bold`,color:v,children:r(`Optional`)}),q(z,{align:`stretch`,spacing:4,children:s.map(e=>q(Lp,{document:e,register:l},e.id))})]})]})}),q(I,{children:J(z,{width:`full`,spacing:3,children:[q(j,{variant:`vechainKitPrimary`,width:`full`,type:`submit`,isDisabled:!u,"data-testid":`accept-tnc-button`,children:S}),!n&&q(j,{variant:`ghost`,width:`full`,onClick:t,"data-testid":`reject-tnc-button`,colorScheme:`red`,children:r(`Reject and logout`)})]})})]})})};var zp=function(e){return e.REVIEW_DOCUMENTS=`REVIEW_DOCUMENTS`,e.REJECT_DOCUMENTS=`REJECT_DOCUMENTS`,e}(zp||{});const Bp=({isOpen:e,onAgree:t,handleLogout:n,onlyOptionalDocuments:r})=>{let{t:i}=Y(),{activeStep:a,goToPrevious:o,setActiveStep:s,goToNext:c}=qt({index:0,count:Object.keys(zp).length}),l=()=>{s(0)},u=()=>{c()},d=()=>{n(),l()};return q(Ip,{isOpen:e,onClose:()=>{},goToPrevious:o,goToNext:c,setActiveStep:s,steps:W(()=>[{key:zp.REVIEW_DOCUMENTS,content:q(Rp,{onAgree:t,onReject:u,onlyOptionalDocuments:r})},{key:zp.REJECT_DOCUMENTS,content:q(il,{onDisconnect:d,onBack:o,onClose:o,text:i(`Are you sure you want to reject the policies and disconnect?`),showCloseButton:!1})}],[Rp,il,t,d]),disableCloseButton:!0,disableBackButton:!0,isCloseable:!1,closeOnOverlayClick:!1,activeStep:a})},Vp=e=>`${e.documentType}-${e.url.replace(/[^\w-]+/g,`-`)}-v${e.version}`,Hp=e=>e.map(e=>({...e,id:Vp(e)})),Up=e=>e.filter(e=>!e.required),Wp=(e,t)=>{let n=Date.now();return e.map(e=>({...e,walletAddress:t,timestamp:n}))},Gp=Yt(void 0),Kp=()=>Xt(Gp)||{hasAgreedToRequiredDocuments:!0,agreements:[],walletAddress:void 0,documents:[],documentsNotAgreed:[]},qp=({children:e})=>{let{connection:t,account:n,disconnect:r}=Q(),{darkMode:i,legalDocuments:a,theme:s}=$(),[c,l]=gp(`vechain-kit-legal-documents`,[]),[u,d]=gp(`vechain-kit-legal-documents-optional-reject`,[]),[f,p]=G(!1),h=H((e,t)=>u.some(n=>o(n.walletAddress,t)&&n.id===e.id),[u]),[g,_]=W(()=>{let e=Hp([{items:a?.cookiePolicy||[],type:se.COOKIES,source:m.APPLICATION},{items:a?.privacyPolicy||[],type:se.PRIVACY,source:m.APPLICATION},{items:a?.termsAndConditions||[],type:se.TERMS,source:m.APPLICATION}].flatMap(e=>e.items.map(t=>({...t,documentType:e.type,documentSource:e.source}))));return[e,e.filter(e=>e.required)]},[a]),v=W(()=>n?.address?g.filter(e=>c.some(t=>o(t.walletAddress,n.address)&&t.id===e.id)?!1:!u.some(t=>o(t.walletAddress,n.address)&&t.id===e.id)):[],[g,n?.address,c,u]),y=W(()=>!_.length||!n?.address?!0:_.every(e=>c.some(t=>o(t.walletAddress,n.address)&&t.id===e.id)),[_,c,n?.address]),b=W(()=>{if(!n?.address||!v?.length)return!1;let e=Up(v);return e.length===0?!1:e.some(e=>!h(e,n.address))},[v,n?.address,Up,h]),x=W(()=>y&&b,[y,b]);W(()=>{let e=new Set(c.map(e=>e.id));return g.some(t=>e.has(t.id))},[g,c]),U(()=>{t.isConnected&&n?.address?p(!y||b):p(!1)},[t.isConnected,n?.address,y,b]);let S=H((e,t)=>{let n=Array.isArray(e)?e:[e];if(!n.length)return;let r=Wp(n,t);l([...c.filter(e=>!o(e.walletAddress,t)||!n.some(t=>t.id===e.id)),...r])},[c,Wp]),C=H(e=>{if(!n?.address)return;let t=Up(v);if(t.length===0)return;let r=e.map(e=>e.id),i=t.filter(e=>!r.includes(e.id));if(!i?.length)return;let a=Wp(i,n.address);d(e=>[...e,...a])},[n?.address,v,Up,Wp]),w=H(e=>{if(!n?.address)return;let t=Array.isArray(e)?e:[e];t.length>0&&S(t,n.address),C(t),p(!1)},[n?.address,S,C]);return J(Gp.Provider,{value:{hasAgreedToRequiredDocuments:y,agreements:c,walletAddress:n?.address,documents:g,documentsNotAgreed:v},children:[e,q(rd,{darkMode:i,theme:s,children:q(Bp,{isOpen:f,onAgree:w,handleLogout:x?()=>{}:()=>{r(),p(!1)},onlyOptionalDocuments:x})})]})},Jp=Yt(null),Yp=({children:e,nodeUrl:n,delegatorUrl:r=_(),delegateAllTransactions:i,genericDelegator:a})=>{let{signTypedData:o,exportWallet:s,signMessage:c}=Tn(),{signTypedData:l,signMessage:u}=Us(),{connection:d,connectedWallet:f}=Q(),{network:p}=$(),{data:m}=Nf(f?.address??``),{data:h}=xf(m?.address??``,f?.address??``),{data:g}=Tf(f?.address??``),{buildClausesWithAuth:v}=fp(),{sendTransactionUsingGenericDelegator:y}=wp(),b=Ri.at(n),x=async(e,i,a)=>{if(!m?.address)throw Error(`Smart account address is not set`);let o=new zi(b,i??new Ii([{privateKey:Buffer.from(t.privateKey.slice(2),`hex`),address:t.address}],{gasPayer:{gasPayerServiceUrl:r}}),!0),s=a??await o.getSigner(t.address),c=Bi.transactionBodyToTransactionRequestInput(e,t.address),l=await s.signTransaction(c),{id:u}=await fetch(`${n}/transactions`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({raw:l})}).then(e=>e.json());return u},S=H(async({txClauses:e=[],title:n=`Sign Transaction`,description:i,buttonText:o=`Sign`})=>{if(!m||m&&!m.address||!f||f&&!f.address)throw Error(`Address or embedded wallet is missing`);if(a)return await y({clauses:e,genericDelegatorUrl:r??``});let s=await v({clauses:e,smartAccount:m,version:g?1:h?.version??3,title:n,description:i,buttonText:o}),c={clauses:s,simulateTransactionOptions:{caller:t.address}},l=await b.transactions.simulateTransaction(c.clauses,{...c.simulateTransactionOptions});for(let e=0;e<l.length;e++)if(l[e].reverted)return console.error(`simulatedTx1[i].vmError: ${l[e].vmError}`),l[e].vmError;return await x(await xp(s,b,t,!0))},[y,a,m,f,r,v,g,h,b]);return q(Jp.Provider,{value:{accountFactory:k(p.type).accountFactoryAddress,sendTransaction:S,signMessage:async e=>d.isConnectedWithCrossApp?await u(e):(await c({message:e})).signature,signTypedData:async e=>d.isConnectedWithCrossApp?await l({...e,address:f?.address,types:Object.fromEntries(Object.entries(e.types).map(([e,t])=>[e,[...t]]))}):(await o(e)).signature,exportWallet:s,delegateAllTransactions:i},children:e})},Xp=()=>{let e=Xt(Jp);if(!e)throw Error(`usePrivyWalletProvider must be used within a PrivyWalletProvider`);return e},Zp=Yt(null),$=()=>{let e=Xt(Zp);if(!e)throw Error(`useVeChainKitConfig must be used within VeChainKit`);return e},Qp=e=>{let t=[],n={...e};if((n.privy!==void 0||n.loginMethods?.some(e=>e.method===`vechain`||e.method===`ecosystem`))&&(n.feeDelegation?!n.feeDelegation.delegatorUrl&&!n.feeDelegation.genericDelegatorUrl&&(n.feeDelegation.genericDelegatorUrl=_()):n.feeDelegation={genericDelegatorUrl:_()}),n.network?(n.network.type||t.push(`network.type is required`),[`main`,`test`,`solo`].includes(n.network.type)||t.push(`network.type must be either "main", "test" or "solo"`)):t.push(`network configuration is required`),n.loginMethods&&!n.privy){let e=n.loginMethods.filter(e=>[`email`,`google`,`passkey`,`more`].includes(e.method));e.length>0&&t.push(`Login methods ${e.map(e=>`"${e.method}"`).join(`, `)} require Privy configuration. Please either remove these methods or configure the privy prop.`)}if(n?.legalDocuments&&(n.legalDocuments.termsAndConditions&&n.legalDocuments.termsAndConditions.forEach(e=>{C(e.url)||t.push(`legalDocuments.termsAndConditions.url is invalid: ${e.url}`)}),n.legalDocuments.privacyPolicy&&n.legalDocuments.privacyPolicy.forEach(e=>{C(e.url)||t.push(`legalDocuments.privacyPolicy.url is invalid: ${e.url}`)}),n.legalDocuments.cookiePolicy&&n.legalDocuments.cookiePolicy.forEach(e=>{C(e.url)||t.push(`legalDocuments.cookiePolicy.url is invalid: ${e.url}`)})),t.length>0)throw Error(`VeChainKit Configuration Error:
192
+ `}),Xu=({children:e,theme:t,bodyFont:n,headingFont:r})=>J(ra,{value:W(()=>Ju(),[]),children:[q(Yu,{bodyFont:n,headingFont:r}),q(Xe,{theme:t,resetCSS:!1,portalZIndex:void 0,children:e})]}),Zu=({darkMode:e})=>{try{if(S(`[data-chakra-color-mode]`))return null}catch(e){console.error(e)}return q(et,{initialColorMode:e?`dark`:`light`})},Qu=Yt({portalRootRef:void 0,tokens:void 0}),$u=()=>{let e=Xt(Qu);if(!e)throw Error(`useVechainKitTheme must be used within a VechainKitThemeProvider`);return e},ed=({darkMode:e=!1})=>{let{setColorMode:t,colorMode:n}=Wt();return U(()=>{let r=e?`dark`:`light`;n!==r&&t(r)},[e]),q(K,{})},td=({children:e,darkMode:t=!1,theme:n})=>{let r=Zt(null),i=Xt(Yp),a=i?i.theme:void 0,o=n??a,s=W(()=>Ra(La(t),za(o,t)),[t,o]),c=W(()=>({...Ku(t,o),config:{...Ku(t,o).config,initialColorMode:t?`dark`:`light`}}),[t,o]);return J(Qu.Provider,{value:{portalRootRef:r,tokens:s},children:[q(Zu,{darkMode:t}),J(Xu,{theme:c,bodyFont:s.fonts.body,headingFont:s.fonts.heading,children:[q(ed,{darkMode:t}),q(A,{id:`vechain-kit-root`,ref:r,bg:`transparent`,borderRadius:`12px`,children:e})]}),q(qu,{})]})},nd=Yt(null),rd=()=>{let e=Xt(nd);if(!e)throw Error(`useModal must be used within ModalProvider`);return e},id=({children:e})=>{let{darkMode:t,theme:n}=$(),[r,i]=G(!1),{setSource:a,connectV2:o}=Mn(),s=H(()=>{y()&&window.vechain&&window.vechain.isInAppBrowser?(a(`veworld`),o(null)):i(!0)},[]),c=H(()=>i(!1),[]),[l,u]=G(!1),[d,f]=G(!1),p=H((e,t)=>{re(e??`main`),f(t?.isolatedView??!1),u(!0)},[]),m=H(()=>{u(!1),setTimeout(()=>{f(!1)},300)},[]),[h,g]=G(!1),_=H(()=>g(!0),[]),v=H(()=>g(!1),[]),[b,x]=G(!1),S=H(()=>x(!0),[]),C=H(()=>x(!1),[]),[w,ee]=G(!1),[T,E]=G(void 0),D=H(e=>{E(e),ee(!0)},[]),te=H(()=>ee(!1),[]),[ne,re]=G(`main`);return J(nd.Provider,{value:{openConnectModal:s,closeConnectModal:c,isConnectModalOpen:r,openAccountModal:p,closeAccountModal:m,isAccountModalOpen:l,setAccountModalContent:re,accountModalContent:ne,isolatedView:d,openTransactionModal:_,closeTransactionModal:v,isTransactionModalOpen:h,openTransactionToast:S,closeTransactionToast:C,isTransactionToastOpen:b,openUpgradeSmartAccountModal:D,closeUpgradeSmartAccountModal:te,isUpgradeSmartAccountModalOpen:w},children:[e,J(td,{darkMode:t,theme:n,children:[q(pu,{isOpen:r,onClose:c}),q(fu,{isOpen:l,onClose:m,initialContent:ne}),q(ku,{isOpen:w,onClose:te,style:T})]})]})},ad=()=>{let{loginMethods:e}=$(),t=e?.length===1&&e[0].method===`dappkit`,{openConnectModal:n,closeConnectModal:r,isConnectModalOpen:i}=rd(),{open:a,close:o}=Pn();return{open:t?a:n,close:t?o:r,isOpen:t?!1:i}},od=({children:e})=>q(K,{children:e}),sd=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=rd();return{open:()=>e(),close:t,isOpen:n}},cd=({children:e})=>q(K,{children:e}),ld=()=>{let{openTransactionModal:e,closeTransactionModal:t,isTransactionModalOpen:n}=rd();return{open:e,close:t,isOpen:n}},ud=({children:e})=>q(K,{children:e}),dd=()=>{let{openTransactionToast:e,closeTransactionToast:t,isTransactionToastOpen:n}=rd();return{open:e,close:t,isOpen:n}},fd=({children:e})=>q(K,{children:e}),pd=()=>{let{connection:e}=Q(),{openConnectModal:t,closeConnectModal:n,isConnectModalOpen:r,openAccountModal:i,closeAccountModal:a,isAccountModalOpen:o}=rd();return{open:()=>{e.isConnected?i():t()},close:()=>{o&&a(),r&&n()},isOpen:r||o}},md=({children:e})=>q(K,{children:e}),hd=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n,setAccountModalContent:r}=rd();return{open:t=>{e({type:`choose-name`,props:{setCurrentContent:r,onBack:()=>r(`main`),initialContentSource:`main`}},t)},close:()=>{t()},isOpen:n}},gd=({children:e})=>q(K,{children:e}),_d=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n,setAccountModalContent:r}=rd();return{open:t=>{e({type:`send-token`,props:{setCurrentContent:r}},t)},close:()=>{t()},isOpen:n}},vd=({children:e})=>q(K,{children:e}),yd=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n,setAccountModalContent:r}=rd();return{open:t=>{e({type:`swap-token`,props:{setCurrentContent:r,fromTokenAddress:t?.fromTokenAddress,toTokenAddress:t?.toTokenAddress}},{isolatedView:t?.isolatedView})},close:()=>{t()},isOpen:n}},bd=({children:e})=>q(K,{children:e}),xd=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=rd();return{open:t=>{e(`access-and-security`,t)},close:()=>{t()},isOpen:n}},Sd=({children:e})=>q(K,{children:e}),Cd=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=rd();return{open:t=>{e(`ecosystem`,t)},close:()=>{t()},isOpen:n}},wd=({children:e})=>q(K,{children:e}),Td=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=rd();return{open:t=>{e(`notifications`,t)},close:()=>{t()},isOpen:n}},Ed=({children:e})=>q(K,{children:e}),Dd=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n,setAccountModalContent:r}=rd();return{open:t=>{e({type:`faq`,props:{onGoBack:()=>r(`main`),showLanguageSelector:!1}},t)},close:()=>{t()},isOpen:n}},Od=({children:e})=>q(K,{children:e}),kd=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n,setAccountModalContent:r}=rd();return{open:()=>{e({type:`account-customization`,props:{setCurrentContent:r}})},close:()=>{t()},isOpen:n}},Ad=({children:e})=>q(K,{children:e}),jd=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=rd();return{open:t=>{e(`receive-token`,t)},close:()=>{t()},isOpen:n}},Md=({children:e})=>q(K,{children:e}),Nd=()=>{let{privy:e,loginMethods:t}=$(),n=e?.appId===O,r=e=>t?Array.isArray(e)?e.some(e=>t.some(t=>t.method===e)):t.some(t=>t.method===e):!0,i=W(()=>t?t.length===0||r(`ecosystem`):!0,[t]),a=W(()=>r(`vechain`),[t]),o=W(()=>r(`dappkit`),[t]),s=W(()=>r(`passkey`),[t]),c=W(()=>r(`email`),[t]),l={showGoogleLogin:W(()=>r(`google`),[t]),showEmailLogin:c,showPasskey:s,showVeChainLogin:a,showDappKit:o,showEcosystem:i,showMoreLogin:W(()=>r(`more`),[t]),showGithubLogin:W(()=>r(`github`),[t]),isOfficialVeChainApp:!1};return e?n?{...l,isOfficialVeChainApp:!0}:{...l}:{...l,showGoogleLogin:!1,showEmailLogin:!1,showPasskey:!1,showMoreLogin:!1}},Pd=e=>{let{openUpgradeSmartAccountModal:t,closeUpgradeSmartAccountModal:n,isUpgradeSmartAccountModalOpen:r}=rd();return{open:()=>t(e),close:n,isOpen:r}},Fd=({children:e})=>q(K,{children:e}),Id=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=rd();return{open:t=>{e(`profile`,t)},close:()=>{t()},isOpen:n}},Ld=({children:e})=>q(K,{children:e}),Rd=()=>{let[e,t]=G(!1),[n,r]=G(null),[i,a]=G(null),{connection:o,account:s}=Q(),{requestCertificate:c}=Nn(),l=Jp();return{signMessage:H(async e=>{if(!s)throw Error(`Account not found`);t(!0),a(null),r(null);try{let t=null;return t=o.isConnectedWithDappKit?(await c({purpose:`agreement`,payload:{type:`text`,content:e}},{signer:s.address})).signature:await l.signMessage(e),r(t),t}catch(e){let t=e instanceof Error?e:Error(String(e));throw a(t),t}finally{t(!1)}},[o,l]),isSigningPending:e,signature:n,error:i,reset:H(()=>{t(!1),r(null),a(null)},[])}},zd=()=>{let[e,t]=G(!1),[n,r]=G(null),[i,a]=G(null),{signer:o}=Mn(),{connection:s}=Q(),c=Jp();return{signTypedData:H(async(e,n)=>{t(!0),a(null),r(null);try{let t;if(s.isConnectedWithDappKit){let r={...e.domain,salt:e.domain?.salt?Buffer.from(e.domain.salt).toString(`hex`):void 0};t=await o.signTypedData(r,e.types,e.message,void 0,n)}else t=await c.signTypedData(e);return r(t),t}catch(e){if(e&&typeof e==`object`&&`statusCode`in e&&e.statusCode===4001){let e=Error(`User denied signature request`);throw a(e),e}let t=e instanceof Error?e:Error(typeof e==`object`?JSON.stringify(e):String(e));throw console.error(t),a(t),t}finally{t(!1)}},[s,c]),isSigningPending:e,signature:n,error:i,reset:H(()=>{t(!1),r(null),a(null)},[])}},Bd=()=>{let{loginWithPasskey:e}=Sn();return{loginWithPasskey:async()=>{try{await e()}catch(e){throw e}}}};let Vd=!1;const Hd=()=>{let{createWallet:e}=yn(),{initOAuth:t}=xn({onComplete:H(async({isNewUser:t})=>{if(t&&!Vd){Vd=!0;try{await e()}catch(e){throw Vd=!1,console.error(`Failed to create wallet:`,e),e}}},[e])});return{initOAuth:async({provider:e})=>{try{await t({provider:e})}catch(e){throw e}}}},Ud=()=>{let e=`vechain_kit_cross_app_connection`;return{setConnectionCache:H(t=>{let n={timestamp:Date.now(),ecosystemApp:t};h(e,JSON.stringify(n))},[]),getConnectionCache:H(()=>{let t=w(e);return t?JSON.parse(t):null},[]),clearConnectionCache:H(()=>{ee(e)},[])}},Wd=()=>{let{login:e}=Us(),{setConnectionCache:t}=Ud(),{data:n}=oo([O]);return{login:async()=>{try{await e(O),t({name:`VeChain`,logoUrl:n?.[O]?.logo_url,appId:O,website:`https://governance.vebetterdao.org`})}catch(e){throw zs({error:e,mobileBrowserPopupMessage:`Your mobile browser blocked the login window. Please click 'Try again' to open the login window or change your browser settings.`,rejectedMessage:`Login request was cancelled.`,defaultMessage:`There was an unexpected issue logging in with VeChain. Please try again or contact support.`})}}}},Gd=`vechain-kit-app-hub-apps`,Kd=`vechain-kit-app-hub-apps-expiry`,qd=`https://raw.githubusercontent.com/vechain/app-hub/master`,Jd=()=>[`VECHAIN_KIT`,`appHub`,`apps`],Yd=async()=>{if(typeof window<`u`)try{let e=w(Gd),t=w(Kd);if(e&&t){let n=parseInt(t,10);if(Date.now()<n)return JSON.parse(e)}}catch{console.warn(`Invalid app-hub cache, fetching fresh data`)}let e=await fetch(`https://api.github.com/repos/vechain/app-hub/contents/apps`);if(!e.ok)throw Error(`Failed to fetch app directories`);let t=(await e.json()).map(async e=>{if(e.type!==`dir`)return null;let t=`${qd}/apps/${e.name}/manifest.json`,n=await fetch(t);if(!n.ok)return console.warn(`Failed to fetch manifest for ${e.name}`),null;try{let t=await n.json();return{id:e.name,name:t.name,description:t.desc,url:t.href,logo:`${qd}/apps/${e.name}/logo.png`,category:t.category,tags:t.tags||[],isVeWorldSupported:t.isVeWorldSupported||!1,repo:t.repo,contracts:t.contracts,veBetterDaoId:t.veBetterDaoId}}catch(t){return console.warn(`Error parsing manifest for ${e.name}:`,t),null}}),n=(await Promise.all(t)).filter(e=>e!==null);if(typeof window<`u`)try{h(Gd,JSON.stringify(n)),h(Kd,(Date.now()+864e5).toString())}catch(e){console.warn(`Failed to cache app-hub data:`,e)}return n},Xd=()=>X({queryKey:Jd(),queryFn:async()=>{try{return await Yd()}catch(e){let t=localStorage.getItem(Gd);if(t)return JSON.parse(t);throw e}},staleTime:1e3*60*60,retry:2}),Zd=({abi:e,address:t,method:n})=>[`callClause`,t,n],Qd=({abi:e,address:t,method:n,args:r})=>[`callClause`,t,n,...r?.length?[r]:[]],$d=({address:e,abi:t,method:n,args:r,queryOptions:i})=>{let a=jn();return X({queryKey:Qd({abi:t,address:e,method:n,args:r}),queryFn:async()=>T({thor:a,contractAddress:e,abi:t,method:n,args:r}),...i})},ef=({thor:e,calls:t,queryKey:n,enabled:r=!0})=>X({queryKey:n,queryFn:()=>re({thor:e,calls:t}),enabled:r}),tf=()=>{let{network:e}=$();return e.nodeUrl??k(e.type).nodeUrl},nf=()=>{let[e,t]=G(!0);return U(()=>{if(!y()){t(!1);return}let e=()=>{t(window.matchMedia(`(display-mode: standalone)`).matches||window.standalone||document.referrer.includes(`android-app://`))};return e(),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`resize`,e)}},[]),e},rf=()=>{U(()=>{let e=document.querySelector(`.chakra-modal__content`);e&&(e.scrollTop=0)},[])},af=async(e,t)=>{if(!t)throw Error(`Address is required`);let n=await e.accounts.getAccount(cn.of(t));return{balance:gi(BigInt(n.balance)).toString(),energy:gi(BigInt(n.energy)).toString()}},of=e=>[`VECHAIN_KIT_BALANCE`,e],sf=e=>{let t=jn();return X({queryKey:of(e),queryFn:()=>af(t,e),enabled:!!e&&cn.isValid(e),refetchInterval:1e4})},cf=async(e,t,n)=>{if(!n)throw Error(`Network type is required`);if(!t)throw Error(`Version is required`);let r=e.contracts.load(k(n).accountFactoryAddress,ti.abi),i;switch(t){case 1:case 2:i=r.read.accountImplementationV1();break;case 3:i=r.read.accountImplementationV3();break;default:throw Error(`Invalid version, must be between 1 and 3`)}let a=await i;if(!a)throw Error(`Failed to get account implementation address`);return a[0].toString()},lf=(e,t)=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`FACTORY`,`IMPLEMENTATION_ADDRESS`,e,t],uf=e=>{let t=jn(),{network:n}=$();return X({queryKey:lf(e,n.type),queryFn:async()=>cf(t,e,n.type),enabled:!!t&&!!e&&!!n})},df=async(e,t)=>{if(!t)throw Error(`Network type is required`);let n=await e.contracts.load(k(t).accountFactoryAddress,ti.abi).read.currentAccountImplementationVersion();if(!n)throw Error(`Failed to get current account implementation version`);return parseInt(n[0].toString())},ff=e=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`FACTORY`,`CURRENT_ACCOUNT_IMPLEMENTATION_VERSION`,e],pf=()=>{let e=jn(),{network:t}=$();return X({queryKey:ff(t.type),queryFn:async()=>df(e,t.type),enabled:!!e&&!!t})},mf=async(e,t,n)=>{if(!t)throw Error(`Owner address is required`);if(!n)throw Error(`Network type is required`);let r=await e.contracts.load(k(n).accountFactoryAddress,ti.abi).read.getAccountAddress(t);if(!r)throw Error(`Failed to get account address of ${t}`);return r[0].toString()},hf=(e,t)=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`FACTORY`,`ADDRESS`,e,t],gf=e=>{let t=jn(),{network:n}=$();return X({queryKey:hf(e,n.type),queryFn:async()=>mf(t,e,n.type),enabled:!!t&&!!e&&!!n})},_f=ti.abi,vf=(e,t,n)=>Qd({abi:_f,address:k(n).accountFactoryAddress,method:`getAccountVersion`,args:[e,t]}),yf=(e,t)=>{let{network:n}=$();return $d({address:k(n.type).accountFactoryAddress,abi:_f,method:`getAccountVersion`,args:[e,t],queryOptions:{select:e=>({version:parseInt(e[0].toString()),isDeployed:e[1]})}})},bf=ti.abi,xf=async(e,t,n)=>{if(!t)throw Error(`Owner address is required`);if(!n)throw Error(`Network type is required`);let[r]=await T({thor:e,abi:bf,contractAddress:k(n).accountFactoryAddress,method:`hasLegacyAccount`,args:[t]});return r},Sf=(e,t)=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`HAS_V1_SMART_ACCOUNT`,e,t],Cf=e=>{let t=jn(),{network:n}=$();return X({queryKey:Sf(e,n.type),queryFn:async()=>xf(t,e,n.type),enabled:!!t&&!!e&&!!n})},wf=async(e,t)=>{if(!t)throw Error(`Account address is required`);let n=await e.accounts.getAccount(cn.of(String(t)));if(!n)throw Error(`Account not found`);return n.hasCode},Tf=e=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`IS_DEPLOYED`,e],Ef=e=>{let t=tf(),n=Ri.at(t);return X({queryKey:Tf(e),queryFn:async()=>wf(n,e),enabled:!!n&&!!e})},Df=()=>{let e=zn(),{connectedWallet:t,smartAccount:n}=Q(),{network:r}=$();return{refresh:async()=>{let i=t?.address??``,a=n?.address??``;await Promise.all([e.cancelQueries({queryKey:hf(i,r.type)}),e.cancelQueries({queryKey:vf(a,i,r.type)}),e.cancelQueries({queryKey:Sf(i,r.type)}),e.cancelQueries({queryKey:ff(r.type)}),e.cancelQueries({queryKey:Nf(a,i,3,r.type)}),e.cancelQueries({queryKey:If(a,3,r.type)}),e.cancelQueries({queryKey:lf(3,r.type)})]),await Promise.all([e.refetchQueries({queryKey:hf(i,r.type)}),e.refetchQueries({queryKey:vf(a,i,r.type)}),e.refetchQueries({queryKey:Sf(i,r.type)}),e.refetchQueries({queryKey:ff(r.type)}),e.refetchQueries({queryKey:Nf(a,i,3,r.type)}),e.refetchQueries({queryKey:If(a,3,r.type)}),e.refetchQueries({queryKey:lf(3,r.type)})])}}},Of=()=>{let e=zn(),{smartAccount:t}=Q();return{refresh:async()=>{let n=t?.address??``;await Promise.all([e.cancelQueries({queryKey:Af(n)}),e.cancelQueries({queryKey:Tf(n)})]),await Promise.all([e.refetchQueries({queryKey:Af(n)}),e.refetchQueries({queryKey:Tf(n)})])}}},kf=async(e,t,n)=>{if(!n)return{address:void 0};let r=await e.contracts.load(k(t).accountFactoryAddress,ti.abi).read.getAccountAddress(n);if(!r)throw Error(`Failed to get account address of ${n}`);let i=cn.of(r[0].toString()),a=await e.accounts.getAccount(i);if(!a)throw Error(`Failed to get account detail of ${i}`);return{address:i.toString(),isDeployed:a.hasCode}},Af=e=>[`VECHAIN_KIT_SMART_ACCOUNT`,e],jf=e=>{let{network:t}=$(),n=jn();return X({queryKey:Af(e),queryFn:()=>kf(n,t.type,e),enabled:!!e&&!!t.type&&!!n})},Mf=async(e,t,n,r,i)=>{let a=await e.contracts.load(k(i).accountFactoryAddress,ti.abi).read.upgradeRequired(t,n,BigInt(r));if(!a)throw Error(`Failed to get upgrade required of contract address ${k(i).accountFactoryAddress}`);return a[0]},Nf=(e,t,n,r)=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`FACTORY`,`UPGRADE_REQUIRED`,e,t,n,r],Pf=(e,t,n)=>{let r=jn(),{network:i}=$();return X({queryKey:Nf(e,t,n,i.type),queryFn:async()=>Mf(r,e,t,n,i.type),enabled:!!r&&!!e&&!!t&&!!i.type})},Ff=async(e,t,n,r)=>{let i=await e.contracts.load(k(r).accountFactoryAddress,ti.abi).read.upgradeRequiredForAccount(t,BigInt(n));if(!i)throw Error(`Failed to get upgrade required for contract address ${t}`);return i[0]},If=(e,t,n)=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`FACTORY`,`NEEDS_UPGRADE_FOR_ACCOUNT`,e,t,n],Lf=(e,t)=>{let n=jn(),{network:r}=$();return X({queryKey:If(e,t,r.type),queryFn:async()=>Ff(n,e,t,r.type),enabled:!!n&&!!r&&!!e&&!!t&&e!==``})},Rf=ri.createInterface(),zf=({smartAccountAddress:t,targetVersion:n,onSuccess:r,onError:i})=>{let{refresh:a}=Df(),{refresh:o}=Of(),{data:s}=uf(n),c=H(async()=>{if(!t||!e(t))throw Error(`Invalid smart account address`);if(!s)throw Error(`Unable to fetch implementation address for version ${n}`);return[{to:t,value:`0x0`,data:Rf.encodeFunctionData(`upgradeToAndCall`,[s,`0x`]),comment:`Upgrade account to version ${n}`,abi:Rf.getFunction(`upgradeToAndCall`).format(`json`)}]},[t,s,n]),u=lc({privyUIOptions:{title:`Upgrade Smart Account`,description:`Upgrading your account at ${l(t)} to version ${n}`,buttonText:`Sign to continue`},onTxConfirmed:async()=>{await Promise.all([a(),o()]),r?.()},onTxFailedOrCancelled:async()=>{i?.()}});return{...u,sendTransaction:async()=>u.sendTransaction(await c())}},Bf=()=>[`VECHAIN_KIT`,`CURRENT_BLOCK`],Vf=10*D.SECOND,Hf=()=>{let e=jn();return X({queryKey:Bf(),queryFn:async()=>{let t=await e.blocks.getBestBlockExpanded();if(!t)throw Error(`Failed to fetch current block`);return t},staleTime:1e3*60,refetchInterval:Vf})},Uf=async e=>{let t=await e.blocks.getGenesisBlock();if(!t)throw Error(`Genesis block not found`);return t.id},Wf=()=>[`VECHAIN_KIT_CHAIN_ID`],Gf=()=>{let e=jn();return X({queryKey:Wf(),queryFn:()=>Uf(e),enabled:!!e})},Kf=1e3,qf=async({thor:e,order:t=`asc`,offset:n=0,limit:r=Kf,from:i=0,to:a=e.blocks.getHeadBlock()?.number,filterCriteria:o})=>{let s=await e.logs.filterEventLogs({range:{from:i,to:a,unit:`block`},options:{offset:n,limit:r},order:t,criteriaSet:o});if(!s)throw Error(`Failed to fetch events`);return s},Jf=async({nodeUrl:e,thor:t,order:n=`asc`,from:r=0,to:i,filterCriteria:a})=>{let o=[],s=0;for(;;){let c=await qf({nodeUrl:e,thor:t,filterCriteria:a,from:r,to:i??2**53-1,limit:Kf,order:n,offset:s});if(o.push(...c),c.length<Kf)return o;s+=Kf}},Yf=Qr.createInterface(),Xf=(t,n,r,i)=>{if(!t||!n||!e(t))throw Error(`Invalid receiver address or amount`);let a=[];return a.push({to:r,value:`0x0`,data:Yf.encodeFunctionData(`transfer`,[t,bi(n)]),comment:`Transfer ${n} ${i} to ${t}`,abi:Yf.getFunction(`transfer`)}),a},Zf=({fromAddress:e,receiverAddress:t,amount:n,tokenAddress:r,tokenName:i,onSuccess:a,onError:o})=>{let{refresh:s}=Gs(),c=W(()=>Xf(t,n,r,i),[t,n,r,i]),u=lc({signerAccountAddress:e,privyUIOptions:{title:`Confirm Transfer`,description:`Transfer ${n} ${i} to ${l(t)}`,buttonText:`Sign to continue`},onTxConfirmed:async()=>{s(),a?.()},onTxFailedOrCancelled:async e=>{o?.(e instanceof Error?e.message:String(e))}});return{...u,clauses:c,sendTransaction:async()=>u.sendTransaction(c)}},Qf=(t,n)=>{if(!t||!n||!e(t))throw Error(`Invalid receiver address or amount`);if(isNaN(Number(n)))throw Error(`Invalid amount`);let r=[];try{r.push({to:t,value:bi(n).toString(),data:`0x`,comment:`Transfer ${n} VET to ${t}`})}catch(e){throw console.error(`Error building clauses:`,e),Error(`Invalid amount format`)}return r},$f=({fromAddress:e,receiverAddress:t,amount:n,onSuccess:r,onError:i})=>{let{refresh:a}=Gs(),o=W(()=>Qf(t,n),[t,n]),s=lc({signerAccountAddress:e,privyUIOptions:{title:`Confirm Transfer`,description:`Transfer ${n} VET to ${l(t)}`,buttonText:`Sign to continue`},onTxConfirmed:async()=>{a(),r?.()},onTxFailedOrCancelled:async e=>{i?.(e instanceof Error?e.message:String(e))}});return{...s,clauses:o,sendTransaction:async()=>s.sendTransaction(o)}},ep=({clauseBuilder:e,refetchQueryKeys:t,invalidateCache:n=!0,onSuccess:r,onFailure:i,suggestedMaxGas:a,gasPadding:o})=>{let{account:s}=Q(),c=zn(),l=H(async()=>{n&&t?.forEach(async e=>{await c.cancelQueries({queryKey:e}),await c.refetchQueries({queryKey:e})}),r?.()},[n,r,c,t]),u=lc({signerAccountAddress:s?.address,onTxConfirmed:l,suggestedMaxGas:a,onTxFailedOrCancelled:i,gasPadding:o}),d=H(async t=>{u.sendTransaction(e(t))},[e,u]);return{...u,sendTransaction:d}},tp=10*D.SECOND,np=e=>[`VECHAIN_KIT`,`TX_RECEIPT`,e],rp=(e,t=5)=>{let n=jn();return X({queryKey:np(e),queryFn:async()=>{let r=await n.transactions.waitForTransaction(e,{timeoutMs:t*tp,intervalMs:3e3});if(!r)throw Error(`Transaction receipt not found`);return r},enabled:!!e})},ip=(e,t)=>{let n=pi({abi:t,data:e.data.toString(),topics:e.topics.map(e=>e.toString())});return{meta:e.meta,decodedData:n}},ap=({eventName:e,filterParams:t})=>[e,t?JSON.stringify(t):`all`],op=({abi:e,contractAddress:t,eventName:n,filterParams:r,mapResponse:i,nodeUrl:a})=>{let o=jn();return X({queryFn:H(async()=>{if(!o)return[];let s=o.contracts.load(t,e).getEventAbi(n),c=s.encodeFilterTopicsNoNull(r??{}),l=(await Jf({thor:o,nodeUrl:a,filterCriteria:[{criteria:{address:t,topic0:c[0]??void 0,topic1:c[1]??void 0,topic2:c[2]??void 0,topic3:c[3]??void 0,topic4:c[4]??void 0},eventAbi:s}]})).map(t=>ip(t,e));if(l.some(({decodedData:e})=>e.eventName!==n))throw Error(`Unknown event`);return l.map(e=>i({meta:e.meta,decodedData:e.decodedData}))},[o,t,e,n,r,i,a]),queryKey:W(()=>ap({eventName:n,filterParams:r}),[n,r]),enabled:!!o})};function sp({clauses:e,chainId:t,verifyingContract:n}){let r=[],i=[],a=[];return e.forEach(e=>{r.push(e.to??``),i.push(String(e.value)),typeof e.data==`object`&&`abi`in e.data?a.push(hi(e.data)):a.push(e.data||`0x`)}),{domain:{name:`Wallet`,version:`1`,chainId:t,verifyingContract:n},types:{ExecuteBatchWithAuthorization:[{name:`to`,type:`address[]`},{name:`value`,type:`uint256[]`},{name:`data`,type:`bytes[]`},{name:`validAfter`,type:`uint256`},{name:`validBefore`,type:`uint256`},{name:`nonce`,type:`bytes32`}],EIP712Domain:[{name:`name`,type:`string`},{name:`version`,type:`string`},{name:`chainId`,type:`uint256`},{name:`verifyingContract`,type:`address`}]},primaryType:`ExecuteBatchWithAuthorization`,message:{to:r,value:i,data:a,validAfter:0,validBefore:Math.floor(Date.now()/1e3)+300,nonce:en.hexlify(en.randomBytes(32))}}}function cp({clause:e,chainId:t,smartAccount:n}){return{domain:{name:`Wallet`,version:`1`,chainId:t,verifyingContract:n.address??``},types:{ExecuteWithAuthorization:[{name:`to`,type:`address`},{name:`value`,type:`uint256`},{name:`data`,type:`bytes`},{name:`validAfter`,type:`uint256`},{name:`validBefore`,type:`uint256`}],EIP712Domain:[{name:`name`,type:`string`},{name:`version`,type:`string`},{name:`chainId`,type:`uint256`},{name:`verifyingContract`,type:`address`}]},primaryType:`ExecuteWithAuthorization`,message:{validAfter:0,validBefore:Math.floor(Date.now()/1e3)+60,to:e.to,value:String(e.value),data:(typeof e.data==`object`&&`abi`in e.data?hi(e.data):e.data)||`0x`}}}function lp(){let{connection:e,connectedWallet:t}=Q(),{signTypedData:n}=Us(),{signTypedData:r}=Tn(),{network:i}=$(),{data:a}=Gf();return{connection:e,connectedWallet:t,signTypedDataWithCrossApp:n,signTypedDataPrivy:r,network:i,chainId:a}}const up=()=>{let{connection:e,connectedWallet:t,signTypedDataWithCrossApp:n,signTypedDataPrivy:r,network:i,chainId:a}=lp(),o=async e=>{let{version:t}=e;return t&&t<3?await s(e):await c(e)};async function s(o){let{clauses:s,smartAccount:c,title:l=`Sign Transaction`,description:u,buttonText:d=`Sign`}=o,f=[],p=s.map(e=>cp({clause:e,chainId:a,smartAccount:c})),m=[];for(let i=0;i<p.length;i++){let a=p[i],o=s[i];if(!o)throw Error(`Transaction clause at index ${i} is undefined`);if(e.isConnectedWithCrossApp){let e=await n({...a,address:t?.address,types:Object.fromEntries(Object.entries(a.types).map(([e,t])=>[e,[...t]]))});m.push(e);continue}let c=o.data,f=(await r(a,{uiOptions:{title:l,description:u??(s[i].comment||(typeof c==`object`&&c&&`functionName`in c?c.functionName:` `)),buttonText:d}})).signature;m.push(f)}return c.isDeployed||f.push(ln.callFunction(cn.of(k(i.type).accountFactoryAddress),sn.ofAbi(ei.abi).getFunction(`createAccount`),[t?.address??``])),p.forEach((e,t)=>{f.push(ln.callFunction(cn.of(c.address??``),sn.ofAbi(ni.abi).getFunction(`executeWithAuthorization`),[e.message.to,BigInt(e.message.value),e.message.data,BigInt(e.message.validAfter),BigInt(e.message.validBefore),m[t]]))}),f}async function c(o){let{clauses:s,smartAccount:c,title:l,description:u,buttonText:d=`Sign`}=o,f=[],p=sp({clauses:s,chainId:a,verifyingContract:c.address??``}),m;return m=e.isConnectedWithCrossApp?await n({...p,address:t?.address}):(await r(p,{uiOptions:{title:l,description:u,buttonText:d}})).signature,c.isDeployed||f.push(ln.callFunction(cn.of(k(i.type).accountFactoryAddress),sn.ofAbi(ei.abi).getFunction(`createAccount`),[t?.address??``])),f.push(ln.callFunction(cn.of(c.address??``),sn.ofAbi(ni.abi).getFunction(`executeBatchWithAuthorization`),[p.message.to,p.message.value?.map(e=>BigInt(e))??0,p.message.data,BigInt(p.message.validAfter),BigInt(p.message.validBefore),p.message.nonce,m])),f}return{buildClausesWithAuth:o}};let dp=function(e){return e.CUSTOM_TOKENS=`vechain_kit_custom_tokens`,e.ECOSYSTEM_SHORTCUTS=`vechain-kit-ecosystem-shortcuts`,e.CURRENCY=`vechain_kit_currency`,e.NODE_URL=`vechain_kit_node_url`,e.NETWORK=`vechain_kit_network`,e.GAS_TOKEN_PREFERENCES=`vechain_kit_gas_token_preferences`,e}({});const fp=(e,t)=>{let[n,r]=G(()=>{try{let n=w(e);return n?JSON.parse(n):t}catch(e){return console.error(e),t}});return U(()=>{h(e,JSON.stringify(n))},[e,n]),[n,r]},pp=`vechain-kit-storage-change`,mp=(e,t)=>{let[n,r]=G(()=>{if(typeof window>`u`)return t;try{let n=window.localStorage.getItem(e);return n?JSON.parse(n):t}catch(e){return console.error(`Error loading from localStorage:`,e),t}}),i=Zt(!1);return U(()=>{if(!(typeof window>`u`)){if(i.current){i.current=!1;return}try{window.localStorage.setItem(e,JSON.stringify(n)),window.dispatchEvent(new CustomEvent(pp,{detail:{key:e,value:n}}))}catch(e){console.error(`Error writing to localStorage:`,e)}}},[e,n]),U(()=>{if(typeof window>`u`)return;let t=t=>{if(t.key===e&&t.newValue)try{let e=JSON.parse(t.newValue);JSON.stringify(e)!==JSON.stringify(n)&&(i.current=!0,r(e))}catch(e){console.error(`Error parsing storage value:`,e)}},a=(t=>{if(t.detail.key===e)try{let t=window.localStorage.getItem(e);if(t){let e=JSON.parse(t);JSON.stringify(e)!==JSON.stringify(n)&&(i.current=!0,r(e))}}catch(e){console.error(`Error parsing storage value:`,e)}});return window.addEventListener(`storage`,t),window.addEventListener(pp,a),()=>{window.removeEventListener(`storage`,t),window.removeEventListener(pp,a)}},[e,n]),[n,r,H(()=>{if(!(typeof window>`u`))try{let i=window.localStorage.getItem(e),a=i?JSON.parse(i):t;JSON.stringify(a)!==JSON.stringify(n)&&r(a)}catch(e){console.error(`Error syncing localStorage:`,e)}},[e,t,n]),H(()=>{if(typeof window>`u`)return t;let n=window.localStorage.getItem(e);return n?JSON.parse(n):t},[e,t])]},hp=()=>{let[e,t]=fp(dp.ECOSYSTEM_SHORTCUTS,[]);return{shortcuts:e,addShortcut:n=>{e.some(e=>e.url===n.url)||t([...e,n])},removeShortcut:n=>{t(e.filter(e=>e.url!==n))},isShortcut:t=>e.some(e=>e.url===t)}},gp=async(e,t,n,r,i)=>await(await fetch(t+`estimate/clauses/`+r.toLowerCase()+`?type=smartaccount&speed=`+i,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({clauses:n,signer:e})})).json(),_p=async e=>await(await fetch(e+`deposit/account`,{method:`GET`,headers:{"Content-Type":`application/json`}})).json(),vp=async(e,t,n,r)=>await(await fetch(r+`sign/transaction/authorized/`+n.toLowerCase(),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({raw:e,origin:t,token:n.toLowerCase()})})).json(),yp=async(e,t,n,r)=>{let i=await t.gas.estimateGas(e,n?.address??``),a=Math.max(i.totalGas,0);return r?await t.transactions.buildTransactionBody(e,a,{isDelegated:r}):await t.transactions.buildTransactionBody(e,a)};function bp(e,t){return fn.of(e.body,ua.concatBytes(e.signature??new Uint8Array,un.of(t.slice(2)).bytes))}function xp(e,t){return fn.decode(un.of(e.slice(2)).bytes,t)}const Sp=()=>{let{connectedWallet:e}=Q(),{data:n}=jf(e?.address??``),{data:r}=yf(n?.address??``,e?.address??``),{preferences:i}=Cp(),a=Qr.createInterface(),{network:o}=$(),{buildClausesWithAuth:s}=up(),c=Ri.at(k(o.type).nodeUrl);return{sendTransactionUsingGenericDelegator:H(async({clauses:e,genericDelegatorUrl:o})=>{try{let l=i.gasTokenToUse,u=await gp(n?.address??``,o,e,l,`medium`),d=await _p(o),p={to:l===`VET`?d.depositAccount:f[l].address,value:l===`VET`?bi(u.transactionCost?.toString()??`0`).toString():`0x0`,data:l===`VET`?`0x`:a.encodeFunctionData(`transfer`,[d.depositAccount,bi(u.transactionCost?.toString()??`0`)]),comment:`Transfer ${u.transactionCost} ${l} to ${d.depositAccount}`,abi:l===`VET`?void 0:a.getFunction(`transfer`)},m=await s({clauses:[...e,p],smartAccount:n,version:r?.version??0}),h=await yp(m,c,t,!0),g=await fn.of(h).signAsSender(un.of(t.privateKey).bytes),_=await vp(un.of(g.encoded).toString(),t.address,l,o),v=bp(g,_.signature),y={clauses:m,simulateTransactionOptions:{caller:t.address??``,gasPayer:_.address}},b=await c.transactions.simulateTransaction(y.clauses,{...y.simulateTransactionOptions});for(let e=0;e<b.length;e++)if(b[e].reverted)throw Error(b[e].vmError);return(await c.transactions.sendTransaction(v)).id}catch(e){console.error(`Error sending transaction using generic delegator`,e)}throw Error(`Failed to send transaction using generic delegator, no gas tokens have sufficient balance or are enabled in Gas Token Preferences`)},[i,n,r,s,c,t])}},Cp=()=>{let[e,t]=mp(dp.GAS_TOKEN_PREFERENCES,ne);return{preferences:e,supportedTokens:f,updatePreferences:H(e=>{t(t=>({...t,...e}))},[t]),reorderTokenPriority:H(e=>{t(t=>{let n=e.filter(e=>t.availableGasTokens.includes(e)&&!t.excludedTokens.includes(e));return{...t,tokenPriority:e,availableGasTokens:n,gasTokenToUse:n[0]??t.gasTokenToUse}})},[t]),toggleTokenExclusion:H(e=>{t(t=>{let n=t.excludedTokens.includes(e),r=n?t.excludedTokens.filter(t=>t!==e):[...t.excludedTokens,e],i=t.tokenPriority.indexOf(e),a=n?[...t.availableGasTokens.slice(0,i),e,...t.availableGasTokens.slice(i)]:t.availableGasTokens.filter(t=>t!==e);return{...t,excludedTokens:r,availableGasTokens:a,gasTokenToUse:a[0]??t.gasTokenToUse}})},[t])}},wp=({clauses:e,enabled:t=!0,tokens:n,sendingAmount:r,sendingTokenSymbol:i})=>{let{connectedWallet:a,account:o}=Q(),{data:s}=jf(a?.address??``),{feeDelegation:c}=$(),{balances:l}=ns(o?.address??``),{updatePreferences:u}=Cp();return X({queryKey:[`gas-estimation`,JSON.stringify(e),JSON.stringify(n),r,i],queryFn:async()=>{let t=null;for(let a of n)try{let n=await gp(s?.address??``,c?.genericDelegatorUrl??``,e,a,`medium`),o=n.transactionCost,d=Number(l.find(e=>e.symbol===a)?.balance||0),f=o+(r&&i&&a===i?Number(r):0);if(d>=f)return u({gasTokenToUse:a}),{...n,usedToken:a};t=Error(`Insufficient ${a} balance: has ${d}, needs ${f}`)}catch(e){t=e}throw t||Error(`All gas tokens failed estimation or have insufficient balance`)},enabled:t&&e.length>0&&!!s?.address&&!!c?.genericDelegatorUrl&&n.length>0&&l.length>0,staleTime:30*1e3,gcTime:300*1e3,refetchOnWindowFocus:!1,refetchOnReconnect:!1,refetchOnMount:!1,retry:!1,retryDelay:1e3})},Tp=({clauses:e,tokens:t,enabled:n=!0})=>{let{connectedWallet:r}=Q(),{data:i}=jf(r?.address??``),{feeDelegation:a}=$();return X({queryKey:[`gas-estimation-all-tokens`,JSON.stringify(e),JSON.stringify(t)],queryFn:async()=>{let n={};return await Promise.all(t.map(async t=>{try{n[t]={cost:(await gp(i?.address??``,a?.genericDelegatorUrl??``,e,t,`medium`)).transactionCost||0,loading:!1}}catch(e){n[t]={cost:0,loading:!1,error:e instanceof Error?e.message:`Unknown error`}}})),n},enabled:n&&e.length>0&&!!i?.address&&!!a?.genericDelegatorUrl&&t.length>0,staleTime:30*1e3,gcTime:300*1e3,refetchOnWindowFocus:!1,refetchOnReconnect:!1,refetchOnMount:!1})},Ep=({label:e,address:t,domain:n,imageSrc:r,imageAlt:i=`Account`,hideAddress:a=!1,balance:o,tokenAddress:s})=>{let{t:c}=Y(),u=B(`colors`,`vechain-kit-text-primary`),d=B(`colors`,`vechain-kit-text-secondary`),f=B(`colors`,`vechain-kit-card`),{isLoading:p}=fs({address:t}),{tokens:m,isLoading:h}=ds({address:t}),g=W(()=>s?m.find(e=>e.address===s):null,[m,s]),_=W(()=>o===void 0?g?Number(g.balance):0:o,[o,g]),v=g?.symbol||``;return p||h?J(A,{w:`full`,p:2,borderRadius:`lg`,bg:f,children:[q(R,{fontSize:`sm`,fontWeight:`bold`,mb:2,color:u,children:e}),J(M,{minH:`50px`,justify:`space-between`,children:[J(M,{children:[q(kt,{boxSize:`40px`,borderRadius:`xl`}),J(z,{align:`start`,spacing:0,children:[q(kt,{height:`16px`,width:`120px`,borderRadius:`md`}),!a&&q(kt,{mt:2,height:`12px`,width:`100px`,borderRadius:`md`})]})]}),J(z,{justify:`flex-start`,align:`flex-end`,spacing:0,mr:2,children:[q(R,{fontSize:`sm`,fontWeight:`medium`,color:u,children:c(`Balance`)}),q(kt,{height:`12px`,width:`80px`,borderRadius:`md`})]})]})]}):J(A,{w:`full`,p:2,borderRadius:`lg`,bg:f,wordBreak:`break-word`,children:[q(R,{fontSize:`sm`,fontWeight:`bold`,mb:2,color:u,children:e}),J(M,{minH:`50px`,justify:`space-between`,children:[J(M,{children:[q(ut,{src:r,alt:i,boxSize:`40px`,borderRadius:`xl`,objectFit:`cover`}),q(z,{align:`start`,spacing:0,children:n?J(K,{children:[q(R,{fontWeight:`medium`,fontSize:`sm`,color:u,"data-testid":`${e.toLowerCase()}-domain`,children:n}),!a&&q(R,{fontSize:`xs`,color:d,"data-testid":`${e.toLowerCase()}-address`,children:l(t,6,4)})]}):q(R,{fontWeight:`medium`,fontSize:`sm`,color:u,"data-testid":`${e.toLowerCase()}-address`,children:l(t,6,4)})})]}),J(z,{justify:`flex-start`,align:`flex-end`,spacing:0,mr:2,children:[q(R,{fontSize:`sm`,fontWeight:`medium`,color:u,children:c(`Balance`)}),J(R,{fontSize:`xs`,color:d,children:[_.toLocaleString(void 0,{maximumFractionDigits:2}),v&&` ${v}`]})]})]})]})},Dp=({onClick:e,...t})=>q(lt,{"aria-label":`FAQ`,icon:q(N,{as:sr,fontSize:`17px`}),size:`sm`,variant:`ghost`,position:`absolute`,borderRadius:`50%`,left:`10px`,top:`10px`,onClick:e,...t}),Op=({children:e,...t})=>(rf(),q(z,{...t,children:e})),kp=({wallet:e,props:t})=>{let n=Zt(e?.image);return U(()=>{e?.image&&!e.isLoadingMetadata&&(n.current=e.image)},[e?.image,e?.isLoadingMetadata]),!t?.src&&!e?.image&&!n.current||e?.isLoadingMetadata?q(kt,{rounded:`full`,width:t?.width,height:t?.height}):q(ut,{src:t?.src||e?.image||n.current,alt:t?.alt||e?.domain,objectFit:`cover`,rounded:`full`,...t})},Ap=({transactionError:e,isSubmitting:t,isTxWaitingConfirmation:n,onConfirm:r,onRetry:i,transactionPendingText:a,txReceipt:o,isSubmitForm:s=!1,buttonText:c,isDisabled:l=!1,style:u,onError:d,gasEstimationError:f,hasEnoughGasBalance:p=!0,isLoadingGasEstimation:m=!1,showGasEstimationError:h=!1,context:g=`transaction`})=>{let{t:_}=Y(),{darkMode:v}=$(),{network:y}=$(),b=W(()=>e?e.reason||_(`Something went wrong. Please try again.`):null,[e,_]);U(()=>{b&&d?.(b)},[b,d]);let x=W(()=>{if(u?.accentColor)return`${u.accentColor} !important`},[u?.accentColor]),S=W(()=>{if(!h||m||!(f||p))return null;if(!p&&!f)return{message:_(`You don't have any gas tokens enabled. Please enable at least one gas token in Gas Token Preferences.`)};if(f){let e=``;switch(g){case`send`:e=_(`Insufficient balance to complete this transfer and cover gas fees.`);break;case`customization`:e=_(`Insufficient balance to update your profile and cover gas fees.`);break;case`domain`:e=_(`Insufficient balance to claim this domain and cover gas fees.`);break;default:e=_(`Insufficient balance to complete this transaction and cover gas fees.`)}return{message:e}}return null},[f,p,m,h,g,_]);return J(z,{width:`full`,spacing:4,children:[b&&q(A,{p:3,borderRadius:`md`,bg:v?`rgba(218, 90, 90, 0.1)`:`rgba(218, 90, 90, 0.05)`,borderWidth:`1px`,borderColor:v?`rgba(218, 90, 90, 0.3)`:`rgba(218, 90, 90, 0.2)`,w:`full`,children:q(R,{color:`#da5a5a`,fontSize:`sm`,fontWeight:`medium`,"data-testid":`tx-send-error-msg`,children:b})}),S&&!b&&q(A,{p:3,borderRadius:`md`,bg:v?`rgba(218, 90, 90, 0.1)`:`rgba(218, 90, 90, 0.05)`,borderWidth:`1px`,borderColor:v?`rgba(218, 90, 90, 0.3)`:`rgba(218, 90, 90, 0.2)`,w:`full`,children:q(R,{color:`#da5a5a`,fontSize:`sm`,fontWeight:`medium`,"data-testid":`gas-estimation-error`,children:S.message})}),q(j,{px:4,variant:b?`vechainKitSecondary`:`vechainKitPrimary`,bg:x,onClick:()=>b&&i?i():r(),type:s?`submit`:`button`,isLoading:t,isDisabled:l,loadingText:n?_(`Waiting wallet confirmation...`):a,"data-testid":`confirm-button`,children:b?_(`Retry`):c||_(`Confirm`)}),b&&o?.meta.txID&&q(ht,{isExternal:!0,fontSize:`sm`,color:v?`whiteAlpha.600`:`blackAlpha.600`,textAlign:`center`,width:`full`,href:`${k(y.type).explorerUrl}/${o?.meta.txID}`,target:`_blank`,rel:`noopener noreferrer`,children:_(`View transaction on the explorer`)})]})},jp=({onClick:e,hasUnreadNotifications:t,...n})=>q(lt,{"aria-label":`Notifications`,size:`sm`,variant:`ghost`,position:`absolute`,borderRadius:`50%`,left:`10px`,top:`10px`,onClick:e,icon:J(A,{position:`relative`,children:[q(Xn,{fontSize:`20px`}),t&&q(A,{position:`absolute`,top:`-1px`,right:`-1px`,minWidth:`8px`,height:`8px`,bg:`red.500`,borderRadius:`full`})]}),...n}),Mp=({isOpen:e,onClose:t,selectedToken:n,onTokenSelect:r,availableTokens:i,tokenEstimations:a,walletAddress:o})=>{let{t:c}=Y(),{balances:l}=ns(o),[u,d]=V.useState(n),[p,m]=V.useState(!1),h=B(`colors`,`vechain-kit-text-primary`),g=B(`colors`,`vechain-kit-text-secondary`),_=B(`colors`,`vechain-kit-text-tertiary`),y=B(`colors`,`vechain-kit-error`),b=e=>e?_:`transparent`,x=e=>e?h:`transparent`;V.useEffect(()=>{e&&(d(n),m(!1))},[e,n]);let S=()=>{r(u,p),t()},C=e=>{let t=l.find(t=>t.symbol===e);return t?Number(t.balance).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2}):`0.00`},w=e=>{let t=l.find(t=>t.symbol===e),n=a[e];return!t||!n?!1:Number(t.balance)<n.cost};return J($a,{isOpen:e,onClose:t,size:`sm`,children:[J(L,{children:[q(R,{fontSize:`lg`,fontWeight:`semibold`,color:h,children:c(`Fee token`)}),q(R,{fontSize:`sm`,fontWeight:`normal`,color:g,mt:1,children:c(`Select the token to pay the fee with`)})]}),q(P,{children:J(z,{spacing:2,align:`stretch`,children:[i.map(e=>{let t=f[e],n=u===e,r=a[e]||{cost:0,loading:!0},i=w(e);return q(A,{cursor:i?`not-allowed`:`pointer`,bg:b(n),border:`1px`,borderColor:x(n),borderRadius:`md`,p:3,transition:`all 0.2s ease`,_hover:{backgroundColor:i?b(n):g&&`#ffffff12`,borderColor:i?x(n):g},opacity:i?.5:1,onClick:()=>!i&&d(e),children:J(M,{spacing:3,justify:`space-between`,children:[J(M,{spacing:3,flex:1,children:[V.cloneElement(s[e],{boxSize:`36px`,borderRadius:`full`}),J(z,{align:`start`,spacing:0,children:[q(R,{fontWeight:`medium`,color:h,children:t.symbol}),J(R,{fontSize:`xs`,color:g,children:[c(`Balance`),`:`,` `,C(e)]}),i&&q(R,{fontSize:`xs`,color:y,children:c(`Insufficient balance`)})]})]}),q(z,{align:`end`,spacing:0,children:r.loading?q(kt,{height:`16px`,width:`60px`}):J(K,{children:[q(R,{fontSize:`sm`,fontWeight:`semibold`,color:h,children:v(r.cost,2)}),q(R,{fontSize:`xs`,color:g,children:t.symbol})]})})]})},e)}),u!==n&&J(it,{display:`flex`,alignItems:`center`,justifyContent:`space-between`,children:[q(at,{htmlFor:`remember-choice`,mb:`0`,fontSize:`sm`,color:h,children:c(`Use this token for future transactions`)}),q(Mt,{id:`remember-choice`,isChecked:p,onChange:e=>m(e.target.checked),color:h})]})]})}),q(I,{children:J(z,{spacing:3,w:`full`,children:[q(j,{variant:`vechainKitPrimary`,onClick:S,isDisabled:w(u),children:c(`Apply`)}),q(j,{variant:`ghost`,width:`full`,onClick:t,children:c(`Cancel`)})]})})]})},Np=({estimation:e,isLoading:t,isLoadingTransaction:n,onTokenChange:r,clauses:i=[],userSelectedToken:a})=>{let{t:o}=Y(),{feeDelegation:c}=$(),{connection:l,account:u}=Q(),{preferences:d,reorderTokenPriority:p}=Cp(),{isOpen:m,onOpen:h,onClose:g}=Gt(),_=B(`colors`,`vechain-kit-text-primary`),y=B(`colors`,`vechain-kit-text-secondary`),[b,x]=G(()=>{let e={};return d.availableGasTokens.forEach(t=>{e[t]={cost:0,loading:!0}}),e}),{data:S,isLoading:C}=Tp({clauses:i,tokens:d.availableGasTokens,enabled:i.length>0});U(()=>{!C&&S&&x(S)},[S,C]),U(()=>{e&&x(t=>({...t,[e.usedToken]:{cost:e.transactionCost||0,loading:!1}}))},[e]),U(()=>{C&&x(d.availableGasTokens.reduce((e,t)=>(e[t]={cost:0,loading:!0},e),{}))},[C,d.availableGasTokens]);let w=H((t,n)=>{n&&p([t,...d.tokenPriority.filter(e=>e!==t)]),r&&t!==e?.usedToken&&r(t)},[e,r,p,d.tokenPriority]);if(c?.delegatorUrl||l.isConnectedWithDappKit||d.availableGasTokens.length===0)return null;let{balances:ee}=ns(u?.address??``),T=e=>{let t=ee.find(t=>t.symbol===e),n=b[e];return!t||!n||n.loading?!0:Number(t.balance)<n.cost},E=e?.usedToken,D=d.availableGasTokens,te;E?te=E:a&&D.includes(a)?te=a:(te=D.find(e=>b[e]&&!b[e].loading&&!T(e)),te||=D.find(e=>b[e]&&!b[e].loading),te||=D[0]);let ne=te?b[te]:void 0,re=E&&e?.transactionCost?e.transactionCost:ne?.cost||0,O=te?f[te]:void 0;return J(K,{children:[q(nt,{mt:3}),J(M,{mt:3,w:`full`,justifyContent:`start`,alignItems:`center`,children:[J(z,{align:`start`,spacing:0,w:`full`,children:[q(R,{fontSize:`sm`,fontWeight:`light`,textAlign:`left`,w:`full`,color:y,children:o(`Fee`)}),q(M,{align:`start`,justifyContent:`space-between`,spacing:0,w:`full`,children:q(M,{justifyContent:`flex-start`,w:`full`,children:t||!E&&(!ne||ne.loading)||!O?J(K,{children:[q(kt,{height:`16px`,width:`120px`,borderRadius:`md`}),q(kt,{height:`16px`,width:`60px`,borderRadius:`md`})]}):J(K,{children:[J(R,{color:_,fontSize:`sm`,fontWeight:`semibold`,children:[v(re,2),` `,O.symbol]}),J(R,{color:y,fontSize:`xs`,children:[`≈`,` $`,(re*.01).toFixed(2)]})]})})})]}),J(j,{onClick:h,variant:`outline`,size:`sm`,borderRadius:`full`,px:6,disabled:n,color:y,borderColor:y,_hover:{bg:y},leftIcon:V.cloneElement(s[te||d.availableGasTokens[0]],{boxSize:`20px`,borderRadius:`full`}),children:[q(R,{fontSize:`sm`,fontWeight:`semibold`,children:te||d.availableGasTokens[0]}),q(N,{as:tr,boxSize:5,color:y})]})]}),q(Mp,{isOpen:m,onClose:g,selectedToken:te||d.availableGasTokens[0],onTokenSelect:w,availableTokens:d.availableGasTokens,tokenEstimations:b,walletAddress:u?.address??``})]})},Pp=({isOpen:e,onClose:t,steps:n,activeStep:r,goToPrevious:i,setActiveStep:a,disableBackButton:o,disableCloseButton:s,closeOnOverlayClick:c=!0,isCloseable:l=!0})=>{let u=()=>{a(0),t()},[d]=Kt(`(min-width: 1060px)`),f=n[r],p=r===0,m=!p&&!o||f?.title||d&&!s;return f?q($a,{closeOnOverlayClick:c,isOpen:e,onClose:u,isCloseable:l,blockScrollOnMount:!0,children:q(Ge,{p:0,bg:`none`,children:J(Ke,{p:0,children:[m?J(Z,{children:[f?.title?q(L,{children:f.title}):null,!p&&!o?q(Ja,{onClick:i}):null,d&&!s?q(F,{onClick:t}):null]}):null,f?.description?q(R,{fontSize:{base:14,md:16},fontWeight:400,px:4,children:f?.description}):null,q(Vn.div,{initial:`hidden`,animate:`visible`,style:{width:`100%`},children:f.content},f.key)]})})}):null},Fp=({document:e,register:t,isText:n=!1})=>{let{t:r}=Y(),{darkMode:i}=$(),a=e.displayName??r(`Policy`),o=i?`whiteAlpha.400`:`blackAlpha.400`,s=i?`blue.300`:`blue.500`,c=i?`blue.200`:`blue.700`,l=(()=>{if(!e.documentType)return a;switch(e.documentType){case`terms`:return e.displayName||`Terms of Service`;case`privacy`:return e.displayName||`Privacy Policy`;case`cookies`:return e.displayName||`Cookie Policy`;default:return e.displayName||`Legal Document`}})();return n?J(ht,{href:e.url,isExternal:!0,color:`blue.500`,textDecoration:`underline`,_hover:{color:`blue.300`,textDecoration:`underline`},fontWeight:`medium`,display:`contents`,alignItems:`center`,children:[q(dt,{...t(e.id,{required:e.required}),type:`checkbox`,hidden:!0}),l,q(N,{as:fr,ml:1,boxSize:3})]},e.id):q(M,{width:`full`,borderRadius:`md`,transition:`all 0.2s`,children:J(M,{align:`flex-start`,spacing:3,width:`full`,children:[q(Ze,{mt:`2px`,size:`md`,colorScheme:`blue`,borderColor:o,...t(e.id,{required:e.required}),"data-testid":`tnc-checkbox`}),J(R,{fontSize:`xs`,children:[r(`I have read and agree to `),J(ht,{href:e.url,isExternal:!0,color:s,textDecoration:`underline`,_hover:{color:c,textDecoration:`underline`},fontWeight:`medium`,display:`contents`,alignItems:`center`,children:[l,q(N,{as:fr,ml:1})]}),e.required&&q(R,{as:`span`,color:`red.500`,fontWeight:`bold`,children:`*`})]})]})},e.id)},Ip=({onAgree:e,onReject:t,onlyOptionalDocuments:n=!1})=>{let{t:r}=Y(),{darkMode:i}=$(),{documentsNotAgreed:a}=Wp(),{requiredDocuments:o,optionalDocuments:s}=W(()=>a.reduce((e,t)=>(t.required?e.requiredDocuments.push(t):e.optionalDocuments.push(t),e),{requiredDocuments:[],optionalDocuments:[]}),[a]),{handleSubmit:c,register:l,formState:{isValid:u},watch:d}=Hi({defaultValues:W(()=>a.reduce((e,t)=>(e[t.id]=t.required,e),{}),[a])}),f=d(),p=W(()=>a.filter(e=>f[e.id]),[a,f]),m=a?.length===p.length,h=H(t=>{let n=new Set(Object.entries(t).filter(([e,t])=>t).map(([e])=>e));return e(a.filter(e=>n.has(e.id)))},[a,e]),g=i?`#3a3a3a`:`#eaeaea`,_=i?`#2a2a2a`:`#f5f5f5`,v=i?`gray.300`:`gray.600`,y=i?`0 2px 8px rgba(0, 0, 0, 0.2)`:`0 2px 8px rgba(0, 0, 0, 0.05)`,b=o.length>0,x=s.length>0,S=W(()=>{let e=s.filter(e=>f[e.id]).length;return r(m?`Accept all`:n&&e===0?`Ignore and continue`:b&&!x||b&&e===0?`Accept`:`Accept selected`)},[n,m,s,f]),C=e=>e===o.length-2&&o.length>1?r(` and `):`, `;return q(jt,{width:`full`,children:J(`form`,{onSubmit:c(h),children:[q(Z,{children:q(L,{children:r(`Terms and Policies`)})}),q(P,{children:J(z,{align:`stretch`,spacing:5,width:`full`,children:[b&&J(R,{as:`span`,fontSize:`sm`,children:[r(`By continuing, you agree to`),` `,o.map((e,t)=>J(Jt,{children:[q(Fp,{document:e,register:l,isText:!0},e.id),t<o.length-1?C(t):null]},e.id)),`.`,` `,r(`Please take a moment to review all the policies, with acceptance being mandatory to continue.`)]}),n&&q(R,{fontSize:`sm`,color:v,mb:3,children:q(gn,{i18nKey:`<bold>Your privacy matters.</bold> You’re in control, accept to enable optional features like cookies that help us enhance your experience.`,components:{bold:q(R,{as:`span`,fontWeight:`semibold`,color:v})}})}),x&&J(jt,{p:4,borderRadius:`xl`,bg:_,borderWidth:`1px`,borderColor:g,boxShadow:y,spacing:5,children:[q(R,{fontSize:`md`,fontWeight:`bold`,color:v,children:r(`Optional`)}),q(z,{align:`stretch`,spacing:4,children:s.map(e=>q(Fp,{document:e,register:l},e.id))})]})]})}),q(I,{children:J(z,{width:`full`,spacing:3,children:[q(j,{variant:`vechainKitPrimary`,width:`full`,type:`submit`,isDisabled:!u,"data-testid":`accept-tnc-button`,children:S}),!n&&q(j,{variant:`ghost`,width:`full`,onClick:t,"data-testid":`reject-tnc-button`,colorScheme:`red`,children:r(`Reject and logout`)})]})})]})})};var Lp=function(e){return e.REVIEW_DOCUMENTS=`REVIEW_DOCUMENTS`,e.REJECT_DOCUMENTS=`REJECT_DOCUMENTS`,e}(Lp||{});const Rp=({isOpen:e,onAgree:t,handleLogout:n,onlyOptionalDocuments:r})=>{let{t:i}=Y(),{activeStep:a,goToPrevious:o,setActiveStep:s,goToNext:c}=qt({index:0,count:Object.keys(Lp).length}),l=()=>{s(0)},u=()=>{c()},d=()=>{n(),l()};return q(Pp,{isOpen:e,onClose:()=>{},goToPrevious:o,goToNext:c,setActiveStep:s,steps:W(()=>[{key:Lp.REVIEW_DOCUMENTS,content:q(Ip,{onAgree:t,onReject:u,onlyOptionalDocuments:r})},{key:Lp.REJECT_DOCUMENTS,content:q(nl,{onDisconnect:d,onBack:o,onClose:o,text:i(`Are you sure you want to reject the policies and disconnect?`),showCloseButton:!1})}],[Ip,nl,t,d]),disableCloseButton:!0,disableBackButton:!0,isCloseable:!1,closeOnOverlayClick:!1,activeStep:a})},zp=e=>`${e.documentType}-${e.url.replace(/[^\w-]+/g,`-`)}-v${e.version}`,Bp=e=>e.map(e=>({...e,id:zp(e)})),Vp=e=>e.filter(e=>!e.required),Hp=(e,t)=>{let n=Date.now();return e.map(e=>({...e,walletAddress:t,timestamp:n}))},Up=Yt(void 0),Wp=()=>Xt(Up)||{hasAgreedToRequiredDocuments:!0,agreements:[],walletAddress:void 0,documents:[],documentsNotAgreed:[]},Gp=({children:e})=>{let{connection:t,account:n,disconnect:r}=Q(),{darkMode:i,legalDocuments:a,theme:s}=$(),[c,l]=mp(`vechain-kit-legal-documents`,[]),[u,d]=mp(`vechain-kit-legal-documents-optional-reject`,[]),[f,p]=G(!1),h=H((e,t)=>u.some(n=>o(n.walletAddress,t)&&n.id===e.id),[u]),[g,_]=W(()=>{let e=Bp([{items:a?.cookiePolicy||[],type:se.COOKIES,source:m.APPLICATION},{items:a?.privacyPolicy||[],type:se.PRIVACY,source:m.APPLICATION},{items:a?.termsAndConditions||[],type:se.TERMS,source:m.APPLICATION}].flatMap(e=>e.items.map(t=>({...t,documentType:e.type,documentSource:e.source}))));return[e,e.filter(e=>e.required)]},[a]),v=W(()=>n?.address?g.filter(e=>c.some(t=>o(t.walletAddress,n.address)&&t.id===e.id)?!1:!u.some(t=>o(t.walletAddress,n.address)&&t.id===e.id)):[],[g,n?.address,c,u]),y=W(()=>!_.length||!n?.address?!0:_.every(e=>c.some(t=>o(t.walletAddress,n.address)&&t.id===e.id)),[_,c,n?.address]),b=W(()=>{if(!n?.address||!v?.length)return!1;let e=Vp(v);return e.length===0?!1:e.some(e=>!h(e,n.address))},[v,n?.address,Vp,h]),x=W(()=>y&&b,[y,b]);W(()=>{let e=new Set(c.map(e=>e.id));return g.some(t=>e.has(t.id))},[g,c]),U(()=>{t.isConnected&&n?.address?p(!y||b):p(!1)},[t.isConnected,n?.address,y,b]);let S=H((e,t)=>{let n=Array.isArray(e)?e:[e];if(!n.length)return;let r=Hp(n,t);l([...c.filter(e=>!o(e.walletAddress,t)||!n.some(t=>t.id===e.id)),...r])},[c,Hp]),C=H(e=>{if(!n?.address)return;let t=Vp(v);if(t.length===0)return;let r=e.map(e=>e.id),i=t.filter(e=>!r.includes(e.id));if(!i?.length)return;let a=Hp(i,n.address);d(e=>[...e,...a])},[n?.address,v,Vp,Hp]),w=H(e=>{if(!n?.address)return;let t=Array.isArray(e)?e:[e];t.length>0&&S(t,n.address),C(t),p(!1)},[n?.address,S,C]);return J(Up.Provider,{value:{hasAgreedToRequiredDocuments:y,agreements:c,walletAddress:n?.address,documents:g,documentsNotAgreed:v},children:[e,q(td,{darkMode:i,theme:s,children:q(Rp,{isOpen:f,onAgree:w,handleLogout:x?()=>{}:()=>{r(),p(!1)},onlyOptionalDocuments:x})})]})},Kp=Yt(null),qp=({children:e,nodeUrl:n,delegatorUrl:r=_(),delegateAllTransactions:i,genericDelegator:a})=>{let{signTypedData:o,exportWallet:s,signMessage:c}=Tn(),{signTypedData:l,signMessage:u}=Us(),{connection:d,connectedWallet:f}=Q(),{network:p}=$(),{data:m}=jf(f?.address??``),{data:h}=yf(m?.address??``,f?.address??``),{data:g}=Cf(f?.address??``),{buildClausesWithAuth:v}=up(),{sendTransactionUsingGenericDelegator:y}=Sp(),b=Ri.at(n),x=async(e,i,a)=>{if(!m?.address)throw Error(`Smart account address is not set`);let o=new zi(b,i??new Ii([{privateKey:Buffer.from(t.privateKey.slice(2),`hex`),address:t.address}],{gasPayer:{gasPayerServiceUrl:r}}),!0),s=a??await o.getSigner(t.address),c=Bi.transactionBodyToTransactionRequestInput(e,t.address),l=await s.signTransaction(c),{id:u}=await fetch(`${n}/transactions`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({raw:l})}).then(e=>e.json());return u},S=H(async({txClauses:e=[],title:n=`Sign Transaction`,description:i,buttonText:o=`Sign`})=>{if(!m||m&&!m.address||!f||f&&!f.address)throw Error(`Address or embedded wallet is missing`);if(a)return await y({clauses:e,genericDelegatorUrl:r??``});let s=await v({clauses:e,smartAccount:m,version:g?1:h?.version??3,title:n,description:i,buttonText:o}),c={clauses:s,simulateTransactionOptions:{caller:t.address}},l=await b.transactions.simulateTransaction(c.clauses,{...c.simulateTransactionOptions});for(let e=0;e<l.length;e++)if(l[e].reverted)return console.error(`simulatedTx1[i].vmError: ${l[e].vmError}`),l[e].vmError;return await x(await yp(s,b,t,!0))},[y,a,m,f,r,v,g,h,b]);return q(Kp.Provider,{value:{accountFactory:k(p.type).accountFactoryAddress,sendTransaction:S,signMessage:async e=>d.isConnectedWithCrossApp?await u(e):(await c({message:e})).signature,signTypedData:async e=>d.isConnectedWithCrossApp?await l({...e,address:f?.address,types:Object.fromEntries(Object.entries(e.types).map(([e,t])=>[e,[...t]]))}):(await o(e)).signature,exportWallet:s,delegateAllTransactions:i},children:e})},Jp=()=>{let e=Xt(Kp);if(!e)throw Error(`usePrivyWalletProvider must be used within a PrivyWalletProvider`);return e},Yp=Yt(null),$=()=>{let e=Xt(Yp);if(!e)throw Error(`useVeChainKitConfig must be used within VeChainKit`);return e},Xp=e=>{let t=[],n={...e};if(n.dappKit||={allowedWallets:[`veworld`]},(n.privy!==void 0||n.loginMethods?.some(e=>e.method===`vechain`||e.method===`ecosystem`))&&(n.feeDelegation?!n.feeDelegation.delegatorUrl&&!n.feeDelegation.genericDelegatorUrl&&(n.feeDelegation.genericDelegatorUrl=_()):n.feeDelegation={genericDelegatorUrl:_()}),!n.network||!n.network.type)n.network={type:`main`};else{let e=n.network.type;[`main`,`test`,`solo`].includes(e)||t.push(`network.type must be either "main", "test" or "solo"`)}if(n.loginMethods||=[{method:`vechain`,gridColumn:4},{method:`ecosystem`,gridColumn:4},{method:`dappkit`,gridColumn:4}],n.loginMethods&&!n.privy){let e=n.loginMethods.filter(e=>[`email`,`google`,`passkey`,`more`].includes(e.method));e.length>0&&t.push(`Login methods ${e.map(e=>`"${e.method}"`).join(`, `)} require Privy configuration. Please either remove these methods or configure the privy prop.`)}if(n?.legalDocuments&&(n.legalDocuments.termsAndConditions&&n.legalDocuments.termsAndConditions.forEach(e=>{C(e.url)||t.push(`legalDocuments.termsAndConditions.url is invalid: ${e.url}`)}),n.legalDocuments.privacyPolicy&&n.legalDocuments.privacyPolicy.forEach(e=>{C(e.url)||t.push(`legalDocuments.privacyPolicy.url is invalid: ${e.url}`)}),n.legalDocuments.cookiePolicy&&n.legalDocuments.cookiePolicy.forEach(e=>{C(e.url)||t.push(`legalDocuments.cookiePolicy.url is invalid: ${e.url}`)})),t.length>0)throw Error(`VeChainKit Configuration Error:
193
193
  `+t.join(`
194
- `));return n},$p=e=>{let{children:t,privy:n,feeDelegation:r,dappKit:i,loginModalUI:o,loginMethods:s,darkMode:c=!1,i18n:l,language:u=`en`,network:d,allowCustomTokens:f,legalDocuments:p,defaultCurrency:m=`usd`,theme:g}=Qp(e),_=s,v=W(()=>_?.find(e=>e.method===`ecosystem`)?.allowedApps??a.map(e=>e.id),[_]),y,b;n?(y=n.appId,b=n.clientId):(y=`clzdb5k0b02b9qvzjm6jpknsc`,b=`client-WY2oy87y6KNrHFnpXuwVsiFMkwPZKTYpExtjvUQuMbCMF`),U(()=>{wa(Ca),u&&Ca.changeLanguage(u),l&&Object.keys(l).forEach(e=>{Ca.addResourceBundle(e,`translation`,l[e],!0,!0)})},[u,l]),U(()=>{h(oe.NETWORK,d.type)},[d]);let x=W(()=>Ra(La(c),za(g,c)),[g,c]),S=W(()=>Va(x,c),[x,c]),C=W(()=>Ha(x,c),[x,c]);return U(()=>{let e=Ba(x.colors.background.card,c),t=Ba(x.colors.background.cardElevated,c),n=c?`transparent`:`#ffffff`,r=c?`transparent`:`#ffffff`,i=c?`transparent`:`#ffffff`;Wa(C,x.effects.backdropFilter.modal,e,t,n,r,i,x.colors.border.default)},[C,x.effects.backdropFilter.modal,x.colors.background.card,x.colors.background.cardElevated,x.colors.border.default,c]),U(()=>{Ua()},[]),J(qa,{children:[q(Dn,{initialIsOpen:!1}),q(Hs,{privyEcosystemAppIDS:v,children:q(Zp.Provider,{value:{privy:n,privyEcosystemAppIDS:v,feeDelegation:r,dappKit:i,loginModalUI:o,loginMethods:_,darkMode:c,i18n:l,language:u,network:{...d,nodeUrl:d.nodeUrl??k(d?.type)?.nodeUrl},allowCustomTokens:f,legalDocuments:p,defaultCurrency:m,theme:g},children:q(vn,{appId:y,clientId:b,config:{loginMethodsAndOrder:{primary:n?.loginMethods.slice(0,4)??[],overflow:n?.loginMethods.slice(4)??[]},externalWallets:{walletConnect:{enabled:!1}},appearance:{theme:c?`dark`:`light`,accentColor:n?.appearance.accentColor??(x.buttons.primaryButton.bg?.startsWith(`#`)?x.buttons.primaryButton.bg:c?`#3182CE`:`#2B6CB0`),loginMessage:n?.appearance.loginMessage,logo:n?.appearance.logo},embeddedWallets:{createOnLogin:n?.embeddedWallets?.createOnLogin??`all-users`},passkeys:{shouldUnlinkOnUnenrollMfa:!1}},children:q(On,{node:d.nodeUrl??k(d.type).nodeUrl,v2Api:{enabled:i.v2Api?.enabled??!0,external:i.v2Api?.external??!1},i18n:l,language:u,logLevel:i.logLevel,modalParent:i.modalParent,onSourceClick:i.onSourceClick,usePersistence:i.usePersistence??!0,allowedWallets:i.allowedWallets,walletConnectOptions:i.walletConnectOptions,themeMode:c?`DARK`:`LIGHT`,themeVariables:i.themeVariables?{...S,...i.themeVariables}:S,children:q(Yp,{nodeUrl:d.nodeUrl??k(d.type).nodeUrl,delegatorUrl:r?.delegatorUrl??r?.genericDelegatorUrl,delegateAllTransactions:r?.delegateAllTransactions??!1,genericDelegator:!!(!r?.delegatorUrl&&r?.genericDelegatorUrl),children:q(od,{children:q(qp,{children:t})})})})})})})]})};export{Yc as AccessAndSecurityContent,wd as AccessAndSecurityModalProvider,jp as AccountAvatar,Md as AccountCustomizationModalProvider,Ic as AccountDetailsButton,Fc as AccountMainContent,mu as AccountModal,ud as AccountModalProvider,Rc as AccountSelector,Lc as ActionButton,Ya as AddressDisplay,Op as AddressDisplayCard,Ml as AppearanceSettingsContent,ro as AssetButton,El as AssetsContent,Bc as BalanceSection,$a as BaseModal,Te as BetterSwapLogo,Ol as BridgeContent,c as CURRENCY_SYMBOLS,kl as ChangeCurrencyContent,pl as ChooseNameContent,vd as ChooseNameModalProvider,_l as ChooseNameSearchContent,vl as ChooseNameSummaryContent,nd as ColorModeSync,hu as ConnectModal,cd as ConnectModalProvider,_u as ConnectPopover,gu as ConnectionButton,Jc as CrossAppConnectionSecurityCard,xl as CustomizationContent,Sl as CustomizationSummaryContent,kn as DAppKitWalletButton,kc as DappKitButton,il as DisconnectConfirmContent,qc as DomainRequiredAlert,le as ENS_TEXT_RECORDS,Mc as EcosystemButton,Ou as EcosystemModal,Cc as EmailLoginButton,rl as EmbeddedWalletContent,Kc as ExchangeWarningAlert,Ed as ExploreEcosystemModalProvider,bl as FAQContent,Ad as FAQModalProvider,Gc as FeatureAnnouncementCard,Fp as GasFeeSummary,Pp as GasFeeTokenSelector,Fl as GasTokenSettingsContent,Al as GeneralSettingsContent,Ne as GitHubLogo,pe as GoogleLogo,jl as LanguageSettingsContent,Lp as LegalDocumentItem,m as LegalDocumentSource,se as LegalDocumentType,Bp as LegalDocumentsModal,qp as LegalDocumentsProvider,pp as LocalStorageKey,wu as LoginLoadingModal,Tc as LoginWithGithubButton,wc as LoginWithGoogleButton,Qs as MAX_IMAGE_SIZE,Nc as MainContent,Dl as ManageCustomTokenContent,Ja as ModalBackButton,kp as ModalFAQButton,Np as ModalNotificationButton,od as ModalProvider,n as NFTMediaType,Od as NotificationsModalProvider,rs as PRICE_FEED_IDS,Oc as PasskeyLoginButton,Ac as PrivyButton,Se as PrivyLogo,Yp as PrivyWalletProvider,wl as ProfileContent,zd as ProfileModalProvider,Uc as QuickActionsSection,Pd as ReceiveModalProvider,cl as ReceiveTokenContent,Ap as ScrollToTopWrapper,al as SelectTokenContent,ol as SendTokenContent,bd as SendTokenModalProvider,sl as SendTokenSummaryContent,Zc as SettingsContent,lu as ShareButtons,xu as SocialIcons,Qa as StickyFooterContainer,Z as StickyHeaderContainer,fl as SwapTokenContent,Sd as SwapTokenModalProvider,Vl as TermsAndPrivacyContent,Li as ThorClient,Mp as TransactionButtonAndStatus,du as TransactionModal,uu as TransactionModalContent,fd as TransactionModalProvider,Cu as TransactionToast,md as TransactionToastProvider,de as TwitterLogo,Tl as UpgradeSmartAccountContent,ju as UpgradeSmartAccountModal,Ld as UpgradeSmartAccountModalProvider,_e as VETLogo,ke as VTHOLogo,Ce as VeBetterIcon,je as VeBetterIconDark,ve as VeBetterIconLight,ye as VeBetterLogo,De as VeBetterLogoDark,we as VeBetterLogoLight,Zp as VeChainKitContext,$p as VeChainKitProvider,Dc as VeChainLoginButton,Ec as VeChainWithPrivyLoginButton,ce as VePassportUserStatus,Ae as VeTradeLogo,he as VeWorldLogoDark,Ee as VeWorldLogoLight,Oe as VechainEnergy,xe as VechainIcon,be as VechainIconDark,me as VechainIconLight,rd as VechainKitThemeProvider,fe as VechainLogo,Pe as VechainLogoDark,Fe as VechainLogoHorizontalDark,Me as VechainLogoHorizontalLight,ge as VechainLogoLight,Za as VersionFooter,bu as WalletButton,gd as WalletModalProvider,lp as buildBatchAuthorizationTypedData,ae as buildCallClauses,Vo as buildClauses,Qf as buildERC20Clauses,up as buildSingleAuthorizationTypedData,ep as buildVETClauses,Co as buildVetDomainClauses,ue as calculateTotalCost,ac as compressImages,Hf as currentBlockQueryKey,op as decodeEventLog,Cp as decodeRawTx,bp as delegateAuthorized,xp as estimateAndBuildTxBody,vp as estimateGas,T as executeCallClause,re as executeMultipleClausesCall,Zd as fetchAppHubApps,io as fetchPrivyAppInfo,so as fetchPrivyStatus,v as formatGasCost,gf as getAccountAddress,_f as getAccountAddressQueryKey,sf as getAccountBalance,cf as getAccountBalanceQueryKey,uf as getAccountImplementationAddress,df as getAccountImplementationAddressQueryKey,bf as getAccountVersionQueryKey,Xf as getAllEventLogs,Xd as getAppHubAppsQueryKey,Yo as getAvatarLegacy,Xo as getAvatarLegacyQueryKey,Go as getAvatarOfAddressQueryKey,Po as getAvatarQueryKey,xs as getB3trBalanceQueryKey,$d as getCallClauseQueryKey,ef as getCallClauseQueryKeyWithArgs,Gf as getChainId,Kf as getChainIdQueryKey,k as getConfig,pf as getCurrentAccountImplementationVersion,mf as getCurrentAccountImplementationVersionQueryKey,hs as getCurrentAllocationsRoundIdQueryKey,Cs as getCustomTokenBalanceQueryKey,vs as getCustomTokenInfoQueryKey,yp as getDepositAccount,jo as getDomainsOfAddress,Mo as getDomainsOfAddressQueryKey,po as getEnsRecordExistsQueryKey,Ts as getErc20BalanceQueryKey,Yf as getEventLogs,sp as getEventsKey,Cf as getHasV1SmartAccount,wf as getHasV1SmartAccountQueryKey,$s as getIpfsImage,ec as getIpfsImageQueryKey,Ys as getIpfsMetadata,Xs as getIpfsMetadataQueryKey,Ef as getIsDeployed,Df as getIsDeployedQueryKey,To as getIsDomainProtectedQueryKey,ks as getIsPersonQueryKey,ao as getPrivyAppInfoQueryKey,Uo as getResolverAddressQueryKey,Ns as getRoundXAppsQueryKey,jf as getSmartAccount,Mf as getSmartAccountQueryKey,Lo as getTextRecords,Ro as getTextRecordsQueryKey,_s as getTokenInfo,is as getTokenUsdPrice,as as getTokenUsdPriceQueryKey,Pf as getUpgradeRequired,Lf as getUpgradeRequiredForAccount,Rf as getUpgradeRequiredForAccountQueryKey,Ff as getUpgradeRequiredQueryKey,lo as getVechainDomainQueryKey,Ds as getVot3BalanceQueryKey,Ks as getXAppMetadata,Is as getXAppsSharesQueryKey,ic as imageCompressionOptions,Sp as signVip191Transaction,ip as txReceiptQueryKey,Cd as useAccessAndSecurityModal,lf as useAccountBalance,jd as useAccountCustomizationModal,ff as useAccountImplementationAddress,ld as useAccountModal,Xc as useAccountModalOptions,Qd as useAppHubApps,fp as useBuildClauses,np as useBuildTransaction,tf as useCallClause,_d as useChooseNameModal,bo as useClaimVeWorldSubdomain,wo as useClaimVetDomain,sd as useConnectModal,Gd as useCrossAppConnectionCache,us as useCurrency,hf as useCurrentAccountImplementationVersion,gs as useCurrentAllocationsRoundId,Wf as useCurrentBlock,bs as useCustomTokens,Mn as useDAppKitWallet,Pn as useDAppKitWalletModal,_p as useEcosystemShortcuts,mo as useEnsRecordExists,Dp as useEstimateAllTokens,cp as useEvents,Td as useExploreEcosystemModal,kd as useFAQModal,Wc as useFeatureAnnouncement,oo as useFetchAppInfo,co as useFetchPrivyStatus,Ep as useGasEstimation,Tp as useGasTokenSelection,wp as useGenericDelegator,vf as useGetAccountAddress,xf as useGetAccountVersion,Fo as useGetAvatar,Qo as useGetAvatarLegacy,Ko as useGetAvatarOfAddress,Ss as useGetB3trBalance,qf as useGetChainId,ws as useGetCustomTokenBalances,ys as useGetCustomTokenInfo,No as useGetDomainsOfAddress,Es as useGetErc20Balance,rf as useGetNodeUrl,Wo as useGetResolverAddress,zo as useGetTextRecords,os as useGetTokenUsdPrice,Os as useGetVot3Balance,Tf as useHasV1SmartAccount,tc as useIpfsImage,nc as useIpfsImageList,Zs as useIpfsMetadata,rc as useIpfsMetadatas,Oo as useIsDomainProtected,af as useIsPWA,As as useIsPerson,Of as useIsSmartAccountDeployed,Kp as useLegalDocuments,mp as useLocalStorage,Fd as useLoginModalContent,Wd as useLoginWithOAuth,Hd as useLoginWithPasskey,Kd as useLoginWithVeChain,Cn as useMfaEnrollment,ad as useModal,Rs as useMostVotedAppsInRound,nf as useMultipleClausesCall,Kl as useNotificationAlerts,ql as useNotifications,Dd as useNotificationsModal,wn as usePrivy,Xp as usePrivyWalletProvider,Rd as useProfileModal,Nd as useReceiveModal,Gs as useRefreshBalances,kf as useRefreshFactoryQueries,ho as useRefreshMetadata,Af as useRefreshSmartAccountQueries,Ps as useRoundXApps,of as useScrollToTop,yd as useSendTokenModal,lc as useSendTransaction,En as useSetWalletRecovery,Bd as useSignMessage,Vd as useSignTypedData,sc as useSingleImageUpload,Nf as useSmartAccount,xc as useSwapQuotes,xd as useSwapTokenModal,uc as useSwapTransaction,gp as useSyncableLocalStorage,An as useThor,ns as useTokenBalances,ss as useTokenPrices,ds as useTokensWithValues,fs as useTotalBalance,dd as useTransactionModal,pd as useTransactionToast,$f as useTransferERC20,tp as useTransferVET,ap as useTxReceipt,ts as useUnsetDomain,Ho as useUpdateTextRecord,If as useUpgradeRequired,zf as useUpgradeRequiredForAccount,Vf as useUpgradeSmartAccount,Id as useUpgradeSmartAccountModal,oc as useUploadImages,$ as useVeChainKitConfig,uo as useVechainDomain,td as useVechainKitThemeConfig,Q as useWallet,Ws as useWalletMetadata,hd as useWalletModal,Js as useXAppMetadata,Ls as useXAppsShares};
194
+ `));return n},Zp=e=>{let{children:t,privy:n,feeDelegation:r,dappKit:i,loginModalUI:o,loginMethods:s,darkMode:c=!1,i18n:l,language:u=`en`,network:d,allowCustomTokens:f,legalDocuments:p,defaultCurrency:m=`usd`,theme:g}=Xp(e),_=d?.type??`main`,v=d?.nodeUrl??k(_).nodeUrl,y={...d,type:_,nodeUrl:v},b=i??{allowedWallets:[`veworld`]},x=s,S=W(()=>x?.find(e=>e.method===`ecosystem`)?.allowedApps??a.map(e=>e.id),[x]),C,w;n?(C=n.appId,w=n.clientId):(C=`clzdb5k0b02b9qvzjm6jpknsc`,w=`client-WY2oy87y6KNrHFnpXuwVsiFMkwPZKTYpExtjvUQuMbCMF`),U(()=>{wa(Ca),u&&Ca.changeLanguage(u),l&&Object.keys(l).forEach(e=>{Ca.addResourceBundle(e,`translation`,l[e],!0,!0)})},[u,l]),U(()=>{h(oe.NETWORK,_)},[_]);let ee=W(()=>Ra(La(c),za(g,c)),[g,c]),T=W(()=>Va(ee,c),[ee,c]),E=W(()=>Ha(ee,c),[ee,c]);return U(()=>{let e=Ba(ee.colors.background.card,c),t=Ba(ee.colors.background.cardElevated,c),n=c?`transparent`:`#ffffff`,r=c?`transparent`:`#ffffff`,i=c?`transparent`:`#ffffff`;Wa(E,ee.effects.backdropFilter.modal,e,t,n,r,i,ee.colors.border.default)},[E,ee.effects.backdropFilter.modal,ee.colors.background.card,ee.colors.background.cardElevated,ee.colors.border.default,c]),U(()=>{Ua()},[]),J(qa,{children:[q(Dn,{initialIsOpen:!1}),q(Hs,{privyEcosystemAppIDS:S,children:q(Yp.Provider,{value:{privy:n,privyEcosystemAppIDS:S,feeDelegation:r,dappKit:b,loginModalUI:o,loginMethods:x,darkMode:c,i18n:l,language:u,network:y,allowCustomTokens:f,legalDocuments:p,defaultCurrency:m,theme:g},children:q(vn,{appId:C,clientId:w,config:{loginMethodsAndOrder:{primary:n?.loginMethods.slice(0,4)??[],overflow:n?.loginMethods.slice(4)??[]},externalWallets:{walletConnect:{enabled:!1}},appearance:{theme:c?`dark`:`light`,accentColor:n?.appearance.accentColor??(ee.buttons.primaryButton.bg?.startsWith(`#`)?ee.buttons.primaryButton.bg:c?`#3182CE`:`#2B6CB0`),loginMessage:n?.appearance.loginMessage,logo:n?.appearance.logo},embeddedWallets:{createOnLogin:n?.embeddedWallets?.createOnLogin??`all-users`},passkeys:{shouldUnlinkOnUnenrollMfa:!1}},children:q(On,{node:y.nodeUrl,v2Api:{enabled:b.v2Api?.enabled??!0,external:b.v2Api?.external??!1},i18n:l,language:u,logLevel:b.logLevel,modalParent:b.modalParent,onSourceClick:b.onSourceClick,usePersistence:b.usePersistence??!0,allowedWallets:b.allowedWallets,walletConnectOptions:b.walletConnectOptions,themeMode:c?`DARK`:`LIGHT`,themeVariables:b.themeVariables?{...T,...b.themeVariables}:T,children:q(qp,{nodeUrl:y.nodeUrl,delegatorUrl:r?.delegatorUrl??r?.genericDelegatorUrl,delegateAllTransactions:r?.delegateAllTransactions??!1,genericDelegator:!!(!r?.delegatorUrl&&r?.genericDelegatorUrl),children:q(id,{children:q(Gp,{children:t})})})})})})})]})};export{qc as AccessAndSecurityContent,Sd as AccessAndSecurityModalProvider,kp as AccountAvatar,Ad as AccountCustomizationModalProvider,Pc as AccountDetailsButton,Nc as AccountMainContent,fu as AccountModal,cd as AccountModalProvider,Ic as AccountSelector,Fc as ActionButton,Ya as AddressDisplay,Ep as AddressDisplayCard,Al as AppearanceSettingsContent,ro as AssetButton,wl as AssetsContent,Rc as BalanceSection,$a as BaseModal,Te as BetterSwapLogo,El as BridgeContent,c as CURRENCY_SYMBOLS,Dl as ChangeCurrencyContent,dl as ChooseNameContent,gd as ChooseNameModalProvider,hl as ChooseNameSearchContent,gl as ChooseNameSummaryContent,ed as ColorModeSync,pu as ConnectModal,od as ConnectModalProvider,hu as ConnectPopover,mu as ConnectionButton,Kc as CrossAppConnectionSecurityCard,yl as CustomizationContent,bl as CustomizationSummaryContent,kn as DAppKitWalletButton,Dc as DappKitButton,nl as DisconnectConfirmContent,Gc as DomainRequiredAlert,le as ENS_TEXT_RECORDS,Ac as EcosystemButton,Eu as EcosystemModal,xc as EmailLoginButton,tl as EmbeddedWalletContent,Wc as ExchangeWarningAlert,wd as ExploreEcosystemModalProvider,vl as FAQContent,Od as FAQModalProvider,Uc as FeatureAnnouncementCard,Np as GasFeeSummary,Mp as GasFeeTokenSelector,Nl as GasTokenSettingsContent,Ol as GeneralSettingsContent,Ne as GitHubLogo,pe as GoogleLogo,kl as LanguageSettingsContent,Fp as LegalDocumentItem,m as LegalDocumentSource,se as LegalDocumentType,Rp as LegalDocumentsModal,Gp as LegalDocumentsProvider,dp as LocalStorageKey,Su as LoginLoadingModal,Cc as LoginWithGithubButton,Sc as LoginWithGoogleButton,Qs as MAX_IMAGE_SIZE,jc as MainContent,Tl as ManageCustomTokenContent,Ja as ModalBackButton,Dp as ModalFAQButton,jp as ModalNotificationButton,id as ModalProvider,n as NFTMediaType,Ed as NotificationsModalProvider,rs as PRICE_FEED_IDS,Ec as PasskeyLoginButton,Oc as PrivyButton,Se as PrivyLogo,qp as PrivyWalletProvider,Sl as ProfileContent,Ld as ProfileModalProvider,Vc as QuickActionsSection,Md as ReceiveModalProvider,ol as ReceiveTokenContent,Op as ScrollToTopWrapper,rl as SelectTokenContent,il as SendTokenContent,vd as SendTokenModalProvider,al as SendTokenSummaryContent,Yc as SettingsContent,su as ShareButtons,yu as SocialIcons,Qa as StickyFooterContainer,Z as StickyHeaderContainer,ul as SwapTokenContent,bd as SwapTokenModalProvider,zl as TermsAndPrivacyContent,Li as ThorClient,Ap as TransactionButtonAndStatus,lu as TransactionModal,cu as TransactionModalContent,ud as TransactionModalProvider,xu as TransactionToast,fd as TransactionToastProvider,de as TwitterLogo,Cl as UpgradeSmartAccountContent,ku as UpgradeSmartAccountModal,Fd as UpgradeSmartAccountModalProvider,_e as VETLogo,ke as VTHOLogo,Ce as VeBetterIcon,je as VeBetterIconDark,ve as VeBetterIconLight,ye as VeBetterLogo,De as VeBetterLogoDark,we as VeBetterLogoLight,Yp as VeChainKitContext,Zp as VeChainKitProvider,Tc as VeChainLoginButton,wc as VeChainWithPrivyLoginButton,ce as VePassportUserStatus,Ae as VeTradeLogo,he as VeWorldLogoDark,Ee as VeWorldLogoLight,Oe as VechainEnergy,xe as VechainIcon,be as VechainIconDark,me as VechainIconLight,td as VechainKitThemeProvider,fe as VechainLogo,Pe as VechainLogoDark,Fe as VechainLogoHorizontalDark,Me as VechainLogoHorizontalLight,ge as VechainLogoLight,Za as VersionFooter,vu as WalletButton,md as WalletModalProvider,sp as buildBatchAuthorizationTypedData,ae as buildCallClauses,Vo as buildClauses,Xf as buildERC20Clauses,cp as buildSingleAuthorizationTypedData,Qf as buildVETClauses,Co as buildVetDomainClauses,ue as calculateTotalCost,ac as compressImages,Bf as currentBlockQueryKey,ip as decodeEventLog,xp as decodeRawTx,vp as delegateAuthorized,yp as estimateAndBuildTxBody,gp as estimateGas,T as executeCallClause,re as executeMultipleClausesCall,Yd as fetchAppHubApps,io as fetchPrivyAppInfo,so as fetchPrivyStatus,v as formatGasCost,mf as getAccountAddress,hf as getAccountAddressQueryKey,af as getAccountBalance,of as getAccountBalanceQueryKey,cf as getAccountImplementationAddress,lf as getAccountImplementationAddressQueryKey,vf as getAccountVersionQueryKey,Jf as getAllEventLogs,Jd as getAppHubAppsQueryKey,Yo as getAvatarLegacy,Xo as getAvatarLegacyQueryKey,Go as getAvatarOfAddressQueryKey,Po as getAvatarQueryKey,xs as getB3trBalanceQueryKey,Zd as getCallClauseQueryKey,Qd as getCallClauseQueryKeyWithArgs,Uf as getChainId,Wf as getChainIdQueryKey,k as getConfig,df as getCurrentAccountImplementationVersion,ff as getCurrentAccountImplementationVersionQueryKey,hs as getCurrentAllocationsRoundIdQueryKey,Cs as getCustomTokenBalanceQueryKey,vs as getCustomTokenInfoQueryKey,_p as getDepositAccount,jo as getDomainsOfAddress,Mo as getDomainsOfAddressQueryKey,po as getEnsRecordExistsQueryKey,Ts as getErc20BalanceQueryKey,qf as getEventLogs,ap as getEventsKey,xf as getHasV1SmartAccount,Sf as getHasV1SmartAccountQueryKey,$s as getIpfsImage,ec as getIpfsImageQueryKey,Ys as getIpfsMetadata,Xs as getIpfsMetadataQueryKey,wf as getIsDeployed,Tf as getIsDeployedQueryKey,To as getIsDomainProtectedQueryKey,ks as getIsPersonQueryKey,ao as getPrivyAppInfoQueryKey,Uo as getResolverAddressQueryKey,Ns as getRoundXAppsQueryKey,kf as getSmartAccount,Af as getSmartAccountQueryKey,Lo as getTextRecords,Ro as getTextRecordsQueryKey,_s as getTokenInfo,is as getTokenUsdPrice,as as getTokenUsdPriceQueryKey,Mf as getUpgradeRequired,Ff as getUpgradeRequiredForAccount,If as getUpgradeRequiredForAccountQueryKey,Nf as getUpgradeRequiredQueryKey,lo as getVechainDomainQueryKey,Ds as getVot3BalanceQueryKey,Ks as getXAppMetadata,Is as getXAppsSharesQueryKey,ic as imageCompressionOptions,bp as signVip191Transaction,np as txReceiptQueryKey,xd as useAccessAndSecurityModal,sf as useAccountBalance,kd as useAccountCustomizationModal,uf as useAccountImplementationAddress,sd as useAccountModal,Jc as useAccountModalOptions,Xd as useAppHubApps,up as useBuildClauses,ep as useBuildTransaction,$d as useCallClause,hd as useChooseNameModal,bo as useClaimVeWorldSubdomain,wo as useClaimVetDomain,ad as useConnectModal,Ud as useCrossAppConnectionCache,us as useCurrency,pf as useCurrentAccountImplementationVersion,gs as useCurrentAllocationsRoundId,Hf as useCurrentBlock,bs as useCustomTokens,Mn as useDAppKitWallet,Pn as useDAppKitWalletModal,hp as useEcosystemShortcuts,mo as useEnsRecordExists,Tp as useEstimateAllTokens,op as useEvents,Cd as useExploreEcosystemModal,Dd as useFAQModal,Hc as useFeatureAnnouncement,oo as useFetchAppInfo,co as useFetchPrivyStatus,wp as useGasEstimation,Cp as useGasTokenSelection,Sp as useGenericDelegator,gf as useGetAccountAddress,yf as useGetAccountVersion,Fo as useGetAvatar,Qo as useGetAvatarLegacy,Ko as useGetAvatarOfAddress,Ss as useGetB3trBalance,Gf as useGetChainId,ws as useGetCustomTokenBalances,ys as useGetCustomTokenInfo,No as useGetDomainsOfAddress,Es as useGetErc20Balance,tf as useGetNodeUrl,Wo as useGetResolverAddress,zo as useGetTextRecords,os as useGetTokenUsdPrice,Os as useGetVot3Balance,Cf as useHasV1SmartAccount,tc as useIpfsImage,nc as useIpfsImageList,Zs as useIpfsMetadata,rc as useIpfsMetadatas,Oo as useIsDomainProtected,nf as useIsPWA,As as useIsPerson,Ef as useIsSmartAccountDeployed,Wp as useLegalDocuments,fp as useLocalStorage,Nd as useLoginModalContent,Hd as useLoginWithOAuth,Bd as useLoginWithPasskey,Wd as useLoginWithVeChain,Cn as useMfaEnrollment,rd as useModal,Rs as useMostVotedAppsInRound,ef as useMultipleClausesCall,Wl as useNotificationAlerts,Gl as useNotifications,Td as useNotificationsModal,wn as usePrivy,Jp as usePrivyWalletProvider,Id as useProfileModal,jd as useReceiveModal,Gs as useRefreshBalances,Df as useRefreshFactoryQueries,ho as useRefreshMetadata,Of as useRefreshSmartAccountQueries,Ps as useRoundXApps,rf as useScrollToTop,_d as useSendTokenModal,lc as useSendTransaction,En as useSetWalletRecovery,Rd as useSignMessage,zd as useSignTypedData,sc as useSingleImageUpload,jf as useSmartAccount,yc as useSwapQuotes,yd as useSwapTokenModal,uc as useSwapTransaction,mp as useSyncableLocalStorage,An as useThor,ns as useTokenBalances,ss as useTokenPrices,ds as useTokensWithValues,fs as useTotalBalance,ld as useTransactionModal,dd as useTransactionToast,Zf as useTransferERC20,$f as useTransferVET,rp as useTxReceipt,ts as useUnsetDomain,Ho as useUpdateTextRecord,Pf as useUpgradeRequired,Lf as useUpgradeRequiredForAccount,zf as useUpgradeSmartAccount,Pd as useUpgradeSmartAccountModal,oc as useUploadImages,$ as useVeChainKitConfig,uo as useVechainDomain,$u as useVechainKitThemeConfig,Q as useWallet,Ws as useWalletMetadata,pd as useWalletModal,Js as useXAppMetadata,Ls as useXAppsShares};
195
195
  //# sourceMappingURL=index.mjs.map