import{jsxs as e,jsx as o,Fragment as r}from"react/jsx-runtime";import n from"@heroicons/react/24/outline/DevicePhoneMobileIcon";import i from"@heroicons/react/24/outline/FingerPrintIcon";import t from"@heroicons/react/24/outline/PhoneIcon";import a from"@heroicons/react/24/outline/ShieldCheckIcon";import{b as s,M as c,P as l,S as d}from"./ModalHeader-DffkxvO4.mjs";import{S as m}from"./ScreenLayout-Caq5mGD8.mjs";import{l as h,m as p,C as u}from"./useActiveWallet-BEfvREjE.mjs";import{M as g,F as f,T as y,L as C,a as k,b as T,C as S,E as b,P as v,I,N as w,S as P}from"./PinInput-B8vD-umi.mjs";import j from"@heroicons/react/24/outline/CalendarIcon";import x from"@heroicons/react/24/outline/ExclamationTriangleIcon";import{e as B}from"./StackedContainer-B2vaEl56.mjs";import{u as E}from"./internal-context-dfitw7Ot.mjs";import{useState as M,useMemo as V,useEffect as A}from"react";import{styled as Y}from"styled-components";import{toHex as D}from"viem";import{u as F}from"./useGetTokenPrice-ENX-6s3C.mjs";import{u as L}from"./get-entropy-details-for-user-BIWg0YxF.mjs";import{d as H}from"./toViemAccount-4iGGrW4w.mjs";import{g as N}from"./getPublicClient-D4yNgeGy.mjs";import{T as G}from"./TransactionDetails-BIrREalL.mjs";import{u as W}from"./context-BKnOUECq.mjs";import{c as Z,d as $,f as _}from"./index-C5jxD-zy.mjs";const q=({handleClose:r,mfaMethods:c,onSelect:l})=>/*#__PURE__*/e(m,{title:"Verify your identity",subtitle:"Choose a verification method",icon:a,iconVariant:"subtle",onClose:r,showClose:!0,watermark:!0,children:[/*#__PURE__*/e(g,{children:[c.includes("totp")&&/*#__PURE__*/e(h,{onClick:()=>l("totp"),children:[/*#__PURE__*/o(p,{children:/*#__PURE__*/o(n,{})}),"Authenticator app"]},"totp"),c.includes("sms")&&/*#__PURE__*/e(h,{onClick:()=>l("sms"),children:[/*#__PURE__*/o(p,{children:/*#__PURE__*/o(t,{})}),"SMS"]},"sms"),c.includes("passkey")&&/*#__PURE__*/e(h,{onClick:()=>l("passkey"),children:[/*#__PURE__*/o(p,{children:/*#__PURE__*/o(i,{})}),"Passkey"]},"passkey")]}),/*#__PURE__*/o(s,{})]}),z=({pendingTransaction:e})=>{let{wallets:r}=L(),{walletProxy:n,rpcConfig:i,chains:t,appId:a,nativeTokenSymbolForChainId:s}=E(),[c,l]=M(null),[d,m]=M(e),{tokenPrice:h}=F(d.chainId),p=s(e.chainId)||"ETH",u=V((()=>r.find((e=>"privy"===e.walletClientType))),[r]);return A((()=>{(async function(){if(!n||!u)return d;let e=N(d.chainId,t,i,{appId:a}),o=await H(d,e,u.address);return l(D(BigInt(o.gas??0))),o})().then(m).catch(console.error)}),[n]),u?/*#__PURE__*/o(J,{children:/*#__PURE__*/o(G,{from:u.address,to:d.to,txn:d,gas:c??void 0,tokenPrice:h,tokenSymbol:p})}):null};let J=Y.div`
  width: 100%;
  padding: 1rem 0;
`;const K=({hasBlockingError:n,error:i,onClose:t,onBack:d,handleSubmit:m,account:h,submitSuccess:p})=>{let{pendingTransaction:g}=E();/*#__PURE__*/return e(r,{children:[/*#__PURE__*/o(c,{onClose:t},"header"),/*#__PURE__*/o(B,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/o(u,{success:p,fail:!!i}),/*#__PURE__*/o(i?x:f,{style:{width:"38px",height:"38px"}})]})}),/*#__PURE__*/o(y,{style:{marginTop:"1rem"},children:"Verifying with passkey"}),/*#__PURE__*/e(C,{children:[/*#__PURE__*/e(k,{children:[/*#__PURE__*/o(T,{children:/*#__PURE__*/o(a,{})}),"Approve this action using your touch, face, PIN, or hardware key."]}),/*#__PURE__*/e(k,{children:[/*#__PURE__*/o(T,{children:/*#__PURE__*/o(j,{})}),"You last added a passkey on"," ",h?.firstVerifiedAt?.toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"}),"."]})]}),g&&/*#__PURE__*/o(S,{children:/*#__PURE__*/o(z,{pendingTransaction:g})}),i&&/*#__PURE__*/e(r,{children:[/*#__PURE__*/o(b,{style:{marginTop:"1.25rem"},children:i.message}),/*#__PURE__*/o(l,{disabled:n,onClick:m,style:{margin:"1.25rem auto 0"},children:"Try again"})]}),d&&/*#__PURE__*/o(v,{style:{marginTop:"1rem"},onClick:d,children:"Choose another method"}),/*#__PURE__*/o(s,{})]})},O=({selectedMethod:i,submitSuccess:a,hasBlockingError:l,onClose:m,onBack:h,handleSubmitCode:p})=>{let u=W(),{pendingTransaction:g}=E();switch(i){case"sms":/*#__PURE__*/return e(r,{children:[/*#__PURE__*/o(c,{onClose:m},"header"),/*#__PURE__*/o(I,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/o(t,{})}),/*#__PURE__*/o(y,{children:"Enter verification code"}),/*#__PURE__*/e(S,{children:[/*#__PURE__*/o(w,{success:a,disabled:l,onChange:p}),/*#__PURE__*/e(P,{children:["To continue, please enter the 6-digit code sent to your ",/*#__PURE__*/o("strong",{children:"mobile device"})]}),g&&/*#__PURE__*/o(z,{pendingTransaction:g})]}),h&&/*#__PURE__*/o(v,{theme:u?.appearance.palette.colorScheme,onClick:h,children:"Choose another method"}),/*#__PURE__*/o(d,{onClick:m,children:"Cancel"}),/*#__PURE__*/o(s,{})]});case"totp":/*#__PURE__*/return e(r,{children:[/*#__PURE__*/o(c,{onClose:m},"header"),/*#__PURE__*/o(I,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/o(n,{})}),/*#__PURE__*/o(y,{children:"Enter verification code"}),/*#__PURE__*/e(S,{children:[/*#__PURE__*/o(w,{success:a,disabled:l,onChange:p}),/*#__PURE__*/e(P,{children:["To continue, please enter the 6-digit code generated from your"," ",/*#__PURE__*/o("strong",{children:"authenticator app"})]}),g&&/*#__PURE__*/o(z,{pendingTransaction:g})]}),h&&/*#__PURE__*/o(v,{theme:u?.appearance.palette.colorScheme,onClick:h,children:"Choose another method"}),/*#__PURE__*/o(d,{onClick:m,children:"Cancel"}),/*#__PURE__*/o(s,{})]});default:return null}},Q=e=>Z(e)?{isBlocking:!0,error:Error("You have exceeded the maximum number of attempts. Please close this window and try again in 10 seconds.")}:$(e)?{isBlocking:!1,error:Error("The code you entered is not valid")}:_(e)?{isBlocking:!0,error:Error("You have exceeded the time limit for code entry. Please try again in 30 seconds.")}:(console.error(e),{isBlocking:!1,error:Error("Something went wrong.")});export{K as V,O as a,q as b,Q as t};
//# sourceMappingURL=to-ui-error-C5L4eJlu.mjs.map
