@vechain/vechain-kit 2.6.4 → 2.6.5
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/assets/index.d.cts +1 -1
- package/dist/assets/index.d.mts +1 -1
- package/dist/{index-CWViOs1U.d.mts → index-BN8V0jxo.d.mts} +4 -4
- package/dist/{index-I8fe7GR2.d.cts.map → index-BN8V0jxo.d.mts.map} +1 -1
- package/dist/{index-D0SCAGbu.d.mts → index-C13QSjNa.d.mts} +3 -3
- package/dist/{index-D0SCAGbu.d.mts.map → index-C13QSjNa.d.mts.map} +1 -1
- package/dist/{index-I8fe7GR2.d.cts → index-DSMUkHcK.d.cts} +4 -4
- package/dist/{index-CWViOs1U.d.mts.map → index-DSMUkHcK.d.cts.map} +1 -1
- package/dist/{index-DQiXM6hu.d.cts → index-DadZUdez.d.cts} +148 -148
- package/dist/{index-DQiXM6hu.d.cts.map → index-DadZUdez.d.cts.map} +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +3 -3
- package/dist/index.mjs.map +1 -1
- package/dist/utils/index.d.cts +2 -2
- package/dist/utils/index.d.mts +2 -2
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -118,13 +118,13 @@ import{$ as e,C as t,D as n,G as r,H as i,J as a,Q as o,S as s,T as c,U as l,V a
|
|
|
118
118
|
opacity: 0.5 !important;
|
|
119
119
|
}
|
|
120
120
|
`),d.length>0&&(u.textContent=d.join(`
|
|
121
|
-
`))}let To=null;function Eo(){return To||=new nr({defaultOptions:{queries:{queryKeyHashFn:cr,retry:0,staleTime:3e4,refetchOnWindowFocus:!0,refetchOnMount:!0,refetchOnReconnect:!0,refetchInterval:!1,refetchIntervalInBackground:!1}}}),To}const Do=({children:e})=>{try{if(H.useContext(rr))return J(q,{children:e})}catch(e){console.log(e)}return J(ir,{client:Eo(),children:e})},Oo=({onClick:e,...t})=>J(Dt,{"aria-label":`Back`,icon:J(P,{as:wr,fontSize:`20px`}),size:`sm`,variant:`vechainKitHeaderIconButtons`,position:`absolute`,left:`10px`,top:`8px`,onClick:e,lineHeight:`0`,...t}),ko=({wallet:e,label:t,style:n,showHumanAddress:r=!0,setCurrentContent:i,onLogout:a})=>{let{t:o}=X(),[s,c]=K(!1),[l,u]=K(!1),f=V(`colors`,`vechain-kit-text-primary`),p=V(`colors`,`vechain-kit-text-secondary`),m=dn(`#ebebeb`,`#ffffff0a`),h=dn(`#ffffff`,`transparent`),g=async(e,t)=>{await k(e)&&(t(!0),setTimeout(()=>{t(!1)},2e3))},_=()=>{i&&(e?.domain?i({type:`choose-name-search`,props:{name:``,setCurrentContent:i,initialContentSource:`profile`}}):i({type:`choose-name`,props:{setCurrentContent:i,initialContentSource:`profile`,onBack:()=>i(`profile`)}}))};return J(B,{w:`full`,justifyContent:`center`,...n,children:Y(B,{w:`full`,spacing:4,children:[t&&J(z,{fontSize:`sm`,color:p,children:t}),Y(B,{spacing:2,w:`full`,children:[e?.domain&&Y(N,{w:`full`,spacing:3,px:4,py:2,borderWidth:1,borderColor:m,borderRadius:`md`,bg:h,children:[J(P,{as:ri,color:p}),J(z,{flex:1,fontSize:`sm`,fontWeight:`700`,color:f,noOfLines:1,children:l?o(`Copied!`):e.domain}),Y(N,{spacing:2,children:[i&&J(Dt,{icon:J(Jr,{}),height:`30px`,borderRadius:`5px`,variant:`vechainKitSecondary`,onClick:_,"aria-label":`Edit domain`}),J(Dt,{icon:J(l?Sr:jr,{}),height:`30px`,borderRadius:`5px`,variant:`vechainKitSecondary`,onClick:()=>g(e.domain||``,u),"aria-label":`Copy domain`})]})]}),Y(N,{w:`full`,spacing:3,px:4,py:2,borderWidth:1,borderColor:m,borderRadius:`md`,bg:h,children:[J(P,{as:si,color:p}),J(z,{flex:1,fontSize:`sm`,fontWeight:`700`,color:f,noOfLines:1,children:s?o(`Copied!`):r?d(e?.address??``,8,7):e?.address}),Y(N,{spacing:2,children:[J(Dt,{icon:J(Gr,{}),onClick:()=>i?.({type:`disconnect-confirm`,props:{onDisconnect:()=>a?.(),onBack:()=>i?.(`profile`)}}),variant:`vechainKitSecondary`,height:`30px`,w:`30px`,borderRadius:`5px`,"aria-label":`Copy address`}),J(Dt,{icon:J(s?Sr:jr,{}),onClick:()=>g(e?.address??``,c),variant:`vechainKitSecondary`,height:`30px`,w:`30px`,borderRadius:`5px`,"aria-label":`Copy address`})]})]})]})]})})};var Ao=`2.6.4`,jo={"@adraffy/ens-normalize":`^1.11.0`,"@chakra-ui/react":`^2.8.2`,"@emotion/styled":`^11.14.1`,"@privy-io/cross-app-connect":`0.2.2`,"@privy-io/react-auth":`2.25.0`,"@solana/web3.js":`^1.98.0`,"@tanstack/react-query":`^5.64.2`,"@tanstack/react-query-devtools":`^5.64.1`,"@vechain/contract-getters":`1.3.0`,"@vechain/dapp-kit-react":`2.1.0-rc.5`,"@vechain/picasso":`^2.1.1`,"@vechain/vechain-contract-types":`1.6.0-rc`,"@wagmi/core":`^2.17.2`,"bignumber.js":`^9.1.2`,"browser-image-compression":`^2.0.2`,dotenv:`^16.4.7`,ethers:`^6.13.5`,"framer-motion":`^11.15.0`,i18next:`^24.2.1`,"i18next-browser-languagedetector":`^8.0.2`,net:`^1.0.2`,process:`^0.11.10`,react:`^18.2.0`,"react-device-detect":`^2.2.3`,"react-hook-form":`^7.54.2`,"react-i18next":`^15.4.0`,"react-icons":`^5.4.0`,"react-qrcode-logo":`^3.0.0`,vaul:`^1.1.2`,viem:`^2.29.3`,wagmi:`^2.15.4`},Mo={"@chakra-ui/react":`^2.8.2`,"@emotion/react":`^11.0.0`,"@emotion/styled":`^11.0.0`,"@tanstack/react-query":`^5.64.2`,"@vechain/dapp-kit-react":`2.1.0-rc.5`,"framer-motion":`^11.0.0`,react:`^18.0.0`,"react-dom":`^18.0.0`};const No=({...e})=>{let{darkMode:t}=$();return Y(N,{w:`full`,justifyContent:`center`,alignItems:`center`,spacing:0,...e,children:[J(be,{isDark:t,w:`70px`,h:`auto`,opacity:.4,mr:1,ml:`-16px`}),Y(Nt,{fontSize:`11px`,fontWeight:`500`,opacity:.4,textAlign:`left`,href:`https://github.com/vechain/vechain-kit/releases/tag/${Ao}`,isExternal:!0,pt:`1px`,children:[`v`,Ao]})]})},Po=gn({hasContentBelow:!1}),Fo=()=>_n(Po),Z=({children:e})=>{let[t,n]=K(!1),r=vn(null),i=vn(null),a=vn(null),o=vn(!0),{tokens:s}=Yd(),c=s?.effects?.backdropFilter?.stickyHeader??`blur(20px)`;return W(()=>{let e=e=>{if(!e)return null;let t=e.parentElement;for(;t;){let e=window.getComputedStyle(t);if(e.overflowY===`auto`||e.overflowY===`scroll`||e.overflow===`auto`||e.overflow===`scroll`)return t;t=t.parentElement}return null},t=([e])=>{a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{if(o.current){o.current=!1,n(!1);return}n(!e.isIntersecting)},50)},s=e(i.current),c={threshold:0};s&&(c.root=s,c.rootMargin=`0px`);let l=new IntersectionObserver(t,c),u=setTimeout(()=>{r.current&&l.observe(r.current)},200);return()=>{clearTimeout(u),a.current&&clearTimeout(a.current),l.disconnect()}},[]),Y(Po.Provider,{value:{hasContentBelow:t},children:[J(j,{ref:i,position:`sticky`,top:`0`,left:`0`,w:`full`,borderRadius:`24px 24px 0px 0px`,backdropFilter:t?c:`none`,style:{WebkitBackdropFilter:t?c:`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}),J(`div`,{ref:r,style:{height:`1px`,width:`100%`,pointerEvents:`none`,visibility:`hidden`,marginTop:`-1px`}})]})},Io=({children:e})=>J(j,{position:`absolute`,bottom:`0`,left:`0`,right:`0`,bg:V(`colors`,`vechain-kit-modal`),zIndex:`1000`,p:4,w:`full`,children:e}),Lo=({scrollableContainerRef:e,observerRef:t})=>{let n=V(`colors`,`vechain-kit-border`),{tokens:r}=Yd(),i=r?.effects?.backdropFilter?.stickyHeader??`blur(20px)`,[a,o]=K(!1),s=vn(null),c=vn(!0);return W(()=>{let n=([e])=>{s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{if(c.current){c.current=!1,o(!1);return}o(!e.isIntersecting)},50)},r={threshold:0};e.current&&(r.root=e.current,r.rootMargin=`0px`);let i=new IntersectionObserver(n,r),a=setTimeout(()=>{t.current&&i.observe(t.current)},200);return()=>{clearTimeout(a),s.current&&clearTimeout(s.current),i.disconnect()}},[e,t]),J(j,{position:`sticky`,top:`0`,w:`full`,backdropFilter:a?i:`none`,style:{WebkitBackdropFilter:a?i:`none`},zIndex:999,transition:`backdrop-filter 0.2s ease-in-out`,children:J(j,{mx:`auto`,w:`34px`,h:`5px`,bg:n,mt:4,rounded:`full`})})},Ro=({isOpen:e,onClose:t,children:n,ariaTitle:r,ariaDescription:i,isDismissable:a=!0,minHeight:o,maxHeight:s=`68vh`,closeThreshold:c=.5})=>{let l=V(`colors`,`vechain-kit-modal`),u=V(`colors`,`vechain-kit-overlay`),d=vn(null),f=vn(null),{tokens:p}=Yd(),m=p?.effects?.backdropFilter?.overlay,h=p?.colors?.border?.modal||`none`;return J(ui.Root,{dismissible:a,shouldScaleBackground:!0,repositionInputs:!1,open:e,closeThreshold:c,onOpenChange:e=>{e||t()},children:Y(ui.Portal,{children:[J(ui.Overlay,{style:{zIndex:100,position:`fixed`,top:0,right:0,bottom:0,left:0,backgroundColor:u,backdropFilter:m,WebkitBackdropFilter:m}}),Y(ui.Content,{"aria-description":i,style:{zIndex:101,backgroundColor:l,borderRadius:`24px 24px 0 0`,border:h,position:`fixed`,bottom:0,left:0,right:0,...o&&{minHeight:o},maxHeight:s,display:`flex`,flexDirection:`column`},children:[J(ui.Title,{style:{position:`absolute`,width:`1px`,height:`1px`,padding:0,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:0},children:r}),Y(j,{ref:d,flex:`1`,overflowY:`auto`,children:[J(Lo,{scrollableContainerRef:d,observerRef:f}),J(`div`,{ref:f,style:{height:`1px`,width:`100%`,visibility:`hidden`,marginTop:`-1px`}}),n]})]})]})})},zo=({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,useBottomSheetOnMobile:d,mobileMinHeight:f,mobileMaxHeight:p=`57vh`,desktopMinHeight:m,desktopMaxHeight:h})=>{let[g]=pn(`(min-width: 768px)`),{portalRootRef:_,themeConfig:v,tokens:y}=Yd(),b=d??v?.modal?.useBottomSheetOnMobile??!1,x=V(`colors`,`vechain-kit-modal`),S=V(`colors`,`vechain-kit-overlay`),C=y?.effects?.backdropFilter?.overlay,w=y?.effects?.backdropFilter?.modal,T=l??C??`blur(3px)`,E=g?{minHeight:m,maxHeight:h}:{position:`fixed`,bottom:`0`,mb:`0`,maxW:`2xl`,borderRadius:`24px 24px 0px 0px !important`,overflowY:`auto`,overflowX:`hidden`,scrollBehavior:`smooth`,minHeight:f,maxHeight:p},D=Y(It,{motionPreset:a,isOpen:e,onClose:t,isCentered:i,size:r,returnFocusOnClose:!1,blockScrollOnMount:s,closeOnOverlayClick:o&&u,preserveScrollBarGap:!0,portalProps:{containerRef:_},trapFocus:!c,autoFocus:!c,variant:`vechainKitBase`,children:[J(Rt,{bg:S,backdropFilter:T}),J(Lt,{role:`dialog`,"aria-modal":!c,bg:x,sx:{backdropFilter:w,WebkitBackdropFilter:w},...E,children:n})]});return J(q,{children:!g&&b?J(It,{isOpen:e,onClose:t,size:r,blockScrollOnMount:!1,trapFocus:!1,children:J(Ro,{isOpen:e,onClose:t,ariaTitle:`Dialog`,ariaDescription:`Dialog content area`,isDismissable:u,minHeight:f,maxHeight:p,children:n})}):D})},Bo=async e=>{let t=new URL(`/api/v1/apps/${e}`,Be),n=await fetch(t,{headers:{"privy-app-id":e}});if(!n.ok)throw Error(`Failed to fetch Privy app info`);return n.json()},Vo=e=>[`VECHAIN_KIT_PRIVY_APP_INFO`,...Array.isArray(e)?e:[e]],Ho=e=>{let t=Array.isArray(e)?e:[e];return or({queryKey:Vo(e),queryFn:async()=>{let e=await Promise.all(t.map(e=>Bo(e)));return Object.fromEntries(e.map((e,n)=>{let r=t[n],i=f.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})},Uo=async()=>{try{let e=new URL(`summary.json`,ze),t=await fetch(e);if(!t.ok)throw Error(`Failed to fetch Privy status`);return(await t.json()).page.status??`No data`}catch(e){return console.error(`Error fetching data:`,e),`Error fetching data`}},Wo=()=>or({queryKey:[`PRIVY_STATUS`],queryFn:Uo,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}),Go=e=>[`VECHAIN_KIT_DOMAIN`,e],Ko=e=>{let{network:t}=$();return or({queryKey:Go(e),queryFn:async()=>{if(!e)throw Error(`Address or domain is required`);if(t.type!==`main`&&t.type!==`test`){let t=D(e);return{address:t?e:void 0,domain:void 0,isValidAddressOrDomain:t,isPrimaryDomain:!1}}let n=await bi(e,{networkUrl:t.nodeUrl}),r=D(e);if(!n&&!r)throw Error(`Input must be a valid domain or address`);let i=null,a=null,o=!1;return n?(i=await mi(e,{networkUrl:t.nodeUrl}),a=e,i&&(o=await yi(e,i,{networkUrl:t.nodeUrl}))):(a=await di(e,{networkUrl:t.nodeUrl}),i=e,a&&(o=await yi(a,e,{networkUrl:t.nodeUrl}))),{address:i||void 0,domain:a||void 0,isValidAddressOrDomain:n||r,isPrimaryDomain:o}},enabled:!!e&&!!t.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})},qo=async(e,t,n)=>{let r=Ri(Mi([`0x571e15b4bbf879cf28e5075190137be8e18500e3d38543bf0cbcdb54e00b02cc`,Ri(Hi(n))])),i=await e.contracts.load(y(t).vetDomainsContractAddress,Ei.abi).read.recordExists(r);if(!i)throw Error(`Failed to get ENS record exists for ${n}`);return i[0]},Jo=e=>[`VECHAIN_KIT_ENS_RECORD_VE_WORLD_EXISTS`,e],Yo=e=>{let t=Qn(),{network:n}=$();return or({queryKey:Jo(e),queryFn:()=>qo(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})},Xo=(e,t)=>{let n=sr(),{network:r}=$();return{refresh:async()=>{await Promise.all([n.invalidateQueries({queryKey:hs(e??``,r.type)}),n.invalidateQueries({queryKey:ys(e,r.type)}),n.invalidateQueries({queryKey:Os(t)})])}}},Zo=async(e,t,n,r,i,a)=>{await Promise.all([e.invalidateQueries({queryKey:Go(t)}),e.invalidateQueries({queryKey:Go(n)}),e.invalidateQueries({queryKey:Jo(r)}),e.invalidateQueries({queryKey:ps(t,`.vet`)}),e.invalidateQueries({queryKey:ps(t,`.veworld.vet`)}),e.invalidateQueries({queryKey:ys(n)})]),await Promise.all([e.refetchQueries({queryKey:Go(t)}),e.refetchQueries({queryKey:Go(n)}),e.refetchQueries({queryKey:ps(t,`.vet`)}),e.refetchQueries({queryKey:ps(t,`.veworld.vet`)}),e.refetchQueries({queryKey:hs(r+`.`+i,a)}),e.refetchQueries({queryKey:ys(n)}),e.refetchQueries({queryKey:Jo(r)}),e.refetchQueries({queryKey:Os(t)})])},Qo=Oi.createInterface(),$o=Di.createInterface(),es=(e,t,n,r,i)=>{let a=[];if(!e)throw Error(`Invalid subdomain`);let o=`${e}.${t}`;if(a.push({to:y(i.type).vetDomainsReverseRegistrarAddress,value:`0x0`,data:$o.encodeFunctionData(`setName`,[``]),comment:`Unsetting your current VeChain nickname of the account ${d(r?.address??``,4,4)}`,abi:$o.getFunction(`setName`)}),n){a.push({to:y(i.type).vetDomainsReverseRegistrarAddress,value:`0x0`,data:$o.encodeFunctionData(`setName`,[o]),comment:`Setting your VeChain nickname to ${o}`,abi:$o.getFunction(`setName`)});let e=new xn.Interface([`function setAddr(bytes32 node, address addr)`]),t=xn.namehash(o);a.push({to:y(i.type).vetDomainsPublicResolverAddress,value:`0x0`,data:e.encodeFunctionData(`setAddr`,[t,r?.address||``]),comment:`Setting the address for ${o} to ${d(r?.address??``,4,4)}`,abi:e.getFunction(`setAddr`)})}else if(ns(t))a.push({to:y(i.type).veWorldSubdomainClaimerContractAddress,value:`0x0`,data:Qo.encodeFunctionData(`claim`,[e,y(i.type).vetDomainsPublicResolverAddress]),comment:`Claim VeChain subdomain: ${e}.${t}`,abi:Qo.getFunction(`claim`)}),a.push({to:y(i.type).vetDomainsReverseRegistrarAddress,value:`0x0`,data:$o.encodeFunctionData(`setName`,[e+`.`+t]),comment:`Set ${e}.${t} as the VeChain nickname of the account ${d(r?.address??``,4,4)}`,abi:$o.getFunction(`setName`)});else throw Error(`This hook only supports .veworld.vet subdomains`);return a},ts=({subdomain:e,domain:t,onSuccess:n,onError:r,alreadyOwned:i=!1})=>{let a=sr(),{account:o}=Q(),{network:s}=$(),{refresh:c}=Xo(e+`.`+t,o?.address??``),l=U(()=>es(e,t,i,o,s),[e,t,i,o,s]),u=U(async()=>{let r=`${e}.${t}`;await Zo(a,o?.address??``,r,e,t,s.type),c(),n?.()},[n,e,t,a,o,s.type,c]),d=Xc({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())}},ns=e=>e.endsWith(`veworld.vet`),rs=Di.createInterface(),is=(e,t,n,r)=>{let i=[];if(!e)throw Error(`Invalid domain`);if(t){i.push({to:y(r.type).vetDomainsReverseRegistrarAddress,value:`0x0`,data:rs.encodeFunctionData(`setName`,[e]),comment:`Setting your VeChain nickname to ${e}`,abi:rs.getFunction(`setName`)});let t=new xn.Interface([`function setAddr(bytes32 node, address addr)`]),a=xn.namehash(e);i.push({to:y(r.type).vetDomainsPublicResolverAddress,value:`0x0`,data:t.encodeFunctionData(`setAddr`,[a,n?.address||``]),comment:`Setting the address for ${e} to ${d(n?.address??``,4,4)}`,abi:t.getFunction(`setAddr`)})}else throw Error(`Primary .vet domains are not supported yet`);return i},as=({domain:e,onSuccess:t,onError:n,alreadyOwned:r=!1})=>{let{network:i}=$(),a=sr(),{account:o}=Q(),{refresh:s}=Xo(e,o?.address??``),c=U(()=>is(e,r,o,i),[e,r,o,i]),l=U(async()=>{await Zo(a,o?.address??``,e,``,e.endsWith(`.vet`)?e:`${e}.vet`,i.type),s(),t?.()},[t,e,a,o,i.type,s]),u=Xc({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())}},os=e=>[`VECHAIN_KIT_DOMAIN`,e,`IS_DOMAIN_PROTECTED`],ss=Dn.ofAbi(Oi.abi),cs=async(e,t,n)=>{let r=y(t).veWorldSubdomainClaimerContractAddress;return(await e.contracts.load(r,ss.abi).read.isDomainProtected(n))[0]},ls=(e,t=!0)=>{let n=Qn(),{network:r}=$();return or({queryKey:os(e),queryFn:()=>cs(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})},us=Wi.object({name:Wi.string()}),ds=Wi.object({domains:Wi.array(us)}),fs=async(e,t,n)=>{if(!t)throw Error(`Address is required`);let r=y(e).graphQlIndexerUrl,i=`query Registrations {
|
|
121
|
+
`))}let To=null;function Eo(){return To||=new nr({defaultOptions:{queries:{queryKeyHashFn:cr,retry:0,staleTime:3e4,refetchOnWindowFocus:!0,refetchOnMount:!0,refetchOnReconnect:!0,refetchInterval:!1,refetchIntervalInBackground:!1}}}),To}const Do=({children:e})=>{try{if(H.useContext(rr))return J(q,{children:e})}catch(e){console.log(e)}return J(ir,{client:Eo(),children:e})},Oo=({onClick:e,...t})=>J(Dt,{"aria-label":`Back`,icon:J(P,{as:wr,fontSize:`20px`}),size:`sm`,variant:`vechainKitHeaderIconButtons`,position:`absolute`,left:`10px`,top:`8px`,onClick:e,lineHeight:`0`,...t}),ko=({wallet:e,label:t,style:n,showHumanAddress:r=!0,setCurrentContent:i,onLogout:a})=>{let{t:o}=X(),[s,c]=K(!1),[l,u]=K(!1),f=V(`colors`,`vechain-kit-text-primary`),p=V(`colors`,`vechain-kit-text-secondary`),m=dn(`#ebebeb`,`#ffffff0a`),h=dn(`#ffffff`,`transparent`),g=async(e,t)=>{await k(e)&&(t(!0),setTimeout(()=>{t(!1)},2e3))},_=()=>{i&&(e?.domain?i({type:`choose-name-search`,props:{name:``,setCurrentContent:i,initialContentSource:`profile`}}):i({type:`choose-name`,props:{setCurrentContent:i,initialContentSource:`profile`,onBack:()=>i(`profile`)}}))};return J(B,{w:`full`,justifyContent:`center`,...n,children:Y(B,{w:`full`,spacing:4,children:[t&&J(z,{fontSize:`sm`,color:p,children:t}),Y(B,{spacing:2,w:`full`,children:[e?.domain&&Y(N,{w:`full`,spacing:3,px:4,py:2,borderWidth:1,borderColor:m,borderRadius:`md`,bg:h,children:[J(P,{as:ri,color:p}),J(z,{flex:1,fontSize:`sm`,fontWeight:`700`,color:f,noOfLines:1,children:l?o(`Copied!`):e.domain}),Y(N,{spacing:2,children:[i&&J(Dt,{icon:J(Jr,{}),height:`30px`,borderRadius:`5px`,variant:`vechainKitSecondary`,onClick:_,"aria-label":`Edit domain`}),J(Dt,{icon:J(l?Sr:jr,{}),height:`30px`,borderRadius:`5px`,variant:`vechainKitSecondary`,onClick:()=>g(e.domain||``,u),"aria-label":`Copy domain`})]})]}),Y(N,{w:`full`,spacing:3,px:4,py:2,borderWidth:1,borderColor:m,borderRadius:`md`,bg:h,children:[J(P,{as:si,color:p}),J(z,{flex:1,fontSize:`sm`,fontWeight:`700`,color:f,noOfLines:1,children:s?o(`Copied!`):r?d(e?.address??``,8,7):e?.address}),Y(N,{spacing:2,children:[J(Dt,{icon:J(Gr,{}),onClick:()=>i?.({type:`disconnect-confirm`,props:{onDisconnect:()=>a?.(),onBack:()=>i?.(`profile`)}}),variant:`vechainKitSecondary`,height:`30px`,w:`30px`,borderRadius:`5px`,"aria-label":`Copy address`}),J(Dt,{icon:J(s?Sr:jr,{}),onClick:()=>g(e?.address??``,c),variant:`vechainKitSecondary`,height:`30px`,w:`30px`,borderRadius:`5px`,"aria-label":`Copy address`})]})]})]})]})})};var Ao=`2.6.5`,jo={"@adraffy/ens-normalize":`^1.11.0`,"@chakra-ui/react":`^2.8.2`,"@emotion/styled":`^11.14.1`,"@privy-io/cross-app-connect":`0.2.2`,"@privy-io/react-auth":`2.25.0`,"@solana/web3.js":`^1.98.0`,"@tanstack/react-query":`^5.64.2`,"@tanstack/react-query-devtools":`^5.64.1`,"@vechain/contract-getters":`1.3.0`,"@vechain/dapp-kit-react":`2.1.0-rc.5`,"@vechain/picasso":`^2.1.1`,"@vechain/vechain-contract-types":`1.6.0-rc`,"@wagmi/core":`^2.17.2`,"bignumber.js":`^9.1.2`,"browser-image-compression":`^2.0.2`,dotenv:`^16.4.7`,ethers:`^6.13.5`,"framer-motion":`^11.15.0`,i18next:`^24.2.1`,"i18next-browser-languagedetector":`^8.0.2`,net:`^1.0.2`,process:`^0.11.10`,react:`^18.2.0`,"react-device-detect":`^2.2.3`,"react-hook-form":`^7.54.2`,"react-i18next":`^15.4.0`,"react-icons":`^5.4.0`,"react-qrcode-logo":`^3.0.0`,vaul:`^1.1.2`,viem:`^2.29.3`,wagmi:`^2.15.4`},Mo={"@chakra-ui/react":`^2.8.2`,"@emotion/react":`^11.0.0`,"@emotion/styled":`^11.0.0`,"@tanstack/react-query":`^5.64.2`,"@vechain/dapp-kit-react":`2.1.0-rc.5`,"framer-motion":`^11.0.0`,react:`^18.0.0`,"react-dom":`^18.0.0`};const No=({...e})=>{let{darkMode:t}=$();return Y(N,{w:`full`,justifyContent:`center`,alignItems:`center`,spacing:0,...e,children:[J(be,{isDark:t,w:`70px`,h:`auto`,opacity:.4,mr:1,ml:`-16px`}),Y(Nt,{fontSize:`11px`,fontWeight:`500`,opacity:.4,textAlign:`left`,href:`https://github.com/vechain/vechain-kit/releases/tag/${Ao}`,isExternal:!0,pt:`1px`,children:[`v`,Ao]})]})},Po=gn({hasContentBelow:!1}),Fo=()=>_n(Po),Z=({children:e})=>{let[t,n]=K(!1),r=vn(null),i=vn(null),a=vn(null),o=vn(!0),{tokens:s}=Yd(),c=s?.effects?.backdropFilter?.stickyHeader??`blur(20px)`;return W(()=>{let e=e=>{if(!e)return null;let t=e.parentElement;for(;t;){let e=window.getComputedStyle(t);if(e.overflowY===`auto`||e.overflowY===`scroll`||e.overflow===`auto`||e.overflow===`scroll`)return t;t=t.parentElement}return null},t=([e])=>{a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{if(o.current){o.current=!1,n(!1);return}n(!e.isIntersecting)},50)},s=e(i.current),c={threshold:0};s&&(c.root=s,c.rootMargin=`0px`);let l=new IntersectionObserver(t,c),u=setTimeout(()=>{r.current&&l.observe(r.current)},200);return()=>{clearTimeout(u),a.current&&clearTimeout(a.current),l.disconnect()}},[]),Y(Po.Provider,{value:{hasContentBelow:t},children:[J(j,{ref:i,position:`sticky`,top:`0`,left:`0`,w:`full`,borderRadius:`24px 24px 0px 0px`,backdropFilter:t?c:`none`,style:{WebkitBackdropFilter:t?c:`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}),J(`div`,{ref:r,style:{height:`1px`,width:`100%`,pointerEvents:`none`,visibility:`hidden`,marginTop:`-1px`}})]})},Io=({children:e})=>J(j,{position:`absolute`,bottom:`0`,left:`0`,right:`0`,bg:V(`colors`,`vechain-kit-modal`),zIndex:`1000`,p:4,w:`full`,children:e}),Lo=({scrollableContainerRef:e,observerRef:t})=>{let n=V(`colors`,`vechain-kit-border`),{tokens:r}=Yd(),i=r?.effects?.backdropFilter?.stickyHeader??`blur(20px)`,[a,o]=K(!1),s=vn(null),c=vn(!0);return W(()=>{let n=([e])=>{s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{if(c.current){c.current=!1,o(!1);return}o(!e.isIntersecting)},50)},r={threshold:0};e.current&&(r.root=e.current,r.rootMargin=`0px`);let i=new IntersectionObserver(n,r),a=setTimeout(()=>{t.current&&i.observe(t.current)},200);return()=>{clearTimeout(a),s.current&&clearTimeout(s.current),i.disconnect()}},[e,t]),J(j,{position:`sticky`,top:`0`,w:`full`,backdropFilter:a?i:`none`,style:{WebkitBackdropFilter:a?i:`none`},zIndex:999,transition:`backdrop-filter 0.2s ease-in-out`,children:J(j,{mx:`auto`,w:`34px`,h:`5px`,bg:n,mt:4,rounded:`full`})})},Ro=({isOpen:e,onClose:t,children:n,ariaTitle:r,ariaDescription:i,isDismissable:a=!0,minHeight:o,maxHeight:s=`68vh`,closeThreshold:c=.5})=>{let l=V(`colors`,`vechain-kit-modal`),u=V(`colors`,`vechain-kit-overlay`),d=vn(null),f=vn(null),{tokens:p}=Yd(),m=p?.effects?.backdropFilter?.overlay,h=p?.colors?.border?.modal||`none`;return J(ui.Root,{dismissible:a,shouldScaleBackground:!0,repositionInputs:!1,open:e,closeThreshold:c,onOpenChange:e=>{e||t()},children:Y(ui.Portal,{children:[J(ui.Overlay,{style:{zIndex:100,position:`fixed`,top:0,right:0,bottom:0,left:0,backgroundColor:u,backdropFilter:m,WebkitBackdropFilter:m}}),Y(ui.Content,{"aria-description":i,style:{zIndex:101,backgroundColor:l,borderRadius:`24px 24px 0 0`,border:h,position:`fixed`,bottom:0,left:0,right:0,...o&&{minHeight:o},maxHeight:s,display:`flex`,flexDirection:`column`},children:[J(ui.Title,{style:{position:`absolute`,width:`1px`,height:`1px`,padding:0,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:0},children:r}),Y(j,{ref:d,flex:`1`,overflowY:`auto`,children:[J(Lo,{scrollableContainerRef:d,observerRef:f}),J(`div`,{ref:f,style:{height:`1px`,width:`100%`,visibility:`hidden`,marginTop:`-1px`}}),n]})]})]})})},zo=({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,useBottomSheetOnMobile:d,mobileMinHeight:f,mobileMaxHeight:p=`57vh`,desktopMinHeight:m,desktopMaxHeight:h})=>{let[g]=pn(`(min-width: 768px)`),{portalRootRef:_,themeConfig:v,tokens:y}=Yd(),b=d??v?.modal?.useBottomSheetOnMobile??!1,x=V(`colors`,`vechain-kit-modal`),S=V(`colors`,`vechain-kit-overlay`),C=y?.effects?.backdropFilter?.overlay,w=y?.effects?.backdropFilter?.modal,T=l??C??`blur(3px)`,E=g?{minHeight:m,maxHeight:h}:{position:`fixed`,bottom:`0`,mb:`0`,maxW:`2xl`,borderRadius:`24px 24px 0px 0px !important`,overflowY:`auto`,overflowX:`hidden`,scrollBehavior:`smooth`,minHeight:f,maxHeight:p},D=Y(It,{motionPreset:a,isOpen:e,onClose:t,isCentered:i,size:r,returnFocusOnClose:!1,blockScrollOnMount:s,closeOnOverlayClick:o&&u,preserveScrollBarGap:!0,portalProps:{containerRef:_},trapFocus:!c,autoFocus:!c,variant:`vechainKitBase`,children:[J(Rt,{bg:S,backdropFilter:T}),J(Lt,{role:`dialog`,"aria-modal":!c,bg:x,sx:{backdropFilter:w,WebkitBackdropFilter:w},...E,children:n})]});return J(q,{children:!g&&b?J(It,{isOpen:e,onClose:t,size:r,blockScrollOnMount:!1,trapFocus:!1,children:J(Ro,{isOpen:e,onClose:t,ariaTitle:`Dialog`,ariaDescription:`Dialog content area`,isDismissable:u,minHeight:f,maxHeight:p,children:n})}):D})},Bo=async e=>{let t=new URL(`/api/v1/apps/${e}`,Be),n=await fetch(t,{headers:{"privy-app-id":e}});if(!n.ok)throw Error(`Failed to fetch Privy app info`);return n.json()},Vo=e=>[`VECHAIN_KIT_PRIVY_APP_INFO`,...Array.isArray(e)?e:[e]],Ho=e=>{let t=Array.isArray(e)?e:[e];return or({queryKey:Vo(e),queryFn:async()=>{let e=await Promise.all(t.map(e=>Bo(e)));return Object.fromEntries(e.map((e,n)=>{let r=t[n],i=f.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})},Uo=async()=>{try{let e=new URL(`summary.json`,ze),t=await fetch(e);if(!t.ok)throw Error(`Failed to fetch Privy status`);return(await t.json()).page.status??`No data`}catch(e){return console.error(`Error fetching data:`,e),`Error fetching data`}},Wo=()=>or({queryKey:[`PRIVY_STATUS`],queryFn:Uo,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}),Go=e=>[`VECHAIN_KIT_DOMAIN`,e],Ko=e=>{let{network:t}=$();return or({queryKey:Go(e),queryFn:async()=>{if(!e)throw Error(`Address or domain is required`);if(t.type!==`main`&&t.type!==`test`){let t=D(e);return{address:t?e:void 0,domain:void 0,isValidAddressOrDomain:t,isPrimaryDomain:!1}}let n=await bi(e,{networkUrl:t.nodeUrl}),r=D(e);if(!n&&!r)throw Error(`Input must be a valid domain or address`);let i=null,a=null,o=!1;return n?(i=await mi(e,{networkUrl:t.nodeUrl}),a=e,i&&(o=await yi(e,i,{networkUrl:t.nodeUrl}))):(a=await di(e,{networkUrl:t.nodeUrl}),i=e,a&&(o=await yi(a,e,{networkUrl:t.nodeUrl}))),{address:i||void 0,domain:a||void 0,isValidAddressOrDomain:n||r,isPrimaryDomain:o}},enabled:!!e&&!!t.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})},qo=async(e,t,n)=>{let r=Ri(Mi([`0x571e15b4bbf879cf28e5075190137be8e18500e3d38543bf0cbcdb54e00b02cc`,Ri(Hi(n))])),i=await e.contracts.load(y(t).vetDomainsContractAddress,Ei.abi).read.recordExists(r);if(!i)throw Error(`Failed to get ENS record exists for ${n}`);return i[0]},Jo=e=>[`VECHAIN_KIT_ENS_RECORD_VE_WORLD_EXISTS`,e],Yo=e=>{let t=Qn(),{network:n}=$();return or({queryKey:Jo(e),queryFn:()=>qo(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})},Xo=(e,t)=>{let n=sr(),{network:r}=$();return{refresh:async()=>{await Promise.all([n.invalidateQueries({queryKey:hs(e??``,r.type)}),n.invalidateQueries({queryKey:ys(e,r.type)}),n.invalidateQueries({queryKey:Os(t)})])}}},Zo=async(e,t,n,r,i,a)=>{await Promise.all([e.invalidateQueries({queryKey:Go(t)}),e.invalidateQueries({queryKey:Go(n)}),e.invalidateQueries({queryKey:Jo(r)}),e.invalidateQueries({queryKey:ps(t,`.vet`)}),e.invalidateQueries({queryKey:ps(t,`.veworld.vet`)}),e.invalidateQueries({queryKey:ys(n)})]),await Promise.all([e.refetchQueries({queryKey:Go(t)}),e.refetchQueries({queryKey:Go(n)}),e.refetchQueries({queryKey:ps(t,`.vet`)}),e.refetchQueries({queryKey:ps(t,`.veworld.vet`)}),e.refetchQueries({queryKey:hs(r+`.`+i,a)}),e.refetchQueries({queryKey:ys(n)}),e.refetchQueries({queryKey:Jo(r)}),e.refetchQueries({queryKey:Os(t)})])},Qo=Oi.createInterface(),$o=Di.createInterface(),es=(e,t,n,r,i)=>{let a=[];if(!e)throw Error(`Invalid subdomain`);let o=`${e}.${t}`;if(a.push({to:y(i.type).vetDomainsReverseRegistrarAddress,value:`0x0`,data:$o.encodeFunctionData(`setName`,[``]),comment:`Unsetting your current VeChain nickname of the account ${d(r?.address??``,4,4)}`,abi:$o.getFunction(`setName`)}),n){a.push({to:y(i.type).vetDomainsReverseRegistrarAddress,value:`0x0`,data:$o.encodeFunctionData(`setName`,[o]),comment:`Setting your VeChain nickname to ${o}`,abi:$o.getFunction(`setName`)});let e=new xn.Interface([`function setAddr(bytes32 node, address addr)`]),t=xn.namehash(o);a.push({to:y(i.type).vetDomainsPublicResolverAddress,value:`0x0`,data:e.encodeFunctionData(`setAddr`,[t,r?.address||``]),comment:`Setting the address for ${o} to ${d(r?.address??``,4,4)}`,abi:e.getFunction(`setAddr`)})}else if(ns(t))a.push({to:y(i.type).veWorldSubdomainClaimerContractAddress,value:`0x0`,data:Qo.encodeFunctionData(`claim`,[e,y(i.type).vetDomainsPublicResolverAddress]),comment:`Claim VeChain subdomain: ${e}.${t}`,abi:Qo.getFunction(`claim`)}),a.push({to:y(i.type).vetDomainsReverseRegistrarAddress,value:`0x0`,data:$o.encodeFunctionData(`setName`,[e+`.`+t]),comment:`Set ${e}.${t} as the VeChain nickname of the account ${d(r?.address??``,4,4)}`,abi:$o.getFunction(`setName`)});else throw Error(`This hook only supports .veworld.vet subdomains`);return a},ts=({subdomain:e,domain:t,onSuccess:n,onError:r,alreadyOwned:i=!1})=>{let a=sr(),{account:o}=Q(),{network:s}=$(),{refresh:c}=Xo(e+`.`+t,o?.address??``),l=U(()=>es(e,t,i,o,s),[e,t,i,o,s]),u=U(async()=>{let r=`${e}.${t}`;await Zo(a,o?.address??``,r,e,t,s.type),c(),n?.()},[n,e,t,a,o,s.type,c]),d=Xc({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())}},ns=e=>e.endsWith(`veworld.vet`),rs=Di.createInterface(),is=(e,t,n,r)=>{let i=[];if(!e)throw Error(`Invalid domain`);if(t){i.push({to:y(r.type).vetDomainsReverseRegistrarAddress,value:`0x0`,data:rs.encodeFunctionData(`setName`,[e]),comment:`Setting your VeChain nickname to ${e}`,abi:rs.getFunction(`setName`)});let t=new xn.Interface([`function setAddr(bytes32 node, address addr)`]),a=xn.namehash(e);i.push({to:y(r.type).vetDomainsPublicResolverAddress,value:`0x0`,data:t.encodeFunctionData(`setAddr`,[a,n?.address||``]),comment:`Setting the address for ${e} to ${d(n?.address??``,4,4)}`,abi:t.getFunction(`setAddr`)})}else throw Error(`Primary .vet domains are not supported yet`);return i},as=({domain:e,onSuccess:t,onError:n,alreadyOwned:r=!1})=>{let{network:i}=$(),a=sr(),{account:o}=Q(),{refresh:s}=Xo(e,o?.address??``),c=U(()=>is(e,r,o,i),[e,r,o,i]),l=U(async()=>{await Zo(a,o?.address??``,e,``,e.endsWith(`.vet`)?e:`${e}.vet`,i.type),s(),t?.()},[t,e,a,o,i.type,s]),u=Xc({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())}},os=e=>[`VECHAIN_KIT_DOMAIN`,e,`IS_DOMAIN_PROTECTED`],ss=Dn.ofAbi(Oi.abi),cs=async(e,t,n)=>{let r=y(t).veWorldSubdomainClaimerContractAddress;return(await e.contracts.load(r,ss.abi).read.isDomainProtected(n))[0]},ls=(e,t=!0)=>{let n=Qn(),{network:r}=$();return or({queryKey:os(e),queryFn:()=>cs(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})},us=Wi.object({name:Wi.string()}),ds=Wi.object({domains:Wi.array(us)}),fs=async(e,t,n)=>{if(!t)throw Error(`Address is required`);let r=y(e).graphQlIndexerUrl,i=`query Registrations {
|
|
122
122
|
domains(
|
|
123
123
|
where: ${n?`{owner: "${t.toLowerCase()}", parent_: {name: "${n}"}}`:`{owner: "${t.toLowerCase()}"}`}
|
|
124
124
|
) {
|
|
125
125
|
name
|
|
126
126
|
}
|
|
127
|
-
}`,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`))),ds.parse(o.data)},ps=(e,t)=>[`VECHAIN_KIT`,`VET_DOMAINS`,e,t],ms=(e,t)=>{let{network:n}=$();return or({queryKey:ps(e,t),queryFn:()=>fs(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})},hs=(e,t)=>[`VECHAIN_KIT`,`VET_DOMAINS`,`AVATAR`,e,t],gs=e=>{let{network:t}=$();return or({queryKey:hs(e??``,t.type),queryFn:async()=>e?fi(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})},_s=new bn([`function resolver(bytes32 node) returns (address resolverAddress)`,`function text(bytes32 node, string key) view returns (string)`]),vs=async(e,t,n)=>{if(!n)return{};let r=Sn(n);try{let n=new URL(`accounts/*`,e),[{data:i,reverted:a}]=await(await fetch(n,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({clauses:[{to:y(t).vetDomainsContractAddress,data:_s.encodeFunctionData(`resolver`,[r])}]})})).json();if(a)return{};let{resolverAddress:o}=_s.decodeFunctionResult(`resolver`,i);return(await(await fetch(n,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({clauses:s.map(e=>({to:o,data:_s.encodeFunctionData(`text`,[r,e])}))})})).json()).reduce((e,{data:t,reverted:n},r)=>{if(!n&&t&&t!==`0x`)try{let n=_s.decodeFunctionResult(`text`,t)[0];n&&(e[s[r]]=n)}catch(e){console.error(`Failed to decode text record for ${s[r]}:`,e)}return e},{})}catch(e){throw console.error(`Error fetching text records:`,e),e}},ys=(e,t)=>[`VECHAIN_KIT_TEXT_RECORDS`,e,t],bs=e=>{let{network:t}=$(),n=t.nodeUrl??y(t.type).nodeUrl;return or({queryKey:ys(e,t.type),queryFn:()=>vs(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})},xs=new bn([`function resolver(bytes32 node) returns (address resolverAddress)`,`function setText(bytes32 node, string key, string value) external`]),Ss=(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=Sn(r);n.push({to:e,data:xs.encodeFunctionData(`setText`,[t,i,a]),value:`0`,comment:`Update ${i} record`})}return n},Cs=({onSuccess:e,onError:t,signerAccountAddress:n,resolverAddress:r}={})=>{let i=U(e=>{if(!r)throw Error(`Resolver address is required`);return Ss(r,e)},[r]),a=Xc({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))}},ws=e=>[`VECHAIN_KIT`,`RESOLVER_ADDRESS`,e],Ts=e=>{let{network:t}=$();return Xf({address:y(t.type).vetDomainsContractAddress,abi:Ei.abi,method:`resolver`,args:[e?zi(e):`0x`],queryOptions:{select:e=>e[0],enabled:!!e}})},Es={Mugshot:new URL(`mugshot.png`,Xe).toString(),Greencart:new URL(`greencart.png`,Xe).toString(),Cleanify:new URL(`cleanify.png`,Xe).toString(),EVearn:new URL(`evearn.png`,Xe).toString()},Ds=()=>{let e=x(`vechain_kit_cross_app_connection`);if(!e)return null;try{let t=JSON.parse(e)?.ecosystemApp?.name;return t?Es[t]??null:null}catch{return null}},Os=e=>[`VECHAIN_KIT`,`VET_DOMAINS`,`AVATAR_OF_ADDRESS`,e],ks=e=>{let{network:t}=$();return or({queryKey:Os(e),queryFn:async()=>{if(!e||!t.nodeUrl)return Ds()??l(e??``);if(t.type!==`main`&&t.type!==`test`)return Ds()??l(e);let n=await di(e,{networkUrl:t.nodeUrl});return n&&await fi(n,{networkUrl:t.nodeUrl})||(Ds()??l(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})},As=new bn([`function resolver(bytes32 node) returns (address resolverAddress)`,`function text(bytes32 node, string key) returns (string avatar)`]),js=new bn([`function tokenURI(uint256 tokenId) view returns (string)`,`function uri(uint256 id) view returns (string)`]),Ms=async(e,t,n)=>{if(!n)throw Error(`Name is required`);let r=Sn(n);try{let n=new URL(`accounts/*`,t),[{data:i,reverted:a}]=await(await fetch(n,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({clauses:[{to:y(e).vetDomainsContractAddress,data:As.encodeFunctionData(`resolver`,[r])}]})})).json();if(a)return null;let{resolverAddress:o}=As.decodeFunctionResult(`resolver`,i),[{data:s,reverted:c}]=await(await fetch(n,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({clauses:[{to:o,data:As.encodeFunctionData(`text`,[r,`avatar`])}]})})).json();if(c||s===`0x`)return null;try{let{avatar:n}=As.decodeFunctionResult(`text`,s),r=n===``?null:n;return r?Ps(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}},Ns=(e,t)=>[`VECHAIN_KIT`,`VET_DOMAINS`,`AVATAR`,`LEGACY`,e,t];async function Ps(e,t,n){try{if(e.startsWith(`http`)||e.startsWith(`ipfs://`)||e.startsWith(`ar://`))return C(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:js.encodeFunctionData(s?`uri`:`tokenURI`,[BigInt(o||0)])}],l=new URL(`accounts/*`,n),[{data:u,reverted:d}]=await fetch(l,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({clauses:c})}).then(e=>e.json());if(d)return console.error(`Failed to fetch tokenURI`),null;let f=``;try{f=js.decodeFunctionResult(s?`uri`:`tokenURI`,u)[0]}catch(e){console.error(`Failed to decode avatar data:`,e),f=Tn(u)}f=C(f,t)||f,s&&(f=f.replace(`{id}`,En(wn(BigInt(o||0)),32).slice(2)));let p=await fetch(f);if(!p.ok)return console.error(`Failed to fetch metadata`),null;let m=await p.json(),h=m.image||m.image_url||m.image_data;return h?C(h,t)||h:(console.error(`No image URL in metadata`),null)}return null}catch(e){return console.error(`Error parsing avatar record:`,e),null}}const Fs=e=>{let{network:t}=$(),n=t.nodeUrl??y(t.type).nodeUrl;return or({queryKey:Ns(e??``,t.type),queryFn:async()=>e?Ms(t.type,n,e):null,enabled:!!e&&!!n&&!!t.type})},Is=Di.createInterface(),Ls=(e,t)=>{let n=[];return n.push({to:y(t.type).vetDomainsReverseRegistrarAddress,value:`0x0`,data:Is.encodeFunctionData(`setName`,[``]),comment:`Unsetting your current VeChain nickname of the account ${d(e?.address??``,4,4)}`,abi:Is.getFunction(`setName`)}),n},Rs=({onSuccess:e,onError:t})=>{let n=sr(),{account:r}=Q(),{network:i}=$(),a=U(()=>Ls(r,i),[r,i]),o=U(async()=>{await Zo(n,r?.address??``,``,``,``,i.type),e?.()},[e,n,r,i.type]),s=Xc({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())}},zs=e=>{let{network:t,allowCommunityTokens:n}=$(),r=y(t.type),{data:i,isLoading:a}=op(e),{data:o,isLoading:s}=sc(e),{data:c,isLoading:l}=pc(e),{data:u,isLoading:d}=dc(r.veDelegateTokenContractAddress,e),{data:f,isLoading:p}=dc(r.sassContractAddress,e,{enabled:n}),m=lc(e),h=m.map(e=>e.data).filter(Boolean),g=m.some(e=>e.isLoading);return{balances:G(()=>{if(!e)return[];let t={vet:`0x`,vtho:r.vthoContractAddress,b3tr:r.b3trContractAddress,vot3:r.vot3ContractAddress,veDelegate:r.veDelegate},a=[{address:t.vet,symbol:`VET`,balance:i?.balance||`0`},{address:t.vtho,symbol:`VTHO`,balance:i?.energy||`0`},{address:t.b3tr,symbol:`B3TR`,balance:o?.scaled??`0`},{address:t.vot3,symbol:`VOT3`,balance:c?.scaled??`0`},{address:t.veDelegate,symbol:`veDelegate`,balance:u?.scaled??`0`}],s=h.map(e=>({address:e?.address||``,symbol:e?.symbol||``,balance:e?.scaled||`0`})),l=n?[{address:r.sassContractAddress,symbol:`SASS`,balance:f?.scaled??`0`}]:[];return[...a,...s,...l]},[e,i,o,c,u,h,n,f,r.sassContractAddress,t.type]),isLoading:a||s||l||d||n&&p||g}},Bs={B3TR:`0x623374722d757364000000000000000000000000000000000000000000000000`,VET:`0x7665742d75736400000000000000000000000000000000000000000000000000`,VTHO:`0x7674686f2d757364000000000000000000000000000000000000000000000000`,GBP:`0x6762702d75736400000000000000000000000000000000000000000000000000`,EUR:`0x657572742d757364000000000000000000000000000000000000000000000000`},Vs=async(e,t,n)=>{let r=await e.contracts.load(y(n).oracleContractAddress,Si.abi).read.getLatestValue(Bs[t]);if(!r)throw Error(`Failed to get price of ${t}`);return new yn(r[0].toString()).div(0xe8d4a51000).toNumber()},Hs=e=>[`VECHAIN_KIT_PRICE`,e],Us=e=>{let t=Qn(),{network:n}=$();return or({queryKey:Hs(e),queryFn:async()=>Vs(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})},Ws=()=>{let{network:e}=$(),t=y(e.type),{data:n,isLoading:r}=Us(`VET`),{data:i,isLoading:a}=Us(`VTHO`),{data:o,isLoading:s}=Us(`B3TR`),{data:c,isLoading:l}=Us(`EUR`),{data:u,isLoading:d}=Us(`GBP`);return{prices:G(()=>{let e={vet:`0x`,vtho:t.vthoContractAddress,b3tr:t.b3trContractAddress,vot3:t.vot3ContractAddress,veDelegate:t.veDelegate,SASS:t.sassContractAddress};return{[e.vet]:n||0,[e.vtho]:i||0,[e.b3tr]:o||0,[e.vot3]:o||0,[e.veDelegate]:o||0,[e.SASS]:0}},[n,i,o,t.vthoContractAddress,t.b3trContractAddress,t.vot3ContractAddress,t.veDelegate,t.sassContractAddress]),exchangeRates:G(()=>({eurUsdPrice:c||1,gbpUsdPrice:u||1}),[c,u]),isLoading:r||a||s||l||d}},Gs=(e,t,n)=>{switch(t){case`eur`:return e/n.eurUsdPrice;case`gbp`:return e/n.gbpUsdPrice;default:return e}},Ks=(e,t=`en`,n)=>{let r={style:`currency`,minimumFractionDigits:2,maximumFractionDigits:2,currency:n?.currency??`usd`,...n};return new Intl.NumberFormat(eo[t],r).format(e)},qs=(e,t)=>Ks(e,no.resolvedLanguage,{notation:`compact`,compactDisplay:`short`,currency:t?.currency??`usd`,...t}),Js=[`usd`,`eur`,`gbp`],Ys=()=>{let{currentCurrency:e,setCurrency:t}=$();return W(()=>{de(`vechain_kit_currency`,e)},[e]),{currentCurrency:e,allCurrencies:Js,changeCurrency:e=>{if(!Js.includes(e)){console.error(`Invalid currency: ${e}`);return}t(e)}}},Xs=({address:e=``})=>{let{balances:t,isLoading:n}=zs(e),{prices:r,exchangeRates:i,isLoading:a}=Ws(),{currentCurrency:o}=Ys(),s=G(()=>t.map(e=>{let t=r[e.address]||0,n=Number(e.balance)*t,a=Gs(n,o,i);return{...e,priceUsd:t,valueUsd:n,valueInCurrency:a}}),[t,r,o,i]),c=G(()=>[...s].sort((e,t)=>t.valueInCurrency-e.valueInCurrency),[s]);return{tokens:s,sortedTokens:c,tokensWithBalance:G(()=>c.filter(e=>Number(e.balance)>0),[c]),isLoading:n||a}},Zs=({address:e=``})=>{let{tokensWithBalance:t,isLoading:n}=Xs({address:e}),{currentCurrency:r}=Ys(),i=G(()=>t.reduce((e,t)=>e+t.valueInCurrency,0),[t]);return{totalBalanceInCurrency:i,totalBalanceUsd:G(()=>t.reduce((e,t)=>e+t.valueUsd,0),[t]),formattedBalance:G(()=>qs(i,{currency:r}),[i,r]),isLoading:n,hasAnyBalance:t.length>0}},Qs=ji.abi,$s=`currentRoundId`,ec=e=>qf({abi:Qs,address:e,method:$s}),tc=()=>{let{network:e}=$(),t=y(e.type).xAllocationVotingContractAddress;return Xf({abi:Qs,address:t,method:$s,args:[],queryOptions:{select:e=>e[0].toString()}})},nc=async(e,t)=>_i(e,{networkUrl:t}),rc=e=>[`VECHAIN_KIT_CUSTOM_TOKEN_INFO`,e],ic=e=>{let{network:t}=$();return or({queryKey:rc(e),queryFn:async()=>{if(!e)throw Error(`Token address is required`);if(!t.nodeUrl)throw Error(`Network node URL is required`);return nc(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})},ac=()=>{let[e,t]=dm(um.CUSTOM_TOKENS,[]),{network:n}=$(),r=async r=>{if(!a(r)&&!o(r)){if(!n.nodeUrl)throw Error(`Network node URL is required`);let i={...await nc(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)),o=e=>{let t={vet:`0x`,vtho:y(n.type).vthoContractAddress,b3tr:y(n.type).b3trContractAddress,vot3:y(n.type).vot3ContractAddress,veDelegate:y(n.type).veDelegate};return Object.values(t).includes(e)};return{customTokens:e,addToken:r,removeToken:i,isTokenIncluded:a,isDefaultToken:o}},oc=e=>[`VEBETTERDAO_BALANCE`,e,`B3TR`],sc=e=>{let{network:t}=$();return or({queryKey:oc(e),queryFn:async()=>{if(!e)throw Error(`Address is required`);let n=await pi(e,{networkUrl:t.nodeUrl});if(!n)throw Error(`Failed to get b3tr balance`);let r=n[0];return i(r)},enabled:!!e&&!!t.type})},cc=(e,t)=>[`VECHAIN_KIT_BALANCE`,t,`CUSTOM_TOKEN`,e],lc=e=>{let{network:t}=$(),{customTokens:n}=ac();return ar({queries:n.map(n=>({queryKey:cc(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 hi(n.address,e,{networkUrl:t.nodeUrl});if(!r)throw Error(`Failed to get token balance`);let a=i(r[0]);return{...n,...a}}}))})},uc=(e,t)=>[`VECHAIN_KIT`,`BALANCE`,`ERC20`,e,t],dc=(e,t,n)=>{let{network:r}=$(),a=!!t&&!!r.type;return or({queryKey:uc(e,t),queryFn:async()=>{if(!t)throw Error(`Address is required`);let n=await hi(e,t,{networkUrl:r.nodeUrl});if(!n)throw Error(`Failed to get vot3 balance`);let a=n[0];return i(a)},enabled:a&&(n?.enabled??!0)})},fc=e=>[`VEBETTERDAO_BALANCE`,e,`VOT3`],pc=e=>{let{network:t}=$();return or({queryKey:fc(e),queryFn:async()=>{if(!e)throw Error(`Address is required`);let n=await vi(e,{networkUrl:t.nodeUrl});if(!n)throw Error(`Failed to get vot3 balance`);let r=n[0];return i(r)},enabled:!!e&&!!t.type})},mc=(e,t)=>[`VECHAIN_KIT`,`IS_PERSON`,e,t],hc=e=>{let{network:t}=$();return or({queryKey:mc(e??``,t.type),queryFn:async()=>{if(!e)throw Error(`User address is required`);return gi(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})},gc=ji.abi,_c=`getAppsOfRound`,vc=(e,t)=>Yf({abi:gc,address:y(t).xAllocationVotingContractAddress,method:_c,args:[BigInt(e??0)]}),yc=e=>{let{network:t}=$(),n=y(t.type).xAllocationVotingContractAddress;return Xf({abi:gc,address:n,method:_c,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()}))}})},bc=Ai.abi,xc=e=>[`VECHAIN_KIT`,`XApps`,`Shares`,e],Sc=(e,t)=>{let n=Qn(),{network:r}=$(),i=y(r.type).xAllocationPoolContractAddress;return or({queryKey:xc(t),queryFn:async()=>(await ne({thor:n,calls:e.map(e=>({abi:bc,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})},Cc=e=>{let{data:t}=yc(e),n=Sc(t?.map(e=>e.id)??[],e);return{data:G(()=>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}},wc=({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 ea&&i&&!g(i)?Error(t):i&&g(i)?Error(n):e instanceof Error?e:Error(r)},Tc=Pi({id:`1176455790972829965191905223412607679856028701100105089447013101863`,name:`Vechain`,nativeCurrency:{name:`VeChain`,symbol:`VET`,decimals:18},rpcUrls:{default:{http:[he]}},blockExplorers:{default:{name:`Vechain Explorer`,url:Oe},vechainStats:{name:`Vechain Stats`,url:Le}}}),Ec=()=>$i({id:_,name:`VeChain`,iconUrl:`https://imagedelivery.net/oHBRUd2clqykxgDWmeAyLg/661dd77c-2f9d-40e7-baa1-f4e24fd7bf00/icon`,smartWalletMode:!1}),Dc=({privyEcosystemAppIDS:e,children:t})=>J(Gi,{config:vn(Ki({chains:[Tc],ssr:!0,connectors:[Ec(),...e.map(e=>$i({id:e,name:``,iconUrl:``}))],transports:{[Tc.id]:qi()},multiInjectedProviderDiscovery:!1})).current,children:t}),Oc=()=>{let{connectAsync:e,connectors:t}=Yi(),{signTypedDataAsync:n}=Qi(),{signMessageAsync:r}=Zi(),{disconnectAsync:i}=Xi(),{isConnected:a}=Ji(),[o,s]=K(!1),[c,l]=K(null),u=U(async()=>{try{a&&(await i(),A()&&window.dispatchEvent(new Event(`wallet_disconnected`)))}catch(e){throw console.error(`Error during logout:`,e),e}},[i,a]);return{login:U(async n=>{try{s(!0),l(null);let r=t.find(e=>e.id===(n||_));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:U(async e=>{try{return await r({message:e})}catch(e){throw wc({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:U(async e=>{try{return await n(e)}catch(e){throw wc({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}},kc=(e,t)=>{let{data:n,isLoading:r}=Ko(e??``),{data:i,isLoading:a}=ks(e??``),{data:o,isLoading:s}=bs(n?.domain??``),c=o?.header?C(o.header,t):null;return{domain:n?.domain,image:i,records:{...o,header:c},isLoading:r||a||s}},Ac=()=>{let{network:e}=$(),t=U(e=>({wallets:`vechain_kit_wallets_${e}`,activeWallet:`vechain_kit_active_wallet_${e}`}),[]),n=U(()=>{if(!A())return[];let n=x(t(e.type).wallets);return n?JSON.parse(n):[]},[e.type,t]),r=U(()=>A()?x(t(e.type).activeWallet):null,[e.type,t]),i=U(r=>{if(!A())return;let i=t(e.type),a=n(),o=a.findIndex(e=>e.address.toLowerCase()===r.toLowerCase()),s={address:r,connectedAt:o>=0?a[o].connectedAt:Date.now(),isActive:!1};o>=0?a[o]=s:a.push(s),de(i.wallets,JSON.stringify(a))},[e.type,t,n]),a=U(r=>{if(!A())return;let i=t(e.type),a=n().map(e=>({...e,isActive:e.address.toLowerCase()===r.toLowerCase()}));de(i.wallets,JSON.stringify(a)),de(i.activeWallet,r)},[e.type,t,n]);return{getStoredWallets:n,getActiveWallet:r,saveWallet:i,setActiveWallet:a,removeWallet:U(i=>{if(!A())return;let a=t(e.type),o=n().filter(e=>e.address.toLowerCase()!==i.toLowerCase());de(a.wallets,JSON.stringify(o));let s=r();s&&s.toLowerCase()===i.toLowerCase()&&w(a.activeWallet),A()&&window.dispatchEvent(new CustomEvent(`wallet_removed`,{detail:{address:i}}))},[e.type,t,n,r]),initializeCurrentWallet:U(e=>{A()&&n().length===0&&(i(e),a(e))},[n,i,a])}},Q=()=>{let{address:e,isConnected:t,isConnecting:n,isReconnecting:r}=Ji(),{logout:i}=Oc(),{loading:a}=Hn({}),{feeDelegation:o,network:s,privy:c}=$(),{user:l,authenticated:u,logout:d,ready:f}=Kn(),{data:p}=Wp(),{account:m,disconnect:h}=$n(),{getConnectionCache:g,clearConnectionCache:v}=Bf(),y=g(),{initializeCurrentWallet:b,getActiveWallet:x,saveWallet:S,getStoredWallets:C}=Ac(),w=tp(),T=G(()=>A()?!!window.vechain?.isInAppBrowser:!1,[]),E=!!m,D=u&&!!l,k=D||t,ee=D&&c?.appId===_||t&&y?.ecosystemApp?.appId===_,te=n||r||a||!f,[ne,re]=K(!1),ie=t?{type:`privy-cross-app`,displayName:`Ecosystem`}:E?{type:`wallet`,displayName:`Wallet`}:{type:`privy`,displayName:`Social Login`};W(()=>{let e=E||D||t;ne!==e&&(re(e),e||(v(),A()&&window.dispatchEvent(new Event(`wallet_disconnected`))))},[E,D,t,v,ne]);let ae=l?.linkedAccounts?.find(e=>e.type===`wallet`&&e.connectorType===`embedded`)?.address,oe=E?m:t?e:ae,[se,ce]=K(()=>E&&!T?x():null);W(()=>{ce(E&&!T?x():null)},[E,T,x]);let[le,ue]=K(!1);W(()=>{if(!A()||!E||T)return;let e=e=>{ue(!0),ce(e.detail.address),setTimeout(()=>{ue(!1)},1e3)};return window.addEventListener(`wallet_switched`,e),()=>{window.removeEventListener(`wallet_switched`,e)}},[E,T]);let de=C().some(e=>e.address.toLowerCase()===oe?.toLowerCase()),fe=E&&!T?x():null,pe=le&&fe||fe&&de?fe:oe,{data:me}=Ap(pe??``),he=E?pe:me?.address,ge=kc(he??``,s.type),_e=kc(pe??``,s.type),ve=kc(me?.address??``,s.type),{setActiveWallet:ye}=Ac(),be=vn(new Set);W(()=>{if(!A()||!E||T)return;let e=e=>{be.current.add(e.detail.address.toLowerCase()),setTimeout(()=>{be.current.delete(e.detail.address.toLowerCase())},5e3)};return window.addEventListener(`wallet_removed`,e),()=>{window.removeEventListener(`wallet_removed`,e)}},[E,T]),W(()=>{if(E&&!T&&oe&&ge&&!ge.isLoading){if(be.current.has(oe.toLowerCase()))return;let e=!C().some(e=>e.address.toLowerCase()===oe.toLowerCase());b(oe),S(oe);let t=!se,n=se&&se.toLowerCase()===oe.toLowerCase();(e||t||n)&&!le&&ye(oe)}},[E,T,oe,ge?.domain,ge?.image,ge?.isLoading,b,S,ye,se,C]),W(()=>{E&&!T&&se&&se.toLowerCase()===pe?.toLowerCase()&&S(se)},[E,T,se,pe,S]);let xe=he?{address:he,domain:ge.domain,image:ge.image,isLoadingMetadata:ge.isLoading,metadata:ge.records}:null,Se=oe?{address:oe,domain:_e.domain,image:_e.image,isLoadingMetadata:_e.isLoading,metadata:_e.records}:null,{data:Ce}=vp(me?.address??``,Se?.address??``),we=!!me?.address&&!!xe?.address&&O(me?.address,xe?.address),Te=U(async()=>{try{re(!1),E?h():D?await d():t&&await i(),v(),A()&&window.dispatchEvent(new Event(`wallet_disconnected`))}catch(e){console.error(`Error during disconnect:`,e)}},[E,h,D,d,t,i,v]);return{account:xe,smartAccount:{address:me?.address??``,domain:ve.domain,image:ve.image,isDeployed:me?.isDeployed??!1,isActive:we,version:Ce?.version??null,isLoadingMetadata:ve.isLoading,metadata:ve.records},connectedWallet:Se,privyUser:l,connection:{isLoading:te,isConnected:ne,isConnectedWithSocialLogin:D,isConnectedWithDappKit:E,isConnectedWithCrossApp:t,isConnectedWithPrivy:k,isConnectedWithVeChain:ee,source:ie,isInAppBrowser:T,nodeUrl:w,delegatorUrl:o?.delegatorUrl,chainId:p,network:s.type},disconnect:Te}},jc=()=>{let e=sr(),{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`]})])}}},Mc=()=>{let{switchWallet:e}=$n(),{connection:t}=Q(),[n,r]=K(!1),{getStoredWallets:i,setActiveWallet:a,removeWallet:o}=Ac(),s=t.isInAppBrowser;return{switchWallet:U(async()=>{if(s){if(!e)return;r(!0);try{await e()}catch{}finally{r(!1)}}else return Promise.resolve()},[e,s]),isSwitching:n,getStoredWallets:i,setActiveWallet:U(e=>{a(e),A()&&window.dispatchEvent(new CustomEvent(`wallet_switched`,{detail:{address:e}}))},[a]),removeWallet:o,isInAppBrowser:s}},Nc=async(e,t)=>{let n=C(e,t)||``,r=await fetch(n,{signal:AbortSignal.timeout(2e4)});if(!r.ok)throw Error(`HTTP error! status: ${r.status}`);return await r.json()},Pc=ki.abi,Fc=e=>{let t=Qn(),{network:n}=$();return or({queryKey:[`xAppMetaData`,e],queryFn:async()=>{let r=y(n.type).x2EarnAppsContractAddress,i=t.contracts.load(r,Pc),a=(await i.read.app(e))[0][3]?.toString()||``,[o]=await i.read.baseURI();return await Nc(`${o}${a}`,n.type)},enabled:!!e})},Ic=async(e,t,n=!1)=>{if(!t)throw Error(`No URI provided`);let r=C(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},Lc=(e,t)=>[`VECHAIN_KIT`,`IPFS_METADATA`,e,t],Rc=(e,t=!1)=>{let{network:n}=$();return or({queryKey:Lc(n.type,e),queryFn:()=>Ic(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})},zc=1024*1024*10,Bc=async(e,t)=>{if(!t)throw Error(`IPFS URI is required`);let n=await fetch(C(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>zc)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:m(r.type)})},n.onerror=()=>{t(Error(`Error occurred while reading blob.`))}})},Vc=(e,t)=>[`VECHAIN_KIT`,`IPFS_IMAGE`,e,t],Hc=e=>{let{network:t}=$();return or({queryKey:Vc(t.type,e),queryFn:()=>Bc(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})},Uc=e=>{let{network:t}=$();return ar({queries:e.map(e=>({queryKey:Vc(t.type,e),queryFn:()=>Bc(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}))})},Wc=(e,t=!1)=>{let{network:n}=$();return ar({queries:e.map(e=>({queryKey:Lc(n.type,e),queryFn:async()=>Ic(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}))})},Gc={maxSizeMB:.4,maxWidthOrHeight:1920,useWebWorker:!0},Kc=async e=>{let t=[];try{for(let n of e){let e=await ta(n.file,Gc);t.push(e)}return t}catch(e){throw console.error(`compress error`,e),e}},qc=({compressImages:e,defaultImages:t})=>{let[n,r]=K(t??[]);W(()=>{t&&r(t)},[t]);let[i,a]=K([]),o=U(e=>r(t=>t.filter((t,n)=>n!==e)),[]);return{uploadedImages:n,setUploadedImages:r,onUpload:U(async(t,n=!0)=>{a([]);let i=[];for(let n of t){let t=n;e&&(t=await ta(n,Gc));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}},Jc=({compressImage:e,defaultImage:t})=>{let[n,r]=K(t);W(()=>{t&&r(t)},[t]);let i=U(()=>r(void 0),[]);return{uploadedImage:n,setUploadedImage:r,onUpload:U(async t=>{let n=t;e&&(n=await ta(n,Gc));let i={file:n,image:URL.createObjectURL(n)};return r(i),i},[e]),onRemove:i}},Yc=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)},Xc=({signerAccountAddress:e,clauses:t,onTxConfirmed:n,onTxFailedOrCancelled:r,suggestedMaxGas:i,privyUIOptions:a,gasPadding:o,delegationUrl:s})=>{let c=Qn(),{signer:l,requestTransaction:u}=er(),{connection:d}=Q(),{feeDelegation:f}=$(),p=tp(),m=Qm(),h=U(async(t,n,r)=>{let a=typeof t==`function`?await t():t??[];if(d.isConnectedWithPrivy)return await m.sendTransaction({txClauses:a,...r,delegationUrl:n});if(!e)throw Error(`signerAccountAddress is required`);let s=0;try{s=await Yc(c,[...a],e,{revision:Mn.NEXT,...o?{gasPadding:o}:{}})}catch(e){console.error(`Gas estimation failed`,e)}return(await u(a,{signer:d.isConnectedWithDappKit&&!d.isInAppBrowser&&e?e:l.address,gas:i??s,...f?.delegateAllTransactions||n?{delegator:{url:n??f?.delegatorUrl??``,signer:e}}:{}})).txid},[e,i,p,m,a,f,c,l,o,s,u,d.isConnectedWithDappKit,d.isInAppBrowser]),[g,_]=K(null),[v,y]=K(!1),[b,x]=K(null),S=U(async(e,n)=>{if(!e&&!t)throw Error(`clauses are required`);try{_(null),y(!0),x(null),O(void 0),_(await h(e??[],n,{...a}))}catch(e){x(e&&typeof e==`object`&&`message`in e?e.message:String(e)),r?.(e instanceof Error?e:Error(String(e)))}finally{y(!1)}},[h,t,a,s]),{data:C,isLoading:w,error:T}=nm(g??``),E=U(async e=>{if(!(!e.reverted||!e.meta.txID))return await c.transactions.getRevertReason(e.meta.txID)},[c]),[D,O]=K(),k=G(()=>{if(v)return`pending`;if(b)return`error`;if(g){if(w)return`waitingConfirmation`;if(T)return`error`;if(C)return C.reverted?`error`:`success`}return`ready`},[w,b,v,g,C,T]);W(()=>{if(k===`success`||k===`error`){if(b&&!D){O({type:`UserRejectedError`,reason:b});return}if(C?.reverted&&!D?.type){(async()=>{let e=await E(C);O({type:`RevertReasonError`,reason:e?`Transaction reverted with: `+e:`Transaction reverted`})})();return}C&&!C.reverted&&n?.()}},[k,C,n,E,b]);let A=U(()=>{_(null),y(!1),x(null),O(void 0)},[]);return{sendTransaction:S,isTransactionPending:G(()=>v||w||k===`pending`||k===`waitingConfirmation`,[v,w,k]),isWaitingForWalletConfirmation:G(()=>k===`pending`,[v,k]),txReceipt:C??null,status:k,resetStatus:A,error:D}},Zc=(e,t)=>{let{account:n}=Q(),{t:r}=X(),{sendTransaction:i,isTransactionPending:a,isWaitingForWalletConfirmation:o,txReceipt:s,status:c,resetStatus:l,error:u}=Xc({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:U(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}},Qc=e=>e===`0x`||e===Ui,$c=(e,t,n,r)=>{let i={},a=r.toLowerCase();for(let t of e)try{let e=Ni({abi:An,eventName:`Transfer`,topics:t.topics,data:t.data}),n=e.args.from.toLowerCase(),r=e.args.to.toLowerCase(),o=e.args.value,s=typeof o==`bigint`?o:BigInt(o);if(n!==a&&r!==a)continue;let c=t.address.toLowerCase(),l=i[c]??{inflow:0n,outflow:0n};n===a&&(l.outflow+=s),r===a&&(l.inflow+=s),i[c]=l}catch{continue}if(n!==void 0){let e=BigInt(n);if(e>0n){let t=i[Ui]??{inflow:0n,outflow:0n};t.outflow+=e,i[Ui]=t}}for(let e of t){if(e.recipient.toLowerCase()!==a)continue;let t=BigInt(e.amount);if(t<=0n)continue;let n=i[Ui]??{inflow:0n,outflow:0n};n.inflow+=t,i[Ui]=n}return i},el=async(e,t,n,r)=>{try{if(n.length===0)return{gasCostVTHO:0,success:!1,error:`No clauses found for simulation`};let i=await r.transactions.simulateTransaction(n,{caller:e.userAddress}),a=!1,o,s=2e5,c={};for(let t=0;t<i.length;t++){let r=i[t];r.reverted&&(a=!0,o=r.vmError||`Transaction reverted`),s+=r.gasUsed;let l=n[t],u=$c(r.events,r.transfers,l?.value,e.userAddress);for(let[e,t]of Object.entries(u)){let n=c[e]??{inflow:0n,outflow:0n};c[e]={inflow:n.inflow+t.inflow,outflow:n.outflow+t.outflow}}}if(a)return{gasCostVTHO:0,success:!1,error:o||`Transaction reverted`};let l=s/1e5,u=Qc(e.fromTokenAddress),d=Qc(e.toTokenAddress),f=BigInt(e.amountIn);if(u){let e=c[Ui]??{inflow:0n,outflow:0n};if(e.outflow>f)return{gasCostVTHO:l,success:!1,error:`VET outflow mismatch: expected ${f.toString()}, got ${e.outflow.toString()}`};for(let[e,t]of Object.entries(c))if(e!==Ui&&t.outflow>0n)return{gasCostVTHO:l,success:!1,error:`Unexpected token outflow: token ${e} has outflow ${t.outflow.toString()}, expected 0`}}else{let t=e.fromTokenAddress.toLowerCase(),n=c[t]??{inflow:0n,outflow:0n};if(n.outflow>f)return{gasCostVTHO:l,success:!1,error:`Token outflow mismatch: expected ${f.toString()}, got ${n.outflow.toString()}`};for(let[e,n]of Object.entries(c))if(e!==t&&n.outflow>0n)return{gasCostVTHO:l,success:!1,error:`Unexpected token outflow: ${e===Ui?`VET`:e} has outflow ${n.outflow.toString()}, expected 0`}}if(t.minimumOutputAmount&&t.minimumOutputAmount>0n)if(d){let e=c[Ui]??{inflow:0n,outflow:0n};if(e.inflow<t.minimumOutputAmount)return{gasCostVTHO:l,success:!1,error:`VET inflow mismatch: expected ${t.minimumOutputAmount.toString()}, got ${e.inflow.toString()}`}}else{let n=c[e.toTokenAddress.toLowerCase()]??{inflow:0n,outflow:0n};if(n.inflow<t.minimumOutputAmount)return{gasCostVTHO:l,success:!1,error:`Token inflow mismatch: expected ${t.minimumOutputAmount.toString()}, got ${n.inflow.toString()}`}}return{gasCostVTHO:l,success:!0}}catch(e){return{gasCostVTHO:0,success:!1,error:e instanceof Error?e.message:`Simulation failed`}}},tl=e=>e.startsWith(`0x`)?BigInt(e).toString():e,nl=(e,t)=>({name:e,type:`function`,inputs:t.map(e=>({name:e.name,type:e.type,internalType:e.internalType,components:e.components})),outputs:[],stateMutability:`nonpayable`}),rl=(e,t)=>{if(Array.isArray(e)&&e.length>0){let n=e[0];if(typeof n==`object`&&`name`in n&&`type`in n&&n.type===`function`)return e;if(typeof n==`object`&&`name`in n&&`type`in n&&!(`stateMutability`in n||`outputs`in n))return[nl(t,e)]}return e},il=e=>{try{let t=e.functionName||e.name;if(!t)throw Error(`Function name is required (either functionName or name must be provided)`);return Fi({abi:rl(e.abi,t),functionName:t,args:e.args})}catch(t){console.error(`Failed to encode function call:`,t);let n=e.functionName||e.name||`unknown`;throw Error(`Failed to encode function call ${n}: ${t instanceof Error?t.message:`Unknown error`}`)}},al=e=>{let t=il(e.functionCall);return{to:e.to,value:tl(e.value),data:t,comment:e.comment||`Swap on aggregator`}},ol=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=new URL(e.apiBaseUrl);i.search=r.toString();let a=await fetch(i);if(!a.ok)throw Error(`API request failed: ${a.status} ${a.statusText}`);let o=await a.json(),s=o.clauses.map(al),c=BigInt(o.amountOut),l=BigInt(o.amountOutMin);return{aggregatorName:e.name,aggregator:t,outputAmount:c,minimumOutputAmount:l,priceImpact:0,data:{clauses:s,path:o.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{return el(e,t,await this.buildSwapTransaction(e,t),n)}catch(e){return{gasCostVTHO:0,success:!1,error:e instanceof Error?e.message:`Failed to build swap transaction for simulation`}}},async buildSwapTransaction(t,n){if(!n.data||typeof n.data!=`object`||!(`clauses`in n.data))throw Error(`Invalid quote data: clauses not found`);let r=n.data.clauses;if(r.length===0)throw Error(`No clauses found in quote`);if(e.supportedAddresses&&e.supportedAddresses.length>0){let t=e.supportedAddresses.map(e=>e.toLowerCase());if(r=r.filter(e=>e.to?t.includes(e.to.toLowerCase()):!1),r.length===0)throw Error(`No clauses found matching supported addresses`)}if(!n.minimumOutputAmount||n.minimumOutputAmount===0n)throw Error(`Invalid quote: minimumOutputAmount is missing or zero`);return r}};return t},sl={main:{supportedAddresses:[`0xE5fA980a6EfE5B79C2150a529da06AeF455963b6`,`0x7C755EC0165fCD926cC6faB10E7BB16a72E9f34A`]},test:{supportedAddresses:[]},solo:{supportedAddresses:[]}},cl=e=>e===`0x`||e===`0x0000000000000000000000000000000000000000`,ll=e=>new URL(`api/quote/vck`,Te).toString(),ul=e=>{let t=sl[e]??sl.main,n=ol({name:`VeTrade.vet`,apiBaseUrl:ll(e),network:e,getIcon:(e=`20px`)=>H.createElement(Je,{boxSize:e}),supportedAddresses:t.supportedAddresses});return{...n,async simulateSwap(e,t,n){try{return el(e,t,await this.buildSwapTransaction(e,t),n)}catch(e){return{gasCostVTHO:0,success:!1,error:e instanceof Error?e.message:`Simulation failed`}}},async buildSwapTransaction(e,r){let i=[],a=await n.buildSwapTransaction(e,r);if(!a||a.length===0)throw Error(`Failed to build swap transaction`);if(cl(e.fromTokenAddress))a[0].value=e.amountIn;else{if(t.supportedAddresses.length===0)throw Error(`No supported addresses configured for VeTrade on this network`);let n=Dn.ofAbi(xi.abi),o=On.of(e.fromTokenAddress),s=BigInt(e.amountIn);i.push(kn.callFunction(o,n.getFunction(`approve`),[a[0].to,s.toString()],Fn.of(0n,Pn.wei),{comment:`Approve ${r.aggregatorName} to access ${e.fromTokenAddress}`}))}return i.push(...a),i}}},dl=e=>e===`0x`||e===`0x0000000000000000000000000000000000000000`,fl=()=>BigInt(Math.floor(Date.now()/1e3)+1200),pl=e=>{let t={name:e.name,getIcon:e.getIcon,async getQuote(n,r){let i=[dl(n.fromTokenAddress)?e.wrappedVET:n.fromTokenAddress,dl(n.toTokenAddress)?e.wrappedVET:n.toTokenAddress],a=BigInt(n.amountIn);try{let[o]=await r.contracts.load(e.routerAddress,Ti.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){return el(e,t,await this.buildSwapTransaction(e,t),n)},async buildSwapTransaction(t,n){if(!n.data||typeof n.data!=`object`||!(`path`in n.data))throw Error(`Invalid quote data`);let r=fl();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=dl(t.fromTokenAddress),s=dl(t.toTokenAddress),c=Dn.ofAbi(Ti.abi),l=[];if(o)l.push(kn.callFunction(On.of(e.routerAddress),c.getFunction(`swapExactETHForTokens`),[i.toString(),n.data.path,t.userAddress,r.toString()],Fn.of(a,Pn.wei),{comment:`Swap on ${n.aggregatorName}`}));else{let o=Dn.ofAbi(xi.abi),u=On.of(t.fromTokenAddress),d=On.of(e.routerAddress);l.push(kn.callFunction(u,o.getFunction(`approve`),[d.toString(),a.toString()],Fn.of(0n,Pn.wei),{comment:`Swap on ${n.aggregatorName}`})),s?l.push(kn.callFunction(d,c.getFunction(`swapExactTokensForETH`),[a.toString(),i.toString(),n.data.path,t.userAddress,r.toString()],Fn.of(0n,Pn.wei),{comment:`Swap on ${n.aggregatorName}`})):l.push(kn.callFunction(d,c.getFunction(`swapExactTokensForTokens`),[a.toString(),i.toString(),n.data.path,t.userAddress,r.toString()],Fn.of(0n,Pn.wei),{comment:`Swap on ${n.aggregatorName}`}))}return l}};return t},ml={main:{routerAddress:`0xf21Dd7108D93af56FaB07423EfB90F4a3604DA89`,wrappedVET:`0xf9b02b47694fd635A413F16dC7B38aF06Cc16fe5`},test:{routerAddress:Ui,wrappedVET:Ui},solo:{routerAddress:Ui,wrappedVET:Ui}},hl=e=>{let t=ml[e]??ml.main;return pl({name:`BetterSwap.io`,routerAddress:t.routerAddress,wrappedVET:t.wrappedVET,getIcon:(e=`20px`)=>H.createElement(We,{boxSize:e})})},gl=e=>[ul(e),hl(e)],_l=(e,t,n,r,i=1,a=!0)=>{let o=Qn(),{connection:s}=Q(),c=e?.address??null,l=t?.address??null,{data:u}=ic(c===`0x`||c===Ui||!c?``:c),{data:d}=ic(l===`0x`||l===Ui||!l?``:l),f=G(()=>!c||c===`0x`||c===Ui||!u?18:Number(u?.decimals??18),[c,u?.decimals]),p=G(()=>!l||l===`0x`||l===Ui||!d?18:Number(d?.decimals??18),[l,d?.decimals]),m=G(()=>{if(!c||!l||!n||!r)return null;let e;try{e=Vi(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:_}=or({queryKey:[`unified-swap-quotes`,m,s.network],queryFn:async()=>{if(!m||!o||!s.network)return{quotes:[],best:null};let e=gl(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}},vl=({email:e,onResend:t,isLoading:n,isOpen:r,onClose:i})=>{let{t:a}=X(),{darkMode:o}=$(),s=V(`colors`,`vechain-kit-text-secondary`),[c,l]=K(``),[u,d]=K(null),{createWallet:f}=Bn(),{loginWithCode:p}=Vn({onComplete:async({isNewUser:e})=>{e&&await f()}});return W(()=>{c.length===6&&p({code:c}).then(()=>{i()}).catch(e=>{d(e.message)})},[c]),Y(zo,{isOpen:r,onClose:i,trapFocus:!1,children:[Y(Z,{children:[J(R,{alignItems:`center`,display:`flex`,gap:2,children:a(`Enter confirmation code`)}),J(I,{})]}),Y(yt,{maxW:`container.lg`,children:[J(F,{children:Y(B,{spacing:2,children:[J(P,{as:Kr,w:`48px`,h:`48px`,color:s}),J(z,{fontSize:`xs`,color:s,textAlign:`center`,children:a(`Please check {{email}} for an email from privy.io and enter your code below.`,{email:e})}),J(N,{spacing:2,justify:`center`,mt:4,children:Y(zt,{value:c,onChange:l,otp:!0,size:`lg`,isInvalid:!!u,errorBorderColor:`#ef4444`,children:[J(Bt,{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`}),J(Bt,{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`}),J(Bt,{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`}),J(Bt,{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`}),J(Bt,{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`}),J(Bt,{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&&J(z,{color:`#ef4444`,fontSize:`xs`,children:u})]})}),J(L,{children:Y(z,{w:`100%`,textAlign:`center`,fontSize:`14px`,color:o?`whiteAlpha.700`:`gray.600`,children:[a(`Didn't get an email?`),` `,J(M,{variant:`link`,color:`blue.500`,fontSize:`14px`,onClick:t,isLoading:n,children:a(`Resend code`)})]})})]})]})},yl=()=>{let{t:e}=X(),{darkMode:t}=$(),[n,r]=K(``),{sendCode:i,state:a}=Vn({}),o=fn(),s=async()=>{await i({email:n}),o.onOpen()};return Y(q,{children:[J(Tt,{colSpan:4,w:`full`,children:J(B,{spacing:3,w:`full`,children:Y(At,{size:`lg`,w:`full`,children:[J(jt,{pointerEvents:`none`,height:`100%`,pl:4,children:J(P,{as:Kr,color:t?`whiteAlpha.600`:`blackAlpha.700`,w:`20px`,h:`20px`})}),J(kt,{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}),J(M,{"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`)})]})})}),J(vl,{isOpen:o.isOpen,onClose:o.onClose,onResend:()=>i({email:n}),email:n,isLoading:a.status===`sending-code`})]})},bl=({isDark:e,gridColumn:t})=>{let{t:n}=X(),{initOAuth:r}=zf();return J(Tt,{colSpan:t??4,w:`full`,children:J(pd,{isDark:e,onClick:async()=>{await r({provider:`google`})},icon:na,text:n(`Continue with Google`)})})},xl=({isDark:e,gridColumn:t})=>{let{t:n}=X(),{initOAuth:r}=zf();return J(Tt,{colSpan:t??4,w:`full`,children:J(pd,{isDark:e,onClick:async()=>{await r({provider:`github`})},icon:zr,text:n(`Continue with Github`)})})},Sl=({isDark:e,gridColumn:t})=>{let{t:n}=X(),{login:r}=Gn();return J(Tt,{colSpan:t||4,w:`full`,children:J(pd,{isDark:e,onClick:r,icon:e?xe:Ke,text:n(`Use social login with VeChain`),variant:`loginWithVechain`,rightIcon:J(vd,{})})})},Cl=({isDark:e,gridColumn:t,setCurrentContent:n})=>{let{t:r}=X(),{login:i}=Vf(),a=async()=>{n({type:`loading`,props:{title:r(`Connecting to VeChain`),loadingText:r(`Please approve the request in the connection request window...`),onTryAgain:a}});try{await i()}catch(e){console.error(r(`Login failed:`),e),n({type:`error`,props:{error:e instanceof Error?e.message:r(`Failed to connect with VeChain`),onTryAgain:a}})}};return J(Tt,{colSpan:t||4,w:`full`,children:J(pd,{isDark:e,onClick:a,icon:e?xe:Ke,text:r(`Use social login with VeChain`),variant:`loginWithVechain`,rightIcon:J(vd,{})})})},wl=({isDark:e,gridColumn:t,setCurrentContent:n})=>{let{t:r}=X(),{loginWithPasskey:i}=Lf(),a=async()=>{n({type:`loading`,props:{title:r(`Connecting with Passkey`),loadingText:r(`Please complete the passkey authentication...`),onTryAgain:a}});try{await i()}catch(e){(e instanceof Error?e.message.toLowerCase():``).includes(`not found`)&&console.error(e),n({type:`error`,props:{error:e instanceof Error?e.message:r(`Failed to connect with Passkey`),onTryAgain:a}})}};return J(Tt,{colSpan:t,w:`full`,children:J(pd,{isDark:e,onClick:a,icon:Ir,text:t&&t>=2?r(`Passkey`):void 0})})},Tl=({isDark:e,gridColumn:t=2})=>{let{t:n}=X(),{open:r,onConnectionStatusChange:i}=tr(),{dappKit:a}=$(),{source:o}=er(),s=a?.allowedWallets?.includes(`sync2`)?n(`Connect wallet`):n(`Connect with VeWorld wallet`);return W(()=>{i((e,t)=>{if(!e)return t?.message&&console.error(t?.message),{...o&&{source:o}}})},[i,o]),J(Tt,{colSpan:t||2,w:`full`,children:J(pd,{isDark:e,onClick:()=>{r()},icon:a?.allowedWallets?.includes(`sync2`)?si:e?Ce:He,iconWidth:`27px`,text:t>=2?s:void 0,rightIcon:a?.allowedWallets?.includes(`sync2`)&&J(P,{as:hr})||void 0})})},El=({isDark:e,onViewMoreLogin:t,gridColumn:n})=>{let{t:r}=X();return J(Tt,{colSpan:n,w:`full`,children:J(pd,{isDark:e,onClick:t,icon:Nr,text:n&&n>=2?r(`More`):void 0,rightIcon:J(P,{as:hr})})})},Dl=({setCurrentContent:e})=>{let{loginMethods:t,darkMode:n}=$(),{login:r}=Gn(),{showGoogleLogin:i,showEmailLogin:a,showPasskey:o,showVeChainLogin:s,showDappKit:c,showMoreLogin:l,showGithubLogin:u,isOfficialVeChainApp:d}=Of();return J(Yt,{spacing:4,w:`full`,align:`center`,children:J(wt,{templateColumns:`repeat(4, 1fr)`,gap:2,w:`full`,children:t?.map(({method:t,gridColumn:f})=>{switch(t){case`email`:return a&&J(yl,{},`email`);case`google`:return i&&J(bl,{isDark:n,gridColumn:f},`google`);case`github`:return u&&J(xl,{isDark:n,gridColumn:f},`github`);case`vechain`:return s&&(d?J(Sl,{isDark:n,gridColumn:f},`vechain`):J(Cl,{isDark:n,gridColumn:f,setCurrentContent:e},`vechain`));case`passkey`:return o&&J(wl,{isDark:n,gridColumn:f,setCurrentContent:e},`passkey`);case`dappkit`:return c&&J(Tl,{isDark:n,gridColumn:f},`dappkit`);case`more`:return l&&J(El,{isDark:n,onViewMoreLogin:r,gridColumn:f},`more`);default:return null}})})})},Ol=({appsInfo:e,isLoading:t,setCurrentContent:n})=>{let{t:r}=X();return J(M,{fontSize:`sm`,variant:`link`,onClick:()=>n({type:`ecosystem`,props:{appsInfo:e,isLoading:t}}),children:r(`Already have an x2earn app wallet?`)})},kl=({setCurrentContent:e})=>{let{t}=X(),{loginModalUI:n,darkMode:r}=$(),{loginMethods:i,privyEcosystemAppIDS:a}=$(),{data:o,isLoading:s}=Ho(a),c=V(`colors`,`vechain-kit-text-secondary`),l=()=>{e(`faq`)},u=i?.some(({method:e})=>e===`ecosystem`);return Y(q,{children:[Y(Z,{children:[J(Dm,{onClick:l}),J(R,{children:t(`Log in or sign up`)}),J(I,{})]}),n?.logo&&J(N,{justify:`center`,children:J(Ot,{src:n.logo||`/images/favicon.png`,maxW:`180px`,maxH:`90px`,m:8,alt:`logo`})}),Y(F,{children:[n?.description&&J(N,{spacing:4,w:`full`,justify:`center`,mb:`24px`,px:4,children:J(z,{color:c,fontSize:`sm`,textAlign:`center`,children:n?.description})}),J(Dl,{setCurrentContent:e})]}),u?J(L,{children:J(N,{justify:`center`,w:`full`,children:J(Ol,{isDark:r,appsInfo:Object.values(o||{}),isLoading:s,setCurrentContent:e})})}):J(L,{pt:0,pb:`5px`})]})},Al=({setCurrentContent:e,wallet:t,onClose:n,switchFeedback:r})=>{let{t:i}=X(),{network:a}=$(),{isolatedView:o}=Ml();return Y(Om,{children:[Y(Z,{children:[!o&&J(Oo,{onClick:()=>{e(`profile`)}}),Y(R,{children:[i(`Wallet`),a?.type!==`main`&&J(Zt,{size:`xs`,colorScheme:`orange`,fontSize:`2xs`,p:1,ml:1,textTransform:`uppercase`,children:`${a?.type}`})]}),J(I,{})]}),J(F,{w:`full`,children:Y(B,{w:`full`,overflow:`hidden`,justifyContent:`flex-start`,spacing:8,children:[J(Lm,{showFeedback:r?.showFeedback}),J(Xl,{style:{justifyContent:`flex-start`},onClick:()=>{e(`profile`)},setCurrentContent:e,onClose:n,wallet:t}),J(Ql,{onAssetsClick:()=>{e(`assets`)}}),J(tu,{setCurrentContent:e})]})}),J(L,{pt:0})]})},jl=({onSelectToken:e,onBack:t,showAllTokens:n=!1,excludedTokenSymbols:r=p})=>{let{t:i}=X(),{darkMode:a}=$(),{currentCurrency:o}=Ys(),s=V(`colors`,`vechain-kit-text-primary`),c=V(`colors`,`vechain-kit-text-secondary`),l=V(`colors`,`vechain-kit-text-tertiary`),{account:u}=Q(),{tokensWithBalance:d,sortedTokens:f}=Xs({address:u?.address??``}),[m,h]=K(``),g=G(()=>{let e=e=>r.includes(e),t;if(n){let n=f.filter(t=>Number(t.balance)>0&&!e(t.symbol)),r=[...f.filter(t=>Number(t.balance)===0&&!e(t.symbol))].sort((e,t)=>e.symbol.localeCompare(t.symbol));t=[...n,...r]}else t=d.filter(t=>!e(t.symbol));return t},[n,f,d,r]).filter(({symbol:e})=>e.toLowerCase().includes(m.toLowerCase()));return Y(q,{children:[Y(Z,{children:[J(R,{children:i(`Select Token`)}),J(Oo,{onClick:t}),J(I,{})]}),J(yt,{h:[`540px`,`auto`],p:0,children:J(F,{children:Y(B,{spacing:4,align:`stretch`,children:[Y(At,{size:`lg`,children:[J(kt,{placeholder:`Search token`,bg:a?`vechain-kit-overlay`:`vechain-kit-card`,borderRadius:`xl`,height:`56px`,pl:12,value:m,onChange:e=>h(e.target.value),"data-testid":`search-token-input`}),J(jt,{h:`56px`,w:`56px`,pl:4,children:J(Qr,{color:l})})]}),J(z,{fontSize:`lg`,fontWeight:`semibold`,color:s,mt:4,children:i(n?`All tokens`:`Your tokens`)}),g.length===0?Y(B,{spacing:2,py:8,children:[J(P,{as:ni,boxSize:12,color:l}),J(z,{fontSize:`lg`,color:s,children:i(`No tokens found`)}),J(z,{fontSize:`md`,color:c,children:i(`Try searching with a different term`)})]}):J(B,{spacing:2,align:`stretch`,children:g.map(t=>J(Tm,{symbol:t.symbol,amount:Number(t.balance),currencyValue:t.valueInCurrency,currentCurrency:o,onClick:()=>e(t)},t.address))})]})})}),J(L,{pt:0})]})},Ml=()=>{let{isolatedView:e,closeAccountModal:t}=$d();return{isolatedView:e,closeAccountModal:t}},Nl=({setCurrentContent:t,preselectedToken:n,initialAmount:r=``,initialToAddressOrDomain:i=``,onBack:a=()=>t(`main`)})=>{let{t:o}=X(),{darkMode:s,feeDelegation:c}=$(),{currentCurrency:l}=Ys(),u=V(`colors`,`vechain-kit-text-primary`),d=V(`colors`,`vechain-kit-text-secondary`),f=V(`colors`,`vechain-kit-text-tertiary`),m=V(`colors`,`vechain-kit-error`),h=V(`colors`,`vechain-kit-card`),{exchangeRates:g}=Ws(),{account:_}=Q(),{isolatedView:v}=Ml(),{tokensWithBalance:y}=Xs({address:_?.address??``}),b=G(()=>y.filter(e=>!p.includes(e.symbol)),[y]),[x,C]=K(()=>n&&!p.includes(n.symbol)?n:b[0]??null),[w,T]=K(!1);W(()=>{!x&&b.length>0&&C(b[0])},[b,x]);let{register:E,watch:D,setValue:O,setError:k,formState:{errors:A,isValid:ee},handleSubmit:te}=ra({defaultValues:{amount:r,toAddressOrDomain:i},mode:`onChange`}),{toAddressOrDomain:ne,amount:re}=D(),ie=vn(x);W(()=>{ie.current&&x&&ie.current.address!==x.address&&O(`amount`,``),ie.current=x},[x,O]);let ae=G(()=>x?qs(Gs(Number(re)*x.priceUsd,l,g),{currency:l}):``,[re,x,l,g]),{data:oe,isLoading:se}=Ko(ne),ce=()=>{x&&O(`amount`,x.balance)},le=()=>{a()},ue=async e=>{if(x){if(!(oe?.isValidAddressOrDomain&&(!oe?.domain||oe?.domain&&oe?.isPrimaryDomain))){k(`toAddressOrDomain`,{type:`manual`,message:o(`Invalid address or domain`)});return}if(x){let t=Cn(e.amount),n=c?.b3trTransfers?.minAmountInEther;if(x.symbol===`B3TR`&&typeof n==`number`&&n>0)try{if(t<Cn(String(n))){k(`amount`,{type:`manual`,message:o(`Minimum {{symbol}} transfer is {{min}}`,{symbol:x.symbol,min:n})});return}}catch{}if(t>Cn(x.balance)){k(`amount`,{type:`manual`,message:o(`Insufficient {{symbol}} balance`,{symbol:x.symbol})});return}}t({type:`send-token-summary`,props:{toAddressOrDomain:e.toAddressOrDomain,resolvedDomain:oe?.domain,resolvedAddress:oe?.address,amount:e.amount,selectedToken:x,formattedTotalAmount:ae,setCurrentContent:t}})}};return w?J(jl,{setCurrentContent:t,onSelectToken:e=>{C(e),T(!1)},onBack:()=>{T(!1)}}):Y(q,{children:[Y(Z,{children:[J(R,{children:o(`Send`)}),!v&&J(Oo,{onClick:le}),J(I,{})]}),J(F,{children:Y(B,{spacing:2,align:`stretch`,position:`relative`,children:[Y(N,{justify:`space-between`,children:[J(z,{fontSize:`md`,fontWeight:`bold`,color:u,children:o(`Amount`)}),Y(z,{cursor:`pointer`,_hover:{color:d,textDecoration:`underline`},onClick:ce,noOfLines:1,overflow:`hidden`,textOverflow:`ellipsis`,fontSize:`sm`,fontWeight:`medium`,color:d,children:[o(`Balance`),`:`,` `,Number(x?.balance??0).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})]})]}),J(j,{p:4,borderRadius:`2xl`,bg:h,children:J(B,{align:`stretch`,spacing:2,children:Y(St,{isInvalid:!!A.amount,children:[Y(N,{justify:`space-between`,children:[J(kt,{...E(`amount`,{required:o(`Amount is required`),pattern:{value:/^\d*\.?\d*$/,message:o(`Please enter a valid number`)},validate:e=>{if(!e)return!0;let t=parseFloat(e);if(isNaN(t))return o(`Please enter a valid number`);let n=c?.b3trTransfers?.minAmountInEther;return x?.symbol===`B3TR`&&typeof n==`number`&&n>0&&t<n?o(`Minimum {{symbol}} transfer is {{min}}`,{symbol:x.symbol,min:n}):!0}}),onChange:e=>{let t=e.target.value.trim();e.target.value=t,O(`amount`,t,{shouldValidate:!0})},placeholder:`0`,variant:`unstyled`,fontSize:`4xl`,fontWeight:`bold`,"data-testid":`tx-amount-input`,type:`number`,inputMode:`decimal`,color:u}),x?Y(M,{variant:`outline`,size:`sm`,borderRadius:`full`,px:6,color:d,borderColor:d,_hover:{bg:s?`whiteAlpha.300`:`blackAlpha.300`},onClick:()=>T(!0),leftIcon:S[x.symbol]?H.cloneElement(S[x.symbol],{boxSize:`20px`,borderRadius:`full`}):J(Ot,{src:e[x.symbol],alt:`${x.symbol} logo`,boxSize:`20px`,borderRadius:`full`,fallback:J(j,{boxSize:`20px`,borderRadius:`full`,bg:`whiteAlpha.200`,display:`flex`,alignItems:`center`,justifyContent:`center`,children:J(z,{fontSize:`8px`,fontWeight:`bold`,color:u,children:x.symbol.slice(0,3)})})}),children:[x.symbol,J(P,{as:Cr,boxSize:5,color:d})]}):Y(M,{variant:`outline`,size:`sm`,borderRadius:`full`,px:6,color:d,borderColor:d,_hover:{bg:s?`whiteAlpha.300`:`blackAlpha.300`,color:f},onClick:()=>T(!0),children:[o(`Select token`),J(P,{as:Cr,boxSize:5,color:d})]})]}),x&&J(N,{spacing:1,fontSize:`sm`,justifyContent:`space-between`,color:d,children:Y(z,{color:d,children:[`≈ `,ae]})}),A.amount&&J(z,{color:`#ef4444`,fontSize:`sm`,mt:1,"data-testid":`amount-error-msg`,children:A.amount.message})]})})}),J(N,{justify:`space-between`,mt:2,children:J(z,{fontSize:`md`,fontWeight:`bold`,color:u,children:o(`To`)})}),J(j,{borderRadius:`2xl`,bg:h,children:J(B,{align:`stretch`,spacing:2,p:4,width:`100%`,children:Y(St,{isInvalid:!!A.toAddressOrDomain,children:[J(kt,{...E(`toAddressOrDomain`,{required:o(`Address is required`)}),onChange:e=>{let t=e.target.value.trim(),n=t.includes(`.`)?ia(t):t;e.target.value=n,O(`toAddressOrDomain`,n,{shouldValidate:!0})},placeholder:o(`Type the receiver address or domain`),_placeholder:{fontSize:`md`,fontWeight:`normal`},fontSize:`lg`,fontWeight:`bold`,color:u,variant:`unstyled`,"data-testid":`tx-address-input`}),A.toAddressOrDomain&&J(z,{color:m,fontSize:`sm`,"data-testid":`address-error-msg`,children:A.toAddressOrDomain.message})]})})})]})}),J(L,{children:J(M,{variant:`vechainKitPrimary`,isDisabled:!x||!ee,isLoading:se,onClick:te(ue),"data-testid":`send-button`,children:o(x?`Send`:`Select Token`)})})]})},Pl=({setCurrentContent:e,toAddressOrDomain:t,resolvedDomain:n,resolvedAddress:r,amount:i,selectedToken:a,formattedTotalAmount:o})=>{let{t:s}=X(),{account:c,connection:u,connectedWallet:d}=Q(),{data:f}=ks(r??``),{network:p,feeDelegation:m}=$(),{preferences:h}=Sm(),{isolatedView:g,closeAccountModal:_}=Ml(),v=V(`colors`,`vechain-kit-text-primary`),y=V(`colors`,`vechain-kit-text-secondary`),{data:b}=Np(c?.address??``,d?.address??``,3),{open:x}=kf(),S=G(()=>f||l(r||t),[f,p.type,r,t]),C=async()=>{if(b){x();return}try{a.symbol===`VET`?await ee():await T()}catch(e){console.error(s(`Transaction failed:`),e)}},w=H.useCallback(t=>{e({type:`successful-operation`,props:{setCurrentContent:e,txId:t,title:s(`Transaction successful`),onDone:()=>{g?_():e(`main`)},showSocialButtons:!0}})},[e,s,g,_]),{sendTransaction:T,txReceipt:E,error:D,isWaitingForWalletConfirmation:O,isTransactionPending:k,clauses:A}=Xp({fromAddress:c?.address??``,receiverAddress:r||t,amount:i,tokenAddress:a.address,tokenName:a.symbol,onError:e=>{fe(e??``)}}),{sendTransaction:ee,txReceipt:te,error:ne,isWaitingForWalletConfirmation:re,isTransactionPending:ie,clauses:ae}=Qp({fromAddress:c?.address??``,receiverAddress:r||t,amount:i,onError:e=>{fe(e??``)}}),oe=H.useCallback(()=>a.symbol===`VET`?te:E,[a.symbol,te,E]),se=O||re,ce=se||k||ie,[le,ue]=H.useState(!1);H.useEffect(()=>{let e=oe();if(!e||e.reverted||le||ce)return;let t=e.meta.txID;t&&(ue(!0),w(t))},[oe,le,ce,w]),H.useEffect(()=>{ce&&ue(!1)},[ce]);let de=()=>{e({type:`send-token`,props:{setCurrentContent:e,preselectedToken:a,initialAmount:i,initialToAddressOrDomain:t}})},fe=e=>{console.error(`Transaction failed:`,e)},[pe,me]=H.useState(null),[he,ge]=H.useState(null),_e=h.availableGasTokens.length>0&&(u.isConnectedWithPrivy||u.isConnectedWithVeChain)&&!m?.delegatorUrl,{data:ve,isLoading:ye,error:be,refetch:xe}=Cm({clauses:a.symbol===`VET`?ae:A,tokens:pe?[pe]:h.availableGasTokens,sendingAmount:i,sendingTokenSymbol:a.symbol,enabled:_e&&!!m?.genericDelegatorUrl}),Se=ve?.usedToken,Ce=(ye||!ve)&&u.isConnectedWithPrivy&&!m?.delegatorUrl,we=H.useCallback(e=>{me(e),ge(e),setTimeout(()=>xe(),100)},[xe]),Te=!!Se&&!be;return H.useEffect(()=>{be&&pe&&me(null)},[be,pe]),Y(q,{children:[Y(Z,{children:[J(R,{children:`Send`}),J(Oo,{isDisabled:ce,onClick:de}),J(I,{isDisabled:ce})]}),J(F,{children:J(B,{spacing:6,align:`stretch`,w:`full`,children:Y(B,{spacing:4,w:`full`,children:[Y(j,{w:`full`,children:[J(z,{fontSize:`sm`,mb:2,color:y,children:s(`From`)}),J(Em,{address:c?.address??``,domain:c?.domain,imageSrc:c?.image??``,imageAlt:`From account`,balance:Number(a.balance),tokenAddress:a.address})]}),Y(j,{w:`full`,children:[J(z,{fontSize:`sm`,mb:2,color:y,children:s(`To`)}),J(Em,{address:r||t,domain:n,imageSrc:S??``,imageAlt:`To account`,tokenAddress:a.address})]}),u.isConnectedWithPrivy&&J(Nm,{estimation:ve,isLoading:ye,isLoadingTransaction:ce,onTokenChange:we,clauses:a.symbol===`VET`?ae:A,userSelectedToken:he}),Y(B,{spacing:0,w:`full`,justifyContent:`flex-start`,children:[J(z,{fontSize:`sm`,fontWeight:`light`,textAlign:`left`,w:`full`,color:y,children:s(`Amount`)}),Y(N,{justifyContent:`flex-start`,w:`full`,children:[Y(z,{fontSize:`xl`,fontWeight:`semibold`,textAlign:`left`,"data-testid":`send-summary-amount`,color:v,children:[Number(i).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2}),` `,a.symbol]}),Y(z,{color:y,children:[`≈ `,o]})]})]})]})})}),J(L,{children:J(Am,{transactionError:a.symbol===`VET`?ne:D,isSubmitting:ce,isTxWaitingConfirmation:se,onConfirm:C,transactionPendingText:s(`Sending...`),txReceipt:oe(),buttonText:s(`Confirm`),isDisabled:ce||Ce,gasEstimationError:be,hasEnoughGasBalance:Te,isLoadingGasEstimation:ye,showGasEstimationError:!m?.delegatorUrl&&u.isConnectedWithPrivy,context:`send`})})]})},Fl=({setCurrentContent:e})=>{let{t}=X(),{account:n}=Q(),{isolatedView:r}=Ml(),i=V(`colors`,`vechain-kit-text-primary`),a=V(`colors`,`vechain-kit-text-secondary`);return Y(q,{children:[Y(Z,{children:[J(R,{children:t(`Receive`)}),!r&&J(Oo,{onClick:()=>e(`main`)}),J(I,{})]}),Y(yt,{maxW:`container.lg`,children:[J(F,{children:Y(B,{spacing:4,align:`center`,w:`full`,children:[J(aa,{value:n?.address??``,size:200,removeQrCodeBehindLogo:!0,eyeRadius:4,logoPaddingStyle:`circle`,style:{borderRadius:`16px`}}),J(ko,{wallet:n,style:{w:`85%`}}),J(z,{fontSize:`sm`,textAlign:`center`,color:i,children:t(`Copy your address or scan this QR code`)}),J(z,{fontSize:`xs`,textAlign:`center`,color:a,children:t(`This address only supports VeChain assets.`)})]})}),J(L,{pt:0})]})]})},Il=({quotes:t,selectedQuote:n,toTokenAddress:r,onSelectQuote:i,onBack:a})=>{let{t:o}=X(),{darkMode:s}=$(),{currentCurrency:c}=Ys(),{account:l}=Q(),{exchangeRates:u,prices:d}=Ws(),{tokens:f}=Xs({address:l?.address??``}),[p,m]=K(!1),h=G(()=>r&&f.find(e=>O(e.address,r))||null,[r,f]),g=t.filter(e=>!e.reverted),_=t.filter(e=>e.reverted),v=G(()=>g.length===0?null:g.reduce((e,t)=>{let n=BigInt(e.outputAmount||`0`);return BigInt(t.outputAmount||`0`)>n?t:e}),[g]),y=G(()=>{let e=r&&d[r]||0;return g.map(t=>{let n=Ii(BigInt(t.outputAmount||`0`)),r=Number(n)*e,i=Gs(r,c,u),a=v&&t.aggregatorName===v.aggregatorName,o=0;if(v&&!a){let e=BigInt(v.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)})},[g,r,d,c,u,v]);return Y(q,{children:[Y(Z,{children:[J(R,{children:o(`Found following rates`)}),J(Oo,{onClick:a}),J(I,{})]}),J(yt,{h:[`540px`,`auto`],p:0,children:J(F,{children:Y(B,{spacing:6,align:`stretch`,children:[y.length>0&&J(B,{spacing:2,align:`stretch`,children:y.map(t=>{let r=n?.aggregatorName===t.aggregatorName;return Y(j,{p:2.5,borderRadius:`xl`,bg:s?`#00000038`:`gray.50`,borderWidth:1,borderColor:r?`blue.500`:s?`whiteAlpha.200`:`gray.200`,cursor:`pointer`,onClick:()=>i(t),_hover:{borderColor:r?`blue.500`:s?`whiteAlpha.400`:`gray.300`},position:`relative`,children:[(t.isBest||!t.isBest&&t.percentageDiff<0)&&J(j,{position:`absolute`,top:-1,left:0,zIndex:1,children:t.isBest?J(ct,{colorScheme:`purple`,borderRadius:`sm`,fontSize:`2xs`,px:1.5,py:.5,borderTopLeftRadius:`xl`,borderBottomRightRadius:`md`,children:o(`Best`)}):Y(ct,{colorScheme:`red`,borderRadius:`xs`,fontSize:`2xs`,px:1.5,py:.5,borderTopLeftRadius:`xl`,borderBottomRightRadius:`md`,children:[t.percentageDiff.toFixed(2),`%`]})}),Y(B,{align:`stretch`,spacing:1.5,marginTop:4,children:[Y(N,{justify:`space-between`,align:`center`,children:[Y(N,{spacing:1.5,align:`center`,children:[t.aggregator.getIcon(`20px`),J(z,{fontSize:`md`,fontWeight:`bold`,children:t.aggregatorName})]}),J(N,{align:`center`,spacing:1.5,children:h&&Y(q,{children:[S[h.symbol]?H.cloneElement(S[h.symbol],{boxSize:`24px`,borderRadius:`full`}):e[h.symbol]?J(Ot,{src:e[h.symbol],alt:`${h.symbol} logo`,boxSize:`24px`,borderRadius:`full`}):null,J($t,{label:Number(t.outputAmountFormatted).toLocaleString(void 0,{maximumFractionDigits:18}),hasArrow:!0,placement:`top`,children:Y(z,{fontSize:`md`,fontWeight:`bold`,textAlign:`right`,whiteSpace:`nowrap`,children:[Number(t.outputAmountFormatted).toLocaleString(void 0,{minimumFractionDigits:4}),` `,h.symbol]})})]})})]}),Y(N,{justify:`space-between`,align:`center`,children:[J(z,{fontSize:`xs`,color:s?`whiteAlpha.500`:`blackAlpha.500`,children:t.gasCostVTHO&&t.gasCostVTHO>0?`Gas: ${t.gasCostVTHO.toLocaleString(void 0,{maximumFractionDigits:2})} VTHO`:``}),t.valueUsd>0&&Y(z,{fontSize:`xs`,color:s?`whiteAlpha.600`:`blackAlpha.600`,textAlign:`right`,whiteSpace:`nowrap`,children:[`≈ `,qs(t.valueInCurrency,{currency:c})]})]})]})]},t.aggregatorName)})}),_.length>0&&Y(j,{children:[Y(N,{justify:`space-between`,cursor:`pointer`,onClick:()=>m(!p),py:2,children:[Y(z,{fontSize:`sm`,color:s?`whiteAlpha.600`:`blackAlpha.600`,children:[_.length,` `,o(`rate`),_.length===1?``:`s`,` `,o(`unavailable`)]}),J(P,{as:p?Er:Cr,boxSize:4,color:s?`whiteAlpha.600`:`blackAlpha.600`})]}),J(_t,{in:p,animateOpacity:!0,children:J(B,{spacing:2,align:`stretch`,pt:2,children:_.map(e=>J(j,{p:2,borderRadius:`xl`,bg:s?`#00000038`:`gray.50`,opacity:.6,children:Y(N,{justify:`space-between`,children:[Y(N,{spacing:2,align:`center`,children:[e.aggregator.getIcon(`20px`),J(z,{fontSize:`md`,fontWeight:`medium`,children:e.aggregatorName})]}),J(z,{fontSize:`xs`,color:s?`whiteAlpha.500`:`blackAlpha.500`,children:o(`Unable to fetch the price`)})]})},e.aggregatorName))})})]}),y.length===0&&_.length===0&&J(B,{spacing:2,py:8,color:s?`whiteAlpha.600`:`blackAlpha.600`,children:J(z,{fontSize:`lg`,children:o(`No quotes available`)})})]})})}),J(L,{})]})},Ll=e=>e===`0x`||e===Ui||!e,Rl=(e,t,n,r)=>{if(!e||!t||!n||!r)return null;let i=t.toLowerCase(),a=n.toLowerCase(),o=r.toLowerCase(),s=Ll(n),c=Ll(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=xi.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=Ni({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}},zl=({setCurrentContent:t,fromTokenAddress:n,toTokenAddress:r})=>{let{t:i}=X(),{account:a,connection:o}=Q(),{currentCurrency:s}=Ys(),{network:c,feeDelegation:l,darkMode:u}=$(),{isolatedView:d,closeAccountModal:f}=Ml(),m=V(`colors`,`vechain-kit-card`),h=V(`colors`,`vechain-kit-text-primary`),g=V(`colors`,`vechain-kit-text-secondary`),_=V(`colors`,`vechain-kit-text-tertiary`),v=V(`colors`,`vechain-kit-button-primary-bg`),b=V(`colors`,`vechain-kit-button-primary-color`),{preferences:x}=Sm(),{sortedTokens:C}=Xs({address:a?.address??``}),[w,T]=K(`main`),[E,D]=K(null),[k,A]=K(null),[ee,te]=K(``),[ne,re]=K(!1),[ie,ae]=K(1),[oe,se]=K(`1`),[ce,le]=K(null),[ue,de]=H.useState(null),[fe,pe]=H.useState(null),[me,he]=H.useState([]),{prices:ge,exchangeRates:_e}=Ws(),ve=ie===1;H.useEffect(()=>{se(ie===1?`1`:ie===.5?`0.5`:ie===3?`3`:ie.toString())},[ie]),H.useEffect(()=>{if(C.length!==0){if((n||r)&&(!E||!k)){if(n&&!E){let e=C.find(e=>O(e.address,n));e&&!p.includes(e.symbol)&&D(e)}if(r&&!k){let e=C.find(e=>O(e.address,r));e&&!p.includes(e.symbol)&&A(e)}return}if(!E&&!k){let e=C.find(e=>e.symbol===`VET`);e&&D(e);let t=C.find(e=>e.symbol===`B3TR`);if(!t)try{let e=y(c.type).b3trContractAddress;e&&(t=C.find(t=>O(t.address,e)))}catch(e){console.warn(`Failed to get B3TR address from config:`,e)}t&&A(t)}}},[C,E,k,n,r,c.type]),H.useEffect(()=>{le(null)},[E?.address,k?.address,ee]);let{bestQuote:ye,quotes:be,isLoading:xe,from:Se,to:Ce}=_l(E,k,ee,a?.address??``,ie,!!E&&!!k&&Number(ee)>0),we=G(()=>{if(!ee||Number(ee)<=0||!Se)return 0n;try{return Vi(ee,Se.decimals)}catch{return 0n}},[ee,Se?.decimals]),Te=ce||ye,Ee=G(()=>{if(!Te?.outputAmount||!Ce)return`0`;try{return Li(Te.outputAmount,Ce.decimals)}catch{return`0`}},[Te,Ce?.decimals]),De=G(()=>{if(!E||!ee)return 0;let e=ge[E.address]||0;return Gs(Number(ee)*e,s,_e)},[E?.address,ee,ge,s,_e]),Oe=G(()=>{if(!k||!Ee)return 0;let e=ge[k.address]||0;return Gs(Number(Ee)*e,s,_e)},[k?.address,Ee,ge,s,_e]),ke=G(()=>!E||!k||!a?.address||we===0n?null:{fromTokenAddress:E.address,toTokenAddress:k.address,amountIn:we.toString(),userAddress:a.address,slippageTolerance:ie},[E,k,a?.address,we,ie]),Ae=Te?.gasCostVTHO??0;H.useEffect(()=>{(async()=>{if(!Te||!ke||!Te.aggregator){he([]);return}try{he(await Te.aggregator.buildSwapTransaction(ke,Te))}catch(e){console.error(`Failed to build swap clauses for gas estimation:`,e),he([])}})()},[Te,ke]);let je=x.availableGasTokens.length>0&&(o.isConnectedWithPrivy||o.isConnectedWithVeChain)&&!l?.delegatorUrl,{data:Me,isLoading:Ne,error:Pe,refetch:Fe}=Cm({clauses:me,tokens:ue?[ue]:x.availableGasTokens,sendingAmount:ee,sendingTokenSymbol:E?.symbol??``,enabled:je&&!!l?.genericDelegatorUrl&&me.length>0}),Ie=Me?.usedToken,Le=(Ne||!Me)&&o.isConnectedWithPrivy&&!l?.delegatorUrl,Re=H.useCallback(e=>{de(e),pe(e),setTimeout(()=>Fe(),100)},[Fe]),ze=!!Ie&&!Pe;H.useEffect(()=>{Pe&&ue&&de(null)},[Pe,ue]);let{executeSwap:Be,isTransactionPending:Ve,isWaitingForWalletConfirmation:He,txReceipt:Ue,status:We,error:Ge}=Zc(ke,Te),Ke=U(()=>{let e=Ue?.meta.txID??``,n=i(`Swap successful`,{defaultValue:`Swap successful`}),r;if(Ue&&E&&k&&a?.address){let e=Rl(Ue,a.address,E.address,k.address);if(e&&Se&&Ce)try{let t=Se.decimals,n=Ce.decimals,a=Li(e.fromAmount,t),o=Li(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})};r=i(`You successfully swapped {fromAmount} {fromSymbol} for {toAmount} {toSymbol}`,{fromAmount:s(a),fromSymbol:E.symbol,toAmount:s(o),toSymbol:k.symbol,defaultValue:`You successfully swapped ${s(a)} ${E.symbol} for ${s(o)} ${k.symbol}`})}catch(e){console.warn(`Failed to format swap amounts:`,e)}}!r&&E&&k&&(r=i(`You successfully swapped {fromToken} for {toToken}`,{fromToken:E.symbol,toToken:k.symbol,defaultValue:`You successfully swapped ${E.symbol} for ${k.symbol}`})),t({type:`successful-operation`,props:{setCurrentContent:t,txId:e,title:n,description:r,onDone:()=>{d?f():t(`main`)},showSocialButtons:!0}})},[E,k,ee,Te,Ue,a?.address,t,i,d,f]),qe=U(e=>{let t=typeof e==`string`?e:e.message;console.error(`Swap failed:`,t)},[E,k,ee]),[Je,Ye]=H.useState(!1);H.useEffect(()=>{if(We===`ready`){Ye(!1);return}Je||(We===`success`&&Ue&&!Ue.reverted?(Ye(!0),Ke()):We===`error`&&Ge?qe(Ge?.reason||Ge?.message||String(Ge)):Ue?.reverted&&qe(`Transaction reverted`))},[We,Ue,Ge,Ke,qe,Je]);let Xe=U(e=>{if(D(e),e.symbol===`VET`&&!k){let e=C.find(e=>e.symbol===`B3TR`);if(!e)try{let t=y(c.type).b3trContractAddress;t&&(e=C.find(e=>O(e.address,t)))}catch(e){console.warn(`Failed to get B3TR address from config:`,e)}e&&A(e)}T(`main`)},[k,C,c.type]),Ze=U(e=>{A(e),T(`main`)},[]),Qe=U(e=>{(/^\d*\.?\d*$/.test(e)||e===``)&&te(e)},[]),$e=U(()=>{E&&te(E.balance)},[E]),et=t=>{if(!t)return null;let n=S[t.symbol],r=e[t.symbol];return{symbol:t.symbol,logoComponent:n,logoUrl:r,balance:t.balance,value:t.valueInCurrency}},tt=et(E),nt=et(k);return w===`select-from-token`?J(jl,{setCurrentContent:t,onSelectToken:Xe,onBack:()=>T(`main`),showAllTokens:!1}):w===`select-quote`?J(Il,{quotes:be,selectedQuote:Te,toTokenAddress:k?.address??null,onSelectQuote:e=>{le(e),T(`main`)},onBack:()=>T(`main`)}):w===`select-to-token`?J(jl,{setCurrentContent:t,onSelectToken:Ze,onBack:()=>T(`main`),showAllTokens:!0}):Y(q,{children:[Y(Z,{children:[J(R,{children:i(`Swap`)}),!d&&J(Oo,{onClick:()=>t(`main`),isDisabled:Ve||He}),J(I,{isDisabled:Ve||He})]}),J(F,{children:Y(B,{spacing:2,align:`stretch`,w:`full`,children:[Y(N,{justify:`space-between`,children:[J(z,{fontSize:`md`,fontWeight:`bold`,color:h,children:i(`From`)}),tt&&Y(z,{cursor:`pointer`,_hover:{color:g,textDecoration:`underline`},onClick:$e,noOfLines:1,overflow:`hidden`,textOverflow:`ellipsis`,fontSize:`sm`,fontWeight:`medium`,color:g,children:[i(`Balance`),`:`,` `,Number(tt.balance??0).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})]})]}),J(j,{p:4,borderRadius:`2xl`,bg:m,children:Y(B,{align:`stretch`,spacing:2,children:[Y(N,{justify:`space-between`,children:[J(kt,{placeholder:`0`,value:ee,onChange:e=>Qe(e.target.value),fontSize:`4xl`,fontWeight:`bold`,variant:`unstyled`,"data-testid":`swap-amount-input`,type:`number`,inputMode:`decimal`,color:tt&&ee&&Number(ee)>Number(tt.balance)?`red.500`:h}),tt?Y(M,{onClick:()=>T(`select-from-token`),variant:`outline`,size:`sm`,borderRadius:`full`,px:6,color:g,borderColor:g,_hover:{bg:u?`whiteAlpha.300`:`blackAlpha.300`},leftIcon:tt.logoComponent?H.cloneElement(tt.logoComponent,{boxSize:`20px`,borderRadius:`full`}):tt.logoUrl?J(Ot,{src:tt.logoUrl,alt:`${tt.symbol} logo`,boxSize:`20px`,borderRadius:`full`,fallback:J(j,{boxSize:`20px`,borderRadius:`full`,bg:`whiteAlpha.200`,display:`flex`,alignItems:`center`,justifyContent:`center`,children:J(z,{fontSize:`8px`,fontWeight:`bold`,color:h,children:tt.symbol.slice(0,3)})})}):void 0,children:[tt.symbol,J(P,{as:Cr,boxSize:5,color:g})]}):Y(M,{onClick:()=>T(`select-from-token`),variant:`outline`,size:`sm`,borderRadius:`full`,px:6,color:g,borderColor:g,_hover:{bg:u?`whiteAlpha.300`:`blackAlpha.300`,color:_},children:[i(`Select token`),J(P,{as:Cr,boxSize:5,color:g})]})]}),J(N,{spacing:1,fontSize:`sm`,justifyContent:`space-between`,color:g,children:J(N,{spacing:2,alignItems:`center`,children:Y(z,{color:g,children:[`≈`,` `,qs(De??0,{currency:s})]})})})]})}),J(N,{justify:`space-between`,mt:4,children:J(z,{fontSize:`md`,fontWeight:`bold`,color:h,children:i(`To`)})}),J(j,{borderRadius:`2xl`,bg:m,p:4,children:Y(B,{align:`stretch`,spacing:2,width:`100%`,children:[Y(N,{justify:`space-between`,alignItems:`center`,children:[J(kt,{value:Number(Ee).toLocaleString(void 0,{maximumFractionDigits:Number(Ee)>1e4?0:2}),readOnly:!0,variant:`unstyled`,fontSize:`4xl`,fontWeight:`bold`,"data-testid":`swap-output-amount`,color:h}),nt?Y(M,{onClick:()=>T(`select-to-token`),variant:`outline`,size:`sm`,borderRadius:`full`,px:6,color:g,borderColor:g,_hover:{bg:u?`whiteAlpha.300`:`blackAlpha.300`},leftIcon:nt.logoComponent?H.cloneElement(nt.logoComponent,{boxSize:`20px`,borderRadius:`full`}):nt.logoUrl?J(Ot,{src:nt.logoUrl,alt:`${nt.symbol} logo`,boxSize:`20px`,borderRadius:`full`,fallback:J(j,{boxSize:`20px`,borderRadius:`full`,bg:`whiteAlpha.200`,display:`flex`,alignItems:`center`,justifyContent:`center`,children:J(z,{fontSize:`8px`,fontWeight:`bold`,color:h,children:nt.symbol.slice(0,3)})})}):void 0,children:[nt.symbol,J(P,{as:Cr,boxSize:5,color:g})]}):Y(M,{onClick:()=>T(`select-to-token`),variant:`outline`,size:`sm`,borderRadius:`full`,px:6,color:g,borderColor:g,_hover:{bg:u?`whiteAlpha.300`:`blackAlpha.300`,color:_},children:[i(`Select token`),J(P,{as:Cr,boxSize:5,color:g})]})]}),Y(N,{spacing:1,fontSize:`sm`,justifyContent:`space-between`,color:g,children:[J(N,{spacing:2,alignItems:`center`,children:Y(z,{color:g,children:[`≈`,` `,qs(Oe??0,{currency:s})]})}),nt&&Y(z,{noOfLines:1,overflow:`hidden`,textOverflow:`ellipsis`,fontSize:`sm`,fontWeight:`medium`,color:g,children:[i(`Balance`),`:`,` `,Number(nt.balance??0).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})]})]})]})}),J(_t,{in:ne&&!!Te,animateOpacity:!0,children:Y(B,{spacing:1,align:`stretch`,p:4,borderRadius:`2xl`,bg:m,children:[Te&&Y(N,{justify:`space-between`,children:[Y(z,{fontSize:`xs`,color:g,children:[i(`Source`),`:`]}),J(M,{variant:`outline`,size:`xs`,borderRadius:`full`,px:3,h:`auto`,py:1,cursor:`pointer`,onClick:()=>T(`select-quote`),color:g,borderColor:g,_hover:{bg:u?`whiteAlpha.300`:`blackAlpha.300`},leftIcon:Te.aggregator?.getIcon(`12px`),children:J(z,{fontSize:`xs`,color:h,children:Te.aggregatorName})})]}),Y(B,{align:`stretch`,spacing:2,children:[Y(N,{justify:`space-between`,children:[Y(z,{fontSize:`xs`,color:g,children:[i(`Slippage tolerance`),`:`]}),Y(z,{fontSize:`xs`,fontWeight:`medium`,color:h,children:[ie,`%`]})]}),J(B,{spacing:3,align:`stretch`,pt:2,children:Y(N,{spacing:2,children:[J(M,{size:`sm`,variant:`outline`,onClick:()=>{ae(1)},flex:`0 0 auto`,minW:`60px`,borderRadius:`md`,fontSize:`xs`,bg:ve?v:`transparent`,color:ve?b:g,borderColor:ve?v:g,_hover:{bg:ve?v:u?`whiteAlpha.300`:`blackAlpha.300`,opacity:ve?.8:1},children:`Auto`}),J(M,{size:`sm`,variant:`outline`,onClick:()=>{ae(.5)},flex:`0 0 auto`,minW:`60px`,borderRadius:`md`,fontSize:`xs`,bg:ie===.5?v:`transparent`,color:ie===.5?b:g,borderColor:ie===.5?v:g,_hover:{bg:ie===.5?v:u?`whiteAlpha.300`:`blackAlpha.300`,opacity:ie===.5?.8:1},children:`0.5%`}),J(M,{size:`sm`,variant:`outline`,onClick:()=>{ae(3)},flex:`0 0 auto`,minW:`60px`,borderRadius:`md`,fontSize:`xs`,bg:ie===3?v:`transparent`,color:ie===3?b:g,borderColor:ie===3?v:g,_hover:{bg:ie===3?v:u?`whiteAlpha.300`:`blackAlpha.300`,opacity:ie===3?.8:1},children:`3%`}),Y(At,{size:`sm`,flex:1,children:[J(kt,{value:oe,onChange:e=>{let t=e.target.value;if(/^\d*\.?\d*$/.test(t)||t===``)if(se(t),t!==``){let e=parseFloat(t);!isNaN(e)&&e>=0&&e<=100&&ae(e)}else ae(1)},placeholder:`1`,borderRadius:`md`,textAlign:`right`,pr:8,fontSize:`xs`,color:h}),J(Mt,{width:`2rem`,pointerEvents:`none`,children:J(z,{fontSize:`2xs`,color:g,children:`%`})})]})]})})]}),Y(N,{justify:`space-between`,children:[Y(z,{fontSize:`xs`,color:g,children:[i(`Fee`),`:`]}),J(z,{fontSize:`xs`,fontWeight:`medium`,color:h,children:Ae>0?`${Ae.toLocaleString(void 0,{maximumFractionDigits:2})} VTHO`:`-`})]})]})}),Te&&J(j,{minH:`24px`,display:`flex`,alignItems:`center`,justifyContent:`center`,children:J(M,{variant:`ghost`,size:`xs`,onClick:()=>re(!ne),rightIcon:J(P,{color:_,_hover:{color:g},as:ne?gr:fr}),fontSize:`xs`,fontWeight:`light`,color:_,_hover:{color:g},children:i(ne?`Hide`:`Show Advanced Options`)})}),me.length>0&&o.isConnectedWithPrivy&&J(Nm,{estimation:Me,isLoading:Ne,isLoadingTransaction:Ve,onTokenChange:Re,clauses:me,userSelectedToken:fe})]})}),J(L,{children:J(Am,{buttonText:i(xe?`Loading quote...`:`Swap`),onConfirm:Be,isSubmitting:Ve,isTxWaitingConfirmation:He,transactionPendingText:i(`Swapping...`),txReceipt:Ue,transactionError:Ge,onError:e=>{qe(e)},isDisabled:!E||!k||!ee||Number(ee)<=0||xe||!Te||Te?.reverted===!0||!!(tt&&ee&&Number(ee)>Number(tt.balance))||Le,gasEstimationError:Pe,hasEnoughGasBalance:ze,isLoadingGasEstimation:Ne,showGasEstimationError:!l?.delegatorUrl&&o.isConnectedWithPrivy,context:`transaction`})})]})},Bl=({setCurrentContent:e,onBack:t=()=>e(`settings`),initialContentSource:n=`settings`})=>{let{t:r}=X(),{isolatedView:i}=Ml(),a=V(`colors`,`vechain-kit-text-primary`),o=V(`colors`,`vechain-kit-text-secondary`),s=()=>{t()};return Y(q,{children:[Y(Z,{children:[J(R,{"data-testid":`modal-title`,children:r(`Choose your account name`)}),!i&&J(Oo,{onClick:s}),J(I,{})]}),J(F,{children:Y(B,{spacing:6,align:`center`,py:8,children:[J(P,{as:ri,boxSize:16,color:o}),Y(B,{spacing:2,children:[J(z,{fontSize:`lg`,fontWeight:`500`,textAlign:`center`,color:a,children:r(`Finally say goodbye to 0x addresses`)}),J(z,{fontSize:`md`,color:o,textAlign:`center`,px:4,children:r(`Name your account to make it easier to exchange assets`)})]})]})}),J(L,{children:J(M,{variant:`vechainKitPrimary`,onClick:()=>e({type:`choose-name-search`,props:{name:``,setCurrentContent:e,initialContentSource:n}}),"data-testid":`choose-name-button`,children:r(`Choose name`)})})]})},Vl=({domain:e,isCurrentDomain:t,onSelect:n})=>{let{connection:i}=Q(),{t:a}=X(),o=kc(e.name,i.network),s=V(`colors`,`vechain-kit-card`),c=V(`colors`,`vechain-kit-card-hover`),u=V(`colors`,`vechain-kit-border`),d=V(`colors`,`vechain-kit-text-primary`),f=V(`colors`,`vechain-kit-text-secondary`),p=V(`colors`,`vechain-kit-card`);return J(Ft,{p:4,bg:s,borderRadius:`xl`,cursor:t?`default`:`pointer`,opacity:t?.7:1,border:`1px solid ${u}`,_hover:{bg:t?c:s,borderColor:u},onClick:()=>!t&&n(e.name),transition:`all 0.2s`,children:Y(N,{spacing:3,align:`center`,children:[J(km,{props:{width:`40px`,height:`40px`,src:o.image??l(e.name),alt:e.name}}),Y(B,{align:`start`,spacing:0,flex:1,children:[J(z,{color:d,fontSize:`md`,fontWeight:`500`,children:r(e.name,24,0)}),t&&J(z,{fontSize:`sm`,color:f,children:a(`Current domain`)})]}),t&&J(Zt,{size:`sm`,bg:p,color:d,px:3,py:1,borderRadius:`full`,children:a(`Current`)})]})},e.name)},Hl=({onUnset:e})=>{let t=V(`colors`,`vechain-kit-card`),n=V(`colors`,`vechain-kit-card-hover`),r=V(`colors`,`vechain-kit-border`),i=V(`colors`,`vechain-kit-text-primary`),a=V(`colors`,`vechain-kit-text-secondary`),o=V(`colors`,`vechain-kit-error`),{t:s}=X();return J(Ft,{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:Y(N,{spacing:3,align:`center`,children:[J(j,{width:`40px`,height:`40px`,borderRadius:`full`,display:`flex`,alignItems:`center`,justifyContent:`center`,bg:t,children:J(P,{as:ii,fontSize:`18px`,color:o})}),Y(B,{align:`start`,spacing:0,flex:1,children:[J(z,{color:i,fontSize:`md`,fontWeight:`500`,children:s(`Unset current domain`)}),J(z,{fontSize:`sm`,color:a,children:s(`Remove your current domain name`)})]})]})},`unset-domain-list-item`)},Ul=({domains:e,onDomainSelect:t,onUnsetDomain:n,isLoading:r})=>{let{t:i}=X(),{account:a}=Q(),o=V(`colors`,`vechain-kit-card`),s=V(`colors`,`vechain-kit-card-hover`),c=V(`colors`,`vechain-kit-text-primary`),l=V(`colors`,`vechain-kit-text-secondary`);return e.length===0||r?null:J(et,{allowToggle:!0,children:J(nt,{border:`none`,children:({isExpanded:u})=>Y(q,{children:[Y(tt,{bg:o,borderRadius:`xl`,_hover:{bg:s},opacity:r?.7:1,transition:`all 0.2s`,disabled:r,children:[J(j,{flex:`1`,textAlign:`left`,py:2,children:J(z,{fontWeight:`500`,color:c,children:r?i(`Loading your domains...`):`${i(`Your existing domains`)} (${e.length})`})}),J(P,{as:u?Er:Cr,fontSize:`20px`,color:l})]}),J(rt,{pb:4,pt:2,children:Y(Pt,{spacing:2,children:[e.map(e=>J(Vl,{domain:e,isCurrentDomain:e.name===a?.domain,onSelect:t},e.name)),a?.domain&&J(Hl,{onUnset:n})]})})]})})})},Wl=({name:e,setCurrentContent:t,initialContentSource:n=`settings`})=>{let{t:r}=X(),{account:i}=Q(),{darkMode:a}=$(),{isolatedView:o}=Ml(),[s,c]=K(ia(e)),[l,u]=K(null),[d,f]=K(!1),[p,m]=K(!1),[h,g]=K(!1),_=V(`colors`,`vechain-kit-error`),v=V(`colors`,`vechain-kit-success`),y=V(`colors`,`vechain-kit-text-secondary`),{data:b,isLoading:x}=Yo(s),{data:S,isLoading:C}=Ko(`${s}.veworld.vet`),{data:w,isLoading:T}=ls(s),{data:E,isLoading:D}=ms(i?.address,``),O=x||C||T;W(()=>{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,O]);let k=()=>{p&&!l&&t({type:`choose-name-summary`,props:{fullDomain:s+`.veworld.vet`,isOwnDomain:d,setCurrentContent:t,initialContentSource:n}})},A=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}})},ee=()=>{t({type:`choose-name-summary`,props:{fullDomain:``,domainType:``,isOwnDomain:!1,isUnsetting:!0,setCurrentContent:t,initialContentSource:n}})},te=()=>{t(n)};return Y(q,{children:[Y(Z,{children:[J(R,{"data-testid":`modal-title`,children:r(`Choose Name`)}),!o&&J(Oo,{onClick:te}),J(I,{})]}),J(F,{children:Y(B,{spacing:4,align:`stretch`,children:[J(Ul,{domains:E?.domains||[],onDomainSelect:A,onUnsetDomain:ee,isLoading:D}),Y(At,{size:`lg`,children:[J(kt,{placeholder:r(`Enter your name`),value:s,onChange:e=>{c(ia(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`}),J(Mt,{width:`auto`,paddingRight:`12px`,h:`full`,children:J(j,{mr:4,fontSize:`sm`,color:y,children:`.veworld.vet`})})]}),l&&h&&J(z,{color:_,fontSize:`sm`,"data-testid":`domain-availability-status`,children:l}),!l&&h&&s.length>=3&&J(z,{fontSize:`sm`,color:p?v:_,fontWeight:`500`,"data-testid":`domain-availability-status`,children:r(d?`YOU OWN THIS`:p?`AVAILABLE`:`UNAVAILABLE`)})]})}),J(L,{children:J(M,{variant:`vechainKitPrimary`,isDisabled:!p||!!l||w||O,isLoading:O,onClick:k,loadingText:r(`Checking...`),"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}=X(),s=V(`colors`,`vechain-kit-text-primary`),{isolatedView:c,closeAccountModal:l}=Ml(),{account:u,connectedWallet:d,connection:f}=Q(),{data:p}=Np(u?.address??``,d?.address??``,3),{open:m}=kf(),{preferences:h}=Sm(),{feeDelegation:g}=$(),_=e=>{console.error(`Transaction failed:`,e)},v=Rs({onSuccess:()=>O()}),y=n.endsWith(`veworld.vet`),b=ts({subdomain:t.split(`.veworld.vet`)[0],domain:n,alreadyOwned:r,onSuccess:()=>O()}),x=as({domain:!i&&!y?t:``,alreadyOwned:r,onSuccess:()=>O()}),{sendTransaction:S,txReceipt:C,error:w,isWaitingForWalletConfirmation:T,isTransactionPending:E,clauses:D}=i?v:y?b:x,O=()=>{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)}}})},k=async()=>{if(p){m();return}try{await S()}catch(e){console.error(`Transaction failed:`,e)}},A=()=>{k()},ee=()=>{e({type:`choose-name-search`,props:{setCurrentContent:e,name:t,initialContentSource:a}})},[te,ne]=H.useState(null),[re,ie]=H.useState(null),ae=h.availableGasTokens.length>0&&(f.isConnectedWithPrivy||f.isConnectedWithVeChain)&&!g?.delegatorUrl,{data:oe,isLoading:se,error:ce,refetch:le}=Cm({clauses:D(),tokens:te?[te]:h.availableGasTokens,enabled:ae&&!!g?.genericDelegatorUrl}),ue=oe?.usedToken,de=(se||!oe)&&f.isConnectedWithPrivy&&!g?.delegatorUrl,fe=H.useCallback(e=>{ne(e),ie(e),setTimeout(()=>le(),100)},[le]),pe=!!ue&&!ce;return H.useEffect(()=>{ce&&te&&ne(null)},[ce,te]),Y(q,{children:[Y(Z,{children:[J(R,{"data-testid":`confirm-domain`,children:o(i?`Confirm Unset Domain`:`Confirm Name`)}),J(Oo,{onClick:ee,isDisabled:E}),J(I,{isDisabled:E})]}),Y(F,{children:[Y(B,{spacing:6,align:`center`,mt:10,children:[J(P,{as:ri,color:s,fontSize:`60px`,opacity:.5}),J(z,{fontSize:`md`,textAlign:`center`,color:s,children:i?o(`By confirming, your current domain will be unset`):o(`By confirming, your address will be set to {{domain}}`,{domain:t})})]}),!i&&J(B,{spacing:4,align:`stretch`,mt:6,children:J(z,{fontSize:`xl`,fontWeight:`bold`,color:s,textAlign:`center`,"data-testid":`preconfirm-domain-val`,children:t})}),f.isConnectedWithPrivy&&J(Nm,{estimation:oe,isLoading:se,isLoadingTransaction:E,onTokenChange:fe,clauses:D(),userSelectedToken:re})]}),J(L,{gap:4,w:`full`,children:J(Am,{transactionError:w,isSubmitting:E,isTxWaitingConfirmation:T,onConfirm:k,onRetry:A,transactionPendingText:o(i?`Unsetting current domain...`:`Claiming name...`),txReceipt:C,buttonText:o(`Confirm`),isDisabled:E||de,onError:_,gasEstimationError:ce,hasEnoughGasBalance:pe,isLoadingGasEstimation:se,showGasEstimationError:!g?.delegatorUrl&&f.isConnectedWithPrivy,context:`domain`})})]})},Kl=()=>{let{t:e}=X(),[t,n]=K(``),r=V(`colors`,`vechain-kit-card`),i=V(`colors`,`vechain-kit-text-secondary`),a=V(`colors`,`vechain-kit-text-tertiary`),o=V(`colors`,`vechain-kit-card`),s=V(`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 Y(B,{spacing:4,align:`stretch`,children:[Y(At,{size:`lg`,children:[J(kt,{placeholder:e(`Search FAQ`),bg:r,borderRadius:`xl`,height:`56px`,pl:12,value:t,onChange:e=>n(e.target.value)}),J(jt,{h:`56px`,w:`56px`,pl:4,children:J(Qr,{color:a})})]}),c.length===0?Y(B,{spacing:2,py:8,color:i,children:[J(P,{as:ni,boxSize:12,opacity:.5}),J(z,{fontSize:`lg`,children:e(`No questions found`)}),J(z,{fontSize:`md`,children:e(`Try searching with a different term`)})]}):J(et,{allowMultiple:!0,children:c.map((e,t)=>J(nt,{border:`none`,mb:2,children:({isExpanded:t})=>Y(q,{children:[Y(tt,{bg:o,borderRadius:`xl`,color:i,_hover:{bg:s},children:[J(j,{flex:`1`,textAlign:`left`,py:2,children:J(z,{fontWeight:`500`,color:i,children:e.question})}),J(P,{as:t?Er:Cr,fontSize:`20px`,opacity:.5})]}),J(rt,{pb:4,children:J(z,{fontSize:`sm`,color:i,opacity:.8,children:e.answer})})]})},t))})]})},ql=({onGoBack:e,showLanguageSelector:t=!0})=>{let{i18n:n,t:r}=X(),{isolatedView:i}=Ml(),a=V(`colors`,`vechain-kit-card`),o=V(`colors`,`vechain-kit-border`),s=V(`colors`,`vechain-kit-border-hover`);return Y(Om,{children:[Y(Z,{children:[J(R,{children:r(`Help`)}),!i&&J(Oo,{onClick:e}),J(I,{})]}),J(F,{w:`full`,children:Y(B,{spacing:6,align:`stretch`,children:[t&&J(Kt,{borderRadius:`md`,size:`sm`,width:`auto`,value:n.language,onChange:e=>{n.changeLanguage(e.target.value)},bg:a,borderColor:o,_hover:{borderColor:s},children:Za.map(e=>J(`option`,{value:e,children:$a[e]},e))}),J(M,{as:Nt,href:me,isExternal:!0,variant:`vechainKitSecondary`,rightIcon:J(P,{as:Pr}),children:r(`For developers`)}),J(Kl,{})]})}),J(L,{pt:0})]})},Jl=({leftIcon:e,rightIcon:t,title:n,wallet:i,onClick:a,leftImage:o,isActive:s=!1})=>{let{t:c}=X(),{darkMode:l}=$();return J(M,{w:`full`,minH:`70px`,h:`fit-content`,py:4,onClick:a,backgroundColor:`transparent`,border:`1px solid ${l?`#ffffff29`:`#ebebeb`}`,children:Y(N,{w:`full`,justify:`space-between`,children:[J(j,{minW:`40px`,justifyContent:`center`,children:o?J(Ot,{justifySelf:`center`,src:o,w:`28px`,alt:`left-image`}):J(P,{as:e,fontSize:`28px`})}),Y(B,{textAlign:`left`,w:`full`,flex:1,children:[J(N,{w:`full`,spacing:2,justifyContent:`flex-start`,children:J(z,{fontSize:`sm`,fontWeight:`400`,children:n})}),J(z,{fontSize:`sm`,fontWeight:`500`,opacity:.5,overflowWrap:`break-word`,wordBreak:`break-word`,whiteSpace:`normal`,w:`full`,children:i?.domain?r(i?.domain??``,18,0):d(i?.address??``,6,4)})]}),J(B,{minW:`40px`,justifyContent:`flex-end`,children:Y(N,{justifyContent:`flex-end`,minW:`40px`,children:[s&&J(Zt,{size:`sm`,colorScheme:`green`,children:c(`Active`)}),J(P,{as:t,fontSize:`20px`,opacity:.5})]})})]})})},Yl=({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:_}=X();return J(M,{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:Y(N,{w:`full`,justify:`space-between`,alignItems:`center`,children:[J(j,{minW:`40px`,h:`20px`,children:i?J(Ot,{src:i,w:`30px`,h:`30px`,borderRadius:`full`,alt:`left-image`,alignSelf:`end`,objectFit:`cover`}):J(P,{as:e,fontSize:`20px`,h:`full`,alignContent:`center`})}),J(B,{textAlign:`left`,w:`full`,flex:1,justifyContent:`flex-start`,alignItems:`flex-start`,children:Y(N,{justify:`flex-start`,alignItems:`baseline`,children:[J(z,{fontSize:`sm`,fontWeight:`400`,children:n}),o&&J(Zt,{size:`sm`,colorScheme:`red`,children:_(`Coming Soon!`)}),m]})}),t&&J(B,{minW:`40px`,justifyContent:`flex-end`,children:J(P,{as:t,fontSize:`20px`,opacity:.5})})]})})},Xl=({wallet:e,setCurrentContent:t,size:n=`md`,onClick:i,onClose:a,mt:o,style:s})=>{let{t:c}=X(),{connection:l}=Q(),{switchWallet:u,isSwitching:f,isInAppBrowser:p}=Mc(),{isSwitchWalletEnabled:m}=$n(),[h,g]=K(!1),_=async()=>{await k(e?.domain??e?.address??``)&&(g(!0),setTimeout(()=>{g(!1)},2e3))},v=()=>{p?u():t?.({type:`select-wallet`,props:{setCurrentContent:t,onClose:a,returnTo:`main`,onLogoutSuccess:a}})};return Y(N,{mt:o,w:`full`,...s,justifyContent:`flex-start`,alignItems:`center`,children:[J(M,{w:`full`,h:12,"aria-label":`Wallet`,onClick:i,variant:`vechainKitSecondary`,p:3,"data-testid":`profile-button`,children:Y(N,{spacing:2,align:`center`,justifyContent:`space-between`,w:`full`,children:[Y(N,{spacing:2,justifyContent:`flex-start`,children:[J(km,{wallet:e,props:{width:7,height:7}}),J(z,{fontSize:n,fontWeight:`500`,children:h?c(`Copied!`):r(e?.domain??``,22,0)||d(e?.address??``,6,4)})]}),J(P,{boxSize:5,as:Tr,cursor:`pointer`,opacity:.5})]})}),l.isInAppBrowser&&m||!l.isInAppBrowser&&l.isConnectedWithDappKit?J(Dt,{"aria-label":`Switch wallet`,icon:J(P,{as:mr}),onClick:v,w:`60px`,h:12,variant:`vechainKitSecondary`,p:3,isLoading:f,isDisabled:f,"data-testid":`switch-wallet-button`}):J(Dt,{"aria-label":`Copy address`,icon:J(P,{as:h?Sr:jr}),onClick:_,w:`60px`,h:12,variant:`vechainKitSecondary`,p:3})]})},Zl=({address:t,maxIcons:n=3,iconSize:r=20,ml:i=0,style:a,iconsGap:o=0,rightIcon:s,showNoAssetsWarning:c=!1,onClick:l})=>{let{t:u}=X(),{tokensWithBalance:d}=Xs({address:t}),{darkMode:f}=$(),p=V(`colors`,`vechain-kit-text-secondary`),m=o<1?`-${r/2}px`:`${o}px`,h=d.slice(0,n),g=d.length-n;return!t||d.length===0&&!c?null:Y(N,{spacing:0,ml:i,...a,onClick:l,children:[Y(N,{spacing:0,children:[h.map((t,n)=>J(gt,{ml:n>0?m:`0`,zIndex:n,size:`${r}px`,borderRadius:`full`,bg:f?`gray.100`:`gray.600`,border:`2px solid #00000024`,alignItems:`center`,justifyContent:`center`,children:S[t.symbol]?H.cloneElement(S[t.symbol],{width:`${r*.8}px`,height:`${r*.8}px`,rounded:`full`}):e[t.symbol]?J(Ot,{src:e[t.symbol],alt:`${t.symbol} logo`,width:`${r*.8}px`,height:`${r*.8}px`,rounded:`full`}):J(z,{fontSize:`${r*.4}px`,fontWeight:`bold`,color:f?`black`:`white`,children:t.symbol.slice(0,3)})},t.symbol)),g>0&&J(gt,{ml:m,zIndex:h.length,size:`${r}px`,borderRadius:`full`,bg:f?`gray.100`:`gray.700`,display:`flex`,alignItems:`center`,justifyContent:`center`,border:`2px solid`,children:Y(z,{fontSize:`${r*.4}px`,fontWeight:`bold`,color:f?`black`:`white`,children:[`+`,g]})}),d.length===0&&c&&J(z,{fontSize:`sm`,color:p,fontWeight:`700`,children:u(`No assets`)})]}),s]})},Ql=({mb:e,mt:t,onAssetsClick:n})=>{let{t:r}=X(),{account:i}=Q(),{formattedBalance:a,isLoading:o}=Zs({address:i?.address??``}),{refresh:s}=jc(),[c,l]=K(!1),u=V(`colors`,`vechain-kit-text-secondary`),d=async()=>{l(!0),await s(),setTimeout(()=>{l(!1)},1500)},[f,p]=dm(um.SHOW_ASSETS,!0);return Y(B,{w:`full`,justifyContent:`start`,spacing:1,mt:t,mb:e,children:[Y(N,{w:`full`,justifyContent:`space-between`,alignItems:`center`,spacing:0,role:`group`,children:[J(Et,{size:`xs`,fontWeight:`800`,color:u,textTransform:`uppercase`,letterSpacing:1.2,ml:`5px`,children:r(`Assets`)}),Y(N,{spacing:0,alignItems:`center`,children:[J(Dt,{"aria-label":`Refresh balances`,variant:`ghost`,size:`sm`,opacity:.5,_hover:{opacity:.8},onClick:d,icon:J(P,{as:Zr,boxSize:4}),isLoading:o||c,sx:{"& > span.chakra-button__spinner":{width:`16px`,height:`16px`,position:`absolute`}}}),J(Dt,{"aria-label":`Show/hide assets`,variant:`ghost`,size:`sm`,opacity:.5,_hover:{opacity:.8},onClick:()=>p(!f),icon:J(P,{as:f?oa:sa,boxSize:4})})]})]}),J(M,{onClick:n,h:`fit-content`,variant:`vechainKitSecondary`,children:Y(B,{spacing:2,w:`full`,justifyContent:`flex-start`,alignItems:`flex-start`,mt:4,mb:4,children:[J(Et,{size:`2xl`,fontWeight:`700`,children:f?a:`$****`}),J(N,{w:`full`,justifyContent:`flex-start`,"data-testid":`all-assets-button`,mt:2,children:J(Zl,{style:{width:`100%`,justifyContent:`space-between`},maxIcons:10,iconSize:26,iconsGap:3,address:i?.address??``,showNoAssetsWarning:!0,rightIcon:J(P,{as:Tr,boxSize:5,opacity:.5,marginLeft:2})})})]})})]})},$l=[{icon:_r,label:`Send`,onClick:e=>e({type:`send-token`,props:{setCurrentContent:e}}),isDisabled:e=>!e},{icon:mr,label:`Swap`,onClick:e=>{e(`swap-token`)},isDisabled:e=>!e},{icon:pr,label:`Receive`,onClick:e=>{e(`receive-token`)}}],eu=({icon:e,label:t,onClick:n,isDisabled:r,showRedDot:i})=>{let{t:a}=X();return J(Dt,{variant:`vechainKitSecondary`,h:`80px`,w:`full`,"aria-label":t,isDisabled:r,p:3,icon:Y(B,{spacing:4,children:[J(P,{as:e,boxSize:5,opacity:.9}),Y(N,{p:0,alignItems:`baseline`,spacing:1,children:[J(z,{fontSize:`sm`,fontWeight:`600`,"data-testid":`${t.toLowerCase()}-button-label`,children:a(t,t)}),i&&J(j,{minWidth:`8px`,height:`8px`,bg:`red.500`,borderRadius:`full`,display:`flex`,alignItems:`center`,justifyContent:`center`})]})]}),onClick:n})},tu=({mt:e,setCurrentContent:t})=>{let{account:n,smartAccount:r,connectedWallet:i,connection:a}=Q(),{hasAnyBalance:o}=Zs({address:n?.address??``}),{data:s}=Np(r?.address??``,i?.address??``,3),c=a.isConnectedWithPrivy&&s;return J(wt,{templateColumns:`repeat(3, 1fr)`,gap:2,w:`full`,mt:e,children:$l.map(e=>J(eu,{icon:e.icon,label:e.label,onClick:()=>e.onClick(t),isDisabled:e.isDisabled?.(o),showRedDot:c&&e.label===`Settings`},e.label))})},nu=({setCurrentContent:e})=>{let{t}=X(),n=V(`colors`,`vechain-kit-text-primary`),r=V(`colors`,`vechain-kit-text-secondary`);return J(lt,{w:`full`,variant:`featureAnnouncement`,overflow:`hidden`,onClick:()=>{e({type:`choose-name`,props:{setCurrentContent:e,onBack:()=>e(`profile`),initialContentSource:`profile`}})},cursor:`pointer`,_hover:{opacity:.8},children:J(ut,{p:4,children:J(N,{justify:`space-between`,align:`flex-start`,spacing:3,children:Y(B,{align:`flex-start`,spacing:1,children:[Y(N,{spacing:2,children:[J(z,{fontSize:`sm`,fontWeight:`400`,color:n,children:t(`Claim your vet domain!`)}),J(Zt,{size:`sm`,colorScheme:`red`,children:t(`New`)})]}),J(z,{fontSize:`xs`,color:r,children:t(`Say goodbye to 0x addresses, claim your .veworld.vet subdomain now for free!`)})]})})})})},ru=()=>{let{t:e}=X();return J(it,{status:`warning`,fontSize:`xs`,borderRadius:`xl`,p:2,children:J(B,{spacing:1,align:`stretch`,w:`full`,children:Y(N,{spacing:2,align:`flex-start`,children:[J(ot,{boxSize:4,mt:`10px`}),J(z,{w:`full`,children:e(`Sending to OceanX or other exchanges may result in loss of funds.`)})]})})})},iu=()=>{let{t:e}=X();return J(it,{status:`warning`,fontSize:`xs`,borderRadius:`xl`,p:2,children:J(B,{spacing:1,align:`stretch`,w:`full`,children:Y(N,{spacing:2,align:`flex-start`,children:[J(ot,{boxSize:4,mt:`10px`}),J(z,{w:`full`,children:e(`A .vet domain is required to customize your profile. Choose an account name to get started.`)})]})})})},au=()=>{let{t:e}=X(),{getConnectionCache:t}=Bf(),n=t();return Y(lt,{variant:`vechainKitBase`,w:`full`,children:[Y(ft,{p:4,pl:6,borderBottomWidth:`1px`,children:[J(z,{fontWeight:`medium`,opacity:.8,children:e(`Security preferences`)}),J(z,{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`})})]}),J(ut,{borderRadius:`none`,children:Y(B,{spacing:3,align:`stretch`,children:[Y(N,{spacing:3,align:`center`,children:[J(pt,{w:`fit-content`,h:`fit-content`,p:2,borderRadius:`full`,bg:`blackAlpha.100`,flexShrink:0,children:J(P,{as:oi})}),Y(j,{flex:1,children:[J(z,{fontSize:`sm`,fontWeight:`medium`,lineHeight:`shorter`,children:e(`Login methods`)}),J(z,{fontSize:`xs`,opacity:.7,lineHeight:`shorter`,children:e(`Manage your login methods and passkeys`)})]})]}),Y(N,{spacing:3,align:`center`,children:[J(pt,{w:`fit-content`,h:`fit-content`,p:2,borderRadius:`full`,bg:`blackAlpha.100`,flexShrink:0,children:J(P,{as:ti})}),Y(j,{flex:1,children:[J(z,{fontSize:`sm`,fontWeight:`medium`,lineHeight:`shorter`,children:e(`Security settings`)}),J(z,{fontSize:`xs`,opacity:.7,lineHeight:`shorter`,children:e(`Backup your wallet, configure MFA and set recovery options`)})]})]})]})}),J(dt,{children:Y(M,{variant:`vechainKitSecondary`,w:`full`,onClick:()=>{window.open(n?.ecosystemApp.website??Qe,`_blank`)},children:[e(`Manage on {{appName}}`,{appName:n?.ecosystemApp.name??`origin app`}),J(P,{as:Pr,ml:2})]})})]})},ou=({setCurrentContent:e,initialContentSource:t=`profile`})=>{let{t:r}=X(),{network:i}=$(),{account:a}=Q(),o=V(`colors`,`vechain-kit-text-primary`),s=V(`colors`,`vechain-kit-error`),c=V(`colors`,`vechain-kit-card`),l=vn(null),u=vn(null),[d,f]=K(!1),{onUpload:p}=Jc({compressImage:!0}),[m,h]=K(null),[g,_]=K(null),v=!!a?.domain,[y,b]=K(null),[x,S]=K(``),[C,w]=K(``),{register:T,watch:E,formState:{errors:D,isValid:O}}=ra({defaultValues:{displayName:a?.metadata?.display||``,description:a?.metadata?.description||``},mode:`onChange`});W(()=>{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 k=E(),A=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 n(e.file,t.name,i.type))}catch(e){console.error(`Error uploading image:`,e),h(null)}finally{f(!1)}};W(()=>()=>{m&&URL.revokeObjectURL(m)},[m]);let ee=()=>{let e={};return g!==y&&g&&(e.avatarIpfsHash=g),k.displayName!==x&&(e.displayName=k.displayName),k.description!==C&&(e.description=k.description),e},te=G(()=>{let e=ee();return Object.keys(e).length>0},[ee]),ne=()=>{e({type:`account-customization-summary`,props:{setCurrentContent:e,changes:ee(),onDoneRedirectContent:t}})},re=()=>{e(t)};return Y(q,{children:[Y(Z,{children:[J(R,{"data-testid":`modal-title`,children:r(`Customization`)}),J(Oo,{onClick:re}),J(I,{})]}),Y(F,{children:[Y(j,{cursor:v?`pointer`:`default`,pt:2,display:`flex`,justifyContent:`center`,position:`relative`,onClick:()=>v&&l.current?.click(),children:[J(km,{wallet:a,props:{width:`100px`,height:`100px`,boxShadow:`0px 0px 3px 2px #00000024`,src:m??void 0}}),v&&J(P,{as:xr,position:`absolute`,top:`80px`,left:`60%`,bg:c,color:o,p:`1`,borderRadius:`full`,boxSize:`6`}),d&&J(j,{display:`flex`,alignItems:`center`,justifyContent:`center`,backgroundColor:`rgba(0, 0, 0, 0.5)`,position:`absolute`,transform:`translateX(0%)`,width:`100px`,height:`100px`,borderRadius:`full`,zIndex:10,children:J(z,{fontSize:`xs`,color:`white`,children:d?`Uploading...`:`Processing...`})})]}),Y(B,{spacing:6,mt:4,children:[!v&&J(iu,{}),J(Yl,{title:a?.domain??r(`Choose account name`),description:r(`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:ri,rightIcon:Tr,dataTestId:`set-domain-name-button`}),Y(St,{isDisabled:!v,isInvalid:!!D.displayName,children:[J(Ct,{fontSize:`sm`,fontWeight:`medium`,color:o,children:r(`Display Name`)}),J(kt,{...T(`displayName`,{maxLength:{value:25,message:r(`Display name must be less than 25 characters`)}}),placeholder:r(v?`Enter your display name`:`Set a domain first`),fontWeight:`medium`,color:o,"data-testid":`display-name-input`}),D.displayName&&J(z,{color:s,fontSize:`sm`,mt:1,fontWeight:`medium`,children:D.displayName.message})]}),Y(St,{isDisabled:!v,isInvalid:!!D.description,children:[J(Ct,{fontSize:`sm`,fontWeight:`medium`,color:o,children:r(`Description`)}),J(Qt,{...T(`description`,{maxLength:{value:100,message:r(`Description must be less than 100 characters`)}}),placeholder:r(`Eg: DevRel @ ENS Labs`),fontWeight:`medium`,color:o,"data-testid":`description-input`,minH:`50px`}),D.description&&J(z,{color:s,mt:1,fontSize:`sm`,fontWeight:`medium`,children:D.description.message})]})]}),J(`input`,{type:`file`,ref:l,hidden:!0,accept:`image/*`,onChange:async e=>await A(e)}),J(`input`,{type:`file`,ref:u,hidden:!0,accept:`image/*`,onChange:async e=>{e.preventDefault()}})]}),J(L,{w:`full`,children:J(M,{variant:`vechainKitPrimary`,onClick:ne,isDisabled:!v||!te||!O,isLoading:d,loadingText:r(`Preparing changes...`),"data-testid":`save-changes-button`,children:r(`Save Changes`)})})]})},su=({setCurrentContent:e,changes:t,onDoneRedirectContent:n})=>{let{t:r}=X(),{darkMode:i,network:a,feeDelegation:o}=$(),s=V(`colors`,`vechain-kit-text-primary`),{account:c,connectedWallet:l,connection:u}=Q(),{preferences:d}=Sm(),{data:f}=Np(c?.address??``,l?.address??``,3),{open:p}=kf(),{handleSubmit:m}=ra({defaultValues:{...t,avatarIpfsHash:t.avatarIpfsHash??void 0}}),h=c?.domain??``,{data:g}=Ts(h),_=sr(),{sendTransaction:v,txReceipt:y,error:b,isWaitingForWalletConfirmation:x,isTransactionPending:S,clauses:w}=Cs({resolverAddress:g,signerAccountAddress:c?.address??``,onSuccess:async()=>{try{await he()}catch(e){console.error(`Error refreshing data:`,e)}},onError:e=>{console.error(`Error updating text record:`,e)}}),[T,E]=H.useState(!1);H.useEffect(()=>{if(!y||y.reverted||T||S)return;let t=y.meta.txID;t&&(E(!0),e({type:`successful-operation`,props:{setCurrentContent:e,txId:t,title:r(`Profile Updated`),description:r(`Your changes have been saved successfully.`),onDone:()=>{e(n)}}}))},[y,T,S,e,r,n]),H.useEffect(()=>{S&&E(!1)},[S]);let D=G(()=>{let e=c?.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,c?.domain]),O=G(()=>{try{return!g||D.length===0||!w?[]:w(D)}catch(e){return console.error(`Error building clauses:`,e),[]}},[D,w,g]),[k,A]=H.useState(null),[ee,te]=H.useState(null),ne=d.availableGasTokens.length>0&&(u.isConnectedWithPrivy||u.isConnectedWithVeChain)&&!o?.delegatorUrl,{data:re,isLoading:ie,error:ae,refetch:oe}=Cm({clauses:O,tokens:k?[k]:d.availableGasTokens,enabled:ne&&!!o?.genericDelegatorUrl}),se=re?.usedToken,ce=(ie||!re)&&u.isConnectedWithPrivy&&!o?.delegatorUrl,le=H.useCallback(e=>{A(e),te(e),setTimeout(()=>oe(),100)},[oe]),ue=!!se&&!ae;H.useEffect(()=>{ae&&k&&A(null)},[ae,k]);let de=async()=>{if(f){p();return}try{D.length>0&&await v(D)}catch(e){console.error(`Error saving changes:`,e)}},fe=(e,t)=>t?.trim()?Y(B,{align:`flex-start`,w:`full`,spacing:1,children:[J(z,{fontSize:`sm`,color:i?`whiteAlpha.600`:`blackAlpha.600`,children:e}),J(z,{fontSize:`md`,children:t})]}):null,pe=()=>{m(de)()},me=()=>{e({type:`account-customization`,props:{setCurrentContent:e}})},he=async()=>{t.avatarIpfsHash&&(_.setQueryData(hs(h,a.type),C(`ipfs://`+t.avatarIpfsHash,a.type)),_.setQueryData(Os(c?.address??``),C(`ipfs://`+t.avatarIpfsHash,a.type))),await _.invalidateQueries({queryKey:ys(h,a.type)}),await _.refetchQueries({queryKey:ys(h,a.type)})};return Y(q,{children:[Y(Z,{children:[J(R,{children:r(`Confirm Changes`)}),J(Oo,{isDisabled:S,onClick:me}),J(I,{isDisabled:S})]}),Y(F,{children:[Y(B,{spacing:6,align:`center`,mt:10,children:[J(P,{as:Fr,color:s,fontSize:`60px`,opacity:.5}),J(z,{fontSize:`md`,textAlign:`center`,color:s,children:r(`By confirming, the following details attached to your name ({{domain}}) will be updated`,{domain:h})})]}),Y(B,{spacing:4,align:`stretch`,mt:6,children:[t.avatarIpfsHash&&Y(B,{align:`flex-start`,w:`full`,spacing:1,children:[J(z,{fontSize:`sm`,color:i?`whiteAlpha.600`:`blackAlpha.600`,children:r(`Profile Image`)}),J(z,{fontSize:`md`,children:r(`New image selected`)})]}),t.displayName&&fe(r(`Display Name`),t.displayName),t.description&&fe(r(`Description`),t.description),t.twitter&&fe(r(`Twitter`),t.twitter),t.website&&fe(r(`Website`),t.website),t.email&&fe(r(`Email`),t.email)]}),u.isConnectedWithPrivy&&J(Nm,{estimation:re,isLoading:ie,isLoadingTransaction:S,onTokenChange:le,clauses:O,userSelectedToken:ee})]}),J(L,{gap:4,w:`full`,children:J(Am,{transactionError:b,isSubmitting:S,isTxWaitingConfirmation:x,onConfirm:m(de),onRetry:pe,transactionPendingText:r(`Saving changes...`),txReceipt:y,buttonText:r(`Confirm`),isDisabled:S||ce,gasEstimationError:ae,hasEnoughGasBalance:ue,isLoadingGasEstimation:ie,showGasEstimationError:!o?.delegatorUrl&&u.isConnectedWithPrivy,context:`customization`})})]})},cu=({address:e,showHeader:t=!0,showLinks:n=!0,showDescription:r=!0,showDisplayName:i=!0,reserveNameDescriptionSpace:a=!1,setCurrentContent:o,onLogout:s})=>{let{network:c}=$(),u=V(`colors`,`vechain-kit-text-primary`),d=V(`colors`,`vechain-kit-text-secondary`),f=V(`colors`,`vechain-kit-card`),p=kc(e,c.type),m=l(e),h=p?.records?.url||p?.records?.[`com.x`]||p?.records?.email,g=e=>{try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`?t.toString():null}catch{return null}};return Y(B,{spacing:0,w:`full`,children:[J(j,{p:0,backgroundSize:`100% !important`,backgroundPosition:`center`,position:`relative`,background:t?`no-repeat url('${m}')`:`none`,w:`100%`,borderRadius:`14px 14px 0 0`}),Y(j,{position:`relative`,display:`inline-block`,cursor:o?`pointer`:`default`,onClick:o?()=>{o({type:`account-customization`,props:{setCurrentContent:o,initialContentSource:`profile`}})}:void 0,children:[J(km,{wallet:{address:e,domain:p?.domain,image:p?.image,isLoadingMetadata:p?.isLoading,metadata:p?.records},props:{width:`120px`,height:`120px`}}),o&&J(P,{as:Jr,position:`absolute`,bottom:`0`,right:`0`,bg:f,color:u,p:`1`,borderRadius:`full`,boxSize:`6`,border:`2px solid`,borderColor:f})]}),Y(B,{w:`full`,spacing:2,children:[i&&(p?.records?.display?J(z,{fontSize:`xl`,color:u,fontWeight:`bold`,w:`full`,textAlign:`center`,mt:2,"data-testid":`display-name-val`,children:p?.records?.display}):a&&J(j,{mt:2,minH:`28px`,"aria-hidden":!0})),r&&(p?.records?.description?J(z,{fontSize:`sm`,color:d,w:`full`,textAlign:`center`,"data-testid":`description-val`,children:p?.records?.description}):a&&J(j,{minH:`20px`,"aria-hidden":!0})),n&&h&&Y(N,{w:`full`,justify:`center`,spacing:5,mt:4,children:[p?.records?.email&&J(Nt,{href:`mailto:${p?.records?.email}`,target:`_blank`,"data-testid":`mail-link`,children:J(P,{as:Kr,color:u})}),p?.records?.url&&J(Nt,{href:g(p.records.url)??void 0,target:`_blank`,rel:`noopener noreferrer`,"data-testid":`website-link`,children:J(P,{as:Br,color:u})}),p?.records?.[`com.x`]&&J(Nt,{href:`https://x.com/${encodeURIComponent(String(p.records[`com.x`]))}`,target:`_blank`,rel:`noopener noreferrer`,"data-testid":`twitter-link`,children:J(P,{as:la,color:u})})]}),J(ko,{onLogout:s,wallet:{address:e,domain:p?.domain,image:p?.image,isLoadingMetadata:p?.isLoading,metadata:p?.records},style:{mt:4},setCurrentContent:o})]})]})},lu=({onClick:e,...t})=>{let{smartAccount:n,connectedWallet:r,connection:i}=Q(),[a,o]=K(!1);W(()=>{o(!localStorage.getItem(`app-first-visit`))},[]);let{data:s}=Np(n?.address??``,r?.address??``,3),c=i.isConnectedWithPrivy&&s,l=()=>{a&&(localStorage.setItem(`app-first-visit`,`true`),o(!1)),e()};return J(Dt,{"aria-label":`Settings`,size:`sm`,variant:`vechainKitHeaderIconButtons`,position:`absolute`,left:`10px`,top:`8px`,lineHeight:`0`,onClick:l,icon:Y(j,{position:`relative`,children:[J(P,{as:$r,fontSize:`18px`}),c&&J(j,{position:`absolute`,top:`-1px`,right:`-1px`,minWidth:`8px`,height:`8px`,bg:`red.500`,borderRadius:`full`})]}),...t})},uu=({setCurrentContent:e,onLogoutSuccess:t,switchFeedback:n})=>{let{t:r}=X(),{account:i,disconnect:a,connection:o}=Q(),{switchWallet:s,isSwitching:c,isInAppBrowser:l}=Mc(),{isSwitchWalletEnabled:u}=$n(),{hasAnyBalance:d,formattedBalance:f}=Zs({address:i?.address}),[p]=dm(um.SHOW_ASSETS,!0),m=()=>{l?s():e({type:`select-wallet`,props:{setCurrentContent:e,onClose:()=>{},returnTo:`profile`,onLogoutSuccess:t}})};return Y(q,{children:[Y(Z,{children:[J(R,{"data-testid":`modal-title`,children:r(`Profile`)}),J(lu,{onClick:()=>{e(`settings`)},"data-testid":`settings-button`}),J(I,{})]}),J(F,{w:`full`,children:Y(B,{w:`full`,spacing:6,children:[J(Lm,{showFeedback:n?.showFeedback}),!i?.domain&&J(nu,{setCurrentContent:e}),J(cu,{reserveNameDescriptionSpace:!!i?.domain,onEditClick:()=>{e({type:`account-customization`,props:{setCurrentContent:e,initialContentSource:`profile`}})},address:i?.address??``,showHeader:!1,setCurrentContent:e,onLogout:()=>{a(),t?.()}})]})}),J(L,{w:`full`,children:Y(N,{w:`full`,justify:`space-between`,spacing:4,mt:4,children:[J(M,{size:`md`,width:`full`,height:`40px`,variant:`vechainKitSecondary`,leftIcon:d?void 0:J(P,{as:ci}),onClick:()=>e(`main`),"data-testid":`wallet-button`,children:d?Y(N,{spacing:2,w:`full`,justify:`center`,children:[J(Zl,{address:i?.address??``,maxIcons:2}),J(z,{fontWeight:`600`,children:p?f:`$****`})]}):r(`Wallet`)}),o.isInAppBrowser&&u||!o.isInAppBrowser&&o.isConnectedWithDappKit?J(M,{size:`md`,width:`full`,height:`40px`,variant:`vechainKitSecondary`,leftIcon:J(P,{as:mr}),colorScheme:`red`,onClick:async()=>{m()},isLoading:c,isDisabled:c,"data-testid":`switch-wallet-button`,children:r(`Switch`)}):J(M,{size:`md`,width:`full`,height:`40px`,variant:`vechainKitSecondary`,leftIcon:J(P,{as:Gr}),colorScheme:`red`,onClick:()=>e({type:`disconnect-confirm`,props:{onDisconnect:()=>{a(),t?.()},onBack:()=>e?.(`profile`)}}),"data-testid":`logout-button`,children:r(`Logout`)})]})})]})},du=({setCurrentContent:e,handleClose:t,initialContent:n=`settings`})=>{let{t:r}=X(),{smartAccount:i,connectedWallet:a}=Q(),{data:o}=Np(i?.address??``,a?.address??``,3),{sendTransaction:s,isTransactionPending:c,isWaitingForWalletConfirmation:l,error:u,txReceipt:d}=Rp({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 Y(q,{children:[Y(Z,{children:[J(R,{children:r(`Account upgrade required`)}),J(Oo,{onClick:()=>{e(n)}}),J(I,{})]}),J(F,{children:Y(B,{spacing:10,align:`stretch`,children:[J(z,{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.`)}),Y(N,{align:`center`,justifyContent:`space-evenly`,rounded:`md`,children:[Y(j,{position:`relative`,display:`inline-block`,children:[J(gt,{size:`60px`,bg:`gray.200`,children:J(Ot,{borderRadius:`full`,src:i?.image,alt:r(`Profile Picture`),w:`100%`,h:`100%`,objectFit:`cover`})}),J(Et,{position:`absolute`,top:`-5`,right:`-5`,color:`#D23F63`,fontSize:`28px`,children:`v1`})]}),J(P,{as:hr,color:`#3DBA67`}),Y(j,{position:`relative`,display:`inline-block`,children:[J(gt,{size:`60px`,bg:`gray.200`,children:J(Ot,{borderRadius:`full`,src:i?.image,alt:r(`Profile Picture`),w:`100%`,h:`100%`,objectFit:`cover`})}),J(Et,{position:`absolute`,top:`-5`,right:`-5`,color:`#3DBA67`,fontSize:`28px`,children:`v3`})]})]}),Y(it,{status:`info`,borderRadius:`md`,children:[J(ot,{}),Y(j,{children:[J(st,{fontSize:`sm`,children:r(`Benefits of this upgrade:`)}),J(at,{fontSize:`xs`,children:Y(B,{align:`start`,spacing:0,mt:1,children:[Y(z,{fontSize:`xs`,lineHeight:`1.2`,children:[`• `,r(`Improved security features`)]}),Y(z,{fontSize:`xs`,children:[`• `,r(`Better transaction handling`)]}),Y(z,{fontSize:`xs`,children:[`•`,` `,r(`Enhanced compatibility with dApps`)]}),Y(z,{fontSize:`xs`,children:[`•`,` `,r(`Reduced gas costs for operations`)]})]})})]})]})]})}),J(L,{justifyContent:`center`,children:Y(B,{spacing:3,w:`full`,children:[J(Am,{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}),J(M,{mt:2,variant:`link`,onClick:()=>{t?t():e(n)},isDisabled:c,children:r(o?`Close and do this later`:`Close`)})]})})]})},fu=({setCurrentContent:e})=>{let{account:t}=Q(),{sortedTokens:n}=Xs({address:t?.address}),{allowCustomTokens:r,darkMode:i}=$(),{currentCurrency:a}=Ys(),o=V(`colors`,`vechain-kit-text-tertiary`),{t:s}=X(),{isolatedView:c}=Ml(),[l,u]=K(``),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 Y(q,{children:[Y(Z,{children:[J(R,{children:s(`Assets`)}),!c&&J(Oo,{onClick:()=>e(`main`)}),J(I,{})]}),Y(yt,{h:[`540px`,`auto`],p:0,children:[Y(F,{children:[Y(At,{size:`lg`,children:[J(kt,{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`}),J(jt,{h:`56px`,w:`56px`,pl:4,children:J(Qr,{color:o})})]}),J(B,{spacing:2,align:`stretch`,mt:2,children:f.map(e=>{let t=Number(e.balance)>0,n=p.includes(e.symbol);return J(Tm,{symbol:e.symbol,amount:Number(e.balance),currencyValue:e.valueInCurrency,currentCurrency:a,onClick:()=>d(e),isDisabled:!t||n},e.address)})})]}),J(L,{children:r&&J(M,{variant:`vechainKitSecondary`,leftIcon:J(P,{as:Jr,boxSize:4}),onClick:()=>e(`add-custom-token`),children:s(`Manage Custom Tokens`)})})]})]})},pu=({setCurrentContent:t})=>{let{t:n}=X(),r=V(`colors`,`vechain-kit-text-primary`),i=V(`colors`,`vechain-kit-text-secondary`),a=V(`colors`,`vechain-kit-card`),o=V(`colors`,`vechain-kit-overlay`),{addToken:s,removeToken:c,isTokenIncluded:l,isDefaultToken:u,customTokens:f}=ac(),{register:p,setError:m,setValue:h,formState:{errors:g,isValid:_},handleSubmit:v}=ra({defaultValues:{newTokenAddress:``},mode:`onChange`}),y=async e=>{if(e.newTokenAddress){if(l(e.newTokenAddress)||u(e.newTokenAddress))return m(`newTokenAddress`,{type:`manual`,message:n(`Token already added`)});try{await s(e.newTokenAddress),h(`newTokenAddress`,``)}catch(e){console.error(`Error adding token 2:`,e),m(`newTokenAddress`,{type:`manual`,message:n(`Invalid token address`)})}}};return Y(q,{children:[Y(Z,{children:[J(R,{children:n(`Manage Custom Tokens`)}),J(Oo,{onClick:()=>t(`assets`)}),J(I,{})]}),J(F,{children:Y(B,{spacing:4,align:`stretch`,position:`relative`,children:[J(j,{p:6,borderRadius:`xl`,bg:a,children:J(B,{align:`stretch`,spacing:2,children:Y(St,{isInvalid:!!g.newTokenAddress,children:[J(Ct,{fontSize:`sm`,fontWeight:`medium`,color:r,children:n(`Token Contract Address`)}),J(kt,{...p(`newTokenAddress`,{required:n(`Address is required`),pattern:{value:/^0x[a-fA-F0-9]{40}$/,message:n(`Please enter a valid contract address`)},validate:e=>/^0x[a-fA-F0-9]{40}$/.test(e)||n(`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&&J(z,{color:`#ef4444`,fontSize:`sm`,children:g.newTokenAddress.message})]})})}),f.length>0&&Y(j,{p:4,borderRadius:`xl`,bg:o,children:[J(z,{fontSize:`sm`,fontWeight:`medium`,mb:2,children:n(`Existing Custom Tokens`)}),J(B,{align:`stretch`,spacing:2,children:f.map(t=>Y(N,{justify:`space-between`,fontSize:`sm`,p:2,borderRadius:`md`,bg:a,children:[Y(N,{children:[J(Ot,{src:e[t?.symbol],alt:`${t.symbol} logo`,boxSize:`20px`,borderRadius:`full`,fallback:J(j,{boxSize:`20px`,borderRadius:`full`,bg:`whiteAlpha.200`,display:`flex`,alignItems:`center`,justifyContent:`center`,children:J(z,{fontSize:`8px`,fontWeight:`bold`,color:r,children:t.symbol?.slice(0,3)})})}),J(z,{fontWeight:`medium`,color:r,children:t.symbol??`Unknown`})]}),J(z,{color:i,children:d(t.address??``,4,4)}),J(M,{size:`sm`,variant:`ghost`,color:r,borderRadius:`md`,p:2,onClick:()=>c(t.address),children:J(ii,{size:16,color:r})})]},t.address))})]})]})}),J(L,{children:J(M,{variant:`vechainKitPrimary`,isDisabled:!_,onClick:v(y),children:n(`Add Token`)})})]})},mu=({setCurrentContent:e})=>{let{t}=X(),{darkMode:n}=$(),{isolatedView:r}=Ml();return Y(q,{children:[Y(Z,{children:[J(R,{children:t(`Bridge`)}),!r&&J(Oo,{onClick:()=>e(`main`)}),J(I,{})]}),J(yt,{maxW:`container.lg`,children:J(F,{children:Y(B,{spacing:6,align:`center`,w:`full`,children:[J(qe,{isDark:n,borderRadius:`xl`}),J(z,{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.`)})]})})}),J(L,{children:Y(M,{variant:`vechainKitSecondary`,onClick:()=>{window.open(Ze,`_blank`)},children:[t(`Launch vechain.energy`),J(P,{as:Pr,ml:2})]})})]})},hu=({setCurrentContent:e})=>{let{t:n}=X(),{currentCurrency:r,changeCurrency:i,allCurrencies:a}=Ys(),o=dn(`rgba(0, 0, 0, 0.1)`,`rgba(255, 255, 255, 0.05)`);W(()=>{de(`settings-currency-visited`,`true`)},[]);let s=e=>{let n=r===e;return Y(M,{w:`full`,variant:`ghost`,justifyContent:`space-between`,onClick:()=>i(e),py:6,px:4,bg:n?o:void 0,children:[Y(N,{spacing:3,children:[J(z,{fontSize:`xl`,children:t[e]}),J(z,{children:e.toUpperCase()})]}),n&&J(P,{as:Sr,boxSize:5,color:`blue.500`})]},e)};return Y(Om,{children:[Y(Z,{children:[J(R,{children:n(`Select currency`)}),J(Oo,{onClick:()=>e(`settings`)}),J(I,{})]}),J(F,{w:`full`,children:J(B,{justify:`center`,spacing:3,align:`flex-start`,w:`full`,children:a.map(e=>s(e))})}),J(L,{pt:0})]})},gu=({setCurrentContent:e})=>{let{t,i18n:n}=X(),r=dn(`rgba(0, 0, 0, 0.1)`,`rgba(255, 255, 255, 0.05)`),i=e=>{n.changeLanguage(e)},a=e=>{let t=n.language===e;return Y(M,{w:`full`,variant:`ghost`,justifyContent:`space-between`,onClick:()=>i(e),py:6,px:4,bg:t?r:void 0,children:[J(z,{children:$a[e]}),t&&J(P,{as:Sr,boxSize:5,color:`blue.500`})]},e)};return Y(Om,{children:[Y(Z,{children:[J(R,{children:t(`Select language`)}),J(Oo,{onClick:()=>e(`settings`)}),J(I,{})]}),J(F,{w:`full`,children:J(B,{justify:`center`,spacing:3,align:`flex-start`,w:`full`,children:Za.map(e=>a(e))})}),J(L,{pt:0})]})},_u=({token:e,index:t,isExcluded:n,onToggleExclusion:r,onDragStart:i,onDragOver:a,onDrop:s,onTouchStart:c,onTouchMove:l,onTouchEnd:u,isDragging:d,isDraggedOver:f})=>{let p=o[e],{darkMode:m}=$(),h=V(`colors`,`vechain-kit-text-primary`),g=V(`colors`,`vechain-kit-text-secondary`),_=V(`colors`,`vechain-kit-card`);return J(j,{bg:m?`#ffffff0a`:`blackAlpha.50`,borderRadius:`md`,border:`1px`,borderColor:d?m?`blue.500`:`blue.300`:f?m?`blue.400`:`blue.200`:_,p:3,mb:2,opacity:d||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:()=>s(t),onTouchStart:e=>c(t,e),onTouchMove:l,onTouchEnd:u,_hover:{backgroundColor:m?`#ffffff12`:`blackAlpha.200`},children:Y(N,{justify:`space-between`,children:[Y(N,{opacity:n?.5:1,children:[J(j,{cursor:`grab`,_active:{cursor:`grabbing`},pointerEvents:`none`,children:J(P,{as:Vr,color:g})}),Y(B,{align:`start`,spacing:0,children:[J(z,{fontWeight:`medium`,color:h,children:p.name}),J(z,{fontSize:`sm`,color:g,children:p.description})]})]}),J(Xt,{isChecked:!n,onChange:()=>r(e),colorScheme:`blue`,size:`sm`})]})})},vu=({tokens:e,excludedTokens:t,onReorder:n,onToggleExclusion:r})=>{let[i,a]=K(null),[o,s]=K(null),c=vn([]),l=vn(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 J(j,{w:`full`,children:e.map((e,n)=>J(j,{ref:e=>{c.current[n]=e},children:J(_u,{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))})},yu=({setCurrentContent:e})=>{let{t}=X(),{preferences:n,reorderTokenPriority:r,toggleTokenExclusion:i}=Sm(),a=V(`colors`,`vechain-kit-text-primary`),o=V(`colors`,`vechain-kit-text-secondary`),s=U(e=>{r(e)},[r]);return Y(Om,{children:[Y(Z,{children:[J(R,{children:t(`Gas Token Preferences`)}),J(Oo,{onClick:()=>e(`settings`)}),J(I,{})]}),J(F,{w:`full`,children:Y(B,{justify:`center`,spacing:6,align:`flex-start`,w:`full`,children:[J(B,{w:`full`,justifyContent:`center`,spacing:3,mb:3,children:J(z,{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&&Y(it,{status:`warning`,borderRadius:`md`,children:[J(ot,{}),J(at,{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.`)})]}),Y(B,{w:`full`,align:`start`,spacing:3,children:[J(z,{fontSize:`md`,fontWeight:`semibold`,color:a,children:t(`Token Priority Order`)}),J(z,{fontSize:`sm`,color:o,children:t(`Drag to reorder. The system will automatically use the highest priority token with sufficient balance.`)}),J(vu,{tokens:n.tokenPriority,excludedTokens:n.excludedTokens,onReorder:s,onToggleExclusion:i})]})]})})]})},bu=({setCurrentContent:e,onLogoutSuccess:t})=>{let{t:n}=X(),{isolatedView:r}=Ml(),{exportWallet:i,linkPasskey:a}=Gn(),{showMfaEnrollmentModal:o}=Wn(),{feeDelegation:s}=$(),{connection:c,disconnect:l,smartAccount:u,connectedWallet:d}=Q(),{data:f}=Np(u?.address??``,d?.address??``,3),p=()=>{e({type:`upgrade-smart-account`,props:{setCurrentContent:e,initialContent:`settings`}})},m=()=>{e(`connection-details`)},h=()=>{l(),t()},g=V(`colors`,`vechain-kit-text-secondary`);return Y(q,{children:[Y(Z,{children:[J(R,{children:n(`Settings`)}),!r&&J(Oo,{onClick:()=>e(`profile`)}),J(I,{})]}),Y(F,{w:`full`,children:[Y(B,{w:`full`,spacing:2,children:[J(z,{fontSize:`sm`,fontWeight:`bold`,color:g,textAlign:`left`,w:`full`,children:n(`General`)}),J(Yl,{title:n(`Currency`),onClick:()=>{e(`change-currency`)},leftIcon:Mr,rightIcon:Tr}),J(Yl,{title:n(`Language`),onClick:()=>{e(`change-language`)},leftIcon:Ur,rightIcon:Tr}),c.isConnectedWithPrivy&&!s?.delegatorUrl&&J(Yl,{title:n(`Gas Token Preferences`),onClick:()=>{e(`gas-token-settings`)},leftIcon:Lr,rightIcon:Tr}),J(Yl,{title:n(`Terms and Policies`),onClick:()=>{e({type:`terms-and-privacy`,props:{onGoBack:()=>e(`settings`)}})},leftIcon:ei,rightIcon:Tr}),J(Yl,{title:n(`Logout`),onClick:()=>e({type:`disconnect-confirm`,props:{onDisconnect:h,onBack:()=>e(`settings`)}}),leftIcon:Gr})]}),f&&J(B,{w:`full`,spacing:2,mt:4,children:J(Yl,{title:n(`Upgrade Smart Account to V3`),description:n(`A new version is available for your account`),onClick:p,leftIcon:$r,extraContent:J(j,{minWidth:`8px`,height:`8px`,bg:`red.500`,borderRadius:`full`,display:`flex`,alignItems:`center`,justifyContent:`center`,ml:2})})}),c.isConnectedWithSocialLogin&&Y(B,{w:`full`,spacing:2,mt:4,children:[J(z,{fontSize:`sm`,fontWeight:`bold`,color:g,textAlign:`left`,w:`full`,children:n(`Access and security`)}),J(Yl,{title:n(`Passkey`),onClick:()=>a(),leftIcon:Ir}),J(Yl,{title:n(`Backup`),onClick:()=>{i()},leftIcon:Hr}),J(Yl,{title:n(`Manage MFA`),onClick:()=>{o()},leftIcon:ti}),J(Yl,{title:n(`Login methods`),onClick:()=>{e(`privy-linked-accounts`)},leftIcon:oi,rightIcon:Tr})]}),Y(B,{w:`full`,spacing:2,mt:4,children:[J(z,{fontSize:`sm`,fontWeight:`bold`,color:g,textAlign:`left`,w:`full`,children:n(`Help`)}),J(Yl,{title:n(`Connection details`),onClick:m,leftIcon:ai,rightIcon:Tr}),J(Yl,{title:n(`Explore ecosystem`),onClick:()=>e(`ecosystem`),leftIcon:Wr,rightIcon:Tr}),J(Yl,{title:n(`Frequently asked questions`),onClick:()=>e({type:`faq`,props:{onGoBack:()=>e(`settings`),showLanguageSelector:!1}}),leftIcon:kr,rightIcon:Tr})]})]}),J(L,{p:0})]})},xu=({title:e,description:t,icon:n})=>{let r=V(`colors`,`vechain-kit-text-secondary`),i=V(`colors`,`vechain-kit-text-primary`);return Y(B,{spacing:6,align:`center`,py:8,children:[J(P,{as:n,boxSize:16,color:r}),Y(B,{spacing:2,children:[J(z,{fontSize:`lg`,fontWeight:`500`,textAlign:`center`,color:i,children:e}),J(z,{fontSize:`md`,color:r,textAlign:`center`,px:4,children:t})]})]})},Su=(e,t=`en-US`)=>new Intl.DateTimeFormat(t,{month:`short`,day:`numeric`}).format(new Date(e)),Cu=({document:e})=>{let{t}=X(),n=V(`colors`,`vechain-kit-text-secondary`),r=e.documentSource===se.VECHAIN_KIT&&e.documentType===ue.TERMS;return Y(N,{children:[Y(Zt,{size:`sm`,borderRadius:`full`,color:n,children:[`v`,e.version]}),J(z,{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:Su(e.timestamp)})})]})},wu=({title:e,description:t,documents:n,bg:r,hoverBg:i,currentPolicy:a})=>{let{t:o}=X(),s=V(`colors`,`vechain-kit-text-primary`),c=V(`colors`,`vechain-kit-text-secondary`),l=n?.length>0,u=n?.find(e=>e.id===a?.id);return l?J(nt,{border:`none`,mb:3,children:({isExpanded:l})=>Y(q,{children:[Y(tt,{bg:r,borderRadius:`xl`,_hover:{bg:i},children:[Y(B,{w:`full`,align:`flex-start`,textAlign:`left`,children:[J(z,{fontWeight:`700`,color:s,children:e}),J(z,{fontSize:`xs`,color:c,children:t})]}),J(P,{as:l?Er:Cr,fontSize:`20px`,color:c})]}),J(rt,{pb:4,pt:3,children:Y(B,{align:`stretch`,spacing:4,children:[u?.id?Y(N,{w:`full`,children:[J(P,{as:Sr,color:s}),J(z,{fontSize:`xs`,color:c,children:o(`You accepted current policy on {{date}}`,{date:Su(u.timestamp)})})]}):null,J(N,{w:`full`,textAlign:`left`,children:J(z,{fontSize:`xs`,fontWeight:`bold`,color:c,children:o(`All policies you have accepted`)})}),J(N,{w:`full`,gap:2,children:J(B,{align:`stretch`,spacing:2,children:n.map(e=>J(Cu,{document:e},e.id))})}),a&&J(M,{variant:`outline`,size:`xs`,alignSelf:`flex-end`,onClick:()=>{window.open(a.url,`_blank`)},children:o(`View Current Policy`)})]})})]})}):null},Tu=()=>{let{account:e}=Q(),{t}=X(),{darkMode:n}=$(),{agreements:r,documents:i}=Jm(),a=G(()=>{let t=r?.filter(t=>O(t.walletAddress,e?.address));return[{id:`vechain-kit-terms`,...E,documentType:ue.TERMS,documentSource:se.VECHAIN_KIT,walletAddress:e?.address??``,timestamp:new Date().getTime()},...t]?.reduce((e,t)=>(e[t.documentType]=[...e[t.documentType]||[],t],e),{})},[r,e?.address]),o=G(()=>i.reduce((e,t)=>{let n=t.documentType;return(!e[n]||t.version>e[n].version)&&(e[n]=t),e},{}),[i]),s=G(()=>Object.values(a).some(e=>e.length>0),[a]),c=n?`whiteAlpha.50`:`blackAlpha.50`,l=n?`whiteAlpha.100`:`blackAlpha.100`,u=G(()=>{let e=[];return a[ue.TERMS]?.length>0&&e.push(0),a[ue.PRIVACY]?.length>0&&e.push(1),a[ue.COOKIES]?.length>0&&e.push(2),e},[a]);return s?J(B,{spacing:4,align:`stretch`,children:Y(et,{allowMultiple:!0,defaultIndex:u,children:[J(wu,{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[ue.TERMS],bg:c,hoverBg:l,currentPolicy:o[ue.TERMS]}),J(wu,{title:t(`Privacy Policy`),description:t(`Privacy policy outlining the data collection and processing practices.`),documents:a[ue.PRIVACY],bg:c,hoverBg:l,currentPolicy:o[ue.PRIVACY]}),J(wu,{title:t(`Cookie Policy`),description:t(`Cookie policy outlining the use of cookies and tracking technologies.`),documents:a[ue.COOKIES],bg:c,hoverBg:l,currentPolicy:o[ue.COOKIES]})]})}):J(xu,{title:t(`No policies accepted`),description:t(`When you have accepted a policy, it will appear here`),icon:Rr})},Eu=({onGoBack:e})=>{let{t}=X();return Y(Om,{children:[Y(Z,{children:[J(R,{children:t(`Terms and Policies`)}),J(Oo,{onClick:e}),J(I,{})]}),J(F,{w:`full`,children:J(B,{spacing:6,align:`stretch`,children:J(Tu,{})})}),J(L,{pt:0})]})},Du=({onDisconnect:e,onBack:t,onClose:n,showCloseButton:r=!0,text:i})=>{let{t:a}=X(),o=V(`colors`,`vechain-kit-text-primary`),s=i??a(`Are you sure you want to disconnect your wallet?`);return Y(q,{children:[Y(Z,{children:[J(R,{children:a(`Logout`)}),J(Oo,{onClick:t}),r?J(I,{onClick:n}):null]}),J(F,{children:Y(B,{spacing:6,align:`center`,mt:10,children:[J(P,{as:Gr,color:`#ef4444`,fontSize:`60px`,opacity:.5}),J(z,{fontSize:`md`,textAlign:`center`,color:o,children:s})]})}),J(L,{w:`full`,mt:4,children:Y(B,{spacing:3,w:`full`,children:[J(M,{onClick:e,"data-testid":`disconnect-button`,variant:`vechainKitLogout`,children:a(`Confirm`)}),J(M,{variant:`vechainKitSecondary`,onClick:t,"data-testid":`cancel-logout-button`,children:a(`Cancel`)})]})})]})},Ou=({wallet:e,isActive:t,onSelect:n,onRemove:i,showRemove:a=!0})=>{let{t:o}=X(),{network:s}=$(),{formattedBalance:c,isLoading:l}=Zs({address:e.address}),{domain:u,image:f,isLoading:p}=kc(e.address,s.type),m=V(`colors`,`vechain-kit-text-primary`),h=V(`colors`,`vechain-kit-text-secondary`),g=V(`colors`,`vechain-kit-border`),_=l||p;return J(lt,{variant:`vechainKitWalletCard`,onClick:n,borderWidth:t?`2px`:`1px`,borderColor:t?`vechain-kit-primary`:g,_hover:{borderColor:t?`vechain-kit-primary`:`vechain-kit-text-secondary`},children:J(ut,{p:4,children:Y(N,{spacing:3,w:`full`,justifyContent:`space-between`,children:[Y(N,{spacing:3,flex:1,minW:0,children:[J(km,{wallet:{address:e.address,domain:u??void 0,image:f??void 0,isLoadingMetadata:p},props:{width:10,height:10}}),Y(B,{spacing:0,alignItems:`flex-start`,flex:1,minW:0,children:[J(z,{fontSize:`sm`,fontWeight:`medium`,color:m,noOfLines:1,children:u?r(u,22,0):d(e.address,6,4)}),J(z,{fontSize:`xs`,color:h,noOfLines:1,children:_?o(`Loading...`):c})]})]}),t&&J(j,{children:J(P,{as:Sr,boxSize:5,color:`vechain-kit-primary`})}),a&&!t&&J(Dt,{"aria-label":o(`Remove wallet`),icon:J(P,{as:ii}),variant:`vechainKitSecondary`,height:`30px`,w:`30px`,borderRadius:`5px`,onClick:e=>{e.stopPropagation(),i()}})]})})})},ku=e=>te(e.map(e=>e.address.toLowerCase()).sort().join(`|`)),Au=({setCurrentContent:e,returnTo:t=`main`,onLogoutSuccess:n})=>{let{t:r}=X(),{isolatedView:i}=Ml(),{account:a,disconnect:o}=Q(),{disconnect:s}=$n(),{open:c}=tr(),{getStoredWallets:l,setActiveWallet:u,removeWallet:d}=Mc(),{saveWallet:f}=Ac(),{refresh:p}=jc(),m=V(`colors`,`vechain-kit-text-secondary`),[h,g]=K(l()),_=vn(ku(l())),v=U(()=>{let e=l();g(e),_.current=ku(e)},[l]);W(()=>{v()},[v,a?.address]),W(()=>{let e=()=>{setTimeout(()=>{v()},100)};if(typeof window<`u`)return window.addEventListener(`wallet_switched`,e),()=>{window.removeEventListener(`wallet_switched`,e)}},[v]),W(()=>{let e=setInterval(()=>{ku(l())!==_.current&&v()},200);return()=>clearInterval(e)},[l,v]);let y=G(()=>{let e=h.find(e=>e.isActive);return e?e.address:a?.address??null},[h,a?.address]),b=G(()=>h.find(e=>e.address.toLowerCase()===y?.toLowerCase()),[h,y]),x=G(()=>h.filter(e=>e.address.toLowerCase()!==y?.toLowerCase()),[h,y]),S=U(n=>{n.toLowerCase()!==y?.toLowerCase()&&(b&&f(b.address),u(n),setTimeout(()=>{v()},50),p(),e({type:t,props:{switchFeedback:{showFeedback:!0}}}))},[y,b,a,u,p,e,v,f]),C=U(r=>{let i=r.address.toLowerCase()===y?.toLowerCase(),a=h.filter(e=>e.address.toLowerCase()!==r.address.toLowerCase());e({type:`remove-wallet-confirm`,props:{walletAddress:r.address,walletDomain:null,onConfirm:async()=>{if(i&&a.length>0){let e=a[0];u(e.address)}else if(i&&a.length===0)try{await s()}catch(e){console.error(`Error disconnecting:`,e)}if(d(r.address),setTimeout(()=>{v()},50),a.length===0){n&&n();return}e({type:`select-wallet`,props:{setCurrentContent:e,onClose:()=>{},returnTo:t,onLogoutSuccess:n}})},onBack:()=>{e({type:`select-wallet`,props:{setCurrentContent:e,onClose:()=>{},returnTo:t,onLogoutSuccess:n}})}}})},[d,v,e,t,n,y,h,u,s]),w=U(()=>{c()},[c]),T=()=>{o(),n?.()};return Y(q,{children:[Y(Z,{children:[!i&&J(Oo,{onClick:()=>{e(t)}}),J(R,{children:r(`Select Wallet`)}),J(I,{})]}),J(F,{w:`full`,children:Y(B,{w:`full`,spacing:4,children:[b&&Y(B,{w:`full`,spacing:2,alignItems:`flex-start`,children:[J(Et,{size:`sm`,color:m,children:r(`Active Wallet`)}),J(Ou,{wallet:b,isActive:!0,onSelect:()=>{},onRemove:()=>C(b),showRemove:h.length>1})]}),x.length>0&&Y(B,{w:`full`,spacing:2,alignItems:`flex-start`,children:[J(Et,{size:`sm`,color:m,children:r(`Other Wallets`)}),x.map(e=>J(Ou,{wallet:e,isActive:!1,onSelect:()=>S(e.address),onRemove:()=>C(e),showRemove:!0},e.address))]})]})}),J(L,{w:`full`,children:Y(B,{w:`full`,spacing:2,children:[J(M,{w:`full`,leftIcon:J(Xr,{}),variant:`vechainKitSecondary`,onClick:w,children:r(`Add New Wallet`)}),J(M,{w:`full`,leftIcon:J(Gr,{}),variant:`vechainKitLogout`,onClick:()=>e({type:`disconnect-confirm`,props:{onDisconnect:T,onBack:()=>e({type:`select-wallet`,props:{setCurrentContent:e,onClose:()=>{},returnTo:t,onLogoutSuccess:n}})}}),children:r(`Logout`)})]})})]})},ju=({walletAddress:e,walletDomain:t,onConfirm:n,onBack:i,onClose:a})=>{let{t:o}=X(),{network:s}=$(),{domain:c}=kc(e,s.type),l=V(`colors`,`vechain-kit-text-primary`),u=c?r(c,20,0):d(e,6,4);return Y(q,{children:[Y(Z,{children:[J(R,{children:o(`Remove`)}),J(Oo,{onClick:i}),a&&J(I,{onClick:a})]}),J(F,{children:Y(B,{spacing:6,align:`center`,mt:10,children:[J(P,{as:ii,color:`#ef4444`,fontSize:`60px`,opacity:.5}),J(z,{fontSize:`md`,textAlign:`center`,color:l,children:o(`Are you sure you want to remove this wallet?`)}),J(z,{fontSize:`sm`,textAlign:`center`,color:`vechain-kit-text-secondary`,fontWeight:`600`,children:u}),J(z,{fontSize:`sm`,textAlign:`center`,color:`vechain-kit-text-secondary`,children:d(e,8,7)})]})}),J(L,{w:`full`,mt:4,children:Y(B,{spacing:3,w:`full`,children:[J(M,{onClick:n,"data-testid":`remove-wallet-button`,variant:`vechainKitLogout`,children:o(`Remove`)}),J(M,{variant:`vechainKitSecondary`,onClick:i,"data-testid":`cancel-remove-button`,children:o(`Cancel`)})]})})]})},Mu=jo[`@vechain/dapp-kit-react`]||Mo[`@vechain/dapp-kit-react`]||`unknown`,Nu=jo[`@privy-io/react-auth`]||`unknown`,Pu=({connectionCache:e})=>{let{t}=X(),{connection:n,smartAccount:r,connectedWallet:i}=Q(),{source:a}=er(),{privy:o,network:s}=$(),c=o?.appId,{data:l,isLoading:u}=Ho(c||[]),{onCopy:f,hasCopied:p}=ln(``),{data:m,isLoading:h}=Wo(),{data:g,isLoading:_}=vp(r.address??``,i?.address??``),v=V(`colors`,`vechain-kit-card`),b=V(`colors`,`vechain-kit-text-secondary`),x=V(`colors`,`vechain-kit-text-primary`),S=(()=>n.isConnectedWithCrossApp&&e?.ecosystemApp?e.ecosystemApp.name:n.isConnectedWithSocialLogin&&l?Object.values(l)[0]?.name??null:n.isConnectedWithDappKit&&a?a:null)(),C=n.isConnectedWithSocialLogin&&u,w=({label:e,value:t,isLoading:n=!1,href:r})=>Y(N,{w:`full`,justifyContent:`space-between`,children:[Y(z,{fontSize:`sm`,color:x,children:[e,`:`]}),J(z,{fontSize:`sm`,as:r?`a`:void 0,href:r,target:`_blank`,rel:`noopener noreferrer`,style:{textDecoration:r?`underline`:`none`},color:b,children:n?`Loading...`:t})]});return C?J(B,{w:`full`,h:`full`,justify:`center`,align:`center`,minH:`200px`,borderRadius:`xl`,bg:v,children:J(Jt,{})}):S?Y(B,{p:4,bg:v,borderRadius:`xl`,spacing:4,w:`full`,justifyContent:`space-between`,children:[J(w,{label:t(`Logged in with`),value:S}),n.isConnectedWithCrossApp&&e?.timestamp&&J(w,{label:t(`At`),value:new Date(e.timestamp).toLocaleString()}),J(w,{label:t(`Connection Type`),value:n.source.type,isLoading:n.isLoading}),J(bt,{}),J(w,{label:t(`Network`),value:s.type}),J(w,{label:t(`Node URL`),value:s.nodeUrl||y(s.type).nodeUrl}),n.isConnectedWithPrivy&&J(bt,{}),n.isConnectedWithPrivy&&Y(N,{w:`full`,justifyContent:`space-between`,children:[Y(z,{fontSize:`sm`,color:x,children:[t(`Embedded wallet`),`:`]}),Y(N,{children:[J(z,{fontSize:`sm`,color:b,children:i?.address?d(i.address,8,7):`-`}),J(P,{color:b,onClick:()=>{i?.address&&f(i.address)},opacity:i?.address?1:.4,pointerEvents:i?.address?`auto`:`none`,cursor:`pointer`,as:p?Sr:jr})]})]}),n.isConnectedWithPrivy?Y(q,{children:[J(w,{label:t(`Smart Account`),value:`v${g?.version??``} ${g?.isDeployed?``:`(not deployed)`}`,isLoading:_}),J(w,{label:t(`Privy Status`),value:m||``,isLoading:h})]}):r.isDeployed&&J(w,{label:t(`Smart Account`),value:`v${g?.version??``}`,isLoading:_}),J(bt,{}),J(w,{label:t(`VeChain Kit`),value:Ao,href:`https://github.com/vechain/vechain-kit/releases/tag/${Ao}`}),J(w,{label:`DAppKit`,value:Mu}),J(w,{label:`Privy`,value:Nu})]}):null},Fu=()=>{let{connection:e}=Q(),{t}=X(),{privy:n,darkMode:r}=$(),{getConnectionCache:i}=Bf(),a=i(),o=V(`colors`,`vechain-kit-card`);return e.isConnectedWithPrivy?Y(B,{w:`full`,align:`stretch`,textAlign:`center`,mt:5,p:3,borderRadius:`lg`,bg:o,shadow:`sm`,children:[J(z,{fontSize:`xs`,fontWeight:`800`,children:t(`Wallet secured by`)}),Y(N,{justify:`center`,children:[J(Ve,{isDark:r,w:`50px`}),J(P,{as:qr,ml:3}),e.isConnectedWithVeChain?J(be,{isDark:r,w:`80px`,h:`auto`,mb:`3px`}):e.isConnectedWithCrossApp&&a&&J(Ot,{src:a.ecosystemApp.logoUrl,alt:a.ecosystemApp.name,maxW:`40px`,borderRadius:`md`}),e.isConnectedWithSocialLogin&&!e.isConnectedWithVeChain&&J(Ot,{src:n?.appearance.logo,alt:n?.appearance.logo,maxW:`40px`,borderRadius:`md`})]})]}):null},Iu=({onGoBack:e})=>{let{t}=X(),{getConnectionCache:n}=Bf(),r=n()??void 0;return Y(Om,{children:[Y(Z,{children:[J(R,{children:t(`Connection Details`)}),J(Oo,{onClick:()=>{e()}}),J(I,{})]}),Y(F,{w:`full`,children:[J(Pu,{connectionCache:r}),J(Fu,{})]}),J(L,{pt:0})]})},Lu=({accountType:e,accountDescription:t,isLoading:n,onConfirm:r,onCancel:i})=>{let{t:a}=X();return Y(B,{spacing:6,align:`stretch`,children:[J(z,{fontSize:`md`,textAlign:`center`,color:V(`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})}),Y(B,{spacing:3,w:`full`,children:[J(M,{height:`60px`,colorScheme:`red`,w:`full`,onClick:r,isLoading:n,children:a(`Remove Login Method`)}),J(M,{isLoading:n,height:`60px`,w:`full`,onClick:i,children:a(`Cancel`)})]})]})},Ru=({onBack:e})=>{let{t}=X(),{privy:n,dappKit:r}=$(),[i,a]=K(null),[o,s]=K(!1),[c,l]=K(!1),[u,f]=K(!1),p=V(`colors`,`vechain-kit-text-primary`),m=V(`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:T,linkTelegram:E,linkFarcaster:D,linkPasskey:O,linkDiscord:k,unlinkEmail:A,unlinkGoogle:ee,unlinkApple:te,unlinkSpotify:ne,unlinkInstagram:re,unlinkTiktok:ie,unlinkGithub:ae,unlinkLinkedIn:oe,unlinkTelegram:se,unlinkFarcaster:ce,unlinkPhone:le,unlinkPasskey:ue,unlinkDiscord:de,linkWallet:fe}=Kn(),pe=G(()=>{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]),me=e=>{switch(e){case`google_oauth`:return na;case`email`:return Kr;case`passkey`:return Ir;case`wallet`:return si;case`twitter_oauth`:return la;case`phone`:return Yr;case`spotify_oauth`:return ha;case`apple_oauth`:return da;case`instagram_oauth`:return pa;case`tiktok_oauth`:return va;case`github_oauth`:return zr;case`linkedin_oauth`:return ma;case`telegram`:return ga;case`farcaster`:return ua;case`discord_oauth`:return fa;default:return}},he=()=>{let e=h?.linkedAccounts?.filter(e=>e.type!==`wallet`||e.type===`wallet`&&e.connectorType!==`embedded`);return e&&e?.length>1},ge=async e=>{if(he()){f(!0);try{switch(e.type){case`google_oauth`:await ee(e.subject);break;case`email`:await A(e.address);break;case`passkey`:await ue(e.subject);break;case`phone`:await le(e.number);break;case`spotify_oauth`:await ne(e.subject);break;case`apple_oauth`:await te(e.subject);break;case`instagram_oauth`:await re(e.subject);break;case`tiktok_oauth`:await ie(e.subject);break;case`github_oauth`:await ae(e.subject);break;case`linkedin_oauth`:await oe(e.subject);break;case`telegram`:await se(e.subject);break;case`farcaster`:await ce(e.subject);break;case`discord_oauth`:await de(e.subject);break;default:break}}catch(e){console.error(e)}finally{f(!1),a(null)}}},_e=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`${d(e.address)} - ${e.walletClientType}`;default:return``}},ve=h?.linkedAccounts?.map(e=>e.type)||[],ye=n?.loginMethods||[],be=!ve.includes(`google_oauth`)&&ye.includes(`google`),xe=!ve.includes(`email`)&&ye.includes(`email`),Se=!ve.includes(`twitter_oauth`)&&ye.includes(`twitter`),Ce=!ve.includes(`phone`)&&ye.includes(`sms`),we=!ve.includes(`spotify_oauth`)&&ye.includes(`spotify`),Te=!ve.includes(`apple_oauth`)&&ye.includes(`apple`),Ee=!ve.includes(`instagram_oauth`)&&ye.includes(`instagram`),De=!ve.includes(`tiktok_oauth`)&&ye.includes(`tiktok`),Oe=!ve.includes(`github_oauth`)&&ye.includes(`github`),ke=!ve.includes(`linkedin_oauth`)&&ye.includes(`linkedin`),Ae=!ve.includes(`telegram`)&&ye.includes(`telegram`),je=!ve.includes(`farcaster`)&&ye.includes(`farcaster`),Me=!ve.includes(`discord_oauth`)&&ye.includes(`discord`);return o?Y(Om,{children:[Y(Z,{children:[J(R,{children:t(`Select Additional Login Method`)}),J(Oo,{onClick:()=>s(!1)}),J(I,{})]}),J(F,{w:`full`,children:Y(B,{spacing:3,align:`stretch`,w:`full`,children:[J(Yl,{title:t(`Set up Passkey`),description:t(`Set up a passkey for easier access`),onClick:()=>O(),leftIcon:Ir}),be&&J(Yl,{title:t(`Link Google Account`),description:t(`Connect your Google account for easier access`),onClick:()=>_(),leftIcon:na}),xe&&J(Yl,{title:t(`Link Email Account`),description:t(`Connect your email for easier access`),onClick:()=>g(),leftIcon:Kr,stacked:!0}),Se&&J(Yl,{title:t(`Link Twitter Account`),description:t(`Connect your Twitter account for easier access`),onClick:()=>v(),leftIcon:la}),Ce&&J(Yl,{title:t(`Link Phone Number`),description:t(`Connect your phone number for easier access`),onClick:()=>y(),leftIcon:Yr}),we&&J(Yl,{title:t(`Link Spotify Account`),description:t(`Connect your Spotify account for easier access`),onClick:()=>b(),leftIcon:ha}),Te&&J(Yl,{title:t(`Link Apple Account`),description:t(`Connect your Apple account for easier access`),onClick:()=>x(),leftIcon:da}),Ee&&J(Yl,{title:t(`Link Instagram Account`),description:t(`Connect your Instagram account for easier access`),onClick:()=>S(),leftIcon:pa}),De&&J(Yl,{title:t(`Link Tiktok Account`),description:t(`Connect your Tiktok account for easier access`),onClick:()=>C(),leftIcon:va}),Oe&&J(Yl,{title:t(`Link Github Account`),description:t(`Connect your Github account for easier access`),onClick:()=>w(),leftIcon:zr}),ke&&J(Yl,{title:t(`Link LinkedIn Account`),description:t(`Connect your LinkedIn account for easier access`),onClick:()=>T(),leftIcon:ma}),Ae&&J(Yl,{title:t(`Link Telegram Account`),description:t(`Connect your Telegram account for easier access`),onClick:()=>E(),leftIcon:ga}),je&&J(Yl,{title:t(`Link Farcaster Account`),description:t(`Connect your Farcaster account for easier access`),onClick:()=>D(),leftIcon:ua}),Me&&J(Yl,{title:t(`Link Discord Account`),description:t(`Connect your Discord account for easier access`),onClick:()=>k(),leftIcon:fa}),pe&&J(Yl,{title:t(`Link External Wallet`),description:t(`Connect an external wallet for easier access`),onClick:()=>fe(),leftIcon:si}),!be&&!xe&&!Se&&!Ce&&!we&&!Te&&!Ee&&!De&&!Oe&&!ke&&!Ae&&!je&&!Me&&J(z,{fontSize:`sm`,textAlign:`center`,opacity:.7,children:t(`No additional accounts available to link`)})]})}),J(L,{pt:0})]}):i?Y(Om,{children:[Y(Z,{children:[J(R,{children:t(`Remove Login Method`)}),J(Oo,{onClick:()=>a(null)}),J(I,{})]}),J(F,{children:J(Lu,{accountType:i.type,accountDescription:_e(i),isLoading:u,onConfirm:()=>ge(i),onCancel:()=>a(null)})}),J(L,{pt:0})]}):Y(Om,{children:[Y(Z,{children:[J(R,{children:t(`Login methods`)}),J(Oo,{onClick:e}),J(I,{})]}),J(F,{w:`full`,children:Y(B,{spacing:3,align:`center`,w:`full`,justify:`center`,children:[Y(B,{spacing:1,justify:`flex-start`,alignItems:`flex-start`,mb:5,textAlign:`left`,w:`full`,children:[J(z,{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&&J(z,{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.`)}),J(M,{variant:`link`,mt:0,size:`sm`,onClick:()=>l(!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=>Y(xt,{p:4,borderWidth:`1px`,borderRadius:`md`,align:`center`,justify:`space-between`,w:`full`,children:[Y(xt,{align:`center`,gap:3,children:[J(P,{as:me(e.type),color:p}),Y(B,{align:`start`,spacing:0,children:[J(z,{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`)}),J(z,{fontSize:`sm`,color:m,children:_e(e)})]})]}),J(M,{size:`sm`,variant:`ghost`,colorScheme:`red`,isDisabled:!he(),onClick:()=>{e.type===`passkey`?O():a(e)},children:t(`Remove`)})]},e.type))]})}),J(L,{w:`full`,children:J(M,{w:`full`,variant:`vechainKitPrimary`,onClick:()=>s(!0),leftIcon:J(P,{as:Xr}),isDisabled:!be&&!xe&&!Se&&!Ce&&!we&&!Te&&!Ee&&!De&&!Oe&&!ke&&!Ae&&!je&&!Me,children:t(`Add Login Method`)})})]})},zu=[{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}],Bu=()=>{let{t:e}=X(),{account:t,connection:n,smartAccount:r}=Q(),{addNotification:i,getNotifications:a}=Vu(),{data:o}=Ip(r?.address??``,3);W(()=>{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]),W(()=>{!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]),W(()=>{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])},Vu=()=>{let{account:e}=Q(),t=U(e=>{let t=e?.toLowerCase();return{notifications:`vechain_kit_notifications_${t}`,archived:`vechain_kit_archived_notifications_${t}`,initialized:`vechain_kit_notifications_initialized_${t}`}},[]),n=U(()=>{if(!e?.address||!A())return;let n=t(e.address);x(n.initialized)||(de(n.notifications,JSON.stringify(zu)),de(n.initialized,`true`))},[e?.address,t]);W(()=>{n()},[n]);let r=U(()=>{if(!e?.address||!A())return[];let n=x(t(e.address).notifications);return n?JSON.parse(n):[]},[e?.address,t]),i=U(()=>{if(!e?.address||!A())return[];let n=x(t(e.address).archived);return n?JSON.parse(n):[]},[e?.address,t]),a=U(n=>{if(!e?.address||!A())return;let i=t(e.address),a=r(),o=x(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};de(i.notifications,JSON.stringify([c,...a]))},[e?.address,r,t]),o=U(n=>{if(!e?.address||!A())return;let i=t(e.address),a=r().filter(e=>e.id!==n);de(i.notifications,JSON.stringify(a))},[e?.address,r,t]);return{getNotifications:r,getArchivedNotifications:i,addNotification:a,clearAllNotifications:U(()=>{if(!e?.address||!A())return;let n=t(e.address),a=r();de(n.archived,JSON.stringify([...i(),...a])),de(n.notifications,JSON.stringify([]))},[e?.address,r,i,t]),markAsRead:U(n=>{if(!e?.address||!A())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];de(a.notifications,JSON.stringify(l)),de(a.archived,JSON.stringify(e))}},[e?.address,r,i,t]),deleteNotification:o}},Hu=({showArchived:e})=>{let{t}=X();return J(xu,{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?dr:vr})},Uu=({notification:e,isArchiveView:t,onMarkAsRead:n})=>{let{t:r}=X(),i=()=>{n(e.id)};return e.isRead&&!t?null:Y(it,{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:[J(ot,{boxSize:`16px`}),Y(j,{children:[J(st,{fontSize:`sm`,"data-testid":`notification-title`,children:r(e.title)}),J(at,{fontSize:`xs`,lineHeight:`1.2`,"data-testid":`notification-text`,children:r(e.description)})]}),!t&&!e.isRead&&J(Dt,{position:`absolute`,right:1,top:1,size:`sm`,variant:`ghost`,icon:J(Ar,{}),onClick:e=>{e.stopPropagation(),i()},"aria-label":`Mark as read and archive`,"data-testid":`remove-notification-button`})]},e.id)},Wu=({setCurrentContent:e})=>{let{t}=X(),{isolatedView:n}=Ml(),{getNotifications:r,getArchivedNotifications:i,clearAllNotifications:a,markAsRead:o}=Vu(),[s,c]=K(!1),[l,u]=K(r()),[d,f]=K(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 Y(Om,{children:[Y(Z,{children:[!n&&J(Oo,{onClick:()=>e(`main`)}),J(R,{"data-testid":`modal-title`,children:t(s?`Archived Notifications`:`Notifications`)}),J(I,{})]}),Y(yt,{h:[`540px`,`auto`],p:0,children:[J(F,{children:Y(B,{spacing:4,align:`stretch`,w:`full`,children:[Y(N,{justify:`space-between`,children:[J(M,{variant:`ghost`,leftIcon:J(P,{as:s?vr:dr}),size:`sm`,onClick:h,"data-testid":`toggle-view-button`,children:t(s?`Current`:`Archived`)}),!s&&l.length>0&&J(M,{variant:`ghost`,size:`sm`,onClick:p,"data-testid":`clear-all-button`,children:t(`Clear all`)})]}),g.length===0?J(Hu,{showArchived:s}):J(B,{spacing:3,children:_.map(e=>J(Uu,{notification:e,isArchiveView:s,onMarkAsRead:m},e.id))})]})}),J(L,{pt:0})]})]})},Gu=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`}},Ku=({category:e,...t})=>{let{t:n}=X(),r=e.toLowerCase();return J(Zt,{size:`sm`,colorScheme:Gu(r),borderRadius:`full`,px:2,...t,children:n(r)})},qu=({name:e,imageUrl:t,logoComponent:n,category:r,onClick:i,size:a=`md`})=>Y(lt,{variant:`vechainKitAppCard`,_hover:{opacity:.8},cursor:`pointer`,onClick:i,position:`relative`,children:[r&&J(j,{position:`absolute`,top:`2`,right:`2`,zIndex:`1`,children:J(Ku,{category:r})}),J(ut,{p:a===`sm`?2:4,alignItems:`center`,children:Y(B,{spacing:2,h:`100%`,justifyContent:`space-between`,children:[n||t&&J(Ot,{src:t,fallbackSrc:b,alt:e,height:`90px`,objectFit:`contain`,rounded:`full`}),e&&J(z,{fontWeight:`medium`,wordBreak:`break-word`,noOfLines:1,textAlign:`center`,w:`full`,children:e})]})})]}),Ju=({xApp:e,setCurrentContent:t,selectedCategory:n})=>{let{data:r,isLoading:i}=Fc(e.id),{data:a,isLoading:o}=Hc(r?.logo);return J(qt,{isLoaded:!i&&!o,borderRadius:`md`,height:`100%`,children:J(qu,{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}})}})})},Yu=({name:e,image:t,url:n,description:r,category:i,logoComponent:a,selectedCategory:o,setCurrentContent:s})=>J(qu,{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}}),Xu=({})=>{let{t:e}=X(),{shortcuts:t}=mm();return t.length===0?null:Y(B,{w:`full`,align:`flex-start`,spacing:2,children:[J(z,{fontSize:`sm`,fontWeight:`500`,children:e(`Shortcuts`)}),J(wt,{templateColumns:`repeat(4, 1fr)`,gap:2,w:`full`,children:t.map(e=>J(Tt,{children:J(lt,{_hover:{opacity:.8},cursor:`pointer`,onClick:()=>window.open(e.url,`_blank`),children:J(ut,{p:2,alignItems:`center`,children:J(Ot,{src:e.image,fallbackSrc:b,alt:e.name,objectFit:`contain`,rounded:`full`})})})},e.url))})]})},Zu=({selectedCategory:e,onCategoryChange:t,categories:n,darkMode:r})=>{let{t:i}=X();return Y(j,{width:`full`,mb:4,children:[J(z,{fontSize:`sm`,fontWeight:`500`,mb:2,children:i(`Filter by category`)}),Y(en,{spacing:2,children:[J(tn,{children:J(Zt,{size:`md`,borderRadius:`full`,variant:e===null?`solid`:`outline`,colorScheme:r?`gray`:`blackAlpha`,cursor:`pointer`,onClick:()=>t(null),children:i(`All`)})}),n.map(n=>J(tn,{children:J(Ku,{category:n,size:`md`,variant:e===n?`solid`:`outline`,cursor:`pointer`,onClick:()=>t(n)})},n))]})]})},Qu=[{name:`VeBetterDAO`,description:`Engage, earn and prosper by doing sustainable actions.`,external_url:Qe,logo:new URL(`/static/img/coins/64x64/33509.png`,Re).toString(),banner:new URL(`/static/img/icons/vbd.png`,Re).toString(),screenshots:[],social_urls:[],app_urls:[],tweets:[],ve_world:{banner:new URL(`/static/img/icons/vbd.png`,Re).toString()},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:Ue,logo:new URL(`/assets/walletconnect.png`,Ue).toString(),banner:new URL(`/assets/walletconnect.png`,Ue).toString(),screenshots:[],social_urls:[],app_urls:[],tweets:[],ve_world:{banner:new URL(`/assets/walletconnect.png`,Ue).toString()},categories:[]}],$u=({setCurrentContent:e,selectedCategory:t})=>{let{t:n}=X(),{darkMode:r,network:i}=$(),{isolatedView:a}=Ml(),o=V(`colors`,`vechain-kit-text-tertiary`),[s,c]=K(``),[l,u]=K(t||null);W(()=>{t!==void 0&&u(t)},[t]);let{data:d}=tc(),{data:f}=Cc(d?(parseInt(d)-1).toString():`1`),{data:p,isLoading:m,error:h}=Kf(),g=G(()=>{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=Qu.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}=mm();return Y(q,{children:[Y(Z,{children:[J(R,{children:n(`Ecosystem`)}),!a&&J(Oo,{onClick:()=>e(`settings`)}),J(I,{})]}),J(F,{overflowY:`auto`,minH:`300px`,children:Y(B,{spacing:6,w:`full`,children:[J(Xu,{setCurrentContent:e}),S.length>0&&J(z,{fontSize:`sm`,fontWeight:`500`,w:`full`,textAlign:`left`,children:n(`All apps`)}),Y(At,{size:`lg`,children:[J(kt,{placeholder:n(`Search Apps`),value:s,onChange:e=>{c(e.target.value)},bg:r?`#00000038`:`gray.50`,borderRadius:`xl`,height:`56px`,pl:12}),J(jt,{h:`56px`,w:`56px`,pl:4,children:J(Qr,{color:o})})]}),g.length>0&&J(Zu,{selectedCategory:l,onCategoryChange:e=>{u(e)},categories:g,darkMode:r}),Y(wt,{templateColumns:`repeat(2, 1fr)`,gap:4,w:`full`,children:[b&&v.length>0&&J(q,{children:v.map(t=>J(Tt,{children:J(Yu,{name:t.name,image:t.logo,url:t.external_url,setCurrentContent:e,description:t.description,selectedCategory:l})},t.name))}),x&&_.length>0&&J(q,{children:_.map(t=>J(Tt,{children:J(Ju,{xApp:t.app,setCurrentContent:e,selectedCategory:l})},t.id))}),m?J(Tt,{colSpan:2,children:J(pt,{py:4,children:J(Jt,{})})}):h?J(Tt,{colSpan:2,children:J(z,{color:`red.500`,textAlign:`center`,children:n(`Failed to load App Hub apps`)})}):y.length>0?y.map(t=>J(Tt,{children:J(Yu,{name:t.name,image:t.logo,url:t.url,setCurrentContent:e,description:t.description,category:t.category,selectedCategory:l})},t.id)):l&&!x&&J(Tt,{colSpan:2,children:J(pt,{py:4,children:J(z,{children:n(`No apps found in this category`)})})})]})]})}),J(L,{pt:0})]})},ed=({name:e,image:t,url:n,description:r})=>{let{t:i}=X(),{isShortcut:a,addShortcut:o,removeShortcut:s}=mm(),c=a(n);return J(M,{px:4,width:`full`,height:`45px`,variant:`vechainKitSecondary`,borderRadius:`xl`,onClick:()=>{c?s(n):o({name:e,image:t,url:n,description:r})},leftIcon:J(P,{as:c?br:yr}),children:i(c?`Remove from shortcuts`:`Add to shortcuts`)})},td=({setCurrentContent:e,name:t,image:n,url:r,description:i,category:a,selectedCategory:o,logoComponent:s})=>{let{t:c}=X();return Y(q,{children:[Y(Z,{children:[J(R,{children:t}),J(Oo,{onClick:()=>{e(o?{type:`ecosystem-with-category`,props:{selectedCategory:o,setCurrentContent:e}}:`ecosystem`)}}),J(I,{})]}),J(F,{children:Y(B,{spacing:6,align:`center`,w:`full`,children:[Y(xt,{direction:`column`,align:`center`,children:[s||J(Ot,{src:n,alt:t,w:`200px`,h:`200px`,objectFit:`contain`,borderRadius:`xl`}),a&&J(N,{mt:2,children:J(Ku,{category:a})})]}),J(z,{fontSize:`sm`,textAlign:`center`,children:i}),J(z,{fontSize:`sm`,textAlign:`center`,children:c(`Click below to access {{ name }} and explore its features.`,{name:t})})]})}),J(L,{children:Y(B,{w:`full`,spacing:4,children:[Y(M,{variant:`vechainKitSecondary`,onClick:()=>{window.open(r,`_blank`)},children:[c(`Launch {{name}}`,{name:t}),J(P,{as:Pr,ml:2})]}),J(ed,{name:t,image:n,url:r,description:i})]})})]})},nd=({children:e})=>J(lr.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}),rd=({description:e})=>{let{darkMode:t}=$(),n=new URL(`intent/tweet`,Ye);n.searchParams.set(`text`,e);let r=new URL(`share/url`,Fe);r.searchParams.set(`url`,e);let i=new URL(``,fe);return i.searchParams.set(`text`,e),Y(N,{gap:2,children:[J(nd,{children:J(Nt,{href:n.toString(),isExternal:!0,children:J(j,{bg:t?`blackAlpha.700`:`lightgrey`,p:2,borderRadius:`full`,children:J(la,{size:22})})})}),J(nd,{children:J(Nt,{href:r.toString(),isExternal:!0,children:J(j,{bg:`#30abec`,p:2,borderRadius:`full`,children:J(_a,{color:`white`,size:22})})})}),J(nd,{children:J(Nt,{href:i.toString(),isExternal:!0,children:J(j,{bg:`#01cb37`,p:2,borderRadius:`full`,children:J(ya,{size:22,color:`white`})})})})]})},id=({status:e,uiConfig:t,onTryAgain:n,txReceipt:r,txError:i,onClose:a})=>{let{t:o}=X(),{network:s}=$(),c=V(`colors`,`vechain-kit-error`),l=V(`colors`,`vechain-kit-success`),u=V(`colors`,`vechain-kit-text-primary`),d=V(`colors`,`vechain-kit-text-secondary`),f=G(()=>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??J(Jt,{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??J(P,{as:Dr,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??J(P,{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=`${y(s.type).explorerUrl}/${r?.meta.txID}`;return Y(q,{children:[Y(Z,{children:[J(R,{children:p.title}),J(I,{isDisabled:e===`pending`&&!t?.isClosable})]}),J(F,{children:Y(B,{align:`center`,p:6,spacing:3,children:[p.icon,e===`success`&&t?.showShareOnSocials&&Y(B,{mt:2,spacing:3,children:[J(z,{fontSize:`sm`,fontWeight:`bold`,color:d,children:o(`Share on`)}),J(rd,{description:m})]}),p.description&&J(z,{fontSize:e===`ready`?`md`:`sm`,textAlign:`center`,color:e===`error`?c:u,mt:5,style:{lineBreak:`anywhere`},children:p.description})]})}),J(L,{justifyContent:`center`,children:Y(B,{width:`full`,spacing:4,children:[e===`error`&&!!n&&Y(M,{variant:`vechainKitPrimary`,onClick:n,width:`full`,children:[J(P,{mr:2,as:Zr}),o(`Try again`)]}),e===`ready`&&J(M,{onClick:n,variant:`vechainKitPrimary`,width:`full`,children:o(`Confirm`)}),(e===`success`||e===`error`||e===`ready`)&&J(M,{onClick:a,variant:`ghost`,width:`full`,children:o(`Close`)}),t?.showExplorerButton&&r?.meta.txID&&J(Nt,{href:`${y(s.type).explorerUrl}/${r?.meta.txID}`,isExternal:!0,opacity:.5,fontSize:`14px`,textDecoration:`underline`,children:Y(N,{spacing:1,alignItems:`center`,w:`full`,justifyContent:`center`,children:[J(z,{color:d,children:o(`View transaction on the explorer`)}),J(P,{size:`sm`,as:Pr,color:d})]})})]})})]})},ad=({isOpen:e,onClose:t,status:n,uiConfig:r,txReceipt:i,txError:a,onTryAgain:o})=>{let{darkMode:s,theme:c}=$();return e?J(Zd,{darkMode:s,theme:c,children:J(zo,{isOpen:e,onClose:t,allowExternalFocus:!0,blockScrollOnMount:!0,closeOnOverlayClick:n!==`pending`&&r?.isClosable,children:J(id,{status:n,onTryAgain:o,uiConfig:r,txReceipt:i,onClose:t,txError:a})})}):null},od=({txId:e,title:t,description:n,onDone:r,showSocialButtons:i=!1})=>{let{t:a}=X(),{network:o}=$(),s=y(o.type).explorerUrl,c=`${s}/${e}`,l=V(`colors`,`vechain-kit-success`),u=V(`colors`,`vechain-kit-text-primary`),d=V(`colors`,`vechain-kit-text-secondary`);return Y(q,{children:[Y(Z,{children:[J(R,{children:t}),J(I,{})]}),J(F,{children:Y(B,{align:`center`,p:6,spacing:3,children:[J(P,{as:Or,fontSize:`100px`,color:l,"data-testid":`success-icon`}),n&&J(z,{fontSize:`sm`,textAlign:`center`,color:u,children:n}),i&&e&&Y(B,{mt:2,spacing:3,children:[J(z,{fontSize:`sm`,fontWeight:`bold`,color:d,children:a(`Share on`)}),J(rd,{description:c})]})]})}),J(L,{justifyContent:`center`,children:Y(B,{width:`full`,spacing:4,children:[J(M,{onClick:r,variant:`vechainKitSecondary`,width:`full`,children:a(`Done`)}),e&&J(Nt,{href:`${s}/${e}`,isExternal:!0,opacity:.5,fontSize:`14px`,textDecoration:`underline`,children:Y(N,{spacing:1,alignItems:`center`,w:`full`,justifyContent:`center`,children:[J(z,{color:d,children:a(`View transaction on the explorer`)}),J(P,{size:16,as:Pr})]})})]})})]})},sd=({txId:e,title:t,description:n,onDone:r})=>{let{t:i}=X(),{network:a,darkMode:o}=$(),s=y(a.type).explorerUrl;return Y(q,{children:[Y(Z,{children:[J(R,{children:t}),J(I,{})]}),J(F,{children:Y(B,{align:`center`,p:6,spacing:3,children:[J(P,{as:Dr,fontSize:`100px`,color:o?`red.400`:`red.500`,"data-testid":`error-icon`}),n&&J(z,{fontSize:`sm`,textAlign:`center`,children:n})]})}),J(L,{justifyContent:`center`,children:Y(B,{width:`full`,spacing:4,children:[J(M,{onClick:r,variant:`vechainKitSecondary`,width:`full`,children:i(`Done`)}),e&&J(Nt,{href:`${s}/${e}`,isExternal:!0,opacity:.5,fontSize:`14px`,textDecoration:`underline`,children:Y(N,{spacing:1,alignItems:`center`,w:`full`,justifyContent:`center`,children:[J(z,{children:i(`View transaction on the explorer`)}),J(P,{size:16,as:Pr})]})})]})})]})},cd=({isOpen:e,onClose:t,initialContent:n=`profile`})=>{let{account:r}=Q(),{themeConfig:i}=Yd(),{accountModalContent:a,setAccountModalContent:o}=$d();return W(()=>{e&&o(n)},[e,n,o]),J(zo,{isOpen:e,onClose:t,allowExternalFocus:!0,blockScrollOnMount:!0,mobileMinHeight:i?.modal?.useBottomSheetOnMobile?`520px`:`510px`,mobileMaxHeight:i?.modal?.useBottomSheetOnMobile?`520px`:`510px`,desktopMinHeight:`485px`,desktopMaxHeight:`485px`,children:(()=>{if(typeof a==`object`)switch(a.type){case`send-token`:return J(Nl,{...a.props});case`send-token-summary`:return J(Pl,{...a.props});case`swap-token`:return J(zl,{...a.props});case`choose-name`:return J(Bl,{...a.props});case`choose-name-search`:return J(Wl,{...a.props});case`choose-name-summary`:return J(Gl,{...a.props});case`app-overview`:return J(td,{...a.props,setCurrentContent:o});case`disconnect-confirm`:return J(Du,{...a.props});case`remove-wallet-confirm`:return J(ju,{...a.props});case`account-customization`:return J(ou,{...a.props});case`account-customization-summary`:return J(su,{...a.props});case`successful-operation`:return J(od,{...a.props});case`failed-operation`:return J(sd,{...a.props});case`upgrade-smart-account`:return J(du,{...a.props});case`faq`:return J(ql,{...a.props});case`terms-and-privacy`:return J(Eu,{...a.props});case`ecosystem-with-category`:return J($u,{setCurrentContent:o,selectedCategory:a.props.selectedCategory});case`select-wallet`:return J(Au,{setCurrentContent:o,onClose:t,returnTo:a.props.returnTo,onLogoutSuccess:a.props.onLogoutSuccess});case`main`:return J(Al,{setCurrentContent:o,onClose:t,wallet:r,switchFeedback:a.props?.switchFeedback});case`profile`:return J(uu,{setCurrentContent:o,onLogoutSuccess:()=>{t()},switchFeedback:a.props?.switchFeedback})}switch(a){case`main`:return J(Al,{setCurrentContent:o,onClose:t,wallet:r});case`settings`:return J(bu,{setCurrentContent:o,onLogoutSuccess:()=>{t()}});case`profile`:return J(uu,{setCurrentContent:o,onLogoutSuccess:()=>{t()}});case`assets`:return J(fu,{setCurrentContent:o});case`notifications`:return J(Wu,{setCurrentContent:o});case`receive-token`:return J(Fl,{setCurrentContent:o});case`swap-token`:return J(zl,{setCurrentContent:o});case`connection-details`:return J(Iu,{onGoBack:()=>o(`settings`)});case`privy-linked-accounts`:return J(Ru,{onBack:()=>o(`settings`)});case`ecosystem`:return J($u,{setCurrentContent:o});case`add-custom-token`:return J(pu,{setCurrentContent:o});case`change-currency`:return J(hu,{setCurrentContent:o});case`change-language`:return J(gu,{setCurrentContent:o});case`gas-token-settings`:return J(yu,{setCurrentContent:o});default:return null}})()})},ld=({loadingText:e,title:t,onTryAgain:n,onClose:r,onGoBack:i,showBackButton:a=!0})=>{let{t:o}=X(),[s,c]=H.useState(!1);return H.useEffect(()=>{let e=setTimeout(()=>{c(!0)},7e3);return()=>clearTimeout(e)},[]),Y(q,{children:[J(Z,{children:Y(R,{children:[a&&J(Oo,{onClick:i}),t??o(`Connecting...`),J(I,{onClick:r})]})}),Y(F,{children:[J(B,{align:`center`,p:6,gap:0,w:`full`,justifyContent:`center`,minH:`150px`,children:J(Jt,{size:`xl`})}),e&&!s&&J(z,{size:`sm`,textAlign:`center`,children:e}),s&&Y(B,{mt:4,spacing:2,children:[J(z,{color:`orange.300`,size:`sm`,textAlign:`center`,children:o(`This is taking longer than expected.`)}),J(z,{size:`sm`,textAlign:`center`,children:o(`You may want to try establishing the connection again.`)})]})]}),J(L,{justifyContent:`center`,children:s&&Y(M,{variant:`vechainKitPrimary`,onClick:n,children:[J(P,{mr:2,as:Zr}),o(`Try again`)]})})]})},ud=({error:e,onClose:t,onTryAgain:n,onGoBack:r})=>{let{t:i}=X(),a=ur();return Y(q,{children:[J(Z,{children:Y(R,{children:[J(Oo,{onClick:r}),i(`Connection Failed`),J(I,{onClick:t})]})}),J(F,{children:Y(B,{align:`center`,p:6,w:`full`,justifyContent:`center`,minH:`100px`,gap:4,children:[J(lr.div,{transition:{duration:4,ease:`easeInOut`,repeat:a?0:1/0},animate:{scale:a?[1]:[1,1.1,1]},children:J(P,{as:Dr,color:`#ef4444`,fontSize:`60px`,opacity:.5})}),J(z,{w:`full`,size:`sm`,textAlign:`center`,children:e})]})}),J(L,{justifyContent:`center`,children:Y(M,{variant:`vechainKitPrimary`,onClick:n,children:[J(P,{mr:2,as:Zr}),i(`Try again`)]})})]})},dd=({onClose:e,appsInfo:t,isLoading:n,setCurrentContent:r,showBackButton:i=!0})=>{let{t:a}=X(),o=V(`colors`,`vechain-kit-text-primary`),{setConnectionCache:s}=Bf(),{login:c}=Oc(),l=async(n,i)=>{r({type:`loading`,props:{title:`${a(`Connecting with`)} ${i}`,loadingText:a(`Please approve the request in the connection request window...`),onTryAgain:()=>{l(n,i)}}});try{await c(n),s({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 a=e?.message;if(a&&g(a)){r({type:`ecosystem`,props:{appsInfo:t,isLoading:!1}});return}r({type:`error`,props:{error:(e instanceof Error?e:Error(`An unexpected issue occurred while logging in with this app. Please try again or contact support.`)).message,onTryAgain:()=>{l(n,i)}}})}};return J(j,{children:Y(q,{children:[J(Z,{children:Y(R,{children:[i&&J(Oo,{onClick:()=>r(`main`)}),a(`Already have an x2earn app wallet?`),J(I,{onClick:e})]})}),Y(F,{children:[n&&J(B,{minH:`200px`,w:`full`,justifyContent:`center`,children:J(Jt,{})}),!n&&t&&J(B,{spacing:4,w:`full`,pb:6,children:t.map(e=>Y(M,{variant:`loginIn`,fontSize:`14px`,fontWeight:`400`,p:6,borderRadius:16,w:`full`,onClick:()=>{l(e.id,e.name)},justifyContent:`flex-start`,children:[J(Ot,{src:e.logo_url,alt:e.name,w:`30px`}),J(z,{ml:5,children:e.name})]},e.id))}),!n&&!t&&J(z,{textAlign:`center`,color:o,children:a(`No application from VeChain ecosystem is available to login.`)})]}),J(L,{pt:0})]})})},fd=({isOpen:e,onClose:t,initialContent:n=`main`,preventAutoClose:r=!1})=>{let{connection:i}=Q(),[a,o]=K(n);W(()=>{e&&o(n)},[e,n,o]),W(()=>{i.isConnected&&e&&!r&&t()},[i.isConnected,e,t,r]);let s=(()=>{if(!a)return J(kl,{setCurrentContent:o});switch(a){case`main`:return J(kl,{setCurrentContent:o});case`faq`:return J(ql,{onGoBack:()=>o(`main`)})}if(typeof a==`object`&&`type`in a)switch(a.type){case`ecosystem`:return J(dd,{onClose:t,appsInfo:a.props.appsInfo,isLoading:a.props.isLoading,setCurrentContent:o,showBackButton:a.props.showBackButton});case`loading`:return J(ld,{title:a.props.title,loadingText:a.props.loadingText,onTryAgain:a.props.onTryAgain,onClose:t,onGoBack:()=>o(`main`),showBackButton:a.props.showBackButton});case`error`:return J(ud,{error:a.props.error,onClose:t,onTryAgain:a.props.onTryAgain,onGoBack:()=>o(`main`)})}return null})();return s?J(zo,{isOpen:e,onClose:t,allowExternalFocus:!0,blockScrollOnMount:!0,mobileMinHeight:`260px`,mobileMaxHeight:`400px`,desktopMinHeight:`250px`,desktopMaxHeight:`400px`,children:s}):J(zo,{isOpen:e,onClose:t,allowExternalFocus:!0,blockScrollOnMount:!0,mobileMinHeight:`260px`,mobileMaxHeight:`400px`,desktopMinHeight:`250px`,desktopMaxHeight:`400px`,children:J(kl,{setCurrentContent:o})})},pd=({onClick:e,text:t,icon:n,customIcon:r,rightIcon:i,style:a,variant:o=`loginIn`,iconWidth:s=`25px`})=>t?t?Y(M,{...a,variant:o,w:`full`,onClick:e,children:[Y(N,{w:`full`,justify:`flex-start`,gap:2,children:[r||J(P,{as:n,w:s,h:s}),J(z,{opacity:.9,children:t})]}),i]}):null:J(M,{...a,variant:o,w:`full`,onClick:e,children:r||J(P,{as:n,w:`20px`,h:`20px`})}),md=({isLoading:e,buttonStyle:t})=>{let{t:n}=X(),{loginMethods:r,darkMode:i,privyEcosystemAppIDS:a}=$(),o=r?.some(({method:e})=>e===`ecosystem`),{open:s}=tf(),{data:c,isLoading:l}=Ho(a),u=U(e=>{let t=typeof e==`function`?e(`main`):e;typeof t==`object`&&`type`in t?t.type===`ecosystem`?s({type:`ecosystem`,props:{...t.props,showBackButton:!1}}):t.type===`loading`?s({type:`loading`,props:{...t.props,showBackButton:!1}}):s(t):s(t)},[s]);return J(Vt,{placement:`bottom-start`,size:`xl`,closeOnBlur:!1,variant:`vechainKitBase`,children:({isOpen:r})=>Y(q,{children:[J(Gt,{children:Y(M,{isLoading:e,...t,isActive:r,children:[n(`Login`),J(P,{ml:2,as:Cr,transform:r?`rotate(180deg)`:`rotate(0deg)`,transition:`transform 0.2s`})]})}),Y(Ut,{children:[J(Ht,{children:J(Dl,{setCurrentContent:u})}),J(Wt,{borderTop:`none`,pb:`15px`,children:o&&J(N,{justify:`center`,w:`full`,children:J(Ol,{isDark:i,appsInfo:Object.values(c||{}),isLoading:l,setCurrentContent:u})})})]})]})})},hd=({variant:e})=>{let{account:t}=Q();return t?e===`icon`?null:e===`iconAndDomain`?t.domain?J(z,{fontSize:`sm`,children:r(t?.domain??``,16,0)}):J(z,{fontSize:`sm`,children:d(t.address??``,6,4)}):e===`iconDomainAndAssets`?Y(N,{spacing:4,children:[Y(B,{spacing:0,alignItems:`flex-start`,children:[t.domain&&J(z,{fontSize:`sm`,fontWeight:`bold`,children:r(t?.domain??``,16,0)}),J(z,{fontSize:t.domain?`xs`:`sm`,opacity:t.domain?.5:1,"data-testid":`trimmed-address`,children:d(t.address??``,4,4)})]}),J(Zl,{address:t.address??``,maxIcons:3})]}):Y(B,{spacing:0,alignItems:`flex-start`,children:[t.domain&&J(z,{fontSize:`sm`,fontWeight:`bold`,children:r(t?.domain??``,16,0)}),J(z,{fontSize:t.domain?`xs`:`sm`,opacity:t.domain?.5:1,children:d(t.address??``,4,4)})]}):J(Jt,{})},gd=({mobileVariant:e=`iconAndDomain`,desktopVariant:t=`iconAndDomain`,onOpen:n,buttonStyle:r={}})=>{let{account:i}=Q(),[a]=pn(`(min-width: 768px)`);return J(M,{...r,onClick:n,w:`full`,minH:`45px`,maxW:`fit-content`,"data-testid":`wallet-button`,children:Y(N,{w:`full`,minW:`fit-content`,children:[J(km,{wallet:i,props:{width:30,height:30,minWidth:30,minHeight:30}}),J(hd,{variant:a?t:e})]})})},_d=({mobileVariant:e=`iconAndDomain`,desktopVariant:t=`iconDomainAndAddress`,buttonStyle:n,connectionVariant:r=`modal`,label:i=`Login`})=>{let{darkMode:a,loginMethods:o,theme:s}=$(),c=o?.length===1&&o[0].method===`dappkit`,{connection:l,account:u}=Q(),{setSource:d,connectV2:f}=$n(),[p]=pn(`(max-width: 768px)`),m=fn(),h=fn(),{open:g}=tr();return Y(Zd,{darkMode:a,theme:s,children:[l.isConnected&&u?J(gd,{mobileVariant:e,desktopVariant:t,onOpen:h.onOpen,buttonStyle:n}):r===`popover`&&!p?J(md,{isLoading:l.isLoading,buttonStyle:n}):J(M,{isLoading:l.isLoading,onClick:()=>{l.isInAppBrowser?(d(`veworld`),f(null)):c?g():m.onOpen()},...n,children:i}),J(fd,{isOpen:m.isOpen,onClose:m.onClose}),J(cd,{isOpen:h.isOpen,onClose:h.onClose})]})},vd=()=>{let{darkMode:e}=$(),t=25/2,[n]=pn(`(max-width: 280px)`),[r]=pn(`(max-width: 380px)`);return Y(N,{spacing:0,ml:0,children:[J(gt,{size:`25px`,borderRadius:`full`,bg:`#F8F8F8`,p:2,alignItems:`center`,justifyContent:`center`,zIndex:3,children:J(P,{as:na,fontSize:`20px`})}),!n&&J(gt,{ml:`-${t}px`,size:`25px`,borderRadius:`full`,bg:`black`,p:2,alignItems:`center`,justifyContent:`center`,zIndex:2,children:J(P,{as:la,color:`white`,fontSize:`20px`})}),!n&&!r&&J(gt,{ml:`-${t}px`,zIndex:1,size:`25px`,borderRadius:`full`,bg:`#5865F2`,p:2,alignItems:`center`,justifyContent:`center`,children:J(P,{as:ca,color:`white`,fontSize:`20px`})}),J(P,{zIndex:1,as:Xr,color:e?`black`:`white`,fontSize:`15px`})]})},yd=({status:e,txReceipt:t,txError:n,onTryAgain:r,description:i,onClose:a})=>{let{t:o}=X(),{network:s}=$(),c=y(s.type).explorerUrl,l=G(()=>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:J(Jt,{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:J(P,{as:Dr,color:`red.500`,fontSize:`40px`,"data-testid":`error-icon-toast`}),title:o(`Transaction failed`),closeDisabled:!1,description:l};case`success`:return{icon:J(P,{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?Y(N,{justify:`space-between`,alignItems:`flex-start`,w:`full`,children:[J(B,{spacing:4,children:Y(N,{spacing:4,w:`full`,justifyContent:`flex-start`,alignItems:`flex-start`,children:[u.icon,Y(B,{w:`full`,align:`flex-start`,spacing:2,children:[Y(B,{spacing:1,w:`full`,children:[J(Et,{w:`full`,size:`xs`,children:u.title}),u.description&&J(z,{fontSize:`xs`,children:u.description})]}),(e===`error`||e===`ready`)&&J(M,{size:`xs`,onClick:r,children:e===`error`?Y(q,{children:[J(P,{mr:2,as:Zr}),o(`Try again`)]}):o(`Confirm`)}),t&&e!==`pending`&&Y(Nt,{fontSize:`xs`,isExternal:!0,href:`${c}/${t.meta.txID}`,children:[o(`View on explorer`),` `,J(P,{as:Pr})]})]})]})}),!u.closeDisabled&&J(Dt,{onClick:a,size:`sm`,borderRadius:`full`,"aria-label":`Close`,icon:J(P,{as:li,boxSize:4})})]}):null},bd=({isOpen:e,onClose:t,status:n,txReceipt:r,txError:i,onTryAgain:a,description:o})=>{let{darkMode:s}=$();return e?J(j,{position:`fixed`,bottom:`5`,left:`5`,zIndex:`11111`,bg:s?`#1f1f1e`:`white`,borderRadius:`md`,p:5,boxShadow:`lg`,maxW:`sm`,minW:`300px`,children:J(yd,{status:n,txReceipt:r,txError:i,onTryAgain:a,description:o,onClose:t})}):null},xd=({txId:e,title:t,description:n,onDone:r,showSocialButtons:i=!1})=>{let{t:a}=X(),{network:o}=$(),s=y(o.type).explorerUrl,c=`${s}/${e}`,l=V(`colors`,`vechain-kit-success`);return Y(q,{children:[Y(Z,{children:[J(R,{children:t}),J(I,{})]}),J(F,{children:Y(B,{align:`center`,p:6,spacing:3,children:[J(lr.div,{transition:{duration:4,ease:`easeInOut`,repeat:1/0},animate:{scale:[1,1.1,1]},children:J(P,{as:Or,fontSize:`100px`,color:l})}),n&&J(z,{fontSize:`sm`,textAlign:`center`,children:n}),i&&e&&Y(B,{mt:2,children:[J(z,{fontSize:`xs`,children:a(`Share on`)}),J(rd,{description:c})]})]})}),J(L,{justifyContent:`center`,children:Y(B,{width:`full`,spacing:4,children:[J(M,{onClick:r,variant:`vechainKitSecondary`,width:`full`,children:a(`Done`)}),e&&J(Nt,{href:`${s}/${e}`,isExternal:!0,opacity:.5,fontSize:`14px`,textDecoration:`underline`,children:Y(N,{spacing:1,alignItems:`center`,w:`full`,justifyContent:`center`,children:[J(z,{children:a(`View transaction on the explorer`)}),J(P,{size:16,as:Pr})]})})]})})]})},Sd=({setCurrentContent:e,handleClose:t,style:n})=>{let{t:r}=X(),{smartAccount:i,connectedWallet:a}=Q(),{data:o}=Np(i?.address??``,a?.address??``,3),{sendTransaction:s,isTransactionPending:c,isWaitingForWalletConfirmation:l,error:u,txReceipt:d}=Rp({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 Y(q,{children:[Y(Z,{children:[J(R,{children:r(`Account upgrade required`)}),J(I,{})]}),J(F,{children:Y(B,{spacing:10,align:`stretch`,justifyContent:`center`,children:[J(z,{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).`)}),Y(N,{align:`center`,justifyContent:`space-evenly`,rounded:`md`,children:[Y(j,{position:`relative`,display:`inline-block`,children:[J(gt,{size:`60px`,bg:`gray.200`,children:J(Ot,{src:i?.image,alt:r(`Profile Picture`),w:`100%`,h:`100%`,borderRadius:`full`,objectFit:`cover`})}),J(Et,{position:`absolute`,top:`-5`,right:`-5`,color:`#D23F63`,fontSize:`28px`,children:`v1`})]}),J(P,{as:hr,color:`#3DBA67`}),Y(j,{position:`relative`,display:`inline-block`,children:[J(gt,{size:`60px`,bg:`gray.200`,children:J(Ot,{src:i?.image,alt:r(`Profile Picture`),w:`100%`,h:`100%`,borderRadius:`full`,objectFit:`cover`})}),J(Et,{position:`absolute`,top:`-5`,right:`-5`,color:`#3DBA67`,fontSize:`28px`,children:`v3`})]})]}),Y(it,{status:`info`,borderRadius:`md`,children:[J(ot,{}),Y(j,{children:[J(st,{fontSize:`sm`,children:r(`Benefits of this upgrade:`)}),J(at,{fontSize:`xs`,children:Y(B,{align:`start`,spacing:0,mt:1,children:[Y(z,{fontSize:`xs`,lineHeight:`1.2`,children:[`• `,r(`Improved security features`)]}),Y(z,{fontSize:`xs`,children:[`• `,r(`Better transaction handling`)]}),Y(z,{fontSize:`xs`,children:[`•`,` `,r(`Enhanced compatibility with dApps`)]}),Y(z,{fontSize:`xs`,children:[`•`,` `,r(`Reduced gas costs for operations`)]})]})})]})]})]})}),J(L,{justifyContent:`center`,children:J(B,{spacing:3,w:`full`,children:J(Am,{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})})})]})},Cd=({isOpen:e,onClose:t,style:n})=>{let[r,i]=K(`upgrade-smart-account`);return W(()=>{e&&i(`upgrade-smart-account`)},[e]),J(zo,{isOpen:e,onClose:t,allowExternalFocus:!0,blockScrollOnMount:!0,size:n?.modalSize,children:(()=>{if(typeof r==`object`)switch(r.type){case`successful-operation`:return J(xd,{...r.props})}else if(r===`upgrade-smart-account`)return J(Sd,{setCurrentContent:i,handleClose:t,style:n})})()})},{definePartsStyle:wd,defineMultiStyleConfig:Td}=nn(Ea.keys),Ed=e=>({vechainKitBase:wd({dialog:{scrollbarWidth:`none`,overflow:`scroll`,overflowX:`hidden`,rounded:e.modal.rounded??e.borders.radius.modal,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:{...e.buttons.button.hoverBg?{bg:e.buttons.button.hoverBg}:{opacity:.8}},_active:{bg:e.buttons.button.bg,opacity:.8}},header:{w:`full`,color:e.colors.text.primary,fontSize:e.fonts.sizes.large,fontWeight:e.fonts.weights.bold,textAlign:`center`,paddingBottom:5,paddingTop:5}})}),Dd=e=>Td({variants:Ed(e),defaultProps:{variant:`vechainKitBase`}}),{definePartsStyle:Od,defineMultiStyleConfig:kd}=nn(Ta.keys),Ad=e=>({vechainKitBase:Od({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}`}}),vechainKitWalletCard:Od({container:{backgroundColor:e.colors.background.card,borderRadius:e.borders.radius.medium,width:`full`,cursor:`pointer`,position:`relative`}}),featureAnnouncement:Od({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:Od({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`}})}),jd=e=>kd({variants:Ad(e),defaultProps:{variant:`vechainKitBase`}}),Md=an({borderRadius:`12px`}),Nd=e=>({loginIn:an(()=>({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,rounded:e.buttons.loginButton.rounded??e.borders.radius.large,backdropFilter:e.buttons.loginButton.backdropFilter,_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:an(()=>({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:an(()=>({fontSize:e.fonts.sizes.medium,px:4,width:`full`,height:`60px`,rounded:e.buttons.primaryButton.rounded??e.borders.radius.large,bg:e.buttons.primaryButton.bg,color:e.buttons.primaryButton.color,border:e.buttons.primaryButton.border,backdropFilter:e.buttons.primaryButton.backdropFilter,_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:an(()=>({fontSize:e.fonts.sizes.medium,px:4,width:`full`,height:`60px`,rounded:e.buttons.button.rounded??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,backdropFilter:e.buttons.button.backdropFilter,_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:an(()=>({fontSize:e.fonts.sizes.medium,px:4,width:`full`,height:`60px`,rounded:e.buttons.tertiaryButton.rounded??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,backdropFilter:e.buttons.tertiaryButton.backdropFilter,_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:an(()=>({px:4,width:`full`,height:`60px`,rounded:e.buttons.button.rounded??e.borders.radius.large,bg:e.colors.error+`1f`,color:e.colors.error,border:e.buttons.button.border===`none`?`none`:e.buttons.button.border,backdropFilter:e.buttons.button.backdropFilter,_hover:{opacity:.8,_disabled:{opacity:.5,bg:e.colors.error+`1f`}},_disabled:{opacity:.5,cursor:`not-allowed`},transition:`all 0.2s`})),vechainKitHeaderIconButtons:an(()=>({bg:e.buttons.button.bg,color:e.buttons.button.color,border:e.buttons.button.border===`none`?`none`:e.buttons.button.border,backdropFilter:e.buttons.button.backdropFilter,_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`,rounded:`full`,mt:`8px`})),actionButton:an(()=>({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:an(()=>({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:an(()=>({color:e.colors.text.primary,_hover:{color:e.colors.text.secondary,textDecoration:`underline`},_active:{color:e.colors.text.primary},transition:`all 0.2s`}))}),Pd=e=>on({baseStyle:Md,variants:Nd(e)}),Fd=e=>on({baseStyle:Md,variants:Nd(e)}),Id=e=>on({baseStyle:Md,variants:Nd(e),defaultProps:{variant:`vechainKitHeaderIconButtons`}}),{definePartsStyle:Ld,defineMultiStyleConfig:Rd}=nn(Da.keys),zd=e=>({vechainKitBase:Ld({popper:{zIndex:1e3},content:{borderRadius:e.borders.radius.xl,border:e.colors.border.modal,backgroundColor:e.colors.background.modal,backdropFilter:e.effects.backdropFilter.modal,boxShadow:`0px 4px 16px rgba(0, 0, 0, 0.12)`,minWidth:`380px`},body:{padding:`16px`}})}),Bd=e=>Rd({variants:zd(e),defaultProps:{variant:`vechainKitBase`}}),Vd=(e,t)=>({useSystemColorMode:!1,disableTransitionOnChange:!1,components:{Modal:Dd(t),Card:jd(t),Button:Pd(t),IconButton:Fd(t),CloseButton:Id(t),Popover:Bd(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,"vechain-kit-button-primary-bg":t.buttons.primaryButton.bg,"vechain-kit-button-primary-color":t.buttons.primaryButton.color},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:cn.fonts,fontSizes:{...cn.fontSizes,sm:t.fonts.sizes.small,md:t.fonts.sizes.medium,lg:t.fonts.sizes.large},fontWeights:{...cn.fontWeights,normal:t.fonts.weights.normal,medium:t.fonts.weights.medium,bold:t.fonts.weights.bold},colors:cn.colors,space:cn.space}),Hd=(e,t)=>{let n=sn(Vd(e,vo(_o(e),yo(t,e))));return n.styles.global=()=>({}),n.__cssVars&&(n.__cssVars.global=()=>({})),n},{ToastContainer:Ud}=rn(),Wd=()=>wa({key:`vechain-kit`,prepend:!0}),Gd=({bodyFont:e,headingFont:t})=>J(xa,{styles:Sa`
|
|
127
|
+
}`,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`))),ds.parse(o.data)},ps=(e,t)=>[`VECHAIN_KIT`,`VET_DOMAINS`,e,t],ms=(e,t)=>{let{network:n}=$();return or({queryKey:ps(e,t),queryFn:()=>fs(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})},hs=(e,t)=>[`VECHAIN_KIT`,`VET_DOMAINS`,`AVATAR`,e,t],gs=e=>{let{network:t}=$();return or({queryKey:hs(e??``,t.type),queryFn:async()=>e?fi(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})},_s=new bn([`function resolver(bytes32 node) returns (address resolverAddress)`,`function text(bytes32 node, string key) view returns (string)`]),vs=async(e,t,n)=>{if(!n)return{};let r=Sn(n);try{let n=new URL(`accounts/*`,e),[{data:i,reverted:a}]=await(await fetch(n,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({clauses:[{to:y(t).vetDomainsContractAddress,data:_s.encodeFunctionData(`resolver`,[r])}]})})).json();if(a)return{};let{resolverAddress:o}=_s.decodeFunctionResult(`resolver`,i);return(await(await fetch(n,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({clauses:s.map(e=>({to:o,data:_s.encodeFunctionData(`text`,[r,e])}))})})).json()).reduce((e,{data:t,reverted:n},r)=>{if(!n&&t&&t!==`0x`)try{let n=_s.decodeFunctionResult(`text`,t)[0];n&&(e[s[r]]=n)}catch(e){console.error(`Failed to decode text record for ${s[r]}:`,e)}return e},{})}catch(e){throw console.error(`Error fetching text records:`,e),e}},ys=(e,t)=>[`VECHAIN_KIT_TEXT_RECORDS`,e,t],bs=e=>{let{network:t}=$(),n=t.nodeUrl??y(t.type).nodeUrl;return or({queryKey:ys(e,t.type),queryFn:()=>vs(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})},xs=new bn([`function resolver(bytes32 node) returns (address resolverAddress)`,`function setText(bytes32 node, string key, string value) external`]),Ss=(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=Sn(r);n.push({to:e,data:xs.encodeFunctionData(`setText`,[t,i,a]),value:`0`,comment:`Update ${i} record`})}return n},Cs=({onSuccess:e,onError:t,signerAccountAddress:n,resolverAddress:r}={})=>{let i=U(e=>{if(!r)throw Error(`Resolver address is required`);return Ss(r,e)},[r]),a=Xc({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))}},ws=e=>[`VECHAIN_KIT`,`RESOLVER_ADDRESS`,e],Ts=e=>{let{network:t}=$();return Xf({address:y(t.type).vetDomainsContractAddress,abi:Ei.abi,method:`resolver`,args:[e?zi(e):`0x`],queryOptions:{select:e=>e[0],enabled:!!e}})},Es={Mugshot:new URL(`mugshot.png`,Xe).toString(),Greencart:new URL(`greencart.png`,Xe).toString(),Cleanify:new URL(`cleanify.png`,Xe).toString(),EVearn:new URL(`evearn.png`,Xe).toString()},Ds=()=>{let e=x(`vechain_kit_cross_app_connection`);if(!e)return null;try{let t=JSON.parse(e)?.ecosystemApp?.name;return t?Es[t]??null:null}catch{return null}},Os=e=>[`VECHAIN_KIT`,`VET_DOMAINS`,`AVATAR_OF_ADDRESS`,e],ks=e=>{let{network:t}=$();return or({queryKey:Os(e),queryFn:async()=>{if(!e||!t.nodeUrl)return Ds()??l(e??``);if(t.type!==`main`&&t.type!==`test`)return Ds()??l(e);let n=await di(e,{networkUrl:t.nodeUrl});return n&&await fi(n,{networkUrl:t.nodeUrl})||(Ds()??l(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})},As=new bn([`function resolver(bytes32 node) returns (address resolverAddress)`,`function text(bytes32 node, string key) returns (string avatar)`]),js=new bn([`function tokenURI(uint256 tokenId) view returns (string)`,`function uri(uint256 id) view returns (string)`]),Ms=async(e,t,n)=>{if(!n)throw Error(`Name is required`);let r=Sn(n);try{let n=new URL(`accounts/*`,t),[{data:i,reverted:a}]=await(await fetch(n,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({clauses:[{to:y(e).vetDomainsContractAddress,data:As.encodeFunctionData(`resolver`,[r])}]})})).json();if(a)return null;let{resolverAddress:o}=As.decodeFunctionResult(`resolver`,i),[{data:s,reverted:c}]=await(await fetch(n,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({clauses:[{to:o,data:As.encodeFunctionData(`text`,[r,`avatar`])}]})})).json();if(c||s===`0x`)return null;try{let{avatar:n}=As.decodeFunctionResult(`text`,s),r=n===``?null:n;return r?Ps(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}},Ns=(e,t)=>[`VECHAIN_KIT`,`VET_DOMAINS`,`AVATAR`,`LEGACY`,e,t];async function Ps(e,t,n){try{if(e.startsWith(`http`)||e.startsWith(`ipfs://`)||e.startsWith(`ar://`))return C(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:js.encodeFunctionData(s?`uri`:`tokenURI`,[BigInt(o||0)])}],l=new URL(`accounts/*`,n),[{data:u,reverted:d}]=await fetch(l,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({clauses:c})}).then(e=>e.json());if(d)return console.error(`Failed to fetch tokenURI`),null;let f=``;try{f=js.decodeFunctionResult(s?`uri`:`tokenURI`,u)[0]}catch(e){console.error(`Failed to decode avatar data:`,e),f=Tn(u)}f=C(f,t)||f,s&&(f=f.replace(`{id}`,En(wn(BigInt(o||0)),32).slice(2)));let p=await fetch(f);if(!p.ok)return console.error(`Failed to fetch metadata`),null;let m=await p.json(),h=m.image||m.image_url||m.image_data;return h?C(h,t)||h:(console.error(`No image URL in metadata`),null)}return null}catch(e){return console.error(`Error parsing avatar record:`,e),null}}const Fs=e=>{let{network:t}=$(),n=t.nodeUrl??y(t.type).nodeUrl;return or({queryKey:Ns(e??``,t.type),queryFn:async()=>e?Ms(t.type,n,e):null,enabled:!!e&&!!n&&!!t.type})},Is=Di.createInterface(),Ls=(e,t)=>{let n=[];return n.push({to:y(t.type).vetDomainsReverseRegistrarAddress,value:`0x0`,data:Is.encodeFunctionData(`setName`,[``]),comment:`Unsetting your current VeChain nickname of the account ${d(e?.address??``,4,4)}`,abi:Is.getFunction(`setName`)}),n},Rs=({onSuccess:e,onError:t})=>{let n=sr(),{account:r}=Q(),{network:i}=$(),a=U(()=>Ls(r,i),[r,i]),o=U(async()=>{await Zo(n,r?.address??``,``,``,``,i.type),e?.()},[e,n,r,i.type]),s=Xc({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())}},zs=e=>{let{network:t,allowCommunityTokens:n}=$(),r=y(t.type),{data:i,isLoading:a}=op(e),{data:o,isLoading:s}=sc(e),{data:c,isLoading:l}=pc(e),{data:u,isLoading:d}=dc(r.veDelegateTokenContractAddress,e),{data:f,isLoading:p}=dc(r.sassContractAddress,e,{enabled:n}),m=lc(e),h=m.map(e=>e.data).filter(Boolean),g=m.some(e=>e.isLoading);return{balances:G(()=>{if(!e)return[];let t={vet:`0x`,vtho:r.vthoContractAddress,b3tr:r.b3trContractAddress,vot3:r.vot3ContractAddress,veDelegate:r.veDelegate},a=[{address:t.vet,symbol:`VET`,balance:i?.balance||`0`},{address:t.vtho,symbol:`VTHO`,balance:i?.energy||`0`},{address:t.b3tr,symbol:`B3TR`,balance:o?.scaled??`0`},{address:t.vot3,symbol:`VOT3`,balance:c?.scaled??`0`},{address:t.veDelegate,symbol:`veDelegate`,balance:u?.scaled??`0`}],s=h.map(e=>({address:e?.address||``,symbol:e?.symbol||``,balance:e?.scaled||`0`})),l=n?[{address:r.sassContractAddress,symbol:`SASS`,balance:f?.scaled??`0`}]:[];return[...a,...s,...l]},[e,i,o,c,u,h,n,f,r.sassContractAddress,t.type]),isLoading:a||s||l||d||n&&p||g}},Bs={B3TR:`0x623374722d757364000000000000000000000000000000000000000000000000`,VET:`0x7665742d75736400000000000000000000000000000000000000000000000000`,VTHO:`0x7674686f2d757364000000000000000000000000000000000000000000000000`,GBP:`0x6762702d75736400000000000000000000000000000000000000000000000000`,EUR:`0x657572742d757364000000000000000000000000000000000000000000000000`},Vs=async(e,t,n)=>{let r=await e.contracts.load(y(n).oracleContractAddress,Si.abi).read.getLatestValue(Bs[t]);if(!r)throw Error(`Failed to get price of ${t}`);return new yn(r[0].toString()).div(0xe8d4a51000).toNumber()},Hs=e=>[`VECHAIN_KIT_PRICE`,e],Us=e=>{let t=Qn(),{network:n}=$();return or({queryKey:Hs(e),queryFn:async()=>Vs(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})},Ws=()=>{let{network:e}=$(),t=y(e.type),{data:n,isLoading:r}=Us(`VET`),{data:i,isLoading:a}=Us(`VTHO`),{data:o,isLoading:s}=Us(`B3TR`),{data:c,isLoading:l}=Us(`EUR`),{data:u,isLoading:d}=Us(`GBP`);return{prices:G(()=>{let e={vet:`0x`,vtho:t.vthoContractAddress,b3tr:t.b3trContractAddress,vot3:t.vot3ContractAddress,veDelegate:t.veDelegate,SASS:t.sassContractAddress};return{[e.vet]:n||0,[e.vtho]:i||0,[e.b3tr]:o||0,[e.vot3]:o||0,[e.veDelegate]:o||0,[e.SASS]:0}},[n,i,o,t.vthoContractAddress,t.b3trContractAddress,t.vot3ContractAddress,t.veDelegate,t.sassContractAddress]),exchangeRates:G(()=>({eurUsdPrice:c||1,gbpUsdPrice:u||1}),[c,u]),isLoading:r||a||s||l||d}},Gs=(e,t,n)=>{switch(t){case`eur`:return e/n.eurUsdPrice;case`gbp`:return e/n.gbpUsdPrice;default:return e}},Ks=(e,t=`en`,n)=>{let r={style:`currency`,minimumFractionDigits:2,maximumFractionDigits:2,currency:n?.currency??`usd`,...n};return new Intl.NumberFormat(eo[t],r).format(e)},qs=(e,t)=>Ks(e,no.resolvedLanguage,{notation:`compact`,compactDisplay:`short`,currency:t?.currency??`usd`,...t}),Js=[`usd`,`eur`,`gbp`],Ys=()=>{let{currentCurrency:e,setCurrency:t}=$();return W(()=>{de(`vechain_kit_currency`,e)},[e]),{currentCurrency:e,allCurrencies:Js,changeCurrency:e=>{if(!Js.includes(e)){console.error(`Invalid currency: ${e}`);return}t(e)}}},Xs=({address:e=``})=>{let{balances:t,isLoading:n}=zs(e),{prices:r,exchangeRates:i,isLoading:a}=Ws(),{currentCurrency:o}=Ys(),s=G(()=>t.map(e=>{let t=r[e.address]||0,n=Number(e.balance)*t,a=Gs(n,o,i);return{...e,priceUsd:t,valueUsd:n,valueInCurrency:a}}),[t,r,o,i]),c=G(()=>[...s].sort((e,t)=>t.valueInCurrency-e.valueInCurrency),[s]);return{tokens:s,sortedTokens:c,tokensWithBalance:G(()=>c.filter(e=>Number(e.balance)>0),[c]),isLoading:n||a}},Zs=({address:e=``})=>{let{tokensWithBalance:t,isLoading:n}=Xs({address:e}),{currentCurrency:r}=Ys(),i=G(()=>t.reduce((e,t)=>e+t.valueInCurrency,0),[t]);return{totalBalanceInCurrency:i,totalBalanceUsd:G(()=>t.reduce((e,t)=>e+t.valueUsd,0),[t]),formattedBalance:G(()=>qs(i,{currency:r}),[i,r]),isLoading:n,hasAnyBalance:t.length>0}},Qs=ji.abi,$s=`currentRoundId`,ec=e=>qf({abi:Qs,address:e,method:$s}),tc=()=>{let{network:e}=$(),t=y(e.type).xAllocationVotingContractAddress;return Xf({abi:Qs,address:t,method:$s,args:[],queryOptions:{select:e=>e[0].toString()}})},nc=async(e,t)=>_i(e,{networkUrl:t}),rc=e=>[`VECHAIN_KIT_CUSTOM_TOKEN_INFO`,e],ic=e=>{let{network:t}=$();return or({queryKey:rc(e),queryFn:async()=>{if(!e)throw Error(`Token address is required`);if(!t.nodeUrl)throw Error(`Network node URL is required`);return nc(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})},ac=()=>{let[e,t]=dm(um.CUSTOM_TOKENS,[]),{network:n}=$(),r=async r=>{if(!a(r)&&!o(r)){if(!n.nodeUrl)throw Error(`Network node URL is required`);let i={...await nc(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)),o=e=>{let t={vet:`0x`,vtho:y(n.type).vthoContractAddress,b3tr:y(n.type).b3trContractAddress,vot3:y(n.type).vot3ContractAddress,veDelegate:y(n.type).veDelegate};return Object.values(t).includes(e)};return{customTokens:e,addToken:r,removeToken:i,isTokenIncluded:a,isDefaultToken:o}},oc=e=>[`VEBETTERDAO_BALANCE`,e,`B3TR`],sc=e=>{let{network:t}=$();return or({queryKey:oc(e),queryFn:async()=>{if(!e)throw Error(`Address is required`);let n=await pi(e,{networkUrl:t.nodeUrl});if(!n)throw Error(`Failed to get b3tr balance`);let r=n[0];return i(r)},enabled:!!e&&!!t.type})},cc=(e,t)=>[`VECHAIN_KIT_BALANCE`,t,`CUSTOM_TOKEN`,e],lc=e=>{let{network:t}=$(),{customTokens:n}=ac();return ar({queries:n.map(n=>({queryKey:cc(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 hi(n.address,e,{networkUrl:t.nodeUrl});if(!r)throw Error(`Failed to get token balance`);let a=i(r[0]);return{...n,...a}}}))})},uc=(e,t)=>[`VECHAIN_KIT`,`BALANCE`,`ERC20`,e,t],dc=(e,t,n)=>{let{network:r}=$(),a=!!t&&!!r.type;return or({queryKey:uc(e,t),queryFn:async()=>{if(!t)throw Error(`Address is required`);let n=await hi(e,t,{networkUrl:r.nodeUrl});if(!n)throw Error(`Failed to get vot3 balance`);let a=n[0];return i(a)},enabled:a&&(n?.enabled??!0)})},fc=e=>[`VEBETTERDAO_BALANCE`,e,`VOT3`],pc=e=>{let{network:t}=$();return or({queryKey:fc(e),queryFn:async()=>{if(!e)throw Error(`Address is required`);let n=await vi(e,{networkUrl:t.nodeUrl});if(!n)throw Error(`Failed to get vot3 balance`);let r=n[0];return i(r)},enabled:!!e&&!!t.type})},mc=(e,t)=>[`VECHAIN_KIT`,`IS_PERSON`,e,t],hc=e=>{let{network:t}=$();return or({queryKey:mc(e??``,t.type),queryFn:async()=>{if(!e)throw Error(`User address is required`);return gi(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})},gc=ji.abi,_c=`getAppsOfRound`,vc=(e,t)=>Yf({abi:gc,address:y(t).xAllocationVotingContractAddress,method:_c,args:[BigInt(e??0)]}),yc=e=>{let{network:t}=$(),n=y(t.type).xAllocationVotingContractAddress;return Xf({abi:gc,address:n,method:_c,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()}))}})},bc=Ai.abi,xc=e=>[`VECHAIN_KIT`,`XApps`,`Shares`,e],Sc=(e,t)=>{let n=Qn(),{network:r}=$(),i=y(r.type).xAllocationPoolContractAddress;return or({queryKey:xc(t),queryFn:async()=>(await ne({thor:n,calls:e.map(e=>({abi:bc,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})},Cc=e=>{let{data:t}=yc(e),n=Sc(t?.map(e=>e.id)??[],e);return{data:G(()=>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}},wc=({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 ea&&i&&!g(i)?Error(t):i&&g(i)?Error(n):e instanceof Error?e:Error(r)},Tc=Pi({id:`1176455790972829965191905223412607679856028701100105089447013101863`,name:`Vechain`,nativeCurrency:{name:`VeChain`,symbol:`VET`,decimals:18},rpcUrls:{default:{http:[he]}},blockExplorers:{default:{name:`Vechain Explorer`,url:Oe},vechainStats:{name:`Vechain Stats`,url:Le}}}),Ec=()=>$i({id:_,name:`VeChain`,iconUrl:`https://imagedelivery.net/oHBRUd2clqykxgDWmeAyLg/661dd77c-2f9d-40e7-baa1-f4e24fd7bf00/icon`,smartWalletMode:!1}),Dc=({privyEcosystemAppIDS:e,children:t})=>J(Gi,{config:vn(Ki({chains:[Tc],ssr:!0,connectors:[Ec(),...e.map(e=>$i({id:e,name:``,iconUrl:``}))],transports:{[Tc.id]:qi()},multiInjectedProviderDiscovery:!1})).current,children:t}),Oc=()=>{let{connectAsync:e,connectors:t}=Yi(),{signTypedDataAsync:n}=Qi(),{signMessageAsync:r}=Zi(),{disconnectAsync:i}=Xi(),{isConnected:a}=Ji(),[o,s]=K(!1),[c,l]=K(null),u=U(async()=>{try{a&&(await i(),A()&&window.dispatchEvent(new Event(`wallet_disconnected`)))}catch(e){throw console.error(`Error during logout:`,e),e}},[i,a]);return{login:U(async n=>{try{s(!0),l(null);let r=t.find(e=>e.id===(n||_));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:U(async e=>{try{return await r({message:e})}catch(e){throw wc({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:U(async e=>{try{return await n(e)}catch(e){throw wc({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}},kc=(e,t)=>{let{data:n,isLoading:r}=Ko(e??``),{data:i,isLoading:a}=ks(e??``),{data:o,isLoading:s}=bs(n?.domain??``),c=o?.header?C(o.header,t):null;return{domain:n?.domain,image:i,records:{...o,header:c},isLoading:r||a||s}},Ac=()=>{let{network:e}=$(),t=U(e=>({wallets:`vechain_kit_wallets_${e}`,activeWallet:`vechain_kit_active_wallet_${e}`}),[]),n=U(()=>{if(!A())return[];let n=x(t(e.type).wallets);return n?JSON.parse(n):[]},[e.type,t]),r=U(()=>A()?x(t(e.type).activeWallet):null,[e.type,t]),i=U(r=>{if(!A())return;let i=t(e.type),a=n(),o=a.findIndex(e=>e.address.toLowerCase()===r.toLowerCase()),s={address:r,connectedAt:o>=0?a[o].connectedAt:Date.now(),isActive:!1};o>=0?a[o]=s:a.push(s),de(i.wallets,JSON.stringify(a))},[e.type,t,n]),a=U(r=>{if(!A())return;let i=t(e.type),a=n().map(e=>({...e,isActive:e.address.toLowerCase()===r.toLowerCase()}));de(i.wallets,JSON.stringify(a)),de(i.activeWallet,r)},[e.type,t,n]);return{getStoredWallets:n,getActiveWallet:r,saveWallet:i,setActiveWallet:a,removeWallet:U(i=>{if(!A())return;let a=t(e.type),o=n().filter(e=>e.address.toLowerCase()!==i.toLowerCase());de(a.wallets,JSON.stringify(o));let s=r();s&&s.toLowerCase()===i.toLowerCase()&&w(a.activeWallet),A()&&window.dispatchEvent(new CustomEvent(`wallet_removed`,{detail:{address:i}}))},[e.type,t,n,r]),initializeCurrentWallet:U(e=>{A()&&n().length===0&&(i(e),a(e))},[n,i,a])}},Q=()=>{let{address:e,isConnected:t,isConnecting:n,isReconnecting:r}=Ji(),{logout:i}=Oc(),{loading:a}=Hn({}),{feeDelegation:o,network:s,privy:c}=$(),{user:l,authenticated:u,logout:d,ready:f}=Kn(),{data:p}=Wp(),{account:m,disconnect:h}=$n(),{getConnectionCache:g,clearConnectionCache:v}=Bf(),y=g(),{initializeCurrentWallet:b,getActiveWallet:x,saveWallet:S,getStoredWallets:C}=Ac(),w=tp(),T=G(()=>A()?!!window.vechain?.isInAppBrowser:!1,[]),E=!!m,D=u&&!!l,k=D||t,ee=D&&c?.appId===_||t&&y?.ecosystemApp?.appId===_,te=n||r||a||!f,[ne,re]=K(!1),ie=t?{type:`privy-cross-app`,displayName:`Ecosystem`}:E?{type:`wallet`,displayName:`Wallet`}:{type:`privy`,displayName:`Social Login`};W(()=>{let e=E||D||t;ne!==e&&(re(e),e||(v(),A()&&window.dispatchEvent(new Event(`wallet_disconnected`))))},[E,D,t,v,ne]);let ae=l?.linkedAccounts?.find(e=>e.type===`wallet`&&e.connectorType===`embedded`)?.address,oe=E?m:t?e:ae,[se,ce]=K(()=>E&&!T?x():null);W(()=>{ce(E&&!T?x():null)},[E,T,x]);let[le,ue]=K(!1);W(()=>{if(!A()||!E||T)return;let e=e=>{ue(!0),ce(e.detail.address),setTimeout(()=>{ue(!1)},1e3)};return window.addEventListener(`wallet_switched`,e),()=>{window.removeEventListener(`wallet_switched`,e)}},[E,T]);let de=C().some(e=>e.address.toLowerCase()===oe?.toLowerCase()),fe=E&&!T?x():null,pe=le&&fe||fe&&de?fe:oe,{data:me}=Ap(pe??``),he=E?pe:me?.address,ge=kc(he??``,s.type),_e=kc(pe??``,s.type),ve=kc(me?.address??``,s.type),{setActiveWallet:ye}=Ac(),be=vn(new Set);W(()=>{if(!A()||!E||T)return;let e=e=>{be.current.add(e.detail.address.toLowerCase()),setTimeout(()=>{be.current.delete(e.detail.address.toLowerCase())},5e3)};return window.addEventListener(`wallet_removed`,e),()=>{window.removeEventListener(`wallet_removed`,e)}},[E,T]),W(()=>{if(E&&!T&&oe&&ge&&!ge.isLoading){if(be.current.has(oe.toLowerCase()))return;let e=!C().some(e=>e.address.toLowerCase()===oe.toLowerCase());b(oe),S(oe);let t=!se,n=se&&se.toLowerCase()===oe.toLowerCase();(e||t||n)&&!le&&ye(oe)}},[E,T,oe,ge?.domain,ge?.image,ge?.isLoading,b,S,ye,se,C]),W(()=>{E&&!T&&se&&se.toLowerCase()===pe?.toLowerCase()&&S(se)},[E,T,se,pe,S]);let xe=he?{address:he,domain:ge.domain,image:ge.image,isLoadingMetadata:ge.isLoading,metadata:ge.records}:null,Se=oe?{address:oe,domain:_e.domain,image:_e.image,isLoadingMetadata:_e.isLoading,metadata:_e.records}:null,{data:Ce}=vp(me?.address??``,Se?.address??``),we=!!me?.address&&!!xe?.address&&O(me?.address,xe?.address),Te=U(async()=>{try{re(!1),E?h():D?await d():t&&await i(),v(),A()&&window.dispatchEvent(new Event(`wallet_disconnected`))}catch(e){console.error(`Error during disconnect:`,e)}},[E,h,D,d,t,i,v]);return{account:xe,smartAccount:{address:me?.address??``,domain:ve.domain,image:ve.image,isDeployed:me?.isDeployed??!1,isActive:we,version:Ce?.version??null,isLoadingMetadata:ve.isLoading,metadata:ve.records},connectedWallet:Se,privyUser:l,connection:{isLoading:te,isConnected:ne,isConnectedWithSocialLogin:D,isConnectedWithDappKit:E,isConnectedWithCrossApp:t,isConnectedWithPrivy:k,isConnectedWithVeChain:ee,source:ie,isInAppBrowser:T,nodeUrl:w,delegatorUrl:o?.delegatorUrl,chainId:p,network:s.type},disconnect:Te}},jc=()=>{let e=sr(),{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`]})])}}},Mc=()=>{let{switchWallet:e}=$n(),{connection:t}=Q(),[n,r]=K(!1),{getStoredWallets:i,setActiveWallet:a,removeWallet:o}=Ac(),s=t.isInAppBrowser;return{switchWallet:U(async()=>{if(s){if(!e)return;r(!0);try{await e()}catch{}finally{r(!1)}}else return Promise.resolve()},[e,s]),isSwitching:n,getStoredWallets:i,setActiveWallet:U(e=>{a(e),A()&&window.dispatchEvent(new CustomEvent(`wallet_switched`,{detail:{address:e}}))},[a]),removeWallet:o,isInAppBrowser:s}},Nc=async(e,t)=>{let n=C(e,t)||``,r=await fetch(n,{signal:AbortSignal.timeout(2e4)});if(!r.ok)throw Error(`HTTP error! status: ${r.status}`);return await r.json()},Pc=ki.abi,Fc=e=>{let t=Qn(),{network:n}=$();return or({queryKey:[`xAppMetaData`,e],queryFn:async()=>{let r=y(n.type).x2EarnAppsContractAddress,i=t.contracts.load(r,Pc),a=(await i.read.app(e))[0][3]?.toString()||``,[o]=await i.read.baseURI();return await Nc(`${o}${a}`,n.type)},enabled:!!e})},Ic=async(e,t,n=!1)=>{if(!t)throw Error(`No URI provided`);let r=C(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},Lc=(e,t)=>[`VECHAIN_KIT`,`IPFS_METADATA`,e,t],Rc=(e,t=!1)=>{let{network:n}=$();return or({queryKey:Lc(n.type,e),queryFn:()=>Ic(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})},zc=1024*1024*10,Bc=async(e,t)=>{if(!t)throw Error(`IPFS URI is required`);let n=await fetch(C(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>zc)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:m(r.type)})},n.onerror=()=>{t(Error(`Error occurred while reading blob.`))}})},Vc=(e,t)=>[`VECHAIN_KIT`,`IPFS_IMAGE`,e,t],Hc=e=>{let{network:t}=$();return or({queryKey:Vc(t.type,e),queryFn:()=>Bc(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})},Uc=e=>{let{network:t}=$();return ar({queries:e.map(e=>({queryKey:Vc(t.type,e),queryFn:()=>Bc(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}))})},Wc=(e,t=!1)=>{let{network:n}=$();return ar({queries:e.map(e=>({queryKey:Lc(n.type,e),queryFn:async()=>Ic(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}))})},Gc={maxSizeMB:.4,maxWidthOrHeight:1920,useWebWorker:!0},Kc=async e=>{let t=[];try{for(let n of e){let e=await ta(n.file,Gc);t.push(e)}return t}catch(e){throw console.error(`compress error`,e),e}},qc=({compressImages:e,defaultImages:t})=>{let[n,r]=K(t??[]);W(()=>{t&&r(t)},[t]);let[i,a]=K([]),o=U(e=>r(t=>t.filter((t,n)=>n!==e)),[]);return{uploadedImages:n,setUploadedImages:r,onUpload:U(async(t,n=!0)=>{a([]);let i=[];for(let n of t){let t=n;e&&(t=await ta(n,Gc));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}},Jc=({compressImage:e,defaultImage:t})=>{let[n,r]=K(t);W(()=>{t&&r(t)},[t]);let i=U(()=>r(void 0),[]);return{uploadedImage:n,setUploadedImage:r,onUpload:U(async t=>{let n=t;e&&(n=await ta(n,Gc));let i={file:n,image:URL.createObjectURL(n)};return r(i),i},[e]),onRemove:i}},Yc=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)},Xc=({signerAccountAddress:e,clauses:t,onTxConfirmed:n,onTxFailedOrCancelled:r,suggestedMaxGas:i,privyUIOptions:a,gasPadding:o,delegationUrl:s})=>{let c=Qn(),{signer:l,requestTransaction:u}=er(),{connection:d}=Q(),{feeDelegation:f}=$(),p=tp(),m=Qm(),h=U(async(t,n,r)=>{let a=typeof t==`function`?await t():t??[];if(d.isConnectedWithPrivy)return await m.sendTransaction({txClauses:a,...r,delegationUrl:n});if(!e)throw Error(`signerAccountAddress is required`);let s=0;try{s=await Yc(c,[...a],e,{revision:Mn.NEXT,...o?{gasPadding:o}:{}})}catch(e){console.error(`Gas estimation failed`,e)}return(await u(a,{signer:d.isConnectedWithDappKit&&!d.isInAppBrowser&&e?e:l.address,gas:i??s,...f?.delegateAllTransactions||n?{delegator:{url:n??f?.delegatorUrl??``,signer:e}}:{}})).txid},[e,i,p,m,a,f,c,l,o,s,u,d.isConnectedWithDappKit,d.isInAppBrowser]),[g,_]=K(null),[v,y]=K(!1),[b,x]=K(null),S=U(async(e,n)=>{if(!e&&!t)throw Error(`clauses are required`);try{_(null),y(!0),x(null),O(void 0),_(await h(e??[],n,{...a}))}catch(e){x(e&&typeof e==`object`&&`message`in e?e.message:String(e)),r?.(e instanceof Error?e:Error(String(e)))}finally{y(!1)}},[h,t,a,s]),{data:C,isLoading:w,error:T}=nm(g??``),E=U(async e=>{if(!(!e.reverted||!e.meta.txID))return await c.transactions.getRevertReason(e.meta.txID)},[c]),[D,O]=K(),k=G(()=>{if(v)return`pending`;if(b)return`error`;if(g){if(w)return`waitingConfirmation`;if(T)return`error`;if(C)return C.reverted?`error`:`success`}return`ready`},[w,b,v,g,C,T]);W(()=>{if(k===`success`||k===`error`){if(b&&!D){O({type:`UserRejectedError`,reason:b});return}if(C?.reverted&&!D?.type){(async()=>{let e=await E(C);O({type:`RevertReasonError`,reason:e?`Transaction reverted with: `+e:`Transaction reverted`})})();return}C&&!C.reverted&&n?.()}},[k,C,n,E,b]);let A=U(()=>{_(null),y(!1),x(null),O(void 0)},[]);return{sendTransaction:S,isTransactionPending:G(()=>v||w||k===`pending`||k===`waitingConfirmation`,[v,w,k]),isWaitingForWalletConfirmation:G(()=>k===`pending`,[v,k]),txReceipt:C??null,status:k,resetStatus:A,error:D}},Zc=(e,t)=>{let{account:n}=Q(),{t:r}=X(),{sendTransaction:i,isTransactionPending:a,isWaitingForWalletConfirmation:o,txReceipt:s,status:c,resetStatus:l,error:u}=Xc({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:U(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}},Qc=e=>e===`0x`||e===Ui,$c=(e,t,n,r)=>{let i={},a=r.toLowerCase();for(let t of e)try{let e=Ni({abi:An,eventName:`Transfer`,topics:t.topics,data:t.data}),n=e.args.from.toLowerCase(),r=e.args.to.toLowerCase(),o=e.args.value,s=typeof o==`bigint`?o:BigInt(o);if(n!==a&&r!==a)continue;let c=t.address.toLowerCase(),l=i[c]??{inflow:0n,outflow:0n};n===a&&(l.outflow+=s),r===a&&(l.inflow+=s),i[c]=l}catch{continue}if(n!==void 0){let e=BigInt(n);if(e>0n){let t=i[Ui]??{inflow:0n,outflow:0n};t.outflow+=e,i[Ui]=t}}for(let e of t){if(e.recipient.toLowerCase()!==a)continue;let t=BigInt(e.amount);if(t<=0n)continue;let n=i[Ui]??{inflow:0n,outflow:0n};n.inflow+=t,i[Ui]=n}return i},el=async(e,t,n,r)=>{try{if(n.length===0)return{gasCostVTHO:0,success:!1,error:`No clauses found for simulation`};let i=await r.transactions.simulateTransaction(n,{caller:e.userAddress}),a=!1,o,s=2e5,c={};for(let t=0;t<i.length;t++){let r=i[t];r.reverted&&(a=!0,o=r.vmError||`Transaction reverted`),s+=r.gasUsed;let l=n[t],u=$c(r.events,r.transfers,l?.value,e.userAddress);for(let[e,t]of Object.entries(u)){let n=c[e]??{inflow:0n,outflow:0n};c[e]={inflow:n.inflow+t.inflow,outflow:n.outflow+t.outflow}}}if(a)return{gasCostVTHO:0,success:!1,error:o||`Transaction reverted`};let l=s/1e5,u=Qc(e.fromTokenAddress),d=Qc(e.toTokenAddress),f=BigInt(e.amountIn);if(u){let e=c[Ui]??{inflow:0n,outflow:0n};if(e.outflow>f)return{gasCostVTHO:l,success:!1,error:`VET outflow mismatch: expected ${f.toString()}, got ${e.outflow.toString()}`};for(let[e,t]of Object.entries(c))if(e!==Ui&&t.outflow>0n)return{gasCostVTHO:l,success:!1,error:`Unexpected token outflow: token ${e} has outflow ${t.outflow.toString()}, expected 0`}}else{let t=e.fromTokenAddress.toLowerCase(),n=c[t]??{inflow:0n,outflow:0n};if(n.outflow>f)return{gasCostVTHO:l,success:!1,error:`Token outflow mismatch: expected ${f.toString()}, got ${n.outflow.toString()}`};for(let[e,n]of Object.entries(c))if(e!==t&&n.outflow>0n)return{gasCostVTHO:l,success:!1,error:`Unexpected token outflow: ${e===Ui?`VET`:e} has outflow ${n.outflow.toString()}, expected 0`}}if(t.minimumOutputAmount&&t.minimumOutputAmount>0n)if(d){let e=c[Ui]??{inflow:0n,outflow:0n};if(e.inflow<t.minimumOutputAmount)return{gasCostVTHO:l,success:!1,error:`VET inflow mismatch: expected ${t.minimumOutputAmount.toString()}, got ${e.inflow.toString()}`}}else{let n=c[e.toTokenAddress.toLowerCase()]??{inflow:0n,outflow:0n};if(n.inflow<t.minimumOutputAmount)return{gasCostVTHO:l,success:!1,error:`Token inflow mismatch: expected ${t.minimumOutputAmount.toString()}, got ${n.inflow.toString()}`}}return{gasCostVTHO:l,success:!0}}catch(e){return{gasCostVTHO:0,success:!1,error:e instanceof Error?e.message:`Simulation failed`}}},tl=e=>e.startsWith(`0x`)?BigInt(e).toString():e,nl=(e,t)=>({name:e,type:`function`,inputs:t.map(e=>({name:e.name,type:e.type,internalType:e.internalType,components:e.components})),outputs:[],stateMutability:`nonpayable`}),rl=(e,t)=>{if(Array.isArray(e)&&e.length>0){let n=e[0];if(typeof n==`object`&&`name`in n&&`type`in n&&n.type===`function`)return e;if(typeof n==`object`&&`name`in n&&`type`in n&&!(`stateMutability`in n||`outputs`in n))return[nl(t,e)]}return e},il=e=>{try{let t=e.functionName||e.name;if(!t)throw Error(`Function name is required (either functionName or name must be provided)`);return Fi({abi:rl(e.abi,t),functionName:t,args:e.args})}catch(t){console.error(`Failed to encode function call:`,t);let n=e.functionName||e.name||`unknown`;throw Error(`Failed to encode function call ${n}: ${t instanceof Error?t.message:`Unknown error`}`)}},al=e=>{let t=il(e.functionCall);return{to:e.to,value:tl(e.value),data:t,comment:e.comment||`Swap on aggregator`}},ol=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=new URL(e.apiBaseUrl);i.search=r.toString();let a=await fetch(i);if(!a.ok)throw Error(`API request failed: ${a.status} ${a.statusText}`);let o=await a.json(),s=o.clauses.map(al),c=BigInt(o.amountOut),l=BigInt(o.amountOutMin);return{aggregatorName:e.name,aggregator:t,outputAmount:c,minimumOutputAmount:l,priceImpact:0,data:{clauses:s,path:o.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{return el(e,t,await this.buildSwapTransaction(e,t),n)}catch(e){return{gasCostVTHO:0,success:!1,error:e instanceof Error?e.message:`Failed to build swap transaction for simulation`}}},async buildSwapTransaction(t,n){if(!n.data||typeof n.data!=`object`||!(`clauses`in n.data))throw Error(`Invalid quote data: clauses not found`);let r=n.data.clauses;if(r.length===0)throw Error(`No clauses found in quote`);if(e.supportedAddresses&&e.supportedAddresses.length>0){let t=e.supportedAddresses.map(e=>e.toLowerCase());if(r=r.filter(e=>e.to?t.includes(e.to.toLowerCase()):!1),r.length===0)throw Error(`No clauses found matching supported addresses`)}if(!n.minimumOutputAmount||n.minimumOutputAmount===0n)throw Error(`Invalid quote: minimumOutputAmount is missing or zero`);return r}};return t},sl={main:{supportedAddresses:[`0xE5fA980a6EfE5B79C2150a529da06AeF455963b6`,`0x7C755EC0165fCD926cC6faB10E7BB16a72E9f34A`]},test:{supportedAddresses:[]},solo:{supportedAddresses:[]}},cl=e=>e===`0x`||e===`0x0000000000000000000000000000000000000000`,ll=e=>new URL(`api/quote/vck`,Te).toString(),ul=e=>{let t=sl[e]??sl.main,n=ol({name:`VeTrade.vet`,apiBaseUrl:ll(e),network:e,getIcon:(e=`20px`)=>H.createElement(Je,{boxSize:e}),supportedAddresses:t.supportedAddresses});return{...n,async simulateSwap(e,t,n){try{return el(e,t,await this.buildSwapTransaction(e,t),n)}catch(e){return{gasCostVTHO:0,success:!1,error:e instanceof Error?e.message:`Simulation failed`}}},async buildSwapTransaction(e,r){let i=[],a=await n.buildSwapTransaction(e,r);if(!a||a.length===0)throw Error(`Failed to build swap transaction`);if(cl(e.fromTokenAddress))a[0].value=e.amountIn;else{if(t.supportedAddresses.length===0)throw Error(`No supported addresses configured for VeTrade on this network`);let n=Dn.ofAbi(xi.abi),o=On.of(e.fromTokenAddress),s=BigInt(e.amountIn);i.push(kn.callFunction(o,n.getFunction(`approve`),[a[0].to,s.toString()],Fn.of(0n,Pn.wei),{comment:`Approve ${r.aggregatorName} to access ${e.fromTokenAddress}`}))}return i.push(...a),i}}},dl=e=>e===`0x`||e===`0x0000000000000000000000000000000000000000`,fl=()=>BigInt(Math.floor(Date.now()/1e3)+1200),pl=e=>{let t={name:e.name,getIcon:e.getIcon,async getQuote(n,r){let i=[dl(n.fromTokenAddress)?e.wrappedVET:n.fromTokenAddress,dl(n.toTokenAddress)?e.wrappedVET:n.toTokenAddress],a=BigInt(n.amountIn);try{let[o]=await r.contracts.load(e.routerAddress,Ti.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){return el(e,t,await this.buildSwapTransaction(e,t),n)},async buildSwapTransaction(t,n){if(!n.data||typeof n.data!=`object`||!(`path`in n.data))throw Error(`Invalid quote data`);let r=fl();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=dl(t.fromTokenAddress),s=dl(t.toTokenAddress),c=Dn.ofAbi(Ti.abi),l=[];if(o)l.push(kn.callFunction(On.of(e.routerAddress),c.getFunction(`swapExactETHForTokens`),[i.toString(),n.data.path,t.userAddress,r.toString()],Fn.of(a,Pn.wei),{comment:`Swap on ${n.aggregatorName}`}));else{let o=Dn.ofAbi(xi.abi),u=On.of(t.fromTokenAddress),d=On.of(e.routerAddress);l.push(kn.callFunction(u,o.getFunction(`approve`),[d.toString(),a.toString()],Fn.of(0n,Pn.wei),{comment:`Swap on ${n.aggregatorName}`})),s?l.push(kn.callFunction(d,c.getFunction(`swapExactTokensForETH`),[a.toString(),i.toString(),n.data.path,t.userAddress,r.toString()],Fn.of(0n,Pn.wei),{comment:`Swap on ${n.aggregatorName}`})):l.push(kn.callFunction(d,c.getFunction(`swapExactTokensForTokens`),[a.toString(),i.toString(),n.data.path,t.userAddress,r.toString()],Fn.of(0n,Pn.wei),{comment:`Swap on ${n.aggregatorName}`}))}return l}};return t},ml={main:{routerAddress:`0xf21Dd7108D93af56FaB07423EfB90F4a3604DA89`,wrappedVET:`0xf9b02b47694fd635A413F16dC7B38aF06Cc16fe5`},test:{routerAddress:Ui,wrappedVET:Ui},solo:{routerAddress:Ui,wrappedVET:Ui}},hl=e=>{let t=ml[e]??ml.main;return pl({name:`BetterSwap.io`,routerAddress:t.routerAddress,wrappedVET:t.wrappedVET,getIcon:(e=`20px`)=>H.createElement(We,{boxSize:e})})},gl=e=>[ul(e),hl(e)],_l=(e,t,n,r,i=1,a=!0)=>{let o=Qn(),{connection:s}=Q(),c=e?.address??null,l=t?.address??null,{data:u}=ic(c===`0x`||c===Ui||!c?``:c),{data:d}=ic(l===`0x`||l===Ui||!l?``:l),f=G(()=>!c||c===`0x`||c===Ui||!u?18:Number(u?.decimals??18),[c,u?.decimals]),p=G(()=>!l||l===`0x`||l===Ui||!d?18:Number(d?.decimals??18),[l,d?.decimals]),m=G(()=>{if(!c||!l||!n||!r)return null;let e;try{e=Vi(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:_}=or({queryKey:[`unified-swap-quotes`,m,s.network],queryFn:async()=>{if(!m||!o||!s.network)return{quotes:[],best:null};let e=gl(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}},vl=({email:e,onResend:t,isLoading:n,isOpen:r,onClose:i})=>{let{t:a}=X(),{darkMode:o}=$(),s=V(`colors`,`vechain-kit-text-secondary`),[c,l]=K(``),[u,d]=K(null),{createWallet:f}=Bn(),{loginWithCode:p}=Vn({onComplete:async({isNewUser:e})=>{e&&await f()}});return W(()=>{c.length===6&&p({code:c}).then(()=>{i()}).catch(e=>{d(e.message)})},[c]),Y(zo,{isOpen:r,onClose:i,trapFocus:!1,children:[Y(Z,{children:[J(R,{alignItems:`center`,display:`flex`,gap:2,children:a(`Enter confirmation code`)}),J(I,{})]}),Y(yt,{maxW:`container.lg`,children:[J(F,{children:Y(B,{spacing:2,children:[J(P,{as:Kr,w:`48px`,h:`48px`,color:s}),J(z,{fontSize:`xs`,color:s,textAlign:`center`,children:a(`Please check {{email}} for an email from privy.io and enter your code below.`,{email:e})}),J(N,{spacing:2,justify:`center`,mt:4,children:Y(zt,{value:c,onChange:l,otp:!0,size:`lg`,isInvalid:!!u,errorBorderColor:`#ef4444`,children:[J(Bt,{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`}),J(Bt,{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`}),J(Bt,{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`}),J(Bt,{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`}),J(Bt,{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`}),J(Bt,{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&&J(z,{color:`#ef4444`,fontSize:`xs`,children:u})]})}),J(L,{children:Y(z,{w:`100%`,textAlign:`center`,fontSize:`14px`,color:o?`whiteAlpha.700`:`gray.600`,children:[a(`Didn't get an email?`),` `,J(M,{variant:`link`,color:`blue.500`,fontSize:`14px`,onClick:t,isLoading:n,children:a(`Resend code`)})]})})]})]})},yl=()=>{let{t:e}=X(),{darkMode:t}=$(),[n,r]=K(``),{sendCode:i,state:a}=Vn({}),o=fn(),s=async()=>{await i({email:n}),o.onOpen()};return Y(q,{children:[J(Tt,{colSpan:4,w:`full`,children:J(B,{spacing:3,w:`full`,children:Y(At,{size:`lg`,w:`full`,children:[J(jt,{pointerEvents:`none`,height:`100%`,pl:4,children:J(P,{as:Kr,color:t?`whiteAlpha.600`:`blackAlpha.700`,w:`20px`,h:`20px`})}),J(kt,{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}),J(M,{"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`)})]})})}),J(vl,{isOpen:o.isOpen,onClose:o.onClose,onResend:()=>i({email:n}),email:n,isLoading:a.status===`sending-code`})]})},bl=({isDark:e,gridColumn:t})=>{let{t:n}=X(),{initOAuth:r}=zf();return J(Tt,{colSpan:t??4,w:`full`,children:J(pd,{isDark:e,onClick:async()=>{await r({provider:`google`})},icon:na,text:n(`Continue with Google`)})})},xl=({isDark:e,gridColumn:t})=>{let{t:n}=X(),{initOAuth:r}=zf();return J(Tt,{colSpan:t??4,w:`full`,children:J(pd,{isDark:e,onClick:async()=>{await r({provider:`github`})},icon:zr,text:n(`Continue with Github`)})})},Sl=({isDark:e,gridColumn:t})=>{let{t:n}=X(),{login:r}=Gn();return J(Tt,{colSpan:t||4,w:`full`,children:J(pd,{isDark:e,onClick:r,icon:e?xe:Ke,text:n(`Use social login with VeChain`),variant:`loginWithVechain`,rightIcon:J(vd,{})})})},Cl=({isDark:e,gridColumn:t,setCurrentContent:n})=>{let{t:r}=X(),{login:i}=Vf(),a=async()=>{n({type:`loading`,props:{title:r(`Connecting to VeChain`),loadingText:r(`Please approve the request in the connection request window...`),onTryAgain:a}});try{await i()}catch(e){console.error(r(`Login failed:`),e),n({type:`error`,props:{error:e instanceof Error?e.message:r(`Failed to connect with VeChain`),onTryAgain:a}})}};return J(Tt,{colSpan:t||4,w:`full`,children:J(pd,{isDark:e,onClick:a,icon:e?xe:Ke,text:r(`Use social login with VeChain`),variant:`loginWithVechain`,rightIcon:J(vd,{})})})},wl=({isDark:e,gridColumn:t,setCurrentContent:n})=>{let{t:r}=X(),{loginWithPasskey:i}=Lf(),a=async()=>{n({type:`loading`,props:{title:r(`Connecting with Passkey`),loadingText:r(`Please complete the passkey authentication...`),onTryAgain:a}});try{await i()}catch(e){(e instanceof Error?e.message.toLowerCase():``).includes(`not found`)&&console.error(e),n({type:`error`,props:{error:e instanceof Error?e.message:r(`Failed to connect with Passkey`),onTryAgain:a}})}};return J(Tt,{colSpan:t,w:`full`,children:J(pd,{isDark:e,onClick:a,icon:Ir,text:t&&t>=2?r(`Passkey`):void 0})})},Tl=({isDark:e,gridColumn:t=2})=>{let{t:n}=X(),{open:r,onConnectionStatusChange:i}=tr(),{dappKit:a}=$(),{source:o}=er(),s=a?.allowedWallets?.includes(`sync2`)?n(`Connect wallet`):n(`Connect with VeWorld wallet`);return W(()=>{i((e,t)=>{if(!e)return t?.message&&console.error(t?.message),{...o&&{source:o}}})},[i,o]),J(Tt,{colSpan:t||2,w:`full`,children:J(pd,{isDark:e,onClick:()=>{r()},icon:a?.allowedWallets?.includes(`sync2`)?si:e?Ce:He,iconWidth:`27px`,text:t>=2?s:void 0,rightIcon:a?.allowedWallets?.includes(`sync2`)&&J(P,{as:hr})||void 0})})},El=({isDark:e,onViewMoreLogin:t,gridColumn:n})=>{let{t:r}=X();return J(Tt,{colSpan:n,w:`full`,children:J(pd,{isDark:e,onClick:t,icon:Nr,text:n&&n>=2?r(`More`):void 0,rightIcon:J(P,{as:hr})})})},Dl=({setCurrentContent:e})=>{let{loginMethods:t,darkMode:n}=$(),{login:r}=Gn(),{showGoogleLogin:i,showEmailLogin:a,showPasskey:o,showVeChainLogin:s,showDappKit:c,showMoreLogin:l,showGithubLogin:u,isOfficialVeChainApp:d}=Of();return J(Yt,{spacing:4,w:`full`,align:`center`,children:J(wt,{templateColumns:`repeat(4, 1fr)`,gap:2,w:`full`,children:t?.map(({method:t,gridColumn:f})=>{switch(t){case`email`:return a&&J(yl,{},`email`);case`google`:return i&&J(bl,{isDark:n,gridColumn:f},`google`);case`github`:return u&&J(xl,{isDark:n,gridColumn:f},`github`);case`vechain`:return s&&(d?J(Sl,{isDark:n,gridColumn:f},`vechain`):J(Cl,{isDark:n,gridColumn:f,setCurrentContent:e},`vechain`));case`passkey`:return o&&J(wl,{isDark:n,gridColumn:f,setCurrentContent:e},`passkey`);case`dappkit`:return c&&J(Tl,{isDark:n,gridColumn:f},`dappkit`);case`more`:return l&&J(El,{isDark:n,onViewMoreLogin:r,gridColumn:f},`more`);default:return null}})})})},Ol=({appsInfo:e,isLoading:t,setCurrentContent:n})=>{let{t:r}=X();return J(M,{fontSize:`sm`,variant:`link`,onClick:()=>n({type:`ecosystem`,props:{appsInfo:e,isLoading:t}}),children:r(`Already have an x2earn app wallet?`)})},kl=({setCurrentContent:e})=>{let{t}=X(),{loginModalUI:n,darkMode:r}=$(),{loginMethods:i,privyEcosystemAppIDS:a}=$(),{data:o,isLoading:s}=Ho(a),c=V(`colors`,`vechain-kit-text-secondary`),l=()=>{e(`faq`)},u=i?.some(({method:e})=>e===`ecosystem`);return Y(q,{children:[Y(Z,{children:[J(Dm,{onClick:l}),J(R,{children:t(`Log in or sign up`)}),J(I,{})]}),n?.logo&&J(N,{justify:`center`,children:J(Ot,{src:n.logo||`/images/favicon.png`,maxW:`180px`,maxH:`90px`,m:8,alt:`logo`})}),Y(F,{children:[n?.description&&J(N,{spacing:4,w:`full`,justify:`center`,mb:`24px`,px:4,children:J(z,{color:c,fontSize:`sm`,textAlign:`center`,children:n?.description})}),J(Dl,{setCurrentContent:e})]}),u?J(L,{children:J(N,{justify:`center`,w:`full`,children:J(Ol,{isDark:r,appsInfo:Object.values(o||{}),isLoading:s,setCurrentContent:e})})}):J(L,{pt:0,pb:`5px`})]})},Al=({setCurrentContent:e,wallet:t,onClose:n,switchFeedback:r})=>{let{t:i}=X(),{network:a}=$(),{isolatedView:o}=Ml();return Y(Om,{children:[Y(Z,{children:[!o&&J(Oo,{onClick:()=>{e(`profile`)}}),Y(R,{children:[i(`Wallet`),a?.type!==`main`&&J(Zt,{size:`xs`,colorScheme:`orange`,fontSize:`2xs`,p:1,ml:1,textTransform:`uppercase`,children:`${a?.type}`})]}),J(I,{})]}),J(F,{w:`full`,children:Y(B,{w:`full`,overflow:`hidden`,justifyContent:`flex-start`,spacing:8,children:[J(Lm,{showFeedback:r?.showFeedback}),J(Xl,{style:{justifyContent:`flex-start`},onClick:()=>{e(`profile`)},setCurrentContent:e,onClose:n,wallet:t}),J(Ql,{onAssetsClick:()=>{e(`assets`)}}),J(tu,{setCurrentContent:e})]})}),J(L,{pt:0})]})},jl=({onSelectToken:e,onBack:t,showAllTokens:n=!1,excludedTokenSymbols:r=p})=>{let{t:i}=X(),{darkMode:a}=$(),{currentCurrency:o}=Ys(),s=V(`colors`,`vechain-kit-text-primary`),c=V(`colors`,`vechain-kit-text-secondary`),l=V(`colors`,`vechain-kit-text-tertiary`),{account:u}=Q(),{tokensWithBalance:d,sortedTokens:f}=Xs({address:u?.address??``}),[m,h]=K(``),g=G(()=>{let e=e=>r.includes(e),t;if(n){let n=f.filter(t=>Number(t.balance)>0&&!e(t.symbol)),r=[...f.filter(t=>Number(t.balance)===0&&!e(t.symbol))].sort((e,t)=>e.symbol.localeCompare(t.symbol));t=[...n,...r]}else t=d.filter(t=>!e(t.symbol));return t},[n,f,d,r]).filter(({symbol:e})=>e.toLowerCase().includes(m.toLowerCase()));return Y(q,{children:[Y(Z,{children:[J(R,{children:i(`Select Token`)}),J(Oo,{onClick:t}),J(I,{})]}),J(yt,{h:[`540px`,`auto`],p:0,children:J(F,{children:Y(B,{spacing:4,align:`stretch`,children:[Y(At,{size:`lg`,children:[J(kt,{placeholder:`Search token`,bg:a?`vechain-kit-overlay`:`vechain-kit-card`,borderRadius:`xl`,height:`56px`,pl:12,value:m,onChange:e=>h(e.target.value),"data-testid":`search-token-input`}),J(jt,{h:`56px`,w:`56px`,pl:4,children:J(Qr,{color:l})})]}),J(z,{fontSize:`lg`,fontWeight:`semibold`,color:s,mt:4,children:i(n?`All tokens`:`Your tokens`)}),g.length===0?Y(B,{spacing:2,py:8,children:[J(P,{as:ni,boxSize:12,color:l}),J(z,{fontSize:`lg`,color:s,children:i(`No tokens found`)}),J(z,{fontSize:`md`,color:c,children:i(`Try searching with a different term`)})]}):J(B,{spacing:2,align:`stretch`,children:g.map(t=>J(Tm,{symbol:t.symbol,amount:Number(t.balance),currencyValue:t.valueInCurrency,currentCurrency:o,onClick:()=>e(t)},t.address))})]})})}),J(L,{pt:0})]})},Ml=()=>{let{isolatedView:e,closeAccountModal:t}=$d();return{isolatedView:e,closeAccountModal:t}},Nl=({setCurrentContent:t,preselectedToken:n,initialAmount:r=``,initialToAddressOrDomain:i=``,onBack:a=()=>t(`main`)})=>{let{t:o}=X(),{darkMode:s,feeDelegation:c}=$(),{currentCurrency:l}=Ys(),u=V(`colors`,`vechain-kit-text-primary`),d=V(`colors`,`vechain-kit-text-secondary`),f=V(`colors`,`vechain-kit-text-tertiary`),m=V(`colors`,`vechain-kit-error`),h=V(`colors`,`vechain-kit-card`),{exchangeRates:g}=Ws(),{account:_}=Q(),{isolatedView:v}=Ml(),{tokensWithBalance:y}=Xs({address:_?.address??``}),b=G(()=>y.filter(e=>!p.includes(e.symbol)),[y]),[x,C]=K(()=>n&&!p.includes(n.symbol)?n:b[0]??null),[w,T]=K(!1);W(()=>{!x&&b.length>0&&C(b[0])},[b,x]);let{register:E,watch:D,setValue:O,setError:k,formState:{errors:A,isValid:ee},handleSubmit:te}=ra({defaultValues:{amount:r,toAddressOrDomain:i},mode:`onChange`}),{toAddressOrDomain:ne,amount:re}=D(),ie=vn(x);W(()=>{ie.current&&x&&ie.current.address!==x.address&&O(`amount`,``),ie.current=x},[x,O]);let ae=G(()=>x?qs(Gs(Number(re)*x.priceUsd,l,g),{currency:l}):``,[re,x,l,g]),{data:oe,isLoading:se}=Ko(ne),ce=()=>{x&&O(`amount`,x.balance)},le=()=>{a()},ue=async e=>{if(x){if(!(oe?.isValidAddressOrDomain&&(!oe?.domain||oe?.domain&&oe?.isPrimaryDomain))){k(`toAddressOrDomain`,{type:`manual`,message:o(`Invalid address or domain`)});return}if(x){let t=Cn(e.amount),n=c?.b3trTransfers?.minAmountInEther;if(x.symbol===`B3TR`&&typeof n==`number`&&n>0)try{if(t<Cn(String(n))){k(`amount`,{type:`manual`,message:o(`Minimum {{symbol}} transfer is {{min}}`,{symbol:x.symbol,min:n})});return}}catch{}if(t>Cn(x.balance)){k(`amount`,{type:`manual`,message:o(`Insufficient {{symbol}} balance`,{symbol:x.symbol})});return}}t({type:`send-token-summary`,props:{toAddressOrDomain:e.toAddressOrDomain,resolvedDomain:oe?.domain,resolvedAddress:oe?.address,amount:e.amount,selectedToken:x,formattedTotalAmount:ae,setCurrentContent:t}})}};return w?J(jl,{setCurrentContent:t,onSelectToken:e=>{C(e),T(!1)},onBack:()=>{T(!1)}}):Y(q,{children:[Y(Z,{children:[J(R,{children:o(`Send`)}),!v&&J(Oo,{onClick:le}),J(I,{})]}),J(F,{children:Y(B,{spacing:2,align:`stretch`,position:`relative`,children:[Y(N,{justify:`space-between`,children:[J(z,{fontSize:`md`,fontWeight:`bold`,color:u,children:o(`Amount`)}),Y(z,{cursor:`pointer`,_hover:{color:d,textDecoration:`underline`},onClick:ce,noOfLines:1,overflow:`hidden`,textOverflow:`ellipsis`,fontSize:`sm`,fontWeight:`medium`,color:d,children:[o(`Balance`),`:`,` `,Number(x?.balance??0).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})]})]}),J(j,{p:4,borderRadius:`2xl`,bg:h,children:J(B,{align:`stretch`,spacing:2,children:Y(St,{isInvalid:!!A.amount,children:[Y(N,{justify:`space-between`,children:[J(kt,{...E(`amount`,{required:o(`Amount is required`),pattern:{value:/^\d*\.?\d*$/,message:o(`Please enter a valid number`)},validate:e=>{if(!e)return!0;let t=parseFloat(e);if(isNaN(t))return o(`Please enter a valid number`);let n=c?.b3trTransfers?.minAmountInEther;return x?.symbol===`B3TR`&&typeof n==`number`&&n>0&&t<n?o(`Minimum {{symbol}} transfer is {{min}}`,{symbol:x.symbol,min:n}):!0}}),onChange:e=>{let t=e.target.value.trim();e.target.value=t,O(`amount`,t,{shouldValidate:!0})},placeholder:`0`,variant:`unstyled`,fontSize:`4xl`,fontWeight:`bold`,"data-testid":`tx-amount-input`,type:`number`,inputMode:`decimal`,color:u}),x?Y(M,{variant:`outline`,size:`sm`,borderRadius:`full`,px:6,color:d,borderColor:d,_hover:{bg:s?`whiteAlpha.300`:`blackAlpha.300`},onClick:()=>T(!0),leftIcon:S[x.symbol]?H.cloneElement(S[x.symbol],{boxSize:`20px`,borderRadius:`full`}):J(Ot,{src:e[x.symbol],alt:`${x.symbol} logo`,boxSize:`20px`,borderRadius:`full`,fallback:J(j,{boxSize:`20px`,borderRadius:`full`,bg:`whiteAlpha.200`,display:`flex`,alignItems:`center`,justifyContent:`center`,children:J(z,{fontSize:`8px`,fontWeight:`bold`,color:u,children:x.symbol.slice(0,3)})})}),children:[x.symbol,J(P,{as:Cr,boxSize:5,color:d})]}):Y(M,{variant:`outline`,size:`sm`,borderRadius:`full`,px:6,color:d,borderColor:d,_hover:{bg:s?`whiteAlpha.300`:`blackAlpha.300`,color:f},onClick:()=>T(!0),children:[o(`Select token`),J(P,{as:Cr,boxSize:5,color:d})]})]}),x&&J(N,{spacing:1,fontSize:`sm`,justifyContent:`space-between`,color:d,children:Y(z,{color:d,children:[`≈ `,ae]})}),A.amount&&J(z,{color:`#ef4444`,fontSize:`sm`,mt:1,"data-testid":`amount-error-msg`,children:A.amount.message})]})})}),J(N,{justify:`space-between`,mt:2,children:J(z,{fontSize:`md`,fontWeight:`bold`,color:u,children:o(`To`)})}),J(j,{borderRadius:`2xl`,bg:h,children:J(B,{align:`stretch`,spacing:2,p:4,width:`100%`,children:Y(St,{isInvalid:!!A.toAddressOrDomain,children:[J(kt,{...E(`toAddressOrDomain`,{required:o(`Address is required`)}),onChange:e=>{let t=e.target.value.trim(),n=t.includes(`.`)?ia(t):t;e.target.value=n,O(`toAddressOrDomain`,n,{shouldValidate:!0})},placeholder:o(`Type the receiver address or domain`),_placeholder:{fontSize:`md`,fontWeight:`normal`},fontSize:`lg`,fontWeight:`bold`,color:u,variant:`unstyled`,"data-testid":`tx-address-input`}),A.toAddressOrDomain&&J(z,{color:m,fontSize:`sm`,"data-testid":`address-error-msg`,children:A.toAddressOrDomain.message})]})})})]})}),J(L,{children:J(M,{variant:`vechainKitPrimary`,isDisabled:!x||!ee,isLoading:se,onClick:te(ue),"data-testid":`send-button`,children:o(x?`Send`:`Select Token`)})})]})},Pl=({setCurrentContent:e,toAddressOrDomain:t,resolvedDomain:n,resolvedAddress:r,amount:i,selectedToken:a,formattedTotalAmount:o})=>{let{t:s}=X(),{account:c,connection:u,connectedWallet:d}=Q(),{data:f}=ks(r??``),{network:p,feeDelegation:m}=$(),{preferences:h}=Sm(),{isolatedView:g,closeAccountModal:_}=Ml(),v=V(`colors`,`vechain-kit-text-primary`),y=V(`colors`,`vechain-kit-text-secondary`),{data:b}=Np(c?.address??``,d?.address??``,3),{open:x}=kf(),S=G(()=>f||l(r||t),[f,p.type,r,t]),C=async()=>{if(b){x();return}try{a.symbol===`VET`?await ee():await T()}catch(e){console.error(s(`Transaction failed:`),e)}},w=H.useCallback(t=>{e({type:`successful-operation`,props:{setCurrentContent:e,txId:t,title:s(`Transaction successful`),onDone:()=>{g?_():e(`main`)},showSocialButtons:!0}})},[e,s,g,_]),{sendTransaction:T,txReceipt:E,error:D,isWaitingForWalletConfirmation:O,isTransactionPending:k,clauses:A}=Xp({fromAddress:c?.address??``,receiverAddress:r||t,amount:i,tokenAddress:a.address,tokenName:a.symbol,onError:e=>{fe(e??``)}}),{sendTransaction:ee,txReceipt:te,error:ne,isWaitingForWalletConfirmation:re,isTransactionPending:ie,clauses:ae}=Qp({fromAddress:c?.address??``,receiverAddress:r||t,amount:i,onError:e=>{fe(e??``)}}),oe=H.useCallback(()=>a.symbol===`VET`?te:E,[a.symbol,te,E]),se=O||re,ce=se||k||ie,[le,ue]=H.useState(!1);H.useEffect(()=>{let e=oe();if(!e||e.reverted||le||ce)return;let t=e.meta.txID;t&&(ue(!0),w(t))},[oe,le,ce,w]),H.useEffect(()=>{ce&&ue(!1)},[ce]);let de=()=>{e({type:`send-token`,props:{setCurrentContent:e,preselectedToken:a,initialAmount:i,initialToAddressOrDomain:t}})},fe=e=>{console.error(`Transaction failed:`,e)},[pe,me]=H.useState(null),[he,ge]=H.useState(null),_e=h.availableGasTokens.length>0&&(u.isConnectedWithPrivy||u.isConnectedWithVeChain)&&!m?.delegatorUrl,{data:ve,isLoading:ye,error:be,refetch:xe}=Cm({clauses:a.symbol===`VET`?ae:A,tokens:pe?[pe]:h.availableGasTokens,sendingAmount:i,sendingTokenSymbol:a.symbol,enabled:_e&&!!m?.genericDelegatorUrl}),Se=ve?.usedToken,Ce=(ye||!ve)&&u.isConnectedWithPrivy&&!m?.delegatorUrl,we=H.useCallback(e=>{me(e),ge(e),setTimeout(()=>xe(),100)},[xe]),Te=!!Se&&!be;return H.useEffect(()=>{be&&pe&&me(null)},[be,pe]),Y(q,{children:[Y(Z,{children:[J(R,{children:`Send`}),J(Oo,{isDisabled:ce,onClick:de}),J(I,{isDisabled:ce})]}),J(F,{children:J(B,{spacing:6,align:`stretch`,w:`full`,children:Y(B,{spacing:4,w:`full`,children:[Y(j,{w:`full`,children:[J(z,{fontSize:`sm`,mb:2,color:y,children:s(`From`)}),J(Em,{address:c?.address??``,domain:c?.domain,imageSrc:c?.image??``,imageAlt:`From account`,balance:Number(a.balance),tokenAddress:a.address})]}),Y(j,{w:`full`,children:[J(z,{fontSize:`sm`,mb:2,color:y,children:s(`To`)}),J(Em,{address:r||t,domain:n,imageSrc:S??``,imageAlt:`To account`,tokenAddress:a.address})]}),u.isConnectedWithPrivy&&J(Nm,{estimation:ve,isLoading:ye,isLoadingTransaction:ce,onTokenChange:we,clauses:a.symbol===`VET`?ae:A,userSelectedToken:he}),Y(B,{spacing:0,w:`full`,justifyContent:`flex-start`,children:[J(z,{fontSize:`sm`,fontWeight:`light`,textAlign:`left`,w:`full`,color:y,children:s(`Amount`)}),Y(N,{justifyContent:`flex-start`,w:`full`,children:[Y(z,{fontSize:`xl`,fontWeight:`semibold`,textAlign:`left`,"data-testid":`send-summary-amount`,color:v,children:[Number(i).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2}),` `,a.symbol]}),Y(z,{color:y,children:[`≈ `,o]})]})]})]})})}),J(L,{children:J(Am,{transactionError:a.symbol===`VET`?ne:D,isSubmitting:ce,isTxWaitingConfirmation:se,onConfirm:C,transactionPendingText:s(`Sending...`),txReceipt:oe(),buttonText:s(`Confirm`),isDisabled:ce||Ce,gasEstimationError:be,hasEnoughGasBalance:Te,isLoadingGasEstimation:ye,showGasEstimationError:!m?.delegatorUrl&&u.isConnectedWithPrivy,context:`send`})})]})},Fl=({setCurrentContent:e})=>{let{t}=X(),{account:n}=Q(),{isolatedView:r}=Ml(),i=V(`colors`,`vechain-kit-text-primary`),a=V(`colors`,`vechain-kit-text-secondary`);return Y(q,{children:[Y(Z,{children:[J(R,{children:t(`Receive`)}),!r&&J(Oo,{onClick:()=>e(`main`)}),J(I,{})]}),Y(yt,{maxW:`container.lg`,children:[J(F,{children:Y(B,{spacing:4,align:`center`,w:`full`,children:[J(aa,{value:n?.address??``,size:200,removeQrCodeBehindLogo:!0,eyeRadius:4,logoPaddingStyle:`circle`,style:{borderRadius:`16px`}}),J(ko,{wallet:n,style:{w:`85%`}}),J(z,{fontSize:`sm`,textAlign:`center`,color:i,children:t(`Copy your address or scan this QR code`)}),J(z,{fontSize:`xs`,textAlign:`center`,color:a,children:t(`This address only supports VeChain assets.`)})]})}),J(L,{pt:0})]})]})},Il=({quotes:t,selectedQuote:n,toTokenAddress:r,onSelectQuote:i,onBack:a})=>{let{t:o}=X(),{darkMode:s}=$(),{currentCurrency:c}=Ys(),{account:l}=Q(),{exchangeRates:u,prices:d}=Ws(),{tokens:f}=Xs({address:l?.address??``}),[p,m]=K(!1),h=G(()=>r&&f.find(e=>O(e.address,r))||null,[r,f]),g=t.filter(e=>!e.reverted),_=t.filter(e=>e.reverted),v=G(()=>g.length===0?null:g.reduce((e,t)=>{let n=BigInt(e.outputAmount||`0`);return BigInt(t.outputAmount||`0`)>n?t:e}),[g]),y=G(()=>{let e=r&&d[r]||0;return g.map(t=>{let n=Ii(BigInt(t.outputAmount||`0`)),r=Number(n)*e,i=Gs(r,c,u),a=v&&t.aggregatorName===v.aggregatorName,o=0;if(v&&!a){let e=BigInt(v.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)})},[g,r,d,c,u,v]);return Y(q,{children:[Y(Z,{children:[J(R,{children:o(`Found following rates`)}),J(Oo,{onClick:a}),J(I,{})]}),J(yt,{h:[`540px`,`auto`],p:0,children:J(F,{children:Y(B,{spacing:6,align:`stretch`,children:[y.length>0&&J(B,{spacing:2,align:`stretch`,children:y.map(t=>{let r=n?.aggregatorName===t.aggregatorName;return Y(j,{p:2.5,borderRadius:`xl`,bg:s?`#00000038`:`gray.50`,borderWidth:1,borderColor:r?`blue.500`:s?`whiteAlpha.200`:`gray.200`,cursor:`pointer`,onClick:()=>i(t),_hover:{borderColor:r?`blue.500`:s?`whiteAlpha.400`:`gray.300`},position:`relative`,children:[(t.isBest||!t.isBest&&t.percentageDiff<0)&&J(j,{position:`absolute`,top:-1,left:0,zIndex:1,children:t.isBest?J(ct,{colorScheme:`purple`,borderRadius:`sm`,fontSize:`2xs`,px:1.5,py:.5,borderTopLeftRadius:`xl`,borderBottomRightRadius:`md`,children:o(`Best`)}):Y(ct,{colorScheme:`red`,borderRadius:`xs`,fontSize:`2xs`,px:1.5,py:.5,borderTopLeftRadius:`xl`,borderBottomRightRadius:`md`,children:[t.percentageDiff.toFixed(2),`%`]})}),Y(B,{align:`stretch`,spacing:1.5,marginTop:4,children:[Y(N,{justify:`space-between`,align:`center`,children:[Y(N,{spacing:1.5,align:`center`,children:[t.aggregator.getIcon(`20px`),J(z,{fontSize:`md`,fontWeight:`bold`,children:t.aggregatorName})]}),J(N,{align:`center`,spacing:1.5,children:h&&Y(q,{children:[S[h.symbol]?H.cloneElement(S[h.symbol],{boxSize:`24px`,borderRadius:`full`}):e[h.symbol]?J(Ot,{src:e[h.symbol],alt:`${h.symbol} logo`,boxSize:`24px`,borderRadius:`full`}):null,J($t,{label:Number(t.outputAmountFormatted).toLocaleString(void 0,{maximumFractionDigits:18}),hasArrow:!0,placement:`top`,children:Y(z,{fontSize:`md`,fontWeight:`bold`,textAlign:`right`,whiteSpace:`nowrap`,children:[Number(t.outputAmountFormatted).toLocaleString(void 0,{minimumFractionDigits:4}),` `,h.symbol]})})]})})]}),Y(N,{justify:`space-between`,align:`center`,children:[J(z,{fontSize:`xs`,color:s?`whiteAlpha.500`:`blackAlpha.500`,children:t.gasCostVTHO&&t.gasCostVTHO>0?`Gas: ${t.gasCostVTHO.toLocaleString(void 0,{maximumFractionDigits:2})} VTHO`:``}),t.valueUsd>0&&Y(z,{fontSize:`xs`,color:s?`whiteAlpha.600`:`blackAlpha.600`,textAlign:`right`,whiteSpace:`nowrap`,children:[`≈ `,qs(t.valueInCurrency,{currency:c})]})]})]})]},t.aggregatorName)})}),_.length>0&&Y(j,{children:[Y(N,{justify:`space-between`,cursor:`pointer`,onClick:()=>m(!p),py:2,children:[Y(z,{fontSize:`sm`,color:s?`whiteAlpha.600`:`blackAlpha.600`,children:[_.length,` `,o(`rate`),_.length===1?``:`s`,` `,o(`unavailable`)]}),J(P,{as:p?Er:Cr,boxSize:4,color:s?`whiteAlpha.600`:`blackAlpha.600`})]}),J(_t,{in:p,animateOpacity:!0,children:J(B,{spacing:2,align:`stretch`,pt:2,children:_.map(e=>J(j,{p:2,borderRadius:`xl`,bg:s?`#00000038`:`gray.50`,opacity:.6,children:Y(N,{justify:`space-between`,children:[Y(N,{spacing:2,align:`center`,children:[e.aggregator.getIcon(`20px`),J(z,{fontSize:`md`,fontWeight:`medium`,children:e.aggregatorName})]}),J(z,{fontSize:`xs`,color:s?`whiteAlpha.500`:`blackAlpha.500`,children:o(`Unable to fetch the price`)})]})},e.aggregatorName))})})]}),y.length===0&&_.length===0&&J(B,{spacing:2,py:8,color:s?`whiteAlpha.600`:`blackAlpha.600`,children:J(z,{fontSize:`lg`,children:o(`No quotes available`)})})]})})}),J(L,{})]})},Ll=e=>e===`0x`||e===Ui||!e,Rl=(e,t,n,r)=>{if(!e||!t||!n||!r)return null;let i=t.toLowerCase(),a=n.toLowerCase(),o=r.toLowerCase(),s=Ll(n),c=Ll(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=xi.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=Ni({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}},zl=({setCurrentContent:t,fromTokenAddress:n,toTokenAddress:r})=>{let{t:i}=X(),{account:a,connection:o}=Q(),{currentCurrency:s}=Ys(),{network:c,feeDelegation:l,darkMode:u}=$(),{isolatedView:d,closeAccountModal:f}=Ml(),m=V(`colors`,`vechain-kit-card`),h=V(`colors`,`vechain-kit-text-primary`),g=V(`colors`,`vechain-kit-text-secondary`),_=V(`colors`,`vechain-kit-text-tertiary`),v=V(`colors`,`vechain-kit-button-primary-bg`),b=V(`colors`,`vechain-kit-button-primary-color`),{preferences:x}=Sm(),{sortedTokens:C}=Xs({address:a?.address??``}),[w,T]=K(`main`),[E,D]=K(null),[k,A]=K(null),[ee,te]=K(``),[ne,re]=K(!1),[ie,ae]=K(1),[oe,se]=K(`1`),[ce,le]=K(null),[ue,de]=H.useState(null),[fe,pe]=H.useState(null),[me,he]=H.useState([]),{prices:ge,exchangeRates:_e}=Ws(),ve=ie===1;H.useEffect(()=>{se(ie===1?`1`:ie===.5?`0.5`:ie===3?`3`:ie.toString())},[ie]),H.useEffect(()=>{if(C.length!==0){if((n||r)&&(!E||!k)){if(n&&!E){let e=C.find(e=>O(e.address,n));e&&!p.includes(e.symbol)&&D(e)}if(r&&!k){let e=C.find(e=>O(e.address,r));e&&!p.includes(e.symbol)&&A(e)}return}if(!E&&!k){let e=C.find(e=>e.symbol===`VET`);e&&D(e);let t=C.find(e=>e.symbol===`B3TR`);if(!t)try{let e=y(c.type).b3trContractAddress;e&&(t=C.find(t=>O(t.address,e)))}catch(e){console.warn(`Failed to get B3TR address from config:`,e)}t&&A(t)}}},[C,E,k,n,r,c.type]),H.useEffect(()=>{le(null)},[E?.address,k?.address,ee]);let{bestQuote:ye,quotes:be,isLoading:xe,from:Se,to:Ce}=_l(E,k,ee,a?.address??``,ie,!!E&&!!k&&Number(ee)>0),we=G(()=>{if(!ee||Number(ee)<=0||!Se)return 0n;try{return Vi(ee,Se.decimals)}catch{return 0n}},[ee,Se?.decimals]),Te=ce||ye,Ee=G(()=>{if(!Te?.outputAmount||!Ce)return`0`;try{return Li(Te.outputAmount,Ce.decimals)}catch{return`0`}},[Te,Ce?.decimals]),De=G(()=>{if(!E||!ee)return 0;let e=ge[E.address]||0;return Gs(Number(ee)*e,s,_e)},[E?.address,ee,ge,s,_e]),Oe=G(()=>{if(!k||!Ee)return 0;let e=ge[k.address]||0;return Gs(Number(Ee)*e,s,_e)},[k?.address,Ee,ge,s,_e]),ke=G(()=>!E||!k||!a?.address||we===0n?null:{fromTokenAddress:E.address,toTokenAddress:k.address,amountIn:we.toString(),userAddress:a.address,slippageTolerance:ie},[E,k,a?.address,we,ie]),Ae=Te?.gasCostVTHO??0;H.useEffect(()=>{(async()=>{if(!Te||!ke||!Te.aggregator){he([]);return}try{he(await Te.aggregator.buildSwapTransaction(ke,Te))}catch(e){console.error(`Failed to build swap clauses for gas estimation:`,e),he([])}})()},[Te,ke]);let je=x.availableGasTokens.length>0&&(o.isConnectedWithPrivy||o.isConnectedWithVeChain)&&!l?.delegatorUrl,{data:Me,isLoading:Ne,error:Pe,refetch:Fe}=Cm({clauses:me,tokens:ue?[ue]:x.availableGasTokens,sendingAmount:ee,sendingTokenSymbol:E?.symbol??``,enabled:je&&!!l?.genericDelegatorUrl&&me.length>0}),Ie=Me?.usedToken,Le=(Ne||!Me)&&o.isConnectedWithPrivy&&!l?.delegatorUrl,Re=H.useCallback(e=>{de(e),pe(e),setTimeout(()=>Fe(),100)},[Fe]),ze=!!Ie&&!Pe;H.useEffect(()=>{Pe&&ue&&de(null)},[Pe,ue]);let{executeSwap:Be,isTransactionPending:Ve,isWaitingForWalletConfirmation:He,txReceipt:Ue,status:We,error:Ge}=Zc(ke,Te),Ke=U(()=>{let e=Ue?.meta.txID??``,n=i(`Swap successful`,{defaultValue:`Swap successful`}),r;if(Ue&&E&&k&&a?.address){let e=Rl(Ue,a.address,E.address,k.address);if(e&&Se&&Ce)try{let t=Se.decimals,n=Ce.decimals,a=Li(e.fromAmount,t),o=Li(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})};r=i(`You successfully swapped {fromAmount} {fromSymbol} for {toAmount} {toSymbol}`,{fromAmount:s(a),fromSymbol:E.symbol,toAmount:s(o),toSymbol:k.symbol,defaultValue:`You successfully swapped ${s(a)} ${E.symbol} for ${s(o)} ${k.symbol}`})}catch(e){console.warn(`Failed to format swap amounts:`,e)}}!r&&E&&k&&(r=i(`You successfully swapped {fromToken} for {toToken}`,{fromToken:E.symbol,toToken:k.symbol,defaultValue:`You successfully swapped ${E.symbol} for ${k.symbol}`})),t({type:`successful-operation`,props:{setCurrentContent:t,txId:e,title:n,description:r,onDone:()=>{d?f():t(`main`)},showSocialButtons:!0}})},[E,k,ee,Te,Ue,a?.address,t,i,d,f]),qe=U(e=>{let t=typeof e==`string`?e:e.message;console.error(`Swap failed:`,t)},[E,k,ee]),[Je,Ye]=H.useState(!1);H.useEffect(()=>{if(We===`ready`){Ye(!1);return}Je||(We===`success`&&Ue&&!Ue.reverted?(Ye(!0),Ke()):We===`error`&&Ge?qe(Ge?.reason||Ge?.message||String(Ge)):Ue?.reverted&&qe(`Transaction reverted`))},[We,Ue,Ge,Ke,qe,Je]);let Xe=U(e=>{if(D(e),e.symbol===`VET`&&!k){let e=C.find(e=>e.symbol===`B3TR`);if(!e)try{let t=y(c.type).b3trContractAddress;t&&(e=C.find(e=>O(e.address,t)))}catch(e){console.warn(`Failed to get B3TR address from config:`,e)}e&&A(e)}T(`main`)},[k,C,c.type]),Ze=U(e=>{A(e),T(`main`)},[]),Qe=U(e=>{(/^\d*\.?\d*$/.test(e)||e===``)&&te(e)},[]),$e=U(()=>{E&&te(E.balance)},[E]),et=t=>{if(!t)return null;let n=S[t.symbol],r=e[t.symbol];return{symbol:t.symbol,logoComponent:n,logoUrl:r,balance:t.balance,value:t.valueInCurrency}},tt=et(E),nt=et(k);return w===`select-from-token`?J(jl,{setCurrentContent:t,onSelectToken:Xe,onBack:()=>T(`main`),showAllTokens:!1}):w===`select-quote`?J(Il,{quotes:be,selectedQuote:Te,toTokenAddress:k?.address??null,onSelectQuote:e=>{le(e),T(`main`)},onBack:()=>T(`main`)}):w===`select-to-token`?J(jl,{setCurrentContent:t,onSelectToken:Ze,onBack:()=>T(`main`),showAllTokens:!0}):Y(q,{children:[Y(Z,{children:[J(R,{children:i(`Swap`)}),!d&&J(Oo,{onClick:()=>t(`main`),isDisabled:Ve||He}),J(I,{isDisabled:Ve||He})]}),J(F,{children:Y(B,{spacing:2,align:`stretch`,w:`full`,children:[Y(N,{justify:`space-between`,children:[J(z,{fontSize:`md`,fontWeight:`bold`,color:h,children:i(`From`)}),tt&&Y(z,{cursor:`pointer`,_hover:{color:g,textDecoration:`underline`},onClick:$e,noOfLines:1,overflow:`hidden`,textOverflow:`ellipsis`,fontSize:`sm`,fontWeight:`medium`,color:g,children:[i(`Balance`),`:`,` `,Number(tt.balance??0).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})]})]}),J(j,{p:4,borderRadius:`2xl`,bg:m,children:Y(B,{align:`stretch`,spacing:2,children:[Y(N,{justify:`space-between`,children:[J(kt,{placeholder:`0`,value:ee,onChange:e=>Qe(e.target.value),fontSize:`4xl`,fontWeight:`bold`,variant:`unstyled`,"data-testid":`swap-amount-input`,type:`number`,inputMode:`decimal`,color:tt&&ee&&Number(ee)>Number(tt.balance)?`red.500`:h}),tt?Y(M,{onClick:()=>T(`select-from-token`),variant:`outline`,size:`sm`,borderRadius:`full`,px:6,color:g,borderColor:g,_hover:{bg:u?`whiteAlpha.300`:`blackAlpha.300`},leftIcon:tt.logoComponent?H.cloneElement(tt.logoComponent,{boxSize:`20px`,borderRadius:`full`}):tt.logoUrl?J(Ot,{src:tt.logoUrl,alt:`${tt.symbol} logo`,boxSize:`20px`,borderRadius:`full`,fallback:J(j,{boxSize:`20px`,borderRadius:`full`,bg:`whiteAlpha.200`,display:`flex`,alignItems:`center`,justifyContent:`center`,children:J(z,{fontSize:`8px`,fontWeight:`bold`,color:h,children:tt.symbol.slice(0,3)})})}):void 0,children:[tt.symbol,J(P,{as:Cr,boxSize:5,color:g})]}):Y(M,{onClick:()=>T(`select-from-token`),variant:`outline`,size:`sm`,borderRadius:`full`,px:6,color:g,borderColor:g,_hover:{bg:u?`whiteAlpha.300`:`blackAlpha.300`,color:_},children:[i(`Select token`),J(P,{as:Cr,boxSize:5,color:g})]})]}),J(N,{spacing:1,fontSize:`sm`,justifyContent:`space-between`,color:g,children:J(N,{spacing:2,alignItems:`center`,children:Y(z,{color:g,children:[`≈`,` `,qs(De??0,{currency:s})]})})})]})}),J(N,{justify:`space-between`,mt:4,children:J(z,{fontSize:`md`,fontWeight:`bold`,color:h,children:i(`To`)})}),J(j,{borderRadius:`2xl`,bg:m,p:4,children:Y(B,{align:`stretch`,spacing:2,width:`100%`,children:[Y(N,{justify:`space-between`,alignItems:`center`,children:[J(kt,{value:Number(Ee).toLocaleString(void 0,{maximumFractionDigits:Number(Ee)>1e4?0:2}),readOnly:!0,variant:`unstyled`,fontSize:`4xl`,fontWeight:`bold`,"data-testid":`swap-output-amount`,color:h}),nt?Y(M,{onClick:()=>T(`select-to-token`),variant:`outline`,size:`sm`,borderRadius:`full`,px:6,color:g,borderColor:g,_hover:{bg:u?`whiteAlpha.300`:`blackAlpha.300`},leftIcon:nt.logoComponent?H.cloneElement(nt.logoComponent,{boxSize:`20px`,borderRadius:`full`}):nt.logoUrl?J(Ot,{src:nt.logoUrl,alt:`${nt.symbol} logo`,boxSize:`20px`,borderRadius:`full`,fallback:J(j,{boxSize:`20px`,borderRadius:`full`,bg:`whiteAlpha.200`,display:`flex`,alignItems:`center`,justifyContent:`center`,children:J(z,{fontSize:`8px`,fontWeight:`bold`,color:h,children:nt.symbol.slice(0,3)})})}):void 0,children:[nt.symbol,J(P,{as:Cr,boxSize:5,color:g})]}):Y(M,{onClick:()=>T(`select-to-token`),variant:`outline`,size:`sm`,borderRadius:`full`,px:6,color:g,borderColor:g,_hover:{bg:u?`whiteAlpha.300`:`blackAlpha.300`,color:_},children:[i(`Select token`),J(P,{as:Cr,boxSize:5,color:g})]})]}),Y(N,{spacing:1,fontSize:`sm`,justifyContent:`space-between`,color:g,children:[J(N,{spacing:2,alignItems:`center`,children:Y(z,{color:g,children:[`≈`,` `,qs(Oe??0,{currency:s})]})}),nt&&Y(z,{noOfLines:1,overflow:`hidden`,textOverflow:`ellipsis`,fontSize:`sm`,fontWeight:`medium`,color:g,children:[i(`Balance`),`:`,` `,Number(nt.balance??0).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})]})]})]})}),J(_t,{in:ne&&!!Te,animateOpacity:!0,children:Y(B,{spacing:1,align:`stretch`,p:4,borderRadius:`2xl`,bg:m,children:[Te&&Y(N,{justify:`space-between`,children:[Y(z,{fontSize:`xs`,color:g,children:[i(`Source`),`:`]}),J(M,{variant:`outline`,size:`xs`,borderRadius:`full`,px:3,h:`auto`,py:1,cursor:`pointer`,onClick:()=>T(`select-quote`),color:g,borderColor:g,_hover:{bg:u?`whiteAlpha.300`:`blackAlpha.300`},leftIcon:Te.aggregator?.getIcon(`12px`),children:J(z,{fontSize:`xs`,color:h,children:Te.aggregatorName})})]}),Y(B,{align:`stretch`,spacing:2,children:[Y(N,{justify:`space-between`,children:[Y(z,{fontSize:`xs`,color:g,children:[i(`Slippage tolerance`),`:`]}),Y(z,{fontSize:`xs`,fontWeight:`medium`,color:h,children:[ie,`%`]})]}),J(B,{spacing:3,align:`stretch`,pt:2,children:Y(N,{spacing:2,children:[J(M,{size:`sm`,variant:`outline`,onClick:()=>{ae(1)},flex:`0 0 auto`,minW:`60px`,borderRadius:`md`,fontSize:`xs`,bg:ve?v:`transparent`,color:ve?b:g,borderColor:ve?v:g,_hover:{bg:ve?v:u?`whiteAlpha.300`:`blackAlpha.300`,opacity:ve?.8:1},children:`Auto`}),J(M,{size:`sm`,variant:`outline`,onClick:()=>{ae(.5)},flex:`0 0 auto`,minW:`60px`,borderRadius:`md`,fontSize:`xs`,bg:ie===.5?v:`transparent`,color:ie===.5?b:g,borderColor:ie===.5?v:g,_hover:{bg:ie===.5?v:u?`whiteAlpha.300`:`blackAlpha.300`,opacity:ie===.5?.8:1},children:`0.5%`}),J(M,{size:`sm`,variant:`outline`,onClick:()=>{ae(3)},flex:`0 0 auto`,minW:`60px`,borderRadius:`md`,fontSize:`xs`,bg:ie===3?v:`transparent`,color:ie===3?b:g,borderColor:ie===3?v:g,_hover:{bg:ie===3?v:u?`whiteAlpha.300`:`blackAlpha.300`,opacity:ie===3?.8:1},children:`3%`}),Y(At,{size:`sm`,flex:1,children:[J(kt,{value:oe,onChange:e=>{let t=e.target.value;if(/^\d*\.?\d*$/.test(t)||t===``)if(se(t),t!==``){let e=parseFloat(t);!isNaN(e)&&e>=0&&e<=100&&ae(e)}else ae(1)},placeholder:`1`,borderRadius:`md`,textAlign:`right`,pr:8,fontSize:`xs`,color:h}),J(Mt,{width:`2rem`,pointerEvents:`none`,children:J(z,{fontSize:`2xs`,color:g,children:`%`})})]})]})})]}),Y(N,{justify:`space-between`,children:[Y(z,{fontSize:`xs`,color:g,children:[i(`Fee`),`:`]}),J(z,{fontSize:`xs`,fontWeight:`medium`,color:h,children:Ae>0?`${Ae.toLocaleString(void 0,{maximumFractionDigits:2})} VTHO`:`-`})]})]})}),Te&&J(j,{minH:`24px`,display:`flex`,alignItems:`center`,justifyContent:`center`,children:J(M,{variant:`ghost`,size:`xs`,onClick:()=>re(!ne),rightIcon:J(P,{color:_,_hover:{color:g},as:ne?gr:fr}),fontSize:`xs`,fontWeight:`light`,color:_,_hover:{color:g},children:i(ne?`Hide`:`Show Advanced Options`)})}),me.length>0&&o.isConnectedWithPrivy&&J(Nm,{estimation:Me,isLoading:Ne,isLoadingTransaction:Ve,onTokenChange:Re,clauses:me,userSelectedToken:fe})]})}),J(L,{children:J(Am,{buttonText:i(xe?`Loading quote...`:`Swap`),onConfirm:Be,isSubmitting:Ve,isTxWaitingConfirmation:He,transactionPendingText:i(`Swapping...`),txReceipt:Ue,transactionError:Ge,onError:e=>{qe(e)},isDisabled:!E||!k||!ee||Number(ee)<=0||xe||!Te||Te?.reverted===!0||!!(tt&&ee&&Number(ee)>Number(tt.balance))||Le,gasEstimationError:Pe,hasEnoughGasBalance:ze,isLoadingGasEstimation:Ne,showGasEstimationError:!l?.delegatorUrl&&o.isConnectedWithPrivy,context:`transaction`})})]})},Bl=({setCurrentContent:e,onBack:t=()=>e(`settings`),initialContentSource:n=`settings`})=>{let{t:r}=X(),{isolatedView:i}=Ml(),a=V(`colors`,`vechain-kit-text-primary`),o=V(`colors`,`vechain-kit-text-secondary`),s=()=>{t()};return Y(q,{children:[Y(Z,{children:[J(R,{"data-testid":`modal-title`,children:r(`Choose your account name`)}),!i&&J(Oo,{onClick:s}),J(I,{})]}),J(F,{children:Y(B,{spacing:6,align:`center`,py:8,children:[J(P,{as:ri,boxSize:16,color:o}),Y(B,{spacing:2,children:[J(z,{fontSize:`lg`,fontWeight:`500`,textAlign:`center`,color:a,children:r(`Finally say goodbye to 0x addresses`)}),J(z,{fontSize:`md`,color:o,textAlign:`center`,px:4,children:r(`Name your account to make it easier to exchange assets`)})]})]})}),J(L,{children:J(M,{variant:`vechainKitPrimary`,onClick:()=>e({type:`choose-name-search`,props:{name:``,setCurrentContent:e,initialContentSource:n}}),"data-testid":`choose-name-button`,children:r(`Choose name`)})})]})},Vl=({domain:e,isCurrentDomain:t,onSelect:n})=>{let{connection:i}=Q(),{t:a}=X(),o=kc(e.name,i.network),s=V(`colors`,`vechain-kit-card`),c=V(`colors`,`vechain-kit-card-hover`),u=V(`colors`,`vechain-kit-border`),d=V(`colors`,`vechain-kit-text-primary`),f=V(`colors`,`vechain-kit-text-secondary`),p=V(`colors`,`vechain-kit-card`);return J(Ft,{p:4,bg:s,borderRadius:`xl`,cursor:t?`default`:`pointer`,opacity:t?.7:1,border:`1px solid ${u}`,_hover:{bg:t?c:s,borderColor:u},onClick:()=>!t&&n(e.name),transition:`all 0.2s`,children:Y(N,{spacing:3,align:`center`,children:[J(km,{props:{width:`40px`,height:`40px`,src:o.image??l(e.name),alt:e.name}}),Y(B,{align:`start`,spacing:0,flex:1,children:[J(z,{color:d,fontSize:`md`,fontWeight:`500`,children:r(e.name,24,0)}),t&&J(z,{fontSize:`sm`,color:f,children:a(`Current domain`)})]}),t&&J(Zt,{size:`sm`,bg:p,color:d,px:3,py:1,borderRadius:`full`,children:a(`Current`)})]})},e.name)},Hl=({onUnset:e})=>{let t=V(`colors`,`vechain-kit-card`),n=V(`colors`,`vechain-kit-card-hover`),r=V(`colors`,`vechain-kit-border`),i=V(`colors`,`vechain-kit-text-primary`),a=V(`colors`,`vechain-kit-text-secondary`),o=V(`colors`,`vechain-kit-error`),{t:s}=X();return J(Ft,{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:Y(N,{spacing:3,align:`center`,children:[J(j,{width:`40px`,height:`40px`,borderRadius:`full`,display:`flex`,alignItems:`center`,justifyContent:`center`,bg:t,children:J(P,{as:ii,fontSize:`18px`,color:o})}),Y(B,{align:`start`,spacing:0,flex:1,children:[J(z,{color:i,fontSize:`md`,fontWeight:`500`,children:s(`Unset current domain`)}),J(z,{fontSize:`sm`,color:a,children:s(`Remove your current domain name`)})]})]})},`unset-domain-list-item`)},Ul=({domains:e,onDomainSelect:t,onUnsetDomain:n,isLoading:r})=>{let{t:i}=X(),{account:a}=Q(),o=V(`colors`,`vechain-kit-card`),s=V(`colors`,`vechain-kit-card-hover`),c=V(`colors`,`vechain-kit-text-primary`),l=V(`colors`,`vechain-kit-text-secondary`);return e.length===0||r?null:J(et,{allowToggle:!0,children:J(nt,{border:`none`,children:({isExpanded:u})=>Y(q,{children:[Y(tt,{bg:o,borderRadius:`xl`,_hover:{bg:s},opacity:r?.7:1,transition:`all 0.2s`,disabled:r,children:[J(j,{flex:`1`,textAlign:`left`,py:2,children:J(z,{fontWeight:`500`,color:c,children:r?i(`Loading your domains...`):`${i(`Your existing domains`)} (${e.length})`})}),J(P,{as:u?Er:Cr,fontSize:`20px`,color:l})]}),J(rt,{pb:4,pt:2,children:Y(Pt,{spacing:2,children:[e.map(e=>J(Vl,{domain:e,isCurrentDomain:e.name===a?.domain,onSelect:t},e.name)),a?.domain&&J(Hl,{onUnset:n})]})})]})})})},Wl=({name:e,setCurrentContent:t,initialContentSource:n=`settings`})=>{let{t:r}=X(),{account:i}=Q(),{darkMode:a}=$(),{isolatedView:o}=Ml(),[s,c]=K(ia(e)),[l,u]=K(null),[d,f]=K(!1),[p,m]=K(!1),[h,g]=K(!1),_=V(`colors`,`vechain-kit-error`),v=V(`colors`,`vechain-kit-success`),y=V(`colors`,`vechain-kit-text-secondary`),{data:b,isLoading:x}=Yo(s),{data:S,isLoading:C}=Ko(`${s}.veworld.vet`),{data:w,isLoading:T}=ls(s),{data:E,isLoading:D}=ms(i?.address,``),O=x||C||T;W(()=>{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,O]);let k=()=>{p&&!l&&t({type:`choose-name-summary`,props:{fullDomain:s+`.veworld.vet`,isOwnDomain:d,setCurrentContent:t,initialContentSource:n}})},A=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}})},ee=()=>{t({type:`choose-name-summary`,props:{fullDomain:``,domainType:``,isOwnDomain:!1,isUnsetting:!0,setCurrentContent:t,initialContentSource:n}})},te=()=>{t(n)};return Y(q,{children:[Y(Z,{children:[J(R,{"data-testid":`modal-title`,children:r(`Choose Name`)}),!o&&J(Oo,{onClick:te}),J(I,{})]}),J(F,{children:Y(B,{spacing:4,align:`stretch`,children:[J(Ul,{domains:E?.domains||[],onDomainSelect:A,onUnsetDomain:ee,isLoading:D}),Y(At,{size:`lg`,children:[J(kt,{placeholder:r(`Enter your name`),value:s,onChange:e=>{c(ia(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`}),J(Mt,{width:`auto`,paddingRight:`12px`,h:`full`,children:J(j,{mr:4,fontSize:`sm`,color:y,children:`.veworld.vet`})})]}),l&&h&&J(z,{color:_,fontSize:`sm`,"data-testid":`domain-availability-status`,children:l}),!l&&h&&s.length>=3&&J(z,{fontSize:`sm`,color:p?v:_,fontWeight:`500`,"data-testid":`domain-availability-status`,children:r(d?`YOU OWN THIS`:p?`AVAILABLE`:`UNAVAILABLE`)})]})}),J(L,{children:J(M,{variant:`vechainKitPrimary`,isDisabled:!p||!!l||w||O,isLoading:O,onClick:k,loadingText:r(`Checking...`),"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}=X(),s=V(`colors`,`vechain-kit-text-primary`),{isolatedView:c,closeAccountModal:l}=Ml(),{account:u,connectedWallet:d,connection:f}=Q(),{data:p}=Np(u?.address??``,d?.address??``,3),{open:m}=kf(),{preferences:h}=Sm(),{feeDelegation:g}=$(),_=e=>{console.error(`Transaction failed:`,e)},v=Rs({onSuccess:()=>O()}),y=n.endsWith(`veworld.vet`),b=ts({subdomain:t.split(`.veworld.vet`)[0],domain:n,alreadyOwned:r,onSuccess:()=>O()}),x=as({domain:!i&&!y?t:``,alreadyOwned:r,onSuccess:()=>O()}),{sendTransaction:S,txReceipt:C,error:w,isWaitingForWalletConfirmation:T,isTransactionPending:E,clauses:D}=i?v:y?b:x,O=()=>{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)}}})},k=async()=>{if(p){m();return}try{await S()}catch(e){console.error(`Transaction failed:`,e)}},A=()=>{k()},ee=()=>{e({type:`choose-name-search`,props:{setCurrentContent:e,name:t,initialContentSource:a}})},[te,ne]=H.useState(null),[re,ie]=H.useState(null),ae=h.availableGasTokens.length>0&&(f.isConnectedWithPrivy||f.isConnectedWithVeChain)&&!g?.delegatorUrl,{data:oe,isLoading:se,error:ce,refetch:le}=Cm({clauses:D(),tokens:te?[te]:h.availableGasTokens,enabled:ae&&!!g?.genericDelegatorUrl}),ue=oe?.usedToken,de=(se||!oe)&&f.isConnectedWithPrivy&&!g?.delegatorUrl,fe=H.useCallback(e=>{ne(e),ie(e),setTimeout(()=>le(),100)},[le]),pe=!!ue&&!ce;return H.useEffect(()=>{ce&&te&&ne(null)},[ce,te]),Y(q,{children:[Y(Z,{children:[J(R,{"data-testid":`confirm-domain`,children:o(i?`Confirm Unset Domain`:`Confirm Name`)}),J(Oo,{onClick:ee,isDisabled:E}),J(I,{isDisabled:E})]}),Y(F,{children:[Y(B,{spacing:6,align:`center`,mt:10,children:[J(P,{as:ri,color:s,fontSize:`60px`,opacity:.5}),J(z,{fontSize:`md`,textAlign:`center`,color:s,children:i?o(`By confirming, your current domain will be unset`):o(`By confirming, your address will be set to {{domain}}`,{domain:t})})]}),!i&&J(B,{spacing:4,align:`stretch`,mt:6,children:J(z,{fontSize:`xl`,fontWeight:`bold`,color:s,textAlign:`center`,"data-testid":`preconfirm-domain-val`,children:t})}),f.isConnectedWithPrivy&&J(Nm,{estimation:oe,isLoading:se,isLoadingTransaction:E,onTokenChange:fe,clauses:D(),userSelectedToken:re})]}),J(L,{gap:4,w:`full`,children:J(Am,{transactionError:w,isSubmitting:E,isTxWaitingConfirmation:T,onConfirm:k,onRetry:A,transactionPendingText:o(i?`Unsetting current domain...`:`Claiming name...`),txReceipt:C,buttonText:o(`Confirm`),isDisabled:E||de,onError:_,gasEstimationError:ce,hasEnoughGasBalance:pe,isLoadingGasEstimation:se,showGasEstimationError:!g?.delegatorUrl&&f.isConnectedWithPrivy,context:`domain`})})]})},Kl=()=>{let{t:e}=X(),[t,n]=K(``),r=V(`colors`,`vechain-kit-card`),i=V(`colors`,`vechain-kit-text-secondary`),a=V(`colors`,`vechain-kit-text-tertiary`),o=V(`colors`,`vechain-kit-card`),s=V(`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 Y(B,{spacing:4,align:`stretch`,children:[Y(At,{size:`lg`,children:[J(kt,{placeholder:e(`Search FAQ`),bg:r,borderRadius:`xl`,height:`56px`,pl:12,value:t,onChange:e=>n(e.target.value)}),J(jt,{h:`56px`,w:`56px`,pl:4,children:J(Qr,{color:a})})]}),c.length===0?Y(B,{spacing:2,py:8,color:i,children:[J(P,{as:ni,boxSize:12,opacity:.5}),J(z,{fontSize:`lg`,children:e(`No questions found`)}),J(z,{fontSize:`md`,children:e(`Try searching with a different term`)})]}):J(et,{allowMultiple:!0,children:c.map((e,t)=>J(nt,{border:`none`,mb:2,children:({isExpanded:t})=>Y(q,{children:[Y(tt,{bg:o,borderRadius:`xl`,color:i,_hover:{bg:s},children:[J(j,{flex:`1`,textAlign:`left`,py:2,children:J(z,{fontWeight:`500`,color:i,children:e.question})}),J(P,{as:t?Er:Cr,fontSize:`20px`,opacity:.5})]}),J(rt,{pb:4,children:J(z,{fontSize:`sm`,color:i,opacity:.8,children:e.answer})})]})},t))})]})},ql=({onGoBack:e,showLanguageSelector:t=!0})=>{let{i18n:n,t:r}=X(),{isolatedView:i}=Ml(),a=V(`colors`,`vechain-kit-card`),o=V(`colors`,`vechain-kit-border`),s=V(`colors`,`vechain-kit-border-hover`);return Y(Om,{children:[Y(Z,{children:[J(R,{children:r(`Help`)}),!i&&J(Oo,{onClick:e}),J(I,{})]}),J(F,{w:`full`,children:Y(B,{spacing:6,align:`stretch`,children:[t&&J(Kt,{borderRadius:`md`,size:`sm`,width:`auto`,value:n.language,onChange:e=>{n.changeLanguage(e.target.value)},bg:a,borderColor:o,_hover:{borderColor:s},children:Za.map(e=>J(`option`,{value:e,children:$a[e]},e))}),J(M,{as:Nt,href:me,isExternal:!0,variant:`vechainKitSecondary`,rightIcon:J(P,{as:Pr}),children:r(`For developers`)}),J(Kl,{})]})}),J(L,{pt:0})]})},Jl=({leftIcon:e,rightIcon:t,title:n,wallet:i,onClick:a,leftImage:o,isActive:s=!1})=>{let{t:c}=X(),{darkMode:l}=$();return J(M,{w:`full`,minH:`70px`,h:`fit-content`,py:4,onClick:a,backgroundColor:`transparent`,border:`1px solid ${l?`#ffffff29`:`#ebebeb`}`,children:Y(N,{w:`full`,justify:`space-between`,children:[J(j,{minW:`40px`,justifyContent:`center`,children:o?J(Ot,{justifySelf:`center`,src:o,w:`28px`,alt:`left-image`}):J(P,{as:e,fontSize:`28px`})}),Y(B,{textAlign:`left`,w:`full`,flex:1,children:[J(N,{w:`full`,spacing:2,justifyContent:`flex-start`,children:J(z,{fontSize:`sm`,fontWeight:`400`,children:n})}),J(z,{fontSize:`sm`,fontWeight:`500`,opacity:.5,overflowWrap:`break-word`,wordBreak:`break-word`,whiteSpace:`normal`,w:`full`,children:i?.domain?r(i?.domain??``,18,0):d(i?.address??``,6,4)})]}),J(B,{minW:`40px`,justifyContent:`flex-end`,children:Y(N,{justifyContent:`flex-end`,minW:`40px`,children:[s&&J(Zt,{size:`sm`,colorScheme:`green`,children:c(`Active`)}),J(P,{as:t,fontSize:`20px`,opacity:.5})]})})]})})},Yl=({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:_}=X();return J(M,{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:Y(N,{w:`full`,justify:`space-between`,alignItems:`center`,children:[J(j,{minW:`40px`,h:`20px`,children:i?J(Ot,{src:i,w:`30px`,h:`30px`,borderRadius:`full`,alt:`left-image`,alignSelf:`end`,objectFit:`cover`}):J(P,{as:e,fontSize:`20px`,h:`full`,alignContent:`center`})}),J(B,{textAlign:`left`,w:`full`,flex:1,justifyContent:`flex-start`,alignItems:`flex-start`,children:Y(N,{justify:`flex-start`,alignItems:`baseline`,children:[J(z,{fontSize:`sm`,fontWeight:`400`,children:n}),o&&J(Zt,{size:`sm`,colorScheme:`red`,children:_(`Coming Soon!`)}),m]})}),t&&J(B,{minW:`40px`,justifyContent:`flex-end`,children:J(P,{as:t,fontSize:`20px`,opacity:.5})})]})})},Xl=({wallet:e,setCurrentContent:t,size:n=`md`,onClick:i,onClose:a,mt:o,style:s})=>{let{t:c}=X(),{connection:l}=Q(),{switchWallet:u,isSwitching:f,isInAppBrowser:p}=Mc(),{isSwitchWalletEnabled:m}=$n(),[h,g]=K(!1),_=async()=>{await k(e?.domain??e?.address??``)&&(g(!0),setTimeout(()=>{g(!1)},2e3))},v=()=>{p?u():t?.({type:`select-wallet`,props:{setCurrentContent:t,onClose:a,returnTo:`main`,onLogoutSuccess:a}})};return Y(N,{mt:o,w:`full`,...s,justifyContent:`flex-start`,alignItems:`center`,children:[J(M,{w:`full`,h:12,"aria-label":`Wallet`,onClick:i,variant:`vechainKitSecondary`,p:3,"data-testid":`profile-button`,children:Y(N,{spacing:2,align:`center`,justifyContent:`space-between`,w:`full`,children:[Y(N,{spacing:2,justifyContent:`flex-start`,children:[J(km,{wallet:e,props:{width:7,height:7}}),J(z,{fontSize:n,fontWeight:`500`,children:h?c(`Copied!`):r(e?.domain??``,22,0)||d(e?.address??``,6,4)})]}),J(P,{boxSize:5,as:Tr,cursor:`pointer`,opacity:.5})]})}),l.isInAppBrowser&&m||!l.isInAppBrowser&&l.isConnectedWithDappKit?J(Dt,{"aria-label":`Switch wallet`,icon:J(P,{as:mr}),onClick:v,w:`60px`,h:12,variant:`vechainKitSecondary`,p:3,isLoading:f,isDisabled:f,"data-testid":`switch-wallet-button`}):J(Dt,{"aria-label":`Copy address`,icon:J(P,{as:h?Sr:jr}),onClick:_,w:`60px`,h:12,variant:`vechainKitSecondary`,p:3})]})},Zl=({address:t,maxIcons:n=3,iconSize:r=20,ml:i=0,style:a,iconsGap:o=0,rightIcon:s,showNoAssetsWarning:c=!1,onClick:l})=>{let{t:u}=X(),{tokensWithBalance:d}=Xs({address:t}),{darkMode:f}=$(),p=V(`colors`,`vechain-kit-text-secondary`),m=o<1?`-${r/2}px`:`${o}px`,h=d.slice(0,n),g=d.length-n;return!t||d.length===0&&!c?null:Y(N,{spacing:0,ml:i,...a,onClick:l,children:[Y(N,{spacing:0,children:[h.map((t,n)=>J(gt,{ml:n>0?m:`0`,zIndex:n,size:`${r}px`,borderRadius:`full`,bg:f?`gray.100`:`gray.600`,border:`2px solid #00000024`,alignItems:`center`,justifyContent:`center`,children:S[t.symbol]?H.cloneElement(S[t.symbol],{width:`${r*.8}px`,height:`${r*.8}px`,rounded:`full`}):e[t.symbol]?J(Ot,{src:e[t.symbol],alt:`${t.symbol} logo`,width:`${r*.8}px`,height:`${r*.8}px`,rounded:`full`}):J(z,{fontSize:`${r*.4}px`,fontWeight:`bold`,color:f?`black`:`white`,children:t.symbol.slice(0,3)})},t.symbol)),g>0&&J(gt,{ml:m,zIndex:h.length,size:`${r}px`,borderRadius:`full`,bg:f?`gray.100`:`gray.700`,display:`flex`,alignItems:`center`,justifyContent:`center`,border:`2px solid`,children:Y(z,{fontSize:`${r*.4}px`,fontWeight:`bold`,color:f?`black`:`white`,children:[`+`,g]})}),d.length===0&&c&&J(z,{fontSize:`sm`,color:p,fontWeight:`700`,children:u(`No assets`)})]}),s]})},Ql=({mb:e,mt:t,onAssetsClick:n})=>{let{t:r}=X(),{account:i}=Q(),{formattedBalance:a,isLoading:o}=Zs({address:i?.address??``}),{refresh:s}=jc(),[c,l]=K(!1),u=V(`colors`,`vechain-kit-text-secondary`),d=async()=>{l(!0),await s(),setTimeout(()=>{l(!1)},1500)},[f,p]=dm(um.SHOW_ASSETS,!0);return Y(B,{w:`full`,justifyContent:`start`,spacing:1,mt:t,mb:e,children:[Y(N,{w:`full`,justifyContent:`space-between`,alignItems:`center`,spacing:0,role:`group`,children:[J(Et,{size:`xs`,fontWeight:`800`,color:u,textTransform:`uppercase`,letterSpacing:1.2,ml:`5px`,children:r(`Assets`)}),Y(N,{spacing:0,alignItems:`center`,children:[J(Dt,{"aria-label":`Refresh balances`,variant:`ghost`,size:`sm`,opacity:.5,_hover:{opacity:.8},onClick:d,icon:J(P,{as:Zr,boxSize:4}),isLoading:o||c,sx:{"& > span.chakra-button__spinner":{width:`16px`,height:`16px`,position:`absolute`}}}),J(Dt,{"aria-label":`Show/hide assets`,variant:`ghost`,size:`sm`,opacity:.5,_hover:{opacity:.8},onClick:()=>p(!f),icon:J(P,{as:f?oa:sa,boxSize:4})})]})]}),J(M,{onClick:n,h:`fit-content`,variant:`vechainKitSecondary`,children:Y(B,{spacing:2,w:`full`,justifyContent:`flex-start`,alignItems:`flex-start`,mt:4,mb:4,children:[J(Et,{size:`2xl`,fontWeight:`700`,children:f?a:`$****`}),J(N,{w:`full`,justifyContent:`flex-start`,"data-testid":`all-assets-button`,mt:2,children:J(Zl,{style:{width:`100%`,justifyContent:`space-between`},maxIcons:10,iconSize:26,iconsGap:3,address:i?.address??``,showNoAssetsWarning:!0,rightIcon:J(P,{as:Tr,boxSize:5,opacity:.5,marginLeft:2})})})]})})]})},$l=[{icon:_r,label:`Send`,onClick:e=>e({type:`send-token`,props:{setCurrentContent:e}}),isDisabled:e=>!e},{icon:mr,label:`Swap`,onClick:e=>{e(`swap-token`)},isDisabled:e=>!e},{icon:pr,label:`Receive`,onClick:e=>{e(`receive-token`)}}],eu=({icon:e,label:t,onClick:n,isDisabled:r,showRedDot:i})=>{let{t:a}=X();return J(Dt,{variant:`vechainKitSecondary`,h:`80px`,w:`full`,"aria-label":t,isDisabled:r,p:3,icon:Y(B,{spacing:4,children:[J(P,{as:e,boxSize:5,opacity:.9}),Y(N,{p:0,alignItems:`baseline`,spacing:1,children:[J(z,{fontSize:`sm`,fontWeight:`600`,"data-testid":`${t.toLowerCase()}-button-label`,children:a(t,t)}),i&&J(j,{minWidth:`8px`,height:`8px`,bg:`red.500`,borderRadius:`full`,display:`flex`,alignItems:`center`,justifyContent:`center`})]})]}),onClick:n})},tu=({mt:e,setCurrentContent:t})=>{let{account:n,smartAccount:r,connectedWallet:i,connection:a}=Q(),{hasAnyBalance:o}=Zs({address:n?.address??``}),{data:s}=Np(r?.address??``,i?.address??``,3),c=a.isConnectedWithPrivy&&s;return J(wt,{templateColumns:`repeat(3, 1fr)`,gap:2,w:`full`,mt:e,children:$l.map(e=>J(eu,{icon:e.icon,label:e.label,onClick:()=>e.onClick(t),isDisabled:e.isDisabled?.(o),showRedDot:c&&e.label===`Settings`},e.label))})},nu=({setCurrentContent:e})=>{let{t}=X(),n=V(`colors`,`vechain-kit-text-primary`),r=V(`colors`,`vechain-kit-text-secondary`);return J(lt,{w:`full`,variant:`featureAnnouncement`,overflow:`hidden`,onClick:()=>{e({type:`choose-name`,props:{setCurrentContent:e,onBack:()=>e(`profile`),initialContentSource:`profile`}})},cursor:`pointer`,_hover:{opacity:.8},children:J(ut,{p:4,children:J(N,{justify:`space-between`,align:`flex-start`,spacing:3,children:Y(B,{align:`flex-start`,spacing:1,children:[Y(N,{spacing:2,children:[J(z,{fontSize:`sm`,fontWeight:`400`,color:n,children:t(`Claim your vet domain!`)}),J(Zt,{size:`sm`,colorScheme:`red`,children:t(`New`)})]}),J(z,{fontSize:`xs`,color:r,children:t(`Say goodbye to 0x addresses, claim your .veworld.vet subdomain now for free!`)})]})})})})},ru=()=>{let{t:e}=X();return J(it,{status:`warning`,fontSize:`xs`,borderRadius:`xl`,p:2,children:J(B,{spacing:1,align:`stretch`,w:`full`,children:Y(N,{spacing:2,align:`flex-start`,children:[J(ot,{boxSize:4,mt:`10px`}),J(z,{w:`full`,children:e(`Sending to OceanX or other exchanges may result in loss of funds.`)})]})})})},iu=()=>{let{t:e}=X();return J(it,{status:`warning`,fontSize:`xs`,borderRadius:`xl`,p:2,children:J(B,{spacing:1,align:`stretch`,w:`full`,children:Y(N,{spacing:2,align:`flex-start`,children:[J(ot,{boxSize:4,mt:`10px`}),J(z,{w:`full`,children:e(`A .vet domain is required to customize your profile. Choose an account name to get started.`)})]})})})},au=()=>{let{t:e}=X(),{getConnectionCache:t}=Bf(),n=t();return Y(lt,{variant:`vechainKitBase`,w:`full`,children:[Y(ft,{p:4,pl:6,borderBottomWidth:`1px`,children:[J(z,{fontWeight:`medium`,opacity:.8,children:e(`Security preferences`)}),J(z,{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`})})]}),J(ut,{borderRadius:`none`,children:Y(B,{spacing:3,align:`stretch`,children:[Y(N,{spacing:3,align:`center`,children:[J(pt,{w:`fit-content`,h:`fit-content`,p:2,borderRadius:`full`,bg:`blackAlpha.100`,flexShrink:0,children:J(P,{as:oi})}),Y(j,{flex:1,children:[J(z,{fontSize:`sm`,fontWeight:`medium`,lineHeight:`shorter`,children:e(`Login methods`)}),J(z,{fontSize:`xs`,opacity:.7,lineHeight:`shorter`,children:e(`Manage your login methods and passkeys`)})]})]}),Y(N,{spacing:3,align:`center`,children:[J(pt,{w:`fit-content`,h:`fit-content`,p:2,borderRadius:`full`,bg:`blackAlpha.100`,flexShrink:0,children:J(P,{as:ti})}),Y(j,{flex:1,children:[J(z,{fontSize:`sm`,fontWeight:`medium`,lineHeight:`shorter`,children:e(`Security settings`)}),J(z,{fontSize:`xs`,opacity:.7,lineHeight:`shorter`,children:e(`Backup your wallet, configure MFA and set recovery options`)})]})]})]})}),J(dt,{children:Y(M,{variant:`vechainKitSecondary`,w:`full`,onClick:()=>{window.open(n?.ecosystemApp.website??Qe,`_blank`)},children:[e(`Manage on {{appName}}`,{appName:n?.ecosystemApp.name??`origin app`}),J(P,{as:Pr,ml:2})]})})]})},ou=({setCurrentContent:e,initialContentSource:t=`profile`})=>{let{t:r}=X(),{network:i}=$(),{account:a}=Q(),o=V(`colors`,`vechain-kit-text-primary`),s=V(`colors`,`vechain-kit-error`),c=V(`colors`,`vechain-kit-card`),l=vn(null),u=vn(null),[d,f]=K(!1),{onUpload:p}=Jc({compressImage:!0}),[m,h]=K(null),[g,_]=K(null),v=!!a?.domain,[y,b]=K(null),[x,S]=K(``),[C,w]=K(``),{register:T,watch:E,formState:{errors:D,isValid:O}}=ra({defaultValues:{displayName:a?.metadata?.display||``,description:a?.metadata?.description||``},mode:`onChange`});W(()=>{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 k=E(),A=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 n(e.file,t.name,i.type))}catch(e){console.error(`Error uploading image:`,e),h(null)}finally{f(!1)}};W(()=>()=>{m&&URL.revokeObjectURL(m)},[m]);let ee=()=>{let e={};return g!==y&&g&&(e.avatarIpfsHash=g),k.displayName!==x&&(e.displayName=k.displayName),k.description!==C&&(e.description=k.description),e},te=G(()=>{let e=ee();return Object.keys(e).length>0},[ee]),ne=()=>{e({type:`account-customization-summary`,props:{setCurrentContent:e,changes:ee(),onDoneRedirectContent:t}})},re=()=>{e(t)};return Y(q,{children:[Y(Z,{children:[J(R,{"data-testid":`modal-title`,children:r(`Customization`)}),J(Oo,{onClick:re}),J(I,{})]}),Y(F,{children:[Y(j,{cursor:v?`pointer`:`default`,pt:2,display:`flex`,justifyContent:`center`,position:`relative`,onClick:()=>v&&l.current?.click(),children:[J(km,{wallet:a,props:{width:`100px`,height:`100px`,boxShadow:`0px 0px 3px 2px #00000024`,src:m??void 0}}),v&&J(P,{as:xr,position:`absolute`,top:`80px`,left:`60%`,bg:c,color:o,p:`1`,borderRadius:`full`,boxSize:`6`}),d&&J(j,{display:`flex`,alignItems:`center`,justifyContent:`center`,backgroundColor:`rgba(0, 0, 0, 0.5)`,position:`absolute`,transform:`translateX(0%)`,width:`100px`,height:`100px`,borderRadius:`full`,zIndex:10,children:J(z,{fontSize:`xs`,color:`white`,children:d?`Uploading...`:`Processing...`})})]}),Y(B,{spacing:6,mt:4,children:[!v&&J(iu,{}),J(Yl,{title:a?.domain??r(`Choose account name`),description:r(`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:ri,rightIcon:Tr,dataTestId:`set-domain-name-button`}),Y(St,{isDisabled:!v,isInvalid:!!D.displayName,children:[J(Ct,{fontSize:`sm`,fontWeight:`medium`,color:o,children:r(`Display Name`)}),J(kt,{...T(`displayName`,{maxLength:{value:25,message:r(`Display name must be less than 25 characters`)}}),placeholder:r(v?`Enter your display name`:`Set a domain first`),fontWeight:`medium`,color:o,"data-testid":`display-name-input`}),D.displayName&&J(z,{color:s,fontSize:`sm`,mt:1,fontWeight:`medium`,children:D.displayName.message})]}),Y(St,{isDisabled:!v,isInvalid:!!D.description,children:[J(Ct,{fontSize:`sm`,fontWeight:`medium`,color:o,children:r(`Description`)}),J(Qt,{...T(`description`,{maxLength:{value:100,message:r(`Description must be less than 100 characters`)}}),placeholder:r(`Eg: DevRel @ ENS Labs`),fontWeight:`medium`,color:o,"data-testid":`description-input`,minH:`50px`}),D.description&&J(z,{color:s,mt:1,fontSize:`sm`,fontWeight:`medium`,children:D.description.message})]})]}),J(`input`,{type:`file`,ref:l,hidden:!0,accept:`image/*`,onChange:async e=>await A(e)}),J(`input`,{type:`file`,ref:u,hidden:!0,accept:`image/*`,onChange:async e=>{e.preventDefault()}})]}),J(L,{w:`full`,children:J(M,{variant:`vechainKitPrimary`,onClick:ne,isDisabled:!v||!te||!O,isLoading:d,loadingText:r(`Preparing changes...`),"data-testid":`save-changes-button`,children:r(`Save Changes`)})})]})},su=({setCurrentContent:e,changes:t,onDoneRedirectContent:n})=>{let{t:r}=X(),{darkMode:i,network:a,feeDelegation:o}=$(),s=V(`colors`,`vechain-kit-text-primary`),{account:c,connectedWallet:l,connection:u}=Q(),{preferences:d}=Sm(),{data:f}=Np(c?.address??``,l?.address??``,3),{open:p}=kf(),{handleSubmit:m}=ra({defaultValues:{...t,avatarIpfsHash:t.avatarIpfsHash??void 0}}),h=c?.domain??``,{data:g}=Ts(h),_=sr(),{sendTransaction:v,txReceipt:y,error:b,isWaitingForWalletConfirmation:x,isTransactionPending:S,clauses:w}=Cs({resolverAddress:g,signerAccountAddress:c?.address??``,onSuccess:async()=>{try{await he()}catch(e){console.error(`Error refreshing data:`,e)}},onError:e=>{console.error(`Error updating text record:`,e)}}),[T,E]=H.useState(!1);H.useEffect(()=>{if(!y||y.reverted||T||S)return;let t=y.meta.txID;t&&(E(!0),e({type:`successful-operation`,props:{setCurrentContent:e,txId:t,title:r(`Profile Updated`),description:r(`Your changes have been saved successfully.`),onDone:()=>{e(n)}}}))},[y,T,S,e,r,n]),H.useEffect(()=>{S&&E(!1)},[S]);let D=G(()=>{let e=c?.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,c?.domain]),O=G(()=>{try{return!g||D.length===0||!w?[]:w(D)}catch(e){return console.error(`Error building clauses:`,e),[]}},[D,w,g]),[k,A]=H.useState(null),[ee,te]=H.useState(null),ne=d.availableGasTokens.length>0&&(u.isConnectedWithPrivy||u.isConnectedWithVeChain)&&!o?.delegatorUrl,{data:re,isLoading:ie,error:ae,refetch:oe}=Cm({clauses:O,tokens:k?[k]:d.availableGasTokens,enabled:ne&&!!o?.genericDelegatorUrl}),se=re?.usedToken,ce=(ie||!re)&&u.isConnectedWithPrivy&&!o?.delegatorUrl,le=H.useCallback(e=>{A(e),te(e),setTimeout(()=>oe(),100)},[oe]),ue=!!se&&!ae;H.useEffect(()=>{ae&&k&&A(null)},[ae,k]);let de=async()=>{if(f){p();return}try{D.length>0&&await v(D)}catch(e){console.error(`Error saving changes:`,e)}},fe=(e,t)=>t?.trim()?Y(B,{align:`flex-start`,w:`full`,spacing:1,children:[J(z,{fontSize:`sm`,color:i?`whiteAlpha.600`:`blackAlpha.600`,children:e}),J(z,{fontSize:`md`,children:t})]}):null,pe=()=>{m(de)()},me=()=>{e({type:`account-customization`,props:{setCurrentContent:e}})},he=async()=>{t.avatarIpfsHash&&(_.setQueryData(hs(h,a.type),C(`ipfs://`+t.avatarIpfsHash,a.type)),_.setQueryData(Os(c?.address??``),C(`ipfs://`+t.avatarIpfsHash,a.type))),await _.invalidateQueries({queryKey:ys(h,a.type)}),await _.refetchQueries({queryKey:ys(h,a.type)})};return Y(q,{children:[Y(Z,{children:[J(R,{children:r(`Confirm Changes`)}),J(Oo,{isDisabled:S,onClick:me}),J(I,{isDisabled:S})]}),Y(F,{children:[Y(B,{spacing:6,align:`center`,mt:10,children:[J(P,{as:Fr,color:s,fontSize:`60px`,opacity:.5}),J(z,{fontSize:`md`,textAlign:`center`,color:s,children:r(`By confirming, the following details attached to your name ({{domain}}) will be updated`,{domain:h})})]}),Y(B,{spacing:4,align:`stretch`,mt:6,children:[t.avatarIpfsHash&&Y(B,{align:`flex-start`,w:`full`,spacing:1,children:[J(z,{fontSize:`sm`,color:i?`whiteAlpha.600`:`blackAlpha.600`,children:r(`Profile Image`)}),J(z,{fontSize:`md`,children:r(`New image selected`)})]}),t.displayName&&fe(r(`Display Name`),t.displayName),t.description&&fe(r(`Description`),t.description),t.twitter&&fe(r(`Twitter`),t.twitter),t.website&&fe(r(`Website`),t.website),t.email&&fe(r(`Email`),t.email)]}),u.isConnectedWithPrivy&&J(Nm,{estimation:re,isLoading:ie,isLoadingTransaction:S,onTokenChange:le,clauses:O,userSelectedToken:ee})]}),J(L,{gap:4,w:`full`,children:J(Am,{transactionError:b,isSubmitting:S,isTxWaitingConfirmation:x,onConfirm:m(de),onRetry:pe,transactionPendingText:r(`Saving changes...`),txReceipt:y,buttonText:r(`Confirm`),isDisabled:S||ce,gasEstimationError:ae,hasEnoughGasBalance:ue,isLoadingGasEstimation:ie,showGasEstimationError:!o?.delegatorUrl&&u.isConnectedWithPrivy,context:`customization`})})]})},cu=({address:e,showHeader:t=!0,showLinks:n=!0,showDescription:r=!0,showDisplayName:i=!0,reserveNameDescriptionSpace:a=!1,setCurrentContent:o,onLogout:s})=>{let{network:c}=$(),u=V(`colors`,`vechain-kit-text-primary`),d=V(`colors`,`vechain-kit-text-secondary`),f=V(`colors`,`vechain-kit-card`),p=kc(e,c.type),m=l(e),h=p?.records?.url||p?.records?.[`com.x`]||p?.records?.email,g=e=>{try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`?t.toString():null}catch{return null}};return Y(B,{spacing:0,w:`full`,children:[J(j,{p:0,backgroundSize:`100% !important`,backgroundPosition:`center`,position:`relative`,background:t?`no-repeat url('${m}')`:`none`,w:`100%`,borderRadius:`14px 14px 0 0`}),Y(j,{position:`relative`,display:`inline-block`,cursor:o?`pointer`:`default`,onClick:o?()=>{o({type:`account-customization`,props:{setCurrentContent:o,initialContentSource:`profile`}})}:void 0,children:[J(km,{wallet:{address:e,domain:p?.domain,image:p?.image,isLoadingMetadata:p?.isLoading,metadata:p?.records},props:{width:`120px`,height:`120px`}}),o&&J(P,{as:Jr,position:`absolute`,bottom:`0`,right:`0`,bg:f,color:u,p:`1`,borderRadius:`full`,boxSize:`6`,border:`2px solid`,borderColor:f})]}),Y(B,{w:`full`,spacing:2,children:[i&&(p?.records?.display?J(z,{fontSize:`xl`,color:u,fontWeight:`bold`,w:`full`,textAlign:`center`,mt:2,"data-testid":`display-name-val`,children:p?.records?.display}):a&&J(j,{mt:2,minH:`28px`,"aria-hidden":!0})),r&&(p?.records?.description?J(z,{fontSize:`sm`,color:d,w:`full`,textAlign:`center`,"data-testid":`description-val`,children:p?.records?.description}):a&&J(j,{minH:`20px`,"aria-hidden":!0})),n&&h&&Y(N,{w:`full`,justify:`center`,spacing:5,mt:4,children:[p?.records?.email&&J(Nt,{href:`mailto:${p?.records?.email}`,target:`_blank`,"data-testid":`mail-link`,children:J(P,{as:Kr,color:u})}),p?.records?.url&&J(Nt,{href:g(p.records.url)??void 0,target:`_blank`,rel:`noopener noreferrer`,"data-testid":`website-link`,children:J(P,{as:Br,color:u})}),p?.records?.[`com.x`]&&J(Nt,{href:`https://x.com/${encodeURIComponent(String(p.records[`com.x`]))}`,target:`_blank`,rel:`noopener noreferrer`,"data-testid":`twitter-link`,children:J(P,{as:la,color:u})})]}),J(ko,{onLogout:s,wallet:{address:e,domain:p?.domain,image:p?.image,isLoadingMetadata:p?.isLoading,metadata:p?.records},style:{mt:4},setCurrentContent:o})]})]})},lu=({onClick:e,...t})=>{let{smartAccount:n,connectedWallet:r,connection:i}=Q(),[a,o]=K(!1);W(()=>{o(!localStorage.getItem(`app-first-visit`))},[]);let{data:s}=Np(n?.address??``,r?.address??``,3),c=i.isConnectedWithPrivy&&s,l=()=>{a&&(localStorage.setItem(`app-first-visit`,`true`),o(!1)),e()};return J(Dt,{"aria-label":`Settings`,size:`sm`,variant:`vechainKitHeaderIconButtons`,position:`absolute`,left:`10px`,top:`8px`,lineHeight:`0`,onClick:l,icon:Y(j,{position:`relative`,children:[J(P,{as:$r,fontSize:`18px`}),c&&J(j,{position:`absolute`,top:`-1px`,right:`-1px`,minWidth:`8px`,height:`8px`,bg:`red.500`,borderRadius:`full`})]}),...t})},uu=({setCurrentContent:e,onLogoutSuccess:t,switchFeedback:n})=>{let{t:r}=X(),{account:i,disconnect:a,connection:o}=Q(),{switchWallet:s,isSwitching:c,isInAppBrowser:l}=Mc(),{isSwitchWalletEnabled:u}=$n(),{hasAnyBalance:d,formattedBalance:f}=Zs({address:i?.address}),[p]=dm(um.SHOW_ASSETS,!0),m=()=>{l?s():e({type:`select-wallet`,props:{setCurrentContent:e,onClose:()=>{},returnTo:`profile`,onLogoutSuccess:t}})};return Y(q,{children:[Y(Z,{children:[J(R,{"data-testid":`modal-title`,children:r(`Profile`)}),J(lu,{onClick:()=>{e(`settings`)},"data-testid":`settings-button`}),J(I,{})]}),J(F,{w:`full`,children:Y(B,{w:`full`,spacing:6,children:[J(Lm,{showFeedback:n?.showFeedback}),!i?.domain&&J(nu,{setCurrentContent:e}),J(cu,{reserveNameDescriptionSpace:!!i?.domain,onEditClick:()=>{e({type:`account-customization`,props:{setCurrentContent:e,initialContentSource:`profile`}})},address:i?.address??``,showHeader:!1,setCurrentContent:e,onLogout:()=>{a(),t?.()}})]})}),J(L,{w:`full`,children:Y(N,{w:`full`,justify:`space-between`,spacing:4,mt:4,children:[J(M,{size:`md`,width:`full`,height:`40px`,variant:`vechainKitSecondary`,leftIcon:d?void 0:J(P,{as:ci}),onClick:()=>e(`main`),"data-testid":`wallet-button`,children:d?Y(N,{spacing:2,w:`full`,justify:`center`,children:[J(Zl,{address:i?.address??``,maxIcons:2}),J(z,{fontWeight:`600`,children:p?f:`$****`})]}):r(`Wallet`)}),o.isInAppBrowser&&u||!o.isInAppBrowser&&o.isConnectedWithDappKit?J(M,{size:`md`,width:`full`,height:`40px`,variant:`vechainKitSecondary`,leftIcon:J(P,{as:mr}),colorScheme:`red`,onClick:async()=>{m()},isLoading:c,isDisabled:c,"data-testid":`switch-wallet-button`,children:r(`Switch`)}):J(M,{size:`md`,width:`full`,height:`40px`,variant:`vechainKitSecondary`,leftIcon:J(P,{as:Gr}),colorScheme:`red`,onClick:()=>e({type:`disconnect-confirm`,props:{onDisconnect:()=>{a(),t?.()},onBack:()=>e?.(`profile`)}}),"data-testid":`logout-button`,children:r(`Logout`)})]})})]})},du=({setCurrentContent:e,handleClose:t,initialContent:n=`settings`})=>{let{t:r}=X(),{smartAccount:i,connectedWallet:a}=Q(),{data:o}=Np(i?.address??``,a?.address??``,3),{sendTransaction:s,isTransactionPending:c,isWaitingForWalletConfirmation:l,error:u,txReceipt:d}=Rp({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 Y(q,{children:[Y(Z,{children:[J(R,{children:r(`Account upgrade required`)}),J(Oo,{onClick:()=>{e(n)}}),J(I,{})]}),J(F,{children:Y(B,{spacing:10,align:`stretch`,children:[J(z,{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.`)}),Y(N,{align:`center`,justifyContent:`space-evenly`,rounded:`md`,children:[Y(j,{position:`relative`,display:`inline-block`,children:[J(gt,{size:`60px`,bg:`gray.200`,children:J(Ot,{borderRadius:`full`,src:i?.image,alt:r(`Profile Picture`),w:`100%`,h:`100%`,objectFit:`cover`})}),J(Et,{position:`absolute`,top:`-5`,right:`-5`,color:`#D23F63`,fontSize:`28px`,children:`v1`})]}),J(P,{as:hr,color:`#3DBA67`}),Y(j,{position:`relative`,display:`inline-block`,children:[J(gt,{size:`60px`,bg:`gray.200`,children:J(Ot,{borderRadius:`full`,src:i?.image,alt:r(`Profile Picture`),w:`100%`,h:`100%`,objectFit:`cover`})}),J(Et,{position:`absolute`,top:`-5`,right:`-5`,color:`#3DBA67`,fontSize:`28px`,children:`v3`})]})]}),Y(it,{status:`info`,borderRadius:`md`,children:[J(ot,{}),Y(j,{children:[J(st,{fontSize:`sm`,children:r(`Benefits of this upgrade:`)}),J(at,{fontSize:`xs`,children:Y(B,{align:`start`,spacing:0,mt:1,children:[Y(z,{fontSize:`xs`,lineHeight:`1.2`,children:[`• `,r(`Improved security features`)]}),Y(z,{fontSize:`xs`,children:[`• `,r(`Better transaction handling`)]}),Y(z,{fontSize:`xs`,children:[`•`,` `,r(`Enhanced compatibility with dApps`)]}),Y(z,{fontSize:`xs`,children:[`•`,` `,r(`Reduced gas costs for operations`)]})]})})]})]})]})}),J(L,{justifyContent:`center`,children:Y(B,{spacing:3,w:`full`,children:[J(Am,{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}),J(M,{mt:2,variant:`link`,onClick:()=>{t?t():e(n)},isDisabled:c,children:r(o?`Close and do this later`:`Close`)})]})})]})},fu=({setCurrentContent:e})=>{let{account:t}=Q(),{sortedTokens:n}=Xs({address:t?.address}),{allowCustomTokens:r,darkMode:i}=$(),{currentCurrency:a}=Ys(),o=V(`colors`,`vechain-kit-text-tertiary`),{t:s}=X(),{isolatedView:c}=Ml(),[l,u]=K(``),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 Y(q,{children:[Y(Z,{children:[J(R,{children:s(`Assets`)}),!c&&J(Oo,{onClick:()=>e(`main`)}),J(I,{})]}),Y(yt,{h:[`540px`,`auto`],p:0,children:[Y(F,{children:[Y(At,{size:`lg`,children:[J(kt,{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`}),J(jt,{h:`56px`,w:`56px`,pl:4,children:J(Qr,{color:o})})]}),J(B,{spacing:2,align:`stretch`,mt:2,children:f.map(e=>{let t=Number(e.balance)>0,n=p.includes(e.symbol);return J(Tm,{symbol:e.symbol,amount:Number(e.balance),currencyValue:e.valueInCurrency,currentCurrency:a,onClick:()=>d(e),isDisabled:!t||n},e.address)})})]}),J(L,{children:r&&J(M,{variant:`vechainKitSecondary`,leftIcon:J(P,{as:Jr,boxSize:4}),onClick:()=>e(`add-custom-token`),children:s(`Manage Custom Tokens`)})})]})]})},pu=({setCurrentContent:t})=>{let{t:n}=X(),r=V(`colors`,`vechain-kit-text-primary`),i=V(`colors`,`vechain-kit-text-secondary`),a=V(`colors`,`vechain-kit-card`),o=V(`colors`,`vechain-kit-overlay`),{addToken:s,removeToken:c,isTokenIncluded:l,isDefaultToken:u,customTokens:f}=ac(),{register:p,setError:m,setValue:h,formState:{errors:g,isValid:_},handleSubmit:v}=ra({defaultValues:{newTokenAddress:``},mode:`onChange`}),y=async e=>{if(e.newTokenAddress){if(l(e.newTokenAddress)||u(e.newTokenAddress))return m(`newTokenAddress`,{type:`manual`,message:n(`Token already added`)});try{await s(e.newTokenAddress),h(`newTokenAddress`,``)}catch(e){console.error(`Error adding token 2:`,e),m(`newTokenAddress`,{type:`manual`,message:n(`Invalid token address`)})}}};return Y(q,{children:[Y(Z,{children:[J(R,{children:n(`Manage Custom Tokens`)}),J(Oo,{onClick:()=>t(`assets`)}),J(I,{})]}),J(F,{children:Y(B,{spacing:4,align:`stretch`,position:`relative`,children:[J(j,{p:6,borderRadius:`xl`,bg:a,children:J(B,{align:`stretch`,spacing:2,children:Y(St,{isInvalid:!!g.newTokenAddress,children:[J(Ct,{fontSize:`sm`,fontWeight:`medium`,color:r,children:n(`Token Contract Address`)}),J(kt,{...p(`newTokenAddress`,{required:n(`Address is required`),pattern:{value:/^0x[a-fA-F0-9]{40}$/,message:n(`Please enter a valid contract address`)},validate:e=>/^0x[a-fA-F0-9]{40}$/.test(e)||n(`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&&J(z,{color:`#ef4444`,fontSize:`sm`,children:g.newTokenAddress.message})]})})}),f.length>0&&Y(j,{p:4,borderRadius:`xl`,bg:o,children:[J(z,{fontSize:`sm`,fontWeight:`medium`,mb:2,children:n(`Existing Custom Tokens`)}),J(B,{align:`stretch`,spacing:2,children:f.map(t=>Y(N,{justify:`space-between`,fontSize:`sm`,p:2,borderRadius:`md`,bg:a,children:[Y(N,{children:[J(Ot,{src:e[t?.symbol],alt:`${t.symbol} logo`,boxSize:`20px`,borderRadius:`full`,fallback:J(j,{boxSize:`20px`,borderRadius:`full`,bg:`whiteAlpha.200`,display:`flex`,alignItems:`center`,justifyContent:`center`,children:J(z,{fontSize:`8px`,fontWeight:`bold`,color:r,children:t.symbol?.slice(0,3)})})}),J(z,{fontWeight:`medium`,color:r,children:t.symbol??`Unknown`})]}),J(z,{color:i,children:d(t.address??``,4,4)}),J(M,{size:`sm`,variant:`ghost`,color:r,borderRadius:`md`,p:2,onClick:()=>c(t.address),children:J(ii,{size:16,color:r})})]},t.address))})]})]})}),J(L,{children:J(M,{variant:`vechainKitPrimary`,isDisabled:!_,onClick:v(y),children:n(`Add Token`)})})]})},mu=({setCurrentContent:e})=>{let{t}=X(),{darkMode:n}=$(),{isolatedView:r}=Ml();return Y(q,{children:[Y(Z,{children:[J(R,{children:t(`Bridge`)}),!r&&J(Oo,{onClick:()=>e(`main`)}),J(I,{})]}),J(yt,{maxW:`container.lg`,children:J(F,{children:Y(B,{spacing:6,align:`center`,w:`full`,children:[J(qe,{isDark:n,borderRadius:`xl`}),J(z,{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.`)})]})})}),J(L,{children:Y(M,{variant:`vechainKitSecondary`,onClick:()=>{window.open(Ze,`_blank`)},children:[t(`Launch vechain.energy`),J(P,{as:Pr,ml:2})]})})]})},hu=({setCurrentContent:e})=>{let{t:n}=X(),{currentCurrency:r,changeCurrency:i,allCurrencies:a}=Ys(),o=dn(`rgba(0, 0, 0, 0.1)`,`rgba(255, 255, 255, 0.05)`);W(()=>{de(`settings-currency-visited`,`true`)},[]);let s=e=>{let n=r===e;return Y(M,{w:`full`,variant:`ghost`,justifyContent:`space-between`,onClick:()=>i(e),py:6,px:4,bg:n?o:void 0,children:[Y(N,{spacing:3,children:[J(z,{fontSize:`xl`,children:t[e]}),J(z,{children:e.toUpperCase()})]}),n&&J(P,{as:Sr,boxSize:5,color:`blue.500`})]},e)};return Y(Om,{children:[Y(Z,{children:[J(R,{children:n(`Select currency`)}),J(Oo,{onClick:()=>e(`settings`)}),J(I,{})]}),J(F,{w:`full`,children:J(B,{justify:`center`,spacing:3,align:`flex-start`,w:`full`,children:a.map(e=>s(e))})}),J(L,{pt:0})]})},gu=({setCurrentContent:e})=>{let{t,i18n:n}=X(),r=dn(`rgba(0, 0, 0, 0.1)`,`rgba(255, 255, 255, 0.05)`),i=e=>{n.changeLanguage(e)},a=e=>{let t=n.language===e;return Y(M,{w:`full`,variant:`ghost`,justifyContent:`space-between`,onClick:()=>i(e),py:6,px:4,bg:t?r:void 0,children:[J(z,{children:$a[e]}),t&&J(P,{as:Sr,boxSize:5,color:`blue.500`})]},e)};return Y(Om,{children:[Y(Z,{children:[J(R,{children:t(`Select language`)}),J(Oo,{onClick:()=>e(`settings`)}),J(I,{})]}),J(F,{w:`full`,children:J(B,{justify:`center`,spacing:3,align:`flex-start`,w:`full`,children:Za.map(e=>a(e))})}),J(L,{pt:0})]})},_u=({token:e,index:t,isExcluded:n,onToggleExclusion:r,onDragStart:i,onDragOver:a,onDrop:s,onTouchStart:c,onTouchMove:l,onTouchEnd:u,isDragging:d,isDraggedOver:f})=>{let p=o[e],{darkMode:m}=$(),h=V(`colors`,`vechain-kit-text-primary`),g=V(`colors`,`vechain-kit-text-secondary`),_=V(`colors`,`vechain-kit-card`);return J(j,{bg:m?`#ffffff0a`:`blackAlpha.50`,borderRadius:`md`,border:`1px`,borderColor:d?m?`blue.500`:`blue.300`:f?m?`blue.400`:`blue.200`:_,p:3,mb:2,opacity:d||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:()=>s(t),onTouchStart:e=>c(t,e),onTouchMove:l,onTouchEnd:u,_hover:{backgroundColor:m?`#ffffff12`:`blackAlpha.200`},children:Y(N,{justify:`space-between`,children:[Y(N,{opacity:n?.5:1,children:[J(j,{cursor:`grab`,_active:{cursor:`grabbing`},pointerEvents:`none`,children:J(P,{as:Vr,color:g})}),Y(B,{align:`start`,spacing:0,children:[J(z,{fontWeight:`medium`,color:h,children:p.name}),J(z,{fontSize:`sm`,color:g,children:p.description})]})]}),J(Xt,{isChecked:!n,onChange:()=>r(e),colorScheme:`blue`,size:`sm`})]})})},vu=({tokens:e,excludedTokens:t,onReorder:n,onToggleExclusion:r})=>{let[i,a]=K(null),[o,s]=K(null),c=vn([]),l=vn(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 J(j,{w:`full`,children:e.map((e,n)=>J(j,{ref:e=>{c.current[n]=e},children:J(_u,{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))})},yu=({setCurrentContent:e})=>{let{t}=X(),{preferences:n,reorderTokenPriority:r,toggleTokenExclusion:i}=Sm(),a=V(`colors`,`vechain-kit-text-primary`),o=V(`colors`,`vechain-kit-text-secondary`),s=U(e=>{r(e)},[r]);return Y(Om,{children:[Y(Z,{children:[J(R,{children:t(`Gas Token Preferences`)}),J(Oo,{onClick:()=>e(`settings`)}),J(I,{})]}),J(F,{w:`full`,children:Y(B,{justify:`center`,spacing:6,align:`flex-start`,w:`full`,children:[J(B,{w:`full`,justifyContent:`center`,spacing:3,mb:3,children:J(z,{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&&Y(it,{status:`warning`,borderRadius:`md`,children:[J(ot,{}),J(at,{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.`)})]}),Y(B,{w:`full`,align:`start`,spacing:3,children:[J(z,{fontSize:`md`,fontWeight:`semibold`,color:a,children:t(`Token Priority Order`)}),J(z,{fontSize:`sm`,color:o,children:t(`Drag to reorder. The system will automatically use the highest priority token with sufficient balance.`)}),J(vu,{tokens:n.tokenPriority,excludedTokens:n.excludedTokens,onReorder:s,onToggleExclusion:i})]})]})})]})},bu=({setCurrentContent:e,onLogoutSuccess:t})=>{let{t:n}=X(),{isolatedView:r}=Ml(),{exportWallet:i,linkPasskey:a}=Gn(),{showMfaEnrollmentModal:o}=Wn(),{feeDelegation:s}=$(),{connection:c,disconnect:l,smartAccount:u,connectedWallet:d}=Q(),{data:f}=Np(u?.address??``,d?.address??``,3),p=()=>{e({type:`upgrade-smart-account`,props:{setCurrentContent:e,initialContent:`settings`}})},m=()=>{e(`connection-details`)},h=()=>{l(),t()},g=V(`colors`,`vechain-kit-text-secondary`);return Y(q,{children:[Y(Z,{children:[J(R,{children:n(`Settings`)}),!r&&J(Oo,{onClick:()=>e(`profile`)}),J(I,{})]}),Y(F,{w:`full`,children:[Y(B,{w:`full`,spacing:2,children:[J(z,{fontSize:`sm`,fontWeight:`bold`,color:g,textAlign:`left`,w:`full`,children:n(`General`)}),J(Yl,{title:n(`Currency`),onClick:()=>{e(`change-currency`)},leftIcon:Mr,rightIcon:Tr}),J(Yl,{title:n(`Language`),onClick:()=>{e(`change-language`)},leftIcon:Ur,rightIcon:Tr}),c.isConnectedWithPrivy&&!s?.delegatorUrl&&J(Yl,{title:n(`Gas Token Preferences`),onClick:()=>{e(`gas-token-settings`)},leftIcon:Lr,rightIcon:Tr}),J(Yl,{title:n(`Terms and Policies`),onClick:()=>{e({type:`terms-and-privacy`,props:{onGoBack:()=>e(`settings`)}})},leftIcon:ei,rightIcon:Tr}),J(Yl,{title:n(`Logout`),onClick:()=>e({type:`disconnect-confirm`,props:{onDisconnect:h,onBack:()=>e(`settings`)}}),leftIcon:Gr})]}),f&&J(B,{w:`full`,spacing:2,mt:4,children:J(Yl,{title:n(`Upgrade Smart Account to V3`),description:n(`A new version is available for your account`),onClick:p,leftIcon:$r,extraContent:J(j,{minWidth:`8px`,height:`8px`,bg:`red.500`,borderRadius:`full`,display:`flex`,alignItems:`center`,justifyContent:`center`,ml:2})})}),c.isConnectedWithSocialLogin&&Y(B,{w:`full`,spacing:2,mt:4,children:[J(z,{fontSize:`sm`,fontWeight:`bold`,color:g,textAlign:`left`,w:`full`,children:n(`Access and security`)}),J(Yl,{title:n(`Passkey`),onClick:()=>a(),leftIcon:Ir}),J(Yl,{title:n(`Backup`),onClick:()=>{i()},leftIcon:Hr}),J(Yl,{title:n(`Manage MFA`),onClick:()=>{o()},leftIcon:ti}),J(Yl,{title:n(`Login methods`),onClick:()=>{e(`privy-linked-accounts`)},leftIcon:oi,rightIcon:Tr})]}),Y(B,{w:`full`,spacing:2,mt:4,children:[J(z,{fontSize:`sm`,fontWeight:`bold`,color:g,textAlign:`left`,w:`full`,children:n(`Help`)}),J(Yl,{title:n(`Connection details`),onClick:m,leftIcon:ai,rightIcon:Tr}),J(Yl,{title:n(`Explore ecosystem`),onClick:()=>e(`ecosystem`),leftIcon:Wr,rightIcon:Tr}),J(Yl,{title:n(`Frequently asked questions`),onClick:()=>e({type:`faq`,props:{onGoBack:()=>e(`settings`),showLanguageSelector:!1}}),leftIcon:kr,rightIcon:Tr})]})]}),J(L,{p:0})]})},xu=({title:e,description:t,icon:n})=>{let r=V(`colors`,`vechain-kit-text-secondary`),i=V(`colors`,`vechain-kit-text-primary`);return Y(B,{spacing:6,align:`center`,py:8,children:[J(P,{as:n,boxSize:16,color:r}),Y(B,{spacing:2,children:[J(z,{fontSize:`lg`,fontWeight:`500`,textAlign:`center`,color:i,children:e}),J(z,{fontSize:`md`,color:r,textAlign:`center`,px:4,children:t})]})]})},Su=(e,t=`en-US`)=>new Intl.DateTimeFormat(t,{month:`short`,day:`numeric`}).format(new Date(e)),Cu=({document:e})=>{let{t}=X(),n=V(`colors`,`vechain-kit-text-secondary`),r=e.documentSource===se.VECHAIN_KIT&&e.documentType===ue.TERMS;return Y(N,{children:[Y(Zt,{size:`sm`,borderRadius:`full`,color:n,children:[`v`,e.version]}),J(z,{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:Su(e.timestamp)})})]})},wu=({title:e,description:t,documents:n,bg:r,hoverBg:i,currentPolicy:a})=>{let{t:o}=X(),s=V(`colors`,`vechain-kit-text-primary`),c=V(`colors`,`vechain-kit-text-secondary`),l=n?.length>0,u=n?.find(e=>e.id===a?.id);return l?J(nt,{border:`none`,mb:3,children:({isExpanded:l})=>Y(q,{children:[Y(tt,{bg:r,borderRadius:`xl`,_hover:{bg:i},children:[Y(B,{w:`full`,align:`flex-start`,textAlign:`left`,children:[J(z,{fontWeight:`700`,color:s,children:e}),J(z,{fontSize:`xs`,color:c,children:t})]}),J(P,{as:l?Er:Cr,fontSize:`20px`,color:c})]}),J(rt,{pb:4,pt:3,children:Y(B,{align:`stretch`,spacing:4,children:[u?.id?Y(N,{w:`full`,children:[J(P,{as:Sr,color:s}),J(z,{fontSize:`xs`,color:c,children:o(`You accepted current policy on {{date}}`,{date:Su(u.timestamp)})})]}):null,J(N,{w:`full`,textAlign:`left`,children:J(z,{fontSize:`xs`,fontWeight:`bold`,color:c,children:o(`All policies you have accepted`)})}),J(N,{w:`full`,gap:2,children:J(B,{align:`stretch`,spacing:2,children:n.map(e=>J(Cu,{document:e},e.id))})}),a&&J(M,{variant:`outline`,size:`xs`,alignSelf:`flex-end`,onClick:()=>{window.open(a.url,`_blank`)},children:o(`View Current Policy`)})]})})]})}):null},Tu=()=>{let{account:e}=Q(),{t}=X(),{darkMode:n}=$(),{agreements:r,documents:i}=Jm(),a=G(()=>{let t=r?.filter(t=>O(t.walletAddress,e?.address));return[{id:`vechain-kit-terms`,...E,documentType:ue.TERMS,documentSource:se.VECHAIN_KIT,walletAddress:e?.address??``,timestamp:new Date().getTime()},...t]?.reduce((e,t)=>(e[t.documentType]=[...e[t.documentType]||[],t],e),{})},[r,e?.address]),o=G(()=>i.reduce((e,t)=>{let n=t.documentType;return(!e[n]||t.version>e[n].version)&&(e[n]=t),e},{}),[i]),s=G(()=>Object.values(a).some(e=>e.length>0),[a]),c=n?`whiteAlpha.50`:`blackAlpha.50`,l=n?`whiteAlpha.100`:`blackAlpha.100`,u=G(()=>{let e=[];return a[ue.TERMS]?.length>0&&e.push(0),a[ue.PRIVACY]?.length>0&&e.push(1),a[ue.COOKIES]?.length>0&&e.push(2),e},[a]);return s?J(B,{spacing:4,align:`stretch`,children:Y(et,{allowMultiple:!0,defaultIndex:u,children:[J(wu,{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[ue.TERMS],bg:c,hoverBg:l,currentPolicy:o[ue.TERMS]}),J(wu,{title:t(`Privacy Policy`),description:t(`Privacy policy outlining the data collection and processing practices.`),documents:a[ue.PRIVACY],bg:c,hoverBg:l,currentPolicy:o[ue.PRIVACY]}),J(wu,{title:t(`Cookie Policy`),description:t(`Cookie policy outlining the use of cookies and tracking technologies.`),documents:a[ue.COOKIES],bg:c,hoverBg:l,currentPolicy:o[ue.COOKIES]})]})}):J(xu,{title:t(`No policies accepted`),description:t(`When you have accepted a policy, it will appear here`),icon:Rr})},Eu=({onGoBack:e})=>{let{t}=X();return Y(Om,{children:[Y(Z,{children:[J(R,{children:t(`Terms and Policies`)}),J(Oo,{onClick:e}),J(I,{})]}),J(F,{w:`full`,children:J(B,{spacing:6,align:`stretch`,children:J(Tu,{})})}),J(L,{pt:0})]})},Du=({onDisconnect:e,onBack:t,onClose:n,showCloseButton:r=!0,text:i})=>{let{t:a}=X(),o=V(`colors`,`vechain-kit-text-primary`),s=i??a(`Are you sure you want to disconnect your wallet?`);return Y(q,{children:[Y(Z,{children:[J(R,{children:a(`Logout`)}),J(Oo,{onClick:t}),r?J(I,{onClick:n}):null]}),J(F,{children:Y(B,{spacing:6,align:`center`,mt:10,children:[J(P,{as:Gr,color:`#ef4444`,fontSize:`60px`,opacity:.5}),J(z,{fontSize:`md`,textAlign:`center`,color:o,children:s})]})}),J(L,{w:`full`,mt:4,children:Y(B,{spacing:3,w:`full`,children:[J(M,{onClick:e,"data-testid":`disconnect-button`,variant:`vechainKitLogout`,children:a(`Confirm`)}),J(M,{variant:`vechainKitSecondary`,onClick:t,"data-testid":`cancel-logout-button`,children:a(`Cancel`)})]})})]})},Ou=({wallet:e,isActive:t,onSelect:n,onRemove:i,showRemove:a=!0})=>{let{t:o}=X(),{network:s}=$(),{formattedBalance:c,isLoading:l}=Zs({address:e.address}),{domain:u,image:f,isLoading:p}=kc(e.address,s.type),m=V(`colors`,`vechain-kit-text-primary`),h=V(`colors`,`vechain-kit-text-secondary`),g=V(`colors`,`vechain-kit-border`),_=l||p;return J(lt,{variant:`vechainKitWalletCard`,onClick:n,borderWidth:t?`2px`:`1px`,borderColor:t?`vechain-kit-primary`:g,_hover:{borderColor:t?`vechain-kit-primary`:`vechain-kit-text-secondary`},children:J(ut,{p:4,children:Y(N,{spacing:3,w:`full`,justifyContent:`space-between`,children:[Y(N,{spacing:3,flex:1,minW:0,children:[J(km,{wallet:{address:e.address,domain:u??void 0,image:f??void 0,isLoadingMetadata:p},props:{width:10,height:10}}),Y(B,{spacing:0,alignItems:`flex-start`,flex:1,minW:0,children:[J(z,{fontSize:`sm`,fontWeight:`medium`,color:m,noOfLines:1,children:u?r(u,22,0):d(e.address,6,4)}),J(z,{fontSize:`xs`,color:h,noOfLines:1,children:_?o(`Loading...`):c})]})]}),t&&J(j,{children:J(P,{as:Sr,boxSize:5,color:`vechain-kit-primary`})}),a&&!t&&J(Dt,{"aria-label":o(`Remove wallet`),icon:J(P,{as:ii}),variant:`vechainKitSecondary`,height:`30px`,w:`30px`,borderRadius:`5px`,onClick:e=>{e.stopPropagation(),i()}})]})})})},ku=e=>te(e.map(e=>e.address.toLowerCase()).sort().join(`|`)),Au=({setCurrentContent:e,returnTo:t=`main`,onLogoutSuccess:n})=>{let{t:r}=X(),{isolatedView:i}=Ml(),{account:a,disconnect:o}=Q(),{disconnect:s}=$n(),{open:c}=tr(),{getStoredWallets:l,setActiveWallet:u,removeWallet:d}=Mc(),{saveWallet:f}=Ac(),{refresh:p}=jc(),m=V(`colors`,`vechain-kit-text-secondary`),[h,g]=K(l()),_=vn(ku(l())),v=U(()=>{let e=l();g(e),_.current=ku(e)},[l]);W(()=>{v()},[v,a?.address]),W(()=>{let e=()=>{setTimeout(()=>{v()},100)};if(typeof window<`u`)return window.addEventListener(`wallet_switched`,e),()=>{window.removeEventListener(`wallet_switched`,e)}},[v]),W(()=>{let e=setInterval(()=>{ku(l())!==_.current&&v()},200);return()=>clearInterval(e)},[l,v]);let y=G(()=>{let e=h.find(e=>e.isActive);return e?e.address:a?.address??null},[h,a?.address]),b=G(()=>h.find(e=>e.address.toLowerCase()===y?.toLowerCase()),[h,y]),x=G(()=>h.filter(e=>e.address.toLowerCase()!==y?.toLowerCase()),[h,y]),S=U(n=>{n.toLowerCase()!==y?.toLowerCase()&&(b&&f(b.address),u(n),setTimeout(()=>{v()},50),p(),e({type:t,props:{switchFeedback:{showFeedback:!0}}}))},[y,b,a,u,p,e,v,f]),C=U(r=>{let i=r.address.toLowerCase()===y?.toLowerCase(),a=h.filter(e=>e.address.toLowerCase()!==r.address.toLowerCase());e({type:`remove-wallet-confirm`,props:{walletAddress:r.address,walletDomain:null,onConfirm:async()=>{if(i&&a.length>0){let e=a[0];u(e.address)}else if(i&&a.length===0)try{await s()}catch(e){console.error(`Error disconnecting:`,e)}if(d(r.address),setTimeout(()=>{v()},50),a.length===0){n&&n();return}e({type:`select-wallet`,props:{setCurrentContent:e,onClose:()=>{},returnTo:t,onLogoutSuccess:n}})},onBack:()=>{e({type:`select-wallet`,props:{setCurrentContent:e,onClose:()=>{},returnTo:t,onLogoutSuccess:n}})}}})},[d,v,e,t,n,y,h,u,s]),w=U(()=>{c()},[c]),T=()=>{o(),n?.()};return Y(q,{children:[Y(Z,{children:[!i&&J(Oo,{onClick:()=>{e(t)}}),J(R,{children:r(`Select Wallet`)}),J(I,{})]}),J(F,{w:`full`,children:Y(B,{w:`full`,spacing:4,children:[b&&Y(B,{w:`full`,spacing:2,alignItems:`flex-start`,children:[J(Et,{size:`sm`,color:m,children:r(`Active Wallet`)}),J(Ou,{wallet:b,isActive:!0,onSelect:()=>{},onRemove:()=>C(b),showRemove:h.length>1})]}),x.length>0&&Y(B,{w:`full`,spacing:2,alignItems:`flex-start`,children:[J(Et,{size:`sm`,color:m,children:r(`Other Wallets`)}),x.map(e=>J(Ou,{wallet:e,isActive:!1,onSelect:()=>S(e.address),onRemove:()=>C(e),showRemove:!0},e.address))]})]})}),J(L,{w:`full`,children:Y(B,{w:`full`,spacing:2,children:[J(M,{w:`full`,leftIcon:J(Xr,{}),variant:`vechainKitSecondary`,onClick:w,children:r(`Add New Wallet`)}),J(M,{w:`full`,leftIcon:J(Gr,{}),variant:`vechainKitLogout`,onClick:()=>e({type:`disconnect-confirm`,props:{onDisconnect:T,onBack:()=>e({type:`select-wallet`,props:{setCurrentContent:e,onClose:()=>{},returnTo:t,onLogoutSuccess:n}})}}),children:r(`Logout`)})]})})]})},ju=({walletAddress:e,walletDomain:t,onConfirm:n,onBack:i,onClose:a})=>{let{t:o}=X(),{network:s}=$(),{domain:c}=kc(e,s.type),l=V(`colors`,`vechain-kit-text-primary`),u=c?r(c,20,0):d(e,6,4);return Y(q,{children:[Y(Z,{children:[J(R,{children:o(`Remove`)}),J(Oo,{onClick:i}),a&&J(I,{onClick:a})]}),J(F,{children:Y(B,{spacing:6,align:`center`,mt:10,children:[J(P,{as:ii,color:`#ef4444`,fontSize:`60px`,opacity:.5}),J(z,{fontSize:`md`,textAlign:`center`,color:l,children:o(`Are you sure you want to remove this wallet?`)}),J(z,{fontSize:`sm`,textAlign:`center`,color:`vechain-kit-text-secondary`,fontWeight:`600`,children:u}),J(z,{fontSize:`sm`,textAlign:`center`,color:`vechain-kit-text-secondary`,children:d(e,8,7)})]})}),J(L,{w:`full`,mt:4,children:Y(B,{spacing:3,w:`full`,children:[J(M,{onClick:n,"data-testid":`remove-wallet-button`,variant:`vechainKitLogout`,children:o(`Remove`)}),J(M,{variant:`vechainKitSecondary`,onClick:i,"data-testid":`cancel-remove-button`,children:o(`Cancel`)})]})})]})},Mu=jo[`@vechain/dapp-kit-react`]||Mo[`@vechain/dapp-kit-react`]||`unknown`,Nu=jo[`@privy-io/react-auth`]||`unknown`,Pu=({connectionCache:e})=>{let{t}=X(),{connection:n,smartAccount:r,connectedWallet:i}=Q(),{source:a}=er(),{privy:o,network:s}=$(),c=o?.appId,{data:l,isLoading:u}=Ho(c||[]),{onCopy:f,hasCopied:p}=ln(``),{data:m,isLoading:h}=Wo(),{data:g,isLoading:_}=vp(r.address??``,i?.address??``),v=V(`colors`,`vechain-kit-card`),b=V(`colors`,`vechain-kit-text-secondary`),x=V(`colors`,`vechain-kit-text-primary`),S=(()=>n.isConnectedWithCrossApp&&e?.ecosystemApp?e.ecosystemApp.name:n.isConnectedWithSocialLogin&&l?Object.values(l)[0]?.name??null:n.isConnectedWithDappKit&&a?a:null)(),C=n.isConnectedWithSocialLogin&&u,w=({label:e,value:t,isLoading:n=!1,href:r})=>Y(N,{w:`full`,justifyContent:`space-between`,children:[Y(z,{fontSize:`sm`,color:x,children:[e,`:`]}),J(z,{fontSize:`sm`,as:r?`a`:void 0,href:r,target:`_blank`,rel:`noopener noreferrer`,style:{textDecoration:r?`underline`:`none`},color:b,children:n?`Loading...`:t})]});return C?J(B,{w:`full`,h:`full`,justify:`center`,align:`center`,minH:`200px`,borderRadius:`xl`,bg:v,children:J(Jt,{})}):S?Y(B,{p:4,bg:v,borderRadius:`xl`,spacing:4,w:`full`,justifyContent:`space-between`,children:[J(w,{label:t(`Logged in with`),value:S}),n.isConnectedWithCrossApp&&e?.timestamp&&J(w,{label:t(`At`),value:new Date(e.timestamp).toLocaleString()}),J(w,{label:t(`Connection Type`),value:n.source.type,isLoading:n.isLoading}),J(bt,{}),J(w,{label:t(`Network`),value:s.type}),J(w,{label:t(`Node URL`),value:s.nodeUrl||y(s.type).nodeUrl}),n.isConnectedWithPrivy&&J(bt,{}),n.isConnectedWithPrivy&&Y(N,{w:`full`,justifyContent:`space-between`,children:[Y(z,{fontSize:`sm`,color:x,children:[t(`Embedded wallet`),`:`]}),Y(N,{children:[J(z,{fontSize:`sm`,color:b,children:i?.address?d(i.address,8,7):`-`}),J(P,{color:b,onClick:()=>{i?.address&&f(i.address)},opacity:i?.address?1:.4,pointerEvents:i?.address?`auto`:`none`,cursor:`pointer`,as:p?Sr:jr})]})]}),n.isConnectedWithPrivy?Y(q,{children:[J(w,{label:t(`Smart Account`),value:`v${g?.version??``} ${g?.isDeployed?``:`(not deployed)`}`,isLoading:_}),J(w,{label:t(`Privy Status`),value:m||``,isLoading:h})]}):r.isDeployed&&J(w,{label:t(`Smart Account`),value:`v${g?.version??``}`,isLoading:_}),J(bt,{}),J(w,{label:t(`VeChain Kit`),value:Ao,href:`https://github.com/vechain/vechain-kit/releases/tag/${Ao}`}),J(w,{label:`DAppKit`,value:Mu}),J(w,{label:`Privy`,value:Nu})]}):null},Fu=()=>{let{connection:e}=Q(),{t}=X(),{privy:n,darkMode:r}=$(),{getConnectionCache:i}=Bf(),a=i(),o=V(`colors`,`vechain-kit-card`);return e.isConnectedWithPrivy?Y(B,{w:`full`,align:`stretch`,textAlign:`center`,mt:5,p:3,borderRadius:`lg`,bg:o,shadow:`sm`,children:[J(z,{fontSize:`xs`,fontWeight:`800`,children:t(`Wallet secured by`)}),Y(N,{justify:`center`,children:[J(Ve,{isDark:r,w:`50px`}),J(P,{as:qr,ml:3}),e.isConnectedWithVeChain?J(be,{isDark:r,w:`80px`,h:`auto`,mb:`3px`}):e.isConnectedWithCrossApp&&a&&J(Ot,{src:a.ecosystemApp.logoUrl,alt:a.ecosystemApp.name,maxW:`40px`,borderRadius:`md`}),e.isConnectedWithSocialLogin&&!e.isConnectedWithVeChain&&J(Ot,{src:n?.appearance.logo,alt:n?.appearance.logo,maxW:`40px`,borderRadius:`md`})]})]}):null},Iu=({onGoBack:e})=>{let{t}=X(),{getConnectionCache:n}=Bf(),r=n()??void 0;return Y(Om,{children:[Y(Z,{children:[J(R,{children:t(`Connection Details`)}),J(Oo,{onClick:()=>{e()}}),J(I,{})]}),Y(F,{w:`full`,children:[J(Pu,{connectionCache:r}),J(Fu,{})]}),J(L,{pt:0})]})},Lu=({accountType:e,accountDescription:t,isLoading:n,onConfirm:r,onCancel:i})=>{let{t:a}=X();return Y(B,{spacing:6,align:`stretch`,children:[J(z,{fontSize:`md`,textAlign:`center`,color:V(`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})}),Y(B,{spacing:3,w:`full`,children:[J(M,{height:`60px`,colorScheme:`red`,w:`full`,onClick:r,isLoading:n,children:a(`Remove Login Method`)}),J(M,{isLoading:n,height:`60px`,w:`full`,onClick:i,children:a(`Cancel`)})]})]})},Ru=({onBack:e})=>{let{t}=X(),{privy:n,dappKit:r}=$(),[i,a]=K(null),[o,s]=K(!1),[c,l]=K(!1),[u,f]=K(!1),p=V(`colors`,`vechain-kit-text-primary`),m=V(`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:T,linkTelegram:E,linkFarcaster:D,linkPasskey:O,linkDiscord:k,unlinkEmail:A,unlinkGoogle:ee,unlinkApple:te,unlinkSpotify:ne,unlinkInstagram:re,unlinkTiktok:ie,unlinkGithub:ae,unlinkLinkedIn:oe,unlinkTelegram:se,unlinkFarcaster:ce,unlinkPhone:le,unlinkPasskey:ue,unlinkDiscord:de,linkWallet:fe}=Kn(),pe=G(()=>{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]),me=e=>{switch(e){case`google_oauth`:return na;case`email`:return Kr;case`passkey`:return Ir;case`wallet`:return si;case`twitter_oauth`:return la;case`phone`:return Yr;case`spotify_oauth`:return ha;case`apple_oauth`:return da;case`instagram_oauth`:return pa;case`tiktok_oauth`:return va;case`github_oauth`:return zr;case`linkedin_oauth`:return ma;case`telegram`:return ga;case`farcaster`:return ua;case`discord_oauth`:return fa;default:return}},he=()=>{let e=h?.linkedAccounts?.filter(e=>e.type!==`wallet`||e.type===`wallet`&&e.connectorType!==`embedded`);return e&&e?.length>1},ge=async e=>{if(he()){f(!0);try{switch(e.type){case`google_oauth`:await ee(e.subject);break;case`email`:await A(e.address);break;case`passkey`:await ue(e.subject);break;case`phone`:await le(e.number);break;case`spotify_oauth`:await ne(e.subject);break;case`apple_oauth`:await te(e.subject);break;case`instagram_oauth`:await re(e.subject);break;case`tiktok_oauth`:await ie(e.subject);break;case`github_oauth`:await ae(e.subject);break;case`linkedin_oauth`:await oe(e.subject);break;case`telegram`:await se(e.subject);break;case`farcaster`:await ce(e.subject);break;case`discord_oauth`:await de(e.subject);break;default:break}}catch(e){console.error(e)}finally{f(!1),a(null)}}},_e=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`${d(e.address)} - ${e.walletClientType}`;default:return``}},ve=h?.linkedAccounts?.map(e=>e.type)||[],ye=n?.loginMethods||[],be=!ve.includes(`google_oauth`)&&ye.includes(`google`),xe=!ve.includes(`email`)&&ye.includes(`email`),Se=!ve.includes(`twitter_oauth`)&&ye.includes(`twitter`),Ce=!ve.includes(`phone`)&&ye.includes(`sms`),we=!ve.includes(`spotify_oauth`)&&ye.includes(`spotify`),Te=!ve.includes(`apple_oauth`)&&ye.includes(`apple`),Ee=!ve.includes(`instagram_oauth`)&&ye.includes(`instagram`),De=!ve.includes(`tiktok_oauth`)&&ye.includes(`tiktok`),Oe=!ve.includes(`github_oauth`)&&ye.includes(`github`),ke=!ve.includes(`linkedin_oauth`)&&ye.includes(`linkedin`),Ae=!ve.includes(`telegram`)&&ye.includes(`telegram`),je=!ve.includes(`farcaster`)&&ye.includes(`farcaster`),Me=!ve.includes(`discord_oauth`)&&ye.includes(`discord`);return o?Y(Om,{children:[Y(Z,{children:[J(R,{children:t(`Select Additional Login Method`)}),J(Oo,{onClick:()=>s(!1)}),J(I,{})]}),J(F,{w:`full`,children:Y(B,{spacing:3,align:`stretch`,w:`full`,children:[J(Yl,{title:t(`Set up Passkey`),description:t(`Set up a passkey for easier access`),onClick:()=>O(),leftIcon:Ir}),be&&J(Yl,{title:t(`Link Google Account`),description:t(`Connect your Google account for easier access`),onClick:()=>_(),leftIcon:na}),xe&&J(Yl,{title:t(`Link Email Account`),description:t(`Connect your email for easier access`),onClick:()=>g(),leftIcon:Kr,stacked:!0}),Se&&J(Yl,{title:t(`Link Twitter Account`),description:t(`Connect your Twitter account for easier access`),onClick:()=>v(),leftIcon:la}),Ce&&J(Yl,{title:t(`Link Phone Number`),description:t(`Connect your phone number for easier access`),onClick:()=>y(),leftIcon:Yr}),we&&J(Yl,{title:t(`Link Spotify Account`),description:t(`Connect your Spotify account for easier access`),onClick:()=>b(),leftIcon:ha}),Te&&J(Yl,{title:t(`Link Apple Account`),description:t(`Connect your Apple account for easier access`),onClick:()=>x(),leftIcon:da}),Ee&&J(Yl,{title:t(`Link Instagram Account`),description:t(`Connect your Instagram account for easier access`),onClick:()=>S(),leftIcon:pa}),De&&J(Yl,{title:t(`Link Tiktok Account`),description:t(`Connect your Tiktok account for easier access`),onClick:()=>C(),leftIcon:va}),Oe&&J(Yl,{title:t(`Link Github Account`),description:t(`Connect your Github account for easier access`),onClick:()=>w(),leftIcon:zr}),ke&&J(Yl,{title:t(`Link LinkedIn Account`),description:t(`Connect your LinkedIn account for easier access`),onClick:()=>T(),leftIcon:ma}),Ae&&J(Yl,{title:t(`Link Telegram Account`),description:t(`Connect your Telegram account for easier access`),onClick:()=>E(),leftIcon:ga}),je&&J(Yl,{title:t(`Link Farcaster Account`),description:t(`Connect your Farcaster account for easier access`),onClick:()=>D(),leftIcon:ua}),Me&&J(Yl,{title:t(`Link Discord Account`),description:t(`Connect your Discord account for easier access`),onClick:()=>k(),leftIcon:fa}),pe&&J(Yl,{title:t(`Link External Wallet`),description:t(`Connect an external wallet for easier access`),onClick:()=>fe(),leftIcon:si}),!be&&!xe&&!Se&&!Ce&&!we&&!Te&&!Ee&&!De&&!Oe&&!ke&&!Ae&&!je&&!Me&&J(z,{fontSize:`sm`,textAlign:`center`,opacity:.7,children:t(`No additional accounts available to link`)})]})}),J(L,{pt:0})]}):i?Y(Om,{children:[Y(Z,{children:[J(R,{children:t(`Remove Login Method`)}),J(Oo,{onClick:()=>a(null)}),J(I,{})]}),J(F,{children:J(Lu,{accountType:i.type,accountDescription:_e(i),isLoading:u,onConfirm:()=>ge(i),onCancel:()=>a(null)})}),J(L,{pt:0})]}):Y(Om,{children:[Y(Z,{children:[J(R,{children:t(`Login methods`)}),J(Oo,{onClick:e}),J(I,{})]}),J(F,{w:`full`,children:Y(B,{spacing:3,align:`center`,w:`full`,justify:`center`,children:[Y(B,{spacing:1,justify:`flex-start`,alignItems:`flex-start`,mb:5,textAlign:`left`,w:`full`,children:[J(z,{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&&J(z,{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.`)}),J(M,{variant:`link`,mt:0,size:`sm`,onClick:()=>l(!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=>Y(xt,{p:4,borderWidth:`1px`,borderRadius:`md`,align:`center`,justify:`space-between`,w:`full`,children:[Y(xt,{align:`center`,gap:3,children:[J(P,{as:me(e.type),color:p}),Y(B,{align:`start`,spacing:0,children:[J(z,{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`)}),J(z,{fontSize:`sm`,color:m,children:_e(e)})]})]}),J(M,{size:`sm`,variant:`ghost`,colorScheme:`red`,isDisabled:!he(),onClick:()=>{e.type===`passkey`?O():a(e)},children:t(`Remove`)})]},e.type))]})}),J(L,{w:`full`,children:J(M,{w:`full`,variant:`vechainKitPrimary`,onClick:()=>s(!0),leftIcon:J(P,{as:Xr}),isDisabled:!be&&!xe&&!Se&&!Ce&&!we&&!Te&&!Ee&&!De&&!Oe&&!ke&&!Ae&&!je&&!Me,children:t(`Add Login Method`)})})]})},zu=[{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}],Bu=()=>{let{t:e}=X(),{account:t,connection:n,smartAccount:r}=Q(),{addNotification:i,getNotifications:a}=Vu(),{data:o}=Ip(r?.address??``,3);W(()=>{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]),W(()=>{!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]),W(()=>{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])},Vu=()=>{let{account:e}=Q(),t=U(e=>{let t=e?.toLowerCase();return{notifications:`vechain_kit_notifications_${t}`,archived:`vechain_kit_archived_notifications_${t}`,initialized:`vechain_kit_notifications_initialized_${t}`}},[]),n=U(()=>{if(!e?.address||!A())return;let n=t(e.address);x(n.initialized)||(de(n.notifications,JSON.stringify(zu)),de(n.initialized,`true`))},[e?.address,t]);W(()=>{n()},[n]);let r=U(()=>{if(!e?.address||!A())return[];let n=x(t(e.address).notifications);return n?JSON.parse(n):[]},[e?.address,t]),i=U(()=>{if(!e?.address||!A())return[];let n=x(t(e.address).archived);return n?JSON.parse(n):[]},[e?.address,t]),a=U(n=>{if(!e?.address||!A())return;let i=t(e.address),a=r(),o=x(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};de(i.notifications,JSON.stringify([c,...a]))},[e?.address,r,t]),o=U(n=>{if(!e?.address||!A())return;let i=t(e.address),a=r().filter(e=>e.id!==n);de(i.notifications,JSON.stringify(a))},[e?.address,r,t]);return{getNotifications:r,getArchivedNotifications:i,addNotification:a,clearAllNotifications:U(()=>{if(!e?.address||!A())return;let n=t(e.address),a=r();de(n.archived,JSON.stringify([...i(),...a])),de(n.notifications,JSON.stringify([]))},[e?.address,r,i,t]),markAsRead:U(n=>{if(!e?.address||!A())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];de(a.notifications,JSON.stringify(l)),de(a.archived,JSON.stringify(e))}},[e?.address,r,i,t]),deleteNotification:o}},Hu=({showArchived:e})=>{let{t}=X();return J(xu,{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?dr:vr})},Uu=({notification:e,isArchiveView:t,onMarkAsRead:n})=>{let{t:r}=X(),i=()=>{n(e.id)};return e.isRead&&!t?null:Y(it,{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:[J(ot,{boxSize:`16px`}),Y(j,{children:[J(st,{fontSize:`sm`,"data-testid":`notification-title`,children:r(e.title)}),J(at,{fontSize:`xs`,lineHeight:`1.2`,"data-testid":`notification-text`,children:r(e.description)})]}),!t&&!e.isRead&&J(Dt,{position:`absolute`,right:1,top:1,size:`sm`,variant:`ghost`,icon:J(Ar,{}),onClick:e=>{e.stopPropagation(),i()},"aria-label":`Mark as read and archive`,"data-testid":`remove-notification-button`})]},e.id)},Wu=({setCurrentContent:e})=>{let{t}=X(),{isolatedView:n}=Ml(),{getNotifications:r,getArchivedNotifications:i,clearAllNotifications:a,markAsRead:o}=Vu(),[s,c]=K(!1),[l,u]=K(r()),[d,f]=K(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 Y(Om,{children:[Y(Z,{children:[!n&&J(Oo,{onClick:()=>e(`main`)}),J(R,{"data-testid":`modal-title`,children:t(s?`Archived Notifications`:`Notifications`)}),J(I,{})]}),Y(yt,{h:[`540px`,`auto`],p:0,children:[J(F,{children:Y(B,{spacing:4,align:`stretch`,w:`full`,children:[Y(N,{justify:`space-between`,children:[J(M,{variant:`ghost`,leftIcon:J(P,{as:s?vr:dr}),size:`sm`,onClick:h,"data-testid":`toggle-view-button`,children:t(s?`Current`:`Archived`)}),!s&&l.length>0&&J(M,{variant:`ghost`,size:`sm`,onClick:p,"data-testid":`clear-all-button`,children:t(`Clear all`)})]}),g.length===0?J(Hu,{showArchived:s}):J(B,{spacing:3,children:_.map(e=>J(Uu,{notification:e,isArchiveView:s,onMarkAsRead:m},e.id))})]})}),J(L,{pt:0})]})]})},Gu=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`}},Ku=({category:e,...t})=>{let{t:n}=X(),r=e.toLowerCase();return J(Zt,{size:`sm`,colorScheme:Gu(r),borderRadius:`full`,px:2,...t,children:n(r)})},qu=({name:e,imageUrl:t,logoComponent:n,category:r,onClick:i,size:a=`md`})=>Y(lt,{variant:`vechainKitAppCard`,_hover:{opacity:.8},cursor:`pointer`,onClick:i,position:`relative`,children:[r&&J(j,{position:`absolute`,top:`2`,right:`2`,zIndex:`1`,children:J(Ku,{category:r})}),J(ut,{p:a===`sm`?2:4,alignItems:`center`,children:Y(B,{spacing:2,h:`100%`,justifyContent:`space-between`,children:[n||t&&J(Ot,{src:t,fallbackSrc:b,alt:e,height:`90px`,objectFit:`contain`,rounded:`full`}),e&&J(z,{fontWeight:`medium`,wordBreak:`break-word`,noOfLines:1,textAlign:`center`,w:`full`,children:e})]})})]}),Ju=({xApp:e,setCurrentContent:t,selectedCategory:n})=>{let{data:r,isLoading:i}=Fc(e.id),{data:a,isLoading:o}=Hc(r?.logo);return J(qt,{isLoaded:!i&&!o,borderRadius:`md`,height:`100%`,children:J(qu,{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}})}})})},Yu=({name:e,image:t,url:n,description:r,category:i,logoComponent:a,selectedCategory:o,setCurrentContent:s})=>J(qu,{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}}),Xu=({})=>{let{t:e}=X(),{shortcuts:t}=mm();return t.length===0?null:Y(B,{w:`full`,align:`flex-start`,spacing:2,children:[J(z,{fontSize:`sm`,fontWeight:`500`,children:e(`Shortcuts`)}),J(wt,{templateColumns:`repeat(4, 1fr)`,gap:2,w:`full`,children:t.map(e=>J(Tt,{children:J(lt,{_hover:{opacity:.8},cursor:`pointer`,onClick:()=>window.open(e.url,`_blank`),children:J(ut,{p:2,alignItems:`center`,children:J(Ot,{src:e.image,fallbackSrc:b,alt:e.name,objectFit:`contain`,rounded:`full`})})})},e.url))})]})},Zu=({selectedCategory:e,onCategoryChange:t,categories:n,darkMode:r})=>{let{t:i}=X();return Y(j,{width:`full`,mb:4,children:[J(z,{fontSize:`sm`,fontWeight:`500`,mb:2,children:i(`Filter by category`)}),Y(en,{spacing:2,children:[J(tn,{children:J(Zt,{size:`md`,borderRadius:`full`,variant:e===null?`solid`:`outline`,colorScheme:r?`gray`:`blackAlpha`,cursor:`pointer`,onClick:()=>t(null),children:i(`All`)})}),n.map(n=>J(tn,{children:J(Ku,{category:n,size:`md`,variant:e===n?`solid`:`outline`,cursor:`pointer`,onClick:()=>t(n)})},n))]})]})},Qu=[{name:`VeBetterDAO`,description:`Engage, earn and prosper by doing sustainable actions.`,external_url:Qe,logo:new URL(`/static/img/coins/64x64/33509.png`,Re).toString(),banner:new URL(`/static/img/icons/vbd.png`,Re).toString(),screenshots:[],social_urls:[],app_urls:[],tweets:[],ve_world:{banner:new URL(`/static/img/icons/vbd.png`,Re).toString()},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:Ue,logo:new URL(`/assets/walletconnect.png`,Ue).toString(),banner:new URL(`/assets/walletconnect.png`,Ue).toString(),screenshots:[],social_urls:[],app_urls:[],tweets:[],ve_world:{banner:new URL(`/assets/walletconnect.png`,Ue).toString()},categories:[]}],$u=({setCurrentContent:e,selectedCategory:t})=>{let{t:n}=X(),{darkMode:r,network:i}=$(),{isolatedView:a}=Ml(),o=V(`colors`,`vechain-kit-text-tertiary`),[s,c]=K(``),[l,u]=K(t||null);W(()=>{t!==void 0&&u(t)},[t]);let{data:d}=tc(),{data:f}=Cc(d?(parseInt(d)-1).toString():`1`),{data:p,isLoading:m,error:h}=Kf(),g=G(()=>{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=Qu.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}=mm();return Y(q,{children:[Y(Z,{children:[J(R,{children:n(`Ecosystem`)}),!a&&J(Oo,{onClick:()=>e(`settings`)}),J(I,{})]}),J(F,{overflowY:`auto`,minH:`300px`,children:Y(B,{spacing:6,w:`full`,children:[J(Xu,{setCurrentContent:e}),S.length>0&&J(z,{fontSize:`sm`,fontWeight:`500`,w:`full`,textAlign:`left`,children:n(`All apps`)}),Y(At,{size:`lg`,children:[J(kt,{placeholder:n(`Search Apps`),value:s,onChange:e=>{c(e.target.value)},bg:r?`#00000038`:`gray.50`,borderRadius:`xl`,height:`56px`,pl:12}),J(jt,{h:`56px`,w:`56px`,pl:4,children:J(Qr,{color:o})})]}),g.length>0&&J(Zu,{selectedCategory:l,onCategoryChange:e=>{u(e)},categories:g,darkMode:r}),Y(wt,{templateColumns:`repeat(2, 1fr)`,gap:4,w:`full`,children:[b&&v.length>0&&J(q,{children:v.map(t=>J(Tt,{children:J(Yu,{name:t.name,image:t.logo,url:t.external_url,setCurrentContent:e,description:t.description,selectedCategory:l})},t.name))}),x&&_.length>0&&J(q,{children:_.map(t=>J(Tt,{children:J(Ju,{xApp:t.app,setCurrentContent:e,selectedCategory:l})},t.id))}),m?J(Tt,{colSpan:2,children:J(pt,{py:4,children:J(Jt,{})})}):h?J(Tt,{colSpan:2,children:J(z,{color:`red.500`,textAlign:`center`,children:n(`Failed to load App Hub apps`)})}):y.length>0?y.map(t=>J(Tt,{children:J(Yu,{name:t.name,image:t.logo,url:t.url,setCurrentContent:e,description:t.description,category:t.category,selectedCategory:l})},t.id)):l&&!x&&J(Tt,{colSpan:2,children:J(pt,{py:4,children:J(z,{children:n(`No apps found in this category`)})})})]})]})}),J(L,{pt:0})]})},ed=({name:e,image:t,url:n,description:r})=>{let{t:i}=X(),{isShortcut:a,addShortcut:o,removeShortcut:s}=mm(),c=a(n);return J(M,{px:4,width:`full`,height:`45px`,variant:`vechainKitSecondary`,borderRadius:`xl`,onClick:()=>{c?s(n):o({name:e,image:t,url:n,description:r})},leftIcon:J(P,{as:c?br:yr}),children:i(c?`Remove from shortcuts`:`Add to shortcuts`)})},td=({setCurrentContent:e,name:t,image:n,url:r,description:i,category:a,selectedCategory:o,logoComponent:s})=>{let{t:c}=X();return Y(q,{children:[Y(Z,{children:[J(R,{children:t}),J(Oo,{onClick:()=>{e(o?{type:`ecosystem-with-category`,props:{selectedCategory:o,setCurrentContent:e}}:`ecosystem`)}}),J(I,{})]}),J(F,{children:Y(B,{spacing:6,align:`center`,w:`full`,children:[Y(xt,{direction:`column`,align:`center`,children:[s||J(Ot,{src:n,alt:t,w:`200px`,h:`200px`,objectFit:`contain`,borderRadius:`xl`}),a&&J(N,{mt:2,children:J(Ku,{category:a})})]}),J(z,{fontSize:`sm`,textAlign:`center`,children:i}),J(z,{fontSize:`sm`,textAlign:`center`,children:c(`Click below to access {{ name }} and explore its features.`,{name:t})})]})}),J(L,{children:Y(B,{w:`full`,spacing:4,children:[Y(M,{variant:`vechainKitSecondary`,onClick:()=>{window.open(r,`_blank`)},children:[c(`Launch {{name}}`,{name:t}),J(P,{as:Pr,ml:2})]}),J(ed,{name:t,image:n,url:r,description:i})]})})]})},nd=({children:e})=>J(lr.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}),rd=({description:e})=>{let{darkMode:t}=$(),n=new URL(`intent/tweet`,Ye);n.searchParams.set(`text`,e);let r=new URL(`share/url`,Fe);r.searchParams.set(`url`,e);let i=new URL(``,fe);return i.searchParams.set(`text`,e),Y(N,{gap:2,children:[J(nd,{children:J(Nt,{href:n.toString(),isExternal:!0,children:J(j,{bg:t?`blackAlpha.700`:`lightgrey`,p:2,borderRadius:`full`,children:J(la,{size:22})})})}),J(nd,{children:J(Nt,{href:r.toString(),isExternal:!0,children:J(j,{bg:`#30abec`,p:2,borderRadius:`full`,children:J(_a,{color:`white`,size:22})})})}),J(nd,{children:J(Nt,{href:i.toString(),isExternal:!0,children:J(j,{bg:`#01cb37`,p:2,borderRadius:`full`,children:J(ya,{size:22,color:`white`})})})})]})},id=({status:e,uiConfig:t,onTryAgain:n,txReceipt:r,txError:i,onClose:a})=>{let{t:o}=X(),{network:s}=$(),c=V(`colors`,`vechain-kit-error`),l=V(`colors`,`vechain-kit-success`),u=V(`colors`,`vechain-kit-text-primary`),d=V(`colors`,`vechain-kit-text-secondary`),f=G(()=>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??J(Jt,{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??J(P,{as:Dr,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??J(P,{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=`${y(s.type).explorerUrl}/${r?.meta.txID}`;return Y(q,{children:[Y(Z,{children:[J(R,{children:p.title}),J(I,{isDisabled:e===`pending`&&!t?.isClosable})]}),J(F,{children:Y(B,{align:`center`,p:6,spacing:3,children:[p.icon,e===`success`&&t?.showShareOnSocials&&Y(B,{mt:2,spacing:3,children:[J(z,{fontSize:`sm`,fontWeight:`bold`,color:d,children:o(`Share on`)}),J(rd,{description:m})]}),p.description&&J(z,{fontSize:e===`ready`?`md`:`sm`,textAlign:`center`,color:e===`error`?c:u,mt:5,style:{lineBreak:`anywhere`},children:p.description})]})}),J(L,{justifyContent:`center`,children:Y(B,{width:`full`,spacing:4,children:[e===`error`&&!!n&&Y(M,{variant:`vechainKitPrimary`,onClick:n,width:`full`,children:[J(P,{mr:2,as:Zr}),o(`Try again`)]}),e===`ready`&&J(M,{onClick:n,variant:`vechainKitPrimary`,width:`full`,children:o(`Confirm`)}),(e===`success`||e===`error`||e===`ready`)&&J(M,{onClick:a,variant:`ghost`,width:`full`,children:o(`Close`)}),t?.showExplorerButton&&r?.meta.txID&&J(Nt,{href:`${y(s.type).explorerUrl}/${r?.meta.txID}`,isExternal:!0,opacity:.5,fontSize:`14px`,textDecoration:`underline`,children:Y(N,{spacing:1,alignItems:`center`,w:`full`,justifyContent:`center`,children:[J(z,{color:d,children:o(`View transaction on the explorer`)}),J(P,{size:`sm`,as:Pr,color:d})]})})]})})]})},ad=({isOpen:e,onClose:t,status:n,uiConfig:r,txReceipt:i,txError:a,onTryAgain:o})=>{let{darkMode:s,theme:c}=$();return e?J(Zd,{darkMode:s,theme:c,children:J(zo,{isOpen:e,onClose:t,allowExternalFocus:!0,blockScrollOnMount:!0,closeOnOverlayClick:n!==`pending`&&r?.isClosable,children:J(id,{status:n,onTryAgain:o,uiConfig:r,txReceipt:i,onClose:t,txError:a})})}):null},od=({txId:e,title:t,description:n,onDone:r,showSocialButtons:i=!1})=>{let{t:a}=X(),{network:o}=$(),s=y(o.type).explorerUrl,c=`${s}/${e}`,l=V(`colors`,`vechain-kit-success`),u=V(`colors`,`vechain-kit-text-primary`),d=V(`colors`,`vechain-kit-text-secondary`);return Y(q,{children:[Y(Z,{children:[J(R,{children:t}),J(I,{})]}),J(F,{children:Y(B,{align:`center`,p:6,spacing:3,children:[J(P,{as:Or,fontSize:`100px`,color:l,"data-testid":`success-icon`}),n&&J(z,{fontSize:`sm`,textAlign:`center`,color:u,children:n}),i&&e&&Y(B,{mt:2,spacing:3,children:[J(z,{fontSize:`sm`,fontWeight:`bold`,color:d,children:a(`Share on`)}),J(rd,{description:c})]})]})}),J(L,{justifyContent:`center`,children:Y(B,{width:`full`,spacing:4,children:[J(M,{onClick:r,variant:`vechainKitSecondary`,width:`full`,children:a(`Done`)}),e&&J(Nt,{href:`${s}/${e}`,isExternal:!0,opacity:.5,fontSize:`14px`,textDecoration:`underline`,children:Y(N,{spacing:1,alignItems:`center`,w:`full`,justifyContent:`center`,children:[J(z,{color:d,children:a(`View transaction on the explorer`)}),J(P,{size:16,as:Pr})]})})]})})]})},sd=({txId:e,title:t,description:n,onDone:r})=>{let{t:i}=X(),{network:a,darkMode:o}=$(),s=y(a.type).explorerUrl;return Y(q,{children:[Y(Z,{children:[J(R,{children:t}),J(I,{})]}),J(F,{children:Y(B,{align:`center`,p:6,spacing:3,children:[J(P,{as:Dr,fontSize:`100px`,color:o?`red.400`:`red.500`,"data-testid":`error-icon`}),n&&J(z,{fontSize:`sm`,textAlign:`center`,children:n})]})}),J(L,{justifyContent:`center`,children:Y(B,{width:`full`,spacing:4,children:[J(M,{onClick:r,variant:`vechainKitSecondary`,width:`full`,children:i(`Done`)}),e&&J(Nt,{href:`${s}/${e}`,isExternal:!0,opacity:.5,fontSize:`14px`,textDecoration:`underline`,children:Y(N,{spacing:1,alignItems:`center`,w:`full`,justifyContent:`center`,children:[J(z,{children:i(`View transaction on the explorer`)}),J(P,{size:16,as:Pr})]})})]})})]})},cd=({isOpen:e,onClose:t,initialContent:n=`profile`})=>{let{account:r}=Q(),{themeConfig:i}=Yd(),{accountModalContent:a,setAccountModalContent:o}=$d();return W(()=>{e&&o(n)},[e,n,o]),J(zo,{isOpen:e,onClose:t,allowExternalFocus:!0,blockScrollOnMount:!0,mobileMinHeight:i?.modal?.useBottomSheetOnMobile?`520px`:`510px`,mobileMaxHeight:i?.modal?.useBottomSheetOnMobile?`520px`:`510px`,desktopMinHeight:`485px`,desktopMaxHeight:`485px`,children:(()=>{if(typeof a==`object`)switch(a.type){case`send-token`:return J(Nl,{...a.props});case`send-token-summary`:return J(Pl,{...a.props});case`swap-token`:return J(zl,{...a.props});case`choose-name`:return J(Bl,{...a.props});case`choose-name-search`:return J(Wl,{...a.props});case`choose-name-summary`:return J(Gl,{...a.props});case`app-overview`:return J(td,{...a.props,setCurrentContent:o});case`disconnect-confirm`:return J(Du,{...a.props});case`remove-wallet-confirm`:return J(ju,{...a.props});case`account-customization`:return J(ou,{...a.props});case`account-customization-summary`:return J(su,{...a.props});case`successful-operation`:return J(od,{...a.props});case`failed-operation`:return J(sd,{...a.props});case`upgrade-smart-account`:return J(du,{...a.props});case`faq`:return J(ql,{...a.props});case`terms-and-privacy`:return J(Eu,{...a.props});case`ecosystem-with-category`:return J($u,{setCurrentContent:o,selectedCategory:a.props.selectedCategory});case`select-wallet`:return J(Au,{setCurrentContent:o,onClose:t,returnTo:a.props.returnTo,onLogoutSuccess:a.props.onLogoutSuccess});case`main`:return J(Al,{setCurrentContent:o,onClose:t,wallet:r,switchFeedback:a.props?.switchFeedback});case`profile`:return J(uu,{setCurrentContent:o,onLogoutSuccess:()=>{t()},switchFeedback:a.props?.switchFeedback})}switch(a){case`main`:return J(Al,{setCurrentContent:o,onClose:t,wallet:r});case`settings`:return J(bu,{setCurrentContent:o,onLogoutSuccess:()=>{t()}});case`profile`:return J(uu,{setCurrentContent:o,onLogoutSuccess:()=>{t()}});case`assets`:return J(fu,{setCurrentContent:o});case`notifications`:return J(Wu,{setCurrentContent:o});case`receive-token`:return J(Fl,{setCurrentContent:o});case`swap-token`:return J(zl,{setCurrentContent:o});case`connection-details`:return J(Iu,{onGoBack:()=>o(`settings`)});case`privy-linked-accounts`:return J(Ru,{onBack:()=>o(`settings`)});case`ecosystem`:return J($u,{setCurrentContent:o});case`add-custom-token`:return J(pu,{setCurrentContent:o});case`change-currency`:return J(hu,{setCurrentContent:o});case`change-language`:return J(gu,{setCurrentContent:o});case`gas-token-settings`:return J(yu,{setCurrentContent:o});case`account-customization`:return J(ou,{setCurrentContent:o});default:return null}})()})},ld=({loadingText:e,title:t,onTryAgain:n,onClose:r,onGoBack:i,showBackButton:a=!0})=>{let{t:o}=X(),[s,c]=H.useState(!1);return H.useEffect(()=>{let e=setTimeout(()=>{c(!0)},7e3);return()=>clearTimeout(e)},[]),Y(q,{children:[J(Z,{children:Y(R,{children:[a&&J(Oo,{onClick:i}),t??o(`Connecting...`),J(I,{onClick:r})]})}),Y(F,{children:[J(B,{align:`center`,p:6,gap:0,w:`full`,justifyContent:`center`,minH:`150px`,children:J(Jt,{size:`xl`})}),e&&!s&&J(z,{size:`sm`,textAlign:`center`,children:e}),s&&Y(B,{mt:4,spacing:2,children:[J(z,{color:`orange.300`,size:`sm`,textAlign:`center`,children:o(`This is taking longer than expected.`)}),J(z,{size:`sm`,textAlign:`center`,children:o(`You may want to try establishing the connection again.`)})]})]}),J(L,{justifyContent:`center`,children:s&&Y(M,{variant:`vechainKitPrimary`,onClick:n,children:[J(P,{mr:2,as:Zr}),o(`Try again`)]})})]})},ud=({error:e,onClose:t,onTryAgain:n,onGoBack:r})=>{let{t:i}=X(),a=ur();return Y(q,{children:[J(Z,{children:Y(R,{children:[J(Oo,{onClick:r}),i(`Connection Failed`),J(I,{onClick:t})]})}),J(F,{children:Y(B,{align:`center`,p:6,w:`full`,justifyContent:`center`,minH:`100px`,gap:4,children:[J(lr.div,{transition:{duration:4,ease:`easeInOut`,repeat:a?0:1/0},animate:{scale:a?[1]:[1,1.1,1]},children:J(P,{as:Dr,color:`#ef4444`,fontSize:`60px`,opacity:.5})}),J(z,{w:`full`,size:`sm`,textAlign:`center`,children:e})]})}),J(L,{justifyContent:`center`,children:Y(M,{variant:`vechainKitPrimary`,onClick:n,children:[J(P,{mr:2,as:Zr}),i(`Try again`)]})})]})},dd=({onClose:e,appsInfo:t,isLoading:n,setCurrentContent:r,showBackButton:i=!0})=>{let{t:a}=X(),o=V(`colors`,`vechain-kit-text-primary`),{setConnectionCache:s}=Bf(),{login:c}=Oc(),l=async(n,i)=>{r({type:`loading`,props:{title:`${a(`Connecting with`)} ${i}`,loadingText:a(`Please approve the request in the connection request window...`),onTryAgain:()=>{l(n,i)}}});try{await c(n),s({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 a=e?.message;if(a&&g(a)){r({type:`ecosystem`,props:{appsInfo:t,isLoading:!1}});return}r({type:`error`,props:{error:(e instanceof Error?e:Error(`An unexpected issue occurred while logging in with this app. Please try again or contact support.`)).message,onTryAgain:()=>{l(n,i)}}})}};return J(j,{children:Y(q,{children:[J(Z,{children:Y(R,{children:[i&&J(Oo,{onClick:()=>r(`main`)}),a(`Already have an x2earn app wallet?`),J(I,{onClick:e})]})}),Y(F,{children:[n&&J(B,{minH:`200px`,w:`full`,justifyContent:`center`,children:J(Jt,{})}),!n&&t&&J(B,{spacing:4,w:`full`,pb:6,children:t.map(e=>Y(M,{variant:`loginIn`,fontSize:`14px`,fontWeight:`400`,p:6,borderRadius:16,w:`full`,onClick:()=>{l(e.id,e.name)},justifyContent:`flex-start`,children:[J(Ot,{src:e.logo_url,alt:e.name,w:`30px`}),J(z,{ml:5,children:e.name})]},e.id))}),!n&&!t&&J(z,{textAlign:`center`,color:o,children:a(`No application from VeChain ecosystem is available to login.`)})]}),J(L,{pt:0})]})})},fd=({isOpen:e,onClose:t,initialContent:n=`main`,preventAutoClose:r=!1})=>{let{connection:i}=Q(),[a,o]=K(n);W(()=>{e&&o(n)},[e,n,o]),W(()=>{i.isConnected&&e&&!r&&t()},[i.isConnected,e,t,r]);let s=(()=>{if(!a)return J(kl,{setCurrentContent:o});switch(a){case`main`:return J(kl,{setCurrentContent:o});case`faq`:return J(ql,{onGoBack:()=>o(`main`)})}if(typeof a==`object`&&`type`in a)switch(a.type){case`ecosystem`:return J(dd,{onClose:t,appsInfo:a.props.appsInfo,isLoading:a.props.isLoading,setCurrentContent:o,showBackButton:a.props.showBackButton});case`loading`:return J(ld,{title:a.props.title,loadingText:a.props.loadingText,onTryAgain:a.props.onTryAgain,onClose:t,onGoBack:()=>o(`main`),showBackButton:a.props.showBackButton});case`error`:return J(ud,{error:a.props.error,onClose:t,onTryAgain:a.props.onTryAgain,onGoBack:()=>o(`main`)})}return null})();return s?J(zo,{isOpen:e,onClose:t,allowExternalFocus:!0,blockScrollOnMount:!0,mobileMinHeight:`260px`,mobileMaxHeight:`400px`,desktopMinHeight:`250px`,desktopMaxHeight:`400px`,children:s}):J(zo,{isOpen:e,onClose:t,allowExternalFocus:!0,blockScrollOnMount:!0,mobileMinHeight:`260px`,mobileMaxHeight:`400px`,desktopMinHeight:`250px`,desktopMaxHeight:`400px`,children:J(kl,{setCurrentContent:o})})},pd=({onClick:e,text:t,icon:n,customIcon:r,rightIcon:i,style:a,variant:o=`loginIn`,iconWidth:s=`25px`})=>t?t?Y(M,{...a,variant:o,w:`full`,onClick:e,children:[Y(N,{w:`full`,justify:`flex-start`,gap:2,children:[r||J(P,{as:n,w:s,h:s}),J(z,{opacity:.9,children:t})]}),i]}):null:J(M,{...a,variant:o,w:`full`,onClick:e,children:r||J(P,{as:n,w:`20px`,h:`20px`})}),md=({isLoading:e,buttonStyle:t})=>{let{t:n}=X(),{loginMethods:r,darkMode:i,privyEcosystemAppIDS:a}=$(),o=r?.some(({method:e})=>e===`ecosystem`),{open:s}=tf(),{data:c,isLoading:l}=Ho(a),u=U(e=>{let t=typeof e==`function`?e(`main`):e;typeof t==`object`&&`type`in t?t.type===`ecosystem`?s({type:`ecosystem`,props:{...t.props,showBackButton:!1}}):t.type===`loading`?s({type:`loading`,props:{...t.props,showBackButton:!1}}):s(t):s(t)},[s]);return J(Vt,{placement:`bottom-start`,size:`xl`,closeOnBlur:!1,variant:`vechainKitBase`,children:({isOpen:r})=>Y(q,{children:[J(Gt,{children:Y(M,{isLoading:e,...t,isActive:r,children:[n(`Login`),J(P,{ml:2,as:Cr,transform:r?`rotate(180deg)`:`rotate(0deg)`,transition:`transform 0.2s`})]})}),Y(Ut,{children:[J(Ht,{children:J(Dl,{setCurrentContent:u})}),J(Wt,{borderTop:`none`,pb:`15px`,children:o&&J(N,{justify:`center`,w:`full`,children:J(Ol,{isDark:i,appsInfo:Object.values(c||{}),isLoading:l,setCurrentContent:u})})})]})]})})},hd=({variant:e})=>{let{account:t}=Q();return t?e===`icon`?null:e===`iconAndDomain`?t.domain?J(z,{fontSize:`sm`,children:r(t?.domain??``,16,0)}):J(z,{fontSize:`sm`,children:d(t.address??``,6,4)}):e===`iconDomainAndAssets`?Y(N,{spacing:4,children:[Y(B,{spacing:0,alignItems:`flex-start`,children:[t.domain&&J(z,{fontSize:`sm`,fontWeight:`bold`,children:r(t?.domain??``,16,0)}),J(z,{fontSize:t.domain?`xs`:`sm`,opacity:t.domain?.5:1,"data-testid":`trimmed-address`,children:d(t.address??``,4,4)})]}),J(Zl,{address:t.address??``,maxIcons:3})]}):Y(B,{spacing:0,alignItems:`flex-start`,children:[t.domain&&J(z,{fontSize:`sm`,fontWeight:`bold`,children:r(t?.domain??``,16,0)}),J(z,{fontSize:t.domain?`xs`:`sm`,opacity:t.domain?.5:1,children:d(t.address??``,4,4)})]}):J(Jt,{})},gd=({mobileVariant:e=`iconAndDomain`,desktopVariant:t=`iconAndDomain`,onOpen:n,buttonStyle:r={}})=>{let{account:i}=Q(),[a]=pn(`(min-width: 768px)`);return J(M,{...r,onClick:n,w:`full`,minH:`45px`,maxW:`fit-content`,"data-testid":`wallet-button`,children:Y(N,{w:`full`,minW:`fit-content`,children:[J(km,{wallet:i,props:{width:30,height:30,minWidth:30,minHeight:30}}),J(hd,{variant:a?t:e})]})})},_d=({mobileVariant:e=`iconAndDomain`,desktopVariant:t=`iconDomainAndAddress`,buttonStyle:n,connectionVariant:r=`modal`,label:i=`Login`})=>{let{darkMode:a,loginMethods:o,theme:s}=$(),c=o?.length===1&&o[0].method===`dappkit`,{connection:l,account:u}=Q(),{setSource:d,connectV2:f}=$n(),[p]=pn(`(max-width: 768px)`),m=fn(),h=fn(),{open:g}=tr();return Y(Zd,{darkMode:a,theme:s,children:[l.isConnected&&u?J(gd,{mobileVariant:e,desktopVariant:t,onOpen:h.onOpen,buttonStyle:n}):r===`popover`&&!p?J(md,{isLoading:l.isLoading,buttonStyle:n}):J(M,{isLoading:l.isLoading,onClick:()=>{l.isInAppBrowser?(d(`veworld`),f(null)):c?g():m.onOpen()},...n,children:i}),J(fd,{isOpen:m.isOpen,onClose:m.onClose}),J(cd,{isOpen:h.isOpen,onClose:h.onClose})]})},vd=()=>{let{darkMode:e}=$(),t=25/2,[n]=pn(`(max-width: 280px)`),[r]=pn(`(max-width: 380px)`);return Y(N,{spacing:0,ml:0,children:[J(gt,{size:`25px`,borderRadius:`full`,bg:`#F8F8F8`,p:2,alignItems:`center`,justifyContent:`center`,zIndex:3,children:J(P,{as:na,fontSize:`20px`})}),!n&&J(gt,{ml:`-${t}px`,size:`25px`,borderRadius:`full`,bg:`black`,p:2,alignItems:`center`,justifyContent:`center`,zIndex:2,children:J(P,{as:la,color:`white`,fontSize:`20px`})}),!n&&!r&&J(gt,{ml:`-${t}px`,zIndex:1,size:`25px`,borderRadius:`full`,bg:`#5865F2`,p:2,alignItems:`center`,justifyContent:`center`,children:J(P,{as:ca,color:`white`,fontSize:`20px`})}),J(P,{zIndex:1,as:Xr,color:e?`black`:`white`,fontSize:`15px`})]})},yd=({status:e,txReceipt:t,txError:n,onTryAgain:r,description:i,onClose:a})=>{let{t:o}=X(),{network:s}=$(),c=y(s.type).explorerUrl,l=G(()=>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:J(Jt,{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:J(P,{as:Dr,color:`red.500`,fontSize:`40px`,"data-testid":`error-icon-toast`}),title:o(`Transaction failed`),closeDisabled:!1,description:l};case`success`:return{icon:J(P,{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?Y(N,{justify:`space-between`,alignItems:`flex-start`,w:`full`,children:[J(B,{spacing:4,children:Y(N,{spacing:4,w:`full`,justifyContent:`flex-start`,alignItems:`flex-start`,children:[u.icon,Y(B,{w:`full`,align:`flex-start`,spacing:2,children:[Y(B,{spacing:1,w:`full`,children:[J(Et,{w:`full`,size:`xs`,children:u.title}),u.description&&J(z,{fontSize:`xs`,children:u.description})]}),(e===`error`||e===`ready`)&&J(M,{size:`xs`,onClick:r,children:e===`error`?Y(q,{children:[J(P,{mr:2,as:Zr}),o(`Try again`)]}):o(`Confirm`)}),t&&e!==`pending`&&Y(Nt,{fontSize:`xs`,isExternal:!0,href:`${c}/${t.meta.txID}`,children:[o(`View on explorer`),` `,J(P,{as:Pr})]})]})]})}),!u.closeDisabled&&J(Dt,{onClick:a,size:`sm`,borderRadius:`full`,"aria-label":`Close`,icon:J(P,{as:li,boxSize:4})})]}):null},bd=({isOpen:e,onClose:t,status:n,txReceipt:r,txError:i,onTryAgain:a,description:o})=>{let{darkMode:s}=$();return e?J(j,{position:`fixed`,bottom:`5`,left:`5`,zIndex:`11111`,bg:s?`#1f1f1e`:`white`,borderRadius:`md`,p:5,boxShadow:`lg`,maxW:`sm`,minW:`300px`,children:J(yd,{status:n,txReceipt:r,txError:i,onTryAgain:a,description:o,onClose:t})}):null},xd=({txId:e,title:t,description:n,onDone:r,showSocialButtons:i=!1})=>{let{t:a}=X(),{network:o}=$(),s=y(o.type).explorerUrl,c=`${s}/${e}`,l=V(`colors`,`vechain-kit-success`);return Y(q,{children:[Y(Z,{children:[J(R,{children:t}),J(I,{})]}),J(F,{children:Y(B,{align:`center`,p:6,spacing:3,children:[J(lr.div,{transition:{duration:4,ease:`easeInOut`,repeat:1/0},animate:{scale:[1,1.1,1]},children:J(P,{as:Or,fontSize:`100px`,color:l})}),n&&J(z,{fontSize:`sm`,textAlign:`center`,children:n}),i&&e&&Y(B,{mt:2,children:[J(z,{fontSize:`xs`,children:a(`Share on`)}),J(rd,{description:c})]})]})}),J(L,{justifyContent:`center`,children:Y(B,{width:`full`,spacing:4,children:[J(M,{onClick:r,variant:`vechainKitSecondary`,width:`full`,children:a(`Done`)}),e&&J(Nt,{href:`${s}/${e}`,isExternal:!0,opacity:.5,fontSize:`14px`,textDecoration:`underline`,children:Y(N,{spacing:1,alignItems:`center`,w:`full`,justifyContent:`center`,children:[J(z,{children:a(`View transaction on the explorer`)}),J(P,{size:16,as:Pr})]})})]})})]})},Sd=({setCurrentContent:e,handleClose:t,style:n})=>{let{t:r}=X(),{smartAccount:i,connectedWallet:a}=Q(),{data:o}=Np(i?.address??``,a?.address??``,3),{sendTransaction:s,isTransactionPending:c,isWaitingForWalletConfirmation:l,error:u,txReceipt:d}=Rp({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 Y(q,{children:[Y(Z,{children:[J(R,{children:r(`Account upgrade required`)}),J(I,{})]}),J(F,{children:Y(B,{spacing:10,align:`stretch`,justifyContent:`center`,children:[J(z,{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).`)}),Y(N,{align:`center`,justifyContent:`space-evenly`,rounded:`md`,children:[Y(j,{position:`relative`,display:`inline-block`,children:[J(gt,{size:`60px`,bg:`gray.200`,children:J(Ot,{src:i?.image,alt:r(`Profile Picture`),w:`100%`,h:`100%`,borderRadius:`full`,objectFit:`cover`})}),J(Et,{position:`absolute`,top:`-5`,right:`-5`,color:`#D23F63`,fontSize:`28px`,children:`v1`})]}),J(P,{as:hr,color:`#3DBA67`}),Y(j,{position:`relative`,display:`inline-block`,children:[J(gt,{size:`60px`,bg:`gray.200`,children:J(Ot,{src:i?.image,alt:r(`Profile Picture`),w:`100%`,h:`100%`,borderRadius:`full`,objectFit:`cover`})}),J(Et,{position:`absolute`,top:`-5`,right:`-5`,color:`#3DBA67`,fontSize:`28px`,children:`v3`})]})]}),Y(it,{status:`info`,borderRadius:`md`,children:[J(ot,{}),Y(j,{children:[J(st,{fontSize:`sm`,children:r(`Benefits of this upgrade:`)}),J(at,{fontSize:`xs`,children:Y(B,{align:`start`,spacing:0,mt:1,children:[Y(z,{fontSize:`xs`,lineHeight:`1.2`,children:[`• `,r(`Improved security features`)]}),Y(z,{fontSize:`xs`,children:[`• `,r(`Better transaction handling`)]}),Y(z,{fontSize:`xs`,children:[`•`,` `,r(`Enhanced compatibility with dApps`)]}),Y(z,{fontSize:`xs`,children:[`•`,` `,r(`Reduced gas costs for operations`)]})]})})]})]})]})}),J(L,{justifyContent:`center`,children:J(B,{spacing:3,w:`full`,children:J(Am,{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})})})]})},Cd=({isOpen:e,onClose:t,style:n})=>{let[r,i]=K(`upgrade-smart-account`);return W(()=>{e&&i(`upgrade-smart-account`)},[e]),J(zo,{isOpen:e,onClose:t,allowExternalFocus:!0,blockScrollOnMount:!0,size:n?.modalSize,children:(()=>{if(typeof r==`object`)switch(r.type){case`successful-operation`:return J(xd,{...r.props})}else if(r===`upgrade-smart-account`)return J(Sd,{setCurrentContent:i,handleClose:t,style:n})})()})},{definePartsStyle:wd,defineMultiStyleConfig:Td}=nn(Ea.keys),Ed=e=>({vechainKitBase:wd({dialog:{scrollbarWidth:`none`,overflow:`scroll`,overflowX:`hidden`,rounded:e.modal.rounded??e.borders.radius.modal,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:{...e.buttons.button.hoverBg?{bg:e.buttons.button.hoverBg}:{opacity:.8}},_active:{bg:e.buttons.button.bg,opacity:.8}},header:{w:`full`,color:e.colors.text.primary,fontSize:e.fonts.sizes.large,fontWeight:e.fonts.weights.bold,textAlign:`center`,paddingBottom:5,paddingTop:5}})}),Dd=e=>Td({variants:Ed(e),defaultProps:{variant:`vechainKitBase`}}),{definePartsStyle:Od,defineMultiStyleConfig:kd}=nn(Ta.keys),Ad=e=>({vechainKitBase:Od({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}`}}),vechainKitWalletCard:Od({container:{backgroundColor:e.colors.background.card,borderRadius:e.borders.radius.medium,width:`full`,cursor:`pointer`,position:`relative`}}),featureAnnouncement:Od({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:Od({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`}})}),jd=e=>kd({variants:Ad(e),defaultProps:{variant:`vechainKitBase`}}),Md=an({borderRadius:`12px`}),Nd=e=>({loginIn:an(()=>({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,rounded:e.buttons.loginButton.rounded??e.borders.radius.large,backdropFilter:e.buttons.loginButton.backdropFilter,_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:an(()=>({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:an(()=>({fontSize:e.fonts.sizes.medium,px:4,width:`full`,height:`60px`,rounded:e.buttons.primaryButton.rounded??e.borders.radius.large,bg:e.buttons.primaryButton.bg,color:e.buttons.primaryButton.color,border:e.buttons.primaryButton.border,backdropFilter:e.buttons.primaryButton.backdropFilter,_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:an(()=>({fontSize:e.fonts.sizes.medium,px:4,width:`full`,height:`60px`,rounded:e.buttons.button.rounded??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,backdropFilter:e.buttons.button.backdropFilter,_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:an(()=>({fontSize:e.fonts.sizes.medium,px:4,width:`full`,height:`60px`,rounded:e.buttons.tertiaryButton.rounded??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,backdropFilter:e.buttons.tertiaryButton.backdropFilter,_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:an(()=>({px:4,width:`full`,height:`60px`,rounded:e.buttons.button.rounded??e.borders.radius.large,bg:e.colors.error+`1f`,color:e.colors.error,border:e.buttons.button.border===`none`?`none`:e.buttons.button.border,backdropFilter:e.buttons.button.backdropFilter,_hover:{opacity:.8,_disabled:{opacity:.5,bg:e.colors.error+`1f`}},_disabled:{opacity:.5,cursor:`not-allowed`},transition:`all 0.2s`})),vechainKitHeaderIconButtons:an(()=>({bg:e.buttons.button.bg,color:e.buttons.button.color,border:e.buttons.button.border===`none`?`none`:e.buttons.button.border,backdropFilter:e.buttons.button.backdropFilter,_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`,rounded:`full`,mt:`8px`})),actionButton:an(()=>({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:an(()=>({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:an(()=>({color:e.colors.text.primary,_hover:{color:e.colors.text.secondary,textDecoration:`underline`},_active:{color:e.colors.text.primary},transition:`all 0.2s`}))}),Pd=e=>on({baseStyle:Md,variants:Nd(e)}),Fd=e=>on({baseStyle:Md,variants:Nd(e)}),Id=e=>on({baseStyle:Md,variants:Nd(e),defaultProps:{variant:`vechainKitHeaderIconButtons`}}),{definePartsStyle:Ld,defineMultiStyleConfig:Rd}=nn(Da.keys),zd=e=>({vechainKitBase:Ld({popper:{zIndex:1e3},content:{borderRadius:e.borders.radius.xl,border:e.colors.border.modal,backgroundColor:e.colors.background.modal,backdropFilter:e.effects.backdropFilter.modal,boxShadow:`0px 4px 16px rgba(0, 0, 0, 0.12)`,minWidth:`380px`},body:{padding:`16px`}})}),Bd=e=>Rd({variants:zd(e),defaultProps:{variant:`vechainKitBase`}}),Vd=(e,t)=>({useSystemColorMode:!1,disableTransitionOnChange:!1,components:{Modal:Dd(t),Card:jd(t),Button:Pd(t),IconButton:Fd(t),CloseButton:Id(t),Popover:Bd(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,"vechain-kit-button-primary-bg":t.buttons.primaryButton.bg,"vechain-kit-button-primary-color":t.buttons.primaryButton.color},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:cn.fonts,fontSizes:{...cn.fontSizes,sm:t.fonts.sizes.small,md:t.fonts.sizes.medium,lg:t.fonts.sizes.large},fontWeights:{...cn.fontWeights,normal:t.fonts.weights.normal,medium:t.fonts.weights.medium,bold:t.fonts.weights.bold},colors:cn.colors,space:cn.space}),Hd=(e,t)=>{let n=sn(Vd(e,vo(_o(e),yo(t,e))));return n.styles.global=()=>({}),n.__cssVars&&(n.__cssVars.global=()=>({})),n},{ToastContainer:Ud}=rn(),Wd=()=>wa({key:`vechain-kit`,prepend:!0}),Gd=({bodyFont:e,headingFont:t})=>J(xa,{styles:Sa`
|
|
128
128
|
/* define CSS layers with proper priority order */
|
|
129
129
|
@layer vechain-kit, host-app;
|
|
130
130
|
|
|
@@ -197,7 +197,7 @@ import{$ as e,C as t,D as n,G as r,H as i,J as a,Q as o,S as s,T as c,U as l,V a
|
|
|
197
197
|
font-family: ${t} !important;
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
|
-
`}),Kd=({children:e,theme:t,bodyFont:n,headingFont:r})=>Y(ba,{value:G(()=>Wd(),[]),children:[J(Gd,{bodyFont:n,headingFont:r}),J(mt,{theme:t,resetCSS:!1,portalZIndex:void 0,children:e})]}),qd=({darkMode:e})=>{try{if(h(`[data-chakra-color-mode]`))return null}catch(e){console.error(e)}return J(vt,{initialColorMode:e?`dark`:`light`})},Jd=gn({portalRootRef:void 0,tokens:void 0,themeConfig:void 0}),Yd=()=>{let e=_n(Jd);if(!e)throw Error(`useVechainKitTheme must be used within a VechainKitThemeProvider`);return e},Xd=({darkMode:e=!1})=>{let{setColorMode:t,colorMode:n}=un();return W(()=>{let r=e?`dark`:`light`;n!==r&&t(r)},[e]),J(q,{})},Zd=({children:e,darkMode:t=!1,theme:n})=>{let r=vn(null),i=_n($m),a=i?i.theme:void 0,o=n??a,s=G(()=>vo(_o(t),yo(o,t)),[t,o]),c=G(()=>({...Hd(t,o),config:{...Hd(t,o).config,initialColorMode:t?`dark`:`light`}}),[t,o]);return Y(Jd.Provider,{value:{portalRootRef:r,tokens:s,themeConfig:o},children:[J(qd,{darkMode:t}),Y(Kd,{theme:c,bodyFont:s.fonts.body,headingFont:s.fonts.heading,children:[J(Xd,{darkMode:t}),J(j,{id:`vechain-kit-root`,ref:r,bg:`transparent`,borderRadius:`12px`,children:e})]}),J(Ud,{})]})},Qd=gn(null),$d=()=>{let e=_n(Qd);if(!e)throw Error(`useModal must be used within ModalProvider`);return e},ef=({children:e})=>{let{darkMode:t,theme:n}=$(),[r,i]=K(!1),[a,o]=K(`main`),[s,c]=K(!1),{setSource:l,connectV2:u}=$n(),d=U((e,t)=>{A()&&window.vechain&&window.vechain.isInAppBrowser?(l(`veworld`),u(null)):(o(e??`main`),c(t??!1),i(!0))},[]),f=U(()=>{i(!1),o(`main`),c(!1)},[]),[p,m]=K(!1),[h,g]=K(!1),[_,v]=K(`main`),y=U((e,t)=>{v(e??`main`),g(t?.isolatedView??!1),m(!0)},[]),b=U(()=>{m(!1),v(`main`),setTimeout(()=>{g(!1)},300)},[]),[x,S]=K(!1),C=U(()=>S(!0),[]),w=U(()=>S(!1),[]),[T,E]=K(!1),D=U(()=>E(!0),[]),O=U(()=>E(!1),[]),[k,ee]=K(!1),[te,ne]=K(void 0),re=U(e=>{ne(e),ee(!0)},[]),ie=U(()=>ee(!1),[]);return Y(Qd.Provider,{value:{openConnectModal:d,closeConnectModal:f,isConnectModalOpen:r,connectModalContent:a,setConnectModalContent:o,connectModalPreventAutoClose:s,setConnectModalPreventAutoClose:c,openAccountModal:y,closeAccountModal:b,isAccountModalOpen:p,setAccountModalContent:v,accountModalContent:_,isolatedView:h,openTransactionModal:C,closeTransactionModal:w,isTransactionModalOpen:x,openTransactionToast:D,closeTransactionToast:O,isTransactionToastOpen:T,openUpgradeSmartAccountModal:re,closeUpgradeSmartAccountModal:ie,isUpgradeSmartAccountModalOpen:k},children:[e,Y(Zd,{darkMode:t,theme:n,children:[J(fd,{isOpen:r,onClose:f,initialContent:a,preventAutoClose:s}),J(cd,{isOpen:p,onClose:b,initialContent:_}),J(Cd,{isOpen:k,onClose:ie,style:te})]})]})},tf=()=>{let{loginMethods:e}=$(),t=e?.length===1&&e[0].method===`dappkit`,{openConnectModal:n,closeConnectModal:r,isConnectModalOpen:i}=$d(),{open:a,close:o}=tr();return{open:t?a:e=>n(e),close:t?o:r,isOpen:t?!1:i}},nf=({children:e})=>J(q,{children:e}),rf=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=$d();return{open:()=>e(),close:t,isOpen:n}},af=({children:e})=>J(q,{children:e}),of=()=>{let{openTransactionModal:e,closeTransactionModal:t,isTransactionModalOpen:n}=$d();return{open:e,close:t,isOpen:n}},sf=({children:e})=>J(q,{children:e}),cf=()=>{let{openTransactionToast:e,closeTransactionToast:t,isTransactionToastOpen:n}=$d();return{open:e,close:t,isOpen:n}},lf=({children:e})=>J(q,{children:e}),uf=()=>{let{connection:e}=Q(),{openConnectModal:t,closeConnectModal:n,isConnectModalOpen:r,openAccountModal:i,closeAccountModal:a,isAccountModalOpen:o}=$d();return{open:n=>{e.isConnected?i(void 0,n):t()},close:()=>{o&&a(),r&&n()},isOpen:r||o}},df=({children:e})=>J(q,{children:e}),ff=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n,setAccountModalContent:r}=$d();return{open:t=>{e({type:`choose-name`,props:{setCurrentContent:r,onBack:()=>r(`main`),initialContentSource:`main`}},t)},close:()=>{t()},isOpen:n}},pf=({children:e})=>J(q,{children:e}),mf=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n,setAccountModalContent:r}=$d();return{open:t=>{e({type:`send-token`,props:{setCurrentContent:r}},t)},close:()=>{t()},isOpen:n}},hf=({children:e})=>J(q,{children:e}),gf=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n,setAccountModalContent:r}=$d();return{open:t=>{e({type:`swap-token`,props:{setCurrentContent:r,fromTokenAddress:t?.fromTokenAddress,toTokenAddress:t?.toTokenAddress}},{isolatedView:t?.isolatedView})},close:()=>{t()},isOpen:n}},_f=({children:e})=>J(q,{children:e}),vf=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=$d();return{open:t=>{e(`ecosystem`,t)},close:()=>{t()},isOpen:n}},yf=({children:e})=>J(q,{children:e}),bf=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=$d();return{open:t=>{e(`notifications`,t)},close:()=>{t()},isOpen:n}},xf=({children:e})=>J(q,{children:e}),Sf=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n,setAccountModalContent:r}=$d();return{open:t=>{e({type:`faq`,props:{onGoBack:()=>r(`main`),showLanguageSelector:!1}},t)},close:()=>{t()},isOpen:n}},Cf=({children:e})=>J(q,{children:e}),wf=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n,setAccountModalContent:r}=$d();return{open:()=>{e({type:`account-customization`,props:{setCurrentContent:r}})},close:()=>{t()},isOpen:n}},Tf=({children:e})=>J(q,{children:e}),Ef=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=$d();return{open:t=>{e(`receive-token`,t)},close:()=>{t()},isOpen:n}},Df=({children:e})=>J(q,{children:e}),Of=()=>{let{privy:e,loginMethods:t}=$(),n=e?.appId===_,r=e=>t?Array.isArray(e)?e.some(e=>t.some(t=>t.method===e)):t.some(t=>t.method===e):!0,i=G(()=>t?t.length===0||r(`ecosystem`):!0,[t]),a=G(()=>r(`vechain`),[t]),o=G(()=>r(`dappkit`),[t]),s=G(()=>r(`passkey`),[t]),c=G(()=>r(`email`),[t]),l={showGoogleLogin:G(()=>r(`google`),[t]),showEmailLogin:c,showPasskey:s,showVeChainLogin:a,showDappKit:o,showEcosystem:i,showMoreLogin:G(()=>r(`more`),[t]),showGithubLogin:G(()=>r(`github`),[t]),isOfficialVeChainApp:!1};return e?n?{...l,isOfficialVeChainApp:!0}:{...l}:{...l,showGoogleLogin:!1,showEmailLogin:!1,showPasskey:!1,showMoreLogin:!1}},kf=e=>{let{openUpgradeSmartAccountModal:t,closeUpgradeSmartAccountModal:n,isUpgradeSmartAccountModalOpen:r}=$d();return{open:()=>t(e),close:n,isOpen:r}},Af=({children:e})=>J(q,{children:e}),jf=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=$d();return{open:t=>{e(`profile`,t)},close:()=>{t()},isOpen:n}},Mf=({children:e})=>J(q,{children:e}),Nf=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=$d();return{open:t=>{e(`settings`,t)},close:()=>{t()},isOpen:n}},Pf=({children:e})=>J(q,{children:e}),Ff=()=>{let[e,t]=K(!1),[n,r]=K(null),[i,a]=K(null),{connection:o,account:s}=Q(),{requestCertificate:c}=er(),l=Qm();return{signMessage:U(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,s?.address]),isSigningPending:e,signature:n,error:i,reset:U(()=>{t(!1),r(null),a(null)},[])}},If=()=>{let[e,t]=K(!1),[n,r]=K(null),[i,a]=K(null),{signer:o}=$n(),{connection:s}=Q(),c=Qm();return{signTypedData:U(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:U(()=>{t(!1),r(null),a(null)},[])}},Lf=()=>{let{loginWithPasskey:e}=Un();return{loginWithPasskey:async()=>{try{await e()}catch(e){throw e}}}};let Rf=!1;const zf=()=>{let{createWallet:e}=Bn(),{initOAuth:t}=Hn({onComplete:U(async({isNewUser:t})=>{if(t&&!Rf){Rf=!0;try{await e()}catch(e){throw Rf=!1,console.error(`Failed to create wallet:`,e),e}}},[e])});return{initOAuth:async({provider:e})=>{try{await t({provider:e})}catch(e){throw e}}}},Bf=()=>{let e=`vechain_kit_cross_app_connection`;return{setConnectionCache:U(t=>{let n={timestamp:Date.now(),ecosystemApp:t};de(e,JSON.stringify(n))},[]),getConnectionCache:U(()=>{let t=x(e);return t?JSON.parse(t):null},[]),clearConnectionCache:U(()=>{w(e)},[])}},Vf=()=>{let{login:e}=Oc(),{setConnectionCache:t}=Bf(),{data:n}=Ho([_]);return{login:async()=>{try{await e(_),t({name:`VeChain`,logoUrl:n?.[_]?.logo_url,appId:_,website:Qe})}catch(e){throw wc({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.`})}}}},Hf=`vechain-kit-app-hub-apps`,Uf=`vechain-kit-app-hub-apps-expiry`,Wf=()=>[`VECHAIN_KIT`,`appHub`,`apps`],Gf=async()=>{if(typeof window<`u`)try{let e=x(Hf),t=x(Uf);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=new URL(`contents/apps`,Ie),t=await fetch(e);if(!t.ok)throw Error(`Failed to fetch app directories`);let n=(await t.json()).map(async e=>{if(e.type!==`dir`)return null;let t=new URL(`master/apps/${e.name}/manifest.json`,Ge),n=await fetch(t);if(!n.ok)return console.warn(`Failed to fetch manifest for ${e.name}`),null;try{let t=await n.json(),r=new URL(`master/apps/${e.name}/logo.png`,Ge);return{id:e.name,name:t.name,description:t.desc,url:t.href,logo:r.toString(),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}}),r=(await Promise.all(n)).filter(e=>e!==null);if(typeof window<`u`)try{de(Hf,JSON.stringify(r)),de(Uf,(Date.now()+864e5).toString())}catch(e){console.warn(`Failed to cache app-hub data:`,e)}return r},Kf=()=>or({queryKey:Wf(),queryFn:async()=>{try{return await Gf()}catch(e){let t=localStorage.getItem(Hf);if(t)return JSON.parse(t);throw e}},staleTime:1e3*60*60,retry:2}),qf=({abi:e,address:t,method:n})=>[`callClause`,t,n],Jf=e=>e.map(e=>typeof e==`bigint`?e.toString():Array.isArray(e)?Jf(e):e&&typeof e==`object`?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,typeof t==`bigint`?t.toString():t])):e),Yf=({abi:e,address:t,method:n,args:r})=>[`callClause`,t,n,...r?.length?Jf(r):[]],Xf=({address:e,abi:t,method:n,args:r,queryOptions:i})=>{let a=Qn();return or({queryKey:Yf({abi:t,address:e,method:n,args:r}),queryFn:async()=>ee({thor:a,contractAddress:e,abi:t,method:n,args:r}),...i})},Zf=({thor:e,calls:t,queryKey:n,enabled:r=!0})=>or({queryKey:n,queryFn:()=>ne({thor:e,calls:t}),enabled:r}),Qf=()=>{let{currentLanguage:e,setLanguage:t}=$();return{currentLanguage:e,setLanguage:t}},$f=()=>{let{currentCurrency:e,setCurrency:t}=$();return{currentCurrency:e,setCurrency:t}},ep=()=>{let[e,t]=K(!0),n=`vechain_kit_feature_announcement_closed`;return W(()=>{x(n)&&t(!1)},[]),{isVisible:e,closeAnnouncement:()=>{de(n,`true`),t(!1)}}},tp=()=>{let{network:e}=$();return e.nodeUrl??y(e.type).nodeUrl},np=()=>{let[e,t]=K(!0);return W(()=>{if(!A()){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},rp=()=>{W(()=>{let e=document.querySelector(`.chakra-modal__content`);e&&(e.scrollTop=0)},[])},ip=async(e,t)=>{if(!t)throw Error(`Address is required`);let n=await e.accounts.getAccount(On.of(t));return{balance:Ii(BigInt(n.balance)).toString(),energy:Ii(BigInt(n.energy)).toString()}},ap=e=>[`VECHAIN_KIT_BALANCE`,e],op=e=>{let t=Qn();return or({queryKey:ap(e),queryFn:()=>ip(t,e),enabled:!!e&&On.isValid(e),refetchInterval:1e4})},sp=async(e,t,n)=>{if(!n)throw Error(`Network type is required`);if(!t)throw Error(`Version is required`);let r=e.contracts.load(y(n).accountFactoryAddress,Ci.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()},cp=(e,t)=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`FACTORY`,`IMPLEMENTATION_ADDRESS`,e,t],lp=e=>{let t=Qn(),{network:n}=$();return or({queryKey:cp(e,n.type),queryFn:async()=>sp(t,e,n.type),enabled:!!t&&!!e&&!!n})},up=async(e,t)=>{if(!t)throw Error(`Network type is required`);let n=await e.contracts.load(y(t).accountFactoryAddress,Ci.abi).read.currentAccountImplementationVersion();if(!n)throw Error(`Failed to get current account implementation version`);return parseInt(n[0].toString())},dp=e=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`FACTORY`,`CURRENT_ACCOUNT_IMPLEMENTATION_VERSION`,e],fp=()=>{let e=Qn(),{network:t}=$();return or({queryKey:dp(t.type),queryFn:async()=>up(e,t.type),enabled:!!e&&!!t})},pp=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(y(n).accountFactoryAddress,Ci.abi).read.getAccountAddress(t);if(!r)throw Error(`Failed to get account address of ${t}`);return r[0].toString()},mp=(e,t)=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`FACTORY`,`ADDRESS`,e,t],hp=e=>{let t=Qn(),{network:n}=$();return or({queryKey:mp(e,n.type),queryFn:async()=>pp(t,e,n.type),enabled:!!t&&!!e&&!!n})},gp=Ci.abi,_p=(e,t,n)=>Yf({abi:gp,address:y(n).accountFactoryAddress,method:`getAccountVersion`,args:[e,t]}),vp=(e,t)=>{let{network:n}=$();return Xf({address:y(n.type).accountFactoryAddress,abi:gp,method:`getAccountVersion`,args:[e,t],queryOptions:{select:e=>({version:parseInt(e[0].toString()),isDeployed:e[1]}),enabled:!!e&&!!t}})},yp=Ci.abi,bp=async(e,t,n)=>{if(!t)throw Error(`Owner address is required`);if(!n)throw Error(`Network type is required`);let[r]=await ee({thor:e,abi:yp,contractAddress:y(n).accountFactoryAddress,method:`hasLegacyAccount`,args:[t]});return r},xp=(e,t)=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`HAS_V1_SMART_ACCOUNT`,e,t],Sp=e=>{let t=Qn(),{network:n}=$();return or({queryKey:xp(e,n.type),queryFn:async()=>bp(t,e,n.type),enabled:!!t&&!!e&&!!n})},Cp=async(e,t)=>{if(!t)throw Error(`Account address is required`);let n=await e.accounts.getAccount(On.of(String(t)));if(!n)throw Error(`Account not found`);return n.hasCode},wp=e=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`IS_DEPLOYED`,e],Tp=e=>{let t=tp(),n=Aa.at(t);return or({queryKey:wp(e),queryFn:async()=>Cp(n,e),enabled:!!n&&!!e})},Ep=()=>{let e=sr(),{connectedWallet:t,smartAccount:n}=Q(),{network:r}=$();return{refresh:async()=>{let i=t?.address??``,a=n?.address??``;await Promise.all([e.cancelQueries({queryKey:mp(i,r.type)}),e.cancelQueries({queryKey:_p(a,i,r.type)}),e.cancelQueries({queryKey:xp(i,r.type)}),e.cancelQueries({queryKey:dp(r.type)}),e.cancelQueries({queryKey:Mp(a,i,3,r.type)}),e.cancelQueries({queryKey:Fp(a,3,r.type)}),e.cancelQueries({queryKey:cp(3,r.type)})]),await Promise.all([e.refetchQueries({queryKey:mp(i,r.type)}),e.refetchQueries({queryKey:_p(a,i,r.type)}),e.refetchQueries({queryKey:xp(i,r.type)}),e.refetchQueries({queryKey:dp(r.type)}),e.refetchQueries({queryKey:Mp(a,i,3,r.type)}),e.refetchQueries({queryKey:Fp(a,3,r.type)}),e.refetchQueries({queryKey:cp(3,r.type)})])}}},Dp=()=>{let e=sr(),{smartAccount:t}=Q();return{refresh:async()=>{let n=t?.address??``;await Promise.all([e.cancelQueries({queryKey:kp(n)}),e.cancelQueries({queryKey:wp(n)})]),await Promise.all([e.refetchQueries({queryKey:kp(n)}),e.refetchQueries({queryKey:wp(n)})])}}},Op=async(e,t,n)=>{if(!n)return{address:void 0};let r=await e.contracts.load(y(t).accountFactoryAddress,Ci.abi).read.getAccountAddress(n);if(!r)throw Error(`Failed to get account address of ${n}`);let i=On.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}},kp=e=>[`VECHAIN_KIT_SMART_ACCOUNT`,e],Ap=e=>{let{network:t}=$(),n=Qn();return or({queryKey:kp(e),queryFn:()=>Op(n,t.type,e),enabled:!!e&&!!t.type&&!!n})},jp=async(e,t,n,r,i)=>{let a=await e.contracts.load(y(i).accountFactoryAddress,Ci.abi).read.upgradeRequired(t,n,BigInt(r));if(!a)throw Error(`Failed to get upgrade required of contract address ${y(i).accountFactoryAddress}`);return a[0]},Mp=(e,t,n,r)=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`FACTORY`,`UPGRADE_REQUIRED`,e,t,n,r],Np=(e,t,n)=>{let r=Qn(),{network:i}=$();return or({queryKey:Mp(e,t,n,i.type),queryFn:async()=>jp(r,e,t,n,i.type),enabled:!!r&&!!e&&!!t&&!!i.type})},Pp=async(e,t,n,r)=>{let i=await e.contracts.load(y(r).accountFactoryAddress,Ci.abi).read.upgradeRequiredForAccount(t,BigInt(n));if(!i)throw Error(`Failed to get upgrade required for contract address ${t}`);return i[0]},Fp=(e,t,n)=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`FACTORY`,`NEEDS_UPGRADE_FOR_ACCOUNT`,e,t,n],Ip=(e,t)=>{let n=Qn(),{network:r}=$();return or({queryKey:Fp(e,t,r.type),queryFn:async()=>Pp(n,e,t,r.type),enabled:!!n&&!!r&&!!e&&!!t&&e!==``})},Lp=wi.createInterface(),Rp=({smartAccountAddress:e,targetVersion:t,onSuccess:n,onError:r})=>{let{refresh:i}=Ep(),{refresh:a}=Dp(),{data:o}=lp(t),s=U(async()=>{if(!e||!D(e))throw Error(`Invalid smart account address`);if(!o)throw Error(`Unable to fetch implementation address for version ${t}`);return[{to:e,value:`0x0`,data:Lp.encodeFunctionData(`upgradeToAndCall`,[o,`0x`]),comment:`Upgrade account to version ${t}`,abi:Lp.getFunction(`upgradeToAndCall`).format(`json`)}]},[e,o,t]),c=Xc({privyUIOptions:{title:`Upgrade Smart Account`,description:`Upgrading your account at ${d(e)} to version ${t}`,buttonText:`Sign to continue`},onTxConfirmed:async()=>{await Promise.all([i(),a()]),n?.()},onTxFailedOrCancelled:async()=>{r?.()}});return{...c,sendTransaction:async()=>c.sendTransaction(await s())}},zp=()=>[`VECHAIN_KIT`,`CURRENT_BLOCK`],Bp=10*ie.SECOND,Vp=()=>{let e=Qn();return or({queryKey:zp(),queryFn:async()=>{let t=await e.blocks.getBestBlockExpanded();if(!t)throw Error(`Failed to fetch current block`);return t},staleTime:1e3*60,refetchInterval:Bp})},Hp=async e=>{let t=await e.blocks.getGenesisBlock();if(!t)throw Error(`Genesis block not found`);return t.id},Up=()=>[`VECHAIN_KIT_CHAIN_ID`],Wp=()=>{let e=Qn();return or({queryKey:Up(),queryFn:()=>Hp(e),enabled:!!e})},Gp=1e3,Kp=async({thor:e,order:t=`asc`,offset:n=0,limit:r=Gp,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},qp=async({nodeUrl:e,thor:t,order:n=`asc`,from:r=0,to:i,filterCriteria:a})=>{let o=[],s=0;for(;;){let c=await Kp({nodeUrl:e,thor:t,filterCriteria:a,from:r,to:i??2**53-1,limit:Gp,order:n,offset:s});if(o.push(...c),c.length<Gp)return o;s+=Gp}},Jp=xi.createInterface(),Yp=(e,t,n,r)=>{if(!e||!t||!D(e))throw Error(`Invalid receiver address or amount`);let i=[];return i.push({to:n,value:`0x0`,data:Jp.encodeFunctionData(`transfer`,[e,Bi(t)]),comment:`Transfer ${t} ${r} to ${e}`,abi:Jp.getFunction(`transfer`)}),i},Xp=({fromAddress:e,receiverAddress:t,amount:n,tokenAddress:r,tokenName:i,onSuccess:a,onError:o})=>{let{refresh:s}=jc(),c=G(()=>Yp(t,n,r,i),[t,n,r,i]),l=Xc({signerAccountAddress:e,privyUIOptions:{title:`Confirm Transfer`,description:`Transfer ${n} ${i} to ${d(t)}`,buttonText:`Sign to continue`},onTxConfirmed:async()=>{s(),a?.()},onTxFailedOrCancelled:async e=>{o?.(e instanceof Error?e.message:String(e))}});return{...l,clauses:c,sendTransaction:async()=>l.sendTransaction(c)}},Zp=(e,t)=>{if(!e||!t||!D(e))throw Error(`Invalid receiver address or amount`);if(isNaN(Number(t)))throw Error(`Invalid amount`);let n=[];try{n.push({to:e,value:Bi(t).toString(),data:`0x`,comment:`Transfer ${t} VET to ${e}`})}catch(e){throw console.error(`Error building clauses:`,e),Error(`Invalid amount format`)}return n},Qp=({fromAddress:e,receiverAddress:t,amount:n,onSuccess:r,onError:i})=>{let{refresh:a}=jc(),o=G(()=>Zp(t,n),[t,n]),s=Xc({signerAccountAddress:e,privyUIOptions:{title:`Confirm Transfer`,description:`Transfer ${n} VET to ${d(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)}},$p=({clauseBuilder:e,refetchQueryKeys:t,invalidateCache:n=!0,onSuccess:r,onFailure:i,suggestedMaxGas:a,gasPadding:o,delegationUrl:s})=>{let{account:c}=Q(),l=sr(),u=U(async()=>{n&&t?.forEach(async e=>{await l.cancelQueries({queryKey:e}),await l.refetchQueries({queryKey:e})}),r?.()},[n,r,l,t]),d=Xc({signerAccountAddress:c?.address,onTxConfirmed:u,suggestedMaxGas:a,onTxFailedOrCancelled:i,gasPadding:o,delegationUrl:s}),f=U(async t=>{d.sendTransaction(e(t),s)},[e,d,s]);return{...d,sendTransaction:f}},em=10*ie.SECOND,tm=e=>[`VECHAIN_KIT`,`TX_RECEIPT`,e],nm=(e,t=5)=>{let n=Qn();return or({queryKey:tm(e),queryFn:async()=>{let r=await n.transactions.waitForTransaction(e,{timeoutMs:t*em,intervalMs:3e3});if(!r)throw Error(`Transaction receipt not found`);return r},enabled:!!e})},rm=(e,t)=>{let n=Ni({abi:t,data:e.data.toString(),topics:e.topics.map(e=>e.toString())});return{meta:e.meta,decodedData:n}},im=({eventName:e,filterParams:t})=>[e,t?JSON.stringify(t):`all`],am=({abi:e,contractAddress:t,eventName:n,filterParams:r,mapResponse:i,nodeUrl:a})=>{let o=Qn();return or({queryFn:U(async()=>{if(!o)return[];let s=o.contracts.load(t,e).getEventAbi(n),c=s.encodeFilterTopicsNoNull(r??{}),l=(await qp({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=>rm(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:G(()=>im({eventName:n,filterParams:r}),[n,r]),enabled:!!o})};function om({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(Fi(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:xn.hexlify(xn.randomBytes(32))}}}function sm({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?Fi(e.data):e.data)||`0x`}}}function cm(){let{connection:e,connectedWallet:t}=Q(),{signTypedData:n}=Oc(),{signTypedData:r}=Kn(),{network:i}=$(),{data:a}=Wp();return{connection:e,connectedWallet:t,signTypedDataWithCrossApp:n,signTypedDataPrivy:r,network:i,chainId:a}}const lm=()=>{let{connection:e,connectedWallet:t,signTypedDataWithCrossApp:n,signTypedDataPrivy:r,network:i,chainId:a}=cm(),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=>sm({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(kn.callFunction(On.of(y(i.type).accountFactoryAddress),Dn.ofAbi(Ci.abi).getFunction(`createAccount`),[t?.address??``])),p.forEach((e,t)=>{f.push(kn.callFunction(On.of(c.address??``),Dn.ofAbi(wi.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=om({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(kn.callFunction(On.of(y(i.type).accountFactoryAddress),Dn.ofAbi(Ci.abi).getFunction(`createAccount`),[t?.address??``])),f.push(kn.callFunction(On.of(c.address??``),Dn.ofAbi(wi.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 um=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.SHOW_ASSETS=`vechain_kit_show_assets`,e}({});const dm=(e,t)=>{let[n,r]=K(()=>{try{let n=x(e);return n?JSON.parse(n):t}catch(e){return console.error(e),t}});return W(()=>{de(e,JSON.stringify(n))},[e,n]),[n,r]},fm=`vechain-kit-storage-change`,pm=(e,t)=>{let[n,r]=K(()=>{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=vn(!1);return W(()=>{if(!(typeof window>`u`)){if(i.current){i.current=!1;return}try{window.localStorage.setItem(e,JSON.stringify(n)),window.dispatchEvent(new CustomEvent(fm,{detail:{key:e,value:n}}))}catch(e){console.error(`Error writing to localStorage:`,e)}}},[e,n]),W(()=>{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(fm,a),()=>{window.removeEventListener(`storage`,t),window.removeEventListener(fm,a)}},[e,n]),[n,r,U(()=>{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]),U(()=>{if(typeof window>`u`)return t;let n=window.localStorage.getItem(e);return n?JSON.parse(n):t},[e,t])]},mm=()=>{let[e,t]=dm(um.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)}},hm=async(e,t,n,r,i)=>{let a=new URL(`estimate/clauses/${r.toLowerCase()}`,t);return a.searchParams.set(`type`,`smartaccount`),a.searchParams.set(`speed`,i),await(await fetch(a,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({clauses:n,signer:e})})).json()},gm=async e=>{let t=new URL(`deposit/account`,e);return await(await fetch(t,{method:`GET`,headers:{"Content-Type":`application/json`}})).json()},_m=async(e,t,n,r)=>{let i=new URL(`sign/transaction/authorized/${n.toLowerCase()}`,r);return await(await fetch(i,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({raw:e,origin:t,token:n.toLowerCase()})})).json()},vm=async(e,t,n,r)=>{let i=await t.gas.estimateGas(e,n?.address??``,{gasPadding:1}),a=Math.max(i.totalGas,0);return await t.transactions.buildTransactionBody(e,a,{isDelegated:r})};function ym(e,t){return Nn.of(e.body,Na.concatBytes(e.signature??new Uint8Array,jn.of(t.slice(2)).bytes))}function bm(e,t){return Nn.decode(jn.of(e.slice(2)).bytes,t)}const xm=()=>{let{connectedWallet:e}=Q(),{data:t}=Ap(e?.address??``),{data:n}=vp(t?.address??``,e?.address??``),{preferences:r}=Sm(),i=xi.createInterface(),{network:a}=$(),{buildClausesWithAuth:s}=lm(),c=Aa.at(y(a.type).nodeUrl);return{sendTransactionUsingGenericDelegator:U(async({clauses:e,genericDelegatorUrl:a})=>{try{let l=r.gasTokenToUse,d=await hm(t?.address??``,a,e,l,`medium`),f=await gm(a),p={to:l===`VET`?f.depositAccount:o[l].address,value:l===`VET`?Bi(d.transactionCost?.toString()??`0`).toString():`0x0`,data:l===`VET`?`0x`:i.encodeFunctionData(`transfer`,[f.depositAccount,Bi(d.transactionCost?.toString()??`0`)]),comment:`Transfer ${d.transactionCost} ${l} to ${f.depositAccount}`,abi:l===`VET`?void 0:i.getFunction(`transfer`)},m=await s({clauses:[...e,p],smartAccount:t,version:n?.version??0}),h=await vm(m,c,u,!0),g=await Nn.of(h).signAsSender(jn.of(u.privateKey).bytes),_=await _m(jn.of(g.encoded).toString(),u.address,l,a),v=ym(g,_.signature),y={clauses:m,simulateTransactionOptions:{caller:u.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`)},[r,t,n,s,c,u])}},Sm=()=>{let[e,t]=pm(um.GAS_TOKEN_PREFERENCES,a);return{preferences:e,supportedTokens:o,updatePreferences:U(e=>{t(t=>({...t,...e}))},[t]),reorderTokenPriority:U(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:U(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])}},Cm=({clauses:e,enabled:t=!0,tokens:n,sendingAmount:r,sendingTokenSymbol:i})=>{let{connectedWallet:a,account:o}=Q(),{data:s}=Ap(a?.address??``),{feeDelegation:c}=$(),{balances:l}=zs(o?.address??``),{updatePreferences:u}=Sm();return or({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 hm(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})},wm=({clauses:e,tokens:t,enabled:n=!0})=>{let{connectedWallet:r}=Q(),{data:i}=Ap(r?.address??``),{feeDelegation:a}=$();return or({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 hm(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})},Tm=({symbol:t,amount:n,currencyValue:r,currentCurrency:i,isDisabled:a,onClick:o,...s})=>{let c=V(`colors`,`vechain-kit-text-primary`),l=V(`colors`,`vechain-kit-text-secondary`),[u]=dm(um.SHOW_ASSETS,!0);return Y(M,{height:`72px`,variant:`ghost`,justifyContent:`space-between`,isDisabled:a,p:4,w:`100%`,_disabled:{cursor:`not-allowed`,opacity:.5},onClick:o,"data-testid":`asset-${t}`,...s,children:[Y(N,{children:[S[t]?H.cloneElement(S[t],{boxSize:`24px`,borderRadius:`full`}):J(Ot,{src:e[t],alt:`${t} logo`,boxSize:`24px`,borderRadius:`full`,fallback:J(j,{boxSize:`24px`,borderRadius:`full`,bg:`whiteAlpha.200`,display:`flex`,alignItems:`center`,justifyContent:`center`,children:J(z,{fontSize:`10px`,fontWeight:`bold`,color:c,children:t.slice(0,3)})})}),J(z,{color:c,children:t})]}),Y(B,{align:`flex-end`,spacing:0,children:[Y(z,{color:c,children:[u?n.toLocaleString(void 0,{maximumFractionDigits:2}):`*`.repeat(4),` `]}),J(z,{fontSize:`sm`,color:l,"data-testid":`${t}-balance`,children:u?qs(r,{currency:i}):`*`.repeat(4)})]})]})},Em=({address:e,domain:t,imageSrc:n,imageAlt:r=`Account`,hideAddress:i=!1,balance:a,tokenAddress:o})=>{let{t:s}=X(),c=V(`colors`,`vechain-kit-text-primary`),l=V(`colors`,`vechain-kit-text-secondary`),u=V(`colors`,`vechain-kit-card`),{isLoading:f}=Zs({address:e}),{tokens:p,isLoading:m}=Xs({address:e}),h=G(()=>o?p.find(e=>e.address===o):null,[p,o]),g=G(()=>a===void 0?h?Number(h.balance):0:a,[a,h]),_=h?.symbol||``;return f||m?Y(N,{minH:`50px`,justify:`space-between`,p:4,borderRadius:`2xl`,bg:u,children:[Y(N,{children:[J(qt,{boxSize:`40px`,borderRadius:`full`}),Y(B,{align:`start`,spacing:0,children:[J(qt,{height:`16px`,width:`120px`,borderRadius:`md`}),!i&&J(qt,{mt:2,height:`12px`,width:`100px`,borderRadius:`md`})]})]}),Y(B,{justify:`flex-start`,align:`flex-end`,spacing:0,mr:2,children:[J(z,{fontSize:`sm`,fontWeight:`medium`,color:c,children:s(`Balance`)}),J(qt,{height:`12px`,width:`80px`,borderRadius:`md`})]})]}):Y(N,{minH:`50px`,justify:`space-between`,p:4,borderRadius:`2xl`,bg:u,children:[Y(N,{children:[J(Ot,{src:n,alt:r,boxSize:`40px`,borderRadius:`full`,objectFit:`cover`}),J(B,{align:`start`,spacing:0,children:t?Y(q,{children:[J(z,{fontWeight:`medium`,fontSize:`sm`,color:c,children:t}),!i&&J(z,{fontSize:`xs`,color:l,children:d(e,6,4)})]}):J(z,{fontWeight:`medium`,fontSize:`sm`,color:c,children:d(e,6,4)})})]}),Y(B,{justify:`flex-start`,align:`flex-end`,spacing:0,mr:2,children:[J(z,{fontSize:`sm`,fontWeight:`medium`,color:c,children:s(`Balance`)}),Y(z,{fontSize:`xs`,color:l,children:[g.toLocaleString(void 0,{maximumFractionDigits:2}),_&&` ${_}`]})]})]})},Dm=({onClick:e,...t})=>J(Dt,{"aria-label":`FAQ`,icon:J(P,{as:kr,fontSize:`17px`}),size:`sm`,variant:`vechainKitHeaderIconButtons`,position:`absolute`,lineHeight:`normal`,left:`10px`,top:`8px`,onClick:e,...t}),Om=({children:e,...t})=>(rp(),J(B,{...t,children:e})),km=({wallet:e,props:t})=>{let n=vn(e?.image),r=vn(e?.address);return W(()=>{r.current!==e?.address&&(n.current=e?.image,r.current=e?.address)},[e?.address]),W(()=>{e?.image&&!e.isLoadingMetadata&&(n.current=e.image)},[e?.image,e?.isLoadingMetadata]),!t?.src&&!e?.image&&!n.current||e?.isLoadingMetadata?J(qt,{rounded:`full`,width:t?.width,height:t?.height}):J(Ot,{src:t?.src||e?.image||n.current,alt:t?.alt||e?.domain,objectFit:`cover`,rounded:`full`,...t})},Am=({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:_}=X(),{darkMode:v}=$(),{network:b}=$(),x=G(()=>e?e.reason||_(`Something went wrong. Please try again.`):null,[e,_]);W(()=>{x&&d?.(x)},[x,d]);let S=G(()=>{if(u?.accentColor)return`${u.accentColor} !important`},[u?.accentColor]),C=G(()=>{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 Y(B,{width:`full`,spacing:4,children:[x&&J(j,{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:J(z,{color:`#da5a5a`,fontSize:`sm`,fontWeight:`medium`,"data-testid":`tx-send-error-msg`,children:x})}),C&&!x&&J(j,{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:J(z,{color:`#da5a5a`,fontSize:`sm`,fontWeight:`medium`,"data-testid":`gas-estimation-error`,children:C.message})}),J(M,{px:4,variant:x?`vechainKitSecondary`:`vechainKitPrimary`,bg:S,onClick:()=>x&&i?i():r(),type:s?`submit`:`button`,isLoading:t,isDisabled:l,loadingText:n?_(`Waiting wallet confirmation...`):a,"data-testid":`confirm-button`,children:x?_(`Retry`):c||_(`Confirm`)}),x&&o?.meta.txID&&J(Nt,{isExternal:!0,fontSize:`sm`,color:v?`whiteAlpha.600`:`blackAlpha.600`,textAlign:`center`,width:`full`,href:`${y(b.type).explorerUrl}/${o?.meta.txID}`,target:`_blank`,rel:`noopener noreferrer`,children:_(`View transaction on the explorer`)})]})},jm=({onClick:e,hasUnreadNotifications:t,...n})=>J(Dt,{"aria-label":`Notifications`,size:`sm`,variant:`ghost`,position:`absolute`,borderRadius:`50%`,left:`10px`,top:`10px`,onClick:e,icon:Y(j,{position:`relative`,children:[J(vr,{fontSize:`20px`}),t&&J(j,{position:`absolute`,top:`-1px`,right:`-1px`,minWidth:`8px`,height:`8px`,bg:`red.500`,borderRadius:`full`})]}),...n}),Mm=({isOpen:e,onClose:t,selectedToken:n,onTokenSelect:r,availableTokens:i,tokenEstimations:a,walletAddress:s})=>{let{t:c}=X(),{balances:l}=zs(s),[u,d]=H.useState(n),[f,p]=H.useState(!1),m=V(`colors`,`vechain-kit-text-primary`),h=V(`colors`,`vechain-kit-text-secondary`),g=V(`colors`,`vechain-kit-text-tertiary`),_=V(`colors`,`vechain-kit-error`),v=e=>e?g:`transparent`,y=e=>e?m:`transparent`;H.useEffect(()=>{e&&(d(n),p(!1))},[e,n]);let b=()=>{r(u,f),t()},x=e=>{let t=l.find(t=>t.symbol===e);return t?Number(t.balance).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2}):`0.00`},C=e=>{let t=l.find(t=>t.symbol===e),n=a[e];return!t||!n?!1:Number(t.balance)<n.cost};return Y(zo,{isOpen:e,onClose:t,size:`sm`,children:[Y(R,{children:[J(z,{fontSize:`lg`,fontWeight:`semibold`,color:m,children:c(`Fee token`)}),J(z,{fontSize:`sm`,fontWeight:`normal`,color:h,mt:1,children:c(`Select the token to pay the fee with`)})]}),J(F,{children:Y(B,{spacing:2,align:`stretch`,children:[i.map(e=>{let t=o[e],n=u===e,r=a[e]||{cost:0,loading:!0},i=C(e);return J(j,{cursor:i?`not-allowed`:`pointer`,bg:v(n),border:`1px`,borderColor:y(n),borderRadius:`md`,p:3,transition:`all 0.2s ease`,_hover:{backgroundColor:i?v(n):h&&`#ffffff12`,borderColor:i?y(n):h},opacity:i?.5:1,onClick:()=>!i&&d(e),children:Y(N,{spacing:3,justify:`space-between`,children:[Y(N,{spacing:3,flex:1,children:[H.cloneElement(S[e],{boxSize:`36px`,borderRadius:`full`}),Y(B,{align:`start`,spacing:0,children:[J(z,{fontWeight:`medium`,color:m,children:t.symbol}),Y(z,{fontSize:`xs`,color:h,children:[c(`Balance`),`:`,` `,x(e)]}),i&&J(z,{fontSize:`xs`,color:_,children:c(`Insufficient balance`)})]})]}),J(B,{align:`end`,spacing:0,children:r.loading?J(qt,{height:`16px`,width:`60px`}):Y(q,{children:[J(z,{fontSize:`sm`,fontWeight:`semibold`,color:m,children:le(r.cost,2)}),J(z,{fontSize:`xs`,color:h,children:t.symbol})]})})]})},e)}),u!==n&&Y(St,{display:`flex`,alignItems:`center`,justifyContent:`space-between`,children:[J(Ct,{htmlFor:`remember-choice`,mb:`0`,fontSize:`sm`,color:m,children:c(`Use this token for future transactions`)}),J(Xt,{id:`remember-choice`,isChecked:f,onChange:e=>p(e.target.checked),color:m})]})]})}),J(L,{children:Y(B,{spacing:3,w:`full`,children:[J(M,{variant:`vechainKitPrimary`,onClick:b,isDisabled:C(u),children:c(`Apply`)}),J(M,{variant:`ghost`,width:`full`,onClick:t,children:c(`Cancel`)})]})})]})},Nm=({estimation:e,isLoading:t,isLoadingTransaction:n,onTokenChange:r,clauses:i=[],userSelectedToken:a})=>{let{t:s}=X(),{feeDelegation:c}=$(),{connection:l,account:u}=Q(),{preferences:d,reorderTokenPriority:f}=Sm(),{isOpen:p,onOpen:m,onClose:h}=fn(),g=V(`colors`,`vechain-kit-text-primary`),_=V(`colors`,`vechain-kit-text-secondary`),[v,y]=K(()=>{let e={};return d.availableGasTokens.forEach(t=>{e[t]={cost:0,loading:!0}}),e}),{data:b,isLoading:x}=wm({clauses:i,tokens:d.availableGasTokens,enabled:i.length>0});W(()=>{!x&&b&&y(b)},[b,x]),W(()=>{e&&y(t=>({...t,[e.usedToken]:{cost:e.transactionCost||0,loading:!1}}))},[e]),W(()=>{x&&y(d.availableGasTokens.reduce((e,t)=>(e[t]={cost:0,loading:!0},e),{}))},[x,d.availableGasTokens]);let C=U((t,n)=>{n&&f([t,...d.tokenPriority.filter(e=>e!==t)]),r&&t!==e?.usedToken&&r(t)},[e,r,f,d.tokenPriority]);if(c?.delegatorUrl||l.isConnectedWithDappKit||d.availableGasTokens.length===0)return null;let{balances:w}=zs(u?.address??``),T=e=>{let t=w.find(t=>t.symbol===e),n=v[e];return!t||!n||n.loading?!0:Number(t.balance)<n.cost},E=e?.usedToken,D=d.availableGasTokens,O;E?O=E:a&&D.includes(a)?O=a:(O=D.find(e=>v[e]&&!v[e].loading&&!T(e)),O||=D.find(e=>v[e]&&!v[e].loading),O||=D[0]);let k=O?v[O]:void 0,A=E&&e?.transactionCost?e.transactionCost:k?.cost||0,ee=O?o[O]:void 0;return Y(q,{children:[J(bt,{mt:3}),Y(N,{mt:3,w:`full`,justifyContent:`start`,alignItems:`center`,children:[Y(B,{align:`start`,spacing:0,w:`full`,children:[J(z,{fontSize:`sm`,fontWeight:`light`,textAlign:`left`,w:`full`,color:_,children:s(`Fee`)}),J(N,{align:`start`,justifyContent:`space-between`,spacing:0,w:`full`,children:J(N,{justifyContent:`flex-start`,w:`full`,children:t||!E&&(!k||k.loading)||!ee?Y(q,{children:[J(qt,{height:`16px`,width:`120px`,borderRadius:`md`}),J(qt,{height:`16px`,width:`60px`,borderRadius:`md`})]}):Y(q,{children:[Y(z,{color:g,fontSize:`sm`,fontWeight:`semibold`,children:[le(A,2),` `,ee.symbol]}),Y(z,{color:_,fontSize:`xs`,children:[`≈`,` $`,(A*.01).toFixed(2)]})]})})})]}),Y(M,{onClick:m,variant:`outline`,size:`sm`,borderRadius:`full`,px:6,disabled:n,color:_,borderColor:_,_hover:{bg:_},leftIcon:H.cloneElement(S[O||d.availableGasTokens[0]],{boxSize:`20px`,borderRadius:`full`}),children:[J(z,{fontSize:`sm`,fontWeight:`semibold`,children:O||d.availableGasTokens[0]}),J(P,{as:Cr,boxSize:5,color:_})]})]}),J(Mm,{isOpen:p,onClose:h,selectedToken:O||d.availableGasTokens[0],onTokenSelect:C,availableTokens:d.availableGasTokens,tokenEstimations:v,walletAddress:u?.address??``})]})},Pm=Ca`
|
|
200
|
+
`}),Kd=({children:e,theme:t,bodyFont:n,headingFont:r})=>Y(ba,{value:G(()=>Wd(),[]),children:[J(Gd,{bodyFont:n,headingFont:r}),J(mt,{theme:t,resetCSS:!1,portalZIndex:void 0,children:e})]}),qd=({darkMode:e})=>{try{if(h(`[data-chakra-color-mode]`))return null}catch(e){console.error(e)}return J(vt,{initialColorMode:e?`dark`:`light`})},Jd=gn({portalRootRef:void 0,tokens:void 0,themeConfig:void 0}),Yd=()=>{let e=_n(Jd);if(!e)throw Error(`useVechainKitTheme must be used within a VechainKitThemeProvider`);return e},Xd=({darkMode:e=!1})=>{let{setColorMode:t,colorMode:n}=un();return W(()=>{let r=e?`dark`:`light`;n!==r&&t(r)},[e]),J(q,{})},Zd=({children:e,darkMode:t=!1,theme:n})=>{let r=vn(null),i=_n($m),a=i?i.theme:void 0,o=n??a,s=G(()=>vo(_o(t),yo(o,t)),[t,o]),c=G(()=>({...Hd(t,o),config:{...Hd(t,o).config,initialColorMode:t?`dark`:`light`}}),[t,o]);return Y(Jd.Provider,{value:{portalRootRef:r,tokens:s,themeConfig:o},children:[J(qd,{darkMode:t}),Y(Kd,{theme:c,bodyFont:s.fonts.body,headingFont:s.fonts.heading,children:[J(Xd,{darkMode:t}),J(j,{id:`vechain-kit-root`,ref:r,bg:`transparent`,borderRadius:`12px`,children:e})]}),J(Ud,{})]})},Qd=gn(null),$d=()=>{let e=_n(Qd);if(!e)throw Error(`useModal must be used within ModalProvider`);return e},ef=({children:e})=>{let{darkMode:t,theme:n}=$(),[r,i]=K(!1),[a,o]=K(`main`),[s,c]=K(!1),{setSource:l,connectV2:u}=$n(),d=U((e,t)=>{A()&&window.vechain&&window.vechain.isInAppBrowser?(l(`veworld`),u(null)):(o(e??`main`),c(t??!1),i(!0))},[]),f=U(()=>{i(!1),o(`main`),c(!1)},[]),[p,m]=K(!1),[h,g]=K(!1),[_,v]=K(`main`),y=U((e,t)=>{v(e??`main`),g(t?.isolatedView??!1),m(!0)},[]),b=U(()=>{m(!1),v(`main`),setTimeout(()=>{g(!1)},300)},[]),[x,S]=K(!1),C=U(()=>S(!0),[]),w=U(()=>S(!1),[]),[T,E]=K(!1),D=U(()=>E(!0),[]),O=U(()=>E(!1),[]),[k,ee]=K(!1),[te,ne]=K(void 0),re=U(e=>{ne(e),ee(!0)},[]),ie=U(()=>ee(!1),[]);return Y(Qd.Provider,{value:{openConnectModal:d,closeConnectModal:f,isConnectModalOpen:r,connectModalContent:a,setConnectModalContent:o,connectModalPreventAutoClose:s,setConnectModalPreventAutoClose:c,openAccountModal:y,closeAccountModal:b,isAccountModalOpen:p,setAccountModalContent:v,accountModalContent:_,isolatedView:h,openTransactionModal:C,closeTransactionModal:w,isTransactionModalOpen:x,openTransactionToast:D,closeTransactionToast:O,isTransactionToastOpen:T,openUpgradeSmartAccountModal:re,closeUpgradeSmartAccountModal:ie,isUpgradeSmartAccountModalOpen:k},children:[e,Y(Zd,{darkMode:t,theme:n,children:[J(fd,{isOpen:r,onClose:f,initialContent:a,preventAutoClose:s}),J(cd,{isOpen:p,onClose:b,initialContent:_}),J(Cd,{isOpen:k,onClose:ie,style:te})]})]})},tf=()=>{let{loginMethods:e}=$(),t=e?.length===1&&e[0].method===`dappkit`,{openConnectModal:n,closeConnectModal:r,isConnectModalOpen:i}=$d(),{open:a,close:o}=tr();return{open:t?a:e=>n(e),close:t?o:r,isOpen:t?!1:i}},nf=({children:e})=>J(q,{children:e}),rf=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=$d();return{open:()=>e(),close:t,isOpen:n}},af=({children:e})=>J(q,{children:e}),of=()=>{let{openTransactionModal:e,closeTransactionModal:t,isTransactionModalOpen:n}=$d();return{open:e,close:t,isOpen:n}},sf=({children:e})=>J(q,{children:e}),cf=()=>{let{openTransactionToast:e,closeTransactionToast:t,isTransactionToastOpen:n}=$d();return{open:e,close:t,isOpen:n}},lf=({children:e})=>J(q,{children:e}),uf=()=>{let{connection:e}=Q(),{openConnectModal:t,closeConnectModal:n,isConnectModalOpen:r,openAccountModal:i,closeAccountModal:a,isAccountModalOpen:o}=$d();return{open:n=>{e.isConnected?i(void 0,n):t()},close:()=>{o&&a(),r&&n()},isOpen:r||o}},df=({children:e})=>J(q,{children:e}),ff=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n,setAccountModalContent:r}=$d();return{open:t=>{e({type:`choose-name`,props:{setCurrentContent:r,onBack:()=>r(`main`),initialContentSource:`main`}},t)},close:()=>{t()},isOpen:n}},pf=({children:e})=>J(q,{children:e}),mf=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n,setAccountModalContent:r}=$d();return{open:t=>{e({type:`send-token`,props:{setCurrentContent:r}},t)},close:()=>{t()},isOpen:n}},hf=({children:e})=>J(q,{children:e}),gf=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n,setAccountModalContent:r}=$d();return{open:t=>{e({type:`swap-token`,props:{setCurrentContent:r,fromTokenAddress:t?.fromTokenAddress,toTokenAddress:t?.toTokenAddress}},{isolatedView:t?.isolatedView})},close:()=>{t()},isOpen:n}},_f=({children:e})=>J(q,{children:e}),vf=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=$d();return{open:t=>{e(`ecosystem`,t)},close:()=>{t()},isOpen:n}},yf=({children:e})=>J(q,{children:e}),bf=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=$d();return{open:t=>{e(`notifications`,t)},close:()=>{t()},isOpen:n}},xf=({children:e})=>J(q,{children:e}),Sf=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n,setAccountModalContent:r}=$d();return{open:t=>{e({type:`faq`,props:{onGoBack:()=>r(`main`),showLanguageSelector:!1}},t)},close:()=>{t()},isOpen:n}},Cf=({children:e})=>J(q,{children:e}),wf=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=$d();return{open:t=>{e(`account-customization`,t)},close:()=>{t()},isOpen:n}},Tf=({children:e})=>J(q,{children:e}),Ef=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=$d();return{open:t=>{e(`receive-token`,t)},close:()=>{t()},isOpen:n}},Df=({children:e})=>J(q,{children:e}),Of=()=>{let{privy:e,loginMethods:t}=$(),n=e?.appId===_,r=e=>t?Array.isArray(e)?e.some(e=>t.some(t=>t.method===e)):t.some(t=>t.method===e):!0,i=G(()=>t?t.length===0||r(`ecosystem`):!0,[t]),a=G(()=>r(`vechain`),[t]),o=G(()=>r(`dappkit`),[t]),s=G(()=>r(`passkey`),[t]),c=G(()=>r(`email`),[t]),l={showGoogleLogin:G(()=>r(`google`),[t]),showEmailLogin:c,showPasskey:s,showVeChainLogin:a,showDappKit:o,showEcosystem:i,showMoreLogin:G(()=>r(`more`),[t]),showGithubLogin:G(()=>r(`github`),[t]),isOfficialVeChainApp:!1};return e?n?{...l,isOfficialVeChainApp:!0}:{...l}:{...l,showGoogleLogin:!1,showEmailLogin:!1,showPasskey:!1,showMoreLogin:!1}},kf=e=>{let{openUpgradeSmartAccountModal:t,closeUpgradeSmartAccountModal:n,isUpgradeSmartAccountModalOpen:r}=$d();return{open:()=>t(e),close:n,isOpen:r}},Af=({children:e})=>J(q,{children:e}),jf=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=$d();return{open:t=>{e(`profile`,t)},close:()=>{t()},isOpen:n}},Mf=({children:e})=>J(q,{children:e}),Nf=()=>{let{openAccountModal:e,closeAccountModal:t,isAccountModalOpen:n}=$d();return{open:t=>{e(`settings`,t)},close:()=>{t()},isOpen:n}},Pf=({children:e})=>J(q,{children:e}),Ff=()=>{let[e,t]=K(!1),[n,r]=K(null),[i,a]=K(null),{connection:o,account:s}=Q(),{requestCertificate:c}=er(),l=Qm();return{signMessage:U(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,s?.address]),isSigningPending:e,signature:n,error:i,reset:U(()=>{t(!1),r(null),a(null)},[])}},If=()=>{let[e,t]=K(!1),[n,r]=K(null),[i,a]=K(null),{signer:o}=$n(),{connection:s}=Q(),c=Qm();return{signTypedData:U(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:U(()=>{t(!1),r(null),a(null)},[])}},Lf=()=>{let{loginWithPasskey:e}=Un();return{loginWithPasskey:async()=>{try{await e()}catch(e){throw e}}}};let Rf=!1;const zf=()=>{let{createWallet:e}=Bn(),{initOAuth:t}=Hn({onComplete:U(async({isNewUser:t})=>{if(t&&!Rf){Rf=!0;try{await e()}catch(e){throw Rf=!1,console.error(`Failed to create wallet:`,e),e}}},[e])});return{initOAuth:async({provider:e})=>{try{await t({provider:e})}catch(e){throw e}}}},Bf=()=>{let e=`vechain_kit_cross_app_connection`;return{setConnectionCache:U(t=>{let n={timestamp:Date.now(),ecosystemApp:t};de(e,JSON.stringify(n))},[]),getConnectionCache:U(()=>{let t=x(e);return t?JSON.parse(t):null},[]),clearConnectionCache:U(()=>{w(e)},[])}},Vf=()=>{let{login:e}=Oc(),{setConnectionCache:t}=Bf(),{data:n}=Ho([_]);return{login:async()=>{try{await e(_),t({name:`VeChain`,logoUrl:n?.[_]?.logo_url,appId:_,website:Qe})}catch(e){throw wc({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.`})}}}},Hf=`vechain-kit-app-hub-apps`,Uf=`vechain-kit-app-hub-apps-expiry`,Wf=()=>[`VECHAIN_KIT`,`appHub`,`apps`],Gf=async()=>{if(typeof window<`u`)try{let e=x(Hf),t=x(Uf);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=new URL(`contents/apps`,Ie),t=await fetch(e);if(!t.ok)throw Error(`Failed to fetch app directories`);let n=(await t.json()).map(async e=>{if(e.type!==`dir`)return null;let t=new URL(`master/apps/${e.name}/manifest.json`,Ge),n=await fetch(t);if(!n.ok)return console.warn(`Failed to fetch manifest for ${e.name}`),null;try{let t=await n.json(),r=new URL(`master/apps/${e.name}/logo.png`,Ge);return{id:e.name,name:t.name,description:t.desc,url:t.href,logo:r.toString(),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}}),r=(await Promise.all(n)).filter(e=>e!==null);if(typeof window<`u`)try{de(Hf,JSON.stringify(r)),de(Uf,(Date.now()+864e5).toString())}catch(e){console.warn(`Failed to cache app-hub data:`,e)}return r},Kf=()=>or({queryKey:Wf(),queryFn:async()=>{try{return await Gf()}catch(e){let t=localStorage.getItem(Hf);if(t)return JSON.parse(t);throw e}},staleTime:1e3*60*60,retry:2}),qf=({abi:e,address:t,method:n})=>[`callClause`,t,n],Jf=e=>e.map(e=>typeof e==`bigint`?e.toString():Array.isArray(e)?Jf(e):e&&typeof e==`object`?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,typeof t==`bigint`?t.toString():t])):e),Yf=({abi:e,address:t,method:n,args:r})=>[`callClause`,t,n,...r?.length?Jf(r):[]],Xf=({address:e,abi:t,method:n,args:r,queryOptions:i})=>{let a=Qn();return or({queryKey:Yf({abi:t,address:e,method:n,args:r}),queryFn:async()=>ee({thor:a,contractAddress:e,abi:t,method:n,args:r}),...i})},Zf=({thor:e,calls:t,queryKey:n,enabled:r=!0})=>or({queryKey:n,queryFn:()=>ne({thor:e,calls:t}),enabled:r}),Qf=()=>{let{currentLanguage:e,setLanguage:t}=$();return{currentLanguage:e,setLanguage:t}},$f=()=>{let{currentCurrency:e,setCurrency:t}=$();return{currentCurrency:e,setCurrency:t}},ep=()=>{let[e,t]=K(!0),n=`vechain_kit_feature_announcement_closed`;return W(()=>{x(n)&&t(!1)},[]),{isVisible:e,closeAnnouncement:()=>{de(n,`true`),t(!1)}}},tp=()=>{let{network:e}=$();return e.nodeUrl??y(e.type).nodeUrl},np=()=>{let[e,t]=K(!0);return W(()=>{if(!A()){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},rp=()=>{W(()=>{let e=document.querySelector(`.chakra-modal__content`);e&&(e.scrollTop=0)},[])},ip=async(e,t)=>{if(!t)throw Error(`Address is required`);let n=await e.accounts.getAccount(On.of(t));return{balance:Ii(BigInt(n.balance)).toString(),energy:Ii(BigInt(n.energy)).toString()}},ap=e=>[`VECHAIN_KIT_BALANCE`,e],op=e=>{let t=Qn();return or({queryKey:ap(e),queryFn:()=>ip(t,e),enabled:!!e&&On.isValid(e),refetchInterval:1e4})},sp=async(e,t,n)=>{if(!n)throw Error(`Network type is required`);if(!t)throw Error(`Version is required`);let r=e.contracts.load(y(n).accountFactoryAddress,Ci.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()},cp=(e,t)=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`FACTORY`,`IMPLEMENTATION_ADDRESS`,e,t],lp=e=>{let t=Qn(),{network:n}=$();return or({queryKey:cp(e,n.type),queryFn:async()=>sp(t,e,n.type),enabled:!!t&&!!e&&!!n})},up=async(e,t)=>{if(!t)throw Error(`Network type is required`);let n=await e.contracts.load(y(t).accountFactoryAddress,Ci.abi).read.currentAccountImplementationVersion();if(!n)throw Error(`Failed to get current account implementation version`);return parseInt(n[0].toString())},dp=e=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`FACTORY`,`CURRENT_ACCOUNT_IMPLEMENTATION_VERSION`,e],fp=()=>{let e=Qn(),{network:t}=$();return or({queryKey:dp(t.type),queryFn:async()=>up(e,t.type),enabled:!!e&&!!t})},pp=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(y(n).accountFactoryAddress,Ci.abi).read.getAccountAddress(t);if(!r)throw Error(`Failed to get account address of ${t}`);return r[0].toString()},mp=(e,t)=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`FACTORY`,`ADDRESS`,e,t],hp=e=>{let t=Qn(),{network:n}=$();return or({queryKey:mp(e,n.type),queryFn:async()=>pp(t,e,n.type),enabled:!!t&&!!e&&!!n})},gp=Ci.abi,_p=(e,t,n)=>Yf({abi:gp,address:y(n).accountFactoryAddress,method:`getAccountVersion`,args:[e,t]}),vp=(e,t)=>{let{network:n}=$();return Xf({address:y(n.type).accountFactoryAddress,abi:gp,method:`getAccountVersion`,args:[e,t],queryOptions:{select:e=>({version:parseInt(e[0].toString()),isDeployed:e[1]}),enabled:!!e&&!!t}})},yp=Ci.abi,bp=async(e,t,n)=>{if(!t)throw Error(`Owner address is required`);if(!n)throw Error(`Network type is required`);let[r]=await ee({thor:e,abi:yp,contractAddress:y(n).accountFactoryAddress,method:`hasLegacyAccount`,args:[t]});return r},xp=(e,t)=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`HAS_V1_SMART_ACCOUNT`,e,t],Sp=e=>{let t=Qn(),{network:n}=$();return or({queryKey:xp(e,n.type),queryFn:async()=>bp(t,e,n.type),enabled:!!t&&!!e&&!!n})},Cp=async(e,t)=>{if(!t)throw Error(`Account address is required`);let n=await e.accounts.getAccount(On.of(String(t)));if(!n)throw Error(`Account not found`);return n.hasCode},wp=e=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`IS_DEPLOYED`,e],Tp=e=>{let t=tp(),n=Aa.at(t);return or({queryKey:wp(e),queryFn:async()=>Cp(n,e),enabled:!!n&&!!e})},Ep=()=>{let e=sr(),{connectedWallet:t,smartAccount:n}=Q(),{network:r}=$();return{refresh:async()=>{let i=t?.address??``,a=n?.address??``;await Promise.all([e.cancelQueries({queryKey:mp(i,r.type)}),e.cancelQueries({queryKey:_p(a,i,r.type)}),e.cancelQueries({queryKey:xp(i,r.type)}),e.cancelQueries({queryKey:dp(r.type)}),e.cancelQueries({queryKey:Mp(a,i,3,r.type)}),e.cancelQueries({queryKey:Fp(a,3,r.type)}),e.cancelQueries({queryKey:cp(3,r.type)})]),await Promise.all([e.refetchQueries({queryKey:mp(i,r.type)}),e.refetchQueries({queryKey:_p(a,i,r.type)}),e.refetchQueries({queryKey:xp(i,r.type)}),e.refetchQueries({queryKey:dp(r.type)}),e.refetchQueries({queryKey:Mp(a,i,3,r.type)}),e.refetchQueries({queryKey:Fp(a,3,r.type)}),e.refetchQueries({queryKey:cp(3,r.type)})])}}},Dp=()=>{let e=sr(),{smartAccount:t}=Q();return{refresh:async()=>{let n=t?.address??``;await Promise.all([e.cancelQueries({queryKey:kp(n)}),e.cancelQueries({queryKey:wp(n)})]),await Promise.all([e.refetchQueries({queryKey:kp(n)}),e.refetchQueries({queryKey:wp(n)})])}}},Op=async(e,t,n)=>{if(!n)return{address:void 0};let r=await e.contracts.load(y(t).accountFactoryAddress,Ci.abi).read.getAccountAddress(n);if(!r)throw Error(`Failed to get account address of ${n}`);let i=On.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}},kp=e=>[`VECHAIN_KIT_SMART_ACCOUNT`,e],Ap=e=>{let{network:t}=$(),n=Qn();return or({queryKey:kp(e),queryFn:()=>Op(n,t.type,e),enabled:!!e&&!!t.type&&!!n})},jp=async(e,t,n,r,i)=>{let a=await e.contracts.load(y(i).accountFactoryAddress,Ci.abi).read.upgradeRequired(t,n,BigInt(r));if(!a)throw Error(`Failed to get upgrade required of contract address ${y(i).accountFactoryAddress}`);return a[0]},Mp=(e,t,n,r)=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`FACTORY`,`UPGRADE_REQUIRED`,e,t,n,r],Np=(e,t,n)=>{let r=Qn(),{network:i}=$();return or({queryKey:Mp(e,t,n,i.type),queryFn:async()=>jp(r,e,t,n,i.type),enabled:!!r&&!!e&&!!t&&!!i.type})},Pp=async(e,t,n,r)=>{let i=await e.contracts.load(y(r).accountFactoryAddress,Ci.abi).read.upgradeRequiredForAccount(t,BigInt(n));if(!i)throw Error(`Failed to get upgrade required for contract address ${t}`);return i[0]},Fp=(e,t,n)=>[`VECHAIN_KIT`,`SMART_ACCOUNT`,`FACTORY`,`NEEDS_UPGRADE_FOR_ACCOUNT`,e,t,n],Ip=(e,t)=>{let n=Qn(),{network:r}=$();return or({queryKey:Fp(e,t,r.type),queryFn:async()=>Pp(n,e,t,r.type),enabled:!!n&&!!r&&!!e&&!!t&&e!==``})},Lp=wi.createInterface(),Rp=({smartAccountAddress:e,targetVersion:t,onSuccess:n,onError:r})=>{let{refresh:i}=Ep(),{refresh:a}=Dp(),{data:o}=lp(t),s=U(async()=>{if(!e||!D(e))throw Error(`Invalid smart account address`);if(!o)throw Error(`Unable to fetch implementation address for version ${t}`);return[{to:e,value:`0x0`,data:Lp.encodeFunctionData(`upgradeToAndCall`,[o,`0x`]),comment:`Upgrade account to version ${t}`,abi:Lp.getFunction(`upgradeToAndCall`).format(`json`)}]},[e,o,t]),c=Xc({privyUIOptions:{title:`Upgrade Smart Account`,description:`Upgrading your account at ${d(e)} to version ${t}`,buttonText:`Sign to continue`},onTxConfirmed:async()=>{await Promise.all([i(),a()]),n?.()},onTxFailedOrCancelled:async()=>{r?.()}});return{...c,sendTransaction:async()=>c.sendTransaction(await s())}},zp=()=>[`VECHAIN_KIT`,`CURRENT_BLOCK`],Bp=10*ie.SECOND,Vp=()=>{let e=Qn();return or({queryKey:zp(),queryFn:async()=>{let t=await e.blocks.getBestBlockExpanded();if(!t)throw Error(`Failed to fetch current block`);return t},staleTime:1e3*60,refetchInterval:Bp})},Hp=async e=>{let t=await e.blocks.getGenesisBlock();if(!t)throw Error(`Genesis block not found`);return t.id},Up=()=>[`VECHAIN_KIT_CHAIN_ID`],Wp=()=>{let e=Qn();return or({queryKey:Up(),queryFn:()=>Hp(e),enabled:!!e})},Gp=1e3,Kp=async({thor:e,order:t=`asc`,offset:n=0,limit:r=Gp,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},qp=async({nodeUrl:e,thor:t,order:n=`asc`,from:r=0,to:i,filterCriteria:a})=>{let o=[],s=0;for(;;){let c=await Kp({nodeUrl:e,thor:t,filterCriteria:a,from:r,to:i??2**53-1,limit:Gp,order:n,offset:s});if(o.push(...c),c.length<Gp)return o;s+=Gp}},Jp=xi.createInterface(),Yp=(e,t,n,r)=>{if(!e||!t||!D(e))throw Error(`Invalid receiver address or amount`);let i=[];return i.push({to:n,value:`0x0`,data:Jp.encodeFunctionData(`transfer`,[e,Bi(t)]),comment:`Transfer ${t} ${r} to ${e}`,abi:Jp.getFunction(`transfer`)}),i},Xp=({fromAddress:e,receiverAddress:t,amount:n,tokenAddress:r,tokenName:i,onSuccess:a,onError:o})=>{let{refresh:s}=jc(),c=G(()=>Yp(t,n,r,i),[t,n,r,i]),l=Xc({signerAccountAddress:e,privyUIOptions:{title:`Confirm Transfer`,description:`Transfer ${n} ${i} to ${d(t)}`,buttonText:`Sign to continue`},onTxConfirmed:async()=>{s(),a?.()},onTxFailedOrCancelled:async e=>{o?.(e instanceof Error?e.message:String(e))}});return{...l,clauses:c,sendTransaction:async()=>l.sendTransaction(c)}},Zp=(e,t)=>{if(!e||!t||!D(e))throw Error(`Invalid receiver address or amount`);if(isNaN(Number(t)))throw Error(`Invalid amount`);let n=[];try{n.push({to:e,value:Bi(t).toString(),data:`0x`,comment:`Transfer ${t} VET to ${e}`})}catch(e){throw console.error(`Error building clauses:`,e),Error(`Invalid amount format`)}return n},Qp=({fromAddress:e,receiverAddress:t,amount:n,onSuccess:r,onError:i})=>{let{refresh:a}=jc(),o=G(()=>Zp(t,n),[t,n]),s=Xc({signerAccountAddress:e,privyUIOptions:{title:`Confirm Transfer`,description:`Transfer ${n} VET to ${d(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)}},$p=({clauseBuilder:e,refetchQueryKeys:t,invalidateCache:n=!0,onSuccess:r,onFailure:i,suggestedMaxGas:a,gasPadding:o,delegationUrl:s})=>{let{account:c}=Q(),l=sr(),u=U(async()=>{n&&t?.forEach(async e=>{await l.cancelQueries({queryKey:e}),await l.refetchQueries({queryKey:e})}),r?.()},[n,r,l,t]),d=Xc({signerAccountAddress:c?.address,onTxConfirmed:u,suggestedMaxGas:a,onTxFailedOrCancelled:i,gasPadding:o,delegationUrl:s}),f=U(async t=>{d.sendTransaction(e(t),s)},[e,d,s]);return{...d,sendTransaction:f}},em=10*ie.SECOND,tm=e=>[`VECHAIN_KIT`,`TX_RECEIPT`,e],nm=(e,t=5)=>{let n=Qn();return or({queryKey:tm(e),queryFn:async()=>{let r=await n.transactions.waitForTransaction(e,{timeoutMs:t*em,intervalMs:3e3});if(!r)throw Error(`Transaction receipt not found`);return r},enabled:!!e})},rm=(e,t)=>{let n=Ni({abi:t,data:e.data.toString(),topics:e.topics.map(e=>e.toString())});return{meta:e.meta,decodedData:n}},im=({eventName:e,filterParams:t})=>[e,t?JSON.stringify(t):`all`],am=({abi:e,contractAddress:t,eventName:n,filterParams:r,mapResponse:i,nodeUrl:a})=>{let o=Qn();return or({queryFn:U(async()=>{if(!o)return[];let s=o.contracts.load(t,e).getEventAbi(n),c=s.encodeFilterTopicsNoNull(r??{}),l=(await qp({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=>rm(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:G(()=>im({eventName:n,filterParams:r}),[n,r]),enabled:!!o})};function om({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(Fi(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:xn.hexlify(xn.randomBytes(32))}}}function sm({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?Fi(e.data):e.data)||`0x`}}}function cm(){let{connection:e,connectedWallet:t}=Q(),{signTypedData:n}=Oc(),{signTypedData:r}=Kn(),{network:i}=$(),{data:a}=Wp();return{connection:e,connectedWallet:t,signTypedDataWithCrossApp:n,signTypedDataPrivy:r,network:i,chainId:a}}const lm=()=>{let{connection:e,connectedWallet:t,signTypedDataWithCrossApp:n,signTypedDataPrivy:r,network:i,chainId:a}=cm(),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=>sm({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(kn.callFunction(On.of(y(i.type).accountFactoryAddress),Dn.ofAbi(Ci.abi).getFunction(`createAccount`),[t?.address??``])),p.forEach((e,t)=>{f.push(kn.callFunction(On.of(c.address??``),Dn.ofAbi(wi.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=om({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(kn.callFunction(On.of(y(i.type).accountFactoryAddress),Dn.ofAbi(Ci.abi).getFunction(`createAccount`),[t?.address??``])),f.push(kn.callFunction(On.of(c.address??``),Dn.ofAbi(wi.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 um=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.SHOW_ASSETS=`vechain_kit_show_assets`,e}({});const dm=(e,t)=>{let[n,r]=K(()=>{try{let n=x(e);return n?JSON.parse(n):t}catch(e){return console.error(e),t}});return W(()=>{de(e,JSON.stringify(n))},[e,n]),[n,r]},fm=`vechain-kit-storage-change`,pm=(e,t)=>{let[n,r]=K(()=>{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=vn(!1);return W(()=>{if(!(typeof window>`u`)){if(i.current){i.current=!1;return}try{window.localStorage.setItem(e,JSON.stringify(n)),window.dispatchEvent(new CustomEvent(fm,{detail:{key:e,value:n}}))}catch(e){console.error(`Error writing to localStorage:`,e)}}},[e,n]),W(()=>{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(fm,a),()=>{window.removeEventListener(`storage`,t),window.removeEventListener(fm,a)}},[e,n]),[n,r,U(()=>{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]),U(()=>{if(typeof window>`u`)return t;let n=window.localStorage.getItem(e);return n?JSON.parse(n):t},[e,t])]},mm=()=>{let[e,t]=dm(um.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)}},hm=async(e,t,n,r,i)=>{let a=new URL(`estimate/clauses/${r.toLowerCase()}`,t);return a.searchParams.set(`type`,`smartaccount`),a.searchParams.set(`speed`,i),await(await fetch(a,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({clauses:n,signer:e})})).json()},gm=async e=>{let t=new URL(`deposit/account`,e);return await(await fetch(t,{method:`GET`,headers:{"Content-Type":`application/json`}})).json()},_m=async(e,t,n,r)=>{let i=new URL(`sign/transaction/authorized/${n.toLowerCase()}`,r);return await(await fetch(i,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({raw:e,origin:t,token:n.toLowerCase()})})).json()},vm=async(e,t,n,r)=>{let i=await t.gas.estimateGas(e,n?.address??``,{gasPadding:1}),a=Math.max(i.totalGas,0);return await t.transactions.buildTransactionBody(e,a,{isDelegated:r})};function ym(e,t){return Nn.of(e.body,Na.concatBytes(e.signature??new Uint8Array,jn.of(t.slice(2)).bytes))}function bm(e,t){return Nn.decode(jn.of(e.slice(2)).bytes,t)}const xm=()=>{let{connectedWallet:e}=Q(),{data:t}=Ap(e?.address??``),{data:n}=vp(t?.address??``,e?.address??``),{preferences:r}=Sm(),i=xi.createInterface(),{network:a}=$(),{buildClausesWithAuth:s}=lm(),c=Aa.at(y(a.type).nodeUrl);return{sendTransactionUsingGenericDelegator:U(async({clauses:e,genericDelegatorUrl:a})=>{try{let l=r.gasTokenToUse,d=await hm(t?.address??``,a,e,l,`medium`),f=await gm(a),p={to:l===`VET`?f.depositAccount:o[l].address,value:l===`VET`?Bi(d.transactionCost?.toString()??`0`).toString():`0x0`,data:l===`VET`?`0x`:i.encodeFunctionData(`transfer`,[f.depositAccount,Bi(d.transactionCost?.toString()??`0`)]),comment:`Transfer ${d.transactionCost} ${l} to ${f.depositAccount}`,abi:l===`VET`?void 0:i.getFunction(`transfer`)},m=await s({clauses:[...e,p],smartAccount:t,version:n?.version??0}),h=await vm(m,c,u,!0),g=await Nn.of(h).signAsSender(jn.of(u.privateKey).bytes),_=await _m(jn.of(g.encoded).toString(),u.address,l,a),v=ym(g,_.signature),y={clauses:m,simulateTransactionOptions:{caller:u.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`)},[r,t,n,s,c,u])}},Sm=()=>{let[e,t]=pm(um.GAS_TOKEN_PREFERENCES,a);return{preferences:e,supportedTokens:o,updatePreferences:U(e=>{t(t=>({...t,...e}))},[t]),reorderTokenPriority:U(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:U(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])}},Cm=({clauses:e,enabled:t=!0,tokens:n,sendingAmount:r,sendingTokenSymbol:i})=>{let{connectedWallet:a,account:o}=Q(),{data:s}=Ap(a?.address??``),{feeDelegation:c}=$(),{balances:l}=zs(o?.address??``),{updatePreferences:u}=Sm();return or({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 hm(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})},wm=({clauses:e,tokens:t,enabled:n=!0})=>{let{connectedWallet:r}=Q(),{data:i}=Ap(r?.address??``),{feeDelegation:a}=$();return or({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 hm(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})},Tm=({symbol:t,amount:n,currencyValue:r,currentCurrency:i,isDisabled:a,onClick:o,...s})=>{let c=V(`colors`,`vechain-kit-text-primary`),l=V(`colors`,`vechain-kit-text-secondary`),[u]=dm(um.SHOW_ASSETS,!0);return Y(M,{height:`72px`,variant:`ghost`,justifyContent:`space-between`,isDisabled:a,p:4,w:`100%`,_disabled:{cursor:`not-allowed`,opacity:.5},onClick:o,"data-testid":`asset-${t}`,...s,children:[Y(N,{children:[S[t]?H.cloneElement(S[t],{boxSize:`24px`,borderRadius:`full`}):J(Ot,{src:e[t],alt:`${t} logo`,boxSize:`24px`,borderRadius:`full`,fallback:J(j,{boxSize:`24px`,borderRadius:`full`,bg:`whiteAlpha.200`,display:`flex`,alignItems:`center`,justifyContent:`center`,children:J(z,{fontSize:`10px`,fontWeight:`bold`,color:c,children:t.slice(0,3)})})}),J(z,{color:c,children:t})]}),Y(B,{align:`flex-end`,spacing:0,children:[Y(z,{color:c,children:[u?n.toLocaleString(void 0,{maximumFractionDigits:2}):`*`.repeat(4),` `]}),J(z,{fontSize:`sm`,color:l,"data-testid":`${t}-balance`,children:u?qs(r,{currency:i}):`*`.repeat(4)})]})]})},Em=({address:e,domain:t,imageSrc:n,imageAlt:r=`Account`,hideAddress:i=!1,balance:a,tokenAddress:o})=>{let{t:s}=X(),c=V(`colors`,`vechain-kit-text-primary`),l=V(`colors`,`vechain-kit-text-secondary`),u=V(`colors`,`vechain-kit-card`),{isLoading:f}=Zs({address:e}),{tokens:p,isLoading:m}=Xs({address:e}),h=G(()=>o?p.find(e=>e.address===o):null,[p,o]),g=G(()=>a===void 0?h?Number(h.balance):0:a,[a,h]),_=h?.symbol||``;return f||m?Y(N,{minH:`50px`,justify:`space-between`,p:4,borderRadius:`2xl`,bg:u,children:[Y(N,{children:[J(qt,{boxSize:`40px`,borderRadius:`full`}),Y(B,{align:`start`,spacing:0,children:[J(qt,{height:`16px`,width:`120px`,borderRadius:`md`}),!i&&J(qt,{mt:2,height:`12px`,width:`100px`,borderRadius:`md`})]})]}),Y(B,{justify:`flex-start`,align:`flex-end`,spacing:0,mr:2,children:[J(z,{fontSize:`sm`,fontWeight:`medium`,color:c,children:s(`Balance`)}),J(qt,{height:`12px`,width:`80px`,borderRadius:`md`})]})]}):Y(N,{minH:`50px`,justify:`space-between`,p:4,borderRadius:`2xl`,bg:u,children:[Y(N,{children:[J(Ot,{src:n,alt:r,boxSize:`40px`,borderRadius:`full`,objectFit:`cover`}),J(B,{align:`start`,spacing:0,children:t?Y(q,{children:[J(z,{fontWeight:`medium`,fontSize:`sm`,color:c,children:t}),!i&&J(z,{fontSize:`xs`,color:l,children:d(e,6,4)})]}):J(z,{fontWeight:`medium`,fontSize:`sm`,color:c,children:d(e,6,4)})})]}),Y(B,{justify:`flex-start`,align:`flex-end`,spacing:0,mr:2,children:[J(z,{fontSize:`sm`,fontWeight:`medium`,color:c,children:s(`Balance`)}),Y(z,{fontSize:`xs`,color:l,children:[g.toLocaleString(void 0,{maximumFractionDigits:2}),_&&` ${_}`]})]})]})},Dm=({onClick:e,...t})=>J(Dt,{"aria-label":`FAQ`,icon:J(P,{as:kr,fontSize:`17px`}),size:`sm`,variant:`vechainKitHeaderIconButtons`,position:`absolute`,lineHeight:`normal`,left:`10px`,top:`8px`,onClick:e,...t}),Om=({children:e,...t})=>(rp(),J(B,{...t,children:e})),km=({wallet:e,props:t})=>{let n=vn(e?.image),r=vn(e?.address);return W(()=>{r.current!==e?.address&&(n.current=e?.image,r.current=e?.address)},[e?.address]),W(()=>{e?.image&&!e.isLoadingMetadata&&(n.current=e.image)},[e?.image,e?.isLoadingMetadata]),!t?.src&&!e?.image&&!n.current||e?.isLoadingMetadata?J(qt,{rounded:`full`,width:t?.width,height:t?.height}):J(Ot,{src:t?.src||e?.image||n.current,alt:t?.alt||e?.domain,objectFit:`cover`,rounded:`full`,...t})},Am=({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:_}=X(),{darkMode:v}=$(),{network:b}=$(),x=G(()=>e?e.reason||_(`Something went wrong. Please try again.`):null,[e,_]);W(()=>{x&&d?.(x)},[x,d]);let S=G(()=>{if(u?.accentColor)return`${u.accentColor} !important`},[u?.accentColor]),C=G(()=>{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 Y(B,{width:`full`,spacing:4,children:[x&&J(j,{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:J(z,{color:`#da5a5a`,fontSize:`sm`,fontWeight:`medium`,"data-testid":`tx-send-error-msg`,children:x})}),C&&!x&&J(j,{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:J(z,{color:`#da5a5a`,fontSize:`sm`,fontWeight:`medium`,"data-testid":`gas-estimation-error`,children:C.message})}),J(M,{px:4,variant:x?`vechainKitSecondary`:`vechainKitPrimary`,bg:S,onClick:()=>x&&i?i():r(),type:s?`submit`:`button`,isLoading:t,isDisabled:l,loadingText:n?_(`Waiting wallet confirmation...`):a,"data-testid":`confirm-button`,children:x?_(`Retry`):c||_(`Confirm`)}),x&&o?.meta.txID&&J(Nt,{isExternal:!0,fontSize:`sm`,color:v?`whiteAlpha.600`:`blackAlpha.600`,textAlign:`center`,width:`full`,href:`${y(b.type).explorerUrl}/${o?.meta.txID}`,target:`_blank`,rel:`noopener noreferrer`,children:_(`View transaction on the explorer`)})]})},jm=({onClick:e,hasUnreadNotifications:t,...n})=>J(Dt,{"aria-label":`Notifications`,size:`sm`,variant:`ghost`,position:`absolute`,borderRadius:`50%`,left:`10px`,top:`10px`,onClick:e,icon:Y(j,{position:`relative`,children:[J(vr,{fontSize:`20px`}),t&&J(j,{position:`absolute`,top:`-1px`,right:`-1px`,minWidth:`8px`,height:`8px`,bg:`red.500`,borderRadius:`full`})]}),...n}),Mm=({isOpen:e,onClose:t,selectedToken:n,onTokenSelect:r,availableTokens:i,tokenEstimations:a,walletAddress:s})=>{let{t:c}=X(),{balances:l}=zs(s),[u,d]=H.useState(n),[f,p]=H.useState(!1),m=V(`colors`,`vechain-kit-text-primary`),h=V(`colors`,`vechain-kit-text-secondary`),g=V(`colors`,`vechain-kit-text-tertiary`),_=V(`colors`,`vechain-kit-error`),v=e=>e?g:`transparent`,y=e=>e?m:`transparent`;H.useEffect(()=>{e&&(d(n),p(!1))},[e,n]);let b=()=>{r(u,f),t()},x=e=>{let t=l.find(t=>t.symbol===e);return t?Number(t.balance).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2}):`0.00`},C=e=>{let t=l.find(t=>t.symbol===e),n=a[e];return!t||!n?!1:Number(t.balance)<n.cost};return Y(zo,{isOpen:e,onClose:t,size:`sm`,children:[Y(R,{children:[J(z,{fontSize:`lg`,fontWeight:`semibold`,color:m,children:c(`Fee token`)}),J(z,{fontSize:`sm`,fontWeight:`normal`,color:h,mt:1,children:c(`Select the token to pay the fee with`)})]}),J(F,{children:Y(B,{spacing:2,align:`stretch`,children:[i.map(e=>{let t=o[e],n=u===e,r=a[e]||{cost:0,loading:!0},i=C(e);return J(j,{cursor:i?`not-allowed`:`pointer`,bg:v(n),border:`1px`,borderColor:y(n),borderRadius:`md`,p:3,transition:`all 0.2s ease`,_hover:{backgroundColor:i?v(n):h&&`#ffffff12`,borderColor:i?y(n):h},opacity:i?.5:1,onClick:()=>!i&&d(e),children:Y(N,{spacing:3,justify:`space-between`,children:[Y(N,{spacing:3,flex:1,children:[H.cloneElement(S[e],{boxSize:`36px`,borderRadius:`full`}),Y(B,{align:`start`,spacing:0,children:[J(z,{fontWeight:`medium`,color:m,children:t.symbol}),Y(z,{fontSize:`xs`,color:h,children:[c(`Balance`),`:`,` `,x(e)]}),i&&J(z,{fontSize:`xs`,color:_,children:c(`Insufficient balance`)})]})]}),J(B,{align:`end`,spacing:0,children:r.loading?J(qt,{height:`16px`,width:`60px`}):Y(q,{children:[J(z,{fontSize:`sm`,fontWeight:`semibold`,color:m,children:le(r.cost,2)}),J(z,{fontSize:`xs`,color:h,children:t.symbol})]})})]})},e)}),u!==n&&Y(St,{display:`flex`,alignItems:`center`,justifyContent:`space-between`,children:[J(Ct,{htmlFor:`remember-choice`,mb:`0`,fontSize:`sm`,color:m,children:c(`Use this token for future transactions`)}),J(Xt,{id:`remember-choice`,isChecked:f,onChange:e=>p(e.target.checked),color:m})]})]})}),J(L,{children:Y(B,{spacing:3,w:`full`,children:[J(M,{variant:`vechainKitPrimary`,onClick:b,isDisabled:C(u),children:c(`Apply`)}),J(M,{variant:`ghost`,width:`full`,onClick:t,children:c(`Cancel`)})]})})]})},Nm=({estimation:e,isLoading:t,isLoadingTransaction:n,onTokenChange:r,clauses:i=[],userSelectedToken:a})=>{let{t:s}=X(),{feeDelegation:c}=$(),{connection:l,account:u}=Q(),{preferences:d,reorderTokenPriority:f}=Sm(),{isOpen:p,onOpen:m,onClose:h}=fn(),g=V(`colors`,`vechain-kit-text-primary`),_=V(`colors`,`vechain-kit-text-secondary`),[v,y]=K(()=>{let e={};return d.availableGasTokens.forEach(t=>{e[t]={cost:0,loading:!0}}),e}),{data:b,isLoading:x}=wm({clauses:i,tokens:d.availableGasTokens,enabled:i.length>0});W(()=>{!x&&b&&y(b)},[b,x]),W(()=>{e&&y(t=>({...t,[e.usedToken]:{cost:e.transactionCost||0,loading:!1}}))},[e]),W(()=>{x&&y(d.availableGasTokens.reduce((e,t)=>(e[t]={cost:0,loading:!0},e),{}))},[x,d.availableGasTokens]);let C=U((t,n)=>{n&&f([t,...d.tokenPriority.filter(e=>e!==t)]),r&&t!==e?.usedToken&&r(t)},[e,r,f,d.tokenPriority]);if(c?.delegatorUrl||l.isConnectedWithDappKit||d.availableGasTokens.length===0)return null;let{balances:w}=zs(u?.address??``),T=e=>{let t=w.find(t=>t.symbol===e),n=v[e];return!t||!n||n.loading?!0:Number(t.balance)<n.cost},E=e?.usedToken,D=d.availableGasTokens,O;E?O=E:a&&D.includes(a)?O=a:(O=D.find(e=>v[e]&&!v[e].loading&&!T(e)),O||=D.find(e=>v[e]&&!v[e].loading),O||=D[0]);let k=O?v[O]:void 0,A=E&&e?.transactionCost?e.transactionCost:k?.cost||0,ee=O?o[O]:void 0;return Y(q,{children:[J(bt,{mt:3}),Y(N,{mt:3,w:`full`,justifyContent:`start`,alignItems:`center`,children:[Y(B,{align:`start`,spacing:0,w:`full`,children:[J(z,{fontSize:`sm`,fontWeight:`light`,textAlign:`left`,w:`full`,color:_,children:s(`Fee`)}),J(N,{align:`start`,justifyContent:`space-between`,spacing:0,w:`full`,children:J(N,{justifyContent:`flex-start`,w:`full`,children:t||!E&&(!k||k.loading)||!ee?Y(q,{children:[J(qt,{height:`16px`,width:`120px`,borderRadius:`md`}),J(qt,{height:`16px`,width:`60px`,borderRadius:`md`})]}):Y(q,{children:[Y(z,{color:g,fontSize:`sm`,fontWeight:`semibold`,children:[le(A,2),` `,ee.symbol]}),Y(z,{color:_,fontSize:`xs`,children:[`≈`,` $`,(A*.01).toFixed(2)]})]})})})]}),Y(M,{onClick:m,variant:`outline`,size:`sm`,borderRadius:`full`,px:6,disabled:n,color:_,borderColor:_,_hover:{bg:_},leftIcon:H.cloneElement(S[O||d.availableGasTokens[0]],{boxSize:`20px`,borderRadius:`full`}),children:[J(z,{fontSize:`sm`,fontWeight:`semibold`,children:O||d.availableGasTokens[0]}),J(P,{as:Cr,boxSize:5,color:_})]})]}),J(Mm,{isOpen:p,onClose:h,selectedToken:O||d.availableGasTokens[0],onTokenSelect:C,availableTokens:d.availableGasTokens,tokenEstimations:v,walletAddress:u?.address??``})]})},Pm=Ca`
|
|
201
201
|
from {
|
|
202
202
|
transform: translateY(-100%);
|
|
203
203
|
opacity: 0;
|