keyring-chatbot-agent 1.0.25 → 1.0.26

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.
@@ -27,37 +27,36 @@ return function(n){function r(e){var n;return function(e,n){if(!(e instanceof n)
27
27
  /* @__PURE__ */k.jsx("div",{className:`mc-heading mc-h${e}`,children:dm(n)},`h-${r}`)),r++;continue}if(e.trimStart().startsWith("> ")){const e=[];for(;r<n.length&&n[r].trimStart().startsWith("> ");)e.push(n[r].replace(/^\s*>\s?/,"")),r++;t.push(
28
28
  /* @__PURE__ */k.jsx("div",{className:"mc-blockquote",children:e.map((e,n)=>/* @__PURE__ */k.jsx("div",{children:dm(e)},n))},`bq-${r}`));continue}""!==e?.trim()?(t.push(
29
29
  /* @__PURE__ */k.jsx("div",{className:"mc-line",children:dm(e)},`line-${r}`)),r++):(t.push(/* @__PURE__ */k.jsx("div",{className:"mc-empty-line"},`empty-${r}`)),r++)}/* @__PURE__ */
30
- return k.jsx("div",{className:"message-content",children:t})},pm=({isOpen:e,onClose:n,onTransaction:t,position:r="bottom-right",modalChatStyle:o={},chatTitle:i,welcomeMessage:a,customSuggestions:s,additionalSuggestions:u,chatIcon:l})=>{const{t:c,ti:f}=G(),{messages:d,addMessage:h,updateMessageAction:p,updateMessageActionParameters:m,updateMessageText:y,clearMessages:v,clearMessagesById:b,updateMessageType:w}=function({customWelcomeMessage:e}={}){const{account:n}=Qd(),{t:t}=G(),r=(o=n?.address,i=n?.chainId,o&&i?`${o}_${i}`:"");var o,i;const a=j.useMemo(()=>rh(e||t("welcomeMessage")),[t,e]),[s,u]=j.useState(()=>r||"pending"),[l,c]=j.useState(()=>{const n=ih();return r?n&&n.owner===r?n.messages:rh(e||t("welcomeMessage")):n?.messages??rh(e||t("welcomeMessage"))});if("pending"===s&&r){const e=ih();e&&e.owner===r?c(e.messages):ah(r,l),u(r)}else"pending"!==s&&r&&s!==r&&(c(a),ah(r,a),u(r));const f=j.useMemo(()=>l.map(n=>n.id===th?{...n,text:e||t("welcomeMessage")}:n),[l,t,e]);j.useEffect(()=>{"pending"!==s&&ah(s,l)},[l,s]),j.useEffect(()=>{const e=[];for(let n=0;n<Gd.length;n++){const t=Gd.key(n);t&&t.startsWith($d+"_")&&e.push(t)}e.forEach(e=>Gd.removeItem(e))},[]);const d=j.useCallback(()=>{c(a),ah(r,a)},[r,a]),h=j.useCallback(e=>{c(n=>{const t=n.filter(n=>!e.includes(n.id));return t.length>eh?t.slice(t.length-eh):t})},[]);return{messages:f,setMessages:c,addMessage:(e,n,t,r,o,i="web3")=>{const a=t?l.find(e=>e.id===t):void 0,s={id:nh(),text:e,sender:n,timestamp:/* @__PURE__ */new Date,typeChat:i,...a&&{replyTo:{id:a.id,text:a.text,sender:a.sender}},...r&&{buttons:r},...o&&{actionData:o}};return c(e=>{const n=[...e,s];return n.length>eh?n.slice(n.length-eh):n}),s},updateMessageAction:(e,n)=>{c(t=>t.map(t=>t.id===e&&t.actionData?{...t,actionData:{...t.actionData,status:n}}:t))},updateMessageActionParameters:(e,n)=>{c(t=>t.map(t=>t.id===e&&t.actionData?{...t,actionData:{...t.actionData,parameters:{...t.actionData.parameters,...n}}}:t))},updateMessageText:(e,n)=>{c(t=>t.map(t=>t.id===e?{...t,text:n}:t))},getMessageById:e=>l.find(n=>n.id===e),clearMessages:d,clearMessagesById:h,updateMessageType:(e,n)=>{c(t=>t.map(t=>t.id===e?{...t,typeChat:n}:t))}}}({customWelcomeMessage:a}),[g,A]=j.useState(""),[E,T]=j.useState(!1),[S,x]=j.useState(!0),[C,I]=j.useState(null),[M,O]=j.useState({}),R=j.useRef(null),N=j.useRef(null),B=j.useRef(null),P=j.useRef(null),L=j.useRef(!1),F=j.useRef(S),{modal:D}=Jd();j.useEffect(()=>{F.current=S},[S]);const{account:U,chainData:H,chainType:q,chainTypeMoralis:V,chainId:W,isChainSupported:z}=Qd(),{config:Y}=(()=>{const e=j.useContext(sh);if(!e)throw new Error("useConfig must be used within ConfigProvider");return e})(),J=W&&Y?.rpcUrls?.[W]||void 0,K=j.useCallback(()=>{v(),A(""),I(null),T(!1),x(!0)},[v]);j.useEffect(()=>(Hh(K),()=>{Hh(null)}),[K]);const X=j.useCallback(e=>{I(e),Dh.isDesktop&&B.current?.focus()},[]),{getDataBuyToken:Q,updateDataBuyToken:Z}=function(){const e=j.useCallback(()=>{const e=Gd.getItem(jh);if(e)try{return JSON.parse(e)}catch{return{...qh}}return{...qh}},[]),n=j.useCallback(e=>{Gd.setItem(jh,JSON.stringify(e))},[]),t=j.useCallback(t=>{const r=e();n({...r,...t})},[e,n]);return{getDataBuyToken:e,setDataBuyToken:n,updateDataBuyToken:t}}(),{showTrendingTokens:_,showMyNFTs:$,showMyBalances:ee}=function(e){const{addMessage:n,setIsTyping:t,chainData:r,chainType:o,account:i,chainTypeMoralis:a,t:s,ti:u}=e;return{showTrendingTokens:j.useCallback(async()=>{try{t(!0);const e=r?.tokenTrendingDefault||[],[i,a]=await Promise.allSettled([Wh.getTopGainers(o,"24h",5),Wh.getTokensDetails(e,o)]);let l=[];"fulfilled"===i.status&&i.value?.data&&(l=[...i.value.data]),"fulfilled"===a.status&&a.value?.data&&(l=[...a.value.data,...l]),l=l.filter((e,n,t)=>n===t.findIndex(n=>n.address.toLowerCase()===e.address.toLowerCase()));const c=l.map(e=>({id:e?.symbol,text:e?.symbol,value:u("buttonBuyToken",{name:e.name,symbol:e?.symbol||""}),action:"click_buy_item_token_button",extraData:{tokenAddress:e?.address||"",symbol:e?.symbol||"",decimals:e?.decimals||18}}));await qd(1e3),t(!1),n(u("trendingTokensHeader",{chain:r?.name||"Unknown"}),"bot");const f=l.map((e,n)=>`${n+1}. ${e.name} (${e?.auditGoplus?.token_symbol||e.symbol||"Unknown"})\n$${Mh(e?.price||0).decimalPlaces(4).toFormat()} (${e.price_change_percentage_24h||e.priceChange}%)\n\n---\n`).join("\n");n(`${f}${s("trendingTokensQuestion")}`,"bot",void 0,c)}catch(e){n(s("trendingTokensError"),"bot")}finally{t(!1)}},[n,t,r,o,s,u]),showMyNFTs:j.useCallback(async()=>{try{const{getDataPackage:e}=await Promise.resolve().then(()=>Kd),r=e()?.linkViewNft;n(r?u("viewNftViaWebsiteWithLink",{link:r}):s("viewNftViaWebsite"),"bot"),t(!1)}catch(e){t(!1),n(s("nftFetchError"),"bot")}},[n,t,s,u]),showMyBalances:j.useCallback(async()=>{try{t(!0);const e=await Xh({address:i?.address||"",chain:a});if(e?.success&&e?.data?.result&&e.data.result.length>0){const o=e.data.result.map((e,n)=>{const t=void 0!==e.usd_value?` ≈ $${Mh(e.usd_value).decimalPlaces(2).toFormat()}`:"";return`${n+1}. **${e.name}** (${e.symbol})\n Balance: ${e.balance_formatted}${t}`}).join("\n\n");await qd(500),t(!1),n(u("viewBalancesHeader",{chain:r?.name||"this chain",list:o}),"bot")}else t(!1),n(s("viewBalancesEmpty"),"bot")}catch(e){t(!1),n(s("viewBalancesFetchError"),"bot")}},[i?.address,a,n,t,r?.name,s,u])}}({addMessage:h,setIsTyping:T,chainData:H,chainType:q,account:U,chainTypeMoralis:V,t:c,ti:f}),{onClickItemTokenToBuy:ne,onClickItemUserBalanceToBuy:te,showPreviewToBuy:re}=function(e){const{getDataBuyToken:n,updateDataBuyToken:t,addMessage:r,setIsTyping:o,account:i,chainData:a,chainTypeMoralis:s,chainId:u,rpcUrl:l,t:c,ti:f}=e;return{onClickItemTokenToBuy:j.useCallback(async(e,n)=>{t({descTokenAddress:e,descTokenDecimals:n||18});try{o(!0);const e=await Xh({address:i?.address||"",chain:s});if(e?.success&&e?.data?.result){const n=e.data.result;if(n?.length>0){const e=n.map(e=>({id:e.token_address,text:`${e.name}: ${e.balance_formatted} ${e.symbol} ($${Mh(e.usd_value||0).decimalPlaces(2).toFormat()||"0"})`,value:f("buttonBuyWith",{symbol:e.symbol}),action:"click_balance_item_user_to_buy_button",fullWidth:!0,extraData:{tokenAddress:e.token_address,symbol:e.symbol,balance:e.balance_formatted,usdValue:e.usd_value,decimals:e.decimals}}));r(f("walletBalanceSpendable",{chain:a?.name||"unknown"}),"bot",void 0,e)}else r(f("walletNoTokensFound",{chain:a?.name||"unknown"}),"bot")}else r(c("walletFetchFailed"),"bot")}catch(u){r(c("walletFetchError"),"bot")}finally{o(!1)}},[t,i?.address,s,r,o,a?.name,c,f]),onClickItemUserBalanceToBuy:j.useCallback(async(e,n,o,i)=>{t({srcTokenAddress:e,srcTokenDecimals:i||18});let a=o||"0";if(e===Zo)try{const e=await pp({chainId:u,rpcUrl:l});if(e.isGreaterThan(0)){const n=e.times(1e6),t=new Mh(Qo(o,i||18).toString()).minus(n);a=t.isGreaterThan(0)?Mh(lt(BigInt(t.toFixed(0)),18)).toFixed():"0"}}catch(c){}const s=[25,50,75,100].map(t=>({id:`percent-${t}`,text:`${t}%`,value:f("buttonUsePercent",{percent:String(t),symbol:n}),action:"select_percent",extraData:{percent:t,tokenAddress:e,tokenSymbol:n,tokenDecimals:i||18,tokenBalance:a}}));Mh(a).isZero()?r(f("insufficientFeeToken",{symbol:n}),"bot"):r(f("selectAmountOf",{symbol:n,balance:a}),"bot",void 0,s)},[r,u,l,t,f]),showPreviewToBuy:j.useCallback(async(e,o,s,d)=>{const h={amount:Mh(o).times(e).dividedBy(100).toFixed()};void 0!==s&&(h.srcTokenAddress=s),void 0!==d&&(h.srcTokenDecimals=d),t(h);const p=n(),m=Qo(p.amount,p.srcTokenDecimals||18).toString(),y=await np({chainId:u,tokenIn:p.srcTokenAddress,tokenInAmount:m,tokenOut:p.descTokenAddress,tokenOutRecipient:i?.address||"",slippage:"auto",accesstoken:"d6c45897b8f6"});if(y.success&&y.data){const e=y.data,n=e.tokenIn,t=e.tokenOut,o=Mh(lt(BigInt(n.amount||0),n.decimals)).decimalPlaces(8).toFormat(),s=Mh(lt(BigInt(t.amount||0),t.decimals)).decimalPlaces(8).toFormat();let d=!1;if(p.srcTokenAddress!==Zo&&""!==p.srcTokenAddress&&i?.address&&e.tx?.to)try{const n=await cp({tokenAddress:p.srcTokenAddress,ownerAddress:i.address,spenderAddress:e.tx.to,chainId:u,rpcUrl:l});d=Mh(n.toString()).isLessThan(m)}catch(v){d=!0}const h=e.estimatedTransactionFee?.total?Mh(e.estimatedTransactionFee.total):Mh(0);let b=Mh(0);if(d&&i?.address)try{const n=fp({tokenAddress:p.srcTokenAddress,spenderAddress:e.tx?.to||"",fromAddress:i.address,chainId:u,amount:m});b=await hp({from:i.address,to:n.to,data:n.data,chainId:u,rpcUrl:l})}catch(v){}const w=h.plus(b),g=a?.nativeCurrency?.symbol||"native";let k="",A=!1;if(i?.address&&w.isGreaterThan(0))try{const e=await dp({address:i.address,chainId:u,rpcUrl:l});if(e.isLessThan(w)){A=!0;const n=Mh(lt(BigInt(e.toFixed(0)),18)).decimalPlaces(8).toFormat(),t=Mh(lt(BigInt(w.toFixed(0)),18)).decimalPlaces(8).toFormat();k=f("swapFeeWarning",{symbol:g,balance:n,needed:t})}}catch(v){}const E=`From: ${o} ${n.symbol}\n⬇️\nTo: ${s} ${t.symbol}\n\n`+k+"\n";if(A)r(E,"bot");else if(d){const t=[{id:"approve-for-swap",text:f("swapApproveButton",{symbol:n.symbol}),value:f("swapApproveValue",{symbol:n.symbol}),action:"approve_for_swap",fullWidth:!0,extraData:{tokenAddress:p.srcTokenAddress,spenderAddress:e.tx.to,tokenSymbol:n.symbol,amountInWei:m,tx:e.tx}}];r(E+f("swapNeedApprove",{symbol:n.symbol}),"bot",void 0,t)}else{const n=[{id:"confirm-swap",text:c("swapConfirmButton"),value:c("swapConfirmValue"),action:"confirm_swap",extraData:{tx:e.tx}}];r(E+c("swapReadyToProceed"),"bot",void 0,n)}}else r(f("swapEstimationError",{error:y.errorMessage||y.error||"Unknown error"}),"bot")},[n,t,r,u,i?.address,a?.nativeCurrency?.symbol,l,c,f])}}({getDataBuyToken:Q,updateDataBuyToken:Z,addMessage:h,setIsTyping:T,account:U,chainData:H,chainTypeMoralis:V,chainId:W,rpcUrl:J,t:c,ti:f}),{handleSendMessage:oe}=function(e){const{inputValue:n,setInputValue:t,isTyping:r,setIsTyping:o,replyingTo:i,setReplyingTo:a,setShowSuggestions:s,inputRef:u,messages:l,addMessage:c,updateMessageType:f,account:d,chainData:h,chainType:p,chainTypeMoralis:m,chainId:y,isChainSupported:v,rpcUrl:b,t:w,ti:g,updateDataBuyToken:k,showTrendingTokens:A,showMyNFTs:E,showMyBalances:T,onClickItemTokenToBuy:S,onClickItemUserBalanceToBuy:x,showPreviewToBuy:C}=e;return{handleSendMessage:j.useCallback(async e=>{const I=e??n?.trim();if(!I||r)return;const M=i,O=c(I,"user",i?.id);t(""),a(null),o(!0),s(!1);try{const e=l.slice(-10);let n="",t="";if(e.length>0){n="\n\n## CONVERSATION HISTORY:\n";for(const t of e)"user"===t.sender?n+=`User: ${t.text}\n`:n+=`Assistant: ${t.text}\n`;n+="\n---\n"}let r,i,a=I;M&&(a=`[Replying to ${"user"===M.sender?"my previous":"your"} message: "${M.text}"]\n\n${a}`);try{const r=await kp.checkInfoQuestion(I,n);if(r.language&&(t=r.language),"faq"===r.model&&r.faqAnswer)return o(!1),void c(r.faqAnswer,"bot",O.id);if("pool"===r.model&&v)try{const n=await im({question:I,language:t||"en",currentChain:m||p||void 0,walletAddress:d?.address||void 0,chatHistory:e.map(e=>({role:"user"===e.sender?"user":"assistant",content:e.text})),signal:void 0});if(n){if(o(!1),"send_position"===n.parsed.intent){const e=n.parsed.poolId;if(!e)return void c(w("sendPositionNoId"),"bot",O.id);if(!d?.address)return void c(w("walletNotConnected"),"bot",O.id);try{o(!0);const t=await _h({address:d.address,chain:m,limit:100,exclude_spam:!1});if(t?.success&&t?.data?.result){const r=t.data.result.find(n=>n.token_id===e);if(r){const t=r.normalized_metadata?.name||r.name||`LP Position #${e}`,o=r.normalized_metadata?.image||r.media?.original_media_url||"",i={contract_address:r.token_address,token_id:r.token_id,to_address:n.parsed.toAddress||"",token_standard:r.contract_type||"ERC721",amount:"1",maxAmount:r.amount||"1",nft_name:t};c(g("nftSendReview",{name:t,standard:r.contract_type||"ERC721",tokenId:r.token_id}),"bot",O.id,void 0,{action:"send_nft",parameters:i,status:"pending",nftInfo:{name:t,image:o||void 0,tokenId:r.token_id,contractAddress:r.token_address,tokenStandard:r.contract_type||"ERC721"}})}else c(g("sendPositionNotFound",{id:e,chain:h?.name||m||p||"this chain"}),"bot",O.id)}else c(w("nftNoCollection"),"bot",O.id)}catch(R){c(w("sendPositionFetchError"),"bot",O.id)}finally{o(!1)}return}return void c(n.response,"bot",O.id)}}catch(N){}if("general"===r.model){f(O.id,"normal");const e=l.filter(e=>"normal"===e.typeChat);let n="";if(e.slice(-10).length>0){n="\n\n## CONVERSATION HISTORY:\n";for(const t of e.slice(-10))"user"===t.sender?n+=`User: ${t.text}\n`:n+=`Assistant: ${t.text}\n\n`}const r=await kp.generateContent(a,n,t),i=fm(r);return o(!1),void c(i?.message||r,"bot",void 0,void 0,void 0,"normal")}}catch(B){}if(d?.address&&v)try{const[e,n]=await Promise.allSettled([Xh({address:d.address,chain:m}),_h({address:d.address,chain:m,limit:100,exclude_spam:!0})]);"fulfilled"===e.status&&e.value?.success&&e.value?.data?.result&&(r=e.value.data.result.map(e=>({symbol:e.symbol,name:e.name,balance_formatted:e.balance_formatted,usd_value:e.usd_value,native_token:e.native_token,token_address:e.token_address,price:e.usd_price}))),"fulfilled"===n.status&&n.value?.success&&n.value?.data?.result&&(i=n.value.data.result.map(e=>({name:e.normalized_metadata?.name||e.name||`#${e.token_id}`,token_address:e.token_address,token_id:e.token_id,contract_type:e.contract_type||"",amount:e.amount||"1"})))}catch{}const s=function(e){const{walletAddress:n,chainName:t,chainId:r,nativeSymbol:o,walletTokens:i,walletNfts:a,language:s}=e;if(!n)return`You are a Web3 wallet assistant for the crypto EVM wallet app.\nThe user is currently NOT connected to any wallet.\n\n## YOUR ROLE:\n- You are a friendly, knowledgeable assistant that can talk about ANY topic naturally\n- You can freely answer general questions, discuss crypto tokens, prices, market info, provide token details, etc. — these do NOT require a wallet connection\n- ONLY ask the user to connect their wallet when their request explicitly requires their personal wallet/address, such as:\n - Sending tokens or NFTs\n - Swapping tokens\n - Approving token spending\n - Wrapping/unwrapping tokens\n - Checking THEIR OWN balance ("what is MY balance?", "how much ETH do I have?")\n - Viewing THEIR OWN NFT collection\n - Any action that reads or writes to THEIR wallet address\n- For all other requests (token info, prices, general crypto questions, market data, etc.), respond normally and helpfully\n- ${lm(s)}\n- **LANGUAGE DETECTION — CRYPTO TICKERS**: Crypto token symbols and tickers (ETH, BTC, USDC, BNB, MATIC, SOL, etc.) are NOT language indicators. They are proper nouns used in ALL languages. Detect the language from the surrounding non-ticker text only. Example: "ETHの現在の価格は?" → Japanese (the surrounding text は Japanese characters). "ETH의 가격은?" → Korean. "Giá ETH là bao nhiêu?" → Vietnamese. NEVER treat a ticker symbol as evidence of English.\n\n## RESPONSE FORMAT:\nAlways respond with a valid JSON object:\n{"action":"chat","message":"<your friendly response to the user>", "suggested_actions":[{"label":"<short button text>","prompt":"<message sent when clicked>"}]}\n\n## RULES:\n- suggested_actions: include when your message offers the user interactive choices or asks a follow-up question. NEVER include suggested_actions that ask the user to connect their wallet (e.g., "Connect wallet", "Connect now", etc.) — the app handles wallet connection separately\n- **CRITICAL**: NEVER include any "Buy" actions (e.g., "Buy USDC", "Buy ETH", "Purchase token", etc.) in suggested_actions. The app handles Buy buttons separately. Only include non-buy actions in suggested_actions (e.g., "Send token", "Swap token", "Check balance", "Show my NFTs").\n- For wallet-required actions, politely explain the user needs to connect their wallet first, and put this in the "message" field\n- ALWAYS respond with raw JSON only, never wrap in \`\`\`json code blocks\n- ${lm(s)}`;if(n&&!li[r]?.isSupported)return`You are a Web3 wallet assistant for the crypto EVM wallet app.\n The user's wallet address is: ${n}\n The user is selected on (chainId: ${r}) an UNSUPPORTED chain.\n\n ## YOUR ROLE:\n - You are a friendly, knowledgeable assistant that can talk about ANY topic naturally\n - You can freely answer general questions, discuss crypto tokens, prices, market info, token details, etc. — these do NOT require a supported chain\n - **BLOCKED on unsupported chain** — if the user asks for any of the following, politely inform them that chain (chainId: ${r}) is not currently supported and the action cannot be performed:\n - Checking THEIR OWN balance ("what is my balance?", "how much ETH do I have?")\n - Sending tokens or NFTs\n - Swapping or buying tokens\n - Approving token spending\n - Wrapping/unwrapping tokens\n - Viewing or transferring their NFT collection\n - Any action that reads or writes to their wallet on the current chain\n - **ALLOWED on unsupported chain** — respond normally and helpfully for:\n - General questions (weather, coding, history, math, etc.)\n - Token information, prices, market data, token details\n - Any query that does NOT require interacting with the user's wallet on the current chain\n - ${lm(s)}\n - **LANGUAGE DETECTION — CRYPTO TICKERS**: Crypto token symbols and tickers (ETH, BTC, USDC, BNB, MATIC, SOL, etc.) are NOT language indicators. They are proper nouns used in ALL languages. Detect the language from the surrounding non-ticker text only. Example: "ETHの現在の価格は?" → Japanese. "ETH의 가격은?" → Korean. "Giá ETH là bao nhiêu?" → Vietnamese. NEVER treat a ticker symbol as evidence of English.\n\n ## RESPONSE FORMAT:\n Always respond with a valid JSON object:\n {"action":"chat","message":"<your response>", suggested_actions:[{"label":"<short button text>","prompt":"<message sent when clicked>"}]}\n\n ## RULES:\n - suggested_actions: include when your message offers the user interactive choices or asks a follow-up question. NEVER include suggested_actions that ask the user to connect their wallet (e.g., "Connect wallet", "Connect now", etc.) — the app handles wallet connection separately\n - **CRITICAL**: NEVER include any "Buy" actions (e.g., "Buy USDC", "Buy ETH", "Purchase token", etc.) in suggested_actions. The app handles Buy buttons separately. Only include non-buy actions in suggested_actions (e.g., "Send token", "Swap token", "Check balance", "Show my NFTs").\n - **CRITICAL**: ABSOLUTELY NEVER include any option that suggests switching, changing, or selecting a different chain (e.g., "Switch to Ethereum", "Change chain", "Switch network", "Chuyển sang chain khác", "Đổi mạng") — the app handles chain switching separately.\n - For wallet-required actions, politely explain the user needs to connect their wallet first, and put this in the "message" field\n - ALWAYS respond with raw JSON only, never wrap in \`\`\`json code blocks\n - ${lm(s)}`;const u=i&&i.length>0?`\n## USER'S CURRENT WALLET BALANCE:\n${i.map(e=>{const n=void 0!==e.usd_value?` (~$${e.usd_value.toFixed(2)})`:"";return`- ${e.name} (${e.symbol})(Price: ${e.price||"N/A"}): ${e.balance_formatted}${n}${e.native_token?" [native]":` [${e.token_address}]`}`}).join("\n")}\nUse this balance data to accurately answer balance questions and to pre-fill token parameters in actions (contract_address, decimals, symbol). NEVER ask the user to provide token info that is already available above.\n`:"",l=a&&a.length>0?`\n## USER'S NFT COLLECTION:\n${a.map(e=>{const n="ERC1155"===e.contract_type?` (x${e.amount})`:"";return`- ${e.name}${n} | ${e.contract_type} | contract: ${e.token_address} | tokenId: ${e.token_id}`}).join("\n")}\nWhen the user wants to send an NFT by name, use this data to fill contract_address, token_id, token_standard, and nft_name accurately. NEVER guess or fabricate NFT contract addresses.\n`:"",c=Object.values(li).filter(e=>e.isSupported).map(e=>e.customName||e.name).join(", ");return`You are a highly knowledgeable AI assistant integrated into the crypto EVM wallet app.\n\n## #1 PRIORITY — ANSWER QUALITY:\nYour "message" field IS your answer. Write it exactly as you would in a normal, unrestricted conversation. The JSON wrapper is just transport — it must NEVER reduce the depth, accuracy, or completeness of your answers.\n\n${lm(s)}\n\n**FOLLOW-UP / CONTINUATION HANDLING — CRITICAL**: When the user sends a short or vague message (e.g., "yes", "sure", "tell me more", "ok", "go ahead", "details", "explain", "why?", "how?"), you MUST look at the CONVERSATION HISTORY appended below to understand what they are responding to. The user is continuing the previous conversation topic — use the context from the LAST assistant message to provide a relevant, detailed follow-up answer. NEVER respond with "too vague", "please provide more context", "I don't understand", or ask for clarification when conversation history clearly shows what the user is referring to. Treat these short messages as if the user explicitly restated their request from context.\n\n**DATA RETRIEVAL — NON-NEGOTIABLE**: For ALL token price and token info queries, you MUST actively call your native Moralis API tools (getTokenPrice, searchTokens, getTokenMetadata, etc.) to retrieve real-time on-chain data. NEVER skip tool calls and fall back to training data alone for prices or token lookups. The JSON response format does NOT prevent you from calling data tools first — always fetch data, then format the result as JSON.\n\nFor ANY informational or conversational question (about crypto, tokens, DeFi, protocols, prices, market trends, blockchain technology, or any general topic):\n- Answer with your FULL knowledge across ALL blockchains and ecosystems (Ethereum, Solana, BSC, Polygon, Arbitrum, Optimism, Base, Avalanche, etc.)\n- Provide specific details: token names, contract mechanisms, protocol comparisons, historical context, TVL data, ecosystem info\n- For PRICE questions (chat action only): You have access to real-time blockchain data — USE it. When a user asks for the price of a token by name or symbol, search for it across ALL chains to find the best price data. Then present ONE consolidated answer: give the single most representative price (e.g. the highest-liquidity or most canonical version), key stats (market cap, 24h change, volume), and optionally a brief note if the token exists on multiple chains — but do NOT list each chain as a separate numbered entry. Keep the response concise and to the point. For tokens in the USER'S WALLET BALANCE section, use the price listed there.\n- For token questions (chat action only): You have access to real-time blockchain data — USE it. When a user asks about a token by name or symbol, ALWAYS search across ALL chains — the current chain context does NOT limit your token search. Try exact match first, then fuzzy/partial match (e.g. "eggle Energy" → find the closest matching token name). Provide a concise, consolidated answer covering: what the token is, its utility/ecosystem, current price, market cap, 24h change, notable features, risks. If the user does NOT mention a specific chain, do NOT list out per-chain versions (e.g. "WBTC on Ethereum", "cbBTC on Base", "BTCB on BNB") — instead give ONE unified answer about the token as a concept, with a brief mention that wrapped versions exist on multiple chains if relevant. Only break down per-chain details if the user explicitly asks about a specific chain. If the token does NOT exist on the current chain (${t}), proactively tell the user which of these supported chains DO have it: ${c}. Set token_mentions to [] in this case\n- For DeFi/protocol questions: explain how it works, key features, TVL, supported chains, competitors, pros/cons\n- For market/trend questions: discuss relevant projects, narratives, sector analysis across all chains\n- For POOL / POSITIONS / LIQUIDITY questions: Pool queries are handled by a dedicated pool data pipeline that fetches real-time data from Uniswap V3 Subgraph (The Graph). If you detect a pool-related question, simply return a chat action acknowledging the query — the system will automatically intercept and handle it with accurate on-chain pool data including TVL, volume, APR, fee tiers, and pool addresses.\n- Write detailed paragraphs, use bullet points, include numbers and facts. Minimum 3-5 sentences for simple questions, more for complex topics\n\n## CONTEXT:\nWallet: ${n} | Chain: ${t} (chainId: ${r}) | Native: ${o}${u}${l}\n\n## WHEN TO USE WHICH ACTION:\n- "send_native": user wants to send the native token (${o}) to an address\n- "send_token": user wants to send an ERC20 token to an address\n- "swap_token": user wants to swap/exchange/convert/trade/sell one token for another — covers ALL of the following keywords and patterns, even if only ONE token or NO amount is mentioned:\n - swap: "swap X", "swap X to Y", "swap X for Y", "swap to ETH", "swap native"\n - exchange: "exchange X", "exchange X to Y", "exchange X for Y", "exchange native", "exchange ETH"\n - convert: "convert X to Y", "convert native", "convert ETH to USDC", "convert X"\n - trade: "trade X for Y", "trade X to Y", "trade X"\n - sell (for another token): "sell X for Y", "sell ETH for USDC"\n - Vietnamese: "đổi X sang Y", "đổi X", "đổi native", "đổi ETH sang USDC", "chuyển đổi X", "bán X lấy Y", "hoán đổi X"\n - **CRITICAL**: When the source is the native token (ETH, BNB, MATIC, etc.) → token_in: "native". This MUST be treated as swap_token, never chat.\n → ALWAYS return swap_token. Leave missing params as "". NEVER fall back to chat.\n- "buy_token": user wants to buy a specific token AND the user clearly names a token (symbol or contract address). If user also specifies which token to pay with (e.g. "buy PEPE with USDC", "mua PEPE bằng ETH", "buy PEPE using my USDC"), fill pay_with_symbol and pay_with_address from USER'S WALLET BALANCE. **CRITICAL**: ALWAYS return buy_token if the user clearly names a token they want to buy — even if you cannot find the contract address or token data. Leave contract_address as "" and the app will search for it. NEVER fall back to "chat" just because you lack token data.\n- "buy_token_trending": user wants to buy a token BUT does NOT specify which token — covers ALL of the following patterns:\n - User asks to buy trending tokens: "buy trending tokens", "buy trending", "mua token trending", "mua token đang trending"\n - User asks to buy tokens with strong growth/momentum: "buy tokens pumping", "buy hot tokens", "buy movers", "mua token tăng mạnh", "mua token đang tăng", "mua token tiềm năng"\n - User says "buy a token" / "I want to buy" / "mua token" with NO specific token name or address provided\n - User asks for token recommendations to buy without specifying one\n → ALWAYS return buy_token_trending. Leave all params as "". NEVER fall back to chat or buy_token.\n- "approve_token": user wants to approve a token for a spender\n- "wrap_native": user wants to wrap native token (e.g. ETH → WETH) — also triggered by "deposit" into WETH/wrapped token\n- "unwrap_native": user wants to unwrap (e.g. WETH → ETH) — also triggered by "withdraw" from WETH/wrapped token\n- "send_nft": user wants to send/transfer an NFT\n- "view_nfts": user wants to see/browse their NFT collection\n- "view_balances": user wants to see ALL their token balances/tokens at once — covers ALL of the following patterns (NOT for single token price/info):\n - "show my balance", "view my balance", "check my balance", "what's my balance"\n - "what's in my wallet", "what do I have", "what tokens do I have"\n - "view all tokens", "show all tokens", "list my tokens"\n - "my portfolio", "show portfolio", "wallet overview"\n - Vietnamese: "xem số dư", "số dư của tôi", "kiểm tra số dư", "ví tôi có gì", "tôi có bao nhiêu tiền", "xem ví", "danh mục của tôi"\n → ALWAYS return view_balances for these. Do NOT return chat.\n- "chat": EVERYTHING ELSE — questions, token info, prices, greetings, DeFi explanations, market data, etc.\n\nAll wallet actions (send, swap, buy, approve, wrap, unwrap, send_nft) are chain-specific: use chainId ${r} only.\nFor "chat" action: no chain restriction — use cross-chain knowledge freely.\n\n## OUTPUT FORMAT:\n${lm(s)}\n**LANGUAGE DETECTION — CRYPTO TICKERS**: Crypto token symbols/tickers (ETH, BTC, USDC, BNB, SOL, etc.) are NOT language indicators — they are proper nouns used universally. Detect language ONLY from the surrounding non-ticker text. Examples: "ETHの現在の価格は?" → Japanese. "ETH의 가격은?" → Korean. "Giá ETH?" → Vietnamese. NEVER classify a message as English just because it contains a ticker symbol.\n\nWallet action: {"action":"<type>","message":"<explanation>","parameters":{...}}\nChat/info: {"action":"chat","message":"<YOUR FULL DETAILED ANSWER>","parameters":{},"token_mentions":[],"suggested_actions":[]}\n\n## WALLET ACTION RULES:\n- Return action type IMMEDIATELY even if params are missing (leave as ""). Ask for missing info in "message". NEVER fall back to "chat" just because parameters are incomplete — always return the intended action.\n- **CROSS-CHAIN REQUESTS**: All wallet actions (send, swap, buy, approve, wrap, unwrap, send_nft, view_nfts, view_balances) execute ONLY on the CURRENT chain: ${t} (chainId: ${r}). If the user's message explicitly targets a DIFFERENT chain (e.g. "send on Ethereum", "swap on BSC", "transfer on Polygon", "buy on base") and the current chain is NOT that chain, do NOT execute the wallet action. Instead, return action: "chat" and politely notify the user to switch to the requested chain in the app first. This rule applies to ALL non-chat actions.\n- For ERC20 actions: provide correct contract_address on chainId ${r}. **CRITICAL — CHAIN-SPECIFIC ADDRESSES**: Contract addresses differ on every chain. You MUST obtain the address via your Moralis API tools (searchTokens, getTokenMetadata) for chainId ${r}, OR use the address already present in USER'S WALLET BALANCE. NEVER fill in a contract_address from training knowledge alone — leave it as "" if you cannot verify it via API or wallet balance. If token doesn't exist on this chain, inform user.\n- send_native: ONLY for ${o}. If user says "send ETH" but native ≠ ETH, use send_token.\n- Amount: "max"/"all" → "max". "X%" → "50%". USD formats → always prefix with "$": "5 dollar" → "$5", "5$" → "$5", "$5" → "$5", "5usd" → "$5", "5 đô la" → "$5", "0.01$ eth" → "$0.01", "$0.01 eth" → "$0.01", "5$ usdc" → "$5". The "$" MUST appear in the amount field (not stripped) so the app knows it's a USD value. Otherwise exact number string.\n- Decimals & symbol: always accurate.\n- send_nft: contract_address optional — use nft_name if NFT known by name.\n\n## suggested_actions & token_mentions:\n- suggested_actions: include when offering choices. {"label":"<2-6 words>","prompt":"<message>"}. Max 4. Never include "Buy" (app handles separately). **ABSOLUTELY NEVER** include any option that suggests switching, changing, or selecting a different chain (e.g., "Switch to Ethereum", "Change chain", "Switch network", "Chuyển sang chain khác", "Đổi mạng") — the app handles chain switching separately.\n- token_mentions: ONLY include when the token EXISTS on the CURRENT chain (chainId ${r}) AND you have obtained a VERIFIED contract address via your Moralis API tools (searchTokens, getTokenMetadata, getTokenPrice) for this exact chain.\n - **CRITICAL — CONTRACT ADDRESSES ARE CHAIN-SPECIFIC**: The same token has a DIFFERENT contract address on every chain. USDC on Ethereum ≠ USDC on Base ≠ USDC on Polygon ≠ USDC on BNB Chain. NEVER use an address from your training knowledge — training-data addresses are frequently wrong, hallucinated, or belong to a different chain.\n - **REQUIRED WORKFLOW**: Before populating token_mentions for a token, you MUST call your Moralis API tool (searchTokens or getTokenMetadata) specifying chainId ${r} to retrieve the verified contract address. If the API call fails or returns no result for this chain, set token_mentions: [].\n - If the token address is already available in the USER'S WALLET BALANCE section above, you MAY use that address (it is already verified for chainId ${r}).\n - If you cannot confirm the address via API or wallet balance, set token_mentions: [] — never guess.\n - **Native token**: If the token IS the chain's native token (${o}), use contract_address: "native" — do NOT look up an address.\n - Format: {"symbol":"","contract_address":"<API-verified address on chainId ${r}, or 'native' for the native token>","decimals":<n>}. 2+ tokens → [], use suggested_actions. Non-crypto → [].\n\n## ACTION PARAMS REFERENCE:\nValid actions: send_native, send_token, swap_token, buy_token, buy_token_trending, approve_token, wrap_native, unwrap_native, send_nft, view_nfts, view_balances, chat. NEVER use any other action name.\n\n1. send_native: {"to_address":"","amount":""}\n2. send_token: {"contract_address":"(REQ)","token_symbol":"","to_address":"","amount":"","decimals":""}\n3. swap_token: {"token_in":"<addr or 'native'>","token_in_symbol":"","token_in_decimals":"","token_out":"<addr>","token_out_symbol":"","token_out_decimals":"","amount":""}\n No tokens specified → all params "". Native → token_in:"native".\n4. buy_token: {"token_symbol":"(REQ — always fill this)","contract_address":"(if known and verified, else leave '')","decimals":"","buy_amount":"(opt — amount of the TOKEN BEING BOUGHT that user wants to RECEIVE. Use this when the amount refers to the destination token.)","pay_with_symbol":"(opt — symbol of token user wants to pay with, e.g. 'USDC', 'ETH')","pay_with_address":"(opt — contract address of payment token from WALLET BALANCE, or 'native' for native token)","pay_with_decimals":"(opt — decimals of payment token)","pay_with_amount":"(opt — amount of the PAYMENT TOKEN (token in) user wants to SPEND. Use this when the amount refers to the payment/source token.)"}.\n **CRITICAL — AMOUNT DISAMBIGUATION:**\n The amount in a buy request belongs to EITHER the token being bought OR the payment token. Parse the grammar carefully:\n - "buy PEPE with 10 USDC" → amount=10 belongs to USDC (payment) → pay_with_amount:"10", buy_amount:""\n - "buy 0.02 PCM with USDC" → amount=0.02 belongs to PCM (bought) → buy_amount:"0.02", pay_with_amount:""\n - "dùng 10 USDC mua PEPE" → amount=10 belongs to USDC (payment) → pay_with_amount:"10", buy_amount:""\n - "mua 0.02 PCM bằng USDC" → amount=0.02 belongs to PCM (bought) → buy_amount:"0.02", pay_with_amount:""\n NEVER put the amount of the token being bought into pay_with_amount. NEVER put the payment amount into buy_amount.\n If pay token is native (${o}), set pay_with_address:"native". Both tokens specified as a trade/exchange → swap_token. If you cannot verify the address, set contract_address:'' but ALWAYS return buy_token with the symbol filled. **NATIVE TOKEN**: If the token to buy IS the chain's native token (${o}), set contract_address: "native" directly — no API lookup needed.\n5. buy_token_trending: {} — no parameters needed; app handles discovery of trending/high-growth tokens. **message**: write ONLY a short 1-sentence header (e.g. "Here are the trending tokens on [chain] right now!"). Do NOT write analysis, tips, or explanations.\n6. approve_token: {"contract_address":"(REQ)","token_symbol":"","spender_address":"","amount":"","decimals":""}\n7. wrap_native: {"amount":""}\n8. unwrap_native: {"amount":""}\n9. send_nft: {"contract_address":"(opt)","token_id":"","to_address":"","token_standard":"","amount":"(def 1)","nft_name":""}\n10. view_nfts: {}\n11. view_balances: {} — use ONLY when user wants to see all balances/tokens, NOT for single token price/info queries\n12. chat: {} + token_mentions + suggested_actions — use for ALL informational/conversational requests\n\n## EXAMPLES:\nThese examples show INTENT → ACTION + PARAMETERS mapping only. The "message" content is for illustration — compose your own natural, helpful response based on context.\n\n// --- SEND NATIVE ---\n// Intent: user wants to send the chain's native token to an address\n// Triggers: "send ETH/BNB/MATIC to...", "transfer [native] to...", "chuyển [native] cho..."\n→ action: send_native | parameters: {to_address, amount}\n\n// --- SEND TOKEN ---\n// Intent: user wants to send an ERC20 token to an address\n// Triggers: "send USDC to...", "transfer [token] to...", "gửi [token] cho..."\n→ action: send_token | parameters: {contract_address, token_symbol, to_address, amount, decimals}\n\n// --- SWAP ---\n// Intent: exchange one token for another — trigger with ANY conversion/exchange/trade/sell keyword,\n// even with just ONE token mentioned, no amount, or only the native token as source\n// EN triggers: "swap X", "swap X to Y", "swap X for Y", "swap to ETH", "swap native"\n// "exchange X", "exchange X to Y", "exchange X for Y", "exchange native", "exchange ETH"\n// "convert X to Y", "convert native to USDC", "convert ETH", "convert X"\n// "trade X for Y", "trade X to Y", "trade ETH"\n// "sell X for Y", "sell ETH for USDC" (selling one token FOR another = swap)\n// VI triggers: "đổi X sang Y", "đổi X", "đổi native", "đổi ETH", "chuyển đổi X", "bán X lấy Y", "hoán đổi X"\n// Native source: token_in = "native" (e.g. "exchange ETH" → token_in:"native", token_in_symbol:"ETH")\n// Native dest: token_out = zeroAddress\n// ⚠️ NEVER confuse with wrap/unwrap: those are specifically ETH↔WETH. All other pairs = swap_token.\n→ action: swap_token | parameters: {token_in, token_in_symbol, token_in_decimals, token_out, token_out_symbol, token_out_decimals, amount}\n// Missing params → leave as "", ask for them in message. NEVER downgrade to chat.\n\n// --- WRAP / UNWRAP ---\n// Intent wrap: convert native to wrapped version — also triggered by "deposit"\n// Triggers: "wrap ETH", "deposit ETH", "deposit ETH to WETH", "đổi ETH sang WETH"\n→ action: wrap_native | parameters: {amount}\n\n// Intent unwrap: convert wrapped token back to native — also triggered by "withdraw"\n// Triggers: "unwrap WETH", "withdraw WETH", "convert WETH to ETH", "rút WETH"\n→ action: unwrap_native | parameters: {amount}\n\n// --- VIEW NFTs ---\n// Intent: user wants to see/browse their NFT collection\n// Triggers: "show my NFTs", "what NFTs do I have", "view my NFTs", "xem NFT của tôi"\n→ action: view_nfts | parameters: {}\n\n// --- VIEW BALANCES ---\n// Intent: user wants to see ALL their token balances at once (not a single token query)\n// EN triggers: "show my balance", "view my balance", "check my balance", "what's my balance"\n// "what's in my wallet", "what do I have", "what tokens do I have"\n// "view all tokens", "show all tokens", "list my tokens"\n// "my portfolio", "show portfolio", "wallet overview"\n// VI triggers: "xem số dư", "số dư của tôi", "kiểm tra số dư", "ví tôi có gì"\n// "tôi có bao nhiêu tiền", "xem ví", "danh mục của tôi"\n// ⚠️ Do NOT use view_balances for single-token queries ("price of ETH", "how much USDC is worth") → use chat instead\n→ action: view_balances | parameters: {}\n\n// --- BUY TOKEN TRENDING ---\n// Intent: user wants to buy but does NOT specify a token — or explicitly asks for trending/pumping/high-growth tokens to buy\n// EN triggers: "buy trending tokens", "buy trending", "buy hot tokens", "buy tokens pumping", "buy movers", "I want to buy a token", "buy a token"\n// VI triggers: "mua token trending", "mua token đang trending", "mua token tăng mạnh", "mua token đang tăng", "mua token tiềm năng", "mua token", "tôi muốn mua token"\n// ⚠️ CRITICAL: If user says "buy X" where X is a named token → use buy_token, NOT buy_token_trending\n// ⚠️ CRITICAL: If user gives NO specific token → ALWAYS use buy_token_trending, never chat\n// ⚠️ MESSAGE: ONLY a short 1-sentence header introducing the trending list. NO analysis, NO tips, NO explanations.\n→ action: buy_token_trending | parameters: {} | message: short header only (e.g. "Here are the trending tokens on [chain]!")\n\n// --- BUY TOKEN WITH SPECIFIC PAYMENT ---\n// Intent: user wants to buy a specific token AND specifies which token to pay with\n// EN triggers: "buy PEPE with USDC", "buy PEPE using ETH", "buy PEPE with 10 USDC", "purchase DOGE with my 0.5 ETH"\n// VI triggers: "mua PEPE bằng USDC", "mua PEPE dùng ETH", "mua PEPE bằng 10 USDC", "mua DOGE bằng 0.5 ETH của tôi"\n// → action: buy_token | parameters: {token_symbol, contract_address, decimals, pay_with_symbol, pay_with_address, pay_with_decimals, pay_with_amount}\n// AMOUNT DISAMBIGUATION (critical):\n// "buy PEPE with 10 USDC" → pay_with_amount:"10" buy_amount:"" (10 USDC to spend)\n// "buy 0.02 PCM with USDC" → buy_amount:"0.02" pay_with_amount:"" (0.02 PCM to receive)\n// "mua PEPE bằng 0.5 ETH" → pay_with_amount:"0.5" buy_amount:"" (0.5 ETH to spend)\n// "mua 0.02 PCM bằng USDC" → buy_amount:"0.02" pay_with_amount:"" (0.02 PCM to receive)\n// pay_with_* fields are filled from USER'S WALLET BALANCE. If pay token = native → pay_with_address: "native"\n// ⚠️ This is still buy_token (NOT swap_token) — the user's intent is to BUY, with a specified payment method\n\n// --- TOKEN INFO / PRICE (chat) ---\n// Intent: learn about a token, its price, market data — NOT a wallet action\n// Triggers: "tell me about X", "what is X token", "price of X", "X coin info", "X là gì"\n→ action: chat | compose a detailed answer using real-time data from your tools\n// If token EXISTS on current chain → token_mentions: [{symbol, contract_address, decimals}]\n// If token NOT on current chain → token_mentions: [] but tell user which supported chains have it\n\n// --- CROSS-CHAIN / GENERAL INFO (chat) ---\n// Intent: any question not requiring a wallet action — crypto trends, DeFi, protocols, general Q&A\n// Triggers: "what's trending on X?", "explain DeFi", "how does Uniswap work", anything conversational\n→ action: chat | compose a full, knowledgeable answer; add relevant suggested_actions if helpful\n\n// --- GREETING (chat) ---\n// Intent: greeting or open-ended start\n// Triggers: "hello", "hi", "hey", "xin chào", "bắt đầu"\n→ action: chat | introduce yourself and offer helpful options via suggested_actions`}({walletAddress:d?.address||void 0,chainName:h?.name||void 0,chainId:y||void 0,nativeSymbol:h?.nativeCurrency?.symbol||void 0,walletTokens:r,walletNfts:i,language:t}),u=await Zh({prompt:a,model:"gpt-4.1-mini",stream:!1,systemPrompt:s+n});if(!u.success||!u.data)return void c(w("errorProcessingRequest"),"bot",O.id);const P=u.data.text||"",L=fm(P);L&&L.action&&"chat"!==L.action?await async function(e,n,t){switch(e.action){case"buy_token":await async function(e,n){const t=e.parameters?.token_symbol||"";let r=e.parameters?.contract_address||"",o=18,i=!1;if("native"!==r.toLowerCase()&&r!==Zo||(r=Zo),!r&&t&&h?.nativeCurrency?.symbol&&t.toUpperCase()===h.nativeCurrency.symbol.toUpperCase()&&(r=Zo),r&&r!==Zo)try{const e=await Wh.getTokensDetails([r],p),n=e?.data?.[0];n&&(t&&n.symbol?.toUpperCase()!==t.toUpperCase()?r="":o=n.decimals||18)}catch(R){}if(!r&&t&&d?.address)try{const e=await Xh({address:d.address,chain:m});if(e?.success&&e?.data?.result){const n=e.data.result,i=n.find(e=>e.token_address.toLowerCase()===r.toLowerCase())||n.find(e=>e.symbol.toUpperCase()===t.toUpperCase());i&&(r=i.token_address,o=i.decimals)}if(!r){const e=h?.tokenTrendingDefault||[],[n,i]=await Promise.allSettled([Wh.getTopGainers(p,"24h",10),Wh.getTokensDetails(e,p)]),a=[];"fulfilled"===n.status&&n.value?.data&&a.push(...n.value.data),"fulfilled"===i.status&&i.value?.data&&a.push(...i.value.data);const s=a.find(e=>e.address?.toLowerCase()===r.toLowerCase())||a.find(e=>e.symbol?.toUpperCase()===t.toUpperCase());s&&(r=s.address,o=s.decimals||18)}if(!r&&y)try{const e=await Wh.searchTokensByKey(t,y);if(Array.isArray(e?.data)&&e.data.length>0){const n=e.data.find(e=>e.symbol?.toUpperCase()===t.toUpperCase())||e.data[0];n?.address&&(i=!0,r=n.address,o=n.decimals||18)}}catch(a){}}catch(R){}if(r){c(i?g("buyingOnChain",{symbol:t,chain:h?.name||""}):e.message||g("buyTokenHelp",{symbol:t}),"bot",n),k({descTokenAddress:r,descTokenDecimals:o||18});const a=e.parameters?.pay_with_symbol||"",u=e.parameters?.pay_with_address||"";let l=!1;if(a||u)try{const n=await Xh({address:d?.address||"",chain:m});if(n?.success&&n?.data?.result){const t=n.data.result;let o;if(o="native"===u.toLowerCase()||u===Zo||!u&&a&&h?.nativeCurrency?.symbol&&a.toUpperCase()===h.nativeCurrency.symbol.toUpperCase()?t.find(e=>e.token_address===Zo||e.native_token):t.find(e=>u&&e.token_address.toLowerCase()===u.toLowerCase())||t.find(e=>a&&e.symbol.toUpperCase()===a.toUpperCase()),o){l=!0;const t=e.parameters?.pay_with_amount||"",i=e.parameters?.buy_amount||"";if(t)k({srcTokenAddress:o.token_address,srcTokenDecimals:o.decimals}),await C(100,t,o.token_address,o.decimals);else if(i){let e="";try{const t=n.data.result.find(e=>e.token_address.toLowerCase()===r.toLowerCase());let a=t?.usd_price??null;if(null==a&&r){const e=await Qh({address:r,chain:m});e.success&&null!=e.data?.usd_price&&(a=e.data.usd_price)}const s=o.usd_price??null;null!=a&&null!=s&&s>0&&(e=(parseFloat(i)*a/s).toFixed(8).replace(/\.?0+$/,""))}catch(s){}e?(k({srcTokenAddress:o.token_address,srcTokenDecimals:o.decimals}),await C(100,e,o.token_address,o.decimals)):await x(o.token_address,o.symbol,o.balance_formatted,o.decimals)}else await x(o.token_address,o.symbol,o.balance_formatted,o.decimals)}}}catch(R){}l||await S(r,o)}else c(g("tokenNotFoundOnChain",{symbol:t}),"bot",n),await A()}(e,t);break;case"buy_token_trending":await A();break;case"swap_token":await async function(e,n){const t={...e.parameters||{}},r="native"===t.token_in||t.token_in_symbol?.toUpperCase()===h?.nativeCurrency?.symbol?.toUpperCase(),i="native"===t.token_out||t.token_out_symbol?.toUpperCase()===h?.nativeCurrency?.symbol?.toUpperCase();i&&(t.token_out=Zo);let a=[];if(d?.address)try{const e=await Xh({address:d.address,chain:m});e?.success&&e?.data?.result&&(a=e.data.result)}catch(R){}if(!r&&(t.token_in||t.token_in_symbol)&&a.length>0){const e=t.token_in?a.find(e=>e.token_address.toLowerCase()===t.token_in.toLowerCase()):a.find(e=>e.symbol.toUpperCase()===t.token_in_symbol.toUpperCase());e&&(t.token_in=e.token_address,t.token_in_decimals=String(e.decimals))}if(!i&&(t.token_out||t.token_out_symbol)&&a.length>0){const e=t.token_out?a.find(e=>e.token_address.toLowerCase()===t.token_out.toLowerCase()):a.find(e=>e.symbol.toUpperCase()===t.token_out_symbol.toUpperCase());e&&(t.token_out=e.token_address,t.token_out_decimals=String(e.decimals))}const s=!(!t.token_in&&!r),u=!!t.token_out,l=!!t.amount;if(s&&a.length>0)if(r){const e=a.find(e=>e.native_token);if(!e||Mh(e.balance_formatted||"0").isZero())return c(g("formInsufficientBalance",{balance:"0",symbol:h?.nativeCurrency?.symbol||"native"}),"bot",n),void o(!1)}else if(t.token_in){const e=a.find(e=>e.token_address.toLowerCase()===t.token_in.toLowerCase());if(!e)return c(g("swapTokenNotInWallet",{symbol:t.token_in_symbol||t.token_in}),"bot",n),void o(!1);if(Mh(e.balance_formatted||"0").isZero())return c(g("formInsufficientBalance",{balance:"0",symbol:e.symbol}),"bot",n),void o(!1)}if(s&&u&&l)await async function(e,n,t){try{const r=[];e.token_out&&r.push(e.token_out),e.token_in&&!n&&r.push(e.token_in);let i=18,a=18;if(r.length>0)try{const t=await Wh.getTokensDetails(r,p);if(t?.data)for(const r of t.data)n||r.address.toLowerCase()!==e.token_in?.toLowerCase()||(i=r.decimals||18),r.address.toLowerCase()===e.token_out?.toLowerCase()&&(a=r.decimals||18)}catch{}if(d?.address&&t.length>0)if(n){const n=t.find(e=>e.native_token);let r=n?.balance_formatted||"0";try{const e=await pp({chainId:y,rpcUrl:b});if(e.isGreaterThan(0)){const t=e.times(1e6),o=new Mh(n?.balance||"0").minus(t);r=o.isGreaterThan(0)?Mh(lt(BigInt(o.toFixed(0)),n?.decimals||18)).toFixed():"0"}}catch{}if(e.amount=cm(e.amount,r,n?.usd_price),Mh(r).lte(0))return c(g("formInsufficientBalance",{balance:Mh(r).decimalPlaces(8).toFixed(),symbol:h?.nativeCurrency?.symbol||"native"}),"bot"),void o(!1);if(Mh(r).lt(e.amount))return c(g("swapInsufficientNativeBalance",{balance:Mh(r).decimalPlaces(8).toFixed(),symbol:h?.nativeCurrency?.symbol||"native",amount:e.amount}),"bot"),void o(!1)}else{const n=t.find(n=>n.token_address.toLowerCase()===e.token_in?.toLowerCase());if(!n)return c(g("swapTokenNotInWallet",{symbol:e.token_in_symbol||e.token_in}),"bot"),void o(!1);if(e.amount=cm(e.amount,n.balance_formatted||"0",n.usd_price),Mh(n.balance_formatted||"0").lt(e.amount))return c(g("swapInsufficientTokenBalance",{balance:Mh(n.balance_formatted||"0").decimalPlaces(8).toFixed(),symbol:n.symbol,amount:e.amount}),"bot"),void o(!1)}const s=n?Zo:e.token_in;k({srcTokenAddress:s,descTokenAddress:e.token_out,amount:e.amount,srcTokenDecimals:i,descTokenDecimals:a}),await C(100,e.amount,s,i)}catch(r){c(w("swapEstimationFailed"),"bot")}}(t,r,a);else if(s&&u&&!l)await async function(e,n,t,r){let i=n?18:parseInt(e.token_in_decimals||"18",10),a=parseInt(e.token_out_decimals||"18",10);const s=[];if(e.token_out&&s.push(e.token_out),e.token_in&&!n&&s.push(e.token_in),s.length>0)try{const t=await Wh.getTokensDetails(s,p);if(t?.data)for(const r of t.data)n||r.address.toLowerCase()!==e.token_in?.toLowerCase()||(i=r.decimals||i),r.address.toLowerCase()===e.token_out?.toLowerCase()&&(a=r.decimals||a)}catch{}if(k({descTokenAddress:e.token_out,descTokenDecimals:a}),n)if(t.length>0){const e=t.find(e=>e.native_token),n=h?.nativeCurrency?.symbol||"ETH";let o=e?.balance_formatted||"0";try{const n=await pp({chainId:y,rpcUrl:b});if(n.isGreaterThan(0)){const t=new Mh(e?.balance||"0").minus(n.times(1e6));o=t.isGreaterThan(0)?Mh(lt(BigInt(t.toFixed(0)),e?.decimals||18)).toFixed():"0"}}catch{}k({srcTokenAddress:Zo,srcTokenDecimals:i});const a=[25,50,75,100].map(e=>({id:`percent-${e}`,text:`${e}%`,value:g("buttonUsePercent",{percent:String(e),symbol:n}),action:"select_percent",extraData:{percent:e,tokenAddress:Zo,tokenSymbol:n,tokenDecimals:i,tokenBalance:o}}));c(g("selectAmountToSwap",{symbol:n,balance:o}),"bot",r,a)}else c(w("couldNotFetchBalance"),"bot");else{const n=e.token_in_symbol||"Token";if(k({srcTokenAddress:e.token_in,srcTokenDecimals:i}),t.length>0){const i=t.find(n=>n.token_address.toLowerCase()===e.token_in?.toLowerCase());if(!i)return c(g("swapTokenNotInWallet",{symbol:n}),"bot"),void o(!1);const a=[25,50,75,100].map(e=>({id:`percent-${e}`,text:`${e}%`,value:g("buttonUsePercent",{percent:String(e),symbol:i.symbol}),action:"select_percent",extraData:{percent:e,tokenAddress:i.token_address,tokenSymbol:i.symbol,tokenDecimals:i.decimals||18,tokenBalance:i.balance_formatted}}));c(g("selectAmountToSwap",{symbol:i.symbol,balance:`${i.balance_formatted} (~$${i.usd_value?.toFixed(2)||"0"})`}),"bot",r,a)}else c(w("couldNotFetchBalance"),"bot")}}(t,r,a,n);else if(!s&&u){c(e.message||w("swapChooseFrom"),"bot",n);let r=parseInt(t.token_out_decimals||"18",10);if(t.token_out)try{const e=await Wh.getTokensDetails([t.token_out],p);e?.data?.[0]&&(r=e.data[0].decimals||r)}catch{}l&&k({descTokenAddress:t.token_out,descTokenDecimals:r,amount:t.amount}),await S(t.token_out,r)}else s&&!u?await async function(e,n,t,r,i,a){let s=n?18:parseInt(e.token_in_decimals||"18",10);if(e.token_in&&!n)try{const n=await Wh.getTokensDetails([e.token_in],p);n?.data?.[0]&&(s=n.data[0].decimals||s)}catch{}if(k(n?{srcTokenAddress:Zo,srcTokenDecimals:18,...r?{amount:e.amount}:{}}:{srcTokenAddress:e.token_in,srcTokenDecimals:s,...r?{amount:e.amount}:{}}),r&&t.length>0)if(n){const n=t.find(e=>e.native_token),r=cm(e.amount,n?.balance_formatted||"0",n?.usd_price);if(Mh(n?.balance_formatted||"0").lt(r))return c(g("swapInsufficientNativeBalance",{balance:Mh(n?.balance_formatted||"0").decimalPlaces(8).toFixed(),symbol:h?.nativeCurrency?.symbol||"native",amount:r}),"bot",i),void o(!1);e.amount=r,k({amount:r})}else if(e.token_in){const n=t.find(n=>n.token_address.toLowerCase()===e.token_in.toLowerCase());if(n){const t=cm(e.amount,n.balance_formatted||"0",n.usd_price);if(Mh(n.balance_formatted||"0").lt(t))return c(g("swapInsufficientTokenBalance",{balance:Mh(n.balance_formatted||"0").decimalPlaces(8).toFixed(),symbol:n.symbol,amount:t}),"bot",i),void o(!1);e.amount=t,k({amount:t})}}c(a||g("swapChooseTo",{symbol:e.token_in_symbol||"your token"}),"bot",i);try{o(!0);const e=h?.tokenTrendingDefault||[],[n,t]=await Promise.allSettled([Wh.getTopGainers(p,"24h",5),Wh.getTokensDetails(e,p)]);let r=[];"fulfilled"===n.status&&n.value?.data&&(r=[...n.value.data]),"fulfilled"===t.status&&t.value?.data&&(r=[...t.value.data,...r]),r=r.filter((e,n,t)=>n===t.findIndex(n=>n.address.toLowerCase()===e.address.toLowerCase()));const i=r.map(e=>({id:e?.symbol,text:e?.symbol,value:g("buttonSwapTo",{name:e.name,symbol:e?.symbol||""}),action:"click_swap_dest_token",extraData:{tokenAddress:e?.address||"",symbol:e?.symbol||"",decimals:e?.decimals||18}}));c(g("trendingTokensForReceive",{chain:h?.name||"Unknown"}),"bot",void 0,i)}catch(R){c(w("couldNotLoadTokenList"),"bot")}finally{o(!1)}}(t,r,a,l,n,e.message):await async function(e,n,t,r){if(n&&k({amount:e.amount}),c(r||w("swapChooseToken"),"bot",t),d?.address)try{o(!0);const e=await Xh({address:d.address,chain:m});if(e?.success&&e?.data?.result&&e.data.result.length>0){const n=e.data.result.map(e=>({id:`swap-select-${e.token_address}`,text:`${e.name}: ${e.balance_formatted} ${e.symbol} ($${Mh(e?.usd_value||0).decimalPlaces(2).toFixed()||"0"})`,value:`Swap ${e.symbol}`,action:"suggested_action",fullWidth:!0}));await qd(500),o(!1),c(g("walletBalanceSpendable",{chain:h?.name||"this chain"}),"bot",void 0,n)}else o(!1),c(g("walletNoTokensFound",{chain:h?.name||"this chain"}),"bot")}catch(R){o(!1),c(w("walletFetchError"),"bot")}}(t,l,n,e.message)}(e,t);break;case"view_balances":await T();break;case"view_nfts":await E();break;default:await async function(e,n,t){const{isTransactionAction:r}=await Promise.resolve().then(()=>mp),{getNftContractMetadata:i}=await Promise.resolve().then(()=>$h),a=e.action;if("send_token"===a&&!e.parameters?.contract_address&&!e.parameters?.token_symbol&&d?.address){try{const e=await Xh({address:d.address,chain:m});if(e?.success&&e?.data?.result&&e.data.result.length>0){c(w("sendTokenChoose"),"bot",t),o(!0),await qd(500);const n=e.data.result.map(e=>({id:`send-select-${e.token_address}`,text:`${e.name}: ${e.balance_formatted} ${e.symbol} ($${Mh(e?.usd_value||0).decimalPlaces(2).toFixed()||"0"})`,value:g("buttonSendToken",{symbol:e.symbol}),action:"suggested_action",fullWidth:!0}));await qd(500),o(!1),c(g("walletBalanceSpendable",{chain:h?.name||"this chain"}),"bot",void 0,n)}else o(!1),c(g("walletNoTokensFound",{chain:h?.name||"this chain"}),"bot")}catch(R){o(!1),c(w("walletFetchError"),"bot")}return}if("send_nft"===a&&!e.parameters?.contract_address&&!e.parameters?.token_id&&!e.parameters?.nft_name&&d?.address){const{getDataPackage:e}=await Promise.resolve().then(()=>Kd),n=e()?.linkViewNft;return void c(n?g("sendNftViaWebsiteWithLink",{link:n}):w("sendNftViaWebsite"),"bot")}if("send_nft"===a&&!jn(e.parameters?.contract_address||"")&&(e.parameters?.nft_name||e.parameters?.token_id)&&d?.address){try{o(!0);const n=await _h({address:d.address,chain:m,limit:100,exclude_spam:!1});if(n?.success&&n?.data?.result){const r=n.data.result,i=(e.parameters?.nft_name||"").toLowerCase(),a=e.parameters?.token_id||"",s=e=>{const n=(e.normalized_metadata?.name||e.name||"").toLowerCase(),t=(e.name||"").toLowerCase(),r=i&&(n.includes(i)||t.includes(i)),o=a&&e.token_id===a;return i&&a?r&&o:i?r:o},u=!i&&!!a,l=u?r.filter(s):[],f=u?1===l.length?l[0]:null:r.find(s);if(u&&l.length>1){const n=l.map(n=>{const t=n.normalized_metadata?.name||n.name||`#${n.token_id}`,r=n.normalized_metadata?.image||n.media?.original_media_url||"";return{id:`${n.token_address}-${n.token_id}`,text:`${t} (${n.symbol||n.contract_type}) #${n.token_id}`,value:g("buttonSendNft",{name:t}),action:"select_nft_to_send",fullWidth:!0,extraData:{contractAddress:n.token_address,tokenId:n.token_id,tokenStandard:n.contract_type,name:t,symbol:n.symbol,amount:n.amount,image:r,toAddress:e.parameters?.to_address||""}}}),r=l.map((e,n)=>{const t=e.normalized_metadata?.name||e.name||`#${e.token_id}`,r=e.normalized_metadata?.image||e.media?.original_media_url||"";return`${n+1}. ${r?`![${t}](${r})\n`:"🖼️ "}**${t}**\n ${e.symbol||e.contract_type} | Token ID: ${e.token_id}`}).join("\n\n");o(!1),c(g("nftMultipleMatchesForTokenId",{count:String(l.length),tokenId:a})+"\n\n"+r,"bot",t,n)}else if(f){const n=f.normalized_metadata?.name||f.name||`#${f.token_id}`,r=f.normalized_metadata?.image||f.media?.original_media_url||"",o={contract_address:f.token_address,token_id:f.token_id,to_address:e.parameters?.to_address||"",token_standard:f.contract_type||"",amount:e.parameters?.amount||"1",maxAmount:f.amount||"1",nft_name:n};c(e.message||g("nftSendReview",{name:n,standard:f.contract_type||"NFT",tokenId:f.token_id}),"bot",t,void 0,{action:"send_nft",parameters:o,status:"pending",nftInfo:{name:n,image:r||void 0,tokenId:f.token_id,contractAddress:f.token_address,tokenStandard:f.contract_type||void 0}})}else c(g("nftNotFoundInWallet",{name:i||a}),"bot",t)}else c(w("nftNoCollection"),"bot",t)}catch(R){c(w("nftFetchError"),"bot",t)}finally{o(!1)}return}const s=r(a);let u,l,f={...e.parameters||{}};const p=["send_token","approve_token"].includes(a)&&(f.contract_address||f.token_symbol),v="send_native"===a||"wrap_native"===a,k="unwrap_native"===a,A="send_nft"===a&&f.contract_address;if(p&&d?.address)try{const e=await Xh({address:d.address,chain:m});if(e?.success&&e?.data?.result){const n=e.data.result,t=f.contract_address?n.find(e=>e.token_address.toLowerCase()===f.contract_address.toLowerCase()):n.find(e=>e.symbol.toUpperCase()===f.token_symbol.toUpperCase());t&&(f={...f,contract_address:t.token_address,decimals:String(t.decimals)},u={symbol:t.symbol,name:t.name,balance:t.balance,balanceFormatted:t.balance_formatted,usdValue:t.usd_value,usdPrice:t.usd_price,decimals:t.decimals,logo:t.logo||t.thumbnail,contractAddress:t.token_address})}}catch(R){}if(p&&!u&&"send_token"===a){const e=f.token_symbol||f.contract_address||"this token";return c(g("sendTokenNotInWallet",{symbol:e}),"bot",t),void o(!1)}if(p&&!u&&f.contract_address)try{const e=await Qh({address:f.contract_address,chain:m});e?.success&&e?.data&&(u={symbol:e.data.symbol,name:e.data.name,balance:"0",balanceFormatted:"0",usdPrice:e.data.usd_price,decimals:e.data.decimals,logo:e.data.logo,contractAddress:f.contract_address},f={...f,decimals:String(e.data.decimals)})}catch(R){}if(v&&d?.address)try{const e=await Xh({address:d.address,chain:m});if(e?.success&&e?.data?.result){const n=e.data.result.find(e=>e.native_token);if(n){let e=n.balance_formatted,t=n.balance;try{const{estimateTransactionFee:r}=await Promise.resolve().then(()=>mp),o=new Mh(n.balance),i="0x"+BigInt(o.toFixed(0)).toString(16),a=await r({from:d.address,to:d.address,data:"0x",value:i,chainId:y,rpcUrl:b});if(a.isGreaterThan(0)){const r=o.minus(a);r.isGreaterThan(0)?(t=r.toFixed(0),e=Mh(lt(BigInt(r.toFixed(0)),n.decimals)).toFixed()):(t="0",e="0")}}catch{}u={symbol:n.symbol,name:n.name,balance:t,balanceFormatted:e,usdValue:n.usd_value,usdPrice:n.usd_price,decimals:n.decimals,logo:n.logo||n.thumbnail,contractAddress:Zo}}else{const e=await Qh({address:Zo,chain:m});e?.success&&e?.data&&(u={symbol:e.data.symbol,name:e.data.name,balance:"0",balanceFormatted:"0",usdValue:0,usdPrice:e.data.usd_price,decimals:e.data.decimals,logo:e.data.logo,contractAddress:Zo})}}}catch(R){}if(k&&d?.address)try{const e=await Xh({address:d.address,chain:m});if(e?.success&&e?.data?.result){const n=e.data.result,t=`W${h?.nativeCurrency?.symbol||"ETH"}`,r=n.find(e=>e.symbol.toUpperCase()===t.toUpperCase());r&&(u={symbol:r.symbol,name:r.name,balance:r.balance,balanceFormatted:r.balance_formatted,usdValue:r.usd_value,usdPrice:r.usd_price,decimals:r.decimals,logo:r.logo||r.thumbnail,contractAddress:r.token_address})}}catch(R){}if(A){try{const e=await i({address:f.contract_address,chain:m});e?.success&&e?.data&&(e.data.contract_type&&(f={...f,token_standard:e.data.contract_type}),!f.nft_name&&e.data.name&&(f={...f,nft_name:e.data.name}))}catch(R){}if(d?.address)try{const e=await _h({address:d.address,chain:m,limit:100,exclude_spam:!1});if(e?.success&&e?.data?.result){const n=e.data.result.find(e=>e.token_address.toLowerCase()===f.contract_address.toLowerCase()&&e.token_id===f.token_id);if(!n){const e=f.nft_name||`#${f.token_id||f.contract_address}`;return c(g("nftNotFoundInWallet",{name:e}),"bot",t),void o(!1)}{f={...f,amount:f.amount||"1",maxAmount:n.amount||"1"};const e=n.normalized_metadata?.image||n.media?.original_media_url||"";l={name:n.normalized_metadata?.name||n.name||f.nft_name||`#${n.token_id}`,image:e||void 0,tokenId:n.token_id,contractAddress:n.token_address,tokenStandard:n.contract_type||f.token_standard||void 0}}}}catch(R){}}f.amount&&u?.balanceFormatted&&("send_token"===a||"send_native"===a||"wrap_native"===a||"unwrap_native"===a)&&(f.amount=cm(f.amount,u.balanceFormatted,u.usdPrice)),s?c(e.message||"Please review and complete the form below.","bot",t,void 0,{action:e.action,parameters:f,status:"pending",tokenInfo:u,nftInfo:l}):c(e.message||n,"bot",t)}(e,n,t)}}(L,P,O.id):L&&"chat"===L.action?await async function(e,n,t,r){const o=e.token_mentions||[],i=e.suggested_actions||[],a=[];o.length>0&&(await Promise.all(o.map(async e=>{let n=e.contract_address||"",t=e.decimals||18;if("native"===n.toLowerCase()&&(n=Zo),n===Zo){const n=r?.find(e=>e.native_token);return n?{symbol:e.symbol||n.symbol,contract_address:Zo,decimals:18}:e.symbol?{symbol:e.symbol,contract_address:Zo,decimals:18}:null}if(n&&n!==Zo){const o=r?.find(t=>t.token_address.toLowerCase()===n.toLowerCase()&&t.symbol.toUpperCase()===e.symbol.toUpperCase());if(o){try{const e=await Wh.getTokensDetails([n],p);t=e?.data?.[0]?.decimals??t}catch{}return{symbol:e.symbol,contract_address:n,decimals:t}}try{const r=await Wh.getTokensDetails([n],p),o=r?.data?.[0];if(o&&o.symbol?.toUpperCase()===e.symbol.toUpperCase())return{symbol:e.symbol,contract_address:n,decimals:o.decimals??t};n=""}catch{n=""}}if(!n&&r){const o=r.find(n=>n.symbol.toUpperCase()===e.symbol.toUpperCase());if(o){n=o.token_address;try{const e=await Wh.getTokensDetails([n],p);t=e?.data?.[0]?.decimals??t}catch{}}}return n?{symbol:e.symbol,contract_address:n,decimals:t}:null}))).filter(e=>null!==e).forEach(e=>{a.push({id:`buy-${e.symbol}`,text:`💰 Buy ${e.symbol}`,value:g("buttonBuySymbol",{symbol:e.symbol}),action:"click_buy_item_token_button",extraData:{tokenAddress:e.contract_address,symbol:e.symbol,decimals:e.decimals},fullWidth:!0})}),i.length>0&&i.forEach((e,n)=>{a.push({id:`suggested-${n}-${e.label}`,text:e.label,value:e.prompt,action:"suggested_action",fullWidth:!0})}),a.length>0?c(e.message||n,"bot",t,a):c(e.message||n,"bot",t)}(L,P,O.id,r):c(P,"bot",O.id)}catch(B){c(w("errorProcessingRequest"),"bot",O.id)}o(!1),await qd(50),Dh.isDesktop&&u.current?.focus()},[n,r,i,c,l,d?.address,v,h?.name,h?.nativeCurrency?.symbol,h?.tokenTrendingDefault,y,f,m,p,g,S,x,C,A,w,k,b,T,E])}}({inputValue:g,setInputValue:A,isTyping:E,setIsTyping:T,replyingTo:C,setReplyingTo:I,setShowSuggestions:x,inputRef:B,messages:d,addMessage:h,updateMessageType:w,account:U,chainData:H,chainType:q,chainTypeMoralis:V,chainId:W,isChainSupported:z,rpcUrl:J,t:c,ti:f,updateDataBuyToken:Z,showTrendingTokens:_,showMyNFTs:$,showMyBalances:ee,onClickItemTokenToBuy:ne,onClickItemUserBalanceToBuy:te,showPreviewToBuy:re}),{handleButtonClick:ie}=function(e){const{addMessage:n,handleSendMessage:t,setIsTyping:r,setShowSuggestions:o,onClickItemTokenToBuy:i,onClickItemUserBalanceToBuy:a,showPreviewToBuy:s,onTransaction:u,updateMessageText:l,ti:c,t:f,account:d,chainId:h,chainData:p,chainTypeMoralis:m,rpcUrl:y,updateDataBuyToken:v,getDataBuyToken:b,inputRef:w}=e;return{handleButtonClick:j.useCallback(async(e,g,k)=>{try{if("suggested_action"===g)return o(!1),void(await t(e));if(n(e,"user"),o(!1),r(!0),g)switch(await qd(500),g){case"click_buy_item_token_button":await i(k?.tokenAddress||"",k?.decimals||18);break;case"click_balance_item_user_to_buy_button":await a(k?.tokenAddress||"",k?.symbol||"",k?.balance||"",k?.decimals||18);break;case"select_percent":await s(k?.percent||0,k?.tokenBalance||"",k?.tokenAddress||void 0,k?.tokenDecimals||void 0);break;case"confirm_swap":{if(!k?.tx||!u){n(f("txDataNotAvailable"),"bot");break}const e=k.tx,t={from:d?.address||"",to:e.to,data:e.data,value:e.value,chainId:h},o=n(f("txProcessing"),"bot");try{r(!1);const e=await u(t),n=p?.blockExplorers?.default?.url,i=e.transactionHash?n?` [View on Explorer](${n}/tx/${e.transactionHash})`:` Tx: ${e.transactionHash}`:"";if("success"===e.status&&e.transactionHash){l(o.id,f("txSubmitted")+i);try{await qd(2e3);const n=await lp({transactionHash:e.transactionHash,chainId:h||1,rpcUrl:y});l(o.id,("success"===n.status?f("txConfirmedSwap"):f("txRevertedSwap"))+i)}catch{l(o.id,f("txTimeout")+i)}}else"success"===e.status?l(o.id,f("txSuccessfulSwap")):l(o.id,f("txFailed")+(e.error?`\nError: ${e.error}`:""))}catch(A){l(o.id,f("txFailed"))}break}case"approve_for_swap":{const e=k?.tokenAddress||"",t=k?.spenderAddress||"",o=k?.tokenSymbol||"token",i=k?.tx;if(!e||!t||!u){n(f("approvalDataNotAvailable"),"bot");break}const a=k?.amountInWei||void 0,s=fp({tokenAddress:e,spenderAddress:t,fromAddress:d?.address||"",chainId:h,tokenSymbol:o,amount:a}),l={from:s.from,to:s.to,data:s.data,value:s.value,chainId:s.chainId};n(c("approving",{symbol:o}),"bot");try{r(!1);const e=await u(l);let t="success"===e.status;if("success"===e.status&&e.transactionHash)try{t="success"===(await lp({transactionHash:e.transactionHash,chainId:h||1,rpcUrl:y})).status}catch{t=!0}t?(n(c("approvalSuccess",{symbol:o}),"bot"),n(f("approvalConfirmSwap"),"bot",void 0,[{id:"confirm-swap-after-approve",text:f("confirmSwapButton"),value:f("swapConfirmValue"),action:"confirm_swap",fullWidth:!0,extraData:{tx:i}}])):n(f("approvalFailed")+(e.error?`\nError: ${e.error}`:""),"bot")}catch(A){n(f("approvalFailed"),"bot")}break}case"click_swap_dest_token":{const e=k?.tokenAddress||"",t=k?.symbol||"";v({descTokenAddress:e,descTokenDecimals:k?.decimals||18});const r=b(),o=r.srcTokenAddress||"",i=o===Zo,a=r.amount||"";try{const s=await Xh({address:d?.address||"",chain:m});if(s?.success&&s?.data?.result){const u=s.data.result;let l,m="",b="0";if(i){const e=u.find(e=>e.native_token);m=p?.nativeCurrency?.symbol||"ETH",b=e?.balance_formatted||"0",l=e?.usd_price}else{const e=u.find(e=>e.token_address.toLowerCase()===o.toLowerCase());e&&(m=e.symbol,b=e.balance_formatted,l=e.usd_price)}if(a&&m){const t=cm(a,b,l),s=r.srcTokenDecimals||18,u=i?Zo:o;v({amount:t});try{const r=Qo(t,s).toString(),o=await np({chainId:h,tokenIn:u,tokenInAmount:r,tokenOut:e,tokenOutRecipient:d?.address||"",slippage:"auto",accesstoken:"d6c45897b8f6"});if(o.success&&o.data){const e=o.data,t=e.tokenIn,a=e.tokenOut,s=Mh(lt(BigInt(t.amount||0),t.decimals)).decimalPlaces(8).toFormat(),l=Mh(lt(BigInt(a.amount||0),a.decimals)).decimalPlaces(8).toFormat();let m=!1;if(!i&&d?.address&&e.tx?.to)try{const n=await cp({tokenAddress:u,ownerAddress:d.address,spenderAddress:e.tx.to,chainId:h,rpcUrl:y});m=Mh(n.toString()).isLessThan(r)}catch{m=!0}const v=e.estimatedTransactionFee?.total?Mh(e.estimatedTransactionFee.total):Mh(0);let b=Mh(0);if(m&&d?.address)try{const n=fp({tokenAddress:u,spenderAddress:e.tx?.to||"",fromAddress:d.address,chainId:h,amount:r});b=await hp({from:d.address,to:n.to,data:n.data,chainId:h,rpcUrl:y})}catch{}const w=v.plus(b),g=p?.nativeCurrency?.symbol||"native";let k="",A=!1;if(d?.address&&w.isGreaterThan(0))try{const e=await dp({address:d.address,chainId:h,rpcUrl:y});e.isLessThan(w)&&(A=!0,k=c("swapFeeWarning",{symbol:g,balance:Mh(lt(BigInt(e.toFixed(0)),18)).decimalPlaces(8).toFormat(),needed:Mh(lt(BigInt(w.toFixed(0)),18)).decimalPlaces(8).toFormat()}))}catch{}const E=`From: ${s} ${t.symbol}\n⬇️\nTo: ${l} ${a.symbol}\n\n${k}\n`;A?n(E,"bot"):m?n(E+c("swapNeedApprove",{symbol:t.symbol}),"bot",void 0,[{id:"approve-for-swap",text:c("swapApproveButton",{symbol:t.symbol}),value:c("swapApproveValue",{symbol:t.symbol}),action:"approve_for_swap",fullWidth:!0,extraData:{tokenAddress:u,spenderAddress:e.tx.to,tokenSymbol:t.symbol,amountInWei:r,tx:e.tx}}]):n(E+f("swapReadyToProceed"),"bot",void 0,[{id:"confirm-swap",text:f("swapConfirmYes"),value:f("swapConfirmValue"),action:"confirm_swap",extraData:{tx:e.tx}}])}else n(c("swapEstimationError",{error:o.errorMessage||o.error||"Unknown error"}),"bot")}catch(A){n(f("swapEstimationFailed"),"bot")}}else if(m&&parseFloat(b)>0){const e=r.srcTokenDecimals||18,i=[25,50,75,100].map(n=>({id:`percent-${n}`,text:`${n}%`,value:c("buttonUsePercent",{percent:String(n),symbol:m}),action:"select_percent",extraData:{percent:n,tokenAddress:o,tokenSymbol:m,tokenDecimals:e,tokenBalance:b}}));n(c("swapSelectAmount",{from:m,to:t,balance:b}),"bot",void 0,i)}else n(f("swapNoSourceToken"),"bot")}else n(f("couldNotFetchBalance"),"bot")}catch(A){n(f("couldNotLoadBalance"),"bot")}break}case"select_nft_to_send":{const e=k?.name||"NFT",t=k?.contractAddress||"",r=k?.tokenId||"",o=k?.tokenStandard||"ERC721",i=k?.amount||"1",a=k?.image||"",s=k?.toAddress||"";n(c("nftSendReview",{name:e,standard:o,tokenId:r}),"bot",void 0,void 0,{action:"send_nft",parameters:{contract_address:t,token_id:r,to_address:s,token_standard:o,amount:i,maxAmount:i,nft_name:e},status:"pending",nftInfo:{name:e,image:a||void 0,tokenId:r,contractAddress:t,tokenStandard:o}});break}default:n(c("actionExecutedFor",{action:g,value:e}),"bot")}else await qd(500),n(c("receivedButtonValue",{value:e}),"bot");r(!1),Dh.isDesktop&&w.current?.focus()}catch(E){n(f("errorProcessingRequest"),"bot"),r(!1)}},[n,t,i,a,s,u,c,d?.address,h,f,p?.blockExplorers?.default?.url,p?.nativeCurrency?.symbol,l,y,v,b,m])}}({addMessage:h,handleSendMessage:oe,setIsTyping:T,setShowSuggestions:x,onClickItemTokenToBuy:ne,onClickItemUserBalanceToBuy:te,showPreviewToBuy:re,onTransaction:t,updateMessageText:y,ti:f,t:c,account:U,chainId:W,chainData:H,chainTypeMoralis:V,rpcUrl:J,updateDataBuyToken:Z,getDataBuyToken:Q,inputRef:B}),{handleActionFormSubmit:ae}=function(e){const{updateMessageAction:n,updateMessageActionParameters:t,chainId:r,account:o,chainType:i,chainData:a,rpcUrl:s,ti:u,t:l,addMessage:c,onTransaction:f,setIsTyping:d}=e;return{handleActionFormSubmit:j.useCallback(async(e,h,p)=>{try{if(n(p,"submitted"),"swap_token"===e){let e=18;if(h.token_in&&h.token_in!==Zo)try{const n=await Wh.getTokensDetails([h.token_in],i);n?.data?.[0]&&(e=n.data[0].decimals||18)}catch(m){}const t=Qo(h.amount||"0",e).toString(),f=await np({chainId:r,tokenIn:h.token_in||"",tokenInAmount:t,tokenOut:h.token_out||"",tokenOutRecipient:o?.address||"",slippage:"auto",accesstoken:"d6c45897b8f6"});if(!f.success||!f.data)return n(p,"pending"),void c(u("swapEstimationError",{error:f.errorMessage||f.error||"Unknown error"}),"bot");const d=f.data,y=d.tokenIn,v=d.tokenOut,b=Mh(lt(BigInt(y.amount||0),y.decimals)).decimalPlaces(8).toFormat(),w=Mh(lt(BigInt(v.amount||0),v.decimals)).decimalPlaces(8).toFormat(),g=!h.token_in||h.token_in===Zo;let k=!1;if(!g&&o?.address&&d.tx?.to)try{const e=await cp({tokenAddress:h.token_in,ownerAddress:o.address,spenderAddress:d.tx.to,chainId:r,rpcUrl:s});k=Mh(e.toString()).isLessThan(t)}catch(m){}const A=d.estimatedTransactionFee?.total?Mh(d.estimatedTransactionFee.total):Mh(0);let E=Mh(0);if(k&&o?.address)try{const e=fp({tokenAddress:h.token_in,spenderAddress:d.tx?.to||"",fromAddress:o.address,chainId:r,amount:t});E=await hp({from:o.address,to:e.to,data:e.data,chainId:r,rpcUrl:s})}catch(m){}const T=A.plus(E),S=a?.nativeCurrency?.symbol||"native";let x="",C=!1;if(o?.address&&T.isGreaterThan(0))try{const e=await dp({address:o.address,chainId:r,rpcUrl:s});e.isLessThan(T)&&(C=!0,x=u("swapFeeWarning",{symbol:S,balance:Mh(lt(BigInt(e.toFixed(0)),18)).decimalPlaces(8).toFormat(),needed:Mh(lt(BigInt(T.toFixed(0)),18)).decimalPlaces(8).toFormat()}))}catch(m){}const I=`From: ${b} ${y.symbol}\n⬇️\nTo: ${w} ${v.symbol}\n\n${x}\n`;return void(C?(n(p,"pending"),c(I,"bot")):k?(n(p,"success"),c(I+u("swapApprovalRequired",{symbol:y.symbol}),"bot",void 0,[{id:"approve-swap-actionform",text:u("swapApproveButton",{symbol:y.symbol}),value:u("swapApproveValue",{symbol:y.symbol}),action:"approve_for_swap",extraData:{tokenAddress:h.token_in,spenderAddress:d.tx.to,tokenSymbol:y.symbol,amountInWei:t,tx:d.tx},fullWidth:!0}])):(n(p,"success"),c(I+l("swapReadyToProceed"),"bot",void 0,[{id:"confirm-swap-actionform",text:l("swapConfirmYes"),value:l("swapConfirmValue"),action:"confirm_swap",extraData:{tx:d.tx}}])))}const v=up({action:e,parameters:h,fromAddress:o?.address||"",chainId:r||1}),b={from:v.from,to:v.to,data:v.data,value:v.value,chainId:v.chainId};if(["send_token","send_native","send_nft","wrap_native","unwrap_native","approve_token"].includes(e)&&o?.address)try{const e=a?.nativeCurrency?.symbol||"native",t=await hp({from:v.from,to:v.to,data:v.data,value:v.value&&"0"!==v.value?`0x${BigInt(v.value).toString(16)}`:void 0,chainId:r,rpcUrl:s});if(t.isGreaterThan(0)){const i=await dp({address:o.address,chainId:r,rpcUrl:s});if(i.isLessThan(t))return n(p,"pending"),void c(u("txInsufficientGas",{symbol:e,balance:Mh(lt(BigInt(i.toFixed(0)),18)).decimalPlaces(8).toFormat(),fee:Mh(lt(BigInt(t.toFixed(0)),18)).decimalPlaces(8).toFormat()}),"bot")}}catch(y){}if(!f)return n(p,"pending"),void c(l("txNoHandler"),"bot");d(!1);const w=await f(b);if("success"===w.status&&w.transactionHash){const o=a?.blockExplorers?.default?.url,i=o?` [View on Explorer](${o}/tx/${w.transactionHash})`:` Tx: ${w.transactionHash}`;try{if(await qd(4e3),"success"===(await lp({transactionHash:w.transactionHash,chainId:r||1,rpcUrl:s})).status){if(n(p,"success"),t(p,h),"approve_token"===e)c(u("approvalSuccess",{symbol:h.token_symbol||h.contract_address||"Token"})+i,"bot");else if("send_nft"===e){const e=h.to_address||h.recipient||"",n=e?`${e.slice(0,6)}...${e.slice(-4)}`:"";c(u("txSuccessfulSendNft",{name:h.nft_name||h.token_symbol||"NFT",tokenId:h.token_id||"",to:n})+i,"bot")}else if("send_token"===e||"send_native"===e){const n=h.to_address||h.recipient||"",t=n?`${n.slice(0,6)}...${n.slice(-4)}`:"";c(u("send_native"===e?"txSuccessfulSendNative":"txSuccessfulSendToken",{amount:h.amount||"",symbol:h.token_symbol||("send_native"===e?a?.nativeCurrency?.symbol||"native":"Token"),to:t})+i,"bot")}else if("wrap_native"===e){const e=a?.nativeCurrency?.symbol||"native";c(u("txSuccessfulWrapNative",{amount:h.amount||"",from:e,to:`W${e}`})+i,"bot")}else if("unwrap_native"===e){const e=a?.nativeCurrency?.symbol||"native";c(u("txSuccessfulUnwrapNative",{amount:h.amount||"",from:`W${e}`,to:e})+i,"bot")}}else n(p,"pending"),c(l("txReverted")+"\n"+i,"bot")}catch{n(p,"success"),c(l("txTimeout")+"\n"+i,"bot")}}else"success"===w.status?n(p,"success"):(n(p,"pending"),c(l("txFailed")+(w.error?`\nError: ${w.error}`:""),"bot"))}catch(v){n(p,"pending"),c(u("txError",{message:v instanceof Error?v.message:"Unknown error"}),"bot")}},[n,t,r,o?.address,i,a?.nativeCurrency?.symbol,a?.blockExplorers?.default?.url,s,u,l,c,f])}}({updateMessageAction:p,updateMessageActionParameters:m,chainId:W,account:U,chainType:q,chainData:H,rpcUrl:J,ti:f,t:c,addMessage:h,onTransaction:t,setIsTyping:T}),se=j.useMemo(()=>{const e=(e=[])=>e.map(e=>({...e,id:nh(),action:async()=>{x(!1),await ie(e.text,"suggested_action")}})),n=[{id:"ask",icon:"❓",text:c("suggestionAskText"),action:async()=>{x(!1),T(!0),h(c("suggestionAskUserMessage"),"user"),await qd(1e3),T(!1),h(c("suggestionAskBotReply"),"bot")}},{id:"buy",icon:"💰",text:c("suggestionBuyText"),action:async()=>{x(!1),h(c("suggestionBuyText"),"user"),jn(U?.address||"")&&z?await _():(T(!0),await qd(1e3),jn(U?.address||"")&&!z?h(c("walletConnectedChainUnsupported"),"bot"):h(c("walletNotConnected"),"bot"),T(!1))}}],t=s?e(s):n;return u?.length?[...t,...e(u)]:t},[s,u,ie,h,U?.address,_,c,z]),ue=j.useCallback(async(e,n,t)=>{x(!1),O(e=>({...e,[t]:!0}));try{await ae(e,n,t)}finally{O(e=>({...e,[t]:!1}))}},[ae]),le=j.useCallback(e=>{b([e])},[b]),ce=j.useCallback(e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),oe())},[oe]),fe=j.useCallback(()=>{const e=window.getSelection();e&&e.toString().length>0||n()},[n]),de=e=>{if(0===e)return!0;const n=new Date(d[e].timestamp),t=new Date(d[e-1].timestamp);return n.setHours(0,0,0,0),t.setHours(0,0,0,0),n.getTime()!==t.getTime()};return j.useEffect(()=>{R.current?.scrollIntoView({behavior:"smooth"})},[d]),j.useEffect(()=>{e?(B.current&&Dh.isDesktop&&B.current.focus(),R.current?.scrollIntoView({behavior:"instant"}),L.current&&P.current?Date.now()-P.current>12e5&&x(!0):x(!0),P.current=null,L.current=!1,setTimeout(()=>{R.current?.scrollIntoView({behavior:"smooth"})},50)):(P.current=Date.now(),L.current=!F.current)},[e]),j.useEffect(()=>{const t=t=>{"Escape"===t.key&&e&&n()};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e,n]),e?/* @__PURE__ */k.jsx("div",{className:"chat-modal-overlay"+("bottom-left"===r?" chat-modal-overlay--left":""),onClick:fe,role:"dialog","aria-modal":"true","aria-labelledby":"chat-modal-title",children:/* @__PURE__ */k.jsxs("div",{className:"chat-modal",style:o,onClick:e=>e.stopPropagation(),children:[
30
+ return k.jsx("div",{className:"message-content",children:t})},pm=({isOpen:e,onClose:n,onTransaction:t,position:r="bottom-right",modalChatStyle:o={},chatTitle:i,welcomeMessage:a,customSuggestions:s,additionalSuggestions:u,chatIcon:l,modalConfig:c})=>{const{isShowIcon:f=!0}=c||{},{t:d,ti:h}=G(),{messages:p,addMessage:m,updateMessageAction:y,updateMessageActionParameters:v,updateMessageText:b,clearMessages:w,clearMessagesById:g,updateMessageType:A}=function({customWelcomeMessage:e}={}){const{account:n}=Qd(),{t:t}=G(),r=(o=n?.address,i=n?.chainId,o&&i?`${o}_${i}`:"");var o,i;const a=j.useMemo(()=>rh(e||t("welcomeMessage")),[t,e]),[s,u]=j.useState(()=>r||"pending"),[l,c]=j.useState(()=>{const n=ih();return r?n&&n.owner===r?n.messages:rh(e||t("welcomeMessage")):n?.messages??rh(e||t("welcomeMessage"))});if("pending"===s&&r){const e=ih();e&&e.owner===r?c(e.messages):ah(r,l),u(r)}else"pending"!==s&&r&&s!==r&&(c(a),ah(r,a),u(r));const f=j.useMemo(()=>l.map(n=>n.id===th?{...n,text:e||t("welcomeMessage")}:n),[l,t,e]);j.useEffect(()=>{"pending"!==s&&ah(s,l)},[l,s]),j.useEffect(()=>{const e=[];for(let n=0;n<Gd.length;n++){const t=Gd.key(n);t&&t.startsWith($d+"_")&&e.push(t)}e.forEach(e=>Gd.removeItem(e))},[]);const d=j.useCallback(()=>{c(a),ah(r,a)},[r,a]),h=j.useCallback(e=>{c(n=>{const t=n.filter(n=>!e.includes(n.id));return t.length>eh?t.slice(t.length-eh):t})},[]);return{messages:f,setMessages:c,addMessage:(e,n,t,r,o,i="web3")=>{const a=t?l.find(e=>e.id===t):void 0,s={id:nh(),text:e,sender:n,timestamp:/* @__PURE__ */new Date,typeChat:i,...a&&{replyTo:{id:a.id,text:a.text,sender:a.sender}},...r&&{buttons:r},...o&&{actionData:o}};return c(e=>{const n=[...e,s];return n.length>eh?n.slice(n.length-eh):n}),s},updateMessageAction:(e,n)=>{c(t=>t.map(t=>t.id===e&&t.actionData?{...t,actionData:{...t.actionData,status:n}}:t))},updateMessageActionParameters:(e,n)=>{c(t=>t.map(t=>t.id===e&&t.actionData?{...t,actionData:{...t.actionData,parameters:{...t.actionData.parameters,...n}}}:t))},updateMessageText:(e,n)=>{c(t=>t.map(t=>t.id===e?{...t,text:n}:t))},getMessageById:e=>l.find(n=>n.id===e),clearMessages:d,clearMessagesById:h,updateMessageType:(e,n)=>{c(t=>t.map(t=>t.id===e?{...t,typeChat:n}:t))}}}({customWelcomeMessage:a}),[E,T]=j.useState(""),[S,x]=j.useState(!1),[C,I]=j.useState(!0),[M,O]=j.useState(null),[R,N]=j.useState({}),B=j.useRef(null),P=j.useRef(null),L=j.useRef(null),F=j.useRef(null),D=j.useRef(!1),U=j.useRef(C),{modal:H}=Jd();j.useEffect(()=>{U.current=C},[C]);const{account:q,chainData:V,chainType:W,chainTypeMoralis:z,chainId:Y,isChainSupported:J}=Qd(),{config:K}=(()=>{const e=j.useContext(sh);if(!e)throw new Error("useConfig must be used within ConfigProvider");return e})(),X=Y&&K?.rpcUrls?.[Y]||void 0,Q=j.useCallback(()=>{w(),T(""),O(null),x(!1),I(!0)},[w]);j.useEffect(()=>(Hh(Q),()=>{Hh(null)}),[Q]);const Z=j.useCallback(e=>{O(e),Dh.isDesktop&&L.current?.focus()},[]),{getDataBuyToken:_,updateDataBuyToken:$}=function(){const e=j.useCallback(()=>{const e=Gd.getItem(jh);if(e)try{return JSON.parse(e)}catch{return{...qh}}return{...qh}},[]),n=j.useCallback(e=>{Gd.setItem(jh,JSON.stringify(e))},[]),t=j.useCallback(t=>{const r=e();n({...r,...t})},[e,n]);return{getDataBuyToken:e,setDataBuyToken:n,updateDataBuyToken:t}}(),{showTrendingTokens:ee,showMyNFTs:ne,showMyBalances:te}=function(e){const{addMessage:n,setIsTyping:t,chainData:r,chainType:o,account:i,chainTypeMoralis:a,t:s,ti:u}=e;return{showTrendingTokens:j.useCallback(async()=>{try{t(!0);const e=r?.tokenTrendingDefault||[],[i,a]=await Promise.allSettled([Wh.getTopGainers(o,"24h",5),Wh.getTokensDetails(e,o)]);let l=[];"fulfilled"===i.status&&i.value?.data&&(l=[...i.value.data]),"fulfilled"===a.status&&a.value?.data&&(l=[...a.value.data,...l]),l=l.filter((e,n,t)=>n===t.findIndex(n=>n.address.toLowerCase()===e.address.toLowerCase()));const c=l.map(e=>({id:e?.symbol,text:e?.symbol,value:u("buttonBuyToken",{name:e.name,symbol:e?.symbol||""}),action:"click_buy_item_token_button",extraData:{tokenAddress:e?.address||"",symbol:e?.symbol||"",decimals:e?.decimals||18}}));await qd(1e3),t(!1),n(u("trendingTokensHeader",{chain:r?.name||"Unknown"}),"bot");const f=l.map((e,n)=>`${n+1}. ${e.name} (${e?.auditGoplus?.token_symbol||e.symbol||"Unknown"})\n$${Mh(e?.price||0).decimalPlaces(4).toFormat()} (${e.price_change_percentage_24h||e.priceChange}%)\n\n---\n`).join("\n");n(`${f}${s("trendingTokensQuestion")}`,"bot",void 0,c)}catch(e){n(s("trendingTokensError"),"bot")}finally{t(!1)}},[n,t,r,o,s,u]),showMyNFTs:j.useCallback(async()=>{try{const{getDataPackage:e}=await Promise.resolve().then(()=>Kd),r=e()?.linkViewNft;n(r?u("viewNftViaWebsiteWithLink",{link:r}):s("viewNftViaWebsite"),"bot"),t(!1)}catch(e){t(!1),n(s("nftFetchError"),"bot")}},[n,t,s,u]),showMyBalances:j.useCallback(async()=>{try{t(!0);const e=await Xh({address:i?.address||"",chain:a});if(e?.success&&e?.data?.result&&e.data.result.length>0){const o=e.data.result.map((e,n)=>{const t=void 0!==e.usd_value?` ≈ $${Mh(e.usd_value).decimalPlaces(2).toFormat()}`:"";return`${n+1}. **${e.name}** (${e.symbol})\n Balance: ${e.balance_formatted}${t}`}).join("\n\n");await qd(500),t(!1),n(u("viewBalancesHeader",{chain:r?.name||"this chain",list:o}),"bot")}else t(!1),n(s("viewBalancesEmpty"),"bot")}catch(e){t(!1),n(s("viewBalancesFetchError"),"bot")}},[i?.address,a,n,t,r?.name,s,u])}}({addMessage:m,setIsTyping:x,chainData:V,chainType:W,account:q,chainTypeMoralis:z,t:d,ti:h}),{onClickItemTokenToBuy:re,onClickItemUserBalanceToBuy:oe,showPreviewToBuy:ie}=function(e){const{getDataBuyToken:n,updateDataBuyToken:t,addMessage:r,setIsTyping:o,account:i,chainData:a,chainTypeMoralis:s,chainId:u,rpcUrl:l,t:c,ti:f}=e;return{onClickItemTokenToBuy:j.useCallback(async(e,n)=>{t({descTokenAddress:e,descTokenDecimals:n||18});try{o(!0);const e=await Xh({address:i?.address||"",chain:s});if(e?.success&&e?.data?.result){const n=e.data.result;if(n?.length>0){const e=n.map(e=>({id:e.token_address,text:`${e.name}: ${e.balance_formatted} ${e.symbol} ($${Mh(e.usd_value||0).decimalPlaces(2).toFormat()||"0"})`,value:f("buttonBuyWith",{symbol:e.symbol}),action:"click_balance_item_user_to_buy_button",fullWidth:!0,extraData:{tokenAddress:e.token_address,symbol:e.symbol,balance:e.balance_formatted,usdValue:e.usd_value,decimals:e.decimals}}));r(f("walletBalanceSpendable",{chain:a?.name||"unknown"}),"bot",void 0,e)}else r(f("walletNoTokensFound",{chain:a?.name||"unknown"}),"bot")}else r(c("walletFetchFailed"),"bot")}catch(u){r(c("walletFetchError"),"bot")}finally{o(!1)}},[t,i?.address,s,r,o,a?.name,c,f]),onClickItemUserBalanceToBuy:j.useCallback(async(e,n,o,i)=>{t({srcTokenAddress:e,srcTokenDecimals:i||18});let a=o||"0";if(e===Zo)try{const e=await pp({chainId:u,rpcUrl:l});if(e.isGreaterThan(0)){const n=e.times(1e6),t=new Mh(Qo(o,i||18).toString()).minus(n);a=t.isGreaterThan(0)?Mh(lt(BigInt(t.toFixed(0)),18)).toFixed():"0"}}catch(c){}const s=[25,50,75,100].map(t=>({id:`percent-${t}`,text:`${t}%`,value:f("buttonUsePercent",{percent:String(t),symbol:n}),action:"select_percent",extraData:{percent:t,tokenAddress:e,tokenSymbol:n,tokenDecimals:i||18,tokenBalance:a}}));Mh(a).isZero()?r(f("insufficientFeeToken",{symbol:n}),"bot"):r(f("selectAmountOf",{symbol:n,balance:a}),"bot",void 0,s)},[r,u,l,t,f]),showPreviewToBuy:j.useCallback(async(e,o,s,d)=>{const h={amount:Mh(o).times(e).dividedBy(100).toFixed()};void 0!==s&&(h.srcTokenAddress=s),void 0!==d&&(h.srcTokenDecimals=d),t(h);const p=n(),m=Qo(p.amount,p.srcTokenDecimals||18).toString(),y=await np({chainId:u,tokenIn:p.srcTokenAddress,tokenInAmount:m,tokenOut:p.descTokenAddress,tokenOutRecipient:i?.address||"",slippage:"auto",accesstoken:"d6c45897b8f6"});if(y.success&&y.data){const e=y.data,n=e.tokenIn,t=e.tokenOut,o=Mh(lt(BigInt(n.amount||0),n.decimals)).decimalPlaces(8).toFormat(),s=Mh(lt(BigInt(t.amount||0),t.decimals)).decimalPlaces(8).toFormat();let d=!1;if(p.srcTokenAddress!==Zo&&""!==p.srcTokenAddress&&i?.address&&e.tx?.to)try{const n=await cp({tokenAddress:p.srcTokenAddress,ownerAddress:i.address,spenderAddress:e.tx.to,chainId:u,rpcUrl:l});d=Mh(n.toString()).isLessThan(m)}catch(v){d=!0}const h=e.estimatedTransactionFee?.total?Mh(e.estimatedTransactionFee.total):Mh(0);let b=Mh(0);if(d&&i?.address)try{const n=fp({tokenAddress:p.srcTokenAddress,spenderAddress:e.tx?.to||"",fromAddress:i.address,chainId:u,amount:m});b=await hp({from:i.address,to:n.to,data:n.data,chainId:u,rpcUrl:l})}catch(v){}const w=h.plus(b),g=a?.nativeCurrency?.symbol||"native";let k="",A=!1;if(i?.address&&w.isGreaterThan(0))try{const e=await dp({address:i.address,chainId:u,rpcUrl:l});if(e.isLessThan(w)){A=!0;const n=Mh(lt(BigInt(e.toFixed(0)),18)).decimalPlaces(8).toFormat(),t=Mh(lt(BigInt(w.toFixed(0)),18)).decimalPlaces(8).toFormat();k=f("swapFeeWarning",{symbol:g,balance:n,needed:t})}}catch(v){}const E=`From: ${o} ${n.symbol}\n⬇️\nTo: ${s} ${t.symbol}\n\n`+k+"\n";if(A)r(E,"bot");else if(d){const t=[{id:"approve-for-swap",text:f("swapApproveButton",{symbol:n.symbol}),value:f("swapApproveValue",{symbol:n.symbol}),action:"approve_for_swap",fullWidth:!0,extraData:{tokenAddress:p.srcTokenAddress,spenderAddress:e.tx.to,tokenSymbol:n.symbol,amountInWei:m,tx:e.tx}}];r(E+f("swapNeedApprove",{symbol:n.symbol}),"bot",void 0,t)}else{const n=[{id:"confirm-swap",text:c("swapConfirmButton"),value:c("swapConfirmValue"),action:"confirm_swap",extraData:{tx:e.tx}}];r(E+c("swapReadyToProceed"),"bot",void 0,n)}}else r(f("swapEstimationError",{error:y.errorMessage||y.error||"Unknown error"}),"bot")},[n,t,r,u,i?.address,a?.nativeCurrency?.symbol,l,c,f])}}({getDataBuyToken:_,updateDataBuyToken:$,addMessage:m,setIsTyping:x,account:q,chainData:V,chainTypeMoralis:z,chainId:Y,rpcUrl:X,t:d,ti:h}),{handleSendMessage:ae}=function(e){const{inputValue:n,setInputValue:t,isTyping:r,setIsTyping:o,replyingTo:i,setReplyingTo:a,setShowSuggestions:s,inputRef:u,messages:l,addMessage:c,updateMessageType:f,account:d,chainData:h,chainType:p,chainTypeMoralis:m,chainId:y,isChainSupported:v,rpcUrl:b,t:w,ti:g,updateDataBuyToken:k,showTrendingTokens:A,showMyNFTs:E,showMyBalances:T,onClickItemTokenToBuy:S,onClickItemUserBalanceToBuy:x,showPreviewToBuy:C}=e;return{handleSendMessage:j.useCallback(async e=>{const I=e??n?.trim();if(!I||r)return;const M=i,O=c(I,"user",i?.id);t(""),a(null),o(!0),s(!1);try{const e=l.slice(-10);let n="",t="";if(e.length>0){n="\n\n## CONVERSATION HISTORY:\n";for(const t of e)"user"===t.sender?n+=`User: ${t.text}\n`:n+=`Assistant: ${t.text}\n`;n+="\n---\n"}let r,i,a=I;M&&(a=`[Replying to ${"user"===M.sender?"my previous":"your"} message: "${M.text}"]\n\n${a}`);try{const r=await kp.checkInfoQuestion(I,n);if(r.language&&(t=r.language),"faq"===r.model&&r.faqAnswer)return o(!1),void c(r.faqAnswer,"bot",O.id);if("pool"===r.model&&v)try{const n=await im({question:I,language:t||"en",currentChain:m||p||void 0,walletAddress:d?.address||void 0,chatHistory:e.map(e=>({role:"user"===e.sender?"user":"assistant",content:e.text})),signal:void 0});if(n){if(o(!1),"send_position"===n.parsed.intent){const e=n.parsed.poolId;if(!e)return void c(w("sendPositionNoId"),"bot",O.id);if(!d?.address)return void c(w("walletNotConnected"),"bot",O.id);try{o(!0);const t=await _h({address:d.address,chain:m,limit:100,exclude_spam:!1});if(t?.success&&t?.data?.result){const r=t.data.result.find(n=>n.token_id===e);if(r){const t=r.normalized_metadata?.name||r.name||`LP Position #${e}`,o=r.normalized_metadata?.image||r.media?.original_media_url||"",i={contract_address:r.token_address,token_id:r.token_id,to_address:n.parsed.toAddress||"",token_standard:r.contract_type||"ERC721",amount:"1",maxAmount:r.amount||"1",nft_name:t};c(g("nftSendReview",{name:t,standard:r.contract_type||"ERC721",tokenId:r.token_id}),"bot",O.id,void 0,{action:"send_nft",parameters:i,status:"pending",nftInfo:{name:t,image:o||void 0,tokenId:r.token_id,contractAddress:r.token_address,tokenStandard:r.contract_type||"ERC721"}})}else c(g("sendPositionNotFound",{id:e,chain:h?.name||m||p||"this chain"}),"bot",O.id)}else c(w("nftNoCollection"),"bot",O.id)}catch(R){c(w("sendPositionFetchError"),"bot",O.id)}finally{o(!1)}return}return void c(n.response,"bot",O.id)}}catch(N){}if("general"===r.model){f(O.id,"normal");const e=l.filter(e=>"normal"===e.typeChat);let n="";if(e.slice(-10).length>0){n="\n\n## CONVERSATION HISTORY:\n";for(const t of e.slice(-10))"user"===t.sender?n+=`User: ${t.text}\n`:n+=`Assistant: ${t.text}\n\n`}const r=await kp.generateContent(a,n,t),i=fm(r);return o(!1),void c(i?.message||r,"bot",void 0,void 0,void 0,"normal")}}catch(B){}if(d?.address&&v)try{const[e,n]=await Promise.allSettled([Xh({address:d.address,chain:m}),_h({address:d.address,chain:m,limit:100,exclude_spam:!0})]);"fulfilled"===e.status&&e.value?.success&&e.value?.data?.result&&(r=e.value.data.result.map(e=>({symbol:e.symbol,name:e.name,balance_formatted:e.balance_formatted,usd_value:e.usd_value,native_token:e.native_token,token_address:e.token_address,price:e.usd_price}))),"fulfilled"===n.status&&n.value?.success&&n.value?.data?.result&&(i=n.value.data.result.map(e=>({name:e.normalized_metadata?.name||e.name||`#${e.token_id}`,token_address:e.token_address,token_id:e.token_id,contract_type:e.contract_type||"",amount:e.amount||"1"})))}catch{}const s=function(e){const{walletAddress:n,chainName:t,chainId:r,nativeSymbol:o,walletTokens:i,walletNfts:a,language:s}=e;if(!n)return`You are a Web3 wallet assistant for the crypto EVM wallet app.\nThe user is currently NOT connected to any wallet.\n\n## YOUR ROLE:\n- You are a friendly, knowledgeable assistant that can talk about ANY topic naturally\n- You can freely answer general questions, discuss crypto tokens, prices, market info, provide token details, etc. — these do NOT require a wallet connection\n- ONLY ask the user to connect their wallet when their request explicitly requires their personal wallet/address, such as:\n - Sending tokens or NFTs\n - Swapping tokens\n - Approving token spending\n - Wrapping/unwrapping tokens\n - Checking THEIR OWN balance ("what is MY balance?", "how much ETH do I have?")\n - Viewing THEIR OWN NFT collection\n - Any action that reads or writes to THEIR wallet address\n- For all other requests (token info, prices, general crypto questions, market data, etc.), respond normally and helpfully\n- ${lm(s)}\n- **LANGUAGE DETECTION — CRYPTO TICKERS**: Crypto token symbols and tickers (ETH, BTC, USDC, BNB, MATIC, SOL, etc.) are NOT language indicators. They are proper nouns used in ALL languages. Detect the language from the surrounding non-ticker text only. Example: "ETHの現在の価格は?" → Japanese (the surrounding text は Japanese characters). "ETH의 가격은?" → Korean. "Giá ETH là bao nhiêu?" → Vietnamese. NEVER treat a ticker symbol as evidence of English.\n\n## RESPONSE FORMAT:\nAlways respond with a valid JSON object:\n{"action":"chat","message":"<your friendly response to the user>", "suggested_actions":[{"label":"<short button text>","prompt":"<message sent when clicked>"}]}\n\n## RULES:\n- suggested_actions: include when your message offers the user interactive choices or asks a follow-up question. NEVER include suggested_actions that ask the user to connect their wallet (e.g., "Connect wallet", "Connect now", etc.) — the app handles wallet connection separately\n- **CRITICAL**: NEVER include any "Buy" actions (e.g., "Buy USDC", "Buy ETH", "Purchase token", etc.) in suggested_actions. The app handles Buy buttons separately. Only include non-buy actions in suggested_actions (e.g., "Send token", "Swap token", "Check balance", "Show my NFTs").\n- For wallet-required actions, politely explain the user needs to connect their wallet first, and put this in the "message" field\n- ALWAYS respond with raw JSON only, never wrap in \`\`\`json code blocks\n- ${lm(s)}`;if(n&&!li[r]?.isSupported)return`You are a Web3 wallet assistant for the crypto EVM wallet app.\n The user's wallet address is: ${n}\n The user is selected on (chainId: ${r}) an UNSUPPORTED chain.\n\n ## YOUR ROLE:\n - You are a friendly, knowledgeable assistant that can talk about ANY topic naturally\n - You can freely answer general questions, discuss crypto tokens, prices, market info, token details, etc. — these do NOT require a supported chain\n - **BLOCKED on unsupported chain** — if the user asks for any of the following, politely inform them that chain (chainId: ${r}) is not currently supported and the action cannot be performed:\n - Checking THEIR OWN balance ("what is my balance?", "how much ETH do I have?")\n - Sending tokens or NFTs\n - Swapping or buying tokens\n - Approving token spending\n - Wrapping/unwrapping tokens\n - Viewing or transferring their NFT collection\n - Any action that reads or writes to their wallet on the current chain\n - **ALLOWED on unsupported chain** — respond normally and helpfully for:\n - General questions (weather, coding, history, math, etc.)\n - Token information, prices, market data, token details\n - Any query that does NOT require interacting with the user's wallet on the current chain\n - ${lm(s)}\n - **LANGUAGE DETECTION — CRYPTO TICKERS**: Crypto token symbols and tickers (ETH, BTC, USDC, BNB, MATIC, SOL, etc.) are NOT language indicators. They are proper nouns used in ALL languages. Detect the language from the surrounding non-ticker text only. Example: "ETHの現在の価格は?" → Japanese. "ETH의 가격은?" → Korean. "Giá ETH là bao nhiêu?" → Vietnamese. NEVER treat a ticker symbol as evidence of English.\n\n ## RESPONSE FORMAT:\n Always respond with a valid JSON object:\n {"action":"chat","message":"<your response>", suggested_actions:[{"label":"<short button text>","prompt":"<message sent when clicked>"}]}\n\n ## RULES:\n - suggested_actions: include when your message offers the user interactive choices or asks a follow-up question. NEVER include suggested_actions that ask the user to connect their wallet (e.g., "Connect wallet", "Connect now", etc.) — the app handles wallet connection separately\n - **CRITICAL**: NEVER include any "Buy" actions (e.g., "Buy USDC", "Buy ETH", "Purchase token", etc.) in suggested_actions. The app handles Buy buttons separately. Only include non-buy actions in suggested_actions (e.g., "Send token", "Swap token", "Check balance", "Show my NFTs").\n - **CRITICAL**: ABSOLUTELY NEVER include any option that suggests switching, changing, or selecting a different chain (e.g., "Switch to Ethereum", "Change chain", "Switch network", "Chuyển sang chain khác", "Đổi mạng") — the app handles chain switching separately.\n - For wallet-required actions, politely explain the user needs to connect their wallet first, and put this in the "message" field\n - ALWAYS respond with raw JSON only, never wrap in \`\`\`json code blocks\n - ${lm(s)}`;const u=i&&i.length>0?`\n## USER'S CURRENT WALLET BALANCE:\n${i.map(e=>{const n=void 0!==e.usd_value?` (~$${e.usd_value.toFixed(2)})`:"";return`- ${e.name} (${e.symbol})(Price: ${e.price||"N/A"}): ${e.balance_formatted}${n}${e.native_token?" [native]":` [${e.token_address}]`}`}).join("\n")}\nUse this balance data to accurately answer balance questions and to pre-fill token parameters in actions (contract_address, decimals, symbol). NEVER ask the user to provide token info that is already available above.\n`:"",l=a&&a.length>0?`\n## USER'S NFT COLLECTION:\n${a.map(e=>{const n="ERC1155"===e.contract_type?` (x${e.amount})`:"";return`- ${e.name}${n} | ${e.contract_type} | contract: ${e.token_address} | tokenId: ${e.token_id}`}).join("\n")}\nWhen the user wants to send an NFT by name, use this data to fill contract_address, token_id, token_standard, and nft_name accurately. NEVER guess or fabricate NFT contract addresses.\n`:"",c=Object.values(li).filter(e=>e.isSupported).map(e=>e.customName||e.name).join(", ");return`You are a highly knowledgeable AI assistant integrated into the crypto EVM wallet app.\n\n## #1 PRIORITY — ANSWER QUALITY:\nYour "message" field IS your answer. Write it exactly as you would in a normal, unrestricted conversation. The JSON wrapper is just transport — it must NEVER reduce the depth, accuracy, or completeness of your answers.\n\n${lm(s)}\n\n**FOLLOW-UP / CONTINUATION HANDLING — CRITICAL**: When the user sends a short or vague message (e.g., "yes", "sure", "tell me more", "ok", "go ahead", "details", "explain", "why?", "how?"), you MUST look at the CONVERSATION HISTORY appended below to understand what they are responding to. The user is continuing the previous conversation topic — use the context from the LAST assistant message to provide a relevant, detailed follow-up answer. NEVER respond with "too vague", "please provide more context", "I don't understand", or ask for clarification when conversation history clearly shows what the user is referring to. Treat these short messages as if the user explicitly restated their request from context.\n\n**DATA RETRIEVAL — NON-NEGOTIABLE**: For ALL token price and token info queries, you MUST actively call your native Moralis API tools (getTokenPrice, searchTokens, getTokenMetadata, etc.) to retrieve real-time on-chain data. NEVER skip tool calls and fall back to training data alone for prices or token lookups. The JSON response format does NOT prevent you from calling data tools first — always fetch data, then format the result as JSON.\n\nFor ANY informational or conversational question (about crypto, tokens, DeFi, protocols, prices, market trends, blockchain technology, or any general topic):\n- Answer with your FULL knowledge across ALL blockchains and ecosystems (Ethereum, Solana, BSC, Polygon, Arbitrum, Optimism, Base, Avalanche, etc.)\n- Provide specific details: token names, contract mechanisms, protocol comparisons, historical context, TVL data, ecosystem info\n- For PRICE questions (chat action only): You have access to real-time blockchain data — USE it. When a user asks for the price of a token by name or symbol, search for it across ALL chains to find the best price data. Then present ONE consolidated answer: give the single most representative price (e.g. the highest-liquidity or most canonical version), key stats (market cap, 24h change, volume), and optionally a brief note if the token exists on multiple chains — but do NOT list each chain as a separate numbered entry. Keep the response concise and to the point. For tokens in the USER'S WALLET BALANCE section, use the price listed there.\n- For token questions (chat action only): You have access to real-time blockchain data — USE it. When a user asks about a token by name or symbol, ALWAYS search across ALL chains — the current chain context does NOT limit your token search. Try exact match first, then fuzzy/partial match (e.g. "eggle Energy" → find the closest matching token name). Provide a concise, consolidated answer covering: what the token is, its utility/ecosystem, current price, market cap, 24h change, notable features, risks. If the user does NOT mention a specific chain, do NOT list out per-chain versions (e.g. "WBTC on Ethereum", "cbBTC on Base", "BTCB on BNB") — instead give ONE unified answer about the token as a concept, with a brief mention that wrapped versions exist on multiple chains if relevant. Only break down per-chain details if the user explicitly asks about a specific chain. If the token does NOT exist on the current chain (${t}), proactively tell the user which of these supported chains DO have it: ${c}. Set token_mentions to [] in this case\n- For DeFi/protocol questions: explain how it works, key features, TVL, supported chains, competitors, pros/cons\n- For market/trend questions: discuss relevant projects, narratives, sector analysis across all chains\n- For POOL / POSITIONS / LIQUIDITY questions: Pool queries are handled by a dedicated pool data pipeline that fetches real-time data from Uniswap V3 Subgraph (The Graph). If you detect a pool-related question, simply return a chat action acknowledging the query — the system will automatically intercept and handle it with accurate on-chain pool data including TVL, volume, APR, fee tiers, and pool addresses.\n- Write detailed paragraphs, use bullet points, include numbers and facts. Minimum 3-5 sentences for simple questions, more for complex topics\n\n## CONTEXT:\nWallet: ${n} | Chain: ${t} (chainId: ${r}) | Native: ${o}${u}${l}\n\n## WHEN TO USE WHICH ACTION:\n- "send_native": user wants to send the native token (${o}) to an address\n- "send_token": user wants to send an ERC20 token to an address\n- "swap_token": user wants to swap/exchange/convert/trade/sell one token for another — covers ALL of the following keywords and patterns, even if only ONE token or NO amount is mentioned:\n - swap: "swap X", "swap X to Y", "swap X for Y", "swap to ETH", "swap native"\n - exchange: "exchange X", "exchange X to Y", "exchange X for Y", "exchange native", "exchange ETH"\n - convert: "convert X to Y", "convert native", "convert ETH to USDC", "convert X"\n - trade: "trade X for Y", "trade X to Y", "trade X"\n - sell (for another token): "sell X for Y", "sell ETH for USDC"\n - Vietnamese: "đổi X sang Y", "đổi X", "đổi native", "đổi ETH sang USDC", "chuyển đổi X", "bán X lấy Y", "hoán đổi X"\n - **CRITICAL**: When the source is the native token (ETH, BNB, MATIC, etc.) → token_in: "native". This MUST be treated as swap_token, never chat.\n → ALWAYS return swap_token. Leave missing params as "". NEVER fall back to chat.\n- "buy_token": user wants to buy a specific token AND the user clearly names a token (symbol or contract address). If user also specifies which token to pay with (e.g. "buy PEPE with USDC", "mua PEPE bằng ETH", "buy PEPE using my USDC"), fill pay_with_symbol and pay_with_address from USER'S WALLET BALANCE. **CRITICAL**: ALWAYS return buy_token if the user clearly names a token they want to buy — even if you cannot find the contract address or token data. Leave contract_address as "" and the app will search for it. NEVER fall back to "chat" just because you lack token data.\n- "buy_token_trending": user wants to buy a token BUT does NOT specify which token — covers ALL of the following patterns:\n - User asks to buy trending tokens: "buy trending tokens", "buy trending", "mua token trending", "mua token đang trending"\n - User asks to buy tokens with strong growth/momentum: "buy tokens pumping", "buy hot tokens", "buy movers", "mua token tăng mạnh", "mua token đang tăng", "mua token tiềm năng"\n - User says "buy a token" / "I want to buy" / "mua token" with NO specific token name or address provided\n - User asks for token recommendations to buy without specifying one\n → ALWAYS return buy_token_trending. Leave all params as "". NEVER fall back to chat or buy_token.\n- "approve_token": user wants to approve a token for a spender\n- "wrap_native": user wants to wrap native token (e.g. ETH → WETH) — also triggered by "deposit" into WETH/wrapped token\n- "unwrap_native": user wants to unwrap (e.g. WETH → ETH) — also triggered by "withdraw" from WETH/wrapped token\n- "send_nft": user wants to send/transfer an NFT\n- "view_nfts": user wants to see/browse their NFT collection\n- "view_balances": user wants to see ALL their token balances/tokens at once — covers ALL of the following patterns (NOT for single token price/info):\n - "show my balance", "view my balance", "check my balance", "what's my balance"\n - "what's in my wallet", "what do I have", "what tokens do I have"\n - "view all tokens", "show all tokens", "list my tokens"\n - "my portfolio", "show portfolio", "wallet overview"\n - Vietnamese: "xem số dư", "số dư của tôi", "kiểm tra số dư", "ví tôi có gì", "tôi có bao nhiêu tiền", "xem ví", "danh mục của tôi"\n → ALWAYS return view_balances for these. Do NOT return chat.\n- "chat": EVERYTHING ELSE — questions, token info, prices, greetings, DeFi explanations, market data, etc.\n\nAll wallet actions (send, swap, buy, approve, wrap, unwrap, send_nft) are chain-specific: use chainId ${r} only.\nFor "chat" action: no chain restriction — use cross-chain knowledge freely.\n\n## OUTPUT FORMAT:\n${lm(s)}\n**LANGUAGE DETECTION — CRYPTO TICKERS**: Crypto token symbols/tickers (ETH, BTC, USDC, BNB, SOL, etc.) are NOT language indicators — they are proper nouns used universally. Detect language ONLY from the surrounding non-ticker text. Examples: "ETHの現在の価格は?" → Japanese. "ETH의 가격은?" → Korean. "Giá ETH?" → Vietnamese. NEVER classify a message as English just because it contains a ticker symbol.\n\nWallet action: {"action":"<type>","message":"<explanation>","parameters":{...}}\nChat/info: {"action":"chat","message":"<YOUR FULL DETAILED ANSWER>","parameters":{},"token_mentions":[],"suggested_actions":[]}\n\n## WALLET ACTION RULES:\n- Return action type IMMEDIATELY even if params are missing (leave as ""). Ask for missing info in "message". NEVER fall back to "chat" just because parameters are incomplete — always return the intended action.\n- **CROSS-CHAIN REQUESTS**: All wallet actions (send, swap, buy, approve, wrap, unwrap, send_nft, view_nfts, view_balances) execute ONLY on the CURRENT chain: ${t} (chainId: ${r}). If the user's message explicitly targets a DIFFERENT chain (e.g. "send on Ethereum", "swap on BSC", "transfer on Polygon", "buy on base") and the current chain is NOT that chain, do NOT execute the wallet action. Instead, return action: "chat" and politely notify the user to switch to the requested chain in the app first. This rule applies to ALL non-chat actions.\n- For ERC20 actions: provide correct contract_address on chainId ${r}. **CRITICAL — CHAIN-SPECIFIC ADDRESSES**: Contract addresses differ on every chain. You MUST obtain the address via your Moralis API tools (searchTokens, getTokenMetadata) for chainId ${r}, OR use the address already present in USER'S WALLET BALANCE. NEVER fill in a contract_address from training knowledge alone — leave it as "" if you cannot verify it via API or wallet balance. If token doesn't exist on this chain, inform user.\n- send_native: ONLY for ${o}. If user says "send ETH" but native ≠ ETH, use send_token.\n- Amount: "max"/"all" → "max". "X%" → "50%". USD formats → always prefix with "$": "5 dollar" → "$5", "5$" → "$5", "$5" → "$5", "5usd" → "$5", "5 đô la" → "$5", "0.01$ eth" → "$0.01", "$0.01 eth" → "$0.01", "5$ usdc" → "$5". The "$" MUST appear in the amount field (not stripped) so the app knows it's a USD value. Otherwise exact number string.\n- Decimals & symbol: always accurate.\n- send_nft: contract_address optional — use nft_name if NFT known by name.\n\n## suggested_actions & token_mentions:\n- suggested_actions: include when offering choices. {"label":"<2-6 words>","prompt":"<message>"}. Max 4. Never include "Buy" (app handles separately). **ABSOLUTELY NEVER** include any option that suggests switching, changing, or selecting a different chain (e.g., "Switch to Ethereum", "Change chain", "Switch network", "Chuyển sang chain khác", "Đổi mạng") — the app handles chain switching separately.\n- token_mentions: ONLY include when the token EXISTS on the CURRENT chain (chainId ${r}) AND you have obtained a VERIFIED contract address via your Moralis API tools (searchTokens, getTokenMetadata, getTokenPrice) for this exact chain.\n - **CRITICAL — CONTRACT ADDRESSES ARE CHAIN-SPECIFIC**: The same token has a DIFFERENT contract address on every chain. USDC on Ethereum ≠ USDC on Base ≠ USDC on Polygon ≠ USDC on BNB Chain. NEVER use an address from your training knowledge — training-data addresses are frequently wrong, hallucinated, or belong to a different chain.\n - **REQUIRED WORKFLOW**: Before populating token_mentions for a token, you MUST call your Moralis API tool (searchTokens or getTokenMetadata) specifying chainId ${r} to retrieve the verified contract address. If the API call fails or returns no result for this chain, set token_mentions: [].\n - If the token address is already available in the USER'S WALLET BALANCE section above, you MAY use that address (it is already verified for chainId ${r}).\n - If you cannot confirm the address via API or wallet balance, set token_mentions: [] — never guess.\n - **Native token**: If the token IS the chain's native token (${o}), use contract_address: "native" — do NOT look up an address.\n - Format: {"symbol":"","contract_address":"<API-verified address on chainId ${r}, or 'native' for the native token>","decimals":<n>}. 2+ tokens → [], use suggested_actions. Non-crypto → [].\n\n## ACTION PARAMS REFERENCE:\nValid actions: send_native, send_token, swap_token, buy_token, buy_token_trending, approve_token, wrap_native, unwrap_native, send_nft, view_nfts, view_balances, chat. NEVER use any other action name.\n\n1. send_native: {"to_address":"","amount":""}\n2. send_token: {"contract_address":"(REQ)","token_symbol":"","to_address":"","amount":"","decimals":""}\n3. swap_token: {"token_in":"<addr or 'native'>","token_in_symbol":"","token_in_decimals":"","token_out":"<addr>","token_out_symbol":"","token_out_decimals":"","amount":""}\n No tokens specified → all params "". Native → token_in:"native".\n4. buy_token: {"token_symbol":"(REQ — always fill this)","contract_address":"(if known and verified, else leave '')","decimals":"","buy_amount":"(opt — amount of the TOKEN BEING BOUGHT that user wants to RECEIVE. Use this when the amount refers to the destination token.)","pay_with_symbol":"(opt — symbol of token user wants to pay with, e.g. 'USDC', 'ETH')","pay_with_address":"(opt — contract address of payment token from WALLET BALANCE, or 'native' for native token)","pay_with_decimals":"(opt — decimals of payment token)","pay_with_amount":"(opt — amount of the PAYMENT TOKEN (token in) user wants to SPEND. Use this when the amount refers to the payment/source token.)"}.\n **CRITICAL — AMOUNT DISAMBIGUATION:**\n The amount in a buy request belongs to EITHER the token being bought OR the payment token. Parse the grammar carefully:\n - "buy PEPE with 10 USDC" → amount=10 belongs to USDC (payment) → pay_with_amount:"10", buy_amount:""\n - "buy 0.02 PCM with USDC" → amount=0.02 belongs to PCM (bought) → buy_amount:"0.02", pay_with_amount:""\n - "dùng 10 USDC mua PEPE" → amount=10 belongs to USDC (payment) → pay_with_amount:"10", buy_amount:""\n - "mua 0.02 PCM bằng USDC" → amount=0.02 belongs to PCM (bought) → buy_amount:"0.02", pay_with_amount:""\n NEVER put the amount of the token being bought into pay_with_amount. NEVER put the payment amount into buy_amount.\n If pay token is native (${o}), set pay_with_address:"native". Both tokens specified as a trade/exchange → swap_token. If you cannot verify the address, set contract_address:'' but ALWAYS return buy_token with the symbol filled. **NATIVE TOKEN**: If the token to buy IS the chain's native token (${o}), set contract_address: "native" directly — no API lookup needed.\n5. buy_token_trending: {} — no parameters needed; app handles discovery of trending/high-growth tokens. **message**: write ONLY a short 1-sentence header (e.g. "Here are the trending tokens on [chain] right now!"). Do NOT write analysis, tips, or explanations.\n6. approve_token: {"contract_address":"(REQ)","token_symbol":"","spender_address":"","amount":"","decimals":""}\n7. wrap_native: {"amount":""}\n8. unwrap_native: {"amount":""}\n9. send_nft: {"contract_address":"(opt)","token_id":"","to_address":"","token_standard":"","amount":"(def 1)","nft_name":""}\n10. view_nfts: {}\n11. view_balances: {} — use ONLY when user wants to see all balances/tokens, NOT for single token price/info queries\n12. chat: {} + token_mentions + suggested_actions — use for ALL informational/conversational requests\n\n## EXAMPLES:\nThese examples show INTENT → ACTION + PARAMETERS mapping only. The "message" content is for illustration — compose your own natural, helpful response based on context.\n\n// --- SEND NATIVE ---\n// Intent: user wants to send the chain's native token to an address\n// Triggers: "send ETH/BNB/MATIC to...", "transfer [native] to...", "chuyển [native] cho..."\n→ action: send_native | parameters: {to_address, amount}\n\n// --- SEND TOKEN ---\n// Intent: user wants to send an ERC20 token to an address\n// Triggers: "send USDC to...", "transfer [token] to...", "gửi [token] cho..."\n→ action: send_token | parameters: {contract_address, token_symbol, to_address, amount, decimals}\n\n// --- SWAP ---\n// Intent: exchange one token for another — trigger with ANY conversion/exchange/trade/sell keyword,\n// even with just ONE token mentioned, no amount, or only the native token as source\n// EN triggers: "swap X", "swap X to Y", "swap X for Y", "swap to ETH", "swap native"\n// "exchange X", "exchange X to Y", "exchange X for Y", "exchange native", "exchange ETH"\n// "convert X to Y", "convert native to USDC", "convert ETH", "convert X"\n// "trade X for Y", "trade X to Y", "trade ETH"\n// "sell X for Y", "sell ETH for USDC" (selling one token FOR another = swap)\n// VI triggers: "đổi X sang Y", "đổi X", "đổi native", "đổi ETH", "chuyển đổi X", "bán X lấy Y", "hoán đổi X"\n// Native source: token_in = "native" (e.g. "exchange ETH" → token_in:"native", token_in_symbol:"ETH")\n// Native dest: token_out = zeroAddress\n// ⚠️ NEVER confuse with wrap/unwrap: those are specifically ETH↔WETH. All other pairs = swap_token.\n→ action: swap_token | parameters: {token_in, token_in_symbol, token_in_decimals, token_out, token_out_symbol, token_out_decimals, amount}\n// Missing params → leave as "", ask for them in message. NEVER downgrade to chat.\n\n// --- WRAP / UNWRAP ---\n// Intent wrap: convert native to wrapped version — also triggered by "deposit"\n// Triggers: "wrap ETH", "deposit ETH", "deposit ETH to WETH", "đổi ETH sang WETH"\n→ action: wrap_native | parameters: {amount}\n\n// Intent unwrap: convert wrapped token back to native — also triggered by "withdraw"\n// Triggers: "unwrap WETH", "withdraw WETH", "convert WETH to ETH", "rút WETH"\n→ action: unwrap_native | parameters: {amount}\n\n// --- VIEW NFTs ---\n// Intent: user wants to see/browse their NFT collection\n// Triggers: "show my NFTs", "what NFTs do I have", "view my NFTs", "xem NFT của tôi"\n→ action: view_nfts | parameters: {}\n\n// --- VIEW BALANCES ---\n// Intent: user wants to see ALL their token balances at once (not a single token query)\n// EN triggers: "show my balance", "view my balance", "check my balance", "what's my balance"\n// "what's in my wallet", "what do I have", "what tokens do I have"\n// "view all tokens", "show all tokens", "list my tokens"\n// "my portfolio", "show portfolio", "wallet overview"\n// VI triggers: "xem số dư", "số dư của tôi", "kiểm tra số dư", "ví tôi có gì"\n// "tôi có bao nhiêu tiền", "xem ví", "danh mục của tôi"\n// ⚠️ Do NOT use view_balances for single-token queries ("price of ETH", "how much USDC is worth") → use chat instead\n→ action: view_balances | parameters: {}\n\n// --- BUY TOKEN TRENDING ---\n// Intent: user wants to buy but does NOT specify a token — or explicitly asks for trending/pumping/high-growth tokens to buy\n// EN triggers: "buy trending tokens", "buy trending", "buy hot tokens", "buy tokens pumping", "buy movers", "I want to buy a token", "buy a token"\n// VI triggers: "mua token trending", "mua token đang trending", "mua token tăng mạnh", "mua token đang tăng", "mua token tiềm năng", "mua token", "tôi muốn mua token"\n// ⚠️ CRITICAL: If user says "buy X" where X is a named token → use buy_token, NOT buy_token_trending\n// ⚠️ CRITICAL: If user gives NO specific token → ALWAYS use buy_token_trending, never chat\n// ⚠️ MESSAGE: ONLY a short 1-sentence header introducing the trending list. NO analysis, NO tips, NO explanations.\n→ action: buy_token_trending | parameters: {} | message: short header only (e.g. "Here are the trending tokens on [chain]!")\n\n// --- BUY TOKEN WITH SPECIFIC PAYMENT ---\n// Intent: user wants to buy a specific token AND specifies which token to pay with\n// EN triggers: "buy PEPE with USDC", "buy PEPE using ETH", "buy PEPE with 10 USDC", "purchase DOGE with my 0.5 ETH"\n// VI triggers: "mua PEPE bằng USDC", "mua PEPE dùng ETH", "mua PEPE bằng 10 USDC", "mua DOGE bằng 0.5 ETH của tôi"\n// → action: buy_token | parameters: {token_symbol, contract_address, decimals, pay_with_symbol, pay_with_address, pay_with_decimals, pay_with_amount}\n// AMOUNT DISAMBIGUATION (critical):\n// "buy PEPE with 10 USDC" → pay_with_amount:"10" buy_amount:"" (10 USDC to spend)\n// "buy 0.02 PCM with USDC" → buy_amount:"0.02" pay_with_amount:"" (0.02 PCM to receive)\n// "mua PEPE bằng 0.5 ETH" → pay_with_amount:"0.5" buy_amount:"" (0.5 ETH to spend)\n// "mua 0.02 PCM bằng USDC" → buy_amount:"0.02" pay_with_amount:"" (0.02 PCM to receive)\n// pay_with_* fields are filled from USER'S WALLET BALANCE. If pay token = native → pay_with_address: "native"\n// ⚠️ This is still buy_token (NOT swap_token) — the user's intent is to BUY, with a specified payment method\n\n// --- TOKEN INFO / PRICE (chat) ---\n// Intent: learn about a token, its price, market data — NOT a wallet action\n// Triggers: "tell me about X", "what is X token", "price of X", "X coin info", "X là gì"\n→ action: chat | compose a detailed answer using real-time data from your tools\n// If token EXISTS on current chain → token_mentions: [{symbol, contract_address, decimals}]\n// If token NOT on current chain → token_mentions: [] but tell user which supported chains have it\n\n// --- CROSS-CHAIN / GENERAL INFO (chat) ---\n// Intent: any question not requiring a wallet action — crypto trends, DeFi, protocols, general Q&A\n// Triggers: "what's trending on X?", "explain DeFi", "how does Uniswap work", anything conversational\n→ action: chat | compose a full, knowledgeable answer; add relevant suggested_actions if helpful\n\n// --- GREETING (chat) ---\n// Intent: greeting or open-ended start\n// Triggers: "hello", "hi", "hey", "xin chào", "bắt đầu"\n→ action: chat | introduce yourself and offer helpful options via suggested_actions`}({walletAddress:d?.address||void 0,chainName:h?.name||void 0,chainId:y||void 0,nativeSymbol:h?.nativeCurrency?.symbol||void 0,walletTokens:r,walletNfts:i,language:t}),u=await Zh({prompt:a,model:"gpt-4.1-mini",stream:!1,systemPrompt:s+n});if(!u.success||!u.data)return void c(w("errorProcessingRequest"),"bot",O.id);const P=u.data.text||"",L=fm(P);L&&L.action&&"chat"!==L.action?await async function(e,n,t){switch(e.action){case"buy_token":await async function(e,n){const t=e.parameters?.token_symbol||"";let r=e.parameters?.contract_address||"",o=18,i=!1;if("native"!==r.toLowerCase()&&r!==Zo||(r=Zo),!r&&t&&h?.nativeCurrency?.symbol&&t.toUpperCase()===h.nativeCurrency.symbol.toUpperCase()&&(r=Zo),r&&r!==Zo)try{const e=await Wh.getTokensDetails([r],p),n=e?.data?.[0];n&&(t&&n.symbol?.toUpperCase()!==t.toUpperCase()?r="":o=n.decimals||18)}catch(R){}if(!r&&t&&d?.address)try{const e=await Xh({address:d.address,chain:m});if(e?.success&&e?.data?.result){const n=e.data.result,i=n.find(e=>e.token_address.toLowerCase()===r.toLowerCase())||n.find(e=>e.symbol.toUpperCase()===t.toUpperCase());i&&(r=i.token_address,o=i.decimals)}if(!r){const e=h?.tokenTrendingDefault||[],[n,i]=await Promise.allSettled([Wh.getTopGainers(p,"24h",10),Wh.getTokensDetails(e,p)]),a=[];"fulfilled"===n.status&&n.value?.data&&a.push(...n.value.data),"fulfilled"===i.status&&i.value?.data&&a.push(...i.value.data);const s=a.find(e=>e.address?.toLowerCase()===r.toLowerCase())||a.find(e=>e.symbol?.toUpperCase()===t.toUpperCase());s&&(r=s.address,o=s.decimals||18)}if(!r&&y)try{const e=await Wh.searchTokensByKey(t,y);if(Array.isArray(e?.data)&&e.data.length>0){const n=e.data.find(e=>e.symbol?.toUpperCase()===t.toUpperCase())||e.data[0];n?.address&&(i=!0,r=n.address,o=n.decimals||18)}}catch(a){}}catch(R){}if(r){c(i?g("buyingOnChain",{symbol:t,chain:h?.name||""}):e.message||g("buyTokenHelp",{symbol:t}),"bot",n),k({descTokenAddress:r,descTokenDecimals:o||18});const a=e.parameters?.pay_with_symbol||"",u=e.parameters?.pay_with_address||"";let l=!1;if(a||u)try{const n=await Xh({address:d?.address||"",chain:m});if(n?.success&&n?.data?.result){const t=n.data.result;let o;if(o="native"===u.toLowerCase()||u===Zo||!u&&a&&h?.nativeCurrency?.symbol&&a.toUpperCase()===h.nativeCurrency.symbol.toUpperCase()?t.find(e=>e.token_address===Zo||e.native_token):t.find(e=>u&&e.token_address.toLowerCase()===u.toLowerCase())||t.find(e=>a&&e.symbol.toUpperCase()===a.toUpperCase()),o){l=!0;const t=e.parameters?.pay_with_amount||"",i=e.parameters?.buy_amount||"";if(t)k({srcTokenAddress:o.token_address,srcTokenDecimals:o.decimals}),await C(100,t,o.token_address,o.decimals);else if(i){let e="";try{const t=n.data.result.find(e=>e.token_address.toLowerCase()===r.toLowerCase());let a=t?.usd_price??null;if(null==a&&r){const e=await Qh({address:r,chain:m});e.success&&null!=e.data?.usd_price&&(a=e.data.usd_price)}const s=o.usd_price??null;null!=a&&null!=s&&s>0&&(e=(parseFloat(i)*a/s).toFixed(8).replace(/\.?0+$/,""))}catch(s){}e?(k({srcTokenAddress:o.token_address,srcTokenDecimals:o.decimals}),await C(100,e,o.token_address,o.decimals)):await x(o.token_address,o.symbol,o.balance_formatted,o.decimals)}else await x(o.token_address,o.symbol,o.balance_formatted,o.decimals)}}}catch(R){}l||await S(r,o)}else c(g("tokenNotFoundOnChain",{symbol:t}),"bot",n),await A()}(e,t);break;case"buy_token_trending":await A();break;case"swap_token":await async function(e,n){const t={...e.parameters||{}},r="native"===t.token_in||t.token_in_symbol?.toUpperCase()===h?.nativeCurrency?.symbol?.toUpperCase(),i="native"===t.token_out||t.token_out_symbol?.toUpperCase()===h?.nativeCurrency?.symbol?.toUpperCase();i&&(t.token_out=Zo);let a=[];if(d?.address)try{const e=await Xh({address:d.address,chain:m});e?.success&&e?.data?.result&&(a=e.data.result)}catch(R){}if(!r&&(t.token_in||t.token_in_symbol)&&a.length>0){const e=t.token_in?a.find(e=>e.token_address.toLowerCase()===t.token_in.toLowerCase()):a.find(e=>e.symbol.toUpperCase()===t.token_in_symbol.toUpperCase());e&&(t.token_in=e.token_address,t.token_in_decimals=String(e.decimals))}if(!i&&(t.token_out||t.token_out_symbol)&&a.length>0){const e=t.token_out?a.find(e=>e.token_address.toLowerCase()===t.token_out.toLowerCase()):a.find(e=>e.symbol.toUpperCase()===t.token_out_symbol.toUpperCase());e&&(t.token_out=e.token_address,t.token_out_decimals=String(e.decimals))}const s=!(!t.token_in&&!r),u=!!t.token_out,l=!!t.amount;if(s&&a.length>0)if(r){const e=a.find(e=>e.native_token);if(!e||Mh(e.balance_formatted||"0").isZero())return c(g("formInsufficientBalance",{balance:"0",symbol:h?.nativeCurrency?.symbol||"native"}),"bot",n),void o(!1)}else if(t.token_in){const e=a.find(e=>e.token_address.toLowerCase()===t.token_in.toLowerCase());if(!e)return c(g("swapTokenNotInWallet",{symbol:t.token_in_symbol||t.token_in}),"bot",n),void o(!1);if(Mh(e.balance_formatted||"0").isZero())return c(g("formInsufficientBalance",{balance:"0",symbol:e.symbol}),"bot",n),void o(!1)}if(s&&u&&l)await async function(e,n,t){try{const r=[];e.token_out&&r.push(e.token_out),e.token_in&&!n&&r.push(e.token_in);let i=18,a=18;if(r.length>0)try{const t=await Wh.getTokensDetails(r,p);if(t?.data)for(const r of t.data)n||r.address.toLowerCase()!==e.token_in?.toLowerCase()||(i=r.decimals||18),r.address.toLowerCase()===e.token_out?.toLowerCase()&&(a=r.decimals||18)}catch{}if(d?.address&&t.length>0)if(n){const n=t.find(e=>e.native_token);let r=n?.balance_formatted||"0";try{const e=await pp({chainId:y,rpcUrl:b});if(e.isGreaterThan(0)){const t=e.times(1e6),o=new Mh(n?.balance||"0").minus(t);r=o.isGreaterThan(0)?Mh(lt(BigInt(o.toFixed(0)),n?.decimals||18)).toFixed():"0"}}catch{}if(e.amount=cm(e.amount,r,n?.usd_price),Mh(r).lte(0))return c(g("formInsufficientBalance",{balance:Mh(r).decimalPlaces(8).toFixed(),symbol:h?.nativeCurrency?.symbol||"native"}),"bot"),void o(!1);if(Mh(r).lt(e.amount))return c(g("swapInsufficientNativeBalance",{balance:Mh(r).decimalPlaces(8).toFixed(),symbol:h?.nativeCurrency?.symbol||"native",amount:e.amount}),"bot"),void o(!1)}else{const n=t.find(n=>n.token_address.toLowerCase()===e.token_in?.toLowerCase());if(!n)return c(g("swapTokenNotInWallet",{symbol:e.token_in_symbol||e.token_in}),"bot"),void o(!1);if(e.amount=cm(e.amount,n.balance_formatted||"0",n.usd_price),Mh(n.balance_formatted||"0").lt(e.amount))return c(g("swapInsufficientTokenBalance",{balance:Mh(n.balance_formatted||"0").decimalPlaces(8).toFixed(),symbol:n.symbol,amount:e.amount}),"bot"),void o(!1)}const s=n?Zo:e.token_in;k({srcTokenAddress:s,descTokenAddress:e.token_out,amount:e.amount,srcTokenDecimals:i,descTokenDecimals:a}),await C(100,e.amount,s,i)}catch(r){c(w("swapEstimationFailed"),"bot")}}(t,r,a);else if(s&&u&&!l)await async function(e,n,t,r){let i=n?18:parseInt(e.token_in_decimals||"18",10),a=parseInt(e.token_out_decimals||"18",10);const s=[];if(e.token_out&&s.push(e.token_out),e.token_in&&!n&&s.push(e.token_in),s.length>0)try{const t=await Wh.getTokensDetails(s,p);if(t?.data)for(const r of t.data)n||r.address.toLowerCase()!==e.token_in?.toLowerCase()||(i=r.decimals||i),r.address.toLowerCase()===e.token_out?.toLowerCase()&&(a=r.decimals||a)}catch{}if(k({descTokenAddress:e.token_out,descTokenDecimals:a}),n)if(t.length>0){const e=t.find(e=>e.native_token),n=h?.nativeCurrency?.symbol||"ETH";let o=e?.balance_formatted||"0";try{const n=await pp({chainId:y,rpcUrl:b});if(n.isGreaterThan(0)){const t=new Mh(e?.balance||"0").minus(n.times(1e6));o=t.isGreaterThan(0)?Mh(lt(BigInt(t.toFixed(0)),e?.decimals||18)).toFixed():"0"}}catch{}k({srcTokenAddress:Zo,srcTokenDecimals:i});const a=[25,50,75,100].map(e=>({id:`percent-${e}`,text:`${e}%`,value:g("buttonUsePercent",{percent:String(e),symbol:n}),action:"select_percent",extraData:{percent:e,tokenAddress:Zo,tokenSymbol:n,tokenDecimals:i,tokenBalance:o}}));c(g("selectAmountToSwap",{symbol:n,balance:o}),"bot",r,a)}else c(w("couldNotFetchBalance"),"bot");else{const n=e.token_in_symbol||"Token";if(k({srcTokenAddress:e.token_in,srcTokenDecimals:i}),t.length>0){const i=t.find(n=>n.token_address.toLowerCase()===e.token_in?.toLowerCase());if(!i)return c(g("swapTokenNotInWallet",{symbol:n}),"bot"),void o(!1);const a=[25,50,75,100].map(e=>({id:`percent-${e}`,text:`${e}%`,value:g("buttonUsePercent",{percent:String(e),symbol:i.symbol}),action:"select_percent",extraData:{percent:e,tokenAddress:i.token_address,tokenSymbol:i.symbol,tokenDecimals:i.decimals||18,tokenBalance:i.balance_formatted}}));c(g("selectAmountToSwap",{symbol:i.symbol,balance:`${i.balance_formatted} (~$${i.usd_value?.toFixed(2)||"0"})`}),"bot",r,a)}else c(w("couldNotFetchBalance"),"bot")}}(t,r,a,n);else if(!s&&u){c(e.message||w("swapChooseFrom"),"bot",n);let r=parseInt(t.token_out_decimals||"18",10);if(t.token_out)try{const e=await Wh.getTokensDetails([t.token_out],p);e?.data?.[0]&&(r=e.data[0].decimals||r)}catch{}l&&k({descTokenAddress:t.token_out,descTokenDecimals:r,amount:t.amount}),await S(t.token_out,r)}else s&&!u?await async function(e,n,t,r,i,a){let s=n?18:parseInt(e.token_in_decimals||"18",10);if(e.token_in&&!n)try{const n=await Wh.getTokensDetails([e.token_in],p);n?.data?.[0]&&(s=n.data[0].decimals||s)}catch{}if(k(n?{srcTokenAddress:Zo,srcTokenDecimals:18,...r?{amount:e.amount}:{}}:{srcTokenAddress:e.token_in,srcTokenDecimals:s,...r?{amount:e.amount}:{}}),r&&t.length>0)if(n){const n=t.find(e=>e.native_token),r=cm(e.amount,n?.balance_formatted||"0",n?.usd_price);if(Mh(n?.balance_formatted||"0").lt(r))return c(g("swapInsufficientNativeBalance",{balance:Mh(n?.balance_formatted||"0").decimalPlaces(8).toFixed(),symbol:h?.nativeCurrency?.symbol||"native",amount:r}),"bot",i),void o(!1);e.amount=r,k({amount:r})}else if(e.token_in){const n=t.find(n=>n.token_address.toLowerCase()===e.token_in.toLowerCase());if(n){const t=cm(e.amount,n.balance_formatted||"0",n.usd_price);if(Mh(n.balance_formatted||"0").lt(t))return c(g("swapInsufficientTokenBalance",{balance:Mh(n.balance_formatted||"0").decimalPlaces(8).toFixed(),symbol:n.symbol,amount:t}),"bot",i),void o(!1);e.amount=t,k({amount:t})}}c(a||g("swapChooseTo",{symbol:e.token_in_symbol||"your token"}),"bot",i);try{o(!0);const e=h?.tokenTrendingDefault||[],[n,t]=await Promise.allSettled([Wh.getTopGainers(p,"24h",5),Wh.getTokensDetails(e,p)]);let r=[];"fulfilled"===n.status&&n.value?.data&&(r=[...n.value.data]),"fulfilled"===t.status&&t.value?.data&&(r=[...t.value.data,...r]),r=r.filter((e,n,t)=>n===t.findIndex(n=>n.address.toLowerCase()===e.address.toLowerCase()));const i=r.map(e=>({id:e?.symbol,text:e?.symbol,value:g("buttonSwapTo",{name:e.name,symbol:e?.symbol||""}),action:"click_swap_dest_token",extraData:{tokenAddress:e?.address||"",symbol:e?.symbol||"",decimals:e?.decimals||18}}));c(g("trendingTokensForReceive",{chain:h?.name||"Unknown"}),"bot",void 0,i)}catch(R){c(w("couldNotLoadTokenList"),"bot")}finally{o(!1)}}(t,r,a,l,n,e.message):await async function(e,n,t,r){if(n&&k({amount:e.amount}),c(r||w("swapChooseToken"),"bot",t),d?.address)try{o(!0);const e=await Xh({address:d.address,chain:m});if(e?.success&&e?.data?.result&&e.data.result.length>0){const n=e.data.result.map(e=>({id:`swap-select-${e.token_address}`,text:`${e.name}: ${e.balance_formatted} ${e.symbol} ($${Mh(e?.usd_value||0).decimalPlaces(2).toFixed()||"0"})`,value:`Swap ${e.symbol}`,action:"suggested_action",fullWidth:!0}));await qd(500),o(!1),c(g("walletBalanceSpendable",{chain:h?.name||"this chain"}),"bot",void 0,n)}else o(!1),c(g("walletNoTokensFound",{chain:h?.name||"this chain"}),"bot")}catch(R){o(!1),c(w("walletFetchError"),"bot")}}(t,l,n,e.message)}(e,t);break;case"view_balances":await T();break;case"view_nfts":await E();break;default:await async function(e,n,t){const{isTransactionAction:r}=await Promise.resolve().then(()=>mp),{getNftContractMetadata:i}=await Promise.resolve().then(()=>$h),a=e.action;if("send_token"===a&&!e.parameters?.contract_address&&!e.parameters?.token_symbol&&d?.address){try{const e=await Xh({address:d.address,chain:m});if(e?.success&&e?.data?.result&&e.data.result.length>0){c(w("sendTokenChoose"),"bot",t),o(!0),await qd(500);const n=e.data.result.map(e=>({id:`send-select-${e.token_address}`,text:`${e.name}: ${e.balance_formatted} ${e.symbol} ($${Mh(e?.usd_value||0).decimalPlaces(2).toFixed()||"0"})`,value:g("buttonSendToken",{symbol:e.symbol}),action:"suggested_action",fullWidth:!0}));await qd(500),o(!1),c(g("walletBalanceSpendable",{chain:h?.name||"this chain"}),"bot",void 0,n)}else o(!1),c(g("walletNoTokensFound",{chain:h?.name||"this chain"}),"bot")}catch(R){o(!1),c(w("walletFetchError"),"bot")}return}if("send_nft"===a&&!e.parameters?.contract_address&&!e.parameters?.token_id&&!e.parameters?.nft_name&&d?.address){const{getDataPackage:e}=await Promise.resolve().then(()=>Kd),n=e()?.linkViewNft;return void c(n?g("sendNftViaWebsiteWithLink",{link:n}):w("sendNftViaWebsite"),"bot")}if("send_nft"===a&&!jn(e.parameters?.contract_address||"")&&(e.parameters?.nft_name||e.parameters?.token_id)&&d?.address){try{o(!0);const n=await _h({address:d.address,chain:m,limit:100,exclude_spam:!1});if(n?.success&&n?.data?.result){const r=n.data.result,i=(e.parameters?.nft_name||"").toLowerCase(),a=e.parameters?.token_id||"",s=e=>{const n=(e.normalized_metadata?.name||e.name||"").toLowerCase(),t=(e.name||"").toLowerCase(),r=i&&(n.includes(i)||t.includes(i)),o=a&&e.token_id===a;return i&&a?r&&o:i?r:o},u=!i&&!!a,l=u?r.filter(s):[],f=u?1===l.length?l[0]:null:r.find(s);if(u&&l.length>1){const n=l.map(n=>{const t=n.normalized_metadata?.name||n.name||`#${n.token_id}`,r=n.normalized_metadata?.image||n.media?.original_media_url||"";return{id:`${n.token_address}-${n.token_id}`,text:`${t} (${n.symbol||n.contract_type}) #${n.token_id}`,value:g("buttonSendNft",{name:t}),action:"select_nft_to_send",fullWidth:!0,extraData:{contractAddress:n.token_address,tokenId:n.token_id,tokenStandard:n.contract_type,name:t,symbol:n.symbol,amount:n.amount,image:r,toAddress:e.parameters?.to_address||""}}}),r=l.map((e,n)=>{const t=e.normalized_metadata?.name||e.name||`#${e.token_id}`,r=e.normalized_metadata?.image||e.media?.original_media_url||"";return`${n+1}. ${r?`![${t}](${r})\n`:"🖼️ "}**${t}**\n ${e.symbol||e.contract_type} | Token ID: ${e.token_id}`}).join("\n\n");o(!1),c(g("nftMultipleMatchesForTokenId",{count:String(l.length),tokenId:a})+"\n\n"+r,"bot",t,n)}else if(f){const n=f.normalized_metadata?.name||f.name||`#${f.token_id}`,r=f.normalized_metadata?.image||f.media?.original_media_url||"",o={contract_address:f.token_address,token_id:f.token_id,to_address:e.parameters?.to_address||"",token_standard:f.contract_type||"",amount:e.parameters?.amount||"1",maxAmount:f.amount||"1",nft_name:n};c(e.message||g("nftSendReview",{name:n,standard:f.contract_type||"NFT",tokenId:f.token_id}),"bot",t,void 0,{action:"send_nft",parameters:o,status:"pending",nftInfo:{name:n,image:r||void 0,tokenId:f.token_id,contractAddress:f.token_address,tokenStandard:f.contract_type||void 0}})}else c(g("nftNotFoundInWallet",{name:i||a}),"bot",t)}else c(w("nftNoCollection"),"bot",t)}catch(R){c(w("nftFetchError"),"bot",t)}finally{o(!1)}return}const s=r(a);let u,l,f={...e.parameters||{}};const p=["send_token","approve_token"].includes(a)&&(f.contract_address||f.token_symbol),v="send_native"===a||"wrap_native"===a,k="unwrap_native"===a,A="send_nft"===a&&f.contract_address;if(p&&d?.address)try{const e=await Xh({address:d.address,chain:m});if(e?.success&&e?.data?.result){const n=e.data.result,t=f.contract_address?n.find(e=>e.token_address.toLowerCase()===f.contract_address.toLowerCase()):n.find(e=>e.symbol.toUpperCase()===f.token_symbol.toUpperCase());t&&(f={...f,contract_address:t.token_address,decimals:String(t.decimals)},u={symbol:t.symbol,name:t.name,balance:t.balance,balanceFormatted:t.balance_formatted,usdValue:t.usd_value,usdPrice:t.usd_price,decimals:t.decimals,logo:t.logo||t.thumbnail,contractAddress:t.token_address})}}catch(R){}if(p&&!u&&"send_token"===a){const e=f.token_symbol||f.contract_address||"this token";return c(g("sendTokenNotInWallet",{symbol:e}),"bot",t),void o(!1)}if(p&&!u&&f.contract_address)try{const e=await Qh({address:f.contract_address,chain:m});e?.success&&e?.data&&(u={symbol:e.data.symbol,name:e.data.name,balance:"0",balanceFormatted:"0",usdPrice:e.data.usd_price,decimals:e.data.decimals,logo:e.data.logo,contractAddress:f.contract_address},f={...f,decimals:String(e.data.decimals)})}catch(R){}if(v&&d?.address)try{const e=await Xh({address:d.address,chain:m});if(e?.success&&e?.data?.result){const n=e.data.result.find(e=>e.native_token);if(n){let e=n.balance_formatted,t=n.balance;try{const{estimateTransactionFee:r}=await Promise.resolve().then(()=>mp),o=new Mh(n.balance),i="0x"+BigInt(o.toFixed(0)).toString(16),a=await r({from:d.address,to:d.address,data:"0x",value:i,chainId:y,rpcUrl:b});if(a.isGreaterThan(0)){const r=o.minus(a);r.isGreaterThan(0)?(t=r.toFixed(0),e=Mh(lt(BigInt(r.toFixed(0)),n.decimals)).toFixed()):(t="0",e="0")}}catch{}u={symbol:n.symbol,name:n.name,balance:t,balanceFormatted:e,usdValue:n.usd_value,usdPrice:n.usd_price,decimals:n.decimals,logo:n.logo||n.thumbnail,contractAddress:Zo}}else{const e=await Qh({address:Zo,chain:m});e?.success&&e?.data&&(u={symbol:e.data.symbol,name:e.data.name,balance:"0",balanceFormatted:"0",usdValue:0,usdPrice:e.data.usd_price,decimals:e.data.decimals,logo:e.data.logo,contractAddress:Zo})}}}catch(R){}if(k&&d?.address)try{const e=await Xh({address:d.address,chain:m});if(e?.success&&e?.data?.result){const n=e.data.result,t=`W${h?.nativeCurrency?.symbol||"ETH"}`,r=n.find(e=>e.symbol.toUpperCase()===t.toUpperCase());r&&(u={symbol:r.symbol,name:r.name,balance:r.balance,balanceFormatted:r.balance_formatted,usdValue:r.usd_value,usdPrice:r.usd_price,decimals:r.decimals,logo:r.logo||r.thumbnail,contractAddress:r.token_address})}}catch(R){}if(A){try{const e=await i({address:f.contract_address,chain:m});e?.success&&e?.data&&(e.data.contract_type&&(f={...f,token_standard:e.data.contract_type}),!f.nft_name&&e.data.name&&(f={...f,nft_name:e.data.name}))}catch(R){}if(d?.address)try{const e=await _h({address:d.address,chain:m,limit:100,exclude_spam:!1});if(e?.success&&e?.data?.result){const n=e.data.result.find(e=>e.token_address.toLowerCase()===f.contract_address.toLowerCase()&&e.token_id===f.token_id);if(!n){const e=f.nft_name||`#${f.token_id||f.contract_address}`;return c(g("nftNotFoundInWallet",{name:e}),"bot",t),void o(!1)}{f={...f,amount:f.amount||"1",maxAmount:n.amount||"1"};const e=n.normalized_metadata?.image||n.media?.original_media_url||"";l={name:n.normalized_metadata?.name||n.name||f.nft_name||`#${n.token_id}`,image:e||void 0,tokenId:n.token_id,contractAddress:n.token_address,tokenStandard:n.contract_type||f.token_standard||void 0}}}}catch(R){}}f.amount&&u?.balanceFormatted&&("send_token"===a||"send_native"===a||"wrap_native"===a||"unwrap_native"===a)&&(f.amount=cm(f.amount,u.balanceFormatted,u.usdPrice)),s?c(e.message||"Please review and complete the form below.","bot",t,void 0,{action:e.action,parameters:f,status:"pending",tokenInfo:u,nftInfo:l}):c(e.message||n,"bot",t)}(e,n,t)}}(L,P,O.id):L&&"chat"===L.action?await async function(e,n,t,r){const o=e.token_mentions||[],i=e.suggested_actions||[],a=[];o.length>0&&(await Promise.all(o.map(async e=>{let n=e.contract_address||"",t=e.decimals||18;if("native"===n.toLowerCase()&&(n=Zo),n===Zo){const n=r?.find(e=>e.native_token);return n?{symbol:e.symbol||n.symbol,contract_address:Zo,decimals:18}:e.symbol?{symbol:e.symbol,contract_address:Zo,decimals:18}:null}if(n&&n!==Zo){const o=r?.find(t=>t.token_address.toLowerCase()===n.toLowerCase()&&t.symbol.toUpperCase()===e.symbol.toUpperCase());if(o){try{const e=await Wh.getTokensDetails([n],p);t=e?.data?.[0]?.decimals??t}catch{}return{symbol:e.symbol,contract_address:n,decimals:t}}try{const r=await Wh.getTokensDetails([n],p),o=r?.data?.[0];if(o&&o.symbol?.toUpperCase()===e.symbol.toUpperCase())return{symbol:e.symbol,contract_address:n,decimals:o.decimals??t};n=""}catch{n=""}}if(!n&&r){const o=r.find(n=>n.symbol.toUpperCase()===e.symbol.toUpperCase());if(o){n=o.token_address;try{const e=await Wh.getTokensDetails([n],p);t=e?.data?.[0]?.decimals??t}catch{}}}return n?{symbol:e.symbol,contract_address:n,decimals:t}:null}))).filter(e=>null!==e).forEach(e=>{a.push({id:`buy-${e.symbol}`,text:`💰 Buy ${e.symbol}`,value:g("buttonBuySymbol",{symbol:e.symbol}),action:"click_buy_item_token_button",extraData:{tokenAddress:e.contract_address,symbol:e.symbol,decimals:e.decimals},fullWidth:!0})}),i.length>0&&i.forEach((e,n)=>{a.push({id:`suggested-${n}-${e.label}`,text:e.label,value:e.prompt,action:"suggested_action",fullWidth:!0})}),a.length>0?c(e.message||n,"bot",t,a):c(e.message||n,"bot",t)}(L,P,O.id,r):c(P,"bot",O.id)}catch(B){c(w("errorProcessingRequest"),"bot",O.id)}o(!1),await qd(50),Dh.isDesktop&&u.current?.focus()},[n,r,i,c,l,d?.address,v,h?.name,h?.nativeCurrency?.symbol,h?.tokenTrendingDefault,y,f,m,p,g,S,x,C,A,w,k,b,T,E])}}({inputValue:E,setInputValue:T,isTyping:S,setIsTyping:x,replyingTo:M,setReplyingTo:O,setShowSuggestions:I,inputRef:L,messages:p,addMessage:m,updateMessageType:A,account:q,chainData:V,chainType:W,chainTypeMoralis:z,chainId:Y,isChainSupported:J,rpcUrl:X,t:d,ti:h,updateDataBuyToken:$,showTrendingTokens:ee,showMyNFTs:ne,showMyBalances:te,onClickItemTokenToBuy:re,onClickItemUserBalanceToBuy:oe,showPreviewToBuy:ie}),{handleButtonClick:se}=function(e){const{addMessage:n,handleSendMessage:t,setIsTyping:r,setShowSuggestions:o,onClickItemTokenToBuy:i,onClickItemUserBalanceToBuy:a,showPreviewToBuy:s,onTransaction:u,updateMessageText:l,ti:c,t:f,account:d,chainId:h,chainData:p,chainTypeMoralis:m,rpcUrl:y,updateDataBuyToken:v,getDataBuyToken:b,inputRef:w}=e;return{handleButtonClick:j.useCallback(async(e,g,k)=>{try{if("suggested_action"===g)return o(!1),void(await t(e));if(n(e,"user"),o(!1),r(!0),g)switch(await qd(500),g){case"click_buy_item_token_button":await i(k?.tokenAddress||"",k?.decimals||18);break;case"click_balance_item_user_to_buy_button":await a(k?.tokenAddress||"",k?.symbol||"",k?.balance||"",k?.decimals||18);break;case"select_percent":await s(k?.percent||0,k?.tokenBalance||"",k?.tokenAddress||void 0,k?.tokenDecimals||void 0);break;case"confirm_swap":{if(!k?.tx||!u){n(f("txDataNotAvailable"),"bot");break}const e=k.tx,t={from:d?.address||"",to:e.to,data:e.data,value:e.value,chainId:h},o=n(f("txProcessing"),"bot");try{r(!1);const e=await u(t),n=p?.blockExplorers?.default?.url,i=e.transactionHash?n?` [View on Explorer](${n}/tx/${e.transactionHash})`:` Tx: ${e.transactionHash}`:"";if("success"===e.status&&e.transactionHash){l(o.id,f("txSubmitted")+i);try{await qd(2e3);const n=await lp({transactionHash:e.transactionHash,chainId:h||1,rpcUrl:y});l(o.id,("success"===n.status?f("txConfirmedSwap"):f("txRevertedSwap"))+i)}catch{l(o.id,f("txTimeout")+i)}}else"success"===e.status?l(o.id,f("txSuccessfulSwap")):l(o.id,f("txFailed")+(e.error?`\nError: ${e.error}`:""))}catch(A){l(o.id,f("txFailed"))}break}case"approve_for_swap":{const e=k?.tokenAddress||"",t=k?.spenderAddress||"",o=k?.tokenSymbol||"token",i=k?.tx;if(!e||!t||!u){n(f("approvalDataNotAvailable"),"bot");break}const a=k?.amountInWei||void 0,s=fp({tokenAddress:e,spenderAddress:t,fromAddress:d?.address||"",chainId:h,tokenSymbol:o,amount:a}),l={from:s.from,to:s.to,data:s.data,value:s.value,chainId:s.chainId};n(c("approving",{symbol:o}),"bot");try{r(!1);const e=await u(l);let t="success"===e.status;if("success"===e.status&&e.transactionHash)try{t="success"===(await lp({transactionHash:e.transactionHash,chainId:h||1,rpcUrl:y})).status}catch{t=!0}t?(n(c("approvalSuccess",{symbol:o}),"bot"),n(f("approvalConfirmSwap"),"bot",void 0,[{id:"confirm-swap-after-approve",text:f("confirmSwapButton"),value:f("swapConfirmValue"),action:"confirm_swap",fullWidth:!0,extraData:{tx:i}}])):n(f("approvalFailed")+(e.error?`\nError: ${e.error}`:""),"bot")}catch(A){n(f("approvalFailed"),"bot")}break}case"click_swap_dest_token":{const e=k?.tokenAddress||"",t=k?.symbol||"";v({descTokenAddress:e,descTokenDecimals:k?.decimals||18});const r=b(),o=r.srcTokenAddress||"",i=o===Zo,a=r.amount||"";try{const s=await Xh({address:d?.address||"",chain:m});if(s?.success&&s?.data?.result){const u=s.data.result;let l,m="",b="0";if(i){const e=u.find(e=>e.native_token);m=p?.nativeCurrency?.symbol||"ETH",b=e?.balance_formatted||"0",l=e?.usd_price}else{const e=u.find(e=>e.token_address.toLowerCase()===o.toLowerCase());e&&(m=e.symbol,b=e.balance_formatted,l=e.usd_price)}if(a&&m){const t=cm(a,b,l),s=r.srcTokenDecimals||18,u=i?Zo:o;v({amount:t});try{const r=Qo(t,s).toString(),o=await np({chainId:h,tokenIn:u,tokenInAmount:r,tokenOut:e,tokenOutRecipient:d?.address||"",slippage:"auto",accesstoken:"d6c45897b8f6"});if(o.success&&o.data){const e=o.data,t=e.tokenIn,a=e.tokenOut,s=Mh(lt(BigInt(t.amount||0),t.decimals)).decimalPlaces(8).toFormat(),l=Mh(lt(BigInt(a.amount||0),a.decimals)).decimalPlaces(8).toFormat();let m=!1;if(!i&&d?.address&&e.tx?.to)try{const n=await cp({tokenAddress:u,ownerAddress:d.address,spenderAddress:e.tx.to,chainId:h,rpcUrl:y});m=Mh(n.toString()).isLessThan(r)}catch{m=!0}const v=e.estimatedTransactionFee?.total?Mh(e.estimatedTransactionFee.total):Mh(0);let b=Mh(0);if(m&&d?.address)try{const n=fp({tokenAddress:u,spenderAddress:e.tx?.to||"",fromAddress:d.address,chainId:h,amount:r});b=await hp({from:d.address,to:n.to,data:n.data,chainId:h,rpcUrl:y})}catch{}const w=v.plus(b),g=p?.nativeCurrency?.symbol||"native";let k="",A=!1;if(d?.address&&w.isGreaterThan(0))try{const e=await dp({address:d.address,chainId:h,rpcUrl:y});e.isLessThan(w)&&(A=!0,k=c("swapFeeWarning",{symbol:g,balance:Mh(lt(BigInt(e.toFixed(0)),18)).decimalPlaces(8).toFormat(),needed:Mh(lt(BigInt(w.toFixed(0)),18)).decimalPlaces(8).toFormat()}))}catch{}const E=`From: ${s} ${t.symbol}\n⬇️\nTo: ${l} ${a.symbol}\n\n${k}\n`;A?n(E,"bot"):m?n(E+c("swapNeedApprove",{symbol:t.symbol}),"bot",void 0,[{id:"approve-for-swap",text:c("swapApproveButton",{symbol:t.symbol}),value:c("swapApproveValue",{symbol:t.symbol}),action:"approve_for_swap",fullWidth:!0,extraData:{tokenAddress:u,spenderAddress:e.tx.to,tokenSymbol:t.symbol,amountInWei:r,tx:e.tx}}]):n(E+f("swapReadyToProceed"),"bot",void 0,[{id:"confirm-swap",text:f("swapConfirmYes"),value:f("swapConfirmValue"),action:"confirm_swap",extraData:{tx:e.tx}}])}else n(c("swapEstimationError",{error:o.errorMessage||o.error||"Unknown error"}),"bot")}catch(A){n(f("swapEstimationFailed"),"bot")}}else if(m&&parseFloat(b)>0){const e=r.srcTokenDecimals||18,i=[25,50,75,100].map(n=>({id:`percent-${n}`,text:`${n}%`,value:c("buttonUsePercent",{percent:String(n),symbol:m}),action:"select_percent",extraData:{percent:n,tokenAddress:o,tokenSymbol:m,tokenDecimals:e,tokenBalance:b}}));n(c("swapSelectAmount",{from:m,to:t,balance:b}),"bot",void 0,i)}else n(f("swapNoSourceToken"),"bot")}else n(f("couldNotFetchBalance"),"bot")}catch(A){n(f("couldNotLoadBalance"),"bot")}break}case"select_nft_to_send":{const e=k?.name||"NFT",t=k?.contractAddress||"",r=k?.tokenId||"",o=k?.tokenStandard||"ERC721",i=k?.amount||"1",a=k?.image||"",s=k?.toAddress||"";n(c("nftSendReview",{name:e,standard:o,tokenId:r}),"bot",void 0,void 0,{action:"send_nft",parameters:{contract_address:t,token_id:r,to_address:s,token_standard:o,amount:i,maxAmount:i,nft_name:e},status:"pending",nftInfo:{name:e,image:a||void 0,tokenId:r,contractAddress:t,tokenStandard:o}});break}default:n(c("actionExecutedFor",{action:g,value:e}),"bot")}else await qd(500),n(c("receivedButtonValue",{value:e}),"bot");r(!1),Dh.isDesktop&&w.current?.focus()}catch(E){n(f("errorProcessingRequest"),"bot"),r(!1)}},[n,t,i,a,s,u,c,d?.address,h,f,p?.blockExplorers?.default?.url,p?.nativeCurrency?.symbol,l,y,v,b,m])}}({addMessage:m,handleSendMessage:ae,setIsTyping:x,setShowSuggestions:I,onClickItemTokenToBuy:re,onClickItemUserBalanceToBuy:oe,showPreviewToBuy:ie,onTransaction:t,updateMessageText:b,ti:h,t:d,account:q,chainId:Y,chainData:V,chainTypeMoralis:z,rpcUrl:X,updateDataBuyToken:$,getDataBuyToken:_,inputRef:L}),{handleActionFormSubmit:ue}=function(e){const{updateMessageAction:n,updateMessageActionParameters:t,chainId:r,account:o,chainType:i,chainData:a,rpcUrl:s,ti:u,t:l,addMessage:c,onTransaction:f,setIsTyping:d}=e;return{handleActionFormSubmit:j.useCallback(async(e,h,p)=>{try{if(n(p,"submitted"),"swap_token"===e){let e=18;if(h.token_in&&h.token_in!==Zo)try{const n=await Wh.getTokensDetails([h.token_in],i);n?.data?.[0]&&(e=n.data[0].decimals||18)}catch(m){}const t=Qo(h.amount||"0",e).toString(),f=await np({chainId:r,tokenIn:h.token_in||"",tokenInAmount:t,tokenOut:h.token_out||"",tokenOutRecipient:o?.address||"",slippage:"auto",accesstoken:"d6c45897b8f6"});if(!f.success||!f.data)return n(p,"pending"),void c(u("swapEstimationError",{error:f.errorMessage||f.error||"Unknown error"}),"bot");const d=f.data,y=d.tokenIn,v=d.tokenOut,b=Mh(lt(BigInt(y.amount||0),y.decimals)).decimalPlaces(8).toFormat(),w=Mh(lt(BigInt(v.amount||0),v.decimals)).decimalPlaces(8).toFormat(),g=!h.token_in||h.token_in===Zo;let k=!1;if(!g&&o?.address&&d.tx?.to)try{const e=await cp({tokenAddress:h.token_in,ownerAddress:o.address,spenderAddress:d.tx.to,chainId:r,rpcUrl:s});k=Mh(e.toString()).isLessThan(t)}catch(m){}const A=d.estimatedTransactionFee?.total?Mh(d.estimatedTransactionFee.total):Mh(0);let E=Mh(0);if(k&&o?.address)try{const e=fp({tokenAddress:h.token_in,spenderAddress:d.tx?.to||"",fromAddress:o.address,chainId:r,amount:t});E=await hp({from:o.address,to:e.to,data:e.data,chainId:r,rpcUrl:s})}catch(m){}const T=A.plus(E),S=a?.nativeCurrency?.symbol||"native";let x="",C=!1;if(o?.address&&T.isGreaterThan(0))try{const e=await dp({address:o.address,chainId:r,rpcUrl:s});e.isLessThan(T)&&(C=!0,x=u("swapFeeWarning",{symbol:S,balance:Mh(lt(BigInt(e.toFixed(0)),18)).decimalPlaces(8).toFormat(),needed:Mh(lt(BigInt(T.toFixed(0)),18)).decimalPlaces(8).toFormat()}))}catch(m){}const I=`From: ${b} ${y.symbol}\n⬇️\nTo: ${w} ${v.symbol}\n\n${x}\n`;return void(C?(n(p,"pending"),c(I,"bot")):k?(n(p,"success"),c(I+u("swapApprovalRequired",{symbol:y.symbol}),"bot",void 0,[{id:"approve-swap-actionform",text:u("swapApproveButton",{symbol:y.symbol}),value:u("swapApproveValue",{symbol:y.symbol}),action:"approve_for_swap",extraData:{tokenAddress:h.token_in,spenderAddress:d.tx.to,tokenSymbol:y.symbol,amountInWei:t,tx:d.tx},fullWidth:!0}])):(n(p,"success"),c(I+l("swapReadyToProceed"),"bot",void 0,[{id:"confirm-swap-actionform",text:l("swapConfirmYes"),value:l("swapConfirmValue"),action:"confirm_swap",extraData:{tx:d.tx}}])))}const v=up({action:e,parameters:h,fromAddress:o?.address||"",chainId:r||1}),b={from:v.from,to:v.to,data:v.data,value:v.value,chainId:v.chainId};if(["send_token","send_native","send_nft","wrap_native","unwrap_native","approve_token"].includes(e)&&o?.address)try{const e=a?.nativeCurrency?.symbol||"native",t=await hp({from:v.from,to:v.to,data:v.data,value:v.value&&"0"!==v.value?`0x${BigInt(v.value).toString(16)}`:void 0,chainId:r,rpcUrl:s});if(t.isGreaterThan(0)){const i=await dp({address:o.address,chainId:r,rpcUrl:s});if(i.isLessThan(t))return n(p,"pending"),void c(u("txInsufficientGas",{symbol:e,balance:Mh(lt(BigInt(i.toFixed(0)),18)).decimalPlaces(8).toFormat(),fee:Mh(lt(BigInt(t.toFixed(0)),18)).decimalPlaces(8).toFormat()}),"bot")}}catch(y){}if(!f)return n(p,"pending"),void c(l("txNoHandler"),"bot");d(!1);const w=await f(b);if("success"===w.status&&w.transactionHash){const o=a?.blockExplorers?.default?.url,i=o?` [View on Explorer](${o}/tx/${w.transactionHash})`:` Tx: ${w.transactionHash}`;try{if(await qd(4e3),"success"===(await lp({transactionHash:w.transactionHash,chainId:r||1,rpcUrl:s})).status){if(n(p,"success"),t(p,h),"approve_token"===e)c(u("approvalSuccess",{symbol:h.token_symbol||h.contract_address||"Token"})+i,"bot");else if("send_nft"===e){const e=h.to_address||h.recipient||"",n=e?`${e.slice(0,6)}...${e.slice(-4)}`:"";c(u("txSuccessfulSendNft",{name:h.nft_name||h.token_symbol||"NFT",tokenId:h.token_id||"",to:n})+i,"bot")}else if("send_token"===e||"send_native"===e){const n=h.to_address||h.recipient||"",t=n?`${n.slice(0,6)}...${n.slice(-4)}`:"";c(u("send_native"===e?"txSuccessfulSendNative":"txSuccessfulSendToken",{amount:h.amount||"",symbol:h.token_symbol||("send_native"===e?a?.nativeCurrency?.symbol||"native":"Token"),to:t})+i,"bot")}else if("wrap_native"===e){const e=a?.nativeCurrency?.symbol||"native";c(u("txSuccessfulWrapNative",{amount:h.amount||"",from:e,to:`W${e}`})+i,"bot")}else if("unwrap_native"===e){const e=a?.nativeCurrency?.symbol||"native";c(u("txSuccessfulUnwrapNative",{amount:h.amount||"",from:`W${e}`,to:e})+i,"bot")}}else n(p,"pending"),c(l("txReverted")+"\n"+i,"bot")}catch{n(p,"success"),c(l("txTimeout")+"\n"+i,"bot")}}else"success"===w.status?n(p,"success"):(n(p,"pending"),c(l("txFailed")+(w.error?`\nError: ${w.error}`:""),"bot"))}catch(v){n(p,"pending"),c(u("txError",{message:v instanceof Error?v.message:"Unknown error"}),"bot")}},[n,t,r,o?.address,i,a?.nativeCurrency?.symbol,a?.blockExplorers?.default?.url,s,u,l,c,f])}}({updateMessageAction:y,updateMessageActionParameters:v,chainId:Y,account:q,chainType:W,chainData:V,rpcUrl:X,ti:h,t:d,addMessage:m,onTransaction:t,setIsTyping:x}),le=j.useMemo(()=>{const e=(e=[])=>e.map(e=>({...e,id:nh(),action:async()=>{I(!1),await se(e.text,"suggested_action")}})),n=[{id:"ask",icon:"❓",text:d("suggestionAskText"),action:async()=>{I(!1),x(!0),m(d("suggestionAskUserMessage"),"user"),await qd(1e3),x(!1),m(d("suggestionAskBotReply"),"bot")}},{id:"buy",icon:"💰",text:d("suggestionBuyText"),action:async()=>{I(!1),m(d("suggestionBuyText"),"user"),jn(q?.address||"")&&J?await ee():(x(!0),await qd(1e3),jn(q?.address||"")&&!J?m(d("walletConnectedChainUnsupported"),"bot"):m(d("walletNotConnected"),"bot"),x(!1))}}],t=s?e(s):n;return u?.length?[...t,...e(u)]:t},[s,u,se,m,q?.address,ee,d,J]),ce=j.useCallback(async(e,n,t)=>{I(!1),N(e=>({...e,[t]:!0}));try{await ue(e,n,t)}finally{N(e=>({...e,[t]:!1}))}},[ue]),fe=j.useCallback(e=>{g([e])},[g]),de=j.useCallback(e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),ae())},[ae]),he=j.useCallback(()=>{const e=window.getSelection();e&&e.toString().length>0||n()},[n]),pe=e=>{if(0===e)return!0;const n=new Date(p[e].timestamp),t=new Date(p[e-1].timestamp);return n.setHours(0,0,0,0),t.setHours(0,0,0,0),n.getTime()!==t.getTime()};return j.useEffect(()=>{B.current?.scrollIntoView({behavior:"smooth"})},[p]),j.useEffect(()=>{e?(L.current&&Dh.isDesktop&&L.current.focus(),B.current?.scrollIntoView({behavior:"instant"}),D.current&&F.current?Date.now()-F.current>12e5&&I(!0):I(!0),F.current=null,D.current=!1,setTimeout(()=>{B.current?.scrollIntoView({behavior:"smooth"})},50)):(F.current=Date.now(),D.current=!U.current)},[e]),j.useEffect(()=>{const t=t=>{"Escape"===t.key&&e&&n()};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e,n]),e?/* @__PURE__ */k.jsx("div",{className:"chat-modal-overlay"+("bottom-left"===r?" chat-modal-overlay--left":""),onClick:he,role:"dialog","aria-modal":"true","aria-labelledby":"chat-modal-title",children:/* @__PURE__ */k.jsxs("div",{className:"chat-modal",style:o,onClick:e=>e.stopPropagation(),children:[
31
31
  /* @__PURE__ */k.jsxs("div",{className:"chat-modal-header",children:[
32
32
  /* @__PURE__ */k.jsxs("div",{className:"chat-modal-header-title",children:[
33
- /* @__PURE__ */k.jsxs("div",{className:"chat-modal-header-left",children:[
34
- /* @__PURE__ */k.jsx("div",{className:"keyring-logo",children:/* @__PURE__ */k.jsx("img",{src:l||D?.icon||"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACwAAAA8CAYAAAAdUliaAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAOdEVYdFNvZnR3YXJlAEZpZ21hnrGWYwAADAhJREFUeAHtWUtsnNUVPufOw2NAjS3UqqwyZtNVhaO2cbyoYqMKlU2xaRKIQPUMBQqllcegFgVVeBwEIZWKbQQElYfHoDYPUo1pqdpN40EgOSatxlm1KzzuhlZt5Umblsbz//dw7ut/zCOZQLLLkWb+131899zvnse9ANfkmsQE4VMIlcf6oJGaACkHICm2gU8bIJIV3HusAldZLgswLTDQG5KTQFjgmtuA+B/5X12BCEBscJNzuO/4PFwl6RowvbVnhIEuMK4soKqmAGKn+jUQWMQ9JxbhCsslAdPRu7MgvEkuOshPrEQxyFj7QsBtgDutI66Dt3Ur7l+qwRWSiwLWXK1zofxSPfb+xN7dfMnZH1xC20pKkGrM4PhnB962k+xytS8FjWyP5/f1UqJ+5rada+3Kae0n/DLfDjZ9cQOwmtYvNwFpHveenIErBbhvZSXb60Oxh/BbPR729/hIaY+gV+JG2oNKyvdnfj8+XGtuhI5/e4K5UuTWskGzJCHG9WBxwjrze+bT8hujYBNCLDOwbI8PwD/KeIAKcFoK6vEI+cfvRQkY+NL+dsD3MWia7qJXBo9vg781dbn8Fu7GT4plbiYbbZYQySrHElStI8r1AC7f+4vVFmB414ki+IkBLm6014nWWtPyDkik1umtfZceYLQP9ZepruQSvnidKQBak1bD+uqh1nKPT5Dh7zwDYL6j0vpGWiaKL9731Zbp5YXJ1gTKIU3aIrdcxxpre7Qbb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jzv/QUSVNMP6lI0NL3bZ9VQA7ee3plVzSw4leiSPRU1ULupaRMv/lF4Yrl9PmVQXs5GiRqeKJwd4GbU9JOsdHw7Wvz10e0GtyTTrIJznoNVtvIOH9AAAAAElFTkSuQmCC",alt:"Keyring Logo",width:22,height:30})}),
35
- /* @__PURE__ */k.jsx("h3",{id:"chat-modal-title",children:i||D?.title||c("chatTitle")})]}),
36
- /* @__PURE__ */k.jsx("button",{className:"close-button",onClick:n,"aria-label":c("closeChat"),type:"button",children:/* @__PURE__ */k.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:/* @__PURE__ */k.jsx("path",{d:"M15 5L5 15M5 5L15 15",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})})]}),
37
- /* @__PURE__ */k.jsx(_d,{address:U?.address,chainId:U?.chainId})]}),
33
+ /* @__PURE__ */k.jsxs("div",{className:"chat-modal-header-left",children:[f&&/* @__PURE__ */k.jsx("div",{className:"keyring-logo",children:/* @__PURE__ */k.jsx("img",{src:l||H?.icon||"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACwAAAA8CAYAAAAdUliaAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAOdEVYdFNvZnR3YXJlAEZpZ21hnrGWYwAADAhJREFUeAHtWUtsnNUVPufOw2NAjS3UqqwyZtNVhaO2cbyoYqMKlU2xaRKIQPUMBQqllcegFgVVeBwEIZWKbQQElYfHoDYPUo1pqdpN40EgOSatxlm1KzzuhlZt5Umblsbz//dw7ut/zCOZQLLLkWb+131899zvnse9ANfkmsQE4VMIlcf6oJGaACkHICm2gU8bIJIV3HusAldZLgswLTDQG5KTQFjgmtuA+B/5X12BCEBscJNzuO/4PFwl6RowvbVnhIEuMK4soKqmAGKn+jUQWMQ9JxbhCsslAdPRu7MgvEkuOshPrEQxyFj7QsBtgDutI66Dt3Ur7l+qwRWSiwLWXK1zofxSPfb+xN7dfM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OS3dw4tks/7Z6DCzFAwmpEjuJOLrDqbfuPgKvF26zpiqsrfboHANJhhozHSTRzG6EElb4I3ZtzDZQFWos7nju0f4v0zOcDR0ZKze2CvaFIAu09k/Afa4zQderj9crAOxdg39CCj03t9CA+6PEeQvBH43/iZB8JnlB++tpJLe2I6LWF7ho/I+DSKeswpFLpzkYw5MyF1fsLnIhiePulzEuQzkVr2laEBDfjE3iqPjLdhvbaHjp8ZsJMnjpyZ5kOdHCek2/XJkwYYgjYnU+qcjyB6YsXvKOXJxYHXduXdLiXuP1np1M8VA6xEmbQM4DSfSOX0MZiHsaMyPnGitISIhvmZT53SKEcHXm4947vqgJ3MHlrJpkGUGdxgxk27Bdxjzv/QUSVNMP6lI0NL3bZ9VQA7ee3plVzSw4leiSPRU1ULupaRMv/lF4Yrl9PmVQXs5GiRqeKJwd4GbU9JOsdHw7Wvz10e0GtyTTrIJznoNVtvIOH9AAAAAElFTkSuQmCC",alt:"Keyring Logo",width:22,height:30})}),
34
+ /* @__PURE__ */k.jsx("h3",{id:"chat-modal-title",children:i||H?.title||d("chatTitle")})]}),
35
+ /* @__PURE__ */k.jsx("button",{className:"close-button",onClick:n,"aria-label":d("closeChat"),type:"button",children:/* @__PURE__ */k.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:/* @__PURE__ */k.jsx("path",{d:"M15 5L5 15M5 5L15 15",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})})]}),
36
+ /* @__PURE__ */k.jsx(_d,{address:q?.address,chainId:q?.chainId})]}),
38
37
  /* @__PURE__ */k.jsxs("div",{className:"chat-modal-messages-wrapper",children:[
39
- /* @__PURE__ */k.jsxs("div",{className:"chat-modal-messages",ref:N,role:"log","aria-live":"polite",children:[d.map((e,n)=>/* @__PURE__ */k.jsxs("div",{children:[de(n)&&/* @__PURE__ */k.jsx("div",{className:"date-separator",children:jd(e.timestamp)}),
38
+ /* @__PURE__ */k.jsxs("div",{className:"chat-modal-messages",ref:P,role:"log","aria-live":"polite",children:[p.map((e,n)=>/* @__PURE__ */k.jsxs("div",{children:[pe(n)&&/* @__PURE__ */k.jsx("div",{className:"date-separator",children:jd(e.timestamp)}),
40
39
  /* @__PURE__ */k.jsxs("div",{className:"message "+("user"===e.sender?"message-user":"message-bot"),role:"article",children:[
41
- /* @__PURE__ */k.jsx("button",{disabled:Dh.isMobile,className:"message-reply-button",onClick:()=>X(e),"aria-label":c("replyToMessage"),type:"button",children:/* @__PURE__ */k.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:/* @__PURE__ */k.jsx("path",{d:"M3.5 8.5L1 6L3.5 3.5M1.5 6H10C12.2091 6 14 7.79086 14 10V13",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),
40
+ /* @__PURE__ */k.jsx("button",{disabled:Dh.isMobile,className:"message-reply-button",onClick:()=>Z(e),"aria-label":d("replyToMessage"),type:"button",children:/* @__PURE__ */k.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:/* @__PURE__ */k.jsx("path",{d:"M3.5 8.5L1 6L3.5 3.5M1.5 6H10C12.2091 6 14 7.79086 14 10V13",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),
42
41
  /* @__PURE__ */k.jsxs("div",{className:"message-bubble",children:[e.replyTo&&/* @__PURE__ */k.jsxs("div",{className:"message-reply-to",children:[
43
- /* @__PURE__ */k.jsxs("div",{className:"message-reply-to-label",children:[c("replyingTo")," ","user"===e.replyTo.sender?c("replyingToYou"):i||c("replyingToAgent")]}),
42
+ /* @__PURE__ */k.jsxs("div",{className:"message-reply-to-label",children:[d("replyingTo")," ","user"===e.replyTo.sender?d("replyingToYou"):i||d("replyingToAgent")]}),
44
43
  /* @__PURE__ */k.jsx("div",{className:"message-reply-to-text",children:e.replyTo.text})]}),
45
- /* @__PURE__ */k.jsx("div",{className:"message-text",children:/* @__PURE__ */k.jsx(hm,{content:e.text})}),e.buttons&&e.buttons.length>0&&/* @__PURE__ */k.jsx("div",{className:"message-buttons",children:e.buttons.map(e=>/* @__PURE__ */k.jsx("button",{className:`message-button ${e.fullWidth?"full-width":""} ${"suggested_action"===e.action?"suggested-action":""}`,onClick:()=>ie(e.value,e.action,e?.extraData),type:"button",children:e.text},e.id))}),e.actionData&&("pending"===e.actionData.status||"success"===e.actionData.status||"submitted"===e.actionData.status)&&/* @__PURE__ */k.jsx(Oh,{disabled:"success"===e.actionData.status||"submitted"===e.actionData.status,action:e.actionData.action,initialValues:e.actionData.parameters,onSubmit:(n,t)=>{ue(n,t,e.id),setTimeout(()=>{R.current?.scrollIntoView({behavior:"smooth"})},100)},onCancel:()=>le(e.id),isSubmitting:M[e.id]||!1,tokenInfo:e.actionData.tokenInfo,nftInfo:e.actionData.nftInfo}),e.actionData&&"submitted"===e.actionData.status&&/* @__PURE__ */k.jsx("div",{className:"action-status action-status-submitted",children:c("txProcessing")}),e.actionData&&"fail"===e.actionData.status&&/* @__PURE__ */k.jsx("div",{className:"action-status action-status-fail",children:c("actionFail")}),
46
- /* @__PURE__ */k.jsxs("div",{className:"message-timestamp",children:[e.timestamp.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1}),"user"===e.sender&&/* @__PURE__ */k.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",className:"check-icon",children:/* @__PURE__ */k.jsx("path",{d:"M13.3333 4L6 11.3333L2.66667 8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]})]})]})]},e.id)),E&&/* @__PURE__ */k.jsx("div",{className:"message message-bot typing-indicator",role:"status","aria-label":c("botIsTyping"),children:/* @__PURE__ */k.jsxs("div",{className:"message-bubble",children:[
44
+ /* @__PURE__ */k.jsx("div",{className:"message-text",children:/* @__PURE__ */k.jsx(hm,{content:e.text})}),e.buttons&&e.buttons.length>0&&/* @__PURE__ */k.jsx("div",{className:"message-buttons",children:e.buttons.map(e=>/* @__PURE__ */k.jsx("button",{className:`message-button ${e.fullWidth?"full-width":""} ${"suggested_action"===e.action?"suggested-action":""}`,onClick:()=>se(e.value,e.action,e?.extraData),type:"button",children:e.text},e.id))}),e.actionData&&("pending"===e.actionData.status||"success"===e.actionData.status||"submitted"===e.actionData.status)&&/* @__PURE__ */k.jsx(Oh,{disabled:"success"===e.actionData.status||"submitted"===e.actionData.status,action:e.actionData.action,initialValues:e.actionData.parameters,onSubmit:(n,t)=>{ce(n,t,e.id),setTimeout(()=>{B.current?.scrollIntoView({behavior:"smooth"})},100)},onCancel:()=>fe(e.id),isSubmitting:R[e.id]||!1,tokenInfo:e.actionData.tokenInfo,nftInfo:e.actionData.nftInfo}),e.actionData&&"submitted"===e.actionData.status&&/* @__PURE__ */k.jsx("div",{className:"action-status action-status-submitted",children:d("txProcessing")}),e.actionData&&"fail"===e.actionData.status&&/* @__PURE__ */k.jsx("div",{className:"action-status action-status-fail",children:d("actionFail")}),
45
+ /* @__PURE__ */k.jsxs("div",{className:"message-timestamp",children:[e.timestamp.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1}),"user"===e.sender&&/* @__PURE__ */k.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",className:"check-icon",children:/* @__PURE__ */k.jsx("path",{d:"M13.3333 4L6 11.3333L2.66667 8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]})]})]})]},e.id)),S&&/* @__PURE__ */k.jsx("div",{className:"message message-bot typing-indicator",role:"status","aria-label":d("botIsTyping"),children:/* @__PURE__ */k.jsxs("div",{className:"message-bubble",children:[
47
46
  /* @__PURE__ */k.jsx("span",{className:"typing-dot"}),
48
47
  /* @__PURE__ */k.jsx("span",{className:"typing-dot"}),
49
- /* @__PURE__ */k.jsx("span",{className:"typing-dot"})]})}),(S||1===d.length)&&/* @__PURE__ */k.jsxs(k.Fragment,{children:[d.length>1&&/* @__PURE__ */k.jsx("div",{className:"message message-bot",role:"article",children:/* @__PURE__ */k.jsx("div",{className:"message-bubble",children:/* @__PURE__ */k.jsx("div",{className:"message-text",children:c("canIHelpYou")})})}),
50
- /* @__PURE__ */k.jsx("div",{className:"suggestions-container",children:se.map(e=>/* @__PURE__ */k.jsxs("button",{className:"suggestion-button",onClick:e.action,type:"button",children:[e.icon&&/* @__PURE__ */k.jsx("span",{className:"suggestion-icon",children:e.icon}),
48
+ /* @__PURE__ */k.jsx("span",{className:"typing-dot"})]})}),(C||1===p.length)&&/* @__PURE__ */k.jsxs(k.Fragment,{children:[p.length>1&&/* @__PURE__ */k.jsx("div",{className:"message message-bot",role:"article",children:/* @__PURE__ */k.jsx("div",{className:"message-bubble",children:/* @__PURE__ */k.jsx("div",{className:"message-text",children:d("canIHelpYou")})})}),
49
+ /* @__PURE__ */k.jsx("div",{className:"suggestions-container",children:le.map(e=>/* @__PURE__ */k.jsxs("button",{className:"suggestion-button",onClick:e.action,type:"button",children:[e.icon&&/* @__PURE__ */k.jsx("span",{className:"suggestion-icon",children:e.icon}),
51
50
  /* @__PURE__ */k.jsx("span",{className:"suggestion-text",children:e.text})]},e.id??e.text))})]}),
52
- /* @__PURE__ */k.jsx("div",{ref:R})]}),
53
- /* @__PURE__ */k.jsx(Rh,{scrollContainerRef:N})]}),
54
- /* @__PURE__ */k.jsxs("div",{className:"chat-modal-input",children:[C&&/* @__PURE__ */k.jsxs("div",{className:"reply-preview",children:[
51
+ /* @__PURE__ */k.jsx("div",{ref:B})]}),
52
+ /* @__PURE__ */k.jsx(Rh,{scrollContainerRef:P})]}),
53
+ /* @__PURE__ */k.jsxs("div",{className:"chat-modal-input",children:[M&&/* @__PURE__ */k.jsxs("div",{className:"reply-preview",children:[
55
54
  /* @__PURE__ */k.jsxs("div",{className:"reply-preview-content",children:[
56
- /* @__PURE__ */k.jsxs("div",{className:"reply-preview-label",children:[c("replyingTo")," ","user"===C.sender?c("replyingToYou"):i||c("replyingToAgent")]}),
57
- /* @__PURE__ */k.jsx("div",{className:"reply-preview-text",children:C.text})]}),
58
- /* @__PURE__ */k.jsx("button",{className:"reply-preview-close",onClick:()=>I(null),"aria-label":c("cancelReply"),type:"button",children:/* @__PURE__ */k.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:/* @__PURE__ */k.jsx("path",{d:"M12 4L4 12M4 4L12 12",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})]}),
55
+ /* @__PURE__ */k.jsxs("div",{className:"reply-preview-label",children:[d("replyingTo")," ","user"===M.sender?d("replyingToYou"):i||d("replyingToAgent")]}),
56
+ /* @__PURE__ */k.jsx("div",{className:"reply-preview-text",children:M.text})]}),
57
+ /* @__PURE__ */k.jsx("button",{className:"reply-preview-close",onClick:()=>O(null),"aria-label":d("cancelReply"),type:"button",children:/* @__PURE__ */k.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:/* @__PURE__ */k.jsx("path",{d:"M12 4L4 12M4 4L12 12",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})]}),
59
58
  /* @__PURE__ */k.jsxs("div",{className:"chat-modal-input-row",children:[
60
- /* @__PURE__ */k.jsx("input",{ref:B,type:"text",placeholder:c("messagePlaceholder"),value:g,onChange:e=>A(e.target.value),onKeyPress:ce,disabled:E,"aria-label":"Message input"}),
61
- /* @__PURE__ */k.jsx("button",{className:"send-button",onClick:()=>{oe()},"aria-label":c("sendMessage"),disabled:E||""===g?.trim(),type:"button",children:/* @__PURE__ */k.jsx("img",{src:"data:image/svg+xml,%3csvg%20width='36'%20height='36'%20viewBox='0%200%2036%2036'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3crect%20width='36'%20height='36'%20rx='18'%20fill='%232358B2'/%3e%3cmask%20id='mask0_1924_16177'%20style='mask-type:alpha'%20maskUnits='userSpaceOnUse'%20x='11'%20y='10'%20width='17'%20height='16'%3e%3crect%20x='11.334'%20y='10'%20width='16'%20height='16'%20fill='url(%23pattern0_1924_16177)'/%3e%3c/mask%3e%3cg%20mask='url(%23mask0_1924_16177)'%3e%3crect%20x='11.334'%20y='10'%20width='16'%20height='16'%20fill='white'/%3e%3c/g%3e%3cdefs%3e%3cpattern%20id='pattern0_1924_16177'%20patternContentUnits='objectBoundingBox'%20width='1'%20height='1'%3e%3cuse%20xlink:href='%23image0_1924_16177'%20transform='scale(0.00195312)'/%3e%3c/pattern%3e%3cimage%20id='image0_1924_16177'%20width='512'%20height='512'%20preserveAspectRatio='none'%20xlink:href='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACAYAAAD0eNT6AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAOgAAADoABlffMYAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAACAASURBVHic7d13uGRlme7/79M0ijnrKM6ImHAMmHXGgB7zKJhzAAMgZjFg4DfnzO8ISM4gKIKIEgwImAAjiAQRCSoCCgaCgOQcn/PHu5reNHt37121qt61qr6f6+pLbLr3vi/Seuqtp947MhNJkjRdFtUOIEmSxs8BQJKkKeQAIEnSFHIAkCRpCjkASJI0hRbXDjCoiFgMPBB40Iwf9wZimV96E/AP4PzmxwWZeeMYo0qS1DnRl48BRsSqwFrA85ofa3DHh/18JHAxcCrwmyU/MvPslqJKktR5nR0AImJ1lj7s1wJWH/G3vAw4EjgE+EFmXj7i7ydJUjWdGgAi4uXA2ykP/YdWjHITcBRlGDggMy+umEWSpNZVHwAiYmXgrcAngMdXDTO7G4ADgZ0z88TaYSRJakO1ASAi7glsAHwUWLVKiIU7FtgZ+FZm3lQ7jCRJgxr7ABARDwE+AmwI3Gus37w9fwW2AvbKzBtqh5EkaaHGNgBExKOBz1CO++80lm86ehcA2wB7ZOY1tcNIkjRfIx8Ams/rbwL8f8CdR/rN6vknsD2wS2ZeWTuMJEkrMtIBICKeCuwFrDmyb9Itl1N2BHbMzEtqh5EkaS4jG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gEODhrX3RyXAL8A1gi8w8vXYYSZJaHQAAIuKewJ7Am1r9wv10I+WtkS9k5tm1w0iStETrA8BtXzjiPZSSmruO5Bt023XAl4GtMvPc2mEkSVrWyAYAgIhYA9gPeOrIvkm3XA3sDmybmRfWDiNJ0lxGOgAARMQiYH3g88D9R/rN6rkc2BnYITMvrR1GkqQVGfkAcNs3irgP8P8DGzE5Vwj/E9ge2CUzr6wdRpKk+RrbAHDbNyyfFPgf4FUMcRNhZRdQLj/aw0peSVIfjX0AuO0bRzwK2BhYF7hLlRALdwKwG3CAlbySpD6rNgDcFiDiAcAHgXcCq1UNM7trKZ/h3z0zT6odRpKkNlQfAGaKiH8HXtH8eDawuFKUG4GjgO8C+2XmFZVySJI0Ep0aAGaKiHsBL6EMAy8HHjjib3ku8EPg+8BPMvPqEX8/SZKq6ewAMFNEBPB0ykCwOvDgGT/uz8KWCW8G/gT8fsaP07yiV5I0TXoxACxPRCymnA7MHAoeAFwPXAFcOeN/LwPOycwb66SVJKkbej8ASJKkhevr5/AlSdIQHAAkSZpCDgCSJE0hBwBJkqaQA4AkSVPo/wH9hnZgmG1pVwAAAABJRU5ErkJggg=='/%3e%3c/defs%3e%3c/svg%3e",alt:"Send",width:44,height:44})})]})]})]})}):null},mm=({position:e,theme:n,defaultOpen:t,onOpen:r,onClose:o,onTransaction:i,chatTitle:a,welcomeMessage:s,customSuggestions:u,additionalSuggestions:l,buttonIcon:c,chatIcon:f,customChatButton:d,styleButtonChat:h})=>{const{account:p,chainId:m}=Qd(),[y,v]=j.useState(t),b=X;j.useEffect(()=>{t&&r&&r()},[]),j.useEffect(()=>{if("undefined"==typeof window)return;const e=document.body,n=document.documentElement,t=e.style.overscrollBehavior,r=n.style.overscrollBehavior,o=e.style.overflow;return y&&(e.style.overscrollBehavior="none",n.style.overscrollBehavior="none",e.style.overflow="hidden"),()=>{e.style.overscrollBehavior=t,n.style.overscrollBehavior=r,e.style.overflow=o}},[y]);const w=j.useCallback(()=>{v(!0),r?.()},[r]),g=j.useCallback(()=>{v(!1),o?.()},[o]),A=j.useCallback(()=>{y?g():w()},[y,w,g]),E={position:"fixed",["bottom-right"===e?"right":"left"]:n.offset?.x??20,bottom:n.offset?.y??20,zIndex:n.zIndex??9999};return Yd(p?.address||"")&&m?b.length>0&&!b.includes(window.location.origin)&&!window.location.href.startsWith("http://localhost")?/* @__PURE__ */k.jsx(k.Fragment,{}):/* @__PURE__ */k.jsxs("div",{style:{...E,...h},role:"complementary","aria-label":"Chat widget",children:[
62
- /* @__PURE__ */k.jsx(Y,{buttonSize:n.buttonSize,onClick:A,customIcon:c,customChatButton:d}),
63
- /* @__PURE__ */k.jsx(pm,{isOpen:y,onClose:g,onTransaction:i,position:e,modalChatStyle:n.modalChatStyle,chatTitle:a,welcomeMessage:s,customSuggestions:u,additionalSuggestions:l,chatIcon:f})]}):/* @__PURE__ */k.jsx(k.Fragment,{})},ym=({position:e="bottom-right",theme:n={},defaultOpen:t=!1,onOpen:r,onClose:o,account:i,onTransaction:a,language:s="en",rpcUrls:u,chatTitle:l,welcomeMessage:c,customSuggestions:f,additionalSuggestions:d,buttonIcon:h,chatIcon:p,customChatButton:m,styleButtonChat:y})=>{const v={position:e,theme:n,rpcUrls:u};return"undefined"==typeof window?null:/* @__PURE__ */k.jsx(uh,{initialConfig:v,children:/* @__PURE__ */k.jsx(Zd,{initialAccount:i,children:/* @__PURE__ */k.jsx(z,{initialLanguage:s,children:/* @__PURE__ */k.jsx(mm,{position:e,theme:n,defaultOpen:t,onOpen:r,onClose:o,onTransaction:a,chatTitle:l,welcomeMessage:c,customSuggestions:f,additionalSuggestions:d,buttonIcon:h,chatIcon:p,customChatButton:m,styleButtonChat:y})})})})};class vm extends HTMLElement{root=null;mountPoint=null;qn=void 0;Vn=void 0;Wn=void 0;zn=void 0;Gn=void 0;Yn=void 0;Jn=void 0;Kn=void 0;Xn=void 0;Qn=void 0;Zn=void 0;_n=void 0;$n=void 0;clearChat(){Uh?.()}static get observedAttributes(){return["position","primary-color","button-size","z-index","default-open","language"]}set account(e){this.qn=e,this.nt()}get account(){return this.qn}set rpcUrls(e){this.Vn=e,this.nt()}get rpcUrls(){return this.Vn}set onTransaction(e){this.Wn=e,this.nt()}get onTransaction(){return this.Wn}set onOpen(e){this.zn=e,this.nt()}get onOpen(){return this.zn}set onClose(e){this.Gn=e,this.nt()}get onClose(){return this.Gn}set chatTitle(e){this.Yn=e,this.nt()}get chatTitle(){return this.Yn}set welcomeMessage(e){this.Jn=e,this.nt()}get welcomeMessage(){return this.Jn}set customSuggestions(e){this.Kn=e,this.nt()}get customSuggestions(){return this.Kn}set additionalSuggestions(e){this.Xn=e,this.nt()}get additionalSuggestions(){return this.Xn}set buttonIcon(e){this.Qn=e,this.nt()}get buttonIcon(){return this.Qn}set chatIcon(e){this.Zn=e,this.nt()}get chatIcon(){return this.Zn}set customChatButton(e){this._n=e,this.nt()}get customChatButton(){return this._n}set styleButtonChat(e){this.$n=e,this.nt()}get styleButtonChat(){return this.$n}connectedCallback(){this.mountPoint=document.createElement("div"),this.attachShadow({mode:"open"}).appendChild(this.mountPoint),this.root=H.createRoot(this.mountPoint),this.nt()}disconnectedCallback(){this.root&&(this.root.unmount(),this.root=null),this.mountPoint=null}attributeChangedCallback(){this.nt()}nt(){if(!this.root)return;const e={position:this.getAttribute("position")||"bottom-right",defaultOpen:"true"===this.getAttribute("default-open"),language:this.getAttribute("language")||"en",theme:{primaryColor:this.getAttribute("primary-color")||"#007bff",buttonSize:parseInt(this.getAttribute("button-size")||"60"),zIndex:parseInt(this.getAttribute("z-index")||"9999")},account:this.qn,rpcUrls:this.Vn,onTransaction:this.Wn,onOpen:this.zn,onClose:this.Gn,chatTitle:this.Yn,welcomeMessage:this.Jn,customSuggestions:this.Kn,additionalSuggestions:this.Xn,buttonIcon:this.Qn,chatIcon:this.Zn,customChatButton:this._n,styleButtonChat:this.$n};this.root.render(/* @__PURE__ */k.jsx(ym,{...e}))}}customElements.get("chat-widget")||customElements.define("chat-widget",vm);export{vm as ChatWidgetElement};
59
+ /* @__PURE__ */k.jsx("input",{ref:L,type:"text",placeholder:d("messagePlaceholder"),value:E,onChange:e=>T(e.target.value),onKeyPress:de,disabled:S,"aria-label":"Message input"}),
60
+ /* @__PURE__ */k.jsx("button",{className:"send-button",onClick:()=>{ae()},"aria-label":d("sendMessage"),disabled:S||""===E?.trim(),type:"button",children:/* @__PURE__ */k.jsx("img",{src:"data:image/svg+xml,%3csvg%20width='36'%20height='36'%20viewBox='0%200%2036%2036'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3crect%20width='36'%20height='36'%20rx='18'%20fill='%232358B2'/%3e%3cmask%20id='mask0_1924_16177'%20style='mask-type:alpha'%20maskUnits='userSpaceOnUse'%20x='11'%20y='10'%20width='17'%20height='16'%3e%3crect%20x='11.334'%20y='10'%20width='16'%20height='16'%20fill='url(%23pattern0_1924_16177)'/%3e%3c/mask%3e%3cg%20mask='url(%23mask0_1924_16177)'%3e%3crect%20x='11.334'%20y='10'%20width='16'%20height='16'%20fill='white'/%3e%3c/g%3e%3cdefs%3e%3cpattern%20id='pattern0_1924_16177'%20patternContentUnits='objectBoundingBox'%20width='1'%20height='1'%3e%3cuse%20xlink:href='%23image0_1924_16177'%20transform='scale(0.00195312)'/%3e%3c/pattern%3e%3cimage%20id='image0_1924_16177'%20width='512'%20height='512'%20preserveAspectRatio='none'%20xlink:href='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACAYAAAD0eNT6AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAOgAAADoABlffMYAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAACAASURBVHic7d13uGRlme7/79M0ijnrKM6ImHAMmHXGgB7zKJhzAAMgZjFg4DfnzO8ISM4gKIKIEgwImAAjiAQRCSoCCgaCgOQcn/PHu5reNHt37121qt61qr6f6+pLbLr3vi/Seuqtp947MhNJkjRdFt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VwAAAABJRU5ErkJggg=='/%3e%3c/defs%3e%3c/svg%3e",alt:"Send",width:44,height:44})})]})]})]})}):null},mm=({position:e,theme:n,defaultOpen:t,onOpen:r,onClose:o,onTransaction:i,chatTitle:a,welcomeMessage:s,customSuggestions:u,additionalSuggestions:l,buttonIcon:c,chatIcon:f,customChatButton:d,styleButtonChat:h,modalConfig:p})=>{const{account:m,chainId:y}=Qd(),[v,b]=j.useState(t),w=X;j.useEffect(()=>{t&&r&&r()},[]),j.useEffect(()=>{if("undefined"==typeof window)return;const e=document.body,n=document.documentElement,t=e.style.overscrollBehavior,r=n.style.overscrollBehavior,o=e.style.overflow;return v&&(e.style.overscrollBehavior="none",n.style.overscrollBehavior="none",e.style.overflow="hidden"),()=>{e.style.overscrollBehavior=t,n.style.overscrollBehavior=r,e.style.overflow=o}},[v]);const g=j.useCallback(()=>{b(!0),r?.()},[r]),A=j.useCallback(()=>{b(!1),o?.()},[o]),E=j.useCallback(()=>{v?A():g()},[v,g,A]),T={position:"fixed",["bottom-right"===e?"right":"left"]:n.offset?.x??20,bottom:n.offset?.y??20,zIndex:n.zIndex??9999};return Yd(m?.address||"")&&y?w.length>0&&!w.includes(window.location.origin)&&!window.location.href.startsWith("http://localhost")?/* @__PURE__ */k.jsx(k.Fragment,{}):/* @__PURE__ */k.jsxs("div",{style:{...T,...h},role:"complementary","aria-label":"Chat widget",children:[
61
+ /* @__PURE__ */k.jsx(Y,{buttonSize:n.buttonSize,onClick:E,customIcon:c,customChatButton:d}),
62
+ /* @__PURE__ */k.jsx(pm,{modalConfig:p,isOpen:v,onClose:A,onTransaction:i,position:e,modalChatStyle:n.modalChatStyle,chatTitle:a,welcomeMessage:s,customSuggestions:u,additionalSuggestions:l,chatIcon:f})]}):/* @__PURE__ */k.jsx(k.Fragment,{})},ym=({position:e="bottom-right",theme:n={},defaultOpen:t=!1,onOpen:r,onClose:o,account:i,onTransaction:a,language:s="en",rpcUrls:u,chatTitle:l,welcomeMessage:c,customSuggestions:f,additionalSuggestions:d,buttonIcon:h,chatIcon:p,customChatButton:m,styleButtonChat:y,modalConfig:v})=>{const b={position:e,theme:n,rpcUrls:u};return"undefined"==typeof window?null:/* @__PURE__ */k.jsx(uh,{initialConfig:b,children:/* @__PURE__ */k.jsx(Zd,{initialAccount:i,children:/* @__PURE__ */k.jsx(z,{initialLanguage:s,children:/* @__PURE__ */k.jsx(mm,{modalConfig:v,position:e,theme:n,defaultOpen:t,onOpen:r,onClose:o,onTransaction:a,chatTitle:l,welcomeMessage:c,customSuggestions:f,additionalSuggestions:d,buttonIcon:h,chatIcon:p,customChatButton:m,styleButtonChat:y})})})})};class vm extends HTMLElement{root=null;mountPoint=null;qn=void 0;Vn=void 0;Wn=void 0;zn=void 0;Gn=void 0;Yn=void 0;Jn=void 0;Kn=void 0;Xn=void 0;Qn=void 0;Zn=void 0;_n=void 0;$n=void 0;clearChat(){Uh?.()}static get observedAttributes(){return["position","primary-color","button-size","z-index","default-open","language"]}set account(e){this.qn=e,this.nt()}get account(){return this.qn}set rpcUrls(e){this.Vn=e,this.nt()}get rpcUrls(){return this.Vn}set onTransaction(e){this.Wn=e,this.nt()}get onTransaction(){return this.Wn}set onOpen(e){this.zn=e,this.nt()}get onOpen(){return this.zn}set onClose(e){this.Gn=e,this.nt()}get onClose(){return this.Gn}set chatTitle(e){this.Yn=e,this.nt()}get chatTitle(){return this.Yn}set welcomeMessage(e){this.Jn=e,this.nt()}get welcomeMessage(){return this.Jn}set customSuggestions(e){this.Kn=e,this.nt()}get customSuggestions(){return this.Kn}set additionalSuggestions(e){this.Xn=e,this.nt()}get additionalSuggestions(){return this.Xn}set buttonIcon(e){this.Qn=e,this.nt()}get buttonIcon(){return this.Qn}set chatIcon(e){this.Zn=e,this.nt()}get chatIcon(){return this.Zn}set customChatButton(e){this._n=e,this.nt()}get customChatButton(){return this._n}set styleButtonChat(e){this.$n=e,this.nt()}get styleButtonChat(){return this.$n}connectedCallback(){this.mountPoint=document.createElement("div"),this.attachShadow({mode:"open"}).appendChild(this.mountPoint),this.root=H.createRoot(this.mountPoint),this.nt()}disconnectedCallback(){this.root&&(this.root.unmount(),this.root=null),this.mountPoint=null}attributeChangedCallback(){this.nt()}nt(){if(!this.root)return;const e={position:this.getAttribute("position")||"bottom-right",defaultOpen:"true"===this.getAttribute("default-open"),language:this.getAttribute("language")||"en",theme:{primaryColor:this.getAttribute("primary-color")||"#007bff",buttonSize:parseInt(this.getAttribute("button-size")||"60"),zIndex:parseInt(this.getAttribute("z-index")||"9999")},account:this.qn,rpcUrls:this.Vn,onTransaction:this.Wn,onOpen:this.zn,onClose:this.Gn,chatTitle:this.Yn,welcomeMessage:this.Jn,customSuggestions:this.Kn,additionalSuggestions:this.Xn,buttonIcon:this.Qn,chatIcon:this.Zn,customChatButton:this._n,styleButtonChat:this.$n};this.root.render(/* @__PURE__ */k.jsx(ym,{...e}))}}customElements.get("chat-widget")||customElements.define("chat-widget",vm);export{vm as ChatWidgetElement};