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-DffkxvO4.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-BOC18tYY.mjs";import{W as I}from"./WalletInfoCard-BVXOg6V2.mjs";import{u as A}from"./context-BKnOUECq.mjs";import{G as C}from"./useActiveWallet-BEfvREjE.mjs";import{L as S}from"./LoadingSkeleton-U6-3yFwI.mjs";import{isAddress as M}from"viem";import{B as $}from"./shared-FM0rljBt.mjs";import{C as j}from"./Checkbox-BhNoOKjX.mjs";import{E}from"./ErrorBanner-CQERa7bL.mjs";import{W as O}from"./WarningBanner-D5LqDt95.mjs";import N from"@heroicons/react/24/outline/ClipboardDocumentCheckIcon";import D from"@heroicons/react/24/outline/ClipboardDocumentIcon";import F from"@heroicons/react/24/outline/ExclamationCircleIcon";import{PrivyErrorCode as L}from"@privy-io/api-base";import{u as P}from"./internal-context-dfitw7Ot.mjs";const B=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(V,{src:n,alt:"Token icon"}),a&&a>1?a+"x":void 0," ",l,d," ",o]}),t&&/*#__PURE__*/r(R,{$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;

  ${S}
`;const R=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;

  ${S}
`;let V=a.img`
  height: 14px;
  width: 14px;
  margin-right: 4px;
  object-fit: contain;
`;const U=i=>{let{chain:o,transactionDetails:t,isTokenContractInfoLoading:l,symbol:a}=i,{action:s,functionName:c}=t;/*#__PURE__*/return e($,{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&&M(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||"transferWithMemo"===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})})]})]})})},H=({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(J,{children:[/*#__PURE__*/e(j,{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;
`,J=a.div`
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
`;const Q=({transactionIndex:e,maxIndex:r})=>"number"!=typeof e||0===r?"":` (${e+1} / ${r+1})`,G=({img:a,submitError:s,prepareError:u,onClose:v,action:I,title:S,subtitle:M,to:$,tokenAddress:j,network:E,missingFunds:O,fee:N,from:D,cta:F,disabled:L,chain:P,isSubmitting:z,isPreparing:R,isTokenPriceLoading:V,isTokenContractInfoLoading:q,isSponsored:J,symbol:G,balance:K,onClick:Y,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&&q||R||V||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:[S,/*#__PURE__*/e(Q,{maxIndex:oe,transactionIndex:ie})]}),/*#__PURE__*/e(b,{children:M}),/*#__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:P?.blockExplorers?.default?.url})})]}):null,$&&/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"To"}),/*#__PURE__*/e(g,{children:/*#__PURE__*/e(T,{address:$,url:P?.blockExplorers?.default?.url,showCopyIcon:!0})})]}),j&&/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Token address"}),/*#__PURE__*/e(g,{children:/*#__PURE__*/e(T,{address:j,url:P?.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||V||void 0===J,children:J?/*#__PURE__*/r(ee,{children:[/*#__PURE__*/r(re,{children:["Sponsored by ",be.name]}),/*#__PURE__*/e(i,{height:16,width:16})]}):N})]}),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(U,{action:I,chain:P,transactionDetails:ne,isTokenContractInfoLoading:q,symbol:G})]}),se&&/*#__PURE__*/e(k,{children:/*#__PURE__*/r(B,{onClick:()=>ce(!0),children:[/*#__PURE__*/e("span",{className:"text-color-primary",children:"Details"}),/*#__PURE__*/e(o,{height:"14px",width:"14px",strokeWidth:"2"})]})})]}),/*#__PURE__*/e(C,{}),s?/*#__PURE__*/e(x,{style:{marginTop:"2rem"},children:s.message}):u&&0===ie?
/*#__PURE__*/e(x,{style:{marginTop:"2rem"},children:u.shortMessage??_}):null,/*#__PURE__*/e(H,{variant:ae,preventMaliciousTransaction:de,setPreventMaliciousTransaction:he}),/*#__PURE__*/e(X,{$useSmallMargins:!(!u&&!s&&"warn"!==ae&&"error"!==ae),address:D,balance:K,errMsg:R||u||s||!O?void 0:`Add funds on ${P?.name??le} to complete transaction.`}),/*#__PURE__*/e(d,{style:{marginTop:"1rem"},loading:z,disabled:L||R,onClick:Y,children:F}),ge&&/*#__PURE__*/e(h,{style:{marginTop:"1rem"},onClick:v,isSubmitting:!1,children:"Not now"}),/*#__PURE__*/e(m,{})]})},K=({img:o,title:a,subtitle:h,cta:u,instructions:f,network:I,blockExplorerUrl:S,isMissingFunds:M,submitError:$,parseError:j,total:E,swap:O,transactingWalletAddress:N,fee:D,balance:F,disabled:L,isSubmitting:P,isPreparing:W,isTokenPriceLoading:z,onClick:R,onClose:V,onBack:U,isSponsored:H})=>{let q=W||z,[J,Q]=l(!1),G=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||q)&&/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Amount"}),/*#__PURE__*/e(g,{$isLoading:q,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})]}),(D||q||void 0!==H)&&/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Estimated fee"}),/*#__PURE__*/e(g,{$isLoading:q,children:H&&!q?/*#__PURE__*/r(ee,{children:[/*#__PURE__*/r(re,{children:["Sponsored by ",G.name]}),/*#__PURE__*/e(i,{height:16,width:16})]}):D})]})]}),/*#__PURE__*/e(k,{children:/*#__PURE__*/r(B,{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(Y,{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:S})})]})]},i):"spl-transfer"===n.type?/*#__PURE__*/r(Y,{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:S})})]}),!!n.toAta&&/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Destination"}),/*#__PURE__*/e(g,{children:/*#__PURE__*/e(T,{address:n.toAta,url:S})})]}),!!n.token.address&&/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Token"}),/*#__PURE__*/e(g,{children:/*#__PURE__*/e(T,{address:n.token.address,url:S})})]})]},i):"ata-creation"===n.type?/*#__PURE__*/r(Y,{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:S})})]}),!!n.owner&&/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Owner"}),/*#__PURE__*/e(g,{children:/*#__PURE__*/e(T,{address:n.owner,url:S})})]})]},i):"create-account"===n.type?/*#__PURE__*/r(Y,{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:S})})]}),/*#__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(Y,{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:S})})]}),!!n.mint&&/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Mint"}),/*#__PURE__*/e(g,{children:/*#__PURE__*/e(T,{address:n.mint,url:S})})]}),!!n.owner&&/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Owner"}),/*#__PURE__*/e(g,{children:/*#__PURE__*/e(T,{address:n.owner,url:S})})]})]},i):"spl-close-account"===n.type?/*#__PURE__*/r(Y,{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:S})})]}),!!n.destination&&/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Destination"}),/*#__PURE__*/e(g,{children:/*#__PURE__*/e(T,{address:n.destination,url:S})})]}),!!n.owner&&/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Owner"}),/*#__PURE__*/e(g,{children:/*#__PURE__*/e(T,{address:n.owner,url:S})})]})]},i):"spl-sync-native"===n.type?/*#__PURE__*/r(Y,{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:S})})]})]},i):"raydium-swap-base-input"===n.type?/*#__PURE__*/r(Y,{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:S})})]}),n.mintOut&&/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Token out"}),/*#__PURE__*/e(g,{children:/*#__PURE__*/e(T,{address:n.mintOut,url:S})})]})]},i):"raydium-swap-base-output"===n.type?/*#__PURE__*/r(Y,{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:S})})]}),n.mintOut&&/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Token out"}),/*#__PURE__*/e(g,{children:/*#__PURE__*/e(T,{address:n.mintOut,url:S})})]})]},i):"jupiter-swap-shared-accounts-route"===n.type?/*#__PURE__*/r(Y,{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:S})})]}),n.mintOut&&/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Token out"}),/*#__PURE__*/e(g,{children:/*#__PURE__*/e(T,{address:n.mintOut,url:S})})]})]},i):"jupiter-swap-exact-out-route"===n.type?/*#__PURE__*/r(Y,{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:S})})]}),n.mintOut&&/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Token out"}),/*#__PURE__*/e(g,{children:/*#__PURE__*/e(T,{address:n.mintOut,url:S})})]})]},i):/*#__PURE__*/r(Y,{children:[/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Program ID"}),/*#__PURE__*/e(g,{children:/*#__PURE__*/e(T,{address:n.program,url:S})})]}),/*#__PURE__*/r(k,{children:[/*#__PURE__*/e(p,{children:"Data"}),/*#__PURE__*/e(g,{children:n.discriminator})]})]},i)))}),/*#__PURE__*/e(C,{}),$?/*#__PURE__*/e(x,{style:{marginTop:"2rem"},children:$.message}):j?/*#__PURE__*/e(x,{style:{marginTop:"2rem"},children:_}):null,/*#__PURE__*/e(X,{$useSmallMargins:!(!j&&!$),title:"",address:N,balance:F,errMsg:W||j||$||!M?void 0:"Add funds on Solana to complete transaction."}),/*#__PURE__*/e(d,{style:{marginTop:"1rem"},loading:P,disabled:L||W,onClick:R,children:u}),/*#__PURE__*/e(m,{})]})};let X=a(I)`
  ${e=>e.$useSmallMargins?"margin-top: 0.5rem;":"margin-top: 2rem;"}
`,Y=a(y)`
  margin-top: 0.5rem;
  border: 1px solid var(--privy-color-foreground-4);
  border-radius: var(--privy-border-radius-sm);
  padding: 0.5rem;
`,_="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);
  }
`,ee=a.span`
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
`,re=a.span`
  font-size: 14px;
  font-weight: 500;
  color: var(--privy-color-foreground);
`;let ne=e=>e?.code===L.COMPLIANCE_BLOCKED,ie=()=>/*#__PURE__*/r(se,{children:[/*#__PURE__*/e(de,{}),/*#__PURE__*/e(ce,{})]});const oe=({transactionError:i,chainId:o,onClose:t,onRetry:a,chainType:s,transactionHash:d})=>{let{chains:h}=P(),[m,p]=l(!1),{errorCode:g,errorMessage:f}=((e,r)=>{if("ethereum"===r)return ne(e)?{errorCode:"Transaction blocked",errorMessage:e.message}:{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=ne(i),k=(({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(te,{children:[/*#__PURE__*/e(ie,{}),/*#__PURE__*/e(le,{children:g}),/*#__PURE__*/e(ae,{children:y?"This transaction cannot be completed.":"Please try again."}),/*#__PURE__*/r(ue,{children:[/*#__PURE__*/e(me,{children:"Error message"}),/*#__PURE__*/e(ge,{$clickable:!1,children:f})]}),d&&/*#__PURE__*/r(ue,{children:[/*#__PURE__*/e(me,{children:"Transaction hash"}),/*#__PURE__*/r(pe,{children:["Copy this hash to view details about the transaction on a"," ",/*#__PURE__*/e("u",{children:/*#__PURE__*/e("a",{href:k,children:"block explorer"})}),"."]}),/*#__PURE__*/r(ge,{$clickable:!0,onClick:async()=>{await navigator.clipboard.writeText(d),p(!0)},children:[d,/*#__PURE__*/e(ke,{clicked:m})]})]}),!y&&/*#__PURE__*/e(he,{onClick:()=>a({resetNonce:!!d}),children:"Retry transaction"})]}),/*#__PURE__*/e(u,{})]})};let te=a.div`
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
`,le=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;
`,ae=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;
`,se=a.div`
  position: relative;
  width: 60px;
  height: 60px;
  margin: 10px;
  display: flex;
  justify-content: center;
  align-items: center;
`,ce=a(F)`
  position: absolute;
  width: 35px;
  height: 35px;
  color: var(--privy-color-error);
`,de=a.div`
  position: absolute;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background-color: var(--privy-color-error);
  opacity: 0.1;
`,he=a(d)`
  && {
    margin-top: 24px;
  }
  transition:
    color 350ms ease,
    background-color 350ms ease;
`,me=a.span`
  width: 100%;
  text-align: left;
  font-size: 0.825rem;
  color: var(--privy-color-foreground);
  padding: 4px;
`,ue=a.div`
  width: 100%;
  margin: 5px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
`,pe=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;
`,ge=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  }"}
`,fe=a(D)`
  position: absolute;
  top: 13px;
  right: 13px;
  width: 24px;
  height: 24px;
`,ye=a(N)`
  position: absolute;
  top: 13px;
  right: 13px;
  width: 24px;
  height: 24px;
`,ke=({clicked:r})=>/*#__PURE__*/e(r?ye:fe,{});export{G as S,oe as T,K as a};
//# sourceMappingURL=TransactionErrorView-DeK4ya42.mjs.map
