import{jsx as e,jsxs as t,Fragment as r}from"react/jsx-runtime";import{useState as o,useEffect as i,useRef as n}from"react";import{styled as a}from"styled-components";import{constructURL as l}from"@privy-io/urls";import{W as d}from"./WarningBanner-D5LqDt95.mjs";import{W as s}from"./WalletInfoCard-BVXOg6V2.mjs";import{u as p}from"./context-BKnOUECq.mjs";import{u as c}from"./internal-context-dfitw7Ot.mjs";import{u as m}from"./modal-context-DBwfUxD-.mjs";import{u}from"./privy-context-Bi6vqCPc.mjs";import{S as h}from"./ScreenLayout-Caq5mGD8.mjs";import"@heroicons/react/24/outline/ExclamationTriangleIcon";import"lucide-react";import"./ModalHeader-DffkxvO4.mjs";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"@privy-io/js-sdk-core";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"./ErrorMessage-D8VaAP5m.mjs";import"./LabelXs-oqZNqbm_.mjs";import"./Address-BOC18tYY.mjs";import"./shared-FM0rljBt.mjs";import"tinycolor2";import"@privy-io/are-addresses-equal";import"./Screen-D8KNyGVj.mjs";import"./index-Dq_xe9dz.mjs";const y=({address:o,hideWalletAddress:i,accessToken:n,appConfigTheme:a,onClose:l,exportButtonProps:p,onBack:c})=>/*#__PURE__*/e(h,{title:"Export wallet",subtitle:/*#__PURE__*/t(r,{children:["Copy either your private key or seed phrase to export your wallet."," ",/*#__PURE__*/e("a",{href:"https://privy-io.notion.site/Transferring-your-account-9dab9e16c6034a7ab1ff7fa479b02828",target:"blank",rel:"noopener noreferrer",children:"Learn more"})]}),onClose:l,onBack:c,showBack:!!c,watermark:!0,children:/*#__PURE__*/t(f,{children:[/*#__PURE__*/e(d,{theme:a,children:"Never share your private key or seed phrase with anyone."}),!i&&/*#__PURE__*/e(s,{title:"Your wallet",address:o,showCopyButton:!0}),/*#__PURE__*/e("div",{style:{width:"100%"},children:n&&p&&/*#__PURE__*/e(v,{accessToken:n,dimensions:{height:"44px"},...p})})]})});let f=a.div`
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  text-align: left;
`;function g({chainType:e,imported:t,isUnifiedWallet:r}){return!t&&(r?"ethereum"===e||"bitcoin-taproot"===e||"pearl"===e:"ethereum"===e)}function v(r){let[a,l]=o(r.dimensions.width),[d,s]=o(!1),[p,c]=o(void 0),m=n(null);i((()=>{if(m.current&&void 0===a){let{width:e}=m.current.getBoundingClientRect();l(e)}let e=getComputedStyle(document.documentElement);c({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 u=g({chainType:r.chainType,imported:r.imported,isUnifiedWallet:r.isUnifiedWallet});/*#__PURE__*/return e("div",{ref:m,children:a&&
/*#__PURE__*/t(w,{children:[/*#__PURE__*/e("iframe",{style:{position:"absolute",zIndex:1,opacity:d?1:0,transition:"opacity 50ms ease-in-out",pointerEvents:d?"auto":"none"},onLoad:()=>setTimeout((()=>s(!0)),1500),width:a,height:r.dimensions.height,allow:"clipboard-write self *",src:x({origin:r.origin,appId:r.appId,appClientId:r.appClientId,walletId:r.walletId,entropyId:r.entropyId,entropyIdVerifier:r.entropyIdVerifier,hdWalletIndex:r.hdWalletIndex,chainType:r.chainType,accessToken:r.accessToken,clientAnalyticsId:r.clientAnalyticsId,width:a,palette:p,isUnifiedWallet:r.isUnifiedWallet,exportSeedPhrase:u})}),/*#__PURE__*/e(k,{children:"Loading..."}),u&&/*#__PURE__*/e(k,{children:"Loading..."})]})})}const I={component:()=>{let[t,r]=o(null),{authenticated:n,user:a}=u(),{closePrivyModal:l,createAnalyticsEvent:d,clientAnalyticsId:s,client:h}=c(),f=p(),{data:g,onUserCloseViaDialogOrKeybindRef:v}=m(),{onFailure:I,onSuccess:x,origin:w,appId:k,appClientId:j,entropyId:b,entropyIdVerifier:T,walletId:W,hdWalletIndex:C,chainType:A,address:_,uiOptions:P,isUnifiedWallet:V,imported:S,showBackButton:B}=g.keyExport,U=e=>{l({shouldCallAuthOnSuccess:!1}),I("string"==typeof e?Error(e):e)},L=()=>{l({shouldCallAuthOnSuccess:!1}),x(),d({eventName:"embedded_wallet_key_export_completed",payload:{walletAddress:_}})};return i((()=>{if(!n)return U("User must be authenticated before exporting their wallet");h.getAccessToken().then(r).catch(U)}),[n,a]),v.current=L,/*#__PURE__*/e(y,{address:_,hideWalletAddress:P?.hideWalletAddress,accessToken:t,appConfigTheme:f.appearance.palette.colorScheme,onClose:L,isLoading:!t,onBack:B?L:void 0,exportButtonProps:t?{origin:w,appId:k,appClientId:j,clientAnalyticsId:s,entropyId:b,entropyIdVerifier:T,walletId:W,hdWalletIndex:C,isUnifiedWallet:V,imported:S,chainType:A}:void 0})}};function x({origin:e,appId:t,appClientId:r,walletId:o,entropyId:i,entropyIdVerifier:n,hdWalletIndex:a,chainType:d,accessToken:s,clientAnalyticsId:p,width:c,palette:m,isUnifiedWallet:u,exportSeedPhrase:h}){return l({origin:e,path:`/apps/${t}/embedded-wallets/export`,query:u?{v:"1-unified",wallet_id:o,client_id:r,width:`${c}px`,caid:p,phrase_export:h,...m}:{v:"1",entropy_id:i,entropy_id_verifier:n,hd_wallet_index:a,chain_type:d,client_id:r,width:`${c}px`,caid:p,phrase_export:h,...m},hash:{token:s}})}let w=a.div`
  overflow: visible;
  position: relative;
  overflow: none;
  height: 44px;
  display: flex;
  gap: 12px;
`,k=a.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);
`;export{I as EmbeddedWalletKeyExportScreen,y as EmbeddedWalletKeyExportView,x as constructWalletExportIframeUrl,I as default,g as supportsSeedPhraseExport};
//# sourceMappingURL=EmbeddedWalletKeyExportScreen-CBFzpGNE.mjs.map
