UNPKG

@privy-io/react-auth

Version:

React client for the Privy Auth API

167 lines (162 loc) 24.3 kB
import{jsx as e,jsxs as r,Fragment as n}from"react/jsx-runtime";import{BoltIcon as i,ArrowRightIcon as o,ChevronDownIcon as t}from"@heroicons/react/24/outline";import{useState as l}from"react";import{styled as a}from"styled-components";import{formatTokenAmount as s}from"@privy-io/js-sdk-core";import{M as c,P as d,E as h,B as m,b as u}from"./ModalHeader-D8-mhjp4.mjs";import{L as p,V as g,a as f}from"./Value-tcJV9e0L.mjs";import{a as y,R as k}from"./Row-C9vrS4Zi.mjs";import{E as x}from"./ErrorMessage-D8VaAP5m.mjs";import{L as v}from"./LabelXs-oqZNqbm_.mjs";import{S as b}from"./Subtitle-CV-2yKE4.mjs";import{T as w}from"./Title-BnzYV3Is.mjs";import{A as T}from"./Address-BjZb-TIL.mjs";import{W as I}from"./WalletInfoCard-DFt8ndGE.mjs";import{u as A}from"./context-WTldtXS8.mjs";import{Y as S}from"./useActiveWallet-3RHPIBxJ.mjs";import{L as C}from"./LoadingSkeleton-U6-3yFwI.mjs";import{isAddress as $}from"viem";import{B as j}from"./shared-FM0rljBt.mjs";import{C as M}from"./Checkbox-BhNoOKjX.mjs";import{E}from"./ErrorBanner-CQERa7bL.mjs";import{W as O}from"./WarningBanner-c8L53pJ2.mjs";import D from"@heroicons/react/24/outline/ClipboardDocumentCheckIcon";import N from"@heroicons/react/24/outline/ClipboardDocumentIcon";import F from"@heroicons/react/24/outline/ExclamationCircleIcon";import{u as L}from"./internal-context-Z-fyxadS.mjs";const P=a(p)` cursor: pointer; display: inline-flex; gap: 8px; align-items: center; color: var(--privy-color-accent); svg { fill: var(--privy-color-accent); } `;var W=({iconUrl:n,value:i,symbol:o,usdValue:t,nftName:l,nftCount:a,decimals:s,$isLoading:c})=>{if(c)/*#__PURE__*/return e(z,{$isLoading:c});let d=i&&t&&s?function(e,r,n){let i=parseFloat(e),o=parseFloat(n);if(0===i||0===o||Number.isNaN(i)||Number.isNaN(o))return e;let t=Math.ceil(-Math.log10(.01/(o/i))),l=Math.pow(10,t=Math.max(t=Math.min(t,r),1)),a=+(Math.floor(i*l)/l).toFixed(t).replace(/\.?0+$/,"");return Intl.NumberFormat(void 0,{maximumFractionDigits:r}).format(a)}(i,s,t):i;/*#__PURE__*/return r("div",{children:[/*#__PURE__*/r(z,{$isLoading:c,children:[n&&/*#__PURE__*/e(R,{src:n,alt:"Token icon"}),a&&a>1?a+"x":void 0," ",l,d," ",o]}),t&&/*#__PURE__*/r(B,{$isLoading:c,children:["$",t]})]})};let z=a.span` color: var(--privy-color-foreground); font-size: 0.875rem; font-weight: 500; line-height: 1.375rem; word-break: break-all; text-align: right; display: flex; justify-content: flex-end; ${C} `;const B=a.span` color: var(--privy-color-foreground-2); font-size: 12px; font-weight: 400; line-height: 18px; word-break: break-all; text-align: right; display: flex; justify-content: flex-end; ${C} `;let R=a.img` height: 14px; width: 14px; margin-right: 4px; object-fit: contain; `;const V=i=>{let{chain:o,transactionDetails:t,isTokenContractInfoLoading:l,symbol:a}=i,{action:s,functionName:c}=t;/*#__PURE__*/return e(j,{children:/*#__PURE__*/r(y,{children:["transaction"!==s&&/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Action"}),/*#__PURE__*/e(g,{children:c})]}),"mint"===c&&"args"in t&&t.args.filter((e=>e)).map(((n,i)=>/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:`Param ${i}`}),/*#__PURE__*/e(g,{children:"string"==typeof n&&$(n)?/*#__PURE__*/e(T,{address:n,url:o?.blockExplorers?.default?.url,showCopyIcon:!1}):n?.toString()})]},i))),"setApprovalForAll"===c&&t.operator&&/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Operator"}),/*#__PURE__*/e(g,{children:/*#__PURE__*/e(T,{address:t.operator,url:o?.blockExplorers?.default?.url,showCopyIcon:!1})})]}),"setApprovalForAll"===c&&void 0!==t.approved&&/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Set approval to"}),/*#__PURE__*/e(g,{children:t.approved?"true":"false"})]}),"transfer"===c||"transferFrom"===c||"safeTransferFrom"===c||"approve"===c?/*#__PURE__*/r(n,{children:["formattedAmount"in t&&t.formattedAmount&&/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Amount"}),/*#__PURE__*/r(g,{$isLoading:l,children:[t.formattedAmount," ",a]})]}),"tokenId"in t&&t.tokenId&&/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Token ID"}),/*#__PURE__*/e(g,{children:t.tokenId.toString()})]})]}):null,"safeBatchTransferFrom"===c&&/*#__PURE__*/r(n,{children:["amounts"in t&&t.amounts&&/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Amounts"}),/*#__PURE__*/e(g,{children:t.amounts.join(", ")})]}),"tokenIds"in t&&t.tokenIds&&/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Token IDs"}),/*#__PURE__*/e(g,{children:t.tokenIds.join(", ")})]})]}),"approve"===c&&t.spender&&/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Spender"}),/*#__PURE__*/e(g,{children:/*#__PURE__*/e(T,{address:t.spender,url:o?.blockExplorers?.default?.url,showCopyIcon:!1})})]}),("transferFrom"===c||"safeTransferFrom"===c||"safeBatchTransferFrom"===c)&&t.transferFrom&&/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Transferring from"}),/*#__PURE__*/e(g,{children:/*#__PURE__*/e(T,{address:t.transferFrom,url:o?.blockExplorers?.default?.url,showCopyIcon:!1})})]}),("transferFrom"===c||"safeTransferFrom"===c||"safeBatchTransferFrom"===c)&&t.transferTo&&/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Transferring to"}),/*#__PURE__*/e(g,{children:/*#__PURE__*/e(T,{address:t.transferTo,url:o?.blockExplorers?.default?.url,showCopyIcon:!1})})]})]})})},U=({variant:i,setPreventMaliciousTransaction:o,colorScheme:t="light",preventMaliciousTransaction:l})=>"warn"===i?/*#__PURE__*/e(q,{children:/*#__PURE__*/r(O,{theme:t,children:[/*#__PURE__*/e("span",{style:{fontWeight:"500"},children:"Warning: Suspicious transaction"}),/*#__PURE__*/e("br",{}),"This has been flagged as a potentially deceptive request. Approving could put your assets or funds at risk."]})}):"error"===i?/*#__PURE__*/e(n,{children:/*#__PURE__*/r(q,{children:[/*#__PURE__*/e(E,{theme:t,children:/*#__PURE__*/r("div",{children:[/*#__PURE__*/e("strong",{children:"This is a malicious transaction"}),/*#__PURE__*/e("br",{}),"This transaction transfers tokens to a known malicious address. Proceeding may result in the loss of valuable assets."]})}),/*#__PURE__*/r(H,{children:[/*#__PURE__*/e(M,{color:"var(--privy-color-error)",checked:!l,readOnly:!0,onClick:()=>o(!l)}),/*#__PURE__*/e("span",{children:"I understand and want to proceed anyways."})]})]})}):null;let q=a.div` margin-top: 1.5rem; `,H=a.div` display: flex; align-items: center; gap: 0.5rem; margin-top: 0.75rem; `;const J=({transactionIndex:e,maxIndex:r})=>"number"!=typeof e||0===r?"":` (${e+1} / ${r+1})`,Q=({img:a,submitError:s,prepareError:u,onClose:v,action:I,title:C,subtitle:$,to:j,tokenAddress:M,network:E,missingFunds:O,fee:D,from:N,cta:F,disabled:L,chain:z,isSubmitting:B,isPreparing:R,isTokenPriceLoading:q,isTokenContractInfoLoading:H,isSponsored:Q,symbol:Y,balance:G,onClick:re,transactionDetails:ne,transactionIndex:ie,maxIndex:oe,onBack:te,chainName:le,validation:ae,hasScanDetails:se,setIsScanDetailsOpen:ce,preventMaliciousTransaction:de,setPreventMaliciousTransaction:he,tokensSent:me,tokensReceived:ue,isScanning:pe,isCancellable:ge,functionName:fe})=>{let{showTransactionDetails:ye,setShowTransactionDetails:ke,hasMoreDetails:xe,isErc20Ish:ve}=(e=>{let[r,n]=l(!1),i=!0,o=!1;return(!e||e.isErc20Ish||"transaction"===e.action)&&(i=!1),i&&(o=Object.entries(e||{}).some((([e,r])=>r&&!["action","isErc20Ish","isNFTIsh"].includes(e)))),{showTransactionDetails:r,setShowTransactionDetails:n,hasMoreDetails:i&&o,isErc20Ish:e?.isErc20Ish}})(ne),be=A(),we=ve&&H||R||q||pe;/*#__PURE__*/return r(n,{children:[/*#__PURE__*/e(c,{onClose:v,backFn:te}),a&&/*#__PURE__*/e(Z,{children:a}),/*#__PURE__*/r(w,{style:{marginTop:a?"1.5rem":0},children:[C,/*#__PURE__*/e(J,{maxIndex:oe,transactionIndex:ie})]}),/*#__PURE__*/e(b,{children:$}),/*#__PURE__*/r(y,{style:{marginTop:"2rem"},children:[(!!me[0]||we)&&/*#__PURE__*/r(k,{children:[ue.length>0?/*#__PURE__*/e(p,{children:"Send"}):/*#__PURE__*/e(p,{children:"approve"===I?"Approval amount":"Amount"}),/*#__PURE__*/e("div",{className:"flex flex-col",children:me.map(((r,n)=>/*#__PURE__*/e(W,{iconUrl:r.iconUrl,value:"setApprovalForAll"===fe?"All":r.value,usdValue:r.usdValue,symbol:r.symbol,nftName:r.nftName,nftCount:r.nftCount,decimals:r.decimals},n)))})]}),ue.length>0&&/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Receive"}),/*#__PURE__*/e("div",{className:"flex flex-col",children:ue.map(((r,n)=>/*#__PURE__*/e(W,{iconUrl:r.iconUrl,value:r.value,usdValue:r.usdValue,symbol:r.symbol,nftName:r.nftName,nftCount:r.nftCount,decimals:r.decimals},n)))})]}),ne&&"spender"in ne&&ne?.spender?/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Spender"}),/*#__PURE__*/e(g,{children:/*#__PURE__*/e(T,{address:ne.spender,url:z?.blockExplorers?.default?.url})})]}):null,j&&/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"To"}),/*#__PURE__*/e(g,{children:/*#__PURE__*/e(T,{address:j,url:z?.blockExplorers?.default?.url,showCopyIcon:!0})})]}),M&&/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Token address"}),/*#__PURE__*/e(g,{children:/*#__PURE__*/e(T,{address:M,url:z?.blockExplorers?.default?.url})})]}),/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Network"}),/*#__PURE__*/e(g,{children:E})]}),/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Estimated fee"}),/*#__PURE__*/e(g,{$isLoading:R||q||void 0===Q,children:Q?/*#__PURE__*/r(_,{children:[/*#__PURE__*/r(ee,{children:["Sponsored by ",be.name]}),/*#__PURE__*/e(i,{height:16,width:16})]}):D})]}),xe&&!se&&/*#__PURE__*/r(n,{children:[/*#__PURE__*/e(k,{className:"cursor-pointer",onClick:()=>ke(!ye),children:/*#__PURE__*/r(f,{className:"flex items-center gap-x-1",children:["Details"," ",/*#__PURE__*/e(t,{style:{width:"0.75rem",marginLeft:"0.25rem",transform:ye?"rotate(180deg)":void 0}})]})}),ye&&ne&&/*#__PURE__*/e(V,{action:I,chain:z,transactionDetails:ne,isTokenContractInfoLoading:H,symbol:Y})]}),se&&/*#__PURE__*/e(k,{children:/*#__PURE__*/r(P,{onClick:()=>ce(!0),children:[/*#__PURE__*/e("span",{className:"text-color-primary",children:"Details"}),/*#__PURE__*/e(o,{height:"14px",width:"14px",strokeWidth:"2"})]})})]}),/*#__PURE__*/e(S,{}),s?/*#__PURE__*/e(x,{style:{marginTop:"2rem"},children:s.message}):u&&0===ie? /*#__PURE__*/e(x,{style:{marginTop:"2rem"},children:u.shortMessage??K}):null,/*#__PURE__*/e(U,{variant:ae,preventMaliciousTransaction:de,setPreventMaliciousTransaction:he}),/*#__PURE__*/e(X,{$useSmallMargins:!(!u&&!s&&"warn"!==ae&&"error"!==ae),address:N,balance:G,errMsg:R||u||s||!O?void 0:`Add funds on ${z?.name??le} to complete transaction.`}),/*#__PURE__*/e(d,{style:{marginTop:"1rem"},loading:B,disabled:L||R,onClick:re,children:F}),ge&&/*#__PURE__*/e(h,{style:{marginTop:"1rem"},onClick:v,isSubmitting:!1,children:"Not now"}),/*#__PURE__*/e(m,{})]})},Y=({img:o,title:a,subtitle:h,cta:u,instructions:f,network:I,blockExplorerUrl:C,isMissingFunds:$,submitError:j,parseError:M,total:E,swap:O,transactingWalletAddress:D,fee:N,balance:F,disabled:L,isSubmitting:W,isPreparing:z,isTokenPriceLoading:B,onClick:R,onClose:V,onBack:U,isSponsored:q})=>{let H=z||B,[J,Q]=l(!1),Y=A();/*#__PURE__*/return r(n,{children:[/*#__PURE__*/e(c,{onClose:V,backFn:U}),o&&/*#__PURE__*/e(Z,{children:o}),/*#__PURE__*/e(w,{style:{marginTop:o?"1.5rem":0},children:a}),/*#__PURE__*/e(b,{children:h}),/*#__PURE__*/r(y,{style:{marginTop:"2rem",marginBottom:".5rem"},children:[(E||H)&&/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Amount"}),/*#__PURE__*/e(g,{$isLoading:H,children:E})]}),O&&/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Swap"}),/*#__PURE__*/e(g,{children:O})]}),I&&/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Network"}),/*#__PURE__*/e(g,{children:I})]}),(N||H||void 0!==q)&&/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Estimated fee"}),/*#__PURE__*/e(g,{$isLoading:H,children:q&&!H?/*#__PURE__*/r(_,{children:[/*#__PURE__*/r(ee,{children:["Sponsored by ",Y.name]}),/*#__PURE__*/e(i,{height:16,width:16})]}):N})]})]}),/*#__PURE__*/e(k,{children:/*#__PURE__*/r(P,{onClick:()=>Q((e=>!e)),children:[/*#__PURE__*/e("span",{children:"Advanced"}),/*#__PURE__*/e(t,{height:"16px",width:"16px",strokeWidth:"2",style:{transition:"all 300ms",transform:J?"rotate(180deg)":void 0}})]})}),J&&/*#__PURE__*/e(n,{children:f.map(((n,i)=>"sol-transfer"===n.type?/*#__PURE__*/r(G,{children:[/*#__PURE__*/e(k,{children:/*#__PURE__*/r(v,{children:["Transfer ",n.withSeed?"with seed":""]})}),/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Amount"}),/*#__PURE__*/r(g,{children:[s({amount:n.value,decimals:n.token.decimals})," ",n.token.symbol]})]}),!!n.toAccount&&/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Destination"}),/*#__PURE__*/e(g,{children:/*#__PURE__*/e(T,{address:n.toAccount,url:C})})]})]},i):"spl-transfer"===n.type?/*#__PURE__*/r(G,{children:[/*#__PURE__*/e(k,{children:/*#__PURE__*/r(v,{children:["Transfer ",n.token.symbol]})}),/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Amount"}),/*#__PURE__*/e(g,{children:n.value.toString()})]}),!!n.fromAta&&/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Source"}),/*#__PURE__*/e(g,{children:/*#__PURE__*/e(T,{address:n.fromAta,url:C})})]}),!!n.toAta&&/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Destination"}),/*#__PURE__*/e(g,{children:/*#__PURE__*/e(T,{address:n.toAta,url:C})})]}),!!n.token.address&&/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Token"}),/*#__PURE__*/e(g,{children:/*#__PURE__*/e(T,{address:n.token.address,url:C})})]})]},i):"ata-creation"===n.type?/*#__PURE__*/r(G,{children:[/*#__PURE__*/e(k,{children:/*#__PURE__*/e(v,{children:"Create token account"})}),/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Program ID"}),/*#__PURE__*/e(g,{children:/*#__PURE__*/e(T,{address:n.program,url:C})})]}),!!n.owner&&/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Owner"}),/*#__PURE__*/e(g,{children:/*#__PURE__*/e(T,{address:n.owner,url:C})})]})]},i):"create-account"===n.type?/*#__PURE__*/r(G,{children:[/*#__PURE__*/e(k,{children:/*#__PURE__*/r(v,{children:["Create account ",n.withSeed?"with seed":""]})}),!!n.account&&/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Account"}),/*#__PURE__*/e(g,{children:/*#__PURE__*/e(T,{address:n.account,url:C})})]}),/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Amount"}),/*#__PURE__*/r(g,{children:[s({amount:n.value,decimals:9})," SOL"]})]})]},i):"spl-init-account"===n.type?/*#__PURE__*/r(G,{children:[/*#__PURE__*/e(k,{children:/*#__PURE__*/e(v,{children:"Initialize token account"})}),!!n.account&&/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Account"}),/*#__PURE__*/e(g,{children:/*#__PURE__*/e(T,{address:n.account,url:C})})]}),!!n.mint&&/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Mint"}),/*#__PURE__*/e(g,{children:/*#__PURE__*/e(T,{address:n.mint,url:C})})]}),!!n.owner&&/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Owner"}),/*#__PURE__*/e(g,{children:/*#__PURE__*/e(T,{address:n.owner,url:C})})]})]},i):"spl-close-account"===n.type?/*#__PURE__*/r(G,{children:[/*#__PURE__*/e(k,{children:/*#__PURE__*/e(v,{children:"Close token account"})}),!!n.source&&/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Source"}),/*#__PURE__*/e(g,{children:/*#__PURE__*/e(T,{address:n.source,url:C})})]}),!!n.destination&&/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Destination"}),/*#__PURE__*/e(g,{children:/*#__PURE__*/e(T,{address:n.destination,url:C})})]}),!!n.owner&&/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Owner"}),/*#__PURE__*/e(g,{children:/*#__PURE__*/e(T,{address:n.owner,url:C})})]})]},i):"spl-sync-native"===n.type?/*#__PURE__*/r(G,{children:[/*#__PURE__*/e(k,{children:/*#__PURE__*/e(v,{children:"Sync native"})}),/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Program ID"}),/*#__PURE__*/e(g,{children:/*#__PURE__*/e(T,{address:n.program,url:C})})]})]},i):"raydium-swap-base-input"===n.type?/*#__PURE__*/r(G,{children:[/*#__PURE__*/e(k,{children:/*#__PURE__*/r(v,{children:["Raydium swap"," ",n.tokenIn&&n.tokenOut?`${n.tokenIn.symbol} → ${n.tokenOut.symbol}`:""]})}),/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Amount in"}),/*#__PURE__*/e(g,{children:n.amountIn.toString()})]}),/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Minimum amount out"}),/*#__PURE__*/e(g,{children:n.minimumAmountOut.toString()})]}),n.mintIn&&/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Token in"}),/*#__PURE__*/e(g,{children:/*#__PURE__*/e(T,{address:n.mintIn,url:C})})]}),n.mintOut&&/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Token out"}),/*#__PURE__*/e(g,{children:/*#__PURE__*/e(T,{address:n.mintOut,url:C})})]})]},i):"raydium-swap-base-output"===n.type?/*#__PURE__*/r(G,{children:[/*#__PURE__*/e(k,{children:/*#__PURE__*/r(v,{children:["Raydium swap"," ",n.tokenIn&&n.tokenOut?`${n.tokenIn.symbol} → ${n.tokenOut.symbol}`:""]})}),/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Max amount in"}),/*#__PURE__*/e(g,{children:n.maxAmountIn.toString()})]}),/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Amount out"}),/*#__PURE__*/e(g,{children:n.amountOut.toString()})]}),n.mintIn&&/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Token in"}),/*#__PURE__*/e(g,{children:/*#__PURE__*/e(T,{address:n.mintIn,url:C})})]}),n.mintOut&&/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Token out"}),/*#__PURE__*/e(g,{children:/*#__PURE__*/e(T,{address:n.mintOut,url:C})})]})]},i):"jupiter-swap-shared-accounts-route"===n.type?/*#__PURE__*/r(G,{children:[/*#__PURE__*/e(k,{children:/*#__PURE__*/r(v,{children:["Jupiter swap"," ",n.tokenIn&&n.tokenOut?`${n.tokenIn.symbol} → ${n.tokenOut.symbol}`:""]})}),/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"In amount"}),/*#__PURE__*/e(g,{children:n.inAmount.toString()})]}),/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Quoted out amount"}),/*#__PURE__*/e(g,{children:n.quotedOutAmount.toString()})]}),n.mintIn&&/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Token in"}),/*#__PURE__*/e(g,{children:/*#__PURE__*/e(T,{address:n.mintIn,url:C})})]}),n.mintOut&&/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Token out"}),/*#__PURE__*/e(g,{children:/*#__PURE__*/e(T,{address:n.mintOut,url:C})})]})]},i):"jupiter-swap-exact-out-route"===n.type?/*#__PURE__*/r(G,{children:[/*#__PURE__*/e(k,{children:/*#__PURE__*/r(v,{children:["Jupiter swap"," ",n.tokenIn&&n.tokenOut?`${n.tokenIn.symbol} → ${n.tokenOut.symbol}`:""]})}),/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Quoted in amount"}),/*#__PURE__*/e(g,{children:n.quotedInAmount.toString()})]}),/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Amount out"}),/*#__PURE__*/e(g,{children:n.outAmount.toString()})]}),n.mintIn&&/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Token in"}),/*#__PURE__*/e(g,{children:/*#__PURE__*/e(T,{address:n.mintIn,url:C})})]}),n.mintOut&&/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Token out"}),/*#__PURE__*/e(g,{children:/*#__PURE__*/e(T,{address:n.mintOut,url:C})})]})]},i):/*#__PURE__*/r(G,{children:[/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Program ID"}),/*#__PURE__*/e(g,{children:/*#__PURE__*/e(T,{address:n.program,url:C})})]}),/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Data"}),/*#__PURE__*/e(g,{children:n.discriminator})]})]},i)))}),/*#__PURE__*/e(S,{}),j?/*#__PURE__*/e(x,{style:{marginTop:"2rem"},children:j.message}):M?/*#__PURE__*/e(x,{style:{marginTop:"2rem"},children:K}):null,/*#__PURE__*/e(X,{$useSmallMargins:!(!M&&!j),title:"",address:D,balance:F,errMsg:z||M||j||!$?void 0:"Add funds on Solana to complete transaction."}),/*#__PURE__*/e(d,{style:{marginTop:"1rem"},loading:W,disabled:L||z,onClick:R,children:u}),/*#__PURE__*/e(m,{})]})};let X=a(I)` ${e=>e.$useSmallMargins?"margin-top: 0.5rem;":"margin-top: 2rem;"} `,G=a(y)` margin-top: 0.5rem; border: 1px solid var(--privy-color-foreground-4); border-radius: var(--privy-border-radius-sm); padding: 0.5rem; `,K="There was an error preparing your transaction. Your transaction request will likely fail.",Z=a.div` display: flex; width: 100%; justify-content: center; max-height: 40px; > img { object-fit: contain; border-radius: var(--privy-border-radius-sm); } `,_=a.span` display: inline-flex; align-items: center; gap: 0.3rem; `,ee=a.span` font-size: 14px; font-weight: 500; color: var(--privy-color-foreground); `;let re=()=>/*#__PURE__*/r(le,{children:[/*#__PURE__*/e(se,{}),/*#__PURE__*/e(ae,{})]});const ne=({transactionError:i,chainId:o,onClose:t,onRetry:a,chainType:s,transactionHash:d})=>{let{chains:h}=L(),[m,p]=l(!1),{errorCode:g,errorMessage:f}=((e,r)=>{if("ethereum"===r)return{errorCode:e.details??e.message,errorMessage:e.shortMessage};let n=e.txSignature,i=e?.transactionMessage||"Something went wrong.";if(Array.isArray(e.logs)){let r=e.logs.find((e=>/insufficient (lamports|funds)/gi.test(e)));r&&(i=r)}return{transactionHash:n,errorMessage:i}})(i,s),y=(({chains:e,chainId:r,chainType:n,transactionHash:i})=>"ethereum"===n?e.find((e=>e.id===r))?.blockExplorers?.default.url??"https://etherscan.io":function(e,r){return`https://explorer.solana.com/tx/${e}?chain=${r}`}(i||"",r))({chains:h,chainId:o,chainType:s,transactionHash:d});/*#__PURE__*/return r(n,{children:[/*#__PURE__*/e(c,{onClose:t}),/*#__PURE__*/r(ie,{children:[/*#__PURE__*/e(re,{}),/*#__PURE__*/e(oe,{children:g}),/*#__PURE__*/e(te,{children:"Please try again."}),/*#__PURE__*/r(he,{children:[/*#__PURE__*/e(de,{children:"Error message"}),/*#__PURE__*/e(ue,{$clickable:!1,children:f})]}),d&&/*#__PURE__*/r(he,{children:[/*#__PURE__*/e(de,{children:"Transaction hash"}),/*#__PURE__*/r(me,{children:["Copy this hash to view details about the transaction on a"," ",/*#__PURE__*/e("u",{children:/*#__PURE__*/e("a",{href:y,children:"block explorer"})}),"."]}),/*#__PURE__*/r(ue,{$clickable:!0,onClick:async()=>{await navigator.clipboard.writeText(d),p(!0)},children:[d,/*#__PURE__*/e(fe,{clicked:m})]})]}),/*#__PURE__*/e(ce,{onClick:()=>a({resetNonce:!!d}),children:"Retry transaction"})]}),/*#__PURE__*/e(u,{})]})};let ie=a.div` display: flex; flex-direction: column; align-items: center; justify-content: center; `,oe=a.span` color: var(--privy-color-foreground); text-align: center; font-size: 1.125rem; font-weight: 500; line-height: 1.25rem; /* 111.111% */ text-align: center; margin: 10px; `,te=a.span` margin-top: 4px; margin-bottom: 10px; color: var(--privy-color-foreground-3); text-align: center; font-size: 0.875rem; font-style: normal; font-weight: 400; line-height: 20px; /* 142.857% */ letter-spacing: -0.008px; `,le=a.div` position: relative; width: 60px; height: 60px; margin: 10px; display: flex; justify-content: center; align-items: center; `,ae=a(F)` position: absolute; width: 35px; height: 35px; color: var(--privy-color-error); `,se=a.div` position: absolute; width: 60px; height: 60px; border-radius: 50%; background-color: var(--privy-color-error); opacity: 0.1; `,ce=a(d)` && { margin-top: 24px; } transition: color 350ms ease, background-color 350ms ease; `,de=a.span` width: 100%; text-align: left; font-size: 0.825rem; color: var(--privy-color-foreground); padding: 4px; `,he=a.div` width: 100%; margin: 5px; display: flex; flex-direction: column; justify-content: center; align-items: center; `,me=a.text` position: relative; width: 100%; padding: 5px; font-size: 0.8rem; color: var(--privy-color-foreground-3); text-align: left; word-wrap: break-word; `,ue=a.span` position: relative; width: 100%; background-color: var(--privy-color-background-2); padding: 8px 12px; border-radius: 10px; margin-top: 5px; font-size: 14px; color: var(--privy-color-foreground-3); text-align: left; word-wrap: break-word; ${e=>e.$clickable&&"cursor: pointer;\n transition: background-color 0.3s;\n padding-right: 45px;\n\n &:hover {\n background-color: var(--privy-color-foreground-4);\n }"} `,pe=a(N)` position: absolute; top: 13px; right: 13px; width: 24px; height: 24px; `,ge=a(D)` position: absolute; top: 13px; right: 13px; width: 24px; height: 24px; `,fe=({clicked:r})=>/*#__PURE__*/e(r?ge:pe,{});export{Q as S,ne as T,Y as a};