@unifold/connect-react-native 0.1.23 → 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/stripe.mjs CHANGED
@@ -1 +1,3 @@
1
- import {StripeOnramp}from'@unifold/ui-react-native/stripe';export{AmountScreen,KYCWizardScreen,OnrampScreen,StripeOnramp,StripeOnrampPreconfigure,getStripePublishableKey,setStripeOnrampApiUrl,setStripeOnrampPublishableKey,useStripeOnramp}from'@unifold/ui-react-native/stripe';var n="__unifold_stripe_onramp__";function r(e){globalThis[n]=e;}r(StripeOnramp);
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.23",
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",
@@ -42,15 +42,14 @@
42
42
  },
43
43
  "dependencies": {
44
44
  "@tanstack/react-query": "^5.90.11",
45
- "react-native-qrcode-svg": "^6.3.2",
46
- "@unifold/ui-react-native": "0.1.16"
45
+ "react-native-qrcode-svg": "^6.3.2"
47
46
  },
48
47
  "devDependencies": {
49
48
  "@types/react": "^18.2.0",
50
49
  "@types/react-native": "^0.72.0",
51
- "dts-bundle-generator": "^9.5.1",
52
50
  "tsup": "^8.0.0",
53
- "typescript": "^5.0.0"
51
+ "typescript": "^5.0.0",
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 && pnpm build:dts",
81
- "build:dts": "dts-bundle-generator --config dts-bundle-generator.config.json && cp dist/index.d.ts dist/index.d.mts && cp stripe-entry.d.ts dist/stripe.d.ts && cp stripe-entry.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*\"",