"use strict";var e=require("react/jsx-runtime"),r=require("@heroicons/react/24/outline/ExclamationTriangleIcon"),t=require("@heroicons/react/24/outline/LockClosedIcon"),o=require("react"),i=require("./privy-context-UTJouJ1x.js"),n=require("./ModalHeader-Cpls13mi.js"),s=require("styled-components"),l=require("./Subtitle-CR8zM7ZJ.js"),a=require("./Title-ifTy35V5.js"),c=require("./context-rs-ygOK2.js"),u=require("./internal-context-CdsQ3LEl.js"),d=require("./modal-context-BgeioxwT.js"),y=require("./useActiveWallet-dTc6deka.js");function h(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("@privy-io/are-addresses-equal"),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("@privy-io/js-sdk-core"),require("tinycolor2"),require("viem/utils"),require("./wallet-connect-BuohfvHK.js"),require("./errors-CBapWvRs.js"),require("ofetch"),require("./getPublicClient-CFd_sHBk.js"),require("viem"),require("viem/chains"),require("eventemitter3"),require("./events-context-Di6--rDg.js"),require("./index-Ub4KpwSY.js"),require("zustand"),require("react-device-detect"),require("./get-entropy-details-for-user-D63rM5_a.js"),require("./user-D2oPA-vS.js");var v=/*#__PURE__*/h(r),j=/*#__PURE__*/h(t);const q=s.styled.div`
  && {
    border-width: 4px;
  }

  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1rem;
  aspect-ratio: 1;
  border-style: solid;
  border-color: ${e=>e.$color??"var(--privy-color-accent)"};
  border-radius: 50%;
`,f={component:()=>{let{user:r}=i.usePrivyContext(),{client:t,walletProxy:s,refreshSessionAndUser:h,closePrivyModal:f}=u.usePrivyInternal(),m=d.usePrivyModal(),{entropyId:g,entropyIdVerifier:x}=m.data?.recoverWallet??{},[p,w]=o.useState(!1),[S,b]=o.useState(null),[C,I]=o.useState(null);function P(){if(!p){if(C)return m.data?.setWalletPassword?.onFailure(C),void f();if(!S)return m.data?.setWalletPassword?.onFailure(Error("User exited set recovery flow")),void f()}}m.onUserCloseViaDialogOrKeybindRef.current=P;let T=!(!p&&!S);return C?/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(n.ModalHeader,{onClose:P},"header"),/*#__PURE__*/e.jsx(q,{$color:"var(--privy-color-error)",style:{alignSelf:"center"},children:/*#__PURE__*/e.jsx(v.default,{height:38,width:38,stroke:"var(--privy-color-error)"})}),/*#__PURE__*/e.jsx(a.Title,{style:{marginTop:"0.5rem"},children:"Something went wrong"}),/*#__PURE__*/e.jsx(y.Grow,{style:{minHeight:"2rem"}}),/*#__PURE__*/e.jsx(n.PrimaryButtonWithoutGray,{onClick:()=>I(null),children:"Try again"}),/*#__PURE__*/e.jsx(n.BlobbyFooter,{})]}):/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(n.ModalHeader,{onClose:P},"header"),/*#__PURE__*/e.jsx(j.default,{style:{width:"3rem",height:"3rem",alignSelf:"center"}}),/*#__PURE__*/e.jsx(a.Title,{style:{marginTop:"0.5rem"},children:"Automatically secure your account"}),/*#__PURE__*/e.jsx(l.Subtitle,{style:{marginTop:"1rem"},children:"When you log into a new device, you’ll only need to authenticate to access your account. Never get logged out if you forget your password."}),/*#__PURE__*/e.jsx(y.Grow,{style:{minHeight:"2rem"}}),/*#__PURE__*/e.jsx(n.PrimaryButtonWithoutGray,{loading:p,disabled:T,onClick:()=>async function(){w(!0);try{let e=await t.getAccessToken(),o=i.getPrivyWalletWithAddress(r,g);if(!e||!s||!o)return;if(!(await s.setRecovery({accessToken:e,entropyId:g,entropyIdVerifier:x,existingRecoveryMethod:o.recoveryMethod,recoveryMethod:"privy"})).entropyId)throw Error("Unable to set recovery on wallet");let n=await h();if(!n)throw Error("Unable to set recovery on wallet");let l=i.getPrivyWalletWithAddress(n,o.address);if(!l)throw Error("Unabled to set recovery on wallet");b(!!n),setTimeout((()=>{m.data?.setWalletPassword?.onSuccess(l),f()}),c.DEFAULT_SUCCESS_SCREEN_DURATION_MS)}catch(e){I(e)}finally{w(!1)}}(),children:S?"Success":"Confirm"}),/*#__PURE__*/e.jsx(n.BlobbyFooter,{})]})}};exports.SetAutomaticRecoveryScreen=f,exports.default=f;
//# sourceMappingURL=SetAutomaticRecoveryScreen-CkF7YbLC.js.map
