"use strict";var e=require("react/jsx-runtime"),r=require("lucide-react"),t=require("react"),i=require("./index-BoiKFBqR.js"),s=require("./modal-context-BgeioxwT.js"),u=require("./ScreenLayout-DaFW0I3a.js");require("@privy-io/js-sdk-core"),require("./toViemAccount-CopJpCYv.js"),require("jose"),require("./privy-context-UTJouJ1x.js"),require("@privy-io/are-addresses-equal"),require("./internal-context-CdsQ3LEl.js"),require("eventemitter3"),require("./index-Ub4KpwSY.js"),require("zustand"),require("./context-rs-ygOK2.js"),require("tinycolor2"),require("viem"),require("viem/utils"),require("./errors-CBapWvRs.js"),require("ofetch"),require("./wallet-connect-BuohfvHK.js"),require("./getPublicClient-CFd_sHBk.js"),require("viem/chains"),require("react-device-detect"),require("@coinbase/wallet-sdk"),require("@walletconnect/ethereum-provider"),require("./pkce-CmuJlEgn.js"),require("./paths-DizMb-lU.js"),require("./PrivyPluginContext-DsLtVhZA.js"),require("js-cookie"),require("@privy-io/ethereum"),require("viem/accounts"),require("mipd"),require("@scure/base"),require("./usePrivy-Dt4_yE6Q.js"),require("./use-unlink-wallet-DAxmY7kq.js"),require("./get-entropy-details-for-user-D63rM5_a.js"),require("./user-D2oPA-vS.js"),require("@privy-io/popup"),require("./events-context-Di6--rDg.js"),require("styled-components"),require("./useActiveWallet-dTc6deka.js"),require("@headlessui/react"),require("@privy-io/urls"),require("./getEmbeddedConnectedWallet-D6YL2FS9.js"),require("./frame-BHa-PKpX.js"),require("@privy-io/routes"),require("./use-deposit-address-CVyd0fqP.js"),require("x402/client"),require("@privy-io/api-base"),require("./use-sign-with-user-signer-BhoaqeNG.js"),require("./ModalHeader-Cpls13mi.js"),require("@heroicons/react/24/outline/ArrowLeftIcon"),require("@heroicons/react/24/outline/ArrowRightIcon"),require("@heroicons/react/24/outline/QuestionMarkCircleIcon"),require("@heroicons/react/24/outline/XMarkIcon"),require("./Screen-8NusMFtu.js"),require("./index-ByFhjjzH.js");const a=({status:i,title:s,description:a,userIntentRequired:n,retriesRemaining:o,hasSelectedCta:c,onContinue:l,onRetry:d})=>{let q=t.useMemo((()=>{switch(i){case"loading":default:return;case"success":return n?{label:c?"Continuing...":"Continue",onClick:l,disabled:c,loading:c}:void 0;case"error":return o>0?{label:"Retry",onClick:d}:void 0}}),[i,c,l,d]),p=t.useMemo((()=>({loading:"loading",ready:"subtle",disabled:"subtle",success:"success",error:"error"}[i]||"loading")),[i]);/*#__PURE__*/return e.jsx(u.ScreenLayout,{icon:"loading"===i||"ready"===i?void 0:"success"===i?r.CheckCircle:r.XCircle,iconVariant:p,title:s,subtitle:a,primaryCta:q,watermark:!0})},n={component:()=>{let{lastScreen:r,data:u,navigate:n,setModalData:o}=s.usePrivyModal(),{status:c,token:l,waitForResult:d,reset:q,execute:p}=i.useCaptcha(),j=t.useRef([]),y=e=>{j.current=[e,...j.current]},[h,m]=t.useState(!0);t.useEffect((()=>(y(setTimeout(m,1e3,!1)),()=>{j.current.forEach((e=>clearTimeout(e))),j.current=[]})),[]);let[g,v]=t.useState(""),[C,f]=t.useState("Checking that you are a human..."),[S,k]=t.useState(!1),[b,w]=t.useState(3),x=u?.captchaModalData,R=async e=>{try{await(x?.callback(e)),x?.onSuccessNavigateTo&&n(x?.onSuccessNavigateTo,!1)}catch(e){if(e instanceof i.CaptchaError)return;o({errorModalData:{error:e,previousScreen:r||"LandingScreen"}}),n(x?.onErrorNavigateTo||"ErrorScreen",!1)}};t.useEffect((()=>{"success"===c?y(setTimeout((async()=>{let e=await d();!e||x?.userIntentRequired||R(e)}),1e3)):"ready"===c&&y(setTimeout((()=>{"ready"===c&&p()}),500))}),[c]),t.useEffect((()=>{if(!h)switch(c){case"success":v("Success!"),f("CAPTCHA passed successfully."),x?.userIntentRequired||setTimeout((()=>{k(!0),R(l)}),2e3);break;case"loading":v(""),f("Checking that you are a human...");break;case"error":v("Something went wrong"),f(b<=0?"If you use an adblocker or VPN, try disabling and re-attempting.":"You did not pass CAPTCHA. Please try again.")}}),[c,h,S]);/*#__PURE__*/return e.jsx(a,{status:c,title:g,description:C,userIntentRequired:x?.userIntentRequired,retriesRemaining:b,hasSelectedCta:S,onContinue:()=>{k(!0),R(l)},onRetry:async()=>{if(b<=0)return;w((e=>e-1)),q(),p();let e=await d();!e||x?.userIntentRequired||R(e)}})}};exports.CaptchaScreen=n,exports.CaptchaScreenView=a,exports.default=n;
//# sourceMappingURL=CaptchaScreen-CIojMJ-c.js.map
