"use strict";var e=require("react/jsx-runtime"),r=require("react"),t=require("styled-components"),i=require("@privy-io/urls"),o=require("./WarningBanner-DUcGaIpZ.js"),n=require("./WalletInfoCard-CG-n_44w.js"),a=require("./context-rs-ygOK2.js"),s=require("./internal-context-CdsQ3LEl.js"),l=require("./modal-context-BgeioxwT.js"),d=require("./privy-context-UTJouJ1x.js"),c=require("./ScreenLayout-DaFW0I3a.js");require("@heroicons/react/24/outline/ExclamationTriangleIcon"),require("lucide-react"),require("./ModalHeader-Cpls13mi.js"),require("./useActiveWallet-dTc6deka.js"),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("@privy-io/js-sdk-core"),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"),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("./ErrorMessage-BfTVyue9.js"),require("./LabelXs-C8rLnCfU.js"),require("./Address-DW_NyDV7.js"),require("./shared-DBm7PUrg.js"),require("tinycolor2"),require("@privy-io/are-addresses-equal"),require("./Screen-8NusMFtu.js"),require("./index-ByFhjjzH.js");const u=({address:r,hideWalletAddress:t,accessToken:i,appConfigTheme:a,onClose:s,exportButtonProps:l,onBack:d})=>/*#__PURE__*/e.jsx(c.ScreenLayout,{title:"Export wallet",subtitle:/*#__PURE__*/e.jsxs(e.Fragment,{children:["Copy either your private key or seed phrase to export your wallet."," ",/*#__PURE__*/e.jsx("a",{href:"https://privy-io.notion.site/Transferring-your-account-9dab9e16c6034a7ab1ff7fa479b02828",target:"blank",rel:"noopener noreferrer",children:"Learn more"})]}),onClose:s,onBack:d,showBack:!!d,watermark:!0,children:/*#__PURE__*/e.jsxs(p,{children:[/*#__PURE__*/e.jsx(o.WarningBanner,{theme:a,children:"Never share your private key or seed phrase with anyone."}),!t&&/*#__PURE__*/e.jsx(n.WalletInfoCard,{title:"Your wallet",address:r,showCopyButton:!0}),/*#__PURE__*/e.jsx("div",{style:{width:"100%"},children:i&&l&&/*#__PURE__*/e.jsx(y,{accessToken:i,dimensions:{height:"44px"},...l})})]})});let p=t.styled.div`
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  text-align: left;
`;function h({chainType:e,imported:r,isUnifiedWallet:t}){return!r&&(t?"ethereum"===e||"bitcoin-taproot"===e||"pearl"===e:"ethereum"===e)}function y(t){let[i,o]=r.useState(t.dimensions.width),[n,a]=r.useState(!1),[s,l]=r.useState(void 0),d=r.useRef(null);r.useEffect((()=>{if(d.current&&void 0===i){let{width:e}=d.current.getBoundingClientRect();o(e)}let e=getComputedStyle(document.documentElement);l({background:e.getPropertyValue("--privy-color-background"),background2:e.getPropertyValue("--privy-color-background-2"),foreground3:e.getPropertyValue("--privy-color-foreground-3"),foregroundAccent:e.getPropertyValue("--privy-color-foreground-accent"),accent:e.getPropertyValue("--privy-color-accent"),accentDark:e.getPropertyValue("--privy-color-accent-dark"),success:e.getPropertyValue("--privy-color-success"),colorScheme:e.getPropertyValue("color-scheme")})}),[]);let c=h({chainType:t.chainType,imported:t.imported,isUnifiedWallet:t.isUnifiedWallet});/*#__PURE__*/return e.jsx("div",{ref:d,children:i&&
/*#__PURE__*/e.jsxs(g,{children:[/*#__PURE__*/e.jsx("iframe",{style:{position:"absolute",zIndex:1,opacity:n?1:0,transition:"opacity 50ms ease-in-out",pointerEvents:n?"auto":"none"},onLoad:()=>setTimeout((()=>a(!0)),1500),width:i,height:t.dimensions.height,allow:"clipboard-write self *",src:x({origin:t.origin,appId:t.appId,appClientId:t.appClientId,walletId:t.walletId,entropyId:t.entropyId,entropyIdVerifier:t.entropyIdVerifier,hdWalletIndex:t.hdWalletIndex,chainType:t.chainType,accessToken:t.accessToken,clientAnalyticsId:t.clientAnalyticsId,width:i,palette:s,isUnifiedWallet:t.isUnifiedWallet,exportSeedPhrase:c})}),/*#__PURE__*/e.jsx(v,{children:"Loading..."}),c&&/*#__PURE__*/e.jsx(v,{children:"Loading..."})]})})}const f={component:()=>{let[t,i]=r.useState(null),{authenticated:o,user:n}=d.usePrivyContext(),{closePrivyModal:c,createAnalyticsEvent:p,clientAnalyticsId:h,client:y}=s.usePrivyInternal(),f=a.useAppConfig(),{data:x,onUserCloseViaDialogOrKeybindRef:g}=l.usePrivyModal(),{onFailure:v,onSuccess:m,origin:I,appId:q,appClientId:j,entropyId:w,entropyIdVerifier:k,walletId:b,hdWalletIndex:W,chainType:C,address:T,uiOptions:A,isUnifiedWallet:P,imported:S,showBackButton:E}=x.keyExport,V=e=>{c({shouldCallAuthOnSuccess:!1}),v("string"==typeof e?Error(e):e)},_=()=>{c({shouldCallAuthOnSuccess:!1}),m(),p({eventName:"embedded_wallet_key_export_completed",payload:{walletAddress:T}})};return r.useEffect((()=>{if(!o)return V("User must be authenticated before exporting their wallet");y.getAccessToken().then(i).catch(V)}),[o,n]),g.current=_,/*#__PURE__*/e.jsx(u,{address:T,hideWalletAddress:A?.hideWalletAddress,accessToken:t,appConfigTheme:f.appearance.palette.colorScheme,onClose:_,isLoading:!t,onBack:E?_:void 0,exportButtonProps:t?{origin:I,appId:q,appClientId:j,clientAnalyticsId:h,entropyId:w,entropyIdVerifier:k,walletId:b,hdWalletIndex:W,isUnifiedWallet:P,imported:S,chainType:C}:void 0})}};function x({origin:e,appId:r,appClientId:t,walletId:o,entropyId:n,entropyIdVerifier:a,hdWalletIndex:s,chainType:l,accessToken:d,clientAnalyticsId:c,width:u,palette:p,isUnifiedWallet:h,exportSeedPhrase:y}){return i.constructURL({origin:e,path:`/apps/${r}/embedded-wallets/export`,query:h?{v:"1-unified",wallet_id:o,client_id:t,width:`${u}px`,caid:c,phrase_export:y,...p}:{v:"1",entropy_id:n,entropy_id_verifier:a,hd_wallet_index:s,chain_type:l,client_id:t,width:`${u}px`,caid:c,phrase_export:y,...p},hash:{token:d}})}let g=t.styled.div`
  overflow: visible;
  position: relative;
  overflow: none;
  height: 44px;
  display: flex;
  gap: 12px;
`,v=t.styled.div`
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 16px;
  font-weight: 500;
  border-radius: var(--privy-border-radius-md);
  background-color: var(--privy-color-background-2);
  color: var(--privy-color-foreground-3);
`;exports.EmbeddedWalletKeyExportScreen=f,exports.EmbeddedWalletKeyExportView=u,exports.constructWalletExportIframeUrl=x,exports.default=f,exports.supportsSeedPhraseExport=h;
//# sourceMappingURL=EmbeddedWalletKeyExportScreen-DF5fkj5n.js.map
