@unifold/connect-react-native 0.1.22 → 0.1.24
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.
- package/dist/index.d.mts +402 -370
- package/dist/index.d.ts +402 -370
- package/dist/index.js +2 -2
- package/dist/index.mjs +2 -2
- package/dist/stripe.d.mts +197 -190
- package/dist/stripe.d.ts +197 -190
- package/dist/stripe.js +3 -3
- package/dist/stripe.mjs +3 -3
- package/package.json +3 -5
package/dist/stripe.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {useState,useRef,useEffect,useCallback,useMemo}from'react';import {StyleSheet,Platform,View,TouchableOpacity,Text,KeyboardAvoidingView,ScrollView,TextInput,ActivityIndicator,Keyboard,Clipboard}from'react-native';import {Onramp,useOnramp,isPlatformPaySupported,PlatformPay,initStripe}from'@stripe/stripe-react-native';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import gn,{G,Path,Defs,ClipPath,Rect,LinearGradient,Stop,Circle}from'react-native-svg';var Qr="__unifold_stripe_onramp__";function or(e){globalThis[Qr]=e;}var Xr="#00D924",en="#000000",tn="#1C1C1E",Bt="#FFFFFF",Vt="#8E8E93",ir="#636366",rn=[["1","2","3"],["4","5","6"],["7","8","9"],["\u232B","0","."]];function ht({initialAmount:e="",currency:a="USD",onConfirm:o,onCancel:l}){let[c,x]=useState(e),B=T=>{if(T==="\u232B"){x(S=>S.slice(0,-1));return}if(T==="."){if(c.includes("."))return;x(S=>S===""?"0.":S+".");return}x(S=>{let k=S.indexOf(".");return k!==-1&&S.length-k>2?S:S==="0"&&T!=="."?T:S+T});},L=c===""?"0":c,D=parseFloat(c),W=c!==""&&!isNaN(D)&&D>0;return jsxs(View,{style:I.screen,children:[jsxs(View,{style:I.header,children:[jsx(TouchableOpacity,{style:I.cancelBtn,onPress:l,children:jsx(Text,{style:I.cancelText,children:"Cancel"})}),jsx(Text,{style:I.headerTitle,children:"Enter amount"}),jsx(View,{style:{width:64}})]}),jsxs(View,{style:I.amountContainer,children:[jsxs(Text,{style:[I.amountText,L==="0"&&I.amountPlaceholder],adjustsFontSizeToFit:true,numberOfLines:1,children:["$",L]}),jsx(Text,{style:I.currencyLabel,children:a.toUpperCase()})]}),jsx(View,{style:I.numpad,children:rn.map((T,S)=>jsx(View,{style:I.numpadRow,children:T.map(k=>jsx(TouchableOpacity,{style:I.numpadKey,onPress:()=>B(k),activeOpacity:.6,children:jsx(Text,{style:k==="\u232B"?I.backspaceText:I.numpadKeyText,children:k})},k))},S))}),jsx(TouchableOpacity,{style:[I.confirmBtn,!W&&I.confirmBtnDisabled],onPress:()=>W&&o(c),disabled:!W,children:jsx(Text,{style:[I.confirmBtnText,!W&&I.confirmBtnTextDisabled],children:"Continue"})})]})}var I=StyleSheet.create({screen:{flex:1,backgroundColor:en,paddingHorizontal:24,paddingBottom:48},header:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingTop:60,paddingBottom:8},cancelBtn:{width:64},cancelText:{color:Vt,fontSize:16,fontWeight:"500"},headerTitle:{color:Bt,fontSize:17,fontWeight:"700"},amountContainer:{flex:1,alignItems:"center",justifyContent:"center",gap:8},amountText:{fontSize:64,fontWeight:"300",color:Bt,letterSpacing:-2,minWidth:80,textAlign:"center"},amountPlaceholder:{color:ir},currencyLabel:{fontSize:15,color:Vt,letterSpacing:1,fontWeight:"500"},numpad:{gap:4,marginBottom:24},numpadRow:{flexDirection:"row",justifyContent:"space-between"},numpadKey:{flex:1,height:68,alignItems:"center",justifyContent:"center",borderRadius:16,marginHorizontal:4},numpadKeyText:{fontSize:28,fontWeight:"400",color:Bt},backspaceText:{fontSize:22,color:Vt},confirmBtn:{backgroundColor:Xr,borderRadius:24,paddingVertical:18,alignItems:"center"},confirmBtnDisabled:{backgroundColor:tn},confirmBtnText:{color:"#000000",fontSize:17,fontWeight:"700"},confirmBtnTextDisabled:{color:ir}});var Nt="#00D924",ln="#000000",_t="#1C1C1E",sr="#38383A",Ft="#FFFFFF",ct="#8E8E93",j="#636366",lt=4;function bt({initialData:e={},loading:a=false,onComplete:o,onCancel:l}){let[c,x]=useState(1),[B,L]=useState(e.firstName??""),[D,W]=useState(e.lastName??""),[T,S]=useState(e.dobMonth??""),[k,O]=useState(e.dobDay??""),[y,N]=useState(e.dobYear??""),[b,Ve]=useState(e.addressLine1??""),[m,ge]=useState(e.addressLine2??""),[te,C]=useState(e.city??""),[se,M]=useState(e.state??""),[ve,Le]=useState(e.postalCode??""),[Ae,Re]=useState(e.country??"US"),[Ee,Ne]=useState(e.idNumber??""),Fe=useRef(null),K=useRef(null),ze=useRef(null),he=useRef(null),_e=useRef(null),Ye=useRef(null),be=useRef(null),De=useRef(null),ae=()=>{switch(c){case 1:return B.trim().length>0&&D.trim().length>0;case 2:return T.length===2&&k.length===2&&y.length===4;case 3:return b.trim().length>0&&te.trim().length>0&&se.trim().length>0&&ve.trim().length>0;case 4:return Ee.trim().length>0;default:return false}},re=()=>{ae()&&(c<lt?x(w=>w+1):o({firstName:B,lastName:D,idNumber:Ee,dobMonth:T,dobDay:k,dobYear:y,addressLine1:b,addressLine2:m,city:te,state:se,postalCode:ve,country:Ae}));},F=()=>{c>1?x(w=>w-1):l();},h=["Enter your name","Enter your date of birth","Enter your address","Enter your SSN"],U=["Use your full legal name as it appears on your ID.","We use this to verify your identity.","Enter the address associated with your ID.","Your SSN is encrypted and used only for identity verification."];return jsx(KeyboardAvoidingView,{style:p.flex,behavior:Platform.OS==="ios"?"padding":void 0,children:jsxs(View,{style:p.screen,children:[jsxs(View,{style:p.header,children:[jsx(TouchableOpacity,{style:p.backBtn,onPress:F,children:jsx(Text,{style:p.backBtnText,children:"\u2039"})}),jsxs(Text,{style:p.stepCounter,children:[c," of ",lt]}),jsx(TouchableOpacity,{style:p.closeBtn,onPress:l,children:jsx(Text,{style:p.closeText,children:"\u2715"})})]}),jsx(View,{style:p.progressTrack,children:Array.from({length:lt}).map((w,V)=>jsx(View,{style:[p.progressSegment,V<c&&p.progressSegmentDone,V+1===c&&p.progressSegmentActive]},V))}),jsxs(ScrollView,{style:p.flex,contentContainerStyle:p.content,keyboardShouldPersistTaps:"handled",children:[jsx(Text,{style:p.title,children:h[c-1]}),jsx(Text,{style:p.subtitle,children:U[c-1]}),c===1&&jsxs(Fragment,{children:[jsx(Te,{label:"First name",children:jsx(TextInput,{style:p.input,placeholder:"Jane",placeholderTextColor:j,value:B,onChangeText:L,autoCapitalize:"words",returnKeyType:"next",onSubmitEditing:()=>Fe.current?.focus()})}),jsx(Te,{label:"Last name",children:jsx(TextInput,{ref:Fe,style:p.input,placeholder:"Doe",placeholderTextColor:j,value:D,onChangeText:W,autoCapitalize:"words",returnKeyType:"done",onSubmitEditing:re})})]}),c===2&&jsxs(View,{style:p.dobRow,children:[jsxs(View,{style:p.dobCol,children:[jsx(Text,{style:p.dobLabel,children:"Month"}),jsx(TextInput,{style:[p.input,p.dobInput],placeholder:"MM",placeholderTextColor:j,value:T,onChangeText:w=>{let V=w.replace(/\D/g,"").slice(0,2);S(V),V.length===2&&K.current?.focus();},keyboardType:"number-pad",maxLength:2})]}),jsxs(View,{style:p.dobCol,children:[jsx(Text,{style:p.dobLabel,children:"Day"}),jsx(TextInput,{ref:K,style:[p.input,p.dobInput],placeholder:"DD",placeholderTextColor:j,value:k,onChangeText:w=>{let V=w.replace(/\D/g,"").slice(0,2);O(V),V.length===2&&ze.current?.focus();},keyboardType:"number-pad",maxLength:2})]}),jsxs(View,{style:p.dobColWide,children:[jsx(Text,{style:p.dobLabel,children:"Year"}),jsx(TextInput,{ref:ze,style:[p.input,p.dobInput],placeholder:"YYYY",placeholderTextColor:j,value:y,onChangeText:w=>{let V=w.replace(/\D/g,"").slice(0,4);N(V);},keyboardType:"number-pad",maxLength:4,returnKeyType:"done",onSubmitEditing:re})]})]}),c===3&&jsxs(Fragment,{children:[jsx(Te,{label:"Street address",children:jsx(TextInput,{style:p.input,placeholder:"123 Main St",placeholderTextColor:j,value:b,onChangeText:Ve,returnKeyType:"next",onSubmitEditing:()=>he.current?.focus()})}),jsx(Te,{label:"Apt, suite, etc. (optional)",children:jsx(TextInput,{ref:he,style:p.input,placeholder:"Apt 2",placeholderTextColor:j,value:m,onChangeText:ge,returnKeyType:"next",onSubmitEditing:()=>_e.current?.focus()})}),jsx(Te,{label:"City",children:jsx(TextInput,{ref:_e,style:p.input,placeholder:"San Francisco",placeholderTextColor:j,value:te,onChangeText:C,autoCapitalize:"words",returnKeyType:"next",onSubmitEditing:()=>Ye.current?.focus()})}),jsxs(View,{style:p.row,children:[jsx(View,{style:[p.flex,{marginRight:8}],children:jsx(Te,{label:"State",children:jsx(TextInput,{ref:Ye,style:p.input,placeholder:"NY",placeholderTextColor:j,value:se,onChangeText:w=>M(w.toUpperCase().slice(0,2)),autoCapitalize:"characters",maxLength:2,returnKeyType:"next",onSubmitEditing:()=>be.current?.focus()})})}),jsx(View,{style:p.flex,children:jsx(Te,{label:"ZIP code",children:jsx(TextInput,{ref:be,style:p.input,placeholder:"11201",placeholderTextColor:j,value:ve,onChangeText:Le,keyboardType:"number-pad",maxLength:10,returnKeyType:"next",onSubmitEditing:()=>De.current?.focus()})})})]}),jsx(Te,{label:"Country",children:jsx(TextInput,{ref:De,style:p.input,placeholder:"US",placeholderTextColor:j,value:Ae,onChangeText:w=>Re(w.toUpperCase().slice(0,2)),autoCapitalize:"characters",maxLength:2,returnKeyType:"done",onSubmitEditing:re})})]}),c===4&&jsxs(Te,{label:"Social Security Number",children:[jsx(TextInput,{style:p.input,placeholder:"123-45-6789",placeholderTextColor:j,value:Ee,onChangeText:Ne,keyboardType:"number-pad",secureTextEntry:true,returnKeyType:"done",onSubmitEditing:re}),jsx(Text,{style:p.ssnHint,children:"Your SSN is transmitted securely and never stored on this device."})]})]}),jsx(View,{style:p.footer,children:a&&c===lt?jsx(View,{style:p.continueBtn,children:jsx(ActivityIndicator,{color:"#000"})}):jsx(TouchableOpacity,{style:[p.continueBtn,!ae()&&p.continueBtnDisabled],onPress:re,disabled:!ae(),children:jsx(Text,{style:[p.continueBtnText,!ae()&&p.continueBtnTextDisabled],children:c===lt?"Submit":"Continue"})})})]})})}function Te({label:e,children:a}){return jsxs(View,{style:ar.container,children:[jsx(Text,{style:ar.label,children:e}),a]})}var ar=StyleSheet.create({container:{marginBottom:20},label:{fontSize:13,color:ct,marginBottom:8,fontWeight:"600",textTransform:"uppercase",letterSpacing:.5}}),p=StyleSheet.create({flex:{flex:1},screen:{flex:1,backgroundColor:ln},header:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingTop:60,paddingHorizontal:20,paddingBottom:16},backBtn:{width:36,height:36,borderRadius:18,backgroundColor:_t,alignItems:"center",justifyContent:"center"},backBtnText:{color:Ft,fontSize:22,marginTop:-1},stepCounter:{color:ct,fontSize:15,fontWeight:"600"},closeBtn:{width:36,height:36,borderRadius:18,backgroundColor:_t,alignItems:"center",justifyContent:"center"},closeText:{color:ct,fontSize:14,fontWeight:"600"},progressTrack:{flexDirection:"row",gap:4,paddingHorizontal:20,marginBottom:32},progressSegment:{flex:1,height:3,borderRadius:2,backgroundColor:sr},progressSegmentDone:{backgroundColor:Nt},progressSegmentActive:{backgroundColor:Nt},content:{paddingHorizontal:24,paddingBottom:16},title:{fontSize:28,fontWeight:"700",color:Ft,marginBottom:8,lineHeight:34},subtitle:{fontSize:15,color:ct,marginBottom:32,lineHeight:22},input:{backgroundColor:_t,borderRadius:12,padding:16,fontSize:17,color:Ft,borderWidth:1,borderColor:sr},dobRow:{flexDirection:"row",gap:10,marginBottom:20},dobCol:{flex:1},dobColWide:{flex:1.5},dobLabel:{fontSize:13,color:ct,fontWeight:"600",marginBottom:8,textTransform:"uppercase",letterSpacing:.5,textAlign:"center"},dobInput:{textAlign:"center"},row:{flexDirection:"row"},ssnHint:{fontSize:12,color:j,marginTop:10,lineHeight:18},footer:{paddingHorizontal:24,paddingBottom:48,paddingTop:12},continueBtn:{backgroundColor:Nt,borderRadius:24,paddingVertical:18,alignItems:"center"},continueBtnDisabled:{backgroundColor:_t},continueBtnText:{color:"#000000",fontSize:17,fontWeight:"700"},continueBtnTextDisabled:{color:j}});var cn="https://api.unifold.io",dr,dn="pk_test_123";function un(){return typeof __DEV__<"u"&&__DEV__&&dr?dr:cn}function ur(){return un()}function wt(){return dn}var pr="",mr;function xt(e){pr=e;}function Ct(e){mr=e;}function ce(){let e=pr||wt();return e}function de(){return mr??ur()}async function Tt(){let e=`${de()}/v1/public/onramps/headless/stripe/config`,a=ce(),o=await fetch(e,{method:"GET",headers:{"x-publishable-key":a,"Content-Type":"application/json"}});if(!o.ok)throw new Error(`Failed to load Stripe config: ${o.status}`);let l=await o.json();if(!l?.publishable_key)throw new Error("Missing Stripe publishable key in config response");return l.publishable_key}async function fr(e){let a=await fetch(`${de()}/v1/public/onramps/headless/stripe/oauth/start`,{method:"POST",headers:{"x-publishable-key":ce(),"Content-Type":"application/json"},body:JSON.stringify({email:e})});if(!a.ok)throw new Error(`Failed to create auth intent: ${a.status}`);let o=await a.json();return o.auth_intent_id??o.id}async function yr(e){let a=await fetch(`${de()}/v1/public/onramps/headless/stripe/oauth/token`,{method:"POST",headers:{"x-publishable-key":ce(),"Content-Type":"application/json"},body:JSON.stringify({auth_intent_id:e})});if(!a.ok)throw new Error(`Failed to exchange auth intent for tokens: ${a.status}`);return a.json()}async function gr(e,a){let o={crypto_customer_id:e.cryptoCustomerId,payment_token:e.paymentToken,source_amount:e.sourceAmount,source_currency:e.sourceCurrency,destination_currency:e.destinationCurrency,wallet_address:e.walletAddress,destination_network:e.destinationNetwork},l=await fetch(`${de()}/v1/public/onramps/headless/stripe/sessions`,{method:"POST",headers:{"x-publishable-key":ce(),"x-stripe-oauth-token":a,"Content-Type":"application/json"},body:JSON.stringify(o)}),c=await l.text();if(!l.ok)throw new Error(`Failed to create onramp session: ${l.status} ${c}`);return JSON.parse(c)}async function hr(e,a){let o=await fetch(`${de()}/v1/public/onramps/headless/stripe/sessions/${e}/confirm`,{method:"POST",headers:{"x-publishable-key":ce(),"x-stripe-oauth-token":a,"Content-Type":"application/json"}}),l=await o.text();if(!o.ok)throw new Error(`Failed to confirm onramp session: ${o.status} ${l}`);return JSON.parse(l)}async function _r(e,a){let o=`${de()}/v1/public/onramps/headless/stripe/customers/${e}`,l=await fetch(o,{method:"GET",headers:{"x-publishable-key":ce(),"x-stripe-oauth-token":a}}),c=await l.text();if(!l.ok)throw new Error(`Failed to get onramp customer: ${l.status} ${c}`);return JSON.parse(c)}async function br(e,a){let o=`${de()}/v1/public/onramps/headless/stripe/sessions/${e}`,l=await fetch(o,{method:"GET",headers:{"x-publishable-key":ce(),"x-stripe-oauth-token":a}}),c=await l.text();if(!l.ok)throw new Error(`Failed to get onramp session: ${l.status} ${c}`);return JSON.parse(c)}async function wr(e,a){let o=await fetch(`${de()}/v1/public/onramps/headless/stripe/sessions/${e}/quote/refresh`,{method:"POST",headers:{"x-publishable-key":ce(),"x-stripe-oauth-token":a,"Content-Type":"application/json"}});if(!o.ok){let l=await o.text();throw new Error(`Failed to refresh quote: ${o.status} ${l}`)}return o.json()}async function xr(e){if(!e.recipient_address)throw new Error("[Unifold] recipient_address is required for fetchDepositAddress. Pass recipientAddress in your onramp config.");let a={external_user_id:e.external_user_id,destination_chain_type:e.destination_chain_type||"ethereum",destination_chain_id:e.destination_chain_id||"8453",destination_token_address:e.destination_token_address||"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",recipient_address:e.recipient_address,client_metadata:{}},o=await fetch(`${de()}/v1/public/deposit_addresses`,{method:"POST",headers:{accept:"application/json","x-publishable-key":ce(),"Content-Type":"application/json"},body:JSON.stringify(a)});if(!o.ok)throw new Error(`Failed to create deposit address: ${o.status}`);return o.json()}async function Cr(e){let a=new URLSearchParams({token_address:e.token_address,chain_id:e.chain_id,chain_type:e.chain_type}),o=await fetch(`${de()}/v1/public/onramps/headless/stripe/default_token?${a.toString()}`,{method:"GET",headers:{accept:"application/json","x-publishable-key":ce()}});if(!o.ok)throw new Error(`Failed to fetch default onramp token: ${o.status}`);return o.json()}var Tr={firstName:"",lastName:"",idNumber:"",dobDay:"",dobMonth:"",dobYear:"",addressLine1:"",addressLine2:"",city:"",state:"",postalCode:"",country:"US"};function St(e){let a=e?.flowOrder==="amount_first",o=a?"session_params":"email",{configure:l,hasLinkAccount:c,registerLinkUser:x,authorize:B,attachKycInfo:L,presentKycInfoVerification:D,verifyIdentity:W,registerWalletAddress:T,collectPaymentMethod:S,createCryptoPaymentToken:k}=useOnramp(),[O,y]=useState(o),[N,b]=useState(false),[Ve,m]=useState(""),[ge,te]=useState(null),[C,se]=useState(e?.email??""),[M,ve]=useState(e?.phone??""),[Le,Ae]=useState(""),[Re,Ee]=useState("US"),[Ne,Fe]=useState(""),[K,ze]=useState(""),[he,_e]=useState(false),[Ye,be]=useState(false),De=useRef(false),ae=useRef(false),re=useRef(""),F=useRef(null),[h,U]=useState(Tr),[w,V]=useState(e?.defaultWalletAddress??"0x102471956A026866171C44F326e1DfafB6C6e34c"),[Wr,Kr]=useState(""),[We,tt]=useState(e?.defaultNetwork??Onramp.CryptoNetwork.base),[Ke,Yt]=useState(e?.defaultSourceAmount??"100"),[ft,Gt]=useState(e?.defaultSourceCurrency??"usd"),[yt,vt]=useState(e?.defaultDestinationCurrency??"usdc"),[we,rt]=useState(null),[Ht,At]=useState(false),[Ur,$r]=useState(false),nt=useRef(null),ot=useRef(false),qt=useRef(e?.onComplete),Qt=useRef(e?.onError),Jt=useRef(e?.onStepChange),Zt=useRef(o);useEffect(()=>{qt.current=e?.onComplete;},[e?.onComplete]),useEffect(()=>{Qt.current=e?.onError;},[e?.onError]),useEffect(()=>{Jt.current=e?.onStepChange;},[e?.onStepChange]);let Rt=useRef(o);useEffect(()=>{O!==Rt.current&&(Jt.current?.(O,Rt.current),Rt.current=O),Zt.current=O;},[O]);let f=useCallback((r,d,_)=>{let P={code:r,message:d,step:Zt.current,stripeErrorCode:_};te(P),m(""),Qt.current?.(P);},[]),Xt=useCallback(r=>{let d={sessionId:r.id,status:r.status,sourceAmount:r.transaction_details.source_amount,sourceCurrency:r.transaction_details.source_currency,destinationAmount:r.transaction_details.destination_amount,destinationCurrency:r.transaction_details.destination_currency,destinationNetwork:r.transaction_details.destination_network,walletAddress:r.transaction_details.wallet_address,fees:{networkFee:r.transaction_details.fees.network_fee_amount,transactionFee:r.transaction_details.fees.transaction_fee_amount}};return qt.current?.(d),d},[]),R=useCallback(()=>te(null),[]);useEffect(()=>{isPlatformPaySupported().then($r);},[]),useEffect(()=>(ot.current=false,()=>{ot.current=true,nt.current&&clearTimeout(nt.current);}),[]),useEffect(()=>{if(!e?.publishableKey||!e?.externalUserId||!e?.recipientAddress||he||Ye)return;let r=false;be(true);async function d(){try{let[_,P]=await Promise.all([xr({external_user_id:e.externalUserId,recipient_address:e.recipientAddress,destination_chain_type:e?.destinationChainType,destination_chain_id:e?.destinationChainId,destination_token_address:e?.destinationTokenAddress}),e?.destinationTokenAddress&&e?.destinationChainId&&e?.destinationChainType?Cr({token_address:e.destinationTokenAddress,chain_id:e.destinationChainId,chain_type:e.destinationChainType}).catch(Y=>(console.warn("[useStripeOnramp] fetchDefaultOnrampToken failed, using chain_id fallback:",Y?.message),null)):Promise.resolve(null)]);if(r)return;let le=e?.destinationChainType??"ethereum",xe=_.data.find(Y=>Y.chain_type===le);if(xe?.address){let Y=xe.address.toLowerCase();V(Y),re.current=Y,xe.recipient_address&&Kr(xe.recipient_address);}else console.warn("[resolveWallet] No wallet found for chain_type",le,"in",_.data?.length,"wallets");let Q={base:Onramp.CryptoNetwork.base,ethereum:Onramp.CryptoNetwork.ethereum,solana:Onramp.CryptoNetwork.solana,bitcoin:Onramp.CryptoNetwork.bitcoin,polygon:Onramp.CryptoNetwork.polygon},st={8453:"base",1:"ethereum",137:"polygon"},Ge=P?.destination_network,at="none";if(Ge&&Q[Ge])tt(Q[Ge]),at=Ge+" (from default_token API)";else if(e?.destinationChainId&&st[e.destinationChainId]){let Y=st[e.destinationChainId];Q[Y]&&tt(Q[Y]),at=Y+" (from chain_id "+e.destinationChainId+")";}else Q[le]&&(tt(Q[le]),at=le+" (from chain_type fallback)");P?.destination_currency&&vt(P.destination_currency.toLowerCase()),_e(!0),ae.current=!0;}catch(_){console.error("[useStripeOnramp] Failed to resolve wallet:",_?.message),_e(true),ae.current=true;}finally{r||be(false);}}return d(),()=>{r=true;}},[e?.publishableKey,e?.externalUserId]);let it=useCallback(async()=>{if(F.current)return F.current;let r=l({merchantDisplayName:e?.merchantDisplayName??"Unifold",appearance:{lightColors:{primary:"#2d22a1",contentOnPrimary:"#ffffff",borderSelected:"#07b8b8"},darkColors:{primary:"#800080",contentOnPrimary:"#ffffff",borderSelected:"#526f3e"},style:"ALWAYS_DARK",primaryButton:{cornerRadius:8,height:48}}}).then(d=>(d.error&&(console.error("[useStripeOnramp] configureSDK error:",d.error.message,d.error.code),F.current=null),d)).catch(d=>{throw console.error("[useStripeOnramp] configureSDK threw:",d?.message??d),F.current=null,d});return F.current=r,r},[l,e?.merchantDisplayName]);useEffect(()=>{it();},[]);let Ue=useCallback(async r=>{b(true),R(),m("Creating auth intent...");try{let d=await fr(r);m("Waiting for authorization...");let _=await B(d);if(_?.error){f("authorization_error",_.error.message,_.error.code),y("email");return}if(_?.status==="Denied"){f("authorization_error","Authorization denied by user."),y("email");return}if(_?.status!=="Consented"||!_.customerId){f("authorization_error","Authorization was canceled."),y("email");return}m("Exchanging tokens...");let P=await yr(d),le=_.customerId,xe=P.access_token;Fe(le),ze(xe),m("Checking verification status...");try{let Q=await _r(le,xe),st=Q.verifications.find(Ce=>Ce.name==="kyc_verified"),Ge=Q.verifications.find(Ce=>Ce.name==="id_document_verified"),at=st?.status==="verified",Y=st?.status==="rejected",nr=Ge?.status==="verified",Dt=Q.provided_fields.includes("first_name");if(m(""),Y&&!Dt)f("kyc_error","KYC was previously rejected. Please submit with correct info."),y("kyc");else if(Y&&Dt)y(nr?"wallet":"identity");else if(!at&&!Dt)y("kyc");else if(!nr)y("identity");else if(ae.current&&re.current)try{let Ce=await T(re.current,We);Ce?.error?(f("wallet_error",Ce.error.message,Ce.error.code),y("wallet")):y(a?"payment_method":"session_params");}catch(Ce){console.warn("[proceedToAuthorize] Inline wallet registration failed, falling back to wallet step:",Ce?.message),y("wallet");}else y("wallet");}catch(Q){console.warn("[getOnrampCustomer] failed, defaulting to kyc:",Q?.message),m(""),y("kyc");}}catch(d){f("authorization_error",d?.message??String(d)),y("email");}finally{b(false);}},[B,R,f,T,We,a]),jr=useCallback(async()=>{if(Keyboard.dismiss(),!C){f("validation_error","Please enter an email address.");return}b(true),R(),m("");try{m("Configuring...");let r=await it();if(r.error){f("configuration_error",r.error.message,r.error.code);return}m("Checking Link account...");let d=await c(C);if(d.error){f("authorization_error",d.error.message,d.error.code);return}d.hasLinkAccount?await Ue(C):(m(""),y("register"));}catch(r){f("unknown_error",r?.message??String(r));}finally{b(false);}},[R,it,C,f,c,Ue]),Mr=useCallback(async()=>{if(!M){f("validation_error","Please enter your phone number.");return}b(true),R(),m("");try{m("Creating Link account...");let r=await x({email:C,phone:M,fullName:Le||C,country:Re||"US"});if(r.error){f("registration_error",r.error.message,r.error.code);return}await Ue(C);}catch(r){f("registration_error",r?.message??String(r));}finally{b(false);}},[R,Re,C,f,Le,M,x,Ue]);useEffect(()=>{De.current||O==="email"&&e?.email&&(De.current=true,e?.phone?(async()=>{b(true),R();try{m("Configuring...");let r=await it();if(r.error){f("configuration_error",r.error.message,r.error.code);return}m("Checking Link account...");let d=await c(e.email);if(d.error){f("authorization_error",d.error.message,d.error.code);return}if(d.hasLinkAccount)await Ue(e.email);else {m("Creating Link account...");let _=await x({email:e.email,phone:e.phone,fullName:e.email,country:"US"});if(_.error){f("registration_error",_.error.message,_.error.code);return}await Ue(e.email);}}catch(r){f("unknown_error",r?.message??String(r));}finally{b(false);}})():(async()=>{b(true),R();try{m("Configuring...");let r=await it();if(r.error){f("configuration_error",r.error.message,r.error.code);return}m("Checking Link account...");let d=await c(e.email);if(d.error){f("authorization_error",d.error.message,d.error.code);return}d.hasLinkAccount?await Ue(e.email):(m(""),y("register"));}catch(r){f("unknown_error",r?.message??String(r));}finally{b(false);}})());},[O]);let Yr=useCallback(async r=>{b(true),R(),m(""),U(r);try{let d={firstName:r.firstName,lastName:r.lastName,idNumber:r.idNumber||void 0,dateOfBirth:{day:parseInt(r.dobDay,10),month:parseInt(r.dobMonth,10),year:parseInt(r.dobYear,10)},address:{line1:r.addressLine1,line2:r.addressLine2||void 0,city:r.city,state:r.state,postalCode:r.postalCode,country:r.country}},_=await L(d);if(_?.error){if(_.error.stripeErrorCode==="consumer_person_already_verified"){m(""),y("identity");return}f("kyc_error",_.error.message,_.error.stripeErrorCode??_.error.code),y("kyc");return}m("Please review your KYC information...");let P=await D(null);if(P?.error){f("kyc_error",P.error.message,P.error.stripeErrorCode??P.error.code),y("kyc");return}if(P?.status==="UpdateAddress"){f("kyc_error","Please update your address and resubmit."),y("kyc");return}m(""),y("identity");}catch(d){f("kyc_error",d?.message??String(d)),y("kyc");}finally{b(false);}},[L,R,f,D]),er=useCallback(async()=>{b(true),R(),m("Launching identity verification...");try{let r=await W();if(r?.error){f("identity_error",r.error.message,r.error.code);return}m(""),y("wallet");}catch(r){f("identity_error",r?.message??String(r));}finally{b(false);}},[R,f,W]);useEffect(()=>{O==="identity"&&!N&&er();},[O]);let tr=useCallback(async()=>{if(!w){f("validation_error","Please enter a wallet address.");return}b(true),R(),m("");try{let r=await T(w.toLowerCase(),We);if(r?.error){f("wallet_error",r.error.message,r.error.code);return}m(""),y(a?"payment_method":"session_params");}catch(r){f("wallet_error",r?.message??String(r));}finally{b(false);}},[R,f,w,We,T,a]);useEffect(()=>{O==="wallet"&&he&&w&&!N&&tr();},[O,he,w]);let Gr=useCallback(async(r=false)=>{if(!Ke||isNaN(Number(Ke))||Number(Ke)<=0){f("validation_error","Please enter a valid amount.");return}b(true),R(),m("");try{let d;if(r){m("Opening Apple Pay...");let xe={applePay:{merchantCountryCode:"US",currencyCode:ft.toUpperCase(),cartItems:[{paymentType:PlatformPay.PaymentType.Immediate,label:`${yt.toUpperCase()} purchase + fees`,amount:Ke||"0.00"}]}};d=await S("PlatformPay",xe);}else m("Select a payment method..."),d=await S("Card");if(d?.error){f("payment_error",d.error.message,d.error.code),y("payment_method");return}if(!d?.displayData){f("payment_error","Payment method selection was canceled."),y("payment_method");return}m("Creating payment token...");let _=await k();if(_?.error){f("payment_error",_.error.message,_.error.code),y("payment_method");return}let P=_.cryptoPaymentToken;m("Creating onramp session...");let le=await gr({cryptoCustomerId:Ne,paymentToken:P,sourceAmount:Number(Ke),sourceCurrency:ft,destinationCurrency:yt,walletAddress:w.toLowerCase(),destinationNetwork:We},K);rt(le),At(r),m(""),y("quote");}catch(d){f("session_error",d?.message??String(d)),y("payment_method");}finally{b(false);}},[K,R,S,k,Ne,yt,f,Ke,ft,w,We]),Hr=useCallback(async()=>{if(we){b(true),R(),m("");try{let r=await wr(we.id,K);rt(r);}catch(r){f("session_error",r?.message??String(r));}finally{b(false);}}},[K,R,f,we]),rr=useCallback((r,d)=>{ot.current=false;let _=async()=>{try{let P=await br(r,d);if(ot.current)return;P.status==="fulfillment_complete"?(rt(P),y("success"),Xt(P)):nt.current=setTimeout(_,3e3);}catch(P){if(ot.current)return;console.error("[pollSessionStatus] error:",P?.message),nt.current=setTimeout(_,5e3);}};nt.current=setTimeout(_,3e3);},[Xt]),Et=useCallback(async()=>{if(we){b(true),R(),m("");try{m("Confirming purchase...");let r=await hr(we.id,K);rt(r),y("processing"),m(""),rr(r.id,K);}catch(r){f("session_error",r?.message??String(r));}finally{b(false);}}},[K,R,f,rr,we]);useEffect(()=>{O==="quote"&&Ht&&we&&!N&&(At(false),Et());},[O,Ht,we,N,Et]);let qr=useCallback(()=>{y(o),b(false),m(""),te(null),se(e?.email??""),ve(e?.phone??""),Ae(""),Ee("US"),Fe(""),ze(""),_e(false),be(false),U(Tr),V(e?.recipientAddress??""),tt(Onramp.CryptoNetwork.ethereum),Yt(e?.defaultSourceAmount??"100"),Gt(e?.defaultSourceCurrency??"usd"),vt(e?.defaultDestinationCurrency??"usdc"),rt(null),At(false),De.current=false;},[e,o]);return {step:O,loading:N,status:Ve,error:ge,email:C,phone:M,fullName:Le,country:Re,customerId:Ne,accessToken:K,session:we,kycData:h,walletAddress:w,resolvedRecipientAddress:Wr,walletNetwork:We,sourceAmount:Ke,sourceCurrency:ft,destinationCurrency:yt,applePaySupported:Ur,walletReady:he,walletLoading:Ye,setStep:y,setStatus:m,setEmail:se,setPhone:ve,setFullName:Ae,setCountry:Ee,setWalletAddress:V,setWalletNetwork:tt,setSourceAmount:Yt,setSourceCurrency:Gt,setDestinationCurrency:vt,checkEmail:jr,register:Mr,attachKyc:Yr,verifyIdentity:er,registerWallet:tr,collectPaymentMethod:Gr,refreshQuote:Hr,confirmCheckout:Et,reset:qr,clearError:R,amountFirst:a}}function kr({size:e=28}){return jsx(gn,{width:e,height:e,viewBox:"0 0 28 28",fill:"none",children:jsxs(G,{fillRule:"evenodd",children:[jsx(Path,{fill:"#0052FF",fillRule:"nonzero",d:"M14 28a14 14 0 1 0 0-28 14 14 0 0 0 0 28"}),jsx(Path,{fill:"#FFF",d:"M13.967 23.86c5.445 0 9.86-4.415 9.86-9.86s-4.415-9.86-9.86-9.86c-5.166 0-9.403 3.974-9.825 9.03h14.63v1.642H4.142c.413 5.065 4.654 9.047 9.826 9.047Z"})]})})}function Pr({size:e=28}){return jsxs(gn,{width:e,height:e,viewBox:"0 0 28 28",fill:"none",children:[jsxs(G,{clipPath:"url(#eth_clip)",children:[jsx(Path,{d:"M14 28C21.732 28 28 21.732 28 14C28 6.26801 21.732 0 14 0C6.26801 0 0 6.26801 0 14C0 21.732 6.26801 28 14 28Z",fill:"#627EEA"}),jsx(Path,{d:"M14.4357 3.5V11.2612L20.9956 14.1925L14.4357 3.5Z",fill:"white",fillOpacity:.602}),jsx(Path,{d:"M14.4357 3.5L7.875 14.1925L14.4357 11.2612V3.5Z",fill:"white"}),jsx(Path,{d:"M14.4357 19.222V24.4956L21 15.414L14.4357 19.222Z",fill:"white",fillOpacity:.602}),jsx(Path,{d:"M14.4357 24.4956V19.2211L7.875 15.414L14.4357 24.4956Z",fill:"white"}),jsx(Path,{d:"M14.4357 18.0014L20.9956 14.1925L14.4357 11.263V18.0014Z",fill:"white",fillOpacity:.2}),jsx(Path,{d:"M7.875 14.1925L14.4357 18.0014V11.263L7.875 14.1925Z",fill:"white",fillOpacity:.602})]}),jsx(Defs,{children:jsx(ClipPath,{id:"eth_clip",children:jsx(Rect,{width:28,height:28,fill:"white"})})})]})}function Rr({size:e=28}){return jsxs(gn,{width:e,height:e,viewBox:"0 0 28 28",fill:"none",children:[jsxs(G,{clipPath:"url(#btc_clip)",children:[jsx(Path,{d:"M14 28C21.732 28 28 21.732 28 14C28 6.26801 21.732 0 14 0C6.26801 0 0 6.26801 0 14C0 21.732 6.26801 28 14 28Z",fill:"#F7931A"}),jsx(Path,{d:"M20.0594 12.1625C20.3438 10.2594 18.9 9.23124 16.9203 8.55311L17.5656 5.97186L15.9906 5.57811L15.3672 8.09374C14.9516 7.9953 14.525 7.89686 14.0985 7.79843L14.7328 5.27186L13.1578 4.87811L12.5125 7.45936C12.1735 7.3828 11.8344 7.30624 11.5063 7.22968V7.21874L9.34065 6.67186L8.92502 8.35624C8.92502 8.35624 10.0844 8.61874 10.0625 8.64061C10.6969 8.79374 10.8063 9.2203 10.7844 9.54843L10.0625 12.4578C10.1063 12.4687 10.161 12.4797 10.2266 12.5125C10.1828 12.5016 10.1281 12.4906 10.0735 12.4687L9.05627 16.5375C8.97971 16.7344 8.78284 17.0187 8.34534 16.9094C8.36721 16.9312 7.20784 16.625 7.20784 16.625L6.43127 18.4297L8.47659 18.9437C8.8594 19.0422 9.23127 19.1406 9.59221 19.2281L8.9469 21.8422L10.5219 22.2359L11.1672 19.6547C11.5938 19.775 12.0094 19.8734 12.4141 19.9828L11.7688 22.5531L13.3438 22.9469L13.9891 20.3328C16.6578 20.8359 18.6594 20.6281 19.5016 18.2219C20.1797 16.2859 19.4688 15.1703 18.0688 14.4375C19.086 14.2078 19.8516 13.5406 20.0594 12.1625ZM16.4938 17.1609C16.0125 19.0969 12.7531 18.0469 11.6922 17.7844L12.5453 14.35C13.6063 14.6125 16.9969 15.1484 16.4938 17.1609ZM16.975 12.1297C16.5375 13.8906 13.825 12.9937 12.95 12.775L13.7266 9.6578C14.6016 9.87655 17.4344 10.2812 16.975 12.1297Z",fill:"white"})]}),jsx(Defs,{children:jsx(ClipPath,{id:"btc_clip",children:jsx(Rect,{width:28,height:28,fill:"white"})})})]})}function Er({size:e=28}){return jsxs(gn,{width:e,height:e,viewBox:"0 0 256 256",fill:"none",children:[jsxs(Defs,{children:[jsxs(LinearGradient,{id:"sol1",x1:"360.9",y1:"-37.5",x2:"141.2",y2:"383.3",gradientUnits:"userSpaceOnUse",children:[jsx(Stop,{offset:"0",stopColor:"#00FFA3"}),jsx(Stop,{offset:"1",stopColor:"#DC1FFF"})]}),jsxs(LinearGradient,{id:"sol2",x1:"264.8",y1:"-87.6",x2:"45.16",y2:"333.15",gradientUnits:"userSpaceOnUse",children:[jsx(Stop,{offset:"0",stopColor:"#00FFA3"}),jsx(Stop,{offset:"1",stopColor:"#DC1FFF"})]}),jsxs(LinearGradient,{id:"sol3",x1:"312.55",y1:"-62.69",x2:"92.88",y2:"358.06",gradientUnits:"userSpaceOnUse",children:[jsx(Stop,{offset:"0",stopColor:"#00FFA3"}),jsx(Stop,{offset:"1",stopColor:"#DC1FFF"})]})]}),jsx(Circle,{cx:128,cy:128,r:128,fill:"black"}),jsxs(G,{transform:"translate(128,128) scale(0.35) translate(-198.85,-156)",children:[jsx(Path,{fill:"url(#sol2)",d:"M64.6,3.8C67.1,1.4,70.4,0,73.8,0h317.4c5.8,0,8.7,7,4.6,11.1l-62.7,62.7c-2.4,2.4-5.7,3.8-9.2,3.8H6.5c-5.8,0-8.7-7-4.6-11.1L64.6,3.8z"}),jsx(Path,{fill:"url(#sol3)",d:"M333.1,120.1c-2.4-2.4-5.7-3.8-9.2-3.8H6.5c-5.8,0-8.7,7-4.6,11.1l62.7,62.7c2.4,2.4,5.7,3.8,9.2,3.8h317.4c5.8,0,8.7-7,4.6-11.1L333.1,120.1z"}),jsx(Path,{fill:"url(#sol1)",d:"M64.6,237.9c2.4-2.4,5.7-3.8,9.2-3.8h317.4c5.8,0,8.7,7,4.6,11.1l-62.7,62.7c-2.4,2.4-5.7,3.8-9.2,3.8H6.5c-5.8,0-8.7-7-4.6-11.1L64.6,237.9z"})]})]})}function Dr({size:e=28}){return jsx(gn,{width:e,height:e,viewBox:"0 0 32 32",fill:"none",children:jsxs(G,{children:[jsx(Circle,{cx:16,cy:16,r:16,fill:"#6F41D8"}),jsx(Path,{fill:"#FFF",d:"M21.092 12.693c-.369-.215-.848-.215-1.254 0l-2.879 1.654-1.955 1.078-2.879 1.653c-.369.216-.848.216-1.254 0l-2.288-1.294c-.369-.215-.627-.61-.627-1.042V12.19c0-.431.221-.826.627-1.042l2.25-1.258c.37-.216.85-.216 1.256 0l2.25 1.258c.37.216.628.611.628 1.042v1.654l1.955-1.115v-1.653a1.16 1.16 0 0 0-.627-1.042l-4.17-2.372c-.369-.216-.848-.216-1.254 0l-4.244 2.372A1.16 1.16 0 0 0 6 11.076v4.78c0 .432.221.827.627 1.043l4.244 2.372c.369.215.849.215 1.254 0l2.879-1.618 1.955-1.114 2.879-1.617c.369-.216.848-.216 1.254 0l2.251 1.258c.37.215.627.61.627 1.042v2.552c0 .431-.22.826-.627 1.042l-2.25 1.294c-.37.216-.85.216-1.255 0l-2.251-1.258c-.37-.216-.628-.611-.628-1.042v-1.654l-1.955 1.115v1.653c0 .431.221.827.627 1.042l4.244 2.372c.369.216.848.216 1.254 0l4.244-2.372c.369-.215.627-.61.627-1.042v-4.78a1.16 1.16 0 0 0-.627-1.042l-4.28-2.409z"})]})})}var q="#00D924",Lr="#00D92440",Kn="#000000",Oe="#1C1C1E",Be="#38383A",Pe="#FFFFFF",fe="#8E8E93",ye="#636366",Un="#FF453A",Ir=[{label:"Base",value:Onramp.CryptoNetwork.base,defaultCrypto:"usdc",Icon:kr},{label:"Ethereum",value:Onramp.CryptoNetwork.ethereum,defaultCrypto:"eth",Icon:Pr},{label:"Bitcoin",value:Onramp.CryptoNetwork.bitcoin,defaultCrypto:"btc",Icon:Rr},{label:"Solana",value:Onramp.CryptoNetwork.solana,defaultCrypto:"sol",Icon:Er},{label:"Polygon",value:Onramp.CryptoNetwork.polygon,defaultCrypto:"matic",Icon:Dr}];function Br(e,a){let o=parseFloat(e);if(isNaN(o))return e;let l=a.toLowerCase(),c=["eth","btc"].includes(l)?4:2;return o.toFixed(c)}function Ot({config:e,onComplete:a}){let{step:o,loading:l,status:c,error:x,email:B,phone:L,session:D,kycData:W,walletAddress:T,resolvedRecipientAddress:S,walletNetwork:k,sourceAmount:O,sourceCurrency:y,destinationCurrency:N,applePaySupported:b,walletReady:Ve,walletLoading:m,setStep:ge,setEmail:te,setPhone:C,setWalletAddress:se,setWalletNetwork:M,setSourceAmount:ve,setDestinationCurrency:Le,checkEmail:Ae,register:Re,attachKyc:Ee,verifyIdentity:Ne,registerWallet:Fe,collectPaymentMethod:K,refreshQuote:ze,confirmCheckout:he,reset:_e,clearError:Ye,amountFirst:be}=St(e),De=!!e?.email,ae=!!e?.phone,re=!!e?.publishableKey&&!!e?.externalUserId,F=()=>{_e(),a?.();};if(o==="email")return De?jsx(View,{style:n.screen,children:jsxs(View,{style:A.centered,children:[jsx(ActivityIndicator,{size:"large",color:q}),jsx(Se,{error:x,progress:c,loading:l})]})}):jsx(KeyboardAvoidingView,{style:n.flex,behavior:Platform.OS==="ios"?"padding":void 0,children:jsxs(View,{style:n.screen,children:[jsx(Ze,{onPress:F}),jsxs(View,{style:n.content,children:[jsx(Text,{style:n.title,children:"Enter your email"}),jsx(Text,{style:n.subtitle,children:"We'll check if you have a Link account or create one for you."}),jsxs(View,{style:n.fieldWrap,children:[jsx(Text,{style:n.fieldLabel,children:"Email address"}),jsx(TextInput,{style:n.input,placeholder:"jane@example.com",placeholderTextColor:ye,keyboardType:"email-address",autoCapitalize:"none",autoCorrect:false,value:B,onChangeText:te,autoFocus:true,returnKeyType:"done",onSubmitEditing:Ae})]})]}),jsxs(View,{style:n.footer,children:[l?jsx(View,{style:n.continueBtn,children:jsx(ActivityIndicator,{color:"#fff"})}):jsx(TouchableOpacity,{style:[n.continueBtn,!B&&n.continueBtnDisabled],onPress:Ae,disabled:!B,children:jsx(Text,{style:[n.continueBtnText,!B&&n.continueBtnTextDisabled],children:"Continue"})}),jsx(Se,{error:x,progress:c,loading:l})]})]})});if(o==="register")return ae?jsx(View,{style:n.screen,children:jsxs(View,{style:A.centered,children:[jsx(ActivityIndicator,{size:"large",color:q}),jsx(Se,{error:x,progress:c,loading:l})]})}):jsx(KeyboardAvoidingView,{style:n.flex,behavior:Platform.OS==="ios"?"padding":void 0,children:jsxs(View,{style:n.screen,children:[jsx(Ze,{onPress:F}),jsxs(View,{style:n.content,children:[jsx(Text,{style:n.title,children:"Enter your phone"}),jsx(Text,{style:n.subtitle,children:"We'll send a verification code to confirm your number."}),jsxs(View,{style:n.fieldWrap,children:[jsx(Text,{style:n.fieldLabel,children:"Phone number"}),jsx(TextInput,{style:n.input,placeholder:"+12125551234",placeholderTextColor:ye,keyboardType:"phone-pad",value:L,onChangeText:h=>C(h.replace(/[^\d+]/g,"").replace(/(?!^)\+/g,"")),autoFocus:true,returnKeyType:"done",onSubmitEditing:Re}),jsx(Text,{style:n.hint,children:"Include country code, e.g. +12125551234"})]}),jsxs(View,{style:n.emailRow,children:[jsx(Text,{style:n.emailLabel,children:"Signing up as"}),jsx(Text,{style:n.emailValue,children:B})]})]}),jsxs(View,{style:n.footer,children:[l?jsx(View,{style:n.continueBtn,children:jsx(ActivityIndicator,{color:"#fff"})}):jsx(TouchableOpacity,{style:[n.continueBtn,!L&&n.continueBtnDisabled],onPress:Re,disabled:!L,children:jsx(Text,{style:[n.continueBtnText,!L&&n.continueBtnTextDisabled],children:"Continue"})}),jsx(Se,{error:x,progress:c,loading:l})]})]})});if(o==="kyc")return jsx(bt,{initialData:W,loading:l,onComplete:Ee,onCancel:()=>ge("email")});if(o==="identity")return jsxs(View,{style:n.screen,children:[jsx(Ze,{onPress:F}),jsxs(View,{style:A.centered,children:[l?jsxs(Fragment,{children:[jsx(View,{style:A.spinnerWrap,children:jsx(ActivityIndicator,{size:"large",color:q})}),jsx(Text,{style:A.heading,children:"Verifying identity"}),jsx(Text,{style:A.sub,children:c||"Preparing identity verification..."})]}):jsxs(Fragment,{children:[jsx(View,{style:A.spinnerWrap,children:jsx(Text,{style:A.idIcon,children:"\u{1FAAA}"})}),jsx(Text,{style:A.heading,children:"Identity verification"}),jsx(Text,{style:A.sub,children:c||"Tap below to continue verification."})]}),jsx(Se,{error:x,progress:c,loading:false})]}),!l&&jsx(View,{style:n.footer,children:jsx(TouchableOpacity,{style:n.continueBtn,onPress:Ne,children:jsx(Text,{style:n.continueBtnText,children:"Continue Verification"})})})]});if(o==="wallet")return re?jsx(View,{style:n.screen,children:jsxs(View,{style:A.centered,children:[jsx(ActivityIndicator,{size:"large",color:q}),jsx(Se,{error:x,progress:c,loading:l})]})}):jsx(KeyboardAvoidingView,{style:n.flex,behavior:Platform.OS==="ios"?"padding":void 0,children:jsxs(View,{style:n.screen,children:[jsx(Ze,{onPress:F}),jsxs(View,{style:n.content,children:[jsx(Text,{style:n.title,children:"Your crypto wallet"}),jsx(Text,{style:n.subtitle,children:"Enter the wallet address where you'd like to receive your crypto."}),jsxs(View,{style:n.fieldWrap,children:[jsx(Text,{style:n.fieldLabel,children:"Wallet address"}),jsx(TextInput,{style:[n.input,ke.input],placeholder:"0x...",placeholderTextColor:ye,autoCapitalize:"none",autoCorrect:false,value:T,onChangeText:se})]}),jsxs(View,{style:n.fieldWrap,children:[jsx(Text,{style:n.fieldLabel,children:"Network"}),jsx(View,{style:ke.list,children:Ir.map(h=>{let U=k===h.value;return jsxs(TouchableOpacity,{style:[ke.row,U&&ke.rowSelected],onPress:()=>{M(h.value),Le(h.defaultCrypto);},children:[jsx(View,{style:ke.iconWrap,children:jsx(h.Icon,{size:24})}),jsx(Text,{style:[ke.rowText,U&&ke.rowTextSelected],children:h.label}),U&&jsx(View,{style:ke.checkCircle,children:jsx(Text,{style:ke.check,children:"\u2713"})})]},h.value)})})]})]}),jsxs(View,{style:n.footer,children:[l?jsx(View,{style:n.continueBtn,children:jsx(ActivityIndicator,{color:"#fff"})}):jsx(TouchableOpacity,{style:[n.continueBtn,!T&&n.continueBtnDisabled],onPress:Fe,disabled:!T,children:jsx(Text,{style:[n.continueBtnText,!T&&n.continueBtnTextDisabled],children:"Continue"})}),jsx(Se,{error:x,progress:c,loading:l})]})]})});if(o==="session_params")return jsx(ht,{initialAmount:O,currency:y,onConfirm:h=>{ve(h),ge(be?"email":"payment_method");},onCancel:()=>{be?F():ge("wallet");}});if(o==="payment_method"){let h=Ir.find(U=>U.value===k)?.label??k;return jsxs(View,{style:n.screen,children:[jsx(Ze,{onPress:F}),jsxs(View,{style:n.content,children:[jsx(Text,{style:n.title,children:"How do you want to pay?"}),jsxs(View,{style:X.summary,children:[jsxs(View,{style:X.summaryCol,children:[jsx(Text,{style:X.summaryLabel,children:"You spend"}),jsxs(Text,{style:X.summaryAmount,children:["$",O," ",jsx(Text,{style:X.summaryCurrency,children:y.toUpperCase()})]})]}),jsx(View,{style:X.divider}),jsxs(View,{style:X.summaryCol,children:[jsx(Text,{style:X.summaryLabel,children:"You receive"}),jsxs(Text,{style:X.summaryDest,children:[N.toUpperCase(),jsxs(Text,{style:X.summaryNetwork,children:[" on ",h]})]})]})]})]}),jsxs(View,{style:n.footer,children:[l?jsx(View,{style:n.continueBtn,children:jsx(ActivityIndicator,{color:"#fff"})}):jsxs(Fragment,{children:[b&&jsx(TouchableOpacity,{style:X.applePayBtn,onPress:()=>K(true),children:jsxs(Text,{style:X.applePayBtnText,children:["Pay with ","\uF8FF"," Pay"]})}),jsx(TouchableOpacity,{style:n.continueBtn,onPress:()=>K(false),children:jsx(Text,{style:n.continueBtnText,children:"Pay with Card"})})]}),jsx(Se,{error:x,progress:c,loading:l})]})]})}if(o==="quote"&&D){let h=D.transaction_details,U=new Date(h.quote_expiration*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),w=h.wallet_address.slice(0,6)+"..."+h.wallet_address.slice(-4),V=Br(h.destination_amount,h.destination_currency);return jsxs(View,{style:n.screen,children:[jsx(View,{style:{opacity:l?0:1},pointerEvents:l?"none":"auto",children:jsx(Ze,{onPress:F})}),jsxs(View,{style:n.content,children:[jsx(Text,{style:n.title,children:"Review your purchase"}),jsxs(View,{style:E.heroBox,children:[jsx(Text,{style:E.heroLabel,children:"You receive"}),jsxs(Text,{style:E.heroAmount,children:[V," ",jsx(Text,{style:E.heroCurrency,children:h.destination_currency.toUpperCase()})]}),jsx(Text,{style:E.heroNetwork,children:h.destination_network})]}),jsxs(View,{style:E.card,children:[jsx(Xe,{label:"You pay",value:`${h.source_amount} ${h.source_currency.toUpperCase()}`}),jsx(Xe,{label:"Network fee",value:`$${h.fees.network_fee_amount}`}),jsx(Xe,{label:"Transaction fee",value:`$${h.fees.transaction_fee_amount}`}),jsx(Xe,{label:"Wallet",value:w,mono:true}),jsx(Xe,{label:"Quote expires",value:U,last:true})]})]}),jsxs(View,{style:n.footer,children:[l?jsx(View,{style:n.continueBtn,children:jsx(ActivityIndicator,{color:"#fff"})}):jsxs(Fragment,{children:[jsx(TouchableOpacity,{style:n.continueBtn,onPress:he,children:jsx(Text,{style:n.continueBtnText,children:"Confirm Purchase"})}),jsx(TouchableOpacity,{style:n.ghostBtn,onPress:ze,children:jsx(Text,{style:n.ghostBtnText,children:"Refresh Quote"})})]}),jsx(Se,{error:x,progress:c,loading:l})]})]})}if(o==="processing")return jsx(View,{style:n.screen,children:jsxs(View,{style:A.centered,children:[jsx(View,{style:A.spinnerWrap,children:jsx(ActivityIndicator,{size:"large",color:q})}),jsx(Text,{style:A.heading,children:"Processing your purchase"}),jsxs(Text,{style:A.sub,children:["Your payment has been confirmed.",`
|
|
2
|
-
`,"We're sending your crypto \u2014 this usually takes less than a minute."]})]})});if(o==="success"&&D){let h=D.transaction_details,U=Br(h.destination_amount,h.destination_currency),w=S||e?.recipientAddress||"";return jsxs(View,{style:n.screen,children:[jsxs(ScrollView,{contentContainerStyle:A.centered,showsVerticalScrollIndicator:false,children:[jsx(View,{style:A.checkCircle,children:jsx(Text,{style:A.checkMark,children:"\u2713"})}),jsx(Text,{style:A.heading,children:"Purchase complete!"}),jsx(Text,{style:A.sub,children:"Your crypto is on its way to your wallet."}),jsxs(View,{style:[E.heroBox,A.detailCard],children:[jsx(Text,{style:E.heroLabel,children:"You received"}),jsx(Text,{style:E.heroAmount,children:U}),jsxs(Text,{style:E.heroCurrency,children:[h.destination_currency.toUpperCase()," (",h.destination_network,")"]})]}),jsxs(View,{style:[E.card,A.detailCard],children:[jsx(Vr,{label:"Deposit Address",address:h.wallet_address}),w?jsx(Vr,{label:"Recipient Address",address:w,last:true}):jsx(Xe,{label:"Session",value:D.id.slice(0,8)+"..."+D.id.slice(-6),mono:true,last:true})]})]}),jsx(View,{style:n.footer,children:jsx(TouchableOpacity,{style:n.continueBtn,onPress:()=>{_e(),a?.();},children:jsx(Text,{style:n.continueBtnText,children:"Done"})})})]})}return null}function Ze({onPress:e}){return jsxs(View,{style:n.header,children:[jsx(View,{style:n.headerSpacer}),jsx(TouchableOpacity,{style:n.closeBtn,onPress:e,children:jsx(Text,{style:n.closeBtnText,children:"\u2715"})})]})}function Se({error:e,progress:a,loading:o}){return e?jsx(Text,{style:n.errorText,children:e.message}):a&&o&&__DEV__?jsx(Text,{style:n.progressText,children:a}):null}function Xe({label:e,value:a,mono:o,last:l}){return jsxs(View,{style:[E.row,l&&E.rowLast],children:[jsx(Text,{style:E.rowLabel,children:e}),jsx(Text,{style:[E.rowValue,o&&E.rowMono],children:a})]})}function Vr({label:e,address:a,last:o}){let[l,c]=useState(false),x=()=>{Clipboard.setString(a),c(true),setTimeout(()=>c(false),2e3);};return jsxs(TouchableOpacity,{style:[E.row,o&&E.rowLast,{flexDirection:"column",alignItems:"flex-start",gap:6}],onPress:x,activeOpacity:.7,children:[jsxs(View,{style:{flexDirection:"row",justifyContent:"space-between",width:"100%"},children:[jsx(Text,{style:E.rowLabel,children:e}),jsx(Text,{style:{fontSize:12,color:l?q:fe},children:l?"Copied!":"Tap to copy"})]}),jsx(Text,{style:[E.rowValue,E.rowMono,{fontSize:12,lineHeight:18}],selectable:true,children:a})]})}var n=StyleSheet.create({flex:{flex:1},screen:{flex:1,backgroundColor:Kn,paddingHorizontal:24,paddingBottom:48},header:{flexDirection:"row",justifyContent:"flex-end",paddingTop:60,paddingBottom:16},headerSpacer:{flex:1},closeBtn:{width:36,height:36,borderRadius:18,backgroundColor:Oe,alignItems:"center",justifyContent:"center"},closeBtnText:{color:fe,fontSize:14,fontWeight:"600"},content:{flex:1,paddingTop:16},title:{fontSize:28,fontWeight:"700",color:Pe,marginBottom:8},subtitle:{fontSize:15,color:fe,marginBottom:36,lineHeight:22},fieldWrap:{marginBottom:20},fieldLabel:{fontSize:13,color:fe,fontWeight:"600",marginBottom:8,textTransform:"uppercase",letterSpacing:.5},input:{backgroundColor:Oe,borderRadius:12,padding:16,fontSize:17,color:Pe,borderWidth:1,borderColor:Be},hint:{fontSize:12,color:ye,marginTop:8},emailRow:{flexDirection:"row",alignItems:"center",gap:6,marginTop:4,backgroundColor:Oe,paddingHorizontal:14,paddingVertical:10,borderRadius:10},emailLabel:{fontSize:13,color:ye},emailValue:{fontSize:13,color:Pe,fontWeight:"600"},footer:{gap:12},continueBtn:{backgroundColor:q,borderRadius:24,paddingVertical:18,alignItems:"center"},continueBtnDisabled:{backgroundColor:Oe},continueBtnText:{color:"#000000",fontSize:17,fontWeight:"700"},continueBtnTextDisabled:{color:ye},ghostBtn:{paddingVertical:16,alignItems:"center"},ghostBtnText:{color:fe,fontSize:15,fontWeight:"500"},errorText:{fontSize:14,color:Un,textAlign:"center",lineHeight:20,marginTop:24},progressText:{fontSize:13,color:ye,textAlign:"center",lineHeight:18,marginTop:24}}),E=StyleSheet.create({heroBox:{backgroundColor:Oe,borderRadius:16,padding:24,alignItems:"center",marginBottom:16,marginTop:8,borderWidth:1,borderColor:Be,gap:4},heroLabel:{fontSize:13,color:ye,fontWeight:"600",letterSpacing:.5,textTransform:"uppercase"},heroAmount:{fontSize:48,fontWeight:"700",color:Pe,letterSpacing:-1},heroCurrency:{fontSize:22,fontWeight:"500",color:q},heroNetwork:{fontSize:13,color:ye,marginTop:2},card:{backgroundColor:Oe,borderRadius:16,borderWidth:1,borderColor:Be,overflow:"hidden"},row:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:14,paddingHorizontal:16,borderBottomWidth:1,borderBottomColor:Be},rowLast:{borderBottomWidth:0},rowLabel:{fontSize:14,color:fe},rowValue:{fontSize:14,fontWeight:"600",color:Pe},rowMono:{fontFamily:Platform.OS==="ios"?"Menlo":"monospace",fontSize:13}}),X=StyleSheet.create({summary:{backgroundColor:Oe,borderRadius:16,padding:20,marginTop:16,marginBottom:28,borderWidth:1,borderColor:Be,gap:16},summaryCol:{gap:4},summaryLabel:{fontSize:12,color:ye,fontWeight:"600",textTransform:"uppercase",letterSpacing:.3},summaryAmount:{fontSize:24,fontWeight:"700",color:Pe},summaryCurrency:{fontSize:14,fontWeight:"400",color:fe},summaryDest:{fontSize:24,fontWeight:"700",color:q},summaryNetwork:{fontSize:13,fontWeight:"400",color:fe},divider:{height:1,backgroundColor:Be},applePayBtn:{backgroundColor:Pe,borderRadius:24,paddingVertical:18,alignItems:"center",marginBottom:10},applePayBtnText:{color:"#000",fontSize:17,fontWeight:"700"}}),ke=StyleSheet.create({input:{fontSize:14,fontFamily:Platform.OS==="ios"?"Menlo":"monospace"},list:{gap:8},row:{flexDirection:"row",alignItems:"center",paddingVertical:14,paddingHorizontal:16,borderRadius:14,borderWidth:1,borderColor:Be,backgroundColor:Oe},rowSelected:{borderColor:q,backgroundColor:Lr},iconWrap:{width:32,height:32,alignItems:"center",justifyContent:"center",marginRight:12},rowText:{flex:1,fontSize:15,color:fe,fontWeight:"500"},rowTextSelected:{color:Pe,fontWeight:"600"},checkCircle:{width:24,height:24,borderRadius:12,backgroundColor:q,alignItems:"center",justifyContent:"center"},check:{fontSize:14,color:"#000",fontWeight:"700"}}),A=StyleSheet.create({centered:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:24},spinnerWrap:{width:80,height:80,borderRadius:40,backgroundColor:Oe,borderWidth:1,borderColor:Be,alignItems:"center",justifyContent:"center",marginBottom:28},idIcon:{fontSize:36},checkCircle:{width:80,height:80,borderRadius:40,backgroundColor:Lr,borderWidth:2,borderColor:q,alignItems:"center",justifyContent:"center",marginBottom:28},checkMark:{fontSize:36,color:q,fontWeight:"600"},heading:{fontSize:28,fontWeight:"700",color:Pe,textAlign:"center",marginBottom:10},sub:{fontSize:15,color:fe,textAlign:"center",lineHeight:22,marginBottom:36},detailCard:{width:"100%"}});var qn="https://api.unifold.io",Qn="https://api-staging.unifold.io";function Jn(){return typeof __DEV__<"u"&&__DEV__?Qn:qn}function Pt({publishableKey:e,email:a,phone:o,externalUserId:l,flowOrder:c,destinationChainType:x="ethereum",destinationChainId:B="8453",destinationTokenAddress:L,recipientAddress:D,onComplete:W,onError:T,onStepChange:S,onClose:k,merchantIdentifier:O="merchant.io.unifold",urlScheme:y="unifoldOnramp"}){let N=e||wt(),[b,Ve]=useState("loading"),[m,ge]=useState(null);useEffect(()=>{let C=false;async function se(){try{N&&(xt(N),Ct(Jn()));let M=await Tt();if(C||(await initStripe({publishableKey:M,merchantIdentifier:O,urlScheme:y}),C))return;Ve("ready");}catch(M){if(C)return;console.error("[StripeOnramp] Init failed:",M),ge(M?.message??"Failed to load Stripe configuration"),Ve("error");}}return se(),()=>{C=true;}},[N,O,y]);let te=useMemo(()=>{let C={publishableKey:N,externalUserId:l,destinationChainType:x,destinationChainId:B,onComplete:W,onError:T,onStepChange:S};return L&&(C.destinationTokenAddress=L),D&&(C.recipientAddress=D),a&&(C.email=a),o&&(C.phone=o),c&&(C.flowOrder=c),C},[N,l,x,B,L,D,a,o,c,W,T,S]);return b==="error"?jsxs(View,{style:et.centered,children:[jsx(Text,{style:et.errorText,children:"Unable to initialize"}),jsx(Text,{style:et.errorDetail,children:m}),k&&jsx(TouchableOpacity,{style:et.retryBtn,onPress:k,children:jsx(Text,{style:et.retryBtnText,children:"Go Back"})})]}):b==="loading"?jsx(View,{style:et.centered,children:jsx(ActivityIndicator,{size:"large",color:"#00D924"})}):jsx(Ot,{config:te,onComplete:k})}var et=StyleSheet.create({centered:{flex:1,justifyContent:"center",alignItems:"center",backgroundColor:"#000000",paddingHorizontal:24},errorText:{color:"#FF453A",fontSize:18,fontWeight:"600",marginBottom:8},errorDetail:{color:"#8E8E93",fontSize:14,textAlign:"center",marginBottom:24},retryBtn:{backgroundColor:"#00D924",borderRadius:24,paddingVertical:14,paddingHorizontal:32},retryBtnText:{color:"#000000",fontSize:16,fontWeight:"700"}});function zr(){let{configure:e}=useOnramp(),a=useRef(false);return useEffect(()=>{a.current||(a.current=true,e({merchantDisplayName:"Unifold",appearance:{lightColors:{primary:"#2d22a1",contentOnPrimary:"#ffffff",borderSelected:"#07b8b8"},darkColors:{primary:"#800080",contentOnPrimary:"#ffffff",borderSelected:"#526f3e"},style:"ALWAYS_DARK",primaryButton:{cornerRadius:8,height:48}}}).then(o=>{o.error&&console.error("[StripeOnrampPreconfigure] error:",o.error.message);}).catch(o=>{console.error("[StripeOnrampPreconfigure] threw:",o?.message);}));},[e]),null}or(Pt);
|
|
3
|
-
export{
|
|
1
|
+
import {createContext,useState,useRef,useEffect,useCallback,useMemo,useContext,useId,Fragment as Fragment$1}from'react';import {StyleSheet,View,Text,TouchableOpacity,KeyboardAvoidingView,ScrollView,TextInput,Platform,Keyboard,Animated,Easing,Clipboard}from'react-native';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import Ot,{G,Path,Defs,ClipPath,Rect,LinearGradient,Stop,Circle,Line,Polyline}from'react-native-svg';import {Onramp,useOnramp,isPlatformPaySupported,PlatformPay,initStripe}from'@stripe/stripe-react-native';var $o="__unifold_stripe_onramp__";function Fr(e){globalThis[$o]=e;}var Dr={dark:{background:"#2D2C2F",card:"#3A393C",cardHover:"#48474A",foreground:"#F8FAFC",foregroundMuted:"#94A3B8",foregroundSubtle:"#64748B",border:"#38383A",borderSecondary:"#48484A",primary:"#3B82F6",primaryForeground:"#FFFFFF",success:"#22C55E",successBackground:"rgba(34, 197, 94, 0.1)",warning:"#F59E0B",warningBackground:"rgba(245, 158, 11, 0.1)",error:"#EF4444",errorBackground:"rgba(239, 68, 68, 0.1)",overlay:"rgba(0, 0, 0, 0.7)"}},mr=Dr;function Kt(e,r){return r?{...e,...r,shadowOffset:r.shadowOffset??e.shadowOffset,backShadowOffset:r.backShadowOffset??e.backShadowOffset}:e}function fr(e,r,o){let t=(b,k,S)=>{return S},l={backgroundColor:t("card","backgroundColor",e.card),titleColor:t("card","titleColor",e.foreground),subtitleColor:t("card","subtitleColor",e.foregroundMuted),labelColor:t("card","labelColor",e.foregroundMuted),headerColor:t("card","headerColor",e.foregroundMuted),labelRightColor:t("card","labelRightColor",e.foregroundMuted),labelHighlightRightColor:t("card","labelHighlightRightColor",e.warning),textRightColor:t("card","textRightColor",e.foreground),subtextRightColor:t("card","subtextRightColor",e.foregroundMuted),rowLeftLabel:t("card","rowLeftLabel",e.foregroundMuted),rowRightLabel:t("card","rowRightLabel",e.foreground),iconColor:t("card","iconColor",e.primary),iconBackgroundColor:t("card","iconBackgroundColor",e.primary+"26"),actionColor:t("card","actionColor",e.foregroundMuted),actionIcon:t("card","actionIcon",e.foregroundMuted),descriptionColor:t("card","descriptionColor",e.foregroundMuted),borderRadius:t("card","borderRadius",12),borderWidth:t("card","borderWidth",0),borderColor:t("card","borderColor",e.border),shadowColor:t("card","shadowColor","#000"),shadowOffset:t("card","shadowOffset",{width:0,height:-4}),shadowOpacity:t("card","shadowOpacity",0),shadowRadius:t("card","shadowRadius",12),elevation:t("card","elevation",0),iconContainerBorderRadius:t("card","iconContainerBorderRadius",12),backShadowColor:"transparent",backShadowOffset:{top:4,left:4,right:-4,bottom:-4},backShadowSpacing:8},s=(r?.depositMenu)?.card,h=(r?.transferCrypto)?.depositAddress?.card,a=(r?.depositCard)?.quoteProvider?.card,p=(r?.depositTracker)?.executionRow?.card;return {header:{titleColor:t("header","titleColor",e.foreground),buttonColor:t("header","buttonColor",e.foreground)},card:l,input:{backgroundColor:t("input","backgroundColor",t("search","backgroundColor",e.card)),textColor:t("input","textColor",t("search","inputColor",e.foreground)),placeholderColor:t("input","placeholderColor",t("search","placeholderColor",e.foregroundMuted)),borderColor:t("input","borderColor",e.border),borderRadius:t("input","borderRadius",t("search","borderRadius",8)),borderWidth:t("input","borderWidth",1)},button:{primaryBackground:t("button","primaryBackground",e.primary),primaryText:t("button","primaryText",e.primaryForeground),secondaryBackground:t("button","secondaryBackground",e.card),secondaryText:t("button","secondaryText",e.foreground),borderRadius:t("button","borderRadius",12),borderWidth:t("button","borderWidth",0),borderColor:t("button","borderColor",e.border)},container:{titleColor:t("container","titleColor",e.foreground),subtitleColor:t("container","subtitleColor",e.foregroundMuted),actionColor:t("container","actionColor",e.foregroundMuted),actionTitle:t("container","actionTitle",e.foregroundMuted),buttonColor:t("container","buttonColor",e.primary),buttonTitleColor:t("container","buttonTitleColor",e.primaryForeground),iconBackgroundColor:t("container","iconBackgroundColor",e.success),iconColor:t("container","iconColor",e.foreground)},search:{backgroundColor:t("search","backgroundColor",e.card),inputColor:t("search","inputColor",e.foreground),placeholderColor:t("search","placeholderColor",e.foregroundMuted),borderRadius:t("search","borderRadius",8)},list:{titleSectionColor:t("list","titleSectionColor",e.foregroundMuted),rowBorderRadius:t("list","rowBorderRadius",12)},badge:{borderRadius:t("badge","borderRadius",8)},sheet:{shadowColor:t("sheet","shadowColor","#000"),shadowOffset:t("sheet","shadowOffset",{width:0,height:-4}),shadowOpacity:t("sheet","shadowOpacity",.1),shadowRadius:t("sheet","shadowRadius",12),elevation:t("sheet","elevation",16)},depositMenu:{card:Kt(l,s)},transferCrypto:{depositAddress:{card:Kt(l,h)}},depositCard:{quoteProvider:{card:Kt(l,a)}},depositTracker:{executionRow:{card:Kt(l,p)}}}}var Go=createContext(null);function L(){let e=useContext(Go);if(!e){let r=mr.dark;return {mode:"dark",colors:r,fonts:{regular:void 0,medium:void 0,semibold:void 0,bold:void 0},components:fr(r,void 0),isDark:true}}return e}function Er({size:e=24,color:r="#fff",strokeWidth:o=2}){return jsxs(Ot,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Line,{x1:"19",y1:"12",x2:"5",y2:"12",stroke:r,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"12 19 5 12 12 5",stroke:r,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function zt({size:e=24,color:r="#fff",strokeWidth:o=2}){return jsxs(Ot,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Line,{x1:"18",y1:"6",x2:"6",y2:"18",stroke:r,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"6",y1:"6",x2:"18",y2:"18",stroke:r,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Wr({size:e=24,color:r="#fff",strokeWidth:o=2}){return jsx(Ot,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsx(Polyline,{points:"6 9 12 15 18 9",stroke:r,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})})}function Mr({size:e=24,color:r="#fff",strokeWidth:o=2}){return jsxs(Ot,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Rect,{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2",stroke:r,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1",stroke:r,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function lt({size:e=24,color:r="#fff",strokeWidth:o=2}){return jsx(Ot,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsx(Polyline,{points:"20 6 9 17 4 12",stroke:r,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})})}function jr({size:e=28}){return jsx(Ot,{width:e,height:e,viewBox:"0 0 28 28",fill:"none",children:jsxs(G,{fillRule:"evenodd",children:[jsx(Path,{fill:"#0052FF",fillRule:"nonzero",d:"M14 28a14 14 0 1 0 0-28 14 14 0 0 0 0 28"}),jsx(Path,{fill:"#FFF",d:"M13.967 23.86c5.445 0 9.86-4.415 9.86-9.86s-4.415-9.86-9.86-9.86c-5.166 0-9.403 3.974-9.825 9.03h14.63v1.642H4.142c.413 5.065 4.654 9.047 9.826 9.047Z"})]})})}function zr({size:e=28}){return jsxs(Ot,{width:e,height:e,viewBox:"0 0 28 28",fill:"none",children:[jsxs(G,{clipPath:"url(#eth_clip)",children:[jsx(Path,{d:"M14 28C21.732 28 28 21.732 28 14C28 6.26801 21.732 0 14 0C6.26801 0 0 6.26801 0 14C0 21.732 6.26801 28 14 28Z",fill:"#627EEA"}),jsx(Path,{d:"M14.4357 3.5V11.2612L20.9956 14.1925L14.4357 3.5Z",fill:"white",fillOpacity:.602}),jsx(Path,{d:"M14.4357 3.5L7.875 14.1925L14.4357 11.2612V3.5Z",fill:"white"}),jsx(Path,{d:"M14.4357 19.222V24.4956L21 15.414L14.4357 19.222Z",fill:"white",fillOpacity:.602}),jsx(Path,{d:"M14.4357 24.4956V19.2211L7.875 15.414L14.4357 24.4956Z",fill:"white"}),jsx(Path,{d:"M14.4357 18.0014L20.9956 14.1925L14.4357 11.263V18.0014Z",fill:"white",fillOpacity:.2}),jsx(Path,{d:"M7.875 14.1925L14.4357 18.0014V11.263L7.875 14.1925Z",fill:"white",fillOpacity:.602})]}),jsx(Defs,{children:jsx(ClipPath,{id:"eth_clip",children:jsx(Rect,{width:28,height:28,fill:"white"})})})]})}function Hr({size:e=28}){return jsxs(Ot,{width:e,height:e,viewBox:"0 0 28 28",fill:"none",children:[jsxs(G,{clipPath:"url(#btc_clip)",children:[jsx(Path,{d:"M14 28C21.732 28 28 21.732 28 14C28 6.26801 21.732 0 14 0C6.26801 0 0 6.26801 0 14C0 21.732 6.26801 28 14 28Z",fill:"#F7931A"}),jsx(Path,{d:"M20.0594 12.1625C20.3438 10.2594 18.9 9.23124 16.9203 8.55311L17.5656 5.97186L15.9906 5.57811L15.3672 8.09374C14.9516 7.9953 14.525 7.89686 14.0985 7.79843L14.7328 5.27186L13.1578 4.87811L12.5125 7.45936C12.1735 7.3828 11.8344 7.30624 11.5063 7.22968V7.21874L9.34065 6.67186L8.92502 8.35624C8.92502 8.35624 10.0844 8.61874 10.0625 8.64061C10.6969 8.79374 10.8063 9.2203 10.7844 9.54843L10.0625 12.4578C10.1063 12.4687 10.161 12.4797 10.2266 12.5125C10.1828 12.5016 10.1281 12.4906 10.0735 12.4687L9.05627 16.5375C8.97971 16.7344 8.78284 17.0187 8.34534 16.9094C8.36721 16.9312 7.20784 16.625 7.20784 16.625L6.43127 18.4297L8.47659 18.9437C8.8594 19.0422 9.23127 19.1406 9.59221 19.2281L8.9469 21.8422L10.5219 22.2359L11.1672 19.6547C11.5938 19.775 12.0094 19.8734 12.4141 19.9828L11.7688 22.5531L13.3438 22.9469L13.9891 20.3328C16.6578 20.8359 18.6594 20.6281 19.5016 18.2219C20.1797 16.2859 19.4688 15.1703 18.0688 14.4375C19.086 14.2078 19.8516 13.5406 20.0594 12.1625ZM16.4938 17.1609C16.0125 19.0969 12.7531 18.0469 11.6922 17.7844L12.5453 14.35C13.6063 14.6125 16.9969 15.1484 16.4938 17.1609ZM16.975 12.1297C16.5375 13.8906 13.825 12.9937 12.95 12.775L13.7266 9.6578C14.6016 9.87655 17.4344 10.2812 16.975 12.1297Z",fill:"white"})]}),jsx(Defs,{children:jsx(ClipPath,{id:"btc_clip",children:jsx(Rect,{width:28,height:28,fill:"white"})})})]})}function qr({size:e=28}){return jsxs(Ot,{width:e,height:e,viewBox:"0 0 256 256",fill:"none",children:[jsxs(Defs,{children:[jsxs(LinearGradient,{id:"sol1",x1:"360.9",y1:"-37.5",x2:"141.2",y2:"383.3",gradientUnits:"userSpaceOnUse",children:[jsx(Stop,{offset:"0",stopColor:"#00FFA3"}),jsx(Stop,{offset:"1",stopColor:"#DC1FFF"})]}),jsxs(LinearGradient,{id:"sol2",x1:"264.8",y1:"-87.6",x2:"45.16",y2:"333.15",gradientUnits:"userSpaceOnUse",children:[jsx(Stop,{offset:"0",stopColor:"#00FFA3"}),jsx(Stop,{offset:"1",stopColor:"#DC1FFF"})]}),jsxs(LinearGradient,{id:"sol3",x1:"312.55",y1:"-62.69",x2:"92.88",y2:"358.06",gradientUnits:"userSpaceOnUse",children:[jsx(Stop,{offset:"0",stopColor:"#00FFA3"}),jsx(Stop,{offset:"1",stopColor:"#DC1FFF"})]})]}),jsx(Circle,{cx:128,cy:128,r:128,fill:"black"}),jsxs(G,{transform:"translate(128,128) scale(0.35) translate(-198.85,-156)",children:[jsx(Path,{fill:"url(#sol2)",d:"M64.6,3.8C67.1,1.4,70.4,0,73.8,0h317.4c5.8,0,8.7,7,4.6,11.1l-62.7,62.7c-2.4,2.4-5.7,3.8-9.2,3.8H6.5c-5.8,0-8.7-7-4.6-11.1L64.6,3.8z"}),jsx(Path,{fill:"url(#sol3)",d:"M333.1,120.1c-2.4-2.4-5.7-3.8-9.2-3.8H6.5c-5.8,0-8.7,7-4.6,11.1l62.7,62.7c2.4,2.4,5.7,3.8,9.2,3.8h317.4c5.8,0,8.7-7,4.6-11.1L333.1,120.1z"}),jsx(Path,{fill:"url(#sol1)",d:"M64.6,237.9c2.4-2.4,5.7-3.8,9.2-3.8h317.4c5.8,0,8.7,7,4.6,11.1l-62.7,62.7c-2.4,2.4-5.7,3.8-9.2,3.8H6.5c-5.8,0-8.7-7-4.6-11.1L64.6,237.9z"})]})]})}function Yr({size:e=28}){return jsx(Ot,{width:e,height:e,viewBox:"0 0 32 32",fill:"none",children:jsxs(G,{children:[jsx(Circle,{cx:16,cy:16,r:16,fill:"#6F41D8"}),jsx(Path,{fill:"#FFF",d:"M21.092 12.693c-.369-.215-.848-.215-1.254 0l-2.879 1.654-1.955 1.078-2.879 1.653c-.369.216-.848.216-1.254 0l-2.288-1.294c-.369-.215-.627-.61-.627-1.042V12.19c0-.431.221-.826.627-1.042l2.25-1.258c.37-.216.85-.216 1.256 0l2.25 1.258c.37.216.628.611.628 1.042v1.654l1.955-1.115v-1.653a1.16 1.16 0 0 0-.627-1.042l-4.17-2.372c-.369-.216-.848-.216-1.254 0l-4.244 2.372A1.16 1.16 0 0 0 6 11.076v4.78c0 .432.221.827.627 1.043l4.244 2.372c.369.215.849.215 1.254 0l2.879-1.618 1.955-1.114 2.879-1.617c.369-.216.848-.216 1.254 0l2.251 1.258c.37.215.627.61.627 1.042v2.552c0 .431-.22.826-.627 1.042l-2.25 1.294c-.37.216-.85.216-1.255 0l-2.251-1.258c-.37-.216-.628-.611-.628-1.042v-1.654l-1.955 1.115v1.653c0 .431.221.827.627 1.042l4.244 2.372c.369.216.848.216 1.254 0l4.244-2.372c.369-.215.627-.61.627-1.042v-4.78a1.16 1.16 0 0 0-.627-1.042l-4.28-2.409z"})]})})}var ut=[{label:"Base",value:Onramp.CryptoNetwork.base,defaultCrypto:"usdc",Icon:jr},{label:"Ethereum",value:Onramp.CryptoNetwork.ethereum,defaultCrypto:"eth",Icon:zr},{label:"Bitcoin",value:Onramp.CryptoNetwork.bitcoin,defaultCrypto:"btc",Icon:Hr},{label:"Solana",value:Onramp.CryptoNetwork.solana,defaultCrypto:"sol",Icon:qr},{label:"Polygon",value:Onramp.CryptoNetwork.polygon,defaultCrypto:"matic",Icon:Yr}];function Gr(e,r=8,o=4){let n=e.trim();return n.length<=r+o+3?n:`${n.slice(0,r)}...${n.slice(-o)}`}function Ut(e,r){let o=parseFloat(e);if(isNaN(o))return e;let n=r.toLowerCase(),t=["eth","btc"].includes(n)?4:2;return o.toFixed(t)}function $t(e){let r=e.trim().toLowerCase();if(!r)return e.trim();let o=ut.find(t=>t.label.toLowerCase()===r);if(o)return o.label;let n=ut.find(t=>String(t.value).toLowerCase()===r);return n?n.label:e.trim()}function R({onPress:e,title:r}){let{components:o,fonts:n}=L(),t=jsx(TouchableOpacity,{style:pt.closeBtn,onPress:e,hitSlop:{top:10,bottom:10,left:10,right:10},accessibilityRole:"button",accessibilityLabel:"Close",children:jsx(zt,{size:20,color:o.header.buttonColor,strokeWidth:2})});return r?jsxs(View,{style:pt.headerWithTitle,children:[jsx(View,{style:pt.headerSide}),jsx(Text,{style:[pt.headerTitleText,{color:o.header.titleColor},...n.bold?[{fontFamily:n.bold}]:[]],numberOfLines:1,ellipsizeMode:"tail",accessibilityRole:"header",children:r}),t]}):jsxs(View,{style:pt.header,children:[jsx(View,{style:pt.headerSpacer}),t]})}var Ht={paddingTop:60,paddingBottom:16},pt=StyleSheet.create({header:{flexDirection:"row",justifyContent:"flex-end",...Ht},headerWithTitle:{flexDirection:"row",alignItems:"center",...Ht},headerSpacer:{flex:1},headerSide:{width:28},headerTitleText:{flex:1,textAlign:"center",fontSize:17},closeBtn:{width:28,height:28,borderRadius:8,backgroundColor:"transparent",alignItems:"center",justifyContent:"center"}});function D({error:e,progress:r,loading:o}){let{colors:n,fonts:t}=L();return e?jsx(Text,{style:[Qr.errorText,{color:n.error},...t.regular?[{fontFamily:t.regular}]:[]],children:e.message}):r&&o&&__DEV__?jsx(Text,{style:[Qr.progressText,{color:n.foregroundSubtle},...t.regular?[{fontFamily:t.regular}]:[]],children:r}):null}var Qr=StyleSheet.create({errorText:{fontSize:14,textAlign:"center",lineHeight:20,marginTop:24},progressText:{fontSize:13,textAlign:"center",lineHeight:18,marginTop:24}});function De({quote:e,label:r,value:o,mono:n,last:t}){return jsxs(Fragment$1,{children:[jsxs(View,{style:e.row,children:[jsx(Text,{style:e.rowLabel,children:r}),jsx(Text,{style:[e.rowValue,n&&e.rowMono],children:o})]}),t?null:jsx(View,{style:e.rowDivider})]})}function Sr({quote:e,label:r,address:o,last:n}){let[t,l]=useState(false),{colors:s,components:h}=L(),a=()=>{Clipboard.setString(o),l(true),setTimeout(()=>l(false),2e3);},p=Gr(o);return jsxs(Fragment$1,{children:[jsxs(View,{style:e.row,children:[jsx(Text,{style:e.rowLabel,children:r}),jsxs(View,{style:e.rowRight,children:[jsx(Text,{style:[e.rowValue,e.rowMono,{flexShrink:1,minWidth:0}],numberOfLines:1,ellipsizeMode:"middle",selectable:true,children:p}),jsx(TouchableOpacity,{onPress:a,hitSlop:{top:10,bottom:10,left:10,right:10},accessibilityRole:"button",accessibilityLabel:`Copy ${r}`,children:t?jsx(lt,{size:14,color:s.success,strokeWidth:2.5}):jsx(Mr,{size:14,color:h.card.actionIcon,strokeWidth:2})})]})]}),n?null:jsx(View,{style:e.rowDivider})]})}function mt(){let{colors:e,fonts:r,components:o}=L(),n=o.input,t=o.button,l=o.container,s=o.card,h=o.header;return useMemo(()=>{let a=s.borderRadius,p=Platform.OS==="ios"?"Menlo":"monospace",b={flex:{flex:1},screen:{flex:1,backgroundColor:e.background,paddingHorizontal:24,paddingBottom:48},content:{flex:1,paddingTop:16},title:{fontSize:28,color:h.titleColor,marginBottom:8,...r.bold?{fontFamily:r.bold}:{}},subtitle:{fontSize:15,color:e.foregroundMuted,marginBottom:36,lineHeight:22,...r.regular?{fontFamily:r.regular}:{}},fieldWrap:{marginBottom:20},fieldLabel:{fontSize:13,color:e.foregroundSubtle,marginBottom:8,textTransform:"uppercase",letterSpacing:.5,...r.semibold?{fontFamily:r.semibold}:{}},input:{backgroundColor:n.backgroundColor,borderRadius:n.borderRadius,padding:16,fontSize:17,color:n.textColor,borderWidth:n.borderWidth,borderColor:n.borderColor,...r.regular?{fontFamily:r.regular}:{}},hint:{fontSize:12,color:e.foregroundSubtle,marginTop:8,...r.regular?{fontFamily:r.regular}:{}},emailRow:{flexDirection:"row",alignItems:"center",gap:6,marginTop:4,backgroundColor:e.card,paddingHorizontal:14,paddingVertical:10,borderRadius:Math.min(a,12)},emailLabel:{fontSize:13,color:e.foregroundSubtle,...r.regular?{fontFamily:r.regular}:{}},emailValue:{fontSize:13,color:e.foreground,...r.semibold?{fontFamily:r.semibold}:{}},footer:{gap:4},continueBtn:{backgroundColor:l.buttonColor,borderRadius:t.borderRadius,paddingVertical:18,alignItems:"center"},continueBtnDisabled:{backgroundColor:e.card},continueBtnText:{color:l.buttonTitleColor,fontSize:17,...r.bold?{fontFamily:r.bold}:{}},continueBtnTextDisabled:{color:e.foregroundSubtle,...r.regular?{fontFamily:r.regular}:{}},ghostBtn:{paddingVertical:16,alignItems:"center"},ghostBtnText:{color:e.foregroundMuted,fontSize:15,...r.medium?{fontFamily:r.medium}:{}},loaderInButton:{justifyContent:"center",alignItems:"center"}},k={amountContainer:{flex:1,alignItems:"center",justifyContent:"center",gap:8},amountText:{fontSize:64,color:e.foreground,letterSpacing:-2,minWidth:80,textAlign:"center",...r.regular?{fontFamily:r.regular}:{}},amountPlaceholder:{color:e.foregroundSubtle},currencyLabel:{fontSize:15,color:e.foregroundMuted,letterSpacing:1,...r.medium?{fontFamily:r.medium}:{}},numpad:{gap:4,marginBottom:24},numpadRow:{flexDirection:"row",justifyContent:"space-between"},numpadKey:{flex:1,height:68,alignItems:"center",justifyContent:"center",marginHorizontal:4},numpadKeyText:{fontSize:28,color:e.foreground,...r.regular?{fontFamily:r.regular}:{}},backspaceText:{fontSize:22,color:e.foregroundMuted,...r.regular?{fontFamily:r.regular}:{}}},S={heroBox:{backgroundColor:s.backgroundColor,borderRadius:a,padding:24,alignItems:"center",marginBottom:16,marginTop:8,borderWidth:s.borderWidth,borderColor:s.borderColor,gap:4},heroLabel:{fontSize:12,color:e.foregroundSubtle,letterSpacing:.5,textTransform:"uppercase",...r.semibold?{fontFamily:r.semibold}:{}},heroAmount:{fontSize:48,color:e.foreground,letterSpacing:-1,...r.bold?{fontFamily:r.bold}:{}},heroCurrency:{fontSize:22,color:e.primary,...r.medium?{fontFamily:r.medium}:{}},heroNetwork:{fontSize:15,color:e.foregroundSubtle,marginTop:2,...r.medium?{fontFamily:r.medium}:{}},card:{backgroundColor:s.backgroundColor,borderRadius:a,borderWidth:s.borderWidth,borderColor:s.borderColor,overflow:"hidden",marginBottom:12},row:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:14,paddingHorizontal:16},rowRight:{flex:1,minWidth:0,flexDirection:"row",alignItems:"center",justifyContent:"flex-end",gap:8},rowDivider:{height:1,marginHorizontal:16,backgroundColor:e.border},rowLabel:{fontSize:14,color:s.rowLeftLabel,...r.regular?{fontFamily:r.regular}:{}},rowValue:{fontSize:14,fontWeight:"500",color:s.rowRightLabel,...r.medium?{fontFamily:r.medium}:{}},rowMono:{fontFamily:p,fontSize:13}},c=Math.max(16,Math.min(a,22)),d={stackWrapper:{width:"100%",marginBottom:8,marginTop:4},swapCard:{backgroundColor:e.card,borderWidth:s.borderWidth,borderColor:e.border,paddingHorizontal:16,paddingVertical:16},swapCardTop:{borderTopLeftRadius:c,borderTopRightRadius:c,borderBottomLeftRadius:10,borderBottomRightRadius:10},swapCardBottom:{borderBottomLeftRadius:c,borderBottomRightRadius:c,borderTopLeftRadius:10,borderTopRightRadius:10,marginTop:16},swapConnectorWrap:{alignSelf:"center",zIndex:3,marginTop:-24,marginBottom:-32},swapConnectorCircle:{width:48,height:48,borderRadius:24,backgroundColor:e.primary,alignItems:"center",justifyContent:"center",borderWidth:4,borderColor:e.background},swapRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginTop:8,gap:12},swapLeftCol:{flex:1,minWidth:0},swapSpendAmount:{fontSize:40,color:e.foreground,letterSpacing:-1,...r.regular?{fontFamily:r.regular}:{}},swapReceivePrimary:{fontSize:40,color:e.foreground,letterSpacing:-1,...r.regular?{fontFamily:r.regular}:{}},swapReceiveSub:{fontSize:13,color:e.foregroundMuted,marginTop:4,...r.regular?{fontFamily:r.regular}:{}},swapPill:{flexDirection:"row",alignItems:"center",gap:6,paddingVertical:10,paddingHorizontal:14,borderRadius:999,backgroundColor:e.cardHover,borderWidth:s.borderWidth,borderColor:e.border},swapPillText:{fontSize:16,color:e.foreground,...r.semibold?{fontFamily:r.semibold}:{}},payHint:{fontSize:15,color:e.foregroundMuted,textAlign:"center",marginBottom:18,marginTop:4,...r.regular?{fontFamily:r.regular}:{}},summaryLabel:{fontSize:12,color:e.foregroundSubtle,textTransform:"uppercase",letterSpacing:.3,...r.semibold?{fontFamily:r.semibold}:{}},applePayBtn:{backgroundColor:t.secondaryBackground,borderRadius:t.borderRadius,borderWidth:t.borderWidth>0?t.borderWidth:1,borderColor:t.borderWidth>0?t.borderColor:e.border,paddingVertical:18,alignItems:"center",marginBottom:10},applePayBtnText:{color:t.secondaryText,fontSize:17,...r.bold?{fontFamily:r.bold}:{}}},_={input:{fontSize:14,fontFamily:p},list:{gap:8},row:{flexDirection:"row",alignItems:"center",paddingVertical:14,paddingHorizontal:16,borderRadius:Math.min(a,14),borderWidth:s.borderWidth,borderColor:e.border,backgroundColor:e.card},rowSelected:{borderColor:e.primary,backgroundColor:e.successBackground},iconWrap:{width:32,height:32,alignItems:"center",justifyContent:"center",marginRight:12},rowText:{flex:1,fontSize:15,color:e.foregroundMuted,...r.medium?{fontFamily:r.medium}:{}},rowTextSelected:{color:e.foreground,...r.semibold?{fontFamily:r.semibold}:{}},checkCircle:{width:24,height:24,borderRadius:12,backgroundColor:e.primary,alignItems:"center",justifyContent:"center"}},w={centered:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:24},spinnerWrap:{width:80,height:80,borderRadius:40,backgroundColor:e.card,borderWidth:s.borderWidth,borderColor:e.border,alignItems:"center",justifyContent:"center",marginBottom:28},idIcon:{fontSize:36},checkCircle:{width:80,height:80,borderRadius:40,backgroundColor:e.successBackground,borderWidth:2,borderColor:e.success,alignItems:"center",justifyContent:"center",marginBottom:28},heading:{fontSize:28,color:h.titleColor,textAlign:"center",marginBottom:10,...r.bold?{fontFamily:r.bold}:{}},sub:{fontSize:15,color:e.foregroundMuted,textAlign:"center",lineHeight:22,marginBottom:36,...r.regular?{fontFamily:r.regular}:{}},successScrollContent:{flexGrow:1,width:"100%",alignItems:"center",paddingBottom:24},detailCard:{width:"100%"}};return {form:b,quote:S,pm:d,wallet:_,flow:w,amount:k}},[e,r,n,t,l,s,h])}var On=[["1","2","3"],["4","5","6"],["7","8","9"],["\u232B","0","."]];function Gt({initialAmount:e="",currency:r="USD",onConfirm:o,onCancel:n}){let t=mt(),[l,s]=useState(e),h=k=>{if(k==="\u232B"){s(S=>S.slice(0,-1));return}if(k==="."){if(l.includes("."))return;s(S=>S===""?"0.":S+".");return}s(S=>{let c=S.indexOf(".");return c!==-1&&S.length-c>2?S:S==="0"&&k!=="."?k:S+k});},a=l===""?"0":l,p=parseFloat(l),b=l!==""&&!isNaN(p)&&p>0;return jsxs(View,{style:t.form.screen,children:[jsx(R,{onPress:n,title:"Enter amount"}),jsxs(View,{style:t.form.content,children:[jsxs(View,{style:t.amount.amountContainer,children:[jsxs(Text,{style:[t.amount.amountText,a==="0"&&t.amount.amountPlaceholder],adjustsFontSizeToFit:true,numberOfLines:1,children:["$",a]}),jsx(Text,{style:t.amount.currencyLabel,children:r.toUpperCase()})]}),jsx(View,{style:t.amount.numpad,children:On.map((k,S)=>jsx(View,{style:t.amount.numpadRow,children:k.map(c=>jsx(TouchableOpacity,{style:t.amount.numpadKey,onPress:()=>h(c),activeOpacity:.6,children:jsx(Text,{style:c==="\u232B"?t.amount.backspaceText:t.amount.numpadKeyText,children:c})},c))},S))}),jsx(TouchableOpacity,{style:[t.form.continueBtn,!b&&t.form.continueBtnDisabled],onPress:()=>b&&o(l),disabled:!b,children:jsx(Text,{style:[t.form.continueBtnText,!b&&t.form.continueBtnTextDisabled],children:"Continue"})})]})]})}function I({size:e=56,strokeWidth:r=3,children:o,iconSize:n,style:t,gradientFrom:l,gradientTo:s}){let{colors:h}=L(),a=l??h.warning,p=s??"#FBBF24",b=useRef(new Animated.Value(0)).current,k=useId(),S=useMemo(()=>`circularProgressGrad_${k.replace(/[^a-zA-Z0-9_-]/g,"")}`,[k]),c=(e-r)/2,d=2*Math.PI*c,_=e/2,w=n??Math.max(0,Math.round(e-r*2-8)),G=(e-w)/2;useEffect(()=>{let U=Animated.loop(Animated.timing(b,{toValue:1,duration:1500,easing:Easing.linear,useNativeDriver:true}));return U.start(),()=>U.stop()},[b]);let m=b.interpolate({inputRange:[0,1],outputRange:["0deg","360deg"]});return jsxs(View,{style:[{width:e,height:e},t],children:[jsx(Animated.View,{style:{position:"absolute",top:0,left:0,width:e,height:e,transform:[{rotate:m}]},children:jsxs(Ot,{width:e,height:e,children:[jsx(Defs,{children:jsxs(LinearGradient,{id:S,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:[jsx(Stop,{offset:"0%",stopColor:a}),jsx(Stop,{offset:"100%",stopColor:p})]})}),jsx(Circle,{cx:_,cy:_,r:c,stroke:`url(#${S})`,strokeWidth:r,fill:"none",strokeDasharray:`${d*.75} ${d*.25}`,strokeLinecap:"round",rotation:-90,origin:`${_}, ${_}`})]})}),o!=null?jsx(View,{style:{position:"absolute",top:G+1.5,left:G,width:w,height:w},children:o}):null]})}var Rt=4;function Jt({initialData:e={},loading:r=false,onComplete:o,onCancel:n}){let t=mt(),{colors:l,fonts:s,components:h}=L(),a=h.input.placeholderColor,[p,b]=useState(1),[k,S]=useState(e.firstName??""),[c,d]=useState(e.lastName??""),[_,w]=useState(e.dobMonth??""),[G,m]=useState(e.dobDay??""),[U,be]=useState(e.dobYear??""),[x,Re]=useState(e.addressLine1??""),[$,Xe]=useState(e.addressLine2??""),[ke,et]=useState(e.city??""),[we,tt]=useState(e.state??""),[Ce,rt]=useState(e.postalCode??""),[N,ot]=useState(e.country??"US"),[de,Ie]=useState(e.idNumber??""),je=useRef(null),Se=useRef(null),Ve=useRef(null),xe=useRef(null),_e=useRef(null),K=useRef(null),Ae=useRef(null),Be=useRef(null),nt=()=>{switch(p){case 1:return k.trim().length>0&&c.trim().length>0;case 2:return _.length===2&&G.length===2&&U.length===4;case 3:return x.trim().length>0&&ke.trim().length>0&&we.trim().length>0&&Ce.trim().length>0;case 4:return de.trim().length>0;default:return false}},Fe=()=>{nt()&&(p<Rt?b(O=>O+1):o({firstName:k,lastName:c,idNumber:de,dobMonth:_,dobDay:G,dobYear:U,addressLine1:x,addressLine2:$,city:ke,state:we,postalCode:Ce,country:N}));},ce=()=>{p>1?b(O=>O-1):n();},Ct=["Enter your name","Enter your date of birth","Enter your address","Enter your SSN"],ar=["Use your full legal name as it appears on your ID.","We use this to verify your identity.","Enter the address associated with your ID.","Your SSN is encrypted and used only for identity verification."],lr=[P.stepCounter,{color:l.foregroundMuted},...s.semibold?[{fontFamily:s.semibold}]:[]];return jsx(KeyboardAvoidingView,{style:t.form.flex,behavior:Platform.OS==="ios"?"padding":void 0,children:jsxs(View,{style:t.form.screen,children:[jsxs(View,{style:P.header,children:[jsx(View,{style:P.headerSide,children:jsx(TouchableOpacity,{style:P.iconButton,onPress:ce,hitSlop:{top:10,bottom:10,left:10,right:10},accessibilityRole:"button",accessibilityLabel:p>1?"Back":"Cancel",children:jsx(Er,{size:20,color:h.header.buttonColor,strokeWidth:2})})}),jsx(View,{style:P.headerCenter,children:jsxs(Text,{style:lr,children:[p," of ",Rt]})}),jsx(View,{style:P.headerSide,children:jsx(TouchableOpacity,{style:P.iconButton,onPress:n,hitSlop:{top:10,bottom:10,left:10,right:10},accessibilityRole:"button",accessibilityLabel:"Close",children:jsx(zt,{size:20,color:h.header.buttonColor,strokeWidth:2})})})]}),jsx(View,{style:P.progressTrack,children:Array.from({length:Rt}).map((O,F)=>jsx(View,{style:[P.progressSegment,{backgroundColor:F<p||F+1===p?l.primary:l.border}]},F))}),jsxs(ScrollView,{style:t.form.flex,contentContainerStyle:P.scrollContent,keyboardShouldPersistTaps:"handled",children:[jsx(Text,{style:t.form.title,children:Ct[p-1]}),jsx(Text,{style:t.form.subtitle,children:ar[p-1]}),p===1&&jsxs(Fragment,{children:[jsx(Pe,{form:t.form,label:"First name",children:jsx(TextInput,{style:t.form.input,placeholder:"Jane",placeholderTextColor:a,value:k,onChangeText:S,autoCapitalize:"words",returnKeyType:"next",onSubmitEditing:()=>je.current?.focus()})}),jsx(Pe,{form:t.form,label:"Last name",children:jsx(TextInput,{ref:je,style:t.form.input,placeholder:"Doe",placeholderTextColor:a,value:c,onChangeText:d,autoCapitalize:"words",returnKeyType:"done",onSubmitEditing:Fe})})]}),p===2&&jsxs(View,{style:P.dobRow,children:[jsxs(View,{style:P.dobCol,children:[jsx(Text,{style:[t.form.fieldLabel,P.dobLabel],children:"Month"}),jsx(TextInput,{style:[t.form.input,P.dobInput],placeholder:"MM",placeholderTextColor:a,value:_,onChangeText:O=>{let F=O.replace(/\D/g,"").slice(0,2);w(F),F.length===2&&Se.current?.focus();},keyboardType:"number-pad",maxLength:2})]}),jsxs(View,{style:P.dobCol,children:[jsx(Text,{style:[t.form.fieldLabel,P.dobLabel],children:"Day"}),jsx(TextInput,{ref:Se,style:[t.form.input,P.dobInput],placeholder:"DD",placeholderTextColor:a,value:G,onChangeText:O=>{let F=O.replace(/\D/g,"").slice(0,2);m(F),F.length===2&&Ve.current?.focus();},keyboardType:"number-pad",maxLength:2})]}),jsxs(View,{style:P.dobColWide,children:[jsx(Text,{style:[t.form.fieldLabel,P.dobLabel],children:"Year"}),jsx(TextInput,{ref:Ve,style:[t.form.input,P.dobInput],placeholder:"YYYY",placeholderTextColor:a,value:U,onChangeText:O=>{let F=O.replace(/\D/g,"").slice(0,4);be(F);},keyboardType:"number-pad",maxLength:4,returnKeyType:"done",onSubmitEditing:Fe})]})]}),p===3&&jsxs(Fragment,{children:[jsx(Pe,{form:t.form,label:"Street address",children:jsx(TextInput,{style:t.form.input,placeholder:"123 Main St",placeholderTextColor:a,value:x,onChangeText:Re,returnKeyType:"next",onSubmitEditing:()=>xe.current?.focus()})}),jsx(Pe,{form:t.form,label:"Apt, suite, etc. (optional)",children:jsx(TextInput,{ref:xe,style:t.form.input,placeholder:"Apt 2",placeholderTextColor:a,value:$,onChangeText:Xe,returnKeyType:"next",onSubmitEditing:()=>_e.current?.focus()})}),jsx(Pe,{form:t.form,label:"City",children:jsx(TextInput,{ref:_e,style:t.form.input,placeholder:"San Francisco",placeholderTextColor:a,value:ke,onChangeText:et,autoCapitalize:"words",returnKeyType:"next",onSubmitEditing:()=>K.current?.focus()})}),jsxs(View,{style:P.row,children:[jsx(View,{style:[t.form.flex,{marginRight:8}],children:jsx(Pe,{form:t.form,label:"State",children:jsx(TextInput,{ref:K,style:t.form.input,placeholder:"NY",placeholderTextColor:a,value:we,onChangeText:O=>tt(O.toUpperCase().slice(0,2)),autoCapitalize:"characters",maxLength:2,returnKeyType:"next",onSubmitEditing:()=>Ae.current?.focus()})})}),jsx(View,{style:t.form.flex,children:jsx(Pe,{form:t.form,label:"ZIP code",children:jsx(TextInput,{ref:Ae,style:t.form.input,placeholder:"11201",placeholderTextColor:a,value:Ce,onChangeText:rt,keyboardType:"number-pad",maxLength:10,returnKeyType:"next",onSubmitEditing:()=>Be.current?.focus()})})})]}),jsx(Pe,{form:t.form,label:"Country",children:jsx(TextInput,{ref:Be,style:t.form.input,placeholder:"US",placeholderTextColor:a,value:N,onChangeText:O=>ot(O.toUpperCase().slice(0,2)),autoCapitalize:"characters",maxLength:2,returnKeyType:"done",onSubmitEditing:Fe})})]}),p===4&&jsxs(Pe,{form:t.form,label:"Social Security Number",children:[jsx(TextInput,{style:t.form.input,placeholder:"123-45-6789",placeholderTextColor:a,value:de,onChangeText:Ie,keyboardType:"number-pad",secureTextEntry:true,returnKeyType:"done",onSubmitEditing:Fe}),jsx(Text,{style:[t.form.hint,P.ssnHint],children:"Your SSN is transmitted securely and never stored on this device."})]})]}),jsx(View,{style:t.form.footer,children:r&&p===Rt?jsx(View,{style:[t.form.continueBtn,t.form.loaderInButton],children:jsx(I,{size:28,strokeWidth:2})}):jsx(TouchableOpacity,{style:[t.form.continueBtn,!nt()&&t.form.continueBtnDisabled],onPress:Fe,disabled:!nt(),children:jsx(Text,{style:[t.form.continueBtnText,!nt()&&t.form.continueBtnTextDisabled],children:p===Rt?"Submit":"Continue"})})})]})})}function Pe({form:e,label:r,children:o}){return jsxs(View,{style:e.fieldWrap,children:[jsx(Text,{style:e.fieldLabel,children:r}),o]})}var P=StyleSheet.create({header:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingTop:60,paddingBottom:16},headerSide:{width:40,alignItems:"center"},headerCenter:{flex:1,alignItems:"center",justifyContent:"center"},iconButton:{width:28,height:28,borderRadius:8,backgroundColor:"transparent",alignItems:"center",justifyContent:"center"},stepCounter:{fontSize:15},progressTrack:{flexDirection:"row",gap:4,marginBottom:32},progressSegment:{flex:1,height:3,borderRadius:2},scrollContent:{flexGrow:1,paddingBottom:16,paddingTop:16},dobRow:{flexDirection:"row",gap:10,marginBottom:20},dobCol:{flex:1},dobColWide:{flex:1.5},dobLabel:{textAlign:"center"},dobInput:{textAlign:"center"},row:{flexDirection:"row"},ssnHint:{marginTop:10,lineHeight:18}});var Nn="https://api.unifold.io",no,jn="pk_test_123";function Kn(){return typeof __DEV__<"u"&&__DEV__&&no?no:Nn}function io(){return Kn()}function Zt(){return jn}var so="",ao;function Xt(e){so=e;}function er(e){ao=e;}function ye(){let e=so||Zt();return e}function he(){return ao??io()}async function tr(){let e=`${he()}/v1/public/onramps/headless/stripe/config`,r=ye(),o=await fetch(e,{method:"GET",headers:{"x-publishable-key":r,"Content-Type":"application/json"}});if(!o.ok)throw new Error(`Failed to load Stripe config: ${o.status}`);let n=await o.json();if(!n?.publishable_key)throw new Error("Missing Stripe publishable key in config response");return n.publishable_key}async function lo(e){let r=await fetch(`${he()}/v1/public/onramps/headless/stripe/oauth/start`,{method:"POST",headers:{"x-publishable-key":ye(),"Content-Type":"application/json"},body:JSON.stringify({email:e})});if(!r.ok)throw new Error(`Failed to create auth intent: ${r.status}`);let o=await r.json();return o.auth_intent_id??o.id}async function co(e){let r=await fetch(`${he()}/v1/public/onramps/headless/stripe/oauth/token`,{method:"POST",headers:{"x-publishable-key":ye(),"Content-Type":"application/json"},body:JSON.stringify({auth_intent_id:e})});if(!r.ok)throw new Error(`Failed to exchange auth intent for tokens: ${r.status}`);return r.json()}async function uo(e,r){let o={crypto_customer_id:e.cryptoCustomerId,payment_token:e.paymentToken,source_amount:e.sourceAmount,source_currency:e.sourceCurrency,destination_currency:e.destinationCurrency,wallet_address:e.walletAddress,destination_network:e.destinationNetwork},n=await fetch(`${he()}/v1/public/onramps/headless/stripe/sessions`,{method:"POST",headers:{"x-publishable-key":ye(),"x-stripe-oauth-token":r,"Content-Type":"application/json"},body:JSON.stringify(o)}),t=await n.text();if(!n.ok)throw new Error(`Failed to create onramp session: ${n.status} ${t}`);return JSON.parse(t)}async function po(e,r){let o=await fetch(`${he()}/v1/public/onramps/headless/stripe/sessions/${e}/confirm`,{method:"POST",headers:{"x-publishable-key":ye(),"x-stripe-oauth-token":r,"Content-Type":"application/json"}}),n=await o.text();if(!o.ok)throw new Error(`Failed to confirm onramp session: ${o.status} ${n}`);return JSON.parse(n)}async function mo(e,r){let o=`${he()}/v1/public/onramps/headless/stripe/customers/${e}`,n=await fetch(o,{method:"GET",headers:{"x-publishable-key":ye(),"x-stripe-oauth-token":r}}),t=await n.text();if(!n.ok)throw new Error(`Failed to get onramp customer: ${n.status} ${t}`);return JSON.parse(t)}async function fo(e,r){let o=`${he()}/v1/public/onramps/headless/stripe/sessions/${e}`,n=await fetch(o,{method:"GET",headers:{"x-publishable-key":ye(),"x-stripe-oauth-token":r}}),t=await n.text();if(!n.ok)throw new Error(`Failed to get onramp session: ${n.status} ${t}`);return JSON.parse(t)}async function yo(e,r){let o=await fetch(`${he()}/v1/public/onramps/headless/stripe/sessions/${e}/quote/refresh`,{method:"POST",headers:{"x-publishable-key":ye(),"x-stripe-oauth-token":r,"Content-Type":"application/json"}});if(!o.ok){let n=await o.text();throw new Error(`Failed to refresh quote: ${o.status} ${n}`)}return o.json()}async function ho(e){if(!e.recipient_address)throw new Error("[Unifold] recipient_address is required for fetchDepositAddress. Pass recipientAddress in your onramp config.");let r={external_user_id:e.external_user_id,destination_chain_type:e.destination_chain_type||"ethereum",destination_chain_id:e.destination_chain_id||"8453",destination_token_address:e.destination_token_address||"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",recipient_address:e.recipient_address,client_metadata:{}},o=await fetch(`${he()}/v1/public/deposit_addresses`,{method:"POST",headers:{accept:"application/json","x-publishable-key":ye(),"Content-Type":"application/json"},body:JSON.stringify(r)});if(!o.ok)throw new Error(`Failed to create deposit address: ${o.status}`);return o.json()}async function go(e){let r=new URLSearchParams({token_address:e.token_address,chain_id:e.chain_id,chain_type:e.chain_type}),o=await fetch(`${he()}/v1/public/onramps/headless/stripe/default_token?${r.toString()}`,{method:"GET",headers:{accept:"application/json","x-publishable-key":ye()}});if(!o.ok)throw new Error(`Failed to fetch default onramp token: ${o.status}`);return o.json()}var qn=5,bo={firstName:"",lastName:"",idNumber:"",dobDay:"",dobMonth:"",dobYear:"",addressLine1:"",addressLine2:"",city:"",state:"",postalCode:"",country:"US"};function rr(e){let r=e?.flowOrder==="amount_first",o=r?"session_params":"email",{configure:n,hasLinkAccount:t,registerLinkUser:l,authorize:s,attachKycInfo:h,presentKycInfoVerification:a,verifyIdentity:p,registerWalletAddress:b,collectPaymentMethod:k,createCryptoPaymentToken:S}=useOnramp(),[c,d]=useState(o),[_,w]=useState(false),[G,m]=useState(""),[U,be]=useState(null),[x,Re]=useState(e?.email??""),[$,Xe]=useState(e?.phone??""),[ke,et]=useState(""),[we,tt]=useState("US"),[Ce,rt]=useState(""),[N,ot]=useState(""),[de,Ie]=useState(false),[je,Se]=useState(false),Ve=useRef(0),xe=useRef(false),_e=useRef(false),K=useRef(false),Ae=useRef(""),Be=useRef(null),[nt,Fe]=useState(bo),[ce,Ct]=useState(e?.defaultWalletAddress??"0x102471956A026866171C44F326e1DfafB6C6e34c"),[ar,lr]=useState(""),[O,F]=useState(e?.defaultNetwork??Onramp.CryptoNetwork.base),[Ke,Or]=useState(e?.defaultSourceAmount??"100"),[Wt,Pr]=useState(e?.defaultSourceCurrency??"usd"),[Mt,dr]=useState(e?.defaultDestinationCurrency??"usdc"),[ue,St]=useState(null),[Fo,Do]=useState(false),ne=useRef(null),it=useRef(false),st=useRef(0),vr=useRef(e?.onComplete),Lr=useRef(e?.onError),Rr=useRef(e?.onStepChange),cr=useRef(o);useEffect(()=>{vr.current=e?.onComplete;},[e?.onComplete]),useEffect(()=>{Lr.current=e?.onError;},[e?.onError]),useEffect(()=>{Rr.current=e?.onStepChange;},[e?.onStepChange]);let ur=useRef(o);useEffect(()=>{c!==ur.current&&(Rr.current?.(c,ur.current),ur.current=c),cr.current=c;},[c]);let f=useCallback((i,u,g)=>{let C={code:i,message:u,step:cr.current,stripeErrorCode:g};be(C),m(""),Lr.current?.(C);},[]),Ir=useCallback(i=>{let u={sessionId:i.id,status:i.status,sourceAmount:i.transaction_details.source_amount,sourceCurrency:i.transaction_details.source_currency,destinationAmount:i.transaction_details.destination_amount,destinationCurrency:i.transaction_details.destination_currency,destinationNetwork:i.transaction_details.destination_network,walletAddress:i.transaction_details.wallet_address,fees:{networkFee:i.transaction_details.fees.network_fee_amount,transactionFee:i.transaction_details.fees.transaction_fee_amount}};return vr.current?.(u),u},[]),T=useCallback(()=>be(null),[]);useEffect(()=>{isPlatformPaySupported().then(Do);},[]),useEffect(()=>(it.current=false,()=>{it.current=true,ne.current&&clearTimeout(ne.current);}),[]),useEffect(()=>{if(!e?.publishableKey||!e?.externalUserId||!e?.recipientAddress||de||je)return;let i=false;Se(true);async function u(){try{let[g,C]=await Promise.all([ho({external_user_id:e.externalUserId,recipient_address:e.recipientAddress,destination_chain_type:e?.destinationChainType,destination_chain_id:e?.destinationChainId,destination_token_address:e?.destinationTokenAddress}),e?.destinationTokenAddress&&e?.destinationChainId&&e?.destinationChainType?go({token_address:e.destinationTokenAddress,chain_id:e.destinationChainId,chain_type:e.destinationChainType}).catch(J=>(console.warn("[useStripeOnramp] fetchDefaultOnrampToken failed, using chain_id fallback:",J?.message),null)):Promise.resolve(null)]);if(i)return;let v=e?.destinationChainType??"ethereum",Q=g.data.find(J=>J.chain_type===v);if(Q?.address){let J=Q.address.toLowerCase();Ct(J),Ae.current=J,Q.recipient_address&&lr(Q.recipient_address);}else console.warn("[resolveWallet] No wallet found for chain_type",v,"in",g.data?.length,"wallets");let re={base:Onramp.CryptoNetwork.base,ethereum:Onramp.CryptoNetwork.ethereum,solana:Onramp.CryptoNetwork.solana,bitcoin:Onramp.CryptoNetwork.bitcoin,polygon:Onramp.CryptoNetwork.polygon},_t={8453:"base",1:"ethereum",137:"polygon"},at=C?.destination_network,Tt="none";if(at&&re[at])F(re[at]),Tt=at+" (from default_token API)";else if(e?.destinationChainId&&_t[e.destinationChainId]){let J=_t[e.destinationChainId];re[J]&&F(re[J]),Tt=J+" (from chain_id "+e.destinationChainId+")";}else re[v]&&(F(re[v]),Tt=v+" (from chain_type fallback)");C?.destination_currency&&dr(C.destination_currency.toLowerCase()),Ie(!0),K.current=!0;}catch(g){console.error("[useStripeOnramp] Failed to resolve wallet:",g?.message),Ie(true),K.current=true;}finally{i||Se(false);}}return u(),()=>{i=true;}},[e?.publishableKey,e?.externalUserId]);let xt=useCallback(async()=>{if(Be.current)return Be.current;let i=n({merchantDisplayName:e?.merchantDisplayName??"Unifold",appearance:{lightColors:{primary:"#2d22a1",contentOnPrimary:"#ffffff",borderSelected:"#07b8b8"},darkColors:{primary:"#800080",contentOnPrimary:"#ffffff",borderSelected:"#526f3e"},style:"ALWAYS_DARK",primaryButton:{cornerRadius:8,height:48}}}).then(u=>(u.error&&(console.error("[useStripeOnramp] configureSDK error:",u.error.message,u.error.code),Be.current=null),u)).catch(u=>{throw console.error("[useStripeOnramp] configureSDK threw:",u?.message??u),Be.current=null,u});return Be.current=i,i},[n,e?.merchantDisplayName]);useEffect(()=>{xt();},[]);let ze=useCallback(async i=>{if(!xe.current){xe.current=true,w(true),T(),m("Creating auth intent...");try{let u=await lo(i);m("Waiting for authorization...");let g=await s(u);if(g?.error){f("authorization_error",g.error.message,g.error.code),d("email");return}if(g?.status==="Denied"){f("authorization_error","Authorization denied by user."),d("email");return}if(g?.status!=="Consented"||!g.customerId){f("authorization_error","Authorization was canceled."),d("email");return}m("Exchanging tokens...");let C=await co(u),v=g.customerId,Q=C.access_token;rt(v),ot(Q),m("Checking verification status...");try{let re=await mo(v,Q),_t=re.verifications.find(Te=>Te.name==="kyc_verified"),at=re.verifications.find(Te=>Te.name==="id_document_verified"),Tt=_t?.status==="verified",J=_t?.status==="rejected",Br=at?.status==="verified",pr=re.provided_fields.includes("first_name");if(m(""),J&&!pr)f("kyc_error","KYC was previously rejected. Please submit with correct info."),d("kyc");else if(J&&pr)d(Br?"wallet":"identity");else if(!Tt&&!pr)d("kyc");else if(!Br)d("identity");else if(K.current&&Ae.current)try{let Te=await b(Ae.current,O);Te?.error?(f("wallet_error",Te.error.message,Te.error.code),d("wallet")):d(r?"payment_method":"session_params");}catch(Te){console.warn("[proceedToAuthorize] Inline wallet registration failed, falling back to wallet step:",Te?.message),d("wallet");}else d("wallet");}catch(re){console.warn("[getOnrampCustomer] failed, defaulting to kyc:",re?.message),m(""),d("kyc");}}catch(u){f("authorization_error",u?.message??String(u)),d("email");}finally{xe.current=false,w(false);}}},[s,T,f,b,O,r]),Eo=useCallback(async()=>{if(Keyboard.dismiss(),!x){f("validation_error","Please enter an email address.");return}w(true),T(),m("");try{m("Configuring...");let i=await xt();if(i.error){f("configuration_error",i.error.message,i.error.code);return}m("Checking Link account...");let u=await t(x);if(u.error){f("authorization_error",u.error.message,u.error.code);return}u.hasLinkAccount?await ze(x):(m(""),d("register"));}catch(i){f("unknown_error",i?.message??String(i));}finally{w(false);}},[T,xt,x,f,t,ze]),Wo=useCallback(async()=>{if(!$){f("validation_error","Please enter your phone number.");return}w(true),T(),m("");try{m("Creating Link account...");let i=await l({email:x,phone:$,fullName:ke||x,country:we||"US"});if(i.error){f("registration_error",i.error.message,i.error.code);return}await ze(x);}catch(i){f("registration_error",i?.message??String(i));}finally{w(false);}},[T,we,x,f,ke,$,l,ze]);useEffect(()=>{if(c!=="email"||!e?.email)return;let i=++Ve.current,u=false,g=()=>u||Ve.current!==i;return e?.phone?(async()=>{w(true),T();try{m("Configuring...");let C=await xt();if(g())return;if(C.error){f("configuration_error",C.error.message,C.error.code);return}m("Checking Link account...");let v=await t(e.email);if(g())return;if(v.error){f("authorization_error",v.error.message,v.error.code);return}if(v.hasLinkAccount){if(g())return;await ze(e.email);}else {m("Creating Link account...");let Q=await l({email:e.email,phone:e.phone,fullName:e.email,country:"US"});if(g())return;if(Q.error){f("registration_error",Q.error.message,Q.error.code);return}if(g())return;await ze(e.email);}}catch(C){g()||f("unknown_error",C?.message??String(C));}finally{w(false);}})():(async()=>{w(true),T();try{m("Configuring...");let C=await xt();if(g())return;if(C.error){f("configuration_error",C.error.message,C.error.code);return}m("Checking Link account...");let v=await t(e.email);if(g())return;if(v.error){f("authorization_error",v.error.message,v.error.code);return}if(v.hasLinkAccount){if(g())return;await ze(e.email);}else {if(g())return;m(""),d("register");}}catch(C){g()||f("unknown_error",C?.message??String(C));}finally{w(false);}})(),()=>{u=true;}},[c,e?.email,e?.phone]);let Mo=useCallback(async i=>{w(true),T(),m(""),Fe(i);try{let u={firstName:i.firstName,lastName:i.lastName,idNumber:i.idNumber||void 0,dateOfBirth:{day:parseInt(i.dobDay,10),month:parseInt(i.dobMonth,10),year:parseInt(i.dobYear,10)},address:{line1:i.addressLine1,line2:i.addressLine2||void 0,city:i.city,state:i.state,postalCode:i.postalCode,country:i.country}},g=await h(u);if(g?.error){if(g.error.stripeErrorCode==="consumer_person_already_verified"){m(""),d("identity");return}f("kyc_error",g.error.message,g.error.stripeErrorCode??g.error.code),d("kyc");return}m("Please review your KYC information...");let C=await a(null);if(C?.error){f("kyc_error",C.error.message,C.error.stripeErrorCode??C.error.code),d("kyc");return}if(C?.status==="UpdateAddress"){f("kyc_error","Please update your address and resubmit."),d("kyc");return}m(""),d("identity");}catch(u){f("kyc_error",u?.message??String(u)),d("kyc");}finally{w(false);}},[h,T,f,a]),Vr=useCallback(async()=>{if(!_e.current){_e.current=true,w(true),T(),m("Launching identity verification...");try{let i=await p();if(i?.error){f("identity_error",i.error.message,i.error.code);return}m(""),d("wallet");}catch(i){f("identity_error",i?.message??String(i));}finally{_e.current=false,w(false);}}},[T,f,p]);useEffect(()=>{c==="identity"&&!_&&Vr();},[c]);let Ar=useCallback(async()=>{if(!ce){f("validation_error","Please enter a wallet address.");return}w(true),T(),m("");try{let i=await b(ce.toLowerCase(),O);if(i?.error){f("wallet_error",i.error.message,i.error.code);return}m(""),d(r?"payment_method":"session_params");}catch(i){f("wallet_error",i?.message??String(i));}finally{w(false);}},[T,f,ce,O,b,r]);useEffect(()=>{c==="wallet"&&de&&ce&&!_&&Ar();},[c,de,ce]);let Nt=useCallback((i,u)=>{it.current=false,st.current=0;let g=async()=>{try{let C=await fo(i,u);if(it.current)return;st.current=0,C.status==="fulfillment_complete"?(St(C),d("success"),Ir(C)):ne.current=setTimeout(g,3e3);}catch(C){if(it.current)return;if(st.current+=1,console.error("[pollSessionStatus] error:",C?.message),st.current>=qn){f("session_error","We couldn't confirm delivery status. Your purchase may still complete \u2014 try again, or close and check your wallet.");return}ne.current=setTimeout(g,5e3);}};ne.current=setTimeout(g,3e3);},[Ir,f]),No=useCallback(()=>{cr.current==="processing"&&(!ue?.id||!N||(T(),st.current=0,ne.current&&(clearTimeout(ne.current),ne.current=null),Nt(ue.id,N)));},[N,T,Nt,ue?.id]),jt=useCallback(async i=>{w(true),T(),m("");try{m("Confirming purchase...");let u=await po(i,N);St(u),d("processing"),m(""),Nt(u.id,N);}finally{w(false);}},[N,T,Nt]),jo=useCallback(async()=>{if(ue)try{await jt(ue.id);}catch(i){f("session_error",i?.message??String(i)),d("quote");}},[f,jt,ue]),Ko=useCallback(async(i=false)=>{if(!Ke||isNaN(Number(Ke))||Number(Ke)<=0){f("validation_error","Please enter a valid amount.");return}w(true),T(),m("");try{let u;if(i){m("Opening Apple Pay...");let Q={applePay:{merchantCountryCode:"US",currencyCode:Wt.toUpperCase(),cartItems:[{paymentType:PlatformPay.PaymentType.Immediate,label:`${Mt.toUpperCase()} purchase + fees`,amount:Ke||"0.00"}]}};u=await k("PlatformPay",Q);}else m("Select a payment method..."),u=await k("Card");if(u?.error){f("payment_error",u.error.message,u.error.code),d("payment_method");return}if(!u?.displayData){f("payment_error","Payment method selection was canceled."),d("payment_method");return}m("Creating payment token...");let g=await S();if(g?.error){f("payment_error",g.error.message,g.error.code),d("payment_method");return}let C=g.cryptoPaymentToken;m("Creating onramp session...");let v=await uo({cryptoCustomerId:Ce,paymentToken:C,sourceAmount:Number(Ke),sourceCurrency:Wt,destinationCurrency:Mt,walletAddress:ce.toLowerCase(),destinationNetwork:O},N);St(v),m(""),i?await jt(v.id):d("quote");}catch(u){f("session_error",u?.message??String(u)),d("payment_method");}finally{w(false);}},[N,T,k,S,Ce,Mt,f,jt,Ke,Wt,ce,O]),zo=useCallback(async()=>{if(ue){w(true),T(),m("");try{let i=await yo(ue.id,N);St(i);}catch(i){f("session_error",i?.message??String(i));}finally{w(false);}}},[N,T,f,ue]),Uo=useCallback(()=>{it.current=true,st.current=0,ne.current&&(clearTimeout(ne.current),ne.current=null),d(o),w(false),m(""),be(null),Re(e?.email??""),Xe(e?.phone??""),et(""),tt("US"),rt(""),ot(""),Ie(false),Se(false),Fe(bo),Ct(e?.recipientAddress??""),F(Onramp.CryptoNetwork.ethereum),Or(e?.defaultSourceAmount??"100"),Pr(e?.defaultSourceCurrency??"usd"),dr(e?.defaultDestinationCurrency??"usdc"),St(null),Ve.current+=1,xe.current=false,_e.current=false;},[e,o]);return {step:c,loading:_,status:G,error:U,email:x,phone:$,fullName:ke,country:we,customerId:Ce,accessToken:N,session:ue,kycData:nt,walletAddress:ce,resolvedRecipientAddress:ar,walletNetwork:O,sourceAmount:Ke,sourceCurrency:Wt,destinationCurrency:Mt,applePaySupported:Fo,walletReady:de,walletLoading:je,setStep:d,setStatus:m,setEmail:Re,setPhone:Xe,setFullName:et,setCountry:tt,setWalletAddress:Ct,setWalletNetwork:F,setSourceAmount:Or,setSourceCurrency:Pr,setDestinationCurrency:dr,checkEmail:Eo,register:Wo,attachKyc:Mo,verifyIdentity:Vr,registerWallet:Ar,collectPaymentMethod:Ko,refreshQuote:zo,confirmCheckout:jo,reset:Uo,clearError:T,resumeFulfillmentPolling:No,amountFirst:r}}function ko({styles:e,placeholderColor:r,hasPrefilledEmail:o,loading:n,error:t,status:l,email:s,setEmail:h,checkEmail:a,onClose:p}){return o?jsxs(View,{style:e.form.screen,children:[jsx(R,{onPress:p}),jsxs(View,{style:e.flow.centered,children:[jsx(I,{size:56,strokeWidth:3}),jsx(D,{error:t,progress:l,loading:n})]})]}):jsx(KeyboardAvoidingView,{style:e.form.flex,behavior:Platform.OS==="ios"?"padding":void 0,children:jsxs(View,{style:e.form.screen,children:[jsx(R,{onPress:p}),jsxs(View,{style:e.form.content,children:[jsx(Text,{style:e.form.title,children:"Enter your email"}),jsx(Text,{style:e.form.subtitle,children:"We'll check if you have a Link account or create one for you."}),jsxs(View,{style:e.form.fieldWrap,children:[jsx(Text,{style:e.form.fieldLabel,children:"Email address"}),jsx(TextInput,{style:e.form.input,placeholder:"jane@example.com",placeholderTextColor:r,keyboardType:"email-address",autoCapitalize:"none",autoCorrect:false,value:s,onChangeText:h,autoFocus:true,returnKeyType:"done",onSubmitEditing:a})]})]}),jsxs(View,{style:e.form.footer,children:[n?jsx(View,{style:[e.form.continueBtn,e.form.loaderInButton],children:jsx(I,{size:28,strokeWidth:2})}):jsx(TouchableOpacity,{style:[e.form.continueBtn,!s&&e.form.continueBtnDisabled],onPress:a,disabled:!s,children:jsx(Text,{style:[e.form.continueBtnText,!s&&e.form.continueBtnTextDisabled],children:"Continue"})}),jsx(D,{error:t,progress:l,loading:n})]})]})})}function Co({styles:e,loading:r,status:o,error:n,verifyIdentity:t,onClose:l}){return jsxs(View,{style:e.form.screen,children:[jsx(R,{onPress:l}),jsxs(View,{style:e.flow.centered,children:[r?jsxs(Fragment,{children:[jsx(View,{style:e.flow.spinnerWrap,children:jsx(I,{size:48,strokeWidth:3})}),jsx(Text,{style:e.flow.heading,children:"Verifying identity"}),jsx(Text,{style:e.flow.sub,children:o||"Preparing identity verification..."})]}):jsxs(Fragment,{children:[jsx(View,{style:e.flow.spinnerWrap,children:jsx(Text,{style:e.flow.idIcon,children:"\u{1FAAA}"})}),jsx(Text,{style:e.flow.heading,children:"Identity verification"}),jsx(Text,{style:e.flow.sub,children:o||"Tap below to continue verification."})]}),jsx(D,{error:n,progress:o,loading:false})]}),!r&&jsx(View,{style:e.form.footer,children:jsx(TouchableOpacity,{style:e.form.continueBtn,onPress:t,children:jsx(Text,{style:e.form.continueBtnText,children:"Continue Verification"})})})]})}function xo({styles:e,loading:r,error:o,status:n,sourceAmount:t,sourceCurrency:l,destinationCurrency:s,walletNetwork:h,applePaySupported:a,collectPaymentMethod:p,onClose:b}){let{colors:k}=L(),S=ut.find(_=>_.value===h)?.label??h,c=t===""||t===void 0?"0":t,d=k.primaryForeground;return jsxs(View,{style:e.form.screen,children:[jsx(R,{onPress:b,title:"How do you want to pay?"}),jsxs(View,{style:e.form.content,children:[jsx(Text,{style:e.pm.payHint,children:"Select a payment method to continue"}),jsxs(View,{style:e.pm.stackWrapper,children:[jsxs(View,{style:[e.pm.swapCard,e.pm.swapCardTop],children:[jsx(Text,{style:e.pm.summaryLabel,children:"You pay"}),jsxs(View,{style:e.pm.swapRow,children:[jsxs(Text,{style:e.pm.swapSpendAmount,numberOfLines:1,adjustsFontSizeToFit:true,children:["$",c]}),jsx(View,{style:e.pm.swapPill,children:jsx(Text,{style:e.pm.swapPillText,children:l.toUpperCase()})})]})]}),jsx(View,{style:e.pm.swapConnectorWrap,pointerEvents:"none",children:jsx(View,{style:e.pm.swapConnectorCircle,children:jsx(Wr,{size:20,color:d,strokeWidth:2.5})})}),jsxs(View,{style:[e.pm.swapCard,e.pm.swapCardBottom],children:[jsx(Text,{style:e.pm.summaryLabel,children:"You receive"}),jsxs(View,{style:e.pm.swapRow,children:[jsx(View,{style:e.pm.swapLeftCol,children:jsx(Text,{style:e.pm.swapReceivePrimary,numberOfLines:1,adjustsFontSizeToFit:true,children:s.toUpperCase()})}),jsx(View,{style:e.pm.swapPill,children:jsx(Text,{style:e.pm.swapPillText,children:S.toUpperCase()})})]})]})]})]}),jsxs(View,{style:e.form.footer,children:[r?jsx(View,{style:[e.form.continueBtn,e.form.loaderInButton],children:jsx(I,{size:28,strokeWidth:2})}):jsxs(Fragment,{children:[a&&jsx(TouchableOpacity,{style:e.pm.applePayBtn,onPress:()=>p(true),children:jsxs(Text,{style:e.pm.applePayBtnText,children:["Pay with ","\uF8FF"," Pay"]})}),jsx(TouchableOpacity,{style:e.form.continueBtn,onPress:()=>p(false),children:jsx(Text,{style:e.form.continueBtnText,children:"Pay with Card"})})]}),jsx(D,{error:o,progress:n,loading:r})]})]})}function To({styles:e,error:r,status:o,loading:n,onClose:t,onRetryStatusCheck:l}){let s=!!r;return jsxs(View,{style:e.form.screen,children:[s?jsx(R,{onPress:t}):jsx(View,{style:Ht}),jsx(View,{style:e.flow.centered,children:r?jsxs(Fragment,{children:[jsx(Text,{style:e.flow.heading,children:"Could not confirm status"}),jsx(Text,{style:e.flow.sub,children:"Your payment may still be completing. Try checking again, or close this screen and verify your wallet balance."})]}):jsxs(Fragment,{children:[jsx(View,{style:e.flow.spinnerWrap,children:jsx(I,{size:48,strokeWidth:3})}),jsx(Text,{style:e.flow.heading,children:"Processing your purchase"}),jsxs(Text,{style:e.flow.sub,children:["Your payment has been confirmed.",`
|
|
2
|
+
`,"We're sending your crypto \u2014 this usually takes less than a minute."]})]})}),jsxs(View,{style:e.form.footer,children:[jsx(D,{error:r,progress:o,loading:n}),r?jsx(TouchableOpacity,{style:e.form.ghostBtn,onPress:l,children:jsx(Text,{style:e.form.ghostBtnText,children:"Check status again"})}):null]})]})}function Po({styles:e,session:r,loading:o,error:n,status:t,confirmCheckout:l,refreshQuote:s,onClose:h}){let a=r.transaction_details,p=new Date(a.quote_expiration*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),b=a.wallet_address.slice(0,6)+"..."+a.wallet_address.slice(-4),k=Ut(a.destination_amount,a.destination_currency);return jsxs(View,{style:e.form.screen,children:[jsx(R,{onPress:h,title:"Review your purchase"}),jsxs(View,{style:e.form.content,children:[jsxs(View,{style:e.quote.heroBox,children:[jsx(Text,{style:e.quote.heroLabel,children:"You receive"}),jsx(Text,{style:e.quote.heroAmount,children:k}),jsxs(Text,{style:e.quote.heroNetwork,children:[a.destination_currency.toUpperCase()," ",$t(a.destination_network)]})]}),jsxs(View,{style:e.quote.card,children:[jsx(De,{quote:e.quote,label:"You pay",value:`${a.source_amount} ${a.source_currency.toUpperCase()}`}),jsx(De,{quote:e.quote,label:"Network fee",value:`$${a.fees.network_fee_amount}`}),jsx(De,{quote:e.quote,label:"Transaction fee",value:`$${a.fees.transaction_fee_amount}`}),jsx(De,{quote:e.quote,label:"Wallet",value:b,mono:true}),jsx(De,{quote:e.quote,label:"Quote expires",value:p,last:true})]})]}),jsxs(View,{style:e.form.footer,children:[o?jsx(View,{style:[e.form.continueBtn,e.form.loaderInButton],children:jsx(I,{size:28,strokeWidth:2})}):jsxs(Fragment,{children:[jsx(TouchableOpacity,{style:e.form.continueBtn,onPress:l,children:jsx(Text,{style:e.form.continueBtnText,children:"Confirm Purchase"})}),jsx(TouchableOpacity,{style:e.form.ghostBtn,onPress:s,children:jsx(Text,{style:e.form.ghostBtnText,children:"Refresh Quote"})})]}),jsx(D,{error:n,progress:t,loading:o})]})]})}function vo({styles:e,hasPrefilledPhone:r,loading:o,error:n,status:t,email:l,phone:s,setPhone:h,register:a,onClose:p}){let b=L();return r?jsxs(View,{style:e.form.screen,children:[jsx(R,{onPress:p}),jsxs(View,{style:e.flow.centered,children:[jsx(I,{size:56,strokeWidth:3}),jsx(D,{error:n,progress:t,loading:o})]})]}):jsx(KeyboardAvoidingView,{style:e.form.flex,behavior:Platform.OS==="ios"?"padding":void 0,children:jsxs(View,{style:e.form.screen,children:[jsx(R,{onPress:p}),jsxs(View,{style:e.form.content,children:[jsx(Text,{style:e.form.title,children:"Enter your phone"}),jsx(Text,{style:e.form.subtitle,children:"We'll send a verification code to confirm your number."}),jsxs(View,{style:e.form.fieldWrap,children:[jsx(Text,{style:e.form.fieldLabel,children:"Phone number"}),jsx(TextInput,{style:e.form.input,placeholder:"+12125551234",placeholderTextColor:b.components.input.placeholderColor,keyboardType:"phone-pad",value:s,onChangeText:k=>h(k.replace(/[^\d+]/g,"").replace(/(?!^)\+/g,"")),autoFocus:true,returnKeyType:"done",onSubmitEditing:a}),jsx(Text,{style:e.form.hint,children:"Include country code, e.g. +12125551234"})]}),jsxs(View,{style:e.form.emailRow,children:[jsx(Text,{style:e.form.emailLabel,children:"Signing up as"}),jsx(Text,{style:e.form.emailValue,children:l})]})]}),jsxs(View,{style:e.form.footer,children:[o?jsx(View,{style:[e.form.continueBtn,e.form.loaderInButton],children:jsx(I,{size:28,strokeWidth:2})}):jsx(TouchableOpacity,{style:[e.form.continueBtn,!s&&e.form.continueBtnDisabled],onPress:a,disabled:!s,children:jsx(Text,{style:[e.form.continueBtnText,!s&&e.form.continueBtnTextDisabled],children:"Continue"})}),jsx(D,{error:n,progress:t,loading:o})]})]})})}function Lo({styles:e,session:r,resolvedRecipientAddress:o,recipientFromConfig:n,onDone:t}){let{colors:l}=L(),s=r.transaction_details,h=Ut(s.destination_amount,s.destination_currency),a=o||n||"";return jsxs(View,{style:e.form.screen,children:[jsx(R,{onPress:t,title:"Purchase complete"}),jsx(View,{style:e.form.content,children:jsxs(ScrollView,{style:e.form.flex,contentContainerStyle:e.flow.successScrollContent,showsVerticalScrollIndicator:false,children:[jsx(View,{style:e.flow.checkCircle,children:jsx(lt,{size:40,color:l.success,strokeWidth:2.5})}),jsx(Text,{style:e.flow.sub,children:"Your crypto is on its way to your wallet."}),jsxs(View,{style:[e.quote.heroBox,e.flow.detailCard],children:[jsx(Text,{style:e.quote.heroLabel,children:"You received"}),jsx(Text,{style:e.quote.heroAmount,children:h}),jsxs(Text,{style:e.quote.heroNetwork,children:[s.destination_currency.toUpperCase()," ",$t(s.destination_network)]})]}),jsxs(View,{style:[e.quote.card,e.flow.detailCard],children:[jsx(Sr,{quote:e.quote,label:"Deposit Address",address:s.wallet_address}),a?jsx(Sr,{quote:e.quote,label:"Recipient Address",address:a,last:true}):jsx(De,{quote:e.quote,label:"Session",value:r.id.slice(0,8)+"..."+r.id.slice(-6),mono:true,last:true})]})]})}),jsx(View,{style:e.form.footer,children:jsx(TouchableOpacity,{style:e.form.continueBtn,onPress:t,children:jsx(Text,{style:e.form.continueBtnText,children:"Done"})})})]})}function Io({styles:e,hasAutoWallet:r,loading:o,error:n,status:t,walletAddress:l,walletNetwork:s,setWalletAddress:h,setWalletNetwork:a,setDestinationCurrency:p,registerWallet:b,onClose:k}){let{components:S}=L();return r?jsxs(View,{style:e.form.screen,children:[jsx(R,{onPress:k}),jsxs(View,{style:e.flow.centered,children:[jsx(I,{size:56,strokeWidth:3}),jsx(D,{error:n,progress:t,loading:o})]})]}):jsx(KeyboardAvoidingView,{style:e.form.flex,behavior:Platform.OS==="ios"?"padding":void 0,children:jsxs(View,{style:e.form.screen,children:[jsx(R,{onPress:k}),jsxs(View,{style:e.form.content,children:[jsx(Text,{style:e.form.title,children:"Your crypto wallet"}),jsx(Text,{style:e.form.subtitle,children:"Enter the wallet address where you'd like to receive your crypto."}),jsxs(View,{style:e.form.fieldWrap,children:[jsx(Text,{style:e.form.fieldLabel,children:"Wallet address"}),jsx(TextInput,{style:[e.form.input,e.wallet.input],placeholder:"0x...",placeholderTextColor:S.input.placeholderColor,autoCapitalize:"none",autoCorrect:false,value:l,onChangeText:h})]}),jsxs(View,{style:e.form.fieldWrap,children:[jsx(Text,{style:e.form.fieldLabel,children:"Network"}),jsx(View,{style:e.wallet.list,children:ut.map(c=>{let d=s===c.value;return jsxs(TouchableOpacity,{style:[e.wallet.row,d&&e.wallet.rowSelected],onPress:()=>{a(c.value),p(c.defaultCrypto);},children:[jsx(View,{style:e.wallet.iconWrap,children:jsx(c.Icon,{size:24})}),jsx(Text,{style:[e.wallet.rowText,d&&e.wallet.rowTextSelected],children:c.label}),d&&jsx(View,{style:e.wallet.checkCircle,children:jsx(lt,{size:14,color:S.container.buttonTitleColor,strokeWidth:2.5})})]},c.value)})})]})]}),jsxs(View,{style:e.form.footer,children:[o?jsx(View,{style:[e.form.continueBtn,e.form.loaderInButton],children:jsx(I,{size:28,strokeWidth:2})}):jsx(TouchableOpacity,{style:[e.form.continueBtn,!l&&e.form.continueBtnDisabled],onPress:b,disabled:!l,children:jsx(Text,{style:[e.form.continueBtnText,!l&&e.form.continueBtnTextDisabled],children:"Continue"})}),jsx(D,{error:n,progress:t,loading:o})]})]})})}function ir({config:e,onComplete:r}){let o=L(),n=mt(),{step:t,loading:l,status:s,error:h,email:a,phone:p,session:b,kycData:k,walletAddress:S,resolvedRecipientAddress:c,walletNetwork:d,sourceAmount:_,sourceCurrency:w,destinationCurrency:G,applePaySupported:m,setStep:U,setEmail:be,setPhone:x,setWalletAddress:Re,setWalletNetwork:$,setSourceAmount:Xe,setDestinationCurrency:ke,checkEmail:et,register:we,attachKyc:tt,verifyIdentity:Ce,registerWallet:rt,collectPaymentMethod:N,refreshQuote:ot,confirmCheckout:de,reset:Ie,resumeFulfillmentPolling:je,amountFirst:Se}=rr(e),Ve=!!e?.email,xe=!!e?.phone,_e=!!e?.publishableKey&&!!e?.externalUserId,K=()=>{Ie(),r?.();};return t==="email"?jsx(ko,{styles:n,placeholderColor:o.components.input.placeholderColor,hasPrefilledEmail:Ve,loading:l,error:h,status:s,email:a,setEmail:be,checkEmail:et,onClose:K}):t==="register"?jsx(vo,{styles:n,hasPrefilledPhone:xe,loading:l,error:h,status:s,email:a,phone:p,setPhone:x,register:we,onClose:K}):t==="kyc"?jsx(Jt,{initialData:k,loading:l,onComplete:tt,onCancel:()=>U("email")}):t==="identity"?jsx(Co,{styles:n,loading:l,status:s,error:h,verifyIdentity:Ce,onClose:K}):t==="wallet"?jsx(Io,{styles:n,hasAutoWallet:_e,loading:l,error:h,status:s,walletAddress:S,walletNetwork:d,setWalletAddress:Re,setWalletNetwork:$,setDestinationCurrency:ke,registerWallet:rt,onClose:K}):t==="session_params"?jsx(Gt,{initialAmount:_,currency:w,onConfirm:Ae=>{Xe(Ae),U(Se?"email":"payment_method");},onCancel:()=>{Se?K():U("wallet");}}):t==="payment_method"?jsx(xo,{styles:n,loading:l,error:h,status:s,sourceAmount:_,sourceCurrency:w,destinationCurrency:G,walletNetwork:d,applePaySupported:m,collectPaymentMethod:N,onClose:K}):t==="quote"&&b?jsx(Po,{styles:n,session:b,loading:l,error:h,status:s,confirmCheckout:de,refreshQuote:ot,onClose:K}):t==="processing"?jsx(To,{styles:n,error:h,status:s,loading:l,onClose:K,onRetryStatusCheck:je}):t==="success"&&b?jsx(Lo,{styles:n,session:b,resolvedRecipientAddress:c,recipientFromConfig:e?.recipientAddress,onDone:()=>{Ie(),r?.();}}):null}var hi="https://api.unifold.io",gi="https://api-staging.unifold.io";function bi(){return typeof __DEV__<"u"&&__DEV__?gi:hi}function sr({publishableKey:e,email:r,phone:o,externalUserId:n,flowOrder:t,destinationChainType:l="ethereum",destinationChainId:s="8453",destinationTokenAddress:h,recipientAddress:a,onComplete:p,onError:b,onStepChange:k,onClose:S,merchantIdentifier:c="merchant.io.unifold",urlScheme:d="unifoldOnramp"}){let _=e||Zt(),[w,G]=useState("loading"),[m,U]=useState(null);useEffect(()=>{let x=false;async function Re(){try{_&&(Xt(_),er(bi()));let $=await tr();if(x||(await initStripe({publishableKey:$,merchantIdentifier:c,urlScheme:d}),x))return;G("ready");}catch($){if(x)return;console.error("[StripeOnramp] Init failed:",$),U($?.message??"Failed to load Stripe configuration"),G("error");}}return Re(),()=>{x=true;}},[_,c,d]);let be=useMemo(()=>{let x={publishableKey:_,externalUserId:n,destinationChainType:l,destinationChainId:s,onComplete:p,onError:b,onStepChange:k};return h&&(x.destinationTokenAddress=h),a&&(x.recipientAddress=a),r&&(x.email=r),o&&(x.phone=o),t&&(x.flowOrder=t),x},[_,n,l,s,h,a,r,o,t,p,b,k]);return w==="error"?jsxs(View,{style:wt.centered,children:[jsx(Text,{style:wt.errorText,children:"Unable to initialize"}),jsx(Text,{style:wt.errorDetail,children:m}),S&&jsx(TouchableOpacity,{style:wt.retryBtn,onPress:S,children:jsx(Text,{style:wt.retryBtnText,children:"Go Back"})})]}):w==="loading"?jsx(View,{style:wt.centered,children:jsx(I,{size:56,strokeWidth:3})}):jsx(ir,{config:be,onComplete:S})}var wt=StyleSheet.create({centered:{flex:1,justifyContent:"center",alignItems:"center",backgroundColor:"#000000",paddingHorizontal:24},errorText:{color:"#FF453A",fontSize:18,fontWeight:"600",marginBottom:8},errorDetail:{color:"#8E8E93",fontSize:14,textAlign:"center",marginBottom:24},retryBtn:{backgroundColor:"#00D924",borderRadius:24,paddingVertical:14,paddingHorizontal:32},retryBtnText:{color:"#000000",fontSize:16,fontWeight:"700"}});function Bo(){let{configure:e}=useOnramp(),r=useRef(false);return useEffect(()=>{r.current||(r.current=true,e({merchantDisplayName:"Unifold",appearance:{lightColors:{primary:"#2d22a1",contentOnPrimary:"#ffffff",borderSelected:"#07b8b8"},darkColors:{primary:"#800080",contentOnPrimary:"#ffffff",borderSelected:"#526f3e"},style:"ALWAYS_DARK",primaryButton:{cornerRadius:8,height:48}}}).then(o=>{o.error&&console.error("[StripeOnrampPreconfigure] error:",o.error.message);}).catch(o=>{console.error("[StripeOnrampPreconfigure] threw:",o?.message);}));},[e]),null}Fr(sr);
|
|
3
|
+
export{Gt as AmountScreen,Jt as KYCWizardScreen,ir as OnrampScreen,sr as StripeOnramp,Bo as StripeOnrampPreconfigure,tr as getStripePublishableKey,er as setStripeOnrampApiUrl,Xt as setStripeOnrampPublishableKey,rr as useStripeOnramp};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unifold/connect-react-native",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.24",
|
|
4
4
|
"description": "Unifold Connect React Native SDK - Crypto deposit and onramp for React Native/Expo",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -47,10 +47,9 @@
|
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/react": "^18.2.0",
|
|
49
49
|
"@types/react-native": "^0.72.0",
|
|
50
|
-
"dts-bundle-generator": "^9.5.1",
|
|
51
50
|
"tsup": "^8.0.0",
|
|
52
51
|
"typescript": "^5.0.0",
|
|
53
|
-
"@unifold/ui-react-native": "0.1.
|
|
52
|
+
"@unifold/ui-react-native": "0.1.16"
|
|
54
53
|
},
|
|
55
54
|
"keywords": [
|
|
56
55
|
"unifold",
|
|
@@ -77,8 +76,7 @@
|
|
|
77
76
|
},
|
|
78
77
|
"homepage": "https://unifold.io",
|
|
79
78
|
"scripts": {
|
|
80
|
-
"build": "tsup &&
|
|
81
|
-
"build:dts": "dts-bundle-generator --config dts-bundle-generator.config.json && cp dist/index.d.ts dist/index.d.mts && cp dist/stripe.d.ts dist/stripe.d.mts",
|
|
79
|
+
"build": "tsup && cp dist/index.d.ts dist/index.d.mts && cp dist/stripe.d.ts dist/stripe.d.mts",
|
|
82
80
|
"dev": "tsup --watch",
|
|
83
81
|
"clean": "rm -rf dist",
|
|
84
82
|
"lint": "eslint \"src/**/*.ts*\"",
|