@privy-io/expo 0.77.0 → 0.78.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import{a as vt,b as _,c as M,e as l,f as bt,g as St,h as ve}from"./chunk-K5SPDXVF.js";import{useEffect as Br}from"react";import{create as Hr}from"zustand";var Ct=Hr(()=>({status:"disconnected"})),be=()=>Ct.getState().onNeedsRecovery,Jr=e=>{Br(()=>{Ct.setState({onNeedsRecovery:e==null?void 0:e.onNeedsRecovery})},[e==null?void 0:e.onNeedsRecovery])};import{digest as Qr,randomUUID as Yr}from"expo-crypto";import Xr from"@privy-io/js-sdk-core";var Et={name:"@privy-io/expo",version:"0.77.0",description:"Expo client for the Privy Auth API",keywords:["authentication","authorization","identity","privacy","privy","user data","react-native","expo","web3"],homepage:"https://docs.privy.io",bugs:{url:"https://privy.io/slack"},license:"Apache-2.0",author:"privy.io",exports:{".":{require:"./dist/index.js",import:"./dist/esm/index.js",types:"./dist/index.d.ts"},"./passkey":{require:"./dist/passkey.js",import:"./dist/esm/passkey.js",types:"./dist/passkey.d.ts"},"./smart-wallets":{require:"./dist/smart-wallets.js",import:"./dist/esm/smart-wallets.js",types:"./dist/smart-wallets.d.ts"},"./extended-chains":{require:"./dist/extended-chains.js",import:"./dist/esm/extended-chains.js",types:"./dist/extended-chains.d.ts"},"./ui":{require:"./dist/ui.js",import:"./dist/esm/ui.js",types:"./dist/ui.d.ts"},"./cards":{require:"./dist/cards.js",import:"./dist/esm/cards.js",types:"./dist/cards.d.ts"},"./connectors":{require:"./dist/connectors.js",import:"./dist/esm/connectors.js",types:"./dist/connectors.d.ts"}},main:"./dist/esm/index.js",source:"./src/index.ts",types:"./dist/index.d.ts",files:["dist/**/*","LICENSE","README.md"],scripts:{build:"tsup --clean --minify","check-types":"tsc --noEmit",clean:"rm -rf dist .turbo *.tsbuildinfo","clean:reset":"rm -rf dist .turbo node_modules *.tsbuildinfo",dev:"tsup --watch",format:"oxlint src --fix","generate-types":"tsup --dts-only",lint:"oxlint src",test:"jest"},browserslist:["defaults","node >= 18","not op_mini all"],dependencies:{"@privy-io/api-types":"catalog:","@privy-io/are-addresses-equal":"workspace:*","@privy-io/encoding":"workspace:*","@privy-io/js-sdk-core":"workspace:*","@privy-io/routes":"workspace:*","@scure/base":"^1.2.4","react-fast-compare":"^3.2.2",tweetnacl:"catalog:",zustand:"catalog:"},devDependencies:{oxlint:"catalog:package-new","oxlint-tsgolint":"catalog:package-new","@faker-js/faker":"catalog:","@privy-io/eslint-plugin-privy-rules":"workspace:*","@privy-io/tsconfig":"workspace:*","@simplewebauthn/types":"9.0.1","@solana/web3.js":"catalog:","@svgr/core":"^8.1.0","@svgr/plugin-jsx":"^8.1.0","@svgr/plugin-svgo":"^8.1.0","@testing-library/react-native":"^13.1.0","@tsconfig/node16-strictest-esm":"catalog:","@types/jest":"catalog:","@types/react":"catalog:",expo:"57.0.28","expo-apple-authentication":"57.0.2","expo-application":"57.0.3","expo-clipboard":"57.0.2","expo-crypto":"57.0.4","expo-linking":"57.0.12","expo-secure-store":"57.0.4","expo-web-browser":"57.0.3",jest:"catalog:","jest-expo":"57.0.6","lucide-react-native":"^0.474.0",react:"catalog:","react-native":"0.86.3","react-native-webview":"13.16.1","react-test-renderer":"19.2.3",tsup:"^6.2.3",typescript:"catalog:"},peerDependencies:{"@privy-io/expo-native-extensions":"workspace:*","expo-apple-authentication":"*","expo-application":"*","expo-clipboard":"*","expo-crypto":"*","expo-linking":"*","expo-secure-store":"*","expo-web-browser":"*",permissionless:"^0.2.47",react:"*","react-native":"*","react-native-passkeys":"catalog:","react-native-qrcode-styled":"0.3.3","react-native-safe-area-context":"*","react-native-svg":"*","react-native-webview":"*",viem:"catalog:"},peerDependenciesMeta:{permissionless:{optional:!0},viem:{optional:!0},"react-native-svg":{optional:!0},"expo-apple-authentication":{optional:!0},"expo-clipboard":{optional:!0},"expo-linking":{optional:!0},"expo-secure-store":{optional:!0},"expo-web-browser":{optional:!0},"react-native-qrcode-styled":{optional:!0},"react-native-safe-area-context":{optional:!0}},publishConfig:{access:"public"}};var _t=({appId:e,clientId:t,storage:o=ve,supportedChains:r,baseUrl:i,logLevel:s,logger:n,sessions:a,plugins:d})=>{let c=a!=null&&a.mode?{mode:a.mode}:void 0;return new Xr({appId:e,clientId:t,plugins:d,supportedChains:r,storage:St(o),sdkVersion:`expo:${Et.version}`,nativeAppIdentifier:bt(),crypto:{digest:Qr,randomUUID:Yr},baseUrl:i,logLevel:s,logger:n,sessions:c})};import{useCallback as mt,useContext as Ts}from"react";import{PrivyClientError as Fs}from"@privy-io/js-sdk-core";import ee,{useState as L,useMemo as Rs,createContext as Is,useCallback as De,useRef as fe,useEffect as Mr,useContext as Os}from"react";import{AppState as Tr,View as Ls}from"react-native";import{PrivyClientError as Fr}from"@privy-io/js-sdk-core";import Zr from"react-fast-compare";import{create as eo}from"zustand";var Se=eo(()=>{}),kt=e=>Se.setState(t=>Zr(t,e)?t:e),x=Se.getState;import oo from"react";import{useCallback as G,useEffect as Ut,useRef as ne,useState as no}from"react";import{AppState as io}from"react-native";import so from"react-native-webview";import*as F from"expo-secure-store";function Wt(e){return typeof e!="object"||e===null||!("event"in e&&typeof e.event=="string")||!("id"in e&&typeof e.id=="string")||!("data"in e&&typeof e.data=="object")||e.data===null?!1:e.event.startsWith("app:secure-storage:")}function At(e){return l(this,null,function*(){switch(e.event){case"app:secure-storage:get":{let{key:t}=e.data,o=yield F.getItemAsync(Ve(t),{keychainAccessible:F.AFTER_FIRST_UNLOCK_THIS_DEVICE_ONLY}).catch(r=>(console.warn("Failed to get the value from secure store",r),null));return{event:e.event,id:e.id,data:{value:o}}}case"app:secure-storage:remove":{let{key:t}=e.data,o=yield F.deleteItemAsync(Ve(t),{keychainAccessible:F.AFTER_FIRST_UNLOCK_THIS_DEVICE_ONLY}).then(()=>!0).catch(r=>(console.warn("Failed to remove the value from secure store",r),!1));return{event:e.event,id:e.id,data:{success:o}}}case"app:secure-storage:set":{let{key:t,value:o}=e.data,r=yield F.setItemAsync(Ve(t),o,{keychainAccessible:F.AFTER_FIRST_UNLOCK_THIS_DEVICE_ONLY}).then(()=>!0).catch(i=>(console.warn("Failed to write the value to secure store",i),!1));return{event:e.event,id:e.id,data:{success:r}}}}})}var Ve=e=>e.replaceAll(":","-");import to from"react-fast-compare";import{createStore as ro,useStore as Ce}from"zustand";var D=ro()(()=>({user:null,storedUsers:[],proxyStatus:"loading"}));function S(){return D.getState().user}var ea=D.subscribe.bind(D);function Ge(e){D.setState(({user:t})=>to(t,e)?{}:{user:e})}var xt=e=>D.setState({storedUsers:e.users}),oe=e=>D.setState({proxyStatus:e});function U(){return Ce(D,e=>e.user)}function ta(){return Ce(D,e=>!!e.user)}function Pt(){return Ce(D,e=>e.storedUsers)}function z(){return Ce(D,e=>e.proxyStatus!=="loading")}var ao={shouldUseAppBackedStorage:!0},co=";",lo=500,uo=(e,t)=>{if(!e)return!1;try{return new URL(e).origin===new URL(t).origin}catch(o){return!1}},po=1e3,mo=6e4,Rt=({client:e,isClientReady:t})=>{let o=ne(null),[r,i]=no(0),s=ne(0),n=ne(void 0),a=ne(0),d=ne(void 0);Ut(()=>()=>clearTimeout(d.current),[]);let c=G(y=>{e.logger.info(`[privy:webview] recreating, ${y}`),clearTimeout(d.current),s.current+=1,oe("reloading"),e.embeddedWallet.reload(),i(g=>g+1)},[e]);Ut(()=>{let y=io.addEventListener("change",g=>l(void 0,null,function*(){var b;if(g==="background")n.current=s.current,e.embeddedWallet.onBackground();else if(g==="active"){let C=(b=n.current)!=null?b:s.current;n.current=void 0,!(yield e.embeddedWallet.ping(lo))&&s.current===C&&(oe("reloading"),e.embeddedWallet.reload())}}));return()=>y.remove()},[e]);let u=G(y=>l(void 0,null,function*(){var C;if(!uo(y.nativeEvent.url,e.embeddedWallet.getURL()))return;let{data:g}=y.nativeEvent,b=JSON.parse(g);if(a.current=0,Wt(b)){let k=yield At(b);(C=o.current)==null||C.postMessage(JSON.stringify(k));return}e.embeddedWallet.onMessage(b)}),[e]),p=G(()=>{clearTimeout(d.current),oe("loaded")},[]),m=G(()=>{e.logger.info("[privy:webview] reloading, load failed"),oe("reloading"),e.embeddedWallet.reload()},[e]),w=G(y=>{let g=Math.min(po*vt(2,a.current),mo);a.current+=1,e.logger.warn(`[privy:webview] load failed (${y.nativeEvent.code}: ${y.nativeEvent.description}), retrying in ${g}ms`),clearTimeout(d.current),d.current=setTimeout(m,g)},[e,m]),h=G(()=>{c("content process terminated")},[c]),v=G(()=>{c("render process gone")},[c]);return t?oo.createElement(so,{key:r,style:{flex:1},ref:y=>{y&&(e.setMessagePoster(y),o.current=y)},cacheEnabled:!1,cacheMode:"LOAD_NO_CACHE",injectedJavaScriptObject:ao,injectedJavaScriptBeforeContentLoaded:co,source:{uri:e.embeddedWallet.getURL()},webviewDebuggingEnabled:e.logger.level==="DEBUG",onLoad:p,onError:w,onMessage:u,onContentProcessDidTerminate:h,onRenderProcessGone:v}):null};import{useCallback as Ke,useEffect as Mt,useMemo as qe}from"react";import{errorIndicatesRecoveryIsNeeded as fo,getAllUserEmbeddedSolanaWallets as go,getEntropyDetailsFromUser as Tt,PrivyClientError as ie}from"@privy-io/js-sdk-core";import{getAllUserEmbeddedSolanaWallets as Ee,getEntropyDetailsFromAccount as It,getUserEmbeddedEthereumWallet as yo,PrivyClientError as B}from"@privy-io/js-sdk-core";function Ot(s){return l(this,arguments,function*({client:e,setSolanaWallet:t,createSolanaWalletCallbacks:o,setSolanaRecoveryFlowState:r,opts:i}){var n,a,d;t({status:"creating"});try{let{user:c}=yield e.user.get(),u=Ee(c),p=u[0],m=(n=yo(c))!=null?n:void 0;if(i!=null&&i.recoveryMethod&&i.recoveryMethod!=="privy")throw new B({code:"embedded_wallet_creation_error",error:"Unsupported recovery method for solana wallet."});if(!(i!=null&&i.createAdditional)&&p)throw new B({code:"embedded_wallet_creation_error",error:"Solana wallet already exists for this user. Set `createAdditional` to `true` to create another wallet"});let w,h;if(p){let y=m!=null?m:p,{entropyId:g,entropyIdVerifier:b}=It(y),C=Math.max(...u.map(P=>P.wallet_index),0)+1,k=yield e.embeddedWallet.add({chainType:"solana",entropyId:g,entropyIdVerifier:b,hdWalletIndex:C}),A=Ee(k.user).find(P=>P.wallet_index===C);if(!A)throw new B({error:"Embedded wallet account not created",code:"embedded_wallet_creation_error"});w=yield e.embeddedWallet.getSolanaProvider(A,g,b),h=k.user}else{let y=yield e.embeddedWallet.createSolana({ethereumAccount:m}),g=Ee(y.user).find(A=>A.wallet_index===0);if(!g)throw new B({error:"Embedded wallet account not created",code:"embedded_wallet_creation_error"});let b=m!=null?m:g,{entropyId:C,entropyIdVerifier:k}=It(b);w=yield e.embeddedWallet.getSolanaProvider(g,C,k),h=y.user}let v=Ee(h)[0];if(!v)throw new B({code:"embedded_wallet_creation_error",error:"Unknown error creating solana wallet"});return(d=(a=o.current)==null?void 0:a.onSuccess)==null||d.call(a,w),t({status:"connected",publicKey:v.public_key}),r({status:"initial"}),w}catch(c){let u=c instanceof Error?c.message:"Error creating embedded wallet";throw t({status:"error",error:u}),r({status:"initial"}),new B({code:"embedded_wallet_creation_error",error:u})}})}import{PrivyClientError as K}from"@privy-io/js-sdk-core";function _e(u){return l(this,arguments,function*({client:e,account:t,setWallet:o,recoverWalletCallbacks:r,recoveryMethod:i,setRecoveryFlowState:s,password:n,recoveryKey:a,recoveryToken:d,recoverySecretOverride:c}){var p,m,w,h;if(!t)throw new K({code:"embedded_wallet_does_not_exist",error:"Embedded wallet does not exist"});switch(i){case"user-passcode":if(!n)throw new K({code:"embedded_wallet_recovery_error",error:"password is required for user-passcode recovery method"});break;case"google-drive":if(!d)throw new K({code:"embedded_wallet_recovery_error",error:"Recovery token is required for google-drive recovery method"});break;case"icloud":if(!c)throw new K({code:"embedded_wallet_recovery_error",error:"Record name is required for icloud recovery method"});break;case"recovery-encryption-key":if(!a)throw new K({code:"embedded_wallet_recovery_error",error:"recoveryKey is required for recovery-encryption-key recovery method"});break}o({status:"connecting",account:t});try{let v=yield e.embeddedWallet.getProvider(t,n,d,c,a);return o({status:"connected",provider:v,account:t}),s({status:"initial"}),(m=(p=r.current)==null?void 0:p.onSuccess)==null||m.call(p,v),v}catch(v){o({status:"needs-recovery",account:t}),s({status:"initial"});let y=new K({code:"embedded_wallet_recovery_error",error:v instanceof Error?v.message:"Error recovering embedded wallet"});throw(h=(w=r.current)==null?void 0:w.onError)==null||h.call(w,y),y}})}function Lt(a){return l(this,arguments,function*({client:e,account:t,entropyId:o,entropyIdVerifier:r,setSolanaWallet:i,recoverSolanaWalletCallbacks:s,setSolanaRecoveryFlowState:n}){var d,c,u,p;i({status:"connecting"});try{let m=yield e.embeddedWallet.getSolanaProvider(t,o,r);return i({status:"connected",publicKey:m._publicKey}),n({status:"initial"}),(c=(d=s.current)==null?void 0:d.onSuccess)==null||c.call(d,m),m}catch(m){i({status:"needs-recovery"}),n({status:"initial"});let w=new K({code:"embedded_wallet_recovery_error",error:m instanceof Error?m.message:"Error recovering embedded wallet"});throw(p=(u=s.current)==null?void 0:u.onError)==null||p.call(u,w),w}})}var Ft=({client:e,solanaWallet:t,setSolanaWallet:o,setSolanaRecoveryFlowState:r,createSolanaWalletCallbacks:i,recoverSolanaWalletCallbacks:s})=>{let n=U(),a=qe(()=>go(n),[n]),d=z(),c=qe(()=>a.length===0?null:Tt(n,a[0]),[n,a]),u=qe(()=>{let h=a.map(b=>{let C=Tt(n,b);return C?{account:b,entropy:C}:null});if(h.some(b=>b===null))return[];let v=void 0,y=void 0,g=void 0;return h.filter(b=>b!==null).map(({account:b,entropy:{entropyId:C,entropyIdVerifier:k}})=>({address:b.address,publicKey:b.address,walletIndex:b.wallet_index,getProvider:()=>e.embeddedWallet.getSolanaProvider(b,C,k,v,y,g,A=>l(void 0,null,function*(){var P;yield(P=be())==null?void 0:P(A)}))}))},[a,n,e]),p=Ke(h=>l(void 0,null,function*(){return yield Ot({client:e,setSolanaWallet:o,createSolanaWalletCallbacks:i,setSolanaRecoveryFlowState:r,opts:h})}),[e,i]),m=Ke(()=>l(void 0,null,function*(){if(!c)throw new ie({code:"embedded_wallet_does_not_exist",error:"Embedded wallet does not exist"});let{entropyId:h,entropyIdVerifier:v}=c;return Lt({client:e,account:a[0],entropyId:h,entropyIdVerifier:v,setSolanaWallet:o,recoverSolanaWalletCallbacks:s,setSolanaRecoveryFlowState:r})}),[e,c,a,s,r,o]),w=Ke(()=>l(void 0,null,function*(){if(!c)throw o({status:"not-created"}),new ie({code:"embedded_wallet_does_not_exist",error:"Embedded wallet does not exist"});o(h=>h.status==="connected"?{status:"reconnecting"}:{status:"connecting"});try{let{entropyId:h,entropyIdVerifier:v}=c,y=yield e.embeddedWallet.getSolanaProvider(a[0],h,v);return o({status:"connected",publicKey:a[0].public_key}),y}catch(h){throw fo(h)?(o({status:"needs-recovery"}),new ie({code:"embedded_wallet_needs_recovery",error:"Embedded wallet not loaded on device"})):h instanceof Error?(o({status:"error",error:h.message}),new ie({code:"unknown_embedded_wallet_error",error:h.message})):(o({status:"error",error:"Error loading embedded wallet"}),new ie({code:"unknown_embedded_wallet_error",error:"Error loading embedded wallet"}))}}),[a,e,c,o]);return Mt(()=>{if(!n&&t.status!=="disconnected")return o({status:"disconnected"});d&&w().catch(()=>{})},[d,n]),Mt(()=>{t.status==="error"&&t.error.includes("User must be logged in")&&w()},[t.status]),{create:p,recover:m,getProvider:w,wallets:u}};import{useCallback as ce,useEffect as Gt,useMemo as Ao}from"react";import{getUserEmbeddedEthereumWallet as xo,getUserEmbeddedSolanaWallet as Kt,isUnifiedWallet as Po,throwIfInvalidRecoveryUpgradePath as Uo}from"@privy-io/js-sdk-core";import{errorIndicatesRecoveryIsNeeded as Ro,PrivyClientError as R}from"@privy-io/js-sdk-core";import{getUserEmbeddedEthereumWallet as ho}from"@privy-io/js-sdk-core";import{PrivyClientError as H}from"@privy-io/js-sdk-core";function ke(p){return l(this,arguments,function*({client:e,setWallet:t,createWalletCallbacks:o,recoveryMethod:r,setRecoveryFlowState:i,password:s,recoveryKey:n,recoveryToken:a,recoverySecretOverride:d,iCloudRecordNameOverride:c,solanaAccount:u}){var w,h;switch(r){case"user-passcode":if(!s)throw new H({code:"embedded_wallet_recovery_error",error:"password is required for user-passcode recovery method"});break;case"recovery-encryption-key":if(!n)throw new H({code:"embedded_wallet_recovery_error",error:"key is required for recovery-encryption-key recovery method"});break;case"google-drive":if(!a)throw new H({code:"embedded_wallet_recovery_error",error:"Recovery token is required for google-drive recovery method"});break;case"icloud":if(!d||!c)throw new H({code:"embedded_wallet_recovery_error",error:"iCloud recovery failed due to inability to store credentials"});break}t({status:"creating",account:null});let m=r==="icloud"?"icloud-native":r;try{let{user:v}=yield e.embeddedWallet.create({password:s,recoveryMethod:m,recoveryKey:n,recoveryToken:a,recoverySecretOverride:d,iCloudRecordNameOverride:c,solanaAccount:u}),y=ho(v);if(!y)throw new H({error:"Embedded wallet account not created",code:"embedded_wallet_creation_error"});let g=yield e.embeddedWallet.getProvider(y);return(h=(w=o.current)==null?void 0:w.onSuccess)==null||h.call(w,g),t({status:"connected",provider:g,account:y}),i({status:"initial"}),g}catch(v){let y=v instanceof Error?v.message:"Error creating embedded wallet";throw t({status:"error",error:y,account:null}),i({status:"initial"}),new H({code:"embedded_wallet_creation_error",error:y})}})}import{Platform as Nt}from"react-native";import{PrivyClientError as N}from"@privy-io/js-sdk-core";import{Platform as wo}from"react-native";var Dt=new Set;function We(e,{isDevelopment:t=__DEV__,reactNativeVersion:o=wo.constants.reactNativeVersion,warn:r=i=>console.warn(i)}={}){if(!t||Dt.has(e))return;let{major:i,minor:s,patch:n}=o;if(i>0||i===0&&s>=81)return;let d=`[Privy] Upcoming optional dependency change
1
+ import{a as bt,b as St,c as ve}from"./chunk-F7DR7TVR.js";import{a as Ct}from"./chunk-3HF374LL.js";import{a as vt,b as _,c as M,e as l}from"./chunk-C5WYSLQF.js";import{useEffect as Hr}from"react";import{create as Jr}from"zustand";var Et=Jr(()=>({status:"disconnected"})),be=()=>Et.getState().onNeedsRecovery,$r=e=>{Hr(()=>{Et.setState({onNeedsRecovery:e==null?void 0:e.onNeedsRecovery})},[e==null?void 0:e.onNeedsRecovery])};import Yr from"@privy-io/js-sdk-core";var _t={name:"@privy-io/expo",version:"0.78.0",description:"Expo client for the Privy Auth API",keywords:["authentication","authorization","identity","privacy","privy","user data","react-native","expo","web3"],homepage:"https://docs.privy.io",bugs:{url:"https://privy.io/slack"},license:"Apache-2.0",author:"privy.io",exports:{".":{require:"./dist/index.js",import:"./dist/esm/index.js",types:"./dist/index.d.ts"},"./passkey":{require:"./dist/passkey.js",import:"./dist/esm/passkey.js",types:"./dist/passkey.d.ts"},"./smart-wallets":{require:"./dist/smart-wallets.js",import:"./dist/esm/smart-wallets.js",types:"./dist/smart-wallets.d.ts"},"./extended-chains":{require:"./dist/extended-chains.js",import:"./dist/esm/extended-chains.js",types:"./dist/extended-chains.d.ts"},"./ui":{require:"./dist/ui.js",import:"./dist/esm/ui.js",types:"./dist/ui.d.ts"},"./cards":{require:"./dist/cards.js",import:"./dist/esm/cards.js",types:"./dist/cards.d.ts"},"./connectors":{require:"./dist/connectors.js",import:"./dist/esm/connectors.js",types:"./dist/connectors.d.ts"},"./polyfills":{require:"./dist/polyfills.js",import:"./dist/esm/polyfills.js",types:"./dist/polyfills.d.ts"}},main:"./dist/esm/index.js",source:"./src/index.ts",types:"./dist/index.d.ts",files:["dist/**/*","LICENSE","README.md"],scripts:{build:"tsup --clean --minify","check-types":"tsc --noEmit",clean:"rm -rf dist .turbo *.tsbuildinfo","clean:reset":"rm -rf dist .turbo node_modules *.tsbuildinfo",dev:"tsup --watch",format:"oxlint src --fix","generate-types":"tsup --dts-only",lint:"oxlint src",test:"jest"},browserslist:["defaults","node >= 18","not op_mini all"],dependencies:{"@noble/curves":"catalog:","@privy-io/api-types":"catalog:","@privy-io/are-addresses-equal":"workspace:*","@privy-io/encoding":"workspace:*","@privy-io/js-sdk-core":"workspace:*","@privy-io/routes":"workspace:*","@scure/base":"^1.2.4","react-fast-compare":"^3.2.2",tweetnacl:"catalog:",zustand:"catalog:"},devDependencies:{oxlint:"catalog:package-new","oxlint-tsgolint":"catalog:package-new","@faker-js/faker":"catalog:","@hpke/chacha20poly1305":"catalog:","@hpke/core":"catalog:","@privy-io/eslint-plugin-privy-rules":"workspace:*","@privy-io/tsconfig":"workspace:*","@simplewebauthn/types":"9.0.1","@solana/web3.js":"catalog:","@svgr/core":"^8.1.0","@svgr/plugin-jsx":"^8.1.0","@svgr/plugin-svgo":"^8.1.0","@testing-library/react-native":"^13.1.0","@tsconfig/node16-strictest-esm":"catalog:","@types/jest":"catalog:","@types/react":"catalog:",expo:"57.0.28","expo-apple-authentication":"57.0.2","expo-application":"57.0.3","expo-clipboard":"57.0.2","expo-linking":"57.0.12","expo-secure-store":"57.0.4","expo-web-browser":"57.0.3",jest:"catalog:","jest-expo":"57.0.6","lucide-react-native":"^0.474.0",react:"catalog:","react-native":"0.86.3","react-native-nitro-modules":"catalog:","react-native-quick-base64":"catalog:","react-native-quick-crypto":"catalog:","react-native-webview":"13.16.1","react-test-renderer":"19.2.3",tsup:"^6.2.3",typescript:"catalog:"},peerDependencies:{"@privy-io/expo-native-extensions":"workspace:*","expo-apple-authentication":"*","expo-application":"*","expo-clipboard":"*","expo-linking":"*","expo-secure-store":"*","expo-web-browser":"*",permissionless:"^0.2.47",react:"*","react-native":"*","react-native-passkeys":"catalog:","react-native-qrcode-styled":"0.3.3","react-native-quick-crypto":"^1.0.0","react-native-safe-area-context":"*","react-native-svg":"*","react-native-webview":"*",viem:"^2.57.8"},peerDependenciesMeta:{permissionless:{optional:!0},viem:{optional:!0},"react-native-svg":{optional:!0},"expo-apple-authentication":{optional:!0},"expo-clipboard":{optional:!0},"expo-linking":{optional:!0},"expo-secure-store":{optional:!0},"expo-web-browser":{optional:!0},"react-native-qrcode-styled":{optional:!0},"react-native-safe-area-context":{optional:!0}},publishConfig:{access:"public"}};var kt=({appId:e,clientId:t,storage:o=ve,supportedChains:r,baseUrl:i,logLevel:s,logger:n,sessions:a,plugins:d})=>{Ct();let c=a!=null&&a.mode?{mode:a.mode}:void 0;return new Yr({appId:e,clientId:t,plugins:d,supportedChains:r,storage:St(o),sdkVersion:`expo:${_t.version}`,nativeAppIdentifier:bt(),baseUrl:i,logLevel:s,logger:n,sessions:c})};import{useCallback as mt,useContext as Ms}from"react";import{PrivyClientError as Ts}from"@privy-io/js-sdk-core";import ee,{useState as L,useMemo as Us,createContext as Rs,useCallback as De,useRef as fe,useEffect as Tr,useContext as Is}from"react";import{AppState as Fr,View as Os}from"react-native";import{PrivyClientError as Dr}from"@privy-io/js-sdk-core";import Xr from"react-fast-compare";import{create as Zr}from"zustand";var Se=Zr(()=>{}),Wt=e=>Se.setState(t=>Xr(t,e)?t:e),x=Se.getState;import ro from"react";import{useCallback as G,useEffect as Rt,useRef as ne,useState as oo}from"react";import{AppState as no}from"react-native";import io from"react-native-webview";import*as F from"expo-secure-store";function At(e){return typeof e!="object"||e===null||!("event"in e&&typeof e.event=="string")||!("id"in e&&typeof e.id=="string")||!("data"in e&&typeof e.data=="object")||e.data===null?!1:e.event.startsWith("app:secure-storage:")}function xt(e){return l(this,null,function*(){switch(e.event){case"app:secure-storage:get":{let{key:t}=e.data,o=yield F.getItemAsync(Ve(t),{keychainAccessible:F.AFTER_FIRST_UNLOCK_THIS_DEVICE_ONLY}).catch(r=>(console.warn("Failed to get the value from secure store",r),null));return{event:e.event,id:e.id,data:{value:o}}}case"app:secure-storage:remove":{let{key:t}=e.data,o=yield F.deleteItemAsync(Ve(t),{keychainAccessible:F.AFTER_FIRST_UNLOCK_THIS_DEVICE_ONLY}).then(()=>!0).catch(r=>(console.warn("Failed to remove the value from secure store",r),!1));return{event:e.event,id:e.id,data:{success:o}}}case"app:secure-storage:set":{let{key:t,value:o}=e.data,r=yield F.setItemAsync(Ve(t),o,{keychainAccessible:F.AFTER_FIRST_UNLOCK_THIS_DEVICE_ONLY}).then(()=>!0).catch(i=>(console.warn("Failed to write the value to secure store",i),!1));return{event:e.event,id:e.id,data:{success:r}}}}})}var Ve=e=>e.replaceAll(":","-");import eo from"react-fast-compare";import{createStore as to,useStore as Ce}from"zustand";var D=to()(()=>({user:null,storedUsers:[],proxyStatus:"loading"}));function S(){return D.getState().user}var Zs=D.subscribe.bind(D);function Ge(e){D.setState(({user:t})=>eo(t,e)?{}:{user:e})}var Pt=e=>D.setState({storedUsers:e.users}),oe=e=>D.setState({proxyStatus:e});function U(){return Ce(D,e=>e.user)}function ea(){return Ce(D,e=>!!e.user)}function Ut(){return Ce(D,e=>e.storedUsers)}function z(){return Ce(D,e=>e.proxyStatus!=="loading")}var so={shouldUseAppBackedStorage:!0},ao=";",co=500,lo=(e,t)=>{if(!e)return!1;try{return new URL(e).origin===new URL(t).origin}catch(o){return!1}},uo=1e3,po=6e4,It=({client:e,isClientReady:t})=>{let o=ne(null),[r,i]=oo(0),s=ne(0),n=ne(void 0),a=ne(0),d=ne(void 0);Rt(()=>()=>clearTimeout(d.current),[]);let c=G(y=>{e.logger.info(`[privy:webview] recreating, ${y}`),clearTimeout(d.current),s.current+=1,oe("reloading"),e.embeddedWallet.reload(),i(g=>g+1)},[e]);Rt(()=>{let y=no.addEventListener("change",g=>l(void 0,null,function*(){var b;if(g==="background")n.current=s.current,e.embeddedWallet.onBackground();else if(g==="active"){let C=(b=n.current)!=null?b:s.current;n.current=void 0,!(yield e.embeddedWallet.ping(co))&&s.current===C&&(oe("reloading"),e.embeddedWallet.reload())}}));return()=>y.remove()},[e]);let u=G(y=>l(void 0,null,function*(){var C;if(!lo(y.nativeEvent.url,e.embeddedWallet.getURL()))return;let{data:g}=y.nativeEvent,b=JSON.parse(g);if(a.current=0,At(b)){let k=yield xt(b);(C=o.current)==null||C.postMessage(JSON.stringify(k));return}e.embeddedWallet.onMessage(b)}),[e]),p=G(()=>{clearTimeout(d.current),oe("loaded")},[]),m=G(()=>{e.logger.info("[privy:webview] reloading, load failed"),oe("reloading"),e.embeddedWallet.reload()},[e]),w=G(y=>{let g=Math.min(uo*vt(2,a.current),po);a.current+=1,e.logger.warn(`[privy:webview] load failed (${y.nativeEvent.code}: ${y.nativeEvent.description}), retrying in ${g}ms`),clearTimeout(d.current),d.current=setTimeout(m,g)},[e,m]),h=G(()=>{c("content process terminated")},[c]),v=G(()=>{c("render process gone")},[c]);return t?ro.createElement(io,{key:r,style:{flex:1},ref:y=>{y&&(e.setMessagePoster(y),o.current=y)},cacheEnabled:!1,cacheMode:"LOAD_NO_CACHE",injectedJavaScriptObject:so,injectedJavaScriptBeforeContentLoaded:ao,source:{uri:e.embeddedWallet.getURL()},webviewDebuggingEnabled:e.logger.level==="DEBUG",onLoad:p,onError:w,onMessage:u,onContentProcessDidTerminate:h,onRenderProcessGone:v}):null};import{useCallback as Ke,useEffect as Tt,useMemo as qe}from"react";import{errorIndicatesRecoveryIsNeeded as yo,getAllUserEmbeddedSolanaWallets as fo,getEntropyDetailsFromUser as Ft,PrivyClientError as ie}from"@privy-io/js-sdk-core";import{getAllUserEmbeddedSolanaWallets as Ee,getEntropyDetailsFromAccount as Ot,getUserEmbeddedEthereumWallet as mo,PrivyClientError as B}from"@privy-io/js-sdk-core";function Lt(s){return l(this,arguments,function*({client:e,setSolanaWallet:t,createSolanaWalletCallbacks:o,setSolanaRecoveryFlowState:r,opts:i}){var n,a,d;t({status:"creating"});try{let{user:c}=yield e.user.get(),u=Ee(c),p=u[0],m=(n=mo(c))!=null?n:void 0;if(i!=null&&i.recoveryMethod&&i.recoveryMethod!=="privy")throw new B({code:"embedded_wallet_creation_error",error:"Unsupported recovery method for solana wallet."});if(!(i!=null&&i.createAdditional)&&p)throw new B({code:"embedded_wallet_creation_error",error:"Solana wallet already exists for this user. Set `createAdditional` to `true` to create another wallet"});let w,h;if(p){let y=m!=null?m:p,{entropyId:g,entropyIdVerifier:b}=Ot(y),C=Math.max(...u.map(P=>P.wallet_index),0)+1,k=yield e.embeddedWallet.add({chainType:"solana",entropyId:g,entropyIdVerifier:b,hdWalletIndex:C}),A=Ee(k.user).find(P=>P.wallet_index===C);if(!A)throw new B({error:"Embedded wallet account not created",code:"embedded_wallet_creation_error"});w=yield e.embeddedWallet.getSolanaProvider(A,g,b),h=k.user}else{let y=yield e.embeddedWallet.createSolana({ethereumAccount:m}),g=Ee(y.user).find(A=>A.wallet_index===0);if(!g)throw new B({error:"Embedded wallet account not created",code:"embedded_wallet_creation_error"});let b=m!=null?m:g,{entropyId:C,entropyIdVerifier:k}=Ot(b);w=yield e.embeddedWallet.getSolanaProvider(g,C,k),h=y.user}let v=Ee(h)[0];if(!v)throw new B({code:"embedded_wallet_creation_error",error:"Unknown error creating solana wallet"});return(d=(a=o.current)==null?void 0:a.onSuccess)==null||d.call(a,w),t({status:"connected",publicKey:v.public_key}),r({status:"initial"}),w}catch(c){let u=c instanceof Error?c.message:"Error creating embedded wallet";throw t({status:"error",error:u}),r({status:"initial"}),new B({code:"embedded_wallet_creation_error",error:u})}})}import{PrivyClientError as K}from"@privy-io/js-sdk-core";function _e(u){return l(this,arguments,function*({client:e,account:t,setWallet:o,recoverWalletCallbacks:r,recoveryMethod:i,setRecoveryFlowState:s,password:n,recoveryKey:a,recoveryToken:d,recoverySecretOverride:c}){var p,m,w,h;if(!t)throw new K({code:"embedded_wallet_does_not_exist",error:"Embedded wallet does not exist"});switch(i){case"user-passcode":if(!n)throw new K({code:"embedded_wallet_recovery_error",error:"password is required for user-passcode recovery method"});break;case"google-drive":if(!d)throw new K({code:"embedded_wallet_recovery_error",error:"Recovery token is required for google-drive recovery method"});break;case"icloud":if(!c)throw new K({code:"embedded_wallet_recovery_error",error:"Record name is required for icloud recovery method"});break;case"recovery-encryption-key":if(!a)throw new K({code:"embedded_wallet_recovery_error",error:"recoveryKey is required for recovery-encryption-key recovery method"});break}o({status:"connecting",account:t});try{let v=yield e.embeddedWallet.getProvider(t,n,d,c,a);return o({status:"connected",provider:v,account:t}),s({status:"initial"}),(m=(p=r.current)==null?void 0:p.onSuccess)==null||m.call(p,v),v}catch(v){o({status:"needs-recovery",account:t}),s({status:"initial"});let y=new K({code:"embedded_wallet_recovery_error",error:v instanceof Error?v.message:"Error recovering embedded wallet"});throw(h=(w=r.current)==null?void 0:w.onError)==null||h.call(w,y),y}})}function Mt(a){return l(this,arguments,function*({client:e,account:t,entropyId:o,entropyIdVerifier:r,setSolanaWallet:i,recoverSolanaWalletCallbacks:s,setSolanaRecoveryFlowState:n}){var d,c,u,p;i({status:"connecting"});try{let m=yield e.embeddedWallet.getSolanaProvider(t,o,r);return i({status:"connected",publicKey:m._publicKey}),n({status:"initial"}),(c=(d=s.current)==null?void 0:d.onSuccess)==null||c.call(d,m),m}catch(m){i({status:"needs-recovery"}),n({status:"initial"});let w=new K({code:"embedded_wallet_recovery_error",error:m instanceof Error?m.message:"Error recovering embedded wallet"});throw(p=(u=s.current)==null?void 0:u.onError)==null||p.call(u,w),w}})}var Dt=({client:e,solanaWallet:t,setSolanaWallet:o,setSolanaRecoveryFlowState:r,createSolanaWalletCallbacks:i,recoverSolanaWalletCallbacks:s})=>{let n=U(),a=qe(()=>fo(n),[n]),d=z(),c=qe(()=>a.length===0?null:Ft(n,a[0]),[n,a]),u=qe(()=>{let h=a.map(b=>{let C=Ft(n,b);return C?{account:b,entropy:C}:null});if(h.some(b=>b===null))return[];let v=void 0,y=void 0,g=void 0;return h.filter(b=>b!==null).map(({account:b,entropy:{entropyId:C,entropyIdVerifier:k}})=>({address:b.address,publicKey:b.address,walletIndex:b.wallet_index,getProvider:()=>e.embeddedWallet.getSolanaProvider(b,C,k,v,y,g,A=>l(void 0,null,function*(){var P;yield(P=be())==null?void 0:P(A)}))}))},[a,n,e]),p=Ke(h=>l(void 0,null,function*(){return yield Lt({client:e,setSolanaWallet:o,createSolanaWalletCallbacks:i,setSolanaRecoveryFlowState:r,opts:h})}),[e,i]),m=Ke(()=>l(void 0,null,function*(){if(!c)throw new ie({code:"embedded_wallet_does_not_exist",error:"Embedded wallet does not exist"});let{entropyId:h,entropyIdVerifier:v}=c;return Mt({client:e,account:a[0],entropyId:h,entropyIdVerifier:v,setSolanaWallet:o,recoverSolanaWalletCallbacks:s,setSolanaRecoveryFlowState:r})}),[e,c,a,s,r,o]),w=Ke(()=>l(void 0,null,function*(){if(!c)throw o({status:"not-created"}),new ie({code:"embedded_wallet_does_not_exist",error:"Embedded wallet does not exist"});o(h=>h.status==="connected"?{status:"reconnecting"}:{status:"connecting"});try{let{entropyId:h,entropyIdVerifier:v}=c,y=yield e.embeddedWallet.getSolanaProvider(a[0],h,v);return o({status:"connected",publicKey:a[0].public_key}),y}catch(h){throw yo(h)?(o({status:"needs-recovery"}),new ie({code:"embedded_wallet_needs_recovery",error:"Embedded wallet not loaded on device"})):h instanceof Error?(o({status:"error",error:h.message}),new ie({code:"unknown_embedded_wallet_error",error:h.message})):(o({status:"error",error:"Error loading embedded wallet"}),new ie({code:"unknown_embedded_wallet_error",error:"Error loading embedded wallet"}))}}),[a,e,c,o]);return Tt(()=>{if(!n&&t.status!=="disconnected")return o({status:"disconnected"});d&&w().catch(()=>{})},[d,n]),Tt(()=>{t.status==="error"&&t.error.includes("User must be logged in")&&w()},[t.status]),{create:p,recover:m,getProvider:w,wallets:u}};import{useCallback as ce,useEffect as Kt,useMemo as Wo}from"react";import{getUserEmbeddedEthereumWallet as Ao,getUserEmbeddedSolanaWallet as qt,isUnifiedWallet as xo,throwIfInvalidRecoveryUpgradePath as Po}from"@privy-io/js-sdk-core";import{errorIndicatesRecoveryIsNeeded as Uo,PrivyClientError as R}from"@privy-io/js-sdk-core";import{getUserEmbeddedEthereumWallet as go}from"@privy-io/js-sdk-core";import{PrivyClientError as H}from"@privy-io/js-sdk-core";function ke(p){return l(this,arguments,function*({client:e,setWallet:t,createWalletCallbacks:o,recoveryMethod:r,setRecoveryFlowState:i,password:s,recoveryKey:n,recoveryToken:a,recoverySecretOverride:d,iCloudRecordNameOverride:c,solanaAccount:u}){var w,h;switch(r){case"user-passcode":if(!s)throw new H({code:"embedded_wallet_recovery_error",error:"password is required for user-passcode recovery method"});break;case"recovery-encryption-key":if(!n)throw new H({code:"embedded_wallet_recovery_error",error:"key is required for recovery-encryption-key recovery method"});break;case"google-drive":if(!a)throw new H({code:"embedded_wallet_recovery_error",error:"Recovery token is required for google-drive recovery method"});break;case"icloud":if(!d||!c)throw new H({code:"embedded_wallet_recovery_error",error:"iCloud recovery failed due to inability to store credentials"});break}t({status:"creating",account:null});let m=r==="icloud"?"icloud-native":r;try{let{user:v}=yield e.embeddedWallet.create({password:s,recoveryMethod:m,recoveryKey:n,recoveryToken:a,recoverySecretOverride:d,iCloudRecordNameOverride:c,solanaAccount:u}),y=go(v);if(!y)throw new H({error:"Embedded wallet account not created",code:"embedded_wallet_creation_error"});let g=yield e.embeddedWallet.getProvider(y);return(h=(w=o.current)==null?void 0:w.onSuccess)==null||h.call(w,g),t({status:"connected",provider:g,account:y}),i({status:"initial"}),g}catch(v){let y=v instanceof Error?v.message:"Error creating embedded wallet";throw t({status:"error",error:y,account:null}),i({status:"initial"}),new H({code:"embedded_wallet_creation_error",error:y})}})}import{Platform as jt}from"react-native";import{PrivyClientError as N}from"@privy-io/js-sdk-core";import{Platform as ho}from"react-native";var Nt=new Set;function We(e,{isDevelopment:t=__DEV__,reactNativeVersion:o=ho.constants.reactNativeVersion,warn:r=i=>console.warn(i)}={}){if(!t||Nt.has(e))return;let{major:i,minor:s,patch:n}=o;if(i>0||i===0&&s>=81)return;let d=`[Privy] Upcoming optional dependency change
2
2
 
3
3
  This app uses React Native ${`${i}.${s}.${n}`}. A future @privy-io/expo release will make ${e} optional.
4
4
 
@@ -9,4 +9,4 @@ Check Metro with:
9
9
  npm ls metro metro-config metro-runtime
10
10
  yarn why metro
11
11
 
12
- If these requirements cannot be met, keep ${e} installed.`:d+`Expo SDK 52 and React Native 0.78 or earlier cannot safely omit ${e}. Upgrade to Expo SDK 54 or React Native 0.81, or keep ${e} installed.`;Dt.add(e),r(c)}function jt(){return l(this,null,function*(){We("@privy-io/expo-native-extensions");try{return yield import("@privy-io/expo-native-extensions")}catch(e){throw new N({code:"configuration_error",error:"`@privy-io/expo-native-extensions` is not installed. Install it and rebuild the native app."})}})}function se(r){return l(this,arguments,function*({user:e,appId:t,client:o}){var a;if(Nt.OS==="android")throw new N({code:"embedded_wallet_recovery_error",error:"iCloud recovery is not supported on Android"});let i=yield jt(),s=yield o.recovery.icloudAuth.getICloudConfiguration("expo-ios");if(!(s==null?void 0:s.container_identifier))throw new N({code:"embedded_wallet_recovery_error",error:"An iCloud Container ID must be specified in the Privy Dashboard."});try{let{recoverySecret:d,iCloudRecordName:c}=yield i.writeRecoverySecretToICloud({containerId:s.container_identifier,appId:t,userId:e.id});return{recoverySecret:d,iCloudRecordName:c}}catch(d){if(d instanceof Error){let c=(a=d.message.split("Caused by: ")[1])!=null?a:"Error writing to iCloud";throw new N({code:"embedded_wallet_recovery_error",error:c})}throw new N({code:"embedded_wallet_recovery_error",error:"Error writing to iCloud"})}})}function Ae(r){return l(this,arguments,function*({walletAddress:e,client:t,chainType:o}){var c;if(Nt.OS==="android")throw new N({code:"embedded_wallet_recovery_error",error:"iCloud recovery is not supported on Android"});let i=yield jt(),n=(yield t.recovery.getRecoveryKeyMaterial(e,o)).icloud_record_name;if(!n)throw new N({code:"embedded_wallet_recovery_error",error:"iCloud recovery not properly backed up."});let a=yield t.recovery.icloudAuth.getICloudConfiguration("expo-ios"),d=a==null?void 0:a.container_identifier;if(!d)throw new N({code:"embedded_wallet_recovery_error",error:"An iCloud Container ID must be specified in the Privy Dashboard."});try{let{recoverySecret:u}=yield i.readRecoverySecretFromICloud({containerId:d,recordName:n});return{recoverySecret:u}}catch(u){if(u instanceof Error){let p=(c=u.message.split("Caused by: ")[1])!=null?c:"Error writing to iCloud";throw new N({code:"embedded_wallet_recovery_error",error:p})}throw new N({code:"embedded_wallet_recovery_error",error:"Error writing to iCloud"})}})}import*as q from"expo-linking";import*as zt from"expo-web-browser";import{Platform as Vt}from"react-native";import{PrivyClientError as $}from"@privy-io/js-sdk-core";import Fa from"react-fast-compare";import{PrivyApiError as vo,PrivyClientError as bo}from"@privy-io/js-sdk-core";function E(e){return e instanceof Error||e instanceof vo||e instanceof bo?e:typeof e=="string"?new Error(e):new Error("Unknown error")}var J=e=>new Promise(t=>setTimeout(t,e));import{useEffect as So,useRef as Co}from"react";import{AppState as Be}from"react-native";function xe(){let e=Co(Be.currentState);So(()=>Be.addEventListener("change",r=>{e.current=r}).remove,[]);function t(){return Be.currentState}return{appState:e,getCurrentAppState:t}}function ae(i){return l(this,arguments,function*({provider:e,redirectUri:t,client:o,onError:r}){try{let s;switch(e){case"google-drive":{let{url:c}=yield o.recovery.auth.generateURL(q.createURL(t||"/"));s=c;break}default:throw new $({error:"OAuth invalid provider",code:"embedded_wallet_recovery_error"})}let n=yield zt.openAuthSessionAsync(s);if(Vt.OS==="android")return;if(n.type!=="success")throw new $({error:"Recovery OAuth session failed",code:"embedded_wallet_recovery_error"});let{queryParams:a}=q.parse(n.url),d;switch(e){case"google-drive":{let{privy_oauth_state:c,privy_oauth_code:u}=a;if(!u||!c)throw new $({error:"Recovery OAuth invalid credentials",code:"embedded_wallet_recovery_error"});d=yield Pe({oAuthCode:u,oAuthState:c,client:o});break}default:throw new $({error:"Recovery OAuth invalid provider",code:"embedded_wallet_recovery_error"})}return d}catch(s){throw r==null||r(E(s)),s}})}function Pe(r){return l(this,arguments,function*({oAuthCode:e,oAuthState:t,client:o}){let{access_token:i}=yield o.recovery.auth.authorize(e,t);if(!i)throw new $({error:"OAuth invalid credentials",code:"login_with_oauth_returned_with_invalid_credentials"});return i})}var Eo=2*60*1e3;function _o(e){let t;return new Promise((o,r)=>{t=q.addEventListener("url",s=>l(this,[s],function*({url:i}){if(!i)return;let{queryParams:n}=q.parse(i),{privy_oauth_state:a,privy_oauth_code:d}=n!=null?n:{};if(typeof d!="string"||typeof a!="string")return;let c=yield Pe({client:e,oAuthCode:d,oAuthState:a});o(c)})),setTimeout(()=>{r(new $({code:"embedded_wallet_set_recovery_error",error:"Failed to complete Google Drive recovery flow"}))},Eo)}).finally(()=>{t==null||t.remove()})}function Ue(e){return l(this,null,function*(){let t;Vt.OS==="android"&&(t=_o(e));let o=yield ae({provider:"google-drive",client:e});return o!=null?o:yield t})}import{getUserEmbeddedWallet as ko,PrivyClientError as Wo}from"@privy-io/js-sdk-core";function Re(s){return l(this,arguments,function*({client:e,recoveryInput:t,setWalletRecoveryCallbacks:o,setRecoveryFlowState:r,setWallet:i}){var n,a,d,c;try{let{provider:u,user:p}=yield e.embeddedWallet.setRecovery(t),m=u,w=ko(p);return i({status:"connected",provider:m,account:w}),(a=(n=o.current)==null?void 0:n.onSuccess)==null||a.call(n,m),r({status:"initial"}),m}catch(u){let p=new Wo({code:"embedded_wallet_set_recovery_error",error:u instanceof Error?u.message:"Error setting password on embedded wallet"});throw(c=(d=o.current)==null?void 0:d.onError)==null||c.call(d,p),r({status:"initial"}),p}})}function qt(e){return e===void 0?{recoveryMethod:"privy"}:typeof e=="string"?{recoveryMethod:"user-passcode",password:e}:e.recoveryMethod==="user-passcode"?{recoveryMethod:"user-passcode",password:e.password}:e.recoveryMethod==="recovery-encryption-key"?{recoveryMethod:"recovery-encryption-key",recoveryKey:e.recoveryKey}:{recoveryMethod:e.recoveryMethod}}var Bt=({client:e,appId:t,wallet:o,setWallet:r,setRecoveryFlowState:i,createWalletCallbacks:s,recoverWalletCallbacks:n,setWalletRecoveryCallbacks:a})=>{let d=U(),c=Ao(()=>xo(d),[d]),u=z(),p=ce(y=>l(void 0,null,function*(){var ge,he;if(c)throw new R({error:"This user already has an embedded wallet",code:"embedded_wallet_already_exists"});let{user:g}=yield e.user.get(),{password:b,recoveryMethod:C,recoveryKey:k}=qt(y),A,P,T;if(C==="google-drive"&&(A=yield ae({provider:C,client:e,onError:(ge=s.current)==null?void 0:ge.onError}),i({status:"creating-wallet"}),!A))return null;if(C==="icloud"){if(!g)throw new R({code:"embedded_wallet_recovery_error",error:"User must be loaded before creating a wallet with iCloud."});let{recoverySecret:Ne,iCloudRecordName:re}=yield se({user:g,appId:t,client:e});P=Ne,T=re}return yield ke({client:e,setWallet:r,createWalletCallbacks:s,recoveryMethod:C,recoveryKey:k,setRecoveryFlowState:i,password:b,recoverySecretOverride:P,iCloudRecordNameOverride:T,solanaAccount:(he=Kt(g))!=null?he:void 0})}),[e,c,d]),m=ce(y=>l(void 0,null,function*(){var C;if(o.status!=="connected")throw new R({code:"attempted_to_set_password_before_connected",error:"Embedded wallet must be connected before setting password"});if(!c)throw new R({code:"embedded_wallet_does_not_exist",error:"Embedded wallet does not exist"});if(Kt(d))throw new R({code:"embedded_wallet_set_recovery_error",error:"Cannot set user-controlled recovery for a user with an embedded Solana wallet."});if(Po(c))throw new R({code:"unsupported_wallet_type",error:"Embedded wallet recovery is only supported for on-device execution and this app uses TEE execution. Learn more https://docs.privy.io/recipes/tee-wallet-migration-guide"});Uo({currentRecoveryMethod:c.recovery_method,upgradeToRecoveryMethod:y.recoveryMethod});let g,b;switch(y.recoveryMethod){case"privy":b=M(_({},y),{wallet:c});break;case"user-passcode":b=M(_({},y),{wallet:c,password:y.password});break;case"google-drive":if(g=yield ae({provider:y.recoveryMethod,client:e,onError:(C=a.current)==null?void 0:C.onError}),i({status:"upgrading-recovery"}),!g)return null;b={recoveryMethod:"google-drive",wallet:c,recoveryAccessToken:g};break;case"icloud":if(!d)throw new R({code:"embedded_wallet_recovery_error",error:"User must be loaded before backing up to iCloud."});let{recoverySecret:k,iCloudRecordName:A}=yield se({user:d,appId:t,client:e});b={recoveryMethod:"icloud-native",recoverySecretOverride:k,iCloudRecordNameOverride:A,wallet:c};break;default:throw new R({code:"embedded_wallet_recovery_error",error:"Unrecognized recovery method"})}return Re({client:e,recoveryInput:b,setWalletRecoveryCallbacks:a,setRecoveryFlowState:i,setWallet:r})}),[e,c,o.status,d]),w=ce(y=>l(void 0,null,function*(){return m({recoveryMethod:"user-passcode",password:y})}),[e,c,o.status]),h=ce(y=>l(void 0,null,function*(){var P;if(!c)throw new R({code:"embedded_wallet_does_not_exist",error:"Embedded wallet does not exist"});let{password:g,recoveryMethod:b,recoveryKey:C}=qt(y),k,A;if(b==="google-drive"&&(k=yield ae({provider:b,client:e,onError:(P=n.current)==null?void 0:P.onError}),i({status:"recovering"}),!k))return null;if(b==="icloud"){if(!d)throw new R({code:"embedded_wallet_recovery_error",error:"User must be loaded before recovering via iCloud."});let{recoverySecret:T}=yield Ae({client:e,walletAddress:c.address});A=T}return _e({client:e,account:c,setWallet:r,recoverWalletCallbacks:n,recoveryMethod:b,setRecoveryFlowState:i,recoveryKey:C,password:g,recoveryToken:k,recoverySecretOverride:A})}),[e,c]),v=ce(()=>l(void 0,null,function*(){if(!c)throw r({status:"not-created",account:null}),new R({code:"embedded_wallet_does_not_exist",error:"Embedded wallet does not exist"});r(y=>y.status==="connected"?{status:"reconnecting",account:c}:{status:"connecting",account:c});try{let y=yield e.embeddedWallet.getProvider(c);return r({status:"connected",provider:y,account:c}),y}catch(y){throw Ro(y)?(r({status:"needs-recovery",account:c}),new R({code:"embedded_wallet_needs_recovery",error:"Embedded wallet not loaded on device"})):y instanceof Error?(r({status:"error",error:y.message,account:c}),new R({code:"unknown_embedded_wallet_error",error:y.message})):(r({status:"error",error:"Error loading embedded wallet",account:c}),new R({code:"unknown_embedded_wallet_error",error:"Error loading embedded wallet"}))}}),[e,c]);return Gt(()=>{if(!d&&o.status!=="disconnected")return r({status:"disconnected",account:null});u&&v().catch(()=>{})},[u,d,c]),Gt(()=>{o.status==="error"&&o.error.includes("User must be logged in")&&v()},[o.status]),{create:p,recover:h,setPassword:w,setRecovery:m,getProvider:v}};import{useEffect as Io,useState as Oo}from"react";import{PrivyClientError as Ht}from"@privy-io/js-sdk-core";var Jt=({client:e,isReady:t})=>{let o=U(),r=Se(n=>n==null?void 0:n.customAuth),[i,s]=Oo({status:"initial"});return Io(()=>{(()=>l(void 0,null,function*(){if(!(r!=null&&r.enabled)){s({status:"not-enabled"});return}s({status:"loading"});let{getCustomAccessToken:a,isLoading:d}=r;if(!(!t||d))try{let c=yield a();if(!c&&o){yield e.auth.logout(),s({status:"done"});return}if(!c){s({status:"done"});return}if(o){s({status:"done"});return}let u=x();if(!(yield e.auth.customProvider.syncWithToken(c,{embedded:u==null?void 0:u.embedded}))){yield e.auth.logout(),s({status:"error",error:new Ht({error:"Failed to sync with custom auth provider",code:"third_party_auth_error"})});return}s({status:"done"})}catch(c){if(s({status:"error",error:c}),o)throw yield e.auth.logout(),new Ht({error:"Third-party auth failed",code:"third_party_auth_error"})}}))()},[e,o,t,r==null?void 0:r.enabled,r==null?void 0:r.getCustomAccessToken,r==null?void 0:r.isLoading]),{customAuthState:i,customAuthStateIsSettled:i.status!=="loading"&&i.status!=="initial"}};import*as Q from"expo-linking";import{useCallback as Lo,useEffect as Mo,useMemo as To}from"react";import{Platform as Fo}from"react-native";import{getUserEmbeddedSolanaWallet as Do,getUserEmbeddedWallet as No}from"@privy-io/js-sdk-core";var $t=({client:e,createWalletCallbacks:t,recoverWalletCallbacks:o,setWalletRecoveryCallbacks:r,recoveryFlowState:i,oAuthState:s,setRecoveryFlowState:n,setWallet:a,appStateVisible:d})=>{let c=Q.useURL(),u=U(),p=To(()=>No(u),[u]),m=z(),w=Lo(h=>{var y,g,b,C;let v=E(h);i.status==="creating-wallet"?(g=(y=t.current).onError)==null||g.call(y,E(v)):(C=(b=o.current).onError)==null||C.call(b,E(v)),n({status:"initial"})},[i]);return Mo(()=>{function h(){return l(this,null,function*(){var b;if(!c&&i.status!=="initial"&&d&&w(new Error("Recovery OAuth session failed")),!c||i.status==="initial"||s.status!=="initial"||!d||!m)return;let{queryParams:v}=Q.parse(c),{privy_oauth_state:y,privy_oauth_code:g}=v;if(!(!g||!y)){yield Q.openURL(c.split("?")[0]);try{let C=yield Pe({oAuthCode:g,oAuthState:y,client:e});if(i.status==="creating-wallet"){let k=(b=Do(u))!=null?b:void 0;yield ke({client:e,setWallet:a,createWalletCallbacks:t,recoveryMethod:"google-drive",setRecoveryFlowState:n,recoveryToken:C,solanaAccount:k})}else if(i.status==="upgrading-recovery"){if(!p)throw new Error("Embedded wallet not found");yield Re({client:e,recoveryInput:{recoveryMethod:"google-drive",wallet:p,recoveryAccessToken:C},setWalletRecoveryCallbacks:r,setRecoveryFlowState:n,setWallet:a})}else yield _e({client:e,account:p,setWallet:a,recoverWalletCallbacks:o,recoveryMethod:"google-drive",setRecoveryFlowState:n,recoveryToken:C})}catch(C){w(C)}}})}Fo.OS==="android"&&h()},[c,i.status,d,m])};import{useEffect as zo}from"react";import{Platform as He}from"react-native";var jo="sdk_initialize";function Qt(){let{major:e,minor:t,patch:o,prerelease:r}=He.constants.reactNativeVersion;return{name:jo,properties:{reactNativeVersion:`${e}.${t}.${o}${r!=null?`-${r}`:""}`,operatingSystem:`${He.OS}:${He.Version}`}}}var Yt=({client:e,isUserInitialized:t,setIsUserInitialized:o,setError:r})=>{zo(()=>{t||(()=>l(void 0,null,function*(){try{yield e.initialize(),e.track(Qt())}catch(s){r(s instanceof Error?s:new Error(String(s)))}try{yield e.user.get()}catch(s){}finally{o(!0)}}))()},[e,t,r,o])};import{useEffect as Ps,useRef as Us}from"react";import{useCallback as Je,useContext as Vo}from"react";import{PrivyClientError as Go}from"@privy-io/js-sdk-core";var Bc=e=>{let{client:t,setSiweState:o,siweState:r}=Vo(f),i=Je(a=>{var c;let d=E(a);return o({status:"error",error:d}),(c=e==null?void 0:e.onError)==null||c.call(e,d),d},[e==null?void 0:e.onError]),s=Je(u=>l(void 0,[u],function*({wallet:a,from:{domain:d,uri:c}}){var p;try{o({status:"generating-message"});let m=yield t.auth.siwe.init(a,d,c);return o({status:"awaiting-signature"}),(p=e==null?void 0:e.onGenerateMessage)==null||p.call(e,m.message),m.message}catch(m){throw i(m)}}),[t,i,e==null?void 0:e.onGenerateMessage]);return{loginWithSiwe:Je(u=>l(void 0,[u],function*({signature:a,messageOverride:d,disableSignup:c}){var p;try{if(S())throw new Go({code:"attempted_login_with_siwe_while_already_logged_in",error:"Already logged in, use `useLinkWithSiwe` if you are trying to link a wallet to an existing account"});o({status:"submitting-signature"});let w=x(),h=yield t.auth.siwe.loginWithSiwe(a,void 0,d,c?"no-signup":"login-or-sign-up",{embedded:w==null?void 0:w.embedded});return o({status:"done"}),(p=e==null?void 0:e.onSuccess)==null||p.call(e,h.user,h.is_new_user),h.user}catch(m){throw i(m)}}),[t,i,e==null?void 0:e.onSuccess]),generateSiweMessage:s,state:r}};import{useCallback as Xt}from"react";import{createSiwsMessage as qo,PrivyClientError as Bo}from"@privy-io/js-sdk-core";import{useContext as Ko}from"react";var W=()=>{let{client:e}=Ko(f);return e};var od=()=>{let e=W(),t=Xt(n=>l(void 0,[n],function*({wallet:{address:r},from:{domain:i,uri:s}}){try{let{nonce:a}=yield e.auth.siws.fetchNonce({address:r});return{message:qo({address:r,domain:i,uri:s,nonce:a})}}catch(a){throw E(a)}}),[e]),o=Xt(a=>l(void 0,[a],function*({signature:r,message:i,wallet:{walletClientType:s,connectorType:n}={}}){try{if(!S())throw new Bo({code:"attempted_link_siws_before_logged_in",error:"Must be logged in to link a wallet, Use `useLoginWithSiws` to login with a wallet"});let{user:c}=yield e.auth.siws.link({signature:r,message:i,walletClientType:s,connectorType:n});return c}catch(d){throw E(d)}}),[e]);return{generateMessage:t,link:o}};import{useCallback as Zt}from"react";import{createSiwsMessage as Ho,PrivyClientError as Jo}from"@privy-io/js-sdk-core";var pd=()=>{let e=W(),t=Zt(n=>l(void 0,[n],function*({wallet:{address:r},from:{domain:i,uri:s}}){try{let{nonce:a}=yield e.auth.siws.fetchNonce({address:r});return{message:Ho({address:r,domain:i,uri:s,nonce:a})}}catch(a){throw E(a)}}),[e]),o=Zt(d=>l(void 0,[d],function*({signature:r,message:i,wallet:{walletClientType:s,connectorType:n}={},disableSignup:a}){try{if(S())throw new Jo({code:"attempted_login_with_siws_while_already_logged_in",error:"Already logged in, use `useLinkWithSiws` if you are trying to link a wallet to an existing account"});let u=x();return(yield e.auth.siws.login({signature:r,message:i,walletClientType:s,connectorType:n,mode:a?"no-signup":"login-or-sign-up",opts:{embedded:u==null?void 0:u.embedded}})).user}catch(c){throw E(c)}}),[e]);return{generateMessage:t,login:o}};import{useCallback as er,useContext as $o}from"react";import{PrivyClientError as Qo}from"@privy-io/js-sdk-core";var bd=e=>{let{client:t}=$o(f),o=er(i=>{var n;let s=E(i);return(n=e==null?void 0:e.onError)==null||n.call(e,s),s},[e==null?void 0:e.onError]);return{unlinkWallet:er(s=>l(void 0,[s],function*({address:i}){var n;try{if(!S())throw new Qo({code:"attempted_unlink_siwe_before_logged_in",error:"Must be logged in to unlink a wallet, Use `useLoginWithSiwe` to login with a wallet"});let{user:d}=yield t.auth.siwe.unlinkWallet(i);return(n=e==null?void 0:e.onSuccess)==null||n.call(e,d),d}catch(a){throw o(a)}}),[t,o,e==null?void 0:e.onSuccess])}};import{useCallback as $e,useContext as Yo,useState as Xo}from"react";import{PrivyClientError as tr}from"@privy-io/js-sdk-core";var xd=e=>{let[t,o]=Xo(""),{client:r,otpState:i,setOtpState:s}=Yo(f),n=$e(c=>{var p;let u=E(c);return s({status:"error",error:u}),(p=e==null?void 0:e.onError)==null||p.call(e,u),u},[e,s]),a=$e(u=>l(void 0,[u],function*({email:c}){var p;o(c);try{s({status:"sending-code"});let m=yield r.auth.email.sendCode(c);return s({status:"awaiting-code-input"}),(p=e==null?void 0:e.onSendCodeSuccess)==null||p.call(e,{email:c}),m}catch(m){throw n(m)}}),[r,n,e,s]),d=$e(p=>l(void 0,[p],function*({code:c,email:u}){var m;try{if(!S())throw new tr({code:"attempted_link_email_before_logged_in",error:"Must be logged in to link an email, Use `useLoginWithEmail` to login with email"});let h=u||t;if(!h)throw new tr({code:"attempted_submit_otp_before_sending",error:"Must `sendCode` with a valid email before calling `linkWithCode`"});s({status:"submitting-code"});let{user:v}=yield r.auth.email.linkWithCode(h,c);return s({status:"done"}),(m=e==null?void 0:e.onLinkSuccess)==null||m.call(e,v),v}catch(w){throw n(w)}}),[t,s,r,e,n]);return{sendCode:a,linkWithCode:d,state:i}};import{useCallback as rr,useContext as Zo}from"react";var Ld=e=>{let{client:t}=Zo(f),o=rr(i=>{var n;let s=E(i);return(n=e==null?void 0:e.onError)==null||n.call(e,s),s},[e==null?void 0:e.onError]);return{unlinkEmail:rr(s=>l(void 0,[s],function*({email:i}){var n;try{let{user:a}=yield t.auth.email.unlink(i);return(n=e==null?void 0:e.onSuccess)==null||n.call(e,a),a}catch(a){throw o(a)}}),[t,e==null?void 0:e.onSuccess,o])}};import{useCallback as Qe,useContext as en,useState as tn}from"react";import{PrivyClientError as or}from"@privy-io/js-sdk-core";var Gd=e=>{let[t,o]=tn(""),{client:r,otpState:i,setOtpState:s}=en(f),n=Qe(c=>{var p;let u=E(c);return s({status:"error",error:u}),(p=e==null?void 0:e.onError)==null||p.call(e,u),u},[e,s]),a=Qe(u=>l(void 0,[u],function*({email:c}){var p;o(c);try{s({status:"sending-code"});let m=yield r.auth.email.sendCode(c);return s({status:"awaiting-code-input"}),(p=e==null?void 0:e.onSendCodeSuccess)==null||p.call(e,{email:c}),m}catch(m){throw n(m)}}),[r,n,e,s]),d=Qe(m=>l(void 0,[m],function*({code:c,email:u,disableSignup:p}){var w;try{if(S()&&!r.isMultiUserModeEnabled)throw new or({code:"attempted_login_with_email_while_already_logged_in",error:"Already logged in, use `useLinkWithEmail` if you are trying to link an email to an existing account"});let v=u||t;if(!v)throw new or({code:"attempted_submit_otp_before_sending",error:"Must `sendCode` with a valid email before calling `loginWithCode`"});s({status:"submitting-code"});let y=x(),g=yield r.auth.email.loginWithCode(v,c,p?"no-signup":"login-or-sign-up",{embedded:y==null?void 0:y.embedded});return s({status:"done"}),(w=e==null?void 0:e.onLoginSuccess)==null||w.call(e,g.user,g.is_new_user),g==null?void 0:g.user}catch(h){throw n(h)}}),[t,s,r,e,n]);return{sendCode:a,loginWithCode:d,state:i}};import{useCallback as Ye,useContext as rn,useState as on}from"react";import{PrivyClientError as nr}from"@privy-io/js-sdk-core";var Yd=e=>{let[t,o]=on(""),{client:r,otpState:i,setOtpState:s}=rn(f),n=Ye(c=>{var p;let u=E(c);return s({status:"error",error:u}),(p=e==null?void 0:e.onError)==null||p.call(e,u),u},[e,s]),a=Ye(u=>l(void 0,[u],function*({phone:c}){var p;o(c);try{s({status:"sending-code"});let m=yield r.auth.phone.sendCode(c);return s({status:"awaiting-code-input"}),(p=e==null?void 0:e.onSendCodeSuccess)==null||p.call(e,{phone:c}),m}catch(m){throw n(m)}}),[r,n,e,s]),d=Ye(p=>l(void 0,[p],function*({code:c,phone:u}){var m;try{if(!S())throw new nr({code:"attempted_link_sms_before_logged_in",error:"Must be logged in to link a phone number, Use `useLoginWithSMS` to login with a phone number"});if(!(u||t))throw new nr({code:"attempted_submit_otp_before_sending",error:"Must `sendCode` with a valid phone number before calling `linkWithCode`"});s({status:"submitting-code"});let{user:v}=yield r.auth.phone.linkWithCode(u||t,c);return s({status:"done"}),(m=e==null?void 0:e.onLinkSuccess)==null||m.call(e,v),v}catch(w){throw n(w)}}),[t,s,r,e,n]);return{sendCode:a,linkWithCode:d,state:i}};import{useCallback as Xe,useContext as nn,useState as sn}from"react";import{PrivyClientError as ir}from"@privy-io/js-sdk-core";var sl=e=>{let[t,o]=sn(""),{client:r,otpState:i,setOtpState:s}=nn(f),n=Xe(c=>{var p;let u=E(c);return s({status:"error",error:u}),(p=e==null?void 0:e.onError)==null||p.call(e,u),u},[e,s]),a=Xe(u=>l(void 0,[u],function*({phone:c}){var p;o(c);try{s({status:"sending-code"});let m=yield r.auth.phone.sendCode(c);return s({status:"awaiting-code-input"}),(p=e==null?void 0:e.onSendCodeSuccess)==null||p.call(e,{phone:c}),m}catch(m){throw n(m)}}),[r,n,e,s]),d=Xe(m=>l(void 0,[m],function*({code:c,phone:u,disableSignup:p}){var w;try{if(S())throw new ir({code:"attempted_login_with_sms_while_already_logged_in",error:"Already logged in, use `useLinkWithSMS` if you are trying to link a phone number to an existing account"});if(!(u||t))throw new ir({code:"attempted_submit_otp_before_sending",error:"Must `sendCode` with a valid phone number before calling `loginWithCode`"});s({status:"submitting-code"});let y=x(),g=yield r.auth.phone.loginWithCode(u||t,c,p?"no-signup":"login-or-sign-up",{embedded:y==null?void 0:y.embedded});return s({status:"done"}),(w=e==null?void 0:e.onLoginSuccess)==null||w.call(e,g.user,g.is_new_user),g==null?void 0:g.user}catch(h){throw n(h)}}),[t,s,r,e,n]);return{sendCode:a,loginWithCode:d,state:i}};import*as Ie from"expo-linking";import{useCallback as Ze,useContext as an,useRef as cn}from"react";import{PrivyClientError as de}from"@privy-io/js-sdk-core";var yl=e=>{let{appState:t,getCurrentAppState:o}=xe(),{client:r,farcasterState:i,setFarcasterState:s}=an(f),n=cn(!1),a=Ze(u=>{var m;let p=E(u);return s({status:"error",error:p}),(m=e==null?void 0:e.onError)==null||m.call(e,p),p},[e==null?void 0:e.onError,s]),d=Ze(()=>{n.current=!0},[]);return{linkWithFarcaster:Ze((w,...h)=>l(void 0,[w,...h],function*({relyingParty:u,redirectUrl:p},m={pollAttempts:10,pollIntervalMs:1e3}){var v;try{let y=S();if(n.current=!1,!y)throw new de({code:"attempted_link_farcaster_before_logged_in",error:"Must be logged in to link a Farcaster account."});s({status:"generating-uri"});let{connect_uri:g,channel_token:b}=yield r.auth.farcaster.initializeAuth({relyingParty:u,redirectUrl:Ie.createURL(p!=null?p:"/")});if(!g)throw new de({code:"failed_to_generate_farcaster_uri",error:"Failed to generate farcaster uri"});if(!b)throw new de({code:"failed_to_generate_farcaster_channel_token",error:"Failed to generate farcaster channel token"});yield Ie.openURL(g),s({status:"polling-status"});let C=0;for(;C<m.pollAttempts;){if(n.current)throw new de({code:"farcaster_polling_canceled",error:"Farcaster polling canceled"});if(t.current!=="active"&&o()!=="active"){yield J(m.pollIntervalMs);continue}let k=yield r.auth.farcaster.getFarcasterStatus({channel_token:b});if(k.state==="completed"){s({status:"submitting-token"});let{user:A}=yield r.auth.farcaster.link(_({channel_token:b},k));return s({status:"done"}),(v=e==null?void 0:e.onSuccess)==null||v.call(e,A),A}C++,yield J(m.pollIntervalMs)}throw new de({code:"farcaster_polling_timeout",error:"Farcasting polling timed out"})}catch(y){throw a(y)}}),[r,e==null?void 0:e.onSuccess,a,s]),state:i,cancel:d}};import{useCallback as sr,useContext as dn}from"react";var bl=e=>{let{client:t}=dn(f),o=sr(i=>{var n;let s=E(i);return(n=e==null?void 0:e.onError)==null||n.call(e,s),s},[e==null?void 0:e.onError]);return{unlinkFarcaster:sr(s=>l(void 0,[s],function*({fid:i}){var n;try{let{user:a}=yield t.auth.farcaster.unlink({fid:i});return(n=e==null?void 0:e.onSuccess)==null||n.call(e,a),a}catch(a){throw o(a)}}),[t,e==null?void 0:e.onSuccess,o])}};import*as Oe from"expo-linking";import{useCallback as rt,useContext as ln,useRef as un}from"react";import{PrivyClientError as le}from"@privy-io/js-sdk-core";var Pl=e=>{let{appState:t,getCurrentAppState:o}=xe(),{client:r,farcasterState:i,setFarcasterState:s}=ln(f),n=un(!1),a=rt(u=>{var m;let p=E(u);return s({status:"error",error:p}),(m=e==null?void 0:e.onError)==null||m.call(e,p),p},[e==null?void 0:e.onError,s]),d=rt(()=>{n.current=!0},[]);return{loginWithFarcaster:rt((h,...v)=>l(void 0,[h,...v],function*({relyingParty:u,redirectUrl:p,disableSignup:m},w={pollAttempts:10,pollIntervalMs:1e3}){var y;try{if(n.current=!1,S())throw new le({code:"attempted_login_with_farcaster_while_already_logged_in",error:"Already logged in, use `useLinkWithFarcaster` if you are trying to link farcaster to an existing account"});s({status:"generating-uri"});let{connect_uri:b,channel_token:C}=yield r.auth.farcaster.initializeAuth({relyingParty:u,redirectUrl:Oe.createURL(p!=null?p:"/")});if(!b)throw new le({code:"failed_to_generate_farcaster_uri",error:"Failed to generate farcaster uri"});if(!C)throw new le({code:"failed_to_generate_farcaster_channel_token",error:"Failed to generate farcaster channel token"});yield Oe.openURL(b),s({status:"polling-status"});let k=0;for(;k<w.pollAttempts;){if(n.current)throw new le({code:"farcaster_polling_canceled",error:"Farcaster polling canceled"});if(t.current!=="active"&&o()!=="active"){yield J(w.pollIntervalMs);continue}let A=yield r.auth.farcaster.getFarcasterStatus({channel_token:C});if(A.state==="completed"){s({status:"submitting-token"});let P=x(),T=yield r.auth.farcaster.authenticate(_({channel_token:C,mode:m?"no-signup":"login-or-sign-up"},A),{embedded:P==null?void 0:P.embedded});return s({status:"done"}),(y=e==null?void 0:e.onSuccess)==null||y.call(e,T.user,T.is_new_user),T.user}k++,yield J(w.pollIntervalMs)}throw new le({code:"farcaster_polling_timeout",error:"Farcasting polling timed out"})}catch(g){throw a(g)}}),[r,a,e==null?void 0:e.onSuccess,s,t]),state:i,cancel:d}};import{useCallback as ar,useContext as pn}from"react";import{create as mn}from"zustand";import{PrivyClientError as yn}from"@privy-io/js-sdk-core";var ot=mn(()=>({status:"initial"})),V=e=>ot.setState(e,!0),fn=ot.getState,Nl=()=>{let{client:e}=pn(f),t=ot(),o=ar(()=>l(void 0,null,function*(){try{V({status:"fetching-nonce"});let i=yield e.auth.farcasterV2.initializeAuth();return V({status:"awaiting-signature"}),i}catch(i){let s=E(i);throw V({status:"initial",error:s}),s}}),[e]),r=ar(i=>l(void 0,null,function*(){let s=fn().status;try{if(S()){let c=new yn({code:"attempted_login_with_farcaster_while_already_logged_in",error:"Already logged in, use a link helper if you are trying to link farcaster to an existing account"});throw V({status:s,error:c}),c}V({status:"submitting-signature"});let a=x(),d=yield e.auth.farcasterV2.authenticate(i,{embedded:a==null?void 0:a.embedded});return V({status:"done"}),setTimeout(()=>V({status:"initial"}),1500),{user:d.user}}catch(n){let a=E(n);throw V({status:s,error:a}),a}}),[e]);return{init:o,login:r,state:t}};import{useContext as gn,useMemo as hn}from"react";import{delegatedActions as cr}from"@privy-io/js-sdk-core";var ql=()=>{let{client:e}=gn(f);return hn(()=>({delegateWallet:cr.delegateWallet(e),revokeWallets:cr.revokeWallets(e)}),[e])};import{useContext as wn,useMemo as vn}from"react";import{depositAddress as ue}from"@privy-io/js-sdk-core";var Ql=()=>{let{client:e}=wn(f);return vn(()=>({getConfig:()=>ue.getConfig(e),generateDepositAddress:t=>ue.generateDepositAddress(_({privy:e},t)),getDeposit:t=>ue.getDeposit(_({privy:e},t)),waitForDeposit:t=>ue.waitForDeposit(_({privy:e},t)),waitForCompletion:t=>ue.waitForCompletion(_({privy:e},t))}),[e])};import{useContext as bn,useMemo as Sn}from"react";import{cryptoDepositAccount as Le}from"@privy-io/js-sdk-core";var ru=()=>{let{client:e}=bn(f);return Sn(()=>({createCryptoDepositAccount:t=>Le.createCryptoDepositAccount(e,(...o)=>e.embeddedWallet.signWithUserSigner(...o),t),getQuote:t=>Le.getCryptoDepositAccountQuote(e,t),getOrder:t=>Le.getCryptoDepositAccountOrder(e,t),getNextOrder:t=>Le.getCryptoDepositAccountNextOrder(e,t)}),[e])};import{useContext as _n,useMemo as kn}from"react";import{addSessionSigners as Wn,removeSessionSigners as An}from"@privy-io/js-sdk-core";import{isEmbeddedWalletAccount as Cn}from"@privy-io/js-sdk-core";function En(e,t){return e.linked_accounts.filter(Cn).find(o=>o.address===t)}function Y(e){let t=S();if(!t)throw new Error("User must be authenticated to perform this operation");let o=En(t,e);if(!o)throw new Error(`No wallet found with address ${e}`);return o}var uu=()=>{let{client:e}=_n(f);return kn(()=>({addSessionSigners:({address:t,signers:o})=>Wn({client:e,wallet:Y(t),signers:o.map(r=>({signer_id:r.signerId,override_policy_ids:r.policyIds}))}),removeSessionSigners:({address:t})=>An({client:e,wallet:Y(t)})}),[e])};import{useContext as xn,useMemo as Pn}from"react";import{addSessionSigners as Un,removeSessionSigners as Rn}from"@privy-io/js-sdk-core";var hu=()=>{let{client:e}=xn(f);return Pn(()=>({addSigners:({address:t,signers:o})=>Un({client:e,wallet:Y(t),signers:o.map(r=>({signer_id:r.signerId,override_policy_ids:r.policyIds}))}),removeSigners:({address:t})=>Rn({client:e,wallet:Y(t)})}),[e])};import{useContext as In,useMemo as On}from"react";import{PrivyClientError as lr}from"@privy-io/js-sdk-core";var Eu=()=>{let{client:e}=In(f);return On(()=>({sendCode(r){return l(this,arguments,function*({newEmailAddress:o}){dr(),yield e.auth.email.sendCode(o)})},updateEmail(i){return l(this,arguments,function*({newEmailAddress:o,code:r}){let{address:s}=dr(),{user:n}=yield e.auth.email.updateEmail({oldEmailAddress:s,newEmailAddress:o,code:r});return n})}}),[e])};function dr(){let t=Ln().linked_accounts.find(o=>o.type==="email");if(!t)throw new lr({code:"attempted_update_email_without_a_linked_email",error:"Must have a linked email account already to update an email address. Use `useLinkEmail` to link an email account."});return t}function Ln(){let e=S();if(!e)throw new lr({code:"attempted_update_before_logged_in",error:"Must be logged in to update a user profile."});return e}import{useContext as Mn,useMemo as Tn}from"react";import{PrivyClientError as pr}from"@privy-io/js-sdk-core";var Uu=()=>{let{client:e}=Mn(f);return Tn(()=>({sendCode(r){return l(this,arguments,function*({newPhoneNumber:o}){ur(),yield e.auth.phone.sendCode(o)})},updatePhone(i){return l(this,arguments,function*({newPhoneNumber:o,code:r}){let{phoneNumber:s}=ur(),{user:n}=yield e.auth.phone.updatePhone({oldPhoneNumber:s,newPhoneNumber:o,code:r});return n})}}),[e])};function ur(){let t=Fn().linked_accounts.find(o=>o.type==="phone");if(!t)throw new pr({code:"attempted_update_phone_without_a_linked_phone",error:"Must have a linked phone account already to update a phone number. Use `useLinkSMS` to link a phone number."});return t}function Fn(){let e=S();if(!e)throw new pr({code:"attempted_update_before_logged_in",error:"Must be logged in to update a user profile."});return e}import*as fr from"expo-linking";import{useCallback as Nn,useContext as jn,useMemo as zn}from"react";import{crossApp as Vn,PrivyClientError as Gn}from"@privy-io/js-sdk-core";import*as yr from"expo-linking";import*as pe from"expo-web-browser";import{PrivyClientError as mr}from"@privy-io/js-sdk-core";var j=(e,t)=>l(void 0,null,function*(){let o=yield pe.openAuthSessionAsync(e,t,{createTask:!1});if(o.type!=="success")throw o.type===pe.WebBrowserResultType.CANCEL||o.type===pe.WebBrowserResultType.DISMISS?new mr({error:"OAuth session was cancelled",code:"oauth_session_failed"}):new mr({error:"OAuth session failed",code:"oauth_session_failed"});return Dn(o.url)});function Dn(e){let{queryParams:t}=yr.parse(e);return t}var Vu=()=>{let{client:e}=jn(f),t=zn(()=>Vn.loginWithCrossAppAuth({client:e,openAuthSession:j}),[e]);return{loginWithCrossApp:Nn(s=>l(void 0,[s],function*({appId:r,redirectUri:i}){if(S())throw new Gn({code:"attempted_login_with_cross_app_while_already_logged_in",error:"Already logged in, use `linkCrossAppAccount` if you are trying to link a cross app account to an existing account"});let a=x(),{user:d}=yield t({providerAppId:r,redirectUrl:fr.createURL(i||"/"),loginOptions:{embedded:a==null?void 0:a.embedded}});return{user:d}}),[t])}};import*as gr from"expo-linking";import{useCallback as Kn,useContext as qn,useMemo as Bn}from"react";import{crossApp as Hn,PrivyClientError as Jn}from"@privy-io/js-sdk-core";var Qu=()=>{let{client:e}=qn(f),t=Bn(()=>Hn.linkWithCrossAppAuth({client:e,openAuthSession:j}),[e]);return{linkWithCrossApp:Kn(s=>l(void 0,[s],function*({appId:r,redirectUri:i}){if(!S())throw new Jn({code:"attempted_link_cross_app_before_logged_in",error:"Must be logged in to link a cross app account, Use `loginWithCrossAppAccount` to login with cross app"});return{user:yield t({providerAppId:r,redirectUrl:gr.createURL(i||"/")})}}),[t])}};import*as wr from"expo-linking";import{useContext as $n,useMemo as hr}from"react";import{crossApp as Qn}from"@privy-io/js-sdk-core";var np=()=>{let{client:e}=$n(f),t=hr(()=>Qn.wallet.signMessage({client:e,openAuthSession:j}),[e]);return hr(()=>({signMessage:({address:o,message:r,redirectUri:i="/"})=>t({user:S(),address:o,message:r,redirectUrl:wr.createURL(i)})}),[t])};import*as br from"expo-linking";import{useContext as Yn,useMemo as vr}from"react";import{crossApp as Xn}from"@privy-io/js-sdk-core";var up=()=>{let{client:e}=Yn(f),t=vr(()=>Xn.wallet.signTypedData({client:e,openAuthSession:j}),[e]);return vr(()=>({signTypedData:({address:o,typedData:r,redirectUri:i="/"})=>t({user:S(),address:o,typedData:r,redirectUrl:br.createURL(i)})}),[t])};import*as Cr from"expo-linking";import{useContext as Zn,useMemo as Sr}from"react";import{crossApp as ei}from"@privy-io/js-sdk-core";var wp=()=>{let{client:e}=Zn(f),t=Sr(()=>ei.wallet.sendTransaction({client:e,openAuthSession:j}),[e]);return Sr(()=>({sendTransaction:({address:o,transaction:r,redirectUri:i="/"})=>t({user:S(),address:o,transaction:r,redirectUrl:Cr.createURL(i)})}),[t])};import{useCallback as ti,useContext as ri}from"react";import{getUserEmbeddedEthereumWallet as oi,getUserEmbeddedSolanaWallet as ni,isUnifiedWallet as ii,PrivyClientError as X,throwIfInvalidRecoveryUpgradePath as si}from"@privy-io/js-sdk-core";var Wp=()=>{let{client:e}=ri(f);return{setRecovery:ti(o=>l(void 0,null,function*(){var a;let r=S(),i=e.app.appId;if(!r)throw new X({code:"embedded_wallet_recovery_error",error:"User must be loaded before attempting to modify the recovery method."});let s=(a=oi(r))!=null?a:ni(r);if(!s)throw new X({code:"embedded_wallet_does_not_exist",error:"Embedded wallet does not exist"});if(ii(s))throw new X({code:"unsupported_wallet_type",error:"Embedded wallet recovery is only supported for on-device execution and this app uses TEE execution. Learn more https://docs.privy.io/recipes/tee-wallet-migration-guide"});try{s.chain_type==="ethereum"?yield e.embeddedWallet.getProvider(s):s.chain_type==="solana"&&(yield e.embeddedWallet.getSolanaProvider(s,s.address,"solana-address-verifier"))}catch(d){throw new X({code:"attempted_to_set_password_before_connected",error:"Embedded wallet must be connected before setting password"})}si({currentRecoveryMethod:s.recovery_method,upgradeToRecoveryMethod:o.recoveryMethod});let n=yield ai({appId:i,client:e,user:r,primaryAccount:s,recoveryParams:o});try{let{user:d}=yield e.embeddedWallet.setRecovery(n);return{user:d}}catch(d){throw new X({code:"embedded_wallet_set_recovery_error",error:d instanceof Error?d.message:"Error setting password on embedded wallet"})}}),[e])}},ai=s=>l(void 0,[s],function*({appId:e,client:t,user:o,primaryAccount:r,recoveryParams:i}){switch(i.recoveryMethod){case"privy":return{recoveryMethod:"privy",wallet:r};case"user-passcode":return M(_({},i),{wallet:r});case"google-drive":{let n=yield Ue(t);return{recoveryMethod:"google-drive",wallet:r,recoveryAccessToken:n}}case"icloud":{let{recoverySecret:n,iCloudRecordName:a}=yield se({appId:e,client:t,user:o});return{recoveryMethod:"icloud-native",recoverySecretOverride:n,iCloudRecordNameOverride:a,wallet:r}}case"recovery-encryption-key":return{recoveryMethod:"recovery-encryption-key",wallet:r,recoveryKey:i.recoveryKey};default:throw new X({code:"embedded_wallet_recovery_error",error:"Unrecognized recovery method"})}});import{useCallback as ci,useContext as di}from"react";import{getUserEmbeddedEthereumWallet as li,getUserEmbeddedSolanaWallet as ui,PrivyClientError as me,isUnifiedWallet as pi}from"@privy-io/js-sdk-core";var Mp=()=>{let{client:e}=di(f);return{recover:ci(o=>l(void 0,null,function*(){var c;let r=S();if(!r)throw new me({code:"embedded_wallet_recovery_error",error:"User must be loaded before attempting to modify the recovery method."});let i=(c=li(r))!=null?c:ui(r);if(!i)throw new me({code:"embedded_wallet_does_not_exist",error:"Embedded wallet does not exist"});if(pi(i))throw new me({code:"unsupported_wallet_type",error:"User owned wallet recovery is only supported for on-device execution and this app uses TEE execution. Learn more https://docs.privy.io/recipes/tee-wallet-migration-guide"});let s,n,a,d;switch(o.recoveryMethod){case"user-passcode":n=o.password;break;case"google-drive":a=yield Ue(e);break;case"icloud":let{recoverySecret:u}=yield Ae({client:e,walletAddress:i.address,chainType:i.chain_type});d=u;break;case"recovery-encryption-key":s=o.recoveryKey;break;case"privy":break;default:throw new me({code:"unsupported_recovery_method",error:`Unsupported recovery options ${o}`})}try{i.chain_type==="ethereum"?yield e.embeddedWallet.getProvider(i,n,a,d,s):i.chain_type==="solana"&&(yield e.embeddedWallet.getSolanaProvider(i,i.address,"solana-address-verifier",n,a,d))}catch(u){throw new me({code:"attempted_to_set_password_before_connected",error:"Embedded wallet must be connected before setting password"})}}),[e])}};import{useEffect as yi}from"react";import{useContext as mi,useEffect as nt}from"react";var it=(e={})=>{let{wallet:t,createWalletCallbacks:o,recoverWalletCallbacks:r,setWalletRecoveryCallbacks:i}=mi(f),{onCreateWalletSuccess:s,onCreateWalletError:n,onRecoverWalletError:a,onRecoverWalletSuccess:d,onSetWalletRecoverySuccess:c,onSetWalletRecoveryError:u}=e;return nt(()=>{o.current={onSuccess:s,onError:n}},[s,n]),nt(()=>{r.current={onSuccess:d,onError:a}},[d,a]),nt(()=>{i.current={onSuccess:c,onError:u}},[d,a]),t};var Gp=({onStateChange:e})=>{let t=it();return yi(()=>{e(t)},[t])};import{useContext as fi}from"react";var Hp=()=>{let{getIdentityToken:e}=fi(f);return{getIdentityToken:e}};import{useCallback as Er,useContext as gi}from"react";import{PrivyClientError as hi}from"@privy-io/js-sdk-core";var tm=e=>{let{client:t}=gi(f),o=Er(i=>{var n;let s=E(i);return(n=e==null?void 0:e.onError)==null||n.call(e,s),s},[e==null?void 0:e.onError]);return{create:Er(()=>l(void 0,null,function*(){var i;try{if(S())throw new hi({code:"attempted_to_create_guest_account_for_logged_in_user",error:"Already logged in, you cannot create a guest account"});let n=x(),a=yield t.auth.guest.create({embedded:n==null?void 0:n.embedded});return(i=e==null?void 0:e.onSuccess)==null||i.call(e,a.user,a.is_new_user),a.user}catch(s){throw o(s)}}),[t,o,e==null?void 0:e.onSuccess])}};import{useContext as wi,useEffect as vi}from"react";function am({onMfaRequired:e}){let{client:t}=wi(f);vi(()=>{function o(){return l(this,null,function*(){var i;let r=S();yield e((i=r==null?void 0:r.mfa_methods.map(({type:s})=>s).filter(s=>s!=="email"))!=null?i:[])})}return t.mfaPromises.on("mfaRequired",o),()=>{t.mfaPromises.off("mfaRequired",o)}},[t,e])}import{useCallback as ye,useContext as Wi}from"react";import{PrivyClientError as Te}from"@privy-io/js-sdk-core";import{PrivyClientError as bi}from"@privy-io/js-sdk-core";function Me(){return l(this,null,function*(){We("react-native-passkeys");try{return yield import("react-native-passkeys")}catch(e){return Promise.reject(e)}})}var Si=(e,t)=>l(void 0,null,function*(){var i;let r=yield(yield Me()).create(Ci(e,t));if(!r)throw new bi({code:"failed_to_create_passkey",error:"Could not create passkey"});return M(_({},r),{type:(i=r.type)!=null?i:"public-key",clientExtensionResults:{}})});function Ci(e,t){return M(_({},t),{rp:e.rp,user:e.user,challenge:e.challenge,pubKeyCredParams:e.pubKeyCredParams,excludeCredentials:e.excludeCredentials,authenticatorSelection:e.authenticatorSelection,timeout:12e4,attestation:void 0})}import{PrivyClientError as Ei}from"@privy-io/js-sdk-core";var at=(e,t)=>l(void 0,null,function*(){var i;let r=yield(yield Me()).get(_i(e,t));if(!r)throw new Ei({code:"no_passkey_found_for_challenge",error:"Could not find a matching passkey to login with"});return M(_({},r),{type:(i=r.type)!=null?i:"public-key",clientExtensionResults:{}})});function _i(e,t){return M(_({},t),{rpId:e.rpId,challenge:e.challenge,allowCredentials:e.allowCredentials,userVerification:e.userVerification,timeout:12e4})}function _r(e){var t;return{id:e.id,client_extension_results:{app_id:e.clientExtensionResults.appid,cred_props:e.clientExtensionResults.credProps,hmac_create_secret:e.clientExtensionResults.hmacCreateSecret},raw_id:e.rawId,type:e.type,authenticator_attachment:(t=e.authenticatorAttachment)!=null?t:"platform",response:{authenticator_data:e.response.authenticatorData,client_data_json:e.response.clientDataJSON,signature:e.response.signature,user_handle:e.response.userHandle}}}function kr(e){var t,o,r,i;return{challenge:e.challenge,rpId:e.rp_id,extensions:{appid:(t=e.extensions)==null?void 0:t.app_id,credProps:(o=e.extensions)==null?void 0:o.cred_props,hmacCreateSecret:(r=e.extensions)==null?void 0:r.hmac_create_secret},timeout:e.timeout,allowCredentials:(i=e.allow_credentials)==null?void 0:i.map(({id:s,type:n,transports:a})=>({id:s,type:n,transports:a})),userVerification:e.user_verification}}function Wm(e){var t,o,r,i,s,n,a,d;return{rp:e.rp,user:{id:e.user.id,name:e.user.name,displayName:e.user.display_name},challenge:e.challenge,pubKeyCredParams:e.pub_key_cred_params,extensions:{hmacCreateSecret:(t=e.extensions)==null?void 0:t.hmac_create_secret,credProps:(r=(o=e.extensions)==null?void 0:o.cred_props)==null?void 0:r.rk,appid:(i=e.extensions)==null?void 0:i.app_id},attestation:e.attestation,excludeCredentials:e.exclude_credentials,authenticatorSelection:{authenticatorAttachment:(s=e.authenticator_selection)==null?void 0:s.authenticator_attachment,residentKey:(n=e.authenticator_selection)==null?void 0:n.resident_key,userVerification:(a=e.authenticator_selection)==null?void 0:a.user_verification,requireResidentKey:(d=e.authenticator_selection)==null?void 0:d.require_resident_key}}}function Im(){let{client:e}=Wi(f),t=ye(n=>l(this,null,function*(){var a,d;switch(n.method){case"sms":yield e.mfa.sms.sendCode({action:"verify"});return;case"passkey":let{options:c}=yield e.mfa.passkey.generateAuthenticationOptions({relying_party:n.relyingParty||((d=(a=x())==null?void 0:a.mfa)==null?void 0:d.relyingParty)});return kr(c);case"totp":return;default:throw new Error(`Unsupported MFA method: ${n.mfaMethod}`)}}),[e]),o=ye(n=>l(this,null,function*(){var a,d,c,u,p,m,w;switch(n.method){case"totp":case"sms":if(typeof n.mfaCode!="string")throw new Te({code:"invalid_mfa_code",error:"Invalid MFA code"});(c=e.mfaPromises.rootPromise.current)==null||c.resolve({mfaMethod:n.method,mfaCode:n.mfaCode,relyingParty:n.relyingParty||((d=(a=x())==null?void 0:a.mfa)==null?void 0:d.relyingParty)||""}),yield new Promise((g,b)=>{e.mfaPromises.submitPromise.current={resolve:g,reject:b}});break;case"passkey":if(typeof n.mfaCode=="string")throw new Te({code:"invalid_passkey_response",error:"Invalid authenticator response"});let h=yield at(n.mfaCode),v=_r(h);(m=e.mfaPromises.rootPromise.current)==null||m.resolve({mfaMethod:n.method,relyingParty:n.relyingParty||((p=(u=x())==null?void 0:u.mfa)==null?void 0:p.relyingParty)||"",mfaCode:v}),yield new Promise((g,b)=>{e.mfaPromises.submitPromise.current={resolve:g,reject:b}});break;default:let y=new Te({code:"unsupported_mfa_method",error:"Unsupported MFA method"});throw(w=e.mfaPromises.rootPromise.current)==null||w.reject(y),y}}),[e]),r=ye(()=>l(this,null,function*(){let n=S();!n||n.mfa_methods.length===0||(yield e.mfa.verifyMfa())}),[e]),i=ye(()=>{var n;(n=e.mfaPromises.rootPromise.current)==null||n.reject(new Te({code:"mfa_canceled",error:"MFA canceled"}))},[e]),s=ye(()=>l(this,null,function*(){let n=S();n&&(yield e.mfa.clearMfa({userId:n.id}))}),[e]);return{init:t,submit:o,prompt:r,cancel:i,clear:s}}import{useCallback as ct,useContext as Ai}from"react";function Fm(){let{client:e}=Ai(f),t=ct(i=>l(this,null,function*(){switch(i.method){case"sms":case"totp":return yield e.mfa.initEnrollMfa(i);case"passkey":return;default:throw new Error(`Unsupported MFA method: ${i.method}`)}}),[e]),o=ct(i=>l(this,null,function*(){switch(i.method){case"sms":case"totp":case"passkey":yield e.mfa.submitEnrollMfa(i);return;default:throw new Error(`Unsupported MFA method: ${i.method}`)}}),[e]),r=ct(i=>l(this,null,function*(){switch(i.method){case"sms":case"totp":yield e.mfa.unenrollMfa(i.method);return;case"passkey":yield e.mfa.submitEnrollMfa({method:"passkey",credentialIds:[],removeForLogin:i.removeForLogin});return;default:throw new Error(`Unsupported MFA method: ${i.method}`)}}),[e]);return{initMfaEnrollment:t,submitMfaEnrollment:o,unenrollMfa:r}}import{useCallback as xi,useContext as Pi}from"react";function Vm(){let{client:e}=Pi(f);return{unlink:xi(i=>l(this,[i],function*({credentialId:o,removeAsMfa:r}){yield e.mfa.unlinkPasskey({credentialId:o,removeAsMfa:r})}),[e])}}import{useCallback as Ui}from"react";import{areAddressesEqual as Ri}from"@privy-io/are-addresses-equal";import{getAllUserEmbeddedEthereumWallets as Ii,getAllUserEmbeddedSolanaWallets as Oi,PrivyClientError as Li}from"@privy-io/js-sdk-core";var $m=()=>{let e=W();return{importWallet:Ui(s=>l(void 0,[s],function*({privateKey:o,chainType:r,additionalSigners:i}){let{address:n,user:a}=yield e.embeddedWallet.importWallet({privateKey:o,chainType:r,additionalSigners:i}),c=(r==="solana"?Oi(a.user):Ii(a.user)).find(u=>Ri(u.address,n));if(!c)throw new Li({code:"embedded_wallet_creation_error",error:"Failed to import wallet"});return{user:a.user,wallet:c}}),[e])}};import{useCallback as Mi,useMemo as Wr}from"react";import{getAllUserEmbeddedEthereumWallets as Fe,getEntropyDetailsFromUser as Ar,getUserEmbeddedSolanaWallet as Ti,PrivyClientError as dt}from"@privy-io/js-sdk-core";var lt=()=>{let e=U(),t=W(),o=Wr(()=>{let s=Fe(e).map(n=>{let a=Ar(e,n);return a?{account:n,entropy:a}:null});return s.some(n=>n===null)?[]:s.filter(n=>n!==null).map(({account:n,entropy:{entropyId:a,entropyIdVerifier:d}})=>({address:n.address,walletIndex:n.wallet_index,chainType:n.chain_type,getProvider:()=>t.embeddedWallet.getEthereumProvider({wallet:n,entropyId:a,entropyIdVerifier:d,onNeedsRecovery:c=>l(void 0,null,function*(){var u;yield(u=be())==null?void 0:u(c)})})}))},[t,e]),r=Mi((...s)=>l(void 0,[...s],function*({createAdditional:i=!1}={}){var p,m,w;let{user:n}=yield t.user.get(),a=Fe(n);if(!i&&a.length>0)throw new dt({code:"embedded_wallet_creation_error",error:"Wallet already exists for this user. Set `createAdditional` to `true` to create another wallet"});if(a.length===0){let h=(p=Ti(n))!=null?p:void 0,v=yield t.embeddedWallet.create(h?{solanaAccount:h}:{});return Fi(v.user),{user:v.user}}let d=Ar(n),c=a.map(h=>h.wallet_index).reduce((h,v)=>Math.max(h,v),0)+1,u=yield t.embeddedWallet.add({chainType:"ethereum",hdWalletIndex:c,entropyId:(m=d==null?void 0:d.entropyId)!=null?m:"",entropyIdVerifier:(w=d==null?void 0:d.entropyIdVerifier)!=null?w:"ethereum-address-verifier"});if(Fe(u.user).length<=a.length)throw new dt({code:"embedded_wallet_creation_error",error:"Unknown error creating wallet"});return{user:u.user}}),[t]);return Wr(()=>({wallets:o,create:r}),[o,r])};function Fi(e){if(!e||Fe(e).length===0)throw new dt({code:"embedded_wallet_creation_error",error:"Unknown error creating wallet"})}import{useContext as Di,useEffect as xr}from"react";var Ni=(e={})=>{let{solanaWallet:t,createSolanaWalletCallbacks:o,recoverSolanaWalletCallbacks:r}=Di(f),{onCreateWalletSuccess:i,onCreateWalletError:s,onRecoverWalletError:n,onRecoverWalletSuccess:a}=e;return xr(()=>{o.current={onSuccess:i,onError:s}},[i,s]),xr(()=>{r.current={onSuccess:a,onError:n}},[a,n]),t};import{useCallback as ji,useMemo as zi}from"react";import{getAllUserEmbeddedBitcoinWallets as ut,getEntropyDetailsFromUser as Pr,isUnifiedWallet as Vi,PrivyClientError as Z}from"@privy-io/js-sdk-core";var Gi=()=>{let e=U(),t=W(),o=zi(()=>{let i=Pr(e);if(!i)return[];let s=ut(e),{entropyId:n,entropyIdVerifier:a}=i;return s.map(d=>({address:d.address,walletIndex:d.wallet_index,publicKey:d.public_key,chainType:d.chain_type,getProvider:()=>Vi(d)?Promise.reject(new Z({code:"unsupported_wallet_type",error:"Bitcoin wallet providers are only supported for on-device execution and this app uses TEE execution. Use the useSignRawHash hook from @privy-io/expo/extended-chains to sign over a hash with this wallet. Learn more at https://docs.privy.io/recipes/tee-wallet-migration-guide"})):t.embeddedWallet.getBitcoinProvider({wallet:d,entropyId:n,entropyIdVerifier:a})}))},[t,e]),r=ji(n=>l(void 0,[n],function*({chainType:i,createAdditional:s=!1}){var y;let a=t.app.getConfig();if(((y=a==null?void 0:a.embedded_wallet_config)==null?void 0:y.mode)==="user-controlled-server-wallets-only")throw i==="bitcoin-segwit"?new Z({code:"unsupported_wallet_type",error:"This app uses TEE execution. Use the useCreateWallet hook from @privy-io/expo/extended-chains to create the wallet instead. Learn more https://docs.privy.io/recipes/tee-wallet-migration-guide"}):new Z({code:"unsupported_wallet_type",error:`Bitcoin (${i}) wallets are only supported for on-device execution and this app uses TEE execution. Learn more https://docs.privy.io/recipes/tee-wallet-migration-guide`});let{user:d}=yield t.user.get(),c=Pr(d);if(!c)throw new Z({code:"embedded_wallet_creation_error",error:"No existing wallet for this user, create an Ethereum walet first to add a Bitcoin wallet"});let{entropyId:u,entropyIdVerifier:p}=c,m=ut(d).filter(g=>g.chain_type===i);if(!s&&m.length>0)throw new Z({code:"embedded_wallet_creation_error",error:"Wallet already exists for this user. Set `createAdditional` to `true` to create another wallet"});let w=m.length===0?0:Math.max(...m.map(g=>g.wallet_index),0)+1,h=yield t.embeddedWallet.add({chainType:i,hdWalletIndex:w,entropyId:u,entropyIdVerifier:p}),v=ut(h.user).find(g=>g.chain_type===i&&g.wallet_index===w);if(!h.user||!v)throw new Z({code:"embedded_wallet_creation_error",error:"Unknown error creating wallet"});return{user:h.user,provider:yield t.embeddedWallet.getBitcoinProvider({wallet:v,entropyId:u,entropyIdVerifier:p})}}),[t]);return{wallets:o,create:r}};import{useContext as Ki}from"react";var pt=()=>{let{isReady:e,logout:t,getAccessToken:o,error:r,client:i}=Ki(f);return{user:U(),isReady:e,error:r,logout:t,getAccessToken:o,refreshUser:()=>i.user.refreshUser()}};import{useContext as qi}from"react";function Bi(){let{client:e}=qi(f);return{acceptTerms:()=>l(this,null,function*(){return e.user.acceptTerms()})}}import{useMemo as Hi}from"react";import{generateAuthorizationSignature as Ji}from"@privy-io/js-sdk-core";var $i=()=>{let e=W();return Hi(()=>({generateAuthorizationSignature(o){return l(this,null,function*(){let{signature:r}=yield Ji((...i)=>e.embeddedWallet.signWithUserSigner(...i),o);return{signature:r}})}}),[e])};import{useContext as Qi,useMemo as Yi}from"react";import{GetEncryptedAuthorizationKey as Xi}from"@privy-io/routes";var Uy=()=>{let{client:e}=Qi(f);return Yi(()=>({getEncryptedAuthorizationKey:({id:t})=>e.fetchPrivyRoute(Xi,{params:{encrypted_authorization_key_id:t}})}),[e])};import{useCallback as Zi}from"react";import{createWalletClient as es,getAddress as Ur,http as ts,parseSignature as rs,zeroAddress as os}from"viem";import{hashAuthorization as ns}from"viem/utils";import{getAllUserEmbeddedEthereumWallets as is,getJsonRpcEndpointFromChain as ss}from"@privy-io/js-sdk-core";var as=()=>{let e=U(),{wallets:t}=lt(),o=W();return{signAuthorization:Zi((i,s)=>l(void 0,null,function*(){var p,m,w;if(!e)throw new Error("User must be authenticated before signing with a Privy wallet");let n=(w=(m=s==null?void 0:s.address)!=null?m:(p=is(e)[0])==null?void 0:p.address)!=null?w:os,a=t.find(h=>Ur(h.address)===Ur(n));if(!a)throw new Error("Signing wallet not found.");let d;if(i.chainId===0){if(i.nonce===void 0)throw new Error("nonce is required when chainId is 0 \u2014 chain-agnostic authorizations are replayable across networks");d={chainId:0,address:i.contractAddress,nonce:i.nonce}}else{let v=o.embeddedWallet.chains.find(b=>b.id===i.chainId);if(!v)throw new Error("Error, chain not configured in PrivyProvider config");let y=ss(v,{},o.app.appId);d=yield es({account:n,chain:v,transport:ts(y)}).prepareAuthorization(_({},i))}let u=yield(yield a.getProvider()).request({method:"secp256k1_sign",params:[ns(d)]});return _(_({},d),rs(u))}),[t,e,o])}};import{useMemo as cs}from"react";import{transfer as ds}from"@privy-io/js-sdk-core";var ls=()=>{let e=W();return cs(()=>({transfer:(t,o)=>ds(e,(...r)=>e.embeddedWallet.signWithUserSigner(...r),_({wallet_id:t},o))}),[e])};import{useMemo as us}from"react";import{PrivyClientError as ps,updateWallet as ms}from"@privy-io/js-sdk-core";var ys=()=>{let e=W();return us(()=>({updateWallet:(t,o)=>l(void 0,null,function*(){yield ms(e,{wallet_id:t},(...s)=>e.embeddedWallet.signWithUserSigner(...s),o);let{user:r}=yield e.user.refreshUser(),i=r==null?void 0:r.linked_accounts.find(s=>s.type==="wallet"&&"id"in s&&s.id===t);if(!i)throw new ps({code:"embedded_wallet_does_not_exist",error:"Updated wallet was not found in the refreshed user."});return{wallet:i}})}),[e])};import{useMemo as fs}from"react";import{getWalletAction as gs,listWalletActions as hs}from"@privy-io/js-sdk-core";var ws=()=>{let e=W();return fs(()=>({getAction:(t,o)=>gs(e,{wallet_id:t,action_id:o}),listActions:(t,o)=>hs(e,_({wallet_id:t},o))}),[e])};import{useMemo as vs}from"react";var bs=()=>{let e=Pt();return vs(()=>({users:e}),[e])};import{useMemo as Ss}from"react";var Cs=()=>{let e=W();return Ss(()=>({switchUser:o=>l(void 0,[o],function*({userId:t}){return yield e.user.switchActiveUser({userId:t})})}),[e])};import{useCallback as As}from"react";import{PrivyClientError as xs}from"@privy-io/js-sdk-core";import{getAllUserEmbeddedBitcoinWallets as Es,getUserEmbeddedEthereumWallet as _s,getUserEmbeddedSolanaWallet as ks,isEmbeddedWalletAccount as Ws,isUnifiedWallet as Rr}from"@privy-io/js-sdk-core";function Ir(e,t){return l(this,null,function*(){var i,s;let o=t.linked_accounts.filter(Ws).filter(n=>!n.imported&&!Rr(n)).filter(n=>n.chain_type==="ethereum"||n.chain_type==="solana"),r=(i=o.find(n=>n.chain_type==="ethereum"&&n.wallet_index===0))!=null?i:o.find(n=>n.chain_type==="solana"&&n.wallet_index===0);if(!r){let n=(s=_s(t))!=null?s:ks(t);if(n!=null&&n.imported&&!Rr(n))throw new Error("Imported wallets cannot be migrated");return{success:!0,migrated:!1}}if(Es(t).length>0)throw new Error("Bitcoin wallets cannot be migrated");return r.chain_type==="ethereum"?yield e.embeddedWallet.getProvider(r):r.chain_type==="solana"&&(yield e.embeddedWallet.getSolanaProvider(r,r.address,"solana-address-verifier")),yield e.embeddedWallet.delegateWallets({rootWallet:{address:r.address,chainType:r.chain_type,imported:r.imported},delegatedWallets:o.map(n=>({address:n.address,chainType:n.chain_type,walletIndex:n.wallet_index}))}),yield e.user.get(),{success:!0,migrated:!0}})}var Or=()=>{let e=W();return{migrate:As(()=>l(void 0,null,function*(){var s;let o=S(),r=e.app.getConfig();if(((s=r==null?void 0:r.embedded_wallet_config)==null?void 0:s.mode)!=="user-controlled-server-wallets-only")return{success:!0};if(!o)throw new xs({code:"embedded_wallet_before_logged_in",error:"User must be authenticated before migrating wallets"});return Ir(e,o)}),[e])}};var Lr=({disabled:e})=>{let{migrate:t}=Or(),{user:o}=pt(),r=Us(!1);return Ps(()=>{e||o&&(r.current||(r.current=!0,t().then(i=>{i.migrated&&!r.current&&(console.info("Migrated wallets for user"),r.current=!0)}).catch(i=>{console.debug("Unable to migrate wallets: ",i)}).finally(()=>{r.current=!1})))},[t,o,e]),null};var f=Is(null),te;function Fg(e){return te?te.getAccessToken():e!=null&&e.strict?Promise.reject(new Fr({code:"attempted_to_read_storage_before_client_initialized",error:"Called `getAccessToken` before client initialized"})):(console.warn("Called `getAccessToken` before client initialized"),Promise.resolve(null))}var Dg=e=>{var gt,ht,wt;Ms();let[t,o]=L(Tr.currentState==="active");Mr(()=>{let O=Tr.addEventListener("change",qr=>{o(qr==="active")});return()=>{O.remove()}},[]),Mr(()=>kt(e.config),[e.config]);let[r,i]=L(!1),[s,n]=L(null),[a,d]=L(!1),[c,u]=L({status:"disconnected",account:null}),[p,m]=L({status:"disconnected"}),[w,h]=L({status:"initial"}),[v,y]=L({status:"initial"}),[g,b]=L({status:"initial"}),[C,k]=L({status:"initial"}),[A,P]=L({status:"initial"}),[T,ge]=L({status:"initial"}),[he,Ne]=L({status:"initial"}),re=fe({}),je=fe({}),ze=fe({}),yt=fe({}),ft=fe({}),we=De(O=>{if(O){Ge(O),n(null);return}Ge(null),h({status:"initial"}),y({status:"initial"}),u({status:"disconnected",account:null})},[]),I=Rs(()=>{let O=e.storage||ve;return e.client?te=e.client:te=_t({appId:e.appId,clientId:e.clientId,supportedChains:e.supportedChains,storage:O,baseUrl:e.baseUrl,logLevel:e.logLevel}),te.setCallbacks({setUser:we,setIsReady:d,setStoredUsers:xt}),te},[e.client,e.storage,e.appId,e.clientId,e.baseUrl,e.supportedChains,e.logLevel,we]),Dr=De(()=>l(void 0,null,function*(){let O=S();yield I.auth.logout(O?{userId:O==null?void 0:O.id}:void 0),we(null)}),[we,I]),Nr=De(()=>l(void 0,null,function*(){try{return yield I.getAccessToken()}catch(O){return console.debug(O),null}}),[I]),jr=De(()=>I.getIdentityToken(),[I]);Yt({client:I,isUserInitialized:r,setIsUserInitialized:i,setError:n});let zr=Bt({client:I,appId:e.appId,createWalletCallbacks:re,recoverWalletCallbacks:je,setWalletRecoveryCallbacks:ze,setRecoveryFlowState:b,wallet:c,setWallet:u}),Vr=Ft({client:I,createSolanaWalletCallbacks:yt,recoverSolanaWalletCallbacks:ft,setSolanaRecoveryFlowState:k,solanaWallet:p,setSolanaWallet:m});$t({client:I,createWalletCallbacks:re,recoverWalletCallbacks:je,setWalletRecoveryCallbacks:ze,recoveryFlowState:g,oAuthState:v,setRecoveryFlowState:b,setWallet:u,appStateVisible:t});let{customAuthStateIsSettled:Gr}=Jt({client:I,isReady:r}),Kr=z();return ee.createElement(ee.Fragment,null,ee.createElement(f.Provider,{value:{client:I,isReady:Kr&&r&&Gr,error:s,logout:Dr,getAccessToken:Nr,getIdentityToken:jr,wallet:_(_({},c),zr),solanaWallet:_(_({},p),Vr),oAuthState:v,recoveryFlowState:g,setRecoveryFlowState:b,solanaRecoveryFlowState:C,setSolanaRecoveryFlowState:k,createWalletCallbacks:re,recoverWalletCallbacks:je,setWalletRecoveryCallbacks:ze,createSolanaWalletCallbacks:yt,recoverSolanaWalletCallbacks:ft,setOAuthState:y,siweState:A,setSiweState:P,otpState:w,setOtpState:h,passkeyState:T,setPasskeyState:ge,farcasterState:he,setFarcasterState:Ne}},e.children,ee.createElement(Lr,{disabled:(wt=(ht=(gt=e.config)==null?void 0:gt.embedded)==null?void 0:ht.disableAutomaticMigration)!=null?wt:!1})),ee.createElement(Ls,{style:{width:0,height:0,overflow:"hidden"}},ee.createElement(Rt,{client:I,isClientReady:a})))},Ms=()=>{if(Os(f))throw new Fr({code:"configuration_error",error:"Found multiple instances of PrivyProvider, ensure there is only one mounted in your application tree."})};var Bg=e=>{let{client:t,setSiweState:o,siweState:r}=Ts(f),i=mt(a=>{var c;let d=E(a);return o({status:"error",error:d}),(c=e==null?void 0:e.onError)==null||c.call(e,d),d},[e==null?void 0:e.onError]),s=mt(u=>l(void 0,[u],function*({wallet:a,from:{domain:d,uri:c}}){var p;try{o({status:"generating-message"});let m=yield t.auth.siwe.init(a,d,c);return o({status:"awaiting-signature"}),(p=e==null?void 0:e.onGenerateMessage)==null||p.call(e,m.message),m.message}catch(m){throw i(m)}}),[t,i,e==null?void 0:e.onGenerateMessage]),n=mt(c=>l(void 0,[c],function*({signature:a,messageOverride:d}){var u;try{if(!S())throw new Fs({code:"attempted_link_siwe_before_logged_in",error:"Must be logged in to link a wallet, Use `useLoginWithSiwe` to login with a wallet"});o({status:"submitting-signature"});let{user:m}=yield t.auth.siwe.linkWithSiwe(a,void 0,d);return o({status:"done"}),(u=e==null?void 0:e.onSuccess)==null||u.call(e,m),m}catch(p){throw i(p)}}),[t,i,e==null?void 0:e.onSuccess]);return{generateSiweMessage:s,linkWithSiwe:n,state:r}};export{x as a,S as b,ea as c,U as d,ta as e,Jr as f,We as g,E as h,J as i,_t as j,Bg as k,Bc as l,W as m,od as n,pd as o,bd as p,xd as q,Ld as r,Gd as s,Yd as t,sl as u,yl as v,bl as w,Pl as x,Nl as y,ql as z,Ql as A,ru as B,uu as C,hu as D,Eu as E,Uu as F,Vu as G,Qu as H,np as I,up as J,wp as K,Wp as L,Mp as M,it as N,Gp as O,Hp as P,tm as Q,am as R,Si as S,at as T,Wm as U,Im as V,Fm as W,Vm as X,$m as Y,lt as Z,Ni as _,Gi as $,pt as aa,Bi as ba,$i as ca,Uy as da,as as ea,ls as fa,ys as ga,ws as ha,bs as ia,Cs as ja,Or as ka,f as la,Fg as ma,Dg as na};
12
+ If these requirements cannot be met, keep ${e} installed.`:d+`Expo SDK 52 and React Native 0.78 or earlier cannot safely omit ${e}. Upgrade to Expo SDK 54 or React Native 0.81, or keep ${e} installed.`;Nt.add(e),r(c)}function zt(){return l(this,null,function*(){We("@privy-io/expo-native-extensions");try{return yield import("@privy-io/expo-native-extensions")}catch(e){throw new N({code:"configuration_error",error:"`@privy-io/expo-native-extensions` is not installed. Install it and rebuild the native app."})}})}function se(r){return l(this,arguments,function*({user:e,appId:t,client:o}){var a;if(jt.OS==="android")throw new N({code:"embedded_wallet_recovery_error",error:"iCloud recovery is not supported on Android"});let i=yield zt(),s=yield o.recovery.icloudAuth.getICloudConfiguration("expo-ios");if(!(s==null?void 0:s.container_identifier))throw new N({code:"embedded_wallet_recovery_error",error:"An iCloud Container ID must be specified in the Privy Dashboard."});try{let{recoverySecret:d,iCloudRecordName:c}=yield i.writeRecoverySecretToICloud({containerId:s.container_identifier,appId:t,userId:e.id});return{recoverySecret:d,iCloudRecordName:c}}catch(d){if(d instanceof Error){let c=(a=d.message.split("Caused by: ")[1])!=null?a:"Error writing to iCloud";throw new N({code:"embedded_wallet_recovery_error",error:c})}throw new N({code:"embedded_wallet_recovery_error",error:"Error writing to iCloud"})}})}function Ae(r){return l(this,arguments,function*({walletAddress:e,client:t,chainType:o}){var c;if(jt.OS==="android")throw new N({code:"embedded_wallet_recovery_error",error:"iCloud recovery is not supported on Android"});let i=yield zt(),n=(yield t.recovery.getRecoveryKeyMaterial(e,o)).icloud_record_name;if(!n)throw new N({code:"embedded_wallet_recovery_error",error:"iCloud recovery not properly backed up."});let a=yield t.recovery.icloudAuth.getICloudConfiguration("expo-ios"),d=a==null?void 0:a.container_identifier;if(!d)throw new N({code:"embedded_wallet_recovery_error",error:"An iCloud Container ID must be specified in the Privy Dashboard."});try{let{recoverySecret:u}=yield i.readRecoverySecretFromICloud({containerId:d,recordName:n});return{recoverySecret:u}}catch(u){if(u instanceof Error){let p=(c=u.message.split("Caused by: ")[1])!=null?c:"Error writing to iCloud";throw new N({code:"embedded_wallet_recovery_error",error:p})}throw new N({code:"embedded_wallet_recovery_error",error:"Error writing to iCloud"})}})}import*as q from"expo-linking";import*as Vt from"expo-web-browser";import{Platform as Gt}from"react-native";import{PrivyClientError as $}from"@privy-io/js-sdk-core";import Ta from"react-fast-compare";import{PrivyApiError as wo,PrivyClientError as vo}from"@privy-io/js-sdk-core";function E(e){return e instanceof Error||e instanceof wo||e instanceof vo?e:typeof e=="string"?new Error(e):new Error("Unknown error")}var J=e=>new Promise(t=>setTimeout(t,e));import{useEffect as bo,useRef as So}from"react";import{AppState as Be}from"react-native";function xe(){let e=So(Be.currentState);bo(()=>Be.addEventListener("change",r=>{e.current=r}).remove,[]);function t(){return Be.currentState}return{appState:e,getCurrentAppState:t}}function ae(i){return l(this,arguments,function*({provider:e,redirectUri:t,client:o,onError:r}){try{let s;switch(e){case"google-drive":{let{url:c}=yield o.recovery.auth.generateURL(q.createURL(t||"/"));s=c;break}default:throw new $({error:"OAuth invalid provider",code:"embedded_wallet_recovery_error"})}let n=yield Vt.openAuthSessionAsync(s);if(Gt.OS==="android")return;if(n.type!=="success")throw new $({error:"Recovery OAuth session failed",code:"embedded_wallet_recovery_error"});let{queryParams:a}=q.parse(n.url),d;switch(e){case"google-drive":{let{privy_oauth_state:c,privy_oauth_code:u}=a;if(!u||!c)throw new $({error:"Recovery OAuth invalid credentials",code:"embedded_wallet_recovery_error"});d=yield Pe({oAuthCode:u,oAuthState:c,client:o});break}default:throw new $({error:"Recovery OAuth invalid provider",code:"embedded_wallet_recovery_error"})}return d}catch(s){throw r==null||r(E(s)),s}})}function Pe(r){return l(this,arguments,function*({oAuthCode:e,oAuthState:t,client:o}){let{access_token:i}=yield o.recovery.auth.authorize(e,t);if(!i)throw new $({error:"OAuth invalid credentials",code:"login_with_oauth_returned_with_invalid_credentials"});return i})}var Co=2*60*1e3;function Eo(e){let t;return new Promise((o,r)=>{t=q.addEventListener("url",s=>l(this,[s],function*({url:i}){if(!i)return;let{queryParams:n}=q.parse(i),{privy_oauth_state:a,privy_oauth_code:d}=n!=null?n:{};if(typeof d!="string"||typeof a!="string")return;let c=yield Pe({client:e,oAuthCode:d,oAuthState:a});o(c)})),setTimeout(()=>{r(new $({code:"embedded_wallet_set_recovery_error",error:"Failed to complete Google Drive recovery flow"}))},Co)}).finally(()=>{t==null||t.remove()})}function Ue(e){return l(this,null,function*(){let t;Gt.OS==="android"&&(t=Eo(e));let o=yield ae({provider:"google-drive",client:e});return o!=null?o:yield t})}import{getUserEmbeddedWallet as _o,PrivyClientError as ko}from"@privy-io/js-sdk-core";function Re(s){return l(this,arguments,function*({client:e,recoveryInput:t,setWalletRecoveryCallbacks:o,setRecoveryFlowState:r,setWallet:i}){var n,a,d,c;try{let{provider:u,user:p}=yield e.embeddedWallet.setRecovery(t),m=u,w=_o(p);return i({status:"connected",provider:m,account:w}),(a=(n=o.current)==null?void 0:n.onSuccess)==null||a.call(n,m),r({status:"initial"}),m}catch(u){let p=new ko({code:"embedded_wallet_set_recovery_error",error:u instanceof Error?u.message:"Error setting password on embedded wallet"});throw(c=(d=o.current)==null?void 0:d.onError)==null||c.call(d,p),r({status:"initial"}),p}})}function Bt(e){return e===void 0?{recoveryMethod:"privy"}:typeof e=="string"?{recoveryMethod:"user-passcode",password:e}:e.recoveryMethod==="user-passcode"?{recoveryMethod:"user-passcode",password:e.password}:e.recoveryMethod==="recovery-encryption-key"?{recoveryMethod:"recovery-encryption-key",recoveryKey:e.recoveryKey}:{recoveryMethod:e.recoveryMethod}}var Ht=({client:e,appId:t,wallet:o,setWallet:r,setRecoveryFlowState:i,createWalletCallbacks:s,recoverWalletCallbacks:n,setWalletRecoveryCallbacks:a})=>{let d=U(),c=Wo(()=>Ao(d),[d]),u=z(),p=ce(y=>l(void 0,null,function*(){var ge,he;if(c)throw new R({error:"This user already has an embedded wallet",code:"embedded_wallet_already_exists"});let{user:g}=yield e.user.get(),{password:b,recoveryMethod:C,recoveryKey:k}=Bt(y),A,P,T;if(C==="google-drive"&&(A=yield ae({provider:C,client:e,onError:(ge=s.current)==null?void 0:ge.onError}),i({status:"creating-wallet"}),!A))return null;if(C==="icloud"){if(!g)throw new R({code:"embedded_wallet_recovery_error",error:"User must be loaded before creating a wallet with iCloud."});let{recoverySecret:Ne,iCloudRecordName:re}=yield se({user:g,appId:t,client:e});P=Ne,T=re}return yield ke({client:e,setWallet:r,createWalletCallbacks:s,recoveryMethod:C,recoveryKey:k,setRecoveryFlowState:i,password:b,recoverySecretOverride:P,iCloudRecordNameOverride:T,solanaAccount:(he=qt(g))!=null?he:void 0})}),[e,c,d]),m=ce(y=>l(void 0,null,function*(){var C;if(o.status!=="connected")throw new R({code:"attempted_to_set_password_before_connected",error:"Embedded wallet must be connected before setting password"});if(!c)throw new R({code:"embedded_wallet_does_not_exist",error:"Embedded wallet does not exist"});if(qt(d))throw new R({code:"embedded_wallet_set_recovery_error",error:"Cannot set user-controlled recovery for a user with an embedded Solana wallet."});if(xo(c))throw new R({code:"unsupported_wallet_type",error:"Embedded wallet recovery is only supported for on-device execution and this app uses TEE execution. Learn more https://docs.privy.io/recipes/tee-wallet-migration-guide"});Po({currentRecoveryMethod:c.recovery_method,upgradeToRecoveryMethod:y.recoveryMethod});let g,b;switch(y.recoveryMethod){case"privy":b=M(_({},y),{wallet:c});break;case"user-passcode":b=M(_({},y),{wallet:c,password:y.password});break;case"google-drive":if(g=yield ae({provider:y.recoveryMethod,client:e,onError:(C=a.current)==null?void 0:C.onError}),i({status:"upgrading-recovery"}),!g)return null;b={recoveryMethod:"google-drive",wallet:c,recoveryAccessToken:g};break;case"icloud":if(!d)throw new R({code:"embedded_wallet_recovery_error",error:"User must be loaded before backing up to iCloud."});let{recoverySecret:k,iCloudRecordName:A}=yield se({user:d,appId:t,client:e});b={recoveryMethod:"icloud-native",recoverySecretOverride:k,iCloudRecordNameOverride:A,wallet:c};break;default:throw new R({code:"embedded_wallet_recovery_error",error:"Unrecognized recovery method"})}return Re({client:e,recoveryInput:b,setWalletRecoveryCallbacks:a,setRecoveryFlowState:i,setWallet:r})}),[e,c,o.status,d]),w=ce(y=>l(void 0,null,function*(){return m({recoveryMethod:"user-passcode",password:y})}),[e,c,o.status]),h=ce(y=>l(void 0,null,function*(){var P;if(!c)throw new R({code:"embedded_wallet_does_not_exist",error:"Embedded wallet does not exist"});let{password:g,recoveryMethod:b,recoveryKey:C}=Bt(y),k,A;if(b==="google-drive"&&(k=yield ae({provider:b,client:e,onError:(P=n.current)==null?void 0:P.onError}),i({status:"recovering"}),!k))return null;if(b==="icloud"){if(!d)throw new R({code:"embedded_wallet_recovery_error",error:"User must be loaded before recovering via iCloud."});let{recoverySecret:T}=yield Ae({client:e,walletAddress:c.address});A=T}return _e({client:e,account:c,setWallet:r,recoverWalletCallbacks:n,recoveryMethod:b,setRecoveryFlowState:i,recoveryKey:C,password:g,recoveryToken:k,recoverySecretOverride:A})}),[e,c]),v=ce(()=>l(void 0,null,function*(){if(!c)throw r({status:"not-created",account:null}),new R({code:"embedded_wallet_does_not_exist",error:"Embedded wallet does not exist"});r(y=>y.status==="connected"?{status:"reconnecting",account:c}:{status:"connecting",account:c});try{let y=yield e.embeddedWallet.getProvider(c);return r({status:"connected",provider:y,account:c}),y}catch(y){throw Uo(y)?(r({status:"needs-recovery",account:c}),new R({code:"embedded_wallet_needs_recovery",error:"Embedded wallet not loaded on device"})):y instanceof Error?(r({status:"error",error:y.message,account:c}),new R({code:"unknown_embedded_wallet_error",error:y.message})):(r({status:"error",error:"Error loading embedded wallet",account:c}),new R({code:"unknown_embedded_wallet_error",error:"Error loading embedded wallet"}))}}),[e,c]);return Kt(()=>{if(!d&&o.status!=="disconnected")return r({status:"disconnected",account:null});u&&v().catch(()=>{})},[u,d,c]),Kt(()=>{o.status==="error"&&o.error.includes("User must be logged in")&&v()},[o.status]),{create:p,recover:h,setPassword:w,setRecovery:m,getProvider:v}};import{useEffect as Ro,useState as Io}from"react";import{PrivyClientError as Jt}from"@privy-io/js-sdk-core";var $t=({client:e,isReady:t})=>{let o=U(),r=Se(n=>n==null?void 0:n.customAuth),[i,s]=Io({status:"initial"});return Ro(()=>{(()=>l(void 0,null,function*(){if(!(r!=null&&r.enabled)){s({status:"not-enabled"});return}s({status:"loading"});let{getCustomAccessToken:a,isLoading:d}=r;if(!(!t||d))try{let c=yield a();if(!c&&o){yield e.auth.logout(),s({status:"done"});return}if(!c){s({status:"done"});return}if(o){s({status:"done"});return}let u=x();if(!(yield e.auth.customProvider.syncWithToken(c,{embedded:u==null?void 0:u.embedded}))){yield e.auth.logout(),s({status:"error",error:new Jt({error:"Failed to sync with custom auth provider",code:"third_party_auth_error"})});return}s({status:"done"})}catch(c){if(s({status:"error",error:c}),o)throw yield e.auth.logout(),new Jt({error:"Third-party auth failed",code:"third_party_auth_error"})}}))()},[e,o,t,r==null?void 0:r.enabled,r==null?void 0:r.getCustomAccessToken,r==null?void 0:r.isLoading]),{customAuthState:i,customAuthStateIsSettled:i.status!=="loading"&&i.status!=="initial"}};import*as Q from"expo-linking";import{useCallback as Oo,useEffect as Lo,useMemo as Mo}from"react";import{Platform as To}from"react-native";import{getUserEmbeddedSolanaWallet as Fo,getUserEmbeddedWallet as Do}from"@privy-io/js-sdk-core";var Qt=({client:e,createWalletCallbacks:t,recoverWalletCallbacks:o,setWalletRecoveryCallbacks:r,recoveryFlowState:i,oAuthState:s,setRecoveryFlowState:n,setWallet:a,appStateVisible:d})=>{let c=Q.useURL(),u=U(),p=Mo(()=>Do(u),[u]),m=z(),w=Oo(h=>{var y,g,b,C;let v=E(h);i.status==="creating-wallet"?(g=(y=t.current).onError)==null||g.call(y,E(v)):(C=(b=o.current).onError)==null||C.call(b,E(v)),n({status:"initial"})},[i]);return Lo(()=>{function h(){return l(this,null,function*(){var b;if(!c&&i.status!=="initial"&&d&&w(new Error("Recovery OAuth session failed")),!c||i.status==="initial"||s.status!=="initial"||!d||!m)return;let{queryParams:v}=Q.parse(c),{privy_oauth_state:y,privy_oauth_code:g}=v;if(!(!g||!y)){yield Q.openURL(c.split("?")[0]);try{let C=yield Pe({oAuthCode:g,oAuthState:y,client:e});if(i.status==="creating-wallet"){let k=(b=Fo(u))!=null?b:void 0;yield ke({client:e,setWallet:a,createWalletCallbacks:t,recoveryMethod:"google-drive",setRecoveryFlowState:n,recoveryToken:C,solanaAccount:k})}else if(i.status==="upgrading-recovery"){if(!p)throw new Error("Embedded wallet not found");yield Re({client:e,recoveryInput:{recoveryMethod:"google-drive",wallet:p,recoveryAccessToken:C},setWalletRecoveryCallbacks:r,setRecoveryFlowState:n,setWallet:a})}else yield _e({client:e,account:p,setWallet:a,recoverWalletCallbacks:o,recoveryMethod:"google-drive",setRecoveryFlowState:n,recoveryToken:C})}catch(C){w(C)}}})}To.OS==="android"&&h()},[c,i.status,d,m])};import{useEffect as jo}from"react";import{Platform as He}from"react-native";var No="sdk_initialize";function Yt(){let{major:e,minor:t,patch:o,prerelease:r}=He.constants.reactNativeVersion;return{name:No,properties:{reactNativeVersion:`${e}.${t}.${o}${r!=null?`-${r}`:""}`,operatingSystem:`${He.OS}:${He.Version}`}}}var Xt=({client:e,isUserInitialized:t,setIsUserInitialized:o,setError:r})=>{jo(()=>{t||(()=>l(void 0,null,function*(){try{yield e.initialize(),e.track(Yt())}catch(s){r(s instanceof Error?s:new Error(String(s)))}try{yield e.user.get()}catch(s){}finally{o(!0)}}))()},[e,t,r,o])};import{useEffect as xs,useRef as Ps}from"react";import{useCallback as Je,useContext as zo}from"react";import{PrivyClientError as Vo}from"@privy-io/js-sdk-core";var qc=e=>{let{client:t,setSiweState:o,siweState:r}=zo(f),i=Je(a=>{var c;let d=E(a);return o({status:"error",error:d}),(c=e==null?void 0:e.onError)==null||c.call(e,d),d},[e==null?void 0:e.onError]),s=Je(u=>l(void 0,[u],function*({wallet:a,from:{domain:d,uri:c}}){var p;try{o({status:"generating-message"});let m=yield t.auth.siwe.init(a,d,c);return o({status:"awaiting-signature"}),(p=e==null?void 0:e.onGenerateMessage)==null||p.call(e,m.message),m.message}catch(m){throw i(m)}}),[t,i,e==null?void 0:e.onGenerateMessage]);return{loginWithSiwe:Je(u=>l(void 0,[u],function*({signature:a,messageOverride:d,disableSignup:c}){var p;try{if(S())throw new Vo({code:"attempted_login_with_siwe_while_already_logged_in",error:"Already logged in, use `useLinkWithSiwe` if you are trying to link a wallet to an existing account"});o({status:"submitting-signature"});let w=x(),h=yield t.auth.siwe.loginWithSiwe(a,void 0,d,c?"no-signup":"login-or-sign-up",{embedded:w==null?void 0:w.embedded});return o({status:"done"}),(p=e==null?void 0:e.onSuccess)==null||p.call(e,h.user,h.is_new_user),h.user}catch(m){throw i(m)}}),[t,i,e==null?void 0:e.onSuccess]),generateSiweMessage:s,state:r}};import{useCallback as Zt}from"react";import{createSiwsMessage as Ko,PrivyClientError as qo}from"@privy-io/js-sdk-core";import{useContext as Go}from"react";var W=()=>{let{client:e}=Go(f);return e};var rd=()=>{let e=W(),t=Zt(n=>l(void 0,[n],function*({wallet:{address:r},from:{domain:i,uri:s}}){try{let{nonce:a}=yield e.auth.siws.fetchNonce({address:r});return{message:Ko({address:r,domain:i,uri:s,nonce:a})}}catch(a){throw E(a)}}),[e]),o=Zt(a=>l(void 0,[a],function*({signature:r,message:i,wallet:{walletClientType:s,connectorType:n}={}}){try{if(!S())throw new qo({code:"attempted_link_siws_before_logged_in",error:"Must be logged in to link a wallet, Use `useLoginWithSiws` to login with a wallet"});let{user:c}=yield e.auth.siws.link({signature:r,message:i,walletClientType:s,connectorType:n});return c}catch(d){throw E(d)}}),[e]);return{generateMessage:t,link:o}};import{useCallback as er}from"react";import{createSiwsMessage as Bo,PrivyClientError as Ho}from"@privy-io/js-sdk-core";var ud=()=>{let e=W(),t=er(n=>l(void 0,[n],function*({wallet:{address:r},from:{domain:i,uri:s}}){try{let{nonce:a}=yield e.auth.siws.fetchNonce({address:r});return{message:Bo({address:r,domain:i,uri:s,nonce:a})}}catch(a){throw E(a)}}),[e]),o=er(d=>l(void 0,[d],function*({signature:r,message:i,wallet:{walletClientType:s,connectorType:n}={},disableSignup:a}){try{if(S())throw new Ho({code:"attempted_login_with_siws_while_already_logged_in",error:"Already logged in, use `useLinkWithSiws` if you are trying to link a wallet to an existing account"});let u=x();return(yield e.auth.siws.login({signature:r,message:i,walletClientType:s,connectorType:n,mode:a?"no-signup":"login-or-sign-up",opts:{embedded:u==null?void 0:u.embedded}})).user}catch(c){throw E(c)}}),[e]);return{generateMessage:t,login:o}};import{useCallback as tr,useContext as Jo}from"react";import{PrivyClientError as $o}from"@privy-io/js-sdk-core";var vd=e=>{let{client:t}=Jo(f),o=tr(i=>{var n;let s=E(i);return(n=e==null?void 0:e.onError)==null||n.call(e,s),s},[e==null?void 0:e.onError]);return{unlinkWallet:tr(s=>l(void 0,[s],function*({address:i}){var n;try{if(!S())throw new $o({code:"attempted_unlink_siwe_before_logged_in",error:"Must be logged in to unlink a wallet, Use `useLoginWithSiwe` to login with a wallet"});let{user:d}=yield t.auth.siwe.unlinkWallet(i);return(n=e==null?void 0:e.onSuccess)==null||n.call(e,d),d}catch(a){throw o(a)}}),[t,o,e==null?void 0:e.onSuccess])}};import{useCallback as $e,useContext as Qo,useState as Yo}from"react";import{PrivyClientError as rr}from"@privy-io/js-sdk-core";var Ad=e=>{let[t,o]=Yo(""),{client:r,otpState:i,setOtpState:s}=Qo(f),n=$e(c=>{var p;let u=E(c);return s({status:"error",error:u}),(p=e==null?void 0:e.onError)==null||p.call(e,u),u},[e,s]),a=$e(u=>l(void 0,[u],function*({email:c}){var p;o(c);try{s({status:"sending-code"});let m=yield r.auth.email.sendCode(c);return s({status:"awaiting-code-input"}),(p=e==null?void 0:e.onSendCodeSuccess)==null||p.call(e,{email:c}),m}catch(m){throw n(m)}}),[r,n,e,s]),d=$e(p=>l(void 0,[p],function*({code:c,email:u}){var m;try{if(!S())throw new rr({code:"attempted_link_email_before_logged_in",error:"Must be logged in to link an email, Use `useLoginWithEmail` to login with email"});let h=u||t;if(!h)throw new rr({code:"attempted_submit_otp_before_sending",error:"Must `sendCode` with a valid email before calling `linkWithCode`"});s({status:"submitting-code"});let{user:v}=yield r.auth.email.linkWithCode(h,c);return s({status:"done"}),(m=e==null?void 0:e.onLinkSuccess)==null||m.call(e,v),v}catch(w){throw n(w)}}),[t,s,r,e,n]);return{sendCode:a,linkWithCode:d,state:i}};import{useCallback as or,useContext as Xo}from"react";var Od=e=>{let{client:t}=Xo(f),o=or(i=>{var n;let s=E(i);return(n=e==null?void 0:e.onError)==null||n.call(e,s),s},[e==null?void 0:e.onError]);return{unlinkEmail:or(s=>l(void 0,[s],function*({email:i}){var n;try{let{user:a}=yield t.auth.email.unlink(i);return(n=e==null?void 0:e.onSuccess)==null||n.call(e,a),a}catch(a){throw o(a)}}),[t,e==null?void 0:e.onSuccess,o])}};import{useCallback as Qe,useContext as Zo,useState as en}from"react";import{PrivyClientError as nr}from"@privy-io/js-sdk-core";var Vd=e=>{let[t,o]=en(""),{client:r,otpState:i,setOtpState:s}=Zo(f),n=Qe(c=>{var p;let u=E(c);return s({status:"error",error:u}),(p=e==null?void 0:e.onError)==null||p.call(e,u),u},[e,s]),a=Qe(u=>l(void 0,[u],function*({email:c}){var p;o(c);try{s({status:"sending-code"});let m=yield r.auth.email.sendCode(c);return s({status:"awaiting-code-input"}),(p=e==null?void 0:e.onSendCodeSuccess)==null||p.call(e,{email:c}),m}catch(m){throw n(m)}}),[r,n,e,s]),d=Qe(m=>l(void 0,[m],function*({code:c,email:u,disableSignup:p}){var w;try{if(S()&&!r.isMultiUserModeEnabled)throw new nr({code:"attempted_login_with_email_while_already_logged_in",error:"Already logged in, use `useLinkWithEmail` if you are trying to link an email to an existing account"});let v=u||t;if(!v)throw new nr({code:"attempted_submit_otp_before_sending",error:"Must `sendCode` with a valid email before calling `loginWithCode`"});s({status:"submitting-code"});let y=x(),g=yield r.auth.email.loginWithCode(v,c,p?"no-signup":"login-or-sign-up",{embedded:y==null?void 0:y.embedded});return s({status:"done"}),(w=e==null?void 0:e.onLoginSuccess)==null||w.call(e,g.user,g.is_new_user),g==null?void 0:g.user}catch(h){throw n(h)}}),[t,s,r,e,n]);return{sendCode:a,loginWithCode:d,state:i}};import{useCallback as Ye,useContext as tn,useState as rn}from"react";import{PrivyClientError as ir}from"@privy-io/js-sdk-core";var Qd=e=>{let[t,o]=rn(""),{client:r,otpState:i,setOtpState:s}=tn(f),n=Ye(c=>{var p;let u=E(c);return s({status:"error",error:u}),(p=e==null?void 0:e.onError)==null||p.call(e,u),u},[e,s]),a=Ye(u=>l(void 0,[u],function*({phone:c}){var p;o(c);try{s({status:"sending-code"});let m=yield r.auth.phone.sendCode(c);return s({status:"awaiting-code-input"}),(p=e==null?void 0:e.onSendCodeSuccess)==null||p.call(e,{phone:c}),m}catch(m){throw n(m)}}),[r,n,e,s]),d=Ye(p=>l(void 0,[p],function*({code:c,phone:u}){var m;try{if(!S())throw new ir({code:"attempted_link_sms_before_logged_in",error:"Must be logged in to link a phone number, Use `useLoginWithSMS` to login with a phone number"});if(!(u||t))throw new ir({code:"attempted_submit_otp_before_sending",error:"Must `sendCode` with a valid phone number before calling `linkWithCode`"});s({status:"submitting-code"});let{user:v}=yield r.auth.phone.linkWithCode(u||t,c);return s({status:"done"}),(m=e==null?void 0:e.onLinkSuccess)==null||m.call(e,v),v}catch(w){throw n(w)}}),[t,s,r,e,n]);return{sendCode:a,linkWithCode:d,state:i}};import{useCallback as Xe,useContext as on,useState as nn}from"react";import{PrivyClientError as sr}from"@privy-io/js-sdk-core";var il=e=>{let[t,o]=nn(""),{client:r,otpState:i,setOtpState:s}=on(f),n=Xe(c=>{var p;let u=E(c);return s({status:"error",error:u}),(p=e==null?void 0:e.onError)==null||p.call(e,u),u},[e,s]),a=Xe(u=>l(void 0,[u],function*({phone:c}){var p;o(c);try{s({status:"sending-code"});let m=yield r.auth.phone.sendCode(c);return s({status:"awaiting-code-input"}),(p=e==null?void 0:e.onSendCodeSuccess)==null||p.call(e,{phone:c}),m}catch(m){throw n(m)}}),[r,n,e,s]),d=Xe(m=>l(void 0,[m],function*({code:c,phone:u,disableSignup:p}){var w;try{if(S())throw new sr({code:"attempted_login_with_sms_while_already_logged_in",error:"Already logged in, use `useLinkWithSMS` if you are trying to link a phone number to an existing account"});if(!(u||t))throw new sr({code:"attempted_submit_otp_before_sending",error:"Must `sendCode` with a valid phone number before calling `loginWithCode`"});s({status:"submitting-code"});let y=x(),g=yield r.auth.phone.loginWithCode(u||t,c,p?"no-signup":"login-or-sign-up",{embedded:y==null?void 0:y.embedded});return s({status:"done"}),(w=e==null?void 0:e.onLoginSuccess)==null||w.call(e,g.user,g.is_new_user),g==null?void 0:g.user}catch(h){throw n(h)}}),[t,s,r,e,n]);return{sendCode:a,loginWithCode:d,state:i}};import*as Ie from"expo-linking";import{useCallback as Ze,useContext as sn,useRef as an}from"react";import{PrivyClientError as de}from"@privy-io/js-sdk-core";var ml=e=>{let{appState:t,getCurrentAppState:o}=xe(),{client:r,farcasterState:i,setFarcasterState:s}=sn(f),n=an(!1),a=Ze(u=>{var m;let p=E(u);return s({status:"error",error:p}),(m=e==null?void 0:e.onError)==null||m.call(e,p),p},[e==null?void 0:e.onError,s]),d=Ze(()=>{n.current=!0},[]);return{linkWithFarcaster:Ze((w,...h)=>l(void 0,[w,...h],function*({relyingParty:u,redirectUrl:p},m={pollAttempts:10,pollIntervalMs:1e3}){var v;try{let y=S();if(n.current=!1,!y)throw new de({code:"attempted_link_farcaster_before_logged_in",error:"Must be logged in to link a Farcaster account."});s({status:"generating-uri"});let{connect_uri:g,channel_token:b}=yield r.auth.farcaster.initializeAuth({relyingParty:u,redirectUrl:Ie.createURL(p!=null?p:"/")});if(!g)throw new de({code:"failed_to_generate_farcaster_uri",error:"Failed to generate farcaster uri"});if(!b)throw new de({code:"failed_to_generate_farcaster_channel_token",error:"Failed to generate farcaster channel token"});yield Ie.openURL(g),s({status:"polling-status"});let C=0;for(;C<m.pollAttempts;){if(n.current)throw new de({code:"farcaster_polling_canceled",error:"Farcaster polling canceled"});if(t.current!=="active"&&o()!=="active"){yield J(m.pollIntervalMs);continue}let k=yield r.auth.farcaster.getFarcasterStatus({channel_token:b});if(k.state==="completed"){s({status:"submitting-token"});let{user:A}=yield r.auth.farcaster.link(_({channel_token:b},k));return s({status:"done"}),(v=e==null?void 0:e.onSuccess)==null||v.call(e,A),A}C++,yield J(m.pollIntervalMs)}throw new de({code:"farcaster_polling_timeout",error:"Farcasting polling timed out"})}catch(y){throw a(y)}}),[r,e==null?void 0:e.onSuccess,a,s]),state:i,cancel:d}};import{useCallback as ar,useContext as cn}from"react";var vl=e=>{let{client:t}=cn(f),o=ar(i=>{var n;let s=E(i);return(n=e==null?void 0:e.onError)==null||n.call(e,s),s},[e==null?void 0:e.onError]);return{unlinkFarcaster:ar(s=>l(void 0,[s],function*({fid:i}){var n;try{let{user:a}=yield t.auth.farcaster.unlink({fid:i});return(n=e==null?void 0:e.onSuccess)==null||n.call(e,a),a}catch(a){throw o(a)}}),[t,e==null?void 0:e.onSuccess,o])}};import*as Oe from"expo-linking";import{useCallback as rt,useContext as dn,useRef as ln}from"react";import{PrivyClientError as le}from"@privy-io/js-sdk-core";var xl=e=>{let{appState:t,getCurrentAppState:o}=xe(),{client:r,farcasterState:i,setFarcasterState:s}=dn(f),n=ln(!1),a=rt(u=>{var m;let p=E(u);return s({status:"error",error:p}),(m=e==null?void 0:e.onError)==null||m.call(e,p),p},[e==null?void 0:e.onError,s]),d=rt(()=>{n.current=!0},[]);return{loginWithFarcaster:rt((h,...v)=>l(void 0,[h,...v],function*({relyingParty:u,redirectUrl:p,disableSignup:m},w={pollAttempts:10,pollIntervalMs:1e3}){var y;try{if(n.current=!1,S())throw new le({code:"attempted_login_with_farcaster_while_already_logged_in",error:"Already logged in, use `useLinkWithFarcaster` if you are trying to link farcaster to an existing account"});s({status:"generating-uri"});let{connect_uri:b,channel_token:C}=yield r.auth.farcaster.initializeAuth({relyingParty:u,redirectUrl:Oe.createURL(p!=null?p:"/")});if(!b)throw new le({code:"failed_to_generate_farcaster_uri",error:"Failed to generate farcaster uri"});if(!C)throw new le({code:"failed_to_generate_farcaster_channel_token",error:"Failed to generate farcaster channel token"});yield Oe.openURL(b),s({status:"polling-status"});let k=0;for(;k<w.pollAttempts;){if(n.current)throw new le({code:"farcaster_polling_canceled",error:"Farcaster polling canceled"});if(t.current!=="active"&&o()!=="active"){yield J(w.pollIntervalMs);continue}let A=yield r.auth.farcaster.getFarcasterStatus({channel_token:C});if(A.state==="completed"){s({status:"submitting-token"});let P=x(),T=yield r.auth.farcaster.authenticate(_({channel_token:C,mode:m?"no-signup":"login-or-sign-up"},A),{embedded:P==null?void 0:P.embedded});return s({status:"done"}),(y=e==null?void 0:e.onSuccess)==null||y.call(e,T.user,T.is_new_user),T.user}k++,yield J(w.pollIntervalMs)}throw new le({code:"farcaster_polling_timeout",error:"Farcasting polling timed out"})}catch(g){throw a(g)}}),[r,a,e==null?void 0:e.onSuccess,s,t]),state:i,cancel:d}};import{useCallback as cr,useContext as un}from"react";import{create as pn}from"zustand";import{PrivyClientError as mn}from"@privy-io/js-sdk-core";var ot=pn(()=>({status:"initial"})),V=e=>ot.setState(e,!0),yn=ot.getState,Dl=()=>{let{client:e}=un(f),t=ot(),o=cr(()=>l(void 0,null,function*(){try{V({status:"fetching-nonce"});let i=yield e.auth.farcasterV2.initializeAuth();return V({status:"awaiting-signature"}),i}catch(i){let s=E(i);throw V({status:"initial",error:s}),s}}),[e]),r=cr(i=>l(void 0,null,function*(){let s=yn().status;try{if(S()){let c=new mn({code:"attempted_login_with_farcaster_while_already_logged_in",error:"Already logged in, use a link helper if you are trying to link farcaster to an existing account"});throw V({status:s,error:c}),c}V({status:"submitting-signature"});let a=x(),d=yield e.auth.farcasterV2.authenticate(i,{embedded:a==null?void 0:a.embedded});return V({status:"done"}),setTimeout(()=>V({status:"initial"}),1500),{user:d.user}}catch(n){let a=E(n);throw V({status:s,error:a}),a}}),[e]);return{init:o,login:r,state:t}};import{useContext as fn,useMemo as gn}from"react";import{delegatedActions as dr}from"@privy-io/js-sdk-core";var Kl=()=>{let{client:e}=fn(f);return gn(()=>({delegateWallet:dr.delegateWallet(e),revokeWallets:dr.revokeWallets(e)}),[e])};import{useContext as hn,useMemo as wn}from"react";import{depositAddress as ue}from"@privy-io/js-sdk-core";var $l=()=>{let{client:e}=hn(f);return wn(()=>({getConfig:()=>ue.getConfig(e),generateDepositAddress:t=>ue.generateDepositAddress(_({privy:e},t)),getDeposit:t=>ue.getDeposit(_({privy:e},t)),waitForDeposit:t=>ue.waitForDeposit(_({privy:e},t)),waitForCompletion:t=>ue.waitForCompletion(_({privy:e},t))}),[e])};import{useContext as vn,useMemo as bn}from"react";import{cryptoDepositAccount as Le}from"@privy-io/js-sdk-core";var tu=()=>{let{client:e}=vn(f);return bn(()=>({createCryptoDepositAccount:t=>Le.createCryptoDepositAccount(e,(...o)=>e.embeddedWallet.signWithUserSigner(...o),t),getQuote:t=>Le.getCryptoDepositAccountQuote(e,t),getOrder:t=>Le.getCryptoDepositAccountOrder(e,t),getNextOrder:t=>Le.getCryptoDepositAccountNextOrder(e,t)}),[e])};import{useContext as En,useMemo as _n}from"react";import{addSessionSigners as kn,removeSessionSigners as Wn}from"@privy-io/js-sdk-core";import{isEmbeddedWalletAccount as Sn}from"@privy-io/js-sdk-core";function Cn(e,t){return e.linked_accounts.filter(Sn).find(o=>o.address===t)}function Y(e){let t=S();if(!t)throw new Error("User must be authenticated to perform this operation");let o=Cn(t,e);if(!o)throw new Error(`No wallet found with address ${e}`);return o}var lu=()=>{let{client:e}=En(f);return _n(()=>({addSessionSigners:({address:t,signers:o})=>kn({client:e,wallet:Y(t),signers:o.map(r=>({signer_id:r.signerId,override_policy_ids:r.policyIds}))}),removeSessionSigners:({address:t})=>Wn({client:e,wallet:Y(t)})}),[e])};import{useContext as An,useMemo as xn}from"react";import{addSessionSigners as Pn,removeSessionSigners as Un}from"@privy-io/js-sdk-core";var gu=()=>{let{client:e}=An(f);return xn(()=>({addSigners:({address:t,signers:o})=>Pn({client:e,wallet:Y(t),signers:o.map(r=>({signer_id:r.signerId,override_policy_ids:r.policyIds}))}),removeSigners:({address:t})=>Un({client:e,wallet:Y(t)})}),[e])};import{useContext as Rn,useMemo as In}from"react";import{PrivyClientError as ur}from"@privy-io/js-sdk-core";var Cu=()=>{let{client:e}=Rn(f);return In(()=>({sendCode(r){return l(this,arguments,function*({newEmailAddress:o}){lr(),yield e.auth.email.sendCode(o)})},updateEmail(i){return l(this,arguments,function*({newEmailAddress:o,code:r}){let{address:s}=lr(),{user:n}=yield e.auth.email.updateEmail({oldEmailAddress:s,newEmailAddress:o,code:r});return n})}}),[e])};function lr(){let t=On().linked_accounts.find(o=>o.type==="email");if(!t)throw new ur({code:"attempted_update_email_without_a_linked_email",error:"Must have a linked email account already to update an email address. Use `useLinkEmail` to link an email account."});return t}function On(){let e=S();if(!e)throw new ur({code:"attempted_update_before_logged_in",error:"Must be logged in to update a user profile."});return e}import{useContext as Ln,useMemo as Mn}from"react";import{PrivyClientError as mr}from"@privy-io/js-sdk-core";var Pu=()=>{let{client:e}=Ln(f);return Mn(()=>({sendCode(r){return l(this,arguments,function*({newPhoneNumber:o}){pr(),yield e.auth.phone.sendCode(o)})},updatePhone(i){return l(this,arguments,function*({newPhoneNumber:o,code:r}){let{phoneNumber:s}=pr(),{user:n}=yield e.auth.phone.updatePhone({oldPhoneNumber:s,newPhoneNumber:o,code:r});return n})}}),[e])};function pr(){let t=Tn().linked_accounts.find(o=>o.type==="phone");if(!t)throw new mr({code:"attempted_update_phone_without_a_linked_phone",error:"Must have a linked phone account already to update a phone number. Use `useLinkSMS` to link a phone number."});return t}function Tn(){let e=S();if(!e)throw new mr({code:"attempted_update_before_logged_in",error:"Must be logged in to update a user profile."});return e}import*as gr from"expo-linking";import{useCallback as Dn,useContext as Nn,useMemo as jn}from"react";import{crossApp as zn,PrivyClientError as Vn}from"@privy-io/js-sdk-core";import*as fr from"expo-linking";import*as pe from"expo-web-browser";import{PrivyClientError as yr}from"@privy-io/js-sdk-core";var j=(e,t)=>l(void 0,null,function*(){let o=yield pe.openAuthSessionAsync(e,t,{createTask:!1});if(o.type!=="success")throw o.type===pe.WebBrowserResultType.CANCEL||o.type===pe.WebBrowserResultType.DISMISS?new yr({error:"OAuth session was cancelled",code:"oauth_session_failed"}):new yr({error:"OAuth session failed",code:"oauth_session_failed"});return Fn(o.url)});function Fn(e){let{queryParams:t}=fr.parse(e);return t}var zu=()=>{let{client:e}=Nn(f),t=jn(()=>zn.loginWithCrossAppAuth({client:e,openAuthSession:j}),[e]);return{loginWithCrossApp:Dn(s=>l(void 0,[s],function*({appId:r,redirectUri:i}){if(S())throw new Vn({code:"attempted_login_with_cross_app_while_already_logged_in",error:"Already logged in, use `linkCrossAppAccount` if you are trying to link a cross app account to an existing account"});let a=x(),{user:d}=yield t({providerAppId:r,redirectUrl:gr.createURL(i||"/"),loginOptions:{embedded:a==null?void 0:a.embedded}});return{user:d}}),[t])}};import*as hr from"expo-linking";import{useCallback as Gn,useContext as Kn,useMemo as qn}from"react";import{crossApp as Bn,PrivyClientError as Hn}from"@privy-io/js-sdk-core";var $u=()=>{let{client:e}=Kn(f),t=qn(()=>Bn.linkWithCrossAppAuth({client:e,openAuthSession:j}),[e]);return{linkWithCrossApp:Gn(s=>l(void 0,[s],function*({appId:r,redirectUri:i}){if(!S())throw new Hn({code:"attempted_link_cross_app_before_logged_in",error:"Must be logged in to link a cross app account, Use `loginWithCrossAppAccount` to login with cross app"});return{user:yield t({providerAppId:r,redirectUrl:hr.createURL(i||"/")})}}),[t])}};import*as vr from"expo-linking";import{useContext as Jn,useMemo as wr}from"react";import{crossApp as $n}from"@privy-io/js-sdk-core";var op=()=>{let{client:e}=Jn(f),t=wr(()=>$n.wallet.signMessage({client:e,openAuthSession:j}),[e]);return wr(()=>({signMessage:({address:o,message:r,redirectUri:i="/"})=>t({user:S(),address:o,message:r,redirectUrl:vr.createURL(i)})}),[t])};import*as Sr from"expo-linking";import{useContext as Qn,useMemo as br}from"react";import{crossApp as Yn}from"@privy-io/js-sdk-core";var lp=()=>{let{client:e}=Qn(f),t=br(()=>Yn.wallet.signTypedData({client:e,openAuthSession:j}),[e]);return br(()=>({signTypedData:({address:o,typedData:r,redirectUri:i="/"})=>t({user:S(),address:o,typedData:r,redirectUrl:Sr.createURL(i)})}),[t])};import*as Er from"expo-linking";import{useContext as Xn,useMemo as Cr}from"react";import{crossApp as Zn}from"@privy-io/js-sdk-core";var hp=()=>{let{client:e}=Xn(f),t=Cr(()=>Zn.wallet.sendTransaction({client:e,openAuthSession:j}),[e]);return Cr(()=>({sendTransaction:({address:o,transaction:r,redirectUri:i="/"})=>t({user:S(),address:o,transaction:r,redirectUrl:Er.createURL(i)})}),[t])};import{useCallback as ei,useContext as ti}from"react";import{getUserEmbeddedEthereumWallet as ri,getUserEmbeddedSolanaWallet as oi,isUnifiedWallet as ni,PrivyClientError as X,throwIfInvalidRecoveryUpgradePath as ii}from"@privy-io/js-sdk-core";var kp=()=>{let{client:e}=ti(f);return{setRecovery:ei(o=>l(void 0,null,function*(){var a;let r=S(),i=e.app.appId;if(!r)throw new X({code:"embedded_wallet_recovery_error",error:"User must be loaded before attempting to modify the recovery method."});let s=(a=ri(r))!=null?a:oi(r);if(!s)throw new X({code:"embedded_wallet_does_not_exist",error:"Embedded wallet does not exist"});if(ni(s))throw new X({code:"unsupported_wallet_type",error:"Embedded wallet recovery is only supported for on-device execution and this app uses TEE execution. Learn more https://docs.privy.io/recipes/tee-wallet-migration-guide"});try{s.chain_type==="ethereum"?yield e.embeddedWallet.getProvider(s):s.chain_type==="solana"&&(yield e.embeddedWallet.getSolanaProvider(s,s.address,"solana-address-verifier"))}catch(d){throw new X({code:"attempted_to_set_password_before_connected",error:"Embedded wallet must be connected before setting password"})}ii({currentRecoveryMethod:s.recovery_method,upgradeToRecoveryMethod:o.recoveryMethod});let n=yield si({appId:i,client:e,user:r,primaryAccount:s,recoveryParams:o});try{let{user:d}=yield e.embeddedWallet.setRecovery(n);return{user:d}}catch(d){throw new X({code:"embedded_wallet_set_recovery_error",error:d instanceof Error?d.message:"Error setting password on embedded wallet"})}}),[e])}},si=s=>l(void 0,[s],function*({appId:e,client:t,user:o,primaryAccount:r,recoveryParams:i}){switch(i.recoveryMethod){case"privy":return{recoveryMethod:"privy",wallet:r};case"user-passcode":return M(_({},i),{wallet:r});case"google-drive":{let n=yield Ue(t);return{recoveryMethod:"google-drive",wallet:r,recoveryAccessToken:n}}case"icloud":{let{recoverySecret:n,iCloudRecordName:a}=yield se({appId:e,client:t,user:o});return{recoveryMethod:"icloud-native",recoverySecretOverride:n,iCloudRecordNameOverride:a,wallet:r}}case"recovery-encryption-key":return{recoveryMethod:"recovery-encryption-key",wallet:r,recoveryKey:i.recoveryKey};default:throw new X({code:"embedded_wallet_recovery_error",error:"Unrecognized recovery method"})}});import{useCallback as ai,useContext as ci}from"react";import{getUserEmbeddedEthereumWallet as di,getUserEmbeddedSolanaWallet as li,PrivyClientError as me,isUnifiedWallet as ui}from"@privy-io/js-sdk-core";var Lp=()=>{let{client:e}=ci(f);return{recover:ai(o=>l(void 0,null,function*(){var c;let r=S();if(!r)throw new me({code:"embedded_wallet_recovery_error",error:"User must be loaded before attempting to modify the recovery method."});let i=(c=di(r))!=null?c:li(r);if(!i)throw new me({code:"embedded_wallet_does_not_exist",error:"Embedded wallet does not exist"});if(ui(i))throw new me({code:"unsupported_wallet_type",error:"User owned wallet recovery is only supported for on-device execution and this app uses TEE execution. Learn more https://docs.privy.io/recipes/tee-wallet-migration-guide"});let s,n,a,d;switch(o.recoveryMethod){case"user-passcode":n=o.password;break;case"google-drive":a=yield Ue(e);break;case"icloud":let{recoverySecret:u}=yield Ae({client:e,walletAddress:i.address,chainType:i.chain_type});d=u;break;case"recovery-encryption-key":s=o.recoveryKey;break;case"privy":break;default:throw new me({code:"unsupported_recovery_method",error:`Unsupported recovery options ${o}`})}try{i.chain_type==="ethereum"?yield e.embeddedWallet.getProvider(i,n,a,d,s):i.chain_type==="solana"&&(yield e.embeddedWallet.getSolanaProvider(i,i.address,"solana-address-verifier",n,a,d))}catch(u){throw new me({code:"attempted_to_set_password_before_connected",error:"Embedded wallet must be connected before setting password"})}}),[e])}};import{useEffect as mi}from"react";import{useContext as pi,useEffect as nt}from"react";var it=(e={})=>{let{wallet:t,createWalletCallbacks:o,recoverWalletCallbacks:r,setWalletRecoveryCallbacks:i}=pi(f),{onCreateWalletSuccess:s,onCreateWalletError:n,onRecoverWalletError:a,onRecoverWalletSuccess:d,onSetWalletRecoverySuccess:c,onSetWalletRecoveryError:u}=e;return nt(()=>{o.current={onSuccess:s,onError:n}},[s,n]),nt(()=>{r.current={onSuccess:d,onError:a}},[d,a]),nt(()=>{i.current={onSuccess:c,onError:u}},[d,a]),t};var Vp=({onStateChange:e})=>{let t=it();return mi(()=>{e(t)},[t])};import{useContext as yi}from"react";var Bp=()=>{let{getIdentityToken:e}=yi(f);return{getIdentityToken:e}};import{useCallback as _r,useContext as fi}from"react";import{PrivyClientError as gi}from"@privy-io/js-sdk-core";var em=e=>{let{client:t}=fi(f),o=_r(i=>{var n;let s=E(i);return(n=e==null?void 0:e.onError)==null||n.call(e,s),s},[e==null?void 0:e.onError]);return{create:_r(()=>l(void 0,null,function*(){var i;try{if(S())throw new gi({code:"attempted_to_create_guest_account_for_logged_in_user",error:"Already logged in, you cannot create a guest account"});let n=x(),a=yield t.auth.guest.create({embedded:n==null?void 0:n.embedded});return(i=e==null?void 0:e.onSuccess)==null||i.call(e,a.user,a.is_new_user),a.user}catch(s){throw o(s)}}),[t,o,e==null?void 0:e.onSuccess])}};import{useContext as hi,useEffect as wi}from"react";function sm({onMfaRequired:e}){let{client:t}=hi(f);wi(()=>{function o(){return l(this,null,function*(){var i;let r=S();yield e((i=r==null?void 0:r.mfa_methods.map(({type:s})=>s).filter(s=>s!=="email"))!=null?i:[])})}return t.mfaPromises.on("mfaRequired",o),()=>{t.mfaPromises.off("mfaRequired",o)}},[t,e])}import{useCallback as ye,useContext as ki}from"react";import{PrivyClientError as Te}from"@privy-io/js-sdk-core";import{PrivyClientError as vi}from"@privy-io/js-sdk-core";function Me(){return l(this,null,function*(){We("react-native-passkeys");try{return yield import("react-native-passkeys")}catch(e){return Promise.reject(e)}})}var bi=(e,t)=>l(void 0,null,function*(){var i;let r=yield(yield Me()).create(Si(e,t));if(!r)throw new vi({code:"failed_to_create_passkey",error:"Could not create passkey"});return M(_({},r),{type:(i=r.type)!=null?i:"public-key",clientExtensionResults:{}})});function Si(e,t){return M(_({},t),{rp:e.rp,user:e.user,challenge:e.challenge,pubKeyCredParams:e.pubKeyCredParams,excludeCredentials:e.excludeCredentials,authenticatorSelection:e.authenticatorSelection,timeout:12e4,attestation:void 0})}import{PrivyClientError as Ci}from"@privy-io/js-sdk-core";var at=(e,t)=>l(void 0,null,function*(){var i;let r=yield(yield Me()).get(Ei(e,t));if(!r)throw new Ci({code:"no_passkey_found_for_challenge",error:"Could not find a matching passkey to login with"});return M(_({},r),{type:(i=r.type)!=null?i:"public-key",clientExtensionResults:{}})});function Ei(e,t){return M(_({},t),{rpId:e.rpId,challenge:e.challenge,allowCredentials:e.allowCredentials,userVerification:e.userVerification,timeout:12e4})}function kr(e){var t;return{id:e.id,client_extension_results:{app_id:e.clientExtensionResults.appid,cred_props:e.clientExtensionResults.credProps,hmac_create_secret:e.clientExtensionResults.hmacCreateSecret},raw_id:e.rawId,type:e.type,authenticator_attachment:(t=e.authenticatorAttachment)!=null?t:"platform",response:{authenticator_data:e.response.authenticatorData,client_data_json:e.response.clientDataJSON,signature:e.response.signature,user_handle:e.response.userHandle}}}function Wr(e){var t,o,r,i;return{challenge:e.challenge,rpId:e.rp_id,extensions:{appid:(t=e.extensions)==null?void 0:t.app_id,credProps:(o=e.extensions)==null?void 0:o.cred_props,hmacCreateSecret:(r=e.extensions)==null?void 0:r.hmac_create_secret},timeout:e.timeout,allowCredentials:(i=e.allow_credentials)==null?void 0:i.map(({id:s,type:n,transports:a})=>({id:s,type:n,transports:a})),userVerification:e.user_verification}}function km(e){var t,o,r,i,s,n,a,d;return{rp:e.rp,user:{id:e.user.id,name:e.user.name,displayName:e.user.display_name},challenge:e.challenge,pubKeyCredParams:e.pub_key_cred_params,extensions:{hmacCreateSecret:(t=e.extensions)==null?void 0:t.hmac_create_secret,credProps:(r=(o=e.extensions)==null?void 0:o.cred_props)==null?void 0:r.rk,appid:(i=e.extensions)==null?void 0:i.app_id},attestation:e.attestation,excludeCredentials:e.exclude_credentials,authenticatorSelection:{authenticatorAttachment:(s=e.authenticator_selection)==null?void 0:s.authenticator_attachment,residentKey:(n=e.authenticator_selection)==null?void 0:n.resident_key,userVerification:(a=e.authenticator_selection)==null?void 0:a.user_verification,requireResidentKey:(d=e.authenticator_selection)==null?void 0:d.require_resident_key}}}function Rm(){let{client:e}=ki(f),t=ye(n=>l(this,null,function*(){var a,d;switch(n.method){case"sms":yield e.mfa.sms.sendCode({action:"verify"});return;case"passkey":let{options:c}=yield e.mfa.passkey.generateAuthenticationOptions({relying_party:n.relyingParty||((d=(a=x())==null?void 0:a.mfa)==null?void 0:d.relyingParty)});return Wr(c);case"totp":return;default:throw new Error(`Unsupported MFA method: ${n.mfaMethod}`)}}),[e]),o=ye(n=>l(this,null,function*(){var a,d,c,u,p,m,w;switch(n.method){case"totp":case"sms":if(typeof n.mfaCode!="string")throw new Te({code:"invalid_mfa_code",error:"Invalid MFA code"});(c=e.mfaPromises.rootPromise.current)==null||c.resolve({mfaMethod:n.method,mfaCode:n.mfaCode,relyingParty:n.relyingParty||((d=(a=x())==null?void 0:a.mfa)==null?void 0:d.relyingParty)||""}),yield new Promise((g,b)=>{e.mfaPromises.submitPromise.current={resolve:g,reject:b}});break;case"passkey":if(typeof n.mfaCode=="string")throw new Te({code:"invalid_passkey_response",error:"Invalid authenticator response"});let h=yield at(n.mfaCode),v=kr(h);(m=e.mfaPromises.rootPromise.current)==null||m.resolve({mfaMethod:n.method,relyingParty:n.relyingParty||((p=(u=x())==null?void 0:u.mfa)==null?void 0:p.relyingParty)||"",mfaCode:v}),yield new Promise((g,b)=>{e.mfaPromises.submitPromise.current={resolve:g,reject:b}});break;default:let y=new Te({code:"unsupported_mfa_method",error:"Unsupported MFA method"});throw(w=e.mfaPromises.rootPromise.current)==null||w.reject(y),y}}),[e]),r=ye(()=>l(this,null,function*(){let n=S();!n||n.mfa_methods.length===0||(yield e.mfa.verifyMfa())}),[e]),i=ye(()=>{var n;(n=e.mfaPromises.rootPromise.current)==null||n.reject(new Te({code:"mfa_canceled",error:"MFA canceled"}))},[e]),s=ye(()=>l(this,null,function*(){let n=S();n&&(yield e.mfa.clearMfa({userId:n.id}))}),[e]);return{init:t,submit:o,prompt:r,cancel:i,clear:s}}import{useCallback as ct,useContext as Wi}from"react";function Tm(){let{client:e}=Wi(f),t=ct(i=>l(this,null,function*(){switch(i.method){case"sms":case"totp":return yield e.mfa.initEnrollMfa(i);case"passkey":return;default:throw new Error(`Unsupported MFA method: ${i.method}`)}}),[e]),o=ct(i=>l(this,null,function*(){switch(i.method){case"sms":case"totp":case"passkey":yield e.mfa.submitEnrollMfa(i);return;default:throw new Error(`Unsupported MFA method: ${i.method}`)}}),[e]),r=ct(i=>l(this,null,function*(){switch(i.method){case"sms":case"totp":yield e.mfa.unenrollMfa(i.method);return;case"passkey":yield e.mfa.submitEnrollMfa({method:"passkey",credentialIds:[],removeForLogin:i.removeForLogin});return;default:throw new Error(`Unsupported MFA method: ${i.method}`)}}),[e]);return{initMfaEnrollment:t,submitMfaEnrollment:o,unenrollMfa:r}}import{useCallback as Ai,useContext as xi}from"react";function zm(){let{client:e}=xi(f);return{unlink:Ai(i=>l(this,[i],function*({credentialId:o,removeAsMfa:r}){yield e.mfa.unlinkPasskey({credentialId:o,removeAsMfa:r})}),[e])}}import{useCallback as Pi}from"react";import{areAddressesEqual as Ui}from"@privy-io/are-addresses-equal";import{getAllUserEmbeddedEthereumWallets as Ri,getAllUserEmbeddedSolanaWallets as Ii,PrivyClientError as Oi}from"@privy-io/js-sdk-core";var Jm=()=>{let e=W();return{importWallet:Pi(s=>l(void 0,[s],function*({privateKey:o,chainType:r,additionalSigners:i}){let{address:n,user:a}=yield e.embeddedWallet.importWallet({privateKey:o,chainType:r,additionalSigners:i}),c=(r==="solana"?Ii(a.user):Ri(a.user)).find(u=>Ui(u.address,n));if(!c)throw new Oi({code:"embedded_wallet_creation_error",error:"Failed to import wallet"});return{user:a.user,wallet:c}}),[e])}};import{useCallback as Li,useMemo as Ar}from"react";import{getAllUserEmbeddedEthereumWallets as Fe,getEntropyDetailsFromUser as xr,getUserEmbeddedSolanaWallet as Mi,PrivyClientError as dt}from"@privy-io/js-sdk-core";var lt=()=>{let e=U(),t=W(),o=Ar(()=>{let s=Fe(e).map(n=>{let a=xr(e,n);return a?{account:n,entropy:a}:null});return s.some(n=>n===null)?[]:s.filter(n=>n!==null).map(({account:n,entropy:{entropyId:a,entropyIdVerifier:d}})=>({address:n.address,walletIndex:n.wallet_index,chainType:n.chain_type,getProvider:()=>t.embeddedWallet.getEthereumProvider({wallet:n,entropyId:a,entropyIdVerifier:d,onNeedsRecovery:c=>l(void 0,null,function*(){var u;yield(u=be())==null?void 0:u(c)})})}))},[t,e]),r=Li((...s)=>l(void 0,[...s],function*({createAdditional:i=!1}={}){var p,m,w;let{user:n}=yield t.user.get(),a=Fe(n);if(!i&&a.length>0)throw new dt({code:"embedded_wallet_creation_error",error:"Wallet already exists for this user. Set `createAdditional` to `true` to create another wallet"});if(a.length===0){let h=(p=Mi(n))!=null?p:void 0,v=yield t.embeddedWallet.create(h?{solanaAccount:h}:{});return Ti(v.user),{user:v.user}}let d=xr(n),c=a.map(h=>h.wallet_index).reduce((h,v)=>Math.max(h,v),0)+1,u=yield t.embeddedWallet.add({chainType:"ethereum",hdWalletIndex:c,entropyId:(m=d==null?void 0:d.entropyId)!=null?m:"",entropyIdVerifier:(w=d==null?void 0:d.entropyIdVerifier)!=null?w:"ethereum-address-verifier"});if(Fe(u.user).length<=a.length)throw new dt({code:"embedded_wallet_creation_error",error:"Unknown error creating wallet"});return{user:u.user}}),[t]);return Ar(()=>({wallets:o,create:r}),[o,r])};function Ti(e){if(!e||Fe(e).length===0)throw new dt({code:"embedded_wallet_creation_error",error:"Unknown error creating wallet"})}import{useContext as Fi,useEffect as Pr}from"react";var Di=(e={})=>{let{solanaWallet:t,createSolanaWalletCallbacks:o,recoverSolanaWalletCallbacks:r}=Fi(f),{onCreateWalletSuccess:i,onCreateWalletError:s,onRecoverWalletError:n,onRecoverWalletSuccess:a}=e;return Pr(()=>{o.current={onSuccess:i,onError:s}},[i,s]),Pr(()=>{r.current={onSuccess:a,onError:n}},[a,n]),t};import{useCallback as Ni,useMemo as ji}from"react";import{getAllUserEmbeddedBitcoinWallets as ut,getEntropyDetailsFromUser as Ur,isUnifiedWallet as zi,PrivyClientError as Z}from"@privy-io/js-sdk-core";var Vi=()=>{let e=U(),t=W(),o=ji(()=>{let i=Ur(e);if(!i)return[];let s=ut(e),{entropyId:n,entropyIdVerifier:a}=i;return s.map(d=>({address:d.address,walletIndex:d.wallet_index,publicKey:d.public_key,chainType:d.chain_type,getProvider:()=>zi(d)?Promise.reject(new Z({code:"unsupported_wallet_type",error:"Bitcoin wallet providers are only supported for on-device execution and this app uses TEE execution. Use the useSignRawHash hook from @privy-io/expo/extended-chains to sign over a hash with this wallet. Learn more at https://docs.privy.io/recipes/tee-wallet-migration-guide"})):t.embeddedWallet.getBitcoinProvider({wallet:d,entropyId:n,entropyIdVerifier:a})}))},[t,e]),r=Ni(n=>l(void 0,[n],function*({chainType:i,createAdditional:s=!1}){var y;let a=t.app.getConfig();if(((y=a==null?void 0:a.embedded_wallet_config)==null?void 0:y.mode)==="user-controlled-server-wallets-only")throw i==="bitcoin-segwit"?new Z({code:"unsupported_wallet_type",error:"This app uses TEE execution. Use the useCreateWallet hook from @privy-io/expo/extended-chains to create the wallet instead. Learn more https://docs.privy.io/recipes/tee-wallet-migration-guide"}):new Z({code:"unsupported_wallet_type",error:`Bitcoin (${i}) wallets are only supported for on-device execution and this app uses TEE execution. Learn more https://docs.privy.io/recipes/tee-wallet-migration-guide`});let{user:d}=yield t.user.get(),c=Ur(d);if(!c)throw new Z({code:"embedded_wallet_creation_error",error:"No existing wallet for this user, create an Ethereum walet first to add a Bitcoin wallet"});let{entropyId:u,entropyIdVerifier:p}=c,m=ut(d).filter(g=>g.chain_type===i);if(!s&&m.length>0)throw new Z({code:"embedded_wallet_creation_error",error:"Wallet already exists for this user. Set `createAdditional` to `true` to create another wallet"});let w=m.length===0?0:Math.max(...m.map(g=>g.wallet_index),0)+1,h=yield t.embeddedWallet.add({chainType:i,hdWalletIndex:w,entropyId:u,entropyIdVerifier:p}),v=ut(h.user).find(g=>g.chain_type===i&&g.wallet_index===w);if(!h.user||!v)throw new Z({code:"embedded_wallet_creation_error",error:"Unknown error creating wallet"});return{user:h.user,provider:yield t.embeddedWallet.getBitcoinProvider({wallet:v,entropyId:u,entropyIdVerifier:p})}}),[t]);return{wallets:o,create:r}};import{useContext as Gi}from"react";var pt=()=>{let{isReady:e,logout:t,getAccessToken:o,error:r,client:i}=Gi(f);return{user:U(),isReady:e,error:r,logout:t,getAccessToken:o,refreshUser:()=>i.user.refreshUser()}};import{useContext as Ki}from"react";function qi(){let{client:e}=Ki(f);return{acceptTerms:()=>l(this,null,function*(){return e.user.acceptTerms()})}}import{useMemo as Bi}from"react";import{generateAuthorizationSignature as Hi}from"@privy-io/js-sdk-core";var Ji=()=>{let e=W();return Bi(()=>({generateAuthorizationSignature(o){return l(this,null,function*(){let{signature:r}=yield Hi((...i)=>e.embeddedWallet.signWithUserSigner(...i),o);return{signature:r}})}}),[e])};import{useContext as $i,useMemo as Qi}from"react";import{GetEncryptedAuthorizationKey as Yi}from"@privy-io/routes";var Py=()=>{let{client:e}=$i(f);return Qi(()=>({getEncryptedAuthorizationKey:({id:t})=>e.fetchPrivyRoute(Yi,{params:{encrypted_authorization_key_id:t}})}),[e])};import{useCallback as Xi}from"react";import{createWalletClient as Zi,getAddress as Rr,http as es,parseSignature as ts,zeroAddress as rs}from"viem";import{hashAuthorization as os}from"viem/utils";import{getAllUserEmbeddedEthereumWallets as ns,getJsonRpcEndpointFromChain as is}from"@privy-io/js-sdk-core";var ss=()=>{let e=U(),{wallets:t}=lt(),o=W();return{signAuthorization:Xi((i,s)=>l(void 0,null,function*(){var p,m,w;if(!e)throw new Error("User must be authenticated before signing with a Privy wallet");let n=(w=(m=s==null?void 0:s.address)!=null?m:(p=ns(e)[0])==null?void 0:p.address)!=null?w:rs,a=t.find(h=>Rr(h.address)===Rr(n));if(!a)throw new Error("Signing wallet not found.");let d;if(i.chainId===0){if(i.nonce===void 0)throw new Error("nonce is required when chainId is 0 \u2014 chain-agnostic authorizations are replayable across networks");d={chainId:0,address:i.contractAddress,nonce:i.nonce}}else{let v=o.embeddedWallet.chains.find(b=>b.id===i.chainId);if(!v)throw new Error("Error, chain not configured in PrivyProvider config");let y=is(v,{},o.app.appId);d=yield Zi({account:n,chain:v,transport:es(y)}).prepareAuthorization(_({},i))}let u=yield(yield a.getProvider()).request({method:"secp256k1_sign",params:[os(d)]});return _(_({},d),ts(u))}),[t,e,o])}};import{useMemo as as}from"react";import{transfer as cs}from"@privy-io/js-sdk-core";var ds=()=>{let e=W();return as(()=>({transfer:(t,o)=>cs(e,(...r)=>e.embeddedWallet.signWithUserSigner(...r),_({wallet_id:t},o))}),[e])};import{useMemo as ls}from"react";import{PrivyClientError as us,updateWallet as ps}from"@privy-io/js-sdk-core";var ms=()=>{let e=W();return ls(()=>({updateWallet:(t,o)=>l(void 0,null,function*(){yield ps(e,{wallet_id:t},(...s)=>e.embeddedWallet.signWithUserSigner(...s),o);let{user:r}=yield e.user.refreshUser(),i=r==null?void 0:r.linked_accounts.find(s=>s.type==="wallet"&&"id"in s&&s.id===t);if(!i)throw new us({code:"embedded_wallet_does_not_exist",error:"Updated wallet was not found in the refreshed user."});return{wallet:i}})}),[e])};import{useMemo as ys}from"react";import{getWalletAction as fs,listWalletActions as gs}from"@privy-io/js-sdk-core";var hs=()=>{let e=W();return ys(()=>({getAction:(t,o)=>fs(e,{wallet_id:t,action_id:o}),listActions:(t,o)=>gs(e,_({wallet_id:t},o))}),[e])};import{useMemo as ws}from"react";var vs=()=>{let e=Ut();return ws(()=>({users:e}),[e])};import{useMemo as bs}from"react";var Ss=()=>{let e=W();return bs(()=>({switchUser:o=>l(void 0,[o],function*({userId:t}){return yield e.user.switchActiveUser({userId:t})})}),[e])};import{useCallback as Ws}from"react";import{PrivyClientError as As}from"@privy-io/js-sdk-core";import{getAllUserEmbeddedBitcoinWallets as Cs,getUserEmbeddedEthereumWallet as Es,getUserEmbeddedSolanaWallet as _s,isEmbeddedWalletAccount as ks,isUnifiedWallet as Ir}from"@privy-io/js-sdk-core";function Or(e,t){return l(this,null,function*(){var i,s;let o=t.linked_accounts.filter(ks).filter(n=>!n.imported&&!Ir(n)).filter(n=>n.chain_type==="ethereum"||n.chain_type==="solana"),r=(i=o.find(n=>n.chain_type==="ethereum"&&n.wallet_index===0))!=null?i:o.find(n=>n.chain_type==="solana"&&n.wallet_index===0);if(!r){let n=(s=Es(t))!=null?s:_s(t);if(n!=null&&n.imported&&!Ir(n))throw new Error("Imported wallets cannot be migrated");return{success:!0,migrated:!1}}if(Cs(t).length>0)throw new Error("Bitcoin wallets cannot be migrated");return r.chain_type==="ethereum"?yield e.embeddedWallet.getProvider(r):r.chain_type==="solana"&&(yield e.embeddedWallet.getSolanaProvider(r,r.address,"solana-address-verifier")),yield e.embeddedWallet.delegateWallets({rootWallet:{address:r.address,chainType:r.chain_type,imported:r.imported},delegatedWallets:o.map(n=>({address:n.address,chainType:n.chain_type,walletIndex:n.wallet_index}))}),yield e.user.get(),{success:!0,migrated:!0}})}var Lr=()=>{let e=W();return{migrate:Ws(()=>l(void 0,null,function*(){var s;let o=S(),r=e.app.getConfig();if(((s=r==null?void 0:r.embedded_wallet_config)==null?void 0:s.mode)!=="user-controlled-server-wallets-only")return{success:!0};if(!o)throw new As({code:"embedded_wallet_before_logged_in",error:"User must be authenticated before migrating wallets"});return Or(e,o)}),[e])}};var Mr=({disabled:e})=>{let{migrate:t}=Lr(),{user:o}=pt(),r=Ps(!1);return xs(()=>{e||o&&(r.current||(r.current=!0,t().then(i=>{i.migrated&&!r.current&&(console.info("Migrated wallets for user"),r.current=!0)}).catch(i=>{console.debug("Unable to migrate wallets: ",i)}).finally(()=>{r.current=!1})))},[t,o,e]),null};var f=Rs(null),te;function Tg(e){return te?te.getAccessToken():e!=null&&e.strict?Promise.reject(new Dr({code:"attempted_to_read_storage_before_client_initialized",error:"Called `getAccessToken` before client initialized"})):(console.warn("Called `getAccessToken` before client initialized"),Promise.resolve(null))}var Fg=e=>{var gt,ht,wt;Ls();let[t,o]=L(Fr.currentState==="active");Tr(()=>{let O=Fr.addEventListener("change",Br=>{o(Br==="active")});return()=>{O.remove()}},[]),Tr(()=>Wt(e.config),[e.config]);let[r,i]=L(!1),[s,n]=L(null),[a,d]=L(!1),[c,u]=L({status:"disconnected",account:null}),[p,m]=L({status:"disconnected"}),[w,h]=L({status:"initial"}),[v,y]=L({status:"initial"}),[g,b]=L({status:"initial"}),[C,k]=L({status:"initial"}),[A,P]=L({status:"initial"}),[T,ge]=L({status:"initial"}),[he,Ne]=L({status:"initial"}),re=fe({}),je=fe({}),ze=fe({}),yt=fe({}),ft=fe({}),we=De(O=>{if(O){Ge(O),n(null);return}Ge(null),h({status:"initial"}),y({status:"initial"}),u({status:"disconnected",account:null})},[]),I=Us(()=>{let O=e.storage||ve;return e.client?te=e.client:te=kt({appId:e.appId,clientId:e.clientId,supportedChains:e.supportedChains,storage:O,baseUrl:e.baseUrl,logLevel:e.logLevel}),te.setCallbacks({setUser:we,setIsReady:d,setStoredUsers:Pt}),te},[e.client,e.storage,e.appId,e.clientId,e.baseUrl,e.supportedChains,e.logLevel,we]),Nr=De(()=>l(void 0,null,function*(){let O=S();yield I.auth.logout(O?{userId:O==null?void 0:O.id}:void 0),we(null)}),[we,I]),jr=De(()=>l(void 0,null,function*(){try{return yield I.getAccessToken()}catch(O){return console.debug(O),null}}),[I]),zr=De(()=>I.getIdentityToken(),[I]);Xt({client:I,isUserInitialized:r,setIsUserInitialized:i,setError:n});let Vr=Ht({client:I,appId:e.appId,createWalletCallbacks:re,recoverWalletCallbacks:je,setWalletRecoveryCallbacks:ze,setRecoveryFlowState:b,wallet:c,setWallet:u}),Gr=Dt({client:I,createSolanaWalletCallbacks:yt,recoverSolanaWalletCallbacks:ft,setSolanaRecoveryFlowState:k,solanaWallet:p,setSolanaWallet:m});Qt({client:I,createWalletCallbacks:re,recoverWalletCallbacks:je,setWalletRecoveryCallbacks:ze,recoveryFlowState:g,oAuthState:v,setRecoveryFlowState:b,setWallet:u,appStateVisible:t});let{customAuthStateIsSettled:Kr}=$t({client:I,isReady:r}),qr=z();return ee.createElement(ee.Fragment,null,ee.createElement(f.Provider,{value:{client:I,isReady:qr&&r&&Kr,error:s,logout:Nr,getAccessToken:jr,getIdentityToken:zr,wallet:_(_({},c),Vr),solanaWallet:_(_({},p),Gr),oAuthState:v,recoveryFlowState:g,setRecoveryFlowState:b,solanaRecoveryFlowState:C,setSolanaRecoveryFlowState:k,createWalletCallbacks:re,recoverWalletCallbacks:je,setWalletRecoveryCallbacks:ze,createSolanaWalletCallbacks:yt,recoverSolanaWalletCallbacks:ft,setOAuthState:y,siweState:A,setSiweState:P,otpState:w,setOtpState:h,passkeyState:T,setPasskeyState:ge,farcasterState:he,setFarcasterState:Ne}},e.children,ee.createElement(Mr,{disabled:(wt=(ht=(gt=e.config)==null?void 0:gt.embedded)==null?void 0:ht.disableAutomaticMigration)!=null?wt:!1})),ee.createElement(Os,{style:{width:0,height:0,overflow:"hidden"}},ee.createElement(It,{client:I,isClientReady:a})))},Ls=()=>{if(Is(f))throw new Dr({code:"configuration_error",error:"Found multiple instances of PrivyProvider, ensure there is only one mounted in your application tree."})};var qg=e=>{let{client:t,setSiweState:o,siweState:r}=Ms(f),i=mt(a=>{var c;let d=E(a);return o({status:"error",error:d}),(c=e==null?void 0:e.onError)==null||c.call(e,d),d},[e==null?void 0:e.onError]),s=mt(u=>l(void 0,[u],function*({wallet:a,from:{domain:d,uri:c}}){var p;try{o({status:"generating-message"});let m=yield t.auth.siwe.init(a,d,c);return o({status:"awaiting-signature"}),(p=e==null?void 0:e.onGenerateMessage)==null||p.call(e,m.message),m.message}catch(m){throw i(m)}}),[t,i,e==null?void 0:e.onGenerateMessage]),n=mt(c=>l(void 0,[c],function*({signature:a,messageOverride:d}){var u;try{if(!S())throw new Ts({code:"attempted_link_siwe_before_logged_in",error:"Must be logged in to link a wallet, Use `useLoginWithSiwe` to login with a wallet"});o({status:"submitting-signature"});let{user:m}=yield t.auth.siwe.linkWithSiwe(a,void 0,d);return o({status:"done"}),(u=e==null?void 0:e.onSuccess)==null||u.call(e,m),m}catch(p){throw i(p)}}),[t,i,e==null?void 0:e.onSuccess]);return{generateSiweMessage:s,linkWithSiwe:n,state:r}};export{x as a,S as b,Zs as c,U as d,ea as e,$r as f,We as g,E as h,J as i,kt as j,qg as k,qc as l,W as m,rd as n,ud as o,vd as p,Ad as q,Od as r,Vd as s,Qd as t,il as u,ml as v,vl as w,xl as x,Dl as y,Kl as z,$l as A,tu as B,lu as C,gu as D,Cu as E,Pu as F,zu as G,$u as H,op as I,lp as J,hp as K,kp as L,Lp as M,it as N,Vp as O,Bp as P,em as Q,sm as R,bi as S,at as T,km as U,Rm as V,Tm as W,zm as X,Jm as Y,lt as Z,Di as _,Vi as $,pt as aa,qi as ba,Ji as ca,Py as da,ss as ea,ds as fa,ms as ga,hs as ha,vs as ia,Ss as ja,Lr as ka,f as la,Tg as ma,Fg as na};
@@ -1 +1 @@
1
- import{a as R,b as N,g as B,h as T,la as D}from"./chunk-WFA766DT.js";import{b as E,c as P,d as F,e as l}from"./chunk-K5SPDXVF.js";import*as O from"expo-linking";import{useCallback as q,useContext as tt,useEffect as et,useRef as it}from"react";import{Platform as ot}from"react-native";import{PrivyClientError as W}from"@privy-io/js-sdk-core";import{PrivyClientError as X}from"@privy-io/js-sdk-core";import{PrivyClientError as K}from"@privy-io/js-sdk-core";function M(){return l(this,null,function*(){B("expo-apple-authentication");try{return yield import("expo-apple-authentication")}catch(t){throw new K({code:"configuration_error",error:"`expo-apple-authentication` is not installed. Install it and rebuild the native app."})}})}function H(u){return l(this,arguments,function*({oauthProviderUrl:t,isLogin:i}){try{let o=yield M();return yield o.signInAsync({state:Y(t),requestedScopes:[o.AppleAuthenticationScope.EMAIL,o.AppleAuthenticationScope.FULL_NAME]})}catch(o){throw o instanceof Error&&"code"in o&&o.code==="ERR_REQUEST_CANCELED"?new X({error:"Apple login was cancelled",code:i?"login_with_oauth_was_cancelled_by_user":"link_with_oauth_was_cancelled_by_user"}):o}})}function Y(t){var u;return(u=new URL(t).searchParams.get("state"))!=null?u:""}import{Platform as Z}from"react-native";function z(t){return Z.select({android:t.replace("x.com","twitter.com"),default:t})}import*as Q from"expo-linking";import*as m from"expo-web-browser";import{PrivyClientError as j}from"@privy-io/js-sdk-core";function V(o){return l(this,arguments,function*({oauthProviderUrl:t,isLogin:i,returnUrl:u}){var a,p;let n=yield m.openAuthSessionAsync(t,u,{createTask:!1});if(n.type===m.WebBrowserResultType.CANCEL||n.type===m.WebBrowserResultType.DISMISS)throw new j({error:"OAuth was cancelled",code:i?"login_with_oauth_was_cancelled_by_user":"link_with_oauth_was_cancelled_by_user"});if(n.type!=="success")throw new j({error:"OAuth session failed",code:i?"failed_to_complete_login_with_oauth":"failed_to_complete_link_with_oauth"});let r=Q.parse(n.url).queryParams;return{authorizationCode:(a=r==null?void 0:r.privy_oauth_code)!=null?a:null,state:(p=r==null?void 0:r.privy_oauth_state)!=null?p:null,resultUrl:n.url}})}var $=(u={})=>{var o=u,{action:t}=o,i=F(o,["action"]);let{oAuthState:n,setOAuthState:r,client:a}=tt(D),p=it(i);return et(()=>{p.current=i},[i]),{start:q(function(Nt){return l(this,arguments,function*({provider:c,redirectUri:d,isLegacyAppleIosBehaviorEnabled:G=!1,disableSignup:J,onAppleOAuthUserInfo:S}){var C,U,L,v;r({status:"loading"});let y=N(),g=t?t==="login":!!!y;try{if(y&&t==="login"&&!a.isMultiUserModeEnabled)throw new W({code:"attempted_login_with_oauth_while_already_logged_in",error:"Already logged in, if trying to link an OAuth account use `useLinkWithOAuth`"});if(!y&&t==="link")throw new W({code:"attempted_link_oauth_before_logged_in",error:"Must be logged in to link an OAuth account, use `useLoginWithOAuth`"});if(__DEV__&&d!=null&&d.includes("://")){let e=d.split("://")[0];console.warn(`redirectUri includes a scheme prefix (${e}://), it should be a path instead, such as '/authenticated'`)}let w=O.createURL(d||"/"),{url:s}=yield a.auth.oauth.generateURL(c,w);c==="twitter"&&(s=z(s));let h,b,A,f,I,k,_;if(ot.OS==="ios"&&c==="apple"&&!G){let e=yield H({oauthProviderUrl:s,isLogin:g});A=e.authorizationCode,f=e.state,_=e,I="raw"}else{let e=yield V({oauthProviderUrl:s,isLogin:g,returnUrl:w});A=e.authorizationCode,f=e.state,k=e.resultUrl}if(!A||!f)throw new W({error:"OAuth invalid credentials",code:g?"login_with_oauth_returned_with_invalid_credentials":"link_with_oauth_returned_with_invalid_credentials"});if(g){let e=R(),x=yield a.auth.oauth.loginWithCode(A,f,c,I,J?"no-signup":"login-or-sign-up",{embedded:e==null?void 0:e.embedded});h=x.user,b=x.is_new_user}else({user:h}=yield a.auth.oauth.linkWithCode(A,f,c,I));return _&&S&&S({fullName:_.fullName,email:_.email}),(U=(C=p.current).onSuccess)==null||U.call(C,h,b),k&&(yield O.openURL(k.split("?")[0])),r({status:"done",isNewUser:b}),h!=null?h:void 0}catch(w){let s=T(w);throw r({status:"error",error:s}),(v=(L=p.current).onError)==null||v.call(L,s),s}})},[a.auth.oauth,t,r]),state:n}};function Pt(t){let{state:i,start:u}=$(P(E({},t),{action:"login"}));return{state:i,login:u}}export{$ as a,Pt as b};
1
+ import{a as R,b as N,g as B,h as T,la as D}from"./chunk-6LJTXHKE.js";import{b as E,c as P,d as F,e as l}from"./chunk-C5WYSLQF.js";import*as O from"expo-linking";import{useCallback as q,useContext as tt,useEffect as et,useRef as it}from"react";import{Platform as ot}from"react-native";import{PrivyClientError as W}from"@privy-io/js-sdk-core";import{PrivyClientError as X}from"@privy-io/js-sdk-core";import{PrivyClientError as K}from"@privy-io/js-sdk-core";function M(){return l(this,null,function*(){B("expo-apple-authentication");try{return yield import("expo-apple-authentication")}catch(t){throw new K({code:"configuration_error",error:"`expo-apple-authentication` is not installed. Install it and rebuild the native app."})}})}function H(u){return l(this,arguments,function*({oauthProviderUrl:t,isLogin:i}){try{let o=yield M();return yield o.signInAsync({state:Y(t),requestedScopes:[o.AppleAuthenticationScope.EMAIL,o.AppleAuthenticationScope.FULL_NAME]})}catch(o){throw o instanceof Error&&"code"in o&&o.code==="ERR_REQUEST_CANCELED"?new X({error:"Apple login was cancelled",code:i?"login_with_oauth_was_cancelled_by_user":"link_with_oauth_was_cancelled_by_user"}):o}})}function Y(t){var u;return(u=new URL(t).searchParams.get("state"))!=null?u:""}import{Platform as Z}from"react-native";function z(t){return Z.select({android:t.replace("x.com","twitter.com"),default:t})}import*as Q from"expo-linking";import*as m from"expo-web-browser";import{PrivyClientError as j}from"@privy-io/js-sdk-core";function V(o){return l(this,arguments,function*({oauthProviderUrl:t,isLogin:i,returnUrl:u}){var a,p;let n=yield m.openAuthSessionAsync(t,u,{createTask:!1});if(n.type===m.WebBrowserResultType.CANCEL||n.type===m.WebBrowserResultType.DISMISS)throw new j({error:"OAuth was cancelled",code:i?"login_with_oauth_was_cancelled_by_user":"link_with_oauth_was_cancelled_by_user"});if(n.type!=="success")throw new j({error:"OAuth session failed",code:i?"failed_to_complete_login_with_oauth":"failed_to_complete_link_with_oauth"});let r=Q.parse(n.url).queryParams;return{authorizationCode:(a=r==null?void 0:r.privy_oauth_code)!=null?a:null,state:(p=r==null?void 0:r.privy_oauth_state)!=null?p:null,resultUrl:n.url}})}var $=(u={})=>{var o=u,{action:t}=o,i=F(o,["action"]);let{oAuthState:n,setOAuthState:r,client:a}=tt(D),p=it(i);return et(()=>{p.current=i},[i]),{start:q(function(Nt){return l(this,arguments,function*({provider:c,redirectUri:d,isLegacyAppleIosBehaviorEnabled:G=!1,disableSignup:J,onAppleOAuthUserInfo:S}){var C,U,L,v;r({status:"loading"});let y=N(),g=t?t==="login":!!!y;try{if(y&&t==="login"&&!a.isMultiUserModeEnabled)throw new W({code:"attempted_login_with_oauth_while_already_logged_in",error:"Already logged in, if trying to link an OAuth account use `useLinkWithOAuth`"});if(!y&&t==="link")throw new W({code:"attempted_link_oauth_before_logged_in",error:"Must be logged in to link an OAuth account, use `useLoginWithOAuth`"});if(__DEV__&&d!=null&&d.includes("://")){let e=d.split("://")[0];console.warn(`redirectUri includes a scheme prefix (${e}://), it should be a path instead, such as '/authenticated'`)}let w=O.createURL(d||"/"),{url:s}=yield a.auth.oauth.generateURL(c,w);c==="twitter"&&(s=z(s));let h,b,A,f,I,k,_;if(ot.OS==="ios"&&c==="apple"&&!G){let e=yield H({oauthProviderUrl:s,isLogin:g});A=e.authorizationCode,f=e.state,_=e,I="raw"}else{let e=yield V({oauthProviderUrl:s,isLogin:g,returnUrl:w});A=e.authorizationCode,f=e.state,k=e.resultUrl}if(!A||!f)throw new W({error:"OAuth invalid credentials",code:g?"login_with_oauth_returned_with_invalid_credentials":"link_with_oauth_returned_with_invalid_credentials"});if(g){let e=R(),x=yield a.auth.oauth.loginWithCode(A,f,c,I,J?"no-signup":"login-or-sign-up",{embedded:e==null?void 0:e.embedded});h=x.user,b=x.is_new_user}else({user:h}=yield a.auth.oauth.linkWithCode(A,f,c,I));return _&&S&&S({fullName:_.fullName,email:_.email}),(U=(C=p.current).onSuccess)==null||U.call(C,h,b),k&&(yield O.openURL(k.split("?")[0])),r({status:"done",isNewUser:b}),h!=null?h:void 0}catch(w){let s=T(w);throw r({status:"error",error:s}),(v=(L=p.current).onError)==null||v.call(L,s),s}})},[a.auth.oauth,t,r]),state:n}};function Pt(t){let{state:i,start:u}=$(P(E({},t),{action:"login"}));return{state:i,login:u}}export{$ as a,Pt as b};
@@ -0,0 +1 @@
1
+ var o=Object.defineProperty,p=Object.defineProperties;var q=Object.getOwnPropertyDescriptors;var f=Object.getOwnPropertySymbols;var k=Object.prototype.hasOwnProperty,l=Object.prototype.propertyIsEnumerable;var r=Math.pow,j=(a,c,b)=>c in a?o(a,c,{enumerable:!0,configurable:!0,writable:!0,value:b}):a[c]=b,s=(a,c)=>{for(var b in c||(c={}))k.call(c,b)&&j(a,b,c[b]);if(f)for(var b of f(c))l.call(c,b)&&j(a,b,c[b]);return a},t=(a,c)=>p(a,q(c));var u=(a,c)=>{var b={};for(var d in a)k.call(a,d)&&c.indexOf(d)<0&&(b[d]=a[d]);if(a!=null&&f)for(var d of f(a))c.indexOf(d)<0&&l.call(a,d)&&(b[d]=a[d]);return b};var v=(a,c,b)=>new Promise((d,i)=>{var m=e=>{try{g(b.next(e))}catch(h){i(h)}},n=e=>{try{g(b.throw(e))}catch(h){i(h)}},g=e=>e.done?d(e.value):Promise.resolve(e.value).then(m,n);g((b=b.apply(a,c)).next())});export{r as a,s as b,t as c,u as d,v as e};
@@ -1,4 +1,4 @@
1
- import{la as Ce}from"./chunk-WFA766DT.js";import{b as r,c as U,d as m}from"./chunk-K5SPDXVF.js";var C=class extends Error{constructor(o,u){super(u);this.code=o,this.error=u}},he=class extends C{constructor(o){super("underlying_error",o instanceof Error?o.message:"An underlying error occurred");this.wrappedError=o}};import qe,{useContext as ve}from"react";import{useMemo as Ue}from"react";import{createContext as be}from"react";var O=be(void 0);var ge="#5B4FFF";function Se({colorScheme:a,accentHex:t}){return a==="dark"?{interactive:t,background:"#22222A",backgroundSecondary:"#010110",backgroundInformation:"#1E1B4B",backgroundTertiary:"#010110",backgroundHighlight:"#052E16",text:"#ffffff",textPlaceholder:"#9498B8",textMuted:"#FFFFFF",textHighlight:"#BBF7D0",textTitle:"#FFFFFF",textInteractive:"#FFFFFF",icon:"#FFFFFF",iconInformation:"#818CF8",iconSubtle:"#919191",privyBrand:"#FFFFFF",success:"#4ADE80",successLight:"#C5F7D7",border:"#474869",borderInformation:"#818CF8",error:"#FCA5A5",errorDark:"#EF4444"}:{interactive:t,background:"#FFFFFF",backgroundSecondary:"#F3F3F3",backgroundInformation:"#E0E7FF",backgroundTertiary:"#FFFFFF",backgroundHighlight:"#F1F2F9",text:"#040217",textPlaceholder:"#9498B8",textMuted:"#64668B",textHighlight:"#64668B",textTitle:"#1A1C29",textInteractive:"#FFFFFF",icon:"#110F2A",iconSubtle:"#9498B8",iconInformation:"#4F46E5",privyBrand:"#010110",success:"#16A34A",successLight:"#DCFCE7",border:"#E2E3F0",borderInformation:"#5B4FFF",error:"#EF4444",errorDark:"#B91C1C"}}function ke({colorScheme:a,accentHex:t}){return{colors:Se({colorScheme:a,accentHex:t}),colorScheme:a}}function Oe({children:a,appearance:t={}}){let{colorScheme:o="light",accentColor:u}=t,{isReady:d,client:l}=ve(Ce),f=Ue(()=>{var B,L;let s=d?l.app.getConfig():void 0,i=(B=s==null?void 0:s.accent_color)!=null?B:void 0;return ke({colorScheme:o,accentHex:(L=u!=null?u:i)!=null?L:ge})},[o,u,d,l]);return qe.createElement(O.Provider,{value:f},a)}import{useContext as He}from"react";var n=()=>{let a=He(O);if(a===void 0)throw new Error("Components calling useTheme must be wrapped in an ElementsThemeProvider");return a};import{useEffect as Ee}from"react";import{useStore as Ve}from"zustand";import{createStore as Ge}from"zustand/vanilla";var H=Ge()(a=>({elementsConfig:null,updateUIMounted:t=>a({elementsConfig:t})})),Ra=()=>{let{elementsConfig:a}=H.getState();if(!(a!==null))throw new C("privy_elements_not_ready","Privy Elements is not mounted")},ba=()=>{let{elementsConfig:a}=H.getState();if(a===null)throw new C("privy_elements_not_ready","Privy Elements is not mounted");return a},qa=()=>Ve(H,a=>{var t;return(t=a.elementsConfig)==null?void 0:t.appearance}),va=a=>{Ee(()=>{let{updateUIMounted:t}=H.getState();return t(a),()=>{t(null)}},[a])};var we={regular:"Inter_400Regular",medium:"Inter_500Medium",semibold:"Inter_600SemiBold"};import h from"react";import{View as We,Text as Pe,StyleSheet as ze}from"react-native";var Xe=h.forwardRef((d,u)=>{var l=d,{style:a,variant:t="default"}=l,o=m(l,["style","variant"]);let{colors:f}=n();return h.createElement(We,r({ref:u,style:[E.alert,t==="info"&&{backgroundColor:f.backgroundInformation,borderColor:f.borderInformation},a]},o))});Xe.displayName="Alert";var Ne=h.forwardRef((u,o)=>{var d=u,{style:a}=d,t=m(d,["style"]);let{colors:l}=n();return h.createElement(Pe,r({ref:o,style:[E.title,{color:l.text},a]},t))});Ne.displayName="AlertTitle";var _e=h.forwardRef((u,o)=>{var d=u,{style:a}=d,t=m(d,["style"]);let{colors:l}=n();return h.createElement(Pe,r({ref:o,style:[E.description,{color:l.text},a]},t))});_e.displayName="AlertDescription";var E=ze.create({alert:{borderRadius:8,alignItems:"center",gap:12,paddingHorizontal:12,paddingVertical:8,flexDirection:"row"},title:{marginBottom:4,fontFamily:we.semibold,fontSize:16},description:{fontSize:14,lineHeight:20}});import{forwardRef as Ke,createElement as ye}from"react";import*as V from"react-native-svg";var I={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},Ae={fill:I.fill,stroke:I.stroke,strokeWidth:I.strokeWidth,strokeLinecap:I.strokeLinecap,strokeLinejoin:I.strokeLinejoin};var e=(a,t)=>{let o=Ke((p,L)=>{var M=p,{color:u="currentColor",size:d=24,strokeWidth:l=2,absoluteStrokeWidth:f,children:s,"data-testid":i}=M,B=m(M,["color","size","strokeWidth","absoluteStrokeWidth","children","data-testid"]);let v=r({stroke:u,strokeWidth:f?Number(l)*24/Number(d):l},B);return ye(V.Svg,r(U(r({ref:L},I),{width:d,height:d,"data-testid":i}),v),[...t.map(([D,Te])=>{let Re=D.charAt(0).toUpperCase()+D.slice(1);return ye(V[Re],r(r(r({},Ae),v),Te))}),...(Array.isArray(s)?s:[s])||[]])});return o.displayName=`${a}`,o};var G=e("ArrowLeftRight",[["path",{d:"M8 3 4 7l4 4",key:"9rb6wj"}],["path",{d:"M4 7h16",key:"6tx8e3"}],["path",{d:"m16 21 4-4-4-4",key:"siv7j2"}],["path",{d:"M20 17H4",key:"h6l3hr"}]]);var T=e("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);var W=e("Ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]]);var g=e("ChartLine",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]]);var z=e("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);var X=e("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);var N=e("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);var S=e("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);var k=e("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);var w=e("CircleHelp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);var P=e("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);var _=e("Clock10",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 8 10",key:"atfzqc"}]]);var A=e("CloudUpload",[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"m8 17 4-4 4 4",key:"1quai1"}]]);var K=e("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);var Z=e("CreditCard",[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]]);var J=e("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);var Q=e("EyeOff",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);var j=e("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);var Y=e("FileCheck",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m9 15 2 2 4-4",key:"1grp1n"}]]);var y=e("FilePen",[["path",{d:"M12.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v9.5",key:"1couwa"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M13.378 15.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"1y4qbx"}]]);var $=e("Files",[["path",{d:"M20 7h-3a2 2 0 0 1-2-2V2",key:"x099mo"}],["path",{d:"M9 18a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h7l4 4v10a2 2 0 0 1-2 2Z",key:"18t6ie"}],["path",{d:"M3 7.6v12.8A1.6 1.6 0 0 0 4.6 22h9.8",key:"1nja0z"}]]);var ee=e("Fingerprint",[["path",{d:"M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4",key:"1nerag"}],["path",{d:"M14 13.12c0 2.38 0 6.38-1 8.88",key:"o46ks0"}],["path",{d:"M17.29 21.02c.12-.6.43-2.3.5-3.02",key:"ptglia"}],["path",{d:"M2 12a10 10 0 0 1 18-6",key:"ydlgp0"}],["path",{d:"M2 16h.01",key:"1gqxmh"}],["path",{d:"M21.8 16c.2-2 .131-5.354 0-6",key:"drycrb"}],["path",{d:"M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2",key:"1tidbn"}],["path",{d:"M8.65 22c.21-.66.45-1.32.57-2",key:"13wd9y"}],["path",{d:"M9 6.8a6 6 0 0 1 9 5.2v2",key:"1fr1j5"}]]);var ae=e("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);var te=e("LogIn",[["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}],["polyline",{points:"10 17 15 12 10 7",key:"1ail0h"}],["line",{x1:"15",x2:"3",y1:"12",y2:"12",key:"v6grx8"}]]);var oe=e("Mail",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]]);var ue=e("Phone",[["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]]);var de=e("QrCode",[["rect",{width:"5",height:"5",x:"3",y:"3",rx:"1",key:"1tu5fj"}],["rect",{width:"5",height:"5",x:"16",y:"3",rx:"1",key:"1v8r4q"}],["rect",{width:"5",height:"5",x:"3",y:"16",rx:"1",key:"1x03jg"}],["path",{d:"M21 16h-3a2 2 0 0 0-2 2v3",key:"177gqh"}],["path",{d:"M21 21v.01",key:"ents32"}],["path",{d:"M12 7v3a2 2 0 0 1-2 2H7",key:"8crl2c"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M12 3h.01",key:"n36tog"}],["path",{d:"M12 16v.01",key:"133mhm"}],["path",{d:"M16 12h1",key:"1slzba"}],["path",{d:"M21 12v.01",key:"1lwtk9"}],["path",{d:"M12 21v-1",key:"1880an"}]]);var le=e("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);var re=e("ScanFace",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["path",{d:"M8 14s1.5 2 4 2 4-2 4-2",key:"1y1vjs"}],["path",{d:"M9 9h.01",key:"1q5me6"}],["path",{d:"M15 9h.01",key:"x1ddxp"}]]);var fe=e("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);var se=e("ShieldAlert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]);var ie=e("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);var ce=e("Smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]);var ne=e("Store",[["path",{d:"m2 7 4.41-4.41A2 2 0 0 1 7.83 2h8.34a2 2 0 0 1 1.42.59L22 7",key:"ztvudi"}],["path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8",key:"1b2hhj"}],["path",{d:"M15 22v-4a2 2 0 0 0-2-2h-2a2 2 0 0 0-2 2v4",key:"2ebpfo"}],["path",{d:"M2 7h20",key:"1fcdvo"}],["path",{d:"M22 7v3a2 2 0 0 1-2 2a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 16 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 12 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 8 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 4 12a2 2 0 0 1-2-2V7",key:"6c3vgh"}]]);var pe=e("UserCheck",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["polyline",{points:"16 11 18 13 22 9",key:"1pwet4"}]]);var R=e("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);import c from"react";import{Pressable as Fe,StyleSheet as Ze,View as b}from"react-native";var au=({goBack:a,close:t})=>c.createElement(b,{style:me.navigationBar},c.createElement(b,null,a&&c.createElement(Je,{onPress:a})),c.createElement(b,null,t&&c.createElement(Qe,{onPress:t}))),Je=a=>{let{colors:t}=n();return c.createElement(Fe,r({accessibilityRole:"button",accessibilityLabel:"Back"},a),c.createElement(b,{style:me.backButton},c.createElement(T,{size:24,color:t.icon})))},Qe=a=>{let{colors:t}=n();return c.createElement(Fe,r({accessibilityRole:"button",accessibilityLabel:"Close"},a),c.createElement(b,{style:me.backButton},c.createElement(R,{size:24,color:t.icon})))},me=Ze.create({navigationBar:{height:48,flexDirection:"row",justifyContent:"space-between"},backButton:{width:48,height:48,justifyContent:"center",alignItems:"center"}});import{create as je}from"zustand";var Le=je(()=>null),Ye=()=>{var t;let a=(t=Le.getState())==null?void 0:t.controller;return!a||a.signal.aborted?null:a},du=()=>{var a;(a=Ye())==null||a.abort(),Le.setState(null)},lu=a=>{Le.setState(t=>t&&{step:a})};import x from"react";import{View as Me,Text as ua,Pressable as da,StyleSheet as la}from"react-native";import Ie,{useEffect as $e}from"react";import{Animated as xe,Easing as ea,useAnimatedValue as aa}from"react-native";import ta,{Path as oa}from"react-native-svg";var Be=({color:a})=>{let t=aa(0);$e(()=>{t.setValue(0);let u=xe.loop(xe.timing(t,{toValue:1,duration:1200,useNativeDriver:!0,easing:ea.linear}));return u.start(),()=>u.stop()},[t]);let o=t.interpolate({inputRange:[0,1],outputRange:["0deg","360deg"]});return Ie.createElement(xe.View,{style:{transform:[{rotate:o}]}},Ie.createElement(ta,{width:20,height:20,viewBox:"0 0 20 20",fill:"none"},Ie.createElement(oa,{d:"M19 10a9 9 0 11-6.219-8.56",stroke:a,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})))};var Iu=B=>{var L=B,{variant:a="primary",title:t,destroy:o=!1,loading:u=!1,LeftIcon:d,RightIcon:l,color:f,style:s}=L,i=m(L,["variant","title","destroy","loading","LeftIcon","RightIcon","color","style"]);let{colors:p}=n(),M=o?p.errorDark:p.interactive,v={primary:M,secondary:p.backgroundTertiary,tertiary:p.background}[a],D={primary:p.textInteractive,secondary:p.text,tertiary:M}[a];return x.createElement(da,U(r({},i),{disabled:i.disabled||u}),x.createElement(Me,{style:[q.buttonBox,{backgroundColor:v},a==="secondary"&&q.buttonBoxSecondary,a==="secondary"&&{borderColor:p.border},s]},u?x.createElement(Be,{color:f!=null?f:D}):x.createElement(x.Fragment,null,d,x.createElement(ua,{style:[q.buttonLabel,{color:f!=null?f:D},a==="secondary"&&q.buttonLabelSecondary,a==="tertiary"&&q.buttonLabelTertiary]},t),!!l&&x.createElement(Me,{style:{marginLeft:"auto"}},l))))},q=la.create({buttonBox:{height:54,flexDirection:"row",justifyContent:"center",alignItems:"center",borderRadius:14,paddingHorizontal:16,gap:12},buttonBoxSecondary:{justifyContent:"flex-start",borderWidth:1,borderRadius:12},buttonLabel:{fontFamily:"Inter_600SemiBold",fontSize:16,lineHeight:24},buttonLabelSecondary:{fontFamily:"Inter_400Regular"},buttonLabelTertiary:{fontFamily:"Inter_500Medium"}});import*as F from"expo-web-browser";import{AppState as ra,Platform as De}from"react-native";var gu=a=>{if(!a)return null;try{return new URL(a).protocol==="https:"?a:null}catch(t){return null}},Su=a=>{let t=!1,o=!1,u=null;function d(){o=!0,u==null||u.remove()}function l(f){if(t||o)return;t=!0;let s=!1;u=De.OS==="android"?ra.addEventListener("change",i=>{i==="background"&&(s=!0),i==="active"&&s&&d()}):null,F.openBrowserAsync(f,{createTask:!1}).then(i=>{i.type!==F.WebBrowserResultType.OPENED&&d()}).catch(d)}return a&&l(a),{navigate:l,isClosed:()=>o,dismiss:()=>{o||(d(),t&&De.OS==="ios"&&F.dismissBrowser().catch(()=>{}))}}};export{Oe as a,n as b,Iu as c,G as d,W as e,g as f,z as g,X as h,N as i,S as j,k,w as l,P as m,_ as n,A as o,K as p,Z as q,J as r,Q as s,j as t,Y as u,y as v,$ as w,ee as x,ae as y,te as z,oe as A,ue as B,de as C,le as D,re as E,fe as F,se as G,ie as H,ce as I,ne as J,pe as K,C as L,he as M,Ra as N,ba as O,qa as P,va as Q,we as R,Xe as S,_e as T,au as U,gu as V,Su as W,Le as X,Ye as Y,du as Z,lu as _};
1
+ import{la as Ce}from"./chunk-6LJTXHKE.js";import{b as r,c as U,d as m}from"./chunk-C5WYSLQF.js";var C=class extends Error{constructor(o,u){super(u);this.code=o,this.error=u}},he=class extends C{constructor(o){super("underlying_error",o instanceof Error?o.message:"An underlying error occurred");this.wrappedError=o}};import qe,{useContext as ve}from"react";import{useMemo as Ue}from"react";import{createContext as be}from"react";var O=be(void 0);var ge="#5B4FFF";function Se({colorScheme:a,accentHex:t}){return a==="dark"?{interactive:t,background:"#22222A",backgroundSecondary:"#010110",backgroundInformation:"#1E1B4B",backgroundTertiary:"#010110",backgroundHighlight:"#052E16",text:"#ffffff",textPlaceholder:"#9498B8",textMuted:"#FFFFFF",textHighlight:"#BBF7D0",textTitle:"#FFFFFF",textInteractive:"#FFFFFF",icon:"#FFFFFF",iconInformation:"#818CF8",iconSubtle:"#919191",privyBrand:"#FFFFFF",success:"#4ADE80",successLight:"#C5F7D7",border:"#474869",borderInformation:"#818CF8",error:"#FCA5A5",errorDark:"#EF4444"}:{interactive:t,background:"#FFFFFF",backgroundSecondary:"#F3F3F3",backgroundInformation:"#E0E7FF",backgroundTertiary:"#FFFFFF",backgroundHighlight:"#F1F2F9",text:"#040217",textPlaceholder:"#9498B8",textMuted:"#64668B",textHighlight:"#64668B",textTitle:"#1A1C29",textInteractive:"#FFFFFF",icon:"#110F2A",iconSubtle:"#9498B8",iconInformation:"#4F46E5",privyBrand:"#010110",success:"#16A34A",successLight:"#DCFCE7",border:"#E2E3F0",borderInformation:"#5B4FFF",error:"#EF4444",errorDark:"#B91C1C"}}function ke({colorScheme:a,accentHex:t}){return{colors:Se({colorScheme:a,accentHex:t}),colorScheme:a}}function Oe({children:a,appearance:t={}}){let{colorScheme:o="light",accentColor:u}=t,{isReady:d,client:l}=ve(Ce),f=Ue(()=>{var B,L;let s=d?l.app.getConfig():void 0,i=(B=s==null?void 0:s.accent_color)!=null?B:void 0;return ke({colorScheme:o,accentHex:(L=u!=null?u:i)!=null?L:ge})},[o,u,d,l]);return qe.createElement(O.Provider,{value:f},a)}import{useContext as He}from"react";var n=()=>{let a=He(O);if(a===void 0)throw new Error("Components calling useTheme must be wrapped in an ElementsThemeProvider");return a};import{useEffect as Ee}from"react";import{useStore as Ve}from"zustand";import{createStore as Ge}from"zustand/vanilla";var H=Ge()(a=>({elementsConfig:null,updateUIMounted:t=>a({elementsConfig:t})})),Ra=()=>{let{elementsConfig:a}=H.getState();if(!(a!==null))throw new C("privy_elements_not_ready","Privy Elements is not mounted")},ba=()=>{let{elementsConfig:a}=H.getState();if(a===null)throw new C("privy_elements_not_ready","Privy Elements is not mounted");return a},qa=()=>Ve(H,a=>{var t;return(t=a.elementsConfig)==null?void 0:t.appearance}),va=a=>{Ee(()=>{let{updateUIMounted:t}=H.getState();return t(a),()=>{t(null)}},[a])};var we={regular:"Inter_400Regular",medium:"Inter_500Medium",semibold:"Inter_600SemiBold"};import h from"react";import{View as We,Text as Pe,StyleSheet as ze}from"react-native";var Xe=h.forwardRef((d,u)=>{var l=d,{style:a,variant:t="default"}=l,o=m(l,["style","variant"]);let{colors:f}=n();return h.createElement(We,r({ref:u,style:[E.alert,t==="info"&&{backgroundColor:f.backgroundInformation,borderColor:f.borderInformation},a]},o))});Xe.displayName="Alert";var Ne=h.forwardRef((u,o)=>{var d=u,{style:a}=d,t=m(d,["style"]);let{colors:l}=n();return h.createElement(Pe,r({ref:o,style:[E.title,{color:l.text},a]},t))});Ne.displayName="AlertTitle";var _e=h.forwardRef((u,o)=>{var d=u,{style:a}=d,t=m(d,["style"]);let{colors:l}=n();return h.createElement(Pe,r({ref:o,style:[E.description,{color:l.text},a]},t))});_e.displayName="AlertDescription";var E=ze.create({alert:{borderRadius:8,alignItems:"center",gap:12,paddingHorizontal:12,paddingVertical:8,flexDirection:"row"},title:{marginBottom:4,fontFamily:we.semibold,fontSize:16},description:{fontSize:14,lineHeight:20}});import{forwardRef as Ke,createElement as ye}from"react";import*as V from"react-native-svg";var I={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},Ae={fill:I.fill,stroke:I.stroke,strokeWidth:I.strokeWidth,strokeLinecap:I.strokeLinecap,strokeLinejoin:I.strokeLinejoin};var e=(a,t)=>{let o=Ke((p,L)=>{var M=p,{color:u="currentColor",size:d=24,strokeWidth:l=2,absoluteStrokeWidth:f,children:s,"data-testid":i}=M,B=m(M,["color","size","strokeWidth","absoluteStrokeWidth","children","data-testid"]);let v=r({stroke:u,strokeWidth:f?Number(l)*24/Number(d):l},B);return ye(V.Svg,r(U(r({ref:L},I),{width:d,height:d,"data-testid":i}),v),[...t.map(([D,Te])=>{let Re=D.charAt(0).toUpperCase()+D.slice(1);return ye(V[Re],r(r(r({},Ae),v),Te))}),...(Array.isArray(s)?s:[s])||[]])});return o.displayName=`${a}`,o};var G=e("ArrowLeftRight",[["path",{d:"M8 3 4 7l4 4",key:"9rb6wj"}],["path",{d:"M4 7h16",key:"6tx8e3"}],["path",{d:"m16 21 4-4-4-4",key:"siv7j2"}],["path",{d:"M20 17H4",key:"h6l3hr"}]]);var T=e("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);var W=e("Ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]]);var g=e("ChartLine",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]]);var z=e("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);var X=e("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);var N=e("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);var S=e("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);var k=e("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);var w=e("CircleHelp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);var P=e("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);var _=e("Clock10",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 8 10",key:"atfzqc"}]]);var A=e("CloudUpload",[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"m8 17 4-4 4 4",key:"1quai1"}]]);var K=e("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);var Z=e("CreditCard",[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]]);var J=e("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);var Q=e("EyeOff",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);var j=e("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);var Y=e("FileCheck",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m9 15 2 2 4-4",key:"1grp1n"}]]);var y=e("FilePen",[["path",{d:"M12.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v9.5",key:"1couwa"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M13.378 15.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"1y4qbx"}]]);var $=e("Files",[["path",{d:"M20 7h-3a2 2 0 0 1-2-2V2",key:"x099mo"}],["path",{d:"M9 18a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h7l4 4v10a2 2 0 0 1-2 2Z",key:"18t6ie"}],["path",{d:"M3 7.6v12.8A1.6 1.6 0 0 0 4.6 22h9.8",key:"1nja0z"}]]);var ee=e("Fingerprint",[["path",{d:"M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4",key:"1nerag"}],["path",{d:"M14 13.12c0 2.38 0 6.38-1 8.88",key:"o46ks0"}],["path",{d:"M17.29 21.02c.12-.6.43-2.3.5-3.02",key:"ptglia"}],["path",{d:"M2 12a10 10 0 0 1 18-6",key:"ydlgp0"}],["path",{d:"M2 16h.01",key:"1gqxmh"}],["path",{d:"M21.8 16c.2-2 .131-5.354 0-6",key:"drycrb"}],["path",{d:"M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2",key:"1tidbn"}],["path",{d:"M8.65 22c.21-.66.45-1.32.57-2",key:"13wd9y"}],["path",{d:"M9 6.8a6 6 0 0 1 9 5.2v2",key:"1fr1j5"}]]);var ae=e("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);var te=e("LogIn",[["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}],["polyline",{points:"10 17 15 12 10 7",key:"1ail0h"}],["line",{x1:"15",x2:"3",y1:"12",y2:"12",key:"v6grx8"}]]);var oe=e("Mail",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]]);var ue=e("Phone",[["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]]);var de=e("QrCode",[["rect",{width:"5",height:"5",x:"3",y:"3",rx:"1",key:"1tu5fj"}],["rect",{width:"5",height:"5",x:"16",y:"3",rx:"1",key:"1v8r4q"}],["rect",{width:"5",height:"5",x:"3",y:"16",rx:"1",key:"1x03jg"}],["path",{d:"M21 16h-3a2 2 0 0 0-2 2v3",key:"177gqh"}],["path",{d:"M21 21v.01",key:"ents32"}],["path",{d:"M12 7v3a2 2 0 0 1-2 2H7",key:"8crl2c"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M12 3h.01",key:"n36tog"}],["path",{d:"M12 16v.01",key:"133mhm"}],["path",{d:"M16 12h1",key:"1slzba"}],["path",{d:"M21 12v.01",key:"1lwtk9"}],["path",{d:"M12 21v-1",key:"1880an"}]]);var le=e("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);var re=e("ScanFace",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["path",{d:"M8 14s1.5 2 4 2 4-2 4-2",key:"1y1vjs"}],["path",{d:"M9 9h.01",key:"1q5me6"}],["path",{d:"M15 9h.01",key:"x1ddxp"}]]);var fe=e("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);var se=e("ShieldAlert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]);var ie=e("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);var ce=e("Smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]);var ne=e("Store",[["path",{d:"m2 7 4.41-4.41A2 2 0 0 1 7.83 2h8.34a2 2 0 0 1 1.42.59L22 7",key:"ztvudi"}],["path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8",key:"1b2hhj"}],["path",{d:"M15 22v-4a2 2 0 0 0-2-2h-2a2 2 0 0 0-2 2v4",key:"2ebpfo"}],["path",{d:"M2 7h20",key:"1fcdvo"}],["path",{d:"M22 7v3a2 2 0 0 1-2 2a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 16 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 12 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 8 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 4 12a2 2 0 0 1-2-2V7",key:"6c3vgh"}]]);var pe=e("UserCheck",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["polyline",{points:"16 11 18 13 22 9",key:"1pwet4"}]]);var R=e("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);import c from"react";import{Pressable as Fe,StyleSheet as Ze,View as b}from"react-native";var au=({goBack:a,close:t})=>c.createElement(b,{style:me.navigationBar},c.createElement(b,null,a&&c.createElement(Je,{onPress:a})),c.createElement(b,null,t&&c.createElement(Qe,{onPress:t}))),Je=a=>{let{colors:t}=n();return c.createElement(Fe,r({accessibilityRole:"button",accessibilityLabel:"Back"},a),c.createElement(b,{style:me.backButton},c.createElement(T,{size:24,color:t.icon})))},Qe=a=>{let{colors:t}=n();return c.createElement(Fe,r({accessibilityRole:"button",accessibilityLabel:"Close"},a),c.createElement(b,{style:me.backButton},c.createElement(R,{size:24,color:t.icon})))},me=Ze.create({navigationBar:{height:48,flexDirection:"row",justifyContent:"space-between"},backButton:{width:48,height:48,justifyContent:"center",alignItems:"center"}});import{create as je}from"zustand";var Le=je(()=>null),Ye=()=>{var t;let a=(t=Le.getState())==null?void 0:t.controller;return!a||a.signal.aborted?null:a},du=()=>{var a;(a=Ye())==null||a.abort(),Le.setState(null)},lu=a=>{Le.setState(t=>t&&{step:a})};import x from"react";import{View as Me,Text as ua,Pressable as da,StyleSheet as la}from"react-native";import Ie,{useEffect as $e}from"react";import{Animated as xe,Easing as ea,useAnimatedValue as aa}from"react-native";import ta,{Path as oa}from"react-native-svg";var Be=({color:a})=>{let t=aa(0);$e(()=>{t.setValue(0);let u=xe.loop(xe.timing(t,{toValue:1,duration:1200,useNativeDriver:!0,easing:ea.linear}));return u.start(),()=>u.stop()},[t]);let o=t.interpolate({inputRange:[0,1],outputRange:["0deg","360deg"]});return Ie.createElement(xe.View,{style:{transform:[{rotate:o}]}},Ie.createElement(ta,{width:20,height:20,viewBox:"0 0 20 20",fill:"none"},Ie.createElement(oa,{d:"M19 10a9 9 0 11-6.219-8.56",stroke:a,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})))};var Iu=B=>{var L=B,{variant:a="primary",title:t,destroy:o=!1,loading:u=!1,LeftIcon:d,RightIcon:l,color:f,style:s}=L,i=m(L,["variant","title","destroy","loading","LeftIcon","RightIcon","color","style"]);let{colors:p}=n(),M=o?p.errorDark:p.interactive,v={primary:M,secondary:p.backgroundTertiary,tertiary:p.background}[a],D={primary:p.textInteractive,secondary:p.text,tertiary:M}[a];return x.createElement(da,U(r({},i),{disabled:i.disabled||u}),x.createElement(Me,{style:[q.buttonBox,{backgroundColor:v},a==="secondary"&&q.buttonBoxSecondary,a==="secondary"&&{borderColor:p.border},s]},u?x.createElement(Be,{color:f!=null?f:D}):x.createElement(x.Fragment,null,d,x.createElement(ua,{style:[q.buttonLabel,{color:f!=null?f:D},a==="secondary"&&q.buttonLabelSecondary,a==="tertiary"&&q.buttonLabelTertiary]},t),!!l&&x.createElement(Me,{style:{marginLeft:"auto"}},l))))},q=la.create({buttonBox:{height:54,flexDirection:"row",justifyContent:"center",alignItems:"center",borderRadius:14,paddingHorizontal:16,gap:12},buttonBoxSecondary:{justifyContent:"flex-start",borderWidth:1,borderRadius:12},buttonLabel:{fontFamily:"Inter_600SemiBold",fontSize:16,lineHeight:24},buttonLabelSecondary:{fontFamily:"Inter_400Regular"},buttonLabelTertiary:{fontFamily:"Inter_500Medium"}});import*as F from"expo-web-browser";import{AppState as ra,Platform as De}from"react-native";var gu=a=>{if(!a)return null;try{return new URL(a).protocol==="https:"?a:null}catch(t){return null}},Su=a=>{let t=!1,o=!1,u=null;function d(){o=!0,u==null||u.remove()}function l(f){if(t||o)return;t=!0;let s=!1;u=De.OS==="android"?ra.addEventListener("change",i=>{i==="background"&&(s=!0),i==="active"&&s&&d()}):null,F.openBrowserAsync(f,{createTask:!1}).then(i=>{i.type!==F.WebBrowserResultType.OPENED&&d()}).catch(d)}return a&&l(a),{navigate:l,isClosed:()=>o,dismiss:()=>{o||(d(),t&&De.OS==="ios"&&F.dismissBrowser().catch(()=>{}))}}};export{Oe as a,n as b,Iu as c,G as d,W as e,g as f,z as g,X as h,N as i,S as j,k,w as l,P as m,_ as n,A as o,K as p,Z as q,J as r,Q as s,j as t,Y as u,y as v,$ as w,ee as x,ae as y,te as z,oe as A,ue as B,de as C,le as D,re as E,fe as F,se as G,ie as H,ce as I,ne as J,pe as K,C as L,he as M,Ra as N,ba as O,qa as P,va as Q,we as R,Xe as S,_e as T,au as U,gu as V,Su as W,Le as X,Ye as Y,du as Z,lu as _};
2
2
  /*! Bundled license information:
3
3
 
4
4
  lucide-react-native/dist/esm/defaultAttributes.js:
@@ -0,0 +1 @@
1
+ import{e as o}from"./chunk-C5WYSLQF.js";import{applicationId as n}from"expo-application";import*as e from"expo-secure-store";import{PrivyClientError as c}from"@privy-io/js-sdk-core";var S=()=>{if(typeof n!="string")throw new c({error:"Cannot determine native application ID. Please make sure `expo-application` is installed as a dependency and that `ios.bundleId` or `android.package` is set.",code:"invalid_native_app_id"});return n},a=/[:/]/g;function l(r){return{get(t){return r.get(t.replaceAll(a,"-"))},put(t,i){return r.put(t.replaceAll(a,"-"),i)},del(t){return r.del(t.replaceAll(a,"-"))},getKeys:()=>o(this,null,function*(){return[]})}}var u={get(r){return e.getItemAsync(r,{keychainAccessible:e.AFTER_FIRST_UNLOCK_THIS_DEVICE_ONLY})},put(r,t){return e.setItemAsync(r,t,{keychainAccessible:e.AFTER_FIRST_UNLOCK_THIS_DEVICE_ONLY})},del(r){return e.deleteItemAsync(r,{keychainAccessible:e.AFTER_FIRST_UNLOCK_THIS_DEVICE_ONLY})},getKeys:()=>o(void 0,null,function*(){return[]})};export{S as a,l as b,u as c};