@idosgames/wallet 0.6.2 → 0.6.3
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/{bridge-C5z9TgKG.d.cts → bridge-BAyA43hM.d.cts} +1 -1
- package/dist/{bridge-BPZNXQuQ.d.ts → bridge-BsVqE7-T.d.ts} +1 -1
- package/dist/chunk-B4KT5CVC.js +1 -0
- package/dist/chunk-DOWG5IDM.js +1 -0
- package/dist/chunk-NU3WMVH2.js +2 -0
- package/dist/chunk-ZOWZE7MU.js +1 -0
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/{platformWalletLogin-Ysdf-Tt8.d.cts → platformWalletLogin-BBBBN68y.d.cts} +1 -1
- package/dist/{platformWalletLogin-DNC2Ajle.d.ts → platformWalletLogin-BxAoMCd9.d.ts} +1 -1
- package/dist/react/index.cjs +2 -2
- package/dist/react/index.d.cts +8 -1
- package/dist/react/index.d.ts +8 -1
- package/dist/react/index.js +1 -1
- package/dist/react/lazyIndex.cjs +2 -2
- package/dist/react/lazyIndex.d.cts +9 -2
- package/dist/react/lazyIndex.d.ts +9 -2
- package/dist/react/lazyIndex.js +1 -1
- package/dist/react/solanaIndex.cjs +2 -2
- package/dist/react/solanaIndex.d.cts +9 -3
- package/dist/react/solanaIndex.d.ts +9 -3
- package/dist/react/solanaIndex.js +1 -1
- package/dist/topUp-CCNQcHcH.d.cts +18 -0
- package/dist/topUp-CCNQcHcH.d.ts +18 -0
- package/package.json +2 -2
- package/dist/chunk-D2ZPJ33L.js +0 -1
- package/dist/chunk-XJV2C5QX.js +0 -1
package/dist/react/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {p as p$1,o as o$1,j as j$1,h,q as q$
|
|
1
|
+
import {p as p$1,o as o$1,j as j$1,h,q as q$2,r as r$1}from'../chunk-YTTVLBAW.js';export{a as useWalletTopUp}from'../chunk-DOWG5IDM.js';import {a,c as c$1,b as b$1}from'../chunk-NU3WMVH2.js';import'../chunk-ZOWZE7MU.js';import {k,l,m,n,o,p,q as q$1,r,u,b,c}from'../chunk-K3THMWU2.js';export{o as arbitrum,n as base,l as bsc,t as chainById,s as idosChains,k as mainnet,p as optimism,m as polygon,r as polygonAmoy,q as sepolia}from'../chunk-K3THMWU2.js';import {http,createConfig,WagmiProvider,useAccount,usePublicClient,useWalletClient,useConfig,useConnect,useDisconnect,useSwitchChain}from'wagmi';import {injected,coinbaseWallet}from'wagmi/connectors';import {WagmiAdapter}from'@reown/appkit-adapter-wagmi';import {createAppKit}from'@reown/appkit/react';import {QueryClient,QueryClientProvider}from'@tanstack/react-query';import {useState,useRef,useEffect,useMemo}from'react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {getAccount,watchAccount,getWalletClient,getPublicClient}from'wagmi/actions';import {authErrorText}from'@idosgames/core';import {parseUnits}from'viem';var se=[k,l,m,n,o,p,q$1,r],_=new Map;function j(e){let{chains:n=se,walletConnectProjectId:t,appName:o,appUrl:r,appIcon:s,transports:p,connectors:a$1}=e,c=t??"__extension_only__";if(!a$1){let i=_.get(c);if(i)return i}let m={};for(let i of n)m[i.id]=p?.[i.id]??http();let l=r??(typeof window<"u"?window.location.origin:""),w={name:o??"iDosGames",description:o??"iDosGames game",url:l,icons:s?[s]:[]};if(t&&!a$1){let i=n.map(u),d=new WagmiAdapter({networks:i,projectId:t,transports:m});return a(createAppKit({adapters:[d],networks:i,projectId:t,metadata:w,features:{analytics:false,email:false,socials:false}})),_.set(c,d.wagmiConfig),d.wagmiConfig}let f=a$1??[injected(),coinbaseWallet({appName:o??"iDosGames"})],v=createConfig({chains:n,connectors:f,transports:m});return a$1||_.set(c,v),v}function E(e){let{wagmiConfig:n,queryClient:t,children:o}=e,[r]=useState(()=>t??new QueryClient);return jsx(WagmiProvider,{config:n,children:jsx(QueryClientProvider,{client:r,children:o})})}function I(){let{address:e}=useAccount(),n=usePublicClient(),{data:t}=useWalletClient();return !e||!n||!t?null:{account:e,publicClient:n,walletClient:t}}var T="Wallet not connected.";function q(e,n){let t=I();return {connected:!!t,account:t?.account??null,loginWithWallet:(o,r)=>t?q$2({client:e,clients:t,networkID:o,walletAddress:r}):Promise.resolve(c("challenge",T)),depositToken:o=>t?h({client:e,clients:t,titleID:n,...o}):Promise.resolve(b("approve",T)),depositNft:o=>t?j$1({client:e,clients:t,titleID:n,...o}):Promise.resolve(b("deposit-onchain",T)),withdrawToken:o=>t?o$1({client:e,clients:t,...o}):Promise.resolve(b("withdraw-onchain",T)),withdrawNft:o=>t?p$1({client:e,clients:t,...o}):Promise.resolve(b("withdraw-onchain",T))}}function _e(e){let{wagmiConfig:n,...t}=e;return jsx(E,{wagmiConfig:n,children:jsx(fe,{...t})})}function je(e){return e instanceof Error&&(e.name==="ConnectorAlreadyConnectedError"||e.message.includes("already connected"))}function qe(e){let n="Wallet sign-in failed. Please try again.";return e instanceof Error?e.name==="ProviderNotFoundError"||/provider not found/i.test(e.message)?"No crypto wallet found in this browser. Install a wallet extension (e.g. MetaMask) or open this page in your wallet's browser, then try again.":e.name==="UserRejectedRequestError"||/user (rejected|denied|cancelled|canceled)/i.test(e.message)?"Request declined in the wallet.":/timed? ?out/i.test(e.message)?"The wallet did not respond. Open your wallet and try again.":n:n}async function pe(e){let n=await getWalletClient(e).catch(()=>null);if(!n)return null;let t=getPublicClient(e);return t?{account:n.account.address,publicClient:t,walletClient:n}:null}function Oe(e,n=18e4){return getAccount(e).isConnected?Promise.resolve(true):new Promise(t=>{let o=false,r=a=>{o||(o=true,s(),clearTimeout(p),t(a));},s=watchAccount(e,{onChange:a=>{a.isConnected&&r(true);}}),p=setTimeout(()=>r(false),n);})}function Ke(e,n=8e3){let t=o=>o==="reconnecting"||o==="connecting";return t(getAccount(e).status)?new Promise(o=>{let r=false,s=()=>{r||(r=true,p(),clearTimeout(a),o());},p=watchAccount(e,{onChange:c=>{t(c.status)||s();}}),a=setTimeout(s,n);}):Promise.resolve()}function Me(e){let n=r=>e.find(s=>s.id===r||s.type===r),t=n("injected"),o=typeof window<"u"&&window.ethereum!=null;return t&&o?t:n("walletConnect")??t??e[0]}var de=9e4;async function Qe(e){try{let o=(await getAccount(e).connector?.getProvider?.())?.session?.peer?.metadata?.redirect,r=o?.native||o?.universal;return !r||typeof window>"u"?!1:(window.location.href=r,!0)}catch{return false}}function ue(e,n){return new Promise((t,o)=>{let r=setTimeout(()=>o(new Error("The wallet request timed out.")),n);e.then(s=>{clearTimeout(r),t(s);},s=>{clearTimeout(r),o(s instanceof Error?s:new Error(String(s)));});})}function fe(e){let{client:n,networkID:t,onAuthenticated:o,disabled:r,label:s,style:p,autoStart:a,mode:c="login",onLinked:m}=e,l=useConfig(),{isConnected:w}=useAccount(),{connectAsync:f,connectors:v}=useConnect(),i=I(),[d,P]=useState(false),[y,h]=useState(null),[M,Q]=useState(false),V=useRef(0),$=useRef(false),z=async()=>{let we=++V.current,W=()=>V.current===we;P(true),h(null);try{if(await Ke(l),!W())return;if(!getAccount(l).isConnected){let g=b$1();if(g){if(await g.open(),!await Oe(l)){h("No wallet was connected.");return}}else {let H=Me(v);if(!H){h("No wallet connector is configured.");return}try{await f({connector:H});}catch(J){if(!je(J))throw J}}}let C=i??await pe(l);if(!C&&getAccount(l).isConnected&&(await new Promise(g=>setTimeout(g,300)),C=await pe(l),!W()))return;if(!C){h("Wallet client is not available.");return}if(Q(!0),c==="link"){let g=await ue(r$1({client:n,clients:C,networkID:t}),de);if(!W())return;if(g.ok){m?.(g.data.PlayAccess??null);return}h(g.stage==="sign"?"Signature declined.":authErrorText(g.error,"Could not link the wallet."));return}let D=await ue(q$2({client:n,clients:C,networkID:t}),de);if(!W())return;if(D.ok){o();return}h(D.stage==="sign"?"Signature declined.":authErrorText(D.error,"Wallet sign-in failed."));}catch(C){if(!W())return;console.error("[idosgames/wallet] wallet sign-in failed:",C),h(qe(C));}finally{W()&&(P(false),Q(false));}};useEffect(()=>{!a||$.current||($.current=true,z());},[a]);let ge=async()=>{await Qe(l)||await b$1()?.open();};return jsxs(Fragment,{children:[jsx("button",{type:"button",onClick:()=>{M?ge():z();},disabled:r,style:{...Ve,...r?{opacity:.6,cursor:"default"}:null,...p},children:M?"Waiting for signature \u2014 tap to open wallet":d?"Check your wallet\u2026":w?s??(c==="link"?"Link wallet":"Sign in with wallet"):"Connect wallet"}),y&&jsx("span",{role:"alert",style:$e,children:y})]})}var Ve={padding:"11px 16px",borderRadius:"8px",border:"none",background:"#4c3fa8",color:"#fff",font:"inherit",fontWeight:600,cursor:"pointer"},$e={display:"block",marginTop:"6px",color:"#ff9b9b",fontSize:"13px",textAlign:"center"};function rt(e){let{client:n,walletConnectProjectId:t,appName:o,onClose:r,style:s,topUp:p}=e,[a,c]=useState(t??"");useEffect(()=>{if(t)return;let l=true;return (async()=>{let w=await n.blockchain.getDefinitions();if(!l||!w.ok)return;let f=w.data.Blockchain?.WalletLogin?.WalletConnectProjectId;f&&c(f);})(),()=>{l=false;}},[n,t]);let m=useMemo(()=>j({walletConnectProjectId:a||void 0,appName:o}),[a,o]);return jsx(E,{wagmiConfig:m,children:jsx(it,{client:n,onClose:r,style:s,topUp:p})})}function it({client:e,onClose:n,style:t,topUp:o}){let r=q(e,e.titleID),{address:s,isConnected:p,chainId:a}=useAccount(),{connect:c,connectors:m}=useConnect(),{disconnect:l}=useDisconnect(),{switchChainAsync:w}=useSwitchChain();async function f(i){if(!i||a===i)return true;try{return await w({chainId:i}),!0}catch{return false}}let v={networkType:"EVM",address:p&&s?s:null,connectChoices:m.map(i=>({key:i.uid,label:i.name,connect:()=>c({connector:i})})),disconnect:()=>l(),deposit:async({network:i,binding:d,amount:P})=>{if(!d.ContractAddress)return b("approve","This token cannot be deposited.");if(!await f(i.ChainID))return b("approve",`Switch your wallet to chain ${i.ChainID} to continue.`);let y;try{y=parseUnits(P,d.Decimals??18);}catch{return b("approve","Invalid amount.")}return r.depositToken({network:i,tokenAddress:d.ContractAddress,amount:y})},withdraw:async({network:i,networkID:d,currencyID:P,amount:y})=>r.account?await f(i.ChainID)?r.withdrawToken({currencyID:P,networkID:d,walletAddress:r.account,amount:y}):b("request",`Switch your wallet to chain ${i.ChainID} to continue.`):b("request","Wallet not connected.")};return jsx(c$1,{client:e,engine:v,onClose:n,style:t,topUp:o})}export{se as DEFAULT_EVM_CHAINS,E as IDosGamesWalletProvider,_e as WalletLogin,fe as WalletLoginButton,rt as WalletPanel,j as createEvmWalletConfig,q as useEvmBridge,I as useEvmBridgeClients};
|
package/dist/react/lazyIndex.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var viem=require('viem'),core=require('@idosgames/core'),wagmi=require('wagmi'),connectors=require('wagmi/connectors'),appkitAdapterWagmi=require('@reown/appkit-adapter-wagmi'),react$1=require('@reown/appkit/react'),reactQuery=require('@tanstack/react-query'),react=require('react'),jsxRuntime=require('react/jsx-runtime'),actions=require('wagmi/actions'),appkitAdapterSolana=require('@reown/appkit-adapter-solana'),buffer=require('buffer'),web3_js=require('@solana/web3.js');var Tn=Object.defineProperty;var k=(t,e)=>()=>(t&&(e=t(t=0)),e);var Wt=(t,e)=>{for(var n in e)Tn(t,n,{get:e[n],enumerable:true});};function I(t){return t instanceof viem.BaseError?t.shortMessage:t instanceof Error?t.message:String(t)}function f(t,e,n){return {ok:false,stage:t,error:e,...n}}function b(t,e){return {ok:false,stage:t,error:e}}var L=k(()=>{});function Dn(t=typeof window>"u"?"":window.location.hostname){let e=t.toLowerCase();return In.test(e)?true:e!=="localhost"&&e!=="127.0.0.1"?false:globalThis.__IDOS_PREVIEW__!=null}function S(){if(typeof window>"u"||Dn())return false;try{return window.self!==window.top}catch{return true}}function Ue(){if(typeof window>"u")return false;try{return window.parent!==window.top}catch{return true}}function U(t){return f(t,At)}function ee(t){return b(t,At)}var At,In,V=k(()=>{L();At="WALLET_USE_SITE_PANEL",In=/^[a-z0-9]{8}-preview\.idos\.games$/;});function qe(t){return Object.values(exports.idosChains).find(e=>e.id===t)}function Dt(t){return {...t,chainNamespace:"eip155",caipNetworkId:`eip155:${t.id}`}}exports.mainnet=void 0;exports.bsc=void 0;exports.polygon=void 0;exports.base=void 0;exports.arbitrum=void 0;exports.optimism=void 0;exports.sepolia=void 0;exports.polygonAmoy=void 0;exports.idosChains=void 0;exports.solanaMainnet=void 0;exports.solanaDevnet=void 0;var Q=k(()=>{exports.mainnet={id:1,name:"Ethereum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://eth.llamarpc.com"]}},blockExplorers:{default:{name:"Etherscan",url:"https://etherscan.io"}}},exports.bsc={id:56,name:"BNB Smart Chain",nativeCurrency:{name:"BNB",symbol:"BNB",decimals:18},rpcUrls:{default:{http:["https://bsc-dataseed.binance.org"]}},blockExplorers:{default:{name:"BscScan",url:"https://bscscan.com"}}},exports.polygon={id:137,name:"Polygon",nativeCurrency:{name:"POL",symbol:"POL",decimals:18},rpcUrls:{default:{http:["https://polygon-rpc.com"]}},blockExplorers:{default:{name:"PolygonScan",url:"https://polygonscan.com"}}},exports.base={id:8453,name:"Base",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://mainnet.base.org"]}},blockExplorers:{default:{name:"BaseScan",url:"https://basescan.org"}}},exports.arbitrum={id:42161,name:"Arbitrum One",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://arb1.arbitrum.io/rpc"]}},blockExplorers:{default:{name:"Arbiscan",url:"https://arbiscan.io"}}},exports.optimism={id:10,name:"OP Mainnet",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://mainnet.optimism.io"]}},blockExplorers:{default:{name:"Optimistic Etherscan",url:"https://optimistic.etherscan.io"}}},exports.sepolia={id:11155111,name:"Sepolia",testnet:true,nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.sepolia.org"]}},blockExplorers:{default:{name:"Etherscan",url:"https://sepolia.etherscan.io"}}},exports.polygonAmoy={id:80002,name:"Polygon Amoy",testnet:true,nativeCurrency:{name:"POL",symbol:"POL",decimals:18},rpcUrls:{default:{http:["https://rpc-amoy.polygon.technology"]}},blockExplorers:{default:{name:"PolygonScan",url:"https://amoy.polygonscan.com"}}},exports.idosChains={mainnet:exports.mainnet,bsc:exports.bsc,polygon:exports.polygon,base:exports.base,arbitrum:exports.arbitrum,optimism:exports.optimism,sepolia:exports.sepolia,polygonAmoy:exports.polygonAmoy};exports.solanaMainnet={id:"5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",name:"Solana",network:"solana-mainnet",nativeCurrency:{name:"Solana",symbol:"SOL",decimals:9},rpcUrls:{default:{http:["https://api.mainnet-beta.solana.com"]}},blockExplorers:{default:{name:"Solscan",url:"https://solscan.io"}},testnet:false,chainNamespace:"solana",caipNetworkId:"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"},exports.solanaDevnet={id:"EtWTRABZaYq6iMfeYKouRu166VU2xqa1",name:"Solana Devnet",network:"solana-devnet",nativeCurrency:{name:"Solana",symbol:"SOL",decimals:9},rpcUrls:{default:{http:["https://api.devnet.solana.com"]}},blockExplorers:{default:{name:"Solscan",url:"https://solscan.io"}},testnet:true,chainNamespace:"solana",caipNetworkId:"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1"};});function Te(t){xt=t;}function H(){return xt}var xt,ce=k(()=>{xt=null;});function ve(t){let{chains:e=ze,walletConnectProjectId:n,appName:o,appUrl:a,appIcon:r,transports:c,connectors:l}=t,i=n??"__extension_only__";if(!l){let g=Ve.get(i);if(g)return g}let d={};for(let g of e)d[g.id]=c?.[g.id]??wagmi.http();let s=a??(typeof window<"u"?window.location.origin:""),u={name:o??"iDosGames",description:o??"iDosGames game",url:s,icons:r?[r]:[]};if(n&&!l){let g=e.map(Dt),y=new appkitAdapterWagmi.WagmiAdapter({networks:g,projectId:n,transports:d});return Te(react$1.createAppKit({adapters:[y],networks:g,projectId:n,metadata:u,features:{analytics:false,email:false,socials:false}})),Ve.set(i,y.wagmiConfig),y.wagmiConfig}let p=l??[connectors.injected(),connectors.coinbaseWallet({appName:o??"iDosGames"})],m=wagmi.createConfig({chains:e,connectors:p,transports:d});return l||Ve.set(i,m),m}var ze,Ve,je=k(()=>{Q();ce();ze=[exports.mainnet,exports.bsc,exports.polygon,exports.base,exports.arbitrum,exports.optimism,exports.sepolia,exports.polygonAmoy],Ve=new Map;});function de(t){let{wagmiConfig:e,queryClient:n,children:o}=t,[a]=react.useState(()=>n??new reactQuery.QueryClient);return jsxRuntime.jsx(wagmi.WagmiProvider,{config:e,children:jsxRuntime.jsx(reactQuery.QueryClientProvider,{client:a,children:o})})}var Ie=k(()=>{});var De,Lt,$e,Rt,Ye=k(()=>{De=[{type:"function",name:"depositERC20",stateMutability:"nonpayable",inputs:[{name:"token",type:"address"},{name:"amount",type:"uint256"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"}],outputs:[{name:"",type:"bool"}]},{type:"function",name:"withdrawERC20",stateMutability:"nonpayable",inputs:[{name:"token",type:"address"},{name:"to",type:"address"},{name:"amount",type:"uint256"},{name:"burnAmount",type:"uint256"},{name:"splits",type:"tuple[]",components:[{name:"to",type:"address"},{name:"amount",type:"uint256"}]},{name:"nonce",type:"uint256"},{name:"signature",type:"bytes"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"},{name:"deadline",type:"uint256"}],outputs:[]},{type:"function",name:"withdrawERC1155",stateMutability:"nonpayable",inputs:[{name:"token",type:"address"},{name:"to",type:"address"},{name:"id",type:"uint256"},{name:"amount",type:"uint256"},{name:"splits",type:"tuple[]",components:[{name:"to",type:"address"},{name:"amount",type:"uint256"}]},{name:"nonce",type:"uint256"},{name:"signature",type:"bytes"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"},{name:"deadline",type:"uint256"}],outputs:[]},{type:"function",name:"withdrawERC721",stateMutability:"nonpayable",inputs:[{name:"token",type:"address"},{name:"to",type:"address"},{name:"tokenId",type:"uint256"},{name:"nonce",type:"uint256"},{name:"signature",type:"bytes"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"},{name:"deadline",type:"uint256"}],outputs:[]}],Lt=[{type:"function",name:"withdrawERC1155Mint",stateMutability:"nonpayable",inputs:[{name:"collection",type:"address"},{name:"to",type:"address"},{name:"id",type:"uint256"},{name:"amount",type:"uint256"},{name:"splits",type:"tuple[]",components:[{name:"to",type:"address"},{name:"amount",type:"uint256"}]},{name:"nonce",type:"uint256"},{name:"signature",type:"bytes"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"},{name:"deadline",type:"uint256"}],outputs:[]},{type:"function",name:"withdrawERC721Mint",stateMutability:"nonpayable",inputs:[{name:"collection",type:"address"},{name:"to",type:"address"},{name:"tokenId",type:"uint256"},{name:"nonce",type:"uint256"},{name:"signature",type:"bytes"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"},{name:"deadline",type:"uint256"}],outputs:[]}],$e=[{type:"function",name:"approve",stateMutability:"nonpayable",inputs:[{name:"spender",type:"address"},{name:"amount",type:"uint256"}],outputs:[{name:"",type:"bool"}]},{type:"function",name:"allowance",stateMutability:"view",inputs:[{name:"owner",type:"address"},{name:"spender",type:"address"}],outputs:[{name:"",type:"uint256"}]},{type:"function",name:"decimals",stateMutability:"view",inputs:[],outputs:[{name:"",type:"uint8"}]},{type:"function",name:"balanceOf",stateMutability:"view",inputs:[{name:"account",type:"address"}],outputs:[{name:"",type:"uint256"}]}],Rt=[{type:"function",name:"safeTransferFrom",stateMutability:"nonpayable",inputs:[{name:"from",type:"address"},{name:"to",type:"address"},{name:"id",type:"uint256"},{name:"amount",type:"uint256"},{name:"data",type:"bytes"}],outputs:[]},{type:"function",name:"isApprovedForAll",stateMutability:"view",inputs:[{name:"account",type:"address"},{name:"operator",type:"address"}],outputs:[{name:"",type:"bool"}]},{type:"function",name:"setApprovalForAll",stateMutability:"nonpayable",inputs:[{name:"operator",type:"address"},{name:"approved",type:"bool"}],outputs:[]},{type:"function",name:"balanceOf",stateMutability:"view",inputs:[{name:"account",type:"address"},{name:"id",type:"uint256"}],outputs:[{name:"",type:"uint256"}]}];});function Bt(t,e,n){return viem.encodeAbiParameters([{type:"string"},{type:"string"},{type:"string"}],[t,e,core.normalizeBlockchainCategory(n)])}var _t=k(()=>{});async function Z(t,e){let{walletClient:n,publicClient:o,account:a}=t,r=await n.writeContract({address:e.address,abi:e.abi,functionName:e.functionName,args:e.args,account:a,chain:n.chain,value:e.value});if((await o.waitForTransactionReceipt({hash:r})).status==="reverted")throw new Error(`On-chain transaction reverted (${r}).`);return r}var Qe=k(()=>{});function Ot(t){let e=t.RewardPoolAddress;return e||null}async function Mt(t,e,n,o){return await t.publicClient.readContract({address:e,abi:$e,functionName:"allowance",args:[t.account,n]})>=o?null:Z(t,{address:e,abi:$e,functionName:"approve",args:[n,o]})}async function Ze(t){let{client:e,clients:n,network:o,tokenAddress:a,amount:r,titleID:c,category:l}=t;if(S())return U("approve");let i=e.auth.context?.userID;if(!i)return f("approve","Not logged in.");let d=Ot(o);if(!d)return f("approve","Network has no RewardPoolAddress.");if(r<=0n)return f("approve","Amount must be positive.");try{await Mt(n,a,d,r);}catch(p){return f("approve",I(p))}let s;try{s=await Z(n,{address:d,abi:De,functionName:"depositERC20",args:[a,r,i,c,l??""]});}catch(p){return f("deposit-onchain",I(p))}let u=await e.blockchain.depositToken(o.NetworkID??"",s);return u.ok?{ok:true,onChainTxHash:s,data:u.data}:f("report",u.error,{onChainTxHash:s})}async function Je(t){let{client:e,clients:n,network:o,nftContractAddress:a,tokenId:r,amount:c,titleID:l,category:i}=t;if(S())return U("deposit-onchain");let d=e.auth.context?.userID;if(!d)return f("deposit-onchain","Not logged in.");let s=Ot(o);if(!s)return f("deposit-onchain","Network has no RewardPoolAddress.");if(c<=0n)return f("deposit-onchain","Amount must be positive.");let u=Bt(d,l,i),p;try{p=await Z(n,{address:a,abi:Rt,functionName:"safeTransferFrom",args:[n.account,s,r,c,u]});}catch(g){return f("deposit-onchain",I(g))}let m=await e.blockchain.depositNFT(o.NetworkID??"",p);return m.ok?{ok:true,onChainTxHash:p,data:m.data}:f("report",m.error,{onChainTxHash:p})}var Ft=k(()=>{Ye();_t();Qe();L();V();});function Kt(t){return (t.Splits??[]).map(e=>({to:e.To,amount:BigInt(e.Amount??"0")}))}async function Gt(t,e){return Z(t,{address:e.ContractAddress,abi:De,functionName:"withdrawERC20",args:[e.TokenAddress,e.WalletAddress,BigInt(e.Amount??"0"),BigInt(e.BurnAmount??"0"),Kt(e),BigInt(e.Nonce??"0"),e.Signature??"0x",e.UserID??"",e.TitleID??"",e.Category??"",BigInt(e.Deadline??"0")]})}async function Ut(t,e){return Z(t,{address:e.ContractAddress,abi:Lt,functionName:"withdrawERC1155Mint",args:[e.TokenAddress,e.WalletAddress,BigInt(e.TokenId??"0"),BigInt(e.Amount??"0"),Kt(e),BigInt(e.Nonce??"0"),e.Signature??"0x",e.UserID??"",e.TitleID??"",e.Category??"",BigInt(e.Deadline??"0")]})}async function Xe(t){let{client:e,clients:n,currencyID:o,networkID:a,walletAddress:r,amount:c,category:l}=t;if(S())return U("request");let i=await e.blockchain.requestTokenWithdrawal(o,a,r,c,l);if(!i.ok)return f("request",i.error);let d=i.data.EvmSignature,s=i.data.TitleTransactionID??void 0;if(!d)return f("request","Withdrawal response carried no EVM signature.",{titleTransactionID:s});let u;try{u=await Gt(n,d);}catch(m){return f("withdraw-onchain",I(m),{titleTransactionID:s})}let p=await Ht(e,s,u);return p.ok?{ok:true,onChainTxHash:u,data:i.data}:p}async function et(t){let{client:e,clients:n,itemID:o,networkID:a,walletAddress:r,amount:c,category:l}=t;if(S())return U("request");let i=await e.blockchain.requestNFTWithdrawal(o,a,r,c,l);if(!i.ok)return f("request",i.error);let d=i.data.EvmSignature,s=i.data.TitleTransactionID??void 0;if(!d)return f("request","Withdrawal response carried no EVM signature.",{titleTransactionID:s});let u;try{u=await Ut(n,d);}catch(m){return f("withdraw-onchain",I(m),{titleTransactionID:s})}let p=await Ht(e,s,u);return p.ok?{ok:true,onChainTxHash:u,data:i.data}:p}async function Ht(t,e,n){if(!e)return f("confirm","Missing TitleTransactionID.",{onChainTxHash:n});let o=await t.blockchain.confirmWithdrawal(e,n);return o.ok?{ok:true,onChainTxHash:n,data:o.data}:f("confirm",o.error,{onChainTxHash:n,titleTransactionID:e})}var qt=k(()=>{Ye();Qe();L();V();});async function he(t){let{client:e,clients:n,networkID:o}=t;if(S())return ee("challenge");let a=t.walletAddress??n.account,r=await e.auth.requestWalletChallenge(a,o);if(!r.ok)return b("challenge",r.error);let c;try{c=await n.walletClient.signMessage({account:n.account,message:r.data.Message});}catch(i){return b("sign",I(i))}let l=await e.auth.loginWithWallet(a,o,c);return l.ok?{ok:true,data:l.data}:b("login",l.error)}async function tt(t){let{client:e,clients:n,networkID:o}=t;if(S())return ee("challenge");let a=t.walletAddress??n.account,r=await e.auth.linkWallet(a,o);if(!r.ok)return b("challenge",r.error);if(!r.data.Challenge)return b("challenge","No challenge was issued.");let c;try{c=await n.walletClient.signMessage({account:n.account,message:r.data.Challenge});}catch(i){return b("sign",I(i))}let l=await e.auth.linkWallet(a,o,c);return l.ok?{ok:true,data:l.data}:b("login",l.error)}var Vt=k(()=>{L();V();});var nt=k(()=>{Ft();qt();Vt();});function be(){let{address:t}=wagmi.useAccount(),e=wagmi.usePublicClient(),{data:n}=wagmi.useWalletClient();return !t||!e||!n?null:{account:t,publicClient:e,walletClient:n}}function xe(t,e){let n=be();return {connected:!!n,account:n?.account??null,loginWithWallet:(o,a)=>n?he({client:t,clients:n,networkID:o,walletAddress:a}):Promise.resolve(b("challenge",ke)),depositToken:o=>n?Ze({client:t,clients:n,titleID:e,...o}):Promise.resolve(f("approve",ke)),depositNft:o=>n?Je({client:t,clients:n,titleID:e,...o}):Promise.resolve(f("deposit-onchain",ke)),withdrawToken:o=>n?Xe({client:t,clients:n,...o}):Promise.resolve(f("withdraw-onchain",ke)),withdrawNft:o=>n?et({client:t,clients:n,...o}):Promise.resolve(f("withdraw-onchain",ke))}}var ke,Ne=k(()=>{nt();L();ke="Wallet not connected.";});function ue(t,e){switch(t){case null:case void 0:case "":return e;case "PLAY_ACCESS_WALLET_USED_BY_ANOTHER_ACCOUNT":return "This wallet already plays with another account.";case "WALLET_UNLINK_COOLDOWN":return "This wallet was unlinked from another account less than 7 days ago. Try again after the 7 days.";case "WALLET_CHANGES_TOO_FREQUENT":return "Too many wallets were changed this week. Try again in a few days.";case "PLAY_ACCESS_WALLET_LOGIN_ONLY":return "This game is played with a wallet login only.";case "INVALID_WALLET_SIGNATURE":return "The signature does not match the wallet. Please try again.";case "WALLET_CHALLENGE_EXPIRED":return "The request expired. Please try again.";default:return t}}var ot=k(()=>{});function Zt(t){let{wagmiConfig:e,...n}=t;return jsxRuntime.jsx(de,{wagmiConfig:e,children:jsxRuntime.jsx(at,{...n})})}function ro(t){return t instanceof Error&&(t.name==="ConnectorAlreadyConnectedError"||t.message.includes("already connected"))}function ao(t){let e="Wallet sign-in failed. Please try again.";return t instanceof Error?t.name==="ProviderNotFoundError"||/provider not found/i.test(t.message)?"No crypto wallet found in this browser. Install a wallet extension (e.g. MetaMask) or open this page in your wallet's browser, then try again.":t.name==="UserRejectedRequestError"||/user (rejected|denied|cancelled|canceled)/i.test(t.message)?"Request declined in the wallet.":/timed? ?out/i.test(t.message)?"The wallet did not respond. Open your wallet and try again.":e:e}async function jt(t){let e=await actions.getWalletClient(t).catch(()=>null);if(!e)return null;let n=actions.getPublicClient(t);return n?{account:e.account.address,publicClient:n,walletClient:e}:null}function io(t,e=18e4){return actions.getAccount(t).isConnected?Promise.resolve(true):new Promise(n=>{let o=false,a=l=>{o||(o=true,r(),clearTimeout(c),n(l));},r=actions.watchAccount(t,{onChange:l=>{l.isConnected&&a(true);}}),c=setTimeout(()=>a(false),e);})}function so(t,e=8e3){let n=o=>o==="reconnecting"||o==="connecting";return n(actions.getAccount(t).status)?new Promise(o=>{let a=false,r=()=>{a||(a=true,c(),clearTimeout(l),o());},c=actions.watchAccount(t,{onChange:i=>{n(i.status)||r();}}),l=setTimeout(r,e);}):Promise.resolve()}function lo(t){let e=a=>t.find(r=>r.id===a||r.type===a),n=e("injected"),o=typeof window<"u"&&window.ethereum!=null;return n&&o?n:e("walletConnect")??n??t[0]}async function co(t){try{let o=(await actions.getAccount(t).connector?.getProvider?.())?.session?.peer?.metadata?.redirect,a=o?.native||o?.universal;return !a||typeof window>"u"?!1:(window.location.href=a,!0)}catch{return false}}function Yt(t,e){return new Promise((n,o)=>{let a=setTimeout(()=>o(new Error("The wallet request timed out.")),e);t.then(r=>{clearTimeout(a),n(r);},r=>{clearTimeout(a),o(r instanceof Error?r:new Error(String(r)));});})}function at(t){let{client:e,networkID:n,onAuthenticated:o,disabled:a,label:r,style:c,autoStart:l,mode:i="login",onLinked:d}=t,s=wagmi.useConfig(),{isConnected:u}=wagmi.useAccount(),{connectAsync:p,connectors:m}=wagmi.useConnect(),g=be(),[y,w]=react.useState(false),[W,A]=react.useState(null),[B,M]=react.useState(false),_=react.useRef(0),j=react.useRef(false),N=async()=>{let h=++_.current,C=()=>_.current===h;w(true),A(null);try{if(await so(s),!C())return;if(!actions.getAccount(s).isConnected){let v=H();if(v){if(await v.open(),!await io(s)){A("No wallet was connected.");return}}else {let X=lo(m);if(!X){A("No wallet connector is configured.");return}try{await p({connector:X});}catch(G){if(!ro(G))throw G}}}let T=g??await jt(s);if(!T&&actions.getAccount(s).isConnected&&(await new Promise(v=>setTimeout(v,300)),T=await jt(s),!C()))return;if(!T){A("Wallet client is not available.");return}if(M(!0),i==="link"){let v=await Yt(tt({client:e,clients:T,networkID:n}),$t);if(!C())return;if(v.ok){d?.(v.data.PlayAccess??null);return}A(v.stage==="sign"?"Signature declined.":ue(v.error,"Could not link the wallet."));return}let F=await Yt(he({client:e,clients:T,networkID:n}),$t);if(!C())return;if(F.ok){o();return}A(F.stage==="sign"?"Signature declined.":ue(F.error,"Wallet sign-in failed."));}catch(T){if(!C())return;console.error("[idosgames/wallet] wallet sign-in failed:",T),A(ao(T));}finally{C()&&(w(false),M(false));}};react.useEffect(()=>{!l||j.current||(j.current=true,N());},[l]);let q=async()=>{await co(s)||await H()?.open();};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{B?q():N();},disabled:a,style:{...uo,...a?{opacity:.6,cursor:"default"}:null,...c},children:B?"Waiting for signature \u2014 tap to open wallet":y?"Check your wallet\u2026":u?r??(i==="link"?"Link wallet":"Sign in with wallet"):"Connect wallet"}),W&&jsxRuntime.jsx("span",{role:"alert",style:po,children:W})]})}var $t,uo,po,Jt=k(()=>{ce();ot();nt();Ie();Ne();$t=9e4;uo={padding:"11px 16px",borderRadius:"8px",border:"none",background:"#4c3fa8",color:"#fff",font:"inherit",fontWeight:600,cursor:"pointer"},po={display:"block",marginTop:"6px",color:"#ff9b9b",fontSize:"13px",textAlign:"center"};});function Be({client:t,engine:e,onClose:n,style:o}){let[,a]=react.useReducer(h=>h+1,0),[r,c]=react.useState({}),[l,i]=react.useState({}),[d,s]=react.useState(""),[u,p]=react.useState(""),[m,g]=react.useState(""),[y,w]=react.useState(false),[W,A]=react.useState(null);react.useEffect(()=>{let h=true;return (async()=>{let C=await t.blockchain.getDefinitions();if(await t.blockchain.getUserState(),!h||!C.ok)return;let T={};for(let[F,v]of Object.entries(C.data.Blockchain?.Networks??{}))v.Type===e.networkType&&(T[F]=v);c(T),i(C.data.CryptoCurrencies??{}),s(Object.keys(T)[0]??"");})(),()=>{h=false;}},[t,e.networkType]),react.useEffect(()=>t.on("user:anyUpdated",a),[t]);let B=react.useMemo(()=>Object.entries(l).filter(([,h])=>h.Networks?.some(C=>C.NetworkID===d&&!!C.ContractAddress)),[l,d]);react.useEffect(()=>{let h=B[0]?.[0]??"";p(C=>B.some(([T])=>T===C)?C:h);},[B]);let M=d?r[d]:void 0,_=u?l[u]?.Networks?.find(h=>h.NetworkID===d):void 0,j=u?t.data.user.getCryptoCurrencyAmount(u):"0",N=!!e.address;async function q(h){w(true),A(null);try{let C=await h();A(C),C.ok&&await t.blockchain.getUserState();}finally{w(false);}}return jsxRuntime.jsxs("div",{style:{...wo,...o},children:[jsxRuntime.jsxs("div",{style:{...lt,justifyContent:"space-between"},children:[jsxRuntime.jsx("span",{style:ho,children:"Crypto wallet"}),n&&jsxRuntime.jsx("button",{type:"button",style:Re,onClick:n,children:"\u2715"})]}),N?jsxRuntime.jsxs("div",{style:lt,children:[jsxRuntime.jsxs("span",{style:{...z,flex:1,alignSelf:"center"},children:[e.address.slice(0,6),"\u2026",e.address.slice(-4)]}),jsxRuntime.jsx("button",{type:"button",style:Re,onClick:e.disconnect,children:"Disconnect"})]}):jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[jsxRuntime.jsx("span",{style:z,children:"Connect a browser or mobile wallet"}),e.connectChoices.length===0?jsxRuntime.jsx("span",{style:z,children:"Wallet connection is not configured for this title."}):e.connectChoices.map(h=>jsxRuntime.jsx("button",{type:"button",style:Re,onClick:h.connect,children:h.label},h.key))]}),Object.keys(r).length===0?jsxRuntime.jsxs("span",{style:z,children:["No ",e.networkType," networks configured for this title."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{style:z,children:"Network"}),jsxRuntime.jsx("select",{style:st,value:d,onChange:h=>s(h.target.value),children:Object.entries(r).map(([h,C])=>jsxRuntime.jsx("option",{value:h,children:C.DisplayName??h},h))})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{style:z,children:"Token"}),jsxRuntime.jsxs("select",{style:st,value:u,onChange:h=>p(h.target.value),children:[B.length===0&&jsxRuntime.jsx("option",{value:"",children:"\u2014 no depositable tokens \u2014"}),B.map(([h,C])=>jsxRuntime.jsx("option",{value:h,children:C.DisplayName??h},h))]})]}),jsxRuntime.jsxs("div",{style:z,children:["In-game balance: ",jsxRuntime.jsx("b",{children:j})," ",u]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{style:z,children:"Amount"}),jsxRuntime.jsx("input",{style:st,inputMode:"decimal",placeholder:"0.0",value:m,onChange:h=>g(h.target.value)})]}),jsxRuntime.jsxs("div",{style:lt,children:[jsxRuntime.jsx("button",{type:"button",style:{...ko,flex:1,opacity:y?.6:1},disabled:y||!N||!_?.ContractAddress,onClick:()=>{!M||!_||q(()=>e.deposit({network:M,binding:_,currencyID:u,amount:m||"0"}));},children:"Deposit"}),jsxRuntime.jsx("button",{type:"button",style:{...Re,flex:1,opacity:y?.6:1},disabled:y||!N||!u,onClick:()=>{M&&q(()=>e.withdraw({network:M,networkID:d,currencyID:u,amount:m||"0"}));},children:"Withdraw"})]})]}),W&&jsxRuntime.jsx(bo,{result:W})]})}function bo({result:t}){let e={fontSize:12,borderRadius:8,padding:"8px 10px",background:t.ok?"#1e3a2a":"#3a1e28",color:t.ok?"#8ef0b0":"#f2a0b4",wordBreak:"break-all"};return t.ok?jsxRuntime.jsxs("div",{style:e,children:["\u2713 Done \xB7 tx ",t.onChainTxHash]}):jsxRuntime.jsxs("div",{style:e,children:["\u2715 [",t.stage,"] ",t.error,t.titleTransactionID?` \xB7 already debited (tx ${t.titleTransactionID}) \u2014 retry/confirm, don't re-request`:""]})}var wo,ho,z,st,ko,Re,lt,ct=k(()=>{wo={pointerEvents:"auto",background:"#04276bf5",border:"1px solid #1e59c8",borderRadius:12,padding:16,color:"#fff",width:320,boxSizing:"border-box",fontFamily:"system-ui, sans-serif",display:"flex",flexDirection:"column",gap:10,maxHeight:"80vh",overflow:"auto"},ho={fontWeight:700,fontSize:16},z={fontSize:12,opacity:.7},st={background:"#052e7e",border:"1px solid #1e59c8",borderRadius:8,color:"#fff",padding:"8px 10px",width:"100%",boxSizing:"border-box"},ko={background:"#0d66fe",color:"#fff",border:"none",borderRadius:8,padding:"9px 14px",fontWeight:700,cursor:"pointer"},Re={background:"#1e59c8",color:"#fff",border:"none",borderRadius:8,padding:"7px 12px",fontWeight:600,cursor:"pointer"},lt={display:"flex",gap:8};});function Xt(t){let{client:e,walletConnectProjectId:n,appName:o,onClose:a,style:r}=t,[c,l]=react.useState(n??"");react.useEffect(()=>{if(n)return;let d=true;return (async()=>{let s=await e.blockchain.getDefinitions();if(!d||!s.ok)return;let u=s.data.Blockchain?.WalletLogin?.WalletConnectProjectId;u&&l(u);})(),()=>{d=false;}},[e,n]);let i=react.useMemo(()=>ve({walletConnectProjectId:c||void 0,appName:o}),[c,o]);return jsxRuntime.jsx(de,{wagmiConfig:i,children:jsxRuntime.jsx(Do,{client:e,onClose:a,style:r})})}function Do({client:t,onClose:e,style:n}){let o=xe(t,t.titleID),{address:a,isConnected:r,chainId:c}=wagmi.useAccount(),{connect:l,connectors:i}=wagmi.useConnect(),{disconnect:d}=wagmi.useDisconnect(),{switchChainAsync:s}=wagmi.useSwitchChain();async function u(m){if(!m||c===m)return true;try{return await s({chainId:m}),!0}catch{return false}}let p={networkType:"EVM",address:r&&a?a:null,connectChoices:i.map(m=>({key:m.uid,label:m.name,connect:()=>l({connector:m})})),disconnect:()=>d(),deposit:async({network:m,binding:g,amount:y})=>{if(!g.ContractAddress)return f("approve","This token cannot be deposited.");if(!await u(m.ChainID))return f("approve",`Switch your wallet to chain ${m.ChainID} to continue.`);let w;try{w=viem.parseUnits(y,g.Decimals??18);}catch{return f("approve","Invalid amount.")}return o.depositToken({network:m,tokenAddress:g.ContractAddress,amount:w})},withdraw:async({network:m,networkID:g,currencyID:y,amount:w})=>o.account?await u(m.ChainID)?o.withdrawToken({currencyID:y,networkID:g,walletAddress:o.account,amount:w}):f("request",`Switch your wallet to chain ${m.ChainID} to continue.`):f("request","Wallet not connected.")};return jsxRuntime.jsx(Be,{client:t,engine:p,onClose:e,style:n})}var en=k(()=>{je();Ie();Ne();L();ct();});var ut={};Wt(ut,{DEFAULT_EVM_CHAINS:()=>ze,IDosGamesWalletProvider:()=>de,WalletLogin:()=>Zt,WalletLoginButton:()=>at,WalletPanel:()=>Xt,arbitrum:()=>exports.arbitrum,base:()=>exports.base,bsc:()=>exports.bsc,chainById:()=>qe,createEvmWalletConfig:()=>ve,idosChains:()=>exports.idosChains,mainnet:()=>exports.mainnet,optimism:()=>exports.optimism,polygon:()=>exports.polygon,polygonAmoy:()=>exports.polygonAmoy,sepolia:()=>exports.sepolia,useEvmBridge:()=>xe,useEvmBridgeClients:()=>be});var pt=k(()=>{je();Q();Ie();Ne();Jt();en();});function _e(t){let{walletConnectProjectId:e,appName:n,appUrl:o,appIcon:a,wallets:r}=t,c=tn.get(e);if(c)return c;let l=t.networks??[exports.solanaMainnet],i=o??(typeof window<"u"?window.location.origin:""),d={name:n??"iDosGames",description:n??"iDosGames game",url:i,icons:a?[a]:[]},s=new appkitAdapterSolana.SolanaAdapter(r?{wallets:r}:{});return Te(react$1.createAppKit({adapters:[s],networks:l,projectId:e,metadata:d,features:{analytics:false,email:false,socials:false}})),tn.set(e,s),s}var tn,mt=k(()=>{Q();ce();tn=new Map;});async function Pe(t){let{client:e,adapter:n,network:o,mint:a,amountRaw:r,titleID:c,category:l}=t;if(S())return U("deposit-onchain");let i=e.auth.context?.userID;if(!i)return f("deposit-onchain","Not logged in.");if(r<=0n)return f("deposit-onchain","Amount must be positive.");let d;try{d=await n.depositSpl({mint:a,amountRaw:r,userID:i,titleID:c,category:core.normalizeBlockchainCategory(l)});}catch(u){return f("deposit-onchain",I(u))}let s=await e.blockchain.depositToken(o.NetworkID??"",d);return s.ok?{ok:true,onChainTxHash:d,data:s.data}:f("report",s.error,{onChainTxHash:d})}async function Se(t){let{client:e,adapter:n,currencyID:o,networkID:a,walletAddress:r,amount:c,category:l}=t;if(S())return U("request");let i=await e.blockchain.requestTokenWithdrawal(o,a,r,c,l);if(!i.ok)return f("request",i.error);let d=i.data.SolanaSignature,s=i.data.TitleTransactionID??void 0;if(!d)return f("request","Withdrawal response carried no Solana signature.",{titleTransactionID:s});let u;try{u=await n.submitWithdrawal(d);}catch(m){return f("withdraw-onchain",I(m),{titleTransactionID:s})}if(!s)return f("confirm","Missing TitleTransactionID.",{onChainTxHash:u});let p=await e.blockchain.confirmWithdrawal(s,u);return p.ok?{ok:true,onChainTxHash:u,data:i.data}:f("confirm",p.error,{onChainTxHash:u,titleTransactionID:s})}var nn=k(()=>{L();V();});async function We(t){let{client:e,networkID:n,walletAddress:o,signMessage:a}=t;if(S())return ee("challenge");let r=await e.auth.requestWalletChallenge(o,n);if(!r.ok)return b("challenge",r.error);let c;try{let i=await a(new TextEncoder().encode(r.data.Message));c=on(i);}catch(i){return b("sign",I(i))}let l=await e.auth.loginWithWallet(o,n,c);return l.ok?{ok:true,data:l.data}:b("login",l.error)}async function ft(t){let{client:e,networkID:n,walletAddress:o,signMessage:a}=t;if(S())return ee("challenge");let r=await e.auth.linkWallet(o,n);if(!r.ok)return b("challenge",r.error);if(!r.data.Challenge)return b("challenge","No challenge was issued.");let c;try{let i=await a(new TextEncoder().encode(r.data.Challenge));c=on(i);}catch(i){return b("sign",I(i))}let l=await e.auth.linkWallet(o,n,c);return l.ok?{ok:true,data:l.data}:b("login",l.error)}function on(t){let e="0x";for(let n of t)e+=n.toString(16).padStart(2,"0");return e}var rn=k(()=>{L();V();});var Oe=k(()=>{nn();rn();});function sn(t,e,n){let{address:o}=react$1.useAppKitAccount(),{walletProvider:a}=react$1.useAppKitProvider("solana"),r=o??null,c=a?.signMessage?.bind(a);return {connected:!!r,account:r,loginWithWallet:(l,i)=>{let d=i??r;return d?c?We({client:t,networkID:l,walletAddress:d,signMessage:c}):Promise.resolve(b("sign","The connected wallet does not support message signing.")):Promise.resolve(b("challenge",an))},depositToken:l=>Pe({client:t,adapter:n,titleID:e,...l}),withdrawToken:l=>{let i=l.walletAddress??r;return i?Se({client:t,adapter:n,...l,walletAddress:i}):Promise.resolve(f("request",an))}}}var an,ln=k(()=>{Oe();L();an="Wallet not connected.";});function Fo(t){try{let n=t?.session?.peer?.metadata?.redirect,o=n?.native||n?.universal;return !o||typeof window>"u"?!1:(window.location.href=o,!0)}catch{return false}}function dn(t,e){return new Promise((n,o)=>{let a=setTimeout(()=>o(new Error("The wallet request timed out.")),e);t.then(r=>{clearTimeout(a),n(r);},r=>{clearTimeout(a),o(r instanceof Error?r:new Error(String(r)));});})}function Ko(t){let e="Wallet sign-in failed. Please try again.";return t instanceof Error?/user (rejected|denied|cancelled|canceled)|rejected the request/i.test(t.message)?"Request declined in the wallet.":/timed? ?out/i.test(t.message)?"The wallet did not respond. Open your wallet and try again.":e:e}function pn(t){let{client:e,networkID:n,onAuthenticated:o,disabled:a,label:r,style:c,autoStart:l,mode:i="login",onLinked:d}=t,{address:s,isConnected:u}=react$1.useAppKitAccount(),{walletProvider:p}=react$1.useAppKitProvider("solana"),[m,g]=react.useState(false),[y,w]=react.useState(null),[W,A]=react.useState(false),[B,M]=react.useState(false),_=react.useRef(null),j=react.useRef(0),N=react.useCallback(()=>{_.current&&clearTimeout(_.current),_.current=null;},[]);react.useEffect(()=>N,[N]);let q=react.useRef(false),h=react.useCallback(async()=>{let F=++j.current,v=()=>j.current===F,X=p?.signMessage?.bind(p);if(!s||!X){w("The connected wallet cannot sign messages."),g(false);return}g(true),w(null);try{if(M(!0),i==="link"){let Ae=await dn(ft({client:e,networkID:n,walletAddress:s,signMessage:X}),cn);if(!v())return;if(Ae.ok){d?.(Ae.data.PlayAccess??null);return}w(Ae.stage==="sign"?"Signature declined.":ue(Ae.error,"Could not link the wallet."));return}let G=await dn(We({client:e,networkID:n,walletAddress:s,signMessage:X}),cn);if(!v())return;if(G.ok){o();return}w(G.stage==="sign"?"Signature declined.":ue(G.error,"Wallet sign-in failed."));}catch(G){if(!v())return;console.error("[idosgames/wallet] solana sign-in failed:",G),w(Ko(G));}finally{v()&&(g(false),M(false));}},[s,p,e,n,o,i,d]),C=react.useCallback(()=>{Fo(p)||H()?.open();},[p]);react.useEffect(()=>{!W||!u||!s||!p||(A(false),N(),h());},[W,u,s,p,h,N]);let T=()=>{if(B){C();return}if(w(null),q.current=true,u&&s&&p){h();return}let F=H();if(!F){w("Wallet sign-in is not configured for this title.");return}g(true),A(true),N(),_.current=setTimeout(()=>{A(false),g(false),w("No wallet was connected.");},Mo),F.open();};return react.useEffect(()=>{!l||q.current||(q.current=true,T());},[l]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",onClick:T,disabled:a,style:{...Go,...a?{opacity:.6,cursor:"default"}:null,...c},children:B?"Waiting for signature \u2014 tap to open wallet":m?"Check your wallet\u2026":u?r??(i==="link"?"Link wallet":"Sign in with wallet"):"Connect wallet"}),y&&jsxRuntime.jsx("span",{role:"alert",style:Uo,children:y})]})}var Mo,cn,Go,Uo,mn=k(()=>{ot();Oe();ce();Mo=18e4,cn=9e4;Go={padding:"11px 16px",borderRadius:"8px",border:"none",background:"#4c3fa8",color:"#fff",font:"inherit",fontWeight:600,cursor:"pointer"},Uo={display:"block",marginTop:"6px",color:"#ff9b9b",fontSize:"13px",textAlign:"center"};});function Fe(t){let e=(t??"").replace(/^0x/i,""),n=new Uint8Array(e.length>>1);for(let o=0;o<n.length;o++)n[o]=parseInt(e.slice(o*2,o*2+2),16);return n}function pe(t){let e=buffer.Buffer.alloc(8);return e.writeBigUInt64LE(BigInt(t||0)),e}function tr(t){let e=buffer.Buffer.alloc(8);return e.writeBigInt64LE(BigInt(t||0)),e}function fe(t){let e=buffer.Buffer.from(t??"","utf8"),n=buffer.Buffer.alloc(4);return n.writeUInt32LE(e.length),buffer.Buffer.concat([n,e])}function nr(t){return buffer.Buffer.concat([buffer.Buffer.from(Yo,"hex"),pe(t.amountRaw),fe(t.userID),fe(t.titleID),fe(t.category)])}function or(t){let e=t.Splits??[],n=buffer.Buffer.alloc(4);return n.writeUInt32LE(e.length),buffer.Buffer.concat([buffer.Buffer.from(t.Domain==="SPL_DEV"?Zo:Qo,"hex"),pe(t.Amount),pe(t.BurnAmount),pe(t.Nonce),tr(t.ExpiresAt),n,...e.map(o=>buffer.Buffer.concat([buffer.Buffer.from(new web3_js.PublicKey(o.To??"").toBytes()),pe(o.Amount)])),fe(t.UserID),fe(t.TitleID),fe(t.Category)])}function me(t,e,n){return web3_js.PublicKey.findProgramAddressSync([e.toBuffer(),n.toBuffer(),t.toBuffer()],Ke)[0]}function rr(t,e,n,o,a){return new web3_js.TransactionInstruction({programId:Ke,keys:[{pubkey:t,isSigner:true,isWritable:true},{pubkey:e,isSigner:false,isWritable:true},{pubkey:n,isSigner:false,isWritable:false},{pubkey:o,isSigner:false,isWritable:false},{pubkey:web3_js.SystemProgram.programId,isSigner:false,isWritable:false},{pubkey:a,isSigner:false,isWritable:false}],data:buffer.Buffer.from([1])})}function ge(t,...e){return web3_js.PublicKey.findProgramAddressSync(e,t)[0]}function ar(t){let{programId:e,user:n,mint:o,tokenProgram:a}=t,r=ge(e,buffer.Buffer.from("vault"));return new web3_js.TransactionInstruction({programId:e,keys:[{pubkey:ge(e,buffer.Buffer.from("config")),isSigner:false,isWritable:false},{pubkey:r,isSigner:false,isWritable:true},{pubkey:o,isSigner:false,isWritable:false},{pubkey:n,isSigner:true,isWritable:true},{pubkey:me(o,n,a),isSigner:false,isWritable:true},{pubkey:me(o,r,a),isSigner:false,isWritable:true},{pubkey:a,isSigner:false,isWritable:false},{pubkey:Ke,isSigner:false,isWritable:false},{pubkey:web3_js.SystemProgram.programId,isSigner:false,isWritable:false}],data:nr(t)})}function ir(t){let{sig:e,payer:n,tokenProgram:o}=t,a=new web3_js.PublicKey(e.ProgramID??""),r=new web3_js.PublicKey(e.Mint??""),c=new web3_js.PublicKey(e.WalletAddress??""),l=ge(a,buffer.Buffer.from("vault")),i=new web3_js.PublicKey(Jo),d=(e.Splits??[]).map(g=>new web3_js.PublicKey(g.To??"")),s=d.map(g=>me(r,g,o)),u=web3_js.Ed25519Program.createInstructionWithPublicKey({publicKey:Fe(e.Ed25519PublicKey),message:Fe(e.Ed25519Message),signature:Fe(e.SignatureHex)}),p=d.map((g,y)=>rr(n,s[y],g,r,o)),m=new web3_js.TransactionInstruction({programId:a,keys:[{pubkey:ge(a,buffer.Buffer.from("config")),isSigner:false,isWritable:false},{pubkey:n,isSigner:true,isWritable:true},{pubkey:l,isSigner:false,isWritable:true},{pubkey:ge(a,buffer.Buffer.from("nonce"),pe(e.Nonce)),isSigner:false,isWritable:true},{pubkey:r,isSigner:false,isWritable:false},{pubkey:c,isSigner:false,isWritable:false},{pubkey:me(r,l,o),isSigner:false,isWritable:true},{pubkey:me(r,c,o),isSigner:false,isWritable:true},{pubkey:i,isSigner:false,isWritable:false},{pubkey:me(r,i,o),isSigner:false,isWritable:true},{pubkey:web3_js.SYSVAR_INSTRUCTIONS_PUBKEY,isSigner:false,isWritable:false},{pubkey:o,isSigner:false,isWritable:false},{pubkey:Ke,isSigner:false,isWritable:false},{pubkey:web3_js.SystemProgram.programId,isSigner:false,isWritable:false},...s.map(g=>({pubkey:g,isSigner:false,isWritable:true}))],data:or(e)});return [u,...p,m]}function Ge(t){let{connection:e,signTransaction:n}=t;async function o(r){let c=await e.getAccountInfo(r);if(!c)throw new O("MINT_NOT_FOUND",`mint ${r.toBase58()} not found`);return c.owner}async function a(r,c){let{blockhash:l,lastValidBlockHeight:i}=await e.getLatestBlockhash("confirmed"),d=new web3_js.Transaction;d.feePayer=r,d.recentBlockhash=l,d.add(...c);let s=await n(d),u=await e.sendRawTransaction(s.serialize());return await e.confirmTransaction({signature:u,blockhash:l,lastValidBlockHeight:i},"confirmed"),u}return {async depositSpl({mint:r,amountRaw:c,userID:l,titleID:i,category:d}){let s=new web3_js.PublicKey(t.owner),u=new web3_js.PublicKey(r),p=await o(u);return a(s,[ar({programId:new web3_js.PublicKey(t.programId),user:s,mint:u,tokenProgram:p,amountRaw:c,userID:l,titleID:i,category:d})])},async submitWithdrawal(r){if(!r.ProgramID||!r.Mint||!r.WalletAddress)throw new O("BAD_VOUCHER","the voucher has no program, mint or wallet");let c=new web3_js.PublicKey(t.owner),l=new web3_js.PublicKey(r.ProgramID),i=await e.getAccountInfo(ge(l,buffer.Buffer.from("config")));if(!i)throw new O("POOL_NOT_ON_THIS_CLUSTER","the pool's config account is not on this cluster");if(i.data.length!==fn)throw new O("POOL_NOT_MIGRATED",`config is ${i.data.length} bytes, expected ${fn} (migrate_config not run)`);let d=buffer.Buffer.from(i.data);if(d[er]===1)throw new O("POOL_PAUSED","pool withdrawals are paused");let s=d.readBigUInt64LE(wn);if(s!==BigInt(r.SignatureEpoch||0))throw new O("VOUCHER_REVOKED",`signature epoch mismatch: voucher ${r.SignatureEpoch}, on-chain ${s}`);let u=buffer.Buffer.from(Fe(r.Ed25519PublicKey)),p=false;for(let g=0;g<yn;g++){let y=gn+g*32;u.equals(d.subarray(y,y+32))&&(p=true);}if(!p)throw new O("SIGNER_NOT_TRUSTED","the voucher's signer is not in the pool's server_pubkeys");let m=await o(new web3_js.PublicKey(r.Mint));return a(c,[web3_js.ComputeBudgetProgram.setComputeUnitLimit({units:Xo}),...ir({sig:r,payer:c,tokenProgram:m})])}}}var Yo,Qo,Zo,Ke,Jo,fn,Xo,gn,yn,wn,er,O,bt=k(()=>{Yo="e000c6afc62f69cc",Qo="b59a5e563e7306ba",Zo="d668e18c1bdc33f1",Ke=new web3_js.PublicKey("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"),Jo="1nc1nerator11111111111111111111111111111111",fn=177,Xo=3e5,gn=40,yn=4,wn=gn+32*yn,er=wn+8,O=class extends Error{constructor(n,o){super(o);this.code=n;this.name="PlatformPoolError";}code};});function gr(t){return (t.ChainID===fr?exports.solanaDevnet:exports.solanaMainnet).rpcUrls.default.http[0]}function hn(t){let{client:e,walletConnectProjectId:n,appName:o,onClose:a,style:r}=t,[c,l]=react.useState(n??"");react.useEffect(()=>{if(n)return;let y=true;return (async()=>{let w=await e.blockchain.getDefinitions();if(!y||!w.ok)return;let W=w.data.Blockchain?.WalletLogin?.WalletConnectProjectId;W&&l(W);})(),()=>{y=false;}},[e,n]);let i=react.useMemo(()=>c?(_e({walletConnectProjectId:c,appName:o}),true):false,[c,o]),{address:d,isConnected:s}=react$1.useAppKitAccount(),{walletProvider:u}=react$1.useAppKitProvider("solana"),p=s&&d?d:null,m=(y,w)=>Ge({connection:new web3_js.Connection(gr(y),"confirmed"),owner:w,programId:y.RewardPoolAddress??"",signTransaction:async W=>{if(!u)throw new Error("Wallet not connected.");return u.signTransaction(W)}});return jsxRuntime.jsx(Be,{client:e,engine:{networkType:"Solana",address:p,connectChoices:i?[{key:"appkit",label:"Connect wallet",connect:()=>{H()?.open();}}]:[],disconnect:()=>{H()?.disconnect("solana");},deposit:async({network:y,binding:w,amount:W})=>{if(!p)return f("deposit-onchain","Wallet not connected.");if(!w.ContractAddress)return f("deposit-onchain","This token cannot be deposited.");if(!y.RewardPoolAddress)return f("deposit-onchain","POOL_NOT_IN_REGISTRY");let A;try{A=viem.parseUnits(W,w.Decimals??9);}catch{return f("deposit-onchain","Invalid amount.")}return Pe({client:e,adapter:m(y,p),network:y,mint:w.ContractAddress,amountRaw:A,titleID:e.titleID})},withdraw:async({network:y,networkID:w,currencyID:W,amount:A})=>p?Se({client:e,adapter:m(y,p),currencyID:W,networkID:w,walletAddress:p,amount:A}):f("request","Wallet not connected.")},onClose:a,style:r})}var fr,kn=k(()=>{Q();Oe();bt();L();ce();mt();ct();fr=103;});var Ct={};Wt(Ct,{PlatformPoolError:()=>O,SolanaWalletLogin:()=>pn,SolanaWalletPanel:()=>hn,createPlatformPoolAdapter:()=>Ge,createSolanaWalletConfig:()=>_e,solanaDevnet:()=>exports.solanaDevnet,solanaMainnet:()=>exports.solanaMainnet,useSolanaBridge:()=>sn});var Pt=k(()=>{mt();ln();mn();kn();bt();Q();});V();L();var $={addressRequest:"IDOS_PLATFORM_WALLET_ADDRESS_REQUEST",addressResponse:"IDOS_PLATFORM_WALLET_ADDRESS_RESPONSE",signRequest:"IDOS_PLATFORM_WALLET_SIGN_REQUEST",signResponse:"IDOS_PLATFORM_WALLET_SIGN_RESPONSE",ack:"IDOS_PLATFORM_WALLET_ACK",openRequest:"IDOS_PLATFORM_WALLET_OPEN_REQUEST",openResponse:"IDOS_PLATFORM_WALLET_OPEN_RESPONSE"},ye="PLATFORM_WALLET_UNAVAILABLE",Nn=5e3,Ln=18e4;function Rn(){let t=[...core.PLATFORM_ORIGINS],e=window.location.ancestorOrigins?.[0];return e&&!t.includes(e)&&core.isPlatformParentOrigin(e)&&t.push(e),t}function Bn(){return `wallet-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function He(t,e,n){if(typeof window>"u"||window.self===window.top)return Promise.resolve({ok:false,error:ye});let o=window.parent;if(!o)return Promise.resolve({ok:false,error:ye});let a=Bn();return new Promise(r=>{let c=false,l,i=s=>{c||(c=true,window.removeEventListener("message",d),clearTimeout(l),r(s));},d=s=>{if(!core.isPlatformParentOrigin(s.origin))return;let u=s.data;if(!(!u||u.requestId!==a)){if(u.type===$.ack){clearTimeout(l),l=setTimeout(()=>i({ok:false,error:"TIMEOUT"}),Ln);return}u.type===e&&i({ok:u.ok===true,error:typeof u.error=="string"?u.error:void 0,address:typeof u.address=="string"?u.address:void 0,signature:typeof u.signature=="string"?u.signature:void 0});}};l=setTimeout(()=>i({ok:false,error:ye}),Nn),window.addEventListener("message",d);for(let s of Rn())try{o.postMessage({type:t,requestId:a,...n},s);}catch{}})}async function _n(){return (await He($.openRequest,$.openResponse,{})).ok}async function Tt(t){let{client:e,networkID:n}=t;return It(t,async o=>{let a=await e.auth.requestWalletChallenge(o,n);return a.ok?{ok:true,message:a.data.Message}:{ok:false,error:a.error}},(o,a)=>e.auth.loginWithWallet(o,n,a))}async function vt(t){let{client:e,networkID:n}=t;return It(t,async o=>{let a=await e.auth.linkWallet(o,n);return a.ok?a.data.Challenge?{ok:true,message:a.data.Challenge}:{ok:false,error:"No challenge was issued."}:{ok:false,error:a.error}},(o,a)=>e.auth.linkWallet(o,n,a))}async function It(t,e,n){let{client:o,family:a}=t,r=o.titleID,c=await He($.addressRequest,$.addressResponse,{titleID:r,family:a});if(!c.ok||!c.address)return b("challenge",c.error??"NO_WALLET");let l=c.address,i=await e(l);if(!i.ok)return b("challenge",i.error);let d=await He($.signRequest,$.signResponse,{titleID:r,family:a,address:l,message:i.message});if(!d.ok||!d.signature)return b("sign",d.error??"SIGN_FAILED");let s=await n(l,d.signature);return s.ok?{ok:true,data:s.data}:b("login",s.error)}var Cn={padding:"11px 16px",borderRadius:"8px",border:"none",background:"#4c3fa8",color:"#fff",font:"inherit",fontWeight:600,cursor:"pointer"},Pn={display:"block",marginTop:"6px",color:"#ff9b9b",fontSize:"13px",textAlign:"center"};function bn(t){switch(t){case ye:return "Wallet sign-in is not available on this page.";case "NO_WALLET":case "CANCELLED":return "Connect a wallet on the page to sign in.";case "REJECTED":return "The signature was declined.";case "TIMEOUT":return "The wallet did not answer. Please try again.";default:return t}}function hr(t){let{client:e,networkID:n,onAuthenticated:o,onLinked:a,mode:r="login",family:c,disabled:l,label:i,style:d}=t,[s,u]=react.useState(false),[p,m]=react.useState(null);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{u(true),m(null),(async()=>{if(r==="link"){let w=await vt({client:e,networkID:n,family:c});if(w.ok){u(false),a?.(w.data.PlayAccess??null);return}m(bn(w.error)),u(false);return}let y=await Tt({client:e,networkID:n,family:c});if(y.ok){o?.();return}m(bn(y.error)),u(false);})();},disabled:l||s,style:{...Cn,...l||s?{opacity:.6,cursor:"default"}:null,...d},children:s?"Waiting for the wallet\u2026":i??(r==="link"?"Link wallet":"Sign in with wallet")}),p&&jsxRuntime.jsx("span",{role:"alert",style:Pn,children:p})]})}function Sn(t,e){return Ue()?null:jsxRuntime.jsx(hr,{...t,family:e})}function Wn(t){let{loading:e,disabled:n,label:o,style:a,error:r,onClick:c}=t;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",onClick:c,disabled:n||e,style:{...Cn,...n||e?{opacity:.6,cursor:"default"}:null,...a},children:e?"Loading wallet\u2026":o??"Sign in with wallet"}),r&&jsxRuntime.jsx("span",{role:"alert",style:Pn,children:r})]})}function kr(t){let{chains:e,walletConnectProjectId:n,appName:o,disabled:a,label:r,style:c,onAuthenticated:l,...i}=t,[d,s]=react.useState(null),[u,p]=react.useState(false),[m,g]=react.useState(null);if(S())return Sn(t,"evm");let y=()=>{p(true),g(null),(async()=>{try{let w=await Promise.resolve().then(()=>(pt(),ut)),W=w.createEvmWalletConfig({chains:e,walletConnectProjectId:n,appName:o});s({mod:w,config:W});}catch(w){console.error("[idosgames/wallet] failed to load the wallet module:",w),g("Could not load the wallet. Please try again.");}finally{p(false);}})();};if(d){let{WalletLogin:w}=d.mod;return jsxRuntime.jsx(w,{...i,onAuthenticated:l??An,wagmiConfig:d.config,disabled:a,label:r,style:c,autoStart:true})}return jsxRuntime.jsx(Wn,{loading:u,disabled:a,label:r??(t.mode==="link"?"Link wallet":void 0),style:c,error:m,onClick:y})}function An(){}function br(t){let{walletConnectProjectId:e,appName:n,disabled:o,label:a,style:r,onAuthenticated:c,...l}=t,[i,d]=react.useState(null),[s,u]=react.useState(false),[p,m]=react.useState(null);if(S())return Sn(t,"solana");let g=()=>{u(true),m(null),(async()=>{try{let y=await Promise.resolve().then(()=>(Pt(),Ct));e&&y.createSolanaWalletConfig({walletConnectProjectId:e,appName:n}),d(y);}catch(y){console.error("[idosgames/wallet] failed to load the wallet module:",y),m("Could not load the wallet. Please try again.");}finally{u(false);}})();};if(i){let{SolanaWalletLogin:y}=i;return jsxRuntime.jsx(y,{...l,onAuthenticated:c??An,disabled:o,label:a,style:r,autoStart:true})}return jsxRuntime.jsx(Wn,{loading:s,disabled:o,label:a??(t.mode==="link"?"Link wallet":void 0),style:r,error:p,onClick:g})}var Cr={pointerEvents:"auto",background:"#04276bf5",border:"1px solid #1e59c8",borderRadius:12,padding:16,color:"#fff",width:320,boxSizing:"border-box",fontFamily:"system-ui, sans-serif",fontSize:13};function Pr(t){let{client:e,onClose:n,style:o}=t,a=S(),[r,c]=react.useState(null),[l,i]=react.useState(null);return react.useEffect(()=>{if(a)return;let d=true;return (async()=>{try{let s=await e.blockchain.getDefinitions(),u=Object.values((s.ok?s.data.Blockchain?.Networks:null)??{}).map(g=>g.Type),m=u.includes("Solana")&&!u.includes("EVM")?{kind:"solana",mod:await Promise.resolve().then(()=>(Pt(),Ct))}:{kind:"evm",mod:await Promise.resolve().then(()=>(pt(),ut))};d&&c(m);}catch(s){console.error("[idosgames/wallet] failed to load the wallet panel:",s),d&&i("Could not load the wallet.");}})(),()=>{d=false;}},[a,e]),a?null:r?.kind==="evm"?jsxRuntime.jsx(r.mod.WalletPanel,{...t}):r?.kind==="solana"?jsxRuntime.jsx(r.mod.SolanaWalletPanel,{...t}):jsxRuntime.jsxs("div",{style:{...Cr,...o},children:[l??"Loading wallet\u2026",n&&jsxRuntime.jsx("button",{type:"button",onClick:n,style:{background:"#1e59c8",color:"#fff",border:"none",borderRadius:8,padding:"7px 12px",fontWeight:600,cursor:"pointer",marginLeft:10},children:"\u2715"})]})}V();Q();
|
|
2
|
-
exports.LazySolanaWalletLogin=
|
|
1
|
+
'use strict';var viem=require('viem'),core=require('@idosgames/core'),wagmi=require('wagmi'),connectors=require('wagmi/connectors'),appkitAdapterWagmi=require('@reown/appkit-adapter-wagmi'),react$1=require('@reown/appkit/react'),reactQuery=require('@tanstack/react-query'),react=require('react'),jsxRuntime=require('react/jsx-runtime'),actions=require('wagmi/actions'),appkitAdapterSolana=require('@reown/appkit-adapter-solana'),buffer=require('buffer'),web3_js=require('@solana/web3.js');var ho=Object.defineProperty;var C=(t,e)=>()=>(t&&(e=t(t=0)),e);var Qt=(t,e)=>{for(var n in e)ho(t,n,{get:e[n],enumerable:true});};function O(t){return t instanceof viem.BaseError?t.shortMessage:t instanceof Error?t.message:String(t)}function y(t,e,n){return {ok:false,stage:t,error:e,...n}}function P(t,e){return {ok:false,stage:t,error:e}}var G=C(()=>{});function So(t=typeof window>"u"?"":window.location.hostname){let e=t.toLowerCase();return ko.test(e)?true:e!=="localhost"&&e!=="127.0.0.1"?false:globalThis.__IDOS_PREVIEW__!=null}function E(){if(typeof window>"u"||So())return false;try{return window.self!==window.top}catch{return true}}function Ee(){if(typeof window>"u")return false;try{return window.parent!==window.top}catch{return true}}function ee(t){return y(t,Jt)}function me(t){return P(t,Jt)}var Jt,ko,te=C(()=>{G();Jt="WALLET_USE_SITE_PANEL",ko=/^[a-z0-9]{8}-preview\.idos\.games$/;});function se(t,e=false,n="md"){let[o,r,a]=e?["#8e95b8","#5b6187","#ffffff"]:Xt[t];return {...L,color:a,boxSizing:"border-box",fontFamily:f.font,fontSize:n==="sm"?13:n==="lg"?18:16,border:"none",borderRadius:f.buttonRadius,padding:n==="sm"?"6px 12px":n==="lg"?"13px 22px":"10px 18px",minHeight:n==="sm"?34:n==="lg"?52:44,cursor:e?"default":"pointer",background:`linear-gradient(180deg, ${o} 0%, ${r} 100%)`,boxShadow:`0 4px 0 ${f.edge}, inset 0 2px 0 rgba(255,255,255,.35)`,opacity:e?.75:1,display:"inline-flex",alignItems:"center",justifyContent:"center",gap:8}}function en(t){let[e,n,o]=Xt[t];return {background:`linear-gradient(180deg, ${e} 0%, ${n} 100%)`,color:o,borderRadius:16,boxShadow:`0 4px 0 ${f.edge}, inset 0 2px 0 rgba(255,255,255,.3)`}}function Po(){if(typeof navigator>"u")return false;let t=(navigator.language||"").toLowerCase();return Co.some(e=>t.startsWith(e))}function h(t,e){let n=(Po()?xo:Zt)[t]??Zt[t];for(let[o,r]of Object.entries(e??{}))n=n.replace(`{${o}}`,String(r));return n}var T,f,Xt,L,De,ne,B,Co,Zt,xo,it=C(()=>{T=(t,e)=>`var(--idos-ui-${t}, ${e})`,f={panel:T("panel","#2c3480"),panelDeep:T("panel-deep","#1d2360"),panelEdge:T("panel-edge","#4f5bc9"),text:T("text","#ffffff"),textDim:T("text-dim","#aeb6f0"),gold:T("gold","#ffd24a"),goldDeep:T("gold-deep","#e89a12"),green:T("green","#59d35b"),greenDeep:T("green-deep","#2b9936"),blue:T("blue","#4fb1ff"),blueDeep:T("blue-deep","#2276d6"),red:T("red","#ff5a5a"),redDeep:T("red-deep","#b83232"),onGreen:T("on-green","#ffffff"),onBlue:T("on-blue","#ffffff"),onGold:T("on-gold","#ffffff"),textOutline:T("text-outline","0 2px 0 rgba(0,0,0,.45), 0 0 1px rgba(0,0,0,.6)"),well:T("well","rgba(8, 10, 40, 0.6)"),wellSoft:T("well-soft","rgba(0, 0, 0, 0.3)"),wellShadow:T("well-shadow","inset 0 2px 4px rgba(0, 0, 0, 0.4)"),edge:T("edge","rgba(0, 0, 0, 0.35)"),line:T("line","rgba(255, 255, 255, 0.2)"),panelShadow:T("panel-shadow","0 6px 0 rgba(4, 6, 30, 0.55), inset 0 2px 0 rgba(255, 255, 255, 0.12)"),radius:T("radius","18px"),buttonRadius:T("button-radius","14px"),font:T("font","'Baloo 2', 'Nunito', 'Trebuchet MS', system-ui, sans-serif"),fast:T("fast","120ms")},Xt={green:[f.green,f.greenDeep,f.onGreen],blue:[f.blue,f.blueDeep,f.onBlue],gold:[f.gold,f.goldDeep,f.onGold],red:[f.red,f.redDeep,"#ffffff"]},L={color:f.text,fontWeight:800,textShadow:f.textOutline,letterSpacing:.2},De={boxSizing:"border-box",background:`linear-gradient(180deg, ${f.panel} 0%, ${f.panelDeep} 100%)`,border:`2px solid ${f.panelEdge}`,borderRadius:f.radius,boxShadow:f.panelShadow},ne={boxSizing:"border-box",background:f.well,border:`2px solid ${f.panelEdge}`,boxShadow:f.wellShadow,borderRadius:14};B={...L,fontSize:13,color:f.textDim},Co=["ru","kk","uk","be","ky","uz","tg"];Zt={title:"Wallet",topUpTitle:"Top up to buy",connectHint:"Connect a wallet to deposit and withdraw",connect:"Connect wallet",notConfigured:"Wallet connection is not set up for this app.",disconnect:"Disconnect",balance:"In-game balance",deposit:"Deposit",withdraw:"Withdraw",network:"Network",token:"Token",amount:"Amount",max:"MAX",minWithdraw:"Minimum to withdraw: {n}",noNetworks:"Crypto is not set up for this app yet.",noTokens:"No tokens on this network.",depositing:"Confirm in your wallet\u2026",withdrawing:"Withdrawing\u2026",confirming:"Waiting for the network to confirm\u2026",loading:"Loading\u2026",doneDeposit:"Deposited \u2014 the balance is updated.",doneWithdraw:"Sent to your wallet.",topUpNeed:"This purchase needs",topUpMore:"more",topUpHint:"Deposit it from your wallet \u2014 the purchase completes by itself once it is credited.",topUpCannot:"{name} cannot be deposited here.",depositAmount:"Deposit {amount} {name}",failed:"Did not go through",debited:"The amount is already debited \u2014 retry this withdrawal, do not request a new one.",tx:"Transaction",backed:"Crypto (withdrawable)",unbacked:"IOU (not backed yet)",total:"Total",iouHint:"IOUs spend in the app like crypto, but you can withdraw only the backed part; the developer backs IOUs later.",backedHint:"All of it is real crypto and can be withdrawn."},xo={title:"\u041A\u043E\u0448\u0435\u043B\u0451\u043A",topUpTitle:"\u041F\u043E\u043F\u043E\u043B\u043D\u0435\u043D\u0438\u0435 \u0434\u043B\u044F \u043F\u043E\u043A\u0443\u043F\u043A\u0438",connectHint:"\u041F\u043E\u0434\u043A\u043B\u044E\u0447\u0438\u0442\u0435 \u043A\u043E\u0448\u0435\u043B\u0451\u043A, \u0447\u0442\u043E\u0431\u044B \u043F\u043E\u043F\u043E\u043B\u043D\u044F\u0442\u044C \u0438 \u0432\u044B\u0432\u043E\u0434\u0438\u0442\u044C",connect:"\u041F\u043E\u0434\u043A\u043B\u044E\u0447\u0438\u0442\u044C \u043A\u043E\u0448\u0435\u043B\u0451\u043A",notConfigured:"\u041F\u043E\u0434\u043A\u043B\u044E\u0447\u0435\u043D\u0438\u0435 \u043A\u043E\u0448\u0435\u043B\u044C\u043A\u0430 \u0434\u043B\u044F \u044D\u0442\u043E\u0433\u043E \u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u044F \u043D\u0435 \u043D\u0430\u0441\u0442\u0440\u043E\u0435\u043D\u043E.",disconnect:"\u041E\u0442\u043A\u043B\u044E\u0447\u0438\u0442\u044C",balance:"\u0411\u0430\u043B\u0430\u043D\u0441 \u0432 \u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u0438",deposit:"\u041F\u043E\u043F\u043E\u043B\u043D\u0438\u0442\u044C",withdraw:"\u0412\u044B\u0432\u0435\u0441\u0442\u0438",network:"\u0421\u0435\u0442\u044C",token:"\u0422\u043E\u043A\u0435\u043D",amount:"\u0421\u0443\u043C\u043C\u0430",max:"\u0412\u0421\u0401",minWithdraw:"\u041C\u0438\u043D\u0438\u043C\u0443\u043C \u0434\u043B\u044F \u0432\u044B\u0432\u043E\u0434\u0430: {n}",noNetworks:"\u041A\u0440\u0438\u043F\u0442\u0430 \u0434\u043B\u044F \u044D\u0442\u043E\u0433\u043E \u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u044F \u0435\u0449\u0451 \u043D\u0435 \u043D\u0430\u0441\u0442\u0440\u043E\u0435\u043D\u0430.",noTokens:"\u0412 \u044D\u0442\u043E\u0439 \u0441\u0435\u0442\u0438 \u043D\u0435\u0442 \u0442\u043E\u043A\u0435\u043D\u043E\u0432.",depositing:"\u041F\u043E\u0434\u0442\u0432\u0435\u0440\u0434\u0438\u0442\u0435 \u0432 \u043A\u043E\u0448\u0435\u043B\u044C\u043A\u0435\u2026",withdrawing:"\u0412\u044B\u0432\u043E\u0434\u0438\u043C\u2026",confirming:"\u0416\u0434\u0451\u043C \u043F\u043E\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043D\u0438\u044F \u0441\u0435\u0442\u0438\u2026",loading:"\u0417\u0430\u0433\u0440\u0443\u0437\u043A\u0430\u2026",doneDeposit:"\u041F\u043E\u043F\u043E\u043B\u043D\u0435\u043D\u043E \u2014 \u0431\u0430\u043B\u0430\u043D\u0441 \u043E\u0431\u043D\u043E\u0432\u043B\u0451\u043D.",doneWithdraw:"\u041E\u0442\u043F\u0440\u0430\u0432\u043B\u0435\u043D\u043E \u043D\u0430 \u0432\u0430\u0448 \u043A\u043E\u0448\u0435\u043B\u0451\u043A.",topUpNeed:"\u0414\u043B\u044F \u043F\u043E\u043A\u0443\u043F\u043A\u0438 \u043D\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442",topUpMore:"",topUpHint:"\u041F\u043E\u043F\u043E\u043B\u043D\u0438\u0442\u0435 \u0441 \u043A\u043E\u0448\u0435\u043B\u044C\u043A\u0430 \u2014 \u043F\u043E\u043A\u0443\u043F\u043A\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u0441\u044F \u0441\u0430\u043C\u0430, \u043A\u0430\u043A \u0442\u043E\u043B\u044C\u043A\u043E \u043F\u043E\u043F\u043E\u043B\u043D\u0435\u043D\u0438\u0435 \u0437\u0430\u0447\u0438\u0441\u043B\u0438\u0442\u0441\u044F.",topUpCannot:"{name} \u0437\u0434\u0435\u0441\u044C \u043F\u043E\u043F\u043E\u043B\u043D\u0438\u0442\u044C \u043D\u0435\u043B\u044C\u0437\u044F.",depositAmount:"\u041F\u043E\u043F\u043E\u043B\u043D\u0438\u0442\u044C \u043D\u0430 {amount} {name}",failed:"\u041D\u0435 \u043F\u0440\u043E\u0448\u043B\u043E",debited:"\u0421\u0443\u043C\u043C\u0430 \u0443\u0436\u0435 \u0441\u043F\u0438\u0441\u0430\u043D\u0430 \u2014 \u043F\u043E\u0432\u0442\u043E\u0440\u0438\u0442\u0435 \u044D\u0442\u043E\u0442 \u0432\u044B\u0432\u043E\u0434, \u043D\u043E\u0432\u044B\u0439 \u043D\u0435 \u0437\u0430\u043F\u0440\u0430\u0448\u0438\u0432\u0430\u0439\u0442\u0435.",tx:"\u0422\u0440\u0430\u043D\u0437\u0430\u043A\u0446\u0438\u044F",backed:"\u041A\u0440\u0438\u043F\u0442\u0430 (\u043C\u043E\u0436\u043D\u043E \u0432\u044B\u0432\u0435\u0441\u0442\u0438)",unbacked:"\u0420\u0430\u0441\u043F\u0438\u0441\u043A\u0438 (\u043F\u043E\u043A\u0430 \u043D\u0435 \u043E\u0431\u0435\u0441\u043F\u0435\u0447\u0435\u043D\u044B)",total:"\u0412\u0441\u0435\u0433\u043E",iouHint:"\u0420\u0430\u0441\u043F\u0438\u0441\u043A\u0438 \u0442\u0440\u0430\u0442\u044F\u0442\u0441\u044F \u0432 \u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u0438 \u043A\u0430\u043A \u043A\u0440\u0438\u043F\u0442\u0430, \u043D\u043E \u0432\u044B\u0432\u0435\u0441\u0442\u0438 \u043C\u043E\u0436\u043D\u043E \u0442\u043E\u043B\u044C\u043A\u043E \u043E\u0431\u0435\u0441\u043F\u0435\u0447\u0435\u043D\u043D\u0443\u044E \u0447\u0430\u0441\u0442\u044C; \u0440\u0430\u0437\u0440\u0430\u0431\u043E\u0442\u0447\u0438\u043A \u043E\u0431\u0435\u0441\u043F\u0435\u0447\u0438\u0442 \u0440\u0430\u0441\u043F\u0438\u0441\u043A\u0438 \u043F\u043E\u0437\u0436\u0435.",backedHint:"\u042D\u0442\u043E \u043D\u0430\u0441\u0442\u043E\u044F\u0449\u0430\u044F \u043A\u0440\u0438\u043F\u0442\u0430, \u0435\u0451 \u043C\u043E\u0436\u043D\u043E \u0432\u044B\u0432\u0435\u0441\u0442\u0438 \u0446\u0435\u043B\u0438\u043A\u043E\u043C."};});function lt(t){return Object.values(exports.idosChains).find(e=>e.id===t)}function an(t){return {...t,chainNamespace:"eip155",caipNetworkId:`eip155:${t.id}`}}exports.mainnet=void 0;exports.bsc=void 0;exports.polygon=void 0;exports.base=void 0;exports.arbitrum=void 0;exports.optimism=void 0;exports.sepolia=void 0;exports.polygonAmoy=void 0;exports.idosChains=void 0;exports.solanaMainnet=void 0;exports.solanaDevnet=void 0;var ce=C(()=>{exports.mainnet={id:1,name:"Ethereum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://eth.llamarpc.com"]}},blockExplorers:{default:{name:"Etherscan",url:"https://etherscan.io"}}},exports.bsc={id:56,name:"BNB Smart Chain",nativeCurrency:{name:"BNB",symbol:"BNB",decimals:18},rpcUrls:{default:{http:["https://bsc-dataseed.binance.org"]}},blockExplorers:{default:{name:"BscScan",url:"https://bscscan.com"}}},exports.polygon={id:137,name:"Polygon",nativeCurrency:{name:"POL",symbol:"POL",decimals:18},rpcUrls:{default:{http:["https://polygon-rpc.com"]}},blockExplorers:{default:{name:"PolygonScan",url:"https://polygonscan.com"}}},exports.base={id:8453,name:"Base",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://mainnet.base.org"]}},blockExplorers:{default:{name:"BaseScan",url:"https://basescan.org"}}},exports.arbitrum={id:42161,name:"Arbitrum One",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://arb1.arbitrum.io/rpc"]}},blockExplorers:{default:{name:"Arbiscan",url:"https://arbiscan.io"}}},exports.optimism={id:10,name:"OP Mainnet",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://mainnet.optimism.io"]}},blockExplorers:{default:{name:"Optimistic Etherscan",url:"https://optimistic.etherscan.io"}}},exports.sepolia={id:11155111,name:"Sepolia",testnet:true,nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.sepolia.org"]}},blockExplorers:{default:{name:"Etherscan",url:"https://sepolia.etherscan.io"}}},exports.polygonAmoy={id:80002,name:"Polygon Amoy",testnet:true,nativeCurrency:{name:"POL",symbol:"POL",decimals:18},rpcUrls:{default:{http:["https://rpc-amoy.polygon.technology"]}},blockExplorers:{default:{name:"PolygonScan",url:"https://amoy.polygonscan.com"}}},exports.idosChains={mainnet:exports.mainnet,bsc:exports.bsc,polygon:exports.polygon,base:exports.base,arbitrum:exports.arbitrum,optimism:exports.optimism,sepolia:exports.sepolia,polygonAmoy:exports.polygonAmoy};exports.solanaMainnet={id:"5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",name:"Solana",network:"solana-mainnet",nativeCurrency:{name:"Solana",symbol:"SOL",decimals:9},rpcUrls:{default:{http:["https://api.mainnet-beta.solana.com"]}},blockExplorers:{default:{name:"Solscan",url:"https://solscan.io"}},testnet:false,chainNamespace:"solana",caipNetworkId:"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"},exports.solanaDevnet={id:"EtWTRABZaYq6iMfeYKouRu166VU2xqa1",name:"Solana Devnet",network:"solana-devnet",nativeCurrency:{name:"Solana",symbol:"SOL",decimals:9},rpcUrls:{default:{http:["https://api.devnet.solana.com"]}},blockExplorers:{default:{name:"Solscan",url:"https://solscan.io"}},testnet:true,chainNamespace:"solana",caipNetworkId:"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1"};});function Ke(t){sn=t;}function oe(){return sn}var sn,Pe=C(()=>{sn=null;});function Ge(t){let{chains:e=dt,walletConnectProjectId:n,appName:o,appUrl:r,appIcon:a,transports:s,connectors:l}=t,i=n??"__extension_only__";if(!l){let m=ct.get(i);if(m)return m}let d={};for(let m of e)d[m.id]=s?.[m.id]??wagmi.http();let c=r??(typeof window<"u"?window.location.origin:""),p={name:o??"iDosGames",description:o??"iDosGames game",url:c,icons:a?[a]:[]};if(n&&!l){let m=e.map(an),k=new appkitAdapterWagmi.WagmiAdapter({networks:m,projectId:n,transports:d});return Ke(react$1.createAppKit({adapters:[k],networks:m,projectId:n,metadata:p,features:{analytics:false,email:false,socials:false}})),ct.set(i,k.wagmiConfig),k.wagmiConfig}let u=l??[connectors.injected(),connectors.coinbaseWallet({appName:o??"iDosGames"})],b=wagmi.createConfig({chains:e,connectors:u,transports:d});return l||ct.set(i,b),b}var dt,ct,pt=C(()=>{ce();Pe();dt=[exports.mainnet,exports.bsc,exports.polygon,exports.base,exports.arbitrum,exports.optimism,exports.sepolia,exports.polygonAmoy],ct=new Map;});function xe(t){let{wagmiConfig:e,queryClient:n,children:o}=t,[r]=react.useState(()=>n??new reactQuery.QueryClient);return jsxRuntime.jsx(wagmi.WagmiProvider,{config:e,children:jsxRuntime.jsx(reactQuery.QueryClientProvider,{client:r,children:o})})}var ze=C(()=>{});var qe,cn,ut,dn,mt=C(()=>{qe=[{type:"function",name:"depositERC20",stateMutability:"nonpayable",inputs:[{name:"token",type:"address"},{name:"amount",type:"uint256"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"}],outputs:[{name:"",type:"bool"}]},{type:"function",name:"withdrawERC20",stateMutability:"nonpayable",inputs:[{name:"token",type:"address"},{name:"to",type:"address"},{name:"amount",type:"uint256"},{name:"burnAmount",type:"uint256"},{name:"splits",type:"tuple[]",components:[{name:"to",type:"address"},{name:"amount",type:"uint256"}]},{name:"nonce",type:"uint256"},{name:"signature",type:"bytes"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"},{name:"deadline",type:"uint256"}],outputs:[]},{type:"function",name:"withdrawERC1155",stateMutability:"nonpayable",inputs:[{name:"token",type:"address"},{name:"to",type:"address"},{name:"id",type:"uint256"},{name:"amount",type:"uint256"},{name:"splits",type:"tuple[]",components:[{name:"to",type:"address"},{name:"amount",type:"uint256"}]},{name:"nonce",type:"uint256"},{name:"signature",type:"bytes"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"},{name:"deadline",type:"uint256"}],outputs:[]},{type:"function",name:"withdrawERC721",stateMutability:"nonpayable",inputs:[{name:"token",type:"address"},{name:"to",type:"address"},{name:"tokenId",type:"uint256"},{name:"nonce",type:"uint256"},{name:"signature",type:"bytes"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"},{name:"deadline",type:"uint256"}],outputs:[]}],cn=[{type:"function",name:"withdrawERC1155Mint",stateMutability:"nonpayable",inputs:[{name:"collection",type:"address"},{name:"to",type:"address"},{name:"id",type:"uint256"},{name:"amount",type:"uint256"},{name:"splits",type:"tuple[]",components:[{name:"to",type:"address"},{name:"amount",type:"uint256"}]},{name:"nonce",type:"uint256"},{name:"signature",type:"bytes"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"},{name:"deadline",type:"uint256"}],outputs:[]},{type:"function",name:"withdrawERC721Mint",stateMutability:"nonpayable",inputs:[{name:"collection",type:"address"},{name:"to",type:"address"},{name:"tokenId",type:"uint256"},{name:"nonce",type:"uint256"},{name:"signature",type:"bytes"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"},{name:"deadline",type:"uint256"}],outputs:[]}],ut=[{type:"function",name:"approve",stateMutability:"nonpayable",inputs:[{name:"spender",type:"address"},{name:"amount",type:"uint256"}],outputs:[{name:"",type:"bool"}]},{type:"function",name:"allowance",stateMutability:"view",inputs:[{name:"owner",type:"address"},{name:"spender",type:"address"}],outputs:[{name:"",type:"uint256"}]},{type:"function",name:"decimals",stateMutability:"view",inputs:[],outputs:[{name:"",type:"uint8"}]},{type:"function",name:"balanceOf",stateMutability:"view",inputs:[{name:"account",type:"address"}],outputs:[{name:"",type:"uint256"}]}],dn=[{type:"function",name:"safeTransferFrom",stateMutability:"nonpayable",inputs:[{name:"from",type:"address"},{name:"to",type:"address"},{name:"id",type:"uint256"},{name:"amount",type:"uint256"},{name:"data",type:"bytes"}],outputs:[]},{type:"function",name:"isApprovedForAll",stateMutability:"view",inputs:[{name:"account",type:"address"},{name:"operator",type:"address"}],outputs:[{name:"",type:"bool"}]},{type:"function",name:"setApprovalForAll",stateMutability:"nonpayable",inputs:[{name:"operator",type:"address"},{name:"approved",type:"bool"}],outputs:[]},{type:"function",name:"balanceOf",stateMutability:"view",inputs:[{name:"account",type:"address"},{name:"id",type:"uint256"}],outputs:[{name:"",type:"uint256"}]}];});function pn(t,e,n){return viem.encodeAbiParameters([{type:"string"},{type:"string"},{type:"string"}],[t,e,core.normalizeBlockchainCategory(n)])}var un=C(()=>{});async function de(t,e){let{walletClient:n,publicClient:o,account:r}=t,a=await n.writeContract({address:e.address,abi:e.abi,functionName:e.functionName,args:e.args,account:r,chain:n.chain,value:e.value});if((await o.waitForTransactionReceipt({hash:a})).status==="reverted")throw new Error(`On-chain transaction reverted (${a}).`);return a}var ft=C(()=>{});function mn(t){let e=t.RewardPoolAddress;return e||null}async function fn(t,e,n,o){return await t.publicClient.readContract({address:e,abi:ut,functionName:"allowance",args:[t.account,n]})>=o?null:de(t,{address:e,abi:ut,functionName:"approve",args:[n,o]})}async function gt(t){let{client:e,clients:n,network:o,tokenAddress:r,amount:a,titleID:s,category:l}=t;if(E())return ee("approve");let i=e.auth.context?.userID;if(!i)return y("approve","Not logged in.");let d=mn(o);if(!d)return y("approve","Network has no RewardPoolAddress.");if(a<=0n)return y("approve","Amount must be positive.");try{await fn(n,r,d,a);}catch(u){return y("approve",O(u))}let c;try{c=await de(n,{address:d,abi:qe,functionName:"depositERC20",args:[r,a,i,s,l??""]});}catch(u){return y("deposit-onchain",O(u))}let p=await e.blockchain.depositToken(o.NetworkID??"",c);return p.ok?{ok:true,onChainTxHash:c,data:p.data}:y("report",p.error,{onChainTxHash:c})}async function yt(t){let{client:e,clients:n,network:o,nftContractAddress:r,tokenId:a,amount:s,titleID:l,category:i}=t;if(E())return ee("deposit-onchain");let d=e.auth.context?.userID;if(!d)return y("deposit-onchain","Not logged in.");let c=mn(o);if(!c)return y("deposit-onchain","Network has no RewardPoolAddress.");if(s<=0n)return y("deposit-onchain","Amount must be positive.");let p=pn(d,l,i),u;try{u=await de(n,{address:r,abi:dn,functionName:"safeTransferFrom",args:[n.account,c,a,s,p]});}catch(m){return y("deposit-onchain",O(m))}let b=await e.blockchain.depositNFT(o.NetworkID??"",u);return b.ok?{ok:true,onChainTxHash:u,data:b.data}:y("report",b.error,{onChainTxHash:u})}var gn=C(()=>{mt();un();ft();G();te();});function yn(t){return (t.Splits??[]).map(e=>({to:e.To,amount:BigInt(e.Amount??"0")}))}async function wn(t,e){return de(t,{address:e.ContractAddress,abi:qe,functionName:"withdrawERC20",args:[e.TokenAddress,e.WalletAddress,BigInt(e.Amount??"0"),BigInt(e.BurnAmount??"0"),yn(e),BigInt(e.Nonce??"0"),e.Signature??"0x",e.UserID??"",e.TitleID??"",e.Category??"",BigInt(e.Deadline??"0")]})}async function hn(t,e){return de(t,{address:e.ContractAddress,abi:cn,functionName:"withdrawERC1155Mint",args:[e.TokenAddress,e.WalletAddress,BigInt(e.TokenId??"0"),BigInt(e.Amount??"0"),yn(e),BigInt(e.Nonce??"0"),e.Signature??"0x",e.UserID??"",e.TitleID??"",e.Category??"",BigInt(e.Deadline??"0")]})}async function wt(t){let{client:e,clients:n,currencyID:o,networkID:r,walletAddress:a,amount:s,category:l}=t;if(E())return ee("request");let i=await e.blockchain.requestTokenWithdrawal(o,r,a,s,l);if(!i.ok)return y("request",i.error);let d=i.data.EvmSignature,c=i.data.TitleTransactionID??void 0;if(!d)return y("request","Withdrawal response carried no EVM signature.",{titleTransactionID:c});let p;try{p=await wn(n,d);}catch(b){return y("withdraw-onchain",O(b),{titleTransactionID:c})}let u=await bn(e,c,p);return u.ok?{ok:true,onChainTxHash:p,data:i.data}:u}async function ht(t){let{client:e,clients:n,itemID:o,networkID:r,walletAddress:a,amount:s,category:l}=t;if(E())return ee("request");let i=await e.blockchain.requestNFTWithdrawal(o,r,a,s,l);if(!i.ok)return y("request",i.error);let d=i.data.EvmSignature,c=i.data.TitleTransactionID??void 0;if(!d)return y("request","Withdrawal response carried no EVM signature.",{titleTransactionID:c});let p;try{p=await hn(n,d);}catch(b){return y("withdraw-onchain",O(b),{titleTransactionID:c})}let u=await bn(e,c,p);return u.ok?{ok:true,onChainTxHash:p,data:i.data}:u}async function bn(t,e,n){if(!e)return y("confirm","Missing TitleTransactionID.",{onChainTxHash:n});let o=await t.blockchain.confirmWithdrawal(e,n);return o.ok?{ok:true,onChainTxHash:n,data:o.data}:y("confirm",o.error,{onChainTxHash:n,titleTransactionID:e})}var kn=C(()=>{mt();ft();G();te();});async function Re(t){let{client:e,clients:n,networkID:o}=t;if(E())return me("challenge");let r=t.walletAddress??n.account,a=await e.auth.requestWalletChallenge(r,o);if(!a.ok)return P("challenge",a.error);let s;try{s=await n.walletClient.signMessage({account:n.account,message:a.data.Message});}catch(i){return P("sign",O(i))}let l=await e.auth.loginWithWallet(r,o,s);return l.ok?{ok:true,data:l.data}:P("login",l.error)}async function bt(t){let{client:e,clients:n,networkID:o}=t;if(E())return me("challenge");let r=t.walletAddress??n.account,a=await e.auth.linkWallet(r,o);if(!a.ok)return P("challenge",a.error);if(!a.data.Challenge)return P("challenge","No challenge was issued.");let s;try{s=await n.walletClient.signMessage({account:n.account,message:a.data.Challenge});}catch(i){return P("sign",O(i))}let l=await e.auth.linkWallet(r,o,s);return l.ok?{ok:true,data:l.data}:P("login",l.error)}var Sn=C(()=>{G();te();});var kt=C(()=>{gn();kn();Sn();});function Be(){let{address:t}=wagmi.useAccount(),e=wagmi.usePublicClient(),{data:n}=wagmi.useWalletClient();return !t||!e||!n?null:{account:t,publicClient:e,walletClient:n}}function Ve(t,e){let n=Be();return {connected:!!n,account:n?.account??null,loginWithWallet:(o,r)=>n?Re({client:t,clients:n,networkID:o,walletAddress:r}):Promise.resolve(P("challenge",Le)),depositToken:o=>n?gt({client:t,clients:n,titleID:e,...o}):Promise.resolve(y("approve",Le)),depositNft:o=>n?yt({client:t,clients:n,titleID:e,...o}):Promise.resolve(y("deposit-onchain",Le)),withdrawToken:o=>n?wt({client:t,clients:n,...o}):Promise.resolve(y("withdraw-onchain",Le)),withdrawNft:o=>n?ht({client:t,clients:n,...o}):Promise.resolve(y("withdraw-onchain",Le))}}var Le,$e=C(()=>{kt();G();Le="Wallet not connected.";});function In(t){let{wagmiConfig:e,...n}=t;return jsxRuntime.jsx(xe,{wagmiConfig:e,children:jsxRuntime.jsx(Ct,{...n})})}function Qo(t){return t instanceof Error&&(t.name==="ConnectorAlreadyConnectedError"||t.message.includes("already connected"))}function Jo(t){let e="Wallet sign-in failed. Please try again.";return t instanceof Error?t.name==="ProviderNotFoundError"||/provider not found/i.test(t.message)?"No crypto wallet found in this browser. Install a wallet extension (e.g. MetaMask) or open this page in your wallet's browser, then try again.":t.name==="UserRejectedRequestError"||/user (rejected|denied|cancelled|canceled)/i.test(t.message)?"Request declined in the wallet.":/timed? ?out/i.test(t.message)?"The wallet did not respond. Open your wallet and try again.":e:e}async function xn(t){let e=await actions.getWalletClient(t).catch(()=>null);if(!e)return null;let n=actions.getPublicClient(t);return n?{account:e.account.address,publicClient:n,walletClient:e}:null}function Zo(t,e=18e4){return actions.getAccount(t).isConnected?Promise.resolve(true):new Promise(n=>{let o=false,r=l=>{o||(o=true,a(),clearTimeout(s),n(l));},a=actions.watchAccount(t,{onChange:l=>{l.isConnected&&r(true);}}),s=setTimeout(()=>r(false),e);})}function Xo(t,e=8e3){let n=o=>o==="reconnecting"||o==="connecting";return n(actions.getAccount(t).status)?new Promise(o=>{let r=false,a=()=>{r||(r=true,s(),clearTimeout(l),o());},s=actions.watchAccount(t,{onChange:i=>{n(i.status)||a();}}),l=setTimeout(a,e);}):Promise.resolve()}function er(t){let e=r=>t.find(a=>a.id===r||a.type===r),n=e("injected"),o=typeof window<"u"&&window.ethereum!=null;return n&&o?n:e("walletConnect")??n??t[0]}async function tr(t){try{let o=(await actions.getAccount(t).connector?.getProvider?.())?.session?.peer?.metadata?.redirect,r=o?.native||o?.universal;return !r||typeof window>"u"?!1:(window.location.href=r,!0)}catch{return false}}function Wn(t,e){return new Promise((n,o)=>{let r=setTimeout(()=>o(new Error("The wallet request timed out.")),e);t.then(a=>{clearTimeout(r),n(a);},a=>{clearTimeout(r),o(a instanceof Error?a:new Error(String(a)));});})}function Ct(t){let{client:e,networkID:n,onAuthenticated:o,disabled:r,label:a,style:s,autoStart:l,mode:i="login",onLinked:d}=t,c=wagmi.useConfig(),{isConnected:p}=wagmi.useAccount(),{connectAsync:u,connectors:b}=wagmi.useConnect(),m=Be(),[k,g]=react.useState(false),[W,A]=react.useState(null),[_,J]=react.useState(false),$=react.useRef(0),Z=react.useRef(false),z=async()=>{let re=++$.current,M=()=>$.current===re;g(true),A(null);try{if(await Xo(c),!M())return;if(!actions.getAccount(c).isConnected){let v=oe();if(v){if(await v.open(),!await Zo(c)){A("No wallet was connected.");return}}else {let j=er(b);if(!j){A("No wallet connector is configured.");return}try{await u({connector:j});}catch(K){if(!Qo(K))throw K}}}let D=m??await xn(c);if(!D&&actions.getAccount(c).isConnected&&(await new Promise(v=>setTimeout(v,300)),D=await xn(c),!M()))return;if(!D){A("Wallet client is not available.");return}if(J(!0),i==="link"){let v=await Wn(bt({client:e,clients:D,networkID:n}),Tn);if(!M())return;if(v.ok){d?.(v.data.PlayAccess??null);return}A(v.stage==="sign"?"Signature declined.":core.authErrorText(v.error,"Could not link the wallet."));return}let U=await Wn(Re({client:e,clients:D,networkID:n}),Tn);if(!M())return;if(U.ok){o();return}A(U.stage==="sign"?"Signature declined.":core.authErrorText(U.error,"Wallet sign-in failed."));}catch(D){if(!M())return;console.error("[idosgames/wallet] wallet sign-in failed:",D),A(Jo(D));}finally{M()&&(g(false),J(false));}};react.useEffect(()=>{!l||Z.current||(Z.current=true,z());},[l]);let ae=async()=>{await tr(c)||await oe()?.open();};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{_?ae():z();},disabled:r,style:{...nr,...r?{opacity:.6,cursor:"default"}:null,...s},children:_?"Waiting for signature \u2014 tap to open wallet":k?"Check your wallet\u2026":p?a??(i==="link"?"Link wallet":"Sign in with wallet"):"Connect wallet"}),W&&jsxRuntime.jsx("span",{role:"alert",style:or,children:W})]})}var Tn,nr,or,vn=C(()=>{Pe();kt();ze();$e();Tn=9e4;nr={padding:"11px 16px",borderRadius:"8px",border:"none",background:"#4c3fa8",color:"#fff",font:"inherit",fontWeight:600,cursor:"pointer"},or={display:"block",marginTop:"6px",color:"#ff9b9b",fontSize:"13px",textAlign:"center"};});function pr(t,e){let n=Math.max(0,Math.floor(e||0)),[o="0",r=""]=t.split(".");if(r.length<=n)return t;let a=r.slice(0,n),s=BigInt(o+a)+(/^0*$/.test(r.slice(n))?BigInt(0):BigInt(1));if(n===0)return s.toString();let l=s.toString().padStart(n+1,"0");return `${l.slice(0,-n)}.${l.slice(-n)}`.replace(/\.?0+$/,"")}function Tt(t,e=6){let n=Number(t);return Number.isFinite(n)?n.toLocaleString("en-US",{maximumFractionDigits:Math.max(0,e)}).replace(/,/g," "):String(t)}function Ye({client:t,engine:e,onClose:n,style:o,topUp:r}){let[,a]=react.useReducer(S=>S+1,0),[s,l]=react.useState(false),[i,d]=react.useState({}),[c,p]=react.useState({}),[u,b]=react.useState("deposit"),[m,k]=react.useState(""),[g,W]=react.useState(""),[A,_]=react.useState(""),[J,$]=react.useState(false),[Z,z]=react.useState(null),[ae,re]=react.useState(false);react.useEffect(()=>{let S=true;return (async()=>{let[R]=await Promise.all([t.blockchain.getDefinitions(),t.cache.ensureState(["InventoryV2","Blockchain"])]);if(!S||(l(true),!R.ok))return;let N={};for(let[Y,ie]of Object.entries(R.data.Blockchain?.Networks??{}))ie.Type===e.networkType&&(N[Y]=ie);d(N);let ue=R.data.CryptoCurrencies??{};p(ue);let ve=r?ue[r.currencyID]?.Networks?.find(Y=>!!Y.NetworkID&&!!N[Y.NetworkID]&&!!Y.ContractAddress&&Y.DepositsEnabled!==false&&N[Y.NetworkID]?.DepositsEnabled!==false)?.NetworkID:null;k(ve??Object.keys(N)[0]??"");})(),()=>{S=false;}},[t,e.networkType]),react.useEffect(()=>t.on("user:anyUpdated",a),[t]);let M=react.useMemo(()=>Object.entries(c).filter(([,S])=>S.Networks?.some(R=>R.NetworkID===m&&!!R.ContractAddress)),[c,m]);react.useEffect(()=>{let S=M[0]?.[0]??"";W(R=>r?r.currencyID:M.some(([N])=>N===R)?R:S);},[M,r]);let D=m?i[m]:void 0,U=g?c[g]:void 0,v=U?.Networks?.find(S=>S.NetworkID===m),j=g?t.data.user.getCryptoCurrencyAmount(g):"0",K=U?.DisplayName??g,X=g?U?.UnbackedRewardCurrencyID||`${g}_IOU`:"",co=X&&Number(t.data.user.state?.InventoryV2?.VirtualCurrencies?.[X]?.Amount??0)||0,po=!!X&&t.data.user.state?.InventoryV2?.VirtualCurrencies?.[X]!=null,Gt=U?.DisplayDecimals??6,Ue=!!e.address,zt=!!r&&!!v?.ContractAddress&&g===r.currencyID,nt=r&&v?pr(r.amount,v.Decimals??18):"",ot=r?c[r.currencyID]?.DisplayName??r.currencyID:"",qt=Number(v?.MinWithdraw??0);async function rt(S,R){$(true),z(null);try{let N=await R();return z({tab:S,res:N}),N.ok&&_(""),N}finally{$(false);}}async function Vt(S){let R=await $t();if(!R)return y("approve",h("noNetworks"));let N=await e.deposit({...S,network:R});if(N.ok||N.stage!=="report"||!N.onChainTxHash)return N;let ue=N.onChainTxHash,ve=N.error;re(true);try{for(let Y=1;Y<=cr&&lr.test(ve);Y++){await new Promise(wo=>setTimeout(wo,dr));let ie=await t.blockchain.depositToken(m,ue);if(ie.ok)return {ok:!0,onChainTxHash:ue,data:ie.data};if(/^Transaction hash already used/.test(ie.error))return await t.cache.ensureState(["InventoryV2"],{force:!0}),{ok:!0,onChainTxHash:ue,data:null};ve=ie.error;}}finally{re(false);}return {...N,error:ve}}async function $t(){let S=await t.blockchain.getDefinitions({forceRefresh:true});return S.ok?S.data.Blockchain?.Networks?.[m]??null:null}async function uo(){let S=await $t();return S?e.withdraw({network:S,networkID:m,currencyID:g,amount:A}):y("request",h("noNetworks"))}let at=ae?h("confirming"):u==="withdraw"&&!r?h("withdrawing"):h("depositing"),mo=Ue?jsxRuntime.jsxs("div",{style:{...ne,display:"flex",alignItems:"center",gap:10,padding:"8px 8px 8px 12px"},children:[jsxRuntime.jsx("span",{style:fr,"aria-hidden":true}),jsxRuntime.jsxs("div",{style:{display:"grid",flex:1,minWidth:0},children:[jsxRuntime.jsx("span",{style:{...L,fontSize:15,fontFamily:"ui-monospace, Consolas, monospace"},children:Nn(e.address)}),D?jsxRuntime.jsx("span",{style:{...B,fontSize:12},children:D.DisplayName??m}):null]}),jsxRuntime.jsx("button",{type:"button",className:"idos-press",style:gr,onClick:e.disconnect,children:h("disconnect")})]}):jsxRuntime.jsxs("div",{style:{display:"grid",gap:8},children:[jsxRuntime.jsx("span",{style:B,children:h("connectHint")}),e.connectChoices.length===0?jsxRuntime.jsx("div",{style:{...ne,padding:"10px 12px",...B},children:h("notConfigured")}):e.connectChoices.length===1?jsxRuntime.jsx("button",{type:"button",className:"idos-press",style:{...se("blue",false,"lg"),width:"100%"},onClick:e.connectChoices[0].connect,children:h("connect")}):e.connectChoices.map(S=>jsxRuntime.jsxs("button",{type:"button",className:"idos-press",style:yr,onClick:S.connect,children:[jsxRuntime.jsx("span",{style:{flex:1,textAlign:"left"},children:S.label}),jsxRuntime.jsx("span",{"aria-hidden":true,style:{color:f.textDim},children:"\u203A"})]},S.key))]}),jt=g?jsxRuntime.jsx(kr,{icon:jsxRuntime.jsx(br,{assets:U?.AssetPaths,name:K}),name:K,backed:Number(j)||0,unbacked:co,hasIou:po,decimals:Gt}):null,fo=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[Object.keys(i).length>1?jsxRuntime.jsx(Dn,{caption:h("network"),value:m,onChange:k,options:Object.entries(i).map(([S,R])=>[S,R.DisplayName??S])}):null,M.length===0?jsxRuntime.jsx("div",{style:{...ne,padding:"10px 12px",...B},children:h("noTokens")}):M.length>1?jsxRuntime.jsx(Dn,{caption:h("token"),value:g,onChange:W,options:M.map(([S,R])=>[S,R.DisplayName??S])}):null]}),go=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Sr,{value:u,onChange:S=>{b(S),z(null),_("");}}),fo,jsxRuntime.jsxs("div",{style:{display:"grid",gap:6},children:[jsxRuntime.jsx("span",{style:B,children:h("amount")}),jsxRuntime.jsxs("div",{style:{...ne,display:"flex",alignItems:"center",gap:8,padding:"4px 6px 4px 14px"},children:[jsxRuntime.jsx("input",{style:hr,inputMode:"decimal",placeholder:"0.0",value:A,onChange:S=>_(S.target.value.replace(",","."))}),jsxRuntime.jsx("span",{style:{...B,fontSize:14},children:K}),u==="withdraw"&&Number(j)>0?jsxRuntime.jsx("button",{type:"button",className:"idos-press",style:se("gold",false,"sm"),onClick:()=>_(String(j)),children:h("max")}):null]}),u==="withdraw"&&qt>0?jsxRuntime.jsx("span",{style:{...B,fontSize:12},children:h("minWithdraw",{n:Tt(qt,Gt)})}):null]}),u==="deposit"?jsxRuntime.jsx(xt,{tone:"green",busy:J,busyText:at,disabled:!Ue||!v?.ContractAddress||!En(A),onClick:()=>{!D||!v||rt("deposit",()=>Vt({network:D,binding:v,currencyID:g,amount:A}));},children:h("deposit")}):jsxRuntime.jsx(xt,{tone:"blue",busy:J,busyText:at,disabled:!Ue||!g||!En(A),onClick:()=>{D&&rt("withdraw",()=>uo());},children:h("withdraw")})]}),yo=r?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{style:{...en("gold"),padding:"12px 14px",display:"grid",gap:4},children:zt?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{style:{...L,color:"inherit",fontSize:13,opacity:.9},children:h("topUpNeed")}),jsxRuntime.jsxs("span",{style:{...L,color:"inherit",fontSize:24,lineHeight:1.1},children:[nt," ",ot," ",h("topUpMore")]}),jsxRuntime.jsx("span",{style:{fontSize:13,fontWeight:600,opacity:.95},children:h("topUpHint")})]}):jsxRuntime.jsx("span",{style:{...L,color:"inherit",fontSize:15},children:s?h("topUpCannot",{name:ot}):h("loading")})}),jt,jsxRuntime.jsx(xt,{tone:"green",busy:J,busyText:at,disabled:!Ue||!zt,onClick:()=>{!D||!v||rt("deposit",()=>Vt({network:D,binding:v,currencyID:g,amount:nt})).then(S=>{S.ok&&r.onDone(true);});},children:h("depositAmount",{amount:nt,name:ot})})]}):null,Yt=!!n;return jsxRuntime.jsxs("div",{style:{...mr,...Yt?{...De,padding:16,width:360,maxWidth:"100%",maxHeight:"80vh",overflow:"auto"}:{},...o},children:[jsxRuntime.jsx("style",{children:ur}),Yt?jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[jsxRuntime.jsx("span",{style:{...L,fontSize:20},children:r?h("topUpTitle"):h("title")}),jsxRuntime.jsx("button",{type:"button",className:"idos-press",style:wr,onClick:n,"aria-label":"\u2715",children:"\u2715"})]}):null,mo,s?Object.keys(i).length===0?jsxRuntime.jsx("div",{style:{...ne,padding:"12px 14px",...B},children:h("noNetworks")}):r?yo:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jt,go]}):jsxRuntime.jsx("div",{style:{...B,textAlign:"center",padding:12},children:h("loading")}),Z?jsxRuntime.jsx(Cr,{tab:Z.tab,result:Z.res}):null]})}function br({assets:t,name:e}){let n=t?.Default||t?.Icon||"",o={width:40,height:40,borderRadius:"50%",flex:"none",display:"grid",placeItems:"center",background:`linear-gradient(180deg, ${f.gold}, ${f.goldDeep})`,boxShadow:`0 3px 0 ${f.edge}`,overflow:"hidden",fontSize:22};return /^(https?:)?\/\/|^\//.test(n)?jsxRuntime.jsx("span",{style:o,children:jsxRuntime.jsx("img",{src:n,alt:"",style:{width:"100%",height:"100%",objectFit:"cover"}})}):jsxRuntime.jsx("span",{style:{...o,...L,fontSize:20},"aria-hidden":true,children:(e.trim()[0]??"?").toUpperCase()})}function kr({icon:t,name:e,backed:n,unbacked:o,hasIou:r,decimals:a}){let[s,l]=react.useState(false),i=(d,c,p=false)=>jsxRuntime.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:16},children:[jsxRuntime.jsx("span",{style:{...B,fontSize:13},children:d}),jsxRuntime.jsx("span",{style:{...L,fontSize:14,color:p?f.textDim:f.text},children:Tt(c,a)})]});return jsxRuntime.jsxs("div",{style:{position:"relative"},onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),children:[jsxRuntime.jsxs("button",{type:"button","aria-expanded":s,onClick:()=>l(d=>!d),onBlur:()=>l(false),style:{...ne,display:"flex",alignItems:"center",gap:12,padding:"10px 14px",width:"100%",cursor:"pointer",font:"inherit",textAlign:"left"},children:[t,jsxRuntime.jsxs("span",{style:{display:"grid",minWidth:0,flex:1},children:[jsxRuntime.jsx("span",{style:{...B,fontSize:12},children:h("balance")}),jsxRuntime.jsxs("span",{style:{...L,fontSize:22,lineHeight:1.1},children:[Tt(n+o,a)," ",jsxRuntime.jsx("span",{style:{fontSize:15,color:f.textDim},children:e})]})]}),jsxRuntime.jsx("span",{"aria-hidden":true,style:{...B,fontSize:16},children:"\u24D8"})]}),s?jsxRuntime.jsxs("div",{role:"tooltip",style:{...De,position:"absolute",left:0,right:0,top:"calc(100% + 6px)",zIndex:5,padding:"10px 12px",display:"grid",gap:6},children:[i(h("backed"),n),r?i(h("unbacked"),o,o===0):null,jsxRuntime.jsx("div",{style:{height:1,background:f.line}}),i(h("total"),n+o),jsxRuntime.jsx("span",{style:{fontSize:12,color:f.textDim,lineHeight:1.35},children:r?h("iouHint"):h("backedHint")})]}):null]})}function Sr({value:t,onChange:e}){let n=[["deposit",h("deposit")],["withdraw",h("withdraw")]];return jsxRuntime.jsx("div",{role:"tablist",style:{display:"flex",gap:6,padding:4,borderRadius:16,background:f.wellSoft},children:n.map(([o,r])=>{let a=o===t;return jsxRuntime.jsx("button",{role:"tab","aria-selected":a,type:"button",className:"idos-press",onClick:()=>!a&&e(o),style:{...L,fontFamily:f.font,fontSize:15,flex:1,border:"none",borderRadius:12,padding:"9px 14px",cursor:"pointer",color:a?f.onBlue:f.textDim,background:a?`linear-gradient(180deg, ${f.blue}, ${f.blueDeep})`:"transparent",boxShadow:a?`0 3px 0 ${f.edge}, inset 0 2px 0 rgba(255,255,255,.3)`:"none",transition:`background ${f.fast} ease`},children:r},o)})})}function Dn({caption:t,value:e,onChange:n,options:o}){return jsxRuntime.jsxs("label",{style:{display:"grid",gap:6},children:[jsxRuntime.jsx("span",{style:B,children:t}),jsxRuntime.jsxs("span",{style:{position:"relative",display:"block"},children:[jsxRuntime.jsx("select",{value:e,onChange:r=>n(r.target.value),style:{...ne,...L,fontFamily:f.font,fontSize:15,width:"100%",padding:"10px 36px 10px 12px",appearance:"none",WebkitAppearance:"none",cursor:"pointer",outline:"none"},children:o.map(([r,a])=>jsxRuntime.jsx("option",{value:r,style:{color:"#111"},children:a},r))}),jsxRuntime.jsx("span",{"aria-hidden":true,style:{position:"absolute",right:14,top:"50%",transform:"translateY(-50%)",color:f.textDim,pointerEvents:"none"},children:"\u25BE"})]})]})}function xt({tone:t,busy:e,busyText:n,disabled:o,onClick:r,children:a}){return jsxRuntime.jsx("button",{type:"button",className:"idos-press",disabled:o||e,onClick:r,style:{...se(t,o&&!e,"lg"),width:"100%"},children:e?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{"aria-hidden":true,style:{width:18,height:18,borderRadius:"50%",border:"3px solid rgba(255,255,255,.35)",borderTopColor:"#fff",animation:"idosw-spin .8s linear infinite"}}),n]}):a})}function Cr({tab:t,result:e}){let n=e.ok,o={borderRadius:14,padding:"10px 12px",display:"grid",gap:4,background:`color-mix(in srgb, ${n?f.green:f.red} 22%, transparent)`,border:`2px solid color-mix(in srgb, ${n?f.green:f.red} 60%, transparent)`,wordBreak:"break-word"};return n?jsxRuntime.jsxs("div",{style:o,role:"status",children:[jsxRuntime.jsxs("span",{style:{...L,fontSize:15},children:["\u2713 ",t==="withdraw"?h("doneWithdraw"):h("doneDeposit")]}),jsxRuntime.jsxs("span",{style:{...B,fontSize:12},children:[h("tx"),": ",Nn(e.onChainTxHash)]})]}):jsxRuntime.jsxs("div",{style:o,role:"alert",children:[jsxRuntime.jsxs("span",{style:{...L,fontSize:15},children:["\u2715 ",h("failed")]}),jsxRuntime.jsx("span",{style:{fontSize:13,color:f.text,opacity:.9},children:e.error}),e.titleTransactionID?jsxRuntime.jsx("span",{style:{...B,fontSize:12},children:h("debited")}):null]})}var lr,cr,dr,Nn,En,ur,mr,fr,gr,yr,wr,hr,Wt=C(()=>{G();it();lr=/^(Not enough confirmations|Transaction not found on chain)/,cr=8,dr=5e3;Nn=t=>t.length>14?`${t.slice(0,6)}\u2026${t.slice(-4)}`:t,En=t=>/^\d+(\.\d+)?$/.test(t)&&Number(t)>0;ur="@keyframes idosw-spin { to { transform: rotate(360deg) } }",mr={pointerEvents:"auto",color:f.text,fontFamily:f.font,display:"flex",flexDirection:"column",gap:12,boxSizing:"border-box",width:"100%",minWidth:0,maxWidth:"100%"},fr={width:10,height:10,borderRadius:"50%",background:f.green,boxShadow:`0 0 0 3px color-mix(in srgb, ${f.green} 30%, transparent)`,flex:"none"},gr={...L,fontFamily:f.font,fontSize:13,color:f.textDim,background:"transparent",border:`2px solid ${f.line}`,borderRadius:10,padding:"5px 10px",cursor:"pointer"},yr={...ne,...L,fontFamily:f.font,fontSize:15,display:"flex",alignItems:"center",gap:10,padding:"10px 12px",cursor:"pointer",width:"100%"},wr={...se("red",false,"sm"),width:36,minHeight:36,padding:0,borderRadius:"50%"},hr={...L,fontFamily:f.font,fontSize:22,flex:1,minWidth:0,background:"transparent",border:"none",outline:"none",padding:"6px 0"};});function Rn(t){let{client:e,walletConnectProjectId:n,appName:o,onClose:r,style:a,topUp:s}=t,[l,i]=react.useState(n??"");react.useEffect(()=>{if(n)return;let c=true;return (async()=>{let p=await e.blockchain.getDefinitions();if(!c||!p.ok)return;let u=p.data.Blockchain?.WalletLogin?.WalletConnectProjectId;u&&i(u);})(),()=>{c=false;}},[e,n]);let d=react.useMemo(()=>Ge({walletConnectProjectId:l||void 0,appName:o}),[l,o]);return jsxRuntime.jsx(xe,{wagmiConfig:d,children:jsxRuntime.jsx(Dr,{client:e,onClose:r,style:a,topUp:s})})}function Dr({client:t,onClose:e,style:n,topUp:o}){let r=Ve(t,t.titleID),{address:a,isConnected:s,chainId:l}=wagmi.useAccount(),{connect:i,connectors:d}=wagmi.useConnect(),{disconnect:c}=wagmi.useDisconnect(),{switchChainAsync:p}=wagmi.useSwitchChain();async function u(m){if(!m||l===m)return true;try{return await p({chainId:m}),!0}catch{return false}}let b={networkType:"EVM",address:s&&a?a:null,connectChoices:d.map(m=>({key:m.uid,label:m.name,connect:()=>i({connector:m})})),disconnect:()=>c(),deposit:async({network:m,binding:k,amount:g})=>{if(!k.ContractAddress)return y("approve","This token cannot be deposited.");if(!await u(m.ChainID))return y("approve",`Switch your wallet to chain ${m.ChainID} to continue.`);let W;try{W=viem.parseUnits(g,k.Decimals??18);}catch{return y("approve","Invalid amount.")}return r.depositToken({network:m,tokenAddress:k.ContractAddress,amount:W})},withdraw:async({network:m,networkID:k,currencyID:g,amount:W})=>r.account?await u(m.ChainID)?r.withdrawToken({currencyID:g,networkID:k,walletAddress:r.account,amount:W}):y("request",`Switch your wallet to chain ${m.ChainID} to continue.`):y("request","Wallet not connected.")};return jsxRuntime.jsx(Ye,{client:t,engine:b,onClose:e,style:n,topUp:o})}var Ln=C(()=>{pt();ze();$e();G();Wt();});function It(t){let[e,n]=react.useState(null);return react.useEffect(()=>{if(E()||Ee())return;let o=null;return t.checkout.setTopUpHandler(r=>new Promise(a=>{o?.(false);let s=false,l=i=>{s||(s=true,o===l&&(o=null),n(d=>d?.onDone===l?null:d),a(i));};o=l,n({currencyID:r.currencyID,amount:r.missingAmount??String(r.missing),onDone:l});})),()=>{t.checkout.setTopUpHandler(null),o?.(false);}},[t]),e}var vt=C(()=>{te();});var Et={};Qt(Et,{DEFAULT_EVM_CHAINS:()=>dt,IDosGamesWalletProvider:()=>xe,WalletLogin:()=>In,WalletLoginButton:()=>Ct,WalletPanel:()=>Rn,arbitrum:()=>exports.arbitrum,base:()=>exports.base,bsc:()=>exports.bsc,chainById:()=>lt,createEvmWalletConfig:()=>Ge,idosChains:()=>exports.idosChains,mainnet:()=>exports.mainnet,optimism:()=>exports.optimism,polygon:()=>exports.polygon,polygonAmoy:()=>exports.polygonAmoy,sepolia:()=>exports.sepolia,useEvmBridge:()=>Ve,useEvmBridgeClients:()=>Be,useWalletTopUp:()=>It});var Dt=C(()=>{pt();ce();ze();$e();vn();Ln();vt();});function Qe(t){let{walletConnectProjectId:e,appName:n,appUrl:o,appIcon:r,wallets:a}=t,s=Bn.get(e);if(s)return s;let l=t.networks??[exports.solanaMainnet],i=o??(typeof window<"u"?window.location.origin:""),d={name:n??"iDosGames",description:n??"iDosGames game",url:i,icons:r?[r]:[]},c=new appkitAdapterSolana.SolanaAdapter(a?{wallets:a}:{});return Ke(react$1.createAppKit({adapters:[c],networks:l,projectId:e,metadata:d,features:{analytics:false,email:false,socials:false}})),Bn.set(e,c),c}var Bn,Nt=C(()=>{ce();Pe();Bn=new Map;});async function _e(t){let{client:e,adapter:n,network:o,mint:r,amountRaw:a,titleID:s,category:l}=t;if(E())return ee("deposit-onchain");let i=e.auth.context?.userID;if(!i)return y("deposit-onchain","Not logged in.");if(a<=0n)return y("deposit-onchain","Amount must be positive.");let d;try{d=await n.depositSpl({mint:r,amountRaw:a,userID:i,titleID:s,category:core.normalizeBlockchainCategory(l)});}catch(p){return y("deposit-onchain",O(p))}let c=await e.blockchain.depositToken(o.NetworkID??"",d);return c.ok?{ok:true,onChainTxHash:d,data:c.data}:y("report",c.error,{onChainTxHash:d})}async function Me(t){let{client:e,adapter:n,currencyID:o,networkID:r,walletAddress:a,amount:s,category:l}=t;if(E())return ee("request");let i=await e.blockchain.requestTokenWithdrawal(o,r,a,s,l);if(!i.ok)return y("request",i.error);let d=i.data.SolanaSignature,c=i.data.TitleTransactionID??void 0;if(!d)return y("request","Withdrawal response carried no Solana signature.",{titleTransactionID:c});let p;try{p=await n.submitWithdrawal(d);}catch(b){return y("withdraw-onchain",O(b),{titleTransactionID:c})}if(!c)return y("confirm","Missing TitleTransactionID.",{onChainTxHash:p});let u=await e.blockchain.confirmWithdrawal(c,p);return u.ok?{ok:true,onChainTxHash:p,data:i.data}:y("confirm",u.error,{onChainTxHash:p,titleTransactionID:c})}var On=C(()=>{G();te();});async function Fe(t){let{client:e,networkID:n,walletAddress:o,signMessage:r}=t;if(E())return me("challenge");let a=await e.auth.requestWalletChallenge(o,n);if(!a.ok)return P("challenge",a.error);let s;try{let i=await r(new TextEncoder().encode(a.data.Message));s=_n(i);}catch(i){return P("sign",O(i))}let l=await e.auth.loginWithWallet(o,n,s);return l.ok?{ok:true,data:l.data}:P("login",l.error)}async function Rt(t){let{client:e,networkID:n,walletAddress:o,signMessage:r}=t;if(E())return me("challenge");let a=await e.auth.linkWallet(o,n);if(!a.ok)return P("challenge",a.error);if(!a.data.Challenge)return P("challenge","No challenge was issued.");let s;try{let i=await r(new TextEncoder().encode(a.data.Challenge));s=_n(i);}catch(i){return P("sign",O(i))}let l=await e.auth.linkWallet(o,n,s);return l.ok?{ok:true,data:l.data}:P("login",l.error)}function _n(t){let e="0x";for(let n of t)e+=n.toString(16).padStart(2,"0");return e}var Mn=C(()=>{G();te();});var Je=C(()=>{On();Mn();});function Un(t,e,n){let{address:o}=react$1.useAppKitAccount(),{walletProvider:r}=react$1.useAppKitProvider("solana"),a=o??null,s=r?.signMessage?.bind(r);return {connected:!!a,account:a,loginWithWallet:(l,i)=>{let d=i??a;return d?s?Fe({client:t,networkID:l,walletAddress:d,signMessage:s}):Promise.resolve(P("sign","The connected wallet does not support message signing.")):Promise.resolve(P("challenge",Fn))},depositToken:l=>_e({client:t,adapter:n,titleID:e,...l}),withdrawToken:l=>{let i=l.walletAddress??a;return i?Me({client:t,adapter:n,...l,walletAddress:i}):Promise.resolve(y("request",Fn))}}}var Fn,Hn=C(()=>{Je();G();Fn="Wallet not connected.";});function Kr(t){try{let n=t?.session?.peer?.metadata?.redirect,o=n?.native||n?.universal;return !o||typeof window>"u"?!1:(window.location.href=o,!0)}catch{return false}}function zn(t,e){return new Promise((n,o)=>{let r=setTimeout(()=>o(new Error("The wallet request timed out.")),e);t.then(a=>{clearTimeout(r),n(a);},a=>{clearTimeout(r),o(a instanceof Error?a:new Error(String(a)));});})}function Gr(t){let e="Wallet sign-in failed. Please try again.";return t instanceof Error?/user (rejected|denied|cancelled|canceled)|rejected the request/i.test(t.message)?"Request declined in the wallet.":/timed? ?out/i.test(t.message)?"The wallet did not respond. Open your wallet and try again.":e:e}function Vn(t){let{client:e,networkID:n,onAuthenticated:o,disabled:r,label:a,style:s,autoStart:l,mode:i="login",onLinked:d}=t,{address:c,isConnected:p}=react$1.useAppKitAccount(),{walletProvider:u}=react$1.useAppKitProvider("solana"),[b,m]=react.useState(false),[k,g]=react.useState(null),[W,A]=react.useState(false),[_,J]=react.useState(false),$=react.useRef(null),Z=react.useRef(0),z=react.useCallback(()=>{$.current&&clearTimeout($.current),$.current=null;},[]);react.useEffect(()=>z,[z]);let ae=react.useRef(false),re=react.useCallback(async()=>{let U=++Z.current,v=()=>Z.current===U,j=u?.signMessage?.bind(u);if(!c||!j){g("The connected wallet cannot sign messages."),m(false);return}m(true),g(null);try{if(J(!0),i==="link"){let X=await zn(Rt({client:e,networkID:n,walletAddress:c,signMessage:j}),Gn);if(!v())return;if(X.ok){d?.(X.data.PlayAccess??null);return}g(X.stage==="sign"?"Signature declined.":core.authErrorText(X.error,"Could not link the wallet."));return}let K=await zn(Fe({client:e,networkID:n,walletAddress:c,signMessage:j}),Gn);if(!v())return;if(K.ok){o();return}g(K.stage==="sign"?"Signature declined.":core.authErrorText(K.error,"Wallet sign-in failed."));}catch(K){if(!v())return;console.error("[idosgames/wallet] solana sign-in failed:",K),g(Gr(K));}finally{v()&&(m(false),J(false));}},[c,u,e,n,o,i,d]),M=react.useCallback(()=>{Kr(u)||oe()?.open();},[u]);react.useEffect(()=>{!W||!p||!c||!u||(A(false),z(),re());},[W,p,c,u,re,z]);let D=()=>{if(_){M();return}if(g(null),ae.current=true,p&&c&&u){re();return}let U=oe();if(!U){g("Wallet sign-in is not configured for this title.");return}m(true),A(true),z(),$.current=setTimeout(()=>{A(false),m(false),g("No wallet was connected.");},Hr),U.open();};return react.useEffect(()=>{!l||ae.current||(ae.current=true,D());},[l]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",onClick:D,disabled:r,style:{...zr,...r?{opacity:.6,cursor:"default"}:null,...s},children:_?"Waiting for signature \u2014 tap to open wallet":b?"Check your wallet\u2026":p?a??(i==="link"?"Link wallet":"Sign in with wallet"):"Connect wallet"}),k&&jsxRuntime.jsx("span",{role:"alert",style:qr,children:k})]})}var Hr,Gn,zr,qr,$n=C(()=>{Je();Pe();Hr=18e4,Gn=9e4;zr={padding:"11px 16px",borderRadius:"8px",border:"none",background:"#4c3fa8",color:"#fff",font:"inherit",fontWeight:600,cursor:"pointer"},qr={display:"block",marginTop:"6px",color:"#ff9b9b",fontSize:"13px",textAlign:"center"};});function Xe(t){let e=(t??"").replace(/^0x/i,""),n=new Uint8Array(e.length>>1);for(let o=0;o<n.length;o++)n[o]=parseInt(e.slice(o*2,o*2+2),16);return n}function We(t){let e=buffer.Buffer.alloc(8);return e.writeBigUInt64LE(BigInt(t||0)),e}function ra(t){let e=buffer.Buffer.alloc(8);return e.writeBigInt64LE(BigInt(t||0)),e}function Ie(t){let e=buffer.Buffer.from(t??"","utf8"),n=buffer.Buffer.alloc(4);return n.writeUInt32LE(e.length),buffer.Buffer.concat([n,e])}async function Yn(t){let e=await globalThis.crypto.subtle.digest("SHA-256",new TextEncoder().encode(t??""));return new Uint8Array(e)}function Xn(t,e,n){return pe(t,buffer.Buffer.from("title_balance"),buffer.Buffer.from(e),n.toBuffer())}function aa(t){return buffer.Buffer.concat([buffer.Buffer.from(Zr,"hex"),We(t.amountRaw),Ie(t.userID),Ie(t.titleID),Ie(t.category),buffer.Buffer.from(t.titleHash)])}function ia(t,e){let n=t.Splits??[],o=buffer.Buffer.alloc(4);return o.writeUInt32LE(n.length),buffer.Buffer.concat([buffer.Buffer.from(t.Domain==="SPL_DEV"?ea:Xr,"hex"),We(t.Amount),We(t.BurnAmount),We(t.Nonce),ra(t.ExpiresAt),o,...n.map(r=>buffer.Buffer.concat([buffer.Buffer.from(new web3_js.PublicKey(r.To??"").toBytes()),We(r.Amount)])),Ie(t.UserID),Ie(t.TitleID),Ie(t.Category),buffer.Buffer.from(e)])}function Ae(t,e,n){return web3_js.PublicKey.findProgramAddressSync([e.toBuffer(),n.toBuffer(),t.toBuffer()],et)[0]}function sa(t,e,n,o,r){return new web3_js.TransactionInstruction({programId:et,keys:[{pubkey:t,isSigner:true,isWritable:true},{pubkey:e,isSigner:false,isWritable:true},{pubkey:n,isSigner:false,isWritable:false},{pubkey:o,isSigner:false,isWritable:false},{pubkey:web3_js.SystemProgram.programId,isSigner:false,isWritable:false},{pubkey:r,isSigner:false,isWritable:false}],data:buffer.Buffer.from([1])})}function pe(t,...e){return web3_js.PublicKey.findProgramAddressSync(e,t)[0]}function la(t){let{programId:e,user:n,mint:o,tokenProgram:r}=t,a=pe(e,buffer.Buffer.from("vault"));return new web3_js.TransactionInstruction({programId:e,keys:[{pubkey:pe(e,buffer.Buffer.from("config")),isSigner:false,isWritable:false},{pubkey:a,isSigner:false,isWritable:true},{pubkey:o,isSigner:false,isWritable:false},{pubkey:n,isSigner:true,isWritable:true},{pubkey:Ae(o,n,r),isSigner:false,isWritable:true},{pubkey:Ae(o,a,r),isSigner:false,isWritable:true},{pubkey:r,isSigner:false,isWritable:false},{pubkey:et,isSigner:false,isWritable:false},{pubkey:web3_js.SystemProgram.programId,isSigner:false,isWritable:false},{pubkey:Xn(e,t.titleHash,o),isSigner:false,isWritable:true}],data:aa(t)})}function ca(t){let{sig:e,payer:n,tokenProgram:o,titleHash:r}=t,a=new web3_js.PublicKey(e.ProgramID??""),s=new web3_js.PublicKey(e.Mint??""),l=new web3_js.PublicKey(e.WalletAddress??""),i=pe(a,buffer.Buffer.from("vault")),d=new web3_js.PublicKey(ta),c=(e.Splits??[]).map(k=>new web3_js.PublicKey(k.To??"")),p=c.map(k=>Ae(s,k,o)),u=web3_js.Ed25519Program.createInstructionWithPublicKey({publicKey:Xe(e.Ed25519PublicKey),message:Xe(e.Ed25519Message),signature:Xe(e.SignatureHex)}),b=c.map((k,g)=>sa(n,p[g],k,s,o)),m=new web3_js.TransactionInstruction({programId:a,keys:[{pubkey:pe(a,buffer.Buffer.from("config")),isSigner:false,isWritable:false},{pubkey:n,isSigner:true,isWritable:true},{pubkey:i,isSigner:false,isWritable:true},{pubkey:pe(a,buffer.Buffer.from("nonce"),We(e.Nonce)),isSigner:false,isWritable:true},{pubkey:s,isSigner:false,isWritable:false},{pubkey:l,isSigner:false,isWritable:false},{pubkey:Ae(s,i,o),isSigner:false,isWritable:true},{pubkey:Ae(s,l,o),isSigner:false,isWritable:true},{pubkey:d,isSigner:false,isWritable:false},{pubkey:Ae(s,d,o),isSigner:false,isWritable:true},{pubkey:web3_js.SYSVAR_INSTRUCTIONS_PUBKEY,isSigner:false,isWritable:false},{pubkey:o,isSigner:false,isWritable:false},{pubkey:et,isSigner:false,isWritable:false},{pubkey:web3_js.SystemProgram.programId,isSigner:false,isWritable:false},{pubkey:Xn(a,r,s),isSigner:false,isWritable:true},...p.map(k=>({pubkey:k,isSigner:false,isWritable:true}))],data:ia(e,r)});return [u,...b,m]}async function da(t,e,n){let o=async a=>{let s=(await t.getSignatureStatuses([e],{searchTransactionHistory:a})).value[0];if(s?.err)throw new H("TRANSACTION_FAILED",`transaction ${e} failed: ${JSON.stringify(s.err)}`);return s},r=a=>a?.confirmationStatus==="confirmed"||a?.confirmationStatus==="finalized";for(let a=1;;a++){await new Promise(i=>setTimeout(i,pa));let s=null;try{s=await o(!1);}catch(i){if(i instanceof H)throw i}if(r(s))return;if(!(s||a%ua!==0||await t.getBlockHeight("confirmed").catch(()=>-1)<=n)){if(r(await o(true).catch(()=>null)))return;throw new H("TRANSACTION_EXPIRED",`transaction ${e} expired: block height exceeded`)}}}function tt(t){let{connection:e,signTransaction:n}=t;async function o(a){let s=await e.getAccountInfo(a);if(!s)throw new H("MINT_NOT_FOUND",`mint ${a.toBase58()} not found`);return s.owner}async function r(a,s){let{blockhash:l,lastValidBlockHeight:i}=await e.getLatestBlockhash("confirmed"),d=new web3_js.Transaction;d.feePayer=a,d.recentBlockhash=l,d.add(...s);let c=await n(d),p=await e.sendRawTransaction(c.serialize());return await da(e,p,i),p}return {async depositSpl({mint:a,amountRaw:s,userID:l,titleID:i,category:d}){let c=new web3_js.PublicKey(t.owner),p=new web3_js.PublicKey(a),u=await o(p);return r(c,[la({programId:new web3_js.PublicKey(t.programId),user:c,mint:p,tokenProgram:u,amountRaw:s,userID:l,titleID:i,category:d,titleHash:await Yn(i)})])},async submitWithdrawal(a){if(!a.ProgramID||!a.Mint||!a.WalletAddress)throw new H("BAD_VOUCHER","the voucher has no program, mint or wallet");let s=new web3_js.PublicKey(t.owner),l=new web3_js.PublicKey(a.ProgramID),i=await e.getAccountInfo(pe(l,buffer.Buffer.from("config")));if(!i)throw new H("POOL_NOT_ON_THIS_CLUSTER","the pool's config account is not on this cluster");if(i.data.length!==jn)throw new H("POOL_NOT_MIGRATED",`config is ${i.data.length} bytes, expected ${jn} (migrate_config not run)`);let d=buffer.Buffer.from(i.data);if(d[oa]===1)throw new H("POOL_PAUSED","pool withdrawals are paused");let c=d.readBigUInt64LE(Zn);if(c!==BigInt(a.SignatureEpoch||0))throw new H("VOUCHER_REVOKED",`signature epoch mismatch: voucher ${a.SignatureEpoch}, on-chain ${c}`);let p=buffer.Buffer.from(Xe(a.Ed25519PublicKey)),u=false;for(let m=0;m<Jn;m++){let k=Qn+m*32;p.equals(d.subarray(k,k+32))&&(u=true);}if(!u)throw new H("SIGNER_NOT_TRUSTED","the voucher's signer is not in the pool's server_pubkeys");let b=await o(new web3_js.PublicKey(a.Mint));return r(s,[web3_js.ComputeBudgetProgram.setComputeUnitLimit({units:na}),...ca({sig:a,payer:s,tokenProgram:b,titleHash:await Yn(a.TitleID??"")})])}}}var Zr,Xr,ea,et,ta,jn,na,Qn,Jn,Zn,oa,H,pa,ua,Ft=C(()=>{Zr="e000c6afc62f69cc",Xr="b59a5e563e7306ba",ea="d668e18c1bdc33f1",et=new web3_js.PublicKey("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"),ta="1nc1nerator11111111111111111111111111111111",jn=177,na=3e5,Qn=40,Jn=4,Zn=Qn+32*Jn,oa=Zn+8,H=class extends Error{constructor(n,o){super(o);this.code=n;this.name="PlatformPoolError";}code};pa=2e3,ua=5;});function Sa(t){return (t.ChainID===ka?exports.solanaDevnet:exports.solanaMainnet).rpcUrls.default.http[0]}function eo(t){let{client:e,walletConnectProjectId:n,appName:o,onClose:r,style:a,topUp:s}=t,[l,i]=react.useState(n??"");react.useEffect(()=>{if(n)return;let g=true;return (async()=>{let W=await e.blockchain.getDefinitions();if(!g||!W.ok)return;let A=W.data.Blockchain?.WalletLogin?.WalletConnectProjectId;A&&i(A);})(),()=>{g=false;}},[e,n]);let d=react.useMemo(()=>l?(Qe({walletConnectProjectId:l,appName:o}),true):false,[l,o]),{address:c,isConnected:p}=react$1.useAppKitAccount(),{walletProvider:u}=react$1.useAppKitProvider("solana"),b=p&&c?c:null,m=(g,W)=>tt({connection:new web3_js.Connection(Sa(g),"confirmed"),owner:W,programId:g.RewardPoolAddress??"",signTransaction:async A=>{if(!u)throw new Error("Wallet not connected.");return u.signTransaction(A)}});return jsxRuntime.jsx(Ye,{client:e,engine:{networkType:"Solana",address:b,connectChoices:d?[{key:"appkit",label:"Connect wallet",connect:()=>{oe()?.open();}}]:[],disconnect:()=>{oe()?.disconnect("solana");},deposit:async({network:g,binding:W,amount:A})=>{if(!b)return y("deposit-onchain","Wallet not connected.");if(!W.ContractAddress)return y("deposit-onchain","This token cannot be deposited.");if(!g.RewardPoolAddress)return y("deposit-onchain","POOL_NOT_IN_REGISTRY");let _;try{_=viem.parseUnits(A,W.Decimals??9);}catch{return y("deposit-onchain","Invalid amount.")}return _e({client:e,adapter:m(g,b),network:g,mint:W.ContractAddress,amountRaw:_,titleID:e.titleID})},withdraw:async({network:g,networkID:W,currencyID:A,amount:_})=>b?Me({client:e,adapter:m(g,b),currencyID:A,networkID:W,walletAddress:b,amount:_}):y("request","Wallet not connected.")},onClose:r,style:a,topUp:s})}var ka,to=C(()=>{ce();Je();Ft();G();Pe();Nt();Wt();ka=103;});var Ut={};Qt(Ut,{PlatformPoolError:()=>H,SolanaWalletLogin:()=>Vn,SolanaWalletPanel:()=>eo,createPlatformPoolAdapter:()=>tt,createSolanaWalletConfig:()=>Qe,solanaDevnet:()=>exports.solanaDevnet,solanaMainnet:()=>exports.solanaMainnet,useSolanaBridge:()=>Un});var Ht=C(()=>{Nt();Hn();$n();to();Ft();ce();});te();it();G();var fe={addressRequest:"IDOS_PLATFORM_WALLET_ADDRESS_REQUEST",addressResponse:"IDOS_PLATFORM_WALLET_ADDRESS_RESPONSE",signRequest:"IDOS_PLATFORM_WALLET_SIGN_REQUEST",signResponse:"IDOS_PLATFORM_WALLET_SIGN_RESPONSE",openRequest:"IDOS_PLATFORM_WALLET_OPEN_REQUEST",openResponse:"IDOS_PLATFORM_WALLET_OPEN_RESPONSE"},tn=core.PLATFORM_PAGE_UNAVAILABLE;async function st(t,e,n){let o=await core.askPlatformPage(t,e,n),{address:r,signature:a}=o.data;return {ok:o.ok,error:o.error,address:typeof r=="string"?r:void 0,signature:typeof a=="string"?a:void 0}}async function Io(){return (await st(fe.openRequest,fe.openResponse,{})).ok}async function nn(t){let{client:e,networkID:n}=t;return rn(t,async o=>{let r=await e.auth.requestWalletChallenge(o,n);return r.ok?{ok:true,message:r.data.Message}:{ok:false,error:r.error}},(o,r)=>e.auth.loginWithWallet(o,n,r))}async function on(t){let{client:e,networkID:n}=t;return rn(t,async o=>{let r=await e.auth.linkWallet(o,n);return r.ok?r.data.Challenge?{ok:true,message:r.data.Challenge}:{ok:false,error:"No challenge was issued."}:{ok:false,error:r.error}},(o,r)=>e.auth.linkWallet(o,n,r))}async function rn(t,e,n){let{client:o,family:r}=t,a=o.titleID,s=await st(fe.addressRequest,fe.addressResponse,{titleID:a,family:r});if(!s.ok||!s.address)return P("challenge",s.error??"NO_WALLET");let l=s.address,i=await e(l);if(!i.ok)return P("challenge",i.error);let d=await st(fe.signRequest,fe.signResponse,{titleID:a,family:r,address:l,message:i.message});if(!d.ok||!d.signature)return P("sign",d.error??"SIGN_FAILED");let c=await n(l,d.signature);return c.ok?{ok:true,data:c.data}:P("login",c.error)}var oo={padding:"11px 16px",borderRadius:"8px",border:"none",background:"#4c3fa8",color:"#fff",font:"inherit",fontWeight:600,cursor:"pointer"},ro={display:"block",marginTop:"6px",color:"#ff9b9b",fontSize:"13px",textAlign:"center"};function no(t){switch(t){case tn:return "Wallet sign-in is not available on this page.";case "NO_WALLET":case "CANCELLED":return "Connect a wallet on the page to sign in.";case "REJECTED":return "The signature was declined.";case "TIMEOUT":return "The wallet did not answer. Please try again.";default:return t}}function xa(t){let{client:e,networkID:n,onAuthenticated:o,onLinked:r,mode:a="login",family:s,disabled:l,label:i,style:d}=t,[c,p]=react.useState(false),[u,b]=react.useState(null);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>{p(true),b(null),(async()=>{if(a==="link"){let g=await on({client:e,networkID:n,family:s});if(g.ok){p(false),r?.(g.data.PlayAccess??null);return}b(no(g.error)),p(false);return}let k=await nn({client:e,networkID:n,family:s});if(k.ok){o?.();return}b(no(k.error)),p(false);})();},disabled:l||c,style:{...oo,...l||c?{opacity:.6,cursor:"default"}:null,...d},children:c?"Waiting for the wallet\u2026":i??(a==="link"?"Link wallet":"Sign in with wallet")}),u&&jsxRuntime.jsx("span",{role:"alert",style:ro,children:u})]})}function ao(t,e){return Ee()?null:jsxRuntime.jsx(xa,{...t,family:e})}function io(t){let{loading:e,disabled:n,label:o,style:r,error:a,onClick:s}=t;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",onClick:s,disabled:n||e,style:{...oo,...n||e?{opacity:.6,cursor:"default"}:null,...r},children:e?"Loading wallet\u2026":o??"Sign in with wallet"}),a&&jsxRuntime.jsx("span",{role:"alert",style:ro,children:a})]})}function Ta(t){let{chains:e,walletConnectProjectId:n,appName:o,disabled:r,label:a,style:s,onAuthenticated:l,...i}=t,[d,c]=react.useState(null),[p,u]=react.useState(false),[b,m]=react.useState(null);if(E())return ao(t,"evm");let k=()=>{u(true),m(null),(async()=>{try{let g=await Promise.resolve().then(()=>(Dt(),Et)),W=g.createEvmWalletConfig({chains:e,walletConnectProjectId:n,appName:o});c({mod:g,config:W});}catch(g){console.error("[idosgames/wallet] failed to load the wallet module:",g),m("Could not load the wallet. Please try again.");}finally{u(false);}})();};if(d){let{WalletLogin:g}=d.mod;return jsxRuntime.jsx(g,{...i,onAuthenticated:l??so,wagmiConfig:d.config,disabled:r,label:a,style:s,autoStart:true})}return jsxRuntime.jsx(io,{loading:p,disabled:r,label:a??(t.mode==="link"?"Link wallet":void 0),style:s,error:b,onClick:k})}function so(){}function Wa(t){let{walletConnectProjectId:e,appName:n,disabled:o,label:r,style:a,onAuthenticated:s,...l}=t,[i,d]=react.useState(null),[c,p]=react.useState(false),[u,b]=react.useState(null);if(E())return ao(t,"solana");let m=()=>{p(true),b(null),(async()=>{try{let k=await Promise.resolve().then(()=>(Ht(),Ut));e&&k.createSolanaWalletConfig({walletConnectProjectId:e,appName:n}),d(k);}catch(k){console.error("[idosgames/wallet] failed to load the wallet module:",k),b("Could not load the wallet. Please try again.");}finally{p(false);}})();};if(i){let{SolanaWalletLogin:k}=i;return jsxRuntime.jsx(k,{...l,onAuthenticated:s??so,disabled:o,label:r,style:a,autoStart:true})}return jsxRuntime.jsx(io,{loading:c,disabled:o,label:r??(t.mode==="link"?"Link wallet":void 0),style:a,error:u,onClick:m})}var Aa={...B,pointerEvents:"auto",padding:16,boxSizing:"border-box",display:"flex",alignItems:"center",justifyContent:"space-between",gap:10,fontSize:15};function Ia(t){let{client:e,onClose:n,style:o}=t,r=E(),[a,s]=react.useState(null),[l,i]=react.useState(null);return react.useEffect(()=>{if(r)return;let d=true;return (async()=>{try{let c=await e.blockchain.getDefinitions(),p=Object.values((c.ok?c.data.Blockchain?.Networks:null)??{}).map(m=>m.Type),b=p.includes("Solana")&&!p.includes("EVM")?{kind:"solana",mod:await Promise.resolve().then(()=>(Ht(),Ut))}:{kind:"evm",mod:await Promise.resolve().then(()=>(Dt(),Et))};d&&s(b);}catch(c){console.error("[idosgames/wallet] failed to load the wallet panel:",c),d&&i("Could not load the wallet.");}})(),()=>{d=false;}},[r,e]),r?null:a?.kind==="evm"?jsxRuntime.jsx(a.mod.WalletPanel,{...t}):a?.kind==="solana"?jsxRuntime.jsx(a.mod.SolanaWalletPanel,{...t}):jsxRuntime.jsxs("div",{style:{...Aa,...n?{...De,width:360,maxWidth:"100%"}:{},...o},children:[l??h("loading"),n&&jsxRuntime.jsx("button",{type:"button",className:"idos-press",onClick:n,"aria-label":"\u2715",style:{...se("red",false,"sm"),width:36,minHeight:36,padding:0,borderRadius:"50%"},children:"\u2715"})]})}te();vt();ce();
|
|
2
|
+
exports.LazySolanaWalletLogin=Wa;exports.LazyWalletLogin=Ta;exports.LazyWalletPanel=Ia;exports.chainById=lt;exports.isEmbeddedInPlatform=E;exports.isEmbeddedOnForeignSite=Ee;exports.openPlatformWalletPanel=Io;exports.useWalletTopUp=It;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { CSSProperties, ReactNode } from 'react';
|
|
2
2
|
import { Chain } from 'viem';
|
|
3
3
|
import { IDosGamesClient, PlayAccessStatus } from '@idosgames/core';
|
|
4
|
-
|
|
4
|
+
import { W as WalletTopUpRequest } from '../topUp-CCNQcHcH.cjs';
|
|
5
|
+
export { u as useWalletTopUp } from '../topUp-CCNQcHcH.cjs';
|
|
6
|
+
export { c as isEmbeddedInPlatform, d as isEmbeddedOnForeignSite, f as openPlatformWalletPanel } from '../platformWalletLogin-BBBBN68y.cjs';
|
|
5
7
|
export { a as AppKitSolanaNetwork, h as arbitrum, i as base, k as bsc, l as chainById, m as idosChains, n as mainnet, o as optimism, p as polygon, q as polygonAmoy, s as sepolia, r as solanaDevnet, t as solanaMainnet } from '../chains-B2jQ-L0B.cjs';
|
|
6
8
|
|
|
7
9
|
interface LazyLoginCommonProps {
|
|
@@ -54,6 +56,11 @@ interface LazyWalletPanelProps {
|
|
|
54
56
|
onClose?: () => void;
|
|
55
57
|
/** Overrides for the outer card container. */
|
|
56
58
|
style?: CSSProperties;
|
|
59
|
+
/**
|
|
60
|
+
* Top up for a purchase the engine refused for a crypto shortfall: the panel shows only this
|
|
61
|
+
* currency and the missing amount, then calls `topUp.onDone(true)` (see `useWalletTopUp`).
|
|
62
|
+
*/
|
|
63
|
+
topUp?: WalletTopUpRequest;
|
|
57
64
|
}
|
|
58
65
|
/**
|
|
59
66
|
* "Sign in with wallet" for **EVM** titles that loads its machinery on demand.
|
|
@@ -79,4 +86,4 @@ declare function LazySolanaWalletLogin(props: LazySolanaWalletLoginProps): React
|
|
|
79
86
|
*/
|
|
80
87
|
declare function LazyWalletPanel(props: LazyWalletPanelProps): ReactNode;
|
|
81
88
|
|
|
82
|
-
export { LazySolanaWalletLogin, type LazySolanaWalletLoginProps, LazyWalletLogin, type LazyWalletLoginProps, LazyWalletPanel, type LazyWalletPanelProps };
|
|
89
|
+
export { LazySolanaWalletLogin, type LazySolanaWalletLoginProps, LazyWalletLogin, type LazyWalletLoginProps, LazyWalletPanel, type LazyWalletPanelProps, WalletTopUpRequest };
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { CSSProperties, ReactNode } from 'react';
|
|
2
2
|
import { Chain } from 'viem';
|
|
3
3
|
import { IDosGamesClient, PlayAccessStatus } from '@idosgames/core';
|
|
4
|
-
|
|
4
|
+
import { W as WalletTopUpRequest } from '../topUp-CCNQcHcH.js';
|
|
5
|
+
export { u as useWalletTopUp } from '../topUp-CCNQcHcH.js';
|
|
6
|
+
export { c as isEmbeddedInPlatform, d as isEmbeddedOnForeignSite, f as openPlatformWalletPanel } from '../platformWalletLogin-BxAoMCd9.js';
|
|
5
7
|
export { a as AppKitSolanaNetwork, h as arbitrum, i as base, k as bsc, l as chainById, m as idosChains, n as mainnet, o as optimism, p as polygon, q as polygonAmoy, s as sepolia, r as solanaDevnet, t as solanaMainnet } from '../chains-B2jQ-L0B.js';
|
|
6
8
|
|
|
7
9
|
interface LazyLoginCommonProps {
|
|
@@ -54,6 +56,11 @@ interface LazyWalletPanelProps {
|
|
|
54
56
|
onClose?: () => void;
|
|
55
57
|
/** Overrides for the outer card container. */
|
|
56
58
|
style?: CSSProperties;
|
|
59
|
+
/**
|
|
60
|
+
* Top up for a purchase the engine refused for a crypto shortfall: the panel shows only this
|
|
61
|
+
* currency and the missing amount, then calls `topUp.onDone(true)` (see `useWalletTopUp`).
|
|
62
|
+
*/
|
|
63
|
+
topUp?: WalletTopUpRequest;
|
|
57
64
|
}
|
|
58
65
|
/**
|
|
59
66
|
* "Sign in with wallet" for **EVM** titles that loads its machinery on demand.
|
|
@@ -79,4 +86,4 @@ declare function LazySolanaWalletLogin(props: LazySolanaWalletLoginProps): React
|
|
|
79
86
|
*/
|
|
80
87
|
declare function LazyWalletPanel(props: LazyWalletPanelProps): ReactNode;
|
|
81
88
|
|
|
82
|
-
export { LazySolanaWalletLogin, type LazySolanaWalletLoginProps, LazyWalletLogin, type LazyWalletLoginProps, LazyWalletPanel, type LazyWalletPanelProps };
|
|
89
|
+
export { LazySolanaWalletLogin, type LazySolanaWalletLoginProps, LazyWalletLogin, type LazyWalletLoginProps, LazyWalletPanel, type LazyWalletPanelProps, WalletTopUpRequest };
|
package/dist/react/lazyIndex.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {e,d,b}from'../chunk-
|
|
1
|
+
import {e as e$1,d,b}from'../chunk-B4KT5CVC.js';export{c as openPlatformWalletPanel}from'../chunk-B4KT5CVC.js';export{a as useWalletTopUp}from'../chunk-DOWG5IDM.js';import {g,c,h,e}from'../chunk-ZOWZE7MU.js';import {f,g as g$1}from'../chunk-K3THMWU2.js';export{o as arbitrum,n as base,l as bsc,t as chainById,s as idosChains,f as isEmbeddedInPlatform,g as isEmbeddedOnForeignSite,k as mainnet,p as optimism,m as polygon,r as polygonAmoy,q as sepolia,w as solanaDevnet,v as solanaMainnet}from'../chunk-K3THMWU2.js';import {useState,useEffect}from'react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';var A={padding:"11px 16px",borderRadius:"8px",border:"none",background:"#4c3fa8",color:"#fff",font:"inherit",fontWeight:600,cursor:"pointer"},N={display:"block",marginTop:"6px",color:"#ff9b9b",fontSize:"13px",textAlign:"center"};function z(e){switch(e){case b:return "Wallet sign-in is not available on this page.";case "NO_WALLET":case "CANCELLED":return "Connect a wallet on the page to sign in.";case "REJECTED":return "The signature was declined.";case "TIMEOUT":return "The wallet did not answer. Please try again.";default:return e}}function Z(e){let{client:t,networkID:o,onAuthenticated:u,onLinked:a,mode:l="login",family:s,disabled:y,label:g,style:d$1}=e,[n,i]=useState(false),[b,p]=useState(null);return jsxs(Fragment,{children:[jsx("button",{type:"button",onClick:()=>{i(true),p(null),(async()=>{if(l==="link"){let m=await e$1({client:t,networkID:o,family:s});if(m.ok){i(false),a?.(m.data.PlayAccess??null);return}p(z(m.error)),i(false);return}let c=await d({client:t,networkID:o,family:s});if(c.ok){u?.();return}p(z(c.error)),i(false);})();},disabled:y||n,style:{...A,...y||n?{opacity:.6,cursor:"default"}:null,...d$1},children:n?"Waiting for the wallet\u2026":g??(l==="link"?"Link wallet":"Sign in with wallet")}),b&&jsx("span",{role:"alert",style:N,children:b})]})}function T(e,t){return g$1()?null:jsx(Z,{...e,family:t})}function I(e){let{loading:t,disabled:o,label:u,style:a,error:l,onClick:s}=e;return jsxs(Fragment,{children:[jsx("button",{type:"button",onClick:s,disabled:o||t,style:{...A,...o||t?{opacity:.6,cursor:"default"}:null,...a},children:t?"Loading wallet\u2026":u??"Sign in with wallet"}),l&&jsx("span",{role:"alert",style:N,children:l})]})}function $(e){let{chains:t,walletConnectProjectId:o,appName:u,disabled:a,label:l,style:s,onAuthenticated:y,...g}=e,[d,n]=useState(null),[i,b]=useState(false),[p,L]=useState(null);if(f())return T(e,"evm");let c=()=>{b(true),L(null),(async()=>{try{let m=await import('./index.js'),D=m.createEvmWalletConfig({chains:t,walletConnectProjectId:o,appName:u});n({mod:m,config:D});}catch(m){console.error("[idosgames/wallet] failed to load the wallet module:",m),L("Could not load the wallet. Please try again.");}finally{b(false);}})();};if(d){let{WalletLogin:m}=d.mod;return jsx(m,{...g,onAuthenticated:y??R,wagmiConfig:d.config,disabled:a,label:l,style:s,autoStart:true})}return jsx(I,{loading:i,disabled:a,label:l??(e.mode==="link"?"Link wallet":void 0),style:s,error:p,onClick:c})}function R(){}function ee(e){let{walletConnectProjectId:t,appName:o,disabled:u,label:a,style:l,onAuthenticated:s,...y}=e,[g,d]=useState(null),[n,i]=useState(false),[b,p]=useState(null);if(f())return T(e,"solana");let L=()=>{i(true),p(null),(async()=>{try{let c=await import('./solanaIndex.js');t&&c.createSolanaWalletConfig({walletConnectProjectId:t,appName:o}),d(c);}catch(c){console.error("[idosgames/wallet] failed to load the wallet module:",c),p("Could not load the wallet. Please try again.");}finally{i(false);}})();};if(g){let{SolanaWalletLogin:c}=g;return jsx(c,{...y,onAuthenticated:s??R,disabled:u,label:a,style:l,autoStart:true})}return jsx(I,{loading:n,disabled:u,label:a??(e.mode==="link"?"Link wallet":void 0),style:l,error:b,onClick:L})}var te={...g,pointerEvents:"auto",padding:16,boxSizing:"border-box",display:"flex",alignItems:"center",justifyContent:"space-between",gap:10,fontSize:15};function le(e$1){let{client:t,onClose:o,style:u}=e$1,a=f(),[l,s]=useState(null),[y,g]=useState(null);return useEffect(()=>{if(a)return;let d=true;return (async()=>{try{let n=await t.blockchain.getDefinitions(),i=Object.values((n.ok?n.data.Blockchain?.Networks:null)??{}).map(L=>L.Type),p=i.includes("Solana")&&!i.includes("EVM")?{kind:"solana",mod:await import('./solanaIndex.js')}:{kind:"evm",mod:await import('./index.js')};d&&s(p);}catch(n){console.error("[idosgames/wallet] failed to load the wallet panel:",n),d&&g("Could not load the wallet.");}})(),()=>{d=false;}},[a,t]),a?null:l?.kind==="evm"?jsx(l.mod.WalletPanel,{...e$1}):l?.kind==="solana"?jsx(l.mod.SolanaWalletPanel,{...e$1}):jsxs("div",{style:{...te,...o?{...c,width:360,maxWidth:"100%"}:{},...u},children:[y??h("loading"),o&&jsx("button",{type:"button",className:"idos-press",onClick:o,"aria-label":"\u2715",style:{...e("red",false,"sm"),width:36,minHeight:36,padding:0,borderRadius:"50%"},children:"\u2715"})]})}export{ee as LazySolanaWalletLogin,$ as LazyWalletLogin,le as LazyWalletPanel};
|