import{jsx as o}from"react/jsx-runtime";import{useMemo as e,useState as t,useEffect as r,useRef as i}from"react";import{u as s}from"./context-BKnOUECq.mjs";import{u as m}from"./modal-context-DBwfUxD-.mjs";import{u as n}from"./privy-context-Bi6vqCPc.mjs";import{V as a,a as c,b as p,t as l}from"./to-ui-error-C5L4eJlu.mjs";import"@privy-io/js-sdk-core";import"tinycolor2";import"./internal-context-dfitw7Ot.mjs";import"@privy-io/are-addresses-equal";import"@heroicons/react/24/outline/DevicePhoneMobileIcon";import"@heroicons/react/24/outline/FingerPrintIcon";import"@heroicons/react/24/outline/PhoneIcon";import"@heroicons/react/24/outline/ShieldCheckIcon";import"./ModalHeader-DffkxvO4.mjs";import"styled-components";import"./useActiveWallet-BEfvREjE.mjs";import"viem/utils";import"./wallet-connect-58EobR5U.mjs";import"./errors-Dd6zfYtp.mjs";import"ofetch";import"./getPublicClient-D4yNgeGy.mjs";import"viem";import"viem/chains";import"eventemitter3";import"./events-context-BJ75xIIf.mjs";import"./index-BtwxknTg.mjs";import"zustand";import"react-device-detect";import"./get-entropy-details-for-user-BIWg0YxF.mjs";import"./user-D5cqJNp9.mjs";import"@heroicons/react/24/outline/ArrowLeftIcon";import"@heroicons/react/24/outline/ArrowRightIcon";import"@heroicons/react/24/outline/QuestionMarkCircleIcon";import"@heroicons/react/24/outline/XMarkIcon";import"./ScreenLayout-Caq5mGD8.mjs";import"./Screen-D8KNyGVj.mjs";import"./index-Dq_xe9dz.mjs";import"./PinInput-B8vD-umi.mjs";import"@heroicons/react/24/outline/CalendarIcon";import"@heroicons/react/24/outline/ExclamationTriangleIcon";import"./StackedContainer-B2vaEl56.mjs";import"./useGetTokenPrice-ENX-6s3C.mjs";import"./useGetSolPrice-x7gfUIHJ.mjs";import"./toViemAccount-4iGGrW4w.mjs";import"jose";import"@coinbase/wallet-sdk";import"@walletconnect/ethereum-provider";import"./pkce-BinverJO.mjs";import"./paths-BH8W4zMc.mjs";import"./PrivyPluginContext-DA-yS5vO.mjs";import"js-cookie";import"@privy-io/ethereum";import"viem/accounts";import"./TransactionDetails-BIrREalL.mjs";import"./WalletLink-B5NUjxf-.mjs";import"./ethers-VpbQV-TA.mjs";import"./getFormattedUsdFromLamports-B6EqSEho.mjs";import"./transaction-CnfuREWo.mjs";import"./Layouts-BlFm53ED.mjs";import"@heroicons/react/24/outline/ChevronDownIcon";import"./index-C5jxD-zy.mjs";import"mipd";import"@scure/base";import"./usePrivy-BhL-ltvm.mjs";import"./use-unlink-wallet-oAguM2-k.mjs";import"@privy-io/popup";import"@headlessui/react";import"@privy-io/urls";import"./getEmbeddedConnectedWallet-Ba6LFHzY.mjs";import"./frame-DtizlaLu.mjs";import"@privy-io/routes";import"./use-deposit-address-BwThybOQ.mjs";import"x402/client";import"@privy-io/api-base";import"./use-sign-with-user-signer-CQI6hUH7.mjs";const u={component:()=>{let{user:u}=n(),d=s(),h=e((()=>u?.mfaMethods.filter((o=>"passkey"!==o||!d.globalDisablePasskeys))??[]),[u?.mfaMethods,d.globalDisablePasskeys]),{data:j}=m(),[f,y]=t(h[0]),[v,k]=t(!1),[g,w]=t(),[b,C]=t();if(r((()=>{y(h[0])}),[h]),!j?.mfaVerify)throw Error("Missing modal data for MFA verification screen.");let{onFailure:x,onSuccess:S,generateOptions:I,verifyTotpCode:M,verifyPasskey:P,verifySmsCode:A,sendSmsCode:E}=j.mfaVerify,B=async o=>{if("passkey"!==o)try{y(o),"sms"===o&&(y(o),await E()),"totp"===o&&y(o)}catch(o){console.error(o)}else try{y(o);let e=await I();if(!e)throw Error("something went wrong");w(e),await P(e),k(!0),C(void 0),S()}catch(o){C(l(o))}},F=async o=>{C(void 0);try{if(!o||!f)return;if("passkey"===f){if(!g)throw Error("Missing passkey challenge");await P(g)}else"sms"===f?await A(o):"totp"===f&&await M(o);C(void 0),k(!0),S()}catch(o){throw l(o).error}},V=()=>{b||!v?x(b?.error??Error("Canceled MFA verification.")):S()},D=i(!1);return r((()=>{!D.current&&f&&(D.current=!0,B(f).finally((()=>{D.current=!1})))}),[open]),u?"passkey"===f?/*#__PURE__*/o(a,{account:u.linkedAccounts.filter((o=>"passkey"===o.type&&o.enrolledInMfa)).sort(((o,e)=>e.firstVerifiedAt.valueOf()-o.firstVerifiedAt.valueOf()))[0],submitSuccess:v,hasBlockingError:b?.isBlocking??!1,error:b?.error,onClose:V,onBack:()=>{y(void 0),C(void 0)},handleSubmit:()=>F(g).catch(C)}):"sms"===f||"totp"===f?/*#__PURE__*/o(c,{selectedMethod:f,submitSuccess:v,hasBlockingError:b?.isBlocking??!1,handleSubmitCode:F,onClose:V,onBack:h.length>1?()=>y(void 0):void 0}):/*#__PURE__*/o(p,{mfaMethods:h,onSelect:B,handleClose:V}):null}};export{u as MfaAuthVerifyFlowScreen,u as default};
//# sourceMappingURL=MfaAuthVerifyFlowScreen-DSrR1iZ-.mjs.map
